summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJens Carl <j.carl43@gmx.de>2017-12-01 01:00:41 +0000
committerJens Carl <j.carl43@gmx.de>2017-12-01 19:17:54 +0100
commit350eec67a5989365560e38e9270990dcd0a019e8 (patch)
treec758839bc70046a86b9f41f698750ed09117defa /test
parentdccfe8765c25caf8485e659711a6df6c43ed63a9 (diff)
tdf#45904 Move _XMultipleOperation Java tests to C++
Change-Id: I102b726e673f69bfe64eff7e28e380dd6f15f1f8 Reviewed-on: https://gerrit.libreoffice.org/45629 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jens Carl <j.carl43@gmx.de>
Diffstat (limited to 'test')
-rw-r--r--test/Library_subsequenttest.mk1
-rw-r--r--test/source/sheet/xmultipleoperation.cxx96
2 files changed, 97 insertions, 0 deletions
diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk
index 803f18303799..c398bb0cf10b 100644
--- a/test/Library_subsequenttest.mk
+++ b/test/Library_subsequenttest.mk
@@ -65,6 +65,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\
test/source/sheet/xlabelranges \
test/source/sheet/xnamedrange \
test/source/sheet/xnamedranges \
+ test/source/sheet/xmultipleoperation \
test/source/sheet/xprintareas \
test/source/sheet/xscenarioenhanced \
test/source/sheet/xscenarios \
diff --git a/test/source/sheet/xmultipleoperation.cxx b/test/source/sheet/xmultipleoperation.cxx
new file mode 100644
index 000000000000..5f5f100ea247
--- /dev/null
+++ b/test/source/sheet/xmultipleoperation.cxx
@@ -0,0 +1,96 @@
+/* -*- 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/xmultipleoperation.hxx>
+
+#include <com/sun/star/sheet/TableOperationMode.hpp>
+#include <com/sun/star/sheet/XCellAddressable.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/sheet/XMultipleOperation.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/table/XCell.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <cppunit/extensions/HelperMacros.h>
+
+using namespace css;
+using namespace css::uno;
+
+namespace apitest
+{
+void XMultipleOperation::testSetTableOperation()
+{
+ uno::Reference<sheet::XMultipleOperation> xMultipleOperation(init(), UNO_QUERY_THROW);
+
+ uno::Reference<sheet::XSpreadsheet> xSheet(getXSpreadsheet(), UNO_QUERY_THROW);
+ uno::Reference<table::XCellRange> xCellRange(xSheet->getCellRangeByName("$A$20:$A$20"),
+ UNO_QUERY_THROW);
+ uno::Reference<sheet::XCellRangeAddressable> xCellRangeAddr(xCellRange, UNO_QUERY_THROW);
+
+ uno::Reference<table::XCell> xCell = xSheet->getCellByPosition(0, 19);
+ xCell->setFormula("=a18+a19");
+
+ uno::Reference<table::XCell> xCell1 = xSheet->getCellByPosition(0, 17);
+ uno::Reference<sheet::XCellAddressable> xCellAddr1(xCell1, UNO_QUERY_THROW);
+
+ uno::Reference<table::XCell> xCell2 = xSheet->getCellByPosition(0, 18);
+ uno::Reference<sheet::XCellAddressable> xCellAddr2(xCell2, UNO_QUERY_THROW);
+
+ fillCells(xSheet);
+ xMultipleOperation->setTableOperation(
+ xCellRangeAddr->getRangeAddress(), sheet::TableOperationMode_ROW,
+ xCellAddr1->getCellAddress(), xCellAddr2->getCellAddress());
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Check cell at position 1,1 (OpMode: ROW)", 5.0,
+ xSheet->getCellByPosition(1, 1)->getValue());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Check cell at position 2,1 (OpMode: ROW)", 10.0,
+ xSheet->getCellByPosition(2, 1)->getValue());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Check cell at position 3,1 (OpMode: ROW)", 15.0,
+ xSheet->getCellByPosition(3, 1)->getValue());
+
+ fillCells(xSheet);
+ xMultipleOperation->setTableOperation(
+ xCellRangeAddr->getRangeAddress(), sheet::TableOperationMode_COLUMN,
+ xCellAddr1->getCellAddress(), xCellAddr2->getCellAddress());
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Check cell at position 1,1 (OpMode: COLUMN)", 12.0,
+ xSheet->getCellByPosition(1, 1)->getValue());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Check cell at position 1,2 (OpMode: COLUMN)", 24.0,
+ xSheet->getCellByPosition(1, 2)->getValue());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Check cell at position 1,3 (OpMode: COLUMN)", 36.0,
+ xSheet->getCellByPosition(1, 3)->getValue());
+
+ fillCells(xSheet);
+ xMultipleOperation->setTableOperation(
+ xCellRangeAddr->getRangeAddress(), sheet::TableOperationMode_BOTH,
+ xCellAddr1->getCellAddress(), xCellAddr2->getCellAddress());
+
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Check cell at position 1,1 (OpMode: BOTH)", 17.0,
+ xSheet->getCellByPosition(1, 1)->getValue());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Check cell at position 2,2 (OpMode: BOTH)", 34.0,
+ xSheet->getCellByPosition(2, 2)->getValue());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Check cell at position 3,3 (OpMode: BOTH)", 51.0,
+ xSheet->getCellByPosition(3, 3)->getValue());
+}
+
+void XMultipleOperation::fillCells(uno::Reference<sheet::XSpreadsheet>& xSheet)
+{
+ for (unsigned int i = 1; i < 5; i++)
+ {
+ uno::Reference<table::XCell> xCellFill = xSheet->getCellByPosition(0, i);
+ xCellFill->setValue(i * 12);
+ xCellFill = xSheet->getCellByPosition(i, 0);
+ xCellFill->setValue(i * 5);
+ }
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */