diff options
Diffstat (limited to 'chart2/source/model')
25 files changed, 1233 insertions, 356 deletions
diff --git a/chart2/source/model/inc/Diagram.hxx b/chart2/source/model/inc/Diagram.hxx index b8247b65a15c..a7962f302b3b 100644 --- a/chart2/source/model/inc/Diagram.hxx +++ b/chart2/source/model/inc/Diagram.hxx @@ -2,9 +2,9 @@ * * $RCSfile: Diagram.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:30 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:21 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -178,6 +178,8 @@ protected: const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XDataSeriesTreeParent >& xTree ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); +// virtual ::rtl::OUString SAL_CALL getChartTypeTemplateServiceName() +// throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL getWall() throw (::com::sun::star::uno::RuntimeException); @@ -302,6 +304,8 @@ private: ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XLegend > m_xLegend; + + const ::rtl::OUString m_aTemplateServiceName; }; } // namespace chart diff --git a/chart2/source/model/main/Axis.cxx b/chart2/source/model/main/Axis.cxx index 6ee34b675bdd..a1c0ed79de73 100644 --- a/chart2/source/model/main/Axis.cxx +++ b/chart2/source/model/main/Axis.cxx @@ -2,9 +2,9 @@ * * $RCSfile: Axis.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: bm $ $Date: 2003-10-06 15:49:33 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:22 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -309,7 +309,13 @@ Axis::~Axis() // -------------------------------------------------------------------------------- // ____ XAxis ____ -// (nothing) +uno::Sequence< uno::Reference< beans::XPropertySet > > SAL_CALL Axis::getSubTickProperties() + throw (uno::RuntimeException) +{ + OSL_ENSURE( false, "Not implemented yet" ); + return uno::Sequence< uno::Reference< beans::XPropertySet > >(); +} + // ____ XMeter ____ void SAL_CALL Axis::attachCoordinateSystem( diff --git a/chart2/source/model/main/Axis.hxx b/chart2/source/model/main/Axis.hxx index 7ff3d0068691..3a69fac502dc 100644 --- a/chart2/source/model/main/Axis.hxx +++ b/chart2/source/model/main/Axis.hxx @@ -2,9 +2,9 @@ * * $RCSfile: Axis.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:30 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:22 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -144,8 +144,12 @@ protected: // throw (::com::sun::star::lang::IllegalArgumentException); // ____ XAxis ____ + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > > SAL_CALL getSubTickProperties() + throw (::com::sun::star::uno::RuntimeException); - // ____ XMeter ____ +// ____ XMeter ____ virtual void SAL_CALL attachCoordinateSystem( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XBoundedCoordinateSystem >& xCoordSys, diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index 847656233427..a07a5af186d7 100644 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ChartModel.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: bm $ $Date: 2003-10-17 14:48:14 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:22 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,6 +62,8 @@ #include "ImplChartModel.hxx" #include "servicenames.hxx" #include "MediaDescriptorHelper.hxx" +#include "macros.hxx" +#include "ChartDocumentWrapper.hxx" #ifndef _COM_SUN_STAR_UNO_REFERENCE_H_ #include <com/sun/star/uno/Reference.h> @@ -100,11 +102,15 @@ ChartModel::ChartModel(uno::Reference<uno::XComponentContext > const & xContext) , m_xCurrentController( NULL ) , m_nControllerLockCount(0) , m_pImplChartModel( new impl::ImplChartModel( xContext ) ) + , m_xContext( xContext ) { } ChartModel::~ChartModel() { + if( m_xOldModelAgg.is()) + m_xOldModelAgg->setDelegator( NULL ); + //@todo if ( m_pControllers ) @@ -783,8 +789,7 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME) void SAL_CALL ChartModel ::setDiagram( const uno::Reference< chart2::XDiagram >& xDiagram ) - throw (lang::IllegalArgumentException, - uno::RuntimeException) + throw (uno::RuntimeException) { OSL_ASSERT( m_pImplChartModel.get() != 0 ); // /-- @@ -839,28 +844,6 @@ APPHELPER_XSERVICEINFO_IMPL(ChartModel,CHART_MODEL_SERVICE_IMPLEMENTATION_NAME) // \-- } - void SAL_CALL ChartModel -::setChartTypeTemplate( const uno::Reference< chart2::XChartTypeTemplate >& xNewTemplate ) - throw (uno::RuntimeException) -{ - OSL_ASSERT( m_pImplChartModel.get() != 0 ); - // /-- - MutexGuard aGuard( m_aModelMutex ); - m_pImplChartModel->SetChartTypeTemplate( xNewTemplate ); - // \-- -} - - uno::Reference< chart2::XChartTypeTemplate > SAL_CALL ChartModel -::getChartTypeTemplate() - throw (uno::RuntimeException) -{ - OSL_ASSERT( m_pImplChartModel.get() != 0 ); - // /-- - MutexGuard aGuard( m_aModelMutex ); - return m_pImplChartModel->GetChartTypeTemplate(); - // \-- -} - // void SAL_CALL ChartModel // ::setSplitLayoutContainer( const uno::Reference< layout::XSplitLayoutContainer >& xLayoutCnt ) // throw (uno::RuntimeException) @@ -921,14 +904,30 @@ void SAL_CALL ChartModel::setTitle( uno::Any SAL_CALL ChartModel::queryInterface( const uno::Type& aType ) throw (uno::RuntimeException) { - // return old API wrapper - if( aType == - ::getCppuType( (uno::Reference< ::com::sun::star::chart::XChartDocument > *)0 )) + uno::Any aResult( impl::ChartModel_Base::queryInterface( aType )); + + if( ! aResult.hasValue()) { - return uno::makeAny( m_pImplChartModel->GetOldChartDocument( this )); + // try old API wrapper + try + { + if( ! m_xOldModelAgg.is()) + { + m_xOldModelAgg.set( + static_cast< uno::XWeak* >( + new wrapper::ChartDocumentWrapper( m_xContext )), uno::UNO_QUERY_THROW ); + m_xOldModelAgg->setDelegator( static_cast< ::cppu::OWeakObject* >( this )); + } + + aResult = m_xOldModelAgg->queryAggregation( aType ); + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } } - return impl::ChartModel_Base::queryInterface( aType ); + return aResult; } diff --git a/chart2/source/model/main/ChartModel.hxx b/chart2/source/model/main/ChartModel.hxx index 68cfff6f5bd9..553f0cb16c05 100644 --- a/chart2/source/model/main/ChartModel.hxx +++ b/chart2/source/model/main/ChartModel.hxx @@ -2,9 +2,9 @@ * * $RCSfile: ChartModel.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: bm $ $Date: 2003-10-17 14:48:14 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:22 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -208,6 +208,9 @@ private: ::std::auto_ptr< impl::ImplChartModel > m_pImplChartModel; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > m_xOldModelAgg; + private: //private methods @@ -467,8 +470,7 @@ public: virtual void SAL_CALL setDiagram( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XDiagram >& xDiagram ) - throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException); + throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL attachDataProvider( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XDataProvider >& xProvider ) @@ -484,13 +486,6 @@ public: virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XChartTypeManager > SAL_CALL getChartTypeManager() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL - setChartTypeTemplate( const ::com::sun::star::uno::Reference< - ::drafts::com::sun::star::chart2::XChartTypeTemplate >& xNewTemplate ) - throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XChartTypeTemplate > SAL_CALL - getChartTypeTemplate() - throw (::com::sun::star::uno::RuntimeException); // virtual void SAL_CALL setSplitLayoutContainer( // const ::com::sun::star::uno::Reference< // ::drafts::com::sun::star::layout::XSplitLayoutContainer >& xLayoutCnt ) @@ -502,7 +497,7 @@ public: getPageBackground() throw (::com::sun::star::uno::RuntimeException); -// ____ XTitled ____ + // ____ XTitled ____ virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XTitle > SAL_CALL getTitle() throw (::com::sun::star::uno::RuntimeException); @@ -518,4 +513,3 @@ public: } // namespace chart #endif - diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx index 1ac3bcd359ef..4e55032f3b21 100644 --- a/chart2/source/model/main/Diagram.cxx +++ b/chart2/source/model/main/Diagram.cxx @@ -2,9 +2,9 @@ * * $RCSfile: Diagram.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: bm $ $Date: 2003-10-06 12:54:13 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -165,6 +165,11 @@ Diagram::Diagram( uno::Reference< uno::XComponentContext > const & xContext ) : m_xTitle( NULL ), m_aIdentifier( C2U( "@diagram" )) { + if( ! m_xContext.is() || + ! ( xContext->getValueByName( C2U( "TemplateServiceName" )) >>= m_aTemplateServiceName )) + { + OSL_ENSURE( false, "Missing argument TemplateServiceName" ); + } } Diagram::~Diagram() @@ -200,6 +205,12 @@ void SAL_CALL Diagram::setTree( } } +// ::rtl::OUString SAL_CALL Diagram::getChartTypeTemplateServiceName() +// throw (uno::RuntimeException) +// { +// return m_aTemplateServiceName; +// } + uno::Reference< beans::XPropertySet > SAL_CALL Diagram::getWall() throw (uno::RuntimeException) { @@ -484,6 +495,6 @@ IMPLEMENT_FORWARD_XTYPEPROVIDER2( Diagram, Diagram_Base, ::property::OPropertySe // implement XServiceInfo methods basing upon getSupportedServiceNames_Static APPHELPER_XSERVICEINFO_IMPL( Diagram, - C2U( "com.sun.star.comp.chart.Diagram" )); + C2U( "com.sun.star.comp.chart2.Diagram" )); } // namespace chart diff --git a/chart2/source/model/main/ImplChartModel.cxx b/chart2/source/model/main/ImplChartModel.cxx index 5b1659b5aaf7..5a1de910bddc 100644 --- a/chart2/source/model/main/ImplChartModel.cxx +++ b/chart2/source/model/main/ImplChartModel.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ImplChartModel.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: bm $ $Date: 2003-10-17 14:48:14 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -69,7 +69,6 @@ #include "ContextHelper.hxx" // #include "SplitLayoutContainer.hxx" #include "LayoutDefaults.hxx" -#include "ChartDocumentWrapper.hxx" #include "PageBackground.hxx" #ifndef _CPPUHELPER_COMPONENT_CONTEXT_HXX_ @@ -381,23 +380,6 @@ void ImplChartModel::SetTitle( const uno::Reference< chart2::XTitle >& rTitle ) m_xTitle = rTitle; } -uno::Reference< ::com::sun::star::chart::XChartDocument > ImplChartModel::GetOldChartDocument( - const uno::Reference< chart2::XChartDocument > & xNewModel ) -{ - // put weak reference into a strong one - uno::Reference< ::com::sun::star::chart::XChartDocument > xRef( m_xOldModel ); - - if( ! xRef.is()) - { - xRef.set( new wrapper::ChartDocumentWrapper( xNewModel, m_xContext )); - - // assing reference to weak reference - m_xOldModel = xRef; - } - - return xRef; -} - void ImplChartModel::dispose() { // exception is thrown by ChartModel diff --git a/chart2/source/model/main/ImplChartModel.hxx b/chart2/source/model/main/ImplChartModel.hxx index f09ac0f99666..20eb9d3bd7a6 100644 --- a/chart2/source/model/main/ImplChartModel.hxx +++ b/chart2/source/model/main/ImplChartModel.hxx @@ -2,9 +2,9 @@ * * $RCSfile: ImplChartModel.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: bm $ $Date: 2003-10-17 14:48:14 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -93,10 +93,6 @@ #include <com/sun/star/container/NoSuchElementException.hpp> #endif -#ifndef _COM_SUN_STAR_CHART_XCHARTDOCUMENT_HPP_ -#include <com/sun/star/chart/XChartDocument.hpp> -#endif - #ifndef _CPPUHELPER_WEAKREF_HXX_ #include <cppuhelper/weakref.hxx> #endif @@ -180,11 +176,6 @@ public: void SetTitle( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XTitle >& rTitle ); - ::com::sun::star::uno::Reference< - ::com::sun::star::chart::XChartDocument > GetOldChartDocument( - const ::com::sun::star::uno::Reference< - ::drafts::com::sun::star::chart2::XChartDocument > & xNewModel ); - /** Is called by the ChartModel's XComponent::dispose() to notify the impl-class to release resources */ @@ -226,8 +217,6 @@ private: ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XTitle > m_xTitle; - ::com::sun::star::uno::WeakReference< ::com::sun::star::chart::XChartDocument > - m_xOldModel; bool m_bIsDisposed; ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xPageBackground; diff --git a/chart2/source/model/main/makefile.mk b/chart2/source/model/main/makefile.mk index 65d340b36ac4..6e51963d017e 100644 --- a/chart2/source/model/main/makefile.mk +++ b/chart2/source/model/main/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.2 $ +# $Revision: 1.3 $ # -# last change: $Author: bm $ $Date: 2003-10-17 14:32:50 $ +# last change: $Author: bm $ $Date: 2003-11-04 12:37:25 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -106,6 +106,7 @@ SLOFILES= \ $(SLO)$/Scale.obj \ $(SLO)$/StyleFamilies.obj \ $(SLO)$/StyleFamily.obj \ + $(SLO)$/SubGrid.obj \ $(SLO)$/Title.obj \ $(SLO)$/UserDefinedProperties.obj \ $(SLO)$/Wall.obj \ diff --git a/chart2/source/model/template/AreaChartTypeTemplate.cxx b/chart2/source/model/template/AreaChartTypeTemplate.cxx index d84b17d09731..cca9d6f88728 100644 --- a/chart2/source/model/template/AreaChartTypeTemplate.cxx +++ b/chart2/source/model/template/AreaChartTypeTemplate.cxx @@ -2,9 +2,9 @@ * * $RCSfile: AreaChartTypeTemplate.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:31 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -60,29 +60,175 @@ ************************************************************************/ #include "AreaChartTypeTemplate.hxx" #include "AreaChartType.hxx" +#include "macros.hxx" +#include "algohelper.hxx" + +#ifndef CHART_PROPERTYHELPER_HXX +#include "PropertyHelper.hxx" +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ +#include <com/sun/star/beans/PropertyAttribute.hpp> +#endif + +#include <algorithm> using namespace ::com::sun::star; using namespace ::drafts::com::sun::star; +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 +{ + +static const ::rtl::OUString lcl_aServiceName( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.AreaChartTypeTemplate" )); + +enum +{ + PROP_AREA_TEMPLATE_DIMENSION +}; + +void lcl_AddPropertiesToVector( + ::std::vector< Property > & rOutProperties ) +{ + rOutProperties.push_back( + Property( C2U( "Dimension" ), + PROP_AREA_TEMPLATE_DIMENSION, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); +} + +void lcl_AddDefaultsToMap( + ::chart::helper::tPropertyValueMap & rOutMap ) +{ + OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_AREA_TEMPLATE_DIMENSION )); + rOutMap[ PROP_AREA_TEMPLATE_DIMENSION ] = + uno::makeAny( sal_Int32( 2 ) ); +} + +const uno::Sequence< Property > & lcl_GetPropertySequence() +{ + static uno::Sequence< Property > aPropSeq; + + // /-- + 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::helper::PropertyNameLess() ); + + // transfer result to static Sequence + aPropSeq = ::chart::helper::VectorToSequence( aProperties ); + } + + return aPropSeq; +} + +::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +{ + static ::cppu::OPropertyArrayHelper aArrayHelper( + lcl_GetPropertySequence(), + /* bSorted = */ sal_True ); + + return aArrayHelper; +} + +} // anonymous namespace + namespace chart { AreaChartTypeTemplate::AreaChartTypeTemplate( uno::Reference< uno::XComponentContext > const & xContext, + const ::rtl::OUString & rServiceName, chart2::StackMode eStackMode, sal_Int32 nDim /* = 2 */ ) : - ChartTypeTemplate( xContext ), - m_eStackMode( eStackMode ), - m_nDim( nDim ) -{} + ChartTypeTemplate( xContext, rServiceName ), + ::property::OPropertySet( m_aMutex ), + m_eStackMode( eStackMode ) +{ + setFastPropertyValue_NoBroadcast( PROP_AREA_TEMPLATE_DIMENSION, uno::makeAny( nDim )); +} AreaChartTypeTemplate::~AreaChartTypeTemplate() {} +// ____ OPropertySet ____ +uno::Any AreaChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const + throw(beans::UnknownPropertyException) +{ + static helper::tPropertyValueMap aStaticDefaults; + + // /-- + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( 0 == aStaticDefaults.size() ) + { + // initialize defaults + lcl_AddDefaultsToMap( aStaticDefaults ); + } + + helper::tPropertyValueMap::const_iterator aFound( + aStaticDefaults.find( nHandle )); + + if( aFound == aStaticDefaults.end()) + return uno::Any(); + + return (*aFound).second; + // \-- +} + +::cppu::IPropertyArrayHelper & SAL_CALL AreaChartTypeTemplate::getInfoHelper() +{ + return lcl_getInfoHelper(); +} + + +// ____ XPropertySet ____ +uno::Reference< beans::XPropertySetInfo > SAL_CALL + AreaChartTypeTemplate::getPropertySetInfo() + throw (uno::RuntimeException) +{ + static uno::Reference< beans::XPropertySetInfo > xInfo; + + // /-- + MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( !xInfo.is()) + { + xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( + getInfoHelper()); + } + + return xInfo; + // \-- +} + sal_Int32 AreaChartTypeTemplate::getDimension() const { - return m_nDim; + sal_Int32 nDim = 2; + try + { + // note: UNO-methods are never const + const_cast< AreaChartTypeTemplate * >( this )-> + getFastPropertyValue( PROP_AREA_TEMPLATE_DIMENSION ) >>= nDim; + } + catch( beans::UnknownPropertyException & ex ) + { + ASSERT_EXCEPTION( ex ); + } + + return nDim; } chart2::StackMode AreaChartTypeTemplate::getStackMode() const @@ -90,11 +236,26 @@ chart2::StackMode AreaChartTypeTemplate::getStackMode() const return m_eStackMode; } -// ____ XChartTypeTemplate ____ -uno::Reference< chart2::XChartType > SAL_CALL AreaChartTypeTemplate::getChartTypeForAdditionalSeries() +uno::Reference< chart2::XChartType > AreaChartTypeTemplate::getDefaultChartType() throw (uno::RuntimeException) { - return new AreaChartType( m_nDim ); + return new AreaChartType( getDimension() ); } +// ---------------------------------------- + +uno::Sequence< ::rtl::OUString > AreaChartTypeTemplate::getSupportedServiceNames_Static() +{ + uno::Sequence< ::rtl::OUString > aServices( 2 ); + aServices[ 0 ] = lcl_aServiceName; + aServices[ 1 ] = C2U( "drafts.com.sun.star.chart2.ChartTypeTemplate" ); + return aServices; +} + +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +APPHELPER_XSERVICEINFO_IMPL( AreaChartTypeTemplate, lcl_aServiceName ); + +IMPLEMENT_FORWARD_XINTERFACE2( AreaChartTypeTemplate, ChartTypeTemplate, OPropertySet ) +IMPLEMENT_FORWARD_XTYPEPROVIDER2( AreaChartTypeTemplate, ChartTypeTemplate, OPropertySet ) + } // namespace chart diff --git a/chart2/source/model/template/AreaChartTypeTemplate.hxx b/chart2/source/model/template/AreaChartTypeTemplate.hxx index 4c0dbdc1f09c..5c5b806110ea 100644 --- a/chart2/source/model/template/AreaChartTypeTemplate.hxx +++ b/chart2/source/model/template/AreaChartTypeTemplate.hxx @@ -2,9 +2,9 @@ * * $RCSfile: AreaChartTypeTemplate.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:31 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -63,6 +63,13 @@ #include "ChartTypeTemplate.hxx" +#include "OPropertySet.hxx" +#include "MutexContainer.hxx" + +#ifndef _COMPHELPER_UNO3_HXX_ +#include <comphelper/uno3.hxx> +#endif + #ifndef _DRAFTS_COM_SUN_STAR_CHART2_STACKMODE_HPP_ #include <drafts/com/sun/star/chart2/StackMode.hpp> #endif @@ -70,24 +77,44 @@ namespace chart { -class AreaChartTypeTemplate : public ChartTypeTemplate +class AreaChartTypeTemplate : + public helper::MutexContainer, + public ChartTypeTemplate, + public ::property::OPropertySet { public: explicit AreaChartTypeTemplate( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext, + const ::rtl::OUString & rServiceName, ::drafts::com::sun::star::chart2::StackMode eStackMode, sal_Int32 nDim = 2 ); virtual ~AreaChartTypeTemplate(); + /// XServiceInfo declarations + APPHELPER_XSERVICEINFO_DECL() + + /// merge XInterface implementations + DECLARE_XINTERFACE() + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + protected: + // ____ OPropertySet ____ + virtual ::com::sun::star::uno::Any GetDefaultValue( sal_Int32 nHandle ) const + throw(::com::sun::star::beans::UnknownPropertyException); + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); + + // ____ XPropertySet ____ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + // ____ ChartTypeTemplate ____ virtual sal_Int32 getDimension() const; virtual ::drafts::com::sun::star::chart2::StackMode getStackMode() const; - - // ____ XChartTypeTemplate ____ virtual ::com::sun::star::uno::Reference< - ::drafts::com::sun::star::chart2::XChartType > SAL_CALL getChartTypeForAdditionalSeries() + ::drafts::com::sun::star::chart2::XChartType > getDefaultChartType() throw (::com::sun::star::uno::RuntimeException); private: diff --git a/chart2/source/model/template/BarChartTypeTemplate.cxx b/chart2/source/model/template/BarChartTypeTemplate.cxx index 91f988602939..387ba68402a8 100644 --- a/chart2/source/model/template/BarChartTypeTemplate.cxx +++ b/chart2/source/model/template/BarChartTypeTemplate.cxx @@ -2,9 +2,9 @@ * * $RCSfile: BarChartTypeTemplate.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:31 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:31 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -60,21 +60,115 @@ ************************************************************************/ #include "BarChartTypeTemplate.hxx" #include "BarChartType.hxx" +#include "ColumnChartType.hxx" +#include "algohelper.hxx" +#include "macros.hxx" + +#ifndef CHART_PROPERTYHELPER_HXX +#include "PropertyHelper.hxx" +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ +#include <com/sun/star/beans/PropertyAttribute.hpp> +#endif +#ifndef _COM_SUN_STAR_CHART_CHARTSOLIDTYPE_HPP_ +#include <com/sun/star/chart/ChartSolidType.hpp> +#endif + +#include <algorithm> using namespace ::com::sun::star; using namespace ::drafts::com::sun::star; +using ::com::sun::star::beans::Property; +using ::osl::MutexGuard; + +namespace +{ + +static const ::rtl::OUString lcl_aServiceName( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.BarChartTypeTemplate" )); + +enum +{ + PROP_BAR_TEMPLATE_DIMENSION, + PROP_BAR_TEMPLATE_SOLID_TYPE +}; + +void lcl_AddPropertiesToVector( + ::std::vector< Property > & rOutProperties ) +{ + rOutProperties.push_back( + Property( C2U( "Dimension" ), + PROP_BAR_TEMPLATE_DIMENSION, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "SolidType" ), + PROP_BAR_TEMPLATE_SOLID_TYPE, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); +} + +void lcl_AddDefaultsToMap( + ::chart::helper::tPropertyValueMap & rOutMap ) +{ + OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_BAR_TEMPLATE_DIMENSION )); + rOutMap[ PROP_BAR_TEMPLATE_DIMENSION ] = + uno::makeAny( sal_Int32( 2 ) ); + OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_BAR_TEMPLATE_SOLID_TYPE )); + rOutMap[ PROP_BAR_TEMPLATE_SOLID_TYPE ] = + uno::makeAny( ::com::sun::star::chart::ChartSolidType::RECTANGULAR_SOLID ); +} + +const uno::Sequence< Property > & lcl_GetPropertySequence() +{ + static uno::Sequence< Property > aPropSeq; + + // /-- + 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::helper::PropertyNameLess() ); + + // transfer result to static Sequence + aPropSeq = ::chart::helper::VectorToSequence( aProperties ); + } + + return aPropSeq; +} + +::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +{ + static ::cppu::OPropertyArrayHelper aArrayHelper( + lcl_GetPropertySequence(), + /* bSorted = */ sal_True ); + + return aArrayHelper; +} + +} // anonymous namespace + namespace chart { BarChartTypeTemplate::BarChartTypeTemplate( uno::Reference< uno::XComponentContext > const & xContext, + const ::rtl::OUString & rServiceName, chart2::StackMode eStackMode, BarDirection eDirection, sal_Int32 nDim /* = 2 */, ThreeDMode eThreeDMode /* = THREE_D_FLAT */ ) : - ChartTypeTemplate( xContext ), + ChartTypeTemplate( xContext, rServiceName ), + ::property::OPropertySet( m_aMutex ), m_eStackMode( eStackMode ), m_eBarDirection( eDirection ), m_nDim( nDim ), @@ -94,11 +188,81 @@ chart2::StackMode BarChartTypeTemplate::getStackMode() const return m_eStackMode; } -// ____ XChartTypeTemplate ____ -uno::Reference< chart2::XChartType > SAL_CALL BarChartTypeTemplate::getChartTypeForAdditionalSeries() +uno::Reference< chart2::XChartType > BarChartTypeTemplate::getDefaultChartType() throw (uno::RuntimeException) { - return new BarChartType( m_nDim ); + uno::Reference< chart2::XChartType > xResult; + if( m_eBarDirection == HORIZONTAL ) + xResult.set( new BarChartType( m_nDim )); + else + xResult.set( new ColumnChartType( m_nDim )); + + return xResult; } +// ____ OPropertySet ____ +uno::Any BarChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const + throw(beans::UnknownPropertyException) +{ + static helper::tPropertyValueMap aStaticDefaults; + + // /-- + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( 0 == aStaticDefaults.size() ) + { + // initialize defaults + lcl_AddDefaultsToMap( aStaticDefaults ); + } + + helper::tPropertyValueMap::const_iterator aFound( + aStaticDefaults.find( nHandle )); + + if( aFound == aStaticDefaults.end()) + return uno::Any(); + + return (*aFound).second; + // \-- +} + +::cppu::IPropertyArrayHelper & SAL_CALL BarChartTypeTemplate::getInfoHelper() +{ + return lcl_getInfoHelper(); +} + + +// ____ XPropertySet ____ +uno::Reference< beans::XPropertySetInfo > SAL_CALL + BarChartTypeTemplate::getPropertySetInfo() + throw (uno::RuntimeException) +{ + static uno::Reference< beans::XPropertySetInfo > xInfo; + + // /-- + MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( !xInfo.is()) + { + xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( + getInfoHelper()); + } + + return xInfo; + // \-- +} + +// ---------------------------------------- + +uno::Sequence< ::rtl::OUString > BarChartTypeTemplate::getSupportedServiceNames_Static() +{ + uno::Sequence< ::rtl::OUString > aServices( 2 ); + aServices[ 0 ] = lcl_aServiceName; + aServices[ 1 ] = C2U( "drafts.com.sun.star.chart2.ChartTypeTemplate" ); + return aServices; +} + +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +APPHELPER_XSERVICEINFO_IMPL( BarChartTypeTemplate, lcl_aServiceName ); + +IMPLEMENT_FORWARD_XINTERFACE2( BarChartTypeTemplate, ChartTypeTemplate, OPropertySet ) +IMPLEMENT_FORWARD_XTYPEPROVIDER2( BarChartTypeTemplate, ChartTypeTemplate, OPropertySet ) + } // namespace chart diff --git a/chart2/source/model/template/BarChartTypeTemplate.hxx b/chart2/source/model/template/BarChartTypeTemplate.hxx index 6ca1e720e447..8117c6ab2052 100644 --- a/chart2/source/model/template/BarChartTypeTemplate.hxx +++ b/chart2/source/model/template/BarChartTypeTemplate.hxx @@ -2,9 +2,9 @@ * * $RCSfile: BarChartTypeTemplate.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:31 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -61,6 +61,13 @@ #ifndef CHART_BARCHARTTYPETEMPLATE_HXX #define CHART_BARCHARTTYPETEMPLATE_HXX +#include "OPropertySet.hxx" +#include "MutexContainer.hxx" + +#ifndef _COMPHELPER_UNO3_HXX_ +#include <comphelper/uno3.hxx> +#endif + #include "ChartTypeTemplate.hxx" #ifndef _DRAFTS_COM_SUN_STAR_CHART2_STACKMODE_HPP_ @@ -70,7 +77,10 @@ namespace chart { -class BarChartTypeTemplate : public ChartTypeTemplate +class BarChartTypeTemplate : + public helper::MutexContainer, + public ChartTypeTemplate, + public ::property::OPropertySet { public: enum BarDirection @@ -88,20 +98,37 @@ public: explicit BarChartTypeTemplate( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext, + const ::rtl::OUString & rServiceName, ::drafts::com::sun::star::chart2::StackMode eStackMode, BarDirection eDirection, sal_Int32 nDim = 2, ThreeDMode eThreeDMode = THREE_D_FLAT ); virtual ~BarChartTypeTemplate(); + /// XServiceInfo declarations + APPHELPER_XSERVICEINFO_DECL() + + /// merge XInterface implementations + DECLARE_XINTERFACE() + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + protected: + // ____ OPropertySet ____ + virtual ::com::sun::star::uno::Any GetDefaultValue( sal_Int32 nHandle ) const + throw(::com::sun::star::beans::UnknownPropertyException); + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); + + // ____ XPropertySet ____ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + // ____ ChartTypeTemplate ____ virtual sal_Int32 getDimension() const; virtual ::drafts::com::sun::star::chart2::StackMode getStackMode() const; - - // ____ XChartTypeTemplate ____ virtual ::com::sun::star::uno::Reference< - ::drafts::com::sun::star::chart2::XChartType > SAL_CALL getChartTypeForAdditionalSeries() + ::drafts::com::sun::star::chart2::XChartType > getDefaultChartType() throw (::com::sun::star::uno::RuntimeException); private: diff --git a/chart2/source/model/template/ChartTypeManager.cxx b/chart2/source/model/template/ChartTypeManager.cxx index 4457ba879921..d02164bafa8c 100644 --- a/chart2/source/model/template/ChartTypeManager.cxx +++ b/chart2/source/model/template/ChartTypeManager.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ChartTypeManager.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:31 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -244,8 +244,8 @@ enum TemplateId TEMPLATE_THREEDBARFLAT, TEMPLATE_STACKEDTHREEDBARFLAT, TEMPLATE_PERCENTSTACKEDTHREEDBARFLAT, - TEMPLATE_COLUMNWITHONELINE, - TEMPLATE_STACKEDCOLUMNWITHONELINE, + TEMPLATE_COLUMNWITHLINE, + TEMPLATE_STACKEDCOLUMNWITHLINE, TEMPLATE_AREA, TEMPLATE_STACKEDAREA, TEMPLATE_PERCENTSTACKEDAREA, @@ -312,8 +312,8 @@ const tTemplateMapType & lcl_DefaultChartTypeMap() ( C2U( "com.sun.star.chart2.template.ThreeDBarFlat" ), TEMPLATE_THREEDBARFLAT ) ( C2U( "com.sun.star.chart2.template.StackedThreeDBarFlat" ), TEMPLATE_STACKEDTHREEDBARFLAT ) ( C2U( "com.sun.star.chart2.template.PercentStackedThreeDBarFlat" ), TEMPLATE_PERCENTSTACKEDTHREEDBARFLAT ) - ( C2U( "com.sun.star.chart2.template.ColumnWithOneLine" ), TEMPLATE_COLUMNWITHONELINE ) - ( C2U( "com.sun.star.chart2.template.StackedColumnWithOneLine" ), TEMPLATE_STACKEDCOLUMNWITHONELINE ) + ( C2U( "com.sun.star.chart2.template.ColumnWithLine" ), TEMPLATE_COLUMNWITHLINE ) + ( C2U( "com.sun.star.chart2.template.StackedColumnWithLine" ), TEMPLATE_STACKEDCOLUMNWITHLINE ) ( C2U( "com.sun.star.chart2.template.Area" ), TEMPLATE_AREA ) ( C2U( "com.sun.star.chart2.template.StackedArea" ), TEMPLATE_STACKEDAREA ) ( C2U( "com.sun.star.chart2.template.PercentStackedArea" ), TEMPLATE_PERCENTSTACKEDAREA ) @@ -399,167 +399,167 @@ uno::Reference< uno::XInterface > SAL_CALL ChartTypeManager::createInstance( { // Line case TEMPLATE_LINE: - xTemplate.set( new LineChartTypeTemplate( m_xContext, + xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, LineChartTypeTemplate::NO_SPLINE, false )); break; case TEMPLATE_STACKEDLINE: - xTemplate.set( new LineChartTypeTemplate( m_xContext, + xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED, LineChartTypeTemplate::NO_SPLINE, false )); break; case TEMPLATE_PERCENTSTACKEDLINE: - xTemplate.set( new LineChartTypeTemplate( m_xContext, + xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED_PERCENT, LineChartTypeTemplate::NO_SPLINE, false )); break; case TEMPLATE_LINESYMBOL: - xTemplate.set( new LineChartTypeTemplate( m_xContext, + xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, LineChartTypeTemplate::NO_SPLINE, true )); break; case TEMPLATE_STACKEDLINESYMBOL: - xTemplate.set( new LineChartTypeTemplate( m_xContext, + xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED, LineChartTypeTemplate::NO_SPLINE, true )); break; case TEMPLATE_PERCENTSTACKEDLINESYMBOL: - xTemplate.set( new LineChartTypeTemplate( m_xContext, + xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED_PERCENT, LineChartTypeTemplate::NO_SPLINE, true )); break; case TEMPLATE_CUBICSPLINE: - xTemplate.set( new LineChartTypeTemplate( m_xContext, + xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, LineChartTypeTemplate::CUBIC_SPLINE, false )); break; case TEMPLATE_CUBICSPLINESYMBOL: - xTemplate.set( new LineChartTypeTemplate( m_xContext, + xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, LineChartTypeTemplate::CUBIC_SPLINE, true )); break; case TEMPLATE_BSPLINE: - xTemplate.set( new LineChartTypeTemplate( m_xContext, + xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, LineChartTypeTemplate::B_SPLINE, false )); break; case TEMPLATE_BSPLINESYMBOL: - xTemplate.set( new LineChartTypeTemplate( m_xContext, + xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, LineChartTypeTemplate::B_SPLINE, true )); break; case TEMPLATE_THREEDLINE: - xTemplate.set( new LineChartTypeTemplate( m_xContext, + xTemplate.set( new LineChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, LineChartTypeTemplate::NO_SPLINE, false, 3 )); break; // Bar/Column case TEMPLATE_COLUMN: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, BarChartTypeTemplate::VERTICAL )); break; case TEMPLATE_STACKEDCOLUMN: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED, BarChartTypeTemplate::VERTICAL )); break; case TEMPLATE_PERCENTSTACKEDCOLUMN: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED_PERCENT, BarChartTypeTemplate::VERTICAL )); break; case TEMPLATE_BAR: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, BarChartTypeTemplate::HORIZONTAL )); break; case TEMPLATE_STACKEDBAR: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED, BarChartTypeTemplate::HORIZONTAL )); break; case TEMPLATE_PERCENTSTACKEDBAR: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED_PERCENT, BarChartTypeTemplate::HORIZONTAL )); break; case TEMPLATE_THREEDCOLUMNDEEP: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, BarChartTypeTemplate::VERTICAL, 3, BarChartTypeTemplate::THREE_D_DEEP )); break; case TEMPLATE_THREEDCOLUMNFLAT: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, BarChartTypeTemplate::VERTICAL, 3, BarChartTypeTemplate::THREE_D_FLAT )); break; case TEMPLATE_STACKEDTHREEDCOLUMNFLAT: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED, BarChartTypeTemplate::VERTICAL, 3, BarChartTypeTemplate::THREE_D_FLAT )); case TEMPLATE_PERCENTSTACKEDTHREEDCOLUMNFLAT: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED_PERCENT, BarChartTypeTemplate::VERTICAL, 3, BarChartTypeTemplate::THREE_D_FLAT )); case TEMPLATE_THREEDBARDEEP: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, BarChartTypeTemplate::HORIZONTAL, 3, BarChartTypeTemplate::THREE_D_DEEP )); break; case TEMPLATE_THREEDBARFLAT: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, BarChartTypeTemplate::HORIZONTAL, 3, BarChartTypeTemplate::THREE_D_FLAT )); break; case TEMPLATE_STACKEDTHREEDBARFLAT: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED, BarChartTypeTemplate::HORIZONTAL, 3, BarChartTypeTemplate::THREE_D_FLAT )); break; case TEMPLATE_PERCENTSTACKEDTHREEDBARFLAT: - xTemplate.set( new BarChartTypeTemplate( m_xContext, + xTemplate.set( new BarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED_PERCENT, BarChartTypeTemplate::HORIZONTAL, 3, BarChartTypeTemplate::THREE_D_FLAT )); break; // Combi-Chart Line/Column - case TEMPLATE_COLUMNWITHONELINE: - case TEMPLATE_STACKEDCOLUMNWITHONELINE: + case TEMPLATE_COLUMNWITHLINE: + case TEMPLATE_STACKEDCOLUMNWITHLINE: { - chart2::StackMode eMode = ( nId == TEMPLATE_COLUMNWITHONELINE ) + chart2::StackMode eMode = ( nId == TEMPLATE_COLUMNWITHLINE ) ? chart2::StackMode_NONE : chart2::StackMode_STACKED; sal_Int32 nNumOfLines = 1; getFastPropertyValue( PROP_TEMPLATE_MANAGER_NUMBER_OF_LINES ) >>= nNumOfLines; - xTemplate.set( new ColumnLineChartTypeTemplate( m_xContext, eMode, nNumOfLines )); + xTemplate.set( new ColumnLineChartTypeTemplate( m_xContext, aServiceSpecifier, eMode, nNumOfLines )); } break; // Area case TEMPLATE_AREA: - xTemplate.set( new AreaChartTypeTemplate( m_xContext, chart2::StackMode_NONE )); + xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE )); break; case TEMPLATE_STACKEDAREA: - xTemplate.set( new AreaChartTypeTemplate( m_xContext, chart2::StackMode_STACKED )); + xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED )); break; case TEMPLATE_PERCENTSTACKEDAREA: - xTemplate.set( new AreaChartTypeTemplate( m_xContext, chart2::StackMode_STACKED_PERCENT )); + xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED_PERCENT )); break; case TEMPLATE_THREEDAREA: - xTemplate.set( new AreaChartTypeTemplate( m_xContext, chart2::StackMode_NONE, 3 )); + xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, 3 )); break; case TEMPLATE_STACKEDTHREEDAREA: - xTemplate.set( new AreaChartTypeTemplate( m_xContext, chart2::StackMode_STACKED, 3 )); + xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED, 3 )); break; case TEMPLATE_PERCENTSTACKEDTHREEDAREA: - xTemplate.set( new AreaChartTypeTemplate( m_xContext, chart2::StackMode_STACKED_PERCENT, 3 )); + xTemplate.set( new AreaChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED_PERCENT, 3 )); break; case TEMPLATE_PIE: - xTemplate.set( new PieChartTypeTemplate( m_xContext, - PieChartTypeTemplate::NO_OFFSET, false )); + xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier, + chart2::PieChartOffsetMode_NONE, false )); break; case TEMPLATE_PIEONEEXPLODED: - xTemplate.set( new PieChartTypeTemplate( m_xContext, - PieChartTypeTemplate::FIRST_EXPLODED, false )); + xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier, + chart2::PieChartOffsetMode_FIRST_EXPLODED, false )); break; case TEMPLATE_PIEALLEXPLODED: - xTemplate.set( new PieChartTypeTemplate( m_xContext, - PieChartTypeTemplate::ALL_EXPLODED, false )); + xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier, + chart2::PieChartOffsetMode_ALL_EXPLODED, false )); break; case TEMPLATE_RING: - xTemplate.set( new PieChartTypeTemplate( m_xContext, - PieChartTypeTemplate::NO_OFFSET, true )); + xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier, + chart2::PieChartOffsetMode_NONE, true )); break; case TEMPLATE_THREEDPIE: - xTemplate.set( new PieChartTypeTemplate( m_xContext, - PieChartTypeTemplate::NO_OFFSET, false, 3 )); + xTemplate.set( new PieChartTypeTemplate( m_xContext, aServiceSpecifier, + chart2::PieChartOffsetMode_NONE, false, 3 )); break; case TEMPLATE_SCATTERLINESYMBOL: @@ -572,7 +572,7 @@ uno::Reference< uno::XInterface > SAL_CALL ChartTypeManager::createInstance( // TEST !!! case TEMPLATE_NET: - xTemplate.set( new DoubleStackedBarChartTypeTemplate( m_xContext, + xTemplate.set( new DoubleStackedBarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_NONE, chart2::StackMode_STACKED )); break; @@ -580,14 +580,14 @@ uno::Reference< uno::XInterface > SAL_CALL ChartTypeManager::createInstance( case TEMPLATE_NETSYMBOL: case TEMPLATE_STACKEDNET: case TEMPLATE_STACKEDNETSYMBOL: - xTemplate.set( new DoubleStackedBarChartTypeTemplate( m_xContext, + xTemplate.set( new DoubleStackedBarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED, chart2::StackMode_STACKED )); break; // TEST !!! case TEMPLATE_PERCENTSTACKEDNET: case TEMPLATE_PERCENTSTACKEDNETSYMBOL: - xTemplate.set( new DoubleStackedBarChartTypeTemplate( m_xContext, + xTemplate.set( new DoubleStackedBarChartTypeTemplate( m_xContext, aServiceSpecifier, chart2::StackMode_STACKED_PERCENT, chart2::StackMode_STACKED )); break; diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx b/chart2/source/model/template/ChartTypeTemplate.cxx index 4ff84c4ecc41..e21eb8065562 100644 --- a/chart2/source/model/template/ChartTypeTemplate.cxx +++ b/chart2/source/model/template/ChartTypeTemplate.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ChartTypeTemplate.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: bm $ $Date: 2003-10-09 16:46:43 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -60,17 +60,17 @@ ************************************************************************/ #include "ChartTypeTemplate.hxx" #include "PropertyHelper.hxx" -#include "algohelper.hxx" #include "macros.hxx" #include "ContextHelper.hxx" #include "Scale.hxx" +#include "DataSeriesTreeHelper.hxx" -#include "Diagram.hxx" #include "Scaling.hxx" #include "CartesianCoordinateSystem.hxx" #include "BoundedCoordinateSystem.hxx" #include "MeterHelper.hxx" #include "LegendHelper.hxx" +#include "BarChartType.hxx" #ifndef _CPPUHELPER_COMPONENT_CONTEXT_HXX_ #include <cppuhelper/component_context.hxx> @@ -106,85 +106,6 @@ using ::com::sun::star::uno::Any; namespace { -bool lcl_SetStackModeAtTree( - const Reference< chart2::XDataSeriesTreeParent > & rTree, - chart2::StackMode eMode ) -{ - if( ! rTree.is()) - return false; - - bool bResult = false; - - // seek value stacking group - Sequence< Reference< chart2::XDataSeriesTreeNode > > aChildren( rTree->getChildren()); - for( sal_Int32 i = 0; - ( ! bResult ) && ( i < aChildren.getLength() ); - ++i ) - { - Reference< chart2::XStackableScaleGroup > xStackGroup( aChildren[ i ], uno::UNO_QUERY ); - if( xStackGroup.is()) - { - Reference< lang::XServiceInfo > xServInfo( aChildren[ i ], uno::UNO_QUERY ); - if( xServInfo.is() && - xServInfo->supportsService( - C2U( "drafts.com.sun.star.chart2.ContinuousScaleGroup" ))) - { - xStackGroup->setStackMode( eMode ); - bResult = true; - break; - } - } - - // recurse - Reference< chart2::XDataSeriesTreeParent > xNewParent( aChildren[ i ], uno::UNO_QUERY ); - if( xNewParent.is() && - lcl_SetStackModeAtTree( xNewParent, eMode )) - bResult = true; - } - - return bResult; -} - -// helping method for lcl_GetDataSeries() (see below) -void lcl_AddSeriesRecursive( - Reference< chart2::XDataSeriesTreeParent > xParent, - ::std::vector< Reference< chart2::XDataSeries > > & rOutSeriesVec ) -{ - if( xParent.is()) - { - Sequence< Reference< chart2::XDataSeriesTreeNode > > aChildren( xParent->getChildren()); - for( sal_Int32 i = 0; i < aChildren.getLength(); ++i ) - { - Reference< chart2::XDataSeries > aDataSeries( aChildren[ i ], uno::UNO_QUERY ); - if( aDataSeries.is()) - { - rOutSeriesVec.push_back( aDataSeries ); - } - else - { - Reference< chart2::XDataSeriesTreeParent > xNewParent( aChildren[ i ], uno::UNO_QUERY ); - if( xNewParent.is()) - lcl_AddSeriesRecursive( xNewParent, rOutSeriesVec ); - } - } - } -} -Sequence< Reference< chart2::XDataSeries > > - lcl_GetDataSeries( const Reference< chart2::XDiagram > & xDia ) -{ - ::std::vector< Reference< chart2::XDataSeries > > aSeriesVec; - - if( xDia.is()) - { - Reference< chart2::XDataSeriesTreeParent > aParent( xDia->getTree()); - - if( aParent.is()) - lcl_AddSeriesRecursive( aParent, aSeriesVec ); - } - - return ::chart::helper::VectorToSequence( aSeriesVec ); -} - void lcl_FlushLegend( const Reference< chart2::XLegend > & xLegend ) { if( xLegend.is()) @@ -213,8 +134,10 @@ namespace chart { ChartTypeTemplate::ChartTypeTemplate( - Reference< uno::XComponentContext > const & xContext ) : - m_xContext( xContext ) + Reference< uno::XComponentContext > const & xContext, + const ::rtl::OUString & rServiceName ) : + m_xContext( xContext ), + m_aServiceName( rServiceName ) { } @@ -227,35 +150,49 @@ Reference< chart2::XDiagram > SAL_CALL ChartTypeTemplate::createDiagram( const Sequence< Reference< chart2::XDataSeries > >& aSeriesSeq ) throw (uno::RuntimeException) { - // create diagram - Reference< chart2::XDiagram > xDia( new Diagram( m_xContext ) ); + Reference< chart2::XDiagram > xDia; - // modify diagram - FillDiagram( xDia, aSeriesSeq ); + try + { + // create diagram + ContextHelper::tContextEntryMapType aContextValues( + ContextHelper::MakeContextEntryMap + ( C2U( "TemplateServiceName" ), + uno::makeAny( getServiceName() )) + ); - // create and attach legend - Reference< chart2::XLegend > xLegend( - m_xContext->getServiceManager()->createInstanceWithContext( - C2U( "drafts.com.sun.star.chart2.Legend" ), - m_xContext ), - uno::UNO_QUERY ); + xDia.set( + m_xContext->getServiceManager()->createInstanceWithContext( + C2U( "drafts.com.sun.star.chart2.Diagram" ), + ContextHelper::createContext( aContextValues, m_xContext ) ), + uno::UNO_QUERY_THROW ); - xDia->setLegend( xLegend ); - LegendHelper::defaultFillEmptyLegend( xLegend, xDia ); + // modify diagram + FillDiagram( xDia, aSeriesSeq ); + + // create and attach legend + Reference< chart2::XLegend > xLegend( + m_xContext->getServiceManager()->createInstanceWithContext( + C2U( "drafts.com.sun.star.chart2.Legend" ), + m_xContext ), + uno::UNO_QUERY_THROW ); + + xDia->setLegend( xLegend ); + LegendHelper::defaultFillEmptyLegend( xLegend, xDia ); + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } return xDia; } -// simple first approach -void SAL_CALL ChartTypeTemplate::changeDiagram( const Reference< chart2::XDiagram >& xDiagram ) +// ____ XServiceName ____ + ::rtl::OUString SAL_CALL ChartTypeTemplate::getServiceName() throw (uno::RuntimeException) { - Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( lcl_GetDataSeries( xDiagram )); - FillDiagram( xDiagram, aSeriesSeq ); - - Reference< chart2::XLegend > xLegend( xDiagram->getLegend()); - lcl_FlushLegend( xLegend ); - LegendHelper::defaultFillEmptyLegend( xLegend, xDiagram ); + return m_aServiceName; } // ________________________________________ @@ -270,6 +207,12 @@ chart2::StackMode ChartTypeTemplate::getStackMode() const return chart2::StackMode_NONE; } +uno::Reference< chart2::XChartType > ChartTypeTemplate::getDefaultChartType() + throw (uno::RuntimeException) +{ + return new BarChartType( 2 ); +} + // ________________________________________ Reference< chart2::XBoundedCoordinateSystem > ChartTypeTemplate::createCoordinateSystem( @@ -528,7 +471,7 @@ Reference< chart2::XDataSeriesTreeParent > ChartTypeTemplate::createDataSeriesTr // chart type group Reference< chart2::XDataSeriesTreeNode > aChartTypeNode( - createChartTypeGroup( getChartTypeForAdditionalSeries())); + createChartTypeGroup( getDefaultChartType())); // 'x-axis' group Reference< chart2::XDataSeriesTreeNode > aCategoryNode( @@ -558,7 +501,7 @@ void ChartTypeTemplate::setStackModeAtTree( const Reference< chart2::XDataSeriesTreeParent > & rTree, chart2::StackMode eMode ) { - bool bResult = lcl_SetStackModeAtTree( rTree, eMode ); + bool bResult = helper::DataSeriesTreeHelper::setStackMode( rTree, eMode ); OSL_ENSURE( bResult, "stack-mode could not be set" ); } diff --git a/chart2/source/model/template/ChartTypeTemplate.hxx b/chart2/source/model/template/ChartTypeTemplate.hxx index f69bd610dd31..d59763872a90 100644 --- a/chart2/source/model/template/ChartTypeTemplate.hxx +++ b/chart2/source/model/template/ChartTypeTemplate.hxx @@ -2,9 +2,9 @@ * * $RCSfile: ChartTypeTemplate.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: bm $ $Date: 2003-10-09 16:46:43 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -61,8 +61,8 @@ #ifndef CHART_CHARTTYPETEMPLATE_HXX #define CHART_CHARTTYPETEMPLATE_HXX -#ifndef _CPPUHELPER_IMPLBASE1_HXX_ -#include <cppuhelper/implbase1.hxx> +#ifndef _CPPUHELPER_IMPLBASE2_HXX_ +#include <cppuhelper/implbase2.hxx> #endif #include "ServiceMacros.hxx" @@ -87,17 +87,25 @@ #ifndef _DRAFTS_COM_SUN_STAR_CHART2_XLEGEND_HPP_ #include <drafts/com/sun/star/chart2/XLegend.hpp> #endif +#ifndef _COM_SUN_STAR_LANG_XSERVICENAME_HPP_ +#include <com/sun/star/lang/XServiceName.hpp> +#endif +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_XCHARTTYPE_HPP_ +#include <drafts/com/sun/star/chart2/XChartType.hpp> +#endif namespace chart { -class ChartTypeTemplate : public ::cppu::WeakImplHelper1< - ::drafts::com::sun::star::chart2::XChartTypeTemplate > +class ChartTypeTemplate : public ::cppu::WeakImplHelper2< + ::drafts::com::sun::star::chart2::XChartTypeTemplate, + ::com::sun::star::lang::XServiceName > { public: explicit ChartTypeTemplate( ::com::sun::star::uno::Reference< - ::com::sun::star::uno::XComponentContext > const & xContext ); + ::com::sun::star::uno::XComponentContext > const & xContext, + const ::rtl::OUString & rServiceName ); virtual ~ChartTypeTemplate(); APPHELPER_XSERVICEINFO_DECL() @@ -106,17 +114,14 @@ public: protected: // ____ XChartTypeTemplate ____ - // still abstract ! - virtual ::com::sun::star::uno::Reference< - ::drafts::com::sun::star::chart2::XChartType > SAL_CALL getChartTypeForAdditionalSeries() - throw (::com::sun::star::uno::RuntimeException) = 0; virtual ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XDiagram > SAL_CALL createDiagram( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XDataSeries > >& aSeriesSeq ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL changeDiagram( - const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::chart2::XDiagram >& xDiagram ) + + // ____ XServiceName ____ + virtual ::rtl::OUString SAL_CALL getServiceName() throw (::com::sun::star::uno::RuntimeException); // Methods to overload for automatic creation @@ -130,6 +135,10 @@ protected: */ virtual ::drafts::com::sun::star::chart2::StackMode getStackMode() const; + virtual ::com::sun::star::uno::Reference< + ::drafts::com::sun::star::chart2::XChartType > getDefaultChartType() + throw (::com::sun::star::uno::RuntimeException); + // Methods for creating the diagram piecewise // ------------------------------------------ @@ -252,6 +261,7 @@ protected: private: ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + const ::rtl::OUString m_aServiceName; /** modifies the given diagram */ diff --git a/chart2/source/model/template/ColumnChartType.cxx b/chart2/source/model/template/ColumnChartType.cxx new file mode 100644 index 000000000000..dfb3c98f579f --- /dev/null +++ b/chart2/source/model/template/ColumnChartType.cxx @@ -0,0 +1,83 @@ +/************************************************************************* + * + * $RCSfile: ColumnChartType.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: bm $ $Date: 2003-11-04 12:37:33 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2003 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#include "ColumnChartType.hxx" + +using namespace ::com::sun::star; +using namespace ::drafts::com::sun::star; + +namespace chart +{ + +ColumnChartType::ColumnChartType( sal_Int32 nDim /* = 2 */ ) : + ChartType( nDim ) +{} + +ColumnChartType::~ColumnChartType() +{} + +// ____ XChartType ____ +::rtl::OUString SAL_CALL ColumnChartType::getChartType() + throw (uno::RuntimeException) +{ + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.ColumnChart" )); +} + +} // namespace chart diff --git a/chart2/source/model/template/ColumnChartType.hxx b/chart2/source/model/template/ColumnChartType.hxx new file mode 100644 index 000000000000..2a56b9c95c0b --- /dev/null +++ b/chart2/source/model/template/ColumnChartType.hxx @@ -0,0 +1,84 @@ +/************************************************************************* + * + * $RCSfile: ColumnChartType.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: bm $ $Date: 2003-11-04 12:37:33 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library 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 for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2003 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifndef CHART_COLUMNCHARTTYPE_HXX +#define CHART_COLUMNCHARTTYPE_HXX + +#include "ChartType.hxx" + +namespace chart +{ + +class ColumnChartType : public ChartType +{ +public: + ColumnChartType( sal_Int32 nDim = 2 ); + virtual ~ColumnChartType(); + +protected: + // ____ XChartType ____ + virtual ::rtl::OUString SAL_CALL getChartType() + throw (::com::sun::star::uno::RuntimeException); +}; + +} // namespace chart + +// CHART_COLUMNCHARTTYPE_HXX +#endif diff --git a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx index 4a264b6d1a66..bff100afd7c4 100644 --- a/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx +++ b/chart2/source/model/template/ColumnLineChartTypeTemplate.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ColumnLineChartTypeTemplate.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:32 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:33 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,6 +62,14 @@ #include "macros.hxx" #include "LineChartType.hxx" #include "BarChartType.hxx" +#include "algohelper.hxx" + +#ifndef CHART_PROPERTYHELPER_HXX +#include "PropertyHelper.hxx" +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ +#include <com/sun/star/beans/PropertyAttribute.hpp> +#endif #include <algorithm> @@ -71,6 +79,74 @@ using namespace ::drafts::com::sun::star; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; using ::rtl::OUString; +using ::com::sun::star::beans::Property; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Any; +using ::osl::MutexGuard; + +namespace +{ + +static const ::rtl::OUString lcl_aServiceName( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.ColumnLineChartTypeTemplate" )); + +enum +{ + PROP_COL_LINE_NUMBER_OF_LINES +}; + +void lcl_AddPropertiesToVector( + ::std::vector< Property > & rOutProperties ) +{ + rOutProperties.push_back( + Property( C2U( "NumberOfLines" ), + PROP_COL_LINE_NUMBER_OF_LINES, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); +} + +void lcl_AddDefaultsToMap( + ::chart::helper::tPropertyValueMap & rOutMap ) +{ + OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_COL_LINE_NUMBER_OF_LINES )); + rOutMap[ PROP_COL_LINE_NUMBER_OF_LINES ] = + uno::makeAny( sal_Int32( 1 ) ); +} + +const uno::Sequence< Property > & lcl_GetPropertySequence() +{ + static uno::Sequence< Property > aPropSeq; + + // /-- + 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::helper::PropertyNameLess() ); + + // transfer result to static Sequence + aPropSeq = ::chart::helper::VectorToSequence( aProperties ); + } + + return aPropSeq; +} + +::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +{ + static ::cppu::OPropertyArrayHelper aArrayHelper( + lcl_GetPropertySequence(), + /* bSorted = */ sal_True ); + + return aArrayHelper; +} + +} // anonymous namespace namespace chart { @@ -78,16 +154,69 @@ namespace chart ColumnLineChartTypeTemplate::ColumnLineChartTypeTemplate( Reference< uno::XComponentContext > const & xContext, + const ::rtl::OUString & rServiceName, chart2::StackMode eStackMode, sal_Int32 nNumberOfLines ) : - ChartTypeTemplate( xContext ), - m_eStackMode( eStackMode ), - m_nNumberOfLines( nNumberOfLines ) -{} + ChartTypeTemplate( xContext, rServiceName ), + ::property::OPropertySet( m_aMutex ), + m_eStackMode( eStackMode ) +{ + setFastPropertyValue_NoBroadcast( PROP_COL_LINE_NUMBER_OF_LINES, uno::makeAny( nNumberOfLines )); +} ColumnLineChartTypeTemplate::~ColumnLineChartTypeTemplate() {} + +// ____ OPropertySet ____ +uno::Any ColumnLineChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const + throw(beans::UnknownPropertyException) +{ + static helper::tPropertyValueMap aStaticDefaults; + + // /-- + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( 0 == aStaticDefaults.size() ) + { + // initialize defaults + lcl_AddDefaultsToMap( aStaticDefaults ); + } + + helper::tPropertyValueMap::const_iterator aFound( + aStaticDefaults.find( nHandle )); + + if( aFound == aStaticDefaults.end()) + return uno::Any(); + + return (*aFound).second; + // \-- +} + +::cppu::IPropertyArrayHelper & SAL_CALL ColumnLineChartTypeTemplate::getInfoHelper() +{ + return lcl_getInfoHelper(); +} + + +// ____ XPropertySet ____ +uno::Reference< beans::XPropertySetInfo > SAL_CALL + ColumnLineChartTypeTemplate::getPropertySetInfo() + throw (uno::RuntimeException) +{ + static uno::Reference< beans::XPropertySetInfo > xInfo; + + // /-- + MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( !xInfo.is()) + { + xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( + getInfoHelper()); + } + + return xInfo; + // \-- +} + Reference< chart2::XDataSeriesTreeParent > ColumnLineChartTypeTemplate::createDataSeriesTree( const Sequence< Reference< chart2::XDataSeries > > & aSeriesSeq, const Reference< chart2::XBoundedCoordinateSystem > & rCoordSys ) @@ -97,7 +226,9 @@ Reference< chart2::XDataSeriesTreeParent > ColumnLineChartTypeTemplate::createDa Reference< chart2::XDataSeriesTreeParent > aRoot( createRootNode()); sal_Int32 nNumberOfBars = aSeriesSeq.getLength(); - sal_Int32 nNumberOfLines = m_nNumberOfLines; + sal_Int32 nNumberOfLines = 1; + getFastPropertyValue( PROP_COL_LINE_NUMBER_OF_LINES ) >>= nNumberOfLines; + if( nNumberOfLines >= nNumberOfBars ) { nNumberOfLines = 1; @@ -165,11 +296,26 @@ Reference< chart2::XDataSeriesTreeParent > ColumnLineChartTypeTemplate::createDa return aRoot; } -// ____ XChartTypeTemplate ____ -uno::Reference< chart2::XChartType > SAL_CALL ColumnLineChartTypeTemplate::getChartTypeForAdditionalSeries() +uno::Reference< chart2::XChartType > ColumnLineChartTypeTemplate::getDefaultChartType() throw (uno::RuntimeException) { return new LineChartType(); } +// ---------------------------------------- + +uno::Sequence< ::rtl::OUString > ColumnLineChartTypeTemplate::getSupportedServiceNames_Static() +{ + uno::Sequence< ::rtl::OUString > aServices( 2 ); + aServices[ 0 ] = lcl_aServiceName; + aServices[ 1 ] = C2U( "drafts.com.sun.star.chart2.ChartTypeTemplate" ); + return aServices; +} + +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +APPHELPER_XSERVICEINFO_IMPL( ColumnLineChartTypeTemplate, lcl_aServiceName ); + +IMPLEMENT_FORWARD_XINTERFACE2( ColumnLineChartTypeTemplate, ChartTypeTemplate, OPropertySet ) +IMPLEMENT_FORWARD_XTYPEPROVIDER2( ColumnLineChartTypeTemplate, ChartTypeTemplate, OPropertySet ) + } // namespace chart diff --git a/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx b/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx index fed23a93aefc..0ea4dd39d5ed 100644 --- a/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx +++ b/chart2/source/model/template/ColumnLineChartTypeTemplate.hxx @@ -2,9 +2,9 @@ * * $RCSfile: ColumnLineChartTypeTemplate.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:32 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:34 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -63,6 +63,13 @@ #include "ChartTypeTemplate.hxx" +#include "OPropertySet.hxx" +#include "MutexContainer.hxx" + +#ifndef _COMPHELPER_UNO3_HXX_ +#include <comphelper/uno3.hxx> +#endif + #ifndef _DRAFTS_COM_SUN_STAR_CHART2_STACKMODE_HPP_ #include <drafts/com/sun/star/chart2/StackMode.hpp> #endif @@ -70,20 +77,37 @@ namespace chart { -class ColumnLineChartTypeTemplate : public ChartTypeTemplate +class ColumnLineChartTypeTemplate : + public helper::MutexContainer, + public ChartTypeTemplate, + public ::property::OPropertySet { public: explicit ColumnLineChartTypeTemplate( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext, + const ::rtl::OUString & rServiceName, ::drafts::com::sun::star::chart2::StackMode eStackMode, sal_Int32 nNumberOfLines ); virtual ~ColumnLineChartTypeTemplate(); + /// XServiceInfo declarations + APPHELPER_XSERVICEINFO_DECL() + + /// merge XInterface implementations + DECLARE_XINTERFACE() + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + protected: - // ____ XChartTypeTemplate ____ - virtual ::com::sun::star::uno::Reference< - ::drafts::com::sun::star::chart2::XChartType > SAL_CALL getChartTypeForAdditionalSeries() + // ____ OPropertySet ____ + virtual ::com::sun::star::uno::Any GetDefaultValue( sal_Int32 nHandle ) const + throw(::com::sun::star::beans::UnknownPropertyException); + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); + + // ____ XPropertySet ____ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() throw (::com::sun::star::uno::RuntimeException); // ____ ChartTypeTemplate ____ @@ -96,10 +120,13 @@ protected: ::drafts::com::sun::star::chart2::XBoundedCoordinateSystem > & rCoordSys ); + virtual ::com::sun::star::uno::Reference< + ::drafts::com::sun::star::chart2::XChartType > getDefaultChartType() + throw (::com::sun::star::uno::RuntimeException); + private: ::drafts::com::sun::star::chart2::StackMode m_eStackMode; - sal_Int32 m_nNumberOfLines; }; } // namespace chart diff --git a/chart2/source/model/template/LineChartTypeTemplate.cxx b/chart2/source/model/template/LineChartTypeTemplate.cxx index 1334b365c4bc..7e6dc44bfa9a 100644 --- a/chart2/source/model/template/LineChartTypeTemplate.cxx +++ b/chart2/source/model/template/LineChartTypeTemplate.cxx @@ -2,9 +2,9 @@ * * $RCSfile: LineChartTypeTemplate.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:32 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:35 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,11 +70,12 @@ namespace chart LineChartTypeTemplate::LineChartTypeTemplate( uno::Reference< uno::XComponentContext > const & xContext, + const ::rtl::OUString & rServiceName, chart2::StackMode eStackMode, SplineMode eSplineMode, bool bSymbols, sal_Int32 nDim /* = 2 */ ) : - ChartTypeTemplate( xContext ), + ChartTypeTemplate( xContext, rServiceName ), m_eStackMode( eStackMode ), m_eSplineMode( eSplineMode ), m_bHasSymbols( bSymbols ), @@ -94,8 +95,7 @@ chart2::StackMode LineChartTypeTemplate::getStackMode() const return m_eStackMode; } -// ____ XChartTypeTemplate ____ -uno::Reference< chart2::XChartType > SAL_CALL LineChartTypeTemplate::getChartTypeForAdditionalSeries() +uno::Reference< chart2::XChartType > LineChartTypeTemplate::getDefaultChartType() throw (uno::RuntimeException) { return new LineChartType( m_nDim ); diff --git a/chart2/source/model/template/LineChartTypeTemplate.hxx b/chart2/source/model/template/LineChartTypeTemplate.hxx index d8c2c939192c..f2f478142b48 100644 --- a/chart2/source/model/template/LineChartTypeTemplate.hxx +++ b/chart2/source/model/template/LineChartTypeTemplate.hxx @@ -2,9 +2,9 @@ * * $RCSfile: LineChartTypeTemplate.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:32 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:35 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -83,6 +83,7 @@ public: explicit LineChartTypeTemplate( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext, + const ::rtl::OUString & rServiceName, ::drafts::com::sun::star::chart2::StackMode eStackMode, SplineMode eSplineMode, bool bSymbols, sal_Int32 nDim = 2 ); virtual ~LineChartTypeTemplate(); @@ -91,10 +92,8 @@ protected: // ____ ChartTypeTemplate ____ virtual sal_Int32 getDimension() const; virtual ::drafts::com::sun::star::chart2::StackMode getStackMode() const; - - // ____ XChartTypeTemplate ____ virtual ::com::sun::star::uno::Reference< - ::drafts::com::sun::star::chart2::XChartType > SAL_CALL getChartTypeForAdditionalSeries() + ::drafts::com::sun::star::chart2::XChartType > getDefaultChartType() throw (::com::sun::star::uno::RuntimeException); private: diff --git a/chart2/source/model/template/PieChartTypeTemplate.cxx b/chart2/source/model/template/PieChartTypeTemplate.cxx index 01037b7d4d8c..11245487af7c 100644 --- a/chart2/source/model/template/PieChartTypeTemplate.cxx +++ b/chart2/source/model/template/PieChartTypeTemplate.cxx @@ -2,9 +2,9 @@ * * $RCSfile: PieChartTypeTemplate.cxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:32 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:35 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -65,6 +65,16 @@ #include "PieChartType.hxx" #include "Scale.hxx" #include "macros.hxx" +#include "algohelper.hxx" + +#ifndef CHART_PROPERTYHELPER_HXX +#include "PropertyHelper.hxx" +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_ +#include <com/sun/star/beans/PropertyAttribute.hpp> +#endif + +#include <algorithm> using namespace ::com::sun::star; using namespace ::drafts::com::sun::star; @@ -76,27 +86,189 @@ using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Any; using ::osl::MutexGuard; +namespace +{ + +static const ::rtl::OUString lcl_aServiceName( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.PieChartTypeTemplate" )); + +enum +{ + PROP_PIE_TEMPLATE_DEFAULT_OFFSET, + PROP_PIE_TEMPLATE_OFFSET_MODE, + PROP_PIE_TEMPLATE_DIMENSION, + PROP_PIE_TEMPLATE_USE_RINGS +}; + +void lcl_AddPropertiesToVector( + ::std::vector< Property > & rOutProperties ) +{ + rOutProperties.push_back( + Property( C2U( "OffsetMode" ), + PROP_PIE_TEMPLATE_OFFSET_MODE, + ::getCppuType( reinterpret_cast< const chart2::PieChartOffsetMode * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "DefaultOffset" ), + PROP_PIE_TEMPLATE_DEFAULT_OFFSET, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "Dimension" ), + PROP_PIE_TEMPLATE_DIMENSION, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "UseRings" ), + PROP_PIE_TEMPLATE_USE_RINGS, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); +} + +void lcl_AddDefaultsToMap( + ::chart::helper::tPropertyValueMap & rOutMap ) +{ + OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_PIE_TEMPLATE_OFFSET_MODE )); + rOutMap[ PROP_PIE_TEMPLATE_OFFSET_MODE ] = + uno::makeAny( chart2::PieChartOffsetMode_NONE ); + OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_PIE_TEMPLATE_DEFAULT_OFFSET )); + rOutMap[ PROP_PIE_TEMPLATE_DEFAULT_OFFSET ] = + uno::makeAny( sal_Int32( 10 ) ); + OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_PIE_TEMPLATE_DIMENSION )); + rOutMap[ PROP_PIE_TEMPLATE_DIMENSION ] = + uno::makeAny( sal_Int32( 2 ) ); + OSL_ASSERT( rOutMap.end() == rOutMap.find( PROP_PIE_TEMPLATE_USE_RINGS )); + rOutMap[ PROP_PIE_TEMPLATE_USE_RINGS ] = + uno::makeAny( sal_False ); +} + +const uno::Sequence< Property > & lcl_GetPropertySequence() +{ + static uno::Sequence< Property > aPropSeq; + + // /-- + 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::helper::PropertyNameLess() ); + + // transfer result to static Sequence + aPropSeq = ::chart::helper::VectorToSequence( aProperties ); + } + + return aPropSeq; +} + +::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +{ + static ::cppu::OPropertyArrayHelper aArrayHelper( + lcl_GetPropertySequence(), + /* bSorted = */ sal_True ); + + return aArrayHelper; +} + +} // anonymous namespace + namespace chart { PieChartTypeTemplate::PieChartTypeTemplate( uno::Reference< uno::XComponentContext > const & xContext, - PieOffsetMode eMode, + const ::rtl::OUString & rServiceName, + chart2::PieChartOffsetMode eMode, bool bRings /* = false */, sal_Int32 nDim /* = 2 */ ) : - ChartTypeTemplate( xContext ), + ChartTypeTemplate( xContext, rServiceName ), + ::property::OPropertySet( m_aMutex ), m_ePieOffsetMode( eMode ), - m_nDim( nDim ), m_bIsRingChart( bRings ) -{} +{ + setFastPropertyValue_NoBroadcast( PROP_PIE_TEMPLATE_OFFSET_MODE, uno::makeAny( eMode )); + setFastPropertyValue_NoBroadcast( PROP_PIE_TEMPLATE_DIMENSION, uno::makeAny( nDim )); + setFastPropertyValue_NoBroadcast( PROP_PIE_TEMPLATE_USE_RINGS, uno::makeAny( sal_Bool( bRings ))); +} PieChartTypeTemplate::~PieChartTypeTemplate() {} +// ____ OPropertySet ____ +uno::Any PieChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle ) const + throw(beans::UnknownPropertyException) +{ + static helper::tPropertyValueMap aStaticDefaults; + + // /-- + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( 0 == aStaticDefaults.size() ) + { + // initialize defaults + lcl_AddDefaultsToMap( aStaticDefaults ); + } + + helper::tPropertyValueMap::const_iterator aFound( + aStaticDefaults.find( nHandle )); + + if( aFound == aStaticDefaults.end()) + return uno::Any(); + + return (*aFound).second; + // \-- +} + +::cppu::IPropertyArrayHelper & SAL_CALL PieChartTypeTemplate::getInfoHelper() +{ + return lcl_getInfoHelper(); +} + + +// ____ XPropertySet ____ +uno::Reference< beans::XPropertySetInfo > SAL_CALL + PieChartTypeTemplate::getPropertySetInfo() + throw (uno::RuntimeException) +{ + static uno::Reference< beans::XPropertySetInfo > xInfo; + + // /-- + MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( !xInfo.is()) + { + xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( + getInfoHelper()); + } + + return xInfo; + // \-- +} + + +// ____ ChartTypeTemplate ____ sal_Int32 PieChartTypeTemplate::getDimension() const { - return m_nDim; + sal_Int32 nDim = 2; + try + { + // note: UNO-methods are never const + const_cast< PieChartTypeTemplate * >( this )-> + getFastPropertyValue( PROP_PIE_TEMPLATE_DIMENSION ) >>= nDim; + } + catch( beans::UnknownPropertyException & ex ) + { + ASSERT_EXCEPTION( ex ); + } + + return nDim; } uno::Reference< chart2::XBoundedCoordinateSystem > PieChartTypeTemplate::createCoordinateSystem( @@ -139,9 +311,12 @@ Reference< chart2::XDataSeriesTreeParent > PieChartTypeTemplate::createDataSerie const Sequence< Reference< chart2::XDataSeries > > & aSeriesSeq, const Reference< chart2::XBoundedCoordinateSystem > & rCoordSys ) { - sal_Int32 nOffset = (m_ePieOffsetMode == NO_OFFSET) + sal_Int32 nDefaultOffset = 10; + sal_Int32 nDim = getDimension(); + getFastPropertyValue( PROP_PIE_TEMPLATE_DEFAULT_OFFSET ) >>= nDefaultOffset; + sal_Int32 nOffset = (m_ePieOffsetMode == chart2::PieChartOffsetMode_NONE) ? 0 - : m_nDefaultOffset; + : nDefaultOffset; // create series tree nodes // root @@ -149,7 +324,7 @@ Reference< chart2::XDataSeriesTreeParent > PieChartTypeTemplate::createDataSerie // chart type group Reference< chart2::XDataSeriesTreeNode > aChartTypeNode( - createChartTypeGroup( new PieChartType( m_nDim, nOffset ))); + createChartTypeGroup( new PieChartType( nDim, nOffset ))); // 'x-axis' group Reference< chart2::XDataSeriesTreeNode > aCategoryNode( @@ -164,7 +339,7 @@ Reference< chart2::XDataSeriesTreeParent > PieChartTypeTemplate::createDataSerie // build tree // add series node to value node - if( m_ePieOffsetMode == FIRST_EXPLODED ) + if( m_ePieOffsetMode == chart2::PieChartOffsetMode_FIRST_EXPLODED ) { if( aSeriesSeq.getLength() >= 1 ) { @@ -176,7 +351,7 @@ Reference< chart2::XDataSeriesTreeParent > PieChartTypeTemplate::createDataSerie { // chart type group Reference< chart2::XDataSeriesTreeNode > aChartTypeNode2( - createChartTypeGroup( new PieChartType( m_nDim, 0 ))); + createChartTypeGroup( new PieChartType( nDim, 0 ))); // 'x-axis' group Reference< chart2::XDataSeriesTreeNode > aCategoryNode2( @@ -208,15 +383,33 @@ Reference< chart2::XDataSeriesTreeParent > PieChartTypeTemplate::createDataSerie return aRoot; } -// ____ XChartTypeTemplate ____ -uno::Reference< chart2::XChartType > SAL_CALL PieChartTypeTemplate::getChartTypeForAdditionalSeries() +uno::Reference< chart2::XChartType > PieChartTypeTemplate::getDefaultChartType() throw (uno::RuntimeException) { sal_Int32 nOffset = 0; - if( m_ePieOffsetMode == ALL_EXPLODED ) - nOffset = m_nDefaultOffset; + if( m_ePieOffsetMode == chart2::PieChartOffsetMode_ALL_EXPLODED ) + { + nOffset = 10; + getFastPropertyValue( PROP_PIE_TEMPLATE_DEFAULT_OFFSET ) >>= nOffset; + } + + return new PieChartType( getDimension(), nOffset ); +} - return new PieChartType( m_nDim, nOffset ); +// ---------------------------------------- + +uno::Sequence< ::rtl::OUString > PieChartTypeTemplate::getSupportedServiceNames_Static() +{ + uno::Sequence< ::rtl::OUString > aServices( 2 ); + aServices[ 0 ] = lcl_aServiceName; + aServices[ 1 ] = C2U( "drafts.com.sun.star.chart2.ChartTypeTemplate" ); + return aServices; } +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +APPHELPER_XSERVICEINFO_IMPL( PieChartTypeTemplate, lcl_aServiceName ); + +IMPLEMENT_FORWARD_XINTERFACE2( PieChartTypeTemplate, ChartTypeTemplate, OPropertySet ) +IMPLEMENT_FORWARD_XTYPEPROVIDER2( PieChartTypeTemplate, ChartTypeTemplate, OPropertySet ) + } // namespace chart diff --git a/chart2/source/model/template/PieChartTypeTemplate.hxx b/chart2/source/model/template/PieChartTypeTemplate.hxx index 8d2bbdd24904..010616b02fe7 100644 --- a/chart2/source/model/template/PieChartTypeTemplate.hxx +++ b/chart2/source/model/template/PieChartTypeTemplate.hxx @@ -2,9 +2,9 @@ * * $RCSfile: PieChartTypeTemplate.hxx,v $ * - * $Revision: 1.1.1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: bm $ $Date: 2003-10-06 09:58:32 $ + * last change: $Author: bm $ $Date: 2003-11-04 12:37:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -61,30 +61,56 @@ #ifndef CHART_PIECHARTTYPETEMPLATE_HXX #define CHART_PIECHARTTYPETEMPLATE_HXX +#include "OPropertySet.hxx" +#include "MutexContainer.hxx" + +#ifndef _COMPHELPER_UNO3_HXX_ +#include <comphelper/uno3.hxx> +#endif + #include "ChartTypeTemplate.hxx" +#ifndef _DRAFTS_COM_SUN_STAR_CHART2_PIECHARTOFFSETMODE_HPP_ +#include <drafts/com/sun/star/chart2/PieChartOffsetMode.hpp> +#endif + namespace chart { -class PieChartTypeTemplate : public ChartTypeTemplate +class PieChartTypeTemplate : + public helper::MutexContainer, + public ChartTypeTemplate, + public ::property::OPropertySet { public: - enum PieOffsetMode - { - NO_OFFSET, - FIRST_EXPLODED, - ALL_EXPLODED - }; - PieChartTypeTemplate( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext, - PieOffsetMode eMode, + const ::rtl::OUString & rServiceName, + ::drafts::com::sun::star::chart2::PieChartOffsetMode eMode, bool bRings = false, sal_Int32 nDim = 2 ); virtual ~PieChartTypeTemplate(); + /// XServiceInfo declarations + APPHELPER_XSERVICEINFO_DECL() + + /// merge XInterface implementations + DECLARE_XINTERFACE() + /// merge XTypeProvider implementations + DECLARE_XTYPEPROVIDER() + protected: + // ____ OPropertySet ____ + virtual ::com::sun::star::uno::Any GetDefaultValue( sal_Int32 nHandle ) const + throw(::com::sun::star::beans::UnknownPropertyException); + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); + + // ____ XPropertySet ____ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + // ____ ChartTypeTemplate ____ virtual sal_Int32 getDimension() const; @@ -109,18 +135,14 @@ protected: ::drafts::com::sun::star::chart2::XBoundedCoordinateSystem > & rCoordSys ); - // ____ XChartTypeTemplate ____ virtual ::com::sun::star::uno::Reference< - ::drafts::com::sun::star::chart2::XChartType > SAL_CALL getChartTypeForAdditionalSeries() + ::drafts::com::sun::star::chart2::XChartType > getDefaultChartType() throw (::com::sun::star::uno::RuntimeException); private: - PieOffsetMode m_ePieOffsetMode; - sal_Int32 m_nDim; - bool m_bIsRingChart; - - // same value as in old chart - static const sal_Int32 m_nDefaultOffset = 10; + ::drafts::com::sun::star::chart2::PieChartOffsetMode + m_ePieOffsetMode; + bool m_bIsRingChart; }; } // namespace chart diff --git a/chart2/source/model/template/makefile.mk b/chart2/source/model/template/makefile.mk index a24cb6d3eed0..bcfddc2fc99e 100644 --- a/chart2/source/model/template/makefile.mk +++ b/chart2/source/model/template/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.1.1.1 $ +# $Revision: 1.2 $ # -# last change: $Author: bm $ $Date: 2003-10-06 09:58:32 $ +# last change: $Author: bm $ $Date: 2003-11-04 12:37:36 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -83,6 +83,7 @@ SLOFILES= \ $(SLO)$/ChartType.obj \ $(SLO)$/ChartTypeManager.obj \ $(SLO)$/ChartTypeTemplate.obj \ + $(SLO)$/ColumnChartType.obj \ $(SLO)$/ColumnLineChartTypeTemplate.obj \ $(SLO)$/DoubleStackedBarChartTypeTemplate.obj \ $(SLO)$/LineChartType.obj \ |