[Libreoffice-commits] core.git: include/test qadevOOo/Jar_OOoRunner.mk qadevOOo/objdsc qadevOOo/tests sc/CppunitTest_sc_cellrangesobj.mk sc/Module_sc.mk sc/qa test/Library_subsequenttest.mk test/source

Jens Carl j.carl43 at gmx.de
Sun Oct 29 22:44:54 UTC 2017


 include/test/sheet/xsheetoperation.hxx                          |   37 +++
 qadevOOo/Jar_OOoRunner.mk                                       |    1 
 qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellCursorObj.csv |    2 
 qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangeObj.csv  |    2 
 qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangesObj.csv |    2 
 qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableSheetObj.csv |    2 
 qadevOOo/tests/java/ifc/sheet/_XSheetOperation.java             |   95 --------
 sc/CppunitTest_sc_cellrangesobj.mk                              |  105 +++++++++
 sc/Module_sc.mk                                                 |    1 
 sc/qa/extras/sccellcursorobj.cxx                                |   21 +
 sc/qa/extras/sccellrangeobj.cxx                                 |   28 +-
 sc/qa/extras/sccellrangesobj.cxx                                |  115 ++++++++++
 sc/qa/extras/sctablesheetobj.cxx                                |    8 
 test/Library_subsequenttest.mk                                  |    1 
 test/source/sheet/xsheetoperation.cxx                           |   44 +++
 15 files changed, 343 insertions(+), 121 deletions(-)

New commits:
commit a0b7cd137aac7529b328c813b011166a78074cb4
Author: Jens Carl <j.carl43 at gmx.de>
Date:   Thu Oct 19 08:19:39 2017 +0000

    tdf#45904: Move Java _XSheetOperation tests to C++
    
    Change-Id: I5aaeebd074882bb05a78e6d4057162e1da61d673
    Reviewed-on: https://gerrit.libreoffice.org/43539
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/include/test/sheet/xsheetoperation.hxx b/include/test/sheet/xsheetoperation.hxx
new file mode 100644
index 000000000000..ab03d2d451d0
--- /dev/null
+++ b/include/test/sheet/xsheetoperation.hxx
@@ -0,0 +1,37 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_TEST_SHEET_XSHEETOPERATION_HXX
+#define INCLUDED_TEST_SHEET_XSHEETOPERATION_HXX
+
+
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <test/testdllapi.hxx>
+
+namespace apitest {
+
+class OOO_DLLPUBLIC_TEST XSheetOperation
+{
+public:
+    virtual css::uno::Reference< css::uno::XInterface > init() = 0;
+
+    void testComputeFunction();
+    void testClearContents();
+
+protected:
+    ~XSheetOperation() {}
+};
+
+}
+
+#endif // INCLUDED_TEST_SHEET_XSHEETOPERATION_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/qadevOOo/Jar_OOoRunner.mk b/qadevOOo/Jar_OOoRunner.mk
index 93e01587192f..a6ebf3502b72 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -628,7 +628,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
     qadevOOo/tests/java/ifc/sheet/_XSheetFilterableEx \
     qadevOOo/tests/java/ifc/sheet/_XSheetFilterDescriptor \
     qadevOOo/tests/java/ifc/sheet/_XSheetLinkable \
-    qadevOOo/tests/java/ifc/sheet/_XSheetOperation \
     qadevOOo/tests/java/ifc/sheet/_XSpreadsheetView \
     qadevOOo/tests/java/ifc/style/_CharacterProperties \
     qadevOOo/tests/java/ifc/style/_CharacterPropertiesAsian \
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellCursorObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellCursorObj.csv
index 1ed7325b2fca..b58f89f320a8 100644
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellCursorObj.csv
+++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellCursorObj.csv
@@ -108,8 +108,6 @@
 "ScCellCursorObj";"com::sun::star::style::ParagraphProperties";"ParaUserDefinedAttributes#optional"
 "ScCellCursorObj";"com::sun::star::style::ParagraphProperties";"NumberingIsNumber#optional"
 "ScCellCursorObj";"com::sun::star::style::ParagraphProperties";"ParaIsConnectBorder#optional"
-"ScCellCursorObj";"com::sun::star::sheet::XSheetOperation";"computeFunction()"
-"ScCellCursorObj";"com::sun::star::sheet::XSheetOperation";"clearContents()"
 "ScCellCursorObj";"com::sun::star::style::CharacterPropertiesComplex";"CharHeightComplex"
 "ScCellCursorObj";"com::sun::star::style::CharacterPropertiesComplex";"CharWeightComplex"
 "ScCellCursorObj";"com::sun::star::style::CharacterPropertiesComplex";"CharFontNameComplex"
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangeObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangeObj.csv
index 71f5f2647995..a44495862bf6 100644
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangeObj.csv
+++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangeObj.csv
@@ -103,8 +103,6 @@
 "ScCellRangeObj";"com::sun::star::style::ParagraphProperties";"ParaUserDefinedAttributes#optional"
 "ScCellRangeObj";"com::sun::star::style::ParagraphProperties";"NumberingIsNumber#optional"
 "ScCellRangeObj";"com::sun::star::style::ParagraphProperties";"ParaIsConnectBorder#optional"
-"ScCellRangeObj";"com::sun::star::sheet::XSheetOperation";"computeFunction()"
-"ScCellRangeObj";"com::sun::star::sheet::XSheetOperation";"clearContents()"
 "ScCellRangeObj";"com::sun::star::style::CharacterPropertiesComplex";"CharHeightComplex"
 "ScCellRangeObj";"com::sun::star::style::CharacterPropertiesComplex";"CharWeightComplex"
 "ScCellRangeObj";"com::sun::star::style::CharacterPropertiesComplex";"CharFontNameComplex"
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangesObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangesObj.csv
index cfe1f3bfef3b..927dfc3ce333 100644
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangesObj.csv
+++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellRangesObj.csv
@@ -107,8 +107,6 @@
 "ScCellRangesObj";"com::sun::star::style::ParagraphProperties";"ParaUserDefinedAttributes#optional"
 "ScCellRangesObj";"com::sun::star::style::ParagraphProperties";"NumberingIsNumber#optional"
 "ScCellRangesObj";"com::sun::star::style::ParagraphProperties";"ParaIsConnectBorder#optional"
-"ScCellRangesObj";"com::sun::star::sheet::XSheetOperation";"computeFunction()"
-"ScCellRangesObj";"com::sun::star::sheet::XSheetOperation";"clearContents()"
 "ScCellRangesObj";"com::sun::star::style::CharacterPropertiesComplex";"CharHeightComplex"
 "ScCellRangesObj";"com::sun::star::style::CharacterPropertiesComplex";"CharWeightComplex"
 "ScCellRangesObj";"com::sun::star::style::CharacterPropertiesComplex";"CharFontNameComplex"
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableSheetObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableSheetObj.csv
index 8f7c54adaa3d..16ddec448d96 100644
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableSheetObj.csv
+++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableSheetObj.csv
@@ -104,8 +104,6 @@
 "ScTableSheetObj";"com::sun::star::style::ParagraphProperties";"ParaUserDefinedAttributes#optional"
 "ScTableSheetObj";"com::sun::star::style::ParagraphProperties";"NumberingIsNumber#optional"
 "ScTableSheetObj";"com::sun::star::style::ParagraphProperties";"ParaIsConnectBorder#optional"
-"ScTableSheetObj";"com::sun::star::sheet::XSheetOperation";"computeFunction()"
-"ScTableSheetObj";"com::sun::star::sheet::XSheetOperation";"clearContents()"
 "ScTableSheetObj";"com::sun::star::style::CharacterPropertiesComplex";"CharHeightComplex"
 "ScTableSheetObj";"com::sun::star::style::CharacterPropertiesComplex";"CharWeightComplex"
 "ScTableSheetObj";"com::sun::star::style::CharacterPropertiesComplex";"CharFontNameComplex"
diff --git a/qadevOOo/tests/java/ifc/sheet/_XSheetOperation.java b/qadevOOo/tests/java/ifc/sheet/_XSheetOperation.java
deleted file mode 100644
index e01ac2e5fd62..000000000000
--- a/qadevOOo/tests/java/ifc/sheet/_XSheetOperation.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-package ifc.sheet;
-
-import lib.MultiMethodTest;
-
-import com.sun.star.sheet.CellFlags;
-import com.sun.star.sheet.GeneralFunction;
-import com.sun.star.sheet.XSheetOperation;
-
-/**
-* Testing <code>com.sun.star.sheet.XSheetOperation</code>
-* interface methods :
-* <ul>
-*  <li><code> computeFunction()</code></li>
-*  <li><code> clearContents()</code></li>
-* </ul> <p>
-* @see com.sun.star.sheet.XSheetOperation
-*/
-public class _XSheetOperation extends MultiMethodTest {
-
-    public XSheetOperation oObj = null;
-
-    /**
-    * Test clears formula and value contents, calls the method
-    * <code>computeFunction</code> and checks returned value. <p>
-    * Has <b> OK </b> status if returned value is equal to zero
-    * and no exceptions were thrown. <p>
-    */
-    public void _clearContents() {
-        boolean result = true;
-        double resultVal = -1;
-
-        log.println("Testing clearContents() ...");
-
-        int allFlags;
-        allFlags = CellFlags.VALUE | CellFlags.FORMULA;
-
-        oObj.clearContents (allFlags) ;
-
-        try {
-            resultVal = oObj.computeFunction(GeneralFunction.SUM);
-            result &= (resultVal == 0.0) || (resultVal == 0);
-        } catch (com.sun.star.uno.Exception e) {
-            result &= false ;
-            log.println(
-                    "Exception occurred while checking results of method");
-            e.printStackTrace(log);
-        }
-
-        tRes.tested("clearContents()", result);
-
-    } // finished clearContents
-
-    /**
-    * Test calls the method and checks returned value. <p>
-    * Has <b> OK </b> status if returned value is equal or greater than zero
-    * and no exceptions were thrown. <p>
-    */
-    public void _computeFunction() {
-
-        log.println("Testing computeFunction() ...");
-        double resultVal = -1;
-        boolean result = true;
-
-        try {
-            resultVal = oObj.computeFunction (GeneralFunction.COUNT) ;
-            result = resultVal >= 0;
-        } catch (com.sun.star.uno.Exception e) {
-            result = false;
-            log.println("Exception occurred in method computeFunction.");
-            e.printStackTrace(log);
-        }
-
-        tRes.tested("computeFunction()", result);
-    } // finished computeFunction
-
-} // finished class _XSheetOperation
-
diff --git a/sc/CppunitTest_sc_cellrangesobj.mk b/sc/CppunitTest_sc_cellrangesobj.mk
new file mode 100644
index 000000000000..792f0dac3334
--- /dev/null
+++ b/sc/CppunitTest_sc_cellrangesobj.mk
@@ -0,0 +1,105 @@
+# -*- 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_cellrangesobj))
+
+$(eval $(call gb_CppunitTest_use_external,sc_cellrangesobj,boost_headers))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sc_cellrangesobj, \
+	sc/qa/extras/sccellrangesobj\
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sc_cellrangesobj, \
+	basegfx \
+	comphelper \
+	cppu \
+	cppuhelper \
+	drawinglayer \
+	editeng \
+	for \
+	forui \
+	i18nlangtag \
+	msfilter \
+	oox \
+	sal \
+	salhelper \
+	sax \
+	sb \
+	sc \
+	sfx \
+	sot \
+	subsequenttest \
+	svl \
+	svt \
+	svx \
+	svxcore \
+	test \
+	tk \
+	tl \
+	ucbhelper \
+	unotest \
+	utl \
+	vbahelper \
+	vcl \
+	xo \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sc_cellrangesobj,\
+	-I$(SRCDIR)/sc/source/ui/inc \
+	-I$(SRCDIR)/sc/inc \
+	$$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,sc_cellrangesobj))
+
+$(eval $(call gb_CppunitTest_use_ure,sc_cellrangesobj))
+$(eval $(call gb_CppunitTest_use_vcl,sc_cellrangesobj))
+
+$(eval $(call gb_CppunitTest_use_components,sc_cellrangesobj,\
+	basic/util/sb \
+	comphelper/util/comphelp \
+	configmgr/source/configmgr \
+	dbaccess/util/dba \
+	filter/source/config/cache/filterconfig1 \
+	filter/source/storagefilterdetect/storagefd \
+	forms/util/frm \
+	framework/util/fwk \
+	i18npool/source/search/i18nsearch \
+	i18npool/util/i18npool \
+	oox/util/oox \
+	package/source/xstor/xstor \
+	package/util/package2 \
+	sax/source/expatwrap/expwrap \
+	scripting/source/basprov/basprov \
+	scripting/util/scriptframe \
+	sc/util/sc \
+	sc/util/scd \
+	sc/util/scfilt \
+	$(call gb_Helper_optional,SCRIPTING, \
+		sc/util/vbaobj) \
+	sfx2/util/sfx \
+	sot/util/sot \
+	svl/source/fsstor/fsstorage \
+	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 \
+	svtools/util/svt \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,sc_cellrangesobj))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index 1c40074b114b..ed4e61855d45 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -132,6 +132,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
 	CppunitTest_sc_datapilotitemobj \
 	CppunitTest_sc_subtotalfieldobj \
 	CppunitTest_sc_arealinksobj \
