aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2015-07-22 14:03:11 +0000
committerDominik Stadler <centic@apache.org>2015-07-22 14:03:11 +0000
commitdd15c3bd37f517b93c097bd8a3c85bb8358b69e7 (patch)
treea933e29f795e4ce6329ee38a806bb8ec26fb0df5 /src
parentd438fcaf691ce1ca80bb6c63c371a6075c13535c (diff)
downloadpoi-dd15c3bd37f517b93c097bd8a3c85bb8358b69e7.tar.gz
poi-dd15c3bd37f517b93c097bd8a3c85bb8358b69e7.zip
Still more checks to track down why canComputeColumnWidth() returns true, but width is still returned 0 on freebsd...
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1692278 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
index a51e9f8fb8..e94a4d0253 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
@@ -372,11 +372,14 @@ public abstract class BaseTestBugzillaIssues {
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 BaseTestBugzillaIssues {
}
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 BaseTestBugzillaIssues {
}
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) {