summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorTünde Tóth <tundeth@gmail.com>2020-03-02 14:57:20 +0100
committerLászló Németh <nemeth@numbertext.org>2020-03-05 12:45:54 +0100
commit65123d41f62597053bc3893ee4fb46868a6b1f2d (patch)
treee099c27ca8b6cf3c3cabdce3eda40f096ceeb8d1 /xmloff
parent9fab1ba8ddc59924c633aa17c65f7330a4762726 (diff)
tdf#75330 chart: implement ODF import/export of legend overlay feature
Follow-up of commit 9fab1ba8ddc59924c633aa17c65f7330a4762726 (tdf#75330 add a new overlay/no-overlay feature for the legend). Change-Id: I7781fd8b926d4add56f3db0d56dceab8e27e5f85 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89836 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/chart/SchXMLExport.cxx18
-rw-r--r--xmloff/source/chart/SchXMLLegendContext.cxx31
-rw-r--r--xmloff/source/core/xmltoken.cxx1
-rw-r--r--xmloff/source/token/tokens.txt1
4 files changed, 40 insertions, 11 deletions
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index 51f399956ae0..4344d6187b5e 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -1370,6 +1370,8 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument >
Reference< beans::XPropertySet > xProp( rChartDoc->getLegend(), uno::UNO_QUERY );
if( xProp.is())
{
+ const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() );
+
// export legend anchor position
try
{
@@ -1382,12 +1384,26 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument >
SAL_WARN("xmloff.chart", "Property Align not found in ChartLegend" );
}
+ // export legend overlay
+ try
+ {
+ if (nCurrentODFVersion > SvtSaveOptions::ODFVER_012)
+ {
+ Any aAny( xProp->getPropertyValue("Overlay"));
+ if(aAny.get<bool>())
+ mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_OVERLAY, OUString::boolean(true));
+ }
+ }
+ catch( const beans::UnknownPropertyException & )
+ {
+ SAL_WARN("xmloff.chart", "Property Overlay not found in ChartLegend" );
+ }
+
// export absolute legend position
Reference< drawing::XShape > xLegendShape( xProp, uno::UNO_QUERY );
addPosition( xLegendShape );
// export legend size
- const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() );
if( xLegendShape.is() && nCurrentODFVersion >= SvtSaveOptions::ODFVER_012 )
{
try
diff --git a/xmloff/source/chart/SchXMLLegendContext.cxx b/xmloff/source/chart/SchXMLLegendContext.cxx
index 902fffb25f46..3427fa3683a7 100644
--- a/xmloff/source/chart/SchXMLLegendContext.cxx
+++ b/xmloff/source/chart/SchXMLLegendContext.cxx
@@ -40,6 +40,7 @@ namespace
enum LegendAttributeTokens
{
XML_TOK_LEGEND_POSITION,
+ XML_TOK_LEGEND_OVERLAY,
XML_TOK_LEGEND_X,
XML_TOK_LEGEND_Y,
XML_TOK_LEGEND_STYLE_NAME,
@@ -54,6 +55,7 @@ enum LegendAttributeTokens
const SvXMLTokenMapEntry aLegendAttributeTokenMap[] =
{
{ XML_NAMESPACE_CHART, XML_LEGEND_POSITION, XML_TOK_LEGEND_POSITION },
+ { XML_NAMESPACE_LO_EXT, XML_OVERLAY, XML_TOK_LEGEND_OVERLAY },
{ XML_NAMESPACE_SVG, XML_X, XML_TOK_LEGEND_X },
{ XML_NAMESPACE_SVG, XML_Y, XML_TOK_LEGEND_Y },
{ XML_NAMESPACE_CHART, XML_STYLE_NAME, XML_TOK_LEGEND_STYLE_NAME },
@@ -117,6 +119,7 @@ void SchXMLLegendContext::StartElement( const uno::Reference< xml::sax::XAttribu
const SvXMLTokenMap& rAttrTokenMap = theLegendAttributeTokenMap::get();
awt::Point aLegendPos;
+ bool bOverlay = false;
bool bHasXPosition=false;
bool bHasYPosition=false;
awt::Size aLegendSize;
@@ -138,19 +141,27 @@ void SchXMLLegendContext::StartElement( const uno::Reference< xml::sax::XAttribu
switch( rAttrTokenMap.Get( nPrefix, aLocalName ))
{
case XML_TOK_LEGEND_POSITION:
+ try
{
- try
- {
- if( SchXMLEnumConverter::getLegendPositionConverter().importXML( aValue, aAny, GetImport().GetMM100UnitConverter() ) )
- xLegendProps->setPropertyValue("Alignment", aAny );
- }
- catch(const beans::UnknownPropertyException&)
- {
- SAL_INFO("xmloff.chart", "Property Alignment (legend) not found" );
- }
+ if( SchXMLEnumConverter::getLegendPositionConverter().importXML( aValue, aAny, GetImport().GetMM100UnitConverter() ) )
+ xLegendProps->setPropertyValue("Alignment", aAny );
+ }
+ catch(const beans::UnknownPropertyException&)
+ {
+ SAL_INFO("xmloff.chart", "Property Alignment (legend) not found" );
+ }
+ break;
+ case XML_TOK_LEGEND_OVERLAY:
+ try
+ {
+ bOverlay = xAttrList->getValueByIndex(i).toBoolean();
+ xLegendProps->setPropertyValue("Overlay", uno::makeAny(bOverlay));
+ }
+ catch(const beans::UnknownPropertyException&)
+ {
+ SAL_INFO("xmloff.chart", "Property Overlay (legend) not found" );
}
break;
-
case XML_TOK_LEGEND_X:
GetImport().GetMM100UnitConverter().convertMeasureToCore(
aLegendPos.X, aValue );
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 46125e067982..b55c4c9c7a7b 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -1391,6 +1391,7 @@ namespace xmloff::token {
TOKEN( "outset", XML_OUTSET ),
TOKEN( "outside", XML_OUTSIDE ),
TOKEN( "overlap", XML_OVERLAP ),
+ TOKEN( "overlay", XML_OVERLAY ),
TOKEN( "p", XML_P ),
TOKEN( "package-name", XML_PACKAGE_NAME ),
TOKEN( "padding", XML_PADDING ),
diff --git a/xmloff/source/token/tokens.txt b/xmloff/source/token/tokens.txt
index 31dae860a15e..5d14dd65c820 100644
--- a/xmloff/source/token/tokens.txt
+++ b/xmloff/source/token/tokens.txt
@@ -1304,6 +1304,7 @@ outline-style
outset
outside
overlap
+overlay
p
package-name
padding