Impress Remote 1.0.5, tag sdremote-1.0.5
[LibreOffice.git] / sc / qa / extras / sccellrangeobj.cxx
blob20a5c3aabd35c2066fc368fa19a7f9b58eaa6056
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * Version: MPL 1.1 / GPLv3+ / LGPLv3+
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License or as specified alternatively below. You may obtain a copy of
8 * the License at http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * Major Contributor(s):
16 * Copyright (C) 2011 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
18 * All Rights Reserved.
20 * For minor contributions see the git repository.
22 * Alternatively, the contents of this file may be used under the terms of
23 * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
24 * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
25 * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
26 * instead of those above.
29 #include <test/unoapi_test.hxx>
30 #include <test/sheet/xcellrangesquery.hxx>
31 #include <test/sheet/cellproperties.hxx>
32 #include <test/util/xreplaceable.hxx>
33 #include <test/util/xsearchable.hxx>
34 #include <test/sheet/xcellrangedata.hxx>
36 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
37 #include <com/sun/star/sheet/XSpreadsheet.hpp>
38 #include <com/sun/star/table/XCellRange.hpp>
40 namespace sc_apitest {
42 #define NUMBER_OF_TESTS 14
44 class ScCellRangeObj : public UnoApiTest, apitest::XCellRangesQuery, apitest::CellProperties,
45 apitest::XSearchable, apitest::XReplaceable, apitest::XCellRangeData
47 public:
48 ScCellRangeObj();
50 virtual void setUp();
51 virtual void tearDown();
52 virtual uno::Reference< uno::XInterface > init();
53 virtual uno::Reference< uno::XInterface > getXCellRangeData();
55 CPPUNIT_TEST_SUITE(ScCellRangeObj);
56 CPPUNIT_TEST(testQueryColumnDifference);
57 CPPUNIT_TEST(testQueryContentDifference);
58 CPPUNIT_TEST(testQueryEmptyCells);
59 //CPPUNIT_TEST(testQueryFormulaCells);
60 CPPUNIT_TEST(testQueryIntersection);
61 CPPUNIT_TEST(testQueryRowDifference);
62 CPPUNIT_TEST(testQueryVisibleCells);
63 CPPUNIT_TEST(testVertJustify);
64 CPPUNIT_TEST(testRotateReference);
65 CPPUNIT_TEST(testFindAll);
66 CPPUNIT_TEST(testFindFirst);
67 CPPUNIT_TEST(testReplaceAll);
68 CPPUNIT_TEST(testCreateReplaceDescriptor);
69 CPPUNIT_TEST(testGetDataArray);
70 CPPUNIT_TEST(testSetDataArray);
71 CPPUNIT_TEST_SUITE_END();
73 private:
74 static sal_Int32 nTest;
75 static uno::Reference< lang::XComponent > mxComponent;
78 sal_Int32 ScCellRangeObj::nTest = 0;
79 uno::Reference< lang::XComponent > ScCellRangeObj::mxComponent;
81 ScCellRangeObj::ScCellRangeObj():
82 apitest::XSearchable(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("15")), 1),
83 apitest::XReplaceable(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("15")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("35")))
88 uno::Reference< uno::XInterface > ScCellRangeObj::init()
90 rtl::OUString aFileURL;
91 const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("xcellrangesquery.ods"));
92 createFileURL(aFileBase, aFileURL);
93 std::cout << rtl::OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
94 if( !mxComponent.is())
95 mxComponent = loadFromDesktop(aFileURL);
96 uno::Reference< sheet::XSpreadsheetDocument> xDoc (mxComponent, UNO_QUERY_THROW);
97 uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
98 uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
100 CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is());
102 uno::Reference<table::XCellRange> xReturn(xSheet->getCellRangeByPosition(0,0,3,4), UNO_QUERY_THROW);
104 CPPUNIT_ASSERT_MESSAGE("Could not create object of type XCellRangesQuery", xReturn.is());
105 return xReturn;
108 uno::Reference< uno::XInterface > ScCellRangeObj::getXCellRangeData()
110 rtl::OUString aFileURL;
111 const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("xcellrangesquery.ods"));
112 createFileURL(aFileBase, aFileURL);
113 std::cout << rtl::OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
114 if( !mxComponent.is())
115 mxComponent = loadFromDesktop(aFileURL);
116 uno::Reference< sheet::XSpreadsheetDocument> xDoc (mxComponent, UNO_QUERY_THROW);
117 uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
118 uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(1), UNO_QUERY_THROW);
120 CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is());
122 uno::Reference<table::XCellRange> xReturn(xSheet->getCellRangeByPosition(0,0,3,3), UNO_QUERY_THROW);
124 CPPUNIT_ASSERT_MESSAGE("Could not create object of type XCellRangesQuery", xReturn.is());
125 return xReturn;
128 void ScCellRangeObj::setUp()
130 nTest++;
131 CPPUNIT_ASSERT(nTest <= NUMBER_OF_TESTS);
132 UnoApiTest::setUp();
135 void ScCellRangeObj::tearDown()
137 if (nTest == NUMBER_OF_TESTS)
138 closeDocument(mxComponent);
140 UnoApiTest::tearDown();
143 CPPUNIT_TEST_SUITE_REGISTRATION(ScCellRangeObj);
145 CPPUNIT_PLUGIN_IMPLEMENT();
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */