]> source.dussan.org Git - poi.git/commitdiff
#59170 - Remove deprecated classes (POI 3.15) - o.a.p.hssf.model.*Shape classes removed
authorAndreas Beeker <kiwiwings@apache.org>
Sun, 3 Jul 2016 21:54:17 +0000 (21:54 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Sun, 3 Jul 2016 21:54:17 +0000 (21:54 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1751174 13f79535-47bb-0310-9956-ffa450edef68

18 files changed:
src/java/org/apache/poi/hssf/model/AbstractShape.java [deleted file]
src/java/org/apache/poi/hssf/model/ComboboxShape.java [deleted file]
src/java/org/apache/poi/hssf/model/CommentShape.java [deleted file]
src/java/org/apache/poi/hssf/model/LineShape.java [deleted file]
src/java/org/apache/poi/hssf/model/PictureShape.java [deleted file]
src/java/org/apache/poi/hssf/model/PolygonShape.java [deleted file]
src/java/org/apache/poi/hssf/model/SimpleFilledShape.java [deleted file]
src/java/org/apache/poi/hssf/model/TextboxShape.java [deleted file]
src/java/org/apache/poi/hssf/record/LbsDataSubRecord.java
src/java/org/apache/poi/hssf/usermodel/HSSFShape.java
src/testcases/org/apache/poi/hssf/model/HSSFTestModelHelper.java [deleted file]
src/testcases/org/apache/poi/hssf/model/TestDrawingAggregate.java
src/testcases/org/apache/poi/hssf/model/TestDrawingShapes.java
src/testcases/org/apache/poi/hssf/model/TestShapes.java [deleted file]
src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java
src/testcases/org/apache/poi/hssf/usermodel/TestPolygon.java
src/testcases/org/apache/poi/hssf/usermodel/TestText.java

diff --git a/src/java/org/apache/poi/hssf/model/AbstractShape.java b/src/java/org/apache/poi/hssf/model/AbstractShape.java
deleted file mode 100644 (file)
index 1bfbc26..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-/* ====================================================================
-   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.model;
-
-import org.apache.poi.ddf.*;
-import org.apache.poi.hssf.record.ObjRecord;
-import org.apache.poi.hssf.usermodel.*;
-
-/**
- * An abstract shape is the lowlevel model for a shape.
- */
-@Deprecated
-public abstract class AbstractShape
-{
-    /**
-     * Create a new shape object used to create the escher records.
-     *
-     * @param hssfShape     The simple shape this is based on.
-     */
-    public static AbstractShape createShape( HSSFShape hssfShape, int shapeId )
-    {
-        AbstractShape shape;
-        if (hssfShape instanceof HSSFComment)
-        {
-            shape = new CommentShape( (HSSFComment)hssfShape, shapeId );
-        }
-        else if (hssfShape instanceof HSSFTextbox)
-        {
-            shape = new TextboxShape( (HSSFTextbox)hssfShape, shapeId );
-        }
-        else if (hssfShape instanceof HSSFPolygon)
-        {
-            shape = new PolygonShape( (HSSFPolygon) hssfShape, shapeId );
-        }
-        else if (hssfShape instanceof HSSFSimpleShape)
-        {
-            HSSFSimpleShape simpleShape = (HSSFSimpleShape) hssfShape;
-            switch ( simpleShape.getShapeType() )
-            {
-                case HSSFSimpleShape.OBJECT_TYPE_PICTURE:
-                    shape = new PictureShape( simpleShape, shapeId );
-                    break;
-                case HSSFSimpleShape.OBJECT_TYPE_LINE:
-                    shape = new LineShape( simpleShape, shapeId );
-                    break;
-                case HSSFSimpleShape.OBJECT_TYPE_OVAL:
-                case HSSFSimpleShape.OBJECT_TYPE_RECTANGLE:
-                    shape = new SimpleFilledShape( simpleShape, shapeId );
-                    break;
-                case HSSFSimpleShape.OBJECT_TYPE_COMBO_BOX:
-                    shape = new ComboboxShape( simpleShape, shapeId );
-                    break;
-                default:
-                    throw new IllegalArgumentException("Do not know how to handle this type of shape");
-            }
-        }
-        else
-        {
-            throw new IllegalArgumentException("Unknown shape type");
-        }
-        EscherSpRecord sp = shape.getSpContainer().getChildById(EscherSpRecord.RECORD_ID);
-        if (hssfShape.getParent() != null)
-            sp.setFlags(sp.getFlags() | EscherSpRecord.FLAG_CHILD);
-        return shape;
-    }
-
-    protected AbstractShape()
-    {
-    }
-
-    /**
-     * @return  The shape container and it's children that can represent this
-     *          shape.
-     */
-    public abstract EscherContainerRecord getSpContainer();
-
-    /**
-     * @return  The object record that is associated with this shape.
-     */
-    public abstract ObjRecord getObjRecord();
-
-    /**
-     * Creates an escher anchor record from a HSSFAnchor.
-     *
-     * @param userAnchor    The high level anchor to convert.
-     * @return  An escher anchor record.
-     */
-    protected EscherRecord createAnchor( HSSFAnchor userAnchor )
-    {
-        return ConvertAnchor.createAnchor(userAnchor);
-    }
-
-    /**
-     * Add standard properties to the opt record.  These properties effect
-     * all records.
-     *
-     * @param shape     The user model shape.
-     * @param opt       The opt record to add the properties to.
-     * @return          The number of options added.
-     */
-    protected int addStandardOptions( HSSFShape shape, EscherOptRecord opt )
-    {
-        opt.addEscherProperty( new EscherBoolProperty( EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x080000 ) );
-//        opt.addEscherProperty( new EscherBoolProperty( EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x080008 ) );
-        if ( shape.isNoFill() )
-        {
-            // Wonderful... none of the spec's give any clue as to what these constants mean.
-            opt.addEscherProperty( new EscherBoolProperty( EscherProperties.FILL__NOFILLHITTEST, 0x00110000 ) );
-        }
-        else
-        {
-            opt.addEscherProperty( new EscherBoolProperty( EscherProperties.FILL__NOFILLHITTEST, 0x00010000 ) );
-        }
-        opt.addEscherProperty( new EscherRGBProperty( EscherProperties.FILL__FILLCOLOR, shape.getFillColor() ) );
-        opt.addEscherProperty( new EscherBoolProperty( EscherProperties.GROUPSHAPE__PRINT, 0x080000 ) );
-        opt.addEscherProperty( new EscherRGBProperty( EscherProperties.LINESTYLE__COLOR, shape.getLineStyleColor() ) );
-        int options = 5;
-        if (shape.getLineWidth() != HSSFShape.LINEWIDTH_DEFAULT)
-        {
-            opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.LINESTYLE__LINEWIDTH, shape.getLineWidth()));
-            options++;
-        }
-        if (shape.getLineStyle() != HSSFShape.LINESTYLE_SOLID)
-        {
-            opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.LINESTYLE__LINEDASHING, shape.getLineStyle()));
-            opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.LINESTYLE__LINEENDCAPSTYLE, 0));
-            if (shape.getLineStyle() == HSSFShape.LINESTYLE_NONE)
-                opt.addEscherProperty( new EscherBoolProperty( EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080000));
-            else
-                opt.addEscherProperty( new EscherBoolProperty( EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080008));
-            options += 3;
-        }
-        opt.sortProperties();
-        return options;   // # options added
-    }
-
-    /**
-     * Generate id for the CommonObjectDataSubRecord that stands behind this shape
-     *
-     * <p>
-     *     Typically objectId starts with 1, is unique among all Obj record within the worksheet stream
-     *     and increments by 1 for every new shape.
-     *     For most shapes there is a straight relationship between shapeId (generated by DDF) and objectId:
-     * </p>
-     * <p>
-     *     shapeId  is unique and starts with 1024, hence objectId can be derived as <code>shapeId-1024</code>.
-     * </p>
-     * <p>
-     *     An exception from this rule is the CellComment shape whose objectId start with 1024.
-     *      See {@link CommentShape#getCmoObjectId(int)}
-     * </p>
-     *
-     *
-     *
-     * @param  shapeId   shape id as generated by drawing manager
-     * @return objectId  object id that will be assigned to the Obj record
-     */
-    int getCmoObjectId(int shapeId){
-        return shapeId - 1024;
-    }
-}
diff --git a/src/java/org/apache/poi/hssf/model/ComboboxShape.java b/src/java/org/apache/poi/hssf/model/ComboboxShape.java
deleted file mode 100644 (file)
index 2bfd9ef..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/* ====================================================================
-   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.model;
-
-import org.apache.poi.ddf.*;
-import org.apache.poi.hssf.record.*;
-import org.apache.poi.hssf.usermodel.*;
-import org.apache.poi.ss.usermodel.ClientAnchor.AnchorType;
-
-/**
- * Represents a combobox shape.
- */
-@Deprecated
-public class ComboboxShape
-        extends AbstractShape {
-    private EscherContainerRecord spContainer;
-    private ObjRecord objRecord;
-
-    /**
-     * Creates the low evel records for a combobox.
-     *
-     * @param hssfShape The highlevel shape.
-     * @param shapeId   The shape id to use for this shape.
-     */
-    ComboboxShape(HSSFSimpleShape hssfShape, int shapeId) {
-        spContainer = createSpContainer(hssfShape, shapeId);
-        objRecord = createObjRecord(hssfShape, shapeId);
-    }
-
-    /**
-     * Creates the low level OBJ record for this shape.
-     */
-    private ObjRecord createObjRecord(HSSFSimpleShape shape, int shapeId) {
-        ObjRecord obj = new ObjRecord();
-        CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();
-        c.setObjectType(HSSFSimpleShape.OBJECT_TYPE_COMBO_BOX);
-        c.setObjectId(  getCmoObjectId(shapeId) );
-        c.setLocked(true);
-        c.setPrintable(false);
-        c.setAutofill(true);
-        c.setAutoline(false);
-
-        FtCblsSubRecord f = new FtCblsSubRecord();
-
-        LbsDataSubRecord l = LbsDataSubRecord.newAutoFilterInstance();
-
-        EndSubRecord e = new EndSubRecord();
-
-        obj.addSubRecord(c);
-        obj.addSubRecord(f);
-        obj.addSubRecord(l);
-        obj.addSubRecord(e);
-
-        return obj;
-    }
-
-    /**
-     * Generates the escher shape records for this shape.
-     */
-    private EscherContainerRecord createSpContainer(HSSFSimpleShape shape, int shapeId) {
-        EscherContainerRecord spContainer = new EscherContainerRecord();
-        EscherSpRecord sp = new EscherSpRecord();
-        EscherOptRecord opt = new EscherOptRecord();
-        EscherClientDataRecord clientData = new EscherClientDataRecord();
-
-        spContainer.setRecordId(EscherContainerRecord.SP_CONTAINER);
-        spContainer.setOptions((short) 0x000F);
-        sp.setRecordId(EscherSpRecord.RECORD_ID);
-        sp.setOptions((short) ((EscherAggregate.ST_HOSTCONTROL << 4) | 0x2));
-
-        sp.setShapeId(shapeId);
-        sp.setFlags(EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE);
-        opt.setRecordId(EscherOptRecord.RECORD_ID);
-        opt.addEscherProperty(new EscherBoolProperty(EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 17039620));
-        opt.addEscherProperty(new EscherBoolProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x00080008));
-        opt.addEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080000));
-        opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GROUPSHAPE__PRINT, 0x00020000));
-
-        HSSFClientAnchor userAnchor = (HSSFClientAnchor) shape.getAnchor();
-        userAnchor.setAnchorType(AnchorType.DONT_MOVE_DO_RESIZE);
-        EscherRecord anchor = createAnchor(userAnchor);
-        clientData.setRecordId(EscherClientDataRecord.RECORD_ID);
-        clientData.setOptions((short) 0x0000);
-
-        spContainer.addChildRecord(sp);
-        spContainer.addChildRecord(opt);
-        spContainer.addChildRecord(anchor);
-        spContainer.addChildRecord(clientData);
-
-        return spContainer;
-    }
-
-    public EscherContainerRecord getSpContainer() {
-        return spContainer;
-    }
-
-    public ObjRecord getObjRecord() {
-        return objRecord;
-    }
-
-}
diff --git a/src/java/org/apache/poi/hssf/model/CommentShape.java b/src/java/org/apache/poi/hssf/model/CommentShape.java
deleted file mode 100644 (file)
index ba1fad9..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-/* ====================================================================
-   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.model;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.poi.ddf.EscherOptRecord;
-import org.apache.poi.ddf.EscherProperties;
-import org.apache.poi.ddf.EscherProperty;
-import org.apache.poi.ddf.EscherSimpleProperty;
-import org.apache.poi.hssf.record.CommonObjectDataSubRecord;
-import org.apache.poi.hssf.record.NoteRecord;
-import org.apache.poi.hssf.record.NoteStructureSubRecord;
-import org.apache.poi.hssf.record.ObjRecord;
-import org.apache.poi.hssf.record.SubRecord;
-import org.apache.poi.hssf.usermodel.HSSFComment;
-import org.apache.poi.hssf.usermodel.HSSFShape;
-
-/**
- * Represents a cell comment.
- * This class converts highlevel model data from <code>HSSFComment</code>
- * to low-level records.
- */
-@Deprecated
-public final class CommentShape extends TextboxShape {
-
-    private NoteRecord _note;
-
-    /**
-     * Creates the low-level records for a comment.
-     *
-     * @param hssfShape  The highlevel shape.
-     * @param shapeId    The shape id to use for this shape.
-     */
-     public CommentShape( HSSFComment hssfShape, int shapeId )
-    {
-        super(hssfShape, shapeId);
-
-        _note = createNoteRecord(hssfShape, shapeId);
-
-        ObjRecord obj = getObjRecord();
-        List<SubRecord> records = obj.getSubRecords();
-        int cmoIdx = 0;
-        for (int i = 0; i < records.size(); i++) {
-            Object r = records.get(i);
-
-            if (r instanceof CommonObjectDataSubRecord){
-                //modify autofill attribute inherited from <code>TextObjectRecord</code>
-                CommonObjectDataSubRecord cmo = (CommonObjectDataSubRecord)r;
-                cmo.setAutofill(false);
-                cmoIdx = i;
-            }
-        }
-        //add NoteStructure sub record
-        //we don't know it's format, for now the record data is empty
-        NoteStructureSubRecord u = new NoteStructureSubRecord();
-        obj.addSubRecord(cmoIdx+1, u);
-    }
-
-    /**
-     * Creates the low level <code>NoteRecord</code>
-     *  which holds the comment attributes.
-     */
-     private NoteRecord createNoteRecord( HSSFComment shape, int shapeId )
-    {
-        NoteRecord note = new NoteRecord();
-        note.setColumn(shape.getColumn());
-        note.setRow(shape.getRow());
-        note.setFlags(shape.isVisible() ? NoteRecord.NOTE_VISIBLE : NoteRecord.NOTE_HIDDEN);
-        note.setShapeId(shapeId);
-        note.setAuthor(shape.getAuthor() == null ? "" : shape.getAuthor());
-        return note;
-    }
-
-    /**
-     * Sets standard escher options for a comment.
-     * This method is responsible for setting default background,
-     * shading and other comment properties.
-     *
-     * @param shape   The highlevel shape.
-     * @param opt     The escher records holding the proerties
-     * @return number of escher options added
-     */
-    @Override
-       protected int addStandardOptions( HSSFShape shape, EscherOptRecord opt )
-    {
-        super.addStandardOptions(shape, opt);
-
-        //remove unnecessary properties inherited from TextboxShape
-        List<EscherProperty> props = opt.getEscherProperties();
-        for (Iterator<EscherProperty> iterator = props.iterator(); iterator.hasNext(); ) {
-            EscherProperty prop = iterator.next();
-            switch (prop.getId()){
-                case EscherProperties.TEXT__TEXTLEFT:
-                case EscherProperties.TEXT__TEXTRIGHT:
-                case EscherProperties.TEXT__TEXTTOP:
-                case EscherProperties.TEXT__TEXTBOTTOM:
-                case EscherProperties.GROUPSHAPE__PRINT:
-                case EscherProperties.FILL__FILLBACKCOLOR:
-                case EscherProperties.LINESTYLE__COLOR:
-                    iterator.remove();
-                    break;
-                default:
-                    break;
-            }
-        }
-
-        HSSFComment comment = (HSSFComment)shape;
-        opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.GROUPSHAPE__PRINT, comment.isVisible() ? 0x000A0000 : 0x000A0002) );
-        opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.SHADOWSTYLE__SHADOWOBSURED, 0x00030003 ) );
-        opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.SHADOWSTYLE__COLOR, 0x00000000 ) );
-        opt.sortProperties();
-        return opt.getEscherProperties().size();   // # options added
-    }
-
-    /**
-     * Return the <code>NoteRecord</code> holding the comment attributes
-     *
-     * @return <code>NoteRecord</code> holding the comment attributes
-     */
-    public NoteRecord getNoteRecord()
-    {
-        return _note;
-    }
-
-    @Override
-    int getCmoObjectId(int shapeId){
-        return shapeId;
-    }
-
-}
diff --git a/src/java/org/apache/poi/hssf/model/LineShape.java b/src/java/org/apache/poi/hssf/model/LineShape.java
deleted file mode 100644 (file)
index d9f6e63..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/* ====================================================================
-   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.model;
-
-import org.apache.poi.ddf.*;
-import org.apache.poi.hssf.record.*;
-import org.apache.poi.hssf.usermodel.*;
-
-/**
- * Represents a line shape and creates all the line specific low level records.
- */
-@Deprecated
-public class LineShape
-        extends AbstractShape
-{
-    private EscherContainerRecord spContainer;
-    private ObjRecord objRecord;
-
-    /**
-     * Creates the line shape from the highlevel user shape.  All low level
-     * records are created at this point.
-     *
-     * @param hssfShape     The user model shape.
-     * @param shapeId       The identifier to use for this shape.
-     */
-    LineShape( HSSFSimpleShape hssfShape, int shapeId )
-    {
-        spContainer = createSpContainer(hssfShape, shapeId);
-        objRecord = createObjRecord(hssfShape, shapeId);
-    }
-
-    /**
-     * Creates the lowerlevel escher records for this shape.
-     */
-    private EscherContainerRecord createSpContainer(HSSFSimpleShape hssfShape, int shapeId)
-    {
-        HSSFShape shape = hssfShape;
-
-        EscherContainerRecord spContainer = new EscherContainerRecord();
-        EscherSpRecord sp = new EscherSpRecord();
-        EscherOptRecord opt = new EscherOptRecord();
-        EscherClientDataRecord clientData = new EscherClientDataRecord();
-
-        spContainer.setRecordId( EscherContainerRecord.SP_CONTAINER );
-        spContainer.setOptions( (short) 0x000F );
-        sp.setRecordId( EscherSpRecord.RECORD_ID );
-        sp.setOptions( (short) ( (EscherAggregate.ST_LINE << 4) | 0x2 ) );
-
-        sp.setShapeId( shapeId );
-        sp.setFlags( EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE );
-        opt.setRecordId( EscherOptRecord.RECORD_ID );
-        opt.addEscherProperty( new EscherShapePathProperty( EscherProperties.GEOMETRY__SHAPEPATH, EscherShapePathProperty.COMPLEX ) );
-        opt.addEscherProperty( new EscherBoolProperty( EscherProperties.LINESTYLE__NOLINEDRAWDASH, 1048592 ) );
-        addStandardOptions(shape, opt);
-        HSSFAnchor userAnchor = shape.getAnchor();
-        if (userAnchor.isHorizontallyFlipped())
-            sp.setFlags(sp.getFlags() | EscherSpRecord.FLAG_FLIPHORIZ);
-        if (userAnchor.isVerticallyFlipped())
-            sp.setFlags(sp.getFlags() | EscherSpRecord.FLAG_FLIPVERT);
-        EscherRecord anchor = createAnchor(userAnchor);
-        clientData.setRecordId( EscherClientDataRecord.RECORD_ID );
-        clientData.setOptions( (short) 0x0000 );
-
-        spContainer.addChildRecord(sp);
-        spContainer.addChildRecord(opt);
-        spContainer.addChildRecord(anchor);
-        spContainer.addChildRecord(clientData);
-
-        return spContainer;
-    }
-
-    /**
-     * Creates the low level OBJ record for this shape.
-     */
-    private ObjRecord createObjRecord(HSSFShape hssfShape, int shapeId)
-    {
-        HSSFShape shape = hssfShape;
-
-        ObjRecord obj = new ObjRecord();
-        CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();
-        c.setObjectType((short) ((HSSFSimpleShape)shape).getShapeType());
-        c.setObjectId(  getCmoObjectId(shapeId) );
-        c.setLocked(true);
-        c.setPrintable(true);
-        c.setAutofill(true);
-        c.setAutoline(true);
-        EndSubRecord e = new EndSubRecord();
-
-        obj.addSubRecord(c);
-        obj.addSubRecord(e);
-
-        return obj;
-    }
-
-    public EscherContainerRecord getSpContainer()
-    {
-        return spContainer;
-    }
-
-    public ObjRecord getObjRecord()
-    {
-        return objRecord;
-    }
-
-}
diff --git a/src/java/org/apache/poi/hssf/model/PictureShape.java b/src/java/org/apache/poi/hssf/model/PictureShape.java
deleted file mode 100644 (file)
index af8e769..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-
-/* ====================================================================
-   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.model;
-
-import org.apache.poi.ddf.*;
-import org.apache.poi.hssf.record.*;
-import org.apache.poi.hssf.usermodel.*;
-
-/**
- * Represents a picture shape and creates all specific low level records.
- * @deprecated 3.15 beta 2. Use {@link HSSFPicture} instead.
- * This should have been deprecated in r1364547 (POI 3.9) with the other AbstractShape deprecations.
- */
-@Deprecated
-public class PictureShape
-        extends AbstractShape
-{
-    private EscherContainerRecord spContainer;
-    private ObjRecord objRecord;
-
-    /**
-     * Creates the line shape from the highlevel user shape.  All low level
-     * records are created at this point.
-     *
-     * @param hssfShape     The user model shape.
-     * @param shapeId       The identifier to use for this shape.
-     */
-    PictureShape( HSSFSimpleShape hssfShape, int shapeId )
-    {
-        spContainer = createSpContainer(hssfShape, shapeId);
-        objRecord = createObjRecord(hssfShape, shapeId);
-    }
-
-    /**
-     * Creates the lowerlevel escher records for this shape.
-     */
-    private EscherContainerRecord createSpContainer(HSSFSimpleShape hssfShape, int shapeId)
-    {
-        HSSFPicture shape = (HSSFPicture) hssfShape;
-
-        EscherContainerRecord spContainer = new EscherContainerRecord();
-        EscherSpRecord sp = new EscherSpRecord();
-        EscherOptRecord opt = new EscherOptRecord();
-        EscherRecord anchor;
-        EscherClientDataRecord clientData = new EscherClientDataRecord();
-
-        spContainer.setRecordId( EscherContainerRecord.SP_CONTAINER );
-        spContainer.setOptions( (short) 0x000F );
-        sp.setRecordId( EscherSpRecord.RECORD_ID );
-        sp.setOptions( (short) ( (EscherAggregate.ST_PICTUREFRAME << 4) | 0x2 ) );
-
-        sp.setShapeId( shapeId );
-        sp.setFlags( EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE );
-        opt.setRecordId( EscherOptRecord.RECORD_ID );
-//        opt.addEscherProperty( new EscherBoolProperty( EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 0x00800080 ) );
-        opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.BLIP__BLIPTODISPLAY, false, true, shape.getPictureIndex() ) );
-//        opt.addEscherProperty( new EscherComplexProperty( EscherProperties.BLIP__BLIPFILENAME, true, new byte[] { (byte)0x74, (byte)0x00, (byte)0x65, (byte)0x00, (byte)0x73, (byte)0x00, (byte)0x74, (byte)0x00, (byte)0x00, (byte)0x00 } ) );
-//        opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.FILL__FILLTYPE, 0x00000003 ) );
-        addStandardOptions(shape, opt);
-        HSSFAnchor userAnchor = shape.getAnchor();
-        if (userAnchor.isHorizontallyFlipped())
-            sp.setFlags(sp.getFlags() | EscherSpRecord.FLAG_FLIPHORIZ);
-        if (userAnchor.isVerticallyFlipped())
-            sp.setFlags(sp.getFlags() | EscherSpRecord.FLAG_FLIPVERT);
-        anchor = createAnchor(userAnchor);
-        clientData.setRecordId( EscherClientDataRecord.RECORD_ID );
-        clientData.setOptions( (short) 0x0000 );
-
-        spContainer.addChildRecord(sp);
-        spContainer.addChildRecord(opt);
-        spContainer.addChildRecord(anchor);
-        spContainer.addChildRecord(clientData);
-
-        return spContainer;
-    }
-
-    /**
-     * Creates the low level OBJ record for this shape.
-     */
-    private ObjRecord createObjRecord(HSSFShape hssfShape, int shapeId)
-    {
-        HSSFShape shape = hssfShape;
-
-        ObjRecord obj = new ObjRecord();
-        CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();
-        c.setObjectType((short) ((HSSFSimpleShape)shape).getShapeType());
-        c.setObjectId( getCmoObjectId(shapeId) );
-        c.setLocked(true);
-        c.setPrintable(true);
-        c.setAutofill(true);
-        c.setAutoline(true);
-        c.setReserved2( 0x0 );
-        EndSubRecord e = new EndSubRecord();
-
-        obj.addSubRecord(c);
-        obj.addSubRecord(e);
-
-        return obj;
-    }
-
-    public EscherContainerRecord getSpContainer()
-    {
-        return spContainer;
-    }
-
-    public ObjRecord getObjRecord()
-    {
-        return objRecord;
-    }
-
-}
diff --git a/src/java/org/apache/poi/hssf/model/PolygonShape.java b/src/java/org/apache/poi/hssf/model/PolygonShape.java
deleted file mode 100644 (file)
index 2d7b724..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-/* ====================================================================
-   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.model;
-
-import org.apache.poi.ddf.*;
-import org.apache.poi.hssf.record.ObjRecord;
-import org.apache.poi.hssf.record.EscherAggregate;
-import org.apache.poi.hssf.record.CommonObjectDataSubRecord;
-import org.apache.poi.hssf.record.EndSubRecord;
-import org.apache.poi.hssf.usermodel.HSSFShape;
-import org.apache.poi.hssf.usermodel.HSSFPolygon;
-import org.apache.poi.util.LittleEndian;
-
-@Deprecated
-public class PolygonShape
-        extends AbstractShape
-{
-    public final static short       OBJECT_TYPE_MICROSOFT_OFFICE_DRAWING = 30;
-
-    private EscherContainerRecord spContainer;
-    private ObjRecord objRecord;
-
-    /**
-     * Creates the low evel records for an polygon.
-     *
-     * @param hssfShape  The highlevel shape.
-     * @param shapeId    The shape id to use for this shape.
-     */
-    PolygonShape( HSSFPolygon hssfShape, int shapeId )
-    {
-        spContainer = createSpContainer( hssfShape, shapeId );
-        objRecord = createObjRecord( hssfShape, shapeId );
-    }
-
-    /**
-     * Generates the shape records for this shape.
-     *
-     */
-    private EscherContainerRecord createSpContainer( HSSFPolygon hssfShape, int shapeId )
-    {
-        HSSFShape shape = hssfShape;
-
-        EscherContainerRecord spContainer = new EscherContainerRecord();
-        EscherSpRecord sp = new EscherSpRecord();
-        EscherOptRecord opt = new EscherOptRecord();
-        EscherClientDataRecord clientData = new EscherClientDataRecord();
-
-        spContainer.setRecordId( EscherContainerRecord.SP_CONTAINER );
-        spContainer.setOptions( (short) 0x000F );
-        sp.setRecordId( EscherSpRecord.RECORD_ID );
-        sp.setOptions( (short) ( ( EscherAggregate.ST_NOT_PRIMATIVE << 4 ) | 0x2 ) );
-        sp.setShapeId( shapeId );
-        if (hssfShape.getParent() == null)
-            sp.setFlags( EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE );
-        else
-            sp.setFlags( EscherSpRecord.FLAG_CHILD | EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE );
-        opt.setRecordId( EscherOptRecord.RECORD_ID );
-        opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.TRANSFORM__ROTATION, false, false, 0));
-        opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__RIGHT, false, false, hssfShape.getDrawAreaWidth()));
-        opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__BOTTOM, false, false, hssfShape.getDrawAreaHeight()));
-        opt.addEscherProperty(new EscherShapePathProperty(EscherProperties.GEOMETRY__SHAPEPATH, EscherShapePathProperty.COMPLEX));
-        EscherArrayProperty verticesProp = new EscherArrayProperty(EscherProperties.GEOMETRY__VERTICES, false, new byte[0] );
-        verticesProp.setNumberOfElementsInArray(hssfShape.getXPoints().length+1);
-        verticesProp.setNumberOfElementsInMemory(hssfShape.getXPoints().length+1);
-        verticesProp.setSizeOfElements(0xFFF0);
-        for (int i = 0; i < hssfShape.getXPoints().length; i++)
-        {
-            byte[] data = new byte[4];
-            LittleEndian.putShort(data, 0, (short)hssfShape.getXPoints()[i]);
-            LittleEndian.putShort(data, 2, (short)hssfShape.getYPoints()[i]);
-            verticesProp.setElement(i, data);
-        }
-        int point = hssfShape.getXPoints().length;
-        byte[] data = new byte[4];
-        LittleEndian.putShort(data, 0, (short)hssfShape.getXPoints()[0]);
-        LittleEndian.putShort(data, 2, (short)hssfShape.getYPoints()[0]);
-        verticesProp.setElement(point, data);
-        opt.addEscherProperty(verticesProp);
-        EscherArrayProperty segmentsProp = new EscherArrayProperty(EscherProperties.GEOMETRY__SEGMENTINFO, false, null );
-        segmentsProp.setSizeOfElements(0x0002);
-        segmentsProp.setNumberOfElementsInArray(hssfShape.getXPoints().length * 2 + 4);
-        segmentsProp.setNumberOfElementsInMemory(hssfShape.getXPoints().length * 2 + 4);
-        segmentsProp.setElement(0, new byte[] { (byte)0x00, (byte)0x40 } );
-        segmentsProp.setElement(1, new byte[] { (byte)0x00, (byte)0xAC } );
-        for (int i = 0; i < hssfShape.getXPoints().length; i++)
-        {
-            segmentsProp.setElement(2 + i * 2, new byte[] { (byte)0x01, (byte)0x00 } );
-            segmentsProp.setElement(3 + i * 2, new byte[] { (byte)0x00, (byte)0xAC } );
-        }
-        segmentsProp.setElement(segmentsProp.getNumberOfElementsInArray() - 2, new byte[] { (byte)0x01, (byte)0x60 } );
-        segmentsProp.setElement(segmentsProp.getNumberOfElementsInArray() - 1, new byte[] { (byte)0x00, (byte)0x80 } );
-        opt.addEscherProperty(segmentsProp);
-        opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__FILLOK, false, false, 0x00010001));
-        opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINESTARTARROWHEAD, false, false, 0x0));
-        opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEENDARROWHEAD, false, false, 0x0));
-        opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEENDCAPSTYLE, false, false, 0x0));
-
-        addStandardOptions(shape, opt);
-
-        EscherRecord anchor = createAnchor( shape.getAnchor() );
-        clientData.setRecordId( EscherClientDataRecord.RECORD_ID );
-        clientData.setOptions( (short) 0x0000 );
-
-        spContainer.addChildRecord( sp );
-        spContainer.addChildRecord( opt );
-        spContainer.addChildRecord( anchor );
-        spContainer.addChildRecord( clientData );
-
-        return spContainer;
-    }
-
-    /**
-     * Creates the low level OBJ record for this shape.
-     */
-    private ObjRecord createObjRecord( HSSFShape hssfShape, int shapeId )
-    {
-        ObjRecord obj = new ObjRecord();
-        CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();
-        c.setObjectType( OBJECT_TYPE_MICROSOFT_OFFICE_DRAWING );
-        c.setObjectId( getCmoObjectId(shapeId) );
-        c.setLocked( true );
-        c.setPrintable( true );
-        c.setAutofill( true );
-        c.setAutoline( true );
-        EndSubRecord e = new EndSubRecord();
-
-        obj.addSubRecord( c );
-        obj.addSubRecord( e );
-
-        return obj;
-    }
-
-    public EscherContainerRecord getSpContainer()
-    {
-        return spContainer;
-    }
-
-    public ObjRecord getObjRecord()
-    {
-        return objRecord;
-    }
-
-}
diff --git a/src/java/org/apache/poi/hssf/model/SimpleFilledShape.java b/src/java/org/apache/poi/hssf/model/SimpleFilledShape.java
deleted file mode 100644 (file)
index 1763b9d..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/* ====================================================================
-   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.model;
-
-import org.apache.poi.ddf.*;
-import org.apache.poi.hssf.record.ObjRecord;
-import org.apache.poi.hssf.record.EscherAggregate;
-import org.apache.poi.hssf.record.CommonObjectDataSubRecord;
-import org.apache.poi.hssf.record.EndSubRecord;
-import org.apache.poi.hssf.usermodel.HSSFSimpleShape;
-import org.apache.poi.hssf.usermodel.HSSFShape;
-
-@Deprecated
-public class SimpleFilledShape
-        extends AbstractShape
-{
-    private EscherContainerRecord spContainer;
-    private ObjRecord objRecord;
-
-    /**
-     * Creates the low evel records for an oval.
-     *
-     * @param hssfShape  The highlevel shape.
-     * @param shapeId    The shape id to use for this shape.
-     */
-    SimpleFilledShape( HSSFSimpleShape hssfShape, int shapeId )
-    {
-        spContainer = createSpContainer( hssfShape, shapeId );
-        objRecord = createObjRecord( hssfShape, shapeId );
-    }
-
-    /**
-     * Generates the shape records for this shape.
-     *
-     * @param hssfShape
-     * @param shapeId
-     */
-    private EscherContainerRecord createSpContainer( HSSFSimpleShape hssfShape, int shapeId )
-    {
-        HSSFShape shape = hssfShape;
-
-        EscherContainerRecord spContainer = new EscherContainerRecord();
-        EscherSpRecord sp = new EscherSpRecord();
-        EscherOptRecord opt = new EscherOptRecord();
-        EscherClientDataRecord clientData = new EscherClientDataRecord();
-
-        spContainer.setRecordId( EscherContainerRecord.SP_CONTAINER );
-        spContainer.setOptions( (short) 0x000F );
-        sp.setRecordId( EscherSpRecord.RECORD_ID );
-        short shapeType = objTypeToShapeType( hssfShape.getShapeType() );
-        sp.setOptions( (short) ( ( shapeType << 4 ) | 0x2 ) );
-        sp.setShapeId( shapeId );
-        sp.setFlags( EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE );
-        opt.setRecordId( EscherOptRecord.RECORD_ID );
-        addStandardOptions(shape, opt);
-        EscherRecord anchor = createAnchor( shape.getAnchor() );
-        clientData.setRecordId( EscherClientDataRecord.RECORD_ID );
-        clientData.setOptions( (short) 0x0000 );
-
-        spContainer.addChildRecord( sp );
-        spContainer.addChildRecord( opt );
-        spContainer.addChildRecord( anchor );
-        spContainer.addChildRecord( clientData );
-
-        return spContainer;
-    }
-
-    private short objTypeToShapeType( int objType )
-    {
-        short shapeType;
-        if (objType == HSSFSimpleShape.OBJECT_TYPE_OVAL)
-            shapeType = EscherAggregate.ST_ELLIPSE;
-        else if (objType == HSSFSimpleShape.OBJECT_TYPE_RECTANGLE)
-            shapeType = EscherAggregate.ST_RECTANGLE;
-        else
-            throw new IllegalArgumentException("Unable to handle an object of this type");
-        return shapeType;
-    }
-
-    /**
-     * Creates the low level OBJ record for this shape.
-     */
-    private ObjRecord createObjRecord( HSSFShape hssfShape, int shapeId )
-    {
-        HSSFShape shape = hssfShape;
-
-        ObjRecord obj = new ObjRecord();
-        CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();
-        c.setObjectType( (short) ( (HSSFSimpleShape) shape ).getShapeType() );
-        c.setObjectId(  getCmoObjectId(shapeId) );
-        c.setLocked( true );
-        c.setPrintable( true );
-        c.setAutofill( true );
-        c.setAutoline( true );
-        EndSubRecord e = new EndSubRecord();
-
-        obj.addSubRecord( c );
-        obj.addSubRecord( e );
-
-        return obj;
-    }
-
-    public EscherContainerRecord getSpContainer()
-    {
-        return spContainer;
-    }
-
-    public ObjRecord getObjRecord()
-    {
-        return objRecord;
-    }
-
-}
diff --git a/src/java/org/apache/poi/hssf/model/TextboxShape.java b/src/java/org/apache/poi/hssf/model/TextboxShape.java
deleted file mode 100644 (file)
index d4379fd..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-/* ====================================================================
-   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.model;
-
-import org.apache.poi.ddf.*;
-import org.apache.poi.hssf.record.*;
-import org.apache.poi.hssf.usermodel.*;
-
-/**
- * Represents an textbox shape and converts between the highlevel records
- * and lowlevel records for an oval.
- */
-@Deprecated
-public class TextboxShape
-        extends AbstractShape
-{
-    private EscherContainerRecord spContainer;
-    private TextObjectRecord textObjectRecord;
-    private ObjRecord objRecord;
-    private EscherTextboxRecord escherTextbox;
-
-    /**
-     * Creates the low evel records for an textbox.
-     *
-     * @param hssfShape  The highlevel shape.
-     * @param shapeId    The shape id to use for this shape.
-     */
-    TextboxShape( HSSFTextbox hssfShape, int shapeId )
-    {
-        spContainer = createSpContainer( hssfShape, shapeId );
-        objRecord = createObjRecord( hssfShape, shapeId );
-        textObjectRecord = createTextObjectRecord( hssfShape, shapeId );
-    }
-
-    /**
-     * Creates the low level OBJ record for this shape.
-     */
-    private ObjRecord createObjRecord( HSSFTextbox hssfShape, int shapeId )
-    {
-        HSSFShape shape = hssfShape;
-
-        ObjRecord obj = new ObjRecord();
-        CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();
-        c.setObjectType( (short) ( (HSSFSimpleShape) shape ).getShapeType() );
-        c.setObjectId( getCmoObjectId(shapeId) );
-        c.setLocked( true );
-        c.setPrintable( true );
-        c.setAutofill( true );
-        c.setAutoline( true );
-        EndSubRecord e = new EndSubRecord();
-
-        obj.addSubRecord( c );
-        obj.addSubRecord( e );
-
-        return obj;
-    }
-
-    /**
-     * Generates the escher shape records for this shape.
-     *
-     * @param hssfShape
-     * @param shapeId
-     */
-    private EscherContainerRecord createSpContainer( HSSFTextbox hssfShape, int shapeId )
-    {
-        HSSFTextbox shape = hssfShape;
-
-        EscherContainerRecord spContainer = new EscherContainerRecord();
-        EscherSpRecord sp = new EscherSpRecord();
-        EscherOptRecord opt = new EscherOptRecord();
-        EscherClientDataRecord clientData = new EscherClientDataRecord();
-        escherTextbox = new EscherTextboxRecord();
-
-        spContainer.setRecordId( EscherContainerRecord.SP_CONTAINER );
-        spContainer.setOptions( (short) 0x000F );
-        sp.setRecordId( EscherSpRecord.RECORD_ID );
-        sp.setOptions( (short) ( ( EscherAggregate.ST_TEXTBOX << 4 ) | 0x2 ) );
-
-        sp.setShapeId( shapeId );
-        sp.setFlags( EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE );
-        opt.setRecordId( EscherOptRecord.RECORD_ID );
-        //        opt.addEscherProperty( new EscherBoolProperty( EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 262144 ) );
-        opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.TEXT__TEXTID, 0 ) );
-        opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.TEXT__TEXTLEFT, shape.getMarginLeft() ) );
-        opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.TEXT__TEXTRIGHT, shape.getMarginRight() ) );
-        opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.TEXT__TEXTBOTTOM, shape.getMarginBottom() ) );
-        opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.TEXT__TEXTTOP, shape.getMarginTop() ) );
-
-        opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.TEXT__WRAPTEXT, 0 ) );
-        opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.TEXT__ANCHORTEXT, 0 ) );
-        opt.addEscherProperty( new EscherSimpleProperty( EscherProperties.GROUPSHAPE__PRINT, 0x00080000 ) );
-
-        addStandardOptions( shape, opt );
-        HSSFAnchor userAnchor = shape.getAnchor();
-        //        if (userAnchor.isHorizontallyFlipped())
-        //            sp.setFlags(sp.getFlags() | EscherSpRecord.FLAG_FLIPHORIZ);
-        //        if (userAnchor.isVerticallyFlipped())
-        //            sp.setFlags(sp.getFlags() | EscherSpRecord.FLAG_FLIPVERT);
-        EscherRecord anchor = createAnchor( userAnchor );
-        clientData.setRecordId( EscherClientDataRecord.RECORD_ID );
-        clientData.setOptions( (short) 0x0000 );
-        escherTextbox.setRecordId( EscherTextboxRecord.RECORD_ID );
-        escherTextbox.setOptions( (short) 0x0000 );
-
-        spContainer.addChildRecord( sp );
-        spContainer.addChildRecord( opt );
-        spContainer.addChildRecord( anchor );
-        spContainer.addChildRecord( clientData );
-        spContainer.addChildRecord( escherTextbox );
-
-        return spContainer;
-    }
-
-    /**
-     * Textboxes also have an extra TXO record associated with them that most
-     * other shapes dont have.
-     */
-    private TextObjectRecord createTextObjectRecord( HSSFTextbox hssfShape, int shapeId )
-    {
-        HSSFTextbox shape = hssfShape;
-
-        TextObjectRecord obj = new TextObjectRecord();
-        obj.setHorizontalTextAlignment(hssfShape.getHorizontalAlignment());
-        obj.setVerticalTextAlignment(hssfShape.getVerticalAlignment());
-        obj.setTextLocked(true);
-        obj.setTextOrientation(TextObjectRecord.TEXT_ORIENTATION_NONE);
-        obj.setStr(shape.getString());
-
-        return obj;
-    }
-
-    public EscherContainerRecord getSpContainer()
-    {
-        return spContainer;
-    }
-
-    public ObjRecord getObjRecord()
-    {
-        return objRecord;
-    }
-
-    public TextObjectRecord getTextObjectRecord()
-    {
-        return textObjectRecord;
-    }
-
-    public EscherRecord getEscherTextbox()
-    {
-        return escherTextbox;
-    }
-
-}
index 91b9fb7524e6dfcbc46b599f9c6dd433f6b7cf42..5e91b18e7866b774165893f9103944d1633d5c9c 100644 (file)
@@ -160,7 +160,7 @@ public class LbsDataSubRecord extends SubRecord {
     /**\r
      *\r
      * @return a new instance of LbsDataSubRecord to construct auto-filters\r
-     * @see org.apache.poi.hssf.model.ComboboxShape#createObjRecord(org.apache.poi.hssf.usermodel.HSSFSimpleShape, int)\r
+     * @see org.apache.poi.hssf.usermodel.HSSFCombobox\r
      */\r
     public static LbsDataSubRecord newAutoFilterInstance(){\r
         LbsDataSubRecord lbs = new LbsDataSubRecord();\r
@@ -330,7 +330,7 @@ public class LbsDataSubRecord extends SubRecord {
         /**\r
          * a string that specifies the current string value in the dropdown\r
          */\r
-        private String _str;\r
+        private final String _str;\r
 \r
         /**\r
          * Optional, undefined and MUST be ignored.\r
index dbdd741548b941fe98888230d9a8c2e3fff98a66..dc31858fefe7d1f673b59531c09ba61fe6fe8f34 100644 (file)
@@ -143,7 +143,12 @@ public abstract class HSSFShape {
         return _objRecord;
     }
 
-    protected EscherOptRecord getOptRecord() {
+    /**
+     * Return the low-level EscherOptRecord to read/modify not yet wrapped escher properties  
+     *
+     * @return the low-level EscherOptRecord
+     */
+    public EscherOptRecord getOptRecord() {
         return _optRecord;
     }
 
diff --git a/src/testcases/org/apache/poi/hssf/model/HSSFTestModelHelper.java b/src/testcases/org/apache/poi/hssf/model/HSSFTestModelHelper.java
deleted file mode 100644 (file)
index 10acb70..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/* ====================================================================\r
-   Licensed to the Apache Software Foundation (ASF) under one or more\r
-   contributor license agreements.  See the NOTICE file distributed with\r
-   this work for additional information regarding copyright ownership.\r
-   The ASF licenses this file to You under the Apache License, Version 2.0\r
-   (the "License"); you may not use this file except in compliance with\r
-   the License.  You may obtain a copy of the License at\r
-\r
-       http://www.apache.org/licenses/LICENSE-2.0\r
-\r
-   Unless required by applicable law or agreed to in writing, software\r
-   distributed under the License is distributed on an "AS IS" BASIS,\r
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-   See the License for the specific language governing permissions and\r
-   limitations under the License.\r
-==================================================================== */\r
-\r
-package org.apache.poi.hssf.model;\r
-\r
-import org.apache.poi.hssf.usermodel.HSSFComment;\r
-import org.apache.poi.hssf.usermodel.HSSFPolygon;\r
-import org.apache.poi.hssf.usermodel.HSSFTextbox;\r
-\r
-/**\r
- * @author Evgeniy Berlog\r
- * @date 25.06.12\r
- */\r
-public class HSSFTestModelHelper {\r
-    public static TextboxShape createTextboxShape(int shapeId, HSSFTextbox textbox){\r
-        return new TextboxShape(textbox, shapeId);\r
-    }\r
-\r
-    public static CommentShape createCommentShape(int shapeId, HSSFComment comment){\r
-        return new CommentShape(comment, shapeId);\r
-    }\r
-\r
-    public static PolygonShape createPolygonShape(int shapeId, HSSFPolygon polygon){\r
-        return new PolygonShape(polygon, shapeId);\r
-    }\r
-}\r
index df03e33fa3d625b9044164a85e98d38c899a5b74..70e7c7db63fff8143480ac3718bf627e2ccd89d4 100644 (file)
@@ -224,8 +224,7 @@ public class TestDrawingAggregate {
             "H4sIAAAAAAAAAGWOOw7CQAxE32YTsSRIWSgQJSUloqSm5g4ICURBg+iBK3APGi6wBWeh9xGYbEps2WON"+\r
             "P+OWwpYeIsECMFC8S2jxNvMdlrYQ5xha5N8K6ryHdir6+avwOer5l3hq2NPYWuWN0n1dIsgfbgshuSj1"+\r
             "+2eqbvLdxQ0ndhy5KJ/lc1ZZK9okY5X/gSbrHZTH1vE/ozagTcwAAAA=";\r
-        byte[] base64Bytes = DatatypeConverter.parseBase64Binary(data);\r
-        byte[] dgBytes = IOUtils.toByteArray(new GZIPInputStream(new ByteArrayInputStream(base64Bytes)));\r
+        byte[] dgBytes = decompress(data);\r
 \r
         List<EscherRecord> records = new ArrayList<EscherRecord>();\r
         EscherRecordFactory recordFactory = new DefaultEscherRecordFactory();\r
@@ -725,8 +724,7 @@ public class TestDrawingAggregate {
             "IppKQdVys+cLtUY6Un0+hI2Z0wMzAxO8Lr0LbaILk8WtNsxpaFYMrTjC22723OH5GFkUi+ux8An2Hi0F"+\r
             "fvcr1v8aFU6POn+OCqfj4ffS/e+pcOEMKhABrCdUAAPhwB+pQHYGFcT/BBUEz6LC/wGpc+eRNSkAAA==";\r
 \r
-        byte[] base64Bytes = DatatypeConverter.parseBase64Binary(data);\r
-        byte[] dgBytes = IOUtils.toByteArray(new GZIPInputStream(new ByteArrayInputStream(base64Bytes)));\r
+        byte[] dgBytes = decompress(data);\r
         List<Record> dgRecords = RecordFactory.createRecords(new ByteArrayInputStream(dgBytes));\r
         assertEquals(20, dgRecords.size());\r
 \r
@@ -904,8 +902,7 @@ public class TestDrawingAggregate {
             "p9IQmzVDjm0LdSLqeHM8ILiJRsdoNYS93WyEhi7IOdKXZLTCvCLifxTMEi+snNzAtfevk8DpkejvSeB0"+\r
             "BPza/oPKABD5z4SARKQEELP1WQsFMc+QwP8ATkmhK404AAA=";\r
 \r
-        byte[] base64Bytes = DatatypeConverter.parseBase64Binary(data);\r
-        byte[] dgBytes = IOUtils.toByteArray(new GZIPInputStream(new ByteArrayInputStream(base64Bytes)));\r
+        byte[] dgBytes = decompress(data);\r
         List<Record> dgRecords = RecordFactory.createRecords(new ByteArrayInputStream(dgBytes));\r
         assertEquals(14, dgRecords.size());\r
 \r
@@ -950,4 +947,31 @@ public class TestDrawingAggregate {
         assertTrue("drawing data brefpore and after save is different", Arrays.equals(dgBytes, dgBytesAfterSave));\r
     }\r
 \r
+\r
+    /**\r
+     * Decompress previously gziped/base64ed data\r
+     *\r
+     * @param data the gziped/base64ed data\r
+     * @return the raw bytes\r
+     * @throws IOException if you copy and pasted the data wrong\r
+     */\r
+    public static byte[] decompress(String data) throws IOException {\r
+        byte[] base64Bytes = DatatypeConverter.parseBase64Binary(data);\r
+        return IOUtils.toByteArray(new GZIPInputStream(new ByteArrayInputStream(base64Bytes)));\r
+    }\r
+    \r
+    /**\r
+     * Compress raw data for test runs - usually called while debugging :)\r
+     *\r
+     * @param data the raw data\r
+     * @return the gziped/base64ed data as String\r
+     * @throws IOException usually not ...\r
+     */\r
+    public static String compress(byte[] data) throws IOException {\r
+        java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();\r
+        java.util.zip.GZIPOutputStream gz = new java.util.zip.GZIPOutputStream(bos);\r
+        gz.write(data);\r
+        gz.finish();\r
+        return DatatypeConverter.printBase64Binary(bos.toByteArray());        \r
+    }\r
 }\r
index b21806a57cfb1f6631b7a3f432eb592b96f57210..7c817833313f2d59efb3b7f02943c51ee62d4efb 100644 (file)
@@ -20,6 +20,7 @@ package org.apache.poi.hssf.model;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
 
@@ -103,23 +104,14 @@ public class TestDrawingShapes {
         assertEquals(HSSFShape.LINEWIDTH_DEFAULT, shape.getLineWidth());
         assertEquals(HSSFShape.LINESTYLE_SOLID, shape.getLineStyle());
         assertFalse(shape.isNoFill());
-
-        AbstractShape sp = AbstractShape.createShape(shape, 1);
-        EscherContainerRecord spContainer = sp.getSpContainer();
-        EscherOptRecord opt =
-                spContainer.getChildById(EscherOptRecord.RECORD_ID);
+        
+        EscherOptRecord opt = shape.getOptRecord();
 
         assertEquals(7, opt.getEscherProperties().size());
-        assertTrue(((EscherBoolProperty) opt.lookup(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE)).isTrue());
-        assertEquals(0x00000004,
-                ((EscherSimpleProperty) opt.lookup(EscherProperties.GEOMETRY__SHAPEPATH)).getPropertyValue());
-        assertEquals(0x08000009,
-                ((EscherSimpleProperty) opt.lookup(EscherProperties.FILL__FILLCOLOR)).getPropertyValue());
-        assertTrue(((EscherBoolProperty) opt.lookup(EscherProperties.FILL__NOFILLHITTEST)).isTrue());
-        assertEquals(0x08000040,
-                ((EscherSimpleProperty) opt.lookup(EscherProperties.LINESTYLE__COLOR)).getPropertyValue());
-        assertTrue(((EscherBoolProperty) opt.lookup(EscherProperties.LINESTYLE__NOLINEDRAWDASH)).isTrue());
         assertTrue(((EscherBoolProperty) opt.lookup(EscherProperties.GROUPSHAPE__PRINT)).isTrue());
+        assertTrue(((EscherBoolProperty) opt.lookup(EscherProperties.LINESTYLE__NOLINEDRAWDASH)).isTrue());
+        assertEquals(0x00000004, ((EscherSimpleProperty) opt.lookup(EscherProperties.GEOMETRY__SHAPEPATH)).getPropertyValue());
+        assertNull(opt.lookup(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE));
     }
 
     @Test
diff --git a/src/testcases/org/apache/poi/hssf/model/TestShapes.java b/src/testcases/org/apache/poi/hssf/model/TestShapes.java
deleted file mode 100644 (file)
index beed4a1..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- *  ====================================================================
- *    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.model;
-
-import junit.framework.TestCase;
-
-import org.apache.poi.hssf.record.CommonObjectDataSubRecord;
-import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
-import org.apache.poi.hssf.usermodel.HSSFComment;
-import org.apache.poi.hssf.usermodel.HSSFPicture;
-import org.apache.poi.hssf.usermodel.HSSFTextbox;
-
-/**
- *
- * @author Yegor Kozlov
- */
-public final class TestShapes extends TestCase {
-
-    /**
-     * Test generator of ids for the CommonObjectDataSubRecord record.
-     *
-     * See Bug 51332
-     */
-    @SuppressWarnings("deprecation")
-       public void testShapeId(){
-
-        HSSFClientAnchor anchor = new HSSFClientAnchor();
-        AbstractShape shape;
-        CommonObjectDataSubRecord cmo;
-
-        shape = new TextboxShape(new HSSFTextbox(null, anchor), 1025);
-        cmo = (CommonObjectDataSubRecord)shape.getObjRecord().getSubRecords().get(0);
-        assertEquals(1, cmo.getObjectId());
-
-        shape = new PictureShape(new HSSFPicture(null, anchor), 1026);
-        cmo = (CommonObjectDataSubRecord)shape.getObjRecord().getSubRecords().get(0);
-        assertEquals(2, cmo.getObjectId());
-
-        shape = new CommentShape(new HSSFComment(null, anchor), 1027);
-        cmo = (CommonObjectDataSubRecord)shape.getObjRecord().getSubRecords().get(0);
-        assertEquals(1027, cmo.getObjectId());
-    }
-}
index 7ccae676bdcf76df56fff874857040154d383249..a65721151be37754abdc95eb5bfc8461489da6b4 100644 (file)
@@ -51,6 +51,7 @@ import org.apache.poi.hssf.extractor.ExcelExtractor;
 import org.apache.poi.hssf.model.InternalSheet;
 import org.apache.poi.hssf.model.InternalWorkbook;
 import org.apache.poi.hssf.record.CellValueRecordInterface;
+import org.apache.poi.hssf.record.CommonObjectDataSubRecord;
 import org.apache.poi.hssf.record.EmbeddedObjectRefSubRecord;
 import org.apache.poi.hssf.record.NameRecord;
 import org.apache.poi.hssf.record.Record;
@@ -3009,4 +3010,29 @@ public final class TestBugs extends BaseTestBugzillaIssues {
         assertNotNull(newSheet);
         wb.close();
     }
+
+    /**
+     * Test generator of ids for the CommonObjectDataSubRecord record.
+     */
+    @Test
+    public void test51332() {
+        HSSFClientAnchor anchor = new HSSFClientAnchor();
+        HSSFSimpleShape shape;
+        CommonObjectDataSubRecord cmo;
+        
+        shape = new HSSFTextbox(null, anchor);
+        shape.setShapeId(1025);
+        cmo = (CommonObjectDataSubRecord)shape.getObjRecord().getSubRecords().get(0);
+        assertEquals(1, cmo.getObjectId());
+
+        shape = new HSSFPicture(null, anchor);
+        shape.setShapeId(1026);
+        cmo = (CommonObjectDataSubRecord)shape.getObjRecord().getSubRecords().get(0);
+        assertEquals(2, cmo.getObjectId());
+
+        shape = new HSSFComment(null, anchor);
+        shape.setShapeId(1027);
+        cmo = (CommonObjectDataSubRecord)shape.getObjRecord().getSubRecords().get(0);
+        assertEquals(1027, cmo.getObjectId());
+    }
 }
index ac6507034027e320fb292d3f71729bb631e55ce4..9e40695b4b8370b64bfb061ee709a95fea3eb8f8 100644 (file)
@@ -16,6 +16,7 @@
 ==================================================================== */
 package org.apache.poi.hssf.usermodel;
 
+import static org.apache.poi.hssf.model.TestDrawingAggregate.decompress;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -26,8 +27,6 @@ import java.io.IOException;
 import org.apache.poi.ddf.EscherSpRecord;
 import org.apache.poi.hssf.HSSFITestDataProvider;
 import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.hssf.model.CommentShape;
-import org.apache.poi.hssf.model.HSSFTestModelHelper;
 import org.apache.poi.hssf.record.CommonObjectDataSubRecord;
 import org.apache.poi.hssf.record.EscherAggregate;
 import org.apache.poi.hssf.record.NoteRecord;
@@ -66,7 +65,7 @@ public final class TestHSSFComment extends BaseTestCellComment {
      * when matching cells and their cell comments. The correct algorithm is to map
      */
     @Test
-    public void bug47924() {
+    public void bug47924() throws IOException {
         HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("47924.xls");
         HSSFSheet sheet = wb.getSheetAt(0);
         HSSFCell cell;
@@ -95,6 +94,8 @@ public final class TestHSSFComment extends BaseTestCellComment {
         cell = sheet.getRow(5).getCell(2);
         comment = cell.getCellComment();
         assertEquals("c6", comment.getString().getString());
+        
+        wb.close();
     }
     
     @Test
@@ -202,7 +203,7 @@ public final class TestHSSFComment extends BaseTestCellComment {
     }
     
     @Test
-    public void resultEqualsToAbstractShape() throws IOException {
+    public void resultEqualsToNonExistingAbstractShape() throws IOException {
         HSSFWorkbook wb = new HSSFWorkbook();
         HSSFSheet sh = wb.createSheet();
         HSSFPatriarch patriarch = sh.createDrawingPatriarch();
@@ -212,59 +213,53 @@ public final class TestHSSFComment extends BaseTestCellComment {
         HSSFCell cell = row.createCell(0);
         cell.setCellComment(comment);
 
-        CommentShape commentShape = HSSFTestModelHelper.createCommentShape(1025, comment);
-
         assertEquals(comment.getEscherContainer().getChildRecords().size(), 5);
-        assertEquals(commentShape.getSpContainer().getChildRecords().size(), 5);
 
         //sp record
-        byte[] expected = commentShape.getSpContainer().getChild(0).serialize();
+        byte[] expected = decompress("H4sIAAAAAAAAAFvEw/WBg4GBgZEFSHAxMAAA9gX7nhAAAAA=");
         byte[] actual = comment.getEscherContainer().getChild(0).serialize();
 
         assertEquals(expected.length, actual.length);
         assertArrayEquals(expected, actual);
 
-        expected = commentShape.getSpContainer().getChild(2).serialize();
+        expected = decompress("H4sIAAAAAAAAAGNgEPggxIANAABK4+laGgAAAA==");
         actual = comment.getEscherContainer().getChild(2).serialize();
 
         assertEquals(expected.length, actual.length);
         assertArrayEquals(expected, actual);
 
-        expected = commentShape.getSpContainer().getChild(3).serialize();
+        expected = decompress("H4sIAAAAAAAAAGNgEPzAAAQACl6c5QgAAAA=");
         actual = comment.getEscherContainer().getChild(3).serialize();
 
         assertEquals(expected.length, actual.length);
         assertArrayEquals(expected, actual);
 
-        expected = commentShape.getSpContainer().getChild(4).serialize();
+        expected = decompress("H4sIAAAAAAAAAGNg4P3AAAQA6pyIkQgAAAA=");
         actual = comment.getEscherContainer().getChild(4).serialize();
 
         assertEquals(expected.length, actual.length);
         assertArrayEquals(expected, actual);
 
         ObjRecord obj = comment.getObjRecord();
-        ObjRecord objShape = commentShape.getObjRecord();
 
-        expected = obj.serialize();
-        actual = objShape.serialize();
+        expected = decompress("H4sIAAAAAAAAAItlMGEQZRBikGRgZBF0YEACvAxiDLgBAJZsuoU4AAAA");
+        actual = obj.serialize();
 
         assertEquals(expected.length, actual.length);
         //assertArrayEquals(expected, actual);
 
         TextObjectRecord tor = comment.getTextObjectRecord();
-        TextObjectRecord torShape = commentShape.getTextObjectRecord();
 
-        expected = tor.serialize();
-        actual = torShape.serialize();
+        expected = decompress("H4sIAAAAAAAAANvGKMQgxMSABgBGi8T+FgAAAA==");
+        actual = tor.serialize();
 
         assertEquals(expected.length, actual.length);
         assertArrayEquals(expected, actual);
 
         NoteRecord note = comment.getNoteRecord();
-        NoteRecord noteShape = commentShape.getNoteRecord();
 
-        expected = note.serialize();
-        actual = noteShape.serialize();
+        expected = decompress("H4sIAAAAAAAAAJNh4GGAAEYWEAkAS0KXuRAAAAA=");
+        actual = note.serialize();
 
         assertEquals(expected.length, actual.length);
         assertArrayEquals(expected, actual);
@@ -376,7 +371,7 @@ public final class TestHSSFComment extends BaseTestCellComment {
     }
 
     @Test
-    public void existingFileWithComment(){
+    public void existingFileWithComment() throws IOException {
         HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("drawings.xls");
         HSSFSheet sheet = wb.getSheet("comments");
         HSSFPatriarch drawing = sheet.getDrawingPatriarch();
@@ -386,6 +381,7 @@ public final class TestHSSFComment extends BaseTestCellComment {
         assertEquals(comment.getString().getString(), "evgeniy:\npoi test");
         assertEquals(comment.getColumn(), 1);
         assertEquals(comment.getRow(), 2);
+        wb.close();
     }
 
     @Test
@@ -399,8 +395,6 @@ public final class TestHSSFComment extends BaseTestCellComment {
         HSSFCell cell = row.createCell(4);
         cell.setCellComment(comment);
 
-        HSSFTestModelHelper.createCommentShape(0, comment);
-
         assertNotNull(sh.findCellComment(5, 4));
         assertNull(sh.findCellComment(5, 5));
 
index bcaf4774939b2999447a12c81b4758765f53de98..6174a5ff304ef9213bd6e12b2b300f4b599225bb 100644 (file)
 \r
 package org.apache.poi.hssf.usermodel;\r
 \r
+import static org.apache.poi.hssf.model.TestDrawingAggregate.decompress;\r
 import static org.junit.Assert.assertArrayEquals;\r
+import static org.junit.Assert.assertEquals;\r
+import static org.junit.Assert.assertTrue;\r
 \r
 import java.io.IOException;\r
 \r
-import junit.framework.TestCase;\r
-\r
 import org.apache.poi.ddf.EscherArrayProperty;\r
-import org.apache.poi.ddf.EscherOptRecord;\r
 import org.apache.poi.ddf.EscherProperties;\r
 import org.apache.poi.ddf.EscherSpRecord;\r
 import org.apache.poi.hssf.HSSFTestDataSamples;\r
-import org.apache.poi.hssf.model.HSSFTestModelHelper;\r
-import org.apache.poi.hssf.model.PolygonShape;\r
 import org.apache.poi.hssf.record.ObjRecord;\r
+import org.junit.Test;\r
 \r
-/**\r
- * @author Evgeniy Berlog\r
- * @date 28.06.12\r
- */\r
-public class TestPolygon extends TestCase{\r
-\r
+public class TestPolygon {\r
+    @Test\r
     public void testResultEqualsToAbstractShape() throws IOException {\r
         HSSFWorkbook wb = new HSSFWorkbook();\r
         HSSFSheet sh = wb.createSheet();\r
@@ -46,42 +41,42 @@ public class TestPolygon extends TestCase{
         HSSFPolygon polygon = patriarch.createPolygon(new HSSFClientAnchor());\r
         polygon.setPolygonDrawArea( 100, 100 );\r
         polygon.setPoints( new int[]{0, 90, 50}, new int[]{5, 5, 44} );\r
-        PolygonShape polygonShape = HSSFTestModelHelper.createPolygonShape(1024, polygon);\r
         polygon.setShapeId(1024);\r
 \r
         assertEquals(polygon.getEscherContainer().getChildRecords().size(), 4);\r
-        assertEquals(polygonShape.getSpContainer().getChildRecords().size(), 4);\r
 \r
         //sp record\r
-        byte[] expected = polygonShape.getSpContainer().getChild(0).serialize();\r
+        byte[] expected = decompress("H4sIAAAAAAAAAGNi4PrAwQAELEDMxcAAAAU6ZlwQAAAA");\r
         byte[] actual = polygon.getEscherContainer().getChild(0).serialize();\r
 \r
         assertEquals(expected.length, actual.length);\r
         assertArrayEquals(expected, actual);\r
 \r
-        expected = polygonShape.getSpContainer().getChild(2).serialize();\r
+        expected = decompress("H4sIAAAAAAAAAGNgEPggxIANAABK4+laGgAAAA==");\r
         actual = polygon.getEscherContainer().getChild(2).serialize();\r
 \r
         assertEquals(expected.length, actual.length);\r
         assertArrayEquals(expected, actual);\r
 \r
-        expected = polygonShape.getSpContainer().getChild(3).serialize();\r
+        expected = decompress("H4sIAAAAAAAAAGNgEPzAAAQACl6c5QgAAAA=");\r
         actual = polygon.getEscherContainer().getChild(3).serialize();\r
 \r
         assertEquals(expected.length, actual.length);\r
         assertArrayEquals(expected, actual);\r
 \r
         ObjRecord obj = polygon.getObjRecord();\r
-        ObjRecord objShape = polygonShape.getObjRecord();\r
 \r
-        expected = obj.serialize();\r
-        actual = objShape.serialize();\r
+        expected = decompress("H4sIAAAAAAAAAItlkGIQZRBikGNgYBBMYEADAOAV/ZkeAAAA");\r
+        actual = obj.serialize();\r
 \r
         assertEquals(expected.length, actual.length);\r
         assertArrayEquals(expected, actual);\r
+        \r
+        wb.close();\r
     }\r
 \r
-    public void testPolygonPoints(){\r
+    @Test\r
+    public void testPolygonPoints() throws IOException {\r
         HSSFWorkbook wb = new HSSFWorkbook();\r
         HSSFSheet sh = wb.createSheet();\r
         HSSFPatriarch patriarch = sh.createDrawingPatriarch();\r
@@ -90,31 +85,46 @@ public class TestPolygon extends TestCase{
         polygon.setPolygonDrawArea( 100, 100 );\r
         polygon.setPoints( new int[]{0, 90, 50, 90}, new int[]{5, 5, 44, 88} );\r
 \r
-        PolygonShape polygonShape = HSSFTestModelHelper.createPolygonShape(0, polygon);\r
-\r
         EscherArrayProperty verticesProp1 = polygon.getOptRecord().lookup(EscherProperties.GEOMETRY__VERTICES);\r
-        EscherArrayProperty verticesProp2 = ((EscherOptRecord)polygonShape.getSpContainer().getChildById(EscherOptRecord.RECORD_ID))\r
-                .lookup(EscherProperties.GEOMETRY__VERTICES);\r
 \r
-        assertEquals(verticesProp1.getNumberOfElementsInArray(), verticesProp2.getNumberOfElementsInArray());\r
-        assertEquals(verticesProp1.toXml(""), verticesProp2.toXml(""));\r
+        String expected =\r
+            "<EscherArrayProperty id=\"0x8145\" name=\"geometry.vertices\" blipId=\"false\">"+\r
+            "<Element>[00, 00, 05, 00]</Element>"+\r
+            "<Element>[5A, 00, 05, 00]</Element>"+\r
+            "<Element>[32, 00, 2C, 00]</Element>"+\r
+            "<Element>[5A, 00, 58, 00]</Element>"+\r
+            "<Element>[00, 00, 05, 00]</Element>"+\r
+            "</EscherArrayProperty>";\r
+        String actual = verticesProp1.toXml("").replaceAll("[\r\n\t]","");\r
+        \r
+        assertEquals(verticesProp1.getNumberOfElementsInArray(), 5);\r
+        assertEquals(expected, actual);\r
         \r
         polygon.setPoints(new int[]{1,2,3}, new int[] {4,5,6});\r
         assertArrayEquals(polygon.getXPoints(), new int[]{1, 2, 3});\r
         assertArrayEquals(polygon.getYPoints(), new int[]{4, 5, 6});\r
 \r
-        polygonShape = HSSFTestModelHelper.createPolygonShape(0, polygon);\r
         verticesProp1 = polygon.getOptRecord().lookup(EscherProperties.GEOMETRY__VERTICES);\r
-        verticesProp2 = ((EscherOptRecord)polygonShape.getSpContainer().getChildById(EscherOptRecord.RECORD_ID))\r
-                .lookup(EscherProperties.GEOMETRY__VERTICES);\r
 \r
-        assertEquals(verticesProp1.getNumberOfElementsInArray(), verticesProp2.getNumberOfElementsInArray());\r
-        assertEquals(verticesProp1.toXml(""), verticesProp2.toXml(""));\r
+        expected =\r
+            "<EscherArrayProperty id=\"0x8145\" name=\"geometry.vertices\" blipId=\"false\">" +\r
+            "<Element>[01, 00, 04, 00]</Element>" +\r
+            "<Element>[02, 00, 05, 00]</Element>" +\r
+            "<Element>[03, 00, 06, 00]</Element>" +\r
+            "<Element>[01, 00, 04, 00]</Element>" +\r
+            "</EscherArrayProperty>";\r
+        actual = verticesProp1.toXml("").replaceAll("[\r\n\t]","");\r
+        \r
+        assertEquals(verticesProp1.getNumberOfElementsInArray(), 4);\r
+        assertEquals(expected, actual);\r
+        \r
+        wb.close();\r
     }\r
 \r
-    public void testSetGetProperties(){\r
-        HSSFWorkbook wb = new HSSFWorkbook();\r
-        HSSFSheet sh = wb.createSheet();\r
+    @Test\r
+    public void testSetGetProperties() throws IOException {\r
+        HSSFWorkbook wb1 = new HSSFWorkbook();\r
+        HSSFSheet sh = wb1.createSheet();\r
         HSSFPatriarch patriarch = sh.createDrawingPatriarch();\r
 \r
         HSSFPolygon polygon = patriarch.createPolygon(new HSSFClientAnchor());\r
@@ -126,8 +136,9 @@ public class TestPolygon extends TestCase{
         assertEquals(polygon.getDrawAreaHeight(), 101);\r
         assertEquals(polygon.getDrawAreaWidth(), 102);\r
 \r
-        wb = HSSFTestDataSamples.writeOutAndReadBack(wb);\r
-        sh = wb.getSheetAt(0);\r
+        HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);\r
+        wb1.close();\r
+        sh = wb2.getSheetAt(0);\r
         patriarch = sh.getDrawingPatriarch();\r
 \r
         polygon = (HSSFPolygon) patriarch.getChildren().get(0);\r
@@ -144,8 +155,9 @@ public class TestPolygon extends TestCase{
         assertEquals(polygon.getDrawAreaHeight(), 1011);\r
         assertEquals(polygon.getDrawAreaWidth(), 1021);\r
 \r
-        wb = HSSFTestDataSamples.writeOutAndReadBack(wb);\r
-        sh = wb.getSheetAt(0);\r
+        HSSFWorkbook wb3 = HSSFTestDataSamples.writeOutAndReadBack(wb2);\r
+        wb2.close();\r
+        sh = wb3.getSheetAt(0);\r
         patriarch = sh.getDrawingPatriarch();\r
 \r
         polygon = (HSSFPolygon) patriarch.getChildren().get(0);\r
@@ -154,11 +166,14 @@ public class TestPolygon extends TestCase{
         assertArrayEquals(polygon.getYPoints(), new int[]{41, 51, 61});\r
         assertEquals(polygon.getDrawAreaHeight(), 1011);\r
         assertEquals(polygon.getDrawAreaWidth(), 1021);\r
+        \r
+        wb3.close();\r
     }\r
 \r
-    public void testAddToExistingFile(){\r
-        HSSFWorkbook wb = new HSSFWorkbook();\r
-        HSSFSheet sh = wb.createSheet();\r
+    @Test\r
+    public void testAddToExistingFile() throws IOException {\r
+        HSSFWorkbook wb1 = new HSSFWorkbook();\r
+        HSSFSheet sh = wb1.createSheet();\r
         HSSFPatriarch patriarch = sh.createDrawingPatriarch();\r
 \r
         HSSFPolygon polygon = patriarch.createPolygon(new HSSFClientAnchor());\r
@@ -169,8 +184,9 @@ public class TestPolygon extends TestCase{
         polygon1.setPolygonDrawArea( 103, 104 );\r
         polygon1.setPoints( new int[]{11,12,13}, new int[]{14,15,16} );\r
 \r
-        wb = HSSFTestDataSamples.writeOutAndReadBack(wb);\r
-        sh = wb.getSheetAt(0);\r
+        HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);\r
+        wb1.close();\r
+        sh = wb2.getSheetAt(0);\r
         patriarch = sh.getDrawingPatriarch();\r
 \r
         assertEquals(patriarch.getChildren().size(), 2);\r
@@ -179,8 +195,9 @@ public class TestPolygon extends TestCase{
         polygon2.setPolygonDrawArea( 203, 204 );\r
         polygon2.setPoints( new int[]{21,22,23}, new int[]{24,25,26} );\r
 \r
-        wb = HSSFTestDataSamples.writeOutAndReadBack(wb);\r
-        sh = wb.getSheetAt(0);\r
+        HSSFWorkbook wb3 = HSSFTestDataSamples.writeOutAndReadBack(wb2);\r
+        wb2.close();\r
+        sh = wb3.getSheetAt(0);\r
         patriarch = sh.getDrawingPatriarch();\r
 \r
         assertEquals(patriarch.getChildren().size(), 3);\r
@@ -203,8 +220,11 @@ public class TestPolygon extends TestCase{
         assertArrayEquals(polygon2.getYPoints(), new int[]{24,25,26});\r
         assertEquals(polygon2.getDrawAreaHeight(), 204);\r
         assertEquals(polygon2.getDrawAreaWidth(), 203);\r
+        \r
+        wb3.close();\r
     }\r
 \r
+    @Test\r
     public void testExistingFile() throws IOException {\r
         HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("drawings.xls");\r
         HSSFSheet sheet = wb.getSheet("polygon");\r
@@ -216,19 +236,23 @@ public class TestPolygon extends TestCase{
         assertEquals(polygon.getDrawAreaWidth(), 3686175);\r
         assertArrayEquals(polygon.getXPoints(), new int[]{0, 0, 31479, 16159, 19676, 20502});\r
         assertArrayEquals(polygon.getYPoints(), new int[]{0, 0, 36, 56, 34, 18});\r
+        \r
+        wb.close();\r
     }\r
 \r
-    public void testPolygonType(){\r
-        HSSFWorkbook wb = new HSSFWorkbook();\r
-        HSSFSheet sh = wb.createSheet();\r
+    @Test\r
+    public void testPolygonType() throws IOException {\r
+        HSSFWorkbook wb1 = new HSSFWorkbook();\r
+        HSSFSheet sh = wb1.createSheet();\r
         HSSFPatriarch patriarch = sh.createDrawingPatriarch();\r
 \r
         HSSFPolygon polygon = patriarch.createPolygon(new HSSFClientAnchor());\r
         polygon.setPolygonDrawArea( 102, 101 );\r
         polygon.setPoints( new int[]{1,2,3}, new int[]{4,5,6} );\r
 \r
-        wb = HSSFTestDataSamples.writeOutAndReadBack(wb);\r
-        sh = wb.getSheetAt(0);\r
+        HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);\r
+        wb1.close();\r
+        sh = wb2.getSheetAt(0);\r
         patriarch = sh.getDrawingPatriarch();\r
 \r
         HSSFPolygon polygon1 = patriarch.createPolygon(new HSSFClientAnchor());\r
@@ -239,12 +263,14 @@ public class TestPolygon extends TestCase{
 \r
         spRecord.setShapeType((short)77/**RANDOM**/);\r
 \r
-        wb = HSSFTestDataSamples.writeOutAndReadBack(wb);\r
-        sh = wb.getSheetAt(0);\r
+        HSSFWorkbook wb3 = HSSFTestDataSamples.writeOutAndReadBack(wb2);\r
+        wb2.close();\r
+        sh = wb3.getSheetAt(0);\r
         patriarch = sh.getDrawingPatriarch();\r
 \r
         assertEquals(patriarch.getChildren().size(), 2);\r
         assertTrue(patriarch.getChildren().get(0) instanceof HSSFPolygon);\r
         assertTrue(patriarch.getChildren().get(1) instanceof HSSFPolygon);\r
+        wb3.close();\r
     }\r
 }\r
index 51eede08f0f8f26160bb696aaae4274e3082c935..c8203d8d4913e5f61970e0c93a2697e0f306c233 100644 (file)
 \r
 package org.apache.poi.hssf.usermodel;\r
 \r
+import static org.apache.poi.hssf.model.TestDrawingAggregate.decompress;\r
 import static org.junit.Assert.assertArrayEquals;\r
 import static org.junit.Assert.assertEquals;\r
 \r
+import java.io.IOException;\r
+\r
 import org.apache.poi.hssf.HSSFTestDataSamples;\r
-import org.apache.poi.hssf.model.HSSFTestModelHelper;\r
-import org.apache.poi.hssf.model.TextboxShape;\r
 import org.apache.poi.hssf.record.ObjRecord;\r
 import org.apache.poi.hssf.record.TextObjectRecord;\r
 import org.junit.Test;\r
@@ -31,56 +32,54 @@ import org.junit.Test;
  * @author Evgeniy Berlog\r
  * @date 25.06.12\r
  */\r
-@SuppressWarnings("deprecation")\r
 public class TestText {\r
 \r
     @Test\r
-    public void testResultEqualsToAbstractShape() throws Exception {\r
+    public void testResultEqualsToNonExistingAbstractShape() throws IOException {\r
         HSSFWorkbook wb = new HSSFWorkbook();\r
         HSSFSheet sh = wb.createSheet();\r
         HSSFPatriarch patriarch = sh.createDrawingPatriarch();\r
         HSSFTextbox textbox = patriarch.createTextbox(new HSSFClientAnchor());\r
-        TextboxShape textboxShape = HSSFTestModelHelper.createTextboxShape(1025, textbox);\r
 \r
         assertEquals(textbox.getEscherContainer().getChildRecords().size(), 5);\r
-        assertEquals(textboxShape.getSpContainer().getChildRecords().size(), 5);\r
 \r
         //sp record\r
-        byte[] expected = textboxShape.getSpContainer().getChild(0).serialize();\r
+        byte[] expected = decompress("H4sIAAAAAAAAAFvEw/WBg4GBgZEFSHAxMAAA9gX7nhAAAAA=");\r
         byte[] actual = textbox.getEscherContainer().getChild(0).serialize();\r
 \r
         assertEquals(expected.length, actual.length);\r
         assertArrayEquals(expected, actual);\r
 \r
-        expected = textboxShape.getSpContainer().getChild(2).serialize();\r
+        expected = decompress("H4sIAAAAAAAAAGNgEPggxIANAABK4+laGgAAAA==");\r
         actual = textbox.getEscherContainer().getChild(2).serialize();\r
 \r
         assertEquals(expected.length, actual.length);\r
         assertArrayEquals(expected, actual);\r
 \r
-        expected = textboxShape.getSpContainer().getChild(3).serialize();\r
+        expected = decompress("H4sIAAAAAAAAAGNgEPzAAAQACl6c5QgAAAA=");\r
         actual = textbox.getEscherContainer().getChild(3).serialize();\r
 \r
         assertEquals(expected.length, actual.length);\r
         assertArrayEquals(expected, actual);\r
 \r
-        expected = textboxShape.getSpContainer().getChild(4).serialize();\r
+        expected = decompress("H4sIAAAAAAAAAGNg4P3AAAQA6pyIkQgAAAA=");\r
         actual = textbox.getEscherContainer().getChild(4).serialize();\r
 \r
         assertEquals(expected.length, actual.length);\r
         assertArrayEquals(expected, actual);\r
 \r
         ObjRecord obj = textbox.getObjRecord();\r
-        ObjRecord objShape = textboxShape.getObjRecord();\r
 \r
-        expected = obj.serialize();\r
-        actual = objShape.serialize();\r
+        expected = decompress("H4sIAAAAAAAAAItlkGIQZRBiYGNgZBBMYEADAOdCLuweAAAA");\r
+        actual = obj.serialize();\r
 \r
+        assertEquals(expected.length, actual.length);\r
+        assertArrayEquals(expected, actual);\r
+        \r
         TextObjectRecord tor = textbox.getTextObjectRecord();\r
-        TextObjectRecord torShape = textboxShape.getTextObjectRecord();\r
 \r
-        expected = tor.serialize();\r
-        actual = torShape.serialize();\r
+        expected = decompress("H4sIAAAAAAAAANvGKMQgxMSABgBGi8T+FgAAAA==");\r
+        actual = tor.serialize();\r
 \r
         assertEquals(expected.length, actual.length);\r
         assertArrayEquals(expected, actual);\r