From ebc731a087df8af8d2fc2d8d531d274fc17f532d Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Wed, 2 Jan 2008 15:48:11 +0000 Subject: [PATCH] Improve the javadocs for font and fill related colourings, and add another tests to check it all works as expected git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@608132 13f79535-47bb-0310-9956-ffa450edef68 --- src/documentation/content/xdocs/changes.xml | 3 +- src/documentation/content/xdocs/status.xml | 3 +- .../poi/hssf/usermodel/HSSFCellStyle.java | 49 +++++++------ .../apache/poi/hssf/usermodel/HSSFFont.java | 2 +- .../poi/hssf/data/SimpleWithColours.xls | Bin 0 -> 6144 bytes .../poi/hssf/usermodel/TestHSSFPalette.java | 65 ++++++++++++++++++ 6 files changed, 98 insertions(+), 24 deletions(-) create mode 100755 src/testcases/org/apache/poi/hssf/data/SimpleWithColours.xls diff --git a/src/documentation/content/xdocs/changes.xml b/src/documentation/content/xdocs/changes.xml index db17e5f5a..5a39d4d69 100644 --- a/src/documentation/content/xdocs/changes.xml +++ b/src/documentation/content/xdocs/changes.xml @@ -35,7 +35,8 @@ - + + Improve JavaDocs relating to hssf font and fill colourings 44095, 44097, 44099 - [PATCH] Support for Mid, Replace and Substitute excel functions 44055 - [PATCH] Support for getting the from field from HSMF messages 43551 - [PATCH] Support for 1904 date windowing in HSSF (previously only supported 1900 date windowing) diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index bff8b99c7..39c84096d 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -32,7 +32,8 @@ - + + Improve JavaDocs relating to hssf font and fill colourings 44095, 44097, 44099 - [PATCH] Support for Mid, Replace and Substitute excel functions 44055 - [PATCH] Support for getting the from field from HSMF messages 43551 - [PATCH] Support for 1904 date windowing in HSSF (previously only supported 1900 date windowing) diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java b/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java index e2725937f..cdea9ee5b 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java @@ -294,10 +294,24 @@ public class HSSFCellStyle format.setFontIndex(fontindex); } + /** + * gets the index of the font for this style + * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#getFontAt(short) + */ public short getFontIndex() { return format.getFontIndex(); } + + /** + * gets the font for this style + * @param parentWorkbook The HSSFWorkbook that this style belongs to + * @see org.apache.poi.hssf.usermodel.HSSFCellStyle#getFontIndex() + * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#getFontAt(short) + */ + public HSSFFont getFont(HSSFWorkbook parentWorkbook) { + return parentWorkbook.getFontAt(getFontIndex()); + } /** * set the cell's using this style to be hidden @@ -689,7 +703,6 @@ public class HSSFCellStyle * @see #BORDER_MEDIUM_DASH_DOT_DOT * @see #BORDER_SLANTED_DASH_DOT */ - public short getBorderBottom() { return format.getBorderBottom(); @@ -697,9 +710,8 @@ public class HSSFCellStyle /** * set the color to use for the left border - * @param color + * @param color The index of the color definition */ - public void setLeftBorderColor(short color) { format.setLeftBorderPaletteIdx(color); @@ -707,9 +719,9 @@ public class HSSFCellStyle /** * get the color to use for the left border - * @return color + * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short) + * @param color The index of the color definition */ - public short getLeftBorderColor() { return format.getLeftBorderPaletteIdx(); @@ -717,9 +729,8 @@ public class HSSFCellStyle /** * set the color to use for the right border - * @param color + * @param color The index of the color definition */ - public void setRightBorderColor(short color) { format.setRightBorderPaletteIdx(color); @@ -727,9 +738,9 @@ public class HSSFCellStyle /** * get the color to use for the left border - * @return color + * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short) + * @param color The index of the color definition */ - public short getRightBorderColor() { return format.getRightBorderPaletteIdx(); @@ -737,9 +748,8 @@ public class HSSFCellStyle /** * set the color to use for the top border - * @param color + * @param color The index of the color definition */ - public void setTopBorderColor(short color) { format.setTopBorderPaletteIdx(color); @@ -747,9 +757,9 @@ public class HSSFCellStyle /** * get the color to use for the top border - * @return color + * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short) + * @param color The index of the color definition */ - public short getTopBorderColor() { return format.getTopBorderPaletteIdx(); @@ -757,9 +767,8 @@ public class HSSFCellStyle /** * set the color to use for the bottom border - * @param color + * @param color The index of the color definition */ - public void setBottomBorderColor(short color) { format.setBottomBorderPaletteIdx(color); @@ -767,9 +776,9 @@ public class HSSFCellStyle /** * get the color to use for the left border - * @return color + * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short) + * @param color The index of the color definition */ - public short getBottomBorderColor() { return format.getBottomBorderPaletteIdx(); @@ -871,9 +880,9 @@ public class HSSFCellStyle /** * get the background fill color + * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short) * @return fill color */ - public short getFillBackgroundColor() { short result = format.getFillBackground(); @@ -889,7 +898,6 @@ public class HSSFCellStyle * Note: Ensure Foreground color is set prior to background color. * @param bg color */ - public void setFillForegroundColor(short bg) { format.setFillForeground(bg); @@ -898,12 +906,11 @@ public class HSSFCellStyle /** * get the foreground fill color + * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short) * @return fill color */ - public short getFillForegroundColor() { return format.getFillForeground(); } - } diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFFont.java b/src/java/org/apache/poi/hssf/usermodel/HSSFFont.java index 852e15ee2..cfaa5e4f4 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFFont.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFFont.java @@ -281,8 +281,8 @@ public class HSSFFont * @return color to use * @see #COLOR_NORMAL * @see #COLOR_RED + * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short) */ - public short getColor() { return font.getColorPaletteIndex(); diff --git a/src/testcases/org/apache/poi/hssf/data/SimpleWithColours.xls b/src/testcases/org/apache/poi/hssf/data/SimpleWithColours.xls new file mode 100755 index 0000000000000000000000000000000000000000..ab3cdecf0b5674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