Tag: cws_src680_reportdesign03 User: oj Date: 2007-12-14 10:26:11+0000 Removed: dba/dbaccess/source/ui/dlg/AdvancedPageDlg.cxx dba/dbaccess/source/ui/dlg/AdvancedPageDlg.hrc dba/dbaccess/source/ui/dlg/AdvancedPageDlg.src dba/dbaccess/source/ui/inc/AdvancedPageDlg.hxx dba/dbaccess/source/ui/inc/dialogcontrolling.hxx dba/dbaccess/source/ui/misc/dialogcontrolling.cxx dba/dbaccess/source/ui/querydesign/TableWindowData.hxx dba/dbaccess/source/ui/uno/AdvancedSettingsDlg.hxx
Modified: dba/dbaccess/source/ui/app/AppController.cxx Log: RESYNC: (1.47-1.50); 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.47.30.1&r2=1.47.30.2 Delta lines: +207 -148 ----------------------- --- AppController.cxx 2007-11-30 06:57:15+0000 1.47.30.1 +++ AppController.cxx 2007-12-14 10:25:13+0000 1.47.30.2 @@ -36,12 +36,10 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_dbaccess.hxx" -#ifndef DBAUI_APPCONTROLLER_HXX #include "AppController.hxx" -#endif -#ifndef DBACCESS_SHARED_DBUSTRINGS_HRC #include "dbustrings.hrc" -#endif +#include "advancedsettingsdlg.hxx" + /** === begin UNO includes === **/ #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ #include <com/sun/star/container/XNameContainer.hpp> @@ -70,6 +68,9 @@ #ifndef _COM_SUN_STAR_SDBCX_XAPPEND_HPP_ #include <com/sun/star/sdbcx/XAppend.hpp> #endif +#ifndef _COM_SUN_STAR_SDBCX_XALTERVIEW_HPP_ +#include <com/sun/star/sdbcx/XAlterView.hpp> +#endif #ifndef _COM_SUN_STAR_SDB_XOFFICEDATABASEDOCUMENT_HPP_ #include <com/sun/star/sdb/XOfficeDatabaseDocument.hpp> #endif @@ -731,6 +732,7 @@ break; case SID_FORM_CREATE_REPWIZ_PRE_SEL: case SID_REPORT_CREATE_REPWIZ_PRE_SEL: + case SID_APP_NEW_REPORT_PRE_SEL: aReturn.bEnabled = !isDataSourceReadOnly() && SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SWRITER) && getContainer()->isALeafSelected(); @@ -738,6 +740,17 @@ { ElementType eType = getContainer()->getElementType(); aReturn.bEnabled = eType == E_QUERY || eType == E_TABLE; + if ( aReturn.bEnabled && SID_APP_NEW_REPORT_PRE_SEL == _nId ) + { + Reference< XContentEnumerationAccess > xEnumAccess(m_xServiceFactory, UNO_QUERY); + aReturn.bEnabled = xEnumAccess.is(); + if ( aReturn.bEnabled ) + { + static ::rtl::OUString s_sReportDesign(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.report.pentaho.SOReportJobFactory")); + Reference< XEnumeration > xEnumDrivers = xEnumAccess->createContentEnumeration(s_sReportDesign); + aReturn.bEnabled = xEnumDrivers.is() && xEnumDrivers->hasMoreElements(); + } + } } break; case SID_DB_APP_DELETE: @@ -773,12 +786,36 @@ && getContainer()->isALeafSelected(); break; case SID_DB_APP_EDIT_SQL_VIEW: - aReturn.bEnabled = - ( ( !isDataSourceReadOnly() ) - && ( getContainer()->getElementType() == E_QUERY ) - && ( getContainer()->getSelectionCount() > 0 ) + if ( isDataSourceReadOnly() ) + aReturn.bEnabled = sal_False; + else + { + switch ( getContainer()->getElementType() ) + { + case E_QUERY: + aReturn.bEnabled = ( getContainer()->getSelectionCount() > 0 ) + && ( getContainer()->isALeafSelected() ); + break; + case E_TABLE: + aReturn.bEnabled = sal_False; + // there's one exception: views which support altering their underlying + // command can be edited in SQL view, too + if ( ( getContainer()->getSelectionCount() > 0 ) && ( getContainer()->isALeafSelected() ) - ); + ) + { + ::std::vector< ::rtl::OUString > aSelected; + getSelectionElementNames( aSelected ); + OSL_ENSURE( aSelected.size() == 1, "OApplicationController::GetState: inconsistency!" ); + if ( aSelected.size() == 1 ) + if ( impl_isAlterableView_nothrow( aSelected[0] ) ) + aReturn.bEnabled = sal_True; + } + break; + default: + break; + } + } break; case SID_DB_APP_OPEN: case SID_DB_APP_TABLE_OPEN: @@ -789,9 +826,8 @@ break; case SID_DB_APP_DSUSERADMIN: { - ODsnTypeCollection aTypeCollection; - DATASOURCE_TYPE eType = aTypeCollection.getType(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL))); - aReturn.bEnabled = DST_EMBEDDED != eType; + DATASOURCE_TYPE eType = m_aTypeCollection.getType(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL))); + aReturn.bEnabled = DST_EMBEDDED_HSQLDB != eType; } break; case SID_DB_APP_DSRELDESIGN: @@ -808,7 +844,7 @@ if ( aReturn.bEnabled ) { 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_KAB != eType && DST_MACAB != eType && DST_OUTLOOK != eType && DST_OUTLOOKEXP != eType; + aReturn.bEnabled = DST_EMBEDDED_HSQLDB != eType && DST_MOZILLA != eType && DST_EVOLUTION != eType && DST_KAB != eType && DST_MACAB != eType && DST_OUTLOOK != eType && DST_OUTLOOKEXP != eType; } break; case SID_DB_APP_DSCONNECTION_TYPE: @@ -816,15 +852,15 @@ if ( aReturn.bEnabled ) { DATASOURCE_TYPE eType = m_aTypeCollection.getType(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL))); - aReturn.bEnabled = DST_EMBEDDED != eType; + aReturn.bEnabled = DST_EMBEDDED_HSQLDB != eType; } break; case SID_DB_APP_DSADVANCED_SETTINGS: aReturn.bEnabled = m_xDataSource.is(); if ( aReturn.bEnabled ) { - 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_KAB != eType && DST_MACAB != eType && DST_OUTLOOK != eType && DST_OUTLOOKEXP != eType; + DATASOURCE_TYPE eType = m_aTypeCollection.getType( ::comphelper::getString( m_xDataSource->getPropertyValue( PROPERTY_URL ) ) ); + aReturn.bEnabled = AdvancedSettingsDialog::doesHaveAnyAdvancedSettings( eType ); } break; case SID_DB_APP_CONVERTTOVIEW: @@ -884,23 +920,18 @@ aReturn.bEnabled = m_xDataSource.is(); if ( aReturn.bEnabled ) { - ::rtl::OUString sTemp; - m_xDataSource->getPropertyValue(PROPERTY_URL) >>= sTemp; - DATASOURCE_TYPE eType = m_aTypeCollection.getType(sTemp); + ::rtl::OUString sURL; + m_xDataSource->getPropertyValue(PROPERTY_URL) >>= sURL; + DATASOURCE_TYPE eType = m_aTypeCollection.getType( sURL ); + String sDatabaseName; - if ( eType != DST_EMBEDDED ) - { - String sUser,sHostName,ssTemp; - ssTemp = sTemp; - sal_Int32 nPortNumber = -1; + String sHostName; + sal_Int32 nPortNumber( -1 ); - m_aTypeCollection.extractHostNamePort(ssTemp - ,sDatabaseName - ,sHostName - ,nPortNumber); - if ( !sDatabaseName.Len() ) - sDatabaseName = m_aTypeCollection.cutPrefix(sTemp); + m_aTypeCollection.extractHostNamePort( sURL, sDatabaseName, sHostName, nPortNumber ); + if ( !sDatabaseName.Len() ) + sDatabaseName = m_aTypeCollection.cutPrefix( sURL ); if ( m_aTypeCollection.isFileSystemBased(eType) ) { sDatabaseName = SvtPathOptions().SubstituteVariable( sDatabaseName ); @@ -911,9 +942,10 @@ sDatabaseName = aFileNotation.get(::svt::OFileNotation::N_SYSTEM); } } - } - else - sDatabaseName = m_aTypeCollection.getEmbeddedDatabaseUIName(getORB()); + + if ( sDatabaseName.Len() == 0 ) + sDatabaseName = m_aTypeCollection.getTypeDisplayName( eType ); + aReturn.sTitle = sDatabaseName; } break; @@ -926,21 +958,14 @@ aReturn.bEnabled = m_xDataSource.is(); if ( aReturn.bEnabled ) { - ::rtl::OUString sTemp; - m_xDataSource->getPropertyValue(PROPERTY_URL) >>= sTemp; - DATASOURCE_TYPE eType = m_aTypeCollection.getType(sTemp); - if ( eType != DST_EMBEDDED ) - { - String sUser,sHostName,sDatabaseName,ssTemp; - ssTemp = sTemp; + ::rtl::OUString sURL; + m_xDataSource->getPropertyValue( PROPERTY_URL ) >>= sURL; + + String sHostName, sDatabaseName; sal_Int32 nPortNumber = -1; - m_aTypeCollection.extractHostNamePort(ssTemp - ,sDatabaseName - ,sHostName - ,nPortNumber); + m_aTypeCollection.extractHostNamePort( sURL, sDatabaseName, sHostName, nPortNumber ); aReturn.sTitle = sHostName; } - } break; default: aReturn = OApplicationController_CBASE::GetState(_nId); @@ -1155,6 +1180,7 @@ case ID_APP_NEW_QUERY_AUTO_PILOT: case SID_DB_FORM_NEW_PILOT: case SID_REPORT_CREATE_REPWIZ_PRE_SEL: + case SID_APP_NEW_REPORT_PRE_SEL: case SID_FORM_CREATE_REPWIZ_PRE_SEL: case ID_DOCUMENT_CREATE_REPWIZ: case SID_APP_NEW_FORM: @@ -1181,6 +1207,7 @@ bAutoPilot = sal_True; // run through case SID_APP_NEW_REPORT: + case SID_APP_NEW_REPORT_PRE_SEL: eType = E_REPORT; break; case ID_APP_NEW_QUERY_AUTO_PILOT: @@ -1220,7 +1247,7 @@ SharedConnection xConnection( ensureConnection() ); if ( xConnection.is() ) { - QueryDesigner aDesigner( getORB(), this, m_xCurrentFrame, sal_True, SID_DB_NEW_VIEW_SQL == _nId ); + QueryDesigner aDesigner( getORB(), this, m_xCurrentFrame, true, SID_DB_NEW_VIEW_SQL == _nId ); Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY ); Reference< XComponent > xComponent( aDesigner.createNew( xDataSource ), UNO_QUERY ); @@ -1371,6 +1398,8 @@ CommandGroup::APPLICATION ); implDescribeSupportedFeature( ".uno:DBNewReport", SID_APP_NEW_REPORT, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:DBNewReportWithPreSelection", + SID_APP_NEW_REPORT_PRE_SEL,CommandGroup::APPLICATION ); implDescribeSupportedFeature( ".uno:DBNewReportAutoPilot", ID_DOCUMENT_CREATE_REPWIZ, CommandGroup::INSERT ); implDescribeSupportedFeature( ".uno:DBNewReportAutoPilotWithPreSelection", @@ -1692,6 +1721,32 @@ return false; // not handled } // ----------------------------------------------------------------------------- +bool OApplicationController::impl_isAlterableView_nothrow( const ::rtl::OUString& _rTableOrViewName ) const +{ + OSL_PRECOND( m_xDataSourceConnection.is(), "OApplicationController::impl_isAlterableView_nothrow: no connection!" ); + + bool bIsAlterableView( false ); + try + { + Reference< XViewsSupplier > xViewsSupp( m_xDataSourceConnection, UNO_QUERY ); + Reference< XNameAccess > xViews; + if ( xViewsSupp.is() ) + xViews = xViewsSupp->getViews(); + + Reference< XAlterView > xAsAlterableView; + if ( xViews.is() && xViews->hasByName( _rTableOrViewName ) ) + xAsAlterableView.set( xViews->getByName( _rTableOrViewName ), UNO_QUERY ); + + bIsAlterableView = xAsAlterableView.is(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return bIsAlterableView; +} + +// ----------------------------------------------------------------------------- Reference< XComponent > OApplicationController::openElement(const ::rtl::OUString& _sName, ElementType _eType, OLinkedDocumentsAccess::EOpenMode _eOpenMode, sal_uInt16 _nInstigatorCommand ) { @@ -1702,6 +1757,7 @@ // OJ: http://www.openoffice.org/issues/show_bug.cgi?id=30382 getContainer()->showPreview(NULL); } + switch ( _eType ) { case E_REPORT: @@ -1723,28 +1779,30 @@ case E_TABLE: { SharedConnection xConnection( ensureConnection() ); - if ( xConnection.is() ) - { + if ( !xConnection.is() ) + break; + ::std::auto_ptr< DatabaseObjectView > pDesigner; Sequence < PropertyValue > aArgs; Any aDataSource; if ( _eOpenMode == OLinkedDocumentsAccess::OPEN_DESIGN ) { + sal_Bool bQuerySQLMode =( _nInstigatorCommand == SID_DB_APP_EDIT_SQL_VIEW ); + if ( _eType == E_TABLE ) { + if ( impl_isAlterableView_nothrow( _sName ) ) + pDesigner.reset( new QueryDesigner( getORB(), this, m_xCurrentFrame, true, bQuerySQLMode ) ); + else pDesigner.reset( new TableDesigner( getORB(), this, m_xCurrentFrame ) ); } else if ( _eType == E_QUERY ) { - sal_Bool bQuerySQLMode = - ( ( _nInstigatorCommand == SID_DB_APP_EDIT_SQL_VIEW ) - && ( _eType == E_QUERY ) - ); - pDesigner.reset( new QueryDesigner( getORB(), this, m_xCurrentFrame, sal_False, bQuerySQLMode ) ); + pDesigner.reset( new QueryDesigner( getORB(), this, m_xCurrentFrame, false, bQuerySQLMode ) ); } else if ( _eType == E_REPORT ) { - pDesigner.reset(new OReportDesigner(getORB(),this, m_xCurrentFrame )); + pDesigner.reset( new ReportDesigner( getORB(),this, m_xCurrentFrame ) ); } aDataSource <<= m_xDataSource; } @@ -1762,8 +1820,8 @@ Reference< XComponent > xComponent( pDesigner->openExisting( aDataSource, _sName, aArgs ), UNO_QUERY ); addDocumentListener( xComponent, NULL ); } - } break; + default: break; } @@ -1790,24 +1848,8 @@ ::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; - - ::rtl::OUString sName; - if ( nCommandType != -1 ) - { - try - { - sName = getContainer()->getQualifiedName( NULL ); - OSL_ENSURE( sName.getLength(), "OApplicationController::newElementWithPilot: no name given!" ); - } - catch(Exception) - { - OSL_ENSURE( 0, "OApplicationController::newElementWithPilot: Exception catched!" ); - } - } - + sal_Int32 nCommandType = -1; + const ::rtl::OUString sName(getCurrentlySelectedName(nCommandType)); Reference< XComponent > xComponent,xDefinition; if ( E_REPORT == _eType ) xComponent = aHelper->newReportWithPilot(xDefinition,nCommandType,sName); @@ -1844,18 +1886,13 @@ switch ( _eType ) { case E_FORM: - { - ::std::auto_ptr<OLinkedDocumentsAccess> aHelper = getDocumentsAccess(_eType); - Reference< XComponent > xComponent,xDefinition; - xComponent = aHelper->newForm(ID_FORM_NEW_TEXT,xDefinition); - addDocumentListener(xComponent,xDefinition); - } - break; case E_REPORT: { ::std::auto_ptr<OLinkedDocumentsAccess> aHelper = getDocumentsAccess(_eType); Reference< XComponent > xComponent,xDefinition; - xComponent = aHelper->newForm(ID_REPORT_NEW_TEXT,xDefinition); + sal_Int32 nCommandType = -1; + const ::rtl::OUString sName(getCurrentlySelectedName(nCommandType)); + xComponent = aHelper->newDocument(_eType == E_FORM ? ID_FORM_NEW_TEXT : ID_REPORT_NEW_TEXT,xDefinition,nCommandType,sName); addDocumentListener(xComponent,xDefinition); } break; @@ -1873,10 +1910,10 @@ } else if ( _eType == E_QUERY ) { - pDesigner.reset( new QueryDesigner( getORB(), this, m_xCurrentFrame, sal_False, _bSQLView ) ); + pDesigner.reset( new QueryDesigner( getORB(), this, m_xCurrentFrame, false, _bSQLView ) ); } else - pDesigner.reset(new OReportDesigner(getORB(),this, m_xCurrentFrame )); + pDesigner.reset( new ReportDesigner( getORB(), this, m_xCurrentFrame ) ); Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY ); Reference< XComponent > xComponent( pDesigner->createNew( xDataSource ), UNO_QUERY ); @@ -2488,6 +2525,28 @@ } } // ----------------------------------------------------------------------------- +::rtl::OUString OApplicationController::getCurrentlySelectedName(sal_Int32& _rnCommandType) const +{ + _rnCommandType = ( (getContainer()->getElementType() == E_QUERY) + ? CommandType::QUERY : ( (getContainer()->getElementType() == E_TABLE) ? CommandType::TABLE : -1 )); + + + ::rtl::OUString sName; + if ( _rnCommandType != -1 ) + { + try + { + sName = getContainer()->getQualifiedName( NULL ); + OSL_ENSURE( sName.getLength(), "OApplicationController::newElementWithPilot: no name given!" ); + } + catch(Exception) + { + OSL_ENSURE( 0, "OApplicationController::newElementWithPilot: Exception catched!" ); + } + } + return sName; +} +// ----------------------------------------------------------------------------- ::sal_Bool SAL_CALL OApplicationController::select( const Any& _aSelection ) throw (IllegalArgumentException, RuntimeException) { ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); Directory: /dba/dbaccess/source/ui/dlg/ ======================================= File [removed]: AdvancedPageDlg.cxx Directory: /dba/dbaccess/source/ui/dlg/ ======================================= File [removed]: AdvancedPageDlg.hrc Directory: /dba/dbaccess/source/ui/dlg/ ======================================= File [removed]: AdvancedPageDlg.src Directory: /dba/dbaccess/source/ui/inc/ ======================================= File [removed]: AdvancedPageDlg.hxx Directory: /dba/dbaccess/source/ui/inc/ ======================================= File [removed]: dialogcontrolling.hxx Directory: /dba/dbaccess/source/ui/misc/ ======================================== File [removed]: dialogcontrolling.cxx Directory: /dba/dbaccess/source/ui/querydesign/ =============================================== File [removed]: TableWindowData.hxx Directory: /dba/dbaccess/source/ui/uno/ ======================================= File [removed]: AdvancedSettingsDlg.hxx --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
