User: hr      
Date: 05/09/23 05:14:25

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

Log:
 INTEGRATION: CWS dba201b (1.20.26); FILE MERGED
 2005/09/21 07:45:52 oj 1.20.26.10: RESYNC: (1.20-1.21); FILE MERGED
 2005/08/08 12:28:34 fs 1.20.26.9: merging a (lost) fix from CWS dba201(a)
 2005/08/08 12:27:20 fs 1.20.26.8: merging a (lost) fix from CWS dba201a
 2005/08/08 12:23:14 fs 1.20.26.7: merging a (lost) fix from CWS dba201a
 2005/08/08 12:04:58 oj 1.20.26.6: #i43965# remove DBNewViewAutoPilot
 2005/07/22 07:02:37 fs 1.20.26.5: #i10000#
 2005/07/21 14:35:54 fs 1.20.26.4: slight syntax changes to the recently 
introduced SharedUNOComponent for better readability of client code
 2005/07/20 10:13:27 fs 1.20.26.3: #i51255# use a ModelControllerConnector to 
connect ourself to the model, and to keep it alive as long as we ourself live
 2005/07/11 13:37:09 fs 1.20.26.2: merging CWS dba201 into CWS dba201b
 2005/05/31 13:29:35 oj 1.20.26.1: #123000# check if vector is empty

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.21&r2=1.22
Delta lines:  +74 -49
---------------------
--- AppController.cxx   8 Sep 2005 14:18:46 -0000       1.21
+++ AppController.cxx   23 Sep 2005 12:14:21 -0000      1.22
@@ -318,6 +318,7 @@
 //====================================================================
 //= OApplicationController
 //====================================================================
+DBG_NAME(OApplicationController)
 //--------------------------------------------------------------------
 OApplicationController::OApplicationController(const Reference< 
XMultiServiceFactory >& _rxORB)
        :OApplicationController_CBASE( _rxORB )
@@ -330,6 +331,8 @@
        ,m_eOldType(E_NONE)
     ,m_aTableCopyHelper(this)
 {
+    DBG_CTOR(OApplicationController,NULL);
+
        m_aTypeCollection.initUserDriverTypes(_rxORB);
 }
 
//------------------------------------------------------------------------------
@@ -344,6 +347,8 @@
        }
        ::std::auto_ptr< Window> aTemp(m_pView);
        m_pView = NULL;
+
+    DBG_DTOR(OApplicationController,NULL);
 }
 //--------------------------------------------------------------------
 
IMPLEMENT_FORWARD_XTYPEPROVIDER2(OApplicationController,OApplicationController_CBASE,OApplicationController_Base)
@@ -404,7 +409,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));
 
@@ -426,11 +431,10 @@
                                                getStrippedDatabaseName(),
                                                ::rtl::OUString() );
             }
-                       m_xModel->disconnectController( this );
-                       // forces the data source to reload
-               }
 
-               m_xModel = NULL;
+            m_aModelConnector.clear();
+            m_xModel.clear();
+               }
        }
        catch(Exception)
        {
@@ -443,7 +447,7 @@
 //--------------------------------------------------------------------
 sal_Bool OApplicationController::Construct(Window* _pParent)
 {
-       m_pView = new 
OApplicationView(_pParent,getORB(),this,this,this,this,this,this);
+       m_pView = new 
OApplicationView(_pParent,getORB(),this,this,this,this,this,this,m_ePreviewMode);
        m_pView->SetUniqueId(UID_APP_VIEW);
        
        // late construction
@@ -472,12 +476,6 @@
        if ( getView() )
                getView()->enableSeparator( );
 
-       if ( getContainer() && m_ePreviewMode != 
getContainer()->getPreviewMode() )
-               getContainer()->switchPreview(m_ePreviewMode);
-
-//     if ( getContainer() && m_xDataSource.is() )
-//             getContainer()->setStatusInformations(m_xDataSource);
-
        // now that we have a view we can create the clipboard listener
        m_aSystemClipboard = TransferableDataHelper::CreateFromSystemClipboard( 
getView() );
        m_aSystemClipboard.StartClipboardListening( );
@@ -516,7 +514,8 @@
        }
        else if ( _rSource.Source == m_xModel )
        {
-               m_xModel = NULL;
+               m_xModel.clear();
+        m_aModelConnector.clear();
        }
        else if ( _rSource.Source == m_xDataSource )
        {
@@ -627,7 +626,7 @@
                                                aReturn.bEnabled = 
!isDataSourceReadOnly() && 
getViewClipboard().HasFormat(SOT_FORMATSTR_ID_DBACCESS_QUERY);
                                                break;
                                        default:
-                                               aReturn.bEnabled = 
!isDataSourceReadOnly() && 
OComponentTransferable::canExtractComponentDescriptor(getViewClipboard().GetDataFlavorExVector());
+                                               aReturn.bEnabled = 
!isDataSourceReadOnly() && 
OComponentTransferable::canExtractComponentDescriptor(getViewClipboard().GetDataFlavorExVector(),getContainer()->getElementType()
 == E_FORM);
                                }
                                break;
                        case SID_DB_APP_PASTE_SPECIAL:
@@ -773,16 +772,14 @@
                        case SID_DB_APP_DSPROPS:
                                if ( aReturn.bEnabled = m_xDataSource.is() )
                                {
-                                       static ODsnTypeCollection 
aTypeCollection;
-                                       DATASOURCE_TYPE eType = 
aTypeCollection.getType(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL)));
+                                       DATASOURCE_TYPE eType = 
m_aTypeCollection.getType(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL)));
                                        aReturn.bEnabled = DST_EMBEDDED != 
