LibreOffice Module winaccessibility (master) 1
AccComponentBase.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include "stdafx.h"
21#include "AccComponentBase.h"
22#include <com/sun/star/accessibility/XAccessible.hpp>
23#include <com/sun/star/accessibility/XAccessibleContext.hpp>
24#include <vcl/svapp.hxx>
25#include "MAccessible.h"
26
27using namespace com::sun::star::accessibility;
28using namespace com::sun::star::uno;
29
30// Construction/Destruction
31
33
35
42COM_DECLSPEC_NOTHROW STDMETHODIMP CAccComponentBase::get_locationInParent(long* x, long* y)
43{
45
46 try
47 {
48 if (x == nullptr || y == nullptr)
49 return E_INVALIDARG;
50 // #CHECK XInterface#
51 if (!pRXComp.is())
52 return E_FAIL;
53
54 const css::awt::Point& pt = GetXInterface()->getLocation();
55 *x = pt.X;
56 *y = pt.Y;
57 return S_OK;
58 }
59 catch (...)
60 {
61 return E_FAIL;
62 }
63}
64
72COM_DECLSPEC_NOTHROW STDMETHODIMP CAccComponentBase::get_locationOnScreen(long* x, long* y)
73{
75
76 try
77 {
78 if (x == nullptr || y == nullptr)
79 return E_INVALIDARG;
80 // #CHECK XInterface#
81 if (!pRXComp.is())
82 return E_FAIL;
83
84 const css::awt::Point& pt = GetXInterface()->getLocationOnScreen();
85 *x = pt.X;
86 *y = pt.Y;
87 return S_OK;
88 }
89 catch (...)
90 {
91 return E_FAIL;
92 }
93}
94
100COM_DECLSPEC_NOTHROW STDMETHODIMP CAccComponentBase::grabFocus(boolean* success)
101{
103
104 try
105 {
106 if (success == nullptr)
107 return E_INVALIDARG;
108 // #CHECK XInterface#
109 if (!pRXComp.is())
110 {
111 return E_FAIL;
112 }
113 GetXInterface()->grabFocus();
114 *success = TRUE;
115
116 return S_OK;
117 }
118 catch (...)
119 {
120 return E_FAIL;
121 }
122}
123
129COM_DECLSPEC_NOTHROW STDMETHODIMP CAccComponentBase::get_foreground(IA2Color* foreground)
130{
132
133 try
134 {
135 if (foreground == nullptr)
136 return E_INVALIDARG;
137 // #CHECK XInterface#
138 if (!pRXComp.is())
139 {
140 return E_FAIL;
141 }
142 *foreground = static_cast<long>(GetXInterface()->getForeground());
143
144 return S_OK;
145 }
146 catch (...)
147 {
148 return E_FAIL;
149 }
150}
151
157COM_DECLSPEC_NOTHROW STDMETHODIMP CAccComponentBase::get_background(IA2Color* background)
158{
160
161 try
162 {
163 if (background == nullptr)
164 return E_INVALIDARG;
165 // #CHECK XInterface#
166 if (!pRXComp.is())
167 {
168 return E_FAIL;
169 }
170 *background = static_cast<long>(GetXInterface()->getBackground());
171
172 return S_OK;
173 }
174 catch (...)
175 {
176 return E_FAIL;
177 }
178}
179
185COM_DECLSPEC_NOTHROW STDMETHODIMP CAccComponentBase::put_XInterface(hyper pXInterface)
186{
187 // internal IUNOXWrapper - no mutex meeded
188
189 try
190 {
191 CUNOXWrapper::put_XInterface(pXInterface);
192 //special query.
193 if (pUNOInterface == nullptr)
194 return E_FAIL;
195 Reference<XAccessibleContext> pRContext = pUNOInterface->getAccessibleContext();
196 if (!pRContext.is())
197 {
198 return E_FAIL;
199 }
200 Reference<XAccessibleComponent> pRXI(pRContext, UNO_QUERY);
201 if (!pRXI.is())
202 pRXComp = nullptr;
203 else
204 pRXComp = pRXI.get();
205
206 return S_OK;
207 }
208 catch (...)
209 {
210 return E_FAIL;
211 }
212}
213
214/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
STDMETHOD() grabFocus(boolean *success)
Grabs the focus to this object.
STDMETHOD() put_XInterface(hyper pXInterface) override
Override of IUNOXWrapper.
css::accessibility::XAccessibleComponent * GetXInterface()
STDMETHOD() get_background(IA2Color *background)
Returns the background color of this object.
STDMETHOD() get_locationInParent(long *x, long *y)
Returns the location of the upper left corner of the object's bounding box relative to the parent.
STDMETHOD() get_locationOnScreen(long *x, long *y)
Returns the location of the upper left corner of the object's bounding box in screen.
virtual ~CAccComponentBase()
STDMETHOD() get_foreground(IA2Color *foreground)
Returns the foreground color of this object.
css::uno::Reference< css::accessibility::XAccessibleComponent > pRXComp
STDMETHOD() put_XInterface(hyper pXInterface) override
Definition: UNOXWrapper.cxx:27
css::accessibility::XAccessible * pUNOInterface
Definition: UNOXWrapper.h:34
float y
float x
#define TRUE
long IA2Color
A value specifying a color in ARGB format, where each 8 bit color component specifies alpha,...