LibreOffice Module test (master)  1
xcontrolaccess.cxx
Go to the documentation of this file.
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.
4  *
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  */
9 
11 #include <test/helper/form.hxx>
12 
13 #include <com/sun/star/awt/XControl.hpp>
14 #include <com/sun/star/awt/XControlModel.hpp>
15 #include <com/sun/star/drawing/XControlShape.hpp>
16 #include <com/sun/star/drawing/XDrawPage.hpp>
17 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
18 #include <com/sun/star/drawing/XShape.hpp>
19 #include <com/sun/star/drawing/XShapes.hpp>
20 #include <com/sun/star/lang/XComponent.hpp>
21 #include <com/sun/star/view/XControlAccess.hpp>
22 
23 #include <com/sun/star/uno/Reference.hxx>
24 
25 #include <cppunit/TestAssert.h>
26 
27 using namespace css;
28 
29 namespace apitest
30 {
31 void XControlAccess::testGetControl()
32 {
33  uno::Reference<view::XControlAccess> xCA(init(), uno::UNO_QUERY_THROW);
34 
35  uno::Reference<lang::XComponent> xComponent(getXComponent(), uno::UNO_QUERY_THROW);
36  uno::Reference<drawing::XDrawPagesSupplier> xDPS(xComponent, uno::UNO_QUERY_THROW);
37  uno::Reference<drawing::XDrawPage> xDP(xDPS->getDrawPages()->getByIndex(0),
38  uno::UNO_QUERY_THROW);
39 
40  uno::Reference<drawing::XShapes> xShapes(xDP, uno::UNO_QUERY_THROW);
41  uno::Reference<drawing::XShape> xShape(
42  helper::form::createControlShape(xComponent, u"CommandButton", 10000, 50000, 100, 100),
43  uno::UNO_QUERY_THROW);
44 
45  xShapes->add(xShape);
46 
47  uno::Reference<drawing::XControlShape> xCS(xShape, uno::UNO_QUERY_THROW);
48  uno::Reference<awt::XControlModel> xCM(xCS->getControl(), uno::UNO_SET_THROW);
49  uno::Reference<awt::XControl> xControl(xCA->getControl(xCM), uno::UNO_SET_THROW);
50 
51  CPPUNIT_ASSERT(xControl.is());
52 }
53 
54 } // namespace apitest
55 
56 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
float u
uno::Reference< drawing::XControlShape > OOO_DLLPUBLIC_TEST createControlShape(const uno::Reference< lang::XComponent > &r_xComponent, std::u16string_view r_aKind, const sal_Int32 nX, const sal_Int32 nY, const sal_Int32 nHeight, const sal_Int32 nWidth)
Definition: form.cxx:35
FILE * init(int, char **)