summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngrid Halama [iha] <Ingrid.Halama@oracle.com>2011-01-24 17:44:18 +0100
committerIngrid Halama [iha] <Ingrid.Halama@oracle.com>2011-01-24 17:44:18 +0100
commitc0f7a3f7cf33debd0f6049c415c412d14526a79e (patch)
tree0e55294af5e47936dbfa7532c705c8b5301727c5
parente26194b675380ad6b6a1287f97bce93006be176c (diff)
chart52: #28670# make the legend within charts resizeable - part 2
-rw-r--r--xmloff/inc/SchXMLImport.hxx8
-rw-r--r--xmloff/inc/xmloff/SchXMLImportHelper.hxx2
-rw-r--r--xmloff/inc/xmloff/xmltoken.hxx1
-rw-r--r--xmloff/source/chart/SchXMLChartContext.cxx128
-rw-r--r--xmloff/source/chart/SchXMLChartContext.hxx15
-rwxr-xr-xxmloff/source/chart/SchXMLEnumConverter.cxx104
-rwxr-xr-xxmloff/source/chart/SchXMLEnumConverter.hxx39
-rw-r--r--xmloff/source/chart/SchXMLExport.cxx89
-rw-r--r--xmloff/source/chart/SchXMLImport.cxx22
-rwxr-xr-xxmloff/source/chart/SchXMLLegendContext.cxx229
-rwxr-xr-xxmloff/source/chart/SchXMLLegendContext.hxx46
-rw-r--r--xmloff/source/chart/makefile.mk2
-rw-r--r--xmloff/source/core/xmltoken.cxx1
13 files changed, 459 insertions, 227 deletions
diff --git a/xmloff/inc/SchXMLImport.hxx b/xmloff/inc/SchXMLImport.hxx
index 7168b2b811a8..c544e3a46ed8 100644
--- a/xmloff/inc/SchXMLImport.hxx
+++ b/xmloff/inc/SchXMLImport.hxx
@@ -141,14 +141,6 @@ enum SchXMLAxisAttrTokenMap
XML_TOK_AXIS_STYLE_NAME
};
-enum SchXMLLegendAttrMap
-{
- XML_TOK_LEGEND_POSITION,
- XML_TOK_LEGEND_X,
- XML_TOK_LEGEND_Y,
- XML_TOK_LEGEND_STYLE_NAME
-};
-
enum SchXMLAutoStyleAttrMap
{
XML_TOK_AS_FAMILY,
diff --git a/xmloff/inc/xmloff/SchXMLImportHelper.hxx b/xmloff/inc/xmloff/SchXMLImportHelper.hxx
index 03fa8c8e16c0..6c35072a3fb3 100644
--- a/xmloff/inc/xmloff/SchXMLImportHelper.hxx
+++ b/xmloff/inc/xmloff/SchXMLImportHelper.hxx
@@ -85,7 +85,6 @@ private:
SvXMLTokenMap* mpChartAttrTokenMap;
SvXMLTokenMap* mpPlotAreaAttrTokenMap;
SvXMLTokenMap* mpAxisAttrTokenMap;
- SvXMLTokenMap* mpLegendAttrTokenMap;
SvXMLTokenMap* mpAutoStyleAttrTokenMap;
SvXMLTokenMap* mpCellAttrTokenMap;
SvXMLTokenMap* mpSeriesAttrTokenMap;
@@ -128,7 +127,6 @@ public:
const SvXMLTokenMap& GetChartAttrTokenMap();
const SvXMLTokenMap& GetPlotAreaAttrTokenMap();
const SvXMLTokenMap& GetAxisAttrTokenMap();
- const SvXMLTokenMap& GetLegendAttrTokenMap();
const SvXMLTokenMap& GetAutoStyleAttrTokenMap();
const SvXMLTokenMap& GetCellAttrTokenMap();
const SvXMLTokenMap& GetSeriesAttrTokenMap();
diff --git a/xmloff/inc/xmloff/xmltoken.hxx b/xmloff/inc/xmloff/xmltoken.hxx
index 241201ea5ed7..9339b27cacce 100644
--- a/xmloff/inc/xmloff/xmltoken.hxx
+++ b/xmloff/inc/xmloff/xmltoken.hxx
@@ -3114,6 +3114,7 @@ namespace xmloff { namespace token {
XML_OUTSIDE_MAXIMUM,//#i114142#
XML_LEGEND_EXPANSION, //#i28760#
+ XML_LEGEND_EXPANSION_ASPECT_RATIO, //#i28760#
XML_BALANCED, //#i28760#
XML_HIGH, //#i28760#
XML_WIDE, //#i28760#
diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx
index e9e3771eb0d7..6fac2d62d782 100644
--- a/xmloff/source/chart/SchXMLChartContext.cxx
+++ b/xmloff/source/chart/SchXMLChartContext.cxx
@@ -30,6 +30,7 @@
#include "SchXMLChartContext.hxx"
#include "SchXMLImport.hxx"
+#include "SchXMLLegendContext.hxx"
#include "SchXMLPlotAreaContext.hxx"
#include "SchXMLParagraphContext.hxx"
#include "SchXMLTableContext.hxx"
@@ -52,7 +53,6 @@
#include <com/sun/star/chart/XChartDocument.hpp>
#include <com/sun/star/chart/XDiagram.hpp>
#include <com/sun/star/xml/sax/XAttributeList.hpp>
-#include <com/sun/star/chart/ChartLegendPosition.hpp>
#include <com/sun/star/util/XStringMapping.hpp>
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
#include <com/sun/star/drawing/XDrawPage.hpp>
@@ -60,7 +60,6 @@
#include <com/sun/star/awt/PosSize.hpp>
#include <com/sun/star/embed/Aspects.hpp>
#include <com/sun/star/embed/XVisualObject.hpp>
-#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/chart2/XChartTypeTemplate.hpp>
@@ -277,19 +276,6 @@ uno::Sequence< sal_Int32 > lcl_getNumberSequenceFromString( const ::rtl::OUStrin
} // anonymous namespace
-static __FAR_DATA SvXMLEnumMapEntry aXMLLegendAlignmentMap[] =
-{
-// { XML_LEFT, chart::ChartLegendPosition_LEFT },
- // #i35421#
- { XML_START, chart::ChartLegendPosition_LEFT },
- { XML_TOP, chart::ChartLegendPosition_TOP },
-// { XML_RIGHT, chart::ChartLegendPosition_RIGHT },
- // #i35421#
- { XML_END, chart::ChartLegendPosition_RIGHT },
- { XML_BOTTOM, chart::ChartLegendPosition_BOTTOM },
- { XML_TOKEN_INVALID, 0 }
-};
-
// ----------------------------------------
SchXMLChartContext::SchXMLChartContext( SchXMLImportHelper& rImpHelper,
@@ -1318,115 +1304,3 @@ SvXMLImportContext* SchXMLTitleContext::CreateChildContext(
}
// ----------------------------------------
-
-SchXMLLegendContext::SchXMLLegendContext( SchXMLImportHelper& rImpHelper,
- SvXMLImport& rImport, const rtl::OUString& rLocalName ) :
- SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
- mrImportHelper( rImpHelper )
-{
-}
-
-void SchXMLLegendContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
-{
- uno::Reference< chart::XChartDocument > xDoc = mrImportHelper.GetChartDocument();
- if( ! xDoc.is())
- return;
-
- // turn on legend
- uno::Reference< beans::XPropertySet > xDocProp( xDoc, uno::UNO_QUERY );
- if( xDocProp.is())
- {
- uno::Any aTrueBool;
- aTrueBool <<= (sal_Bool)(sal_True);
- try
- {
- xDocProp->setPropertyValue( rtl::OUString::createFromAscii( "HasLegend" ), aTrueBool );
- }
- catch( beans::UnknownPropertyException )
- {
- DBG_ERROR( "Property HasLegend not found" );
- }
- }
-
- // parse attributes
- sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
- const SvXMLTokenMap& rAttrTokenMap = mrImportHelper.GetLegendAttrTokenMap();
-
- awt::Point aLegendPos;
- bool bHasXPosition=false;
- bool bHasYPosition=false;
-
- rtl::OUString sAutoStyleName;
-
- for( sal_Int16 i = 0; i < nAttrCount; i++ )
- {
- rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
- rtl::OUString aLocalName;
- rtl::OUString aValue = xAttrList->getValueByIndex( i );
- USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
-
- switch( rAttrTokenMap.Get( nPrefix, aLocalName ))
- {
- case XML_TOK_LEGEND_POSITION:
- {
- // set anchor position
- uno::Reference< beans::XPropertySet > xProp( xDoc->getLegend(), uno::UNO_QUERY );
- if( xProp.is())
- {
- try
- {
- USHORT nEnumVal;
- if( GetImport().GetMM100UnitConverter().convertEnum( nEnumVal, aValue, aXMLLegendAlignmentMap ))
- {
- uno::Any aAny;
- aAny <<= (chart::ChartLegendPosition)(nEnumVal);
- xProp->setPropertyValue( rtl::OUString::createFromAscii( "Alignment" ), aAny );
- }
- }
- catch( beans::UnknownPropertyException )
- {
- DBG_ERROR( "Property Alignment (legend) not found" );
- }
- }
- }
- break;
-
- case XML_TOK_LEGEND_X:
- GetImport().GetMM100UnitConverter().convertMeasure( aLegendPos.X, aValue );
- bHasXPosition = true;
- break;
- case XML_TOK_LEGEND_Y:
- GetImport().GetMM100UnitConverter().convertMeasure( aLegendPos.Y, aValue );
- bHasYPosition = true;
- break;
- case XML_TOK_LEGEND_STYLE_NAME:
- sAutoStyleName = aValue;
- }
- }
-
- uno::Reference< drawing::XShape > xLegendShape( xDoc->getLegend(), uno::UNO_QUERY );
- if( xLegendShape.is() && bHasXPosition && bHasYPosition )
- xLegendShape->setPosition( aLegendPos );
-
- // set auto-styles for Legend
- uno::Reference< beans::XPropertySet > xProp( xLegendShape, uno::UNO_QUERY );
- if( xProp.is())
- {
- // the fill style has the default "none" in XML, but "solid" in the model.
- xProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillStyle" )),
- uno::makeAny( drawing::FillStyle_NONE ));
- const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
- if( pStylesCtxt )
- {
- const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
- mrImportHelper.GetChartFamilyID(), sAutoStyleName );
-
- if( pStyle && pStyle->ISA( XMLPropStyleContext ))
- (( XMLPropStyleContext* )pStyle )->FillPropertySet( xProp );
- }
- }
-}
-
-SchXMLLegendContext::~SchXMLLegendContext()
-{
-}
diff --git a/xmloff/source/chart/SchXMLChartContext.hxx b/xmloff/source/chart/SchXMLChartContext.hxx
index 0f1fb0b4ab83..2ff2a4e3571f 100644
--- a/xmloff/source/chart/SchXMLChartContext.hxx
+++ b/xmloff/source/chart/SchXMLChartContext.hxx
@@ -171,19 +171,4 @@ public:
const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
};
-// ----------------------------------------
-
-class SchXMLLegendContext : public SvXMLImportContext
-{
-private:
- SchXMLImportHelper& mrImportHelper;
-
-public:
- SchXMLLegendContext( SchXMLImportHelper& rImpHelper,
- SvXMLImport& rImport, const rtl::OUString& rLocalName );
- virtual ~SchXMLLegendContext();
-
- virtual void StartElement( const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
-};
-
#endif // _SCH_XMLCHARTCONTEXT_HXX_
diff --git a/xmloff/source/chart/SchXMLEnumConverter.cxx b/xmloff/source/chart/SchXMLEnumConverter.cxx
new file mode 100755
index 000000000000..fd4d7914a2fe
--- /dev/null
+++ b/xmloff/source/chart/SchXMLEnumConverter.cxx
@@ -0,0 +1,104 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+#include "SchXMLEnumConverter.hxx"
+
+#include <com/sun/star/chart/ChartLegendPosition.hpp>
+#include <com/sun/star/chart/ChartLegendExpansion.hpp>
+#include <com/sun/star/uno/Any.hxx>
+
+// header for rtl::Static
+#include <rtl/instance.hxx>
+
+using ::rtl::OUString;
+using namespace ::xmloff::token;
+using namespace ::com::sun::star;
+
+namespace
+{
+//-----------------------------------------------------------------------
+
+SvXMLEnumMapEntry aXMLLegendPositionEnumMap[] =
+{
+ { XML_START, chart::ChartLegendPosition_LEFT },
+ { XML_TOP, chart::ChartLegendPosition_TOP },
+ { XML_END, chart::ChartLegendPosition_RIGHT },
+ { XML_BOTTOM, chart::ChartLegendPosition_BOTTOM },
+ { XML_TOKEN_INVALID, 0 }
+};
+
+class XMLLegendPositionPropertyHdl : public XMLEnumPropertyHdl
+{
+public:
+ XMLLegendPositionPropertyHdl()
+ : XMLEnumPropertyHdl( aXMLLegendPositionEnumMap, ::getCppuType((const chart::ChartLegendPosition*)0) ) {}
+ virtual ~XMLLegendPositionPropertyHdl() {};
+};
+
+struct TheLegendPositionPropertyHdl : public rtl::Static< XMLLegendPositionPropertyHdl, TheLegendPositionPropertyHdl >
+{
+};
+
+//-----------------------------------------------------------------------
+
+SvXMLEnumMapEntry aXMLLegendExpansionEnumMap[] =
+{
+ { XML_WIDE, chart::ChartLegendExpansion_WIDE },
+ { XML_HIGH, chart::ChartLegendExpansion_HIGH },
+ { XML_BALANCED, chart::ChartLegendExpansion_BALANCED },
+ { XML_CUSTOM, chart::ChartLegendExpansion_CUSTOM },
+ { XML_TOKEN_INVALID, 0 }
+};
+
+class XMLLegendExpansionPropertyHdl : public XMLEnumPropertyHdl
+{
+public:
+ XMLLegendExpansionPropertyHdl()
+ : XMLEnumPropertyHdl( aXMLLegendExpansionEnumMap, ::getCppuType((const chart::ChartLegendExpansion*)0) ) {}
+ virtual ~XMLLegendExpansionPropertyHdl() {};
+};
+
+struct TheLegendExpansionPropertyHdl : public rtl::Static< XMLLegendExpansionPropertyHdl, TheLegendExpansionPropertyHdl >
+{
+};
+
+//-----------------------------------------------------------------------
+
+}//end anonymous namespace
+
+//-----------------------------------------------------------------------
+
+XMLEnumPropertyHdl& SchXMLEnumConverter::getLegendPositionConverter()
+{
+ return TheLegendPositionPropertyHdl::get();
+}
+XMLEnumPropertyHdl& SchXMLEnumConverter::getLegendExpansionConverter()
+{
+ return TheLegendExpansionPropertyHdl::get();
+}
diff --git a/xmloff/source/chart/SchXMLEnumConverter.hxx b/xmloff/source/chart/SchXMLEnumConverter.hxx
new file mode 100755
index 000000000000..63a9fb7ffb95
--- /dev/null
+++ b/xmloff/source/chart/SchXMLEnumConverter.hxx
@@ -0,0 +1,39 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _XML_CHART_ENUM_CONVERTER_HXX_
+#define _XML_CHART_ENUM_CONVERTER_HXX_
+
+#include <xmloff/EnumPropertyHdl.hxx>
+
+class SchXMLEnumConverter
+{
+public:
+ static XMLEnumPropertyHdl& getLegendPositionConverter();//returns a singleton
+ static XMLEnumPropertyHdl& getLegendExpansionConverter();//returns a singleton
+};
+
+#endif // _XML_CHART_ENUM_CONVERTER_HXX_
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index 9450eb383d1c..ff98ad9e92ea 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>
@@ -66,7 +68,7 @@
#include <com/sun/star/chart/XChartDocument.hpp>
#include <com/sun/star/chart/ChartLegendPosition.hpp>
-#include <com/sun/star/chart2/LegendExpansion.hpp>
+#include <com/sun/star/chart/ChartLegendExpansion.hpp>
#include <com/sun/star/chart/XTwoAxisXSupplier.hpp>
#include <com/sun/star/chart/XTwoAxisYSupplier.hpp>
#include <com/sun/star/chart/XAxisZSupplier.hpp>
@@ -1416,69 +1418,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 )
- {
- 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;
- }
-
- // 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 );
+ // export absolute legend position
+ Reference< drawing::XShape > xLegendShape( xProp, uno::UNO_QUERY );
+ addPosition( xLegendShape );
- // export size
- chart2::LegendExpansion aLegendExpansion = chart2::LegendExpansion_HIGH;
- try
+ // 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
{
- Any aAny( xProp->getPropertyValue(
- OUString( RTL_CONSTASCII_USTRINGPARAM( "Expansion" ))));
- bool bHasExpansion = (aAny >>= aLegendExpansion);
- //todo
- //if (bHasExpansion)
- // mrExport.AddAttribute( XML_NAMESPACE_STYLE, XML_LEGEND_EXPANSION, );
- }
- catch( beans::UnknownPropertyException & )
- {
- DBG_WARNING( "Property Expansion not found in ChartLegend" );
+ 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" );
+ }
}
-
-
}
// write style name
diff --git a/xmloff/source/chart/SchXMLImport.cxx b/xmloff/source/chart/SchXMLImport.cxx
index 587070202c9c..ef14384a11d8 100644
--- a/xmloff/source/chart/SchXMLImport.cxx
+++ b/xmloff/source/chart/SchXMLImport.cxx
@@ -148,7 +148,6 @@ SchXMLImportHelper::SchXMLImportHelper() :
mpChartAttrTokenMap( 0 ),
mpPlotAreaAttrTokenMap( 0 ),
mpAxisAttrTokenMap( 0 ),
- mpLegendAttrTokenMap( 0 ),
mpAutoStyleAttrTokenMap( 0 ),
mpCellAttrTokenMap( 0 ),
mpSeriesAttrTokenMap( 0 ),
@@ -178,8 +177,6 @@ SchXMLImportHelper::~SchXMLImportHelper()
delete mpPlotAreaAttrTokenMap;
if( mpAxisAttrTokenMap )
delete mpAxisAttrTokenMap;
- if( mpLegendAttrTokenMap )
- delete mpLegendAttrTokenMap;
if( mpAutoStyleAttrTokenMap )
delete mpAutoStyleAttrTokenMap;
if( mpCellAttrTokenMap )
@@ -413,25 +410,6 @@ const SvXMLTokenMap& SchXMLImportHelper::GetAxisAttrTokenMap()
return *mpAxisAttrTokenMap;
}
-const SvXMLTokenMap& SchXMLImportHelper::GetLegendAttrTokenMap()
-{
- if( ! mpLegendAttrTokenMap )
- {
- static __FAR_DATA SvXMLTokenMapEntry aLegendAttrTokenMap[] =
-{
- { XML_NAMESPACE_CHART, XML_LEGEND_POSITION, XML_TOK_LEGEND_POSITION },
- { 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 },
- XML_TOKEN_MAP_END
-};
-
- mpLegendAttrTokenMap = new SvXMLTokenMap( aLegendAttrTokenMap );
- } // if( ! mpLegendAttrTokenMap )
-
- return *mpLegendAttrTokenMap;
-}
-
const SvXMLTokenMap& SchXMLImportHelper::GetAutoStyleAttrTokenMap()
{
if( ! mpAutoStyleAttrTokenMap )
diff --git a/xmloff/source/chart/SchXMLLegendContext.cxx b/xmloff/source/chart/SchXMLLegendContext.cxx
new file mode 100755
index 000000000000..2cd88dfb14b7
--- /dev/null
+++ b/xmloff/source/chart/SchXMLLegendContext.cxx
@@ -0,0 +1,229 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_xmloff.hxx"
+#include "SchXMLLegendContext.hxx"
+#include "SchXMLEnumConverter.hxx"
+
+#include "xmlnmspe.hxx"
+#include <xmloff/xmlement.hxx>
+#include <xmloff/prstylei.hxx>
+#include <xmloff/nmspmap.hxx>
+#include <xmloff/xmluconv.hxx>
+
+#include <tools/debug.hxx>
+
+#include <com/sun/star/chart/ChartLegendPosition.hpp>
+#include <com/sun/star/chart/ChartLegendExpansion.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
+
+using namespace ::xmloff::token;
+using namespace com::sun::star;
+
+using rtl::OUString;
+using com::sun::star::uno::Reference;
+
+//----------------------------------------
+
+namespace
+{
+
+enum LegendAttributeTokens
+{
+ XML_TOK_LEGEND_POSITION,
+ XML_TOK_LEGEND_X,
+ XML_TOK_LEGEND_Y,
+ XML_TOK_LEGEND_STYLE_NAME,
+ XML_TOK_LEGEND_EXPANSION,
+ XML_TOK_LEGEND_EXPANSION_ASPECT_RATIO,
+ XML_TOK_LEGEND_WIDTH,
+ XML_TOK_LEGEND_WIDTH_EXT,
+ XML_TOK_LEGEND_HEIGHT,
+ XML_TOK_LEGEND_HEIGHT_EXT
+};
+
+SvXMLTokenMapEntry aLegendAttributeTokenMap[] =
+{
+ { XML_NAMESPACE_CHART, XML_LEGEND_POSITION, XML_TOK_LEGEND_POSITION },
+ { 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 },
+ { XML_NAMESPACE_STYLE, XML_LEGEND_EXPANSION, XML_TOK_LEGEND_EXPANSION },
+ { XML_NAMESPACE_STYLE, XML_LEGEND_EXPANSION_ASPECT_RATIO, XML_TOK_LEGEND_EXPANSION_ASPECT_RATIO },
+ { XML_NAMESPACE_SVG, XML_WIDTH, XML_TOK_LEGEND_WIDTH },
+ { XML_NAMESPACE_CHART_EXT, XML_WIDTH, XML_TOK_LEGEND_WIDTH_EXT },
+ { XML_NAMESPACE_SVG, XML_HEIGHT, XML_TOK_LEGEND_HEIGHT },
+ { XML_NAMESPACE_CHART_EXT, XML_HEIGHT, XML_TOK_LEGEND_HEIGHT_EXT },
+ XML_TOKEN_MAP_END
+};
+
+class LegendAttributeTokenMap : public SvXMLTokenMap
+{
+public:
+ LegendAttributeTokenMap(): SvXMLTokenMap( aLegendAttributeTokenMap ) {}
+ virtual ~LegendAttributeTokenMap() {}
+};
+
+//a LegendAttributeTokenMap Singleton
+struct theLegendAttributeTokenMap : public rtl::Static< LegendAttributeTokenMap, theLegendAttributeTokenMap > {};
+
+}//end anonymous namespace
+
+//----------------------------------------
+
+SchXMLLegendContext::SchXMLLegendContext( SchXMLImportHelper& rImpHelper, SvXMLImport& rImport, const rtl::OUString& rLocalName ) :
+ SvXMLImportContext( rImport, XML_NAMESPACE_CHART, rLocalName ),
+ mrImportHelper( rImpHelper )
+{
+}
+
+void SchXMLLegendContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList )
+{
+ uno::Reference< chart::XChartDocument > xDoc = mrImportHelper.GetChartDocument();
+ if( !xDoc.is() )
+ return;
+
+ // turn on legend
+ uno::Reference< beans::XPropertySet > xDocProp( xDoc, uno::UNO_QUERY );
+ if( xDocProp.is() )
+ {
+ try
+ {
+ xDocProp->setPropertyValue( rtl::OUString::createFromAscii( "HasLegend" ), uno::makeAny( sal_True ) );
+ }
+ catch( beans::UnknownPropertyException )
+ {
+ DBG_ERROR( "Property HasLegend not found" );
+ }
+ }
+
+ uno::Reference< drawing::XShape > xLegendShape( xDoc->getLegend(), uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySet > xLegendProps( xLegendShape, uno::UNO_QUERY );
+ if( !xLegendShape.is() || !xLegendProps.is() )
+ {
+ DBG_ERROR( "legend could not be created" );
+ return;
+ }
+
+ // parse attributes
+ sal_Int16 nAttrCount = xAttrList.is()? xAttrList->getLength(): 0;
+ const SvXMLTokenMap& rAttrTokenMap = theLegendAttributeTokenMap::get();
+
+ awt::Point aLegendPos;
+ bool bHasXPosition=false;
+ bool bHasYPosition=false;
+ awt::Size aLegendSize;
+ bool bHasWidth=false;
+ bool bHasHeight=false;
+ chart::ChartLegendExpansion nLegendExpansion = chart::ChartLegendExpansion_HIGH;
+ bool bHasExpansion=false;
+
+ rtl::OUString sAutoStyleName;
+ uno::Any aAny;
+
+ for( sal_Int16 i = 0; i < nAttrCount; i++ )
+ {
+ rtl::OUString sAttrName = xAttrList->getNameByIndex( i );
+ rtl::OUString aLocalName;
+ rtl::OUString aValue = xAttrList->getValueByIndex( i );
+ USHORT nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
+
+ switch( rAttrTokenMap.Get( nPrefix, aLocalName ))
+ {
+ case XML_TOK_LEGEND_POSITION:
+ {
+ try
+ {
+ if( SchXMLEnumConverter::getLegendPositionConverter().importXML( aValue, aAny, GetImport().GetMM100UnitConverter() ) )
+ xLegendProps->setPropertyValue( rtl::OUString::createFromAscii( "Alignment" ), aAny );
+ }
+ catch( beans::UnknownPropertyException )
+ {
+ DBG_ERROR( "Property Alignment (legend) not found" );
+ }
+ }
+ break;
+
+ case XML_TOK_LEGEND_X:
+ GetImport().GetMM100UnitConverter().convertMeasure( aLegendPos.X, aValue );
+ bHasXPosition = true;
+ break;
+ case XML_TOK_LEGEND_Y:
+ GetImport().GetMM100UnitConverter().convertMeasure( aLegendPos.Y, aValue );
+ bHasYPosition = true;
+ break;
+ case XML_TOK_LEGEND_STYLE_NAME:
+ sAutoStyleName = aValue;
+ break;
+ case XML_TOK_LEGEND_EXPANSION:
+ SchXMLEnumConverter::getLegendPositionConverter().importXML( aValue, aAny, GetImport().GetMM100UnitConverter() );
+ bHasExpansion = (aAny>>=nLegendExpansion);
+ break;
+ case XML_TOK_LEGEND_EXPANSION_ASPECT_RATIO:
+ break;
+ case XML_TOK_LEGEND_WIDTH:
+ case XML_TOK_LEGEND_WIDTH_EXT:
+ GetImport().GetMM100UnitConverter().convertMeasure( aLegendSize.Width, aValue );
+ bHasWidth = true;
+ break;
+ case XML_TOK_LEGEND_HEIGHT:
+ case XML_TOK_LEGEND_HEIGHT_EXT:
+ GetImport().GetMM100UnitConverter().convertMeasure( aLegendSize.Height, aValue );
+ bHasHeight = true;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if( bHasXPosition && bHasYPosition )
+ xLegendShape->setPosition( aLegendPos );
+
+ if( bHasExpansion && nLegendExpansion!= chart::ChartLegendExpansion_CUSTOM )
+ xLegendProps->setPropertyValue( rtl::OUString::createFromAscii( "Expansion" ), uno::makeAny(nLegendExpansion) );
+ else if( bHasHeight && bHasWidth )
+ xLegendShape->setSize( aLegendSize );
+
+ // the fill style has the default "none" in XML, but "solid" in the model.
+ xLegendProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FillStyle" )), uno::makeAny( drawing::FillStyle_NONE ));
+
+ // set auto-styles for Legend
+ const SvXMLStylesContext* pStylesCtxt = mrImportHelper.GetAutoStylesContext();
+ if( pStylesCtxt )
+ {
+ const SvXMLStyleContext* pStyle = pStylesCtxt->FindStyleChildContext(
+ mrImportHelper.GetChartFamilyID(), sAutoStyleName );
+
+ if( pStyle && pStyle->ISA( XMLPropStyleContext ))
+ (( XMLPropStyleContext* )pStyle )->FillPropertySet( xLegendProps );
+ }
+}
+
+SchXMLLegendContext::~SchXMLLegendContext()
+{
+}
diff --git a/xmloff/source/chart/SchXMLLegendContext.hxx b/xmloff/source/chart/SchXMLLegendContext.hxx
new file mode 100755
index 000000000000..1841b0cef24b
--- /dev/null
+++ b/xmloff/source/chart/SchXMLLegendContext.hxx
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _SCH_XMLLEGENDCONTEXT_HXX_
+#define _SCH_XMLLEGENDCONTEXT_HXX_
+
+#include "SchXMLImport.hxx"
+
+// ----------------------------------------
+
+class SchXMLLegendContext : public SvXMLImportContext
+{
+public:
+ SchXMLLegendContext( SchXMLImportHelper& rImpHelper, SvXMLImport& rImport, const rtl::OUString& rLocalName );
+ virtual ~SchXMLLegendContext();
+
+ virtual void StartElement( const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList );
+
+private:
+ SchXMLImportHelper& mrImportHelper;
+};
+
+#endif // _SCH_XMLLEGENDCONTEXT_HXX_
diff --git a/xmloff/source/chart/makefile.mk b/xmloff/source/chart/makefile.mk
index bfdc9aeb5e22..187c5418aa33 100644
--- a/xmloff/source/chart/makefile.mk
+++ b/xmloff/source/chart/makefile.mk
@@ -45,11 +45,13 @@ SLOFILES = $(SLO)$/ColorPropertySet.obj \
$(SLO)$/contexts.obj \
$(SLO)$/SchXMLTableContext.obj \
$(SLO)$/SchXMLChartContext.obj \
+ $(SLO)$/SchXMLLegendContext.obj \
$(SLO)$/SchXMLPlotAreaContext.obj \
$(SLO)$/SchXMLParagraphContext.obj \
$(SLO)$/SchXMLTextListContext.obj \
$(SLO)$/SchXMLSeriesHelper.obj \
$(SLO)$/SchXMLSeries2Context.obj \
+ $(SLO)$/SchXMLEnumConverter.obj \
$(SLO)$/PropertyMaps.obj \
$(SLO)$/XMLChartStyleContext.obj \
$(SLO)$/XMLErrorIndicatorPropertyHdl.obj \
diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx
index 6c077ff1e4d8..f0058337967f 100644
--- a/xmloff/source/core/xmltoken.cxx
+++ b/xmloff/source/core/xmltoken.cxx
@@ -3114,6 +3114,7 @@ namespace xmloff { namespace token {
TOKEN( "outside-maximum", XML_OUTSIDE_MAXIMUM ),
TOKEN( "legend-expansion", XML_LEGEND_EXPANSION),
+ TOKEN( "legend-expansion-aspect-ratio", XML_LEGEND_EXPANSION_ASPECT_RATIO),
TOKEN( "balanced", XML_BALANCED),
TOKEN( "high", XML_HIGH),
TOKEN( "wide", XML_WIDE),