Tag: cws_src680_asyncdialogs2 User: pb Date: 2008-07-01 12:02:07+0000 Removed: dba/dbaccess/source/core/api/CKey.cxx dba/dbaccess/source/core/api/CKey.hxx dba/dbaccess/source/core/api/CKeyColumn.hxx dba/dbaccess/source/core/api/CKeyColumns.cxx dba/dbaccess/source/core/api/CKeyColumns.hxx dba/dbaccess/source/core/api/CKeys.cxx dba/dbaccess/source/core/api/CKeys.hxx dba/dbaccess/source/ui/app/IAppElementNotification.hxx dba/dbaccess/util/defs/wntmsci12
Modified: dba/dbaccess/source/ui/app/AppController.cxx dba/dbaccess/source/ui/app/AppController.hxx Log: RESYNC:; FILE REMOVED File Changes: Directory: /dba/dbaccess/source/core/api/ ========================================= File [removed]: CKey.cxx Directory: /dba/dbaccess/source/core/api/ ========================================= File [removed]: CKey.hxx Directory: /dba/dbaccess/source/core/api/ ========================================= File [removed]: CKeyColumn.hxx Directory: /dba/dbaccess/source/core/api/ ========================================= File [removed]: CKeyColumns.cxx Directory: /dba/dbaccess/source/core/api/ ========================================= File [removed]: CKeyColumns.hxx Directory: /dba/dbaccess/source/core/api/ ========================================= File [removed]: CKeys.cxx Directory: /dba/dbaccess/source/core/api/ ========================================= File [removed]: CKeys.hxx 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.37.34.14&r2=1.37.34.15 Delta lines: +426 -104 ----------------------- --- AppController.cxx 2008-05-27 07:58:07+0000 1.37.34.14 +++ AppController.cxx 2008-07-01 12:00:22+0000 1.37.34.15 @@ -68,12 +68,14 @@ #include <com/sun/star/container/XHierarchicalNameContainer.hpp> #include <com/sun/star/util/XModifyBroadcaster.hpp> #include <com/sun/star/util/XModifiable.hpp> -#include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/frame/FrameSearchFlag.hpp> #include <com/sun/star/util/XFlushable.hpp> #include "com/sun/star/ui/dialogs/TemplateDescription.hpp" #include "com/sun/star/beans/NamedValue.hpp" #include <com/sun/star/awt/XTopWindow.hpp> +#include <com/sun/star/task/XInteractionHandler.hpp> +#include <com/sun/star/sdb/application/DatabaseObject.hpp> +#include <com/sun/star/sdb/application/DatabaseObjectContainer.hpp> /** === end UNO includes === **/ #ifndef _TOOLS_DEBUG_HXX @@ -88,6 +90,9 @@ #ifndef _COMPHELPER_TYPES_HXX_ #include <comphelper/types.hxx> #endif +#ifndef _COMPHELPER_INTERACTION_HXX_ +#include <comphelper/interaction.hxx> +#endif #ifndef COMPHELPER_COMPONENTCONTEXT_HXX #include <comphelper/componentcontext.hxx> #endif @@ -227,12 +232,11 @@ #include "dbaccess_slotid.hrc" #endif -#include <boost/mem_fn.hpp> -#include <boost/bind.hpp> -#include <boost/utility.hpp> #include <algorithm> #include <functional> +#include <boost/noncopyable.hpp> + extern "C" void SAL_CALL createRegistryInfo_ODBApplication() { static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OApplicationController > aAutoRegistration; @@ -257,7 +261,12 @@ using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::datatransfer; using namespace ::com::sun::star::ui::dialogs; +using namespace ::com::sun::star::task; using ::com::sun::star::document::XEmbeddedScripts; +using ::com::sun::star::sdb::application::NamedDatabaseObject; + +namespace DatabaseObject = ::com::sun::star::sdb::application::DatabaseObject; +namespace DatabaseObjectContainer = ::com::sun::star::sdb::application::DatabaseObjectContainer; //------------------------------------------------------------------------------ ::rtl::OUString SAL_CALL OApplicationController::getImplementationName() throw( RuntimeException ) @@ -274,7 +283,7 @@ Sequence< ::rtl::OUString> OApplicationController::getSupportedServiceNames_Static(void) throw( RuntimeException ) { Sequence< ::rtl::OUString> aSupported(1); - aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.ApplicationController"); + aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.application.DefaultViewController"); return aSupported; } //------------------------------------------------------------------------- @@ -306,20 +315,108 @@ //==================================================================== //= OApplicationController //==================================================================== +class SelectionNotifier : public ::boost::noncopyable +{ +private: + ::cppu::OInterfaceContainerHelper m_aSelectionListeners; + ::cppu::OWeakObject& m_rContext; + sal_Int32 m_nSelectionNestingLevel; + +public: + SelectionNotifier( ::osl::Mutex& _rMutex, ::cppu::OWeakObject& _rContext ) + :m_aSelectionListeners( _rMutex ) + ,m_rContext( _rContext ) + ,m_nSelectionNestingLevel( 0 ) + { + } + + void addListener( const Reference< XSelectionChangeListener >& _Listener ) + { + m_aSelectionListeners.addInterface( _Listener ); + } + + void removeListener( const Reference< XSelectionChangeListener >& _Listener ) + { + m_aSelectionListeners.removeInterface( _Listener ); + } + + void disposing() + { + EventObject aEvent( m_rContext ); + m_aSelectionListeners.disposeAndClear( aEvent ); + } + + ~SelectionNotifier() + { + } + + struct SelectionGuardAccess { friend class SelectionGuard; private: SelectionGuardAccess() { } }; + + /** enters a block which modifies the selection of our owner. + + Can be called multiple times, the only important thing is to call leaveSelection + equally often. + */ + void enterSelection( SelectionGuardAccess ) + { + ++m_nSelectionNestingLevel; + } + + /** leaves a block which modifies the selection of our owner + + Must be paired with enterSelection calls. + + When the last block is left, i.e. the last leaveSelection call is made on the current stack, + then our SelectionChangeListeners are notified + */ + void leaveSelection( SelectionGuardAccess ) + { + if ( --m_nSelectionNestingLevel == 0 ) + { + EventObject aEvent( m_rContext ); + m_aSelectionListeners.notifyEach( &XSelectionChangeListener::selectionChanged, aEvent ); + } + } +}; + +class SelectionGuard : public ::boost::noncopyable +{ +public: + SelectionGuard( SelectionNotifier& _rNotifier ) + :m_rNotifier( _rNotifier ) + { + m_rNotifier.enterSelection( SelectionNotifier::SelectionGuardAccess() ); + } + + ~SelectionGuard() + { + m_rNotifier.leaveSelection( SelectionNotifier::SelectionGuardAccess() ); + } + +private: + SelectionNotifier& m_rNotifier; +}; + +//==================================================================== +//= OApplicationController +//==================================================================== DBG_NAME(OApplicationController) //-------------------------------------------------------------------- OApplicationController::OApplicationController(const Reference< XMultiServiceFactory >& _rxORB) :OApplicationController_CBASE( _rxORB ) + ,m_aContextMenuInterceptors( m_aMutex ) ,m_aTableCopyHelper(this) ,m_pClipbordNotifier(NULL) ,m_nAsyncDrop(0) ,m_aControllerConnectedEvent( LINK( this, OApplicationController, OnFirstControllerConnected ) ) + ,m_aSelectContainerEvent( LINK( this, OApplicationController, OnSelectContainer ) ) ,m_ePreviewMode(E_PREVIEWNONE) ,m_eCurrentType(E_NONE) ,m_bNeedToReconnect(sal_False) ,m_bSuspended( sal_False ) - ,m_bEmptyFilter( sal_False) + ,m_bEmptyFilter( sal_False ) ,m_pDlgHelper( NULL ) + ,m_pSelectionNotifier( new SelectionNotifier( m_aMutex, *this ) ) { DBG_CTOR(OApplicationController,NULL); @@ -378,6 +475,7 @@ m_aCurrentContainers.clear(); m_aSpecialSubFrames.clear(); m_aDocuments.clear(); + m_pSelectionNotifier->disposing(); if ( getView() ) { @@ -448,7 +546,7 @@ //-------------------------------------------------------------------- sal_Bool OApplicationController::Construct(Window* _pParent) { - m_pView = new OApplicationView(_pParent,getORB(),this,this,this,this,this,this,m_ePreviewMode); + m_pView = new OApplicationView( _pParent, getORB(), *this, m_ePreviewMode ); m_pView->SetUniqueId(UID_APP_VIEW); // late construction @@ -995,11 +1093,50 @@ } return aReturn; } + +// ----------------------------------------------------------------------------- +namespace +{ + bool lcl_handleException_nothrow( const Reference< XModel >& _rxDocument, const Any& _rException ) + { + bool bHandled = false; + + // try handling the error with an interaction handler + ::comphelper::NamedValueCollection aArgs( _rxDocument->getArgs() ); + Reference< XInteractionHandler > xHandler( aArgs.getOrDefault( "InteractionHandler", Reference< XInteractionHandler >() ) ); + if ( xHandler.is() ) + { + ::rtl::Reference< ::comphelper::OInteractionRequest > pRequest( new ::comphelper::OInteractionRequest( _rException ) ); + ::rtl::Reference< ::comphelper::OInteractionApprove > pApprove( new ::comphelper::OInteractionApprove ); + pRequest->addContinuation( pApprove.get() ); + + try + { + xHandler->handle( pRequest.get() ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + bHandled = pApprove->wasSelected(); + } + return bHandled; + } +} + // ----------------------------------------------------------------------------- void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyValue >& aArgs) { ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); ::osl::MutexGuard aGuard(m_aMutex); + + if ( isUserDefinedFeature( _nId ) ) + { + OApplicationController_CBASE::Execute( _nId, aArgs ); + return; + } + if ( !getContainer() || m_bReadOnly ) return; // return without execution @@ -1126,11 +1263,18 @@ break; case ID_BROWSER_SAVEDOC: { - Reference<XStorable> xStore(m_xModel,UNO_QUERY); - if ( xStore.is() ) + Reference< XStorable > xStore( m_xModel, UNO_QUERY_THROW ); + try + { xStore->store(); } + catch( const Exception& ) + { + lcl_handleException_nothrow( m_xModel, ::cppu::getCaughtException() ); + } + } break; + case ID_BROWSER_SAVEASDOC: { WinBits nBits(WB_STDMODAL|WB_SAVEAS); @@ -1334,16 +1478,16 @@ impl_migrateScripts_nothrow(); break; case SID_DB_APP_VIEW_TABLES: - getContainer()->selectContainer(E_TABLE); + m_aSelectContainerEvent.Call( reinterpret_cast< void* >( E_TABLE ) ); break; case SID_DB_APP_VIEW_QUERIES: - getContainer()->selectContainer(E_QUERY); + m_aSelectContainerEvent.Call( reinterpret_cast< void* >( E_QUERY ) ); break; case SID_DB_APP_VIEW_FORMS: - getContainer()->selectContainer(E_FORM); + m_aSelectContainerEvent.Call( reinterpret_cast< void* >( E_FORM ) ); break; case SID_DB_APP_VIEW_REPORTS: - getContainer()->selectContainer(E_REPORT); + m_aSelectContainerEvent.Call( reinterpret_cast< void* >( E_REPORT ) ); break; case SID_DB_APP_DISABLE_PREVIEW: m_ePreviewMode = E_PREVIEWNONE; @@ -1379,17 +1523,18 @@ //------------------------------------------------------------------------------ IMPL_LINK(OApplicationController, DialogClosedHdl, sfx2::FileDialogHelper*, pFdh) { - try - { if ( pFdh->GetError() == ERRCODE_NONE ) { - Reference<XStorable> xStore(m_xModel,UNO_QUERY); - if ( xStore.is() ) - { + Reference<XStorable> xStore(m_xModel,UNO_QUERY_THROW); INetURLObject aURL( pFdh->GetPath() ); - if( aURL.GetProtocol() != INET_PROT_NOT_VALID ) + try { - xStore->storeAsURL(aURL.GetMainURL( INetURLObject::NO_DECODE ),Sequence<PropertyValue>()); + xStore->storeAsURL( aURL.GetMainURL( INetURLObject::NO_DECODE ), Sequence< PropertyValue >() ); + } + catch( const Exception& ) + { + lcl_handleException_nothrow( m_xModel, ::cppu::getCaughtException() ); + } m_sDatabaseName = ::rtl::OUString(); /*updateTitle();*/ m_bCurrentlyModified = sal_False; @@ -1400,14 +1545,6 @@ getContainer()->selectContainer(E_TABLE); } } - } - } - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } - InvalidateFeature(ID_BROWSER_SAVEASDOC); return 0L; } // ----------------------------------------------------------------------------- @@ -1430,8 +1567,6 @@ 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", @@ -1507,6 +1642,8 @@ implDescribeSupportedFeature( ".uno:OpenUrl", SID_OPENURL, CommandGroup::APPLICATION ); // this one should not appear under Tools->Customize->Keyboard + implDescribeSupportedFeature( ".uno:DBNewReportWithPreSelection", + SID_APP_NEW_REPORT_PRE_SEL,CommandGroup::INTERNAL ); implDescribeSupportedFeature( ".uno:DBDSImport", SID_DB_APP_DSIMPORT, CommandGroup::INTERNAL); implDescribeSupportedFeature( ".uno:DBDSExport", SID_DB_APP_DSEXPORT, CommandGroup::INTERNAL); implDescribeSupportedFeature( ".uno:DBDBAdmin", SID_DB_APP_DBADMIN, CommandGroup::INTERNAL); @@ -1522,13 +1659,7 @@ { return static_cast< OApplicationView* >( getView() ); } -// ----------------------------------------------------------------------------- -void OApplicationController::onCreationClick(const ::rtl::OUString& _sCommand) -{ - URL aCommand; - aCommand.Complete = _sCommand; - executeChecked(aCommand,Sequence<PropertyValue>()); -} + // ----------------------------------------------------------------------------- // ::com::sun::star::container::XContainerListener void SAL_CALL OApplicationController::elementInserted( const ContainerEvent& _rEvent ) throw(RuntimeException) @@ -1684,6 +1815,8 @@ if ( m_eCurrentType != _eType && _eType != E_NONE ) { + SelectionGuard aSelGuard( *m_pSelectionNotifier ); + if ( _eType == E_TABLE ) { try @@ -1730,25 +1863,31 @@ getContainer()->getDetailView()->createPage(_eType,xContainer); } + SelectionByElementType::iterator pendingSelection = m_aPendingSelection.find( _eType ); + if ( pendingSelection != m_aPendingSelection.end() ) + { + Sequence< ::rtl::OUString > aSelected( pendingSelection->second.size() ); + ::std::copy( pendingSelection->second.begin(), pendingSelection->second.end(), aSelected.getArray() ); + getContainer()->selectElements( aSelected ); + + m_aPendingSelection.erase( pendingSelection ); + } + InvalidateAll(); - EventObject aEvent(*this); - m_aSelectionListeners.forEach<XSelectionChangeListener>( - ::boost::bind(&XSelectionChangeListener::selectionChanged,_1,boost::cref(aEvent))); } m_eCurrentType = _eType; return sal_True; } // ----------------------------------------------------------------------------- -bool OApplicationController::onEntryDoubleClick(SvTreeListBox* _pTree) +bool OApplicationController::onEntryDoubleClick( SvTreeListBox& _rTree ) { - OSL_ENSURE(_pTree != NULL,"Who called me without a svtreelsiboc! ->GPF "); - if ( getContainer() && getContainer()->isLeaf(_pTree->GetHdlEntry()) ) + if ( getContainer() && getContainer()->isLeaf( _rTree.GetHdlEntry() ) ) { try { openElement( - getContainer()->getQualifiedName( _pTree->GetHdlEntry() ), + getContainer()->getQualifiedName( _rTree.GetHdlEntry() ), getContainer()->getElementType(), E_OPEN_NORMAL ); @@ -1821,11 +1960,8 @@ Reference< XComponent > xDefinition; xRet = aHelper->open( _sName, xDefinition, _eOpenMode, _rAdditionalArguments ); - if (_eOpenMode == E_OPEN_DESIGN || _eType == E_FORM ) - { addDocumentListener(xRet,xDefinition); } - } break; case E_QUERY: @@ -1884,6 +2020,13 @@ return xRet; } // ----------------------------------------------------------------------------- +IMPL_LINK( OApplicationController, OnSelectContainer, void*, _pType ) +{ + ElementType eType = (ElementType)reinterpret_cast< sal_IntPtr >( _pType ); + getContainer()->selectContainer(eType); + return 0L; +} +// ----------------------------------------------------------------------------- IMPL_LINK( OApplicationController, OnCreateWithPilot, void*, _pType ) { ElementType eType = (ElementType)reinterpret_cast< sal_IntPtr >( _pType ); @@ -2155,12 +2298,11 @@ } } // ----------------------------------------------------------------------------- -void OApplicationController::onEntryDeSelect(SvTreeListBox* /*_pTree*/) +void OApplicationController::onEntryDeSelect(SvTreeListBox& /*_rTree*/) { + SelectionGuard aSelGuard( *m_pSelectionNotifier ); + InvalidateAll(); - EventObject aEvent(*this); - m_aSelectionListeners.forEach<XSelectionChangeListener>( - ::boost::bind(&XSelectionChangeListener::selectionChanged,_1,boost::cref(aEvent))); } // ----------------------------------------------------------------------------- void OApplicationController::onEntrySelect(SvLBoxEntry* _pEntry) @@ -2170,16 +2312,14 @@ OApplicationView* pView = getContainer(); if ( pView ) { + SelectionGuard aSelGuard( *m_pSelectionNotifier ); + 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))); } } // ----------------------------------------------------------------------------- @@ -2287,10 +2427,91 @@ } executeChecked(nId,Sequence<PropertyValue>()); } + // ----------------------------------------------------------------------------- -sal_Bool OApplicationController::requestContextMenu( const CommandEvent& /*_rEvent*/ ) +void OApplicationController::executeUnChecked(const URL& _rCommand, const Sequence< PropertyValue>& aArgs) { - return sal_False; + OApplicationController_CBASE::executeUnChecked( _rCommand, aArgs ); +} + +// ----------------------------------------------------------------------------- +void OApplicationController::executeChecked(const URL& _rCommand, const Sequence< PropertyValue>& aArgs) +{ + OApplicationController_CBASE::executeChecked( _rCommand, aArgs ); +} + +// ----------------------------------------------------------------------------- +void OApplicationController::executeUnChecked(sal_uInt16 _nCommandId, const Sequence< PropertyValue>& aArgs) +{ + OApplicationController_CBASE::executeUnChecked( _nCommandId, aArgs ); +} + +// ----------------------------------------------------------------------------- +void OApplicationController::executeChecked(sal_uInt16 _nCommandId, const Sequence< PropertyValue>& aArgs) +{ + OApplicationController_CBASE::executeChecked( _nCommandId, aArgs ); +} + +// ----------------------------------------------------------------------------- +sal_Bool OApplicationController::isCommandEnabled(sal_uInt16 _nCommandId) const +{ + return OApplicationController_CBASE::isCommandEnabled( _nCommandId ); +} + +// ----------------------------------------------------------------------------- +sal_Bool OApplicationController::isCommandEnabled( const ::rtl::OUString& _rCompleteCommandURL ) const +{ + return OApplicationController_CBASE::isCommandEnabled( _rCompleteCommandURL ); +} + +// ----------------------------------------------------------------------------- +sal_uInt16 OApplicationController::registerCommandURL( const ::rtl::OUString& _rCompleteCommandURL ) +{ + return OApplicationController_CBASE::registerCommandURL( _rCompleteCommandURL ); +} + +// ----------------------------------------------------------------------------- +void OApplicationController::notifyHiContrastChanged() +{ + OApplicationController_CBASE::notifyHiContrastChanged(); +} + +// ----------------------------------------------------------------------------- +Reference< XController > OApplicationController::getXController() throw( RuntimeException ) +{ + return OApplicationController_CBASE::getXController(); +} + +// ----------------------------------------------------------------------------- +bool OApplicationController::interceptUserInput( const NotifyEvent& _rEvent ) +{ + return OApplicationController_CBASE::interceptUserInput( _rEvent ); +} + +// ----------------------------------------------------------------------------- +PopupMenu* OApplicationController::getContextMenu( Control& /*_rControl*/ ) const +{ + return new PopupMenu( ModuleRes( RID_MENU_APP_EDIT ) ); +} + +// ----------------------------------------------------------------------------- +IController& OApplicationController::getCommandController() +{ + return *static_cast< IApplicationController* >( this ); +} + +// ----------------------------------------------------------------------------- +::cppu::OInterfaceContainerHelper* OApplicationController::getContextMenuInterceptors() +{ + return &m_aContextMenuInterceptors; +} + +// ----------------------------------------------------------------------------- +Any OApplicationController::getCurrentSelection( Control& _rControl ) const +{ + Sequence< NamedDatabaseObject > aSelection; + getContainer()->describeCurrentSelectionForControl( _rControl, aSelection ); + return makeAny( aSelection ); } // ----------------------------------------------------------------------------- @@ -2528,14 +2749,25 @@ return 0L; } + try + { + // If the migration just happened, but was not successful, the document is reloaded. + // In this case, we should not show the warning, again. + ::comphelper::NamedValueCollection aModelArgs( m_xModel->getArgs() ); + if ( aModelArgs.getOrDefault( "SuppressMigrationWarning", sal_False ) ) + return 0L; + + // also, if the document is read-only, then no migration is possible, and the + // respective menu entry is hidden. So, don't show the warning in this case, too. + if ( Reference< XStorable >( m_xModel, UNO_QUERY_THROW )->isReadonly() ) + return 0L; + SQLWarning aWarning; aWarning.Message = String( ModuleRes( STR_SUB_DOCS_WITH_SCRIPTS ) ); SQLException aDetail; aDetail.Message = String( ModuleRes( STR_SUB_DOCS_WITH_SCRIPTS_DETAIL ) ); aWarning.NextException <<= aDetail; - try - { ::comphelper::ComponentContext aContext( getORB() ); Sequence< Any > aArgs(1); aArgs[0] <<= NamedValue( PROPERTY_SQLEXCEPTION, makeAny( aWarning ) ); @@ -2663,6 +2895,19 @@ } return sName; } + +// ----------------------------------------------------------------------------- +void SAL_CALL OApplicationController::addSelectionChangeListener( const Reference< view::XSelectionChangeListener >& _Listener ) throw (RuntimeException) +{ + m_pSelectionNotifier->addListener( _Listener ); +} + +// ----------------------------------------------------------------------------- +void SAL_CALL OApplicationController::removeSelectionChangeListener( const Reference< view::XSelectionChangeListener >& _Listener ) throw (RuntimeException) +{ + m_pSelectionNotifier->removeListener( _Listener ); +} + // ----------------------------------------------------------------------------- ::sal_Bool SAL_CALL OApplicationController::select( const Any& _aSelection ) throw (IllegalArgumentException, RuntimeException) { @@ -2674,6 +2919,9 @@ getContainer()->selectElements(aSelection); return sal_True; } + + // -------------------------------------------------------------- + // BEGIN compatibility Sequence< NamedValue > aCurrentSelection; if ( (_aSelection >>= aCurrentSelection) && aCurrentSelection.getLength() ) { @@ -2686,44 +2934,117 @@ { sal_Int32 nType = 0; pIter->Value >>= nType; - if ( nType < 0 || nType > 4) + if ( nType < DatabaseObject::TABLE || nType > DatabaseObject::REPORT ) throw IllegalArgumentException(); - eType = static_cast<ElementType>(nType); + eType = static_cast< ElementType >( nType ); } else if ( pIter->Name.equalsAscii("Selection") ) pIter->Value >>= aSelection; } + m_aSelectContainerEvent.CancelCall(); // just in case the async select request was running getContainer()->selectContainer(eType); getContainer()->selectElements(aSelection); return sal_True; } + // END compatibility + // -------------------------------------------------------------- + + Sequence< NamedDatabaseObject > aSelectedObjects; + if ( !( _aSelection >>= aSelectedObjects ) ) + { + aSelectedObjects.realloc( 1 ); + if ( !( _aSelection >>= aSelectedObjects[0] ) ) throw IllegalArgumentException(); + } + + SelectionByElementType aSelectedElements; + ElementType eSelectedCategory = E_NONE; + for ( const NamedDatabaseObject* pObject = aSelectedObjects.getConstArray(); + pObject != aSelectedObjects.getConstArray() + aSelectedObjects.getLength(); + ++pObject + ) + { + switch ( pObject->Type ) + { + case DatabaseObject::TABLE: + case DatabaseObjectContainer::SCHEMA: + case DatabaseObjectContainer::CATALOG: + aSelectedElements[ E_TABLE ].push_back( pObject->Name ); + break; + case DatabaseObject::QUERY: + aSelectedElements[ E_QUERY ].push_back( pObject->Name ); + break; + case DatabaseObject::FORM: + case DatabaseObjectContainer::FORMS_FOLDER: + aSelectedElements[ E_FORM ].push_back( pObject->Name ); + break; + case DatabaseObject::REPORT: + case DatabaseObjectContainer::REPORTS_FOLDER: + aSelectedElements[ E_REPORT ].push_back( pObject->Name ); + break; + case DatabaseObjectContainer::TABLES: + case DatabaseObjectContainer::QUERIES: + case DatabaseObjectContainer::FORMS: + case DatabaseObjectContainer::REPORTS: + if ( eSelectedCategory != E_NONE ) + throw IllegalArgumentException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "You cannot select different categories." ) ), + // TODO: resource + *this, sal_Int16( pObject - aSelectedObjects.getConstArray() ) ); + eSelectedCategory = + ( pObject->Type == DatabaseObjectContainer::TABLES ) ? E_TABLE + : ( pObject->Type == DatabaseObjectContainer::QUERIES ) ? E_QUERY + : ( pObject->Type == DatabaseObjectContainer::FORMS ) ? E_FORM + : ( pObject->Type == DatabaseObjectContainer::REPORTS ) ? E_REPORT + : E_NONE; + break; + + default: + case DatabaseObjectContainer::DATA_SOURCE: + { + ::rtl::OUStringBuffer aMessage; + aMessage.appendAscii( "Unsupported object type found (" ); + aMessage.append ( sal_Int32( pObject->Type ) ); + aMessage.appendAscii( ")." ); + // TODO: resource + throw IllegalArgumentException( + aMessage.makeStringAndClear(), *this, sal_Int16( pObject - aSelectedObjects.getConstArray() ) ); + } + } + } + + for ( SelectionByElementType::const_iterator sel = aSelectedElements.begin(); + sel != aSelectedElements.end(); + ++sel + ) + { + if ( sel->first == m_eCurrentType ) + { + Sequence< ::rtl::OUString > aSelected( sel->second.size() ); + ::std::copy( sel->second.begin(), sel->second.end(), aSelected.getArray() ); + getContainer()->selectElements( aSelected ); + } + else + { + m_aPendingSelection[ sel->first ] = sel->second; + } + } + + m_aSelectContainerEvent.CancelCall(); // just in case the async select request was running + getContainer()->selectContainer( eSelectedCategory ); + + return sal_True; } // ----------------------------------------------------------------------------- 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); + Sequence< NamedDatabaseObject > aCurrentSelection; + getContainer()->describeCurrentSelectionForType( getContainer()->getElementType(), aCurrentSelection ); + return makeAny( aCurrentSelection ); } // ----------------------------------------------------------------------------- void OApplicationController::impl_migrateScripts_nothrow() @@ -2774,6 +3095,7 @@ } // while ( aFind != m_aSpecialSubFrames.end() ) return bFound; } + //........................................................................ } // namespace dbaui //........................................................................ Directory: /dba/dbaccess/source/ui/app/ ======================================= File [removed]: IAppElementNotification.hxx Directory: /dba/dbaccess/source/ui/app/ ======================================= File [changed]: AppController.hxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppController.hxx?r1=1.15.38.10&r2=1.15.38.11 Delta lines: +63 -46 --------------------- --- AppController.hxx 2008-05-27 07:58:11+0000 1.15.38.10 +++ AppController.hxx 2008-07-01 12:00:30+0000 1.15.38.11 @@ -31,13 +31,13 @@ #ifndef DBAUI_APPCONTROLLER_HXX #define DBAUI_APPCONTROLLER_HXX +#include "IApplicationController.hxx" #include "AppElementType.hxx" #include "callbacks.hxx" #include "commontypes.hxx" #include "documentcontroller.hxx" #include "dsntypes.hxx" #include "genericcontroller.hxx" -#include "IAppElementNotification.hxx" #include "linkeddocuments.hxx" #include "moduledbu.hxx" #include "TableCopyHelper.hxx" @@ -47,12 +47,13 @@ #include <com/sun/star/container/XContainerListener.hpp> #include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp> #include <com/sun/star/util/XModifiable.hpp> +#include <com/sun/star/ui/XContextMenuInterception.hpp> /** === end UNO includes === **/ #include <comphelper/stl_types.hxx> #include <comphelper/namedvaluecollection.hxx> #include <comphelper/uno3.hxx> -#include <cppuhelper/implbase3.hxx> +#include <cppuhelper/implbase5.hxx> #include <sot/storage.hxx> #include <svtools/transfer.hxx> #include <svx/dataaccessdescriptor.hxx> @@ -71,8 +72,6 @@ FORWARD_DECLARE_INTERFACE(container,XNameContainer) FORWARD_DECLARE_INTERFACE(container,XContainer) -FORWARD_DECLARE_INTERFACE(util,XNumberFormatter) -FORWARD_DECLARE_INTERFACE(util,XCloseable) FORWARD_DECLARE_INTERFACE(ucb,XContent) //........................................................................ @@ -86,18 +85,19 @@ class OApplicationView; class OLinkedDocumentsAccess; typedef OGenericUnoController OApplicationController_CBASE; - typedef ::cppu::ImplHelper3 < ::com::sun::star::container::XContainerListener + typedef ::cppu::ImplHelper5 < ::com::sun::star::container::XContainerListener , ::com::sun::star::beans::XPropertyChangeListener , ::com::sun::star::sdb::application::XDatabaseDocumentUI + , ::com::sun::star::ui::XContextMenuInterception + , ::com::sun::star::view::XSelectionSupplier > OApplicationController_Base; + class SelectionNotifier; + class OApplicationController :public OApplicationController_CBASE ,public OApplicationController_Base - ,public IApplicationElementNotification - ,public IControlActionListener - ,public IContainerFoundListener - ,public IViewChangeListener + ,public IApplicationController { public: typedef ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer > TContainer; @@ -120,11 +120,15 @@ OModuleClient m_aModuleClient; TransferableDataHelper m_aSystemClipboard; // content of the clipboard - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xDataSource; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > + m_xDataSource; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModel; ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifiable > m_xDocumentModify; + ::cppu::OInterfaceContainerHelper + m_aContextMenuInterceptors; + ModelControllerConnector m_aModelConnector; TContainerVector m_aCurrentContainers; // the containers where we are listener on @@ -137,6 +141,7 @@ mutable ::rtl::OUString m_sDatabaseName; sal_Int32 m_nAsyncDrop; OAsyncronousLink m_aControllerConnectedEvent; + OAsyncronousLink m_aSelectContainerEvent; PreviewMode m_ePreviewMode; // the mode of the preview ElementType m_eCurrentType; sal_Bool m_bNeedToReconnect; // true when the settings of the data source were modified and the connection is no longer up to date @@ -145,6 +150,11 @@ ::std::auto_ptr<sfx2::FileDialogHelper> m_pDlgHelper; + ::std::auto_ptr< SelectionNotifier > + m_pSelectionNotifier; + typedef ::std::map< ElementType, ::std::vector< ::rtl::OUString > > SelectionByElementType; + SelectionByElementType m_aPendingSelection; + private: OApplicationView* getContainer() const; @@ -224,21 +234,13 @@ */ void convertToView(const ::rtl::OUString& _sName); - /** checks if the selected data source is read only - @return - <TRUE/> if read only, otherwise <FALSE/> - */ - virtual sal_Bool isDataSourceReadOnly() const; - /** checks if the connection for the selected data source is read only. If the connection doesn't exist, <TRUE/> will be returned. @return <TRUE/> if read only or doesn't exist, otherwise <FALSE/> */ sal_Bool isConnectionReadOnly() const; - /** fills the list with the selected entries. - @param _rNames - */ + /// fills the list with the selected entries. void getSelectionElementNames( ::std::vector< ::rtl::OUString>& _rNames ) const; /// deletes the entries selected. @@ -453,13 +455,6 @@ // execute a feature virtual void Execute(sal_uInt16 nId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs); - // IControlActionListener overridables - virtual sal_Bool requestContextMenu( const CommandEvent& _rEvent ); - virtual sal_Bool requestQuickHelp( const SvLBoxEntry* _pEntry, String& _rText ) const; - virtual sal_Bool requestDrag( sal_Int8 _nAction, const Point& _rPosPixel ); - virtual sal_Int8 queryDrop( const AcceptDropEvent& _rEvt, const DataFlavorExVector& _rFlavors ); - virtual sal_Int8 executeDrop( const ExecuteDropEvent& _rEvt ); - // OGenericUnoController virtual void onLoadedMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& _xLayoutManager ); @@ -509,9 +504,15 @@ virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > SAL_CALL loadComponent( ::sal_Int32 ObjectType, const ::rtl::OUString& ObjectName, ::sal_Bool ForEditing ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > SAL_CALL loadComponentWithArguments( ::sal_Int32 ObjectType, const ::rtl::OUString& ObjectName, ::sal_Bool ForEditing, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // XContextMenuInterception + virtual void SAL_CALL registerContextMenuInterceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XContextMenuInterceptor >& Interceptor ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL releaseContextMenuInterceptor( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XContextMenuInterceptor >& Interceptor ) throw (::com::sun::star::uno::RuntimeException); + // XSelectionSupplier virtual ::sal_Bool SAL_CALL select( const ::com::sun::star::uno::Any& xSelection ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Any SAL_CALL getSelection( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addSelectionChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeSelectionChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::view::XSelectionChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); /** retrieves the current connection, creates it if necessary */ @@ -531,38 +532,54 @@ */ void refreshTables(); - /// @see <method>IApplicationElementNotification::onEntryDoubleClick</method> - virtual bool onEntryDoubleClick(SvTreeListBox* _pTree); - /// @see <method>IApplicationElementNotification::onCreationClick</method> - virtual void onCreationClick(const ::rtl::OUString& _sCommand); - /// @see <method>IApplicationElementNotification::onContainerSelect</method> + // IApplicationController + virtual bool onEntryDoubleClick(SvTreeListBox& _rTree); virtual sal_Bool onContainerSelect(ElementType _eType); - /// @see <method>IApplicationElementNotification::onEntrySelect</method> virtual void onEntrySelect(SvLBoxEntry* _pEntry); - /// @see <method>IApplicationElementNotification::onEntryDeSelect</method> - virtual void onEntryDeSelect(SvTreeListBox* _pTree); - /// @see <method>IApplicationElementNotification::onCutEntry</method> + virtual void onEntryDeSelect(SvTreeListBox& _rTree); virtual void onCutEntry(SvLBoxEntry* _pEntry); - /// @see <method>IApplicationElementNotification::onCopyEntry</method> virtual void onCopyEntry(SvLBoxEntry* _pEntry); - /// @see <method>IApplicationElementNotification::onPasteEntry</method> virtual void onPasteEntry(SvLBoxEntry* _pEntry); - /// @see <method>IApplicationElementNotification::onDeleteEntry</method> virtual void onDeleteEntry(SvLBoxEntry* _pEntry); + virtual void previewChanged( sal_Int32 _nMode); + virtual void containerFound( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer >& _xContainer); + + // IController (base of IApplicationController) + virtual void executeUnChecked(const ::com::sun::star::util::URL& _rCommand, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs); + virtual void executeChecked(const ::com::sun::star::util::URL& _rCommand, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs); + virtual void executeUnChecked(sal_uInt16 _nCommandId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs); + virtual void executeChecked(sal_uInt16 _nCommandId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs); + virtual sal_Bool isCommandEnabled(sal_uInt16 _nCommandId) const; + virtual sal_Bool isCommandEnabled( const ::rtl::OUString& _rCompleteCommandURL ) const; + virtual sal_uInt16 registerCommandURL( const ::rtl::OUString& _rCompleteCommandURL ); + virtual void notifyHiContrastChanged(); + virtual sal_Bool isDataSourceReadOnly() const; + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > + getXController(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual bool interceptUserInput( const NotifyEvent& _rEvent ); + + // IControlActionListener overridables + virtual sal_Bool requestQuickHelp( const SvLBoxEntry* _pEntry, String& _rText ) const; + virtual sal_Bool requestDrag( sal_Int8 _nAction, const Point& _rPosPixel ); + virtual sal_Int8 queryDrop( const AcceptDropEvent& _rEvt, const DataFlavorExVector& _rFlavors ); + virtual sal_Int8 executeDrop( const ExecuteDropEvent& _rEvt ); + + // IContextMenuProvider (base of IApplicationController) + virtual PopupMenu* getContextMenu( Control& _rControl ) const; + virtual IController& getCommandController(); + virtual ::cppu::OInterfaceContainerHelper* + getContextMenuInterceptors(); + virtual ::com::sun::star::uno::Any + getCurrentSelection( Control& _rControl ) const; DECL_LINK( OnInvalidateClipboard, void* ); DECL_LINK( OnClipboardChanged, void* ); DECL_LINK( OnAsyncDrop, void* ); DECL_LINK( OnCreateWithPilot, void* ); + DECL_LINK( OnSelectContainer, void* ); DECL_LINK( OnFirstControllerConnected, void* ); DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper* ); - // IContainerFoundListener - virtual void containerFound( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainer >& _xContainer); - - // IViewChangeListener - virtual void previewChanged( sal_Int32 _nMode); - protected: using OApplicationController_CBASE::connect; Directory: /dba/dbaccess/util/defs/ =================================== File [removed]: wntmsci12 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
