slaubach    2005/04/22 07:56:35

  Modified:    src/java/org/apache/poi/hssf/usermodel HSSFHeader.java
                        HSSFFooter.java
  Log:
  Added underline capability to the header and footer.
  
  Revision  Changes    Path
  1.10      +40 -0     
jakarta-poi/src/java/org/apache/poi/hssf/usermodel/HSSFHeader.java
  
  Index: HSSFHeader.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/usermodel/HSSFHeader.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- HSSFHeader.java   19 Sep 2004 02:44:52 -0000      1.9
  +++ HSSFHeader.java   22 Apr 2005 14:56:35 -0000      1.10
  @@ -252,5 +252,45 @@
       {
           return "&A";
       }
  +
  +    /**
  +     * Returns the string representing the start underline
  +     *
  +     * @return The special string for start underline
  +     */
  +    public static String startUnderline()
  +    {
  +        return "&U";
  +    }
  +
  +    /**
  +     * Returns the string representing the end underline
  +     *
  +     * @return The special string for end underline
  +     */
  +    public static String endUnderline()
  +    {
  +        return "&U";
  +    }
  +
  +    /**
  +     * Returns the string representing the start double underline
  +     *
  +     * @return The special string for start double underline
  +     */
  +    public static String startDoubleUnderline()
  +    {
  +        return "&E";
  +    }
  +
  +    /**
  +     * Returns the string representing the end double underline
  +     *
  +     * @return The special string for end double underline
  +     */
  +    public static String endDoubleUnderline()
  +    {
  +        return "&E";
  +    }
   }
   
  
  
  
  1.10      +216 -176  
