Search in sources :

Example 21 with TextPropCollection

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

the class StyleTextPropAtom method addCharacterTextPropCollection.

/**
     * Create a new Character TextPropCollection, and add it to the list
     * @param charactersCovered The number of characters this TextPropCollection will cover
     * @return the new TextPropCollection, which will then be in the list
     */
public TextPropCollection addCharacterTextPropCollection(int charactersCovered) {
    TextPropCollection tpc = new TextPropCollection(charactersCovered, TextPropType.character);
    charStyles.add(tpc);
    return tpc;
}
Also used : TextPropCollection(org.apache.poi.hslf.model.textproperties.TextPropCollection)

Example 22 with TextPropCollection

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

the class TestTxMasterStyleAtom method checkNotesType.

/**
     * Test styles for type=TextHeaderAtom.NOTES_TYPE
     */
private void checkNotesType(TxMasterStyleAtom txmaster) {
    TextPropCollection props;
    TextProp prop;
    //paragraph styles
    props = txmaster.getParagraphStyles().get(0);
    prop = props.findByName("alignment");
    //title has center alignment
    assertEquals(0, prop.getValue());
    //character styles
    props = txmaster.getCharacterStyles().get(0);
    prop = props.findByName("font.color");
    assertEquals(0x1000000, prop.getValue());
    prop = props.findByName("font.index");
    assertEquals(0, prop.getValue());
    prop = props.findByName("font.size");
    assertEquals(12, prop.getValue());
}
Also used : TextProp(org.apache.poi.hslf.model.textproperties.TextProp) TextPropCollection(org.apache.poi.hslf.model.textproperties.TextPropCollection)

Example 23 with TextPropCollection

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

the class TestTxMasterStyleAtom method checkBodyType.

/**
     * Test styles for type=TextHeaderAtom.BODY_TYPE
     */
private void checkBodyType(TxMasterStyleAtom txmaster) {
    TextPropCollection props;
    TextProp prop;
    List<TextPropCollection> prstyles = txmaster.getParagraphStyles();
    List<TextPropCollection> chstyles = txmaster.getCharacterStyles();
    assertEquals("TxMasterStyleAtom for TextHeaderAtom.BODY_TYPE " + "must contain styles for 5 indentation levels", 5, prstyles.size());
    assertEquals("TxMasterStyleAtom for TextHeaderAtom.BODY_TYPE " + "must contain styles for 5 indentation levels", 5, chstyles.size());
    //paragraph styles
    props = prstyles.get(0);
    prop = props.findByName("alignment");
    assertEquals(0, prop.getValue());
    for (int i = 0; i < prstyles.size(); i++) {
        assertNotNull("text.offset is null for indentation level " + i, prstyles.get(i).findByName("text.offset"));
        assertNotNull("bullet.offset is null for indentation level " + i, prstyles.get(i).findByName("bullet.offset"));
    }
    //character styles
    props = chstyles.get(0);
    prop = props.findByName("font.color");
    assertEquals(0x1000000, prop.getValue());
    prop = props.findByName("font.index");
    assertEquals(0, prop.getValue());
    prop = props.findByName("font.size");
    assertEquals(32, prop.getValue());
}
Also used : TextProp(org.apache.poi.hslf.model.textproperties.TextProp) TextPropCollection(org.apache.poi.hslf.model.textproperties.TextPropCollection)

Example 24 with TextPropCollection

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

Example 25 with TextPropCollection

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

TextPropCollection (org.apache.poi.hslf.model.textproperties.TextPropCollection)25 TextProp (org.apache.poi.hslf.model.textproperties.TextProp)6 StyleTextPropAtom (org.apache.poi.hslf.record.StyleTextPropAtom)4 List (java.util.List)3 HSLFException (org.apache.poi.hslf.exceptions.HSLFException)3 DrawPaint (org.apache.poi.sl.draw.DrawPaint)3 SolidPaint (org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 TextHeaderAtom (org.apache.poi.hslf.record.TextHeaderAtom)2 TxMasterStyleAtom (org.apache.poi.hslf.record.TxMasterStyleAtom)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 BitMaskTextProp (org.apache.poi.hslf.model.textproperties.BitMaskTextProp)1 ParagraphFlagsTextProp (org.apache.poi.hslf.model.textproperties.ParagraphFlagsTextProp)1 TextPFException9 (org.apache.poi.hslf.model.textproperties.TextPFException9)1 EscherTextboxWrapper (org.apache.poi.hslf.record.EscherTextboxWrapper)1 MainMaster (org.apache.poi.hslf.record.MainMaster)1 Record (org.apache.poi.hslf.record.Record)1 StyleTextProp9Atom (org.apache.poi.hslf.record.StyleTextProp9Atom)1 TextBytesAtom (org.apache.poi.hslf.record.TextBytesAtom)1