Browse Source

Apply patch from bug 55341

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1527397 13f79535-47bb-0310-9956-ffa450edef68
tags/REL_3_10_FINAL
Dominik Stadler 10 years ago
parent
commit
927dc0ce1d

+ 2
- 2
src/java/org/apache/poi/ss/usermodel/CellStyle.java View File

@@ -113,7 +113,7 @@ public interface CellStyle {
* dot border
*/

public final static short BORDER_HAIR = 0x4;
public final static short BORDER_HAIR = 0x7;

/**
* Thick border
@@ -131,7 +131,7 @@ public interface CellStyle {
* hair-line border
*/

public final static short BORDER_DOTTED = 0x7;
public final static short BORDER_DOTTED = 0x4;

/**
* Medium dashed border

+ 130
- 0
src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java View File

@@ -229,6 +229,136 @@ public class TestXSSFCellStyle extends TestCase {
assertFalse(ctBorder.isSetTop());
}

public void testGetSetBorderThin() {
cellStyle.setBorderTop(CellStyle.BORDER_THIN);
assertEquals(CellStyle.BORDER_THIN, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertTrue(borderId > 0);
//check changes in the underlying xml bean
CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
assertEquals(STBorderStyle.THIN, ctBorder.getTop().getStyle());
}
public void testGetSetBorderMedium() {
cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM);
assertEquals(CellStyle.BORDER_MEDIUM, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertTrue(borderId > 0);
//check changes in the underlying xml bean
CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
assertEquals(STBorderStyle.MEDIUM, ctBorder.getTop().getStyle());
}
public void testGetSetBorderThick() {
cellStyle.setBorderTop(CellStyle.BORDER_THICK);
assertEquals(CellStyle.BORDER_THICK, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertTrue(borderId > 0);
//check changes in the underlying xml bean
CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
assertEquals(STBorderStyle.THICK, ctBorder.getTop().getStyle());
}
public void testGetSetBorderHair() {
cellStyle.setBorderTop(CellStyle.BORDER_HAIR);
assertEquals(CellStyle.BORDER_HAIR, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertTrue(borderId > 0);
//check changes in the underlying xml bean
CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
assertEquals(STBorderStyle.HAIR, ctBorder.getTop().getStyle());
}
public void testGetSetBorderDotted() {
cellStyle.setBorderTop(CellStyle.BORDER_DOTTED);
assertEquals(CellStyle.BORDER_DOTTED, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertTrue(borderId > 0);
//check changes in the underlying xml bean
CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
assertEquals(STBorderStyle.DOTTED, ctBorder.getTop().getStyle());
}
public void testGetSetBorderDashed() {
cellStyle.setBorderTop(CellStyle.BORDER_DASHED);
assertEquals(CellStyle.BORDER_DASHED, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertTrue(borderId > 0);
//check changes in the underlying xml bean
CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
assertEquals(STBorderStyle.DASHED, ctBorder.getTop().getStyle());
}
public void testGetSetBorderDashDot() {
cellStyle.setBorderTop(CellStyle.BORDER_DASH_DOT);
assertEquals(CellStyle.BORDER_DASH_DOT, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertTrue(borderId > 0);
//check changes in the underlying xml bean
CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
assertEquals(STBorderStyle.DASH_DOT, ctBorder.getTop().getStyle());
}
public void testGetSetBorderDashDotDot() {
cellStyle.setBorderTop(CellStyle.BORDER_DASH_DOT_DOT);
assertEquals(CellStyle.BORDER_DASH_DOT_DOT, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertTrue(borderId > 0);
//check changes in the underlying xml bean
CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
assertEquals(STBorderStyle.DASH_DOT_DOT, ctBorder.getTop().getStyle());
}
public void testGetSetBorderMediumDashDot() {
cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASH_DOT);
assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertTrue(borderId > 0);
//check changes in the underlying xml bean
CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
assertEquals(STBorderStyle.MEDIUM_DASH_DOT, ctBorder.getTop().getStyle());
}
public void testGetSetBorderMediumDashDotDot() {
cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASH_DOT_DOT);
assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT_DOT, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertTrue(borderId > 0);
//check changes in the underlying xml bean
CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
assertEquals(STBorderStyle.MEDIUM_DASH_DOT_DOT, ctBorder.getTop().getStyle());
}
public void testGetSetBorderMediumDashed() {
cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASHED);
assertEquals(CellStyle.BORDER_MEDIUM_DASHED, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertTrue(borderId > 0);
//check changes in the underlying xml bean
CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
assertEquals(STBorderStyle.MEDIUM_DASHED, ctBorder.getTop().getStyle());
}
public void testGetSetBorderSlantDashDot() {
cellStyle.setBorderTop(CellStyle.BORDER_SLANTED_DASH_DOT);
assertEquals(CellStyle.BORDER_SLANTED_DASH_DOT, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertTrue(borderId > 0);
//check changes in the underlying xml bean
CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
assertEquals(STBorderStyle.SLANT_DASH_DOT, ctBorder.getTop().getStyle());
}
public void testGetSetBorderDouble() {
cellStyle.setBorderTop(CellStyle.BORDER_DOUBLE);
assertEquals(CellStyle.BORDER_DOUBLE, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertTrue(borderId > 0);
//check changes in the underlying xml bean
CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
assertEquals(STBorderStyle.DOUBLE, ctBorder.getTop().getStyle());
}
public void testGetSetBottomBorderColor() {
//defaults
assertEquals(IndexedColors.BLACK.getIndex(), cellStyle.getBottomBorderColor());

+ 48
- 4
src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java View File

@@ -17,16 +17,18 @@

package org.apache.poi.hssf.usermodel;

import junit.framework.TestCase;
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.util.TempFile;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;

import junit.framework.TestCase;

import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.util.TempFile;

/**
* Class to test cell styling functionality
*
@@ -331,5 +333,47 @@ public final class TestCellStyle extends TestCase {
c4.setCellStyle(cs2);
assertEquals("style1", c4.getCellStyle().getParentStyle().getUserStyleName());
}
public void testGetSetBorderHair() {
HSSFWorkbook wb = openSample("55341_CellStyleBorder.xls");
HSSFSheet s = wb.getSheetAt(0);
HSSFCellStyle cs;
cs = s.getRow(0).getCell(0).getCellStyle();
assertEquals(CellStyle.BORDER_HAIR, cs.getBorderRight());
cs = s.getRow(1).getCell(1).getCellStyle();
assertEquals(CellStyle.BORDER_DOTTED, cs.getBorderRight());
cs = s.getRow(2).getCell(2).getCellStyle();
assertEquals(CellStyle.BORDER_DASH_DOT_DOT, cs.getBorderRight());
cs = s.getRow(3).getCell(3).getCellStyle();
assertEquals(CellStyle.BORDER_DASHED, cs.getBorderRight());
cs = s.getRow(4).getCell(4).getCellStyle();
assertEquals(CellStyle.BORDER_THIN, cs.getBorderRight());
cs = s.getRow(5).getCell(5).getCellStyle();
assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT_DOT, cs.getBorderRight());
cs = s.getRow(6).getCell(6).getCellStyle();
assertEquals(CellStyle.BORDER_SLANTED_DASH_DOT, cs.getBorderRight());
cs = s.getRow(7).getCell(7).getCellStyle();
assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT, cs.getBorderRight());
cs = s.getRow(8).getCell(8).getCellStyle();
assertEquals(CellStyle.BORDER_MEDIUM_DASHED, cs.getBorderRight());
cs = s.getRow(9).getCell(9).getCellStyle();
assertEquals(CellStyle.BORDER_MEDIUM, cs.getBorderRight());
cs = s.getRow(10).getCell(10).getCellStyle();
assertEquals(CellStyle.BORDER_THICK, cs.getBorderRight());
cs = s.getRow(11).getCell(11).getCellStyle();
assertEquals(CellStyle.BORDER_DOUBLE, cs.getBorderRight());
}

}

BIN
test-data/spreadsheet/55341_CellStyleBorder.xls View File


Loading…
Cancel
Save