jakarta-poi/src/java/org/apache/poi/hssf/usermodel/HSSFFooter.java
  
  Index: HSSFFooter.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/usermodel/HSSFFooter.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- HSSFFooter.java   2 Jan 2005 01:00:52 -0000       1.9
  +++ HSSFFooter.java   22 Apr 2005 14:56:35 -0000      1.10
  @@ -33,184 +33,224 @@
    */
   public class HSSFFooter extends Object {
   
  -  FooterRecord footerRecord;
  -  String left;
  -  String center;
  -  String right;
  -
  -  /**
  -   * Constructor.  Creates a new footer interface from a footer record
  -   * @param footerRecord Footer record to create the footer with
  -   */
  -  protected HSSFFooter(FooterRecord footerRecord) {
  -    this.footerRecord = footerRecord;
  -    String foot = footerRecord.getFooter();
  -    while (foot != null && foot.length() > 1) {
  -     int pos = foot.length();
  -     switch (foot.substring(1, 2).charAt(0)) {
  -     case 'L' :
  -         if (foot.indexOf("&C") >= 0) {
  -             pos = Math.min(pos, foot.indexOf("&C"));
  -         } 
  -         if (foot.indexOf("&R") >= 0) {
  -             pos = Math.min(pos, foot.indexOf("&R"));
  -         } 
  -         left = foot.substring(2, pos);
  -         foot = foot.substring(pos);
  -         break;
  -     case 'C' : 
  -         if (foot.indexOf("&L") >= 0) {
  -             pos = Math.min(pos, foot.indexOf("&L"));
  -         } 
  -         if (foot.indexOf("&R") >= 0) {
  -             pos = Math.min(pos, foot.indexOf("&R"));
  -         } 
  -         center = foot.substring(2, pos);
  -         foot = foot.substring(pos);
  -         break;
  -     case 'R' : 
  -         if (foot.indexOf("&C") >= 0) {
  -             pos = Math.min(pos, foot.indexOf("&C"));
  -         } 
  -         if (foot.indexOf("&L") >= 0) {
  -             pos = Math.min(pos, foot.indexOf("&L"));
  -         } 
  -         right = foot.substring(2, pos);
  -         foot = foot.substring(pos);
  -         break;
  -     default : foot = null;
  +    FooterRecord footerRecord;
  +    String left;
  +    String center;
  +    String right;
  +
  +    /**
  +     * Constructor.  Creates a new footer interface from a footer record
  +     * @param footerRecord Footer record to create the footer with
  +     */
  +    protected HSSFFooter(FooterRecord footerRecord) {
  +     this.footerRecord = footerRecord;
  +     String foot = footerRecord.getFooter();
  +     while (foot != null && foot.length() > 1) {
  +         int pos = foot.length();
  +         switch (foot.substring(1, 2).charAt(0)) {
  +         case 'L' :
  +             if (foot.indexOf("&C") >= 0) {
  +                 pos = Math.min(pos, foot.indexOf("&C"));
  +             } 
  +             if (foot.indexOf("&R") >= 0) {
  +                 pos = Math.min(pos, foot.indexOf("&R"));
  +             } 
  +             left = foot.substring(2, pos);
  +             foot = foot.substring(pos);
  +             break;
  +         case 'C' : 
  +             if (foot.indexOf("&L") >= 0) {
  +                 pos = Math.min(pos, foot.indexOf("&L"));
  +             } 
  +             if (foot.indexOf("&R") >= 0) {
  +                 pos = Math.min(pos, foot.indexOf("&R"));
  +             } 
  +             center = foot.substring(2, pos);
  +             foot = foot.substring(pos);
  +             break;
  +         case 'R' : 
  +             if (foot.indexOf("&C") >= 0) {
  +                 pos = Math.min(pos, foot.indexOf("&C"));
  +             } 
  +             if (foot.indexOf("&L") >= 0) {
  +                 pos = Math.min(pos, foot.indexOf("&L"));
  +             } 
  +             right = foot.substring(2, pos);
  +             foot = foot.substring(pos);
  +             break;
  +         default : foot = null;
  +         }
        }
       }
  -  }
   
  -  /**
  -   * Get the left side of the footer.
  -   * @return The string representing the left side.
  -   */
  -  public String getLeft() {
  -    return left;
  -  }
  -
  -  /**
  -   * Sets the left string.
  -   * @param newLeft The string to set as the left side.
  -   */
  -  public void setLeft(String newLeft) {
  -    left = newLeft;
  -    createFooterString();
  -  }
  -
  -  /**
  -   * Get the center of the footer.
  -   * @return The string representing the center.
  -   */
  -  public String getCenter() {
  -    return center;
  -  }
  -
  -  /**
  -   * Sets the center string.
  -   * @param newCenter The string to set as the center.
  -   */
  -  public void setCenter(String newCenter) {
  -    center = newCenter;
  -    createFooterString();
  -  }
  -
  -  /**
  -   * Get the right side of the footer.
  -   * @return The string representing the right side.
  -   */
  -  public String getRight() {
  -    return right;
  -  }
  -
  -  /**
  -   * Sets the right string.
  -   * @param newRight The string to set as the right side.
  -   */
  -  public void setRight(String newRight) {
  -    right = newRight;
  -    createFooterString();
  -  }
  -
  -  /**
  -   * Creates the complete footer string based on the left, center, and middle
  -   * strings.
  -   */
  -  private void createFooterString() {
  -    footerRecord.setFooter(
  -    "&C" + (center == null ? "" : center) +
  -    "&L" + (left == null ? "" : left) +
  -    "&R" + (right == null ? "" : right));
  -    footerRecord.setFooterLength((byte)footerRecord.getFooter().length());
  -  }
  -
  -  /**
  -   * Returns the string that represents the change in font size.
  -   * @param size the new font size
  -   * @return The special string to represent a new font size
  -   */
  -  public static String fontSize(short size) {
  -    return "&" + size;
  -  }
  -
  -  /**
  -   * Returns the string that represents the change in font.
  -   * @param font the new font
  -   * @param style the fonts style
  -   * @return The special string to represent a new font size
  -   */
  -  public static String font(String font, String style) {
  -    return "&\"" + font + "," + style + "\"";
  -  }
  -
  -  /**
  -   * Returns the string representing the current page number
  -   * @return The special string for page number
  -   */
  -  public static String page() {
  -    return "&P";
  -  }
  -
  -  /**
  -   * Returns the string representing the number of pages.
  -   * @return The special string for the number of pages
  -   */
  -  public static String numPages() {
  -    return "&N";
  -  }
  -
  -  /**
  -   * Returns the string representing the current date
  -   * @return The special string for the date
  -   */
  -  public static String date() {
  -    return "&D";
  -  }
  -
  -  /**
  -   * Returns the string representing the current time
  -   * @return The special string for the time
  -   */
  -  public static String time() {
  -    return "&T";
  -  }
  -
  -  /**
  -   * Returns the string representing the current file name
  -   * @return The special string for the file name
  -   */
  -  public static String file() {
  -    return "&F";
  -  }
  -
  -  /**
  -   * Returns the string representing the current tab (sheet) name
  -   * @return The special string for tab name
  -   */
  -  public static String tab() {
  -    return "&A";
  -  }
  +    /**
  +     * Get the left side of the footer.
  +     * @return The string representing the left side.
  +     */
  +    public String getLeft() {
  +     return left;
  +    }
  +
  +    /**
  +     * Sets the left string.
  +     * @param newLeft The string to set as the left side.
  +     */
  +    public void setLeft(String newLeft) {
  +     left = newLeft;
  +     createFooterString();
  +    }
  +
  +    /**
  +     * Get the center of the footer.
  +     * @return The string representing the center.
  +     */
  +    public String getCenter() {
  +     return center;
  +    }
  +
  +    /**
  +     * Sets the center string.
  +     * @param newCenter The string to set as the center.
  +     */
  +    public void setCenter(String newCenter) {
  +     center = newCenter;
  +     createFooterString();
  +    }
  +
  +    /**
  +     * Get the right side of the footer.
  +     * @return The string representing the right side.
  +     */
  +    public String getRight() {
  +     return right;
  +    }
  +
  +    /**
  +     * Sets the right string.
  +     * @param newRight The string to set as the right side.
  +     */
  +    public void setRight(String newRight) {
  +     right = newRight;
  +     createFooterString();
  +    }
  +
  +    /**
  +     * Creates the complete footer string based on the left, center, and 
middle
  +     * strings.
  +     */
  +    private void createFooterString() {
  +     footerRecord.setFooter(
  +                            "&C" + (center == null ? "" : center) +
  +                            "&L" + (left == null ? "" : left) +
  +                            "&R" + (right == null ? "" : right));
  +     footerRecord.setFooterLength((byte)footerRecord.getFooter().length());
  +    }
  +
  +    /**
  +     * Returns the string that represents the change in font size.
  +     * @param size the new font size
  +     * @return The special string to represent a new font size
  +     */
  +    public static String fontSize(short size) {
  +     return "&" + size;
  +    }
  +
  +    /**
  +     * Returns the string that represents the change in font.
  +     * @param font the new font
  +     * @param style the fonts style
  +     * @return The special string to represent a new font size
  +     */
  +    public static String font(String font, String style) {
  +     return "&\"" + font + "," + style + "\"";
  +    }
  +
  +    /**
  +     * Returns the string representing the current page number
  +     * @return The special string for page number
  +     */
  +    public static String page() {
  +     return "&P";
  +    }
  +
  +    /**
  +     * Returns the string representing the number of pages.
  +     * @return The special string for the number of pages
  +     */
  +    public static String numPages() {
  +     return "&N";
  +    }
  +
  +    /**
  +     * Returns the string representing the current date
  +     * @return The special string for the date
  +     */
  +    public static String date() {
  +     return "&D";
  +    }
  +
  +    /**
  +     * Returns the string representing the current time
  +     * @return The special string for the time
  +     */
  +    public static String time() {
  +     return "&T";
  +    }
  +
  +    /**
  +     * Returns the string representing the current file name
  +     * @return The special string for the file name
  +     */
  +    public static String file() {
  +     return "&F";
  +    }
  +
  +    /**
  +     * Returns the string representing the current tab (sheet) name
  +     * @return The special string for tab name
  +     */
  +    public static String tab() {
  +     return "&A";
  +    }
  +
  +    /**
  +     * Returns the string representing the start underline
  +     *
  +     * @return The special string for start underline
  +     */
  +    public static String startUnderline()
  +    {
  +        return "&U";
  +    }
  +
  +    /**
  +     * Returns the string representing the end underline
  +     *
  +     * @return The special string for end underline
  +     */
  +    public static String endUnderline()
  +    {
  +        return "&U";
  +    }
  +
  +    /**
  +     * Returns the string representing the start double underline
  +     *
  +     * @return The special string for start double underline
  +     */
  +    public static String startDoubleUnderline()
  +    {
  +        return "&E";
  +    }
  +
  +    /**
  +     * Returns the string representing the end double underline
  +     *
  +     * @return The special string for end double underline
  +     */
  +    public static String endDoubleUnderline()
  +    {
  +        return "&E";
  +    }
   }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/

Reply via email to