Skip to content

Commit 370963f

Browse files
authored
Update XSLFSheet.java (#1074)
1 parent 9804b78 commit 370963f

1 file changed

Lines changed: 19 additions & 20 deletions

File tree

poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFSheet.java

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
7474

7575
@Beta
7676
public abstract class XSLFSheet extends POIXMLDocumentPart
77-
implements XSLFShapeContainer, Sheet<XSLFShape,XSLFTextParagraph> {
77+
implements XSLFShapeContainer, Sheet<XSLFShape,XSLFTextParagraph> {
7878
private static final Logger LOG = PoiLogManager.getLogger(XSLFSheet.class);
7979

8080
private XSLFDrawing _drawing;
@@ -83,7 +83,7 @@ public abstract class XSLFSheet extends POIXMLDocumentPart
8383
private XSLFTheme _theme;
8484

8585
private List<XSLFTextShape>_placeholders;
86-
private Map<Integer, XSLFSimpleShape> _placeholderByIdMap;
86+
private Map<Long, XSLFSimpleShape> _placeholderByIdMap;
8787
private Map<Integer, XSLFSimpleShape> _placeholderByTypeMap;
8888

8989
private final SparseBitSet shapeIds = new SparseBitSet();
@@ -340,8 +340,8 @@ public Iterator<XSLFShape> iterator(){
340340
@Override
341341
public void addShape(XSLFShape shape) {
342342
throw new UnsupportedOperationException(
343-
"Adding a shape from a different container is not supported -"
344-
+ " create it from scratch with the XSLFSheet.create* methods");
343+
"Adding a shape from a different container is not supported -"
344+
+ " create it from scratch with the XSLFSheet.create* methods");
345345
}
346346

347347
/**
@@ -496,7 +496,7 @@ public XSLFSheet appendContent(XSLFSheet src){
496496
return this;
497497
}
498498

499-
/**
499+
/**
500500
* @return theme (shared styles) associated with this theme.
501501
* By default returns {@code null} which means that this sheet is theme-less.
502502
* Sheets that support the notion of themes (slides, masters, layouts, etc.) should override this
@@ -508,9 +508,9 @@ public XSLFTheme getTheme() {
508508
}
509509

510510
getRelations().stream()
511-
.filter(p -> p instanceof XSLFTheme)
512-
.findAny()
513-
.ifPresent(p -> _theme = (XSLFTheme)p);
511+
.filter(p -> p instanceof XSLFTheme)
512+
.findAny()
513+
.ifPresent(p -> _theme = (XSLFTheme)p);
514514

515515
return _theme;
516516
}
@@ -535,7 +535,7 @@ String mapSchemeColor(String schemeColor) {
535535
protected XSLFTextShape getTextShapeByType(Placeholder type){
536536
for(XSLFShape shape : this.getShapes()){
537537
if(shape instanceof XSLFTextShape) {
538-
XSLFTextShape txt = (XSLFTextShape)shape;
538+
XSLFTextShape txt = (XSLFTextShape)shape;
539539
if(txt.getTextType() == type) {
540540
return txt;
541541
}
@@ -553,7 +553,7 @@ public XSLFSimpleShape getPlaceholder(Placeholder ph) {
553553
public XSLFSimpleShape getPlaceholder(CTPlaceholder ph) {
554554
XSLFSimpleShape shape = null;
555555
if(ph.isSetIdx()) {
556-
shape = getPlaceholderById((int)ph.getIdx());
556+
shape = getPlaceholderById(ph.getIdx());
557557
}
558558

559559
if (shape == null && ph.isSetType()) {
@@ -575,8 +575,7 @@ private void initPlaceholders() {
575575
if(ph != null) {
576576
_placeholders.add(sShape);
577577
if(ph.isSetIdx()) {
578-
int idx = (int)ph.getIdx();
579-
_placeholderByIdMap.put(idx, sShape);
578+
_placeholderByIdMap.put(ph.getIdx(), sShape);
580579
}
581580
if(ph.isSetType()){
582581
_placeholderByTypeMap.put(ph.getType().intValue(), sShape);
@@ -587,7 +586,7 @@ private void initPlaceholders() {
587586
}
588587
}
589588

590-
private XSLFSimpleShape getPlaceholderById(int id) {
589+
private XSLFSimpleShape getPlaceholderById(long id) {
591590
initPlaceholders();
592591
return _placeholderByIdMap.get(id);
593592
}
@@ -740,13 +739,13 @@ public void addChart(XSLFChart chart, Rectangle2D rect2D) {
740739
}
741740

742741
protected String mapSchemeColor(CTColorMappingOverride cmapOver, String schemeColor) {
743-
String slideColor = mapSchemeColor((cmapOver == null) ? null : cmapOver.getOverrideClrMapping(), schemeColor);
744-
if (slideColor != null) {
745-
return slideColor;
746-
}
747-
XSLFSheet master = (XSLFSheet)getMasterSheet();
748-
String masterColor = (master == null) ? null : master.mapSchemeColor(schemeColor);
749-
return (masterColor == null) ? schemeColor : masterColor;
742+
String slideColor = mapSchemeColor((cmapOver == null) ? null : cmapOver.getOverrideClrMapping(), schemeColor);
743+
if (slideColor != null) {
744+
return slideColor;
745+
}
746+
XSLFSheet master = (XSLFSheet)getMasterSheet();
747+
String masterColor = (master == null) ? null : master.mapSchemeColor(schemeColor);
748+
return (masterColor == null) ? schemeColor : masterColor;
750749
}
751750

752751
protected String mapSchemeColor(CTColorMapping cmap, String schemeColor) {

0 commit comments

Comments
 (0)