Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / winaccessibility / source / UAccCOM / AccHyperLink.cxx
blob8753753a494a76a5d3770b8bb8ffd1f6c1ddb803
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 "AccHyperLink.h"
23 #if defined __clang__
24 #pragma clang diagnostic push
25 #pragma clang diagnostic ignored "-Wnon-virtual-dtor"
26 #endif
27 #include <UAccCOM.h>
28 #if defined __clang__
29 #pragma clang diagnostic pop
30 #endif
32 #include <vcl/svapp.hxx>
34 #include <com/sun/star/accessibility/XAccessible.hpp>
35 #include <com/sun/star/accessibility/XAccessibleAction.hpp>
36 #include "MAccessible.h"
38 using namespace com::sun::star::accessibility;
39 using namespace com::sun::star::uno;
40 using namespace com::sun::star::awt;
42 /**
43 * Returns the number of action.
45 * @param nActions the number of action.
47 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHyperLink::nActions(/*[out,retval]*/long* nActions)
50 return CAccActionBase::nActions(nActions);
53 /**
54 * Performs specified action on the object.
56 * @param actionIndex the index of action.
58 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHyperLink::doAction(/* [in] */ long actionIndex)
61 return CAccActionBase::doAction(actionIndex);
64 /**
65 * Gets description of specified action.
67 * @param actionIndex the index of action.
68 * @param description the description string of the specified action.
70 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHyperLink::get_description(long actionIndex,BSTR __RPC_FAR *description)
73 return CAccActionBase::get_description(actionIndex, description);
76 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHyperLink::get_name( long actionIndex, BSTR __RPC_FAR *name)
79 return CAccActionBase::get_name(actionIndex, name);
82 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHyperLink::get_localizedName( long actionIndex, BSTR __RPC_FAR *localizedName)
85 return CAccActionBase::get_name(actionIndex, localizedName);
88 /**
89 * Returns key binding object (if any) associated with specified action
90 * key binding is string.
91 * e.g. "alt+d" (like IAccessible::get_accKeyboardShortcut).
93 * @param actionIndex the index of action.
94 * @param nMaxBinding the max number of key binding.
95 * @param keyBinding the key binding array.
96 * @param nBinding the actual number of key binding returned.
98 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHyperLink::get_keyBinding(
99 /* [in] */ long actionIndex,
100 /* [in] */ long nMaxBinding,
101 /* [length_is][length_is][size_is][size_is][out] */ BSTR __RPC_FAR *__RPC_FAR *keyBinding,
102 /* [retval][out] */ long __RPC_FAR *nBinding)
105 return CAccActionBase::get_keyBinding(actionIndex, nMaxBinding, keyBinding, nBinding);
109 * get an object
110 * @param
111 * @return Result.
113 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHyperLink::get_anchor(/* [in] */ long index,
114 /* [retval][out] */ VARIANT __RPC_FAR *anchor)
116 SolarMutexGuard g;
118 ENTER_PROTECTED_BLOCK
120 // #CHECK#
121 if(anchor == nullptr)
123 return E_INVALIDARG;
125 // #CHECK XInterface#
126 if(!pRXLink.is())
128 return E_FAIL;
130 // Get Any type value via pRXLink.
131 css::uno::Any anyVal = GetXInterface()->getAccessibleActionAnchor(index);
132 // Convert Any to VARIANT.
133 CMAccessible::ConvertAnyToVariant(anyVal, anchor);
135 return S_OK;
137 LEAVE_PROTECTED_BLOCK
141 * get an object
142 * @param
143 * @return Result.
145 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHyperLink::get_anchorTarget(/* [in] */ long index,
146 /* [retval][out] */ VARIANT __RPC_FAR *anchorTarget)
148 SolarMutexGuard g;
150 ENTER_PROTECTED_BLOCK
152 // #CHECK#
153 if(anchorTarget == nullptr)
155 return E_INVALIDARG;
157 // #CHECK XInterface#
158 if(!pRXLink.is())
160 return E_FAIL;
162 // Get Any type value via pRXLink.
163 css::uno::Any anyVal = GetXInterface()->getAccessibleActionObject(index);
164 // Convert Any to VARIANT.
165 CMAccessible::ConvertAnyToVariant(anyVal, anchorTarget);
167 return S_OK;
169 LEAVE_PROTECTED_BLOCK
174 * Get start index.
175 * @param index Variant to get start index.
176 * @return Result.
178 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHyperLink::get_startIndex(/* [retval][out] */ long __RPC_FAR *index)
180 SolarMutexGuard g;
182 ENTER_PROTECTED_BLOCK
184 // #CHECK#
185 if(index == nullptr)
187 return E_INVALIDARG;
189 *index = GetXInterface()->getStartIndex();
191 return S_OK;
193 LEAVE_PROTECTED_BLOCK
197 * Get start index.
198 * @param index Variant to get end index.
199 * @return Result.
201 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHyperLink::get_endIndex(/* [retval][out] */ long __RPC_FAR *index)
203 SolarMutexGuard g;
205 ENTER_PROTECTED_BLOCK
207 // #CHECK#
208 if(index == nullptr)
210 return E_INVALIDARG;
212 // #CHECK XInterface#
213 if(!pRXLink.is())
215 return E_FAIL;
217 *index = GetXInterface()->getEndIndex();
219 return S_OK;
221 LEAVE_PROTECTED_BLOCK
225 * Judge if the hyperlink is valid.
226 * @param valid Variant to get validity.
227 * @return Result.
229 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHyperLink::get_valid(/* [retval][out] */ boolean __RPC_FAR *valid)
231 SolarMutexGuard g;
233 ENTER_PROTECTED_BLOCK
235 // #CHECK#
236 if(valid == nullptr)
238 return E_INVALIDARG;
240 // #CHECK XInterface#
241 if(!pRXLink.is())
243 return E_FAIL;
245 *valid = GetXInterface()->isValid();
247 return S_OK;
249 LEAVE_PROTECTED_BLOCK
253 * Put UNO interface.
254 * @param pXInterface XAccessibleContext interface.
255 * @return Result.
257 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHyperLink::put_XInterface(hyper pXInterface)
259 // internal IUNOXWrapper - no mutex meeded
261 ENTER_PROTECTED_BLOCK
263 CAccActionBase::put_XInterface(pXInterface);
264 //special query.
265 if(pUNOInterface != nullptr)
267 Reference<XAccessibleContext> pRContext = pUNOInterface->getAccessibleContext();
268 if( !pRContext.is() )
270 return E_FAIL;
272 Reference<XAccessibleHyperlink> pRXI(pRContext,UNO_QUERY);
273 if( !pRXI.is() )
275 pRXLink = nullptr;
277 else
278 pRXLink = pRXI.get();
280 return S_OK;
282 LEAVE_PROTECTED_BLOCK
286 * Put UNO interface.
287 * @param pXSubInterface XAccessibleHyperlink interface.
288 * @return Result.
290 COM_DECLSPEC_NOTHROW STDMETHODIMP CAccHyperLink::put_XSubInterface(hyper pXSubInterface)
292 // internal IUNOXWrapper - no mutex meeded
294 pRXLink = reinterpret_cast<XAccessibleHyperlink*>(pXSubInterface);
295 pRXAct = reinterpret_cast<XAccessibleAction*>(pXSubInterface);
297 return S_OK;
300 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */