Search in sources :

Example 6 with StyleTextPropAtom

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());
}
Also used : StyleTextPropAtom(org.apache.poi.hslf.record.StyleTextPropAtom) TextPropCollection(org.apache.poi.hslf.model.textproperties.TextPropCollection)

Example 7 with StyleTextPropAtom

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);
    }
}
Also used : TextCharsAtom(org.apache.poi.hslf.record.TextCharsAtom) TextHeaderAtom(org.apache.poi.hslf.record.TextHeaderAtom) TextBytesAtom(org.apache.poi.hslf.record.TextBytesAtom) StyleTextPropAtom(org.apache.poi.hslf.record.StyleTextPropAtom) TextPropCollection(org.apache.poi.hslf.model.textproperties.TextPropCollection)

Example 8 with StyleTextPropAtom

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();
}
Also used : SlideListWithText(org.apache.poi.hslf.record.SlideListWithText) Record(org.apache.poi.hslf.record.Record) TextCharsAtom(org.apache.poi.hslf.record.TextCharsAtom) TextBytesAtom(org.apache.poi.hslf.record.TextBytesAtom) StyleTextPropAtom(org.apache.poi.hslf.record.StyleTextPropAtom) HSLFSlideShowImpl(org.apache.poi.hslf.usermodel.HSLFSlideShowImpl)

Example 9 with StyleTextPropAtom

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());
}
Also used : StyleTextPropAtom(org.apache.poi.hslf.record.StyleTextPropAtom) TextPropCollection(org.apache.poi.hslf.model.textproperties.TextPropCollection)

Aggregations

StyleTextPropAtom (org.apache.poi.hslf.record.StyleTextPropAtom)9 Record (org.apache.poi.hslf.record.Record)6 TextBytesAtom (org.apache.poi.hslf.record.TextBytesAtom)5 TextCharsAtom (org.apache.poi.hslf.record.TextCharsAtom)5 TextPropCollection (org.apache.poi.hslf.model.textproperties.TextPropCollection)4 TextHeaderAtom (org.apache.poi.hslf.record.TextHeaderAtom)4 DrawPaint (org.apache.poi.sl.draw.DrawPaint)3 SolidPaint (org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)3 SlideListWithText (org.apache.poi.hslf.record.SlideListWithText)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 EscherContainerRecord (org.apache.poi.ddf.EscherContainerRecord)1 EscherRecord (org.apache.poi.ddf.EscherRecord)1 EscherTextboxRecord (org.apache.poi.ddf.EscherTextboxRecord)1 HSLFException (org.apache.poi.hslf.exceptions.HSLFException)1 EscherTextboxWrapper (org.apache.poi.hslf.record.EscherTextboxWrapper)1 MasterTextPropAtom (org.apache.poi.hslf.record.MasterTextPropAtom)1 RecordContainer (org.apache.poi.hslf.record.RecordContainer)1 TextRulerAtom (org.apache.poi.hslf.record.TextRulerAtom)1 TextSpecInfoAtom (org.apache.poi.hslf.record.TextSpecInfoAtom)1