dbaccess/source/ui/browser/genericcontroller.cxx  |   58 ++-----------------
 framework/source/fwe/helper/documentundoguard.cxx |   67 ++++++----------------
 include/dbaccess/genericcontroller.hxx            |    7 +-
 include/framework/documentundoguard.hxx           |   11 +--
 4 files changed, 39 insertions(+), 104 deletions(-)

New commits:
commit df182c7e4235513916204a4dc4aec6ec6e4c746b
Author:     Noel Grandin <[email protected]>
AuthorDate: Fri Mar 3 14:02:29 2023 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Fri Mar 3 13:44:22 2023 +0000

    flatten OGenericUnoController
    
    rather than having a confusing mix of pimpl pattern and inline fields
    
    Change-Id: I2953df1893f49efb43f387d0d6348c6b17de83f6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148175
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/dbaccess/source/ui/browser/genericcontroller.cxx 
b/dbaccess/source/ui/browser/genericcontroller.cxx
index a5c8afbb306b..654ad2ff1525 100644
--- a/dbaccess/source/ui/browser/genericcontroller.cxx
+++ b/dbaccess/source/ui/browser/genericcontroller.cxx
@@ -37,7 +37,6 @@
 #include <com/sun/star/util/XCloseable.hpp>
 
 #include <com/sun/star/ui/XSidebarProvider.hpp>
-#include <sfx2/userinputinterception.hxx>
 
 #include <datasourceconnector.hxx>
 #include <com/sun/star/frame/FrameSearchFlag.hpp>
