diff options
-rw-r--r-- | framework/qa/complex/api_internal/api.lst | 1 | ||||
-rw-r--r-- | include/test/table/xtablecolumns.hxx | 59 | ||||
-rw-r--r-- | qadevOOo/Jar_OOoRunner.mk | 1 | ||||
-rw-r--r-- | qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableColumnsObj.csv | 2 | ||||
-rw-r--r-- | qadevOOo/tests/java/mod/_sc/ScTableColumnsObj.java | 123 | ||||
-rw-r--r-- | sc/qa/extras/sctablecolumnsobj.cxx | 33 | ||||
-rw-r--r-- | sc/qa/unoapi/sc_7.sce | 1 | ||||
-rw-r--r-- | test/Library_subsequenttest.mk | 1 | ||||
-rw-r--r-- | test/source/table/xtablecolumns.cxx | 174 |
9 files changed, 265 insertions, 130 deletions
diff --git a/framework/qa/complex/api_internal/api.lst b/framework/qa/complex/api_internal/api.lst index 406fbb8bebdc..21a248e9e2ec 100644 --- a/framework/qa/complex/api_internal/api.lst +++ b/framework/qa/complex/api_internal/api.lst @@ -82,7 +82,6 @@ job99=sc.ScHeaderFieldsObj job126=sc.ScSheetLinkObj job132=sc.ScStyleObj job134=sc.ScTableColumnObj -job135=sc.ScTableColumnsObj job138=sc.ScTableRowObj job140=sc.XMLContentExporter job141=sc.XMLContentImporter diff --git a/include/test/table/xtablecolumns.hxx b/include/test/table/xtablecolumns.hxx new file mode 100644 index 000000000000..b4cc23faa465 --- /dev/null +++ b/include/test/table/xtablecolumns.hxx @@ -0,0 +1,59 @@ +/* -*- 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_TABLE_XTABLECOLUMNS_HXX +#define INCLUDED_TEST_TABLE_XTABLECOLUMNS_HXX + +#include <rtl/string.hxx> + +#include <com/sun/star/sheet/XSpreadsheet.hpp> +#include <com/sun/star/table/XCell.hpp> +#include <com/sun/star/uno/XInterface.hpp> + +#include <com/sun/star/uno/Reference.hxx> + +#include <test/testdllapi.hxx> + +namespace apitest +{ +class OOO_DLLPUBLIC_TEST XTableColumns +{ +public: + virtual css::uno::Reference<css::uno::XInterface> init() = 0; + + void setXSpreadsheet(css::uno::Reference<css::sheet::XSpreadsheet>& r_xSheet) + { + m_xSheet = r_xSheet; + } + + void testInsertByIndex(); + void testInsertByIndexWithNegativeIndex(); + // only use with ScTableColumnsObj + void testInsertByIndexWithNoColumn(); + void testInsertByIndexWithOutOfBoundIndex(); + void testRemoveByIndex(); + void testRemoveByIndexWithNegativeIndex(); + // only use with ScTableColumnsObj + void testRemoveByIndexWithNoColumn(); + void testRemoveByIndexWithOutOfBoundIndex(); + +protected: + ~XTableColumns() {} + +private: + css::uno::Reference<css::sheet::XSpreadsheet> m_xSheet; + + static const OUString getCellText(const css::uno::Reference<css::table::XCell>& r_xCell); +}; + +} // namespace apitest + +#endif // INCLUDED_TEST_TABLE_XTABLECOLUMNS_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 805ddeca0e38..d839184c72c1 100644 --- a/qadevOOo/Jar_OOoRunner.mk +++ b/qadevOOo/Jar_OOoRunner.mk @@ -973,7 +973,6 @@ $(eval $(call gb_Jar_add_sourcefiles,OOoRunner,\ qadevOOo/tests/java/mod/_sc/ScStyleObj \ qadevOOo/tests/java/mod/_sc/ScSubTotalDescriptorBase \ qadevOOo/tests/java/mod/_sc/ScTableColumnObj \ - qadevOOo/tests/java/mod/_sc/ScTableColumnsObj \ qadevOOo/tests/java/mod/_sc/ScTableRowObj \ qadevOOo/tests/java/mod/_sc/ScTableSheetObj \ qadevOOo/tests/java/mod/_sc/ScTableSheetsObj \ diff --git a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableColumnsObj.csv b/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableColumnsObj.csv deleted file mode 100644 index 43c4b321bc7d..000000000000 --- a/qadevOOo/objdsc/sc/com.sun.star.comp.office.ScTableColumnsObj.csv +++ /dev/null @@ -1,2 +0,0 @@ -"ScTableColumnsObj";"com::sun::star::table::XTableColumns";"insertByIndex()" -"ScTableColumnsObj";"com::sun::star::table::XTableColumns";"removeByIndex()" diff --git a/qadevOOo/tests/java/mod/_sc/ScTableColumnsObj.java b/qadevOOo/tests/java/mod/_sc/ScTableColumnsObj.java deleted file mode 100644 index 97fab4bbbea3..000000000000 --- a/qadevOOo/tests/java/mod/_sc/ScTableColumnsObj.java +++ /dev/null @@ -1,123 +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.XNameAccess; -import com.sun.star.lang.XComponent; -import com.sun.star.sheet.XSpreadsheet; -import com.sun.star.sheet.XSpreadsheetDocument; -import com.sun.star.sheet.XSpreadsheets; -import com.sun.star.table.XCellRange; -import com.sun.star.table.XColumnRowRange; -import com.sun.star.table.XTableColumns; -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.table.TableColumns</code>. <p> -* Object implements the following interfaces : -* <ul> -* <li> <code>com::sun::star::container::XIndexAccess</code></li> -* <li> <code>com::sun::star::container::XElementAccess</code></li> -* <li> <code>com::sun::star::container::XNameAccess</code></li> -* <li> <code>com::sun::star::table::XTableColumns</code></li> -* </ul> -* @see com.sun.star.table.TableColumns -* @see com.sun.star.container.XIndexAccess -* @see com.sun.star.container.XElementAccess -* @see com.sun.star.container.XNameAccess -* @see com.sun.star.table.XTableColumns -* @see ifc.container._XIndexAccess -* @see ifc.container._XElementAccess -* @see ifc.container._XNameAccess -* @see ifc.table._XTableColumns -*/ -public class ScTableColumnsObj extends TestCase { - private XSpreadsheetDocument xSheetDoc = null; - - /** - * Creates Spreadsheet document. - */ - @Override - protected void initialize( TestParameters tParam, PrintWriter log ) throws Exception { - // get a soffice factory object - SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF()); - log.println( "creating a sheetdocument" ); - 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 the document and takes one of - * them. Obtains the collection of columns in the range using the interface - * <code>XColumnRowRange</code>. This collection is the instance of the - * service <code>com.sun.star.table.TableColumns</code>. - * @see com.sun.star.table.XColumnRowRange - * @see com.sun.star.table.TableColumns - */ - @Override - protected TestEnvironment createTestEnvironment(TestParameters Param, PrintWriter log) throws Exception { - - XInterface oObj = null; - - // creation of the testobject here - // first we write what we are intend to do to log file - log.println("creating a test environment"); - - log.println("getting column"); - XSpreadsheets xSpreadsheets = xSheetDoc.getSheets(); - XNameAccess oNames = UnoRuntime.queryInterface( XNameAccess.class, xSpreadsheets ); - XSpreadsheet xSpreadsheet = (XSpreadsheet) AnyConverter.toObject( - new Type(XSpreadsheet.class), - oNames.getByName(oNames.getElementNames()[0])); - - XColumnRowRange oColumnRowRange = UnoRuntime.queryInterface(XColumnRowRange.class, xSpreadsheet); - XTableColumns oColumns = oColumnRowRange.getColumns(); - oObj = oColumns; - - log.println("creating a new environment for object"); - TestEnvironment tEnv = new TestEnvironment(oObj); - - // adding relation for XTableColumns - tEnv.addObjRelation("XTableColumns.XCellRange", - UnoRuntime.queryInterface(XCellRange.class, xSpreadsheet)); - - return tEnv; - } -} // finish class ScTableColumnsObj diff --git a/sc/qa/extras/sctablecolumnsobj.cxx b/sc/qa/extras/sctablecolumnsobj.cxx index 92b7e790f087..b1ce7f482928 100644 --- a/sc/qa/extras/sctablecolumnsobj.cxx +++ b/sc/qa/extras/sctablecolumnsobj.cxx @@ -12,6 +12,7 @@ #include <test/container/xenumerationaccess.hxx> #include <test/container/xindexaccess.hxx> #include <test/container/xnameaccess.hxx> +#include <test/table/xtablecolumns.hxx> #include <cppu/unotype.hxx> #include <com/sun/star/container/XIndexAccess.hpp> @@ -22,6 +23,7 @@ #include <com/sun/star/table/XCellRange.hpp> #include <com/sun/star/table/XColumnRowRange.hpp> #include <com/sun/star/table/XTableColumns.hpp> +#include <com/sun/star/text/XSimpleText.hpp> #include <com/sun/star/uno/XInterface.hpp> #include <com/sun/star/uno/Reference.hxx> @@ -34,7 +36,8 @@ class ScTableColumnsObj : public CalcUnoApiTest, public apitest::XElementAccess, public apitest::XEnumerationAccess, public apitest::XIndexAccess, - public apitest::XNameAccess + public apitest::XNameAccess, + public apitest::XTableColumns { public: ScTableColumnsObj(); @@ -61,6 +64,16 @@ public: CPPUNIT_TEST(testGetElementNames); CPPUNIT_TEST(testHasByName); + // XTableColumns + CPPUNIT_TEST(testInsertByIndex); + CPPUNIT_TEST(testInsertByIndexWithNegativeIndex); + CPPUNIT_TEST(testInsertByIndexWithNoColumn); + CPPUNIT_TEST(testInsertByIndexWithOutOfBoundIndex); + CPPUNIT_TEST(testRemoveByIndex); + CPPUNIT_TEST(testRemoveByIndexWithNegativeIndex); + CPPUNIT_TEST(testRemoveByIndexWithNoColumn); + CPPUNIT_TEST(testRemoveByIndexWithOutOfBoundIndex); + CPPUNIT_TEST_SUITE_END(); private: @@ -84,7 +97,23 @@ uno::Reference<uno::XInterface> ScTableColumnsObj::init() uno::Reference<table::XColumnRowRange> xCRR(xSheet0, uno::UNO_QUERY_THROW); uno::Reference<table::XTableColumns> xTC(xCRR->getColumns(), uno::UNO_QUERY_THROW); - + setXSpreadsheet(xSheet0); + + uno::Reference<table::XCellRange> xCR(xSheet0, uno::UNO_QUERY_THROW); + for (auto i = 0; i < xTC->getCount() - 1 && i < 3; ++i) + { + uno::Reference<text::XSimpleText> xST0(xCR->getCellByPosition(i, 0), uno::UNO_QUERY_THROW); + xST0->setString(OUString::number(i) + "a"); + uno::Reference<text::XSimpleText> xST1(xCR->getCellByPosition(i, 1), uno::UNO_QUERY_THROW); + xST1->setString(OUString::number(i) + "b"); + } + for (auto i = 3; i < xTC->getCount() - 1 && i < 10; ++i) + { + uno::Reference<text::XSimpleText> xST0(xCR->getCellByPosition(i, 0), uno::UNO_QUERY_THROW); + xST0->setString(""); + uno::Reference<text::XSimpleText> xST1(xCR->getCellByPosition(i, 1), uno::UNO_QUERY_THROW); + xST1->setString(""); + } return xTC; } diff --git a/sc/qa/unoapi/sc_7.sce b/sc/qa/unoapi/sc_7.sce index db39280b3d51..306e95aebb48 100644 --- a/sc/qa/unoapi/sc_7.sce +++ b/sc/qa/unoapi/sc_7.sce @@ -19,7 +19,6 @@ -o sc.ScSubTotalDescriptorBase # # i84656 -o sc.ScTabViewObj # -o sc.ScTableColumnObj --o sc.ScTableColumnsObj # -o sc.ScTableRowObj # -o sc.ScTableSheetObj # -o sc.ScTableSheetsObj diff --git a/test/Library_subsequenttest.mk b/test/Library_subsequenttest.mk index f8d0af7ddb7f..086e24b82b51 100644 --- a/test/Library_subsequenttest.mk +++ b/test/Library_subsequenttest.mk @@ -166,6 +166,7 @@ $(eval $(call gb_Library_add_exception_objects,subsequenttest,\ test/source/table/xtablechart \ test/source/table/xtablecharts \ test/source/table/xtablechartssupplier \ + test/source/table/xtablecolumns \ test/source/table/xtablerows \ test/source/text/xsimpletext \ test/source/text/xtext \ diff --git a/test/source/table/xtablecolumns.cxx b/test/source/table/xtablecolumns.cxx new file mode 100644 index 000000000000..90c67977dd83 --- /dev/null +++ b/test/source/table/xtablecolumns.cxx @@ -0,0 +1,174 @@ +/* -*- 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/table/xtablecolumns.hxx> + +#include <com/sun/star/table/XCell.hpp> +#include <com/sun/star/table/XCellRange.hpp> +#include <com/sun/star/table/XTableColumns.hpp> +#include <com/sun/star/text/XSimpleText.hpp> +#include <com/sun/star/uno/RuntimeException.hpp> + +#include <com/sun/star/uno/Reference.hxx> + +#include <cppunit/extensions/HelperMacros.h> + +using namespace css; + +namespace apitest +{ +void XTableColumns::testInsertByIndex() +{ + uno::Reference<table::XTableColumns> xTC(init(), uno::UNO_QUERY_THROW); + uno::Reference<table::XCellRange> xCR(m_xSheet, uno::UNO_QUERY_THROW); + + // insert one column at position one + xTC->insertByIndex(1, 1); + CPPUNIT_ASSERT_EQUAL(OUString("0a"), getCellText(xCR->getCellByPosition(0, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("0b"), getCellText(xCR->getCellByPosition(0, 1))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(1, 0))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(1, 1))); + CPPUNIT_ASSERT_EQUAL(OUString("1a"), getCellText(xCR->getCellByPosition(2, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("1b"), getCellText(xCR->getCellByPosition(2, 1))); + CPPUNIT_ASSERT_EQUAL(OUString("2a"), getCellText(xCR->getCellByPosition(3, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("2b"), getCellText(xCR->getCellByPosition(3, 1))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(4, 0))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(4, 1))); + + // insert one column at position zero + xTC->insertByIndex(0, 1); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(0, 0))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(0, 1))); + CPPUNIT_ASSERT_EQUAL(OUString("0a"), getCellText(xCR->getCellByPosition(1, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("0b"), getCellText(xCR->getCellByPosition(1, 1))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(2, 0))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(2, 1))); + CPPUNIT_ASSERT_EQUAL(OUString("1a"), getCellText(xCR->getCellByPosition(3, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("1b"), getCellText(xCR->getCellByPosition(3, 1))); + CPPUNIT_ASSERT_EQUAL(OUString("2a"), getCellText(xCR->getCellByPosition(4, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("2b"), getCellText(xCR->getCellByPosition(4, 1))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(5, 0))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(5, 1))); + + // insert two columns at position zero + xTC->insertByIndex(0, 2); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(0, 0))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(0, 1))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(1, 0))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(1, 1))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(2, 0))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(2, 1))); + CPPUNIT_ASSERT_EQUAL(OUString("0a"), getCellText(xCR->getCellByPosition(3, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("0b"), getCellText(xCR->getCellByPosition(3, 1))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(4, 0))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(4, 1))); + CPPUNIT_ASSERT_EQUAL(OUString("1a"), getCellText(xCR->getCellByPosition(5, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("1b"), getCellText(xCR->getCellByPosition(5, 1))); + CPPUNIT_ASSERT_EQUAL(OUString("2a"), getCellText(xCR->getCellByPosition(6, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("2b"), getCellText(xCR->getCellByPosition(6, 1))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(7, 0))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(7, 1))); +} + +void XTableColumns::testInsertByIndexWithNegativeIndex() +{ + uno::Reference<table::XTableColumns> xTC(init(), uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_THROW(xTC->insertByIndex(-1, 1), uno::RuntimeException); +} + +void XTableColumns::testInsertByIndexWithNoColumn() +{ + uno::Reference<table::XTableColumns> xTC(init(), uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_THROW(xTC->insertByIndex(0, 0), uno::RuntimeException); +} + +void XTableColumns::testInsertByIndexWithOutOfBoundIndex() +{ + uno::Reference<table::XTableColumns> xTC(init(), uno::UNO_QUERY_THROW); + + CPPUNIT_ASSERT_THROW(xTC->insertByIndex(xTC->getCount(), 1), uno::RuntimeException); +} + +void XTableColumns::testRemoveByIndex() +{ + uno::Reference<table::XTableColumns> xTC(init(), uno::UNO_QUERY_THROW); + uno::Reference<table::XCellRange> xCR(m_xSheet, uno::UNO_QUERY_THROW); + + xTC->insertByIndex(1, 1); // insert one column at position one + xTC->insertByIndex(0, 1); // insert one column at position zero + xTC->insertByIndex(0, 2); // insert two columns at position zero + + // remove two columns at position zero + xTC->removeByIndex(0, 2); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(0, 0))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(0, 1))); + CPPUNIT_ASSERT_EQUAL(OUString("0a"), getCellText(xCR->getCellByPosition(1, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("0b"), getCellText(xCR->getCellByPosition(1, 1))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(2, 0))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(2, 1))); + CPPUNIT_ASSERT_EQUAL(OUString("1a"), getCellText(xCR->getCellByPosition(3, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("1b"), getCellText(xCR->getCellByPosition(3, 1))); + CPPUNIT_ASSERT_EQUAL(OUString("2a"), getCellText(xCR->getCellByPosition(4, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("2b"), getCellText(xCR->getCellByPosition(4, 1))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(5, 0))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(5, 1))); + + // remove one column at position zero + xTC->removeByIndex(0, 1); + CPPUNIT_ASSERT_EQUAL(OUString("0a"), getCellText(xCR->getCellByPosition(0, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("0b"), getCellText(xCR->getCellByPosition(0, 1))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(1, 0))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(1, 1))); + CPPUNIT_ASSERT_EQUAL(OUString("1a"), getCellText(xCR->getCellByPosition(2, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("1b"), getCellText(xCR->getCellByPosition(2, 1))); + CPPUNIT_ASSERT_EQUAL(OUString("2a"), getCellText(xCR->getCellByPosition(3, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("2b"), getCellText(xCR->getCellByPosition(3, 1))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(4, 0))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(4, 1))); + + // remove one column at position one + xTC->removeByIndex(1, 1); + CPPUNIT_ASSERT_EQUAL(OUString("0a"), getCellText(xCR->getCellByPosition(0, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("0b"), getCellText(xCR->getCellByPosition(0, 1))); + CPPUNIT_ASSERT_EQUAL(OUString("1a"), getCellText(xCR->getCellByPosition(1, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("1b"), getCellText(xCR->getCellByPosition(1, 1))); + CPPUNIT_ASSERT_EQUAL(OUString("2a"), getCellText(xCR->getCellByPosition(2, 0))); + CPPUNIT_ASSERT_EQUAL(OUString("2b"), getCellText(xCR->getCellByPosition(2, 1))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(3, 0))); + CPPUNIT_ASSERT_EQUAL(OUString(""), getCellText(xCR->getCellByPosition(3, 1))); +} + +void XTableColumns::testRemoveByIndexWithNegativeIndex() +{ + uno::Reference<table::XTableColumns> xTC(init(), uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_THROW(xTC->removeByIndex(-1, 1), uno::RuntimeException); +} + +void XTableColumns::testRemoveByIndexWithNoColumn() +{ + uno::Reference<table::XTableColumns> xTC(init(), uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_THROW(xTC->removeByIndex(0, 0), uno::RuntimeException); +} + +void XTableColumns::testRemoveByIndexWithOutOfBoundIndex() +{ + uno::Reference<table::XTableColumns> xTC(init(), uno::UNO_QUERY_THROW); + + CPPUNIT_ASSERT_THROW(xTC->removeByIndex(xTC->getCount(), 1), uno::RuntimeException); +} + +const OUString XTableColumns::getCellText(const uno::Reference<table::XCell>& r_xCell) +{ + uno::Reference<text::XSimpleText> xST(r_xCell, uno::UNO_QUERY_THROW); + return xST->getString(); +} + +} // namespace apitest + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |