bump product version to 5.0.4.1
[LibreOffice.git] / winaccessibility / source / UAccCOM / AccHyperLink.cxx
blob04cd3e8eafa27283a2399ee187a8ab51b50ed01b
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 "UAccCOM.h"
22 #include "AccHyperLink.h"
24 #include <vcl/svapp.hxx>
26 #include <com/sun/star/accessibility/XAccessible.hpp>
27 #include <com/sun/star/accessibility/XAccessibleAction.hpp>
28 #include "MAccessible.h"
30 using namespace com::sun::star::accessibility;
31 using namespace com::sun::star::uno;
32 using namespace com::sun::star::awt;
34 /**
35 * Returns the number of action.
37 * @param nActions the number of action.
39 STDMETHODIMP CAccHyperLink::nActions(/*[out,retval]*/long* nActions)
42 return CAccActionBase::nActions(nActions);
45 /**
46 * Performs specified action on the object.
48 * @param actionIndex the index of action.
50 STDMETHODIMP CAccHyperLink::doAction(/* [in] */ long actionIndex)
53 return CAccActionBase::doAction(actionIndex);
56 /**
57 * Gets description of specified action.
59 * @param actionIndex the index of action.
60 * @param description the description string of the specified action.
62 STDMETHODIMP CAccHyperLink::get_description(long actionIndex,BSTR __RPC_FAR *description)
65 return CAccActionBase::get_description(actionIndex, description);
68 STDMETHODIMP CAccHyperLink::get_name( long actionIndex, BSTR __RPC_FAR *name)
71 return CAccActionBase::get_name(actionIndex, name);
74 STDMETHODIMP CAccHyperLink::get_localizedName( long actionIndex, BSTR __RPC_FAR *localizedName)
77 return CAccActionBase::get_name(actionIndex, localizedName);
80 /**
81 * Returns key binding object (if any) associated with specified action
82 * key binding is string.
83 * e.g. "alt+d" (like IAccessible::get_accKeyboardShortcut).
85 * @param actionIndex the index of action.
86 * @param nMaxBinding the max number of key binding.
87 * @param keyBinding the key binding array.
88 * @param nBinding the actual number of key binding returned.
90 STDMETHODIMP CAccHyperLink::get_keyBinding(
91 /* [in] */ long actionIndex,
92 /* [in] */ long nMaxBinding,
93 /* [length_is][length_is][size_is][size_is][out] */ BSTR __RPC_FAR *__RPC_FAR *keyBinding,
94 /* [retval][out] */ long __RPC_FAR *nBinding)
97 return CAccActionBase::get_keyBinding(actionIndex, nMaxBinding, keyBinding, nBinding);
101 * get an object
102 * @param
103 * @return Result.
105 STDMETHODIMP CAccHyperLink::get_anchor(/* [in] */ long index,
106 /* [retval][out] */ VARIANT __RPC_FAR *anchor)
108 SolarMutexGuard g;
110 ENTER_PROTECTED_BLOCK
112 // #CHECK#
113 if(anchor == NULL)
115 return E_INVALIDARG;
117 // #CHECK XInterface#
118 if(!pRXLink.is())
120 return E_FAIL;
122 // Get Any type value via pRXLink.
123 ::com::sun::star::uno::Any anyVal = GetXInterface()->getAccessibleActionAnchor(index);
124 // Convert Any to VARIANT.
125 CMAccessible::ConvertAnyToVariant(anyVal, anchor);
127 return S_OK;
129 LEAVE_PROTECTED_BLOCK
133 * get an object
134 * @param
135 * @return Result.
137 STDMETHODIMP CAccHyperLink::get_anchorTarget(/* [in] */ long index,
138 /* [retval][out] */ VARIANT __RPC_FAR *anchorTarget)
140 SolarMutexGuard g;
142 ENTER_PROTECTED_BLOCK
144 // #CHECK#
145 if(anchorTarget == NULL)
147 return E_INVALIDARG;
149 // #CHECK XInterface#
150 if(!pRXLink.is())
152 return E_FAIL;
154 // Get Any type value via pRXLink.
155 ::com::sun::star::uno::Any anyVal = GetXInterface()->getAccessibleActionObject(index);
156 // Convert Any to VARIANT.
157 CMAccessible::ConvertAnyToVariant(anyVal, anchorTarget);
159 return S_OK;
161 LEAVE_PROTECTED_BLOCK
166 * Get start index.
167 * @param index Variant to get start index.
168 * @return Result.
170 STDMETHODIMP CAccHyperLink::get_startIndex(/* [retval][out] */ long __RPC_FAR *index)
172 SolarMutexGuard g;
174 ENTER_PROTECTED_BLOCK
176 // #CHECK#
177 if(index == NULL)
179 return E_INVALIDARG;
181 *index = GetXInterface()->getStartIndex();
183 return S_OK;
185 LEAVE_PROTECTED_BLOCK
189 * Get start index.
190 * @param index Variant to get end index.
191 * @return Result.
193 STDMETHODIMP CAccHyperLink::get_endIndex(/* [retval][out] */ long __RPC_FAR *index)
195 SolarMutexGuard g;
197 ENTER_PROTECTED_BLOCK
199 // #CHECK#
200 if(index == NULL)
202 return E_INVALIDARG;
204 // #CHECK XInterface#
205 if(!pRXLink.is())
207 return E_FAIL;
209 *index = GetXInterface()->getEndIndex();
211 return S_OK;
213 LEAVE_PROTECTED_BLOCK
217 * Judge if the hyperlink is valid.
218 * @param valid Variant to get validity.
219 * @return Result.
221 STDMETHODIMP CAccHyperLink::get_valid(/* [retval][out] */ boolean __RPC_FAR *valid)
223 SolarMutexGuard g;
225 ENTER_PROTECTED_BLOCK
227 // #CHECK#
228 if(valid == NULL)
230 return E_INVALIDARG;
232 // #CHECK XInterface#
233 if(!pRXLink.is())
235 return E_FAIL;
237 *valid = GetXInterface()->isValid();
239 return S_OK;
241 LEAVE_PROTECTED_BLOCK
245 * Put UNO interface.
246 * @param pXInterface XAccessibleContext interface.
247 * @return Result.
249 STDMETHODIMP CAccHyperLink::put_XInterface(hyper pXInterface)
251 // internal IUNOXWrapper - no mutex meeded
253 ENTER_PROTECTED_BLOCK
255 CAccActionBase::put_XInterface(pXInterface);
256 //special query.
257 if(pUNOInterface != NULL)
259 Reference<XAccessibleContext> pRContext = pUNOInterface->getAccessibleContext();
260 if( !pRContext.is() )
262 return E_FAIL;
264 Reference<XAccessibleHyperlink> pRXI(pRContext,UNO_QUERY);
265 if( !pRXI.is() )
267 pRXLink = NULL;
269 else
270 pRXLink = pRXI.get();
272 return S_OK;
274 LEAVE_PROTECTED_BLOCK
278 * Put UNO interface.
279 * @param pXSubInterface XAccessibleHyperlink interface.
280 * @return Result.
282 STDMETHODIMP CAccHyperLink::put_XSubInterface(hyper pXSubInterface)
284 // internal IUNOXWrapper - no mutex meeded
286 pRXLink = reinterpret_cast<XAccessibleHyperlink*>(pXSubInterface);
287 pRXAct = reinterpret_cast<XAccessibleAction*>(pXSubInterface);
289 return S_OK;
292 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */