use of org.apache.poi.hslf.record.StyleTextPropAtom in project poi by apache.
the class TestNumberedList3 method checkSingleRunWrapper.
private void checkSingleRunWrapper(final int exceptedLength, final EscherTextboxWrapper wrapper) {
final StyleTextPropAtom styleTextPropAtom = wrapper.getStyleTextPropAtom();
final List<TextPropCollection> textProps = styleTextPropAtom.getCharacterStyles();
assertEquals(1, textProps.size());
assertEquals(exceptedLength, textProps.get(0).getCharactersCovered());
}
use of org.apache.poi.hslf.record.StyleTextPropAtom in project poi by apache.
the class HSLFTextShape method createEmptyParagraph.
private void createEmptyParagraph() {
TextHeaderAtom tha = (TextHeaderAtom) _txtbox.findFirstOfType(TextHeaderAtom._type);
if (tha == null) {
tha = new TextHeaderAtom();
tha.setParentRecord(_txtbox);
_txtbox.appendChildRecord(tha);
}
TextBytesAtom tba = (TextBytesAtom) _txtbox.findFirstOfType(TextBytesAtom._type);
TextCharsAtom tca = (TextCharsAtom) _txtbox.findFirstOfType(TextCharsAtom._type);
if (tba == null && tca == null) {
tba = new TextBytesAtom();
tba.setText(new byte[0]);
_txtbox.appendChildRecord(tba);
}
final String text = ((tba != null) ? tba.getText() : tca.getText());
StyleTextPropAtom sta = (StyleTextPropAtom) _txtbox.findFirstOfType(StyleTextPropAtom._type);
TextPropCollection paraStyle = null, charStyle = null;
if (sta == null) {
int parSiz = text.length();
sta = new StyleTextPropAtom(parSiz + 1);
if (_paragraphs.isEmpty()) {
paraStyle = sta.addParagraphTextPropCollection(parSiz + 1);
charStyle = sta.addCharacterTextPropCollection(parSiz + 1);
} else {
for (HSLFTextParagraph htp : _paragraphs) {
int runsLen = 0;
for (HSLFTextRun htr : htp.getTextRuns()) {
runsLen += htr.getLength();
charStyle = sta.addCharacterTextPropCollection(htr.getLength());
htr.setCharacterStyle(charStyle);
}
paraStyle = sta.addParagraphTextPropCollection(runsLen);
htp.setParagraphStyle(paraStyle);
}
assert (paraStyle != null && charStyle != null);
}
_txtbox.appendChildRecord(sta);
} else {
paraStyle = sta.getParagraphStyles().get(0);
charStyle = sta.getCharacterStyles().get(0);
}
if (_paragraphs.isEmpty()) {
HSLFTextParagraph htp = new HSLFTextParagraph(tha, tba, tca, _paragraphs);
htp.setParagraphStyle(paraStyle);
htp.setParentShape(this);
_paragraphs.add(htp);
HSLFTextRun htr = new HSLFTextRun(htp);
htr.setCharacterStyle(charStyle);
htr.setText(text);
htp.addTextRun(htr);
}
}
use of org.apache.poi.hslf.record.StyleTextPropAtom in project poi by apache.
the class TextStyleListing 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 the documents, and then their SLWT
Record[] records = ss.getRecords();
for (int i = 0; i < records.length; i++) {
if (records[i].getRecordType() == 1000l) {
Record docRecord = records[i];
Record[] docChildren = docRecord.getChildRecords();
for (int j = 0; j < docChildren.length; j++) {
if (docChildren[j] instanceof SlideListWithText) {
Record[] slwtChildren = docChildren[j].getChildRecords();
int lastTextLen = -1;
for (int k = 0; k < slwtChildren.length; k++) {
if (slwtChildren[k] instanceof TextCharsAtom) {
lastTextLen = ((TextCharsAtom) slwtChildren[k]).getText().length();
}
if (slwtChildren[k] instanceof TextBytesAtom) {
lastTextLen = ((TextBytesAtom) slwtChildren[k]).getText().length();
}
if (slwtChildren[k] instanceof StyleTextPropAtom) {
StyleTextPropAtom stpa = (StyleTextPropAtom) slwtChildren[k];
stpa.setParentTextSize(lastTextLen);
showStyleTextPropAtom(stpa);
}
}
}
}
}
}
ss.close();
}
use of org.apache.poi.hslf.record.StyleTextPropAtom in project poi by apache.
the class TestNumberedList2 method checkSingleRunWrapper.
private void checkSingleRunWrapper(final int exceptedLength, final EscherTextboxWrapper wrapper) {
final StyleTextPropAtom styleTextPropAtom = wrapper.getStyleTextPropAtom();
final List<TextPropCollection> textProps = styleTextPropAtom.getCharacterStyles();
assertEquals(1, textProps.size());
assertEquals(exceptedLength, textProps.get(0).getCharactersCovered());
}
Aggregations