Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / winaccessibility / source / UAccCOM / AccComponentBase.cxx
blobad3b06f796681cab7d704f41bfed1916569c0699
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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"
27 using namespace com::sun::star::accessibility;
28 using namespace com::sun::star::uno;
31 // Construction/Destruction
34 CAccComponentBase::CAccComponentBase()
37 CAccComponentBase::~CAccComponentBase()
41 /**
42 * Returns the location of the upper left corner of the object's bounding
43 * box relative to the parent.
45 * @param Location the upper left corner of the object's bounding box.
47 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccComponentBase::get_locationInParent(long *x, long *y)
49 SolarMutexGuard g;
51 try
53 if (x == nullptr || y == nullptr)
54 return E_INVALIDARG;
55 // #CHECK XInterface#
56 if(!pRXComp.is())
57 return E_FAIL;
59 const css::awt::Point& pt = GetXInterface()->getLocation();
60 *x = pt.X;
61 *y = pt.Y;
62 return S_OK;
64 catch(...)
66 return E_FAIL;
70 /**
71 * Returns the location of the upper left corner of the object's bounding
72 * box in screen.
74 * @param Location the upper left corner of the object's bounding
75 * box in screen coordinates.
77 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccComponentBase::get_locationOnScreen(long *x, long *y)
79 SolarMutexGuard g;
81 try
83 if (x == nullptr || y == nullptr)
84 return E_INVALIDARG;
85 // #CHECK XInterface#
86 if(!pRXComp.is())
87 return E_FAIL;
89 const css::awt::Point& pt = GetXInterface()->getLocationOnScreen();
90 *x = pt.X;
91 *y = pt.Y;
92 return S_OK;
95 catch(...)
97 return E_FAIL;
102 * Grabs the focus to this object.
104 * @param success the boolean result to be returned.
106 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccComponentBase::grabFocus(boolean * success)
108 SolarMutexGuard g;
110 ENTER_PROTECTED_BLOCK
112 if (success == nullptr)
113 return E_INVALIDARG;
114 // #CHECK XInterface#
115 if(!pRXComp.is())
117 return E_FAIL;
119 GetXInterface()->grabFocus();
120 *success = TRUE;
122 return S_OK;
124 LEAVE_PROTECTED_BLOCK
128 * Returns the foreground color of this object.
130 * @param Color the color of foreground.
132 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccComponentBase::get_foreground(IA2Color * foreground)
134 SolarMutexGuard g;
136 ENTER_PROTECTED_BLOCK
138 if (foreground == nullptr)
139 return E_INVALIDARG;
140 // #CHECK XInterface#
141 if(!pRXComp.is())
143 return E_FAIL;
145 *foreground = static_cast<long>(GetXInterface()->getForeground());
147 return S_OK;
149 LEAVE_PROTECTED_BLOCK
153 * Returns the background color of this object.
155 * @param Color the color of background.
157 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccComponentBase::get_background(IA2Color * background)
159 SolarMutexGuard g;
161 ENTER_PROTECTED_BLOCK
163 if (background == nullptr)
164 return E_INVALIDARG;
165 // #CHECK XInterface#
166 if(!pRXComp.is())
168 return E_FAIL;
170 *background = static_cast<long>(GetXInterface()->getBackground());
172 return S_OK;
174 LEAVE_PROTECTED_BLOCK
178 * Override of IUNOXWrapper.
180 * @param pXInterface the pointer of UNO interface.
182 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccComponentBase::put_XInterface(hyper pXInterface)
184 // internal IUNOXWrapper - no mutex meeded
186 ENTER_PROTECTED_BLOCK
188 CUNOXWrapper::put_XInterface(pXInterface);
189 //special query.
190 if(pUNOInterface == nullptr)
191 return E_FAIL;
192 Reference<XAccessibleContext> pRContext = pUNOInterface->getAccessibleContext();
193 if( !pRContext.is() )
195 return E_FAIL;
197 Reference<XAccessibleComponent> pRXI(pRContext,UNO_QUERY);
198 if( !pRXI.is() )
199 pRXComp = nullptr;
200 else
201 pRXComp = pRXI.get();
203 return S_OK;
205 LEAVE_PROTECTED_BLOCK
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */