A class to hold the content of an OpenDocument document Use the xml method to write the XML source to the screen or to a file. More...
Public Member Functions | |
def | __init__ |
the constructor More... | |
def | rebuild_caches |
def | clear_caches |
Clears internal caches. More... | |
def | build_caches |
Builds internal caches; called from element.py. More... | |
def | toXml |
converts the document to a valid Xml format. More... | |
def | xml |
Generates the full document as an XML "file". More... | |
def | contentxml |
Generates the content.xml file. More... | |
def | metaxml |
Generates the meta.xml file. More... | |
def | settingsxml |
Generates the settings.xml file. More... | |
def | stylesxml |
Generates the styles.xml file. More... | |
def | addPicture |
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. More... | |
def | addPictureFromFile |
Add a picture It uses the same convention as OOo, in that it saves the picture in the zipfile in the subdirectory 'Pictures'. More... | |
def | addPictureFromString |
Add a picture from contents given as a Byte string. More... | |
def | addThumbnail |
Add a fixed thumbnail The thumbnail in the library is big, so this is pretty useless. More... | |
def | addObject |
Adds an object (subdocument). More... | |
def | save |
Save the document under the filename. More... | |
def | write |
User API to write the ODF file to an open file descriptor Writes the ZIP format. More... | |
def | createElement |
Inconvenient interface to create an element, but follows XML-DOM. More... | |
def | createTextNode |
Method to create a text node. More... | |
def | createCDATASection |
Method to create a CDATA section. More... | |
def | getMediaType |
Returns the media type. More... | |
def | getStyleByName |
Finds a style object based on the name. More... | |
def | getElementsByType |
Gets elements based on the type, which is function from text.py, draw.py etc. More... | |
Public Attributes | |
mimetype | |
childobjects | |
folder | |
topnode | |
Pictures | |
meta | |
scripts | |
fontfacedecls | |
settings | |
styles | |
automaticstyles | |
masterstyles | |
body | |
element_dict | |
manifest | |
Static Public Attributes | |
thumbnail = None | |
A class to hold the content of an OpenDocument document Use the xml method to write the XML source to the screen or to a file.
Example of use: d = OpenDocument(mimetype); fd.write(d.xml())
Definition at line 122 of file opendocument.py.
def 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.
def 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 531 of file opendocument.py.
def 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 436 of file opendocument.py.
def 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 471 of file opendocument.py.
def 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 499 of file opendocument.py.
def 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 514 of file opendocument.py.
def odf.opendocument.OpenDocument.build_caches | ( | self, | |
elt | |||
) |
Builds internal caches; called from element.py.
elt | an element.Element instance |
Definition at line 185 of file opendocument.py.
def odf.opendocument.OpenDocument.clear_caches | ( | self | ) |
Clears internal caches.
Definition at line 175 of file opendocument.py.
def odf.opendocument.OpenDocument.contentxml | ( | self | ) |
Generates the content.xml file.
Definition at line 273 of file opendocument.py.
def odf.opendocument.OpenDocument.createCDATASection | ( | self, | |
data | |||
) |
Method to create a CDATA section.
data | unicode string to include in the CDATA element |
Definition at line 759 of file opendocument.py.
def 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 733 of file opendocument.py.
def odf.opendocument.OpenDocument.createTextNode | ( | self, | |
data | |||
) |
Method to create a text node.
data | unicode string to include in the Text element |
Definition at line 748 of file opendocument.py.
def 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 798 of file opendocument.py.
def odf.opendocument.OpenDocument.getMediaType | ( | self | ) |
def 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 780 of file opendocument.py.
def odf.opendocument.OpenDocument.metaxml | ( | self | ) |
Generates the meta.xml file.
Definition at line 314 of file opendocument.py.
def odf.opendocument.OpenDocument.rebuild_caches | ( | self, | |
node = None |
|||
) |
Definition at line 164 of file opendocument.py.
def 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 595 of file opendocument.py.
def odf.opendocument.OpenDocument.settingsxml | ( | self | ) |
Generates the settings.xml file.
Definition at line 330 of file opendocument.py.
def odf.opendocument.OpenDocument.stylesxml | ( | self | ) |
Generates the styles.xml file.
Definition at line 402 of file opendocument.py.
def 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 234 of file opendocument.py.
def 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 614 of file opendocument.py.
def odf.opendocument.OpenDocument.xml | ( | self | ) |
Generates the full document as an XML "file".
Definition at line 257 of file opendocument.py.
odf.opendocument.OpenDocument.automaticstyles |
Definition at line 157 of file opendocument.py.
odf.opendocument.OpenDocument.body |
Definition at line 161 of file opendocument.py.
odf.opendocument.OpenDocument.childobjects |
Definition at line 136 of file opendocument.py.
odf.opendocument.OpenDocument.element_dict |
Definition at line 176 of file opendocument.py.
odf.opendocument.OpenDocument.folder |
Definition at line 138 of file opendocument.py.
odf.opendocument.OpenDocument.fontfacedecls |
Definition at line 151 of file opendocument.py.
odf.opendocument.OpenDocument.manifest |
Definition at line 631 of file opendocument.py.
odf.opendocument.OpenDocument.masterstyles |
Definition at line 159 of file opendocument.py.
odf.opendocument.OpenDocument.meta |
Definition at line 145 of file opendocument.py.
odf.opendocument.OpenDocument.mimetype |
Definition at line 135 of file opendocument.py.
odf.opendocument.OpenDocument.Pictures |
Definition at line 144 of file opendocument.py.
odf.opendocument.OpenDocument.scripts |
Definition at line 149 of file opendocument.py.
odf.opendocument.OpenDocument.settings |
Definition at line 153 of file opendocument.py.
odf.opendocument.OpenDocument.styles |
Definition at line 155 of file opendocument.py.
|
static |
Definition at line 123 of file opendocument.py.
odf.opendocument.OpenDocument.topnode |
Definition at line 139 of file opendocument.py.