30#include <com/sun/star/chart/ChartLegendExpansion.hpp>
31#include <com/sun/star/chart/XChartDocument.hpp>
32#include <com/sun/star/drawing/FillStyle.hpp>
39 mrImportHelper( rImpHelper )
44 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
51 uno::Reference< beans::XPropertySet > xDocProp( xDoc, uno::UNO_QUERY );
56 xDocProp->setPropertyValue(
"HasLegend",
uno::Any(
true ) );
58 catch(
const beans::UnknownPropertyException&)
60 SAL_INFO(
"xmloff.chart",
"Property HasLegend not found" );
64 uno::Reference< drawing::XShape > xLegendShape = xDoc->getLegend();
65 uno::Reference< beans::XPropertySet > xLegendProps( xLegendShape, uno::UNO_QUERY );
66 if( !xLegendShape.is() || !xLegendProps.is() )
68 SAL_INFO(
"xmloff.chart",
"legend could not be created" );
73 awt::Point aLegendPos;
74 bool bOverlay =
false;
75 bool bHasXPosition=
false;
76 bool bHasYPosition=
false;
77 awt::Size aLegendSize;
79 bool bHasHeight=
false;
80 chart::ChartLegendExpansion nLegendExpansion = chart::ChartLegendExpansion_HIGH;
81 bool bHasExpansion=
false;
83 OUString sAutoStyleName;
88 switch(aIter.getToken())
94 xLegendProps->setPropertyValue(
"Alignment", aAny );
96 catch(
const beans::UnknownPropertyException&)
98 SAL_INFO(
"xmloff.chart",
"Property Alignment (legend) not found" );
104 bOverlay = aIter.toBoolean();
105 xLegendProps->setPropertyValue(
"Overlay",
uno::Any(bOverlay));
107 catch(
const beans::UnknownPropertyException&)
109 SAL_INFO(
"xmloff.chart",
"Property Overlay (legend) not found" );
114 GetImport().GetMM100UnitConverter().convertMeasureToCore(
115 aLegendPos.X, aIter.toView() );
116 bHasXPosition =
true;
120 GetImport().GetMM100UnitConverter().convertMeasureToCore(
121 aLegendPos.Y, aIter.toView() );
122 bHasYPosition =
true;
125 sAutoStyleName = aIter.toString();
129 bHasExpansion = (aAny>>=nLegendExpansion);
136 GetImport().GetMM100UnitConverter().convertMeasureToCore(
137 aLegendSize.Width, aIter.toView() );
143 GetImport().GetMM100UnitConverter().convertMeasureToCore(
144 aLegendSize.Height, aIter.toView() );
153 if( bHasExpansion && nLegendExpansion!= chart::ChartLegendExpansion_CUSTOM )
154 xLegendProps->setPropertyValue(
"Expansion",
uno::Any(nLegendExpansion) );
155 else if( bHasHeight && bHasWidth )
156 xLegendShape->setSize( aLegendSize );
158 if( bHasXPosition && bHasYPosition )
159 xLegendShape->setPosition( aLegendPos );
162 xLegendProps->setPropertyValue(
"FillStyle",
uno::Any( drawing::FillStyle_NONE ));
static XMLEnumPropertyHdl & getLegendPositionConverter()
With this class you can import a <chart:chart> element containing its data as <table:table> element o...
const css::uno::Reference< css::chart::XChartDocument > & GetChartDocument() const
void FillAutoStyle(const OUString &rAutoStyleName, const css::uno::Reference< css::beans::XPropertySet > &rProp)
Fill in the autostyle.
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
SchXMLImportHelper & mrImportHelper
SchXMLLegendContext(SchXMLImportHelper &rImpHelper, SvXMLImport &rImport)
virtual ~SchXMLLegendContext() override
This class deliberately does not support XWeak, to improve performance when loading large documents.
SvXMLImport & GetImport()
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
#define SAL_INFO(area, stream)
XMLOFF_DLLPUBLIC bool importXML(css::uno::Reference< css::xml::sax::XFastAttributeList > const &xAttrList, css::uno::Any &rValue, OUString &rStrName, SvXMLImport &rImport)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Handling of tokens in XML:
@ XML_LEGEND_EXPANSION_ASPECT_RATIO
#define XMLOFF_WARN_UNKNOWN(area, rIter)
#define XML_ELEMENT(prefix, name)