You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2026/09/20 20:07:56 UTC

(poi) branch trunk updated: [bug-69977] XDDFView3D: getDepthPercent/getHPercent return the percentage the setters take (#1334)

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

pjfanning 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 d82646a91e [bug-69977] XDDFView3D: getDepthPercent/getHPercent return the percentage the setters take (#1334)
d82646a91e is described below

commit d82646a91e953a0f1aab36db43f2700852c7304e
Author: PJ Fanning <pj...@users.noreply.github.com>
AuthorDate: Sun Sep 20 21:07:51 2026 +0100

    [bug-69977] XDDFView3D: getDepthPercent/getHPercent return the percentage the setters take (#1334)
    
    * [bug-69977] XDDFView3D: getDepthPercent/getHPercent return the percentage the setters take
    
    POIXMLUnits.parsePercent returns the percentage scaled by 1000, which the
    gap accessors of the 3D chart data classes already divide out; the two
    XDDFView3D getters did not, so setDepthPercent(50) read back as 50000.
    
    Co-Authored-By: Claude Opus 5 (1M context) <no...@anthropic.com>
    
    * [bug-69977] ooxml-lite report: ST_DepthPercent/ST_HPercent union member types
    
    Co-Authored-By: Claude Opus 5 (1M context) <no...@anthropic.com>
    
    ---------
    
    Co-authored-by: Claude Opus 5 (1M context) <no...@anthropic.com>
---
 .../poi/xddf/usermodel/chart/XDDFView3D.java       | 10 +++++++--
 .../poi/xddf/usermodel/chart/TestXDDFChart.java    | 25 ++++++++++++++++++++++
 src/resources/ooxml-lite-report.clazz              |  4 ++++
 src/resources/ooxml-lite-report.xsb                |  4 ++++
 4 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/poi-ooxml/src/main/java/org/apache/poi/xddf/usermodel/chart/XDDFView3D.java b/poi-ooxml/src/main/java/org/apache/poi/xddf/usermodel/chart/XDDFView3D.java
index 4bfe1e10b6..a182a4b0ca 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xddf/usermodel/chart/XDDFView3D.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xddf/usermodel/chart/XDDFView3D.java
@@ -128,8 +128,11 @@ public class XDDFView3D {
         }
     }
 
+    /**
+     * @return the depth of the 3D chart as a percentage of its width (20 to 2000), or null if not set
+     */
     public Integer getDepthPercent() {
-        return (view3D.isSetDepthPercent()) ? POIXMLUnits.parsePercent(view3D.getDepthPercent().xgetVal()) : null;
+        return (view3D.isSetDepthPercent()) ? POIXMLUnits.parsePercent(view3D.getDepthPercent().xgetVal()) / 1000 : null;
     }
 
     public void setDepthPercent(Integer percent) {
@@ -149,8 +152,11 @@ public class XDDFView3D {
         }
     }
 
+    /**
+     * @return the height of the 3D chart as a percentage of its width (5 to 500), or null if not set
+     */
     public Integer getHPercent() {
-        return (view3D.isSetHPercent()) ? POIXMLUnits.parsePercent(view3D.getHPercent().xgetVal()) : null;
+        return (view3D.isSetHPercent()) ? POIXMLUnits.parsePercent(view3D.getHPercent().xgetVal()) / 1000 : null;
     }
 
     public void setHPercent(Integer percent) {
diff --git a/poi-ooxml/src/test/java/org/apache/poi/xddf/usermodel/chart/TestXDDFChart.java b/poi-ooxml/src/test/java/org/apache/poi/xddf/usermodel/chart/TestXDDFChart.java
index 638a808b58..1c532504f5 100644
--- a/poi-ooxml/src/test/java/org/apache/poi/xddf/usermodel/chart/TestXDDFChart.java
+++ b/poi-ooxml/src/test/java/org/apache/poi/xddf/usermodel/chart/TestXDDFChart.java
@@ -20,6 +20,7 @@ package org.apache.poi.xddf.usermodel.chart;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import org.apache.poi.ooxml.POIXMLFactory;
@@ -47,6 +48,30 @@ class TestXDDFChart {
         assertNotNull(xddfChart.getCTPlotArea());
     }
 
+    @Test
+    void testView3DPercentRoundTripBug69977() {
+        XDDFChart chart = newXDDFChart();
+        XDDFView3D view3D = chart.getOrAddView3D();
+        assertNull(view3D.getDepthPercent());
+        assertNull(view3D.getHPercent());
+
+        view3D.setDepthPercent(50);
+        assertEquals(50, view3D.getDepthPercent());
+        view3D.setHPercent(150);
+        assertEquals(150, view3D.getHPercent());
+
+        // Office also writes these with a trailing percent sign
+        chart.getCTChart().getView3D().getDepthPercent().xgetVal().setStringValue("75%");
+        assertEquals(75, view3D.getDepthPercent());
+        chart.getCTChart().getView3D().getHPercent().xgetVal().setStringValue("20%");
+        assertEquals(20, view3D.getHPercent());
+
+        view3D.setDepthPercent(null);
+        assertNull(view3D.getDepthPercent());
+        view3D.setHPercent(null);
+        assertNull(view3D.getHPercent());
+    }
+
     @Test
     void testSetMajorUnit() {
         // minimal test to cause ooxml-lite to include all the classes in poi-ooxml-lite
diff --git a/src/resources/ooxml-lite-report.clazz b/src/resources/ooxml-lite-report.clazz
index 2069d3eef0..92e3226569 100644
--- a/src/resources/ooxml-lite-report.clazz
+++ b/src/resources/ooxml-lite-report.clazz
@@ -2554,3 +2554,7 @@ org/openxmlformats/schemas/drawingml/x2006/chart/impl/STHoleSizeUByteImpl
 org/openxmlformats/schemas/drawingml/x2006/main/CTSupplementalFont
 org/openxmlformats/schemas/drawingml/x2006/main/impl/CTSupplementalFontImpl
 org/openxmlformats/schemas/officeDocument/x2006/sharedTypes/impl/STPositivePercentageImpl
+org/openxmlformats/schemas/drawingml/x2006/chart/impl/STDepthPercentUShortImpl
+org/openxmlformats/schemas/drawingml/x2006/chart/impl/STHPercentUShortImpl
+org/openxmlformats/schemas/drawingml/x2006/chart/impl/STDepthPercentWithSymbolImpl
+org/openxmlformats/schemas/drawingml/x2006/chart/impl/STHPercentWithSymbolImpl
diff --git a/src/resources/ooxml-lite-report.xsb b/src/resources/ooxml-lite-report.xsb
index 0a06847fcf..33fd98415b 100644
--- a/src/resources/ooxml-lite-report.xsb
+++ b/src/resources/ooxml-lite-report.xsb
@@ -1188,3 +1188,7 @@ stholesizeubyte577atype
 chartspace67aadoctype
 ctsupplementalfonta06etype
 timestampvalidationdataelement
+stdepthpercentwithsymbola04ctype
+stdepthpercentushorte7a3type
+sthpercentwithsymbole671type
+sthpercentushort0848type


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org