chart2/qa/extras/chart2export.cxx | 15 ++++++++++++++- chart2/qa/extras/data/docx/fdo83058_dlblPos.docx |binary include/oox/export/chartexport.hxx | 1 - oox/source/export/chartexport.cxx | 19 ++++++++++++++----- 4 files changed, 28 insertions(+), 7 deletions(-)
New commits: commit a7052b906dfd1d749f7da9ea64a3479d7c1cc2c9 Author: PriyankaGaikwad <priyanka.gaik...@synerzip.com> Date: Wed Aug 27 19:28:44 2014 +0530 fdo#83058 File corrupt due to data label position is invalid in chart.xml - File getting corrupted after RT due to data label position is invalid in chart.xml - LO must not export invalid label position property if chart type doesn't support that positioning in MS Office. - For clusterd bar chart XML Difference chart1.xml Original file <c:barChart> <c:grouping val="clustered" /> <c:ser> <c:dLbls> ... <c:dLbl> <c:dLblPos val="outEnd" /> </c:dLbl> ... </c:dLbls> </c:ser> </c:barChart> Roundtrip file <c:barChart> <c:grouping val="clustered" /> <c:ser> <c:dLbls> ... <c:dLbl> <c:dLblPos val="r" /> </c:dLbl> ... </c:dLbls> </c:ser> </c:barChart> Change-Id: I9cae11b8d198aaa70fb05cb3bf329cd898519170 Reviewed-on: https://gerrit.libreoffice.org/11141 Reviewed-by: Kohei Yoshida <libreoff...@kohei.us> Tested-by: Kohei Yoshida <libreoff...@kohei.us> diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index fc29305..66f5b90 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -79,6 +79,7 @@ public: void testDataLabelDoughnutChartDOCX(); void testDataLabelAreaChartDOCX(); void testDataLabelDefaultLineChartDOCX(); + void testFdo83058dlblPos(); CPPUNIT_TEST_SUITE(Chart2ExportTest); CPPUNIT_TEST(test); @@ -123,6 +124,7 @@ public: CPPUNIT_TEST(testDataLabelDoughnutChartDOCX); CPPUNIT_TEST(testDataLabelAreaChartDOCX); CPPUNIT_TEST(testDataLabelDefaultLineChartDOCX); + CPPUNIT_TEST(testFdo83058dlblPos); CPPUNIT_TEST_SUITE_END(); protected: @@ -867,7 +869,7 @@ void Chart2ExportTest::testDataLabelClusteredBarChartDOCX() CPPUNIT_ASSERT(pXmlDoc); // This was "t", should be one of the allowed values. - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls/c:dLbl[2]/c:dLblPos", "val", "ctr"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls/c:dLbl[2]/c:dLblPos", "val", "outEnd"); } void Chart2ExportTest::testDataLabelRadarChartDOCX() @@ -1186,6 +1188,17 @@ void Chart2ExportTest::testLabelStringODS() CPPUNIT_ASSERT_EQUAL(OUString("\"LabelName\""), aLabelString); } +void Chart2ExportTest::testFdo83058dlblPos() +{ + load ("/chart2/qa/extras/data/docx/", "fdo83058_dlblPos.docx"); + xmlDocPtr pXmlDoc = parseExport("word/charts/chart","Office Open XML Text"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls[1]/c:dLbl[2]/c:dLblPos", "val", "outEnd"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls[1]/c:dLbl[3]/c:dLblPos", "val", "outEnd"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls[1]/c:dLbl[4]/c:dLblPos", "val", "outEnd"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser[1]/c:dLbls[1]/c:dLbl[5]/c:dLblPos", "val", "outEnd"); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/chart2/qa/extras/data/docx/fdo83058_dlblPos.docx b/chart2/qa/extras/data/docx/fdo83058_dlblPos.docx new file mode 100644 index 0000000..721a717 Binary files /dev/null and b/chart2/qa/extras/data/docx/fdo83058_dlblPos.docx differ diff --git a/include/oox/export/chartexport.hxx b/include/oox/export/chartexport.hxx index 3d56047..b76811d 100644 --- a/include/oox/export/chartexport.hxx +++ b/include/oox/export/chartexport.hxx @@ -99,7 +99,6 @@ private: bool mbIs3DChart; bool mbStacked; bool mbPercent; - bool mbClustered; private: sal_Int32 getChartType(); diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index 727d307..7437152 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -446,7 +446,6 @@ ChartExport::ChartExport( sal_Int32 nXmlNamespace, FSHelperPtr pFS, Reference< f , mbIs3DChart( false ) , mbStacked(false) , mbPercent(false) - , mbClustered(false) { } @@ -2656,13 +2655,15 @@ void ChartExport::exportDataLabels( aParam.mbExport = !mbIs3DChart; aParam.meDefault = rInfo.mnDefLabelPos; aParam.allowAll(); - switch (getChartType()) // diagram chart type + switch (eChartType) // diagram chart type { case chart::TYPEID_PIE: + if(getChartType() == chart::TYPEID_DOUGHNUT) + aParam.mbExport = false; + else // All pie charts support label placement. aParam.mbExport = true; break; - case chart::TYPEID_DOUGHNUT: case chart::TYPEID_AREA: case chart::TYPEID_RADARLINE: case chart::TYPEID_RADARAREA: @@ -2670,7 +2671,7 @@ void ChartExport::exportDataLabels( aParam.mbExport = false; break; case chart::TYPEID_BAR: - if (mbStacked || mbPercent || mbClustered) + if (mbStacked || mbPercent) { aParam.maAllowedValues.clear(); aParam.maAllowedValues.insert(css::chart::DataLabelPlacement::CENTER); @@ -2678,6 +2679,15 @@ void ChartExport::exportDataLabels( aParam.maAllowedValues.insert(css::chart::DataLabelPlacement::NEAR_ORIGIN); aParam.meDefault = css::chart::DataLabelPlacement::CENTER; } + else // Clustered bar chart + { + aParam.maAllowedValues.clear(); + aParam.maAllowedValues.insert(css::chart::DataLabelPlacement::CENTER); + aParam.maAllowedValues.insert(css::chart::DataLabelPlacement::INSIDE); + aParam.maAllowedValues.insert(css::chart::DataLabelPlacement::OUTSIDE); + aParam.maAllowedValues.insert(css::chart::DataLabelPlacement::NEAR_ORIGIN); + aParam.meDefault = css::chart::DataLabelPlacement::OUTSIDE; + } break; default: ; @@ -2818,7 +2828,6 @@ void ChartExport::exportGrouping( bool isBar ) if( isBar && !isDeep3dChart() ) { grouping = "clustered"; - mbClustered = true; } else grouping = "standard"; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits