[Libreoffice-commits] core.git: 2 commits - chart2/qa sc/inc sc/source xmloff/source

Kohei Yoshida kohei.yoshida at collabora.com
Thu Jun 12 08:27:32 PDT 2014


 chart2/qa/extras/chart2export.cxx    |    2 -
 chart2/qa/extras/charttest.hxx       |    1 
 sc/inc/unonames.hxx                  |    2 +
 sc/source/ui/unoobj/chart2uno.cxx    |   14 +++++++++++
 xmloff/source/chart/SchXMLExport.cxx |   41 ++++++++++++++++++++---------------
 5 files changed, 39 insertions(+), 21 deletions(-)

New commits:
commit a2a1a59a448420a858724371c4a339f75ebe8c1e
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Thu Jun 12 11:24:30 2014 -0400

    fdo#77506: More reliable way to determine label strings.
    
    Not beautiful, but doable.
    
    Change-Id: I6f3b00d620e7d7d19cc05ec4239deeb14d0d5201

diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx
index ca7a28c..aaead41 100644
--- a/sc/inc/unonames.hxx
+++ b/sc/inc/unonames.hxx
@@ -654,6 +654,8 @@
 #define SC_UNONAME_INCLUDEHIDDENCELLS   "IncludeHiddenCells"
 #define SC_UNONAME_HIDDENVALUES     "HiddenValues"
 #define SC_UNONAME_USE_INTERNAL_DATA_PROVIDER "UseInternalDataProvider"
+#define SC_UNONAME_HAS_STRING_LABEL "HasStringLabel"
+#define SC_UNONAME_TIME_BASED       "TimeBased"
 
 // Solver
 #define SC_UNONAME_TIMEOUT          "Timeout"
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index 3da876a..ed9c2dc 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -3526,10 +3526,22 @@ uno::Any SAL_CALL ScChart2DataSequence::getPropertyValue(const OUString& rProper
         BuildDataCache();
         aRet <<= m_aHiddenValues;
     }
-    else if (rPropertyName == "TimeBased")
+    else if (rPropertyName == SC_UNONAME_TIME_BASED)
     {
         aRet <<= mbTimeBased;
     }
