Tag: cws_src680_dba201b
User: fs      
Date: 05/07/20 03:13:30

Modified:
 /dba/dbaccess/source/ui/app/
  AppController.cxx

Log:
 #i51255# use a ModelControllerConnector to connect ourself to the model, and 
to keep it alive as long as we ourself live

File Changes:

Directory: /dba/dbaccess/source/ui/app/
=======================================

File [changed]: AppController.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppController.cxx?r1=1.20.26.2&r2=1.20.26.3
Delta lines:  +40 -17
---------------------
--- AppController.cxx   11 Jul 2005 13:37:09 -0000      1.20.26.2
+++ AppController.cxx   20 Jul 2005 10:13:27 -0000      1.20.26.3
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: AppController.cxx,v $
  *
- *  $Revision: 1.20.26.2 $
+ *  $Revision: 1.20.26.3 $
  *
- *  last change: $Author: fs $ $Date: 2005/07/11 13:37:09 $
+ *  last change: $Author: fs $ $Date: 2005/07/20 10:13:27 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -435,7 +435,7 @@
                        m_xDataSource = NULL;
                }
 
-               Reference< XModifyBroadcaster >  xBroadcaster(m_xModel, 
UNO_QUERY);
+               Reference< XModifyBroadcaster > xBroadcaster( m_xModel, 
UNO_QUERY );
                if ( xBroadcaster.is() )
                        
xBroadcaster->removeModifyListener(static_cast<XModifyListener*>(this));
 
@@ -457,11 +457,10 @@
                                                getStrippedDatabaseName(),
                                                ::rtl::OUString() );
             }
-                       m_xModel->disconnectController( this );
-                       // forces the data source to reload
-               }
 
-               m_xModel = NULL;
+            m_aModelConnector.swap( ModelControllerConnector() );
+            m_xModel.clear();
+               }
        }
        catch(Exception)
        {
@@ -541,7 +540,8 @@
        }
        else if ( _rSource.Source == m_xModel )
        {
-               m_xModel = NULL;
+               m_xModel.clear();
+        m_aModelConnector.clear();
        }
        else if ( _rSource.Source == m_xDataSource )
        {
@@ -980,7 +980,11 @@
                             {
                                 Reference<XConnection> xDestConnection;
                                            ensureConnection(xDestConnection);
-                                                           
m_aTableCopyHelper.pasteTable( aTransferData , getDatabaseName() , 
xDestConnection);
+
+                                SharedConnection xConnection( xDestConnection, 
false /* don't take ownership */ );
+                                // TODO: migrate ensureConnection to the 
SharedConnection-API
+
+                                m_aTableCopyHelper.pasteTable( aTransferData , 
getDatabaseName(), xConnection );
                             }
                                                        break;
                                                case E_QUERY:
@@ -2348,7 +2352,11 @@
        {
         Reference<XConnection> xDestConnection;         // supports the 
service sdb::connection
            ensureConnection( xDestConnection);
-           if ( xDestConnection.is() && 
m_aTableCopyHelper.copyTagTable(aDroppedData,m_aAsyncDrop,xDestConnection) )
+
+        SharedConnection xConnection( xDestConnection, false /* don't take 
ownership */ );
+        // TODO: migrate ensureConnection to the SharedConnection-API
+
+        if ( xDestConnection.is() && m_aTableCopyHelper.copyTagTable( 
aDroppedData, m_aAsyncDrop, xConnection ) )
         {
                        // asyncron because we some dialogs and we aren't 
allowed to show them while in D&D
                        m_nAsyncDrop = Application::PostUserEvent(LINK(this, 
OApplicationController, OnAsyncDrop));
@@ -2364,13 +2372,27 @@
        return m_xModel;
 }
 // 
-----------------------------------------------------------------------------
-sal_Bool SAL_CALL OApplicationController::attachModel(const Reference< XModel 
> & xModel) throw( RuntimeException )
+sal_Bool SAL_CALL OApplicationController::attachModel(const Reference< XModel 
> & _rxModel) throw( RuntimeException )
 {
-       ::osl::MutexGuard aGuard(m_aMutex);
-       m_xModel = xModel;
-    Reference<XOfficeDatabaseDocument> xOfficeDoc(m_xModel,UNO_QUERY);
+       ::osl::MutexGuard aGuard( m_aMutex );
+    Reference< XOfficeDatabaseDocument > xOfficeDoc( _rxModel, UNO_QUERY );
+    if ( !xOfficeDoc.is() && _rxModel.is() )
+    {
+        DBG_ERROR( "OApplicationController::attachModel: invalid model!" );
+        return sal_False;
+    }
+
+    DBG_ASSERT( !( m_xModel.is() && ( m_xModel != _rxModel ) ),
+        "OApplicationController::attachModel: missing implementation: setting 
a new model while we have another one!" );
+        // at least: remove as property change listener from the old 
model/data source
+
+    m_xModel = _rxModel;
+    m_aModelConnector.swap( _rxModel.is() ? ModelControllerConnector( 
_rxModel, this ) : ModelControllerConnector() );
+
     m_xDataSource.set(xOfficeDoc.is() ? xOfficeDoc->getDataSource() : 
Reference<XDataSource>(),UNO_QUERY);
-       if ( m_xDataSource.is() )
+       if ( !m_xDataSource.is() )
+        m_sDatabaseName = ::rtl::OUString();
+    else
        {
                try
                {
@@ -2405,10 +2427,11 @@
                }
                catch(Exception)
                {
-                       OSL_ENSURE(0,"Exception catched while set property 
listener");
+            OSL_ENSURE( false, "OApplicationController::attachModel: caught an 
exception while doing the property stuff!" );
                }
        }
-       return m_sDatabaseName.getLength() != 0;
+
+       return sal_True;
 }
 // 
-----------------------------------------------------------------------------
 void OApplicationController::containerFound( const Reference< XContainer >& 
_xContainer)




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

Reply via email to