sc/source/ui/docshell/dataprovider.cxx | 55 +++++++++++++++------------------ 1 file changed, 26 insertions(+), 29 deletions(-)
New commits: commit 631023655da490f9e5c5721389ccd34b491307be Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Thu Aug 10 09:13:08 2017 +0200 external data: import all the csv data Change-Id: Ifcb2c42594713ed263ef38c1ef0e8bc0efbce01e Reviewed-on: https://gerrit.libreoffice.org/40963 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrh...@googlemail.com> diff --git a/sc/source/ui/docshell/dataprovider.cxx b/sc/source/ui/docshell/dataprovider.cxx index 97dbea72fa8d..9d17c892cb96 100644 --- a/sc/source/ui/docshell/dataprovider.cxx +++ b/sc/source/ui/docshell/dataprovider.cxx @@ -249,43 +249,40 @@ void CSVFetchThread::execute() { OStringBuffer aBuffer(64000); std::unique_ptr<SvStream> pStream = FetchStreamFromURL(maURL, aBuffer); - if (pStream->good()) + SCROW nCurRow = 0; + SCCOL nCol = 0; + while (pStream->good()) { - LinesType aLines(10); - SCROW nCurRow = 0; - SCCOL nCol = 0; - for (Line & rLine : aLines) - { - if (mbTerminate) - break; + if (mbTerminate) + break; + + Line aLine; + aLine.maCells.clear(); + pStream->ReadLine(aLine.maLine); + CSVHandler aHdl(aLine, MAXCOL); + orcus::csv_parser<CSVHandler> parser(aLine.maLine.getStr(), aLine.maLine.getLength(), aHdl, maConfig); + parser.parse(); - rLine.maCells.clear(); - pStream->ReadLine(rLine.maLine); - CSVHandler aHdl(rLine, MAXCOL); - orcus::csv_parser<CSVHandler> parser(rLine.maLine.getStr(), rLine.maLine.getLength(), aHdl, maConfig); - parser.parse(); + if (aLine.maCells.empty()) + { + break; + } - if (rLine.maCells.empty()) + nCol = 0; + const char* pLineHead = aLine.maLine.getStr(); + for (auto& rCell : aLine.maCells) + { + if (rCell.mbValue) { - break; + mrDocument.SetValue(ScAddress(nCol, nCurRow, 0 /* Tab */), rCell.mfValue); } - - nCol = 0; - const char* pLineHead = rLine.maLine.getStr(); - for (auto& rCell : rLine.maCells) + else { - if (rCell.mbValue) - { - mrDocument.SetValue(ScAddress(nCol, nCurRow, 0 /* Tab */), rCell.mfValue); - } - else - { - mrDocument.SetString(nCol, nCurRow, 0 /* Tab */, OUString(pLineHead+rCell.maStr.Pos, rCell.maStr.Size, RTL_TEXTENCODING_UTF8)); - } - ++nCol; + mrDocument.SetString(nCol, nCurRow, 0 /* Tab */, OUString(pLineHead+rCell.maStr.Pos, rCell.maStr.Size, RTL_TEXTENCODING_UTF8)); } - nCurRow++; + ++nCol; } + nCurRow++; } SolarMutexGuard aGuard; mpIdle->Start(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits