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

(-)src/java/org/apache/poi/ss/util/SheetUtil.java (-1 / +1 lines)
Lines 275-281 Link Here
275
     * @param font The Font that is used in the Cell
275
     * @param font The Font that is used in the Cell
276
     * @return true if computing the size for this Font will succeed, false otherwise
276
     * @return true if computing the size for this Font will succeed, false otherwise
277
     */
277
     */
278
    public static boolean canComputeColumnWidht(Font font) {
278
    public static boolean canComputeColumnWidth(Font font) {
279
        // not sure what is the best value sample-here, only "1" did not work on some platforms...
279
        // not sure what is the best value sample-here, only "1" did not work on some platforms...
280
        AttributedString str = new AttributedString("1w");
280
        AttributedString str = new AttributedString("1w");
281
        copyAttributes(font, str, 0, "1w".length());
281
        copyAttributes(font, str, 0, "1w".length());
(-)src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java (-2 / +2 lines)
Lines 299-305 Link Here
299
        Workbook wb = new XSSFWorkbook();
299
        Workbook wb = new XSSFWorkbook();
300
300
301
        // cannot check on result because on some machines we get back false here!
301
        // cannot check on result because on some machines we get back false here!
302
        SheetUtil.canComputeColumnWidht(wb.getFontAt((short)0));
302
        SheetUtil.canComputeColumnWidth(wb.getFontAt((short)0));
303
303
304
        wb.close();        
304
        wb.close();        
305
    }
305
    }
Lines 310-315 Link Here
310
        font.setFontName("some non existing font name");
310
        font.setFontName("some non existing font name");
311
        
311
        
312
        // Even with invalid fonts we still get back useful data most of the time... 
312
        // Even with invalid fonts we still get back useful data most of the time... 
313
        SheetUtil.canComputeColumnWidht(font);
313
        SheetUtil.canComputeColumnWidth(font);
314
    }
314
    }
315
}
315
}
(-)src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java (-2 / +2 lines)
Lines 381-387 Link Here
381
        // autoSize will fail if required fonts are not installed, skip this test then
381
        // autoSize will fail if required fonts are not installed, skip this test then
382
        Font font = wb.getFontAt(cell0.getCellStyle().getFontIndex());
382
        Font font = wb.getFontAt(cell0.getCellStyle().getFontIndex());
383
        Assume.assumeTrue("Cannot verify autoSizeColumn() because the necessary Fonts are not installed on this machine: " + font,
383
        Assume.assumeTrue("Cannot verify autoSizeColumn() because the necessary Fonts are not installed on this machine: " + font,
384
                SheetUtil.canComputeColumnWidht(font));
384
                SheetUtil.canComputeColumnWidth(font));
385
385
386
        assertEquals("Expecting no indentation in this test",
386
        assertEquals("Expecting no indentation in this test",
387
                0, cell0.getCellStyle().getIndention());
387
                0, cell0.getCellStyle().getIndention());
Lines 399-405 Link Here
399
        double widthBeforeCol = SheetUtil.getColumnWidth(sheet, 0, false);
399
        double widthBeforeCol = SheetUtil.getColumnWidth(sheet, 0, false);
400
400
401
        String info = widthManual + "/" + widthBeforeCell + "/" + widthBeforeCol + "/" +
401
        String info = widthManual + "/" + widthBeforeCell + "/" + widthBeforeCol + "/" +
402
                        SheetUtil.canComputeColumnWidht(font) + "/" + computeCellWidthFixed(font, "1") + "/" + computeCellWidthFixed(font, "w") + "/" +
402
                        SheetUtil.canComputeColumnWidth(font) + "/" + computeCellWidthFixed(font, "1") + "/" + computeCellWidthFixed(font, "w") + "/" +
403
                        computeCellWidthFixed(font, "1w") + "/" + computeCellWidthFixed(font, "0000") + "/" + computeCellWidthFixed(font, longValue);
403
                        computeCellWidthFixed(font, "1w") + "/" + computeCellWidthFixed(font, "0000") + "/" + computeCellWidthFixed(font, longValue);
404
        assertTrue("Expected to have cell width > 0 when computing manually, but had " + info, widthManual > 0);
404
        assertTrue("Expected to have cell width > 0 when computing manually, but had " + info, widthManual > 0);
405
        assertTrue("Expected to have cell width > 0 BEFORE auto-size, but had " + info, widthBeforeCell > 0);
405
        assertTrue("Expected to have cell width > 0 BEFORE auto-size, but had " + info, widthBeforeCell > 0);
(-)src/testcases/org/apache/poi/ss/util/TestSheetUtil.java (-1 / +1 lines)
Lines 72-78 Link Here
72
        Workbook wb = new HSSFWorkbook();
72
        Workbook wb = new HSSFWorkbook();
73
        
73
        
74
        // cannot check on result because on some machines we get back false here!
74
        // cannot check on result because on some machines we get back false here!
75
        SheetUtil.canComputeColumnWidht(wb.getFontAt((short)0));
75
        SheetUtil.canComputeColumnWidth(wb.getFontAt((short)0));
76
76
77
        wb.close();        
77
        wb.close();        
78
    }
78
    }

Return to bug 58576