diff options
Diffstat (limited to 'src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java')
-rw-r--r-- | src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java b/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java index c0ad5f1bd1..6120e5b48b 100644 --- a/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java +++ b/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java @@ -176,14 +176,29 @@ public class StylesTable extends POIXMLDocumentPart { return fonts.get(idx); } - public int putFont(XSSFFont font) { - int idx = fonts.indexOf(font); + /** + * Records the given font in the font table. + * Will re-use an existing font index if this + * font matches another, EXCEPT if forced + * registration is requested. + * This allows people to create several fonts + * then customise them later. + */ + public int putFont(XSSFFont font, boolean forceRegistration) { + int idx = -1; + if(!forceRegistration) { + idx = fonts.indexOf(font); + } + if (idx != -1) { return idx; } fonts.add(font); return fonts.size() - 1; } + public int putFont(XSSFFont font) { + return putFont(font, false); + } public XSSFCellStyle getStyleAt(int idx) { int styleXfId = 0; |