diff options
author | Markus Mohrhard <markus.mohrhard@collabora.co.uk> | 2014-04-05 16:49:39 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-04-05 18:34:22 +0200 |
commit | 89bbc9286778df711f786f50c27f65315b29c39a (patch) | |
tree | da9adfbc69b3900bdb9e4d7154e701ce19fae20b | |
parent | 2c59f12e5a9b062f91d6f0b85d4b6196728c689c (diff) |
export label names that are strings, fdo#64722, cp#1000058
Change-Id: Id72e9778c70db02b942326c6f8b5f448acb28b41
-rw-r--r-- | include/xmloff/xmltoken.hxx | 1 | ||||
-rw-r--r-- | xmloff/inc/SchXMLImport.hxx | 1 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLExport.cxx | 28 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLImport.cxx | 1 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLSeries2Context.cxx | 10 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLTools.cxx | 32 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLTools.hxx | 5 | ||||
-rw-r--r-- | xmloff/source/core/xmltoken.cxx | 1 |
8 files changed, 75 insertions, 4 deletions
diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx index c934912203d5..9e206d855bd1 100644 --- a/include/xmloff/xmltoken.hxx +++ b/include/xmloff/xmltoken.hxx @@ -1066,6 +1066,7 @@ namespace xmloff { namespace token { XML_LABEL_CELL_RANGE_ADDRESS, XML_LABEL_RANGE, XML_LABEL_RANGES, + XML_LABEL_STRING, XML_LAMBDA, XML_LANDSCAPE, XML_LANGUAGE, diff --git a/xmloff/inc/SchXMLImport.hxx b/xmloff/inc/SchXMLImport.hxx index 173788a92a37..8b6286dfedef 100644 --- a/xmloff/inc/SchXMLImport.hxx +++ b/xmloff/inc/SchXMLImport.hxx @@ -140,6 +140,7 @@ enum SchXMLSeriesAttrMap { XML_TOK_SERIES_CELL_RANGE, XML_TOK_SERIES_LABEL_ADDRESS, + XML_TOK_SERIES_LABEL_STRING, XML_TOK_SERIES_ATTACHED_AXIS, XML_TOK_SERIES_STYLE_NAME, XML_TOK_SERIES_CHART_CLASS diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index 859e4a5e6f5b..bd17360ac261 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -2553,6 +2553,14 @@ namespace //no doubles and no texts return false; } + + bool isString(const OUString& rString) + { + if(rString.startsWith("\"") && rString.endsWith("\"")) + return true; + + return false; + } } void SchXMLExportHelper_Impl::exportSeries( @@ -2720,10 +2728,21 @@ void SchXMLExportHelper_Impl::exportSeries( 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 )); + + OUString aXMLRange = lcl_ConvertRange( aRange, xNewDoc ); + if(aXMLRange.isEmpty() && !aRange.isEmpty()) + { + // might just be a string + bool bIsString = isString(aRange); + if(bIsString) + { + mrExport.AddAttribute( XML_NAMESPACE_LO_EXT, + XML_LABEL_STRING, aRange ); + } + } + else + mrExport.AddAttribute( XML_NAMESPACE_CHART, + XML_LABEL_CELL_ADDRESS, aXMLRange ); } if( xLabelSeq.is() || xValuesSeq.is() ) aSeriesLabelValuesPair = tLabelValuesDataPair( xLabelSeq, xValuesSeq ); @@ -3138,6 +3157,7 @@ void SchXMLExportHelper_Impl::exportCandleStickSeries( Reference< chart2::XChartDocument > xNewDoc( mrExport.GetModel(), uno::UNO_QUERY ); //@todo: export data points + //TODO: moggi: same code three times // open if( bJapaneseCandleSticks ) { diff --git a/xmloff/source/chart/SchXMLImport.cxx b/xmloff/source/chart/SchXMLImport.cxx index 3a3dc51e9370..042dcba37848 100644 --- a/xmloff/source/chart/SchXMLImport.cxx +++ b/xmloff/source/chart/SchXMLImport.cxx @@ -339,6 +339,7 @@ const SvXMLTokenMap& SchXMLImportHelper::GetSeriesAttrTokenMap() { { XML_NAMESPACE_CHART, XML_VALUES_CELL_RANGE_ADDRESS, XML_TOK_SERIES_CELL_RANGE }, { XML_NAMESPACE_CHART, XML_LABEL_CELL_ADDRESS, XML_TOK_SERIES_LABEL_ADDRESS }, + { XML_NAMESPACE_LO_EXT, XML_LABEL_STRING, XML_TOK_SERIES_LABEL_STRING }, { XML_NAMESPACE_CHART, XML_ATTACHED_AXIS, XML_TOK_SERIES_ATTACHED_AXIS }, { XML_NAMESPACE_CHART, XML_STYLE_NAME, XML_TOK_SERIES_STYLE_NAME }, { XML_NAMESPACE_CHART, XML_CLASS, XML_TOK_SERIES_CHART_CLASS }, diff --git a/xmloff/source/chart/SchXMLSeries2Context.cxx b/xmloff/source/chart/SchXMLSeries2Context.cxx index 795effbbbe30..54dcd57602b6 100644 --- a/xmloff/source/chart/SchXMLSeries2Context.cxx +++ b/xmloff/source/chart/SchXMLSeries2Context.cxx @@ -308,6 +308,7 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib bool bHasRange = false; OUString aSeriesLabelRange; + OUString aSeriesLabelString; for( sal_Int16 i = 0; i < nAttrCount; i++ ) { @@ -325,6 +326,9 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib case XML_TOK_SERIES_LABEL_ADDRESS: aSeriesLabelRange = aValue; break; + case XML_TOK_SERIES_LABEL_STRING: + aSeriesLabelString = aValue; + break; case XML_TOK_SERIES_ATTACHED_AXIS: { sal_Int32 nNumOfAxes = mrAxes.size(); @@ -442,6 +446,12 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib SchXMLTools::CreateDataSequence( aSeriesLabelRange, mxNewDoc ); xLabeledSeq->setLabel( xLabelSequence ); } + else if( !aSeriesLabelString.isEmpty() ) + { + Reference< chart2::data::XDataSequence > xLabelSequence = + SchXMLTools::CreateDataSequenceWithoutConvert( aSeriesLabelString, mxNewDoc ); + xLabeledSeq->setLabel( xLabelSequence ); + } // Note: Even if we have no label, we have to register the label // for creation, because internal data always has labels. If diff --git a/xmloff/source/chart/SchXMLTools.cxx b/xmloff/source/chart/SchXMLTools.cxx index 8e86b91a1fc0..e37ed835295c 100644 --- a/xmloff/source/chart/SchXMLTools.cxx +++ b/xmloff/source/chart/SchXMLTools.cxx @@ -424,6 +424,38 @@ Reference< chart2::data::XDataSequence > CreateDataSequence( return xRet; } +Reference< chart2::data::XDataSequence > CreateDataSequenceWithoutConvert( + const OUString & rRange, + const Reference< chart2::XChartDocument >& xChartDoc ) +{ + Reference< chart2::data::XDataSequence > xRet; + + if( !xChartDoc.is() ) + { + SAL_WARN("xmloff.chart", "need a chart document" ); + return xRet; + } + + Reference< chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider() ); + if( !xDataProvider.is() ) + { + SAL_WARN("xmloff.chart", "need a data provider" ); + return xRet; + } + + try + { + xRet.set( xDataProvider->createDataSequenceByRangeRepresentation( rRange ) ); + SchXMLTools::setXMLRangePropertyAtDataSequence( xRet, rRange ); + } + catch( const lang::IllegalArgumentException & ) + { + SAL_WARN("xmloff.chart", "could not create data sequence" ); + } + + return xRet; +} + void CreateCategories( const uno::Reference< chart2::data::XDataProvider > & xDataProvider, const uno::Reference< chart2::XChartDocument > & xNewDoc, diff --git a/xmloff/source/chart/SchXMLTools.hxx b/xmloff/source/chart/SchXMLTools.hxx index 0b6f49a57bc9..ed21ea23932c 100644 --- a/xmloff/source/chart/SchXMLTools.hxx +++ b/xmloff/source/chart/SchXMLTools.hxx @@ -86,6 +86,11 @@ namespace SchXMLTools const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDoc ); + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence > CreateDataSequenceWithoutConvert( + const OUString& rRange, + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument >& xChartDoc ); + void CreateCategories( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider > & xDataProvider, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xNewDoc, diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index c28b8505e7c2..09027cdac1e7 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -1071,6 +1071,7 @@ namespace xmloff { namespace token { TOKEN( "label-cell-range-address", XML_LABEL_CELL_RANGE_ADDRESS ), TOKEN( "label-range", XML_LABEL_RANGE ), TOKEN( "label-ranges", XML_LABEL_RANGES ), + TOKEN( "label-string", XML_LABEL_STRING ), TOKEN( "lambda", XML_LAMBDA ), TOKEN( "landscape", XML_LANDSCAPE ), TOKEN( "language", XML_LANGUAGE ), |