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__ (self, mimetype, add_generator=True) |
the constructor More... | |
def | rebuild_caches (self, node=None) |
def | clear_caches (self) |
Clears internal caches. More... | |
def | build_caches (self, elt) |
Builds internal caches; called from element.py. More... | |
def | toXml (self, filename=u'') |
converts the document to a valid Xml format. More... | |
def | xml (self) |
Generates the full document as an XML "file". More... | |
def | contentxml (self) |
Generates the content.xml file. More... | |
def | metaxml (self) |
Generates the meta.xml file. More... | |
def | settingsxml (self) |
Generates the settings.xml file. More... | |
def | stylesxml (self) |
Generates the styles.xml file. More... | |
def | 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. More... | |
def | 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'. More... | |
def | addPictureFromString (self, content, mediatype) |
Add a picture from contents given as a Byte string. More... | |
def | addThumbnail (self, filecontent=None) |
Add a fixed thumbnail The thumbnail in the library is big, so this is pretty useless. More... | |
def | addObject (self, document, objectname=None) |
Adds an object (subdocument). More... | |
def | save (self, outputfile, addsuffix=False) |
Save the document under the filename. More... | |
def | write (self, outputfp) |
User API to write the ODF file to an open file descriptor Writes the ZIP format. More... | |
def | createElement (self, elt) |
Inconvenient interface to create an element, but follows XML-DOM. More... | |
def | createTextNode (self, data) |
Method to create a text node. More... | |
def | createCDATASection (self, data) |
Method to create a CDATA section. More... | |
def | getMediaType (self) |
Returns the media type. More... | |
def | getStyleByName (self, name) |
Finds a style object based on the name. More... | |
def | getElementsByType (self, elt) |
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 123 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 132 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 437 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 186 of file opendocument.py.
def odf.opendocument.OpenDocument.clear_caches | ( | self | ) |
Clears internal caches.
Definition at line 176 of file opendocument.py.
def odf.opendocument.OpenDocument.contentxml | ( | self | ) |
Generates the content.xml file.
Definition at line 274 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 755 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 729 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 744 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 794 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 776 of file opendocument.py.
def odf.opendocument.OpenDocument.metaxml | ( | self | ) |
Generates the meta.xml file.
Definition at line 315 of file opendocument.py.
def odf.opendocument.OpenDocument.rebuild_caches | ( | self, | |
node = None |
|||
) |
Definition at line 165 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 331 of file opendocument.py.
def odf.opendocument.OpenDocument.stylesxml | ( | self | ) |
Generates the styles.xml file.
Definition at line 403 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 235 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 612 of file opendocument.py.
def odf.opendocument.OpenDocument.xml | ( | self | ) |
Generates the full document as an XML "file".
Definition at line 258 of file opendocument.py.
odf.opendocument.OpenDocument.automaticstyles |
Definition at line 158 of file opendocument.py.
odf.opendocument.OpenDocument.body |
Definition at line 162 of file opendocument.py.
odf.opendocument.OpenDocument.childobjects |
Definition at line 137 of file opendocument.py.
odf.opendocument.OpenDocument.element_dict |
Definition at line 177 of file opendocument.py.
odf.opendocument.OpenDocument.folder |
Definition at line 139 of file opendocument.py.
odf.opendocument.OpenDocument.fontfacedecls |
Definition at line 152 of file opendocument.py.
odf.opendocument.OpenDocument.manifest |
Definition at line 627 of file opendocument.py.
odf.opendocument.OpenDocument.masterstyles |
Definition at line 160 of file opendocument.py.
odf.opendocument.OpenDocument.meta |
Definition at line 146 of file opendocument.py.
odf.opendocument.OpenDocument.mimetype |
Definition at line 136 of file opendocument.py.
odf.opendocument.OpenDocument.Pictures |
Definition at line 145 of file opendocument.py.
odf.opendocument.OpenDocument.scripts |
Definition at line 150 of file opendocument.py.
odf.opendocument.OpenDocument.settings |
Definition at line 154 of file opendocument.py.
odf.opendocument.OpenDocument.styles |
Definition at line 156 of file opendocument.py.
|
static |
Definition at line 124 of file opendocument.py.
odf.opendocument.OpenDocument.topnode |
Definition at line 140 of file opendocument.py.