dbaccess/source/core/dataaccess/ModelImpl.cxx  |    3 -
 dbaccess/source/core/dataaccess/datasource.cxx |   73 -------------------------
 dbaccess/source/core/inc/ModelImpl.hxx         |   70 ++++++++++++++++++++++-
 3 files changed, 68 insertions(+), 78 deletions(-)

New commits:
commit 1c15934170341bbcfb4671fdbb01c2259265b3e1
Author:     Julien Nabet <serval2...@yahoo.fr>
AuthorDate: Wed Oct 18 10:45:36 2023 +0200
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Thu Oct 19 07:45:34 2023 +0200

    Related tdf#144256: remove m_pSharedConnectionManager
    
    to only use "m_xSharedConnectionManager".
    For this, it required some refactoring but except the removing, logic 
hasn't been changed.
    
    Change-Id: Iccfe5c45381f31019a0751a61cea6661c88188f1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158107
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx 
b/dbaccess/source/core/dataaccess/ModelImpl.cxx
index 3e21289dbe9a..66f8309ac657 100644
--- a/dbaccess/source/core/dataaccess/ModelImpl.cxx
+++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx
@@ -370,7 +370,6 @@ ODatabaseModelImpl::ODatabaseModelImpl( const Reference< 
XComponentContext >& _r
             ,m_bModified(false)
             ,m_bDocumentReadOnly(false)
             ,m_bMacroCallsSeenWhileLoading(false)
-            ,m_pSharedConnectionManager(nullptr)
             ,m_nControllerLockCount(0)
 {
     // some kind of default
@@ -401,7 +400,6 @@ ODatabaseModelImpl::ODatabaseModelImpl(
             ,m_bModified(false)
             ,m_bDocumentReadOnly(false)
             ,m_bMacroCallsSeenWhileLoading(false)
-            ,m_pSharedConnectionManager(nullptr)
             ,m_nControllerLockCount(0)
 {
     impl_construct_nothrow();
@@ -624,7 +622,6 @@ void ODatabaseModelImpl::clearConnections()
         }
     }
 
-    m_pSharedConnectionManager = nullptr;
     m_xSharedConnectionManager = nullptr;
 }
 
diff --git a/dbaccess/source/core/dataaccess/datasource.cxx 
b/dbaccess/source/core/dataaccess/datasource.cxx
index e2c02d49c818..55c161b854d1 100644
--- a/dbaccess/source/core/dataaccess/datasource.cxx
+++ b/dbaccess/source/core/dataaccess/datasource.cxx
@@ -62,7 +62,6 @@
 #include <sal/log.hxx>
 #include <tools/urlobj.hxx>
 #include <unotools/sharedunocomponent.hxx>
-#include <rtl/digest.h>
 
 #include <algorithm>
 #include <iterator>
@@ -250,69 +249,6 @@ void SAL_CALL 
OAuthenticationContinuation::setRememberAccount( RememberAuthentic
     SAL_WARN("dbaccess","OAuthenticationContinuation::setRememberAccount: not 
supported!");
 }
 
-namespace {
-
-/** The class OSharedConnectionManager implements a structure to share 
connections.
-    It owns the master connections which will be disposed when the last 
connection proxy is gone.
-*/
-// need to hold the digest
-struct TDigestHolder
-{
-    sal_uInt8 m_pBuffer[RTL_DIGEST_LENGTH_SHA1];
-    TDigestHolder()
-    {
-        m_pBuffer[0] = 0;
-    }
-
-};
-
-}
-
-class OSharedConnectionManager : public ::cppu::WeakImplHelper< XEventListener 
>
-{
-
-     // contains the currently used master connections
-    struct TConnectionHolder
-    {
-        Reference< XConnection >    xMasterConnection;
-        oslInterlockedCount         nALiveCount;
-    };
-
-    // the less-compare functor, used for the stl::map
-    struct TDigestLess
-    {
-        bool operator() (const TDigestHolder& x, const TDigestHolder& y) const
-        {
-            sal_uInt32 i;
-            for(i=0;i < RTL_DIGEST_LENGTH_SHA1 && (x.m_pBuffer[i] >= 
y.m_pBuffer[i]); ++i)
-                ;
-            return i < RTL_DIGEST_LENGTH_SHA1;
-        }
-    };
-
-    typedef std::map< TDigestHolder,TConnectionHolder,TDigestLess>        
TConnectionMap;      // holds the master connections
-    typedef std::map< Reference< XConnection >,TConnectionMap::iterator>  
TSharedConnectionMap;// holds the shared connections
-
-    ::osl::Mutex                m_aMutex;
-    TConnectionMap              m_aConnections;         // remember the master 
connection in conjunction with the digest
-    TSharedConnectionMap        m_aSharedConnection;    // the shared 
connections with conjunction with an iterator into the connections map
-    Reference< XProxyFactory >  m_xProxyFactory;
-
-protected:
-    virtual ~OSharedConnectionManager() override;
-
-public:
-    explicit OSharedConnectionManager(const Reference< XComponentContext >& 
_rxContext);
-
-    void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
-    Reference<XConnection> getConnection(   const OUString& url,
-                                            const OUString& user,
-                                            const OUString& password,
-                                            const Sequence< PropertyValue >& 
_aInfo,
-                                            ODatabaseSource* _pDataSource);
-    void addEventListener(const Reference<XConnection>& _rxConnection, 
TConnectionMap::iterator const & _rIter);
-};
-
 OSharedConnectionManager::OSharedConnectionManager(const Reference< 
XComponentContext >& _rxContext)
 {
     m_xProxyFactory.set( ProxyFactory::create( _rxContext ) );
@@ -1234,14 +1170,9 @@ Reference< XConnection > 
ODatabaseSource::getConnection(const OUString& user, co
     { // create a new proxy for the connection
         if ( !m_pImpl->m_xSharedConnectionManager.is() )
         {
-            // TODO ideally we could just have one field, but to make that work
-            // we'd need to move OSharedConnectionManager into its own file 
and header
-            rtl::Reference<OSharedConnectionManager> manager =
-                new OSharedConnectionManager( m_pImpl->m_aContext );
-            m_pImpl->m_pSharedConnectionManager = manager.get();
-            m_pImpl->m_xSharedConnectionManager = 
m_pImpl->m_pSharedConnectionManager;
+            m_pImpl->m_xSharedConnectionManager = new 
OSharedConnectionManager( m_pImpl->m_aContext );
         }
-        xConn = m_pImpl->m_pSharedConnectionManager->getConnection(
+        xConn = m_pImpl->m_xSharedConnectionManager->getConnection(
             m_pImpl->m_sConnectURL, user, password, 
m_pImpl->m_xSettings->getPropertyValues(), this );
     }
 
diff --git a/dbaccess/source/core/inc/ModelImpl.hxx 
b/dbaccess/source/core/inc/ModelImpl.hxx
index 3140c3c2bdc7..a582ece2575f 100644
--- a/dbaccess/source/core/inc/ModelImpl.hxx
+++ b/dbaccess/source/core/inc/ModelImpl.hxx
@@ -27,17 +27,21 @@
 #include <com/sun/star/document/XDocumentSubStorageSupplier.hpp>
 #include <com/sun/star/embed/XStorage.hpp>
 #include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/reflection/ProxyFactory.hpp>
 #include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
 #include <com/sun/star/sdbc/XDataSource.hpp>
 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
 
+
 #include <comphelper/namedvaluecollection.hxx>
 #include <cppuhelper/weakref.hxx>
 #include <vcl/svapp.hxx>
 #include <sfx2/docmacromode.hxx>
 #include <sfx2/docstoragemodifylistener.hxx>
 #include <unotools/sharedunocomponent.hxx>
+#include <rtl/digest.h>
 #include <rtl/ref.hxx>
 #include <o3tl/enumarray.hxx>
 
@@ -90,7 +94,67 @@ typedef ::utl::SharedUNOComponent< css::embed::XStorage >  
SharedStorage;
 
 class ODatabaseContext;
 class DocumentStorageAccess;
-class OSharedConnectionManager;
+class ODatabaseSource;
+
+
+/** The class OSharedConnectionManager implements a structure to share 
connections.
+    It owns the master connections which will be disposed when the last 
connection proxy is gone.
+*/
+// need to hold the digest
+struct TDigestHolder
+{
+    sal_uInt8 m_pBuffer[RTL_DIGEST_LENGTH_SHA1];
+    TDigestHolder()
+    {
+        m_pBuffer[0] = 0;
+    }
+
+};
+
+class OSharedConnectionManager : public ::cppu::WeakImplHelper< 
css::lang::XEventListener >
+{
+    // contains the currently used master connections
+    struct TConnectionHolder
+    {
+        css::uno::Reference< css::sdbc::XConnection >    xMasterConnection;
+        oslInterlockedCount         nALiveCount;
+    };
+
+    // the less-compare functor, used for the stl::map
+    struct TDigestLess
+    {
+        bool operator() (const TDigestHolder& x, const TDigestHolder& y) const
+        {
+            sal_uInt32 i;
+            for(i=0;i < RTL_DIGEST_LENGTH_SHA1 && (x.m_pBuffer[i] >= 
y.m_pBuffer[i]); ++i)
+                ;
+            return i < RTL_DIGEST_LENGTH_SHA1;
+        }
+    };
+
+    typedef std::map< TDigestHolder,TConnectionHolder,TDigestLess>        
TConnectionMap;      // holds the master connections
+    typedef std::map< css::uno::Reference< css::sdbc::XConnection 
>,TConnectionMap::iterator>  TSharedConnectionMap;// holds the shared 
connections
+
+    ::osl::Mutex                m_aMutex;
+    TConnectionMap              m_aConnections;         // remember the master 
connection in conjunction with the digest
+    TSharedConnectionMap        m_aSharedConnection;    // the shared 
connections with conjunction with an iterator into the connections map
+    css::uno::Reference< css::reflection::XProxyFactory >  m_xProxyFactory;
+
+protected:
+    virtual ~OSharedConnectionManager() override;
+
+public:
+    explicit OSharedConnectionManager(const css::uno::Reference< 
css::uno::XComponentContext >& _rxContext);
+
+    void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
+    css::uno::Reference< css::sdbc::XConnection > getConnection(   const 
OUString& url,
+                                            const OUString& user,
+                                            const OUString& password,
+                                            const css::uno::Sequence< 
css::beans::PropertyValue >& _aInfo,
+                                            ODatabaseSource* _pDataSource);
+    void addEventListener(const css::uno::Reference< css::sdbc::XConnection >& 
_rxConnection, TConnectionMap::iterator const & _rIter);
+};
+
 
 class ODatabaseModelImpl    :public ::sfx2::IMacroDocumentAccess
                             ,public ::sfx2::IModifiableDocument
@@ -188,9 +252,7 @@ public:
                                                         m_xSettings;
     css::uno::Sequence< OUString >                      m_aTableFilter;
     css::uno::Sequence< OUString >                      m_aTableTypeFilter;
-    OSharedConnectionManager*                           
m_pSharedConnectionManager;
-    css::uno::Reference< css::lang::XEventListener >
-                                                        
m_xSharedConnectionManager;
+    rtl::Reference< OSharedConnectionManager >          
m_xSharedConnectionManager;
     css::uno::Reference<css::awt::XWindow>
                                                         m_xDialogParent;
     sal_uInt16                                          m_nControllerLockCount;

Reply via email to