1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright IBM Corporation 2010. 6 * Copyright 2000, 2010 Oracle and/or its affiliates. 7 * 8 * OpenOffice.org - a multi-platform office productivity suite 9 * 10 * This file is part of OpenOffice.org. 11 * 12 * OpenOffice.org is free software: you can redistribute it and/or modify 13 * it under the terms of the GNU Lesser General Public License version 3 14 * only, as published by the Free Software Foundation. 15 * 16 * OpenOffice.org is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License version 3 for more details 20 * (a copy is included in the LICENSE file that accompanied this code). 21 * 22 * You should have received a copy of the GNU Lesser General Public License 23 * version 3 along with OpenOffice.org. If not, see 24 * <http://www.openoffice.org/license.html> 25 * for a copy of the LGPLv3 License. 26 * 27 ************************************************************************/ 28 29 #include "stdafx.h" 30 #include "UAccCOM2.h" 31 #include "AccHyperLink.h" 32 #include <com/sun/star/accessibility/XAccessible.hpp> 33 #include <com/sun/star/accessibility/XAccessibleAction.hpp> 34 #include "MAccessible.h" 35 36 using namespace com::sun::star::accessibility; 37 using namespace com::sun::star::uno; 38 using namespace com::sun::star::awt; 39 40 /** 41 * Returns the number of action. 42 * 43 * @param nActions the number of action. 44 */ 45 STDMETHODIMP CAccHyperLink::nActions(/*[out,retval]*/long* nActions) 46 { 47 48 return CAccActionBase::nActions(nActions); 49 } 50 51 /** 52 * Performs specified action on the object. 53 * 54 * @param actionIndex the index of action. 55 */ 56 STDMETHODIMP CAccHyperLink::doAction(/* [in] */ long actionIndex) 57 { 58 59 return CAccActionBase::doAction(actionIndex); 60 } 61 62 /** 63 * Gets description of specified action. 64 * 65 * @param actionIndex the index of action. 66 * @param description the description string of the specified action. 67 */ 68 STDMETHODIMP CAccHyperLink::get_description(long actionIndex,BSTR __RPC_FAR *description) 69 { 70 71 return CAccActionBase::get_description(actionIndex, description); 72 } 73 74 STDMETHODIMP CAccHyperLink::get_name( long actionIndex, BSTR __RPC_FAR *name) 75 { 76 77 return CAccActionBase::get_name(actionIndex, name); 78 } 79 80 STDMETHODIMP CAccHyperLink::get_localizedName( long actionIndex, BSTR __RPC_FAR *localizedName) 81 { 82 83 return CAccActionBase::get_name(actionIndex, localizedName); 84 } 85 86 /** 87 * Returns key binding object (if any) associated with specified action 88 * key binding is string. 89 * e.g. "alt+d" (like IAccessible::get_accKeyboardShortcut). 90 * 91 * @param actionIndex the index of action. 92 * @param nMaxBinding the max number of key binding. 93 * @param keyBinding the key binding array. 94 * @param nBinding the actual number of key binding returned. 95 */ 96 STDMETHODIMP CAccHyperLink::get_keyBinding( 97 /* [in] */ long actionIndex, 98 /* [in] */ long nMaxBinding, 99 /* [length_is][length_is][size_is][size_is][out] */ BSTR __RPC_FAR *__RPC_FAR *keyBinding, 100 /* [retval][out] */ long __RPC_FAR *nBinding) 101 { 102 103 return CAccActionBase::get_keyBinding(actionIndex, nMaxBinding, keyBinding, nBinding); 104 } 105 106 /** 107 * get an object 108 * @param 109 * @return Result. 110 */ 111 STDMETHODIMP CAccHyperLink::get_anchor(/* [in] */ long index, 112 /* [retval][out] */ VARIANT __RPC_FAR *anchor) 113 { 114 115 CHECK_ENABLE_INF 116 117 ENTER_PROTECTED_BLOCK 118 119 // #CHECK# 120 if(anchor == NULL) 121 { 122 return E_INVALIDARG; 123 } 124 // #CHECK XInterface# 125 if(!pRXLink.is()) 126 { 127 return E_FAIL; 128 } 129 // Get Any type value via pRXLink. 130 ::com::sun::star::uno::Any anyVal = GetXInterface()->getAccessibleActionAnchor(index); 131 // Convert Any to VARIANT. 132 CMAccessible::ConvertAnyToVariant(anyVal, anchor); 133 134 return S_OK; 135 136 LEAVE_PROTECTED_BLOCK 137 } 138 139 /** 140 * get an object 141 * @param 142 * @return Result. 143 */ 144 STDMETHODIMP CAccHyperLink::get_anchorTarget(/* [in] */ long index, 145 /* [retval][out] */ VARIANT __RPC_FAR *anchorTarget) 146 { 147 148 149 CHECK_ENABLE_INF 150 ENTER_PROTECTED_BLOCK 151 152 // #CHECK# 153 if(anchorTarget == NULL) 154 { 155 return E_INVALIDARG; 156 } 157 // #CHECK XInterface# 158 if(!pRXLink.is()) 159 { 160 return E_FAIL; 161 } 162 // Get Any type value via pRXLink. 163 ::com::sun::star::uno::Any anyVal = GetXInterface()->getAccessibleActionObject(index); 164 // Convert Any to VARIANT. 165 CMAccessible::ConvertAnyToVariant(anyVal, anchorTarget); 166 167 return S_OK; 168 169 LEAVE_PROTECTED_BLOCK 170 } 171 172 173 /** 174 * Get start index. 175 * @param index Variant to get start index. 176 * @return Result. 177 */ 178 STDMETHODIMP CAccHyperLink::get_startIndex(/* [retval][out] */ long __RPC_FAR *index) 179 { 180 181 CHECK_ENABLE_INF 182 183 ENTER_PROTECTED_BLOCK 184 185 // #CHECK# 186 if(index == NULL) 187 { 188 return E_INVALIDARG; 189 } 190 *index = GetXInterface()->getStartIndex(); 191 192 return S_OK; 193 194 LEAVE_PROTECTED_BLOCK 195 } 196 197 /** 198 * Get start index. 199 * @param index Variant to get end index. 200 * @return Result. 201 */ 202 STDMETHODIMP CAccHyperLink::get_endIndex(/* [retval][out] */ long __RPC_FAR *index) 203 { 204 205 CHECK_ENABLE_INF 206 207 ENTER_PROTECTED_BLOCK 208 209 // #CHECK# 210 if(index == NULL) 211 { 212 return E_INVALIDARG; 213 } 214 // #CHECK XInterface# 215 if(!pRXLink.is()) 216 { 217 return E_FAIL; 218 } 219 *index = GetXInterface()->getEndIndex(); 220 221 return S_OK; 222 223 LEAVE_PROTECTED_BLOCK 224 } 225 226 /** 227 * Judge if the hyperlink is valid. 228 * @param valid Variant to get validity. 229 * @return Result. 230 */ 231 STDMETHODIMP CAccHyperLink::get_valid(/* [retval][out] */ boolean __RPC_FAR *valid) 232 { 233 234 CHECK_ENABLE_INF 235 236 ENTER_PROTECTED_BLOCK 237 238 // #CHECK# 239 if(valid == NULL) 240 { 241 return E_INVALIDARG; 242 } 243 // #CHECK XInterface# 244 if(!pRXLink.is()) 245 { 246 return E_FAIL; 247 } 248 *valid = GetXInterface()->isValid(); 249 250 return S_OK; 251 252 LEAVE_PROTECTED_BLOCK 253 } 254 255 /** 256 * Put UNO interface. 257 * @param pXInterface XAccessibleContext interface. 258 * @return Result. 259 */ 260 STDMETHODIMP CAccHyperLink::put_XInterface(long pXInterface) 261 { 262 263 CHECK_ENABLE_INF 264 265 ENTER_PROTECTED_BLOCK 266 267 CAccActionBase::put_XInterface(pXInterface); 268 //special query. 269 if(pUNOInterface != NULL) 270 { 271 Reference<XAccessibleContext> pRContext = pUNOInterface->getAccessibleContext(); 272 if( !pRContext.is() ) 273 { 274 return E_FAIL; 275 } 276 Reference<XAccessibleHyperlink> pRXI(pRContext,UNO_QUERY); 277 if( !pRXI.is() ) 278 { 279 pRXLink = NULL; 280 } 281 else 282 pRXLink = pRXI.get(); 283 } 284 return S_OK; 285 286 LEAVE_PROTECTED_BLOCK 287 } 288 289 /** 290 * Put UNO interface. 291 * @param pXSubInterface XAccessibleHyperlink interface. 292 * @return Result. 293 */ 294 STDMETHODIMP CAccHyperLink::put_XSubInterface(long pXSubInterface) 295 { 296 297 CHECK_ENABLE_INF 298 299 pRXLink = (XAccessibleHyperlink*)pXSubInterface; 300 pRXAct = (XAccessibleAction*)pXSubInterface; 301 302 return S_OK; 303 } 304