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 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_editeng.hxx" 26 27 //------------------------------------------------------------------------ 28 // 29 // Global header 30 // 31 //------------------------------------------------------------------------ 32 33 #include <limits.h> 34 #include <vector> 35 #include <algorithm> 36 #include <vos/mutex.hxx> 37 #include <vcl/window.hxx> 38 #include <vcl/svapp.hxx> 39 #include <editeng/flditem.hxx> 40 #include <com/sun/star/uno/Any.hxx> 41 #include <com/sun/star/uno/Reference.hxx> 42 #include <com/sun/star/awt/Point.hpp> 43 #include <com/sun/star/awt/Rectangle.hpp> 44 #include <com/sun/star/lang/DisposedException.hpp> 45 #include <com/sun/star/accessibility/AccessibleRole.hpp> 46 #include <com/sun/star/accessibility/AccessibleTextType.hpp> 47 #include <com/sun/star/accessibility/AccessibleStateType.hpp> 48 #include <com/sun/star/accessibility/AccessibleEventId.hpp> 49 #include <comphelper/accessibleeventnotifier.hxx> 50 #include <comphelper/sequenceashashmap.hxx> 51 #include <unotools/accessiblestatesethelper.hxx> 52 #include <unotools/accessiblerelationsethelper.hxx> 53 #include <com/sun/star/accessibility/AccessibleRelationType.hpp> 54 #include <vcl/unohelp.hxx> 55 #include <editeng/editeng.hxx> 56 #include <editeng/unoprnms.hxx> 57 #include <editeng/unoipset.hxx> 58 #include <editeng/outliner.hxx> 59 #include <svl/intitem.hxx> 60 61 //------------------------------------------------------------------------ 62 // 63 // Project-local header 64 // 65 //------------------------------------------------------------------------ 66 67 #include <com/sun/star/beans/PropertyState.hpp> 68 69 //!!!#include <svx/unoshape.hxx> 70 //!!!#include <svx/dialmgr.hxx> 71 //!!!#include "accessibility.hrc" 72 73 #include <editeng/unolingu.hxx> 74 #include <editeng/unopracc.hxx> 75 #include "editeng/AccessibleEditableTextPara.hxx" 76 #include "AccessibleHyperlink.hxx" 77 78 #include <svtools/colorcfg.hxx> 79 //IAccessibility2 Implementation 2009----- 80 #include <algorithm> 81 using namespace std; 82 #include "editeng.hrc" 83 #include <editeng/eerdll.hxx> 84 #include <editeng/numitem.hxx> 85 #include <sfx2/viewfrm.hxx> 86 #include <sfx2/viewsh.hxx> 87 //-----IAccessibility2 Implementation 2009 88 89 using namespace ::com::sun::star; 90 using namespace ::com::sun::star::beans; 91 using namespace ::com::sun::star::accessibility; 92 93 94 //------------------------------------------------------------------------ 95 // 96 // AccessibleEditableTextPara implementation 97 // 98 //------------------------------------------------------------------------ 99 100 namespace accessibility 101 { 102 //IAccessibility2 Implementation 2009----- 103 104 const SvxItemPropertySet* ImplGetSvxCharAndParaPropertiesSet() 105 { 106 // PropertyMap for character and paragraph properties 107 static const SfxItemPropertyMapEntry aPropMap[] = 108 { 109 SVX_UNOEDIT_OUTLINER_PROPERTIES, 110 SVX_UNOEDIT_CHAR_PROPERTIES, 111 SVX_UNOEDIT_PARA_PROPERTIES, 112 SVX_UNOEDIT_NUMBERING_PROPERTIE, 113 {MAP_CHAR_LEN("TextUserDefinedAttributes"), EE_CHAR_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, 114 {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, 115 {0,0,0,0,0,0} 116 }; 117 static SvxItemPropertySet aPropSet( aPropMap, EditEngine::GetGlobalItemPool() ); 118 return &aPropSet; 119 } 120 121 122 DBG_NAME( AccessibleEditableTextPara ) 123 124 // --> OD 2006-01-11 #i27138# - add parameter <_pParaManager> 125 AccessibleEditableTextPara::AccessibleEditableTextPara( 126 const uno::Reference< XAccessible >& rParent, 127 const AccessibleParaManager* _pParaManager ) 128 : AccessibleTextParaInterfaceBase( m_aMutex ), 129 mnParagraphIndex( 0 ), 130 mnIndexInParent( 0 ), 131 mpEditSource( NULL ), 132 maEEOffset( 0, 0 ), 133 mxParent( rParent ), 134 // well, that's strictly (UNO) exception safe, though not 135 // really robust. We rely on the fact that this member is 136 // constructed last, and that the constructor body catches 137 // exceptions, thus no chance for exceptions once the Id is 138 // fetched. Nevertheless, normally should employ RAII here... 139 mnNotifierClientId(::comphelper::AccessibleEventNotifier::registerClient()), 140 // --> OD 2006-01-11 #i27138# 141 mpParaManager( _pParaManager ) 142 // <-- 143 { 144 #ifdef DBG_UTIL 145 DBG_CTOR( AccessibleEditableTextPara, NULL ); 146 OSL_TRACE( "AccessibleEditableTextPara received ID: %d\n", mnNotifierClientId ); 147 #endif 148 149 try 150 { 151 // Create the state set. 152 ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper (); 153 mxStateSet = pStateSet; 154 155 // these are always on 156 pStateSet->AddState( AccessibleStateType::MULTI_LINE ); 157 pStateSet->AddState( AccessibleStateType::FOCUSABLE ); 158 pStateSet->AddState( AccessibleStateType::VISIBLE ); 159 pStateSet->AddState( AccessibleStateType::SHOWING ); 160 pStateSet->AddState( AccessibleStateType::ENABLED ); 161 pStateSet->AddState( AccessibleStateType::SENSITIVE ); 162 } 163 catch( const uno::Exception& ) {} 164 } 165 166 AccessibleEditableTextPara::~AccessibleEditableTextPara() 167 { 168 DBG_DTOR( AccessibleEditableTextPara, NULL ); 169 170 // sign off from event notifier 171 if( getNotifierClientId() != -1 ) 172 { 173 try 174 { 175 ::comphelper::AccessibleEventNotifier::revokeClient( getNotifierClientId() ); 176 #ifdef DBG_UTIL 177 OSL_TRACE( "AccessibleEditableTextPara revoked ID: %d\n", mnNotifierClientId ); 178 #endif 179 } 180 catch( const uno::Exception& ) {} 181 } 182 } 183 184 ::rtl::OUString AccessibleEditableTextPara::implGetText() 185 { 186 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 187 188 return GetTextRange( 0, GetTextLen() ); 189 } 190 191 ::com::sun::star::lang::Locale AccessibleEditableTextPara::implGetLocale() 192 { 193 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 194 195 lang::Locale aLocale; 196 197 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 198 "AccessibleEditableTextPara::getLocale: paragraph index value overflow"); 199 200 // return locale of first character in the paragraph 201 return SvxLanguageToLocale(aLocale, GetTextForwarder().GetLanguage( static_cast< sal_uInt16 >( GetParagraphIndex() ), 0 )); 202 } 203 204 void AccessibleEditableTextPara::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ) 205 { 206 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 207 208 sal_uInt16 nStart, nEnd; 209 210 if( GetSelection( nStart, nEnd ) ) 211 { 212 nStartIndex = nStart; 213 nEndIndex = nEnd; 214 } 215 else 216 { 217 // #102234# No exception, just set to 'invalid' 218 nStartIndex = -1; 219 nEndIndex = -1; 220 } 221 } 222 223 void AccessibleEditableTextPara::implGetParagraphBoundary( ::com::sun::star::i18n::Boundary& rBoundary, sal_Int32 /*nIndex*/ ) 224 { 225 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 226 DBG_WARNING( "AccessibleEditableTextPara::implGetParagraphBoundary: only a base implementation, ignoring the index" ); 227 228 rBoundary.startPos = 0; 229 //IAccessibility2 Implementation 2009----- 230 //rBoundary.endPos = GetTextLen(); 231 ::rtl::OUString sText( implGetText() ); 232 sal_Int32 nLength = sText.getLength(); 233 rBoundary.endPos = nLength; 234 //-----IAccessibility2 Implementation 2009 235 } 236 237 void AccessibleEditableTextPara::implGetLineBoundary( ::com::sun::star::i18n::Boundary& rBoundary, sal_Int32 nIndex ) 238 { 239 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 240 241 SvxTextForwarder& rCacheTF = GetTextForwarder(); 242 const sal_Int32 nParaIndex = GetParagraphIndex(); 243 244 DBG_ASSERT(nParaIndex >= 0 && nParaIndex <= USHRT_MAX, 245 "AccessibleEditableTextPara::implGetLineBoundary: paragraph index value overflow"); 246 247 const sal_Int32 nTextLen = rCacheTF.GetTextLen( static_cast< sal_uInt16 >( nParaIndex ) ); 248 249 CheckPosition(nIndex); 250 251 rBoundary.startPos = rBoundary.endPos = -1; 252 253 const sal_uInt16 nLineCount=rCacheTF.GetLineCount( static_cast< sal_uInt16 >( nParaIndex ) ); 254 255 if( nIndex == nTextLen ) 256 { 257 // #i17014# Special-casing one-behind-the-end character 258 if( nLineCount <= 1 ) 259 rBoundary.startPos = 0; 260 else 261 rBoundary.startPos = nTextLen - rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ), 262 nLineCount-1 ); 263 264 rBoundary.endPos = nTextLen; 265 } 266 else 267 { 268 // normal line search 269 sal_uInt16 nLine; 270 sal_Int32 nCurIndex; 271 for( nLine=0, nCurIndex=0; nLine<nLineCount; ++nLine ) 272 { 273 nCurIndex += rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ), nLine); 274 275 if( nCurIndex > nIndex ) 276 { 277 rBoundary.startPos = nCurIndex - rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine); 278 rBoundary.endPos = nCurIndex; 279 break; 280 } 281 } 282 } 283 } 284 285 int AccessibleEditableTextPara::getNotifierClientId() const 286 { 287 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 288 289 return mnNotifierClientId; 290 } 291 292 void AccessibleEditableTextPara::SetIndexInParent( sal_Int32 nIndex ) 293 { 294 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 295 296 mnIndexInParent = nIndex; 297 } 298 299 sal_Int32 AccessibleEditableTextPara::GetIndexInParent() const 300 { 301 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 302 303 return mnIndexInParent; 304 } 305 306 void AccessibleEditableTextPara::SetParagraphIndex( sal_Int32 nIndex ) 307 { 308 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 309 310 sal_Int32 nOldIndex = mnParagraphIndex; 311 312 mnParagraphIndex = nIndex; 313 314 WeakBullet::HardRefType aChild( maImageBullet.get() ); 315 if( aChild.is() ) 316 aChild->SetParagraphIndex(mnParagraphIndex); 317 318 try 319 { 320 if( nOldIndex != nIndex ) 321 { 322 uno::Any aOldDesc; 323 uno::Any aOldName; 324 325 try 326 { 327 aOldDesc <<= getAccessibleDescription(); 328 aOldName <<= getAccessibleName(); 329 } 330 catch( const uno::Exception& ) {} // optional behaviour 331 // index and therefore description changed 332 FireEvent( AccessibleEventId::DESCRIPTION_CHANGED, uno::makeAny( getAccessibleDescription() ), aOldDesc ); 333 FireEvent( AccessibleEventId::NAME_CHANGED, uno::makeAny( getAccessibleName() ), aOldName ); 334 } 335 } 336 catch( const uno::Exception& ) {} // optional behaviour 337 } 338 339 sal_Int32 AccessibleEditableTextPara::GetParagraphIndex() const SAL_THROW((uno::RuntimeException)) 340 { 341 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 342 343 return mnParagraphIndex; 344 } 345 346 void AccessibleEditableTextPara::Dispose() 347 { 348 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 349 350 int nClientId( getNotifierClientId() ); 351 352 // #108212# drop all references before notifying dispose 353 mxParent = NULL; 354 mnNotifierClientId = -1; 355 mpEditSource = NULL; 356 357 // notify listeners 358 if( nClientId != -1 ) 359 { 360 try 361 { 362 uno::Reference < XAccessibleContext > xThis = getAccessibleContext(); 363 364 // #106234# Delegate to EventNotifier 365 ::comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nClientId, xThis ); 366 #ifdef DBG_UTIL 367 OSL_TRACE( "Disposed ID: %d\n", nClientId ); 368 #endif 369 } 370 catch( const uno::Exception& ) {} 371 } 372 } 373 374 void AccessibleEditableTextPara::SetEditSource( SvxEditSourceAdapter* pEditSource ) 375 { 376 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 377 378 WeakBullet::HardRefType aChild( maImageBullet.get() ); 379 if( aChild.is() ) 380 aChild->SetEditSource(pEditSource); 381 382 if( !pEditSource ) 383 { 384 // going defunc 385 UnSetState( AccessibleStateType::SHOWING ); 386 UnSetState( AccessibleStateType::VISIBLE ); 387 SetState( AccessibleStateType::INVALID ); 388 SetState( AccessibleStateType::DEFUNC ); 389 390 Dispose(); 391 } 392 //IAccessibility2 Implementation 2009----- 393 mpEditSource = pEditSource; 394 //-----IAccessibility2 Implementation 2009 395 // #108900# Init last text content 396 try 397 { 398 TextChanged(); 399 } 400 catch( const uno::RuntimeException& ) {} 401 } 402 403 ESelection AccessibleEditableTextPara::MakeSelection( sal_Int32 nStartEEIndex, sal_Int32 nEndEEIndex ) 404 { 405 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 406 407 // check overflow 408 DBG_ASSERT(nStartEEIndex >= 0 && nStartEEIndex <= USHRT_MAX && 409 nEndEEIndex >= 0 && nEndEEIndex <= USHRT_MAX && 410 GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 411 "AccessibleEditableTextPara::MakeSelection: index value overflow"); 412 413 sal_uInt16 nParaIndex = static_cast< sal_uInt16 >( GetParagraphIndex() ); 414 return ESelection( nParaIndex, static_cast< sal_uInt16 >( nStartEEIndex ), 415 nParaIndex, static_cast< sal_uInt16 >( nEndEEIndex ) ); 416 } 417 418 ESelection AccessibleEditableTextPara::MakeSelection( sal_Int32 nEEIndex ) 419 { 420 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 421 422 return MakeSelection( nEEIndex, nEEIndex+1 ); 423 } 424 425 ESelection AccessibleEditableTextPara::MakeCursor( sal_Int32 nEEIndex ) 426 { 427 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 428 429 return MakeSelection( nEEIndex, nEEIndex ); 430 } 431 432 void AccessibleEditableTextPara::CheckIndex( sal_Int32 nIndex ) SAL_THROW((lang::IndexOutOfBoundsException, uno::RuntimeException)) 433 { 434 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 435 436 if( nIndex < 0 || nIndex >= getCharacterCount() ) 437 throw lang::IndexOutOfBoundsException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleEditableTextPara: character index out of bounds")), 438 uno::Reference< uno::XInterface > 439 ( static_cast< ::cppu::OWeakObject* > (this) ) ); // disambiguate hierarchy 440 } 441 442 void AccessibleEditableTextPara::CheckPosition( sal_Int32 nIndex ) SAL_THROW((lang::IndexOutOfBoundsException, uno::RuntimeException)) 443 { 444 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 445 446 if( nIndex < 0 || nIndex > getCharacterCount() ) 447 throw lang::IndexOutOfBoundsException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleEditableTextPara: character position out of bounds")), 448 uno::Reference< uno::XInterface > 449 ( static_cast< ::cppu::OWeakObject* > (this) ) ); // disambiguate hierarchy 450 } 451 452 void AccessibleEditableTextPara::CheckRange( sal_Int32 nStart, sal_Int32 nEnd ) SAL_THROW((lang::IndexOutOfBoundsException, uno::RuntimeException)) 453 { 454 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 455 456 CheckPosition( nStart ); 457 CheckPosition( nEnd ); 458 } 459 460 sal_Bool AccessibleEditableTextPara::GetSelection( sal_uInt16& nStartPos, sal_uInt16& nEndPos ) SAL_THROW((uno::RuntimeException)) 461 { 462 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 463 464 ESelection aSelection; 465 sal_uInt16 nPara = static_cast< sal_uInt16 > ( GetParagraphIndex() ); 466 if( !GetEditViewForwarder().GetSelection( aSelection ) ) 467 return sal_False; 468 469 if( aSelection.nStartPara < aSelection.nEndPara ) 470 { 471 if( aSelection.nStartPara > nPara || 472 aSelection.nEndPara < nPara ) 473 return sal_False; 474 475 if( nPara == aSelection.nStartPara ) 476 nStartPos = aSelection.nStartPos; 477 else 478 nStartPos = 0; 479 480 if( nPara == aSelection.nEndPara ) 481 nEndPos = aSelection.nEndPos; 482 else 483 nEndPos = GetTextLen(); 484 } 485 else 486 { 487 if( aSelection.nStartPara < nPara || 488 aSelection.nEndPara > nPara ) 489 return sal_False; 490 491 if( nPara == aSelection.nStartPara ) 492 nStartPos = aSelection.nStartPos; 493 else 494 nStartPos = GetTextLen(); 495 496 if( nPara == aSelection.nEndPara ) 497 nEndPos = aSelection.nEndPos; 498 else 499 nEndPos = 0; 500 } 501 502 return sal_True; 503 } 504 505 String AccessibleEditableTextPara::GetText( sal_Int32 nIndex ) SAL_THROW((uno::RuntimeException)) 506 { 507 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 508 509 return GetTextForwarder().GetText( MakeSelection(nIndex) ); 510 } 511 512 String AccessibleEditableTextPara::GetTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) SAL_THROW((uno::RuntimeException)) 513 { 514 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 515 516 return GetTextForwarder().GetText( MakeSelection(nStartIndex, nEndIndex) ); 517 } 518 519 sal_uInt16 AccessibleEditableTextPara::GetTextLen() const SAL_THROW((uno::RuntimeException)) 520 { 521 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 522 523 return GetTextForwarder().GetTextLen( static_cast< sal_uInt16 >( GetParagraphIndex() ) ); 524 } 525 526 sal_Bool AccessibleEditableTextPara::IsVisible() const 527 { 528 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 529 530 return mpEditSource ? sal_True : sal_False ; 531 } 532 533 uno::Reference< XAccessibleText > AccessibleEditableTextPara::GetParaInterface( sal_Int32 nIndex ) 534 { 535 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 536 537 uno::Reference< XAccessible > xParent = getAccessibleParent(); 538 if( xParent.is() ) 539 { 540 uno::Reference< XAccessibleContext > xParentContext = xParent->getAccessibleContext(); 541 if( xParentContext.is() ) 542 { 543 uno::Reference< XAccessible > xPara = xParentContext->getAccessibleChild( nIndex ); 544 if( xPara.is() ) 545 { 546 return uno::Reference< XAccessibleText > ( xPara, uno::UNO_QUERY ); 547 } 548 } 549 } 550 551 return uno::Reference< XAccessibleText >(); 552 } 553 554 SvxEditSourceAdapter& AccessibleEditableTextPara::GetEditSource() const SAL_THROW((uno::RuntimeException)) 555 { 556 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 557 558 if( mpEditSource ) 559 return *mpEditSource; 560 else 561 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No edit source, object is defunct")), 562 uno::Reference< uno::XInterface > 563 ( static_cast< ::cppu::OWeakObject* > 564 ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy 565 } 566 567 SvxAccessibleTextAdapter& AccessibleEditableTextPara::GetTextForwarder() const SAL_THROW((uno::RuntimeException)) 568 { 569 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 570 571 SvxEditSourceAdapter& rEditSource = GetEditSource(); 572 SvxAccessibleTextAdapter* pTextForwarder = rEditSource.GetTextForwarderAdapter(); 573 574 if( !pTextForwarder ) 575 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unable to fetch text forwarder, object is defunct")), 576 uno::Reference< uno::XInterface > 577 ( static_cast< ::cppu::OWeakObject* > 578 ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy 579 580 if( pTextForwarder->IsValid() ) 581 return *pTextForwarder; 582 else 583 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Text forwarder is invalid, object is defunct")), 584 uno::Reference< uno::XInterface > 585 ( static_cast< ::cppu::OWeakObject* > 586 ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy 587 } 588 589 SvxViewForwarder& AccessibleEditableTextPara::GetViewForwarder() const SAL_THROW((uno::RuntimeException)) 590 { 591 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 592 593 SvxEditSource& rEditSource = GetEditSource(); 594 SvxViewForwarder* pViewForwarder = rEditSource.GetViewForwarder(); 595 596 if( !pViewForwarder ) 597 { 598 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unable to fetch view forwarder, object is defunct")), 599 uno::Reference< uno::XInterface > 600 ( static_cast< ::cppu::OWeakObject* > 601 ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy 602 } 603 604 if( pViewForwarder->IsValid() ) 605 return *pViewForwarder; 606 else 607 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("View forwarder is invalid, object is defunct")), 608 uno::Reference< uno::XInterface > 609 ( static_cast< ::cppu::OWeakObject* > 610 ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy 611 } 612 613 SvxAccessibleTextEditViewAdapter& AccessibleEditableTextPara::GetEditViewForwarder( sal_Bool bCreate ) const SAL_THROW((uno::RuntimeException)) 614 { 615 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 616 617 SvxEditSourceAdapter& rEditSource = GetEditSource(); 618 SvxAccessibleTextEditViewAdapter* pTextEditViewForwarder = rEditSource.GetEditViewForwarderAdapter( bCreate ); 619 620 if( !pTextEditViewForwarder ) 621 { 622 if( bCreate ) 623 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unable to fetch view forwarder, object is defunct")), 624 uno::Reference< uno::XInterface > 625 ( static_cast< ::cppu::OWeakObject* > 626 ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy 627 else 628 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No view forwarder, object not in edit mode")), 629 uno::Reference< uno::XInterface > 630 ( static_cast< ::cppu::OWeakObject* > 631 ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy 632 } 633 634 if( pTextEditViewForwarder->IsValid() ) 635 return *pTextEditViewForwarder; 636 else 637 { 638 if( bCreate ) 639 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("View forwarder is invalid, object is defunct")), 640 uno::Reference< uno::XInterface > 641 ( static_cast< ::cppu::OWeakObject* > 642 ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy 643 else 644 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("View forwarder is invalid, object not in edit mode")), 645 uno::Reference< uno::XInterface > 646 ( static_cast< ::cppu::OWeakObject* > 647 ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy 648 } 649 } 650 651 sal_Bool AccessibleEditableTextPara::HaveEditView() const 652 { 653 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 654 655 SvxEditSource& rEditSource = GetEditSource(); 656 SvxEditViewForwarder* pViewForwarder = rEditSource.GetEditViewForwarder(); 657 658 if( !pViewForwarder ) 659 return sal_False; 660 661 if( !pViewForwarder->IsValid() ) 662 return sal_False; 663 664 return sal_True; 665 } 666 667 sal_Bool AccessibleEditableTextPara::HaveChildren() 668 { 669 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 670 671 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 672 "AccessibleEditableTextPara::HaveChildren: paragraph index value overflow"); 673 674 return GetTextForwarder().HaveImageBullet( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 675 } 676 677 sal_Bool AccessibleEditableTextPara::IsActive() const SAL_THROW((uno::RuntimeException)) 678 { 679 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 680 681 SvxEditSource& rEditSource = GetEditSource(); 682 SvxEditViewForwarder* pViewForwarder = rEditSource.GetEditViewForwarder(); 683 684 if( !pViewForwarder ) 685 return sal_False; 686 687 if( pViewForwarder->IsValid() ) 688 return sal_False; 689 else 690 return sal_True; 691 } 692 693 Rectangle AccessibleEditableTextPara::LogicToPixel( const Rectangle& rRect, const MapMode& rMapMode, SvxViewForwarder& rForwarder ) 694 { 695 // convert to screen coordinates 696 return Rectangle( rForwarder.LogicToPixel( rRect.TopLeft(), rMapMode ), 697 rForwarder.LogicToPixel( rRect.BottomRight(), rMapMode ) ); 698 } 699 700 const Point& AccessibleEditableTextPara::GetEEOffset() const 701 { 702 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 703 704 return maEEOffset; 705 } 706 707 void AccessibleEditableTextPara::SetEEOffset( const Point& rOffset ) 708 { 709 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 710 711 WeakBullet::HardRefType aChild( maImageBullet.get() ); 712 if( aChild.is() ) 713 aChild->SetEEOffset(rOffset); 714 715 maEEOffset = rOffset; 716 } 717 718 void AccessibleEditableTextPara::FireEvent(const sal_Int16 nEventId, const uno::Any& rNewValue, const uno::Any& rOldValue) const 719 { 720 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 721 722 uno::Reference < XAccessibleContext > xThis( const_cast< AccessibleEditableTextPara* > (this)->getAccessibleContext() ); 723 724 AccessibleEventObject aEvent(xThis, nEventId, rNewValue, rOldValue); 725 726 // #102261# Call global queue for focus events 727 if( nEventId == AccessibleEventId::STATE_CHANGED ) 728 vcl::unohelper::NotifyAccessibleStateEventGlobally( aEvent ); 729 730 // #106234# Delegate to EventNotifier 731 if( getNotifierClientId() != -1 ) 732 ::comphelper::AccessibleEventNotifier::addEvent( getNotifierClientId(), 733 aEvent ); 734 } 735 736 void AccessibleEditableTextPara::GotPropertyEvent( const uno::Any& rNewValue, const sal_Int16 nEventId ) const 737 { 738 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 739 740 FireEvent( nEventId, rNewValue ); 741 } 742 743 void AccessibleEditableTextPara::LostPropertyEvent( const uno::Any& rOldValue, const sal_Int16 nEventId ) const 744 { 745 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 746 747 FireEvent( nEventId, uno::Any(), rOldValue ); 748 } 749 750 bool AccessibleEditableTextPara::HasState( const sal_Int16 nStateId ) 751 { 752 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 753 754 ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get()); 755 if( pStateSet != NULL ) 756 return pStateSet->contains(nStateId) ? true : false; 757 758 return false; 759 } 760 761 void AccessibleEditableTextPara::SetState( const sal_Int16 nStateId ) 762 { 763 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 764 765 ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get()); 766 if( pStateSet != NULL && 767 !pStateSet->contains(nStateId) ) 768 { 769 pStateSet->AddState( nStateId ); 770 //IAccessibility2 Implementation 2009----- 771 // MT: Removed method IsShapeParaFocusable which was introduced with IA2 - basically it was only about figuring out wether or not the window has the focus, should be solved differently 772 // if(IsShapeParaFocusable()) 773 GotPropertyEvent( uno::makeAny( nStateId ), AccessibleEventId::STATE_CHANGED ); 774 //-----IAccessibility2 Implementation 2009 775 } 776 } 777 778 void AccessibleEditableTextPara::UnSetState( const sal_Int16 nStateId ) 779 { 780 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 781 782 ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get()); 783 if( pStateSet != NULL && 784 pStateSet->contains(nStateId) ) 785 { 786 pStateSet->RemoveState( nStateId ); 787 LostPropertyEvent( uno::makeAny( nStateId ), AccessibleEventId::STATE_CHANGED ); 788 } 789 } 790 791 void AccessibleEditableTextPara::TextChanged() 792 { 793 ::rtl::OUString aCurrentString( OCommonAccessibleText::getText() ); 794 uno::Any aDeleted; 795 uno::Any aInserted; 796 if( OCommonAccessibleText::implInitTextChangedEvent( maLastTextString, aCurrentString, 797 aDeleted, aInserted) ) 798 { 799 FireEvent( AccessibleEventId::TEXT_CHANGED, aInserted, aDeleted ); 800 maLastTextString = aCurrentString; 801 } 802 } 803 804 sal_Bool AccessibleEditableTextPara::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, sal_Int32 nIndex ) 805 { 806 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 807 808 DBG_ASSERT(nIndex >= 0 && nIndex <= USHRT_MAX, 809 "AccessibleEditableTextPara::GetAttributeRun: index value overflow"); 810 811 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 812 "AccessibleEditableTextPara::getLocale: paragraph index value overflow"); 813 814 return GetTextForwarder().GetAttributeRun( nStartIndex, 815 nEndIndex, 816 static_cast< sal_uInt16 >(GetParagraphIndex()), 817 static_cast< sal_uInt16 >(nIndex) ); 818 } 819 820 uno::Any SAL_CALL AccessibleEditableTextPara::queryInterface (const uno::Type & rType) throw (uno::RuntimeException) 821 { 822 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 823 824 uno::Any aRet; 825 826 // must provide XAccesibleText by hand, since it comes publicly inherited by XAccessibleEditableText 827 if ( rType == ::getCppuType((uno::Reference< XAccessibleText > *)0) ) 828 { 829 //IAccessibility2 Implementation 2009----- 830 // uno::Reference< XAccessibleText > aAccText = this; 831 uno::Reference< XAccessibleText > aAccText = static_cast< XAccessibleEditableText * >(this); 832 //-----IAccessibility2 Implementation 2009 833 aRet <<= aAccText; 834 } 835 else if ( rType == ::getCppuType((uno::Reference< XAccessibleEditableText > *)0) ) 836 { 837 uno::Reference< XAccessibleEditableText > aAccEditText = this; 838 aRet <<= aAccEditText; 839 } 840 //IAccessibility2 Implementation 2009----- 841 else if ( rType == ::getCppuType((uno::Reference< XAccessibleHypertext > *)0) ) 842 { 843 uno::Reference< XAccessibleHypertext > aAccHyperText = this; 844 aRet <<= aAccHyperText; 845 } 846 //-----IAccessibility2 Implementation 2009 847 else 848 { 849 aRet = AccessibleTextParaInterfaceBase::queryInterface(rType); 850 } 851 852 return aRet; 853 } 854 855 // XAccessible 856 uno::Reference< XAccessibleContext > SAL_CALL AccessibleEditableTextPara::getAccessibleContext() throw (uno::RuntimeException) 857 { 858 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 859 860 // We implement the XAccessibleContext interface in the same object 861 return uno::Reference< XAccessibleContext > ( this ); 862 } 863 864 // XAccessibleContext 865 sal_Int32 SAL_CALL AccessibleEditableTextPara::getAccessibleChildCount() throw (uno::RuntimeException) 866 { 867 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 868 869 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 870 871 return HaveChildren() ? 1 : 0; 872 } 873 874 uno::Reference< XAccessible > SAL_CALL AccessibleEditableTextPara::getAccessibleChild( sal_Int32 i ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 875 { 876 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 877 878 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 879 880 if( !HaveChildren() ) 881 throw lang::IndexOutOfBoundsException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No childs available")), 882 uno::Reference< uno::XInterface > 883 ( static_cast< ::cppu::OWeakObject* > (this) ) ); // static_cast: disambiguate hierarchy 884 885 if( i != 0 ) 886 throw lang::IndexOutOfBoundsException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Invalid child index")), 887 uno::Reference< uno::XInterface > 888 ( static_cast< ::cppu::OWeakObject* > (this) ) ); // static_cast: disambiguate hierarchy 889 890 WeakBullet::HardRefType aChild( maImageBullet.get() ); 891 892 if( !aChild.is() ) 893 { 894 // there is no hard reference available, create object then 895 AccessibleImageBullet* pChild = new AccessibleImageBullet( uno::Reference< XAccessible >( this ) ); 896 uno::Reference< XAccessible > xChild( static_cast< ::cppu::OWeakObject* > (pChild), uno::UNO_QUERY ); 897 898 if( !xChild.is() ) 899 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Child creation failed")), 900 uno::Reference< uno::XInterface > 901 ( static_cast< ::cppu::OWeakObject* > (this) ) ); 902 903 aChild = WeakBullet::HardRefType( xChild, pChild ); 904 905 aChild->SetEditSource( &GetEditSource() ); 906 aChild->SetParagraphIndex( GetParagraphIndex() ); 907 aChild->SetIndexInParent( i ); 908 909 maImageBullet = aChild; 910 } 911 912 return aChild.getRef(); 913 } 914 915 uno::Reference< XAccessible > SAL_CALL AccessibleEditableTextPara::getAccessibleParent() throw (uno::RuntimeException) 916 { 917 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 918 919 #ifdef DBG_UTIL 920 if( !mxParent.is() ) 921 DBG_TRACE( "AccessibleEditableTextPara::getAccessibleParent: no frontend set, did somebody forgot to call AccessibleTextHelper::SetEventSource()?"); 922 #endif 923 924 return mxParent; 925 } 926 927 sal_Int32 SAL_CALL AccessibleEditableTextPara::getAccessibleIndexInParent() throw (uno::RuntimeException) 928 { 929 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 930 931 return mnIndexInParent; 932 } 933 934 sal_Int16 SAL_CALL AccessibleEditableTextPara::getAccessibleRole() throw (uno::RuntimeException) 935 { 936 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 937 938 return AccessibleRole::PARAGRAPH; 939 } 940 941 ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getAccessibleDescription() throw (uno::RuntimeException) 942 { 943 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 944 //IAccessibility2 Implementation 2009----- 945 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 946 947 // append first 40 characters from text, or first line, if shorter 948 // (writer takes first sentence here, but that's not supported 949 // from EditEngine) 950 // throws if defunc 951 ::rtl::OUString aLine; 952 953 if( getCharacterCount() ) 954 aLine = getTextAtIndex(0, AccessibleTextType::LINE).SegmentText; 955 956 // Get the string from the resource for the specified id. 957 String sStr = ::rtl::OUString( String( EditResId (RID_SVXSTR_A11Y_PARAGRAPH_DESCRIPTION ) ) ); 958 String sParaIndex = ::rtl::OUString::valueOf( GetParagraphIndex() ); 959 sStr.SearchAndReplace( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "$(ARG)" )), 960 sParaIndex ); 961 962 if( aLine.getLength() > MaxDescriptionLen ) 963 { 964 ::rtl::OUString aCurrWord; 965 sal_Int32 i; 966 967 // search backward from MaxDescriptionLen for previous word start 968 for( aCurrWord=getTextAtIndex(MaxDescriptionLen, AccessibleTextType::WORD).SegmentText, 969 i=MaxDescriptionLen, 970 aLine=::rtl::OUString(); 971 i>=0; 972 --i ) 973 { 974 if( getTextAtIndex(i, AccessibleTextType::WORD).SegmentText != aCurrWord ) 975 { 976 if( i == 0 ) 977 // prevent completely empty string 978 aLine = getTextAtIndex(0, AccessibleTextType::WORD).SegmentText; 979 else 980 aLine = getTextRange(0, i); 981 } 982 } 983 } 984 985 return ::rtl::OUString( sStr ) + aLine; 986 //-----IAccessibility2 Implementation 2009 987 } 988 989 ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getAccessibleName() throw (uno::RuntimeException) 990 { 991 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 992 993 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 994 995 // throws if defunc 996 sal_Int32 nPara( GetParagraphIndex() ); 997 998 // Get the string from the resource for the specified id. 999 String sStr = ::rtl::OUString( String( EditResId (RID_SVXSTR_A11Y_PARAGRAPH_NAME) ) ); 1000 String sParaIndex = ::rtl::OUString::valueOf( nPara ); 1001 sStr.SearchAndReplace( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "$(ARG)" )), 1002 sParaIndex ); 1003 1004 return ::rtl::OUString( sStr ); 1005 } 1006 1007 uno::Reference< XAccessibleRelationSet > SAL_CALL AccessibleEditableTextPara::getAccessibleRelationSet() throw (uno::RuntimeException) 1008 { 1009 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1010 1011 // --> OD 2006-01-11 #i27138# - provide relations CONTENT_FLOWS_FROM 1012 // and CONTENT_FLOWS_TO 1013 if ( mpParaManager ) 1014 { 1015 utl::AccessibleRelationSetHelper* pAccRelSetHelper = 1016 new utl::AccessibleRelationSetHelper(); 1017 sal_Int32 nMyParaIndex( GetParagraphIndex() ); 1018 // relation CONTENT_FLOWS_FROM 1019 if ( nMyParaIndex > 0 && 1020 mpParaManager->IsReferencable( nMyParaIndex - 1 ) ) 1021 { 1022 uno::Sequence<uno::Reference<XInterface> > aSequence(1); 1023 aSequence[0] = 1024 mpParaManager->GetChild( nMyParaIndex - 1 ).first.get().getRef(); 1025 AccessibleRelation aAccRel( AccessibleRelationType::CONTENT_FLOWS_FROM, 1026 aSequence ); 1027 pAccRelSetHelper->AddRelation( aAccRel ); 1028 } 1029 1030 // relation CONTENT_FLOWS_TO 1031 if ( (nMyParaIndex + 1) < (sal_Int32)mpParaManager->GetNum() && 1032 mpParaManager->IsReferencable( nMyParaIndex + 1 ) ) 1033 { 1034 uno::Sequence<uno::Reference<XInterface> > aSequence(1); 1035 aSequence[0] = 1036 mpParaManager->GetChild( nMyParaIndex + 1 ).first.get().getRef(); 1037 AccessibleRelation aAccRel( AccessibleRelationType::CONTENT_FLOWS_TO, 1038 aSequence ); 1039 pAccRelSetHelper->AddRelation( aAccRel ); 1040 } 1041 1042 return pAccRelSetHelper; 1043 } 1044 else 1045 { 1046 // no relations, therefore empty 1047 return uno::Reference< XAccessibleRelationSet >(); 1048 } 1049 // <-- 1050 } 1051 1052 uno::Reference< XAccessibleStateSet > SAL_CALL AccessibleEditableTextPara::getAccessibleStateSet() throw (uno::RuntimeException) 1053 { 1054 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1055 1056 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1057 1058 // Create a copy of the state set and return it. 1059 ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get()); 1060 1061 if( !pStateSet ) 1062 return uno::Reference<XAccessibleStateSet>(); 1063 //IAccessibility2 Implementation 2009----- 1064 uno::Reference<XAccessibleStateSet> xParentStates; 1065 if (getAccessibleParent().is()) 1066 { 1067 uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext(); 1068 xParentStates = xParentContext->getAccessibleStateSet(); 1069 } 1070 if (xParentStates.is() && xParentStates->contains(AccessibleStateType::EDITABLE) ) 1071 { 1072 pStateSet->AddState(AccessibleStateType::EDITABLE); 1073 } 1074 //-----IAccessibility2 Implementation 2009 1075 return uno::Reference<XAccessibleStateSet>( new ::utl::AccessibleStateSetHelper (*pStateSet) ); 1076 } 1077 1078 lang::Locale SAL_CALL AccessibleEditableTextPara::getLocale() throw (IllegalAccessibleComponentStateException, uno::RuntimeException) 1079 { 1080 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1081 1082 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1083 1084 return implGetLocale(); 1085 } 1086 1087 void SAL_CALL AccessibleEditableTextPara::addEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) throw (uno::RuntimeException) 1088 { 1089 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1090 1091 if( getNotifierClientId() != -1 ) 1092 ::comphelper::AccessibleEventNotifier::addEventListener( getNotifierClientId(), xListener ); 1093 } 1094 1095 void SAL_CALL AccessibleEditableTextPara::removeEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) throw (uno::RuntimeException) 1096 { 1097 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1098 1099 if( getNotifierClientId() != -1 ) 1100 ::comphelper::AccessibleEventNotifier::removeEventListener( getNotifierClientId(), xListener ); 1101 } 1102 1103 // XAccessibleComponent 1104 sal_Bool SAL_CALL AccessibleEditableTextPara::containsPoint( const awt::Point& aTmpPoint ) throw (uno::RuntimeException) 1105 { 1106 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1107 1108 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1109 1110 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1111 "AccessibleEditableTextPara::contains: index value overflow"); 1112 1113 awt::Rectangle aTmpRect = getBounds(); 1114 Rectangle aRect( Point(aTmpRect.X, aTmpRect.Y), Size(aTmpRect.Width, aTmpRect.Height) ); 1115 Point aPoint( aTmpPoint.X, aTmpPoint.Y ); 1116 1117 return aRect.IsInside( aPoint ); 1118 } 1119 1120 uno::Reference< XAccessible > SAL_CALL AccessibleEditableTextPara::getAccessibleAtPoint( const awt::Point& _aPoint ) throw (uno::RuntimeException) 1121 { 1122 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1123 1124 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1125 1126 if( HaveChildren() ) 1127 { 1128 // #103862# No longer need to make given position relative 1129 Point aPoint( _aPoint.X, _aPoint.Y ); 1130 1131 // respect EditEngine offset to surrounding shape/cell 1132 aPoint -= GetEEOffset(); 1133 1134 // convert to EditEngine coordinate system 1135 SvxTextForwarder& rCacheTF = GetTextForwarder(); 1136 Point aLogPoint( GetViewForwarder().PixelToLogic( aPoint, rCacheTF.GetMapMode() ) ); 1137 1138 EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 > (GetParagraphIndex()) ); 1139 1140 if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && 1141 aBulletInfo.bVisible && 1142 aBulletInfo.nType == SVX_NUM_BITMAP ) 1143 { 1144 Rectangle aRect = aBulletInfo.aBounds; 1145 1146 if( aRect.IsInside( aLogPoint ) ) 1147 return getAccessibleChild(0); 1148 } 1149 } 1150 1151 // no children at all, or none at given position 1152 return uno::Reference< XAccessible >(); 1153 } 1154 1155 awt::Rectangle SAL_CALL AccessibleEditableTextPara::getBounds() throw (uno::RuntimeException) 1156 { 1157 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1158 1159 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1160 1161 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1162 "AccessibleEditableTextPara::getBounds: index value overflow"); 1163 1164 SvxTextForwarder& rCacheTF = GetTextForwarder(); 1165 Rectangle aRect = rCacheTF.GetParaBounds( static_cast< sal_uInt16 >( GetParagraphIndex() ) ); 1166 1167 // convert to screen coordinates 1168 Rectangle aScreenRect = AccessibleEditableTextPara::LogicToPixel( aRect, 1169 rCacheTF.GetMapMode(), 1170 GetViewForwarder() ); 1171 1172 // offset from shape/cell 1173 Point aOffset = GetEEOffset(); 1174 1175 return awt::Rectangle( aScreenRect.Left() + aOffset.X(), 1176 aScreenRect.Top() + aOffset.Y(), 1177 aScreenRect.GetSize().Width(), 1178 aScreenRect.GetSize().Height() ); 1179 } 1180 1181 awt::Point SAL_CALL AccessibleEditableTextPara::getLocation( ) throw (uno::RuntimeException) 1182 { 1183 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1184 1185 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1186 1187 awt::Rectangle aRect = getBounds(); 1188 1189 return awt::Point( aRect.X, aRect.Y ); 1190 } 1191 1192 awt::Point SAL_CALL AccessibleEditableTextPara::getLocationOnScreen( ) throw (uno::RuntimeException) 1193 { 1194 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1195 1196 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1197 1198 // relate us to parent 1199 uno::Reference< XAccessible > xParent = getAccessibleParent(); 1200 if( xParent.is() ) 1201 { 1202 uno::Reference< XAccessibleComponent > xParentComponent( xParent, uno::UNO_QUERY ); 1203 if( xParentComponent.is() ) 1204 { 1205 awt::Point aRefPoint = xParentComponent->getLocationOnScreen(); 1206 awt::Point aPoint = getLocation(); 1207 aPoint.X += aRefPoint.X; 1208 aPoint.Y += aRefPoint.Y; 1209 1210 return aPoint; 1211 } 1212 // --> OD 2009-12-16 #i88070# 1213 // fallback to parent's <XAccessibleContext> instance 1214 else 1215 { 1216 uno::Reference< XAccessibleContext > xParentContext = xParent->getAccessibleContext(); 1217 if ( xParentContext.is() ) 1218 { 1219 uno::Reference< XAccessibleComponent > xParentContextComponent( xParentContext, uno::UNO_QUERY ); 1220 if( xParentContextComponent.is() ) 1221 { 1222 awt::Point aRefPoint = xParentContextComponent->getLocationOnScreen(); 1223 awt::Point aPoint = getLocation(); 1224 aPoint.X += aRefPoint.X; 1225 aPoint.Y += aRefPoint.Y; 1226 1227 return aPoint; 1228 } 1229 } 1230 } 1231 // <-- 1232 } 1233 1234 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Cannot access parent")), 1235 uno::Reference< uno::XInterface > 1236 ( static_cast< XAccessible* > (this) ) ); // disambiguate hierarchy 1237 } 1238 1239 awt::Size SAL_CALL AccessibleEditableTextPara::getSize( ) throw (uno::RuntimeException) 1240 { 1241 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1242 1243 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1244 1245 awt::Rectangle aRect = getBounds(); 1246 1247 return awt::Size( aRect.Width, aRect.Height ); 1248 } 1249 1250 void SAL_CALL AccessibleEditableTextPara::grabFocus( ) throw (uno::RuntimeException) 1251 { 1252 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1253 1254 // set cursor to this paragraph 1255 setSelection(0,0); 1256 } 1257 1258 sal_Int32 SAL_CALL AccessibleEditableTextPara::getForeground( ) throw (::com::sun::star::uno::RuntimeException) 1259 { 1260 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1261 1262 // #104444# Added to XAccessibleComponent interface 1263 svtools::ColorConfig aColorConfig; 1264 sal_uInt32 nColor = aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor; 1265 return static_cast<sal_Int32>(nColor); 1266 } 1267 1268 sal_Int32 SAL_CALL AccessibleEditableTextPara::getBackground( ) throw (::com::sun::star::uno::RuntimeException) 1269 { 1270 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1271 1272 // #104444# Added to XAccessibleComponent interface 1273 Color aColor( Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor() ); 1274 1275 // the background is transparent 1276 aColor.SetTransparency( 0xFF); 1277 1278 return static_cast<sal_Int32>( aColor.GetColor() ); 1279 } 1280 1281 // XAccessibleText 1282 sal_Int32 SAL_CALL AccessibleEditableTextPara::getCaretPosition() throw (uno::RuntimeException) 1283 { 1284 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1285 1286 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1287 1288 if( !HaveEditView() ) 1289 return -1; 1290 1291 ESelection aSelection; 1292 if( GetEditViewForwarder().GetSelection( aSelection ) && 1293 GetParagraphIndex() == aSelection.nEndPara ) 1294 { 1295 // caret is always nEndPara,nEndPos 1296 //IAccessibility2 Implementation 2009----- 1297 EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 1298 if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && 1299 aBulletInfo.bVisible && 1300 aBulletInfo.nType != SVX_NUM_BITMAP ) 1301 { 1302 sal_Int32 nBulletLen = aBulletInfo.aText.Len(); 1303 if( aSelection.nEndPos - nBulletLen >= 0 ) 1304 return aSelection.nEndPos - nBulletLen; 1305 } 1306 //-----IAccessibility2 Implementation 2009 1307 return aSelection.nEndPos; 1308 } 1309 1310 // not within this paragraph 1311 return -1; 1312 } 1313 1314 sal_Bool SAL_CALL AccessibleEditableTextPara::setCaretPosition( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1315 { 1316 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1317 1318 return setSelection(nIndex, nIndex); 1319 } 1320 1321 sal_Unicode SAL_CALL AccessibleEditableTextPara::getCharacter( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1322 { 1323 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1324 1325 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1326 1327 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1328 "AccessibleEditableTextPara::getCharacter: index value overflow"); 1329 1330 return OCommonAccessibleText::getCharacter( nIndex ); 1331 } 1332 //IAccessibility2 Implementation 2009----- 1333 static uno::Sequence< ::rtl::OUString > getAttributeNames() 1334 { 1335 static uno::Sequence< ::rtl::OUString >* pNames = NULL; 1336 1337 if( pNames == NULL ) 1338 { 1339 uno::Sequence< ::rtl::OUString >* pSeq = new uno::Sequence< ::rtl::OUString >( 21 ); 1340 ::rtl::OUString* pStrings = pSeq->getArray(); 1341 sal_Int32 i = 0; 1342 #define STR(x) pStrings[i++] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(x)) 1343 //STR("CharBackColor"); 1344 STR("CharColor"); 1345 STR("CharContoured"); 1346 STR("CharEmphasis"); 1347 STR("CharEscapement"); 1348 STR("CharFontName"); 1349 STR("CharHeight"); 1350 STR("CharPosture"); 1351 STR("CharShadowed"); 1352 STR("CharStrikeout"); 1353 STR("CharUnderline"); 1354 STR("CharUnderlineColor"); 1355 STR("CharWeight"); 1356 STR("NumberingLevel"); 1357 STR("NumberingRules"); 1358 STR("ParaAdjust"); 1359 STR("ParaBottomMargin"); 1360 STR("ParaFirstLineIndent"); 1361 STR("ParaLeftMargin"); 1362 STR("ParaLineSpacing"); 1363 STR("ParaRightMargin"); 1364 STR("ParaTabStops"); 1365 #undef STR 1366 DBG_ASSERT( i == pSeq->getLength(), "Please adjust length" ); 1367 if( i != pSeq->getLength() ) 1368 pSeq->realloc( i ); 1369 pNames = pSeq; 1370 } 1371 return *pNames; 1372 } 1373 //-----IAccessibility2 Implementation 2009 1374 struct IndexCompare 1375 { 1376 const PropertyValue* pValues; 1377 IndexCompare( const PropertyValue* pVals ) : pValues(pVals) {} 1378 bool operator() ( const sal_Int32& a, const sal_Int32& b ) const 1379 { 1380 return (pValues[a].Name < pValues[b].Name) ? true : false; 1381 } 1382 }; 1383 1384 String AccessibleEditableTextPara::GetFieldTypeNameAtIndex(sal_Int32 nIndex) 1385 { 1386 String strFldType; 1387 SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); 1388 //For field object info 1389 sal_Int32 nParaIndex = GetParagraphIndex(); 1390 sal_Int32 nAllFieldLen = 0; 1391 sal_Int32 nField = rCacheTF.GetFieldCount(sal_uInt16(nParaIndex)), nFoundFieldIndex = -1; 1392 EFieldInfo ree; 1393 sal_Int32 reeBegin, reeEnd; 1394 sal_Int32 nFieldType = -1; 1395 for(sal_uInt16 j = 0; j < nField; j++) 1396 { 1397 ree = rCacheTF.GetFieldInfo(sal_uInt16(nParaIndex), j); 1398 reeBegin = ree.aPosition.nIndex + nAllFieldLen; 1399 reeEnd = reeBegin + ree.aCurrentText.Len(); 1400 nAllFieldLen += (ree.aCurrentText.Len() - 1); 1401 if( reeBegin > nIndex ) 1402 { 1403 break; 1404 } 1405 if( nIndex >= reeBegin && nIndex < reeEnd ) 1406 { 1407 nFoundFieldIndex = j; 1408 break; 1409 } 1410 } 1411 if( nFoundFieldIndex >= 0 ) 1412 { 1413 // So we get a field, check its type now. 1414 nFieldType = ree.pFieldItem->GetField()->GetClassId() ; 1415 } 1416 switch(nFieldType) 1417 { 1418 case SVX_DATEFIELD: 1419 { 1420 const SvxDateField* pDateField = static_cast< const SvxDateField* >(ree.pFieldItem->GetField()); 1421 if (pDateField) 1422 { 1423 if (pDateField->GetType() == SVXDATETYPE_FIX) 1424 strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("date (fixed)")); 1425 else if (pDateField->GetType() == SVXDATETYPE_VAR) 1426 strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("date (variable)")); 1427 } 1428 } 1429 break; 1430 case SVX_PAGEFIELD: 1431 strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("page-number")); 1432 break; 1433 //support the sheet name & pages fields 1434 case SVX_PAGESFIELD: 1435 strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("page-count")); 1436 break; 1437 case SVX_TABLEFIELD: 1438 strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sheet-name")); 1439 break; 1440 //End 1441 case SVX_TIMEFIELD: 1442 strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("time")); 1443 break; 1444 case SVX_EXT_TIMEFIELD: 1445 { 1446 const SvxExtTimeField* pTimeField = static_cast< const SvxExtTimeField* >(ree.pFieldItem->GetField()); 1447 if (pTimeField) 1448 { 1449 if (pTimeField->GetType() == SVXTIMETYPE_FIX) 1450 strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("time (fixed)")); 1451 else if (pTimeField->GetType() == SVXTIMETYPE_VAR) 1452 strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("time (variable)")); 1453 } 1454 } 1455 break; 1456 case SVX_AUTHORFIELD: 1457 strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("author")); 1458 break; 1459 case SVX_EXT_FILEFIELD: 1460 case SVX_FILEFIELD: 1461 strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file name")); 1462 default: 1463 break; 1464 } 1465 return strFldType; 1466 } 1467 1468 uno::Sequence< beans::PropertyValue > SAL_CALL AccessibleEditableTextPara::getCharacterAttributes( sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rRequestedAttributes ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1469 { 1470 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1471 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1472 1473 //IAccessibility2 Implementation 2009----- 1474 //Skip the bullet range to ingnore the bullet text 1475 SvxTextForwarder& rCacheTF = GetTextForwarder(); 1476 EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 1477 if (aBulletInfo.bVisible) 1478 nIndex += aBulletInfo.aText.Len(); 1479 if (nIndex != 0 && nIndex >= getCharacterCount()) 1480 nIndex = getCharacterCount()-1; 1481 // 1482 if (nIndex != 0) 1483 CheckIndex(nIndex); // may throw IndexOutOfBoundsException 1484 1485 bool bSupplementalMode = false; 1486 uno::Sequence< ::rtl::OUString > aPropertyNames = rRequestedAttributes; 1487 if (aPropertyNames.getLength() == 0) 1488 { 1489 bSupplementalMode = true; 1490 aPropertyNames = getAttributeNames(); 1491 } 1492 // get default attribues... 1493 ::comphelper::SequenceAsHashMap aPropHashMap( getDefaultAttributes( aPropertyNames ) ); 1494 1495 // ... and override them with the direct attributes from the specific position 1496 uno::Sequence< beans::PropertyValue > aRunAttribs( getRunAttributes( nIndex, aPropertyNames ) ); 1497 //-----IAccessibility2 Implementation 2009 1498 sal_Int32 nRunAttribs = aRunAttribs.getLength(); 1499 const beans::PropertyValue *pRunAttrib = aRunAttribs.getConstArray(); 1500 for (sal_Int32 k = 0; k < nRunAttribs; ++k) 1501 { 1502 const beans::PropertyValue &rRunAttrib = pRunAttrib[k]; 1503 aPropHashMap[ rRunAttrib.Name ] = rRunAttrib.Value; //!! should not only be the value !! 1504 } 1505 #ifdef TL_DEBUG 1506 { 1507 uno::Sequence< rtl::OUString > aNames(1); 1508 aNames.getArray()[0] = rtl::OUString::createFromAscii("CharHeight"); 1509 const rtl::OUString *pNames = aNames.getConstArray(); 1510 const uno::Sequence< beans::PropertyValue > aAttribs( getRunAttributes( nIndex, aNames ) ); 1511 const beans::PropertyValue *pAttribs = aAttribs.getConstArray(); 1512 double d1 = -1.0; 1513 float f1 = -1.0; 1514 if (aAttribs.getLength()) 1515 { 1516 uno::Any aAny( pAttribs[0].Value ); 1517 aAny >>= d1; 1518 aAny >>= f1; 1519 } 1520 int i = 3; 1521 } 1522 #endif 1523 1524 // get resulting sequence 1525 uno::Sequence< beans::PropertyValue > aRes; 1526 aPropHashMap >> aRes; 1527 1528 // since SequenceAsHashMap ignores property handles and property state 1529 // we have to restore the property state here (property handles are 1530 // of no use to the accessibility API). 1531 sal_Int32 nRes = aRes.getLength(); 1532 beans::PropertyValue *pRes = aRes.getArray(); 1533 for (sal_Int32 i = 0; i < nRes; ++i) 1534 { 1535 beans::PropertyValue &rRes = pRes[i]; 1536 sal_Bool bIsDirectVal = sal_False; 1537 for (sal_Int32 k = 0; k < nRunAttribs && !bIsDirectVal; ++k) 1538 { 1539 if (rRes.Name == pRunAttrib[k].Name) 1540 bIsDirectVal = sal_True; 1541 } 1542 rRes.Handle = -1; 1543 rRes.State = bIsDirectVal ? PropertyState_DIRECT_VALUE : PropertyState_DEFAULT_VALUE; 1544 } 1545 //IAccessibility2 Implementation 2009----- 1546 if( bSupplementalMode ) 1547 { 1548 _correctValues( nIndex, aRes ); 1549 // NumberingPrefix 1550 nRes = aRes.getLength(); 1551 aRes.realloc( nRes + 1 ); 1552 pRes = aRes.getArray(); 1553 beans::PropertyValue &rRes = pRes[nRes]; 1554 rRes.Name = rtl::OUString::createFromAscii("NumberingPrefix"); 1555 ::rtl::OUString numStr; 1556 if (aBulletInfo.nType != SVX_NUM_CHAR_SPECIAL && aBulletInfo.nType != SVX_NUM_BITMAP) 1557 numStr = (::rtl::OUString)aBulletInfo.aText; 1558 rRes.Value <<= numStr; 1559 rRes.Handle = -1; 1560 rRes.State = PropertyState_DIRECT_VALUE; 1561 //-----IAccessibility2 Implementation 2009 1562 //For field object. 1563 String strFieldType = GetFieldTypeNameAtIndex(nIndex); 1564 if (strFieldType.Len() > 0) 1565 { 1566 nRes = aRes.getLength(); 1567 aRes.realloc( nRes + 1 ); 1568 pRes = aRes.getArray(); 1569 beans::PropertyValue &rResField = pRes[nRes]; 1570 beans::PropertyValue aFieldType; 1571 rResField.Name = rtl::OUString::createFromAscii("FieldType"); 1572 rResField.Value <<= rtl::OUString(strFieldType.ToLowerAscii()); 1573 rResField.Handle = -1; 1574 rResField.State = PropertyState_DIRECT_VALUE; 1575 } 1576 //sort property values 1577 // build sorted index array 1578 sal_Int32 nLength = aRes.getLength(); 1579 const beans::PropertyValue* pPairs = aRes.getConstArray(); 1580 sal_Int32* pIndices = new sal_Int32[nLength]; 1581 sal_Int32 i = 0; 1582 for( i = 0; i < nLength; i++ ) 1583 pIndices[i] = i; 1584 sort( &pIndices[0], &pIndices[nLength], IndexCompare(pPairs) ); 1585 // create sorted sequences accoring to index array 1586 uno::Sequence<beans::PropertyValue> aNewValues( nLength ); 1587 beans::PropertyValue* pNewValues = aNewValues.getArray(); 1588 for( i = 0; i < nLength; i++ ) 1589 { 1590 pNewValues[i] = pPairs[pIndices[i]]; 1591 } 1592 delete[] pIndices; 1593 // 1594 return aNewValues; 1595 } 1596 return aRes; 1597 } 1598 1599 awt::Rectangle SAL_CALL AccessibleEditableTextPara::getCharacterBounds( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1600 { 1601 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1602 1603 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1604 1605 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1606 "AccessibleEditableTextPara::getCharacterBounds: index value overflow"); 1607 1608 // #108900# Have position semantics now for nIndex, as 1609 // one-past-the-end values are legal, too. 1610 CheckPosition( nIndex ); 1611 1612 SvxTextForwarder& rCacheTF = GetTextForwarder(); 1613 Rectangle aRect = rCacheTF.GetCharBounds( static_cast< sal_uInt16 >( GetParagraphIndex() ), static_cast< sal_uInt16 >( nIndex ) ); 1614 1615 // convert to screen 1616 Rectangle aScreenRect = AccessibleEditableTextPara::LogicToPixel( aRect, 1617 rCacheTF.GetMapMode(), 1618 GetViewForwarder() ); 1619 // #109864# offset from parent (paragraph), but in screen 1620 // coordinates. This makes sure the internal text offset in 1621 // the outline view forwarder gets cancelled out here 1622 awt::Rectangle aParaRect( getBounds() ); 1623 aScreenRect.Move( -aParaRect.X, -aParaRect.Y ); 1624 1625 // offset from shape/cell 1626 Point aOffset = GetEEOffset(); 1627 1628 return awt::Rectangle( aScreenRect.Left() + aOffset.X(), 1629 aScreenRect.Top() + aOffset.Y(), 1630 aScreenRect.GetSize().Width(), 1631 aScreenRect.GetSize().Height() ); 1632 } 1633 1634 sal_Int32 SAL_CALL AccessibleEditableTextPara::getCharacterCount() throw (uno::RuntimeException) 1635 { 1636 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1637 1638 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1639 1640 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1641 "AccessibleEditableTextPara::getCharacterCount: index value overflow"); 1642 1643 return OCommonAccessibleText::getCharacterCount(); 1644 } 1645 1646 sal_Int32 SAL_CALL AccessibleEditableTextPara::getIndexAtPoint( const awt::Point& rPoint ) throw (uno::RuntimeException) 1647 { 1648 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1649 1650 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1651 //IAccessibility2 Implementation 2009----- 1652 if ((rPoint.X <= 0) && (rPoint.Y <= 0)) 1653 return 0; 1654 //-----IAccessibility2 Implementation 2009 1655 sal_uInt16 nPara, nIndex; 1656 1657 // offset from surrounding cell/shape 1658 Point aOffset( GetEEOffset() ); 1659 Point aPoint( rPoint.X - aOffset.X(), rPoint.Y - aOffset.Y() ); 1660 1661 // convert to logical coordinates 1662 SvxTextForwarder& rCacheTF = GetTextForwarder(); 1663 Point aLogPoint( GetViewForwarder().PixelToLogic( aPoint, rCacheTF.GetMapMode() ) ); 1664 1665 // re-offset to parent (paragraph) 1666 Rectangle aParaRect = rCacheTF.GetParaBounds( static_cast< sal_uInt16 >( GetParagraphIndex() ) ); 1667 aLogPoint.Move( aParaRect.Left(), aParaRect.Top() ); 1668 1669 if( rCacheTF.GetIndexAtPoint( aLogPoint, nPara, nIndex ) && 1670 GetParagraphIndex() == nPara ) 1671 { 1672 // #102259# Double-check if we're _really_ on the given character 1673 try 1674 { 1675 awt::Rectangle aRect1( getCharacterBounds(nIndex) ); 1676 Rectangle aRect2( aRect1.X, aRect1.Y, 1677 aRect1.Width + aRect1.X, aRect1.Height + aRect1.Y ); 1678 if( aRect2.IsInside( Point( rPoint.X, rPoint.Y ) ) ) 1679 return nIndex; 1680 else 1681 return -1; 1682 } 1683 catch( const lang::IndexOutOfBoundsException& ) 1684 { 1685 // #103927# Don't throw for invalid nIndex values 1686 return -1; 1687 } 1688 } 1689 else 1690 { 1691 // not within our paragraph 1692 return -1; 1693 } 1694 } 1695 1696 ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getSelectedText() throw (uno::RuntimeException) 1697 { 1698 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1699 1700 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1701 1702 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1703 "AccessibleEditableTextPara::getSelectedText: index value overflow"); 1704 1705 if( !HaveEditView() ) 1706 return ::rtl::OUString(); 1707 1708 return OCommonAccessibleText::getSelectedText(); 1709 } 1710 1711 sal_Int32 SAL_CALL AccessibleEditableTextPara::getSelectionStart() throw (uno::RuntimeException) 1712 { 1713 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1714 1715 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1716 1717 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1718 "AccessibleEditableTextPara::getSelectionStart: index value overflow"); 1719 1720 if( !HaveEditView() ) 1721 return -1; 1722 1723 return OCommonAccessibleText::getSelectionStart(); 1724 } 1725 1726 sal_Int32 SAL_CALL AccessibleEditableTextPara::getSelectionEnd() throw (uno::RuntimeException) 1727 { 1728 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1729 1730 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1731 1732 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1733 "AccessibleEditableTextPara::getSelectionEnd: index value overflow"); 1734 1735 if( !HaveEditView() ) 1736 return -1; 1737 1738 return OCommonAccessibleText::getSelectionEnd(); 1739 } 1740 1741 sal_Bool SAL_CALL AccessibleEditableTextPara::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1742 { 1743 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1744 1745 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1746 1747 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1748 "AccessibleEditableTextPara::setSelection: paragraph index value overflow"); 1749 1750 CheckRange(nStartIndex, nEndIndex); 1751 1752 try 1753 { 1754 SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_True ); 1755 return rCacheVF.SetSelection( MakeSelection(nStartIndex, nEndIndex) ); 1756 } 1757 catch( const uno::RuntimeException& ) 1758 { 1759 return sal_False; 1760 } 1761 } 1762 1763 ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getText() throw (uno::RuntimeException) 1764 { 1765 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1766 1767 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1768 1769 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1770 "AccessibleEditableTextPara::getText: paragraph index value overflow"); 1771 1772 return OCommonAccessibleText::getText(); 1773 } 1774 1775 ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1776 { 1777 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1778 1779 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1780 1781 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1782 "AccessibleEditableTextPara::getTextRange: paragraph index value overflow"); 1783 1784 return OCommonAccessibleText::getTextRange(nStartIndex, nEndIndex); 1785 } 1786 //IAccessibility2 Implementation 2009----- 1787 void AccessibleEditableTextPara::_correctValues( const sal_Int32 nIndex, 1788 uno::Sequence< PropertyValue >& rValues) 1789 { 1790 SvxTextForwarder& rCacheTF = GetTextForwarder(); 1791 sal_Int32 nRes = rValues.getLength(); 1792 beans::PropertyValue *pRes = rValues.getArray(); 1793 for (sal_Int32 i = 0; i < nRes; ++i) 1794 { 1795 beans::PropertyValue &rRes = pRes[i]; 1796 // Char color 1797 if (rRes.Name.compareTo(::rtl::OUString::createFromAscii("CharColor"))==0) 1798 { 1799 uno::Any &anyChar = rRes.Value; 1800 sal_uInt32 crChar = (sal_uInt32)(anyChar.pReserved); 1801 if (COL_AUTO == crChar ) 1802 { 1803 uno::Reference< ::com::sun::star::accessibility::XAccessibleComponent > xComponent; 1804 if (mxParent.is()) 1805 { 1806 xComponent.set(mxParent,uno::UNO_QUERY); 1807 } 1808 else 1809 { 1810 xComponent.set(m_xAccInfo,uno::UNO_QUERY); 1811 } 1812 if (xComponent.is()) 1813 { 1814 uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > xContext(xComponent,uno::UNO_QUERY); 1815 if (xContext->getAccessibleRole() == AccessibleRole::SHAPE 1816 || xContext->getAccessibleRole() == AccessibleRole::TABLE_CELL) 1817 { 1818 anyChar <<= COL_BLACK; 1819 } 1820 else 1821 { 1822 Color cr(xComponent->getBackground()); 1823 crChar = cr.IsDark() ? COL_WHITE : COL_BLACK; 1824 anyChar <<= crChar; 1825 } 1826 } 1827 } 1828 continue; 1829 } 1830 // Underline 1831 if(rRes.Name.compareTo(::rtl::OUString::createFromAscii("CharUnderline"))==0) 1832 { 1833 /* 1834 // MT: Implement XAccessibleTextMarkup, mark with TextMarkupType::SPELLCHECK. This way done in SW. 1835 if (IsCurrentEditorEnableAutoSpell( mxParent )) 1836 { 1837 try 1838 { 1839 SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_False ); 1840 sal_Bool bWrong = rCacheVF.IsWrongSpelledWordAtPos( GetParagraphIndex(), nIndex ); 1841 if ( bWrong ) 1842 { 1843 uno::Any &anyUnderLine = pRes[9].Value; 1844 // MT IA2: Not needed? sal_uInt16 crUnderLine = (sal_uInt16)(anyUnderLine.pReserved); 1845 anyUnderLine <<= (sal_uInt16)UNDERLINE_WAVE; 1846 } 1847 } 1848 catch( const uno::RuntimeException& ) 1849 { 1850 } 1851 } 1852 */ 1853 continue; 1854 } 1855 // Underline color && Mis-spell 1856 if(rRes.Name.compareTo(::rtl::OUString::createFromAscii("CharUnderlineColor"))==0) 1857 { 1858 uno::Any &anyCharUnderLine = rRes.Value; 1859 sal_uInt32 crCharUnderLine = (sal_uInt32)(anyCharUnderLine.pReserved); 1860 if (COL_AUTO == crCharUnderLine ) 1861 { 1862 uno::Reference< ::com::sun::star::accessibility::XAccessibleComponent > xComponent; 1863 if (mxParent.is()) 1864 { 1865 xComponent.set(mxParent,uno::UNO_QUERY); 1866 } 1867 else 1868 { 1869 xComponent.set(m_xAccInfo,uno::UNO_QUERY); 1870 } 1871 if (xComponent.is()) 1872 { 1873 uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > xContext(xComponent,uno::UNO_QUERY); 1874 if (xContext->getAccessibleRole() == AccessibleRole::SHAPE 1875 || xContext->getAccessibleRole() == AccessibleRole::TABLE_CELL) 1876 { 1877 anyCharUnderLine <<= COL_BLACK; 1878 } 1879 else 1880 { 1881 Color cr(xComponent->getBackground()); 1882 crCharUnderLine = cr.IsDark() ? COL_WHITE : COL_BLACK; 1883 anyCharUnderLine <<= crCharUnderLine; 1884 } 1885 } 1886 } 1887 // MT: Implement XAccessibleTextMarkup, mark with TextMarkupType::SPELLCHECK. This way done in SW. 1888 /* 1889 if (IsCurrentEditorEnableAutoSpell( mxParent )) 1890 { 1891 try 1892 { 1893 SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_False ); 1894 sal_Bool bWrong = rCacheVF.IsWrongSpelledWordAtPos( GetParagraphIndex(), nIndex ); 1895 if ( bWrong ) 1896 { 1897 uno::Any &anyUnderLineColor = rRes.Value; 1898 // MT IA2: Not needed? sal_uInt16 crUnderLineColor = (sal_uInt16)(anyUnderLineColor.pReserved); 1899 anyUnderLineColor <<= COL_LIGHTRED; 1900 } 1901 } 1902 catch( const uno::RuntimeException& ) 1903 { 1904 } 1905 } 1906 */ 1907 continue; 1908 } 1909 // NumberingLevel 1910 if(rRes.Name.compareTo(::rtl::OUString::createFromAscii("NumberingLevel"))==0) 1911 { 1912 const SvxNumBulletItem& rNumBullet = ( SvxNumBulletItem& )rCacheTF.GetParaAttribs(static_cast< sal_uInt16 >(GetParagraphIndex())).Get(EE_PARA_NUMBULLET); 1913 if(rNumBullet.GetNumRule()->GetLevelCount()==0) 1914 { 1915 rRes.Value <<= (sal_Int16)-1; 1916 rRes.Handle = -1; 1917 rRes.State = PropertyState_DIRECT_VALUE; 1918 } 1919 else 1920 { 1921 // SvxAccessibleTextPropertySet aPropSet( &GetEditSource(), 1922 // ImplGetSvxCharAndParaPropertiesMap() ); 1923 // MT IA2 TODO: Check if this is the correct replacement for ImplGetSvxCharAndParaPropertiesMap 1924 SvxAccessibleTextPropertySet aPropSet( &GetEditSource(), ImplGetSvxTextPortionSvxPropertySet() ); 1925 1926 aPropSet.SetSelection( MakeSelection( 0, GetTextLen() ) ); 1927 rRes.Value = aPropSet._getPropertyValue( rRes.Name, mnParagraphIndex ); 1928 rRes.State = aPropSet._getPropertyState( rRes.Name, mnParagraphIndex ); 1929 rRes.Handle = -1; 1930 } 1931 continue; 1932 } 1933 // NumberingRules 1934 if(rRes.Name.compareTo(::rtl::OUString::createFromAscii("NumberingRules"))==0) 1935 { 1936 SfxItemSet aAttribs = rCacheTF.GetParaAttribs( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 1937 sal_Bool bVis = ((const SfxUInt16Item&)aAttribs.Get( EE_PARA_BULLETSTATE )).GetValue() ? sal_True : sal_False; 1938 if(bVis) 1939 { 1940 rRes.Value <<= (sal_Int16)-1; 1941 rRes.Handle = -1; 1942 rRes.State = PropertyState_DIRECT_VALUE; 1943 } 1944 else 1945 { 1946 // MT IA2 TODO: Check if this is the correct replacement for ImplGetSvxCharAndParaPropertiesMap 1947 SvxAccessibleTextPropertySet aPropSet( &GetEditSource(), ImplGetSvxTextPortionSvxPropertySet() ); 1948 aPropSet.SetSelection( MakeSelection( 0, GetTextLen() ) ); 1949 rRes.Value = aPropSet._getPropertyValue( rRes.Name, mnParagraphIndex ); 1950 rRes.State = aPropSet._getPropertyState( rRes.Name, mnParagraphIndex ); 1951 rRes.Handle = -1; 1952 } 1953 continue; 1954 } 1955 } 1956 } 1957 sal_Int32 AccessibleEditableTextPara::SkipField(sal_Int32 nIndex, sal_Bool bForward) 1958 { 1959 sal_Int32 nParaIndex = GetParagraphIndex(); 1960 SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); 1961 sal_Int32 nAllFieldLen = 0; 1962 sal_Int32 nField = rCacheTF.GetFieldCount(sal_uInt16(nParaIndex)), nFoundFieldIndex = -1; 1963 EFieldInfo ree; 1964 sal_Int32 reeBegin=0, reeEnd=0; 1965 for(sal_uInt16 j = 0; j < nField; j++) 1966 { 1967 ree = rCacheTF.GetFieldInfo(sal_uInt16(nParaIndex), j); 1968 reeBegin = ree.aPosition.nIndex + nAllFieldLen; 1969 reeEnd = reeBegin + ree.aCurrentText.Len(); 1970 nAllFieldLen += (ree.aCurrentText.Len() - 1); 1971 if( reeBegin > nIndex ) 1972 { 1973 break; 1974 } 1975 if( nIndex >= reeBegin && nIndex < reeEnd ) 1976 { 1977 if(ree.pFieldItem->GetField()->GetClassId() != SVX_URLFIELD) 1978 { 1979 nFoundFieldIndex = j; 1980 break; 1981 } 1982 } 1983 } 1984 if( nFoundFieldIndex >= 0 ) 1985 { 1986 if( bForward ) 1987 return reeEnd - 1; 1988 else 1989 return reeBegin; 1990 } 1991 return nIndex; 1992 } 1993 sal_Bool AccessibleEditableTextPara::ExtendByField( ::com::sun::star::accessibility::TextSegment& Segment ) 1994 { 1995 sal_Int32 nParaIndex = GetParagraphIndex(); 1996 SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); 1997 sal_Int32 nAllFieldLen = 0; 1998 sal_Int32 nField = rCacheTF.GetFieldCount(sal_uInt16(nParaIndex)), nFoundFieldIndex = -1; 1999 EFieldInfo ree; 2000 sal_Int32 reeBegin=0, reeEnd=0; 2001 for(sal_uInt16 j = 0; j < nField; j++) 2002 { 2003 ree = rCacheTF.GetFieldInfo(sal_uInt16(nParaIndex), j); 2004 reeBegin = ree.aPosition.nIndex + nAllFieldLen; 2005 reeEnd = reeBegin + ree.aCurrentText.Len(); 2006 nAllFieldLen += (ree.aCurrentText.Len() - 1); 2007 if( reeBegin > Segment.SegmentEnd ) 2008 { 2009 break; 2010 } 2011 if( (Segment.SegmentEnd > reeBegin && Segment.SegmentEnd <= reeEnd) || 2012 (Segment.SegmentStart >= reeBegin && Segment.SegmentStart < reeEnd) ) 2013 { 2014 if(ree.pFieldItem->GetField()->GetClassId() != SVX_URLFIELD) 2015 { 2016 nFoundFieldIndex = j; 2017 break; 2018 } 2019 } 2020 } 2021 sal_Bool bExtend = sal_False; 2022 if( nFoundFieldIndex >= 0 ) 2023 { 2024 if( Segment.SegmentEnd < reeEnd ) 2025 { 2026 Segment.SegmentEnd = reeEnd; 2027 bExtend = sal_True; 2028 } 2029 if( Segment.SegmentStart > reeBegin ) 2030 { 2031 Segment.SegmentStart = reeBegin; 2032 bExtend = sal_True; 2033 } 2034 if( bExtend ) 2035 { 2036 //If there is a bullet before the field, should add the bullet length into the segment. 2037 EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo(sal_uInt16(nParaIndex)); 2038 int nBulletLen = aBulletInfo.aText.Len(); 2039 if (nBulletLen > 0) 2040 { 2041 Segment.SegmentEnd += nBulletLen; 2042 if (nFoundFieldIndex > 0) 2043 Segment.SegmentStart += nBulletLen; 2044 Segment.SegmentText = GetTextRange(Segment.SegmentStart, Segment.SegmentEnd); 2045 //After get the correct field name, should restore the offset value which don't contain the bullet. 2046 Segment.SegmentEnd -= nBulletLen; 2047 if (nFoundFieldIndex > 0) 2048 Segment.SegmentStart -= nBulletLen; 2049 } 2050 else 2051 Segment.SegmentText = GetTextRange(Segment.SegmentStart, Segment.SegmentEnd); 2052 } 2053 } 2054 return bExtend; 2055 } 2056 //-----IAccessibility2 Implementation 2009 2057 ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) 2058 { 2059 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2060 2061 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2062 2063 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2064 "AccessibleEditableTextPara::getTextAtIndex: paragraph index value overflow"); 2065 2066 ::com::sun::star::accessibility::TextSegment aResult; 2067 aResult.SegmentStart = -1; 2068 aResult.SegmentEnd = -1; 2069 2070 switch( aTextType ) 2071 { 2072 //IAccessibility2 Implementation 2009----- 2073 case AccessibleTextType::CHARACTER: 2074 case AccessibleTextType::WORD: 2075 { 2076 aResult = OCommonAccessibleText::getTextAtIndex( nIndex, aTextType ); 2077 ExtendByField( aResult ); 2078 break; 2079 } 2080 //-----IAccessibility2 Implementation 2009 2081 // Not yet handled by OCommonAccessibleText. Missing 2082 // implGetAttributeRunBoundary() method there 2083 case AccessibleTextType::ATTRIBUTE_RUN: 2084 { 2085 const sal_Int32 nTextLen = GetTextForwarder().GetTextLen( static_cast< sal_uInt16 >( GetParagraphIndex() ) ); 2086 2087 if( nIndex == nTextLen ) 2088 { 2089 // #i17014# Special-casing one-behind-the-end character 2090 aResult.SegmentStart = aResult.SegmentEnd = nTextLen; 2091 } 2092 else 2093 { 2094 sal_uInt16 nStartIndex, nEndIndex; 2095 //For the bullet paragraph, the bullet string is ingnored for IAText::attributes() function. 2096 SvxTextForwarder& rCacheTF = GetTextForwarder(); 2097 // MT IA2: Not used? sal_Int32 nBulletLen = 0; 2098 EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 2099 if (aBulletInfo.bVisible) 2100 nIndex += aBulletInfo.aText.Len(); 2101 if (nIndex != 0 && nIndex >= getCharacterCount()) 2102 nIndex = getCharacterCount()-1; 2103 CheckPosition(nIndex); 2104 if( GetAttributeRun(nStartIndex, nEndIndex, nIndex) ) 2105 { 2106 aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex); 2107 if (aBulletInfo.bVisible) 2108 { 2109 nStartIndex -= aBulletInfo.aText.Len(); 2110 nEndIndex -= aBulletInfo.aText.Len(); 2111 } 2112 aResult.SegmentStart = nStartIndex; 2113 aResult.SegmentEnd = nEndIndex; 2114 } 2115 } 2116 break; 2117 } 2118 //IAccessibility2 Implementation 2009----- 2119 case AccessibleTextType::LINE: 2120 { 2121 SvxTextForwarder& rCacheTF = GetTextForwarder(); 2122 sal_Int32 nParaIndex = GetParagraphIndex(); 2123 // MT IA2: Not needed? sal_Int32 nTextLen = rCacheTF.GetTextLen( static_cast< sal_uInt16 >( nParaIndex ) ); 2124 CheckPosition(nIndex); 2125 if (nIndex != 0 && nIndex == getCharacterCount()) 2126 --nIndex; 2127 sal_uInt16 nLine, nLineCount=rCacheTF.GetLineCount( static_cast< sal_uInt16 >( nParaIndex ) ); 2128 sal_Int32 nCurIndex; 2129 //the problem is that rCacheTF.GetLineLen() will include the bullet length. But for the bullet line, 2130 //the text value doesn't contain the bullet characters. all of the bullet and numbering info are exposed 2131 //by the IAText::attributes(). So here must do special support for bullet line. 2132 sal_Int32 nBulletLen = 0; 2133 for( nLine=0, nCurIndex=0; nLine<nLineCount; ++nLine ) 2134 { 2135 if (nLine == 0) 2136 { 2137 EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 >(nParaIndex) ); 2138 if (aBulletInfo.bVisible) 2139 { 2140 //in bullet or numbering; 2141 nBulletLen = aBulletInfo.aText.Len(); 2142 } 2143 } 2144 //nCurIndex += rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ), nLine); 2145 sal_Int32 nLineLen = rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ), nLine); 2146 if (nLine == 0) 2147 nCurIndex += nLineLen - nBulletLen; 2148 else 2149 nCurIndex += nLineLen; 2150 if( nCurIndex > nIndex ) 2151 { 2152 if (nLine ==0) 2153 { 2154 //aResult.SegmentStart = nCurIndex - rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine); 2155 aResult.SegmentStart = 0; 2156 aResult.SegmentEnd = nCurIndex; 2157 //aResult.SegmentText = GetTextRange( aResult.SegmentStart, aResult.SegmentEnd ); 2158 aResult.SegmentText = GetTextRange( aResult.SegmentStart, aResult.SegmentEnd + nBulletLen); 2159 break; 2160 } 2161 else 2162 { 2163 //aResult.SegmentStart = nCurIndex - rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine); 2164 aResult.SegmentStart = nCurIndex - nLineLen; 2165 aResult.SegmentEnd = nCurIndex; 2166 //aResult.SegmentText = GetTextRange( aResult.SegmentStart, aResult.SegmentEnd ); 2167 aResult.SegmentText = GetTextRange( aResult.SegmentStart + nBulletLen, aResult.SegmentEnd + nBulletLen); 2168 break; 2169 } 2170 } 2171 } 2172 break; 2173 } 2174 //-----IAccessibility2 Implementation 2009 2175 default: 2176 aResult = OCommonAccessibleText::getTextAtIndex( nIndex, aTextType ); 2177 break; 2178 } /* end of switch( aTextType ) */ 2179 2180 return aResult; 2181 } 2182 2183 ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) 2184 { 2185 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2186 2187 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2188 2189 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2190 "AccessibleEditableTextPara::getTextBeforeIndex: paragraph index value overflow"); 2191 2192 ::com::sun::star::accessibility::TextSegment aResult; 2193 aResult.SegmentStart = -1; 2194 aResult.SegmentEnd = -1; 2195 //IAccessibility2 Implementation 2009----- 2196 i18n::Boundary aBoundary; 2197 //-----IAccessibility2 Implementation 2009 2198 switch( aTextType ) 2199 { 2200 // Not yet handled by OCommonAccessibleText. Missing 2201 // implGetAttributeRunBoundary() method there 2202 case AccessibleTextType::ATTRIBUTE_RUN: 2203 { 2204 const sal_Int32 nTextLen = GetTextForwarder().GetTextLen( static_cast< sal_uInt16 >( GetParagraphIndex() ) ); 2205 sal_uInt16 nStartIndex, nEndIndex; 2206 2207 if( nIndex == nTextLen ) 2208 { 2209 // #i17014# Special-casing one-behind-the-end character 2210 if( nIndex > 0 && 2211 GetAttributeRun(nStartIndex, nEndIndex, nIndex-1) ) 2212 { 2213 aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex); 2214 aResult.SegmentStart = nStartIndex; 2215 aResult.SegmentEnd = nEndIndex; 2216 } 2217 } 2218 else 2219 { 2220 if( GetAttributeRun(nStartIndex, nEndIndex, nIndex) ) 2221 { 2222 // already at the left border? If not, query 2223 // one index further left 2224 if( nStartIndex > 0 && 2225 GetAttributeRun(nStartIndex, nEndIndex, nStartIndex-1) ) 2226 { 2227 aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex); 2228 aResult.SegmentStart = nStartIndex; 2229 aResult.SegmentEnd = nEndIndex; 2230 } 2231 } 2232 } 2233 break; 2234 } 2235 //IAccessibility2 Implementation 2009----- 2236 case AccessibleTextType::LINE: 2237 { 2238 SvxTextForwarder& rCacheTF = GetTextForwarder(); 2239 sal_Int32 nParaIndex = GetParagraphIndex(); 2240 // MT IA2 not needed? sal_Int32 nTextLen = rCacheTF.GetTextLen( static_cast< sal_uInt16 >( nParaIndex ) ); 2241 2242 CheckPosition(nIndex); 2243 2244 sal_uInt16 nLine, nLineCount=rCacheTF.GetLineCount( static_cast< sal_uInt16 >( nParaIndex ) ); 2245 //the problem is that rCacheTF.GetLineLen() will include the bullet length. But for the bullet line, 2246 //the text value doesn't contain the bullet characters. all of the bullet and numbering info are exposed 2247 //by the IAText::attributes(). So here must do special support for bullet line. 2248 sal_Int32 nCurIndex=0, nLastIndex=0, nCurLineLen=0; 2249 sal_Int32 nLastLineLen = 0, nBulletLen = 0;; 2250 // get the line before the line the index points into 2251 for( nLine=0, nCurIndex=0, nLastIndex=0; nLine<nLineCount; ++nLine ) 2252 { 2253 nLastIndex = nCurIndex; 2254 if (nLine == 0) 2255 { 2256 EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 >(nParaIndex) ); 2257 if (aBulletInfo.bVisible) 2258 { 2259 //in bullet or numbering; 2260 nBulletLen = aBulletInfo.aText.Len(); 2261 } 2262 } 2263 if (nLine == 1) 2264 nLastLineLen = nCurLineLen - nBulletLen; 2265 else 2266 nLastLineLen = nCurLineLen; 2267 nCurLineLen = rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine); 2268 //nCurIndex += nCurLineLen; 2269 if (nLine == 0) 2270 nCurIndex += nCurLineLen - nBulletLen; 2271 else 2272 nCurIndex += nCurLineLen; 2273 2274 //if( nCurIndex > nIndex && 2275 //nLastIndex > nCurLineLen ) 2276 if (nCurIndex > nIndex) 2277 { 2278 if (nLine == 0) 2279 { 2280 break; 2281 } 2282 else if (nLine == 1) 2283 { 2284 aResult.SegmentStart = 0; 2285 aResult.SegmentEnd = static_cast< sal_uInt16 >( nLastIndex ); 2286 aResult.SegmentText = GetTextRange( aResult.SegmentStart, aResult.SegmentEnd + nBulletLen); 2287 break; 2288 } 2289 else 2290 { 2291 //aResult.SegmentStart = nLastIndex - nCurLineLen; 2292 aResult.SegmentStart = nLastIndex - nLastLineLen; 2293 aResult.SegmentEnd = static_cast< sal_uInt16 >( nLastIndex ); 2294 aResult.SegmentText = GetTextRange( aResult.SegmentStart + nBulletLen, aResult.SegmentEnd + nBulletLen); 2295 break; 2296 } 2297 } 2298 } 2299 2300 break; 2301 } 2302 case AccessibleTextType::WORD: 2303 { 2304 nIndex = SkipField( nIndex, sal_False); 2305 ::rtl::OUString sText( implGetText() ); 2306 sal_Int32 nLength = sText.getLength(); 2307 2308 // get word at index 2309 implGetWordBoundary( aBoundary, nIndex ); 2310 2311 2312 //sal_Int32 curWordStart = aBoundary.startPos; 2313 //sal_Int32 preWordStart = curWordStart; 2314 sal_Int32 curWordStart , preWordStart; 2315 if( aBoundary.startPos == -1 || aBoundary.startPos > nIndex) 2316 curWordStart = preWordStart = nIndex; 2317 else 2318 curWordStart = preWordStart = aBoundary.startPos; 2319 2320 // get previous word 2321 2322 sal_Bool bWord = sal_False; 2323 2324 //while ( preWordStart > 0 && aBoundary.startPos == curWordStart) 2325 while ( (preWordStart >= 0 && !bWord ) || ( aBoundary.endPos > curWordStart ) ) 2326 { 2327 preWordStart--; 2328 bWord = implGetWordBoundary( aBoundary, preWordStart ); 2329 } 2330 if ( bWord && implIsValidBoundary( aBoundary, nLength ) ) 2331 { 2332 aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos ); 2333 aResult.SegmentStart = aBoundary.startPos; 2334 aResult.SegmentEnd = aBoundary.endPos; 2335 ExtendByField( aResult ); 2336 } 2337 } 2338 break; 2339 case AccessibleTextType::CHARACTER: 2340 { 2341 nIndex = SkipField( nIndex, sal_False); 2342 aResult = OCommonAccessibleText::getTextBeforeIndex( nIndex, aTextType ); 2343 ExtendByField( aResult ); 2344 break; 2345 } 2346 //-----IAccessibility2 Implementation 2009 2347 default: 2348 aResult = OCommonAccessibleText::getTextBeforeIndex( nIndex, aTextType ); 2349 break; 2350 } /* end of switch( aTextType ) */ 2351 2352 return aResult; 2353 } 2354 2355 ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) 2356 { 2357 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2358 2359 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2360 2361 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2362 "AccessibleEditableTextPara::getTextBehindIndex: paragraph index value overflow"); 2363 2364 ::com::sun::star::accessibility::TextSegment aResult; 2365 aResult.SegmentStart = -1; 2366 aResult.SegmentEnd = -1; 2367 //IAccessibility2 Implementation 2009----- 2368 i18n::Boundary aBoundary; 2369 //-----IAccessibility2 Implementation 2009 2370 switch( aTextType ) 2371 { 2372 case AccessibleTextType::ATTRIBUTE_RUN: 2373 { 2374 sal_uInt16 nStartIndex, nEndIndex; 2375 2376 if( GetAttributeRun(nStartIndex, nEndIndex, nIndex) ) 2377 { 2378 // already at the right border? 2379 if( nEndIndex < GetTextLen() ) 2380 { 2381 if( GetAttributeRun(nStartIndex, nEndIndex, nEndIndex) ) 2382 { 2383 aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex); 2384 aResult.SegmentStart = nStartIndex; 2385 aResult.SegmentEnd = nEndIndex; 2386 } 2387 } 2388 } 2389 break; 2390 } 2391 2392 //IAccessibility2 Implementation 2009----- 2393 case AccessibleTextType::LINE: 2394 { 2395 SvxTextForwarder& rCacheTF = GetTextForwarder(); 2396 sal_Int32 nParaIndex = GetParagraphIndex(); 2397 // MT IA2 not needed? sal_Int32 nTextLen = rCacheTF.GetTextLen( static_cast< sal_uInt16 >( nParaIndex ) ); 2398 2399 CheckPosition(nIndex); 2400 2401 sal_uInt16 nLine, nLineCount=rCacheTF.GetLineCount( static_cast< sal_uInt16 >( nParaIndex ) ); 2402 sal_Int32 nCurIndex; 2403 //the problem is that rCacheTF.GetLineLen() will include the bullet length. But for the bullet line, 2404 //the text value doesn't contain the bullet characters. all of the bullet and numbering info are exposed 2405 //by the IAText::attributes(). So here must do special support for bullet line. 2406 sal_Int32 nBulletLen = 0; 2407 // get the line after the line the index points into 2408 for( nLine=0, nCurIndex=0; nLine<nLineCount; ++nLine ) 2409 { 2410 if (nLine == 0) 2411 { 2412 EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 >(nParaIndex) ); 2413 if (aBulletInfo.bVisible) 2414 { 2415 //in bullet or numbering; 2416 nBulletLen = aBulletInfo.aText.Len(); 2417 } 2418 } 2419 //nCurIndex += rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine); 2420 sal_Int32 nLineLen = rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ), nLine); 2421 2422 if (nLine == 0) 2423 nCurIndex += nLineLen - nBulletLen; 2424 else 2425 nCurIndex += nLineLen; 2426 2427 if( nCurIndex > nIndex && 2428 nLine < nLineCount-1 ) 2429 { 2430 aResult.SegmentStart = nCurIndex; 2431 aResult.SegmentEnd = nCurIndex + rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine+1); 2432 aResult.SegmentText = GetTextRange( aResult.SegmentStart + nBulletLen, aResult.SegmentEnd + nBulletLen); 2433 break; 2434 } 2435 } 2436 2437 break; 2438 } 2439 case AccessibleTextType::WORD: 2440 { 2441 nIndex = SkipField( nIndex, sal_True); 2442 ::rtl::OUString sText( implGetText() ); 2443 sal_Int32 nLength = sText.getLength(); 2444 2445 // get word at index 2446 sal_Bool bWord = implGetWordBoundary( aBoundary, nIndex ); 2447 2448 // real current world 2449 sal_Int32 nextWord = nIndex; 2450 //if( nIndex >= aBoundary.startPos && nIndex <= aBoundary.endPos ) 2451 if( nIndex <= aBoundary.endPos ) 2452 { 2453 nextWord = aBoundary.endPos; 2454 if( sText.getStr()[nextWord] == sal_Unicode(' ') ) nextWord++; 2455 bWord = implGetWordBoundary( aBoundary, nextWord ); 2456 } 2457 2458 if ( bWord && implIsValidBoundary( aBoundary, nLength ) ) 2459 { 2460 aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos ); 2461 aResult.SegmentStart = aBoundary.startPos; 2462 aResult.SegmentEnd = aBoundary.endPos; 2463 2464 // If the end position of aBoundary is inside a field, extend the result to the end of the field 2465 2466 ExtendByField( aResult ); 2467 } 2468 } 2469 break; 2470 2471 case AccessibleTextType::CHARACTER: 2472 { 2473 nIndex = SkipField( nIndex, sal_True); 2474 aResult = OCommonAccessibleText::getTextBehindIndex( nIndex, aTextType ); 2475 ExtendByField( aResult ); 2476 break; 2477 } 2478 //-----IAccessibility2 Implementation 2009 2479 default: 2480 aResult = OCommonAccessibleText::getTextBehindIndex( nIndex, aTextType ); 2481 break; 2482 } /* end of switch( aTextType ) */ 2483 2484 return aResult; 2485 } 2486 2487 sal_Bool SAL_CALL AccessibleEditableTextPara::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 2488 { 2489 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2490 2491 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2492 2493 try 2494 { 2495 SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_True ); 2496 #if OSL_DEBUG_LEVEL > 0 2497 SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs 2498 (void)rCacheTF; 2499 #else 2500 GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs 2501 #endif 2502 2503 sal_Bool aRetVal; 2504 2505 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2506 "AccessibleEditableTextPara::copyText: index value overflow"); 2507 2508 CheckRange(nStartIndex, nEndIndex); 2509 2510 //Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet 2511 sal_Int32 nBulletLen = 0; 2512 EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 2513 if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible ) 2514 nBulletLen = aBulletInfo.aText.Len(); 2515 // save current selection 2516 ESelection aOldSelection; 2517 2518 rCacheVF.GetSelection( aOldSelection ); 2519 //rCacheVF.SetSelection( MakeSelection(nStartIndex, nEndIndex) ); 2520 rCacheVF.SetSelection( MakeSelection(nStartIndex + nBulletLen, nEndIndex + nBulletLen) ); 2521 aRetVal = rCacheVF.Copy(); 2522 rCacheVF.SetSelection( aOldSelection ); // restore 2523 2524 return aRetVal; 2525 } 2526 catch( const uno::RuntimeException& ) 2527 { 2528 return sal_False; 2529 } 2530 } 2531 2532 // XAccessibleEditableText 2533 sal_Bool SAL_CALL AccessibleEditableTextPara::cutText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 2534 { 2535 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2536 2537 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2538 2539 try 2540 { 2541 SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_True ); 2542 SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs 2543 2544 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2545 "AccessibleEditableTextPara::cutText: index value overflow"); 2546 2547 CheckRange(nStartIndex, nEndIndex); 2548 2549 // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet 2550 sal_Int32 nBulletLen = 0; 2551 EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 2552 if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible ) 2553 nBulletLen = aBulletInfo.aText.Len(); 2554 ESelection aSelection = MakeSelection (nStartIndex + nBulletLen, nEndIndex + nBulletLen); 2555 //if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) ) 2556 if( !rCacheTF.IsEditable( aSelection ) ) 2557 return sal_False; // non-editable area selected 2558 2559 // don't save selection, might become invalid after cut! 2560 //rCacheVF.SetSelection( MakeSelection(nStartIndex, nEndIndex) ); 2561 rCacheVF.SetSelection( aSelection ); 2562 2563 return rCacheVF.Cut(); 2564 } 2565 catch( const uno::RuntimeException& ) 2566 { 2567 return sal_False; 2568 } 2569 } 2570 2571 sal_Bool SAL_CALL AccessibleEditableTextPara::pasteText( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 2572 { 2573 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2574 2575 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2576 2577 try 2578 { 2579 SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_True ); 2580 SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs 2581 2582 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2583 "AccessibleEditableTextPara::pasteText: index value overflow"); 2584 2585 CheckPosition(nIndex); 2586 2587 // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet 2588 sal_Int32 nBulletLen = 0; 2589 EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 2590 if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible ) 2591 nBulletLen = aBulletInfo.aText.Len(); 2592 //if( !rCacheTF.IsEditable( MakeSelection(nIndex) ) ) 2593 if( !rCacheTF.IsEditable( MakeSelection(nIndex + nBulletLen) ) ) 2594 return sal_False; // non-editable area selected 2595 2596 // #104400# set empty selection (=> cursor) to given index 2597 //rCacheVF.SetSelection( MakeCursor(nIndex) ); 2598 rCacheVF.SetSelection( MakeCursor(nIndex + nBulletLen) ); 2599 2600 return rCacheVF.Paste(); 2601 } 2602 catch( const uno::RuntimeException& ) 2603 { 2604 return sal_False; 2605 } 2606 } 2607 2608 sal_Bool SAL_CALL AccessibleEditableTextPara::deleteText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 2609 { 2610 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2611 2612 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2613 2614 try 2615 { 2616 // #102710# Request edit view when doing changes 2617 // AccessibleEmptyEditSource relies on this behaviour 2618 GetEditViewForwarder( sal_True ); 2619 SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs 2620 2621 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2622 "AccessibleEditableTextPara::deleteText: index value overflow"); 2623 2624 CheckRange(nStartIndex, nEndIndex); 2625 2626 // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet 2627 sal_Int32 nBulletLen = 0; 2628 EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 2629 if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible ) 2630 nBulletLen = aBulletInfo.aText.Len(); 2631 ESelection aSelection = MakeSelection (nStartIndex + nBulletLen, nEndIndex + nBulletLen); 2632 2633 //if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) ) 2634 if( !rCacheTF.IsEditable( aSelection ) ) 2635 return sal_False; // non-editable area selected 2636 2637 //sal_Bool bRet = rCacheTF.Delete( MakeSelection(nStartIndex, nEndIndex) ); 2638 sal_Bool bRet = rCacheTF.Delete( aSelection ); 2639 2640 GetEditSource().UpdateData(); 2641 2642 return bRet; 2643 } 2644 catch( const uno::RuntimeException& ) 2645 { 2646 return sal_False; 2647 } 2648 } 2649 2650 sal_Bool SAL_CALL AccessibleEditableTextPara::insertText( const ::rtl::OUString& sText, sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 2651 { 2652 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2653 2654 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2655 2656 try 2657 { 2658 // #102710# Request edit view when doing changes 2659 // AccessibleEmptyEditSource relies on this behaviour 2660 GetEditViewForwarder( sal_True ); 2661 SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs 2662 2663 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2664 "AccessibleEditableTextPara::insertText: index value overflow"); 2665 2666 CheckPosition(nIndex); 2667 2668 // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet 2669 sal_Int32 nBulletLen = 0; 2670 EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 2671 if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible ) 2672 nBulletLen = aBulletInfo.aText.Len(); 2673 2674 //if( !rCacheTF.IsEditable( MakeSelection(nIndex) ) ) 2675 if( !rCacheTF.IsEditable( MakeSelection(nIndex + nBulletLen) ) ) 2676 return sal_False; // non-editable area selected 2677 2678 // #104400# insert given text at empty selection (=> cursor) 2679 //sal_Bool bRet = rCacheTF.InsertText( sText, MakeCursor(nIndex) ); 2680 sal_Bool bRet = rCacheTF.InsertText( sText, MakeCursor(nIndex + nBulletLen) ); 2681 2682 rCacheTF.QuickFormatDoc(); 2683 GetEditSource().UpdateData(); 2684 2685 return bRet; 2686 } 2687 catch( const uno::RuntimeException& ) 2688 { 2689 return sal_False; 2690 } 2691 } 2692 2693 sal_Bool SAL_CALL AccessibleEditableTextPara::replaceText( sal_Int32 nStartIndex, sal_Int32 nEndIndex, const ::rtl::OUString& sReplacement ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 2694 { 2695 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2696 2697 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2698 2699 try 2700 { 2701 // #102710# Request edit view when doing changes 2702 // AccessibleEmptyEditSource relies on this behaviour 2703 GetEditViewForwarder( sal_True ); 2704 SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs 2705 2706 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2707 "AccessibleEditableTextPara::replaceText: index value overflow"); 2708 2709 CheckRange(nStartIndex, nEndIndex); 2710 2711 // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet 2712 sal_Int32 nBulletLen = 0; 2713 EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 2714 if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible ) 2715 nBulletLen = aBulletInfo.aText.Len(); 2716 ESelection aSelection = MakeSelection (nStartIndex + nBulletLen, nEndIndex + nBulletLen); 2717 2718 //if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) ) 2719 if( !rCacheTF.IsEditable( aSelection ) ) 2720 return sal_False; // non-editable area selected 2721 2722 // insert given text into given range => replace 2723 //sal_Bool bRet = rCacheTF.InsertText( sReplacement, MakeSelection(nStartIndex, nEndIndex) ); 2724 sal_Bool bRet = rCacheTF.InsertText( sReplacement, aSelection ); 2725 2726 rCacheTF.QuickFormatDoc(); 2727 GetEditSource().UpdateData(); 2728 2729 return bRet; 2730 } 2731 catch( const uno::RuntimeException& ) 2732 { 2733 return sal_False; 2734 } 2735 } 2736 2737 sal_Bool SAL_CALL AccessibleEditableTextPara::setAttributes( sal_Int32 nStartIndex, sal_Int32 nEndIndex, const uno::Sequence< beans::PropertyValue >& aAttributeSet ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 2738 { 2739 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2740 2741 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2742 2743 try 2744 { 2745 // #102710# Request edit view when doing changes 2746 // AccessibleEmptyEditSource relies on this behaviour 2747 GetEditViewForwarder( sal_True ); 2748 SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs 2749 sal_uInt16 nPara = static_cast< sal_uInt16 >( GetParagraphIndex() ); 2750 2751 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2752 "AccessibleEditableTextPara::setAttributes: index value overflow"); 2753 2754 CheckRange(nStartIndex, nEndIndex); 2755 2756 if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) ) 2757 return sal_False; // non-editable area selected 2758 2759 // do the indices span the whole paragraph? Then use the outliner map 2760 // TODO: hold it as a member? 2761 SvxAccessibleTextPropertySet aPropSet( &GetEditSource(), 2762 0 == nStartIndex && 2763 rCacheTF.GetTextLen(nPara) == nEndIndex ? 2764 ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() : 2765 ImplGetSvxTextPortionSvxPropertySet() ); 2766 2767 aPropSet.SetSelection( MakeSelection(nStartIndex, nEndIndex) ); 2768 2769 // convert from PropertyValue to Any 2770 sal_Int32 i, nLength( aAttributeSet.getLength() ); 2771 const beans::PropertyValue* pPropArray = aAttributeSet.getConstArray(); 2772 for(i=0; i<nLength; ++i) 2773 { 2774 try 2775 { 2776 aPropSet.setPropertyValue(pPropArray->Name, pPropArray->Value); 2777 } 2778 catch( const uno::Exception& ) 2779 { 2780 DBG_ERROR("AccessibleEditableTextPara::setAttributes exception in setPropertyValue"); 2781 } 2782 2783 ++pPropArray; 2784 } 2785 2786 rCacheTF.QuickFormatDoc(); 2787 GetEditSource().UpdateData(); 2788 2789 return sal_True; 2790 } 2791 catch( const uno::RuntimeException& ) 2792 { 2793 return sal_False; 2794 } 2795 } 2796 2797 sal_Bool SAL_CALL AccessibleEditableTextPara::setText( const ::rtl::OUString& sText ) throw (uno::RuntimeException) 2798 { 2799 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2800 2801 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2802 2803 return replaceText(0, getCharacterCount(), sText); 2804 } 2805 2806 // XAccessibleTextAttributes 2807 uno::Sequence< beans::PropertyValue > SAL_CALL AccessibleEditableTextPara::getDefaultAttributes( 2808 const uno::Sequence< ::rtl::OUString >& rRequestedAttributes ) 2809 throw (uno::RuntimeException) 2810 { 2811 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2812 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2813 2814 #if OSL_DEBUG_LEVEL > 0 2815 SvxAccessibleTextAdapter& rCacheTF = 2816 #endif 2817 GetTextForwarder(); 2818 2819 #if OSL_DEBUG_LEVEL > 0 2820 (void)rCacheTF; 2821 #endif 2822 2823 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2824 "AccessibleEditableTextPara::getCharacterAttributes: index value overflow"); 2825 2826 // get XPropertySetInfo for paragraph attributes and 2827 // character attributes that span all the paragraphs text. 2828 SvxAccessibleTextPropertySet aPropSet( &GetEditSource(), 2829 ImplGetSvxCharAndParaPropertiesSet() ); 2830 aPropSet.SetSelection( MakeSelection( 0, GetTextLen() ) ); 2831 uno::Reference< beans::XPropertySetInfo > xPropSetInfo = aPropSet.getPropertySetInfo(); 2832 if (!xPropSetInfo.is()) 2833 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Cannot query XPropertySetInfo")), 2834 uno::Reference< uno::XInterface > 2835 ( static_cast< XAccessible* > (this) ) ); // disambiguate hierarchy 2836 2837 // build sequence of available properties to check 2838 sal_Int32 nLenReqAttr = rRequestedAttributes.getLength(); 2839 uno::Sequence< beans::Property > aProperties; 2840 if (nLenReqAttr) 2841 { 2842 const rtl::OUString *pRequestedAttributes = rRequestedAttributes.getConstArray(); 2843 2844 aProperties.realloc( nLenReqAttr ); 2845 beans::Property *pProperties = aProperties.getArray(); 2846 sal_Int32 nCurLen = 0; 2847 for (sal_Int32 i = 0; i < nLenReqAttr; ++i) 2848 { 2849 beans::Property aProp; 2850 try 2851 { 2852 aProp = xPropSetInfo->getPropertyByName( pRequestedAttributes[i] ); 2853 } 2854 catch (beans::UnknownPropertyException &) 2855 { 2856 continue; 2857 } 2858 pProperties[ nCurLen++ ] = aProp; 2859 } 2860 aProperties.realloc( nCurLen ); 2861 } 2862 else 2863 aProperties = xPropSetInfo->getProperties(); 2864 2865 sal_Int32 nLength = aProperties.getLength(); 2866 const beans::Property *pProperties = aProperties.getConstArray(); 2867 2868 // build resulting sequence 2869 uno::Sequence< beans::PropertyValue > aOutSequence( nLength ); 2870 beans::PropertyValue* pOutSequence = aOutSequence.getArray(); 2871 sal_Int32 nOutLen = 0; 2872 for (sal_Int32 i = 0; i < nLength; ++i) 2873 { 2874 // calling implementation functions: 2875 // _getPropertyState and _getPropertyValue (see below) to provide 2876 // the proper paragraph number when retrieving paragraph attributes 2877 PropertyState eState = aPropSet._getPropertyState( pProperties->Name, mnParagraphIndex ); 2878 if ( eState == PropertyState_AMBIGUOUS_VALUE ) 2879 { 2880 OSL_ENSURE( false, "ambiguous property value encountered" ); 2881 } 2882 2883 //if (eState == PropertyState_DIRECT_VALUE) 2884 // per definition all paragraph properties and all character 2885 // properties spanning the whole paragraph should be returned 2886 // and declared as default value 2887 { 2888 pOutSequence->Name = pProperties->Name; 2889 pOutSequence->Handle = pProperties->Handle; 2890 pOutSequence->Value = aPropSet._getPropertyValue( pProperties->Name, mnParagraphIndex ); 2891 pOutSequence->State = PropertyState_DEFAULT_VALUE; 2892 2893 ++pOutSequence; 2894 ++nOutLen; 2895 } 2896 ++pProperties; 2897 } 2898 aOutSequence.realloc( nOutLen ); 2899 2900 return aOutSequence; 2901 } 2902 2903 2904 uno::Sequence< beans::PropertyValue > SAL_CALL AccessibleEditableTextPara::getRunAttributes( 2905 sal_Int32 nIndex, 2906 const uno::Sequence< ::rtl::OUString >& rRequestedAttributes ) 2907 throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 2908 { 2909 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2910 2911 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2912 2913 #if OSL_DEBUG_LEVEL > 0 2914 SvxAccessibleTextAdapter& rCacheTF = 2915 #endif 2916 GetTextForwarder(); 2917 2918 #if OSL_DEBUG_LEVEL > 0 2919 (void)rCacheTF; 2920 #endif 2921 2922 DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2923 "AccessibleEditableTextPara::getCharacterAttributes: index value overflow"); 2924 2925 if( getCharacterCount() > 0 ) 2926 CheckIndex(nIndex); 2927 else 2928 CheckPosition(nIndex); 2929 2930 SvxAccessibleTextPropertySet aPropSet( &GetEditSource(), 2931 ImplGetSvxCharAndParaPropertiesSet() ); 2932 aPropSet.SetSelection( MakeSelection( nIndex ) ); 2933 uno::Reference< beans::XPropertySetInfo > xPropSetInfo = aPropSet.getPropertySetInfo(); 2934 if (!xPropSetInfo.is()) 2935 throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Cannot query XPropertySetInfo")), 2936 uno::Reference< uno::XInterface > 2937 ( static_cast< XAccessible* > (this) ) ); // disambiguate hierarchy 2938 2939 // build sequence of available properties to check 2940 sal_Int32 nLenReqAttr = rRequestedAttributes.getLength(); 2941 uno::Sequence< beans::Property > aProperties; 2942 if (nLenReqAttr) 2943 { 2944 const rtl::OUString *pRequestedAttributes = rRequestedAttributes.getConstArray(); 2945 2946 aProperties.realloc( nLenReqAttr ); 2947 beans::Property *pProperties = aProperties.getArray(); 2948 sal_Int32 nCurLen = 0; 2949 for (sal_Int32 i = 0; i < nLenReqAttr; ++i) 2950 { 2951 beans::Property aProp; 2952 try 2953 { 2954 aProp = xPropSetInfo->getPropertyByName( pRequestedAttributes[i] ); 2955 } 2956 catch (beans::UnknownPropertyException &) 2957 { 2958 continue; 2959 } 2960 pProperties[ nCurLen++ ] = aProp; 2961 } 2962 aProperties.realloc( nCurLen ); 2963 } 2964 else 2965 aProperties = xPropSetInfo->getProperties(); 2966 2967 sal_Int32 nLength = aProperties.getLength(); 2968 const beans::Property *pProperties = aProperties.getConstArray(); 2969 2970 // build resulting sequence 2971 uno::Sequence< beans::PropertyValue > aOutSequence( nLength ); 2972 beans::PropertyValue* pOutSequence = aOutSequence.getArray(); 2973 sal_Int32 nOutLen = 0; 2974 for (sal_Int32 i = 0; i < nLength; ++i) 2975 { 2976 // calling 'regular' functions that will operate on the selection 2977 PropertyState eState = aPropSet.getPropertyState( pProperties->Name ); 2978 if (eState == PropertyState_DIRECT_VALUE) 2979 { 2980 pOutSequence->Name = pProperties->Name; 2981 pOutSequence->Handle = pProperties->Handle; 2982 pOutSequence->Value = aPropSet.getPropertyValue( pProperties->Name ); 2983 pOutSequence->State = eState; 2984 2985 ++pOutSequence; 2986 ++nOutLen; 2987 } 2988 ++pProperties; 2989 } 2990 aOutSequence.realloc( nOutLen ); 2991 2992 return aOutSequence; 2993 } 2994 2995 // XAccessibleHypertext 2996 ::sal_Int32 SAL_CALL AccessibleEditableTextPara::getHyperLinkCount( ) throw (::com::sun::star::uno::RuntimeException) 2997 { 2998 SvxAccessibleTextAdapter& rT = GetTextForwarder(); 2999 const sal_Int32 nPara = GetParagraphIndex(); 3000 3001 sal_uInt16 nHyperLinks = 0; 3002 sal_uInt16 nFields = rT.GetFieldCount( nPara ); 3003 for ( sal_uInt16 n = 0; n < nFields; n++ ) 3004 { 3005 EFieldInfo aField = rT.GetFieldInfo( nPara, n ); 3006 if ( aField.pFieldItem->GetField()->ISA( SvxURLField ) ) 3007 nHyperLinks++; 3008 } 3009 return nHyperLinks; 3010 } 3011 3012 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleHyperlink > SAL_CALL AccessibleEditableTextPara::getHyperLink( ::sal_Int32 nLinkIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) 3013 { 3014 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleHyperlink > xRef; 3015 3016 SvxAccessibleTextAdapter& rT = GetTextForwarder(); 3017 const sal_Int32 nPara = GetParagraphIndex(); 3018 3019 sal_uInt16 nHyperLink = 0; 3020 sal_uInt16 nFields = rT.GetFieldCount( nPara ); 3021 for ( sal_uInt16 n = 0; n < nFields; n++ ) 3022 { 3023 EFieldInfo aField = rT.GetFieldInfo( nPara, n ); 3024 if ( aField.pFieldItem->GetField()->ISA( SvxURLField ) ) 3025 { 3026 if ( nHyperLink == nLinkIndex ) 3027 { 3028 sal_uInt16 nEEStart = aField.aPosition.nIndex; 3029 3030 // Translate EE Index to accessible index 3031 sal_uInt16 nStart = rT.CalcEditEngineIndex( nPara, nEEStart ); 3032 sal_uInt16 nEnd = nStart + aField.aCurrentText.Len(); 3033 xRef = new AccessibleHyperlink( rT, new SvxFieldItem( *aField.pFieldItem ), nPara, nEEStart, nStart, nEnd, aField.aCurrentText ); 3034 break; 3035 } 3036 nHyperLink++; 3037 } 3038 } 3039 3040 return xRef; 3041 } 3042 3043 ::sal_Int32 SAL_CALL AccessibleEditableTextPara::getHyperLinkIndex( ::sal_Int32 nCharIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) 3044 { 3045 const sal_Int32 nPara = GetParagraphIndex(); 3046 SvxAccessibleTextAdapter& rT = GetTextForwarder(); 3047 3048 // SvxAccessibleTextIndex aIndex; 3049 // aIndex.SetIndex(nPara, nCharIndex, rT); 3050 // const sal_uInt16 nEEIndex = aIndex.GetEEIndex(); 3051 3052 const sal_uInt16 nEEIndex = rT.CalcEditEngineIndex( nPara, nCharIndex ); 3053 sal_Int32 nHLIndex = 0; 3054 sal_uInt16 nHyperLink = 0; 3055 sal_uInt16 nFields = rT.GetFieldCount( nPara ); 3056 for ( sal_uInt16 n = 0; n < nFields; n++ ) 3057 { 3058 EFieldInfo aField = rT.GetFieldInfo( nPara, n ); 3059 if ( aField.pFieldItem->GetField()->ISA( SvxURLField ) ) 3060 { 3061 if ( aField.aPosition.nIndex == nEEIndex ) 3062 { 3063 nHLIndex = nHyperLink; 3064 break; 3065 } 3066 nHyperLink++; 3067 } 3068 } 3069 3070 return nHLIndex; 3071 } 3072 3073 // XAccessibleMultiLineText 3074 sal_Int32 SAL_CALL AccessibleEditableTextPara::getLineNumberAtIndex( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 3075 { 3076 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 3077 3078 sal_Int32 nRes = -1; 3079 sal_Int32 nPara = GetParagraphIndex(); 3080 3081 SvxTextForwarder &rCacheTF = GetTextForwarder(); 3082 const bool bValidPara = 0 <= nPara && nPara < rCacheTF.GetParagraphCount(); 3083 DBG_ASSERT( bValidPara, "getLineNumberAtIndex: current paragraph index out of range" ); 3084 if (bValidPara) 3085 { 3086 // we explicitly allow for the index to point at the character right behind the text 3087 if (0 <= nIndex && nIndex <= rCacheTF.GetTextLen( static_cast< sal_uInt16 >(nPara) )) 3088 nRes = rCacheTF.GetLineNumberAtIndex( static_cast< sal_uInt16 >(nPara), static_cast< sal_uInt16 >(nIndex) ); 3089 else 3090 throw lang::IndexOutOfBoundsException(); 3091 } 3092 return nRes; 3093 } 3094 3095 // XAccessibleMultiLineText 3096 ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextAtLineNumber( sal_Int32 nLineNo ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 3097 { 3098 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 3099 3100 ::com::sun::star::accessibility::TextSegment aResult; 3101 sal_Int32 nPara = GetParagraphIndex(); 3102 SvxTextForwarder &rCacheTF = GetTextForwarder(); 3103 const bool bValidPara = 0 <= nPara && nPara < rCacheTF.GetParagraphCount(); 3104 DBG_ASSERT( bValidPara, "getTextAtLineNumber: current paragraph index out of range" ); 3105 if (bValidPara) 3106 { 3107 if (0 <= nLineNo && nLineNo < rCacheTF.GetLineCount( static_cast< sal_uInt16 >(nPara) )) 3108 { 3109 sal_uInt16 nStart = 0, nEnd = 0; 3110 rCacheTF.GetLineBoundaries( nStart, nEnd, static_cast< sal_uInt16 >(nPara), static_cast< sal_uInt16 >(nLineNo) ); 3111 if (nStart != 0xFFFF && nEnd != 0xFFFF) 3112 { 3113 try 3114 { 3115 aResult.SegmentText = getTextRange( nStart, nEnd ); 3116 aResult.SegmentStart = nStart; 3117 aResult.SegmentEnd = nEnd; 3118 } 3119 catch (lang::IndexOutOfBoundsException) 3120 { 3121 // this is not the exception that should be raised in this function ... 3122 DBG_ASSERT( 0, "unexpected exception" ); 3123 } 3124 } 3125 } 3126 else 3127 throw lang::IndexOutOfBoundsException(); 3128 } 3129 return aResult; 3130 } 3131 3132 // XAccessibleMultiLineText 3133 ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextAtLineWithCaret( ) throw (uno::RuntimeException) 3134 { 3135 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 3136 3137 ::com::sun::star::accessibility::TextSegment aResult; 3138 try 3139 { 3140 aResult = getTextAtLineNumber( getNumberOfLineWithCaret() ); 3141 } 3142 catch (lang::IndexOutOfBoundsException &) 3143 { 3144 // this one needs to be catched since this interface does not allow for it. 3145 } 3146 return aResult; 3147 } 3148 3149 // XAccessibleMultiLineText 3150 sal_Int32 SAL_CALL AccessibleEditableTextPara::getNumberOfLineWithCaret( ) throw (uno::RuntimeException) 3151 { 3152 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 3153 3154 sal_Int32 nRes = -1; 3155 try 3156 { 3157 nRes = getLineNumberAtIndex( getCaretPosition() ); 3158 } 3159 catch (lang::IndexOutOfBoundsException &) 3160 { 3161 // this one needs to be catched since this interface does not allow for it. 3162 } 3163 return nRes; 3164 } 3165 3166 3167 // XServiceInfo 3168 ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getImplementationName (void) throw (uno::RuntimeException) 3169 { 3170 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 3171 3172 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("AccessibleEditableTextPara")); 3173 } 3174 3175 sal_Bool SAL_CALL AccessibleEditableTextPara::supportsService (const ::rtl::OUString& sServiceName) throw (uno::RuntimeException) 3176 { 3177 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 3178 3179 // Iterate over all supported service names and return true if on of them 3180 // matches the given name. 3181 uno::Sequence< ::rtl::OUString> aSupportedServices ( 3182 getSupportedServiceNames ()); 3183 for (int i=0; i<aSupportedServices.getLength(); i++) 3184 if (sServiceName == aSupportedServices[i]) 3185 return sal_True; 3186 return sal_False; 3187 } 3188 3189 uno::Sequence< ::rtl::OUString> SAL_CALL AccessibleEditableTextPara::getSupportedServiceNames (void) throw (uno::RuntimeException) 3190 { 3191 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 3192 3193 const ::rtl::OUString sServiceName( getServiceName() ); 3194 return uno::Sequence< ::rtl::OUString > (&sServiceName, 1); 3195 } 3196 3197 // XServiceName 3198 ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getServiceName (void) throw (uno::RuntimeException) 3199 { 3200 DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 3201 3202 // #105185# Using correct service now 3203 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.AccessibleParagraphView")); 3204 } 3205 3206 } // end of namespace accessibility 3207 3208 //------------------------------------------------------------------------ 3209