Examples of TextPropCollection


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

    //  the text by one, we need to shuffle that
    //  extra character onto the new ones
    int pOverRun = _styleAtom.getParagraphTextLengthCovered() - oldSize;
    int cOverRun = _styleAtom.getCharacterTextLengthCovered() - oldSize;
    if(pOverRun > 0) {
      TextPropCollection tpc = (TextPropCollection)
        _styleAtom.getParagraphStyles().getLast();
      tpc.updateTextSize(
          tpc.getCharactersCovered() - pOverRun
      );
    }
    if(cOverRun > 0) {
      TextPropCollection tpc = (TextPropCollection)
        _styleAtom.getCharacterStyles().getLast();
      tpc.updateTextSize(
          tpc.getCharactersCovered() - cOverRun
      );
    }

    // Next, add the styles for its paragraph and characters
    TextPropCollection newPTP =
      _styleAtom.addParagraphTextPropCollection(s.length()+pOverRun);
    TextPropCollection newCTP =
      _styleAtom.addCharacterTextPropCollection(s.length()+cOverRun);

    // Now, create the new RichTextRun
    RichTextRun nr = new RichTextRun(
        this, oldSize, s.length(),
View Full Code Here

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

    //   * reset the length, to the new string's length
    //   * add on +1 if the last block
    // The last run needs its stylings to be 1 longer than the raw
    //  text is. This is to define the stylings that any new text
    //  that is added will inherit
    TextPropCollection pCol = run._getRawParagraphStyle();
    TextPropCollection cCol = run._getRawCharacterStyle();
    int newSize = s.length();
    if(runID == _rtRuns.length-1) {
      newSize++;
    }

    if(run._isParagraphStyleShared()) {
      pCol.updateTextSize( pCol.getCharactersCovered() - run.getLength() + s.length() );
    } else {
      pCol.updateTextSize(newSize);
    }
    if(run._isCharacterStyleShared()) {
      cCol.updateTextSize( cCol.getCharactersCovered() - run.getLength() + s.length() );
    } else {
      cCol.updateTextSize(newSize);
    }

    // Build up the new text
    // As we go through, update the start position for all subsequent runs
    // The building relies on the old text still being present
View Full Code Here

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

    assertEquals(3, trB.getRichTextRuns().length);

    RichTextRun rtrB = trB.getRichTextRuns()[0];
    RichTextRun rtrC = trB.getRichTextRuns()[1];
    RichTextRun rtrD = trB.getRichTextRuns()[2];
    TextPropCollection tpBP = rtrB._getRawParagraphStyle();
    TextPropCollection tpBC = rtrB._getRawCharacterStyle();
    TextPropCollection tpCP = rtrC._getRawParagraphStyle();
    TextPropCollection tpCC = rtrC._getRawCharacterStyle();
    TextPropCollection tpDP = rtrD._getRawParagraphStyle();
    TextPropCollection tpDC = rtrD._getRawCharacterStyle();

    assertEquals(trB.getText().substring(0, 30), rtrB.getText());
    assertNotNull(tpBP);
    assertNotNull(tpBC);
    assertNotNull(tpCP);
View Full Code Here

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

    // We start with 3 text runs, each with their own set of styles,
    //  but all sharing the same paragraph styles
    RichTextRun rtrB = trB.getRichTextRuns()[0];
    RichTextRun rtrC = trB.getRichTextRuns()[1];
    RichTextRun rtrD = trB.getRichTextRuns()[2];
    TextPropCollection tpBP = rtrB._getRawParagraphStyle();
    TextPropCollection tpBC = rtrB._getRawCharacterStyle();
    TextPropCollection tpCP = rtrC._getRawParagraphStyle();
    TextPropCollection tpCC = rtrC._getRawCharacterStyle();
    TextPropCollection tpDP = rtrD._getRawParagraphStyle();
    TextPropCollection tpDC = rtrD._getRawCharacterStyle();

    // Check text and stylings
    assertEquals(trB.getText().substring(0, 30), rtrB.getText());
    assertNotNull(tpBP);
    assertNotNull(tpBC);
    assertNotNull(tpCP);
    assertNotNull(tpCC);
    assertNotNull(tpDP);
    assertNotNull(tpDC);
    assertTrue(tpBP.equals(tpCP));
    assertTrue(tpBP.equals(tpDP));
    assertTrue(tpCP.equals(tpDP));
    assertFalse(tpBC.equals(tpCC));
    assertFalse(tpBC.equals(tpDC));
    assertFalse(tpCC.equals(tpDC));

    // Check text in the rich runs
    assertEquals("This is the subtitle, in bold\n", rtrB.getText());
    assertEquals("This bit is blue and italic\n", rtrC.getText());
    assertEquals("This bit is red (normal)", rtrD.getText());

    String newBText = "New Subtitle, will still be bold\n";
    String newCText = "New blue and italic text\n";
    String newDText = "Funky new normal red text";
    rtrB.setText(newBText);
    rtrC.setText(newCText);
    rtrD.setText(newDText);
    assertEquals(newBText, rtrB.getText());
    assertEquals(newCText, rtrC.getText());
    assertEquals(newDText, rtrD.getText());

    assertEquals(newBText + newCText + newDText, trB.getText());

    // The styles should have been updated for the new sizes
    assertEquals(newBText.length(), tpBC.getCharactersCovered());
    assertEquals(newCText.length(), tpCC.getCharactersCovered());
    assertEquals(newDText.length()+1, tpDC.getCharactersCovered()); // Last one is always one larger

    assertEquals(
        newBText.length() + newCText.length() + newDText.length(),
        tpBP.getCharactersCovered()
    );

    // Paragraph style should be sum of text length
    assertEquals(newBText.length() + newCText.length() + newDText.length(), tpBP.getCharactersCovered());

    // Check stylings still as expected
    TextPropCollection ntpBC = rtrB._getRawCharacterStyle();
    TextPropCollection ntpCC = rtrC._getRawCharacterStyle();
    TextPropCollection ntpDC = rtrD._getRawCharacterStyle();
    assertEquals(tpBC.getTextPropList(), ntpBC.getTextPropList());
    assertEquals(tpCC.getTextPropList(), ntpCC.getTextPropList());
    assertEquals(tpDC.getTextPropList(), ntpDC.getTextPropList());
    }
