use of org.apache.poi.hslf.record.EscherTextboxWrapper in project poi by apache.
the class HSLFTextShape method getTextParagraphs.
@Override
public List<HSLFTextParagraph> getTextParagraphs() {
if (!_paragraphs.isEmpty()) {
return _paragraphs;
}
_txtbox = getEscherTextboxWrapper();
if (_txtbox == null) {
_txtbox = new EscherTextboxWrapper();
createEmptyParagraph();
} else {
List<HSLFTextParagraph> pList = HSLFTextParagraph.findTextParagraphs(_txtbox, getSheet());
if (pList == null) {
// there are actually TextBoxRecords without extra data - see #54722
createEmptyParagraph();
} else {
_paragraphs = pList;
}
if (_paragraphs.isEmpty()) {
LOG.log(POILogger.WARN, "TextRecord didn't contained any text lines");
}
}
for (HSLFTextParagraph p : _paragraphs) {
p.setParentShape(this);
}
return _paragraphs;
}
use of org.apache.poi.hslf.record.EscherTextboxWrapper in project poi by apache.
the class HSLFTextShape method afterInsert.
/**
* When a textbox is added to a sheet we need to tell upper-level
* <code>PPDrawing</code> about it.
*
* @param sh the sheet we are adding to
*/
@Override
protected void afterInsert(HSLFSheet sh) {
super.afterInsert(sh);
storeText();
EscherTextboxWrapper thisTxtbox = getEscherTextboxWrapper();
if (thisTxtbox != null) {
getSpContainer().addChildRecord(thisTxtbox.getEscherRecord());
PPDrawing ppdrawing = sh.getPPDrawing();
ppdrawing.addTextboxWrapper(thisTxtbox);
// Ensure the escher layer knows about the added records
try {
thisTxtbox.writeOut(null);
} catch (IOException e) {
throw new HSLFException(e);
}
boolean isInitialAnchor = getAnchor().equals(new Rectangle2D.Double());
boolean isFilledTxt = !"".equals(getText());
if (isInitialAnchor && isFilledTxt) {
resizeToFitText();
}
}
for (HSLFTextParagraph htp : _paragraphs) {
htp.setShapeId(getShapeId());
}
sh.onAddTextShape(this);
}
use of org.apache.poi.hslf.record.EscherTextboxWrapper in project poi by apache.
the class TestNumberedList2 method checkSlide1.
private void checkSlide1(final HSLFSlide s) {
final StyleTextProp9Atom[] numberedListArray = s.getNumberedListInfo();
assertNotNull(numberedListArray);
assertEquals(1, numberedListArray.length);
final StyleTextProp9Atom numberedListInfoForTextBox = numberedListArray[0];
assertNotNull(numberedListInfoForTextBox);
final TextPFException9[] autoNumbersOfTextBox = numberedListInfoForTextBox.getAutoNumberTypes();
assertEquals(Short.valueOf((short) 1), autoNumbersOfTextBox[0].getfBulletHasAutoNumber());
//Default value = 1 will be used
assertEquals(Short.valueOf((short) 1), autoNumbersOfTextBox[0].getAutoNumberStartNumber());
assertTrue(AutoNumberingScheme.arabicPeriod == autoNumbersOfTextBox[0].getAutoNumberScheme());
List<List<HSLFTextParagraph>> textParass = s.getTextParagraphs();
assertEquals(3, textParass.size());
List<HSLFTextParagraph> textParas = textParass.get(0);
assertEquals("Bulleted list\rMore bullets", HSLFTextParagraph.getRawText(textParas));
assertEquals(2, textParas.size());
assertTrue(textParas.get(0).isBullet());
String expected = "Numbered list between two bulleted lists\rSecond numbered list item";
assertEquals(expected, HSLFTextParagraph.getRawText(textParass.get(1)));
expected = "Second bulleted list – should appear after numbered list\rMore bullets";
assertEquals(expected, HSLFTextParagraph.getRawText(textParass.get(2)));
final EscherTextboxWrapper[] styleAtoms = s.getTextboxWrappers();
assertEquals(textParass.size(), styleAtoms.length);
checkSingleRunWrapper(27, styleAtoms[0]);
checkSingleRunWrapper(67, styleAtoms[1]);
checkSingleRunWrapper(70, styleAtoms[2]);
}
use of org.apache.poi.hslf.record.EscherTextboxWrapper in project poi by apache.
the class TestNumberedList3 method checkSlide.
private void checkSlide(final HSLFSlide s) {
final StyleTextProp9Atom[] numberedListArray = s.getNumberedListInfo();
assertNotNull(numberedListArray);
assertEquals(1, numberedListArray.length);
final StyleTextProp9Atom numberedListInfoForTextBox = numberedListArray[0];
assertNotNull(numberedListInfoForTextBox);
final TextPFException9[] autoNumbersOfTextBox0 = numberedListInfoForTextBox.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 List<List<HSLFTextParagraph>> textParass = s.getTextParagraphs();
assertEquals(3, textParass.size());
assertEquals("Bulleted list\rMore bullets\rNo bullets here", HSLFTextParagraph.getRawText(textParass.get(0)));
assertEquals("Numbered list between two bulleted lists\rSecond numbered list item", HSLFTextParagraph.getRawText(textParass.get(1)));
assertEquals("Second bulleted list – should appear after numbered list\rMore bullets", HSLFTextParagraph.getRawText(textParass.get(2)));
assertEquals(3, textParass.get(0).size());
assertEquals(2, textParass.get(1).size());
assertEquals(2, textParass.get(2).size());
assertNull(textParass.get(0).get(0).getStyleTextProp9Atom());
assertNotNull(textParass.get(1).get(0).getStyleTextProp9Atom());
assertNull(textParass.get(2).get(0).getStyleTextProp9Atom());
final TextPFException9[] autoNumbers = textParass.get(1).get(0).getStyleTextProp9Atom().getAutoNumberTypes();
assertEquals(1, autoNumbers.length);
assertEquals(Short.valueOf((short) 1), autoNumbers[0].getfBulletHasAutoNumber());
//Default value = 1 will be used
assertEquals(Short.valueOf((short) 1), autoNumbers[0].getAutoNumberStartNumber());
assertTrue(AutoNumberingScheme.arabicPeriod == autoNumbersOfTextBox0[0].getAutoNumberScheme());
int chCovered = 0;
for (HSLFTextParagraph htp : textParass.get(1)) {
for (HSLFTextRun htr : htp.getTextRuns()) {
TextPropCollection textProp = htr.getCharacterStyle();
chCovered += textProp.getCharactersCovered();
}
}
assertEquals(67, chCovered);
assertTrue(textParass.get(0).get(0).isBullet());
final EscherTextboxWrapper[] styleAtoms = s.getTextboxWrappers();
assertEquals(textParass.size(), styleAtoms.length);
checkSingleRunWrapper(43, styleAtoms[0]);
checkSingleRunWrapper(67, styleAtoms[1]);
}
Aggregations