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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Nov 14 02:50:52 UTC 2018


 framework/qa/complex/api_internal/api.lst                          |    1 
 include/test/container/xenumeration.hxx                            |   36 ++
 qadevOOo/Jar_OOoRunner.mk                                          |    1 
 qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellsEnumeration.csv |    2 
 qadevOOo/tests/java/mod/_sc/ScCellsEnumeration.java                |  137 ----------
 sc/CppunitTest_sc_cellsenumeration.mk                              |   43 +++
 sc/Module_sc.mk                                                    |    1 
 sc/qa/extras/sccellsenumeration.cxx                                |  105 +++++++
 sc/qa/unoapi/sc_3.sce                                              |    1 
 test/Library_subsequenttest.mk                                     |    1 
 test/source/container/xenumeration.cxx                             |   43 +++
 11 files changed, 229 insertions(+), 142 deletions(-)

New commits:
commit 13dd6c26658727ec72b6fa2f7129a0e283ff1ec6
Author:     Jens Carl <j.carl43 at gmx.de>
AuthorDate: Tue Nov 13 15:24:11 2018 -0800
Commit:     Jens Carl <j.carl43 at gmx.de>
CommitDate: Wed Nov 14 03:50:27 2018 +0100

    tdf#45904 Move _XEnumeration for ScCellsEnumeration to C++
    
    Change-Id: Ic7c8e6a9fe777d16a98da89e00f1f52128ac1b5d
    Reviewed-on: https://gerrit.libreoffice.org/63351
    Tested-by: Jenkins
    Reviewed-by: Jens Carl <j.carl43 at gmx.de>

diff --git a/framework/qa/complex/api_internal/api.lst b/framework/qa/complex/api_internal/api.lst
index 16f62d91d653..d886419b28fd 100644
--- a/framework/qa/complex/api_internal/api.lst
+++ b/framework/qa/complex/api_internal/api.lst
@@ -82,7 +82,6 @@ job82=sc.ScCellFieldsObj
 job83=sc.ScCellFormatsEnumeration
 job84=sc.ScCellFormatsObj
 job85=sc.ScCellSearchObj
-job86=sc.ScCellsEnumeration
 job87=sc.ScCellsObj
 job88=sc.ScDatabaseRangeObj
 job89=sc.ScDatabaseRangesObj
diff --git a/include/test/container/xenumeration.hxx b/include/test/container/xenumeration.hxx
new file mode 100644
index 000000000000..889519229e63
--- /dev/null
+++ b/include/test/container/xenumeration.hxx
@@ -0,0 +1,36 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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_CONTAINER_XENUMERAION_HXX
+#define INCLUDED_TEST_CONTAINER_XENUMERAION_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 XEnumeration
+{
+public:
+    virtual css::uno::Reference<css::uno::XInterface> init() = 0;
+
+    void testHasMoreElements();
+    void testNextElement();
+
+protected:
+    ~XEnumeration() {}
+};
+} // namespace apitest
+
+#endif // INCLUDED_TEST_CONTAINER_XENUMERAION_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/qadevOOo/Jar_OOoRunner.mk b/qadevOOo/Jar_OOoRunner.mk
index bd528d0cc5f1..811627a1b389 100644
--- a/qadevOOo/Jar_OOoRunner.mk
+++ b/qadevOOo/Jar_OOoRunner.mk
@@ -968,7 +968,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\
     qadevOOo/tests/java/mod/_sc/ScCellRangeObj \
     qadevOOo/tests/java/mod/_sc/ScCellRangesObj \
     qadevOOo/tests/java/mod/_sc/ScCellSearchObj \
-    qadevOOo/tests/java/mod/_sc/ScCellsEnumeration \
     qadevOOo/tests/java/mod/_sc/ScCellsObj \
     qadevOOo/tests/java/mod/_sc/ScCellTextCursor \
     qadevOOo/tests/java/mod/_sc/ScChartObj \
diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellsEnumeration.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellsEnumeration.csv
deleted file mode 100644
index c4b6df4c5e94..000000000000
--- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScCellsEnumeration.csv
+++ /dev/null
@@ -1,2 +0,0 @@
-"ScCellsEnumeration";"com::sun::star::container::XEnumeration";"hasMoreElements()"
-"ScCellsEnumeration";"com::sun::star::container::XEnumeration";"nextElement()"
diff --git a/qadevOOo/tests/java/mod/_sc/ScCellsEnumeration.java b/qadevOOo/tests/java/mod/_sc/ScCellsEnumeration.java
deleted file mode 100644
index 48f4adf7713f..000000000000
--- a/qadevOOo/tests/java/mod/_sc/ScCellsEnumeration.java
+++ /dev/null
@@ -1,137 +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 mod._sc;
-
-import java.io.PrintWriter;
-
-import lib.TestCase;
-import lib.TestEnvironment;
-import lib.TestParameters;
-import util.SOfficeFactory;
-
-import com.sun.star.container.XEnumerationAccess;
-import com.sun.star.container.XIndexAccess;
-import com.sun.star.lang.XComponent;
-import com.sun.star.sheet.XCellRangesQuery;
-import com.sun.star.sheet.XSheetCellRanges;
-import com.sun.star.sheet.XSpreadsheetDocument;
-import com.sun.star.sheet.XSpreadsheets;
-import com.sun.star.table.XCell;
-import com.sun.star.table.XCellRange;
-import com.sun.star.text.XTextRange;
-import com.sun.star.uno.AnyConverter;
-import com.sun.star.uno.Type;
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.XInterface;
-
-/**
-* Test for object which is represented by service
-* <code>com.sun.star.sheet.CellsEnumeration</code>. <p>
-* Object implements the following interfaces :
-* <ul>
-*  <li> <code>com::sun::star::container::XEnumeration</code></li>
-* </ul>
-* @see com.sun.star.sheet.CellsEnumeration
-* @see com.sun.star.container.XEnumeration
-* @see ifc.container._XEnumeration
-*/
-public class ScCellsEnumeration extends TestCase {
-    private XSpreadsheetDocument xSheetDoc = null;
-
-    /**
-    * Creates Spreadsheet document.
-    */
-    @Override
-    protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception {
-        SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() );
-        log.println( "creating a Spreadsheet document" );
-        xSheetDoc = SOF.createCalcDoc(null);
-    }
-
-    /**
-    * Disposes Spreadsheet document.
-    */
-    @Override
-    protected void cleanup( TestParameters tParam, PrintWriter log ) {
-        log.println( "    disposing xSheetDoc " );
-        XComponent oComp = UnoRuntime.queryInterface (XComponent.class, xSheetDoc) ;
-        util.DesktopTools.closeDoc(oComp);
-    }
-
-    /**
-    * Creating a TestEnvironment for the interfaces to be tested.
-    * Retrieves a collection of spreadsheets from a document
-    * and takes one of them. Replaces text of some cells.
-    * Retrieves a cell range of the visible cells using the interface
-    * <code>XCellRangesQuery</code>. Retrieves a collection of cells from
-    * this cell range and creates it's enumeration using the interface
-    * <code>XEnumerationAccess</code>.The created enumeration is the instance
-    * of the service <code>com.sun.star.sheet.CellsEnumeration</code>.
-    * Object relations created :
-    * <ul>
-    *  <li> <code>'ENUM'</code> for
-    *      {@link ifc.container._XEnumeration} (type of
-    *      <code>XEnumerationAccess</code> that was retrieved from the
-    *      collection of visible cells)</li>
-    * </ul>
-    * @see com.sun.star.sheet.XCellRangesQuery
-    * @see com.sun.star.container.XEnumerationAccess
-    */
-    @Override
-    protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception {
-
-        XInterface oObj = null;
-        Object cellArr[] = new Object[3] ;
-        XEnumerationAccess oEnum = null;
-
-        // creation of testobject here
-        XSpreadsheets oSheets = xSheetDoc.getSheets();
-        XIndexAccess oIndexAccess = UnoRuntime.queryInterface(XIndexAccess.class, oSheets);
-        XCellRange oSheet = null;
-        oSheet = (XCellRange) AnyConverter.toObject(
-                new Type(XCellRange.class),oIndexAccess.getByIndex(0));
-
-        XCell oCell_1 = oSheet.getCellByPosition(0, 0);
-        XTextRange oTextRange = UnoRuntime.queryInterface(XTextRange.class, oCell_1);
-        oTextRange.setString("Test string 1");
-
-        XCell oCell_2 = oSheet.getCellByPosition(5, 1);
-        oCell_2.setValue(15);
-
-        XCell oCell_3 = oSheet.getCellByPosition(3, 9);
-        oTextRange = UnoRuntime.queryInterface(XTextRange.class, oCell_3);
-        oTextRange.setString("test 2");
-        cellArr[0] = oCell_1;
-        cellArr[1] = oCell_2;
-        cellArr[2] = oCell_3;
-
-        XCellRangesQuery oCellRangesQuery = UnoRuntime.queryInterface(XCellRangesQuery.class, oSheet);
-        XSheetCellRanges oSheetCellRanges = oCellRangesQuery.queryVisibleCells();
-        oEnum = oSheetCellRanges.getCells();
-        oObj = oSheetCellRanges.getCells().createEnumeration();
-
-        TestEnvironment tEnv = new TestEnvironment(oObj);
-
-        // ENUM: XEnumeration
-        tEnv.addObjRelation("ENUM", oEnum);
-
-        return tEnv;
-    }
-
-}    // finish class ScCellsEnumeration
-
diff --git a/sc/CppunitTest_sc_cellsenumeration.mk b/sc/CppunitTest_sc_cellsenumeration.mk
new file mode 100644
index 000000000000..892370b74f6c
--- /dev/null
+++ b/sc/CppunitTest_sc_cellsenumeration.mk
@@ -0,0 +1,43 @@
+# -*- 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_cellsenumeration))
+
+$(eval $(call gb_CppunitTest_use_external,sc_cellsenumeration,boost_headers))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sc_cellsenumeration, \
+	sc/qa/extras/sccellsenumeration \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sc_cellsenumeration, \
+	cppu \
+	sal \
+	subsequenttest \
+	test \
+	unotest \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sc_cellsenumeration,\
+	$$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,sc_cellsenumeration))
+
+$(eval $(call gb_CppunitTest_use_ure,sc_cellsenumeration))
+$(eval $(call gb_CppunitTest_use_vcl,sc_cellsenumeration))
+
+$(eval $(call gb_CppunitTest_use_components,sc_cellsenumeration,\
+    $(sc_unoapi_common_components) \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,sc_cellsenumeration))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk
index b6730d613549..be0d64347c4f 100644
--- a/sc/Module_sc.mk
+++ b/sc/Module_sc.mk
@@ -112,6 +112,7 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sc,\
 	CppunitTest_sc_cellobj \
 	CppunitTest_sc_cellrangeobj \
 	CppunitTest_sc_cellrangesobj \
+	CppunitTest_sc_cellsenumeration \
 	CppunitTest_sc_chart2dataprovider \
 	CppunitTest_sc_check_data_pilot_field \
 	CppunitTest_sc_check_data_pilot_table \
diff --git a/sc/qa/extras/sccellsenumeration.cxx b/sc/qa/extras/sccellsenumeration.cxx
new file mode 100644
index 000000000000..2cc420a87887
--- /dev/null
+++ b/sc/qa/extras/sccellsenumeration.cxx
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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/container/xenumeration.hxx>
+
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/sheet/XCellRangesQuery.hpp>
+#include <com/sun/star/sheet/XSheetCellRanges.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheets.hpp>
+#include <com/sun/star/table/XCell.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/text/XTextRange.hpp>
+#include <com/sun/star/uno/XInterface.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+using namespace css;
+using namespace css::uno;
+
+namespace sc_apitest
+{
+class ScCellsEnumeration : public CalcUnoApiTest, public apitest::XEnumeration
+{
+public:
+    ScCellsEnumeration();
+
+    virtual uno::Reference<uno::XInterface> init() override;
+    virtual void setUp() override;
+    virtual void tearDown() override;
+
+    CPPUNIT_TEST_SUITE(ScCellsEnumeration);
+
+    // XEnumeration
+    CPPUNIT_TEST(testHasMoreElements);
+    CPPUNIT_TEST(testNextElement);
+
+    CPPUNIT_TEST_SUITE_END();
+
+private:
+    uno::Reference<lang::XComponent> m_xComponent;
+};
+
+ScCellsEnumeration::ScCellsEnumeration()
+    : CalcUnoApiTest("/sc/qa/extras/testdocuments")
+{
+}
+
+uno::Reference<uno::XInterface> ScCellsEnumeration::init()
+{
+    uno::Reference<sheet::XSpreadsheetDocument> xDoc(m_xComponent, uno::UNO_QUERY_THROW);
+    CPPUNIT_ASSERT_MESSAGE("no calc document", xDoc.is());
+
+    uno::Reference<sheet::XSpreadsheets> xSheets(xDoc->getSheets(), uno::UNO_QUERY_THROW);
+    uno::Reference<container::XIndexAccess> xIA(xSheets, uno::UNO_QUERY_THROW);
+
+    uno::Reference<table::XCellRange> xCellRange(xIA->getByIndex(0), uno::UNO_QUERY_THROW);
+    uno::Reference<table::XCell> xCell0(xCellRange->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
+    uno::Reference<text::XTextRange> xTextRange0(xCell0, uno::UNO_QUERY_THROW);
+    xTextRange0->setString("Test string 1");
+
+    uno::Reference<table::XCell> xCell1(xCellRange->getCellByPosition(5, 1), uno::UNO_QUERY_THROW);
+    xCell1->setValue(15);
+
+    uno::Reference<table::XCell> xCell2(xCellRange->getCellByPosition(3, 9), uno::UNO_QUERY_THROW);
+    uno::Reference<text::XTextRange> xTextRange1(xCell2, uno::UNO_QUERY_THROW);
+    xTextRange1->setString("Test string 2");
+
+    uno::Reference<sheet::XCellRangesQuery> xCellRangesQuery(xCellRange, uno::UNO_QUERY_THROW);
+    uno::Reference<sheet::XSheetCellRanges> xSCR(xCellRangesQuery->queryVisibleCells(),
+                                                 uno::UNO_QUERY_THROW);
+
+    return xSCR->getCells()->createEnumeration();
+}
+
+void ScCellsEnumeration::setUp()
+{
+    CalcUnoApiTest::setUp();
+    m_xComponent = loadFromDesktop("private:factory/scalc");
+    CPPUNIT_ASSERT_MESSAGE("no component", m_xComponent.is());
+}
+
+void ScCellsEnumeration::tearDown()
+{
+    closeDocument(m_xComponent);
+    CalcUnoApiTest::tearDown();
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ScCellsEnumeration);
+
+} // namespace sc_apitest
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sc/qa/unoapi/sc_3.sce b/sc/qa/unoapi/sc_3.sce
index ba1f28f1746a..a32b6e907168 100644
--- a/sc/qa/unoapi/sc_3.sce
+++ b/sc/qa/unoapi/sc_3.sce
@@ -19,7 +19,6 @@
 -o sc.ScCellRangesObj
 -o sc.ScCellSearchObj
 -o sc.ScCellTextCursor
--o sc.ScCellsEnumeration
 -o sc.ScCellsObj
 -o sc.ScChartObj
 -o sc.ScChartsObj
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index cf30238f7d71..c8a125c38f51 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -43,6 +43,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
 	test/source/beans/xpropertyset \
 	test/source/container/xchild \
 	test/source/container/xelementaccess \
+	test/source/container/xenumeration \
 	test/source/container/xenumerationaccess \
 	test/source/container/xindexaccess \
 	test/source/container/xnamecontainer \
diff --git a/test/source/container/xenumeration.cxx b/test/source/container/xenumeration.cxx
new file mode 100644
index 000000000000..e102a6deb1dd
--- /dev/null
+++ b/test/source/container/xenumeration.cxx
@@ -0,0 +1,43 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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/container/xenumeration.hxx>
+
+#include <com/sun/star/container/NoSuchElementException.hpp>
+#include <com/sun/star/container/XEnumeration.hpp>
+
+#include <com/sun/star/uno/Reference.hxx>
+
+#include <cppunit/extensions/HelperMacros.h>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+
+namespace apitest
+{
+void XEnumeration::testHasMoreElements()
+{
+    uno::Reference<container::XEnumeration> xEnumeration(init(), uno::UNO_QUERY_THROW);
+    CPPUNIT_ASSERT(xEnumeration->hasMoreElements());
+}
+
+void XEnumeration::testNextElement()
+{
+    uno::Reference<container::XEnumeration> xEnumeration(init(), uno::UNO_QUERY_THROW);
+
+    // unwind all elements from the enumeration
+    while (xEnumeration->hasMoreElements())
+        CPPUNIT_ASSERT_NO_THROW(xEnumeration->nextElement());
+
+    CPPUNIT_ASSERT_THROW_MESSAGE("Incorrect exception", xEnumeration->nextElement(),
+                                 container::NoSuchElementException);
+}
+} // namespace apitest
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */


More information about the Libreoffice-commits mailing list