View | Details | Raw Unified | Return to bug 45942
Collapse All | Expand All

(-)src/ooxml/java/org/apache/poi/xssf/usermodel/BorderStyle.java (+113 lines)
Line 0 Link Here
1
/* ====================================================================
2
   Licensed to the Apache Software Foundation (ASF) under one or more
3
   contributor license agreements.  See the NOTICE file distributed with
4
   this work for additional information regarding copyright ownership.
5
   The ASF licenses this file to You under the Apache License, Version 2.0
6
   (the "License"); you may not use this file except in compliance with
7
   the License.  You may obtain a copy of the License at
8
9
       http://www.apache.org/licenses/LICENSE-2.0
10
11
   Unless required by applicable law or agreed to in writing, software
12
   distributed under the License is distributed on an "AS IS" BASIS,
13
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
   See the License for the specific language governing permissions and
15
   limitations under the License.
16
==================================================================== */
17
18
package org.apache.poi.xssf.usermodel;
19
20
/**
21
 * The enumeration value indicating the line style of a border in a cell,
22
 * i.e., whether it is borded dash dot, dash dot dot, dashed, dotted, double, hair, medium, 
23
 * medium dash dot, medium dash dot dot, medium dashed, none, slant dash dot, thick or thin.
24
 */
25
26
27
public enum BorderStyle {
28
29
    /**
30
     * No border
31
     */
32
33
    NONE,
34
35
    /**
36
     * Thin border
37
     */
38
39
    THIN,
40
41
    /**
42
     * Medium border
43
     */
44
45
    MEDIUM,
46
47
    /**
48
     * dash border
49
     */
50
51
    DASHED,
52
53
    /**
54
     * dot border
55
     */
56
57
    HAIR,
58
59
    /**
60
     * Thick border
61
     */
62
63
    THICK,
64
65
    /**
66
     * double-line border
67
     */
68
69
    DOUBLE,
70
71
    /**
72
     * hair-line border
73
     */
74
75
    DOTTED,
76
77
    /**
78
     * Medium dashed border
79
     */
80
81
    MEDIUM_DASHED,
82
83
    /**
84
     * dash-dot border
85
     */
86
87
    DASH_DOT,
88
89
    /**
90
     * medium dash-dot border
91
     */
92
93
    MEDIUM_DASH_DOT,
94
95
    /**
96
     * dash-dot-dot border
97
     */
98
99
    DASH_DOT_DOT,
100
101
    /**
102
     * medium dash-dot-dot border
103
     */
104
105
    MEDIUM_DASH_DOT_DOTC,
106
107
    /**
108
     * slanted dash-dot border
109
     */
110
111
    SLANTED_DASH_DOT;
112
113
}
(-)src/ooxml/java/org/apache/poi/xssf/usermodel/FillPatternType.java (+85 lines)
Line 0 Link Here
1
/* ====================================================================
2
   Licensed to the Apache Software Foundation (ASF) under one or more
3
   contributor license agreements.  See the NOTICE file distributed with
4
   this work for additional information regarding copyright ownership.
5
   The ASF licenses this file to You under the Apache License, Version 2.0
6
   (the "License"); you may not use this file except in compliance with
7
   the License.  You may obtain a copy of the License at
8
9
       http://www.apache.org/licenses/LICENSE-2.0
10
11
   Unless required by applicable law or agreed to in writing, software
12
   distributed under the License is distributed on an "AS IS" BASIS,
13
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
   See the License for the specific language governing permissions and
15
   limitations under the License.
16
==================================================================== */
17
18
package org.apache.poi.xssf.usermodel;
19
20
/**
21
 * The enumeration value indicating the style of fill pattern being used for a cell format.
22
 * 
23
 */
24
25
26
public enum FillPatternType {
27
    
28
    /**  No background */
29
     NO_FILL,
30
31
    /**  Solidly filled */
32
     SOLID_FOREGROUND,
33
34
    /**  Small fine dots */
35
     FINE_DOTS,
36
37
    /**  Wide dots */
38
     ALT_BARS,
39
40
    /**  Sparse dots */
41
     SPARSE_DOTS,
42
43
    /**  Thick horizontal bands */
44
     THICK_HORZ_BANDS,
45
46
    /**  Thick vertical bands */
47
     THICK_VERT_BANDS,
48
49
    /**  Thick backward facing diagonals */
50
     THICK_BACKWARD_DIAG,
51
52
    /**  Thick forward facing diagonals */
53
     THICK_FORWARD_DIAG,
54
55
    /**  Large spots */
56
     BIG_SPOTS,
57
58
    /**  Brick-like layout */
59
     BRICKS,
60
61
    /**  Thin horizontal bands */
62
     THIN_HORZ_BANDS,
63
64
    /**  Thin vertical bands */
65
     THIN_VERT_BANDS,
66
67
    /**  Thin backward diagonal */
68
     THIN_BACKWARD_DIAG,
69
70
    /**  Thin forward diagonal */
71
     THIN_FORWARD_DIAG,
72
73
    /**  Squares */
74
     SQUARES,
75
76
    /**  Diamonds */
77
     DIAMONDS,
78
79
    /**  Less Dots */
80
     LESS_DOTS,
81
82
    /**  Least Dots */
83
     LEAST_DOTS;
84
85
}
(-)src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellFill.java (-22 / +32 lines)
Lines 19-28 Link Here
19
import java.util.List;
19
import java.util.List;
20
20
21
import org.apache.poi.xssf.usermodel.IndexedColors;
21
import org.apache.poi.xssf.usermodel.IndexedColors;
22
import org.apache.poi.xssf.usermodel.FillPatternType;
22
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor;
23
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor;
23
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill;
24
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill;
24
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPatternFill;
25
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPatternFill;
25
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPatternType.Enum;
26
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPatternType;
26
27
27
public final class XSSFCellFill {
28
public final class XSSFCellFill {
28
	
29
	
Lines 37-64 Link Here
37
	}
38
	}
38
	
39
	
39
	public XSSFColor getFillBackgroundColor() {
40
	public XSSFColor getFillBackgroundColor() {
40
		CTColor ctColor = getPatternFill().getBgColor();
41
	    CTColor ctColor=getPatternFill().getBgColor();
41
		if (ctColor == null) {
42
	    XSSFColor color;
42
			XSSFColor result = new XSSFColor();
43
	    if(ctColor == null){
43
			result.setIndexed(IndexedColors.AUTOMATIC.getIndex());
44
		color=new XSSFColor();
44
			return result;
45
		color.setIndexed(IndexedColors.AUTOMATIC.getIndex());
45
		}
46
	    }
46
		return new XSSFColor(ctColor);
47
	    else{
48
		color=new XSSFColor(getPatternFill().getBgColor());
49
	    }
50
	    return color;
47
	}
51
	}
48
52
49
	public XSSFColor getFillForegroundColor() {
53
	public XSSFColor getFillForegroundColor() {
50
		CTColor ctColor = getPatternFill().getFgColor();
54
	    CTColor ctColor=getPatternFill().getFgColor();
51
		if (ctColor == null) {
55
	    XSSFColor color;
52
			XSSFColor result = new XSSFColor();
56
	    if(ctColor == null){
53
			result.setIndexed(IndexedColors.AUTOMATIC.getIndex());
57
		color=new XSSFColor();
54
			return result;
58
		color.setIndexed(IndexedColors.AUTOMATIC.getIndex());
55
		}
59
	    }
56
		return new XSSFColor(ctColor);
60
	    else{
61
		color=new XSSFColor(getPatternFill().getFgColor());
62
	    }
63
	    return color;
57
	}
64
	}
58
59
	public Enum getPatternType() {
60
		return getPatternFill().getPatternType();
61
	}
62
	
65
	
