Package org.apache.poi.hslf.model.textproperties

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


  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();
            int txtype = parentRun.getRunType();
            MasterSheet master = sheet.getMasterSheet();
View Full Code Here

  private void setCharFlagsTextPropVal(int index, boolean 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

  }
  private int getCharactersCovered(LinkedList styles) {
    int length = 0;
    Iterator it = styles.iterator();
    while(it.hasNext()) {
      TextPropCollection tpc =
        (TextPropCollection)it.next();
      length += tpc.getCharactersCovered();
    }
    return length;
  }
View Full Code Here

    // Set empty paragraph and character styles
    paragraphStyles = new LinkedList();
    charStyles = new LinkedList();

    TextPropCollection defaultParagraphTextProps =
      new TextPropCollection(parentTextSize, (short)0);
    paragraphStyles.add(defaultParagraphTextProps);

    TextPropCollection defaultCharacterTextProps =
      new TextPropCollection(parentTextSize);
    charStyles.add(defaultCharacterTextProps);

    // Set us as now initialised
    initialised = true;
  }
View Full Code Here

      // Grab the 4 byte value that tells us what properties follow
      int paraFlags = LittleEndian.getInt(rawContents,pos);
      pos += 4;

      // Now make sense of those properties
      TextPropCollection thisCollection = new TextPropCollection(textLen, paraIgn);
      int plSize = thisCollection.buildTextPropList(
          paraFlags, paragraphTextPropTypes, rawContents, pos);
      pos += plSize;

      // Save this properties set
      paragraphStyles.add(thisCollection);

            // Handle extra 1 paragraph styles at the end
            if(pos < rawContents.length && textHandled == size) {
                prsize++;
            }

    }
        if (rawContents.length > 0 && textHandled != (size+1)){
            logger.log(POILogger.WARN, "Problem reading paragraph style runs: textHandled = " + textHandled + ", text.size+1 = " + (size+1));
        }

    // Now do the character stylings
    textHandled = 0;
        int chsize = size;
    while(pos < rawContents.length && textHandled < chsize) {
      // First up, fetch the number of characters this applies to
      int textLen = LittleEndian.getInt(rawContents,pos);
      textHandled += textLen;
      pos += 4;

      // There is no 2 byte value
      short no_val = -1;

      // Grab the 4 byte value that tells us what properties follow
      int charFlags = LittleEndian.getInt(rawContents,pos);
      pos += 4;

      // Now make sense of those properties
      // (Assuming we actually have some)
      TextPropCollection thisCollection = new TextPropCollection(textLen, no_val);
      int chSize = thisCollection.buildTextPropList(
          charFlags, characterTextPropTypes, rawContents, pos);
      pos += chSize;

      // Save this properties set
      charStyles.add(thisCollection);
View Full Code Here

    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    // First up, we need to serialise the paragraph properties
    for(int i=0; i<paragraphStyles.size(); i++) {
      TextPropCollection tpc = (TextPropCollection)paragraphStyles.get(i);
      tpc.writeOut(baos);
    }

    // Now, we do the character ones
    for(int i=0; i<charStyles.size(); i++) {
      TextPropCollection tpc = (TextPropCollection)charStyles.get(i);
      tpc.writeOut(baos);
    }

    rawContents  = baos.toByteArray();
  }
View Full Code Here

   * Create a new Paragraph 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 addParagraphTextPropCollection(int charactersCovered) {
    TextPropCollection tpc = new TextPropCollection(charactersCovered, (short)0);
    paragraphStyles.add(tpc);
    return tpc;
  }
View Full Code Here

   * 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);
    charStyles.add(tpc);
    return tpc;
  }
View Full Code Here

     */
    public String toString(){
        StringBuffer out = new StringBuffer();
        out.append("Paragraph properties\n");
        for (Iterator it1 = getParagraphStyles().iterator(); it1.hasNext();) {
            TextPropCollection pr = (TextPropCollection)it1.next();
            out.append("  chars covered: " + pr.getCharactersCovered() + "\n");
            for (Iterator it2 = pr.getTextPropList().iterator(); it2.hasNext(); ) {
                TextProp p = (TextProp)it2.next();
                out.append("    " + p.getName() + " = " + p.getValue() + "\n");
            }
        }

        out.append("Character properties\n");
        for (Iterator it1 = getCharacterStyles().iterator(); it1.hasNext();) {
            TextPropCollection pr = (TextPropCollection)it1.next();
            out.append("  chars covered: " + pr.getCharactersCovered() + "\n");
            for (Iterator it2 = pr.getTextPropList().iterator(); it2.hasNext(); ) {
                TextProp p = (TextProp)it2.next();
                out.append("    " + p.getName() + " = " + p.getValue() + "\n");
            }
        }

View Full Code Here

TOP

Related Classes of org.apache.poi.hslf.model.textproperties.TextPropCollection

Copyright © 2018 www.massapicom. 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.