[Libreoffice-commits] core.git: 2 commits - sc/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Thu Aug 10 18:40:27 UTC 2017
sc/source/ui/docshell/dataprovider.cxx | 21 +++++++++++----------
sc/source/ui/inc/dataprovider.hxx | 8 ++++----
sc/source/ui/inc/dataproviderdlg.hxx | 1 +
sc/source/ui/miscdlgs/dataproviderdlg.cxx | 8 ++++++++
sc/source/ui/view/cellsh2.cxx | 1 -
5 files changed, 24 insertions(+), 15 deletions(-)
New commits:
commit 0814bf35b2287e448e350c15d60d0400fd9e224c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Aug 10 09:35:44 2017 +0200
external data: fix a few issues with the dialog
Change-Id: I16358e785d4ebd6375c98b84f4a31d3fa604d734
Reviewed-on: https://gerrit.libreoffice.org/40965
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/sc/source/ui/inc/dataproviderdlg.hxx b/sc/source/ui/inc/dataproviderdlg.hxx
index 0bba15b4e70d..1281adb0581f 100644
--- a/sc/source/ui/inc/dataproviderdlg.hxx
+++ b/sc/source/ui/inc/dataproviderdlg.hxx
@@ -39,6 +39,7 @@ class DataProviderDlg : public ModalDialog
DECL_LINK(UpdateClickHdl, Button*, void);
DECL_LINK(UpdateComboBoxHdl, ComboBox&, void);
DECL_LINK(BrowseHdl, Button*, void);
+ DECL_LINK(EditHdl, Edit&, void);
void UpdateEnable();
diff --git a/sc/source/ui/miscdlgs/dataproviderdlg.cxx b/sc/source/ui/miscdlgs/dataproviderdlg.cxx
index 8c20f8fff4a6..c583df378300 100644
--- a/sc/source/ui/miscdlgs/dataproviderdlg.cxx
+++ b/sc/source/ui/miscdlgs/dataproviderdlg.cxx
@@ -29,7 +29,10 @@ DataProviderDlg::DataProviderDlg(ScDocShell *pDocShell, vcl::Window* pParent)
get(m_pCBData, "combobox_db");
m_pCbUrl->SetSelectHdl( LINK( this, DataProviderDlg, UpdateComboBoxHdl ) );
+ m_pCbUrl->SetModifyHdl(LINK(this, DataProviderDlg, EditHdl));
m_pBtnBrowse->SetClickHdl( LINK( this, DataProviderDlg, BrowseHdl ) );
+ Init();
+ m_pCBData->Resize();
UpdateEnable();
}
@@ -67,6 +70,11 @@ IMPL_LINK_NOARG(DataProviderDlg, UpdateComboBoxHdl, ComboBox&, void)
UpdateEnable();
}
+IMPL_LINK_NOARG(DataProviderDlg, EditHdl, Edit&, void)
+{
+ UpdateEnable();
+}
+
void DataProviderDlg::UpdateEnable()
{
bool bOk = !m_pCbUrl->GetURL().isEmpty();
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index abbb35219c0a..7a2848251b1a 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -782,7 +782,6 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
case SID_DATA_PROVIDER:
{
ScopedVclPtrInstance< sc::DataProviderDlg > aDialog( GetViewData()->GetDocShell(), pTabViewShell->GetDialogParent() );
- aDialog->Init(/**pStrm*/);
if (aDialog->Execute() == RET_OK)
{
aDialog->StartImport();
commit 4bd3b786b2d53fd08767e4efaa7abe9803610aae
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Aug 10 09:14:05 2017 +0200
external data: use the DB name instead of a DB pointer
When we modify the DB range we create a copy and replace the original
DB range with the modified one. Therefore, we would store a pointer
to a deleted object. We can always get the range through the name.
Change-Id: Ifce28efb7263c300c2c8722ac969807de1ab8b2a
Reviewed-on: https://gerrit.libreoffice.org/40964
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/sc/source/ui/docshell/dataprovider.cxx b/sc/source/ui/docshell/dataprovider.cxx
index 9d17c892cb96..5839f3d0f4e8 100644
--- a/sc/source/ui/docshell/dataprovider.cxx
+++ b/sc/source/ui/docshell/dataprovider.cxx
@@ -104,11 +104,11 @@ void ExternalDataSource::setDBData(ScDBData* pDBData)
{
if (!mpDBDataManager)
{
- mpDBDataManager.reset(new ScDBDataManager(pDBData, false, mpDoc));
+ mpDBDataManager.reset(new ScDBDataManager(pDBData->GetName(), false, mpDoc));
}
else
{
- mpDBDataManager->SetDatabase(pDBData);
+ mpDBDataManager->SetDatabase(pDBData->GetName());
}
}
@@ -321,7 +321,7 @@ void CSVDataProvider::Import()
IMPL_LINK_NOARG(CSVDataProvider, ImportFinishedHdl, Timer*, void)
{
- mpDBDataManager->WriteToDoc(*mpDoc, mpDBDataManager->getDBData());
+ mpDBDataManager->WriteToDoc(*mpDoc);
mxCSVFetchThread.clear();
mpDoc.reset();
Refresh();
@@ -333,7 +333,7 @@ void CSVDataProvider::Refresh()
pDocShell->SetDocumentModified();
}
-void ScDBDataManager::WriteToDoc(ScDocument& rDoc, ScDBData* pDBData)
+void ScDBDataManager::WriteToDoc(ScDocument& rDoc)
{
bool bShrunk = false;
SCCOL nStartCol = 0;
@@ -345,7 +345,7 @@ void ScDBDataManager::WriteToDoc(ScDocument& rDoc, ScDBData* pDBData)
rDoc.SetClipArea(aClipRange);
ScRange aDestRange;
- pDBData->GetArea(aDestRange);
+ getDBData()->GetArea(aDestRange);
SCCOL nColSize = std::min<SCCOL>(aDestRange.aEnd.Col() - aDestRange.aStart.Col(), nEndCol);
aDestRange.aEnd.SetCol(aDestRange.aStart.Col() + nColSize);
@@ -359,8 +359,8 @@ void ScDBDataManager::WriteToDoc(ScDocument& rDoc, ScDBData* pDBData)
pDocShell->PostPaint(aDestRange, PaintPartFlags::All);
}
-ScDBDataManager::ScDBDataManager(ScDBData* pDBData, bool /*bAllowResize*/, ScDocument* pDoc):
- mpDBData(pDBData),
+ScDBDataManager::ScDBDataManager(const OUString& rDBName, bool /*bAllowResize*/, ScDocument* pDoc):
+ maDBName(rDBName),
//mbAllowResize(bAllowResize),
mpDoc(pDoc)
{
@@ -370,14 +370,15 @@ ScDBDataManager::~ScDBDataManager()
{
}
-void ScDBDataManager::SetDatabase(ScDBData* pDbData)
+void ScDBDataManager::SetDatabase(const OUString& rDBName)
{
- mpDBData = pDbData;
+ maDBName = rDBName;
}
ScDBData* ScDBDataManager::getDBData()
{
- return mpDBData;
+ ScDBData* pDBData = mpDoc->GetDBCollection()->getNamedDBs().findByUpperName(ScGlobal::pCharClass->uppercase(maDBName));
+ return pDBData;
}
bool DataProviderFactory::isInternalDataProvider(const OUString& rProvider)
diff --git a/sc/source/ui/inc/dataprovider.hxx b/sc/source/ui/inc/dataprovider.hxx
index e3d25317578d..8afff1aefc83 100644
--- a/sc/source/ui/inc/dataprovider.hxx
+++ b/sc/source/ui/inc/dataprovider.hxx
@@ -146,18 +146,18 @@ public:
*/
class ScDBDataManager
{
- ScDBData* mpDBData;
+ OUString maDBName;
ScDocument* mpDoc;
public:
- ScDBDataManager(ScDBData* pDBData, bool bAllowResize, ScDocument* pDoc);
+ ScDBDataManager(const OUString& rDBName, bool bAllowResize, ScDocument* pDoc);
~ScDBDataManager();
- void SetDatabase(ScDBData* pDBData);
+ void SetDatabase(const OUString& rDBName);
ScDBData* getDBData();
- void WriteToDoc(ScDocument& rDoc, ScDBData* pDBData);
+ void WriteToDoc(ScDocument& rDoc);
};
class DataProviderFactory
More information about the Libreoffice-commits
mailing list