Class OfficeDocument

    • Constructor Detail

      • OfficeDocument

        public OfficeDocument​(java.lang.String name)
        Default constructor.
        Parameters:
        name - Document name.
      • OfficeDocument

        public OfficeDocument​(java.lang.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

      • 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 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 org.w3c.dom.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 org.w3c.dom.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​(org.w3c.dom.Node newDom)
        Sets the content tree of the document.
        Parameters:
        newDom - Node containing the new content tree.
      • setMetaDOM

        public void setMetaDOM​(org.w3c.dom.Node newDom)
        Sets the meta tree of the document.
        Parameters:
        newDom - Node containing the new meta tree.
      • setSettingsDOM

        public void setSettingsDOM​(org.w3c.dom.Node newDom)
        Sets the settings tree of the document.
        Parameters:
        newDom - Node containing the new settings tree.
      • setStyleDOM

        public void setStyleDOM​(org.w3c.dom.Node newDom)
        Sets the style tree of the document.
        Parameters:
        newDom - Node containing the new style tree.
      • getStyleDOM

        public org.w3c.dom.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 java.lang.String getName()
        Return the name of the Document.
        Specified by:
        getName in interface Document
        Returns:
        The name of Document.
      • getFileName

        public java.lang.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 java.lang.String getFileExtension()
        Returns the file extension for this type of Document.
        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 Iterator of EmbeddedObject objects.
      • 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 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​(java.io.InputStream is)
                  throws java.io.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:
        java.io.IOException - If any I/O error occurs.
      • read

        public void read​(java.io.InputStream is,
                         boolean isZip)
                  throws java.io.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:
        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.IOException
        Write out Office ZIP file format.
        Specified by:
        write in interface OutputFile
        Parameters:
        os - XML OutputStream.
        Throws:
        java.io.IOException - If any I/O error occurs.
      • write

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

        public final void initContentDOM()
                                  throws java.io.IOException
        Initializes a new DOM Document with 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.IOException
        Initializes a new DOM Document with 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.IOException
        Initializes 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.