Examples of TextProp


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

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

    if(paragraphStyle == null) {
      parentRun.ensureStyleAtomPresent();
      // paragraphStyle will now be defined
    }

    TextProp tp = fetchOrAddTextProp(paragraphStyle, propName);
    tp.setValue(val);
  }
View Full Code Here

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

    if(characterStyle == null) {
      parentRun.ensureStyleAtomPresent();
      // characterStyle will now be defined
    }

    TextProp tp = fetchOrAddTextProp(characterStyle, propName);
    tp.setValue(val);
  }
View Full Code Here

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

  public static void showTextProps(TextPropCollection tpc) {
    LinkedList textProps = tpc.getTextPropList();
    System.out.println("    Contains " + textProps.size() + " TextProps");
    for(int i=0; i<textProps.size(); i++) {
      TextProp tp = (TextProp)textProps.get(i);
      System.out.println("      " + i + " - " + tp.getName());
      System.out.println("          = " + tp.getValue());
      System.out.println("          @ " + tp.getMask());

      if(tp instanceof BitMaskTextProp) {
        BitMaskTextProp bmtp = (BitMaskTextProp)tp;
        String[] subPropNames = bmtp.getSubPropNames();
        boolean[] subPropMatches = bmtp.getSubPropMatches();
View Full Code Here

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

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

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

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

        //character styles
        props = txmaster.getCharacterStyles()[0];

        prop = props.findByName("font.color");
        assertEquals(0x3000000, prop.getValue());

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

        prop = props.findByName("font.size");
        assertEquals(44, prop.getValue());

    }
View Full Code Here

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

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

        TextPropCollection[] prstyles = txmaster.getParagraphStyles();
        TextPropCollection[] chstyles = txmaster.getCharacterStyles();
        assertEquals("TxMasterStyleAtom for TextHeaderAtom.BODY_TYPE " +
                "must contain styles for 5 indentation levels", 5, prstyles.length);
        assertEquals("TxMasterStyleAtom for TextHeaderAtom.BODY_TYPE " +
                "must contain styles for 5 indentation levels", 5, chstyles.length);

        //paragraph styles
        props = prstyles[0];

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


        for (int i = 0; i < prstyles.length; i++) {
            assertNotNull("text.offset is null for indentation level " + i, prstyles[i].findByName("text.offset"));
            assertNotNull("bullet.offset is null for indentation level " + i, prstyles[i].findByName("bullet.offset"));
        }

        //character styles
        props = chstyles[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());
    }
View Full Code Here

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

        TextPropCollection b_p_3 = (TextPropCollection)b_p_l.get(2);
        TextPropCollection b_p_4 = (TextPropCollection)b_p_l.get(3);

        // 1st is left aligned + normal line spacing
        assertEquals(2,b_p_1.getTextPropList().size());
        TextProp tp_1_1 = (TextProp)b_p_1.getTextPropList().get(0);
        TextProp tp_1_2 = (TextProp)b_p_1.getTextPropList().get(1);
        assertEquals(true, tp_1_1 instanceof TextProp);
        assertEquals(true, tp_1_2 instanceof TextProp);
        assertEquals("alignment", tp_1_1.getName());
        assertEquals("linespacing", tp_1_2.getName());
        assertEquals(0, tp_1_1.getValue());
        assertEquals(80, tp_1_2.getValue());

        // 2nd is centre aligned (default) + normal line spacing
        assertEquals(1,b_p_2.getTextPropList().size());
        TextProp tp_2_1 = (TextProp)b_p_2.getTextPropList().get(0);
        assertEquals(true, tp_2_1 instanceof TextProp);
        assertEquals(true, tp_1_2 instanceof TextProp);
        assertEquals("linespacing", tp_2_1.getName());
        assertEquals(80, tp_2_1.getValue());

        // 3rd is right aligned + normal line spacing
        assertEquals(2,b_p_3.getTextPropList().size());
        TextProp tp_3_1 = (TextProp)b_p_3.getTextPropList().get(0);
        TextProp tp_3_2 = (TextProp)b_p_3.getTextPropList().get(1);
        assertEquals(true, tp_3_1 instanceof TextProp);
        assertEquals(true, tp_3_2 instanceof TextProp);
        assertEquals("alignment", tp_3_1.getName());
        assertEquals("linespacing", tp_3_2.getName());
        assertEquals(2, tp_3_1.getValue());
        assertEquals(80, tp_3_2.getValue());

        // 4st is left aligned + normal line spacing (despite differing font)
        assertEquals(2,b_p_4.getTextPropList().size());
        TextProp tp_4_1 = (TextProp)b_p_4.getTextPropList().get(0);
        TextProp tp_4_2 = (TextProp)b_p_4.getTextPropList().get(1);
        assertEquals(true, tp_4_1 instanceof TextProp);
        assertEquals(true, tp_4_2 instanceof TextProp);
        assertEquals("alignment", tp_4_1.getName());
        assertEquals("linespacing", tp_4_2.getName());
        assertEquals(0, tp_4_1.getValue());
        assertEquals(80, tp_4_2.getValue());
    }
View Full Code Here

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

        assertNull(b_ch_3.findByName("char_flags"));
        assertNotNull(b_ch_4.findByName("char_flags"));

        // Now add in on 3, should go to front
        assertEquals(2, b_ch_3.getTextPropList().size());
        TextProp new_cftp = b_ch_3.addWithName("char_flags");
        assertEquals(3, b_ch_3.getTextPropList().size());
        assertEquals(new_cftp, b_ch_3.getTextPropList().get(0));

        // alignment: 1 does have, 2 doesn't
        assertNotNull(b_p_1.findByName("alignment"));
        assertNull(b_p_2.findByName("alignment"));

        // Now add in on 2, should go to the front
        assertEquals(1, b_p_2.getTextPropList().size());
        TextProp new_al = b_p_2.addWithName("alignment");
        assertEquals(2, b_p_2.getTextPropList().size());
        assertEquals(new_al, b_p_2.getTextPropList().get(0));

        // This should go at the end
        TextProp new_sa = b_p_2.addWithName("spaceafter");
        assertEquals(3, b_p_2.getTextPropList().size());
        assertEquals(new_sa, b_p_2.getTextPropList().get(2));

        // Check we get an error with a made up one
        try {
View Full Code Here

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

        TextPropCollection tpca = (TextPropCollection)cs.get(0);
        tpca.updateTextSize(21);

        // Second char style is coloured, 00 00 00 05, and 17 long
        TextPropCollection tpcb = stpa.addCharacterTextPropCollection(17);
        TextProp tpb = tpcb.addWithName("font.color");
        tpb.setValue(0x05000000);

        // Third char style is coloured, FF 33 00 FE, and 16 long
        TextPropCollection tpcc = stpa.addCharacterTextPropCollection(16);
        TextProp tpc = tpcc.addWithName("font.color");
        tpc.setValue(0xFE0033FF);

        // Should now be the same as data_a
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        stpa.writeOut(baos);
        byte[] b = baos.toByteArray();
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.