Kaydet (Commit) 89bbc928 authored tarafından Markus Mohrhard's avatar Markus Mohrhard Kaydeden (comit) Markus Mohrhard

export label names that are strings, fdo#64722, cp#1000058

Change-Id: Id72e9778c70db02b942326c6f8b5f448acb28b41
üst 2c59f12e
...@@ -1066,6 +1066,7 @@ namespace xmloff { namespace token { ...@@ -1066,6 +1066,7 @@ namespace xmloff { namespace token {
XML_LABEL_CELL_RANGE_ADDRESS, XML_LABEL_CELL_RANGE_ADDRESS,
XML_LABEL_RANGE, XML_LABEL_RANGE,
XML_LABEL_RANGES, XML_LABEL_RANGES,
XML_LABEL_STRING,
XML_LAMBDA, XML_LAMBDA,
XML_LANDSCAPE, XML_LANDSCAPE,
XML_LANGUAGE, XML_LANGUAGE,
......
...@@ -140,6 +140,7 @@ enum SchXMLSeriesAttrMap ...@@ -140,6 +140,7 @@ enum SchXMLSeriesAttrMap
{ {
XML_TOK_SERIES_CELL_RANGE, XML_TOK_SERIES_CELL_RANGE,
XML_TOK_SERIES_LABEL_ADDRESS, XML_TOK_SERIES_LABEL_ADDRESS,
XML_TOK_SERIES_LABEL_STRING,
XML_TOK_SERIES_ATTACHED_AXIS, XML_TOK_SERIES_ATTACHED_AXIS,
XML_TOK_SERIES_STYLE_NAME, XML_TOK_SERIES_STYLE_NAME,
XML_TOK_SERIES_CHART_CLASS XML_TOK_SERIES_CHART_CLASS
......
...@@ -2553,6 +2553,14 @@ namespace ...@@ -2553,6 +2553,14 @@ namespace
//no doubles and no texts //no doubles and no texts
return false; return false;
} }
bool isString(const OUString& rString)
{
if(rString.startsWith("\"") && rString.endsWith("\""))
return true;
return false;
}
} }
void SchXMLExportHelper_Impl::exportSeries( void SchXMLExportHelper_Impl::exportSeries(
...@@ -2720,10 +2728,21 @@ void SchXMLExportHelper_Impl::exportSeries( ...@@ -2720,10 +2728,21 @@ void SchXMLExportHelper_Impl::exportSeries(
modifyLabelRange = true; modifyLabelRange = true;
if (modifyLabelRange) if (modifyLabelRange)
aRange = "label " + OUString::number(aRange.copy( OUString("label").getLength()).toInt32() - 1); aRange = "label " + OUString::number(aRange.copy( OUString("label").getLength()).toInt32() - 1);
mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_LABEL_CELL_ADDRESS,
lcl_ConvertRange( OUString aXMLRange = lcl_ConvertRange( aRange, xNewDoc );
aRange, if(aXMLRange.isEmpty() && !aRange.isEmpty())
xNewDoc )); {
// 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() ) if( xLabelSeq.is() || xValuesSeq.is() )
aSeriesLabelValuesPair = tLabelValuesDataPair( xLabelSeq, xValuesSeq ); aSeriesLabelValuesPair = tLabelValuesDataPair( xLabelSeq, xValuesSeq );
...@@ -3138,6 +3157,7 @@ void SchXMLExportHelper_Impl::exportCandleStickSeries( ...@@ -3138,6 +3157,7 @@ void SchXMLExportHelper_Impl::exportCandleStickSeries(
Reference< chart2::XChartDocument > xNewDoc( mrExport.GetModel(), uno::UNO_QUERY ); Reference< chart2::XChartDocument > xNewDoc( mrExport.GetModel(), uno::UNO_QUERY );
//@todo: export data points //@todo: export data points
//TODO: moggi: same code three times
// open // open
if( bJapaneseCandleSticks ) if( bJapaneseCandleSticks )
{ {
......
...@@ -339,6 +339,7 @@ const SvXMLTokenMap& SchXMLImportHelper::GetSeriesAttrTokenMap() ...@@ -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_VALUES_CELL_RANGE_ADDRESS, XML_TOK_SERIES_CELL_RANGE },
{ XML_NAMESPACE_CHART, XML_LABEL_CELL_ADDRESS, XML_TOK_SERIES_LABEL_ADDRESS }, { 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_ATTACHED_AXIS, XML_TOK_SERIES_ATTACHED_AXIS },
{ XML_NAMESPACE_CHART, XML_STYLE_NAME, XML_TOK_SERIES_STYLE_NAME }, { XML_NAMESPACE_CHART, XML_STYLE_NAME, XML_TOK_SERIES_STYLE_NAME },
{ XML_NAMESPACE_CHART, XML_CLASS, XML_TOK_SERIES_CHART_CLASS }, { XML_NAMESPACE_CHART, XML_CLASS, XML_TOK_SERIES_CHART_CLASS },
......
...@@ -308,6 +308,7 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib ...@@ -308,6 +308,7 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib
bool bHasRange = false; bool bHasRange = false;
OUString aSeriesLabelRange; OUString aSeriesLabelRange;
OUString aSeriesLabelString;
for( sal_Int16 i = 0; i < nAttrCount; i++ ) for( sal_Int16 i = 0; i < nAttrCount; i++ )
{ {
...@@ -325,6 +326,9 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib ...@@ -325,6 +326,9 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib
case XML_TOK_SERIES_LABEL_ADDRESS: case XML_TOK_SERIES_LABEL_ADDRESS:
aSeriesLabelRange = aValue; aSeriesLabelRange = aValue;
break; break;
case XML_TOK_SERIES_LABEL_STRING:
aSeriesLabelString = aValue;
break;
case XML_TOK_SERIES_ATTACHED_AXIS: case XML_TOK_SERIES_ATTACHED_AXIS:
{ {
sal_Int32 nNumOfAxes = mrAxes.size(); sal_Int32 nNumOfAxes = mrAxes.size();
...@@ -442,6 +446,12 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib ...@@ -442,6 +446,12 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib
SchXMLTools::CreateDataSequence( aSeriesLabelRange, mxNewDoc ); SchXMLTools::CreateDataSequence( aSeriesLabelRange, mxNewDoc );
xLabeledSeq->setLabel( xLabelSequence ); 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 // Note: Even if we have no label, we have to register the label
// for creation, because internal data always has labels. If // for creation, because internal data always has labels. If
......
...@@ -424,6 +424,38 @@ Reference< chart2::data::XDataSequence > CreateDataSequence( ...@@ -424,6 +424,38 @@ Reference< chart2::data::XDataSequence > CreateDataSequence(
return xRet; 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( void CreateCategories(
const uno::Reference< chart2::data::XDataProvider > & xDataProvider, const uno::Reference< chart2::data::XDataProvider > & xDataProvider,
const uno::Reference< chart2::XChartDocument > & xNewDoc, const uno::Reference< chart2::XChartDocument > & xNewDoc,
......
...@@ -86,6 +86,11 @@ namespace SchXMLTools ...@@ -86,6 +86,11 @@ namespace SchXMLTools
const ::com::sun::star::uno::Reference< const ::com::sun::star::uno::Reference<
::com::sun::star::chart2::XChartDocument >& xChartDoc ); ::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( 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::data::XDataProvider > & xDataProvider,
const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xNewDoc, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xNewDoc,
......
...@@ -1071,6 +1071,7 @@ namespace xmloff { namespace token { ...@@ -1071,6 +1071,7 @@ namespace xmloff { namespace token {
TOKEN( "label-cell-range-address", XML_LABEL_CELL_RANGE_ADDRESS ), TOKEN( "label-cell-range-address", XML_LABEL_CELL_RANGE_ADDRESS ),
TOKEN( "label-range", XML_LABEL_RANGE ), TOKEN( "label-range", XML_LABEL_RANGE ),
TOKEN( "label-ranges", XML_LABEL_RANGES ), TOKEN( "label-ranges", XML_LABEL_RANGES ),
TOKEN( "label-string", XML_LABEL_STRING ),
TOKEN( "lambda", XML_LAMBDA ), TOKEN( "lambda", XML_LAMBDA ),
TOKEN( "landscape", XML_LANDSCAPE ), TOKEN( "landscape", XML_LANDSCAPE ),
TOKEN( "language", XML_LANGUAGE ), TOKEN( "language", XML_LANGUAGE ),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment