From e2f4e65a7b8024c00b049eebf0d87637efda7f24 Mon Sep 17 00:00:00 2001 From: Balazs Varga Date: Thu, 27 Aug 2020 11:21:48 +0200 Subject: tdf#134571 chart2, xmloff: add loext:custom-leader-lines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit new ODF chart series style attribute for saving not default (switched off) state of data labels in custom positions. Note: import of the embedded chart of the DOCX unit test document uses also ODF format in the background, testing also this loext attribute, i.e. the chart of the unit test document doesn't contain custom leader lines. Change-Id: Ia6b76e8d7fe5b6b6204761f3bbc2309f1b631008 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101442 Tested-by: László Németh Reviewed-by: László Németh --- chart2/qa/extras/chart2export.cxx | 18 ++++++++++++++---- .../qa/extras/data/docx/MSO_Custom_Leader_Line.docx | Bin 0 -> 25883 bytes .../chartapiwrapper/DataSeriesPointWrapper.cxx | 7 +++++++ include/xmloff/xmltoken.hxx | 1 + .../OpenDocument-schema-v1.3+libreoffice.rng | 9 +++++++++ xmloff/source/chart/PropertyMap.hxx | 1 + xmloff/source/core/xmltoken.cxx | 3 ++- xmloff/source/token/tokens.txt | 1 + 8 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 chart2/qa/extras/data/docx/MSO_Custom_Leader_Line.docx diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index 4be864c69ce4..6384ac17f0bc 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -2374,10 +2374,19 @@ void Chart2ExportTest::testCustomDataLabelMultipleSeries() void Chart2ExportTest::testLeaderLines() { load("/chart2/qa/extras/data/xlsx/", "testTdf90749.xlsx"); - xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); - CPPUNIT_ASSERT(pXmlDoc); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[1]/c:dLbls/c:extLst/c:ext/c15:showLeaderLines", "val", "1"); - assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[2]/c:dLbls/c:extLst/c:ext/c15:showLeaderLines", "val", "0"); + { + xmlDocUniquePtr pXmlDoc = parseExport("xl/charts/chart", "Calc Office Open XML"); + CPPUNIT_ASSERT(pXmlDoc); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[1]/c:dLbls/c:extLst/c:ext/c15:showLeaderLines", "val", "1"); + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[2]/c:dLbls/c:extLst/c:ext/c15:showLeaderLines", "val", "0"); + } + load("/chart2/qa/extras/data/docx/", "MSO_Custom_Leader_Line.docx"); + { + xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart1", "Office Open XML Text"); + CPPUNIT_ASSERT(pXmlDoc); + // tdf#134571: Check the leader line is switch off. + assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:extLst/c:ext/c15:showLeaderLines", "val", "0"); + } } void Chart2ExportTest::testNumberFormatExportPPTX() @@ -2882,6 +2891,7 @@ void Chart2ExportTest::testTdf123647() assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart", 1); } + CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/chart2/qa/extras/data/docx/MSO_Custom_Leader_Line.docx b/chart2/qa/extras/data/docx/MSO_Custom_Leader_Line.docx new file mode 100644 index 000000000000..c158a0d76513 Binary files /dev/null and b/chart2/qa/extras/data/docx/MSO_Custom_Leader_Line.docx differ diff --git a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx index a6d45dddaa47..6701c1061b01 100644 --- a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx @@ -79,6 +79,7 @@ enum PROP_SERIES_DATAPOINT_LABEL_PLACEMENT, //other series properties PROP_SERIES_ATTACHED_AXIS, + PROP_SERIES_SHOW_CUSTOM_LEADERLINES, PROP_SERIES_DATAPOINT_TEXT_ROTATION, PROP_SERIES_DATAPOINT_LABEL_BORDER_STYLE, PROP_SERIES_DATAPOINT_LABEL_BORDER_WIDTH, @@ -211,6 +212,12 @@ void lcl_AddPropertiesToVector_SeriesOnly( cppu::UnoType::get(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT ); + + rOutProperties.emplace_back( "ShowCustomLeaderLines", + PROP_SERIES_SHOW_CUSTOM_LEADERLINES, + cppu::UnoType::get(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT ); } uno::Sequence< Property > lcl_GetPropertySequence( DataSeriesPointWrapper::eType _eType ) diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx index 4e0385914cf3..1b7a932f9399 100644 --- a/include/xmloff/xmltoken.hxx +++ b/include/xmloff/xmltoken.hxx @@ -538,6 +538,7 @@ namespace xmloff::token { XML_CUSTOM_LABEL_FIELD, XML_CUSTOM_LABEL_POS_X, XML_CUSTOM_LABEL_POS_Y, + XML_CUSTOM_LEADERLINES, XML_CUT, XML_CUT_OFFS, XML_CUT_OFFS2, diff --git a/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng b/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng index 5141f9e0fbe4..486471a317d5 100644 --- a/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng +++ b/schema/libreoffice/OpenDocument-schema-v1.3+libreoffice.rng @@ -2463,4 +2463,13 @@ xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1. + + + + + + + + + diff --git a/xmloff/source/chart/PropertyMap.hxx b/xmloff/source/chart/PropertyMap.hxx index 77340f740155..d98fa98e8912 100644 --- a/xmloff/source/chart/PropertyMap.hxx +++ b/xmloff/source/chart/PropertyMap.hxx @@ -252,6 +252,7 @@ const XMLPropertyMapEntry aXMLChartPropMap[] = MAP_ENTRY_ODF12( "LabelPlacement", CHART, XML_LABEL_POSITION, XML_SCH_TYPE_LABEL_PLACEMENT_TYPE ), MAP_ENTRY( "SegmentOffset", CHART, XML_PIE_OFFSET, XML_TYPE_NUMBER ), MAP_SPECIAL_ODF12( "PercentageNumberFormat", STYLE, XML_PERCENTAGE_DATA_STYLE_NAME, XML_TYPE_NUMBER, XML_SCH_CONTEXT_SPECIAL_NUMBER_FORMAT ), + MAP_ENTRY_ODF_EXT( "ShowCustomLeaderLines", LO_EXT, XML_CUSTOM_LEADERLINES, XML_TYPE_BOOL ), // text properties for titles MAP_SPECIAL( "TextRotation", STYLE, XML_ROTATION_ANGLE, XML_TYPE_NUMBER, XML_SCH_CONTEXT_SPECIAL_TEXT_ROTATION ), // convert 1/100th degrees to degrees diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index b00d8f25985e..d78de79842aa 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -540,9 +540,10 @@ namespace xmloff::token { TOKEN( "custom-iconset", XML_CUSTOM_ICONSET ), TOKEN( "custom-iconset-index", XML_CUSTOM_ICONSET_INDEX ), TOKEN( "custom-iconset-name", XML_CUSTOM_ICONSET_NAME ), - TOKEN( "custom-label-field", XML_CUSTOM_LABEL_FIELD ), + TOKEN( "custom-label-field", XML_CUSTOM_LABEL_FIELD ), TOKEN( "custom-label-pos-x", XML_CUSTOM_LABEL_POS_X ), TOKEN( "custom-label-pos-y", XML_CUSTOM_LABEL_POS_Y ), + TOKEN( "custom-leader-lines", XML_CUSTOM_LEADERLINES ), TOKEN( "cut", XML_CUT ), TOKEN( "cut-offs", XML_CUT_OFFS ), TOKEN( "cut_offs", XML_CUT_OFFS2 ), diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt index 259dd4ce9eac..762879a26c27 100644 --- a/xmloff/source/token/tokens.txt +++ b/xmloff/source/token/tokens.txt @@ -458,6 +458,7 @@ custom-iconset-name custom-label-field custom-label-pos-x custom-label-pos-y +custom-leader-lines cut cut-offs cut_offs -- cgit