sc/source/ui/miscdlgs/dataproviderdlg.cxx |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

New commits:
commit 14f83b8a8ec8f2fe1570db285f4527b9fd5d86ea
Author:     Markus Mohrhard <markus.mohrh...@googlemail.com>
AuthorDate: Fri Oct 19 21:58:18 2018 -0600
Commit:     Markus Mohrhard <markus.mohrh...@googlemail.com>
CommitDate: Sun Nov 18 05:35:31 2018 +0100

    tdf#113916, don't import if no DB range is selected
    
    Change-Id: I6562ded076f53c44b5eeab7027058baf6c71f48f
    Reviewed-on: https://gerrit.libreoffice.org/63509
    Tested-by: Jenkins
    Reviewed-by: Markus Mohrhard <markus.mohrh...@googlemail.com>

diff --git a/sc/source/ui/miscdlgs/dataproviderdlg.cxx 
b/sc/source/ui/miscdlgs/dataproviderdlg.cxx
index 75a7880e42ff..cb58ad0c42ff 100644
--- a/sc/source/ui/miscdlgs/dataproviderdlg.cxx
+++ b/sc/source/ui/miscdlgs/dataproviderdlg.cxx
@@ -18,6 +18,7 @@
 
 #include <comphelper/string.hxx>
 #include <sal/log.hxx>
+#include <unotools/charclass.hxx>
 
 #include <utility>
 #include <vcl/lstbox.hxx>
@@ -1137,9 +1138,22 @@ void ScDataProviderDlg::dateTimeTransformation()
     mpList->addEntry(pDateTimeTransformationEntry);
 }
 
+namespace {
+
+bool hasDBName(const OUString& rName, ScDBCollection* pDBCollection)
+{
+    if 
(pDBCollection->getNamedDBs().findByUpperName(ScGlobal::pCharClass->uppercase(rName)))
+        return true;
+
+    return false;
+}
+
+}
+
 void ScDataProviderDlg::import(ScDocument* pDoc, bool bInternal)
 {
     sc::ExternalDataSource aSource = mpDataProviderCtrl->getDataSource(pDoc);
+
     std::vector<VclPtr<vcl::Window>> aListEntries = mpList->getEntries();
     for (size_t i = 1; i < aListEntries.size(); ++i)
     {
@@ -1156,6 +1170,8 @@ void ScDataProviderDlg::import(ScDocument* pDoc, bool 
bInternal)
     else
     {
         aSource.setDBData(mpDBRanges->GetSelectedEntry());
+        if (!hasDBName(aSource.getDBName(), pDoc->GetDBCollection()))
+            return;
         pDoc->GetExternalDataMapper().insertDataSource(aSource);
     }
     aSource.refresh(pDoc, true);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to