summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2018-12-07 23:28:28 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2018-12-08 01:25:23 +0100
commit7869b3d6e4b24a0567ad2e492038d74c03b06b7d (patch)
treeacbb5035334b9cd2c94ba2ad5c0db38056cbda49 /xmloff
parent897d7314429d2a7aa5ba25111dc454a159bd8e5e (diff)
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>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/inc/SchXMLImport.hxx3
-rw-r--r--xmloff/source/chart/SchXMLExport.cxx13
-rw-r--r--xmloff/source/chart/SchXMLImport.cxx3
-rw-r--r--xmloff/source/chart/SchXMLSeries2Context.cxx32
-rw-r--r--xmloff/source/core/xmltoken.cxx1
-rw-r--r--xmloff/source/token/tokens.txt1
6 files changed, 39 insertions, 14 deletions
diff --git a/xmloff/inc/SchXMLImport.hxx b/xmloff/inc/SchXMLImport.hxx
index 5b9db7bdac34..e8ca86cd589a 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 f4185d8692b9..8a8e94265dc1 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 57b2a8c73b12..12aa351d8fcb 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 c1c3c46a4b56..03d00181ff0e 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 8a40bdc11fc9..dc546397523c 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 c57d2b646ddc..baef6b3a31a1 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