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/main/UndoCommandDispatch.cxx | |
parent | 894985ff00c217013cc360a77108fc68cd8647e7 (diff) | |
parent | 0ceb085ea2b49234664765161095f2e5911e2b3b (diff) |
CWS gnumake3: resync to m99
Diffstat (limited to 'chart2/source/controller/main/UndoCommandDispatch.cxx')
-rw-r--r-- | chart2/source/controller/main/UndoCommandDispatch.cxx | 48 |
1 files changed, 29 insertions, 19 deletions
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 ); |