poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1791696 - in /poi: site/src/documentation/content/xdocs/ trunk/src/java/org/apache/poi/ddf/ trunk/src/ooxml/testcases/org/apache/poi/sl/ trunk/src/scratchpad/src/org/apache/poi/hslf/record/ trunk/src/scratchpad/src/org/apache/poi/hslf/user...
Date Mon, 17 Apr 2017 17:13:23 GMT
Author: kiwiwings
Date: Mon Apr 17 17:13:23 2017
New Revision: 1791696

URL: http://svn.apache.org/viewvc?rev=1791696&view=rev
Log:
#60998 - HSLFTable.setRowHeight sets row height incorrect 

Modified:
    poi/site/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/ddf/EscherProperties.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestTable.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTable.java

Modified: poi/site/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/status.xml?rev=1791696&r1=1791695&r2=1791696&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/status.xml (original)
+++ poi/site/src/documentation/content/xdocs/status.xml Mon Apr 17 17:13:23 2017
@@ -58,6 +58,7 @@
 
     <release version="3.17-beta1" date="2017-07-??">
       <actions>
+        <action dev="PD" type="fix" fixes-bug="60998" module="HSLF">HSLFTable.setRowHeight
sets row height incorrect</action>
         <action dev="PD" type="fix" fixes-bug="60996" module="XSSF">Multiple embedded
objects on same sheet are ignored</action>
         <action dev="PD" type="fix" fixes-bug="60993" module="HSLF">Grid and rowspan
calculation in table cells is wrong</action>
         <action dev="PD" type="fix" fixes-bug="60973" module="XDGF">Support for "PolylineTo"
as well as existing alternate spelling "PolyLineTo"</action>

