tdf#164627 docx export: consolidate getWordCompatibilityMode()
[LibreOffice.git] / sc / qa / extras / scannotationobj.cxx
blob3a6b6e9f4bafa24c6d8b10eec028a1491ca4284f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/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>
27 using namespace css;
29 namespace sc_apitest
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
39 public:
40 ScAnnontationObj();
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);
49 // XChild
50 CPPUNIT_TEST(testGetSetParent);
52 // XServiceInfo
53 CPPUNIT_TEST(testGetImplementationName);
54 CPPUNIT_TEST(testGetSupportedServiceNames);
55 CPPUNIT_TEST(testSupportsService);
57 // XSheetAnnotation
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);
67 // XSimpleText
68 CPPUNIT_TEST(testCreateTextCursor);
69 CPPUNIT_TEST(testCreateTextCursorByRange);
70 CPPUNIT_TEST(testInsertString);
71 CPPUNIT_TEST(testInsertControlCharacter);
73 // XTextRange
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)
91 // get the sheet
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);
97 // get the cell
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(),
104 uno::UNO_SET_THROW);
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()
122 UnoApiTest::setUp();
124 // get the test file
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: */