@@ -73,32 +72,11 @@ typedef std::unordered_map< sal_Int16, sal_Int16 > 
CommandHashMap;
 namespace dbaui
 {
 
-namespace {
-
-// UserDefinedFeatures
-class UserDefinedFeatures
-{
-public:
-    explicit UserDefinedFeatures( const Reference< XController >& 
_rxController );
-
-    void            execute( const URL& _rFeatureURL, const Sequence< 
PropertyValue>& _rArgs );
-
-private:
-    css::uno::WeakReference< XController > m_aController;
-};
-
-}
-
-UserDefinedFeatures::UserDefinedFeatures( const Reference< XController >& 
_rxController )
-    :m_aController( _rxController )
-{
-}
-
-void UserDefinedFeatures::execute( const URL& _rFeatureURL, const Sequence< 
PropertyValue>& _rArgs )
+void OGenericUnoController::executeUserDefinedFeatures( const URL& 
_rFeatureURL, const Sequence< PropertyValue>& _rArgs )
 {
     try
     {
-        Reference< XController > xController( Reference< XController 
>(m_aController), UNO_SET_THROW );
+        Reference< XController > xController( getXController(), UNO_SET_THROW 
);
         Reference< XDispatchProvider > xDispatchProvider( 
xController->getFrame(), UNO_QUERY_THROW );
         Reference< XDispatch > xDispatch( xDispatchProvider->queryDispatch(
             _rFeatureURL,
@@ -121,22 +99,10 @@ void UserDefinedFeatures::execute( const URL& 
_rFeatureURL, const Sequence< Prop
     }
 }
 
-// OGenericUnoController_Data
-struct OGenericUnoController_Data
-{
-    ::sfx2::UserInputInterception   m_aUserInputInterception;
-    UserDefinedFeatures             m_aUserDefinedFeatures;
-
-    OGenericUnoController_Data( OGenericUnoController& _rController, 
::osl::Mutex& _rMutex )
-        :m_aUserInputInterception( _rController, _rMutex )
-        ,m_aUserDefinedFeatures( _rController.getXController() )
-    {
-    }
-};
-
 // OGenericUnoController
 OGenericUnoController::OGenericUnoController(const Reference< 
XComponentContext >& _rM)
     :OGenericUnoController_Base( getMutex() )
+    ,m_aUserInputInterception(*this, getMutex())
     ,m_pView(nullptr)
 #ifdef DBG_UTIL
     ,m_bDescribingSupportedFeatures( false )
@@ -150,12 +116,6 @@ OGenericUnoController::OGenericUnoController(const 
Reference< XComponentContext
     ,m_bCurrentlyModified(false)
     ,m_bExternalTitle(false)
 {
-    osl_atomic_increment( &m_refCount );
-    {
-        m_pData.reset( new OGenericUnoController_Data( *this, getMutex() ) );
-    }
-    osl_atomic_decrement( &m_refCount );
-
 
     try
     {
@@ -815,7 +775,7 @@ void OGenericUnoController::Execute( sal_uInt16 _nId, const 
Sequence< PropertyVa
 
     // user defined features can be handled by dispatch interceptors resp. 
protocol handlers only.
     // So, we need to do a queryDispatch, and dispatch the URL
-    m_pData->m_aUserDefinedFeatures.execute( getURLForId( _nId ), _rArgs );
+    executeUserDefinedFeatures( getURLForId( _nId ), _rArgs );
 }
 
 URL OGenericUnoController::getURLForId(sal_Int32 _nId) const
@@ -1102,23 +1062,23 @@ void SAL_CALL 
OGenericUnoController::removeTitleChangeListener(const Reference<
 void SAL_CALL OGenericUnoController::addKeyHandler( const Reference< 
XKeyHandler >& _rxHandler )
 {
     if ( _rxHandler.is() )
-        m_pData->m_aUserInputInterception.addKeyHandler( _rxHandler );
+        m_aUserInputInterception.addKeyHandler( _rxHandler );
 }
 
 void SAL_CALL OGenericUnoController::removeKeyHandler( const Reference< 
XKeyHandler >& _rxHandler )
 {
-    m_pData->m_aUserInputInterception.removeKeyHandler( _rxHandler );
+    m_aUserInputInterception.removeKeyHandler( _rxHandler );
 }
 
 void SAL_CALL OGenericUnoController::addMouseClickHandler( const Reference< 
XMouseClickHandler >& _rxHandler )
 {
     if ( _rxHandler.is() )
-        m_pData->m_aUserInputInterception.addMouseClickHandler( _rxHandler );
+        m_aUserInputInterception.addMouseClickHandler( _rxHandler );
 }
 
 void SAL_CALL OGenericUnoController::removeMouseClickHandler( const Reference< 
XMouseClickHandler >& _rxHandler )
 {
-    m_pData->m_aUserInputInterception.removeMouseClickHandler( _rxHandler );
+    m_aUserInputInterception.removeMouseClickHandler( _rxHandler );
 }
 
 void OGenericUnoController::executeChecked(sal_uInt16 _nCommandId, const 
Sequence< PropertyValue >& aArgs)
@@ -1144,7 +1104,7 @@ Reference< XController > 
OGenericUnoController::getXController()
 
 bool OGenericUnoController::interceptUserInput( const NotifyEvent& _rEvent )
 {
-    return m_pData->m_aUserInputInterception.handleNotifyEvent( _rEvent );
+    return m_aUserInputInterception.handleNotifyEvent( _rEvent );
 }
 
 bool OGenericUnoController::isCommandChecked(sal_uInt16 _nCommandId) const
diff --git a/include/dbaccess/genericcontroller.hxx 
b/include/dbaccess/genericcontroller.hxx
index 6ef9393c2f9a..efe193b28e7d 100644
--- a/include/dbaccess/genericcontroller.hxx
+++ b/include/dbaccess/genericcontroller.hxx
@@ -63,6 +63,7 @@
 #include <sal/types.h>
 #include <tools/link.hxx>
 #include <vcl/vclptr.hxx>
+#include <sfx2/userinputinterception.hxx>
 
 namespace com::sun::star {
     namespace awt { class XKeyHandler; }
@@ -208,9 +209,7 @@ namespace dbaui
         SupportedFeatures               m_aSupportedFeatures;
         ::comphelper::NamedValueCollection
                                         m_aInitParameters;
-
-        ::std::unique_ptr< OGenericUnoController_Data >
-                                        m_pData;
+        ::sfx2::UserInputInterception   m_aUserInputInterception;
         VclPtr<ODataView>               m_pView;                // our (VCL) 
"main window"
 
 #ifdef DBG_UTIL
@@ -376,6 +375,8 @@ namespace dbaui
 
         void ImplBroadcastFeatureState(const OUString& _rFeature, const 
css::uno::Reference< css::frame::XStatusListener > & xListener, bool 
_bIgnoreCache);
 
+        void executeUserDefinedFeatures( const css::util::URL& _rFeatureURL, 
const css::uno::Sequence< css::beans::PropertyValue>& _rArgs );
+
         // link methods
         DECL_DLLPRIVATE_LINK(OnAsyncInvalidateAll, void*, void);
         DECL_DLLPRIVATE_LINK(OnAsyncCloseTask, void*, void);
commit 37a4d67d6885860c279476c2504e35c3190ffc6c
Author:     Noel Grandin <[email protected]>
AuthorDate: Fri Mar 3 13:15:24 2023 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Fri Mar 3 13:44:15 2023 +0000

    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 <[email protected]>

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;
     };
 
 

Reply via email to