Modified: poi/trunk/src/java/org/apache/poi/ddf/EscherProperties.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ddf/EscherProperties.java?rev=1791696&r1=1791695&r2=1791696&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ddf/EscherProperties.java (original)
+++ poi/trunk/src/java/org/apache/poi/ddf/EscherProperties.java Mon Apr 17 17:13:23 2017
@@ -624,7 +624,7 @@ public final class EscherProperties {
         addProp( m, GROUPSHAPE__BORDERBOTTOMCOLOR, "groupshape.borderBottomColor" ); // 0x039D;
         addProp( m, GROUPSHAPE__BORDERRIGHTCOLOR, "groupshape.borderRightColor" ); // 0x039E;
         addProp( m, GROUPSHAPE__TABLEPROPERTIES, "groupshape.tableProperties" ); // 0x039F;
-        addProp( m, GROUPSHAPE__TABLEROWPROPERTIES, "groupshape.tableRowProperties" ); //
0x03A0;
+        addProp( m, GROUPSHAPE__TABLEROWPROPERTIES, "groupshape.tableRowProperties", EscherPropertyMetaData.TYPE_ARRAY
); // 0x03A0;
         addProp( m, GROUPSHAPE__WEBBOT, "groupshape.wzWebBot" ); // 0x03A5;
         addProp( m, GROUPSHAPE__METROBLOB, "groupshape.metroBlob" ); // 0x03A9;
         addProp( m, GROUPSHAPE__ZORDER, "groupshape.dhgt" ); // 0x03AA;

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestTable.java?rev=1791696&r1=1791695&r2=1791696&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestTable.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestTable.java Mon Apr 17 17:13:23 2017
@@ -88,7 +88,12 @@ public class TestTable {
         
         // assert ppt and pptx versions of the same table have the same shape
         confirmTableShapeEqual(ts, tsx);
-
+        
+        // change row height and validate again
+        tsx.setRowHeight(1, 50);
+        ts.setRowHeight(1, 50);
+        confirmTableShapeEqual(ts, tsx);
+        
         pptx.close();
         ppt.close();
     }
@@ -115,7 +120,7 @@ public class TestTable {
     }
 
     @Test
-    public void textDirectionHSLF() throws IOException {
+    public void directionHSLF() throws IOException {
         assumeFalse(xslfOnly);
         SlideShow<?,?> ppt1 = new HSLFSlideShow();
         testTextDirection(ppt1);
@@ -123,7 +128,7 @@ public class TestTable {
     }
     
     @Test
-    public void textDirectionXSLF() throws IOException {
+    public void directionXSLF() throws IOException {
         SlideShow<?,?> ppt1 = new XMLSlideShow();
         testTextDirection(ppt1);
         ppt1.close();

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java?rev=1791696&r1=1791695&r2=1791696&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java Mon Apr 17 17:13:23
2017
@@ -204,6 +204,7 @@ public enum RecordTypes {
     EscherDeletedPspl(0xf11d,null),
     EscherSplitMenuColors(0xf11e,null),
     EscherOleObject(0xf11f,null),
+    // same as EscherTertiaryOptRecord.RECORD_ID
     EscherUserDefined(0xf122,null);
 
     private static final Map<Short,RecordTypes> LOOKUP;

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTable.java?rev=1791696&r1=1791695&r2=1791696&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTable.java Mon Apr 17 17:13:23
2017
@@ -361,30 +361,38 @@ implements HSLFShapeContainer, TableShap
     }
     
     @Override
-    public void setRowHeight(int row, double height) {
+    public void setRowHeight(int row, final double height) {
         if (row < 0 || row >= cells.length) {
             throw new IllegalArgumentException("Row index '"+row+"' is not within range [0-"+(cells.length-1)+"]");
         }
 
-        int pxHeight = Units.pointsToPixel(height);
-        double currentHeight = cells[row][0].getAnchor().getHeight();
-        double dy = pxHeight - currentHeight;
-
+        // update row height in the table properties
+        AbstractEscherOptRecord opt = getEscherChild(RecordTypes.EscherUserDefined.typeID);
+        EscherArrayProperty p = opt.lookup(EscherProperties.GROUPSHAPE__TABLEROWPROPERTIES);
+        byte[] masterBytes = p.getElement(row);
+        double currentHeight = Units.masterToPoints(LittleEndian.getInt(masterBytes, 0));
+        LittleEndian.putInt(masterBytes, 0, Units.pointsToMaster(height));
+        p.setElement(row, masterBytes);
+        
+        // move the cells
+        double dy = height - currentHeight;
         for (int i = row; i < cells.length; i++) {
-            for (int j = 0; j < cells[i].length; j++) {
-                Rectangle2D anchor = cells[i][j].getAnchor();
+            for (HSLFTableCell c : cells[i]) {
+                if (c == null) {
+                    continue;
+                }
+                Rectangle2D anchor = c.getAnchor();
                 if(i == row) {
-                    anchor.setRect(anchor.getX(), anchor.getY(), anchor.getWidth(), pxHeight);
+                    anchor.setRect(anchor.getX(), anchor.getY(), anchor.getWidth(), height);
                 } else {
-                    anchor.setRect(anchor.getX(), anchor.getY()+dy, anchor.getWidth(), pxHeight);
+                    anchor.setRect(anchor.getX(), anchor.getY()+dy, anchor.getWidth(), anchor.getHeight());
                 }
-                cells[i][j].setAnchor(anchor);
+                c.setAnchor(anchor);
             }
         }
         Rectangle2D tblanchor = getAnchor();
         tblanchor.setRect(tblanchor.getX(), tblanchor.getY(), tblanchor.getWidth(), tblanchor.getHeight()
+ dy);
         setExteriorAnchor(tblanchor);
-
     }
 
     @Override
@@ -453,7 +461,7 @@ implements HSLFShapeContainer, TableShap
     }
 
     private void updateRowHeightsProperty() {
-        AbstractEscherOptRecord opt = getEscherOptRecord();
+        AbstractEscherOptRecord opt = getEscherChild(RecordTypes.EscherUserDefined.typeID);
         EscherArrayProperty p = opt.lookup(EscherProperties.GROUPSHAPE__TABLEROWPROPERTIES);
         byte[] val = new byte[4];
         for (int rowIdx = 0; rowIdx < cells.length; rowIdx++) {



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


Mime
View raw message