1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
10 #include <test/unoapi_test.hxx>
11 #include <test/container/xchild.hxx>
12 #include <test/lang/xserviceinfo.hxx>
13 #include <test/sheet/xsheetannotation.hxx>
14 #include <test/sheet/xsheetannotationshapesupplier.hxx>
15 #include <test/text/xsimpletext.hxx>
16 #include <test/text/xtextrange.hxx>
18 #include <com/sun/star/lang/XComponent.hpp>
19 #include <com/sun/star/sheet/XSheetAnnotationAnchor.hpp>
20 #include <com/sun/star/sheet/XSpreadsheet.hpp>
21 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
22 #include <com/sun/star/table/CellAddress.hpp>
23 #include <com/sun/star/table/XCell.hpp>
24 #include <com/sun/star/uno/XInterface.hpp>
26 #include <com/sun/star/uno/Reference.hxx>
32 class ScAnnontationObj
: public UnoApiTest
,
33 public apitest::XChild
,
34 public apitest::XServiceInfo
,
35 public apitest::XSheetAnnotation
,
36 public apitest::XSheetAnnotationShapeSupplier
,
37 public apitest::XSimpleText
,
38 public apitest::XTextRange
43 virtual void setUp() override
;
45 virtual uno::Reference
<uno::XInterface
> init() override
;
46 virtual uno::Reference
<sheet::XSheetAnnotation
> getAnnotation(table::CellAddress
&) override
;
48 CPPUNIT_TEST_SUITE(ScAnnontationObj
);
51 CPPUNIT_TEST(testGetSetParent
);
54 CPPUNIT_TEST(testGetImplementationName
);
55 CPPUNIT_TEST(testGetSupportedServiceNames
);
56 CPPUNIT_TEST(testSupportsService
);
59 CPPUNIT_TEST(testGetPosition
);
60 CPPUNIT_TEST(testGetAuthor
);
61 CPPUNIT_TEST(testGetDate
);
62 CPPUNIT_TEST(testGetIsVisible
);
63 CPPUNIT_TEST(testSetIsVisible
);
65 // XSheetAnnotationShapeSupplier
66 CPPUNIT_TEST(testGetAnnotationShape
);
69 CPPUNIT_TEST(testCreateTextCursor
);
70 CPPUNIT_TEST(testCreateTextCursorByRange
);
71 CPPUNIT_TEST(testInsertString
);
72 CPPUNIT_TEST(testInsertControlCharacter
);
75 CPPUNIT_TEST(testGetEnd
);
76 CPPUNIT_TEST(testGetSetString
);
77 CPPUNIT_TEST(testGetStart
);
78 CPPUNIT_TEST(testGetText
);
80 CPPUNIT_TEST_SUITE_END();
83 ScAnnontationObj::ScAnnontationObj()
84 : UnoApiTest("/sc/qa/extras/testdocuments")
85 , XServiceInfo("ScAnnotationObj", "com.sun.star.sheet.CellAnnotation")
89 uno::Reference
<sheet::XSheetAnnotation
>
90 ScAnnontationObj::getAnnotation(table::CellAddress
& xCellAddress
)
93 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
94 uno::Reference
<container::XIndexAccess
> xIndex(xDoc
->getSheets(), uno::UNO_QUERY_THROW
);
95 uno::Reference
<sheet::XSpreadsheet
> xSheet(xIndex
->getByIndex(xCellAddress
.Sheet
),
96 uno::UNO_QUERY_THROW
);
99 uno::Reference
<table::XCell
> xCell(
100 xSheet
->getCellByPosition(xCellAddress
.Column
, xCellAddress
.Row
), uno::UNO_SET_THROW
);
102 // get the annotation from cell
103 uno::Reference
<sheet::XSheetAnnotationAnchor
> xAnnotationAnchor(xCell
, uno::UNO_QUERY_THROW
);
104 uno::Reference
<sheet::XSheetAnnotation
> xSheetAnnotation(xAnnotationAnchor
->getAnnotation(),
107 return xSheetAnnotation
;
110 uno::Reference
<uno::XInterface
> ScAnnontationObj::init()
112 // tested annotation is in sheet 0 cell C2
113 table::CellAddress aCellAddress
;
114 aCellAddress
.Sheet
= 0;
115 aCellAddress
.Row
= 1;
116 aCellAddress
.Column
= 2;
118 return getAnnotation(aCellAddress
);
121 void ScAnnontationObj::setUp()
126 loadFromURL(u
"ScAnnotationObj.ods");
129 CPPUNIT_TEST_SUITE_REGISTRATION(ScAnnontationObj
);
131 } // namespace sc_apitest
133 CPPUNIT_PLUGIN_IMPLEMENT();
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */