diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-06-12 11:24:30 -0400 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-06-17 14:13:02 +0000 |
commit | 5b606507e4cbb2b579c90461a9d433bfe9c5cdf1 (patch) | |
tree | 1595935da789268a22ae9ddce9b59a33997c405d | |
parent | 35e31aac7224676b383d63ed4591bbc9c6ba4c08 (diff) |
fdo#77506: More reliable way to determine label strings.
Not beautiful, but doable.
(cherry picked from commit a2a1a59a448420a858724371c4a339f75ebe8c1e)
Conflicts:
sc/source/ui/unoobj/chart2uno.cxx
xmloff/source/chart/SchXMLExport.cxx
Change-Id: I6f3b00d620e7d7d19cc05ec4239deeb14d0d5201
Reviewed-on: https://gerrit.libreoffice.org/9757
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r-- | sc/inc/unonames.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/unoobj/chart2uno.cxx | 12 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLExport.cxx | 38 |
3 files changed, 42 insertions, 10 deletions
diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx index ff4cf9347945..025fed97524c 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 093dbbe36d53..10e47d0d1ad3 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -3499,6 +3499,18 @@ uno::Any SAL_CALL ScChart2DataSequence::getPropertyValue( BuildDataCache(); aRet <<= m_aHiddenValues; } + 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 2de23c694a71..1647e33f02bd 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -2588,7 +2588,6 @@ void SchXMLExportHelper_Impl::exportSeries( OUString aFirstXDomainRange; OUString aFirstYDomainRange; - bool modifyLabelRange = false; std::vector< XMLPropertyState > aPropertyStates; @@ -2734,17 +2733,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()) { + 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()) + { + try + { + xLSProp->getPropertyValue("HasStringLabel") >>= bHasString; + } + catch (const beans::UnknownPropertyException&) {} + } + 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); - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_LABEL_CELL_ADDRESS, - lcl_ConvertRange( - aRange, - xNewDoc )); + + if (bHasString) + { + mrExport.AddAttribute( + XML_NAMESPACE_CHART, XML_LABEL_CELL_ADDRESS, aRange); + } + else + { + mrExport.AddAttribute( + XML_NAMESPACE_CHART, XML_LABEL_CELL_ADDRESS, + lcl_ConvertRange( + xLabelSeq->getSourceRangeRepresentation(), xNewDoc)); + } } + if( xLabelSeq.is() || xValuesSeq.is() ) aSeriesLabelValuesPair = tLabelValuesDataPair( xLabelSeq, xValuesSeq ); |