1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/text/xtext.hxx>
13 #include <com/sun/star/sheet/XSheetAnnotationAnchor.hpp>
14 #include <com/sun/star/sheet/XSheetAnnotationShapeSupplier.hpp>
15 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
16 #include <com/sun/star/sheet/XSpreadsheet.hpp>
18 #define NUMBER_OF_TESTS 1
21 using namespace css::uno
;
23 namespace sc_apitest
{
25 class ScAnnotationShapeObj
: public UnoApiTest
, apitest::XText
28 ScAnnotationShapeObj();
32 virtual void tearDown();
33 virtual uno::Reference
<uno::XInterface
> init();
34 virtual uno::Reference
<text::XTextContent
> getTextContent();
36 CPPUNIT_TEST_SUITE(ScAnnotationShapeObj
);
39 CPPUNIT_TEST(testInsertRemoveTextContent
);
41 CPPUNIT_TEST_SUITE_END();
44 static sal_Int32 nTest
;
45 static uno::Reference
<lang::XComponent
> mxComponent
;
46 static uno::Reference
<text::XTextContent
> mxField
;
49 sal_Int32
ScAnnotationShapeObj::nTest
= 0;
50 uno::Reference
<lang::XComponent
> ScAnnotationShapeObj::mxComponent
;
51 uno::Reference
<text::XTextContent
> ScAnnotationShapeObj::mxField
;
53 ScAnnotationShapeObj::ScAnnotationShapeObj() {}
55 void ScAnnotationShapeObj::setUp()
61 void ScAnnotationShapeObj::tearDown()
63 if (nTest
== NUMBER_OF_TESTS
)
66 closeDocument(mxComponent
);
69 UnoApiTest::tearDown();
72 uno::Reference
<uno::XInterface
> ScAnnotationShapeObj::init()
74 #ifdef FIXME_REMOVE_WHEN_RE_BASE_COMPLETE
75 if (!mxComponent
.is())
76 // Load an empty document.
77 mxComponent
= loadFromDesktop("private:factory/scalc");
79 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc(mxComponent
, UNO_QUERY_THROW
);
80 uno::Reference
<container::XIndexAccess
> xIA(xDoc
->getSheets(), UNO_QUERY_THROW
);
81 uno::Reference
<sheet::XSpreadsheet
> xSheet(xIA
->getByIndex(0), UNO_QUERY_THROW
);
83 // Use cell A1 for this.
84 uno::Reference
<table::XCell
> xCell
= xSheet
->getCellByPosition(0, 0);
85 uno::Reference
<sheet::XSheetAnnotationAnchor
> xAnchor(xCell
, UNO_QUERY_THROW
);
86 uno::Reference
<sheet::XSheetAnnotation
> xAnnotation
= xAnchor
->getAnnotation();
87 uno::Reference
<text::XSimpleText
> xAnnoText(xAnnotation
, UNO_QUERY_THROW
);
88 xAnnoText
->setString("ScAnnotationShapeObj");
90 uno::Reference
<sheet::XSheetAnnotationShapeSupplier
> xShapeSupp(xAnnotation
, UNO_QUERY_THROW
);
91 uno::Reference
<drawing::XShape
> xShape
= xShapeSupp
->getAnnotationShape();
95 return uno::Reference
<drawing::XShape
>();
99 uno::Reference
<text::XTextContent
> ScAnnotationShapeObj::getTextContent()
101 #ifdef FIXME_REMOVE_WHEN_RE_BASE_COMPLETE
104 uno::Reference
<lang::XMultiServiceFactory
> xSM(mxComponent
, UNO_QUERY_THROW
);
105 mxField
.set(xSM
->createInstance("com.sun.star.text.TextField.DateTime"), UNO_QUERY_THROW
);
111 CPPUNIT_TEST_SUITE_REGISTRATION(ScAnnotationShapeObj
);
113 CPPUNIT_PLUGIN_IMPLEMENT();
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */