ASF Bugzilla – Attachment 36622 Details for
Bug 63498
[PATCH] NPE when calling getShapeName on XSLFTableCell
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Fix in XSLFShape.java and a test for it
table-cell-npe.patch (text/plain), 2.17 KB, created by
Mate Borcsok
on 2019-06-12 13:32:26 UTC
(
hide
)
Description:
Fix in XSLFShape.java and a test for it
Filename:
MIME Type:
Creator:
Mate Borcsok
Created:
2019-06-12 13:32:26 UTC
Size:
2.17 KB
patch
obsolete
>diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java >index 3df55edba..b81727623 100644 >--- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java >+++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java >@@ -99,7 +99,8 @@ public abstract class XSLFShape implements Shape<XSLFShape,XSLFTextParagraph> { > > @Override > public String getShapeName(){ >- return getCNvPr().getName(); >+ CTNonVisualDrawingProps nonVisualDrawingProps = getCNvPr(); >+ return nonVisualDrawingProps == null ? null : getCNvPr().getName(); > } > > @Override >diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTableRow.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTableRow.java >index 8a0892819..ed155eb3b 100644 >--- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTableRow.java >+++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTableRow.java >@@ -19,6 +19,7 @@ package org.apache.poi.xslf.usermodel; > import static org.junit.Assert.assertEquals; > import static org.junit.Assert.assertFalse; > import static org.junit.Assert.assertNotNull; >+import static org.junit.Assert.assertNull; > import static org.junit.Assert.assertSame; > import static org.junit.Assert.assertTrue; > import static org.junit.Assert.fail; >@@ -128,4 +129,22 @@ public class TestXSLFTableRow { > assertNotNull(ctrow); > } > >+ @Test >+ public void getShapeNameOfCells() throws Exception { >+ try(XMLSlideShow ss1 = XSLFTestDataSamples.openSampleDocument("table_test.pptx")) { >+ for (XSLFSlide slide : ss1.getSlides()) { >+ for (XSLFShape shape : slide.getShapes()) { >+ shape.getShapeName(); >+ if (shape instanceof XSLFTable) { >+ for (XSLFTableRow row : ((XSLFTable) shape).getRows()) { >+ for (XSLFTableCell cell : row.getCells()) { >+ assertNull(cell.getShapeName()); // Do not throw NPE >+ } >+ } >+ } >+ } >+ } >+ } >+ } >+ > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 63498
: 36622