Search in sources :

Example 6 with EscherTextboxWrapper

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

Example 7 with EscherTextboxWrapper

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

Example 8 with EscherTextboxWrapper

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]);
}
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 9 with EscherTextboxWrapper

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]);
}
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) TextPropCollection(org.apache.poi.hslf.model.textproperties.TextPropCollection)

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