org.apache.poi.xwpf.converter.core
Class XWPFDocumentVisitor<T,O extends Options,E extends IXWPFMasterPage>

java.lang.Object
  extended by org.apache.poi.xwpf.converter.core.XWPFDocumentVisitor<T,O,E>
Type Parameters:
T -
O -
E -
Direct Known Subclasses:
PdfMapper, XHTMLMapper

public abstract class XWPFDocumentVisitor<T,O extends Options,E extends IXWPFMasterPage>
extends Object

Visitor to visit elements from entry word/document.xml, word/header*.xml, word/footer*.xml


Field Summary
protected  org.apache.poi.xwpf.usermodel.XWPFDocument document
           
protected  O options
           
protected  XWPFStylesDocument stylesDocument
           
protected static String WORD_MEDIA
           
 
Constructor Summary
XWPFDocumentVisitor(org.apache.poi.xwpf.usermodel.XWPFDocument document, O options)
           
 
Method Summary
protected abstract  void addNewLine(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBr br, T paragraphContainer)
           
protected abstract  IXWPFMasterPage createMasterPage(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSectPr sectPr)
          Create an instance of master page.
protected  XWPFStylesDocument createStylesDocument(org.apache.poi.xwpf.usermodel.XWPFDocument document)
           
protected abstract  void endVisitDocument()
          End of visit document.
protected abstract  void endVisitParagraph(org.apache.poi.xwpf.usermodel.XWPFParagraph paragraph, T parentContainer, T paragraphContainer)
           
protected abstract  void endVisitTable(org.apache.poi.xwpf.usermodel.XWPFTable table, T parentContainer, T tableContainer)
           
protected abstract  void endVisitTableCell(org.apache.poi.xwpf.usermodel.XWPFTableCell cell, T tableContainer, T tableCellContainer)
           
protected  void endVisitTableRow(org.apache.poi.xwpf.usermodel.XWPFTableRow row, T tableContainer, boolean firstRow, boolean lastRow, boolean headerRow)
           
protected  List<org.apache.poi.xwpf.usermodel.IBodyElement> getBodyElements(org.apache.poi.xwpf.usermodel.XWPFHeaderFooter part)
          Returns the list of IBodyElement of the given header/footer.
protected  IImageExtractor getImageExtractor()
          Returns the image extractor and null otherwise.
 MasterPageManager getMasterPageManager()
           
 O getOptions()
           
 org.apache.poi.xwpf.usermodel.XWPFPictureData getPictureData(org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture picture)
          Returns the picture data of the given picture.
protected  org.apache.poi.xwpf.usermodel.XWPFPictureData getPictureDataByID(String blipId)
          Returns the picture data of the given image id.
 XWPFStylesDocument getStylesDocument()
           
protected  org.apache.poi.xwpf.usermodel.XWPFAbstractNum getXWPFAbstractNum(org.apache.poi.xwpf.usermodel.XWPFNum num)
           
protected  org.apache.poi.xwpf.usermodel.XWPFFooter getXWPFFooter(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtrRef footerRef)
          Returns the XWPFFooter of the given footer reference.
protected  org.apache.poi.xwpf.usermodel.XWPFHeader getXWPFHeader(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtrRef headerRef)
          Returns the XWPFHeader of the given header reference.
protected  org.apache.poi.xwpf.usermodel.XWPFNum getXWPFNum(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTNumPr numPr)
           
protected  org.apache.poi.xwpf.usermodel.XWPFStyle getXWPFStyle(String styleID)
           
protected  boolean isWordDocumentPartParsing()
          Returns true if word/document.xml is parsing and false otherwise.
protected abstract  void pageBreak()
           
protected abstract  void setActiveMasterPage(E masterPage)
          Set active master page.
 void start()
          Main entry for visit XWPFDocument.
protected abstract  T startVisitDocument()
          Start of visit document.
protected abstract  T startVisitParagraph(org.apache.poi.xwpf.usermodel.XWPFParagraph paragraph, ListItemContext itemContext, T parentContainer)
           
protected abstract  T startVisitTable(org.apache.poi.xwpf.usermodel.XWPFTable table, float[] colWidths, T tableContainer)
           
protected abstract  T startVisitTableCell(org.apache.poi.xwpf.usermodel.XWPFTableCell cell, T tableContainer, boolean firstRow, boolean lastRow, boolean firstCol, boolean lastCol, List<org.apache.poi.xwpf.usermodel.XWPFTableCell> vMergeCells)
           
protected  void startVisitTableRow(org.apache.poi.xwpf.usermodel.XWPFTableRow row, T tableContainer, int rowIndex, boolean headerRow)
           
protected  void visitAnchor(org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTAnchor anchor, T parentContainer)
           
protected  void visitBodyElements(List<org.apache.poi.xwpf.usermodel.IBodyElement> bodyElements, T container)
           
