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/sheet/XSheetAnnotationAnchor.hpp>
19 #include <com/sun/star/sheet/XSpreadsheet.hpp>
20 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
21 #include <com/sun/star/table/CellAddress.hpp>
22 #include <com/sun/star/table/XCell.hpp>
23 #include <com/sun/star/uno/XInterface.hpp>
25 #include <com/sun/star/uno/Reference.hxx>
31 class ScAnnontationObj
: public UnoApiTest
,
32 public apitest::XChild
,
33 public apitest::XServiceInfo
,
34 public apitest::XSheetAnnotation
,
35 public apitest::XSheetAnnotationShapeSupplier
,
36 public apitest::XSimpleText
,
37 public apitest::XTextRange
42 virtual void setUp() override
;
44 virtual uno::Reference
<uno::XInterface
> init() override
;
45 virtual uno::Reference
<sheet::XSheetAnnotation
> getAnnotation(table::CellAddress
&) override
;
47 CPPUNIT_TEST_SUITE(ScAnnontationObj
);
50 CPPUNIT_TEST(testGetSetParent
);
53 CPPUNIT_TEST(testGetImplementationName
);
54 CPPUNIT_TEST(testGetSupportedServiceNames
);
55 CPPUNIT_TEST(testSupportsService
);
58 CPPUNIT_TEST(testGetPosition
);
59 CPPUNIT_TEST(testGetAuthor
);
60 CPPUNIT_TEST(testGetDate
);
61 CPPUNIT_TEST(testGetIsVisible
);
62 CPPUNIT_TEST(testSetIsVisible
);
64 // XSheetAnnotationShapeSupplier
65 CPPUNIT_TEST(testGetAnnotationShape
);
68 CPPUNIT_TEST(testCreateTextCursor
);
69 CPPUNIT_TEST(testCreateTextCursorByRange
);
70 CPPUNIT_TEST(testInsertString
);
71 CPPUNIT_TEST(testInsertControlCharacter
);
74 CPPUNIT_TEST(testGetEnd
);
75 CPPUNIT_TEST(testGetSetString
);
76 CPPUNIT_TEST(testGetStart
);
77 CPPUNIT_TEST(testGetText
);
79 CPPUNIT_TEST_SUITE_END();
82 ScAnnontationObj::ScAnnontationObj()
83 : UnoApiTest(u
"/sc/qa/extras/testdocuments"_ustr
)
84 , XServiceInfo(u
"ScAnnotationObj"_ustr
, u
"com.sun.star.sheet.CellAnnotation"_ustr
)
88 uno::Reference
<sheet::XSheetAnnotation
>
89 ScAnnontationObj::getAnnotation(table::CellAddress
& xCellAddress
)
92 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
93 uno::Reference
<container::XIndexAccess
> xIndex(xDoc
->getSheets(), uno::UNO_QUERY_THROW
);
94 uno::Reference
<sheet::XSpreadsheet
> xSheet(xIndex
->getByIndex(xCellAddress
.Sheet
),
95 uno::UNO_QUERY_THROW
);
98 uno::Reference
<table::XCell
> xCell(
99 xSheet
->getCellByPosition(xCellAddress
.Column
, xCellAddress
.Row
), uno::UNO_SET_THROW
);
101 // get the annotation from cell
102 uno::Reference
<sheet::XSheetAnnotationAnchor
> xAnnotationAnchor(xCell
, uno::UNO_QUERY_THROW
);
103 uno::Reference
<sheet::XSheetAnnotation
> xSheetAnnotation(xAnnotationAnchor
->getAnnotation(),
106 return xSheetAnnotation
;
109 uno::Reference
<uno::XInterface
> ScAnnontationObj::init()
111 // tested annotation is in sheet 0 cell C2
112 table::CellAddress aCellAddress
;
113 aCellAddress
.Sheet
= 0;
114 aCellAddress
.Row
= 1;
115 aCellAddress
.Column
= 2;
117 return getAnnotation(aCellAddress
);
120 void ScAnnontationObj::setUp()
125 loadFromFile(u
"ScAnnotationObj.ods");
128 CPPUNIT_TEST_SUITE_REGISTRATION(ScAnnontationObj
);
130 } // namespace sc_apitest
132 CPPUNIT_PLUGIN_IMPLEMENT();
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */