sc/qa/unit/data/dataprovider/html/test1.html | 44 +++++++++++++++++++++++ sc/qa/unit/dataproviders_test.cxx | 42 +++++++++++++++++++++ sc/source/ui/dataprovider/datatransformation.cxx | 10 +++++ sc/source/ui/dataprovider/htmldataprovider.cxx | 7 +++ sc/source/ui/inc/datatransformation.hxx | 12 ++++++ 5 files changed, 115 insertions(+)
New commits: commit b607f62fde45a907f17545f4073e53d308b4cd1f Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Tue Aug 15 18:19:08 2017 +0200 external data: add HTML data provider test Change-Id: I594581ce388221760554f6272ee3af761f172c05 Reviewed-on: https://gerrit.libreoffice.org/41197 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrh...@googlemail.com> diff --git a/sc/qa/unit/data/dataprovider/html/test1.html b/sc/qa/unit/data/dataprovider/html/test1.html new file mode 100644 index 000000000000..2d81f0503d21 --- /dev/null +++ b/sc/qa/unit/data/dataprovider/html/test1.html @@ -0,0 +1,44 @@ +<html> + <table> + <thead> + <tr> + <th>Col1</th> + <th>Col2</th> + <th>Col3</th> + <th>Col4</th> + </tr> + </thead> + <tbody> + <tr> + <td>1</td> + <td>2</td> + <td>Audi</td> + <td>Berlin</td> + </tr> + <tr> + <td>10</td> + <td>2.1</td> + <td>GM</td> + <td>San Francisco</td> + </tr> + <tr> + <td>-100</td> + <td>2010-1-1</td> + <td>Nissan</td> + <td>Tokyo</td> + </tr> + <tr> + <td>-0.11111</td> + <td>2</td> + <td>Ferrari</td> + <td>Rome</td> + </tr> + <tr> + <td>1</td> + <td>2</td> + <td>Peugeot</td> + <td>Paris</td> + </tr> + </tbody> + </table> +</html> diff --git a/sc/qa/unit/dataproviders_test.cxx b/sc/qa/unit/dataproviders_test.cxx index 5ab7dfe3f933..4b18db5ecd75 100644 --- a/sc/qa/unit/dataproviders_test.cxx +++ b/sc/qa/unit/dataproviders_test.cxx @@ -28,10 +28,12 @@ public: void testCSVImport(); void testDataLargerThanDB(); + void testHTMLImport(); CPPUNIT_TEST_SUITE(ScDataProvidersTest); CPPUNIT_TEST(testCSVImport); CPPUNIT_TEST(testDataLargerThanDB); + CPPUNIT_TEST(testHTMLImport); CPPUNIT_TEST_SUITE_END(); private: @@ -95,6 +97,46 @@ void ScDataProvidersTest::testDataLargerThanDB() CPPUNIT_ASSERT_EQUAL(OUString(), m_pDoc->GetString(2, 1, 0)); } +void ScDataProvidersTest::testHTMLImport() +{ + ScDBData* pDBData = new ScDBData("testDB", 0, 0, 0, 10, 10); + bool bInserted = m_pDoc->GetDBCollection()->getNamedDBs().insert(pDBData); + CPPUNIT_ASSERT(bInserted); + + OUString aFileURL; + createFileURL("test1.", "html", aFileURL); + sc::ExternalDataSource aDataSource(aFileURL, "org.libreoffice.calc.html", m_pDoc); + aDataSource.setID("//table"); + aDataSource.setDBData(pDBData); + + + m_pDoc->GetExternalDataMapper().insertDataSource(aDataSource); + auto& rDataSources = m_pDoc->GetExternalDataMapper().getDataSources(); + CPPUNIT_ASSERT(!rDataSources.empty()); + + rDataSources[0].refresh(m_pDoc, true); + Scheduler::ProcessEventsToIdle(); + + + std::vector<OUString> aCarManufacturers = {"Audi", "GM", "Nissan", "Ferrari", "Peugeot"}; + std::vector<OUString> aCities = {"Berlin", "San Francisco", "Tokyo", "Rome", "Paris"}; + std::vector<double> aFirstCol = {1, 10, -100, -0.11111, 1}; + std::vector<double> aSecondCol = {2, 2.1, 40179, 2, 2,}; // 40179 is equal to 2010-1-1 + + CPPUNIT_ASSERT_EQUAL(OUString("Col1"), m_pDoc->GetString(0, 0, 0)); + CPPUNIT_ASSERT_EQUAL(OUString("Col2"), m_pDoc->GetString(1, 0, 0)); + CPPUNIT_ASSERT_EQUAL(OUString("Col3"), m_pDoc->GetString(2, 0, 0)); + CPPUNIT_ASSERT_EQUAL(OUString("Col4"), m_pDoc->GetString(3, 0, 0)); + + for (SCROW nRow = 0; nRow <= 4; ++nRow) + { + ASSERT_DOUBLES_EQUAL(aFirstCol[nRow], m_pDoc->GetValue(0, nRow + 1, 0)); + ASSERT_DOUBLES_EQUAL(aSecondCol[nRow], m_pDoc->GetValue(1, nRow + 1, 0)); + CPPUNIT_ASSERT_EQUAL(aCarManufacturers[nRow], m_pDoc->GetString(2, nRow + 1, 0)); + CPPUNIT_ASSERT_EQUAL(aCities[nRow], m_pDoc->GetString(3, nRow + 1, 0)); + } +} + ScDataProvidersTest::ScDataProvidersTest() : ScBootstrapFixture( "/sc/qa/unit/data/dataprovider" ), m_pDoc(nullptr) diff --git a/sc/source/ui/dataprovider/datatransformation.cxx b/sc/source/ui/dataprovider/datatransformation.cxx index 2c2fe72bbcf4..b4251dc7201a 100644 --- a/sc/source/ui/dataprovider/datatransformation.cxx +++ b/sc/source/ui/dataprovider/datatransformation.cxx @@ -91,6 +91,16 @@ void MergeColumnTransformation::Transform(ScDocument& rDoc) rDoc.DeleteCol(0, 0, MAXROW, 0, mnCol2, 1); } +SortTransformation::SortTransformation(const ScSortParam& rSortParam): + maSortParam(rSortParam) +{ +} + +void SortTransformation::Transform(ScDocument& rDoc) +{ + rDoc.Sort(0, maSortParam, false, false, nullptr, nullptr); +} + } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/datatransformation.hxx b/sc/source/ui/inc/datatransformation.hxx index 09c677b56aa4..7fef5ac472ae 100644 --- a/sc/source/ui/inc/datatransformation.hxx +++ b/sc/source/ui/inc/datatransformation.hxx @@ -13,6 +13,8 @@ #include <address.hxx> #include <scdllapi.h> +#include <sortparam.hxx> + class ScDocument; namespace sc { @@ -65,6 +67,16 @@ public: virtual void Transform(ScDocument& rDoc) override; }; +class SC_DLLPUBLIC SortTransformation : public DataTransformation +{ + ScSortParam maSortParam; +public: + + SortTransformation(const ScSortParam& rParam); + + virtual void Transform(ScDocument& rDoc) override; +}; + } #endif commit 03b55edc3e7ca0fc3ff842e6ca1f4e7477a4d6a2 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Tue Aug 15 19:08:08 2017 +0200 external data: add the deterministic mode also for html Change-Id: If253b2ff2b4f38ba45a2be7f66dfbcb65ed9be74 Reviewed-on: https://gerrit.libreoffice.org/41196 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrh...@googlemail.com> diff --git a/sc/source/ui/dataprovider/htmldataprovider.cxx b/sc/source/ui/dataprovider/htmldataprovider.cxx index 4353d59e0364..61160c07d309 100644 --- a/sc/source/ui/dataprovider/htmldataprovider.cxx +++ b/sc/source/ui/dataprovider/htmldataprovider.cxx @@ -215,6 +215,7 @@ HTMLDataProvider::~HTMLDataProvider() { if (mxHTMLFetchThread.is()) { + SolarMutexReleaser aReleaser; mxHTMLFetchThread->join(); } } @@ -229,6 +230,12 @@ void HTMLDataProvider::Import() mpDoc->ResetClip(mpDocument, (SCTAB)0); mxHTMLFetchThread = new HTMLFetchThread(*mpDoc, maURL, maID, &maIdle); mxHTMLFetchThread->launch(); + + if (mbDeterministic) + { + SolarMutexReleaser aReleaser; + mxHTMLFetchThread->join(); + } } IMPL_LINK_NOARG(HTMLDataProvider, ImportFinishedHdl, Timer*, void) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits