This is an automated email from the ASF dual-hosted git repository.
fanningpj pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi.git
The following commit(s) were added to refs/heads/trunk by this push:
new 05f37a5204 refactor SheetUtil code
05f37a5204 is described below
commit 05f37a5204aa5995999df495cb91ca65066ca692
Author: PJ Fanning <[email protected]>
AuthorDate: Tue Sep 30 10:03:39 2025 +0100
refactor SheetUtil code
---
poi/src/main/java/org/apache/poi/ss/util/SheetUtil.java | 14 +++++++-------
1 file changed, 7 insertions(+), 7 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 312913a84d..cf3525005a 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
@@ -209,7 +209,7 @@ public class SheetUtil {
String txt = line + defaultChar;
AttributedString str = new AttributedString(txt);
- WithJavaDesktop.copyAttributes(font, str, 0, txt.length());
+ WithJavaDesktop.modifyAttributedString(str, font, 0,
txt.length());
/*if (rt.numFormattingRuns() > 0) {
// TODO: support rich text fragments
@@ -233,7 +233,7 @@ public class SheetUtil {
if(sval != null) {
String txt = sval + defaultChar;
AttributedString str = new AttributedString(txt);
- WithJavaDesktop.copyAttributes(font, str, 0, txt.length());
+ WithJavaDesktop.modifyAttributedString(str, font, 0,
txt.length());
width = WithJavaDesktop.getCellWidth(defaultCharWidth,
colspan, style, width, str);
}
@@ -299,19 +299,19 @@ public class SheetUtil {
/**
* Copy text attributes from the supplied Font to Java2D
AttributedString
*/
- private static void copyAttributes(Font font, AttributedString str,
@SuppressWarnings("SameParameterValue") int startIdx, int endIdx) {
+ private static void modifyAttributedString(AttributedString str, Font
font, final int startIdx, final int endIdx) {
str.addAttribute(TextAttribute.FAMILY, font.getFontName(),
startIdx, endIdx);
- str.addAttribute(TextAttribute.SIZE,
(float)font.getFontHeightInPoints());
+ str.addAttribute(TextAttribute.SIZE, (float)
font.getFontHeightInPoints());
if (font.getBold()) str.addAttribute(TextAttribute.WEIGHT,
TextAttribute.WEIGHT_BOLD, startIdx, endIdx);
if (font.getItalic() ) str.addAttribute(TextAttribute.POSTURE,
TextAttribute.POSTURE_OBLIQUE, startIdx, endIdx);
if (font.getUnderline() == Font.U_SINGLE )
str.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON, startIdx,
endIdx);
}
private static boolean canComputeColumnWidth(Font font,
AttributedString str) {
- copyAttributes(font, str, 0, "1w".length());
+ modifyAttributedString(str, font, 0, "1w".length());
TextLayout layout = new TextLayout(str.getIterator(),
fontRenderContext);
- return (layout.getBounds().getWidth() > 0);
+ return layout.getBounds().getWidth() > 0;
}
}
@@ -383,7 +383,7 @@ public class SheetUtil {
AttributedString str = new
AttributedString(String.valueOf(defaultChar));
try {
- WithJavaDesktop.copyAttributes(defaultFont, str, 0, 1);
+ WithJavaDesktop.modifyAttributedString(str, defaultFont, 0, 1);
return WithJavaDesktop.getDefaultCharWidthAsFloat(str);
} catch (Throwable t) {
if (shouldIgnoreMissingFontSystem(t)) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]