diff options
-rw-r--r-- | include/test/sheet/xcellrangemovement.hxx | 37 | ||||
-rw-r--r-- | qadevOOo/Jar_OOoRunner.mk | 1 | ||||
-rw-r--r-- | qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableSheetObj.csv | 4 | ||||
-rw-r--r-- | qadevOOo/tests/java/ifc/sheet/_XCellRangeMovement.java | 225 | ||||
-rw-r--r-- | sc/qa/extras/sctablesheetobj.cxx | 8 | ||||
-rw-r--r-- | test/Library_subsequenttest.mk | 3 | ||||
-rw-r--r-- | test/source/sheet/xcellrangemovement.cxx | 123 |
7 files changed, 170 insertions, 231 deletions
diff --git a/include/test/sheet/xcellrangemovement.hxx b/include/test/sheet/xcellrangemovement.hxx new file mode 100644 index 000000000000..a95fdf6421e4 --- /dev/null +++ b/include/test/sheet/xcellrangemovement.hxx @@ -0,0 +1,37 @@ +/* -*- 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_SHEET_XCELLRANGEMOVEMENT_HXX +#define INCLUDED_TEST_SHEET_XCELLRANGEMOVEMENT_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 XCellRangeMovement +{ +public: + virtual css::uno::Reference<css::uno::XInterface> init() = 0; + + void testInsertCells(); + void testCopyRange(); + void testMoveRange(); + void testRemoveRange(); + +protected: + ~XCellRangeMovement() {} +}; +} // namespace apitest + +#endif // INCLUDED_TEST_SHEET_XCELLRANGEMOVEMENT_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 9e076552c42e..4f0b38f9400e 100644 --- a/qadevOOo/Jar_OOoRunner.mk +++ b/qadevOOo/Jar_OOoRunner.mk @@ -567,7 +567,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\ qadevOOo/tests/java/ifc/sheet/_SpreadsheetDocument \ qadevOOo/tests/java/ifc/sheet/_TableAutoFormatField \ qadevOOo/tests/java/ifc/sheet/_XCellRangeData \ - qadevOOo/tests/java/ifc/sheet/_XCellRangeMovement \ qadevOOo/tests/java/ifc/sheet/_XCellRangeReferrer \ qadevOOo/tests/java/ifc/sheet/_XCellRangesQuery \ qadevOOo/tests/java/ifc/sheet/_XDocumentAuditing \ 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 62789eeed452..03e907459e78 100644 --- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableSheetObj.csv +++ b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableSheetObj.csv @@ -138,10 +138,6 @@ "ScTableSheetObj";"com::sun::star::beans::XTolerantMultiPropertySet#optional";"getDirectPropertyValuesTolerant()" "ScTableSheetObj";"com::sun::star::container::XNamed";"getName()" "ScTableSheetObj";"com::sun::star::container::XNamed";"setName()" -"ScTableSheetObj";"com::sun::star::sheet::XCellRangeMovement";"insertCells()" -"ScTableSheetObj";"com::sun::star::sheet::XCellRangeMovement";"removeRange()" -"ScTableSheetObj";"com::sun::star::sheet::XCellRangeMovement";"moveRange()" -"ScTableSheetObj";"com::sun::star::sheet::XCellRangeMovement";"copyRange()" "ScTableSheetObj";"com::sun::star::style::CharacterProperties";"CharFontName" "ScTableSheetObj";"com::sun::star::style::CharacterProperties";"CharFontStyleName" "ScTableSheetObj";"com::sun::star::style::CharacterProperties";"CharFontFamily" diff --git a/qadevOOo/tests/java/ifc/sheet/_XCellRangeMovement.java b/qadevOOo/tests/java/ifc/sheet/_XCellRangeMovement.java deleted file mode 100644 index 1d0d33c327e4..000000000000 --- a/qadevOOo/tests/java/ifc/sheet/_XCellRangeMovement.java +++ /dev/null @@ -1,225 +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.CellDeleteMode; -import com.sun.star.sheet.CellInsertMode; -import com.sun.star.sheet.XCellRangeAddressable; -import com.sun.star.sheet.XCellRangeMovement; -import com.sun.star.sheet.XSpreadsheet; -import com.sun.star.table.CellAddress; -import com.sun.star.table.CellRangeAddress; -import com.sun.star.table.XColumnRowRange; -import com.sun.star.table.XTableRows; -import com.sun.star.uno.UnoRuntime; - -/** -* Testing <code>com.sun.star.sheet.XCellRangeMovement</code> -* interface methods : -* <ul> -* <li><code> insertCells()</code></li> -* <li><code> removeRange()</code></li> -* <li><code> moveRange()</code></li> -* <li><code> copyRange()</code></li> -* </ul> <p> -* Test object must implements interfaces <code>XCellRangeAddressable</code> -* and <code>XSpreadsheet</code> also. <p> -* @see com.sun.star.sheet.XCellRangeMovement -* @see com.sun.star.sheet.XSpreadsheet -* @see com.sun.star.sheet.XCellRangeAddressable -*/ -public class _XCellRangeMovement extends MultiMethodTest { - - public XCellRangeMovement oObj = null; - - /** - * Test sets specific values to cells in the range, copies this cell range - * to another position in document and checks cell's values in new position.<p> - * Has <b> OK </b> status if cell's values in source range are equal to - * cell's values in destination range and no exceptions were thrown. <p> - */ - public void _copyRange(){ - log.println("Prepare cells before test methods."); - XSpreadsheet oSheet = UnoRuntime.queryInterface(XSpreadsheet.class, oObj); - try { - oSheet.getCellByPosition(1,1).setValue(100); - oSheet.getCellByPosition(1,2).setValue(200); - oSheet.getCellByPosition(2,1).setValue(300); - oSheet.getCellByPosition(2,2).setValue(400); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - e.printStackTrace(log); - tRes.tested("copyRange()", false); - } - - XCellRangeAddressable oAddr = - UnoRuntime.queryInterface (XCellRangeAddressable.class, oObj); - short iSheet = oAddr.getRangeAddress().Sheet; - CellAddress sDest; - CellRangeAddress sSrc; - - sSrc = new CellRangeAddress(iSheet, 1, 1, 2, 2); - sDest = new CellAddress(iSheet, 1, 10); - boolean result = true; - boolean loc_result = true; - - oObj.copyRange(sDest, sSrc); - try { - loc_result = (oSheet.getCellByPosition(1, 10).getValue() == 100); - loc_result &= (oSheet.getCellByPosition(1, 11).getValue() == 200); - loc_result &= (oSheet.getCellByPosition(2, 10).getValue() == 300); - loc_result &= (oSheet.getCellByPosition(2, 11).getValue() == 400); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - e.printStackTrace(log); - tRes.tested("copyRange()", false); - } - - result &= loc_result; - tRes.tested("copyRange()", result); - } - - /** - * Test sets specific values to cells in the two contiguous rows, inserts - * new empty row between them and checks value in - * one cell of the inserted row. <p> - * Has <b> OK </b> status if value of cell in the inserted row is zero - * and no exceptions were thrown. <p> - */ - public void _insertCells(){ - boolean result = false; - - XSpreadsheet oSheet = UnoRuntime.queryInterface(XSpreadsheet.class, oObj); - XCellRangeAddressable oAddr = UnoRuntime.queryInterface (XCellRangeAddressable.class, oObj); - short iSheet = oAddr.getRangeAddress().Sheet; - try { - oSheet.getCellByPosition(0,20).setValue(100); - oSheet.getCellByPosition(1,20).setValue(100); - oSheet.getCellByPosition(2,20).setValue(100); - oSheet.getCellByPosition(3,20).setValue(100); - oSheet.getCellByPosition(0,21).setValue(200); - oSheet.getCellByPosition(1,21).setValue(200); - oSheet.getCellByPosition(2,21).setValue(200); - oSheet.getCellByPosition(3,21).setValue(200); - - // catch some sleight of hand threads - if (oSheet.getCellByPosition(1,21).getValue() != 200){ - log.println("Cells were already inserted. "+ - "Delete old cells now"); - XColumnRowRange oColumnRowRange = UnoRuntime.queryInterface(XColumnRowRange.class, oSheet); - - XTableRows oRows = oColumnRowRange.getRows(); - oRows.removeByIndex(21,1); - } - CellRangeAddress sSrc = new CellRangeAddress(iSheet, 0, 21, 5, 21); - oObj.insertCells (sSrc, CellInsertMode.DOWN) ; - - // check the result - double res = oSheet.getCellByPosition(1, 21).getValue(); - if (res == 0.0) { - result = true; - } - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - e.printStackTrace(log); - result = false; - } - - tRes.tested("insertCells()", result); - } - - /** - * Test sets specific values to cells in the range, moves this cell range - * to another position in document and checks cell's values in new position. - * <p>Has <b>OK</b> status if sum of values in source range is equal to sum - * of values in destination range and no exceptions were thrown. <p> - */ - public void _moveRange(){ - boolean result = false; - - XSpreadsheet oSheet = UnoRuntime.queryInterface(XSpreadsheet.class, oObj); - - XCellRangeAddressable oAddr = UnoRuntime.queryInterface (XCellRangeAddressable.class, oObj); - - short iSheet = oAddr.getRangeAddress().Sheet; - //prepare source range - try { - oSheet.getCellByPosition(4,0).setValue(111); - oSheet.getCellByPosition(4,1).setValue(222); - - CellRangeAddress sSrc = new CellRangeAddress(iSheet, 4, 0, 4, 1); - CellAddress sDest = new CellAddress(iSheet, 4, 4); - oObj.moveRange(sDest, sSrc); - - double cntA = 0; - double cntB = 0; - cntA = oSheet.getCellByPosition(4, 4).getValue(); - cntB = oSheet.getCellByPosition(4, 5).getValue(); - if (cntA + cntB == 333.0){ result = true; } - //clean up - oSheet.getCellByPosition(4,4).setValue(0); - oSheet.getCellByPosition(4,5).setValue(0); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - e.printStackTrace(log); - result = false; - } - - tRes.tested("moveRange()", result); - } - - - /** - * Test sets specific values to cells in the range, deletes this cell range - * from document and checks values of cells in position - * of the deleted range. - * <p>Has <b>OK</b> status if sum of cell values in position of the deleted - * range is equal to zero and no exceptions were thrown. <p> - */ - public void _removeRange(){ - boolean result = false; - - XSpreadsheet oSheet = UnoRuntime.queryInterface(XSpreadsheet.class, oObj); - XCellRangeAddressable oAddr = UnoRuntime.queryInterface (XCellRangeAddressable.class, oObj); - short iSheet = oAddr.getRangeAddress().Sheet; - try { - //prepare source range - oSheet.getCellByPosition(5, 0).setValue(333); - oSheet.getCellByPosition(5, 1).setValue(444); - - CellRangeAddress sSrc = new CellRangeAddress(iSheet, 5, 0, 5, 1); - oObj.removeRange(sSrc, CellDeleteMode.UP); - - double cntA = 0; - double cntB = 0; - cntA = oSheet.getCellByPosition(5, 0).getValue(); - cntB = oSheet.getCellByPosition(5, 1).getValue(); - if (cntA + cntB == 0.0){ result = true; } - - //clean up - oSheet.getCellByPosition(5, 0).setValue(0); - oSheet.getCellByPosition(5, 1).setValue(0); - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - e.printStackTrace(log); - result = false; - } - - tRes.tested("removeRange()", result); - } - -} // EOC _XCellRangeMovement - diff --git a/sc/qa/extras/sctablesheetobj.cxx b/sc/qa/extras/sctablesheetobj.cxx index 8e712f26422a..eed8cbd3440e 100644 --- a/sc/qa/extras/sctablesheetobj.cxx +++ b/sc/qa/extras/sctablesheetobj.cxx @@ -15,6 +15,7 @@ #include <test/sheet/xcellformatrangessupplier.hxx> #include <test/sheet/xcellrangeaddressable.hxx> #include <test/sheet/xcellrangeformula.hxx> +#include <test/sheet/xcellrangemovement.hxx> #include <test/sheet/xcellseries.hxx> #include <test/sheet/xdatapilottablessupplier.hxx> #include <test/sheet/xmultipleoperation.hxx> @@ -53,6 +54,7 @@ class ScTableSheetObj : public CalcUnoApiTest, public apitest::Scenario, public apitest::XCellFormatRangesSupplier, public apitest::XCellRangeAddressable, public apitest::XCellRangeFormula, + public apitest::XCellRangeMovement, public apitest::XCellSeries, public apitest::XDataPilotTablesSupplier, public apitest::XMultipleOperation, @@ -113,6 +115,12 @@ public: CPPUNIT_TEST(testGetSetFormulaArray); #endif + // XCellRangeMovement + CPPUNIT_TEST(testInsertCells); + CPPUNIT_TEST(testCopyRange); + CPPUNIT_TEST(testMoveRange); + CPPUNIT_TEST(testRemoveRange); + // XCellSeries CPPUNIT_TEST(testFillAuto); CPPUNIT_TEST(testFillSeries); diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk index fe8729b40c9f..dd6509ce81c9 100644 --- a/test/Library_subsequenttest.mk +++ b/test/Library_subsequenttest.mk @@ -77,8 +77,9 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\ test/source/sheet/xcelladdressable \ test/source/sheet/xcellformatrangessupplier \ test/source/sheet/xcellrangeaddressable \ - test/source/sheet/xcellrangeformula \ test/source/sheet/xcellrangedata \ + test/source/sheet/xcellrangeformula \ + test/source/sheet/xcellrangemovement \ test/source/sheet/xcellrangereferrer \ test/source/sheet/xcellrangesquery \ test/source/sheet/xcellseries \ diff --git a/test/source/sheet/xcellrangemovement.cxx b/test/source/sheet/xcellrangemovement.cxx new file mode 100644 index 000000000000..93fa2dd2a1cc --- /dev/null +++ b/test/source/sheet/xcellrangemovement.cxx @@ -0,0 +1,123 @@ +/* -*- 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/sheet/xcellrangemovement.hxx> + +#include <com/sun/star/sheet/CellDeleteMode.hpp> +#include <com/sun/star/sheet/CellInsertMode.hpp> +#include <com/sun/star/sheet/XCellRangeAddressable.hpp> +#include <com/sun/star/sheet/XCellRangeMovement.hpp> +#include <com/sun/star/sheet/XSpreadsheet.hpp> +#include <com/sun/star/table/CellAddress.hpp> +#include <com/sun/star/table/CellRangeAddress.hpp> +#include <com/sun/star/table/XColumnRowRange.hpp> +#include <com/sun/star/table/XTableRows.hpp> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/uno/Sequence.hxx> + +#include <cppunit/extensions/HelperMacros.h> + +using namespace com::sun::star; +using namespace com::sun::star::uno; + +namespace apitest +{ +void XCellRangeMovement::testInsertCells() +{ + uno::Reference<sheet::XCellRangeMovement> xCRM(init(), UNO_QUERY_THROW); + uno::Reference<sheet::XSpreadsheet> xSheet(xCRM, UNO_QUERY_THROW); + + uno::Reference<sheet::XCellRangeAddressable> xCRA(xCRM, UNO_QUERY_THROW); + const sal_Int16 nSheet = xCRA->getRangeAddress().Sheet; + + xSheet->getCellByPosition(0, 20)->setValue(100); + xSheet->getCellByPosition(1, 20)->setValue(100); + xSheet->getCellByPosition(2, 20)->setValue(100); + xSheet->getCellByPosition(3, 20)->setValue(100); + xSheet->getCellByPosition(0, 21)->setValue(200); + xSheet->getCellByPosition(1, 21)->setValue(200); + xSheet->getCellByPosition(2, 21)->setValue(200); + xSheet->getCellByPosition(3, 21)->setValue(200); + + table::CellRangeAddress aSrcCellRangeAddr(nSheet, 0, 21, 5, 21); + xCRM->insertCells(aSrcCellRangeAddr, sheet::CellInsertMode_DOWN); + + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Unable to insert cells", 0.0, + xSheet->getCellByPosition(1, 21)->getValue(), 0.0); +} + +void XCellRangeMovement::testCopyRange() +{ + uno::Reference<sheet::XCellRangeMovement> xCRM(init(), UNO_QUERY_THROW); + uno::Reference<sheet::XSpreadsheet> xSheet(xCRM, UNO_QUERY_THROW); + + xSheet->getCellByPosition(1, 1)->setValue(100); + xSheet->getCellByPosition(1, 2)->setValue(200); + xSheet->getCellByPosition(2, 1)->setValue(300); + xSheet->getCellByPosition(2, 2)->setValue(400); + + uno::Reference<sheet::XCellRangeAddressable> xCRA(xCRM, UNO_QUERY_THROW); + const sal_Int16 nSheet = xCRA->getRangeAddress().Sheet; + + table::CellRangeAddress aSrcCellRangeAddr(nSheet, 1, 1, 2, 2); + table::CellAddress aDstCellAddr(nSheet, 1, 10); + + xCRM->copyRange(aDstCellAddr, aSrcCellRangeAddr); + + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Value was not copied from position 1,1 to 1,10", 100.0, + xSheet->getCellByPosition(1, 10)->getValue(), 0.1); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Value was not copied from position 1,2 to 1,11", 200.0, + xSheet->getCellByPosition(1, 11)->getValue(), 0.1); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Value was not copied from position 2,1 to 2,10", 300.0, + xSheet->getCellByPosition(2, 10)->getValue(), 0.1); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Value was not copied from position 2,2 to 2,11", 400.0, + xSheet->getCellByPosition(2, 11)->getValue(), 0.1); +} +void XCellRangeMovement::testMoveRange() +{ + uno::Reference<sheet::XCellRangeMovement> xCRM(init(), UNO_QUERY_THROW); + uno::Reference<sheet::XSpreadsheet> xSheet(xCRM, UNO_QUERY_THROW); + + xSheet->getCellByPosition(4, 0)->setValue(111); + xSheet->getCellByPosition(4, 1)->setValue(222); + + uno::Reference<sheet::XCellRangeAddressable> xCRA(xCRM, UNO_QUERY_THROW); + const sal_Int16 nSheet = xCRA->getRangeAddress().Sheet; + + table::CellRangeAddress aSrcCellRangeAddr(nSheet, 4, 0, 4, 1); + table::CellAddress aDstCellAddr(nSheet, 4, 4); + + xCRM->moveRange(aDstCellAddr, aSrcCellRangeAddr); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Unable to move range", 333.0, + xSheet->getCellByPosition(4, 4)->getValue() + + xSheet->getCellByPosition(4, 5)->getValue(), + 0.0); +} +void XCellRangeMovement::testRemoveRange() +{ + uno::Reference<sheet::XCellRangeMovement> xCRM(init(), UNO_QUERY_THROW); + uno::Reference<sheet::XSpreadsheet> xSheet(xCRM, UNO_QUERY_THROW); + + xSheet->getCellByPosition(5, 0)->setValue(333); + xSheet->getCellByPosition(5, 1)->setValue(444); + + uno::Reference<sheet::XCellRangeAddressable> xCRA(xCRM, UNO_QUERY_THROW); + const sal_Int16 nSheet = xCRA->getRangeAddress().Sheet; + + table::CellRangeAddress aSrcCellRangeAddr(nSheet, 5, 0, 5, 1); + + xCRM->removeRange(aSrcCellRangeAddr, sheet::CellDeleteMode_UP); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Unable to remove range", 0.0, + xSheet->getCellByPosition(5, 0)->getValue() + + xSheet->getCellByPosition(5, 1)->getValue(), + 0.0); +} +} // namespace apitest + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |