[Libreoffice-commits] core.git: sc/CppunitTest_sc_datatransformation.mk sc/Module_sc.mk sc/qa sc/source

Markus Mohrhard markus.mohrhard at googlemail.com
Mon Aug 14 20:11:07 UTC 2017


 sc/CppunitTest_sc_datatransformation.mk |  126 ++++++++++++++++++++++++++++++++
 sc/Module_sc.mk                         |    1 
 sc/qa/unit/datatransformation_test.cxx  |  105 ++++++++++++++++++++++++++
 sc/source/ui/inc/datatransformation.hxx |    5 -
 4 files changed, 235 insertions(+), 2 deletions(-)

New commits:
commit cf410b712b069455f598ad3f8cdaa7bc37411c9d
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Aug 14 17:06:05 2017 +0200

    external data: add first test for data transformations
    
    Change-Id: I300cf3b9f094c912eb4b7618e405ad320e43e008
    Reviewed-on: https://gerrit.libreoffice.org/41147
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/CppunitTest_sc_datatransformation.mk b/sc/CppunitTest_sc_datatransformation.mk
new file mode 100644
index 000000000000..b65d315bb944
--- /dev/null
+++ b/sc/CppunitTest_sc_datatransformation.mk
@@ -0,0 +1,126 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_CppunitTest_CppunitTest,sc_datatransformation))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sc_datatransformation, \
+    sc/qa/unit/datatransformation_test \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,sc_datatransformation, \
+	boost_headers \
+	mdds_headers \
+	libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sc_datatransformation, \
+    basegfx \
+    comphelper \
+    cppu \
+    cppuhelper \
+    drawinglayer \
+    editeng \
+    for \
+    forui \
+    i18nlangtag \
+    msfilter \
+    oox \
+    sal \
+    salhelper \
+    sax \
+    sb \
+    sc \
+    scqahelper \
+    sfx \
+    sot \
+    subsequenttest \
+    svl \
+    svt \
+    svx \
+    svxcore \
+	test \
+    tk \
+    tl \
+    ucbhelper \
+	unotest \
+    utl \
+    vbahelper \
+    vcl \
+    xo \
+	$(gb_UWINAPI) \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sc_datatransformation,\
+    -I$(SRCDIR)/sc/source/ui/inc \
+    -I$(SRCDIR)/sc/inc \
+	-I$(SRCDIR)/sc/source/filter/inc \
+    $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_custom_headers,sc_datatransformation,\
+	officecfg/registry \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,sc_datatransformation))
+
+$(eval $(call gb_CppunitTest_use_ure,sc_datatransformation))
+$(eval $(call gb_CppunitTest_use_vcl,sc_datatransformation))
+
+$(eval $(call gb_CppunitTest_use_components,sc_datatransformation,\
+	basic/util/sb \
+    chart2/source/chartcore \
+    chart2/source/controller/chartcontroller \
+    comphelper/util/comphelp \
+    configmgr/source/configmgr \
+    dbaccess/util/dba \
+    embeddedobj/util/embobj \
+    eventattacher/source/evtatt \
+    filter/source/config/cache/filterconfig1 \
+    forms/util/frm \
+    framework/util/fwk \
+    i18npool/source/search/i18nsearch \
+    i18npool/util/i18npool \
+    linguistic/source/lng \
+    oox/util/oox \
+    package/source/xstor/xstor \
+    package/util/package2 \
+    sax/source/expatwrap/expwrap \
+    scaddins/source/analysis/analysis \
+    scaddins/source/datefunc/date \
+    sc/util/sc \
+    sc/util/scfilt \
+    sfx2/util/sfx \
+    sot/util/sot \
+    svl/util/svl \
+    svl/source/fsstor/fsstorage \
+    svtools/util/svt \
+    toolkit/util/tk \
+    ucb/source/core/ucb1 \
+    ucb/source/ucp/file/ucpfile1 \
+    ucb/source/ucp/tdoc/ucptdoc1 \
+    unotools/util/utl \
+    unoxml/source/rdf/unordf \
+    unoxml/source/service/unoxml \
+    uui/util/uui \
+    xmloff/util/xo \
+    xmlsecurity/util/xmlsecurity \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,sc_datatransformation,\
+	orcus \
+	orcus-parser \
+	boost_filesystem \
+	boost_system \
+	boost_iostreams \
+	zlib \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,sc_datatransformation))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index 0526764df2c5..6db1bd21224b 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -44,6 +44,7 @@ $(eval $(call gb_Module_add_check_targets,sc,\
 	CppunitTest_sc_mark_test \
 	CppunitTest_sc_core \
 	CppunitTest_sc_dataprovider \
+	CppunitTest_sc_datatransformation \
 ))
 
 ifneq ($(ENABLE_HEADLESS),TRUE)
diff --git a/sc/qa/unit/datatransformation_test.cxx b/sc/qa/unit/datatransformation_test.cxx
new file mode 100644
index 000000000000..a894edbaa3c8
--- /dev/null
+++ b/sc/qa/unit/datatransformation_test.cxx
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <rtl/ustring.hxx>
+
+#include "helper/qahelper.hxx"
+#include "document.hxx"
+#include <stringutil.hxx>
+#include "address.hxx"
+#include "dataprovider.hxx"
+#include "datatransformation.hxx"
+#include <vcl/scheduler.hxx>
+
+#include <memory>
+
+class ScDataTransformationTest : public ScBootstrapFixture
+{
+public:
+
+    ScDataTransformationTest();
+
+    virtual void setUp() override;
+    virtual void tearDown() override;
+
+    void testColumnRemove();
+
+    CPPUNIT_TEST_SUITE(ScDataTransformationTest);
+    CPPUNIT_TEST(testColumnRemove);
+    CPPUNIT_TEST_SUITE_END();
+
+private:
+    ScDocShellRef m_xDocShell;
+    ScDocument *m_pDoc;
+};
+
+void ScDataTransformationTest::testColumnRemove()
+{
+    for (SCROW nRow = 0; nRow < 10; ++nRow)
+    {
+        for (SCCOL nCol = 0; nCol < 10; ++nCol)
+        {
+            m_pDoc->SetValue(nCol, nRow, 0, nRow*nCol);
+        }
+    }
+
+    sc::ColumnRemoveTransformation aTransformation(5);
+    aTransformation.Transform(*m_pDoc);
+
+    for (SCROW nRow = 0; nRow < 10; ++nRow)
+    {
+        for (SCCOL nCol = 0; nCol < 9; ++nCol)
+        {
+            double nVal = m_pDoc->GetValue(nCol, nRow, 0);
+            if (nCol < 5)
+            {
+                ASSERT_DOUBLES_EQUAL((double)(nCol)*nRow, nVal);
+            }
+            else
+            {
+                ASSERT_DOUBLES_EQUAL((double)(nCol+1)*nRow, nVal);
+            }
+        }
+    }
+}
+
+ScDataTransformationTest::ScDataTransformationTest() :
+    ScBootstrapFixture( "/sc/qa/unit/data/dataprovider" ),
+    m_pDoc(nullptr)
+{
+}
+
+void ScDataTransformationTest::setUp()
+{
+    ScBootstrapFixture::setUp();
+
+    ScDLL::Init();
+    m_xDocShell = new ScDocShell(
+        SfxModelFlags::EMBEDDED_OBJECT |
+        SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS |
+        SfxModelFlags::DISABLE_DOCUMENT_RECOVERY);
+
+    m_xDocShell->SetIsInUcalc();
+    m_xDocShell->DoInitUnitTest();
+    m_pDoc = &m_xDocShell->GetDocument();
+    m_pDoc->InsertTab(0, "Tab");
+}
+
+void ScDataTransformationTest::tearDown()
+{
+    m_xDocShell->DoClose();
+    m_xDocShell.clear();
+    ScBootstrapFixture::tearDown();
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScDataTransformationTest);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dataprovider/datatransformation.hxx b/sc/source/ui/inc/datatransformation.hxx
similarity index 86%
rename from sc/source/ui/dataprovider/datatransformation.hxx
rename to sc/source/ui/inc/datatransformation.hxx
index cbe181aa921d..44882f0f09d3 100644
--- a/sc/source/ui/dataprovider/datatransformation.hxx
+++ b/sc/source/ui/inc/datatransformation.hxx
@@ -11,12 +11,13 @@
 #define INCLUDED_SC_SOURCE_UI_DATAPROVIDER_DATATRANSFORMATION_HXX
 
 #include <address.hxx>
+#include <scdllapi.h>
 
 class ScDocument;
 
 namespace sc {
 
-class DataTransformation
+class SC_DLLPUBLIC DataTransformation
 {
 public:
     virtual ~DataTransformation();
@@ -24,7 +25,7 @@ public:
     virtual void Transform(ScDocument& rDoc) = 0;
 };
 
-class ColumnRemoveTransformation : public DataTransformation
+class SC_DLLPUBLIC ColumnRemoveTransformation : public DataTransformation
 {
     SCCOL mnCol;
 


More information about the Libreoffice-commits mailing list