Public Member Functions | |
__init__ (self, mimetype, add_generator=True) | |
the constructor | |
rebuild_caches (self, node=None) | |
clear_caches (self) | |
Clears internal caches. | |
build_caches (self, elt) | |
Builds internal caches; called from element.py. | |
remove_from_caches (self, elt) | |
Updates internal caches when an element has been removed. | |
toXml (self, filename=u'') | |
converts the document to a valid Xml format. | |
xml (self) | |
Generates the full document as an XML "file". | |
contentxml (self) | |
Generates the content.xml file. | |
metaxml (self) | |
Generates the meta.xml file. | |
settingsxml (self) | |
Generates the settings.xml file. | |
stylesxml (self) | |
Generates the styles.xml file. | |
addPicture (self, filename, mediatype=None, content=None) | |
Add a picture It uses the same convention as OOo, in that it saves the picture in the zipfile in the subdirectory 'Pictures' If passed a file ptr, mediatype must be set. | |
addPictureFromFile (self, filename, mediatype=None) | |
Add a picture It uses the same convention as OOo, in that it saves the picture in the zipfile in the subdirectory 'Pictures'. | |
addPictureFromString (self, content, mediatype) | |
Add a picture from contents given as a Byte string. | |
addThumbnail (self, filecontent=None) | |
Add a fixed thumbnail The thumbnail in the library is big, so this is pretty useless. | |
addObject (self, document, objectname=None) | |
Adds an object (subdocument). | |
save (self, outputfile, addsuffix=False) | |
Save the document under the filename. | |
write (self, outputfp) | |
User API to write the ODF file to an open file descriptor Writes the ZIP format. | |
createElement (self, elt) | |
Inconvenient interface to create an element, but follows XML-DOM. | |
createTextNode (self, data) | |
Method to create a text node. | |
createCDATASection (self, data) | |
Method to create a CDATA section. | |
getMediaType (self) | |
Returns the media type. | |
getStyleByName (self, name) | |
Finds a style object based on the name. | |
getElementsByType (self, elt) | |
Gets elements based on the type, which is function from text.py, draw.py etc. | |
Public Attributes | |
mimetype = mimetype | |
list | childobjects = [] |
str | folder = u"" |
topnode = Document(mimetype=self.mimetype) | |
dict | Pictures = {} |
meta = Meta() | |
scripts = Scripts() | |
fontfacedecls = FontFaceDecls() | |
settings = Settings() | |
styles = Styles() | |
automaticstyles = AutomaticStyles() | |
masterstyles = MasterStyles() | |
body = Body() | |
dict | element_dict = {} |
list | element_dict = [] |
str | _styles_dict = u'M'+name |
manifest = manifest.Manifest() | |
str | _extra = u"META-INF/documentsignatures.xml": continue |
Static Public Attributes | |
thumbnail = None | |
Protected Member Functions | |
_parseoneelement (self, top, stylenamelist) | |
Finds references to style objects in master-styles and add the style name to the style list if not already there. | |
_used_auto_styles (self, segments) | |
Loop through the masterstyles elements, and find the automatic styles that are used. | |
_savePictures (self, anObject, folder) | |
saves pictures contained in an object | |
_saveXmlObjects (self, anObject, folder) | |
save xml objects of an opendocument to some folder | |
Protected Attributes | |
list | _extra = [] |
dict | _styles_dict = {} |
dict | _styles_ooo_fix = {} |
_z = outputfp | |
_now = time.localtime()[:6] | |
Definition at line 123 of file opendocument.py.
odf.opendocument.OpenDocument.__init__ | ( | self, | |
mimetype, | |||
add_generator = True ) |
the constructor
mimetype | a unicode string |
add_generator | a boolean |
Definition at line 131 of file opendocument.py.
|
protected |
Finds references to style objects in master-styles and add the style name to the style list if not already there.
Recursive
Definition at line 363 of file opendocument.py.
|
protected |
saves pictures contained in an object
anObject | instance of OpenDocument containing pictures |
folder | unicode string: place to save pictures |
Definition at line 558 of file opendocument.py.
|
protected |
save xml objects of an opendocument to some folder
anObject | instance of OpenDocument |
folder | unicode string place to save xml objects |
Definition at line 688 of file opendocument.py.
|
protected |
Loop through the masterstyles elements, and find the automatic styles that are used.
These will be added to the automatic-styles
Definition at line 397 of file opendocument.py.
odf.opendocument.OpenDocument.addObject | ( | self, | |
document, | |||
objectname = None ) |
Adds an object (subdocument).
The object must be an OpenDocument class
document | OpenDocument instance |
objectname | unicode string: the name of an object to add |
Definition at line 540 of file opendocument.py.
odf.opendocument.OpenDocument.addPicture | ( | self, | |
filename, | |||
mediatype = None, | |||
content = None ) |
Add a picture It uses the same convention as OOo, in that it saves the picture in the zipfile in the subdirectory 'Pictures' If passed a file ptr, mediatype must be set.
filename | unicode string: name of a file for Pictures |
mediatype | unicode string: name of a media, None by default |
content | bytes: content of media, None by default |
Definition at line 450 of file opendocument.py.
odf.opendocument.OpenDocument.addPictureFromFile | ( | self, | |
filename, | |||
mediatype = None ) |
Add a picture It uses the same convention as OOo, in that it saves the picture in the zipfile in the subdirectory 'Pictures'.
If mediatype is not given, it will be guessed from the filename extension.
filesname | unicode string: name of an image file |
mediatype | unicode string: type of media, dfaults to None |
Definition at line 483 of file opendocument.py.
odf.opendocument.OpenDocument.addPictureFromString | ( | self, | |
content, | |||
mediatype ) |
Add a picture from contents given as a Byte string.
It uses the same convention as OOo, in that it saves the picture in the zipfile in the subdirectory 'Pictures'. The content variable is a string that contains the binary image data. The mediatype indicates the image format.
content | bytes: content of media |
mediatype | unicode string: name of a media |
Definition at line 510 of file opendocument.py.
odf.opendocument.OpenDocument.addThumbnail | ( | self, | |
filecontent = None ) |
Add a fixed thumbnail The thumbnail in the library is big, so this is pretty useless.
filecontent | bytes: the content of a file; defaults to None |
Definition at line 524 of file opendocument.py.
odf.opendocument.OpenDocument.build_caches | ( | self, | |
elt ) |
Builds internal caches; called from element.py.
elt | an element.Element instance |
Definition at line 183 of file opendocument.py.
odf.opendocument.OpenDocument.clear_caches | ( | self | ) |
Clears internal caches.
Definition at line 174 of file opendocument.py.
odf.opendocument.OpenDocument.contentxml | ( | self | ) |
Generates the content.xml file.
Definition at line 286 of file opendocument.py.
odf.opendocument.OpenDocument.createCDATASection | ( | self, | |
data ) |
Method to create a CDATA section.
data | unicode string to include in the CDATA element |
Definition at line 763 of file opendocument.py.
odf.opendocument.OpenDocument.createElement | ( | self, | |
elt ) |
Inconvenient interface to create an element, but follows XML-DOM.
Does not allow attributes as argument, therefore can't check grammar.
elt | element.Element instance |
Definition at line 739 of file opendocument.py.
odf.opendocument.OpenDocument.createTextNode | ( | self, | |
data ) |
Method to create a text node.
data | unicode string to include in the Text element |
Definition at line 753 of file opendocument.py.
odf.opendocument.OpenDocument.getElementsByType | ( | self, | |
elt ) |
Gets elements based on the type, which is function from text.py, draw.py etc.
elt | instance of a function which returns an element.Element |
Definition at line 799 of file opendocument.py.
odf.opendocument.OpenDocument.getMediaType | ( | self | ) |
odf.opendocument.OpenDocument.getStyleByName | ( | self, | |
name ) |
Finds a style object based on the name.
name | unicode string the name of style to search |
Definition at line 782 of file opendocument.py.
odf.opendocument.OpenDocument.metaxml | ( | self | ) |
Generates the meta.xml file.
Definition at line 327 of file opendocument.py.
odf.opendocument.OpenDocument.rebuild_caches | ( | self, | |
node = None ) |
Definition at line 164 of file opendocument.py.
odf.opendocument.OpenDocument.remove_from_caches | ( | self, | |
elt ) |
Updates internal caches when an element has been removed.
elt | an element.Element instance |
Definition at line 204 of file opendocument.py.
odf.opendocument.OpenDocument.save | ( | self, | |
outputfile, | |||
addsuffix = False ) |
Save the document under the filename.
If the filename is '-' then save to stdout
outputfile | unicode string: the special name '-' is for stdout; as an alternative, it can be an io.ByteIO instance which contains the ZIP content. |
addsuffix | boolean: whether to add a suffix or not; defaults to False |
Definition at line 605 of file opendocument.py.
odf.opendocument.OpenDocument.settingsxml | ( | self | ) |
Generates the settings.xml file.
Definition at line 342 of file opendocument.py.
odf.opendocument.OpenDocument.stylesxml | ( | self | ) |
Generates the styles.xml file.
Definition at line 417 of file opendocument.py.
odf.opendocument.OpenDocument.toXml | ( | self, | |
filename = u'' ) |
converts the document to a valid Xml format.
filename | unicode string: the name of a file, defaults to an empty string. |
Definition at line 249 of file opendocument.py.
odf.opendocument.OpenDocument.write | ( | self, | |
outputfp ) |
User API to write the ODF file to an open file descriptor Writes the ZIP format.
outputfp | open file descriptor |
Definition at line 621 of file opendocument.py.
odf.opendocument.OpenDocument.xml | ( | self | ) |
Generates the full document as an XML "file".
Definition at line 271 of file opendocument.py.
|
protected |
Definition at line 137 of file opendocument.py.
str odf.opendocument.OpenDocument._extra = u"META-INF/documentsignatures.xml": continue |
Definition at line 660 of file opendocument.py.
|
protected |
Definition at line 636 of file opendocument.py.
|
protected |
Definition at line 176 of file opendocument.py.
str odf.opendocument.OpenDocument._styles_dict = u'M'+name |
Definition at line 232 of file opendocument.py.
|
protected |
Definition at line 177 of file opendocument.py.
|
protected |
Definition at line 635 of file opendocument.py.
odf.opendocument.OpenDocument.automaticstyles = AutomaticStyles() |
Definition at line 157 of file opendocument.py.
odf.opendocument.OpenDocument.body = Body() |
Definition at line 161 of file opendocument.py.
list odf.opendocument.OpenDocument.childobjects = [] |
Definition at line 136 of file opendocument.py.
dict odf.opendocument.OpenDocument.element_dict = {} |
Definition at line 175 of file opendocument.py.
list odf.opendocument.OpenDocument.element_dict = [] |
Definition at line 191 of file opendocument.py.
str odf.opendocument.OpenDocument.folder = u"" |
Definition at line 138 of file opendocument.py.
odf.opendocument.OpenDocument.fontfacedecls = FontFaceDecls() |
Definition at line 151 of file opendocument.py.
odf.opendocument.OpenDocument.manifest = manifest.Manifest() |
Definition at line 637 of file opendocument.py.
odf.opendocument.OpenDocument.masterstyles = MasterStyles() |
Definition at line 159 of file opendocument.py.
odf.opendocument.OpenDocument.meta = Meta() |
Definition at line 145 of file opendocument.py.
odf.opendocument.OpenDocument.mimetype = mimetype |
Definition at line 135 of file opendocument.py.
dict odf.opendocument.OpenDocument.Pictures = {} |
Definition at line 144 of file opendocument.py.
odf.opendocument.OpenDocument.scripts = Scripts() |
Definition at line 149 of file opendocument.py.
odf.opendocument.OpenDocument.settings = Settings() |
Definition at line 153 of file opendocument.py.
odf.opendocument.OpenDocument.styles = Styles() |
Definition at line 155 of file opendocument.py.
|
static |
Definition at line 124 of file opendocument.py.
Definition at line 139 of file opendocument.py.