Search in sources :

Example 1 with EscherTextboxWrapper

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;
    }
}
Also used : EscherTextboxWrapper(org.apache.poi.hslf.record.EscherTextboxWrapper) Record(org.apache.poi.hslf.record.Record) EscherContainerRecord(org.apache.poi.ddf.EscherContainerRecord) EscherTextboxRecord(org.apache.poi.ddf.EscherTextboxRecord) EscherRecord(org.apache.poi.ddf.EscherRecord) TextCharsAtom(org.apache.poi.hslf.record.TextCharsAtom) StyleTextPropAtom(org.apache.poi.hslf.record.StyleTextPropAtom) TextBytesAtom(org.apache.poi.hslf.record.TextBytesAtom)

Example 2 with EscherTextboxWrapper

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;
}
Also used : PPDrawing(org.apache.poi.hslf.record.PPDrawing) EscherTextboxRecord(org.apache.poi.ddf.EscherTextboxRecord) EscherTextboxWrapper(org.apache.poi.hslf.record.EscherTextboxWrapper)

Example 3 with EscherTextboxWrapper

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]);
}
Also used : TextPFException9(org.apache.poi.hslf.model.textproperties.TextPFException9) EscherTextboxWrapper(org.apache.poi.hslf.record.EscherTextboxWrapper) List(java.util.List) StyleTextProp9Atom(org.apache.poi.hslf.record.StyleTextProp9Atom)

Example 4 with EscherTextboxWrapper

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

Example 5 with EscherTextboxWrapper

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);
        }
    }
}
Also used : HSLFException(org.apache.poi.hslf.exceptions.HSLFException) RecordContainer(org.apache.poi.hslf.record.RecordContainer) EscherTextboxWrapper(org.apache.poi.hslf.record.EscherTextboxWrapper) IOException(java.io.IOException) TextHeaderAtom(org.apache.poi.hslf.record.TextHeaderAtom)

Aggregations

EscherTextboxWrapper (org.apache.poi.hslf.record.EscherTextboxWrapper)9 List (java.util.List)3 TextPFException9 (org.apache.poi.hslf.model.textproperties.TextPFException9)3 PPDrawing (org.apache.poi.hslf.record.PPDrawing)3 StyleTextProp9Atom (org.apache.poi.hslf.record.StyleTextProp9Atom)3 IOException (java.io.IOException)2 EscherTextboxRecord (org.apache.poi.ddf.EscherTextboxRecord)2 HSLFException (org.apache.poi.hslf.exceptions.HSLFException)2 Record (org.apache.poi.hslf.record.Record)2 TextBytesAtom (org.apache.poi.hslf.record.TextBytesAtom)2 TextCharsAtom (org.apache.poi.hslf.record.TextCharsAtom)2 Rectangle2D (java.awt.geom.Rectangle2D)1 EscherContainerRecord (org.apache.poi.ddf.EscherContainerRecord)1 EscherRecord (org.apache.poi.ddf.EscherRecord)1 TextPropCollection (org.apache.poi.hslf.model.textproperties.TextPropCollection)1 RecordContainer (org.apache.poi.hslf.record.RecordContainer)1 StyleTextPropAtom (org.apache.poi.hslf.record.StyleTextPropAtom)1 TextHeaderAtom (org.apache.poi.hslf.record.TextHeaderAtom)1 HSLFSlideShowImpl (org.apache.poi.hslf.usermodel.HSLFSlideShowImpl)1