Class OfficeImporterScriptService

  • All Implemented Interfaces:
    org.xwiki.script.service.ScriptService

    @Component
    @Named("officeimporter")
    @Singleton
    public class OfficeImporterScriptService
    extends Object
    implements org.xwiki.script.service.ScriptService
    Exposes the office importer APIs to server-side scripts.
    Since:
    4.1M1
    Version:
    $Id: b874f276ee673b6dd9d6440fca22853f43eb34d9 $
    • Field Detail

      • OFFICE_IMPORTER_ERROR

        public static final String OFFICE_IMPORTER_ERROR
        The key used to place any error messages while importing office documents.
        See Also:
        Constant Field Values
    • Constructor Detail

      • OfficeImporterScriptService

        public OfficeImporterScriptService()
    • Method Detail

      • officeToXHTML

        public XHTMLOfficeDocument officeToXHTML​(InputStream officeFileStream,
                                                 String officeFileName,
                                                 org.xwiki.model.reference.DocumentReference targetDocumentReference,
                                                 boolean filterStyles)
        Imports the given office document into an XHTMLOfficeDocument.
        Parameters:
        officeFileStream - binary data stream corresponding to input office document
        officeFileName - name of the input office document, this argument is mainly used for determining input document format where necessary
        targetDocumentReference - the document the import process is carried out relative to; this argument affects the attachment URLs generated during the import process where all references to attachments will be calculated assuming that the attachments are contained on the specified target document
        filterStyles - whether to filter styling information associated with the office document's content or not
        Returns:
        XHTMLOfficeDocument containing xhtml result of the import operation or null if an error occurs
        Since:
        4.3M1
      • officeToXDOM

        public XDOMOfficeDocument officeToXDOM​(InputStream officeFileStream,
                                               String officeFileName,
                                               org.xwiki.model.reference.DocumentReference targetDocumentReference,
                                               boolean filterStyles)
        Imports the given office document into an XDOMOfficeDocument.
        Parameters:
        officeFileStream - binary data stream corresponding to input office document
        officeFileName - name of the input office document, this argument is mainly is used for determining input document format where necessary
        targetDocumentReference - the document the import process is carried out relative to; this argument affects the attachment URLs generated during the import process where all references to attachments will be calculated assuming that the attachments are contained on the specified target document
        filterStyles - whether to filter styling information associated with the office document's content or not
        Returns:
        XDOMOfficeDocument containing XDOM result of the import operation or null if an error occurs
        Since:
        4.3M1
      • split

        public Map<TargetDocumentDescriptor,​XDOMOfficeDocument> split​(XDOMOfficeDocument xdomDocument,
                                                                            String[] headingLevels,
                                                                            String namingCriterionHint,
                                                                            org.xwiki.model.reference.DocumentReference rootDocumentReference)
        Splits the given XDOMOfficeDocument into multiple XDOMOfficeDocument instances according to the specified criterion. This method is useful when a single office document has to be imported and split into multiple wiki pages. An auto generated TOC structure will be returned associated to rootDocumentName TargetDocumentDescriptor entry.
        Parameters:
        xdomDocument - XDOMOfficeDocument to be split
        headingLevels - heading levels defining the split points on the original document
        namingCriterionHint - hint indicating the child pages naming criterion
        rootDocumentReference - the reference of the root document w.r.t which splitting will occur; in the results set the entry corresponding to the root document TargetDocumentDescriptor will hold an auto-generated TOC structure
        Returns:
        a map holding XDOMOfficeDocument fragments against corresponding TargetDocumentDescriptor instances or null if an error occurs
        Since:
        4.3M1
      • split

        @Unstable
        public Map<TargetDocumentDescriptor,​XDOMOfficeDocument> split​(XDOMOfficeDocument xdomDocument,
                                                                            String[] headingLevels,
                                                                            String namingCriterionHint,
                                                                            boolean useTerminalPages,
                                                                            org.xwiki.model.reference.DocumentReference rootDocumentReference)
        Splits the given XDOMOfficeDocument into multiple XDOMOfficeDocument instances according to the specified criterion. This method is useful when a single office document has to be imported and split into multiple wiki pages. An auto generated TOC structure will be returned associated to rootDocumentName TargetDocumentDescriptor entry.
        Parameters:
        xdomDocument - XDOMOfficeDocument to be split
        headingLevels - heading levels defining the split points on the original document
        namingCriterionHint - hint indicating the child pages naming criterion
        useTerminalPages - whether to create the child pages as terminal or not
        rootDocumentReference - the reference of the root document w.r.t which splitting will occur; in the results set the entry corresponding to the root document TargetDocumentDescriptor will hold an auto-generated TOC structure
        Returns:
        a map holding XDOMOfficeDocument fragments against corresponding TargetDocumentDescriptor instances or null if an error occurs
        Since:
        14.10.2, 15.0RC1
      • save

        @Unstable
        public boolean save​(XDOMOfficeDocument doc,
                            org.xwiki.model.reference.DocumentReference documentReference,
                            boolean append)
        Attempts to save the given XDOMOfficeDocument into the target wiki page specified by arguments (using the default content syntax, see ExtendedRenderingConfiguration.getDefaultContentSyntax()).
        Parameters:
        doc - XDOMOfficeDocument to be saved
        documentReference - the reference of the target wiki page
        append - whether to append content if the target wiki page exists
        Returns:
        true if the operation completes successfully, false otherwise
        Since:
        14.10.2, 15.0RC1
      • save

        public boolean save​(XDOMOfficeDocument doc,
                            org.xwiki.model.reference.DocumentReference documentReference,
                            org.xwiki.model.reference.DocumentReference parentReference,
                            String title,
                            boolean append)
        Attempts to save the given XDOMOfficeDocument into the target wiki page specified by arguments (using the default content syntax, see ExtendedRenderingConfiguration.getDefaultContentSyntax()).
        Parameters:
        doc - XDOMOfficeDocument to be saved
        documentReference - the reference of the target wiki page
        parentReference - the reference of the parent wiki page or null
        title - title of the target wiki page or null
        append - whether to append content if the target wiki page exists
        Returns:
        true if the operation completes successfully, false otherwise
        Since:
        11.0, 10.11.9
      • save

        public boolean save​(XDOMOfficeDocument doc,
                            org.xwiki.model.reference.DocumentReference documentReference,
                            String syntaxId,
                            org.xwiki.model.reference.DocumentReference parentReference,
                            String title,
                            boolean append)
        Attempts to save the given XDOMOfficeDocument into the target wiki page specified by arguments.
        Parameters:
        doc - XDOMOfficeDocument to be saved
        documentReference - the reference of the target wiki page
        syntaxId - syntax of the target wiki page
        parentReference - the reference of the parent wiki page or null
        title - title of the target wiki page or null
        append - whether to append content if the target wiki page exists
        Returns:
        true if the operation completes successfully, false otherwise
        Since:
        4.3M1
      • getErrorMessage

        public String getErrorMessage()
        Returns:
        an error message set inside current execution (during import process) or null