summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/datamapper.hxx2
-rw-r--r--sc/qa/unit/dataproviders_test.cxx6
-rw-r--r--sc/source/filter/xml/xmlmappingi.cxx14
-rw-r--r--sc/source/ui/dataprovider/dataprovider.cxx6
-rw-r--r--sc/source/ui/inc/dataproviderdlg.hxx5
-rw-r--r--sc/source/ui/miscdlgs/dataproviderdlg.cxx23
-rw-r--r--sc/source/ui/view/cellsh2.cxx4
-rw-r--r--sc/uiconfig/scalc/ui/dataproviderdlg.ui68
8 files changed, 98 insertions, 30 deletions
diff --git a/sc/inc/datamapper.hxx b/sc/inc/datamapper.hxx
index 75b04440153e..1d7e710051c0 100644
--- a/sc/inc/datamapper.hxx
+++ b/sc/inc/datamapper.hxx
@@ -89,7 +89,7 @@ public:
const OUString& getID() const;
double getUpdateFrequency() const;
OUString getDBName() const;
- void setDBData(const ScDBData* pDBData);
+ void setDBData(const OUString& rDBName);
ScDBDataManager* getDBManager();
void refresh(ScDocument* pDoc, bool bDeterministic = false);
diff --git a/sc/qa/unit/dataproviders_test.cxx b/sc/qa/unit/dataproviders_test.cxx
index d0df69c96d5c..1960fa59eecf 100644
--- a/sc/qa/unit/dataproviders_test.cxx
+++ b/sc/qa/unit/dataproviders_test.cxx
@@ -50,7 +50,7 @@ void ScDataProvidersTest::testCSVImport()
OUString aFileURL;
createFileURL("test1.", "csv", aFileURL);
sc::ExternalDataSource aDataSource(aFileURL, "org.libreoffice.calc.csv", m_pDoc);
- aDataSource.setDBData(pDBData);
+ aDataSource.setDBData(pDBData->GetName());
m_pDoc->GetExternalDataMapper().insertDataSource(aDataSource);
@@ -78,7 +78,7 @@ void ScDataProvidersTest::testDataLargerThanDB()
OUString aFileURL;
createFileURL("test1.", "csv", aFileURL);
sc::ExternalDataSource aDataSource(aFileURL, "org.libreoffice.calc.csv", m_pDoc);
- aDataSource.setDBData(pDBData);
+ aDataSource.setDBData(pDBData->GetName());
m_pDoc->GetExternalDataMapper().insertDataSource(aDataSource);
@@ -107,7 +107,7 @@ void ScDataProvidersTest::testHTMLImport()
createFileURL("test1.", "html", aFileURL);
sc::ExternalDataSource aDataSource(aFileURL, "org.libreoffice.calc.html", m_pDoc);
aDataSource.setID("//table");
- aDataSource.setDBData(pDBData);
+ aDataSource.setDBData(pDBData->GetName());
m_pDoc->GetExternalDataMapper().insertDataSource(aDataSource);
diff --git a/sc/source/filter/xml/xmlmappingi.cxx b/sc/source/filter/xml/xmlmappingi.cxx
index c40734afc177..c2f8b4004213 100644
--- a/sc/source/filter/xml/xmlmappingi.cxx
+++ b/sc/source/filter/xml/xmlmappingi.cxx
@@ -105,15 +105,11 @@ ScXMLMappingContext::ScXMLMappingContext( ScXMLImport& rImport,
if (!aProvider.isEmpty())
{
ScDocument* pDoc = GetScImport().GetDocument();
- ScDBData* pDBData = pDoc->GetDBCollection()->getNamedDBs().findByUpperName(ScGlobal::pCharClass->uppercase(aDBName));
- if (pDBData)
- {
- auto& rDataMapper = pDoc->GetExternalDataMapper();
- sc::ExternalDataSource aSource(aURL, aProvider, pDoc);
- aSource.setID(aID);
- aSource.setDBData(pDBData);
- rDataMapper.insertDataSource(aSource);
- }
+ auto& rDataMapper = pDoc->GetExternalDataMapper();
+ sc::ExternalDataSource aSource(aURL, aProvider, pDoc);
+ aSource.setID(aID);
+ aSource.setDBData(aDBName);
+ rDataMapper.insertDataSource(aSource);
}
}
diff --git a/sc/source/ui/dataprovider/dataprovider.cxx b/sc/source/ui/dataprovider/dataprovider.cxx
index 161aaf502fa9..22a3be99475e 100644
--- a/sc/source/ui/dataprovider/dataprovider.cxx
+++ b/sc/source/ui/dataprovider/dataprovider.cxx
@@ -111,15 +111,15 @@ OUString ExternalDataSource::getDBName() const
return OUString();
}
-void ExternalDataSource::setDBData(const ScDBData* pDBData)
+void ExternalDataSource::setDBData(const OUString& rDBName)
{
if (!mpDBDataManager)
{
- mpDBDataManager.reset(new ScDBDataManager(pDBData->GetName(), false, mpDoc));
+ mpDBDataManager.reset(new ScDBDataManager(rDBName, false, mpDoc));
}
else
{
- mpDBDataManager->SetDatabase(pDBData->GetName());
+ mpDBDataManager->SetDatabase(rDBName);
}
}
diff --git a/sc/source/ui/inc/dataproviderdlg.hxx b/sc/source/ui/inc/dataproviderdlg.hxx
index a56f4f612b45..5b5c444d13d8 100644
--- a/sc/source/ui/inc/dataproviderdlg.hxx
+++ b/sc/source/ui/inc/dataproviderdlg.hxx
@@ -36,6 +36,7 @@ private:
VclPtr<ListControl> mpList;
VclPtr<MenuBar> mpBar;
VclPtr<ScDataProviderBaseControl> mpDataProviderCtrl;
+ VclPtr<ListBox> mpDBRanges;
ScDBData* pDBData;
@@ -47,7 +48,7 @@ private:
public:
- ScDataProviderDlg(vcl::Window* pWindow, std::shared_ptr<ScDocument> pDoc);
+ ScDataProviderDlg(vcl::Window* pWindow, std::shared_ptr<ScDocument> pDoc, ScDocument* pDocument);
virtual ~ScDataProviderDlg() override;
virtual void dispose() override;
@@ -61,7 +62,7 @@ public:
void splitColumn();
void mergeColumns();
- void import(ScDocument* pDoc);
+ void import(ScDocument* pDoc, bool bInternal = false);
};
#endif
diff --git a/sc/source/ui/miscdlgs/dataproviderdlg.cxx b/sc/source/ui/miscdlgs/dataproviderdlg.cxx
index a94a5d4d41e1..a867b419aa7e 100644
--- a/sc/source/ui/miscdlgs/dataproviderdlg.cxx
+++ b/sc/source/ui/miscdlgs/dataproviderdlg.cxx
@@ -437,15 +437,23 @@ std::shared_ptr<sc::DataTransformation> ScMergeColumnTransformationControl::getT
}
-ScDataProviderDlg::ScDataProviderDlg(vcl::Window* pParent, std::shared_ptr<ScDocument> pDoc):
+ScDataProviderDlg::ScDataProviderDlg(vcl::Window* pParent, std::shared_ptr<ScDocument> pDoc, ScDocument* pDocument):
ModalDialog(pParent, "dataproviderdlg", "modules/scalc/ui/dataproviderdlg.ui", true),
mpDoc(pDoc),
mpBar(VclPtr<MenuBar>::Create())
{
get(mpTable, "data_table");
get(mpList, "operation_ctrl");
+ get(mpDBRanges, "select_db_range");
mpTable->Init(mpDoc);
+ ScDBCollection* pDBCollection = pDocument->GetDBCollection();
+ auto& rNamedDBs = pDBCollection->getNamedDBs();
+ for (auto& rNamedDB : rNamedDBs)
+ {
+ mpDBRanges->InsertEntry(rNamedDB->GetName());
+ }
+
mpDataProviderCtrl = VclPtr<ScDataProviderBaseControl>::Create(mpList, LINK(this, ScDataProviderDlg, ImportHdl));
mpList->addEntry(mpDataProviderCtrl);
@@ -466,6 +474,7 @@ void ScDataProviderDlg::dispose()
mpDataProviderCtrl.clear();
mpTable.clear();
mpList.clear();
+ mpDBRanges.clear();
mpBar.disposeAndClear();
ModalDialog::dispose();
@@ -534,7 +543,7 @@ IMPL_LINK(ScDataProviderDlg, ImportHdl, Window*, pCtrl, void)
{
if (pCtrl == mpDataProviderCtrl.get())
{
- import(mpDoc.get());
+ import(mpDoc.get(), true);
}
}
@@ -572,7 +581,7 @@ void ScDataProviderDlg::mergeColumns()
mpList->addEntry(pMergeColumnEntry);
}
-void ScDataProviderDlg::import(ScDocument* pDoc)
+void ScDataProviderDlg::import(ScDocument* pDoc, bool bInternal)
{
sc::ExternalDataSource aSource = mpDataProviderCtrl->getDataSource(pDoc);
std::vector<VclPtr<vcl::Window>> aListEntries = mpList->getEntries();
@@ -586,7 +595,13 @@ void ScDataProviderDlg::import(ScDocument* pDoc)
}
aSource.AddDataTransformation(pTransformationCtrl->getTransformation());
}
- aSource.setDBData(pDBData);
+ if (bInternal)
+ aSource.setDBData(pDBData->GetName());
+ else
+ {
+ aSource.setDBData(mpDBRanges->GetSelectedEntry());
+ pDoc->GetExternalDataMapper().insertDataSource(aSource);
+ }
aSource.refresh(pDoc, true);
mpTable->Invalidate();
}
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index b8b64d869880..b9cead695b7a 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -787,10 +787,10 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
{
std::shared_ptr<ScDocument> xDoc(new ScDocument, o3tl::default_delete<ScDocument>());
xDoc->InsertTab(0, "test");
- ScopedVclPtrInstance< ScDataProviderDlg > aDialog( pTabViewShell->GetDialogParent(), xDoc);
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScopedVclPtrInstance< ScDataProviderDlg > aDialog( pTabViewShell->GetDialogParent(), xDoc, pDoc);
if (aDialog->Execute() == RET_OK)
{
- ScDocument* pDoc = GetViewData()->GetDocument();
aDialog->import(pDoc);
}
}
diff --git a/sc/uiconfig/scalc/ui/dataproviderdlg.ui b/sc/uiconfig/scalc/ui/dataproviderdlg.ui
index 7d04e52c5acc..ead166b83cf2 100644
--- a/sc/uiconfig/scalc/ui/dataproviderdlg.ui
+++ b/sc/uiconfig/scalc/ui/dataproviderdlg.ui
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.0 -->
+<!-- Generated with glade 3.20.2 -->
<interface domain="sc">
<requires lib="gtk+" version="3.18"/>
<requires lib="LibreOffice" version="1.0"/>
@@ -21,20 +21,76 @@
</packing>
</child>
<child>
- <placeholder/>
- </child>
- <child>
- <object class="GtkListBox" id="operation_ctrl">
+ <object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkGrid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes" context="dataproviderdlg|db_name">Database Range: </property>
+ <accessibility>
+ <relation type="label-for" target="select_db_range"/>
+ </accessibility>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="select_db_range">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <accessibility>
+ <relation type="labelled-by" target="label2"/>
+ </accessibility>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkListBox" id="operation_ctrl">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">2</property>
+ <property name="position">1</property>
</packing>
</child>
+ <child>
+ <placeholder/>
+ </child>
</object>
</child>
+ <child type="titlebar">
+ <placeholder/>
+ </child>
</object>
</interface>