Tag: cws_src680_dba24 User: oj Date: 05/02/07 05:06:04 Modified: /dba/dbaccess/source/ui/misc/ linkeddocuments.cxx /dba/dbaccess/source/ui/inc/ linkeddocuments.hxx /dba/dbaccess/source/ui/dlg/ dbwizsetup.cxx /dba/dbaccess/source/ui/app/ AppControllerDnD.cxx, AppController.cxx
Log: #i42200# some little changes how to start a wizard File Changes: Directory: /dba/dbaccess/source/ui/misc/ ======================================== File [changed]: linkeddocuments.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/misc/linkeddocuments.cxx?r1=1.12&r2=1.12.4.1 Delta lines: +26 -92 --------------------- --- linkeddocuments.cxx 21 Jan 2005 17:21:05 -0000 1.12 +++ linkeddocuments.cxx 7 Feb 2005 13:05:56 -0000 1.12.4.1 @@ -214,12 +214,14 @@ OLinkedDocumentsAccess::OLinkedDocumentsAccess(Window* _pDialogParent , const Reference< XMultiServiceFactory >& _rxORB , const Reference< XNameAccess >& _rxContainer - ,const Reference< XConnection>& _xConnection + , const Reference< XConnection>& _xConnection + , const ::rtl::OUString& _sDataSourceName ) :m_xORB(_rxORB) ,m_xDocumentContainer(_rxContainer) ,m_pDialogParent(_pDialogParent) ,m_xConnection(_xConnection) + ,m_sDataSourceName(_sDataSourceName) { OSL_ENSURE(m_xORB.is(), "OLinkedDocumentsAccess::OLinkedDocumentsAccess: invalid service factory!"); OSL_ENSURE(m_pDialogParent, "OLinkedDocumentsAccess::OLinkedDocumentsAccess: really need a dialog parent!"); @@ -287,24 +289,26 @@ return xRet; } //------------------------------------------------------------------ - sal_Bool OLinkedDocumentsAccess::newFormWithPilot(const String& _rDataSourceName, const sal_Int32 _nCommandType, - const String& _rObjectName, const Reference< XConnection >& _rxConnection) + void OLinkedDocumentsAccess::newWithPilot(const char* _pWizardService + , const sal_Int32 _nCommandType + , const ::rtl::OUString& _rObjectName + ) { try { ::svx::ODataAccessDescriptor aDesc; - aDesc.setDataSource(::rtl::OUString(_rDataSourceName)); + aDesc.setDataSource(m_sDataSourceName); if ( _nCommandType != -1 ) aDesc[::svx::daCommandType] <<= _nCommandType; - if ( _rObjectName.Len() ) - aDesc[::svx::daCommand] <<= ::rtl::OUString(_rObjectName); - if ( _rxConnection.is() ) - aDesc[::svx::daConnection] <<= _rxConnection; + if ( _rObjectName.getLength() ) + aDesc[::svx::daCommand] <<= _rObjectName; + if ( m_xConnection.is() ) + aDesc[::svx::daConnection] <<= m_xConnection; Reference< XJobExecutor > xFormWizard; { WaitObject aWaitCursor( m_pDialogParent ); - xFormWizard.set(m_xORB->createInstanceWithArguments(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.wizards.form.CallFormWizard")),aDesc.createAnySequence()),UNO_QUERY); + xFormWizard.set(m_xORB->createInstanceWithArguments(::rtl::OUString::createFromAscii(_pWizardService),aDesc.createAnySequence()),UNO_QUERY); } if ( xFormWizard.is() ) xFormWizard->trigger(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("start"))); @@ -312,99 +316,29 @@ } catch(const Exception&) { - OSL_ENSURE(sal_False, "OLinkedDocumentsAccess::newReport: caught an exception while loading the object!"); + OSL_ENSURE(sal_False, "OLinkedDocumentsAccess::newWithPilot: caught an exception while loading the object!"); } - return sal_True; } - //------------------------------------------------------------------ - sal_Bool OLinkedDocumentsAccess::newReportWithPilot(const String& _rDataSourceName, const sal_Int32 _nCommandType, - const String& _rObjectName, const Reference< XConnection >& _rxConnection) - { - try - { - ::svx::ODataAccessDescriptor aDesc; - aDesc.setDataSource(::rtl::OUString(_rDataSourceName)); - if ( _nCommandType != -1 ) - aDesc[::svx::daCommandType] <<= _nCommandType; - if ( _rObjectName.Len() ) - aDesc[::svx::daCommand] <<= ::rtl::OUString(_rObjectName); - if ( _rxConnection.is() ) - aDesc[::svx::daConnection] <<= _rxConnection; - - Reference< XJobExecutor > xReportWizard; - { - WaitObject aWaitCursor( m_pDialogParent ); - xReportWizard.set(m_xORB->createInstanceWithArguments(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.wizards.report.CallReportWizard")),aDesc.createAnySequence()),UNO_QUERY); - } - if ( xReportWizard.is() ) - xReportWizard->trigger(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("start"))); - - } - catch(const Exception&) + void OLinkedDocumentsAccess::newFormWithPilot(const sal_Int32 _nCommandType,const ::rtl::OUString& _rObjectName) { - OSL_ENSURE(sal_False, "OLinkedDocumentsAccess::newReport: caught an exception while loading the object!"); - } - return sal_True; + newWithPilot("com.sun.star.wizards.form.CallFormWizard",_nCommandType,_rObjectName); } - //------------------------------------------------------------------ - sal_Bool OLinkedDocumentsAccess::newTableWithPilot(const String& _rDataSourceName,const Reference< XConnection >& _rxConnection) - { - try - { - ::svx::ODataAccessDescriptor aDesc; - aDesc.setDataSource(::rtl::OUString(_rDataSourceName)); - if ( _rxConnection.is() ) - aDesc[::svx::daConnection] <<= _rxConnection; - - Reference< XJobExecutor > xTableWizard; + void OLinkedDocumentsAccess::newReportWithPilot(const sal_Int32 _nCommandType,const ::rtl::OUString& _rObjectName) { - WaitObject aWaitCursor( m_pDialogParent ); - xTableWizard.set(m_xORB->createInstanceWithArguments(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.wizards.table.CallTableWizard")),aDesc.createAnySequence()),UNO_QUERY); - } - - if ( xTableWizard.is() ) - xTableWizard->trigger(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("start"))); - - } - catch(const Exception&) - { - OSL_ENSURE(sal_False, "OLinkedDocumentsAccess::newTable: caught an exception while loading the object!"); - } - return sal_True; + newWithPilot("com.sun.star.wizards.report.CallReportWizard",_nCommandType,_rObjectName); } //------------------------------------------------------------------ - sal_Bool OLinkedDocumentsAccess::newQueryWithPilot(const String& _rDataSourceName, const sal_Int32 _nCommandType, - const String& _rObjectName, const Reference< XConnection >& _rxConnection) + void OLinkedDocumentsAccess::newTableWithPilot() { - try - { - ::svx::ODataAccessDescriptor aDesc; - if ( _rDataSourceName.Len() ) - aDesc.setDataSource( ::rtl::OUString(_rDataSourceName) ); - if ( _nCommandType != -1 ) - aDesc[::svx::daCommandType] <<= _nCommandType; - if ( _rObjectName.Len() ) - aDesc[::svx::daCommand] <<= ::rtl::OUString(_rObjectName); - if ( _rxConnection.is() ) - aDesc[::svx::daConnection] <<= _rxConnection; - - Reference< XJobExecutor > xQueryWizard; - { - WaitObject aWaitCursor( m_pDialogParent ); - xQueryWizard.set(m_xORB->createInstanceWithArguments(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.wizards.query.CallQueryWizard")),aDesc.createAnySequence()),UNO_QUERY); + newWithPilot("com.sun.star.wizards.table.CallTableWizard"); } - if ( xQueryWizard.is() ) - xQueryWizard->trigger(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("start"))); - - } - catch(const Exception&) + //------------------------------------------------------------------ + void OLinkedDocumentsAccess::newQueryWithPilot(const sal_Int32 _nCommandType,const ::rtl::OUString& _rObjectName) { - OSL_ENSURE(sal_False, "OLinkedDocumentsAccess::newQueryWithPilot: caught an exception while loading the object!"); - } - return sal_True; + newWithPilot("com.sun.star.wizards.query.CallQueryWizard",_nCommandType,_rObjectName); } //------------------------------------------------------------------ Reference< XComponent > OLinkedDocumentsAccess::newForm(sal_Int32 _nNewFormId,Reference< XComponent >& _xDefinition) Directory: /dba/dbaccess/source/ui/inc/ ======================================= File [changed]: linkeddocuments.hxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/inc/linkeddocuments.hxx?r1=1.8&r2=1.8.4.1 Delta lines: +21 -19 --------------------- --- linkeddocuments.hxx 21 Jan 2005 17:19:08 -0000 1.8 +++ linkeddocuments.hxx 7 Feb 2005 13:05:57 -0000 1.8.4.1 @@ -110,6 +110,8 @@ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> m_xConnection; String m_sCurrentlyEditing; + ::rtl::OUString + m_sDataSourceName; public: OLinkedDocumentsAccess( @@ -117,6 +119,7 @@ ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB ,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxContainer ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection + ,const ::rtl::OUString& _sDataSourceName ); enum EOpenMode @@ -126,6 +129,8 @@ OPEN_FORMAIL }; + sal_Bool isConnected() const { return m_xConnection.is(); } + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent> open(const ::rtl::OUString& _rLinkName ,::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent>& _xDefinition , EOpenMode _eOpenMode = OPEN_NORMAL); @@ -133,29 +138,26 @@ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent> newForm(sal_Int32 _nNewFormId ,::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent>& _xDefinition); - sal_Bool newFormWithPilot( - const String& _rDataSourceName, - const sal_Int32 _nCommandType, - const String& _rObjectName, - const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection + void newWithPilot( + const char* _pWizardService + ,const sal_Int32 _nCommandType = -1 + ,const ::rtl::OUString& _rObjectName = ::rtl::OUString() + ); + + void newFormWithPilot( + const sal_Int32 _nCommandType = -1 + ,const ::rtl::OUString& _rObjectName = ::rtl::OUString() ); - sal_Bool newReportWithPilot( - const String& _rDataSourceName, - const sal_Int32 _nCommandType, - const String& _rObjectName, - const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection + void newReportWithPilot( + const sal_Int32 _nCommandType = -1 + ,const ::rtl::OUString& _rObjectName = ::rtl::OUString() ); - sal_Bool newQueryWithPilot( - const String& _rDataSourceName, - const sal_Int32 _nCommandType, - const String& _rObjectName, - const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection + void newQueryWithPilot( + const sal_Int32 _nCommandType = -1 + ,const ::rtl::OUString& _rObjectName = ::rtl::OUString() ); - sal_Bool newTableWithPilot( - const String& _rDataSourceName, - const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection - ); + void newTableWithPilot(); enum RESULT { Directory: /dba/dbaccess/source/ui/dlg/ ======================================= File [changed]: dbwizsetup.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/dlg/dbwizsetup.cxx?r1=1.8&r2=1.8.4.1 Delta lines: +2 -2 ------------------- --- dbwizsetup.cxx 21 Jan 2005 17:15:01 -0000 1.8 +++ dbwizsetup.cxx 7 Feb 2005 13:05:59 -0000 1.8.4.1 @@ -1194,8 +1194,8 @@ try { ::rtl::OUString sPath = m_pImpl->getDocumentUrl(*m_pOutSet); - ::std::auto_ptr<OLinkedDocumentsAccess> oLinkedDocument(new OLinkedDocumentsAccess(this, getORB(), NULL, NULL)); - oLinkedDocument->newTableWithPilot(sPath, NULL); + ::std::auto_ptr<OLinkedDocumentsAccess> oLinkedDocument(new OLinkedDocumentsAccess(this, getORB(), NULL, NULL,sPath)); + oLinkedDocument->newTableWithPilot(); } catch(const Exception&) { Directory: /dba/dbaccess/source/ui/app/ ======================================= File [changed]: AppControllerDnD.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppControllerDnD.cxx?r1=1.8.4.1&r2=1.8.4.2 Delta lines: +8 -3 ------------------- --- AppControllerDnD.cxx 4 Feb 2005 11:51:12 -0000 1.8.4.1 +++ AppControllerDnD.cxx 7 Feb 2005 13:06:00 -0000 1.8.4.2 @@ -740,10 +740,15 @@ } Reference<XConnection> xConnection; + try + { ensureConnection(xConnection); + } + catch(SQLContext& e) { showError(SQLExceptionInfo(e)); } + catch(SQLWarning& e) { showError(SQLExceptionInfo(e)); } + catch(SQLException& e) { showError(SQLExceptionInfo(e)); } OSL_ENSURE(xNameAccess.is(),"Data source doesn't return a name access -> GPF"); - ::std::auto_ptr<OLinkedDocumentsAccess> aHelper( new OLinkedDocumentsAccess(getView(), getORB(), xNameAccess,xConnection)); - return aHelper; + return ::std::auto_ptr<OLinkedDocumentsAccess>( new OLinkedDocumentsAccess(getView(), getORB(), xNameAccess,xConnection,getDatabaseName())); } // ----------------------------------------------------------------------------- TransferableHelper* OApplicationController::copyObject() File [changed]: AppController.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppController.cxx?r1=1.12.4.1&r2=1.12.4.2 Delta lines: +38 -66 --------------------- --- AppController.cxx 1 Feb 2005 07:52:21 -0000 1.12.4.1 +++ AppController.cxx 7 Feb 2005 13:06:01 -0000 1.12.4.2 @@ -2,9 +2,9 @@ * * $RCSfile: AppController.cxx,v $ * - * $Revision: 1.12.4.1 $ + * $Revision: 1.12.4.2 $ * - * last change: $Author: oj $ $Date: 2005/02/01 07:52:21 $ + * last change: $Author: oj $ $Date: 2005/02/07 13:06:01 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1713,6 +1713,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; @@ -1740,54 +1742,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; } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
