summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-03-03 13:15:24 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-03-03 13:44:15 +0000
commit37a4d67d6885860c279476c2504e35c3190ffc6c (patch)
tree6816c9faf819d7df596dbbd22d469b968b555d6c
parente55096a07a450782c4ab919b7ba60852841004c7 (diff)
flatten DocumentUndoGuard
which is a small object, and doesn't need a pimpl pattern Change-Id: Ib76f6e5ad0347be61fe29b22f57e1211ce3337cc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148172 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--framework/source/fwe/helper/documentundoguard.cxx67
-rw-r--r--include/framework/documentundoguard.hxx11
2 files changed, 26 insertions, 52 deletions
diff --git a/framework/source/fwe/helper/documentundoguard.cxx b/framework/source/fwe/helper/documentundoguard.cxx
index 3442cd501131..0a027921817a 100644
--- a/framework/source/fwe/helper/documentundoguard.cxx
+++ b/framework/source/fwe/helper/documentundoguard.cxx
@@ -44,8 +44,6 @@ namespace framework
typedef ::cppu::WeakImplHelper < XUndoManagerListener
> UndoManagerContextListener_Base;
- namespace {
-
class UndoManagerContextListener : public UndoManagerContextListener_Base
{
public:
@@ -100,8 +98,6 @@ namespace framework
bool m_documentDisposed;
};
- }
-
void SAL_CALL UndoManagerContextListener::undoActionAdded( const UndoManagerEvent& )
{
// not interested in
@@ -162,60 +158,37 @@ namespace framework
m_documentDisposed = true;
}
- //= DocumentUndoGuard_Data
-
- struct DocumentUndoGuard_Data
- {
- Reference< XUndoManager > xUndoManager;
- ::rtl::Reference< UndoManagerContextListener > pContextListener;
- };
+ //= DocumentUndoGuard
- namespace
+ DocumentUndoGuard::DocumentUndoGuard( const Reference< XInterface >& i_undoSupplierComponent )
{
-
- void lcl_init( DocumentUndoGuard_Data& i_data, const Reference< XInterface >& i_undoSupplierComponent )
+ try
{
- try
- {
- Reference< XUndoManagerSupplier > xUndoSupplier( i_undoSupplierComponent, UNO_QUERY );
- if ( xUndoSupplier.is() )
- i_data.xUndoManager.set( xUndoSupplier->getUndoManager(), css::uno::UNO_SET_THROW );
+ Reference< XUndoManagerSupplier > xUndoSupplier( i_undoSupplierComponent, UNO_QUERY );
+ if ( xUndoSupplier.is() )
+ mxUndoManager.set( xUndoSupplier->getUndoManager(), css::uno::UNO_SET_THROW );
- if ( i_data.xUndoManager.is() )
- i_data.pContextListener.set( new UndoManagerContextListener( i_data.xUndoManager ) );
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION("fwk");
- }
+ if ( mxUndoManager.is() )
+ mxContextListener.set( new UndoManagerContextListener( mxUndoManager ) );
}
-
- void lcl_restore( DocumentUndoGuard_Data& i_data )
+ catch( const Exception& )
{
- try
- {
- if ( i_data.pContextListener.is() )
- i_data.pContextListener->finish();
- i_data.pContextListener.clear();
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION("fwk");
- }
+ DBG_UNHANDLED_EXCEPTION("fwk");
}
}
- //= DocumentUndoGuard
-
- DocumentUndoGuard::DocumentUndoGuard( const Reference< XInterface >& i_undoSupplierComponent )
- :m_xData( new DocumentUndoGuard_Data )
- {
- lcl_init( *m_xData, i_undoSupplierComponent );
- }
-
DocumentUndoGuard::~DocumentUndoGuard()
{
- lcl_restore( *m_xData );
+ try
+ {
+ if ( mxContextListener.is() )
+ mxContextListener->finish();
+ mxContextListener.clear();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION("fwk");
+ }
}
} // namespace framework
diff --git a/include/framework/documentundoguard.hxx b/include/framework/documentundoguard.hxx
index ec1a5951b15c..c0cf232e7f28 100644
--- a/include/framework/documentundoguard.hxx
+++ b/include/framework/documentundoguard.hxx
@@ -21,18 +21,18 @@
#define INCLUDED_FRAMEWORK_DOCUMENTUNDOGUARD_HXX
#include <framework/fwkdllapi.h>
-
#include <com/sun/star/uno/Reference.hxx>
-
-#include <memory>
+#include <rtl/ref.hxx>
namespace com::sun::star::uno { class XInterface; }
+namespace com::sun::star::document { class XUndoManager; }
namespace framework
{
+ class UndoManagerContextListener;
+
//= DocumentUndoGuard
- struct DocumentUndoGuard_Data;
/** a helper class guarding the Undo manager of a document
This class guards, within a given scope, the Undo Manager of a document (or another component supporting
@@ -49,7 +49,8 @@ namespace framework
~DocumentUndoGuard();
private:
- std::unique_ptr< DocumentUndoGuard_Data > m_xData;
+ css::uno::Reference< css::document::XUndoManager > mxUndoManager;
+ ::rtl::Reference< UndoManagerContextListener > mxContextListener;
};