Package com.independentsoft.office.odf

# Class Document

java.lang.Object
com.independentsoft.office.odf.Document

Direct Known Subclasses:
  `Chart`, `Spreadsheet`, `TextDocument`

public abstract class Document extends Object
Represents a document in OpenDocument format.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected CommonStyles`
  `commonStyles`
  `protected FileTable`
  `customFileTable`
  `protected FileTable`
  `inputFileTable`
  `protected boolean`
  `isTemplate`
  `protected Manifest`
  `manifest`
  `protected MetaData`
  `metaData`
  `protected String`
  `mimeType`
  `protected ZipOutputStream`
  `outputStream`
  `protected Settings`
  `settings`
  `protected Charset`
  `utf8`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Document()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `addFile​(String filePath, byte[] buffer)`
  `protected void`
  `addFile​(String filePath, String file)`
  `protected void`
  `addManifestEntry​(Manifest currentManifest, Manifest originalManifest, String path)`
  Adds a manifest:file-entry for a package part written from the in-memory model (image, OLE object, embedded document).
  `protected void`
  `addMimeTypeFile​(String mimeTypeValue)`
  `List<AttributedText>`
  `getAttributedTexts()`
  Gets the attributed texts.
  `abstract byte[]`
  `getBytes()`
  Gets the bytes.
  `CommonStyles`
  `getCommonStyles()`
  Gets the common styles.
  `List<Configuration>`
  `getConfigurations()`
  Gets the configurations.
  `abstract List<IContentElement>`
  `getContentElements()`
  Gets the content elements.
  `Date`
  `getCreationDate()`
  Gets the creation date.
  `String`
  `getCreator()`
  Gets the creator.
  `FileTable`
  `getCustomFileTable()`
  Gets the custom file table.
  `String`
  `getDescription()`
  Gets the description.
  `int`
  `getEditingCycles()`
  Gets the editing cycles.
  `String`
  `getEditingDuration()`
  Gets the editing duration.
  `List<Field>`
  `getFields()`
  Gets the fields.
  `FileTable`
  `getFileInputTable()`
  Gets the file input table.
  `String`
  `getGenerator()`
  Gets the generator.
  `List<Heading>`
  `getHeadings()`
  Gets the headings.
  `List<Image>`
  `getImages()`
  Gets the images.
  `String`
  `getInitialCreator()`
  Gets the initial creator.
  `FileTable`
  `getInputFileTable()`
  Gets the input file table.
  `abstract InputStream`
  `getInputStream()`
  Gets the input stream.
  `String`
  `getKeywords()`
  Gets the keywords.
  `String`
  `getLanguage()`
  Gets the language.
  `Date`
  `getLastModified()`
  Gets the last modified.
  `List<List>`
  `getLists()`
  Gets the lists.
  `Manifest`
  `getManifest()`
  Gets the manifest.
  `MetaData`
  `getMetaData()`
  Gets the meta data.
  `String`
  `getMimeType()`
  Gets the mime type.
  `List<Paragraph>`
  `getParagraphs()`
  Gets the paragraphs.
  `protected List<String>`
  `getPreservedPackageParts​(SharedObjects sharedObjects)`
  Returns the paths of original package parts that this writer does NOT regenerate (thumbnails, layout-cache, manifest.rdf, unreferenced pictures, ...) so they can be carried over into the saved package instead of being dropped.
  `Date`
  `getPrintDate()`
  Gets the prints the date.
  `String`
  `getPrintedBy()`
  Gets the printed by.
  `List<Section>`
  `getSections()`
  Gets the sections.
  `DocumentStatistic`
  `getStatistic()`
  Gets the statistic.
  `String`
  `getSubject()`
  Gets the subject.
  `List<Table>`
  `getTables()`
  Gets the tables.
  `Template`
  `getTemplate()`
  Gets the template.
  `List<Text>`
  `getTexts()`
  Gets the texts.
  `String`
  `getTitle()`
  Gets the title.
  `List<UserDefinedMetadataElement>`
  `getUserDefinedMetadataElements()`
  Gets the user defined metadata elements.
  `boolean`
  `isTemplate()`
  Checks if is template.
  `abstract void`
  `open​(InputStream stream)`
  Open.
  `abstract void`
  `open​(String file)`
  Open.
  `protected void`
  `openImplementation​(InputStream stream)`
  `void`
  `replace​(String oldText, String newText)`
  Replace.
  `void`
  `replace​(String oldText, String newText, boolean includeHeaderFooter)`
  Replace.
  `abstract void`
  `save​(OutputStream stream)`
  Save.
  `abstract void`
  `save​(String file)`
  Save.
  `abstract void`
  `save​(String file, boolean overwrite)`
  Save.
  `void`
  `setCreationDate​(Date creationDate)`
  Sets the creation date.
  `void`
  `setCreator​(String creator)`
  Sets the creator.
  `void`
  `setDescription​(String description)`
  Sets the description.
  `void`
  `setEditingCycles​(int editingCycles)`
  Sets the editing cycles.
  `void`
  `setEditingDuration​(String editingDuration)`
  Sets the editing duration.
  `void`
  `setInitialCreator​(String initialCreator)`
  Sets the initial creator.
  `void`
  `setKeywords​(String keywords)`
  Sets the keywords.
  `void`
  `setLanguage​(String language)`
  Sets the language.
  `void`
  `setLastModified​(Date lastModified)`
  Sets the last modified.
  `void`
  `setMimeType​(String mimeType)`
  Sets the mime type.
  `void`
  `setPrintDate​(Date printDate)`
  Sets the prints the date.
  `void`
  `setPrintedBy​(String printedBy)`
  Sets the printed by.
  `void`
  `setStatistic​(DocumentStatistic statistic)`
  Sets the statistic.
  `void`
  `setSubject​(String subject)`
  Sets the subject.
  `void`
  `setTemplate​(boolean isTemplate)`
  Sets the template.
  `void`
  `setTemplate​(Template template)`
  Sets the template.
  `void`
  `setTitle​(String title)`
  Sets the title.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### utf8

    protected Charset utf8

  - ### outputStream

    protected ZipOutputStream outputStream

  - ### inputFileTable

    protected FileTable inputFileTable

  - ### customFileTable

    protected FileTable customFileTable

  - ### mimeType

    protected String mimeType

  - ### isTemplate

    protected boolean isTemplate

  - ### manifest

    protected Manifest manifest

  - ### metaData

    protected MetaData metaData

  - ### commonStyles

    protected CommonStyles commonStyles

  - ### settings

    protected Settings settings

- ## Constructor Details

  - ### Document

    public Document()

- ## Method Details

  - ### open

    public abstract void open​(String file) throws IOException, XMLStreamException
    Open.
    Parameters:
      `file` - the file
    Throws:
      `IOException` - Signals that an I/O exception has occurred.
      `XMLStreamException` - the xML stream exception

  - ### open

    public abstract void open​(InputStream stream) throws IOException, XMLStreamException
    Open.
    Parameters:
      `stream` - the stream
    Throws:
      `IOException` - Signals that an I/O exception has occurred.
      `XMLStreamException` - the xML stream exception

  - ### save

    public abstract void save​(String file) throws IOException
    Save.
    Parameters:
      `file` - the file
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### save

    public abstract void save​(String file, boolean overwrite) throws IOException
    Save.
    Parameters:
      `file` - the file
      `overwrite` - the overwrite
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### save

    public abstract void save​(OutputStream stream) throws IOException
    Save.
    Parameters:
      `stream` - the stream
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### getBytes

    public abstract byte[] getBytes() throws IOException
    Gets the bytes.
    Returns:
      the bytes
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### getInputStream

    public abstract InputStream getInputStream() throws IOException
    Gets the input stream.
    Returns:
      the input stream
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### openImplementation

    protected void openImplementation​(InputStream stream) throws IOException, XMLStreamException
    Throws:
      `IOException`
      `XMLStreamException`

  - ### addFile

    protected void addFile​(String filePath, String file) throws IOException
    Throws:
      `IOException`

  - ### addManifestEntry

    protected void addManifestEntry​(Manifest currentManifest, Manifest originalManifest, String path)
    Adds a manifest:file-entry for a package part written from the in-memory model (image, OLE object, embedded document). Without it the part is unlisted and the package can be reported as corrupt. The original manifest (if any) supplies the exact media-type; otherwise it is derived from the file extension.

  - ### getPreservedPackageParts

    protected List<String> getPreservedPackageParts​(SharedObjects sharedObjects)
    Returns the paths of original package parts that this writer does NOT regenerate (thumbnails, layout-cache, manifest.rdf, unreferenced pictures, ...) so they can be carried over into the saved package instead of being dropped. Directory entries (paths ending in "/") and parts written from the in-memory model are excluded.

  - ### addMimeTypeFile

    protected void addMimeTypeFile​(String mimeTypeValue) throws IOException
    Throws:
      `IOException`

  - ### addFile

    protected void addFile​(String filePath, byte[] buffer) throws IOException
    Throws:
      `IOException`

  - ### getAttributedTexts

    public List<AttributedText> getAttributedTexts()
    Gets the attributed texts.
    Returns:
      the attributed texts

  - ### getTexts

    public List<Text> getTexts()
    Gets the texts.
    Returns:
      the texts

  - ### getParagraphs

    public List<Paragraph> getParagraphs()
    Gets the paragraphs.
    Returns:
      the paragraphs

  - ### getHeadings

    public List<Heading> getHeadings()
    Gets the headings.
    Returns:
      the headings

  - ### getFields

    public List<Field> getFields()
    Gets the fields.
    Returns:
      the fields

  - ### getLists

    public List<List> getLists()
    Gets the lists.
    Returns:
      the lists

  - ### getSections

    public List<Section> getSections()
    Gets the sections.
    Returns:
      the sections

  - ### getTables

    public List<Table> getTables()
    Gets the tables.
    Returns:
      the tables

  - ### getImages

    public List<Image> getImages()
    Gets the images.
    Returns:
      the images

  - ### replace

    public void replace​(String oldText, String newText)
    Replace.
    Parameters:
      `oldText` - the old text
      `newText` - the new text

  - ### replace

    public void replace​(String oldText, String newText, boolean includeHeaderFooter)
    Replace.
    Parameters:
      `oldText` - the old text
      `newText` - the new text
      `includeHeaderFooter` - replace in headers and footers also

  - ### getContentElements

    public abstract List<IContentElement> getContentElements()
    Gets the content elements.
    Returns:
      the content elements

  - ### getInputFileTable

    public FileTable getInputFileTable()
    Gets the input file table.
    Returns:
      the input file table

  - ### getCustomFileTable

    public FileTable getCustomFileTable()
    Gets the custom file table.
    Returns:
      the custom file table

  - ### getCommonStyles

    public CommonStyles getCommonStyles()
    Gets the common styles.
    Returns:
      the common styles

  - ### getGenerator

    public String getGenerator()
    Gets the generator.
    Returns:
      the generator

  - ### getTitle

    public String getTitle()
    Gets the title.
    Returns:
      the title

  - ### setTitle

    public void setTitle​(String title)
    Sets the title.
    Parameters:
      `title` - the new title

  - ### getDescription

    public String getDescription()
    Gets the description.
    Returns:
      the description

  - ### setDescription

    public void setDescription​(String description)
    Sets the description.
    Parameters:
      `description` - the new description

  - ### getSubject

    public String getSubject()
    Gets the subject.
    Returns:
      the subject

  - ### setSubject

    public void setSubject​(String subject)
    Sets the subject.
    Parameters:
      `subject` - the new subject

  - ### getLanguage

    public String getLanguage()
    Gets the language.
    Returns:
      the language

  - ### setLanguage

    public void setLanguage​(String language)
    Sets the language.
    Parameters:
      `language` - the new language

  - ### getKeywords

    public String getKeywords()
    Gets the keywords.
    Returns:
      the keywords

  - ### setKeywords

    public void setKeywords​(String keywords)
    Sets the keywords.
    Parameters:
      `keywords` - the new keywords

  - ### getCreator

    public String getCreator()
    Gets the creator.
    Returns:
      the creator

  - ### setCreator

    public void setCreator​(String creator)
    Sets the creator.
    Parameters:
      `creator` - the new creator

  - ### getCreationDate

    public Date getCreationDate()
    Gets the creation date.
    Returns:
      the creation date

  - ### setCreationDate

    public void setCreationDate​(Date creationDate)
    Sets the creation date.
    Parameters:
      `creationDate` - the new creation date

  - ### getLastModified

    public Date getLastModified()
    Gets the last modified.
    Returns:
      the last modified

  - ### setLastModified

    public void setLastModified​(Date lastModified)
    Sets the last modified.
    Parameters:
      `lastModified` - the new last modified

  - ### getEditingCycles

    public int getEditingCycles()
    Gets the editing cycles.
    Returns:
      the editing cycles

  - ### setEditingCycles

    public void setEditingCycles​(int editingCycles)
    Sets the editing cycles.
    Parameters:
      `editingCycles` - the new editing cycles

  - ### getEditingDuration

    public String getEditingDuration()
    Gets the editing duration.
    Returns:
      the editing duration

  - ### setEditingDuration

    public void setEditingDuration​(String editingDuration)
    Sets the editing duration.
    Parameters:
      `editingDuration` - the new editing duration

  - ### getInitialCreator

    public String getInitialCreator()
    Gets the initial creator.
    Returns:
      the initial creator

  - ### setInitialCreator

    public void setInitialCreator​(String initialCreator)
    Sets the initial creator.
    Parameters:
      `initialCreator` - the new initial creator

  - ### getPrintDate

    public Date getPrintDate()
    Gets the prints the date.
    Returns:
      the prints the date

  - ### setPrintDate

    public void setPrintDate​(Date printDate)
    Sets the prints the date.
    Parameters:
      `printDate` - the new prints the date

  - ### getPrintedBy

    public String getPrintedBy()
    Gets the printed by.
    Returns:
      the printed by

  - ### setPrintedBy

    public void setPrintedBy​(String printedBy)
    Sets the printed by.
    Parameters:
      `printedBy` - the new printed by

  - ### getUserDefinedMetadataElements

    public List<UserDefinedMetadataElement> getUserDefinedMetadataElements()
    Gets the user defined metadata elements.
    Returns:
      the user defined metadata elements

  - ### getTemplate

    public Template getTemplate()
    Gets the template.
    Returns:
      the template

  - ### setTemplate

    public void setTemplate​(Template template)
    Sets the template.
    Parameters:
      `template` - the new template

  - ### getStatistic

    public DocumentStatistic getStatistic()
    Gets the statistic.
    Returns:
      the statistic

  - ### setStatistic

    public void setStatistic​(DocumentStatistic statistic)
    Sets the statistic.
    Parameters:
      `statistic` - the new statistic

  - ### getConfigurations

    public List<Configuration> getConfigurations()
    Gets the configurations.
    Returns:
      the configurations

  - ### isTemplate

    public boolean isTemplate()
    Checks if is template.
    Returns:
      true, if is template

  - ### setTemplate

    public void setTemplate​(boolean isTemplate)
    Sets the template.
    Parameters:
      `isTemplate` - the new template

  - ### getFileInputTable

    public FileTable getFileInputTable()
    Gets the file input table.
    Returns:
      the file input table

  - ### getManifest

    public Manifest getManifest()
    Gets the manifest.
    Returns:
      the manifest

  - ### getMetaData

    public MetaData getMetaData()
    Gets the meta data.
    Returns:
      the meta data

  - ### getMimeType

    public String getMimeType()
    Gets the mime type.
    Returns:
      the mime type

  - ### setMimeType

    public void setMimeType​(String mimeType)
    Sets the mime type.
    Parameters:
      `mimeType` - the new mime type