diff options
Diffstat (limited to 'dbaccess/source/ui/app/AppController.cxx')
-rw-r--r-- | dbaccess/source/ui/app/AppController.cxx | 86 |
1 files changed, 44 insertions, 42 deletions
diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx index 96e23f041d6d..fbe2c395633f 100644 --- a/dbaccess/source/ui/app/AppController.cxx +++ b/dbaccess/source/ui/app/AppController.cxx @@ -55,7 +55,7 @@ #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> @@ -252,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 ) @@ -327,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; } @@ -348,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() ); @@ -357,12 +362,13 @@ void SAL_CALL OApplicationController::disposing() if ( pFilter ) aFilter = pFilter->GetFilterName(); + OUString sDatabaseName; // add to svtool history options 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 ) @@ -499,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>()); @@ -793,18 +800,18 @@ 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: aReturn.bEnabled = false; @@ -907,8 +914,7 @@ 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 ) ); @@ -1027,7 +1033,7 @@ void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyVa { if ( pIter->Name == "FormatStringId" ) { - sal_uLong nTmp; + sal_uInt32 nTmp; if ( pIter->Value >>= nTmp ) pasteFormat(static_cast<SotClipboardFormatId>(nTmp)); break; @@ -1213,7 +1219,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, aCreationArgs ); - onDocumentOpened( OUString(), E_QUERY, E_OPEN_DESIGN, xComponent, nullptr ); + onDocumentOpened( OUString(), E_QUERY, ElementOpenMode::Design, xComponent, nullptr ); } } break; @@ -1237,17 +1243,17 @@ 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 ); + doAction( _nId, ElementOpenMode::Normal ); break; case SID_DB_APP_CONVERTTOVIEW: - doAction( _nId, E_OPEN_NORMAL ); + doAction( _nId, ElementOpenMode::Normal ); break; case SID_SELECTALL: getContainer()->selectAll(); @@ -1256,7 +1262,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() ) @@ -1265,7 +1271,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 ); } } } @@ -1319,15 +1325,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: @@ -1338,7 +1344,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; } } @@ -1703,7 +1709,7 @@ bool OApplicationController::onEntryDoubleClick(const weld::TreeView& rTreeView) openElementWithArguments( getContainer()->getQualifiedName(xHdlEntry.get()), getContainer()->getElementType(), - E_OPEN_NORMAL, + ElementOpenMode::Normal, 0, ::comphelper::NamedValueCollection() ); return true; // handled @@ -1749,7 +1755,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); @@ -1759,7 +1765,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. @@ -1796,7 +1802,7 @@ Reference< XComponent > OApplicationController::openElementWithArguments( const ::comphelper::NamedValueCollection aArguments( _rAdditionalArguments ); Any aDataSource; - if ( _eOpenMode == E_OPEN_DESIGN ) + if ( _eOpenMode == ElementOpenMode::Design ) { bool bAddViewTypeArg = false; @@ -1831,7 +1837,7 @@ Reference< XComponent > OApplicationController::openElementWithArguments( const pDesigner.reset( new ResultSetBrowser( getORB(), this, m_aCurrentFrame.getFrame(), _eType == E_TABLE ) ); if ( !aArguments.has( PROPERTY_SHOWMENU ) ) - aArguments.put( PROPERTY_SHOWMENU, makeAny( true ) ); + aArguments.put( PROPERTY_SHOWMENU, Any( true ) ); aDataSource <<= getDatabaseName(); } @@ -1956,7 +1962,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; } @@ -2155,7 +2161,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(); @@ -2266,7 +2272,7 @@ Any OApplicationController::getCurrentSelection(weld::TreeView& rControl) const { Sequence< NamedDatabaseObject > aSelection; getContainer()->describeCurrentSelectionForControl(rControl, aSelection); - return makeAny( aSelection ); + return Any( aSelection ); } vcl::Window* OApplicationController::getMenuParent() const @@ -2514,8 +2520,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 @@ -2523,13 +2528,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(), "", nullptr, Any( aWarning ) ); xDialog->execute(); } catch( const Exception& ) @@ -2568,7 +2570,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 @@ -2829,7 +2831,7 @@ Any SAL_CALL OApplicationController::getSelection( ) } } } - return makeAny( aCurrentSelection ); + return Any( aCurrentSelection ); } } // namespace dbaui |