summaryrefslogtreecommitdiff
path: root/xmloff/source/chart/SchXMLExport.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'xmloff/source/chart/SchXMLExport.cxx')
-rw-r--r--xmloff/source/chart/SchXMLExport.cxx89
1 files changed, 46 insertions, 43 deletions
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index cc13eb2de733..c74abe953d2f 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -35,6 +35,8 @@
#include "SchXMLSeriesHelper.hxx"
#include "ColorPropertySet.hxx"
#include "SchXMLTools.hxx"
+#include "SchXMLEnumConverter.hxx"
+
#include <tools/debug.hxx>
#include <rtl/logfile.hxx>
#include <comphelper/processfactory.hxx>
@@ -68,6 +70,7 @@
#include <com/sun/star/chart/XAxisSupplier.hpp>
#include <com/sun/star/chart/XChartDocument.hpp>
#include <com/sun/star/chart/ChartLegendPosition.hpp>
+#include <com/sun/star/chart/ChartLegendExpansion.hpp>
#include <com/sun/star/chart/ChartDataRowSource.hpp>
#include <com/sun/star/chart/ChartAxisAssign.hpp>
#include <com/sun/star/chart/ChartAxisType.hpp>
@@ -245,8 +248,8 @@ public:
void addPosition( const ::com::sun::star::awt::Point & rPosition );
void addPosition( com::sun::star::uno::Reference< com::sun::star::drawing::XShape > xShape );
/// add svg size as attribute for current element
- void addSize( const ::com::sun::star::awt::Size & rSize );
- void addSize( com::sun::star::uno::Reference< com::sun::star::drawing::XShape > xShape );
+ void addSize( const ::com::sun::star::awt::Size & rSize, bool bIsOOoNamespace = false );
+ void addSize( com::sun::star::uno::Reference< com::sun::star::drawing::XShape > xShape, bool bIsOOoNamespace = false );
/// fills the member msString with the appropriate String (i.e. "A3")
void getCellAddress( sal_Int32 nCol, sal_Int32 nRow );
/// exports a string as a paragraph element
@@ -1427,51 +1430,50 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument >&
Reference< beans::XPropertySet > xProp( rChartDoc->getLegend(), uno::UNO_QUERY );
if( xProp.is())
{
- chart::ChartLegendPosition aLegendPos = chart::ChartLegendPosition_NONE;
+ // export legend anchor position
try
{
- Any aAny( xProp->getPropertyValue(
- OUString( RTL_CONSTASCII_USTRINGPARAM( "Alignment" ))));
- aAny >>= aLegendPos;
+ Any aAny( xProp->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Alignment" ))));
+ if( SchXMLEnumConverter::getLegendPositionConverter().exportXML( msString, aAny, mrExport.GetMM100UnitConverter() ) )
+ mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_LEGEND_POSITION, msString );
}
catch( beans::UnknownPropertyException & )
{
DBG_WARNING( "Property Align not found in ChartLegend" );
}
- switch( aLegendPos )
+ // 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 && nCurrentODFVersion == SvtSaveOptions::ODFVER_LATEST )//do not export legend-expansion to ODF 1.0 and export size only if extensions are enabled //#i28670# todo: change this dependent on fileformat evolution
{
- case chart::ChartLegendPosition_LEFT:
-// msString = GetXMLToken(XML_LEFT);
- // #i35421# change left->start (not clear why this was done)
- msString = GetXMLToken(XML_START);
- break;
- case chart::ChartLegendPosition_RIGHT:
-// msString = GetXMLToken(XML_RIGHT);
- // #i35421# change right->end (not clear why this was done)
- msString = GetXMLToken(XML_END);
- break;
- case chart::ChartLegendPosition_TOP:
- msString = GetXMLToken(XML_TOP);
- break;
- case chart::ChartLegendPosition_BOTTOM:
- msString = GetXMLToken(XML_BOTTOM);
- break;
- case chart::ChartLegendPosition_NONE:
- case chart::ChartLegendPosition_MAKE_FIXED_SIZE:
- // nothing
- break;
+ try
+ {
+ chart::ChartLegendExpansion nLegendExpansion = chart::ChartLegendExpansion_HIGH;
+ OUString aExpansionString;
+ Any aAny( xProp->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Expansion" ))));
+ bool bHasExpansion = (aAny >>= nLegendExpansion);
+ if( bHasExpansion && SchXMLEnumConverter::getLegendExpansionConverter().exportXML( aExpansionString, aAny, mrExport.GetMM100UnitConverter() ) )
+ {
+ mrExport.AddAttribute( XML_NAMESPACE_STYLE, XML_LEGEND_EXPANSION, aExpansionString );
+ if( nLegendExpansion == chart::ChartLegendExpansion_CUSTOM)
+ {
+ awt::Size aSize( xLegendShape->getSize() );
+ addSize( aSize, true );
+ rtl::OUStringBuffer aAspectRatioString;
+ SvXMLUnitConverter::convertDouble(aAspectRatioString, double(aSize.Width)/double(aSize.Height));
+ mrExport.AddAttribute( XML_NAMESPACE_STYLE, XML_LEGEND_EXPANSION_ASPECT_RATIO, aAspectRatioString.makeStringAndClear() );
+ }
+ }
+ }
+ catch( beans::UnknownPropertyException & )
+ {
+ DBG_WARNING( "Property Expansion not found in ChartLegend" );
+ }
}
-
- // export anchor position
- if( msString.getLength())
- mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_LEGEND_POSITION, msString );
-
- // export absolute position
- msString = OUString();
- Reference< drawing::XShape > xShape( xProp, uno::UNO_QUERY );
- if( xShape.is())
- addPosition( xShape );
}
// write style name
@@ -3535,21 +3537,22 @@ void SchXMLExportHelper_Impl::addPosition( Reference< drawing::XShape > xShape )
addPosition( xShape->getPosition());
}
-void SchXMLExportHelper_Impl::addSize( const awt::Size & rSize )
+void SchXMLExportHelper_Impl::addSize( const awt::Size & rSize, bool bIsOOoNamespace)
{
mrExport.GetMM100UnitConverter().convertMeasure( msStringBuffer, rSize.Width );
msString = msStringBuffer.makeStringAndClear();
- mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_WIDTH, msString );
+ mrExport.AddAttribute( bIsOOoNamespace ? XML_NAMESPACE_CHART_EXT : XML_NAMESPACE_SVG , XML_WIDTH, msString );
+
- mrExport.GetMM100UnitConverter().convertMeasure( msStringBuffer, rSize.Height );
+ mrExport.GetMM100UnitConverter().convertMeasure( msStringBuffer, rSize.Height);
msString = msStringBuffer.makeStringAndClear();
- mrExport.AddAttribute( XML_NAMESPACE_SVG, XML_HEIGHT, msString );
+ mrExport.AddAttribute( bIsOOoNamespace ? XML_NAMESPACE_CHART_EXT : XML_NAMESPACE_SVG, XML_HEIGHT, msString );
}
-void SchXMLExportHelper_Impl::addSize( Reference< drawing::XShape > xShape )
+void SchXMLExportHelper_Impl::addSize( Reference< drawing::XShape > xShape, bool bIsOOoNamespace )
{
if( xShape.is())
- addSize( xShape->getSize() );
+ addSize( xShape->getSize(), bIsOOoNamespace );
}
awt::Size SchXMLExportHelper_Impl::getPageSize( const Reference< chart2::XChartDocument > & xChartDoc ) const