summaryrefslogtreecommitdiff
path: root/sc/source/ui
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/ui')
-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
4 files changed, 27 insertions, 11 deletions
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);
}
}