use of org.apache.poi.hslf.record.EscherTextboxWrapper in project poi by apache.
the class SlideShowRecordDumper method printEscherTextBox.
private void printEscherTextBox(EscherTextboxRecord tbRecord, int indent) {
String ind = tabs.substring(0, indent);
ps.println(ind + "EscherTextboxRecord:");
EscherTextboxWrapper etw = new EscherTextboxWrapper(tbRecord);
Record prevChild = null;
for (Record child : etw.getChildRecords()) {
if (child instanceof StyleTextPropAtom) {
// need preceding Text[Chars|Bytes]Atom to initialize the data structure
String text = null;
if (prevChild instanceof TextCharsAtom) {
text = ((TextCharsAtom) prevChild).getText();
} else if (prevChild instanceof TextBytesAtom) {
text = ((TextBytesAtom) prevChild).getText();
} else {
ps.println(ind + "Error! Couldn't find preceding TextAtom for style");
continue;
}
StyleTextPropAtom tsp = (StyleTextPropAtom) child;
tsp.setParentTextSize(text.length());
}
ps.println(ind + child);
prevChild = child;
}
}
use of org.apache.poi.hslf.record.EscherTextboxWrapper in project poi by apache.
the class HSLFTextShape method getEscherTextboxWrapper.
protected EscherTextboxWrapper getEscherTextboxWrapper() {
if (_txtbox != null) {
return _txtbox;
}
EscherTextboxRecord textRecord = getEscherChild(EscherTextboxRecord.RECORD_ID);
if (textRecord == null) {
return null;
}
HSLFSheet sheet = getSheet();
if (sheet != null) {
PPDrawing drawing = sheet.getPPDrawing();
if (drawing != null) {
EscherTextboxWrapper[] wrappers = drawing.getTextboxWrappers();
if (wrappers != null) {
for (EscherTextboxWrapper w : wrappers) {
// check for object identity
if (textRecord == w.getEscherRecord()) {
_txtbox = w;
return _txtbox;
}
}
}
}
}
_txtbox = new EscherTextboxWrapper(textRecord);
return _txtbox;
}
use of org.apache.poi.hslf.record.EscherTextboxWrapper in project poi by apache.
the class TestNumberedList2 method checkSlide0.
private void checkSlide0(final HSLFSlide s) {
final StyleTextProp9Atom[] numberedListArray = s.getNumberedListInfo();
assertNotNull(numberedListArray);
assertEquals(2, numberedListArray.length);
final StyleTextProp9Atom numberedListInfoForTextBox0 = numberedListArray[0];
final StyleTextProp9Atom numberedListInfoForTextBox1 = numberedListArray[1];
assertNotNull(numberedListInfoForTextBox0);
assertNotNull(numberedListInfoForTextBox1);
final TextPFException9[] autoNumbersOfTextBox0 = numberedListInfoForTextBox0.getAutoNumberTypes();
assertEquals(Short.valueOf((short) 1), autoNumbersOfTextBox0[0].getfBulletHasAutoNumber());
//Default value = 1 will be used
assertEquals(Short.valueOf((short) 1), autoNumbersOfTextBox0[0].getAutoNumberStartNumber());
assertTrue(AutoNumberingScheme.arabicPeriod == autoNumbersOfTextBox0[0].getAutoNumberScheme());
final TextPFException9[] autoNumbersOfTextBox1 = numberedListInfoForTextBox1.getAutoNumberTypes();
assertEquals(Short.valueOf((short) 1), autoNumbersOfTextBox1[0].getfBulletHasAutoNumber());
//Default value = 1 will be used
assertEquals(Short.valueOf((short) 6), autoNumbersOfTextBox1[0].getAutoNumberStartNumber());
assertTrue(AutoNumberingScheme.arabicPeriod == autoNumbersOfTextBox1[0].getAutoNumberScheme());
List<List<HSLFTextParagraph>> textParass = s.getTextParagraphs();
assertEquals(2, textParass.size());
List<HSLFTextParagraph> textParas = textParass.get(0);
assertEquals("List Item One\rList Item Two\rList Item Three", HSLFTextParagraph.getRawText(textParas));
assertEquals(3, textParas.size());
assertTrue(textParas.get(0).isBullet());
String expected = "A numbered list may start at any number \r" + "This would be used as a continuation list on another page\r" + "This list should start with #6";
assertEquals(expected, HSLFTextParagraph.getRawText(textParass.get(1)));
final EscherTextboxWrapper[] styleAtoms = s.getTextboxWrappers();
assertEquals(textParass.size(), styleAtoms.length);
checkSingleRunWrapper(44, styleAtoms[0]);
checkSingleRunWrapper(130, styleAtoms[1]);
}
use of org.apache.poi.hslf.record.EscherTextboxWrapper in project poi by apache.
the class PPDrawingTextListing method main.
public static void main(String[] args) throws IOException {
if (args.length < 1) {
System.err.println("Need to give a filename");
System.exit(1);
}
HSLFSlideShowImpl ss = new HSLFSlideShowImpl(args[0]);
// Find PPDrawings at any second level position
Record[] records = ss.getRecords();
for (int i = 0; i < records.length; i++) {
Record[] children = records[i].getChildRecords();
if (children != null && children.length != 0) {
for (int j = 0; j < children.length; j++) {
if (children[j] instanceof PPDrawing) {
System.out.println("Found PPDrawing at " + j + " in top level record " + i + " (" + records[i].getRecordType() + ")");
// Look for EscherTextboxWrapper's
PPDrawing ppd = (PPDrawing) children[j];
EscherTextboxWrapper[] wrappers = ppd.getTextboxWrappers();
System.out.println(" Has " + wrappers.length + " textbox wrappers within");
// Loop over the wrappers, showing what they contain
for (int k = 0; k < wrappers.length; k++) {
EscherTextboxWrapper tbw = wrappers[k];
System.out.println(" " + k + " has " + tbw.getChildRecords().length + " PPT atoms within");
// Loop over the records, printing the text
Record[] pptatoms = tbw.getChildRecords();
for (int l = 0; l < pptatoms.length; l++) {
String text = null;
if (pptatoms[l] instanceof TextBytesAtom) {
TextBytesAtom tba = (TextBytesAtom) pptatoms[l];
text = tba.getText();
}
if (pptatoms[l] instanceof TextCharsAtom) {
TextCharsAtom tca = (TextCharsAtom) pptatoms[l];
text = tca.getText();
}
if (text != null) {
text = text.replace('\r', '\n');
System.out.println(" ''" + text + "''");
}
}
}
}
}
}
}
ss.close();
}
use of org.apache.poi.hslf.record.EscherTextboxWrapper in project poi by apache.
the class HSLFTextParagraph method refreshRecords.
/**
* Writes the textbox records back to the document record
*/
private static void refreshRecords(List<HSLFTextParagraph> paragraphs) {
TextHeaderAtom headerAtom = paragraphs.get(0)._headerAtom;
RecordContainer _txtbox = headerAtom.getParentRecord();
if (_txtbox instanceof EscherTextboxWrapper) {
try {
((EscherTextboxWrapper) _txtbox).writeOut(null);
} catch (IOException e) {
throw new HSLFException("failed dummy write", e);
}
}
}
Aggregations