[Libreoffice-commits] core.git: sw/inc sw/source

Mike Kaganski mike.kaganski at collabora.com
Mon Nov 20 14:41:17 UTC 2017


 sw/inc/dbmgr.hxx                |   23 --
 sw/source/uibase/dbui/dbmgr.cxx |  314 +++++++++++++++++++++++-----------------
 2 files changed, 186 insertions(+), 151 deletions(-)

New commits:
commit 1560a335f7d548fb9eed564e8d2da03c2ef84b7a
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Mon Nov 20 11:47:37 2017 +0200

    SwDBManager: move implementation details from interface
    
    Change-Id: I738e8306f2f9af7f284cc236d55f5e184e632323
    Reviewed-on: https://gerrit.libreoffice.org/44951
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx
index eeac93d8f793..098e1a26f7f7 100644
--- a/sw/inc/dbmgr.hxx
+++ b/sw/inc/dbmgr.hxx
@@ -293,17 +293,6 @@ public:
     SwDBManager(SwDoc* pDoc);
     ~SwDBManager() COVERITY_NOEXCEPT_FALSE;
 
-    enum DBConnURITypes {
-        DBCONN_UNKNOWN = 0,
-        DBCONN_ODB,
-        DBCONN_CALC,
-        DBCONN_DBASE,
-        DBCONN_FLAT,
-        DBCONN_MSJET,
-        DBCONN_MSACE,
-        DBCONN_WRITER
-    };
-
     /// MailMergeEvent source
     const SwXMailMerge *    GetMailMergeEvtSrc() const  { return pMergeEvtSrc; }
     void SetMailMergeEvtSrc( const SwXMailMerge *pSrc ) { pMergeEvtSrc = pSrc; }
@@ -406,8 +395,6 @@ public:
 
     static css::uno::Sequence<OUString> GetExistingDatabaseNames();
 
-    static DBConnURITypes GetDBunoURI(const OUString &rURI, css::uno::Any &aURLAny);
-
     /**
      Loads a data source from file and registers it.
 
@@ -420,16 +407,6 @@ public:
     /**
      Loads a data source from file and registers it.
 
-     In case of success it returns the registered name, otherwise an empty string.
-     Optionally add a prefix to the registered DB name.
-     */
-    static OUString            LoadAndRegisterDataSource(const DBConnURITypes type, const css::uno::Any &rUnoURI,
-                                                         const css::uno::Reference < css::beans::XPropertySet > *pSettings,
-                                                         const OUString &rURI, const OUString *pPrefix, const OUString *pDestDir,
-                                                         SwDocShell* pDocShell = nullptr);
-    /**
-     Loads a data source from file and registers it.
-
      Convenience function, which calls GetDBunoURI and has just one mandatory parameter.
      In case of success it returns the registered name, otherwise an empty string.
      */
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 93aee382e4ad..5132a0b75e3b 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -2555,136 +2555,129 @@ uno::Sequence<OUString> SwDBManager::GetExistingDatabaseNames()
     return xDBContext->getElementNames();
 }
 
