diff options
Diffstat (limited to 'dbaccess/source/ui/app/AppController.cxx')
-rw-r--r-- | dbaccess/source/ui/app/AppController.cxx | 575 |
1 files changed, 303 insertions, 272 deletions
diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx index b7036d149e25..741dc7afeeb8 100644 --- a/dbaccess/source/ui/app/AppController.cxx +++ b/dbaccess/source/ui/app/AppController.cxx @@ -20,6 +20,7 @@ #include <memory> #include "AppController.hxx" #include <core_resource.hxx> +#include <dbexchange.hxx> #include <strings.hxx> #include <advancedsettingsdlg.hxx> #include "subcomponentmanager.hxx" @@ -54,20 +55,19 @@ #include <com/sun/star/sdb/application/DatabaseObject.hpp> #include <com/sun/star/sdb/application/DatabaseObjectContainer.hpp> #include <com/sun/star/document/XDocumentEventBroadcaster.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <tools/urlobj.hxx> #include <osl/diagnose.h> #include <svl/filenotation.hxx> -#include <vcl/treelistbox.hxx> #include <vcl/transfer.hxx> #include <svtools/cliplistener.hxx> +#include <comphelper/interfacecontainer3.hxx> #include <comphelper/sequence.hxx> #include <comphelper/uno3.hxx> #include <comphelper/types.hxx> #include <comphelper/interaction.hxx> -#include <comphelper/processfactory.hxx> #include <vcl/svapp.hxx> #include <vcl/weld.hxx> @@ -97,6 +97,7 @@ #include <strings.hrc> #include <defaultobjectnamecheck.hxx> #include <databaseobjectview.hxx> +#include <dbtreelistbox.hxx> #include "AppDetailView.hxx" #include <linkeddocuments.hxx> #include <UITools.hxx> @@ -144,7 +145,7 @@ OUString SAL_CALL OApplicationController::getImplementationName() Sequence< OUString> SAL_CALL OApplicationController::getSupportedServiceNames() { - return { "com.sun.star.sdb.application.DefaultViewController" }; + return { u"com.sun.star.sdb.application.DefaultViewController"_ustr }; } namespace { @@ -157,7 +158,7 @@ class SelectionGuard; class SelectionNotifier { private: - ::comphelper::OInterfaceContainerHelper2 m_aSelectionListeners; + ::comphelper::OInterfaceContainerHelper3<XSelectionChangeListener> m_aSelectionListeners; ::cppu::OWeakObject& m_rContext; sal_Int32 m_nSelectionNestingLevel; @@ -251,7 +252,7 @@ OApplicationController::OApplicationController(const Reference< XComponentContex ,m_aTableCopyHelper(this) ,m_nAsyncDrop(nullptr) ,m_aSelectContainerEvent( LINK( this, OApplicationController, OnSelectContainer ) ) - ,m_ePreviewMode(E_PREVIEWNONE) + ,m_ePreviewMode(PreviewMode::NONE) ,m_eCurrentType(E_NONE) ,m_bNeedToReconnect(false) ,m_bSuspended( false ) @@ -326,14 +327,20 @@ void SAL_CALL OApplicationController::disposing() if ( m_xDataSource.is() ) { + // Should correspond to ODatabaseSource::createArrayHelper in dbaccess/source/core/dataaccess/datasource.cxx m_xDataSource->removePropertyChangeListener(OUString(), this); m_xDataSource->removePropertyChangeListener(PROPERTY_INFO, this); - m_xDataSource->removePropertyChangeListener(PROPERTY_URL, this); m_xDataSource->removePropertyChangeListener(PROPERTY_ISPASSWORDREQUIRED, this); + m_xDataSource->removePropertyChangeListener(PROPERTY_ISREADONLY, this); m_xDataSource->removePropertyChangeListener(PROPERTY_LAYOUTINFORMATION, this); + m_xDataSource->removePropertyChangeListener(PROPERTY_NAME, this); + m_xDataSource->removePropertyChangeListener(PROPERTY_NUMBERFORMATSSUPPLIER, this); + m_xDataSource->removePropertyChangeListener(PROPERTY_PASSWORD, this); + m_xDataSource->removePropertyChangeListener(PROPERTY_SETTINGS, this); m_xDataSource->removePropertyChangeListener(PROPERTY_SUPPRESSVERSIONCL, this); m_xDataSource->removePropertyChangeListener(PROPERTY_TABLEFILTER, this); m_xDataSource->removePropertyChangeListener(PROPERTY_TABLETYPEFILTER, this); + m_xDataSource->removePropertyChangeListener(PROPERTY_URL, this); m_xDataSource->removePropertyChangeListener(PROPERTY_USER, this); m_xDataSource = nullptr; } @@ -347,8 +354,7 @@ void SAL_CALL OApplicationController::disposing() OUString sUrl = m_xModel->getURL(); if ( !sUrl.isEmpty() ) { - ::comphelper::NamedValueCollection aArgs( m_xModel->getArgs() ); - if ( aArgs.getOrDefault( "PickListEntry", true ) ) + if ( ::comphelper::NamedValueCollection::getOrDefault( m_xModel->getArgs(), u"PickListEntry", true ) ) { OUString aFilter; INetURLObject aURL( m_xModel->getURL() ); @@ -356,12 +362,13 @@ void SAL_CALL OApplicationController::disposing() if ( pFilter ) aFilter = pFilter->GetFilterName(); + OUString sDatabaseName; // add to svtool history options - SvtHistoryOptions().AppendItem( ePICKLIST, + SvtHistoryOptions::AppendItem( EHistoryType::PickList, aURL.GetURLNoPass( INetURLObject::DecodeMechanism::NONE ), aFilter, - getStrippedDatabaseName(), - std::nullopt); + ::dbaui::getStrippedDatabaseName(m_xDataSource, sDatabaseName), + std::nullopt, std::nullopt); // add to recent document list if ( aURL.GetProtocol() == INetProtocol::File ) @@ -468,7 +475,7 @@ sal_Bool SAL_CALL OApplicationController::suspend(sal_Bool bSuspend) if ( xBroadcaster.is() ) { xBroadcaster->notifyDocumentEvent( - "OnPrepareViewClosing", + u"OnPrepareViewClosing"_ustr, this, Any() ); @@ -498,7 +505,8 @@ sal_Bool SAL_CALL OApplicationController::suspend(sal_Bool bSuspend) ) ) { - switch (ExecuteQuerySaveDocument(getFrameWeld(), getStrippedDatabaseName())) + OUString sDatabaseName; + switch (ExecuteQuerySaveDocument(getFrameWeld(), ::dbaui::getStrippedDatabaseName(m_xDataSource, sDatabaseName))) { case RET_YES: Execute(ID_BROWSER_SAVEDOC,Sequence<PropertyValue>()); @@ -532,6 +540,10 @@ FeatureState OApplicationController::GetState(sal_uInt16 _nId) const { switch (_nId) { + case SID_NEWDOCDIRECT: + aReturn.bEnabled = true; + aReturn.sTitle = "private:factory/sdatabase"; + break; case SID_OPENURL: aReturn.bEnabled = true; if ( m_xModel.is() ) @@ -586,11 +598,10 @@ FeatureState OApplicationController::GetState(sal_uInt16 _nId) const case SID_NEWDOC: case SID_APP_NEW_FORM: case ID_DOCUMENT_CREATE_REPWIZ: - aReturn.bEnabled = !isDataSourceReadOnly() && SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::EModule::WRITER); + aReturn.bEnabled = !isDataSourceReadOnly() && SvtModuleOptions().IsWriterInstalled(); break; case SID_APP_NEW_REPORT: - aReturn.bEnabled = !isDataSourceReadOnly() - && SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::EModule::WRITER); + aReturn.bEnabled = !isDataSourceReadOnly() && SvtModuleOptions().IsWriterInstalled(); if ( aReturn.bEnabled ) { Reference< XContentEnumerationAccess > xEnumAccess(m_xContext->getServiceManager(), UNO_QUERY); @@ -658,7 +669,7 @@ FeatureState OApplicationController::GetState(sal_uInt16 _nId) const case SID_REPORT_CREATE_REPWIZ_PRE_SEL: case SID_APP_NEW_REPORT_PRE_SEL: aReturn.bEnabled = !isDataSourceReadOnly() - && SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::EModule::WRITER) + && SvtModuleOptions().IsWriterInstalled() && getContainer()->isALeafSelected(); if ( aReturn.bEnabled ) { @@ -670,7 +681,7 @@ FeatureState OApplicationController::GetState(sal_uInt16 _nId) const aReturn.bEnabled = xEnumAccess.is(); if ( aReturn.bEnabled ) { - static const char s_sReportDesign[] = "org.libreoffice.report.pentaho.SOReportJobFactory"; + static constexpr OUStringLiteral s_sReportDesign = u"org.libreoffice.report.pentaho.SOReportJobFactory"; Reference< XEnumeration > xEnumDrivers = xEnumAccess->createContentEnumeration(s_sReportDesign); aReturn.bEnabled = xEnumDrivers.is() && xEnumDrivers->hasMoreElements(); } @@ -788,20 +799,22 @@ FeatureState OApplicationController::GetState(sal_uInt16 _nId) const break; case SID_DB_APP_DISABLE_PREVIEW: aReturn.bEnabled = true; - aReturn.bChecked = getContainer()->getPreviewMode() == E_PREVIEWNONE; + aReturn.bChecked = getContainer()->getPreviewMode() == PreviewMode::NONE; break; case SID_DB_APP_VIEW_DOCINFO_PREVIEW: { ElementType eType = getContainer()->getElementType(); aReturn.bEnabled = (E_REPORT == eType || E_FORM == eType); - aReturn.bChecked = getContainer()->getPreviewMode() == E_DOCUMENTINFO; + aReturn.bChecked = getContainer()->getPreviewMode() == PreviewMode::DocumentInfo; } break; case SID_DB_APP_VIEW_DOC_PREVIEW: aReturn.bEnabled = true; - aReturn.bChecked = getContainer()->getPreviewMode() == E_DOCUMENT; + aReturn.bChecked = getContainer()->getPreviewMode() == PreviewMode::Document; break; case ID_BROWSER_UNDO: + case SID_DB_APP_SENDREPORTTOWRITER: + case SID_DB_APP_DBADMIN: aReturn.bEnabled = false; break; case SID_MAIL_SENDDOC: @@ -813,10 +826,6 @@ FeatureState OApplicationController::GetState(sal_uInt16 _nId) const aReturn.bEnabled = E_REPORT == eType && getContainer()->getSelectionCount() > 0 && getContainer()->isALeafSelected(); } break; - case SID_DB_APP_SENDREPORTTOWRITER: - case SID_DB_APP_DBADMIN: - aReturn.bEnabled = false; - break; case SID_DB_APP_STATUS_TYPE: aReturn.bEnabled = m_xDataSource.is(); if ( aReturn.bEnabled ) @@ -902,17 +911,16 @@ namespace bool bHandled = false; // try handling the error with an interaction handler - ::comphelper::NamedValueCollection aArgs( _rxDocument->getArgs() ); - Reference< XInteractionHandler > xHandler( aArgs.getOrDefault( "InteractionHandler", Reference< XInteractionHandler >() ) ); + Reference< XInteractionHandler > xHandler = ::comphelper::NamedValueCollection::getOrDefault( _rxDocument->getArgs(), u"InteractionHandler", Reference< XInteractionHandler >() ); if ( xHandler.is() ) { rtl::Reference pRequest( new ::comphelper::OInteractionRequest( _rException ) ); rtl::Reference pApprove( new ::comphelper::OInteractionApprove ); - pRequest->addContinuation( pApprove.get() ); + pRequest->addContinuation( pApprove ); try { - xHandler->handle( pRequest.get() ); + xHandler->handle( pRequest ); } catch( const Exception& ) { @@ -1009,21 +1017,19 @@ void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyVa std::vector<SotClipboardFormatId> aFormatIds; getSupportedFormats(getContainer()->getElementType(),aFormatIds); for (auto const& formatId : aFormatIds) - pDlg->Insert(formatId,""); + pDlg->Insert(formatId,u""_ustr); const TransferableDataHelper& rClipboard = getViewClipboard(); pasteFormat(pDlg->GetFormat(rClipboard.GetTransferable())); } else { - const PropertyValue* pIter = aArgs.getConstArray(); - const PropertyValue* pEnd = pIter + aArgs.getLength(); - for( ; pIter != pEnd ; ++pIter) + for (auto& arg : aArgs) { - if ( pIter->Name == "FormatStringId" ) + if (arg.Name == "FormatStringId") { - sal_uLong nTmp; - if ( pIter->Value >>= nTmp ) + sal_uInt32 nTmp; + if (arg.Value >>= nTmp) pasteFormat(static_cast<SotClipboardFormatId>(nTmp)); break; } @@ -1031,17 +1037,25 @@ void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyVa } } break; + case SID_NEWDOCDIRECT: case SID_OPENDOC: { Reference < XDispatchProvider > xProv( getFrame(), UNO_QUERY ); if ( xProv.is() ) { URL aURL; - aURL.Complete = ".uno:Open"; + OUString aTarget; + if ( _nId == SID_NEWDOCDIRECT ) + { + aURL.Complete = "private:factory/sdatabase?Interactive"; + aTarget = "_default"; + } + else + aURL.Complete = ".uno:Open"; if ( m_xUrlTransformer.is() ) m_xUrlTransformer->parseStrict( aURL ); - Reference < XDispatch > xDisp = xProv->queryDispatch( aURL, OUString(), 0 ); + Reference < XDispatch > xDisp = xProv->queryDispatch( aURL, aTarget, 0 ); if ( xDisp.is() ) xDisp->dispatch( aURL, Sequence < PropertyValue >() ); } @@ -1066,13 +1080,13 @@ void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyVa OUString sUrl; if ( m_xModel.is() ) sUrl = m_xModel->getURL(); - if ( sUrl.isEmpty() ) - sUrl = SvtPathOptions().GetWorkPath(); ::sfx2::FileDialogHelper aFileDlg( ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION, FileDialogFlags::NONE, getFrameWeld()); - aFileDlg.SetDisplayDirectory( sUrl ); + aFileDlg.SetContext(sfx2::FileDialogHelper::BaseSaveAs); + if (!sUrl.isEmpty()) + aFileDlg.SetDisplayDirectory( sUrl ); std::shared_ptr<const SfxFilter> pFilter = getStandardDatabaseFilter(); if ( pFilter ) @@ -1158,7 +1172,7 @@ void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyVa eType = E_QUERY; break; case ID_NEW_QUERY_DESIGN: - aCreationArgs.put( OUString(PROPERTY_GRAPHICAL_DESIGN), true ); + aCreationArgs.put( PROPERTY_GRAPHICAL_DESIGN, true ); [[fallthrough]]; case ID_NEW_QUERY_SQL: eType = E_QUERY; @@ -1184,7 +1198,7 @@ void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyVa { ElementType eType = getContainer()->getElementType(); OUString sName = getContainer()->getQualifiedName( nullptr ); - insertHierachyElement(eType,sName); + insertHierarchyElement(eType,sName); } break; case ID_NEW_VIEW_DESIGN: @@ -1196,11 +1210,11 @@ void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyVa QueryDesigner aDesigner( getORB(), this, getFrame(), true ); ::comphelper::NamedValueCollection aCreationArgs; - aCreationArgs.put( OUString(PROPERTY_GRAPHICAL_DESIGN), ID_NEW_VIEW_DESIGN == _nId ); + aCreationArgs.put( PROPERTY_GRAPHICAL_DESIGN, ID_NEW_VIEW_DESIGN == _nId ); const Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY ); const Reference< XComponent > xComponent = aDesigner.createNew( xDataSource, aCreationArgs ); - onDocumentOpened( OUString(), E_QUERY, E_OPEN_DESIGN, xComponent, nullptr ); + onDocumentOpened( OUString(), E_QUERY, ElementOpenMode::Design, xComponent, nullptr ); } } break; @@ -1224,17 +1238,15 @@ void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyVa case SID_DB_APP_QUERY_EDIT: case SID_DB_APP_FORM_EDIT: case SID_DB_APP_REPORT_EDIT: - doAction( _nId, E_OPEN_DESIGN ); + doAction( _nId, ElementOpenMode::Design ); break; case SID_DB_APP_OPEN: case SID_DB_APP_TABLE_OPEN: case SID_DB_APP_QUERY_OPEN: case SID_DB_APP_FORM_OPEN: case SID_DB_APP_REPORT_OPEN: - doAction( _nId, E_OPEN_NORMAL ); - break; case SID_DB_APP_CONVERTTOVIEW: - doAction( _nId, E_OPEN_NORMAL ); + doAction( _nId, ElementOpenMode::Normal ); break; case SID_SELECTALL: getContainer()->selectAll(); @@ -1243,7 +1255,7 @@ void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyVa case SID_DB_APP_DSRELDESIGN: { Reference< XComponent > xRelationDesigner; - if ( !m_pSubComponentManager->activateSubFrame( OUString(), SID_DB_APP_DSRELDESIGN, E_OPEN_DESIGN, xRelationDesigner ) ) + if ( !m_pSubComponentManager->activateSubFrame( OUString(), SID_DB_APP_DSRELDESIGN, ElementOpenMode::Design, xRelationDesigner ) ) { SharedConnection xConnection( ensureConnection() ); if ( xConnection.is() ) @@ -1252,7 +1264,7 @@ void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyVa const Reference< XDataSource > xDataSource( m_xDataSource, UNO_QUERY ); const Reference< XComponent > xComponent = aDesigner.createNew( xDataSource ); - onDocumentOpened( OUString(), SID_DB_APP_DSRELDESIGN, E_OPEN_DESIGN, xComponent, nullptr ); + onDocumentOpened( OUString(), SID_DB_APP_DSRELDESIGN, ElementOpenMode::Design, xComponent, nullptr ); } } } @@ -1261,12 +1273,12 @@ void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyVa { SharedConnection xConnection( ensureConnection() ); if ( xConnection.is() ) - openDialog("com.sun.star.sdb.UserAdministrationDialog"); + openDialog(u"com.sun.star.sdb.UserAdministrationDialog"_ustr); } break; case SID_DB_APP_TABLEFILTER: // opens the table filter dialog for the selected data source - openDialog( "com.sun.star.sdb.TableFilterDialog" ); + openDialog( u"com.sun.star.sdb.TableFilterDialog"_ustr ); askToReconnect(); break; case SID_DB_APP_REFRESH_TABLES: @@ -1274,15 +1286,15 @@ void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyVa break; case SID_DB_APP_DSPROPS: // opens the administration dialog for the selected data source - openDialog( "com.sun.star.sdb.DatasourceAdministrationDialog" ); + openDialog( u"com.sun.star.sdb.DatasourceAdministrationDialog"_ustr ); askToReconnect(); break; case SID_DB_APP_DSADVANCED_SETTINGS: - openDialog("com.sun.star.sdb.AdvancedDatabaseSettingsDialog"); + openDialog(u"com.sun.star.sdb.AdvancedDatabaseSettingsDialog"_ustr); askToReconnect(); break; case SID_DB_APP_DSCONNECTION_TYPE: - openDialog("com.sun.star.sdb.DataSourceTypeChangeDialog"); + openDialog(u"com.sun.star.sdb.DataSourceTypeChangeDialog"_ustr); askToReconnect(); break; case ID_DIRECT_SQL: @@ -1306,15 +1318,15 @@ void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyVa m_aSelectContainerEvent.Call( reinterpret_cast< void* >( E_REPORT ) ); break; case SID_DB_APP_DISABLE_PREVIEW: - m_ePreviewMode = E_PREVIEWNONE; + m_ePreviewMode = PreviewMode::NONE; getContainer()->switchPreview(m_ePreviewMode); break; case SID_DB_APP_VIEW_DOCINFO_PREVIEW: - m_ePreviewMode = E_DOCUMENTINFO; + m_ePreviewMode = PreviewMode::DocumentInfo; getContainer()->switchPreview(m_ePreviewMode); break; case SID_DB_APP_VIEW_DOC_PREVIEW: - m_ePreviewMode = E_DOCUMENT; + m_ePreviewMode = PreviewMode::Document; getContainer()->switchPreview(m_ePreviewMode); break; case SID_MAIL_SENDDOC: @@ -1325,7 +1337,7 @@ void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyVa } break; case SID_DB_APP_SENDREPORTASMAIL: - doAction( _nId, E_OPEN_FOR_MAIL ); + doAction( _nId, ElementOpenMode::Mail ); break; } } @@ -1340,106 +1352,107 @@ void OApplicationController::describeSupportedFeatures() { OGenericUnoController::describeSupportedFeatures(); - implDescribeSupportedFeature( ".uno:Save", ID_BROWSER_SAVEDOC, CommandGroup::DOCUMENT ); - implDescribeSupportedFeature( ".uno:SaveAs", ID_BROWSER_SAVEASDOC, CommandGroup::DOCUMENT ); - implDescribeSupportedFeature( ".uno:SendMail", SID_MAIL_SENDDOC, CommandGroup::DOCUMENT ); - implDescribeSupportedFeature( ".uno:DBSendReportAsMail",SID_DB_APP_SENDREPORTASMAIL, + implDescribeSupportedFeature( u".uno:AddDirect"_ustr, SID_NEWDOCDIRECT, CommandGroup::APPLICATION ); + implDescribeSupportedFeature( u".uno:Save"_ustr, ID_BROWSER_SAVEDOC, CommandGroup::DOCUMENT ); + implDescribeSupportedFeature( u".uno:SaveAs"_ustr, ID_BROWSER_SAVEASDOC, CommandGroup::DOCUMENT ); + implDescribeSupportedFeature( u".uno:SendMail"_ustr, SID_MAIL_SENDDOC, CommandGroup::DOCUMENT ); + implDescribeSupportedFeature( u".uno:DBSendReportAsMail"_ustr,SID_DB_APP_SENDREPORTASMAIL, CommandGroup::DOCUMENT ); - implDescribeSupportedFeature( ".uno:DBSendReportToWriter",SID_DB_APP_SENDREPORTTOWRITER, + implDescribeSupportedFeature( u".uno:DBSendReportToWriter"_ustr,SID_DB_APP_SENDREPORTTOWRITER, CommandGroup::DOCUMENT ); - implDescribeSupportedFeature( ".uno:DBNewForm", SID_APP_NEW_FORM, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:DBNewFolder", SID_APP_NEW_FOLDER, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:DBNewFormAutoPilot", SID_DB_FORM_NEW_PILOT, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:DBNewFormAutoPilotWithPreSelection", + implDescribeSupportedFeature( u".uno:DBNewForm"_ustr, SID_APP_NEW_FORM, CommandGroup::INSERT ); + implDescribeSupportedFeature( u".uno:DBNewFolder"_ustr, SID_APP_NEW_FOLDER, CommandGroup::INSERT ); + implDescribeSupportedFeature( u".uno:DBNewFormAutoPilot"_ustr, SID_DB_FORM_NEW_PILOT, CommandGroup::INSERT ); + implDescribeSupportedFeature( u".uno:DBNewFormAutoPilotWithPreSelection"_ustr, SID_FORM_CREATE_REPWIZ_PRE_SEL, CommandGroup::APPLICATION ); - implDescribeSupportedFeature( ".uno:DBNewReport", SID_APP_NEW_REPORT, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:DBNewReportAutoPilot", + implDescribeSupportedFeature( u".uno:DBNewReport"_ustr, SID_APP_NEW_REPORT, CommandGroup::INSERT ); + implDescribeSupportedFeature( u".uno:DBNewReportAutoPilot"_ustr, ID_DOCUMENT_CREATE_REPWIZ, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:DBNewReportAutoPilotWithPreSelection", + implDescribeSupportedFeature( u".uno:DBNewReportAutoPilotWithPreSelection"_ustr, SID_REPORT_CREATE_REPWIZ_PRE_SEL, CommandGroup::APPLICATION ); - implDescribeSupportedFeature( ".uno:DBNewQuery", ID_NEW_QUERY_DESIGN, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:DBNewQuerySql", ID_NEW_QUERY_SQL, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:DBNewQueryAutoPilot",ID_APP_NEW_QUERY_AUTO_PILOT, + implDescribeSupportedFeature( u".uno:DBNewQuery"_ustr, ID_NEW_QUERY_DESIGN, CommandGroup::INSERT ); + implDescribeSupportedFeature( u".uno:DBNewQuerySql"_ustr, ID_NEW_QUERY_SQL, CommandGroup::INSERT ); + implDescribeSupportedFeature( u".uno:DBNewQueryAutoPilot"_ustr,ID_APP_NEW_QUERY_AUTO_PILOT, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:DBNewTable", ID_NEW_TABLE_DESIGN, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:DBNewTableAutoPilot",ID_NEW_TABLE_DESIGN_AUTO_PILOT, + implDescribeSupportedFeature( u".uno:DBNewTable"_ustr, ID_NEW_TABLE_DESIGN, CommandGroup::INSERT ); + implDescribeSupportedFeature( u".uno:DBNewTableAutoPilot"_ustr,ID_NEW_TABLE_DESIGN_AUTO_PILOT, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:DBNewView", ID_NEW_VIEW_DESIGN, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:DBNewViewSQL", SID_DB_NEW_VIEW_SQL, CommandGroup::INSERT ); - - implDescribeSupportedFeature( ".uno:DBDelete", SID_DB_APP_DELETE, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:Delete", SID_DB_APP_DELETE, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:DBRename", SID_DB_APP_RENAME, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:DBEdit", SID_DB_APP_EDIT, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:DBEditSqlView", SID_DB_APP_EDIT_SQL_VIEW, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:DBOpen", SID_DB_APP_OPEN, CommandGroup::EDIT ); - - implDescribeSupportedFeature( ".uno:DBTableDelete", SID_DB_APP_TABLE_DELETE, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:DBTableRename", SID_DB_APP_TABLE_RENAME, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:DBTableEdit", SID_DB_APP_TABLE_EDIT, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:DBTableOpen", SID_DB_APP_TABLE_OPEN, CommandGroup::EDIT ); - - implDescribeSupportedFeature( ".uno:DBQueryDelete", SID_DB_APP_QUERY_DELETE, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:DBQueryRename", SID_DB_APP_QUERY_RENAME, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:DBQueryEdit", SID_DB_APP_QUERY_EDIT, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:DBQueryOpen", SID_DB_APP_QUERY_OPEN, CommandGroup::EDIT ); - - implDescribeSupportedFeature( ".uno:DBFormDelete", SID_DB_APP_FORM_DELETE, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:DBFormRename", SID_DB_APP_FORM_RENAME, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:DBFormEdit", SID_DB_APP_FORM_EDIT, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:DBFormOpen", SID_DB_APP_FORM_OPEN, CommandGroup::EDIT ); - - implDescribeSupportedFeature( ".uno:DBReportDelete", SID_DB_APP_REPORT_DELETE, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:DBReportRename", SID_DB_APP_REPORT_RENAME, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:DBReportEdit", SID_DB_APP_REPORT_EDIT, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:DBReportOpen", SID_DB_APP_REPORT_OPEN, CommandGroup::EDIT ); - - implDescribeSupportedFeature( ".uno:SelectAll", SID_SELECTALL, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:Undo", ID_BROWSER_UNDO, CommandGroup::EDIT ); - - implDescribeSupportedFeature( ".uno:Sortup", ID_BROWSER_SORTUP, CommandGroup::VIEW ); - implDescribeSupportedFeature( ".uno:SortDown", ID_BROWSER_SORTDOWN, CommandGroup::VIEW ); - implDescribeSupportedFeature( ".uno:DBRelationDesign", SID_DB_APP_DSRELDESIGN, CommandGroup::APPLICATION ); - implDescribeSupportedFeature( ".uno:DBUserAdmin", SID_DB_APP_DSUSERADMIN, CommandGroup::APPLICATION ); - implDescribeSupportedFeature( ".uno:DBTableFilter", SID_DB_APP_TABLEFILTER, CommandGroup::APPLICATION ); - implDescribeSupportedFeature( ".uno:DBDSProperties", SID_DB_APP_DSPROPS, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:DBDSConnectionType", SID_DB_APP_DSCONNECTION_TYPE, + implDescribeSupportedFeature( u".uno:DBNewView"_ustr, ID_NEW_VIEW_DESIGN, CommandGroup::INSERT ); + implDescribeSupportedFeature( u".uno:DBNewViewSQL"_ustr, SID_DB_NEW_VIEW_SQL, CommandGroup::INSERT ); + + implDescribeSupportedFeature( u".uno:DBDelete"_ustr, SID_DB_APP_DELETE, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:Delete"_ustr, SID_DB_APP_DELETE, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:DBRename"_ustr, SID_DB_APP_RENAME, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:DBEdit"_ustr, SID_DB_APP_EDIT, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:DBEditSqlView"_ustr, SID_DB_APP_EDIT_SQL_VIEW, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:DBOpen"_ustr, SID_DB_APP_OPEN, CommandGroup::EDIT ); + + implDescribeSupportedFeature( u".uno:DBTableDelete"_ustr, SID_DB_APP_TABLE_DELETE, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:DBTableRename"_ustr, SID_DB_APP_TABLE_RENAME, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:DBTableEdit"_ustr, SID_DB_APP_TABLE_EDIT, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:DBTableOpen"_ustr, SID_DB_APP_TABLE_OPEN, CommandGroup::EDIT ); + + implDescribeSupportedFeature( u".uno:DBQueryDelete"_ustr, SID_DB_APP_QUERY_DELETE, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:DBQueryRename"_ustr, SID_DB_APP_QUERY_RENAME, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:DBQueryEdit"_ustr, SID_DB_APP_QUERY_EDIT, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:DBQueryOpen"_ustr, SID_DB_APP_QUERY_OPEN, CommandGroup::EDIT ); + + implDescribeSupportedFeature( u".uno:DBFormDelete"_ustr, SID_DB_APP_FORM_DELETE, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:DBFormRename"_ustr, SID_DB_APP_FORM_RENAME, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:DBFormEdit"_ustr, SID_DB_APP_FORM_EDIT, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:DBFormOpen"_ustr, SID_DB_APP_FORM_OPEN, CommandGroup::EDIT ); + + implDescribeSupportedFeature( u".uno:DBReportDelete"_ustr, SID_DB_APP_REPORT_DELETE, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:DBReportRename"_ustr, SID_DB_APP_REPORT_RENAME, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:DBReportEdit"_ustr, SID_DB_APP_REPORT_EDIT, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:DBReportOpen"_ustr, SID_DB_APP_REPORT_OPEN, CommandGroup::EDIT ); + + implDescribeSupportedFeature( u".uno:SelectAll"_ustr, SID_SELECTALL, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:Undo"_ustr, ID_BROWSER_UNDO, CommandGroup::EDIT ); + + implDescribeSupportedFeature( u".uno:Sortup"_ustr, ID_BROWSER_SORTUP, CommandGroup::VIEW ); + implDescribeSupportedFeature( u".uno:SortDown"_ustr, ID_BROWSER_SORTDOWN, CommandGroup::VIEW ); + implDescribeSupportedFeature( u".uno:DBRelationDesign"_ustr, SID_DB_APP_DSRELDESIGN, CommandGroup::APPLICATION ); + implDescribeSupportedFeature( u".uno:DBUserAdmin"_ustr, SID_DB_APP_DSUSERADMIN, CommandGroup::APPLICATION ); + implDescribeSupportedFeature( u".uno:DBTableFilter"_ustr, SID_DB_APP_TABLEFILTER, CommandGroup::APPLICATION ); + implDescribeSupportedFeature( u".uno:DBDSProperties"_ustr, SID_DB_APP_DSPROPS, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:DBDSConnectionType"_ustr, SID_DB_APP_DSCONNECTION_TYPE, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:DBDSAdvancedSettings", + implDescribeSupportedFeature( u".uno:DBDSAdvancedSettings"_ustr, SID_DB_APP_DSADVANCED_SETTINGS, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:PasteSpecial", SID_DB_APP_PASTE_SPECIAL, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:DBConvertToView", SID_DB_APP_CONVERTTOVIEW, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:DBRefreshTables", SID_DB_APP_REFRESH_TABLES, CommandGroup::APPLICATION ); - implDescribeSupportedFeature( ".uno:DBDirectSQL", ID_DIRECT_SQL, CommandGroup::APPLICATION ); - implDescribeSupportedFeature( ".uno:DBViewTables", SID_DB_APP_VIEW_TABLES, CommandGroup::VIEW ); - implDescribeSupportedFeature( ".uno:DBViewQueries", SID_DB_APP_VIEW_QUERIES, CommandGroup::VIEW ); - implDescribeSupportedFeature( ".uno:DBViewForms", SID_DB_APP_VIEW_FORMS, CommandGroup::VIEW ); - implDescribeSupportedFeature( ".uno:DBViewReports", SID_DB_APP_VIEW_REPORTS, CommandGroup::VIEW ); - implDescribeSupportedFeature( ".uno:DBDisablePreview", SID_DB_APP_DISABLE_PREVIEW,CommandGroup::VIEW ); - implDescribeSupportedFeature( ".uno:DBShowDocInfoPreview", + implDescribeSupportedFeature( u".uno:PasteSpecial"_ustr, SID_DB_APP_PASTE_SPECIAL, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:DBConvertToView"_ustr, SID_DB_APP_CONVERTTOVIEW, CommandGroup::EDIT ); + implDescribeSupportedFeature( u".uno:DBRefreshTables"_ustr, SID_DB_APP_REFRESH_TABLES, CommandGroup::APPLICATION ); + implDescribeSupportedFeature( u".uno:DBDirectSQL"_ustr, ID_DIRECT_SQL, CommandGroup::APPLICATION ); + implDescribeSupportedFeature( u".uno:DBViewTables"_ustr, SID_DB_APP_VIEW_TABLES, CommandGroup::VIEW ); + implDescribeSupportedFeature( u".uno:DBViewQueries"_ustr, SID_DB_APP_VIEW_QUERIES, CommandGroup::VIEW ); + implDescribeSupportedFeature( u".uno:DBViewForms"_ustr, SID_DB_APP_VIEW_FORMS, CommandGroup::VIEW ); + implDescribeSupportedFeature( u".uno:DBViewReports"_ustr, SID_DB_APP_VIEW_REPORTS, CommandGroup::VIEW ); + implDescribeSupportedFeature( u".uno:DBDisablePreview"_ustr, SID_DB_APP_DISABLE_PREVIEW,CommandGroup::VIEW ); + implDescribeSupportedFeature( u".uno:DBShowDocInfoPreview"_ustr, SID_DB_APP_VIEW_DOCINFO_PREVIEW, CommandGroup::VIEW ); - implDescribeSupportedFeature( ".uno:DBShowDocPreview", SID_DB_APP_VIEW_DOC_PREVIEW, + implDescribeSupportedFeature( u".uno:DBShowDocPreview"_ustr, SID_DB_APP_VIEW_DOC_PREVIEW, CommandGroup::VIEW ); - implDescribeSupportedFeature( ".uno:OpenUrl", SID_OPENURL, CommandGroup::APPLICATION ); + implDescribeSupportedFeature( u".uno:OpenUrl"_ustr, SID_OPENURL, CommandGroup::APPLICATION ); // this one should not appear under Tools->Customize->Keyboard - implDescribeSupportedFeature( ".uno:DBNewReportWithPreSelection", + implDescribeSupportedFeature( u".uno:DBNewReportWithPreSelection"_ustr, SID_APP_NEW_REPORT_PRE_SEL ); - implDescribeSupportedFeature( ".uno:DBDSImport", SID_DB_APP_DSIMPORT); - implDescribeSupportedFeature( ".uno:DBDSExport", SID_DB_APP_DSEXPORT); - implDescribeSupportedFeature( ".uno:DBDBAdmin", SID_DB_APP_DBADMIN); + implDescribeSupportedFeature( u".uno:DBDSImport"_ustr, SID_DB_APP_DSIMPORT); + implDescribeSupportedFeature( u".uno:DBDSExport"_ustr, SID_DB_APP_DSEXPORT); + implDescribeSupportedFeature( u".uno:DBDBAdmin"_ustr, SID_DB_APP_DBADMIN); // status info - implDescribeSupportedFeature( ".uno:DBStatusType", SID_DB_APP_STATUS_TYPE); - implDescribeSupportedFeature( ".uno:DBStatusDBName", SID_DB_APP_STATUS_DBNAME); - implDescribeSupportedFeature( ".uno:DBStatusUserName", SID_DB_APP_STATUS_USERNAME); - implDescribeSupportedFeature( ".uno:DBStatusHostName", SID_DB_APP_STATUS_HOSTNAME); + implDescribeSupportedFeature( u".uno:DBStatusType"_ustr, SID_DB_APP_STATUS_TYPE); + implDescribeSupportedFeature( u".uno:DBStatusDBName"_ustr, SID_DB_APP_STATUS_DBNAME); + implDescribeSupportedFeature( u".uno:DBStatusUserName"_ustr, SID_DB_APP_STATUS_USERNAME); + implDescribeSupportedFeature( u".uno:DBStatusHostName"_ustr, SID_DB_APP_STATUS_HOSTNAME); } OApplicationView* OApplicationController::getContainer() const @@ -1670,26 +1683,35 @@ bool OApplicationController::onContainerSelect(ElementType _eType) return true; } -bool OApplicationController::onEntryDoubleClick( SvTreeListBox const & _rTree ) +bool OApplicationController::onEntryDoubleClick(const weld::TreeView& rTreeView) { - if ( getContainer() && getContainer()->isLeaf( _rTree.GetHdlEntry() ) ) + OApplicationView* pContainer = getContainer(); + if (!pContainer) + return false; // not handled + + std::unique_ptr<weld::TreeIter> xHdlEntry = rTreeView.make_iterator(); + if (!rTreeView.get_cursor(xHdlEntry.get())) + return false; + + if (!pContainer->isLeaf(rTreeView, *xHdlEntry)) + return false; // not handled + + try { - try - { - // opens a new frame with either the table or the query or report or form or view - openElementWithArguments( - getContainer()->getQualifiedName( _rTree.GetHdlEntry() ), - getContainer()->getElementType(), - E_OPEN_NORMAL, - 0, - ::comphelper::NamedValueCollection() ); - return true; // handled - } - catch(const Exception&) - { - DBG_UNHANDLED_EXCEPTION("dbaccess"); - } + // opens a new frame with either the table or the query or report or form or view + openElementWithArguments( + getContainer()->getQualifiedName(xHdlEntry.get()), + getContainer()->getElementType(), + ElementOpenMode::Normal, + 0, + ::comphelper::NamedValueCollection() ); + return true; // handled } + catch(const Exception&) + { + DBG_UNHANDLED_EXCEPTION("dbaccess"); + } + return false; // not handled } @@ -1726,7 +1748,7 @@ Reference< XComponent > OApplicationController::openElementWithArguments( const return nullptr; Reference< XComponent > xRet; - if ( _eOpenMode == E_OPEN_DESIGN ) + if ( _eOpenMode == ElementOpenMode::Design ) { // https://bz.apache.org/ooo/show_bug.cgi?id=30382 getContainer()->showPreview(nullptr); @@ -1736,7 +1758,7 @@ Reference< XComponent > OApplicationController::openElementWithArguments( const switch ( _eType ) { case E_REPORT: - if ( _eOpenMode != E_OPEN_DESIGN ) + if ( _eOpenMode != ElementOpenMode::Design ) { // reports which are opened in a mode other than design are no sub components of our application // component, but standalone documents. @@ -1773,7 +1795,7 @@ Reference< XComponent > OApplicationController::openElementWithArguments( const ::comphelper::NamedValueCollection aArguments( _rAdditionalArguments ); Any aDataSource; - if ( _eOpenMode == E_OPEN_DESIGN ) + if ( _eOpenMode == ElementOpenMode::Design ) { bool bAddViewTypeArg = false; @@ -1799,7 +1821,7 @@ Reference< XComponent > OApplicationController::openElementWithArguments( const if ( bAddViewTypeArg ) { const bool bQueryGraphicalMode =( _nInstigatorCommand != SID_DB_APP_EDIT_SQL_VIEW ); - aArguments.put( OUString(PROPERTY_GRAPHICAL_DESIGN), bQueryGraphicalMode ); + aArguments.put( PROPERTY_GRAPHICAL_DESIGN, bQueryGraphicalMode ); } } @@ -1807,8 +1829,8 @@ Reference< XComponent > OApplicationController::openElementWithArguments( const { pDesigner.reset( new ResultSetBrowser( getORB(), this, m_aCurrentFrame.getFrame(), _eType == E_TABLE ) ); - if ( !aArguments.has( OUString(PROPERTY_SHOWMENU) ) ) - aArguments.put( OUString(PROPERTY_SHOWMENU), makeAny( true ) ); + if ( !aArguments.has( PROPERTY_SHOWMENU ) ) + aArguments.put( PROPERTY_SHOWMENU, Any( true ) ); aDataSource <<= getDatabaseName(); } @@ -1933,7 +1955,7 @@ Reference< XComponent > OApplicationController::newElement( ElementType _eType, } if ( xComponent.is() ) - onDocumentOpened( OUString(), _eType, E_OPEN_DESIGN, xComponent, o_rDocumentDefinition ); + onDocumentOpened( OUString(), _eType, ElementOpenMode::Design, xComponent, o_rDocumentDefinition ); return xComponent; } @@ -2007,11 +2029,11 @@ void OApplicationController::renameEntry() Reference<XHierarchicalNameContainer> xParent(xChild->getParent(),UNO_QUERY); if ( xParent.is() ) { - xHNames = xParent; + xHNames = std::move(xParent); Reference<XPropertySet>(xRename,UNO_QUERY_THROW)->getPropertyValue(PROPERTY_NAME) >>= sName; } } - pNameChecker.reset( new HierarchicalNameCheck( xHNames.get(), OUString() ) ); + pNameChecker.reset( new HierarchicalNameCheck( xHNames, OUString() ) ); xDialog.reset(new OSaveAsDlg( getFrameWeld(), getORB(), sName, sLabel, *pNameChecker, SADFlags::TitleRename)); } @@ -2090,7 +2112,7 @@ void OApplicationController::renameEntry() catch(const ElementExistException& e) { OUString sMsg(DBA_RES(STR_NAME_ALREADY_EXISTS)); - showError(SQLExceptionInfo(SQLException(sMsg.replaceAll("#", e.Message), e.Context, "S1000", 0, Any()))); + showError(SQLExceptionInfo(SQLException(sMsg.replaceAll("#", e.Message), e.Context, u"S1000"_ustr, 0, Any()))); } catch(const Exception& ) { @@ -2132,7 +2154,7 @@ void OApplicationController::onSelectionChanged() void OApplicationController::showPreviewFor(const ElementType _eType,const OUString& _sName) { - if ( m_ePreviewMode == E_PREVIEWNONE ) + if ( m_ePreviewMode == PreviewMode::NONE ) return; OApplicationView* pView = getContainer(); @@ -2224,9 +2246,9 @@ void OApplicationController::onDeleteEntry() executeChecked(nId,Sequence<PropertyValue>()); } -OUString OApplicationController::getContextMenuResourceName( Control& /*_rControl*/ ) const +OUString OApplicationController::getContextMenuResourceName() const { - return "edit"; + return u"edit"_ustr; } IController& OApplicationController::getCommandController() @@ -2239,31 +2261,52 @@ IController& OApplicationController::getCommandController() return &m_aContextMenuInterceptors; } -Any OApplicationController::getCurrentSelection( Control& _rControl ) const +Any OApplicationController::getCurrentSelection(weld::TreeView& rControl) const { Sequence< NamedDatabaseObject > aSelection; - getContainer()->describeCurrentSelectionForControl( _rControl, aSelection ); - return makeAny( aSelection ); + getContainer()->describeCurrentSelectionForControl(rControl, aSelection); + return Any( aSelection ); } -bool OApplicationController::requestQuickHelp( const SvTreeListEntry* /*_pEntry*/, OUString& /*_rText*/ ) const +vcl::Window* OApplicationController::getMenuParent() const +{ + return getContainer()->getMenuParent(); +} + +void OApplicationController::adjustMenuPosition(const weld::TreeView& rControl, ::Point& rPos) const +{ + getContainer()->adjustMenuPosition(rControl, rPos); +} + +bool OApplicationController::requestQuickHelp(const void* /*pUserData*/, OUString& /*rText*/) const { return false; } -bool OApplicationController::requestDrag( const Point& /*_rPosPixel*/ ) +bool OApplicationController::requestDrag(const weld::TreeIter& /*rEntry*/) { - rtl::Reference<TransferableHelper> pTransfer; - if ( getContainer() && getContainer()->getSelectionCount() ) + bool bSuccess = false; + + OApplicationView* pContainer = getContainer(); + if (pContainer && pContainer->getSelectionCount()) { try { - pTransfer = copyObject( ); - - if ( pTransfer && getContainer()->getDetailView() ) + if (getContainer()->getDetailView()) { + TreeListBox* pTreeListBox = getContainer()->getDetailView()->getTreeWindow(); + ElementType eType = getContainer()->getElementType(); - pTransfer->StartDrag( getContainer()->getDetailView()->getTreeWindow(), ((eType == E_FORM || eType == E_REPORT) ? DND_ACTION_COPYMOVE : DND_ACTION_COPY) ); + if (eType == E_TABLE || eType == E_QUERY) + { + ODataClipboard& rExchange = static_cast<ODataClipboard&>(pTreeListBox->GetDataTransfer()); + bSuccess = copySQLObject(rExchange); + } + else + { + svx::OComponentTransferable& rExchange = static_cast<svx::OComponentTransferable&>(pTreeListBox->GetDataTransfer()); + bSuccess = copyDocObject(rExchange); + } } } catch(const Exception& ) @@ -2272,7 +2315,7 @@ bool OApplicationController::requestDrag( const Point& /*_rPosPixel*/ ) } } - return pTransfer.is(); + return bSuccess; } sal_Int8 OApplicationController::queryDrop( const AcceptDropEvent& _rEvt, const DataFlavorExVector& _rFlavors ) @@ -2280,44 +2323,42 @@ sal_Int8 OApplicationController::queryDrop( const AcceptDropEvent& _rEvt, const sal_Int8 nActionAskedFor = _rEvt.mnAction; // check if we're a table or query container OApplicationView* pView = getContainer(); - if ( pView && !isDataSourceReadOnly() ) + if ( !pView || isDataSourceReadOnly() ) + return DND_ACTION_NONE; + + ElementType eType = pView->getElementType(); + if ( eType == E_NONE || (eType == E_TABLE && isConnectionReadOnly()) ) + return DND_ACTION_NONE; + + // check for the concrete type + if(std::any_of(_rFlavors.begin(),_rFlavors.end(),TAppSupportedSotFunctor(eType))) + return DND_ACTION_COPY; + + if ( eType != E_FORM && eType != E_REPORT ) + return DND_ACTION_NONE; + + sal_Int8 nAction = OComponentTransferable::canExtractComponentDescriptor(_rFlavors,eType == E_FORM) ? DND_ACTION_COPY : DND_ACTION_NONE; + if ( nAction == DND_ACTION_NONE ) + return DND_ACTION_NONE; + + auto xHitEntry = pView->getEntry(_rEvt.maPosPixel); + if (xHitEntry) { - ElementType eType = pView->getElementType(); - if ( eType != E_NONE && (eType != E_TABLE || !isConnectionReadOnly()) ) + OUString sName = pView->getQualifiedName(xHitEntry.get()); + if ( !sName.isEmpty() ) { - // check for the concrete type - if(std::any_of(_rFlavors.begin(),_rFlavors.end(),TAppSupportedSotFunctor(eType))) - return DND_ACTION_COPY; - if ( eType == E_FORM || eType == E_REPORT ) + Reference< XHierarchicalNameAccess > xContainer(getElements(pView->getElementType()),UNO_QUERY); + if ( xContainer.is() && xContainer->hasByHierarchicalName(sName) ) { - sal_Int8 nAction = OComponentTransferable::canExtractComponentDescriptor(_rFlavors,eType == E_FORM) ? DND_ACTION_COPY : DND_ACTION_NONE; - if ( nAction != DND_ACTION_NONE ) - { - SvTreeListEntry* pHitEntry = pView->getEntry(_rEvt.maPosPixel); - OUString sName; - if ( pHitEntry ) - { - sName = pView->getQualifiedName( pHitEntry ); - if ( !sName.isEmpty() ) - { - Reference< XHierarchicalNameAccess > xContainer(getElements(pView->getElementType()),UNO_QUERY); - if ( xContainer.is() && xContainer->hasByHierarchicalName(sName) ) - { - Reference< XHierarchicalNameAccess > xHitObject(xContainer->getByHierarchicalName(sName),UNO_QUERY); - if ( xHitObject.is() ) - nAction = nActionAskedFor & DND_ACTION_COPYMOVE; - } - else - nAction = DND_ACTION_NONE; - } - } - } - return nAction; + Reference< XHierarchicalNameAccess > xHitObject(xContainer->getByHierarchicalName(sName),UNO_QUERY); + if ( xHitObject.is() ) + nAction = nActionAskedFor & DND_ACTION_COPYMOVE; } + else + nAction = DND_ACTION_NONE; } } - - return DND_ACTION_NONE; + return nAction; } sal_Int8 OApplicationController::executeDrop( const ExecuteDropEvent& _rEvt ) @@ -2358,9 +2399,9 @@ sal_Int8 OApplicationController::executeDrop( const ExecuteDropEvent& _rEvt ) else if ( OComponentTransferable::canExtractComponentDescriptor(aDroppedData.GetDataFlavorExVector(),m_aAsyncDrop.nType == E_FORM) ) { m_aAsyncDrop.aDroppedData = OComponentTransferable::extractComponentDescriptor(aDroppedData); - SvTreeListEntry* pHitEntry = pView->getEntry(_rEvt.maPosPixel); - if ( pHitEntry ) - m_aAsyncDrop.aUrl = pView->getQualifiedName( pHitEntry ); + auto xHitEntry = pView->getEntry(_rEvt.maPosPixel); + if ( xHitEntry ) + m_aAsyncDrop.aUrl = pView->getQualifiedName(xHitEntry.get()); sal_Int8 nAction = _rEvt.mnAction; Reference<XContent> xContent; @@ -2472,8 +2513,7 @@ void OApplicationController::OnFirstControllerConnected() { // 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", false ) ) + if ( ::comphelper::NamedValueCollection::getOrDefault( m_xModel->getArgs(), u"SuppressMigrationWarning", false ) ) return; // also, if the document is read-only, then no migration is possible, and the @@ -2481,13 +2521,10 @@ void OApplicationController::OnFirstControllerConnected() if ( Reference< XStorable >( m_xModel, UNO_QUERY_THROW )->isReadonly() ) return; - SQLWarning aWarning; - aWarning.Message = DBA_RES(STR_SUB_DOCS_WITH_SCRIPTS); - SQLException aDetail; - aDetail.Message = DBA_RES(STR_SUB_DOCS_WITH_SCRIPTS_DETAIL); - aWarning.NextException <<= aDetail; + SQLException aDetail(DBA_RES(STR_SUB_DOCS_WITH_SCRIPTS_DETAIL), {}, {}, 0, {}); + SQLWarning aWarning(DBA_RES(STR_SUB_DOCS_WITH_SCRIPTS), {}, {}, 0, css::uno::Any(aDetail)); - Reference< XExecutableDialog > xDialog = ErrorMessageDialog::create( getORB(), "", nullptr, makeAny( aWarning ) ); + Reference< XExecutableDialog > xDialog = ErrorMessageDialog::create( getORB(), u""_ustr, nullptr, Any( aWarning ) ); xDialog->execute(); } catch( const Exception& ) @@ -2526,7 +2563,7 @@ sal_Bool SAL_CALL OApplicationController::attachModel(const Reference< XModel > const OUString aPropertyNames[] = { - OUString(PROPERTY_URL), OUString(PROPERTY_USER) + PROPERTY_URL, PROPERTY_USER }; // disconnect from old model @@ -2573,25 +2610,25 @@ sal_Bool SAL_CALL OApplicationController::attachModel(const Reference< XModel > } // initial preview mode - if ( m_xDataSource.is() ) + if ( !m_xDataSource ) + return true; + + try { - try + // to get the 'modified' for the data source + ::comphelper::NamedValueCollection aLayoutInfo( m_xDataSource->getPropertyValue( PROPERTY_LAYOUTINFORMATION ) ); + if ( aLayoutInfo.has( INFO_PREVIEW ) ) { - // to get the 'modified' for the data source - ::comphelper::NamedValueCollection aLayoutInfo( m_xDataSource->getPropertyValue( PROPERTY_LAYOUTINFORMATION ) ); - if ( aLayoutInfo.has( OUString(INFO_PREVIEW) ) ) - { - const sal_Int32 nPreviewMode( aLayoutInfo.getOrDefault( INFO_PREVIEW, sal_Int32(0) ) ); - m_ePreviewMode = static_cast< PreviewMode >( nPreviewMode ); - if ( getView() ) - getContainer()->switchPreview( m_ePreviewMode ); - } - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION("dbaccess"); + const sal_Int32 nPreviewMode( aLayoutInfo.getOrDefault( INFO_PREVIEW, sal_Int32(0) ) ); + m_ePreviewMode = static_cast< PreviewMode >( nPreviewMode ); + if ( getView() ) + getContainer()->switchPreview( m_ePreviewMode ); } } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION("dbaccess"); + } return true; } @@ -2659,20 +2696,18 @@ sal_Bool SAL_CALL OApplicationController::select( const Any& _aSelection ) if ( (_aSelection >>= aCurrentSelection) && aCurrentSelection.hasElements() ) { ElementType eType = E_NONE; - const NamedValue* pIter = aCurrentSelection.getConstArray(); - const NamedValue* pEnd = pIter + aCurrentSelection.getLength(); - for(;pIter != pEnd;++pIter) + for (auto& item : aCurrentSelection) { - if ( pIter->Name == "Type" ) + if (item.Name == "Type") { sal_Int32 nType = 0; - pIter->Value >>= nType; + item.Value >>= nType; if ( nType < DatabaseObject::TABLE || nType > DatabaseObject::REPORT ) throw IllegalArgumentException(); eType = static_cast< ElementType >( nType ); } - else if ( pIter->Name == "Selection" ) - pIter->Value >>= aSelection; + else if (item.Name == "Selection") + item.Value >>= aSelection; } m_aSelectContainerEvent.CancelCall(); // just in case the async select request was running @@ -2686,48 +2721,43 @@ sal_Bool SAL_CALL OApplicationController::select( const Any& _aSelection ) if ( !( _aSelection >>= aSelectedObjects ) ) { aSelectedObjects.realloc( 1 ); - if ( !( _aSelection >>= aSelectedObjects[0] ) ) + if ( !( _aSelection >>= aSelectedObjects.getArray()[0] ) ) throw IllegalArgumentException(); } SelectionByElementType aSelectedElements; ElementType eSelectedCategory = E_NONE; - for ( const NamedDatabaseObject* pObject = aSelectedObjects.getConstArray(); - pObject != aSelectedObjects.getConstArray() + aSelectedObjects.getLength(); - ++pObject - ) + for (sal_Int32 i = 0; i < aSelectedObjects.getLength(); ++i) { - switch ( pObject->Type ) + switch (aSelectedObjects[i].Type) { case DatabaseObject::TABLE: case DatabaseObjectContainer::SCHEMA: case DatabaseObjectContainer::CATALOG: - aSelectedElements[ E_TABLE ].push_back( pObject->Name ); + aSelectedElements[E_TABLE].push_back(aSelectedObjects[i].Name); break; case DatabaseObject::QUERY: - aSelectedElements[ E_QUERY ].push_back( pObject->Name ); + aSelectedElements[E_QUERY].push_back(aSelectedObjects[i].Name); break; case DatabaseObject::FORM: case DatabaseObjectContainer::FORMS_FOLDER: - aSelectedElements[ E_FORM ].push_back( pObject->Name ); + aSelectedElements[E_FORM].push_back(aSelectedObjects[i].Name); break; case DatabaseObject::REPORT: case DatabaseObjectContainer::REPORTS_FOLDER: - aSelectedElements[ E_REPORT ].push_back( pObject->Name ); + aSelectedElements[E_REPORT].push_back(aSelectedObjects[i].Name); break; case DatabaseObjectContainer::TABLES: case DatabaseObjectContainer::QUERIES: case DatabaseObjectContainer::FORMS: case DatabaseObjectContainer::REPORTS: if ( eSelectedCategory != E_NONE ) - throw IllegalArgumentException( - DBA_RES(RID_STR_NO_DIFF_CAT), - *this, sal_Int16( pObject - aSelectedObjects.getConstArray() ) ); + throw IllegalArgumentException(DBA_RES(RID_STR_NO_DIFF_CAT), *this, i); 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 + ( aSelectedObjects[i].Type == DatabaseObjectContainer::TABLES ) ? E_TABLE + : ( aSelectedObjects[i].Type == DatabaseObjectContainer::QUERIES ) ? E_QUERY + : ( aSelectedObjects[i].Type == DatabaseObjectContainer::FORMS ) ? E_FORM + : ( aSelectedObjects[i].Type == DatabaseObjectContainer::REPORTS ) ? E_REPORT : E_NONE; break; @@ -2736,8 +2766,8 @@ sal_Bool SAL_CALL OApplicationController::select( const Any& _aSelection ) { OUString sMessage( DBA_RES(RID_STR_UNSUPPORTED_OBJECT_TYPE). - replaceFirst("$type$", OUString::number(pObject->Type))); - throw IllegalArgumentException(sMessage, *this, sal_Int16( pObject - aSelectedObjects.getConstArray() )); + replaceFirst("$type$", OUString::number(aSelectedObjects[i].Type))); + throw IllegalArgumentException(sMessage, *this, i); } } } @@ -2773,20 +2803,21 @@ Any SAL_CALL OApplicationController::getSelection( ) { // if no objects are selected, add an entry to the sequence which describes the overall category // which is selected currently aCurrentSelection.realloc(1); - aCurrentSelection[0].Name = getDatabaseName(); + auto pCurrentSelection = aCurrentSelection.getArray(); + pCurrentSelection[0].Name = getDatabaseName(); switch ( eType ) { - case E_TABLE: aCurrentSelection[0].Type = DatabaseObjectContainer::TABLES; break; - case E_QUERY: aCurrentSelection[0].Type = DatabaseObjectContainer::QUERIES; break; - case E_FORM: aCurrentSelection[0].Type = DatabaseObjectContainer::FORMS; break; - case E_REPORT: aCurrentSelection[0].Type = DatabaseObjectContainer::REPORTS; break; + case E_TABLE: pCurrentSelection[0].Type = DatabaseObjectContainer::TABLES; break; + case E_QUERY: pCurrentSelection[0].Type = DatabaseObjectContainer::QUERIES; break; + case E_FORM: pCurrentSelection[0].Type = DatabaseObjectContainer::FORMS; break; + case E_REPORT: pCurrentSelection[0].Type = DatabaseObjectContainer::REPORTS; break; default: OSL_FAIL( "OApplicationController::getSelection: unexpected current element type!" ); break; } } } - return makeAny( aCurrentSelection ); + return Any( aCurrentSelection ); } } // namespace dbaui |