diff --git a/chart2/source/model/main/ChartModel.cxx b/chart2/source/model/main/ChartModel.cxx index 4882ecef72de..6dbd255dcab5 100644 --- a/chart2/source/model/main/ChartModel.cxx +++ b/chart2/source/model/main/ChartModel.cxx @@ -738,8 +738,7 @@ sal_Bool SAL_CALL ChartModel::hasInternalDataProvider() setModified( sal_True ); } - void SAL_CALL ChartModel -::setArguments( const Sequence< beans::PropertyValue >& aArguments ) +void SAL_CALL ChartModel::setArguments( const Sequence< beans::PropertyValue >& aArguments ) throw (lang::IllegalArgumentException, uno::RuntimeException) { diff --git a/chart2/source/model/main/ImplChartModel.cxx b/chart2/source/model/main/ImplChartModel.cxx index 5975f44bdce7..984c5c4a5c0a 100755 --- a/chart2/source/model/main/ImplChartModel.cxx +++ b/chart2/source/model/main/ImplChartModel.cxx @@ -134,7 +134,6 @@ ImplChartModel::ImplChartModel( xContext ), uno::UNO_QUERY ); GetStyleFamilies(); - CreateDefaultChartTypeTemplate(); } ImplChartModel::ImplChartModel( const ImplChartModel & rOther, const Reference< util::XModifyListener > & xListener ) : @@ -145,7 +144,6 @@ ImplChartModel::ImplChartModel( const ImplChartModel & rOther, const Reference< { m_xFamilies.set( CreateRefClone< Reference< container::XNameAccess > >()( rOther.m_xFamilies )); m_xChartTypeManager.set( CreateRefClone< Reference< chart2::XChartTypeManager > >()( rOther.m_xChartTypeManager )); - m_xChartTypeTemplate.set( CreateRefClone< Reference< chart2::XChartTypeTemplate > >()( rOther.m_xChartTypeTemplate )); m_xTitle.set( CreateRefClone< Reference< chart2::XTitle > >()( rOther.m_xTitle )); ModifyListenerHelper::addListener( m_xTitle, m_xModifyListener ); m_xPageBackground.set( CreateRefClone< Reference< beans::XPropertySet > >()( rOther.m_xPageBackground )); @@ -238,7 +236,7 @@ Reference< chart2::data::XDataSource > SAL_CALL ImplChartModel::SetArguments( bool bSetData ) throw (lang::IllegalArgumentException) { - Reference< chart2::data::XDataSource > xResult; + Reference< chart2::data::XDataSource > xDataSource; try { OSL_ASSERT( m_spChartData.get() ); @@ -247,10 +245,39 @@ Reference< chart2::data::XDataSource > SAL_CALL ImplChartModel::SetArguments( m_spChartData->getDataProvider()); if( xDataProvider.is() ) { - xResult.set( xDataProvider->createDataSource( aArguments )); + xDataSource.set( xDataProvider->createDataSource( aArguments )); - if( bSetData && xResult.is()) - SetNewData( xResult, aArguments ); + if( bSetData && xDataSource.is()) + { + // set new data + Reference< chart2::XDiagram > xDia; + if( m_aDiagrams.size() > 0 ) + xDia.set( GetDiagram(0)); + Reference< chart2::XChartTypeTemplate > xTemplate; + + if( xDia.is()) + { + // apply new data + DiagramHelper::tTemplateWithServiceName aTemplateAndService = + DiagramHelper::getTemplateForDiagram( + xDia, Reference< lang::XMultiServiceFactory >( m_xChartTypeManager, uno::UNO_QUERY )); + xTemplate.set( aTemplateAndService.first ); + } + + if( !xTemplate.is()) + xTemplate.set( CreateDefaultChartTypeTemplate() ); + + if( xTemplate.is()) + { + if( xDia.is()) + xTemplate->changeDiagramData( xDia, xDataSource, aArguments ); + else + { + RemoveAllDiagrams(); + AppendDiagram( xTemplate->createDiagramByDataSource( xDataSource, aArguments )); + } + } + } } } catch( lang::IllegalArgumentException & ) @@ -262,27 +289,7 @@ Reference< chart2::data::XDataSource > SAL_CALL ImplChartModel::SetArguments( ASSERT_EXCEPTION( ex ); } - return xResult; -} - -Reference< chart2::data::XDataSource > SAL_CALL ImplChartModel::SetRangeRepresentation( - const OUString & rRangeRepresentation, bool bSetData ) - throw (::com::sun::star::lang::IllegalArgumentException) -{ - uno::Sequence< beans::PropertyValue > aArgs( 4 ); - aArgs[0] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("CellRangeRepresentation"), -1, - uno::makeAny( rRangeRepresentation ), beans::PropertyState_DIRECT_VALUE ); - aArgs[1] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("HasCategories"), -1, - uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE ); - aArgs[2] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("FirstCellAsLabel"), -1, - uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE ); - aArgs[3] = beans::PropertyValue( - ::rtl::OUString::createFromAscii("DataRowSource"), -1, - uno::makeAny( ::com::sun::star::chart::ChartDataRowSource_COLUMNS ), beans::PropertyState_DIRECT_VALUE ); - return SetArguments( aArgs, bSetData ); + return xDataSource; } void ImplChartModel::SetChartTypeManager( @@ -296,19 +303,12 @@ Reference< chart2::XChartTypeManager > ImplChartModel::GetChartTypeManager() return m_xChartTypeManager; } -Reference< chart2::XChartTypeTemplate > ImplChartModel::GetChartTypeTemplate() -{ - return m_xChartTypeTemplate; -} - void ImplChartModel::CreateDefaultChart() { - CreateDefaultChartTypeTemplate(); - // clean up RemoveAllDiagrams(); - Reference< chart2::XChartTypeTemplate > xTemplate( GetChartTypeTemplate()); + Reference< chart2::XChartTypeTemplate > xTemplate( CreateDefaultChartTypeTemplate() ); if( xTemplate.is()) { try @@ -316,11 +316,8 @@ void ImplChartModel::CreateDefaultChart() Reference< chart2::data::XDataSource > xDataSource( CreateDefaultData()); Sequence< beans::PropertyValue > aParam; - Sequence< OUString > aParamNames( xTemplate->getAvailableCreationParameterNames()); - const OUString * pBeg = aParamNames.getConstArray(); - const OUString * pEnd = pBeg + aParamNames.getLength(); - const OUString * pFound( ::std::find( pBeg, pEnd, C2U("HasCategories"))); - if( pFound != pEnd ) + bool bSupportsCategories = xTemplate->supportsCategories(); + if( bSupportsCategories ) { aParam.realloc( 1 ); aParam[0] = beans::PropertyValue( C2U("HasCategories"), -1, uno::makeAny( true ), @@ -417,7 +414,6 @@ void ImplChartModel::dispose() DisposeHelper::DisposeAndClear( m_xFamilies ); DisposeHelper::DisposeAndClear( m_xOwnNumberFormatsSupplier ); DisposeHelper::DisposeAndClear( m_xChartTypeManager ); - DisposeHelper::DisposeAndClear( m_xChartTypeTemplate ); DisposeHelper::DisposeAllElements( m_aDiagrams ); m_aDiagrams.clear(); DisposeHelper::DisposeAndClear( m_xTitle ); @@ -446,55 +442,36 @@ Reference< chart2::XUndoManager > ImplChartModel::GetUndoManager() return m_xUndoManager; } -void ImplChartModel::SetNewData( const Reference< chart2::data::XDataSource > & xDataSource, - const Sequence< beans::PropertyValue > & rArgs ) -{ - Reference< chart2::XDiagram > xDia; - if( m_aDiagrams.size() > 0 ) - xDia.set( GetDiagram(0)); - Reference< chart2::XChartTypeTemplate > xTemplate; - - if( xDia.is()) - { - // apply new data - DiagramHelper::tTemplateWithServiceName aTemplateAndService = - DiagramHelper::getTemplateForDiagram( - xDia, Reference< lang::XMultiServiceFactory >( m_xChartTypeManager, uno::UNO_QUERY )); - xTemplate.set( aTemplateAndService.first ); - } - - if( !xTemplate.is()) - xTemplate.set( GetChartTypeTemplate()); - - if( xTemplate.is()) - { - if( xDia.is()) - xTemplate->changeDiagramData( xDia, xDataSource, rArgs ); - else - { - RemoveAllDiagrams(); - AppendDiagram( xTemplate->createDiagramByDataSource( xDataSource, rArgs )); - } - } -} - Reference< chart2::data::XDataSource > ImplChartModel::CreateDefaultData() { - Reference< chart2::data::XDataSource > xResult; + Reference< chart2::data::XDataSource > xDataSource; if( m_spChartData->createDefaultData()) - xResult.set( SetRangeRepresentation( C2U("all"), false /* bSetData */ )); - return xResult; + { + uno::Sequence< beans::PropertyValue > aArgs( 4 ); + aArgs[0] = beans::PropertyValue( + ::rtl::OUString::createFromAscii("CellRangeRepresentation"), -1, + uno::makeAny( C2U("all") ), beans::PropertyState_DIRECT_VALUE ); + aArgs[1] = beans::PropertyValue( + ::rtl::OUString::createFromAscii("HasCategories"), -1, + uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE ); + aArgs[2] = beans::PropertyValue( + ::rtl::OUString::createFromAscii("FirstCellAsLabel"), -1, + uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE ); + aArgs[3] = beans::PropertyValue( + ::rtl::OUString::createFromAscii("DataRowSource"), -1, + uno::makeAny( ::com::sun::star::chart::ChartDataRowSource_COLUMNS ), beans::PropertyState_DIRECT_VALUE ); + xDataSource = SetArguments( aArgs, false /*bSetData*/ ); + } + return xDataSource; } -void ImplChartModel::CreateDefaultChartTypeTemplate() +Reference< chart2::XChartTypeTemplate > ImplChartModel::CreateDefaultChartTypeTemplate() { - // set default chart type + Reference< chart2::XChartTypeTemplate > xTemplate; Reference< lang::XMultiServiceFactory > xFact( m_xChartTypeManager, uno::UNO_QUERY ); if( xFact.is() ) - { - m_xChartTypeTemplate.set( - xFact->createInstance( C2U( "com.sun.star.chart2.template.Column" ) ), uno::UNO_QUERY ); - } + xTemplate.set( xFact->createInstance( C2U( "com.sun.star.chart2.template.Column" ) ), uno::UNO_QUERY ); + return xTemplate; } Reference< uno::XInterface > ImplChartModel::GetDashTable() const diff --git a/chart2/source/model/main/ImplChartModel.hxx b/chart2/source/model/main/ImplChartModel.hxx index 9a912feee246..b263974f3f18 100644 --- a/chart2/source/model/main/ImplChartModel.hxx +++ b/chart2/source/model/main/ImplChartModel.hxx @@ -139,10 +139,6 @@ public: ::com::sun::star::chart2::XChartTypeManager > GetChartTypeManager(); - ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XChartTypeTemplate > - GetChartTypeTemplate(); - ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTitle > GetTitle(); @@ -184,16 +180,8 @@ public: ::com::sun::star::util::XNumberFormatsSupplier > & xNumberFormatsSupplier ); private: - void CreateDefaultChartTypeTemplate(); - ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::data::XDataSource > CreateDefaultData(); - void SetNewData( const ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::data::XDataSource > & xDataSource, - const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & rArgs ); - ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::data::XDataSource > SAL_CALL SetRangeRepresentation( - const ::rtl::OUString & rRangeRepresentation, bool bSetData ) - throw (::com::sun::star::lang::IllegalArgumentException); + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartTypeTemplate > CreateDefaultChartTypeTemplate(); + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource > CreateDefaultData(); // void CreateDefaultLayout(); @@ -202,13 +190,6 @@ private: ::boost::shared_ptr< ChartData > m_spChartData; - // Data Access (deprecated, temporary solution) -// ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource > m_xChartData; -// ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataProvider > m_xDataProvider; - -// ::std::vector< ::com::sun::star::uno::Reference< -// ::com::sun::star::chart2::XDataSeries > > m_aInterpretedData; - ::com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier > m_xOwnNumberFormatsSupplier; ::com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier > @@ -216,8 +197,6 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartTypeManager > m_xChartTypeManager; - ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartTypeTemplate > - m_xChartTypeTemplate; // Diagram Access typedef ::std::vector< ::com::sun::star::uno::Reference< diff --git a/chart2/source/model/template/BubbleChartTypeTemplate.cxx b/chart2/source/model/template/BubbleChartTypeTemplate.cxx index 0853cea6a5cb..ef6fcc32d27b 100644 --- a/chart2/source/model/template/BubbleChartTypeTemplate.cxx +++ b/chart2/source/model/template/BubbleChartTypeTemplate.cxx @@ -181,12 +181,6 @@ StackMode BubbleChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex */ return StackMode_NONE; } -bool BubbleChartTypeTemplate::supportsCategories() const -{ - return false; -} - - void SAL_CALL BubbleChartTypeTemplate::applyStyle( const Reference< chart2::XDataSeries >& xSeries, ::sal_Int32 nChartTypeIndex, @@ -206,10 +200,10 @@ void SAL_CALL BubbleChartTypeTemplate::applyStyle( } // ____ XChartTypeTemplate ____ -Sequence< OUString > SAL_CALL BubbleChartTypeTemplate::getAvailableCreationParameterNames() +sal_Bool SAL_CALL BubbleChartTypeTemplate::supportsCategories() throw (uno::RuntimeException) { - return Sequence< OUString >(); + return false; } sal_Bool SAL_CALL BubbleChartTypeTemplate::matchesTemplate( diff --git a/chart2/source/model/template/BubbleChartTypeTemplate.hxx b/chart2/source/model/template/BubbleChartTypeTemplate.hxx index c094e38e28ac..8e3153e30cad 100644 --- a/chart2/source/model/template/BubbleChartTypeTemplate.hxx +++ b/chart2/source/model/template/BubbleChartTypeTemplate.hxx @@ -70,7 +70,7 @@ protected: throw (::com::sun::star::uno::RuntimeException); // ____ XChartTypeTemplate ____ - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableCreationParameterNames() + virtual sal_Bool SAL_CALL supportsCategories() throw (::com::sun::star::uno::RuntimeException); virtual sal_Bool SAL_CALL matchesTemplate( const ::com::sun::star::uno::Reference< @@ -96,8 +96,6 @@ protected: getChartTypeForIndex( sal_Int32 nChartTypeIndex ); virtual sal_Int32 getDimension() const; virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const; - - virtual bool supportsCategories() const; }; } // namespace chart diff --git a/chart2/source/model/template/ChartTypeTemplate.cxx b/chart2/source/model/template/ChartTypeTemplate.cxx index b735b8a90bc4..447722f880af 100644 --- a/chart2/source/model/template/ChartTypeTemplate.cxx +++ b/chart2/source/model/template/ChartTypeTemplate.cxx @@ -195,11 +195,10 @@ uno::Reference< XDiagram > SAL_CALL ChartTypeTemplate::createDiagramByDataSource return xDia; } -Sequence< OUString > SAL_CALL ChartTypeTemplate::getAvailableCreationParameterNames() +sal_Bool SAL_CALL ChartTypeTemplate::supportsCategories() throw (uno::RuntimeException) { - OUString aHasCat( C2U("HasCategories")); - return Sequence< OUString >( & aHasCat, 1 ); + return sal_True; } void SAL_CALL ChartTypeTemplate::changeDiagram( const uno::Reference< XDiagram >& xDiagram ) @@ -561,11 +560,6 @@ bool ChartTypeTemplate::isSwapXAndY() const return false; } -bool ChartTypeTemplate::supportsCategories() const -{ - return true; -} - // ________________________________________ void ChartTypeTemplate::createCoordinateSystems( @@ -639,7 +633,7 @@ void ChartTypeTemplate::adaptScales( const Reference< data::XLabeledDataSequence > & xCategories //@todo: in future there may be more than one sequence of categories (e.g. charttype with categories at x and y axis ) ) { - bool bSupportsCategories( supportsCategories()); + bool bSupportsCategories( supportsCategories() ); for( sal_Int32 nCooSysIdx=0; nCooSysIdx& xDataSource, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArguments ) throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableCreationParameterNames() + /// denotes if the chart needs categories at the first scale + virtual sal_Bool SAL_CALL supportsCategories() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL changeDiagram( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDiagram >& xDiagram ) @@ -161,9 +162,6 @@ protected: virtual bool isSwapXAndY() const; - /// denotes if the chart needs categories at the first scale - virtual bool supportsCategories() const; - // Methods for creating the diagram piecewise // ------------------------------------------ diff --git a/chart2/source/model/template/ScatterChartTypeTemplate.cxx b/chart2/source/model/template/ScatterChartTypeTemplate.cxx index a87a82c05827..e81089d1a217 100644 --- a/chart2/source/model/template/ScatterChartTypeTemplate.cxx +++ b/chart2/source/model/template/ScatterChartTypeTemplate.cxx @@ -222,12 +222,6 @@ StackMode ScatterChartTypeTemplate::getStackMode( sal_Int32 /* nChartTypeIndex * return StackMode_NONE; } -bool ScatterChartTypeTemplate::supportsCategories() const -{ - return false; -} - - void SAL_CALL ScatterChartTypeTemplate::applyStyle( const Reference< chart2::XDataSeries >& xSeries, ::sal_Int32 nChartTypeIndex, @@ -252,10 +246,10 @@ void SAL_CALL ScatterChartTypeTemplate::applyStyle( } // ____ XChartTypeTemplate ____ -Sequence< OUString > SAL_CALL ScatterChartTypeTemplate::getAvailableCreationParameterNames() +sal_Bool SAL_CALL ScatterChartTypeTemplate::supportsCategories() throw (uno::RuntimeException) { - return Sequence< OUString >(); + return sal_False; } sal_Bool SAL_CALL ScatterChartTypeTemplate::matchesTemplate( diff --git a/chart2/source/model/template/ScatterChartTypeTemplate.hxx b/chart2/source/model/template/ScatterChartTypeTemplate.hxx index 12a4343c3014..4be7bc851d43 100644 --- a/chart2/source/model/template/ScatterChartTypeTemplate.hxx +++ b/chart2/source/model/template/ScatterChartTypeTemplate.hxx @@ -74,7 +74,7 @@ protected: throw (::com::sun::star::uno::RuntimeException); // ____ XChartTypeTemplate ____ - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableCreationParameterNames() + virtual sal_Bool SAL_CALL supportsCategories() throw (::com::sun::star::uno::RuntimeException); virtual sal_Bool SAL_CALL matchesTemplate( const ::com::sun::star::uno::Reference< @@ -101,8 +101,6 @@ protected: virtual sal_Int32 getDimension() const; virtual StackMode getStackMode( sal_Int32 nChartTypeIndex ) const; - virtual bool supportsCategories() const; - private: bool m_bHasSymbols; bool m_bHasLines;