63
	/**
66
	/**
64
	 * @return the index of the just added fill
67
	 * @return the index of the just added fill
Lines 101-109 Link Here
101
104
102
	public void setFillForegroundRgbColor(XSSFColor color) {
105
	public void setFillForegroundRgbColor(XSSFColor color) {
103
		_fill.getPatternFill().setFgColor(color.getCTColor());
106
		_fill.getPatternFill().setFgColor(color.getCTColor());
107
	}	
108
	
109
	public FillPatternType getPatternType() {
110
	    STPatternType.Enum pType = getPatternFill().getPatternType();
111
	    if(pType == null) pType = STPatternType.NONE;
112
	    return FillPatternType.values()[pType.intValue() - 1];
104
	}
113
	}
114
115
	public void setPatternType(FillPatternType type) {
116
	    getPatternFill().setPatternType((STPatternType.Enum.forInt(type.ordinal() + 1)));
117
	}
105
	
118
	
106
	public void setPatternType(Enum patternType) {
107
		getPatternFill().setPatternType(patternType);
108
	}
109
}
119
}
(-)src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellBorder.java (-9 / +20 lines)
Lines 19-24 Link Here
19
19
20
import java.util.LinkedList;
20
import java.util.LinkedList;
21
21
22
import org.apache.poi.xssf.usermodel.BorderStyle;
22
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder;
23
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder;
23
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr;
24
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr;
24
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STBorderStyle;
25
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STBorderStyle;
Lines 53-66 Link Here
53
		return borders.size() - 1;
54
		return borders.size() - 1;
54
	}
55
	}
55
	
56
	
56
	public STBorderStyle.Enum getBorderStyle(BorderSide side) {
57
		return getBorder(side).getStyle();
58
	}
59
	
60
	public void setBorderStyle(BorderSide side, STBorderStyle.Enum style) {
61
		getBorder(side).setStyle(style);
62
	}
63
	
64
	public XSSFColor getBorderColor(BorderSide side) {
57
	public XSSFColor getBorderColor(BorderSide side) {
65
		CTBorderPr borderPr = getBorder(side);
58
		CTBorderPr borderPr = getBorder(side);
66
		if (!borderPr.isSetColor()) {
59
		if (!borderPr.isSetColor()) {
Lines 69-78 Link Here
69
		return new XSSFColor(getBorder(side).getColor());
62
		return new XSSFColor(getBorder(side).getColor());
70
	}
63
	}
71
64
65
	public BorderStyle getBorderStyle(BorderSide side) {
66
	    STBorderStyle.Enum border = getBorder(side).getStyle();
67
	    if(border == null) border = STBorderStyle.NONE;
68
	    return BorderStyle.values()[border.intValue() - 1];
69
	}
70
71
	public String getBorderStyleAsString(BorderSide side) {
72
	    STBorderStyle.Enum border = getBorder(side).getStyle();
73
	    if(border == null) border = STBorderStyle.NONE;
74
	    return border.toString();
75
	}
76
77
	
72
	public void setBorderColor(BorderSide side, XSSFColor color) {
78
	public void setBorderColor(BorderSide side, XSSFColor color) {
73
		getBorder(side).setColor(color.getCTColor());
79
		getBorder(side).setColor(color.getCTColor());
74
	}
80
	}
75
	
81
82
	public void setBorderStyle(BorderSide side,BorderStyle style) {
83
	    getBorder(side).setStyle((STBorderStyle.Enum.forInt(style.ordinal() + 1)));
84
	}
85
76
	private CTBorderPr getBorder(BorderSide side) {
86
	private CTBorderPr getBorder(BorderSide side) {
77
		switch (side) {
87
		switch (side) {
78
		case TOP: {
88
		case TOP: {
Lines 94-97 Link Here
94
		default: throw new IllegalArgumentException("No suitable side specified for the border");
104
		default: throw new IllegalArgumentException("No suitable side specified for the border");
95
		}
105
		}
96
	}
106
	}
107
	
97
}
108
}
(-)src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java (-168 / +662 lines)
Lines 30-38 Link Here
30
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellAlignment;
30
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellAlignment;
31
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellProtection;
31
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellProtection;
32
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf;
32
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf;
33
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STBorderStyle;
34
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPatternType;
35
33
34
/**
35
 * 
36
 *  High level representation of the style of a cell in a sheet of a workbook.
37
 * 
38
 * @see org.apache.poi.xssf.usermodel.XSSFWorkbook#createCellStyle()
39
 * @see org.apache.poi.xssf.usermodel.XSSFWorkbook#getCellStyleAt(short)
40
 * @see org.apache.poi.xssf.usermodel.XSSFCell#setCellStyle(XSSFCellStyle)
41
 */
36
42
37
public class XSSFCellStyle implements CellStyle {
43
public class XSSFCellStyle implements CellStyle {
38
44
Lines 66-71 Link Here
66
    public CTXf getCoreXf() {
72
    public CTXf getCoreXf() {
67
        return cellXf;
73
        return cellXf;
68
    }
74
    }
75
    
69
    /**
76
    /**
70
     * Used so that StylesSource can figure out our location
77
     * Used so that StylesSource can figure out our location
71
     */
78
     */
Lines 117-430 Link Here
117
        }
124
        }
118
        throw new IllegalArgumentException("Can only clone from one XSSFCellStyle to another, not between HSSFCellStyle and XSSFCellStyle");
125
        throw new IllegalArgumentException("Can only clone from one XSSFCellStyle to another, not between HSSFCellStyle and XSSFCellStyle");
119
    }
126
    }
127
    
120
    public void cloneStyleFrom(XSSFCellStyle source) {
128
    public void cloneStyleFrom(XSSFCellStyle source) {
121
        throw new IllegalStateException("TODO");
129
        throw new IllegalStateException("TODO");
122
    }
130
    }
123
131
132
    /**
133
     * get the type of horizontal alignment for the cell
134
     * @see #ALIGN_GENERAL
135
     * @see #ALIGN_LEFT
136
     * @see #ALIGN_CENTER
137
     * @see #ALIGN_RIGHT
138
     * @see #ALIGN_FILL
139
     * @see #ALIGN_JUSTIFY
140
     * @see #ALIGN_CENTER_SELECTION
141
     * @return short - the type of alignment
142
     */
124
    public short getAlignment() {
143
    public short getAlignment() {
125
        return (short)(getAlignmentEnum().ordinal());
144
        return (short)(getAlignmentEnum().ordinal());
126
    }
145
    }
127
146
147
    /**
148
     * get the type of horizontal alignment for the cell
149
     * @return HorizontalAlignment - the type of alignment
150
     */   
128
    public HorizontalAlignment getAlignmentEnum() {
151
    public HorizontalAlignment getAlignmentEnum() {
129
        return getCellAlignment().getHorizontal();
152
        return getCellAlignment().getHorizontal();
130
    }
153
    }
131
154
155
    /**
156
     * get the type of border to use for the bottom border of the cell
157
     * @return short - border type
158
     * @see #BORDER_NONE
159
     * @see #BORDER_THIN
160
     * @see #BORDER_MEDIUM
161
     * @see #BORDER_DASHED
162
     * @see #BORDER_DOTTED
163
     * @see #BORDER_THICK
164
     * @see #BORDER_DOUBLE
165
     * @see #BORDER_HAIR
166
     * @see #BORDER_MEDIUM_DASHED
167
     * @see #BORDER_DASH_DOT
168
     * @see #BORDER_MEDIUM_DASH_DOT
169
     * @see #BORDER_DASH_DOT_DOT
170
     * @see #BORDER_MEDIUM_DASH_DOT_DOT
171
     * @see #BORDER_SLANTED_DASH_DOT
172
     */
132
    public short getBorderBottom() {
173
    public short getBorderBottom() {
133
        return getBorderStyleAsShort(BorderSide.BOTTOM);
174
	return (short) (getBorderStyleEnum(BorderSide.BOTTOM).ordinal());
134
    }
175
    }
135
176
177
    /**
178
     * get the type of border to use for the bottom border of the cell as String
179
     * @return String - border type as string
180
     */
136
    public String getBorderBottomAsString() {
181
    public String getBorderBottomAsString() {
137
        return getBorderStyleAsString(BorderSide.BOTTOM);
182
        return getBorderStyleAsString(BorderSide.BOTTOM);
138
    }
183
    }
139
184
185
    /**
186
     * get the type of border to use for the bottom border of the cell 
187
     * @return BoerderStyle - border type as string
188
     */
189
    public BorderStyle getBorderBottomEnum() {
190
        return getBorderStyleEnum(BorderSide.BOTTOM);
191
    }
192
193
    /**
194
     * get the type of border to use for the left border of the cell
195
     * @return short - border type
196
     * @see #BORDER_NONE
197
     * @see #BORDER_THIN
198
     * @see #BORDER_MEDIUM
199
     * @see #BORDER_DASHED
200
     * @see #BORDER_DOTTED
201
     * @see #BORDER_THICK
202
     * @see #BORDER_DOUBLE
203
     * @see #BORDER_HAIR
204
     * @see #BORDER_MEDIUM_DASHED
205
     * @see #BORDER_DASH_DOT
206
     * @see #BORDER_MEDIUM_DASH_DOT
207
     * @see #BORDER_DASH_DOT_DOT
208
     * @see #BORDER_MEDIUM_DASH_DOT_DOT
209
     * @see #BORDER_SLANTED_DASH_DOT
210
     */
140
    public short getBorderLeft() {
211
    public short getBorderLeft() {
141
        return getBorderStyleAsShort(BorderSide.LEFT);
212
        return (short) (getBorderStyleEnum(BorderSide.LEFT).ordinal());
142
    }
213
    }
143
214
    
215
    /**
216
     * get the type of border to use for the left border of the cell as String
217
     * @return String - border type as string
218
     */
144
    public String getBorderLeftAsString() {
219
    public String getBorderLeftAsString() {
145
        return getBorderStyleAsString(BorderSide.LEFT);
220
        return getBorderStyleAsString(BorderSide.LEFT);
146
    }
221
    }
147
222
223
    /**
224
     * get the type of border to use for the left border of the cell 
225
     * @return BoerderStyle - border type as string
226
     */
227
    public BorderStyle getBorderLeftEnum() {
228
        return getBorderStyleEnum(BorderSide.LEFT);
229
    }
230
231
    /**
232
     * get the type of border to use for the right border of the cell
233
     * @return short - border type
234
     * @see #BORDER_NONE
235
     * @see #BORDER_THIN
236
     * @see #BORDER_MEDIUM
237
     * @see #BORDER_DASHED
238
     * @see #BORDER_DOTTED
239
     * @see #BORDER_THICK
240
     * @see #BORDER_DOUBLE
241
     * @see #BORDER_HAIR
242
     * @see #BORDER_MEDIUM_DASHED
243
     * @see #BORDER_DASH_DOT
244
     * @see #BORDER_MEDIUM_DASH_DOT
245
     * @see #BORDER_DASH_DOT_DOT
246
     * @see #BORDER_MEDIUM_DASH_DOT_DOT
247
     * @see #BORDER_SLANTED_DASH_DOT
248
     */
