You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ce...@apache.org on 2015/07/22 16:03:12 UTC

svn commit: r1692278 - /poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java

Author: centic
Date: Wed Jul 22 14:03:11 2015
New Revision: 1692278

URL: http://svn.apache.org/r1692278
Log:
Still more checks to track down why canComputeColumnWidth() returns true, but width is still returned 0 on freebsd...

Modified:
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java?rev=1692278&r1=1692277&r2=1692278&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java Wed Jul 22 14:03:11 2015
@@ -372,11 +372,14 @@ public abstract class BaseTestBugzillaIs
         double widthBeforeCell = SheetUtil.getCellWidth(cell0, 8, null, false);
         double widthBeforeCol = SheetUtil.getColumnWidth(sheet, 0, false);
 
-        assertTrue("Expected to have cell width > 0 when computing manually, but had " + widthManual + "/" + widthBeforeCell + "/" + widthBeforeCol, 
+        assertTrue("Expected to have cell width > 0 when computing manually, but had " + widthManual + "/" + widthBeforeCell + "/" + widthBeforeCol + "/" + 
+                SheetUtil.canComputeColumnWidht(font) + "/" + computeCellWidthFixed(cell0, font, "1") + "/" + computeCellWidthFixed(cell0, font, longValue), 
                 widthManual > 0);
-        assertTrue("Expected to have cell width > 0 BEFORE auto-size, but had " + widthManual + "/" + widthBeforeCell + "/" + widthBeforeCol, 
+        assertTrue("Expected to have cell width > 0 BEFORE auto-size, but had " + widthManual + "/" + widthBeforeCell + "/" + widthBeforeCol + "/"  + 
+                SheetUtil.canComputeColumnWidht(font) + "/" + computeCellWidthFixed(cell0, font, "1") + "/" + computeCellWidthFixed(cell0, font, longValue), 
                 widthBeforeCell > 0);
-        assertTrue("Expected to have column width > 0 BEFORE auto-size, but had " + widthManual + "/" + widthBeforeCell + "/" + widthBeforeCol, 
+        assertTrue("Expected to have column width > 0 BEFORE auto-size, but had " + widthManual + "/" + widthBeforeCell + "/" + widthBeforeCol + "/"  + 
+                SheetUtil.canComputeColumnWidht(font) + "/" + computeCellWidthFixed(cell0, font, "1") + "/" + computeCellWidthFixed(cell0, font, longValue), 
                 widthBeforeCol > 0);
 
         sheet.autoSizeColumn(0);
@@ -391,7 +394,6 @@ public abstract class BaseTestBugzillaIs
     }
 
     private double computeCellWidthManually(Cell cell0, Font font) {
-        double width;
         final FontRenderContext fontRenderContext = new FontRenderContext(null, true, true);        
         RichTextString rt = cell0.getRichStringCellValue();
         String[] lines = rt.getString().split("\\n");
@@ -406,8 +408,16 @@ public abstract class BaseTestBugzillaIs
         }
 
         TextLayout layout = new TextLayout(str.getIterator(), fontRenderContext);
-        width = ((layout.getBounds().getWidth() / 1) / 8);
-        return width;
+        return ((layout.getBounds().getWidth() / 1) / 8);
+    }
+
+    private double computeCellWidthFixed(Cell cell0, Font font, String txt) {
+        final FontRenderContext fontRenderContext = new FontRenderContext(null, true, true);        
+        AttributedString str = new AttributedString(txt);
+        copyAttributes(font, str, 0, txt.length());
+
+        TextLayout layout = new TextLayout(str.getIterator(), fontRenderContext);
+        return ((layout.getBounds().getWidth() / 1) / 8);
     }
 
     private static void copyAttributes(Font font, AttributedString str, int startIdx, int endIdx) {



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org