protected abstract  void visitBookmark(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBookmark bookmark, org.apache.poi.xwpf.usermodel.XWPFParagraph paragraph, T paragraphContainer)
           
protected  void visitBR(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBr br, T paragraphContainer)
           
protected  void visitCell(org.apache.poi.xwpf.usermodel.XWPFTableCell cell, T tableContainer, boolean firstRow, boolean lastRow, boolean firstCol, boolean lastCol, int rowIndex, int cellIndex, List<org.apache.poi.xwpf.usermodel.XWPFTableCell> vMergedCells)
           
protected  void visitDrawing(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDrawing drawing, T parentContainer)
           
protected abstract  void visitEmptyRun(T paragraphContainer)
           
protected abstract  void visitFooter(org.apache.poi.xwpf.usermodel.XWPFFooter footer, org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtrRef footerRef, org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSectPr sectPr, E masterPage)
           
protected  void visitFooterRef(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtrRef footerRef, org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSectPr sectPr, E masterPage)
           
protected abstract  void visitHeader(org.apache.poi.xwpf.usermodel.XWPFHeader header, org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtrRef headerRef, org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSectPr sectPr, E masterPage)
           
protected  void visitHeaderRef(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtrRef headerRef, org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSectPr sectPr, E masterPage)
           
protected  void visitInline(org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTInline inline, T parentContainer)
           
protected  void visitParagraph(org.apache.poi.xwpf.usermodel.XWPFParagraph paragraph, int index, T container)
          Visit the given paragraph.
protected  void visitParagraphBody(org.apache.poi.xwpf.usermodel.XWPFParagraph paragraph, int index, T paragraphContainer)
           
protected abstract  void visitPicture(org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture picture, Float offsetX, org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.STRelFromH.Enum relativeFromH, Float offsetY, org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.STRelFromV.Enum relativeFromV, org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.STWrapText.Enum wrapText, T parentContainer)
           
protected  void visitRun(org.apache.poi.xwpf.usermodel.XWPFRun run, boolean pageNumber, String url, T paragraphContainer)
           
protected abstract  void visitTab(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPTab o, T paragraphContainer)
           
protected  void visitTable(org.apache.poi.xwpf.usermodel.XWPFTable table, int index, T container)
           
protected  void visitTableBody(org.apache.poi.xwpf.usermodel.XWPFTable table, float[] colWidths, T tableContainer)
           
protected  void visitTableCellBody(org.apache.poi.xwpf.usermodel.XWPFTableCell cell, List<org.apache.poi.xwpf.usermodel.XWPFTableCell> vMergeCells, T tableCellContainer)
           
protected  void visitTableRow(org.apache.poi.xwpf.usermodel.XWPFTableRow row, float[] colWidths, T tableContainer, boolean firstRow, boolean lastRowIfNoneVMerge, int rowIndex, int rowsSize)
           
protected abstract  void visitTabs(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTabs tabs, T paragraphContainer)
           