eType && DST_MOZILLA != eType && DST_EVOLUTION != eType && DST_OUTLOOK != eType 
&& DST_OUTLOOKEXP != eType;
                                }
                                break;
                        case SID_DB_APP_DSCONNECTION_TYPE:
                                if ( aReturn.bEnabled = !isDataSourceReadOnly() 
&& m_xDataSource.is() )
                                {
-                                       static ODsnTypeCollection 
aTypeCollection;
-                                       DATASOURCE_TYPE eType = 
aTypeCollection.getType(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL)));
+                                       DATASOURCE_TYPE eType = 
m_aTypeCollection.getType(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL)));
                                        aReturn.bEnabled = DST_EMBEDDED != 
eType;
                                }
                                break;
@@ -957,10 +954,15 @@
                             {
                                 Reference<XConnection> xDestConnection;
                                            ensureConnection(xDestConnection);
-                                                           
m_aTableCopyHelper.pasteTable( aTransferData , getDatabaseName() , 
xDestConnection);
+
+                                SharedConnection xConnection( xDestConnection, 
SharedConnection::NoTakeOwnership );
+                                // TODO: migrate ensureConnection to the 
SharedConnection-API
+
+                                m_aTableCopyHelper.pasteTable( aTransferData , 
getDatabaseName(), xConnection );
                             }
                                                        break;
                                                case E_QUERY:
+                            if ( 
getViewClipboard().HasFormat(SOT_FORMATSTR_ID_DBACCESS_QUERY) )
                                                        paste( 
E_QUERY,ODataAccessObjectTransferable::extractObjectDescriptor(aTransferData) );
                                                        break;
                                                default:
@@ -1342,8 +1344,6 @@
                                                                                
         CommandGroup::INSERT );
     implDescribeSupportedFeature( ".uno:DBNewView",          
ID_NEW_VIEW_DESIGN,        CommandGroup::INSERT );
     implDescribeSupportedFeature( ".uno:DBNewViewSQL",       
SID_DB_NEW_VIEW_SQL,       CommandGroup::INSERT );
-    implDescribeSupportedFeature( ".uno:DBNewViewAutoPilot", 
ID_NEW_VIEW_DESIGN_AUTO_PILOT,
-                                                                               
         CommandGroup::INSERT );
 
     implDescribeSupportedFeature( ".uno:DBDelete",           
SID_DB_APP_DELETE,         CommandGroup::EDIT );
        implDescribeSupportedFeature( ".uno:Delete",                     
SID_DB_APP_DELETE,         CommandGroup::EDIT );
@@ -1400,16 +1400,16 @@
     implDescribeSupportedFeature( ".uno:DBShowDocPreview",   
SID_DB_APP_VIEW_DOC_PREVIEW,
                                                                                
         CommandGroup::VIEW );
 
-       implDescribeSupportedFeature( ".uno:DBDSImport",                
SID_DB_APP_DSIMPORT);
-       implDescribeSupportedFeature( ".uno:DBDSExport",                
SID_DB_APP_DSEXPORT);
-
-       implDescribeSupportedFeature( ".uno:DBDBAdmin",                 
SID_DB_APP_DBADMIN);
+    // this one should not appear under Tools->Customize->Keyboard
+       implDescribeSupportedFeature( ".uno:DBDSImport",                
SID_DB_APP_DSIMPORT, CommandGroup::INTERNAL);
+       implDescribeSupportedFeature( ".uno:DBDSExport",                
SID_DB_APP_DSEXPORT, CommandGroup::INTERNAL);
+       implDescribeSupportedFeature( ".uno:DBDBAdmin",                 
SID_DB_APP_DBADMIN, CommandGroup::INTERNAL);
 
        // status info
