public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBody
POIXMLDocumentPart.RelationPart
Modifier | Constructor and Description |
---|---|
protected |
XWPFHeaderFooter() |
|
XWPFHeaderFooter(POIXMLDocumentPart parent,
PackagePart part) |
Modifier and Type | Method and Description |
---|---|
org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtr |
_getHdrFtr() |
java.lang.String |
addPictureData(byte[] pictureData,
int format)
Adds a picture to the document.
|
java.lang.String |
addPictureData(byte[] pictureData,
PictureType pictureType)
Adds a picture to the document.
|
java.lang.String |
addPictureData(java.io.InputStream is,
int format)
Adds a picture to the document.
|
java.lang.String |
addPictureData(java.io.InputStream is,
PictureType pictureType)
Adds a picture to the document.
|
void |
clearHeaderFooter()
Clears all paragraphs and tables from this header / footer
|
XWPFParagraph |
createParagraph()
Adds a new paragraph at the end of the header or footer
|
XWPFTable |
createTable(int rows,
int cols)
Adds a new table at the end of the header or footer
|
java.util.List<XWPFPictureData> |
getAllPackagePictures()
get all Pictures in this package
|
java.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 Paragraphs
|
POIXMLDocumentPart |
getOwner() |
XWPFParagraph |
getParagraph(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP p)
Returns the paragraph corresponding to the provided
CTP . |
XWPFParagraph |
getParagraphArray(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.
|
POIXMLDocumentPart |
getPart()
returns the Part, to which the body belongs, which you need for adding relationship to other parts
|
XWPFPictureData |
getPictureDataByID(java.lang.String blipID)
returns the PictureData by blipID
|
XWPFTable |
getTable(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl ctTable)
|
XWPFTable |
getTableArray(int pos)
Returns the table at position pos
|
XWPFTableCell |
getTableCell(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc cell)
get the TableCell which belongs to the TableCell
|
java.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.String |
getText()
Returns the textual content of the header/footer,
by flattening out the text of its paragraph(s)
|
XWPFDocument |
getXWPFDocument()
Return XWPFDocument
|
XWPFParagraph |
insertNewParagraph(org.apache.xmlbeans.XmlCursor cursor)
add a new paragraph at position of the cursor
|
XWPFTable |
insertNewTbl(org.apache.xmlbeans.XmlCursor cursor)
inserts a new Table at the cursor position.
|
void |
insertTable(int pos,
XWPFTable table)
inserts an existing XWPFTable to the arrays bodyElements and tables
|
protected void |
onDocumentRead()
Fired when a package part is read
|
protected void |
prepareForCommit()
Ensure that a memory based package part does not have lingering data from previous
commit() calls.
|
void |
readHdrFtr() |
void |
removeParagraph(XWPFParagraph paragraph)
Removes a specific paragraph from this header / footer
|
void |
removeTable(XWPFTable table)
Removes a specific table from this header / footer
|
void |
setHeaderFooter(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtr headerFooter)
set a new headerFooter
|
void |
setXWPFDocument(XWPFDocument doc) |
_invokeOnDocumentRead, addRelation, commit, createRelationship, createRelationship, createRelationship, getNextPartNumber, getPackagePart, getParent, getRelationById, getRelationId, getRelationPartById, getRelationParts, getRelations, getTargetPart, isCommitted, onDocumentCreate, onDocumentRemove, onSave, read, rebase, removeRelation, removeRelation, removeRelation, setCommitted, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getPartType
protected XWPFHeaderFooter()
public XWPFHeaderFooter(POIXMLDocumentPart parent, PackagePart part)
protected void onDocumentRead() throws java.io.IOException
POIXMLDocumentPart
onDocumentRead
in class POIXMLDocumentPart
java.io.IOException
- a subclass may throw an IOException when a document is read@Internal public org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtr _getHdrFtr()
public java.util.List<IBodyElement> getBodyElements()
IBody
getBodyElements
in interface IBody
public java.util.List<XWPFParagraph> getParagraphs()
getParagraphs
in interface IBody
public java.util.List<XWPFTable> getTables() throws java.lang.ArrayIndexOutOfBoundsException
public java.lang.String getText()
public void setHeaderFooter(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtr headerFooter)
public XWPFTable getTable(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl ctTable)
public XWPFParagraph getParagraph(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP p)
IBody
CTP
.getParagraph
in interface IBody
p
- is instance of CTP and is searching for an XWPFParagraphCTP
, or null
if there is no corresponding paragraph in
this body.public XWPFParagraph getParagraphArray(int pos)
getParagraphArray
in interface IBody
public java.util.List<XWPFParagraph> getListParagraph()
XWPFParagraph
public java.util.List<XWPFPictureData> getAllPictures()
public java.util.List<XWPFPictureData> getAllPackagePictures()
public java.lang.String addPictureData(byte[] pictureData, int format) throws InvalidFormatException
pictureData
- The picture dataformat
- The format of the picture.getAllPictures()
.InvalidFormatException
- If the format of the picture is not known.addPictureData(byte[], PictureType)
public java.lang.String addPictureData(byte[] pictureData, PictureType pictureType) throws InvalidFormatException
pictureData
- The picture datapictureType
- The PictureType
of the picture.getAllPictures()
.InvalidFormatException
- If the format of the picture is not known.public java.lang.String addPictureData(java.io.InputStream is, int format) throws InvalidFormatException, java.io.IOException
is
- The stream to read image fromformat
- The format of the picture.getAllPictures()
.InvalidFormatException
- If the format of the picture is not known.java.io.IOException
- If reading the picture-data from the stream fails.addPictureData(InputStream, PictureType)
public java.lang.String addPictureData(java.io.InputStream is, PictureType pictureType) throws InvalidFormatException, java.io.IOException
is
- The stream to read image frompictureType
- The PictureType
of the picture.getAllPictures()
.InvalidFormatException
- If the format of the picture is not known.java.io.IOException
- If reading the picture-data from the stream fails.public XWPFPictureData getPictureDataByID(java.lang.String blipID)
public XWPFParagraph createParagraph()
XWPFParagraph
objectpublic XWPFTable createTable(int rows, int cols)
rows
- - number of rows in the tablecols
- - number of columns in the tableXWPFTable
objectpublic void removeParagraph(XWPFParagraph paragraph)
paragraph
- - XWPFParagraph
object to removepublic void removeTable(XWPFTable table)
table
- - XWPFTable
object to removepublic void clearHeaderFooter()
public XWPFParagraph insertNewParagraph(org.apache.xmlbeans.XmlCursor cursor)
insertNewParagraph
in interface IBody
public XWPFTable insertNewTbl(org.apache.xmlbeans.XmlCursor cursor)
IBody
insertNewTbl
in interface IBody
public POIXMLDocumentPart getOwner()
public XWPFTable getTableArray(int pos)
getTableArray
in interface IBody
public void insertTable(int pos, XWPFTable table)
insertTable
in interface IBody
public void readHdrFtr()
public XWPFTableCell getTableCell(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc cell)
getTableCell
in interface IBody
public XWPFDocument getXWPFDocument()
IBody
getXWPFDocument
in interface IBody
public void setXWPFDocument(XWPFDocument doc)
public POIXMLDocumentPart getPart()
protected void prepareForCommit()
POIXMLDocumentPart
Note: This is overwritten for some objects, as *PictureData seem to store the actual content in the part directly without keeping a copy like all others therefore we need to handle them differently.
prepareForCommit
in class POIXMLDocumentPart
Copyright 2022 The Apache Software Foundation or its licensors, as applicable.