148
    public short getBorderRight() {
249
    public short getBorderRight() {
149
        return getBorderStyleAsShort(BorderSide.RIGHT);
250
        return (short) (getBorderStyleEnum(BorderSide.RIGHT).ordinal());
150
    }
251
    }
151
252
253
    /**
254
     * get the type of border to use for the right border of the cell as String
255
     * @return String - border type as string
256
     */
152
    public String getBorderRightAsString() {
257
    public String getBorderRightAsString() {
153
        return getBorderStyleAsString(BorderSide.RIGHT);
258
        return getBorderStyleAsString(BorderSide.RIGHT);
154
    }
259
    }
155
260
261
    /**
262
     * get the type of border to use for the right border of the cell 
263
     * @return BoerderStyle - border type as string
264
     */
265
    public BorderStyle getBorderRightEnum() {
266
        return getBorderStyleEnum(BorderSide.RIGHT);
267
    }
268
269
    /**
270
     * get the type of border to use for the top border of the cell
271
     * @return short - border type
272
     * @see #BORDER_NONE
273
     * @see #BORDER_THIN
274
     * @see #BORDER_MEDIUM
275
     * @see #BORDER_DASHED
276
     * @see #BORDER_DOTTED
277
     * @see #BORDER_THICK
278
     * @see #BORDER_DOUBLE
279
     * @see #BORDER_HAIR
280
     * @see #BORDER_MEDIUM_DASHED
281
     * @see #BORDER_DASH_DOT
282
     * @see #BORDER_MEDIUM_DASH_DOT
283
     * @see #BORDER_DASH_DOT_DOT
284
     * @see #BORDER_MEDIUM_DASH_DOT_DOT
285
     * @see #BORDER_SLANTED_DASH_DOT
286
     */
156
    public short getBorderTop() {
287
    public short getBorderTop() {
157
        return getBorderStyleAsShort(BorderSide.TOP);
288
        return (short) (getBorderStyleEnum(BorderSide.TOP).ordinal());
158
    }
289
    }
159
290
291
    /**
292
     * get the type of border to use for the top border of the cell as String
293
     * @return String - border type as string
294
     */
160
    public String getBorderTopAsString() {
295
    public String getBorderTopAsString() {
161
        return getBorderStyleAsString(BorderSide.TOP);
296
        return getBorderStyleAsString(BorderSide.TOP);
162
    }
297
    }
298
    
299
    /**
300
     * get the type of border to use for the top border of the cell 
301
     * @return BoerderStyle - border type as string
302
     */
303
    public BorderStyle getBorderTopEnum() {
304
        return getBorderStyleEnum(BorderSide.TOP);
305
    }
163
306
307
    /**
308
     * set the color to use for the bottom border
309
     * Color is optional. When missing, IndexedColors.AUTOMATIC is implied.
310
     * @return short - color The index of the color definition
311
     * @see IndexedColors
312
     */
164
    public short getBottomBorderColor() {
313
    public short getBottomBorderColor() {
165
        return getBorderColorIndexed(BorderSide.BOTTOM);
314
        return getBorderColorIndexed(BorderSide.BOTTOM);
166
    }
315
    }
167
316
317
    /**
318
     * get the index of the number format (numFmt) record used by this cell format.
319
     */
168
    public short getDataFormat() {
320
    public short getDataFormat() {
169
        return (short)cellXf.getNumFmtId();
321
        return (short)cellXf.getNumFmtId();
170
    }
322
    }
323
324
    /**
325
     * Get the contents of the format string, by looking up
326
     * the StylesSource
327
     * 
328
     * @return the number format string 
329
     */
171
    public String getDataFormatString() {
330
    public String getDataFormatString() {
172
        return stylesSource.getNumberFormatAt(getDataFormat());
331
        return stylesSource.getNumberFormatAt(getDataFormat());
173
    }
332
    }
174
333
334
    /**
335
     * Get the background fill color.
336
     * Note - many cells are actually filled with a foreground
337
     *  fill, not a background fill - see {@link #getFillForegroundColor()}
338
     * @see IndexedColors
339
     * @return short - fill color
340
     */
175
    public short getFillBackgroundColor() {
341
    public short getFillBackgroundColor() {
176
        return (short) getCellFill().getFillBackgroundColor().getIndexed();
342
        return (short) getCellFill().getFillBackgroundColor().getIndexed();
177
    }
343
    }
178
344
    
345
    /**
346
     * Get the background fill color.
347
     * Note - many cells are actually filled with a foreground
348
     *  fill, not a background fill - see {@link #getFillForegroundColor()}
349
     * @see org.apache.poi.hssf.usermodel.XSSFColor#getRgb()
350
     * @return XSSFColor - fill color
351
     */
179
    public XSSFColor getFillBackgroundRgbColor() {
352
    public XSSFColor getFillBackgroundRgbColor() {
180
        return getCellFill().getFillBackgroundColor();
353
        return getCellFill().getFillBackgroundColor();
181
    }
354
    }
182
355
    
356
    /**
357
     * Get the foreground fill color.
358
     * Many cells are filled with this, instead of a 
359
     *  background color ({@link #getFillBackgroundColor()})
360
     * @see IndexedColors
361
     * @return short - fill color
362
     */
183
    public short getFillForegroundColor() {
363
    public short getFillForegroundColor() {
184
        return (short) getCellFill().getFillForegroundColor().getIndexed();
364
        return (short) getCellFill().getFillForegroundColor().getIndexed();
185
    }
365
    }
186
366
    
367
    /**
368
     * Get the foreground fill color.
369
     * Many cells are filled with this, instead of a 
370
     *  background color ({@link #getFillBackgroundColor()})
371
     * @return XSSFColor - fill color
372
     */
187
    public XSSFColor getFillForegroundRgbColor() {
373
    public XSSFColor getFillForegroundRgbColor() {
188
        return  getCellFill().getFillForegroundColor();
374
        return  getCellFill().getFillForegroundColor();
189
    }
375
    }
190
376
377
    /**
378
     * get the fill pattern
379
     * @return short - fill pattern
380
     *      
381
     * @see #NO_FILL
382
     * @see #SOLID_FOREGROUND
383
     * @see #FINE_DOTS
384
     * @see #ALT_BARS
385
     * @see #SPARSE_DOTS
386
     * @see #THICK_HORZ_BANDS
387
     * @see #THICK_VERT_BANDS
388
     * @see #THICK_BACKWARD_DIAG
389
     * @see #THICK_FORWARD_DIAG
390
     * @see #BIG_SPOTS
391
     * @see #BRICKS
392
     * @see #THIN_HORZ_BANDS
393
     * @see #THIN_VERT_BANDS
394
     * @see #THIN_BACKWARD_DIAG
395
     * @see #THIN_FORWARD_DIAG
396
     * @see #SQUARES
397
     * @see #DIAMONDS
398
     */
191
    public short getFillPattern() {
399
    public short getFillPattern() {
192
	int fp= getCellFill().getPatternType().intValue();
400
	return (short) getCellFill().getPatternType().ordinal();
193
	switch (fp) {
194
	case STPatternType.INT_NONE:
195
		return CellStyle.NO_FILL;
196
	case STPatternType.INT_SOLID: 
197
	    return CellStyle.SOLID_FOREGROUND;
198
	case STPatternType.INT_LIGHT_GRAY:
199
	    return CellStyle.FINE_DOTS;
200
	case STPatternType.INT_DARK_GRID:
201
		return CellStyle.ALT_BARS;
202
	case STPatternType.INT_DARK_GRAY:
203
	    return CellStyle.SPARSE_DOTS;
204
	case STPatternType.INT_DARK_HORIZONTAL: 
205
	    return CellStyle.THICK_HORZ_BANDS;
206
	case STPatternType.INT_DARK_VERTICAL:
207
	    return CellStyle.THICK_VERT_BANDS;
208
	case STPatternType.INT_DARK_UP:
209
		return CellStyle.THICK_BACKWARD_DIAG;
210
	case STPatternType.INT_DARK_DOWN:
211
		return CellStyle.THICK_FORWARD_DIAG;
212
	case STPatternType.INT_GRAY_0625:
213
		return CellStyle.BIG_SPOTS;
214
	case STPatternType.INT_DARK_TRELLIS:
215
		return CellStyle.BRICKS;
216
	case STPatternType.INT_LIGHT_HORIZONTAL:
217
		return CellStyle.THIN_HORZ_BANDS;
218
	case STPatternType.INT_LIGHT_VERTICAL:
219
		return CellStyle.THIN_VERT_BANDS;
220
	case STPatternType.INT_LIGHT_UP:
221
		return CellStyle.THIN_BACKWARD_DIAG;
222
	case STPatternType.INT_LIGHT_DOWN:
223
		return CellStyle.THIN_FORWARD_DIAG;
224
	case STPatternType.INT_LIGHT_GRID:
225
		return CellStyle.SQUARES;
226
	case STPatternType.INT_LIGHT_TRELLIS:
227
		return CellStyle.DIAMONDS;
228
	case STPatternType.INT_GRAY_125:
229
		return CellStyle.LESS_DOTS;
230
/*		
231
	case STPatternType.INT_GRAY_0625:
232
		return CellStyle.LEAST_DOTS;
233
*/		
234
	default:
235
	    	return CellStyle.NO_FILL;
236
	}
237
    //    return (short) getCellFill().getPatternType().intValue();
238
    }
401
    }
239
402
403
    /**
404
     * get the fill pattern
405
     * @return FillPatternType - fill pattern
406
     */
407
    public FillPatternType getFillPatternEnum() {
408
	return getCellFill().getPatternType();
409
    } 
410
    
411
    /**
412
    * gets the font for this style
413
    * @param parentWorkbook The XSSFWorkbook that this style belongs to
414
    * @return Font - font
415
    * @see org.apache.poi.xssf.usermodel.XSSFCellStyle#getFontIndex()
416
    * @see org.apache.poi.xssf.usermodel.XSSFWorkbook#getFontAt(short)
417
    */
240
    public Font getFont(Workbook parentWorkbook) {
418
    public Font getFont(Workbook parentWorkbook) {
241
        return getFont();
419
        return getFont();
242
    }
420
    }
243
421
422
    /**
423
    * gets the font for this style
424
    * @return Font - font
425
    */
244
    public Font getFont() {
426
    public Font getFont() {
245
        if (font == null) {
427
        if (font == null) {
246
            font = (XSSFFont) ((StylesTable)stylesSource).getFontAt(getFontId());
428
            font = (XSSFFont) ((StylesTable)stylesSource).getFontAt(getFontId());
247
        }
429
        }
248
        return font;
430
        return font;
249
    }
431
    }
250
432
    
433
    /**
434
     * gets the index of the font for this style
435
     * @return short - font index
436
     * @see org.apache.poi.hssf.usermodel.XSSFWorkbook#getFontAt(short)
437
     */
251
    public short getFontIndex() {
438
    public short getFontIndex() {
252
        return (short) getFontId();
439
        return (short) getFontId();
253
    }
440
    }
254
441
442
    /**
443
     * get whether the cell's using this style are to be hidden
444
     * @return boolean -  whether the cell using this style is hidden
445
     */
255
    public boolean getHidden() {
446
    public boolean getHidden() {
256
        return getCellProtection().getHidden();
447
        return getCellProtection().getHidden();
257
    }
448
    }
258
449
450
    /**
451
     * get the number of spaces to indent the text in the cell
452
     * @return indent - number of spaces
453
     */
259
    public short getIndention() {
454
    public short getIndention() {
260
        return (short) getCellAlignment().getIndent();
455
        return (short) getCellAlignment().getIndent();
261
    }
456
    }
262
457
458
    /**
459
     * get the index within the StylesTable (sequence within the collection of CTXf elements) 
460
     * @return unique index number of the underlying record this style represents
461
     */
263
    public short getIndex() {
462
    public short getIndex() {
264
        return (short) this.cellXfId;
463
        return (short) this.cellXfId;
265
    }
464
    }
266
465
    
466
    /**
467
     * set the color to use for the left border
468
     * Color is optional. When missing, IndexedColors.AUTOMATIC is implied.
469
     * @return short - color The index of the color definition
470
     * @see IndexedColors
471
     */
267
    public short getLeftBorderColor() {
472
    public short getLeftBorderColor() {
268
        return getBorderColorIndexed(BorderSide.LEFT);
473
        return getBorderColorIndexed(BorderSide.LEFT);
269
    }
474
    }
270
475
    
476
    /**
477
     * get whether the cell's using this style are locked
478
     * @return boolean - whether the cell using this style are locked
479
     */
271
    public boolean getLocked() {
480
    public boolean getLocked() {
272
        return getCellProtection().getLocked();
481
        return getCellProtection().getLocked();
273
    }
482
    }
274
483
484
    /**
485
     * set the color to use for the right border
486
     * Color is optional. When missing, IndexedColors.AUTOMATIC is implied.
487
     * @return short - color The index of the color definition
488
     * @see IndexedColors
489
     */
275
    public short getRightBorderColor() {
490
    public short getRightBorderColor() {
276
        return getBorderColorIndexed(BorderSide.RIGHT);
491
        return getBorderColorIndexed(BorderSide.RIGHT);
277
    }
492
    }
278
493
    
494
    /**
495
     * get the degree of rotation for the text in the cell
496
     * @return rotation degrees (between -90 and 90 degrees)
497
     */
279
    public short getRotation() {
498
    public short getRotation() {
280
        return (short) getCellAlignment().getTextRotation();
499
        return (short) getCellAlignment().getTextRotation();
281
    }
500
    }
282
501
502
    /**
503
     * set the color to use for the top border
504
     * Color is optional. When missing, IndexedColors.AUTOMATIC is implied.
505
     * @return short - color The index of the color definition
506
     * @see IndexedColors
507
     */
283
    public short getTopBorderColor() {
508
    public short getTopBorderColor() {
284
        return getBorderColorIndexed(BorderSide.TOP);
509
        return getBorderColorIndexed(BorderSide.TOP);
285
    }
510
    }
286
511
512
    /**
513
     * get the type of vertical alignment for the cell
514
     * @return align the type of alignment
515
     * @see #VERTICAL_TOP
516
     * @see #VERTICAL_CENTER
517
     * @see #VERTICAL_BOTTOM
518
     * @see #VERTICAL_JUSTIFY
519
     */
287
    public short getVerticalAlignment() {
520
    public short getVerticalAlignment() {
288
        return (short) (getVerticalAlignmentEnum().ordinal());
521
        return (short) (getVerticalAlignmentEnum().ordinal());
289
    }
522
    }
290
523
524
    /**
525
     * get the type of vertical alignment for the cell
526
     * @return VerticalAlignment - align the type of alignment
527
     * @see VerticalAlignment
528
     */
291
    public VerticalAlignment getVerticalAlignmentEnum() {
529
    public VerticalAlignment getVerticalAlignmentEnum() {
292
        return getCellAlignment().getVertical();
530
        return getCellAlignment().getVertical();
293
    }
531
    }
294
532
533
    /**
534
     * get whether the text should be wrapped
535
     * @param boolean -  wrap text or not
536
     */
295
    public boolean getWrapText() {
537
    public boolean getWrapText() {
296
        return getCellAlignment().getWrapText();
538
        return getCellAlignment().getWrapText();
297
    }
539
    }
298
540
541
    /**
542
     * set the type of horizontal alignment for the cell
543
     * @param short align - the type of alignment
544
     * @see #ALIGN_GENERAL
545
     * @see #ALIGN_LEFT
546
     * @see #ALIGN_CENTER
547
     * @see #ALIGN_RIGHT
548
     * @see #ALIGN_FILL
549
     * @see #ALIGN_JUSTIFY
550
     * @see #ALIGN_CENTER_SELECTION
551
     */
299
    public void setAlignment(short align) {
552
    public void setAlignment(short align) {
300
        getCellAlignment().setHorizontal(HorizontalAlignment.values()[align]);
553
        getCellAlignment().setHorizontal(HorizontalAlignment.values()[align]);
301
    }
554
    }
302
555
556
    /**
557
     * set the type of horizontal alignment for the cell
558
     * @param HorizontalAlignment.Enum - the type of alignment
559
     * @see HorizontalAlignment
560
     */
303
    public void setAlignment(HorizontalAlignment align) {
561
    public void setAlignment(HorizontalAlignment align) {
304
        setAlignment((short)align.ordinal());
562
        setAlignment((short)align.ordinal());
305
    }
563
    }
306
564
    
565
    /**
566
     * set the type of border to use for the bottom border of the cell
567
     * @param border type
568
     * @see #BORDER_NONE
569
     * @see #BORDER_THIN
570
     * @see #BORDER_MEDIUM
571
     * @see #BORDER_DASHED
572
     * @see #BORDER_DOTTED
573
     * @see #BORDER_THICK
574
     * @see #BORDER_DOUBLE
575
     * @see #BORDER_HAIR
576
     * @see #BORDER_MEDIUM_DASHED
577
     * @see #BORDER_DASH_DOT
578
     * @see #BORDER_MEDIUM_DASH_DOT
579
     * @see #BORDER_DASH_DOT_DOT
580
     * @see #BORDER_MEDIUM_DASH_DOT_DOT
581
     * @see #BORDER_SLANTED_DASH_DOT
582
     */
307
    public void setBorderBottom(short border) {
583
    public void setBorderBottom(short border) {
308
        setBorderBottomEnum(STBorderStyle.Enum.forInt(border));
584
      getCellBorder().setBorderStyle(BorderSide.BOTTOM,BorderStyle.values()[border]);
309
    }
585
    }
310
586
311
    public void setBorderBottomEnum(STBorderStyle.Enum style) {
587
    /**
312
        getCellBorder().setBorderStyle(BorderSide.BOTTOM, style);
588
     * set the type of border to use for the bottom border of the cell
589
     * @param BorderStyle - border type
590
     */
591
    public void setBorderBottomEnum(BorderStyle border) {
592
	setBorderBottom((short)border.ordinal());
313
    }
593
    }
314
594
    
595
    /**
596
     * set the type of border to use for the left border of the cell
597
     * @param border type
598
     * @see #BORDER_NONE
599
     * @see #BORDER_THIN
600
     * @see #BORDER_MEDIUM
601
     * @see #BORDER_DASHED
602
     * @see #BORDER_DOTTED
603
     * @see #BORDER_THICK
604
     * @see #BORDER_DOUBLE
605
     * @see #BORDER_HAIR
606
     * @see #BORDER_MEDIUM_DASHED
607
     * @see #BORDER_DASH_DOT
608
     * @see #BORDER_MEDIUM_DASH_DOT
609
     * @see #BORDER_DASH_DOT_DOT
610
     * @see #BORDER_MEDIUM_DASH_DOT_DOT
611
     * @see #BORDER_SLANTED_DASH_DOT
612
     */
315
    public void setBorderLeft(short border) {
613
    public void setBorderLeft(short border) {
316
        setBorderLeftEnum(STBorderStyle.Enum.forInt(border));
614
	getCellBorder().setBorderStyle(BorderSide.LEFT,BorderStyle.values()[border]);
317
    }
615
    }
318
616
319
    public void setBorderLeftEnum(STBorderStyle.Enum style) {
617
    /**
320
        getCellBorder().setBorderStyle(BorderSide.LEFT, style);
618
     * set the type of border to use for the left border of the cell
619
     * @param border type
620
     */
621
    public void setBorderLeftEnum(BorderStyle border) {
622
	setBorderLeft((short)border.ordinal());
321
    }
623
    }
322
624
    
625
    /**
626
     * set the type of border to use for the right border of the cell
627
     * @param border type
628
     * @see #BORDER_NONE
629
     * @see #BORDER_THIN
630
     * @see #BORDER_MEDIUM
631
     * @see #BORDER_DASHED
632
     * @see #BORDER_DOTTED
633
     * @see #BORDER_THICK
634
     * @see #BORDER_DOUBLE
635
     * @see #BORDER_HAIR
636
     * @see #BORDER_MEDIUM_DASHED
637
     * @see #BORDER_DASH_DOT
638
     * @see #BORDER_MEDIUM_DASH_DOT
639
     * @see #BORDER_DASH_DOT_DOT
640
     * @see #BORDER_MEDIUM_DASH_DOT_DOT
641
     * @see #BORDER_SLANTED_DASH_DOT
642
     */
323
    public void setBorderRight(short border) {
643
    public void setBorderRight(short border) {
324
        setBorderRightEnum(STBorderStyle.Enum.forInt(border));
644
	getCellBorder().setBorderStyle(BorderSide.RIGHT,BorderStyle.values()[border]);
325
    }
645
    }
326
646
327
    public void setBorderRightEnum(STBorderStyle.Enum style) {
647
    /**
328
        getCellBorder().setBorderStyle(BorderSide.RIGHT, style);
648
     * set the type of border to use for the right border of the cell
649
     * @param border type
650
     */
651
    public void setBorderRightEnum(BorderStyle border) {
652
	setBorderRight((short)border.ordinal());
329
    }
653
    }
330
654
    
655
    /**
656
     * set the type of border to use for the top border of the cell
657
     * @param border type
658
     * @see #BORDER_NONE
659
     * @see #BORDER_THIN
660
     * @see #BORDER_MEDIUM
661
     * @see #BORDER_DASHED
662
     * @see #BORDER_DOTTED
663
     * @see #BORDER_THICK
664
     * @see #BORDER_DOUBLE
665
     * @see #BORDER_HAIR
666
     * @see #BORDER_MEDIUM_DASHED
667
     * @see #BORDER_DASH_DOT
668
     * @see #BORDER_MEDIUM_DASH_DOT
669
     * @see #BORDER_DASH_DOT_DOT
670
     * @see #BORDER_MEDIUM_DASH_DOT_DOT
671
     * @see #BORDER_SLANTED_DASH_DOT
672
     */
331
    public void setBorderTop(short border) {
673
    public void setBorderTop(short border) {
332
        setBorderTopEnum(STBorderStyle.Enum.forInt(border));
674
	getCellBorder().setBorderStyle(BorderSide.TOP,BorderStyle.values()[border]);
333
    }
675
    }
334
676
    
335
    public void setBorderTopEnum(STBorderStyle.Enum style) {
677
    /**
336
        getCellBorder().setBorderStyle(BorderSide.TOP, style);
678
     * set the type of border to use for the top border of the cell
679
     * @param border type
680
     */
681
    public void setBorderTopEnum(BorderStyle border) {
682
	setBorderTop((short)border.ordinal());
337
    }
683
    }
338
684
    
685
    /**
686
     * set the color to use for the bottom border
687
     * @param color The index of the color definition
688
     * @see IndexedColors
689
     */
339
    public void setBottomBorderColor(short color) {
690
    public void setBottomBorderColor(short color) {
340
        setBorderColorIndexed(BorderSide.BOTTOM, color);
691
        setBorderColorIndexed(BorderSide.BOTTOM, color);
341
    }
692
    }
342
693
694
    /**
695
     * set the index of a data format 
696
     */
343
    public void setDataFormat(short fmt) {
697
    public void setDataFormat(short fmt) {
344
        cellXf.setNumFmtId((long)fmt);
698
        cellXf.setNumFmtId((long)fmt);
345
    }
699
    }
346
700
701
    /**
702
     * set the background fill color represented as rgb values.
703
     * <p>
704
     * For example:
705
     * <pre>
706
     * cs.setFillPattern(XSSFCellStyle.FINE_DOTS );
707
     * cs.setFillBackgroundRgbColor(IndexedColors.RED.getIndex()); 
708
     * </pre>
709
     * optionally a Foreground and background fill can be applied:
710
     * <i>Note: Ensure Foreground color is set prior to background</i>
711
     * <pre>
712
     * cs.setFillPattern(XSSFCellStyle.FINE_DOTS );
713
     * cs.setFillForegroundColor(IndexedColors.BLUE.getIndex());
714
     * cs.setFillBackgroundColor(IndexedColors.RED.getIndex()); 
715
     * </pre>
716
     * or, for the special case of SOLID_FILL:
717
     * <pre>
718
     * cs.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND );
719
     * cs.setFillForegroundColor(IndexedColors.RED.getIndex());
720
     * </pre>
721
     * It is necessary to set the fill style in order
722
     * for the color to be shown in the cell.
723
     *
724
     * @param XSSFColor - bg  color
725
     */
347
    public void setFillBackgroundRgbColor(XSSFColor color) {
726
    public void setFillBackgroundRgbColor(XSSFColor color) {
348
        cellFill=getCellFill();
727
        cellFill=getCellFill();
349
        cellFill.setFillBackgroundRgbColor(color);
728
        cellFill.setFillBackgroundRgbColor(color);
350
    }
729
    }
351
730
    
731
    /**
732
     * set the background fill color.
733
     * <p>
734
     * For example:
735
     * <pre>
736
     * cs.setFillPattern(XSSFCellStyle.FINE_DOTS );
737
     * cs.setFillBackgroundRgbColor(IndexedColors.RED.getIndex()); 
738
     * </pre>
739
     * optionally a Foreground and background fill can be applied:
740
     * <i>Note: Ensure Foreground color is set prior to background</i>
741
     * <pre>
742
     * cs.setFillPattern(XSSFCellStyle.FINE_DOTS );
743
     * cs.setFillForegroundColor(IndexedColors.BLUE.getIndex());
744
     * cs.setFillBackgroundColor(IndexedColors.RED.getIndex()); 
745
     * </pre>
746
     * or, for the special case of SOLID_FILL:
747
     * <pre>
748
     * cs.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND );
749
     * cs.setFillForegroundColor(IndexedColors.RED.getIndex());
750
     * </pre>
751
     * It is necessary to set the fill style in order
752
     * for the color to be shown in the cell.
753
     *
754
     * @param short - bg  color
755
     */
352
    public void setFillBackgroundColor(short bg) {
756
    public void setFillBackgroundColor(short bg) {
353
        getCellFill().setFillBackgroundColor(bg);
757
        getCellFill().setFillBackgroundColor(bg);
354
    }
758
    }
355
759
    
760
    /**
761
    * set the foreground fill color represented as rgb values.
762
    * <i>Note: Ensure Foreground color is set prior to background color.</i>
763
    * @param XSSFColor - bg  color
764
    */
356
    public void setFillForegroundRgbColor(XSSFColor color) {
765
    public void setFillForegroundRgbColor(XSSFColor color) {
357
        getCellFill().setFillForegroundRgbColor(color);
766
        getCellFill().setFillForegroundRgbColor(color);
358
    }
767
    }
359
768
769
    /**
770
    * set the foreground fill color
771
    * <i>Note: Ensure Foreground color is set prior to background color.</i>
772
    * @param short - bg  color
773
    */
360
    public void setFillForegroundColor(short bg) {
774
    public void setFillForegroundColor(short bg) {
361
	getCellFill().setFillForegroundColor(bg);
775
	getCellFill().setFillForegroundColor(bg);
362
    }
776
    }
363
777
778
    /**
779
     * This element is used to specify cell fill information for pattern and solid color cell fills. For solid cell fills (no pattern),
780
     *  fgColor is used. For cell fills with patterns specified, then the cell fill color is specified by the bgColor element.
781
     *
782
     * @see #NO_FILL
783
     * @see #SOLID_FOREGROUND
784
     * @see #FINE_DOTS
785
     * @see #ALT_BARS
786
     * @see #SPARSE_DOTS
787
     * @see #THICK_HORZ_BANDS
788
     * @see #THICK_VERT_BANDS
789
     * @see #THICK_BACKWARD_DIAG
790
     * @see #THICK_FORWARD_DIAG
791
     * @see #BIG_SPOTS
792
     * @see #BRICKS
793
     * @see #THIN_HORZ_BANDS
794
     * @see #THIN_VERT_BANDS
795
     * @see #THIN_BACKWARD_DIAG
796
     * @see #THIN_FORWARD_DIAG
797
     * @see #SQUARES
798
     * @see #DIAMONDS
799
     *
800
     * @param fp  fill pattern (set to 1 to fill w/foreground color)
801
     */
364
    public void setFillPattern(short fp) {
802
    public void setFillPattern(short fp) {
365
	cellFill=getCellFill();
803
	getCellFill().setPatternType(FillPatternType.values()[fp]);
366
	switch (fp) {
367
	case CellStyle.NO_FILL:
368
		cellFill.setPatternType(STPatternType.NONE);
369
	    break;
370
	case CellStyle.SOLID_FOREGROUND:
371
		cellFill.setPatternType(STPatternType.SOLID);
372
		    break;
373
	case CellStyle.FINE_DOTS:
374
		cellFill.setPatternType(STPatternType.LIGHT_GRAY);
375
		    break;
376
	case CellStyle.ALT_BARS:
377
		cellFill.setPatternType(STPatternType.DARK_GRID);
378
		    break;
379
	case CellStyle.SPARSE_DOTS:
380
		cellFill.setPatternType(STPatternType.DARK_GRAY);
381
		    break;
382
	case CellStyle.THICK_HORZ_BANDS:
383
		cellFill.setPatternType(STPatternType.DARK_HORIZONTAL);
384
		    break;
385
	case CellStyle.THICK_VERT_BANDS:
386
		cellFill.setPatternType(STPatternType.DARK_VERTICAL);
387
		    break;
388
	case CellStyle.THICK_BACKWARD_DIAG:
389
		cellFill.setPatternType(STPatternType.DARK_UP);
390
		    break;
391
	case CellStyle.THICK_FORWARD_DIAG:
392
		cellFill.setPatternType(STPatternType.DARK_DOWN);
393
		    break;
394
	case CellStyle.BIG_SPOTS:
395
		cellFill.setPatternType(STPatternType.GRAY_0625);
396
		    break;
397
	case CellStyle.BRICKS:
398
		cellFill.setPatternType(STPatternType.DARK_TRELLIS);
399
		    break;
400
	case CellStyle.THIN_HORZ_BANDS:
401
		cellFill.setPatternType(STPatternType.LIGHT_HORIZONTAL);
402
		    break;
403
	case CellStyle.THIN_VERT_BANDS:
404
		cellFill.setPatternType(STPatternType.LIGHT_VERTICAL);
405
		    break;
406
	case CellStyle.THIN_BACKWARD_DIAG:
407
		cellFill.setPatternType(STPatternType.LIGHT_UP);
408
		    break;
409
	case CellStyle.THIN_FORWARD_DIAG:
410
		cellFill.setPatternType(STPatternType.LIGHT_DOWN);
411
		    break;
412
	case CellStyle.SQUARES:
413
		cellFill.setPatternType(STPatternType.LIGHT_GRID);
414
		    break;
415
	case CellStyle.DIAMONDS:
416
		cellFill.setPatternType(STPatternType.LIGHT_TRELLIS);
417
		    break;
418
	case CellStyle.LESS_DOTS:
419
		cellFill.setPatternType(STPatternType.GRAY_125);
420
		    break;
421
	case CellStyle.LEAST_DOTS:
422
		cellFill.setPatternType(STPatternType.GRAY_0625);
423
		    break;
424
	default: throw new RuntimeException("Fill type ["+fp+"] not accepted");
425
	}
426
    }
804
    }
427
805
806
    /**
807
     * This element is used to specify cell fill information for pattern and solid color cell fills. For solid cell fills (no pattern),
808
     *  fgColor is used. For cell fills with patterns specified, then the cell fill color is specified by the bgColor element.
809
     *
810
     * @param FillPatternType - fill pattern
811
     *
812
     */
813
    public void setFillPattern(FillPatternType pType) {
814
	setFillPattern((short)pType.ordinal());
815
    }
816
    
817
    /**
818
     * set the font for this style
819
     * @param font  a font object created or retreived from the XSSFWorkbook object
820
     * @see org.apache.poi.hssf.usermodel.XSSFWorkbook#createFont()
821
     * @see org.apache.poi.hssf.usermodel.XSSFWorkbook#getFontAt(short)
822
     */