View Full Code Here

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

  private boolean isCharFlagsTextPropVal(int index) {
    return getFlag(true, index);
  }

    private boolean getFlag(boolean isCharacter, int index) {
        TextPropCollection props;
        String propname;
        if (isCharacter){
            props = characterStyle;
            propname = CharFlagsTextProp.NAME;
        } else {
            props = paragraphStyle;
            propname = ParagraphFlagsTextProp.NAME;
        }

        BitMaskTextProp prop = null;
        if (props != null){
            prop = (BitMaskTextProp)props.findByName(propname);
        }
        if (prop == null){
            Sheet sheet = parentRun.getSheet();
            if(sheet != null){
                int txtype = parentRun.getRunType();
View Full Code Here

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

  private void setCharFlagsTextPropVal(int index, boolean value) {
        if(getFlag(true, index) != value) setFlag(true, index, value);
  }

    public void setFlag(boolean isCharacter, int index, boolean value) {
        TextPropCollection props;
        String propname;
        if (isCharacter){
            props = characterStyle;
            propname = CharFlagsTextProp.NAME;
        } else {
View Full Code Here

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

    System.out.println("\nFound a StyleTextPropAtom");

    LinkedList paragraphStyles = stpa.getParagraphStyles();
    System.out.println("Contains " + paragraphStyles.size() + " paragraph styles:");
    for(int i=0; i<paragraphStyles.size(); i++) {
      TextPropCollection tpc = (TextPropCollection)paragraphStyles.get(i);
      System.out.println(" In paragraph styling " + i + ":");
      System.out.println("  Characters covered is " + tpc.getCharactersCovered());
      showTextProps(tpc);
    }

    LinkedList charStyles = stpa.getCharacterStyles();
    System.out.println("Contains " + charStyles.size() + " character styles:");
    for(int i=0; i<charStyles.size(); i++) {
      TextPropCollection tpc = (TextPropCollection)charStyles.get(i);
      System.out.println("  In character styling " + i + ":");
      System.out.println("    Characters covered is " + tpc.getCharactersCovered());
      showTextProps(tpc);
    }
  }
View Full Code Here

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

        stpa.setParentTextSize(data_a_text_len);
        stpb.setParentTextSize(data_b_text_len);

        // 54 chars, 21 + 17 + 16
        LinkedList a_ch_l = stpa.getCharacterStyles();
        TextPropCollection a_ch_1 = (TextPropCollection)a_ch_l.get(0);
        TextPropCollection a_ch_2 = (TextPropCollection)a_ch_l.get(1);
        TextPropCollection a_ch_3 = (TextPropCollection)a_ch_l.get(2);
        assertEquals(21, a_ch_1.getCharactersCovered());
        assertEquals(17, a_ch_2.getCharactersCovered());
        assertEquals(16, a_ch_3.getCharactersCovered());

        // 179 chars, 30 + 28 + 25
        LinkedList b_ch_l = stpb.getCharacterStyles();
        TextPropCollection b_ch_1 = (TextPropCollection)b_ch_l.get(0);
        TextPropCollection b_ch_2 = (TextPropCollection)b_ch_l.get(1);
        TextPropCollection b_ch_3 = (TextPropCollection)b_ch_l.get(2);
        TextPropCollection b_ch_4 = (TextPropCollection)b_ch_l.get(3);
        assertEquals(30, b_ch_1.getCharactersCovered());
        assertEquals(28, b_ch_2.getCharactersCovered());
        assertEquals(25, b_ch_3.getCharactersCovered());
        assertEquals(96, b_ch_4.getCharactersCovered());
    }
View Full Code Here

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

    public void testCharacterPropOrdering() throws Exception {
        StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length);
        stpb.setParentTextSize(data_b_text_len);

        LinkedList b_ch_l = stpb.getCharacterStyles();
        TextPropCollection b_ch_1 = (TextPropCollection)b_ch_l.get(0);
        TextPropCollection b_ch_2 = (TextPropCollection)b_ch_l.get(1);
        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());
View Full Code Here

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

    public void testParagraphProps() throws Exception {
        StyleTextPropAtom stpb = new StyleTextPropAtom(data_b,0,data_b.length);
        stpb.setParentTextSize(data_b_text_len);

        LinkedList b_p_l = stpb.getParagraphStyles();
        TextPropCollection b_p_1 = (TextPropCollection)b_p_l.get(0);
        TextPropCollection b_p_2 = (TextPropCollection)b_p_l.get(1);
        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());
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.