Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * Version: MPL 1.1 / GPLv3+ / LGPLv3+
4 : *
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/
9 : *
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.
14 : *
15 : * Major Contributor(s):
16 : * Copyright (C) 2011 Markus Mohrhard <markus.mohrhard@googlemail.com> (initial developer)
17 : *
18 : * All Rights Reserved.
19 : *
20 : * For minor contributions see the git repository.
21 : *
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.
27 : */
28 :
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>
35 :
36 : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
37 : #include <com/sun/star/sheet/XSpreadsheet.hpp>
38 : #include <com/sun/star/table/XCellRange.hpp>
39 :
40 : namespace sc_apitest {
41 :
42 : #define NUMBER_OF_TESTS 14
43 :
44 56 : class ScCellRangeObj : public UnoApiTest, apitest::XCellRangesQuery, apitest::CellProperties,
45 : apitest::XSearchable, apitest::XReplaceable, apitest::XCellRangeData
46 : {
47 : public:
48 : ScCellRangeObj();
49 :
50 : virtual void setUp();
51 : virtual void tearDown();
52 : virtual uno::Reference< uno::XInterface > init();
53 : virtual uno::Reference< uno::XInterface > getXCellRangeData();
54 :
55 4 : CPPUNIT_TEST_SUITE(ScCellRangeObj);
56 2 : CPPUNIT_TEST(testQueryColumnDifference);
57 2 : CPPUNIT_TEST(testQueryContentDifference);
58 2 : CPPUNIT_TEST(testQueryEmptyCells);
59 : //CPPUNIT_TEST(testQueryFormulaCells);
60 2 : CPPUNIT_TEST(testQueryIntersection);
61 2 : CPPUNIT_TEST(testQueryRowDifference);
62 2 : CPPUNIT_TEST(testQueryVisibleCells);
63 2 : CPPUNIT_TEST(testVertJustify);
64 2 : CPPUNIT_TEST(testRotateReference);
65 2 : CPPUNIT_TEST(testFindAll);
66 2 : CPPUNIT_TEST(testFindFirst);
67 2 : CPPUNIT_TEST(testReplaceAll);
68 2 : CPPUNIT_TEST(testCreateReplaceDescriptor);
69 2 : CPPUNIT_TEST(testGetDataArray);
70 2 : CPPUNIT_TEST(testSetDataArray);
71 4 : CPPUNIT_TEST_SUITE_END();
72 :
73 : private:
74 : static sal_Int32 nTest;
75 : static uno::Reference< lang::XComponent > mxComponent;
76 : };
77 :
78 : sal_Int32 ScCellRangeObj::nTest = 0;
79 2 : uno::Reference< lang::XComponent > ScCellRangeObj::mxComponent;
80 :
81 28 : ScCellRangeObj::ScCellRangeObj():
82 : apitest::XSearchable(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("15")), 1),
83 28 : apitest::XReplaceable(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("15")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("35")))
84 : {
85 :
86 28 : }
87 :
88 24 : uno::Reference< uno::XInterface > ScCellRangeObj::init()
89 : {
90 24 : rtl::OUString aFileURL;
91 24 : const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("xcellrangesquery.ods"));
92 24 : createFileURL(aFileBase, aFileURL);
93 24 : std::cout << rtl::OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
94 24 : if( !mxComponent.is())
95 2 : mxComponent = loadFromDesktop(aFileURL);
96 24 : uno::Reference< sheet::XSpreadsheetDocument> xDoc (mxComponent, UNO_QUERY_THROW);
97 24 : uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
98 24 : uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
99 :
100 24 : CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is());
101 :
102 24 : uno::Reference<table::XCellRange> xReturn(xSheet->getCellRangeByPosition(0,0,3,4), UNO_QUERY_THROW);
103 :
104 24 : CPPUNIT_ASSERT_MESSAGE("Could not create object of type XCellRangesQuery", xReturn.is());
105 24 : return xReturn;
106 : }
107 :
108 4 : uno::Reference< uno::XInterface > ScCellRangeObj::getXCellRangeData()
109 : {
110 4 : rtl::OUString aFileURL;
111 4 : const rtl::OUString aFileBase(RTL_CONSTASCII_USTRINGPARAM("xcellrangesquery.ods"));
112 4 : createFileURL(aFileBase, aFileURL);
113 4 : std::cout << rtl::OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
114 4 : if( !mxComponent.is())
115 0 : mxComponent = loadFromDesktop(aFileURL);
116 4 : uno::Reference< sheet::XSpreadsheetDocument> xDoc (mxComponent, UNO_QUERY_THROW);
117 4 : uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
118 4 : uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(1), UNO_QUERY_THROW);
119 :
120 4 : CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is());
121 :
122 4 : uno::Reference<table::XCellRange> xReturn(xSheet->getCellRangeByPosition(0,0,3,3), UNO_QUERY_THROW);
123 :
124 4 : CPPUNIT_ASSERT_MESSAGE("Could not create object of type XCellRangesQuery", xReturn.is());
125 4 : return xReturn;
126 : }
127 :
128 28 : void ScCellRangeObj::setUp()
129 : {
130 28 : nTest++;
131 28 : CPPUNIT_ASSERT(nTest <= NUMBER_OF_TESTS);
132 28 : UnoApiTest::setUp();
133 28 : }
134 :
135 28 : void ScCellRangeObj::tearDown()
136 : {
137 28 : if (nTest == NUMBER_OF_TESTS)
138 2 : closeDocument(mxComponent);
139 :
140 28 : UnoApiTest::tearDown();
141 28 : }
142 :
143 2 : CPPUNIT_TEST_SUITE_REGISTRATION(ScCellRangeObj);
144 :
145 2 : CPPUNIT_PLUGIN_IMPLEMENT();
146 :
147 6 : }
148 :
149 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|