Kaydet (Commit) 13dd6c26 authored tarafından Jens Carl's avatar Jens Carl

tdf#45904 Move _XEnumeration for ScCellsEnumeration to C++

Change-Id: Ic7c8e6a9fe777d16a98da89e00f1f52128ac1b5d
Reviewed-on: https://gerrit.libreoffice.org/63351
Tested-by: Jenkins
Reviewed-by: 's avatarJens Carl <j.carl43@gmx.de>
üst 85dba18a
......@@ -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
......
/* -*- 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: */
......@@ -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 \
......
"ScCellsEnumeration";"com::sun::star::container::XEnumeration";"hasMoreElements()"
"ScCellsEnumeration";"com::sun::star::container::XEnumeration";"nextElement()"
/*
* 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
# -*- 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:
......@@ -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 \
......
/* -*- 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: */
......@@ -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
......
......@@ -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 \
......
/* -*- 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: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment