Tag: cws_src680_dba24b User: oj Date: 2007-09-28 11:51:53+0000 Modified: dba/dbaccess/source/ui/app/AppController.cxx
Log: RESYNC: (1.44-1.47); 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.44.6.3&r2=1.44.6.4 Delta lines: +167 -71 ---------------------- --- AppController.cxx 2007-08-29 12:07:02+0000 1.44.6.3 +++ AppController.cxx 2007-09-28 11:51:50+0000 1.44.6.4 @@ -111,6 +111,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 @@ -222,9 +224,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 @@ -252,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> @@ -272,6 +275,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; @@ -721,7 +725,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; @@ -803,7 +807,7 @@ if ( aReturn.bEnabled ) { DATASOURCE_TYPE eType = m_aTypeCollection.getType(::comphelper::getString(m_xDataSource->getPropertyValue(PROPERTY_URL))); - aReturn.bEnabled = DST_EMBEDDED_HSQLDB != 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: @@ -836,18 +840,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: @@ -965,11 +969,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) ); @@ -999,17 +1024,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 { @@ -1583,7 +1608,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 ) @@ -2030,6 +2055,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) @@ -2039,35 +2067,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: @@ -2075,8 +2110,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; } } @@ -2093,9 +2127,8 @@ { OSL_ENSURE(0,"Exception catched while previewing!"); } - } + pView->showPreview(xContent); - } } //------------------------------------------------------------------------------ void OApplicationController::frameAction(const FrameActionEvent& aEvent) throw( RuntimeException ) @@ -2443,6 +2476,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< 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]
