User: vg Date: 05/03/10 08:43:13 Modified: /dba/dbaccess/source/ui/app/ AppController.cxx
Log: INTEGRATION: CWS dba24 (1.12.4); FILE MERGED 2005/03/08 10:16:24 oj 1.12.4.8: RESYNC: (1.14-1.16); FILE MERGED 2005/02/25 06:27:13 oj 1.12.4.7: #i42460# set model in disposing(...) null 2005/02/23 10:17:48 oj 1.12.4.6: #i42461# change model data source concept 2005/02/22 08:56:31 oj 1.12.4.5: #i43248# remove lock mutex in getModel 2005/02/21 13:10:38 oj 1.12.4.4: RESYNC: (1.12-1.14); FILE MERGED 2005/02/18 12:27:20 oj 1.12.4.3: #i42460# changes for the separation of datasource and database document(model) 2005/02/07 13:06:01 oj 1.12.4.2: #i42200# some little changes how to start a wizard 2005/02/01 07:52:21 oj 1.12.4.1: #i41727# disable propeties for specific types 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.16&r2=1.17 Delta lines: +95 -109 ---------------------- --- AppController.cxx 1 Mar 2005 19:14:24 -0000 1.16 +++ AppController.cxx 10 Mar 2005 16:43:10 -0000 1.17 @@ -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,7 +585,7 @@ if ( bSuspend && !suspendDocuments( bSuspend )) return sal_False; - Reference<XModifiable> xModi(m_xDataSource,UNO_QUERY); + Reference<XModifiable> xModi(m_xModel,UNO_QUERY); if ( m_bCurrentlyModified || (xModi.is() && xModi->isModified()) ) { switch (ExecuteQuerySaveDocument(getView(),getStrippedDatabaseName())) @@ -769,11 +783,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: @@ -785,7 +799,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; @@ -1042,7 +1056,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(); @@ -1053,10 +1067,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(); @@ -1072,7 +1085,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() ); @@ -1728,6 +1741,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; @@ -1755,54 +1770,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; } @@ -2334,14 +2319,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 @@ -2357,7 +2343,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]
