Class CollabTextDocument

    • Constructor Detail

      • CollabTextDocument

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

        Since an InputStream does not provide the arbitrary (non sequential) read access needed by CollabTextDocument, 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.

        Parameters:
        inputStream - - the InputStream of the ODF text document.
        Throws:
        Exception
      • CollabTextDocument

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

        Since an InputStream does not provide the arbitrary (non sequential) read access needed by CollabTextDocument, 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.

        Parameters:
        configuration - - key/value pairs of user given run-time settings (configuration)
        documentStream - - the InputStream of the ODF text document.
        Throws:
        Exception
      • CollabTextDocument

        public CollabTextDocument​(InputStream inputStream,
                                  Map<Long,​byte[]> resourceManager,
                                  Map<String,​Object> configuration)
                           throws Exception
        Creates an CollabTextDocument from the OpenDocument provided by a resource Stream.

        Since an InputStream does not provide the arbitrary (non sequential) read access needed by CollabTextDocument, 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.

        Parameters:
        inputStream - - the InputStream of the ODF text document.
        resourceManager - - the bytes of new resources can be accessed by an ID.
        configuration - - key/value pairs of user given run-time settings (configuration)
        Throws:
        Exception - document could not be opened
    • Method Detail

      • newTextCollabDocument

        public static CollabTextDocument newTextCollabDocument()
                                                        throws Exception
        Creates a new ODT document from the default template
        Returns:
        new CollabTextDocument
        Throws:
        Exception
      • getDocumentAsChanges

        public org.json.JSONObject getDocumentAsChanges()
                                                 throws SAXException,
                                                        org.json.JSONException,
                                                        IOException
        Receives the (known) operations of the ODF text document
        Returns:
        the operations as JSON
        Throws:
        SAXException
        org.json.JSONException
        IOException
      • applyChanges

        public int applyChanges​(String operationString)
                         throws Exception
        Applies the (known) operations to upon the latest state of the ODF text document
        Parameters:
        operationString - ODF operations as String JSONObject with "changes" as key for operations
        Returns:
        the number of operations being accepted
        Throws:
        Exception
      • applyChanges

        public int applyChanges​(org.json.JSONObject operations)
                         throws Exception
        Applies the (known) operations to upon the latest state of the ODF text document
        Parameters:
        operations - ODF operations as JSONArray within an JSONObject with OPK_OPERATIONS key from OperationConstants.
        Returns:
        the number of operations being accepted
        Throws:
        Exception
      • getContentSize

        public long getContentSize()
      • getDocument

        public OdfTextDocument getDocument()
        Returns the OdfTextDocument encapsulating the DOM view
        Returns:
        ODF document - currently only Te
      • getPackage

        public OdfPackage getPackage()
        Returns the OdfPackage
        Returns:
        ODF Package
      • close

        public void close()
        Close the OdfPackage and release all temporary created data. After execution of this method, this class is no longer usable. Do this as the last action to free resources. Closing an already closed document has no effect.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
      • countAppliedChanges

        public int countAppliedChanges()
        Returns:
        number of correct applied operations
      • getMaxTableColumnsCount

        public int getMaxTableColumnsCount()
      • getMaxTableRowsCount

        public int getMaxTableRowsCount()
      • getMaxTableCellCount

        public int getMaxTableCellCount()
      • getMaxSheetCount

        public int getMaxSheetCount()
      • getResourceMap

        public Map<Long,​byte[]> getResourceMap()
        Receives the a map with new resources for the Document
        Returns:
        the operations as JSON