This is an automated email from the ASF dual-hosted git repository.

mridulpathak pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git


The following commit(s) were added to refs/heads/trunk by this push:
     new ee1418a42 Take Apache POI for pricat from the framework version catalog
ee1418a42 is described below

commit ee1418a42db3d31d4b6f4ee0da16a02bcf567d67
Author: Mridul Pathak <[email protected]>
AuthorDate: Sun Oct 25 23:32:37 2026 +0530

    Take Apache POI for pricat from the framework version catalog
    
    - Declare libs.poi.ooxml from the framework version catalog instead of POI 
4.1.2, and drop poi-ooxml-schemas, poi-excelant and poi-scratchpad, which 
pricat does not use. Plugin libraries share the framework's classpath, so the 
runtime carried POI 5.5.1 next to the 4.1.2 schemas, excelant and scratchpad 
jars, with two copies of the OOXML schema classes.
    - Call XSSFSheet.getVMLDrawing and XSSFVMLDrawing.findCommentShape directly 
in OFBizPricatUtil instead of through reflection, since both are public in POI 
5.
---
 pricat/build.gradle                                |  6 +--
 .../apache/ofbiz/pricat/util/OFBizPricatUtil.java  | 54 ++--------------------
 2 files changed, 6 insertions(+), 54 deletions(-)

diff --git a/pricat/build.gradle b/pricat/build.gradle
index 642799794..68c36d852 100644
--- a/pricat/build.gradle
+++ b/pricat/build.gradle
@@ -18,9 +18,5 @@
  */
 dependencies {
     pluginLibsCompile 'org.safehaus.jug:jug:2.0.0:asl'
-    // poi-ooxml-schemas-5.0.0.pom'. Received status code 401 from server
-    pluginLibsCompile 'org.apache.poi:poi-ooxml:4.1.2'
-    pluginLibsCompile 'org.apache.poi:poi-ooxml-schemas:4.1.2'
-    pluginLibsCompile 'org.apache.poi:poi-excelant:4.1.2'
-    pluginLibsCompile 'org.apache.poi:poi-scratchpad:4.1.2'
+    pluginLibsCompile libs.poi.ooxml
 }
diff --git 
a/pricat/src/main/java/org/apache/ofbiz/pricat/util/OFBizPricatUtil.java 
b/pricat/src/main/java/org/apache/ofbiz/pricat/util/OFBizPricatUtil.java
index d9e701a32..f643bfc7b 100644
--- a/pricat/src/main/java/org/apache/ofbiz/pricat/util/OFBizPricatUtil.java
+++ b/pricat/src/main/java/org/apache/ofbiz/pricat/util/OFBizPricatUtil.java
@@ -18,66 +18,22 @@
  */
 package org.apache.ofbiz.pricat.util;
 
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import org.apache.ofbiz.base.util.Debug;
 import org.apache.poi.ss.util.CellReference;
 import org.apache.poi.xssf.usermodel.XSSFSheet;
-import org.apache.poi.xssf.usermodel.XSSFVMLDrawing;
 
 import com.microsoft.schemas.vml.CTShape;
 
 public final class OFBizPricatUtil {
     private OFBizPricatUtil() { }
 
-    private static final String MODULE = OFBizPricatUtil.class.getName();
-    private static Method vmlDrawingMethod;
-    // for POI 4.0.0 and later, this field can be removed
-    private static Method findCommentShapeMethod;
-    static {
-        Method[] methods = XSSFSheet.class.getDeclaredMethods();
-        for (Method method : methods) {
-            if ("getVMLDrawing".equals(method.getName())) {
-                vmlDrawingMethod = method;
-                break;
-            }
-        }
-        // for POI 4.0.0 and later, this part can be removed
-        methods = XSSFVMLDrawing.class.getDeclaredMethods();
-        for (Method method : methods) {
-            if ("findCommentShape".equals(method.getName())) {
-                findCommentShapeMethod = method;
-                break;
-            }
-        }
-    }
     public static void formatCommentShape(XSSFSheet sheet, CellReference cell) 
{
-        if (vmlDrawingMethod != null && findCommentShapeMethod != null) {
-            try {
-                XSSFVMLDrawing vml = (XSSFVMLDrawing) 
vmlDrawingMethod.invoke(sheet, true);
-                /** for POI 4.0 and later, use:
-                CTShape ctshape = vml.findCommentShape(cell.getRow(), 
cell.getCol());
-                */
-                CTShape ctshape = (CTShape) findCommentShapeMethod.invoke(vml, 
cell.getRow(), cell.getCol());
-                ctshape.setType("#_x0000_t202");
-            } catch (IllegalAccessException | IllegalArgumentException | 
InvocationTargetException e) {
-                Debug.logError(e, MODULE);
-            }
-        }
+        formatCommentShape(sheet, cell.getRow(), cell.getCol());
     }
+
     public static void formatCommentShape(XSSFSheet sheet, int rowNum, short 
colNum) {
-        if (vmlDrawingMethod != null && findCommentShapeMethod != null) {
-            try {
-                XSSFVMLDrawing vml = (XSSFVMLDrawing) 
vmlDrawingMethod.invoke(sheet, true);
-                /** for POI 4.0 and later, use:
-                CTShape ctshape = vml.findCommentShape(rowNum, colNum);
-                */
-                CTShape ctshape = (CTShape) findCommentShapeMethod.invoke(vml, 
rowNum, colNum);
-                ctshape.setType("#_x0000_t202");
-            } catch (IllegalAccessException | IllegalArgumentException | 
InvocationTargetException e) {
-                Debug.logError(e, MODULE);
-            }
+        CTShape ctshape = sheet.getVMLDrawing(true).findCommentShape(rowNum, 
colNum);
+        if (ctshape != null) {
+            ctshape.setType("#_x0000_t202");
         }
     }
 }

Reply via email to