]> source.dussan.org Git - poi.git/commitdiff
Deprecate functions that duplicate functionality
authorMarius Volkhart <mariusvolkhart@apache.org>
Mon, 1 Mar 2021 00:25:23 +0000 (00:25 +0000)
committerMarius Volkhart <mariusvolkhart@apache.org>
Mon, 1 Mar 2021 00:25:23 +0000 (00:25 +0000)
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

src/java/org/apache/poi/hssf/model/InternalWorkbook.java
src/java/org/apache/poi/hssf/record/AbstractEscherHolderRecord.java
src/java/org/apache/poi/hssf/record/DrawingGroupRecord.java
src/java/org/apache/poi/hssf/record/DrawingRecordForBiffViewer.java

index c5703dfca31d331e958ae9a02649d90d77750c81..d49f2566a71b1de1b382570366e29036f2d6bb3f 100644 (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;
index 48d75056e31dc1c84d82410f1e0d982a313be8cb..0132e276e38945d9d66c95e691f1a6b893451f92 100644 (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 )
index 68c8c24145d698f92ad5025d67556aeb4d480763..4dbbb70b58d73d40a4779526239d4fe23a3498fe 100644 (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() {
index f27c2b6c8573f843356ecf142771c4caff70d9df..8c9743f4bd6076b41d665dfe19313b36899fc2cd 100644 (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)
     {