You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2016/11/18 23:29:53 UTC
svn commit: r1770447 - in /poi: site/src/documentation/content/xdocs/
trunk/src/java/org/apache/poi/sl/draw/
trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/
trunk/src/ooxml/testcases/org/apache/poi/sl/
trunk/src/ooxml/testcases/org/apache/poi/xslf/
Author: kiwiwings
Date: Fri Nov 18 23:29:53 2016
New Revision: 1770447
URL: http://svn.apache.org/viewvc?rev=1770447&view=rev
Log:
Bug 60373 - TableCell.getTextHeight() returns Null pointer Exception
Modified:
poi/site/src/documentation/content/xdocs/status.xml
poi/trunk/src/java/org/apache/poi/sl/draw/DrawTableShape.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTable.java
poi/trunk/src/ooxml/testcases/org/apache/poi/sl/TestTable.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.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=1770447&r1=1770446&r2=1770447&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/status.xml (original)
+++ poi/site/src/documentation/content/xdocs/status.xml Fri Nov 18 23:29:53 2016
@@ -56,13 +56,17 @@
when referring to both H??F and X??F formats.
-->
- <!-- release version="3.16-beta2" date="2017-02-??">
- </release -->
+ <release version="3.16-beta2" date="2017-02-??">
+ <actions>
+ <action dev="PD" type="fix" fixes-bug="60373" module="XSLF">TableCell.getTextHeight() returns NullPointerException</action>
+ </actions>
+ </release>
<release version="3.16-beta1" date="2016-11-20">
<summary>
<summary-item>Initial work on adding a Gradle build, the Ant based build is currently still the official buildsystem, but there are plans to replace this with Gradle in the future.</summary-item>
<summary-item>Add support for mixed-length cipher/hashes in password protected files typically used by Office for Mac</summary-item>
+ <summary-item>Add CryptoAPI and encryption write support for HSSF</summary-item>
<summary-item>Improve support for reading VBA macros</summary-item>
<summary-item>Examples to encrypt temp files in SXSSF</summary-item>
</summary>
Modified: poi/trunk/src/java/org/apache/poi/sl/draw/DrawTableShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/draw/DrawTableShape.java?rev=1770447&r1=1770446&r2=1770447&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/draw/DrawTableShape.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/draw/DrawTableShape.java Fri Nov 18 23:29:53 2016
@@ -137,8 +137,10 @@ public class DrawTableShape extends Draw
for (int row=0; row<rows; row++) {
for (int col=0; col<cols; col++) {
TableCell<?,?> tc = ts.getCell(row, col);
- DrawTextShape dts = df.getDrawable(tc);
- dts.drawContent(graphics);
+ if (tc != null) {
+ DrawTextShape dts = df.getDrawable(tc);
+ dts.drawContent(graphics);
+ }
}
}
}
@@ -229,6 +231,9 @@ public class DrawTableShape extends Draw
* @param args the border attributes
*/
private static void setEdges(TableCell<?,?> cell, BorderEdge edges[], Object... args) {
+ if (cell == null) {
+ return;
+ }
for (BorderEdge be : edges) {
if (be != null) {
if (args.length == 0) {
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTable.java?rev=1770447&r1=1770446&r2=1770447&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTable.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTable.java Fri Nov 18 23:29:53 2016
@@ -297,7 +297,7 @@ public class XSLFTable extends XSLFGraph
double maxHeight = 0;
for (int col=0; col<cols; col++) {
XSLFTableCell tc = getCell(row, col);
- if (tc.getGridSpan() != 1 || tc.getRowSpan() != 1) {
+ if (tc == null || tc.getGridSpan() != 1 || tc.getRowSpan() != 1) {
continue;
}
// need to set the anchor before height calculation
@@ -314,8 +314,10 @@ public class XSLFTable extends XSLFGraph
for (int col=0; col<cols; col++) {
Rectangle2D bounds = new Rectangle2D.Double(newX, newY, colWidths[col], rowHeights[row]);
XSLFTableCell tc = getCell(row, col);
- tc.setAnchor(bounds);
- newX += colWidths[col]+DrawTableShape.borderSize;
+ if (tc != null) {
+ tc.setAnchor(bounds);
+ newX += colWidths[col]+DrawTableShape.borderSize;
+ }
}
newY += rowHeights[row]+DrawTableShape.borderSize;
}
@@ -324,6 +326,9 @@ public class XSLFTable extends XSLFGraph
for (int row=0; row<rows; row++) {
for (int col=0; col<cols; col++) {
XSLFTableCell tc = getCell(row, col);
+ if (tc == null) {
+ continue;
+ }
Rectangle2D mergedBounds = tc.getAnchor();
for (int col2=col+1; col2<col+tc.getGridSpan(); col2++) {
assert(col2 < cols);
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=1770447&r1=1770446&r2=1770447&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 Fri Nov 18 23:29:53 2016
@@ -112,8 +112,10 @@ public class TestTable {
int col = 0;
for (TextDirection td : tds) {
TableCell<?,?> c = tbl1.getCell(0, col++);
- c.setTextDirection(td);
- c.setText("bla");
+ if (c != null) {
+ c.setTextDirection(td);
+ c.setText("bla");
+ }
}
ByteArrayOutputStream bos = new ByteArrayOutputStream();
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java?rev=1770447&r1=1770446&r2=1770447&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/TestXSLFBugs.java Fri Nov 18 23:29:53 2016
@@ -60,6 +60,10 @@ import org.apache.poi.xslf.usermodel.XSL
import org.apache.poi.xslf.usermodel.XSLFSlide;
import org.apache.poi.xslf.usermodel.XSLFSlideLayout;
import org.apache.poi.xslf.usermodel.XSLFSlideMaster;
+import org.apache.poi.xslf.usermodel.XSLFTable;
+import org.apache.poi.xslf.usermodel.XSLFTableCell;
+import org.apache.poi.xslf.usermodel.XSLFTableRow;
+import org.apache.poi.xslf.usermodel.XSLFTextParagraph;
import org.apache.poi.xslf.usermodel.XSLFTextRun;
import org.junit.Ignore;
import org.junit.Test;
@@ -556,4 +560,30 @@ public class TestXSLFBugs {
rwPptx.close();
ppt.close();
}
-}
+
+
+ @Test
+ public void bug60373() throws IOException {
+ XMLSlideShow ppt = new XMLSlideShow();
+ XSLFSlide sl = ppt.createSlide();
+ XSLFTable t = sl.createTable();
+ XSLFTableRow r = t.addRow();
+ bug60373_addCell(r);
+ bug60373_addCell(r);
+ r = t.addRow();
+ XSLFTableCell c = bug60373_addCell(r);
+ // call getTextHeight, when table is not fully populated
+ double th = c.getTextHeight();
+ assertTrue(th > 10);
+ ppt.close();
+ }
+
+ private static XSLFTableCell bug60373_addCell(XSLFTableRow r) {
+ XSLFTableCell cell = r.addCell();
+ XSLFTextParagraph p = cell.addNewTextParagraph();
+ XSLFTextRun tr = p.addNewTextRun();
+ tr.setText("t");
+ return cell;
+ }
+
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org