diff options
author | Mathias Bauer <mba@openoffice.org> | 2011-02-03 15:53:56 +0100 |
---|---|---|
committer | Mathias Bauer <mba@openoffice.org> | 2011-02-03 15:53:56 +0100 |
commit | 76f355864a8c03b64ebfc71139f525a1fc25836a (patch) | |
tree | 189737059bcece8ceacb7abf0c1e3834caa123c5 /chart2/source/controller | |
parent | 894985ff00c217013cc360a77108fc68cd8647e7 (diff) | |
parent | 0ceb085ea2b49234664765161095f2e5911e2b3b (diff) |
CWS gnumake3: resync to m99
Diffstat (limited to 'chart2/source/controller')
60 files changed, 2808 insertions, 2093 deletions
diff --git a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx index ebb9459e7d54..80b7cd20574b 100755 --- a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx @@ -29,10 +29,15 @@ #include "precompiled_chart2.hxx" #include "AxisWrapper.hxx" #include "AxisHelper.hxx" +#include "TitleHelper.hxx" #include "Chart2ModelContact.hxx" #include "ContainerHelper.hxx" #include "macros.hxx" #include "WrappedDirectStateProperty.hxx" +#include "GridWrapper.hxx" +#include "TitleWrapper.hxx" +#include "DisposeHelper.hxx" + #include <comphelper/InlineContainer.hxx> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/chart/ChartAxisArrangeOrderType.hpp> @@ -82,6 +87,9 @@ enum PROP_AXIS_AUTO_MIN, PROP_AXIS_AUTO_STEPMAIN, PROP_AXIS_AUTO_STEPHELP, + PROP_AXIS_TYPE, + PROP_AXIS_TIME_INCREMENT, + PROP_AXIS_EXPLICIT_TIME_INCREMENT, PROP_AXIS_LOGARITHMIC, PROP_AXIS_REVERSEDIRECTION, PROP_AXIS_VISIBLE, @@ -174,6 +182,27 @@ void lcl_AddPropertiesToVector( beans::PropertyAttribute::MAYBEDEFAULT )); rOutProperties.push_back( + Property( C2U( "AxisType" ), + PROP_AXIS_TYPE, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), //type com::sun::star::chart::ChartAxisType + //#i111967# no PropertyChangeEvent is fired on change so far + beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "TimeIncrement" ), + PROP_AXIS_TIME_INCREMENT, + ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::TimeIncrement * >(0)), + //#i111967# no PropertyChangeEvent is fired on change so far + beans::PropertyAttribute::MAYBEVOID )); + + rOutProperties.push_back( + Property( C2U( "ExplicitTimeIncrement" ), + PROP_AXIS_EXPLICIT_TIME_INCREMENT, + ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::TimeIncrement * >(0)), + beans::PropertyAttribute::READONLY | + beans::PropertyAttribute::MAYBEVOID )); + + rOutProperties.push_back( Property( C2U( "Logarithmic" ), PROP_AXIS_LOGARITHMIC, ::getBooleanCppuType(), @@ -374,6 +403,83 @@ AxisWrapper::~AxisWrapper() { } +// ____ chart::XAxis ____ +Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getAxisTitle() throw (uno::RuntimeException) +{ + if( !m_xAxisTitle.is() ) + { + TitleHelper::eTitleType eTitleType( TitleHelper::X_AXIS_TITLE ); + switch( m_eType ) + { + case X_AXIS: + eTitleType = TitleHelper::X_AXIS_TITLE; + break; + case Y_AXIS: + eTitleType = TitleHelper::Y_AXIS_TITLE; + break; + case Z_AXIS: + eTitleType = TitleHelper::Z_AXIS_TITLE; + break; + case SECOND_X_AXIS: + eTitleType = TitleHelper::SECONDARY_X_AXIS_TITLE; + break; + case SECOND_Y_AXIS: + eTitleType = TitleHelper::SECONDARY_Y_AXIS_TITLE; + break; + default: + return 0; + } + m_xAxisTitle = new TitleWrapper( eTitleType, m_spChart2ModelContact ); + } + return m_xAxisTitle; +} +Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getMajorGrid() throw (uno::RuntimeException) +{ + if( !m_xMajorGrid.is() ) + { + GridWrapper::tGridType eGridType( GridWrapper::X_MAJOR_GRID ); + switch( m_eType ) + { + case X_AXIS: + eGridType = GridWrapper::X_MAJOR_GRID; + break; + case Y_AXIS: + eGridType = GridWrapper::Y_MAJOR_GRID; + break; + case Z_AXIS: + eGridType = GridWrapper::Z_MAJOR_GRID; + break; + default: + return 0; + } + m_xMajorGrid = new GridWrapper( eGridType, m_spChart2ModelContact ); + } + return m_xMajorGrid; +} +Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getMinorGrid() throw (uno::RuntimeException) +{ + if( !m_xMinorGrid.is() ) + { + GridWrapper::tGridType eGridType( GridWrapper::X_MAJOR_GRID ); + switch( m_eType ) + { + case X_AXIS: + eGridType = GridWrapper::X_MINOR_GRID; + break; + case Y_AXIS: + eGridType = GridWrapper::Y_MINOR_GRID; + break; + case Z_AXIS: + eGridType = GridWrapper::Z_MINOR_GRID; + break; + default: + return 0; + } + m_xMinorGrid = new GridWrapper( eGridType, m_spChart2ModelContact ); + } + return m_xMinorGrid; +} + // ____ XShape ____ awt::Point SAL_CALL AxisWrapper::getPosition() throw (uno::RuntimeException) @@ -454,6 +560,10 @@ void SAL_CALL AxisWrapper::dispose() Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + DisposeHelper::DisposeAndClear( m_xAxisTitle ); + DisposeHelper::DisposeAndClear( m_xMajorGrid ); + DisposeHelper::DisposeAndClear( m_xMinorGrid ); + clearWrappedPropertySet(); } diff --git a/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx b/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx index 86bd52367bbe..f7a7d514e1f4 100644..100755 --- a/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx @@ -30,9 +30,10 @@ #include "WrappedPropertySet.hxx" #include "ReferenceSizePropertyProvider.hxx" #include "ServiceMacros.hxx" -#include <cppuhelper/implbase4.hxx> +#include <cppuhelper/implbase5.hxx> #include <comphelper/uno3.hxx> #include <cppuhelper/interfacecontainer.hxx> +#include <com/sun/star/chart/XAxis.hpp> #include <com/sun/star/chart2/XAxis.hpp> #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/drawing/XShape.hpp> @@ -45,14 +46,13 @@ namespace chart { - namespace wrapper { - class Chart2ModelContact; -class AxisWrapper : public ::cppu::ImplInheritanceHelper4< +class AxisWrapper : public ::cppu::ImplInheritanceHelper5< WrappedPropertySet + , com::sun::star::chart::XAxis , com::sun::star::drawing::XShape , com::sun::star::lang::XComponent , com::sun::star::lang::XServiceInfo @@ -93,6 +93,11 @@ public: ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); + // ____ chart::XAxis ____ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL getAxisTitle( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL getMajorGrid( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL getMinorGrid( ) throw (::com::sun::star::uno::RuntimeException); + // ____ XShape ____ virtual ::com::sun::star::awt::Point SAL_CALL getPosition() throw (::com::sun::star::uno::RuntimeException); @@ -131,6 +136,10 @@ private: //member tAxisType m_eType; ::com::sun::star::uno::Any m_aTemporaryHelpStepValue; + + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xAxisTitle; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xMajorGrid; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xMinorGrid; }; } // namespace wrapper diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx index e20167e216c2..dafef0f2aa72 100644..100755 --- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx +++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx @@ -27,8 +27,7 @@ #ifndef CHART_CHART2MODELCONTACT_HXX #define CHART_CHART2MODELCONTACT_HXX -#include <com/sun/star/chart2/ExplicitScaleData.hpp> -#include <com/sun/star/chart2/ExplicitIncrementData.hpp> +#include <chartview/ExplicitScaleValues.hxx> #include <com/sun/star/chart2/XAxis.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/XDataSeries.hpp> @@ -79,8 +78,8 @@ public: sal_Bool getExplicitValuesForAxis( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > & xAxis, - ::com::sun::star::chart2::ExplicitScaleData & rOutExplicitScale, - ::com::sun::star::chart2::ExplicitIncrementData & rOutExplicitIncrement ); + ExplicitScaleData & rOutExplicitScale, + ExplicitIncrementData & rOutExplicitIncrement ); sal_Int32 getExplicitNumberFormatKeyForAxis( const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis ); diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx index 7a0907b05a28..3498b812557a 100755 --- a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx @@ -64,9 +64,11 @@ using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; using ::rtl::OUString; using ::osl::MutexGuard; +using ::com::sun::star::chart2::XAnyDescriptionAccess; using ::com::sun::star::chart::XComplexDescriptionAccess; using ::com::sun::star::chart::XChartData; using ::com::sun::star::chart::XChartDataArray; +using ::com::sun::star::chart::XDateCategories; namespace { @@ -132,7 +134,7 @@ struct lcl_Operator virtual ~lcl_Operator() { } - virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess ) = 0; + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) = 0; virtual bool setsCategories( bool /*bDataInColumns*/ ) { @@ -155,13 +157,20 @@ struct lcl_AllOperator : public lcl_Operator return true; } - virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess ) + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) { if( !xDataAccess.is() ) return; + Reference< XAnyDescriptionAccess > xNewAny( m_xDataToApply, uno::UNO_QUERY ); Reference< XComplexDescriptionAccess > xNewComplex( m_xDataToApply, uno::UNO_QUERY ); - if( xNewComplex.is() ) + if( xNewAny.is() ) + { + xDataAccess->setData( xNewAny->getData() ); + xDataAccess->setComplexRowDescriptions( xNewAny->getComplexRowDescriptions() ); + xDataAccess->setComplexColumnDescriptions( xNewAny->getComplexColumnDescriptions() ); + } + else if( xNewComplex.is() ) { xDataAccess->setData( xNewComplex->getData() ); xDataAccess->setComplexRowDescriptions( xNewComplex->getComplexRowDescriptions() ); @@ -192,7 +201,7 @@ struct lcl_DataOperator : public lcl_Operator { } - virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess ) + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) { if( xDataAccess.is() ) xDataAccess->setData( lcl_getNANInsteadDBL_MIN( m_rData ) ); @@ -205,96 +214,208 @@ struct lcl_DataOperator : public lcl_Operator struct lcl_RowDescriptionsOperator : public lcl_Operator { - lcl_RowDescriptionsOperator( const Sequence< OUString >& rRowDescriptions ) + lcl_RowDescriptionsOperator( const Sequence< OUString >& rRowDescriptions + , const Reference< chart2::XChartDocument >& xChartDoc ) : lcl_Operator() , m_rRowDescriptions( rRowDescriptions ) + , m_xChartDoc(xChartDoc) + , m_bDataInColumns(true) { } virtual bool setsCategories( bool bDataInColumns ) { + m_bDataInColumns = bDataInColumns; return bDataInColumns; } - virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess ) + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) { if( xDataAccess.is() ) + { xDataAccess->setRowDescriptions( m_rRowDescriptions ); + if( m_bDataInColumns ) + DiagramHelper::switchToTextCategories( m_xChartDoc ); + } } const Sequence< OUString >& m_rRowDescriptions; + Reference< chart2::XChartDocument > m_xChartDoc; + bool m_bDataInColumns; }; //-------------------------------------------------------------------------- struct lcl_ComplexRowDescriptionsOperator : public lcl_Operator { - lcl_ComplexRowDescriptionsOperator( const Sequence< Sequence< OUString > >& rComplexRowDescriptions ) + lcl_ComplexRowDescriptionsOperator( const Sequence< Sequence< OUString > >& rComplexRowDescriptions + , const Reference< chart2::XChartDocument >& xChartDoc ) : lcl_Operator() , m_rComplexRowDescriptions( rComplexRowDescriptions ) + , m_xChartDoc(xChartDoc) + , m_bDataInColumns(true) { } virtual bool setsCategories( bool bDataInColumns ) { + m_bDataInColumns = bDataInColumns; return bDataInColumns; } - virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess ) + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) { if( xDataAccess.is() ) + { xDataAccess->setComplexRowDescriptions( m_rComplexRowDescriptions ); + if( m_bDataInColumns ) + DiagramHelper::switchToTextCategories( m_xChartDoc ); + } } const Sequence< Sequence< OUString > >& m_rComplexRowDescriptions; + Reference< chart2::XChartDocument > m_xChartDoc; + bool m_bDataInColumns; +}; +//-------------------------------------------------------------------------- + +struct lcl_AnyRowDescriptionsOperator : public lcl_Operator +{ + lcl_AnyRowDescriptionsOperator( const Sequence< Sequence< uno::Any > >& rAnyRowDescriptions ) + : lcl_Operator() + , m_rAnyRowDescriptions( rAnyRowDescriptions ) + { + } + + virtual bool setsCategories( bool bDataInColumns ) + { + return bDataInColumns; + } + + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) + { + if( xDataAccess.is() ) + xDataAccess->setAnyRowDescriptions( m_rAnyRowDescriptions ); + } + + const Sequence< Sequence< uno::Any > >& m_rAnyRowDescriptions; }; //-------------------------------------------------------------------------- struct lcl_ColumnDescriptionsOperator : public lcl_Operator { - lcl_ColumnDescriptionsOperator( const Sequence< OUString >& rColumnDescriptions ) + lcl_ColumnDescriptionsOperator( const Sequence< OUString >& rColumnDescriptions + , const Reference< chart2::XChartDocument >& xChartDoc ) : lcl_Operator() , m_rColumnDescriptions( rColumnDescriptions ) + , m_xChartDoc(xChartDoc) + , m_bDataInColumns(true) { } virtual bool setsCategories( bool bDataInColumns ) { + m_bDataInColumns = bDataInColumns; return !bDataInColumns; } - virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess ) + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) { if( xDataAccess.is() ) + { xDataAccess->setColumnDescriptions( m_rColumnDescriptions ); + if( !m_bDataInColumns ) + DiagramHelper::switchToTextCategories( m_xChartDoc ); + } } const Sequence< OUString >& m_rColumnDescriptions; + Reference< chart2::XChartDocument > m_xChartDoc; + bool m_bDataInColumns; }; //-------------------------------------------------------------------------- struct lcl_ComplexColumnDescriptionsOperator : public lcl_Operator { - lcl_ComplexColumnDescriptionsOperator( const Sequence< Sequence< OUString > >& rComplexColumnDescriptions ) + lcl_ComplexColumnDescriptionsOperator( const Sequence< Sequence< OUString > >& rComplexColumnDescriptions + , const Reference< chart2::XChartDocument >& xChartDoc ) : lcl_Operator() , m_rComplexColumnDescriptions( rComplexColumnDescriptions ) + , m_xChartDoc(xChartDoc) + , m_bDataInColumns(true) { } virtual bool setsCategories( bool bDataInColumns ) { + m_bDataInColumns = bDataInColumns; return !bDataInColumns; } - virtual void apply( const Reference< XComplexDescriptionAccess >& xDataAccess ) + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) { if( xDataAccess.is() ) + { xDataAccess->setComplexColumnDescriptions( m_rComplexColumnDescriptions ); + if( !m_bDataInColumns ) + DiagramHelper::switchToTextCategories( m_xChartDoc ); + } } const Sequence< Sequence< OUString > >& m_rComplexColumnDescriptions; + Reference< chart2::XChartDocument > m_xChartDoc; + bool m_bDataInColumns; +}; + +//-------------------------------------------------------------------------- + +struct lcl_AnyColumnDescriptionsOperator : public lcl_Operator +{ + lcl_AnyColumnDescriptionsOperator( const Sequence< Sequence< uno::Any > >& rAnyColumnDescriptions ) + : lcl_Operator() + , m_rAnyColumnDescriptions( rAnyColumnDescriptions ) + { + } + + virtual bool setsCategories( bool bDataInColumns ) + { + return bDataInColumns; + } + + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) + { + if( xDataAccess.is() ) + xDataAccess->setAnyColumnDescriptions( m_rAnyColumnDescriptions ); + } + + const Sequence< Sequence< uno::Any > >& m_rAnyColumnDescriptions; +}; + +//-------------------------------------------------------------------------- + +struct lcl_DateCategoriesOperator : public lcl_Operator +{ + lcl_DateCategoriesOperator( const Sequence< double >& rDates ) + : lcl_Operator() + , m_rDates( rDates ) + { + } + + virtual bool setsCategories( bool /*bDataInColumns*/ ) + { + return true; + } + + virtual void apply( const Reference< XAnyDescriptionAccess >& xDataAccess ) + { + Reference< XDateCategories > xDateCategories( xDataAccess, uno::UNO_QUERY ); + if( xDateCategories.is() ) + xDateCategories->setDateCategories( m_rDates ); + } + + const Sequence< double >& m_rDates; }; //-------------------------------------------------------------------------- @@ -353,6 +474,7 @@ Sequence< OUString > SAL_CALL ChartDataWrapper::getColumnDescriptions() return m_xDataAccess->getColumnDescriptions(); return Sequence< OUString > (); } + // ____ XComplexDescriptionAccess (read) ____ Sequence< Sequence< OUString > > SAL_CALL ChartDataWrapper::getComplexRowDescriptions() throw (uno::RuntimeException) { @@ -369,6 +491,32 @@ Sequence< Sequence< OUString > > SAL_CALL ChartDataWrapper::getComplexColumnDesc return Sequence< Sequence< OUString > >(); } +// ____ XAnyDescriptionAccess (read) ____ +Sequence< Sequence< uno::Any > > SAL_CALL ChartDataWrapper::getAnyRowDescriptions() throw (uno::RuntimeException) +{ + initDataAccess(); + if( m_xDataAccess.is() ) + return m_xDataAccess->getAnyRowDescriptions(); + return Sequence< Sequence< uno::Any > >(); +} +Sequence< Sequence< uno::Any > > SAL_CALL ChartDataWrapper::getAnyColumnDescriptions() throw (uno::RuntimeException) +{ + initDataAccess(); + if( m_xDataAccess.is() ) + return m_xDataAccess->getAnyColumnDescriptions(); + return Sequence< Sequence< uno::Any > >(); +} + +// ____ XDateCategories (read) ____ +Sequence< double > SAL_CALL ChartDataWrapper::getDateCategories() throw (uno::RuntimeException) +{ + initDataAccess(); + Reference< XDateCategories > xDateCategories( m_xDataAccess, uno::UNO_QUERY ); + if( xDateCategories.is() ) + return xDateCategories->getDateCategories(); + return Sequence< double >(); +} + // ____ XChartDataArray (write)____ void SAL_CALL ChartDataWrapper::setData( const Sequence< Sequence< double > >& rData ) throw (uno::RuntimeException) @@ -379,28 +527,50 @@ void SAL_CALL ChartDataWrapper::setData( const Sequence< Sequence< double > >& r void SAL_CALL ChartDataWrapper::setRowDescriptions( const Sequence< OUString >& rRowDescriptions ) throw (uno::RuntimeException) { - lcl_RowDescriptionsOperator aOperator( rRowDescriptions ); + lcl_RowDescriptionsOperator aOperator( rRowDescriptions, m_spChart2ModelContact->getChart2Document() ); applyData( aOperator ); } void SAL_CALL ChartDataWrapper::setColumnDescriptions( const Sequence< OUString >& rColumnDescriptions ) throw (uno::RuntimeException) { - lcl_ColumnDescriptionsOperator aOperator( rColumnDescriptions ); + lcl_ColumnDescriptionsOperator aOperator( rColumnDescriptions, m_spChart2ModelContact->getChart2Document() ); applyData( aOperator ); } // ____ XComplexDescriptionAccess (write) ____ void SAL_CALL ChartDataWrapper::setComplexRowDescriptions( const Sequence< Sequence< ::rtl::OUString > >& rRowDescriptions ) throw (uno::RuntimeException) { - lcl_ComplexRowDescriptionsOperator aOperator( rRowDescriptions ); + lcl_ComplexRowDescriptionsOperator aOperator( rRowDescriptions, m_spChart2ModelContact->getChart2Document() ); applyData( aOperator ); } void SAL_CALL ChartDataWrapper::setComplexColumnDescriptions( const Sequence< Sequence< ::rtl::OUString > >& rColumnDescriptions ) throw (uno::RuntimeException) { - lcl_ComplexColumnDescriptionsOperator aOperator( rColumnDescriptions ); + lcl_ComplexColumnDescriptionsOperator aOperator( rColumnDescriptions, m_spChart2ModelContact->getChart2Document() ); + applyData( aOperator ); +} + +// ____ XAnyDescriptionAccess (write) ____ +void SAL_CALL ChartDataWrapper::setAnyRowDescriptions( const Sequence< Sequence< uno::Any > >& rRowDescriptions ) throw (uno::RuntimeException) +{ + lcl_AnyRowDescriptionsOperator aOperator( rRowDescriptions ); + applyData( aOperator ); +} +void SAL_CALL ChartDataWrapper::setAnyColumnDescriptions( const Sequence< Sequence< uno::Any > >& rColumnDescriptions ) throw (uno::RuntimeException) +{ + lcl_AnyColumnDescriptionsOperator aOperator( rColumnDescriptions ); applyData( aOperator ); } +// ____ XDateCategories (write) ____ +void SAL_CALL ChartDataWrapper::setDateCategories( const Sequence< double >& rDates ) throw (uno::RuntimeException) +{ + Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); + ControllerLockGuard aCtrlLockGuard( uno::Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY )); + lcl_DateCategoriesOperator aOperator( rDates ); + applyData( aOperator ); + DiagramHelper::switchToDateCategories( xChartDoc ); +} + //-------------------------------------------------------------------------------------- // ____ XChartData (base of XChartDataArray) ____ @@ -508,11 +678,11 @@ void ChartDataWrapper::initDataAccess() if( !xChartDoc.is() ) return; if( xChartDoc->hasInternalDataProvider() ) - m_xDataAccess = Reference< XComplexDescriptionAccess >( xChartDoc->getDataProvider(), uno::UNO_QUERY_THROW ); + m_xDataAccess = Reference< XAnyDescriptionAccess >( xChartDoc->getDataProvider(), uno::UNO_QUERY_THROW ); else { //create a separate "internal data provider" that is not connected to the model - m_xDataAccess = Reference< XComplexDescriptionAccess >( ChartModelHelper::createInternalDataProvider( + m_xDataAccess = Reference< XAnyDescriptionAccess >( ChartModelHelper::createInternalDataProvider( xChartDoc, false /*bConnectToModel*/ ), uno::UNO_QUERY_THROW ); } } @@ -569,30 +739,9 @@ void ChartDataWrapper::applyData( lcl_Operator& rDataOperator ) return; uno::Reference< chart2::data::XDataSource > xSource( xDataProvider->createDataSource( aArguments ) ); - // determine a template - uno::Reference< lang::XMultiServiceFactory > xFact( xChartDoc->getChartTypeManager(), uno::UNO_QUERY ); - uno::Reference< chart2::XDiagram > xDia( xChartDoc->getFirstDiagram()); - DiagramHelper::tTemplateWithServiceName aTemplateAndService = - DiagramHelper::getTemplateForDiagram( xDia, xFact ); - ::rtl::OUString aServiceName( aTemplateAndService.second ); - uno::Reference< chart2::XChartTypeTemplate > xTemplate = aTemplateAndService.first; - - // (fall-back) - if( ! xTemplate.is()) - { - if( aServiceName.getLength() == 0 ) - aServiceName = C2U("com.sun.star.chart2.template.Column"); - xTemplate.set( xFact->createInstance( aServiceName ), uno::UNO_QUERY ); - } - OSL_ASSERT( xTemplate.is()); - - if( xTemplate.is() && xSource.is()) - { - // argument detection works with internal knowledge of the - // ArrayDataProvider - OSL_ASSERT( xDia.is()); - xTemplate->changeDiagramData( xDia, xSource, aArguments ); - } + uno::Reference< chart2::XDiagram > xDia( xChartDoc->getFirstDiagram() ); + if( xDia.is() ) + xDia->setDiagramData( xSource, aArguments ); //correct stacking mode if( bStacked || bPercent || bDeep ) diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx index d56397953d79..16695914f892 100644..100755 --- a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx @@ -29,9 +29,10 @@ #include "ServiceMacros.hxx" #include "MutexContainer.hxx" -#include <cppuhelper/implbase4.hxx> +#include <cppuhelper/implbase5.hxx> #include <cppuhelper/interfacecontainer.hxx> -#include <com/sun/star/chart/XComplexDescriptionAccess.hpp> +#include <com/sun/star/chart2/XAnyDescriptionAccess.hpp> +#include <com/sun/star/chart/XDateCategories.hpp> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> @@ -48,8 +49,9 @@ class Chart2ModelContact; struct lcl_Operator; class ChartDataWrapper : public MutexContainer, public - ::cppu::WeakImplHelper4< - com::sun::star::chart::XComplexDescriptionAccess, + ::cppu::WeakImplHelper5< + com::sun::star::chart2::XAnyDescriptionAccess, + com::sun::star::chart::XDateCategories, com::sun::star::lang::XServiceInfo, com::sun::star::lang::XEventListener, com::sun::star::lang::XComponent > @@ -64,7 +66,25 @@ public: APPHELPER_XSERVICEINFO_DECL() protected: - // ____ XComplexDescriptionAccess ____ + // ____ XDateCategories ____ + virtual ::com::sun::star::uno::Sequence< double > SAL_CALL getDateCategories() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDateCategories( const ::com::sun::star::uno::Sequence< double >& rDates ) throw (::com::sun::star::uno::RuntimeException); + + // ____ XAnyDescriptionAccess ____ + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > > SAL_CALL + getAnyRowDescriptions() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setAnyRowDescriptions( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& aRowDescriptions ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > > SAL_CALL + getAnyColumnDescriptions() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setAnyColumnDescriptions( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& aColumnDescriptions ) + throw (::com::sun::star::uno::RuntimeException); + + // ____ XComplexDescriptionAccess (base of XAnyDescriptionAccess) ____ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL getComplexRowDescriptions() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setComplexRowDescriptions( @@ -136,7 +156,7 @@ private: //methods private: //member ::com::sun::star::uno::Reference< - ::com::sun::star::chart::XComplexDescriptionAccess > m_xDataAccess; + ::com::sun::star::chart2::XAnyDescriptionAccess > m_xDataAccess; ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; ::cppu::OInterfaceContainerHelper m_aEventListenerContainer; diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx index e8d91cd6c124..42d5667b7d82 100755 --- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx @@ -56,11 +56,9 @@ #include "WrappedAddInProperty.hxx" #include "WrappedIgnoreProperty.hxx" #include "ChartRenderer.hxx" -#include "UndoManager.hxx" #include <com/sun/star/chart2/XTitled.hpp> #include <com/sun/star/chart2/data/XDataReceiver.hpp> #include <com/sun/star/chart/ChartDataRowSource.hpp> -#include <com/sun/star/chart/XComplexDescriptionAccess.hpp> #include <comphelper/InlineContainer.hxx> // header for function SvxShapeCollection_NewInstance #include <svx/unoshcol.hxx> @@ -81,8 +79,8 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::chart; -using ::com::sun::star::chart::XComplexDescriptionAccess; using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::UNO_QUERY_THROW; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; using ::com::sun::star::beans::Property; @@ -1413,12 +1411,6 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance( xResult.set( m_xChartView ); bServiceFound = true; } - else if ( aServiceSpecifier.equals( CHART_UNDOMANAGER_SERVICE_NAME ) ) - { - Reference< chart2::XUndoManager > xUndoManager( new UndoManager() ); - xResult.set( xUndoManager ); - bServiceFound = true; - } else { // try to create a shape diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx index c174614a0bf3..e365edb7bd46 100755 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx @@ -30,14 +30,11 @@ #include "DiagramWrapper.hxx" #include "macros.hxx" #include "servicenames_charttypes.hxx" -#include "TitleWrapper.hxx" #include "DataSeriesPointWrapper.hxx" #include "AxisWrapper.hxx" #include "AxisHelper.hxx" #include "Chart2ModelContact.hxx" #include "PositionAndSizeHelper.hxx" -#include "TitleHelper.hxx" -#include "GridWrapper.hxx" #include "WallFloorWrapper.hxx" #include "MinMaxLineWrapper.hxx" #include "UpDownBarWrapper.hxx" @@ -88,6 +85,7 @@ using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Sequence; using ::com::sun::star::beans::Property; +using ::com::sun::star::chart::XAxis; using ::osl::MutexGuard; using ::rtl::OUString; @@ -884,193 +882,209 @@ void SAL_CALL DiagramWrapper::setDiagramPositionIncludingAxesAndAxisTitles( cons return m_spChart2ModelContact->GetDiagramRectangleIncludingTitle(); } -// ____ XAxisZSupplier ____ -Reference< - drawing::XShape > SAL_CALL DiagramWrapper::getZAxisTitle() +// ____ XAxisSupplier ____ +Reference< XAxis > SAL_CALL DiagramWrapper::getAxis( sal_Int32 nDimensionIndex ) throw (uno::RuntimeException) { - if( !m_xZAxisTitle.is() ) + Reference< XAxis > xAxis; + if(!nDimensionIndex) + { + if( !m_xXAxis.is() ) + m_xXAxis = new AxisWrapper( AxisWrapper::X_AXIS, m_spChart2ModelContact ); + xAxis = m_xXAxis; + } + else if(1==nDimensionIndex) + { + if( !m_xYAxis.is() ) + m_xYAxis = new AxisWrapper( AxisWrapper::Y_AXIS, m_spChart2ModelContact ); + xAxis = m_xYAxis; + } + else if(2==nDimensionIndex) { - m_xZAxisTitle = new TitleWrapper( TitleHelper::Z_AXIS_TITLE, m_spChart2ModelContact ); + if( !m_xZAxis.is() ) + m_xZAxis = new AxisWrapper( AxisWrapper::Z_AXIS, m_spChart2ModelContact ); + xAxis = m_xZAxis; } - return m_xZAxisTitle; + return xAxis; } -Reference< - beans::XPropertySet > SAL_CALL DiagramWrapper::getZMainGrid() +Reference< XAxis > SAL_CALL DiagramWrapper::getSecondaryAxis( sal_Int32 nDimensionIndex ) throw (uno::RuntimeException) { - if( ! m_xZMainGrid.is()) + Reference< XAxis > xAxis; + if(!nDimensionIndex) { - m_xZMainGrid = new GridWrapper( GridWrapper::Z_MAIN_GRID, m_spChart2ModelContact ); + if( !m_xSecondXAxis.is() ) + m_xSecondXAxis = new AxisWrapper( AxisWrapper::SECOND_X_AXIS, m_spChart2ModelContact ); + xAxis = m_xSecondXAxis; } - return m_xZMainGrid; + else if(1==nDimensionIndex) + { + if( !m_xSecondYAxis.is() ) + m_xSecondYAxis = new AxisWrapper( AxisWrapper::SECOND_Y_AXIS, m_spChart2ModelContact ); + xAxis = m_xSecondYAxis; + } + return xAxis; } -Reference< - beans::XPropertySet > SAL_CALL DiagramWrapper::getZHelpGrid() +// ____ XAxisZSupplier ____ +Reference< drawing::XShape > SAL_CALL DiagramWrapper::getZAxisTitle() throw (uno::RuntimeException) { - if( !m_xZHelpGrid.is() ) - { - m_xZHelpGrid = new GridWrapper( GridWrapper::Z_SUB_GRID, m_spChart2ModelContact ); - } - return m_xZHelpGrid; + Reference< drawing::XShape > xRet; + Reference< XAxis > xAxis( getAxis(2) ); + if( xAxis.is() ) + xRet = Reference< drawing::XShape >( xAxis->getAxisTitle(), uno::UNO_QUERY ); + return xRet; } -Reference< - beans::XPropertySet > SAL_CALL DiagramWrapper::getZAxis() +Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getZMainGrid() + throw (uno::RuntimeException) +{ + Reference< beans::XPropertySet > xRet; + Reference< XAxis > xAxis( getAxis(2) ); + if( xAxis.is() ) + xRet = xAxis->getMajorGrid(); + return xRet; +} + +Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getZHelpGrid() + throw (uno::RuntimeException) +{ + Reference< beans::XPropertySet > xRet; + Reference< XAxis > xAxis( getAxis(2) ); + if( xAxis.is() ) + xRet = xAxis->getMinorGrid(); + return xRet; +} + +Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getZAxis() throw (uno::RuntimeException) { if( ! m_xZAxis.is()) - { m_xZAxis = new AxisWrapper( AxisWrapper::Z_AXIS, m_spChart2ModelContact ); - } - return m_xZAxis; + return Reference< beans::XPropertySet >( m_xZAxis, uno::UNO_QUERY ); } // ____ XTwoAxisXSupplier ____ -Reference< - beans::XPropertySet > SAL_CALL DiagramWrapper::getSecondaryXAxis() +Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getSecondaryXAxis() throw (uno::RuntimeException) { if( ! m_xSecondXAxis.is()) - { m_xSecondXAxis = new AxisWrapper( AxisWrapper::SECOND_X_AXIS, m_spChart2ModelContact ); - } - return m_xSecondXAxis; + return Reference< beans::XPropertySet >( m_xSecondXAxis, uno::UNO_QUERY ); } // ____ XAxisXSupplier (base of XTwoAxisXSupplier) ____ -Reference< - drawing::XShape > SAL_CALL DiagramWrapper::getXAxisTitle() +Reference< drawing::XShape > SAL_CALL DiagramWrapper::getXAxisTitle() throw (uno::RuntimeException) { - - if( !m_xXAxisTitle.is() ) - { - m_xXAxisTitle = new TitleWrapper( TitleHelper::X_AXIS_TITLE, m_spChart2ModelContact ); - } - return m_xXAxisTitle; + Reference< drawing::XShape > xRet; + Reference< XAxis > xAxis( getAxis(0) ); + if( xAxis.is() ) + xRet = Reference< drawing::XShape >( xAxis->getAxisTitle(), uno::UNO_QUERY ); + return xRet; } -Reference< - beans::XPropertySet > SAL_CALL DiagramWrapper::getXAxis() +Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getXAxis() throw (uno::RuntimeException) { if( ! m_xXAxis.is()) - { m_xXAxis = new AxisWrapper( AxisWrapper::X_AXIS, m_spChart2ModelContact ); - } - - return m_xXAxis; + return Reference< beans::XPropertySet >( m_xXAxis, uno::UNO_QUERY ); } -Reference< - beans::XPropertySet > SAL_CALL DiagramWrapper::getXMainGrid() +Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getXMainGrid() throw (uno::RuntimeException) { - if( ! m_xXMainGrid.is()) - { - m_xXMainGrid = new GridWrapper( GridWrapper::X_MAIN_GRID, m_spChart2ModelContact ); - } - - return m_xXMainGrid; + Reference< beans::XPropertySet > xRet; + Reference< XAxis > xAxis( getAxis(0) ); + if( xAxis.is() ) + xRet = xAxis->getMajorGrid(); + return xRet; } -Reference< - beans::XPropertySet > SAL_CALL DiagramWrapper::getXHelpGrid() +Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getXHelpGrid() throw (uno::RuntimeException) { - if( ! m_xXHelpGrid.is()) - { - m_xXHelpGrid = new GridWrapper( GridWrapper::X_SUB_GRID, m_spChart2ModelContact ); - } - return m_xXHelpGrid; + Reference< beans::XPropertySet > xRet; + Reference< XAxis > xAxis( getAxis(0) ); + if( xAxis.is() ) + xRet = xAxis->getMinorGrid(); + return xRet; } // ____ XTwoAxisYSupplier ____ -Reference< - beans::XPropertySet > SAL_CALL DiagramWrapper::getSecondaryYAxis() +Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getSecondaryYAxis() throw (uno::RuntimeException) { if( ! m_xSecondYAxis.is()) - { m_xSecondYAxis = new AxisWrapper( AxisWrapper::SECOND_Y_AXIS, m_spChart2ModelContact ); - } - return m_xSecondYAxis; + return Reference< beans::XPropertySet >( m_xSecondYAxis, uno::UNO_QUERY ); } // ____ XAxisYSupplier (base of XTwoAxisYSupplier) ____ -Reference< - drawing::XShape > SAL_CALL DiagramWrapper::getYAxisTitle() +Reference< drawing::XShape > SAL_CALL DiagramWrapper::getYAxisTitle() throw (uno::RuntimeException) { - if( !m_xYAxisTitle.is() ) - { - m_xYAxisTitle = new TitleWrapper( TitleHelper::Y_AXIS_TITLE, m_spChart2ModelContact ); - } - return m_xYAxisTitle; + Reference< drawing::XShape > xRet; + Reference< XAxis > xAxis( getAxis(1) ); + if( xAxis.is() ) + xRet = Reference< drawing::XShape >( xAxis->getAxisTitle(), uno::UNO_QUERY ); + return xRet; } -Reference< - beans::XPropertySet > SAL_CALL DiagramWrapper::getYAxis() +Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getYAxis() throw (uno::RuntimeException) { if( ! m_xYAxis.is()) - { m_xYAxis = new AxisWrapper( AxisWrapper::Y_AXIS, m_spChart2ModelContact ); - } - return m_xYAxis; + return Reference< beans::XPropertySet >( m_xYAxis, uno::UNO_QUERY ); } -Reference< - beans::XPropertySet > SAL_CALL DiagramWrapper::getYHelpGrid() +Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getYMainGrid() throw (uno::RuntimeException) { - if( ! m_xYHelpGrid.is()) - { - m_xYHelpGrid = new GridWrapper( GridWrapper::Y_SUB_GRID, m_spChart2ModelContact ); - } - return m_xYHelpGrid; + Reference< beans::XPropertySet > xRet; + Reference< XAxis > xAxis( getAxis(1) ); + if( xAxis.is() ) + xRet = xAxis->getMajorGrid(); + return xRet; } -Reference< - beans::XPropertySet > SAL_CALL DiagramWrapper::getYMainGrid() +Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getYHelpGrid() throw (uno::RuntimeException) { - if( ! m_xYMainGrid.is()) - { - m_xYMainGrid = new GridWrapper( GridWrapper::Y_MAIN_GRID, m_spChart2ModelContact ); - } - return m_xYMainGrid; + Reference< beans::XPropertySet > xRet; + Reference< XAxis > xAxis( getAxis(1) ); + if( xAxis.is() ) + xRet = xAxis->getMinorGrid(); + return xRet; } // ____ XSecondAxisTitleSupplier ____ -Reference< - drawing::XShape > SAL_CALL DiagramWrapper::getSecondXAxisTitle() +Reference< drawing::XShape > SAL_CALL DiagramWrapper::getSecondXAxisTitle() throw (uno::RuntimeException) { - if( !m_xSecondXAxisTitle.is() ) - { - m_xSecondXAxisTitle = new TitleWrapper( TitleHelper::SECONDARY_X_AXIS_TITLE, m_spChart2ModelContact ); - } - return m_xSecondXAxisTitle; + Reference< drawing::XShape > xRet; + Reference< XAxis > xAxis( getSecondaryAxis(0) ); + if( xAxis.is() ) + xRet = Reference< drawing::XShape >( xAxis->getAxisTitle(), uno::UNO_QUERY ); + return xRet; } -Reference< - drawing::XShape > SAL_CALL DiagramWrapper::getSecondYAxisTitle() +Reference< drawing::XShape > SAL_CALL DiagramWrapper::getSecondYAxisTitle() throw (uno::RuntimeException) { - if( !m_xSecondYAxisTitle.is() ) - { - m_xSecondYAxisTitle = new TitleWrapper( TitleHelper::SECONDARY_Y_AXIS_TITLE, m_spChart2ModelContact ); - } - return m_xSecondYAxisTitle; + Reference< drawing::XShape > xRet; + Reference< XAxis > xAxis( getSecondaryAxis(1) ); + if( xAxis.is() ) + xRet = Reference< drawing::XShape >( xAxis->getAxisTitle(), uno::UNO_QUERY ); + return xRet; } // ____ XStatisticDisplay ____ @@ -1163,22 +1177,11 @@ void SAL_CALL DiagramWrapper::dispose() // /-- MutexGuard aGuard( GetMutex()); - DisposeHelper::DisposeAndClear( m_xXAxisTitle ); - DisposeHelper::DisposeAndClear( m_xYAxisTitle ); - DisposeHelper::DisposeAndClear( m_xZAxisTitle ); - DisposeHelper::DisposeAndClear( m_xSecondXAxisTitle ); - DisposeHelper::DisposeAndClear( m_xSecondYAxisTitle ); DisposeHelper::DisposeAndClear( m_xXAxis ); DisposeHelper::DisposeAndClear( m_xYAxis ); DisposeHelper::DisposeAndClear( m_xZAxis ); DisposeHelper::DisposeAndClear( m_xSecondXAxis ); DisposeHelper::DisposeAndClear( m_xSecondYAxis ); - DisposeHelper::DisposeAndClear( m_xXMainGrid ); - DisposeHelper::DisposeAndClear( m_xYMainGrid ); - DisposeHelper::DisposeAndClear( m_xZMainGrid ); - DisposeHelper::DisposeAndClear( m_xXHelpGrid ); - DisposeHelper::DisposeAndClear( m_xYHelpGrid ); - DisposeHelper::DisposeAndClear( m_xZHelpGrid ); DisposeHelper::DisposeAndClear( m_xWall ); DisposeHelper::DisposeAndClear( m_xFloor ); DisposeHelper::DisposeAndClear( m_xMinMaxLineWrapper ); @@ -2147,3 +2150,4 @@ APPHELPER_XSERVICEINFO_IMPL( DiagramWrapper, lcl_aServiceName ); } // namespace wrapper } // namespace chart + diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx index 111e24bd6a8b..678041420cf3 100644..100755 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx @@ -30,7 +30,13 @@ #include "WrappedPropertySet.hxx" #include "ServiceMacros.hxx" #include "DiagramHelper.hxx" -#include <cppuhelper/implbase12.hxx> + +#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_13) +#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_13 +#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 13 +#include "comphelper/implbase_var.hxx" +#endif + #include <comphelper/uno3.hxx> #include <cppuhelper/interfacecontainer.hxx> #include <com/sun/star/chart2/XChartDocument.hpp> @@ -41,6 +47,7 @@ #include <com/sun/star/chart2/XChartTypeTemplate.hpp> #include <com/sun/star/chart2/XChartTypeManager.hpp> #include <com/sun/star/chart/XDiagram.hpp> +#include <com/sun/star/chart/XAxisSupplier.hpp> #include <com/sun/star/chart/XAxisZSupplier.hpp> #include <com/sun/star/chart/XTwoAxisXSupplier.hpp> #include <com/sun/star/chart/XTwoAxisYSupplier.hpp> @@ -56,15 +63,15 @@ namespace chart { - namespace wrapper { class Chart2ModelContact; -class DiagramWrapper : public ::cppu::ImplInheritanceHelper12< +class DiagramWrapper : public ::comphelper::ImplInheritanceHelper13< WrappedPropertySet , ::com::sun::star::chart::XDiagram + , ::com::sun::star::chart::XAxisSupplier , ::com::sun::star::chart::XAxisZSupplier , ::com::sun::star::chart::XTwoAxisXSupplier // : XAxisXSupplier , ::com::sun::star::chart::XTwoAxisYSupplier // : XAxisYSupplier @@ -123,6 +130,14 @@ public: virtual ::rtl::OUString SAL_CALL getShapeType() throw (::com::sun::star::uno::RuntimeException); + // ____ XAxisSupplier ____ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::chart::XAxis > SAL_CALL getAxis( sal_Int32 nDimensionIndex ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::chart::XAxis > SAL_CALL getSecondaryAxis( sal_Int32 nDimensionIndex ) + throw (::com::sun::star::uno::RuntimeException); + // ____ XAxisZSupplier ____ virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > SAL_CALL getZAxisTitle() @@ -244,72 +259,27 @@ private: ::cppu::OInterfaceContainerHelper m_aEventListenerContainer; ::com::sun::star::uno::Reference< - ::com::sun::star::drawing::XShape > - m_xXAxisTitle; - ::com::sun::star::uno::Reference< - ::com::sun::star::drawing::XShape > - m_xYAxisTitle; - ::com::sun::star::uno::Reference< - ::com::sun::star::drawing::XShape > - m_xZAxisTitle; - ::com::sun::star::uno::Reference< - ::com::sun::star::drawing::XShape > - m_xSecondXAxisTitle; - ::com::sun::star::uno::Reference< - ::com::sun::star::drawing::XShape > - m_xSecondYAxisTitle; - - ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xXAxis; - ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xYAxis; - ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xZAxis; - ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xSecondXAxis; - ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xSecondYAxis; - - ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xXMainGrid; - ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xYMainGrid; + ::com::sun::star::chart::XAxis > m_xXAxis; ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xZMainGrid; + ::com::sun::star::chart::XAxis > m_xYAxis; ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xXHelpGrid; + ::com::sun::star::chart::XAxis > m_xZAxis; ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xYHelpGrid; + ::com::sun::star::chart::XAxis > m_xSecondXAxis; ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xZHelpGrid; + ::com::sun::star::chart::XAxis > m_xSecondYAxis; ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xWall; + ::com::sun::star::beans::XPropertySet > m_xWall; ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xFloor; + ::com::sun::star::beans::XPropertySet > m_xFloor; ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xMinMaxLineWrapper; + ::com::sun::star::beans::XPropertySet > m_xMinMaxLineWrapper; ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xUpBarWrapper; + ::com::sun::star::beans::XPropertySet > m_xUpBarWrapper; ::com::sun::star::uno::Reference< - ::com::sun::star::beans::XPropertySet > - m_xDownBarWrapper; + ::com::sun::star::beans::XPropertySet > m_xDownBarWrapper; }; } // namespace wrapper diff --git a/chart2/source/controller/chartapiwrapper/GridWrapper.cxx b/chart2/source/controller/chartapiwrapper/GridWrapper.cxx index 6586511424db..51c269d7dd40 100755 --- a/chart2/source/controller/chartapiwrapper/GridWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/GridWrapper.cxx @@ -112,17 +112,17 @@ void GridWrapper::getDimensionAndSubGridBool( tGridType eType, sal_Int32& rnDime switch( eType ) { - case X_MAIN_GRID: + case X_MAJOR_GRID: rnDimensionIndex = 0; rbSubGrid = false; break; - case Y_MAIN_GRID: + case Y_MAJOR_GRID: rnDimensionIndex = 1; rbSubGrid = false; break; - case Z_MAIN_GRID: + case Z_MAJOR_GRID: rnDimensionIndex = 2; rbSubGrid = false; break; - case X_SUB_GRID: + case X_MINOR_GRID: rnDimensionIndex = 0; rbSubGrid = true; break; - case Y_SUB_GRID: + case Y_MINOR_GRID: rnDimensionIndex = 1; rbSubGrid = true; break; - case Z_SUB_GRID: + case Z_MINOR_GRID: rnDimensionIndex = 2; rbSubGrid = true; break; } } @@ -209,3 +209,4 @@ APPHELPER_XSERVICEINFO_IMPL( GridWrapper, lcl_aServiceName ); } // namespace wrapper } // namespace chart + diff --git a/chart2/source/controller/chartapiwrapper/GridWrapper.hxx b/chart2/source/controller/chartapiwrapper/GridWrapper.hxx index c731b6c22666..653c46353676 100644..100755 --- a/chart2/source/controller/chartapiwrapper/GridWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/GridWrapper.hxx @@ -42,7 +42,6 @@ namespace chart { - namespace wrapper { @@ -57,12 +56,12 @@ class GridWrapper : public ::cppu::ImplInheritanceHelper2< public: enum tGridType { - X_MAIN_GRID, - Y_MAIN_GRID, - Z_MAIN_GRID, - X_SUB_GRID, - Y_SUB_GRID, - Z_SUB_GRID + X_MAJOR_GRID, + Y_MAJOR_GRID, + Z_MAJOR_GRID, + X_MINOR_GRID, + Y_MINOR_GRID, + Z_MINOR_GRID }; GridWrapper( tGridType eType, ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx index a89ca372d9ee..64773ad062f9 100755 --- a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx @@ -33,9 +33,8 @@ #include "CommonConverters.hxx" #include "AxisHelper.hxx" #include <com/sun/star/chart2/XAxis.hpp> -#include <com/sun/star/chart2/ExplicitIncrementData.hpp> -#include <com/sun/star/chart2/ExplicitScaleData.hpp> -#include <com/sun/star/chart2/AxisOrientation.hpp> +#include <com/sun/star/chart/ChartAxisType.hpp> +#include <chartview/ExplicitScaleValues.hxx> using namespace ::com::sun::star; using ::com::sun::star::uno::Any; @@ -43,6 +42,7 @@ using namespace ::com::sun::star::chart2; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; using ::rtl::OUString; +using ::com::sun::star::chart::TimeIncrement; //............................................................................. namespace chart @@ -91,6 +91,15 @@ WrappedScaleProperty::WrappedScaleProperty( tScaleProperty eScaleProperty case SCALE_PROP_AUTO_STEPHELP: m_aOuterName = C2U("AutoStepHelp"); break; + case SCALE_PROP_AXIS_TYPE: + m_aOuterName = C2U("AxisType"); + break; + case SCALE_PROP_DATE_INCREMENT: + m_aOuterName = C2U("TimeIncrement"); + break; + case SCALE_PROP_EXPLICIT_DATE_INCREMENT: + m_aOuterName = C2U("ExplicitTimeIncrement"); + break; case SCALE_PROP_LOGARITHMIC: m_aOuterName = C2U("Logarithmic"); break; @@ -121,6 +130,9 @@ void WrappedScaleProperty::addWrappedProperties( std::vector< WrappedProperty* > rList.push_back( new WrappedScaleProperty( SCALE_PROP_AUTO_ORIGIN, spChart2ModelContact ) ); rList.push_back( new WrappedScaleProperty( SCALE_PROP_AUTO_STEPMAIN, spChart2ModelContact ) ); rList.push_back( new WrappedScaleProperty( SCALE_PROP_AUTO_STEPHELP, spChart2ModelContact ) ); + rList.push_back( new WrappedScaleProperty( SCALE_PROP_AXIS_TYPE, spChart2ModelContact ) ); + rList.push_back( new WrappedScaleProperty( SCALE_PROP_DATE_INCREMENT, spChart2ModelContact ) ); + rList.push_back( new WrappedScaleProperty( SCALE_PROP_EXPLICIT_DATE_INCREMENT, spChart2ModelContact ) ); rList.push_back( new WrappedScaleProperty( SCALE_PROP_LOGARITHMIC, spChart2ModelContact ) ); rList.push_back( new WrappedScaleProperty( SCALE_PROP_REVERSEDIRECTION, spChart2ModelContact ) ); } @@ -265,6 +277,43 @@ void WrappedScaleProperty::setPropertyValue( tScaleProperty eScaleProperty, cons bSetScaleData = true; break; } + case SCALE_PROP_AXIS_TYPE: + { + sal_Int32 nType = 0; + if( (rOuterValue >>= nType) ) + { + if( ::com::sun::star::chart::ChartAxisType::AUTOMATIC == nType ) + { + aScaleData.AutoDateAxis = true; + if( aScaleData.AxisType == AxisType::DATE ) + aScaleData.AxisType = AxisType::CATEGORY; + } + else if( ::com::sun::star::chart::ChartAxisType::CATEGORY == nType ) + { + aScaleData.AutoDateAxis = false; + if( aScaleData.AxisType == AxisType::DATE ) + aScaleData.AxisType = AxisType::CATEGORY; + } + else if( ::com::sun::star::chart::ChartAxisType::DATE == nType ) + { + if( aScaleData.AxisType == AxisType::CATEGORY ) + aScaleData.AxisType = AxisType::DATE; + } + bSetScaleData = true; + } + break; + } + case SCALE_PROP_DATE_INCREMENT: + { + TimeIncrement aTimeIncrement; + rOuterValue >>= aTimeIncrement; + aScaleData.TimeIncrement = aTimeIncrement; + bSetScaleData = true; + break; + } + case SCALE_PROP_EXPLICIT_DATE_INCREMENT: + //read only property + break; case SCALE_PROP_LOGARITHMIC: { if( rOuterValue >>= bBool ) @@ -319,8 +368,8 @@ Any WrappedScaleProperty::getPropertyValue( tScaleProperty eScaleProperty, const chart2::ScaleData aScaleData( xAxis->getScaleData() ); - chart2::ExplicitScaleData aExplicitScale; - chart2::ExplicitIncrementData aExplicitIncrement; + ExplicitScaleData aExplicitScale; + ExplicitIncrementData aExplicitIncrement; switch( eScaleProperty ) { @@ -400,7 +449,8 @@ Any WrappedScaleProperty::getPropertyValue( tScaleProperty eScaleProperty, const { m_spChart2ModelContact->getExplicitValuesForAxis( xAxis, aExplicitScale, aExplicitIncrement ); - if( aExplicitIncrement.SubIncrements.getLength() > 0 && + + if( !aExplicitIncrement.SubIncrements.empty() && aExplicitIncrement.SubIncrements[ 0 ].IntervalCount > 0 ) { if( bLogarithmic ) @@ -439,7 +489,7 @@ Any WrappedScaleProperty::getPropertyValue( tScaleProperty eScaleProperty, const if( bNeedToCalculateExplicitValues ) { m_spChart2ModelContact->getExplicitValuesForAxis( xAxis, aExplicitScale, aExplicitIncrement ); - if( aExplicitIncrement.SubIncrements.getLength() > 0 ) + if( !aExplicitIncrement.SubIncrements.empty() ) nIntervalCount = aExplicitIncrement.SubIncrements[ 0 ].IntervalCount; } aRet = uno::makeAny( nIntervalCount ); @@ -485,6 +535,46 @@ Any WrappedScaleProperty::getPropertyValue( tScaleProperty eScaleProperty, const aRet <<= !hasDoubleValue(aScaleData.Origin); break; } + case SCALE_PROP_AXIS_TYPE: + { + sal_Int32 nType = ::com::sun::star::chart::ChartAxisType::AUTOMATIC; + if( aScaleData.AxisType == AxisType::DATE ) + { + nType = ::com::sun::star::chart::ChartAxisType::DATE; + } + else if( aScaleData.AxisType == AxisType::CATEGORY ) + { + if( !aScaleData.AutoDateAxis ) + nType = ::com::sun::star::chart::ChartAxisType::CATEGORY; + } + aRet = uno::makeAny( nType ); + break; + } + case SCALE_PROP_DATE_INCREMENT: + { + if( aScaleData.AxisType == AxisType::DATE || aScaleData.AutoDateAxis ) + aRet = uno::makeAny( aScaleData.TimeIncrement ); + break; + } + case SCALE_PROP_EXPLICIT_DATE_INCREMENT: + { + if( aScaleData.AxisType == AxisType::DATE || aScaleData.AutoDateAxis ) + { + m_spChart2ModelContact->getExplicitValuesForAxis( xAxis, aExplicitScale, aExplicitIncrement ); + if( aExplicitScale.AxisType == AxisType::DATE ) + { + TimeIncrement aTimeIncrement; + aTimeIncrement.MajorTimeInterval = uno::makeAny( aExplicitIncrement.MajorTimeInterval ); + aTimeIncrement.MinorTimeInterval = uno::makeAny( aExplicitIncrement.MinorTimeInterval ); + aTimeIncrement.TimeResolution = uno::makeAny( aExplicitScale.TimeResolution ); + aRet = uno::makeAny(aTimeIncrement); + } + } + + if( aScaleData.AxisType == AxisType::DATE || aScaleData.AutoDateAxis ) + aRet = uno::makeAny( aScaleData.TimeIncrement ); + break; + } case SCALE_PROP_LOGARITHMIC: { aRet <<= static_cast< sal_Bool >( AxisHelper::isLogarithmic(aScaleData.Scaling) ); @@ -506,5 +596,5 @@ Any WrappedScaleProperty::getPropertyValue( tScaleProperty eScaleProperty, const } } // namespace wrapper -} //namespace chart +} // namespace chart //............................................................................. diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx index 4d29bc009777..8df55339a46e 100644..100755 --- a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx +++ b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx @@ -55,6 +55,9 @@ public: , SCALE_PROP_AUTO_ORIGIN , SCALE_PROP_AUTO_STEPMAIN , SCALE_PROP_AUTO_STEPHELP + , SCALE_PROP_AXIS_TYPE + , SCALE_PROP_DATE_INCREMENT + , SCALE_PROP_EXPLICIT_DATE_INCREMENT , SCALE_PROP_LOGARITHMIC , SCALE_PROP_REVERSEDIRECTION }; diff --git a/chart2/source/controller/dialogs/DataBrowser.cxx b/chart2/source/controller/dialogs/DataBrowser.cxx index fedcfaffebc4..c4c2ba8bdcd8 100644 --- a/chart2/source/controller/dialogs/DataBrowser.cxx +++ b/chart2/source/controller/dialogs/DataBrowser.cxx @@ -47,7 +47,7 @@ #include "ChartModelHelper.hxx" #include "CommonConverters.hxx" #include "macros.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include "servicenames_charttypes.hxx" #include "ResId.hxx" #include "Bitmaps.hrc" @@ -64,6 +64,7 @@ #include <com/sun/star/chart2/XChartType.hpp> #include <com/sun/star/container/XIndexReplace.hpp> +#include <com/sun/star/util/XNumberFormats.hpp> #include <algorithm> #include <functional> @@ -696,6 +697,23 @@ String DataBrowser::GetCellText( long nRow, USHORT nColumnId ) const GetNumberFormatKey( nRow, nColumnId ), fData, nLabelColor, bColorChanged )); } + else if( m_apDataBrowserModel->getCellType( nColIndex, nRow ) == DataBrowserModel::TEXTORDATE ) + { + uno::Any aAny = m_apDataBrowserModel->getCellAny( nColIndex, nRow ); + OUString aText; + double fDouble=0.0; + if( aAny>>=aText ) + aResult = aText; + else if( aAny>>=fDouble ) + { + sal_Int32 nLabelColor; + bool bColorChanged = false; + sal_Int32 nDateNumberFormat = DiagramHelper::getDateNumberFormat( Reference< util::XNumberFormatsSupplier >( m_xChartDoc, uno::UNO_QUERY) ); + if( ! ::rtl::math::isNan( fDouble ) && m_spNumberFormatterWrapper.get() ) + aResult = String( m_spNumberFormatterWrapper->getFormattedString( + nDateNumberFormat, fDouble, nLabelColor, bColorChanged )); + } + } else { OSL_ASSERT( m_apDataBrowserModel->getCellType( nColIndex, nRow ) == DataBrowserModel::TEXT ); @@ -854,6 +872,9 @@ void DataBrowser::SetDataFromModel( new NumberFormatterWrapper( Reference< util::XNumberFormatsSupplier >( m_xChartDoc, uno::UNO_QUERY ))); + if( m_spNumberFormatterWrapper.get() ) + m_aNumberEditField.SetFormatter( m_spNumberFormatterWrapper->getSvNumberFormatter() ); + RenewTable(); const sal_Int32 nColCnt = m_apDataBrowserModel->getColumnCount(); @@ -1134,6 +1155,22 @@ sal_uInt32 DataBrowser::GetNumberFormatKey( sal_Int32 nRow, sal_uInt16 nCol ) co return m_apDataBrowserModel->getNumberFormatKey( lcl_getColumnInData( nCol ), lcl_getRowInData( nRow )); } +bool DataBrowser::isDateString( rtl::OUString aInputString, double& fOutDateValue ) +{ + sal_uInt32 nNumberFormat=0; + SvNumberFormatter* pSvNumberFormatter = m_spNumberFormatterWrapper.get() ? m_spNumberFormatterWrapper->getSvNumberFormatter() : 0; + if( aInputString.getLength() > 0 && pSvNumberFormatter && pSvNumberFormatter->IsNumberFormat( aInputString, nNumberFormat, fOutDateValue ) ) + { + Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( m_xChartDoc, uno::UNO_QUERY ); + Reference< util::XNumberFormats > xNumberFormats; + if( xNumberFormatsSupplier.is() ) + xNumberFormats = Reference< util::XNumberFormats >( xNumberFormatsSupplier->getNumberFormats() ); + if( DiagramHelper::isDateNumberFormat( nNumberFormat, xNumberFormats ) ) + return true; + } + return false; +} + sal_Bool DataBrowser::SaveModified() { if( ! IsModified() ) @@ -1146,6 +1183,7 @@ sal_Bool DataBrowser::SaveModified() DBG_ASSERT( nRow >= 0 || nCol >= 0, "This cell should not be modified!" ); + SvNumberFormatter* pSvNumberFormatter = m_spNumberFormatterWrapper.get() ? m_spNumberFormatterWrapper->getSvNumberFormatter() : 0; switch( m_apDataBrowserModel->getCellType( nCol, nRow )) { case DataBrowserModel::NUMBER: @@ -1155,11 +1193,8 @@ sal_Bool DataBrowser::SaveModified() String aText( m_aNumberEditField.GetText()); // an empty string is valid, if no numberformatter exists, all // values are treated as valid - if( aText.Len() > 0 && - m_spNumberFormatterWrapper.get() && - m_spNumberFormatterWrapper->getSvNumberFormatter() && - ! m_spNumberFormatterWrapper->getSvNumberFormatter()->IsNumberFormat( - aText, nDummy, fDummy )) + if( aText.Len() > 0 && pSvNumberFormatter && + ! pSvNumberFormatter->IsNumberFormat( aText, nDummy, fDummy ) ) { bChangeValid = sal_False; } @@ -1170,6 +1205,17 @@ sal_Bool DataBrowser::SaveModified() } } break; + case DataBrowserModel::TEXTORDATE: + { + OUString aText( m_aTextEditField.GetText() ); + double fDateValue=0.0; + bChangeValid = sal_False; + if( isDateString( aText, fDateValue ) ) + bChangeValid = m_apDataBrowserModel->setCellAny( nCol, nRow, uno::makeAny( fDateValue ) ); + if(!bChangeValid) + bChangeValid = m_apDataBrowserModel->setCellAny( nCol, nRow, uno::makeAny( aText ) ); + } + break; case DataBrowserModel::TEXT: { OUString aText( m_aTextEditField.GetText()); diff --git a/chart2/source/controller/dialogs/DataBrowser.hxx b/chart2/source/controller/dialogs/DataBrowser.hxx index 3583db2770c0..b5cd2a731f7b 100644 --- a/chart2/source/controller/dialogs/DataBrowser.hxx +++ b/chart2/source/controller/dialogs/DataBrowser.hxx @@ -93,6 +93,8 @@ public: */ double GetCellNumber( long nRow, USHORT nColumnId ) const; + bool isDateString( rtl::OUString aInputString, double& fOutDateValue ); + // Window virtual void Resize(); diff --git a/chart2/source/controller/dialogs/DataBrowserModel.cxx b/chart2/source/controller/dialogs/DataBrowserModel.cxx index c0b865536686..23fda0f472af 100644 --- a/chart2/source/controller/dialogs/DataBrowserModel.cxx +++ b/chart2/source/controller/dialogs/DataBrowserModel.cxx @@ -43,6 +43,7 @@ #include "ExplicitCategoriesProvider.hxx" #include <com/sun/star/container/XIndexReplace.hpp> +#include <com/sun/star/chart2/XAxis.hpp> #include <com/sun/star/chart2/XDataSeriesContainer.hpp> #include <com/sun/star/chart2/XInternalDataProvider.hpp> #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> @@ -589,7 +590,7 @@ Reference< chart2::XDataSeries > return 0; } -DataBrowserModel::eCellType DataBrowserModel::getCellType( sal_Int32 nAtColumn, sal_Int32 /* nAtRow */ ) +DataBrowserModel::eCellType DataBrowserModel::getCellType( sal_Int32 nAtColumn, sal_Int32 /* nAtRow */ ) const { eCellType eResult = TEXT; tDataColumnVector::size_type nIndex( nAtColumn ); @@ -619,6 +620,26 @@ double DataBrowserModel::getCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow ) return fResult; } +uno::Any DataBrowserModel::getCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow ) +{ + uno::Any aResult; + + tDataColumnVector::size_type nIndex( nAtColumn ); + if( nIndex < m_aColumns.size() && + m_aColumns[ nIndex ].m_xLabeledDataSequence.is()) + { + Reference< chart2::data::XDataSequence > xData( + m_aColumns[ nIndex ].m_xLabeledDataSequence->getValues() ); + if( xData.is() ) + { + Sequence< uno::Any > aValues( xData->getData()); + if( nAtRow < aValues.getLength()) + aResult = aValues[nAtRow]; + } + } + return aResult; +} + OUString DataBrowserModel::getCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow ) { OUString aResult; @@ -800,7 +821,7 @@ void DataBrowserModel::updateFromModel() aCategories.m_aUIRoleName = DialogModel::GetRoleDataLabel(); else aCategories.m_aUIRoleName = lcl_getUIRoleName( xCategories ); - aCategories.m_eCellType = TEXT; + aCategories.m_eCellType = TEXTORDATE; m_aColumns.push_back( aCategories ); ++nHeaderStart; } diff --git a/chart2/source/controller/dialogs/DataBrowserModel.hxx b/chart2/source/controller/dialogs/DataBrowserModel.hxx index a4378972f70f..bde29f1771e4 100644 --- a/chart2/source/controller/dialogs/DataBrowserModel.hxx +++ b/chart2/source/controller/dialogs/DataBrowserModel.hxx @@ -81,13 +81,15 @@ public: enum eCellType { NUMBER, - TEXT + TEXT, + TEXTORDATE }; - eCellType getCellType( sal_Int32 nAtColumn, sal_Int32 nAtRow ); + eCellType getCellType( sal_Int32 nAtColumn, sal_Int32 nAtRow ) const; /// If getCellType( nAtColumn, nAtRow ) returns TEXT, the result will be Nan double getCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow ); ::rtl::OUString getCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow ); + ::com::sun::star::uno::Any getCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow ); sal_uInt32 getNumberFormatKey( sal_Int32 nAtColumn, sal_Int32 nAtRow ); /// returns </TRUE> if the number could successfully be set at the given position diff --git a/chart2/source/controller/dialogs/DialogModel.cxx b/chart2/source/controller/dialogs/DialogModel.cxx index eedd2e3c6ba9..6e145dc1dfbf 100644 --- a/chart2/source/controller/dialogs/DialogModel.cxx +++ b/chart2/source/controller/dialogs/DialogModel.cxx @@ -160,7 +160,7 @@ void lcl_createRoleIndexMap( lcl_tRoleIndexMap & rOutMap ) struct lcl_DataSeriesContainerAppend : public ::std::iterator< ::std::output_iterator_tag, Reference< XDataSeriesContainer > > { - typedef ::std::vector< chart::DialogModel::tSeriesWithChartTypeByName > tContainerType; + typedef ::std::vector< ::chart::DialogModel::tSeriesWithChartTypeByName > tContainerType; explicit lcl_DataSeriesContainerAppend( tContainerType & rCnt ) : m_rDestCnt( rCnt ) @@ -180,7 +180,7 @@ struct lcl_DataSeriesContainerAppend : public for( sal_Int32 nI = 0; nI < aSeq.getLength(); ++ nI ) { m_rDestCnt.push_back( - chart::DialogModel::tSeriesWithChartTypeByName( + ::chart::DialogModel::tSeriesWithChartTypeByName( ::chart::DataSeriesHelper::getDataSeriesLabel( aSeq[nI], aRole ), ::std::make_pair( aSeq[nI], xCT ))); } diff --git a/chart2/source/controller/dialogs/ObjectNameProvider.cxx b/chart2/source/controller/dialogs/ObjectNameProvider.cxx index 9057b850332f..483424d04497 100644 --- a/chart2/source/controller/dialogs/ObjectNameProvider.cxx +++ b/chart2/source/controller/dialogs/ObjectNameProvider.cxx @@ -40,7 +40,7 @@ #include "AxisIndexDefines.hxx" #include "ExplicitCategoriesProvider.hxx" #include "CommonConverters.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include "RegressionCurveHelper.hxx" #include <rtl/math.hxx> #include <tools/debug.hxx> @@ -191,14 +191,7 @@ OUString lcl_getDataPointValueText( const Reference< XDataSeries >& xSeries, sal if( aX.getLength() == 0 ) { - rtl::OUString aCategory = ::rtl::OUString( String(SchResId(STR_TIP_CATEGORY_VALUE))); - - replaceParamterInString( aCategory - , C2U("%CATEGORYVALUE") - , ExplicitCategoriesProvider::getCategoryByIndex( xCooSys, xChartModel, nPointIndex ) - ); - - aRet = aCategory; + aRet = ExplicitCategoriesProvider::getCategoryByIndex( xCooSys, xChartModel, nPointIndex ); } else { diff --git a/chart2/source/controller/dialogs/Strings.src b/chart2/source/controller/dialogs/Strings.src index 4b4cec65426e..1c0a066df046 100644 --- a/chart2/source/controller/dialogs/Strings.src +++ b/chart2/source/controller/dialogs/Strings.src @@ -388,11 +388,6 @@ String STR_TIP_DATAPOINT_VALUES Text [ en-US ] = "Values: %POINTVALUES"; }; -String STR_TIP_CATEGORY_VALUE -{ - Text [ en-US ] = "'%CATEGORYVALUE'"; -}; - String STR_TIP_DATAPOINT { Text [ en-US ] = "Data Point %POINTNUMBER, data series %SERIESNUMBER, values: %POINTVALUES"; @@ -463,6 +458,10 @@ String STR_ACTION_NOTPOSSIBLE { Text [ en-US ] = "This function cannot be completed with the selected objects." ; }; +String STR_ACTION_EDIT_TEXT +{ + Text [ en-US ] = "Edit text"; +}; String STR_COLUMN_LABEL { diff --git a/chart2/source/controller/dialogs/Strings_Scale.src b/chart2/source/controller/dialogs/Strings_Scale.src index e7a3d6c2b1cf..6f8b75d9509c 100644 --- a/chart2/source/controller/dialogs/Strings_Scale.src +++ b/chart2/source/controller/dialogs/Strings_Scale.src @@ -42,3 +42,11 @@ String STR_MIN_GREATER_MAX { Text [ en-US ] = "The minimum must be lower than the maximum. Check your input." ; }; +String STR_INVALID_INTERVALS +{ + Text [ en-US ] = "The major interval needs to be greater than the minor interval. Check your input." ; +}; +String STR_INVALID_TIME_UNIT +{ + Text [ en-US ] = "The major and minor interval need to be greater or equal to the resolution. Check your input." ; +}; diff --git a/chart2/source/controller/dialogs/TabPages.hrc b/chart2/source/controller/dialogs/TabPages.hrc index 1f445083738f..dbc166e4f2cd 100644 --- a/chart2/source/controller/dialogs/TabPages.hrc +++ b/chart2/source/controller/dialogs/TabPages.hrc @@ -111,31 +111,6 @@ #define FT_AXIS_TEXTDIR 19 #define LB_AXIS_TEXTDIR 20 -//#define TP_SCALE 903 - -#define FL_SCALE 1 - -#define TXT_MIN 1 -#define TXT_MAX 2 -#define TXT_STEP_MAIN 3 -#define TXT_STEP_HELP 4 -#define TXT_ORIGIN 5 - -#define CBX_AUTO_MIN 1 -#define CBX_AUTO_MAX 2 -#define CBX_AUTO_STEP_MAIN 3 -#define CBX_AUTO_STEP_HELP 4 -#define CBX_AUTO_ORIGIN 5 -#define CBX_LOGARITHM 6 -#define CBX_REVERSE 7 - -#define EDT_STEP_MAIN 1 -#define EDT_MAX 2 -#define EDT_MIN 3 -#define EDT_ORIGIN 4 - -#define MT_STEPHELP 10 - //#define TP_AXIS_POSITIONS 904 #define FL_AXIS_LINE 1 diff --git a/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx b/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx index 50aa10ec6e6b..9c0d8f1e1b10 100644 --- a/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx +++ b/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx @@ -118,7 +118,7 @@ double InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( pExplicitValueProvider->getExplicitValuesForAxis( xAxis,aExplicitScale, aExplicitIncrement ); fStepWidth = aExplicitIncrement.Distance; - if( aExplicitIncrement.SubIncrements.getLength() && aExplicitIncrement.SubIncrements[0].IntervalCount>0 ) + if( !aExplicitIncrement.SubIncrements.empty() && aExplicitIncrement.SubIncrements[0].IntervalCount>0 ) fStepWidth=fStepWidth/double(aExplicitIncrement.SubIncrements[0].IntervalCount); else fStepWidth/=10; diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx index 448adbf3e89c..fd14db521416 100644 --- a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx +++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx @@ -56,7 +56,7 @@ #include "ChartTypeHelper.hxx" #include "ObjectNameProvider.hxx" #include "DiagramHelper.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include "AxisIndexDefines.hxx" #include "AxisHelper.hxx" #include "ExplicitCategoriesProvider.hxx" @@ -181,7 +181,7 @@ void ObjectPropertiesDialogParameter::init( const uno::Reference< frame::XModel ScaleData aData( xAxis->getScaleData() ); if( chart2::AxisType::SERIES == aData.AxisType ) m_bHasScaleProperties = false; - if( chart2::AxisType::REALNUMBER == aData.AxisType || chart2::AxisType::PERCENT == aData.AxisType ) + if( chart2::AxisType::SERIES != aData.AxisType ) m_bHasNumberProperties = true; sal_Int32 nCooSysIndex=0; diff --git a/chart2/source/controller/dialogs/res_ErrorBar.cxx b/chart2/source/controller/dialogs/res_ErrorBar.cxx index 8b649072538e..c71e9de73a31 100644 --- a/chart2/source/controller/dialogs/res_ErrorBar.cxx +++ b/chart2/source/controller/dialogs/res_ErrorBar.cxx @@ -474,12 +474,12 @@ IMPL_LINK( ErrorBarResources, ChooseRange, RangeSelectionButton *, pButton ) if( pButton == &m_aIbRangePositive ) { m_pCurrentRangeChoosingField = &m_aEdRangePositive; - aUIString = ::rtl::OUString( String( SchResId( STR_DATA_SELECT_RANGE_FOR_POSITIVE_ERRORBARS ))); + aUIString = String( SchResId( STR_DATA_SELECT_RANGE_FOR_POSITIVE_ERRORBARS )); } else { m_pCurrentRangeChoosingField = &m_aEdRangeNegative; - aUIString = ::rtl::OUString( String( SchResId( STR_DATA_SELECT_RANGE_FOR_NEGATIVE_ERRORBARS ))); + aUIString = String( SchResId( STR_DATA_SELECT_RANGE_FOR_NEGATIVE_ERRORBARS )); } OSL_ASSERT( m_pParentDialog ); diff --git a/chart2/source/controller/dialogs/tp_AxisLabel.cxx b/chart2/source/controller/dialogs/tp_AxisLabel.cxx index 87cc48ec6a55..58322534cba6 100644 --- a/chart2/source/controller/dialogs/tp_AxisLabel.cxx +++ b/chart2/source/controller/dialogs/tp_AxisLabel.cxx @@ -142,13 +142,13 @@ BOOL SchAxisLabelTabPage::FillItemSet( SfxItemSet& rOutAttrs ) bRadioButtonChecked = false; if( bRadioButtonChecked ) - rOutAttrs.Put( SvxChartTextOrderItem( eOrder, SCHATTR_TEXT_ORDER )); + rOutAttrs.Put( SvxChartTextOrderItem( eOrder, SCHATTR_AXIS_LABEL_ORDER )); } if( aCbTextOverlap.GetState() != STATE_DONTKNOW ) - rOutAttrs.Put( SfxBoolItem( SCHATTR_TEXT_OVERLAP, aCbTextOverlap.IsChecked() ) ); + rOutAttrs.Put( SfxBoolItem( SCHATTR_AXIS_LABEL_OVERLAP, aCbTextOverlap.IsChecked() ) ); if( aCbTextBreak.GetState() != STATE_DONTKNOW ) - rOutAttrs.Put( SfxBoolItem( SCHATTR_TEXTBREAK, aCbTextBreak.IsChecked() ) ); + rOutAttrs.Put( SfxBoolItem( SCHATTR_AXIS_LABEL_BREAK, aCbTextBreak.IsChecked() ) ); if( aCbShowDescription.GetState() != STATE_DONTKNOW ) rOutAttrs.Put( SfxBoolItem( SCHATTR_AXIS_SHOWDESCR, aCbShowDescription.IsChecked() ) ); @@ -212,7 +212,7 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet& rInAttrs ) m_aLbTextDirection.SelectEntryValue( SvxFrameDirection(((const SvxFrameDirectionItem*)pPoolItem)->GetValue()) ); // Text overlap ---------- - aState = rInAttrs.GetItemState( SCHATTR_TEXT_OVERLAP, FALSE, &pPoolItem ); + aState = rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_OVERLAP, FALSE, &pPoolItem ); if( aState == SFX_ITEM_DONTCARE ) { aCbTextOverlap.EnableTriState( TRUE ); @@ -231,7 +231,7 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet& rInAttrs ) } // text break ---------- - aState = rInAttrs.GetItemState( SCHATTR_TEXTBREAK, FALSE, &pPoolItem ); + aState = rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_BREAK, FALSE, &pPoolItem ); if( aState == SFX_ITEM_DONTCARE ) { aCbTextBreak.EnableTriState( TRUE ); @@ -256,7 +256,7 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet& rInAttrs ) // text order ---------- if( m_bShowStaggeringControls ) { - aState = rInAttrs.GetItemState( SCHATTR_TEXT_ORDER, FALSE, &pPoolItem ); + aState = rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_ORDER, FALSE, &pPoolItem ); if( aState == SFX_ITEM_SET ) { SvxChartTextOrder eOrder = static_cast< const SvxChartTextOrderItem * >( pPoolItem )->GetValue(); diff --git a/chart2/source/controller/dialogs/tp_RangeChooser.cxx b/chart2/source/controller/dialogs/tp_RangeChooser.cxx index 3ba6ca0f74b2..82a1d19ffdb3 100644 --- a/chart2/source/controller/dialogs/tp_RangeChooser.cxx +++ b/chart2/source/controller/dialogs/tp_RangeChooser.cxx @@ -366,7 +366,7 @@ IMPL_LINK( RangeChooserTabPage, ChooseRangeHdl, void *, EMPTYARG ) { rtl::OUString aRange = m_aED_Range.GetText(); // using assignment for broken gcc 3.3 - rtl::OUString aTitle = ::rtl::OUString( String( SchResId( STR_PAGE_DATA_RANGE ) )); + rtl::OUString aTitle = String( SchResId( STR_PAGE_DATA_RANGE ) ); lcl_enableRangeChoosing( true, m_pParentDialog ); m_rDialogModel.getRangeSelectionHelper()->chooseRange( aRange, aTitle, *this ); diff --git a/chart2/source/controller/dialogs/tp_Scale.cxx b/chart2/source/controller/dialogs/tp_Scale.cxx index 34fc0702bafe..3cb2d2838e8c 100644 --- a/chart2/source/controller/dialogs/tp_Scale.cxx +++ b/chart2/source/controller/dialogs/tp_Scale.cxx @@ -28,9 +28,9 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_chart2.hxx" #include "tp_Scale.hxx" +#include "tp_Scale.hrc" #include "ResId.hxx" -#include "TabPages.hrc" #include "Strings.hrc" #include "chartview/ChartSfxItemIds.hxx" #include "NoWarningThisInCTOR.hxx" @@ -72,6 +72,20 @@ namespace chart namespace { +void lcl_placeControlAtX( Control& rControl, long nNewXPos ) +{ + Point aPos( rControl.GetPosPixel() ); + aPos.X() = nNewXPos; + rControl.SetPosPixel(aPos); +} + +void lcl_placeControlAtY( Control& rControl, long nNewYPos ) +{ + Point aPos( rControl.GetPosPixel() ); + aPos.Y() = nNewYPos; + rControl.SetPosPixel(aPos); +} + void lcl_shiftControls( Control& rEdit, Control& rAuto, long nNewXPos ) { Point aPos( rEdit.GetPosPixel() ); @@ -84,16 +98,15 @@ void lcl_shiftControls( Control& rEdit, Control& rAuto, long nNewXPos ) rAuto.SetPosPixel(aPos); } -void lcl_placeControlsAtY( Control& rTop, Control& rBottom, long nNewYPos ) +long lcl_getLabelDistance( Control& rControl ) { - Point aPos( rTop.GetPosPixel() ); - long nShift = nNewYPos - aPos.Y(); - aPos.Y() = nNewYPos; - rTop.SetPosPixel(aPos); + return rControl.LogicToPixel( Size(RSC_SP_CTRL_DESC_X, 0), MapMode(MAP_APPFONT) ).Width(); +} - aPos = rBottom.GetPosPixel(); - aPos.Y() += nShift; - rBottom.SetPosPixel(aPos); +void lcl_setValue( FormattedField& rFmtField, double fValue ) +{ + rFmtField.SetValue( fValue ); + rFmtField.SetDefaultValue( fValue ); } } @@ -102,32 +115,51 @@ ScaleTabPage::ScaleTabPage(Window* pWindow,const SfxItemSet& rInAttrs) : SfxTabPage(pWindow, SchResId(TP_SCALE), rInAttrs), aFlScale(this, SchResId(FL_SCALE)), + + aCbxReverse(this, SchResId(CBX_REVERSE)), + aCbxLogarithm(this, SchResId(CBX_LOGARITHM)), + + m_aTxt_AxisType(this, SchResId (TXT_AXIS_TYPE)), + m_aLB_AxisType(this, SchResId(LB_AXIS_TYPE)), + aTxtMin (this, SchResId (TXT_MIN)), aFmtFldMin(this, SchResId(EDT_MIN)), aCbxAutoMin(this, SchResId(CBX_AUTO_MIN)), + aTxtMax(this, SchResId (TXT_MAX)), aFmtFldMax(this, SchResId(EDT_MAX)), aCbxAutoMax(this, SchResId(CBX_AUTO_MAX)), + + m_aTxt_TimeResolution(this, SchResId (TXT_TIME_RESOLUTION)), + m_aLB_TimeResolution(this, SchResId(LB_TIME_RESOLUTION)), + m_aCbx_AutoTimeResolution(this, SchResId(CBX_AUTO_TIME_RESOLUTION)), + aTxtMain (this, SchResId (TXT_STEP_MAIN)), aFmtFldStepMain(this, SchResId(EDT_STEP_MAIN)), + m_aMt_MainDateStep(this, SchResId(MT_MAIN_DATE_STEP)), + m_aLB_MainTimeUnit(this, SchResId(LB_MAIN_TIME_UNIT)), aCbxAutoStepMain(this, SchResId(CBX_AUTO_STEP_MAIN)), + + aTxtHelpCount (this, SchResId (TXT_STEP_HELP_COUNT)), aTxtHelp (this, SchResId (TXT_STEP_HELP)), aMtStepHelp (this, SchResId (MT_STEPHELP)), + m_aLB_HelpTimeUnit(this, SchResId(LB_HELP_TIME_UNIT)), aCbxAutoStepHelp(this, SchResId(CBX_AUTO_STEP_HELP)), aTxtOrigin (this, SchResId (TXT_ORIGIN)), aFmtFldOrigin(this, SchResId(EDT_ORIGIN)), aCbxAutoOrigin(this, SchResId(CBX_AUTO_ORIGIN)), - aCbxLogarithm(this, SchResId(CBX_LOGARITHM)), - aCbxReverse(this, SchResId(CBX_REVERSE)), - fMin(0.0), fMax(0.0), fStepMain(0.0), nStepHelp(0), fOrigin(0.0), - nAxisType(chart2::AxisType::REALNUMBER), + m_nTimeResolution(1), + m_nMainTimeUnit(1), + m_nHelpTimeUnit(1), + m_nAxisType(chart2::AxisType::REALNUMBER), + m_bAllowDateAxis(false), pNumFormatter(NULL), m_bShowAxisOrigin(false) { @@ -139,6 +171,26 @@ ScaleTabPage::ScaleTabPage(Window* pWindow,const SfxItemSet& rInAttrs) : aCbxAutoStepMain.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl)); aCbxAutoStepHelp.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl)); aCbxAutoOrigin.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl)); + m_aCbx_AutoTimeResolution.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl)); + + m_aLB_AxisType.SetDropDownLineCount(3); + m_aLB_AxisType.SetSelectHdl(LINK(this, ScaleTabPage, SelectAxisTypeHdl)); + + m_aLB_TimeResolution.SetDropDownLineCount(3); + m_aLB_MainTimeUnit.SetDropDownLineCount(3); + m_aLB_HelpTimeUnit.SetDropDownLineCount(3); + + aFmtFldMin.SetModifyHdl(LINK(this, ScaleTabPage, FmtFieldModifiedHdl)); + aFmtFldMax.SetModifyHdl(LINK(this, ScaleTabPage, FmtFieldModifiedHdl)); + aFmtFldStepMain.SetModifyHdl(LINK(this, ScaleTabPage, FmtFieldModifiedHdl)); + aFmtFldOrigin.SetModifyHdl(LINK(this, ScaleTabPage, FmtFieldModifiedHdl)); +} + +IMPL_LINK( ScaleTabPage, FmtFieldModifiedHdl, FormattedField*, pFmtFied ) +{ + if( pFmtFied ) + pFmtFied->SetDefaultValue( pFmtFied->GetValue() ); + return 0; } void ScaleTabPage::StateChanged( StateChangedType nType ) @@ -155,10 +207,13 @@ void ScaleTabPage::AdjustControlPositions() long nLabelWidth = ::std::max( aTxtMin.CalcMinimumSize().Width(), aTxtMax.CalcMinimumSize().Width() ); nLabelWidth = ::std::max( aTxtMain.CalcMinimumSize().Width(), nLabelWidth ); nLabelWidth = ::std::max( aTxtHelp.CalcMinimumSize().Width(), nLabelWidth ); + nLabelWidth = ::std::max( aTxtHelpCount.CalcMinimumSize().Width(), nLabelWidth ); nLabelWidth = ::std::max( aTxtOrigin.CalcMinimumSize().Width(), nLabelWidth ); + nLabelWidth = ::std::max( m_aTxt_TimeResolution.CalcMinimumSize().Width(), nLabelWidth ); + nLabelWidth = ::std::max( m_aTxt_AxisType.CalcMinimumSize().Width(), nLabelWidth ); nLabelWidth+=1; - long nLabelDistance = aTxtMin.LogicToPixel( Size(RSC_SP_CTRL_DESC_X, 0), MapMode(MAP_APPFONT) ).Width(); + long nLabelDistance = lcl_getLabelDistance(aTxtMin); long nNewXPos = aTxtMin.GetPosPixel().X() + nLabelWidth + nLabelDistance; //ensure that the auto checkboxes are wide enough and have correct size for calculation @@ -167,9 +222,10 @@ void ScaleTabPage::AdjustControlPositions() aCbxAutoStepMain.SetSizePixel( aCbxAutoStepMain.CalcMinimumSize() ); aCbxAutoStepHelp.SetSizePixel( aCbxAutoStepHelp.CalcMinimumSize() ); aCbxAutoOrigin.SetSizePixel( aCbxAutoOrigin.CalcMinimumSize() ); + m_aCbx_AutoTimeResolution.SetSizePixel( m_aCbx_AutoTimeResolution.CalcMinimumSize() ); //ensure new pos is ok - long nWidthOfOtherControls = aCbxAutoMin.GetPosPixel().X() + aCbxAutoMin.GetSizePixel().Width() - aFmtFldMin.GetPosPixel().X(); + long nWidthOfOtherControls = m_aLB_MainTimeUnit.GetPosPixel().X() + m_aLB_MainTimeUnit.GetSizePixel().Width() - aFmtFldMin.GetPosPixel().X(); long nDialogWidth = GetSizePixel().Width(); long nLeftSpace = nDialogWidth - nNewXPos - nWidthOfOtherControls; @@ -181,72 +237,180 @@ void ScaleTabPage::AdjustControlPositions() aTxtMax.SetSizePixel(aSize); aTxtMain.SetSizePixel(aSize); aTxtHelp.SetSizePixel(aSize); + aTxtHelpCount.SetSizePixel(aSize); aTxtOrigin.SetSizePixel(aSize); + m_aTxt_TimeResolution.SetSizePixel(aSize); + m_aTxt_AxisType.SetSizePixel(aSize); + + long nOrgAutoCheckX = aCbxAutoMin.GetPosPixel().X(); + lcl_placeControlAtX( aCbxAutoStepMain, nOrgAutoCheckX ); + lcl_placeControlAtX( aCbxAutoStepHelp, nOrgAutoCheckX ); lcl_shiftControls( aFmtFldMin, aCbxAutoMin, nNewXPos ); lcl_shiftControls( aFmtFldMax, aCbxAutoMax, nNewXPos ); lcl_shiftControls( aFmtFldStepMain, aCbxAutoStepMain, nNewXPos ); + lcl_placeControlAtX( m_aMt_MainDateStep, aFmtFldStepMain.GetPosPixel().X() ); lcl_shiftControls( aMtStepHelp, aCbxAutoStepHelp, nNewXPos ); lcl_shiftControls( aFmtFldOrigin, aCbxAutoOrigin, nNewXPos ); + lcl_shiftControls( m_aLB_TimeResolution, m_aCbx_AutoTimeResolution, nNewXPos ); + lcl_placeControlAtX( m_aLB_AxisType, nNewXPos ); + + nNewXPos = aCbxAutoStepMain.GetPosPixel().X() + aCbxAutoStepMain.GetSizePixel().Width() + nLabelDistance; + lcl_placeControlAtX( m_aLB_MainTimeUnit, nNewXPos ); + lcl_placeControlAtX( m_aLB_HelpTimeUnit, nNewXPos ); } + PlaceIntervalControlsAccordingToAxisType(); } -void ScaleTabPage::EnableControls() +void ScaleTabPage::PlaceIntervalControlsAccordingToAxisType() { - bool bEnableForValueOrPercentAxis = chart2::AxisType::REALNUMBER == nAxisType || chart2::AxisType::PERCENT == nAxisType; - aFlScale.Enable( bEnableForValueOrPercentAxis ); - aTxtMin.Enable( bEnableForValueOrPercentAxis ); - aFmtFldMin.Enable( bEnableForValueOrPercentAxis ); - aCbxAutoMin.Enable( bEnableForValueOrPercentAxis ); - aTxtMax.Enable( bEnableForValueOrPercentAxis ); - aFmtFldMax.Enable( bEnableForValueOrPercentAxis ); - aCbxAutoMax.Enable( bEnableForValueOrPercentAxis ); - aTxtMain.Enable( bEnableForValueOrPercentAxis ); - aFmtFldStepMain.Enable( bEnableForValueOrPercentAxis ); - aCbxAutoStepMain.Enable( bEnableForValueOrPercentAxis ); - aTxtHelp.Enable( bEnableForValueOrPercentAxis ); - aMtStepHelp.Enable( bEnableForValueOrPercentAxis ); - aCbxAutoStepHelp.Enable( bEnableForValueOrPercentAxis ); - aCbxLogarithm.Enable( bEnableForValueOrPercentAxis ); - - aTxtOrigin.Show( m_bShowAxisOrigin && bEnableForValueOrPercentAxis ); - aFmtFldOrigin.Show( m_bShowAxisOrigin && bEnableForValueOrPercentAxis ); - aCbxAutoOrigin.Show( m_bShowAxisOrigin && bEnableForValueOrPercentAxis ); - - long nNewYPos = aTxtOrigin.GetPosPixel().Y(); - if( m_bShowAxisOrigin ) - nNewYPos += ( aTxtOrigin.GetPosPixel().Y() - aTxtHelp.GetPosPixel().Y() ); - lcl_placeControlsAtY( aCbxLogarithm, aCbxReverse, nNewYPos ); + long nMinX = std::min( aCbxAutoStepMain.GetPosPixel().X(), m_aLB_MainTimeUnit.GetPosPixel().X() ); + long nLabelDistance = lcl_getLabelDistance(aTxtMin); + long nListWidth = m_aLB_MainTimeUnit.GetSizePixel().Width(); + + if( chart2::AxisType::DATE == m_nAxisType ) + { + lcl_placeControlAtX( m_aLB_MainTimeUnit, nMinX ); + lcl_placeControlAtX( m_aLB_HelpTimeUnit, nMinX ); + long nSecondX = nMinX + nListWidth + nLabelDistance; + lcl_placeControlAtX( aCbxAutoStepMain, nSecondX ); + lcl_placeControlAtX( aCbxAutoStepHelp, nSecondX ); + + long nOne = m_aMt_MainDateStep.LogicToPixel( Size(0, 1), MapMode(MAP_APPFONT) ).Height(); + + long nYMajor = m_aMt_MainDateStep.GetPosPixel().Y(); + lcl_placeControlAtY( aCbxAutoStepMain , nYMajor+(3*nOne)); + lcl_placeControlAtY( aTxtMain , nYMajor+nOne+nOne); + + long nYMinor = m_aLB_HelpTimeUnit.GetPosPixel().Y(); + lcl_placeControlAtY( aMtStepHelp , nYMinor ); + lcl_placeControlAtY( aCbxAutoStepHelp , nYMinor+(3*nOne)); + } + else + { + lcl_placeControlAtX( aCbxAutoStepMain, nMinX ); + lcl_placeControlAtX( aCbxAutoStepHelp, nMinX ); + long nSecondX = nMinX + aCbxAutoStepMain.GetSizePixel().Width() + nLabelDistance; + long nSecondXMax = GetSizePixel().Width() - nListWidth; + if( nSecondX > nSecondXMax ) + nSecondX = nSecondXMax; + lcl_placeControlAtX( m_aLB_MainTimeUnit, nSecondX ); + lcl_placeControlAtX( m_aLB_HelpTimeUnit, nSecondX ); + } } +void ScaleTabPage::EnableControls() +{ + bool bValueAxis = chart2::AxisType::REALNUMBER == m_nAxisType || chart2::AxisType::PERCENT == m_nAxisType || chart2::AxisType::DATE == m_nAxisType; + bool bDateAxis = chart2::AxisType::DATE == m_nAxisType; + + m_aTxt_AxisType.Show(m_bAllowDateAxis); + m_aLB_AxisType.Show(m_bAllowDateAxis); + + aCbxLogarithm.Show( bValueAxis && !bDateAxis ); + aTxtMin.Show( bValueAxis ); + aFmtFldMin.Show( bValueAxis ); + aCbxAutoMin.Show( bValueAxis ); + aTxtMax.Show( bValueAxis ); + aFmtFldMax.Show( bValueAxis ); + aCbxAutoMax.Show( bValueAxis ); + aTxtMain.Show( bValueAxis ); + aFmtFldStepMain.Show( bValueAxis ); + aCbxAutoStepMain.Show( bValueAxis ); + aTxtHelp.Show( bValueAxis ); + aTxtHelpCount.Show( bValueAxis ); + aMtStepHelp.Show( bValueAxis ); + aCbxAutoStepHelp.Show( bValueAxis ); + + aTxtOrigin.Show( m_bShowAxisOrigin && bValueAxis ); + aFmtFldOrigin.Show( m_bShowAxisOrigin && bValueAxis ); + aCbxAutoOrigin.Show( m_bShowAxisOrigin && bValueAxis ); + + aTxtHelpCount.Show( bValueAxis && !bDateAxis ); + aTxtHelp.Show( bDateAxis ); + + m_aTxt_TimeResolution.Show( bDateAxis ); + m_aLB_TimeResolution.Show( bDateAxis ); + m_aCbx_AutoTimeResolution.Show( bDateAxis ); + + bool bWasDateAxis = m_aMt_MainDateStep.IsVisible(); + if( bWasDateAxis != bDateAxis ) + { + //transport value from one to other control + if( bWasDateAxis ) + lcl_setValue( aFmtFldStepMain, m_aMt_MainDateStep.GetValue() ); + else + m_aMt_MainDateStep.SetValue( static_cast<sal_Int32>(aFmtFldStepMain.GetValue()) ); + } + aFmtFldStepMain.Show( bValueAxis && !bDateAxis ); + m_aMt_MainDateStep.Show( bDateAxis ); + + m_aLB_MainTimeUnit.Show( bDateAxis ); + m_aLB_HelpTimeUnit.Show( bDateAxis ); + EnableValueHdl(&aCbxAutoMin); + EnableValueHdl(&aCbxAutoMax); + EnableValueHdl(&aCbxAutoStepMain); + EnableValueHdl(&aCbxAutoStepHelp); + EnableValueHdl(&aCbxAutoOrigin); + EnableValueHdl(&m_aCbx_AutoTimeResolution); +} IMPL_LINK( ScaleTabPage, EnableValueHdl, CheckBox *, pCbx ) { + bool bEnable = pCbx && !pCbx->IsChecked() && pCbx->IsEnabled(); if (pCbx == &aCbxAutoMin) { - aFmtFldMin.Enable(!aCbxAutoMin.IsChecked()); + aFmtFldMin.Enable( bEnable ); } else if (pCbx == &aCbxAutoMax) { - aFmtFldMax.Enable(!aCbxAutoMax.IsChecked()); + aFmtFldMax.Enable( bEnable ); } else if (pCbx == &aCbxAutoStepMain) { - aFmtFldStepMain.Enable(!aCbxAutoStepMain.IsChecked()); + aFmtFldStepMain.Enable( bEnable ); + m_aMt_MainDateStep.Enable( bEnable ); + m_aLB_MainTimeUnit.Enable( bEnable ); } else if (pCbx == &aCbxAutoStepHelp) { - aMtStepHelp.Show (); - aMtStepHelp.Enable( ! aCbxAutoStepHelp.IsChecked() ); + aMtStepHelp.Enable( bEnable ); + m_aLB_HelpTimeUnit.Enable( bEnable ); + } + else if (pCbx == &m_aCbx_AutoTimeResolution) + { + m_aLB_TimeResolution.Enable( bEnable ); } else if (pCbx == &aCbxAutoOrigin) { - aFmtFldOrigin.Enable(!aCbxAutoOrigin.IsChecked()); + aFmtFldOrigin.Enable( bEnable ); } return 0; } +enum AxisTypeListBoxEntry +{ + TYPE_AUTO=0, + TYPE_TEXT=1, + TYPE_DATE=2 +}; + +IMPL_LINK( ScaleTabPage, SelectAxisTypeHdl, void *, EMPTYARG ) +{ + USHORT nPos = m_aLB_AxisType.GetSelectEntryPos(); + if( nPos==TYPE_DATE ) + m_nAxisType = chart2::AxisType::DATE; + else + m_nAxisType = chart2::AxisType::CATEGORY; + if( chart2::AxisType::DATE == m_nAxisType ) + aCbxLogarithm.Check(false); + EnableControls(); + PlaceIntervalControlsAccordingToAxisType(); + SetNumFormat(); + return 0; +} + SfxTabPage* ScaleTabPage::Create(Window* pWindow,const SfxItemSet& rOutAttrs) { return new ScaleTabPage(pWindow, rOutAttrs); @@ -256,10 +420,18 @@ BOOL ScaleTabPage::FillItemSet(SfxItemSet& rOutAttrs) { DBG_ASSERT( pNumFormatter, "No NumberFormatter available" ); - rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_MIN ,aCbxAutoMin.IsChecked())); - rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_MAX ,aCbxAutoMax.IsChecked())); - rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_HELP,aCbxAutoStepHelp.IsChecked())); - rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_ORIGIN ,aCbxAutoOrigin.IsChecked())); + rOutAttrs.Put(SfxInt32Item(SCHATTR_AXISTYPE, m_nAxisType)); + if(m_bAllowDateAxis) + rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_DATEAXIS, TYPE_AUTO==m_aLB_AxisType.GetSelectEntryPos())); + + bool bAutoScale = false; + if( m_nAxisType==chart2::AxisType::CATEGORY ) + bAutoScale = true;//reset scaling for category charts + + rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_MIN ,bAutoScale || aCbxAutoMin.IsChecked())); + rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_MAX ,bAutoScale || aCbxAutoMax.IsChecked())); + rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_HELP,bAutoScale || aCbxAutoStepHelp.IsChecked())); + rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_ORIGIN ,bAutoScale || aCbxAutoOrigin.IsChecked())); rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_LOGARITHM ,aCbxLogarithm.IsChecked())); rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_REVERSE ,aCbxReverse.IsChecked())); rOutAttrs.Put(SvxDoubleItem(fMax , SCHATTR_AXIS_MAX)); @@ -267,9 +439,15 @@ BOOL ScaleTabPage::FillItemSet(SfxItemSet& rOutAttrs) rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_STEP_HELP, nStepHelp)); rOutAttrs.Put(SvxDoubleItem(fOrigin , SCHATTR_AXIS_ORIGIN)); - rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_MAIN,aCbxAutoStepMain.IsChecked())); + rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_MAIN,bAutoScale || aCbxAutoStepMain.IsChecked())); rOutAttrs.Put(SvxDoubleItem(fStepMain,SCHATTR_AXIS_STEP_MAIN)); + rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_TIME_RESOLUTION,bAutoScale || m_aCbx_AutoTimeResolution.IsChecked())); + rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_TIME_RESOLUTION,m_nTimeResolution)); + + rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_MAIN_TIME_UNIT,m_nMainTimeUnit)); + rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_HELP_TIME_UNIT,m_nHelpTimeUnit)); + return TRUE; } @@ -280,20 +458,50 @@ void ScaleTabPage::Reset(const SfxItemSet& rInAttrs) return; const SfxPoolItem *pPoolItem = NULL; - nAxisType=chart2::AxisType::REALNUMBER; + if (rInAttrs.GetItemState(SCHATTR_AXIS_ALLOW_DATEAXIS, TRUE, &pPoolItem) == SFX_ITEM_SET) + m_bAllowDateAxis = (bool) ((const SfxBoolItem*)pPoolItem)->GetValue(); + m_nAxisType=chart2::AxisType::REALNUMBER; if (rInAttrs.GetItemState(SCHATTR_AXISTYPE, TRUE, &pPoolItem) == SFX_ITEM_SET) + m_nAxisType = (int) ((const SfxInt32Item*)pPoolItem)->GetValue(); + if( m_nAxisType==chart2::AxisType::DATE && !m_bAllowDateAxis ) + m_nAxisType=chart2::AxisType::CATEGORY; + if( m_bAllowDateAxis ) { - nAxisType = (int) ((const SfxInt32Item*)pPoolItem)->GetValue(); - EnableControls(); + bool bAutoDateAxis = false; + if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_DATEAXIS, TRUE, &pPoolItem) == SFX_ITEM_SET) + bAutoDateAxis = (bool) ((const SfxBoolItem*)pPoolItem)->GetValue(); + + USHORT nPos = 0; + if( m_nAxisType==chart2::AxisType::DATE ) + nPos=TYPE_DATE; + else if( bAutoDateAxis ) + nPos=TYPE_AUTO; + else + nPos=TYPE_TEXT; + m_aLB_AxisType.SelectEntryPos( nPos ); } + if( m_bAllowDateAxis ) + aCbxReverse.SetHelpId("chart2:CheckBox:TP_SCALE:CBX_REVERSE:MayBeDateAxis"); + else if( m_nAxisType==chart2::AxisType::CATEGORY || m_nAxisType==chart2::AxisType::SERIES ) + aCbxReverse.SetHelpId("chart2:CheckBox:TP_SCALE:CBX_REVERSE:Category"); + + PlaceIntervalControlsAccordingToAxisType(); + + aCbxAutoMin.Check( true ); + aCbxAutoMax.Check( true ); + aCbxAutoStepMain.Check( true ); + aCbxAutoStepHelp.Check( true ); + aCbxAutoOrigin.Check( true ); + m_aCbx_AutoTimeResolution.Check( true ); + if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_MIN,TRUE,&pPoolItem) == SFX_ITEM_SET) aCbxAutoMin.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); if (rInAttrs.GetItemState(SCHATTR_AXIS_MIN,TRUE, &pPoolItem) == SFX_ITEM_SET) { fMin = ((const SvxDoubleItem*)pPoolItem)->GetValue(); - aFmtFldMin.SetValue( fMin ); + lcl_setValue( aFmtFldMin, fMin ); } if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_MAX,TRUE, &pPoolItem) == SFX_ITEM_SET) @@ -302,7 +510,7 @@ void ScaleTabPage::Reset(const SfxItemSet& rInAttrs) if (rInAttrs.GetItemState(SCHATTR_AXIS_MAX,TRUE, &pPoolItem) == SFX_ITEM_SET) { fMax = ((const SvxDoubleItem*)pPoolItem)->GetValue(); - aFmtFldMax.SetValue( fMax ); + lcl_setValue( aFmtFldMax, fMax ); } if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_STEP_MAIN,TRUE, &pPoolItem) == SFX_ITEM_SET) @@ -311,7 +519,8 @@ void ScaleTabPage::Reset(const SfxItemSet& rInAttrs) if (rInAttrs.GetItemState(SCHATTR_AXIS_STEP_MAIN,TRUE, &pPoolItem) == SFX_ITEM_SET) { fStepMain = ((const SvxDoubleItem*)pPoolItem)->GetValue(); - aFmtFldStepMain.SetValue( fStepMain ); + lcl_setValue( aFmtFldStepMain, fStepMain ); + m_aMt_MainDateStep.SetValue( static_cast<sal_Int32>(fStepMain) ); } if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_STEP_HELP,TRUE, &pPoolItem) == SFX_ITEM_SET) aCbxAutoStepHelp.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); @@ -329,14 +538,30 @@ void ScaleTabPage::Reset(const SfxItemSet& rInAttrs) if (rInAttrs.GetItemState(SCHATTR_AXIS_ORIGIN,TRUE, &pPoolItem) == SFX_ITEM_SET) { fOrigin = ((const SvxDoubleItem*)pPoolItem)->GetValue(); - aFmtFldOrigin.SetValue( fOrigin ); + lcl_setValue( aFmtFldOrigin, fOrigin ); } - EnableValueHdl(&aCbxAutoMin); - EnableValueHdl(&aCbxAutoMax); - EnableValueHdl(&aCbxAutoStepMain); - EnableValueHdl(&aCbxAutoStepHelp); - EnableValueHdl(&aCbxAutoOrigin); + if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_TIME_RESOLUTION,TRUE, &pPoolItem) == SFX_ITEM_SET) + m_aCbx_AutoTimeResolution.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); + if (rInAttrs.GetItemState(SCHATTR_AXIS_TIME_RESOLUTION,TRUE, &pPoolItem) == SFX_ITEM_SET) + { + m_nTimeResolution = ((const SfxInt32Item*)pPoolItem)->GetValue(); + m_aLB_TimeResolution.SelectEntryPos( m_nTimeResolution ); + } + + if (rInAttrs.GetItemState(SCHATTR_AXIS_MAIN_TIME_UNIT,TRUE, &pPoolItem) == SFX_ITEM_SET) + { + m_nMainTimeUnit = ((const SfxInt32Item*)pPoolItem)->GetValue(); + m_aLB_MainTimeUnit.SelectEntryPos( m_nMainTimeUnit ); + } + if (rInAttrs.GetItemState(SCHATTR_AXIS_HELP_TIME_UNIT,TRUE, &pPoolItem) == SFX_ITEM_SET) + { + m_nHelpTimeUnit = ((const SfxInt32Item*)pPoolItem)->GetValue(); + m_aLB_HelpTimeUnit.SelectEntryPos( m_nHelpTimeUnit ); + } + + EnableControls(); + SetNumFormat(); } int ScaleTabPage::DeactivatePage(SfxItemSet* pItemSet) @@ -347,6 +572,8 @@ int ScaleTabPage::DeactivatePage(SfxItemSet* pItemSet) return LEAVE_PAGE; } + bool bDateAxis = chart2::AxisType::DATE == m_nAxisType; + sal_uInt32 nIndex = pNumFormatter->GetStandardIndex(LANGUAGE_SYSTEM); const SfxPoolItem *pPoolItem = NULL; if( GetItemSet().GetItemState( SID_ATTR_NUMBERFORMAT_VALUE, TRUE, &pPoolItem ) == SFX_ITEM_SET ) @@ -356,75 +583,105 @@ int ScaleTabPage::DeactivatePage(SfxItemSet* pItemSet) OSL_ENSURE( false, "Using Standard Language" ); } - Edit* pEdit = NULL; + Control* pControl = NULL; USHORT nErrStrId = 0; double fDummy; fMax = aFmtFldMax.GetValue(); fMin = aFmtFldMin.GetValue(); fOrigin = aFmtFldOrigin.GetValue(); - fStepMain = aFmtFldStepMain.GetValue(); + fStepMain = bDateAxis ? m_aMt_MainDateStep.GetValue() : aFmtFldStepMain.GetValue(); nStepHelp = static_cast< sal_Int32 >( aMtStepHelp.GetValue()); + m_nTimeResolution = m_aLB_TimeResolution.GetSelectEntryPos(); + m_nMainTimeUnit = m_aLB_MainTimeUnit.GetSelectEntryPos(); + m_nHelpTimeUnit = m_aLB_HelpTimeUnit.GetSelectEntryPos(); + + if( chart2::AxisType::REALNUMBER != m_nAxisType ) + aCbxLogarithm.Show( false ); + + //check wich entries need user action - //do some reasonable automatic correction of user input if necessary - if (!aCbxAutoMax.IsChecked() && !aCbxAutoMin.IsChecked() && - fMin >= fMax) - { - pEdit = &aFmtFldMin; - nErrStrId = STR_MIN_GREATER_MAX; - } - // check for entries in invalid ranges if ( aCbxLogarithm.IsChecked() && ( ( !aCbxAutoMin.IsChecked() && fMin <= 0.0 ) || ( !aCbxAutoMax.IsChecked() && fMax <= 0.0 ) ) ) { - pEdit = &aFmtFldMin; + pControl = &aFmtFldMin; nErrStrId = STR_BAD_LOGARITHM; } - if (!aCbxAutoStepMain.IsChecked() && fStepMain <= 0) + else if (!aCbxAutoMax.IsChecked() && !aCbxAutoMin.IsChecked() && + fMin >= fMax) + { + pControl = &aFmtFldMin; + nErrStrId = STR_MIN_GREATER_MAX; + } + else if (!aCbxAutoStepMain.IsChecked() && fStepMain <= 0) { - pEdit = &aFmtFldStepMain; + pControl = &aFmtFldStepMain; nErrStrId = STR_STEP_GT_ZERO; } - - //check wich entries need user action - // check for entries that cannot be parsed for the current number format - if ( aFmtFldMin.IsModified() + else if ( aFmtFldMin.IsModified() && !aCbxAutoMin.IsChecked() && !pNumFormatter->IsNumberFormat(aFmtFldMin.GetText(), nIndex, fDummy)) { - pEdit = &aFmtFldMin; + pControl = &aFmtFldMin; nErrStrId = STR_INVALID_NUMBER; } else if (aFmtFldMax.IsModified() && !aCbxAutoMax.IsChecked() && !pNumFormatter->IsNumberFormat(aFmtFldMax.GetText(), nIndex, fDummy)) { - pEdit = &aFmtFldMax; + pControl = &aFmtFldMax; nErrStrId = STR_INVALID_NUMBER; } - else if (aFmtFldStepMain.IsModified() && !aCbxAutoStepMain.IsChecked() && + else if ( !bDateAxis && aFmtFldStepMain.IsModified() && !aCbxAutoStepMain.IsChecked() && !pNumFormatter->IsNumberFormat(aFmtFldStepMain.GetText(), nIndex, fDummy)) { - pEdit = &aFmtFldStepMain; + pControl = &aFmtFldStepMain; nErrStrId = STR_STEP_GT_ZERO; } else if (aFmtFldOrigin.IsModified() && !aCbxAutoOrigin.IsChecked() && !pNumFormatter->IsNumberFormat(aFmtFldOrigin.GetText(), nIndex, fDummy)) { - pEdit = &aFmtFldOrigin; + pControl = &aFmtFldOrigin; nErrStrId = STR_INVALID_NUMBER; } else if (!aCbxAutoStepMain.IsChecked() && fStepMain <= 0.0) { - pEdit = &aFmtFldStepMain; + pControl = &aFmtFldStepMain; nErrStrId = STR_STEP_GT_ZERO; } + else if( bDateAxis ) + { + if( !aCbxAutoStepMain.IsChecked() && !aCbxAutoStepHelp.IsChecked() ) + { + if( m_nHelpTimeUnit > m_nMainTimeUnit ) + { + pControl = &m_aLB_MainTimeUnit; + nErrStrId = STR_INVALID_INTERVALS; + } + else if( m_nHelpTimeUnit == m_nMainTimeUnit && nStepHelp > fStepMain ) + { + pControl = &m_aLB_MainTimeUnit; + nErrStrId = STR_INVALID_INTERVALS; + } + } + if( !nErrStrId && !m_aCbx_AutoTimeResolution.IsChecked() ) + { + if( (!aCbxAutoStepMain.IsChecked() && m_nTimeResolution > m_nMainTimeUnit ) + || + (!aCbxAutoStepHelp.IsChecked() && m_nTimeResolution > m_nHelpTimeUnit ) + ) + { + pControl = &m_aLB_TimeResolution; + nErrStrId = STR_INVALID_TIME_UNIT; + } + } + } - if( ShowWarning( nErrStrId, pEdit ) ) + if( ShowWarning( nErrStrId, pControl ) ) return KEEP_PAGE; if( pItemSet ) @@ -486,6 +743,19 @@ void ScaleTabPage::SetNumFormat() else nFmt = pNumFormatter->GetStandardFormat( NUMBERFORMAT_TIME ); } + + if( chart2::AxisType::DATE == m_nAxisType && ( eType != NUMBERFORMAT_DATE && eType != NUMBERFORMAT_DATETIME) ) + { + const SvNumberformat* pFormat = pNumFormatter->GetEntry( nFmt ); + if( pFormat ) + nFmt = pNumFormatter->GetStandardFormat( NUMBERFORMAT_DATE, pFormat->GetLanguage() ); + else + nFmt = pNumFormatter->GetStandardFormat( NUMBERFORMAT_DATE ); + + aFmtFldMax.SetFormatKey( nFmt ); + aFmtFldMin.SetFormatKey( nFmt ); + aFmtFldOrigin.SetFormatKey( nFmt ); + } } aFmtFldStepMain.SetFormatKey( nFmt ); @@ -499,7 +769,7 @@ void ScaleTabPage::ShowAxisOrigin( bool bShowOrigin ) m_bShowAxisOrigin = true; } -bool ScaleTabPage::ShowWarning( USHORT nResIdMessage, Edit * pControl /* = NULL */ ) +bool ScaleTabPage::ShowWarning( USHORT nResIdMessage, Control* pControl /* = NULL */ ) { if( nResIdMessage == 0 ) return false; @@ -508,7 +778,9 @@ bool ScaleTabPage::ShowWarning( USHORT nResIdMessage, Edit * pControl /* = NULL if( pControl ) { pControl->GrabFocus(); - pControl->SetSelection( Selection( 0, SELECTION_MAX )); + Edit* pEdit = dynamic_cast<Edit*>(pControl); + if(pEdit) + pEdit->SetSelection( Selection( 0, SELECTION_MAX )); } return true; } diff --git a/chart2/source/controller/dialogs/tp_Scale.hrc b/chart2/source/controller/dialogs/tp_Scale.hrc new file mode 100644 index 000000000000..bde6c21c7924 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_Scale.hrc @@ -0,0 +1,63 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "ResourceIds.hrc" + +#define FL_SCALE 1 + +#define TXT_MIN 1 +#define TXT_MAX 2 +#define TXT_STEP_MAIN 3 +#define TXT_STEP_HELP_COUNT 4 +#define TXT_ORIGIN 5 +#define TXT_TIME_RESOLUTION 6 +#define TXT_AXIS_TYPE 7 +#define TXT_STEP_HELP 8 + +#define CBX_AUTO_MIN 1 +#define CBX_AUTO_MAX 2 +#define CBX_AUTO_STEP_MAIN 3 +#define CBX_AUTO_STEP_HELP 4 +#define CBX_AUTO_ORIGIN 5 +#define CBX_LOGARITHM 6 +#define CBX_REVERSE 7 +#define CBX_AUTO_TIME_RESOLUTION 8 + +#define EDT_STEP_MAIN 1 +#define EDT_MAX 2 +#define EDT_MIN 3 +#define EDT_ORIGIN 4 + +#define MT_STEPHELP 10 +#define MT_MAIN_DATE_STEP 11 + +#define LB_AXIS_TYPE 1 +#define LB_MAIN_TIME_UNIT 2 +#define LB_HELP_TIME_UNIT 3 +#define LB_TIME_RESOLUTION 4 + +#define STR_LIST_TIME_UNIT 1 diff --git a/chart2/source/controller/dialogs/tp_Scale.hxx b/chart2/source/controller/dialogs/tp_Scale.hxx index 8d0e02186c38..ecfc42c2c513 100644 --- a/chart2/source/controller/dialogs/tp_Scale.hxx +++ b/chart2/source/controller/dialogs/tp_Scale.hxx @@ -37,6 +37,8 @@ #include <vcl/button.hxx> // header for MetricField #include <vcl/field.hxx> +// header for class ListBox +#include <vcl/lstbox.hxx> //............................................................................. namespace chart @@ -64,6 +66,13 @@ public: private: FixedLine aFlScale; + CheckBox aCbxReverse; + + CheckBox aCbxLogarithm; + + FixedText m_aTxt_AxisType; + ListBox m_aLB_AxisType; + FixedText aTxtMin; FormattedField aFmtFldMin; CheckBox aCbxAutoMin; @@ -72,35 +81,47 @@ private: FormattedField aFmtFldMax; CheckBox aCbxAutoMax; + FixedText m_aTxt_TimeResolution; + ListBox m_aLB_TimeResolution; + CheckBox m_aCbx_AutoTimeResolution; + FixedText aTxtMain; FormattedField aFmtFldStepMain; + MetricField m_aMt_MainDateStep; + ListBox m_aLB_MainTimeUnit; CheckBox aCbxAutoStepMain; + FixedText aTxtHelpCount; FixedText aTxtHelp; MetricField aMtStepHelp; + ListBox m_aLB_HelpTimeUnit; CheckBox aCbxAutoStepHelp; FixedText aTxtOrigin; FormattedField aFmtFldOrigin; CheckBox aCbxAutoOrigin; - CheckBox aCbxLogarithm; - CheckBox aCbxReverse; - double fMin; double fMax; double fStepMain; sal_Int32 nStepHelp; double fOrigin; - int nAxisType; + sal_Int32 m_nTimeResolution; + sal_Int32 m_nMainTimeUnit; + sal_Int32 m_nHelpTimeUnit; + int m_nAxisType; + bool m_bAllowDateAxis; SvNumberFormatter* pNumFormatter; bool m_bShowAxisOrigin; void AdjustControlPositions(); void EnableControls(); + void PlaceIntervalControlsAccordingToAxisType(); + DECL_LINK( SelectAxisTypeHdl, void* ); DECL_LINK( EnableValueHdl, CheckBox* ); + DECL_LINK( FmtFieldModifiedHdl, FormattedField* ); /** shows a warning window due to an invalid input. @@ -115,7 +136,7 @@ private: @return false, if nResIdMessage was 0, true otherwise */ - bool ShowWarning( USHORT nResIdMessage, Edit * pControl = NULL ); + bool ShowWarning( USHORT nResIdMessage, Control* pControl = NULL ); }; //............................................................................. diff --git a/chart2/source/controller/dialogs/tp_Scale.src b/chart2/source/controller/dialogs/tp_Scale.src index 9e92e70f6f43..0b0e7efcdb9c 100644..100755 --- a/chart2/source/controller/dialogs/tp_Scale.src +++ b/chart2/source/controller/dialogs/tp_Scale.src @@ -25,7 +25,7 @@ * ************************************************************************/ #include "HelpIds.hrc" -#include "TabPages.hrc" +#include "tp_Scale.hrc" #define YLine1 3 #define Y1 (YLine1+13) @@ -33,16 +33,26 @@ #define Y3 (Y2+16) #define Y4 (Y3+16) #define Y5 (Y4+16) -#define Y6 (Y5+17) -#define Y7 (Y6+15) +#define Y6 (Y5+16) +#define Y7 (Y6+16) +#define Y8 (Y7+16) #define LABELWIDTH 88 -#define AUTOCHECKWIDTH 88 +#define AUTOCHECKWIDTH 41 #define EDITWIDTH 50 #define X1 6 #define X2 11 #define X3 (X2+LABELWIDTH+4) #define X4 (X3+EDITWIDTH+5) +#define X5 (X4+AUTOCHECKWIDTH+5) + +#define STR_LIST_TIME_UNIT \ + StringList [ en-US ] = \ + { \ + "Days" ; \ + "Months" ; \ + "Years" ; \ + }; TabPage TP_SCALE { @@ -57,86 +67,201 @@ TabPage TP_SCALE Size = MAP_APPFONT ( 248 , 8 ) ; Text [ en-US ] = "Scale" ; }; - FixedText TXT_MIN + //--------------------------- + CheckBox CBX_REVERSE { + HelpID = "chart2:CheckBox:TP_SCALE:CBX_REVERSE:ValueAxis"; Pos = MAP_APPFONT ( X2 , Y1 ) ; + Size = MAP_APPFONT ( 244 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "~Reverse direction" ; + }; + //--------------------------- + CheckBox CBX_LOGARITHM + { + HelpID = "chart2:CheckBox:TP_SCALE:CBX_LOGARITHM"; + Pos = MAP_APPFONT ( X2 , Y2 ) ; + Size = MAP_APPFONT ( 244 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "~Logarithmic scale" ; + }; + //--------------------------- + FixedText TXT_AXIS_TYPE + { + Pos = MAP_APPFONT ( X2 , Y2 ) ; Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; - Text [ en-US ] = "~Minimum:" ; + Text [ en-US ] = "T~ype" ; + }; + ListBox LB_AXIS_TYPE + { + HelpID = "chart2:ListBox:TP_SCALE:LB_AXIS_TYPE"; + Border = TRUE ; + AutoHScroll = TRUE ; + Pos = MAP_APPFONT ( X3 , Y2-2 ) ; + Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; + TabStop = TRUE ; + Group = TRUE ; + DropDown=TRUE; + DDExtraWidth = TRUE ; + + StringList [ en-US ] = + { + "Automatic" ; + "Text" ; + "Date" ; + }; + }; + //--------------------------- + FixedText TXT_MIN + { + Pos = MAP_APPFONT ( X2 , Y3 ) ; + Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; + Text [ en-US ] = "~Minimum" ; }; SpinField EDT_MIN { HelpID = "chart2:SpinField:TP_SCALE:EDT_MIN"; Border = TRUE ; SVLook = TRUE ; - Pos = MAP_APPFONT ( X3 , Y1-2 ) ; + Pos = MAP_APPFONT ( X3 , Y3-2 ) ; Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; TabStop = TRUE ; }; CheckBox CBX_AUTO_MIN { HelpID = "chart2:CheckBox:TP_SCALE:CBX_AUTO_MIN"; - Pos = MAP_APPFONT ( X4 , Y1-1 ) ; + Pos = MAP_APPFONT ( X4 , Y3+1 ) ; Size = MAP_APPFONT ( AUTOCHECKWIDTH , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "~Automatic" ; }; - + //--------------------------- FixedText TXT_MAX { - Pos = MAP_APPFONT ( X2 , Y2 ) ; + Pos = MAP_APPFONT ( X2 , Y4 ) ; Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; - Text [ en-US ] = "Ma~ximum:" ; + Text [ en-US ] = "Ma~ximum" ; }; SpinField EDT_MAX { HelpID = "chart2:SpinField:TP_SCALE:EDT_MAX"; Border = TRUE ; SVLook = TRUE ; - Pos = MAP_APPFONT ( X3 , Y2-2 ) ; + Pos = MAP_APPFONT ( X3 , Y4-2 ) ; Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; TabStop = TRUE ; }; CheckBox CBX_AUTO_MAX { HelpID = "chart2:CheckBox:TP_SCALE:CBX_AUTO_MAX"; - Pos = MAP_APPFONT ( X4 , Y2-1 ) ; + Pos = MAP_APPFONT ( X4 , Y4+1 ) ; Size = MAP_APPFONT ( AUTOCHECKWIDTH , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "A~utomatic" ; }; + //--------------------------- + FixedText TXT_TIME_RESOLUTION + { + Pos = MAP_APPFONT ( X2 , Y5 ) ; + Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; + Text [ en-US ] = "R~esolution" ; + }; + ListBox LB_TIME_RESOLUTION + { + HelpID = "chart2:ListBox:TP_SCALE:LB_TIME_RESOLUTION"; + Border = TRUE ; + AutoHScroll = TRUE ; + Pos = MAP_APPFONT ( X3 , Y5-2 ) ; + Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; + TabStop = TRUE ; + Group = TRUE ; + DropDown=TRUE; + DDExtraWidth = TRUE ; + + STR_LIST_TIME_UNIT + }; + CheckBox CBX_AUTO_TIME_RESOLUTION + { + HelpID = "chart2:CheckBox:TP_SCALE:CBX_AUTO_TIME_RESOLUTION"; + Pos = MAP_APPFONT ( X4 , Y5+1 ) ; + Size = MAP_APPFONT ( AUTOCHECKWIDTH , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "Automat~ic" ; + }; + //--------------------------- FixedText TXT_STEP_MAIN { - Pos = MAP_APPFONT ( X2 , Y3 ) ; + Pos = MAP_APPFONT ( X2 , Y5 ) ; Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; - Text [ en-US ] = "Ma~jor interval:" ; + Text [ en-US ] = "Ma~jor interval" ; }; SpinField EDT_STEP_MAIN { HelpID = "chart2:SpinField:TP_SCALE:EDT_STEP_MAIN"; Border = TRUE ; - Pos = MAP_APPFONT ( X3 , Y3-2 ) ; + Pos = MAP_APPFONT ( X3 , Y5-2 ) ; Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; TabStop = TRUE ; }; + MetricField MT_MAIN_DATE_STEP + { + HelpID = "chart2:MetricField:TP_SCALE:MT_MAIN_DATE_STEP"; + Border = TRUE ; + Pos = MAP_APPFONT ( X3 , Y6-2 ) ; + Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + Minimum = 1 ; + Maximum = 100000 ; + StrictFormat = TRUE ; + Unit = FUNIT_CUSTOM ; + First = 1 ; + Last = 100000 ; + SpinSize = 1 ; + }; + + ListBox LB_MAIN_TIME_UNIT + { + HelpID = "chart2:ListBox:TP_SCALE:LB_MAIN_TIME_UNIT"; + Border = TRUE ; + AutoHScroll = TRUE ; + Pos = MAP_APPFONT ( X5 , Y6-2 ) ; + Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; + TabStop = TRUE ; + Group = TRUE ; + DropDown=TRUE; + DDExtraWidth = TRUE ; + + STR_LIST_TIME_UNIT + }; + CheckBox CBX_AUTO_STEP_MAIN { HelpID = "chart2:CheckBox:TP_SCALE:CBX_AUTO_STEP_MAIN"; - Pos = MAP_APPFONT ( X4 , Y3-1 ) ; + Pos = MAP_APPFONT ( X4 , Y5+1 ) ; Size = MAP_APPFONT ( AUTOCHECKWIDTH , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "Au~tomatic" ; }; + //--------------------------- + FixedText TXT_STEP_HELP_COUNT + { + Pos = MAP_APPFONT ( X2 , Y6 ) ; + Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; + Text [ en-US ] = "Minor inter~val count" ; + }; FixedText TXT_STEP_HELP { - Pos = MAP_APPFONT ( X2 , Y4 ) ; + Pos = MAP_APPFONT ( X2 , Y7 ) ; Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; - Text [ en-US ] = "Minor interval ~count:" ; + Text [ en-US ] = "Minor inter~val" ; }; MetricField MT_STEPHELP { HelpID = "chart2:MetricField:TP_SCALE:MT_STEPHELP"; Border = TRUE ; - Pos = MAP_APPFONT ( X3 , Y4-2 ) ; + Pos = MAP_APPFONT ( X3 , Y6-2 ) ; Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; TabStop = TRUE ; Repeat = TRUE ; @@ -149,55 +274,51 @@ TabPage TP_SCALE Last = 100 ; SpinSize = 1 ; }; + ListBox LB_HELP_TIME_UNIT + { + HelpID = "chart2:ListBox:TP_SCALE:LB_HELP_TIME_UNIT"; + Border = TRUE ; + AutoHScroll = TRUE ; + Pos = MAP_APPFONT ( X5 , Y7-2 ) ; + Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; + TabStop = TRUE ; + Group = TRUE ; + DropDown=TRUE; + DDExtraWidth = TRUE ; + + STR_LIST_TIME_UNIT + }; CheckBox CBX_AUTO_STEP_HELP { HelpID = "chart2:CheckBox:TP_SCALE:CBX_AUTO_STEP_HELP"; - Pos = MAP_APPFONT ( X4 , Y4-1 ) ; + Pos = MAP_APPFONT ( X4 , Y6+1 ) ; Size = MAP_APPFONT ( AUTOCHECKWIDTH , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "Aut~omatic" ; }; - + //--------------------------- FixedText TXT_ORIGIN { - Pos = MAP_APPFONT ( X2 , Y5 ) ; + Pos = MAP_APPFONT ( X2 , Y7 ) ; Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; - Text [ en-US ] = "Reference ~value:" ; + Text [ en-US ] = "Re~ference value" ; }; SpinField EDT_ORIGIN { HelpID = "chart2:SpinField:TP_SCALE:EDT_ORIGIN"; Border = TRUE ; SVLook = TRUE ; - Pos = MAP_APPFONT ( X3 , Y5-2 ) ; + Pos = MAP_APPFONT ( X3 , Y7-2 ) ; Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; TabStop = TRUE ; }; CheckBox CBX_AUTO_ORIGIN { HelpID = "chart2:CheckBox:TP_SCALE:CBX_AUTO_ORIGIN"; - Pos = MAP_APPFONT ( X4 , Y5-1 ) ; + Pos = MAP_APPFONT ( X4 , Y7+1 ) ; Size = MAP_APPFONT ( AUTOCHECKWIDTH , 10 ) ; TabStop = TRUE ; Text [ en-US ] = "Automat~ic" ; }; - - CheckBox CBX_LOGARITHM - { - HelpID = "chart2:CheckBox:TP_SCALE:CBX_LOGARITHM"; - Pos = MAP_APPFONT ( X2 , Y6 ) ; - Size = MAP_APPFONT ( 244 , 10 ) ; - TabStop = TRUE ; - Text [ en-US ] = "~Logarithmic scale" ; - }; - - CheckBox CBX_REVERSE - { - HelpID = "chart2:CheckBox:TP_SCALE:CBX_REVERSE"; - Pos = MAP_APPFONT ( X2 , Y7 ) ; - Size = MAP_APPFONT ( 244 , 10 ) ; - TabStop = TRUE ; - Text [ en-US ] = "~Reverse direction" ; - }; - + //--------------------------- }; diff --git a/chart2/source/controller/inc/AxisItemConverter.hxx b/chart2/source/controller/inc/AxisItemConverter.hxx index 7c8f83452963..647f82a9eb6a 100644 --- a/chart2/source/controller/inc/AxisItemConverter.hxx +++ b/chart2/source/controller/inc/AxisItemConverter.hxx @@ -27,8 +27,7 @@ #ifndef CHART_AXISITEMCONVERTER_HXX #define CHART_AXISITEMCONVERTER_HXX -#include <com/sun/star/chart2/ExplicitScaleData.hpp> -#include <com/sun/star/chart2/ExplicitIncrementData.hpp> +#include <chartview/ExplicitScaleValues.hxx> #include <com/sun/star/chart2/XAxis.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/awt/Size.hpp> @@ -55,8 +54,8 @@ public: SdrModel& rDrawModel, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xChartDoc, - ::com::sun::star::chart2::ExplicitScaleData * pScale = NULL, - ::com::sun::star::chart2::ExplicitIncrementData * pIncrement = NULL, + ExplicitScaleData * pScale = NULL, + ExplicitIncrementData * pIncrement = NULL, ::std::auto_ptr< ::com::sun::star::awt::Size > pRefSize = ::std::auto_ptr< ::com::sun::star::awt::Size >() ); virtual ~AxisItemConverter(); @@ -81,8 +80,8 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > m_xChartDoc; - ::com::sun::star::chart2::ExplicitScaleData * m_pExplicitScale; - ::com::sun::star::chart2::ExplicitIncrementData * m_pExplicitIncrement; + ExplicitScaleData* m_pExplicitScale; + ExplicitIncrementData* m_pExplicitIncrement; }; } // namespace wrapper diff --git a/chart2/source/controller/inc/DataPointItemConverter.hxx b/chart2/source/controller/inc/DataPointItemConverter.hxx index d738cf8f6245..c5072e26f648 100644 --- a/chart2/source/controller/inc/DataPointItemConverter.hxx +++ b/chart2/source/controller/inc/DataPointItemConverter.hxx @@ -29,7 +29,7 @@ #include "ItemConverter.hxx" #include "GraphicPropertyItemConverter.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include <com/sun/star/chart2/XDataSeries.hpp> #include <com/sun/star/awt/Size.hpp> diff --git a/chart2/source/controller/inc/ErrorBarItemConverter.hxx b/chart2/source/controller/inc/ErrorBarItemConverter.hxx index 9dffde68cd5b..484458a63a84 100755 --- a/chart2/source/controller/inc/ErrorBarItemConverter.hxx +++ b/chart2/source/controller/inc/ErrorBarItemConverter.hxx @@ -29,7 +29,7 @@ #include "ItemConverter.hxx" #include "GraphicPropertyItemConverter.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> diff --git a/chart2/source/controller/inc/StatisticsItemConverter.hxx b/chart2/source/controller/inc/StatisticsItemConverter.hxx index cb4227185093..cb706e92cc97 100644 --- a/chart2/source/controller/inc/StatisticsItemConverter.hxx +++ b/chart2/source/controller/inc/StatisticsItemConverter.hxx @@ -31,7 +31,7 @@ #include "ItemConverter.hxx" #include "GraphicPropertyItemConverter.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include <vector> diff --git a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx index 8cf07aabad08..b1f861461817 100644 --- a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx @@ -38,12 +38,14 @@ #include "ChartModelHelper.hxx" #include "AxisHelper.hxx" #include "CommonConverters.hxx" +#include "ChartTypeHelper.hxx" #include <com/sun/star/chart/ChartAxisLabelPosition.hpp> #include <com/sun/star/chart/ChartAxisMarkPosition.hpp> #include <com/sun/star/chart/ChartAxisPosition.hpp> #include <com/sun/star/chart2/XAxis.hpp> #include <com/sun/star/chart2/AxisOrientation.hpp> +#include <com/sun/star/chart2/AxisType.hpp> // for SfxBoolItem #include <svl/eitem.hxx> @@ -58,6 +60,8 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; using ::com::sun::star::uno::Reference; +using ::com::sun::star::chart::TimeInterval; +using ::com::sun::star::chart::TimeIncrement; namespace { @@ -65,13 +69,13 @@ namespace { static ::comphelper::ItemPropertyMapType aAxisPropertyMap( ::comphelper::MakeItemPropertyMap - IPM_MAP_ENTRY( SCHATTR_AXIS_SHOWDESCR, "DisplayLabels", 0 ) - IPM_MAP_ENTRY( SCHATTR_AXIS_TICKS, "MajorTickmarks", 0 ) - IPM_MAP_ENTRY( SCHATTR_AXIS_HELPTICKS, "MinorTickmarks", 0 ) - IPM_MAP_ENTRY( SCHATTR_TEXT_ORDER, "ArrangeOrder", 0 ) - IPM_MAP_ENTRY( SCHATTR_TEXT_STACKED, "StackCharacters", 0 ) - IPM_MAP_ENTRY( SCHATTR_TEXTBREAK, "TextBreak", 0 ) - IPM_MAP_ENTRY( SCHATTR_TEXT_OVERLAP, "TextOverlap", 0 ) + IPM_MAP_ENTRY( SCHATTR_AXIS_SHOWDESCR, "DisplayLabels", 0 ) + IPM_MAP_ENTRY( SCHATTR_AXIS_TICKS, "MajorTickmarks", 0 ) + IPM_MAP_ENTRY( SCHATTR_AXIS_HELPTICKS, "MinorTickmarks", 0 ) + IPM_MAP_ENTRY( SCHATTR_AXIS_LABEL_ORDER, "ArrangeOrder", 0 ) + IPM_MAP_ENTRY( SCHATTR_TEXT_STACKED, "StackCharacters", 0 ) + IPM_MAP_ENTRY( SCHATTR_AXIS_LABEL_BREAK, "TextBreak", 0 ) + IPM_MAP_ENTRY( SCHATTR_AXIS_LABEL_OVERLAP, "TextOverlap", 0 ) ); return aAxisPropertyMap; @@ -88,8 +92,8 @@ AxisItemConverter::AxisItemConverter( SfxItemPool& rItemPool, SdrModel& rDrawModel, const Reference< chart2::XChartDocument > & xChartDoc, - chart2::ExplicitScaleData * pScale /* = NULL */, - chart2::ExplicitIncrementData * pIncrement /* = NULL */, + ::chart::ExplicitScaleData * pScale /* = NULL */, + ::chart::ExplicitIncrementData * pIncrement /* = NULL */, ::std::auto_ptr< awt::Size > pRefSize /* = NULL */ ) : ItemConverter( rPropertySet, rItemPool ), m_xChartDoc( xChartDoc ), @@ -99,9 +103,9 @@ AxisItemConverter::AxisItemConverter( Reference< lang::XMultiServiceFactory > xNamedPropertyContainerFactory( xChartDoc, uno::UNO_QUERY ); if( pScale ) - m_pExplicitScale = new chart2::ExplicitScaleData( *pScale ); + m_pExplicitScale = new ::chart::ExplicitScaleData( *pScale ); if( pIncrement ) - m_pExplicitIncrement = new chart2::ExplicitIncrementData( *pIncrement ); + m_pExplicitIncrement = new ::chart::ExplicitIncrementData( *pIncrement ); m_aConverters.push_back( new GraphicPropertyItemConverter( rPropertySet, rItemPool, rDrawModel, @@ -162,30 +166,40 @@ bool AxisItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWit return true; } +bool lcl_hasTimeIntervalValue( const uno::Any& rAny ) +{ + bool bRet = false; + TimeInterval aValue; + if( rAny >>= aValue ) + bRet = true; + return bRet; +} + void AxisItemConverter::FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const throw( uno::Exception ) { - if( ! m_xAxis.is() ) + if( !m_xAxis.is() ) return; - const chart2::ScaleData aScale( m_xAxis->getScaleData() ); - const chart2::IncrementData aInc( aScale.IncrementData ); - const uno::Sequence< chart2::SubIncrement > aSubIncs( aScale.IncrementData.SubIncrements ); + const chart2::ScaleData& rScale( m_xAxis->getScaleData() ); + const chart2::IncrementData& rIncrement( rScale.IncrementData ); + const uno::Sequence< chart2::SubIncrement >& rSubIncrements( rScale.IncrementData.SubIncrements ); + const TimeIncrement& rTimeIncrement( rScale.TimeIncrement ); + bool bDateAxis = (chart2::AxisType::DATE == rScale.AxisType); + if( m_pExplicitScale ) + bDateAxis = (chart2::AxisType::DATE == m_pExplicitScale->AxisType); switch( nWhichId ) { case SCHATTR_AXIS_AUTO_MAX: - // if the any has no value => auto is on - rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(aScale.Maximum) ) ); + rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(rScale.Maximum) ) ); break; case SCHATTR_AXIS_MAX: { double fMax = 10.0; - if( aScale.Maximum >>= fMax ) - { + if( rScale.Maximum >>= fMax ) rOutItemSet.Put( SvxDoubleItem( fMax, nWhichId ) ); - } else { if( m_pExplicitScale ) @@ -196,106 +210,141 @@ void AxisItemConverter::FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemS break; case SCHATTR_AXIS_AUTO_MIN: - // if the any has no value => auto is on - rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(aScale.Minimum) ) ); + rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(rScale.Minimum) ) ); break; case SCHATTR_AXIS_MIN: { double fMin = 0.0; - if( aScale.Minimum >>= fMin ) - { + if( rScale.Minimum >>= fMin ) rOutItemSet.Put( SvxDoubleItem( fMin, nWhichId ) ); - } - else - { - if( m_pExplicitScale ) - rOutItemSet.Put( SvxDoubleItem( m_pExplicitScale->Minimum, nWhichId )); - } + else if( m_pExplicitScale ) + rOutItemSet.Put( SvxDoubleItem( m_pExplicitScale->Minimum, nWhichId )); } break; case SCHATTR_AXIS_LOGARITHM: - { - BOOL bValue = AxisHelper::isLogarithmic( aScale.Scaling ); - rOutItemSet.Put( SfxBoolItem( nWhichId, bValue )); - } - break; + { + BOOL bValue = AxisHelper::isLogarithmic( rScale.Scaling ); + rOutItemSet.Put( SfxBoolItem( nWhichId, bValue )); + } + break; case SCHATTR_AXIS_REVERSE: - rOutItemSet.Put( SfxBoolItem( nWhichId, (AxisOrientation_REVERSE == aScale.Orientation) )); + rOutItemSet.Put( SfxBoolItem( nWhichId, (AxisOrientation_REVERSE == rScale.Orientation) )); break; // Increment case SCHATTR_AXIS_AUTO_STEP_MAIN: - // if the any has no value => auto is on - rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(aInc.Distance) ) ); + if( bDateAxis ) + rOutItemSet.Put( SfxBoolItem( nWhichId, !lcl_hasTimeIntervalValue(rTimeIncrement.MajorTimeInterval) ) ); + else + rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(rIncrement.Distance) ) ); + break; + + case SCHATTR_AXIS_MAIN_TIME_UNIT: + { + TimeInterval aTimeInterval; + if( rTimeIncrement.MajorTimeInterval >>= aTimeInterval ) + rOutItemSet.Put( SfxInt32Item( nWhichId, aTimeInterval.TimeUnit ) ); + else if( m_pExplicitIncrement ) + rOutItemSet.Put( SfxInt32Item( nWhichId, m_pExplicitIncrement->MajorTimeInterval.TimeUnit ) ); + } break; case SCHATTR_AXIS_STEP_MAIN: + if( bDateAxis ) + { + TimeInterval aTimeInterval; + if( rTimeIncrement.MajorTimeInterval >>= aTimeInterval ) + rOutItemSet.Put( SvxDoubleItem(aTimeInterval.Number, nWhichId )); + else if( m_pExplicitIncrement ) + rOutItemSet.Put( SvxDoubleItem( m_pExplicitIncrement->MajorTimeInterval.Number, nWhichId )); + } + else { double fDistance = 1.0; - if( aInc.Distance >>= fDistance ) - { + if( rIncrement.Distance >>= fDistance ) rOutItemSet.Put( SvxDoubleItem(fDistance, nWhichId )); - } - else - { - if( m_pExplicitIncrement ) - rOutItemSet.Put( SvxDoubleItem( m_pExplicitIncrement->Distance, nWhichId )); - } + else if( m_pExplicitIncrement ) + rOutItemSet.Put( SvxDoubleItem( m_pExplicitIncrement->Distance, nWhichId )); } break; // SubIncrement case SCHATTR_AXIS_AUTO_STEP_HELP: - { - // if the any has no value => auto is on - rOutItemSet.Put( - SfxBoolItem( - nWhichId, - ! ( aSubIncs.getLength() > 0 && - aSubIncs[0].IntervalCount.hasValue() ))); - } - break; + if( bDateAxis ) + rOutItemSet.Put( SfxBoolItem( nWhichId, !lcl_hasTimeIntervalValue(rTimeIncrement.MinorTimeInterval) ) ); + else + rOutItemSet.Put( SfxBoolItem( nWhichId, + ! ( rSubIncrements.getLength() > 0 && rSubIncrements[0].IntervalCount.hasValue() ))); + break; + + case SCHATTR_AXIS_HELP_TIME_UNIT: + { + TimeInterval aTimeInterval; + if( rTimeIncrement.MinorTimeInterval >>= aTimeInterval ) + rOutItemSet.Put( SfxInt32Item( nWhichId, aTimeInterval.TimeUnit ) ); + else if( m_pExplicitIncrement ) + rOutItemSet.Put( SfxInt32Item( nWhichId, m_pExplicitIncrement->MinorTimeInterval.TimeUnit ) ); + } + break; case SCHATTR_AXIS_STEP_HELP: - { - if( aSubIncs.getLength() > 0 && - aSubIncs[0].IntervalCount.hasValue()) + if( bDateAxis ) { - OSL_ASSERT( aSubIncs[0].IntervalCount.getValueTypeClass() == uno::TypeClass_LONG ); - rOutItemSet.Put( - SfxInt32Item( - nWhichId, - *reinterpret_cast< const sal_Int32 * >( - aSubIncs[0].IntervalCount.getValue()) )); + TimeInterval aTimeInterval; + if( rTimeIncrement.MinorTimeInterval >>= aTimeInterval ) + rOutItemSet.Put( SfxInt32Item( nWhichId, aTimeInterval.Number )); + else if( m_pExplicitIncrement ) + rOutItemSet.Put( SfxInt32Item( nWhichId, m_pExplicitIncrement->MinorTimeInterval.Number )); } else { - if( m_pExplicitIncrement && - m_pExplicitIncrement->SubIncrements.getLength() > 0 ) + if( rSubIncrements.getLength() > 0 && rSubIncrements[0].IntervalCount.hasValue()) + { + OSL_ASSERT( rSubIncrements[0].IntervalCount.getValueTypeClass() == uno::TypeClass_LONG ); + rOutItemSet.Put( SfxInt32Item( nWhichId, + *reinterpret_cast< const sal_Int32 * >( + rSubIncrements[0].IntervalCount.getValue()) )); + } + else { - rOutItemSet.Put( - SfxInt32Item( - nWhichId, - m_pExplicitIncrement->SubIncrements[0].IntervalCount )); + if( m_pExplicitIncrement && !m_pExplicitIncrement->SubIncrements.empty() ) + { + rOutItemSet.Put( SfxInt32Item( nWhichId, + m_pExplicitIncrement->SubIncrements[0].IntervalCount )); + } } } - } - break; + break; + + case SCHATTR_AXIS_AUTO_TIME_RESOLUTION: + { + rOutItemSet.Put( SfxBoolItem( nWhichId, + !rTimeIncrement.TimeResolution.hasValue() )); + } + break; + case SCHATTR_AXIS_TIME_RESOLUTION: + { + long nTimeResolution=0; + if( rTimeIncrement.TimeResolution >>= nTimeResolution ) + rOutItemSet.Put( SfxInt32Item( nWhichId, nTimeResolution ) ); + else if( m_pExplicitScale ) + rOutItemSet.Put( SfxInt32Item( nWhichId, m_pExplicitScale->TimeResolution ) ); + } + break; case SCHATTR_AXIS_AUTO_ORIGIN: { - // if the any has no double value => auto is on - rOutItemSet.Put( SfxBoolItem( nWhichId, ( !hasDoubleValue(aScale.Origin) ))); + rOutItemSet.Put( SfxBoolItem( nWhichId, ( !hasDoubleValue(rScale.Origin) ))); } break; case SCHATTR_AXIS_ORIGIN: { double fOrigin = 0.0; - if( !(aScale.Origin >>= fOrigin) ) + if( !(rScale.Origin >>= fOrigin) ) { if( m_pExplicitScale ) fOrigin = m_pExplicitScale->Origin; @@ -367,7 +416,6 @@ void AxisItemConverter::FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemS break; case SID_ATTR_NUMBERFORMAT_VALUE: -// case SCHATTR_AXIS_NUMFMT: { if( m_pExplicitScale ) { @@ -391,11 +439,44 @@ void AxisItemConverter::FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemS break; case SCHATTR_AXISTYPE: - rOutItemSet.Put( SfxInt32Item( nWhichId, aScale.AxisType )); + rOutItemSet.Put( SfxInt32Item( nWhichId, rScale.AxisType )); + break; + + case SCHATTR_AXIS_AUTO_DATEAXIS: + rOutItemSet.Put( SfxBoolItem( nWhichId, rScale.AutoDateAxis )); + break; + + case SCHATTR_AXIS_ALLOW_DATEAXIS: + { + Reference< chart2::XCoordinateSystem > xCooSys( + AxisHelper::getCoordinateSystemOfAxis( m_xAxis, ChartModelHelper::findDiagram( m_xChartDoc ) ) ); + sal_Int32 nDimensionIndex=0; sal_Int32 nAxisIndex=0; + AxisHelper::getIndicesForAxis(m_xAxis, xCooSys, nDimensionIndex, nAxisIndex ); + bool bChartTypeAllowsDateAxis = ChartTypeHelper::isSupportingDateAxis( AxisHelper::getChartTypeByIndex( xCooSys, 0 ), 2, nDimensionIndex ); + rOutItemSet.Put( SfxBoolItem( nWhichId, bChartTypeAllowsDateAxis )); + } break; } } +bool lcl_isDateAxis( const SfxItemSet & rItemSet ) +{ + sal_Int32 nAxisType = static_cast< const SfxInt32Item & >( rItemSet.Get( SCHATTR_AXISTYPE )).GetValue();//::com::sun::star::chart2::AxisType + return (chart2::AxisType::DATE == nAxisType); +} + +bool lcl_isAutoMajor( const SfxItemSet & rItemSet ) +{ + bool bRet = static_cast< const SfxBoolItem & >( rItemSet.Get( SCHATTR_AXIS_AUTO_STEP_MAIN )).GetValue(); + return bRet; +} + +bool lcl_isAutoMinor( const SfxItemSet & rItemSet ) +{ + bool bRet = static_cast< const SfxBoolItem & >( rItemSet.Get( SCHATTR_AXIS_AUTO_STEP_HELP )).GetValue(); + return bRet; +} + bool AxisItemConverter::ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) throw( uno::Exception ) { @@ -502,23 +583,47 @@ bool AxisItemConverter::ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rI // Increment case SCHATTR_AXIS_AUTO_STEP_MAIN: - if( (static_cast< const SfxBoolItem & >( - rItemSet.Get( nWhichId )).GetValue() )) + if( lcl_isAutoMajor(rItemSet) ) { aScale.IncrementData.Distance.clear(); + aScale.TimeIncrement.MajorTimeInterval.clear(); bSetScale = true; } // else SCHATTR_AXIS_STEP_MAIN must have some value break; + case SCHATTR_AXIS_MAIN_TIME_UNIT: + if( !lcl_isAutoMajor(rItemSet) ) + { + if( rItemSet.Get( nWhichId ).QueryValue( aValue ) ) + { + TimeInterval aTimeInterval; + aScale.TimeIncrement.MajorTimeInterval >>= aTimeInterval; + aValue >>= aTimeInterval.TimeUnit; + aScale.TimeIncrement.MajorTimeInterval = uno::makeAny( aTimeInterval ); + bSetScale = true; + } + } + break; + case SCHATTR_AXIS_STEP_MAIN: // only if auto if false - if( ! (static_cast< const SfxBoolItem & >( - rItemSet.Get( SCHATTR_AXIS_AUTO_STEP_MAIN )).GetValue() )) + if( !lcl_isAutoMajor(rItemSet) ) { rItemSet.Get( nWhichId ).QueryValue( aValue ); - - if( aScale.IncrementData.Distance != aValue ) + if( lcl_isDateAxis(rItemSet) ) + { + double fValue = 1.0; + if( aValue >>= fValue ) + { + TimeInterval aTimeInterval; + aScale.TimeIncrement.MajorTimeInterval >>= aTimeInterval; + aTimeInterval.Number = static_cast<double>(fValue); + aScale.TimeIncrement.MajorTimeInterval = uno::makeAny( aTimeInterval ); + bSetScale = true; + } + } + else if( aScale.IncrementData.Distance != aValue ) { aScale.IncrementData.Distance = aValue; bSetScale = true; @@ -528,35 +633,85 @@ bool AxisItemConverter::ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rI // SubIncrement case SCHATTR_AXIS_AUTO_STEP_HELP: - if( (static_cast< const SfxBoolItem & >( - rItemSet.Get( nWhichId )).GetValue() ) && - aScale.IncrementData.SubIncrements.getLength() > 0 && - aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() ) + if( lcl_isAutoMinor(rItemSet) ) { - aScale.IncrementData.SubIncrements[0].IntervalCount.clear(); + if( aScale.IncrementData.SubIncrements.getLength() > 0 && + aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() ) + { + aScale.IncrementData.SubIncrements[0].IntervalCount.clear(); + bSetScale = true; + } + if( aScale.TimeIncrement.MinorTimeInterval.hasValue() ) + { + aScale.TimeIncrement.MinorTimeInterval.clear(); bSetScale = true; + } } // else SCHATTR_AXIS_STEP_MAIN must have some value break; + case SCHATTR_AXIS_HELP_TIME_UNIT: + if( !lcl_isAutoMinor(rItemSet) ) + { + if( rItemSet.Get( nWhichId ).QueryValue( aValue ) ) + { + TimeInterval aTimeInterval; + aScale.TimeIncrement.MinorTimeInterval >>= aTimeInterval; + aValue >>= aTimeInterval.TimeUnit; + aScale.TimeIncrement.MinorTimeInterval = uno::makeAny( aTimeInterval ); + bSetScale = true; + } + } + break; + case SCHATTR_AXIS_STEP_HELP: - // only if auto if false - if( ! (static_cast< const SfxBoolItem & >( - rItemSet.Get( SCHATTR_AXIS_AUTO_STEP_HELP )).GetValue() ) && - aScale.IncrementData.SubIncrements.getLength() > 0 ) + // only if auto is false + if( !lcl_isAutoMinor(rItemSet) ) + { + rItemSet.Get( nWhichId ).QueryValue( aValue ); + if( lcl_isDateAxis(rItemSet) ) + { + TimeInterval aTimeInterval; + aScale.TimeIncrement.MinorTimeInterval >>= aTimeInterval; + aValue >>= aTimeInterval.Number; + aScale.TimeIncrement.MinorTimeInterval = uno::makeAny(aTimeInterval); + bSetScale = true; + } + else if( aScale.IncrementData.SubIncrements.getLength() > 0 ) + { + if( ! aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() || + aScale.IncrementData.SubIncrements[0].IntervalCount != aValue ) + { + OSL_ASSERT( aValue.getValueTypeClass() == uno::TypeClass_LONG ); + aScale.IncrementData.SubIncrements[0].IntervalCount = aValue; + bSetScale = true; + } + } + } + break; + + case SCHATTR_AXIS_AUTO_TIME_RESOLUTION: + if( (static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue() )) + { + aScale.TimeIncrement.TimeResolution.clear(); + bSetScale = true; + } + break; + case SCHATTR_AXIS_TIME_RESOLUTION: + // only if auto is false + if( ! (static_cast< const SfxBoolItem & >( rItemSet.Get( SCHATTR_AXIS_AUTO_TIME_RESOLUTION )).GetValue() )) { rItemSet.Get( nWhichId ).QueryValue( aValue ); - if( ! aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() || - aScale.IncrementData.SubIncrements[0].IntervalCount != aValue ) + if( aScale.TimeIncrement.TimeResolution != aValue ) { - OSL_ASSERT( aValue.getValueTypeClass() == uno::TypeClass_LONG ); - aScale.IncrementData.SubIncrements[0].IntervalCount = aValue; + aScale.TimeIncrement.TimeResolution = aValue; bSetScale = true; } } break; + case SCHATTR_AXIS_AUTO_ORIGIN: { if( (static_cast< const SfxBoolItem & >( @@ -757,7 +912,6 @@ bool AxisItemConverter::ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rI break; case SID_ATTR_NUMBERFORMAT_VALUE: -// case SCHATTR_AXIS_NUMFMT: { if( m_pExplicitScale ) { @@ -821,7 +975,23 @@ bool AxisItemConverter::ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rI break; case SCHATTR_AXISTYPE: - //don't allow to change the axis type so far + { + sal_Int32 nNewAxisType = static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue();//::com::sun::star::chart2::AxisType + aScale.AxisType = nNewAxisType; + bSetScale = true; + } + break; + + case SCHATTR_AXIS_AUTO_DATEAXIS: + { + bool bNewValue = static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue(); + bool bOldValue = aScale.AutoDateAxis; + if( bOldValue != bNewValue ) + { + aScale.AutoDateAxis = bNewValue; + bSetScale = true; + } + } break; } diff --git a/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx b/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx index f7ddeb42c11e..139283b92e23 100644 --- a/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx +++ b/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx @@ -45,8 +45,7 @@ namespace const USHORT nTitleWhichPairs[] = { - SCHATTR_TEXT_STACKED, SCHATTR_TEXT_STACKED, // 4 sch/schattr.hxx - SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES, // 53 sch/schattr.hxx + SCHATTR_TEXT_START, SCHATTR_TEXT_END, XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1018 - 1046 svx/xdef.hxx SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST, // 1067 - 1078 svx/svddef.hxx @@ -60,24 +59,17 @@ const USHORT nAxisWhichPairs[] = CHARACTER_WHICHPAIRS, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_VALUE, // 10585 - 10585 svx/svxids.hrc SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE, // 11432 svx/svxids.hrc - SCHATTR_AXISTYPE, SCHATTR_AXISTYPE, // 39 sch/schattr.hxx - SCHATTR_TEXT_START, SCHATTR_TEXT_END, // 4 - 6 sch/schattr.hxx - SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES, // 53 sch/schattr.hxx - SCHATTR_TEXT_OVERLAP, SCHATTR_TEXT_OVERLAP, // 54 sch/schattr.hxx - SCHATTR_AXIS_START, SCHATTR_AXIS_END, // 70 - 95 sch/schattr.hxx - SCHATTR_TEXTBREAK, SCHATTR_TEXTBREAK, // 30587 sch/schattr.hxx + SCHATTR_AXIS_START, SCHATTR_AXIS_END, + SCHATTR_TEXT_START, SCHATTR_TEXT_END, 0 }; const USHORT nAllAxisWhichPairs[] = { - XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx + XATTR_LINE_FIRST, XATTR_LINE_LAST, CHARACTER_WHICHPAIRS, - SCHATTR_TEXT_START, SCHATTR_TEXT_END, // 4 - 6 sch/schattr.hxx - SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES, // 53 sch/schattr.hxx - SCHATTR_TEXT_OVERLAP, SCHATTR_TEXT_OVERLAP, // 54 sch/schattr.hxx - SCHATTR_AXIS_SHOWDESCR, SCHATTR_AXIS_SHOWDESCR, // 85 sch/schattr.hxx - SCHATTR_TEXTBREAK, SCHATTR_TEXTBREAK, // 30587 sch/schattr.hxx + SCHATTR_AXIS_LABEL_START, SCHATTR_AXIS_LABEL_END, + SCHATTR_TEXT_START, SCHATTR_TEXT_END, 0 }; @@ -102,8 +94,6 @@ const USHORT nDataLabelWhichPairs[] = SCHATTR_DATADESCR_START, SCHATTR_DATADESCR_END, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO, /* 10585 - 10585 svx/svxids.hrc */ \ SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE, /* 11432 svx/svxids.hrc */ \ - SCHATTR_PERCENT_NUMBERFORMAT_VALUE, SCHATTR_PERCENT_NUMBERFORMAT_VALUE, /* 40 sch/schattr.hxx*/ \ - SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, /* 41 sch/schattr.hxx*/ \ SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES, EE_PARA_WRITINGDIR,EE_PARA_WRITINGDIR, 0 @@ -117,8 +107,6 @@ const USHORT nDataLabelWhichPairs[] = SCHATTR_DATADESCR_START, SCHATTR_DATADESCR_END, /* 1 - 2 sch/schattr.hxx*/ \ SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO, /* 10585 - 10585 svx/svxids.hrc */ \ SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE, /* 11432 svx/svxids.hrc */ \ - SCHATTR_PERCENT_NUMBERFORMAT_VALUE, SCHATTR_PERCENT_NUMBERFORMAT_VALUE, /* 40 sch/schattr.hxx*/ \ - SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, /* 41 sch/schattr.hxx*/ \ SCHATTR_TEXT_DEGREES, SCHATTR_TEXT_DEGREES, \ SCHATTR_STYLE_START,SCHATTR_STYLE_END, /* 59 - 68 sch/schattr.hxx*/ \ SCHATTR_SYMBOL_BRUSH,SCHATTR_SYMBOL_BRUSH, /* 94 sch/schattr.hxx*/ \ @@ -165,16 +153,14 @@ const USHORT nAreaWhichPairs[] = const USHORT nTextWhichPairs[] = { CHARACTER_WHICHPAIRS, - SCHATTR_TEXT_STACKED, SCHATTR_TEXT_STACKED, // 4 sch/schattr.hxx - SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES, // 53 sch/schattr.hxx + SCHATTR_TEXT_START, SCHATTR_TEXT_END, 0 }; const USHORT nTextOrientWhichPairs[] = { CHARACTER_WHICHPAIRS, - SCHATTR_TEXT_STACKED, SCHATTR_TEXT_STACKED, // 4 sch/schattr.hxx - SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES, // 53 sch/schattr.hxx + SCHATTR_TEXT_START, SCHATTR_TEXT_END, 0 }; diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index 675bcf40e7a2..ac3ef57a1bd9 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -49,17 +49,15 @@ #include "macros.hxx" #include "dlg_CreationWizard.hxx" #include "dlg_ChartType.hxx" -//#include "svx/ActionDescriptionProvider.hxx" #include "AccessibleChartView.hxx" #include "DrawCommandDispatch.hxx" #include "ShapeController.hxx" -#include "UndoManager.hxx" +#include "UndoActions.hxx" #include <comphelper/InlineContainer.hxx> #include <com/sun/star/awt/PosSize.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> -#include <com/sun/star/chart2/XUndoSupplier.hpp> #include <com/sun/star/chart2/data/XDataReceiver.hpp> #include <com/sun/star/frame/XLoadable.hpp> #include <com/sun/star/util/XCloneable.hpp> @@ -67,6 +65,8 @@ #include <com/sun/star/util/XModeChangeBroadcaster.hpp> #include <com/sun/star/util/XModifyBroadcaster.hpp> #include <com/sun/star/frame/LayoutManagerEvents.hpp> +#include <com/sun/star/document/XUndoManagerSupplier.hpp> +#include <com/sun/star/document/XUndoAction.hpp> //------- // header for define RET_OK @@ -86,6 +86,7 @@ // object in the DTOR #include <svtools/acceleratorexecute.hxx> #include <svx/ActionDescriptionProvider.hxx> +#include <tools/diagnose_ex.h> // enable the following define to let the controller listen to model changes and // react on this by rebuilding the view @@ -133,7 +134,6 @@ ChartController::ChartController(uno::Reference<uno::XComponentContext> const & , m_eDrawMode( CHARTDRAW_SELECT ) { DBG_CTOR(ChartController,NULL); -// m_aDispatchContainer.setUndoManager( m_xUndoManager ); m_aDoubleClickTimer.SetTimeoutHdl( LINK( this, ChartController, DoubleClickWaitingHdl ) ); } @@ -622,9 +622,8 @@ void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent m_pChartWindow->Invalidate(); } - uno::Reference< chart2::XUndoSupplier > xUndoSupplier( getModel(), uno::UNO_QUERY ); - if( xUndoSupplier.is()) - m_xUndoManager.set( xUndoSupplier->getUndoManager()); + uno::Reference< document::XUndoManagerSupplier > xSuppUndo( getModel(), uno::UNO_QUERY_THROW ); + m_xUndoManager.set( xSuppUndo->getUndoManager(), uno::UNO_QUERY_THROW ); return sal_True; } @@ -1335,7 +1334,7 @@ void SAL_CALL ChartController::executeDispatch_ChartType() { // using assignment for broken gcc 3.3 UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard( - ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_CHARTTYPE ))), m_xUndoManager, getModel() ); + String( SchResId( STR_ACTION_EDIT_CHARTTYPE )), m_xUndoManager ); // /-- ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); @@ -1344,7 +1343,7 @@ void SAL_CALL ChartController::executeDispatch_ChartType() if( aDlg.Execute() == RET_OK ) { impl_adaptDataSeriesAutoResize(); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } // \-- } @@ -1360,7 +1359,7 @@ void SAL_CALL ChartController::executeDispatch_SourceData() // using assignment for broken gcc 3.3 UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard( - ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_DATA_RANGES ))), m_xUndoManager, getModel() ); + String( SchResId( STR_ACTION_EDIT_DATA_RANGES )), m_xUndoManager ); if( xChartDoc.is()) { // /-- @@ -1369,7 +1368,7 @@ void SAL_CALL ChartController::executeDispatch_SourceData() if( aDlg.Execute() == RET_OK ) { impl_adaptDataSeriesAutoResize(); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } // \-- } @@ -1387,14 +1386,14 @@ void SAL_CALL ChartController::executeDispatch_MoveSeries( sal_Bool bForward ) UndoGuardWithSelection aUndoGuard( ActionDescriptionProvider::createDescription( (bForward ? ActionDescriptionProvider::MOVE_TOTOP : ActionDescriptionProvider::MOVE_TOBOTTOM), - ::rtl::OUString( String( SchResId( STR_OBJECT_DATASERIES )))), - m_xUndoManager, getModel()); + String( SchResId( STR_OBJECT_DATASERIES ))), + m_xUndoManager ); bool bChanged = DiagramHelper::moveSeries( ChartModelHelper::findDiagram( getModel() ), xGivenDataSeries, bForward ); if( bChanged ) { m_aSelection.setSelection( ObjectIdentifier::getMovedSeriesCID( aObjectCID, bForward ) ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } @@ -1454,13 +1453,21 @@ void SAL_CALL ChartController::modified( const lang::EventObject& /* aEvent */ ) IMPL_LINK( ChartController, NotifyUndoActionHdl, SdrUndoAction*, pUndoAction ) { + ENSURE_OR_RETURN( pUndoAction, "invalid Undo action", 1L ); + ::rtl::OUString aObjectCID = m_aSelection.getSelectedCID(); if ( aObjectCID.getLength() == 0 ) { - UndoManager* pUndoManager = UndoManager::getImplementation( m_xUndoManager ); - if ( pUndoManager ) + try + { + const Reference< document::XUndoManagerSupplier > xSuppUndo( getModel(), uno::UNO_QUERY_THROW ); + const Reference< document::XUndoManager > xUndoManager( xSuppUndo->getUndoManager(), uno::UNO_QUERY_THROW ); + const Reference< document::XUndoAction > xAction( new impl::ShapeUndoElement( *pUndoAction ) ); + xUndoManager->addUndoAction( xAction ); + } + catch( const uno::Exception& ) { - pUndoManager->addShapeUndoAction( pUndoAction ); + DBG_UNHANDLED_EXCEPTION(); } } return 0L; diff --git a/chart2/source/controller/main/ChartController.hxx b/chart2/source/controller/main/ChartController.hxx index f2b64eb7a9c5..7c06a4ad4ca2 100644 --- a/chart2/source/controller/main/ChartController.hxx +++ b/chart2/source/controller/main/ChartController.hxx @@ -42,7 +42,7 @@ #include <cppuhelper/implbase12.hxx> #include <com/sun/star/accessibility/XAccessible.hpp> -#include <com/sun/star/chart2/XUndoManager.hpp> +#include <com/sun/star/document/XUndoManager.hpp> #include <com/sun/star/frame/XController.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/frame/XDispatch.hpp> @@ -89,6 +89,8 @@ namespace chart { //............................................................................. +class UndoGuard; + enum ChartDrawMode { CHARTDRAW_INSERT, CHARTDRAW_SELECT }; class WindowController @@ -578,7 +580,8 @@ private: bool volatile m_bConnectingToView; - ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XUndoManager > m_xUndoManager; + ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > m_xUndoManager; + ::std::auto_ptr< UndoGuard > m_pTextActionUndoGuard; /// needed for dispatching URLs in FeatureStateEvents mutable ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer; diff --git a/chart2/source/controller/main/ChartController_EditData.cxx b/chart2/source/controller/main/ChartController_EditData.cxx index 0248732a63a7..7c9bfe0c3986 100644 --- a/chart2/source/controller/main/ChartController_EditData.cxx +++ b/chart2/source/controller/main/ChartController_EditData.cxx @@ -66,12 +66,12 @@ void ChartController::executeDispatch_EditData() ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); // using assignment for broken gcc 3.3 UndoLiveUpdateGuardWithData aUndoGuard = UndoLiveUpdateGuardWithData( - ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_CHART_DATA ))), - m_xUndoManager, getModel() ); + String( SchResId( STR_ACTION_EDIT_CHART_DATA )), + m_xUndoManager ); DataEditor aDataEditorDialog( pParent, xChartDoc, m_xCC ); // the dialog has no OK/Cancel aDataEditorDialog.Execute(); - aUndoGuard.commitAction(); + aUndoGuard.commit(); // \-- } } diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx index 0a7a4057ef9a..b6928ac99284 100644 --- a/chart2/source/controller/main/ChartController_Insert.cxx +++ b/chart2/source/controller/main/ChartController_Insert.cxx @@ -44,7 +44,7 @@ #include "DiagramHelper.hxx" #include "macros.hxx" #include "chartview/DrawModelWrapper.hxx" -#include "chartview/NumberFormatterWrapper.hxx" +#include "NumberFormatterWrapper.hxx" #include "ViewElementListProvider.hxx" #include "MultipleChartConverters.hxx" #include "ControllerLockGuard.hxx" @@ -121,8 +121,8 @@ void ChartController::executeDispatch_InsertAxes() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_AXES )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_AXES ))), + m_xUndoManager ); try { @@ -146,7 +146,7 @@ void ChartController::executeDispatch_InsertAxes() , aDialogInput.aExistenceList, aDialogOutput.aExistenceList, m_xCC , mpRefSizeProvider.get() ); if( bChanged ) - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } catch( uno::RuntimeException& e) @@ -159,8 +159,8 @@ void ChartController::executeDispatch_InsertGrid() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_GRIDS )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_GRIDS ))), + m_xUndoManager ); try { @@ -180,7 +180,7 @@ void ChartController::executeDispatch_InsertGrid() bool bChanged = AxisHelper::changeVisibilityOfGrids( xDiagram , aDialogInput.aExistenceList, aDialogOutput.aExistenceList, m_xCC ); if( bChanged ) - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } catch( uno::RuntimeException& e) @@ -196,8 +196,8 @@ void ChartController::executeDispatch_InsertTitles() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_TITLES )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_TITLES ))), + m_xUndoManager ); try { @@ -214,7 +214,7 @@ void ChartController::executeDispatch_InsertTitles() aDlg.getResult( aDialogOutput ); bool bChanged = aDialogOutput.writeDifferenceToModel( getModel(), m_xCC, &aDialogInput ); if( bChanged ) - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } catch( uno::RuntimeException& e) @@ -227,30 +227,30 @@ void ChartController::executeDispatch_DeleteLegend() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_LEGEND )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_LEGEND ))), + m_xUndoManager ); LegendHelper::hideLegend( getModel() ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } void ChartController::executeDispatch_InsertLegend() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_LEGEND )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_LEGEND ))), + m_xUndoManager ); Reference< chart2::XLegend > xLegend = LegendHelper::showLegend( getModel(), m_xCC ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } void ChartController::executeDispatch_OpenLegendDialog() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_LEGEND )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_LEGEND ))), + m_xUndoManager ); try { @@ -264,7 +264,7 @@ void ChartController::executeDispatch_OpenLegendDialog() ControllerLockGuard aCLGuard( getModel() ); bool bChanged = aDlg.writeToModel( getModel() ); if( bChanged ) - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } catch( uno::RuntimeException& e) @@ -280,8 +280,8 @@ void ChartController::executeDispatch_InsertMenu_DataLabels() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_DATALABELS )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_DATALABELS ))), + m_xUndoManager ); //if a series is selected insert labels for that series only: uno::Reference< chart2::XDataSeries > xSeries( @@ -298,7 +298,7 @@ void ChartController::executeDispatch_InsertMenu_DataLabels() bool bSuccess = ChartController::executeDlg_ObjectProperties_withoutUndoGuard( aObjectCID, true ); if( bSuccess ) - aUndoGuard.commitAction(); + aUndoGuard.commit(); return; } @@ -330,7 +330,7 @@ void ChartController::executeDispatch_InsertMenu_DataLabels() ControllerLockGuard aCLGuard( getModel() ); bool bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now if( bChanged ) - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } catch( uno::RuntimeException& e) @@ -354,7 +354,7 @@ void ChartController::executeDispatch_InsertMenu_YErrorBars() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_ERRORS ) ), - m_xUndoManager, getModel() ); + m_xUndoManager ); try { @@ -380,7 +380,7 @@ void ChartController::executeDispatch_InsertMenu_YErrorBars() ControllerLockGuard aCLGuard( getModel() ); bool bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now if( bChanged ) - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } catch( uno::RuntimeException& e) @@ -393,19 +393,19 @@ void ChartController::executeDispatch_InsertMeanValue() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_AVERAGE_LINE )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_AVERAGE_LINE ))), + m_xUndoManager ); lcl_InsertMeanValueLine( m_xCC ).operator()( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() )); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } void ChartController::executeDispatch_InsertMenu_MeanValues() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_AVERAGE_LINE )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_AVERAGE_LINE ))), + m_xUndoManager ); uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY ); @@ -420,7 +420,7 @@ void ChartController::executeDispatch_InsertMenu_MeanValues() DiagramHelper::getDataSeriesFromDiagram( ChartModelHelper::findDiagram( getModel() ))); ::std::for_each( aSeries.begin(), aSeries.end(), lcl_InsertMeanValueLine( m_xCC )); } - aUndoGuard.commitAction(); + aUndoGuard.commit(); } void ChartController::executeDispatch_InsertMenu_Trendlines() @@ -437,7 +437,7 @@ void ChartController::executeDispatch_InsertMenu_Trendlines() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_CURVE ) ), - m_xUndoManager, getModel() ); + m_xUndoManager ); try { @@ -460,7 +460,7 @@ void ChartController::executeDispatch_InsertMenu_Trendlines() ControllerLockGuard aCLGuard( getModel() ); bool bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now if( bChanged ) - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } catch( uno::RuntimeException& e) @@ -477,8 +477,8 @@ void ChartController::executeDispatch_InsertTrendline() { UndoLiveUpdateGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE ))), + m_xUndoManager ); // add a linear curve RegressionCurveHelper::addRegressionCurve( @@ -518,7 +518,7 @@ void ChartController::executeDispatch_InsertTrendline() ControllerLockGuard aCLGuard( getModel() ); aItemConverter.ApplyItemSet( *pOutItemSet ); } - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } } @@ -531,8 +531,8 @@ void ChartController::executeDispatch_InsertYErrorBars() { UndoLiveUpdateGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_ERROR_BARS )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_ERROR_BARS ))), + m_xUndoManager ); // add error bars with standard deviation uno::Reference< beans::XPropertySet > xErrorBarProp( @@ -568,7 +568,7 @@ void ChartController::executeDispatch_InsertYErrorBars() ControllerLockGuard aCLGuard( getModel() ); aItemConverter.ApplyItemSet( *pOutItemSet ); } - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } } @@ -591,11 +591,11 @@ void ChartController::executeDispatch_InsertTrendlineEquation( bool bInsertR2 ) // using assignment for broken gcc 3.3 UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE_EQUATION ))), + m_xUndoManager ); xEqProp->setPropertyValue( C2U("ShowEquation"), uno::makeAny( true )); xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( bInsertR2 )); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } } @@ -608,10 +608,10 @@ void ChartController::executeDispatch_InsertR2Value() { UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE_EQUATION ))), + m_xUndoManager ); xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( true )); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } @@ -623,10 +623,10 @@ void ChartController::executeDispatch_DeleteR2Value() { UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_CURVE_EQUATION ))), + m_xUndoManager ); xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( false )); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } @@ -638,10 +638,10 @@ void ChartController::executeDispatch_DeleteMeanValue() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_AVERAGE_LINE )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_AVERAGE_LINE ))), + m_xUndoManager ); RegressionCurveHelper::removeMeanValueLine( xRegCurveCnt ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } @@ -653,10 +653,10 @@ void ChartController::executeDispatch_DeleteTrendline() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_CURVE ))), + m_xUndoManager ); RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCurveCnt ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } @@ -668,10 +668,10 @@ void ChartController::executeDispatch_DeleteTrendlineEquation() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_CURVE_EQUATION ))), + m_xUndoManager ); RegressionCurveHelper::removeEquations( xRegCurveCnt ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } @@ -683,10 +683,10 @@ void ChartController::executeDispatch_DeleteYErrorBars() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_CURVE ))), + m_xUndoManager ); StatisticsHelper::removeErrorBars( xDataSeries ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } @@ -697,20 +697,20 @@ void ChartController::executeDispatch_InsertDataLabels() if( xSeries.is() ) { UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, - ::rtl::OUString( String( SchResId( STR_OBJECT_DATALABELS )))), - m_xUndoManager, getModel() ); + String( SchResId( STR_OBJECT_DATALABELS ))), + m_xUndoManager ); DataSeriesHelper::insertDataLabelsToSeriesAndAllPoints( xSeries ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } void ChartController::executeDispatch_InsertDataLabel() { UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, - ::rtl::OUString( String( SchResId( STR_OBJECT_LABEL )))), - m_xUndoManager, getModel() ); + String( SchResId( STR_OBJECT_LABEL ))), + m_xUndoManager ); DataSeriesHelper::insertDataLabelToPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getModel() ) ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } void ChartController::executeDispatch_DeleteDataLabels() @@ -720,44 +720,44 @@ void ChartController::executeDispatch_DeleteDataLabels() if( xSeries.is() ) { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, - ::rtl::OUString( String( SchResId( STR_OBJECT_DATALABELS )))), - m_xUndoManager, getModel() ); + String( SchResId( STR_OBJECT_DATALABELS ))), + m_xUndoManager ); DataSeriesHelper::deleteDataLabelsFromSeriesAndAllPoints( xSeries ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } void ChartController::executeDispatch_DeleteDataLabel() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, - ::rtl::OUString( String( SchResId( STR_OBJECT_LABEL )))), - m_xUndoManager, getModel() ); + String( SchResId( STR_OBJECT_LABEL ))), + m_xUndoManager ); DataSeriesHelper::deleteDataLabelsFromPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getModel() ) ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } void ChartController::executeDispatch_ResetAllDataPoints() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::FORMAT, - ::rtl::OUString( String( SchResId( STR_OBJECT_DATAPOINTS )))), - m_xUndoManager, getModel() ); + String( SchResId( STR_OBJECT_DATAPOINTS ))), + m_xUndoManager ); uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY ); if( xSeries.is() ) xSeries->resetAllDataPoints(); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } void ChartController::executeDispatch_ResetDataPoint() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::FORMAT, - ::rtl::OUString( String( SchResId( STR_OBJECT_DATAPOINT )))), - m_xUndoManager, getModel() ); + String( SchResId( STR_OBJECT_DATAPOINT ))), + m_xUndoManager ); uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY ); if( xSeries.is() ) { sal_Int32 nPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( m_aSelection.getSelectedCID() ); xSeries->resetDataPoint( nPointIndex ); } - aUndoGuard.commitAction(); + aUndoGuard.commit(); } void ChartController::executeDispatch_InsertAxisTitle() @@ -768,8 +768,8 @@ void ChartController::executeDispatch_InsertAxisTitle() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_TITLE )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_TITLE ))), + m_xUndoManager ); Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getModel() ); sal_Int32 nDimensionIndex = -1; @@ -787,7 +787,7 @@ void ChartController::executeDispatch_InsertAxisTitle() ::std::auto_ptr< ReferenceSizeProvider > apRefSizeProvider( impl_createReferenceSizeProvider()); xTitle = TitleHelper::createTitle( eTitleType, ObjectNameProvider::getTitleNameByType(eTitleType), getModel(), m_xCC, apRefSizeProvider.get() ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } /* @@ -809,8 +809,8 @@ void ChartController::executeDispatch_InsertAxis() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_AXIS )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_AXIS ))), + m_xUndoManager ); try { @@ -818,7 +818,7 @@ void ChartController::executeDispatch_InsertAxis() if( xAxis.is() ) { AxisHelper::makeAxisVisible( xAxis ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } catch( uno::RuntimeException& e) @@ -831,8 +831,8 @@ void ChartController::executeDispatch_DeleteAxis() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_AXIS )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_AXIS ))), + m_xUndoManager ); try { @@ -840,7 +840,7 @@ void ChartController::executeDispatch_DeleteAxis() if( xAxis.is() ) { AxisHelper::makeAxisInvisible( xAxis ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } catch( uno::RuntimeException& e) @@ -853,8 +853,8 @@ void ChartController::executeDispatch_InsertMajorGrid() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_GRID )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_GRID ))), + m_xUndoManager ); try { @@ -862,7 +862,7 @@ void ChartController::executeDispatch_InsertMajorGrid() if( xAxis.is() ) { AxisHelper::makeGridVisible( xAxis->getGridProperties() ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } catch( uno::RuntimeException& e) @@ -875,8 +875,8 @@ void ChartController::executeDispatch_DeleteMajorGrid() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_GRID )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_GRID ))), + m_xUndoManager ); try { @@ -884,7 +884,7 @@ void ChartController::executeDispatch_DeleteMajorGrid() if( xAxis.is() ) { AxisHelper::makeGridInvisible( xAxis->getGridProperties() ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } catch( uno::RuntimeException& e) @@ -897,8 +897,8 @@ void ChartController::executeDispatch_InsertMinorGrid() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_GRID )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::INSERT, String( SchResId( STR_OBJECT_GRID ))), + m_xUndoManager ); try { @@ -908,7 +908,7 @@ void ChartController::executeDispatch_InsertMinorGrid() Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() ); for( sal_Int32 nN=0; nN<aSubGrids.getLength(); nN++) AxisHelper::makeGridVisible( aSubGrids[nN] ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } catch( uno::RuntimeException& e) @@ -921,8 +921,8 @@ void ChartController::executeDispatch_DeleteMinorGrid() { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_GRID )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_GRID ))), + m_xUndoManager ); try { @@ -932,7 +932,7 @@ void ChartController::executeDispatch_DeleteMinorGrid() Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() ); for( sal_Int32 nN=0; nN<aSubGrids.getLength(); nN++) AxisHelper::makeGridInvisible( aSubGrids[nN] ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } catch( uno::RuntimeException& e) diff --git a/chart2/source/controller/main/ChartController_Position.cxx b/chart2/source/controller/main/ChartController_Position.cxx index 619d308ffad2..ceb6877e64e9 100644 --- a/chart2/source/controller/main/ChartController_Position.cxx +++ b/chart2/source/controller/main/ChartController_Position.cxx @@ -139,7 +139,7 @@ void SAL_CALL ChartController::executeDispatch_PositionAndSize() ActionDescriptionProvider::createDescription( ActionDescriptionProvider::POS_SIZE, ObjectNameProvider::getName( ObjectIdentifier::getObjectType( aCID ))), - m_xUndoManager, getModel() ); + m_xUndoManager ); SfxAbstractTabDialog * pDlg = NULL; try @@ -174,7 +174,7 @@ void SAL_CALL ChartController::executeDispatch_PositionAndSize() , awt::Rectangle(aObjectRect.getX(),aObjectRect.getY(),aObjectRect.getWidth(),aObjectRect.getHeight()) , awt::Rectangle(aPageRect.getX(),aPageRect.getY(),aPageRect.getWidth(),aPageRect.getHeight()) ); if( bChanged ) - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } delete pDlg; diff --git a/chart2/source/controller/main/ChartController_Properties.cxx b/chart2/source/controller/main/ChartController_Properties.cxx index 649b9cb62f9d..29f1bfa9f389 100644 --- a/chart2/source/controller/main/ChartController_Properties.cxx +++ b/chart2/source/controller/main/ChartController_Properties.cxx @@ -720,11 +720,11 @@ void SAL_CALL ChartController::executeDlg_ObjectProperties( const ::rtl::OUStrin UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::FORMAT, ObjectNameProvider::getName( ObjectIdentifier::getObjectType( aObjectCID ))), - m_xUndoManager, getModel() ); + m_xUndoManager ); bool bSuccess = ChartController::executeDlg_ObjectProperties_withoutUndoGuard( aObjectCID, false ); if( bSuccess ) - aUndoGuard.commitAction(); + aUndoGuard.commit(); } bool ChartController::executeDlg_ObjectProperties_withoutUndoGuard( const ::rtl::OUString& rObjectCID, bool bOkClickOnUnchangedDialogSouldBeRatedAsSuccessAlso ) @@ -838,15 +838,15 @@ void SAL_CALL ChartController::executeDispatch_View3D() { // using assignment for broken gcc 3.3 UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard( - ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_3D_VIEW ))), - m_xUndoManager, getModel()); + String( SchResId( STR_ACTION_EDIT_3D_VIEW )), + m_xUndoManager ); // /-- //open dialog ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); View3DDialog aDlg( m_pChartWindow, getModel(), m_pDrawModelWrapper->GetColorTable() ); if( aDlg.Execute() == RET_OK ) - aUndoGuard.commitAction(); + aUndoGuard.commit(); // \-- } catch( uno::RuntimeException& e) diff --git a/chart2/source/controller/main/ChartController_TextEdit.cxx b/chart2/source/controller/main/ChartController_TextEdit.cxx index 6091fd8ef3f8..9354c911ad67 100644 --- a/chart2/source/controller/main/ChartController_TextEdit.cxx +++ b/chart2/source/controller/main/ChartController_TextEdit.cxx @@ -29,6 +29,8 @@ #include "precompiled_chart2.hxx" #include "ChartController.hxx" +#include "ResId.hxx" +#include "UndoGuard.hxx" #include "DrawViewWrapper.hxx" #include "ChartWindow.hxx" #include "TitleHelper.hxx" @@ -36,6 +38,7 @@ #include "macros.hxx" #include "ControllerLockGuard.hxx" #include "AccessibleTextHelper.hxx" +#include "Strings.hrc" #include "chartview/DrawModelWrapper.hxx" #include <svx/svdotext.hxx> @@ -81,7 +84,9 @@ void ChartController::StartTextEdit( const Point* pMousePixel ) if(!pTextObj) return; - m_xUndoManager->preAction( getModel()); + OSL_PRECOND( !m_pTextActionUndoGuard.get(), "ChartController::StartTextEdit: already have a TextUndoGuard!?" ); + m_pTextActionUndoGuard.reset( new UndoGuard( + String( SchResId( STR_ACTION_EDIT_TEXT ) ), m_xUndoManager ) ); SdrOutliner* pOutliner = m_pDrawViewWrapper->getOutliner(); //pOutliner->SetRefDevice(m_pChartWindow); //pOutliner->SetStyleSheetPool((SfxStyleSheetPool*)pStyleSheetPool); @@ -165,26 +170,11 @@ bool ChartController::EndTextEdit() TitleHelper::setCompleteString( aString, uno::Reference< ::com::sun::star::chart2::XTitle >::query( xPropSet ), m_xCC ); - try - { - m_xUndoManager->postAction( C2U("Edit Text") ); - } - catch( uno::RuntimeException& e) - { - ASSERT_EXCEPTION( e ); - } - } - else - { - try - { - m_xUndoManager->cancelAction(); - } - catch ( uno::RuntimeException& e ) - { - ASSERT_EXCEPTION( e ); - } + OSL_ENSURE( m_pTextActionUndoGuard.get(), "ChartController::EndTextEdit: no TextUndoGuard!" ); + if ( m_pTextActionUndoGuard.get() ) + m_pTextActionUndoGuard->commit(); } + m_pTextActionUndoGuard.reset(); } return true; } diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx index 735cb9634671..945ccf4b4b34 100644 --- a/chart2/source/controller/main/ChartController_Tools.cxx +++ b/chart2/source/controller/main/ChartController_Tools.cxx @@ -102,7 +102,7 @@ namespace bool lcl_deleteDataSeries( const OUString & rCID, const Reference< frame::XModel > & xModel, - const Reference< chart2::XUndoManager > & xUndoManager ) + const Reference< document::XUndoManager > & xUndoManager ) { bool bResult = false; uno::Reference< chart2::XDataSeries > xSeries( ::chart::ObjectIdentifier::getDataSeriesForCID( rCID, xModel )); @@ -115,8 +115,8 @@ bool lcl_deleteDataSeries( { ::chart::UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( ::chart::SchResId( STR_OBJECT_DATASERIES )))), - xUndoManager, xModel ); + ActionDescriptionProvider::DELETE, String( ::chart::SchResId( STR_OBJECT_DATASERIES ))), + xUndoManager ); Reference< chart2::XDiagram > xDiagram( ::chart::ChartModelHelper::findDiagram( xModel ) ); uno::Reference< chart2::XAxis > xAxis( ::chart::DiagramHelper::getAttachedAxis( xSeries, xDiagram ) ); @@ -126,7 +126,7 @@ bool lcl_deleteDataSeries( ::chart::AxisHelper::hideAxisIfNoDataIsAttached( xAxis, xDiagram ); bResult = true; - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } return bResult; @@ -135,7 +135,7 @@ bool lcl_deleteDataSeries( bool lcl_deleteDataCurve( const OUString & rCID, const Reference< frame::XModel > & xModel, - const Reference< chart2::XUndoManager > & xUndoManager ) + const Reference< document::XUndoManager > & xUndoManager ) { bool bResult = false; uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( @@ -145,11 +145,11 @@ bool lcl_deleteDataCurve( { ::chart::UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( ::chart::SchResId( STR_OBJECT_CURVE )))), - xUndoManager, xModel ); + ActionDescriptionProvider::DELETE, String( ::chart::SchResId( STR_OBJECT_CURVE ))), + xUndoManager ); ::chart::RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCurveCnt ); bResult = true; - aUndoGuard.commitAction(); + aUndoGuard.commit(); } return bResult; } @@ -235,8 +235,8 @@ void ChartController::executeDispatch_NewArrangement() { // using assignment for broken gcc 3.3 UndoGuard aUndoGuard = UndoGuard( - ::rtl::OUString( String( SchResId( STR_ACTION_REARRANGE_CHART ))), - m_xUndoManager, xModel ); + String( SchResId( STR_ACTION_REARRANGE_CHART )), + m_xUndoManager ); ControllerLockGuard aCtlLockGuard( xModel ); // diagram @@ -271,7 +271,7 @@ void ChartController::executeDispatch_NewArrangement() ::std::for_each( aRegressionCurves.begin(), aRegressionCurves.end(), RegressionCurveHelper::resetEquationPosition ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } catch( uno::RuntimeException & ex ) @@ -285,14 +285,14 @@ void ChartController::executeDispatch_ScaleText() ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); // using assignment for broken gcc 3.3 UndoGuard aUndoGuard = UndoGuard( - ::rtl::OUString( String( SchResId( STR_ACTION_SCALE_TEXT ))), - m_xUndoManager, getModel() ); + String( SchResId( STR_ACTION_SCALE_TEXT )), + m_xUndoManager ); ControllerLockGuard aCtlLockGuard( getModel() ); ::std::auto_ptr< ReferenceSizeProvider > apRefSizeProv( impl_createReferenceSizeProvider()); OSL_ASSERT( apRefSizeProv.get()); if( apRefSizeProv.get()) apRefSizeProv->toggleAutoResizeState(); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } void ChartController::executeDispatch_Paste() @@ -655,12 +655,12 @@ bool ChartController::executeDispatch_Delete() // using assignment for broken gcc 3.3 UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_TITLE )))), - m_xUndoManager, getModel()); + ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_TITLE ))), + m_xUndoManager ); TitleHelper::removeTitle( ObjectIdentifier::getTitleTypeForCID( aCID ), getModel() ); bReturn = true; - aUndoGuard.commitAction(); + aUndoGuard.commit(); break; } case OBJECTTYPE_LEGEND: @@ -674,11 +674,11 @@ bool ChartController::executeDispatch_Delete() // using assignment for broken gcc 3.3 UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_LEGEND )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_LEGEND ))), + m_xUndoManager ); xLegendProp->setPropertyValue( C2U("Show"), uno::makeAny( false )); bReturn = true; - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } break; @@ -709,11 +709,11 @@ bool ChartController::executeDispatch_Delete() // using assignment for broken gcc 3.3 UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_AVERAGE_LINE )))), - m_xUndoManager, getModel() ); + ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_AVERAGE_LINE ))), + m_xUndoManager ); RegressionCurveHelper::removeMeanValueLine( xRegCurveCnt ); bReturn = true; - aUndoGuard.commitAction(); + aUndoGuard.commit(); } break; } @@ -732,15 +732,15 @@ bool ChartController::executeDispatch_Delete() // using assignment for broken gcc 3.3 UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))), - m_xUndoManager, xModel ); + ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_CURVE_EQUATION ))), + m_xUndoManager ); { ControllerLockGuard aCtlLockGuard( xModel ); xEqProp->setPropertyValue( C2U("ShowEquation"), uno::makeAny( false )); xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( false )); } bReturn = true; - aUndoGuard.commitAction(); + aUndoGuard.commit(); } break; } @@ -755,8 +755,8 @@ bool ChartController::executeDispatch_Delete() // using assignment for broken gcc 3.3 UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_ERROR_BARS )))), - m_xUndoManager, xModel ); + ActionDescriptionProvider::DELETE, String( SchResId( STR_OBJECT_ERROR_BARS ))), + m_xUndoManager ); { ControllerLockGuard aCtlLockGuard( xModel ); xErrorBarProp->setPropertyValue( @@ -764,7 +764,7 @@ bool ChartController::executeDispatch_Delete() uno::makeAny( ::com::sun::star::chart::ErrorBarStyle::NONE )); } bReturn = true; - aUndoGuard.commitAction(); + aUndoGuard.commit(); } break; } @@ -780,7 +780,7 @@ bool ChartController::executeDispatch_Delete() ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( aObjectType == OBJECTTYPE_DATA_LABEL ? STR_OBJECT_LABEL : STR_OBJECT_DATALABELS )))), - m_xUndoManager, getModel() ); + m_xUndoManager ); chart2::DataPointLabel aLabel; xObjectProperties->getPropertyValue( C2U( "Label" ) ) >>= aLabel; aLabel.ShowNumber = false; @@ -795,7 +795,7 @@ bool ChartController::executeDispatch_Delete() else xObjectProperties->setPropertyValue( C2U( "Label" ), uno::makeAny(aLabel) ); bReturn = true; - aUndoGuard.commitAction(); + aUndoGuard.commit(); } break; } @@ -844,7 +844,7 @@ void ChartController::executeDispatch_ToggleLegend() { Reference< frame::XModel > xModel( getModel() ); UndoGuard aUndoGuard = UndoGuard( - ::rtl::OUString( String( SchResId( STR_ACTION_TOGGLE_LEGEND ))), m_xUndoManager, xModel ); + String( SchResId( STR_ACTION_TOGGLE_LEGEND )), m_xUndoManager ); Reference< beans::XPropertySet > xLegendProp( LegendHelper::getLegend( xModel ), uno::UNO_QUERY ); bool bChanged = false; if( xLegendProp.is()) @@ -871,14 +871,14 @@ void ChartController::executeDispatch_ToggleLegend() } if( bChanged ) - aUndoGuard.commitAction(); + aUndoGuard.commit(); } void ChartController::executeDispatch_ToggleGridHorizontal() { Reference< frame::XModel > xModel( getModel() ); UndoGuard aUndoGuard = UndoGuard( - ::rtl::OUString( String( SchResId( STR_ACTION_TOGGLE_GRID_HORZ ))), m_xUndoManager, xModel ); + String( SchResId( STR_ACTION_TOGGLE_GRID_HORZ )), m_xUndoManager ); Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( getModel() )); if( xDiagram.is()) { @@ -893,7 +893,7 @@ void ChartController::executeDispatch_ToggleGridHorizontal() else AxisHelper::showGrid( nDimensionIndex, nCooSysIndex, bIsMainGrid, xDiagram, m_xCC ); - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } @@ -911,9 +911,9 @@ void ChartController::impl_switchDiagramPositioningToExcludingPositioning() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::POS_SIZE, ObjectNameProvider::getName( OBJECTTYPE_DIAGRAM)), - m_xUndoManager, m_aModel->getModel() ); + m_xUndoManager ); if( DiagramHelper::switchDiagramPositioningToExcludingPositioning( m_aModel->getModel(), true, true ) ) - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } // namespace chart diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index 885e37126dc2..0a81048d771b 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -801,7 +801,11 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) if ( m_eDrawMode == CHARTDRAW_INSERT && pDrawViewWrapper->IsCreateObj() ) { pDrawViewWrapper->EndCreateObj( SDRCREATE_FORCEEND ); - impl_switchDiagramPositioningToExcludingPositioning(); + { + HiddenUndoContext aUndoContext( m_xUndoManager ); + // don't want the positioning Undo action to appear in the UI + impl_switchDiagramPositioningToExcludingPositioning(); + } if ( pDrawViewWrapper->AreObjectsMarked() ) { if ( pDrawViewWrapper->GetCurrentObjIdentifier() == OBJ_TEXT ) @@ -838,12 +842,12 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) if( pChartDragMethod ) { UndoGuard aUndoGuard( pChartDragMethod->getUndoDescription(), - m_xUndoManager, getModel() ); + m_xUndoManager ); if( pDrawViewWrapper->EndDragObj(false) ) { bDraggingDone = true; - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } @@ -871,7 +875,7 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) ActionDescriptionProvider::createDescription( eActionType, ObjectNameProvider::getName( ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() ))), - m_xUndoManager, getModel() ); + m_xUndoManager ); bool bChanged = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID() , getModel() , awt::Rectangle(aObjectRect.getX(),aObjectRect.getY(),aObjectRect.getWidth(),aObjectRect.getHeight()) @@ -879,7 +883,7 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) if( bChanged ) { bDraggingDone = true; - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } } @@ -1832,7 +1836,7 @@ bool ChartController::impl_moveOrResizeObject( ObjectType eObjectType = ObjectIdentifier::getObjectType( rCID ); UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - eActionType, ObjectNameProvider::getName( eObjectType )), m_xUndoManager, xChartModel ); + eActionType, ObjectNameProvider::getName( eObjectType )), m_xUndoManager ); { ControllerLockGuard aCLGuard( xChartModel ); if( bNeedShift ) @@ -1840,7 +1844,7 @@ bool ChartController::impl_moveOrResizeObject( if( bNeedResize || (eObjectType == OBJECTTYPE_DIAGRAM) )//Also set an explicat size at the diagram when an explicit position is set xObjProp->setPropertyValue( C2U("RelativeSize"), uno::makeAny( aRelSize )); } - aUndoGuard.commitAction(); + aUndoGuard.commit(); } } return bResult; diff --git a/chart2/source/controller/main/ChartDropTargetHelper.cxx b/chart2/source/controller/main/ChartDropTargetHelper.cxx index 8749ca1bc062..fd7dc3ad1744 100644 --- a/chart2/source/controller/main/ChartDropTargetHelper.cxx +++ b/chart2/source/controller/main/ChartDropTargetHelper.cxx @@ -137,58 +137,47 @@ sal_Int8 ChartDropTargetHelper::ExecuteDrop( const ExecuteDropEvent& rEvt ) // parent) if( bDataComesFromParent ) { + Reference< chart2::XDiagram > xDiagram( m_xChartDocument->getFirstDiagram() ); Reference< chart2::data::XDataProvider > xDataProvider( m_xChartDocument->getDataProvider()); - if( xDataProvider.is() && + if( xDataProvider.is() && xDiagram.is() && DataSourceHelper::allArgumentsForRectRangeDetected( m_xChartDocument )) { - DiagramHelper::tTemplateWithServiceName aTempWithServ( - DiagramHelper::getTemplateForDiagram( - m_xChartDocument->getFirstDiagram(), - Reference< lang::XMultiServiceFactory >( - m_xChartDocument->getChartTypeManager(), uno::UNO_QUERY ))); - if( aTempWithServ.first.is()) + Reference< chart2::data::XDataSource > xDataSource( + DataSourceHelper::pressUsedDataIntoRectangularFormat( m_xChartDocument )); + Sequence< beans::PropertyValue > aArguments( + xDataProvider->detectArguments( xDataSource )); + + OUString aOldRange; + beans::PropertyValue * pCellRange = 0; + for( sal_Int32 i=0; i<aArguments.getLength(); ++i ) { - Reference< chart2::data::XDataSource > xDataSource( - DataSourceHelper::pressUsedDataIntoRectangularFormat( m_xChartDocument )); - Sequence< beans::PropertyValue > aArguments( - xDataProvider->detectArguments( xDataSource )); - - OUString aOldRange; - beans::PropertyValue * pCellRange = 0; - for( sal_Int32 i=0; i<aArguments.getLength(); ++i ) + if( aArguments[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("CellRangeRepresentation"))) { - if( aArguments[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("CellRangeRepresentation"))) - { - pCellRange = (aArguments.getArray() + i); - aArguments[i].Value >>= aOldRange; - break; - } + pCellRange = (aArguments.getArray() + i); + aArguments[i].Value >>= aOldRange; + break; } - if( pCellRange ) + } + if( pCellRange ) + { + // copy means add ranges, move means replace + if( rEvt.mnAction == DND_ACTION_COPY ) + { + // @todo: using implcit knowledge that ranges can be + // merged with ";". This should be done more general + pCellRange->Value <<= (aOldRange + OUString( sal_Unicode(';')) + aRangeString ); + } + // move means replace range + else { - // copy means add ranges, move means replace - if( rEvt.mnAction == DND_ACTION_COPY ) - { - // @todo: using implcit knowledge that ranges can be - // merged with ";". This should be done more general - pCellRange->Value <<= (aOldRange + OUString( sal_Unicode(';')) + aRangeString ); - } - // move means replace range - else - { - pCellRange->Value <<= aRangeString; - } - - xDataSource.set( xDataProvider->createDataSource( aArguments )); - aTempWithServ.first->changeDiagramData( - m_xChartDocument->getFirstDiagram(), - xDataSource, - aArguments ); - - // always return copy state to avoid deletion of the - // dragged range - nResult = DND_ACTION_COPY; + pCellRange->Value <<= aRangeString; } + + xDataSource.set( xDataProvider->createDataSource( aArguments )); + xDiagram->setDiagramData( xDataSource, aArguments ); + + // always return copy state to avoid deletion of the dragged range + nResult = DND_ACTION_COPY; } } } diff --git a/chart2/source/controller/main/ChartModelClone.cxx b/chart2/source/controller/main/ChartModelClone.cxx new file mode 100755 index 000000000000..69991eb081df --- /dev/null +++ b/chart2/source/controller/main/ChartModelClone.cxx @@ -0,0 +1,280 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_chart2.hxx" + +#include "ChartModelClone.hxx" +#include "ChartModelHelper.hxx" +#include "ControllerLockGuard.hxx" +#include "DataSourceHelper.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/chart2/XAnyDescriptionAccess.hpp> +#include <com/sun/star/util/XCloneable.hpp> +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/chart2/XTitled.hpp> +#include <com/sun/star/util/XModifiable.hpp> +#include <com/sun/star/chart2/data/XDataSource.hpp> +#include <com/sun/star/chart2/data/XLabeledDataSequence.hpp> +/** === end UNO includes === **/ + +#include <comphelper/property.hxx> +#include <tools/diagnose_ex.h> + +//...................................................................................................................... +namespace chart +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::frame::XModel; + using ::com::sun::star::util::XCloneable; + using ::com::sun::star::chart2::XChartDocument; + using ::com::sun::star::chart2::XInternalDataProvider; + using ::com::sun::star::chart2::XAnyDescriptionAccess; + using ::com::sun::star::view::XSelectionSupplier; + using ::com::sun::star::lang::XComponent; + using ::com::sun::star::chart2::XTitled; + using ::com::sun::star::util::XModifiable; + using ::com::sun::star::chart2::data::XDataSource; + using ::com::sun::star::chart2::data::XLabeledDataSequence; + /** === end UNO using === **/ + + // ================================================================================================================= + // = helper + // ================================================================================================================= + namespace + { + Reference< XModel > lcl_cloneModel( const Reference< XModel > & xModel ) + { + Reference< XModel > xResult; + try + { + const Reference< XCloneable > xCloneable( xModel, UNO_QUERY_THROW ); + xResult.set( xCloneable->createClone(), UNO_QUERY_THROW ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return xResult; + } + + } + + // ================================================================================================================= + // = ChartModelClone + // ================================================================================================================= + // ----------------------------------------------------------------------------------------------------------------- + ChartModelClone::ChartModelClone( const Reference< XModel >& i_model, const ModelFacet i_facet ) + { + m_xModelClone.set( lcl_cloneModel( i_model ) ); + + try + { + if ( i_facet == E_MODEL_WITH_DATA ) + { + const Reference< XChartDocument > xChartDoc( m_xModelClone, UNO_QUERY_THROW ); + ENSURE_OR_THROW( xChartDoc->hasInternalDataProvider(), "invalid chart model" ); + + const Reference< XCloneable > xCloneable( xChartDoc->getDataProvider(), UNO_QUERY_THROW ); + m_xDataClone.set( xCloneable->createClone(), UNO_QUERY_THROW ); + } + + if ( i_facet == E_MODEL_WITH_SELECTION ) + { + const Reference< XSelectionSupplier > xSelSupp( m_xModelClone->getCurrentController(), UNO_QUERY_THROW ); + m_aSelection = xSelSupp->getSelection(); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + + // ----------------------------------------------------------------------------------------------------------------- + ChartModelClone::~ChartModelClone() + { + if ( !impl_isDisposed() ) + dispose(); + } + + // ----------------------------------------------------------------------------------------------------------------- + void ChartModelClone::dispose() + { + if ( impl_isDisposed() ) + return; + + try + { + Reference< XComponent > xComp( m_xModelClone, UNO_QUERY_THROW ); + xComp->dispose(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + m_xModelClone.clear(); + m_xDataClone.clear(); + m_aSelection.clear(); + } + + // ----------------------------------------------------------------------------------------------------------------- + ModelFacet ChartModelClone::getFacet() const + { + if ( m_aSelection.hasValue() ) + return E_MODEL_WITH_SELECTION; + if ( m_xDataClone.is() ) + return E_MODEL_WITH_DATA; + return E_MODEL; + } + + // ----------------------------------------------------------------------------------------------------------------- + void ChartModelClone::applyToModel( const Reference< XModel >& i_model ) const + { + applyModelContentToModel( i_model, m_xModelClone, m_xDataClone ); + + if ( m_aSelection.hasValue() ) + { + try + { + Reference< XSelectionSupplier > xCurrentSelectionSuppl( i_model->getCurrentController(), UNO_QUERY_THROW ); + xCurrentSelectionSuppl->select( m_aSelection ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + } + + // ----------------------------------------------------------------------------------------------------------------- + namespace + { + void ImplApplyDataToModel( const Reference< XModel >& i_model, const Reference< XInternalDataProvider > & i_data ) + { + Reference< XChartDocument > xDoc( i_model, UNO_QUERY ); + OSL_ASSERT( xDoc.is() && xDoc->hasInternalDataProvider() ); + + // copy data from stored internal data provider + if( xDoc.is() && xDoc->hasInternalDataProvider()) + { + Reference< XAnyDescriptionAccess > xCurrentData( xDoc->getDataProvider(), UNO_QUERY ); + Reference< XAnyDescriptionAccess > xSavedData( i_data, UNO_QUERY ); + if ( xCurrentData.is() && xSavedData.is() ) + { + xCurrentData->setData( xSavedData->getData() ); + xCurrentData->setAnyRowDescriptions( xSavedData->getAnyRowDescriptions()); + xCurrentData->setAnyColumnDescriptions( xSavedData->getAnyColumnDescriptions()); + } + } + } + } + + // ----------------------------------------------------------------------------------------------------------------- + void ChartModelClone::applyModelContentToModel( const Reference< XModel >& i_model, + const Reference< XModel >& i_modelToCopyFrom, const Reference< XInternalDataProvider >& i_data ) + { + ENSURE_OR_RETURN_VOID( i_model.is(), "ChartModelElement::applyModelContentToModel: invalid source model!" ); + ENSURE_OR_RETURN_VOID( i_modelToCopyFrom.is(), "ChartModelElement::applyModelContentToModel: invalid source model!" ); + try + { + // /-- loccked controllers of destination + ControllerLockGuard aLockedControllers( i_model ); + Reference< XChartDocument > xSource( i_modelToCopyFrom, UNO_QUERY_THROW ); + Reference< XChartDocument > xDestination( i_model, UNO_QUERY_THROW ); + + // propagate the correct flag for plotting of hidden values to the data provider and all used sequences + ChartModelHelper::setIncludeHiddenCells( ChartModelHelper::isIncludeHiddenCells( i_modelToCopyFrom ) , i_model ); + + // diagram + xDestination->setFirstDiagram( xSource->getFirstDiagram() ); + + // main title + Reference< XTitled > xDestinationTitled( xDestination, UNO_QUERY_THROW ); + Reference< XTitled > xSourceTitled( xSource, UNO_QUERY_THROW ); + xDestinationTitled->setTitleObject( xSourceTitled->getTitleObject() ); + + // page background + ::comphelper::copyProperties( + xSource->getPageBackground(), + xDestination->getPageBackground() ); + + // apply data (not applied in standard Undo) + if ( i_data.is() ) + ImplApplyDataToModel( i_model, i_data ); + + // register all sequences at the internal data provider to get adapted + // indexes when columns are added/removed + if ( xDestination->hasInternalDataProvider() ) + { + Reference< XInternalDataProvider > xNewDataProvider( xDestination->getDataProvider(), UNO_QUERY ); + Reference< XDataSource > xUsedData( DataSourceHelper::getUsedData( i_model ) ); + if ( xUsedData.is() && xNewDataProvider.is() ) + { + Sequence< Reference< XLabeledDataSequence > > aData( xUsedData->getDataSequences() ); + for( sal_Int32 i=0; i<aData.getLength(); ++i ) + { + xNewDataProvider->registerDataSequenceForChanges( aData[i]->getValues() ); + xNewDataProvider->registerDataSequenceForChanges( aData[i]->getLabel() ); + } + } + } + + // restore modify status + Reference< XModifiable > xSourceMod( xSource, UNO_QUERY ); + Reference< XModifiable > xDestMod( xDestination, UNO_QUERY ); + if ( xSourceMod.is() && xDestMod.is() && !xSourceMod->isModified() ) + { + xDestMod->setModified( sal_False ); + } + // \-- loccked controllers of destination + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + + +//...................................................................................................................... +} // namespace chart +//...................................................................................................................... diff --git a/chart2/source/controller/main/ChartModelClone.hxx b/chart2/source/controller/main/ChartModelClone.hxx new file mode 100755 index 000000000000..d5653b8e1ccc --- /dev/null +++ b/chart2/source/controller/main/ChartModelClone.hxx @@ -0,0 +1,89 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef CHART2_CHARTMODELCLONE_HXX +#define CHART2_CHARTMODELCLONE_HXX + +/** === begin UNO includes === **/ +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/chart2/XInternalDataProvider.hpp> +/** === end UNO includes === **/ + +#include <boost/noncopyable.hpp> + +//...................................................................................................................... +namespace chart +{ +//...................................................................................................................... + + //================================================================================================================== + //= ModelFacet + //================================================================================================================== + enum ModelFacet + { + E_MODEL, + E_MODEL_WITH_DATA, + E_MODEL_WITH_SELECTION + }; + + //================================================================================================================== + //= ChartModelClone + //================================================================================================================== + class ChartModelClone : public ::boost::noncopyable + { + public: + ChartModelClone( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& i_model, + const ModelFacet i_facet + ); + + ~ChartModelClone(); + + ModelFacet getFacet() const; + + void applyToModel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& i_model ) const; + + static void applyModelContentToModel( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & i_model, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & i_modelToCopyFrom, + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XInternalDataProvider > & i_data ); + + void dispose(); + + private: + bool impl_isDisposed() const { return !m_xModelClone.is(); } + + private: + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModelClone; + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XInternalDataProvider > m_xDataClone; + ::com::sun::star::uno::Any m_aSelection; + }; + +//...................................................................................................................... +} // namespace chart +//...................................................................................................................... + +#endif // CHART2_CHARTMODELCLONE_HXX diff --git a/chart2/source/controller/main/CommandDispatchContainer.cxx b/chart2/source/controller/main/CommandDispatchContainer.cxx index e0d689340760..c0847a490ea1 100644 --- a/chart2/source/controller/main/CommandDispatchContainer.cxx +++ b/chart2/source/controller/main/CommandDispatchContainer.cxx @@ -75,12 +75,6 @@ void CommandDispatchContainer::setModel( m_xModel = xModel; } -// void CommandDispatchContainer::setUndoManager( -// const Reference< chart2::XUndoManager > & xUndoManager ) -// { -// m_xUndoManager = xUndoManager; -// } - void CommandDispatchContainer::setChartDispatch( const Reference< frame::XDispatch > xChartDispatch, const ::std::set< OUString > & rChartCommands ) diff --git a/chart2/source/controller/main/CommandDispatchContainer.hxx b/chart2/source/controller/main/CommandDispatchContainer.hxx index 1c8769e0a6d9..a5995253e059 100644 --- a/chart2/source/controller/main/CommandDispatchContainer.hxx +++ b/chart2/source/controller/main/CommandDispatchContainer.hxx @@ -28,7 +28,6 @@ #define CHART2_COMMANDDISPATCHCONTAINER_HXX #include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/chart2/XUndoManager.hpp> #include <com/sun/star/frame/XDispatch.hpp> #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/frame/DispatchDescriptor.hpp> @@ -86,9 +85,6 @@ public: void setModel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModel ); -// void setUndoManager( -// const ::com::sun::star::uno::Reference< -// ::com::sun::star::chart2::XUndoManager > & xUndoManager ); /** Set a chart dispatcher that is used for all commands contained in rChartCommands @@ -140,9 +136,8 @@ private: mutable tDispatchMap m_aCachedDispatches; mutable tDisposeVector m_aToBeDisposedDispatches; - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; - ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XModel > m_xModel; - ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XUndoManager > m_xUndoManager; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XModel > m_xModel; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > m_xChartDispatcher; ::std::set< ::rtl::OUString > m_aChartCommands; diff --git a/chart2/source/controller/main/ImplUndoManager.cxx b/chart2/source/controller/main/ImplUndoManager.cxx deleted file mode 100644 index 0976b7db286e..000000000000 --- a/chart2/source/controller/main/ImplUndoManager.cxx +++ /dev/null @@ -1,503 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_chart2.hxx" - -#include "ImplUndoManager.hxx" -#include "DisposeHelper.hxx" -#include "CommonFunctors.hxx" -#include "ControllerLockGuard.hxx" -#include "PropertyHelper.hxx" -#include "DataSourceHelper.hxx" -#include "ChartModelHelper.hxx" - -#include <com/sun/star/chart/XComplexDescriptionAccess.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> -#include <com/sun/star/chart2/XInternalDataProvider.hpp> -#include <com/sun/star/chart2/XTitled.hpp> -#include <com/sun/star/util/XCloneable.hpp> -#include <com/sun/star/util/XModifiable.hpp> -#include <com/sun/star/view/XSelectionSupplier.hpp> - -#include <boost/bind.hpp> -#include <algorithm> - -using namespace ::com::sun::star; - -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; -using ::rtl::OUString; -using ::com::sun::star::chart::XComplexDescriptionAccess; - -namespace chart -{ -namespace impl -{ - -void ImplApplyDataToModel( - Reference< frame::XModel > & xInOutModelToChange, - const Reference< chart2::XInternalDataProvider > & xData ) -{ - Reference< chart2::XChartDocument > xDoc( xInOutModelToChange, uno::UNO_QUERY ); - OSL_ASSERT( xDoc.is() && xDoc->hasInternalDataProvider()); - - // copy data from stored internal data provider - if( xDoc.is() && xDoc->hasInternalDataProvider()) - { - Reference< XComplexDescriptionAccess > xCurrentData( xDoc->getDataProvider(), uno::UNO_QUERY ); - Reference< XComplexDescriptionAccess > xSavedData( xData, uno::UNO_QUERY ); - if( xCurrentData.is() && xSavedData.is()) - { - xCurrentData->setData( xSavedData->getData()); - xCurrentData->setComplexRowDescriptions( xSavedData->getComplexRowDescriptions()); - xCurrentData->setComplexColumnDescriptions( xSavedData->getComplexColumnDescriptions()); - } - } -} - -// ---------------------------------------- - -UndoElement::UndoElement( - const OUString & rActionString, - const Reference< frame::XModel > & xModel ) : - m_aActionString( rActionString ) -{ - initialize( xModel ); -} - -UndoElement::UndoElement( - const Reference< frame::XModel > & xModel ) -{ - initialize( xModel ); -} - -UndoElement::UndoElement( const UndoElement & rOther ) : - m_aActionString( rOther.m_aActionString ) -{ - initialize( rOther.m_xModel ); -} - -UndoElement::~UndoElement() -{} - -void UndoElement::initialize( const Reference< frame::XModel > & xModel ) -{ - if ( xModel.is() ) - { - m_xModel.set( UndoElement::cloneModel( xModel ) ); - } -} - -void UndoElement::dispose() -{ - Reference< lang::XComponent > xComp( m_xModel, uno::UNO_QUERY ); - if( xComp.is()) - xComp->dispose(); - m_xModel.set( 0 ); -} - -void UndoElement::applyToModel( - Reference< frame::XModel > & xInOutModelToChange ) -{ - UndoElement::applyModelContentToModel( xInOutModelToChange, m_xModel ); -} - -UndoElement * UndoElement::createFromModel( - const Reference< frame::XModel > & xModel ) -{ - return new UndoElement( getActionString(), xModel ); -} - -void UndoElement::setActionString( const ::rtl::OUString & rActionString ) -{ - m_aActionString = rActionString; -} - -OUString UndoElement::getActionString() const -{ - return m_aActionString; -} - -Reference< frame::XModel > UndoElement::cloneModel( const Reference< frame::XModel > & xModel ) -{ - Reference< frame::XModel > xResult; - uno::Reference< util::XCloneable > xCloneable( xModel, uno::UNO_QUERY ); - OSL_ENSURE( xCloneable.is(), "Cannot clone model" ); - if( xCloneable.is()) - xResult.set( xCloneable->createClone(), uno::UNO_QUERY ); - - return xResult; -} - -void UndoElement::applyModelContentToModel( - Reference< frame::XModel > & xInOutModelToChange, - const Reference< frame::XModel > & xModelToCopyFrom, - const Reference< chart2::XInternalDataProvider > & xData /* = 0 */ ) -{ - - if( xModelToCopyFrom.is() && xInOutModelToChange.is()) - { - try - { - // /-- loccked controllers of destination - ControllerLockGuard aLockedControllers( xInOutModelToChange ); - Reference< chart2::XChartDocument > xSource( xModelToCopyFrom, uno::UNO_QUERY_THROW ); - Reference< chart2::XChartDocument > xDestination( xInOutModelToChange, uno::UNO_QUERY_THROW ); - - // propagate the correct flag for plotting of hidden values to the data provider and all used sequences - ChartModelHelper::setIncludeHiddenCells( ChartModelHelper::isIncludeHiddenCells( xModelToCopyFrom ) , xInOutModelToChange ); - - // diagram - xDestination->setFirstDiagram( xSource->getFirstDiagram()); - - // main title - Reference< chart2::XTitled > xDestinationTitled( xDestination, uno::UNO_QUERY_THROW ); - Reference< chart2::XTitled > xSourceTitled( xSource, uno::UNO_QUERY_THROW ); - xDestinationTitled->setTitleObject( xSourceTitled->getTitleObject()); - - // page background - comphelper::copyProperties( - xSource->getPageBackground(), - xDestination->getPageBackground() ); - - // apply data (not applied in standard Undo) - if( xData.is()) - ImplApplyDataToModel( xInOutModelToChange, xData ); - - // register all sequences at the internal data provider to get adapted - // indexes when columns are added/removed - if( xDestination->hasInternalDataProvider()) - { - Reference< chart2::XInternalDataProvider > xNewDataProvider( xDestination->getDataProvider(), uno::UNO_QUERY ); - Reference< chart2::data::XDataSource > xUsedData( DataSourceHelper::getUsedData( xInOutModelToChange )); - if( xUsedData.is() && xNewDataProvider.is()) - { - Sequence< Reference< chart2::data::XLabeledDataSequence > > aData( xUsedData->getDataSequences()); - for( sal_Int32 i=0; i<aData.getLength(); ++i ) - { - xNewDataProvider->registerDataSequenceForChanges( aData[i]->getValues()); - xNewDataProvider->registerDataSequenceForChanges( aData[i]->getLabel()); - } - } - } - - // restore modify status - Reference< util::XModifiable > xSourceMod( xSource, uno::UNO_QUERY ); - Reference< util::XModifiable > xDestMod( xDestination, uno::UNO_QUERY ); - if( xSourceMod.is() && xDestMod.is() && - ! xSourceMod->isModified() ) - { - xDestMod->setModified( sal_False ); - } - // \-- loccked controllers of destination - } - catch( uno::Exception & ) - { - } - } -} - -// ---------------------------------------- - -UndoElementWithData::UndoElementWithData( - const OUString & rActionString, - const Reference< frame::XModel > & xModel ) : - UndoElement( rActionString, xModel ) -{ - initializeData(); -} - -UndoElementWithData::UndoElementWithData( - const Reference< frame::XModel > & xModel ) : - UndoElement( xModel ) -{ - initializeData(); -} - - -UndoElementWithData::UndoElementWithData( - const UndoElementWithData & rOther ) : - UndoElement( rOther ) -{ - initializeData(); -} - -UndoElementWithData::~UndoElementWithData() -{} - -void UndoElementWithData::initializeData() -{ - try - { - Reference< chart2::XChartDocument > xChartDoc( m_xModel, uno::UNO_QUERY_THROW ); - OSL_ASSERT( xChartDoc->hasInternalDataProvider()); - if( xChartDoc->hasInternalDataProvider()) - { - Reference< util::XCloneable > xCloneable( xChartDoc->getDataProvider(), uno::UNO_QUERY ); - OSL_ENSURE( xCloneable.is(), "Cannot clone data" ); - if( xCloneable.is()) - m_xData.set( xCloneable->createClone(), uno::UNO_QUERY ); - } - } - catch( uno::Exception & ) - { - } -} - -void UndoElementWithData::dispose() -{ - UndoElement::dispose(); - m_xData.set( 0 ); -} - -void UndoElementWithData::applyToModel( - Reference< frame::XModel > & xInOutModelToChange ) -{ - UndoElement::applyModelContentToModel( xInOutModelToChange, m_xModel, m_xData ); -} - -UndoElement * UndoElementWithData::createFromModel( - const Reference< frame::XModel > & xModel ) -{ - return new UndoElementWithData( getActionString(), xModel ); -} - -// ======================================== - -// ---------------------------------------- - -UndoElementWithSelection::UndoElementWithSelection( - const OUString & rActionString, - const Reference< frame::XModel > & xModel ) : - UndoElement( rActionString, xModel ) -{ - initialize( xModel ); -} - -UndoElementWithSelection::UndoElementWithSelection( - const Reference< frame::XModel > & xModel ) : - UndoElement( xModel ) -{ - initialize( xModel ); -} - -UndoElementWithSelection::UndoElementWithSelection( - const UndoElementWithSelection & rOther ) : - UndoElement( rOther ) -{ - initialize( rOther.m_xModel ); -} - -UndoElementWithSelection::~UndoElementWithSelection() -{} - -void UndoElementWithSelection::initialize( const Reference< frame::XModel > & xModel ) -{ - try - { - uno::Reference< view::XSelectionSupplier > xSelSupp( xModel->getCurrentController(), uno::UNO_QUERY ); - OSL_ASSERT( xSelSupp.is() ); - - if( xSelSupp.is() ) - m_aSelection = xSelSupp->getSelection(); - } - catch( const uno::Exception & ) - { - } -} - -void UndoElementWithSelection::dispose() -{ - UndoElement::dispose(); - m_aSelection.clear(); -} - -void UndoElementWithSelection::applyToModel( - Reference< frame::XModel > & xInOutModelToChange ) -{ - UndoElement::applyModelContentToModel( xInOutModelToChange, m_xModel ); - Reference< view::XSelectionSupplier > xCurrentSelectionSuppl( xInOutModelToChange->getCurrentController(), uno::UNO_QUERY ); - OSL_ASSERT( xCurrentSelectionSuppl.is() ); - - if( xCurrentSelectionSuppl.is()) - xCurrentSelectionSuppl->select( m_aSelection ); -} - -UndoElement * UndoElementWithSelection::createFromModel( - const Reference< frame::XModel > & xModel ) -{ - return new UndoElementWithSelection( getActionString(), xModel ); -} - -// ---------------------------------------- - -ShapeUndoElement::ShapeUndoElement( const OUString& rActionString, SdrUndoAction* pAction ) - :UndoElement( rActionString, Reference< frame::XModel >() ) - ,m_pAction( pAction ) -{ -} - -ShapeUndoElement::ShapeUndoElement( const ShapeUndoElement& rOther ) - :UndoElement( rOther ) - ,m_pAction( rOther.m_pAction ) -{ -} - -ShapeUndoElement::~ShapeUndoElement() -{ -} - -SdrUndoAction* ShapeUndoElement::getSdrUndoAction() -{ - return m_pAction; -} - -// ======================================== - -UndoStack::UndoStack() : - m_nSizeLimit( 1000 ) -{ -} - -UndoStack::~UndoStack() -{ - disposeAndClear(); -} - -void UndoStack::pop() -{ - if( ! empty()) - { - top()->dispose(); - delete top(); - m_aStack.pop_back(); - } -} - -void UndoStack::push( UndoElement * pElement ) -{ - m_aStack.push_back( pElement ); - applyLimitation(); -} - -UndoElement * UndoStack::top() const -{ - return m_aStack.back(); -} - -OUString UndoStack::topUndoString() const -{ - if( ! empty()) - return top()->getActionString(); - return OUString(); -} - -Sequence< OUString > UndoStack::getUndoStrings() const -{ - sal_Int32 nSize( static_cast< sal_Int32 >( m_aStack.size())); - Sequence< OUString > aResult( nSize ); - for( sal_Int32 i=0; i<nSize; ++i ) - aResult[i] = m_aStack[i]->getActionString(); - return aResult; -} - -bool UndoStack::empty() const -{ - return m_aStack.empty(); -} - -void UndoStack::disposeAndClear() -{ - ::std::for_each( m_aStack.begin(), m_aStack.end(), ::boost::mem_fn( & UndoElement::dispose )); - ::std::for_each( m_aStack.begin(), m_aStack.end(), CommonFunctors::DeletePtr< UndoElement >() ); - m_aStack.clear(); -} - -void UndoStack::limitSize( sal_Int32 nMaxSize ) -{ - m_nSizeLimit = nMaxSize; - applyLimitation(); -} - -void UndoStack::applyLimitation() -{ - if( m_aStack.size() > static_cast< sal_uInt32 >( m_nSizeLimit )) - { - tUndoStackType::iterator aBegin( m_aStack.begin()); - tUndoStackType::iterator aEnd( aBegin + (m_aStack.size() - m_nSizeLimit)); - // dispose and remove all undo elements that are over the limit - ::std::for_each( aBegin, aEnd, ::boost::mem_fn( & UndoElement::dispose )); - ::std::for_each( aBegin, aEnd, CommonFunctors::DeletePtr< UndoElement >() ); - m_aStack.erase( aBegin, aEnd ); - } -} - -// ================================================================================ - -namespace -{ -static const OUString aUndoStepsPropName( RTL_CONSTASCII_USTRINGPARAM("Steps")); -} // anonymous namespace - -UndoStepsConfigItem::UndoStepsConfigItem( ConfigItemListener & rListener ) : - ::utl::ConfigItem( OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Undo"))), - m_rListener( rListener ) -{ - EnableNotification( Sequence< OUString >( & aUndoStepsPropName, 1 )); -} - -UndoStepsConfigItem::~UndoStepsConfigItem() -{ -} - -void UndoStepsConfigItem::Notify( const Sequence< OUString > & aPropertyNames ) -{ - for( sal_Int32 nIdx=0; nIdx<aPropertyNames.getLength(); ++nIdx ) - { - if( aPropertyNames[nIdx].equals( aUndoStepsPropName )) - m_rListener.notify( aPropertyNames[nIdx] ); - } -} - -void UndoStepsConfigItem::Commit() -{ -} - -// mtehod is not const, because GetProperties is not const -sal_Int32 UndoStepsConfigItem::getUndoSteps() -{ - sal_Int32 nSteps = -1; - Sequence< uno::Any > aValues( - GetProperties( Sequence< OUString >( & aUndoStepsPropName, 1 ))); - if( aValues.getLength()) - aValues[0] >>= nSteps; - return nSteps; -} - -} // namespace impl -} // namespace chart diff --git a/chart2/source/controller/main/ImplUndoManager.hxx b/chart2/source/controller/main/ImplUndoManager.hxx deleted file mode 100644 index 4dde0bc65719..000000000000 --- a/chart2/source/controller/main/ImplUndoManager.hxx +++ /dev/null @@ -1,227 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef CHART2_IMPLUNDOMANAGER_HXX -#define CHART2_IMPLUNDOMANAGER_HXX - -#include "ConfigItemListener.hxx" - -#include <com/sun/star/frame/XModel.hpp> -#include <com/sun/star/uno/Sequence.hxx> - -#include <rtl/ustring.hxx> -#include <unotools/configitem.hxx> - -#include <utility> -#include <deque> - - -class SdrUndoAction; - -namespace com { namespace sun { namespace star { -namespace chart2 { - class XInternalDataProvider; -} -}}} - - -namespace chart -{ -namespace impl -{ - -class UndoElement -{ -public: - UndoElement( const ::rtl::OUString & rActionString, - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - UndoElement( const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - UndoElement( const UndoElement & rOther ); - virtual ~UndoElement(); - - virtual void dispose(); - virtual UndoElement * createFromModel( - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - - virtual void applyToModel( - ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xInOutModelToChange ); - - void setActionString( const ::rtl::OUString & rActionString ); - ::rtl::OUString getActionString() const; - - static ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > cloneModel( - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModel ); - - static void applyModelContentToModel( - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xInOutModelToChange, - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModelToCopyFrom, - const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XInternalDataProvider > & xData = 0 ); - -protected: - ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > m_xModel; - -private: - void initialize( const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - - ::rtl::OUString m_aActionString; -}; - -class UndoElementWithData : public UndoElement -{ -public: - UndoElementWithData( const ::rtl::OUString & rActionString, - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - UndoElementWithData( const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - UndoElementWithData( const UndoElementWithData & rOther ); - virtual ~UndoElementWithData(); - - virtual void dispose(); - virtual UndoElement * createFromModel( - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - - virtual void applyToModel( - ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xInOutModelToChange ); - -private: - void initializeData(); - - ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XInternalDataProvider > m_xData; -}; - -class UndoElementWithSelection : public UndoElement -{ -public: - UndoElementWithSelection( const ::rtl::OUString & rActionString, - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - UndoElementWithSelection( const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - UndoElementWithSelection( const UndoElementWithSelection & rOther ); - virtual ~UndoElementWithSelection(); - - virtual void dispose(); - virtual UndoElement * createFromModel( - const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - - virtual void applyToModel( - ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xInOutModelToChange ); - -private: - void initialize( const ::com::sun::star::uno::Reference< - ::com::sun::star::frame::XModel > & xModel ); - - ::com::sun::star::uno::Any m_aSelection; -}; - -class ShapeUndoElement : public UndoElement -{ -public: - ShapeUndoElement( const ::rtl::OUString& rActionString, SdrUndoAction* pAction ); - ShapeUndoElement( const ShapeUndoElement& rOther ); - virtual ~ShapeUndoElement(); - - SdrUndoAction* getSdrUndoAction(); - -private: - SdrUndoAction* m_pAction; -}; - -/** Note that all models that are put into this container are at some point - disposed of inside this class. (At least in the destructor). That means - the models retrieved here should never be used, but instead their content - should be copied to a living model. - */ -class UndoStack -{ -public: - UndoStack(); - // disposes of all models left in the stack - ~UndoStack(); - - // removes he last undo action and disposes of the model - void pop(); - void push( UndoElement * rElement ); - - // precondition: !empty() - UndoElement * top() const; - ::rtl::OUString topUndoString() const; - - ::com::sun::star::uno::Sequence< ::rtl::OUString > getUndoStrings() const; - - bool empty() const; - void disposeAndClear(); - - // removes all actions that have been inserted more than nMaxSize steps ago. - // The models of those actions are disposed of - void limitSize( sal_Int32 nMaxSize ); - -private: - void applyLimitation(); - - typedef ::std::deque< UndoElement * > tUndoStackType; - - tUndoStackType m_aStack; - sal_Int32 m_nSizeLimit; -}; - -// ---------------------------------------- - -class UndoStepsConfigItem : public ::utl::ConfigItem -{ -public: - explicit UndoStepsConfigItem( ConfigItemListener & rListener ); - virtual ~UndoStepsConfigItem(); - - sal_Int32 getUndoSteps(); - -protected: - // ____ ::utl::ConfigItem ____ - virtual void Notify( const ::com::sun::star::uno::Sequence< ::rtl::OUString > & aPropertyNames ); - virtual void Commit(); - -private: - ConfigItemListener & m_rListener; -}; - - -} // namespace impl -} // namespace chart - -// CHART2_IMPLUNDOMANAGER_HXX -#endif diff --git a/chart2/source/controller/main/UndoActions.cxx b/chart2/source/controller/main/UndoActions.cxx new file mode 100644 index 000000000000..86c0e365f590 --- /dev/null +++ b/chart2/source/controller/main/UndoActions.cxx @@ -0,0 +1,178 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "UndoActions.hxx" +#include "DisposeHelper.hxx" +#include "CommonFunctors.hxx" +#include "PropertyHelper.hxx" +#include "ChartModelClone.hxx" + +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/util/XCloneable.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> +#include <com/sun/star/lang/DisposedException.hpp> + +#include <tools/diagnose_ex.h> +#include <svx/svdundo.hxx> + +#include <boost/bind.hpp> +#include <algorithm> + +using namespace ::com::sun::star; + +using ::rtl::OUString; + +namespace chart +{ +namespace impl +{ + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::frame::XModel; + using ::com::sun::star::util::XCloneable; + using ::com::sun::star::lang::XComponent; + using ::com::sun::star::lang::DisposedException; + using ::com::sun::star::view::XSelectionSupplier; + using ::com::sun::star::chart2::XChartDocument; + using ::com::sun::star::document::UndoFailedException; + /** === end UNO using === **/ + +// --------------------------------------------------------------------------------------------------------------------- +UndoElement::UndoElement( const OUString& i_actionString, const Reference< XModel >& i_documentModel, const ::boost::shared_ptr< ChartModelClone >& i_modelClone ) + :UndoElement_MBase() + ,UndoElement_TBase( m_aMutex ) + ,m_sActionString( i_actionString ) + ,m_xDocumentModel( i_documentModel ) + ,m_pModelClone( i_modelClone ) +{ +} + +// --------------------------------------------------------------------------------------------------------------------- +UndoElement::~UndoElement() +{ +} + +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UndoElement::disposing() +{ + if ( !!m_pModelClone ) + m_pModelClone->dispose(); + m_pModelClone.reset(); + m_xDocumentModel.clear(); +} + +// --------------------------------------------------------------------------------------------------------------------- +::rtl::OUString SAL_CALL UndoElement::getTitle() throw (RuntimeException) +{ + return m_sActionString; +} + +// --------------------------------------------------------------------------------------------------------------------- +void UndoElement::impl_toggleModelState() +{ + // get a snapshot of the current state of our model + ::boost::shared_ptr< ChartModelClone > pNewClone( new ChartModelClone( m_xDocumentModel, m_pModelClone->getFacet() ) ); + // apply the previous snapshot to our model + m_pModelClone->applyToModel( m_xDocumentModel ); + // remember the new snapshot, for the next toggle + m_pModelClone = pNewClone; +} + +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UndoElement::undo( ) throw (UndoFailedException, RuntimeException) +{ + impl_toggleModelState(); +} + +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UndoElement::redo( ) throw (UndoFailedException, RuntimeException) +{ + impl_toggleModelState(); +} + +// ===================================================================================================================== +// = ShapeUndoElement +// ===================================================================================================================== + +// --------------------------------------------------------------------------------------------------------------------- +ShapeUndoElement::ShapeUndoElement( SdrUndoAction& i_sdrUndoAction ) + :ShapeUndoElement_MBase() + ,ShapeUndoElement_TBase( m_aMutex ) + ,m_pAction( &i_sdrUndoAction ) +{ +} + +// --------------------------------------------------------------------------------------------------------------------- +ShapeUndoElement::~ShapeUndoElement() +{ +} + +// --------------------------------------------------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ShapeUndoElement::getTitle() throw (RuntimeException) +{ + if ( !m_pAction ) + throw DisposedException( ::rtl::OUString(), *this ); + return m_pAction->GetComment(); +} + +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL ShapeUndoElement::undo( ) throw (UndoFailedException, RuntimeException) +{ + if ( !m_pAction ) + throw DisposedException( ::rtl::OUString(), *this ); + m_pAction->Undo(); +} + +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL ShapeUndoElement::redo( ) throw (UndoFailedException, RuntimeException) +{ + if ( !m_pAction ) + throw DisposedException( ::rtl::OUString(), *this ); + m_pAction->Redo(); +} + +// --------------------------------------------------------------------------------------------------------------------- +void SAL_CALL ShapeUndoElement::disposing() +{ +} + +} // namespace impl +} // namespace chart diff --git a/chart2/source/controller/main/UndoActions.hxx b/chart2/source/controller/main/UndoActions.hxx new file mode 100644 index 000000000000..2c98d6af1d54 --- /dev/null +++ b/chart2/source/controller/main/UndoActions.hxx @@ -0,0 +1,134 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_IMPLUNDOMANAGER_HXX +#define CHART2_IMPLUNDOMANAGER_HXX + +#include "ConfigItemListener.hxx" + +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/document/XUndoAction.hpp> +#include <com/sun/star/uno/Sequence.hxx> + +#include <rtl/ustring.hxx> +#include <unotools/configitem.hxx> +#include <cppuhelper/compbase1.hxx> +#include <cppuhelper/basemutex.hxx> + +#include <utility> +#include <deque> + +#include <boost/noncopyable.hpp> +#include <boost/shared_ptr.hpp> + +class SdrUndoAction; + +namespace com { namespace sun { namespace star { +namespace chart2 { + class XInternalDataProvider; +} +}}} + + +namespace chart +{ +class ChartModelClone; + +namespace impl +{ + +typedef ::cppu::BaseMutex UndoElement_MBase; +typedef ::cppu::WeakComponentImplHelper1< ::com::sun::star::document::XUndoAction > UndoElement_TBase; + +class UndoElement :public UndoElement_MBase + ,public UndoElement_TBase + ,public ::boost::noncopyable +{ +public: + /** creates a new undo action + + @param i_actionString + is the title of the Undo action + @param i_documentModel + is the actual document model which the undo actions operates on + @param i_modelClone + is the cloned model from before the changes, which the Undo action represents, have been applied. + Upon <member>invoking</member>, the clone model is applied to the document model. + */ + UndoElement( const ::rtl::OUString & i_actionString, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& i_documentModel, + const ::boost::shared_ptr< ChartModelClone >& i_modelClone + ); + + // XUndoAction + virtual ::rtl::OUString SAL_CALL getTitle() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL undo( ) throw (::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL redo( ) throw (::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException); + + // OComponentHelper + virtual void SAL_CALL disposing(); + +protected: + virtual ~UndoElement(); + +private: + void impl_toggleModelState(); + +private: + ::rtl::OUString m_sActionString; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xDocumentModel; + ::boost::shared_ptr< ChartModelClone > m_pModelClone; +}; + + +typedef ::cppu::BaseMutex ShapeUndoElement_MBase; +typedef ::cppu::WeakComponentImplHelper1< ::com::sun::star::document::XUndoAction > ShapeUndoElement_TBase; +class ShapeUndoElement :public ShapeUndoElement_MBase + ,public ShapeUndoElement_TBase +{ +public: + ShapeUndoElement( SdrUndoAction& i_sdrUndoAction ); + + // XUndoAction + virtual ::rtl::OUString SAL_CALL getTitle() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL undo( ) throw (::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL redo( ) throw (::com::sun::star::document::UndoFailedException, ::com::sun::star::uno::RuntimeException); + + // OComponentHelper + virtual void SAL_CALL disposing(); + +protected: + virtual ~ShapeUndoElement(); + +private: + SdrUndoAction* m_pAction; +}; + +} // namespace impl +} // namespace chart + +// CHART2_IMPLUNDOMANAGER_HXX +#endif diff --git a/chart2/source/controller/main/UndoCommandDispatch.cxx b/chart2/source/controller/main/UndoCommandDispatch.cxx index 128a4b4091d0..487def377d5c 100644 --- a/chart2/source/controller/main/UndoCommandDispatch.cxx +++ b/chart2/source/controller/main/UndoCommandDispatch.cxx @@ -29,13 +29,15 @@ #include "precompiled_chart2.hxx" #include "UndoCommandDispatch.hxx" +#include "ResId.hxx" #include "macros.hxx" -#include <com/sun/star/chart2/XUndoSupplier.hpp> #include <com/sun/star/util/XModifyBroadcaster.hpp> +#include <com/sun/star/document/XUndoManagerSupplier.hpp> #include <vos/mutex.hxx> #include <vcl/svapp.hxx> +#include <tools/diagnose_ex.h> // for ressource strings STR_UNDO and STR_REDO #include <svtools/svtools.hrc> @@ -56,10 +58,8 @@ UndoCommandDispatch::UndoCommandDispatch( CommandDispatch( xContext ), m_xModel( xModel ) { - Reference< chart2::XUndoSupplier > xUndoSupplier( xModel, uno::UNO_QUERY ); - OSL_ASSERT( xUndoSupplier.is()); - if( xUndoSupplier.is()) - m_xUndoManager.set( xUndoSupplier->getUndoManager()); + uno::Reference< document::XUndoManagerSupplier > xSuppUndo( m_xModel, uno::UNO_QUERY_THROW ); + m_xUndoManager.set( xSuppUndo->getUndoManager(), uno::UNO_QUERY_THROW ); } UndoCommandDispatch::~UndoCommandDispatch() @@ -68,10 +68,8 @@ UndoCommandDispatch::~UndoCommandDispatch() void UndoCommandDispatch::initialize() { Reference< util::XModifyBroadcaster > xBroadcaster( m_xUndoManager, uno::UNO_QUERY ); - if( xBroadcaster.is() ) - { - xBroadcaster->addModifyListener( this ); - } + ENSURE_OR_RETURN_VOID( xBroadcaster.is(), "UndoCommandDispatch::initialize: missing modification broadcaster interface!" ); + xBroadcaster->addModifyListener( this ); } void UndoCommandDispatch::fireStatusEvent( @@ -82,23 +80,23 @@ void UndoCommandDispatch::fireStatusEvent( { bool bFireAll = (rURL.getLength() == 0); uno::Any aUndoState, aRedoState; - if( m_xUndoManager->undoPossible()) + if( m_xUndoManager->isUndoPossible()) { // using assignment for broken gcc 3.3 OUString aUndo = OUString( String( SvtResId( STR_UNDO ))); - aUndoState <<= ( aUndo + m_xUndoManager->getCurrentUndoString()); + aUndoState <<= ( aUndo + m_xUndoManager->getCurrentUndoActionTitle()); } - if( m_xUndoManager->redoPossible()) + if( m_xUndoManager->isRedoPossible()) { // using assignment for broken gcc 3.3 OUString aRedo = OUString( String( SvtResId( STR_REDO ))); - aRedoState <<= ( aRedo + m_xUndoManager->getCurrentRedoString()); + aRedoState <<= ( aRedo + m_xUndoManager->getCurrentRedoActionTitle()); } if( bFireAll || rURL.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(".uno:Undo"))) - fireStatusEventForURL( C2U(".uno:Undo"), aUndoState, m_xUndoManager->undoPossible(), xSingleListener ); + fireStatusEventForURL( C2U(".uno:Undo"), aUndoState, m_xUndoManager->isUndoPossible(), xSingleListener ); if( bFireAll || rURL.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(".uno:Redo"))) - fireStatusEventForURL( C2U(".uno:Redo"), aRedoState, m_xUndoManager->redoPossible(), xSingleListener ); + fireStatusEventForURL( C2U(".uno:Redo"), aRedoState, m_xUndoManager->isRedoPossible(), xSingleListener ); } } @@ -113,10 +111,21 @@ void SAL_CALL UndoCommandDispatch::dispatch( // why is it necessary to lock the solar mutex here? // /-- ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); - if( URL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Undo" ))) - m_xUndoManager->undo( m_xModel ); - else - m_xUndoManager->redo( m_xModel ); + try + { + if( URL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Undo" ))) + m_xUndoManager->undo(); + else + m_xUndoManager->redo(); + } + catch( const document::UndoFailedException& ) + { + // silently ignore + } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } // \-- } } @@ -126,6 +135,7 @@ void SAL_CALL UndoCommandDispatch::dispatch( void SAL_CALL UndoCommandDispatch::disposing() { Reference< util::XModifyBroadcaster > xBroadcaster( m_xUndoManager, uno::UNO_QUERY ); + OSL_ENSURE( xBroadcaster.is(), "UndoCommandDispatch::initialize: missing modification broadcaster interface!" ); if( xBroadcaster.is() ) { xBroadcaster->removeModifyListener( this ); diff --git a/chart2/source/controller/main/UndoCommandDispatch.hxx b/chart2/source/controller/main/UndoCommandDispatch.hxx index 28fb813f63de..891ab8b019e5 100644 --- a/chart2/source/controller/main/UndoCommandDispatch.hxx +++ b/chart2/source/controller/main/UndoCommandDispatch.hxx @@ -30,15 +30,12 @@ #include "CommandDispatch.hxx" #include <com/sun/star/frame/XModel.hpp> -#include <com/sun/star/chart2/XUndoManager.hpp> +#include <com/sun/star/document/XUndoManager.hpp> namespace chart { /** This is a CommandDispatch implementation for Undo and Redo. - - You need to pass an UndoManager to this class that is then used for Undo and - Redo. The changes are applied to the given XModel. */ class UndoCommandDispatch : public CommandDispatch { @@ -77,7 +74,7 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModel; ::com::sun::star::uno::Reference< - ::com::sun::star::chart2::XUndoManager > m_xUndoManager; + ::com::sun::star::document::XUndoManager > m_xUndoManager; }; } // namespace chart diff --git a/chart2/source/controller/main/UndoGuard.cxx b/chart2/source/controller/main/UndoGuard.cxx index 8513b6ba9093..52ea27aa8d49 100644 --- a/chart2/source/controller/main/UndoGuard.cxx +++ b/chart2/source/controller/main/UndoGuard.cxx @@ -29,6 +29,12 @@ #include "precompiled_chart2.hxx" #include "UndoGuard.hxx" +#include "ChartModelClone.hxx" +#include "UndoActions.hxx" + +#include <com/sun/star/container/XChild.hpp> + +#include <tools/diagnose_ex.h> using namespace ::com::sun::star; @@ -39,105 +45,154 @@ using ::rtl::OUString; namespace chart { -UndoGuard_Base::UndoGuard_Base( const OUString& rUndoString - , const uno::Reference< chart2::XUndoManager > & xUndoManager - , const uno::Reference< frame::XModel > & xModel ) - : m_xModel( xModel ) - , m_xUndoManager( xUndoManager ) - , m_aUndoString( rUndoString ) - , m_bActionPosted( false ) +//----------------------------------------------------------------------------- + +UndoGuard::UndoGuard( const OUString& i_undoString, const uno::Reference< document::XUndoManager > & i_undoManager, + const ModelFacet i_facet ) + :m_xChartModel( i_undoManager->getParent(), uno::UNO_QUERY_THROW ) + ,m_xUndoManager( i_undoManager ) + ,m_pDocumentSnapshot() + ,m_aUndoString( i_undoString ) + ,m_bActionPosted( false ) { + m_pDocumentSnapshot.reset( new ChartModelClone( m_xChartModel, i_facet ) ); } -UndoGuard_Base::~UndoGuard_Base() +//----------------------------------------------------------------------------- + +UndoGuard::~UndoGuard() { + if ( !!m_pDocumentSnapshot ) + discardSnapshot(); } -void UndoGuard_Base::commitAction() +//----------------------------------------------------------------------------- + +void UndoGuard::commit() { - if( !m_bActionPosted && m_xUndoManager.is() ) - m_xUndoManager->postAction( m_aUndoString ); + if ( !m_bActionPosted && !!m_pDocumentSnapshot ) + { + try + { + const Reference< document::XUndoAction > xAction( new impl::UndoElement( m_aUndoString, m_xChartModel, m_pDocumentSnapshot ) ); + m_pDocumentSnapshot.reset(); // don't dispose, it's data went over to the UndoElement + m_xUndoManager->addUndoAction( xAction ); + } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } m_bActionPosted = true; } //----------------------------------------------------------------------------- -UndoGuard::UndoGuard( const OUString& rUndoString - , const uno::Reference< chart2::XUndoManager > & xUndoManager - , const uno::Reference< frame::XModel > & xModel ) - : UndoGuard_Base( rUndoString, xUndoManager, xModel ) +void UndoGuard::rollback() { - if( m_xUndoManager.is() ) - m_xUndoManager->preAction( m_xModel ); + ENSURE_OR_RETURN_VOID( !!m_pDocumentSnapshot, "no snapshot!" ); + m_pDocumentSnapshot->applyToModel( m_xChartModel ); + discardSnapshot(); } -UndoGuard::~UndoGuard() +//----------------------------------------------------------------------------- +void UndoGuard::discardSnapshot() { - if( !m_bActionPosted && m_xUndoManager.is() ) - m_xUndoManager->cancelAction(); + ENSURE_OR_RETURN_VOID( !!m_pDocumentSnapshot, "no snapshot!" ); + m_pDocumentSnapshot->dispose(); + m_pDocumentSnapshot.reset(); } //----------------------------------------------------------------------------- -UndoLiveUpdateGuard::UndoLiveUpdateGuard( const OUString& rUndoString - , const uno::Reference< chart2::XUndoManager > & xUndoManager - , const uno::Reference< frame::XModel > & xModel ) - : UndoGuard_Base( rUndoString, xUndoManager, xModel ) +UndoLiveUpdateGuard::UndoLiveUpdateGuard( const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager ) + :UndoGuard( i_undoString, i_undoManager, E_MODEL ) { - if( m_xUndoManager.is() ) - m_xUndoManager->preAction( m_xModel ); } UndoLiveUpdateGuard::~UndoLiveUpdateGuard() { - if( !m_bActionPosted && m_xUndoManager.is() ) - m_xUndoManager->cancelActionWithUndo( m_xModel ); + if ( !isActionPosted() ) + rollback(); } //----------------------------------------------------------------------------- -UndoLiveUpdateGuardWithData::UndoLiveUpdateGuardWithData( const OUString& rUndoString - , const uno::Reference< chart2::XUndoManager > & xUndoManager - , const uno::Reference< frame::XModel > & xModel ) - : UndoGuard_Base( rUndoString, xUndoManager, xModel ) +UndoLiveUpdateGuardWithData::UndoLiveUpdateGuardWithData( + const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager ) + :UndoGuard( i_undoString, i_undoManager, E_MODEL_WITH_DATA ) { - if( m_xUndoManager.is() ) - { - Sequence< beans::PropertyValue > aArgs(1); - aArgs[0] = beans::PropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM("WithData")), -1, uno::Any(), - beans::PropertyState_DIRECT_VALUE ); - m_xUndoManager->preActionWithArguments( m_xModel, aArgs ); - } } UndoLiveUpdateGuardWithData::~UndoLiveUpdateGuardWithData() { - if( !m_bActionPosted && m_xUndoManager.is() ) - m_xUndoManager->cancelActionWithUndo( m_xModel ); + if ( !isActionPosted() ) + rollback(); } //----------------------------------------------------------------------------- -UndoGuardWithSelection::UndoGuardWithSelection( const rtl::OUString& rUndoString - , const uno::Reference< chart2::XUndoManager > & xUndoManager - , const uno::Reference< frame::XModel > & xModel ) - : UndoGuard_Base( rUndoString, xUndoManager, xModel ) +UndoGuardWithSelection::UndoGuardWithSelection( + const OUString& i_undoString, const uno::Reference< document::XUndoManager >& i_undoManager ) + :UndoGuard( i_undoString, i_undoManager, E_MODEL_WITH_SELECTION ) { - if( m_xUndoManager.is() ) +} + +//----------------------------------------------------------------------------- + +UndoGuardWithSelection::~UndoGuardWithSelection() +{ + if ( !isActionPosted() ) + rollback(); +} + +//----------------------------------------------------------------------------- + +UndoContext::UndoContext( const Reference< document::XUndoManager > & i_undoManager, const ::rtl::OUString& i_undoTitle ) + :m_xUndoManager( i_undoManager ) +{ + ENSURE_OR_THROW( m_xUndoManager.is(), "invalid undo manager!" ); + m_xUndoManager->enterUndoContext( i_undoTitle ); +} + +//----------------------------------------------------------------------------- + +UndoContext::~UndoContext() +{ + m_xUndoManager->leaveUndoContext(); +} + +//----------------------------------------------------------------------------- + +HiddenUndoContext::HiddenUndoContext( const Reference< document::XUndoManager > & i_undoManager ) + :m_xUndoManager( i_undoManager ) +{ + ENSURE_OR_THROW( m_xUndoManager.is(), "invalid undo manager!" ); + try + { + m_xUndoManager->enterHiddenUndoContext(); + } + catch( const uno::Exception& ) { - Sequence< beans::PropertyValue > aArgs(1); - aArgs[0] = beans::PropertyValue( - OUString( RTL_CONSTASCII_USTRINGPARAM("WithSelection")), -1, uno::Any(), - beans::PropertyState_DIRECT_VALUE ); - m_xUndoManager->preActionWithArguments( m_xModel, aArgs ); + DBG_UNHANDLED_EXCEPTION(); + m_xUndoManager.clear(); + // prevents the leaveUndoContext in the dtor } } -UndoGuardWithSelection::~UndoGuardWithSelection() +//----------------------------------------------------------------------------- + +HiddenUndoContext::~HiddenUndoContext() { - if( !m_bActionPosted && m_xUndoManager.is() ) - m_xUndoManager->cancelAction(); + try + { + if ( m_xUndoManager.is() ) + m_xUndoManager->leaveUndoContext(); + } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } } // namespace chart diff --git a/chart2/source/controller/main/UndoGuard.hxx b/chart2/source/controller/main/UndoGuard.hxx new file mode 100644 index 000000000000..c5c00dd62d1b --- /dev/null +++ b/chart2/source/controller/main/UndoGuard.hxx @@ -0,0 +1,137 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_UNDOGUARD_HXX +#define CHART2_UNDOGUARD_HXX + +#include "ChartModelClone.hxx" + +#include <com/sun/star/document/XUndoManager.hpp> +#include <com/sun/star/frame/XModel.hpp> + +#include <rtl/ustring.hxx> + +#include <boost/shared_ptr.hpp> + +namespace chart +{ + +/** A guard which which does nothing, unless you explicitly call commitAction. In particular, in its destructor, it + does neither auto-commit nor auto-rollback the model changes. + */ +class UndoGuard +{ +public: + explicit UndoGuard( + const ::rtl::OUString& i_undoMessage, + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager, + const ModelFacet i_facet = E_MODEL + ); + ~UndoGuard(); + + void commit(); + void rollback(); + +protected: + bool isActionPosted() const { return m_bActionPosted; } + +private: + void discardSnapshot(); + +private: + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xChartModel; + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > m_xUndoManager; + + ::boost::shared_ptr< ChartModelClone > m_pDocumentSnapshot; + rtl::OUString m_aUndoString; + bool m_bActionPosted; +}; + +/** A guard which, in its destructor, restores the model state it found in the constructor. If + <member>commitAction</member> is called inbetween, the restouration is not performed. + */ +class UndoLiveUpdateGuard : public UndoGuard +{ +public: + explicit UndoLiveUpdateGuard( + const ::rtl::OUString& i_undoMessage, + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager + ); + ~UndoLiveUpdateGuard(); +}; + +/** Same as UndoLiveUpdateGuard but with additional storage of the chart's data. + Only use this if the data has internal data. + */ +class UndoLiveUpdateGuardWithData : + public UndoGuard +{ +public: + explicit UndoLiveUpdateGuardWithData( + const ::rtl::OUString& i_undoMessage, + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager + ); + ~UndoLiveUpdateGuardWithData(); +}; + +class UndoGuardWithSelection : public UndoGuard +{ +public: + explicit UndoGuardWithSelection( + const ::rtl::OUString& i_undoMessage, + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager + ); + virtual ~UndoGuardWithSelection(); +}; + +class UndoContext +{ +public: + UndoContext( + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager, + const ::rtl::OUString& i_undoTitle + ); + ~UndoContext(); + +private: + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > m_xUndoManager; +}; + +class HiddenUndoContext +{ +public: + HiddenUndoContext( + const ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > & i_undoManager + ); + ~HiddenUndoContext(); + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::document::XUndoManager > m_xUndoManager; +}; + +} +// CHART2_UNDOGUARD_HXX +#endif diff --git a/chart2/source/controller/main/UndoManager.cxx b/chart2/source/controller/main/UndoManager.cxx deleted file mode 100644 index 21b3bbc1f725..000000000000 --- a/chart2/source/controller/main/UndoManager.cxx +++ /dev/null @@ -1,438 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_chart2.hxx" - -#include "UndoManager.hxx" -#include "ImplUndoManager.hxx" -#include "DisposeHelper.hxx" -#include "MutexContainer.hxx" -#include "macros.hxx" -#include "ChartViewHelper.hxx" - -#include <com/sun/star/util/XCloneable.hpp> -#include <com/sun/star/frame/XModel.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> - -#include <unotools/configitem.hxx> -#include <cppuhelper/compbase1.hxx> -#include <rtl/uuid.h> -#include <svx/svdundo.hxx> - -#include <functional> - -using namespace ::com::sun::star; - -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; -using ::rtl::OUString; - - -// -------------------------------------------------------------------------------- - -namespace chart -{ - -namespace impl -{ -typedef ::cppu::WeakComponentImplHelper1< - util::XModifyBroadcaster > - ModifyBroadcaster_Base; - -class ModifyBroadcaster : - public ::chart::MutexContainer, - public ModifyBroadcaster_Base -{ -public: - ModifyBroadcaster(); - - void fireEvent(); - -protected: - // ____ XModifyBroadcaster ____ - virtual void SAL_CALL addModifyListener( const Reference< util::XModifyListener >& xListener ) - throw (uno::RuntimeException); - virtual void SAL_CALL removeModifyListener( const Reference< util::XModifyListener >& xListener ) - throw (uno::RuntimeException); -}; - -ModifyBroadcaster::ModifyBroadcaster() : - ModifyBroadcaster_Base( m_aMutex ) -{} - -void SAL_CALL ModifyBroadcaster::addModifyListener( - const Reference< util::XModifyListener >& xListener ) - throw (uno::RuntimeException) -{ - rBHelper.addListener( ::getCppuType( & xListener ), xListener); -} - -void SAL_CALL ModifyBroadcaster::removeModifyListener( - const Reference< util::XModifyListener >& xListener ) - throw (uno::RuntimeException) -{ - rBHelper.removeListener( ::getCppuType( & xListener ), xListener ); -} - -void ModifyBroadcaster::fireEvent() -{ - ::cppu::OInterfaceContainerHelper* pIC = rBHelper.getContainer( - ::getCppuType((const uno::Reference< util::XModifyListener >*)0) ); - if( pIC ) - { - lang::EventObject aEvent( static_cast< lang::XComponent* >( this ) ); - ::cppu::OInterfaceIteratorHelper aIt( *pIC ); - while( aIt.hasMoreElements() ) - { - uno::Reference< util::XModifyListener > xListener( aIt.next(), uno::UNO_QUERY ); - if( xListener.is() ) - xListener->modified( aEvent ); - } - } -} - -} // namespace impl - -UndoManager::UndoManager() : - impl::UndoManager_Base( m_aMutex ), - m_apUndoStack( new impl::UndoStack()), - m_apRedoStack( new impl::UndoStack()), - m_pLastRemeberedUndoElement( 0 ), - m_nMaxNumberOfUndos( 100 ), - m_pModifyBroadcaster( 0 ) -{} - -UndoManager::~UndoManager() -{ - DisposeHelper::Dispose( m_xModifyBroadcaster ); - m_apUndoStack->disposeAndClear(); - m_apRedoStack->disposeAndClear(); - - delete m_pLastRemeberedUndoElement; - m_pLastRemeberedUndoElement = 0; -} - -void UndoManager::addShapeUndoAction( SdrUndoAction* pAction ) -{ - if ( !pAction ) - { - return; - } - - impl::ShapeUndoElement* pShapeUndoElement = new impl::ShapeUndoElement( pAction->GetComment(), pAction ); - if ( pShapeUndoElement ) - { - m_apUndoStack->push( pShapeUndoElement ); - m_apRedoStack->disposeAndClear(); - if ( !m_apUndoStepsConfigItem.get() ) - { - retrieveConfigUndoSteps(); - } - fireModifyEvent(); - } -} - -void UndoManager::impl_undoRedo( - Reference< frame::XModel > & xCurrentModel, - impl::UndoStack * pStackToRemoveFrom, - impl::UndoStack * pStackToAddTo, - bool bUndo ) -{ - if( pStackToRemoveFrom && ! pStackToRemoveFrom->empty() ) - { - // get model from undo/redo - impl::UndoElement * pTop( pStackToRemoveFrom->top()); - if( pTop ) - { - impl::ShapeUndoElement* pShapeUndoElement = dynamic_cast< impl::ShapeUndoElement* >( pTop ); - if ( pShapeUndoElement ) - { - impl::ShapeUndoElement* pNewShapeUndoElement = new impl::ShapeUndoElement( *pShapeUndoElement ); - pStackToAddTo->push( pNewShapeUndoElement ); - SdrUndoAction* pAction = pNewShapeUndoElement->getSdrUndoAction(); - if ( pAction ) - { - if ( bUndo ) - { - pAction->Undo(); - } - else - { - pAction->Redo(); - } - } - } - else - { - // put a clone of current model into redo/undo stack with the same - // action string as the undo/redo - pStackToAddTo->push( pTop->createFromModel( xCurrentModel )); - // change current model by properties of the model from undo - pTop->applyToModel( xCurrentModel ); - } - // remove the top undo element - pStackToRemoveFrom->pop(), pTop = 0; - ChartViewHelper::setViewToDirtyState( xCurrentModel ); - fireModifyEvent(); - } - } - else - { - OSL_ENSURE( false, "Can't Undo/Redo" ); - } -} - -void UndoManager::fireModifyEvent() -{ - if( m_xModifyBroadcaster.is()) - m_pModifyBroadcaster->fireEvent(); -} - - -// ____ ConfigItemListener ____ -void UndoManager::notify( const ::rtl::OUString & rPropertyName ) -{ - OSL_ENSURE( rPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Steps" )), - "Unwanted config property change Notified" ); - if( rPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Steps" ))) - retrieveConfigUndoSteps(); -} - -void UndoManager::retrieveConfigUndoSteps() -{ - if( ! m_apUndoStepsConfigItem.get()) - m_apUndoStepsConfigItem.reset( new impl::UndoStepsConfigItem( *this )); - m_nMaxNumberOfUndos = m_apUndoStepsConfigItem->getUndoSteps(); - m_apUndoStack->limitSize( m_nMaxNumberOfUndos ); - m_apRedoStack->limitSize( m_nMaxNumberOfUndos ); - - // a list of available undo steps could shrink here - fireModifyEvent(); -} - -// ____ XModifyBroadcaster ____ -void SAL_CALL UndoManager::addModifyListener( const Reference< util::XModifyListener >& aListener ) - throw (uno::RuntimeException) -{ - if( ! m_xModifyBroadcaster.is()) - { - m_pModifyBroadcaster = new impl::ModifyBroadcaster(); - m_xModifyBroadcaster.set( static_cast< cppu::OWeakObject* >( m_pModifyBroadcaster ), uno::UNO_QUERY ); - } - m_xModifyBroadcaster->addModifyListener( aListener ); -} - -void SAL_CALL UndoManager::removeModifyListener( const Reference< util::XModifyListener >& aListener ) - throw (uno::RuntimeException) -{ - if( ! m_xModifyBroadcaster.is()) - { - m_pModifyBroadcaster = new impl::ModifyBroadcaster(); - m_xModifyBroadcaster.set( static_cast< cppu::OWeakObject* >( m_pModifyBroadcaster ), uno::UNO_QUERY ); - } - m_xModifyBroadcaster->removeModifyListener( aListener ); -} - -// ____ chart2::XUndoManager ____ -void SAL_CALL UndoManager::preAction( const Reference< frame::XModel >& xModelBeforeChange ) - throw (uno::RuntimeException) -{ - OSL_ENSURE( ! m_pLastRemeberedUndoElement, "Looks like postAction or cancelAction call was missing" ); - m_pLastRemeberedUndoElement = new impl::UndoElement( xModelBeforeChange ); -} - -void SAL_CALL UndoManager::preActionWithArguments( - const Reference< frame::XModel >& xModelBeforeChange, - const Sequence< beans::PropertyValue >& aArguments ) - throw (uno::RuntimeException) -{ - bool bActionHandled( false ); - OSL_ENSURE( ! m_pLastRemeberedUndoElement, "Looks like postAction or cancelAction call was missing" ); - if( aArguments.getLength() > 0 ) - { - OSL_ENSURE( aArguments.getLength() == 1, "More than one argument is not supported yet" ); - if( aArguments[0].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("WithData"))) - { - m_pLastRemeberedUndoElement = new impl::UndoElementWithData( xModelBeforeChange ); - bActionHandled = true; - } - else if( aArguments[0].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("WithSelection"))) - { - m_pLastRemeberedUndoElement = new impl::UndoElementWithSelection( xModelBeforeChange ); - bActionHandled = true; - } - } - - if( !bActionHandled ) - preAction( xModelBeforeChange ); -} - -void SAL_CALL UndoManager::postAction( const OUString& aUndoText ) - throw (uno::RuntimeException) -{ - OSL_ENSURE( m_pLastRemeberedUndoElement, "Looks like preAction call was missing" ); - if( m_pLastRemeberedUndoElement ) - { - m_pLastRemeberedUndoElement->setActionString( aUndoText ); - m_apUndoStack->push( m_pLastRemeberedUndoElement ); - m_pLastRemeberedUndoElement = 0; - - // redo no longer possible - m_apRedoStack->disposeAndClear(); - - // it suffices to get the number of undo steps from config after the - // first time postAction has been called - if( ! m_apUndoStepsConfigItem.get()) - retrieveConfigUndoSteps(); - - fireModifyEvent(); - } -} - -void SAL_CALL UndoManager::cancelAction() - throw (uno::RuntimeException) -{ - delete m_pLastRemeberedUndoElement; - m_pLastRemeberedUndoElement = 0; -} - -void SAL_CALL UndoManager::cancelActionWithUndo( Reference< frame::XModel >& xModelToRestore ) - throw (uno::RuntimeException) -{ - if( m_pLastRemeberedUndoElement ) - { - m_pLastRemeberedUndoElement->applyToModel( xModelToRestore ); - cancelAction(); - } -} - -void SAL_CALL UndoManager::undo( Reference< frame::XModel >& xCurrentModel ) - throw (uno::RuntimeException) -{ - OSL_ASSERT( m_apUndoStack.get() && m_apRedoStack.get()); - impl_undoRedo( xCurrentModel, m_apUndoStack.get(), m_apRedoStack.get(), true ); -} - -void SAL_CALL UndoManager::redo( Reference< frame::XModel >& xCurrentModel ) - throw (uno::RuntimeException) -{ - OSL_ASSERT( m_apUndoStack.get() && m_apRedoStack.get()); - impl_undoRedo( xCurrentModel, m_apRedoStack.get(), m_apUndoStack.get(), false ); -} - -::sal_Bool SAL_CALL UndoManager::undoPossible() - throw (uno::RuntimeException) -{ - return ! m_apUndoStack->empty(); -} - -::sal_Bool SAL_CALL UndoManager::redoPossible() - throw (uno::RuntimeException) -{ - return ! m_apRedoStack->empty(); -} - -OUString SAL_CALL UndoManager::getCurrentUndoString() - throw (uno::RuntimeException) -{ - return m_apUndoStack->topUndoString(); -} - -OUString SAL_CALL UndoManager::getCurrentRedoString() - throw (uno::RuntimeException) -{ - return m_apRedoStack->topUndoString(); -} - -Sequence< OUString > SAL_CALL UndoManager::getAllUndoStrings() - throw (uno::RuntimeException) -{ - return m_apUndoStack->getUndoStrings(); -} - -Sequence< OUString > SAL_CALL UndoManager::getAllRedoStrings() - throw (uno::RuntimeException) -{ - return m_apRedoStack->getUndoStrings(); -} - -// ____ XUndoHelper ____ -Reference< frame::XModel > SAL_CALL UndoManager::getModelCloneForUndo( - const Reference< frame::XModel >& xModelBeforeChange ) - throw (uno::RuntimeException) -{ - return impl::UndoElement::cloneModel( xModelBeforeChange ); -} - -void SAL_CALL UndoManager::applyModelContent( - Reference< frame::XModel >& xModelToChange, - const Reference< frame::XModel >& xModelToCopyFrom ) - throw (uno::RuntimeException) -{ - impl::UndoElement::applyModelContentToModel( xModelToChange, xModelToCopyFrom ); -} - -// ____ XUnoTunnel ____ -sal_Int64 UndoManager::getSomething( const Sequence< sal_Int8 >& rId ) - throw (uno::RuntimeException) -{ - if ( rId.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) - { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ) ); - } - return 0; -} - -const Sequence< sal_Int8 >& UndoManager::getUnoTunnelId() -{ - static Sequence< sal_Int8 >* pSeq = 0; - if( !pSeq ) - { - osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); - if( !pSeq ) - { - static Sequence< sal_Int8 > aSeq( 16 ); - rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); - pSeq = &aSeq; - } - } - return *pSeq; -} - -UndoManager* UndoManager::getImplementation( const Reference< uno::XInterface > xObj ) -{ - UndoManager* pRet = NULL; - Reference< lang::XUnoTunnel > xUT( xObj, uno::UNO_QUERY ); - if ( xUT.is() ) - { - pRet = reinterpret_cast< UndoManager* >( sal::static_int_cast< sal_IntPtr >( xUT->getSomething( getUnoTunnelId() ) ) ); - } - return pRet; -} - -} // namespace chart diff --git a/chart2/source/controller/main/makefile.mk b/chart2/source/controller/main/makefile.mk index 729276d5bd0e..557d6cf6216f 100644 --- a/chart2/source/controller/main/makefile.mk +++ b/chart2/source/controller/main/makefile.mk @@ -72,12 +72,9 @@ SLOFILES = \ $(SLO)$/DrawCommandDispatch.obj \ $(SLO)$/ShapeController.obj \ $(SLO)$/ShapeToolbarController.obj \ - $(SLO)$/ImplUndoManager.obj \ - $(SLO)$/UndoManager.obj \ - $(SLO)$/UndoGuard.obj - -# $(SLO)$/CommonConverters.obj \ -# $(SLO)$/Scaling.obj \ + $(SLO)$/UndoActions.obj \ + $(SLO)$/UndoGuard.obj \ + $(SLO)$/ChartModelClone.obj \ # --- Targets ----------------------------------------------------------------- |