-OUString SwDBManager::LoadAndRegisterDataSource(const vcl::Window* pParent, SwDocShell* pDocShell)
-{
-    sfx2::FileDialogHelper aDlgHelper(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::NONE, pParent);
-    uno::Reference < ui::dialogs::XFilePicker3 > xFP = aDlgHelper.GetFilePicker();
-
-    OUString sHomePath(SvtPathOptions().GetWorkPath());
-    aDlgHelper.SetDisplayDirectory( sHomePath );
-
-    uno::Reference<ui::dialogs::XFilterManager> xFltMgr(xFP, uno::UNO_QUERY);
+namespace {
+enum class DBConnURIType {
+    UNKNOWN = 0,
+    ODB,
+    CALC,
+    DBASE,
+    FLAT,
+    MSJET,
+    MSACE,
+    WRITER
+};
 
-    OUString sFilterAll(SwResId(STR_FILTER_ALL));
-    OUString sFilterAllData(SwResId(STR_FILTER_ALL_DATA));
-    OUString sFilterSXB(SwResId(STR_FILTER_SXB));
-    OUString sFilterSXC(SwResId(STR_FILTER_SXC));
-    OUString sFilterSXW(SwResId(STR_FILTER_SXW));
-    OUString sFilterDBF(SwResId(STR_FILTER_DBF));
-    OUString sFilterXLS(SwResId(STR_FILTER_XLS));
-    OUString sFilterDOC(SwResId(STR_FILTER_DOC));
-    OUString sFilterTXT(SwResId(STR_FILTER_TXT));
-    OUString sFilterCSV(SwResId(STR_FILTER_CSV));
-#ifdef _WIN32
-    OUString sFilterMDB(SwResId(STR_FILTER_MDB));
-    OUString sFilterACCDB(SwResId(STR_FILTER_ACCDB));
-#endif
-    xFltMgr->appendFilter( sFilterAll, "*" );
-    xFltMgr->appendFilter( sFilterAllData, "*.ods;*.sxc;*.odt;*.sxw;*.dbf;*.xls;*.xlsx;*.doc;*.docx;*.txt;*.csv");
+DBConnURIType GetDBunoType(const INetURLObject &rURL)
+{
+    OUString sExt(rURL.GetExtension());
+    DBConnURIType type = DBConnURIType::UNKNOWN;
 
-    xFltMgr->appendFilter( sFilterSXB, "*.odb" );
-    xFltMgr->appendFilter( sFilterSXC, "*.ods;*.sxc" );
-    xFltMgr->appendFilter( sFilterSXW, "*.odt;*.sxw" );
-    xFltMgr->appendFilter( sFilterDBF, "*.dbf" );
-    xFltMgr->appendFilter( sFilterXLS, "*.xls;*.xlsx" );
-    xFltMgr->appendFilter( sFilterDOC, "*.doc;*.docx" );
-    xFltMgr->appendFilter( sFilterTXT, "*.txt" );
-    xFltMgr->appendFilter( sFilterCSV, "*.csv" );
+    if (sExt == "odb")
+    {
+        type = DBConnURIType::ODB;
+    }
+    else if (sExt.equalsIgnoreAsciiCase("sxc")
+        || sExt.equalsIgnoreAsciiCase("ods")
+        || sExt.equalsIgnoreAsciiCase("xls")
+        || sExt.equalsIgnoreAsciiCase("xlsx"))
+    {
+        type = DBConnURIType::CALC;
+    }
+    else if (sExt.equalsIgnoreAsciiCase("sxw") || sExt.equalsIgnoreAsciiCase("odt") || sExt.equalsIgnoreAsciiCase("doc") || sExt.equalsIgnoreAsciiCase("docx"))
+    {
+        type = DBConnURIType::WRITER;
+    }
+    else if (sExt.equalsIgnoreAsciiCase("dbf"))
+    {
+        type = DBConnURIType::DBASE;
+    }
+    else if (sExt.equalsIgnoreAsciiCase("csv") || sExt.equalsIgnoreAsciiCase("txt"))
+    {
+        type = DBConnURIType::FLAT;
+    }
 #ifdef _WIN32
-    xFltMgr->appendFilter(sFilterMDB, "*.mdb;*.mde");
-    xFltMgr->appendFilter(sFilterACCDB, "*.accdb;*.accde");
-#endif
-
-    xFltMgr->setCurrentFilter( sFilterAll ) ;
-    OUString sFind;
-    if( ERRCODE_NONE == aDlgHelper.Execute() )
+    else if (sExt.equalsIgnoreAsciiCase("mdb") || sExt.equalsIgnoreAsciiCase("mde"))
     {
-        uno::Any aURLAny;
-        uno::Reference< beans::XPropertySet > aSettings;
-        const OUString aURI( xFP->getSelectedFiles().getConstArray()[0] );
-        const DBConnURITypes type = GetDBunoURI( aURI, aURLAny );
-
-        if( DBCONN_FLAT == type )
-        {
-            uno::Reference<uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
-            uno::Reference < sdb::XTextConnectionSettings > xSettingsDlg = sdb::TextConnectionSettings::create(xContext);
-            if( xSettingsDlg->execute() )
-                aSettings.set( uno::Reference < beans::XPropertySet >( xSettingsDlg, uno::UNO_QUERY_THROW ) );
-        }
-        sFind = LoadAndRegisterDataSource( type, aURLAny, DBCONN_FLAT == type ? &aSettings : nullptr, aURI, nullptr, nullptr, pDocShell );
-
-        m_aUncommitedRegistrations.push_back(std::pair<SwDocShell*, OUString>(pDocShell, sFind));
+        type = DBConnURIType::MSJET;
     }
-    return sFind;
+    else if (sExt.equalsIgnoreAsciiCase("accdb") || sExt.equalsIgnoreAsciiCase("accde"))
+    {
+        type = DBConnURIType::MSACE;
+    }
+#endif
+    return type;
 }
 
-SwDBManager::DBConnURITypes SwDBManager::GetDBunoURI(const OUString &rURI, uno::Any &aURLAny)
+uno::Any GetDBunoURI(const INetURLObject &rURL, DBConnURIType& rType)
 {
-    INetURLObject aURL( rURI );
-    OUString sExt( aURL.GetExtension() );
-    DBConnURITypes type = DBCONN_UNKNOWN;
+    uno::Any aURLAny;
 
-    if(sExt == "odb")
-    {
-        type = DBCONN_ODB;
-    }
-    else if(sExt.equalsIgnoreAsciiCase("sxc")
-        || sExt.equalsIgnoreAsciiCase("ods")
-            || sExt.equalsIgnoreAsciiCase("xls")
-            || sExt.equalsIgnoreAsciiCase("xlsx"))
+    if (rType == DBConnURIType::UNKNOWN)
+        rType = GetDBunoType(rURL);
+
+    switch (rType) {
+    case DBConnURIType::UNKNOWN:
+    case DBConnURIType::ODB:
+        break;
+    case DBConnURIType::CALC:
     {
         OUString sDBURL("sdbc:calc:");
-        sDBURL += aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE);
+        sDBURL += rURL.GetMainURL(INetURLObject::DecodeMechanism::NONE);
         aURLAny <<= sDBURL;
-        type = DBCONN_CALC;
     }
-    else if (sExt.equalsIgnoreAsciiCase("sxw") || sExt.equalsIgnoreAsciiCase("odt") || sExt.equalsIgnoreAsciiCase("doc") || sExt.equalsIgnoreAsciiCase("docx"))
+    break;
+    case DBConnURIType::WRITER:
     {
         OUString sDBURL("sdbc:writer:");
-        sDBURL += aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE);
+        sDBURL += rURL.GetMainURL(INetURLObject::DecodeMechanism::NONE);
         aURLAny <<= sDBURL;
-        type = DBCONN_WRITER;
     }
-    else if(sExt.equalsIgnoreAsciiCase("dbf"))
+    break;
+    case DBConnURIType::DBASE:
     {
-        aURL.removeSegment();
-        aURL.removeFinalSlash();
+        INetURLObject aUrlTmp(rURL);
+        aUrlTmp.removeSegment();
+        aUrlTmp.removeFinalSlash();
         OUString sDBURL("sdbc:dbase:");
-        sDBURL += aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE);
+        sDBURL += aUrlTmp.GetMainURL(INetURLObject::DecodeMechanism::NONE);
         aURLAny <<= sDBURL;
-        type = DBCONN_DBASE;
     }
-    else if(sExt.equalsIgnoreAsciiCase("csv") || sExt.equalsIgnoreAsciiCase("txt"))
+    break;
+    case DBConnURIType::FLAT:
     {
-        aURL.removeSegment();
-        aURL.removeFinalSlash();
+        INetURLObject aUrlTmp(rURL);
+        aUrlTmp.removeSegment();
+        aUrlTmp.removeFinalSlash();
         OUString sDBURL("sdbc:flat:");
         //only the 'path' has to be added
-        sDBURL += aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE);
+        sDBURL += aUrlTmp.GetMainURL(INetURLObject::DecodeMechanism::NONE);
         aURLAny <<= sDBURL;
-        type = DBCONN_FLAT;
     }
