Tag: cws_src680_dba20blocker
User: fs      
Date: 05/06/23 06:56:46

Modified:
 /dba/dbaccess/source/core/dataaccess/
  ModelImpl.cxx, ModelImpl.hxx, databasecontext.cxx, databasedocument.cxx,
  databasedocument.hxx, datasource.cxx, datasource.hxx, documentcontainer.cxx,
  documentdefinition.cxx, makefile.mk

Log:
 copying fix for #i50905# into this CWS

File Changes:

Directory: /dba/dbaccess/source/core/dataaccess/
================================================

File [changed]: ModelImpl.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/ModelImpl.cxx?r1=1.4&r2=1.4.52.1
Delta lines:  +230 -37
----------------------
--- ModelImpl.cxx       30 Mar 2005 11:54:58 -0000      1.4
+++ ModelImpl.cxx       23 Jun 2005 13:56:40 -0000      1.4.52.1
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: ModelImpl.cxx,v $
  *
- *  $Revision: 1.4 $
+ *  $Revision: 1.4.52.1 $
  *
- *  last change: $Author: rt $ $Date: 2005/03/30 11:54:58 $
+ *  last change: $Author: fs $ $Date: 2005/06/23 13:56:40 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -140,9 +140,6 @@
 #ifndef _COMPHELPER_INTERACTION_HXX_
 #include <comphelper/interaction.hxx>
 #endif
-#ifndef DBA_COREDATAACCESS_COMMITLISTENER_HXX
-#include "commitlistener.hxx"
-#endif
 #ifndef _DBA_CORE_CONNECTION_HXX_
 #include "connection.hxx"
 #endif
@@ -212,6 +209,169 @@
 //........................................................................
 
 //============================================================
+//= DocumentStorageAccess
+//============================================================
+DBG_NAME( DocumentStorageAccess )
+class DocumentStorageAccess : public ::cppu::WeakImplHelper2<   
XDocumentSubStorageSupplier
+                                                            ,   
XTransactionListener >
+{
+    typedef ::std::map< ::rtl::OUString, Reference< XStorage > >    
NamedStorages;
+
+    ::osl::Mutex        m_aMutex;
+    /// all sub storages which we ever gave to the outer world
+    NamedStorages       m_aExposedStorages;
+    ODatabaseModelImpl* m_pModelImplementation;
+    bool                m_bPropagateCommitToRoot;
+
+public:
+    DocumentStorageAccess( ODatabaseModelImpl& _rModelImplementation )
+        :m_pModelImplementation( &_rModelImplementation )
+        ,m_bPropagateCommitToRoot( true )
+    {
+        DBG_CTOR( DocumentStorageAccess, NULL );
+    }
+
+protected:
+    ~DocumentStorageAccess()
+    {
+        DBG_DTOR( DocumentStorageAccess, NULL );
+    }
+
+public:
+    void dispose();
+
+    void    suspendCommitPropagation()
+    {
+        DBG_ASSERT( m_bPropagateCommitToRoot, "DocumentStorageAccess:: 
suspendCommitPropagation: already suspended" );
+        m_bPropagateCommitToRoot = false;
+    }
+    void    resumeCommitPropagation()
+    {
+        DBG_ASSERT( !m_bPropagateCommitToRoot, "DocumentStorageAccess:: 
suspendCommitPropagation: already suspended" );
+        m_bPropagateCommitToRoot = true;
+    }
+
+    // XDocumentSubStorageSupplier
+    virtual Reference< XStorage > SAL_CALL getDocumentSubStorage( const 
::rtl::OUString& aStorageName, ::sal_Int32 nMode ) throw (RuntimeException);
+    virtual Sequence< ::rtl::OUString > SAL_CALL getDocumentSubStoragesNames(  
) throw (IOException, RuntimeException);
+
+    // XTransactionListener
+    virtual void SAL_CALL preCommit( const 
::com::sun::star::lang::EventObject& aEvent ) throw 
(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL commited( const ::com::sun::star::lang::EventObject& 
aEvent ) throw (::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL preRevert( const 
::com::sun::star::lang::EventObject& aEvent ) throw 
(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+    virtual void SAL_CALL reverted( const ::com::sun::star::lang::EventObject& 
aEvent ) throw (::com::sun::star::uno::RuntimeException);
+
+    // XEventListener
+    virtual void SAL_CALL disposing( const 
::com::sun::star::lang::EventObject& Source ) throw 
(::com::sun::star::uno::RuntimeException);
+};
+
+//--------------------------------------------------------------------------
+void DocumentStorageAccess::dispose()
+{
+    ::osl::MutexGuard aGuard( m_aMutex );
+
+    for ( NamedStorages::iterator loop = m_aExposedStorages.begin();
+        loop != m_aExposedStorages.end();
+        ++loop
+        )
+    {
+        try
+        {
+            Reference< XTransactionBroadcaster > xBroadcaster( loop->second, 
UNO_QUERY );
+               if ( xBroadcaster.is() )
+                       xBroadcaster->removeTransactionListener( this );
+        }
+        catch( const Exception& )
+        {
+           OSL_ENSURE( sal_False, "DocumentStorageAccess::dispose: caught an 
exception!" );
+        }
+    }
+
+    m_aExposedStorages.clear();
+
+    m_pModelImplementation = NULL;
+}
+
+//--------------------------------------------------------------------------
+Reference< XStorage > SAL_CALL DocumentStorageAccess::getDocumentSubStorage( 
const ::rtl::OUString& aStorageName, ::sal_Int32 nMode ) throw 
(RuntimeException)
+{
+    ::osl::MutexGuard aGuard( m_aMutex );
+    NamedStorages::iterator pos = m_aExposedStorages.find( aStorageName );
+    if ( pos == m_aExposedStorages.end() )
+    {
+           Reference< XStorage > xResult = m_pModelImplementation->getStorage( 
aStorageName, nMode );
+        Reference< XTransactionBroadcaster > xBroadcaster( xResult, UNO_QUERY 
);
+           if ( xBroadcaster.is() )
+                   xBroadcaster->addTransactionListener( this );
+
+        pos = m_aExposedStorages.insert( NamedStorages::value_type( 
aStorageName, xResult ) ).first;
+    }
+
+    return pos->second;
+}
+
+//--------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL 
DocumentStorageAccess::getDocumentSubStoragesNames(  ) throw (IOException, 
RuntimeException)
+{
+       Sequence< ::rtl::OUString > aRet(2);
+       sal_Int32 nPos = 0;
+       aRet[nPos++] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("forms"));
+       aRet[nPos++] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("reports"));
+       return aRet;
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL DocumentStorageAccess::preCommit( const css::lang::EventObject& 
aEvent ) throw (Exception, RuntimeException)
+{
+       // not interested in
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL DocumentStorageAccess::commited( const css::lang::EventObject& 
aEvent ) throw (RuntimeException)
+{
+       ::osl::MutexGuard aGuard( m_aMutex );
+
+    if ( m_pModelImplementation )
+    {
+        Reference< XModifiable > xModiable( 
m_pModelImplementation->getModel_noCreate(), UNO_QUERY );
+       if ( xModiable.is() )
+                   xModiable->setModified( sal_True );
+    }
+
+    if ( m_pModelImplementation && m_bPropagateCommitToRoot )
+    {
+        TStorages::iterator aFind = 
m_pModelImplementation->m_aStorages.find(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("database")));
+        Reference<XStorage> xStorage(aEvent.Source,UNO_QUERY);
+           if  (   ( aFind != m_pModelImplementation->m_aStorages.end() )
+            &&  ( aFind->second == xStorage )
+            )
+           {
+            m_pModelImplementation->commitRootStorage();
+        }
+    }
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL DocumentStorageAccess::preRevert( const css::lang::EventObject& 
aEvent ) throw (Exception, RuntimeException)
+{
+       // not interested in
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL DocumentStorageAccess::reverted( const css::lang::EventObject& 
aEvent ) throw (RuntimeException)
+{
+       // not interested in
+}
+
+//--------------------------------------------------------------------------
+void SAL_CALL DocumentStorageAccess::disposing( const css::lang::EventObject& 
Source ) throw ( RuntimeException )
+{
+    ODatabaseModelImpl* pImpl = m_pModelImplementation;
+    if ( pImpl )
+        pImpl->disposing( Source );
+}
+
+//============================================================
 //= ODatabaseModelImpl
 //============================================================
 DBG_NAME(ODatabaseModelImpl)
@@ -229,9 +389,10 @@
                        ,m_pDBContext(NULL)
                        ,m_nControllerLockCount(0)
             ,m_bOwnStorage(sal_False)
-            ,m_xModel(_xModel)
+            ,m_xTempModel(_xModel)
                        ,m_nLoginTimeout(0)
                        ,m_refCount(0)
+            ,m_pStorageAccess( NULL )
 {
        // some kind of default
        DBG_CTOR(ODatabaseModelImpl,NULL);
@@ -261,6 +422,7 @@
             ,m_bOwnStorage(sal_False)
                        ,m_nLoginTimeout(0)
                        ,m_refCount(0)
+            ,m_pStorageAccess( NULL )
 {
        DBG_CTOR(ODatabaseModelImpl,NULL);
        // adjust our readonly flag
@@ -278,6 +440,12 @@
 {
        m_bReadOnly = sal_False;
        m_aContainer.resize(4);
+    if ( m_pStorageAccess )
+    {
+        m_pStorageAccess->dispose();
+        m_pStorageAccess->release();
+        m_pStorageAccess = NULL;
+    }
 }
 // 
-----------------------------------------------------------------------------
 ::rtl::OUString ODatabaseModelImpl::getURL(  )
@@ -344,6 +512,21 @@
 
//------------------------------------------------------------------------------
 void ODatabaseModelImpl::dispose()
 {
+    // dispose the data source and the model
+    try
+    {
+        Reference< XDataSource > xDS( m_xDataSource );
+               ::comphelper::disposeComponent( xDS );
+        m_xDataSource = WeakReference<XDataSource>();
+
+        ::comphelper::disposeComponent(m_xTempModel);
+    }
+    catch( const Exception& )
+    {
+    }
+       m_xDataSource = WeakReference<XDataSource>();
+    m_xTempModel.clear();
+
        ::std::vector<TContentPtr>::iterator aIter = m_aContainer.begin();
        ::std::vector<TContentPtr>::iterator aEnd = m_aContainer.end();
        for (;aIter != aEnd ; ++aIter)
@@ -505,10 +688,24 @@
        return m_xStorage;
 }
 // 
-----------------------------------------------------------------------------
-Reference<XStorage> ODatabaseModelImpl::getStorage(const ::rtl::OUString& 
_sStorageName,const Reference<css::embed::XTransactionListener>& 
_xEventListener, sal_Int32 nMode)
+DocumentStorageAccess* ODatabaseModelImpl::getDocumentStorageAccess()
+{
+    if ( !m_pStorageAccess )
+    {
+        m_pStorageAccess = new DocumentStorageAccess( *this );
+        m_pStorageAccess->acquire();
+    }
+    return m_pStorageAccess;
+}
+// 
-----------------------------------------------------------------------------
+Reference< XDocumentSubStorageSupplier > 
ODatabaseModelImpl::getDocumentSubStorageSupplier()
+{
+    return getDocumentStorageAccess();
+}
+// 
-----------------------------------------------------------------------------
+Reference<XStorage> ODatabaseModelImpl::getStorage(const ::rtl::OUString& 
_sStorageName,sal_Int32 nMode)
 {
        OSL_ENSURE(_sStorageName.getLength(),"ODatabaseModelImpl::getStorage: 
Invalid storage name!");
-       OSL_ENSURE(_xEventListener.is(),"No Eventlistener set!");
        Reference<XStorage> xStorage;
        TStorages::iterator aFind = m_aStorages.find(_sStorageName);
        if ( aFind == m_aStorages.end() )
@@ -522,7 +719,7 @@
                                xStorage = 
xMyStorage->openStorageElement(_sStorageName, m_bDocumentReadOnly ? 
ElementModes::READ : nMode);
                 Reference<XTransactionBroadcaster> xBroad(xStorage,UNO_QUERY);
                 if ( xBroad.is() )
-                    xBroad->addTransactionListener(_xEventListener);
+                    xBroad->addTransactionListener( getDocumentStorageAccess() 
);
                                aFind = 
m_aStorages.insert(TStorages::value_type(_sStorageName,xStorage)).first;
                        }
                        catch(Exception&)
@@ -537,8 +734,11 @@
        return xStorage;
 }
 // 
-----------------------------------------------------------------------------
-sal_Bool ODatabaseModelImpl::commitEmbeddedStorage()
+sal_Bool ODatabaseModelImpl::commitEmbeddedStorage( sal_Bool 
_bPreventRootCommits )
 {
+       if ( _bPreventRootCommits && m_pStorageAccess )
+        m_pStorageAccess->suspendCommitPropagation();
+
        sal_Bool bStore = sal_False;
        try
        {
@@ -554,6 +754,10 @@
        {
                OSL_ENSURE(0,"Exception Caught: Could not store embedded 
database!");
        }
+
+    if ( _bPreventRootCommits && m_pStorageAccess )
+        m_pStorageAccess->resumeCommitPropagation();
+
        return bStore;
 }
 // 
-----------------------------------------------------------------------------
@@ -561,13 +765,13 @@
 {
     try
     {
-        Reference<XModifiable> xModi(m_xModel.get(),UNO_QUERY);
+        Reference<XModifiable> xModi(m_xTempModel.get(),UNO_QUERY);
         if ( xModi.is() )
             xModi->setModified(_bModified);
     }
     catch(Exception)
     {
-        OSL_ENSURE(0,"Exception catched!");
+        OSL_ENSURE(0,"ODatabaseModelImpl::setModified: Exception caught!");
     }
 }
 // 
-----------------------------------------------------------------------------
@@ -586,10 +790,10 @@
        }
 }
 // 
-----------------------------------------------------------------------------
-Reference<XDataSource> ODatabaseModelImpl::getDataSource()
+Reference<XDataSource> ODatabaseModelImpl::getDataSource( bool 
_bCreateIfNecessary )
 {
        Reference<XDataSource> xDs = m_xDataSource;
-       if ( !xDs.is() )
+       if ( !xDs.is() && _bCreateIfNecessary )
        { // no data source, so we have to create one and register it later on
                xDs = new ODatabaseSource(this);
                m_xDataSource = xDs;
@@ -597,28 +801,17 @@
        return xDs;
 }
 // 
-----------------------------------------------------------------------------
-Reference< XModel> ODatabaseModelImpl::getModel()
+Reference< XModel> ODatabaseModelImpl::getModel_noCreate()
 {
-       Reference< XModel> xModel = m_xModel;
-       if ( !xModel.is() )
-               xModel = new ODatabaseDocument(this);
-       return xModel;
+    return m_xTempModel;
 }
 // 
-----------------------------------------------------------------------------
-void ODatabaseModelImpl::clear()
+Reference< XModel> ODatabaseModelImpl::createNewModel_deliverOwnership()
 {
-       try
-       {
-               Reference< XComponent > xComp(m_xDataSource.get(), UNO_QUERY);
-               m_xDataSource = WeakReference<XDataSource>();
-               if ( xComp.is() )
-                       xComp->dispose();
-               ::comphelper::disposeComponent(m_xModel);
-       }
-       catch(Exception&)
-       {
-               m_xModel = NULL;
-       }
+    OSL_PRECOND( !m_xTempModel.is(), "ODatabaseModelImpl::getModel_noCreate: 
not to be called if there already is a model!" );
+       if ( !m_xTempModel.is() )
+        m_xTempModel = ODatabaseDocument::createDatabaseDocument( this, 
ODatabaseDocument::FactoryAccess() );
+       return m_xTempModel;
 }
 // 
-----------------------------------------------------------------------------
 oslInterlockedCount SAL_CALL ODatabaseModelImpl::acquire()
@@ -630,7 +823,7 @@
 {
        if ( osl_decrementInterlockedCount(&m_refCount) == 0 )
        {
-               clear();
+        acquire();  // prevent multiple releases
                dispose();
         m_pDBContext->deregisterPrivate(m_sRealFileURL);
                delete this;

File [changed]: ModelImpl.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/ModelImpl.hxx?r1=1.5&r2=1.5.2.1
Delta lines:  +49 -18
---------------------
--- ModelImpl.hxx       14 Jun 2005 16:34:44 -0000      1.5
+++ ModelImpl.hxx       23 Jun 2005 13:56:40 -0000      1.5.2.1
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: ModelImpl.hxx,v $
  *
- *  $Revision: 1.5 $
+ *  $Revision: 1.5.2.1 $
  *
- *  last change: $Author: obo $ $Date: 2005/06/14 16:34:44 $
+ *  last change: $Author: fs $ $Date: 2005/06/23 13:56:40 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -182,6 +182,7 @@
 #ifndef _COM_SUN_STAR_UTIL_XREFRESHABLE_HPP_
 #include <com/sun/star/util/XRefreshable.hpp>
 #endif
+#include <memory>
 
 //........................................................................
 namespace dbaccess
@@ -200,11 +201,16 @@
 DECLARE_STL_USTRINGACCESS_MAP(::com::sun::star::uno::Reference< 
::com::sun::star::embed::XStorage >,TStorages);
 
 
+class ODatabaseContext;
+class DocumentStorageAccess;
+class OSharedConnectionManager;
 class ODatabaseModelImpl : public ::rtl::IReference
 {
-       friend class ODatabaseContext;
-       friend class OConnection;
-       friend class OSharedConnectionManager;
+private:
+    ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel>         
                                m_xTempModel;
+    ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDataSource> 
                        m_xDataSource;
+
+    DocumentStorageAccess*                                                     
             m_pStorageAccess;
 
 public:
 
@@ -271,10 +277,6 @@
     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController>    
                                m_xCurrentController;
     ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >      
                                m_xStorage;
 
-    ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel>         
                                m_xModel;
-    ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDataSource> 
                        m_xDataSource;
-
-
        ODatabaseContext*                                                       
                m_pDBContext;
        OSharedConnectionManager*                                               
        m_pSharedConnectionManager;
        oslInterlockedCount                                                     
                m_refCount;
@@ -289,9 +291,15 @@
     inline bool isEmbeddedDatabase() const { return ( 
m_sConnectURL.compareToAscii( "sdbc:embedded:", 14 ) == 0 ); }
 
     /** stores the embedded storage ("database")
+    
+        @param _bPreventRootCommits
+            Normally, committing the embedded storage results in also 
commiting the root storage
+            - this is an automatism for data safety reasons.
+            If you pass <TRUE/> here, committing the root storage is prevented 
for this particular
+            call.
                @return <TRUE/> if the storage could be commited, otherwise 
<FALSE/>
        */
-       sal_Bool commitEmbeddedStorage();
+       sal_Bool    commitEmbeddedStorage( sal_Bool _bPreventRootCommits = 
sal_False );
 
     /** commits all storages
     */
@@ -349,7 +357,7 @@
        ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > 
SAL_CALL getIsolatedConnection( const ::rtl::OUString& user, const 
::rtl::OUString& password ) throw(::com::sun::star::sdbc::SQLException, 
::com::sun::star::uno::RuntimeException);
        ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > 
SAL_CALL getIsolatedConnectionWithCompletion( const 
::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler 
>& handler ) throw(::com::sun::star::sdbc::SQLException, 
::com::sun::star::uno::RuntimeException);
 
-       void dispose(  );
+       void dispose();
 
     ::rtl::OUString getURL();
 
@@ -363,7 +371,7 @@
 // XCloseable
        void SAL_CALL close( sal_Bool DeliverOwnership ) throw 
(::com::sun::star::util::CloseVetoException, 
::com::sun::star::uno::RuntimeException);
 
-       ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage> 
getStorage(const ::rtl::OUString& _sStorageName,const 
::com::sun::star::uno::Reference< 
::com::sun::star::embed::XTransactionListener>& _xEventListener, sal_Int32 
nMode = ::com::sun::star::embed::ElementModes::READWRITE);
+       ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage> 
getStorage(const ::rtl::OUString& _sStorageName,sal_Int32 nMode = 
::com::sun::star::embed::ElementModes::READWRITE);
 // helper
        const ::com::sun::star::uno::Reference< 
::com::sun::star::util::XNumberFormatsSupplier >&
                        getNumberFormatsSupplier();
@@ -388,12 +396,35 @@
 
        /** returns the data source. If it doesn't exist it will be created
        */
-       ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource> 
getDataSource();
-       /** returns the model or creates a new one.
+       ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource> 
getDataSource( bool _bCreateIfNecessary = true );
+
+    /** returns the model, if there already exists one
        */
-       ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel>      
getModel();
+       ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > 
getModel_noCreate();
+
+    /** returns a new ->ODatabaseDocument
+
+        @precond
+            No ->ODatabaseDocument exists so far
+        @seealso
+            getModel_noCreate
+    */
+       ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > 
createNewModel_deliverOwnership();
+
+    struct ResetModelAccess { friend class ODatabaseDocument; private: 
ResetModelAccess() { } };
+    /** resets the model to NULL
+
+        Only to be called when the model is being disposed
+    */
+    void    modelIsDisposing( ResetModelAccess ) { m_xTempModel = NULL; }
+
+    DocumentStorageAccess*
+            getDocumentStorageAccess();
+
+    ::com::sun::star::uno::Reference< 
::com::sun::star::document::XDocumentSubStorageSupplier >
+            getDocumentSubStorageSupplier();
 
-       void clear();
+//     void clear();
 
        /** @see osl_incrementInterlockedCount.
         */

File [changed]: databasecontext.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/databasecontext.cxx?r1=1.29&r2=1.29.66.1
Delta lines:  +16 -12
---------------------
--- databasecontext.cxx 10 Mar 2005 16:33:20 -0000      1.29
+++ databasecontext.cxx 23 Jun 2005 13:56:40 -0000      1.29.66.1
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: databasecontext.cxx,v $
  *
- *  $Revision: 1.29 $
+ *  $Revision: 1.29.66.1 $
  *
- *  last change: $Author: vg $ $Date: 2005/03/10 16:33:20 $
+ *  last change: $Author: fs $ $Date: 2005/06/23 13:56:40 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -282,9 +282,8 @@
 {
        ::rtl::Reference<ODatabaseModelImpl> pImpl(new 
ODatabaseModelImpl(m_xServiceManager));
        pImpl->m_pDBContext = this;
-       Reference< XInterface > xRet = *(new ODatabaseSource(pImpl));
-       pImpl->m_xDataSource = Reference<XDataSource>(xRet,UNO_QUERY);
-    return xRet;
+    Reference< XDataSource > xDataSource( pImpl->getDataSource() );
+    return xDataSource.get();
 }
 
 //--------------------------------------------------------------------------
@@ -324,7 +323,6 @@
                )
        {
                OSL_ENSURE(aIter->second->m_refCount != 0,"Object is already 
disposed");
-               aIter->second->clear();
                aIter->second->dispose();               
        }
        m_aDatabaseObjects.clear();
@@ -421,16 +419,22 @@
     if ( !xExistent.is() )
     {
                ::rtl::Reference<ODatabaseModelImpl> pImpl(new 
ODatabaseModelImpl(_rName,m_xServiceManager,this));
-               xExistent = *(new ODatabaseSource(pImpl));
-               pImpl->m_xDataSource = 
Reference<XDataSource>(xExistent,UNO_QUERY);
+        xExistent = pImpl->getDataSource().get();
 
            Sequence< PropertyValue > aArgs(1);
            aArgs[0].Name = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FileName"));
            aArgs[0].Value <<= _sURL;
 
-           Reference<XModel> xModel = new ODatabaseDocument(pImpl);
+           Reference<XModel> xModel = pImpl->createNewModel_deliverOwnership();
+        DBG_ASSERT( xModel.is(), "ODatabaseContext::loadObjectFromURL: no 
model?" );
         // calls registerPrivate in attachResource
            xModel->attachResource(_sURL,aArgs);
+
+        // since the model has been newly created, we're its owner. However, 
we do not
+        // really need it, we ust used it for loading the document. So, 
dispose it to prevent
+        // leaks
+        // #i50905# / 2005-06-20 / [EMAIL PROTECTED]
+        ::comphelper::disposeComponent( xModel );
     }
 
     setTransientProperties(_sURL,xExistent);
@@ -520,7 +524,7 @@
                        ++aLookup
                )
        {
-               Reference< XInterface > 
xDataSource(aLookup->second->m_xDataSource.get(), UNO_QUERY);
+               Reference< XInterface > 
xDataSource(aLookup->second->getDataSource(false), UNO_QUERY);
                if ( xDataSource == xSource )
                        break;
        }
@@ -599,7 +603,7 @@
                ObjectCacheIterator aExistent = m_aDatabaseObjects.find(sURL);
                if ( aExistent != m_aDatabaseObjects.end() )
                {
-                       xExistent = aExistent->second->m_xDataSource;
+                       xExistent = aExistent->second->getDataSource(false);
                        if (xExistent.is())
                        {
                                Reference< XComponent > xComponent(xExistent, 
UNO_QUERY);

File [changed]: databasedocument.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/databasedocument.cxx?r1=1.19.32.1&r2=1.19.32.2
Delta lines:  +43 -88
---------------------
--- databasedocument.cxx        23 Jun 2005 11:03:52 -0000      1.19.32.1
+++ databasedocument.cxx        23 Jun 2005 13:56:41 -0000      1.19.32.2
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: databasedocument.cxx,v $
  *
- *  $Revision: 1.19.32.1 $
+ *  $Revision: 1.19.32.2 $
  *
- *  last change: $Author: fs $ $Date: 2005/06/23 11:03:52 $
+ *  last change: $Author: fs $ $Date: 2005/06/23 13:56:41 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -116,9 +116,6 @@
 #ifndef _COM_SUN_STAR_UI_XUICONFIGURATIONSTORAGE_HPP_
 #include <com/sun/star/ui/XUIConfigurationStorage.hpp>
 #endif
-#ifndef DBA_COREDATAACCESS_COMMITLISTENER_HXX
-#include "commitlistener.hxx"
-#endif
 #ifndef _COM_SUN_STAR_EMBED_XTRANSACTIONBROADCASTER_HPP_
 #include <com/sun/star/embed/XTransactionBroadcaster.hpp>
 #endif
@@ -187,7 +184,8 @@
 
        ::rtl::Reference<ODatabaseModelImpl> pImpl(new 
ODatabaseModelImpl(_rxFactory));
        pImpl->m_pDBContext = pContext;
-    return *(new ODatabaseDocument(pImpl));
+    Reference< XModel > xModel( pImpl->createNewModel_deliverOwnership() );
+    return xModel.get();
 }
 //--------------------------------------------------------------------------
 ODatabaseDocument::ODatabaseDocument(const 
::rtl::Reference<ODatabaseModelImpl>& _pImpl        )
@@ -196,20 +194,10 @@
             ,m_aModifyListeners(m_aMutex)
                        ,m_aCloseListener(m_aMutex)
             ,m_aDocEventListeners(m_aMutex)
-            ,m_bCommitMasterStorage(sal_True)
 {
        DBG_CTOR(ODatabaseDocument,NULL);
+
        // adjust our readonly flag
-       m_pChildCommitListen = NULL;
-       m_pImpl->m_xModel = this;
-       TStorages::iterator aIter = m_pImpl->m_aStorages.begin();
-       TStorages::iterator aEnd = m_pImpl->m_aStorages.end();
-       for (; aIter != aEnd ; ++aIter)
-       {
-               Reference<XComponent> xComp(aIter->second,UNO_QUERY);
-               if ( xComp.is() )
-                       xComp->addEventListener( static_cast< 
XTransactionListener* >( this ) );
-       }
     try
     {
         
m_xDocEventBroadcaster.set(m_pImpl->m_xServiceFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.GlobalEventBroadcaster"))),
@@ -302,12 +290,6 @@
                xContainer = m_pImpl->m_xCommandDefinitions;
                ::comphelper::disposeComponent(xContainer);
 
-               if ( m_pChildCommitListen )
-               {
-                       m_pChildCommitListen->dispose();
-                       m_pChildCommitListen->release();
-                       m_pChildCommitListen = NULL;
-               }
                m_pImpl->m_aContainer.clear();
                m_pImpl->lateInit();
        }
@@ -412,6 +394,35 @@
        if ( m_pImpl->m_xCurrentController == _xController )
                m_pImpl->m_xCurrentController = NULL;
 
+    // TODO: The below fragment is conceptually wrong.
+    //
+    // There are more clients of a database document (aka XModel) than its 
controllers.
+    // In particular, people might programmatically obtain a DataSource from 
the
+    // DatabaseContext, script it, and at some point obtain the document from
+    // the data source (XDocumentDataSource::getDatabaseDocument). All this 
might happen
+    // without any controller being involved, which means the document gets 
never disposed,
+    // which imlpies a resource leak.
+    //
+    // You might argue that the scripter who obtained the model is responsible 
for disposing
+    // it. However, she cannot know whether the model she just got from 
getDatabaseDocument
+    // is really hers (since it was newly created), or already owned by 
somebody else. So,
+    // she cannot know whether she is really allowed to dispose it.
+    //
+    // There is a pattern which could prevent this dilemma: closing with 
ownership delivery
+    // (XCloseable::close). With this pattern, every client of a component 
(here: the model)
+    // adds itself as XCloseListener to the component. When the client dies, 
it tries to
+    // close the component, with the DeliverOwnership parameter set to 
<TRUE/>. If there is
+    // another client of the component, it will veto the closing, and take the 
ownership
+    // (and in turn do an own close attempt later on). If there is no other 
client, closing
+    // will succeed.
+    //
+    // We should implement this for models, too. Then, controllers would be 
clients of the
+    // model, and do a close attempt when they disconnect. The model would 
never dispose
+    // itself (as it does now), but it would automatically be closed when the 
last client
+    // dies (provided that all clients respect this pattern). It turn, it 
would not be
+    // allowed to dispose a model directly.
+    //
+    // #i50905# / 2005-06-21 / [EMAIL PROTECTED]
     if ( m_pImpl.is() && m_pImpl->m_aControllers.empty() )
     {
         aGuard.clear();
@@ -645,9 +656,7 @@
                throw IOException( aError );
     }
 
-    m_bCommitMasterStorage = sal_False;
        m_pImpl->commitEmbeddedStorage();
-    m_bCommitMasterStorage = sal_True;
        xMyStorage->copyToStorage( xStorage );
        writeStorage(_rURL,_rArguments,xStorage);
        try
@@ -1047,32 +1056,15 @@
 {
        MutexGuard aGuard(m_aMutex);
     
::connectivity::checkDisposed(ODatabaseDocument_OfficeDocument::rBHelper.bDisposed);
-    OSL_ENSURE(m_pImpl.is(),"Impl is NULL");
 
-       Reference< XStorage > xResult = 
m_pImpl->getStorage(aStorageName,this,nMode);
-       if ( xResult.is() )
-       {
-               Reference< XTransactionBroadcaster > xBroadcaster( xResult, 
UNO_QUERY );
-               if ( xBroadcaster.is() )
-               {
-                       if ( m_pChildCommitListen == NULL )
-                       {
-                               m_pChildCommitListen = new 
OChildCommitListen_Impl( static_cast<XModifiable*>(this) );
-                               m_pChildCommitListen->acquire();
-                       }
-                       xBroadcaster->addTransactionListener( static_cast< 
XTransactionListener* >( m_pChildCommitListen ) );
-               }
-       }
-       return xResult;
+    Reference< XDocumentSubStorageSupplier > xStorageAccess( 
m_pImpl->getDocumentSubStorageSupplier() );
+    return xStorageAccess->getDocumentSubStorage( aStorageName, nMode );
 }
 // 
-----------------------------------------------------------------------------
 Sequence< ::rtl::OUString > SAL_CALL 
ODatabaseDocument::getDocumentSubStoragesNames(  ) throw 
(::com::sun::star::io::IOException, RuntimeException)
 {
-       Sequence< ::rtl::OUString > aRet(2);
-       sal_Int32 nPos = 0;
-       aRet[nPos++] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("forms"));
-       aRet[nPos++] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("reports"));
-       return aRet;
+    Reference< XDocumentSubStorageSupplier > xStorageAccess( 
m_pImpl->getDocumentSubStorageSupplier() );
+    return xStorageAccess->getDocumentSubStoragesNames();
 }
 // 
-----------------------------------------------------------------------------
 void ODatabaseDocument::notifyEvent(const ::rtl::OUString& _sEventName)
@@ -1107,28 +1099,17 @@
 
//------------------------------------------------------------------------------
 void ODatabaseDocument::disposing()
 {
-       Reference<XInterface> xHold = m_pImpl->m_xModel;        
+    Reference< XModel > xHoldAlive( this );
     {
            
notifyEvent(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnUnload")));
-        if ( m_pChildCommitListen )
-           {
-                       m_pChildCommitListen->dispose();
-                   m_pChildCommitListen->release();
-                   m_pChildCommitListen = NULL;
-           }
+        
            css::lang::EventObject aDisposeEvent(static_cast<XWeak*>(this));
            m_aModifyListeners.disposeAndClear( aDisposeEvent );
            m_aCloseListener.disposeAndClear( aDisposeEvent );
            m_aDocEventListeners.disposeAndClear( aDisposeEvent );
 
-           TStorages::iterator aIter = m_pImpl->m_aStorages.begin();
-           TStorages::iterator aEnd = m_pImpl->m_aStorages.end();
-           for (; aIter != aEnd ; ++aIter)
-           {
-                   Reference<XComponent> xComp(aIter->second,UNO_QUERY);
-                   if ( xComp.is() )
-                           xComp->removeEventListener( static_cast< 
XTransactionListener* >( this ) );
-           }
+        m_xDocEventBroadcaster = NULL;
+        m_xUIConfigurationManager = NULL;
 
                Reference<XChild> xChild(m_pImpl->m_xForms.get(),UNO_QUERY);
                if ( xChild.is() )
@@ -1144,7 +1125,7 @@
                if ( xChild.is() )
                        xChild->setParent(NULL);
 
-           m_pImpl->m_xModel.clear();
+        m_pImpl->modelIsDisposing( ODatabaseModelImpl::ResetModelAccess() );
     }
        m_pImpl.clear();
 }
@@ -1214,32 +1195,6 @@
 {
        if ( m_pImpl.is() )
                m_pImpl->disposing(Source);
-}
-//------------------------------------------------------------------
-void SAL_CALL ODatabaseDocument::preCommit( const 
::com::sun::star::lang::EventObject& aEvent ) throw 
(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
-{
-}
-//------------------------------------------------------------------
-void SAL_CALL ODatabaseDocument::commited( const 
::com::sun::star::lang::EventObject& aEvent ) throw 
(::com::sun::star::uno::RuntimeException)
-{
-    if ( m_pImpl.is() && m_bCommitMasterStorage )
-    {
-        ::osl::MutexGuard aGuard(m_aMutex);
-        TStorages::iterator aFind = 
m_pImpl->m_aStorages.find(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("database")));
-        Reference<XStorage> xStorage(aEvent.Source,UNO_QUERY);
-           if ( aFind != m_pImpl->m_aStorages.end() && aFind->second == 
xStorage )
-           {
-            m_pImpl->commitRootStorage();
-        }
-    }
-}
-//------------------------------------------------------------------
-void SAL_CALL ODatabaseDocument::preRevert( const 
::com::sun::star::lang::EventObject& aEvent ) throw 
(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
-{
-}
-//------------------------------------------------------------------
-void SAL_CALL ODatabaseDocument::reverted( const 
::com::sun::star::lang::EventObject& aEvent ) throw 
(::com::sun::star::uno::RuntimeException)
-{
 }
 //------------------------------------------------------------------
 //........................................................................

File [changed]: databasedocument.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/databasedocument.hxx?r1=1.3&r2=1.3.58.1
Delta lines:  +18 -20
---------------------
--- databasedocument.hxx        23 Mar 2005 09:46:19 -0000      1.3
+++ databasedocument.hxx        23 Jun 2005 13:56:41 -0000      1.3.58.1
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: databasedocument.hxx,v $
  *
- *  $Revision: 1.3 $
+ *  $Revision: 1.3.58.1 $
  *
- *  last change: $Author: vg $ $Date: 2005/03/23 09:46:19 $
+ *  last change: $Author: fs $ $Date: 2005/06/23 13:56:41 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -114,20 +114,18 @@
 {
 //........................................................................
 
-    class OChildCommitListen_Impl;
-    class ODatabaseContext;
+class ODatabaseContext;
 //============================================================
 //= ODatabaseDocument
 //============================================================
 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
        ODatabaseDocument_CreateInstance(const 
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory 
>&);
 
-typedef ::cppu::WeakComponentImplHelper11<     ::com::sun::star::frame::XModel
+typedef ::cppu::WeakComponentImplHelper10<     ::com::sun::star::frame::XModel
                                                        ,       
::com::sun::star::util::XModifiable
                                                        ,       
::com::sun::star::frame::XStorable
                                                        ,       
::com::sun::star::document::XEventBroadcaster
                                                        ,       
::com::sun::star::document::XEventListener
-                                                       ,       
::com::sun::star::embed::XTransactionListener
                                                        ,       
::com::sun::star::view::XPrintable
                                                        ,       
::com::sun::star::util::XCloseable
                             ,   ::com::sun::star::lang::XServiceInfo
@@ -139,15 +137,9 @@
 class ODatabaseDocument        : public ::comphelper::OBaseMutex
                          ,public ODatabaseDocument_OfficeDocument
 {
-       friend class ODatabaseContext;
-       friend ::com::sun::star::uno::Reference< 
::com::sun::star::uno::XInterface >
-               ODatabaseDocument_CreateInstance(const 
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory 
>&);
-
-    
     ::com::sun::star::uno::Reference< 
::com::sun::star::ui::XUIConfigurationManager>   m_xUIConfigurationManager;
     ::com::sun::star::uno::Reference< 
::com::sun::star::document::XEventListener >      m_xDocEventBroadcaster;
 
-    OChildCommitListen_Impl*                                                   
m_pChildCommitListen;
     ::cppu::OInterfaceContainerHelper                                  
m_aModifyListeners;
        ::cppu::OInterfaceContainerHelper                                       
m_aCloseListener;
     ::cppu::OInterfaceContainerHelper                                  
m_aDocEventListeners;
@@ -221,12 +213,24 @@
                                        , const 
::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& 
_xStorageToSaveTo);
 
 
+private:
+       ODatabaseDocument(const ::rtl::Reference<ODatabaseModelImpl>& _pImpl);
+    // Do NOT create those documents directly, always use 
ODatabaseModelImpl::getModel. Reason is that
+    // ODatabaseDocument require clear ownership, and in turn lifetime 
synchronisation with the ModelImpl.
+    // If you create a ODatabaseDocument directly, you might easily create a 
leak.
+    // #i50905# / 2005-06-20 / [EMAIL PROTECTED]
+
 protected:
     virtual void SAL_CALL disposing();
 
        virtual ~ODatabaseDocument();
+
 public:
-       ODatabaseDocument(const ::rtl::Reference<ODatabaseModelImpl>& _pImpl);
+    struct FactoryAccess { friend class ODatabaseModelImpl; private: 
FactoryAccess() { } };
+    static ODatabaseDocument* createDatabaseDocument( const 
::rtl::Reference<ODatabaseModelImpl>& _pImpl, FactoryAccess accessControl )
+    {
+        return new ODatabaseDocument( _pImpl );
+    }
        
 // ::com::sun::star::lang::XServiceInfo
     virtual ::rtl::OUString SAL_CALL getImplementationName(  ) 
throw(::com::sun::star::uno::RuntimeException);
@@ -309,12 +313,6 @@
     // XOfficeDatabaseDocument
     virtual ::com::sun::star::uno::Reference< 
::com::sun::star::sdbc::XDataSource > SAL_CALL getDataSource() throw 
(::com::sun::star::uno::RuntimeException);
 
-     // XTransactionListener
-    virtual void SAL_CALL preCommit( const 
::com::sun::star::lang::EventObject& aEvent ) throw 
(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
-    virtual void SAL_CALL commited( const ::com::sun::star::lang::EventObject& 
aEvent ) throw (::com::sun::star::uno::RuntimeException);
-    virtual void SAL_CALL preRevert( const 
::com::sun::star::lang::EventObject& aEvent ) throw 
(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
-    virtual void SAL_CALL reverted( const ::com::sun::star::lang::EventObject& 
aEvent ) throw (::com::sun::star::uno::RuntimeException);
-    
 // XStorageBasedDocument
 /*
     virtual void SAL_CALL loadFromStorage( const 
::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& 
xStorage, const ::com::sun::star::uno::Sequence< 
::com::sun::star::beans::PropertyValue >& aMediaDescriptor ) throw 
(::com::sun::star::lang::IllegalArgumentException, 
::com::sun::star::frame::DoubleInitializationException, 
::com::sun::star::io::IOException, ::com::sun::star::uno::Exception, 
::com::sun::star::uno::RuntimeException);

File [changed]: datasource.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/datasource.cxx?r1=1.59&r2=1.59.58.1
Delta lines:  +37 -11
---------------------
--- datasource.cxx      23 Mar 2005 09:46:37 -0000      1.59
+++ datasource.cxx      23 Jun 2005 13:56:42 -0000      1.59.58.1
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: datasource.cxx,v $
  *
- *  $Revision: 1.59 $
+ *  $Revision: 1.59.58.1 $
  *
- *  last change: $Author: vg $ $Date: 2005/03/23 09:46:37 $
+ *  last change: $Author: fs $ $Date: 2005/06/23 13:56:42 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -125,9 +125,6 @@
 #ifndef _COMPHELPER_INTERACTION_HXX_
 #include <comphelper/interaction.hxx>
 #endif
-#ifndef DBA_COREDATAACCESS_COMMITLISTENER_HXX
-#include "commitlistener.hxx"
-#endif
 #ifndef _DBA_CORE_CONNECTION_HXX_
 #include "connection.hxx"
 #endif
@@ -143,6 +140,9 @@
 #ifndef _COM_SUN_STAR_EMBED_XTRANSACTEDOBJECT_HPP_
 #include <com/sun/star/embed/XTransactedObject.hpp>
 #endif
+#ifndef _COM_SUN_STAR_DOCUMENT_XDOCUMENTSUBSTORAGESUPPLIER_HPP_
+#include <com/sun/star/document/XDocumentSubStorageSupplier.hpp>
+#endif
 
 #include <com/sun/star/document/XEventBroadcaster.hpp>
 #include <com/sun/star/view/XPrintable.hpp>
@@ -737,8 +737,8 @@
                                aDriverInfo[nCount].Name = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URL"));
                                aDriverInfo[nCount++].Value <<= 
m_pImpl->getURL();
                                aDriverInfo[nCount].Name = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Storage"));
-                               Reference<css::embed::XTransactionListener> 
xEvt(m_pImpl->m_xModel,UNO_QUERY);
-                               aDriverInfo[nCount++].Value <<= 
m_pImpl->getStorage(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("database")),xEvt,ElementModes::READWRITE);
+                Reference< css::document::XDocumentSubStorageSupplier> 
xDocSup( m_pImpl->getDocumentSubStorageSupplier() );
+                               aDriverInfo[nCount++].Value <<= 
xDocSup->getDocumentSubStorage(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("database")),ElementModes::READWRITE);
                        }
                        if (nAdditionalArgs)
                                xReturn = 
xManager->getConnectionWithInfo(m_pImpl->m_sConnectURL, 
::comphelper::concatSequences(aUserPwd,aDriverInfo));
@@ -1195,7 +1195,7 @@
        {
                ResettableMutexGuard _rGuard(m_aMutex);
                
::connectivity::checkDisposed(OComponentHelper::rBHelper.bDisposed);
-        Reference< css::frame::XStorable> 
xStorable(m_pImpl->getModel(),UNO_QUERY);
+        Reference< css::frame::XStorable> 
xStorable(getModelWithPossibleLeak(),UNO_QUERY);
         if ( xStorable.is() )
             xStorable->store();
                
@@ -1235,10 +1235,36 @@
                m_pImpl->setModified(sal_True);
 }
 // 
-----------------------------------------------------------------------------
+Reference< XModel > ODatabaseSource::getModelWithPossibleLeak()
+{
+    Reference< XModel > xModel;
+    if ( m_pImpl.is() )
+    {
+        xModel = m_pImpl->getModel_noCreate();
+        if ( !xModel.is() )
+        {
+            // In the course of #i50905#, the ownership of a XModel instance 
was more clearly
+            // defined and respected throughout all involved implementations. 
This place
+            // here is the last one where a fix wasn't easily possible within 
the restrictions
+            // which applied to the fix (time frame, risk)
+            //
+            // There's a pretty large comment in 
ODatabaseDocument::disconnectController
+            // explaining how this dilemma could be solved (which in fact 
suggests to
+            // get completely rid of the "sole ownership" concept, and replace 
it with
+            // shared ownership, and vetoable closing).
+            //
+            // #i50905# / 2005-06-20 / [EMAIL PROTECTED]
+            DBG_ERROR( "ODatabaseSource::::getModelWithPossibleLeak: creating 
a model instance with undefined ownership! Most probably a resource leak!" );
+            xModel = m_pImpl->createNewModel_deliverOwnership();
+        }
+    }
+    return xModel;
+}
+// 
-----------------------------------------------------------------------------
 // XDocumentDataSource
-Reference< ::com::sun::star::sdb::XOfficeDatabaseDocument > SAL_CALL 
ODatabaseSource::getDatabaseDocument() throw (RuntimeException)
+Reference< XOfficeDatabaseDocument > SAL_CALL 
ODatabaseSource::getDatabaseDocument() throw (RuntimeException)
 {
-       return m_pImpl.is() ? Reference< 
::com::sun::star::sdb::XOfficeDatabaseDocument >(m_pImpl->getModel(),UNO_QUERY) 
: Reference< ::com::sun::star::sdb::XOfficeDatabaseDocument >();
+    return Reference< XOfficeDatabaseDocument >( getModelWithPossibleLeak(), 
UNO_QUERY );
 }
 // 
-----------------------------------------------------------------------------
 //........................................................................

File [changed]: datasource.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/datasource.hxx?r1=1.29&r2=1.29.66.1
Delta lines:  +6 -3
-------------------
--- datasource.hxx      10 Mar 2005 16:34:36 -0000      1.29
+++ datasource.hxx      23 Jun 2005 13:56:42 -0000      1.29.66.1
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: datasource.hxx,v $
  *
- *  $Revision: 1.29 $
+ *  $Revision: 1.29.66.1 $
  *
- *  last change: $Author: vg $ $Date: 2005/03/10 16:34:36 $
+ *  last change: $Author: fs $ $Date: 2005/06/23 13:56:42 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -316,6 +316,9 @@
                const rtl::OUString& user, const rtl::OUString& password
                );
 
+    /// see the implementation for an explanation for the method's name ...
+    ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
+        getModelWithPossibleLeak();
 
 // other stuff
        void    flushTables();

File [changed]: documentcontainer.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/documentcontainer.cxx?r1=1.12.58.1&r2=1.12.58.2
Delta lines:  +5 -4
-------------------
--- documentcontainer.cxx       23 Jun 2005 13:31:40 -0000      1.12.58.1
+++ documentcontainer.cxx       23 Jun 2005 13:56:42 -0000      1.12.58.2
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: documentcontainer.cxx,v $
  *
- *  $Revision: 1.12.58.1 $
+ *  $Revision: 1.12.58.2 $
  *
- *  last change: $Author: fs $ $Date: 2005/06/23 13:31:40 $
+ *  last change: $Author: fs $ $Date: 2005/06/23 13:56:42 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -666,8 +666,9 @@
 { 
        static const ::rtl::OUString s_sForms = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("forms"));
        static const ::rtl::OUString s_sReports = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("reports"));
-       Reference<XTransactionListener> 
xEvt(m_pImpl->m_pDataSource->m_xModel,UNO_QUERY);
-       return m_pImpl->m_pDataSource ? 
m_pImpl->m_pDataSource->getStorage(m_bFormsContainer ? s_sForms : 
s_sReports,xEvt) : Reference< XStorage>();
+       return  m_pImpl->m_pDataSource
+        ?   m_pImpl->m_pDataSource->getStorage( m_bFormsContainer ? s_sForms : 
s_sReports )
+        :   Reference< XStorage>();
 }
 // 
-----------------------------------------------------------------------------
 sal_Bool ODocumentContainer::approveNewObject(const ::rtl::OUString& 
_sName,const Reference< XContent >& _rxObject) const

File [changed]: documentdefinition.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/documentdefinition.cxx?r1=1.26.40.1&r2=1.26.40.2
Delta lines:  +5 -4
-------------------
--- documentdefinition.cxx      23 Jun 2005 11:01:16 -0000      1.26.40.1
+++ documentdefinition.cxx      23 Jun 2005 13:56:43 -0000      1.26.40.2
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: documentdefinition.cxx,v $
  *
- *  $Revision: 1.26.40.1 $
+ *  $Revision: 1.26.40.2 $
  *
- *  last change: $Author: fs $ $Date: 2005/06/23 11:01:16 $
+ *  last change: $Author: fs $ $Date: 2005/06/23 13:56:43 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -1311,8 +1311,9 @@
 {
        static const ::rtl::OUString s_sForms = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("forms"));
        static const ::rtl::OUString s_sReports = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("reports"));
-       Reference<css::embed::XTransactionListener> 
xEvt(m_pImpl->m_pDataSource->m_xModel,UNO_QUERY);
-       return m_pImpl->m_pDataSource ? 
m_pImpl->m_pDataSource->getStorage(m_bForm ? s_sForms : s_sReports,xEvt) : 
Reference< XStorage>();
+       return  m_pImpl->m_pDataSource
+        ?   m_pImpl->m_pDataSource->getStorage( m_bForm ? s_sForms : 
s_sReports )
+        :   Reference< XStorage>();
 }
 // 
-----------------------------------------------------------------------------
 sal_Bool ODocumentDefinition::isModified()

File [changed]: makefile.mk
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/makefile.mk?r1=1.6&r2=1.6.66.1
Delta lines:  +3 -4
-------------------
--- makefile.mk 10 Mar 2005 16:35:45 -0000      1.6
+++ makefile.mk 23 Jun 2005 13:56:43 -0000      1.6.66.1
@@ -2,9 +2,9 @@
 #
 #   $RCSfile: makefile.mk,v $
 #
-#   $Revision: 1.6 $
+#   $Revision: 1.6.66.1 $
 #
-#   last change: $Author: vg $ $Date: 2005/03/10 16:35:45 $
+#   last change: $Author: fs $ $Date: 2005/06/23 13:56:43 $
 #
 #   The Contents of this file are made available subject to the terms of
 #   either of the following licenses
@@ -89,7 +89,6 @@
                $(SLO)$/intercept.obj                   \
                $(SLO)$/myucp_datasupplier.obj  \
                $(SLO)$/myucp_resultset.obj             \
-               $(SLO)$/commitlistener.obj              \
                $(SLO)$/databasedocument.obj    \
                $(SLO)$/ModelImpl.obj
 




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to