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
This commit is contained in:
Yegor Kozlov 2012-02-21 12:39:23 +00:00
parent 854e14308f
commit a2aa35c9a8
3 changed files with 35 additions and 0 deletions

View 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>

View File

@ -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;
}
}

View File

@ -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());
}
}