From 78fed9b8623faca46c3e1ef4dc633d80682d0414 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 9 Nov 2010 21:36:54 +0100 Subject: undoapi: step 0.1 of the migration of css.chart2.XUndoManager to css.document.XUndoManager: remove the XModel paramter from the XUndoManager methods, they're an implicit attribute of the instance --- chart2/source/controller/main/UndoCommandDispatch.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'chart2/source/controller/main/UndoCommandDispatch.cxx') diff --git a/chart2/source/controller/main/UndoCommandDispatch.cxx b/chart2/source/controller/main/UndoCommandDispatch.cxx index eb3d00a2723a..97201efa2e04 100644 --- a/chart2/source/controller/main/UndoCommandDispatch.cxx +++ b/chart2/source/controller/main/UndoCommandDispatch.cxx @@ -115,9 +115,9 @@ void SAL_CALL UndoCommandDispatch::dispatch( // /-- ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); if( URL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Undo" ))) - m_xUndoManager->undo( m_xModel ); + m_xUndoManager->undo(); else - m_xUndoManager->redo( m_xModel ); + m_xUndoManager->redo(); // \-- } } -- cgit From 587dfc9e8a00e8b97d5460e4e1d7c48de91b7425 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 9 Nov 2010 21:37:01 +0100 Subject: undoapi: step 2.0 of the migration of css.chart2.XUndoManager to css.document.XUndoManager: rename css.chart2.XUndoManager to XDocumentActions. Not sure this class will still exist (in either form) after the refactoring is finished. --- .../source/controller/main/UndoCommandDispatch.cxx | 34 ++++++++++------------ 1 file changed, 15 insertions(+), 19 deletions(-) (limited to 'chart2/source/controller/main/UndoCommandDispatch.cxx') diff --git a/chart2/source/controller/main/UndoCommandDispatch.cxx b/chart2/source/controller/main/UndoCommandDispatch.cxx index 97201efa2e04..0d1a26d6fc65 100644 --- a/chart2/source/controller/main/UndoCommandDispatch.cxx +++ b/chart2/source/controller/main/UndoCommandDispatch.cxx @@ -31,7 +31,6 @@ #include "UndoCommandDispatch.hxx" #include "macros.hxx" -#include #include #include @@ -57,10 +56,7 @@ 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()); + m_xDocumentActions.set( xModel, uno::UNO_QUERY ); } UndoCommandDispatch::~UndoCommandDispatch() @@ -68,7 +64,7 @@ UndoCommandDispatch::~UndoCommandDispatch() void UndoCommandDispatch::initialize() { - Reference< util::XModifyBroadcaster > xBroadcaster( m_xUndoManager, uno::UNO_QUERY ); + Reference< util::XModifyBroadcaster > xBroadcaster( m_xDocumentActions, uno::UNO_QUERY ); if( xBroadcaster.is() ) { xBroadcaster->addModifyListener( this ); @@ -79,27 +75,27 @@ void UndoCommandDispatch::fireStatusEvent( const OUString & rURL, const Reference< frame::XStatusListener > & xSingleListener /* = 0 */ ) { - if( m_xUndoManager.is() ) + if( m_xDocumentActions.is() ) { bool bFireAll = (rURL.getLength() == 0); uno::Any aUndoState, aRedoState; - if( m_xUndoManager->undoPossible()) + if( m_xDocumentActions->undoPossible()) { // using assignment for broken gcc 3.3 OUString aUndo = OUString( String( SchResId( STR_UNDO ))); - aUndoState <<= ( aUndo + m_xUndoManager->getCurrentUndoString()); + aUndoState <<= ( aUndo + m_xDocumentActions->getCurrentUndoString()); } - if( m_xUndoManager->redoPossible()) + if( m_xDocumentActions->redoPossible()) { // using assignment for broken gcc 3.3 OUString aRedo = OUString( String( SchResId( STR_REDO ))); - aRedoState <<= ( aRedo + m_xUndoManager->getCurrentRedoString()); + aRedoState <<= ( aRedo + m_xDocumentActions->getCurrentRedoString()); } if( bFireAll || rURL.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(".uno:Undo"))) - fireStatusEventForURL( C2U(".uno:Undo"), aUndoState, m_xUndoManager->undoPossible(), xSingleListener ); + fireStatusEventForURL( C2U(".uno:Undo"), aUndoState, m_xDocumentActions->undoPossible(), 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_xDocumentActions->redoPossible(), xSingleListener ); } } @@ -109,15 +105,15 @@ void SAL_CALL UndoCommandDispatch::dispatch( const Sequence< beans::PropertyValue >& /* Arguments */ ) throw (uno::RuntimeException) { - if( m_xUndoManager.is() ) + if( m_xDocumentActions.is() ) { // 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_xDocumentActions->undo(); else - m_xUndoManager->redo(); + m_xDocumentActions->redo(); // \-- } } @@ -126,13 +122,13 @@ void SAL_CALL UndoCommandDispatch::dispatch( /// is called when this is disposed void SAL_CALL UndoCommandDispatch::disposing() { - Reference< util::XModifyBroadcaster > xBroadcaster( m_xUndoManager, uno::UNO_QUERY ); + Reference< util::XModifyBroadcaster > xBroadcaster( m_xDocumentActions, uno::UNO_QUERY ); if( xBroadcaster.is() ) { xBroadcaster->removeModifyListener( this ); } - m_xUndoManager.clear(); + m_xDocumentActions.clear(); m_xModel.clear(); } @@ -140,7 +136,7 @@ void SAL_CALL UndoCommandDispatch::disposing() void SAL_CALL UndoCommandDispatch::disposing( const lang::EventObject& /* Source */ ) throw (uno::RuntimeException) { - m_xUndoManager.clear(); + m_xDocumentActions.clear(); m_xModel.clear(); } -- cgit From 4d0ae2eac2ac03475b7496f81e803b9b71b7481f Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 16 Nov 2010 08:49:38 +0100 Subject: undoapi: step 2.3 of the migration of css.chart2.XUndoManager to css.document.XUndoManager: migrate the clients of XDocumentActions to using the new XUndoManager, and completely remove the (X)DocumentActions still some more cleanup needed --- .../source/controller/main/UndoCommandDispatch.cxx | 51 +++++++++++++--------- 1 file changed, 30 insertions(+), 21 deletions(-) (limited to 'chart2/source/controller/main/UndoCommandDispatch.cxx') diff --git a/chart2/source/controller/main/UndoCommandDispatch.cxx b/chart2/source/controller/main/UndoCommandDispatch.cxx index 0d1a26d6fc65..92a4a469ff1b 100644 --- a/chart2/source/controller/main/UndoCommandDispatch.cxx +++ b/chart2/source/controller/main/UndoCommandDispatch.cxx @@ -32,9 +32,11 @@ #include "macros.hxx" #include +#include #include #include +#include // for ressource strings STR_UNDO and STR_REDO #include @@ -56,7 +58,8 @@ UndoCommandDispatch::UndoCommandDispatch( CommandDispatch( xContext ), m_xModel( xModel ) { - m_xDocumentActions.set( xModel, uno::UNO_QUERY ); + uno::Reference< document::XUndoManagerSupplier > xSuppUndo( m_xModel, uno::UNO_QUERY_THROW ); + m_xUndoManager.set( xSuppUndo->getUndoManager(), uno::UNO_SET_THROW ); } UndoCommandDispatch::~UndoCommandDispatch() @@ -64,38 +67,36 @@ UndoCommandDispatch::~UndoCommandDispatch() void UndoCommandDispatch::initialize() { - Reference< util::XModifyBroadcaster > xBroadcaster( m_xDocumentActions, uno::UNO_QUERY ); - if( xBroadcaster.is() ) - { - xBroadcaster->addModifyListener( this ); - } + Reference< util::XModifyBroadcaster > xBroadcaster( m_xUndoManager, uno::UNO_QUERY ); + ENSURE_OR_RETURN_VOID( xBroadcaster.is(), "UndoCommandDispatch::initialize: missing modification broadcaster interface!" ); + xBroadcaster->addModifyListener( this ); } void UndoCommandDispatch::fireStatusEvent( const OUString & rURL, const Reference< frame::XStatusListener > & xSingleListener /* = 0 */ ) { - if( m_xDocumentActions.is() ) + if( m_xUndoManager.is() ) { bool bFireAll = (rURL.getLength() == 0); uno::Any aUndoState, aRedoState; - if( m_xDocumentActions->undoPossible()) + if( m_xUndoManager->isUndoPossible()) { // using assignment for broken gcc 3.3 OUString aUndo = OUString( String( SchResId( STR_UNDO ))); - aUndoState <<= ( aUndo + m_xDocumentActions->getCurrentUndoString()); + aUndoState <<= ( aUndo + m_xUndoManager->getCurrentUndoActionTitle()); } - if( m_xDocumentActions->redoPossible()) + if( m_xUndoManager->isRedoPossible()) { // using assignment for broken gcc 3.3 OUString aRedo = OUString( String( SchResId( STR_REDO ))); - aRedoState <<= ( aRedo + m_xDocumentActions->getCurrentRedoString()); + aRedoState <<= ( aRedo + m_xUndoManager->getCurrentRedoActionTitle()); } if( bFireAll || rURL.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(".uno:Undo"))) - fireStatusEventForURL( C2U(".uno:Undo"), aUndoState, m_xDocumentActions->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_xDocumentActions->redoPossible(), xSingleListener ); + fireStatusEventForURL( C2U(".uno:Redo"), aRedoState, m_xUndoManager->isRedoPossible(), xSingleListener ); } } @@ -105,15 +106,22 @@ void SAL_CALL UndoCommandDispatch::dispatch( const Sequence< beans::PropertyValue >& /* Arguments */ ) throw (uno::RuntimeException) { - if( m_xDocumentActions.is() ) + if( m_xUndoManager.is() ) { // why is it necessary to lock the solar mutex here? // /-- ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); - if( URL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Undo" ))) - m_xDocumentActions->undo(); - else - m_xDocumentActions->redo(); + try + { + if( URL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Undo" ))) + m_xUndoManager->undo(); + else + m_xUndoManager->redo(); + } + catch( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } // \-- } } @@ -122,13 +130,14 @@ void SAL_CALL UndoCommandDispatch::dispatch( /// is called when this is disposed void SAL_CALL UndoCommandDispatch::disposing() { - Reference< util::XModifyBroadcaster > xBroadcaster( m_xDocumentActions, uno::UNO_QUERY ); + 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 ); } - m_xDocumentActions.clear(); + m_xUndoManager.clear(); m_xModel.clear(); } @@ -136,7 +145,7 @@ void SAL_CALL UndoCommandDispatch::disposing() void SAL_CALL UndoCommandDispatch::disposing( const lang::EventObject& /* Source */ ) throw (uno::RuntimeException) { - m_xDocumentActions.clear(); + m_xUndoManager.clear(); m_xModel.clear(); } -- cgit From cbcedd66765bb932cb60c98f0fa60f3beecca270 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 16 Nov 2010 19:31:36 +0100 Subject: undoapi: updated the Chart test backend --- chart2/source/controller/main/UndoCommandDispatch.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'chart2/source/controller/main/UndoCommandDispatch.cxx') diff --git a/chart2/source/controller/main/UndoCommandDispatch.cxx b/chart2/source/controller/main/UndoCommandDispatch.cxx index 92a4a469ff1b..b2252c1cae3c 100644 --- a/chart2/source/controller/main/UndoCommandDispatch.cxx +++ b/chart2/source/controller/main/UndoCommandDispatch.cxx @@ -59,7 +59,7 @@ UndoCommandDispatch::UndoCommandDispatch( m_xModel( xModel ) { uno::Reference< document::XUndoManagerSupplier > xSuppUndo( m_xModel, uno::UNO_QUERY_THROW ); - m_xUndoManager.set( xSuppUndo->getUndoManager(), uno::UNO_SET_THROW ); + m_xUndoManager.set( xSuppUndo->getUndoManager(), uno::UNO_QUERY_THROW ); } UndoCommandDispatch::~UndoCommandDispatch() @@ -118,6 +118,10 @@ void SAL_CALL UndoCommandDispatch::dispatch( else m_xUndoManager->redo(); } + catch( const document::UndoFailedException& ) + { + // silently ignore + } catch( const uno::Exception& ) { DBG_UNHANDLED_EXCEPTION(); -- cgit From 7623d8ea4e3f512a18ff074a38a5e682e24de9ba Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 4 Jan 2011 13:07:07 +0100 Subject: undoapi: post-rebase problems fixed --- chart2/source/controller/main/UndoCommandDispatch.cxx | 1 + 1 file changed, 1 insertion(+) (limited to 'chart2/source/controller/main/UndoCommandDispatch.cxx') diff --git a/chart2/source/controller/main/UndoCommandDispatch.cxx b/chart2/source/controller/main/UndoCommandDispatch.cxx index 4d19e6f901af..a008c492886d 100644 --- a/chart2/source/controller/main/UndoCommandDispatch.cxx +++ b/chart2/source/controller/main/UndoCommandDispatch.cxx @@ -29,6 +29,7 @@ #include "precompiled_chart2.hxx" #include "UndoCommandDispatch.hxx" +#include "ResId.hxx" #include "macros.hxx" #include -- cgit From d1959d69204893ee006c14dcb6f389e4dfe15449 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 5 Jan 2011 15:00:17 +0100 Subject: undoapi: fixed wrong resolution of merge conflict --- chart2/source/controller/main/UndoCommandDispatch.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'chart2/source/controller/main/UndoCommandDispatch.cxx') diff --git a/chart2/source/controller/main/UndoCommandDispatch.cxx b/chart2/source/controller/main/UndoCommandDispatch.cxx index a008c492886d..487def377d5c 100644 --- a/chart2/source/controller/main/UndoCommandDispatch.cxx +++ b/chart2/source/controller/main/UndoCommandDispatch.cxx @@ -83,13 +83,13 @@ void UndoCommandDispatch::fireStatusEvent( if( m_xUndoManager->isUndoPossible()) { // using assignment for broken gcc 3.3 - OUString aUndo = OUString( String( SchResId( STR_UNDO ))); + OUString aUndo = OUString( String( SvtResId( STR_UNDO ))); aUndoState <<= ( aUndo + m_xUndoManager->getCurrentUndoActionTitle()); } if( m_xUndoManager->isRedoPossible()) { // using assignment for broken gcc 3.3 - OUString aRedo = OUString( String( SchResId( STR_REDO ))); + OUString aRedo = OUString( String( SvtResId( STR_REDO ))); aRedoState <<= ( aRedo + m_xUndoManager->getCurrentRedoActionTitle()); } -- cgit