chart2/qa/extras/chart2export.cxx                 |    2 +-
 chart2/source/model/main/DataSeriesProperties.cxx |    7 +++++++
 chart2/source/model/main/DataSeriesProperties.hxx |    3 ++-
 chart2/source/view/charttypes/VSeriesPlotter.cxx  |    3 ++-
 offapi/com/sun/star/chart2/DataSeries.idl         |    7 +++++++
 oox/source/drawingml/chart/seriescontext.cxx      |    6 +++++-
 oox/source/drawingml/chart/seriesconverter.cxx    |    2 +-
 oox/source/export/chartexport.cxx                 |    6 ++++--
 oox/source/token/properties.txt                   |    2 +-
 9 files changed, 30 insertions(+), 8 deletions(-)

New commits:
commit 5d67d70b26706ce8a08612c12a68821f984210a2
Author:     Balazs Varga <balazs.varga...@gmail.com>
AuthorDate: Wed Jul 8 11:06:38 2020 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Tue Aug 18 19:01:21 2020 +0200

    tdf#134563 Add UNO API for custom leader lines
    
    If its ShowCustomLeaderLines=true, data series uses leader
    lines for labels with custom alignment.
    
    Add also OOXML import/export of custom data series setting.
    
    Change-Id: I8e6f7cb457c38b84aa40c917e69704862262a96e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98323
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/chart2/qa/extras/chart2export.cxx 
b/chart2/qa/extras/chart2export.cxx
index f9b2651a922c..754768880054 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -2373,7 +2373,7 @@ void Chart2ExportTest::testLeaderLines()
     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", "1");
+    assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser[2]/c:dLbls/c:extLst/c:ext/c15:showLeaderLines",
 "val", "0");
 }
 
 void Chart2ExportTest::testNumberFormatExportPPTX()
diff --git a/chart2/source/model/main/DataSeriesProperties.cxx 
b/chart2/source/model/main/DataSeriesProperties.cxx
index 5d0cb777e151..d85d264753c1 100644
--- a/chart2/source/model/main/DataSeriesProperties.cxx
+++ b/chart2/source/model/main/DataSeriesProperties.cxx
@@ -69,6 +69,12 @@ void DataSeriesProperties::AddPropertiesToVector(
                   beans::PropertyAttribute::BOUND
                   | beans::PropertyAttribute::MAYBEVOID );
 
+    rOutProperties.emplace_back( "ShowCustomLeaderLines",
+                  PROP_DATASERIES_SHOW_CUSTOM_LEADERLINES,
+                  cppu::UnoType<sal_Bool>::get(),
+                  beans::PropertyAttribute::BOUND
+                  | beans::PropertyAttribute::MAYBEDEFAULT );
+
     // add properties of service DataPointProperties
     DataPointProperties::AddPropertiesToVector( rOutProperties );
 }
@@ -80,6 +86,7 @@ void DataSeriesProperties::AddDefaultsToMap(
     PropertyHelper::setPropertyValueDefault( rOutMap, 
PROP_DATASERIES_VARY_COLORS_BY_POINT, false );
     PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, 
PROP_DATASERIES_ATTACHED_AXIS_INDEX, 0 );
     PropertyHelper::setPropertyValueDefault( rOutMap, 
PROP_DATASERIES_SHOW_LEGEND_ENTRY, true );
+    PropertyHelper::setPropertyValueDefault( rOutMap, 
PROP_DATASERIES_SHOW_CUSTOM_LEADERLINES, true );
 
     // PROP_DATASERIES_ATTRIBUTED_DATA_POINTS has no default
 
diff --git a/chart2/source/model/main/DataSeriesProperties.hxx 
b/chart2/source/model/main/DataSeriesProperties.hxx
index e20602baf45f..6bc058201466 100644
--- a/chart2/source/model/main/DataSeriesProperties.hxx
+++ b/chart2/source/model/main/DataSeriesProperties.hxx
@@ -35,7 +35,8 @@ namespace chart::DataSeriesProperties
         PROP_DATASERIES_VARY_COLORS_BY_POINT,
         PROP_DATASERIES_ATTACHED_AXIS_INDEX,
         PROP_DATASERIES_SHOW_LEGEND_ENTRY,
