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.ScriptService
Exposes the office importer APIs to server-side scripts.- Since:
- 4.1M1
- Version:
- $Id: b874f276ee673b6dd9d6440fca22853f43eb34d9 $
-
-
Field Summary
Fields Modifier and Type Field Description static String
OFFICE_IMPORTER_ERROR
The 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 String
getErrorMessage()
XDOMOfficeDocument
officeToXDOM(InputStream officeFileStream, String officeFileName, org.xwiki.model.reference.DocumentReference targetDocumentReference, boolean filterStyles)
Imports the given office document into anXDOMOfficeDocument
.XHTMLOfficeDocument
officeToXHTML(InputStream officeFileStream, String officeFileName, org.xwiki.model.reference.DocumentReference targetDocumentReference, boolean filterStyles)
Imports the given office document into anXHTMLOfficeDocument
.boolean
save(XDOMOfficeDocument doc, org.xwiki.model.reference.DocumentReference documentReference, boolean append)
Attempts to save the givenXDOMOfficeDocument
into the target wiki page specified by arguments (using the default content syntax, seeExtendedRenderingConfiguration.getDefaultContentSyntax()
).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 givenXDOMOfficeDocument
into the target wiki page specified by arguments.boolean
save(XDOMOfficeDocument doc, org.xwiki.model.reference.DocumentReference documentReference, org.xwiki.model.reference.DocumentReference parentReference, String title, boolean append)
Attempts to save the givenXDOMOfficeDocument
into 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 givenXDOMOfficeDocument
into multipleXDOMOfficeDocument
instances according to the specified criterion.Map<TargetDocumentDescriptor,XDOMOfficeDocument>
split(XDOMOfficeDocument xdomDocument, String[] headingLevels, String namingCriterionHint, org.xwiki.model.reference.DocumentReference rootDocumentReference)
Splits the givenXDOMOfficeDocument
into multipleXDOMOfficeDocument
instances according to the specified criterion.XDOMOfficeDocument
xhtmlToXDOM(XHTMLOfficeDocument xhtmlOfficeDocument)
Imports the givenXHTMLOfficeDocument
into 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:
XHTMLOfficeDocument
containing xhtml result of the import operation or null if an error occurs- Since:
- 4.3M1
-
xhtmlToXDOM
public XDOMOfficeDocument xhtmlToXDOM(XHTMLOfficeDocument xhtmlOfficeDocument)
Imports the givenXHTMLOfficeDocument
into anXDOMOfficeDocument
.- Parameters:
xhtmlOfficeDocument
-XHTMLOfficeDocument
to be imported- Returns:
XDOMOfficeDocument
containingXDOM
result 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:
XDOMOfficeDocument
containingXDOM
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 givenXDOMOfficeDocument
into multipleXDOMOfficeDocument
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 rootDocumentNameTargetDocumentDescriptor
entry.- Parameters:
xdomDocument
-XDOMOfficeDocument
to 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 documentTargetDocumentDescriptor
will hold an auto-generated TOC structure- Returns:
- a map holding
XDOMOfficeDocument
fragments against correspondingTargetDocumentDescriptor
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 givenXDOMOfficeDocument
into multipleXDOMOfficeDocument
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 rootDocumentNameTargetDocumentDescriptor
entry.- Parameters:
xdomDocument
-XDOMOfficeDocument
to 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 documentTargetDocumentDescriptor
will hold an auto-generated TOC structure- Returns:
- a map holding
XDOMOfficeDocument
fragments against correspondingTargetDocumentDescriptor
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 givenXDOMOfficeDocument
into the target wiki page specified by arguments (using the default content syntax, seeExtendedRenderingConfiguration.getDefaultContentSyntax()
).- Parameters:
doc
-XDOMOfficeDocument
to 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 givenXDOMOfficeDocument
into the target wiki page specified by arguments (using the default content syntax, seeExtendedRenderingConfiguration.getDefaultContentSyntax()
).- Parameters:
doc
-XDOMOfficeDocument
to be saveddocumentReference
- the reference of the target wiki pageparentReference
- the reference of the parent wiki page ornull
title
- title of the target wiki page ornull
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 givenXDOMOfficeDocument
into the target wiki page specified by arguments.- Parameters:
doc
-XDOMOfficeDocument
to be saveddocumentReference
- the reference of the target wiki pagesyntaxId
- syntax of the target wiki pageparentReference
- the reference of the parent wiki page ornull
title
- title of the target wiki page ornull
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
-
-