Package writer2latex.xmerge
Class OfficeDocument
- java.lang.Object
-
- writer2latex.xmerge.OfficeDocument
-
- All Implemented Interfaces:
OutputFile,Document,OfficeConstants
public class OfficeDocument extends java.lang.Object implements Document, OfficeConstants
An implementation ofDocumentfor StarOffice documents.
-
-
Field Summary
-
Fields inherited from interface writer2latex.xmerge.OfficeConstants
ATTRIBUTE_CONFIG_NAME, ATTRIBUTE_CONFIG_TYPE, ATTRIBUTE_DEFAULT_CELL_STYLE, ATTRIBUTE_FO_FONT_FAMILY, ATTRIBUTE_FO_FONT_FAMILY_GENERIC, ATTRIBUTE_MANIFEST_FILE_PATH, ATTRIBUTE_MANIFEST_FILE_TYPE, ATTRIBUTE_OFFICE_CLASS, ATTRIBUTE_SPACE_COUNT, ATTRIBUTE_STYLE_FONT_PITCH, ATTRIBUTE_STYLE_NAME, ATTRIBUTE_TABLE_BASE_CELL_ADDRESS, ATTRIBUTE_TABLE_BOOLEAN_VALUE, ATTRIBUTE_TABLE_CELL_RANGE_ADDRESS, ATTRIBUTE_TABLE_CURRENCY, ATTRIBUTE_TABLE_DATE_VALUE, ATTRIBUTE_TABLE_EXPRESSION, ATTRIBUTE_TABLE_FORMULA, ATTRIBUTE_TABLE_NAME, ATTRIBUTE_TABLE_NUM_COLUMNS_REPEATED, ATTRIBUTE_TABLE_NUM_ROWS_REPEATED, ATTRIBUTE_TABLE_STRING_VALUE, ATTRIBUTE_TABLE_STYLE_NAME, ATTRIBUTE_TABLE_TIME_VALUE, ATTRIBUTE_TABLE_VALUE, ATTRIBUTE_TABLE_VALUE_TYPE, ATTRIBUTE_TEXT_STYLE_NAME, CELLTYPE_BOOLEAN, CELLTYPE_CURRENCY, CELLTYPE_DATE, CELLTYPE_FLOAT, CELLTYPE_PERCENT, CELLTYPE_STRING, CELLTYPE_TIME, STC_MIME_TYPE, STI_MIME_TYPE, STW_MIME_TYPE, SXC_FILE_EXTENSION, SXC_MIME_TYPE, SXC_TYPE, SXD_MIME_TYPE, SXG_MIME_TYPE, SXI_MIME_TYPE, SXM_MIME_TYPE, SXW_FILE_EXTENSION, SXW_MIME_TYPE, SXW_TYPE, TAG_BOOKMARK, TAG_BOOKMARK_START, TAG_CONFIG_ITEM, TAG_CONFIG_ITEM_MAP_ENTRY, TAG_CONFIG_ITEM_MAP_INDEXED, TAG_CONFIG_ITEM_MAP_NAMED, TAG_CONFIG_ITEM_SET, TAG_HEADING, TAG_HYPERLINK, TAG_LINE_BREAK, TAG_LIST_HEADER, TAG_LIST_ITEM, TAG_MANIFEST_FILE, TAG_MANIFEST_ROOT, TAG_NAMED_EXPRESSIONS, TAG_OFFICE_AUTOMATIC_STYLES, TAG_OFFICE_BODY, TAG_OFFICE_DOCUMENT, TAG_OFFICE_DOCUMENT_CONTENT, TAG_OFFICE_DOCUMENT_META, TAG_OFFICE_DOCUMENT_SETTINGS, TAG_OFFICE_DOCUMENT_STYLES, TAG_OFFICE_FONT_DECLS, TAG_OFFICE_FONT_FACE_DECLS, TAG_OFFICE_MASTER_STYLES, TAG_OFFICE_META, TAG_OFFICE_SETTINGS, TAG_OFFICE_STYLES, TAG_ORDERED_LIST, TAG_PARAGRAPH, TAG_SPACE, TAG_SPAN, TAG_STYLE_FONT_DECL, TAG_TAB_STOP, TAG_TABLE, TAG_TABLE_CELL, TAG_TABLE_COLUMN, TAG_TABLE_NAMED_EXPRESSION, TAG_TABLE_NAMED_RANGE, TAG_TABLE_ROW, TAG_TABLE_SCENARIO, TAG_TEXT, TAG_TEXT_AUTHOR_INITIALS, TAG_TEXT_CREATION_TIME, TAG_TEXT_DATE, TAG_TEXT_EXPRESSION, TAG_TEXT_PAGE_COUNT, TAG_TEXT_PAGE_NUMBER, TAG_TEXT_PAGE_VARIABLE_GET, TAG_TEXT_SEQUENCE, TAG_TEXT_SUBJECT, TAG_TEXT_TEXT_INPUT, TAG_TEXT_TIME, TAG_TEXT_TITLE, TAG_TEXT_USER_FIELD_GET, TAG_TEXT_VARIABLE_GET, TAG_TEXT_VARIABLE_INPUT, TAG_TEXT_VARIABLE_SET, TAG_UNORDERED_LIST
-
-
Constructor Summary
Constructors Constructor Description OfficeDocument(java.lang.String name)Default constructor.OfficeDocument(java.lang.String name, boolean namespaceAware, boolean validating)Constructor with arguments to setnamespaceAwareandvalidatingflags.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEmbeddedObject(EmbeddedObject embObj)Adds a new embedded object to the document.org.w3c.dom.DocumentgetContentDOM()Return a DOMDocumentobject of the content.xml file.protected java.lang.StringgetDocumentMimeType()Method to return the MIME type of the document.EmbeddedObjectgetEmbeddedObject(java.lang.String name)Returns the embedded object corresponding to the name provided.java.util.IteratorgetEmbeddedObjects()Returns all the embedded objects (graphics, formulae, etc.) present in this document.protected java.lang.StringgetFileExtension()Returns the file extension for this type ofDocument.java.lang.StringgetFileName()Return the file name of theDocument, possibly with the standard extension.org.w3c.dom.DocumentgetMetaDOM()Return a DOMDocumentobject of the meta.xml file.java.lang.StringgetName()Return the name of theDocument.protected java.lang.StringgetOfficeClassAttribute()Return the office:class attribute value.org.w3c.dom.DocumentgetSettingsDOM()Return a DOMDocumentobject of the settings.xml file.org.w3c.dom.DocumentgetStyleDOM()Return a DOMDocumentobject of the style.xml file.voidinitContentDOM()Initializes a new DOMDocumentwith the content containing minimum OpenOffice XML tags.voidinitSettingsDOM()Initializes a new DOMDocumentwith 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(java.io.InputStream is)Read the OfficeDocumentfrom the givenInputStream.voidread(java.io.InputStream is, boolean isZip)Read the OfficeDocumentfrom the givenInputStream.voidsetContentDOM(org.w3c.dom.Node newDom)Sets the content tree of the document.voidsetMetaDOM(org.w3c.dom.Node newDom)Sets the meta tree of the document.voidsetSettingsDOM(org.w3c.dom.Node newDom)Sets the settings tree of the document.voidsetStyleDOM(org.w3c.dom.Node newDom)Sets the style tree of the document.voidwrite(java.io.OutputStream os)Write out Office ZIP file format.voidwrite(java.io.OutputStream os, boolean isZip)Write out Office ZIP file format.
-
-
-
Constructor Detail
-
OfficeDocument
public OfficeDocument(java.lang.String name)
Default constructor.- Parameters:
name-Documentname.
-
OfficeDocument
public OfficeDocument(java.lang.String name, boolean namespaceAware, boolean validating)Constructor with arguments to setnamespaceAwareandvalidatingflags.- Parameters:
name-Documentname (may or may not contain extension).namespaceAware- Value fornamespaceAwareflag.validating- Value forvalidatingflag.
-
-
Method Detail
-
isPackageFormat
public boolean isPackageFormat()
Package or flat format?- Returns:
- true if the document is in package format, false if it's flat xml
-
getContentDOM
public org.w3c.dom.Document getContentDOM()
Return a DOMDocumentobject of the content.xml file. Note that a content DOM is not created when the constructor is called. So, either thereadmethod or theinitContentDOMmethod will need to be called ahead on this object before calling this method.- Returns:
- DOM
Documentobject.
-
getMetaDOM
public org.w3c.dom.Document getMetaDOM()
Return a DOMDocumentobject of the meta.xml file. Note that a content DOM is not created when the constructor is called. So, either thereadmethod or theinitContentDOMmethod will need to be called ahead on this object before calling this method.- Returns:
- DOM
Documentobject.
-
getSettingsDOM
public org.w3c.dom.Document getSettingsDOM()
Return a DOMDocumentobject of the settings.xml file. Note that a content DOM is not created when the constructor is called. So, either thereadmethod or theinitContentDOMmethod will need to be called ahead on this object before calling this method.- Returns:
- DOM
Documentobject.
-
setContentDOM
public void setContentDOM(org.w3c.dom.Node newDom)
Sets the content tree of the document.- Parameters:
newDom-Nodecontaining the new content tree.
-
setMetaDOM
public void setMetaDOM(org.w3c.dom.Node newDom)
Sets the meta tree of the document.- Parameters:
newDom-Nodecontaining the new meta tree.
-
setSettingsDOM
public void setSettingsDOM(org.w3c.dom.Node newDom)
Sets the settings tree of the document.- Parameters:
newDom-Nodecontaining the new settings tree.
-
setStyleDOM
public void setStyleDOM(org.w3c.dom.Node newDom)
Sets the style tree of the document.- Parameters:
newDom-Nodecontaining the new style tree.
-
getStyleDOM
public org.w3c.dom.Document getStyleDOM()
Return a DOMDocumentobject 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 theInputStream, areadmethod may or may not build a style DOM. When creating a new style DOM, call theinitStyleDOMmethod first.- Returns:
- DOM
Documentobject.
-
getName
public java.lang.String getName()
Return the name of theDocument.
-
getFileName
public java.lang.String getFileName()
Return the file name of theDocument, possibly with the standard extension.- Specified by:
getFileNamein interfaceOutputFile- Returns:
- The file name of
Document.
-
getFileExtension
protected java.lang.String getFileExtension()
Returns the file extension for this type ofDocument.- Returns:
- The file extension of
Document.
-
getEmbeddedObjects
public java.util.Iterator getEmbeddedObjects()
Returns all the embedded objects (graphics, formulae, etc.) present in this document.- Returns:
- An
IteratorofEmbeddedObjectobjects.
-
getEmbeddedObject
public EmbeddedObject getEmbeddedObject(java.lang.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
EmbeddedObjectinstance representing the named object.
-
addEmbeddedObject
public void addEmbeddedObject(EmbeddedObject embObj)
Adds a new embedded object to the document.- Parameters:
embObj- An instance ofEmbeddedObject.
-
read
public void read(java.io.InputStream is) throws java.io.IOExceptionRead the OfficeDocumentfrom the givenInputStream. FIX3 (HJ): Perform simple type detection to determine package or flat format
-
read
public void read(java.io.InputStream is, boolean isZip) throws java.io.IOExceptionRead the OfficeDocumentfrom the givenInputStream.- Parameters:
is- Office documentInputStream.isZip-booleanIdentifies whether a file is zipped or not- Throws:
java.io.IOException- If any I/O error occurs.
-
getDocumentMimeType
protected java.lang.String getDocumentMimeType()
Method to return the MIME type of the document.- Returns:
- String The document's MIME type.
-
write
public void write(java.io.OutputStream os) throws java.io.IOExceptionWrite out Office ZIP file format.- Specified by:
writein interfaceOutputFile- Parameters:
os- XMLOutputStream.- Throws:
java.io.IOException- If any I/O error occurs.
-
write
public void write(java.io.OutputStream os, boolean isZip) throws java.io.IOExceptionWrite out Office ZIP file format.- Parameters:
os- XMLOutputStream.isZip-boolean- Throws:
java.io.IOException- If any I/O error occurs.
-
initContentDOM
public final void initContentDOM() throws java.io.IOExceptionInitializes a new DOMDocumentwith the content containing minimum OpenOffice XML tags.- Throws:
java.io.IOException- If any I/O error occurs.
-
initSettingsDOM
public final void initSettingsDOM() throws java.io.IOExceptionInitializes a new DOMDocumentwith the content containing minimum OpenOffice XML tags.- Throws:
java.io.IOException- If any I/O error occurs.
-
initStyleDOM
public final void initStyleDOM() throws java.io.IOExceptionInitializes a new DOM Document with styles containing minimum OpenOffice XML tags.- Throws:
java.io.IOException- If any I/O error occurs.
-
getOfficeClassAttribute
protected java.lang.String getOfficeClassAttribute()
Return the office:class attribute value.- Returns:
- The attribute value.
-
-