+	CppunitTest_sc_cellrangesobj \
 ))
 
 $(eval $(call gb_Module_add_perfcheck_targets,sc,\
diff --git a/sc/qa/extras/sccellcursorobj.cxx b/sc/qa/extras/sccellcursorobj.cxx
index 5ccc1722320a..517d4ca41131 100644
--- a/sc/qa/extras/sccellcursorobj.cxx
+++ b/sc/qa/extras/sccellcursorobj.cxx
@@ -9,9 +9,10 @@
 
 #include <test/calc_unoapi_test.hxx>
 #include <test/sheet/xcellseries.hxx>
+#include <test/sheet/xsheetoperation.hxx>
+#include <test/sheet/xsubtotalcalculatable.hxx>
 #include <test/sheet/xusedareacursor.hxx>
 #include <test/sheet/xuniquecellformatrangessupplier.hxx>
-#include <test/sheet/xsubtotalcalculatable.hxx>
 
 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
 #include <com/sun/star/sheet/XSpreadsheet.hpp>
@@ -22,11 +23,13 @@ using namespace css::uno;
 
 namespace sc_apitest {
 
-#define NUMBER_OF_TESTS 7
+#define NUMBER_OF_TESTS 9
 
-class ScCellCursorObj : public CalcUnoApiTest,
-                        public apitest::XCellSeries, public apitest::XUsedAreaCursor,
-                        public apitest::XUniqueCellFormatRangesSupplier, public apitest::XSubTotalCalculatable
+class ScCellCursorObj : public CalcUnoApiTest, public apitest::XCellSeries,
+                                               public apitest::XSheetOperation,
+                                               public apitest::XSubTotalCalculatable,
+                                               public apitest::XUsedAreaCursor,
+                                               public apitest::XUniqueCellFormatRangesSupplier
 {
 public:
     ScCellCursorObj();
@@ -46,13 +49,17 @@ public:
     CPPUNIT_TEST(testFillAuto);
     CPPUNIT_TEST(testFillSeries);
 
-    // XUniqueCellFormatRangesSupplier
-    CPPUNIT_TEST(testGetUniqueCellFormatRanges);
+    // XSheetOperation
+    CPPUNIT_TEST(testComputeFunction);
+    CPPUNIT_TEST(testClearContents);
 
     // XSubTotalCalculatable
     CPPUNIT_TEST(testCreateSubTotalDescriptor);
     CPPUNIT_TEST(testApplyRemoveSubTotals);
 
+    // XUniqueCellFormatRangesSupplier
+    CPPUNIT_TEST(testGetUniqueCellFormatRanges);
+
     CPPUNIT_TEST_SUITE_END();
 
 private:
diff --git a/sc/qa/extras/sccellrangeobj.cxx b/sc/qa/extras/sccellrangeobj.cxx
index a062063c58b4..ad6df24af046 100644
--- a/sc/qa/extras/sccellrangeobj.cxx
+++ b/sc/qa/extras/sccellrangeobj.cxx
@@ -12,8 +12,9 @@
 #include <test/sheet/xcellrangedata.hxx>
 #include <test/sheet/xcellrangesquery.hxx>
 #include <test/sheet/xcellseries.hxx>
-#include <test/sheet/xuniquecellformatrangessupplier.hxx>
+#include <test/sheet/xsheetoperation.hxx>
 #include <test/sheet/xsubtotalcalculatable.hxx>
+#include <test/sheet/xuniquecellformatrangessupplier.hxx>
 #include <test/util/xreplaceable.hxx>
 #include <test/util/xsearchable.hxx>
 
@@ -29,12 +30,17 @@ using namespace css::uno;
 
 namespace sc_apitest {
 
-#define NUMBER_OF_TESTS 20
-
-class ScCellRangeObj : public CalcUnoApiTest, public apitest::XCellRangesQuery, public apitest::CellProperties,
-                        public apitest::XSearchable, public apitest::XReplaceable, public apitest::XCellRangeData,
-                        public apitest::XCellSeries, public apitest::XUniqueCellFormatRangesSupplier,
-                        public apitest::XSubTotalCalculatable
+#define NUMBER_OF_TESTS 22
+
+class ScCellRangeObj : public CalcUnoApiTest, public apitest::CellProperties,
+                                              public apitest::XCellRangeData,
+                                              public apitest::XCellRangesQuery,
+                                              public apitest::XCellSeries,
+                                              public apitest::XReplaceable,
+                                              public apitest::XSearchable,
+                                              public apitest::XSheetOperation,
+                                              public apitest::XSubTotalCalculatable,
+                                              public apitest::XUniqueCellFormatRangesSupplier
 {
 public:
     ScCellRangeObj();
@@ -83,6 +89,10 @@ public:
     // XUniqueCellFormatRangesSupplier
     CPPUNIT_TEST(testGetUniqueCellFormatRanges);
 
+    // XSheetOperation
+    CPPUNIT_TEST(testComputeFunction);
+    CPPUNIT_TEST(testClearContents);
+
     // XSubTotalCalculatable
     CPPUNIT_TEST(testCreateSubTotalDescriptor);
     CPPUNIT_TEST(testApplyRemoveSubTotals);
@@ -99,9 +109,9 @@ uno::Reference< lang::XComponent > ScCellRangeObj::mxComponent;
 
 ScCellRangeObj::ScCellRangeObj():
         CalcUnoApiTest("/sc/qa/extras/testdocuments"),
-        apitest::XSearchable("15", 1),
+        apitest::XCellSeries(2, 1),
         apitest::XReplaceable("15", "35"),
-        apitest::XCellSeries(2, 1)
+        apitest::XSearchable("15", 1)
 {
 }
 
diff --git a/sc/qa/extras/sccellrangesobj.cxx b/sc/qa/extras/sccellrangesobj.cxx
new file mode 100644
index 000000000000..9e8d287e125d
--- /dev/null
+++ b/sc/qa/extras/sccellrangesobj.cxx
@@ -0,0 +1,115 @@
+/* -*- 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 <test/calc_unoapi_test.hxx>
+#include <test/sheet/xsheetoperation.hxx>
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+
+using namespace css;
+using namespace css::uno;
+
+namespace sc_apitest {
+
+#define NUMBER_OF_TESTS 2
+
+class ScCellRangesObj : public CalcUnoApiTest, public apitest::XSheetOperation
+{
+public:
+    ScCellRangesObj();
+
+    virtual void setUp() override;
+    virtual void tearDown() override;
+
+    virtual uno::Reference< uno::XInterface > init() override;
+
+    CPPUNIT_TEST_SUITE(ScCellRangesObj);
+
+    // XSheetOperation
+    CPPUNIT_TEST(testComputeFunction);
+    CPPUNIT_TEST(testClearContents);
+
+    CPPUNIT_TEST_SUITE_END();
+
+private:
+    static sal_Int32 nTest;
+    static uno::Reference< lang::XComponent > mxComponent;
+};
+
+sal_Int32 ScCellRangesObj::nTest = 0;
+uno::Reference< lang::XComponent > ScCellRangesObj::mxComponent;
+
+ScCellRangesObj::ScCellRangesObj():
+    CalcUnoApiTest("/sc/qa/extras/testdocuments")
+{
+}
+
+uno::Reference< uno::XInterface > ScCellRangesObj::init()
+{
+    // create a calc document
+    if (!mxComponent.is())
+        mxComponent = loadFromDesktop("private:factory/scalc");
+
+    uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, uno::UNO_QUERY_THROW);
+    CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc.is());
+
+    uno::Reference< container::XIndexAccess > xIndexAccess(xDoc->getSheets(), uno::UNO_QUERY_THROW);
+    uno::Reference< sheet::XSpreadsheet > xSheet(xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW);
+    uno::Reference< lang::XMultiServiceFactory > xMSF(xDoc, uno::UNO_QUERY_THROW);
+    uno::Reference< container::XNameContainer > xRanges(xMSF->createInstance("com.sun.star.sheet.SheetCellRanges"), uno::UNO_QUERY_THROW);
+
+    //uno::Reference< container::XNameContainer > xRanges(xSheet, uno::UNO_QUERY_THROW);
+    uno::Any xCellRange;
+
+    xCellRange <<= xSheet->getCellRangeByName("C1:D4");
+    xRanges->insertByName("Range1", xCellRange);
+    xCellRange <<= xSheet->getCellRangeByName("E2:F5");
+    xRanges->insertByName("Range2", xCellRange);
+    xCellRange <<= xSheet->getCellRangeByName("G2:H3");
+    xRanges->insertByName("Range3", xCellRange);
+    xCellRange <<= xSheet->getCellRangeByName("I7:J8");
+    xRanges->insertByName("Range4", xCellRange);
+
+
+    return xRanges;
+}
+
+void ScCellRangesObj::setUp()
+{
+    nTest++;
+    CPPUNIT_ASSERT(nTest <= NUMBER_OF_TESTS);
+    CalcUnoApiTest::setUp();
+}
+
+void ScCellRangesObj::tearDown()
+{
+    if (nTest == NUMBER_OF_TESTS)
+    {
+        closeDocument(mxComponent);
+        mxComponent.clear();
+    }
+
+    CalcUnoApiTest::tearDown();
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScCellRangesObj);
+
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/extras/sctablesheetobj.cxx b/sc/qa/extras/sctablesheetobj.cxx
index 8f2a4647d26a..a3b246055965 100644
--- a/sc/qa/extras/sctablesheetobj.cxx
+++ b/sc/qa/extras/sctablesheetobj.cxx
@@ -10,6 +10,7 @@
 #include <test/calc_unoapi_test.hxx>
 #include <test/sheet/xcellseries.hxx>
 #include <test/sheet/xprintareas.hxx>
+#include <test/sheet/xsheetoperation.hxx>
 #include <test/sheet/xsheetpagebreak.hxx>
 #include <test/sheet/xspreadsheet.hxx>
 #include <test/sheet/xsubtotalcalculatable.hxx>
@@ -26,12 +27,13 @@ using namespace css::uno;
 namespace sc_apitest
 {
 
-#define NUMBER_OF_TESTS 17
+#define NUMBER_OF_TESTS 19
 
 class ScTableSheetObj : public CalcUnoApiTest, public apitest::XCellSeries,
                                                public apitest::XPrintAreas,
                                                public apitest::XReplaceable,
                                                public apitest::XSearchable,
+                                               public apitest::XSheetOperation,
                                                public apitest::XSheetPageBreak,
                                                public apitest::XSpreadsheet,
                                                public apitest::XSubTotalCalculatable,
@@ -65,6 +67,10 @@ public:
     CPPUNIT_TEST(testFillAuto);
     CPPUNIT_TEST(testFillSeries);
 
+    // XSheetOperation
+    CPPUNIT_TEST(testComputeFunction);
+    CPPUNIT_TEST(testClearContents);
+
     // XSheetPageBreak
     CPPUNIT_TEST(testGetColumnPageBreaks);
     CPPUNIT_TEST(testGetRowPageBreaks);
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index 76aa87850cbd..98f4ce9d566d 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -71,6 +71,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
 	test/source/sheet/xsheetannotations \
 	test/source/sheet/xsheetannotationshapesupplier \
 	test/source/sheet/xsheetoutline \
+	test/source/sheet/xsheetoperation \
 	test/source/sheet/xsheetpagebreak \
 	test/source/sheet/xstyleloader \
 	test/source/sheet/xsubtotalfield \
diff --git a/test/source/sheet/xsheetoperation.cxx b/test/source/sheet/xsheetoperation.cxx
new file mode 100644
index 000000000000..e85783c89526
--- /dev/null
+++ b/test/source/sheet/xsheetoperation.cxx
@@ -0,0 +1,44 @@
+/* -*- 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 <test/sheet/xsheetoperation.hxx>
+
+#include <com/sun/star/sheet/CellFlags.hpp>
+#include <com/sun/star/sheet/GeneralFunction.hpp>
+#include <com/sun/star/sheet/XSheetOperation.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/extensions/HelperMacros.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest {
+
+void XSheetOperation::testClearContents()
+{
+    uno::Reference< sheet::XSheetOperation > xSheetOperation(init(), UNO_QUERY_THROW);
+
+    xSheetOperation->clearContents( sheet::CellFlags::VALUE | sheet::CellFlags::FORMULA );
+
+    double sum = xSheetOperation->computeFunction( sheet::GeneralFunction_SUM );
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("Unable to clean contents", 0.0, sum);
+}
+
+void XSheetOperation::testComputeFunction()
+{
+    uno::Reference< sheet::XSheetOperation > xSheetOperation(init(), UNO_QUERY_THROW);
+
+    double count = xSheetOperation->computeFunction( sheet::GeneralFunction_COUNT );
+    CPPUNIT_ASSERT_MESSAGE("Unable to compute function", count >= 0.0);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list