Search in sources :

Example 1 with TextPFException9

use of org.apache.poi.hslf.model.textproperties.TextPFException9 in project poi by apache.

the class HSLFTextParagraph method getAutoNumberingScheme.

public AutoNumberingScheme getAutoNumberingScheme() {
    if (styleTextProp9Atom == null) {
        return null;
    }
    TextPFException9[] ant = styleTextProp9Atom.getAutoNumberTypes();
    int level = getIndentLevel();
    if (ant == null || level == -1 || level >= ant.length) {
        return null;
    }
    return ant[level].getAutoNumberScheme();
}
Also used : TextPFException9(org.apache.poi.hslf.model.textproperties.TextPFException9) DrawPaint(org.apache.poi.sl.draw.DrawPaint) SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)

Example 2 with TextPFException9

use of org.apache.poi.hslf.model.textproperties.TextPFException9 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 3 with TextPFException9

use of org.apache.poi.hslf.model.textproperties.TextPFException9 in project poi by apache.

the class HSLFTextParagraph method getAutoNumberingStartAt.

public Integer getAutoNumberingStartAt() {
    if (styleTextProp9Atom == null) {
        return null;
    }
    TextPFException9[] ant = styleTextProp9Atom.getAutoNumberTypes();
    int level = getIndentLevel();
    if (ant == null || level >= ant.length) {
        return null;
    }
    Short startAt = ant[level].getAutoNumberStartNumber();
    assert (startAt != null);
    return startAt.intValue();
}
Also used : TextPFException9(org.apache.poi.hslf.model.textproperties.TextPFException9) DrawPaint(org.apache.poi.sl.draw.DrawPaint) SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)

Example 4 with TextPFException9

use of org.apache.poi.hslf.model.textproperties.TextPFException9 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 5 with TextPFException9

use of org.apache.poi.hslf.model.textproperties.TextPFException9 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

TextPFException9 (org.apache.poi.hslf.model.textproperties.TextPFException9)5 List (java.util.List)3 EscherTextboxWrapper (org.apache.poi.hslf.record.EscherTextboxWrapper)3 StyleTextProp9Atom (org.apache.poi.hslf.record.StyleTextProp9Atom)3 DrawPaint (org.apache.poi.sl.draw.DrawPaint)2 SolidPaint (org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)2 TextPropCollection (org.apache.poi.hslf.model.textproperties.TextPropCollection)1