You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2021/05/14 00:37:53 UTC
svn commit: r1889871 [13/17] - in /poi: site/src/documentation/content/xdocs/
site/src/documentation/content/xdocs/components/ trunk/ trunk/maven/
trunk/osgi/ trunk/osgi/src/test/java/org/apache/poi/osgi/
trunk/poi-examples/src/main/java/org/apache/poi...
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/EscherAggregate.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/EscherAggregate.java?rev=1889871&r1=1889870&r2=1889871&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/EscherAggregate.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/EscherAggregate.java Fri May 14 00:37:50 2021
@@ -19,7 +19,6 @@ package org.apache.poi.hssf.record;
import static org.apache.poi.hssf.record.RecordInputStream.MAX_RECORD_DATA_SIZE;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -31,6 +30,7 @@ import java.util.List;
import java.util.Map;
import java.util.function.Supplier;
+import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
import org.apache.poi.ddf.DefaultEscherRecordFactory;
import org.apache.poi.ddf.EscherClientDataRecord;
import org.apache.poi.ddf.EscherContainerRecord;
@@ -40,9 +40,11 @@ import org.apache.poi.ddf.EscherSerializ
import org.apache.poi.ddf.EscherSpRecord;
import org.apache.poi.ddf.EscherSpgrRecord;
import org.apache.poi.ddf.EscherTextboxRecord;
+import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.util.GenericRecordXmlWriter;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.RecordFormatException;
+import org.apache.poi.util.Removal;
/**
* This class is used to aggregate the MSODRAWING and OBJ record
@@ -93,210 +95,825 @@ public final class EscherAggregate exten
private static final int MAX_RECORD_LENGTH = 100_000_000;
+ /** @deprecated not used */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_MIN = (short) 0;
- public static final short ST_NOT_PRIMATIVE = ST_MIN;
+ /** @deprecated use {@link ShapeType#NOT_PRIMITIVE} */
+ @Deprecated
+ @Removal(version = "5.3")
+ public static final short ST_NOT_PRIMATIVE = (short) 0;
+ /** @deprecated use {@link ShapeType#RECT} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_RECTANGLE = (short) 1;
+ /** @deprecated use {@link ShapeType#ROUND_RECT} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_ROUNDRECTANGLE = (short) 2;
+ /** @deprecated use {@link ShapeType#ELLIPSE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_ELLIPSE = (short) 3;
+ /** @deprecated use {@link ShapeType#DIAMOND} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_DIAMOND = (short) 4;
+ /** @deprecated use {@link ShapeType#TRIANGLE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_ISOCELESTRIANGLE = (short) 5;
+ /** @deprecated use {@link ShapeType#RT_TRIANGLE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_RIGHTTRIANGLE = (short) 6;
+ /** @deprecated use {@link ShapeType#PARALLELOGRAM} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_PARALLELOGRAM = (short) 7;
+ /** @deprecated use {@link ShapeType#TRAPEZOID} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TRAPEZOID = (short) 8;
+ /** @deprecated use {@link ShapeType#HEXAGON} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_HEXAGON = (short) 9;
+ /** @deprecated use {@link ShapeType#OCTAGON} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_OCTAGON = (short) 10;
+ /** @deprecated use {@link ShapeType#PLUS} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_PLUS = (short) 11;
+ /** @deprecated use {@link ShapeType#STAR_5} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_STAR = (short) 12;
+ /** @deprecated use {@link ShapeType#RIGHT_ARROW} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_ARROW = (short) 13;
+ /** @deprecated use {@link ShapeType#THICK_ARROW} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_THICKARROW = (short) 14;
+ /** @deprecated use {@link ShapeType#HOME_PLATE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_HOMEPLATE = (short) 15;
+ /** @deprecated use {@link ShapeType#CUBE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_CUBE = (short) 16;
+ /** @deprecated use {@link ShapeType#BALLOON} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_BALLOON = (short) 17;
+ /** @deprecated use {@link ShapeType#SEAL} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_SEAL = (short) 18;
+ /** @deprecated use {@link ShapeType#ARC} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_ARC = (short) 19;
+ /** @deprecated use {@link ShapeType#LINE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_LINE = (short) 20;
+ /** @deprecated use {@link ShapeType#PLAQUE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_PLAQUE = (short) 21;
+ /** @deprecated use {@link ShapeType#CAN} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_CAN = (short) 22;
+ /** @deprecated use {@link ShapeType#DONUT} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_DONUT = (short) 23;
+ /** @deprecated use {@link ShapeType#TEXT_SIMPLE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTSIMPLE = (short) 24;
+ /** @deprecated use {@link ShapeType#TEXT_OCTAGON} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTOCTAGON = (short) 25;
+ /** @deprecated use {@link ShapeType#TEXT_HEXAGON} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTHEXAGON = (short) 26;
+ /** @deprecated use {@link ShapeType#TEXT_CURVE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTCURVE = (short) 27;
+ /** @deprecated use {@link ShapeType#TEXT_WAVE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTWAVE = (short) 28;
+ /** @deprecated use {@link ShapeType#TEXT_RING} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTRING = (short) 29;
+ /** @deprecated use {@link ShapeType#TEXT_ON_CURVE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTONCURVE = (short) 30;
+ /** @deprecated use {@link ShapeType#TEXT_ON_RING} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTONRING = (short) 31;
+ /** @deprecated use {@link ShapeType#STRAIGHT_CONNECTOR_1} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_STRAIGHTCONNECTOR1 = (short) 32;
+ /** @deprecated use {@link ShapeType#BENT_CONNECTOR_2} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_BENTCONNECTOR2 = (short) 33;
+ /** @deprecated use {@link ShapeType#BENT_CONNECTOR_3} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_BENTCONNECTOR3 = (short) 34;
+ /** @deprecated use {@link ShapeType#BENT_CONNECTOR_4} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_BENTCONNECTOR4 = (short) 35;
+ /** @deprecated use {@link ShapeType#BENT_CONNECTOR_5} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_BENTCONNECTOR5 = (short) 36;
+ /** @deprecated use {@link ShapeType#CURVED_CONNECTOR_2} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_CURVEDCONNECTOR2 = (short) 37;
+ /** @deprecated use {@link ShapeType#CURVED_CONNECTOR_3} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_CURVEDCONNECTOR3 = (short) 38;
+ /** @deprecated use {@link ShapeType#CURVED_CONNECTOR_3} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_CURVEDCONNECTOR4 = (short) 39;
+ /** @deprecated use {@link ShapeType#CURVED_CONNECTOR_5} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_CURVEDCONNECTOR5 = (short) 40;
+ /** @deprecated use {@link ShapeType#CALLOUT_1} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_CALLOUT1 = (short) 41;
+ /** @deprecated use {@link ShapeType#CALLOUT_2} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_CALLOUT2 = (short) 42;
+ /** @deprecated use {@link ShapeType#CALLOUT_3} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_CALLOUT3 = (short) 43;
+ /** @deprecated use {@link ShapeType#ACCENT_CALLOUT_1} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_ACCENTCALLOUT1 = (short) 44;
+ /** @deprecated use {@link ShapeType#ACCENT_CALLOUT_2} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_ACCENTCALLOUT2 = (short) 45;
+ /** @deprecated use {@link ShapeType#ACCENT_CALLOUT_3} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_ACCENTCALLOUT3 = (short) 46;
+ /** @deprecated use {@link ShapeType#BORDER_CALLOUT_1} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_BORDERCALLOUT1 = (short) 47;
+ /** @deprecated use {@link ShapeType#BORDER_CALLOUT_2} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_BORDERCALLOUT2 = (short) 48;
+ /** @deprecated use {@link ShapeType#BORDER_CALLOUT_3} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_BORDERCALLOUT3 = (short) 49;
+ /** @deprecated use {@link ShapeType#ACCENT_BORDER_CALLOUT_1} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_ACCENTBORDERCALLOUT1 = (short) 50;
+ /** @deprecated use {@link ShapeType#ACCENT_BORDER_CALLOUT_2} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_ACCENTBORDERCALLOUT2 = (short) 51;
+ /** @deprecated use {@link ShapeType#ACCENT_BORDER_CALLOUT_3} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_ACCENTBORDERCALLOUT3 = (short) 52;
+ /** @deprecated use {@link ShapeType#RIBBON} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_RIBBON = (short) 53;
+ /** @deprecated use {@link ShapeType#RIBBON_2} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_RIBBON2 = (short) 54;
+ /** @deprecated use {@link ShapeType#CHEVRON} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_CHEVRON = (short) 55;
+ /** @deprecated use {@link ShapeType#PENTAGON} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_PENTAGON = (short) 56;
+ /** @deprecated use {@link ShapeType#NO_SMOKING} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_NOSMOKING = (short) 57;
+ /** @deprecated use {@link ShapeType#STAR_8} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_SEAL8 = (short) 58;
+ /** @deprecated use {@link ShapeType#STAR_16} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_SEAL16 = (short) 59;
+ /** @deprecated use {@link ShapeType#STAR_32} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_SEAL32 = (short) 60;
+ /** @deprecated use {@link ShapeType#WEDGE_RECT_CALLOUT} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_WEDGERECTCALLOUT = (short) 61;
+ /** @deprecated use {@link ShapeType#WEDGE_ROUND_RECT_CALLOUT} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_WEDGERRECTCALLOUT = (short) 62;
+ /** @deprecated use {@link ShapeType#WEDGE_ELLIPSE_CALLOUT} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_WEDGEELLIPSECALLOUT = (short) 63;
+ /** @deprecated use {@link ShapeType#WAVE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_WAVE = (short) 64;
+ /** @deprecated use {@link ShapeType#FOLDED_CORNER} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FOLDEDCORNER = (short) 65;
+ /** @deprecated use {@link ShapeType#LEFT_ARROW} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_LEFTARROW = (short) 66;
+ /** @deprecated use {@link ShapeType#DOWN_ARROW} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_DOWNARROW = (short) 67;
+ /** @deprecated use {@link ShapeType#UP_ARROW} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_UPARROW = (short) 68;
+ /** @deprecated use {@link ShapeType#LEFT_RIGHT_ARROW} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_LEFTRIGHTARROW = (short) 69;
+ /** @deprecated use {@link ShapeType#UP_DOWN_ARROW} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_UPDOWNARROW = (short) 70;
+ /** @deprecated use {@link ShapeType#IRREGULAR_SEAL_1} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_IRREGULARSEAL1 = (short) 71;
+ /** @deprecated use {@link ShapeType#IRREGULAR_SEAL_2} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_IRREGULARSEAL2 = (short) 72;
+ /** @deprecated use {@link ShapeType#LIGHTNING_BOLT} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_LIGHTNINGBOLT = (short) 73;
+ /** @deprecated use {@link ShapeType#HEART} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_HEART = (short) 74;
+ /** @deprecated use {@link ShapeType#FRAME} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_PICTUREFRAME = (short) 75;
+ /** @deprecated use {@link ShapeType#QUAD_ARROW} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_QUADARROW = (short) 76;
+ /** @deprecated use {@link ShapeType#LEFT_ARROW_CALLOUT} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_LEFTARROWCALLOUT = (short) 77;
+ /** @deprecated use {@link ShapeType#RIGHT_ARROW_CALLOUT} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_RIGHTARROWCALLOUT = (short) 78;
+ /** @deprecated use {@link ShapeType#UP_ARROW_CALLOUT} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_UPARROWCALLOUT = (short) 79;
+ /** @deprecated use {@link ShapeType#DOWN_ARROW_CALLOUT} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_DOWNARROWCALLOUT = (short) 80;
+ /** @deprecated use {@link ShapeType#LEFT_RIGHT_ARROW_CALLOUT} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_LEFTRIGHTARROWCALLOUT = (short) 81;
+ /** @deprecated use {@link ShapeType#UP_DOWN_ARROW_CALLOUT} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_UPDOWNARROWCALLOUT = (short) 82;
+ /** @deprecated use {@link ShapeType#QUAD_ARROW_CALLOUT} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_QUADARROWCALLOUT = (short) 83;
+ /** @deprecated use {@link ShapeType#BEVEL} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_BEVEL = (short) 84;
+ /** @deprecated use {@link ShapeType#LEFT_BRACKET} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_LEFTBRACKET = (short) 85;
+ /** @deprecated use {@link ShapeType#RIGHT_BRACKET} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_RIGHTBRACKET = (short) 86;
+ /** @deprecated use {@link ShapeType#LEFT_BRACE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_LEFTBRACE = (short) 87;
+ /** @deprecated use {@link ShapeType#RIGHT_BRACE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_RIGHTBRACE = (short) 88;
+ /** @deprecated use {@link ShapeType#LEFT_UP_ARROW} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_LEFTUPARROW = (short) 89;
+ /** @deprecated use {@link ShapeType#BENT_UP_ARROW} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_BENTUPARROW = (short) 90;
+ /** @deprecated use {@link ShapeType#BENT_ARROW} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_BENTARROW = (short) 91;
+ /** @deprecated use {@link ShapeType#STAR_24} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_SEAL24 = (short) 92;
+ /** @deprecated use {@link ShapeType#STRIPED_RIGHT_ARROW} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_STRIPEDRIGHTARROW = (short) 93;
+ /** @deprecated use {@link ShapeType#NOTCHED_RIGHT_ARROW} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_NOTCHEDRIGHTARROW = (short) 94;
+ /** @deprecated use {@link ShapeType#BLOCK_ARC} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_BLOCKARC = (short) 95;
+ /** @deprecated use {@link ShapeType#SMILEY_FACE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_SMILEYFACE = (short) 96;
+ /** @deprecated use {@link ShapeType#VERTICAL_SCROLL} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_VERTICALSCROLL = (short) 97;
+ /** @deprecated use {@link ShapeType#HORIZONTAL_SCROLL} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_HORIZONTALSCROLL = (short) 98;
+ /** @deprecated use {@link ShapeType#CIRCULAR_ARROW} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_CIRCULARARROW = (short) 99;
+ /** @deprecated use {@link ShapeType#NOTCHED_CIRCULAR_ARROW} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_NOTCHEDCIRCULARARROW = (short) 100;
+ /** @deprecated use {@link ShapeType#UTURN_ARROW} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_UTURNARROW = (short) 101;
+ /** @deprecated use {@link ShapeType#CURVED_RIGHT_ARROW} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_CURVEDRIGHTARROW = (short) 102;
+ /** @deprecated use {@link ShapeType#CURVED_LEFT_ARROW} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_CURVEDLEFTARROW = (short) 103;
+ /** @deprecated use {@link ShapeType#CURVED_UP_ARROW} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_CURVEDUPARROW = (short) 104;
+ /** @deprecated use {@link ShapeType#CURVED_DOWN_ARROW} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_CURVEDDOWNARROW = (short) 105;
+ /** @deprecated use {@link ShapeType#CLOUD_CALLOUT} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_CLOUDCALLOUT = (short) 106;
+ /** @deprecated use {@link ShapeType#ELLIPSE_RIBBON} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_ELLIPSERIBBON = (short) 107;
+ /** @deprecated use {@link ShapeType#ELLIPSE_RIBBON_2} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_ELLIPSERIBBON2 = (short) 108;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_PROCESS} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTPROCESS = (short) 109;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_DECISION} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTDECISION = (short) 110;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_INPUT_OUTPUT} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTINPUTOUTPUT = (short) 111;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_PREDEFINED_PROCESS} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTPREDEFINEDPROCESS = (short) 112;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_INTERNAL_STORAGE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTINTERNALSTORAGE = (short) 113;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_DOCUMENT} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTDOCUMENT = (short) 114;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_MULTIDOCUMENT} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTMULTIDOCUMENT = (short) 115;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_TERMINATOR} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTTERMINATOR = (short) 116;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_PREPARATION} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTPREPARATION = (short) 117;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_MANUAL_INPUT} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTMANUALINPUT = (short) 118;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_MANUAL_OPERATION} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTMANUALOPERATION = (short) 119;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_CONNECTOR} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTCONNECTOR = (short) 120;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_PUNCHED_CARD} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTPUNCHEDCARD = (short) 121;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_PUNCHED_TAPE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTPUNCHEDTAPE = (short) 122;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_SUMMING_JUNCTION} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTSUMMINGJUNCTION = (short) 123;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_OR} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTOR = (short) 124;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_COLLATE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTCOLLATE = (short) 125;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_SORT} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTSORT = (short) 126;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_EXTRACT} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTEXTRACT = (short) 127;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_MERGE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTMERGE = (short) 128;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_OFFLINE_STORAGE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTOFFLINESTORAGE = (short) 129;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_ONLINE_STORAGE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTONLINESTORAGE = (short) 130;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_MAGNETIC_TAPE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTMAGNETICTAPE = (short) 131;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_MAGNETIC_DISK} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTMAGNETICDISK = (short) 132;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_MAGNETIC_DRUM} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTMAGNETICDRUM = (short) 133;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_DISPLAY} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTDISPLAY = (short) 134;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_DELAY} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTDELAY = (short) 135;
+ /** @deprecated use {@link ShapeType#TEXT_PLAIN_TEXT} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTPLAINTEXT = (short) 136;
+ /** @deprecated use {@link ShapeType#TEXT_STOP} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTSTOP = (short) 137;
+ /** @deprecated use {@link ShapeType#TEXT_TRIANGLE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTTRIANGLE = (short) 138;
+ /** @deprecated use {@link ShapeType#TEXT_TRIANGLE_INVERTED} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTTRIANGLEINVERTED = (short) 139;
+ /** @deprecated use {@link ShapeType#TEXT_CHEVRON} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTCHEVRON = (short) 140;
+ /** @deprecated use {@link ShapeType#TEXT_CHEVRON_INVERTED} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTCHEVRONINVERTED = (short) 141;
+ /** @deprecated use {@link ShapeType#TEXT_RING_INSIDE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTRINGINSIDE = (short) 142;
+ /** @deprecated use {@link ShapeType#TEXT_RING_OUTSIDE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTRINGOUTSIDE = (short) 143;
+ /** @deprecated use {@link ShapeType#TEXT_ARCH_UP_CURVE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTARCHUPCURVE = (short) 144;
+ /** @deprecated use {@link ShapeType#TEXT_ARCH_DOWN_CURVE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTARCHDOWNCURVE = (short) 145;
+ /** @deprecated use {@link ShapeType#TEXT_CIRCLE_CURVE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTCIRCLECURVE = (short) 146;
+ /** @deprecated use {@link ShapeType#TEXT_BUTTON_CURVE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTBUTTONCURVE = (short) 147;
+ /** @deprecated use {@link ShapeType#TEXT_ARCH_UP_POUR} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTARCHUPPOUR = (short) 148;
+ /** @deprecated use {@link ShapeType#TEXT_ARCH_DOWN_POUR} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTARCHDOWNPOUR = (short) 149;
+ /** @deprecated use {@link ShapeType#TEXT_CIRCLE_POUR} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTCIRCLEPOUR = (short) 150;
+ /** @deprecated use {@link ShapeType#TEXT_BUTTON_POUR} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTBUTTONPOUR = (short) 151;
+ /** @deprecated use {@link ShapeType#TEXT_CURVE_UP} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTCURVEUP = (short) 152;
+ /** @deprecated use {@link ShapeType#TEXT_CURVE_DOWN} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTCURVEDOWN = (short) 153;
+ /** @deprecated use {@link ShapeType#TEXT_CASCADE_UP} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTCASCADEUP = (short) 154;
+ /** @deprecated use {@link ShapeType#TEXT_CASCADE_DOWN} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTCASCADEDOWN = (short) 155;
+ /** @deprecated use {@link ShapeType#TEXT_WAVE_1} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTWAVE1 = (short) 156;
+ /** @deprecated use {@link ShapeType#TEXT_WAVE_2} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTWAVE2 = (short) 157;
+ /** @deprecated use {@link ShapeType#TEXT_WAVE_3} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTWAVE3 = (short) 158;
+ /** @deprecated use {@link ShapeType#TEXT_WAVE_4} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTWAVE4 = (short) 159;
+ /** @deprecated use {@link ShapeType#TEXT_INFLATE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTINFLATE = (short) 160;
+ /** @deprecated use {@link ShapeType#TEXT_DEFLATE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTDEFLATE = (short) 161;
+ /** @deprecated use {@link ShapeType#TEXT_INFLATE_BOTTOM} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTINFLATEBOTTOM = (short) 162;
+ /** @deprecated use {@link ShapeType#TEXT_DEFLATE_BOTTOM} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTDEFLATEBOTTOM = (short) 163;
+ /** @deprecated use {@link ShapeType#TEXT_INFLATE_TOP} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTINFLATETOP = (short) 164;
+ /** @deprecated use {@link ShapeType#TEXT_DEFLATE_TOP} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTDEFLATETOP = (short) 165;
+ /** @deprecated use {@link ShapeType#TEXT_DEFLATE_INFLATE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTDEFLATEINFLATE = (short) 166;
+ /** @deprecated use {@link ShapeType#TEXT_DEFLATE_INFLATE_DEFLATE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTDEFLATEINFLATEDEFLATE = (short) 167;
+ /** @deprecated use {@link ShapeType#TEXT_FADE_RIGHT} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTFADERIGHT = (short) 168;
+ /** @deprecated use {@link ShapeType#TEXT_FADE_LEFT} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTFADELEFT = (short) 169;
+ /** @deprecated use {@link ShapeType#TEXT_FADE_UP} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTFADEUP = (short) 170;
+ /** @deprecated use {@link ShapeType#TEXT_FADE_DOWN} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTFADEDOWN = (short) 171;
+ /** @deprecated use {@link ShapeType#TEXT_SLANT_UP} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTSLANTUP = (short) 172;
+ /** @deprecated use {@link ShapeType#TEXT_SLANT_DOWN} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTSLANTDOWN = (short) 173;
+ /** @deprecated use {@link ShapeType#TEXT_CAN_UP} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTCANUP = (short) 174;
+ /** @deprecated use {@link ShapeType#TEXT_CAN_DOWN} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTCANDOWN = (short) 175;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_ALTERNATE_PROCESS} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTALTERNATEPROCESS = (short) 176;
+ /** @deprecated use {@link ShapeType#FLOW_CHART_OFFPAGE_CONNECTOR} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_FLOWCHARTOFFPAGECONNECTOR = (short) 177;
+ /** @deprecated use {@link ShapeType#CALLOUT_90} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_CALLOUT90 = (short) 178;
+ /** @deprecated use {@link ShapeType#ACCENT_CALLOUT_90} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_ACCENTCALLOUT90 = (short) 179;
+ /** @deprecated use {@link ShapeType#BORDER_CALLOUT_90} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_BORDERCALLOUT90 = (short) 180;
+ /** @deprecated use {@link ShapeType#ACCENT_BORDER_CALLOUT_90} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_ACCENTBORDERCALLOUT90 = (short) 181;
+ /** @deprecated use {@link ShapeType#LEFT_RIGHT_UP_ARROW} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_LEFTRIGHTUPARROW = (short) 182;
+ /** @deprecated use {@link ShapeType#SUN} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_SUN = (short) 183;
+ /** @deprecated use {@link ShapeType#MOON} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_MOON = (short) 184;
+ /** @deprecated use {@link ShapeType#BRACKET_PAIR} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_BRACKETPAIR = (short) 185;
+ /** @deprecated use {@link ShapeType#BRACE_PAIR} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_BRACEPAIR = (short) 186;
+ /** @deprecated use {@link ShapeType#STAR_4} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_SEAL4 = (short) 187;
+ /** @deprecated use {@link ShapeType#DOUBLE_WAVE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_DOUBLEWAVE = (short) 188;
+ /** @deprecated use {@link ShapeType#ACTION_BUTTON_BLANK} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_ACTIONBUTTONBLANK = (short) 189;
+ /** @deprecated use {@link ShapeType#ACTION_BUTTON_HOME} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_ACTIONBUTTONHOME = (short) 190;
+ /** @deprecated use {@link ShapeType#ACTION_BUTTON_HELP} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_ACTIONBUTTONHELP = (short) 191;
+ /** @deprecated use {@link ShapeType#ACTION_BUTTON_INFORMATION} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_ACTIONBUTTONINFORMATION = (short) 192;
+ /** @deprecated use {@link ShapeType#ACTION_BUTTON_FORWARD_NEXT} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_ACTIONBUTTONFORWARDNEXT = (short) 193;
+ /** @deprecated use {@link ShapeType#ACTION_BUTTON_BACK_PREVIOUS} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_ACTIONBUTTONBACKPREVIOUS = (short) 194;
+ /** @deprecated use {@link ShapeType#ACTION_BUTTON_END} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_ACTIONBUTTONEND = (short) 195;
+ /** @deprecated use {@link ShapeType#ACTION_BUTTON_BEGINNING} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_ACTIONBUTTONBEGINNING = (short) 196;
+ /** @deprecated use {@link ShapeType#ACTION_BUTTON_RETURN} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_ACTIONBUTTONRETURN = (short) 197;
+ /** @deprecated use {@link ShapeType#ACTION_BUTTON_DOCUMENT} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_ACTIONBUTTONDOCUMENT = (short) 198;
+ /** @deprecated use {@link ShapeType#ACTION_BUTTON_SOUND} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_ACTIONBUTTONSOUND = (short) 199;
+ /** @deprecated use {@link ShapeType#ACTION_BUTTON_MOVIE} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_ACTIONBUTTONMOVIE = (short) 200;
+ /** @deprecated use {@link ShapeType#HOST_CONTROL} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_HOSTCONTROL = (short) 201;
+ /** @deprecated use {@link ShapeType#TEXT_BOX} */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_TEXTBOX = (short) 202;
+ /** @deprecated not used */
+ @Deprecated
+ @Removal(version = "5.3")
public static final short ST_NIL = (short) 0x0FFF;
/**
@@ -330,6 +947,7 @@ public final class EscherAggregate exten
/**
* @return Returns the current sid.
*/
+ @Override
public short getSid() {
return sid;
}
@@ -402,7 +1020,7 @@ public final class EscherAggregate exten
private static class ShapeCollector extends DefaultEscherRecordFactory {
final List<EscherRecord> objShapes = new ArrayList<>();
- final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ final UnsynchronizedByteArrayOutputStream buffer = new UnsynchronizedByteArrayOutputStream();
void addBytes(byte[] data) {
try {
@@ -412,6 +1030,7 @@ public final class EscherAggregate exten
}
}
+ @Override
public EscherRecord createRecord(byte[] data, int offset) {
EscherRecord r = super.createRecord(data, offset);
short rid = r.getRecordId();
@@ -423,9 +1042,10 @@ public final class EscherAggregate exten
List<EscherRecord> parse(EscherAggregate agg) {
byte[] buf = buffer.toByteArray();
- for (int pos = 0, bytesRead; pos < buf.length; pos += bytesRead) {
+ int pos = 0;
+ while (pos < buf.length) {
EscherRecord r = createRecord(buf, pos);
- bytesRead = r.fillFields(buf, pos, this);
+ pos += r.fillFields(buf, pos, this);
agg.addEscherRecord(r);
}
return objShapes;
@@ -440,6 +1060,7 @@ public final class EscherAggregate exten
* @param data The byte array to serialize to.
* @return The number of bytes serialized.
*/
+ @Override
public int serialize(final int offset, final byte[] data) {
// Determine buffer size
List <EscherRecord>records = getEscherRecords();
@@ -450,12 +1071,13 @@ public final class EscherAggregate exten
final List <Integer>spEndingOffsets = new ArrayList<>();
final List <EscherRecord> shapes = new ArrayList<>();
int pos = 0;
- for (Object record : records) {
- EscherRecord e = (EscherRecord) record;
- pos += e.serialize(pos, buffer, new EscherSerializationListener() {
+ for (EscherRecord record : records) {
+ pos += record.serialize(pos, buffer, new EscherSerializationListener() {
+ @Override
public void beforeRecordSerialize(int offset, short recordId, EscherRecord record) {
}
+ @Override
public void afterRecordSerialize(int offset, short recordId, int size, EscherRecord record) {
if (recordId == EscherClientDataRecord.RECORD_ID || recordId == EscherTextboxRecord.RECORD_ID) {
spEndingOffsets.add(offset);
@@ -545,6 +1167,7 @@ public final class EscherAggregate exten
/**
* @return record size, including header size of obj, text, note, drawing, continue records
*/
+ @Override
public int getRecordSize() {
// To determine size of aggregate record we have to know size of each DrawingRecord because if DrawingRecord
// is split into several continue records we have to add header size to total EscherAggregate size
@@ -557,9 +1180,11 @@ public final class EscherAggregate exten
int pos = 0;
for (EscherRecord e : records) {
pos += e.serialize(pos, buffer, new EscherSerializationListener() {
+ @Override
public void beforeRecordSerialize(int offset, short recordId, EscherRecord record) {
}
+ @Override
public void afterRecordSerialize(int offset, short recordId, int size, EscherRecord record) {
if (recordId == EscherClientDataRecord.RECORD_ID || recordId == EscherTextboxRecord.RECORD_ID) {
spEndingOffsets.add(offset);
@@ -615,6 +1240,7 @@ public final class EscherAggregate exten
/**
* @return "ESCHERAGGREGATE"
*/
+ @Override
protected String getRecordName() {
return "ESCHERAGGREGATE";
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/FilePassRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/FilePassRecord.java?rev=1889871&r1=1889870&r2=1889871&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/FilePassRecord.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/FilePassRecord.java Fri May 14 00:37:50 2021
@@ -17,11 +17,11 @@
package org.apache.poi.hssf.record;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Map;
import java.util.function.Supplier;
+import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.poifs.crypt.EncryptionInfo;
import org.apache.poi.poifs.crypt.EncryptionMode;
@@ -47,7 +47,7 @@ public final class FilePassRecord extend
private static final int ENCRYPTION_OTHER = 1;
private final int encryptionType;
- private EncryptionInfo encryptionInfo;
+ private final EncryptionInfo encryptionInfo;
private FilePassRecord(FilePassRecord other) {
super(other);
@@ -122,7 +122,7 @@ public final class FilePassRecord extend
@Override
protected int getDataSize() {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream();
LittleEndianOutputStream leos = new LittleEndianOutputStream(bos);
serialize(leos);
return bos.size();
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/RecordInputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/RecordInputStream.java?rev=1889871&r1=1889870&r2=1889871&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/RecordInputStream.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/RecordInputStream.java Fri May 14 00:37:50 2021
@@ -17,11 +17,11 @@
package org.apache.poi.hssf.record;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Locale;
+import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
import org.apache.poi.hssf.dev.BiffViewer;
import org.apache.poi.hssf.record.crypto.Biff8DecryptingStream;
import org.apache.poi.poifs.crypt.EncryptionInfo;
@@ -56,7 +56,6 @@ public final class RecordInputStream imp
* For use in {@link BiffViewer} which may construct {@link Record}s that don't completely
* read all available data. This exception should never be thrown otherwise.
*/
- @SuppressWarnings("serial")
public static final class LeftoverDataException extends RuntimeException {
public LeftoverDataException(int sid, int remainingByteCount) {
super("Initialisation of record 0x" + Integer.toHexString(sid).toUpperCase(Locale.ROOT)
@@ -311,6 +310,7 @@ public final class RecordInputStream imp
return Double.longBitsToDouble(readLong());
}
+ @Override
public void readPlain(byte[] buf, int off, int len) {
readFully(buf, 0, buf.length, true);
}
@@ -459,7 +459,7 @@ public final class RecordInputStream imp
*/
@Deprecated
public byte[] readAllContinuedRemainder() {
- ByteArrayOutputStream out = new ByteArrayOutputStream(2 * MAX_RECORD_DATA_SIZE);
+ UnsynchronizedByteArrayOutputStream out = new UnsynchronizedByteArrayOutputStream(2 * MAX_RECORD_DATA_SIZE);
while (true) {
byte[] b = readRemainder();
@@ -486,7 +486,7 @@ public final class RecordInputStream imp
/**
*
- * @return <code>true</code> when a {@link ContinueRecord} is next.
+ * @return {@code true} when a {@link ContinueRecord} is next.
*/
private boolean isContinueNext() {
if (_currentDataLength != DATA_LEN_NEEDS_TO_BE_READ && _currentDataOffset != _currentDataLength) {
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/SubRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/SubRecord.java?rev=1889871&r1=1889870&r2=1889871&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/SubRecord.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/record/SubRecord.java Fri May 14 00:37:50 2021
@@ -17,13 +17,13 @@
package org.apache.poi.hssf.record;
-import java.io.ByteArrayOutputStream;
import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
+import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.common.usermodel.GenericRecord;
import org.apache.poi.util.GenericRecordJsonWriter;
@@ -121,7 +121,7 @@ public abstract class SubRecord implemen
protected abstract int getDataSize();
public byte[] serialize() {
int size = getDataSize() + 4;
- ByteArrayOutputStream baos = new ByteArrayOutputStream(size);
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream(size);
serialize(new LittleEndianOutputStream(baos));
if (baos.size() != size) {
throw new RuntimeException("write size mismatch");
@@ -134,7 +134,7 @@ public abstract class SubRecord implemen
/**
* Whether this record terminates the sub-record stream.
- * There are two cases when this method must be overridden and return <code>true</code>
+ * There are two cases when this method must be overridden and return {@code true}
* - EndSubRecord (sid = 0x00)
* - LbsDataSubRecord (sid = 0x12)
*
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCombobox.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCombobox.java?rev=1889871&r1=1889870&r2=1889871&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCombobox.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFCombobox.java Fri May 14 00:37:50 2021
@@ -27,15 +27,15 @@ import org.apache.poi.ddf.EscherSimplePr
import org.apache.poi.ddf.EscherSpRecord;
import org.apache.poi.hssf.record.CommonObjectDataSubRecord;
import org.apache.poi.hssf.record.EndSubRecord;
-import org.apache.poi.hssf.record.EscherAggregate;
import org.apache.poi.hssf.record.FtCblsSubRecord;
import org.apache.poi.hssf.record.LbsDataSubRecord;
import org.apache.poi.hssf.record.ObjRecord;
import org.apache.poi.hssf.record.TextObjectRecord;
+import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.ss.usermodel.ClientAnchor.AnchorType;
/**
- *
+ *
*/
public class HSSFCombobox extends HSSFSimpleShape {
@@ -65,7 +65,7 @@ public class HSSFCombobox extends HSSFSi
spContainer.setRecordId(EscherContainerRecord.SP_CONTAINER);
spContainer.setOptions((short) 0x000F);
sp.setRecordId(EscherSpRecord.RECORD_ID);
- sp.setOptions((short) ((EscherAggregate.ST_HOSTCONTROL << 4) | 0x2));
+ sp.setOptions((short) ((ShapeType.HOST_CONTROL.nativeId << 4) | 0x2));
sp.setFlags(EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE);
opt.setRecordId(EscherOptRecord.RECORD_ID);
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFPolygon.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFPolygon.java?rev=1889871&r1=1889870&r2=1889871&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFPolygon.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFPolygon.java Fri May 14 00:37:50 2021
@@ -32,9 +32,9 @@ import org.apache.poi.ddf.EscherSimplePr
import org.apache.poi.ddf.EscherSpRecord;
import org.apache.poi.hssf.record.CommonObjectDataSubRecord;
import org.apache.poi.hssf.record.EndSubRecord;
-import org.apache.poi.hssf.record.EscherAggregate;
import org.apache.poi.hssf.record.ObjRecord;
import org.apache.poi.hssf.record.TextObjectRecord;
+import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.util.LittleEndian;
/**
@@ -65,6 +65,7 @@ public class HSSFPolygon extends HSSFSi
/**
* Generates the shape records for this shape.
*/
+ @Override
protected EscherContainerRecord createSpContainer() {
EscherContainerRecord spContainer = new EscherContainerRecord();
EscherSpRecord sp = new EscherSpRecord();
@@ -74,7 +75,7 @@ public class HSSFPolygon extends HSSFSi
spContainer.setRecordId(EscherContainerRecord.SP_CONTAINER);
spContainer.setOptions((short) 0x000F);
sp.setRecordId(EscherSpRecord.RECORD_ID);
- sp.setOptions((short) ((EscherAggregate.ST_NOT_PRIMATIVE << 4) | 0x2));
+ sp.setOptions((short) ((ShapeType.NOT_PRIMITIVE.nativeId << 4) | 0x2));
if (getParent() == null) {
sp.setFlags(EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE);
} else {
@@ -115,6 +116,7 @@ public class HSSFPolygon extends HSSFSi
/**
* Creates the low level OBJ record for this shape.
*/
+ @Override
protected ObjRecord createObjRecord() {
ObjRecord obj = new ObjRecord();
CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();
@@ -216,8 +218,6 @@ public class HSSFPolygon extends HSSFSi
/**
* Defines the width and height of the points in the polygon
- * @param width
- * @param height
*/
public void setPolygonDrawArea(int width, int height) {
setPropertyValue(new EscherSimpleProperty(EscherPropertyTypes.GEOMETRY__RIGHT, width));
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFShape.java?rev=1889871&r1=1889870&r2=1889871&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFShape.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFShape.java Fri May 14 00:37:50 2021
@@ -17,11 +17,6 @@
package org.apache.poi.hssf.usermodel;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
import org.apache.poi.ddf.EscherBoolProperty;
import org.apache.poi.ddf.EscherChildAnchorRecord;
import org.apache.poi.ddf.EscherClientAnchorRecord;
@@ -37,6 +32,7 @@ import org.apache.poi.hssf.record.Common
import org.apache.poi.hssf.record.ObjRecord;
import org.apache.poi.ss.usermodel.Shape;
import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.LittleEndianConsts;
import org.apache.poi.util.StringUtil;
/**
@@ -48,8 +44,6 @@ import org.apache.poi.util.StringUtil;
* setFlipVertical() or setFlipHorizontally().
*/
public abstract class HSSFShape implements Shape {
- private static final Logger LOG = LogManager.getLogger(HSSFShape.class);
-
public static final int LINEWIDTH_ONE_PT = 12700;
public static final int LINEWIDTH_DEFAULT = 9525;
public static final int LINESTYLE__COLOR_DEFAULT = 0x08000040;
@@ -85,8 +79,6 @@ public abstract class HSSFShape implemen
/**
* creates shapes from existing file
- * @param spContainer
- * @param objRecord
*/
public HSSFShape(EscherContainerRecord spContainer, ObjRecord objRecord) {
this._escherContainer = spContainer;
@@ -115,7 +107,6 @@ public abstract class HSSFShape implemen
* remove escher container from the patriarch.escherAggregate
* remove obj, textObj and note records if it's necessary
* in case of ShapeGroup remove all contained shapes
- * @param patriarch
*/
protected abstract void afterRemove(HSSFPatriarch patriarch);
@@ -179,7 +170,7 @@ public abstract class HSSFShape implemen
* @see HSSFClientAnchor
*/
public void setAnchor(HSSFAnchor anchor) {
- int i = 0;
+ int i;
int recordId = -1;
if (parent == null) {
if (anchor instanceof HSSFChildAnchor)
@@ -365,18 +356,13 @@ public abstract class HSSFShape implemen
* @return the rotation, in degrees, that is applied to a shape.
*/
public int getRotationDegree(){
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
EscherSimpleProperty property = getOptRecord().lookup(EscherPropertyTypes.TRANSFORM__ROTATION);
if (null == property){
return 0;
}
- try {
- LittleEndian.putInt(property.getPropertyValue(), bos);
- return LittleEndian.getShort(bos.toByteArray(), 2);
- } catch (IOException e) {
- LOG.atError().withThrowable(e).log("can't determine rotation degree");
- return 0;
- }
+ byte[] buf = new byte[LittleEndianConsts.INT_SIZE];
+ LittleEndian.putInt(buf, 0, property.getPropertyValue());
+ return LittleEndian.getShort(buf, 2);
}
/**
@@ -385,7 +371,6 @@ public abstract class HSSFShape implemen
* Negative values specify rotation in the counterclockwise direction.
* Rotation occurs around the center of the shape.
* The default value for this property is 0x00000000
- * @param value
*/
public void setRotationDegree(short value){
setPropertyValue(new EscherSimpleProperty(EscherPropertyTypes.TRANSFORM__ROTATION , (value << 16)));
@@ -415,6 +400,7 @@ public abstract class HSSFShape implemen
/**
* @return the name of this shape
*/
+ @Override
public String getShapeName() {
EscherOptRecord eor = getOptRecord();
if (eor == null) {
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFShapeGroup.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFShapeGroup.java?rev=1889871&r1=1889870&r2=1889871&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFShapeGroup.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFShapeGroup.java Fri May 14 00:37:50 2021
@@ -46,7 +46,7 @@ import org.apache.poi.hssf.record.ObjRec
*/
public class HSSFShapeGroup extends HSSFShape implements HSSFShapeContainer {
private final List<HSSFShape> shapes = new ArrayList<>();
- private EscherSpgrRecord _spgrRecord;
+ private final EscherSpgrRecord _spgrRecord;
public HSSFShapeGroup(EscherContainerRecord spgrContainer, ObjRecord objRecord) {
super(spgrContainer, objRecord);
@@ -56,14 +56,13 @@ public class HSSFShapeGroup extends HSSF
_spgrRecord = (EscherSpgrRecord) spContainer.getChild(0);
for (EscherRecord ch : spContainer) {
switch (EscherRecordTypes.forTypeID(ch.getRecordId())) {
- case SPGR:
- break;
case CLIENT_ANCHOR:
anchor = new HSSFClientAnchor((EscherClientAnchorRecord) ch);
break;
case CHILD_ANCHOR:
anchor = new HSSFChildAnchor((EscherChildAnchorRecord) ch);
break;
+ case SPGR:
default:
break;
}
@@ -141,10 +140,12 @@ public class HSSFShapeGroup extends HSSF
protected void afterRemove(HSSFPatriarch patriarch) {
patriarch.getBoundAggregate().removeShapeToObjRecord(getEscherContainer().getChildContainers().get(0)
.getChildById(EscherClientDataRecord.RECORD_ID));
- for ( int i=0; i<shapes.size(); i++ ) {
- HSSFShape shape = shapes.get(i);
- removeShape(shape);
- shape.afterRemove(getPatriarch());
+ EscherContainerRecord cont = getEscherContainer();
+ HSSFPatriarch pat = getPatriarch();
+ for (HSSFShape shape : shapes) {
+ if (cont.removeChildRecord(shape.getEscherContainer())){
+ shape.afterRemove(pat);
+ }
}
shapes.clear();
}
@@ -181,6 +182,7 @@ public class HSSFShapeGroup extends HSSF
return group;
}
+ @Override
public void addShape(HSSFShape shape) {
shape.setPatriarch(this.getPatriarch());
shape.setParent(this);
@@ -267,6 +269,7 @@ public class HSSFShapeGroup extends HSSF
/**
* Return all children contained by this shape.
*/
+ @Override
public List<HSSFShape> getChildren() {
return Collections.unmodifiableList(shapes);
}
@@ -275,6 +278,7 @@ public class HSSFShapeGroup extends HSSF
* Sets the coordinate space of this group. All children are constrained
* to these coordinates.
*/
+ @Override
public void setCoordinates(int x1, int y1, int x2, int y2) {
_spgrRecord.setRectX1(x1);
_spgrRecord.setRectX2(x2);
@@ -282,6 +286,7 @@ public class HSSFShapeGroup extends HSSF
_spgrRecord.setRectY2(y2);
}
+ @Override
public void clear() {
ArrayList <HSSFShape> copy = new ArrayList<>(shapes);
for (HSSFShape shape: copy){
@@ -292,6 +297,7 @@ public class HSSFShapeGroup extends HSSF
/**
* The top left x coordinate of this group.
*/
+ @Override
public int getX1() {
return _spgrRecord.getRectX1();
}
@@ -299,6 +305,7 @@ public class HSSFShapeGroup extends HSSF
/**
* The top left y coordinate of this group.
*/
+ @Override
public int getY1() {
return _spgrRecord.getRectY1();
}
@@ -306,6 +313,7 @@ public class HSSFShapeGroup extends HSSF
/**
* The bottom right x coordinate of this group.
*/
+ @Override
public int getX2() {
return _spgrRecord.getRectX2();
}
@@ -313,6 +321,7 @@ public class HSSFShapeGroup extends HSSF
/**
* The bottom right y coordinate of this group.
*/
+ @Override
public int getY2() {
return _spgrRecord.getRectY2();
}
@@ -320,6 +329,7 @@ public class HSSFShapeGroup extends HSSF
/**
* Count of all children and their childrens children.
*/
+ @Override
public int countOfAllChildren() {
int count = shapes.size();
for (HSSFShape shape : shapes) {
@@ -386,10 +396,11 @@ public class HSSFShapeGroup extends HSSF
return group;
}
+ @Override
public boolean removeShape(HSSFShape shape) {
boolean isRemoved = getEscherContainer().removeChildRecord(shape.getEscherContainer());
if (isRemoved){
- shape.afterRemove(this.getPatriarch());
+ shape.afterRemove(getPatriarch());
shapes.remove(shape);
}
return isRemoved;
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFTextbox.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFTextbox.java?rev=1889871&r1=1889870&r2=1889871&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFTextbox.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFTextbox.java Fri May 14 00:37:50 2021
@@ -33,6 +33,7 @@ import org.apache.poi.hssf.record.EndSub
import org.apache.poi.hssf.record.EscherAggregate;
import org.apache.poi.hssf.record.ObjRecord;
import org.apache.poi.hssf.record.TextObjectRecord;
+import org.apache.poi.sl.usermodel.ShapeType;
/**
* A textbox is a shape that may hold a rich text string.
@@ -68,7 +69,7 @@ public class HSSFTextbox extends HSSFSim
/**
* Construct a new textbox with the given parent and anchor.
*
- * @param parent
+ * @param parent the parent shape
* @param anchor One of HSSFClientAnchor or HSSFChildAnchor
*/
public HSSFTextbox(HSSFShape parent, HSSFAnchor anchor) {
@@ -104,7 +105,7 @@ public class HSSFTextbox extends HSSFSim
spContainer.setRecordId(EscherContainerRecord.SP_CONTAINER);
spContainer.setOptions((short) 0x000F);
sp.setRecordId(EscherSpRecord.RECORD_ID);
- sp.setOptions((short) ((EscherAggregate.ST_TEXTBOX << 4) | 0x2));
+ sp.setOptions((short) ((ShapeType.TEXT_BOX.nativeId << 4) | 0x2));
sp.setFlags(EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE);
opt.setRecordId(EscherOptRecord.RECORD_ID);
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java?rev=1889871&r1=1889870&r2=1889871&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java Fri May 14 00:37:50 2021
@@ -23,7 +23,6 @@ import static org.apache.poi.hssf.model.
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -47,6 +46,7 @@ import java.util.Set;
import java.util.regex.Pattern;
import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.poi.EncryptedDocumentException;
@@ -942,7 +942,6 @@ public final class HSSFWorkbook extends
private final class SheetIterator<T extends Sheet> implements Iterator<T> {
final private Iterator<T> it;
- private T cursor;
@SuppressWarnings("unchecked")
public SheetIterator() {
@@ -956,8 +955,7 @@ public final class HSSFWorkbook extends
@Override
public T next() throws NoSuchElementException {
- cursor = it.next();
- return cursor;
+ return it.next();
}
/**
@@ -1994,9 +1992,10 @@ public final class HSSFWorkbook extends
}
}
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- poiData.writeFilesystem(bos);
- return addOlePackage(bos.toByteArray(), label, fileName, command);
+ try (UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream()) {
+ poiData.writeFilesystem(bos);
+ return addOlePackage(bos.toByteArray(), label, fileName, command);
+ }
}
@Override
@@ -2021,9 +2020,10 @@ public final class HSSFWorkbook extends
Ole10Native.createOleMarkerEntry(oleDir);
Ole10Native oleNative = new Ole10Native(label, fileName, command, oleData);
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- oleNative.writeOut(bos);
- oleDir.createDocument(Ole10Native.OLE10_NATIVE, new ByteArrayInputStream(bos.toByteArray()));
+ try (UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream()) {
+ oleNative.writeOut(bos);
+ oleDir.createDocument(Ole10Native.OLE10_NATIVE, bos.toInputStream());
+ }
return storageId;
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java?rev=1889871&r1=1889870&r2=1889871&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDecryptor.java Fri May 14 00:37:50 2021
@@ -17,7 +17,6 @@
package org.apache.poi.poifs.crypt.cryptoapi;
-import java.io.ByteArrayOutputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
@@ -29,6 +28,7 @@ import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
+import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.poifs.crypt.ChunkedCipherInputStream;
import org.apache.poi.poifs.crypt.CryptoFunctions;
@@ -43,7 +43,7 @@ import org.apache.poi.poifs.filesystem.D
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
-import org.apache.poi.util.BoundedInputStream;
+import org.apache.commons.io.input.BoundedInputStream;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LittleEndianInputStream;
@@ -171,10 +171,10 @@ public class CryptoAPIDecryptor extends
public POIFSFileSystem getSummaryEntries(DirectoryNode root, String encryptedStream)
throws IOException, GeneralSecurityException {
DocumentNode es = (DocumentNode) root.getEntry(encryptedStream);
- DocumentInputStream dis = root.createDocumentInputStream(es);
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- IOUtils.copy(dis, bos);
- dis.close();
+ UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream();
+ try (DocumentInputStream dis = root.createDocumentInputStream(es)) {
+ IOUtils.copy(dis, bos);
+ }
POIFSFileSystem fsOut = null;
try (
CryptoAPIDocumentInputStream sbis = new CryptoAPIDocumentInputStream(this, bos.toByteArray());
Modified: poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDocumentOutputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDocumentOutputStream.java?rev=1889871&r1=1889870&r2=1889871&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDocumentOutputStream.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIDocumentOutputStream.java Fri May 14 00:37:50 2021
@@ -16,11 +16,13 @@
==================================================================== */
package org.apache.poi.poifs.crypt.cryptoapi;
-import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
import java.security.GeneralSecurityException;
import javax.crypto.Cipher;
+import org.apache.commons.io.input.BoundedInputStream;
+import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.util.Internal;
@@ -38,8 +40,8 @@ import org.apache.poi.util.Internal;
cipher = encryptor.initCipherForBlock(null, 0);
}
- public byte[] getBuf() {
- return buf;
+ public InputStream toInputStream(long maxSize) {
+ return new BoundedInputStream(toInputStream(), maxSize);
}
public void setSize(int count) {
Modified: poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIEncryptor.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIEncryptor.java?rev=1889871&r1=1889870&r2=1889871&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIEncryptor.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIEncryptor.java Fri May 14 00:37:50 2021
@@ -17,7 +17,6 @@
package org.apache.poi.poifs.crypt.cryptoapi;
-import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
@@ -188,7 +187,7 @@ public class CryptoAPIEncryptor extends
bos.write(buf, 0, 8);
bos.setSize(savedSize);
- dir.createDocument(encryptedStream, new ByteArrayInputStream(bos.getBuf(), 0, savedSize));
+ dir.createDocument(encryptedStream, bos.toInputStream(savedSize));
}
// protected int getKeySizeInBytes() {
Modified: poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/standard/StandardDecryptor.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/standard/StandardDecryptor.java?rev=1889871&r1=1889870&r2=1889871&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/standard/StandardDecryptor.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/standard/StandardDecryptor.java Fri May 14 00:37:50 2021
@@ -38,7 +38,7 @@ import org.apache.poi.poifs.crypt.Encryp
import org.apache.poi.poifs.crypt.HashAlgorithm;
import org.apache.poi.poifs.filesystem.DirectoryNode;
import org.apache.poi.poifs.filesystem.DocumentInputStream;
-import org.apache.poi.util.BoundedInputStream;
+import org.apache.commons.io.input.BoundedInputStream;
import org.apache.poi.util.LittleEndian;
/**
Modified: poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/DocumentOutputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/DocumentOutputStream.java?rev=1889871&r1=1889870&r2=1889871&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/DocumentOutputStream.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/DocumentOutputStream.java Fri May 14 00:37:50 2021
@@ -18,10 +18,10 @@
package org.apache.poi.poifs.filesystem;
import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
import org.apache.poi.poifs.common.POIFSConstants;
import org.apache.poi.poifs.property.DocumentProperty;
@@ -37,13 +37,13 @@ public final class DocumentOutputStream
private boolean _closed = false;
/** the actual Document */
- private POIFSDocument _document;
+ private final POIFSDocument _document;
/** and its Property */
- private DocumentProperty _property;
+ private final DocumentProperty _property;
/** our buffer, when null we're into normal blocks */
- private ByteArrayOutputStream _buffer =
- new ByteArrayOutputStream(POIFSConstants.BIG_BLOCK_MINIMUM_DOCUMENT_SIZE);
+ private UnsynchronizedByteArrayOutputStream _buffer =
+ new UnsynchronizedByteArrayOutputStream(POIFSConstants.BIG_BLOCK_MINIMUM_DOCUMENT_SIZE);
/** our main block stream, when we're into normal blocks */
private POIFSStream _stream;
@@ -115,11 +115,11 @@ public final class DocumentOutputStream
byte[] data = _buffer.toByteArray();
_buffer = null;
write(data, 0, data.length);
- } else {
- // So far, mini stream will work, keep going
}
+ // otherwise mini stream will work, keep going
}
+ @Override
public void write(int b) throws IOException {
write(new byte[] { (byte)b }, 0, 1);
}
@@ -146,11 +146,12 @@ public final class DocumentOutputStream
}
}
+ @Override
public void close() throws IOException {
// Do we have a pending buffer for the mini stream?
if (_buffer != null) {
// It's not much data, so ask POIFSDocument to do it for us
- _document.replaceContents(new ByteArrayInputStream(_buffer.toByteArray()));
+ _document.replaceContents(_buffer.toInputStream());
}
else {
// We've been writing to the stream as we've gone along
Modified: poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/EntryUtils.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/EntryUtils.java?rev=1889871&r1=1889870&r2=1889871&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/EntryUtils.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/EntryUtils.java Fri May 14 00:37:50 2021
@@ -25,7 +25,6 @@ import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
-import org.apache.poi.hpsf.MarkUnsupportedException;
import org.apache.poi.hpsf.NoPropertySetStreamException;
import org.apache.poi.hpsf.PropertySet;
import org.apache.poi.hpsf.PropertySetFactory;
@@ -238,7 +237,7 @@ public final class EntryUtils {
} else {
return isEqual(inpA, inpB);
}
- } catch (MarkUnsupportedException | NoPropertySetStreamException | IOException ex) {
+ } catch (NoPropertySetStreamException | IOException ex) {
throw new RuntimeException(ex);
}
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/Ole10Native.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/Ole10Native.java?rev=1889871&r1=1889870&r2=1889871&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/Ole10Native.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/Ole10Native.java Fri May 14 00:37:50 2021
@@ -18,12 +18,12 @@
package org.apache.poi.poifs.filesystem;
import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
+import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.LittleEndianByteArrayInputStream;
import org.apache.poi.util.LittleEndianConsts;
@@ -336,7 +336,7 @@ public class Ole10Native {
/**
* Returns the size of the embedded file. If the size is 0 (zero), no data
* has been embedded. To be sure, that no data has been embedded, check
- * whether {@link #getDataBuffer()} returns <code>null</code>.
+ * whether {@link #getDataBuffer()} returns {@code null}.
*
* @return the dataSize
*/
@@ -346,10 +346,10 @@ public class Ole10Native {
/**
* Returns the buffer containing the embedded file's data, or
- * <code>null</code> if no data was embedded. Note that an embedding may
+ * {@code null} if no data was embedded. Note that an embedding may
* provide information about the data, but the actual data is not included.
* (So label, filename etc. are available, but this method returns
- * <code>null</code>.)
+ * {@code null}.)
*
* @return the dataBuffer
*/
@@ -372,7 +372,7 @@ public class Ole10Native {
switch (mode) {
case parsed: {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream();
try (LittleEndianOutputStream leos = new LittleEndianOutputStream(bos)) {
// total size, will be determined later ..
Modified: poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java?rev=1889871&r1=1889870&r2=1889871&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java Fri May 14 00:37:50 2021
@@ -16,7 +16,6 @@
==================================================================== */
package org.apache.poi.poifs.filesystem;
-import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
@@ -33,6 +32,7 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
import org.apache.commons.math3.util.ArithmeticUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -733,7 +733,7 @@ public class POIFSFileSystem extends Blo
// _header.setPropertyStart has been updated on write ...
// HeaderBlock
- ByteArrayOutputStream baos = new ByteArrayOutputStream(
+ UnsynchronizedByteArrayOutputStream baos = new UnsynchronizedByteArrayOutputStream(
_header.getBigBlockSize().getBigBlockSize()
);
_header.writeData(baos);
Modified: poi/trunk/poi/src/main/java/org/apache/poi/poifs/macros/VBAMacroReader.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/poifs/macros/VBAMacroReader.java?rev=1889871&r1=1889870&r2=1889871&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/poifs/macros/VBAMacroReader.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/poifs/macros/VBAMacroReader.java Fri May 14 00:37:50 2021
@@ -22,7 +22,6 @@ import static org.apache.poi.util.String
import static org.apache.poi.util.StringUtil.startsWithIgnoreCase;
import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.EOFException;
import java.io.File;
@@ -38,6 +37,7 @@ import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
+import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.poi.poifs.filesystem.DirectoryNode;
@@ -167,10 +167,7 @@ public class VBAMacroReader implements C
ModuleType moduleType;
Charset charset;
void read(InputStream in) throws IOException {
- final ByteArrayOutputStream out = new ByteArrayOutputStream();
- IOUtils.copy(in, out);
- out.close();
- buf = out.toByteArray();
+ buf = IOUtils.toByteArray(in);
}
@Override
public String getContent() {
@@ -414,13 +411,12 @@ public class VBAMacroReader implements C
UNKNOWN(-2);
- private final int VARIABLE_LENGTH = -1;
private final int id;
private final int constantLength;
RecordType(int id) {
this.id = id;
- this.constantLength = VARIABLE_LENGTH;
+ this.constantLength = -1;
}
RecordType(int id, int constantLength) {
@@ -651,13 +647,13 @@ public class VBAMacroReader implements C
return;
}
}
- mbcs = readMBCS(b, is, charset, MAX_STRING_LENGTH);
+ mbcs = readMBCS(b, is, charset);
} catch (EOFException e) {
return;
}
try {
- unicode = readUnicode(is, MAX_STRING_LENGTH);
+ unicode = readUnicode(is);
} catch (EOFException e) {
return;
}
@@ -669,14 +665,14 @@ public class VBAMacroReader implements C
LOGGER.atWarn().log("Hit max name records to read (" + maxNameRecords + "). Stopped early.");
}
- private static String readUnicode(InputStream is, int maxLength) throws IOException {
+ private static String readUnicode(InputStream is) throws IOException {
//reads null-terminated unicode string
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream();
int b0 = IOUtils.readByte(is);
int b1 = IOUtils.readByte(is);
int read = 2;
- while ((b0 + b1) != 0 && read < maxLength) {
+ while ((b0 + b1) != 0 && read < MAX_STRING_LENGTH) {
bos.write(b0);
bos.write(b1);
@@ -684,22 +680,22 @@ public class VBAMacroReader implements C
b1 = IOUtils.readByte(is);
read += 2;
}
- if (read >= maxLength) {
+ if (read >= MAX_STRING_LENGTH) {
LOGGER.atWarn().log("stopped reading unicode name after {} bytes", box(read));
}
- return new String (bos.toByteArray(), StandardCharsets.UTF_16LE);
+ return bos.toString(StandardCharsets.UTF_16LE);
}
- private static String readMBCS(int firstByte, InputStream is, Charset charset, int maxLength) throws IOException {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ private static String readMBCS(int firstByte, InputStream is, Charset charset) throws IOException {
+ UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream();
int len = 0;
int b = firstByte;
- while (b > 0 && len < maxLength) {
+ while (b > 0 && len < MAX_STRING_LENGTH) {
++len;
bos.write(b);
b = IOUtils.readByte(is);
}
- return new String(bos.toByteArray(), charset);
+ return bos.toString(charset);
}
/**
@@ -796,7 +792,7 @@ public class VBAMacroReader implements C
*/
private static byte[] findCompressedStreamWBruteForce(InputStream is) throws IOException {
//buffer to memory for multiple tries
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream();
IOUtils.copy(is, bos);
byte[] compressed = bos.toByteArray();
byte[] decompressed = null;
@@ -825,7 +821,7 @@ public class VBAMacroReader implements C
}
private static byte[] tryToDecompress(InputStream is) {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream();
try {
IOUtils.copy(new RLEDecompressingInputStream(is), bos);
} catch (IllegalArgumentException | IOException | IllegalStateException e){
Modified: poi/trunk/poi/src/main/java/org/apache/poi/sl/draw/BitmapImageRenderer.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/sl/draw/BitmapImageRenderer.java?rev=1889871&r1=1889870&r2=1889871&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/sl/draw/BitmapImageRenderer.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/sl/draw/BitmapImageRenderer.java Fri May 14 00:37:50 2021
@@ -28,7 +28,6 @@ import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;
import java.awt.image.RescaleOp;
import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator;
@@ -40,6 +39,7 @@ import javax.imageio.ImageTypeSpecifier;
import javax.imageio.stream.ImageInputStream;
import javax.imageio.stream.MemoryCacheImageInputStream;
+import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.poi.sl.usermodel.PictureData.PictureType;
@@ -73,11 +73,11 @@ public class BitmapImageRenderer impleme
public void loadImage(InputStream data, String contentType) throws IOException {
InputStream in = data;
if (doCache) {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream();
IOUtils.copy(data, bos);
cachedImage = bos.toByteArray();
cachedContentType = contentType;
- in = new ByteArrayInputStream(cachedImage);
+ in = bos.toInputStream();
}
img = readImage(in, contentType);
}
@@ -107,13 +107,13 @@ public class BitmapImageRenderer impleme
IOException lastException = null;
BufferedImage img = null;
- final ByteArrayInputStream bis;
+ final InputStream bis;
if (data instanceof ByteArrayInputStream) {
- bis = (ByteArrayInputStream)data;
+ bis = data;
} else {
- ByteArrayOutputStream bos = new ByteArrayOutputStream(0x3FFFF);
+ UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream(0x3FFFF);
IOUtils.copy(data, bos);
- bis = new ByteArrayInputStream(bos.toByteArray());
+ bis = bos.toInputStream();
}
@@ -257,7 +257,7 @@ public class BitmapImageRenderer impleme
@Override
public BufferedImage getImage(Dimension2D dim) {
if (img == null) {
- return img;
+ return null;
}
double w_old = img.getWidth();
double h_old = img.getHeight();
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org