Class OfficeDocument

java.lang.Object
writer2latex.xmerge.OfficeDocument
All Implemented Interfaces:
OutputFile, Document, OfficeConstants

public class OfficeDocument extends Object implements Document, OfficeConstants
An implementation of Document for StarOffice documents.
  • Constructor Details

    • 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 Details

    • 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 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.
    • 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.
    • 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.
    • 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.
    • 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.
    • getName

      public String getName()
      Return the name of the Document.
      Specified by:
      getName in interface Document
      Returns:
      The name of Document.
    • getFileName

      public String getFileName()
      Return the file name of the Document, possibly with the standard extension.
      Specified by:
      getFileName in interface OutputFile
      Returns:
      The file name of Document.
    • getFileExtension

      protected String getFileExtension()
      Returns the file extension for this type of Document.
      Returns:
      The file extension of Document.
    • getEmbeddedObjects

      public Iterator getEmbeddedObjects()
      Returns all the embedded objects (graphics, formulae, etc.) present in this document.
      Returns:
      An Iterator of EmbeddedObject objects.
    • 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.
    • addEmbeddedObject

      public void addEmbeddedObject(EmbeddedObject embObj)
      Adds a new embedded object to the document.
      Parameters:
      embObj - An instance of EmbeddedObject.
    • read

      public void read(InputStream is) throws IOException
      Read the Office Document from the given InputStream. FIX3 (HJ): Perform simple type detection to determine package or flat format
      Specified by:
      read in interface Document
      Parameters:
      is - Office document InputStream.
      Throws:
      IOException - If any I/O error occurs.
    • read

      public void read(InputStream is, boolean isZip) throws IOException
      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.
    • getDocumentMimeType

      protected String getDocumentMimeType()
      Method to return the MIME type of the document.
      Returns:
      String The document's MIME type.
    • write

      public void write(OutputStream os) throws IOException
      Write out Office ZIP file format.
      Specified by:
      write in interface OutputFile
      Parameters:
      os - XML OutputStream.
      Throws:
      IOException - If any I/O error occurs.
    • write

      public void write(OutputStream os, boolean isZip) throws IOException
      Write out Office ZIP file format.
      Parameters:
      os - XML OutputStream.
      isZip - boolean
      Throws:
      IOException - If any I/O error occurs.
    • initContentDOM

      public final void initContentDOM() throws IOException
      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() throws IOException
      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() throws IOException
      Initializes a new DOM Document with styles containing minimum OpenOffice XML tags.
      Throws:
      IOException - If any I/O error occurs.
    • getOfficeClassAttribute

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