<!-- Don't forget to update status.xml too! -->
<release version="3.1.1-alpha1" date="2008-??-??">
+ <action dev="POI-DEVELOPERS" type="fix">Properly update the array of Slide's text runs in HSLF when new text shapes are added</action>
<action dev="POI-DEVELOPERS" type="fix">45590 - Fix for Header/footer extraction for .ppt files saved in Office 2007</action>
<action dev="POI-DEVELOPERS" type="fix">Big improvement in how HWPF handles unicode text, and more sanity checking of text ranges within HWPF</action>
<action dev="POI-DEVELOPERS" type="add">Include headers and footers int he extracted text from HWPF's WordExtractor</action>
<!-- Don't forget to update changes.xml too! -->
<changes>
<release version="3.1.1-alpha1" date="2008-??-??">
+ <action dev="POI-DEVELOPERS" type="fix">Properly update the array of Slide's text runs in HSLF when new text shapes are added</action>
<action dev="POI-DEVELOPERS" type="fix">45590 - Fix for Header/footer extraction for .ppt files saved in Office 2007</action>
<action dev="POI-DEVELOPERS" type="fix">Big improvement in how HWPF handles unicode text, and more sanity checking of text ranges within HWPF</action>
<action dev="POI-DEVELOPERS" type="add">Include headers and footers int he extracted text from HWPF's WordExtractor</action>
}
+ /**
+ * Subclasses should call this method and update the array of text runs
+ * when a text shape is added
+ *
+ * @param shape
+ */
+ protected void onAddTextShape(TextShape shape) {
+
+ }
+
/**
* Return placeholder by text type
*
}
-
}
return new HeadersFooters(hdd, this, newRecord, ppt2007);
}
}
+
+ protected void onAddTextShape(TextShape shape) {
+ TextRun run = shape.getTextRun();
+
+ if(_runs == null) _runs = new TextRun[]{run};
+ else {
+ TextRun[] tmp = new TextRun[_runs.length + 1];
+ System.arraycopy(_runs, 0, tmp, 0, _runs.length);
+ tmp[tmp.length-1] = run;
+ _runs = tmp;
+ }
+ }
}
}
}
- /**
- * Checks if the shape is a placeholder.
- * (placeholders aren't normal shapes, they are visible only in the Edit Master mode)
- *
- *
- * @return true if the shape is a placeholder
- */
- public static boolean isPlaceholder(Shape shape){
- if(!(shape instanceof TextShape)) return false;
-
- TextShape tx = (TextShape)shape;
- TextRun run = tx.getTextRun();
- if(run == null) return false;
-
- Record[] records = run._records;
- for (int i = 0; i < records.length; i++) {
- int type = (int)records[i].getRecordType();
- if (type == RecordTypes.OEPlaceholderAtom.typeID ||
- type == RecordTypes.SlideNumberMCAtom.typeID ||
- type == RecordTypes.DateTimeMCAtom.typeID ||
- type == RecordTypes.GenericDateMCAtom.typeID ||
- type == RecordTypes.FooterMCAtom.typeID ){
- return true;
-
- }
-
+ protected void onAddTextShape(TextShape shape) {
+ TextRun run = shape.getTextRun();
+
+ if(_runs == null) _runs = new TextRun[]{run};
+ else {
+ TextRun[] tmp = new TextRun[_runs.length + 1];
+ System.arraycopy(_runs, 0, tmp, 0, _runs.length);
+ tmp[tmp.length-1] = run;
+ _runs = tmp;
}
- return false;
}
}
}
if(getAnchor().equals(new Rectangle()) && !"".equals(getText())) resizeToFitText();
}
+ if(_txtrun != null) {
+ _txtrun.setShapeId(getShapeId());
+ sh.onAddTextShape(this);
+ }
}
protected EscherTextboxWrapper getEscherTextboxWrapper(){
assertEquals("Sdfsdfs\n" +
"Sdfsdf\n", rt[1].getText());
}
+
+ /**
+ * Test creation of TextRun objects.
+ */
+ public void testAddTextRun() throws Exception{
+ SlideShow ppt = new SlideShow();
+ Slide slide = ppt.createSlide();
+
+ assertNull(slide.getTextRuns());
+
+ TextBox shape1 = new TextBox();
+ TextRun run1 = shape1.getTextRun();
+ assertSame(run1, shape1.createTextRun());
+ run1.setText("Text 1");
+ slide.addShape(shape1);
+
+ //The array of Slide's text runs must be updated when new text shapes are added.
+ TextRun[] runs = slide.getTextRuns();
+ assertNotNull(runs);
+ assertSame(run1, runs[0]);
+
+ TextBox shape2 = new TextBox();
+ TextRun run2 = shape2.getTextRun();
+ assertSame(run2, shape2.createTextRun());
+ run2.setText("Text 2");
+ slide.addShape(shape2);
+
+ runs = slide.getTextRuns();
+ assertEquals(2, runs.length);
+
+ assertSame(run1, runs[0]);
+ assertSame(run2, runs[1]);
+
+ //as getShapes()
+ Shape[] sh = slide.getShapes();
+ assertEquals(2, sh.length);
+ assertTrue(sh[0] instanceof TextBox);
+ TextBox box1 = (TextBox)sh[0];
+ assertSame(run1, box1.getTextRun());
+ TextBox box2 = (TextBox)sh[1];
+ assertSame(run2, box2.getTextRun());
+
+ //test Table - a complex group of shapes containing text objects
+ Slide slide2 = ppt.createSlide();
+ assertNull(slide2.getTextRuns());
+ Table table = new Table(2, 2);
+ slide2.addShape(table);
+ runs = slide2.getTextRuns();
+ assertNotNull(runs);
+ assertEquals(4, runs.length);
+ }
}