sc/source/ui/inc/dataproviderdlg.hxx | 1 + sc/source/ui/miscdlgs/dataproviderdlg.cxx | 11 +++++++++++ 2 files changed, 12 insertions(+)
New commits: commit 50ac0aa72f8af34ab180c8ea2060b0221afe0731 Author: Rafael Lima <rafael.palma.l...@gmail.com> AuthorDate: Sun Mar 9 23:15:24 2025 +0100 Commit: Olivier Hallot <olivier.hal...@libreoffice.org> CommitDate: Mon Mar 10 13:03:15 2025 +0100 tdf#165502 Clear table preview when refreshing the data source Previously, when the Apply button was pressed for a second time in the "Data Provider" dialog, and the new dataset was smaller than the existing data, the content outside the new data range would still be visible in the preview. This patch ensures that the preview is cleared before updating it. Change-Id: I33861bba65d9059df2cf44fd76b74b0b981b9564 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182701 Reviewed-by: Olivier Hallot <olivier.hal...@libreoffice.org> Tested-by: Jenkins diff --git a/sc/source/ui/inc/dataproviderdlg.hxx b/sc/source/ui/inc/dataproviderdlg.hxx index 127b6361abbd..40db1fc12cda 100644 --- a/sc/source/ui/inc/dataproviderdlg.hxx +++ b/sc/source/ui/inc/dataproviderdlg.hxx @@ -94,6 +94,7 @@ public: sc::ExternalDataSource getDataSource(ScDocument* pDoc); + void clearTablePreview(); void import(ScDocument& rDoc, bool bInternal = false); }; diff --git a/sc/source/ui/miscdlgs/dataproviderdlg.cxx b/sc/source/ui/miscdlgs/dataproviderdlg.cxx index 8861605d70e3..ccd36a27a7c0 100644 --- a/sc/source/ui/miscdlgs/dataproviderdlg.cxx +++ b/sc/source/ui/miscdlgs/dataproviderdlg.cxx @@ -869,6 +869,7 @@ IMPL_LINK_NOARG(ScDataProviderDlg, URLEditHdl, weld::Entry&, void) IMPL_LINK_NOARG(ScDataProviderDlg, ApplyBtnHdl, weld::Button&, void) { updateApplyBtn(true); + clearTablePreview(); import(*mxDoc, true); } @@ -1004,6 +1005,16 @@ bool hasDBName(const OUString& rName, ScDBCollection* pDBCollection) } +// tdf#165502 Clear the contents of the temporary ScDocument in mxDoc and adds a sheet to +// store the data to be previewed. This is needed if the newly imported content is smaller +// than the previously shown content +void ScDataProviderDlg::clearTablePreview() +{ + mxDoc->Clear(); + // The name "test" below is just a dummy name for the tab that will hold the data + mxDoc->InsertTab(0, u"test"_ustr); +} + void ScDataProviderDlg::import(ScDocument& rDoc, bool bInternal) { sc::ExternalDataSource aSource = getDataSource(&rDoc);