Package org.apache.poi.xwpf.usermodel
Class XWPFTheme
java.lang.Object
org.apache.poi.ooxml.POIXMLDocumentPart
org.apache.poi.xwpf.usermodel.XWPFTheme
A shared style sheet in a .docx document
- Since:
- 5.2.4
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
POIXMLDocumentPart.RelationPart -
Constructor Summary
ConstructorsConstructorDescriptionConstruct XWPFStyles from scratch for a new document.XWPFTheme(PackagePart part) Construct XWPFStyles from a package part -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcommit()Save the content in the underlying package part.org.openxmlformats.schemas.drawingml.x2006.main.CTColorgetCTColor(String name) Get a color from the theme's color scheme by nameorg.openxmlformats.schemas.drawingml.x2006.main.CTOfficeStyleSheetgetMajorFontForScript(String script) getMinorFontForScript(String script) getName()voidimportTheme(XSLFTheme theme) protected voidRead documentvoidSet name of this themevoidsetTheme(org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeStyleSheet theme) Methods inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
_invokeOnDocumentRead, addRelation, createHyperlink, createRelationship, createRelationship, createRelationship, getNextPartNumber, getPackagePart, getParent, getReferenceRelationship, getReferenceRelationships, getRelationById, getRelationId, getRelationPartById, getRelationParts, getRelations, getTargetPart, isCommitted, onDocumentCreate, onDocumentRemove, onSave, prepareForCommit, read, rebase, removeReferenceRelationship, removeRelation, removeRelation, removeRelation, setCommitted, toString
-
Constructor Details
-
XWPFTheme
Construct XWPFStyles from a package part- Parameters:
part- the package part holding the data of the styles
-
XWPFTheme
public XWPFTheme()Construct XWPFStyles from scratch for a new document.
-
-
Method Details
-
importTheme
-
getCTOfficeStyleSheet
public org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeStyleSheet getCTOfficeStyleSheet()- Returns:
- the underlying CTOfficeStyleSheet instance.
- Since:
- 6.0.0
-
getName
- Returns:
- name of this theme, e.g. "Office Theme"
-
setName
Set name of this theme- Parameters:
name- name of this theme
-
getCTColor
Get a color from the theme's color scheme by name- Returns:
- a theme color or
nullif not found
-
getMajorFont
- Returns:
- typeface of the major font to use in a document (possibly
null). Typically, the major font is used for heading areas of a document.
-
getMinorFont
- Returns:
- typeface of the minor font to use in a document (possibly
null). Typically, the minor font is used for normal text or paragraph areas.
-
getMajorFontForScript
- Parameters:
script- a 4-letter script code, e.g. "Latn", "Jpan"- Returns:
- typeface of the major font for the given script (possibly
null) - Since:
- 6.0.0
-
getMinorFontForScript
- Parameters:
script- a 4-letter script code, e.g. "Latn", "Jpan"- Returns:
- typeface of the minor font for the given script (possibly
null) - Since:
- 6.0.0
-
onDocumentRead
Read document- Overrides:
onDocumentReadin classPOIXMLDocumentPart- Throws:
IOException- a subclass may throw an IOException when a document is read
-
commit
Description copied from class:POIXMLDocumentPartSave the content in the underlying package part. Default implementation is empty meaning that the package part is left unmodified.Sub-classes should override and add logic to marshal the "model" into Ooxml4J.
For example, the code saving a generic XML entry may look as follows:
protected void commit() throws IOException { PackagePart part = getPackagePart(); try (OutputStream out = part.getOutputStream()) { XmlObject bean = getXmlBean(); //the "model" which holds changes in memory bean.save(out, DEFAULT_XML_OPTIONS); } }- Overrides:
commitin classPOIXMLDocumentPart- Throws:
IOException- a subclass may throw an IOException if the changes can't be committed
-
setTheme
public void setTheme(org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeStyleSheet theme)
-