Package org.apache.poi.xssf.model
Class ThemesTable
- java.lang.Object
-
- org.apache.poi.ooxml.POIXMLDocumentPart
-
- org.apache.poi.xssf.model.ThemesTable
-
- All Implemented Interfaces:
Themes
public class ThemesTable extends POIXMLDocumentPart implements Themes
Class that represents theme of XLSX document. The theme includes specific colors and fonts.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classThemesTable.ThemeElement-
Nested classes/interfaces inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
POIXMLDocumentPart.RelationPart
-
-
Constructor Summary
Constructors Constructor Description ThemesTable()Create a new, empty ThemesTableThemesTable(InputStream stream)Construct a ThemesTable.ThemesTable(PackagePart part)Construct a ThemesTable.ThemesTable(org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument theme)Construct a ThemesTable from an existing ThemeDocument.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcommit()Save the content in the underlying package part.XSSFColorgetThemeColor(int idx)Convert a theme "index" (as used by fonts etc) into a color.voidinheritFromThemeAsRequired(XSSFColor color)If the colour is based on a theme, then inherit information (currently just colours) from it as required.voidreadFrom(InputStream is)Read this themes table from an XML file.protected voidsetColorMap(IndexedColorMap colorMap)called fromStylesTablewhen setting theme, used to adjust colors if a custom indexed mapping is definedvoidwriteTo(OutputStream out)Write this table out as XML.-
Methods inherited from class org.apache.poi.ooxml.POIXMLDocumentPart
_invokeOnDocumentRead, addRelation, createRelationship, createRelationship, createRelationship, getNextPartNumber, getPackagePart, getParent, getRelationById, getRelationId, getRelationPartById, getRelationParts, getRelations, getTargetPart, isCommitted, onDocumentCreate, onDocumentRead, onDocumentRemove, onSave, prepareForCommit, read, rebase, removeRelation, removeRelation, removeRelation, setCommitted, toString
-
-
-
-
Constructor Detail
-
ThemesTable
public ThemesTable()
Create a new, empty ThemesTable
-
ThemesTable
public ThemesTable(PackagePart part) throws IOException
Construct a ThemesTable.- Parameters:
part- A PackagePart.- Throws:
IOException- Since:
- POI 3.14-Beta1
-
ThemesTable
public ThemesTable(InputStream stream) throws IOException
Construct a ThemesTable.- Parameters:
stream- input stream.- Throws:
IOException- Since:
- POI 5.2.0
-
ThemesTable
public ThemesTable(org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument theme)
Construct a ThemesTable from an existing ThemeDocument.- Parameters:
theme- A ThemeDocument.
-
-
Method Detail
-
readFrom
public void readFrom(InputStream is) throws IOException
Read this themes table from an XML file.- Parameters:
is- The input stream containing the XML document.- Throws:
IOException- if an error occurs while reading.- Since:
- POI 5.2.0
-
setColorMap
protected void setColorMap(IndexedColorMap colorMap)
called fromStylesTablewhen setting theme, used to adjust colors if a custom indexed mapping is defined
-
getThemeColor
public XSSFColor getThemeColor(int idx)
Convert a theme "index" (as used by fonts etc) into a color.- Specified by:
getThemeColorin interfaceThemes- Parameters:
idx- A theme "index"- Returns:
- The mapped XSSFColor, or null if not mapped.
-
inheritFromThemeAsRequired
public void inheritFromThemeAsRequired(XSSFColor color)
If the colour is based on a theme, then inherit information (currently just colours) from it as required.- Specified by:
inheritFromThemeAsRequiredin interfaceThemes
-
writeTo
public void writeTo(OutputStream out) throws IOException
Write this table out as XML.- Parameters:
out- The stream to write to.- Throws:
IOException- if an error occurs while writing.
-
commit
protected void commit() throws IOExceptionDescription 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
-
-