You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2023/01/29 17:15:41 UTC
svn commit: r1907079 - /poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
Author: fanningpj
Date: Sun Jan 29 17:15:41 2023
New Revision: 1907079
URL: http://svn.apache.org/viewvc?rev=1907079&view=rev
Log:
don't create format pr instance for read events
Modified:
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java?rev=1907079&r1=1907078&r2=1907079&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Sun Jan 29 17:15:41 2023
@@ -975,10 +975,11 @@ public class XSSFSheet extends POIXMLDoc
return (float)(pr == null ? 0 : pr.getDefaultRowHeight());
}
- private CTSheetFormatPr getSheetTypeSheetFormatPr() {
- return worksheet.isSetSheetFormatPr() ?
- worksheet.getSheetFormatPr() :
- worksheet.addNewSheetFormatPr();
+ private CTSheetFormatPr getSheetTypeSheetFormatPr(final boolean createIfNotExists) {
+ if (worksheet.isSetSheetFormatPr()) {
+ return worksheet.getSheetFormatPr();
+ }
+ return createIfNotExists ? worksheet.addNewSheetFormatPr() : null;
}
/**
@@ -2612,7 +2613,7 @@ public class XSSFSheet extends POIXMLDoc
*/
@Override
public void setDefaultColumnWidth(int width) {
- getSheetTypeSheetFormatPr().setBaseColWidth(width);
+ getSheetTypeSheetFormatPr(true).setBaseColWidth(width);
}
/**
@@ -2633,7 +2634,7 @@ public class XSSFSheet extends POIXMLDoc
*/
@Override
public void setDefaultRowHeightInPoints(float height) {
- CTSheetFormatPr pr = getSheetTypeSheetFormatPr();
+ CTSheetFormatPr pr = getSheetTypeSheetFormatPr(true);
pr.setDefaultRowHeight(height);
pr.setCustomHeight(true);
}
@@ -3447,32 +3448,36 @@ public class XSSFSheet extends POIXMLDoc
private void increaseSheetFormatPrOutlineLevelRowIfNecessary(final short levelRow) {
if (levelRow > getSheetFormatPrOutlineLevelRow()) {
- getSheetTypeSheetFormatPr().setOutlineLevelRow(levelRow);
+ getSheetTypeSheetFormatPr(true).setOutlineLevelRow(levelRow);
}
}
private void increaseSheetFormatPrOutlineLevelColIfNecessary(final short levelCol) {
if (levelCol > getSheetFormatPrOutlineLevelCol()) {
- getSheetTypeSheetFormatPr().setOutlineLevelCol(levelCol);
+ getSheetTypeSheetFormatPr(true).setOutlineLevelCol(levelCol);
}
}
private void setSheetFormatPrOutlineLevelRow() {
final short maxLevelRow = getMaxOutlineLevelRows();
- getSheetTypeSheetFormatPr().setOutlineLevelRow(maxLevelRow);
+ getSheetTypeSheetFormatPr(true).setOutlineLevelRow(maxLevelRow);
}
+ @Internal // used by SXSSFSHeet
public short getSheetFormatPrOutlineLevelRow() {
- return getSheetTypeSheetFormatPr().getOutlineLevelRow();
+ final CTSheetFormatPr pr = getSheetTypeSheetFormatPr(false);
+ return pr == null ? 0 : pr.getOutlineLevelRow();
}
+ @Internal // used by SXSSFSHeet
public short getSheetFormatPrOutlineLevelCol() {
- return getSheetTypeSheetFormatPr().getOutlineLevelCol();
+ final CTSheetFormatPr pr = getSheetTypeSheetFormatPr(false);
+ return pr == null ? 0 : pr.getOutlineLevelCol();
}
private void setSheetFormatPrOutlineLevelCol() {
final short maxLevelCol = getMaxOutlineLevelCols();
- getSheetTypeSheetFormatPr().setOutlineLevelCol(maxLevelCol);
+ getSheetTypeSheetFormatPr(true).setOutlineLevelCol(maxLevelCol);
}
protected CTSheetViews getSheetTypeSheetViews(final boolean create) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org