Class XDOMOfficeDocument
- java.lang.Object
-
- org.xwiki.officeimporter.document.XDOMOfficeDocument
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,OfficeDocument
public class XDOMOfficeDocument extends Object implements OfficeDocument
AnOfficeDocument
backed by anXDOM
document.- Since:
- 2.1M1
- Version:
- $Id: f41f6a7f0ae46fdec0732dc3af61c4cb418a4238 $
-
-
Constructor Summary
Constructors Constructor Description XDOMOfficeDocument(XDOM xdom, Set<File> artifactFiles, org.xwiki.component.manager.ComponentManager componentManager, OfficeConverterResult converterResult)
Creates a newXDOMOfficeDocument
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Set<File>
getArtifactsFiles()
Returns the files corresponding to all the artifacts for this office document, except the conversion of the document itself.String
getContentAsString()
Returns the content of this document as a string.String
getContentAsString(String syntaxId)
Renders the XDOM encapsulated by this document into the given syntax.XDOM
getContentDocument()
Returns the content of this office document.OfficeConverterResult
getConverterResult()
String
getTitle()
Tries to extract a title suitable for this document.
-
-
-
Constructor Detail
-
XDOMOfficeDocument
@Unstable public XDOMOfficeDocument(XDOM xdom, Set<File> artifactFiles, org.xwiki.component.manager.ComponentManager componentManager, OfficeConverterResult converterResult)
Creates a newXDOMOfficeDocument
.- Parameters:
xdom
-XDOM
corresponding to office document content.artifactFiles
- artifacts for this office document.componentManager
-ComponentManager
used to lookup for various renderers.converterResult
- theOfficeConverterResult
used to build that object.- Since:
- 13.1RC1
-
-
Method Detail
-
getContentDocument
public XDOM getContentDocument()
Description copied from interface:OfficeDocument
Returns the content of this office document. Content document type may vary depending on the implementation. For an example, a particular implementation might return an html DOM object while another implementation might return an XDOM.- Specified by:
getContentDocument
in interfaceOfficeDocument
- Returns:
- content of this document.
-
getContentAsString
public String getContentAsString()
Description copied from interface:OfficeDocument
Returns the content of this document as a string.- Specified by:
getContentAsString
in interfaceOfficeDocument
- Returns:
- content of this document as a string.
-
getContentAsString
public String getContentAsString(String syntaxId)
Renders the XDOM encapsulated by this document into the given syntax.- Parameters:
syntaxId
- string identifier of the syntax.- Returns:
- content of this document in the given syntax or null if the syntax is invalid.
-
getArtifactsFiles
public Set<File> getArtifactsFiles()
Description copied from interface:OfficeDocument
Returns the files corresponding to all the artifacts for this office document, except the conversion of the document itself. Artifacts are generated during the import operation if the original office document contains embedded non-textual elements. Also, some office formats (like presentations) result in multiple output files when converted into html. In this case all these output files will be considered as artifacts.- Specified by:
getArtifactsFiles
in interfaceOfficeDocument
- Returns:
- the set of artifacts related to this office document.
-
getTitle
public String getTitle()
Tries to extract a title suitable for this document. This is done by navigating the internalXDOM
and finding a matching header block.- Returns:
- a title suitable for this document or null if no title can be found.
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceOfficeDocument
- Throws:
IOException
-
getConverterResult
public OfficeConverterResult getConverterResult()
- Specified by:
getConverterResult
in interfaceOfficeDocument
- Returns:
- the converter result.
-
-