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