-       implDescribeSupportedFeature( ".uno:DBStatusType",              
SID_DB_APP_STATUS_TYPE);
-       implDescribeSupportedFeature( ".uno:DBStatusDBName",    
SID_DB_APP_STATUS_DBNAME);
-       implDescribeSupportedFeature( ".uno:DBStatusUserName",  
SID_DB_APP_STATUS_USERNAME);
-       implDescribeSupportedFeature( ".uno:DBStatusHostName",  
SID_DB_APP_STATUS_HOSTNAME);
+       implDescribeSupportedFeature( ".uno:DBStatusType",              
SID_DB_APP_STATUS_TYPE, CommandGroup::INTERNAL);
+       implDescribeSupportedFeature( ".uno:DBStatusDBName",    
SID_DB_APP_STATUS_DBNAME, CommandGroup::INTERNAL);
+       implDescribeSupportedFeature( ".uno:DBStatusUserName",  
SID_DB_APP_STATUS_USERNAME, CommandGroup::INTERNAL);
+       implDescribeSupportedFeature( ".uno:DBStatusHostName",  
SID_DB_APP_STATUS_HOSTNAME, CommandGroup::INTERNAL);
 }
 // 
-----------------------------------------------------------------------------
 OApplicationView*      OApplicationController::getContainer() const
@@ -1633,10 +1633,10 @@
        {
                ElementType eType = getContainer()->getElementType();
 
+               Reference<XConnection> xConnection;
                Reference<XDatabaseMetaData> xMetaData;
                if ( eType == E_TABLE )
                {
-                       Reference<XConnection> xConnection;
                        ensureConnection(xConnection);
                        if ( xConnection.is() )
                        {
@@ -1871,6 +1871,8 @@
 
        Reference< XNameAccess > xContainer = 
getElements(getContainer()->getElementType());
        OSL_ENSURE(aList.size() == 1,"Invalid rename call here. More than one 
element!");
+  if ( aList.empty() )
+    return;
 
        try
        {
@@ -2196,7 +2198,7 @@
                                return DND_ACTION_COPY;
                        if ( eType == E_FORM || eType == E_REPORT )
                        {
-                               sal_Int8 nAction = 
OComponentTransferable::canExtractComponentDescriptor(_rFlavors) ? 
DND_ACTION_COPY : DND_ACTION_NONE;
+                               sal_Int8 nAction = 
OComponentTransferable::canExtractComponentDescriptor(_rFlavors,eType == 
E_FORM) ? DND_ACTION_COPY : DND_ACTION_NONE;
                                if ( nAction != DND_ACTION_NONE )
                                {
                                        SvLBoxEntry* pHitEntry = 
pView->getEntry(_rEvt.maPosPixel);
@@ -2217,8 +2219,9 @@
                                                                nAction = 
DND_ACTION_NONE;
                                                }
                                        }
-                                       else
+                                       /*else
                                                nAction = nActionAskedFor & 
DND_ACTION_COPYMOVE;
+                    */
                                }
                                return nAction;
                        }
@@ -2266,7 +2269,7 @@
                m_nAsyncDrop = Application::PostUserEvent(LINK(this, 
OApplicationController, OnAsyncDrop));
                return DND_ACTION_COPY;
        }
-       else if ( 
OComponentTransferable::canExtractComponentDescriptor(aDroppedData.GetDataFlavorExVector())
 )
+       else if ( 
OComponentTransferable::canExtractComponentDescriptor(aDroppedData.GetDataFlavorExVector(),m_aAsyncDrop.nType
 == E_FORM) )
        {
                m_aAsyncDrop.aDroppedData = 
OComponentTransferable::extractComponentDescriptor(aDroppedData);
                SvLBoxEntry* pHitEntry = pView->getEntry(_rEvt.maPosPixel);
@@ -2321,7 +2324,11 @@
        {
         Reference<XConnection> xDestConnection;         // supports the 
service sdb::connection
            ensureConnection( xDestConnection);
-           if ( xDestConnection.is() && 
m_aTableCopyHelper.copyTagTable(aDroppedData,m_aAsyncDrop,xDestConnection) )
+
+        SharedConnection xConnection( xDestConnection, 
SharedConnection::NoTakeOwnership );
+        // 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));
@@ -2337,13 +2344,30 @@
        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;
+    if ( _rxModel.is() )
+        m_aModelConnector = ModelControllerConnector( _rxModel, this );
+    else
+        m_aModelConnector.clear();
+
     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
                {
@@ -2378,10 +2402,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