Package org.xwiki.officeimporter.script
Class OfficeImporterScriptService
- java.lang.Object
-
- org.xwiki.officeimporter.script.OfficeImporterScriptService
-
- All Implemented Interfaces:
org.xwiki.script.service.ScriptService
@Component @Named("officeimporter") @Singleton public class OfficeImporterScriptService extends Object implements org.xwiki.script.service.ScriptServiceExposes the office importer APIs to server-side scripts.- Since:
- 4.1M1
- Version:
- $Id: b874f276ee673b6dd9d6440fca22853f43eb34d9 $
-
-
Field Summary
Fields Modifier and Type Field Description static StringOFFICE_IMPORTER_ERRORThe key used to place any error messages while importing office documents.
-
Constructor Summary
Constructors Constructor Description OfficeImporterScriptService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetErrorMessage()XDOMOfficeDocumentofficeToXDOM(InputStream officeFileStream, String officeFileName, org.xwiki.model.reference.DocumentReference targetDocumentReference, boolean filterStyles)Imports the given office document into anXDOMOfficeDocument.XHTMLOfficeDocumentofficeToXHTML(InputStream officeFileStream, String officeFileName, org.xwiki.model.reference.DocumentReference targetDocumentReference, boolean filterStyles)Imports the given office document into anXHTMLOfficeDocument.booleansave(XDOMOfficeDocument doc, org.xwiki.model.reference.DocumentReference documentReference, boolean append)Attempts to save the givenXDOMOfficeDocumentinto the target wiki page specified by arguments (using the default content syntax, seeExtendedRenderingConfiguration.getDefaultContentSyntax()).booleansave(XDOMOfficeDocument doc, org.xwiki.model.reference.DocumentReference documentReference, String syntaxId, org.xwiki.model.reference.DocumentReference parentReference, String title, boolean append)Attempts to save the givenXDOMOfficeDocumentinto the target wiki page specified by arguments.booleansave(XDOMOfficeDocument doc, org.xwiki.model.reference.DocumentReference documentReference, org.xwiki.model.reference.DocumentReference parentReference, String title, boolean append)Attempts to save the givenXDOMOfficeDocumentinto the target wiki page specified by arguments (using the default content syntax, seeExtendedRenderingConfiguration.getDefaultContentSyntax()).Map<TargetDocumentDescriptor,XDOMOfficeDocument>split(XDOMOfficeDocument xdomDocument, String[] headingLevels, String namingCriterionHint, boolean useTerminalPages, org.xwiki.model.reference.DocumentReference rootDocumentReference)Splits the givenXDOMOfficeDocumentinto multipleXDOMOfficeDocumentinstances according to the specified criterion.Map<TargetDocumentDescriptor,XDOMOfficeDocument>split(XDOMOfficeDocument xdomDocument, String[] headingLevels, String namingCriterionHint, org.xwiki.model.reference.DocumentReference rootDocumentReference)Splits the givenXDOMOfficeDocumentinto multipleXDOMOfficeDocumentinstances according to the specified criterion.XDOMOfficeDocumentxhtmlToXDOM(XHTMLOfficeDocument xhtmlOfficeDocument)Imports the givenXHTMLOfficeDocumentinto anXDOMOfficeDocument.
-
-
-
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
-
-
Method Detail
-
officeToXHTML
public XHTMLOfficeDocument officeToXHTML(InputStream officeFileStream, String officeFileName, org.xwiki.model.reference.DocumentReference targetDocumentReference, boolean filterStyles)
Imports the given office document into anXHTMLOfficeDocument.- Parameters:
officeFileStream- binary data stream corresponding to input office documentofficeFileName- name of the input office document, this argument is mainly used for determining input document format where necessarytargetDocumentReference- 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 documentfilterStyles- whether to filter styling information associated with the office document's content or not- Returns:
XHTMLOfficeDocumentcontaining xhtml result of the import operation or null if an error occurs- Since:
- 4.3M1
-
xhtmlToXDOM
public XDOMOfficeDocument xhtmlToXDOM(XHTMLOfficeDocument xhtmlOfficeDocument)
Imports the givenXHTMLOfficeDocumentinto anXDOMOfficeDocument.- Parameters:
xhtmlOfficeDocument-XHTMLOfficeDocumentto be imported- Returns:
XDOMOfficeDocumentcontainingXDOMresult of the import operation or null if an error occurs
-
officeToXDOM
public XDOMOfficeDocument officeToXDOM(InputStream officeFileStream, String officeFileName, org.xwiki.model.reference.DocumentReference targetDocumentReference, boolean filterStyles)
Imports the given office document into anXDOMOfficeDocument.- Parameters:
officeFileStream- binary data stream corresponding to input office documentofficeFileName- name of the input office document, this argument is mainly is used for determining input document format where necessarytargetDocumentReference- 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 documentfilterStyles- whether to filter styling information associated with the office document's content or not- Returns:
XDOMOfficeDocumentcontainingXDOMresult 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 givenXDOMOfficeDocumentinto multipleXDOMOfficeDocumentinstances 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 rootDocumentNameTargetDocumentDescriptorentry.- Parameters:
xdomDocument-XDOMOfficeDocumentto be splitheadingLevels- heading levels defining the split points on the original documentnamingCriterionHint- hint indicating the child pages naming criterionrootDocumentReference- the reference of the root document w.r.t which splitting will occur; in the results set the entry corresponding to the root documentTargetDocumentDescriptorwill hold an auto-generated TOC structure- Returns:
- a map holding
XDOMOfficeDocumentfragments against correspondingTargetDocumentDescriptorinstances 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 givenXDOMOfficeDocumentinto multipleXDOMOfficeDocumentinstances 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 rootDocumentNameTargetDocumentDescriptorentry.- Parameters:
xdomDocument-XDOMOfficeDocumentto be splitheadingLevels- heading levels defining the split points on the original documentnamingCriterionHint- hint indicating the child pages naming criterionuseTerminalPages- whether to create the child pages as terminal or notrootDocumentReference- the reference of the root document w.r.t which splitting will occur; in the results set the entry corresponding to the root documentTargetDocumentDescriptorwill hold an auto-generated TOC structure- Returns:
- a map holding
XDOMOfficeDocumentfragments against correspondingTargetDocumentDescriptorinstances 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 givenXDOMOfficeDocumentinto the target wiki page specified by arguments (using the default content syntax, seeExtendedRenderingConfiguration.getDefaultContentSyntax()).- Parameters:
doc-XDOMOfficeDocumentto be saveddocumentReference- the reference of the target wiki pageappend- 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 givenXDOMOfficeDocumentinto the target wiki page specified by arguments (using the default content syntax, seeExtendedRenderingConfiguration.getDefaultContentSyntax()).- Parameters:
doc-XDOMOfficeDocumentto be saveddocumentReference- the reference of the target wiki pageparentReference- the reference of the parent wiki page ornulltitle- title of the target wiki page ornullappend- 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 givenXDOMOfficeDocumentinto the target wiki page specified by arguments.- Parameters:
doc-XDOMOfficeDocumentto be saveddocumentReference- the reference of the target wiki pagesyntaxId- syntax of the target wiki pageparentReference- the reference of the parent wiki page ornulltitle- title of the target wiki page ornullappend- 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
-
-