mirror of https://github.com/apache/poi.git
#59170 - Remove deprecated classes (POI 3.15) - o.a.p.hssf.model.*Shape classes removed
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1751174 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ec2bb82dbb
commit
3e888b1a0c
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -160,7 +160,7 @@ public class LbsDataSubRecord extends SubRecord {
|
|||
/**
|
||||
*
|
||||
* @return a new instance of LbsDataSubRecord to construct auto-filters
|
||||
* @see org.apache.poi.hssf.model.ComboboxShape#createObjRecord(org.apache.poi.hssf.usermodel.HSSFSimpleShape, int)
|
||||
* @see org.apache.poi.hssf.usermodel.HSSFCombobox
|
||||
*/
|
||||
public static LbsDataSubRecord newAutoFilterInstance(){
|
||||
LbsDataSubRecord lbs = new LbsDataSubRecord();
|
||||
|
@ -330,7 +330,7 @@ public class LbsDataSubRecord extends SubRecord {
|
|||
/**
|
||||
* a string that specifies the current string value in the dropdown
|
||||
*/
|
||||
private String _str;
|
||||
private final String _str;
|
||||
|
||||
/**
|
||||
* Optional, undefined and MUST be ignored.
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,40 +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.hssf.usermodel.HSSFComment;
|
||||
import org.apache.poi.hssf.usermodel.HSSFPolygon;
|
||||
import org.apache.poi.hssf.usermodel.HSSFTextbox;
|
||||
|
||||
/**
|
||||
* @author Evgeniy Berlog
|
||||
* @date 25.06.12
|
||||
*/
|
||||
public class HSSFTestModelHelper {
|
||||
public static TextboxShape createTextboxShape(int shapeId, HSSFTextbox textbox){
|
||||
return new TextboxShape(textbox, shapeId);
|
||||
}
|
||||
|
||||
public static CommentShape createCommentShape(int shapeId, HSSFComment comment){
|
||||
return new CommentShape(comment, shapeId);
|
||||
}
|
||||
|
||||
public static PolygonShape createPolygonShape(int shapeId, HSSFPolygon polygon){
|
||||
return new PolygonShape(polygon, shapeId);
|
||||
}
|
||||
}
|
|
@ -224,8 +224,7 @@ public class TestDrawingAggregate {
|
|||
"H4sIAAAAAAAAAGWOOw7CQAxE32YTsSRIWSgQJSUloqSm5g4ICURBg+iBK3APGi6wBWeh9xGYbEps2WON"+
|
||||
"P+OWwpYeIsECMFC8S2jxNvMdlrYQ5xha5N8K6ryHdir6+avwOer5l3hq2NPYWuWN0n1dIsgfbgshuSj1"+
|
||||
"+2eqbvLdxQ0ndhy5KJ/lc1ZZK9okY5X/gSbrHZTH1vE/ozagTcwAAAA=";
|
||||
byte[] base64Bytes = DatatypeConverter.parseBase64Binary(data);
|
||||
byte[] dgBytes = IOUtils.toByteArray(new GZIPInputStream(new ByteArrayInputStream(base64Bytes)));
|
||||
byte[] dgBytes = decompress(data);
|
||||
|
||||
List<EscherRecord> records = new ArrayList<EscherRecord>();
|
||||
EscherRecordFactory recordFactory = new DefaultEscherRecordFactory();
|
||||
|
@ -725,8 +724,7 @@ public class TestDrawingAggregate {
|
|||
"IppKQdVys+cLtUY6Un0+hI2Z0wMzAxO8Lr0LbaILk8WtNsxpaFYMrTjC22723OH5GFkUi+ux8An2Hi0F"+
|
||||
"fvcr1v8aFU6POn+OCqfj4ffS/e+pcOEMKhABrCdUAAPhwB+pQHYGFcT/BBUEz6LC/wGpc+eRNSkAAA==";
|
||||
|
||||
byte[] base64Bytes = DatatypeConverter.parseBase64Binary(data);
|
||||
byte[] dgBytes = IOUtils.toByteArray(new GZIPInputStream(new ByteArrayInputStream(base64Bytes)));
|
||||
byte[] dgBytes = decompress(data);
|
||||
List<Record> dgRecords = RecordFactory.createRecords(new ByteArrayInputStream(dgBytes));
|
||||
assertEquals(20, dgRecords.size());
|
||||
|
||||
|
@ -904,8 +902,7 @@ public class TestDrawingAggregate {
|
|||
"p9IQmzVDjm0LdSLqeHM8ILiJRsdoNYS93WyEhi7IOdKXZLTCvCLifxTMEi+snNzAtfevk8DpkejvSeB0"+
|
||||
"BPza/oPKABD5z4SARKQEELP1WQsFMc+QwP8ATkmhK404AAA=";
|
||||
|
||||
byte[] base64Bytes = DatatypeConverter.parseBase64Binary(data);
|
||||
byte[] dgBytes = IOUtils.toByteArray(new GZIPInputStream(new ByteArrayInputStream(base64Bytes)));
|
||||
byte[] dgBytes = decompress(data);
|
||||
List<Record> dgRecords = RecordFactory.createRecords(new ByteArrayInputStream(dgBytes));
|
||||
assertEquals(14, dgRecords.size());
|
||||
|
||||
|
@ -950,4 +947,31 @@ public class TestDrawingAggregate {
|
|||
assertTrue("drawing data brefpore and after save is different", Arrays.equals(dgBytes, dgBytesAfterSave));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Decompress previously gziped/base64ed data
|
||||
*
|
||||
* @param data the gziped/base64ed data
|
||||
* @return the raw bytes
|
||||
* @throws IOException if you copy and pasted the data wrong
|
||||
*/
|
||||
public static byte[] decompress(String data) throws IOException {
|
||||
byte[] base64Bytes = DatatypeConverter.parseBase64Binary(data);
|
||||
return IOUtils.toByteArray(new GZIPInputStream(new ByteArrayInputStream(base64Bytes)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Compress raw data for test runs - usually called while debugging :)
|
||||
*
|
||||
* @param data the raw data
|
||||
* @return the gziped/base64ed data as String
|
||||
* @throws IOException usually not ...
|
||||
*/
|
||||
public static String compress(byte[] data) throws IOException {
|
||||
java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();
|
||||
java.util.zip.GZIPOutputStream gz = new java.util.zip.GZIPOutputStream(bos);
|
||||
gz.write(data);
|
||||
gz.finish();
|
||||
return DatatypeConverter.printBase64Binary(bos.toByteArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -17,27 +17,22 @@
|
|||
|
||||
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.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.poi.ddf.EscherArrayProperty;
|
||||
import org.apache.poi.ddf.EscherOptRecord;
|
||||
import org.apache.poi.ddf.EscherProperties;
|
||||
import org.apache.poi.ddf.EscherSpRecord;
|
||||
import org.apache.poi.hssf.HSSFTestDataSamples;
|
||||
import org.apache.poi.hssf.model.HSSFTestModelHelper;
|
||||
import org.apache.poi.hssf.model.PolygonShape;
|
||||
import org.apache.poi.hssf.record.ObjRecord;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Evgeniy Berlog
|
||||
* @date 28.06.12
|
||||
*/
|
||||
public class TestPolygon extends TestCase{
|
||||
|
||||
public class TestPolygon {
|
||||
@Test
|
||||
public void testResultEqualsToAbstractShape() throws IOException {
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
HSSFSheet sh = wb.createSheet();
|
||||
|
@ -46,42 +41,42 @@ public class TestPolygon extends TestCase{
|
|||
HSSFPolygon polygon = patriarch.createPolygon(new HSSFClientAnchor());
|
||||
polygon.setPolygonDrawArea( 100, 100 );
|
||||
polygon.setPoints( new int[]{0, 90, 50}, new int[]{5, 5, 44} );
|
||||
PolygonShape polygonShape = HSSFTestModelHelper.createPolygonShape(1024, polygon);
|
||||
polygon.setShapeId(1024);
|
||||
|
||||
assertEquals(polygon.getEscherContainer().getChildRecords().size(), 4);
|
||||
assertEquals(polygonShape.getSpContainer().getChildRecords().size(), 4);
|
||||
|
||||
//sp record
|
||||
byte[] expected = polygonShape.getSpContainer().getChild(0).serialize();
|
||||
byte[] expected = decompress("H4sIAAAAAAAAAGNi4PrAwQAELEDMxcAAAAU6ZlwQAAAA");
|
||||
byte[] actual = polygon.getEscherContainer().getChild(0).serialize();
|
||||
|
||||
assertEquals(expected.length, actual.length);
|
||||
assertArrayEquals(expected, actual);
|
||||
|
||||
expected = polygonShape.getSpContainer().getChild(2).serialize();
|
||||
expected = decompress("H4sIAAAAAAAAAGNgEPggxIANAABK4+laGgAAAA==");
|
||||
actual = polygon.getEscherContainer().getChild(2).serialize();
|
||||
|
||||
assertEquals(expected.length, actual.length);
|
||||
assertArrayEquals(expected, actual);
|
||||
|
||||
expected = polygonShape.getSpContainer().getChild(3).serialize();
|
||||
expected = decompress("H4sIAAAAAAAAAGNgEPzAAAQACl6c5QgAAAA=");
|
||||
actual = polygon.getEscherContainer().getChild(3).serialize();
|
||||
|
||||
assertEquals(expected.length, actual.length);
|
||||
assertArrayEquals(expected, actual);
|
||||
|
||||
ObjRecord obj = polygon.getObjRecord();
|
||||
ObjRecord objShape = polygonShape.getObjRecord();
|
||||
|
||||
expected = obj.serialize();
|
||||
actual = objShape.serialize();
|
||||
expected = decompress("H4sIAAAAAAAAAItlkGIQZRBikGNgYBBMYEADAOAV/ZkeAAAA");
|
||||
actual = obj.serialize();
|
||||
|
||||
assertEquals(expected.length, actual.length);
|
||||
assertArrayEquals(expected, actual);
|
||||
|
||||
wb.close();
|
||||
}
|
||||
|
||||
public void testPolygonPoints(){
|
||||
@Test
|
||||
public void testPolygonPoints() throws IOException {
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
HSSFSheet sh = wb.createSheet();
|
||||
HSSFPatriarch patriarch = sh.createDrawingPatriarch();
|
||||
|
@ -90,31 +85,46 @@ public class TestPolygon extends TestCase{
|
|||
polygon.setPolygonDrawArea( 100, 100 );
|
||||
polygon.setPoints( new int[]{0, 90, 50, 90}, new int[]{5, 5, 44, 88} );
|
||||
|
||||
PolygonShape polygonShape = HSSFTestModelHelper.createPolygonShape(0, polygon);
|
||||
|
||||
EscherArrayProperty verticesProp1 = polygon.getOptRecord().lookup(EscherProperties.GEOMETRY__VERTICES);
|
||||
EscherArrayProperty verticesProp2 = ((EscherOptRecord)polygonShape.getSpContainer().getChildById(EscherOptRecord.RECORD_ID))
|
||||
.lookup(EscherProperties.GEOMETRY__VERTICES);
|
||||
|
||||
assertEquals(verticesProp1.getNumberOfElementsInArray(), verticesProp2.getNumberOfElementsInArray());
|
||||
assertEquals(verticesProp1.toXml(""), verticesProp2.toXml(""));
|
||||
String expected =
|
||||
"<EscherArrayProperty id=\"0x8145\" name=\"geometry.vertices\" blipId=\"false\">"+
|
||||
"<Element>[00, 00, 05, 00]</Element>"+
|
||||
"<Element>[5A, 00, 05, 00]</Element>"+
|
||||
"<Element>[32, 00, 2C, 00]</Element>"+
|
||||
"<Element>[5A, 00, 58, 00]</Element>"+
|
||||
"<Element>[00, 00, 05, 00]</Element>"+
|
||||
"</EscherArrayProperty>";
|
||||
String actual = verticesProp1.toXml("").replaceAll("[\r\n\t]","");
|
||||
|
||||
assertEquals(verticesProp1.getNumberOfElementsInArray(), 5);
|
||||
assertEquals(expected, actual);
|
||||
|
||||
polygon.setPoints(new int[]{1,2,3}, new int[] {4,5,6});
|
||||
assertArrayEquals(polygon.getXPoints(), new int[]{1, 2, 3});
|
||||
assertArrayEquals(polygon.getYPoints(), new int[]{4, 5, 6});
|
||||
|
||||
polygonShape = HSSFTestModelHelper.createPolygonShape(0, polygon);
|
||||
verticesProp1 = polygon.getOptRecord().lookup(EscherProperties.GEOMETRY__VERTICES);
|
||||
verticesProp2 = ((EscherOptRecord)polygonShape.getSpContainer().getChildById(EscherOptRecord.RECORD_ID))
|
||||
.lookup(EscherProperties.GEOMETRY__VERTICES);
|
||||
|
||||
assertEquals(verticesProp1.getNumberOfElementsInArray(), verticesProp2.getNumberOfElementsInArray());
|
||||
assertEquals(verticesProp1.toXml(""), verticesProp2.toXml(""));
|
||||
expected =
|
||||
"<EscherArrayProperty id=\"0x8145\" name=\"geometry.vertices\" blipId=\"false\">" +
|
||||
"<Element>[01, 00, 04, 00]</Element>" +
|
||||
"<Element>[02, 00, 05, 00]</Element>" +
|
||||
"<Element>[03, 00, 06, 00]</Element>" +
|
||||
"<Element>[01, 00, 04, 00]</Element>" +
|
||||
"</EscherArrayProperty>";
|
||||
actual = verticesProp1.toXml("").replaceAll("[\r\n\t]","");
|
||||
|
||||
assertEquals(verticesProp1.getNumberOfElementsInArray(), 4);
|
||||
assertEquals(expected, actual);
|
||||
|
||||
wb.close();
|
||||
}
|
||||
|
||||
public void testSetGetProperties(){
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
HSSFSheet sh = wb.createSheet();
|
||||
@Test
|
||||
public void testSetGetProperties() throws IOException {
|
||||
HSSFWorkbook wb1 = new HSSFWorkbook();
|
||||
HSSFSheet sh = wb1.createSheet();
|
||||
HSSFPatriarch patriarch = sh.createDrawingPatriarch();
|
||||
|
||||
HSSFPolygon polygon = patriarch.createPolygon(new HSSFClientAnchor());
|
||||
|
@ -126,8 +136,9 @@ public class TestPolygon extends TestCase{
|
|||
assertEquals(polygon.getDrawAreaHeight(), 101);
|
||||
assertEquals(polygon.getDrawAreaWidth(), 102);
|
||||
|
||||
wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
|
||||
sh = wb.getSheetAt(0);
|
||||
HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);
|
||||
wb1.close();
|
||||
sh = wb2.getSheetAt(0);
|
||||
patriarch = sh.getDrawingPatriarch();
|
||||
|
||||
polygon = (HSSFPolygon) patriarch.getChildren().get(0);
|
||||
|
@ -144,8 +155,9 @@ public class TestPolygon extends TestCase{
|
|||
assertEquals(polygon.getDrawAreaHeight(), 1011);
|
||||
assertEquals(polygon.getDrawAreaWidth(), 1021);
|
||||
|
||||
wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
|
||||
sh = wb.getSheetAt(0);
|
||||
HSSFWorkbook wb3 = HSSFTestDataSamples.writeOutAndReadBack(wb2);
|
||||
wb2.close();
|
||||
sh = wb3.getSheetAt(0);
|
||||
patriarch = sh.getDrawingPatriarch();
|
||||
|
||||
polygon = (HSSFPolygon) patriarch.getChildren().get(0);
|
||||
|
@ -154,11 +166,14 @@ public class TestPolygon extends TestCase{
|
|||
assertArrayEquals(polygon.getYPoints(), new int[]{41, 51, 61});
|
||||
assertEquals(polygon.getDrawAreaHeight(), 1011);
|
||||
assertEquals(polygon.getDrawAreaWidth(), 1021);
|
||||
|
||||
wb3.close();
|
||||
}
|
||||
|
||||
public void testAddToExistingFile(){
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
HSSFSheet sh = wb.createSheet();
|
||||
@Test
|
||||
public void testAddToExistingFile() throws IOException {
|
||||
HSSFWorkbook wb1 = new HSSFWorkbook();
|
||||
HSSFSheet sh = wb1.createSheet();
|
||||
HSSFPatriarch patriarch = sh.createDrawingPatriarch();
|
||||
|
||||
HSSFPolygon polygon = patriarch.createPolygon(new HSSFClientAnchor());
|
||||
|
@ -169,8 +184,9 @@ public class TestPolygon extends TestCase{
|
|||
polygon1.setPolygonDrawArea( 103, 104 );
|
||||
polygon1.setPoints( new int[]{11,12,13}, new int[]{14,15,16} );
|
||||
|
||||
wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
|
||||
sh = wb.getSheetAt(0);
|
||||
HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);
|
||||
wb1.close();
|
||||
sh = wb2.getSheetAt(0);
|
||||
patriarch = sh.getDrawingPatriarch();
|
||||
|
||||
assertEquals(patriarch.getChildren().size(), 2);
|
||||
|
@ -179,8 +195,9 @@ public class TestPolygon extends TestCase{
|
|||
polygon2.setPolygonDrawArea( 203, 204 );
|
||||
polygon2.setPoints( new int[]{21,22,23}, new int[]{24,25,26} );
|
||||
|
||||
wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
|
||||
sh = wb.getSheetAt(0);
|
||||
HSSFWorkbook wb3 = HSSFTestDataSamples.writeOutAndReadBack(wb2);
|
||||
wb2.close();
|
||||
sh = wb3.getSheetAt(0);
|
||||
patriarch = sh.getDrawingPatriarch();
|
||||
|
||||
assertEquals(patriarch.getChildren().size(), 3);
|
||||
|
@ -203,8 +220,11 @@ public class TestPolygon extends TestCase{
|
|||
assertArrayEquals(polygon2.getYPoints(), new int[]{24,25,26});
|
||||
assertEquals(polygon2.getDrawAreaHeight(), 204);
|
||||
assertEquals(polygon2.getDrawAreaWidth(), 203);
|
||||
|
||||
wb3.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExistingFile() throws IOException {
|
||||
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("drawings.xls");
|
||||
HSSFSheet sheet = wb.getSheet("polygon");
|
||||
|
@ -216,19 +236,23 @@ public class TestPolygon extends TestCase{
|
|||
assertEquals(polygon.getDrawAreaWidth(), 3686175);
|
||||
assertArrayEquals(polygon.getXPoints(), new int[]{0, 0, 31479, 16159, 19676, 20502});
|
||||
assertArrayEquals(polygon.getYPoints(), new int[]{0, 0, 36, 56, 34, 18});
|
||||
|
||||
wb.close();
|
||||
}
|
||||
|
||||
public void testPolygonType(){
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
HSSFSheet sh = wb.createSheet();
|
||||
@Test
|
||||
public void testPolygonType() throws IOException {
|
||||
HSSFWorkbook wb1 = new HSSFWorkbook();
|
||||
HSSFSheet sh = wb1.createSheet();
|
||||
HSSFPatriarch patriarch = sh.createDrawingPatriarch();
|
||||
|
||||
HSSFPolygon polygon = patriarch.createPolygon(new HSSFClientAnchor());
|
||||
polygon.setPolygonDrawArea( 102, 101 );
|
||||
polygon.setPoints( new int[]{1,2,3}, new int[]{4,5,6} );
|
||||
|
||||
wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
|
||||
sh = wb.getSheetAt(0);
|
||||
HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);
|
||||
wb1.close();
|
||||
sh = wb2.getSheetAt(0);
|
||||
patriarch = sh.getDrawingPatriarch();
|
||||
|
||||
HSSFPolygon polygon1 = patriarch.createPolygon(new HSSFClientAnchor());
|
||||
|
@ -239,12 +263,14 @@ public class TestPolygon extends TestCase{
|
|||
|
||||
spRecord.setShapeType((short)77/**RANDOM**/);
|
||||
|
||||
wb = HSSFTestDataSamples.writeOutAndReadBack(wb);
|
||||
sh = wb.getSheetAt(0);
|
||||
HSSFWorkbook wb3 = HSSFTestDataSamples.writeOutAndReadBack(wb2);
|
||||
wb2.close();
|
||||
sh = wb3.getSheetAt(0);
|
||||
patriarch = sh.getDrawingPatriarch();
|
||||
|
||||
assertEquals(patriarch.getChildren().size(), 2);
|
||||
assertTrue(patriarch.getChildren().get(0) instanceof HSSFPolygon);
|
||||
assertTrue(patriarch.getChildren().get(1) instanceof HSSFPolygon);
|
||||
wb3.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,12 +17,13 @@
|
|||
|
||||
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 java.io.IOException;
|
||||
|
||||
import org.apache.poi.hssf.HSSFTestDataSamples;
|
||||
import org.apache.poi.hssf.model.HSSFTestModelHelper;
|
||||
import org.apache.poi.hssf.model.TextboxShape;
|
||||
import org.apache.poi.hssf.record.ObjRecord;
|
||||
import org.apache.poi.hssf.record.TextObjectRecord;
|
||||
import org.junit.Test;
|
||||
|
@ -31,56 +32,54 @@ import org.junit.Test;
|
|||
* @author Evgeniy Berlog
|
||||
* @date 25.06.12
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class TestText {
|
||||
|
||||
@Test
|
||||
public void testResultEqualsToAbstractShape() throws Exception {
|
||||
public void testResultEqualsToNonExistingAbstractShape() throws IOException {
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
HSSFSheet sh = wb.createSheet();
|
||||
HSSFPatriarch patriarch = sh.createDrawingPatriarch();
|
||||
HSSFTextbox textbox = patriarch.createTextbox(new HSSFClientAnchor());
|
||||
TextboxShape textboxShape = HSSFTestModelHelper.createTextboxShape(1025, textbox);
|
||||
|
||||
assertEquals(textbox.getEscherContainer().getChildRecords().size(), 5);
|
||||
assertEquals(textboxShape.getSpContainer().getChildRecords().size(), 5);
|
||||
|
||||
//sp record
|
||||
byte[] expected = textboxShape.getSpContainer().getChild(0).serialize();
|
||||
byte[] expected = decompress("H4sIAAAAAAAAAFvEw/WBg4GBgZEFSHAxMAAA9gX7nhAAAAA=");
|
||||
byte[] actual = textbox.getEscherContainer().getChild(0).serialize();
|
||||
|
||||
assertEquals(expected.length, actual.length);
|
||||
assertArrayEquals(expected, actual);
|
||||
|
||||
expected = textboxShape.getSpContainer().getChild(2).serialize();
|
||||
expected = decompress("H4sIAAAAAAAAAGNgEPggxIANAABK4+laGgAAAA==");
|
||||
actual = textbox.getEscherContainer().getChild(2).serialize();
|
||||
|
||||
assertEquals(expected.length, actual.length);
|
||||
assertArrayEquals(expected, actual);
|
||||
|
||||
expected = textboxShape.getSpContainer().getChild(3).serialize();
|
||||
expected = decompress("H4sIAAAAAAAAAGNgEPzAAAQACl6c5QgAAAA=");
|
||||
actual = textbox.getEscherContainer().getChild(3).serialize();
|
||||
|
||||
assertEquals(expected.length, actual.length);
|
||||
assertArrayEquals(expected, actual);
|
||||
|
||||
expected = textboxShape.getSpContainer().getChild(4).serialize();
|
||||
expected = decompress("H4sIAAAAAAAAAGNg4P3AAAQA6pyIkQgAAAA=");
|
||||
actual = textbox.getEscherContainer().getChild(4).serialize();
|
||||
|
||||
assertEquals(expected.length, actual.length);
|
||||
assertArrayEquals(expected, actual);
|
||||
|
||||
ObjRecord obj = textbox.getObjRecord();
|
||||
ObjRecord objShape = textboxShape.getObjRecord();
|
||||
|
||||
expected = obj.serialize();
|
||||
actual = objShape.serialize();
|
||||
expected = decompress("H4sIAAAAAAAAAItlkGIQZRBiYGNgZBBMYEADAOdCLuweAAAA");
|
||||
actual = obj.serialize();
|
||||
|
||||
assertEquals(expected.length, actual.length);
|
||||
assertArrayEquals(expected, actual);
|
||||
|
||||
TextObjectRecord tor = textbox.getTextObjectRecord();
|
||||
TextObjectRecord torShape = textboxShape.getTextObjectRecord();
|
||||
|
||||
expected = tor.serialize();
|
||||
actual = torShape.serialize();
|
||||
expected = decompress("H4sIAAAAAAAAANvGKMQgxMSABgBGi8T+FgAAAA==");
|
||||
actual = tor.serialize();
|
||||
|
||||
assertEquals(expected.length, actual.length);
|
||||
assertArrayEquals(expected, actual);
|
||||
|
|
Loading…
Reference in New Issue