Class MainDocumentPart
java.lang.Object
org.docx4j.openpackaging.Base
org.docx4j.openpackaging.parts.Part
org.docx4j.openpackaging.parts.JaxbXmlPart<E>
org.docx4j.openpackaging.parts.JaxbXmlPartXPathAware<E>
org.docx4j.openpackaging.parts.JaxbXmlPartAltChunkHost<E>
org.docx4j.openpackaging.parts.WordprocessingML.DocumentPart<Document>
org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart
- All Implemented Interfaces:
AltChunkInterface,XPathEnabled<Document>,ContentAccessor
- Author:
- jharrop
-
Field Summary
Fields inherited from class org.docx4j.openpackaging.parts.WordprocessingML.DocumentPart
commentsExtendedPart, commentsIdsPart, commentsPart, documentSettingsPart, endNotesPart, fontTablePart, footnotesPart, numberingDefinitionsPart, peoplePart, styleDefinitionsPart, themePart, webSettingsPartFields inherited from class org.docx4j.openpackaging.parts.JaxbXmlPartXPathAware
binderFields inherited from class org.docx4j.openpackaging.parts.JaxbXmlPart
jaxbElement, jc, MAX_BYTES_Unmarshal_ErrorFields inherited from class org.docx4j.openpackaging.Base
contentType, partName, relationships -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd the object o to the document.addParagraph(String pXml) Create a paragraph from the xml string <w:p>...</w:p> , and add it to the document.addParagraphOfText(String simpleText) Create a paragraph containing the string simpleText, and add it to the document.addStyledParagraphOfText(String styleId, String text) Create a paragraph containing the string simpleText, styled using the specified style (up to user to ensure it is a paragraph style) and add it to the document.voidattachTemplate(String templatePath) Attach a template to this document.createParagraphOfText(String simpleText) Create a paragraph containing the string simpleText, without adding it to the document.createStyledParagraphOfText(String styleId, String text) Create a paragraph containing the string simpleText, styled using the specified style (up to user to ensure it is a paragraph style) without adding it to the document.Traverse the document, looking for fonts which have been applied, either directly, or via a style.Convenience method to getJaxbElement().getBody().getContent()Traverse the document, and return a map of all styles which are used directly in the document.getStyleTree(boolean refresh) static P.HyperlinkhyperlinkToBookmark(String bookmarkName, String linkText) Create a Hyperlink object, which is suitable for adding to a w:pvoidinit()protected voidsetMceIgnorable(McIgnorableNamespaceDeclarator namespacePrefixMapper) Where the mc:Ignorable attribute is present, ensure its contents matches the ignorable namespaces actually present.booleansetPartShortcut(Part part, String relationshipType) Tell the source Part about this target Part, so the source can use this part via a convenience method.Methods inherited from class org.docx4j.openpackaging.parts.WordprocessingML.DocumentPart
getBibliographyPart, getCommentsExtendedPart, getCommentsIdsPart, getCommentsPart, getComponentsPart, getConditionsPart, getDocumentSettingsPart, getDocumentSettingsPart, getEndNotesPart, getFontTablePart, getFootnote, getFootnotesPart, getNumberingDefinitionsPart, getPeoplePart, getQuestionsPart, getStyleDefinitionsPart, getStyleDefinitionsPart, getThemePart, getWebSettingsPart, getXPathsPart, hasEndnotesPart, hasFootnotesPart, setPartShortcutMethods inherited from class org.docx4j.openpackaging.parts.JaxbXmlPartAltChunkHost
addAltChunk, addAltChunk, addAltChunk, addAltChunk, addAltChunk, addAltChunk, addAltChunk, addAltChunk, convertAltChunksMethods inherited from class org.docx4j.openpackaging.parts.JaxbXmlPartXPathAware
createBinderAndJaxbElement, getBinder, getJAXBAssociationsForXPath, getJAXBAssociationsForXPath, getJAXBNodesViaXPath, getJAXBNodesViaXPath, setJaxbElement, unmarshal, unmarshalMethods inherited from class org.docx4j.openpackaging.parts.JaxbXmlPart
addMcChoiceNamespace, getConfiguredUnmarshaller, getContents, getJAXBContext, getJaxbElement, getMcChoiceNamespaces, getXML, inputStreamToXSR, isContentEqual, isUnmarshalled, marshal, marshal, marshal, marshal, pipe, pipe, pipe, preprocess, setContents, setJAXBContext, setJaxbElement, transform, transformToDom, variableReplaceMethods inherited from class org.docx4j.openpackaging.parts.Part
getContentLengthAsLoaded, getOwningRelationshipPart, getPackage, getRelationshipType, getSourceRelationship, getSourceRelationships, getVersion, remove, rename, setContentLengthAsLoaded, setOwningRelationshipPart, setPackage, setRelationshipType, setSourceRelationship, setVersionMethods inherited from class org.docx4j.openpackaging.Base
addTargetPart, addTargetPart, addTargetPart, addTargetPart, getContentType, getPartName, getRelationshipsPart, getRelationshipsPart, getUserData, reset, setContentType, setPartName, setRelationships, setUserData
-
Constructor Details
-
MainDocumentPart
- Throws:
InvalidFormatException
-
MainDocumentPart
- Throws:
InvalidFormatException
-
-
Method Details
-
init
public void init() -
setMceIgnorable
Description copied from class:JaxbXmlPartWhere the mc:Ignorable attribute is present, ensure its contents matches the ignorable namespaces actually present.- Overrides:
setMceIgnorablein classJaxbXmlPart<Document>
-
getMceIgnorable
- Overrides:
getMceIgnorablein classJaxbXmlPart<Document>
-
getContent
Convenience method to getJaxbElement().getBody().getContent()- Specified by:
getContentin interfaceContentAccessor- Since:
- 2.7
-
getPropertyResolver
-
getStyleTree
-
getStyleTree
-
fontsInUse
Traverse the document, looking for fonts which have been applied, either directly, or via a style.- Returns:
-
getStylesInUse
Traverse the document, and return a map of all styles which are used directly in the document. (IE this does not include styles on which others are just BasedOn).- Returns:
-
addStyledParagraphOfText
Create a paragraph containing the string simpleText, styled using the specified style (up to user to ensure it is a paragraph style) and add it to the document.- Parameters:
styleId-text-- Returns:
-
createStyledParagraphOfText
Create a paragraph containing the string simpleText, styled using the specified style (up to user to ensure it is a paragraph style) without adding it to the document.- Parameters:
styleId-text-- Returns:
-
addParagraphOfText
Create a paragraph containing the string simpleText, and add it to the document. If passed null, the result is an empty P.- Parameters:
simpleText-- Returns:
-
createParagraphOfText
Create a paragraph containing the string simpleText, without adding it to the document. If passed null, the result is an empty P.- Parameters:
simpleText-- Returns:
-
addObject
Add the object o to the document. The same as getContent().add, except that this will ensure any style used is activated.- Parameters:
o-
-
addParagraph
Create a paragraph from the xml string <w:p>...</w:p> , and add it to the document. You'll need to ensure the string contains namespace declarations (including for w:)- Parameters:
simpleText-- Returns:
- Throws:
jakarta.xml.bind.JAXBException
-
hyperlinkToBookmark
Create a Hyperlink object, which is suitable for adding to a w:p- Parameters:
bookmarkName-linkText-- Returns:
-
attachTemplate
Attach a template to this document. This is just an easy way to access the same method in DocumentSettingsPart- Parameters:
templatePath-- Since:
- 6.1.0
-
getGlossaryDocumentPart
- Since:
- 3.0.0
-
getKeyMapCustomizationsPart
- Since:
- 8.2.8
-
setPartShortcut
Description copied from class:BaseTell the source Part about this target Part, so the source can use this part via a convenience method.- Overrides:
setPartShortcutin classDocumentPart<Document>- Returns:
- true if the source Part does use the target Part in a convenience method.
-