diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-08-10 01:26:22 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-08-10 18:53:54 +0200 |
commit | 2f2d41d101e0790ea50be3df7d14224357f3f9fb (patch) | |
tree | e9665a59c3b496b9791a21dc10a692eec1f3b5fa /sc/source | |
parent | 84c2297b48fb5d37dd2db4695e669e8e67801e18 (diff) |
external data: use the existing copy data functionality
Change-Id: Id9eb9bcfaf67a17a945b69d8bc65c7180051f90d
Reviewed-on: https://gerrit.libreoffice.org/40960
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/ui/docshell/dataprovider.cxx | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/sc/source/ui/docshell/dataprovider.cxx b/sc/source/ui/docshell/dataprovider.cxx index fac1e2947544..87288877b22d 100644 --- a/sc/source/ui/docshell/dataprovider.cxx +++ b/sc/source/ui/docshell/dataprovider.cxx @@ -336,7 +336,6 @@ void CSVDataProvider::Refresh() pDocShell->SetDocumentModified(); } -// TODO: why don't we use existing copy functionality void ScDBDataManager::WriteToDoc(ScDocument& rDoc, ScDBData* pDBData) { bool bShrunk = false; @@ -345,28 +344,13 @@ void ScDBDataManager::WriteToDoc(ScDocument& rDoc, ScDBData* pDBData) SCCOL nEndCol = MAXCOL; SCROW nEndRow = MAXROW; rDoc.ShrinkToUsedDataArea(bShrunk, 0, nStartCol, nStartRow, nEndCol, nEndRow, false, true, true); + rDoc.SetClipArea(ScRange(nStartCol, nStartRow, 0, nEndCol, nEndRow, 0)); ScRange aDestRange; pDBData->GetArea(aDestRange); - double* pfValue; - for (int nRow = nStartRow; nRow < nEndRow; ++nRow) - { - for (int nCol = nStartCol; nCol < nEndCol; ++nCol) - { - ScAddress aAddr = ScAddress(nCol, nRow, 0); - pfValue = rDoc.GetValueCell(aAddr); - - if (pfValue == nullptr) - { - OUString aString = rDoc.GetString(nCol, nRow, 0); - mpDoc->SetString(aDestRange.aStart.Col() + nCol, aDestRange.aStart.Row() + nRow, aDestRange.aStart.Tab(), aString); - } - else - { - mpDoc->SetValue(aDestRange.aStart.Col() + nCol, aDestRange.aStart.Row() + nRow, aDestRange.aStart.Tab(), *pfValue); - } - } - } + ScMarkData aMark; + aMark.SelectTable(0, true); + mpDoc->CopyFromClip(aDestRange, aMark, InsertDeleteFlags::CONTENTS, nullptr, &rDoc); ScDocShell* pDocShell = static_cast<ScDocShell*>(mpDoc->GetDocumentShell()); pDocShell->PostPaint(aDestRange, PaintPartFlags::All); } |