Interface DocxContext<T>

    • Method Detail

      • setRunFormatProvider

        void setRunFormatProvider​(RunFormatProvider<T> formatProvider)
      • setParaContainer

        void setParaContainer​(ParaContainer container)
      • setRunContainer

        void setRunContainer​(RunContainer container)
      • getBlockFormatProvider

        BlockFormatProvider<T> getBlockFormatProvider()
        Get current format provider
        Returns:
        format provider
      • addBlankLine

        void addBlankLine​(int size,
                          java.lang.String styleId)
      • addBlankLine

        void addBlankLine​(long size,
                          java.lang.String styleId)
      • addBlankLine

        void addBlankLine​(java.math.BigInteger size,
                          java.lang.String styleId)
      • addBlankLines

        void addBlankLines​(int count)
      • getPackage

        org.docx4j.openpackaging.packages.WordprocessingMLPackage getPackage()
        Returns:
        the Wordprocessing package
      • extendRenderingNodeAttributes

        MutableAttributes extendRenderingNodeAttributes​(AttributablePart part,
                                                        Attributes attributes)
        Extend the attributes by extensions for the node being currently rendered.
        Parameters:
        part - the tag of the node being rendered, some nodes render multiple tags with attributes
        attributes - the attributes that were calculated by the renderer or null, these may be modified. To preserve originals pass a copy.
        Returns:
        the extended attributes with added/updated/removed entries
      • extendRenderingNodeAttributes

        MutableAttributes extendRenderingNodeAttributes​(Node node,
                                                        AttributablePart part,
                                                        Attributes attributes)
        Extend the attributes by extensions for the node being currently rendered.
        Parameters:
        node - node for which to get attributes
        part - the tag of the node being rendered, some nodes render multiple tags with attributes
        attributes - the attributes that were calculated by the renderer or null, these may be modified. To preserve originals pass a copy.
        Returns:
        the extended attributes with added/updated/removed entries
      • getDocxDocument

        org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart getDocxDocument()
        Returns:
        the main document
      • getFactory

        org.docx4j.wml.ObjectFactory getFactory()
        Get the wml object factory
        Returns:
        object factory
      • createPStyle

        org.docx4j.wml.PPrBase.PStyle createPStyle​(java.lang.String style)
      • createP

        org.docx4j.wml.P createP()
        Get a new P element for the current block
        Returns:
        current P element or null if none is open
      • createP

        org.docx4j.wml.P createP​(java.lang.String style)
      • getP

        org.docx4j.wml.P getP()
        Get the last P element for the current block
        Returns:
        current P element or null if none is open
      • createR

        org.docx4j.wml.R createR()
        Create R element, with an RPr and add it to current P element
        Returns:
        R element
      • getR

        org.docx4j.wml.R getR()
        Get last R element of current P or create a new one
        Returns:
        R element
      • createBookmarkStart

        org.docx4j.wml.CTBookmark createBookmarkStart​(java.lang.String bookmarkName,
                                                      boolean isBlockBookmark)
        Insert bookmark start into current P
        Parameters:
        bookmarkName - name of the bookmark (optional), if not given the it will be BM_{id}
        isBlockBookmark - true if block bookmark
        Returns:
        CTBookmark
      • createBookmarkEnd

        org.docx4j.wml.CTMarkupRange createBookmarkEnd​(org.docx4j.wml.CTBookmark bookmarkStart,
                                                       boolean isBlockBookmark)
        Insert bookmark end into current P for given bookmark
        Parameters:
        bookmarkStart - starting bookmark to close
        isBlockBookmark - true if block bookmark
        Returns:
        CTMarkupRange
      • createBookmarkHyperlink

        org.docx4j.wml.P.Hyperlink createBookmarkHyperlink​(java.lang.String bookmarkName,
                                                           java.lang.String linkText)
        Get a hyperlink to a bookmark in the document
        Parameters:
        bookmarkName - name of the bookmark to link to
        linkText - text of the link
        Returns:
        hyperlink
      • getNextBookmarkId

        int getNextBookmarkId()
        Increment the last id and return the id
        Returns:
        next bookmark id
      • getBookmarkIdAtomic

        java.util.concurrent.atomic.AtomicInteger getBookmarkIdAtomic()
        get the atomic integer used to generate bookmark ids
        Returns:
        the id atomic integer
      • addWrappedText

        @Deprecated
        default org.docx4j.wml.Text addWrappedText()
        Deprecated.
        use addText(String) instead
        Create and add wrapped Text element to R element
        Returns:
        Text element
      • addText

        org.docx4j.wml.Text addText​(java.lang.String value,
                                    boolean noProofRPr,
                                    boolean createR)
        Create and add wrapped Text element to R element set value and optionally space preserve if value starts or ends in a space
        Parameters:
        value - value to set
        noProofRPr - if true will add rPr with noProof tag to R
        createR - if true then create a new R, otherwise add to existing one
        Returns:
        Text element
      • addTextCreateR

        default org.docx4j.wml.Text addTextCreateR​(java.lang.String value,
                                                   boolean noProofRPr)
      • addTextCreateR

        default org.docx4j.wml.Text addTextCreateR​(java.lang.String value)
      • addText

        default org.docx4j.wml.Text addText​(java.lang.String value,
                                            boolean noProofRPr)
      • addText

        default org.docx4j.wml.Text addText​(java.lang.String value)
      • addInstrText

        org.docx4j.wml.Text addInstrText​(java.lang.String value,
                                         boolean noProofRPr,
                                         boolean createR)
        Create and add wrapped Text element to R element as RInstrText set value and optionally space preserve if value starts or ends in a space
        Parameters:
        value - instrText Value
        noProofRPr - if true will add rPr with noProof #BooleanDefaultTrue
        createR - if true then create a new R, otherwise add to existing one
        Returns:
        Text element
      • addInstrTextCreateR

        default org.docx4j.wml.Text addInstrTextCreateR​(java.lang.String value,
                                                        boolean noProofRPr)
      • addInstrTextCreateR

        default org.docx4j.wml.Text addInstrTextCreateR​(java.lang.String value)
      • addInstrText

        default org.docx4j.wml.Text addInstrText​(java.lang.String value,
                                                 boolean noProofRPr)
      • addInstrText

        default org.docx4j.wml.Text addInstrText​(java.lang.String value)
      • addFldChar

        org.docx4j.wml.FldChar addFldChar​(org.docx4j.wml.STFldCharType charType,
                                          boolean createR)
        Create and add wrapped Text element to R element as RInstrText
        Parameters:
        charType - char type to set
        createR - if true then create a new R, otherwise add to existing one
        Returns:
        FldChar element
      • addFldCharCreateR

        default org.docx4j.wml.FldChar addFldCharCreateR​(org.docx4j.wml.STFldCharType charType)
      • addFldChar

        default org.docx4j.wml.FldChar addFldChar​(org.docx4j.wml.STFldCharType charType)
      • addPageBreak

        void addPageBreak()
      • addBreak

        void addBreak​(org.docx4j.wml.STBrType breakType)
      • getContent

        java.util.List<java.lang.Object> getContent()
      • addBold

        org.docx4j.wml.RPr addBold()
      • getRPr

        org.docx4j.wml.RPr getRPr()
      • getBooleanDefaultTrue

        org.docx4j.wml.BooleanDefaultTrue getBooleanDefaultTrue​(boolean value)
      • getCTShd

        org.docx4j.wml.CTShd getCTShd()
        Get CTShd from current R or create rPr if none and CTShd if none
        Returns:
        CTShd
      • createColor

        org.docx4j.wml.Color createColor()
      • createHpsMeasure

        org.docx4j.wml.HpsMeasure createHpsMeasure​(long val)
      • text

        @Deprecated
        default org.docx4j.wml.Text text​(java.lang.String text)
        Deprecated.
        Add text to current P, create R and add wrapped text
        Parameters:
        text - text to add
        Returns:
        text element
      • getStyle

        org.docx4j.wml.Style getStyle​(java.lang.String styleName)
        Get a paragraph style of given name
        Parameters:
        styleName - name of the style
        Returns:
        style
      • getHyperlinkRelationship

        org.docx4j.relationships.Relationship getHyperlinkRelationship​(java.lang.String url)
        Get an external hyperlink relationship for the given url
        Parameters:
        url - url
        Returns:
        relationship
      • getContainerPart

        org.docx4j.openpackaging.parts.Part getContainerPart()
      • addLineBreak

        void addLineBreak()
        Add a line break to current R
      • contextFramed

        void contextFramed​(java.lang.Runnable runnable)
        Run within a context, after run the format providers and containers will be restored.

        Use when you need to create a container or format provider but only for a part of the node rendering process.

        Parameters:
        runnable - code to run
      • renderFencedCodeLines

        void renderFencedCodeLines​(java.lang.CharSequence... lines)
      • renderFencedCodeLines

        void renderFencedCodeLines​(java.util.List<? extends java.lang.CharSequence> lines)
      • getFootnotesPart

        org.docx4j.openpackaging.parts.WordprocessingML.FootnotesPart getFootnotesPart()
                                                                                throws org.docx4j.openpackaging.exceptions.Docx4JException
        Get or create FootnotesPart for the document
        Returns:
        footnotes part
        Throws:
        org.docx4j.openpackaging.exceptions.Docx4JException - if cannot create part
      • addFootnote

        org.docx4j.wml.CTFtnEdn addFootnote​(java.math.BigInteger footnoteID)
                                     throws org.docx4j.openpackaging.exceptions.Docx4JException
        Add footnote and return it
        Parameters:
        footnoteID - re-use footnote id or 0 if new footnote
        Returns:
        footnote element
        Throws:
        org.docx4j.openpackaging.exceptions.Docx4JException - thrown if cannot get or create footnotes part of the document
      • getNodeId

        java.lang.String getNodeId​(Node node)
        Get id for a node
        Parameters:
        node - node
        Returns:
        id string or null if none
      • getValidBookmarkName

        java.lang.String getValidBookmarkName​(java.lang.String id)
        Get a valid bookmark for given id
        Parameters:
        id - node id
        Returns:
        mapped to valid bookmark name
      • getNodeFromId

        Node getNodeFromId​(java.lang.String nodeId)
        Get Node from id
        Parameters:
        nodeId - id string
        Returns:
        node or null if no node with given id attribute is defined