]> source.dussan.org Git - poi.git/commitdiff
add test case for bug 53564
authorJaven O'Neal <onealj@apache.org>
Tue, 19 Jul 2016 10:08:50 +0000 (10:08 +0000)
committerJaven O'Neal <onealj@apache.org>
Tue, 19 Jul 2016 10:08:50 +0000 (10:08 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1753359 13f79535-47bb-0310-9956-ffa450edef68

src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java

index 60e09ed2bfa6550cec7d1931e5276b2ad47d2420..466964acf35b7053993156772a68cccf3671ab79 100644 (file)
@@ -74,6 +74,7 @@ import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellStyle;
 import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.ClientAnchor.AnchorType;
+import org.apache.poi.ss.usermodel.ComparisonOperator;
 import org.apache.poi.ss.usermodel.DataFormatter;
 import org.apache.poi.ss.usermodel.FormulaEvaluator;
 import org.apache.poi.ss.usermodel.Name;
@@ -3036,4 +3037,48 @@ public final class TestBugs extends BaseTestBugzillaIssues {
         cmo = (CommonObjectDataSubRecord)shape.getObjRecord().getSubRecords().get(0);
         assertEquals(1027, cmo.getObjectId());
     }
+    
+    // As of POI 3.15 beta 2, LibreOffice does not display the diagonal border while it does display the bottom border
+    // I have not checked Excel to know if this is a LibreOffice or a POI problem.
+    @Test
+    public void test53564() throws IOException {
+        HSSFWorkbook wb = new HSSFWorkbook();
+        HSSFSheet sheet = wb.createSheet("Page 1");
+        final short BLUE = 30;
+        
+        HSSFSheetConditionalFormatting scf = sheet.getSheetConditionalFormatting();
+        HSSFConditionalFormattingRule rule = scf.createConditionalFormattingRule(ComparisonOperator.GT, "10");
+        
+        HSSFBorderFormatting bord = rule.createBorderFormatting();
+        bord.setBorderDiagonal(BorderStyle.THICK);
+        assertEquals(BorderStyle.THICK, bord.getBorderDiagonal());
+
+        bord.setBackwardDiagonalOn(true);
+        assertTrue(bord.isBackwardDiagonalOn());
+
+        bord.setForwardDiagonalOn(true);
+        assertTrue(bord.isForwardDiagonalOn());
+        
+        bord.setDiagonalBorderColor(BLUE);
+        assertEquals(BLUE, bord.getDiagonalBorderColor());
+
+        // Create the bottom border style so we know what a border is supposed to look like
+        bord.setBorderBottom(BorderStyle.THICK);
+        assertEquals(BorderStyle.THICK, bord.getBorderBottom());
+        bord.setBottomBorderColor(BLUE);
+        assertEquals(BLUE, bord.getBottomBorderColor());
+        
+        CellRangeAddress[] A2_D4 = {new CellRangeAddress(1, 3, 0, 3)};
+        scf.addConditionalFormatting(A2_D4, rule);
+        
+        // Set a cell value within the conditional formatting range whose rule would resolve to True.
+        Cell C3 = sheet.createRow(2).createCell(2);
+        C3.setCellValue(30.0);
+        
+        // Manually check the output file with Excel to see if the diagonal border is present
+        //OutputStream fos = new FileOutputStream("/tmp/53564.xls");
+        //wb.write(fos);
+        //fos.close();
+        wb.close();
+    }
 }