git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1203295 13f79535-47bb-0310-9956-ffa450edef68tags/REL_3_8_BETA5
<changes> | <changes> | ||||
<release version="3.8-beta5" date="2011-??-??"> | <release version="3.8-beta5" date="2011-??-??"> | ||||
<action dev="poi-developers" type="fix">51803 - fixed HSLF TextExtractor to extract content from master slide </action> | |||||
<action dev="poi-developers" type="fix">52190 - null check on XWPF setFontFamily</action> | <action dev="poi-developers" type="fix">52190 - null check on XWPF setFontFamily</action> | ||||
<action dev="poi-developers" type="fix">52062 - ensure that temporary files in SXSSF are deleted</action> | <action dev="poi-developers" type="fix">52062 - ensure that temporary files in SXSSF are deleted</action> | ||||
<action dev="poi-developers" type="fix">50936 - Exception parsing MS Word 8.0 file (as duplicate of 47958)</action> | <action dev="poi-developers" type="fix">50936 - Exception parsing MS Word 8.0 file (as duplicate of 47958)</action> |
if (getSlideText) { | if (getSlideText) { | ||||
if (getMasterText) { | if (getMasterText) { | ||||
for (SlideMaster master : _show.getSlidesMasters()) { | for (SlideMaster master : _show.getSlidesMasters()) { | ||||
textRunsToText(ret, master.getTextRuns()); | |||||
for(Shape sh : master.getShapes()){ | |||||
if(sh instanceof TextShape){ | |||||
if(MasterSheet.isPlaceholder(sh)) { | |||||
// don't bother about boiler | |||||
// plate text on master | |||||
// sheets | |||||
continue; | |||||
} | |||||
TextShape tsh = (TextShape)sh; | |||||
String text = tsh.getText(); | |||||
ret.append(text); | |||||
if (!text.endsWith("\n")) { | |||||
ret.append("\n"); | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
} | } | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.Vector; | |||||
import java.awt.*; | import java.awt.*; | ||||
/** | /** | ||||
* For a given PPDrawing, grab all the TextRuns | * For a given PPDrawing, grab all the TextRuns | ||||
*/ | */ | ||||
public static TextRun[] findTextRuns(PPDrawing ppdrawing) { | public static TextRun[] findTextRuns(PPDrawing ppdrawing) { | ||||
Vector runsV = new Vector(); | |||||
final List<TextRun> runsV = new ArrayList<TextRun>(); | |||||
EscherTextboxWrapper[] wrappers = ppdrawing.getTextboxWrappers(); | EscherTextboxWrapper[] wrappers = ppdrawing.getTextboxWrappers(); | ||||
for (int i = 0; i < wrappers.length; i++) { | for (int i = 0; i < wrappers.length; i++) { | ||||
int s1 = runsV.size(); | int s1 = runsV.size(); | ||||
findTextRuns(wrappers[i].getChildRecords(), runsV); | findTextRuns(wrappers[i].getChildRecords(), runsV); | ||||
int s2 = runsV.size(); | int s2 = runsV.size(); | ||||
if (s2 != s1){ | if (s2 != s1){ | ||||
TextRun t = (TextRun) runsV.get(runsV.size()-1); | |||||
TextRun t = runsV.get(runsV.size()-1); | |||||
t.setShapeId(wrappers[i].getShapeId()); | t.setShapeId(wrappers[i].getShapeId()); | ||||
} | } | ||||
} | } | ||||
TextRun[] runs = new TextRun[runsV.size()]; | |||||
for (int i = 0; i < runs.length; i++) { | |||||
runs[i] = (TextRun) runsV.get(i); | |||||
} | |||||
return runs; | |||||
return runsV.toArray(new TextRun[runsV.size()]); | |||||
} | } | ||||
/** | /** | ||||
* @param records the records to build from | * @param records the records to build from | ||||
* @param found vector to add any found to | * @param found vector to add any found to | ||||
*/ | */ | ||||
protected static void findTextRuns(Record[] records, Vector found) { | |||||
protected static void findTextRuns(Record[] records, List<TextRun> found) { | |||||
// Look for a TextHeaderAtom | // Look for a TextHeaderAtom | ||||
for (int i = 0, slwtIndex=0; i < (records.length - 1); i++) { | for (int i = 0, slwtIndex=0; i < (records.length - 1); i++) { | ||||
if (records[i] instanceof TextHeaderAtom) { | if (records[i] instanceof TextHeaderAtom) { |
// Initially not there | // Initially not there | ||||
String text = ppe.getText(); | String text = ppe.getText(); | ||||
assertFalse(text.contains("Master Header Text")); | |||||
assertFalse(text.contains("Text that I added to the master slide")); | |||||
// Enable, shows up | // Enable, shows up | ||||
ppe.setMasterByDefault(true); | ppe.setMasterByDefault(true); | ||||
text = ppe.getText(); | text = ppe.getText(); | ||||
assertTrue(text.contains("Master Header Text")); | |||||
assertTrue(text.contains("Text that I added to the master slide")); | |||||
// Make sure placeholder text does not come out | |||||
assertFalse(text.contains("Click to edit Master")); | |||||
// Now with another file only containing master text | // Now with another file only containing master text | ||||
// Will always show up | // Will always show up |