]> source.dussan.org Git - poi.git/commitdiff
#59686 - Error when trying to access XSLFTableCell properties like textHeight, lineWi...
authorAndreas Beeker <kiwiwings@apache.org>
Thu, 9 Jun 2016 23:06:42 +0000 (23:06 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Thu, 9 Jun 2016 23:06:42 +0000 (23:06 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1747605 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java
src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java

index fc774687317c17f56b42fbdc1e7451244273e504..9a309157a1b6bc115e55e64b569fcc3d30150e85 100644 (file)
@@ -41,6 +41,7 @@ import org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTRegularTextRun;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTable;\r
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTableCell;\r
@@ -670,6 +671,19 @@ public class XSLFTableCell extends XSLFTextShape implements TableCell<XSLFShape,
         return new XSLFCellTextParagraph(p, this);\r
     }\r
 \r
+    /**\r
+     * Return fake shape properties as a fallback for not overridden\r
+     * methods of XSLFSimpleShape\r
+     * \r
+     * @return fake shape properties\r
+     * \r
+     * @since POI 3.15-beta2\r
+     */\r
+    @Override\r
+    protected CTShapeProperties getSpPr() {\r
+        return CTShapeProperties.Factory.newInstance();\r
+    }\r
+    \r
     /**\r
      * @since POI 3.15-beta2\r
      */\r
index 9b6dd3d597aeb5a042226cdc15fd6425383809a5..eab6fef0f615039dda9b7b04f6039ee90c572ed1 100644 (file)
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;\r
 \r
 import java.awt.Color;\r
+import java.awt.geom.Rectangle2D;\r
 import java.io.IOException;\r
 import java.util.List;\r
 \r
@@ -172,4 +173,22 @@ public class TestXSLFTable {
         \r
         ss2.close();\r
     }\r
+\r
+    @Test\r
+    public void checkTextHeight() throws IOException {\r
+        // from bug 59686\r
+        XMLSlideShow ppt = new XMLSlideShow();\r
+        XSLFSlide sl = ppt.createSlide();\r
+        XSLFTable tab = sl.createTable();\r
+        tab.setAnchor(new Rectangle2D.Double(50,50,300,50));\r
+        XSLFTableRow tr = tab.addRow();\r
+        XSLFTableCell tc0 = tr.addCell();\r
+        tc0.setText("bla bla bla bla");\r
+        tab.setColumnWidth(0, 50);\r
+        \r
+        assertEquals(88, tc0.getTextHeight(), 0);\r
+        assertEquals(0, tc0.getLineWidth(), 0);\r
+        \r
+        ppt.close();\r
+    }\r
 }
\ No newline at end of file