aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYegor Kozlov <yegor@apache.org>2012-02-21 12:39:23 +0000
committerYegor Kozlov <yegor@apache.org>2012-02-21 12:39:23 +0000
commitbd09f7104319b1822100e3499cca0d353e5212fd (patch)
treeadd0dbfc08f6c1951d54fd0413aebfe4305f0fb5
parentb0b28bf53cdd2dfa0f6c3b8fcf4d687c14a76531 (diff)
downloadpoi-bd09f7104319b1822100e3499cca0d353e5212fd.tar.gz
poi-bd09f7104319b1822100e3499cca0d353e5212fd.zip
Bugzilla 52701: fixed seting vertical alignment for XSLFTableCell
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1291743 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/documentation/content/xdocs/status.xml1
-rw-r--r--src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java28
-rw-r--r--src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java6
3 files changed, 35 insertions, 0 deletions
diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml
index 85064486b6..9e88c81f2f 100644
--- a/src/documentation/content/xdocs/status.xml
+++ b/src/documentation/content/xdocs/status.xml
@@ -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>
diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java
index df63212af6..a3671ab63d 100644
--- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java
+++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java
@@ -36,6 +36,7 @@ import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndType;
import org.openxmlformats.schemas.drawingml.x2006.main.STLineEndWidth;
import org.openxmlformats.schemas.drawingml.x2006.main.STPenAlignment;
import org.openxmlformats.schemas.drawingml.x2006.main.STPresetLineDashVal;
+import org.openxmlformats.schemas.drawingml.x2006.main.STTextAnchoringType;
/**
* Represents a cell of a table in a .pptx presentation
@@ -299,4 +300,31 @@ public class XSLFTableCell extends XSLFTextShape {
void setVMerge(boolean merge_) {
getXmlObject().setVMerge(merge_);
}
+
+ @Override
+ public void setVerticalAlignment(VerticalAlignment anchor){
+ CTTableCellProperties cellProps = getXmlObject().getTcPr();
+ if(cellProps != null) {
+ if(anchor == null) {
+ if(cellProps.isSetAnchor()) {
+ cellProps.unsetAnchor();
+ }
+ } else {
+ cellProps.setAnchor(STTextAnchoringType.Enum.forInt(anchor.ordinal() + 1));
+ }
+ }
+ }
+
+ @Override
+ public VerticalAlignment getVerticalAlignment(){
+ CTTableCellProperties cellProps = getXmlObject().getTcPr();
+
+ VerticalAlignment align = VerticalAlignment.TOP;
+ if(cellProps != null && cellProps.isSetAnchor()) {
+ int ival = cellProps.getAnchor().intValue();
+ align = VerticalAlignment.values()[ival - 1];
+ }
+ return align;
+ }
+
}
diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java
index 9a4144752a..0ded02a5a7 100644
--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java
+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java
@@ -142,5 +142,11 @@ public class TestXSLFTable extends TestCase {
assertNull(cell1.getBorderRightColor());
cell1.setBorderRightColor(Color.yellow);
assertEquals(Color.yellow, cell1.getBorderRightColor());
+
+ assertEquals(VerticalAlignment.TOP, cell1.getVerticalAlignment());
+ cell1.setVerticalAlignment(VerticalAlignment.MIDDLE);
+ assertEquals(VerticalAlignment.MIDDLE, cell1.getVerticalAlignment());
+ cell1.setVerticalAlignment(null);
+ assertEquals(VerticalAlignment.TOP, cell1.getVerticalAlignment());
}
} \ No newline at end of file