Author: abearez Date: Wed Apr 1 01:40:52 2020 New Revision: 1875978 URL: http://svn.apache.org/viewvc?rev=1875978&view=rev Log: Remove chart title
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartTitle.java Modified: poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java?rev=1875978&r1=1875977&r2=1875978&view=diff ============================================================================== --- poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java (original) +++ poi/trunk/src/ooxml/java/org/apache/poi/xddf/usermodel/chart/XDDFChart.java Wed Apr 1 01:40:52 2020 @@ -253,6 +253,9 @@ public abstract class XDDFChart extends chart.setAutoTitleDeleted(CTBoolean.Factory.newInstance()); } chart.getAutoTitleDeleted().setVal(deleted); + if (deleted && chart.isSetTitle()) { + chart.unsetTitle(); + } } /** @@ -321,7 +324,15 @@ public abstract class XDDFChart extends } } - /** + /** + * Remove the chart title. + * @since POI 4.1.3 + */ + public void removeTitle() { + setAutoTitleDeleted(true); + } + + /** * Get or Add chart 3D view into chart * * @return this method will add 3D view Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartTitle.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartTitle.java?rev=1875978&r1=1875977&r2=1875978&view=diff ============================================================================== --- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartTitle.java (original) +++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/charts/TestXSSFChartTitle.java Wed Apr 1 01:40:52 2020 @@ -137,6 +137,7 @@ public class TestXSSFChartTitle { XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("chartTitle_withTitle.xlsx"); XSSFChart chart = getChartFromWorkbook(wb, "Sheet1"); assertNotNull(chart); + assertNotNull(chart.getTitle()); XSSFRichTextString originalTitle = chart.getTitleText(); assertNotNull(originalTitle); final String myTitle = "My chart title"; @@ -154,6 +155,7 @@ public class TestXSSFChartTitle { XSSFChart chart = getChartFromWorkbook(wb, "Sheet1"); assertNotNull(chart); assertNull(chart.getTitleText()); + assertNull(chart.getTitle()); final String myTitle = "My chart title"; chart.setTitleText(myTitle); XSSFRichTextString queryTitle = chart.getTitleText(); @@ -176,4 +178,30 @@ public class TestXSSFChartTitle { wb.close(); } + @Test + public void testRemovingFromExistingChartNoTitle() throws IOException { + XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("chartTitle_noTitle.xlsx"); + XSSFChart chart = getChartFromWorkbook(wb, "Sheet1"); + assertNotNull(chart); + assertNull(chart.getTitleText()); + assertNull(chart.getTitle()); + chart.removeTitle(); + assertNull(chart.getTitleText()); + assertNull(chart.getTitle()); + wb.close(); + } + + @Test + public void testRemovingFromExistingChartWithTitle() throws IOException { + XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("chartTitle_withTitle.xlsx"); + XSSFChart chart = getChartFromWorkbook(wb, "Sheet1"); + assertNotNull(chart); + assertNotNull(chart.getTitleText()); + assertNotNull(chart.getTitle()); + chart.removeTitle(); + assertNull(chart.getTitleText()); + assertNull(chart.getTitle()); + wb.close(); + } + } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@poi.apache.org For additional commands, e-mail: commits-h...@poi.apache.org