org.apache.poi.xwpf.usermodel
Class XWPFHeaderFooter
- java.lang.Object
-
- org.apache.poi.POIXMLDocumentPart
-
- org.apache.poi.xwpf.usermodel.XWPFHeaderFooter
-
- All Implemented Interfaces:
- IBody
- Direct Known Subclasses:
- XWPFFooter, XWPFHeader
public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBody
Parent of XWPF headers and footers
-
-
Field Summary
-
Fields inherited from class org.apache.poi.POIXMLDocumentPart
DEFAULT_XML_OPTIONS
-
-
Constructor Summary
Constructors Constructor and Description XWPFHeaderFooter(POIXMLDocumentPart parent, PackagePart part, PackageRelationship rel)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtr_getHdrFtr()java.lang.StringaddPictureData(byte[] pictureData, int format)Adds a picture to the document.java.lang.StringaddPictureData(java.io.InputStream is, int format)Adds a picture to the document.java.util.List<XWPFPictureData>getAllPackagePictures()get all Pictures in this packagejava.util.List<XWPFPictureData>getAllPictures()java.util.List<IBodyElement>getBodyElements()Returns an Iterator with paragraphs and tables, in the order that they occur in the text.java.util.List<XWPFParagraph>getListParagraph()get a List of all ParagraphsPOIXMLDocumentPartgetOwner()XWPFParagraphgetParagraph(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP p)if there is a correspondingXWPFParagraphof the parameter ctTable in the paragraphList of this header or footer the method will return this paragraph if there is no correspondingXWPFParagraphthe method will return nullXWPFParagraphgetParagraphArray(int pos)Returns the paragraph that holds the text of the header or footer.java.util.List<XWPFParagraph>getParagraphs()Returns the paragraph(s) that holds the text of the header or footer.POIXMLDocumentPartgetPart()returns the Part, to which the body belongs, which you need for adding relationship to other partsXWPFPictureDatagetPictureDataByID(java.lang.String blipID)returns the PictureData by blipIDXWPFTablegetTable(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl ctTable)XWPFTablegetTableArray(int pos)Returns the table at position posXWPFTableCellgetTableCell(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc cell)get the TableCell which belongs to the TableCelljava.util.List<XWPFTable>getTables()Return the table(s) that holds the text of the header or footer, for complex cases where a paragraph isn't used.java.lang.StringgetText()Returns the textual content of the header/footer, by flattening out the text of its paragraph(s)XWPFDocumentgetXWPFDocument()Return XWPFDocumentXWPFParagraphinsertNewParagraph(org.apache.xmlbeans.XmlCursor cursor)add a new paragraph at position of the cursorXWPFTableinsertNewTbl(org.apache.xmlbeans.XmlCursor cursor)inserts a new Table at the cursor position.voidinsertTable(int pos, XWPFTable table)inserts an existing XWPFTable to the arrays bodyElements and tablesvoidreadHdrFtr()voidsetHeaderFooter(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtr headerFooter)set a new headerFootervoidsetXWPFDocument(XWPFDocument doc)-
Methods inherited from class org.apache.poi.POIXMLDocumentPart
addRelation, createRelationship, createRelationship, getPackagePart, getPackageRelationship, getParent, getRelationById, getRelationId, getRelations, toString
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.poi.xwpf.usermodel.IBody
getPartType
-
-
-
-
Constructor Detail
-
XWPFHeaderFooter
public XWPFHeaderFooter(POIXMLDocumentPart parent, PackagePart part, PackageRelationship rel) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
_getHdrFtr
@Internal public org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtr _getHdrFtr()
-
getBodyElements
public java.util.List<IBodyElement> getBodyElements()
Description copied from interface:IBodyReturns an Iterator with paragraphs and tables, in the order that they occur in the text.- Specified by:
getBodyElementsin interfaceIBody
-
getParagraphs
public java.util.List<XWPFParagraph> getParagraphs()
Returns the paragraph(s) that holds the text of the header or footer. Normally there is only the one paragraph, but there could be more in certain cases, or a table.- Specified by:
getParagraphsin interfaceIBody
-
getTables
public java.util.List<XWPFTable> getTables() throws java.lang.ArrayIndexOutOfBoundsException
Return the table(s) that holds the text of the header or footer, for complex cases where a paragraph isn't used. Normally there's just one paragraph, but some complex headers/footers have a table or two in addition.
-
getText
public java.lang.String getText()
Returns the textual content of the header/footer, by flattening out the text of its paragraph(s)
-
setHeaderFooter
public void setHeaderFooter(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtr headerFooter)
set a new headerFooter
-
getTable
public XWPFTable getTable(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl ctTable)
-
getParagraph
public XWPFParagraph getParagraph(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP p)
if there is a correspondingXWPFParagraphof the parameter ctTable in the paragraphList of this header or footer the method will return this paragraph if there is no correspondingXWPFParagraphthe method will return null- Specified by:
getParagraphin interfaceIBody- Parameters:
p- is instance of CTP and is searching for an XWPFParagraph- Returns:
- null if there is no XWPFParagraph with an corresponding CTPparagraph in the paragraphList of this header or footer XWPFParagraph with the correspondig CTP p
-
getParagraphArray
public XWPFParagraph getParagraphArray(int pos)
Returns the paragraph that holds the text of the header or footer.- Specified by:
getParagraphArrayin interfaceIBody
-
getListParagraph
public java.util.List<XWPFParagraph> getListParagraph()
get a List of all Paragraphs- Returns:
- a list of
XWPFParagraph
-
getAllPictures
public java.util.List<XWPFPictureData> getAllPictures()
-
getAllPackagePictures
public java.util.List<XWPFPictureData> getAllPackagePictures()
get all Pictures in this package- Returns:
- all Pictures in this package
-
addPictureData
public java.lang.String addPictureData(byte[] pictureData, int format) throws InvalidFormatExceptionAdds a picture to the document.- Parameters:
pictureData- The picture dataformat- The format of the picture.- Returns:
- the index to this picture (0 based), the added picture can be obtained from
getAllPictures(). - Throws:
InvalidFormatException
-
addPictureData
public java.lang.String addPictureData(java.io.InputStream is, int format) throws InvalidFormatException, java.io.IOExceptionAdds a picture to the document.- Parameters:
is- The stream to read image fromformat- The format of the picture.- Returns:
- the index to this picture (0 based), the added picture can be obtained from
getAllPictures(). - Throws:
InvalidFormatExceptionjava.io.IOException
-
getPictureDataByID
public XWPFPictureData getPictureDataByID(java.lang.String blipID)
returns the PictureData by blipID- Parameters:
blipID-- Returns:
- XWPFPictureData of a specificID
- Throws:
java.lang.Exception
-
insertNewParagraph
public XWPFParagraph insertNewParagraph(org.apache.xmlbeans.XmlCursor cursor)
add a new paragraph at position of the cursor- Specified by:
insertNewParagraphin interfaceIBody- Parameters:
cursor-- Returns:
- the inserted paragraph
-
insertNewTbl
public XWPFTable insertNewTbl(org.apache.xmlbeans.XmlCursor cursor)
Description copied from interface:IBodyinserts a new Table at the cursor position.- Specified by:
insertNewTblin interfaceIBody- Parameters:
cursor-- Returns:
- the inserted table
-
getOwner
public POIXMLDocumentPart getOwner()
-
getTableArray
public XWPFTable getTableArray(int pos)
Returns the table at position pos- Specified by:
getTableArrayin interfaceIBody- See Also:
IBody.getTableArray(int)
-
insertTable
public void insertTable(int pos, XWPFTable table)inserts an existing XWPFTable to the arrays bodyElements and tables- Specified by:
insertTablein interfaceIBody- Parameters:
pos-table-
-
readHdrFtr
public void readHdrFtr()
-
getTableCell
public XWPFTableCell getTableCell(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc cell)
get the TableCell which belongs to the TableCell- Specified by:
getTableCellin interfaceIBody- Parameters:
cell-
-
setXWPFDocument
public void setXWPFDocument(XWPFDocument doc)
-
getXWPFDocument
public XWPFDocument getXWPFDocument()
Description copied from interface:IBodyReturn XWPFDocument- Specified by:
getXWPFDocumentin interfaceIBody
-
getPart
public POIXMLDocumentPart getPart()
returns the Part, to which the body belongs, which you need for adding relationship to other parts- Specified by:
getPartin interfaceIBody- Returns:
- the Part, to which the body belongs
- See Also:
IBody.getPart()
-
-
DataMelt 3.0 © DataMelt by jWork.ORG