From af79058b8527dc3d958c88a7aafc3ae101b7988a Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Wed, 13 May 2026 23:52:22 +0100 Subject: [PATCH] Update XSLFSheet.java --- .../apache/poi/xslf/usermodel/XSLFSheet.java | 39 +++++++++---------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSheet.java b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSheet.java index 9b9ed2aa778..1a4e3de1943 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSheet.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSheet.java @@ -74,7 +74,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more @Beta public abstract class XSLFSheet extends POIXMLDocumentPart -implements XSLFShapeContainer, Sheet { + implements XSLFShapeContainer, Sheet { private static final Logger LOG = PoiLogManager.getLogger(XSLFSheet.class); private XSLFDrawing _drawing; @@ -83,7 +83,7 @@ public abstract class XSLFSheet extends POIXMLDocumentPart private XSLFTheme _theme; private List_placeholders; - private Map _placeholderByIdMap; + private Map _placeholderByIdMap; private Map _placeholderByTypeMap; private final SparseBitSet shapeIds = new SparseBitSet(); @@ -340,8 +340,8 @@ public Iterator iterator(){ @Override public void addShape(XSLFShape shape) { throw new UnsupportedOperationException( - "Adding a shape from a different container is not supported -" - + " create it from scratch with the XSLFSheet.create* methods"); + "Adding a shape from a different container is not supported -" + + " create it from scratch with the XSLFSheet.create* methods"); } /** @@ -496,7 +496,7 @@ public XSLFSheet appendContent(XSLFSheet src){ return this; } - /** + /** * @return theme (shared styles) associated with this theme. * By default returns {@code null} which means that this sheet is theme-less. * Sheets that support the notion of themes (slides, masters, layouts, etc.) should override this @@ -508,9 +508,9 @@ public XSLFTheme getTheme() { } getRelations().stream() - .filter(p -> p instanceof XSLFTheme) - .findAny() - .ifPresent(p -> _theme = (XSLFTheme)p); + .filter(p -> p instanceof XSLFTheme) + .findAny() + .ifPresent(p -> _theme = (XSLFTheme)p); return _theme; } @@ -535,7 +535,7 @@ String mapSchemeColor(String schemeColor) { protected XSLFTextShape getTextShapeByType(Placeholder type){ for(XSLFShape shape : this.getShapes()){ if(shape instanceof XSLFTextShape) { - XSLFTextShape txt = (XSLFTextShape)shape; + XSLFTextShape txt = (XSLFTextShape)shape; if(txt.getTextType() == type) { return txt; } @@ -553,7 +553,7 @@ public XSLFSimpleShape getPlaceholder(Placeholder ph) { public XSLFSimpleShape getPlaceholder(CTPlaceholder ph) { XSLFSimpleShape shape = null; if(ph.isSetIdx()) { - shape = getPlaceholderById((int)ph.getIdx()); + shape = getPlaceholderById(ph.getIdx()); } if (shape == null && ph.isSetType()) { @@ -575,8 +575,7 @@ private void initPlaceholders() { if(ph != null) { _placeholders.add(sShape); if(ph.isSetIdx()) { - int idx = (int)ph.getIdx(); - _placeholderByIdMap.put(idx, sShape); + _placeholderByIdMap.put(ph.getIdx(), sShape); } if(ph.isSetType()){ _placeholderByTypeMap.put(ph.getType().intValue(), sShape); @@ -587,7 +586,7 @@ private void initPlaceholders() { } } - private XSLFSimpleShape getPlaceholderById(int id) { + private XSLFSimpleShape getPlaceholderById(long id) { initPlaceholders(); return _placeholderByIdMap.get(id); } @@ -740,13 +739,13 @@ public void addChart(XSLFChart chart, Rectangle2D rect2D) { } protected String mapSchemeColor(CTColorMappingOverride cmapOver, String schemeColor) { - String slideColor = mapSchemeColor((cmapOver == null) ? null : cmapOver.getOverrideClrMapping(), schemeColor); - if (slideColor != null) { - return slideColor; - } - XSLFSheet master = (XSLFSheet)getMasterSheet(); - String masterColor = (master == null) ? null : master.mapSchemeColor(schemeColor); - return (masterColor == null) ? schemeColor : masterColor; + String slideColor = mapSchemeColor((cmapOver == null) ? null : cmapOver.getOverrideClrMapping(), schemeColor); + if (slideColor != null) { + return slideColor; + } + XSLFSheet master = (XSLFSheet)getMasterSheet(); + String masterColor = (master == null) ? null : master.mapSchemeColor(schemeColor); + return (masterColor == null) ? schemeColor : masterColor; } protected String mapSchemeColor(CTColorMapping cmap, String schemeColor) {