Class MainDocumentPart

All Implemented Interfaces:
AltChunkInterface, XPathEnabled<Document>, ContentAccessor

public class MainDocumentPart extends DocumentPart<Document> implements ContentAccessor
Author:
jharrop
  • Constructor Details

  • Method Details

    • init

      public void init()
    • setMceIgnorable

      protected void setMceIgnorable(McIgnorableNamespaceDeclarator namespacePrefixMapper)
      Description copied from class: JaxbXmlPart
      Where the mc:Ignorable attribute is present, ensure its contents matches the ignorable namespaces actually present.
      Overrides:
      setMceIgnorable in class JaxbXmlPart<Document>
    • getMceIgnorable

      public String getMceIgnorable()
      Overrides:
      getMceIgnorable in class JaxbXmlPart<Document>
    • getContent

      public List<Object> getContent()
      Convenience method to getJaxbElement().getBody().getContent()
      Specified by:
      getContent in interface ContentAccessor
      Since:
      2.7
    • getPropertyResolver

      public PropertyResolver getPropertyResolver()
      get the PropertyResolver, creating if necessary
    • getPropertyResolver

      public PropertyResolver getPropertyResolver(boolean create)
      get the PropertyResolver
      Parameters:
      create - whether to create if null
      Returns:
      Since:
      11.5.2
    • getStyleTree

      public StyleTree getStyleTree()
    • getStyleTree

      public StyleTree getStyleTree(boolean refresh)
    • fontsInUse

      public Set<String> fontsInUse()
      Traverse the document, looking for fonts which have been applied, either directly, or via a style.
      Returns:
    • getStylesInUse

      public Set<String> 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

      public P 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.
      Parameters:
      styleId -
      text -
      Returns:
    • createStyledParagraphOfText

      public P 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.
      Parameters:
      styleId -
      text -
      Returns:
    • addParagraphOfText

      public P addParagraphOfText(String simpleText)
      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

      public P createParagraphOfText(String simpleText)
      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

      public void addObject(Object o)
      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

      public P addParagraph(String pXml) throws jakarta.xml.bind.JAXBException
      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

      public static P.Hyperlink hyperlinkToBookmark(String bookmarkName, String linkText)
      Create a Hyperlink object, which is suitable for adding to a w:p
      Parameters:
      bookmarkName -
      linkText -
      Returns:
    • attachTemplate

      public void attachTemplate(String templatePath)
      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

      public GlossaryDocumentPart getGlossaryDocumentPart()
      Since:
      3.0.0
    • getKeyMapCustomizationsPart

      public KeyMapCustomizationsPart getKeyMapCustomizationsPart()
      Since:
      8.2.8
    • setPartShortcut

      public boolean setPartShortcut(Part part, String relationshipType)
      Description copied from class: Base
      Tell the source Part about this target Part, so the source can use this part via a convenience method.
      Overrides:
      setPartShortcut in class DocumentPart<Document>
      Returns:
      true if the source Part does use the target Part in a convenience method.