Examples of TextProp


Examples of org.apache.poi.hslf.model.textproperties.TextProp

        // First is 30 long, left aligned, normal spacing
        TextPropCollection tppa = (TextPropCollection)ps.get(0);
        tppa.updateTextSize(30);

        TextProp tp = tppa.addWithName("alignment");
        tp.setValue(0);
        tp = tppa.addWithName("linespacing");
        tp.setValue(80);

        // Second is 28 long, centre aligned and normal spacing
        TextPropCollection tppb = stpa.addParagraphTextPropCollection(28);

        tp = tppb.addWithName("linespacing");
        tp.setValue(80);

        // Third is 25 long, right aligned and normal spacing
        TextPropCollection tppc = stpa.addParagraphTextPropCollection(25);

        tp = tppc.addWithName("alignment");
        tp.setValue(2);
        tp = tppc.addWithName("linespacing");
        tp.setValue(80);

        // Forth is left aligned + normal line spacing (despite differing font)
        TextPropCollection tppd = stpa.addParagraphTextPropCollection(97);

        tp = tppd.addWithName("alignment");
        tp.setValue(0);
        tp = tppd.addWithName("linespacing");
        tp.setValue(80);


        // Now do 4 character styles
        LinkedList cs = stpa.getCharacterStyles();

        // First is 30 long, bold and font size
        TextPropCollection tpca = (TextPropCollection)cs.get(0);
        tpca.updateTextSize(30);

        tp = tpca.addWithName("font.size");
        tp.setValue(20);
        CharFlagsTextProp cftp = (CharFlagsTextProp)
            tpca.addWithName("char_flags");
        assertEquals(0, cftp.getValue());
        cftp.setSubValue(true, CharFlagsTextProp.BOLD_IDX);
        assertEquals(1, cftp.getValue());

        // Second is 28 long, blue and italic
        TextPropCollection tpcb = stpa.addCharacterTextPropCollection(28);

        tp = tpcb.addWithName("font.size");
        tp.setValue(20);
        tp = tpcb.addWithName("font.color");
        tp.setValue(0x05000000);
        cftp = (CharFlagsTextProp)tpcb.addWithName("char_flags");
        cftp.setSubValue(true, CharFlagsTextProp.ITALIC_IDX);
        assertEquals(2, cftp.getValue());

        // Third is 25 long and red
        TextPropCollection tpcc = stpa.addCharacterTextPropCollection(25);

        tp = tpcc.addWithName("font.size");
        tp.setValue(20);
        tp = tpcc.addWithName("font.color");
        tp.setValue(0xfe0033ff);

        // Fourth is 96 long, underlined and different+bigger font
        TextPropCollection tpcd = stpa.addCharacterTextPropCollection(96);

        tp = tpcd.addWithName("font.size");
        tp.setValue(24);
        tp = tpcd.addWithName("font.index");
        tp.setValue(1);
        cftp = (CharFlagsTextProp)tpcd.addWithName("char_flags");
        cftp.setSubValue(true, CharFlagsTextProp.UNDERLINE_IDX);
        assertEquals(4, cftp.getValue());

        // Fifth is 1 long, underlined and different+bigger font + red
        TextPropCollection tpce = stpa.addCharacterTextPropCollection(1);

        tp = tpce.addWithName("font.size");
        tp.setValue(24);
        tp = tpce.addWithName("font.index");
        tp.setValue(1);
        tp = tpce.addWithName("font.color");
        tp.setValue(0xfe0033ff);
        cftp = (CharFlagsTextProp)tpce.addWithName("char_flags");
        cftp.setSubValue(true, CharFlagsTextProp.UNDERLINE_IDX);
        assertEquals(4, cftp.getValue());


        // Check it's as expected
        assertEquals(4, stpa.getParagraphStyles().size());
        assertEquals(5, stpa.getCharacterStyles().size());

        // Compare in detail to b
        StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length);
        stpb.setParentTextSize(data_b_text_len);
        LinkedList psb = stpb.getParagraphStyles();
        LinkedList csb = stpb.getCharacterStyles();

        assertEquals(psb.size(), ps.size());
        assertEquals(csb.size(), cs.size());

        // Ensure Paragraph Character styles match
        for(int z=0; z<2; z++) {
            LinkedList lla = cs;
            LinkedList llb = csb;
            int upto = 5;
            if(z == 1) {
                lla = ps;
                llb = psb;
                upto = 4;
            }

            for(int i=0; i<upto; i++) {
                TextPropCollection ca = (TextPropCollection)lla.get(i);
                TextPropCollection cb = (TextPropCollection)llb.get(i);

                assertEquals(ca.getCharactersCovered(), cb.getCharactersCovered());
                assertEquals(ca.getTextPropList().size(), cb.getTextPropList().size());

                for(int j=0; j<ca.getTextPropList().size(); j++) {
                    TextProp tpa = (TextProp)ca.getTextPropList().get(j);
                    TextProp tpb = (TextProp)cb.getTextPropList().get(j);
                    //System.out.println("TP " + i + " " + j + " " + tpa.getName() + "\t" + tpa.getValue() );
                    assertEquals(tpa.getName(), tpb.getName());
                    assertEquals(tpa.getMask(), tpb.getMask());
                    assertEquals(tpa.getWriteMask(), tpb.getWriteMask());
                    assertEquals(tpa.getValue(), tpb.getValue());
                }

                ByteArrayOutputStream ba = new ByteArrayOutputStream();
                ByteArrayOutputStream bb = new ByteArrayOutputStream();
View Full Code Here

Examples of org.apache.poi.hslf.model.textproperties.TextProp

    /**
     * Test styles for type=TextHeaderAtom.OTHER_TYPE
     */
    private void checkOtherType(TxMasterStyleAtom txmaster){
        TextPropCollection props;
        TextProp prop;

        //paragraph styles
        props = txmaster.getParagraphStyles()[0];

        prop = props.findByName("alignment");
        assertEquals(0, prop.getValue());

        //character styles
        props = txmaster.getCharacterStyles()[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(18, prop.getValue());
    }
View Full Code Here

Examples of org.apache.poi.hslf.model.textproperties.TextProp

    /**
     * Test styles for type=TextHeaderAtom.NOTES_TYPE
     */
    private void checkNotesType(TxMasterStyleAtom txmaster){
        TextPropCollection props;
        TextProp prop;

        //paragraph styles
        props = txmaster.getParagraphStyles()[0];

        prop = props.findByName("alignment");
        assertEquals(0, prop.getValue()); //title has center alignment

        //character styles
        props = txmaster.getCharacterStyles()[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());

    }
View Full Code Here

Examples of org.apache.poi.hslf.model.textproperties.TextProp

        TextPropCollection b_ch_3 = (TextPropCollection)b_ch_l.get(2);
        TextPropCollection b_ch_4 = (TextPropCollection)b_ch_l.get(3);

        // In first set, we get a CharFlagsTextProp and a font.size
        assertEquals(2,b_ch_1.getTextPropList().size());
        TextProp tp_1_1 = (TextProp)b_ch_1.getTextPropList().get(0);
        TextProp tp_1_2 = (TextProp)b_ch_1.getTextPropList().get(1);
        assertEquals(true, tp_1_1 instanceof CharFlagsTextProp);
        assertEquals(true, tp_1_2 instanceof TextProp);
        assertEquals("font.size", tp_1_2.getName());
        assertEquals(20, tp_1_2.getValue());

        // In second set, we get a CharFlagsTextProp and a font.size and a font.color
        assertEquals(3,b_ch_2.getTextPropList().size());
        TextProp tp_2_1 = (TextProp)b_ch_2.getTextPropList().get(0);
        TextProp tp_2_2 = (TextProp)b_ch_2.getTextPropList().get(1);
        TextProp tp_2_3 = (TextProp)b_ch_2.getTextPropList().get(2);
        assertEquals(true, tp_2_1 instanceof CharFlagsTextProp);
        assertEquals(true, tp_2_2 instanceof TextProp);
        assertEquals(true, tp_2_3 instanceof TextProp);
        assertEquals("font.size", tp_2_2.getName());
        assertEquals("font.color", tp_2_3.getName());
        assertEquals(20, tp_2_2.getValue());

        // In third set, it's just a font.size and a font.color
        assertEquals(2,b_ch_3.getTextPropList().size());
        TextProp tp_3_1 = (TextProp)b_ch_3.getTextPropList().get(0);
        TextProp tp_3_2 = (TextProp)b_ch_3.getTextPropList().get(1);
        assertEquals(true, tp_3_1 instanceof TextProp);
        assertEquals(true, tp_3_2 instanceof TextProp);
        assertEquals("font.size", tp_3_1.getName());
        assertEquals("font.color", tp_3_2.getName());
        assertEquals(20, tp_3_1.getValue());

        // In fourth set, we get a CharFlagsTextProp and a font.index and a font.size
        assertEquals(3,b_ch_4.getTextPropList().size());
        TextProp tp_4_1 = (TextProp)b_ch_4.getTextPropList().get(0);
        TextProp tp_4_2 = (TextProp)b_ch_4.getTextPropList().get(1);
        TextProp tp_4_3 = (TextProp)b_ch_4.getTextPropList().get(2);
        assertEquals(true, tp_4_1 instanceof CharFlagsTextProp);
        assertEquals(true, tp_4_2 instanceof TextProp);
        assertEquals(true, tp_4_3 instanceof TextProp);
        assertEquals("font.index", tp_4_2.getName());
        assertEquals("font.size", tp_4_3.getName());
        assertEquals(24, tp_4_3.getValue());
    }
View Full Code Here

Examples of org.apache.poi.hslf.model.textproperties.TextProp

     * Pickup a style attribute from the master.
     * This is the "workhorse" which returns the default style attrubutes.
     */
    public TextProp getStyleAttribute(int txtype, int level, String name, boolean isCharacter) {

        TextProp prop = null;
        for (int i = level; i >= 0; i--) {
            TextPropCollection[] styles =
                    isCharacter ? _txmaster[txtype].getCharacterStyles() : _txmaster[txtype].getParagraphStyles();
            if (i < styles.length) prop = styles[i].findByName(name);
            if (prop != null) break;
View Full Code Here

Examples of org.apache.poi.hslf.model.textproperties.TextProp

        if (level != 0 || type >= MAX_INDENT){
            return StyleTextPropAtom.paragraphTextPropTypes;
        }
        return new TextProp[] {
                new ParagraphFlagsTextProp(),
                new TextProp(2, 0x80, "bullet.char"),
                new TextProp(2, 0x10, "bullet.font"),
                new TextProp(2, 0x40, "bullet.size"),
                new TextProp(4, 0x20, "bullet.color"),
                new TextProp(2, 0xD00, "alignment"),
                new TextProp(2, 0x1000, "linespacing"),
                new TextProp(2, 0x2000, "spacebefore"),
                new TextProp(2, 0x4000, "spaceafter"),
                new TextProp(2, 0x8000, "text.offset"),
                new TextProp(2, 0x10000, "bullet.offset"),
                new TextProp(2, 0x20000, "defaulttab"),
                new TextProp(2, 0x40000, "para_unknown_2"),
                new TextProp(2, 0x80000, "para_unknown_3"),
                new TextProp(2, 0x100000, "para_unknown_4"),
                new TextProp(2, 0x200000, "para_unknown_5")
        };

    }
View Full Code Here

Examples of org.apache.poi.hslf.model.textproperties.TextProp

        if (level != 0 || type >= MAX_INDENT){
            return StyleTextPropAtom.characterTextPropTypes;
        }
        return new TextProp[] {
                new CharFlagsTextProp(),
                new TextProp(2, 0x10000, "font.index"),
                new TextProp(2, 0x20000, "char_unknown_1"),
                new TextProp(4, 0x40000, "char_unknown_2"),
                new TextProp(2, 0x80000, "font.size"),
                new TextProp(2, 0x100000, "char_unknown_3"),
                new TextProp(4, 0x200000, "font.color"),
                new TextProp(2, 0x800000, "char_unknown_4")
        };
    }
View Full Code Here

Examples of org.apache.poi.hslf.model.textproperties.TextProp

   * @param textPropCol The TextPropCollection to fetch from / add into
   * @param textPropName The name of the TextProp to fetch/add
   */
  private TextProp fetchOrAddTextProp(TextPropCollection textPropCol, String textPropName) {
    // Fetch / Add the TextProp
    TextProp tp = textPropCol.findByName(textPropName);
    if(tp == null) {
      tp = textPropCol.addWithName(textPropName);
    }
    return tp;
  }
View Full Code Here

Examples of org.apache.poi.hslf.model.textproperties.TextProp

   * Returns -1 if that TextProp isn't present.
   * If the TextProp isn't present, the value from the appropriate
   *  Master Sheet will apply.
   */
  private int getCharTextPropVal(String propName) {
    TextProp prop = null;
    if (characterStyle != null){
      prop = characterStyle.findByName(propName);
    }

    if (prop == null){
      Sheet sheet = parentRun.getSheet();
      int txtype = parentRun.getRunType();
      MasterSheet master = sheet.getMasterSheet();
      if (master != null)
        prop = master.getStyleAttribute(txtype, getIndentLevel(), propName, true);
    }
    return prop == null ? -1 : prop.getValue();
  }
View Full Code Here

Examples of org.apache.poi.hslf.model.textproperties.TextProp

   * Returns -1 if that TextProp isn't present.
   * If the TextProp isn't present, the value from the appropriate
   *  Master Sheet will apply.
   */
  private int getParaTextPropVal(String propName) {
    TextProp prop = null;
    boolean hardAttribute = false;
    if (paragraphStyle != null){
      prop = paragraphStyle.findByName(propName);

      BitMaskTextProp maskProp = (BitMaskTextProp)paragraphStyle.findByName(ParagraphFlagsTextProp.NAME);
      hardAttribute = maskProp != null && maskProp.getValue() == 0;
    }
    if (prop == null && !hardAttribute){
      Sheet sheet = parentRun.getSheet();
      int txtype = parentRun.getRunType();
      MasterSheet master = sheet.getMasterSheet();
      if (master != null)
        prop = master.getStyleAttribute(txtype, getIndentLevel(), propName, false);
    }

    return prop == null ? -1 : prop.getValue();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.