From e4e6459f54bb2034ff98108e53e14637ab7cb0d1 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Tue, 6 May 2008 16:00:36 +0000 Subject: Merged revisions 638786-638802,638805-638811,638813-638814,638816-639230,639233-639241,639243-639253,639255-639486,639488-639601,639603-639835,639837-639917,639919-640056,640058-640710,640712-641156,641158-641184,641186-641795,641797-641798,641800-641933,641935-641963,641965-641966,641968-641995,641997-642230,642232-642562,642564-642565,642568-642570,642572-642573,642576-642736,642739-642877,642879,642881-642890,642892-642903,642905-642945,642947-643624,643626-643653,643655-643669,643671,643673-643830,643832-643833,643835-644342,644344-644472,644474-644508,644510-645347,645349-645351,645353-645559,645561-645565,645568-645951,645953-646193,646195-646311,646313-646404,646406-646665,646667-646853,646855-646869,646871-647151,647153-647185,647187-647277,647279-647566,647568-647573,647575,647578-647711,647714-647737,647739-647823,647825-648155,648157-648202,648204-648273,648275,648277-648302,648304-648333,648335-648588,648590-648622,648625-648673,648675-649141,649144,649146-649556,649558-649795,649799,649801-649910,649912-649913,649915-650128,650131-650132,650134-650137,650140-650914,650916-653812 via svnmerge from https://svn.apache.org:443/repos/asf/poi/trunk ........ r651992 | nick | 2008-04-27 19:02:13 +0100 (Sun, 27 Apr 2008) | 1 line Fix from Trejkaz from bug #44857 - Avoid OOM on unknown escher records when EscherMetafileBlip is incorrect ........ r652285 | yegor | 2008-04-30 07:18:05 +0100 (Wed, 30 Apr 2008) | 1 line start a new section for 3.1-beta2 ........ r652288 | yegor | 2008-04-30 07:19:38 +0100 (Wed, 30 Apr 2008) | 1 line correctly process PICT blips (see bug #44886) ........ r652290 | yegor | 2008-04-30 07:21:04 +0100 (Wed, 30 Apr 2008) | 1 line more flexible creation of a cluster ........ r652292 | yegor | 2008-04-30 07:22:02 +0100 (Wed, 30 Apr 2008) | 1 line a few more words in the release guide ........ r652298 | yegor | 2008-04-30 07:29:11 +0100 (Wed, 30 Apr 2008) | 1 line more work on rendering ppt slides ........ r652329 | nick | 2008-04-30 12:10:49 +0100 (Wed, 30 Apr 2008) | 1 line Tests to show that bugs 44891 and 44861 were both already fixed ........ r652426 | josh | 2008-05-01 04:25:37 +0100 (Thu, 01 May 2008) | 1 line fixed bug 44892 - made HSSFWorkbook.getSheet(String) case insensitive ........ r652446 | josh | 2008-05-01 08:42:18 +0100 (Thu, 01 May 2008) | 1 line 44914 - Fix/suppress warning message - WARN. Unread n bytes of record 0xNN ........ r652561 | josh | 2008-05-01 16:46:21 +0100 (Thu, 01 May 2008) | 1 line added disabled junit for bug 44916 ........ r652934 | josh | 2008-05-02 23:36:49 +0100 (Fri, 02 May 2008) | 1 line 44921 - allow Ptg.writeBytes() to be called on relative ref Ptgs (RefN* and AreaN*) ........ r652936 | josh | 2008-05-02 23:49:38 +0100 (Fri, 02 May 2008) | 1 line should have been submitted with r652934 ........ r652994 | josh | 2008-05-03 04:59:32 +0100 (Sat, 03 May 2008) | 1 line Fixed 44675 - Parameter operand classes (function metadata) required to encode SUM() etc properly. Added parse validation for number of parameters ........ r653117 | josh | 2008-05-03 20:53:38 +0100 (Sat, 03 May 2008) | 1 line 44929 - Improved error handling in HSSFWorkbook when attempting to read a BIFF5 file ........ r653125 | josh | 2008-05-03 21:13:56 +0100 (Sat, 03 May 2008) | 1 line Swapped ArrayIndexOutOfBoundsException for plain array length check in AbstractFunctionPtg.getParameterClass(). (To help debugging when trying to find a real AIOOB) ........ r653484 | yegor | 2008-05-05 14:59:11 +0100 (Mon, 05 May 2008) | 1 line take into account indentation in HSSFSheet.autosizeColumn ........ r653485 | yegor | 2008-05-05 14:59:38 +0100 (Mon, 05 May 2008) | 1 line take into account indentation in HSSFSheet.autosizeColumn ........ r653486 | yegor | 2008-05-05 15:00:30 +0100 (Mon, 05 May 2008) | 1 line getting ready to 3.1-beta2 ........ r653520 | yegor | 2008-05-05 17:12:21 +0100 (Mon, 05 May 2008) | 1 line bug #44235 is not reproducible in 3.1-beta1 ........ r653521 | yegor | 2008-05-05 17:13:24 +0100 (Mon, 05 May 2008) | 1 line restored mistakenly commented line ........ r653551 | josh | 2008-05-05 19:30:49 +0100 (Mon, 05 May 2008) | 1 line Added test case method javadoc for old bug 44675 ........ r653608 | josh | 2008-05-05 22:38:07 +0100 (Mon, 05 May 2008) | 1 line Follow-on from 28754 - StringPtg.toFormulaString() should escape double quotes ........ r653668 | josh | 2008-05-06 03:02:41 +0100 (Tue, 06 May 2008) | 1 line 42564 - fixed ArrayPtg to use ConstantValueParser. Fixed a few other ArrayPtg encoding issues. ........ r653675 | josh | 2008-05-06 04:57:15 +0100 (Tue, 06 May 2008) | 1 line 42570 - fixed LabelRecord to use empty string instead of null when the length is zero. ........ git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@653822 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/hslf/model/TestFreeform.java | 8 +-- .../org/apache/poi/hslf/model/TestShapes.java | 55 ++++++++++++---- .../apache/poi/hslf/record/TestTextRulerAtom.java | 76 ++++++++++++++++++++++ .../apache/poi/hslf/usermodel/TestRichTextRun.java | 8 ++- 4 files changed, 129 insertions(+), 18 deletions(-) create mode 100755 src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextRulerAtom.java (limited to 'src/scratchpad/testcases') diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java index 5e7e7cc4b7..56d5a099cb 100755 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java @@ -52,7 +52,7 @@ public class TestFreeform extends TestCase { Freeform p = new Freeform(); p.setPath(path1); - GeneralPath path2 = p.getPath(); + java.awt.Shape path2 = p.getOutline(); assertTrue(new Area(path1).equals(new Area(path2))); } @@ -63,7 +63,7 @@ public class TestFreeform extends TestCase { Freeform p = new Freeform(); p.setPath(path1); - GeneralPath path2 = p.getPath(); + java.awt.Shape path2 = p.getOutline(); assertTrue(new Area(path1).equals(new Area(path2))); } @@ -74,7 +74,7 @@ public class TestFreeform extends TestCase { Freeform p = new Freeform(); p.setPath(path1); - GeneralPath path2 = p.getPath(); + java.awt.Shape path2 = p.getOutline(); assertTrue(new Area(path1).equals(new Area(path2))); - } + } } diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java index 511ef7f745..3ce6b91caf 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java @@ -20,6 +20,8 @@ import junit.framework.TestCase; import org.apache.poi.hslf.usermodel.SlideShow; import org.apache.poi.hslf.usermodel.RichTextRun; import org.apache.poi.hslf.HSLFSlideShow; +import org.apache.poi.ddf.EscherDggRecord; +import org.apache.poi.ddf.EscherDgRecord; import java.awt.*; import java.awt.Rectangle; @@ -311,18 +313,49 @@ public class TestShapes extends TestCase { public void testShapeId() throws IOException { SlideShow ppt = new SlideShow(); Slide slide = ppt.createSlide(); - Shape shape; - - shape = new Line(); - assertEquals(0, shape.getShapeId()); - slide.addShape(shape); - assertTrue(shape.getShapeId() > 0); + Shape shape = null; + + //EscherDgg is a document-level record which keeps track of the drawing groups + EscherDggRecord dgg = ppt.getDocumentRecord().getPPDrawingGroup().getEscherDggRecord(); + EscherDgRecord dg = slide.getSheetContainer().getPPDrawing().getEscherDgRecord(); + + int dggShapesUsed = dgg.getNumShapesSaved(); //total number of shapes in the ppt + int dggMaxId = dgg.getShapeIdMax(); //max number of shapeId + + int dgMaxId = dg.getLastMSOSPID(); //max shapeId in the slide + int dgShapesUsed = dg.getNumShapes(); // number of shapes in the slide + //insert 3 shapes and make sure the Ids are properly incremented + for (int i = 0; i < 3; i++) { + shape = new Line(); + assertEquals(0, shape.getShapeId()); + slide.addShape(shape); + assertTrue(shape.getShapeId() > 0); + + //check that EscherDgRecord is updated + assertEquals(shape.getShapeId(), dg.getLastMSOSPID()); + assertEquals(dgMaxId + 1, dg.getLastMSOSPID()); + assertEquals(dgShapesUsed + 1, dg.getNumShapes()); + + //check that EscherDggRecord is updated + assertEquals(shape.getShapeId() + 1, dgg.getShapeIdMax()); + assertEquals(dggMaxId + 1, dgg.getShapeIdMax()); + assertEquals(dggShapesUsed + 1, dgg.getNumShapesSaved()); + + dggShapesUsed = dgg.getNumShapesSaved(); + dggMaxId = dgg.getShapeIdMax(); + dgMaxId = dg.getLastMSOSPID(); + dgShapesUsed = dg.getNumShapes(); + } - int shapeId = shape.getShapeId(); - shape = new Line(); - assertEquals(0, shape.getShapeId()); - slide.addShape(shape); - assertEquals(shapeId + 1, shape.getShapeId()); + //For each drawing group PPT allocates clusters with size=1024 + //if the number of shapes is greater that 1024 a new cluster is allocated + //make sure it is so + int numClusters = dgg.getNumIdClusters(); + for (int i = 0; i < 1025; i++) { + shape = new Line(); + slide.addShape(shape); + } + assertEquals(numClusters + 1, dgg.getNumIdClusters()); } } diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextRulerAtom.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextRulerAtom.java new file mode 100755 index 0000000000..0b610cb645 --- /dev/null +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextRulerAtom.java @@ -0,0 +1,76 @@ + +/* ==================================================================== + 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.hslf.record; + +import org.apache.poi.hslf.HSLFSlideShow; +import org.apache.poi.hslf.model.textproperties.CharFlagsTextProp; +import org.apache.poi.hslf.model.textproperties.TextProp; +import org.apache.poi.hslf.model.textproperties.TextPropCollection; +import org.apache.poi.hslf.record.StyleTextPropAtom.*; +import org.apache.poi.hslf.usermodel.SlideShow; +import org.apache.poi.util.HexDump; + +import junit.framework.TestCase; +import java.io.ByteArrayOutputStream; +import java.util.LinkedList; +import java.util.Arrays; + +/** + * Tests TextRulerAtom + * + * @author Yegor Kozlov + */ +public class TestTextRulerAtom extends TestCase { + + //from a real file + private byte[] data_1 = new byte[] { + 0x00, 0x00, (byte)0xA6, 0x0F, 0x18, 0x00, 0x00, 0x00, + (byte)0xF8, 0x1F, 0x00, 0x00, 0x75, 0x00, (byte)0xE2, 0x00, 0x59, + 0x01, (byte)0xC3, 0x01, 0x1A, 0x03, (byte)0x87, 0x03, (byte)0xF8, + 0x03, 0x69, 0x04, (byte)0xF6, 0x05, (byte)0xF6, 0x05 + }; + + + public void testReadRuler() throws Exception { + TextRulerAtom ruler = new TextRulerAtom(data_1, 0, data_1.length); + assertEquals(ruler.getNumberOfLevels(), 0); + assertEquals(ruler.getDefaultTabSize(), 0); + + int[] tabStops = ruler.getTabStops(); + assertNull(tabStops); + + int[] textOffsets = ruler.getTextOffsets(); + assertTrue(Arrays.equals(new int[]{226, 451, 903, 1129, 1526}, textOffsets)); + + int[] bulletOffsets = ruler.getBulletOffsets(); + assertTrue(Arrays.equals(new int[]{117, 345, 794, 1016, 1526}, bulletOffsets)); + + } + + public void testWriteRuler() throws Exception { + TextRulerAtom ruler = new TextRulerAtom(data_1, 0, data_1.length); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + ruler.writeOut(out); + + byte[] result = out.toByteArray(); + assertTrue(Arrays.equals(result, data_1)); + } +} diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java index 0fecdab97b..eda6589c42 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java @@ -90,9 +90,11 @@ public class TestRichTextRun extends TestCase { // Now set it to not bold rtr.setBold(false); - assertNotNull(rtr._getRawCharacterStyle()); - assertNotNull(rtr._getRawParagraphStyle()); - assertFalse(rtr.isBold()); + //setting bold=false doesn't change the internal state + assertNull(rtr._getRawCharacterStyle()); + assertNull(rtr._getRawParagraphStyle()); + + assertFalse(rtr.isBold()); // And now make it bold rtr.setBold(true); -- cgit v1.2.3