+    break;
+    case DBConnURIType::MSJET:
 #ifdef _WIN32
-    else if (sExt.equalsIgnoreAsciiCase("mdb") || sExt.equalsIgnoreAsciiCase("mde"))
     {
         OUString sDBURL("sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=");
-        sDBURL += aURL.PathToFileName();
+        sDBURL += rURL.PathToFileName();
         aURLAny <<= sDBURL;
-        type = DBCONN_MSJET;
     }
-    else if (sExt.equalsIgnoreAsciiCase("accdb") || sExt.equalsIgnoreAsciiCase("accde"))
+#endif
+    break;
+    case DBConnURIType::MSACE:
+#ifdef _WIN32
     {
         OUString sDBURL("sdbc:ado:PROVIDER=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=");
-        sDBURL += aURL.PathToFileName();
+        sDBURL += rURL.PathToFileName();
         aURLAny <<= sDBURL;
-        type = DBCONN_MSACE;
     }
 #endif
-    return type;
+    break;
+    }
+    return aURLAny;
 }
 
 /// Returns the URL of this SwDoc.
-OUString lcl_getOwnURL(SwDocShell const * pDocShell)
+OUString getOwnURL(SfxObjectShell const * pDocShell)
 {
     OUString aRet;
 
@@ -2696,11 +2689,16 @@ OUString lcl_getOwnURL(SwDocShell const * pDocShell)
     return aRet;
 }
 