protected abstract  void visitText(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTText ctText, boolean pageNumber, T paragraphContainer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WORD_MEDIA

protected static final String WORD_MEDIA
See Also:
Constant Field Values

document

protected final org.apache.poi.xwpf.usermodel.XWPFDocument document

stylesDocument

protected final XWPFStylesDocument stylesDocument

options

protected final O extends Options options
Constructor Detail

XWPFDocumentVisitor

public XWPFDocumentVisitor(org.apache.poi.xwpf.usermodel.XWPFDocument document,
                           O options)
                    throws Exception
Throws:
Exception
Method Detail

createStylesDocument

protected XWPFStylesDocument createStylesDocument(org.apache.poi.xwpf.usermodel.XWPFDocument document)
                                           throws org.apache.xmlbeans.XmlException,
                                                  IOException
Throws:
org.apache.xmlbeans.XmlException
IOException

getStylesDocument

public XWPFStylesDocument getStylesDocument()

getOptions

public O getOptions()

getMasterPageManager

public MasterPageManager getMasterPageManager()

start

public void start()
           throws Exception
Main entry for visit XWPFDocument.

Parameters:
out -
Throws:
Exception

startVisitDocument

protected abstract T startVisitDocument()
                                 throws Exception
Start of visit document.

Returns:
Throws:
Exception

endVisitDocument

protected abstract void endVisitDocument()
                                  throws Exception
End of visit document.

Throws:
Exception

visitBodyElements

protected void visitBodyElements(List<org.apache.poi.xwpf.usermodel.IBodyElement> bodyElements,
                                 T container)
                          throws Exception
Throws:
Exception

visitParagraph

protected void visitParagraph(org.apache.poi.xwpf.usermodel.XWPFParagraph paragraph,
                              int index,
                              T container)
                       throws Exception
Visit the given paragraph.

Parameters:
paragraph -
index -
container -
Throws:
Exception

startVisitParagraph

protected abstract T startVisitParagraph(org.apache.poi.xwpf.usermodel.XWPFParagraph paragraph,
                                         ListItemContext itemContext,
                                         T parentContainer)
                                  throws Exception
Throws:
Exception

endVisitParagraph

protected abstract void endVisitParagraph(org.apache.poi.xwpf.usermodel.XWPFParagraph paragraph,
                                          T parentContainer,
                                          T paragraphContainer)
                                   throws Exception
Throws:
Exception

visitParagraphBody

protected void visitParagraphBody(org.apache.poi.xwpf.usermodel.XWPFParagraph paragraph,
                                  int index,
                                  T paragraphContainer)
                           throws Exception
Throws:
Exception

getXWPFNum

protected org.apache.poi.xwpf.usermodel.XWPFNum getXWPFNum(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTNumPr numPr)

getXWPFAbstractNum

protected org.apache.poi.xwpf.usermodel.XWPFAbstractNum getXWPFAbstractNum(org.apache.poi.xwpf.usermodel.XWPFNum num)

visitEmptyRun

protected abstract void visitEmptyRun(T paragraphContainer)
                               throws Exception
Throws:
Exception

visitRun

protected void visitRun(org.apache.poi.xwpf.usermodel.XWPFRun run,
                        boolean pageNumber,
                        String url,
                        T paragraphContainer)
                 throws Exception
Throws:
Exception

visitText

protected abstract void visitText(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTText ctText,
                                  boolean pageNumber,
                                  T paragraphContainer)
                           throws Exception
Throws:
Exception

visitTab

protected abstract void visitTab(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPTab o,
                                 T paragraphContainer)
                          throws Exception
Throws:
Exception

visitTabs

protected abstract void visitTabs(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTabs tabs,
                                  T paragraphContainer)
                           throws Exception
Throws:
Exception

visitBR

protected void visitBR(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBr br,
                       T paragraphContainer)
                throws Exception
Throws:
Exception

visitBookmark

protected abstract void visitBookmark(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBookmark bookmark,
                                      org.apache.poi.xwpf.usermodel.XWPFParagraph paragraph,
                                      T paragraphContainer)
                               throws Exception
Throws:
Exception

addNewLine

protected abstract void addNewLine(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBr br,
                                   T paragraphContainer)
                            throws Exception
Throws:
Exception

pageBreak

protected abstract void pageBreak()
                           throws Exception
Throws:
Exception

visitTable

protected void visitTable(org.apache.poi.xwpf.usermodel.XWPFTable table,
                          int index,
                          T container)
                   throws Exception
Throws:
Exception

visitTableBody

protected void visitTableBody(org.apache.poi.xwpf.usermodel.XWPFTable table,
                              float[] colWidths,
                              T tableContainer)
                       throws Exception
Throws:
Exception

startVisitTable

protected abstract T startVisitTable(org.apache.poi.xwpf.usermodel.XWPFTable table,
                                     float[] colWidths,
                                     T tableContainer)
                              throws Exception
Throws:
Exception

endVisitTable

protected abstract void endVisitTable(org.apache.poi.xwpf.usermodel.XWPFTable table,
                                      T parentContainer,
                                      T tableContainer)
                               throws Exception
Throws:
Exception

visitTableRow

protected void visitTableRow(org.apache.poi.xwpf.usermodel.XWPFTableRow row,
                             float[] colWidths,
                             T tableContainer,
                             boolean firstRow,
                             boolean lastRowIfNoneVMerge,
                             int rowIndex,
                             int rowsSize)
                      throws Exception
Throws:
Exception

startVisitTableRow

protected void startVisitTableRow(org.apache.poi.xwpf.usermodel.XWPFTableRow row,
                                  T tableContainer,
                                  int rowIndex,
                                  boolean headerRow)
                           throws Exception
Throws:
Exception

endVisitTableRow

protected void endVisitTableRow(org.apache.poi.xwpf.usermodel.XWPFTableRow row,
                                T tableContainer,
                                boolean firstRow,
                                boolean lastRow,
                                boolean headerRow)
                         throws Exception
Throws:
Exception

visitCell

protected void visitCell(org.apache.poi.xwpf.usermodel.XWPFTableCell cell,
                         T tableContainer,
                         boolean firstRow,
                         boolean lastRow,
                         boolean firstCol,
                         boolean lastCol,
                         int rowIndex,
                         int cellIndex,
                         List<org.apache.poi.xwpf.usermodel.XWPFTableCell> vMergedCells)
                  throws Exception
Throws:
Exception

visitTableCellBody

protected void visitTableCellBody(org.apache.poi.xwpf.usermodel.XWPFTableCell cell,
                                  List<org.apache.poi.xwpf.usermodel.XWPFTableCell> vMergeCells,
                                  T tableCellContainer)
                           throws Exception
Throws:
Exception

startVisitTableCell

protected abstract T startVisitTableCell(org.apache.poi.xwpf.usermodel.XWPFTableCell cell,
                                         T tableContainer,
                                         boolean firstRow,
                                         boolean lastRow,
                                         boolean firstCol,
                                         boolean lastCol,
                                         List<org.apache.poi.xwpf.usermodel.XWPFTableCell> vMergeCells)
                                  throws Exception
Throws:
Exception

endVisitTableCell

protected abstract void endVisitTableCell(org.apache.poi.xwpf.usermodel.XWPFTableCell cell,
                                          T tableContainer,
                                          T tableCellContainer)
                                   throws Exception
Throws:
Exception

getXWPFStyle

protected org.apache.poi.xwpf.usermodel.XWPFStyle getXWPFStyle(String styleID)

isWordDocumentPartParsing

protected boolean isWordDocumentPartParsing()
Returns true if word/document.xml is parsing and false otherwise.

Returns:
true if word/document.xml is parsing and false otherwise.

visitHeaderRef

protected void visitHeaderRef(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtrRef headerRef,
                              org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSectPr sectPr,
                              E masterPage)
                       throws Exception
Throws:
Exception

visitHeader

protected abstract void visitHeader(org.apache.poi.xwpf.usermodel.XWPFHeader header,
                                    org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtrRef headerRef,
                                    org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSectPr sectPr,
                                    E masterPage)
                             throws Exception
Throws:
Exception

visitFooterRef

protected void visitFooterRef(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtrRef footerRef,
                              org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSectPr sectPr,
                              E masterPage)
                       throws Exception
Throws:
Exception

visitFooter

protected abstract void visitFooter(org.apache.poi.xwpf.usermodel.XWPFFooter footer,
                                    org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtrRef footerRef,
                                    org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSectPr sectPr,
                                    E masterPage)
                             throws Exception
Throws:
Exception

getBodyElements

protected List<org.apache.poi.xwpf.usermodel.IBodyElement> getBodyElements(org.apache.poi.xwpf.usermodel.XWPFHeaderFooter part)
Returns the list of IBodyElement of the given header/footer. We do that because XWPFHeaderFooter.getBodyElements() doesn't contains the //

Parameters:
part -
Returns:

getXWPFHeader

protected org.apache.poi.xwpf.usermodel.XWPFHeader getXWPFHeader(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtrRef headerRef)
                                                          throws org.apache.xmlbeans.XmlException,
                                                                 IOException
Returns the XWPFHeader of the given header reference.

Parameters:
headerref - the header reference.
Returns:
Throws:
org.apache.xmlbeans.XmlException
IOException

getXWPFFooter

protected org.apache.poi.xwpf.usermodel.XWPFFooter getXWPFFooter(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtrRef footerRef)
                                                          throws org.apache.xmlbeans.XmlException,
                                                                 IOException
Returns the XWPFFooter of the given footer reference.

Parameters:
footerRef - the footer reference.
Returns:
Throws:
org.apache.xmlbeans.XmlException
IOException

visitDrawing

protected void visitDrawing(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDrawing drawing,
                            T parentContainer)
                     throws Exception
Throws:
Exception

visitAnchor

protected void visitAnchor(org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTAnchor anchor,
                           T parentContainer)
                    throws Exception
Throws:
Exception

visitInline

protected void visitInline(org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTInline inline,
                           T parentContainer)
                    throws Exception
Throws:
Exception

getPictureDataByID

protected org.apache.poi.xwpf.usermodel.XWPFPictureData getPictureDataByID(String blipId)
Returns the picture data of the given image id.

Parameters:
blipId -
Returns:

getImageExtractor

protected IImageExtractor getImageExtractor()
Returns the image extractor and null otherwise.

Returns:

getPictureData

public org.apache.poi.xwpf.usermodel.XWPFPictureData getPictureData(org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture picture)
Returns the picture data of the given picture.

Parameters:
picture -
Returns:

visitPicture

protected abstract void visitPicture(org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture picture,
                                     Float offsetX,
                                     org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.STRelFromH.Enum relativeFromH,
                                     Float offsetY,
                                     org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.STRelFromV.Enum relativeFromV,
                                     org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.STWrapText.Enum wrapText,
                                     T parentContainer)
                              throws Exception
Throws:
Exception

setActiveMasterPage

protected abstract void setActiveMasterPage(E masterPage)
Set active master page.

Parameters:
masterPage -

createMasterPage

protected abstract IXWPFMasterPage createMasterPage(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSectPr sectPr)
Create an instance of master page.

Parameters:
sectPr -
Returns:


Copyright © 2013. All rights reserved.