Tag: cws_src680_dba24a User: oj Date: 2007-08-03 06:14:32+0000 Modified: dba/dbaccess/source/ui/app/AppController.cxx dba/dbaccess/source/ui/app/AppController.hxx dba/dbaccess/source/ui/app/AppDetailPageHelper.cxx dba/dbaccess/source/ui/app/AppDetailPageHelper.hxx dba/dbaccess/source/ui/app/AppDetailView.cxx dba/dbaccess/source/ui/app/AppDetailView.hxx dba/dbaccess/source/ui/app/AppView.cxx dba/dbaccess/source/ui/app/AppView.hxx
Log: #i69740# implement the selection interface 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.42.14.1&r2=1.42.14.2 Delta lines: +130 -56 ---------------------- --- AppController.cxx 2007-07-23 11:59:02+0000 1.42.14.1 +++ AppController.cxx 2007-08-03 06:14:16+0000 1.42.14.2 @@ -4,9 +4,9 @@ * * $RCSfile: AppController.cxx,v $ * - * $Revision: 1.42.14.1 $ + * $Revision: 1.42.14.2 $ * - * last change: $Author: fs $ $Date: 2007/07/23 11:59:02 $ + * last change: $Author: oj $ $Date: 2007/08/03 06:14:16 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -253,7 +253,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> @@ -275,6 +277,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; @@ -724,7 +727,7 @@ 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; @@ -1618,7 +1621,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 ) @@ -2089,6 +2092,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) @@ -2098,35 +2104,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: @@ -2134,8 +2147,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; } } @@ -2152,9 +2164,8 @@ { OSL_ENSURE(0,"Exception catched while previewing!"); } - } + pView->showPreview(xContent); - } } //------------------------------------------------------------------------------ void OApplicationController::frameAction(const FrameActionEvent& aEvent) throw( RuntimeException ) @@ -2502,6 +2513,69 @@ OSL_ENSURE(0,"Could not listener on the container!"); } } +// ----------------------------------------------------------------------------- +::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< PropertyValue > aCurrentSelection; + if ( (_aSelection >>= aCurrentSelection) && aCurrentSelection.getLength() ) + { + ElementType eType = E_NONE; + const PropertyValue* pIter = aCurrentSelection.getConstArray(); + const PropertyValue* 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< PropertyValue > aCurrentSelection; + if ( getContainer() ) + { + ::std::vector< ::rtl::OUString> aList; + getSelectionElementNames(aList); + PropertyValue aType; + aType.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Type")); + aType.Value <<= static_cast<sal_Int32>(getContainer()->getElementType()); + PropertyValue 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 //........................................................................ File [changed]: AppController.hxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppController.hxx?r1=1.19&r2=1.19.16.1 Delta lines: +11 -3 -------------------- --- AppController.hxx 2007-07-06 07:58:06+0000 1.19 +++ AppController.hxx 2007-08-03 06:14:16+0000 1.19.16.1 @@ -4,9 +4,9 @@ * * $RCSfile: AppController.hxx,v $ * - * $Revision: 1.19 $ + * $Revision: 1.19.16.1 $ * - * last change: $Author: rt $ $Date: 2007/07/06 07:58:06 $ + * last change: $Author: oj $ $Date: 2007/08/03 06:14:16 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -443,6 +443,10 @@ Defines the mode of opening. @see OLinkedDocumentsAccess::EOpenMode */ void doAction(sal_uInt16 _nId ,OLinkedDocumentsAccess::EOpenMode _eOpenMode); + + /** select the give entry + */ + void selectEntry(const ElementType _eType,const ::rtl::OUString& _sName); protected: // ---------------------------------------------------------------- // initalizing members @@ -508,6 +512,10 @@ virtual ::sal_Bool SAL_CALL isConnected( ) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Bool SAL_CALL connect( ) 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); + /** retrieves the current connection, creates it if necessary */ const SharedConnection& ensureConnection(); File [changed]: AppDetailPageHelper.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppDetailPageHelper.cxx?r1=1.25&r2=1.25.2.1 Delta lines: +21 -3 -------------------- --- AppDetailPageHelper.cxx 2007-07-17 13:21:33+0000 1.25 +++ AppDetailPageHelper.cxx 2007-08-03 06:14:17+0000 1.25.2.1 @@ -4,9 +4,9 @@ * * $RCSfile: AppDetailPageHelper.cxx,v $ * - * $Revision: 1.25 $ + * $Revision: 1.25.2.1 $ * - * last change: $Author: obo $ $Date: 2007/07/17 13:21:33 $ + * last change: $Author: oj $ $Date: 2007/08/03 06:14:17 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -440,6 +440,24 @@ } } // ----------------------------------------------------------------------------- +void OAppDetailPageHelper::selectElements(const Sequence< ::rtl::OUString>& _aNames) +{ + int nPos = getVisibleControlIndex(); + if ( nPos < CONTROL_COUNT ) + { + DBTreeListBox& rTree = *m_pLists[nPos]; + rTree.SelectAll(FALSE); + const ::rtl::OUString* pIter = _aNames.getConstArray(); + const ::rtl::OUString* pEnd = pIter + _aNames.getLength(); + for(;pIter != pEnd;++pIter) + { + SvLBoxEntry* pEntry = rTree.GetEntryPosByName(*pIter); + if ( pEntry ) + rTree.Select(pEntry); + } + } +} +// ----------------------------------------------------------------------------- ::rtl::OUString OAppDetailPageHelper::getQualifiedName( SvLBoxEntry* _pEntry ) const { int nPos = getVisibleControlIndex(); File [changed]: AppDetailPageHelper.hxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppDetailPageHelper.hxx?r1=1.12&r2=1.12.36.1 Delta lines: +9 -3 ------------------- --- AppDetailPageHelper.hxx 2007-05-10 10:17:06+0000 1.12 +++ AppDetailPageHelper.hxx 2007-08-03 06:14:17+0000 1.12.36.1 @@ -4,9 +4,9 @@ * * $RCSfile: AppDetailPageHelper.hxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.12.36.1 $ * - * last change: $Author: kz $ $Date: 2007/05/10 10:17:06 $ + * last change: $Author: oj $ $Date: 2007/08/03 06:14:17 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -266,6 +266,12 @@ */ void getSelectionElementNames( ::std::vector< ::rtl::OUString>& _rNames ) const; + /** select all names on the currently selected container. Non existence names where ignored. + * + * \param _aNames the element names + */ + void selectElements(const ::com::sun::star::uno::Sequence< ::rtl::OUString>& _aNames); + /** return the qualified name. @param _pEntry The entry of a table, or query, form, report to get the qualified name. File [changed]: AppDetailView.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppDetailView.cxx?r1=1.23&r2=1.23.18.1 Delta lines: +9 -3 ------------------- --- AppDetailView.cxx 2007-07-06 07:59:01+0000 1.23 +++ AppDetailView.cxx 2007-08-03 06:14:17+0000 1.23.18.1 @@ -4,9 +4,9 @@ * * $RCSfile: AppDetailView.cxx,v $ * - * $Revision: 1.23 $ + * $Revision: 1.23.18.1 $ * - * last change: $Author: rt $ $Date: 2007/07/06 07:59:01 $ + * last change: $Author: oj $ $Date: 2007/08/03 06:14:17 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -886,6 +886,12 @@ m_pControlHelper->getSelectionElementNames( _rNames ); } // ----------------------------------------------------------------------------- +void OApplicationDetailView::selectElements(const Sequence< ::rtl::OUString>& _aNames) +{ + DBG_CHKTHIS(OApplicationDetailView,NULL); + m_pControlHelper->selectElements( _aNames ); +} +// ----------------------------------------------------------------------------- SvLBoxEntry* OApplicationDetailView::getEntry( const Point& _aPoint ) const { DBG_CHKTHIS(OApplicationDetailView,NULL); File [changed]: AppDetailView.hxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppDetailView.hxx?r1=1.16&r2=1.16.18.1 Delta lines: +9 -3 ------------------- --- AppDetailView.hxx 2007-07-06 07:59:25+0000 1.16 +++ AppDetailView.hxx 2007-08-03 06:14:17+0000 1.16.18.1 @@ -4,9 +4,9 @@ * * $RCSfile: AppDetailView.hxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.16.18.1 $ * - * last change: $Author: rt $ $Date: 2007/07/06 07:59:25 $ + * last change: $Author: oj $ $Date: 2007/08/03 06:14:17 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -300,6 +300,12 @@ */ void getSelectionElementNames(::std::vector< ::rtl::OUString>& _rNames ) const; + /** select all names on the currently selected container. Non existence names where ignored. + * + * \param _aNames the element names + */ + void selectElements(const ::com::sun::star::uno::Sequence< ::rtl::OUString>& _aNames); + /** adds a new object to the detail page. @param _eType The type where the entry shold be appended. File [changed]: AppView.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppView.cxx?r1=1.20&r2=1.20.18.1 Delta lines: +9 -3 ------------------- --- AppView.cxx 2007-07-06 08:01:04+0000 1.20 +++ AppView.cxx 2007-08-03 06:14:17+0000 1.20.18.1 @@ -4,9 +4,9 @@ * * $RCSfile: AppView.cxx,v $ * - * $Revision: 1.20 $ + * $Revision: 1.20.18.1 $ * - * last change: $Author: rt $ $Date: 2007/07/06 08:01:04 $ + * last change: $Author: oj $ $Date: 2007/08/03 06:14:17 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -517,6 +517,12 @@ getDetailView()->getSelectionElementNames( _rNames ); } // ----------------------------------------------------------------------------- +void OApplicationView::selectElements(const Sequence< ::rtl::OUString>& _aNames) +{ + OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF"); + getDetailView()->selectElements( _aNames ); +} +// ----------------------------------------------------------------------------- SvLBoxEntry* OApplicationView::elementAdded(ElementType eType,const ::rtl::OUString& _rName, const Any& _rObject ) { OSL_ENSURE(m_pWin && getDetailView(),"Detail view is NULL! -> GPF"); File [changed]: AppView.hxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppView.hxx?r1=1.13&r2=1.13.20.1 Delta lines: +9 -3 ------------------- --- AppView.hxx 2007-06-12 05:33:36+0000 1.13 +++ AppView.hxx 2007-08-03 06:14:17+0000 1.13.20.1 @@ -4,9 +4,9 @@ * * $RCSfile: AppView.hxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.13.20.1 $ * - * last change: $Author: obo $ $Date: 2007/06/12 05:33:36 $ + * last change: $Author: oj $ $Date: 2007/08/03 06:14:17 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -248,6 +248,12 @@ */ void getSelectionElementNames( ::std::vector< ::rtl::OUString>& _rNames ) const; + /** select all names on the currently selected container. Non existence names where ignored. + * + * \param _aNames the element names + */ + void selectElements(const ::com::sun::star::uno::Sequence< ::rtl::OUString>& _aNames); + /** adds a new object to the detail page. @param _eType The type where the entry shold be appended. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
