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 28 : 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 2 : CPPUNIT_TEST_SUITE(ScCellRangeObj);
40 1 : CPPUNIT_TEST(testQueryColumnDifference);
41 1 : CPPUNIT_TEST(testQueryContentDifference);
42 1 : CPPUNIT_TEST(testQueryEmptyCells);
43 : //CPPUNIT_TEST(testQueryFormulaCells);
44 1 : CPPUNIT_TEST(testQueryIntersection);
45 1 : CPPUNIT_TEST(testQueryRowDifference);
46 1 : CPPUNIT_TEST(testQueryVisibleCells);
47 1 : CPPUNIT_TEST(testVertJustify);
48 1 : CPPUNIT_TEST(testRotateReference);
49 1 : CPPUNIT_TEST(testFindAll);
50 1 : CPPUNIT_TEST(testFindFirst);
51 1 : CPPUNIT_TEST(testReplaceAll);
52 1 : CPPUNIT_TEST(testCreateReplaceDescriptor);
53 1 : CPPUNIT_TEST(testGetDataArray);
54 1 : CPPUNIT_TEST(testSetDataArray);
55 5 : 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 1 : uno::Reference< lang::XComponent > ScCellRangeObj::mxComponent;
64 :
65 14 : ScCellRangeObj::ScCellRangeObj():
66 : CalcUnoApiTest("/sc/qa/extras/testdocuments"),
67 : apitest::XSearchable(OUString("15"), 1),
68 14 : apitest::XReplaceable(OUString("15"), OUString("35"))
69 : {
70 14 : }
71 :
72 12 : uno::Reference< uno::XInterface > ScCellRangeObj::init()
73 : {
74 12 : OUString aFileURL;
75 24 : const OUString aFileBase("xcellrangesquery.ods");
76 12 : createFileURL(aFileBase, aFileURL);
77 12 : std::cout << OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
78 12 : if( !mxComponent.is())
79 1 : mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
80 24 : uno::Reference< sheet::XSpreadsheetDocument> xDoc (mxComponent, UNO_QUERY_THROW);
81 24 : uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
82 24 : uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
83 :
84 12 : CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is());
85 :
86 24 : uno::Reference<table::XCellRange> xReturn(xSheet->getCellRangeByPosition(0,0,3,4), UNO_QUERY_THROW);
87 :
88 12 : CPPUNIT_ASSERT_MESSAGE("Could not create object of type XCellRangesQuery", xReturn.is());
89 24 : return xReturn;
90 : }
91 :
92 2 : uno::Reference< uno::XInterface > ScCellRangeObj::getXCellRangeData()
93 : {
94 2 : OUString aFileURL;
95 4 : const OUString aFileBase("xcellrangesquery.ods");
96 2 : createFileURL(aFileBase, aFileURL);
97 2 : std::cout << OUStringToOString(aFileURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
98 2 : if( !mxComponent.is())
99 0 : mxComponent = loadFromDesktop(aFileURL, "com.sun.star.sheet.SpreadsheetDocument");
100 4 : uno::Reference< sheet::XSpreadsheetDocument> xDoc (mxComponent, UNO_QUERY_THROW);
101 4 : uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
102 4 : uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(1), UNO_QUERY_THROW);
103 :
104 2 : CPPUNIT_ASSERT_MESSAGE("Could not create interface of type XSpreadsheet", xSheet.is());
105 :
106 4 : uno::Reference<table::XCellRange> xReturn(xSheet->getCellRangeByPosition(0,0,3,3), UNO_QUERY_THROW);
107 :
108 2 : CPPUNIT_ASSERT_MESSAGE("Could not create object of type XCellRangesQuery", xReturn.is());
109 4 : return xReturn;
110 : }
111 :
112 14 : void ScCellRangeObj::setUp()
113 : {
114 14 : nTest++;
115 14 : CPPUNIT_ASSERT(nTest <= NUMBER_OF_TESTS);
116 14 : CalcUnoApiTest::setUp();
117 14 : }
118 :
119 14 : void ScCellRangeObj::tearDown()
120 : {
121 14 : if (nTest == NUMBER_OF_TESTS)
122 : {
123 1 : closeDocument(mxComponent);
124 1 : mxComponent.clear();
125 : }
126 :
127 14 : CalcUnoApiTest::tearDown();
128 14 : }
129 :
130 1 : CPPUNIT_TEST_SUITE_REGISTRATION(ScCellRangeObj);
131 :
132 : }
133 :
134 4 : CPPUNIT_PLUGIN_IMPLEMENT();
135 :
136 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|