More fixes to allow EscherContainerRecord to exclusively maintain 'child records' field. (due to r745976 / r746018)

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@746085 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Josh Micich 2009-02-20 01:55:47 +00:00
parent 8a77c05b99
commit 8dcd0c8c58
19 changed files with 889 additions and 896 deletions

View File

@ -2023,7 +2023,7 @@ public final class Workbook implements Model {
}
EscherDggRecord dgg = null;
for(Iterator it = cr.getChildRecords().iterator(); it.hasNext();) {
for(Iterator<EscherRecord> it = cr.getChildIterator(); it.hasNext();) {
Object er = it.next();
if(er instanceof EscherDggRecord) {
dgg = (EscherDggRecord)er;
@ -2150,7 +2150,9 @@ public final class Workbook implements Model {
{
bstoreContainer = new EscherContainerRecord();
bstoreContainer.setRecordId( EscherContainerRecord.BSTORE_CONTAINER );
dggContainer.getChildRecords().add( 1, bstoreContainer );
List<EscherRecord> childRecords = dggContainer.getChildRecords();
childRecords.add(1, bstoreContainer);
dggContainer.setChildRecords(childRecords);
}
bstoreContainer.setOptions( (short) ( (escherBSERecords.size() << 4) | 0xF ) );
@ -2285,18 +2287,18 @@ public final class Workbook implements Model {
dgg.setDrawingsSaved(dgg.getDrawingsSaved() + 1);
EscherDgRecord dg = null;
for(Iterator it = escherContainer.getChildRecords().iterator(); it.hasNext();) {
Object er = it.next();
for(Iterator<EscherRecord> it = escherContainer.getChildIterator(); it.hasNext();) {
EscherRecord er = it.next();
if(er instanceof EscherDgRecord) {
dg = (EscherDgRecord)er;
//update id of the drawing in the cloned sheet
dg.setOptions( (short) ( dgId << 4 ) );
} else if (er instanceof EscherContainerRecord){
//recursively find shape records and re-generate shapeId
ArrayList spRecords = new ArrayList();
List<EscherRecord> spRecords = new ArrayList<EscherRecord>();
EscherContainerRecord cp = (EscherContainerRecord)er;
cp.getRecordsById(EscherSpRecord.RECORD_ID, spRecords);
for(Iterator spIt = spRecords.iterator(); spIt.hasNext();) {
for(Iterator<EscherRecord> spIt = spRecords.iterator(); spIt.hasNext();) {
EscherSpRecord sp = (EscherSpRecord)spIt.next();
int shapeId = drawingManager.allocateShapeId((short)dgId, dg);
//allocateShapeId increments the number of shapes. roll back to the previous value

View File

@ -196,21 +196,20 @@ public abstract class AbstractEscherHolderRecord extends Record {
public EscherRecord findFirstWithId(short id) {
return findFirstWithId(id, getEscherRecords());
}
private EscherRecord findFirstWithId(short id, List records) {
private EscherRecord findFirstWithId(short id, List<EscherRecord> records) {
// Check at our level
for(Iterator it = records.iterator(); it.hasNext();) {
EscherRecord r = (EscherRecord)it.next();
for(Iterator<EscherRecord> it = records.iterator(); it.hasNext();) {
EscherRecord r = it.next();
if(r.getRecordId() == id) {
return r;
}
}
// Then check our children in turn
for(Iterator it = records.iterator(); it.hasNext();) {
EscherRecord r = (EscherRecord)it.next();
for(Iterator<EscherRecord> it = records.iterator(); it.hasNext();) {
EscherRecord r = it.next();
if(r.isContainerRecord()) {
EscherRecord found =
findFirstWithId(id, r.getChildRecords());
EscherRecord found = findFirstWithId(id, r.getChildRecords());
if(found != null) {
return found;
}

View File

@ -281,8 +281,8 @@ public final class EscherAggregate extends AbstractEscherHolderRecord {
protected HSSFPatriarch patriarch;
/** Maps shape container objects to their OBJ records */
private Map shapeToObj = new HashMap();
/** Maps shape container objects to their {@link TextObjectRecord} or {@link ObjRecord} */
private Map<EscherRecord, Record> shapeToObj = new HashMap<EscherRecord, Record>();
private DrawingManager2 drawingManager;
private short drawingGroupId;
@ -331,7 +331,7 @@ public final class EscherAggregate extends AbstractEscherHolderRecord {
{
// Keep track of any shape records created so we can match them back to the object id's.
// Textbox objects are also treated as shape objects.
final List shapeRecords = new ArrayList();
final List<EscherRecord> shapeRecords = new ArrayList<EscherRecord>();
EscherRecordFactory recordFactory = new DefaultEscherRecordFactory()
{
public EscherRecord createRecord( byte[] data, int offset )
@ -385,7 +385,7 @@ public final class EscherAggregate extends AbstractEscherHolderRecord {
// Associate the object records with the shapes
loc = locFirstDrawingRecord;
int shapeIndex = 0;
agg.shapeToObj = new HashMap();
agg.shapeToObj = new HashMap<EscherRecord, Record>();
while ( loc + 1 < records.size()
&& sid( records, loc ) == DrawingRecord.sid
&& isObjectRecord( records, loc + 1 ) )
@ -521,7 +521,7 @@ public final class EscherAggregate extends AbstractEscherHolderRecord {
/**
* Associates an escher record to an OBJ record or a TXO record.
*/
public Object assoicateShapeToObjRecord( EscherRecord r, Record objRecord )
Object associateShapeToObjRecord( EscherRecord r, ObjRecord objRecord )
{
return shapeToObj.put( r, objRecord );
}
@ -566,8 +566,8 @@ public final class EscherAggregate extends AbstractEscherHolderRecord {
EscherContainerRecord patriachContainer =
(EscherContainerRecord)tcc.get(0);
EscherSpgrRecord spgr = null;
for(Iterator it = patriachContainer.getChildRecords().iterator(); it.hasNext();) {
EscherRecord r = (EscherRecord)it.next();
for(Iterator<EscherRecord> it = patriachContainer.getChildIterator(); it.hasNext();) {
EscherRecord r = it.next();
if(r instanceof EscherSpgrRecord) {
spgr = (EscherSpgrRecord)r;
break;
@ -627,8 +627,8 @@ public final class EscherAggregate extends AbstractEscherHolderRecord {
}
private void convertRecordsToUserModel(EscherContainerRecord shapeContainer, Object model) {
for(Iterator it = shapeContainer.getChildRecords().iterator(); it.hasNext();) {
EscherRecord r = (EscherRecord)it.next();
for(Iterator<EscherRecord> it = shapeContainer.getChildIterator(); it.hasNext();) {
EscherRecord r = it.next();
if(r instanceof EscherSpgrRecord) {
// This may be overriden by a later EscherClientAnchorRecord
EscherSpgrRecord spgr = (EscherSpgrRecord)r;
@ -705,9 +705,13 @@ public final class EscherAggregate extends AbstractEscherHolderRecord {
convertPatriarch( patriarch );
EscherContainerRecord dgContainer = (EscherContainerRecord) getEscherRecord( 0 );
EscherContainerRecord spgrContainer = null;
for ( int i = 0; i < dgContainer.getChildRecords().size(); i++ )
if ( dgContainer.getChild( i ).getRecordId() == EscherContainerRecord.SPGR_CONTAINER )
spgrContainer = (EscherContainerRecord) dgContainer.getChild( i );
Iterator<EscherRecord> iter = dgContainer.getChildIterator();
while (iter.hasNext()) {
EscherRecord child = iter.next();
if (child.getRecordId() == EscherContainerRecord.SPGR_CONTAINER) {
spgrContainer = (EscherContainerRecord) child;
}
}
convertShapes( patriarch, spgrContainer, shapeToObj );
patriarch = null;
@ -828,12 +832,12 @@ public final class EscherAggregate extends AbstractEscherHolderRecord {
private EscherRecord findClientData( EscherContainerRecord spContainer )
{
for ( Iterator iterator = spContainer.getChildRecords().iterator(); iterator.hasNext(); )
{
EscherRecord r = (EscherRecord) iterator.next();
if ( r.getRecordId() == EscherClientDataRecord.RECORD_ID )
for (Iterator<EscherRecord> iterator = spContainer.getChildIterator(); iterator.hasNext();) {
EscherRecord r = iterator.next();
if (r.getRecordId() == EscherClientDataRecord.RECORD_ID) {
return r;
}
}
throw new IllegalArgumentException( "Can not find client data record" );
}
@ -877,11 +881,6 @@ public final class EscherAggregate extends AbstractEscherHolderRecord {
addEscherRecord( dgContainer );
}
/** Retrieve the number of shapes (including the patriarch). */
// private int getNumberOfShapes( HSSFPatriarch patriarch )
// {
// return patriarch.countOfAllChildren();
// }
private static short sid( List records, int loc )
{

View File

@ -201,23 +201,21 @@ public final class SlideShowRecordDumper {
String nl = System.getProperty( "line.separator" );
StringBuffer children = new StringBuffer();
if ( ecr.getChildRecords().size() > 0 )
{
children.append( " children: " + nl );
int count = 0;
for ( Iterator iterator = ecr.getChildRecords().iterator(); iterator.hasNext(); )
for ( Iterator<EscherRecord> iterator = ecr.getChildIterator(); iterator.hasNext(); )
{
if (count < 1) {
children.append( " children: " + nl );
}
String newIndent = " ";
EscherRecord record = (EscherRecord) iterator.next();
EscherRecord record = iterator.next();
children.append(newIndent + "Child " + count + ":" + nl);
children.append( printEscherRecord(record) );
count++;
}
}
return
indent + ecr.getClass().getName() + " (" + ecr.getRecordName() + "):" + nl +

View File

@ -76,7 +76,7 @@ public final class ActiveXShape extends Picture {
EscherClientDataRecord cldata = new EscherClientDataRecord();
cldata.setOptions((short)0xF);
_escherContainer.getChildRecords().add(cldata);
_escherContainer.addChildRecord(cldata); // TODO unit test to prove getChildRecords().add is wrong
OEShapeAtom oe = new OEShapeAtom();
@ -100,7 +100,7 @@ public final class ActiveXShape extends Picture {
*/
public void setActiveXIndex(int idx){
EscherContainerRecord spContainer = getSpContainer();
for (Iterator<EscherRecord> it = spContainer.getChildRecords().iterator(); it.hasNext();) {
for (Iterator<EscherRecord> it = spContainer.getChildIterator(); it.hasNext();) {
EscherRecord obj = it.next();
if (obj.getRecordId() == EscherClientDataRecord.RECORD_ID) {
EscherClientDataRecord clientRecord = (EscherClientDataRecord)obj;

View File

@ -177,11 +177,10 @@ public class Hyperlink {
}
EscherContainerRecord spContainer = shape.getSpContainer();
List spchild = spContainer.getChildRecords();
for (Iterator it = spchild.iterator(); it.hasNext(); ) {
EscherRecord obj = (EscherRecord)it.next();
for (Iterator<EscherRecord> it = spContainer.getChildIterator(); it.hasNext(); ) {
EscherRecord obj = it.next();
if (obj.getRecordId() == EscherClientDataRecord.RECORD_ID){
byte[] data = ((EscherContainerRecord)obj).serialize();
byte[] data = obj.serialize();
Record[] records = Record.findChildRecords(data, 8, data.length-8);
if(records != null) find(records, exobj, lst);
}

View File

@ -86,13 +86,7 @@ public class Placeholder extends TextBox {
cldata.setRemainingData(out.toByteArray());
//append placeholder container before EscherTextboxRecord
List lst = _escherContainer.getChildRecords();
for (int i = 0; i < lst.size(); i++) {
EscherRecord rec = (EscherRecord)lst.get(i);
if(rec.getRecordId() == EscherTextboxRecord.RECORD_ID){
lst.add(i++, cldata);
}
}
_escherContainer.addChildBefore(cldata, EscherTextboxRecord.RECORD_ID);
return _escherContainer;
}

View File

@ -246,9 +246,9 @@ public abstract class Shape {
* @return escher record or <code>null</code> if not found.
*/
public static EscherRecord getEscherChild(EscherContainerRecord owner, int recordId){
for ( Iterator iterator = owner.getChildRecords().iterator(); iterator.hasNext(); )
for ( Iterator<EscherRecord> iterator = owner.getChildIterator(); iterator.hasNext(); )
{
EscherRecord escherRecord = (EscherRecord) iterator.next();
EscherRecord escherRecord = iterator.next();
if (escherRecord.getRecordId() == recordId)
return escherRecord;
}

View File

@ -125,8 +125,8 @@ public class ShapeFactory {
protected static Record getClientDataRecord(EscherContainerRecord spContainer, int recordType) {
Record oep = null;
for (Iterator it = spContainer.getChildRecords().iterator(); it.hasNext();) {
EscherRecord obj = (EscherRecord) it.next();
for (Iterator<EscherRecord> it = spContainer.getChildIterator(); it.hasNext();) {
EscherRecord obj = it.next();
if (obj.getRecordId() == EscherClientDataRecord.RECORD_ID) {
byte[] data = obj.serialize();
Record[] records = Record.findChildRecords(data, 8, data.length - 8);

View File

@ -14,18 +14,24 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hslf.model;
import org.apache.poi.ddf.*;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.poi.ddf.EscherChildAnchorRecord;
import org.apache.poi.ddf.EscherClientAnchorRecord;
import org.apache.poi.ddf.EscherContainerRecord;
import org.apache.poi.ddf.EscherRecord;
import org.apache.poi.ddf.EscherSpRecord;
import org.apache.poi.ddf.EscherSpgrRecord;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.POILogger;
import org.apache.poi.hslf.record.EscherTextboxWrapper;
import java.util.ArrayList;
import java.util.List;
import java.awt.geom.Rectangle2D;
import java.awt.geom.AffineTransform;
import java.awt.*;
/**
* Represents a group of shapes.
@ -57,14 +63,17 @@ public class ShapeGroup extends Shape{
* @return the shapes contained in this group container
*/
public Shape[] getShapes() {
// Out escher container record should contain serveral
// Out escher container record should contain several
// SpContainers, the first of which is the group shape itself
List lst = _escherContainer.getChildRecords();
Iterator<EscherRecord> iter = _escherContainer.getChildIterator();
ArrayList shapeList = new ArrayList();
// Don't include the first SpContainer, it is always NotPrimitive
for (int i = 1; i < lst.size(); i++){
EscherRecord r = (EscherRecord)lst.get(i);
if (iter.hasNext()) {
iter.next();
}
List<Shape> shapeList = new ArrayList<Shape>();
while (iter.hasNext()) {
EscherRecord r = iter.next();
if(r instanceof EscherContainerRecord) {
// Create the Shape for it
EscherContainerRecord container = (EscherContainerRecord)r;
@ -79,7 +88,7 @@ public class ShapeGroup extends Shape{
}
// Put the shapes into an array, and return
Shape[] shapes = (Shape[])shapeList.toArray(new Shape[shapeList.size()]);
Shape[] shapes = shapeList.toArray(new Shape[shapeList.size()]);
return shapes;
}
@ -91,7 +100,7 @@ public class ShapeGroup extends Shape{
*/
public void setAnchor(java.awt.Rectangle anchor){
EscherContainerRecord spContainer = (EscherContainerRecord)_escherContainer.getChildRecords().get(0);
EscherContainerRecord spContainer = (EscherContainerRecord)_escherContainer.getChild(0);
EscherClientAnchorRecord clientAnchor = (EscherClientAnchorRecord)getEscherChild(spContainer, EscherClientAnchorRecord.RECORD_ID);
//hack. internal variable EscherClientAnchorRecord.shortRecord can be
@ -122,7 +131,7 @@ public class ShapeGroup extends Shape{
* @param anchor the coordinate space of this group
*/
public void setCoordinates(Rectangle2D anchor){
EscherContainerRecord spContainer = (EscherContainerRecord)_escherContainer.getChildRecords().get(0);
EscherContainerRecord spContainer = (EscherContainerRecord)_escherContainer.getChild(0);
EscherSpgrRecord spgr = (EscherSpgrRecord)getEscherChild(spContainer, EscherSpgrRecord.RECORD_ID);
int x1 = (int)Math.round(anchor.getX()*MASTER_DPI/POINT_DPI);
@ -144,7 +153,7 @@ public class ShapeGroup extends Shape{
* @return the coordinate space of this group
*/
public Rectangle2D getCoordinates(){
EscherContainerRecord spContainer = (EscherContainerRecord)_escherContainer.getChildRecords().get(0);
EscherContainerRecord spContainer = (EscherContainerRecord)_escherContainer.getChild(0);
EscherSpgrRecord spgr = (EscherSpgrRecord)getEscherChild(spContainer, EscherSpgrRecord.RECORD_ID);
Rectangle2D.Float anchor = new Rectangle2D.Float();
@ -228,7 +237,7 @@ public class ShapeGroup extends Shape{
* @return the anchor of this shape group
*/
public Rectangle2D getAnchor2D(){
EscherContainerRecord spContainer = (EscherContainerRecord)_escherContainer.getChildRecords().get(0);
EscherContainerRecord spContainer = (EscherContainerRecord)_escherContainer.getChild(0);
EscherClientAnchorRecord clientAnchor = (EscherClientAnchorRecord)getEscherChild(spContainer, EscherClientAnchorRecord.RECORD_ID);
Rectangle2D.Float anchor = new Rectangle2D.Float();
if(clientAnchor == null){

View File

@ -211,26 +211,32 @@ public abstract class Sheet {
EscherContainerRecord dg = (EscherContainerRecord) ppdrawing.getEscherRecords()[0];
EscherContainerRecord spgr = null;
List ch = dg.getChildRecords();
for (Iterator it = ch.iterator(); it.hasNext();) {
EscherRecord rec = (EscherRecord) it.next();
for (Iterator<EscherRecord> it = dg.getChildIterator(); it.hasNext();) {
EscherRecord rec = it.next();
if (rec.getRecordId() == EscherContainerRecord.SPGR_CONTAINER) {
spgr = (EscherContainerRecord) rec;
break;
}
}
ch = spgr.getChildRecords();
if (spgr == null) {
throw new IllegalStateException("spgr not found");
}
ArrayList shapes = new ArrayList();
for (int i = 1; i < ch.size(); i++) {
EscherContainerRecord sp = (EscherContainerRecord) ch.get(i);
List<Shape> shapes = new ArrayList<Shape>();
Iterator<EscherRecord> it = spgr.getChildIterator();
if (it.hasNext()) {
// skip first item
it.next();
}
for (; it.hasNext();) {
EscherContainerRecord sp = (EscherContainerRecord) it.next();
Shape sh = ShapeFactory.createShape(sp, null);
sh.setSheet(this);
shapes.add(sh);
}
return (Shape[]) shapes.toArray(new Shape[shapes.size()]);
return shapes.toArray(new Shape[shapes.size()]);
}
/**
@ -301,17 +307,21 @@ public abstract class Sheet {
EscherContainerRecord dg = (EscherContainerRecord) ppdrawing.getEscherRecords()[0];
EscherContainerRecord spgr = null;
for (Iterator it = dg.getChildRecords().iterator(); it.hasNext();) {
EscherRecord rec = (EscherRecord) it.next();
for (Iterator<EscherRecord> it = dg.getChildIterator(); it.hasNext();) {
EscherRecord rec = it.next();
if (rec.getRecordId() == EscherContainerRecord.SPGR_CONTAINER) {
spgr = (EscherContainerRecord) rec;
break;
}
}
if(spgr == null) return false;
if(spgr == null) {
return false;
}
List lst = spgr.getChildRecords();
return lst.remove(shape.getSpContainer());
List<EscherRecord> lst = spgr.getChildRecords();
boolean result = lst.remove(shape.getSpContainer());
spgr.setChildRecords(lst);
return result;
}
/**
@ -344,10 +354,9 @@ public abstract class Sheet {
EscherContainerRecord dg = (EscherContainerRecord) ppdrawing.getEscherRecords()[0];
EscherContainerRecord spContainer = null;
List ch = dg.getChildRecords();
for (Iterator it = ch.iterator(); it.hasNext();) {
EscherRecord rec = (EscherRecord) it.next();
for (Iterator<EscherRecord> it = dg.getChildIterator(); it.hasNext();) {
EscherRecord rec = it.next();
if (rec.getRecordId() == EscherContainerRecord.SP_CONTAINER) {
spContainer = (EscherContainerRecord) rec;
break;

View File

@ -17,20 +17,21 @@
package org.apache.poi.hslf.model;
import org.apache.poi.ddf.*;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.hslf.record.ColorSchemeAtom;
import org.apache.poi.hslf.record.Record;
import org.apache.poi.hslf.record.InteractiveInfo;
import org.apache.poi.hslf.record.InteractiveInfoAtom;
import org.apache.poi.hslf.exceptions.HSLFException;
import java.awt.*;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.util.Iterator;
import java.io.ByteArrayOutputStream;
import org.apache.poi.ddf.*;
import org.apache.poi.ddf.EscherSpRecord;
import org.apache.poi.hslf.exceptions.HSLFException;
import org.apache.poi.hslf.record.ColorSchemeAtom;
import org.apache.poi.hslf.record.InteractiveInfo;
import org.apache.poi.hslf.record.InteractiveInfoAtom;
import org.apache.poi.hslf.record.Record;
import org.apache.poi.util.LittleEndian;
/**
* An abstract simple (non-group) shape.
* This is the parent class for all primitive shapes like Line, Rectangle, etc.
@ -256,8 +257,8 @@ public class SimpleShape extends Shape {
Rectangle2D clientAnchor = top.getAnchor2D();
Rectangle2D spgrAnchor = ((ShapeGroup)top).getCoordinates();
double scalex = (double)spgrAnchor.getWidth()/clientAnchor.getWidth();
double scaley = (double)spgrAnchor.getHeight()/clientAnchor.getHeight();
double scalex = spgrAnchor.getWidth()/clientAnchor.getWidth();
double scaley = spgrAnchor.getHeight()/clientAnchor.getHeight();
double x = clientAnchor.getX() + (anchor.getX() - spgrAnchor.getX())/scalex;
double y = clientAnchor.getY() + (anchor.getY() - spgrAnchor.getY())/scaley;
@ -353,7 +354,7 @@ public class SimpleShape extends Shape {
EscherClientDataRecord cldata = new EscherClientDataRecord();
cldata.setOptions((short)0xF);
getSpContainer().getChildRecords().add(cldata);
getSpContainer().addChildRecord(cldata); // TODO - junit to prove getChildRecords().add is wrong
InteractiveInfo info = new InteractiveInfo();
InteractiveInfoAtom infoAtom = info.getInteractiveInfoAtom();

View File

@ -152,7 +152,7 @@ public class Slide extends Sheet
EscherSpRecord spr = null;
switch(c.getRecordId()){
case EscherContainerRecord.SPGR_CONTAINER:
EscherContainerRecord dc = (EscherContainerRecord)c.getChildRecords().get(0);
EscherContainerRecord dc = (EscherContainerRecord)c.getChild(0);
spr = dc.getChildById(EscherSpRecord.RECORD_ID);
break;
case EscherContainerRecord.SP_CONTAINER:

View File

@ -73,7 +73,6 @@ public class Table extends ShapeGroup {
setAnchor(new Rectangle(0, 0, tblWidth, tblHeight));
EscherContainerRecord spCont = (EscherContainerRecord) getSpContainer().getChild(0);
List lst = spCont.getChildRecords();
EscherOptRecord opt = new EscherOptRecord();
opt.setRecordId((short)0xF122);
opt.addEscherProperty(new EscherSimpleProperty((short)0x39F, 1));
@ -82,8 +81,9 @@ public class Table extends ShapeGroup {
p.setNumberOfElementsInArray(numrows);
p.setNumberOfElementsInMemory(numrows);
opt.addEscherProperty(p);
List<EscherRecord> lst = spCont.getChildRecords();
lst.add(lst.size()-1, opt);
spCont.setChildRecords(lst);
}
/**
@ -118,7 +118,7 @@ public class Table extends ShapeGroup {
super.afterInsert(sh);
EscherContainerRecord spCont = (EscherContainerRecord) getSpContainer().getChild(0);
List lst = spCont.getChildRecords();
List<EscherRecord> lst = spCont.getChildRecords();
EscherOptRecord opt = (EscherOptRecord)lst.get(lst.size()-2);
EscherArrayProperty p = (EscherArrayProperty)opt.getEscherProperty(1);
for (int i = 0; i < cells.length; i++) {

View File

@ -175,11 +175,9 @@ public class PPDrawing extends RecordAtom
} else {
// If it has children, walk them
if(toSearch[i].isContainerRecord()) {
List childrenL = toSearch[i].getChildRecords();
List<EscherRecord> childrenL = toSearch[i].getChildRecords();
EscherRecord[] children = new EscherRecord[childrenL.size()];
for(int j=0; j< children.length; j++) {
children[j] = (EscherRecord)childrenL.get(j);
}
childrenL.toArray(children);
findEscherTextboxRecord(children,found);
}
}
@ -309,8 +307,8 @@ public class PPDrawing extends RecordAtom
public EscherDgRecord getEscherDgRecord(){
if(dg == null){
EscherContainerRecord dgContainer = (EscherContainerRecord)childRecords[0];
for(Iterator it = dgContainer.getChildRecords().iterator(); it.hasNext();){
EscherRecord r = (EscherRecord) it.next();
for(Iterator<EscherRecord> it = dgContainer.getChildIterator(); it.hasNext();){
EscherRecord r = it.next();
if(r instanceof EscherDgRecord){
dg = (EscherDgRecord)r;
break;

View File

@ -71,15 +71,14 @@ public class PPDrawingGroup extends RecordAtom {
public void writeOut(OutputStream out) throws IOException {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
List child = dggContainer.getChildRecords();
for (int i = 0; i < child.size(); i++) {
EscherRecord r = (EscherRecord)child.get(i);
Iterator<EscherRecord> iter = dggContainer.getChildIterator();
while (iter.hasNext()) {
EscherRecord r = iter.next();
if (r.getRecordId() == EscherContainerRecord.BSTORE_CONTAINER){
EscherContainerRecord bstore = (EscherContainerRecord)r;
ByteArrayOutputStream b2 = new ByteArrayOutputStream();
List blip = bstore.getChildRecords();
for (Iterator it=blip.iterator(); it.hasNext();) {
for (Iterator<EscherRecord> it= bstore.getChildIterator(); it.hasNext();) {
EscherBSERecord bse = (EscherBSERecord)it.next();
byte[] b = new byte[36+8];
bse.serialize(0, b);
@ -121,8 +120,8 @@ public class PPDrawingGroup extends RecordAtom {
public EscherDggRecord getEscherDggRecord(){
if(dgg == null){
for(Iterator it = dggContainer.getChildRecords().iterator(); it.hasNext();){
EscherRecord r = (EscherRecord) it.next();
for(Iterator<EscherRecord> it = dggContainer.getChildIterator(); it.hasNext();){
EscherRecord r = it.next();
if(r instanceof EscherDggRecord){
dgg = (EscherDggRecord)r;
break;

View File

@ -746,19 +746,11 @@ public final class SlideShow {
bstore = new EscherContainerRecord();
bstore.setRecordId( EscherContainerRecord.BSTORE_CONTAINER);
List child = dggContainer.getChildRecords();
for ( int i = 0; i < child.size(); i++ ) {
EscherRecord rec = (EscherRecord)child.get(i);
if (rec.getRecordId() == EscherOptRecord.RECORD_ID){
child.add(i, bstore);
i++;
}
}
dggContainer.setChildRecords(child);
dggContainer.addChildBefore(bstore, EscherOptRecord.RECORD_ID);
} else {
List lst = bstore.getChildRecords();
for ( int i = 0; i < lst.size(); i++ ) {
EscherBSERecord bse = (EscherBSERecord) lst.get(i);
Iterator<EscherRecord> iter = bstore.getChildIterator();
for (int i = 0; iter.hasNext(); i++) {
EscherBSERecord bse = (EscherBSERecord) iter.next();
if (Arrays.equals(bse.getUid(), uid)){
return i + 1;
}

View File

@ -44,8 +44,8 @@ public class TestEscherBlipRecord extends TestCase
EscherContainerRecord record = new EscherContainerRecord();
record.fillFields(data, 0, new DefaultEscherRecordFactory());
EscherContainerRecord bstore = (EscherContainerRecord)record.getChildRecords().get(1);
EscherBSERecord bse1 = (EscherBSERecord)bstore.getChildRecords().get(0);
EscherContainerRecord bstore = (EscherContainerRecord)record.getChild(1);
EscherBSERecord bse1 = (EscherBSERecord)bstore.getChild(0);
assertEquals(EscherBSERecord.BT_PNG, bse1.getBlipTypeWin32());
assertEquals(EscherBSERecord.BT_PNG, bse1.getBlipTypeMacOS());
assertTrue(Arrays.equals(new byte[]{
@ -89,8 +89,8 @@ public class TestEscherBlipRecord extends TestCase
EscherContainerRecord record = new EscherContainerRecord();
record.fillFields(data, 0, new DefaultEscherRecordFactory());
EscherContainerRecord bstore = (EscherContainerRecord)record.getChildRecords().get(1);
EscherBSERecord bse1 = (EscherBSERecord)bstore.getChildRecords().get(1);
EscherContainerRecord bstore = (EscherContainerRecord)record.getChild(1);
EscherBSERecord bse1 = (EscherBSERecord)bstore.getChild(1);
//System.out.println(bse1);
assertEquals(EscherBSERecord.BT_WMF, bse1.getBlipTypeWin32());
assertEquals(EscherBSERecord.BT_PICT, bse1.getBlipTypeMacOS());

View File

@ -34,15 +34,11 @@ import java.util.List;
*
* @author Glen Stampoultzis (glens at apache.org)
*/
public class TestEscherAggregate extends TestCase
{
public final class TestEscherAggregate extends TestCase {
/**
* Tests that the create aggregate method correctly rejoins escher records together.
*
* @throws Exception
*/
public void testCreateAggregate() throws Exception
{
public void testCreateAggregate() {
String msoDrawingRecord1 =
"0F 00 02 F0 20 01 00 00 10 00 08 F0 08 00 00 00 \n" +
"03 00 00 00 02 04 00 00 0F 00 03 F0 08 01 00 00 \n" +
@ -76,7 +72,7 @@ public class TestEscherAggregate extends TestCase
ObjRecord r2 = new ObjRecord();
List records = new ArrayList();
List<Record> records = new ArrayList<Record>();
records.add( d1 );
records.add( r1 );
records.add( d2 );
@ -92,8 +88,7 @@ public class TestEscherAggregate extends TestCase
// System.out.println( "aggregate = " + aggregate );
}
public void testSerialize() throws Exception
{
public void testSerialize() {
EscherContainerRecord container1 = new EscherContainerRecord();
EscherContainerRecord spContainer1 = new EscherContainerRecord();
@ -127,8 +122,8 @@ public class TestEscherAggregate extends TestCase
EscherAggregate aggregate = new EscherAggregate(null);
aggregate.addEscherRecord( container1 );
aggregate.assoicateShapeToObjRecord( d2, new ObjRecord() );
aggregate.assoicateShapeToObjRecord( d3, new ObjRecord() );
aggregate.associateShapeToObjRecord( d2, new ObjRecord() );
aggregate.associateShapeToObjRecord( d3, new ObjRecord() );
byte[] data = new byte[112];
int bytesWritten = aggregate.serialize( 0, data );
@ -136,5 +131,4 @@ public class TestEscherAggregate extends TestCase
assertEquals( "[EC, 00, 40, 00, 0F, 00, 00, 00, 58, 00, 00, 00, 0F, 00, 04, F0, 10, 00, 00, 00, 00, 00, 0A, F0, 08, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 0F, 00, 04, F0, 18, 00, 00, 00, 00, 00, 0A, F0, 08, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 11, F0, 00, 00, 00, 00, 5D, 00, 00, 00, EC, 00, 20, 00, 0F, 00, 04, F0, 18, 00, 00, 00, 00, 00, 0A, F0, 08, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 11, F0, 00, 00, 00, 00, 5D, 00, 00, 00]",
HexDump.toHex( data ) );
}
}