summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2018-02-08 22:49:55 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2018-07-06 02:14:40 +0200
commit3f66d987ce3a46eb836f2c11bbaf360bd6195e27 (patch)
treed3a3992c97344b6e9015dd6d164a8471b4b47ff1 /sc/source
parenteac72845f5c9aac0fb346b2d48cee697006c057b (diff)
add a selection for the DB range to Dataprovider dlg
Change-Id: I02c63b46e21cd8d04e6b515e2cbbee08743d5657 Reviewed-on: https://gerrit.libreoffice.org/49459 Tested-by: Jenkins Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sc/source')
-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
5 files changed, 32 insertions, 20 deletions
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);
}
}