]> source.dussan.org Git - poi.git/commitdiff
Bugzilla 52701: fixed seting vertical alignment for XSLFTableCell
authorYegor Kozlov <yegor@apache.org>
Tue, 21 Feb 2012 12:39:23 +0000 (12:39 +0000)
committerYegor Kozlov <yegor@apache.org>
Tue, 21 Feb 2012 12:39:23 +0000 (12:39 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1291743 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/status.xml
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java
src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java

index 85064486b635424e31bb5efdc161f80f8480b016..9e88c81f2fa68f11e6f51766832e68c7275754ae 100644 (file)
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.8-beta6" date="2012-??-??">
+           <action dev="poi-developers" type="fix">52701 - fixed seting vertical alignment for XSLFTableCell</action>
            <action dev="poi-developers" type="fix">52687 - fixed merging slides with pictures with associated custom tags</action>
            <action dev="poi-developers" type="add"> allow runtime registration of functions in FormulaEvaluator</action>
            <action dev="poi-developers" type="fix">52665 - When reading from a ZipFileZipEntrySource that has already been closed, give IllegalArgumentException rather than NPE</action>
index df63212af66972f91a344611380b457251ea59ca..a3671ab63dd983d86dc53dc52ff10efa2d518d37 100644 (file)
@@ -36,6 +36,7 @@ import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndType;
 import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndWidth;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.STPenAlignment;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.STPresetLineDashVal;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.STTextAnchoringType;\r
 \r
 /**\r
  * Represents a cell of a table in a .pptx presentation\r
@@ -299,4 +300,31 @@ public class XSLFTableCell extends XSLFTextShape {
     void setVMerge(boolean merge_) {\r
        getXmlObject().setVMerge(merge_);\r
     }\r
+    \r
+    @Override\r
+    public void setVerticalAlignment(VerticalAlignment anchor){\r
+       CTTableCellProperties cellProps = getXmlObject().getTcPr();\r
+       if(cellProps != null) {\r
+               if(anchor == null) {\r
+                       if(cellProps.isSetAnchor()) {\r
+                               cellProps.unsetAnchor();\r
+                       }\r
+               } else {\r
+                               cellProps.setAnchor(STTextAnchoringType.Enum.forInt(anchor.ordinal() + 1));\r
+                       }\r
+       }\r
+    }\r
+\r
+    @Override\r
+    public VerticalAlignment getVerticalAlignment(){\r
+        CTTableCellProperties cellProps = getXmlObject().getTcPr();\r
+\r
+        VerticalAlignment align = VerticalAlignment.TOP;\r
+        if(cellProps != null && cellProps.isSetAnchor()) {\r
+            int ival = cellProps.getAnchor().intValue();\r
+            align = VerticalAlignment.values()[ival - 1];\r
+        }\r
+        return align;\r
+     }\r
+\r
 }\r
index 9a4144752ab6ec3035993ea1e6329500d3d51e36..0ded02a5a792c071a462972b8243716951328654 100644 (file)
@@ -142,5 +142,11 @@ public class TestXSLFTable extends TestCase {
         assertNull(cell1.getBorderRightColor());\r
         cell1.setBorderRightColor(Color.yellow);\r
         assertEquals(Color.yellow, cell1.getBorderRightColor());\r
+\r
+        assertEquals(VerticalAlignment.TOP, cell1.getVerticalAlignment());\r
+        cell1.setVerticalAlignment(VerticalAlignment.MIDDLE);\r
+        assertEquals(VerticalAlignment.MIDDLE, cell1.getVerticalAlignment());\r
+        cell1.setVerticalAlignment(null);\r
+        assertEquals(VerticalAlignment.TOP, cell1.getVerticalAlignment());\r
     }\r
 }
\ No newline at end of file