update credits
[LibreOffice.git] / sc / qa / extras / scannotationsobj.cxx
blob6f2616cbe786aa516b37230c77a7777ef16ac656
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #include <test/unoapi_test.hxx>
11 #include <test/sheet/xsheetannotations.hxx>
13 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
14 #include <com/sun/star/sheet/XSpreadsheet.hpp>
16 #include <com/sun/star/sheet/XSheetAnnotationsSupplier.hpp>
18 using namespace css;
19 using namespace css::uno;
21 namespace sc_apitest {
23 #define NUMBER_OF_TESTS 2
25 class ScAnnontationsObj : public UnoApiTest, apitest::XSheetAnnotations
27 public:
28 ScAnnontationsObj();
30 virtual void setUp();
31 virtual void tearDown();
33 virtual uno::Reference< uno::XInterface > init();
34 virtual uno::Reference< sheet::XSheetAnnotations> getAnnotations();
36 CPPUNIT_TEST_SUITE(ScAnnontationsObj);
37 CPPUNIT_TEST(testInsertNew);
38 CPPUNIT_TEST(testRemoveByIndex);
39 CPPUNIT_TEST_SUITE_END();
40 private:
42 static sal_Int32 nTest;
43 static uno::Reference< lang::XComponent > mxComponent;
46 sal_Int32 ScAnnontationsObj::nTest = 0;
47 uno::Reference< lang::XComponent > ScAnnontationsObj::mxComponent;
49 ScAnnontationsObj::ScAnnontationsObj()
50 : UnoApiTest("/sc/qa/extras/testdocuments")
54 uno::Reference< sheet::XSheetAnnotations> ScAnnontationsObj::getAnnotations()
56 // get the sheet
57 uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
58 uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
59 uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW);
61 // get the annotations collection
62 uno::Reference< sheet::XSheetAnnotationsSupplier > xAnnotationSupplier(xSheet, UNO_QUERY_THROW);
63 uno::Reference< sheet::XSheetAnnotations > xSheetAnnotations( xAnnotationSupplier->getAnnotations(), UNO_QUERY_THROW);
65 CPPUNIT_ASSERT(xSheetAnnotations.is());
67 return xSheetAnnotations;
70 uno::Reference< uno::XInterface > ScAnnontationsObj::init()
72 // get the test file
73 OUString aFileURL;
74 createFileURL(OUString("ScAnnotationObj.ods"), aFileURL);
75 if(!mxComponent.is())
76 mxComponent = loadFromDesktop(aFileURL);
77 CPPUNIT_ASSERT_MESSAGE("Component not loaded",mxComponent.is());
79 return getAnnotations();
82 void ScAnnontationsObj::setUp()
84 nTest++;
85 UnoApiTest::setUp();
88 void ScAnnontationsObj::tearDown()
90 if (nTest == NUMBER_OF_TESTS)
91 closeDocument(mxComponent);
93 UnoApiTest::tearDown();
96 CPPUNIT_TEST_SUITE_REGISTRATION(ScAnnontationsObj);
98 CPPUNIT_PLUGIN_IMPLEMENT();
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */