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

(-)src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java (+130 lines)
Lines 229-234 Link Here
229
        assertFalse(ctBorder.isSetTop());
229
        assertFalse(ctBorder.isSetTop());
230
	}
230
	}
231
231
232
	public void testGetSetBorderThin() {
233
        cellStyle.setBorderTop(CellStyle.BORDER_THIN);
234
        assertEquals(CellStyle.BORDER_THIN, cellStyle.getBorderTop());
235
        int borderId = (int)cellStyle.getCoreXf().getBorderId();
236
        assertTrue(borderId > 0);
237
        //check changes in the underlying xml bean
238
        CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
239
        assertEquals(STBorderStyle.THIN, ctBorder.getTop().getStyle());
240
	}
241
	
242
	public void testGetSetBorderMedium() {
243
        cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM);
244
        assertEquals(CellStyle.BORDER_MEDIUM, cellStyle.getBorderTop());
245
        int borderId = (int)cellStyle.getCoreXf().getBorderId();
246
        assertTrue(borderId > 0);
247
        //check changes in the underlying xml bean
248
        CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
249
        assertEquals(STBorderStyle.MEDIUM, ctBorder.getTop().getStyle());
250
	}
251
	
252
	public void testGetSetBorderThick() {
253
        cellStyle.setBorderTop(CellStyle.BORDER_THICK);
254
        assertEquals(CellStyle.BORDER_THICK, cellStyle.getBorderTop());
255
        int borderId = (int)cellStyle.getCoreXf().getBorderId();
256
        assertTrue(borderId > 0);
257
        //check changes in the underlying xml bean
258
        CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
259
        assertEquals(STBorderStyle.THICK, ctBorder.getTop().getStyle());
260
	}
261
	
262
	public void testGetSetBorderHair() {
263
        cellStyle.setBorderTop(CellStyle.BORDER_HAIR);
264
        assertEquals(CellStyle.BORDER_HAIR, cellStyle.getBorderTop());
265
        int borderId = (int)cellStyle.getCoreXf().getBorderId();
266
        assertTrue(borderId > 0);
267
        //check changes in the underlying xml bean
268
        CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
269
        assertEquals(STBorderStyle.HAIR, ctBorder.getTop().getStyle());
270
	}
271
	
272
	public void testGetSetBorderDotted() {
273
        cellStyle.setBorderTop(CellStyle.BORDER_DOTTED);
274
        assertEquals(CellStyle.BORDER_DOTTED, cellStyle.getBorderTop());
275
        int borderId = (int)cellStyle.getCoreXf().getBorderId();
276
        assertTrue(borderId > 0);
277
        //check changes in the underlying xml bean
278
        CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
279
        assertEquals(STBorderStyle.DOTTED, ctBorder.getTop().getStyle());
280
	}
281
	
282
	public void testGetSetBorderDashed() {
283
        cellStyle.setBorderTop(CellStyle.BORDER_DASHED);
284
        assertEquals(CellStyle.BORDER_DASHED, cellStyle.getBorderTop());
285
        int borderId = (int)cellStyle.getCoreXf().getBorderId();
286
        assertTrue(borderId > 0);
287
        //check changes in the underlying xml bean
288
        CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
289
        assertEquals(STBorderStyle.DASHED, ctBorder.getTop().getStyle());
290
	}
291
	
292
	public void testGetSetBorderDashDot() {
293
        cellStyle.setBorderTop(CellStyle.BORDER_DASH_DOT);
294
        assertEquals(CellStyle.BORDER_DASH_DOT, cellStyle.getBorderTop());
295
        int borderId = (int)cellStyle.getCoreXf().getBorderId();
296
        assertTrue(borderId > 0);
297
        //check changes in the underlying xml bean
298
        CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
299
        assertEquals(STBorderStyle.DASH_DOT, ctBorder.getTop().getStyle());
300
	}
301
	
302
	public void testGetSetBorderDashDotDot() {
303
        cellStyle.setBorderTop(CellStyle.BORDER_DASH_DOT_DOT);
304
        assertEquals(CellStyle.BORDER_DASH_DOT_DOT, cellStyle.getBorderTop());
305
        int borderId = (int)cellStyle.getCoreXf().getBorderId();
306
        assertTrue(borderId > 0);
307
        //check changes in the underlying xml bean
308
        CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
309
        assertEquals(STBorderStyle.DASH_DOT_DOT, ctBorder.getTop().getStyle());
310
	}
311
	
312
	public void testGetSetBorderMediumDashDot() {
313
        cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASH_DOT);
314
        assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT, cellStyle.getBorderTop());
315
        int borderId = (int)cellStyle.getCoreXf().getBorderId();
316
        assertTrue(borderId > 0);
317
        //check changes in the underlying xml bean
318
        CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
319
        assertEquals(STBorderStyle.MEDIUM_DASH_DOT, ctBorder.getTop().getStyle());
320
	}
321
	
322
	public void testGetSetBorderMediumDashDotDot() {
323
        cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASH_DOT_DOT);
324
        assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT_DOT, cellStyle.getBorderTop());
325
        int borderId = (int)cellStyle.getCoreXf().getBorderId();
326
        assertTrue(borderId > 0);
327
        //check changes in the underlying xml bean
328
        CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
329
        assertEquals(STBorderStyle.MEDIUM_DASH_DOT_DOT, ctBorder.getTop().getStyle());
330
	}
331
	
332
	public void testGetSetBorderMediumDashed() {
333
        cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASHED);
334
        assertEquals(CellStyle.BORDER_MEDIUM_DASHED, cellStyle.getBorderTop());
335
        int borderId = (int)cellStyle.getCoreXf().getBorderId();
336
        assertTrue(borderId > 0);
337
        //check changes in the underlying xml bean
338
        CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
339
        assertEquals(STBorderStyle.MEDIUM_DASHED, ctBorder.getTop().getStyle());
340
	}
341
	
342
	public void testGetSetBorderSlantDashDot() {
343
        cellStyle.setBorderTop(CellStyle.BORDER_SLANTED_DASH_DOT);
344
        assertEquals(CellStyle.BORDER_SLANTED_DASH_DOT, cellStyle.getBorderTop());
345
        int borderId = (int)cellStyle.getCoreXf().getBorderId();
346
        assertTrue(borderId > 0);
347
        //check changes in the underlying xml bean
348
        CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
349
        assertEquals(STBorderStyle.SLANT_DASH_DOT, ctBorder.getTop().getStyle());
350
	}
351
	
352
	public void testGetSetBorderDouble() {
353
        cellStyle.setBorderTop(CellStyle.BORDER_DOUBLE);
354
        assertEquals(CellStyle.BORDER_DOUBLE, cellStyle.getBorderTop());
355
        int borderId = (int)cellStyle.getCoreXf().getBorderId();
356
        assertTrue(borderId > 0);
357
        //check changes in the underlying xml bean
358
        CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
359
        assertEquals(STBorderStyle.DOUBLE, ctBorder.getTop().getStyle());
360
	}
361
	
232
	public void testGetSetBottomBorderColor() {
362
	public void testGetSetBottomBorderColor() {
233
        //defaults
363
        //defaults
234
        assertEquals(IndexedColors.BLACK.getIndex(), cellStyle.getBottomBorderColor());
364
        assertEquals(IndexedColors.BLACK.getIndex(), cellStyle.getBottomBorderColor());
(-)src/java/org/apache/poi/ss/usermodel/CellStyle.java (-2 / +2 lines)
Lines 113-119 Link Here
113
     * dot border
113
     * dot border
114
     */
114
     */
115
115
116
    public final static short BORDER_HAIR = 0x4;
116
    public final static short BORDER_HAIR = 0x7;
117
117
118
    /**
118
    /**
119
     * Thick border
119
     * Thick border
Lines 131-137 Link Here
131
     * hair-line border
131
     * hair-line border
132
     */
132
     */
133
133
134
    public final static short BORDER_DOTTED = 0x7;
134
    public final static short BORDER_DOTTED = 0x4;
135
135
136
    /**
136
    /**
137
     * Medium dashed border
137
     * Medium dashed border
(-)src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java (+44 lines)
Lines 18-24 Link Here
18
package org.apache.poi.hssf.usermodel;
18
package org.apache.poi.hssf.usermodel;
19
19
20
import junit.framework.TestCase;
20
import junit.framework.TestCase;
21
21
import org.apache.poi.hssf.HSSFTestDataSamples;
22
import org.apache.poi.hssf.HSSFTestDataSamples;
23
import org.apache.poi.ss.usermodel.CellStyle;
22
import org.apache.poi.util.TempFile;
24
import org.apache.poi.util.TempFile;
23
25
24
import java.io.File;
26
import java.io.File;
Lines 331-335 Link Here
331
        c4.setCellStyle(cs2);
333
        c4.setCellStyle(cs2);
332
        assertEquals("style1", c4.getCellStyle().getParentStyle().getUserStyleName());
334
        assertEquals("style1", c4.getCellStyle().getParentStyle().getUserStyleName());
333
    }
335
    }
336
    
337
	public void testGetSetBorderHair() {
338
        HSSFWorkbook wb = openSample("CellStyleBorder.xls");
339
        HSSFSheet s = wb.getSheetAt(0);
340
        HSSFCellStyle cs;
341
        
342
        cs = s.getRow(0).getCell(0).getCellStyle();
343
        assertEquals(CellStyle.BORDER_HAIR, cs.getBorderRight());
344
        
345
        cs = s.getRow(1).getCell(1).getCellStyle();
346
        assertEquals(CellStyle.BORDER_DOTTED, cs.getBorderRight());
347
348
        cs = s.getRow(2).getCell(2).getCellStyle();
349
        assertEquals(CellStyle.BORDER_DASH_DOT_DOT, cs.getBorderRight());
350
351
        cs = s.getRow(3).getCell(3).getCellStyle();
352
        assertEquals(CellStyle.BORDER_DASHED, cs.getBorderRight());
353
354
        cs = s.getRow(4).getCell(4).getCellStyle();
355
        assertEquals(CellStyle.BORDER_THIN, cs.getBorderRight());
356
357
        cs = s.getRow(5).getCell(5).getCellStyle();
358
        assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT_DOT, cs.getBorderRight());
359
360
        cs = s.getRow(6).getCell(6).getCellStyle();
361
        assertEquals(CellStyle.BORDER_SLANTED_DASH_DOT, cs.getBorderRight());
362
363
        cs = s.getRow(7).getCell(7).getCellStyle();
364
        assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT, cs.getBorderRight());
365
366
        cs = s.getRow(8).getCell(8).getCellStyle();
367
        assertEquals(CellStyle.BORDER_MEDIUM_DASHED, cs.getBorderRight());
368
369
        cs = s.getRow(9).getCell(9).getCellStyle();
370
        assertEquals(CellStyle.BORDER_MEDIUM, cs.getBorderRight());
371
372
        cs = s.getRow(10).getCell(10).getCellStyle();
373
        assertEquals(CellStyle.BORDER_THICK, cs.getBorderRight());
374
375
        cs = s.getRow(11).getCell(11).getCellStyle();
376
        assertEquals(CellStyle.BORDER_DOUBLE, cs.getBorderRight());
377
	}
334
378
335
}
379
}

Return to bug 55341