import java.awt.font.FontRenderContext;\r
import java.awt.font.TextLayout;\r
import java.io.IOException;\r
+import java.util.Vector;\r
\r
/**\r
* Represents a TextFrame shape in PowerPoint.\r
\r
/**\r
* Create a TextBox object and initialize it from the supplied Record container.\r
- *\r
+ * \r
* @param escherRecord <code>EscherSpContainer</code> container which holds information about this shape\r
* @param parent the parent of the shape\r
*/\r
\r
EscherTextboxRecord textbox = (EscherTextboxRecord)Shape.getEscherChild(_escherContainer, EscherTextboxRecord.RECORD_ID);\r
_txtbox = new EscherTextboxWrapper(textbox);\r
-\r
- TextHeaderAtom tha = null;\r
- TextBytesAtom tba = null;\r
- StyleTextPropAtom sta = null;\r
- Record[] child = _txtbox.getChildRecords();\r
- for (int i = 0; i < child.length; i++) {\r
- if (child[i] instanceof TextHeaderAtom) tha = (TextHeaderAtom)child[i];\r
- else if (child[i] instanceof TextBytesAtom) tba = (TextBytesAtom)child[i];\r
- else if (child[i] instanceof StyleTextPropAtom) sta = (StyleTextPropAtom)child[i];\r
+ \r
+ // Find our TextRun\r
+ Vector v = new Vector();\r
+ Sheet.findTextRuns(_txtbox.getChildRecords(), v);\r
+ \r
+ // We should just have one\r
+ if(v.size() == 1) {\r
+ _txtrun = (TextRun)v.get(0);\r
+ } else {\r
+ throw new IllegalStateException("A TextBox should have one TextRun's worth of records in it, found " + v.size());\r
}\r
-\r
- _txtrun = new TextRun(tha,tba,sta);\r
}\r
\r
/**\r
_txtbox = new EscherTextboxWrapper();\r
\r
TextHeaderAtom tha = new TextHeaderAtom();\r
+ tha.setParentRecord(_txtbox); // TextHeaderAtom is parent aware\r
_txtbox.appendChildRecord(tha);\r
\r
TextBytesAtom tba = new TextBytesAtom();\r