-OUString SwDBManager::LoadAndRegisterDataSource(const DBConnURITypes type, const uno::Any &aURLAny, const uno::Reference< beans::XPropertySet > *pSettings,
-                                                const OUString &rURI, const OUString *pPrefix, const OUString *pDestDir, SwDocShell* pDocShell)
+/**
+Loads a data source from file and registers it.
+
+In case of success it returns the registered name, otherwise an empty string.
+Optionally add a prefix to the registered DB name.
+*/
+OUString LoadAndRegisterDataSource_Impl(DBConnURIType type, const uno::Reference< beans::XPropertySet > *pSettings,
+    const INetURLObject &rURL, const OUString *pPrefix, const OUString *pDestDir, SfxObjectShell* pDocShell)
 {
-    INetURLObject aURL( rURI );
-    OUString sExt( aURL.GetExtension() );
+    OUString sExt(rURL.GetExtension());
     uno::Any aTableFilterAny;
     uno::Any aSuppressVersionsAny;
     uno::Any aInfoAny;
@@ -2708,52 +2706,53 @@ OUString SwDBManager::LoadAndRegisterDataSource(const DBConnURITypes type, const
     OUString sFind;
     uno::Sequence<OUString> aFilters(1);
 
+    uno::Any aURLAny = GetDBunoURI(rURL, type);
     switch (type) {
-    case DBCONN_UNKNOWN:
-    case DBCONN_CALC:
-    case DBCONN_WRITER:
+    case DBConnURIType::UNKNOWN:
+    case DBConnURIType::CALC:
+    case DBConnURIType::WRITER:
         break;
-    case DBCONN_ODB:
+    case DBConnURIType::ODB:
         bStore = false;
         break;
-    case DBCONN_FLAT:
-    case DBCONN_DBASE:
+    case DBConnURIType::FLAT:
+    case DBConnURIType::DBASE:
         //set the filter to the file name without extension
-        aFilters[0] = aURL.getBase();
+        aFilters[0] = rURL.getBase();
         aTableFilterAny <<= aFilters;
         break;
-    case DBCONN_MSJET:
-    case DBCONN_MSACE:
+    case DBConnURIType::MSJET:
+    case DBConnURIType::MSACE:
         aSuppressVersionsAny <<= true;
         break;
     }
 
     try
     {
-        uno::Reference<uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
+        uno::Reference<uno::XComponentContext> xContext(::comphelper::getProcessComponentContext());
         uno::Reference<sdb::XDatabaseContext> xDBContext = sdb::DatabaseContext::create(xContext);
 
-        OUString sNewName = INetURLObject::decode( aURL.getName(),
-                                                 INetURLObject::DecodeMechanism::Unambiguous );
+        OUString sNewName = INetURLObject::decode(rURL.getName(),
+            INetURLObject::DecodeMechanism::Unambiguous);
         sal_Int32 nExtLen = sExt.getLength();
-        sNewName = sNewName.replaceAt( sNewName.getLength() - nExtLen - 1, nExtLen + 1, "" );
+        sNewName = sNewName.replaceAt(sNewName.getLength() - nExtLen - 1, nExtLen + 1, "");
         if (pPrefix)
             sNewName = *pPrefix + sNewName;
 
         //find a unique name if sNewName already exists
         sFind = sNewName;
         sal_Int32 nIndex = 0;
-        while(xDBContext->hasByName(sFind))
+        while (xDBContext->hasByName(sFind))
         {
             sFind = sNewName;
             sFind += OUString::number(++nIndex);
         }
 
         uno::Reference<uno::XInterface> xNewInstance;
-        if(!bStore)
+        if (!bStore)
         {
             //odb-file
-            uno::Any aDataSource = xDBContext->getByName(aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE));
+            uno::Any aDataSource = xDBContext->getByName(rURL.GetMainURL(INetURLObject::DecodeMechanism::NONE));
             aDataSource >>= xNewInstance;
         }
         else
@@ -2761,27 +2760,27 @@ OUString SwDBManager::LoadAndRegisterDataSource(const DBConnURITypes type, const
             xNewInstance = xDBContext->createInstance();
             uno::Reference<beans::XPropertySet> xDataProperties(xNewInstance, uno::UNO_QUERY);
 
-            if(aURLAny.hasValue())
+            if (aURLAny.hasValue())
                 xDataProperties->setPropertyValue("URL", aURLAny);
-            if(aTableFilterAny.hasValue())
+            if (aTableFilterAny.hasValue())
                 xDataProperties->setPropertyValue("TableFilter", aTableFilterAny);
-            if(aSuppressVersionsAny.hasValue())
+            if (aSuppressVersionsAny.hasValue())
                 xDataProperties->setPropertyValue("SuppressVersionColumns", aSuppressVersionsAny);
-            if(aInfoAny.hasValue())
+            if (aInfoAny.hasValue())
                 xDataProperties->setPropertyValue("Info", aInfoAny);
 
-            if( DBCONN_FLAT == type && pSettings )
+            if (DBConnURIType::FLAT == type && pSettings)
             {
-                    uno::Any aSettings = xDataProperties->getPropertyValue( "Settings" );
-                    uno::Reference < beans::XPropertySet > xDSSettings;
-                    aSettings >>= xDSSettings;
-                    ::comphelper::copyProperties( *pSettings, xDSSettings );
-                    xDSSettings->setPropertyValue( "Extension", uno::makeAny( sExt ));
+                uno::Any aSettings = xDataProperties->getPropertyValue("Settings");
+                uno::Reference < beans::XPropertySet > xDSSettings;
+                aSettings >>= xDSSettings;
+                ::comphelper::copyProperties(*pSettings, xDSSettings);
+                xDSSettings->setPropertyValue("Extension", uno::makeAny(sExt));
             }
 
             uno::Reference<sdb::XDocumentDataSource> xDS(xNewInstance, uno::UNO_QUERY_THROW);
             uno::Reference<frame::XStorable> xStore(xDS->getDatabaseDocument(), uno::UNO_QUERY_THROW);
-            OUString aOwnURL = lcl_getOwnURL(pDocShell);
+            OUString aOwnURL = getOwnURL(pDocShell);
             if (aOwnURL.isEmpty())
             {
                 // Cannot embed, as embedded data source would need the URL of the parent document.
@@ -2807,16 +2806,15 @@ OUString SwDBManager::LoadAndRegisterDataSource(const DBConnURITypes type, const
                 SwDBManager::StoreEmbeddedDataSource(xStore, xStorage, aStreamRelPath, aOwnURL);
             }
         }
-        xDBContext->registerObject( sFind, xNewInstance );
+        xDBContext->registerObject(sFind, xNewInstance);
     }
-    catch(const uno::Exception&)
+    catch (const uno::Exception&)
     {
         sFind.clear();
     }
     return sFind;
 }
 
-namespace {
 // Construct vnd.sun.star.pkg:// URL
 OUString ConstructVndSunStarPkgUrl(const OUString& rMainURL, const OUString& rStreamRelPath)
 {
@@ -2833,6 +2831,68 @@ OUString ConstructVndSunStarPkgUrl(const OUString& rMainURL, const OUString& rSt
 }
 }
 
+OUString SwDBManager::LoadAndRegisterDataSource(const vcl::Window* pParent, SwDocShell* pDocShell)
+{
+    sfx2::FileDialogHelper aDlgHelper(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::NONE, pParent);
+    uno::Reference < ui::dialogs::XFilePicker3 > xFP = aDlgHelper.GetFilePicker();
+
+    OUString sHomePath(SvtPathOptions().GetWorkPath());
+    aDlgHelper.SetDisplayDirectory( sHomePath );
+
+    uno::Reference<ui::dialogs::XFilterManager> xFltMgr(xFP, uno::UNO_QUERY);
+
+    OUString sFilterAll(SwResId(STR_FILTER_ALL));
+    OUString sFilterAllData(SwResId(STR_FILTER_ALL_DATA));
+    OUString sFilterSXB(SwResId(STR_FILTER_SXB));
+    OUString sFilterSXC(SwResId(STR_FILTER_SXC));
+    OUString sFilterSXW(SwResId(STR_FILTER_SXW));
+    OUString sFilterDBF(SwResId(STR_FILTER_DBF));
+    OUString sFilterXLS(SwResId(STR_FILTER_XLS));
+    OUString sFilterDOC(SwResId(STR_FILTER_DOC));
+    OUString sFilterTXT(SwResId(STR_FILTER_TXT));
+    OUString sFilterCSV(SwResId(STR_FILTER_CSV));
+#ifdef _WIN32
+    OUString sFilterMDB(SwResId(STR_FILTER_MDB));
+    OUString sFilterACCDB(SwResId(STR_FILTER_ACCDB));
+#endif
+    xFltMgr->appendFilter( sFilterAll, "*" );
+    xFltMgr->appendFilter( sFilterAllData, "*.ods;*.sxc;*.odt;*.sxw;*.dbf;*.xls;*.xlsx;*.doc;*.docx;*.txt;*.csv");
+
+    xFltMgr->appendFilter( sFilterSXB, "*.odb" );
+    xFltMgr->appendFilter( sFilterSXC, "*.ods;*.sxc" );
+    xFltMgr->appendFilter( sFilterSXW, "*.odt;*.sxw" );
+    xFltMgr->appendFilter( sFilterDBF, "*.dbf" );
+    xFltMgr->appendFilter( sFilterXLS, "*.xls;*.xlsx" );
+    xFltMgr->appendFilter( sFilterDOC, "*.doc;*.docx" );
+    xFltMgr->appendFilter( sFilterTXT, "*.txt" );
+    xFltMgr->appendFilter( sFilterCSV, "*.csv" );
+#ifdef _WIN32
+    xFltMgr->appendFilter(sFilterMDB, "*.mdb;*.mde");
+    xFltMgr->appendFilter(sFilterACCDB, "*.accdb;*.accde");
+#endif
+
+    xFltMgr->setCurrentFilter( sFilterAll ) ;
+    OUString sFind;
+    if( ERRCODE_NONE == aDlgHelper.Execute() )
+    {
+        uno::Reference< beans::XPropertySet > aSettings;
+        const INetURLObject aURL( xFP->getSelectedFiles().getConstArray()[0] );
+        const DBConnURIType type = GetDBunoType( aURL );
+
+        if( DBConnURIType::FLAT == type )
+        {
+            uno::Reference<uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
+            uno::Reference < sdb::XTextConnectionSettings > xSettingsDlg = sdb::TextConnectionSettings::create(xContext);
+            if( xSettingsDlg->execute() )
+                aSettings.set( uno::Reference < beans::XPropertySet >( xSettingsDlg, uno::UNO_QUERY_THROW ) );
+        }
+        sFind = LoadAndRegisterDataSource_Impl( type, DBConnURIType::FLAT == type ? &aSettings : nullptr, aURL, nullptr, nullptr, pDocShell );
+
+        m_aUncommitedRegistrations.push_back(std::pair<SwDocShell*, OUString>(pDocShell, sFind));
+    }
+    return sFind;
+}
+
 void SwDBManager::StoreEmbeddedDataSource(const uno::Reference<frame::XStorable>& xStorable,
                                           const uno::Reference<embed::XStorage>& xStorage,
                                           const OUString& rStreamRelPath,
@@ -2852,9 +2912,7 @@ void SwDBManager::StoreEmbeddedDataSource(const uno::Reference<frame::XStorable>
 
 OUString SwDBManager::LoadAndRegisterDataSource(const OUString &rURI, const OUString *pDestDir)
 {
-    uno::Any aURLAny;
-    DBConnURITypes type = GetDBunoURI( rURI, aURLAny );
-    return LoadAndRegisterDataSource( type, aURLAny, nullptr, rURI, nullptr, pDestDir );
+    return LoadAndRegisterDataSource_Impl( DBConnURIType::UNKNOWN, nullptr, INetURLObject(rURI), nullptr, pDestDir, nullptr );
 }
 
 void SwDBManager::RevokeDataSource(const OUString& rName)


More information about the Libreoffice-commits mailing list