Public Member Functions | |
def | __init__ (self, mimetype, add_generator=True) |
def | rebuild_caches (self, node=None) |
def | clear_caches (self) |
def | build_caches (self, elt) |
def | toXml (self, filename=u'') |
def | xml (self) |
def | contentxml (self) |
def | metaxml (self) |
def | settingsxml (self) |
def | stylesxml (self) |
def | addPicture (self, filename, mediatype=None, content=None) |
def | addPictureFromFile (self, filename, mediatype=None) |
def | addPictureFromString (self, content, mediatype) |
def | addThumbnail (self, filecontent=None) |
def | addObject (self, document, objectname=None) |
def | save (self, outputfile, addsuffix=False) |
def | write (self, outputfp) |
def | createElement (self, elt) |
def | createTextNode (self, data) |
def | createCDATASection (self, data) |
def | getMediaType (self) |
def | getStyleByName (self, name) |
def | getElementsByType (self, elt) |
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 @param mimetype a unicode string @param 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 @param document OpenDocument instance @param objectname unicode string: the name of an object to add @return a unicode string: the folder name in the zipfile the object is stored in.
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 @param filename unicode string: name of a file for Pictures @param mediatype unicode string: name of a media, None by default @param content bytes: content of media, None by default @return a unicode string: the file name of the media, eventually created on the fly
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. @param filesname unicode string: name of an image file @param mediatype unicode string: type of media, dfaults to None @return a unicode string, the name of the created file
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. @param content bytes: content of media @param mediatype unicode string: name of a media @return a unicode string, the name of the created file
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. @param 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 @param 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 @return a bytestream in UTF-8 encoding
Definition at line 274 of file opendocument.py.
def odf.opendocument.OpenDocument.createCDATASection | ( | self, | |
data | |||
) |
Method to create a CDATA section @param data unicode string to include in the CDATA element @return an instance of element.CDATASection
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. @param elt element.Element instance @return an element.Element instance whose grammar is not checked
Definition at line 729 of file opendocument.py.
def odf.opendocument.OpenDocument.createTextNode | ( | self, | |
data | |||
) |
Method to create a text node @param data unicode string to include in the Text element @return an instance of element.Text
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. @param elt instance of a function which returns an element.Element @return a list of istances of element.Element
Definition at line 794 of file opendocument.py.
def odf.opendocument.OpenDocument.getMediaType | ( | self | ) |
Returns the media type @result a unicode string
Definition at line 765 of file opendocument.py.
def odf.opendocument.OpenDocument.getStyleByName | ( | self, | |
name | |||
) |
Finds a style object based on the name @param name unicode string the name of style to search @return a syle as an element.Element instance
Definition at line 776 of file opendocument.py.
def odf.opendocument.OpenDocument.metaxml | ( | self | ) |
Generates the meta.xml file @return a unicode string
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 @param outputfile unicode string: the special name '-' is for stdout; as an alternative, it can be an io.ByteIO instance which contains the ZIP content. @param 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 @return a unicode string
Definition at line 331 of file opendocument.py.
def odf.opendocument.OpenDocument.stylesxml | ( | self | ) |
Generates the styles.xml file @return valid XML code as a unicode string
Definition at line 403 of file opendocument.py.
def odf.opendocument.OpenDocument.toXml | ( | self, | |
filename = u'' |
|||
) |
converts the document to a valid Xml format. @param filename unicode string: the name of a file, defaults to an empty string. @return if filename is not empty, the XML code will be written into it and the method returns None; otherwise the method returns a StringIO containing valid XML. Then a ".getvalue()" should return a unicode 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 @param 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" @return a bytestream in UTF-8 encoding
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.