dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx |    6 +++-
 dbaccess/source/ui/dlg/dbwizsetup.cxx             |    3 ++
 dbaccess/source/ui/dlg/generalpage.cxx            |   32 ++++++++++------------
 3 files changed, 23 insertions(+), 18 deletions(-)

New commits:
commit 8e0bb9dadb9ef77f693cf6d334843cfb9b4701a3
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Tue Mar 19 11:47:14 2024 +0500
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Thu Mar 28 06:37:08 2024 +0100

    tdf#103068: make sure to update and use current MySQL connection type
    
    1. Don't set selection in OGeneralPageWizard::getEmbeddedDBName. The
    method should only provide a name of an embedded database - either in
    the passed set, or the default one; the activation of controls and
    related actions will be done in the calling implInitControls. This
    makes sure, that ODbTypeWizDialogSetup::m_sURL doesn't get rewritten
    unnecessarily, keeping the current preference intact.
    
    2. In ODbTypeWizDialogSetup::activateDatabasePath, do not use the
    hardcoded MySQL URL from the control, if the current value of m_sURL
    is already a MySQL one. This allows to keep the selected kind intact.
    
    3. In OMySQLIntroPageSetup::implInitControls, do not assume that the
    existing selection means that there's nothing to do. The page keeps
    the selection, even when the wizard's active path was changed; and
    so, the wizard's idea which page to show next may differ from the
    selection. Just make sure to update the setup mode.
    
    Change-Id: Iad98d54a615dccc58b2852a1c0d8aefad6b0b898
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164987
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    (cherry picked from commit 1e66905c840dbee0a67e444fca80bdacfcb6e6b2)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165000
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx 
b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx
index 22cdefdd6c31..ad81680ba421 100644
--- a/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx
+++ b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx
@@ -239,9 +239,13 @@ using namespace ::com::sun::star;
         if ( bHasMySQLNative )
             m_xNATIVEDatabase->show();
 
-        // if any of the options is checked, then there's nothing to do
+        // tdf#103068: if any of the options is checked, then just update the 
selected kind:
+        // it could happen that the selection and the wizard path are not in 
sync
         if ( m_xODBCDatabase->get_active() || m_xJDBCDatabase->get_active() || 
m_xNATIVEDatabase->get_active() )
+        {
+            maClickHdl.Call(this);
             return;
+        }
 
         // prefer "native" or "JDBC"
         if ( bHasMySQLNative )
diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx 
b/dbaccess/source/ui/dlg/dbwizsetup.cxx
index 720892e2a015..2fb260e18e75 100644
--- a/dbaccess/source/ui/dlg/dbwizsetup.cxx
+++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx
@@ -312,6 +312,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)
diff --git a/dbaccess/source/ui/dlg/generalpage.cxx 
b/dbaccess/source/ui/dlg/generalpage.cxx
index a2a48158c56d..bb308845528e 100644
--- a/dbaccess/source/ui/dlg/generalpage.cxx
+++ b/dbaccess/source/ui/dlg/generalpage.cxx
@@ -226,31 +226,29 @@ namespace dbaui
 
     OUString OGeneralPageWizard::getEmbeddedDBName( const SfxItemSet& _rSet )
     {
+        if (!m_pCollection)
+            return {};
         // first check whether or not the selection is invalid or readonly 
(invalid implies readonly, but not vice versa)
         bool bValid, bReadonly;
         getFlags( _rSet, bValid, bReadonly );
-
-        // if the selection is invalid, disable everything
-
-        implSetCurrentType(  OUString() );
+        if (!bValid)
+            return {};
 
         // compare the DSN prefix with the registered ones
-        OUString sDisplayName;
-
-        if (m_pCollection && bValid)
-        {
-            implSetCurrentType( 
dbaccess::ODsnTypeCollection::getEmbeddedDatabase() );
-            sDisplayName = m_pCollection->getTypeDisplayName( 
m_eCurrentSelection );
-            onTypeSelected(m_eCurrentSelection);
-        }
-
-        // select the correct datasource type
-        if  (  dbaccess::ODsnTypeCollection::isEmbeddedDatabase( 
m_eCurrentSelection )
-            && m_xEmbeddedDBType->find_text(sDisplayName) == -1 )
+        OUString sDBURL;
+        if (const SfxStringItem* pUrlItem = 
_rSet.GetItem<SfxStringItem>(DSID_CONNECTURL))
+            if 
(dbaccess::ODsnTypeCollection::isEmbeddedDatabase(pUrlItem->GetValue()))
+                sDBURL = pUrlItem->GetValue();
+        if (sDBURL.isEmpty())
+            sDBURL = dbaccess::ODsnTypeCollection::getEmbeddedDatabase();
+        OUString sDisplayName = m_pCollection->getTypeDisplayName(sDBURL);
+
+        // ensure presence of the correct datasource type
+        if (!sDisplayName.isEmpty() && 
m_xEmbeddedDBType->find_text(sDisplayName) == -1)
         {   // this indicates it's really a type which is known in general, 
but not supported on the current platform
             // show a message saying so
             //  eSpecialMessage = smUnsupportedType;
-            insertEmbeddedDBTypeEntryData( m_eCurrentSelection, sDisplayName );
+            insertEmbeddedDBTypeEntryData(sDBURL, sDisplayName);
         }
 
         return sDisplayName;

Reply via email to