Deprecate functions that duplicate functionality

DrawingGroupRecord#processChildRecords and AbstractEscherHolderRecord#convertRawBytesToEscherRecords duplicate the functionality of AbstractEscherHolderRecord#decode. This makes the code harder to follow, as it is not clear when certain access patterns repeat. Accordingly, these functions are deprecated and flagged for removal.

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1887021 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Marius Volkhart 2021-03-01 00:25:23 +00:00
parent 402d0fc5e5
commit 8ab53c6489
4 changed files with 18 additions and 5 deletions

View File

@ -1840,7 +1840,7 @@ public final class InternalWorkbook {
continue;
}
DrawingGroupRecord dg = (DrawingGroupRecord)r;
dg.processChildRecords();
dg.decode();
drawingManager = findDrawingManager(dg, escherBSERecords);
if (drawingManager != null) {
return drawingManager;

View File

@ -27,6 +27,7 @@ import org.apache.poi.ddf.EscherRecordFactory;
import org.apache.poi.ddf.NullEscherSerializationListener;
import org.apache.poi.hssf.util.LazilyConcatenatedByteArray;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.Removal;
/**
* The escher container record is used to hold escher records. It is abstract and
@ -63,10 +64,17 @@ public abstract class AbstractEscherHolderRecord extends Record {
}
}
/**
* @deprecated Call {@link #decode()} instead.
*/
@Removal(version = "5.3")
@Deprecated
protected void convertRawBytesToEscherRecords() {
// decode() does a check to see if raw bytes have already been interpreted. In the case that we did not eagerly
// interpret the bytes due to DESERIALIZE being false, decode() will interpret the bytes. If we did already
// interpret the bytes due to DESERIALIZE being true, decode skips doing the work again.
if (!DESERIALIZE) {
byte[] rawData = getRawData();
convertToEscherRecords(0, rawData.length, rawData);
decode();
}
}
private void convertToEscherRecords( int offset, int size, byte[] data )

View File

@ -25,6 +25,7 @@ import org.apache.poi.ddf.EscherRecord;
import org.apache.poi.ddf.EscherRecordTypes;
import org.apache.poi.ddf.NullEscherSerializationListener;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.Removal;
/**
* Specifies a group of drawing objects.
@ -81,9 +82,13 @@ public final class DrawingGroupRecord extends AbstractEscherHolderRecord {
* (Not done by default in case we break things,
* unless you set the "poi.deserialize.escher"
* system property)
*
* @deprecated Call {@link #decode()} instead.
*/
@Removal(version = "5.3")
@Deprecated
public void processChildRecords() {
convertRawBytesToEscherRecords();
decode();
}
public int getRecordSize() {

View File

@ -42,7 +42,7 @@ public final class DrawingRecordForBiffViewer extends AbstractEscherHolderRecord
public DrawingRecordForBiffViewer(DrawingRecord r)
{
super(convertToInputStream(r));
convertRawBytesToEscherRecords();
decode();
}
private static RecordInputStream convertToInputStream(DrawingRecord r)
{