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 "AccHypertext.h" 32 33 using namespace com::sun::star::accessibility; 34 using namespace com::sun::star::uno; 35 36 ///////////////////////////////////////////////////////////////////////////// 37 // 38 /** 39 * Get special selection. 40 * @param startOffset Start selection offset. 41 * @param endOffset End selection offset. 42 * @param success Variant to accept the result of if the method call is successful. 43 * @return Result. 44 */ 45 STDMETHODIMP CAccHypertext::addSelection(long startOffset, long endOffset) 46 { 47 48 return CAccTextBase::get_addSelection(startOffset, endOffset); 49 } 50 51 52 /** 53 * Get special attributes. 54 * @param offset Offset. 55 * @param startOffset Variant to accept start offset. 56 * @param endOffset Variant to accept end offset. 57 * @param textAttributes Variant to accept attributes. 58 * @return Result. 59 */ 60 STDMETHODIMP CAccHypertext::get_attributes(long offset, long * startOffset, long * endOffset, BSTR * textAttributes) 61 { 62 63 return CAccTextBase::get_attributes(offset, startOffset, endOffset, textAttributes); 64 } 65 66 /** 67 * Get caret position. 68 * @param offset Variant to accept caret offset. 69 * @return Result. 70 */ 71 STDMETHODIMP CAccHypertext::get_caretOffset(long * offset) 72 { 73 74 return CAccTextBase::get_caretOffset(offset); 75 } 76 77 /** 78 * Get character count. 79 * @param nCharacters Variant to accept character count. 80 * @return Result. 81 */ 82 STDMETHODIMP CAccHypertext::get_characterCount(long * nCharacters) 83 { 84 85 return CAccTextBase::get_characterCount(nCharacters); 86 } 87 88 /** 89 * Get character extents. 90 * @param offset Offset. 91 * @param x Variant to accpet x position. 92 * @param y Variant to accpet y position. 93 * @param width Variant to accpet width. 94 * @param Height Variant to accpet height. 95 * @return Result. 96 */ 97 STDMETHODIMP CAccHypertext::get_characterExtents(long offset, IA2CoordinateType coordType, long * x, long * y, long * width, long * height) 98 { 99 100 return CAccTextBase::get_characterExtents(offset, coordType, x, y, width, height); 101 } 102 103 /** 104 * Get slections count. 105 * @param nSelections Variant to accpet slections count. 106 * @return Result. 107 */ 108 STDMETHODIMP CAccHypertext::get_nSelections(long * nSelections) 109 { 110 111 return CAccTextBase::get_nSelections(nSelections); 112 } 113 114 /** 115 * Get offset of some special point. 116 * @param x X position of one point. 117 * @param x Y position of one point. 118 * @param coordType Type. 119 * @param offset Variant to accept offset. 120 * @return Result. 121 */ 122 STDMETHODIMP CAccHypertext::get_offsetAtPoint(long x, long y, IA2CoordinateType coordType, long * offset) 123 { 124 return CAccTextBase::get_offsetAtPoint(x, y, coordType, offset); 125 } 126 127 /** 128 * Get selection range. 129 * @param selection selection count. 130 * @param startOffset Variant to accept the start offset of special selection. 131 * @param endOffset Variant to accept the end offset of special selection. 132 * @return Result. 133 */ 134 STDMETHODIMP CAccHypertext::get_selection(long selection, long * startOffset, long * endOffset) 135 { 136 137 return CAccTextBase::get_selection(selection, startOffset, endOffset); 138 } 139 140 /** 141 * Get special text. 142 * @param startOffset Start position of special range. 143 * @param endOffset End position of special range. 144 * @param text Variant to accept the text of special range. 145 * @return Result. 146 */ 147 STDMETHODIMP CAccHypertext::get_text(long startOffset, long endOffset, BSTR * text) 148 { 149 150 return CAccTextBase::get_text(startOffset, endOffset, text); 151 } 152 153 /** 154 * Get special text before some position. 155 * @param offset Special position. 156 * @param boundaryType Boundary type. 157 * @param startOffset Variant to accept the start offset. 158 * @param endOffset Variant to accept the end offset. 159 * @param text Variant to accept the special text. 160 * @return Result. 161 */ 162 STDMETHODIMP CAccHypertext::get_textBeforeOffset(long offset, IA2TextBoundaryType boundaryType, long * startOffset, long * endOffset, BSTR * text) 163 { 164 165 return CAccTextBase::get_textBeforeOffset(offset, boundaryType, 166 startOffset, endOffset, text); 167 } 168 169 /** 170 * Get special text after some position. 171 * @param offset Special position. 172 * @param boundaryType Boundary type. 173 * @param startOffset Variant to accept the start offset. 174 * @param endOffset Variant to accept the end offset. 175 * @param text Variant to accept the special text. 176 * @return Result. 177 */ 178 STDMETHODIMP CAccHypertext::get_textAfterOffset(long offset, IA2TextBoundaryType boundaryType, long * startOffset, long * endOffset, BSTR * text) 179 { 180 181 return CAccTextBase::get_textAfterOffset(offset, boundaryType, 182 startOffset, endOffset, text); 183 } 184 185 /** 186 * Get special text at some position. 187 * @param offset Special position. 188 * @param boundaryType Boundary type. 189 * @param startOffset Variant to accept the start offset. 190 * @param endOffset Variant to accept the end offset. 191 * @param text Variant to accept the special text. 192 * @return Result. 193 */ 194 STDMETHODIMP CAccHypertext::get_textAtOffset(long offset, IA2TextBoundaryType boundaryType, long * startOffset, long * endOffset, BSTR * text) 195 { 196 197 return CAccTextBase::get_textAtOffset(offset, boundaryType, 198 startOffset, endOffset, text); 199 } 200 201 /** 202 * Remove selection. 203 * @param selectionIndex Special selection index 204 * @param success Variant to accept the memthod called result. 205 * @return Result. 206 */ 207 STDMETHODIMP CAccHypertext::removeSelection(long selectionIndex) 208 { 209 210 return CAccTextBase::removeSelection(selectionIndex); 211 } 212 213 /** 214 * Set caret position. 215 * @param offset Special position. 216 * @param success Variant to accept the memthod called result. 217 * @return Result. 218 */ 219 STDMETHODIMP CAccHypertext::setCaretOffset(long offset) 220 { 221 222 return CAccTextBase::setCaretOffset(offset); 223 } 224 225 /** 226 * Set special selection. 227 * @param selectionIndex Special selection index. 228 * @param startOffset start position. 229 * @param endOffset end position. 230 * @param success Variant to accept the memthod called result. 231 * @return Result. 232 */ 233 STDMETHODIMP CAccHypertext::setSelection(long selectionIndex, long startOffset, long endOffset) 234 { 235 236 return CAccTextBase::setSelection(selectionIndex, startOffset, 237 endOffset); 238 } 239 240 /** 241 * Get characters count. 242 * @param nCharacters Variant to accept the characters count. 243 * @return Result. 244 */ 245 STDMETHODIMP CAccHypertext::get_nCharacters(long * nCharacters) 246 { 247 248 return CAccTextBase::get_nCharacters(nCharacters); 249 } 250 251 STDMETHODIMP CAccHypertext::get_newText( IA2TextSegment *newText) 252 { 253 return CAccTextBase::get_newText(newText); 254 } 255 256 STDMETHODIMP CAccHypertext::get_oldText( IA2TextSegment *oldText) 257 { 258 return CAccTextBase::get_oldText(oldText); 259 } 260 261 /** 262 * Scroll to special sub-string . 263 * @param startIndex Start index of sub string. 264 * @param endIndex End index of sub string. 265 * @return Result. 266 */ 267 STDMETHODIMP CAccHypertext::scrollSubstringToPoint(long startIndex, long endIndex,enum IA2CoordinateType coordinateType, long x, long y ) 268 { 269 270 return CAccTextBase::scrollSubstringToPoint(startIndex, endIndex, coordinateType, x, y); 271 } 272 STDMETHODIMP CAccHypertext::scrollSubstringTo(long startIndex, long endIndex,enum IA2ScrollType scrollType) 273 { 274 275 return CAccTextBase::scrollSubstringTo(startIndex, endIndex,scrollType); 276 } 277 278 /** 279 * Get hyperlink count. 280 * @param hyperlinkCount Variant to accpet hyperlink count. 281 * @return Result. 282 */ 283 STDMETHODIMP CAccHypertext::get_nHyperlinks(long *hyperlinkCount) 284 { 285 286 CHECK_ENABLE_INF 287 288 ENTER_PROTECTED_BLOCK 289 290 // #CHECK# 291 if(hyperlinkCount == NULL) 292 return E_INVALIDARG; 293 // #CHECK XInterface# 294 if(!pHyperText.is()) 295 { 296 return E_FAIL; 297 } 298 299 *hyperlinkCount = pHyperText->getHyperLinkCount(); 300 return S_OK; 301 302 LEAVE_PROTECTED_BLOCK 303 } 304 305 /** 306 * Get special hyperlink. 307 * @param index Special hyperlink index. 308 * @param hyperlink Variant to accept special hyperlink via index. 309 * @return Result. 310 */ 311 STDMETHODIMP CAccHypertext::get_hyperlink(long index,IAccessibleHyperlink **hyperlink) 312 { 313 314 CHECK_ENABLE_INF 315 316 ENTER_PROTECTED_BLOCK 317 318 // #CHECK# 319 if(hyperlink == NULL) 320 return E_INVALIDARG; 321 // #CHECK XInterface# 322 if(!pHyperText.is()) 323 { 324 return E_FAIL; 325 } 326 327 Reference<XAccessibleHyperlink> pRLink = pHyperText->getHyperLink(index); 328 if(!pRLink.is()) 329 { 330 *hyperlink = NULL; 331 return E_FAIL; 332 } 333 334 IAccessibleHyperlink* plink = NULL; 335 HRESULT hr = CoCreateInstance( CLSID_AccHyperLink, NULL, CLSCTX_SERVER , 336 IID_IAccessibleHyperlink, 337 (void **)&plink); 338 if( SUCCEEDED(hr) ) 339 { 340 IUNOXWrapper* wrapper = NULL; 341 plink->QueryInterface(IID_IUNOXWrapper, (void**)&wrapper); 342 if(wrapper) 343 { 344 wrapper->put_XSubInterface((long)pRLink.get()/*pXI*/); 345 wrapper->Release(); 346 } 347 *hyperlink = plink; 348 return S_OK; 349 } 350 351 return E_FAIL; 352 353 LEAVE_PROTECTED_BLOCK 354 } 355 356 /** 357 * Returns the index of the hyperlink that is associated with this character index. 358 * @param charIndex Special char index. 359 * @param hyperlinkIndex Variant to accept special hyperlink index. 360 * @return Result. 361 */ 362 STDMETHODIMP CAccHypertext::get_hyperlinkIndex(long charIndex, long *hyperlinkIndex) 363 { 364 365 CHECK_ENABLE_INF 366 367 ENTER_PROTECTED_BLOCK 368 369 // #CHECK# 370 if(hyperlinkIndex == NULL) 371 return E_INVALIDARG; 372 // #CHECK XInterface# 373 if(!pHyperText.is()) 374 { 375 return E_FAIL; 376 } 377 378 *hyperlinkIndex = pHyperText->getHyperLinkIndex(charIndex); 379 return S_OK; 380 381 LEAVE_PROTECTED_BLOCK 382 } 383 384 /** 385 * Put UNO interface. 386 * @param pXInterface UNO interface. 387 * @return Result. 388 */ 389 STDMETHODIMP CAccHypertext::put_XInterface(long pXInterface) 390 { 391 392 393 ENTER_PROTECTED_BLOCK 394 395 CAccTextBase::put_XInterface(pXInterface); 396 //special query. 397 if(pUNOInterface == NULL) 398 return E_FAIL; 399 Reference<XAccessibleContext> pRContext = pUNOInterface->getAccessibleContext(); 400 if( !pRContext.is() ) 401 { 402 return E_FAIL; 403 } 404 Reference<XAccessibleHypertext> pRXI(pRContext,UNO_QUERY); 405 if( !pRXI.is() ) 406 pHyperText = NULL; 407 else 408 pHyperText = pRXI.get(); 409 return S_OK; 410 411 LEAVE_PROTECTED_BLOCK 412 } 413