From 940d0e3efc99c5aeba43a7a523abb9a918210bad Mon Sep 17 00:00:00 2001 From: Sergey Vladimirov Date: Wed, 31 Aug 2011 13:14:09 +0000 Subject: [PATCH] replace getInstance() / getOptions() with getShapeType for EscherSpRecord replace getOptions() with getInstance() for other cases git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1163615 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/ddf/AbstractEscherOptRecord.java | 7 +++-- .../org/apache/poi/ddf/EscherBSERecord.java | 3 ++- .../org/apache/poi/ddf/EscherBitmapBlip.java | 3 ++- .../org/apache/poi/ddf/EscherBlipRecord.java | 3 ++- .../apache/poi/ddf/EscherBlipWMFRecord.java | 3 ++- .../poi/ddf/EscherChildAnchorRecord.java | 3 ++- .../poi/ddf/EscherClientAnchorRecord.java | 3 ++- .../poi/ddf/EscherClientDataRecord.java | 3 ++- .../apache/poi/ddf/EscherContainerRecord.java | 3 ++- .../org/apache/poi/ddf/EscherDgRecord.java | 3 ++- .../org/apache/poi/ddf/EscherDggRecord.java | 3 ++- .../apache/poi/ddf/EscherMetafileBlip.java | 3 ++- .../org/apache/poi/ddf/EscherPictBlip.java | 3 ++- .../org/apache/poi/ddf/EscherSpRecord.java | 26 ++++++++++++++++++- .../org/apache/poi/ddf/EscherSpgrRecord.java | 3 ++- .../poi/ddf/EscherSplitMenuColorsRecord.java | 3 ++- .../apache/poi/ddf/EscherTextboxRecord.java | 3 ++- .../apache/poi/ddf/UnknownEscherRecord.java | 3 ++- .../poi/hssf/record/EscherAggregate.java | 2 +- .../src/org/apache/poi/hslf/model/Shape.java | 5 ++-- .../apache/poi/hslf/model/ShapeFactory.java | 2 +- 21 files changed, 67 insertions(+), 23 deletions(-) diff --git a/src/java/org/apache/poi/ddf/AbstractEscherOptRecord.java b/src/java/org/apache/poi/ddf/AbstractEscherOptRecord.java index 840ccc9a10..2b97b2885f 100644 --- a/src/java/org/apache/poi/ddf/AbstractEscherOptRecord.java +++ b/src/java/org/apache/poi/ddf/AbstractEscherOptRecord.java @@ -152,8 +152,11 @@ public abstract class AbstractEscherOptRecord extends EscherRecord stringBuilder.append( " isContainer: " ); stringBuilder.append( isContainerRecord() ); stringBuilder.append( nl ); - stringBuilder.append( " options: 0x" ); - stringBuilder.append( HexDump.toHex( getOptions() ) ); + stringBuilder.append( " version: 0x" ); + stringBuilder.append( HexDump.toHex( getVersion() ) ); + stringBuilder.append( nl ); + stringBuilder.append( " instance: 0x" ); + stringBuilder.append( HexDump.toHex( getInstance() ) ); stringBuilder.append( nl ); stringBuilder.append( " recordId: 0x" ); stringBuilder.append( HexDump.toHex( getRecordId() ) ); diff --git a/src/java/org/apache/poi/ddf/EscherBSERecord.java b/src/java/org/apache/poi/ddf/EscherBSERecord.java index a99c11fd5a..78420683a2 100644 --- a/src/java/org/apache/poi/ddf/EscherBSERecord.java +++ b/src/java/org/apache/poi/ddf/EscherBSERecord.java @@ -313,7 +313,8 @@ public final class EscherBSERecord extends EscherRecord { String extraData = _remainingData == null ? null : HexDump.toHex(_remainingData, 32); return getClass().getName() + ":" + '\n' + " RecordId: 0x" + HexDump.toHex( RECORD_ID ) + '\n' + - " Options: 0x" + HexDump.toHex( getOptions() ) + '\n' + + " Version: 0x" + HexDump.toHex( getVersion() ) + '\n' + + " Instance: 0x" + HexDump.toHex( getInstance() ) + '\n' + " BlipTypeWin32: " + field_1_blipTypeWin32 + '\n' + " BlipTypeMacOS: " + field_2_blipTypeMacOS + '\n' + " SUID: " + (field_3_uid == null ? "" : HexDump.toHex(field_3_uid)) + '\n' + diff --git a/src/java/org/apache/poi/ddf/EscherBitmapBlip.java b/src/java/org/apache/poi/ddf/EscherBitmapBlip.java index 57cdb3023a..bec7635ebf 100644 --- a/src/java/org/apache/poi/ddf/EscherBitmapBlip.java +++ b/src/java/org/apache/poi/ddf/EscherBitmapBlip.java @@ -108,7 +108,8 @@ public class EscherBitmapBlip extends EscherBlipRecord { } return getClass().getName() + ":" + nl + " RecordId: 0x" + HexDump.toHex( getRecordId() ) + nl + - " Options: 0x" + HexDump.toHex( getOptions() ) + nl + + " Version: 0x" + HexDump.toHex( getVersion() ) + nl + + " Instance: 0x" + HexDump.toHex( getInstance() ) + nl + " UID: 0x" + HexDump.toHex( field_1_UID ) + nl + " Marker: 0x" + HexDump.toHex( field_2_marker ) + nl + " Extra Data:" + nl + extraData; diff --git a/src/java/org/apache/poi/ddf/EscherBlipRecord.java b/src/java/org/apache/poi/ddf/EscherBlipRecord.java index 48c0c2b292..f10781f602 100644 --- a/src/java/org/apache/poi/ddf/EscherBlipRecord.java +++ b/src/java/org/apache/poi/ddf/EscherBlipRecord.java @@ -77,7 +77,8 @@ public class EscherBlipRecord extends EscherRecord { // TODO - instantiable supe String extraData = HexDump.toHex(field_pictureData, 32); return getClass().getName() + ":" + '\n' + " RecordId: 0x" + HexDump.toHex( getRecordId() ) + '\n' + - " Options: 0x" + HexDump.toHex( getOptions() ) + '\n' + + " Version: 0x" + HexDump.toHex( getVersion() ) + '\n' + + " Instance: 0x" + HexDump.toHex( getInstance() ) + '\n' + " Extra Data:" + '\n' + extraData; } } diff --git a/src/java/org/apache/poi/ddf/EscherBlipWMFRecord.java b/src/java/org/apache/poi/ddf/EscherBlipWMFRecord.java index f544dbe90c..7881754af5 100644 --- a/src/java/org/apache/poi/ddf/EscherBlipWMFRecord.java +++ b/src/java/org/apache/poi/ddf/EscherBlipWMFRecord.java @@ -334,7 +334,8 @@ public class EscherBlipWMFRecord } return getClass().getName() + ":" + nl + " RecordId: 0x" + HexDump.toHex( getRecordId() ) + nl + - " Options: 0x" + HexDump.toHex( getOptions() ) + nl + + " Version: 0x" + HexDump.toHex( getVersion() ) + nl + + " Instance: 0x" + HexDump.toHex( getInstance() ) + nl + " Secondary UID: " + HexDump.toHex( field_1_secondaryUID ) + nl + " CacheOfSize: " + field_2_cacheOfSize + nl + " BoundaryTop: " + field_3_boundaryTop + nl + diff --git a/src/java/org/apache/poi/ddf/EscherChildAnchorRecord.java b/src/java/org/apache/poi/ddf/EscherChildAnchorRecord.java index 15f729298e..00c61c6e8e 100644 --- a/src/java/org/apache/poi/ddf/EscherChildAnchorRecord.java +++ b/src/java/org/apache/poi/ddf/EscherChildAnchorRecord.java @@ -88,7 +88,8 @@ public class EscherChildAnchorRecord return getClass().getName() + ":" + nl + " RecordId: 0x" + HexDump.toHex(RECORD_ID) + nl + - " Options: 0x" + HexDump.toHex(getOptions()) + nl + + " Version: 0x" + HexDump.toHex(getVersion()) + nl + + " Instance: 0x" + HexDump.toHex(getInstance()) + nl + " X1: " + field_1_dx1 + nl + " Y1: " + field_2_dy1 + nl + " X2: " + field_3_dx2 + nl + diff --git a/src/java/org/apache/poi/ddf/EscherClientAnchorRecord.java b/src/java/org/apache/poi/ddf/EscherClientAnchorRecord.java index 4f96247329..f79569ac6c 100644 --- a/src/java/org/apache/poi/ddf/EscherClientAnchorRecord.java +++ b/src/java/org/apache/poi/ddf/EscherClientAnchorRecord.java @@ -145,7 +145,8 @@ public class EscherClientAnchorRecord } return getClass().getName() + ":" + nl + " RecordId: 0x" + HexDump.toHex(RECORD_ID) + nl + - " Options: 0x" + HexDump.toHex(getOptions()) + nl + + " Version: 0x" + HexDump.toHex(getVersion()) + nl + + " Instance: 0x" + HexDump.toHex(getInstance()) + nl + " Flag: " + field_1_flag + nl + " Col1: " + field_2_col1 + nl + " DX1: " + field_3_dx1 + nl + diff --git a/src/java/org/apache/poi/ddf/EscherClientDataRecord.java b/src/java/org/apache/poi/ddf/EscherClientDataRecord.java index 7dc9627122..a94a022f0a 100644 --- a/src/java/org/apache/poi/ddf/EscherClientDataRecord.java +++ b/src/java/org/apache/poi/ddf/EscherClientDataRecord.java @@ -92,7 +92,8 @@ public class EscherClientDataRecord } return getClass().getName() + ":" + nl + " RecordId: 0x" + HexDump.toHex(RECORD_ID) + nl + - " Options: 0x" + HexDump.toHex(getOptions()) + nl + + " Version: 0x" + HexDump.toHex(getVersion()) + nl + + " Instance: 0x" + HexDump.toHex(getInstance()) + nl + " Extra Data:" + nl + extraData; diff --git a/src/java/org/apache/poi/ddf/EscherContainerRecord.java b/src/java/org/apache/poi/ddf/EscherContainerRecord.java index 4aa9567a2a..70232eb1d8 100644 --- a/src/java/org/apache/poi/ddf/EscherContainerRecord.java +++ b/src/java/org/apache/poi/ddf/EscherContainerRecord.java @@ -248,7 +248,8 @@ public final class EscherContainerRecord extends EscherRecord { return getClass().getName() + " (" + getRecordName() + "):" + nl + " isContainer: " + isContainerRecord() + nl - + " options: 0x" + HexDump.toHex( getOptions() ) + nl + + " version: 0x" + HexDump.toHex( getVersion() ) + nl + + " instance: 0x" + HexDump.toHex( getInstance() ) + nl + " recordId: 0x" + HexDump.toHex( getRecordId() ) + nl + " numchildren: " + _childRecords.size() + nl + children.toString(); diff --git a/src/java/org/apache/poi/ddf/EscherDgRecord.java b/src/java/org/apache/poi/ddf/EscherDgRecord.java index a96bffa861..2f251f17d1 100644 --- a/src/java/org/apache/poi/ddf/EscherDgRecord.java +++ b/src/java/org/apache/poi/ddf/EscherDgRecord.java @@ -88,7 +88,8 @@ public class EscherDgRecord public String toString() { return getClass().getName() + ":" + '\n' + " RecordId: 0x" + HexDump.toHex(RECORD_ID) + '\n' + - " Options: 0x" + HexDump.toHex(getOptions()) + '\n' + + " Version: 0x" + HexDump.toHex(getVersion()) + '\n' + + " Instance: 0x" + HexDump.toHex(getInstance()) + '\n' + " NumShapes: " + field_1_numShapes + '\n' + " LastMSOSPID: " + field_2_lastMSOSPID + '\n'; diff --git a/src/java/org/apache/poi/ddf/EscherDggRecord.java b/src/java/org/apache/poi/ddf/EscherDggRecord.java index bdcf5ad068..c5e4551d4d 100644 --- a/src/java/org/apache/poi/ddf/EscherDggRecord.java +++ b/src/java/org/apache/poi/ddf/EscherDggRecord.java @@ -132,7 +132,8 @@ public final class EscherDggRecord extends EscherRecord { } return getClass().getName() + ":" + '\n' + " RecordId: 0x" + HexDump.toHex(RECORD_ID) + '\n' + - " Options: 0x" + HexDump.toHex(getOptions()) + '\n' + + " Version: 0x" + HexDump.toHex(getVersion()) + '\n' + + " Instance: 0x" + HexDump.toHex(getInstance()) + '\n' + " ShapeIdMax: " + field_1_shapeIdMax + '\n' + " NumIdClusters: " + getNumIdClusters() + '\n' + " NumShapesSaved: " + field_3_numShapesSaved + '\n' + diff --git a/src/java/org/apache/poi/ddf/EscherMetafileBlip.java b/src/java/org/apache/poi/ddf/EscherMetafileBlip.java index 9989951f82..d9a1347615 100644 --- a/src/java/org/apache/poi/ddf/EscherMetafileBlip.java +++ b/src/java/org/apache/poi/ddf/EscherMetafileBlip.java @@ -247,7 +247,8 @@ public final class EscherMetafileBlip extends EscherBlipRecord { String extraData = "";//HexDump.toHex(field_pictureData, 32); return getClass().getName() + ":" + '\n' + " RecordId: 0x" + HexDump.toHex( getRecordId() ) + '\n' + - " Options: 0x" + HexDump.toHex( getOptions() ) + '\n' + + " Version: 0x" + HexDump.toHex( getVersion() ) + '\n' + + " Instance: 0x" + HexDump.toHex( getInstance() ) + '\n' + " UID: 0x" + HexDump.toHex( field_1_UID ) + '\n' + (field_2_UID == null ? "" : (" UID2: 0x" + HexDump.toHex( field_2_UID ) + '\n')) + " Uncompressed Size: " + HexDump.toHex( field_2_cb ) + '\n' + diff --git a/src/java/org/apache/poi/ddf/EscherPictBlip.java b/src/java/org/apache/poi/ddf/EscherPictBlip.java index 31f36c3ebc..978ff777e4 100644 --- a/src/java/org/apache/poi/ddf/EscherPictBlip.java +++ b/src/java/org/apache/poi/ddf/EscherPictBlip.java @@ -202,7 +202,8 @@ public final class EscherPictBlip extends EscherBlipRecord { String extraData = HexDump.toHex(field_pictureData, 32); return getClass().getName() + ":" + '\n' + " RecordId: 0x" + HexDump.toHex( getRecordId() ) + '\n' + - " Options: 0x" + HexDump.toHex( getOptions() ) + '\n' + + " Version: 0x" + HexDump.toHex( getVersion() ) + '\n' + + " Instance: 0x" + HexDump.toHex( getInstance() ) + '\n' + " UID: 0x" + HexDump.toHex( field_1_UID ) + '\n' + " Uncompressed Size: " + HexDump.toHex( field_2_cb ) + '\n' + " Bounds: " + getBounds() + '\n' + diff --git a/src/java/org/apache/poi/ddf/EscherSpRecord.java b/src/java/org/apache/poi/ddf/EscherSpRecord.java index 69bde52c15..cd51c91929 100644 --- a/src/java/org/apache/poi/ddf/EscherSpRecord.java +++ b/src/java/org/apache/poi/ddf/EscherSpRecord.java @@ -108,7 +108,8 @@ public class EscherSpRecord return getClass().getName() + ":" + nl + " RecordId: 0x" + HexDump.toHex(RECORD_ID) + nl + - " Options: 0x" + HexDump.toHex(getOptions()) + nl + + " Version: 0x" + HexDump.toHex(getVersion()) + nl + + " ShapeType: 0x" + HexDump.toHex(getShapeType()) + nl + " ShapeId: " + field_1_shapeId + nl + " Flags: " + decodeFlags(field_2_flags) + " (0x" + HexDump.toHex(field_2_flags) + ")" + nl; @@ -197,4 +198,27 @@ public class EscherSpRecord { this.field_2_flags = field_2_flags; } + + /** + * Returns shape type. Must be one of MSOSPT values (see [MS-ODRAW] for + * details). + * + * @return shape type + */ + public short getShapeType() + { + return getInstance(); + } + + /** + * Sets shape type. Must be one of MSOSPT values (see [MS-ODRAW] for + * details). + * + * @param value + * new shape type + */ + public void setShapeType( short value ) + { + setInstance( value ); + } } diff --git a/src/java/org/apache/poi/ddf/EscherSpgrRecord.java b/src/java/org/apache/poi/ddf/EscherSpgrRecord.java index 80594af5e0..43197322df 100644 --- a/src/java/org/apache/poi/ddf/EscherSpgrRecord.java +++ b/src/java/org/apache/poi/ddf/EscherSpgrRecord.java @@ -89,7 +89,8 @@ public class EscherSpgrRecord public String toString() { return getClass().getName() + ":" + '\n' + " RecordId: 0x" + HexDump.toHex(RECORD_ID) + '\n' + - " Options: 0x" + HexDump.toHex(getOptions()) + '\n' + + " Version: 0x" + HexDump.toHex(getVersion()) + '\n' + + " Instance: 0x" + HexDump.toHex(getInstance()) + '\n' + " RectX: " + field_1_rectX1 + '\n' + " RectY: " + field_2_rectY1 + '\n' + " RectWidth: " + field_3_rectX2 + '\n' + diff --git a/src/java/org/apache/poi/ddf/EscherSplitMenuColorsRecord.java b/src/java/org/apache/poi/ddf/EscherSplitMenuColorsRecord.java index f11c2251bf..2f85ef24ad 100644 --- a/src/java/org/apache/poi/ddf/EscherSplitMenuColorsRecord.java +++ b/src/java/org/apache/poi/ddf/EscherSplitMenuColorsRecord.java @@ -90,7 +90,8 @@ public class EscherSplitMenuColorsRecord public String toString() { return getClass().getName() + ":" + '\n' + " RecordId: 0x" + HexDump.toHex(RECORD_ID) + '\n' + - " Options: 0x" + HexDump.toHex(getOptions()) + '\n' + + " Version: 0x" + HexDump.toHex(getVersion()) + '\n' + + " Instance: 0x" + HexDump.toHex(getInstance()) + '\n' + " Color1: 0x" + HexDump.toHex(field_1_color1) + '\n' + " Color2: 0x" + HexDump.toHex(field_2_color2) + '\n' + " Color3: 0x" + HexDump.toHex(field_3_color3) + '\n' + diff --git a/src/java/org/apache/poi/ddf/EscherTextboxRecord.java b/src/java/org/apache/poi/ddf/EscherTextboxRecord.java index ab1ab0bfc3..5e726d523e 100644 --- a/src/java/org/apache/poi/ddf/EscherTextboxRecord.java +++ b/src/java/org/apache/poi/ddf/EscherTextboxRecord.java @@ -132,7 +132,8 @@ public class EscherTextboxRecord extends EscherRecord return getClass().getName() + ":" + nl + " isContainer: " + isContainerRecord() + nl + - " options: 0x" + HexDump.toHex( getOptions() ) + nl + + " version: 0x" + HexDump.toHex( getVersion() ) + nl + + " instance: 0x" + HexDump.toHex( getInstance() ) + nl + " recordId: 0x" + HexDump.toHex( getRecordId() ) + nl + " numchildren: " + getChildRecords().size() + nl + theDumpHex; diff --git a/src/java/org/apache/poi/ddf/UnknownEscherRecord.java b/src/java/org/apache/poi/ddf/UnknownEscherRecord.java index e5296123b1..563ef6d6e4 100644 --- a/src/java/org/apache/poi/ddf/UnknownEscherRecord.java +++ b/src/java/org/apache/poi/ddf/UnknownEscherRecord.java @@ -135,7 +135,8 @@ public final class UnknownEscherRecord extends EscherRecord { return getClass().getName() + ":" + '\n' + " isContainer: " + isContainerRecord() + '\n' + - " options: 0x" + HexDump.toHex( getOptions() ) + '\n' + + " version: 0x" + HexDump.toHex( getVersion() ) + '\n' + + " instance: 0x" + HexDump.toHex( getInstance() ) + '\n' + " recordId: 0x" + HexDump.toHex( getRecordId() ) + '\n' + " numchildren: " + getChildRecords().size() + '\n' + theDumpHex + diff --git a/src/java/org/apache/poi/hssf/record/EscherAggregate.java b/src/java/org/apache/poi/hssf/record/EscherAggregate.java index 50d5e5d3f3..bc893b4c3b 100644 --- a/src/java/org/apache/poi/hssf/record/EscherAggregate.java +++ b/src/java/org/apache/poi/hssf/record/EscherAggregate.java @@ -616,7 +616,7 @@ public final class EscherAggregate extends AbstractEscherHolderRecord { { EscherSpRecord spRecord = shapeContainer .getChildById( EscherSpRecord.RECORD_ID ); - int type = spRecord.getOptions() >> 4; + int type = spRecord.getShapeType(); switch (type) { diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java b/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java index 49cc01f641..3fca27c449 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java @@ -130,7 +130,7 @@ public abstract class Shape { */ public int getShapeType(){ EscherSpRecord spRecord = _escherContainer.getChildById(EscherSpRecord.RECORD_ID); - return spRecord.getOptions() >> 4; + return spRecord.getShapeType(); } /** @@ -139,7 +139,8 @@ public abstract class Shape { */ public void setShapeType(int type){ EscherSpRecord spRecord = _escherContainer.getChildById(EscherSpRecord.RECORD_ID); - spRecord.setOptions((short)(type << 4 | 0x2)); + spRecord.setShapeType( (short) type ); + spRecord.setVersion( (short) 0x2 ); } /** diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/ShapeFactory.java b/src/scratchpad/src/org/apache/poi/hslf/model/ShapeFactory.java index 05e8733b5a..464c842348 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/ShapeFactory.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/ShapeFactory.java @@ -72,7 +72,7 @@ public final class ShapeFactory { Shape shape = null; EscherSpRecord spRecord = spContainer.getChildById(EscherSpRecord.RECORD_ID); - int type = spRecord.getOptions() >> 4; + int type = spRecord.getShapeType(); switch (type){ case ShapeTypes.TextBox: shape = new TextBox(spContainer, parent); -- 2.39.5