Class DOCXDocument

All Implemented Interfaces:
ICTElement, IDOCXVisitable<Object>, IXWPFElement

public class DOCXDocument extends AbstractBody
Internal Use Only.

Document Definition.

Represents w:document in xml.

Author:
Jamson Chan
  • Constructor Details

    • DOCXDocument

      public DOCXDocument(org.apache.poi.xwpf.usermodel.XWPFDocument xwpfDocument)
      Create a new Document by given XWPFDocument.
      Parameters:
      xwpfDocument - the XWPFDocument object.
  • Method Details

    • getCT

      public org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDocument1 getCT()
      Description copied from interface: ICTElement
      Returns the CT object of current element.
    • accept

      public Object accept(IDOCXVisitor visitor)
      Description copied from interface: IDOCXVisitable
      Accepts a visitor.
    • getXWPF

      public org.apache.poi.xwpf.usermodel.XWPFDocument getXWPF()
      Description copied from interface: IXWPFElement
      Returns the XWPF object of current element.
      Specified by:
      getXWPF in interface IXWPFElement
      Overrides:
      getXWPF in class AbstractBody
    • getParent

      public IXWPFElement getParent()
      Description copied from interface: IXWPFElement
      Returns the parent element of current element.
    • write

      public void write(OutputStream os) throws IOException
      Write the document to the given file output stream.
      Parameters:
      os - the OutputStream.
      Throws:
      IOException - if an I/O error occurs.
    • getSettings

      public DOCXSettings getSettings()
      Returns the settings of this document.

      Represents the xml file at word/settings.xml.

      Returns:
      the DOCXSettings object.
    • getStyles

      public DOCXStyles getStyles()
      Returns the styles of this document.

      Represents the xml file at word/styles.xml.

      Returns:
      the DOCXStyles object.
    • createParagraph

      public DOCXP createParagraph()
      Description copied from class: AbstractBody
      Create a new Paragraph.
      Specified by:
      createParagraph in class AbstractBody
      Returns:
      the new Paragraph.
    • createTable

      public DOCXTbl createTable()
      Description copied from class: AbstractBody
      Create a new Table.
      Specified by:
      createTable in class AbstractBody
      Returns:
      the new Table.
    • getSectPr

      public DOCXSectPr getSectPr()
      Returns the DOCXSectPr of this document (equals to the last section of the whole docx file).
      Returns:
      the DOCXSectPr object.
    • getSectPr

      public DOCXSectPr getSectPr(boolean create)
      Returns the DOCXSectPr of this document (equals to the last section of the whole docx file).

      Represents the following element tag in the schema: w:sectPr.

      Parameters:
      create - whether to create a new section properties if not exist.
      Returns:
      the DOCXSectPr object.
    • getHeaderById

      public DOCXHdr getHeaderById(String id)
      Returns the DOCXHdr by the given id.
      Parameters:
      id - the header id.
      Returns:
      the DOCXHdr object.
    • getFooterById

      public DOCXFtr getFooterById(String id)
      Returns the DOCXFtr by the given id.
      Parameters:
      id - the footer id.
      Returns:
      the DOCXFtr object.
    • getNumbering

      public org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLvl getNumbering(BigInteger numId, BigInteger level)
      Returns the numbering data CTLvl for a specific numbering id and level.
      Parameters:
      numId - the numbering id (w:numId) in the document
      level - the level number (w:ilvl) in the abstract numbering id
      Returns:
      the CTLvl containing the numbering data
    • addNumbering

      public BigInteger addNumbering(org.openxmlformats.schemas.wordprocessingml.x2006.main.STNumberFormat.Enum format, String lvlText, BigInteger indent)
      Adds a new numbering definition to the document, and returns the numbering id of this new numbering.
      Parameters:
      format - the numbering format
      lvlText - the text to display for the numbering level
      indent - the indentation for the numbering
      Returns:
      the numbering id for the newly added numbering definition
    • resetPrevNumberingData

      public void resetPrevNumberingData()
      Resets the previous numbering data.

      This method is used to switch to new numbering group.