From 79e5e6ae16fcd9b6abab8922c59dc03beb82bbd7 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Thu, 30 Jan 2025 22:29:43 +0000 Subject: [PATCH] allow users supply a SheetUtil failover function git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1923467 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/ss/util/SheetUtil.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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 a6cabf543b..633a785b93 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 @@ -26,7 +26,6 @@ import java.text.AttributedString; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.function.BiFunction; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellStyle; @@ -369,6 +368,16 @@ public class SheetUtil { } } + /** + * A function with 5 inputs and a return value. + * @param the type of the first input to the function + * @param the type of the second input to the function + * @param the type of the third input to the function + * @param the type of the fourth input to the function + * @param the type of the fifth input to the function + * @param the return type of the function + * @since POI 5.4.1 + */ @FunctionalInterface public interface Function5Arity { R apply(A a, B b, C c, D d, E e); @@ -380,6 +389,15 @@ public class SheetUtil { private static Function5Arity FAILOVER_FUNCTION = DEFAULT_FAILOVER_FUNCTION; + /** + * Define a function to be used as a failover when the font system is not available. + * This function will be called with the default character width, the colspan, the cell style, + * the minimum width and the attributed string of the cell. + *

+ * The default function will return the default character width. + *

+ * @since POI 5.4.1 + */ public static void setFailoverFunction(Function5Arity failoverFunction) { FAILOVER_FUNCTION = failoverFunction == null ? DEFAULT_FAILOVER_FUNCTION : failoverFunction; }