bump product version to 4.1.6.2
[LibreOffice.git] / sc / qa / extras / scannotationshapeobj.cxx
blobd407118a664a37ef53a21d071821f839e887d6b8
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/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
20 using namespace css;
21 using namespace css::uno;
23 namespace sc_apitest {
25 class ScAnnotationShapeObj : public UnoApiTest, apitest::XText
27 public:
28 ScAnnotationShapeObj();
31 virtual void setUp();
32 virtual void tearDown();
33 virtual uno::Reference<uno::XInterface> init();
34 virtual uno::Reference<text::XTextContent> getTextContent();
36 CPPUNIT_TEST_SUITE(ScAnnotationShapeObj);
38 // XText
39 CPPUNIT_TEST(testInsertRemoveTextContent);
41 CPPUNIT_TEST_SUITE_END();
43 private:
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()
57 ++nTest;
58 UnoApiTest::setUp();
61 void ScAnnotationShapeObj::tearDown()
63 if (nTest == NUMBER_OF_TESTS)
65 mxField.clear();
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();
93 return xShape;
94 #else
95 return uno::Reference<drawing::XShape>();
96 #endif
99 uno::Reference<text::XTextContent> ScAnnotationShapeObj::getTextContent()
101 #ifdef FIXME_REMOVE_WHEN_RE_BASE_COMPLETE
102 if (!mxField.is())
104 uno::Reference<lang::XMultiServiceFactory> xSM(mxComponent, UNO_QUERY_THROW);
105 mxField.set(xSM->createInstance("com.sun.star.text.TextField.DateTime"), UNO_QUERY_THROW);
107 #endif
108 return mxField;
111 CPPUNIT_TEST_SUITE_REGISTRATION(ScAnnotationShapeObj);
113 CPPUNIT_PLUGIN_IMPLEMENT();
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */