This is an automated email from the ASF dual-hosted git repository. centic pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/poi.git
commit c9b37678ccdf91258401985944cf882602144adc Author: Dominik Stadler <[email protected]> AuthorDate: Sun Jan 18 16:30:13 2026 +0100 Introduce getComplexSize() To not materialize the array only to get its size --- poi/src/main/java/org/apache/poi/ddf/EscherArrayProperty.java | 8 ++++---- poi/src/main/java/org/apache/poi/ddf/EscherComplexProperty.java | 4 ++++ poi/src/main/java/org/apache/poi/ddf/EscherPropertyFactory.java | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/poi/src/main/java/org/apache/poi/ddf/EscherArrayProperty.java b/poi/src/main/java/org/apache/poi/ddf/EscherArrayProperty.java index 233fa0a8bc..9aa6bf7937 100644 --- a/poi/src/main/java/org/apache/poi/ddf/EscherArrayProperty.java +++ b/poi/src/main/java/org/apache/poi/ddf/EscherArrayProperty.java @@ -118,7 +118,7 @@ public final class EscherArrayProperty extends EscherComplexProperty implements private void rewriteArray(int numberOfElements, boolean copyToNewLen) { int expectedArraySize = numberOfElements * getActualSizeOfElements(getSizeOfElements()) + FIXED_SIZE; - resizeComplexData(expectedArraySize, copyToNewLen ? expectedArraySize : getComplexData().length); + resizeComplexData(expectedArraySize, copyToNewLen ? expectedArraySize : getComplexSize()); } public int getNumberOfElementsInMemory() { @@ -181,7 +181,7 @@ public final class EscherArrayProperty extends EscherComplexProperty implements // the code here seems to depend on complexData already being // sized correctly via the constructor - int cdLen = getComplexData().length; + int cdLen = getComplexSize(); int arraySize = getActualSizeOfElements(sizeOfElements) * numElements; if (arraySize == cdLen) { // The stored data size in the simple block excludes the header size @@ -190,7 +190,7 @@ public final class EscherArrayProperty extends EscherComplexProperty implements } setComplexData(data, offset); } - return getComplexData().length; + return getComplexSize(); } /** @@ -202,7 +202,7 @@ public final class EscherArrayProperty extends EscherComplexProperty implements @Override public int serializeSimplePart(byte[] data, int pos) { LittleEndian.putShort(data, pos, getId()); - int recordSize = getComplexData().length; + int recordSize = getComplexSize(); if (!sizeIncludesHeaderSize) { recordSize -= 6; } diff --git a/poi/src/main/java/org/apache/poi/ddf/EscherComplexProperty.java b/poi/src/main/java/org/apache/poi/ddf/EscherComplexProperty.java index 218ef9576d..356cd4a8c4 100644 --- a/poi/src/main/java/org/apache/poi/ddf/EscherComplexProperty.java +++ b/poi/src/main/java/org/apache/poi/ddf/EscherComplexProperty.java @@ -135,6 +135,10 @@ public class EscherComplexProperty extends EscherProperty { return complexData; } + public int getComplexSize() { + return complexSize; + } + public int setComplexData(byte[] complexData) { return setComplexData(complexData, 0); } diff --git a/poi/src/main/java/org/apache/poi/ddf/EscherPropertyFactory.java b/poi/src/main/java/org/apache/poi/ddf/EscherPropertyFactory.java index eff992c952..101df04faa 100644 --- a/poi/src/main/java/org/apache/poi/ddf/EscherPropertyFactory.java +++ b/poi/src/main/java/org/apache/poi/ddf/EscherPropertyFactory.java @@ -81,7 +81,7 @@ public final class EscherPropertyFactory { pos += eap.setArrayData(data, pos); } else if (p instanceof EscherComplexProperty) { EscherComplexProperty ecp = (EscherComplexProperty)p; - int cdLen = ecp.getComplexData().length; + int cdLen = ecp.getComplexSize(); int leftover = data.length - pos; if (leftover < cdLen) { throw new IllegalStateException("Could not read complex escher property, length was " + --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
