LibreOffice Module winaccessibility (master) 1
AccActionBase.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
21// AccActionBase.cpp: implementation of the CAccActionBase class.
22
23#include "stdafx.h"
24
25#include "AccActionBase.h"
26#include <com/sun/star/accessibility/XAccessible.hpp>
27#include <com/sun/star/accessibility/AccessibleStateType.hpp>
28#include <com/sun/star/accessibility/AccessibleRole.hpp>
29#include <com/sun/star/accessibility/XAccessibleContext.hpp>
30
31#include <vcl/svapp.hxx>
34
35#include "acccommon.h"
36
37using namespace com::sun::star::accessibility::AccessibleRole;
38using namespace com::sun::star::accessibility;
39using namespace com::sun::star::uno;
40using namespace com::sun::star::awt;
41
42
43// Construction/Destruction
44
45
47{}
48
50{}
51
57COM_DECLSPEC_NOTHROW STDMETHODIMP CAccActionBase::nActions(/*[out,retval]*/long* nActions)
58{
60
61 try {
62
63 // #CHECK#
64 if( pRXAct.is() && nActions != nullptr )
65 {
66 *nActions = GetXInterface()->getAccessibleActionCount();
67 return S_OK;
68 }
69 *nActions = 0;
70
71 return S_OK;
72
73 } catch(...) { return E_FAIL; }
74}
75
81COM_DECLSPEC_NOTHROW STDMETHODIMP CAccActionBase::doAction(/* [in] */ long actionIndex)
82{
84
85 try {
86
87 if( pRXAct.is() )
88 {
89 return GetXInterface()->doAccessibleAction( actionIndex )?S_OK:E_FAIL;
90 }
91 return E_FAIL;
92
93 } catch(...) { return E_FAIL; }
94}
95
102COM_DECLSPEC_NOTHROW STDMETHODIMP CAccActionBase::get_description(long actionIndex,BSTR __RPC_FAR *description)
103{
105
106 try {
107
108 // #CHECK#
109 if(description == nullptr)
110 return E_INVALIDARG;
111
112 // #CHECK XInterface#
113 if(!pRXAct.is())
114 return E_FAIL;
115
116 OUString ouStr = GetXInterface()->getAccessibleActionDescription(actionIndex);
117 // #CHECK#
118
119 SysFreeString(*description);
120 *description = SysAllocString(o3tl::toW(ouStr.getStr()));
121
122 return S_OK;
123
124 } catch(...) { return E_FAIL; }
125}
126
127COM_DECLSPEC_NOTHROW STDMETHODIMP CAccActionBase::get_name( long, BSTR __RPC_FAR *)
128{
129 return E_NOTIMPL;
130}
131
132COM_DECLSPEC_NOTHROW STDMETHODIMP CAccActionBase::get_localizedName( long, BSTR __RPC_FAR *)
133{
134 return E_NOTIMPL;
135}
136
147COM_DECLSPEC_NOTHROW STDMETHODIMP CAccActionBase::get_keyBinding(
148 /* [in] */ long actionIndex,
149 /* [in] */ long,
150 /* [length_is][length_is][size_is][size_is][out] */ BSTR __RPC_FAR *__RPC_FAR *keyBinding,
151 /* [retval][out] */ long __RPC_FAR *nBinding)
152{
154
155 try {
156
157 if( !keyBinding || !nBinding)
158 return E_INVALIDARG;
159
160 if( !pRXAct.is() )
161 return E_FAIL;
162
163 Reference< XAccessibleKeyBinding > binding = GetXInterface()->getAccessibleActionKeyBinding(actionIndex);
164 if( !binding.is() )
165 return E_FAIL;
166
167 sal_Int32 nCount = binding->getAccessibleKeyBindingCount();
168
169 *keyBinding = static_cast<BSTR*>(::CoTaskMemAlloc(nCount*sizeof(BSTR)));
170
171 // #CHECK Memory Allocation#
172 if(*keyBinding == nullptr)
173 return E_FAIL;
174
175 for( sal_Int32 index = 0;index < nCount;index++ )
176 {
178 binding->getAccessibleKeyBinding(index));
179
180 (*keyBinding)[index] = SysAllocString(o3tl::toW(wString.getStr()));
181 }
182
183 *nBinding = nCount;
184 return S_OK;
185
186 } catch(...) { return E_FAIL; }
187}
188
194COM_DECLSPEC_NOTHROW STDMETHODIMP CAccActionBase::put_XInterface(hyper pXInterface)
195{
196 // internal IUNOXWrapper - no mutex meeded
197
198 try {
199
200 CUNOXWrapper::put_XInterface(pXInterface);
201
202 //special query.
203 if(pUNOInterface == nullptr)
204 return E_FAIL;
205 Reference<XAccessibleContext> pRContext = pUNOInterface->getAccessibleContext();
206 if( !pRContext.is() )
207 return E_FAIL;
208
209 Reference<XAccessibleAction> pRXI(pRContext,UNO_QUERY);
210 if( !pRXI.is() )
211 pRXAct = nullptr;
212 else
213 pRXAct = pRXI.get();
214 return S_OK;
215
216 } catch(...) { return E_FAIL; }
217}
218
219/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
long long BSTR __RPC_FAR *__RPC_FAR * keyBinding
Definition: AccActionBase.h:61
STDMETHOD() put_XInterface(hyper pXInterface) override
Override of IUNOXWrapper.
css::accessibility::XAccessibleAction * GetXInterface()
Definition: AccActionBase.h:71
virtual ~CAccActionBase()
STDMETHOD() nActions(long *nActions)
Returns the number of action.
STDMETHOD() doAction(long actionIndex)
Performs specified action on the object.
css::uno::Reference< css::accessibility::XAccessibleAction > pRXAct
Definition: AccActionBase.h:68
STDMETHOD() get_name(long actionIndex, BSTR __RPC_FAR *name)
STDMETHOD() get_localizedName(long actionIndex, BSTR __RPC_FAR *localizedName)
long long BSTR __RPC_FAR *__RPC_FAR long __RPC_FAR * nBinding
Definition: AccActionBase.h:62
STDMETHOD() get_description(long actionIndex, BSTR __RPC_FAR *description)
Gets description of specified action.
STDMETHOD() put_XInterface(hyper pXInterface) override
Definition: UNOXWrapper.cxx:27
css::accessibility::XAccessible * pUNOInterface
Definition: UNOXWrapper.h:34
int nCount
OUString GetkeyBindingStrByXkeyBinding(const Sequence< KeyStroke > &keySet)
index