related tdf#51671, store new "hide legend" feature also in ODF
Change-Id: Ibf55f02eccdcadb2d42f5aff8d72bff20ada3b3a
Reviewed-on: https://gerrit.libreoffice.org/64792
Tested-by: Jenkins
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index 815d84c5..2d19060 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -969,6 +969,7 @@ namespace xmloff { namespace token {
XML_HIDDEN_PARAGRAPH,
XML_HIDDEN_TEXT,
XML_HIDE,
XML_HIDE_LEGEND,
XML_HIDE_SHAPE,
XML_HIDE_TEXT,
XML_HIGHLIGHTED_RANGE,
diff --git a/xmloff/inc/SchXMLImport.hxx b/xmloff/inc/SchXMLImport.hxx
index 5b9db7b..e8ca86c 100644
--- a/xmloff/inc/SchXMLImport.hxx
+++ b/xmloff/inc/SchXMLImport.hxx
@@ -136,7 +136,8 @@ enum SchXMLSeriesAttrMap
XML_TOK_SERIES_LABEL_STRING,
XML_TOK_SERIES_ATTACHED_AXIS,
XML_TOK_SERIES_STYLE_NAME,
XML_TOK_SERIES_CHART_CLASS
XML_TOK_SERIES_CHART_CLASS,
XML_TOK_SERIES_HIDE_LEGEND
};
enum SchXMLRegEquationAttrMap
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index f4185d8..8a8e942 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -2669,6 +2669,19 @@ 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());
const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() );
if( nCurrentODFVersion >= SvtSaveOptions::ODFVER_012 )
{
if (xPropSet.is())
{
Any aAny = xPropSet->getPropertyValue("ShowLegendEntry");
if (!aAny.get<bool>())
{
mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_HIDE_LEGEND, OUString::boolean(true));
}
}
}
if (xLabelSeq.is())
{
// Check if the label is direct string value rather than a reference.
diff --git a/xmloff/source/chart/SchXMLImport.cxx b/xmloff/source/chart/SchXMLImport.cxx
index 57b2a8c..12aa351 100644
--- a/xmloff/source/chart/SchXMLImport.cxx
+++ b/xmloff/source/chart/SchXMLImport.cxx
@@ -319,10 +319,11 @@ 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_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 },
{ XML_NAMESPACE_LO_EXT, XML_HIDE_LEGEND, XML_TOK_SERIES_HIDE_LEGEND },
XML_TOKEN_MAP_END
};
diff --git a/xmloff/source/chart/SchXMLSeries2Context.cxx b/xmloff/source/chart/SchXMLSeries2Context.cxx
index c1c3c46..03d0018 100644
--- a/xmloff/source/chart/SchXMLSeries2Context.cxx
+++ b/xmloff/source/chart/SchXMLSeries2Context.cxx
@@ -297,6 +297,7 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib
bool bHasRange = false;
OUString aSeriesLabelRange;
OUString aSeriesLabelString;
bool bHideLegend = false;
for( sal_Int16 i = 0; i < nAttrCount; i++ )
{
@@ -346,6 +347,9 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib
maSeriesChartTypeName = aClassName;
}
break;
case XML_TOK_SERIES_HIDE_LEGEND:
bHideLegend = aValue.toBoolean();
break;
}
}
@@ -390,21 +394,25 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib
SchXMLImportHelper::GetNewDataSeries( mxNewDoc, nCoordinateSystemIndex, maSeriesChartTypeName, ! mrGlobalChartTypeUsedBySeries ));
Reference< chart2::data::XLabeledDataSequence > xLabeledSeq( SchXMLTools::GetNewLabeledDataSequence(), uno::UNO_QUERY_THROW );
if( bIsCandleStick )
Reference< beans::XPropertySet > xSeriesProp( m_xSeries, uno::UNO_QUERY );
if (xSeriesProp.is())
{
// set default color for range-line to black (before applying styles)
Reference< beans::XPropertySet > xSeriesProp( m_xSeries, uno::UNO_QUERY );
if( xSeriesProp.is())
if (bHideLegend)
xSeriesProp->setPropertyValue("ShowLegendEntry", uno::makeAny(false));
if( bIsCandleStick )
{
// set default color for range-line to black (before applying styles)
xSeriesProp->setPropertyValue("Color",
uno::makeAny( sal_Int32( 0x000000 ))); // black
}
else if ( maSeriesChartTypeName == "com.sun.star.chart2.PieChartType" )
{
//@todo: this property should be saved
Reference< beans::XPropertySet > xSeriesProp( m_xSeries, uno::UNO_QUERY );
if( xSeriesProp.is())
uno::makeAny( sal_Int32( 0x000000 ))); // black
}
else if ( maSeriesChartTypeName == "com.sun.star.chart2.PieChartType" )
{
//@todo: this property should be saved
xSeriesProp->setPropertyValue("VaryColorsByPoint",
uno::makeAny( true ));
uno::makeAny( true ));
}
}
Reference<chart2::data::XDataProvider> xDataProvider(mxNewDoc->getDataProvider());
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 8a40bdc..dc54639 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -969,6 +969,7 @@ namespace xmloff { namespace token {
TOKEN( "hidden-paragraph", XML_HIDDEN_PARAGRAPH ),
TOKEN( "hidden-text", XML_HIDDEN_TEXT ),
TOKEN( "hide", XML_HIDE ),
TOKEN( "hide-legend", XML_HIDE_LEGEND ),
TOKEN( "hide-shape", XML_HIDE_SHAPE ),
TOKEN( "hide-text", XML_HIDE_TEXT ),
TOKEN( "highlighted-range", XML_HIGHLIGHTED_RANGE ),
diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt
index c57d2b64..baef6b3 100644
--- a/xmloff/source/token/tokens.txt
+++ b/xmloff/source/token/tokens.txt
@@ -892,6 +892,7 @@ hidden-and-protected
hidden-paragraph
hidden-text
hide
hide-legend
hide-shape
hide-text
highlighted-range