<changes>
<release version="3.7-SNAPSHOT" date="2010-??-??">
+ <action dev="POI-DEVELOPERS" type="fix">48916 - Propagate parent to parent-aware records decoded from Escher</action>
<action dev="POI-DEVELOPERS" type="fix">48485 - Add extra paper size constans to PrintSetup, such as A3, B4 and B5</action>
<action dev="POI-DEVELOPERS" type="fix">Make poifs.filesystem.DirectoryNode preserve the original ordering of its files, which HSMF needs to be able to correctly match up chunks</action>
<action dev="POI-DEVELOPERS" type="add">Support evaluation of indirect defined names in INDIRECT</action>
EscherTextboxWrapper[] wrappers = ppdrawing.getTextboxWrappers();
for (int i = 0; i < wrappers.length; i++) {
int s1 = runsV.size();
+
+ // propagate parents to parent-aware records
+ RecordContainer.handleParentAwareRecords(wrappers[i]);
findTextRuns(wrappers[i].getChildRecords(), runsV);
int s2 = runsV.size();
if (s2 != s1){
_runs = tmp;
}
}
+
+ public TxMasterStyleAtom[] getTxMasterStyleAtoms(){
+ return _txmaster;
+ }
}
}
}
}
+ // ensure the same references child records of TextRun
+ if(_txtrun != null) for (int i = 0; i < child.length; i++) {
+ for (Record r : _txtrun.getRecords()) {
+ if (child[i].getRecordType() == r.getRecordType()) {
+ child[i] = r;
+ }
+ }
+ }
}
public void draw(Graphics2D graphics){
out.write(toWrite);
}
}
+
+ /**
+ * Find the records that are parent-aware, and tell them who their parent is
+ */
+ public static void handleParentAwareRecords(RecordContainer br) {
+ // Loop over child records, looking for interesting ones
+ for (Record record : br.getChildRecords()) {
+ // Tell parent aware records of their parent
+ if (record instanceof ParentAwareRecord) {
+ ((ParentAwareRecord) record).setParentRecord(br);
+ }
+ // Walk on down for the case of container records
+ if (record instanceof RecordContainer) {
+ handleParentAwareRecords((RecordContainer)record);
+ }
+ }
+ }
+
+
}
* @param hslfSlideShow the HSLFSlideShow to base on
*/
public SlideShow(HSLFSlideShow hslfSlideShow) {
- // Get useful things from our base slideshow
- _hslfSlideShow = hslfSlideShow;
+ // Get useful things from our base slideshow
+ _hslfSlideShow = hslfSlideShow;
_records = _hslfSlideShow.getRecords();
- // Handle Parent-aware Reocrds
- for (int i = 0; i < _records.length; i++) {
- handleParentAwareRecords(_records[i]);
+ // Handle Parent-aware Records
+ for (Record record : _records) {
+ if(record instanceof RecordContainer){
+ RecordContainer.handleParentAwareRecords((RecordContainer)record);
+ }
}
// Find the versions of the core records we'll want to use
this(new HSLFSlideShow(inputStream));
}
- /**
- * Find the records that are parent-aware, and tell them who their parent is
- */
- private void handleParentAwareRecords(Record baseRecord) {
- // Only need to do something if this is a container record
- if (baseRecord instanceof RecordContainer) {
- RecordContainer br = (RecordContainer) baseRecord;
- Record[] childRecords = br.getChildRecords();
-
- // Loop over child records, looking for interesting ones
- for (int i = 0; i < childRecords.length; i++) {
- Record record = childRecords[i];
- // Tell parent aware records of their parent
- if (record instanceof ParentAwareRecord) {
- ((ParentAwareRecord) record).setParentRecord(br);
- }
- // Walk on down for the case of container records
- if (record instanceof RecordContainer) {
- handleParentAwareRecords(record);
- }
- }
- }
- }
-
/**
* Use the PersistPtrHolder entries to figure out what is the "most recent"
* version of all the core records (Document, Notes, Slide etc), and save a
package org.apache.poi.hslf.model;
+import java.awt.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import junit.framework.TestCase;
import org.apache.poi.hslf.model.textproperties.TextPropCollection;
+import org.apache.poi.hslf.record.Record;
import org.apache.poi.hslf.record.TextBytesAtom;
import org.apache.poi.hslf.record.TextCharsAtom;
import org.apache.poi.hslf.record.TextHeaderAtom;
assertNotNull(runs);
assertEquals(4, runs.length);
}
+
+ public void test48916() throws IOException {
+ SlideShow ppt = new SlideShow(_slTests.openResourceAsStream("SampleShow.ppt"));
+ for(Slide slide : ppt.getSlides()){
+ for(Shape sh : slide.getShapes()){
+ if(sh instanceof TextShape){
+ TextShape tx = (TextShape)sh;
+ TextRun run = tx.getTextRun();
+ //verify that records cached in TextRun and EscherTextboxWrapper are the same
+ Record[] runChildren = run.getRecords();
+ Record[] txboxChildren = tx.getEscherTextboxWrapper().getChildRecords();
+ assertEquals(runChildren.length, txboxChildren.length);
+ for(int i=0; i < txboxChildren.length; i++){
+ assertSame(txboxChildren[i], runChildren[i]);
+ }
+ //caused NPE prior to fix of Bugzilla #48916
+ run.getRichTextRuns()[0].setBold(true);
+ run.getRichTextRuns()[0].setFontColor(Color.RED);
+ }
+ }
+ }
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ ppt.write(out);
+ ppt = new SlideShow(new ByteArrayInputStream(out.toByteArray()));
+ for(Slide slide : ppt.getSlides()){
+ for(Shape sh : slide.getShapes()){
+ if(sh instanceof TextShape){
+ TextShape tx = (TextShape)sh;
+ TextRun run = tx.getTextRun();
+ RichTextRun rt = run.getRichTextRuns()[0];
+ assertTrue(rt.isBold());
+ assertEquals(rt.getFontColor(), Color.RED);
+ }
+ }
+ }
+
+ }
}