ASF Bugzilla – Attachment 22670 Details for
Bug 45942
Border and fill pattern enum values
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch
20081003.diff (text/plain), 52.15 KB, created by
Gisella Bronzetti
on 2008-10-03 05:57:41 UTC
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Gisella Bronzetti
Created:
2008-10-03 05:57:41 UTC
Size:
52.15 KB
patch
obsolete
>Index: src/ooxml/java/org/apache/poi/xssf/usermodel/BorderStyle.java >=================================================================== >--- src/ooxml/java/org/apache/poi/xssf/usermodel/BorderStyle.java (revision 0) >+++ src/ooxml/java/org/apache/poi/xssf/usermodel/BorderStyle.java (revision 0) >@@ -0,0 +1,113 @@ >+/* ==================================================================== >+ Licensed to the Apache Software Foundation (ASF) under one or more >+ contributor license agreements. See the NOTICE file distributed with >+ this work for additional information regarding copyright ownership. >+ The ASF licenses this file to You under the Apache License, Version 2.0 >+ (the "License"); you may not use this file except in compliance with >+ the License. You may obtain a copy of the License at >+ >+ http://www.apache.org/licenses/LICENSE-2.0 >+ >+ Unless required by applicable law or agreed to in writing, software >+ distributed under the License is distributed on an "AS IS" BASIS, >+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. >+ See the License for the specific language governing permissions and >+ limitations under the License. >+==================================================================== */ >+ >+package org.apache.poi.xssf.usermodel; >+ >+/** >+ * The enumeration value indicating the line style of a border in a cell, >+ * i.e., whether it is borded dash dot, dash dot dot, dashed, dotted, double, hair, medium, >+ * medium dash dot, medium dash dot dot, medium dashed, none, slant dash dot, thick or thin. >+ */ >+ >+ >+public enum BorderStyle { >+ >+ /** >+ * No border >+ */ >+ >+ NONE, >+ >+ /** >+ * Thin border >+ */ >+ >+ THIN, >+ >+ /** >+ * Medium border >+ */ >+ >+ MEDIUM, >+ >+ /** >+ * dash border >+ */ >+ >+ DASHED, >+ >+ /** >+ * dot border >+ */ >+ >+ HAIR, >+ >+ /** >+ * Thick border >+ */ >+ >+ THICK, >+ >+ /** >+ * double-line border >+ */ >+ >+ DOUBLE, >+ >+ /** >+ * hair-line border >+ */ >+ >+ DOTTED, >+ >+ /** >+ * Medium dashed border >+ */ >+ >+ MEDIUM_DASHED, >+ >+ /** >+ * dash-dot border >+ */ >+ >+ DASH_DOT, >+ >+ /** >+ * medium dash-dot border >+ */ >+ >+ MEDIUM_DASH_DOT, >+ >+ /** >+ * dash-dot-dot border >+ */ >+ >+ DASH_DOT_DOT, >+ >+ /** >+ * medium dash-dot-dot border >+ */ >+ >+ MEDIUM_DASH_DOT_DOTC, >+ >+ /** >+ * slanted dash-dot border >+ */ >+ >+ SLANTED_DASH_DOT; >+ >+} >Index: src/ooxml/java/org/apache/poi/xssf/usermodel/FillPatternType.java >=================================================================== >--- src/ooxml/java/org/apache/poi/xssf/usermodel/FillPatternType.java (revision 0) >+++ src/ooxml/java/org/apache/poi/xssf/usermodel/FillPatternType.java (revision 0) >@@ -0,0 +1,85 @@ >+/* ==================================================================== >+ Licensed to the Apache Software Foundation (ASF) under one or more >+ contributor license agreements. See the NOTICE file distributed with >+ this work for additional information regarding copyright ownership. >+ The ASF licenses this file to You under the Apache License, Version 2.0 >+ (the "License"); you may not use this file except in compliance with >+ the License. You may obtain a copy of the License at >+ >+ http://www.apache.org/licenses/LICENSE-2.0 >+ >+ Unless required by applicable law or agreed to in writing, software >+ distributed under the License is distributed on an "AS IS" BASIS, >+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. >+ See the License for the specific language governing permissions and >+ limitations under the License. >+==================================================================== */ >+ >+package org.apache.poi.xssf.usermodel; >+ >+/** >+ * The enumeration value indicating the style of fill pattern being used for a cell format. >+ * >+ */ >+ >+ >+public enum FillPatternType { >+ >+ /** No background */ >+ NO_FILL, >+ >+ /** Solidly filled */ >+ SOLID_FOREGROUND, >+ >+ /** Small fine dots */ >+ FINE_DOTS, >+ >+ /** Wide dots */ >+ ALT_BARS, >+ >+ /** Sparse dots */ >+ SPARSE_DOTS, >+ >+ /** Thick horizontal bands */ >+ THICK_HORZ_BANDS, >+ >+ /** Thick vertical bands */ >+ THICK_VERT_BANDS, >+ >+ /** Thick backward facing diagonals */ >+ THICK_BACKWARD_DIAG, >+ >+ /** Thick forward facing diagonals */ >+ THICK_FORWARD_DIAG, >+ >+ /** Large spots */ >+ BIG_SPOTS, >+ >+ /** Brick-like layout */ >+ BRICKS, >+ >+ /** Thin horizontal bands */ >+ THIN_HORZ_BANDS, >+ >+ /** Thin vertical bands */ >+ THIN_VERT_BANDS, >+ >+ /** Thin backward diagonal */ >+ THIN_BACKWARD_DIAG, >+ >+ /** Thin forward diagonal */ >+ THIN_FORWARD_DIAG, >+ >+ /** Squares */ >+ SQUARES, >+ >+ /** Diamonds */ >+ DIAMONDS, >+ >+ /** Less Dots */ >+ LESS_DOTS, >+ >+ /** Least Dots */ >+ LEAST_DOTS; >+ >+} >Index: src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellFill.java >=================================================================== >--- src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellFill.java (revision 700785) >+++ src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellFill.java (working copy) >@@ -19,10 +19,11 @@ > import java.util.List; > > import org.apache.poi.xssf.usermodel.IndexedColors; >+import org.apache.poi.xssf.usermodel.FillPatternType; > import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor; > import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill; > import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPatternFill; >-import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPatternType.Enum; >+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPatternType; > > public final class XSSFCellFill { > >@@ -37,28 +38,30 @@ > } > > public XSSFColor getFillBackgroundColor() { >- CTColor ctColor = getPatternFill().getBgColor(); >- if (ctColor == null) { >- XSSFColor result = new XSSFColor(); >- result.setIndexed(IndexedColors.AUTOMATIC.getIndex()); >- return result; >- } >- return new XSSFColor(ctColor); >+ CTColor ctColor=getPatternFill().getBgColor(); >+ XSSFColor color; >+ if(ctColor == null){ >+ color=new XSSFColor(); >+ color.setIndexed(IndexedColors.AUTOMATIC.getIndex()); >+ } >+ else{ >+ color=new XSSFColor(getPatternFill().getBgColor()); >+ } >+ return color; > } > > public XSSFColor getFillForegroundColor() { >- CTColor ctColor = getPatternFill().getFgColor(); >- if (ctColor == null) { >- XSSFColor result = new XSSFColor(); >- result.setIndexed(IndexedColors.AUTOMATIC.getIndex()); >- return result; >- } >- return new XSSFColor(ctColor); >+ CTColor ctColor=getPatternFill().getFgColor(); >+ XSSFColor color; >+ if(ctColor == null){ >+ color=new XSSFColor(); >+ color.setIndexed(IndexedColors.AUTOMATIC.getIndex()); >+ } >+ else{ >+ color=new XSSFColor(getPatternFill().getFgColor()); >+ } >+ return color; > } >- >- public Enum getPatternType() { >- return getPatternFill().getPatternType(); >- } > > /** > * @return the index of the just added fill >@@ -101,9 +104,16 @@ > > public void setFillForegroundRgbColor(XSSFColor color) { > _fill.getPatternFill().setFgColor(color.getCTColor()); >+ } >+ >+ public FillPatternType getPatternType() { >+ STPatternType.Enum pType = getPatternFill().getPatternType(); >+ if(pType == null) pType = STPatternType.NONE; >+ return FillPatternType.values()[pType.intValue() - 1]; > } >+ >+ public void setPatternType(FillPatternType type) { >+ getPatternFill().setPatternType((STPatternType.Enum.forInt(type.ordinal() + 1))); >+ } > >- public void setPatternType(Enum patternType) { >- getPatternFill().setPatternType(patternType); >- } > } >Index: src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellBorder.java >=================================================================== >--- src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellBorder.java (revision 700785) >+++ src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellBorder.java (working copy) >@@ -19,6 +19,7 @@ > > import java.util.LinkedList; > >+import org.apache.poi.xssf.usermodel.BorderStyle; > import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder; > import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr; > import org.openxmlformats.schemas.spreadsheetml.x2006.main.STBorderStyle; >@@ -53,14 +54,6 @@ > return borders.size() - 1; > } > >- public STBorderStyle.Enum getBorderStyle(BorderSide side) { >- return getBorder(side).getStyle(); >- } >- >- public void setBorderStyle(BorderSide side, STBorderStyle.Enum style) { >- getBorder(side).setStyle(style); >- } >- > public XSSFColor getBorderColor(BorderSide side) { > CTBorderPr borderPr = getBorder(side); > if (!borderPr.isSetColor()) { >@@ -69,10 +62,27 @@ > return new XSSFColor(getBorder(side).getColor()); > } > >+ public BorderStyle getBorderStyle(BorderSide side) { >+ STBorderStyle.Enum border = getBorder(side).getStyle(); >+ if(border == null) border = STBorderStyle.NONE; >+ return BorderStyle.values()[border.intValue() - 1]; >+ } >+ >+ public String getBorderStyleAsString(BorderSide side) { >+ STBorderStyle.Enum border = getBorder(side).getStyle(); >+ if(border == null) border = STBorderStyle.NONE; >+ return border.toString(); >+ } >+ >+ > public void setBorderColor(BorderSide side, XSSFColor color) { > getBorder(side).setColor(color.getCTColor()); > } >- >+ >+ public void setBorderStyle(BorderSide side,BorderStyle style) { >+ getBorder(side).setStyle((STBorderStyle.Enum.forInt(style.ordinal() + 1))); >+ } >+ > private CTBorderPr getBorder(BorderSide side) { > switch (side) { > case TOP: { >@@ -94,4 +104,5 @@ > default: throw new IllegalArgumentException("No suitable side specified for the border"); > } > } >+ > } >\ No newline at end of file >Index: src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java >=================================================================== >--- src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java (revision 700785) >+++ src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java (working copy) >@@ -30,9 +30,15 @@ > import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellAlignment; > import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellProtection; > import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf; >-import org.openxmlformats.schemas.spreadsheetml.x2006.main.STBorderStyle; >-import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPatternType; > >+/** >+ * >+ * High level representation of the style of a cell in a sheet of a workbook. >+ * >+ * @see org.apache.poi.xssf.usermodel.XSSFWorkbook#createCellStyle() >+ * @see org.apache.poi.xssf.usermodel.XSSFWorkbook#getCellStyleAt(short) >+ * @see org.apache.poi.xssf.usermodel.XSSFCell#setCellStyle(XSSFCellStyle) >+ */ > > public class XSSFCellStyle implements CellStyle { > >@@ -66,6 +72,7 @@ > public CTXf getCoreXf() { > return cellXf; > } >+ > /** > * Used so that StylesSource can figure out our location > */ >@@ -117,314 +124,702 @@ > } > throw new IllegalArgumentException("Can only clone from one XSSFCellStyle to another, not between HSSFCellStyle and XSSFCellStyle"); > } >+ > public void cloneStyleFrom(XSSFCellStyle source) { > throw new IllegalStateException("TODO"); > } > >+ /** >+ * get the type of horizontal alignment for the cell >+ * @see #ALIGN_GENERAL >+ * @see #ALIGN_LEFT >+ * @see #ALIGN_CENTER >+ * @see #ALIGN_RIGHT >+ * @see #ALIGN_FILL >+ * @see #ALIGN_JUSTIFY >+ * @see #ALIGN_CENTER_SELECTION >+ * @return short - the type of alignment >+ */ > public short getAlignment() { > return (short)(getAlignmentEnum().ordinal()); > } > >+ /** >+ * get the type of horizontal alignment for the cell >+ * @return HorizontalAlignment - the type of alignment >+ */ > public HorizontalAlignment getAlignmentEnum() { > return getCellAlignment().getHorizontal(); > } > >+ /** >+ * get the type of border to use for the bottom border of the cell >+ * @return short - border type >+ * @see #BORDER_NONE >+ * @see #BORDER_THIN >+ * @see #BORDER_MEDIUM >+ * @see #BORDER_DASHED >+ * @see #BORDER_DOTTED >+ * @see #BORDER_THICK >+ * @see #BORDER_DOUBLE >+ * @see #BORDER_HAIR >+ * @see #BORDER_MEDIUM_DASHED >+ * @see #BORDER_DASH_DOT >+ * @see #BORDER_MEDIUM_DASH_DOT >+ * @see #BORDER_DASH_DOT_DOT >+ * @see #BORDER_MEDIUM_DASH_DOT_DOT >+ * @see #BORDER_SLANTED_DASH_DOT >+ */ > public short getBorderBottom() { >- return getBorderStyleAsShort(BorderSide.BOTTOM); >+ return (short) (getBorderStyleEnum(BorderSide.BOTTOM).ordinal()); > } > >+ /** >+ * get the type of border to use for the bottom border of the cell as String >+ * @return String - border type as string >+ */ > public String getBorderBottomAsString() { > return getBorderStyleAsString(BorderSide.BOTTOM); > } > >+ /** >+ * get the type of border to use for the bottom border of the cell >+ * @return BoerderStyle - border type as string >+ */ >+ public BorderStyle getBorderBottomEnum() { >+ return getBorderStyleEnum(BorderSide.BOTTOM); >+ } >+ >+ /** >+ * get the type of border to use for the left border of the cell >+ * @return short - border type >+ * @see #BORDER_NONE >+ * @see #BORDER_THIN >+ * @see #BORDER_MEDIUM >+ * @see #BORDER_DASHED >+ * @see #BORDER_DOTTED >+ * @see #BORDER_THICK >+ * @see #BORDER_DOUBLE >+ * @see #BORDER_HAIR >+ * @see #BORDER_MEDIUM_DASHED >+ * @see #BORDER_DASH_DOT >+ * @see #BORDER_MEDIUM_DASH_DOT >+ * @see #BORDER_DASH_DOT_DOT >+ * @see #BORDER_MEDIUM_DASH_DOT_DOT >+ * @see #BORDER_SLANTED_DASH_DOT >+ */ > public short getBorderLeft() { >- return getBorderStyleAsShort(BorderSide.LEFT); >+ return (short) (getBorderStyleEnum(BorderSide.LEFT).ordinal()); > } >- >+ >+ /** >+ * get the type of border to use for the left border of the cell as String >+ * @return String - border type as string >+ */ > public String getBorderLeftAsString() { > return getBorderStyleAsString(BorderSide.LEFT); > } > >+ /** >+ * get the type of border to use for the left border of the cell >+ * @return BoerderStyle - border type as string >+ */ >+ public BorderStyle getBorderLeftEnum() { >+ return getBorderStyleEnum(BorderSide.LEFT); >+ } >+ >+ /** >+ * get the type of border to use for the right border of the cell >+ * @return short - border type >+ * @see #BORDER_NONE >+ * @see #BORDER_THIN >+ * @see #BORDER_MEDIUM >+ * @see #BORDER_DASHED >+ * @see #BORDER_DOTTED >+ * @see #BORDER_THICK >+ * @see #BORDER_DOUBLE >+ * @see #BORDER_HAIR >+ * @see #BORDER_MEDIUM_DASHED >+ * @see #BORDER_DASH_DOT >+ * @see #BORDER_MEDIUM_DASH_DOT >+ * @see #BORDER_DASH_DOT_DOT >+ * @see #BORDER_MEDIUM_DASH_DOT_DOT >+ * @see #BORDER_SLANTED_DASH_DOT >+ */ > public short getBorderRight() { >- return getBorderStyleAsShort(BorderSide.RIGHT); >+ return (short) (getBorderStyleEnum(BorderSide.RIGHT).ordinal()); > } > >+ /** >+ * get the type of border to use for the right border of the cell as String >+ * @return String - border type as string >+ */ > public String getBorderRightAsString() { > return getBorderStyleAsString(BorderSide.RIGHT); > } > >+ /** >+ * get the type of border to use for the right border of the cell >+ * @return BoerderStyle - border type as string >+ */ >+ public BorderStyle getBorderRightEnum() { >+ return getBorderStyleEnum(BorderSide.RIGHT); >+ } >+ >+ /** >+ * get the type of border to use for the top border of the cell >+ * @return short - border type >+ * @see #BORDER_NONE >+ * @see #BORDER_THIN >+ * @see #BORDER_MEDIUM >+ * @see #BORDER_DASHED >+ * @see #BORDER_DOTTED >+ * @see #BORDER_THICK >+ * @see #BORDER_DOUBLE >+ * @see #BORDER_HAIR >+ * @see #BORDER_MEDIUM_DASHED >+ * @see #BORDER_DASH_DOT >+ * @see #BORDER_MEDIUM_DASH_DOT >+ * @see #BORDER_DASH_DOT_DOT >+ * @see #BORDER_MEDIUM_DASH_DOT_DOT >+ * @see #BORDER_SLANTED_DASH_DOT >+ */ > public short getBorderTop() { >- return getBorderStyleAsShort(BorderSide.TOP); >+ return (short) (getBorderStyleEnum(BorderSide.TOP).ordinal()); > } > >+ /** >+ * get the type of border to use for the top border of the cell as String >+ * @return String - border type as string >+ */ > public String getBorderTopAsString() { > return getBorderStyleAsString(BorderSide.TOP); > } >+ >+ /** >+ * get the type of border to use for the top border of the cell >+ * @return BoerderStyle - border type as string >+ */ >+ public BorderStyle getBorderTopEnum() { >+ return getBorderStyleEnum(BorderSide.TOP); >+ } > >+ /** >+ * set the color to use for the bottom border >+ * Color is optional. When missing, IndexedColors.AUTOMATIC is implied. >+ * @return short - color The index of the color definition >+ * @see IndexedColors >+ */ > public short getBottomBorderColor() { > return getBorderColorIndexed(BorderSide.BOTTOM); > } > >+ /** >+ * get the index of the number format (numFmt) record used by this cell format. >+ */ > public short getDataFormat() { > return (short)cellXf.getNumFmtId(); > } >+ >+ /** >+ * Get the contents of the format string, by looking up >+ * the StylesSource >+ * >+ * @return the number format string >+ */ > public String getDataFormatString() { > return stylesSource.getNumberFormatAt(getDataFormat()); > } > >+ /** >+ * Get the background fill color. >+ * Note - many cells are actually filled with a foreground >+ * fill, not a background fill - see {@link #getFillForegroundColor()} >+ * @see IndexedColors >+ * @return short - fill color >+ */ > public short getFillBackgroundColor() { > return (short) getCellFill().getFillBackgroundColor().getIndexed(); > } >- >+ >+ /** >+ * Get the background fill color. >+ * Note - many cells are actually filled with a foreground >+ * fill, not a background fill - see {@link #getFillForegroundColor()} >+ * @see org.apache.poi.hssf.usermodel.XSSFColor#getRgb() >+ * @return XSSFColor - fill color >+ */ > public XSSFColor getFillBackgroundRgbColor() { > return getCellFill().getFillBackgroundColor(); > } >- >+ >+ /** >+ * Get the foreground fill color. >+ * Many cells are filled with this, instead of a >+ * background color ({@link #getFillBackgroundColor()}) >+ * @see IndexedColors >+ * @return short - fill color >+ */ > public short getFillForegroundColor() { > return (short) getCellFill().getFillForegroundColor().getIndexed(); > } >- >+ >+ /** >+ * Get the foreground fill color. >+ * Many cells are filled with this, instead of a >+ * background color ({@link #getFillBackgroundColor()}) >+ * @return XSSFColor - fill color >+ */ > public XSSFColor getFillForegroundRgbColor() { > return getCellFill().getFillForegroundColor(); > } > >+ /** >+ * get the fill pattern >+ * @return short - fill pattern >+ * >+ * @see #NO_FILL >+ * @see #SOLID_FOREGROUND >+ * @see #FINE_DOTS >+ * @see #ALT_BARS >+ * @see #SPARSE_DOTS >+ * @see #THICK_HORZ_BANDS >+ * @see #THICK_VERT_BANDS >+ * @see #THICK_BACKWARD_DIAG >+ * @see #THICK_FORWARD_DIAG >+ * @see #BIG_SPOTS >+ * @see #BRICKS >+ * @see #THIN_HORZ_BANDS >+ * @see #THIN_VERT_BANDS >+ * @see #THIN_BACKWARD_DIAG >+ * @see #THIN_FORWARD_DIAG >+ * @see #SQUARES >+ * @see #DIAMONDS >+ */ > public short getFillPattern() { >- int fp= getCellFill().getPatternType().intValue(); >- switch (fp) { >- case STPatternType.INT_NONE: >- return CellStyle.NO_FILL; >- case STPatternType.INT_SOLID: >- return CellStyle.SOLID_FOREGROUND; >- case STPatternType.INT_LIGHT_GRAY: >- return CellStyle.FINE_DOTS; >- case STPatternType.INT_DARK_GRID: >- return CellStyle.ALT_BARS; >- case STPatternType.INT_DARK_GRAY: >- return CellStyle.SPARSE_DOTS; >- case STPatternType.INT_DARK_HORIZONTAL: >- return CellStyle.THICK_HORZ_BANDS; >- case STPatternType.INT_DARK_VERTICAL: >- return CellStyle.THICK_VERT_BANDS; >- case STPatternType.INT_DARK_UP: >- return CellStyle.THICK_BACKWARD_DIAG; >- case STPatternType.INT_DARK_DOWN: >- return CellStyle.THICK_FORWARD_DIAG; >- case STPatternType.INT_GRAY_0625: >- return CellStyle.BIG_SPOTS; >- case STPatternType.INT_DARK_TRELLIS: >- return CellStyle.BRICKS; >- case STPatternType.INT_LIGHT_HORIZONTAL: >- return CellStyle.THIN_HORZ_BANDS; >- case STPatternType.INT_LIGHT_VERTICAL: >- return CellStyle.THIN_VERT_BANDS; >- case STPatternType.INT_LIGHT_UP: >- return CellStyle.THIN_BACKWARD_DIAG; >- case STPatternType.INT_LIGHT_DOWN: >- return CellStyle.THIN_FORWARD_DIAG; >- case STPatternType.INT_LIGHT_GRID: >- return CellStyle.SQUARES; >- case STPatternType.INT_LIGHT_TRELLIS: >- return CellStyle.DIAMONDS; >- case STPatternType.INT_GRAY_125: >- return CellStyle.LESS_DOTS; >-/* >- case STPatternType.INT_GRAY_0625: >- return CellStyle.LEAST_DOTS; >-*/ >- default: >- return CellStyle.NO_FILL; >- } >- // return (short) getCellFill().getPatternType().intValue(); >+ return (short) getCellFill().getPatternType().ordinal(); > } > >+ /** >+ * get the fill pattern >+ * @return FillPatternType - fill pattern >+ */ >+ public FillPatternType getFillPatternEnum() { >+ return getCellFill().getPatternType(); >+ } >+ >+ /** >+ * gets the font for this style >+ * @param parentWorkbook The XSSFWorkbook that this style belongs to >+ * @return Font - font >+ * @see org.apache.poi.xssf.usermodel.XSSFCellStyle#getFontIndex() >+ * @see org.apache.poi.xssf.usermodel.XSSFWorkbook#getFontAt(short) >+ */ > public Font getFont(Workbook parentWorkbook) { > return getFont(); > } > >+ /** >+ * gets the font for this style >+ * @return Font - font >+ */ > public Font getFont() { > if (font == null) { > font = (XSSFFont) ((StylesTable)stylesSource).getFontAt(getFontId()); > } > return font; > } >- >+ >+ /** >+ * gets the index of the font for this style >+ * @return short - font index >+ * @see org.apache.poi.hssf.usermodel.XSSFWorkbook#getFontAt(short) >+ */ > public short getFontIndex() { > return (short) getFontId(); > } > >+ /** >+ * get whether the cell's using this style are to be hidden >+ * @return boolean - whether the cell using this style is hidden >+ */ > public boolean getHidden() { > return getCellProtection().getHidden(); > } > >+ /** >+ * get the number of spaces to indent the text in the cell >+ * @return indent - number of spaces >+ */ > public short getIndention() { > return (short) getCellAlignment().getIndent(); > } > >+ /** >+ * get the index within the StylesTable (sequence within the collection of CTXf elements) >+ * @return unique index number of the underlying record this style represents >+ */ > public short getIndex() { > return (short) this.cellXfId; > } >- >+ >+ /** >+ * set the color to use for the left border >+ * Color is optional. When missing, IndexedColors.AUTOMATIC is implied. >+ * @return short - color The index of the color definition >+ * @see IndexedColors >+ */ > public short getLeftBorderColor() { > return getBorderColorIndexed(BorderSide.LEFT); > } >- >+ >+ /** >+ * get whether the cell's using this style are locked >+ * @return boolean - whether the cell using this style are locked >+ */ > public boolean getLocked() { > return getCellProtection().getLocked(); > } > >+ /** >+ * set the color to use for the right border >+ * Color is optional. When missing, IndexedColors.AUTOMATIC is implied. >+ * @return short - color The index of the color definition >+ * @see IndexedColors >+ */ > public short getRightBorderColor() { > return getBorderColorIndexed(BorderSide.RIGHT); > } >- >+ >+ /** >+ * get the degree of rotation for the text in the cell >+ * @return rotation degrees (between -90 and 90 degrees) >+ */ > public short getRotation() { > return (short) getCellAlignment().getTextRotation(); > } > >+ /** >+ * set the color to use for the top border >+ * Color is optional. When missing, IndexedColors.AUTOMATIC is implied. >+ * @return short - color The index of the color definition >+ * @see IndexedColors >+ */ > public short getTopBorderColor() { > return getBorderColorIndexed(BorderSide.TOP); > } > >+ /** >+ * get the type of vertical alignment for the cell >+ * @return align the type of alignment >+ * @see #VERTICAL_TOP >+ * @see #VERTICAL_CENTER >+ * @see #VERTICAL_BOTTOM >+ * @see #VERTICAL_JUSTIFY >+ */ > public short getVerticalAlignment() { > return (short) (getVerticalAlignmentEnum().ordinal()); > } > >+ /** >+ * get the type of vertical alignment for the cell >+ * @return VerticalAlignment - align the type of alignment >+ * @see VerticalAlignment >+ */ > public VerticalAlignment getVerticalAlignmentEnum() { > return getCellAlignment().getVertical(); > } > >+ /** >+ * get whether the text should be wrapped >+ * @param boolean - wrap text or not >+ */ > public boolean getWrapText() { > return getCellAlignment().getWrapText(); > } > >+ /** >+ * set the type of horizontal alignment for the cell >+ * @param short align - the type of alignment >+ * @see #ALIGN_GENERAL >+ * @see #ALIGN_LEFT >+ * @see #ALIGN_CENTER >+ * @see #ALIGN_RIGHT >+ * @see #ALIGN_FILL >+ * @see #ALIGN_JUSTIFY >+ * @see #ALIGN_CENTER_SELECTION >+ */ > public void setAlignment(short align) { > getCellAlignment().setHorizontal(HorizontalAlignment.values()[align]); > } > >+ /** >+ * set the type of horizontal alignment for the cell >+ * @param HorizontalAlignment.Enum - the type of alignment >+ * @see HorizontalAlignment >+ */ > public void setAlignment(HorizontalAlignment align) { > setAlignment((short)align.ordinal()); > } >- >+ >+ /** >+ * set the type of border to use for the bottom border of the cell >+ * @param border type >+ * @see #BORDER_NONE >+ * @see #BORDER_THIN >+ * @see #BORDER_MEDIUM >+ * @see #BORDER_DASHED >+ * @see #BORDER_DOTTED >+ * @see #BORDER_THICK >+ * @see #BORDER_DOUBLE >+ * @see #BORDER_HAIR >+ * @see #BORDER_MEDIUM_DASHED >+ * @see #BORDER_DASH_DOT >+ * @see #BORDER_MEDIUM_DASH_DOT >+ * @see #BORDER_DASH_DOT_DOT >+ * @see #BORDER_MEDIUM_DASH_DOT_DOT >+ * @see #BORDER_SLANTED_DASH_DOT >+ */ > public void setBorderBottom(short border) { >- setBorderBottomEnum(STBorderStyle.Enum.forInt(border)); >+ getCellBorder().setBorderStyle(BorderSide.BOTTOM,BorderStyle.values()[border]); > } > >- public void setBorderBottomEnum(STBorderStyle.Enum style) { >- getCellBorder().setBorderStyle(BorderSide.BOTTOM, style); >+ /** >+ * set the type of border to use for the bottom border of the cell >+ * @param BorderStyle - border type >+ */ >+ public void setBorderBottomEnum(BorderStyle border) { >+ setBorderBottom((short)border.ordinal()); > } >- >+ >+ /** >+ * set the type of border to use for the left border of the cell >+ * @param border type >+ * @see #BORDER_NONE >+ * @see #BORDER_THIN >+ * @see #BORDER_MEDIUM >+ * @see #BORDER_DASHED >+ * @see #BORDER_DOTTED >+ * @see #BORDER_THICK >+ * @see #BORDER_DOUBLE >+ * @see #BORDER_HAIR >+ * @see #BORDER_MEDIUM_DASHED >+ * @see #BORDER_DASH_DOT >+ * @see #BORDER_MEDIUM_DASH_DOT >+ * @see #BORDER_DASH_DOT_DOT >+ * @see #BORDER_MEDIUM_DASH_DOT_DOT >+ * @see #BORDER_SLANTED_DASH_DOT >+ */ > public void setBorderLeft(short border) { >- setBorderLeftEnum(STBorderStyle.Enum.forInt(border)); >+ getCellBorder().setBorderStyle(BorderSide.LEFT,BorderStyle.values()[border]); > } > >- public void setBorderLeftEnum(STBorderStyle.Enum style) { >- getCellBorder().setBorderStyle(BorderSide.LEFT, style); >+ /** >+ * set the type of border to use for the left border of the cell >+ * @param border type >+ */ >+ public void setBorderLeftEnum(BorderStyle border) { >+ setBorderLeft((short)border.ordinal()); > } >- >+ >+ /** >+ * set the type of border to use for the right border of the cell >+ * @param border type >+ * @see #BORDER_NONE >+ * @see #BORDER_THIN >+ * @see #BORDER_MEDIUM >+ * @see #BORDER_DASHED >+ * @see #BORDER_DOTTED >+ * @see #BORDER_THICK >+ * @see #BORDER_DOUBLE >+ * @see #BORDER_HAIR >+ * @see #BORDER_MEDIUM_DASHED >+ * @see #BORDER_DASH_DOT >+ * @see #BORDER_MEDIUM_DASH_DOT >+ * @see #BORDER_DASH_DOT_DOT >+ * @see #BORDER_MEDIUM_DASH_DOT_DOT >+ * @see #BORDER_SLANTED_DASH_DOT >+ */ > public void setBorderRight(short border) { >- setBorderRightEnum(STBorderStyle.Enum.forInt(border)); >+ getCellBorder().setBorderStyle(BorderSide.RIGHT,BorderStyle.values()[border]); > } > >- public void setBorderRightEnum(STBorderStyle.Enum style) { >- getCellBorder().setBorderStyle(BorderSide.RIGHT, style); >+ /** >+ * set the type of border to use for the right border of the cell >+ * @param border type >+ */ >+ public void setBorderRightEnum(BorderStyle border) { >+ setBorderRight((short)border.ordinal()); > } >- >+ >+ /** >+ * set the type of border to use for the top border of the cell >+ * @param border type >+ * @see #BORDER_NONE >+ * @see #BORDER_THIN >+ * @see #BORDER_MEDIUM >+ * @see #BORDER_DASHED >+ * @see #BORDER_DOTTED >+ * @see #BORDER_THICK >+ * @see #BORDER_DOUBLE >+ * @see #BORDER_HAIR >+ * @see #BORDER_MEDIUM_DASHED >+ * @see #BORDER_DASH_DOT >+ * @see #BORDER_MEDIUM_DASH_DOT >+ * @see #BORDER_DASH_DOT_DOT >+ * @see #BORDER_MEDIUM_DASH_DOT_DOT >+ * @see #BORDER_SLANTED_DASH_DOT >+ */ > public void setBorderTop(short border) { >- setBorderTopEnum(STBorderStyle.Enum.forInt(border)); >+ getCellBorder().setBorderStyle(BorderSide.TOP,BorderStyle.values()[border]); > } >- >- public void setBorderTopEnum(STBorderStyle.Enum style) { >- getCellBorder().setBorderStyle(BorderSide.TOP, style); >+ >+ /** >+ * set the type of border to use for the top border of the cell >+ * @param border type >+ */ >+ public void setBorderTopEnum(BorderStyle border) { >+ setBorderTop((short)border.ordinal()); > } >- >+ >+ /** >+ * set the color to use for the bottom border >+ * @param color The index of the color definition >+ * @see IndexedColors >+ */ > public void setBottomBorderColor(short color) { > setBorderColorIndexed(BorderSide.BOTTOM, color); > } > >+ /** >+ * set the index of a data format >+ */ > public void setDataFormat(short fmt) { > cellXf.setNumFmtId((long)fmt); > } > >+ /** >+ * set the background fill color represented as rgb values. >+ * <p> >+ * For example: >+ * <pre> >+ * cs.setFillPattern(XSSFCellStyle.FINE_DOTS ); >+ * cs.setFillBackgroundRgbColor(IndexedColors.RED.getIndex()); >+ * </pre> >+ * optionally a Foreground and background fill can be applied: >+ * <i>Note: Ensure Foreground color is set prior to background</i> >+ * <pre> >+ * cs.setFillPattern(XSSFCellStyle.FINE_DOTS ); >+ * cs.setFillForegroundColor(IndexedColors.BLUE.getIndex()); >+ * cs.setFillBackgroundColor(IndexedColors.RED.getIndex()); >+ * </pre> >+ * or, for the special case of SOLID_FILL: >+ * <pre> >+ * cs.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND ); >+ * cs.setFillForegroundColor(IndexedColors.RED.getIndex()); >+ * </pre> >+ * It is necessary to set the fill style in order >+ * for the color to be shown in the cell. >+ * >+ * @param XSSFColor - bg color >+ */ > public void setFillBackgroundRgbColor(XSSFColor color) { > cellFill=getCellFill(); > cellFill.setFillBackgroundRgbColor(color); > } >- >+ >+ /** >+ * set the background fill color. >+ * <p> >+ * For example: >+ * <pre> >+ * cs.setFillPattern(XSSFCellStyle.FINE_DOTS ); >+ * cs.setFillBackgroundRgbColor(IndexedColors.RED.getIndex()); >+ * </pre> >+ * optionally a Foreground and background fill can be applied: >+ * <i>Note: Ensure Foreground color is set prior to background</i> >+ * <pre> >+ * cs.setFillPattern(XSSFCellStyle.FINE_DOTS ); >+ * cs.setFillForegroundColor(IndexedColors.BLUE.getIndex()); >+ * cs.setFillBackgroundColor(IndexedColors.RED.getIndex()); >+ * </pre> >+ * or, for the special case of SOLID_FILL: >+ * <pre> >+ * cs.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND ); >+ * cs.setFillForegroundColor(IndexedColors.RED.getIndex()); >+ * </pre> >+ * It is necessary to set the fill style in order >+ * for the color to be shown in the cell. >+ * >+ * @param short - bg color >+ */ > public void setFillBackgroundColor(short bg) { > getCellFill().setFillBackgroundColor(bg); > } >- >+ >+ /** >+ * set the foreground fill color represented as rgb values. >+ * <i>Note: Ensure Foreground color is set prior to background color.</i> >+ * @param XSSFColor - bg color >+ */ > public void setFillForegroundRgbColor(XSSFColor color) { > getCellFill().setFillForegroundRgbColor(color); > } > >+ /** >+ * set the foreground fill color >+ * <i>Note: Ensure Foreground color is set prior to background color.</i> >+ * @param short - bg color >+ */ > public void setFillForegroundColor(short bg) { > getCellFill().setFillForegroundColor(bg); > } > >+ /** >+ * This element is used to specify cell fill information for pattern and solid color cell fills. For solid cell fills (no pattern), >+ * fgColor is used. For cell fills with patterns specified, then the cell fill color is specified by the bgColor element. >+ * >+ * @see #NO_FILL >+ * @see #SOLID_FOREGROUND >+ * @see #FINE_DOTS >+ * @see #ALT_BARS >+ * @see #SPARSE_DOTS >+ * @see #THICK_HORZ_BANDS >+ * @see #THICK_VERT_BANDS >+ * @see #THICK_BACKWARD_DIAG >+ * @see #THICK_FORWARD_DIAG >+ * @see #BIG_SPOTS >+ * @see #BRICKS >+ * @see #THIN_HORZ_BANDS >+ * @see #THIN_VERT_BANDS >+ * @see #THIN_BACKWARD_DIAG >+ * @see #THIN_FORWARD_DIAG >+ * @see #SQUARES >+ * @see #DIAMONDS >+ * >+ * @param fp fill pattern (set to 1 to fill w/foreground color) >+ */ > public void setFillPattern(short fp) { >- cellFill=getCellFill(); >- switch (fp) { >- case CellStyle.NO_FILL: >- cellFill.setPatternType(STPatternType.NONE); >- break; >- case CellStyle.SOLID_FOREGROUND: >- cellFill.setPatternType(STPatternType.SOLID); >- break; >- case CellStyle.FINE_DOTS: >- cellFill.setPatternType(STPatternType.LIGHT_GRAY); >- break; >- case CellStyle.ALT_BARS: >- cellFill.setPatternType(STPatternType.DARK_GRID); >- break; >- case CellStyle.SPARSE_DOTS: >- cellFill.setPatternType(STPatternType.DARK_GRAY); >- break; >- case CellStyle.THICK_HORZ_BANDS: >- cellFill.setPatternType(STPatternType.DARK_HORIZONTAL); >- break; >- case CellStyle.THICK_VERT_BANDS: >- cellFill.setPatternType(STPatternType.DARK_VERTICAL); >- break; >- case CellStyle.THICK_BACKWARD_DIAG: >- cellFill.setPatternType(STPatternType.DARK_UP); >- break; >- case CellStyle.THICK_FORWARD_DIAG: >- cellFill.setPatternType(STPatternType.DARK_DOWN); >- break; >- case CellStyle.BIG_SPOTS: >- cellFill.setPatternType(STPatternType.GRAY_0625); >- break; >- case CellStyle.BRICKS: >- cellFill.setPatternType(STPatternType.DARK_TRELLIS); >- break; >- case CellStyle.THIN_HORZ_BANDS: >- cellFill.setPatternType(STPatternType.LIGHT_HORIZONTAL); >- break; >- case CellStyle.THIN_VERT_BANDS: >- cellFill.setPatternType(STPatternType.LIGHT_VERTICAL); >- break; >- case CellStyle.THIN_BACKWARD_DIAG: >- cellFill.setPatternType(STPatternType.LIGHT_UP); >- break; >- case CellStyle.THIN_FORWARD_DIAG: >- cellFill.setPatternType(STPatternType.LIGHT_DOWN); >- break; >- case CellStyle.SQUARES: >- cellFill.setPatternType(STPatternType.LIGHT_GRID); >- break; >- case CellStyle.DIAMONDS: >- cellFill.setPatternType(STPatternType.LIGHT_TRELLIS); >- break; >- case CellStyle.LESS_DOTS: >- cellFill.setPatternType(STPatternType.GRAY_125); >- break; >- case CellStyle.LEAST_DOTS: >- cellFill.setPatternType(STPatternType.GRAY_0625); >- break; >- default: throw new RuntimeException("Fill type ["+fp+"] not accepted"); >- } >+ getCellFill().setPatternType(FillPatternType.values()[fp]); > } > >+ /** >+ * This element is used to specify cell fill information for pattern and solid color cell fills. For solid cell fills (no pattern), >+ * fgColor is used. For cell fills with patterns specified, then the cell fill color is specified by the bgColor element. >+ * >+ * @param FillPatternType - fill pattern >+ * >+ */ >+ public void setFillPattern(FillPatternType pType) { >+ setFillPattern((short)pType.ordinal()); >+ } >+ >+ /** >+ * set the font for this style >+ * @param font a font object created or retreived from the XSSFWorkbook object >+ * @see org.apache.poi.hssf.usermodel.XSSFWorkbook#createFont() >+ * @see org.apache.poi.hssf.usermodel.XSSFWorkbook#getFontAt(short) >+ */ > public void setFont(Font font) { > if(font!=null){ > long index=this.stylesSource.putFont(font); >@@ -433,49 +828,91 @@ > this.cellXf.setApplyFont(true); > } > >+ /** >+ * set the cell's using this style to be hidden >+ * @param boolean - whether the cell using this style should be hidden >+ */ > public void setHidden(boolean hidden) { > getCellProtection().setHidden(hidden); > } > >+ /** >+ * set the number of spaces to indent the text in the cell >+ * @param indent - number of spaces >+ */ > public void setIndention(short indent) { > getCellAlignment().setIndent(indent); > } > >+ /** >+ * set the color to use for the left border >+ * @param color The index of the color definition >+ * @see IndexedColors >+ */ > public void setLeftBorderColor(short color) { > setBorderColorIndexed(BorderSide.LEFT, color); > } > >- >- private void setBorderColorIndexed(BorderSide side, XSSFColor color) { >- this.cellBorder.setBorderColor(side, color); >- } >- >- >+ /** >+ * set the cell's using this style to be locked >+ * @param boolean - whether the cell using this style should be locked >+ */ > public void setLocked(boolean locked) { >- getCellProtection().setLocked(locked); >+ getCellProtection().setLocked(locked); > } > >- >+ /** >+ * set the color to use for the right border >+ * @param color The index of the color definition >+ * @see IndexedColors >+ */ > public void setRightBorderColor(short color) { > setBorderColorIndexed(BorderSide.RIGHT, color); > } > >+ /** >+ * set the degree of rotation for the text in the cell >+ * @param short - rotation degrees (between -90 and 90 degrees) >+ */ > public void setRotation(short rotation) { > getCellAlignment().setTextRotation(rotation); > } > >+ >+ /** >+ * set the color to use for the top border >+ * @param color The index of the color definition >+ * @see IndexedColors >+ */ > public void setTopBorderColor(short color) { > setBorderColorIndexed(BorderSide.TOP, color); > } >- >+ >+ /** >+ * set the type of vertical alignment for the cell >+ * @param short - align the type of alignment >+ * @see #VERTICAL_TOP >+ * @see #VERTICAL_CENTER >+ * @see #VERTICAL_BOTTOM >+ * @see #VERTICAL_JUSTIFY >+ * @see VerticalAlignment >+ */ > public void setVerticalAlignment(short align) { > getCellAlignment().setVertical(VerticalAlignment.values()[align]); > } >- >+ >+ /** >+ * set the type of vertical alignment for the cell >+ * @param VerticalAlignment - align the type of alignment >+ */ > public void setVerticalAlignment(VerticalAlignment align) { > getCellAlignment().setVertical(align); > } > >+ /** >+ * set whether the text should be wrapped >+ * @param boolean - wrap text or not >+ */ > public void setWrapText(boolean wrapped) { > getCellAlignment().setWrapText(wrapped); > } >@@ -483,11 +920,20 @@ > public XSSFColor getBorderColor(BorderSide side) { > return getCellBorder().getBorderColor(side); > } >- >+ >+ /** >+ * set the color to use for the selected border >+ * @param BorderSide - side where to apply the color definition >+ * @param XSSFColor - color rgb value of the color definition >+ */ > public void setBorderColor(BorderSide side, XSSFColor color) { > getCellBorder().setBorderColor(side, color); > } > >+ /** >+ * get the cellBorder object border to use for manage borders >+ * @return XSSFCellBorder - cell border >+ */ > private XSSFCellBorder getCellBorder() { > if (cellBorder == null) { > // TODO make a common Cell Border object >@@ -505,14 +951,22 @@ > return cellBorder; > } > >+ /** >+ * get the index of the border to use for this cell style. >+ * return -1 if no border is defined. >+ * @return int - index of cell border >+ */ > private int getBorderId() { > if (cellXf.isSetBorderId() && cellXf.getBorderId()>0) { > return (int) cellXf.getBorderId(); > } > return -1; >- // return (int) cellStyleXf.getBorderId(); > } > >+ /** >+ * get the cellFill object to use for manage fill >+ * @return XSSFCellFill - cell fill >+ */ > private XSSFCellFill getCellFill() { > if (cellFill == null) { > int fillId=getFillId(); >@@ -529,14 +983,22 @@ > return cellFill; > } > >+ /** >+ * get the index of the fill to use for this cell style. >+ * return -1 if no fill is defined. >+ * @return int - index of cell fill >+ */ > private int getFillId() { > if (cellXf.isSetFillId() && cellXf.getFillId()>0) { > return (int) cellXf.getFillId(); > } >- //return (int) cellStyleXf.getFillId(); > return -1; > } > >+ /** >+ * get the index of the font to use for this cell style. >+ * @return int - index of font >+ */ > private int getFontId() { > if (cellXf.isSetFontId()) { > return (int) cellXf.getFontId(); >@@ -544,6 +1006,10 @@ > return (int) cellStyleXf.getFontId(); > } > >+ /** >+ * get a cellProtection from the supplied XML definition >+ * @return CTCellProtection >+ */ > private CTCellProtection getCellProtection() { > if (cellXf.getProtection() == null) { > cellXf.addNewProtection(); >@@ -551,6 +1017,10 @@ > return cellXf.getProtection(); > } > >+ /** >+ * get the cellAlignment object to use for manage alignment >+ * @return XSSFCellAlignment - cell alignment >+ */ > public XSSFCellAlignment getCellAlignment() { > if (this.cellAlignment == null) { > this.cellAlignment = new XSSFCellAlignment(getCTCellAlignment()); >@@ -558,31 +1028,55 @@ > return this.cellAlignment; > } > >+ >+ /** >+ * Return the CTCellAlignment instance for alignment >+ * >+ * @return CTCellAlignment >+ */ > private CTCellAlignment getCTCellAlignment() { >- if (cellXf.getAlignment() == null) { >- cellXf.setAlignment(CTCellAlignment.Factory.newInstance()); >- } >- return cellXf.getAlignment(); >+ if (cellXf.getAlignment() == null) { >+ cellXf.setAlignment(CTCellAlignment.Factory.newInstance()); >+ } >+ return cellXf.getAlignment(); > } >- >+ >+ /** >+ * get the index of the color to use for the border side specified. >+ * @parameter BorderSie -side >+ * @return short - index of color >+ */ > private short getBorderColorIndexed(BorderSide side) { > return (short) getBorderColor(side).getIndexed(); > } > >+ /** >+ * set the index of the color to use for the border side specified. >+ * @parameter BorderSide -side >+ * @parameter int - color >+ * @see IndexedColors >+ */ > private void setBorderColorIndexed(BorderSide side, int color) { > getBorderColor(side).setIndexed(color); > } >- >- private short getBorderStyleAsShort(BorderSide side) { >- return (short) (getBorderStyle(side).intValue() - 1); >+ >+ /** >+ * get the BorderStyle enum for the border side specified. >+ * @parameter BorderSide -side >+ * @return BorderStyle - index of color >+ */ >+ private BorderStyle getBorderStyleEnum(BorderSide side) { >+ return getCellBorder().getBorderStyle(side); > } >- >+ >+ /** >+ * get the BorderStyle enum for the border side specified. >+ * @parameter BorderSie -side >+ * @return short - index of color >+ */ > private String getBorderStyleAsString(BorderSide side) { >- return getBorderStyle(side).toString(); >+ return getCellBorder().getBorderStyleAsString(side); > } >+ > >- private STBorderStyle.Enum getBorderStyle(BorderSide side) { >- return getCellBorder().getBorderStyle(side); >- } >- > } >Index: src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java >=================================================================== >--- src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java (revision 700785) >+++ src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java (working copy) >@@ -86,9 +86,10 @@ > public void testGetSetBorderBottom() { > ctBorderA.addNewBottom().setStyle(STBorderStyle.THIN); > assertEquals((short)1, cellStyle.getBorderBottom()); >- cellStyle.setBorderBottom((short) 2); >+ //cellStyle.setBorderBottom((short) 2); >+ cellStyle.setBorderBottom(XSSFCellStyle.BORDER_THIN); > assertEquals(STBorderStyle.THIN, ctBorderA.getBottom().getStyle()); >- cellStyle.setBorderBottomEnum(STBorderStyle.THICK); >+ cellStyle.setBorderBottomEnum(BorderStyle.THICK); > assertEquals(6, ctBorderA.getBottom().getStyle().intValue()); > } > >@@ -100,9 +101,9 @@ > public void testGetSetBorderRight() { > ctBorderA.addNewRight().setStyle(STBorderStyle.MEDIUM); > assertEquals((short)2, cellStyle.getBorderRight()); >- cellStyle.setBorderRight((short) 2); >+ cellStyle.setBorderRight(XSSFCellStyle.BORDER_THIN); > assertEquals(STBorderStyle.THIN, ctBorderA.getRight().getStyle()); >- cellStyle.setBorderRightEnum(STBorderStyle.THICK); >+ cellStyle.setBorderRightEnum(BorderStyle.THICK); > assertEquals(6, ctBorderA.getRight().getStyle().intValue()); > } > >@@ -114,9 +115,9 @@ > public void testGetSetBorderLeft() { > ctBorderA.addNewLeft().setStyle(STBorderStyle.DASHED); > assertEquals((short)3, cellStyle.getBorderLeft()); >- cellStyle.setBorderLeft((short) 2); >+ cellStyle.setBorderLeft(XSSFCellStyle.BORDER_THIN); > assertEquals(STBorderStyle.THIN, ctBorderA.getLeft().getStyle()); >- cellStyle.setBorderLeftEnum(STBorderStyle.THICK); >+ cellStyle.setBorderLeftEnum(BorderStyle.THICK); > assertEquals(6, ctBorderA.getLeft().getStyle().intValue()); > } > >@@ -128,9 +129,9 @@ > public void testGetSetBorderTop() { > ctBorderA.addNewTop().setStyle(STBorderStyle.HAIR); > assertEquals((short)7, cellStyle.getBorderTop()); >- cellStyle.setBorderTop((short) 2); >+ cellStyle.setBorderTop(XSSFCellStyle.BORDER_THIN); > assertEquals(STBorderStyle.THIN, ctBorderA.getTop().getStyle()); >- cellStyle.setBorderTopEnum(STBorderStyle.THICK); >+ cellStyle.setBorderTopEnum(BorderStyle.THICK); > assertEquals(6, ctBorderA.getTop().getStyle().intValue()); > } > >@@ -291,18 +292,17 @@ > } > > >- public void testGetFillPattern() { >- >- CTPatternFill ctPatternFill = ctFill.addNewPatternFill(); >- ctPatternFill.setPatternType(STPatternType.DARK_DOWN); >- XSSFCellFill cellFill=new XSSFCellFill(ctFill); >- long index=stylesTable.putFill(cellFill); >- cellStyle.getCoreXf().setFillId(index); >- >- assertEquals(CellStyle.THICK_FORWARD_DIAG, cellStyle.getFillPattern()); >- >- cellStyle.setFillPattern(CellStyle.BRICKS); >- assertEquals(STPatternType.INT_DARK_TRELLIS,ctPatternFill.getPatternType().intValue()); >+ public void testGetSetFillPattern() { >+ CTPatternFill ctPattern=ctFill.addNewPatternFill(); >+ ctPattern.setPatternType(STPatternType.DARK_HORIZONTAL); >+ XSSFCellFill cellFill=new XSSFCellFill(ctFill); >+ long index=stylesTable.putFill(cellFill); >+ cellStyle.getCoreXf().setFillId(index); >+ assertEquals(CellStyle.THICK_HORZ_BANDS, cellStyle.getFillPattern()); >+ >+ cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND); >+ assertEquals(FillPatternType.SOLID_FOREGROUND,cellFill.getPatternType()); >+ assertEquals(STPatternType.SOLID,cellFill.getCTFill().getPatternFill().getPatternType()); > } > > public void testGetFont() { >Index: src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFBorder.java >=================================================================== >--- src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFBorder.java (revision 700785) >+++ src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFBorder.java (working copy) >@@ -17,15 +17,16 @@ > > package org.apache.poi.xssf.usermodel.extensions; > >+import junit.framework.TestCase; >+ >+import org.apache.poi.xssf.usermodel.BorderStyle; > import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder.BorderSide; > import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder; > import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr; > import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet; > import org.openxmlformats.schemas.spreadsheetml.x2006.main.STBorderStyle; > >-import junit.framework.TestCase; > >- > public class TestXSSFBorder extends TestCase { > > public void testGetBorderStyle() { >@@ -34,15 +35,20 @@ > CTBorderPr top = border.addNewTop(); > CTBorderPr right = border.addNewRight(); > CTBorderPr bottom = border.addNewBottom(); >+ > top.setStyle(STBorderStyle.DASH_DOT); > right.setStyle(STBorderStyle.NONE); > bottom.setStyle(STBorderStyle.THIN); >+ > XSSFCellBorder cellBorderStyle = new XSSFCellBorder(border); >- assertEquals("dashDot", cellBorderStyle.getBorderStyle(BorderSide.TOP).toString()); >- assertEquals("none", cellBorderStyle.getBorderStyle(BorderSide.RIGHT).toString()); >- assertEquals(1, cellBorderStyle.getBorderStyle(BorderSide.RIGHT).intValue()); >- assertEquals("thin", cellBorderStyle.getBorderStyle(BorderSide.BOTTOM).toString()); >- assertEquals(2, cellBorderStyle.getBorderStyle(BorderSide.BOTTOM).intValue()); >+ assertEquals("DASH_DOT", cellBorderStyle.getBorderStyle(BorderSide.TOP).toString()); >+ >+ assertEquals("NONE", cellBorderStyle.getBorderStyle(BorderSide.RIGHT).toString()); >+ assertEquals(BorderStyle.NONE.ordinal(), cellBorderStyle.getBorderStyle(BorderSide.RIGHT).ordinal()); >+ >+ assertEquals("THIN", cellBorderStyle.getBorderStyle(BorderSide.BOTTOM).toString()); >+ >+ assertEquals(BorderStyle.THIN.ordinal(), cellBorderStyle.getBorderStyle(BorderSide.BOTTOM).ordinal()); > } > > } >Index: src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java >=================================================================== >--- src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java (revision 700785) >+++ src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java (working copy) >@@ -18,6 +18,7 @@ > package org.apache.poi.xssf.usermodel.extensions; > > >+import org.apache.poi.xssf.usermodel.FillPatternType; > import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor; > import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill; > import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPatternFill; >@@ -48,11 +49,11 @@ > assertEquals(8, cellFill.getFillForegroundColor().getIndexed()); > } > >- public void testGetPatternType() { >+ public void testGetSetPatternType() { > CTFill ctFill = CTFill.Factory.newInstance(); > XSSFCellFill cellFill = new XSSFCellFill(ctFill); > CTPatternFill ctPatternFill = ctFill.addNewPatternFill(); >- ctPatternFill.setPatternType(STPatternType.DARK_DOWN); >- assertEquals(8, cellFill.getPatternType().intValue()); >+ ctPatternFill.setPatternType(STPatternType.SOLID); >+ assertEquals(FillPatternType.SOLID_FOREGROUND.ordinal(), cellFill.getPatternType().ordinal()); > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 45942
: 22670