Tag: cws_src680_dba25
User: fs      
Date: 05/03/14 05:29:17

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

Log:
 RESYNC: (1.16-1.17); FILE MERGED

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.15.2.4&r2=1.15.2.5
Delta lines:  +103 -110
-----------------------
--- AppController.cxx   8 Mar 2005 09:00:36 -0000       1.15.2.4
+++ AppController.cxx   14 Mar 2005 13:29:14 -0000      1.15.2.5
@@ -92,6 +92,9 @@
 #ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_
 #include <com/sun/star/sdbcx/XAppend.hpp>
 #endif
+#ifndef _COM_SUN_STAR_SDB_XOFFICEDATABASEDOCUMENT_HPP_
+#include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp>
+#endif
 #ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
 #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
 #endif
@@ -416,16 +419,28 @@
        clearConnections();
        try
        {
+               Reference < XFrame > xFrame;
+               attachFrame( xFrame );
+
                if ( m_xDataSource.is() )
                {
-                       Reference<XModel> xModel(m_xDataSource,UNO_QUERY);
-                       if ( xModel.is() )
+                   
m_xDataSource->removePropertyChangeListener(::rtl::OUString(), this);
+                       // otherwise we may delete our datasource twice
+                       Reference<XPropertySet> xProp = m_xDataSource;
+                       m_xDataSource = NULL;
+               }
+
+               Reference< XModifyBroadcaster >  xBroadcaster(m_xModel, 
UNO_QUERY);
+               if ( xBroadcaster.is() )
+                       
xBroadcaster->removeModifyListener(static_cast<XModifyListener*>(this));
+
+               if ( m_xModel.is() )
                        {
-                               ::rtl::OUString sUrl = xModel->getURL();
+                       ::rtl::OUString sUrl = m_xModel->getURL();
                                if ( sUrl.getLength() )
                        {
                                    ::rtl::OUString             aFilter;
-                                   INetURLObject               aURL( 
xModel->getURL() );
+                               INetURLObject           aURL( 
m_xModel->getURL() );
                                    const SfxFilter* pFilter = 
getStandardDatabaseFilter();
                                    if ( pFilter )
                                            aFilter = pFilter->GetFilterName();
@@ -437,20 +452,11 @@
                                                    getStrippedDatabaseName(),
                                                    ::rtl::OUString() );
                 }
-                               xModel->disconnectController( this );
+                       m_xModel->disconnectController( this );
                                // forces the data source to reload
-                               
xModel->attachResource(xModel->getURL(),xModel->getArgs());
                        }
-                       Reference < XFrame > xFrame;
-                       attachFrame( xFrame );
 
-                       
m_xDataSource->removePropertyChangeListener(::rtl::OUString(), this);
-                       Reference< XModifyBroadcaster >  
xBroadcaster(m_xDataSource, UNO_QUERY);
-                       if ( xBroadcaster.is() )
-                               
xBroadcaster->removeModifyListener(static_cast<XModifyListener*>(this));
-
-                       m_xDataSource = NULL;
-               }
+               m_xModel = NULL;
        }
        catch(Exception)
        {
@@ -534,6 +540,14 @@
                        }
                }
        }
