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 2019/12/22 21:44:48 UTC
svn commit: r1871911 [10/15] - in /poi/trunk/src:
integrationtest/org/apache/poi/
integrationtest/org/apache/poi/hssf/usermodel/ java/org/apache/poi/common/
java/org/apache/poi/ddf/
java/org/apache/poi/hssf/eventusermodel/dummyrecord/ java/org/apache/p...
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/chart/TextRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/chart/TextRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/chart/TextRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/chart/TextRecord.java Sun Dec 22 21:44:45 2019
@@ -23,13 +23,14 @@ import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.HexDump;
import org.apache.poi.util.LittleEndianOutput;
+import org.apache.poi.util.Removal;
/**
* The text record is used to define text stored on a chart.
*/
public final class TextRecord extends StandardRecord {
- public final static short sid = 0x1025;
-
+ public static final short sid = 0x1025;
+
private static final BitField dataLabelPlacement = BitFieldFactory.getInstance(0x000F);
private static final BitField autoColor = BitFieldFactory.getInstance(0x0001);
private static final BitField showKey = BitFieldFactory.getInstance(0x0002);
@@ -45,66 +46,82 @@ public final class TextRecord extends St
private static final BitField showValueAsPercentage = BitFieldFactory.getInstance(0x1000);
private static final BitField showBubbleSizes = BitFieldFactory.getInstance(0x2000);
private static final BitField showLabel = BitFieldFactory.getInstance(0x4000);
-
-
- private byte field_1_horizontalAlignment;
- public final static byte HORIZONTAL_ALIGNMENT_LEFT = 1;
- public final static byte HORIZONTAL_ALIGNMENT_CENTER = 2;
- public final static byte HORIZONTAL_ALIGNMENT_BOTTOM = 3;
- public final static byte HORIZONTAL_ALIGNMENT_JUSTIFY = 4;
- private byte field_2_verticalAlignment;
- public final static byte VERTICAL_ALIGNMENT_TOP = 1;
- public final static byte VERTICAL_ALIGNMENT_CENTER = 2;
- public final static byte VERTICAL_ALIGNMENT_BOTTOM = 3;
- public final static byte VERTICAL_ALIGNMENT_JUSTIFY = 4;
- private short field_3_displayMode;
- public final static short DISPLAY_MODE_TRANSPARENT = 1;
- public final static short DISPLAY_MODE_OPAQUE = 2;
- private int field_4_rgbColor;
- private int field_5_x;
- private int field_6_y;
- private int field_7_width;
- private int field_8_height;
- private short field_9_options1;
- public final static short ROTATION_NONE = 0;
- public final static short ROTATION_TOP_TO_BOTTOM = 1;
- public final static short ROTATION_ROTATED_90_DEGREES = 2;
- public final static short ROTATION_ROTATED_90_DEGREES_CLOCKWISE = 3;
- private short field_10_indexOfColorValue;
- private short field_11_options2;
- public final static short DATA_LABEL_PLACEMENT_CHART_DEPENDENT = 0;
- public final static short DATA_LABEL_PLACEMENT_OUTSIDE = 1;
- public final static short DATA_LABEL_PLACEMENT_INSIDE = 2;
- public final static short DATA_LABEL_PLACEMENT_CENTER = 3;
- public final static short DATA_LABEL_PLACEMENT_AXIS = 4;
- public final static short DATA_LABEL_PLACEMENT_ABOVE = 5;
- public final static short DATA_LABEL_PLACEMENT_BELOW = 6;
- public final static short DATA_LABEL_PLACEMENT_LEFT = 7;
- public final static short DATA_LABEL_PLACEMENT_RIGHT = 8;
- public final static short DATA_LABEL_PLACEMENT_AUTO = 9;
- public final static short DATA_LABEL_PLACEMENT_USER_MOVED = 10;
- private short field_12_textRotation;
-
-
- public TextRecord()
- {
- }
- public TextRecord(RecordInputStream in)
- {
- field_1_horizontalAlignment = in.readByte();
- field_2_verticalAlignment = in.readByte();
- field_3_displayMode = in.readShort();
- field_4_rgbColor = in.readInt();
- field_5_x = in.readInt();
- field_6_y = in.readInt();
- field_7_width = in.readInt();
- field_8_height = in.readInt();
- field_9_options1 = in.readShort();
- field_10_indexOfColorValue = in.readShort();
- field_11_options2 = in.readShort();
- field_12_textRotation = in.readShort();
+ public static final byte HORIZONTAL_ALIGNMENT_LEFT = 1;
+ public static final byte HORIZONTAL_ALIGNMENT_CENTER = 2;
+ public static final byte HORIZONTAL_ALIGNMENT_BOTTOM = 3;
+ public static final byte HORIZONTAL_ALIGNMENT_JUSTIFY = 4;
+
+ public static final byte VERTICAL_ALIGNMENT_TOP = 1;
+ public static final byte VERTICAL_ALIGNMENT_CENTER = 2;
+ public static final byte VERTICAL_ALIGNMENT_BOTTOM = 3;
+ public static final byte VERTICAL_ALIGNMENT_JUSTIFY = 4;
+
+ public static final short DISPLAY_MODE_TRANSPARENT = 1;
+ public static final short DISPLAY_MODE_OPAQUE = 2;
+
+ public static final short ROTATION_NONE = 0;
+ public static final short ROTATION_TOP_TO_BOTTOM = 1;
+ public static final short ROTATION_ROTATED_90_DEGREES = 2;
+ public static final short ROTATION_ROTATED_90_DEGREES_CLOCKWISE = 3;
+
+ public static final short DATA_LABEL_PLACEMENT_CHART_DEPENDENT = 0;
+ public static final short DATA_LABEL_PLACEMENT_OUTSIDE = 1;
+ public static final short DATA_LABEL_PLACEMENT_INSIDE = 2;
+ public static final short DATA_LABEL_PLACEMENT_CENTER = 3;
+ public static final short DATA_LABEL_PLACEMENT_AXIS = 4;
+ public static final short DATA_LABEL_PLACEMENT_ABOVE = 5;
+ public static final short DATA_LABEL_PLACEMENT_BELOW = 6;
+ public static final short DATA_LABEL_PLACEMENT_LEFT = 7;
+ public static final short DATA_LABEL_PLACEMENT_RIGHT = 8;
+ public static final short DATA_LABEL_PLACEMENT_AUTO = 9;
+ public static final short DATA_LABEL_PLACEMENT_USER_MOVED = 10;
+
+ private byte field_1_horizontalAlignment;
+ private byte field_2_verticalAlignment;
+ private short field_3_displayMode;
+ private int field_4_rgbColor;
+ private int field_5_x;
+ private int field_6_y;
+ private int field_7_width;
+ private int field_8_height;
+ private short field_9_options1;
+ private short field_10_indexOfColorValue;
+ private short field_11_options2;
+ private short field_12_textRotation;
+
+ public TextRecord() {}
+
+ public TextRecord(TextRecord other) {
+ super(other);
+ field_1_horizontalAlignment = other.field_1_horizontalAlignment;
+ field_2_verticalAlignment = other.field_2_verticalAlignment;
+ field_3_displayMode = other.field_3_displayMode;
+ field_4_rgbColor = other.field_4_rgbColor;
+ field_5_x = other.field_5_x;
+ field_6_y = other.field_6_y;
+ field_7_width = other.field_7_width;
+ field_8_height = other.field_8_height;
+ field_9_options1 = other.field_9_options1;
+ field_10_indexOfColorValue = other.field_10_indexOfColorValue;
+ field_11_options2 = other.field_11_options2;
+ field_12_textRotation = other.field_12_textRotation;
+ }
+
+ public TextRecord(RecordInputStream in) {
+ field_1_horizontalAlignment = in.readByte();
+ field_2_verticalAlignment = in.readByte();
+ field_3_displayMode = in.readShort();
+ field_4_rgbColor = in.readInt();
+ field_5_x = in.readInt();
+ field_6_y = in.readInt();
+ field_7_width = in.readInt();
+ field_8_height = in.readInt();
+ field_9_options1 = in.readShort();
+ field_10_indexOfColorValue = in.readShort();
+ field_11_options2 = in.readShort();
+ field_12_textRotation = in.readShort();
}
public String toString()
@@ -115,65 +132,65 @@ public final class TextRecord extends St
buffer.append(" .horizontalAlignment = ")
.append("0x").append(HexDump.toHex( getHorizontalAlignment ()))
.append(" (").append( getHorizontalAlignment() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
+ buffer.append(System.getProperty("line.separator"));
buffer.append(" .verticalAlignment = ")
.append("0x").append(HexDump.toHex( getVerticalAlignment ()))
.append(" (").append( getVerticalAlignment() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
+ buffer.append(System.getProperty("line.separator"));
buffer.append(" .displayMode = ")
.append("0x").append(HexDump.toHex( getDisplayMode ()))
.append(" (").append( getDisplayMode() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
+ buffer.append(System.getProperty("line.separator"));
buffer.append(" .rgbColor = ")
.append("0x").append(HexDump.toHex( getRgbColor ()))
.append(" (").append( getRgbColor() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
+ buffer.append(System.getProperty("line.separator"));
buffer.append(" .x = ")
.append("0x").append(HexDump.toHex( getX ()))
.append(" (").append( getX() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
+ buffer.append(System.getProperty("line.separator"));
buffer.append(" .y = ")
.append("0x").append(HexDump.toHex( getY ()))
.append(" (").append( getY() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
+ buffer.append(System.getProperty("line.separator"));
buffer.append(" .width = ")
.append("0x").append(HexDump.toHex( getWidth ()))
.append(" (").append( getWidth() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
+ buffer.append(System.getProperty("line.separator"));
buffer.append(" .height = ")
.append("0x").append(HexDump.toHex( getHeight ()))
.append(" (").append( getHeight() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
+ buffer.append(System.getProperty("line.separator"));
buffer.append(" .options1 = ")
.append("0x").append(HexDump.toHex( getOptions1 ()))
.append(" (").append( getOptions1() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
- buffer.append(" .autoColor = ").append(isAutoColor()).append('\n');
- buffer.append(" .showKey = ").append(isShowKey()).append('\n');
- buffer.append(" .showValue = ").append(isShowValue()).append('\n');
- buffer.append(" .vertical = ").append(isVertical()).append('\n');
- buffer.append(" .autoGeneratedText = ").append(isAutoGeneratedText()).append('\n');
- buffer.append(" .generated = ").append(isGenerated()).append('\n');
- buffer.append(" .autoLabelDeleted = ").append(isAutoLabelDeleted()).append('\n');
- buffer.append(" .autoBackground = ").append(isAutoBackground()).append('\n');
- buffer.append(" .rotation = ").append(getRotation()).append('\n');
- buffer.append(" .showCategoryLabelAsPercentage = ").append(isShowCategoryLabelAsPercentage()).append('\n');
- buffer.append(" .showValueAsPercentage = ").append(isShowValueAsPercentage()).append('\n');
- buffer.append(" .showBubbleSizes = ").append(isShowBubbleSizes()).append('\n');
- buffer.append(" .showLabel = ").append(isShowLabel()).append('\n');
+ buffer.append(System.getProperty("line.separator"));
+ buffer.append(" .autoColor = ").append(isAutoColor()).append('\n');
+ buffer.append(" .showKey = ").append(isShowKey()).append('\n');
+ buffer.append(" .showValue = ").append(isShowValue()).append('\n');
+ buffer.append(" .vertical = ").append(isVertical()).append('\n');
+ buffer.append(" .autoGeneratedText = ").append(isAutoGeneratedText()).append('\n');
+ buffer.append(" .generated = ").append(isGenerated()).append('\n');
+ buffer.append(" .autoLabelDeleted = ").append(isAutoLabelDeleted()).append('\n');
+ buffer.append(" .autoBackground = ").append(isAutoBackground()).append('\n');
+ buffer.append(" .rotation = ").append(getRotation()).append('\n');
+ buffer.append(" .showCategoryLabelAsPercentage = ").append(isShowCategoryLabelAsPercentage()).append('\n');
+ buffer.append(" .showValueAsPercentage = ").append(isShowValueAsPercentage()).append('\n');
+ buffer.append(" .showBubbleSizes = ").append(isShowBubbleSizes()).append('\n');
+ buffer.append(" .showLabel = ").append(isShowLabel()).append('\n');
buffer.append(" .indexOfColorValue = ")
.append("0x").append(HexDump.toHex( getIndexOfColorValue ()))
.append(" (").append( getIndexOfColorValue() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
+ buffer.append(System.getProperty("line.separator"));
buffer.append(" .options2 = ")
.append("0x").append(HexDump.toHex( getOptions2 ()))
.append(" (").append( getOptions2() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
- buffer.append(" .dataLabelPlacement = ").append(getDataLabelPlacement()).append('\n');
+ buffer.append(System.getProperty("line.separator"));
+ buffer.append(" .dataLabelPlacement = ").append(getDataLabelPlacement()).append('\n');
buffer.append(" .textRotation = ")
.append("0x").append(HexDump.toHex( getTextRotation ()))
.append(" (").append( getTextRotation() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
+ buffer.append(System.getProperty("line.separator"));
buffer.append("[/TEXT]\n");
return buffer.toString();
@@ -203,31 +220,23 @@ public final class TextRecord extends St
return sid;
}
- public Object clone() {
- TextRecord rec = new TextRecord();
-
- rec.field_1_horizontalAlignment = field_1_horizontalAlignment;
- rec.field_2_verticalAlignment = field_2_verticalAlignment;
- rec.field_3_displayMode = field_3_displayMode;
- rec.field_4_rgbColor = field_4_rgbColor;
- rec.field_5_x = field_5_x;
- rec.field_6_y = field_6_y;
- rec.field_7_width = field_7_width;
- rec.field_8_height = field_8_height;
- rec.field_9_options1 = field_9_options1;
- rec.field_10_indexOfColorValue = field_10_indexOfColorValue;
- rec.field_11_options2 = field_11_options2;
- rec.field_12_textRotation = field_12_textRotation;
- return rec;
+ @Override
+ @SuppressWarnings("squid:S2975")
+ @Deprecated
+ @Removal(version = "5.0.0")
+ public TextRecord clone() {
+ return copy();
}
-
-
+ @Override
+ public TextRecord copy() {
+ return new TextRecord(this);
+ }
/**
* Get the horizontal alignment field for the Text record.
*
- * @return One of
+ * @return One of
* HORIZONTAL_ALIGNMENT_LEFT
* HORIZONTAL_ALIGNMENT_CENTER
* HORIZONTAL_ALIGNMENT_BOTTOM
@@ -242,7 +251,7 @@ public final class TextRecord extends St
* Set the horizontal alignment field for the Text record.
*
* @param field_1_horizontalAlignment
- * One of
+ * One of
* HORIZONTAL_ALIGNMENT_LEFT
* HORIZONTAL_ALIGNMENT_CENTER
* HORIZONTAL_ALIGNMENT_BOTTOM
@@ -256,7 +265,7 @@ public final class TextRecord extends St
/**
* Get the vertical alignment field for the Text record.
*
- * @return One of
+ * @return One of
* VERTICAL_ALIGNMENT_TOP
* VERTICAL_ALIGNMENT_CENTER
* VERTICAL_ALIGNMENT_BOTTOM
@@ -271,7 +280,7 @@ public final class TextRecord extends St
* Set the vertical alignment field for the Text record.
*
* @param field_2_verticalAlignment
- * One of
+ * One of
* VERTICAL_ALIGNMENT_TOP
* VERTICAL_ALIGNMENT_CENTER
* VERTICAL_ALIGNMENT_BOTTOM
@@ -285,7 +294,7 @@ public final class TextRecord extends St
/**
* Get the display mode field for the Text record.
*
- * @return One of
+ * @return One of
* DISPLAY_MODE_TRANSPARENT
* DISPLAY_MODE_OPAQUE
*/
@@ -298,7 +307,7 @@ public final class TextRecord extends St
* Set the display mode field for the Text record.
*
* @param field_3_displayMode
- * One of
+ * One of
* DISPLAY_MODE_TRANSPARENT
* DISPLAY_MODE_OPAQUE
*/
@@ -525,7 +534,7 @@ public final class TextRecord extends St
/**
* Sets the auto generated text field value.
- *
+ *
*/
public void setAutoGeneratedText(boolean value)
{
@@ -533,7 +542,7 @@ public final class TextRecord extends St
}
/**
- *
+ *
* @return the auto generated text field value.
*/
public boolean isAutoGeneratedText()
@@ -543,7 +552,7 @@ public final class TextRecord extends St
/**
* Sets the generated field value.
- *
+ *
*/
public void setGenerated(boolean value)
{
@@ -551,7 +560,7 @@ public final class TextRecord extends St
}
/**
- *
+ *
* @return the generated field value.
*/
public boolean isGenerated()
@@ -561,7 +570,7 @@ public final class TextRecord extends St
/**
* Sets the auto label deleted field value.
- *
+ *
*/
public void setAutoLabelDeleted(boolean value)
{
@@ -569,7 +578,7 @@ public final class TextRecord extends St
}
/**
- *
+ *
* @return the auto label deleted field value.
*/
public boolean isAutoLabelDeleted()
@@ -579,7 +588,7 @@ public final class TextRecord extends St
/**
* Sets the auto background field value.
- *
+ *
*/
public void setAutoBackground(boolean value)
{
@@ -587,7 +596,7 @@ public final class TextRecord extends St
}
/**
- *
+ *
* @return the auto background field value.
*/
public boolean isAutoBackground()
@@ -597,7 +606,7 @@ public final class TextRecord extends St
/**
* Sets the rotation field value.
- *
+ *
*/
public void setRotation(short value)
{
@@ -605,7 +614,7 @@ public final class TextRecord extends St
}
/**
- *
+ *
* @return the rotation field value.
*/
public short getRotation()
@@ -615,7 +624,7 @@ public final class TextRecord extends St
/**
* Sets the show category label as percentage field value.
- *
+ *
*/
public void setShowCategoryLabelAsPercentage(boolean value)
{
@@ -623,7 +632,7 @@ public final class TextRecord extends St
}
/**
- *
+ *
* @return the show category label as percentage field value.
*/
public boolean isShowCategoryLabelAsPercentage()
@@ -633,7 +642,7 @@ public final class TextRecord extends St
/**
* Sets the show value as percentage field value.
- *
+ *
*/
public void setShowValueAsPercentage(boolean value)
{
@@ -641,7 +650,7 @@ public final class TextRecord extends St
}
/**
- *
+ *
* @return the show value as percentage field value.
*/
public boolean isShowValueAsPercentage()
@@ -651,7 +660,7 @@ public final class TextRecord extends St
/**
* Sets the show bubble sizes field value.
- *
+ *
*/
public void setShowBubbleSizes(boolean value)
{
@@ -659,7 +668,7 @@ public final class TextRecord extends St
}
/**
- *
+ *
* @return the show bubble sizes field value.
*/
public boolean isShowBubbleSizes()
@@ -669,7 +678,7 @@ public final class TextRecord extends St
/**
* Sets the show label field value.
- *
+ *
*/
public void setShowLabel(boolean value)
{
@@ -677,7 +686,7 @@ public final class TextRecord extends St
}
/**
- *
+ *
* @return the show label field value.
*/
public boolean isShowLabel()
@@ -687,7 +696,7 @@ public final class TextRecord extends St
/**
* Sets the data label placement field value.
- *
+ *
*/
public void setDataLabelPlacement(short value)
{
@@ -695,7 +704,7 @@ public final class TextRecord extends St
}
/**
- *
+ *
* @return the data label placement field value.
*/
public short getDataLabelPlacement()
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/chart/TickRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/chart/TickRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/chart/TickRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/chart/TickRecord.java Sun Dec 22 21:44:45 2019
@@ -23,55 +23,65 @@ import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.HexDump;
import org.apache.poi.util.LittleEndianOutput;
+import org.apache.poi.util.Removal;
/**
* The Tick record defines how tick marks and label positioning/formatting<p>
- *
- * @author Andrew C. Oliver(acoliver at apache.org)
*/
public final class TickRecord extends StandardRecord {
- public final static short sid = 0x101E;
-
+ public static final short sid = 0x101E;
+
private static final BitField autoTextColor = BitFieldFactory.getInstance(0x1);
private static final BitField autoTextBackground = BitFieldFactory.getInstance(0x2);
private static final BitField rotation = BitFieldFactory.getInstance(0x1c);
private static final BitField autorotate = BitFieldFactory.getInstance(0x20);
-
- private byte field_1_majorTickType;
- private byte field_2_minorTickType;
- private byte field_3_labelPosition;
- private byte field_4_background;
- private int field_5_labelColorRgb;
- private int field_6_zero1;
- private int field_7_zero2;
- private int field_8_zero3;
- private int field_9_zero4;
- private short field_10_options;
- private short field_11_tickColor;
- private short field_12_zero5;
-
-
- public TickRecord()
- {
- }
-
- public TickRecord(RecordInputStream in)
- {
-
- field_1_majorTickType = in.readByte();
- field_2_minorTickType = in.readByte();
- field_3_labelPosition = in.readByte();
- field_4_background = in.readByte();
- field_5_labelColorRgb = in.readInt();
- field_6_zero1 = in.readInt();
- field_7_zero2 = in.readInt();
- field_8_zero3 = in.readInt();
- field_9_zero4 = in.readInt();
-
- field_10_options = in.readShort();
- field_11_tickColor = in.readShort();
- field_12_zero5 = in.readShort();
+ private byte field_1_majorTickType;
+ private byte field_2_minorTickType;
+ private byte field_3_labelPosition;
+ private byte field_4_background;
+ private int field_5_labelColorRgb;
+ private int field_6_zero1;
+ private int field_7_zero2;
+ private int field_8_zero3;
+ private int field_9_zero4;
+ private short field_10_options;
+ private short field_11_tickColor;
+ private short field_12_zero5;
+
+
+ public TickRecord() {}
+
+ public TickRecord(TickRecord other) {
+ super(other);
+ field_1_majorTickType = other.field_1_majorTickType;
+ field_2_minorTickType = other.field_2_minorTickType;
+ field_3_labelPosition = other.field_3_labelPosition;
+ field_4_background = other.field_4_background;
+ field_5_labelColorRgb = other.field_5_labelColorRgb;
+ field_6_zero1 = other.field_6_zero1;
+ field_7_zero2 = other.field_7_zero2;
+ field_8_zero3 = other.field_8_zero3;
+ field_9_zero4 = other.field_9_zero4;
+ field_10_options = other.field_10_options;
+ field_11_tickColor = other.field_11_tickColor;
+ field_12_zero5 = other.field_12_zero5;
+ }
+
+ public TickRecord(RecordInputStream in) {
+ field_1_majorTickType = in.readByte();
+ field_2_minorTickType = in.readByte();
+ field_3_labelPosition = in.readByte();
+ field_4_background = in.readByte();
+ field_5_labelColorRgb = in.readInt();
+ field_6_zero1 = in.readInt();
+ field_7_zero2 = in.readInt();
+ field_8_zero3 = in.readInt();
+ field_9_zero4 = in.readInt();
+
+ field_10_options = in.readShort();
+ field_11_tickColor = in.readShort();
+ field_12_zero5 = in.readShort();
}
public String toString()
@@ -82,47 +92,47 @@ public final class TickRecord extends St
buffer.append(" .majorTickType = ")
.append("0x").append(HexDump.toHex( getMajorTickType ()))
.append(" (").append( getMajorTickType() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
+ buffer.append(System.getProperty("line.separator"));
buffer.append(" .minorTickType = ")
.append("0x").append(HexDump.toHex( getMinorTickType ()))
.append(" (").append( getMinorTickType() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
+ buffer.append(System.getProperty("line.separator"));
buffer.append(" .labelPosition = ")
.append("0x").append(HexDump.toHex( getLabelPosition ()))
.append(" (").append( getLabelPosition() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
+ buffer.append(System.getProperty("line.separator"));
buffer.append(" .background = ")
.append("0x").append(HexDump.toHex( getBackground ()))
.append(" (").append( getBackground() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
+ buffer.append(System.getProperty("line.separator"));
buffer.append(" .labelColorRgb = ")
.append("0x").append(HexDump.toHex( getLabelColorRgb ()))
.append(" (").append( getLabelColorRgb() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
+ buffer.append(System.getProperty("line.separator"));
buffer.append(" .zero1 = ")
.append("0x").append(HexDump.toHex( getZero1 ()))
.append(" (").append( getZero1() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
+ buffer.append(System.getProperty("line.separator"));
buffer.append(" .zero2 = ")
.append("0x").append(HexDump.toHex( getZero2 ()))
.append(" (").append( getZero2() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
+ buffer.append(System.getProperty("line.separator"));
buffer.append(" .options = ")
.append("0x").append(HexDump.toHex( getOptions ()))
.append(" (").append( getOptions() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
- buffer.append(" .autoTextColor = ").append(isAutoTextColor()).append('\n');
- buffer.append(" .autoTextBackground = ").append(isAutoTextBackground()).append('\n');
- buffer.append(" .rotation = ").append(getRotation()).append('\n');
- buffer.append(" .autorotate = ").append(isAutorotate()).append('\n');
+ buffer.append(System.getProperty("line.separator"));
+ buffer.append(" .autoTextColor = ").append(isAutoTextColor()).append('\n');
+ buffer.append(" .autoTextBackground = ").append(isAutoTextBackground()).append('\n');
+ buffer.append(" .rotation = ").append(getRotation()).append('\n');
+ buffer.append(" .autorotate = ").append(isAutorotate()).append('\n');
buffer.append(" .tickColor = ")
.append("0x").append(HexDump.toHex( getTickColor ()))
.append(" (").append( getTickColor() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
+ buffer.append(System.getProperty("line.separator"));
buffer.append(" .zero3 = ")
.append("0x").append(HexDump.toHex( getZero3 ()))
.append(" (").append( getZero3() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
+ buffer.append(System.getProperty("line.separator"));
buffer.append("[/TICK]\n");
return buffer.toString();
@@ -152,26 +162,18 @@ public final class TickRecord extends St
return sid;
}
- public Object clone() {
- TickRecord rec = new TickRecord();
-
- rec.field_1_majorTickType = field_1_majorTickType;
- rec.field_2_minorTickType = field_2_minorTickType;
- rec.field_3_labelPosition = field_3_labelPosition;
- rec.field_4_background = field_4_background;
- rec.field_5_labelColorRgb = field_5_labelColorRgb;
- rec.field_6_zero1 = field_6_zero1;
- rec.field_7_zero2 = field_7_zero2;
- rec.field_8_zero3 = field_8_zero3;
- rec.field_9_zero4 = field_9_zero4;
- rec.field_10_options = field_10_options;
- rec.field_11_tickColor = field_11_tickColor;
- rec.field_12_zero5 = field_12_zero5;
- return rec;
+ @Override
+ @SuppressWarnings("squid:S2975")
+ @Deprecated
+ @Removal(version = "5.0.0")
+ public TickRecord clone() {
+ return copy();
}
-
-
+ @Override
+ public TickRecord copy() {
+ return new TickRecord(this);
+ }
/**
* Get the major tick type field for the Tick record.
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/chart/UnitsRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/chart/UnitsRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/chart/UnitsRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/chart/UnitsRecord.java Sun Dec 22 21:44:45 2019
@@ -21,24 +21,25 @@ import org.apache.poi.hssf.record.Record
import org.apache.poi.hssf.record.StandardRecord;
import org.apache.poi.util.HexDump;
import org.apache.poi.util.LittleEndianOutput;
+import org.apache.poi.util.Removal;
/**
* The units record describes units.
*/
public final class UnitsRecord extends StandardRecord {
- public final static short sid = 0x1001;
- private short field_1_units;
+ public static final short sid = 0x1001;
+ private short field_1_units;
- public UnitsRecord()
- {
+ public UnitsRecord() {}
+ public UnitsRecord(UnitsRecord other) {
+ super(other);
+ field_1_units = other.field_1_units;
}
- public UnitsRecord(RecordInputStream in)
- {
- field_1_units = in.readShort();
-
+ public UnitsRecord(RecordInputStream in) {
+ field_1_units = in.readShort();
}
public String toString()
@@ -49,7 +50,7 @@ public final class UnitsRecord extends S
buffer.append(" .units = ")
.append("0x").append(HexDump.toHex( getUnits ()))
.append(" (").append( getUnits() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
+ buffer.append(System.getProperty("line.separator"));
buffer.append("[/UNITS]\n");
return buffer.toString();
@@ -68,15 +69,18 @@ public final class UnitsRecord extends S
return sid;
}
- public Object clone() {
- UnitsRecord rec = new UnitsRecord();
-
- rec.field_1_units = field_1_units;
- return rec;
+ @Override
+ @SuppressWarnings("squid:S2975")
+ @Deprecated
+ @Removal(version = "5.0.0")
+ public UnitsRecord clone() {
+ return copy();
}
-
-
+ @Override
+ public UnitsRecord copy() {
+ return new UnitsRecord(this);
+ }
/**
* Get the units field for the Units record.
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/chart/ValueRangeRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/chart/ValueRangeRecord.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/chart/ValueRangeRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/chart/ValueRangeRecord.java Sun Dec 22 21:44:45 2019
@@ -23,13 +23,14 @@ import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.HexDump;
import org.apache.poi.util.LittleEndianOutput;
+import org.apache.poi.util.Removal;
/**
* The value range record defines the range of the value axis.
*/
public final class ValueRangeRecord extends StandardRecord {
- public final static short sid = 0x101f;
-
+ public static final short sid = 0x101f;
+
private static final BitField automaticMinimum = BitFieldFactory.getInstance(0x0001);
private static final BitField automaticMaximum = BitFieldFactory.getInstance(0x0002);
private static final BitField automaticMajor = BitFieldFactory.getInstance(0x0004);
@@ -39,29 +40,33 @@ public final class ValueRangeRecord exte
private static final BitField valuesInReverse = BitFieldFactory.getInstance(0x0040);
private static final BitField crossCategoryAxisAtMaximum = BitFieldFactory.getInstance(0x0080);
private static final BitField reserved = BitFieldFactory.getInstance(0x0100);
-
- private double field_1_minimumAxisValue;
- private double field_2_maximumAxisValue;
- private double field_3_majorIncrement;
- private double field_4_minorIncrement;
- private double field_5_categoryAxisCross;
- private short field_6_options;
-
-
- public ValueRangeRecord()
- {
-
- }
-
- public ValueRangeRecord(RecordInputStream in)
- {
- field_1_minimumAxisValue = in.readDouble();
- field_2_maximumAxisValue = in.readDouble();
- field_3_majorIncrement = in.readDouble();
- field_4_minorIncrement = in.readDouble();
- field_5_categoryAxisCross = in.readDouble();
- field_6_options = in.readShort();
+ private double field_1_minimumAxisValue;
+ private double field_2_maximumAxisValue;
+ private double field_3_majorIncrement;
+ private double field_4_minorIncrement;
+ private double field_5_categoryAxisCross;
+ private short field_6_options;
+
+ public ValueRangeRecord() {}
+
+ public ValueRangeRecord(ValueRangeRecord other) {
+ super(other);
+ field_1_minimumAxisValue = other.field_1_minimumAxisValue;
+ field_2_maximumAxisValue = other.field_2_maximumAxisValue;
+ field_3_majorIncrement = other.field_3_majorIncrement;
+ field_4_minorIncrement = other.field_4_minorIncrement;
+ field_5_categoryAxisCross = other.field_5_categoryAxisCross;
+ field_6_options = other.field_6_options;
+ }
+
+ public ValueRangeRecord(RecordInputStream in) {
+ field_1_minimumAxisValue = in.readDouble();
+ field_2_maximumAxisValue = in.readDouble();
+ field_3_majorIncrement = in.readDouble();
+ field_4_minorIncrement = in.readDouble();
+ field_5_categoryAxisCross = in.readDouble();
+ field_6_options = in.readShort();
}
public String toString()
@@ -71,32 +76,32 @@ public final class ValueRangeRecord exte
buffer.append("[VALUERANGE]\n");
buffer.append(" .minimumAxisValue = ")
.append(" (").append( getMinimumAxisValue() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
+ buffer.append(System.getProperty("line.separator"));
buffer.append(" .maximumAxisValue = ")
.append(" (").append( getMaximumAxisValue() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
+ buffer.append(System.getProperty("line.separator"));
buffer.append(" .majorIncrement = ")
.append(" (").append( getMajorIncrement() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
+ buffer.append(System.getProperty("line.separator"));
buffer.append(" .minorIncrement = ")
.append(" (").append( getMinorIncrement() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
+ buffer.append(System.getProperty("line.separator"));
buffer.append(" .categoryAxisCross = ")
.append(" (").append( getCategoryAxisCross() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
+ buffer.append(System.getProperty("line.separator"));
buffer.append(" .options = ")
.append("0x").append(HexDump.toHex( getOptions ()))
.append(" (").append( getOptions() ).append(" )");
- buffer.append(System.getProperty("line.separator"));
- buffer.append(" .automaticMinimum = ").append(isAutomaticMinimum()).append('\n');
- buffer.append(" .automaticMaximum = ").append(isAutomaticMaximum()).append('\n');
- buffer.append(" .automaticMajor = ").append(isAutomaticMajor()).append('\n');
- buffer.append(" .automaticMinor = ").append(isAutomaticMinor()).append('\n');
- buffer.append(" .automaticCategoryCrossing = ").append(isAutomaticCategoryCrossing()).append('\n');
- buffer.append(" .logarithmicScale = ").append(isLogarithmicScale()).append('\n');
- buffer.append(" .valuesInReverse = ").append(isValuesInReverse()).append('\n');
- buffer.append(" .crossCategoryAxisAtMaximum = ").append(isCrossCategoryAxisAtMaximum()).append('\n');
- buffer.append(" .reserved = ").append(isReserved()).append('\n');
+ buffer.append(System.getProperty("line.separator"));
+ buffer.append(" .automaticMinimum = ").append(isAutomaticMinimum()).append('\n');
+ buffer.append(" .automaticMaximum = ").append(isAutomaticMaximum()).append('\n');
+ buffer.append(" .automaticMajor = ").append(isAutomaticMajor()).append('\n');
+ buffer.append(" .automaticMinor = ").append(isAutomaticMinor()).append('\n');
+ buffer.append(" .automaticCategoryCrossing = ").append(isAutomaticCategoryCrossing()).append('\n');
+ buffer.append(" .logarithmicScale = ").append(isLogarithmicScale()).append('\n');
+ buffer.append(" .valuesInReverse = ").append(isValuesInReverse()).append('\n');
+ buffer.append(" .crossCategoryAxisAtMaximum = ").append(isCrossCategoryAxisAtMaximum()).append('\n');
+ buffer.append(" .reserved = ").append(isReserved()).append('\n');
buffer.append("[/VALUERANGE]\n");
return buffer.toString();
@@ -120,20 +125,18 @@ public final class ValueRangeRecord exte
return sid;
}
- public Object clone() {
- ValueRangeRecord rec = new ValueRangeRecord();
-
- rec.field_1_minimumAxisValue = field_1_minimumAxisValue;
- rec.field_2_maximumAxisValue = field_2_maximumAxisValue;
- rec.field_3_majorIncrement = field_3_majorIncrement;
- rec.field_4_minorIncrement = field_4_minorIncrement;
- rec.field_5_categoryAxisCross = field_5_categoryAxisCross;
- rec.field_6_options = field_6_options;
- return rec;
+ @Override
+ @SuppressWarnings("squid:S2975")
+ @Deprecated
+ @Removal(version = "5.0.0")
+ public ValueRangeRecord clone() {
+ return copy();
}
-
-
+ @Override
+ public ValueRangeRecord copy() {
+ return new ValueRangeRecord(this);
+ }
/**
* Get the minimum axis value field for the ValueRange record.
Added: poi/trunk/src/java/org/apache/poi/hssf/record/common/ExtRst.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/common/ExtRst.java?rev=1871911&view=auto
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/common/ExtRst.java (added)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/common/ExtRst.java Sun Dec 22 21:44:45 2019
@@ -0,0 +1,261 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hssf.record.common;
+
+import java.util.Arrays;
+import java.util.stream.Stream;
+
+import org.apache.poi.hssf.record.cont.ContinuableRecordOutput;
+import org.apache.poi.util.IOUtils;
+import org.apache.poi.util.Internal;
+import org.apache.poi.util.LittleEndianInput;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
+import org.apache.poi.util.StringUtil;
+
+@Internal
+public class ExtRst implements Comparable<ExtRst> {
+ private static final POILogger _logger = POILogFactory.getLogger(ExtRst.class);
+ //arbitrarily selected; may need to increase
+ private static final int MAX_RECORD_LENGTH = 100_000;
+
+ private short reserved;
+
+ // This is a Phs (see page 881)
+ private short formattingFontIndex;
+ private short formattingOptions;
+
+ // This is a RPHSSub (see page 894)
+ private int numberOfRuns;
+ private String phoneticText;
+
+ // This is an array of PhRuns (see page 881)
+ private PhRun[] phRuns;
+ // Sometimes there's some cruft at the end
+ private byte[] extraData;
+
+ protected ExtRst() {
+ populateEmpty();
+ }
+
+ protected ExtRst(ExtRst other) {
+ reserved = other.reserved;
+ formattingFontIndex = other.formattingFontIndex;
+ formattingOptions = other.formattingOptions;
+ numberOfRuns = other.numberOfRuns;
+ phoneticText = other.phoneticText;
+ phRuns = (other.phRuns == null) ? null : Stream.of(other.phRuns).map(PhRun::new).toArray(PhRun[]::new);
+ }
+
+ protected ExtRst(LittleEndianInput in, int expectedLength) {
+ reserved = in.readShort();
+
+ // Old style detection (Reserved = 0xFF)
+ if(reserved == -1) {
+ populateEmpty();
+ return;
+ }
+
+ // Spot corrupt records
+ if(reserved != 1) {
+ _logger.log(POILogger.WARN, "Warning - ExtRst has wrong magic marker, expecting 1 but found " + reserved + " - ignoring");
+ // Grab all the remaining data, and ignore it
+ for(int i=0; i<expectedLength-2; i++) {
+ in.readByte();
+ }
+ // And make us be empty
+ populateEmpty();
+ return;
+ }
+
+ // Carry on reading in as normal
+ short stringDataSize = in.readShort();
+
+ formattingFontIndex = in.readShort();
+ formattingOptions = in.readShort();
+
+ // RPHSSub
+ numberOfRuns = in.readUShort();
+ short length1 = in.readShort();
+ // No really. Someone clearly forgot to read
+ // the docs on their datastructure...
+ short length2 = in.readShort();
+ // And sometimes they write out garbage :(
+ if(length1 == 0 && length2 > 0) {
+ length2 = 0;
+ }
+ if(length1 != length2) {
+ throw new IllegalStateException(
+ "The two length fields of the Phonetic Text don't agree! " +
+ length1 + " vs " + length2
+ );
+ }
+ phoneticText = StringUtil.readUnicodeLE(in, length1);
+
+ int runData = stringDataSize - 4 - 6 - (2*phoneticText.length());
+ int numRuns = (runData / 6);
+ phRuns = new PhRun[numRuns];
+ for(int i=0; i<phRuns.length; i++) {
+ phRuns[i] = new PhRun(in);
+ }
+
+ int extraDataLength = runData - (numRuns*6);
+ if(extraDataLength < 0) {
+ _logger.log( POILogger.WARN, "Warning - ExtRst overran by " + (0-extraDataLength) + " bytes");
+ extraDataLength = 0;
+ }
+ extraData = IOUtils.safelyAllocate(extraDataLength, MAX_RECORD_LENGTH);
+ for(int i=0; i<extraData.length; i++) {
+ extraData[i] = in.readByte();
+ }
+ }
+
+ private void populateEmpty() {
+ reserved = 1;
+ phoneticText = "";
+ phRuns = new PhRun[0];
+ extraData = new byte[0];
+ }
+
+ /**
+ * Returns our size, excluding our
+ * 4 byte header
+ */
+ protected int getDataSize() {
+ return 4 + 6 + (2*phoneticText.length()) +
+ (6*phRuns.length) + extraData.length;
+ }
+ protected void serialize(ContinuableRecordOutput out) {
+ int dataSize = getDataSize();
+
+ out.writeContinueIfRequired(8);
+ out.writeShort(reserved);
+ out.writeShort(dataSize);
+ out.writeShort(formattingFontIndex);
+ out.writeShort(formattingOptions);
+
+ out.writeContinueIfRequired(6);
+ out.writeShort(numberOfRuns);
+ out.writeShort(phoneticText.length());
+ out.writeShort(phoneticText.length());
+
+ out.writeContinueIfRequired(phoneticText.length()*2);
+ StringUtil.putUnicodeLE(phoneticText, out);
+
+ for(int i=0; i<phRuns.length; i++) {
+ phRuns[i].serialize(out);
+ }
+
+ out.write(extraData);
+ }
+
+ public boolean equals(Object obj) {
+ if(! (obj instanceof ExtRst)) {
+ return false;
+ }
+ ExtRst other = (ExtRst)obj;
+ return (compareTo(other) == 0);
+ }
+ public int compareTo(ExtRst o) {
+ int result;
+
+ result = reserved - o.reserved;
+ if (result != 0) {
+ return result;
+ }
+ result = formattingFontIndex - o.formattingFontIndex;
+ if (result != 0) {
+ return result;
+ }
+ result = formattingOptions - o.formattingOptions;
+ if (result != 0) {
+ return result;
+ }
+ result = numberOfRuns - o.numberOfRuns;
+ if (result != 0) {
+ return result;
+ }
+
+ result = phoneticText.compareTo(o.phoneticText);
+ if (result != 0) {
+ return result;
+ }
+
+ result = phRuns.length - o.phRuns.length;
+ if (result != 0) {
+ return result;
+ }
+ for(int i=0; i<phRuns.length; i++) {
+ result = phRuns[i].phoneticTextFirstCharacterOffset - o.phRuns[i].phoneticTextFirstCharacterOffset;
+ if (result != 0) {
+ return result;
+ }
+ result = phRuns[i].realTextFirstCharacterOffset - o.phRuns[i].realTextFirstCharacterOffset;
+ if (result != 0) {
+ return result;
+ }
+ result = phRuns[i].realTextLength - o.phRuns[i].realTextLength;
+ if (result != 0) {
+ return result;
+ }
+ }
+
+ result = Arrays.hashCode(extraData)-Arrays.hashCode(o.extraData);
+
+ return result;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = reserved;
+ hash = 31*hash+formattingFontIndex;
+ hash = 31*hash+formattingOptions;
+ hash = 31*hash+numberOfRuns;
+ hash = 31*hash+phoneticText.hashCode();
+
+ if (phRuns != null) {
+ for (PhRun ph : phRuns) {
+ hash = 31*hash+ph.phoneticTextFirstCharacterOffset;
+ hash = 31*hash+ph.realTextFirstCharacterOffset;
+ hash = 31*hash+ph.realTextLength;
+ }
+ }
+ return hash;
+ }
+
+ public ExtRst copy() {
+ return new ExtRst(this);
+ }
+
+ public short getFormattingFontIndex() {
+ return formattingFontIndex;
+ }
+ public short getFormattingOptions() {
+ return formattingOptions;
+ }
+ public int getNumberOfRuns() {
+ return numberOfRuns;
+ }
+ public String getPhoneticText() {
+ return phoneticText;
+ }
+ public PhRun[] getPhRuns() {
+ return phRuns;
+ }
+
+}
Propchange: poi/trunk/src/java/org/apache/poi/hssf/record/common/ExtRst.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/common/ExtendedColor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/common/ExtendedColor.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/common/ExtendedColor.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/common/ExtendedColor.java Sun Dec 22 21:44:45 2019
@@ -17,9 +17,11 @@
package org.apache.poi.hssf.record.common;
+import org.apache.poi.common.Duplicatable;
import org.apache.poi.util.HexDump;
import org.apache.poi.util.LittleEndianInput;
import org.apache.poi.util.LittleEndianOutput;
+import org.apache.poi.util.Removal;
/**
@@ -27,16 +29,16 @@ import org.apache.poi.util.LittleEndianO
* <P>
* The HSSF file format normally stores Color information in the
* Palette (see PaletteRecord), but for a few cases (eg Conditional
- * Formatting, Sheet Extensions), this XSSF-style color record
+ * Formatting, Sheet Extensions), this XSSF-style color record
* can be used.
*/
-public final class ExtendedColor implements Cloneable {
+public final class ExtendedColor implements Duplicatable {
public static final int TYPE_AUTO = 0;
public static final int TYPE_INDEXED = 1;
public static final int TYPE_RGB = 2;
public static final int TYPE_THEMED = 3;
public static final int TYPE_UNSET = 4;
-
+
public static final int THEME_DARK_1 = 0;
public static final int THEME_LIGHT_1 = 1;
public static final int THEME_DARK_2 = 2;
@@ -50,23 +52,33 @@ public final class ExtendedColor impleme
public static final int THEME_HYPERLINK = 10;
// This one is SheetEx only, not allowed in CFs
public static final int THEME_FOLLOWED_HYPERLINK = 11;
-
+
private int type;
-
+
// Type = Indexed
private int colorIndex;
// Type = RGB
private byte[] rgba;
// Type = Theme
private int themeIndex;
-
+
private double tint;
-
+
public ExtendedColor() {
- this.type = TYPE_INDEXED;
- this.colorIndex = 0;
- this.tint = 0d;
+ type = TYPE_INDEXED;
+ colorIndex = 0;
+ tint = 0d;
}
+
+ public ExtendedColor(ExtendedColor other) {
+ type = other.type;
+ tint = other.tint;
+ colorIndex = other.colorIndex;
+ rgba = (other.rgba == null) ? null : other.rgba.clone();
+ themeIndex = other.themeIndex;
+ }
+
+
public ExtendedColor(LittleEndianInput in) {
type = in.readInt();
if (type == TYPE_INDEXED) {
@@ -99,7 +111,7 @@ public final class ExtendedColor impleme
public void setColorIndex(int colorIndex) {
this.colorIndex = colorIndex;
}
-
+
/**
* @return Red Green Blue Alpha, if type is {@link #TYPE_RGB}
*/
@@ -109,7 +121,7 @@ public final class ExtendedColor impleme
public void setRGBA(byte[] rgba) {
this.rgba = (rgba == null) ? null : rgba.clone();
}
-
+
/**
* @return Theme color type index, eg {@link #THEME_DARK_1}, if type is {@link #TYPE_THEMED}
*/
@@ -134,7 +146,7 @@ public final class ExtendedColor impleme
}
this.tint = tint;
}
-
+
public String toString() {
StringBuilder buffer = new StringBuilder();
buffer.append(" [Extended Color]\n");
@@ -146,23 +158,20 @@ public final class ExtendedColor impleme
buffer.append(" [/Extended Color]\n");
return buffer.toString();
}
-
+
@Override
- public ExtendedColor clone() {
- ExtendedColor exc = new ExtendedColor();
- exc.type = type;
- exc.tint = tint;
- if (type == TYPE_INDEXED) {
- exc.colorIndex = colorIndex;
- } else if (type == TYPE_RGB) {
- exc.rgba = new byte[4];
- System.arraycopy(rgba, 0, exc.rgba, 0, 4);
- } else if (type == TYPE_THEMED) {
- exc.themeIndex = themeIndex;
- }
- return exc;
+ @SuppressWarnings("squid:S2975")
+ @Deprecated
+ @Removal(version = "5.0.0")
+ public ExtendedColor clone() {
+ return copy();
}
-
+
+ @Override
+ public ExtendedColor copy() {
+ return new ExtendedColor(this);
+ }
+
public int getDataLength() {
return 4+4+8;
}
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/common/FeatFormulaErr2.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/common/FeatFormulaErr2.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/common/FeatFormulaErr2.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/common/FeatFormulaErr2.java Sun Dec 22 21:44:45 2019
@@ -18,8 +18,6 @@
package org.apache.poi.hssf.record.common;
import org.apache.poi.hssf.record.FeatRecord;
-//import org.apache.poi.hssf.record.Feat11Record;
-//import org.apache.poi.hssf.record.Feat12Record;
import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
@@ -28,8 +26,8 @@ import org.apache.poi.util.LittleEndianO
/**
* Title: FeatFormulaErr2 (Formula Evaluation Shared Feature) common record part
* <P>
- * This record part specifies Formula Evaluation & Error Ignoring data
- * for a sheet, stored as part of a Shared Feature. It can be found in
+ * This record part specifies Formula Evaluation & Error Ignoring data
+ * for a sheet, stored as part of a Shared Feature. It can be found in
* records such as {@link FeatRecord}.
* For the full meanings of the flags, see pages 669 and 670
* of the Excel binary file format documentation and/or
@@ -44,15 +42,19 @@ public final class FeatFormulaErr2 imple
private static final BitField CHECK_DATETIME_FORMATS = BitFieldFactory.getInstance(0x20);
private static final BitField CHECK_UNPROTECTED_FORMULAS = BitFieldFactory.getInstance(0x40);
private static final BitField PERFORM_DATA_VALIDATION = BitFieldFactory.getInstance(0x80);
-
+
/**
* What errors we should ignore
*/
private int errorCheck;
-
-
+
+
public FeatFormulaErr2() {}
+ public FeatFormulaErr2(FeatFormulaErr2 other) {
+ errorCheck = other.errorCheck;
+ }
+
public FeatFormulaErr2(RecordInputStream in) {
errorCheck = in.readInt();
}
@@ -60,14 +62,14 @@ public final class FeatFormulaErr2 imple
public String toString() {
StringBuilder buffer = new StringBuilder();
buffer.append(" [FEATURE FORMULA ERRORS]\n");
- buffer.append(" checkCalculationErrors = ");
- buffer.append(" checkEmptyCellRef = ");
- buffer.append(" checkNumbersAsText = ");
- buffer.append(" checkInconsistentRanges = ");
- buffer.append(" checkInconsistentFormulas = ");
- buffer.append(" checkDateTimeFormats = ");
- buffer.append(" checkUnprotectedFormulas = ");
- buffer.append(" performDataValidation = ");
+ buffer.append(" checkCalculationErrors = ");
+ buffer.append(" checkEmptyCellRef = ");
+ buffer.append(" checkNumbersAsText = ");
+ buffer.append(" checkInconsistentRanges = ");
+ buffer.append(" checkInconsistentFormulas = ");
+ buffer.append(" checkDateTimeFormats = ");
+ buffer.append(" checkUnprotectedFormulas = ");
+ buffer.append(" performDataValidation = ");
buffer.append(" [/FEATURE FORMULA ERRORS]\n");
return buffer.toString();
}
@@ -79,7 +81,7 @@ public final class FeatFormulaErr2 imple
public int getDataSize() {
return 4;
}
-
+
public int _getRawErrorCheckValue() {
return errorCheck;
}
@@ -139,4 +141,9 @@ public final class FeatFormulaErr2 imple
public void setPerformDataValidation(boolean performDataValidation) {
errorCheck = PERFORM_DATA_VALIDATION.setBoolean(errorCheck, performDataValidation);
}
+
+ @Override
+ public FeatFormulaErr2 copy() {
+ return new FeatFormulaErr2(this);
+ }
}
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/common/FeatProtection.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/common/FeatProtection.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/common/FeatProtection.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/common/FeatProtection.java Sun Dec 22 21:44:45 2019
@@ -20,8 +20,6 @@ package org.apache.poi.hssf.record.commo
import org.apache.poi.hssf.record.FeatRecord;
import org.apache.poi.hssf.record.PasswordRecord;
import org.apache.poi.hssf.record.PasswordRev4Record;
-//import org.apache.poi.hssf.record.Feat11Record;
-//import org.apache.poi.hssf.record.Feat12Record;
import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.util.LittleEndianOutput;
import org.apache.poi.util.StringUtil;
@@ -39,35 +37,42 @@ public final class FeatProtection implem
public static final long HAS_SELF_RELATIVE_SECURITY_FEATURE = 1;
private int fSD;
-
+
/**
* 0 means no password. Otherwise indicates the
- * password verifier algorithm (same kind as
+ * password verifier algorithm (same kind as
* {@link PasswordRecord} and
* {@link PasswordRev4Record})
*/
private int passwordVerifier;
-
+
private String title;
private byte[] securityDescriptor;
-
+
public FeatProtection() {
securityDescriptor = new byte[0];
}
+ public FeatProtection(FeatProtection other) {
+ fSD = other.fSD;
+ passwordVerifier = other.passwordVerifier;
+ title = other.title;
+ securityDescriptor = (other.securityDescriptor == null) ? null : other.securityDescriptor.clone();
+ }
+
public FeatProtection(RecordInputStream in) {
fSD = in.readInt();
passwordVerifier = in.readInt();
-
+
title = StringUtil.readUnicodeString(in);
-
+
securityDescriptor = in.readRemainder();
}
public String toString() {
StringBuilder buffer = new StringBuilder();
buffer.append(" [FEATURE PROTECTION]\n");
- buffer.append(" Self Relative = " + fSD);
+ buffer.append(" Self Relative = " + fSD);
buffer.append(" Password Verifier = " + passwordVerifier);
buffer.append(" Title = " + title);
buffer.append(" Security Descriptor Size = " + securityDescriptor.length);
@@ -103,4 +108,9 @@ public final class FeatProtection implem
public int getFSD() {
return fSD;
}
+
+ @Override
+ public FeatProtection copy() {
+ return new FeatProtection(this);
+ }
}
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/common/FeatSmartTag.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/common/FeatSmartTag.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/common/FeatSmartTag.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/common/FeatSmartTag.java Sun Dec 22 21:44:45 2019
@@ -18,11 +18,12 @@
package org.apache.poi.hssf.record.common;
import org.apache.poi.hssf.record.FeatRecord;
-//import org.apache.poi.hssf.record.Feat11Record;
-//import org.apache.poi.hssf.record.Feat12Record;
import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.util.LittleEndianOutput;
+//import org.apache.poi.hssf.record.Feat11Record;
+//import org.apache.poi.hssf.record.Feat12Record;
+
/**
* Title: FeatSmartTag (Smart Tag Shared Feature) common record part
* <P>
@@ -36,11 +37,15 @@ import org.apache.poi.util.LittleEndianO
public final class FeatSmartTag implements SharedFeature {
// TODO - process
private byte[] data;
-
+
public FeatSmartTag() {
data = new byte[0];
}
+ public FeatSmartTag(FeatSmartTag other) {
+ data = (other.data == null) ? null : other.data.clone();
+ }
+
public FeatSmartTag(RecordInputStream in) {
data = in.readRemainder();
}
@@ -59,4 +64,9 @@ public final class FeatSmartTag implemen
public void serialize(LittleEndianOutput out) {
out.write(data);
}
+
+ @Override
+ public FeatSmartTag copy() {
+ return new FeatSmartTag(this);
+ }
}
Added: poi/trunk/src/java/org/apache/poi/hssf/record/common/FormatRun.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/common/FormatRun.java?rev=1871911&view=auto
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/common/FormatRun.java (added)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/common/FormatRun.java Sun Dec 22 21:44:45 2019
@@ -0,0 +1,84 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hssf.record.common;
+
+import org.apache.poi.util.Internal;
+import org.apache.poi.util.LittleEndianInput;
+import org.apache.poi.util.LittleEndianOutput;
+
+@Internal
+public class FormatRun implements Comparable<FormatRun> {
+ final short _character;
+ short _fontIndex;
+
+ public FormatRun(short character, short fontIndex) {
+ this._character = character;
+ this._fontIndex = fontIndex;
+ }
+
+ public FormatRun(FormatRun other) {
+ _character = other._character;
+ _fontIndex = other._fontIndex;
+ }
+
+ public FormatRun(LittleEndianInput in) {
+ this(in.readShort(), in.readShort());
+ }
+
+ public short getCharacterPos() {
+ return _character;
+ }
+
+ public short getFontIndex() {
+ return _fontIndex;
+ }
+
+ public boolean equals(Object o) {
+ if (!(o instanceof FormatRun)) {
+ return false;
+ }
+ FormatRun other = (FormatRun) o;
+
+ return _character == other._character && _fontIndex == other._fontIndex;
+ }
+
+ public int compareTo(FormatRun r) {
+ if (_character == r._character && _fontIndex == r._fontIndex) {
+ return 0;
+ }
+ if (_character == r._character) {
+ return _fontIndex - r._fontIndex;
+ }
+ return _character - r._character;
+ }
+
+ @Override
+ public int hashCode() {
+ assert false : "hashCode not designed";
+ return 42; // any arbitrary constant will do
+ }
+
+ public String toString() {
+ return "character=" + _character + ",fontIndex=" + _fontIndex;
+ }
+
+ public void serialize(LittleEndianOutput out) {
+ out.writeShort(_character);
+ out.writeShort(_fontIndex);
+ }
+}
Propchange: poi/trunk/src/java/org/apache/poi/hssf/record/common/FormatRun.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/common/FtrHeader.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/common/FtrHeader.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/common/FtrHeader.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/common/FtrHeader.java Sun Dec 22 21:44:45 2019
@@ -17,18 +17,20 @@
package org.apache.poi.hssf.record.common;
+import org.apache.poi.common.Duplicatable;
import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.LittleEndianOutput;
+import org.apache.poi.util.Removal;
/**
* Title: FtrHeader (Future Record Header) common record part
* <P>
* This record part specifies a header for a Ftr (Future)
* style record, which includes extra attributes above and
- * beyond those of a traditional record.
+ * beyond those of a traditional record.
*/
-public final class FtrHeader implements Cloneable {
+public final class FtrHeader implements Duplicatable {
/** This MUST match the type on the containing record */
private short recordType;
/** This is a FrtFlags */
@@ -40,6 +42,12 @@ public final class FtrHeader implements
associatedRange = new CellRangeAddress(0, 0, 0, 0);
}
+ public FtrHeader(FtrHeader other) {
+ recordType = other.recordType;
+ grbitFrt = other.grbitFrt;
+ associatedRange = other.associatedRange.copy();
+ }
+
public FtrHeader(RecordInputStream in) {
recordType = in.readShort();
grbitFrt = in.readShort();
@@ -87,11 +95,15 @@ public final class FtrHeader implements
this.associatedRange = associatedRange;
}
- public Object clone() {
- FtrHeader result = new FtrHeader();
- result.recordType = recordType;
- result.grbitFrt = grbitFrt;
- result.associatedRange = associatedRange.copy();
- return result;
+ @Override
+ @SuppressWarnings("squid:S2975")
+ @Deprecated
+ @Removal(version = "5.0.0")
+ public FtrHeader clone() {
+ return copy();
+ }
+
+ public FtrHeader copy() {
+ return new FtrHeader(this);
}
}
\ No newline at end of file
Added: poi/trunk/src/java/org/apache/poi/hssf/record/common/PhRun.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/common/PhRun.java?rev=1871911&view=auto
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/common/PhRun.java (added)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/common/PhRun.java Sun Dec 22 21:44:45 2019
@@ -0,0 +1,55 @@
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hssf.record.common;
+
+import org.apache.poi.hssf.record.cont.ContinuableRecordOutput;
+import org.apache.poi.util.Internal;
+import org.apache.poi.util.LittleEndianInput;
+
+@Internal
+public class PhRun {
+ final int phoneticTextFirstCharacterOffset;
+ final int realTextFirstCharacterOffset;
+ final int realTextLength;
+
+ public PhRun(PhRun other) {
+ phoneticTextFirstCharacterOffset = other.phoneticTextFirstCharacterOffset;
+ realTextFirstCharacterOffset = other.realTextFirstCharacterOffset;
+ realTextLength = other.realTextLength;
+ }
+
+ public PhRun(int phoneticTextFirstCharacterOffset,
+ int realTextFirstCharacterOffset, int realTextLength) {
+ this.phoneticTextFirstCharacterOffset = phoneticTextFirstCharacterOffset;
+ this.realTextFirstCharacterOffset = realTextFirstCharacterOffset;
+ this.realTextLength = realTextLength;
+ }
+
+ PhRun(LittleEndianInput in) {
+ phoneticTextFirstCharacterOffset = in.readUShort();
+ realTextFirstCharacterOffset = in.readUShort();
+ realTextLength = in.readUShort();
+ }
+
+ void serialize(ContinuableRecordOutput out) {
+ out.writeContinueIfRequired(6);
+ out.writeShort(phoneticTextFirstCharacterOffset);
+ out.writeShort(realTextFirstCharacterOffset);
+ out.writeShort(realTextLength);
+ }
+}
Propchange: poi/trunk/src/java/org/apache/poi/hssf/record/common/PhRun.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: poi/trunk/src/java/org/apache/poi/hssf/record/common/SharedFeature.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/common/SharedFeature.java?rev=1871911&r1=1871910&r2=1871911&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/common/SharedFeature.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/common/SharedFeature.java Sun Dec 22 21:44:45 2019
@@ -23,7 +23,8 @@ import org.apache.poi.util.LittleEndianO
* Common Interface for all Shared Features
*/
public interface SharedFeature {
- public String toString();
- public void serialize(LittleEndianOutput out);
- public int getDataSize();
+ String toString();
+ void serialize(LittleEndianOutput out);
+ int getDataSize();
+ SharedFeature copy();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org