[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - chart2/qa chart2/source include/xmloff xmloff/inc xmloff/source

Balazs Varga (via logerrit) logerrit at kemper.freedesktop.org
Tue Apr 28 15:13:36 UTC 2020


 chart2/qa/extras/chart2export.cxx                                   |   34 ++++++++++
 chart2/qa/extras/data/ods/tdf131115.ods                             |binary
 chart2/qa/extras/data/ods/tdf131979.ods                             |binary
 chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx |   12 +--
 include/xmloff/prstylei.hxx                                         |    2 
 xmloff/inc/XMLChartStyleContext.hxx                                 |    2 
 xmloff/source/chart/SchXMLSeries2Context.cxx                        |   22 ++++++
 7 files changed, 66 insertions(+), 6 deletions(-)

New commits:
commit d47b0f5880d87142f2d346c1f1903cfcfc673676
Author:     Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Thu Apr 9 13:45:10 2020 +0200
Commit:     Xisco Faulí <xiscofauli at libreoffice.org>
CommitDate: Tue Apr 28 17:13:03 2020 +0200

    tdf#131979 Chart ODF import-export of Link to source format
    
    setting also into data point styles, fixing lost numbering
    style of custom data points. (Only export into the data
    series style was supported previously.)
    
    Also fix tdf#131115 - FILEOPEN: Incorrect format of single data label
    Regression from commit: e57d90cd4e51a1353eafc87bb29cfe6076704a7c
    (tdf#129173 tdf#129175 Fix number format of data labels)
    
    Data point styles in older ODF files do not contain the
    'link-data-style-to-source' property, so they used the
    data series style property during the import previously.
    Now we set the default false value, if the data point
    style contains a 'data-style-name' (number format).
    
    Change-Id: I4786e62ca75770ed632463bcf1275ece7ea793f4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91967
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>
    Signed-off-by: Xisco Fauli <xiscofauli at libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92653
    Tested-by: Jenkins

diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 03188a07ffb0..6826c3f53569 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -151,6 +151,7 @@ public:
     void testTdf115012();
     void testTdf123206_customLabelText();
     void testCustomLabelText();
+    void testTdf131979();
 
     CPPUNIT_TEST_SUITE(Chart2ExportTest);
     CPPUNIT_TEST(testErrorBarXLSX);
@@ -265,6 +266,7 @@ public:
     CPPUNIT_TEST(testTdf115012);
     CPPUNIT_TEST(testTdf123206_customLabelText);
     CPPUNIT_TEST(testCustomLabelText);
+    CPPUNIT_TEST(testTdf131979);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -2433,6 +2435,38 @@ void Chart2ExportTest::testCustomLabelText()
     assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLbl[2]/c:tx/c:rich/a:p/a:r[1]/a:t", "4.5");
     assertXPathContent(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:barChart/c:ser/c:dLbls/c:dLbl[2]/c:tx/c:rich/a:p/a:r[3]/a:t", "CustomLabel 2");
 }
+
+void Chart2ExportTest::testTdf131979()
+{
+    load("/chart2/qa/extras/data/ods/", "tdf131115.ods");
+    {
+        reload("calc8");
+        Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
+        CPPUNIT_ASSERT(xChartDoc.is());
+        Reference<chart2::XDataSeries> xDataSeries(getDataSeriesFromDoc(xChartDoc, 0));
+        CPPUNIT_ASSERT(xDataSeries.is());
+        Reference<beans::XPropertySet> xPropertySet;
+        xPropertySet.set(xDataSeries->getDataPointByIndex(2), uno::UNO_SET_THROW);
+        bool blinknumberformattosource = true;
+        CPPUNIT_ASSERT(xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= blinknumberformattosource);
+        CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to false.", !blinknumberformattosource);
+    }
+
+    load("/chart2/qa/extras/data/ods/", "tdf131979.ods");
+    {
+        reload("calc8");
+        Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0, mxComponent);
+        CPPUNIT_ASSERT(xChartDoc.is());
+        Reference<chart2::XDataSeries> xDataSeries(getDataSeriesFromDoc(xChartDoc, 0));
+        CPPUNIT_ASSERT(xDataSeries.is());
+        Reference<beans::XPropertySet> xPropertySet;
+        xPropertySet.set(xDataSeries->getDataPointByIndex(2), uno::UNO_SET_THROW);
+        bool blinknumberformattosource = true;
+        CPPUNIT_ASSERT(xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= blinknumberformattosource);
+        CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", blinknumberformattosource);
+    }
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/chart2/qa/extras/data/ods/tdf131115.ods b/chart2/qa/extras/data/ods/tdf131115.ods
new file mode 100644
index 000000000000..76a87c2c226c
Binary files /dev/null and b/chart2/qa/extras/data/ods/tdf131115.ods differ
diff --git a/chart2/qa/extras/data/ods/tdf131979.ods b/chart2/qa/extras/data/ods/tdf131979.ods
new file mode 100644
index 000000000000..3dfcf6b699f9
Binary files /dev/null and b/chart2/qa/extras/data/ods/tdf131979.ods differ
diff --git a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
index 09ccd200521f..e632e8fb5db1 100644
--- a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx
@@ -118,6 +118,12 @@ void lcl_AddPropertiesToVector_PointProperties(
                   beans::PropertyAttribute::BOUND
                   | beans::PropertyAttribute::MAYBEVOID );
 
+    rOutProperties.emplace_back( CHART_UNONAME_LINK_TO_SRC_NUMFMT,
+                  PROP_SERIES_LINK_NUMBERFORMAT_TO_SOURCE,
+                  cppu::UnoType<bool>::get(),
+                  beans::PropertyAttribute::BOUND
+                  | beans::PropertyAttribute::MAYBEDEFAULT );
+
     rOutProperties.emplace_back( "PercentageNumberFormat",
                   PROP_SERIES_PERCENTAGE_NUMBERFORMAT,
                   cppu::UnoType<sal_Int32>::get(),
@@ -176,12 +182,6 @@ void lcl_AddPropertiesToVector_SeriesOnly(
                   cppu::UnoType<sal_Int32>::get(),
                   beans::PropertyAttribute::BOUND
                   | beans::PropertyAttribute::MAYBEDEFAULT );
-
-    rOutProperties.emplace_back( CHART_UNONAME_LINK_TO_SRC_NUMFMT,
-                  PROP_SERIES_LINK_NUMBERFORMAT_TO_SOURCE,
-                  cppu::UnoType<bool>::get(),
-                  beans::PropertyAttribute::BOUND
-                  | beans::PropertyAttribute::MAYBEDEFAULT );
 }
 
 uno::Sequence< Property > lcl_GetPropertySequence( DataSeriesPointWrapper::eType _eType )
diff --git a/include/xmloff/prstylei.hxx b/include/xmloff/prstylei.hxx
index db1700cb9e2f..9935176b028c 100644
--- a/include/xmloff/prstylei.hxx
+++ b/include/xmloff/prstylei.hxx
@@ -101,6 +101,8 @@ public:
     virtual void FillPropertySet(
             const css::uno::Reference< css::beans::XPropertySet > & rPropSet );
 
+    virtual bool isEmptyDataStyleName() { return false; };
+
     const SvXMLStylesContext *GetStyles() const { return static_cast<const SvXMLStylesContext *>(mxStyles.get()); }
     const ::std::vector< XMLPropertyState > & GetProperties() const { return maProperties; }
 
diff --git a/xmloff/inc/XMLChartStyleContext.hxx b/xmloff/inc/XMLChartStyleContext.hxx
index cef31d3f5f1c..2c28b670de06 100644
--- a/xmloff/inc/XMLChartStyleContext.hxx
+++ b/xmloff/inc/XMLChartStyleContext.hxx
@@ -52,6 +52,8 @@ public:
         sal_uInt16 nPrefix,
         const OUString& rLocalName,
         const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override;
+
+    bool isEmptyDataStyleName() override { return msDataStyleName.isEmpty(); }
 };
 
 #endif // INCLUDED_XMLOFF_INC_XMLCHARTSTYLECONTEXT_HXX
diff --git a/xmloff/source/chart/SchXMLSeries2Context.cxx b/xmloff/source/chart/SchXMLSeries2Context.cxx
index 4e379814a859..ef6cd0249a7e 100644
--- a/xmloff/source/chart/SchXMLSeries2Context.cxx
+++ b/xmloff/source/chart/SchXMLSeries2Context.cxx
@@ -171,6 +171,26 @@ void lcl_resetSymbolSizeForPointsIfNecessary( const uno::Reference< beans::XProp
         lcl_setSymbolSizeIfNeeded( xPointProp, rImport );
 }
 
+void lcl_setLinkNumberFormatToSourceIfNeeded( const uno::Reference< beans::XPropertySet >& xPointProp
+    , const XMLPropStyleContext* pPropStyleContext, const SvXMLStylesContext* pStylesCtxt )
+{
+    uno::Any aAny( SchXMLTools::getPropertyFromContext("LinkNumberFormatToSource", pPropStyleContext, pStylesCtxt) );
+    if( !aAny.hasValue() )
+    {
+        if( !xPointProp.is() )
+            return;
+
+        bool bLinkToSource = false;
+        if( xPointProp.is() && (xPointProp->getPropertyValue("LinkNumberFormatToSource") >>= bLinkToSource) )
+        {
+            if( bLinkToSource )
+            {
+                xPointProp->setPropertyValue("LinkNumberFormatToSource", uno::makeAny(false));
+            }
+        }
+    }
+}
+
 void lcl_insertErrorBarLSequencesToMap(
     tSchXMLLSequencesPerIndex & rInOutMap,
     const uno::Reference< beans::XPropertySet > & xSeriesProp )
@@ -1084,6 +1104,8 @@ void SchXMLSeries2Context::setStylesToDataPoints( SeriesDefaultsAndStyles& rSeri
                     pPropStyleContext->FillPropertySet( xPointProp );
                     if( seriesStyle.mbSymbolSizeForSeriesIsMissingInFile )
                         lcl_resetSymbolSizeForPointsIfNecessary( xPointProp, rImport, pPropStyleContext, pStylesCtxt );
+                    if( !pPropStyleContext->isEmptyDataStyleName() )
+                        lcl_setLinkNumberFormatToSourceIfNeeded( xPointProp, pPropStyleContext, pStylesCtxt );
                 }
 
                 // Custom labels might be passed as property


More information about the Libreoffice-commits mailing list