diff --git a/deployment/src/main/java/io/quarkiverse/poi/deployment/POIProcessor.java b/deployment/src/main/java/io/quarkiverse/poi/deployment/POIProcessor.java index 46f19c4..eba07e0 100644 --- a/deployment/src/main/java/io/quarkiverse/poi/deployment/POIProcessor.java +++ b/deployment/src/main/java/io/quarkiverse/poi/deployment/POIProcessor.java @@ -12,6 +12,7 @@ import io.quarkus.deployment.builditem.FeatureBuildItem; import io.quarkus.deployment.builditem.IndexDependencyBuildItem; import io.quarkus.deployment.builditem.NativeImageFeatureBuildItem; +import io.quarkus.deployment.builditem.SystemPropertyBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; class POIProcessor { @@ -34,6 +35,11 @@ void indexTransitiveDependencies(BuildProducer index) index.produce(new IndexDependencyBuildItem("org.apache.poi", "poi-ooxml-full")); } + @BuildStep + SystemPropertyBuildItem ignoreMissingFontSystem() { + return new SystemPropertyBuildItem("org.apache.poi.ss.ignoreMissingFontSystem", "true"); + } + @BuildStep void registerXMLBeansClassesForReflection(CombinedIndexBuildItem combinedIndexBuildItem, BuildProducer reflectiveClass) { diff --git a/runtime/src/main/java/io/quarkiverse/poi/runtime/graal/SheetUtilSubstitution.java b/runtime/src/main/java/io/quarkiverse/poi/runtime/graal/SheetUtilSubstitution.java new file mode 100644 index 0000000..0e4f35f --- /dev/null +++ b/runtime/src/main/java/io/quarkiverse/poi/runtime/graal/SheetUtilSubstitution.java @@ -0,0 +1,34 @@ +package io.quarkiverse.poi.runtime.graal; + +import java.text.AttributedString; + +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.util.SheetUtil; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; + +import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.RecomputeFieldValue; +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; + +@TargetClass(SheetUtil.class) +@Platforms(Platform.MACOS.class) +public final class SheetUtilSubstitution { + + @Alias + @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias) + public static int DEFAULT_CHAR_WIDTH = 5; + + @Substitute + public static int getDefaultCharWidth(final Workbook wb) { + return DEFAULT_CHAR_WIDTH; + } + + @Substitute + private static double getCellWidth(int defaultCharWidth, int colspan, + CellStyle style, double minWidth, AttributedString str) { + return defaultCharWidth; + } +}