+       else if ( _rSource.Source == m_xModel )
+       {
+               m_xModel = NULL;
+       }
+       else if ( _rSource.Source == m_xDataSource )
+       {
+               m_xDataSource = NULL;
+       }
        else
        {
                Reference<XComponent> xComp(_rSource.Source,UNO_QUERY);
@@ -571,10 +585,17 @@
            if ( bSuspend && !suspendDocuments( bSuspend ))
                    return sal_False;
            
-           Reference<XModifiable> xModi(m_xDataSource,UNO_QUERY);
+           Reference<XModifiable> xModi(m_xModel,UNO_QUERY);
         Reference<XStorable> xStor(getModel(),UNO_QUERY);
         
-           if ( xStor.is() && !xStor->isReadonly() && (m_bCurrentlyModified || 
(xModi.is() && xModi->isModified())) )
+           if  (   xStor.is()
+            &&  !xStor->isReadonly()
+            &&  (   m_bCurrentlyModified
+                ||  (   xModi.is()
+                    &&  xModi->isModified()
+                    )
+                )
+            )
            {
                    switch 
(ExecuteQuerySaveDocument(getView(),getStrippedDatabaseName()))
                    {
@@ -771,11 +792,11 @@
                                aReturn.bEnabled = 
getContainer()->getElementType() == E_TABLE && getActiveConnection().is();
                                break;
                        case SID_DB_APP_DSPROPS:
-                               if ( m_xDataSource.is() )
+                               if ( aReturn.bEnabled = m_xDataSource.is() )
                                {
                                        static ODsnTypeCollection 
aTypeCollection;
                                        DATASOURCE_TYPE eType = 
aTypeCollection.getType(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL)));
-                                       aReturn.bEnabled = DST_EMBEDDED != 
eType;
+                                       aReturn.bEnabled = DST_EMBEDDED != 
eType && DST_MOZILLA != eType && DST_EVOLUTION != eType && DST_OUTLOOK != eType 
&& DST_OUTLOOKEXP != eType;
                                }
                                break;
                        case SID_DB_APP_DSCONNECTION_TYPE:
@@ -787,7 +808,7 @@
                                }
                                break;
                        case SID_DB_APP_DSADVANCED_SETTINGS:
-                               if ( m_xDataSource.is() )
+                               if ( aReturn.bEnabled = m_xDataSource.is() )
                                {
                                        DATASOURCE_TYPE eType = 
m_aTypeCollection.getType(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL)));
                                        aReturn.bEnabled = DST_EMBEDDED != 
