writer2latex.xmerge

Class OfficeDocument

public class OfficeDocument extends Object implements Document, OfficeConstants

An implementation of Document for StarOffice documents.
Constructor Summary
OfficeDocument(String name)
Default constructor.
OfficeDocument(String name, boolean namespaceAware, boolean validating)
Constructor with arguments to set namespaceAware and validating flags.
Method Summary
voidaddEmbeddedObject(EmbeddedObject embObj)
Adds a new embedded object to the document.
DocumentgetContentDOM()
Return a DOM Document object of the content.xml file.
protected StringgetDocumentMimeType()
Method to return the MIME type of the document.
EmbeddedObjectgetEmbeddedObject(String name)
Returns the embedded object corresponding to the name provided.
IteratorgetEmbeddedObjects()
Returns all the embedded objects (graphics, formulae, etc.) present in this document.
protected StringgetFileExtension()
Returns the file extension for this type of Document.
StringgetFileName()
Return the file name of the Document, possibly with the standard extension.
DocumentgetMetaDOM()
Return a DOM Document object of the meta.xml file.
StringgetName()
Return the name of the Document.
protected StringgetOfficeClassAttribute()
Return the office:class attribute value.
DocumentgetSettingsDOM()
Return a DOM Document object of the settings.xml file.
DocumentgetStyleDOM()
Return a DOM Document object of the style.xml file.
voidinitContentDOM()
Initializes a new DOM Document with the content containing minimum OpenOffice XML tags.
voidinitSettingsDOM()
Initializes a new DOM Document with the content containing minimum OpenOffice XML tags.
voidinitStyleDOM()
Initializes a new DOM Document with styles containing minimum OpenOffice XML tags.
booleanisPackageFormat()
Package or flat format?
voidread(InputStream is)
Read the Office Document from the given InputStream.
voidread(InputStream is, boolean isZip)
Read the Office Document from the given InputStream.
voidsetContentDOM(Node newDom)
Sets the content tree of the document.
voidsetMetaDOM(Node newDom)
Sets the meta tree of the document.
voidsetSettingsDOM(Node newDom)
Sets the settings tree of the document.
voidsetStyleDOM(Node newDom)
Sets the style tree of the document.
voidwrite(OutputStream os)
Write out Office ZIP file format.
voidwrite(OutputStream os, boolean isZip)
Write out Office ZIP file format.

Constructor Detail

OfficeDocument

public OfficeDocument(String name)
Default constructor.

Parameters: name Document name.

OfficeDocument

public OfficeDocument(String name, boolean namespaceAware, boolean validating)
Constructor with arguments to set namespaceAware and validating flags.

Parameters: name Document name (may or may not contain extension). namespaceAware Value for namespaceAware flag. validating Value for validating flag.

Method Detail

addEmbeddedObject

public void addEmbeddedObject(EmbeddedObject embObj)
Adds a new embedded object to the document.

Parameters: embObj An instance of EmbeddedObject.

getContentDOM

public Document getContentDOM()
Return a DOM Document object of the content.xml file. Note that a content DOM is not created when the constructor is called. So, either the read method or the initContentDOM method will need to be called ahead on this object before calling this method.

Returns: DOM Document object.

getDocumentMimeType

protected String getDocumentMimeType()
Method to return the MIME type of the document.

Returns: String The document's MIME type.

getEmbeddedObject

public EmbeddedObject getEmbeddedObject(String name)
Returns the embedded object corresponding to the name provided. The name should be stripped of any preceding path characters, such as '/', '.' or '#'.

Parameters: name The name of the embedded object to retrieve.

Returns: An EmbeddedObject instance representing the named object.

getEmbeddedObjects

public Iterator getEmbeddedObjects()
Returns all the embedded objects (graphics, formulae, etc.) present in this document.

Returns: An Iterator of EmbeddedObject objects.

getFileExtension

protected String getFileExtension()
Returns the file extension for this type of Document.

Returns: The file extension of Document.

getFileName

public String getFileName()
Return the file name of the Document, possibly with the standard extension.

Returns: The file name of Document.

getMetaDOM

public Document getMetaDOM()
Return a DOM Document object of the meta.xml file. Note that a content DOM is not created when the constructor is called. So, either the read method or the initContentDOM method will need to be called ahead on this object before calling this method.

Returns: DOM Document object.

getName

public String getName()
Return the name of the Document.

Returns: The name of Document.

getOfficeClassAttribute

protected String getOfficeClassAttribute()
Return the office:class attribute value.

Returns: The attribute value.

getSettingsDOM

public Document getSettingsDOM()
Return a DOM Document object of the settings.xml file. Note that a content DOM is not created when the constructor is called. So, either the read method or the initContentDOM method will need to be called ahead on this object before calling this method.

Returns: DOM Document object.

getStyleDOM

public Document getStyleDOM()
Return a DOM Document object of the style.xml file. Note that this may return null if there is no style DOM. Note that a style DOM is not created when the constructor is called. Depending on the InputStream, a read method may or may not build a style DOM. When creating a new style DOM, call the initStyleDOM method first.

Returns: DOM Document object.

initContentDOM

public final void initContentDOM()
Initializes a new DOM Document with the content containing minimum OpenOffice XML tags.

Throws: IOException If any I/O error occurs.

initSettingsDOM

public final void initSettingsDOM()
Initializes a new DOM Document with the content containing minimum OpenOffice XML tags.

Throws: IOException If any I/O error occurs.

initStyleDOM

public final void initStyleDOM()
Initializes a new DOM Document with styles containing minimum OpenOffice XML tags.

Throws: IOException If any I/O error occurs.

isPackageFormat

public boolean isPackageFormat()
Package or flat format?

Returns: true if the document is in package format, false if it's flat xml

read

public void read(InputStream is)
Read the Office Document from the given InputStream. FIX3 (HJ): Perform simple type detection to determine package or flat format

Parameters: is Office document InputStream.

Throws: IOException If any I/O error occurs.

read

public void read(InputStream is, boolean isZip)
Read the Office Document from the given InputStream.

Parameters: is Office document InputStream. isZip boolean Identifies whether a file is zipped or not

Throws: IOException If any I/O error occurs.

setContentDOM

public void setContentDOM(Node newDom)
Sets the content tree of the document.

Parameters: newDom Node containing the new content tree.

setMetaDOM

public void setMetaDOM(Node newDom)
Sets the meta tree of the document.

Parameters: newDom Node containing the new meta tree.

setSettingsDOM

public void setSettingsDOM(Node newDom)
Sets the settings tree of the document.

Parameters: newDom Node containing the new settings tree.

setStyleDOM

public void setStyleDOM(Node newDom)
Sets the style tree of the document.

Parameters: newDom Node containing the new style tree.

write

public void write(OutputStream os)
Write out Office ZIP file format.

Parameters: os XML OutputStream.

Throws: IOException If any I/O error occurs.

write

public void write(OutputStream os, boolean isZip)
Write out Office ZIP file format.

Parameters: os XML OutputStream. isZip boolean

Throws: IOException If any I/O error occurs.