+    else if (rPropertyName == SC_UNONAME_HAS_STRING_LABEL)
+    {
+        // Read-only property.  It returns whether or not the label value is a
+        // direct user input, rather than an indirect reference.
+        bool bHasStringLabel = false;
+        if (m_pTokens->size() == 1)
+        {
+            const ScToken& rToken = *(*m_pTokens)[0];
+            bHasStringLabel = rToken.GetType() == formula::svString;
+        }
+        aRet <<= bHasStringLabel;
+    }
     else
         throw beans::UnknownPropertyException();
     // TODO: support optional properties
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index ab62903..6189a8b 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -2565,7 +2565,6 @@ void SchXMLExportHelper_Impl::exportSeries(
 
     OUString aFirstXDomainRange;
     OUString aFirstYDomainRange;
-    bool modifyLabelRange = false;
 
     std::vector< XMLPropertyState > aPropertyStates;
 
@@ -2711,28 +2710,36 @@ void SchXMLExportHelper_Impl::exportSeries(
                                     // #i75297# allow empty series, export empty range to have all ranges on import
                                     mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_VALUES_CELL_RANGE_ADDRESS, OUString());
 
-                                if( xLabelSeq.is()) {
-                                    OUString aRange = xLabelSeq->getSourceRangeRepresentation();
-                                    if ( nSeriesIdx == 0 && aRange.equalsAscii("label 1"))
-                                        modifyLabelRange = true;
-                                    if (modifyLabelRange)
-                                        aRange = "label " + OUString::number(aRange.copy( OUString("label").getLength()).toInt32() - 1);
-
-                                    OUString aXMLRange = lcl_ConvertRange( aRange, xNewDoc );
-                                    if(aXMLRange.isEmpty() && !aRange.isEmpty())
+                                if (xLabelSeq.is())
+                                {
+                                    // Check if the label is direct string value rather than a reference.
+                                    bool bHasString = false;
+                                    uno::Reference<beans::XPropertySet> xLSProp(xLabelSeq, uno::UNO_QUERY);
+                                    if (xLSProp.is())
                                     {
-                                        // might just be a string
-                                        bool bIsString = isString(aRange);
-                                        if(bIsString)
+                                        try
                                         {
-                                            mrExport.AddAttribute( XML_NAMESPACE_LO_EXT,
-                                                    XML_LABEL_STRING, aRange );
+                                            xLSProp->getPropertyValue("HasStringLabel") >>= bHasString;
                                         }
+                                        catch (const beans::UnknownPropertyException&) {}
+                                    }
+
+                                    OUString aRange = xLabelSeq->getSourceRangeRepresentation();
+
+                                    if (bHasString)
+                                    {
+                                        mrExport.AddAttribute(
+                                            XML_NAMESPACE_LO_EXT, XML_LABEL_STRING, aRange);
                                     }
                                     else
-                                        mrExport.AddAttribute( XML_NAMESPACE_CHART,
-                                                XML_LABEL_CELL_ADDRESS, aXMLRange );
+                                    {
+                                        mrExport.AddAttribute(
+                                            XML_NAMESPACE_CHART, XML_LABEL_CELL_ADDRESS,
+                                                lcl_ConvertRange(
+                                                    xLabelSeq->getSourceRangeRepresentation(), xNewDoc));
+                                    }
                                 }
+
                                 if( xLabelSeq.is() || xValuesSeq.is() )
                                     aSeriesLabelValuesPair = tLabelValuesDataPair( xLabelSeq, xValuesSeq );
 
commit 10f8d24540a4145af3ec629f7eb724849ca53d22
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Thu Jun 12 11:21:40 2014 -0400

    fdo#77506: Enable this check.
    
    Change-Id: Ib4ad7c1a1583b9fde1a06dc8e355442f10bb9bec

diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 2d4713e..21a9ece 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -739,13 +739,11 @@ void Chart2ExportTest::testScatterPlotLabels()
     xCT = getChartTypeFromDoc(xChartDoc, 0, 0);
     CPPUNIT_ASSERT(xCT.is());
 
-#if 0
     aLabels = getDataSeriesLabelsFromChartType(xCT);
     CPPUNIT_ASSERT_EQUAL(size_t(3), aLabels.size());
     CPPUNIT_ASSERT_EQUAL(OUString("a"), aLabels[0][0].get<OUString>());
     CPPUNIT_ASSERT_EQUAL(OUString("b"), aLabels[1][0].get<OUString>());
     CPPUNIT_ASSERT_EQUAL(OUString("c"), aLabels[2][0].get<OUString>());
-#endif
 }
 
 void Chart2ExportTest::testErrorBarDataRangeODS()
diff --git a/chart2/qa/extras/charttest.hxx b/chart2/qa/extras/charttest.hxx
index 71b20e7..5d0d15e 100644
--- a/chart2/qa/extras/charttest.hxx
+++ b/chart2/qa/extras/charttest.hxx
@@ -301,7 +301,6 @@ std::vector<uno::Sequence<uno::Any> > getDataSeriesLabelsFromChartType( const Re
     Reference<chart2::XDataSeriesContainer> xDSCont(xCT, uno::UNO_QUERY);
     CPPUNIT_ASSERT(xDSCont.is());
     Sequence<uno::Reference<chart2::XDataSeries> > aDataSeriesSeq = xDSCont->getDataSeries();
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aDataSeriesSeq.getLength());
 
     std::vector<uno::Sequence<uno::Any> > aRet;
     for (sal_Int32 i = 0; i < aDataSeriesSeq.getLength(); ++i)


More information about the Libreoffice-commits mailing list