eType && DST_LDAP != eType && DST_CALC != eType && DST_MOZILLA != eType && 
DST_THUNDERBIRD != eType && DST_EVOLUTION != eType && DST_OUTLOOK != eType && 
DST_OUTLOOKEXP != eType;
@@ -1044,7 +1065,7 @@
                                break;
                        case ID_BROWSER_SAVEDOC:
                                {
-                                       Reference<XStorable> 
xStore(m_xDataSource,UNO_QUERY);
+                                       Reference<XStorable> 
xStore(m_xModel,UNO_QUERY);
                                        if ( xStore.is() )
                                        {
                                                xStore->store();
@@ -1055,10 +1076,9 @@
                        case ID_BROWSER_SAVEASDOC:
                                {
                                        WinBits nBits(WB_STDMODAL|WB_SAVEAS);
-                    Reference<XModel> xModel(m_xDataSource,UNO_QUERY);
                     ::rtl::OUString sUrl;
-                               if ( xModel.is() )
-                                       sUrl = xModel->getURL();
+                               if ( m_xModel.is() )
+                                       sUrl = m_xModel->getURL();
                                if ( !sUrl.getLength() )
                         sUrl = SvtPathOptions().GetWorkPath();
 
@@ -1074,7 +1094,7 @@
 
                                        if ( aFileDlg.Execute() == ERRCODE_NONE 
)
                                        {
-                                               Reference<XStorable> 
xStore(m_xDataSource,UNO_QUERY);
+                                               Reference<XStorable> 
xStore(m_xModel,UNO_QUERY);
                                                if ( xStore.is() )
                                                {
                                                        INetURLObject aURL( 
aFileDlg.GetPath() );
@@ -1742,6 +1762,8 @@
                case E_FORM:
                {
                        ::std::auto_ptr<OLinkedDocumentsAccess> aHelper = 
getDocumentsAccess(_eType);
+            if ( aHelper->isConnected() )
+                       {
                        sal_Int32 nCommandType = ( 
(getContainer()->getElementType() == E_QUERY)
                                                                                
? CommandType::QUERY : ( (getContainer()->getElementType() == E_TABLE) ? 
CommandType::TABLE : -1 ));
                        Reference<XConnection> xConnection;
@@ -1769,54 +1791,24 @@
                                }
                        }
 
-                       try
-                       {
-                               ensureConnection(xConnection,sal_True);
-                       }
-                       catch(SQLContext& e) { showError(SQLExceptionInfo(e)); }
-                       catch(SQLWarning& e) { showError(SQLExceptionInfo(e)); }
-                       catch(SQLException& e) { 
showError(SQLExceptionInfo(e)); }
-
-                       if ( xConnection.is() )
-                       {
                                if ( E_REPORT == _eType )
-                                       
aHelper->newReportWithPilot(getDatabaseName(),nCommandType,sName,xConnection);
+                                       
aHelper->newReportWithPilot(nCommandType,sName);
                                else
-                                       
aHelper->newFormWithPilot(getDatabaseName(),nCommandType,sName,xConnection);
+                                       
aHelper->newFormWithPilot(nCommandType,sName);
                        }
         }
         break;
         case E_QUERY:
-        {
-                   ::std::auto_ptr<OLinkedDocumentsAccess> aHelper = 
getDocumentsAccess(_eType);
-                   Reference<XConnection> xConnection;
-                   try
-                   {
-                           if ( ensureConnection( xConnection, sal_True ) )
-                    
aHelper->newQueryWithPilot(getDatabaseName(),-1,::rtl::OUString(),xConnection);
-                   }
-                   catch(SQLContext& e) { showError(SQLExceptionInfo(e)); }
-                   catch(SQLWarning& e) { showError(SQLExceptionInfo(e)); }
-                   catch(SQLException& e) { showError(SQLExceptionInfo(e)); }
-        }
-               break;
         case E_TABLE:
                {
                        ::std::auto_ptr<OLinkedDocumentsAccess> aHelper = 
getDocumentsAccess(_eType);
-                       Reference<XConnection> xConnection;
-                       try
-                       {
-                               if ( ensureConnection( xConnection, sal_True ) )
+            if ( aHelper->isConnected() )
                 {
                                    if ( E_QUERY == _eType )
-                                           aHelper->newQueryWithPilot( 
getDatabaseName(), -1, ::rtl::OUString(), xConnection );
+                                   aHelper->newQueryWithPilot( );
                                    else
-                                           aHelper->newTableWithPilot( 
getDatabaseName(), xConnection );
-                }
+                                   aHelper->newTableWithPilot( );
                        }
-                       catch(SQLContext& e) { showError(SQLExceptionInfo(e)); }
-                       catch(SQLWarning& e) { showError(SQLExceptionInfo(e)); }
-                       catch(SQLException& e) { 
showError(SQLExceptionInfo(e)); }
                }
                break;
     }
@@ -2359,14 +2351,15 @@
 // 
-----------------------------------------------------------------------------
 Reference< XModel >  SAL_CALL OApplicationController::getModel(void) throw( 
RuntimeException )
 {
-       ::osl::MutexGuard aGuard(m_aMutex);
-       return Reference< XModel >(m_xDataSource,UNO_QUERY);
+       return m_xModel;
 }
 // 
-----------------------------------------------------------------------------
 sal_Bool SAL_CALL OApplicationController::attachModel(const Reference< XModel 
> & xModel) throw( RuntimeException )
 {
        ::osl::MutexGuard aGuard(m_aMutex);
-       m_xDataSource.set(xModel,UNO_QUERY);
+       m_xModel = xModel;
+    Reference<XOfficeDatabaseDocument> xOfficeDoc(m_xModel,UNO_QUERY);
+    m_xDataSource.set(xOfficeDoc.is() ? xOfficeDoc->getDataSource() : 
Reference<XDataSource>(),UNO_QUERY);
        if ( m_xDataSource.is() )
        {
                try
@@ -2382,7 +2375,7 @@
                        
m_xDataSource->addPropertyChangeListener(PROPERTY_TABLETYPEFILTER, this);
                        m_xDataSource->addPropertyChangeListener(PROPERTY_USER, 
this);
                        // to get the 'modified' for the data source
-                       Reference< XModifyBroadcaster >  
xBroadcaster(m_xDataSource, UNO_QUERY);
+                       Reference< XModifyBroadcaster >  xBroadcaster(m_xModel, 
UNO_QUERY);
                        if ( xBroadcaster.is() )
                                
xBroadcaster->addModifyListener(static_cast<XModifyListener*>(this));
 




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

Reply via email to