aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGlen Stampoultzis <glens@apache.org>2005-05-05 13:40:06 +0000
committerGlen Stampoultzis <glens@apache.org>2005-05-05 13:40:06 +0000
commitc3b74a65d6474351c571f74bdfa3a9f15312de4c (patch)
treef8fb104e28c3e9c0c61e359b6459c7b3abef8466 /src
parent9e45972bd16e40a440bdc7c31131a3791748fc8e (diff)
downloadpoi-c3b74a65d6474351c571f74bdfa3a9f15312de4c.tar.gz
poi-c3b74a65d6474351c571f74bdfa3a9f15312de4c.zip
Bug 34745 Update ddf.EscherTextboxRecord to be cleaner, and allow setting of new data
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353675 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/poi/ddf/EscherTextboxRecord.java70
1 files changed, 30 insertions, 40 deletions
diff --git a/src/java/org/apache/poi/ddf/EscherTextboxRecord.java b/src/java/org/apache/poi/ddf/EscherTextboxRecord.java
index a69a2dd569..4d372c5b44 100644
--- a/src/java/org/apache/poi/ddf/EscherTextboxRecord.java
+++ b/src/java/org/apache/poi/ddf/EscherTextboxRecord.java
@@ -17,18 +17,18 @@
package org.apache.poi.ddf;
+import org.apache.poi.hssf.record.RecordFormatException;
import org.apache.poi.util.HexDump;
import org.apache.poi.util.LittleEndian;
-import org.apache.poi.hssf.record.RecordFormatException;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.ArrayList;
/**
- * Supports text boxes
+ * Holds data from the parent application. Most commonly used to store
+ * text in the format of the parent application, rather than in
+ * Escher format. We don't attempt to understand the contents, since
+ * they will be in the parent's format, not Escher format.
*
* @author Glen Stampoultzis (glens at apache.org)
+ * @author Nick Burch (nick at torchbox dot com)
*/
public class EscherTextboxRecord extends EscherRecord
{
@@ -55,29 +55,12 @@ public class EscherTextboxRecord extends EscherRecord
public int fillFields( byte[] data, int offset, EscherRecordFactory recordFactory )
{
int bytesRemaining = readHeader( data, offset );
- if ( isContainerRecord() )
- {
- int bytesWritten = 0;
- thedata = new byte[0];
- offset += 8;
- bytesWritten += 8;
- while ( bytesRemaining > 0 )
- {
- EscherRecord child = recordFactory.createRecord( data, offset );
- int childBytesWritten = child.fillFields( data, offset, recordFactory );
- bytesWritten += childBytesWritten;
- offset += childBytesWritten;
- bytesRemaining -= childBytesWritten;
- getChildRecords().add( child );
- }
- return bytesWritten;
- }
- else
- {
- thedata = new byte[bytesRemaining];
- System.arraycopy( data, offset + 8, thedata, 0, bytesRemaining );
- return bytesRemaining + 8;
- }
+
+ // Save the data, ready for the calling code to do something
+ // useful with it
+ thedata = new byte[bytesRemaining];
+ System.arraycopy( data, offset + 8, thedata, 0, bytesRemaining );
+ return bytesRemaining + 8;
}
/**
@@ -93,19 +76,9 @@ public class EscherTextboxRecord extends EscherRecord
LittleEndian.putShort(data, offset, getOptions());
LittleEndian.putShort(data, offset+2, getRecordId());
int remainingBytes = thedata.length;
- for ( Iterator iterator = getChildRecords().iterator(); iterator.hasNext(); )
- {
- EscherRecord r = (EscherRecord) iterator.next();
- remainingBytes += r.getRecordSize();
- }
LittleEndian.putInt(data, offset+4, remainingBytes);
System.arraycopy(thedata, 0, data, offset+8, thedata.length);
int pos = offset+8+thedata.length;
- for ( Iterator iterator = getChildRecords().iterator(); iterator.hasNext(); )
- {
- EscherRecord r = (EscherRecord) iterator.next();
- pos += r.serialize(pos, data, listener );
- }
listener.afterRecordSerialize( pos, getRecordId(), pos - offset, this );
int size = pos - offset;
@@ -116,7 +89,9 @@ public class EscherTextboxRecord extends EscherRecord
/**
* Returns any extra data associated with this record. In practice excel
- * does not seem to put anything here.
+ * does not seem to put anything here, but with PowerPoint this will
+ * contain the bytes that make up a TextHeaderAtom followed by a
+ * TextBytesAtom/TextCharsAtom
*/
public byte[] getData()
{
@@ -124,6 +99,21 @@ public class EscherTextboxRecord extends EscherRecord
}
/**
+ * Sets the extra data (in the parent application's format) to be
+ * contained by the record. Used when the parent application changes
+ * the contents.
+ */
+ public void setData(byte[] b, int start, int length)
+ {
+ thedata = new byte[length];
+ System.arraycopy(b,start,thedata,0,length);
+ }
+ public void setData(byte[] b) {
+ setData(b,0,b.length);
+ }
+
+
+ /**
* Returns the number of bytes that are required to serialize this record.
*
* @return Number of bytes