428
    public void setFont(Font font) {
823
    public void setFont(Font font) {
429
        if(font!=null){
824
        if(font!=null){
430
            long index=this.stylesSource.putFont(font);
825
            long index=this.stylesSource.putFont(font);
Lines 433-481 Link Here
433
        this.cellXf.setApplyFont(true);
828
        this.cellXf.setApplyFont(true);
434
    }
829
    }
435
830
831
    /**
832
     * set the cell's using this style to be hidden
833
     * @param boolean - whether the cell using this style should be hidden
834
     */
436
    public void setHidden(boolean hidden) {
835
    public void setHidden(boolean hidden) {
437
        getCellProtection().setHidden(hidden);
836
        getCellProtection().setHidden(hidden);
438
    }
837
    }
439
838
839
    /**
840
     * set the number of spaces to indent the text in the cell
841
     * @param indent - number of spaces
842
     */
440
    public void setIndention(short indent) {
843
    public void setIndention(short indent) {
441
        getCellAlignment().setIndent(indent);
844
        getCellAlignment().setIndent(indent);
442
    }
845
    }
443
846
847
    /**
848
     * set the color to use for the left border
849
     * @param color The index of the color definition
850
     * @see IndexedColors
851
     */
444
    public void setLeftBorderColor(short color) {
852
    public void setLeftBorderColor(short color) {
445
        setBorderColorIndexed(BorderSide.LEFT, color);
853
        setBorderColorIndexed(BorderSide.LEFT, color);
446
    }
854
    }
447
855
448
	
856
    /**
449
	private void setBorderColorIndexed(BorderSide side, XSSFColor color) {
857
     * set the cell's using this style to be locked
450
		this.cellBorder.setBorderColor(side, color);
858
     * @param boolean -  whether the cell using this style should be locked
451
	}
859
     */
452
453
454
    public void setLocked(boolean locked) {
860
    public void setLocked(boolean locked) {
455
        getCellProtection().setLocked(locked);
861
	getCellProtection().setLocked(locked);
456
    }
862
    }
457
863
458
864
    /**
865
     * set the color to use for the right border
866
     * @param color The index of the color definition
867
     * @see IndexedColors
868
     */
459
    public void setRightBorderColor(short color) {
869
    public void setRightBorderColor(short color) {
460
        setBorderColorIndexed(BorderSide.RIGHT, color);
870
        setBorderColorIndexed(BorderSide.RIGHT, color);
461
    }
871
    }
462
872
873
    /**
874
     * set the degree of rotation for the text in the cell
875
     * @param short - rotation degrees (between -90 and 90 degrees)
876
     */
463
    public void setRotation(short rotation) {
877
    public void setRotation(short rotation) {
464
        getCellAlignment().setTextRotation(rotation);
878
        getCellAlignment().setTextRotation(rotation);
465
    }
879
    }
466
880
881
882
    /**
883
     * set the color to use for the top border
884
     * @param color The index of the color definition
885
     * @see IndexedColors
886
     */
467
    public void setTopBorderColor(short color) {
887
    public void setTopBorderColor(short color) {
468
        setBorderColorIndexed(BorderSide.TOP, color);
888
        setBorderColorIndexed(BorderSide.TOP, color);
469
    }
889
    }
470
890
    
891
    /**
892
     * set the type of vertical alignment for the cell
893
     * @param short - align the type of alignment
894
     * @see #VERTICAL_TOP
895
     * @see #VERTICAL_CENTER
896
     * @see #VERTICAL_BOTTOM
897
     * @see #VERTICAL_JUSTIFY
898
     * @see VerticalAlignment
899
     */
471
    public void setVerticalAlignment(short align) {
900
    public void setVerticalAlignment(short align) {
472
        getCellAlignment().setVertical(VerticalAlignment.values()[align]);
901
        getCellAlignment().setVertical(VerticalAlignment.values()[align]);
473
    }
902
    }
474
903
    
904
    /**
905
     * set the type of vertical alignment for the cell
906
     * @param VerticalAlignment - align the type of alignment
907
     */
475
    public void setVerticalAlignment(VerticalAlignment align) {
908
    public void setVerticalAlignment(VerticalAlignment align) {
476
        getCellAlignment().setVertical(align);
909
        getCellAlignment().setVertical(align);
477
    }
910
    }
478
911
912
    /**
913
     * set whether the text should be wrapped
914
     * @param boolean -  wrap text or not
915
     */
479
    public void setWrapText(boolean wrapped) {
916
    public void setWrapText(boolean wrapped) {
480
        getCellAlignment().setWrapText(wrapped);
917
        getCellAlignment().setWrapText(wrapped);
481
    }
918
    }
Lines 483-493 Link Here
483
    public XSSFColor getBorderColor(BorderSide side) {
920
    public XSSFColor getBorderColor(BorderSide side) {
484
        return getCellBorder().getBorderColor(side);
921
        return getCellBorder().getBorderColor(side);
485
    }
922
    }
486
923
    
924
    /**
925
     * set the color to use for the selected border
926
     * @param BorderSide - side where to apply the color definition
927
     * @param XSSFColor - color rgb value of the color definition
928
     */
487
    public void setBorderColor(BorderSide side, XSSFColor color) {
929
    public void setBorderColor(BorderSide side, XSSFColor color) {
488
        getCellBorder().setBorderColor(side, color);
930
        getCellBorder().setBorderColor(side, color);
489
    }
931
    }
490
    
932
    
933
    /**
934
     * get the cellBorder object border to use for manage borders
935
     * @return XSSFCellBorder - cell border
936
     */
491
    private XSSFCellBorder getCellBorder() {
937
    private XSSFCellBorder getCellBorder() {
492
        if (cellBorder == null) {
938
        if (cellBorder == null) {
493
            // TODO make a common Cell Border object
939
            // TODO make a common Cell Border object
Lines 505-518 Link Here
505
        return cellBorder;
951
        return cellBorder;
506
    }
952
    }
507
953
954
    /**
955
     * get the index of the border to use for this cell style.
956
     * return -1 if no border is defined. 
957
     * @return int - index of cell border
958
     */
508
    private int getBorderId() {
959
    private int getBorderId() {
509
        if (cellXf.isSetBorderId() && cellXf.getBorderId()>0) {
960
        if (cellXf.isSetBorderId() && cellXf.getBorderId()>0) {
510
            return (int) cellXf.getBorderId();
961
            return (int) cellXf.getBorderId();
511
        }
962
        }
512
        return -1;
963
        return -1;
513
      //  return (int) cellStyleXf.getBorderId();
514
    }
964
    }
515
    
965
    
966
    /**
967
     * get the cellFill object to use for manage fill 
968
     * @return XSSFCellFill - cell fill
969
     */
516
    private XSSFCellFill getCellFill() {
970
    private XSSFCellFill getCellFill() {
517
	if (cellFill == null) {
971
	if (cellFill == null) {
518
	    int fillId=getFillId();
972
	    int fillId=getFillId();
Lines 529-542 Link Here
529
	return cellFill;
983
	return cellFill;
530
    }
984
    }
531
985
986
    /**
987
     * get the index of the fill to use for this cell style.
988
     * return -1 if no fill is defined. 
989
     * @return int - index of cell fill
990
     */
532
    private int getFillId() {
991
    private int getFillId() {
533
        if (cellXf.isSetFillId() && cellXf.getFillId()>0) {
992
        if (cellXf.isSetFillId() && cellXf.getFillId()>0) {
534
            return (int) cellXf.getFillId();
993
            return (int) cellXf.getFillId();
535
        }
994
        }
536
        //return (int) cellStyleXf.getFillId();
537
        return -1; 
995
        return -1; 
538
    }
996
    }
539
997
998
    /**
999
     * get the index of the font to use for this cell style. 
1000
     * @return int - index of font
1001
     */
540
    private int getFontId() {
1002
    private int getFontId() {
541
        if (cellXf.isSetFontId()) {
1003
        if (cellXf.isSetFontId()) {
542
            return (int) cellXf.getFontId();
1004
            return (int) cellXf.getFontId();
Lines 544-549 Link Here
544
        return (int) cellStyleXf.getFontId();
1006
        return (int) cellStyleXf.getFontId();
545
    }
1007
    }
546
1008
1009
    /**
1010
     * get a cellProtection from the supplied XML definition
1011
     * @return CTCellProtection
1012
     */
547
    private CTCellProtection getCellProtection() {
1013
    private CTCellProtection getCellProtection() {
548
        if (cellXf.getProtection() == null) {
1014
        if (cellXf.getProtection() == null) {
549
            cellXf.addNewProtection();
1015
            cellXf.addNewProtection();
Lines 551-556 Link Here
551
        return cellXf.getProtection();
1017
        return cellXf.getProtection();
552
    }
1018
    }
553
1019
1020
    /**
1021
     * get the cellAlignment object to use for manage alignment 
1022
     * @return XSSFCellAlignment - cell alignment
1023
     */
554
    public XSSFCellAlignment getCellAlignment() {
1024
    public XSSFCellAlignment getCellAlignment() {
555
        if (this.cellAlignment == null) {
1025
        if (this.cellAlignment == null) {
556
            this.cellAlignment = new XSSFCellAlignment(getCTCellAlignment());
1026
            this.cellAlignment = new XSSFCellAlignment(getCTCellAlignment());
Lines 558-588 Link Here
558
        return this.cellAlignment;
1028
        return this.cellAlignment;
559
    }
1029
    }
560
1030
1031
1032
    /**
1033
     * Return the CTCellAlignment instance for alignment 
1034
     *
1035
     * @return CTCellAlignment 
1036
     */
561
    private CTCellAlignment getCTCellAlignment() {
1037
    private CTCellAlignment getCTCellAlignment() {
562
        if (cellXf.getAlignment() == null) {
1038
	if (cellXf.getAlignment() == null) {
563
            cellXf.setAlignment(CTCellAlignment.Factory.newInstance());
1039
	    cellXf.setAlignment(CTCellAlignment.Factory.newInstance());
564
        }
1040
	}
565
        return cellXf.getAlignment();
1041
	return cellXf.getAlignment();
566
    }
1042
    }
567
1043
    
1044
    /**
1045
     * get the index of the color to use for the border side specified.
1046
     * @parameter BorderSie -side 
1047
     * @return short - index of color
1048
     */
568
    private short getBorderColorIndexed(BorderSide side) {
1049
    private short getBorderColorIndexed(BorderSide side) {
569
        return (short) getBorderColor(side).getIndexed();
1050
        return (short) getBorderColor(side).getIndexed();
570
    }
1051
    }
571
1052
1053
    /**
1054
     * set the index of the color to use for the border side specified.
1055
     * @parameter BorderSide -side
1056
     * @parameter int - color 
1057
     * @see IndexedColors
1058
     */
572
    private void setBorderColorIndexed(BorderSide side, int color) {
1059
    private void setBorderColorIndexed(BorderSide side, int color) {
573
        getBorderColor(side).setIndexed(color);
1060
        getBorderColor(side).setIndexed(color);
574
    }
1061
    }
575
1062
    
576
    private short getBorderStyleAsShort(BorderSide side) {
1063
    /**
577
        return (short) (getBorderStyle(side).intValue() - 1);
1064
     * get the BorderStyle enum for the border side specified.
1065
     * @parameter BorderSide -side 
1066
     * @return BorderStyle - index of color
1067
     */
1068
    private BorderStyle getBorderStyleEnum(BorderSide side) {
1069
        return getCellBorder().getBorderStyle(side);
578
    }
1070
    }
579
1071
    
1072
    /**
1073
     * get the BorderStyle enum for the border side specified.
1074
     * @parameter BorderSie -side 
1075
     * @return short - index of color
1076
     */
580
    private String getBorderStyleAsString(BorderSide side) {
1077
    private String getBorderStyleAsString(BorderSide side) {
581
        return getBorderStyle(side).toString();
1078
        return getCellBorder().getBorderStyleAsString(side);
582
    }
1079
    }
1080
    
583
1081
584
    private STBorderStyle.Enum getBorderStyle(BorderSide side) {
585
        return getCellBorder().getBorderStyle(side);
586
    }
587
588
}
1082
}
(-)src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java (-20 / +20 lines)
Lines 86-94 Link Here
86
	public void testGetSetBorderBottom() {
86
	public void testGetSetBorderBottom() {
87
		ctBorderA.addNewBottom().setStyle(STBorderStyle.THIN);
87
		ctBorderA.addNewBottom().setStyle(STBorderStyle.THIN);
88
		assertEquals((short)1, cellStyle.getBorderBottom());
88
		assertEquals((short)1, cellStyle.getBorderBottom());
89
		cellStyle.setBorderBottom((short) 2);
89
		//cellStyle.setBorderBottom((short) 2);
90
		cellStyle.setBorderBottom(XSSFCellStyle.BORDER_THIN);
90
		assertEquals(STBorderStyle.THIN, ctBorderA.getBottom().getStyle());
91
		assertEquals(STBorderStyle.THIN, ctBorderA.getBottom().getStyle());
91
		cellStyle.setBorderBottomEnum(STBorderStyle.THICK);
92
		cellStyle.setBorderBottomEnum(BorderStyle.THICK);
92
		assertEquals(6, ctBorderA.getBottom().getStyle().intValue());
93
		assertEquals(6, ctBorderA.getBottom().getStyle().intValue());
93
	}
94
	}
94
95
Lines 100-108 Link Here
100
	public void testGetSetBorderRight() {
101
	public void testGetSetBorderRight() {
101
		ctBorderA.addNewRight().setStyle(STBorderStyle.MEDIUM);
102
		ctBorderA.addNewRight().setStyle(STBorderStyle.MEDIUM);
102
		assertEquals((short)2, cellStyle.getBorderRight());
103
		assertEquals((short)2, cellStyle.getBorderRight());
103
		cellStyle.setBorderRight((short) 2);
104
		cellStyle.setBorderRight(XSSFCellStyle.BORDER_THIN);
104
		assertEquals(STBorderStyle.THIN, ctBorderA.getRight().getStyle());
105
		assertEquals(STBorderStyle.THIN, ctBorderA.getRight().getStyle());
105
		cellStyle.setBorderRightEnum(STBorderStyle.THICK);
106
		cellStyle.setBorderRightEnum(BorderStyle.THICK);
106
		assertEquals(6, ctBorderA.getRight().getStyle().intValue());
107
		assertEquals(6, ctBorderA.getRight().getStyle().intValue());
107
	}
108
	}
108
109
Lines 114-122 Link Here
114
	public void testGetSetBorderLeft() {
115
	public void testGetSetBorderLeft() {
115
		ctBorderA.addNewLeft().setStyle(STBorderStyle.DASHED);
116
		ctBorderA.addNewLeft().setStyle(STBorderStyle.DASHED);
116
		assertEquals((short)3, cellStyle.getBorderLeft());
117
		assertEquals((short)3, cellStyle.getBorderLeft());
117
		cellStyle.setBorderLeft((short) 2);
118
		cellStyle.setBorderLeft(XSSFCellStyle.BORDER_THIN);
118
		assertEquals(STBorderStyle.THIN, ctBorderA.getLeft().getStyle());
119
		assertEquals(STBorderStyle.THIN, ctBorderA.getLeft().getStyle());
119
		cellStyle.setBorderLeftEnum(STBorderStyle.THICK);
120
		cellStyle.setBorderLeftEnum(BorderStyle.THICK);
120
		assertEquals(6, ctBorderA.getLeft().getStyle().intValue());
121
		assertEquals(6, ctBorderA.getLeft().getStyle().intValue());
121
	}
122
	}
122
123
Lines 128-136 Link Here
128
	public void testGetSetBorderTop() {
129
	public void testGetSetBorderTop() {
129
		ctBorderA.addNewTop().setStyle(STBorderStyle.HAIR);
130
		ctBorderA.addNewTop().setStyle(STBorderStyle.HAIR);
130
		assertEquals((short)7, cellStyle.getBorderTop());
131
		assertEquals((short)7, cellStyle.getBorderTop());
131
		cellStyle.setBorderTop((short) 2);
132
		cellStyle.setBorderTop(XSSFCellStyle.BORDER_THIN);
132
		assertEquals(STBorderStyle.THIN, ctBorderA.getTop().getStyle());
133
		assertEquals(STBorderStyle.THIN, ctBorderA.getTop().getStyle());
133
		cellStyle.setBorderTopEnum(STBorderStyle.THICK);
134
		cellStyle.setBorderTopEnum(BorderStyle.THICK);
134
		assertEquals(6, ctBorderA.getTop().getStyle().intValue());
135
		assertEquals(6, ctBorderA.getTop().getStyle().intValue());
135
	}
136
	}
136
137
Lines 291-308 Link Here
291
	}
292
	}
292
	
293
	
293
294
294
	public void testGetFillPattern() {
295
	public void testGetSetFillPattern() {
295
296
	    CTPatternFill ctPattern=ctFill.addNewPatternFill();
296
		CTPatternFill ctPatternFill = ctFill.addNewPatternFill();
297
	    ctPattern.setPatternType(STPatternType.DARK_HORIZONTAL);
297
		ctPatternFill.setPatternType(STPatternType.DARK_DOWN);
298
	    XSSFCellFill cellFill=new XSSFCellFill(ctFill);
298
		XSSFCellFill cellFill=new XSSFCellFill(ctFill);
299
	    long index=stylesTable.putFill(cellFill);
299
		long index=stylesTable.putFill(cellFill);
300
	    cellStyle.getCoreXf().setFillId(index);
300
		cellStyle.getCoreXf().setFillId(index);
301
	    assertEquals(CellStyle.THICK_HORZ_BANDS, cellStyle.getFillPattern());
301
	
302
	    
302
		assertEquals(CellStyle.THICK_FORWARD_DIAG, cellStyle.getFillPattern());
303
	    cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
303
		
304
	    assertEquals(FillPatternType.SOLID_FOREGROUND,cellFill.getPatternType());
304
		cellStyle.setFillPattern(CellStyle.BRICKS);
305
	    assertEquals(STPatternType.SOLID,cellFill.getCTFill().getPatternFill().getPatternType());
305
		assertEquals(STPatternType.INT_DARK_TRELLIS,ctPatternFill.getPatternType().intValue());
306
	}
306
	}
307
307
308
	public void testGetFont() {
308
	public void testGetFont() {
(-)src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFBorder.java (-7 / +13 lines)
Lines 17-31 Link Here
17
17
18
package org.apache.poi.xssf.usermodel.extensions;
18
package org.apache.poi.xssf.usermodel.extensions;
19
19
20
import junit.framework.TestCase;
21
22
import org.apache.poi.xssf.usermodel.BorderStyle;
20
import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder.BorderSide;
23
import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder.BorderSide;
21
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder;
24
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder;
22
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr;
25
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr;
23
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet;
26
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet;
24
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STBorderStyle;
27
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STBorderStyle;
25
28
26
import junit.framework.TestCase;
27
29
28
29
public class TestXSSFBorder extends TestCase {
30
public class TestXSSFBorder extends TestCase {
30
	
31
	
31
	public void testGetBorderStyle() {
32
	public void testGetBorderStyle() {
Lines 34-48 Link Here
34
		CTBorderPr top = border.addNewTop();
35
		CTBorderPr top = border.addNewTop();
35
		CTBorderPr right = border.addNewRight();
36
		CTBorderPr right = border.addNewRight();
36
		CTBorderPr bottom = border.addNewBottom();
37
		CTBorderPr bottom = border.addNewBottom();
38
		
37
		top.setStyle(STBorderStyle.DASH_DOT);
39
		top.setStyle(STBorderStyle.DASH_DOT);
38
		right.setStyle(STBorderStyle.NONE);
40
		right.setStyle(STBorderStyle.NONE);
39
		bottom.setStyle(STBorderStyle.THIN);
41
		bottom.setStyle(STBorderStyle.THIN);
42
		
40
		XSSFCellBorder cellBorderStyle = new XSSFCellBorder(border);
43
		XSSFCellBorder cellBorderStyle = new XSSFCellBorder(border);
41
		assertEquals("dashDot", cellBorderStyle.getBorderStyle(BorderSide.TOP).toString());
44
		assertEquals("DASH_DOT", cellBorderStyle.getBorderStyle(BorderSide.TOP).toString());
42
		assertEquals("none", cellBorderStyle.getBorderStyle(BorderSide.RIGHT).toString());
45
		
43
		assertEquals(1, cellBorderStyle.getBorderStyle(BorderSide.RIGHT).intValue());
46
		assertEquals("NONE", cellBorderStyle.getBorderStyle(BorderSide.RIGHT).toString());
44
		assertEquals("thin", cellBorderStyle.getBorderStyle(BorderSide.BOTTOM).toString());
47
		assertEquals(BorderStyle.NONE.ordinal(), cellBorderStyle.getBorderStyle(BorderSide.RIGHT).ordinal());
45
		assertEquals(2, cellBorderStyle.getBorderStyle(BorderSide.BOTTOM).intValue());
48
		
49
		assertEquals("THIN", cellBorderStyle.getBorderStyle(BorderSide.BOTTOM).toString());
50
		
51
		assertEquals(BorderStyle.THIN.ordinal(), cellBorderStyle.getBorderStyle(BorderSide.BOTTOM).ordinal());
46
	}
52
	}
47
	
53
	
48
}
54
}
(-)src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java (-3 / +4 lines)
Lines 18-23 Link Here
18
package org.apache.poi.xssf.usermodel.extensions;
18
package org.apache.poi.xssf.usermodel.extensions;
19
19
20
20
21
import org.apache.poi.xssf.usermodel.FillPatternType;
21
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor;
22
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor;
22
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill;
23
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill;
23
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPatternFill;
24
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPatternFill;
Lines 48-58 Link Here
48
		assertEquals(8, cellFill.getFillForegroundColor().getIndexed());
49
		assertEquals(8, cellFill.getFillForegroundColor().getIndexed());
49
	}
50
	}
50
	
51
	
51
	public void testGetPatternType() {
52
	public void testGetSetPatternType() {
52
		CTFill ctFill = CTFill.Factory.newInstance();
53
		CTFill ctFill = CTFill.Factory.newInstance();
53
		XSSFCellFill cellFill = new XSSFCellFill(ctFill);
54
		XSSFCellFill cellFill = new XSSFCellFill(ctFill);
54
		CTPatternFill ctPatternFill = ctFill.addNewPatternFill();
55
		CTPatternFill ctPatternFill = ctFill.addNewPatternFill();
55
		ctPatternFill.setPatternType(STPatternType.DARK_DOWN);
56
		ctPatternFill.setPatternType(STPatternType.SOLID);
56
		assertEquals(8, cellFill.getPatternType().intValue());
57
		assertEquals(FillPatternType.SOLID_FOREGROUND.ordinal(), cellFill.getPatternType().ordinal());
57
	}
58
	}
58
}
59
}

Return to bug 45942