diff options
Diffstat (limited to 'chart2/source/model/template/NetChartType.cxx')
-rw-r--r-- | chart2/source/model/template/NetChartType.cxx | 186 |
1 files changed, 181 insertions, 5 deletions
diff --git a/chart2/source/model/template/NetChartType.cxx b/chart2/source/model/template/NetChartType.cxx index 0da96277e1de..1be89098be67 100644 --- a/chart2/source/model/template/NetChartType.cxx +++ b/chart2/source/model/template/NetChartType.cxx @@ -4,9 +4,9 @@ * * $RCSfile: NetChartType.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: obo $ $Date: 2006-09-17 13:19:26 $ + * last change: $Author: vg $ $Date: 2007-05-22 18:49:59 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -36,24 +36,200 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_chart2.hxx" #include "NetChartType.hxx" +#include "PropertyHelper.hxx" +#include "macros.hxx" +#include "PolarCoordinateSystem.hxx" +#include "Scaling.hxx" +#include "servicenames_charttypes.hxx" +#include "ContainerHelper.hxx" +#include "AxisIndexDefines.hxx" + +#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ +#include <com/sun/star/beans/PropertyAttribute.hpp> +#endif + +#ifndef _COM_SUN_STAR_CHART2_AXISTYPE_HPP_ +#include <com/sun/star/chart2/AxisType.hpp> +#endif using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; + +using ::rtl::OUString; +using ::com::sun::star::beans::Property; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Any; +using ::osl::MutexGuard; + +namespace +{ + +void lcl_AddPropertiesToVector( + ::std::vector< Property > & rOutProperties ) +{ +} + +void lcl_AddDefaultsToMap( + ::chart::tPropertyValueMap & rOutMap ) +{ +} + +const Sequence< Property > & lcl_GetPropertySequence() +{ + static Sequence< Property > aPropSeq; + + // /-- + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( 0 == aPropSeq.getLength() ) + { + // get properties + ::std::vector< ::com::sun::star::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); + + // and sort them for access via bsearch + ::std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + // transfer result to static Sequence + aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + } + + return aPropSeq; +} + +} // anonymous namespace namespace chart { -NetChartType::NetChartType() : - ChartType( 2 ) +NetChartType::NetChartType( + const uno::Reference< uno::XComponentContext > & xContext ) : + ChartType( xContext ) {} +NetChartType::NetChartType( const NetChartType & rOther ) : + ChartType( rOther ) +{ +} + NetChartType::~NetChartType() {} +// ____ XCloneable ____ +uno::Reference< util::XCloneable > SAL_CALL NetChartType::createClone() + throw (uno::RuntimeException) +{ + return uno::Reference< util::XCloneable >( new NetChartType( *this )); +} + // ____ XChartType ____ ::rtl::OUString SAL_CALL NetChartType::getChartType() throw (uno::RuntimeException) { - return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.NetChart" )); + return CHART2_SERVICE_NAME_CHARTTYPE_NET; } +Reference< XCoordinateSystem > SAL_CALL + NetChartType::createCoordinateSystem( ::sal_Int32 DimensionCount ) + throw (lang::IllegalArgumentException, + uno::RuntimeException) +{ + if( DimensionCount != 2 ) + throw lang::IllegalArgumentException( + C2U( "NetChart must be two-dimensional" ), + static_cast< ::cppu::OWeakObject* >( this ), 0 ); + + Reference< XCoordinateSystem > xResult( + new PolarCoordinateSystem( + GetComponentContext(), DimensionCount, /* bSwapXAndYAxis */ sal_False )); + + Reference< XAxis > xAxis( xResult->getAxisByDimension( 0, MAIN_AXIS_INDEX ) ); + if( xAxis.is() ) + { + ScaleData aScaleData = xAxis->getScaleData(); + aScaleData.Scaling = new LinearScaling( 1.0, 0.0 ); + aScaleData.AxisType = AxisType::CATEGORY; + aScaleData.Orientation = AxisOrientation_MATHEMATICAL; + xAxis->setScaleData( aScaleData ); + } + + xAxis = xResult->getAxisByDimension( 1, MAIN_AXIS_INDEX ); + if( xAxis.is() ) + { + ScaleData aScaleData = xAxis->getScaleData(); + aScaleData.Orientation = AxisOrientation_MATHEMATICAL; + aScaleData.AxisType = AxisType::REALNUMBER; + xAxis->setScaleData( aScaleData ); + } + + return xResult; +} + +// ____ OPropertySet ____ +uno::Any NetChartType::GetDefaultValue( sal_Int32 nHandle ) const + throw(beans::UnknownPropertyException) +{ + static tPropertyValueMap aStaticDefaults; + + // /-- + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( 0 == aStaticDefaults.size() ) + { + // initialize defaults + lcl_AddDefaultsToMap( aStaticDefaults ); + } + + tPropertyValueMap::const_iterator aFound( + aStaticDefaults.find( nHandle )); + + if( aFound == aStaticDefaults.end()) + return uno::Any(); + + return (*aFound).second; + // \-- +} + +// ____ OPropertySet ____ +::cppu::IPropertyArrayHelper & SAL_CALL NetChartType::getInfoHelper() +{ + static ::cppu::OPropertyArrayHelper aArrayHelper( lcl_GetPropertySequence(), + /* bSorted = */ sal_True ); + + return aArrayHelper; +} + + +// ____ XPropertySet ____ +uno::Reference< beans::XPropertySetInfo > SAL_CALL + NetChartType::getPropertySetInfo() + throw (uno::RuntimeException) +{ + static uno::Reference< beans::XPropertySetInfo > xInfo; + + // /-- + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( !xInfo.is()) + { + xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( + getInfoHelper()); + } + + return xInfo; + // \-- +} + +uno::Sequence< ::rtl::OUString > NetChartType::getSupportedServiceNames_Static() +{ + uno::Sequence< ::rtl::OUString > aServices( 3 ); + aServices[ 0 ] = CHART2_SERVICE_NAME_CHARTTYPE_NET; + aServices[ 1 ] = C2U( "com.sun.star.chart2.ChartType" ); + aServices[ 2 ] = C2U( "com.sun.star.beans.PropertySet" ); + return aServices; +} + +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +APPHELPER_XSERVICEINFO_IMPL( NetChartType, + C2U( "com.sun.star.comp.chart.NetChartType" )); + } // namespace chart |