diff options
Diffstat (limited to 'dbaccess/source/ui/dlg/dbwizsetup.cxx')
-rw-r--r-- | dbaccess/source/ui/dlg/dbwizsetup.cxx | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx b/dbaccess/source/ui/dlg/dbwizsetup.cxx index 88fd1151bfef..9b9e05dbc317 100644 --- a/dbaccess/source/ui/dlg/dbwizsetup.cxx +++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx @@ -43,7 +43,6 @@ #include <cppuhelper/implbase.hxx> #include <com/sun/star/frame/TerminationVetoException.hpp> #include <com/sun/star/frame/XStorable.hpp> -#include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/sdb/DatabaseContext.hpp> #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/frame/FrameSearchFlag.hpp> @@ -61,9 +60,10 @@ #include <comphelper/interaction.hxx> #include <comphelper/namedvaluecollection.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <osl/diagnose.h> #include <connectivity/DriversConfig.hxx> +#include <utility> namespace dbaui { @@ -72,7 +72,6 @@ using namespace vcl; using namespace com::sun::star; using namespace com::sun::star::uno; using namespace com::sun::star::sdbc; -using namespace com::sun::star::sdbcx; using namespace com::sun::star::task; using namespace com::sun::star::lang; using namespace com::sun::star::io; @@ -106,6 +105,7 @@ ODbTypeWizDialogSetup::ODbTypeWizDialogSetup(weld::Window* _pParent , m_sRM_JDBCText( DBA_RES( STR_PAGETITLE_JDBC ) ) , m_sRM_MySQLNativePageTitle( DBA_RES( STR_PAGETITLE_MYSQL_NATIVE ) ) , m_sRM_OracleText( DBA_RES( STR_PAGETITLE_ORACLE ) ) + , m_sRM_PostgresText( DBA_RES( STR_PAGETITLE_POSTGRES ) ) , m_sRM_MySQLText( DBA_RES( STR_PAGETITLE_MYSQL ) ) , m_sRM_ODBCText( DBA_RES( STR_PAGETITLE_ODBC ) ) , m_sRM_DocumentOrSpreadSheetText( DBA_RES( STR_PAGETITLE_DOCUMENT_OR_SPREADSHEET ) ) @@ -115,15 +115,14 @@ ODbTypeWizDialogSetup::ODbTypeWizDialogSetup(weld::Window* _pParent , m_pGeneralPage( nullptr ) , m_pMySQLIntroPage( nullptr ) , m_pFinalPage( nullptr ) - , m_pCollection( nullptr ) { // no local resources needed anymore // extract the datasource type collection from the item set - const DbuTypeCollectionItem* pCollectionItem = dynamic_cast<const DbuTypeCollectionItem*>( _pItems->GetItem(DSID_TYPECOLLECTION) ); - if (pCollectionItem) - m_pCollection = pCollectionItem->getCollection(); + const DbuTypeCollectionItem* pCollectionItem = dynamic_cast<const DbuTypeCollectionItem*>(_pItems->GetItem(DSID_TYPECOLLECTION)); + assert(pCollectionItem && "must exist"); + m_pCollection = pCollectionItem->getCollection(); - OSL_ENSURE(m_pCollection, "ODbTypeWizDialogSetup::ODbTypeWizDialogSetup : really need a DSN type collection !"); + assert(m_pCollection && "ODbTypeWizDialogSetup::ODbTypeWizDialogSetup : really need a DSN type collection !"); m_pImpl.reset(new ODbDataSourceAdministrationHelper(_rxORB, m_xAssistant.get(), _pParent, this)); m_pImpl->setDataSourceOrName(_aDataSourceName); @@ -154,10 +153,14 @@ ODbTypeWizDialogSetup::ODbTypeWizDialogSetup(weld::Window* _pParent aPath.push_back(PAGE_DBSETUPWIZARD_INTRO); declarePath( static_cast<PathId>(m_pCollection->size()+1), aPath); + // Set general help ID for the roadmap + SetRoadmapHelpId(HID_DBWIZ_ROADMAP); + m_xPrevPage->set_help_id(HID_DBWIZ_PREVIOUS); m_xNextPage->set_help_id(HID_DBWIZ_NEXT); m_xCancel->set_help_id(HID_DBWIZ_CANCEL); m_xFinish->set_help_id(HID_DBWIZ_FINISH); + m_xHelp->set_help_id(HID_DBWIZ_HELP); ActivatePage(); setTitleBase(DBA_RES(STR_DBWIZARDTITLE)); m_xAssistant->set_current_page(0); @@ -210,6 +213,9 @@ OUString ODbTypeWizDialogSetup::getStateDisplayName(WizardState _nState) const case PAGE_DBSETUPWIZARD_ORACLE: sRoadmapItem = m_sRM_OracleText; break; + case PAGE_DBSETUPWIZARD_POSTGRES: + sRoadmapItem = m_sRM_PostgresText; + break; case PAGE_DBSETUPWIZARD_MYSQL_INTRO: sRoadmapItem = m_sRM_MySQLText; break; @@ -255,19 +261,12 @@ IMPL_LINK_NOARG(ODbTypeWizDialogSetup, OnTypeSelected, OGeneralPage&, void) static void lcl_removeUnused(const ::comphelper::NamedValueCollection& _aOld,const ::comphelper::NamedValueCollection& _aNew,::comphelper::NamedValueCollection& _rDSInfo) { _rDSInfo.merge(_aNew,true); - uno::Sequence< beans::NamedValue > aOldValues = _aOld.getNamedValues(); - const beans::NamedValue* pIter = aOldValues.getConstArray(); - const beans::NamedValue* pEnd = pIter + aOldValues.getLength(); - for(;pIter != pEnd;++pIter) - { - if ( !_aNew.has(pIter->Name) ) - { - _rDSInfo.remove(pIter->Name); - } - } + for (auto& val : _aOld.getNamedValues()) + if (!_aNew.has(val.Name)) + _rDSInfo.remove(val.Name); } -void DataSourceInfoConverter::convert(const Reference<XComponentContext> & xContext, const ::dbaccess::ODsnTypeCollection* _pCollection,const OUString& _sOldURLPrefix,const OUString& _sNewURLPrefix,const css::uno::Reference< css::beans::XPropertySet >& _xDatasource) +void DataSourceInfoConverter::convert(const Reference<XComponentContext> & xContext, const ::dbaccess::ODsnTypeCollection* _pCollection, std::u16string_view _sOldURLPrefix, std::u16string_view _sNewURLPrefix,const css::uno::Reference< css::beans::XPropertySet >& _xDatasource) { if ( _pCollection->getPrefix(_sOldURLPrefix) == _pCollection->getPrefix(_sNewURLPrefix) ) return ; @@ -282,7 +281,7 @@ void DataSourceInfoConverter::convert(const Reference<XComponentContext> & xCont lcl_removeUnused(aOldProperties,aNewProperties,aDS); aDS >>= aInfo; - _xDatasource->setPropertyValue(PROPERTY_INFO,uno::makeAny(aInfo)); + _xDatasource->setPropertyValue(PROPERTY_INFO,uno::Any(aInfo)); } void ODbTypeWizDialogSetup::activateDatabasePath() @@ -305,6 +304,9 @@ void ODbTypeWizDialogSetup::activateDatabasePath() { OUString sOld = m_sURL; m_sURL = m_pGeneralPage->GetSelectedType(); + if (m_sURL.startsWith("sdbc:mysql:") && sOld.startsWith("sdbc:mysql:")) + m_sURL = sOld; // The type of MySQL connection was already set elsewhere; just use it, + // instead of the hardcoded one from the selector DataSourceInfoConverter::convert(getORB(), m_pCollection,sOld,m_sURL,m_pImpl->getCurrentDataSource()); ::dbaccess::DATASOURCE_TYPE eType = VerifyDataSourceType(m_pCollection->determineType(m_sURL)); if (eType == ::dbaccess::DST_UNKNOWN) @@ -457,7 +459,7 @@ std::unique_ptr<BuilderPage> ODbTypeWizDialogSetup::createPage(WizardState _nSta { std::unique_ptr<OGenericAdministrationPage> xPage; - OString sIdent(OString::number(_nState)); + OUString sIdent(OUString::number(_nState)); weld::Container* pPageContainer = m_xAssistant->append_page(sIdent); switch(_nState) @@ -487,16 +489,16 @@ std::unique_ptr<BuilderPage> ODbTypeWizDialogSetup::createPage(WizardState _nSta break; case PAGE_DBSETUPWIZARD_MYSQL_ODBC: - m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getPrefix("sdbc:mysql:odbc:"))); + m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getPrefix(u"sdbc:mysql:odbc:"))); xPage = OConnectionTabPageSetup::CreateODBCTabPage(pPageContainer, this, *m_pOutSet); break; case PAGE_DBSETUPWIZARD_MYSQL_JDBC: - m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getPrefix("sdbc:mysql:jdbc:"))); + m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getPrefix(u"sdbc:mysql:jdbc:"))); xPage = OGeneralSpecialJDBCConnectionPageSetup::CreateMySQLJDBCTabPage(pPageContainer, this, *m_pOutSet); break; case PAGE_DBSETUPWIZARD_MYSQL_NATIVE: - m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getPrefix("sdbc:mysql:mysqlc:"))); + m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getPrefix(u"sdbc:mysql:mysqlc:"))); xPage = MySQLNativeSetupPage::Create(pPageContainer, this, *m_pOutSet); break; @@ -504,6 +506,10 @@ std::unique_ptr<BuilderPage> ODbTypeWizDialogSetup::createPage(WizardState _nSta xPage = OGeneralSpecialJDBCConnectionPageSetup::CreateOracleJDBCTabPage(pPageContainer, this, *m_pOutSet); break; + case PAGE_DBSETUPWIZARD_POSTGRES: + xPage = OPostgresConnectionPageSetup::CreatePostgresTabPage(pPageContainer, this, *m_pOutSet); + break; + case PAGE_DBSETUPWIZARD_LDAP: xPage = OLDAPConnectionPageSetup::CreateLDAPTabPage(pPageContainer, this, *m_pOutSet); break; @@ -646,12 +652,11 @@ namespace { bool lcl_handle( const Reference< XInteractionHandler2 >& _rxHandler, const Any& _rRequest ) { - OInteractionRequest* pRequest = new OInteractionRequest( _rRequest ); - Reference < XInteractionRequest > xRequest( pRequest ); - OInteractionAbort* pAbort = new OInteractionAbort; + rtl::Reference<OInteractionRequest> pRequest = new OInteractionRequest( _rRequest ); + rtl::Reference<OInteractionAbort> pAbort = new OInteractionAbort; pRequest->addContinuation( pAbort ); - return _rxHandler->handleInteractionRequest( xRequest ); + return _rxHandler->handleInteractionRequest( pRequest ); } } @@ -671,10 +676,10 @@ bool ODbTypeWizDialogSetup::SaveDatabaseDocument() CreateDatabase(); ::comphelper::NamedValueCollection aArgs( xModel->getArgs() ); - aArgs.put( "Overwrite", true ); - aArgs.put( "InteractionHandler", xHandler ); - aArgs.put( "MacroExecutionMode", MacroExecMode::USE_CONFIG ); - aArgs.put( "IgnoreFirebirdMigration", true ); + aArgs.put( u"Overwrite"_ustr, true ); + aArgs.put( u"InteractionHandler"_ustr, xHandler ); + aArgs.put( u"MacroExecutionMode"_ustr, MacroExecMode::USE_CONFIG ); + aArgs.put( u"IgnoreFirebirdMigration"_ustr, true ); OUString sPath = ODbDataSourceAdministrationHelper::getDocumentUrl( *m_pOutSet ); xStore->storeAsURL( sPath, aArgs.getPropertyValues() ); @@ -692,16 +697,13 @@ bool ODbTypeWizDialogSetup::SaveDatabaseDocument() { if ( !lcl_handle( xHandler, aError ) ) { - InteractiveIOException aRequest; - aRequest.Classification = InteractionClassification_ERROR; - if ( aError.isExtractableTo( ::cppu::UnoType< IOException >::get() ) ) - // assume saving the document failed - aRequest.Code = IOErrorCode_CANT_WRITE; - else - aRequest.Code = IOErrorCode_GENERAL; - aRequest.Message = e.Message; - aRequest.Context = e.Context; - lcl_handle( xHandler, makeAny( aRequest ) ); + css::ucb::IOErrorCode code + = aError.isExtractableTo(::cppu::UnoType<IOException>::get()) + ? IOErrorCode_CANT_WRITE // assume saving the document failed + : IOErrorCode_GENERAL; + InteractiveIOException aRequest(e.Message, e.Context, + InteractionClassification_ERROR, code); + lcl_handle( xHandler, Any( aRequest ) ); } } } @@ -740,7 +742,7 @@ bool ODbTypeWizDialogSetup::SaveDatabaseDocument() Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource(); OSL_ENSURE(xDatasource.is(),"DataSource is null!"); if ( xDatasource.is() ) - xDatasource->setPropertyValue( PROPERTY_INFO, makeAny( m_pCollection->getDefaultDBSettings( eType ) ) ); + xDatasource->setPropertyValue( PROPERTY_INFO, Any( m_pCollection->getDefaultDBSettings( eType ) ) ); m_pImpl->translateProperties(xDatasource,*m_pOutSet); } else if ( m_pCollection->isFileSystemBased(eType) ) @@ -757,7 +759,7 @@ bool ODbTypeWizDialogSetup::SaveDatabaseDocument() m_pImpl->saveChanges(*m_pOutSet); } - void ODbTypeWizDialogSetup::RegisterDataSourceByLocation(const OUString& _sPath) + void ODbTypeWizDialogSetup::RegisterDataSourceByLocation(std::u16string_view _sPath) { Reference< XPropertySet > xDatasource = m_pImpl->getCurrentDataSource(); Reference< XDatabaseContext > xDatabaseContext( DatabaseContext::create(getORB()) ); @@ -773,15 +775,14 @@ bool ODbTypeWizDialogSetup::SaveDatabaseDocument() ::sfx2::FileDialogHelper aFileDlg( ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION, FileDialogFlags::NONE, m_xAssistant.get()); + aFileDlg.SetContext(sfx2::FileDialogHelper::BaseSaveAs); std::shared_ptr<const SfxFilter> pFilter = getStandardDatabaseFilter(); if ( pFilter ) { - INetURLObject aWorkURL( m_sWorkPath ); - aFileDlg.SetDisplayFolder( aWorkURL.GetMainURL( INetURLObject::DecodeMechanism::NONE )); - OUString sDefaultName = DBA_RES( STR_DATABASEDEFAULTNAME ); OUString sExtension = pFilter->GetDefaultExtension(); - sDefaultName += sExtension.replaceAt( 0, 1, OUString() ); + sDefaultName += sExtension.replaceAt( 0, 1, u"" ); + INetURLObject aWorkURL( m_sWorkPath ); aWorkURL.Append( sDefaultName ); sDefaultName = createUniqueFileName( aWorkURL ); aFileDlg.SetFileName( sDefaultName ); @@ -817,7 +818,7 @@ bool ODbTypeWizDialogSetup::SaveDatabaseDocument() if (bFolderExists) { i++; - pURL->setName(sLastSegmentName + OUString::number(i)); + pURL->setName(Concat2View(sLastSegmentName + OUString::number(i))); } } } @@ -835,7 +836,7 @@ bool ODbTypeWizDialogSetup::SaveDatabaseDocument() bElementExists = xSimpleFileAccess->exists( aExistenceCheck.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ); if ( bElementExists ) { - aExistenceCheck.setBase( BaseName + OUString::number( i ) ); + aExistenceCheck.setBase( Concat2View(BaseName + OUString::number( i ) )); ++i; } } @@ -862,7 +863,7 @@ bool ODbTypeWizDialogSetup::SaveDatabaseDocument() OAsynchronousLink m_aAsyncCaller; public: - AsyncLoader( const Reference< XComponentContext >& _rxORB, const OUString& _rURL ); + AsyncLoader( const Reference< XComponentContext >& _xORB, OUString _aURL ); void doLoadAsync(); @@ -876,8 +877,8 @@ bool ODbTypeWizDialogSetup::SaveDatabaseDocument() DECL_LINK( OnOpenDocument, void*, void ); }; - AsyncLoader::AsyncLoader( const Reference< XComponentContext >& _rxORB, const OUString& _rURL ) - :m_sURL( _rURL ) + AsyncLoader::AsyncLoader( const Reference< XComponentContext >& _rxORB, OUString _aURL ) + :m_sURL(std::move( _aURL )) ,m_aAsyncCaller( LINK( this, AsyncLoader, OnOpenDocument ) ) { try @@ -914,14 +915,14 @@ bool ODbTypeWizDialogSetup::SaveDatabaseDocument() if ( m_xFrameLoader.is() ) { ::comphelper::NamedValueCollection aLoadArgs; - aLoadArgs.put( "InteractionHandler", m_xInteractionHandler ); - aLoadArgs.put( "MacroExecutionMode", MacroExecMode::USE_CONFIG ); + aLoadArgs.put( u"InteractionHandler"_ustr, m_xInteractionHandler ); + aLoadArgs.put( u"MacroExecutionMode"_ustr, MacroExecMode::USE_CONFIG ); Sequence< PropertyValue > aLoadArgPV; aLoadArgs >>= aLoadArgPV; m_xFrameLoader->loadComponentFromURL( m_sURL, - "_default", + u"_default"_ustr, FrameSearchFlag::ALL, aLoadArgPV ); @@ -969,8 +970,7 @@ bool ODbTypeWizDialogSetup::SaveDatabaseDocument() try { - AsyncLoader* pAsyncLoader = new AsyncLoader( getORB(), m_pGeneralPage->GetSelectedDocumentURL() ); - ::rtl::Reference< AsyncLoader > xKeepAlive( pAsyncLoader ); + rtl::Reference<AsyncLoader> pAsyncLoader = new AsyncLoader( getORB(), m_pGeneralPage->GetSelectedDocumentURL() ); pAsyncLoader->doLoadAsync(); } catch( const Exception& ) |