Tag: cws_src680_hsqlcsv User: fs Date: 2008-01-17 02:18:24+0000 Modified: dba/dbaccess/source/ui/app/AppController.cxx
Log: RESYNC: (1.39-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.32.10.5&r2=1.32.10.6 Delta lines: +404 -209 ----------------------- --- AppController.cxx 2006-12-18 07:50:37+0000 1.32.10.5 +++ AppController.cxx 2008-01-17 02:18:21+0000 1.32.10.6 @@ -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> @@ -64,9 +62,15 @@ #ifndef _COM_SUN_STAR_SDB_XBOOKMARKSSUPPLIER_HPP_ #include <com/sun/star/sdb/XBookmarksSupplier.hpp> #endif +#ifndef _COM_SUN_STAR_CONTAINER_XCONTENTENUMERATIONACCESS_HPP_ +#include <com/sun/star/container/XContentEnumerationAccess.hpp> +#endif #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 @@ -82,7 +86,9 @@ #ifndef _COM_SUN_STAR_SDB_COMMANDTYPE_HPP_ #include <com/sun/star/sdb/CommandType.hpp> #endif +#ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_ #include <com/sun/star/sdb/SQLContext.hpp> +#endif #ifndef _COM_SUN_STAR_SDB_XQUERYDEFINITIONSSUPPLIER_HPP_ #include <com/sun/star/sdb/XQueryDefinitionsSupplier.hpp> #endif @@ -108,6 +114,8 @@ #include <com/sun/star/util/XFlushable.hpp> #endif #include "com/sun/star/ui/dialogs/TemplateDescription.hpp" +#include "com/sun/star/beans/NamedValue.hpp" + /** === end UNO includes === **/ #ifndef _TOOLS_DEBUG_HXX @@ -173,6 +181,7 @@ #ifndef _DBAUI_LISTVIEWITEMS_HXX_ #include "listviewitems.hxx" #endif +#include "ExtensionNotPresent.hxx" #ifndef DBAUI_APPDETAILVIEW_HXX #include "AppDetailView.hxx" #endif @@ -218,9 +227,8 @@ #ifndef _DBAUI_DSNTYPES_HXX_ #include "dsntypes.hxx" #endif -#ifndef _PASTEDLG_HXX -#include <so3/pastedlg.hxx> -#endif +#include <svx/svxdlg.hxx> +#include <svtools/insdlg.hxx> #ifndef _UNOTOOLS_TEMPFILE_HXX #include <unotools/tempfile.hxx> #endif @@ -248,7 +256,9 @@ #ifndef _DBACCESS_SLOTID_HRC_ #include "dbaccess_slotid.hrc" #endif - +#include <boost/mem_fn.hpp> +#include <boost/bind.hpp> +#include <boost/utility.hpp> #include <algorithm> #include <functional> @@ -268,6 +278,7 @@ using namespace ::svx; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::ucb; +using namespace ::com::sun::star::view; using namespace ::com::sun::star::util; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::lang; @@ -659,6 +670,21 @@ case ID_DOCUMENT_CREATE_REPWIZ: aReturn.bEnabled = !isDataSourceReadOnly() && SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SWRITER); break; + case SID_APP_NEW_REPORT: + aReturn.bEnabled = !isDataSourceReadOnly() + && SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SWRITER); + if ( aReturn.bEnabled ) + { + 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_VIEW_TABLES: aReturn.bEnabled = sal_True; aReturn.bChecked = getContainer()->getElementType() == E_TABLE; @@ -702,12 +728,13 @@ aReturn.bEnabled = !isDataSourceReadOnly() && getContainer()->getSelectionCount() <= 1; if ( aReturn.bEnabled ) { - ElementType eType = getContainer()->getElementType(); + const ElementType eType = getContainer()->getElementType(); aReturn.bEnabled = eType == E_REPORT || eType == E_FORM; } 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(); @@ -715,6 +742,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: @@ -750,12 +788,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: @@ -766,9 +828,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: @@ -785,7 +846,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_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: @@ -793,15 +854,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_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: @@ -818,18 +879,18 @@ } break; case SID_DB_APP_DISABLE_PREVIEW: - aReturn.bEnabled = !isDataSourceReadOnly(); + aReturn.bEnabled = sal_True; aReturn.bChecked = getContainer()->getPreviewMode() == E_PREVIEWNONE; break; case SID_DB_APP_VIEW_DOCINFO_PREVIEW: { ElementType eType = getContainer()->getElementType(); - aReturn.bEnabled = !isDataSourceReadOnly() && (E_REPORT == eType || E_FORM == eType); + aReturn.bEnabled = (E_REPORT == eType || E_FORM == eType); aReturn.bChecked = getContainer()->getPreviewMode() == E_DOCUMENTINFO; } break; case SID_DB_APP_VIEW_DOC_PREVIEW: - aReturn.bEnabled = !isDataSourceReadOnly(); + aReturn.bEnabled = sal_True; aReturn.bChecked = getContainer()->getPreviewMode() == E_DOCUMENT; break; case ID_BROWSER_UNDO: @@ -861,23 +922,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 ); @@ -888,9 +944,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; @@ -903,21 +960,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); @@ -957,11 +1007,32 @@ { TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard(getView())); ElementType eType = getContainer()->getElementType(); + switch( eType ) { case E_TABLE: - m_aTableCopyHelper.pasteTable( aTransferData , getDatabaseName(), ensureConnection() ); + { + //dyf add + //for get the selected tablename + ::std::vector< ::rtl::OUString> aList; + getSelectionElementNames(aList); + ::rtl::OUString sTableNameToInsertInto; + + if ( !aList.empty() ) + { + sTableNameToInsertInto = *aList.begin(); + m_aTableCopyHelper.SetDefaultTableName(sTableNameToInsertInto); + m_aTableCopyHelper.SetIsSelectCopytable(true); + } + else + { + m_aTableCopyHelper.SetIsSelectCopytable(false); + } + //dyf add end + m_aTableCopyHelper.pasteTable( aTransferData , getDatabaseName(), ensureConnection()); + } break; + case E_QUERY: if ( getViewClipboard().HasFormat(SOT_FORMATSTR_ID_DBACCESS_QUERY) ) paste( E_QUERY,ODataAccessObjectTransferable::extractObjectDescriptor(aTransferData) ); @@ -991,17 +1062,17 @@ { if ( !aArgs.getLength() ) { - SvPasteObjectDialog aDlg; + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + ::std::auto_ptr<SfxAbstractPasteDialog> pDlg(pFact->CreatePasteDialog( getView() )); ::std::vector<SotFormatStringId> aFormatIds; getSupportedFormats(getContainer()->getElementType(),aFormatIds); - ::std::vector<SotFormatStringId>::iterator aEnd = aFormatIds.end(); + const ::std::vector<SotFormatStringId>::iterator aEnd = aFormatIds.end(); + ::rtl::OUString sEmpty; for (::std::vector<SotFormatStringId>::iterator aIter = aFormatIds.begin();aIter != aEnd; ++aIter) - { - aDlg.Insert(*aIter,SvPasteObjectDialog::GetSotFormatUIName(*aIter)); - } + pDlg->Insert(*aIter,sEmpty); const TransferableDataHelper& rClipboard = getViewClipboard(); - pasteFormat(aDlg.Execute(getView(),rClipboard.GetTransferable())); + pasteFormat(pDlg->GetFormat(rClipboard.GetTransferable())); } else { @@ -1111,9 +1182,11 @@ 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: + case SID_APP_NEW_REPORT: case ID_NEW_QUERY_SQL: case ID_NEW_QUERY_DESIGN: case ID_NEW_TABLE_DESIGN: @@ -1134,6 +1207,9 @@ case ID_DOCUMENT_CREATE_REPWIZ: case SID_REPORT_CREATE_REPWIZ_PRE_SEL: 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: @@ -1173,7 +1249,7 @@ SharedConnection xConnection( ensureConnection() ); if ( xConnection.is() ) { - QueryDesigner aDesigner( getORB(), this, 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 ); @@ -1222,7 +1298,7 @@ SharedConnection xConnection( ensureConnection() ); if ( xConnection.is() ) { - RelationDesigner aDesigner( getORB(), this ); + RelationDesigner aDesigner( getORB(), this, m_xCurrentFrame ); Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY ); Reference< XComponent > xComponent( aDesigner.createNew( xDataSource ), UNO_QUERY ); addDocumentListener( xComponent, NULL ); @@ -1323,6 +1399,9 @@ SID_FORM_CREATE_REPWIZ_PRE_SEL, 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", @@ -1571,7 +1650,7 @@ OSL_ENSURE(getContainer(),"View is NULL! -> GPF"); Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager = getLayoutManager(getFrame()); - if ( xLayoutManager.is() ) + if ( xLayoutManager.is() && m_eOldType != _eType) { sal_Bool bAdd = _eType != E_TABLE; if ( !bAdd ) @@ -1644,6 +1723,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 ) { @@ -1654,45 +1759,58 @@ // OJ: http://www.openoffice.org/issues/show_bug.cgi?id=30382 getContainer()->showPreview(NULL); } + switch ( _eType ) { - case E_REPORT: // TODO: seperate handling of forms and reports + case E_REPORT: case E_FORM: { ::std::auto_ptr<OLinkedDocumentsAccess> aHelper = getDocumentsAccess(_eType); Reference< XComponent > xDefinition; xRet.set(aHelper->open(_sName, xDefinition,_eOpenMode),UNO_QUERY); + if (_eOpenMode == OLinkedDocumentsAccess::OPEN_DESIGN || + _eType == E_FORM ) + { + // // LLA: close only if in EDIT mode addDocumentListener(xRet,xDefinition); } + } break; + case E_QUERY: 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 ) { - pDesigner.reset( new TableDesigner( getORB(), this ) ); - } + 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, sal_False, bQuerySQLMode ) ); + pDesigner.reset( new QueryDesigner( getORB(), this, m_xCurrentFrame, false, bQuerySQLMode ) ); + } + else if ( _eType == E_REPORT ) + { + pDesigner.reset( new ReportDesigner( getORB(),this, m_xCurrentFrame ) ); } aDataSource <<= m_xDataSource; } else { - pDesigner.reset( new ResultSetBrowser( getORB(), this, _eType == E_TABLE ) ); + pDesigner.reset( new ResultSetBrowser( getORB(), this, m_xCurrentFrame, _eType == E_TABLE ) ); aArgs.realloc(1); aArgs[0].Name = PROPERTY_SHOWMENU; @@ -1704,8 +1822,8 @@ Reference< XComponent > xComponent( pDesigner->openExisting( aDataSource, _sName, aArgs ), UNO_QUERY ); addDocumentListener( xComponent, NULL ); } - } break; + default: break; } @@ -1732,24 +1850,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); @@ -1785,20 +1887,20 @@ switch ( _eType ) { - case E_REPORT: - OSL_ENSURE( sal_False, "OApplicationController::newElement: can't create a blank report!" ); - break; - case E_FORM: + case E_REPORT: { ::std::auto_ptr<OLinkedDocumentsAccess> aHelper = getDocumentsAccess(_eType); Reference< XComponent > xComponent,xDefinition; - xComponent = aHelper->newForm(ID_FORM_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; case E_QUERY: case E_TABLE: + { ::std::auto_ptr< DatabaseObjectView > pDesigner; SharedConnection xConnection( ensureConnection() ); @@ -1806,12 +1908,15 @@ { if ( _eType == E_TABLE ) { - pDesigner.reset( new TableDesigner( getORB(), this ) ); + pDesigner.reset( new TableDesigner( getORB(), this, m_xCurrentFrame ) ); } - else + else if ( _eType == E_QUERY ) { - pDesigner.reset( new QueryDesigner( getORB(), this, sal_False, _bSQLView ) ); + pDesigner.reset( new QueryDesigner( getORB(), this, m_xCurrentFrame, false, _bSQLView ) ); } + else + pDesigner.reset( new ReportDesigner( getORB(), this, m_xCurrentFrame ) ); + Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY ); Reference< XComponent > xComponent( pDesigner->createNew( xDataSource ), UNO_QUERY ); addDocumentListener(xComponent,NULL); @@ -1959,15 +2064,12 @@ xRename->rename(sNewName); - if ( !Reference< XNameAccess >( xRename, UNO_QUERY ).is() ) - { if ( eType == E_TABLE ) { Reference<XPropertySet> xProp(xRename,UNO_QUERY); sNewName = ::dbaui::composeTableName( m_xMetaData, xProp, ::dbtools::eInDataManipulation, false, false, false ); } getContainer()->elementReplaced( eType , sOldName, sNewName ); - } bTryAgain = sal_False; } @@ -2003,6 +2105,9 @@ void OApplicationController::onEntryDeSelect(SvTreeListBox* /*_pTree*/) { InvalidateAll(); + EventObject aEvent(*this); + m_aSelectionListeners.forEach<XSelectionChangeListener>( + ::boost::bind(&XSelectionChangeListener::selectionChanged,_1,boost::cref(aEvent))); } // ----------------------------------------------------------------------------- void OApplicationController::onEntrySelect(SvLBoxEntry* _pEntry) @@ -2012,35 +2117,42 @@ OApplicationView* pView = getContainer(); if ( pView ) { - ElementType eType = pView->getElementType(); - Reference< XContent> xContent; + const ElementType eType = pView->getElementType(); if ( _pEntry && pView->isALeafSelected() ) { + const ::rtl::OUString sName = pView->getQualifiedName( _pEntry ); + selectEntry(eType,sName); + } + + EventObject aEvent(*this); + m_aSelectionListeners.forEach<XSelectionChangeListener>( + ::boost::bind(&XSelectionChangeListener::selectionChanged,_1,boost::cref(aEvent))); + } +} +// ----------------------------------------------------------------------------- +void OApplicationController::selectEntry(const ElementType _eType,const ::rtl::OUString& _sName) +{ + OApplicationView* pView = getContainer(); + Reference< XContent> xContent; try { - switch( eType ) + switch( _eType ) { case E_FORM: case E_REPORT: + if ( _sName.getLength() ) { - ::rtl::OUString sName = pView->getQualifiedName( _pEntry ); - if ( sName.getLength() ) - { - Reference< XHierarchicalNameAccess > xContainer(getElements(eType),UNO_QUERY); - if ( xContainer.is() && xContainer->hasByHierarchicalName(sName) ) - xContent.set(xContainer->getByHierarchicalName(sName),UNO_QUERY); - } + Reference< XHierarchicalNameAccess > xContainer(getElements(_eType),UNO_QUERY); + if ( xContainer.is() && xContainer->hasByHierarchicalName(_sName) ) + xContent.set(xContainer->getByHierarchicalName(_sName),UNO_QUERY); } break; case E_QUERY: - { - ::rtl::OUString sName = pView->getQualifiedName( _pEntry ); if ( pView->isPreviewEnabled() ) { SharedConnection xConnection( ensureConnection() ); if ( xConnection.is() ) - pView->showPreview(getDatabaseName(),xConnection,sName,sal_False); - } + pView->showPreview(getDatabaseName(),xConnection,_sName,sal_False); } return; case E_TABLE: @@ -2048,8 +2160,7 @@ SharedConnection xConnection( ensureConnection() ); if ( xConnection.is() ) { - ::rtl::OUString sName = pView->getQualifiedName( _pEntry ); - pView->showPreview(getDatabaseName(),xConnection,sName,eType == E_TABLE); + pView->showPreview(getDatabaseName(),xConnection,_sName,_eType == E_TABLE); return; } } @@ -2066,9 +2177,8 @@ { OSL_ENSURE(0,"Exception catched while previewing!"); } - } + pView->showPreview(xContent); - } } //------------------------------------------------------------------------------ void OApplicationController::frameAction(const FrameActionEvent& aEvent) throw( RuntimeException ) @@ -2416,6 +2526,91 @@ OSL_ENSURE(0,"Could not listener on the container!"); } } +// ----------------------------------------------------------------------------- +::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() ); + ::osl::MutexGuard aGuard(m_aMutex); + Sequence< ::rtl::OUString> aSelection; + if ( !_aSelection.hasValue() || !getView() ) + { + getContainer()->selectElements(aSelection); + return sal_True; + } + Sequence< NamedValue > aCurrentSelection; + if ( (_aSelection >>= aCurrentSelection) && aCurrentSelection.getLength() ) + { + ElementType eType = E_NONE; + const NamedValue* pIter = aCurrentSelection.getConstArray(); + const NamedValue* pEnd = pIter + aCurrentSelection.getLength(); + for(;pIter != pEnd;++pIter) + { + if ( pIter->Name.equalsAscii("Type") ) + { + sal_Int32 nType = 0; + pIter->Value >>= nType; + if ( nType < 0 || nType > 4) + throw IllegalArgumentException(); + eType = static_cast<ElementType>(nType); + } + else if ( pIter->Name.equalsAscii("Selection") ) + pIter->Value >>= aSelection; + } + + getContainer()->changeContainer(eType); + getContainer()->selectElements(aSelection); + return sal_True; + } + throw IllegalArgumentException(); +} +// ----------------------------------------------------------------------------- +Any SAL_CALL OApplicationController::getSelection( ) throw (RuntimeException) +{ + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + ::osl::MutexGuard aGuard(m_aMutex); + Sequence< NamedValue > aCurrentSelection; + if ( getContainer() ) + { + ::std::vector< ::rtl::OUString> aList; + getSelectionElementNames(aList); + NamedValue aType; + aType.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Type")); + aType.Value <<= static_cast<sal_Int32>(getContainer()->getElementType()); + NamedValue aNames; + aNames.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Selection")); + if ( !aList.empty() ) + aNames.Value <<= Sequence< ::rtl::OUString>(&aList[0],aList.size()); + + aCurrentSelection.realloc(2); + aCurrentSelection[0] = aType; + aCurrentSelection[1] = aNames; + } + + return makeAny(aCurrentSelection); +} + //........................................................................ } // namespace dbaui //........................................................................ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
