Class OdfTextDocument

    • Method Detail

      • newTextDocument

        public static OdfTextDocument newTextDocument()
                                               throws Exception
        Creates an empty text document.
        Returns:
        ODF text document based on a default template
        Throws:
        Exception - - if the document could not be created
      • newTextDocument

        public static OdfTextDocument newTextDocument​(Boolean enableCollaboration)
                                               throws Exception
        Creates an empty text document.
        Parameters:
        enableCollaboration - - user changes equivalent for creating this document are gathered
        Returns:
        ODF text document based on a default template
        Throws:
        Exception - - if the document could not be created
      • newTextTemplateDocument

        public static OdfTextDocument newTextTemplateDocument()
                                                       throws Exception
        Creates an empty text template.
        Returns:
        ODF text template based on a default
        Throws:
        Exception - - if the template could not be created
      • newTextMasterDocument

        public static OdfTextDocument newTextMasterDocument()
                                                     throws Exception
        Creates an empty text master document.
        Returns:
        ODF text master based on a default
        Throws:
        Exception - - if the document could not be created
      • newTextWebDocument

        public static OdfTextDocument newTextWebDocument()
                                                  throws Exception
        Creates an empty text web.
        Returns:
        ODF text web based on a default
        Throws:
        Exception - - if the document could not be created
      • loadDocument

        public static OdfTextDocument loadDocument​(InputStream inputStream)
                                            throws Exception
        Creates an OdfTextDocument from the OpenDocument provided by a resource Stream.

        Since an InputStream does not provide the arbitrary (non sequential) read access needed by OdfTextDocument, the InputStream is cached. This usually takes more time compared to the other createInternalDocument methods. An advantage of caching is that there are no problems overwriting an input file.

        If the resource stream is not a ODF text document, ClassCastException might be thrown.

        Parameters:
        inputStream - - the InputStream of the ODF text document.
        Returns:
        the text document created from the given InputStream
        Throws:
        Exception - - if the document could not be created.
      • loadDocument

        public static OdfTextDocument loadDocument​(InputStream inputStream,
                                                   Boolean enableCollaboration)
                                            throws Exception
        Creates an OdfTextDocument from the OpenDocument provided by a resource Stream.

        Since an InputStream does not provide the arbitrary (non sequential) read access needed by OdfTextDocument, the InputStream is cached. This usually takes more time compared to the other createInternalDocument methods. An advantage of caching is that there are no problems overwriting an input file.

        If the resource stream is not a ODF text document, ClassCastException might be thrown.

        Parameters:
        inputStream - - the InputStream of the ODF text document.
        enableCollaboration - - user changes equivalent for creating this document are gathered
        Returns:
        the text document created from the given InputStream
        Throws:
        Exception - - if the document could not be created.
      • loadDocument

        public static OdfTextDocument loadDocument​(InputStream inputStream,
                                                   Map<String,​Object> configuration)
                                            throws Exception
        Creates an OdfTextDocument from the OpenDocument provided by a resource Stream.

        Since an InputStream does not provide the arbitrary (non sequential) read access needed by OdfTextDocument, the InputStream is cached. This usually takes more time compared to the other createInternalDocument methods. An advantage of caching is that there are no problems overwriting an input file.

        If the resource stream is not a ODF text document, ClassCastException might be thrown.

        Parameters:
        inputStream - - the InputStream of the ODF text document.
        configuration - - key/value pairs of user given run-time settings (configuration)
        Returns:
        the text document created from the given InputStream
        Throws:
        Exception - - if the document could not be created.
      • loadDocument

        public static OdfTextDocument loadDocument​(InputStream inputStream,
                                                   Map<String,​Object> configuration,
                                                   Boolean enableCollaboration)
                                            throws Exception
        Creates an OdfTextDocument from the OpenDocument provided by a resource Stream.

        Since an InputStream does not provide the arbitrary (non sequential) read access needed by OdfTextDocument, the InputStream is cached. This usually takes more time compared to the other createInternalDocument methods. An advantage of caching is that there are no problems overwriting an input file.

        If the resource stream is not a ODF text document, ClassCastException might be thrown.

        Parameters:
        inputStream - - the InputStream of the ODF text document.
        configuration - - key/value pairs of user given run-time settings (configuration)
        enableCollaboration - - user changes equivalent for creating this document are gathered
        Returns:
        the text document created from the given InputStream
        Throws:
        Exception - - if the document could not be created.
      • loadDocument

        public static OdfTextDocument loadDocument​(String documentPath)
                                            throws Exception
        Loads an OdfTextDocument from the provided path.

        OdfTextDocument relies on the file being available for read access over the whole life-cycle of OdfTextDocument.

        If the resource stream is not a ODF text document, ClassCastException might be thrown.

        Parameters:
        documentPath - - the path from where the document can be loaded
        Returns:
        the text document from the given path or NULL if the media type is not supported by ODFDOM.
        Throws:
        Exception - - if the document could not be created.
      • loadDocument

        public static OdfTextDocument loadDocument​(File file)
                                            throws Exception
        Creates an OdfTextDocument from the OpenDocument provided by a File.

        OdfTextDocument relies on the file being available for read access over the whole lifecycle of OdfTextDocument.

        If the resource stream is not a ODF text document, ClassCastException might be thrown.

        Parameters:
        file - - a file representing the ODF text document.
        Returns:
        the text document created from the given File
        Throws:
        Exception - - if the document could not be created.
      • getContentRoot

        public OfficeTextElement getContentRoot()
                                         throws Exception
        Get the content root of a text document. Start here to get or create new elements of a text document like paragraphs, headings, tables or lists.
        Overrides:
        getContentRoot in class OdfDocument
        Returns:
        content root, representing the office:text tag
        Throws:
        Exception - if the file DOM could not be created.
      • newParagraph

        public OdfTextParagraph newParagraph​(String text)
                                      throws Exception
        Creates a new paragraph and append text
        Parameters:
        text -
        Returns:
        the new paragraph
        Throws:
        Exception - if the file DOM could not be created.
      • newParagraph

        public OdfTextParagraph newParagraph()
                                      throws Exception
        Creates a new paragraph
        Returns:
        The new paragraph
        Throws:
        Exception - if the file DOM could not be created.
      • addText

        public OdfTextParagraph addText​(String text)
                                 throws Exception
        Append text to the end of a text document. If there is no paragraph at the end of a document, a new one will be created.
        Parameters:
        text - initial text for the paragraph.
        Returns:
        The paragraph at the end of the text document, where the text has been added to.
        Throws:
        Exception - if the file DOM could not be created.
      • changeMode

        public void changeMode​(OdfTextDocument.OdfMediaType mediaType)
        Changes the document to the given mediatype. This method can only be used to convert a document to a related mediatype, e.g. template.
        Parameters:
        mediaType - the related ODF mimetype
      • hasTabsRelativeToIndent

        public Boolean hasTabsRelativeToIndent()
        In LO/AO Tabs are counted from the start of text and the fo:left-margin have to be added. Microsoft Office does not behave this way. For the filter a compatibility flag was added to the settings.xml false