diff options
author | Dominik Stadler <centic@apache.org> | 2024-03-14 13:20:47 +0000 |
---|---|---|
committer | Dominik Stadler <centic@apache.org> | 2024-03-14 13:20:47 +0000 |
commit | f4af02bb24abdfbd39e8a19e2114fadb6f6ef2fa (patch) | |
tree | 702e81d6772660459cc900fe7a2dec9c3c5bf10c /poi/src/main | |
parent | 08436ddf7fd8039118ff073b8dac02b4b5e67774 (diff) | |
download | poi-f4af02bb24abdfbd39e8a19e2114fadb6f6ef2fa.tar.gz poi-f4af02bb24abdfbd39e8a19e2114fadb6f6ef2fa.zip |
Bug 68778: Verify "ignoreMissingFontSystem" for SheetUtil.getDefaultCharWidthAsFloat()
This functionality saw some regressions at times and thus
should be verified via unit-tests.
We can simulate failures in the low-level font-system by
mocking the FontRenderContext and triggering exceptions
from there.
This hopefully now verifies behavior of
SheetUtil.getDefaultCharWidthAsFloat() both with
"ignoreMissingFontSystem" enabled and disabled.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1916297 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi/src/main')
-rw-r--r-- | poi/src/main/java/org/apache/poi/ss/util/SheetUtil.java | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/poi/src/main/java/org/apache/poi/ss/util/SheetUtil.java b/poi/src/main/java/org/apache/poi/ss/util/SheetUtil.java index cc5abe81b1..f90d229895 100644 --- a/poi/src/main/java/org/apache/poi/ss/util/SheetUtil.java +++ b/poi/src/main/java/org/apache/poi/ss/util/SheetUtil.java @@ -96,13 +96,13 @@ public class SheetUtil { /** * drawing context to measure text */ - private static final FontRenderContext fontRenderContext = new FontRenderContext(null, true, true); + private static FontRenderContext fontRenderContext = new FontRenderContext(null, true, true); /** * A system property which can be enabled to not fail when the * font-system is not available on the current machine */ - private static final boolean ignoreMissingFontSystem = + private static boolean ignoreMissingFontSystem = Boolean.parseBoolean(System.getProperty("org.apache.poi.ss.ignoreMissingFontSystem")); /** @@ -490,4 +490,21 @@ public class SheetUtil { // live within any merged regions return null; } + + // Getters/Setters are available to allow in-depth testing + protected static boolean isIgnoreMissingFontSystem() { + return ignoreMissingFontSystem; + } + + protected static void setIgnoreMissingFontSystem(boolean value) { + ignoreMissingFontSystem = value; + } + + protected static FontRenderContext getFontRenderContext() { + return fontRenderContext; + } + + protected static void setFontRenderContext(FontRenderContext fontRenderContext) { + SheetUtil.fontRenderContext = fontRenderContext; + } } |