-        PROP_DATASERIES_DELETED_LEGEND_ENTRIES
+        PROP_DATASERIES_DELETED_LEGEND_ENTRIES,
+        PROP_DATASERIES_SHOW_CUSTOM_LEADERLINES
     };
 
     void AddPropertiesToVector(
diff --git a/chart2/source/view/charttypes/VSeriesPlotter.cxx 
b/chart2/source/view/charttypes/VSeriesPlotter.cxx
index 14b322e8f587..8f7dcbb59a1d 100644
--- a/chart2/source/view/charttypes/VSeriesPlotter.cxx
+++ b/chart2/source/view/charttypes/VSeriesPlotter.cxx
@@ -702,7 +702,8 @@ uno::Reference< drawing::XShape > 
VSeriesPlotter::createDataLabel( const uno::Re
             if( aRelPos.X != -1 )
             {
                 xTextShape->setPosition(aRelPos);
-                if( 
!m_xChartTypeModel->getChartType().equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_PIE)
 )
+                if( 
!m_xChartTypeModel->getChartType().equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_PIE)
 &&
+                    rDataSeries.getPropertiesOfSeries()->getPropertyValue( 
"ShowCustomLeaderLines" ).get<sal_Bool>())
                 {
                     sal_Int32 nX1 = rScreenPosition2D.X;
                     sal_Int32 nY1 = rScreenPosition2D.Y;
diff --git a/offapi/com/sun/star/chart2/DataSeries.idl 
b/offapi/com/sun/star/chart2/DataSeries.idl
index ffcf8daeb7f0..11d4f529007c 100644
--- a/offapi/com/sun/star/chart2/DataSeries.idl
+++ b/offapi/com/sun/star/chart2/DataSeries.idl
@@ -187,6 +187,13 @@ service DataSeries
         @since LibreOffice 7.0
      */
     [optional, property] sequence<long>             DeletedLegendEntries;
+
+    /** This property describes whether the data point and the data label
+        are connected with a leader line.
+
+        @since LibreOffice 7.1
+      */
+    [optional, property] boolean                    ShowCustomLeaderLines;
 };
 
 } ; // chart2
diff --git a/oox/source/drawingml/chart/seriescontext.cxx 
b/oox/source/drawingml/chart/seriescontext.cxx
index 912b7252e02b..3f92818c5544 100644
--- a/oox/source/drawingml/chart/seriescontext.cxx
+++ b/oox/source/drawingml/chart/seriescontext.cxx
@@ -139,8 +139,12 @@ ContextHandlerRef DataLabelsContext::onCreateContext( 
sal_Int32 nElement, const
         case C_TOKEN( leaderLines ):
             return new ShapePrWrapperContext( *this, 
mrModel.mxLeaderLines.create() );
         case C_TOKEN( showLeaderLines ):
-            mrModel.mbShowLeaderLines = rAttribs.getBool( XML_val, 
!bMSO2007Doc );
+        case C15_TOKEN( showLeaderLines ):
+            mrModel.mbShowLeaderLines = rAttribs.getBool( XML_val, true );
             return nullptr;
+        case C_TOKEN( extLst ):
+        case C_TOKEN( ext ):
+            return new DataLabelsContext( *this, mrModel );
     }
     return lclDataLabelSharedCreateContext( *this, nElement, rAttribs, 
mrModel, bMSO2007Doc );
 }
diff --git a/oox/source/drawingml/chart/seriesconverter.cxx 
b/oox/source/drawingml/chart/seriesconverter.cxx
index 6e75fc89beab..b80ea05ae481 100644
--- a/oox/source/drawingml/chart/seriesconverter.cxx
+++ b/oox/source/drawingml/chart/seriesconverter.cxx
@@ -419,7 +419,7 @@ void DataLabelsConverter::convertFromModel( const 
Reference< XDataSeries >& rxDa
     }
     // import leaderline of data labels
     if( !mrModel.mbShowLeaderLines )
-        aPropSet.setProperty( PROP_ShowLeaderLines, false );
+        aPropSet.setProperty( PROP_ShowCustomLeaderLines, false );
 
     // data point label settings
     for (auto const& pointLabel : mrModel.maPointLabels)
diff --git a/oox/source/export/chartexport.cxx 
b/oox/source/export/chartexport.cxx
index db4af798c867..ab8458d44b04 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -3600,14 +3600,16 @@ void ChartExport::exportDataLabels(
     // Baseline label properties for all labels.
     writeLabelProperties(pFS, this, xPropSet, aParam);
 
-    pFS->singleElement(FSNS(XML_c, XML_showLeaderLines), XML_val, "0");
+    bool bShowLeaderLines = false;
+    xPropSet->getPropertyValue("ShowCustomLeaderLines") >>= bShowLeaderLines;
+    pFS->singleElement(FSNS(XML_c, XML_showLeaderLines), XML_val, 
ToPsz10(bShowLeaderLines));
 
     // Export leader line
     if( eChartType != chart::TYPEID_PIE )
     {
         pFS->startElement(FSNS(XML_c, XML_extLst));
         pFS->startElement(FSNS(XML_c, XML_ext), XML_uri, 
"{CE6537A1-D6FC-4f65-9D91-7224C49458BB}", FSNS(XML_xmlns, XML_c15), 
GetFB()->getNamespaceURL(OOX_NS(c15)));
-        pFS->singleElement(FSNS(XML_c15, XML_showLeaderLines), XML_val, "1");
+        pFS->singleElement(FSNS(XML_c15, XML_showLeaderLines), XML_val, 
ToPsz10(bShowLeaderLines));
         pFS->endElement(FSNS(XML_c, XML_ext));
         pFS->endElement(FSNS(XML_c, XML_extLst));
     }
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index fe8d75520077..46200bf221ff 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -463,6 +463,7 @@ Show
 ShowBorder
 ShowCharts
 ShowCorrelationCoefficient
+ShowCustomLeaderLines
 ShowDetail
 ShowDrawing
 ShowEmpty
@@ -474,7 +475,6 @@ ShowFormulas
 ShowGrid
 ShowHighLow
 ShowInputMessage
-ShowLeaderLines
 ShowLegendEntry
 ShowList
 ShowNegativeError
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to