diff options
author | Evgeniy Berlog <berlog@apache.org> | 2012-06-26 11:21:13 +0000 |
---|---|---|
committer | Evgeniy Berlog <berlog@apache.org> | 2012-06-26 11:21:13 +0000 |
commit | b57fa5b4d0621d11b3f324387cebad89cd046eb8 (patch) | |
tree | 524b19e1706364f051f084db7c0158847b39eeec /src/testcases/org/apache/poi/hssf/model | |
parent | 7efc80c3e8945546bb7fa4fa019e9f6449e5b55b (diff) | |
download | poi-b57fa5b4d0621d11b3f324387cebad89cd046eb8.tar.gz poi-b57fa5b4d0621d11b3f324387cebad89cd046eb8.zip |
implemented creating shapes in existing files
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/gsoc2012@1353960 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/hssf/model')
-rw-r--r-- | src/testcases/org/apache/poi/hssf/model/HSSFTestModelHelper.java | 13 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/hssf/model/TestDrawingShapes.java | 37 |
2 files changed, 50 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/hssf/model/HSSFTestModelHelper.java b/src/testcases/org/apache/poi/hssf/model/HSSFTestModelHelper.java new file mode 100644 index 0000000000..cca8f2d635 --- /dev/null +++ b/src/testcases/org/apache/poi/hssf/model/HSSFTestModelHelper.java @@ -0,0 +1,13 @@ +package org.apache.poi.hssf.model;
+
+import org.apache.poi.hssf.usermodel.HSSFTextbox;
+
+/**
+ * @author Evgeniy Berlog
+ * @date 25.06.12
+ */
+public class HSSFTestModelHelper {
+ public static TextboxShape createTextboxShape(int shapeId, HSSFTextbox textbox){
+ return new TextboxShape(textbox, shapeId);
+ }
+}
diff --git a/src/testcases/org/apache/poi/hssf/model/TestDrawingShapes.java b/src/testcases/org/apache/poi/hssf/model/TestDrawingShapes.java index 097d5d01ee..1beeabe94b 100644 --- a/src/testcases/org/apache/poi/hssf/model/TestDrawingShapes.java +++ b/src/testcases/org/apache/poi/hssf/model/TestDrawingShapes.java @@ -251,4 +251,41 @@ public class TestDrawingShapes extends TestCase{ ((EscherContainerRecord)spgrContainer.getChild(2)).getChildById(EscherSpRecord.RECORD_ID);
assertEquals(1026, sp2.getShapeId());
}
+
+ /**
+ * Test get new id for shapes from existing file
+ * File already have for 1 shape on each sheet, because document must contain EscherDgRecord for each sheet
+ */
+ public void testAllocateNewIds(){
+ HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("empty.xls");
+ HSSFSheet sheet = wb.getSheetAt(0);
+ HSSFPatriarch patriarch = sheet.getDrawingPatriarch();
+
+ /**
+ * 2048 - main SpContainer id
+ * 2049 - existing shape id
+ */
+ assertEquals(HSSFTestHelper.allocateNewShapeId(patriarch), 2050);
+ assertEquals(HSSFTestHelper.allocateNewShapeId(patriarch), 2051);
+ assertEquals(HSSFTestHelper.allocateNewShapeId(patriarch), 2052);
+
+ sheet = wb.getSheetAt(1);
+ patriarch = sheet.getDrawingPatriarch();
+
+ /**
+ * 3072 - main SpContainer id
+ * 3073 - existing shape id
+ */
+ assertEquals(HSSFTestHelper.allocateNewShapeId(patriarch), 3074);
+ assertEquals(HSSFTestHelper.allocateNewShapeId(patriarch), 3075);
+ assertEquals(HSSFTestHelper.allocateNewShapeId(patriarch), 3076);
+
+
+ sheet = wb.getSheetAt(2);
+ patriarch = sheet.getDrawingPatriarch();
+
+ assertEquals(HSSFTestHelper.allocateNewShapeId(patriarch), 1026);
+ assertEquals(HSSFTestHelper.allocateNewShapeId(patriarch), 1027);
+ assertEquals(HSSFTestHelper.allocateNewShapeId(patriarch), 1028);
+ }
}
|