nss: upgrade to release 3.73
[LibreOffice.git] / sc / qa / extras / scannotationsobj.cxx
blobaba02c32f06088639f229fd531863e0302e3afeb
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/calc_unoapi_test.hxx>
11 #include <test/container/xelementaccess.hxx>
12 #include <test/container/xenumerationaccess.hxx>
13 #include <test/container/xindexaccess.hxx>
14 #include <test/sheet/xsheetannotations.hxx>
16 #include <com/sun/star/container/XIndexAccess.hpp>
17 #include <com/sun/star/lang/XComponent.hpp>
18 #include <com/sun/star/sheet/XSheetAnnotation.hpp>
19 #include <com/sun/star/sheet/XSheetAnnotations.hpp>
20 #include <com/sun/star/sheet/XSheetAnnotationsSupplier.hpp>
21 #include <com/sun/star/sheet/XSpreadsheet.hpp>
22 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
23 #include <com/sun/star/uno/XInterface.hpp>
25 #include <com/sun/star/uno/Reference.hxx>
27 #include <cppu/unotype.hxx>
29 using namespace css;
30 using namespace css::uno;
32 namespace sc_apitest {
34 class ScAnnontationsObj : public CalcUnoApiTest, public apitest::XElementAccess,
35 public apitest::XEnumerationAccess,
36 public apitest::XIndexAccess,
37 public apitest::XSheetAnnotations
39 public:
40 ScAnnontationsObj();
42 virtual void setUp() override;
43 virtual void tearDown() override;
45 virtual uno::Reference< uno::XInterface > init() override;
46 virtual uno::Reference< sheet::XSheetAnnotations > getAnnotations(tools::Long nIndex) override;
48 CPPUNIT_TEST_SUITE(ScAnnontationsObj);
50 // XElementAccess
51 CPPUNIT_TEST(testGetElementType);
52 CPPUNIT_TEST(testHasElements);
54 // XEnumerationAccess
55 CPPUNIT_TEST(testCreateEnumeration);
57 // XIndexAccess
58 CPPUNIT_TEST(testGetByIndex);
59 CPPUNIT_TEST(testGetCount);
61 // XSheetAnnotations
62 CPPUNIT_TEST(testCount);
63 CPPUNIT_TEST(testIndex);
64 CPPUNIT_TEST(testInsertNew);
65 CPPUNIT_TEST(testRemoveByIndex);
67 CPPUNIT_TEST_SUITE_END();
69 private:
71 uno::Reference< lang::XComponent > mxComponent;
75 ScAnnontationsObj::ScAnnontationsObj()
76 : CalcUnoApiTest("/sc/qa/extras/testdocuments")
77 , XElementAccess(cppu::UnoType<sheet::XSheetAnnotation>::get())
78 , XIndexAccess(1)
82 uno::Reference< sheet::XSheetAnnotations> ScAnnontationsObj::getAnnotations(tools::Long nIndex)
84 // get the sheet
85 uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW);
87 uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW);
88 uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(nIndex), UNO_QUERY_THROW);
90 // get the annotations collection
91 uno::Reference< sheet::XSheetAnnotationsSupplier > xAnnotationSupplier(xSheet, UNO_QUERY_THROW);
92 uno::Reference< sheet::XSheetAnnotations > xSheetAnnotations( xAnnotationSupplier->getAnnotations(), UNO_SET_THROW);
94 return xSheetAnnotations;
97 uno::Reference< uno::XInterface > ScAnnontationsObj::init()
99 return getAnnotations(0);
102 void ScAnnontationsObj::setUp()
104 CalcUnoApiTest::setUp();
106 // get the test file
107 OUString aFileURL;
108 createFileURL("ScAnnotationObj.ods", aFileURL);
109 mxComponent = loadFromDesktop(aFileURL);
112 void ScAnnontationsObj::tearDown()
114 closeDocument(mxComponent);
115 CalcUnoApiTest::tearDown();
118 CPPUNIT_TEST_SUITE_REGISTRATION(ScAnnontationsObj);
122 CPPUNIT_PLUGIN_IMPLEMENT();
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */