Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : */
9 :
10 : #include <test/calc_unoapi_test.hxx>
11 : #include <test/sheet/xcellrangesquery.hxx>
12 : #include <test/sheet/cellproperties.hxx>
13 : #include <test/util/xreplaceable.hxx>
14 : #include <test/util/xsearchable.hxx>
15 : #include <test/sheet/xcellrangedata.hxx>
16 :
17 : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
18 : #include <com/sun/star/sheet/XSpreadsheet.hpp>
19 : #include <com/sun/star/table/XCellRange.hpp>
20 :
21 : using namespace css;
22 : using namespace css::uno;
23 :
24 : namespace sc_apitest {
25 :
26 : #define NUMBER_OF_TESTS 14
27 :
28 56 : class ScCellRangeObj : public CalcUnoApiTest, apitest::XCellRangesQuery, apitest::CellProperties,
29 : apitest::XSearchable, apitest::XReplaceable, apitest::XCellRangeData
30 : {
31 : public:
32 : ScCellRangeObj();
33 :
34 : virtual void setUp() SAL_OVERRIDE;
35 : virtual void tearDown() SAL_OVERRIDE;
36 : virtual uno::Reference< uno::XInterface > init() SAL_OVERRIDE;
37 : virtual uno::Reference< uno::XInterface > getXCellRangeData() SAL_OVERRIDE;
38 :
39 4 : CPPUNIT_TEST_SUITE(ScCellRangeObj);
40 2 : CPPUNIT_TEST(testQueryColumnDifference);
41 2 : CPPUNIT_TEST(testQueryContentDifference);
42 2 : CPPUNIT_TEST(testQueryEmptyCells);
43 : //CPPUNIT_TEST(testQueryFormulaCells);
44 2 : CPPUNIT_TEST(testQueryIntersection);
45 2 : CPPUNIT_TEST(testQueryRowDifference);
46 2 : CPPUNIT_TEST(testQueryVisibleCells);
47 2 : CPPUNIT_TEST(testVertJustify);
48 2 : CPPUNIT_TEST(testRotateReference);
49 2 : CPPUNIT_TEST(testFindAll);
50 2 : CPPUNIT_TEST(testFindFirst);
51 2 : CPPUNIT_TEST(testReplaceAll);
52 2 : CPPUNIT_TEST(testCreateReplaceDescriptor);
53 2 : CPPUNIT_TEST(testGetDataArray);
54 2 : CPPUNIT_TEST(testSetDataArray);
55 4 : CPPUNIT_TEST_SUITE_END();
56 :
57 : private:
58 : static sal_Int32 nTest;
59 : static uno::Reference< lang::XComponent > mxComponent;
60 : };
61 :
62 : sal_Int32 ScCellRangeObj::nTest = 0;
63 2 : uno::Reference< lang::XComponent > ScCellRangeObj::mxComponent;
64 :
65 28 : ScCellRangeObj::ScCellRangeObj():
66 : CalcUnoApiTest("/sc/qa/extras/testdocuments"),
67 : apitest::XSearchable(OUString("15"), 1),
68 28 : apitest::XReplaceable(OUString("15"), OUString("35"))
69 : {
70 28 : }
71 :
72 24 : uno::Reference< uno::XInterface > ScCellRangeObj::init()
73 : {
74 24 : OUString aFileURL;
75 48 : const OUString aFileBase("xcellrangesquery.ods");
76 24 : createFileURL(aFileBase, aFileURL);
77 24 : std::cout << OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
78 24 : if( !mxComponent.is())
79 2 : mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
80 48 : uno::Reference< sheet::XSpreadsheetDocument> xDoc (mxComponent, UNO_QUERY_THROW);
81 48 : uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
82 48 : uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
83 :
84 24 : CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is());
85 :
86 48 : uno::Reference<table::XCellRange> xReturn(xSheet->getCellRangeByPosition(0,0,3,4), UNO_QUERY_THROW);
87 :
88 24 : CPPUNIT_ASSERT_MESSAGE("Could not create object of type XCellRangesQuery", xReturn.is());
89 48 : return xReturn;
90 : }
91 :
92 4 : uno::Reference< uno::XInterface > ScCellRangeObj::getXCellRangeData()
93 : {
94 4 : OUString aFileURL;
95 8 : const OUString aFileBase("xcellrangesquery.ods");
96 4 : createFileURL(aFileBase, aFileURL);
97 4 : std::cout << OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
98 4 : if( !mxComponent.is())
99 0 : mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
100 8 : uno::Reference< sheet::XSpreadsheetDocument> xDoc (mxComponent, UNO_QUERY_THROW);
101 8 : uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
102 8 : uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(1), UNO_QUERY_THROW);
103 :
104 4 : CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is());
105 :
106 8 : uno::Reference<table::XCellRange> xReturn(xSheet->getCellRangeByPosition(0,0,3,3), UNO_QUERY_THROW);
107 :
108 4 : CPPUNIT_ASSERT_MESSAGE("Could not create object of type XCellRangesQuery", xReturn.is());
109 8 : return xReturn;
110 : }
111 :
112 28 : void ScCellRangeObj::setUp()
113 : {
114 28 : nTest++;
115 28 : CPPUNIT_ASSERT(nTest <= NUMBER_OF_TESTS);
116 28 : CalcUnoApiTest::setUp();
117 28 : }
118 :
119 28 : void ScCellRangeObj::tearDown()
120 : {
121 28 : if (nTest == NUMBER_OF_TESTS)
122 : {
123 2 : closeDocument(mxComponent);
124 2 : mxComponent.clear();
125 : }
126 :
127 28 : CalcUnoApiTest::tearDown();
128 28 : }
129 :
130 2 : CPPUNIT_TEST_SUITE_REGISTRATION(ScCellRangeObj);
131 :
132 : }
133 :
134 8 : CPPUNIT_PLUGIN_IMPLEMENT();
135 :
136 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|