java.lang.Object
org.wickedsource.docxstamper.util.DocumentUtil
Utility class to retrieve elements from a document.
- Since:
- 1.4.7
- Version:
- ${version}
- Author:
- Joseph Verron, DallanMC
-
Method Summary
Modifier and TypeMethodDescriptionallElements(org.docx4j.openpackaging.packages.WordprocessingMLPackage subDocument) Retrieve the last element from an object.static booleandepthElementSearch(Object searchTarget, Object content) Recursively searches for an element in a content tree.static org.docx4j.wml.ContentAccessorfindSmallestCommonParent(Object o1, Object o2) Finds the smallest common parent between two objects.static List<org.docx4j.wml.P> getParagraphsFromObject(Object parentObject) Deprecated, for removal: This API element is subject to removal in a future version.method not used internally so will be removedstatic List<org.docx4j.wml.Tc> getTableCellsFromObject(Object parentObject) Deprecated, for removal: This API element is subject to removal in a future version.method not used internally so will be removedstatic List<org.docx4j.wml.Tbl> getTableFromObject(Object parentObject) Deprecated, for removal: This API element is subject to removal in a future version.method not used internally so will be removedstatic List<org.docx4j.wml.Tr> getTableRowsFromObject(Object parentObject) Deprecated, for removal: This API element is subject to removal in a future version.method not used internally so will be removedstatic ObjectlastElement(org.docx4j.openpackaging.packages.WordprocessingMLPackage subDocument) Retrieve the first element from an object.static <T> Stream<T> streamElements(Object object, Class<T> elementClass) Retrieve all the elements of a given class from an object.static Stream<org.docx4j.wml.P> streamParagraphs(org.docx4j.openpackaging.packages.WordprocessingMLPackage document) Retrieve all the runs from a document.static Map<org.docx4j.wml.R, org.docx4j.wml.R> walkObjectsAndImportImages(org.docx4j.openpackaging.packages.WordprocessingMLPackage source, org.docx4j.openpackaging.packages.WordprocessingMLPackage target) Recursively walk through a source to find embedded images and import them in the target document.static Map<org.docx4j.wml.R, org.docx4j.wml.R> walkObjectsAndImportImages(org.docx4j.wml.ContentAccessor container, org.docx4j.openpackaging.packages.WordprocessingMLPackage source, org.docx4j.openpackaging.packages.WordprocessingMLPackage target) Recursively walk through source accessor to find embedded images and import the target document.
-
Method Details
-
getParagraphsFromObject
@Deprecated(since="1.6.8", forRemoval=true) public static List<org.docx4j.wml.P> getParagraphsFromObject(Object parentObject) Deprecated, for removal: This API element is subject to removal in a future version.method not used internally so will be removedRetrieve all the paragraphs from a document- Parameters:
parentObject- the document to get the paragraphs from- Returns:
- a list of paragraphs
-
streamElements
Retrieve all the elements of a given class from an object.- Type Parameters:
T- the type of the elements to get- Parameters:
object- the object to get the elements fromelementClass- the class of the elements to get- Returns:
- a stream of the elements
-
getTableFromObject
@Deprecated(since="1.6.8", forRemoval=true) public static List<org.docx4j.wml.Tbl> getTableFromObject(Object parentObject) Deprecated, for removal: This API element is subject to removal in a future version.method not used internally so will be removedRetrieve all the tables from an object.- Parameters:
parentObject- the object to get the tables from- Returns:
- a list of tables
-
getTableRowsFromObject
@Deprecated(since="1.6.8", forRemoval=true) public static List<org.docx4j.wml.Tr> getTableRowsFromObject(Object parentObject) Deprecated, for removal: This API element is subject to removal in a future version.method not used internally so will be removedRetrieve all the rows from an object.- Parameters:
parentObject- the object to get the rows from- Returns:
- a list of rows
-
getTableCellsFromObject
@Deprecated(since="1.6.8", forRemoval=true) public static List<org.docx4j.wml.Tc> getTableCellsFromObject(Object parentObject) Deprecated, for removal: This API element is subject to removal in a future version.method not used internally so will be removedRetrieve all the cells from an object.- Parameters:
parentObject- the object to get the cells from- Returns:
- a list of cells
-
lastElement
public static Object lastElement(org.docx4j.openpackaging.packages.WordprocessingMLPackage subDocument) Retrieve the first element from an object.- Parameters:
subDocument- the object to get the first element from- Returns:
- the first element
-
allElements
public static List<Object> allElements(org.docx4j.openpackaging.packages.WordprocessingMLPackage subDocument) Retrieve the last element from an object.- Parameters:
subDocument- the object to get the last element from- Returns:
- the last element
-
walkObjectsAndImportImages
public static Map<org.docx4j.wml.R,org.docx4j.wml.R> walkObjectsAndImportImages(org.docx4j.openpackaging.packages.WordprocessingMLPackage source, org.docx4j.openpackaging.packages.WordprocessingMLPackage target) Recursively walk through a source to find embedded images and import them in the target document.- Parameters:
source- source document containing image files.target- target document to add image files to.- Returns:
- a
Mapobject
-
walkObjectsAndImportImages
public static Map<org.docx4j.wml.R,org.docx4j.wml.R> walkObjectsAndImportImages(org.docx4j.wml.ContentAccessor container, org.docx4j.openpackaging.packages.WordprocessingMLPackage source, org.docx4j.openpackaging.packages.WordprocessingMLPackage target) Recursively walk through source accessor to find embedded images and import the target document.- Parameters:
container- source container to walk.source- source document containing image files.target- target document to add image files to.- Returns:
- a
Mapobject
-
streamParagraphs
public static Stream<org.docx4j.wml.P> streamParagraphs(org.docx4j.openpackaging.packages.WordprocessingMLPackage document) Retrieve all the runs from a document.- Parameters:
document- the document to get the runs from- Returns:
- the runs
-
findSmallestCommonParent
Finds the smallest common parent between two objects.- Parameters:
o1- the first objecto2- the second object- Returns:
- the smallest common parent of the two objects
- Throws:
OfficeStamperException- if there is an error finding the common parent
-
depthElementSearch
Recursively searches for an element in a content tree.- Parameters:
searchTarget- the element to search forcontent- the content tree to search in- Returns:
- true if the element is found, false otherwise
-