1190118d0SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3190118d0SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4190118d0SAndrew Rist * or more contributor license agreements. See the NOTICE file 5190118d0SAndrew Rist * distributed with this work for additional information 6190118d0SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7190118d0SAndrew Rist * to you under the Apache License, Version 2.0 (the 8190118d0SAndrew Rist * "License"); you may not use this file except in compliance 9190118d0SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11190118d0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13190118d0SAndrew Rist * Unless required by applicable law or agreed to in writing, 14190118d0SAndrew Rist * software distributed under the License is distributed on an 15190118d0SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16190118d0SAndrew Rist * KIND, either express or implied. See the License for the 17190118d0SAndrew Rist * specific language governing permissions and limitations 18190118d0SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20190118d0SAndrew Rist *************************************************************/ 21190118d0SAndrew Rist 22190118d0SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_editeng.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir //------------------------------------------------------------------------ 28cdf0e10cSrcweir // 29cdf0e10cSrcweir // Global header 30cdf0e10cSrcweir // 31cdf0e10cSrcweir //------------------------------------------------------------------------ 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <limits.h> 34cdf0e10cSrcweir #include <vector> 35cdf0e10cSrcweir #include <algorithm> 36cdf0e10cSrcweir #include <vos/mutex.hxx> 37cdf0e10cSrcweir #include <vcl/window.hxx> 38cdf0e10cSrcweir #include <vcl/svapp.hxx> 39cdf0e10cSrcweir #include <editeng/flditem.hxx> 40cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx> 41cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx> 42cdf0e10cSrcweir #include <com/sun/star/awt/Point.hpp> 43cdf0e10cSrcweir #include <com/sun/star/awt/Rectangle.hpp> 44cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 45cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp> 46cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleTextType.hpp> 47cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 48cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp> 49cdf0e10cSrcweir #include <comphelper/accessibleeventnotifier.hxx> 50cdf0e10cSrcweir #include <comphelper/sequenceashashmap.hxx> 51cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx> 52cdf0e10cSrcweir #include <unotools/accessiblerelationsethelper.hxx> 53cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRelationType.hpp> 54cdf0e10cSrcweir #include <vcl/unohelp.hxx> 55cdf0e10cSrcweir #include <editeng/editeng.hxx> 56cdf0e10cSrcweir #include <editeng/unoprnms.hxx> 57cdf0e10cSrcweir #include <editeng/unoipset.hxx> 58cdf0e10cSrcweir #include <editeng/outliner.hxx> 599b8096d0SSteve Yin #include <svl/intitem.hxx> 60cdf0e10cSrcweir 61cdf0e10cSrcweir //------------------------------------------------------------------------ 62cdf0e10cSrcweir // 63cdf0e10cSrcweir // Project-local header 64cdf0e10cSrcweir // 65cdf0e10cSrcweir //------------------------------------------------------------------------ 66cdf0e10cSrcweir 67cdf0e10cSrcweir #include <com/sun/star/beans/PropertyState.hpp> 68cdf0e10cSrcweir 69cdf0e10cSrcweir //!!!#include <svx/unoshape.hxx> 70cdf0e10cSrcweir //!!!#include <svx/dialmgr.hxx> 71cdf0e10cSrcweir //!!!#include "accessibility.hrc" 72cdf0e10cSrcweir 73cdf0e10cSrcweir #include <editeng/unolingu.hxx> 74cdf0e10cSrcweir #include <editeng/unopracc.hxx> 75cdf0e10cSrcweir #include "editeng/AccessibleEditableTextPara.hxx" 76cdf0e10cSrcweir #include "AccessibleHyperlink.hxx" 77cdf0e10cSrcweir 78cdf0e10cSrcweir #include <svtools/colorcfg.hxx> 799b8096d0SSteve Yin //IAccessibility2 Implementation 2009----- 809b8096d0SSteve Yin #include <algorithm> 819b8096d0SSteve Yin using namespace std; 82*0deba7fbSSteve Yin #include "editeng.hrc" 83*0deba7fbSSteve Yin #include <editeng/eerdll.hxx> 849b8096d0SSteve Yin #include <editeng/numitem.hxx> 85*0deba7fbSSteve Yin #include <sfx2/viewfrm.hxx> 86*0deba7fbSSteve Yin #include <sfx2/viewsh.hxx> 87*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 88cdf0e10cSrcweir 89cdf0e10cSrcweir using namespace ::com::sun::star; 90cdf0e10cSrcweir using namespace ::com::sun::star::beans; 91cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 92cdf0e10cSrcweir 93cdf0e10cSrcweir 94cdf0e10cSrcweir //------------------------------------------------------------------------ 95cdf0e10cSrcweir // 96cdf0e10cSrcweir // AccessibleEditableTextPara implementation 97cdf0e10cSrcweir // 98cdf0e10cSrcweir //------------------------------------------------------------------------ 99cdf0e10cSrcweir 100cdf0e10cSrcweir namespace accessibility 101cdf0e10cSrcweir { 1029b8096d0SSteve Yin //IAccessibility2 Implementation 2009----- 103cdf0e10cSrcweir 104cdf0e10cSrcweir const SvxItemPropertySet* ImplGetSvxCharAndParaPropertiesSet() 105cdf0e10cSrcweir { 106cdf0e10cSrcweir // PropertyMap for character and paragraph properties 107cdf0e10cSrcweir static const SfxItemPropertyMapEntry aPropMap[] = 108cdf0e10cSrcweir { 1099b8096d0SSteve Yin SVX_UNOEDIT_OUTLINER_PROPERTIES, 110cdf0e10cSrcweir SVX_UNOEDIT_CHAR_PROPERTIES, 111cdf0e10cSrcweir SVX_UNOEDIT_PARA_PROPERTIES, 112cdf0e10cSrcweir SVX_UNOEDIT_NUMBERING_PROPERTIE, 113cdf0e10cSrcweir {MAP_CHAR_LEN("TextUserDefinedAttributes"), EE_CHAR_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, 114cdf0e10cSrcweir {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, 115cdf0e10cSrcweir {0,0,0,0,0,0} 116cdf0e10cSrcweir }; 117cdf0e10cSrcweir static SvxItemPropertySet aPropSet( aPropMap, EditEngine::GetGlobalItemPool() ); 118cdf0e10cSrcweir return &aPropSet; 119cdf0e10cSrcweir } 120cdf0e10cSrcweir 121cdf0e10cSrcweir 122cdf0e10cSrcweir DBG_NAME( AccessibleEditableTextPara ) 123cdf0e10cSrcweir 124cdf0e10cSrcweir // --> OD 2006-01-11 #i27138# - add parameter <_pParaManager> 125cdf0e10cSrcweir AccessibleEditableTextPara::AccessibleEditableTextPara( 126cdf0e10cSrcweir const uno::Reference< XAccessible >& rParent, 127cdf0e10cSrcweir const AccessibleParaManager* _pParaManager ) 128cdf0e10cSrcweir : AccessibleTextParaInterfaceBase( m_aMutex ), 129cdf0e10cSrcweir mnParagraphIndex( 0 ), 130cdf0e10cSrcweir mnIndexInParent( 0 ), 131cdf0e10cSrcweir mpEditSource( NULL ), 132cdf0e10cSrcweir maEEOffset( 0, 0 ), 133cdf0e10cSrcweir mxParent( rParent ), 134cdf0e10cSrcweir // well, that's strictly (UNO) exception safe, though not 135cdf0e10cSrcweir // really robust. We rely on the fact that this member is 136cdf0e10cSrcweir // constructed last, and that the constructor body catches 137cdf0e10cSrcweir // exceptions, thus no chance for exceptions once the Id is 138cdf0e10cSrcweir // fetched. Nevertheless, normally should employ RAII here... 139cdf0e10cSrcweir mnNotifierClientId(::comphelper::AccessibleEventNotifier::registerClient()), 140cdf0e10cSrcweir // --> OD 2006-01-11 #i27138# 141cdf0e10cSrcweir mpParaManager( _pParaManager ) 142cdf0e10cSrcweir // <-- 143cdf0e10cSrcweir { 144cdf0e10cSrcweir #ifdef DBG_UTIL 145cdf0e10cSrcweir DBG_CTOR( AccessibleEditableTextPara, NULL ); 146cdf0e10cSrcweir OSL_TRACE( "AccessibleEditableTextPara received ID: %d\n", mnNotifierClientId ); 147cdf0e10cSrcweir #endif 148cdf0e10cSrcweir 149cdf0e10cSrcweir try 150cdf0e10cSrcweir { 151cdf0e10cSrcweir // Create the state set. 152cdf0e10cSrcweir ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper (); 153cdf0e10cSrcweir mxStateSet = pStateSet; 154cdf0e10cSrcweir 155cdf0e10cSrcweir // these are always on 156cdf0e10cSrcweir pStateSet->AddState( AccessibleStateType::MULTI_LINE ); 157cdf0e10cSrcweir pStateSet->AddState( AccessibleStateType::FOCUSABLE ); 158cdf0e10cSrcweir pStateSet->AddState( AccessibleStateType::VISIBLE ); 159cdf0e10cSrcweir pStateSet->AddState( AccessibleStateType::SHOWING ); 160cdf0e10cSrcweir pStateSet->AddState( AccessibleStateType::ENABLED ); 161cdf0e10cSrcweir pStateSet->AddState( AccessibleStateType::SENSITIVE ); 162cdf0e10cSrcweir } 163cdf0e10cSrcweir catch( const uno::Exception& ) {} 164cdf0e10cSrcweir } 165cdf0e10cSrcweir 166cdf0e10cSrcweir AccessibleEditableTextPara::~AccessibleEditableTextPara() 167cdf0e10cSrcweir { 168cdf0e10cSrcweir DBG_DTOR( AccessibleEditableTextPara, NULL ); 169cdf0e10cSrcweir 170cdf0e10cSrcweir // sign off from event notifier 171cdf0e10cSrcweir if( getNotifierClientId() != -1 ) 172cdf0e10cSrcweir { 173cdf0e10cSrcweir try 174cdf0e10cSrcweir { 175cdf0e10cSrcweir ::comphelper::AccessibleEventNotifier::revokeClient( getNotifierClientId() ); 176cdf0e10cSrcweir #ifdef DBG_UTIL 177cdf0e10cSrcweir OSL_TRACE( "AccessibleEditableTextPara revoked ID: %d\n", mnNotifierClientId ); 178cdf0e10cSrcweir #endif 179cdf0e10cSrcweir } 180cdf0e10cSrcweir catch( const uno::Exception& ) {} 181cdf0e10cSrcweir } 182cdf0e10cSrcweir } 183cdf0e10cSrcweir 184cdf0e10cSrcweir ::rtl::OUString AccessibleEditableTextPara::implGetText() 185cdf0e10cSrcweir { 186cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 187cdf0e10cSrcweir 188cdf0e10cSrcweir return GetTextRange( 0, GetTextLen() ); 189cdf0e10cSrcweir } 190cdf0e10cSrcweir 191cdf0e10cSrcweir ::com::sun::star::lang::Locale AccessibleEditableTextPara::implGetLocale() 192cdf0e10cSrcweir { 193cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 194cdf0e10cSrcweir 195cdf0e10cSrcweir lang::Locale aLocale; 196cdf0e10cSrcweir 197cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 198cdf0e10cSrcweir "AccessibleEditableTextPara::getLocale: paragraph index value overflow"); 199cdf0e10cSrcweir 200cdf0e10cSrcweir // return locale of first character in the paragraph 201cdf0e10cSrcweir return SvxLanguageToLocale(aLocale, GetTextForwarder().GetLanguage( static_cast< sal_uInt16 >( GetParagraphIndex() ), 0 )); 202cdf0e10cSrcweir } 203cdf0e10cSrcweir 204cdf0e10cSrcweir void AccessibleEditableTextPara::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ) 205cdf0e10cSrcweir { 206cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 207cdf0e10cSrcweir 208cdf0e10cSrcweir sal_uInt16 nStart, nEnd; 209cdf0e10cSrcweir 210cdf0e10cSrcweir if( GetSelection( nStart, nEnd ) ) 211cdf0e10cSrcweir { 212cdf0e10cSrcweir nStartIndex = nStart; 213cdf0e10cSrcweir nEndIndex = nEnd; 214cdf0e10cSrcweir } 215cdf0e10cSrcweir else 216cdf0e10cSrcweir { 217cdf0e10cSrcweir // #102234# No exception, just set to 'invalid' 218cdf0e10cSrcweir nStartIndex = -1; 219cdf0e10cSrcweir nEndIndex = -1; 220cdf0e10cSrcweir } 221cdf0e10cSrcweir } 222cdf0e10cSrcweir 223cdf0e10cSrcweir void AccessibleEditableTextPara::implGetParagraphBoundary( ::com::sun::star::i18n::Boundary& rBoundary, sal_Int32 /*nIndex*/ ) 224cdf0e10cSrcweir { 225cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 226cdf0e10cSrcweir DBG_WARNING( "AccessibleEditableTextPara::implGetParagraphBoundary: only a base implementation, ignoring the index" ); 227cdf0e10cSrcweir 228cdf0e10cSrcweir rBoundary.startPos = 0; 2299b8096d0SSteve Yin //IAccessibility2 Implementation 2009----- 2309b8096d0SSteve Yin //rBoundary.endPos = GetTextLen(); 2319b8096d0SSteve Yin ::rtl::OUString sText( implGetText() ); 2329b8096d0SSteve Yin sal_Int32 nLength = sText.getLength(); 2339b8096d0SSteve Yin rBoundary.endPos = nLength; 2349b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009 235cdf0e10cSrcweir } 236cdf0e10cSrcweir 237cdf0e10cSrcweir void AccessibleEditableTextPara::implGetLineBoundary( ::com::sun::star::i18n::Boundary& rBoundary, sal_Int32 nIndex ) 238cdf0e10cSrcweir { 239cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 240cdf0e10cSrcweir 241cdf0e10cSrcweir SvxTextForwarder& rCacheTF = GetTextForwarder(); 242cdf0e10cSrcweir const sal_Int32 nParaIndex = GetParagraphIndex(); 243cdf0e10cSrcweir 244cdf0e10cSrcweir DBG_ASSERT(nParaIndex >= 0 && nParaIndex <= USHRT_MAX, 245cdf0e10cSrcweir "AccessibleEditableTextPara::implGetLineBoundary: paragraph index value overflow"); 246cdf0e10cSrcweir 247cdf0e10cSrcweir const sal_Int32 nTextLen = rCacheTF.GetTextLen( static_cast< sal_uInt16 >( nParaIndex ) ); 248cdf0e10cSrcweir 249cdf0e10cSrcweir CheckPosition(nIndex); 250cdf0e10cSrcweir 251cdf0e10cSrcweir rBoundary.startPos = rBoundary.endPos = -1; 252cdf0e10cSrcweir 253cdf0e10cSrcweir const sal_uInt16 nLineCount=rCacheTF.GetLineCount( static_cast< sal_uInt16 >( nParaIndex ) ); 254cdf0e10cSrcweir 255cdf0e10cSrcweir if( nIndex == nTextLen ) 256cdf0e10cSrcweir { 257cdf0e10cSrcweir // #i17014# Special-casing one-behind-the-end character 258cdf0e10cSrcweir if( nLineCount <= 1 ) 259cdf0e10cSrcweir rBoundary.startPos = 0; 260cdf0e10cSrcweir else 261cdf0e10cSrcweir rBoundary.startPos = nTextLen - rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ), 262cdf0e10cSrcweir nLineCount-1 ); 263cdf0e10cSrcweir 264cdf0e10cSrcweir rBoundary.endPos = nTextLen; 265cdf0e10cSrcweir } 266cdf0e10cSrcweir else 267cdf0e10cSrcweir { 268cdf0e10cSrcweir // normal line search 269cdf0e10cSrcweir sal_uInt16 nLine; 270cdf0e10cSrcweir sal_Int32 nCurIndex; 271cdf0e10cSrcweir for( nLine=0, nCurIndex=0; nLine<nLineCount; ++nLine ) 272cdf0e10cSrcweir { 273cdf0e10cSrcweir nCurIndex += rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ), nLine); 274cdf0e10cSrcweir 275cdf0e10cSrcweir if( nCurIndex > nIndex ) 276cdf0e10cSrcweir { 277cdf0e10cSrcweir rBoundary.startPos = nCurIndex - rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine); 278cdf0e10cSrcweir rBoundary.endPos = nCurIndex; 279cdf0e10cSrcweir break; 280cdf0e10cSrcweir } 281cdf0e10cSrcweir } 282cdf0e10cSrcweir } 283cdf0e10cSrcweir } 284cdf0e10cSrcweir 285cdf0e10cSrcweir int AccessibleEditableTextPara::getNotifierClientId() const 286cdf0e10cSrcweir { 287cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 288cdf0e10cSrcweir 289cdf0e10cSrcweir return mnNotifierClientId; 290cdf0e10cSrcweir } 291cdf0e10cSrcweir 292cdf0e10cSrcweir void AccessibleEditableTextPara::SetIndexInParent( sal_Int32 nIndex ) 293cdf0e10cSrcweir { 294cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 295cdf0e10cSrcweir 296cdf0e10cSrcweir mnIndexInParent = nIndex; 297cdf0e10cSrcweir } 298cdf0e10cSrcweir 299cdf0e10cSrcweir sal_Int32 AccessibleEditableTextPara::GetIndexInParent() const 300cdf0e10cSrcweir { 301cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 302cdf0e10cSrcweir 303cdf0e10cSrcweir return mnIndexInParent; 304cdf0e10cSrcweir } 305cdf0e10cSrcweir 306cdf0e10cSrcweir void AccessibleEditableTextPara::SetParagraphIndex( sal_Int32 nIndex ) 307cdf0e10cSrcweir { 308cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 309cdf0e10cSrcweir 310cdf0e10cSrcweir sal_Int32 nOldIndex = mnParagraphIndex; 311cdf0e10cSrcweir 312cdf0e10cSrcweir mnParagraphIndex = nIndex; 313cdf0e10cSrcweir 314cdf0e10cSrcweir WeakBullet::HardRefType aChild( maImageBullet.get() ); 315cdf0e10cSrcweir if( aChild.is() ) 316cdf0e10cSrcweir aChild->SetParagraphIndex(mnParagraphIndex); 317cdf0e10cSrcweir 318cdf0e10cSrcweir try 319cdf0e10cSrcweir { 320cdf0e10cSrcweir if( nOldIndex != nIndex ) 321cdf0e10cSrcweir { 322cdf0e10cSrcweir uno::Any aOldDesc; 323cdf0e10cSrcweir uno::Any aOldName; 324cdf0e10cSrcweir 325cdf0e10cSrcweir try 326cdf0e10cSrcweir { 327cdf0e10cSrcweir aOldDesc <<= getAccessibleDescription(); 328cdf0e10cSrcweir aOldName <<= getAccessibleName(); 329cdf0e10cSrcweir } 330cdf0e10cSrcweir catch( const uno::Exception& ) {} // optional behaviour 331cdf0e10cSrcweir // index and therefore description changed 332cdf0e10cSrcweir FireEvent( AccessibleEventId::DESCRIPTION_CHANGED, uno::makeAny( getAccessibleDescription() ), aOldDesc ); 333cdf0e10cSrcweir FireEvent( AccessibleEventId::NAME_CHANGED, uno::makeAny( getAccessibleName() ), aOldName ); 334cdf0e10cSrcweir } 335cdf0e10cSrcweir } 336cdf0e10cSrcweir catch( const uno::Exception& ) {} // optional behaviour 337cdf0e10cSrcweir } 338cdf0e10cSrcweir 339cdf0e10cSrcweir sal_Int32 AccessibleEditableTextPara::GetParagraphIndex() const SAL_THROW((uno::RuntimeException)) 340cdf0e10cSrcweir { 341cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 342cdf0e10cSrcweir 343cdf0e10cSrcweir return mnParagraphIndex; 344cdf0e10cSrcweir } 345cdf0e10cSrcweir 346cdf0e10cSrcweir void AccessibleEditableTextPara::Dispose() 347cdf0e10cSrcweir { 348cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 349cdf0e10cSrcweir 350cdf0e10cSrcweir int nClientId( getNotifierClientId() ); 351cdf0e10cSrcweir 352cdf0e10cSrcweir // #108212# drop all references before notifying dispose 353cdf0e10cSrcweir mxParent = NULL; 354cdf0e10cSrcweir mnNotifierClientId = -1; 355cdf0e10cSrcweir mpEditSource = NULL; 356cdf0e10cSrcweir 357cdf0e10cSrcweir // notify listeners 358cdf0e10cSrcweir if( nClientId != -1 ) 359cdf0e10cSrcweir { 360cdf0e10cSrcweir try 361cdf0e10cSrcweir { 362cdf0e10cSrcweir uno::Reference < XAccessibleContext > xThis = getAccessibleContext(); 363cdf0e10cSrcweir 364cdf0e10cSrcweir // #106234# Delegate to EventNotifier 365cdf0e10cSrcweir ::comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nClientId, xThis ); 366cdf0e10cSrcweir #ifdef DBG_UTIL 367cdf0e10cSrcweir OSL_TRACE( "Disposed ID: %d\n", nClientId ); 368cdf0e10cSrcweir #endif 369cdf0e10cSrcweir } 370cdf0e10cSrcweir catch( const uno::Exception& ) {} 371cdf0e10cSrcweir } 372cdf0e10cSrcweir } 373cdf0e10cSrcweir 374cdf0e10cSrcweir void AccessibleEditableTextPara::SetEditSource( SvxEditSourceAdapter* pEditSource ) 375cdf0e10cSrcweir { 376cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 377cdf0e10cSrcweir 378cdf0e10cSrcweir WeakBullet::HardRefType aChild( maImageBullet.get() ); 379cdf0e10cSrcweir if( aChild.is() ) 380cdf0e10cSrcweir aChild->SetEditSource(pEditSource); 381cdf0e10cSrcweir 3829b8096d0SSteve Yin if( !pEditSource ) 383cdf0e10cSrcweir { 384cdf0e10cSrcweir // going defunc 385cdf0e10cSrcweir UnSetState( AccessibleStateType::SHOWING ); 386cdf0e10cSrcweir UnSetState( AccessibleStateType::VISIBLE ); 387cdf0e10cSrcweir SetState( AccessibleStateType::INVALID ); 388cdf0e10cSrcweir SetState( AccessibleStateType::DEFUNC ); 389cdf0e10cSrcweir 390cdf0e10cSrcweir Dispose(); 391cdf0e10cSrcweir } 3929b8096d0SSteve Yin //IAccessibility2 Implementation 2009----- 3939b8096d0SSteve Yin mpEditSource = pEditSource; 3949b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009 395cdf0e10cSrcweir // #108900# Init last text content 396cdf0e10cSrcweir try 397cdf0e10cSrcweir { 398cdf0e10cSrcweir TextChanged(); 399cdf0e10cSrcweir } 400cdf0e10cSrcweir catch( const uno::RuntimeException& ) {} 401cdf0e10cSrcweir } 402cdf0e10cSrcweir 403cdf0e10cSrcweir ESelection AccessibleEditableTextPara::MakeSelection( sal_Int32 nStartEEIndex, sal_Int32 nEndEEIndex ) 404cdf0e10cSrcweir { 405cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 406cdf0e10cSrcweir 407cdf0e10cSrcweir // check overflow 408cdf0e10cSrcweir DBG_ASSERT(nStartEEIndex >= 0 && nStartEEIndex <= USHRT_MAX && 409cdf0e10cSrcweir nEndEEIndex >= 0 && nEndEEIndex <= USHRT_MAX && 410cdf0e10cSrcweir GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 411cdf0e10cSrcweir "AccessibleEditableTextPara::MakeSelection: index value overflow"); 412cdf0e10cSrcweir 413cdf0e10cSrcweir sal_uInt16 nParaIndex = static_cast< sal_uInt16 >( GetParagraphIndex() ); 414cdf0e10cSrcweir return ESelection( nParaIndex, static_cast< sal_uInt16 >( nStartEEIndex ), 415cdf0e10cSrcweir nParaIndex, static_cast< sal_uInt16 >( nEndEEIndex ) ); 416cdf0e10cSrcweir } 417cdf0e10cSrcweir 418cdf0e10cSrcweir ESelection AccessibleEditableTextPara::MakeSelection( sal_Int32 nEEIndex ) 419cdf0e10cSrcweir { 420cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 421cdf0e10cSrcweir 422cdf0e10cSrcweir return MakeSelection( nEEIndex, nEEIndex+1 ); 423cdf0e10cSrcweir } 424cdf0e10cSrcweir 425cdf0e10cSrcweir ESelection AccessibleEditableTextPara::MakeCursor( sal_Int32 nEEIndex ) 426cdf0e10cSrcweir { 427cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 428cdf0e10cSrcweir 429cdf0e10cSrcweir return MakeSelection( nEEIndex, nEEIndex ); 430cdf0e10cSrcweir } 431cdf0e10cSrcweir 432cdf0e10cSrcweir void AccessibleEditableTextPara::CheckIndex( sal_Int32 nIndex ) SAL_THROW((lang::IndexOutOfBoundsException, uno::RuntimeException)) 433cdf0e10cSrcweir { 434cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 435cdf0e10cSrcweir 436cdf0e10cSrcweir if( nIndex < 0 || nIndex >= getCharacterCount() ) 437cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleEditableTextPara: character index out of bounds")), 438cdf0e10cSrcweir uno::Reference< uno::XInterface > 439cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > (this) ) ); // disambiguate hierarchy 440cdf0e10cSrcweir } 441cdf0e10cSrcweir 442cdf0e10cSrcweir void AccessibleEditableTextPara::CheckPosition( sal_Int32 nIndex ) SAL_THROW((lang::IndexOutOfBoundsException, uno::RuntimeException)) 443cdf0e10cSrcweir { 444cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 445cdf0e10cSrcweir 446cdf0e10cSrcweir if( nIndex < 0 || nIndex > getCharacterCount() ) 447cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleEditableTextPara: character position out of bounds")), 448cdf0e10cSrcweir uno::Reference< uno::XInterface > 449cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > (this) ) ); // disambiguate hierarchy 450cdf0e10cSrcweir } 451cdf0e10cSrcweir 452cdf0e10cSrcweir void AccessibleEditableTextPara::CheckRange( sal_Int32 nStart, sal_Int32 nEnd ) SAL_THROW((lang::IndexOutOfBoundsException, uno::RuntimeException)) 453cdf0e10cSrcweir { 454cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 455cdf0e10cSrcweir 456cdf0e10cSrcweir CheckPosition( nStart ); 457cdf0e10cSrcweir CheckPosition( nEnd ); 458cdf0e10cSrcweir } 459cdf0e10cSrcweir 460cdf0e10cSrcweir sal_Bool AccessibleEditableTextPara::GetSelection( sal_uInt16& nStartPos, sal_uInt16& nEndPos ) SAL_THROW((uno::RuntimeException)) 461cdf0e10cSrcweir { 462cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 463cdf0e10cSrcweir 464cdf0e10cSrcweir ESelection aSelection; 465cdf0e10cSrcweir sal_uInt16 nPara = static_cast< sal_uInt16 > ( GetParagraphIndex() ); 466cdf0e10cSrcweir if( !GetEditViewForwarder().GetSelection( aSelection ) ) 467cdf0e10cSrcweir return sal_False; 468cdf0e10cSrcweir 469cdf0e10cSrcweir if( aSelection.nStartPara < aSelection.nEndPara ) 470cdf0e10cSrcweir { 471cdf0e10cSrcweir if( aSelection.nStartPara > nPara || 472cdf0e10cSrcweir aSelection.nEndPara < nPara ) 473cdf0e10cSrcweir return sal_False; 474cdf0e10cSrcweir 475cdf0e10cSrcweir if( nPara == aSelection.nStartPara ) 476cdf0e10cSrcweir nStartPos = aSelection.nStartPos; 477cdf0e10cSrcweir else 478cdf0e10cSrcweir nStartPos = 0; 479cdf0e10cSrcweir 480cdf0e10cSrcweir if( nPara == aSelection.nEndPara ) 481cdf0e10cSrcweir nEndPos = aSelection.nEndPos; 482cdf0e10cSrcweir else 483cdf0e10cSrcweir nEndPos = GetTextLen(); 484cdf0e10cSrcweir } 485cdf0e10cSrcweir else 486cdf0e10cSrcweir { 487cdf0e10cSrcweir if( aSelection.nStartPara < nPara || 488cdf0e10cSrcweir aSelection.nEndPara > nPara ) 489cdf0e10cSrcweir return sal_False; 490cdf0e10cSrcweir 491cdf0e10cSrcweir if( nPara == aSelection.nStartPara ) 492cdf0e10cSrcweir nStartPos = aSelection.nStartPos; 493cdf0e10cSrcweir else 494cdf0e10cSrcweir nStartPos = GetTextLen(); 495cdf0e10cSrcweir 496cdf0e10cSrcweir if( nPara == aSelection.nEndPara ) 497cdf0e10cSrcweir nEndPos = aSelection.nEndPos; 498cdf0e10cSrcweir else 499cdf0e10cSrcweir nEndPos = 0; 500cdf0e10cSrcweir } 501cdf0e10cSrcweir 502cdf0e10cSrcweir return sal_True; 503cdf0e10cSrcweir } 504cdf0e10cSrcweir 505cdf0e10cSrcweir String AccessibleEditableTextPara::GetText( sal_Int32 nIndex ) SAL_THROW((uno::RuntimeException)) 506cdf0e10cSrcweir { 507cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 508cdf0e10cSrcweir 509cdf0e10cSrcweir return GetTextForwarder().GetText( MakeSelection(nIndex) ); 510cdf0e10cSrcweir } 511cdf0e10cSrcweir 512cdf0e10cSrcweir String AccessibleEditableTextPara::GetTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) SAL_THROW((uno::RuntimeException)) 513cdf0e10cSrcweir { 514cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 515cdf0e10cSrcweir 516cdf0e10cSrcweir return GetTextForwarder().GetText( MakeSelection(nStartIndex, nEndIndex) ); 517cdf0e10cSrcweir } 518cdf0e10cSrcweir 519cdf0e10cSrcweir sal_uInt16 AccessibleEditableTextPara::GetTextLen() const SAL_THROW((uno::RuntimeException)) 520cdf0e10cSrcweir { 521cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 522cdf0e10cSrcweir 523cdf0e10cSrcweir return GetTextForwarder().GetTextLen( static_cast< sal_uInt16 >( GetParagraphIndex() ) ); 524cdf0e10cSrcweir } 525cdf0e10cSrcweir 526cdf0e10cSrcweir sal_Bool AccessibleEditableTextPara::IsVisible() const 527cdf0e10cSrcweir { 528cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 529cdf0e10cSrcweir 530cdf0e10cSrcweir return mpEditSource ? sal_True : sal_False ; 531cdf0e10cSrcweir } 532cdf0e10cSrcweir 533cdf0e10cSrcweir uno::Reference< XAccessibleText > AccessibleEditableTextPara::GetParaInterface( sal_Int32 nIndex ) 534cdf0e10cSrcweir { 535cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 536cdf0e10cSrcweir 537cdf0e10cSrcweir uno::Reference< XAccessible > xParent = getAccessibleParent(); 538cdf0e10cSrcweir if( xParent.is() ) 539cdf0e10cSrcweir { 540cdf0e10cSrcweir uno::Reference< XAccessibleContext > xParentContext = xParent->getAccessibleContext(); 541cdf0e10cSrcweir if( xParentContext.is() ) 542cdf0e10cSrcweir { 543cdf0e10cSrcweir uno::Reference< XAccessible > xPara = xParentContext->getAccessibleChild( nIndex ); 544cdf0e10cSrcweir if( xPara.is() ) 545cdf0e10cSrcweir { 546cdf0e10cSrcweir return uno::Reference< XAccessibleText > ( xPara, uno::UNO_QUERY ); 547cdf0e10cSrcweir } 548cdf0e10cSrcweir } 549cdf0e10cSrcweir } 550cdf0e10cSrcweir 551cdf0e10cSrcweir return uno::Reference< XAccessibleText >(); 552cdf0e10cSrcweir } 553cdf0e10cSrcweir 554cdf0e10cSrcweir SvxEditSourceAdapter& AccessibleEditableTextPara::GetEditSource() const SAL_THROW((uno::RuntimeException)) 555cdf0e10cSrcweir { 556cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 557cdf0e10cSrcweir 558cdf0e10cSrcweir if( mpEditSource ) 559cdf0e10cSrcweir return *mpEditSource; 560cdf0e10cSrcweir else 561cdf0e10cSrcweir throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No edit source, object is defunct")), 562cdf0e10cSrcweir uno::Reference< uno::XInterface > 563cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > 564cdf0e10cSrcweir ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy 565cdf0e10cSrcweir } 566cdf0e10cSrcweir 567cdf0e10cSrcweir SvxAccessibleTextAdapter& AccessibleEditableTextPara::GetTextForwarder() const SAL_THROW((uno::RuntimeException)) 568cdf0e10cSrcweir { 569cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 570cdf0e10cSrcweir 571cdf0e10cSrcweir SvxEditSourceAdapter& rEditSource = GetEditSource(); 572cdf0e10cSrcweir SvxAccessibleTextAdapter* pTextForwarder = rEditSource.GetTextForwarderAdapter(); 573cdf0e10cSrcweir 574cdf0e10cSrcweir if( !pTextForwarder ) 575cdf0e10cSrcweir throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unable to fetch text forwarder, object is defunct")), 576cdf0e10cSrcweir uno::Reference< uno::XInterface > 577cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > 578cdf0e10cSrcweir ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy 579cdf0e10cSrcweir 580cdf0e10cSrcweir if( pTextForwarder->IsValid() ) 581cdf0e10cSrcweir return *pTextForwarder; 582cdf0e10cSrcweir else 583cdf0e10cSrcweir throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Text forwarder is invalid, object is defunct")), 584cdf0e10cSrcweir uno::Reference< uno::XInterface > 585cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > 586cdf0e10cSrcweir ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy 587cdf0e10cSrcweir } 588cdf0e10cSrcweir 589cdf0e10cSrcweir SvxViewForwarder& AccessibleEditableTextPara::GetViewForwarder() const SAL_THROW((uno::RuntimeException)) 590cdf0e10cSrcweir { 591cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 592cdf0e10cSrcweir 593cdf0e10cSrcweir SvxEditSource& rEditSource = GetEditSource(); 594cdf0e10cSrcweir SvxViewForwarder* pViewForwarder = rEditSource.GetViewForwarder(); 595cdf0e10cSrcweir 596cdf0e10cSrcweir if( !pViewForwarder ) 597cdf0e10cSrcweir { 598cdf0e10cSrcweir throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unable to fetch view forwarder, object is defunct")), 599cdf0e10cSrcweir uno::Reference< uno::XInterface > 600cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > 601cdf0e10cSrcweir ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy 602cdf0e10cSrcweir } 603cdf0e10cSrcweir 604cdf0e10cSrcweir if( pViewForwarder->IsValid() ) 605cdf0e10cSrcweir return *pViewForwarder; 606cdf0e10cSrcweir else 607cdf0e10cSrcweir throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("View forwarder is invalid, object is defunct")), 608cdf0e10cSrcweir uno::Reference< uno::XInterface > 609cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > 610cdf0e10cSrcweir ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy 611cdf0e10cSrcweir } 612cdf0e10cSrcweir 613cdf0e10cSrcweir SvxAccessibleTextEditViewAdapter& AccessibleEditableTextPara::GetEditViewForwarder( sal_Bool bCreate ) const SAL_THROW((uno::RuntimeException)) 614cdf0e10cSrcweir { 615cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 616cdf0e10cSrcweir 617cdf0e10cSrcweir SvxEditSourceAdapter& rEditSource = GetEditSource(); 618cdf0e10cSrcweir SvxAccessibleTextEditViewAdapter* pTextEditViewForwarder = rEditSource.GetEditViewForwarderAdapter( bCreate ); 619cdf0e10cSrcweir 620cdf0e10cSrcweir if( !pTextEditViewForwarder ) 621cdf0e10cSrcweir { 622cdf0e10cSrcweir if( bCreate ) 623cdf0e10cSrcweir throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unable to fetch view forwarder, object is defunct")), 624cdf0e10cSrcweir uno::Reference< uno::XInterface > 625cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > 626cdf0e10cSrcweir ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy 627cdf0e10cSrcweir else 628cdf0e10cSrcweir throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No view forwarder, object not in edit mode")), 629cdf0e10cSrcweir uno::Reference< uno::XInterface > 630cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > 631cdf0e10cSrcweir ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy 632cdf0e10cSrcweir } 633cdf0e10cSrcweir 634cdf0e10cSrcweir if( pTextEditViewForwarder->IsValid() ) 635cdf0e10cSrcweir return *pTextEditViewForwarder; 636cdf0e10cSrcweir else 637cdf0e10cSrcweir { 638cdf0e10cSrcweir if( bCreate ) 639cdf0e10cSrcweir throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("View forwarder is invalid, object is defunct")), 640cdf0e10cSrcweir uno::Reference< uno::XInterface > 641cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > 642cdf0e10cSrcweir ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy 643cdf0e10cSrcweir else 644cdf0e10cSrcweir throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("View forwarder is invalid, object not in edit mode")), 645cdf0e10cSrcweir uno::Reference< uno::XInterface > 646cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > 647cdf0e10cSrcweir ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy 648cdf0e10cSrcweir } 649cdf0e10cSrcweir } 650cdf0e10cSrcweir 651cdf0e10cSrcweir sal_Bool AccessibleEditableTextPara::HaveEditView() const 652cdf0e10cSrcweir { 653cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 654cdf0e10cSrcweir 655cdf0e10cSrcweir SvxEditSource& rEditSource = GetEditSource(); 656cdf0e10cSrcweir SvxEditViewForwarder* pViewForwarder = rEditSource.GetEditViewForwarder(); 657cdf0e10cSrcweir 658cdf0e10cSrcweir if( !pViewForwarder ) 659cdf0e10cSrcweir return sal_False; 660cdf0e10cSrcweir 661cdf0e10cSrcweir if( !pViewForwarder->IsValid() ) 662cdf0e10cSrcweir return sal_False; 663cdf0e10cSrcweir 664cdf0e10cSrcweir return sal_True; 665cdf0e10cSrcweir } 666cdf0e10cSrcweir 667cdf0e10cSrcweir sal_Bool AccessibleEditableTextPara::HaveChildren() 668cdf0e10cSrcweir { 669cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 670cdf0e10cSrcweir 671cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 672cdf0e10cSrcweir "AccessibleEditableTextPara::HaveChildren: paragraph index value overflow"); 673cdf0e10cSrcweir 674cdf0e10cSrcweir return GetTextForwarder().HaveImageBullet( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 675cdf0e10cSrcweir } 676cdf0e10cSrcweir 677cdf0e10cSrcweir sal_Bool AccessibleEditableTextPara::IsActive() const SAL_THROW((uno::RuntimeException)) 678cdf0e10cSrcweir { 679cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 680cdf0e10cSrcweir 681cdf0e10cSrcweir SvxEditSource& rEditSource = GetEditSource(); 682cdf0e10cSrcweir SvxEditViewForwarder* pViewForwarder = rEditSource.GetEditViewForwarder(); 683cdf0e10cSrcweir 684cdf0e10cSrcweir if( !pViewForwarder ) 685cdf0e10cSrcweir return sal_False; 686cdf0e10cSrcweir 687cdf0e10cSrcweir if( pViewForwarder->IsValid() ) 688cdf0e10cSrcweir return sal_False; 689cdf0e10cSrcweir else 690cdf0e10cSrcweir return sal_True; 691cdf0e10cSrcweir } 692cdf0e10cSrcweir 693cdf0e10cSrcweir Rectangle AccessibleEditableTextPara::LogicToPixel( const Rectangle& rRect, const MapMode& rMapMode, SvxViewForwarder& rForwarder ) 694cdf0e10cSrcweir { 695cdf0e10cSrcweir // convert to screen coordinates 696cdf0e10cSrcweir return Rectangle( rForwarder.LogicToPixel( rRect.TopLeft(), rMapMode ), 697cdf0e10cSrcweir rForwarder.LogicToPixel( rRect.BottomRight(), rMapMode ) ); 698cdf0e10cSrcweir } 699cdf0e10cSrcweir 700cdf0e10cSrcweir const Point& AccessibleEditableTextPara::GetEEOffset() const 701cdf0e10cSrcweir { 702cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 703cdf0e10cSrcweir 704cdf0e10cSrcweir return maEEOffset; 705cdf0e10cSrcweir } 706cdf0e10cSrcweir 707cdf0e10cSrcweir void AccessibleEditableTextPara::SetEEOffset( const Point& rOffset ) 708cdf0e10cSrcweir { 709cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 710cdf0e10cSrcweir 711cdf0e10cSrcweir WeakBullet::HardRefType aChild( maImageBullet.get() ); 712cdf0e10cSrcweir if( aChild.is() ) 713cdf0e10cSrcweir aChild->SetEEOffset(rOffset); 714cdf0e10cSrcweir 715cdf0e10cSrcweir maEEOffset = rOffset; 716cdf0e10cSrcweir } 717cdf0e10cSrcweir 718cdf0e10cSrcweir void AccessibleEditableTextPara::FireEvent(const sal_Int16 nEventId, const uno::Any& rNewValue, const uno::Any& rOldValue) const 719cdf0e10cSrcweir { 720cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 721cdf0e10cSrcweir 722cdf0e10cSrcweir uno::Reference < XAccessibleContext > xThis( const_cast< AccessibleEditableTextPara* > (this)->getAccessibleContext() ); 723cdf0e10cSrcweir 724cdf0e10cSrcweir AccessibleEventObject aEvent(xThis, nEventId, rNewValue, rOldValue); 725cdf0e10cSrcweir 726cdf0e10cSrcweir // #102261# Call global queue for focus events 727cdf0e10cSrcweir if( nEventId == AccessibleEventId::STATE_CHANGED ) 728cdf0e10cSrcweir vcl::unohelper::NotifyAccessibleStateEventGlobally( aEvent ); 729cdf0e10cSrcweir 730cdf0e10cSrcweir // #106234# Delegate to EventNotifier 731cdf0e10cSrcweir if( getNotifierClientId() != -1 ) 732cdf0e10cSrcweir ::comphelper::AccessibleEventNotifier::addEvent( getNotifierClientId(), 733cdf0e10cSrcweir aEvent ); 734cdf0e10cSrcweir } 735cdf0e10cSrcweir 736cdf0e10cSrcweir void AccessibleEditableTextPara::GotPropertyEvent( const uno::Any& rNewValue, const sal_Int16 nEventId ) const 737cdf0e10cSrcweir { 738cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 739cdf0e10cSrcweir 740cdf0e10cSrcweir FireEvent( nEventId, rNewValue ); 741cdf0e10cSrcweir } 742cdf0e10cSrcweir 743cdf0e10cSrcweir void AccessibleEditableTextPara::LostPropertyEvent( const uno::Any& rOldValue, const sal_Int16 nEventId ) const 744cdf0e10cSrcweir { 745cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 746cdf0e10cSrcweir 747cdf0e10cSrcweir FireEvent( nEventId, uno::Any(), rOldValue ); 748cdf0e10cSrcweir } 749cdf0e10cSrcweir 750cdf0e10cSrcweir bool AccessibleEditableTextPara::HasState( const sal_Int16 nStateId ) 751cdf0e10cSrcweir { 752cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 753cdf0e10cSrcweir 754cdf0e10cSrcweir ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get()); 755cdf0e10cSrcweir if( pStateSet != NULL ) 756cdf0e10cSrcweir return pStateSet->contains(nStateId) ? true : false; 757cdf0e10cSrcweir 758cdf0e10cSrcweir return false; 759cdf0e10cSrcweir } 760cdf0e10cSrcweir 761cdf0e10cSrcweir void AccessibleEditableTextPara::SetState( const sal_Int16 nStateId ) 762cdf0e10cSrcweir { 763cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 764cdf0e10cSrcweir 765cdf0e10cSrcweir ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get()); 766cdf0e10cSrcweir if( pStateSet != NULL && 767cdf0e10cSrcweir !pStateSet->contains(nStateId) ) 768cdf0e10cSrcweir { 769cdf0e10cSrcweir pStateSet->AddState( nStateId ); 7709b8096d0SSteve Yin //IAccessibility2 Implementation 2009----- 7719b8096d0SSteve Yin // 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 7729b8096d0SSteve Yin // if(IsShapeParaFocusable()) 773cdf0e10cSrcweir GotPropertyEvent( uno::makeAny( nStateId ), AccessibleEventId::STATE_CHANGED ); 7749b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009 775cdf0e10cSrcweir } 776cdf0e10cSrcweir } 777cdf0e10cSrcweir 778cdf0e10cSrcweir void AccessibleEditableTextPara::UnSetState( const sal_Int16 nStateId ) 779cdf0e10cSrcweir { 780cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 781cdf0e10cSrcweir 782cdf0e10cSrcweir ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get()); 783cdf0e10cSrcweir if( pStateSet != NULL && 784cdf0e10cSrcweir pStateSet->contains(nStateId) ) 785cdf0e10cSrcweir { 786cdf0e10cSrcweir pStateSet->RemoveState( nStateId ); 787cdf0e10cSrcweir LostPropertyEvent( uno::makeAny( nStateId ), AccessibleEventId::STATE_CHANGED ); 788cdf0e10cSrcweir } 789cdf0e10cSrcweir } 790cdf0e10cSrcweir 791cdf0e10cSrcweir void AccessibleEditableTextPara::TextChanged() 792cdf0e10cSrcweir { 793cdf0e10cSrcweir ::rtl::OUString aCurrentString( OCommonAccessibleText::getText() ); 794cdf0e10cSrcweir uno::Any aDeleted; 795cdf0e10cSrcweir uno::Any aInserted; 796cdf0e10cSrcweir if( OCommonAccessibleText::implInitTextChangedEvent( maLastTextString, aCurrentString, 797cdf0e10cSrcweir aDeleted, aInserted) ) 798cdf0e10cSrcweir { 799cdf0e10cSrcweir FireEvent( AccessibleEventId::TEXT_CHANGED, aInserted, aDeleted ); 800cdf0e10cSrcweir maLastTextString = aCurrentString; 801cdf0e10cSrcweir } 802cdf0e10cSrcweir } 803cdf0e10cSrcweir 804cdf0e10cSrcweir sal_Bool AccessibleEditableTextPara::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, sal_Int32 nIndex ) 805cdf0e10cSrcweir { 806cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 807cdf0e10cSrcweir 808cdf0e10cSrcweir DBG_ASSERT(nIndex >= 0 && nIndex <= USHRT_MAX, 809cdf0e10cSrcweir "AccessibleEditableTextPara::GetAttributeRun: index value overflow"); 810cdf0e10cSrcweir 811cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 812cdf0e10cSrcweir "AccessibleEditableTextPara::getLocale: paragraph index value overflow"); 813cdf0e10cSrcweir 814cdf0e10cSrcweir return GetTextForwarder().GetAttributeRun( nStartIndex, 815cdf0e10cSrcweir nEndIndex, 816cdf0e10cSrcweir static_cast< sal_uInt16 >(GetParagraphIndex()), 817cdf0e10cSrcweir static_cast< sal_uInt16 >(nIndex) ); 818cdf0e10cSrcweir } 819cdf0e10cSrcweir 820cdf0e10cSrcweir uno::Any SAL_CALL AccessibleEditableTextPara::queryInterface (const uno::Type & rType) throw (uno::RuntimeException) 821cdf0e10cSrcweir { 822cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 823cdf0e10cSrcweir 824cdf0e10cSrcweir uno::Any aRet; 825cdf0e10cSrcweir 826cdf0e10cSrcweir // must provide XAccesibleText by hand, since it comes publicly inherited by XAccessibleEditableText 827cdf0e10cSrcweir if ( rType == ::getCppuType((uno::Reference< XAccessibleText > *)0) ) 828cdf0e10cSrcweir { 8299b8096d0SSteve Yin //IAccessibility2 Implementation 2009----- 8309b8096d0SSteve Yin // uno::Reference< XAccessibleText > aAccText = this; 831cdf0e10cSrcweir uno::Reference< XAccessibleText > aAccText = static_cast< XAccessibleEditableText * >(this); 8329b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009 833cdf0e10cSrcweir aRet <<= aAccText; 834cdf0e10cSrcweir } 835cdf0e10cSrcweir else if ( rType == ::getCppuType((uno::Reference< XAccessibleEditableText > *)0) ) 836cdf0e10cSrcweir { 837cdf0e10cSrcweir uno::Reference< XAccessibleEditableText > aAccEditText = this; 838cdf0e10cSrcweir aRet <<= aAccEditText; 839cdf0e10cSrcweir } 8409b8096d0SSteve Yin //IAccessibility2 Implementation 2009----- 841cdf0e10cSrcweir else if ( rType == ::getCppuType((uno::Reference< XAccessibleHypertext > *)0) ) 842cdf0e10cSrcweir { 843cdf0e10cSrcweir uno::Reference< XAccessibleHypertext > aAccHyperText = this; 844cdf0e10cSrcweir aRet <<= aAccHyperText; 845cdf0e10cSrcweir } 8469b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009 847cdf0e10cSrcweir else 848cdf0e10cSrcweir { 849cdf0e10cSrcweir aRet = AccessibleTextParaInterfaceBase::queryInterface(rType); 850cdf0e10cSrcweir } 851cdf0e10cSrcweir 852cdf0e10cSrcweir return aRet; 853cdf0e10cSrcweir } 854cdf0e10cSrcweir 855cdf0e10cSrcweir // XAccessible 856cdf0e10cSrcweir uno::Reference< XAccessibleContext > SAL_CALL AccessibleEditableTextPara::getAccessibleContext() throw (uno::RuntimeException) 857cdf0e10cSrcweir { 858cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 859cdf0e10cSrcweir 860cdf0e10cSrcweir // We implement the XAccessibleContext interface in the same object 861cdf0e10cSrcweir return uno::Reference< XAccessibleContext > ( this ); 862cdf0e10cSrcweir } 863cdf0e10cSrcweir 864cdf0e10cSrcweir // XAccessibleContext 865cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleEditableTextPara::getAccessibleChildCount() throw (uno::RuntimeException) 866cdf0e10cSrcweir { 867cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 868cdf0e10cSrcweir 869cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 870cdf0e10cSrcweir 871cdf0e10cSrcweir return HaveChildren() ? 1 : 0; 872cdf0e10cSrcweir } 873cdf0e10cSrcweir 874cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL AccessibleEditableTextPara::getAccessibleChild( sal_Int32 i ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 875cdf0e10cSrcweir { 876cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 877cdf0e10cSrcweir 878cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 879cdf0e10cSrcweir 880cdf0e10cSrcweir if( !HaveChildren() ) 881cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No childs available")), 882cdf0e10cSrcweir uno::Reference< uno::XInterface > 883cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > (this) ) ); // static_cast: disambiguate hierarchy 884cdf0e10cSrcweir 885cdf0e10cSrcweir if( i != 0 ) 886cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Invalid child index")), 887cdf0e10cSrcweir uno::Reference< uno::XInterface > 888cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > (this) ) ); // static_cast: disambiguate hierarchy 889cdf0e10cSrcweir 890cdf0e10cSrcweir WeakBullet::HardRefType aChild( maImageBullet.get() ); 891cdf0e10cSrcweir 892cdf0e10cSrcweir if( !aChild.is() ) 893cdf0e10cSrcweir { 894cdf0e10cSrcweir // there is no hard reference available, create object then 895cdf0e10cSrcweir AccessibleImageBullet* pChild = new AccessibleImageBullet( uno::Reference< XAccessible >( this ) ); 896cdf0e10cSrcweir uno::Reference< XAccessible > xChild( static_cast< ::cppu::OWeakObject* > (pChild), uno::UNO_QUERY ); 897cdf0e10cSrcweir 898cdf0e10cSrcweir if( !xChild.is() ) 899cdf0e10cSrcweir throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Child creation failed")), 900cdf0e10cSrcweir uno::Reference< uno::XInterface > 901cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > (this) ) ); 902cdf0e10cSrcweir 903cdf0e10cSrcweir aChild = WeakBullet::HardRefType( xChild, pChild ); 904cdf0e10cSrcweir 905cdf0e10cSrcweir aChild->SetEditSource( &GetEditSource() ); 906cdf0e10cSrcweir aChild->SetParagraphIndex( GetParagraphIndex() ); 907cdf0e10cSrcweir aChild->SetIndexInParent( i ); 908cdf0e10cSrcweir 909cdf0e10cSrcweir maImageBullet = aChild; 910cdf0e10cSrcweir } 911cdf0e10cSrcweir 912cdf0e10cSrcweir return aChild.getRef(); 913cdf0e10cSrcweir } 914cdf0e10cSrcweir 915cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL AccessibleEditableTextPara::getAccessibleParent() throw (uno::RuntimeException) 916cdf0e10cSrcweir { 917cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 918cdf0e10cSrcweir 919cdf0e10cSrcweir #ifdef DBG_UTIL 920cdf0e10cSrcweir if( !mxParent.is() ) 921cdf0e10cSrcweir DBG_TRACE( "AccessibleEditableTextPara::getAccessibleParent: no frontend set, did somebody forgot to call AccessibleTextHelper::SetEventSource()?"); 922cdf0e10cSrcweir #endif 923cdf0e10cSrcweir 924cdf0e10cSrcweir return mxParent; 925cdf0e10cSrcweir } 926cdf0e10cSrcweir 927cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleEditableTextPara::getAccessibleIndexInParent() throw (uno::RuntimeException) 928cdf0e10cSrcweir { 929cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 930cdf0e10cSrcweir 931cdf0e10cSrcweir return mnIndexInParent; 932cdf0e10cSrcweir } 933cdf0e10cSrcweir 934cdf0e10cSrcweir sal_Int16 SAL_CALL AccessibleEditableTextPara::getAccessibleRole() throw (uno::RuntimeException) 935cdf0e10cSrcweir { 936cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 937cdf0e10cSrcweir 938cdf0e10cSrcweir return AccessibleRole::PARAGRAPH; 939cdf0e10cSrcweir } 940cdf0e10cSrcweir 941cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getAccessibleDescription() throw (uno::RuntimeException) 942cdf0e10cSrcweir { 943cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 944*0deba7fbSSteve Yin //IAccessibility2 Implementation 2009----- 945*0deba7fbSSteve Yin ::vos::OGuard aGuard( Application::GetSolarMutex() ); 946cdf0e10cSrcweir 947*0deba7fbSSteve Yin // append first 40 characters from text, or first line, if shorter 948*0deba7fbSSteve Yin // (writer takes first sentence here, but that's not supported 949*0deba7fbSSteve Yin // from EditEngine) 950*0deba7fbSSteve Yin // throws if defunc 951*0deba7fbSSteve Yin ::rtl::OUString aLine; 952cdf0e10cSrcweir 953*0deba7fbSSteve Yin if( getCharacterCount() ) 954*0deba7fbSSteve Yin aLine = getTextAtIndex(0, AccessibleTextType::LINE).SegmentText; 955*0deba7fbSSteve Yin 956*0deba7fbSSteve Yin // Get the string from the resource for the specified id. 957*0deba7fbSSteve Yin String sStr = ::rtl::OUString( String( EditResId (RID_SVXSTR_A11Y_PARAGRAPH_DESCRIPTION ) ) ); 958*0deba7fbSSteve Yin String sParaIndex = ::rtl::OUString::valueOf( GetParagraphIndex() ); 959*0deba7fbSSteve Yin sStr.SearchAndReplace( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "$(ARG)" )), 960*0deba7fbSSteve Yin sParaIndex ); 961*0deba7fbSSteve Yin 962*0deba7fbSSteve Yin if( aLine.getLength() > MaxDescriptionLen ) 963*0deba7fbSSteve Yin { 964*0deba7fbSSteve Yin ::rtl::OUString aCurrWord; 965*0deba7fbSSteve Yin sal_Int32 i; 966*0deba7fbSSteve Yin 967*0deba7fbSSteve Yin // search backward from MaxDescriptionLen for previous word start 968*0deba7fbSSteve Yin for( aCurrWord=getTextAtIndex(MaxDescriptionLen, AccessibleTextType::WORD).SegmentText, 969*0deba7fbSSteve Yin i=MaxDescriptionLen, 970*0deba7fbSSteve Yin aLine=::rtl::OUString(); 971*0deba7fbSSteve Yin i>=0; 972*0deba7fbSSteve Yin --i ) 973*0deba7fbSSteve Yin { 974*0deba7fbSSteve Yin if( getTextAtIndex(i, AccessibleTextType::WORD).SegmentText != aCurrWord ) 975*0deba7fbSSteve Yin { 976*0deba7fbSSteve Yin if( i == 0 ) 977*0deba7fbSSteve Yin // prevent completely empty string 978*0deba7fbSSteve Yin aLine = getTextAtIndex(0, AccessibleTextType::WORD).SegmentText; 979*0deba7fbSSteve Yin else 980*0deba7fbSSteve Yin aLine = getTextRange(0, i); 981*0deba7fbSSteve Yin } 982*0deba7fbSSteve Yin } 983*0deba7fbSSteve Yin } 984*0deba7fbSSteve Yin 985*0deba7fbSSteve Yin return ::rtl::OUString( sStr ) + aLine; 986*0deba7fbSSteve Yin //-----IAccessibility2 Implementation 2009 987cdf0e10cSrcweir } 988cdf0e10cSrcweir 989cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getAccessibleName() throw (uno::RuntimeException) 990cdf0e10cSrcweir { 991cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 992cdf0e10cSrcweir 993*0deba7fbSSteve Yin ::vos::OGuard aGuard( Application::GetSolarMutex() ); 994cdf0e10cSrcweir 995*0deba7fbSSteve Yin // throws if defunc 996*0deba7fbSSteve Yin sal_Int32 nPara( GetParagraphIndex() ); 997*0deba7fbSSteve Yin 998*0deba7fbSSteve Yin // Get the string from the resource for the specified id. 999*0deba7fbSSteve Yin String sStr = ::rtl::OUString( String( EditResId (RID_SVXSTR_A11Y_PARAGRAPH_NAME) ) ); 1000*0deba7fbSSteve Yin String sParaIndex = ::rtl::OUString::valueOf( nPara ); 1001*0deba7fbSSteve Yin sStr.SearchAndReplace( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "$(ARG)" )), 1002*0deba7fbSSteve Yin sParaIndex ); 1003*0deba7fbSSteve Yin 1004*0deba7fbSSteve Yin return ::rtl::OUString( sStr ); 1005cdf0e10cSrcweir } 1006cdf0e10cSrcweir 1007cdf0e10cSrcweir uno::Reference< XAccessibleRelationSet > SAL_CALL AccessibleEditableTextPara::getAccessibleRelationSet() throw (uno::RuntimeException) 1008cdf0e10cSrcweir { 1009cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1010cdf0e10cSrcweir 1011cdf0e10cSrcweir // --> OD 2006-01-11 #i27138# - provide relations CONTENT_FLOWS_FROM 1012cdf0e10cSrcweir // and CONTENT_FLOWS_TO 1013cdf0e10cSrcweir if ( mpParaManager ) 1014cdf0e10cSrcweir { 1015cdf0e10cSrcweir utl::AccessibleRelationSetHelper* pAccRelSetHelper = 1016cdf0e10cSrcweir new utl::AccessibleRelationSetHelper(); 1017cdf0e10cSrcweir sal_Int32 nMyParaIndex( GetParagraphIndex() ); 1018cdf0e10cSrcweir // relation CONTENT_FLOWS_FROM 1019cdf0e10cSrcweir if ( nMyParaIndex > 0 && 1020cdf0e10cSrcweir mpParaManager->IsReferencable( nMyParaIndex - 1 ) ) 1021cdf0e10cSrcweir { 1022cdf0e10cSrcweir uno::Sequence<uno::Reference<XInterface> > aSequence(1); 1023cdf0e10cSrcweir aSequence[0] = 1024cdf0e10cSrcweir mpParaManager->GetChild( nMyParaIndex - 1 ).first.get().getRef(); 1025cdf0e10cSrcweir AccessibleRelation aAccRel( AccessibleRelationType::CONTENT_FLOWS_FROM, 1026cdf0e10cSrcweir aSequence ); 1027cdf0e10cSrcweir pAccRelSetHelper->AddRelation( aAccRel ); 1028cdf0e10cSrcweir } 1029cdf0e10cSrcweir 1030cdf0e10cSrcweir // relation CONTENT_FLOWS_TO 1031cdf0e10cSrcweir if ( (nMyParaIndex + 1) < (sal_Int32)mpParaManager->GetNum() && 1032cdf0e10cSrcweir mpParaManager->IsReferencable( nMyParaIndex + 1 ) ) 1033cdf0e10cSrcweir { 1034cdf0e10cSrcweir uno::Sequence<uno::Reference<XInterface> > aSequence(1); 1035cdf0e10cSrcweir aSequence[0] = 1036cdf0e10cSrcweir mpParaManager->GetChild( nMyParaIndex + 1 ).first.get().getRef(); 1037cdf0e10cSrcweir AccessibleRelation aAccRel( AccessibleRelationType::CONTENT_FLOWS_TO, 1038cdf0e10cSrcweir aSequence ); 1039cdf0e10cSrcweir pAccRelSetHelper->AddRelation( aAccRel ); 1040cdf0e10cSrcweir } 1041cdf0e10cSrcweir 1042cdf0e10cSrcweir return pAccRelSetHelper; 1043cdf0e10cSrcweir } 1044cdf0e10cSrcweir else 1045cdf0e10cSrcweir { 1046cdf0e10cSrcweir // no relations, therefore empty 1047cdf0e10cSrcweir return uno::Reference< XAccessibleRelationSet >(); 1048cdf0e10cSrcweir } 1049cdf0e10cSrcweir // <-- 1050cdf0e10cSrcweir } 1051cdf0e10cSrcweir 1052cdf0e10cSrcweir uno::Reference< XAccessibleStateSet > SAL_CALL AccessibleEditableTextPara::getAccessibleStateSet() throw (uno::RuntimeException) 1053cdf0e10cSrcweir { 1054cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1055cdf0e10cSrcweir 1056cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1057cdf0e10cSrcweir 1058cdf0e10cSrcweir // Create a copy of the state set and return it. 1059cdf0e10cSrcweir ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get()); 1060cdf0e10cSrcweir 1061cdf0e10cSrcweir if( !pStateSet ) 1062cdf0e10cSrcweir return uno::Reference<XAccessibleStateSet>(); 10639b8096d0SSteve Yin //IAccessibility2 Implementation 2009----- 10649b8096d0SSteve Yin uno::Reference<XAccessibleStateSet> xParentStates; 10659b8096d0SSteve Yin if (getAccessibleParent().is()) 10669b8096d0SSteve Yin { 10679b8096d0SSteve Yin uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext(); 10689b8096d0SSteve Yin xParentStates = xParentContext->getAccessibleStateSet(); 10699b8096d0SSteve Yin } 10709b8096d0SSteve Yin if (xParentStates.is() && xParentStates->contains(AccessibleStateType::EDITABLE) ) 10719b8096d0SSteve Yin { 10729b8096d0SSteve Yin pStateSet->AddState(AccessibleStateType::EDITABLE); 10739b8096d0SSteve Yin } 10749b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009 1075cdf0e10cSrcweir return uno::Reference<XAccessibleStateSet>( new ::utl::AccessibleStateSetHelper (*pStateSet) ); 1076cdf0e10cSrcweir } 1077cdf0e10cSrcweir 1078cdf0e10cSrcweir lang::Locale SAL_CALL AccessibleEditableTextPara::getLocale() throw (IllegalAccessibleComponentStateException, uno::RuntimeException) 1079cdf0e10cSrcweir { 1080cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1081cdf0e10cSrcweir 1082cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1083cdf0e10cSrcweir 1084cdf0e10cSrcweir return implGetLocale(); 1085cdf0e10cSrcweir } 1086cdf0e10cSrcweir 1087cdf0e10cSrcweir void SAL_CALL AccessibleEditableTextPara::addEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) throw (uno::RuntimeException) 1088cdf0e10cSrcweir { 1089cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1090cdf0e10cSrcweir 1091cdf0e10cSrcweir if( getNotifierClientId() != -1 ) 1092cdf0e10cSrcweir ::comphelper::AccessibleEventNotifier::addEventListener( getNotifierClientId(), xListener ); 1093cdf0e10cSrcweir } 1094cdf0e10cSrcweir 1095cdf0e10cSrcweir void SAL_CALL AccessibleEditableTextPara::removeEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) throw (uno::RuntimeException) 1096cdf0e10cSrcweir { 1097cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1098cdf0e10cSrcweir 1099cdf0e10cSrcweir if( getNotifierClientId() != -1 ) 1100cdf0e10cSrcweir ::comphelper::AccessibleEventNotifier::removeEventListener( getNotifierClientId(), xListener ); 1101cdf0e10cSrcweir } 1102cdf0e10cSrcweir 1103cdf0e10cSrcweir // XAccessibleComponent 1104cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleEditableTextPara::containsPoint( const awt::Point& aTmpPoint ) throw (uno::RuntimeException) 1105cdf0e10cSrcweir { 1106cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1107cdf0e10cSrcweir 1108cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1109cdf0e10cSrcweir 1110cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1111cdf0e10cSrcweir "AccessibleEditableTextPara::contains: index value overflow"); 1112cdf0e10cSrcweir 1113cdf0e10cSrcweir awt::Rectangle aTmpRect = getBounds(); 1114cdf0e10cSrcweir Rectangle aRect( Point(aTmpRect.X, aTmpRect.Y), Size(aTmpRect.Width, aTmpRect.Height) ); 1115cdf0e10cSrcweir Point aPoint( aTmpPoint.X, aTmpPoint.Y ); 1116cdf0e10cSrcweir 1117cdf0e10cSrcweir return aRect.IsInside( aPoint ); 1118cdf0e10cSrcweir } 1119cdf0e10cSrcweir 1120cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL AccessibleEditableTextPara::getAccessibleAtPoint( const awt::Point& _aPoint ) throw (uno::RuntimeException) 1121cdf0e10cSrcweir { 1122cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1123cdf0e10cSrcweir 1124cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1125cdf0e10cSrcweir 1126cdf0e10cSrcweir if( HaveChildren() ) 1127cdf0e10cSrcweir { 1128cdf0e10cSrcweir // #103862# No longer need to make given position relative 1129cdf0e10cSrcweir Point aPoint( _aPoint.X, _aPoint.Y ); 1130cdf0e10cSrcweir 1131cdf0e10cSrcweir // respect EditEngine offset to surrounding shape/cell 1132cdf0e10cSrcweir aPoint -= GetEEOffset(); 1133cdf0e10cSrcweir 1134cdf0e10cSrcweir // convert to EditEngine coordinate system 1135cdf0e10cSrcweir SvxTextForwarder& rCacheTF = GetTextForwarder(); 1136cdf0e10cSrcweir Point aLogPoint( GetViewForwarder().PixelToLogic( aPoint, rCacheTF.GetMapMode() ) ); 1137cdf0e10cSrcweir 1138cdf0e10cSrcweir EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 > (GetParagraphIndex()) ); 1139cdf0e10cSrcweir 1140cdf0e10cSrcweir if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && 1141cdf0e10cSrcweir aBulletInfo.bVisible && 1142cdf0e10cSrcweir aBulletInfo.nType == SVX_NUM_BITMAP ) 1143cdf0e10cSrcweir { 1144cdf0e10cSrcweir Rectangle aRect = aBulletInfo.aBounds; 1145cdf0e10cSrcweir 1146cdf0e10cSrcweir if( aRect.IsInside( aLogPoint ) ) 1147cdf0e10cSrcweir return getAccessibleChild(0); 1148cdf0e10cSrcweir } 1149cdf0e10cSrcweir } 1150cdf0e10cSrcweir 1151cdf0e10cSrcweir // no children at all, or none at given position 1152cdf0e10cSrcweir return uno::Reference< XAccessible >(); 1153cdf0e10cSrcweir } 1154cdf0e10cSrcweir 1155cdf0e10cSrcweir awt::Rectangle SAL_CALL AccessibleEditableTextPara::getBounds() throw (uno::RuntimeException) 1156cdf0e10cSrcweir { 1157cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1158cdf0e10cSrcweir 1159cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1160cdf0e10cSrcweir 1161cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1162cdf0e10cSrcweir "AccessibleEditableTextPara::getBounds: index value overflow"); 1163cdf0e10cSrcweir 1164cdf0e10cSrcweir SvxTextForwarder& rCacheTF = GetTextForwarder(); 1165cdf0e10cSrcweir Rectangle aRect = rCacheTF.GetParaBounds( static_cast< sal_uInt16 >( GetParagraphIndex() ) ); 1166cdf0e10cSrcweir 1167cdf0e10cSrcweir // convert to screen coordinates 1168cdf0e10cSrcweir Rectangle aScreenRect = AccessibleEditableTextPara::LogicToPixel( aRect, 1169cdf0e10cSrcweir rCacheTF.GetMapMode(), 1170cdf0e10cSrcweir GetViewForwarder() ); 1171cdf0e10cSrcweir 1172cdf0e10cSrcweir // offset from shape/cell 1173cdf0e10cSrcweir Point aOffset = GetEEOffset(); 1174cdf0e10cSrcweir 1175cdf0e10cSrcweir return awt::Rectangle( aScreenRect.Left() + aOffset.X(), 1176cdf0e10cSrcweir aScreenRect.Top() + aOffset.Y(), 1177cdf0e10cSrcweir aScreenRect.GetSize().Width(), 1178cdf0e10cSrcweir aScreenRect.GetSize().Height() ); 1179cdf0e10cSrcweir } 1180cdf0e10cSrcweir 1181cdf0e10cSrcweir awt::Point SAL_CALL AccessibleEditableTextPara::getLocation( ) throw (uno::RuntimeException) 1182cdf0e10cSrcweir { 1183cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1184cdf0e10cSrcweir 1185cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1186cdf0e10cSrcweir 1187cdf0e10cSrcweir awt::Rectangle aRect = getBounds(); 1188cdf0e10cSrcweir 1189cdf0e10cSrcweir return awt::Point( aRect.X, aRect.Y ); 1190cdf0e10cSrcweir } 1191cdf0e10cSrcweir 1192cdf0e10cSrcweir awt::Point SAL_CALL AccessibleEditableTextPara::getLocationOnScreen( ) throw (uno::RuntimeException) 1193cdf0e10cSrcweir { 1194cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1195cdf0e10cSrcweir 1196cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1197cdf0e10cSrcweir 1198cdf0e10cSrcweir // relate us to parent 1199cdf0e10cSrcweir uno::Reference< XAccessible > xParent = getAccessibleParent(); 1200cdf0e10cSrcweir if( xParent.is() ) 1201cdf0e10cSrcweir { 1202cdf0e10cSrcweir uno::Reference< XAccessibleComponent > xParentComponent( xParent, uno::UNO_QUERY ); 1203cdf0e10cSrcweir if( xParentComponent.is() ) 1204cdf0e10cSrcweir { 1205cdf0e10cSrcweir awt::Point aRefPoint = xParentComponent->getLocationOnScreen(); 1206cdf0e10cSrcweir awt::Point aPoint = getLocation(); 1207cdf0e10cSrcweir aPoint.X += aRefPoint.X; 1208cdf0e10cSrcweir aPoint.Y += aRefPoint.Y; 1209cdf0e10cSrcweir 1210cdf0e10cSrcweir return aPoint; 1211cdf0e10cSrcweir } 1212cdf0e10cSrcweir // --> OD 2009-12-16 #i88070# 1213cdf0e10cSrcweir // fallback to parent's <XAccessibleContext> instance 1214cdf0e10cSrcweir else 1215cdf0e10cSrcweir { 1216cdf0e10cSrcweir uno::Reference< XAccessibleContext > xParentContext = xParent->getAccessibleContext(); 1217cdf0e10cSrcweir if ( xParentContext.is() ) 1218cdf0e10cSrcweir { 1219cdf0e10cSrcweir uno::Reference< XAccessibleComponent > xParentContextComponent( xParentContext, uno::UNO_QUERY ); 1220cdf0e10cSrcweir if( xParentContextComponent.is() ) 1221cdf0e10cSrcweir { 1222cdf0e10cSrcweir awt::Point aRefPoint = xParentContextComponent->getLocationOnScreen(); 1223cdf0e10cSrcweir awt::Point aPoint = getLocation(); 1224cdf0e10cSrcweir aPoint.X += aRefPoint.X; 1225cdf0e10cSrcweir aPoint.Y += aRefPoint.Y; 1226cdf0e10cSrcweir 1227cdf0e10cSrcweir return aPoint; 1228cdf0e10cSrcweir } 1229cdf0e10cSrcweir } 1230cdf0e10cSrcweir } 1231cdf0e10cSrcweir // <-- 1232cdf0e10cSrcweir } 1233cdf0e10cSrcweir 1234cdf0e10cSrcweir throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Cannot access parent")), 1235cdf0e10cSrcweir uno::Reference< uno::XInterface > 1236cdf0e10cSrcweir ( static_cast< XAccessible* > (this) ) ); // disambiguate hierarchy 1237cdf0e10cSrcweir } 1238cdf0e10cSrcweir 1239cdf0e10cSrcweir awt::Size SAL_CALL AccessibleEditableTextPara::getSize( ) throw (uno::RuntimeException) 1240cdf0e10cSrcweir { 1241cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1242cdf0e10cSrcweir 1243cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1244cdf0e10cSrcweir 1245cdf0e10cSrcweir awt::Rectangle aRect = getBounds(); 1246cdf0e10cSrcweir 1247cdf0e10cSrcweir return awt::Size( aRect.Width, aRect.Height ); 1248cdf0e10cSrcweir } 1249cdf0e10cSrcweir 1250cdf0e10cSrcweir void SAL_CALL AccessibleEditableTextPara::grabFocus( ) throw (uno::RuntimeException) 1251cdf0e10cSrcweir { 1252cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1253cdf0e10cSrcweir 1254cdf0e10cSrcweir // set cursor to this paragraph 1255cdf0e10cSrcweir setSelection(0,0); 1256cdf0e10cSrcweir } 1257cdf0e10cSrcweir 1258cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleEditableTextPara::getForeground( ) throw (::com::sun::star::uno::RuntimeException) 1259cdf0e10cSrcweir { 1260cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1261cdf0e10cSrcweir 1262cdf0e10cSrcweir // #104444# Added to XAccessibleComponent interface 1263cdf0e10cSrcweir svtools::ColorConfig aColorConfig; 1264cdf0e10cSrcweir sal_uInt32 nColor = aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor; 1265cdf0e10cSrcweir return static_cast<sal_Int32>(nColor); 1266cdf0e10cSrcweir } 1267cdf0e10cSrcweir 1268cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleEditableTextPara::getBackground( ) throw (::com::sun::star::uno::RuntimeException) 1269cdf0e10cSrcweir { 1270cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1271cdf0e10cSrcweir 1272cdf0e10cSrcweir // #104444# Added to XAccessibleComponent interface 1273cdf0e10cSrcweir Color aColor( Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor() ); 1274cdf0e10cSrcweir 1275cdf0e10cSrcweir // the background is transparent 1276cdf0e10cSrcweir aColor.SetTransparency( 0xFF); 1277cdf0e10cSrcweir 1278cdf0e10cSrcweir return static_cast<sal_Int32>( aColor.GetColor() ); 1279cdf0e10cSrcweir } 1280cdf0e10cSrcweir 1281cdf0e10cSrcweir // XAccessibleText 1282cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleEditableTextPara::getCaretPosition() throw (uno::RuntimeException) 1283cdf0e10cSrcweir { 1284cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1285cdf0e10cSrcweir 1286cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1287cdf0e10cSrcweir 1288cdf0e10cSrcweir if( !HaveEditView() ) 1289cdf0e10cSrcweir return -1; 1290cdf0e10cSrcweir 1291cdf0e10cSrcweir ESelection aSelection; 1292cdf0e10cSrcweir if( GetEditViewForwarder().GetSelection( aSelection ) && 1293cdf0e10cSrcweir GetParagraphIndex() == aSelection.nEndPara ) 1294cdf0e10cSrcweir { 1295cdf0e10cSrcweir // caret is always nEndPara,nEndPos 12969b8096d0SSteve Yin //IAccessibility2 Implementation 2009----- 12979b8096d0SSteve Yin EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 12989b8096d0SSteve Yin if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && 12999b8096d0SSteve Yin aBulletInfo.bVisible && 13009b8096d0SSteve Yin aBulletInfo.nType != SVX_NUM_BITMAP ) 13019b8096d0SSteve Yin { 13029b8096d0SSteve Yin sal_Int32 nBulletLen = aBulletInfo.aText.Len(); 13039b8096d0SSteve Yin if( aSelection.nEndPos - nBulletLen >= 0 ) 13049b8096d0SSteve Yin return aSelection.nEndPos - nBulletLen; 13059b8096d0SSteve Yin } 13069b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009 1307cdf0e10cSrcweir return aSelection.nEndPos; 1308cdf0e10cSrcweir } 1309cdf0e10cSrcweir 1310cdf0e10cSrcweir // not within this paragraph 1311cdf0e10cSrcweir return -1; 1312cdf0e10cSrcweir } 1313cdf0e10cSrcweir 1314cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleEditableTextPara::setCaretPosition( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1315cdf0e10cSrcweir { 1316cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1317cdf0e10cSrcweir 1318cdf0e10cSrcweir return setSelection(nIndex, nIndex); 1319cdf0e10cSrcweir } 1320cdf0e10cSrcweir 1321cdf0e10cSrcweir sal_Unicode SAL_CALL AccessibleEditableTextPara::getCharacter( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1322cdf0e10cSrcweir { 1323cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1324cdf0e10cSrcweir 1325cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1326cdf0e10cSrcweir 1327cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1328cdf0e10cSrcweir "AccessibleEditableTextPara::getCharacter: index value overflow"); 1329cdf0e10cSrcweir 1330cdf0e10cSrcweir return OCommonAccessibleText::getCharacter( nIndex ); 1331cdf0e10cSrcweir } 13329b8096d0SSteve Yin //IAccessibility2 Implementation 2009----- 13339b8096d0SSteve Yin static uno::Sequence< ::rtl::OUString > getAttributeNames() 13349b8096d0SSteve Yin { 13359b8096d0SSteve Yin static uno::Sequence< ::rtl::OUString >* pNames = NULL; 13369b8096d0SSteve Yin 13379b8096d0SSteve Yin if( pNames == NULL ) 13389b8096d0SSteve Yin { 13399b8096d0SSteve Yin uno::Sequence< ::rtl::OUString >* pSeq = new uno::Sequence< ::rtl::OUString >( 21 ); 13409b8096d0SSteve Yin ::rtl::OUString* pStrings = pSeq->getArray(); 13419b8096d0SSteve Yin sal_Int32 i = 0; 13429b8096d0SSteve Yin #define STR(x) pStrings[i++] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(x)) 13439b8096d0SSteve Yin //STR("CharBackColor"); 13449b8096d0SSteve Yin STR("CharColor"); 13459b8096d0SSteve Yin STR("CharContoured"); 13469b8096d0SSteve Yin STR("CharEmphasis"); 13479b8096d0SSteve Yin STR("CharEscapement"); 13489b8096d0SSteve Yin STR("CharFontName"); 13499b8096d0SSteve Yin STR("CharHeight"); 13509b8096d0SSteve Yin STR("CharPosture"); 13519b8096d0SSteve Yin STR("CharShadowed"); 13529b8096d0SSteve Yin STR("CharStrikeout"); 13539b8096d0SSteve Yin STR("CharUnderline"); 13549b8096d0SSteve Yin STR("CharUnderlineColor"); 13559b8096d0SSteve Yin STR("CharWeight"); 13569b8096d0SSteve Yin STR("NumberingLevel"); 13579b8096d0SSteve Yin STR("NumberingRules"); 13589b8096d0SSteve Yin STR("ParaAdjust"); 13599b8096d0SSteve Yin STR("ParaBottomMargin"); 13609b8096d0SSteve Yin STR("ParaFirstLineIndent"); 13619b8096d0SSteve Yin STR("ParaLeftMargin"); 13629b8096d0SSteve Yin STR("ParaLineSpacing"); 13639b8096d0SSteve Yin STR("ParaRightMargin"); 13649b8096d0SSteve Yin STR("ParaTabStops"); 13659b8096d0SSteve Yin #undef STR 13669b8096d0SSteve Yin DBG_ASSERT( i == pSeq->getLength(), "Please adjust length" ); 13679b8096d0SSteve Yin if( i != pSeq->getLength() ) 13689b8096d0SSteve Yin pSeq->realloc( i ); 13699b8096d0SSteve Yin pNames = pSeq; 13709b8096d0SSteve Yin } 13719b8096d0SSteve Yin return *pNames; 13729b8096d0SSteve Yin } 13739b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009 13749b8096d0SSteve Yin struct IndexCompare 13759b8096d0SSteve Yin { 13769b8096d0SSteve Yin const PropertyValue* pValues; 13779b8096d0SSteve Yin IndexCompare( const PropertyValue* pVals ) : pValues(pVals) {} 13789b8096d0SSteve Yin bool operator() ( const sal_Int32& a, const sal_Int32& b ) const 13799b8096d0SSteve Yin { 13809b8096d0SSteve Yin return (pValues[a].Name < pValues[b].Name) ? true : false; 13819b8096d0SSteve Yin } 13829b8096d0SSteve Yin }; 13839b8096d0SSteve Yin 13849b8096d0SSteve Yin String AccessibleEditableTextPara::GetFieldTypeNameAtIndex(sal_Int32 nIndex) 13859b8096d0SSteve Yin { 13869b8096d0SSteve Yin String strFldType; 13879b8096d0SSteve Yin SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); 13889b8096d0SSteve Yin //For field object info 13899b8096d0SSteve Yin sal_Int32 nParaIndex = GetParagraphIndex(); 13909b8096d0SSteve Yin sal_Int32 nAllFieldLen = 0; 13919b8096d0SSteve Yin sal_Int32 nField = rCacheTF.GetFieldCount(sal_uInt16(nParaIndex)), nFoundFieldIndex = -1; 13929b8096d0SSteve Yin EFieldInfo ree; 13939b8096d0SSteve Yin sal_Int32 reeBegin, reeEnd; 13949b8096d0SSteve Yin sal_Int32 nFieldType = -1; 13959b8096d0SSteve Yin for(sal_uInt16 j = 0; j < nField; j++) 13969b8096d0SSteve Yin { 13979b8096d0SSteve Yin ree = rCacheTF.GetFieldInfo(sal_uInt16(nParaIndex), j); 13989b8096d0SSteve Yin reeBegin = ree.aPosition.nIndex + nAllFieldLen; 13999b8096d0SSteve Yin reeEnd = reeBegin + ree.aCurrentText.Len(); 14009b8096d0SSteve Yin nAllFieldLen += (ree.aCurrentText.Len() - 1); 14019b8096d0SSteve Yin if( reeBegin > nIndex ) 14029b8096d0SSteve Yin { 14039b8096d0SSteve Yin break; 14049b8096d0SSteve Yin } 14059b8096d0SSteve Yin if( nIndex >= reeBegin && nIndex < reeEnd ) 14069b8096d0SSteve Yin { 14079b8096d0SSteve Yin nFoundFieldIndex = j; 14089b8096d0SSteve Yin break; 14099b8096d0SSteve Yin } 14109b8096d0SSteve Yin } 14119b8096d0SSteve Yin if( nFoundFieldIndex >= 0 ) 14129b8096d0SSteve Yin { 14139b8096d0SSteve Yin // So we get a field, check its type now. 14149b8096d0SSteve Yin nFieldType = ree.pFieldItem->GetField()->GetClassId() ; 14159b8096d0SSteve Yin } 14169b8096d0SSteve Yin switch(nFieldType) 14179b8096d0SSteve Yin { 14189b8096d0SSteve Yin case SVX_DATEFIELD: 14199b8096d0SSteve Yin { 14209b8096d0SSteve Yin const SvxDateField* pDateField = static_cast< const SvxDateField* >(ree.pFieldItem->GetField()); 14219b8096d0SSteve Yin if (pDateField) 14229b8096d0SSteve Yin { 14239b8096d0SSteve Yin if (pDateField->GetType() == SVXDATETYPE_FIX) 14249b8096d0SSteve Yin strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("date (fixed)")); 14259b8096d0SSteve Yin else if (pDateField->GetType() == SVXDATETYPE_VAR) 14269b8096d0SSteve Yin strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("date (variable)")); 14279b8096d0SSteve Yin } 14289b8096d0SSteve Yin } 14299b8096d0SSteve Yin break; 14309b8096d0SSteve Yin case SVX_PAGEFIELD: 14319b8096d0SSteve Yin strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("page-number")); 14329b8096d0SSteve Yin break; 1433*0deba7fbSSteve Yin //support the sheet name & pages fields 14349b8096d0SSteve Yin case SVX_PAGESFIELD: 14359b8096d0SSteve Yin strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("page-count")); 14369b8096d0SSteve Yin break; 14379b8096d0SSteve Yin case SVX_TABLEFIELD: 14389b8096d0SSteve Yin strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sheet-name")); 14399b8096d0SSteve Yin break; 1440*0deba7fbSSteve Yin //End 14419b8096d0SSteve Yin case SVX_TIMEFIELD: 14429b8096d0SSteve Yin strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("time")); 14439b8096d0SSteve Yin break; 14449b8096d0SSteve Yin case SVX_EXT_TIMEFIELD: 14459b8096d0SSteve Yin { 14469b8096d0SSteve Yin const SvxExtTimeField* pTimeField = static_cast< const SvxExtTimeField* >(ree.pFieldItem->GetField()); 14479b8096d0SSteve Yin if (pTimeField) 14489b8096d0SSteve Yin { 14499b8096d0SSteve Yin if (pTimeField->GetType() == SVXTIMETYPE_FIX) 14509b8096d0SSteve Yin strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("time (fixed)")); 14519b8096d0SSteve Yin else if (pTimeField->GetType() == SVXTIMETYPE_VAR) 14529b8096d0SSteve Yin strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("time (variable)")); 14539b8096d0SSteve Yin } 14549b8096d0SSteve Yin } 14559b8096d0SSteve Yin break; 14569b8096d0SSteve Yin case SVX_AUTHORFIELD: 14579b8096d0SSteve Yin strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("author")); 14589b8096d0SSteve Yin break; 14599b8096d0SSteve Yin case SVX_EXT_FILEFIELD: 14609b8096d0SSteve Yin case SVX_FILEFIELD: 14619b8096d0SSteve Yin strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file name")); 14629b8096d0SSteve Yin default: 14639b8096d0SSteve Yin break; 14649b8096d0SSteve Yin } 14659b8096d0SSteve Yin return strFldType; 14669b8096d0SSteve Yin } 1467cdf0e10cSrcweir 1468cdf0e10cSrcweir 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) 1469cdf0e10cSrcweir { 1470cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1471cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1472cdf0e10cSrcweir 14739b8096d0SSteve Yin //IAccessibility2 Implementation 2009----- 14749b8096d0SSteve Yin //Skip the bullet range to ingnore the bullet text 14759b8096d0SSteve Yin SvxTextForwarder& rCacheTF = GetTextForwarder(); 14769b8096d0SSteve Yin EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 14779b8096d0SSteve Yin if (aBulletInfo.bVisible) 14789b8096d0SSteve Yin nIndex += aBulletInfo.aText.Len(); 14799b8096d0SSteve Yin if (nIndex != 0 && nIndex >= getCharacterCount()) 14809b8096d0SSteve Yin nIndex = getCharacterCount()-1; 14819b8096d0SSteve Yin // 14829b8096d0SSteve Yin if (nIndex != 0) 1483cdf0e10cSrcweir CheckIndex(nIndex); // may throw IndexOutOfBoundsException 1484cdf0e10cSrcweir 14859b8096d0SSteve Yin bool bSupplementalMode = false; 14869b8096d0SSteve Yin uno::Sequence< ::rtl::OUString > aPropertyNames = rRequestedAttributes; 14879b8096d0SSteve Yin if (aPropertyNames.getLength() == 0) 14889b8096d0SSteve Yin { 14899b8096d0SSteve Yin bSupplementalMode = true; 14909b8096d0SSteve Yin aPropertyNames = getAttributeNames(); 14919b8096d0SSteve Yin } 1492cdf0e10cSrcweir // get default attribues... 14939b8096d0SSteve Yin ::comphelper::SequenceAsHashMap aPropHashMap( getDefaultAttributes( aPropertyNames ) ); 1494cdf0e10cSrcweir 1495cdf0e10cSrcweir // ... and override them with the direct attributes from the specific position 14969b8096d0SSteve Yin uno::Sequence< beans::PropertyValue > aRunAttribs( getRunAttributes( nIndex, aPropertyNames ) ); 14979b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009 1498cdf0e10cSrcweir sal_Int32 nRunAttribs = aRunAttribs.getLength(); 1499cdf0e10cSrcweir const beans::PropertyValue *pRunAttrib = aRunAttribs.getConstArray(); 1500cdf0e10cSrcweir for (sal_Int32 k = 0; k < nRunAttribs; ++k) 1501cdf0e10cSrcweir { 1502cdf0e10cSrcweir const beans::PropertyValue &rRunAttrib = pRunAttrib[k]; 1503cdf0e10cSrcweir aPropHashMap[ rRunAttrib.Name ] = rRunAttrib.Value; //!! should not only be the value !! 1504cdf0e10cSrcweir } 1505cdf0e10cSrcweir #ifdef TL_DEBUG 1506cdf0e10cSrcweir { 1507cdf0e10cSrcweir uno::Sequence< rtl::OUString > aNames(1); 1508cdf0e10cSrcweir aNames.getArray()[0] = rtl::OUString::createFromAscii("CharHeight"); 1509cdf0e10cSrcweir const rtl::OUString *pNames = aNames.getConstArray(); 1510cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue > aAttribs( getRunAttributes( nIndex, aNames ) ); 1511cdf0e10cSrcweir const beans::PropertyValue *pAttribs = aAttribs.getConstArray(); 1512cdf0e10cSrcweir double d1 = -1.0; 1513cdf0e10cSrcweir float f1 = -1.0; 1514cdf0e10cSrcweir if (aAttribs.getLength()) 1515cdf0e10cSrcweir { 1516cdf0e10cSrcweir uno::Any aAny( pAttribs[0].Value ); 1517cdf0e10cSrcweir aAny >>= d1; 1518cdf0e10cSrcweir aAny >>= f1; 1519cdf0e10cSrcweir } 1520cdf0e10cSrcweir int i = 3; 1521cdf0e10cSrcweir } 1522cdf0e10cSrcweir #endif 1523cdf0e10cSrcweir 1524cdf0e10cSrcweir // get resulting sequence 1525cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aRes; 1526cdf0e10cSrcweir aPropHashMap >> aRes; 1527cdf0e10cSrcweir 1528cdf0e10cSrcweir // since SequenceAsHashMap ignores property handles and property state 1529cdf0e10cSrcweir // we have to restore the property state here (property handles are 1530cdf0e10cSrcweir // of no use to the accessibility API). 1531cdf0e10cSrcweir sal_Int32 nRes = aRes.getLength(); 1532cdf0e10cSrcweir beans::PropertyValue *pRes = aRes.getArray(); 1533cdf0e10cSrcweir for (sal_Int32 i = 0; i < nRes; ++i) 1534cdf0e10cSrcweir { 1535cdf0e10cSrcweir beans::PropertyValue &rRes = pRes[i]; 1536cdf0e10cSrcweir sal_Bool bIsDirectVal = sal_False; 1537cdf0e10cSrcweir for (sal_Int32 k = 0; k < nRunAttribs && !bIsDirectVal; ++k) 1538cdf0e10cSrcweir { 1539cdf0e10cSrcweir if (rRes.Name == pRunAttrib[k].Name) 1540cdf0e10cSrcweir bIsDirectVal = sal_True; 1541cdf0e10cSrcweir } 1542cdf0e10cSrcweir rRes.Handle = -1; 1543cdf0e10cSrcweir rRes.State = bIsDirectVal ? PropertyState_DIRECT_VALUE : PropertyState_DEFAULT_VALUE; 1544cdf0e10cSrcweir } 15459b8096d0SSteve Yin //IAccessibility2 Implementation 2009----- 15469b8096d0SSteve Yin if( bSupplementalMode ) 15479b8096d0SSteve Yin { 15489b8096d0SSteve Yin _correctValues( nIndex, aRes ); 15499b8096d0SSteve Yin // NumberingPrefix 15509b8096d0SSteve Yin nRes = aRes.getLength(); 15519b8096d0SSteve Yin aRes.realloc( nRes + 1 ); 15529b8096d0SSteve Yin pRes = aRes.getArray(); 15539b8096d0SSteve Yin beans::PropertyValue &rRes = pRes[nRes]; 15549b8096d0SSteve Yin rRes.Name = rtl::OUString::createFromAscii("NumberingPrefix"); 15559b8096d0SSteve Yin ::rtl::OUString numStr; 15569b8096d0SSteve Yin if (aBulletInfo.nType != SVX_NUM_CHAR_SPECIAL && aBulletInfo.nType != SVX_NUM_BITMAP) 15579b8096d0SSteve Yin numStr = (::rtl::OUString)aBulletInfo.aText; 15589b8096d0SSteve Yin rRes.Value <<= numStr; 15599b8096d0SSteve Yin rRes.Handle = -1; 15609b8096d0SSteve Yin rRes.State = PropertyState_DIRECT_VALUE; 15619b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009 15629b8096d0SSteve Yin //For field object. 15639b8096d0SSteve Yin String strFieldType = GetFieldTypeNameAtIndex(nIndex); 15649b8096d0SSteve Yin if (strFieldType.Len() > 0) 15659b8096d0SSteve Yin { 15669b8096d0SSteve Yin nRes = aRes.getLength(); 15679b8096d0SSteve Yin aRes.realloc( nRes + 1 ); 15689b8096d0SSteve Yin pRes = aRes.getArray(); 15699b8096d0SSteve Yin beans::PropertyValue &rResField = pRes[nRes]; 15709b8096d0SSteve Yin beans::PropertyValue aFieldType; 15719b8096d0SSteve Yin rResField.Name = rtl::OUString::createFromAscii("FieldType"); 15729b8096d0SSteve Yin rResField.Value <<= rtl::OUString(strFieldType.ToLowerAscii()); 15739b8096d0SSteve Yin rResField.Handle = -1; 15749b8096d0SSteve Yin rResField.State = PropertyState_DIRECT_VALUE; 15759b8096d0SSteve Yin } 15769b8096d0SSteve Yin //sort property values 15779b8096d0SSteve Yin // build sorted index array 15789b8096d0SSteve Yin sal_Int32 nLength = aRes.getLength(); 15799b8096d0SSteve Yin const beans::PropertyValue* pPairs = aRes.getConstArray(); 15809b8096d0SSteve Yin sal_Int32* pIndices = new sal_Int32[nLength]; 15819b8096d0SSteve Yin sal_Int32 i = 0; 15829b8096d0SSteve Yin for( i = 0; i < nLength; i++ ) 15839b8096d0SSteve Yin pIndices[i] = i; 15849b8096d0SSteve Yin sort( &pIndices[0], &pIndices[nLength], IndexCompare(pPairs) ); 15859b8096d0SSteve Yin // create sorted sequences accoring to index array 15869b8096d0SSteve Yin uno::Sequence<beans::PropertyValue> aNewValues( nLength ); 15879b8096d0SSteve Yin beans::PropertyValue* pNewValues = aNewValues.getArray(); 15889b8096d0SSteve Yin for( i = 0; i < nLength; i++ ) 15899b8096d0SSteve Yin { 15909b8096d0SSteve Yin pNewValues[i] = pPairs[pIndices[i]]; 15919b8096d0SSteve Yin } 15929b8096d0SSteve Yin delete[] pIndices; 15939b8096d0SSteve Yin // 15949b8096d0SSteve Yin return aNewValues; 15959b8096d0SSteve Yin } 1596cdf0e10cSrcweir return aRes; 1597cdf0e10cSrcweir } 1598cdf0e10cSrcweir 1599cdf0e10cSrcweir awt::Rectangle SAL_CALL AccessibleEditableTextPara::getCharacterBounds( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1600cdf0e10cSrcweir { 1601cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1602cdf0e10cSrcweir 1603cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1604cdf0e10cSrcweir 1605cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1606cdf0e10cSrcweir "AccessibleEditableTextPara::getCharacterBounds: index value overflow"); 1607cdf0e10cSrcweir 1608cdf0e10cSrcweir // #108900# Have position semantics now for nIndex, as 1609cdf0e10cSrcweir // one-past-the-end values are legal, too. 1610cdf0e10cSrcweir CheckPosition( nIndex ); 1611cdf0e10cSrcweir 1612cdf0e10cSrcweir SvxTextForwarder& rCacheTF = GetTextForwarder(); 1613cdf0e10cSrcweir Rectangle aRect = rCacheTF.GetCharBounds( static_cast< sal_uInt16 >( GetParagraphIndex() ), static_cast< sal_uInt16 >( nIndex ) ); 1614cdf0e10cSrcweir 1615cdf0e10cSrcweir // convert to screen 1616cdf0e10cSrcweir Rectangle aScreenRect = AccessibleEditableTextPara::LogicToPixel( aRect, 1617cdf0e10cSrcweir rCacheTF.GetMapMode(), 1618cdf0e10cSrcweir GetViewForwarder() ); 1619cdf0e10cSrcweir // #109864# offset from parent (paragraph), but in screen 1620cdf0e10cSrcweir // coordinates. This makes sure the internal text offset in 1621cdf0e10cSrcweir // the outline view forwarder gets cancelled out here 1622cdf0e10cSrcweir awt::Rectangle aParaRect( getBounds() ); 1623cdf0e10cSrcweir aScreenRect.Move( -aParaRect.X, -aParaRect.Y ); 1624cdf0e10cSrcweir 1625cdf0e10cSrcweir // offset from shape/cell 1626cdf0e10cSrcweir Point aOffset = GetEEOffset(); 1627cdf0e10cSrcweir 1628cdf0e10cSrcweir return awt::Rectangle( aScreenRect.Left() + aOffset.X(), 1629cdf0e10cSrcweir aScreenRect.Top() + aOffset.Y(), 1630cdf0e10cSrcweir aScreenRect.GetSize().Width(), 1631cdf0e10cSrcweir aScreenRect.GetSize().Height() ); 1632cdf0e10cSrcweir } 1633cdf0e10cSrcweir 1634cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleEditableTextPara::getCharacterCount() throw (uno::RuntimeException) 1635cdf0e10cSrcweir { 1636cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1637cdf0e10cSrcweir 1638cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1639cdf0e10cSrcweir 1640cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1641cdf0e10cSrcweir "AccessibleEditableTextPara::getCharacterCount: index value overflow"); 1642cdf0e10cSrcweir 1643cdf0e10cSrcweir return OCommonAccessibleText::getCharacterCount(); 1644cdf0e10cSrcweir } 1645cdf0e10cSrcweir 1646cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleEditableTextPara::getIndexAtPoint( const awt::Point& rPoint ) throw (uno::RuntimeException) 1647cdf0e10cSrcweir { 1648cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1649cdf0e10cSrcweir 1650cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 16519b8096d0SSteve Yin //IAccessibility2 Implementation 2009----- 16529b8096d0SSteve Yin if ((rPoint.X <= 0) && (rPoint.Y <= 0)) 16539b8096d0SSteve Yin return 0; 16549b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009 1655cdf0e10cSrcweir sal_uInt16 nPara, nIndex; 1656cdf0e10cSrcweir 1657cdf0e10cSrcweir // offset from surrounding cell/shape 1658cdf0e10cSrcweir Point aOffset( GetEEOffset() ); 1659cdf0e10cSrcweir Point aPoint( rPoint.X - aOffset.X(), rPoint.Y - aOffset.Y() ); 1660cdf0e10cSrcweir 1661cdf0e10cSrcweir // convert to logical coordinates 1662cdf0e10cSrcweir SvxTextForwarder& rCacheTF = GetTextForwarder(); 1663cdf0e10cSrcweir Point aLogPoint( GetViewForwarder().PixelToLogic( aPoint, rCacheTF.GetMapMode() ) ); 1664cdf0e10cSrcweir 1665cdf0e10cSrcweir // re-offset to parent (paragraph) 1666cdf0e10cSrcweir Rectangle aParaRect = rCacheTF.GetParaBounds( static_cast< sal_uInt16 >( GetParagraphIndex() ) ); 1667cdf0e10cSrcweir aLogPoint.Move( aParaRect.Left(), aParaRect.Top() ); 1668cdf0e10cSrcweir 1669cdf0e10cSrcweir if( rCacheTF.GetIndexAtPoint( aLogPoint, nPara, nIndex ) && 1670cdf0e10cSrcweir GetParagraphIndex() == nPara ) 1671cdf0e10cSrcweir { 1672cdf0e10cSrcweir // #102259# Double-check if we're _really_ on the given character 1673cdf0e10cSrcweir try 1674cdf0e10cSrcweir { 1675cdf0e10cSrcweir awt::Rectangle aRect1( getCharacterBounds(nIndex) ); 1676cdf0e10cSrcweir Rectangle aRect2( aRect1.X, aRect1.Y, 1677cdf0e10cSrcweir aRect1.Width + aRect1.X, aRect1.Height + aRect1.Y ); 1678cdf0e10cSrcweir if( aRect2.IsInside( Point( rPoint.X, rPoint.Y ) ) ) 1679cdf0e10cSrcweir return nIndex; 1680cdf0e10cSrcweir else 1681cdf0e10cSrcweir return -1; 1682cdf0e10cSrcweir } 1683cdf0e10cSrcweir catch( const lang::IndexOutOfBoundsException& ) 1684cdf0e10cSrcweir { 1685cdf0e10cSrcweir // #103927# Don't throw for invalid nIndex values 1686cdf0e10cSrcweir return -1; 1687cdf0e10cSrcweir } 1688cdf0e10cSrcweir } 1689cdf0e10cSrcweir else 1690cdf0e10cSrcweir { 1691cdf0e10cSrcweir // not within our paragraph 1692cdf0e10cSrcweir return -1; 1693cdf0e10cSrcweir } 1694cdf0e10cSrcweir } 1695cdf0e10cSrcweir 1696cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getSelectedText() throw (uno::RuntimeException) 1697cdf0e10cSrcweir { 1698cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1699cdf0e10cSrcweir 1700cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1701cdf0e10cSrcweir 1702cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1703cdf0e10cSrcweir "AccessibleEditableTextPara::getSelectedText: index value overflow"); 1704cdf0e10cSrcweir 1705cdf0e10cSrcweir if( !HaveEditView() ) 1706cdf0e10cSrcweir return ::rtl::OUString(); 1707cdf0e10cSrcweir 1708cdf0e10cSrcweir return OCommonAccessibleText::getSelectedText(); 1709cdf0e10cSrcweir } 1710cdf0e10cSrcweir 1711cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleEditableTextPara::getSelectionStart() throw (uno::RuntimeException) 1712cdf0e10cSrcweir { 1713cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1714cdf0e10cSrcweir 1715cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1716cdf0e10cSrcweir 1717cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1718cdf0e10cSrcweir "AccessibleEditableTextPara::getSelectionStart: index value overflow"); 1719cdf0e10cSrcweir 1720cdf0e10cSrcweir if( !HaveEditView() ) 1721cdf0e10cSrcweir return -1; 1722cdf0e10cSrcweir 1723cdf0e10cSrcweir return OCommonAccessibleText::getSelectionStart(); 1724cdf0e10cSrcweir } 1725cdf0e10cSrcweir 1726cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleEditableTextPara::getSelectionEnd() throw (uno::RuntimeException) 1727cdf0e10cSrcweir { 1728cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1729cdf0e10cSrcweir 1730cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1731cdf0e10cSrcweir 1732cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1733cdf0e10cSrcweir "AccessibleEditableTextPara::getSelectionEnd: index value overflow"); 1734cdf0e10cSrcweir 1735cdf0e10cSrcweir if( !HaveEditView() ) 1736cdf0e10cSrcweir return -1; 1737cdf0e10cSrcweir 1738cdf0e10cSrcweir return OCommonAccessibleText::getSelectionEnd(); 1739cdf0e10cSrcweir } 1740cdf0e10cSrcweir 1741cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleEditableTextPara::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1742cdf0e10cSrcweir { 1743cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1744cdf0e10cSrcweir 1745cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1746cdf0e10cSrcweir 1747cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1748cdf0e10cSrcweir "AccessibleEditableTextPara::setSelection: paragraph index value overflow"); 1749cdf0e10cSrcweir 1750cdf0e10cSrcweir CheckRange(nStartIndex, nEndIndex); 1751cdf0e10cSrcweir 1752cdf0e10cSrcweir try 1753cdf0e10cSrcweir { 1754cdf0e10cSrcweir SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_True ); 1755cdf0e10cSrcweir return rCacheVF.SetSelection( MakeSelection(nStartIndex, nEndIndex) ); 1756cdf0e10cSrcweir } 1757cdf0e10cSrcweir catch( const uno::RuntimeException& ) 1758cdf0e10cSrcweir { 1759cdf0e10cSrcweir return sal_False; 1760cdf0e10cSrcweir } 1761cdf0e10cSrcweir } 1762cdf0e10cSrcweir 1763cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getText() throw (uno::RuntimeException) 1764cdf0e10cSrcweir { 1765cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1766cdf0e10cSrcweir 1767cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1768cdf0e10cSrcweir 1769cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1770cdf0e10cSrcweir "AccessibleEditableTextPara::getText: paragraph index value overflow"); 1771cdf0e10cSrcweir 1772cdf0e10cSrcweir return OCommonAccessibleText::getText(); 1773cdf0e10cSrcweir } 1774cdf0e10cSrcweir 1775cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1776cdf0e10cSrcweir { 1777cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1778cdf0e10cSrcweir 1779cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1780cdf0e10cSrcweir 1781cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1782cdf0e10cSrcweir "AccessibleEditableTextPara::getTextRange: paragraph index value overflow"); 1783cdf0e10cSrcweir 1784cdf0e10cSrcweir return OCommonAccessibleText::getTextRange(nStartIndex, nEndIndex); 1785cdf0e10cSrcweir } 17869b8096d0SSteve Yin //IAccessibility2 Implementation 2009----- 17879b8096d0SSteve Yin void AccessibleEditableTextPara::_correctValues( const sal_Int32 nIndex, 17889b8096d0SSteve Yin uno::Sequence< PropertyValue >& rValues) 17899b8096d0SSteve Yin { 17909b8096d0SSteve Yin SvxTextForwarder& rCacheTF = GetTextForwarder(); 17919b8096d0SSteve Yin sal_Int32 nRes = rValues.getLength(); 17929b8096d0SSteve Yin beans::PropertyValue *pRes = rValues.getArray(); 17939b8096d0SSteve Yin for (sal_Int32 i = 0; i < nRes; ++i) 17949b8096d0SSteve Yin { 17959b8096d0SSteve Yin beans::PropertyValue &rRes = pRes[i]; 17969b8096d0SSteve Yin // Char color 17979b8096d0SSteve Yin if (rRes.Name.compareTo(::rtl::OUString::createFromAscii("CharColor"))==0) 17989b8096d0SSteve Yin { 17999b8096d0SSteve Yin uno::Any &anyChar = rRes.Value; 18009b8096d0SSteve Yin sal_uInt32 crChar = (sal_uInt32)(anyChar.pReserved); 18019b8096d0SSteve Yin if (COL_AUTO == crChar ) 18029b8096d0SSteve Yin { 18039b8096d0SSteve Yin uno::Reference< ::com::sun::star::accessibility::XAccessibleComponent > xComponent; 18049b8096d0SSteve Yin if (mxParent.is()) 18059b8096d0SSteve Yin { 18069b8096d0SSteve Yin xComponent.set(mxParent,uno::UNO_QUERY); 18079b8096d0SSteve Yin } 18089b8096d0SSteve Yin else 18099b8096d0SSteve Yin { 18109b8096d0SSteve Yin xComponent.set(m_xAccInfo,uno::UNO_QUERY); 18119b8096d0SSteve Yin } 18129b8096d0SSteve Yin if (xComponent.is()) 18139b8096d0SSteve Yin { 18149b8096d0SSteve Yin uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > xContext(xComponent,uno::UNO_QUERY); 18159b8096d0SSteve Yin if (xContext->getAccessibleRole() == AccessibleRole::SHAPE 18169b8096d0SSteve Yin || xContext->getAccessibleRole() == AccessibleRole::TABLE_CELL) 18179b8096d0SSteve Yin { 18189b8096d0SSteve Yin anyChar <<= COL_BLACK; 18199b8096d0SSteve Yin } 18209b8096d0SSteve Yin else 18219b8096d0SSteve Yin { 18229b8096d0SSteve Yin Color cr(xComponent->getBackground()); 18239b8096d0SSteve Yin crChar = cr.IsDark() ? COL_WHITE : COL_BLACK; 18249b8096d0SSteve Yin anyChar <<= crChar; 18259b8096d0SSteve Yin } 18269b8096d0SSteve Yin } 18279b8096d0SSteve Yin } 18289b8096d0SSteve Yin continue; 18299b8096d0SSteve Yin } 18309b8096d0SSteve Yin // Underline 18319b8096d0SSteve Yin if(rRes.Name.compareTo(::rtl::OUString::createFromAscii("CharUnderline"))==0) 18329b8096d0SSteve Yin { 18339b8096d0SSteve Yin /* 18349b8096d0SSteve Yin // MT: Implement XAccessibleTextMarkup, mark with TextMarkupType::SPELLCHECK. This way done in SW. 18359b8096d0SSteve Yin if (IsCurrentEditorEnableAutoSpell( mxParent )) 18369b8096d0SSteve Yin { 18379b8096d0SSteve Yin try 18389b8096d0SSteve Yin { 18399b8096d0SSteve Yin SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_False ); 18409b8096d0SSteve Yin sal_Bool bWrong = rCacheVF.IsWrongSpelledWordAtPos( GetParagraphIndex(), nIndex ); 18419b8096d0SSteve Yin if ( bWrong ) 18429b8096d0SSteve Yin { 18439b8096d0SSteve Yin uno::Any &anyUnderLine = pRes[9].Value; 18449b8096d0SSteve Yin // MT IA2: Not needed? sal_uInt16 crUnderLine = (sal_uInt16)(anyUnderLine.pReserved); 18459b8096d0SSteve Yin anyUnderLine <<= (sal_uInt16)UNDERLINE_WAVE; 18469b8096d0SSteve Yin } 18479b8096d0SSteve Yin } 18489b8096d0SSteve Yin catch( const uno::RuntimeException& ) 18499b8096d0SSteve Yin { 18509b8096d0SSteve Yin } 18519b8096d0SSteve Yin } 18529b8096d0SSteve Yin */ 18539b8096d0SSteve Yin continue; 18549b8096d0SSteve Yin } 18559b8096d0SSteve Yin // Underline color && Mis-spell 18569b8096d0SSteve Yin if(rRes.Name.compareTo(::rtl::OUString::createFromAscii("CharUnderlineColor"))==0) 18579b8096d0SSteve Yin { 18589b8096d0SSteve Yin uno::Any &anyCharUnderLine = rRes.Value; 18599b8096d0SSteve Yin sal_uInt32 crCharUnderLine = (sal_uInt32)(anyCharUnderLine.pReserved); 18609b8096d0SSteve Yin if (COL_AUTO == crCharUnderLine ) 18619b8096d0SSteve Yin { 18629b8096d0SSteve Yin uno::Reference< ::com::sun::star::accessibility::XAccessibleComponent > xComponent; 18639b8096d0SSteve Yin if (mxParent.is()) 18649b8096d0SSteve Yin { 18659b8096d0SSteve Yin xComponent.set(mxParent,uno::UNO_QUERY); 18669b8096d0SSteve Yin } 18679b8096d0SSteve Yin else 18689b8096d0SSteve Yin { 18699b8096d0SSteve Yin xComponent.set(m_xAccInfo,uno::UNO_QUERY); 18709b8096d0SSteve Yin } 18719b8096d0SSteve Yin if (xComponent.is()) 18729b8096d0SSteve Yin { 18739b8096d0SSteve Yin uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > xContext(xComponent,uno::UNO_QUERY); 18749b8096d0SSteve Yin if (xContext->getAccessibleRole() == AccessibleRole::SHAPE 18759b8096d0SSteve Yin || xContext->getAccessibleRole() == AccessibleRole::TABLE_CELL) 18769b8096d0SSteve Yin { 18779b8096d0SSteve Yin anyCharUnderLine <<= COL_BLACK; 18789b8096d0SSteve Yin } 18799b8096d0SSteve Yin else 18809b8096d0SSteve Yin { 18819b8096d0SSteve Yin Color cr(xComponent->getBackground()); 18829b8096d0SSteve Yin crCharUnderLine = cr.IsDark() ? COL_WHITE : COL_BLACK; 18839b8096d0SSteve Yin anyCharUnderLine <<= crCharUnderLine; 18849b8096d0SSteve Yin } 18859b8096d0SSteve Yin } 18869b8096d0SSteve Yin } 18879b8096d0SSteve Yin // MT: Implement XAccessibleTextMarkup, mark with TextMarkupType::SPELLCHECK. This way done in SW. 18889b8096d0SSteve Yin /* 18899b8096d0SSteve Yin if (IsCurrentEditorEnableAutoSpell( mxParent )) 18909b8096d0SSteve Yin { 18919b8096d0SSteve Yin try 18929b8096d0SSteve Yin { 18939b8096d0SSteve Yin SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_False ); 18949b8096d0SSteve Yin sal_Bool bWrong = rCacheVF.IsWrongSpelledWordAtPos( GetParagraphIndex(), nIndex ); 18959b8096d0SSteve Yin if ( bWrong ) 18969b8096d0SSteve Yin { 18979b8096d0SSteve Yin uno::Any &anyUnderLineColor = rRes.Value; 18989b8096d0SSteve Yin // MT IA2: Not needed? sal_uInt16 crUnderLineColor = (sal_uInt16)(anyUnderLineColor.pReserved); 18999b8096d0SSteve Yin anyUnderLineColor <<= COL_LIGHTRED; 19009b8096d0SSteve Yin } 19019b8096d0SSteve Yin } 19029b8096d0SSteve Yin catch( const uno::RuntimeException& ) 19039b8096d0SSteve Yin { 19049b8096d0SSteve Yin } 19059b8096d0SSteve Yin } 19069b8096d0SSteve Yin */ 19079b8096d0SSteve Yin continue; 19089b8096d0SSteve Yin } 19099b8096d0SSteve Yin // NumberingLevel 19109b8096d0SSteve Yin if(rRes.Name.compareTo(::rtl::OUString::createFromAscii("NumberingLevel"))==0) 19119b8096d0SSteve Yin { 19129b8096d0SSteve Yin const SvxNumBulletItem& rNumBullet = ( SvxNumBulletItem& )rCacheTF.GetParaAttribs(static_cast< sal_uInt16 >(GetParagraphIndex())).Get(EE_PARA_NUMBULLET); 19139b8096d0SSteve Yin if(rNumBullet.GetNumRule()->GetLevelCount()==0) 19149b8096d0SSteve Yin { 19159b8096d0SSteve Yin rRes.Value <<= (sal_Int16)-1; 19169b8096d0SSteve Yin rRes.Handle = -1; 19179b8096d0SSteve Yin rRes.State = PropertyState_DIRECT_VALUE; 19189b8096d0SSteve Yin } 19199b8096d0SSteve Yin else 19209b8096d0SSteve Yin { 19219b8096d0SSteve Yin // SvxAccessibleTextPropertySet aPropSet( &GetEditSource(), 19229b8096d0SSteve Yin // ImplGetSvxCharAndParaPropertiesMap() ); 19239b8096d0SSteve Yin // MT IA2 TODO: Check if this is the correct replacement for ImplGetSvxCharAndParaPropertiesMap 19249b8096d0SSteve Yin SvxAccessibleTextPropertySet aPropSet( &GetEditSource(), ImplGetSvxTextPortionSvxPropertySet() ); 1925cdf0e10cSrcweir 19269b8096d0SSteve Yin aPropSet.SetSelection( MakeSelection( 0, GetTextLen() ) ); 19279b8096d0SSteve Yin rRes.Value = aPropSet._getPropertyValue( rRes.Name, mnParagraphIndex ); 19289b8096d0SSteve Yin rRes.State = aPropSet._getPropertyState( rRes.Name, mnParagraphIndex ); 19299b8096d0SSteve Yin rRes.Handle = -1; 19309b8096d0SSteve Yin } 19319b8096d0SSteve Yin continue; 19329b8096d0SSteve Yin } 19339b8096d0SSteve Yin // NumberingRules 19349b8096d0SSteve Yin if(rRes.Name.compareTo(::rtl::OUString::createFromAscii("NumberingRules"))==0) 19359b8096d0SSteve Yin { 19369b8096d0SSteve Yin SfxItemSet aAttribs = rCacheTF.GetParaAttribs( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 19379b8096d0SSteve Yin sal_Bool bVis = ((const SfxUInt16Item&)aAttribs.Get( EE_PARA_BULLETSTATE )).GetValue() ? sal_True : sal_False; 19389b8096d0SSteve Yin if(bVis) 19399b8096d0SSteve Yin { 19409b8096d0SSteve Yin rRes.Value <<= (sal_Int16)-1; 19419b8096d0SSteve Yin rRes.Handle = -1; 19429b8096d0SSteve Yin rRes.State = PropertyState_DIRECT_VALUE; 19439b8096d0SSteve Yin } 19449b8096d0SSteve Yin else 19459b8096d0SSteve Yin { 19469b8096d0SSteve Yin // MT IA2 TODO: Check if this is the correct replacement for ImplGetSvxCharAndParaPropertiesMap 19479b8096d0SSteve Yin SvxAccessibleTextPropertySet aPropSet( &GetEditSource(), ImplGetSvxTextPortionSvxPropertySet() ); 19489b8096d0SSteve Yin aPropSet.SetSelection( MakeSelection( 0, GetTextLen() ) ); 19499b8096d0SSteve Yin rRes.Value = aPropSet._getPropertyValue( rRes.Name, mnParagraphIndex ); 19509b8096d0SSteve Yin rRes.State = aPropSet._getPropertyState( rRes.Name, mnParagraphIndex ); 19519b8096d0SSteve Yin rRes.Handle = -1; 19529b8096d0SSteve Yin } 19539b8096d0SSteve Yin continue; 19549b8096d0SSteve Yin } 19559b8096d0SSteve Yin } 19569b8096d0SSteve Yin } 19579b8096d0SSteve Yin sal_Int32 AccessibleEditableTextPara::SkipField(sal_Int32 nIndex, sal_Bool bForward) 19589b8096d0SSteve Yin { 19599b8096d0SSteve Yin sal_Int32 nParaIndex = GetParagraphIndex(); 19609b8096d0SSteve Yin SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); 19619b8096d0SSteve Yin sal_Int32 nAllFieldLen = 0; 19629b8096d0SSteve Yin sal_Int32 nField = rCacheTF.GetFieldCount(sal_uInt16(nParaIndex)), nFoundFieldIndex = -1; 19639b8096d0SSteve Yin EFieldInfo ree; 19649b8096d0SSteve Yin sal_Int32 reeBegin=0, reeEnd=0; 19659b8096d0SSteve Yin for(sal_uInt16 j = 0; j < nField; j++) 19669b8096d0SSteve Yin { 19679b8096d0SSteve Yin ree = rCacheTF.GetFieldInfo(sal_uInt16(nParaIndex), j); 19689b8096d0SSteve Yin reeBegin = ree.aPosition.nIndex + nAllFieldLen; 19699b8096d0SSteve Yin reeEnd = reeBegin + ree.aCurrentText.Len(); 19709b8096d0SSteve Yin nAllFieldLen += (ree.aCurrentText.Len() - 1); 19719b8096d0SSteve Yin if( reeBegin > nIndex ) 19729b8096d0SSteve Yin { 19739b8096d0SSteve Yin break; 19749b8096d0SSteve Yin } 19759b8096d0SSteve Yin if( nIndex >= reeBegin && nIndex < reeEnd ) 19769b8096d0SSteve Yin { 19779b8096d0SSteve Yin if(ree.pFieldItem->GetField()->GetClassId() != SVX_URLFIELD) 19789b8096d0SSteve Yin { 19799b8096d0SSteve Yin nFoundFieldIndex = j; 19809b8096d0SSteve Yin break; 19819b8096d0SSteve Yin } 19829b8096d0SSteve Yin } 19839b8096d0SSteve Yin } 19849b8096d0SSteve Yin if( nFoundFieldIndex >= 0 ) 19859b8096d0SSteve Yin { 19869b8096d0SSteve Yin if( bForward ) 19879b8096d0SSteve Yin return reeEnd - 1; 19889b8096d0SSteve Yin else 19899b8096d0SSteve Yin return reeBegin; 19909b8096d0SSteve Yin } 19919b8096d0SSteve Yin return nIndex; 19929b8096d0SSteve Yin } 19939b8096d0SSteve Yin sal_Bool AccessibleEditableTextPara::ExtendByField( ::com::sun::star::accessibility::TextSegment& Segment ) 19949b8096d0SSteve Yin { 19959b8096d0SSteve Yin sal_Int32 nParaIndex = GetParagraphIndex(); 19969b8096d0SSteve Yin SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); 19979b8096d0SSteve Yin sal_Int32 nAllFieldLen = 0; 19989b8096d0SSteve Yin sal_Int32 nField = rCacheTF.GetFieldCount(sal_uInt16(nParaIndex)), nFoundFieldIndex = -1; 19999b8096d0SSteve Yin EFieldInfo ree; 20009b8096d0SSteve Yin sal_Int32 reeBegin=0, reeEnd=0; 20019b8096d0SSteve Yin for(sal_uInt16 j = 0; j < nField; j++) 20029b8096d0SSteve Yin { 20039b8096d0SSteve Yin ree = rCacheTF.GetFieldInfo(sal_uInt16(nParaIndex), j); 20049b8096d0SSteve Yin reeBegin = ree.aPosition.nIndex + nAllFieldLen; 20059b8096d0SSteve Yin reeEnd = reeBegin + ree.aCurrentText.Len(); 20069b8096d0SSteve Yin nAllFieldLen += (ree.aCurrentText.Len() - 1); 20079b8096d0SSteve Yin if( reeBegin > Segment.SegmentEnd ) 20089b8096d0SSteve Yin { 20099b8096d0SSteve Yin break; 20109b8096d0SSteve Yin } 20119b8096d0SSteve Yin if( (Segment.SegmentEnd > reeBegin && Segment.SegmentEnd <= reeEnd) || 20129b8096d0SSteve Yin (Segment.SegmentStart >= reeBegin && Segment.SegmentStart < reeEnd) ) 20139b8096d0SSteve Yin { 20149b8096d0SSteve Yin if(ree.pFieldItem->GetField()->GetClassId() != SVX_URLFIELD) 20159b8096d0SSteve Yin { 20169b8096d0SSteve Yin nFoundFieldIndex = j; 20179b8096d0SSteve Yin break; 20189b8096d0SSteve Yin } 20199b8096d0SSteve Yin } 20209b8096d0SSteve Yin } 20219b8096d0SSteve Yin sal_Bool bExtend = sal_False; 20229b8096d0SSteve Yin if( nFoundFieldIndex >= 0 ) 20239b8096d0SSteve Yin { 20249b8096d0SSteve Yin if( Segment.SegmentEnd < reeEnd ) 20259b8096d0SSteve Yin { 20269b8096d0SSteve Yin Segment.SegmentEnd = reeEnd; 20279b8096d0SSteve Yin bExtend = sal_True; 20289b8096d0SSteve Yin } 20299b8096d0SSteve Yin if( Segment.SegmentStart > reeBegin ) 20309b8096d0SSteve Yin { 20319b8096d0SSteve Yin Segment.SegmentStart = reeBegin; 20329b8096d0SSteve Yin bExtend = sal_True; 20339b8096d0SSteve Yin } 20349b8096d0SSteve Yin if( bExtend ) 20359b8096d0SSteve Yin { 20369b8096d0SSteve Yin //If there is a bullet before the field, should add the bullet length into the segment. 20379b8096d0SSteve Yin EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo(sal_uInt16(nParaIndex)); 20389b8096d0SSteve Yin int nBulletLen = aBulletInfo.aText.Len(); 20399b8096d0SSteve Yin if (nBulletLen > 0) 20409b8096d0SSteve Yin { 20419b8096d0SSteve Yin Segment.SegmentEnd += nBulletLen; 20429b8096d0SSteve Yin if (nFoundFieldIndex > 0) 20439b8096d0SSteve Yin Segment.SegmentStart += nBulletLen; 20449b8096d0SSteve Yin Segment.SegmentText = GetTextRange(Segment.SegmentStart, Segment.SegmentEnd); 20459b8096d0SSteve Yin //After get the correct field name, should restore the offset value which don't contain the bullet. 20469b8096d0SSteve Yin Segment.SegmentEnd -= nBulletLen; 20479b8096d0SSteve Yin if (nFoundFieldIndex > 0) 20489b8096d0SSteve Yin Segment.SegmentStart -= nBulletLen; 20499b8096d0SSteve Yin } 20509b8096d0SSteve Yin else 20519b8096d0SSteve Yin Segment.SegmentText = GetTextRange(Segment.SegmentStart, Segment.SegmentEnd); 20529b8096d0SSteve Yin } 20539b8096d0SSteve Yin } 20549b8096d0SSteve Yin return bExtend; 20559b8096d0SSteve Yin } 20569b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009 2057cdf0e10cSrcweir ::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) 2058cdf0e10cSrcweir { 2059cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2060cdf0e10cSrcweir 2061cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2062cdf0e10cSrcweir 2063cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2064cdf0e10cSrcweir "AccessibleEditableTextPara::getTextAtIndex: paragraph index value overflow"); 2065cdf0e10cSrcweir 2066cdf0e10cSrcweir ::com::sun::star::accessibility::TextSegment aResult; 2067cdf0e10cSrcweir aResult.SegmentStart = -1; 2068cdf0e10cSrcweir aResult.SegmentEnd = -1; 2069cdf0e10cSrcweir 2070cdf0e10cSrcweir switch( aTextType ) 2071cdf0e10cSrcweir { 20729b8096d0SSteve Yin //IAccessibility2 Implementation 2009----- 20739b8096d0SSteve Yin case AccessibleTextType::CHARACTER: 20749b8096d0SSteve Yin case AccessibleTextType::WORD: 20759b8096d0SSteve Yin { 20769b8096d0SSteve Yin aResult = OCommonAccessibleText::getTextAtIndex( nIndex, aTextType ); 20779b8096d0SSteve Yin ExtendByField( aResult ); 20789b8096d0SSteve Yin break; 20799b8096d0SSteve Yin } 20809b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009 2081cdf0e10cSrcweir // Not yet handled by OCommonAccessibleText. Missing 2082cdf0e10cSrcweir // implGetAttributeRunBoundary() method there 2083cdf0e10cSrcweir case AccessibleTextType::ATTRIBUTE_RUN: 2084cdf0e10cSrcweir { 2085cdf0e10cSrcweir const sal_Int32 nTextLen = GetTextForwarder().GetTextLen( static_cast< sal_uInt16 >( GetParagraphIndex() ) ); 2086cdf0e10cSrcweir 2087cdf0e10cSrcweir if( nIndex == nTextLen ) 2088cdf0e10cSrcweir { 2089cdf0e10cSrcweir // #i17014# Special-casing one-behind-the-end character 2090cdf0e10cSrcweir aResult.SegmentStart = aResult.SegmentEnd = nTextLen; 2091cdf0e10cSrcweir } 2092cdf0e10cSrcweir else 2093cdf0e10cSrcweir { 2094cdf0e10cSrcweir sal_uInt16 nStartIndex, nEndIndex; 20959b8096d0SSteve Yin //For the bullet paragraph, the bullet string is ingnored for IAText::attributes() function. 20969b8096d0SSteve Yin SvxTextForwarder& rCacheTF = GetTextForwarder(); 20979b8096d0SSteve Yin // MT IA2: Not used? sal_Int32 nBulletLen = 0; 20989b8096d0SSteve Yin EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 20999b8096d0SSteve Yin if (aBulletInfo.bVisible) 21009b8096d0SSteve Yin nIndex += aBulletInfo.aText.Len(); 21019b8096d0SSteve Yin if (nIndex != 0 && nIndex >= getCharacterCount()) 21029b8096d0SSteve Yin nIndex = getCharacterCount()-1; 21039b8096d0SSteve Yin CheckPosition(nIndex); 2104cdf0e10cSrcweir if( GetAttributeRun(nStartIndex, nEndIndex, nIndex) ) 2105cdf0e10cSrcweir { 2106cdf0e10cSrcweir aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex); 21079b8096d0SSteve Yin if (aBulletInfo.bVisible) 21089b8096d0SSteve Yin { 21099b8096d0SSteve Yin nStartIndex -= aBulletInfo.aText.Len(); 21109b8096d0SSteve Yin nEndIndex -= aBulletInfo.aText.Len(); 21119b8096d0SSteve Yin } 2112cdf0e10cSrcweir aResult.SegmentStart = nStartIndex; 2113cdf0e10cSrcweir aResult.SegmentEnd = nEndIndex; 2114cdf0e10cSrcweir } 2115cdf0e10cSrcweir } 2116cdf0e10cSrcweir break; 2117cdf0e10cSrcweir } 21189b8096d0SSteve Yin //IAccessibility2 Implementation 2009----- 21199b8096d0SSteve Yin case AccessibleTextType::LINE: 21209b8096d0SSteve Yin { 21219b8096d0SSteve Yin SvxTextForwarder& rCacheTF = GetTextForwarder(); 21229b8096d0SSteve Yin sal_Int32 nParaIndex = GetParagraphIndex(); 21239b8096d0SSteve Yin // MT IA2: Not needed? sal_Int32 nTextLen = rCacheTF.GetTextLen( static_cast< sal_uInt16 >( nParaIndex ) ); 21249b8096d0SSteve Yin CheckPosition(nIndex); 21259b8096d0SSteve Yin if (nIndex != 0 && nIndex == getCharacterCount()) 21269b8096d0SSteve Yin --nIndex; 21279b8096d0SSteve Yin sal_uInt16 nLine, nLineCount=rCacheTF.GetLineCount( static_cast< sal_uInt16 >( nParaIndex ) ); 21289b8096d0SSteve Yin sal_Int32 nCurIndex; 21299b8096d0SSteve Yin //the problem is that rCacheTF.GetLineLen() will include the bullet length. But for the bullet line, 21309b8096d0SSteve Yin //the text value doesn't contain the bullet characters. all of the bullet and numbering info are exposed 21319b8096d0SSteve Yin //by the IAText::attributes(). So here must do special support for bullet line. 21329b8096d0SSteve Yin sal_Int32 nBulletLen = 0; 21339b8096d0SSteve Yin for( nLine=0, nCurIndex=0; nLine<nLineCount; ++nLine ) 21349b8096d0SSteve Yin { 21359b8096d0SSteve Yin if (nLine == 0) 21369b8096d0SSteve Yin { 21379b8096d0SSteve Yin EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 >(nParaIndex) ); 21389b8096d0SSteve Yin if (aBulletInfo.bVisible) 21399b8096d0SSteve Yin { 21409b8096d0SSteve Yin //in bullet or numbering; 21419b8096d0SSteve Yin nBulletLen = aBulletInfo.aText.Len(); 21429b8096d0SSteve Yin } 21439b8096d0SSteve Yin } 21449b8096d0SSteve Yin //nCurIndex += rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ), nLine); 21459b8096d0SSteve Yin sal_Int32 nLineLen = rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ), nLine); 21469b8096d0SSteve Yin if (nLine == 0) 21479b8096d0SSteve Yin nCurIndex += nLineLen - nBulletLen; 21489b8096d0SSteve Yin else 21499b8096d0SSteve Yin nCurIndex += nLineLen; 21509b8096d0SSteve Yin if( nCurIndex > nIndex ) 21519b8096d0SSteve Yin { 21529b8096d0SSteve Yin if (nLine ==0) 21539b8096d0SSteve Yin { 21549b8096d0SSteve Yin //aResult.SegmentStart = nCurIndex - rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine); 21559b8096d0SSteve Yin aResult.SegmentStart = 0; 21569b8096d0SSteve Yin aResult.SegmentEnd = nCurIndex; 21579b8096d0SSteve Yin //aResult.SegmentText = GetTextRange( aResult.SegmentStart, aResult.SegmentEnd ); 21589b8096d0SSteve Yin aResult.SegmentText = GetTextRange( aResult.SegmentStart, aResult.SegmentEnd + nBulletLen); 21599b8096d0SSteve Yin break; 21609b8096d0SSteve Yin } 21619b8096d0SSteve Yin else 21629b8096d0SSteve Yin { 21639b8096d0SSteve Yin //aResult.SegmentStart = nCurIndex - rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine); 21649b8096d0SSteve Yin aResult.SegmentStart = nCurIndex - nLineLen; 21659b8096d0SSteve Yin aResult.SegmentEnd = nCurIndex; 21669b8096d0SSteve Yin //aResult.SegmentText = GetTextRange( aResult.SegmentStart, aResult.SegmentEnd ); 21679b8096d0SSteve Yin aResult.SegmentText = GetTextRange( aResult.SegmentStart + nBulletLen, aResult.SegmentEnd + nBulletLen); 21689b8096d0SSteve Yin break; 21699b8096d0SSteve Yin } 21709b8096d0SSteve Yin } 21719b8096d0SSteve Yin } 21729b8096d0SSteve Yin break; 21739b8096d0SSteve Yin } 21749b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009 2175cdf0e10cSrcweir default: 2176cdf0e10cSrcweir aResult = OCommonAccessibleText::getTextAtIndex( nIndex, aTextType ); 2177cdf0e10cSrcweir break; 2178cdf0e10cSrcweir } /* end of switch( aTextType ) */ 2179cdf0e10cSrcweir 2180cdf0e10cSrcweir return aResult; 2181cdf0e10cSrcweir } 2182cdf0e10cSrcweir 2183cdf0e10cSrcweir ::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) 2184cdf0e10cSrcweir { 2185cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2186cdf0e10cSrcweir 2187cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2188cdf0e10cSrcweir 2189cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2190cdf0e10cSrcweir "AccessibleEditableTextPara::getTextBeforeIndex: paragraph index value overflow"); 2191cdf0e10cSrcweir 2192cdf0e10cSrcweir ::com::sun::star::accessibility::TextSegment aResult; 2193cdf0e10cSrcweir aResult.SegmentStart = -1; 2194cdf0e10cSrcweir aResult.SegmentEnd = -1; 21959b8096d0SSteve Yin //IAccessibility2 Implementation 2009----- 21969b8096d0SSteve Yin i18n::Boundary aBoundary; 21979b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009 2198cdf0e10cSrcweir switch( aTextType ) 2199cdf0e10cSrcweir { 2200cdf0e10cSrcweir // Not yet handled by OCommonAccessibleText. Missing 2201cdf0e10cSrcweir // implGetAttributeRunBoundary() method there 2202cdf0e10cSrcweir case AccessibleTextType::ATTRIBUTE_RUN: 2203cdf0e10cSrcweir { 2204cdf0e10cSrcweir const sal_Int32 nTextLen = GetTextForwarder().GetTextLen( static_cast< sal_uInt16 >( GetParagraphIndex() ) ); 2205cdf0e10cSrcweir sal_uInt16 nStartIndex, nEndIndex; 2206cdf0e10cSrcweir 2207cdf0e10cSrcweir if( nIndex == nTextLen ) 2208cdf0e10cSrcweir { 2209cdf0e10cSrcweir // #i17014# Special-casing one-behind-the-end character 2210cdf0e10cSrcweir if( nIndex > 0 && 2211cdf0e10cSrcweir GetAttributeRun(nStartIndex, nEndIndex, nIndex-1) ) 2212cdf0e10cSrcweir { 2213cdf0e10cSrcweir aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex); 2214cdf0e10cSrcweir aResult.SegmentStart = nStartIndex; 2215cdf0e10cSrcweir aResult.SegmentEnd = nEndIndex; 2216cdf0e10cSrcweir } 2217cdf0e10cSrcweir } 2218cdf0e10cSrcweir else 2219cdf0e10cSrcweir { 2220cdf0e10cSrcweir if( GetAttributeRun(nStartIndex, nEndIndex, nIndex) ) 2221cdf0e10cSrcweir { 2222cdf0e10cSrcweir // already at the left border? If not, query 2223cdf0e10cSrcweir // one index further left 2224cdf0e10cSrcweir if( nStartIndex > 0 && 2225cdf0e10cSrcweir GetAttributeRun(nStartIndex, nEndIndex, nStartIndex-1) ) 2226cdf0e10cSrcweir { 2227cdf0e10cSrcweir aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex); 2228cdf0e10cSrcweir aResult.SegmentStart = nStartIndex; 2229cdf0e10cSrcweir aResult.SegmentEnd = nEndIndex; 2230cdf0e10cSrcweir } 2231cdf0e10cSrcweir } 2232cdf0e10cSrcweir } 2233cdf0e10cSrcweir break; 2234cdf0e10cSrcweir } 22359b8096d0SSteve Yin //IAccessibility2 Implementation 2009----- 22369b8096d0SSteve Yin case AccessibleTextType::LINE: 22379b8096d0SSteve Yin { 22389b8096d0SSteve Yin SvxTextForwarder& rCacheTF = GetTextForwarder(); 22399b8096d0SSteve Yin sal_Int32 nParaIndex = GetParagraphIndex(); 22409b8096d0SSteve Yin // MT IA2 not needed? sal_Int32 nTextLen = rCacheTF.GetTextLen( static_cast< sal_uInt16 >( nParaIndex ) ); 2241cdf0e10cSrcweir 22429b8096d0SSteve Yin CheckPosition(nIndex); 22439b8096d0SSteve Yin 22449b8096d0SSteve Yin sal_uInt16 nLine, nLineCount=rCacheTF.GetLineCount( static_cast< sal_uInt16 >( nParaIndex ) ); 22459b8096d0SSteve Yin //the problem is that rCacheTF.GetLineLen() will include the bullet length. But for the bullet line, 22469b8096d0SSteve Yin //the text value doesn't contain the bullet characters. all of the bullet and numbering info are exposed 22479b8096d0SSteve Yin //by the IAText::attributes(). So here must do special support for bullet line. 22489b8096d0SSteve Yin sal_Int32 nCurIndex=0, nLastIndex=0, nCurLineLen=0; 22499b8096d0SSteve Yin sal_Int32 nLastLineLen = 0, nBulletLen = 0;; 22509b8096d0SSteve Yin // get the line before the line the index points into 22519b8096d0SSteve Yin for( nLine=0, nCurIndex=0, nLastIndex=0; nLine<nLineCount; ++nLine ) 22529b8096d0SSteve Yin { 22539b8096d0SSteve Yin nLastIndex = nCurIndex; 22549b8096d0SSteve Yin if (nLine == 0) 22559b8096d0SSteve Yin { 22569b8096d0SSteve Yin EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 >(nParaIndex) ); 22579b8096d0SSteve Yin if (aBulletInfo.bVisible) 22589b8096d0SSteve Yin { 22599b8096d0SSteve Yin //in bullet or numbering; 22609b8096d0SSteve Yin nBulletLen = aBulletInfo.aText.Len(); 22619b8096d0SSteve Yin } 22629b8096d0SSteve Yin } 22639b8096d0SSteve Yin if (nLine == 1) 22649b8096d0SSteve Yin nLastLineLen = nCurLineLen - nBulletLen; 22659b8096d0SSteve Yin else 22669b8096d0SSteve Yin nLastLineLen = nCurLineLen; 22679b8096d0SSteve Yin nCurLineLen = rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine); 22689b8096d0SSteve Yin //nCurIndex += nCurLineLen; 22699b8096d0SSteve Yin if (nLine == 0) 22709b8096d0SSteve Yin nCurIndex += nCurLineLen - nBulletLen; 22719b8096d0SSteve Yin else 22729b8096d0SSteve Yin nCurIndex += nCurLineLen; 22739b8096d0SSteve Yin 22749b8096d0SSteve Yin //if( nCurIndex > nIndex && 22759b8096d0SSteve Yin //nLastIndex > nCurLineLen ) 22769b8096d0SSteve Yin if (nCurIndex > nIndex) 22779b8096d0SSteve Yin { 22789b8096d0SSteve Yin if (nLine == 0) 22799b8096d0SSteve Yin { 22809b8096d0SSteve Yin break; 22819b8096d0SSteve Yin } 22829b8096d0SSteve Yin else if (nLine == 1) 22839b8096d0SSteve Yin { 22849b8096d0SSteve Yin aResult.SegmentStart = 0; 22859b8096d0SSteve Yin aResult.SegmentEnd = static_cast< sal_uInt16 >( nLastIndex ); 22869b8096d0SSteve Yin aResult.SegmentText = GetTextRange( aResult.SegmentStart, aResult.SegmentEnd + nBulletLen); 22879b8096d0SSteve Yin break; 22889b8096d0SSteve Yin } 22899b8096d0SSteve Yin else 22909b8096d0SSteve Yin { 22919b8096d0SSteve Yin //aResult.SegmentStart = nLastIndex - nCurLineLen; 22929b8096d0SSteve Yin aResult.SegmentStart = nLastIndex - nLastLineLen; 22939b8096d0SSteve Yin aResult.SegmentEnd = static_cast< sal_uInt16 >( nLastIndex ); 22949b8096d0SSteve Yin aResult.SegmentText = GetTextRange( aResult.SegmentStart + nBulletLen, aResult.SegmentEnd + nBulletLen); 22959b8096d0SSteve Yin break; 22969b8096d0SSteve Yin } 22979b8096d0SSteve Yin } 22989b8096d0SSteve Yin } 22999b8096d0SSteve Yin 23009b8096d0SSteve Yin break; 23019b8096d0SSteve Yin } 23029b8096d0SSteve Yin case AccessibleTextType::WORD: 23039b8096d0SSteve Yin { 23049b8096d0SSteve Yin nIndex = SkipField( nIndex, sal_False); 23059b8096d0SSteve Yin ::rtl::OUString sText( implGetText() ); 23069b8096d0SSteve Yin sal_Int32 nLength = sText.getLength(); 23079b8096d0SSteve Yin 23089b8096d0SSteve Yin // get word at index 23099b8096d0SSteve Yin implGetWordBoundary( aBoundary, nIndex ); 23109b8096d0SSteve Yin 23119b8096d0SSteve Yin 23129b8096d0SSteve Yin //sal_Int32 curWordStart = aBoundary.startPos; 23139b8096d0SSteve Yin //sal_Int32 preWordStart = curWordStart; 23149b8096d0SSteve Yin sal_Int32 curWordStart , preWordStart; 23159b8096d0SSteve Yin if( aBoundary.startPos == -1 || aBoundary.startPos > nIndex) 23169b8096d0SSteve Yin curWordStart = preWordStart = nIndex; 23179b8096d0SSteve Yin else 23189b8096d0SSteve Yin curWordStart = preWordStart = aBoundary.startPos; 23199b8096d0SSteve Yin 23209b8096d0SSteve Yin // get previous word 23219b8096d0SSteve Yin 23229b8096d0SSteve Yin sal_Bool bWord = sal_False; 23239b8096d0SSteve Yin 23249b8096d0SSteve Yin //while ( preWordStart > 0 && aBoundary.startPos == curWordStart) 23259b8096d0SSteve Yin while ( (preWordStart >= 0 && !bWord ) || ( aBoundary.endPos > curWordStart ) ) 23269b8096d0SSteve Yin { 23279b8096d0SSteve Yin preWordStart--; 23289b8096d0SSteve Yin bWord = implGetWordBoundary( aBoundary, preWordStart ); 23299b8096d0SSteve Yin } 23309b8096d0SSteve Yin if ( bWord && implIsValidBoundary( aBoundary, nLength ) ) 23319b8096d0SSteve Yin { 23329b8096d0SSteve Yin aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos ); 23339b8096d0SSteve Yin aResult.SegmentStart = aBoundary.startPos; 23349b8096d0SSteve Yin aResult.SegmentEnd = aBoundary.endPos; 23359b8096d0SSteve Yin ExtendByField( aResult ); 23369b8096d0SSteve Yin } 23379b8096d0SSteve Yin } 23389b8096d0SSteve Yin break; 23399b8096d0SSteve Yin case AccessibleTextType::CHARACTER: 23409b8096d0SSteve Yin { 23419b8096d0SSteve Yin nIndex = SkipField( nIndex, sal_False); 23429b8096d0SSteve Yin aResult = OCommonAccessibleText::getTextBeforeIndex( nIndex, aTextType ); 23439b8096d0SSteve Yin ExtendByField( aResult ); 23449b8096d0SSteve Yin break; 23459b8096d0SSteve Yin } 23469b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009 2347cdf0e10cSrcweir default: 2348cdf0e10cSrcweir aResult = OCommonAccessibleText::getTextBeforeIndex( nIndex, aTextType ); 2349cdf0e10cSrcweir break; 2350cdf0e10cSrcweir } /* end of switch( aTextType ) */ 2351cdf0e10cSrcweir 2352cdf0e10cSrcweir return aResult; 2353cdf0e10cSrcweir } 2354cdf0e10cSrcweir 2355cdf0e10cSrcweir ::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) 2356cdf0e10cSrcweir { 2357cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2358cdf0e10cSrcweir 2359cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2360cdf0e10cSrcweir 2361cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2362cdf0e10cSrcweir "AccessibleEditableTextPara::getTextBehindIndex: paragraph index value overflow"); 2363cdf0e10cSrcweir 2364cdf0e10cSrcweir ::com::sun::star::accessibility::TextSegment aResult; 2365cdf0e10cSrcweir aResult.SegmentStart = -1; 2366cdf0e10cSrcweir aResult.SegmentEnd = -1; 23679b8096d0SSteve Yin //IAccessibility2 Implementation 2009----- 23689b8096d0SSteve Yin i18n::Boundary aBoundary; 23699b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009 2370cdf0e10cSrcweir switch( aTextType ) 2371cdf0e10cSrcweir { 2372cdf0e10cSrcweir case AccessibleTextType::ATTRIBUTE_RUN: 2373cdf0e10cSrcweir { 2374cdf0e10cSrcweir sal_uInt16 nStartIndex, nEndIndex; 2375cdf0e10cSrcweir 2376cdf0e10cSrcweir if( GetAttributeRun(nStartIndex, nEndIndex, nIndex) ) 2377cdf0e10cSrcweir { 2378cdf0e10cSrcweir // already at the right border? 2379cdf0e10cSrcweir if( nEndIndex < GetTextLen() ) 2380cdf0e10cSrcweir { 2381cdf0e10cSrcweir if( GetAttributeRun(nStartIndex, nEndIndex, nEndIndex) ) 2382cdf0e10cSrcweir { 2383cdf0e10cSrcweir aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex); 2384cdf0e10cSrcweir aResult.SegmentStart = nStartIndex; 2385cdf0e10cSrcweir aResult.SegmentEnd = nEndIndex; 2386cdf0e10cSrcweir } 2387cdf0e10cSrcweir } 2388cdf0e10cSrcweir } 2389cdf0e10cSrcweir break; 2390cdf0e10cSrcweir } 2391cdf0e10cSrcweir 23929b8096d0SSteve Yin //IAccessibility2 Implementation 2009----- 23939b8096d0SSteve Yin case AccessibleTextType::LINE: 23949b8096d0SSteve Yin { 23959b8096d0SSteve Yin SvxTextForwarder& rCacheTF = GetTextForwarder(); 23969b8096d0SSteve Yin sal_Int32 nParaIndex = GetParagraphIndex(); 23979b8096d0SSteve Yin // MT IA2 not needed? sal_Int32 nTextLen = rCacheTF.GetTextLen( static_cast< sal_uInt16 >( nParaIndex ) ); 23989b8096d0SSteve Yin 23999b8096d0SSteve Yin CheckPosition(nIndex); 24009b8096d0SSteve Yin 24019b8096d0SSteve Yin sal_uInt16 nLine, nLineCount=rCacheTF.GetLineCount( static_cast< sal_uInt16 >( nParaIndex ) ); 24029b8096d0SSteve Yin sal_Int32 nCurIndex; 24039b8096d0SSteve Yin //the problem is that rCacheTF.GetLineLen() will include the bullet length. But for the bullet line, 24049b8096d0SSteve Yin //the text value doesn't contain the bullet characters. all of the bullet and numbering info are exposed 24059b8096d0SSteve Yin //by the IAText::attributes(). So here must do special support for bullet line. 24069b8096d0SSteve Yin sal_Int32 nBulletLen = 0; 24079b8096d0SSteve Yin // get the line after the line the index points into 24089b8096d0SSteve Yin for( nLine=0, nCurIndex=0; nLine<nLineCount; ++nLine ) 24099b8096d0SSteve Yin { 24109b8096d0SSteve Yin if (nLine == 0) 24119b8096d0SSteve Yin { 24129b8096d0SSteve Yin EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 >(nParaIndex) ); 24139b8096d0SSteve Yin if (aBulletInfo.bVisible) 24149b8096d0SSteve Yin { 24159b8096d0SSteve Yin //in bullet or numbering; 24169b8096d0SSteve Yin nBulletLen = aBulletInfo.aText.Len(); 24179b8096d0SSteve Yin } 24189b8096d0SSteve Yin } 24199b8096d0SSteve Yin //nCurIndex += rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine); 24209b8096d0SSteve Yin sal_Int32 nLineLen = rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ), nLine); 24219b8096d0SSteve Yin 24229b8096d0SSteve Yin if (nLine == 0) 24239b8096d0SSteve Yin nCurIndex += nLineLen - nBulletLen; 24249b8096d0SSteve Yin else 24259b8096d0SSteve Yin nCurIndex += nLineLen; 24269b8096d0SSteve Yin 24279b8096d0SSteve Yin if( nCurIndex > nIndex && 24289b8096d0SSteve Yin nLine < nLineCount-1 ) 24299b8096d0SSteve Yin { 24309b8096d0SSteve Yin aResult.SegmentStart = nCurIndex; 24319b8096d0SSteve Yin aResult.SegmentEnd = nCurIndex + rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine+1); 24329b8096d0SSteve Yin aResult.SegmentText = GetTextRange( aResult.SegmentStart + nBulletLen, aResult.SegmentEnd + nBulletLen); 24339b8096d0SSteve Yin break; 24349b8096d0SSteve Yin } 24359b8096d0SSteve Yin } 24369b8096d0SSteve Yin 24379b8096d0SSteve Yin break; 24389b8096d0SSteve Yin } 24399b8096d0SSteve Yin case AccessibleTextType::WORD: 24409b8096d0SSteve Yin { 24419b8096d0SSteve Yin nIndex = SkipField( nIndex, sal_True); 24429b8096d0SSteve Yin ::rtl::OUString sText( implGetText() ); 24439b8096d0SSteve Yin sal_Int32 nLength = sText.getLength(); 24449b8096d0SSteve Yin 24459b8096d0SSteve Yin // get word at index 24469b8096d0SSteve Yin sal_Bool bWord = implGetWordBoundary( aBoundary, nIndex ); 24479b8096d0SSteve Yin 24489b8096d0SSteve Yin // real current world 24499b8096d0SSteve Yin sal_Int32 nextWord = nIndex; 24509b8096d0SSteve Yin //if( nIndex >= aBoundary.startPos && nIndex <= aBoundary.endPos ) 24519b8096d0SSteve Yin if( nIndex <= aBoundary.endPos ) 24529b8096d0SSteve Yin { 24539b8096d0SSteve Yin nextWord = aBoundary.endPos; 24549b8096d0SSteve Yin if( sText.getStr()[nextWord] == sal_Unicode(' ') ) nextWord++; 24559b8096d0SSteve Yin bWord = implGetWordBoundary( aBoundary, nextWord ); 24569b8096d0SSteve Yin } 24579b8096d0SSteve Yin 24589b8096d0SSteve Yin if ( bWord && implIsValidBoundary( aBoundary, nLength ) ) 24599b8096d0SSteve Yin { 24609b8096d0SSteve Yin aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos ); 24619b8096d0SSteve Yin aResult.SegmentStart = aBoundary.startPos; 24629b8096d0SSteve Yin aResult.SegmentEnd = aBoundary.endPos; 24639b8096d0SSteve Yin 24649b8096d0SSteve Yin // If the end position of aBoundary is inside a field, extend the result to the end of the field 24659b8096d0SSteve Yin 24669b8096d0SSteve Yin ExtendByField( aResult ); 24679b8096d0SSteve Yin } 24689b8096d0SSteve Yin } 24699b8096d0SSteve Yin break; 24709b8096d0SSteve Yin 24719b8096d0SSteve Yin case AccessibleTextType::CHARACTER: 24729b8096d0SSteve Yin { 24739b8096d0SSteve Yin nIndex = SkipField( nIndex, sal_True); 24749b8096d0SSteve Yin aResult = OCommonAccessibleText::getTextBehindIndex( nIndex, aTextType ); 24759b8096d0SSteve Yin ExtendByField( aResult ); 24769b8096d0SSteve Yin break; 24779b8096d0SSteve Yin } 24789b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009 2479cdf0e10cSrcweir default: 2480cdf0e10cSrcweir aResult = OCommonAccessibleText::getTextBehindIndex( nIndex, aTextType ); 2481cdf0e10cSrcweir break; 2482cdf0e10cSrcweir } /* end of switch( aTextType ) */ 2483cdf0e10cSrcweir 2484cdf0e10cSrcweir return aResult; 2485cdf0e10cSrcweir } 2486cdf0e10cSrcweir 2487cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleEditableTextPara::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 2488cdf0e10cSrcweir { 2489cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2490cdf0e10cSrcweir 2491cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2492cdf0e10cSrcweir 2493cdf0e10cSrcweir try 2494cdf0e10cSrcweir { 2495cdf0e10cSrcweir SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_True ); 2496cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 2497cdf0e10cSrcweir SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs 2498cdf0e10cSrcweir (void)rCacheTF; 2499cdf0e10cSrcweir #else 2500cdf0e10cSrcweir GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs 2501cdf0e10cSrcweir #endif 2502cdf0e10cSrcweir 2503cdf0e10cSrcweir sal_Bool aRetVal; 2504cdf0e10cSrcweir 2505cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2506cdf0e10cSrcweir "AccessibleEditableTextPara::copyText: index value overflow"); 2507cdf0e10cSrcweir 2508cdf0e10cSrcweir CheckRange(nStartIndex, nEndIndex); 2509cdf0e10cSrcweir 25109b8096d0SSteve Yin //Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet 25119b8096d0SSteve Yin sal_Int32 nBulletLen = 0; 25129b8096d0SSteve Yin EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 25139b8096d0SSteve Yin if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible ) 25149b8096d0SSteve Yin nBulletLen = aBulletInfo.aText.Len(); 2515cdf0e10cSrcweir // save current selection 2516cdf0e10cSrcweir ESelection aOldSelection; 2517cdf0e10cSrcweir 2518cdf0e10cSrcweir rCacheVF.GetSelection( aOldSelection ); 25199b8096d0SSteve Yin //rCacheVF.SetSelection( MakeSelection(nStartIndex, nEndIndex) ); 25209b8096d0SSteve Yin rCacheVF.SetSelection( MakeSelection(nStartIndex + nBulletLen, nEndIndex + nBulletLen) ); 2521cdf0e10cSrcweir aRetVal = rCacheVF.Copy(); 2522cdf0e10cSrcweir rCacheVF.SetSelection( aOldSelection ); // restore 2523cdf0e10cSrcweir 2524cdf0e10cSrcweir return aRetVal; 2525cdf0e10cSrcweir } 2526cdf0e10cSrcweir catch( const uno::RuntimeException& ) 2527cdf0e10cSrcweir { 2528cdf0e10cSrcweir return sal_False; 2529cdf0e10cSrcweir } 2530cdf0e10cSrcweir } 2531cdf0e10cSrcweir 2532cdf0e10cSrcweir // XAccessibleEditableText 2533cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleEditableTextPara::cutText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 2534cdf0e10cSrcweir { 2535cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2536cdf0e10cSrcweir 2537cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2538cdf0e10cSrcweir 2539cdf0e10cSrcweir try 2540cdf0e10cSrcweir { 2541cdf0e10cSrcweir SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_True ); 2542cdf0e10cSrcweir SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs 2543cdf0e10cSrcweir 2544cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2545cdf0e10cSrcweir "AccessibleEditableTextPara::cutText: index value overflow"); 2546cdf0e10cSrcweir 2547cdf0e10cSrcweir CheckRange(nStartIndex, nEndIndex); 2548cdf0e10cSrcweir 25499b8096d0SSteve Yin // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet 25509b8096d0SSteve Yin sal_Int32 nBulletLen = 0; 25519b8096d0SSteve Yin EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 25529b8096d0SSteve Yin if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible ) 25539b8096d0SSteve Yin nBulletLen = aBulletInfo.aText.Len(); 25549b8096d0SSteve Yin ESelection aSelection = MakeSelection (nStartIndex + nBulletLen, nEndIndex + nBulletLen); 25559b8096d0SSteve Yin //if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) ) 25569b8096d0SSteve Yin if( !rCacheTF.IsEditable( aSelection ) ) 2557cdf0e10cSrcweir return sal_False; // non-editable area selected 2558cdf0e10cSrcweir 2559cdf0e10cSrcweir // don't save selection, might become invalid after cut! 25609b8096d0SSteve Yin //rCacheVF.SetSelection( MakeSelection(nStartIndex, nEndIndex) ); 25619b8096d0SSteve Yin rCacheVF.SetSelection( aSelection ); 2562cdf0e10cSrcweir 2563cdf0e10cSrcweir return rCacheVF.Cut(); 2564cdf0e10cSrcweir } 2565cdf0e10cSrcweir catch( const uno::RuntimeException& ) 2566cdf0e10cSrcweir { 2567cdf0e10cSrcweir return sal_False; 2568cdf0e10cSrcweir } 2569cdf0e10cSrcweir } 2570cdf0e10cSrcweir 2571cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleEditableTextPara::pasteText( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 2572cdf0e10cSrcweir { 2573cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2574cdf0e10cSrcweir 2575cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2576cdf0e10cSrcweir 2577cdf0e10cSrcweir try 2578cdf0e10cSrcweir { 2579cdf0e10cSrcweir SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_True ); 2580cdf0e10cSrcweir SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs 2581cdf0e10cSrcweir 2582cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2583cdf0e10cSrcweir "AccessibleEditableTextPara::pasteText: index value overflow"); 2584cdf0e10cSrcweir 2585cdf0e10cSrcweir CheckPosition(nIndex); 2586cdf0e10cSrcweir 25879b8096d0SSteve Yin // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet 25889b8096d0SSteve Yin sal_Int32 nBulletLen = 0; 25899b8096d0SSteve Yin EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 25909b8096d0SSteve Yin if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible ) 25919b8096d0SSteve Yin nBulletLen = aBulletInfo.aText.Len(); 25929b8096d0SSteve Yin //if( !rCacheTF.IsEditable( MakeSelection(nIndex) ) ) 25939b8096d0SSteve Yin if( !rCacheTF.IsEditable( MakeSelection(nIndex + nBulletLen) ) ) 2594cdf0e10cSrcweir return sal_False; // non-editable area selected 2595cdf0e10cSrcweir 2596cdf0e10cSrcweir // #104400# set empty selection (=> cursor) to given index 25979b8096d0SSteve Yin //rCacheVF.SetSelection( MakeCursor(nIndex) ); 25989b8096d0SSteve Yin rCacheVF.SetSelection( MakeCursor(nIndex + nBulletLen) ); 2599cdf0e10cSrcweir 2600cdf0e10cSrcweir return rCacheVF.Paste(); 2601cdf0e10cSrcweir } 2602cdf0e10cSrcweir catch( const uno::RuntimeException& ) 2603cdf0e10cSrcweir { 2604cdf0e10cSrcweir return sal_False; 2605cdf0e10cSrcweir } 2606cdf0e10cSrcweir } 2607cdf0e10cSrcweir 2608cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleEditableTextPara::deleteText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 2609cdf0e10cSrcweir { 2610cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2611cdf0e10cSrcweir 2612cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2613cdf0e10cSrcweir 2614cdf0e10cSrcweir try 2615cdf0e10cSrcweir { 2616cdf0e10cSrcweir // #102710# Request edit view when doing changes 2617cdf0e10cSrcweir // AccessibleEmptyEditSource relies on this behaviour 2618cdf0e10cSrcweir GetEditViewForwarder( sal_True ); 2619cdf0e10cSrcweir SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs 2620cdf0e10cSrcweir 2621cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2622cdf0e10cSrcweir "AccessibleEditableTextPara::deleteText: index value overflow"); 2623cdf0e10cSrcweir 2624cdf0e10cSrcweir CheckRange(nStartIndex, nEndIndex); 2625cdf0e10cSrcweir 26269b8096d0SSteve Yin // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet 26279b8096d0SSteve Yin sal_Int32 nBulletLen = 0; 26289b8096d0SSteve Yin EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 26299b8096d0SSteve Yin if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible ) 26309b8096d0SSteve Yin nBulletLen = aBulletInfo.aText.Len(); 26319b8096d0SSteve Yin ESelection aSelection = MakeSelection (nStartIndex + nBulletLen, nEndIndex + nBulletLen); 26329b8096d0SSteve Yin 26339b8096d0SSteve Yin //if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) ) 26349b8096d0SSteve Yin if( !rCacheTF.IsEditable( aSelection ) ) 2635cdf0e10cSrcweir return sal_False; // non-editable area selected 2636cdf0e10cSrcweir 26379b8096d0SSteve Yin //sal_Bool bRet = rCacheTF.Delete( MakeSelection(nStartIndex, nEndIndex) ); 26389b8096d0SSteve Yin sal_Bool bRet = rCacheTF.Delete( aSelection ); 2639cdf0e10cSrcweir 2640cdf0e10cSrcweir GetEditSource().UpdateData(); 2641cdf0e10cSrcweir 2642cdf0e10cSrcweir return bRet; 2643cdf0e10cSrcweir } 2644cdf0e10cSrcweir catch( const uno::RuntimeException& ) 2645cdf0e10cSrcweir { 2646cdf0e10cSrcweir return sal_False; 2647cdf0e10cSrcweir } 2648cdf0e10cSrcweir } 2649cdf0e10cSrcweir 2650cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleEditableTextPara::insertText( const ::rtl::OUString& sText, sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 2651cdf0e10cSrcweir { 2652cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2653cdf0e10cSrcweir 2654cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2655cdf0e10cSrcweir 2656cdf0e10cSrcweir try 2657cdf0e10cSrcweir { 2658cdf0e10cSrcweir // #102710# Request edit view when doing changes 2659cdf0e10cSrcweir // AccessibleEmptyEditSource relies on this behaviour 2660cdf0e10cSrcweir GetEditViewForwarder( sal_True ); 2661cdf0e10cSrcweir SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs 2662cdf0e10cSrcweir 2663cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2664cdf0e10cSrcweir "AccessibleEditableTextPara::insertText: index value overflow"); 2665cdf0e10cSrcweir 2666cdf0e10cSrcweir CheckPosition(nIndex); 2667cdf0e10cSrcweir 26689b8096d0SSteve Yin // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet 26699b8096d0SSteve Yin sal_Int32 nBulletLen = 0; 26709b8096d0SSteve Yin EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 26719b8096d0SSteve Yin if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible ) 26729b8096d0SSteve Yin nBulletLen = aBulletInfo.aText.Len(); 26739b8096d0SSteve Yin 26749b8096d0SSteve Yin //if( !rCacheTF.IsEditable( MakeSelection(nIndex) ) ) 26759b8096d0SSteve Yin if( !rCacheTF.IsEditable( MakeSelection(nIndex + nBulletLen) ) ) 2676cdf0e10cSrcweir return sal_False; // non-editable area selected 2677cdf0e10cSrcweir 2678cdf0e10cSrcweir // #104400# insert given text at empty selection (=> cursor) 26799b8096d0SSteve Yin //sal_Bool bRet = rCacheTF.InsertText( sText, MakeCursor(nIndex) ); 26809b8096d0SSteve Yin sal_Bool bRet = rCacheTF.InsertText( sText, MakeCursor(nIndex + nBulletLen) ); 2681cdf0e10cSrcweir 2682cdf0e10cSrcweir rCacheTF.QuickFormatDoc(); 2683cdf0e10cSrcweir GetEditSource().UpdateData(); 2684cdf0e10cSrcweir 2685cdf0e10cSrcweir return bRet; 2686cdf0e10cSrcweir } 2687cdf0e10cSrcweir catch( const uno::RuntimeException& ) 2688cdf0e10cSrcweir { 2689cdf0e10cSrcweir return sal_False; 2690cdf0e10cSrcweir } 2691cdf0e10cSrcweir } 2692cdf0e10cSrcweir 2693cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleEditableTextPara::replaceText( sal_Int32 nStartIndex, sal_Int32 nEndIndex, const ::rtl::OUString& sReplacement ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 2694cdf0e10cSrcweir { 2695cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2696cdf0e10cSrcweir 2697cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2698cdf0e10cSrcweir 2699cdf0e10cSrcweir try 2700cdf0e10cSrcweir { 2701cdf0e10cSrcweir // #102710# Request edit view when doing changes 2702cdf0e10cSrcweir // AccessibleEmptyEditSource relies on this behaviour 2703cdf0e10cSrcweir GetEditViewForwarder( sal_True ); 2704cdf0e10cSrcweir SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs 2705cdf0e10cSrcweir 2706cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2707cdf0e10cSrcweir "AccessibleEditableTextPara::replaceText: index value overflow"); 2708cdf0e10cSrcweir 2709cdf0e10cSrcweir CheckRange(nStartIndex, nEndIndex); 2710cdf0e10cSrcweir 27119b8096d0SSteve Yin // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet 27129b8096d0SSteve Yin sal_Int32 nBulletLen = 0; 27139b8096d0SSteve Yin EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 27149b8096d0SSteve Yin if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible ) 27159b8096d0SSteve Yin nBulletLen = aBulletInfo.aText.Len(); 27169b8096d0SSteve Yin ESelection aSelection = MakeSelection (nStartIndex + nBulletLen, nEndIndex + nBulletLen); 27179b8096d0SSteve Yin 27189b8096d0SSteve Yin //if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) ) 27199b8096d0SSteve Yin if( !rCacheTF.IsEditable( aSelection ) ) 2720cdf0e10cSrcweir return sal_False; // non-editable area selected 2721cdf0e10cSrcweir 2722cdf0e10cSrcweir // insert given text into given range => replace 27239b8096d0SSteve Yin //sal_Bool bRet = rCacheTF.InsertText( sReplacement, MakeSelection(nStartIndex, nEndIndex) ); 27249b8096d0SSteve Yin sal_Bool bRet = rCacheTF.InsertText( sReplacement, aSelection ); 2725cdf0e10cSrcweir 2726cdf0e10cSrcweir rCacheTF.QuickFormatDoc(); 2727cdf0e10cSrcweir GetEditSource().UpdateData(); 2728cdf0e10cSrcweir 2729cdf0e10cSrcweir return bRet; 2730cdf0e10cSrcweir } 2731cdf0e10cSrcweir catch( const uno::RuntimeException& ) 2732cdf0e10cSrcweir { 2733cdf0e10cSrcweir return sal_False; 2734cdf0e10cSrcweir } 2735cdf0e10cSrcweir } 2736cdf0e10cSrcweir 2737cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleEditableTextPara::setAttributes( sal_Int32 nStartIndex, sal_Int32 nEndIndex, const uno::Sequence< beans::PropertyValue >& aAttributeSet ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 2738cdf0e10cSrcweir { 2739cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2740cdf0e10cSrcweir 2741cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2742cdf0e10cSrcweir 2743cdf0e10cSrcweir try 2744cdf0e10cSrcweir { 2745cdf0e10cSrcweir // #102710# Request edit view when doing changes 2746cdf0e10cSrcweir // AccessibleEmptyEditSource relies on this behaviour 2747cdf0e10cSrcweir GetEditViewForwarder( sal_True ); 2748cdf0e10cSrcweir SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs 2749cdf0e10cSrcweir sal_uInt16 nPara = static_cast< sal_uInt16 >( GetParagraphIndex() ); 2750cdf0e10cSrcweir 2751cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2752cdf0e10cSrcweir "AccessibleEditableTextPara::setAttributes: index value overflow"); 2753cdf0e10cSrcweir 2754cdf0e10cSrcweir CheckRange(nStartIndex, nEndIndex); 2755cdf0e10cSrcweir 2756cdf0e10cSrcweir if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) ) 2757cdf0e10cSrcweir return sal_False; // non-editable area selected 2758cdf0e10cSrcweir 2759cdf0e10cSrcweir // do the indices span the whole paragraph? Then use the outliner map 2760cdf0e10cSrcweir // TODO: hold it as a member? 2761cdf0e10cSrcweir SvxAccessibleTextPropertySet aPropSet( &GetEditSource(), 2762cdf0e10cSrcweir 0 == nStartIndex && 2763cdf0e10cSrcweir rCacheTF.GetTextLen(nPara) == nEndIndex ? 2764cdf0e10cSrcweir ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() : 2765cdf0e10cSrcweir ImplGetSvxTextPortionSvxPropertySet() ); 2766cdf0e10cSrcweir 2767cdf0e10cSrcweir aPropSet.SetSelection( MakeSelection(nStartIndex, nEndIndex) ); 2768cdf0e10cSrcweir 2769cdf0e10cSrcweir // convert from PropertyValue to Any 2770cdf0e10cSrcweir sal_Int32 i, nLength( aAttributeSet.getLength() ); 2771cdf0e10cSrcweir const beans::PropertyValue* pPropArray = aAttributeSet.getConstArray(); 2772cdf0e10cSrcweir for(i=0; i<nLength; ++i) 2773cdf0e10cSrcweir { 2774cdf0e10cSrcweir try 2775cdf0e10cSrcweir { 2776cdf0e10cSrcweir aPropSet.setPropertyValue(pPropArray->Name, pPropArray->Value); 2777cdf0e10cSrcweir } 2778cdf0e10cSrcweir catch( const uno::Exception& ) 2779cdf0e10cSrcweir { 2780cdf0e10cSrcweir DBG_ERROR("AccessibleEditableTextPara::setAttributes exception in setPropertyValue"); 2781cdf0e10cSrcweir } 2782cdf0e10cSrcweir 2783cdf0e10cSrcweir ++pPropArray; 2784cdf0e10cSrcweir } 2785cdf0e10cSrcweir 2786cdf0e10cSrcweir rCacheTF.QuickFormatDoc(); 2787cdf0e10cSrcweir GetEditSource().UpdateData(); 2788cdf0e10cSrcweir 2789cdf0e10cSrcweir return sal_True; 2790cdf0e10cSrcweir } 2791cdf0e10cSrcweir catch( const uno::RuntimeException& ) 2792cdf0e10cSrcweir { 2793cdf0e10cSrcweir return sal_False; 2794cdf0e10cSrcweir } 2795cdf0e10cSrcweir } 2796cdf0e10cSrcweir 2797cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleEditableTextPara::setText( const ::rtl::OUString& sText ) throw (uno::RuntimeException) 2798cdf0e10cSrcweir { 2799cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2800cdf0e10cSrcweir 2801cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2802cdf0e10cSrcweir 2803cdf0e10cSrcweir return replaceText(0, getCharacterCount(), sText); 2804cdf0e10cSrcweir } 2805cdf0e10cSrcweir 2806cdf0e10cSrcweir // XAccessibleTextAttributes 2807cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > SAL_CALL AccessibleEditableTextPara::getDefaultAttributes( 2808cdf0e10cSrcweir const uno::Sequence< ::rtl::OUString >& rRequestedAttributes ) 2809cdf0e10cSrcweir throw (uno::RuntimeException) 2810cdf0e10cSrcweir { 2811cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2812cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2813cdf0e10cSrcweir 2814cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 2815cdf0e10cSrcweir SvxAccessibleTextAdapter& rCacheTF = 2816cdf0e10cSrcweir #endif 2817cdf0e10cSrcweir GetTextForwarder(); 2818cdf0e10cSrcweir 2819cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 2820cdf0e10cSrcweir (void)rCacheTF; 2821cdf0e10cSrcweir #endif 2822cdf0e10cSrcweir 2823cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2824cdf0e10cSrcweir "AccessibleEditableTextPara::getCharacterAttributes: index value overflow"); 2825cdf0e10cSrcweir 2826cdf0e10cSrcweir // get XPropertySetInfo for paragraph attributes and 2827cdf0e10cSrcweir // character attributes that span all the paragraphs text. 2828cdf0e10cSrcweir SvxAccessibleTextPropertySet aPropSet( &GetEditSource(), 2829cdf0e10cSrcweir ImplGetSvxCharAndParaPropertiesSet() ); 2830cdf0e10cSrcweir aPropSet.SetSelection( MakeSelection( 0, GetTextLen() ) ); 2831cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > xPropSetInfo = aPropSet.getPropertySetInfo(); 2832cdf0e10cSrcweir if (!xPropSetInfo.is()) 2833cdf0e10cSrcweir throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Cannot query XPropertySetInfo")), 2834cdf0e10cSrcweir uno::Reference< uno::XInterface > 2835cdf0e10cSrcweir ( static_cast< XAccessible* > (this) ) ); // disambiguate hierarchy 2836cdf0e10cSrcweir 2837cdf0e10cSrcweir // build sequence of available properties to check 2838cdf0e10cSrcweir sal_Int32 nLenReqAttr = rRequestedAttributes.getLength(); 2839cdf0e10cSrcweir uno::Sequence< beans::Property > aProperties; 2840cdf0e10cSrcweir if (nLenReqAttr) 2841cdf0e10cSrcweir { 2842cdf0e10cSrcweir const rtl::OUString *pRequestedAttributes = rRequestedAttributes.getConstArray(); 2843cdf0e10cSrcweir 2844cdf0e10cSrcweir aProperties.realloc( nLenReqAttr ); 2845cdf0e10cSrcweir beans::Property *pProperties = aProperties.getArray(); 2846cdf0e10cSrcweir sal_Int32 nCurLen = 0; 2847cdf0e10cSrcweir for (sal_Int32 i = 0; i < nLenReqAttr; ++i) 2848cdf0e10cSrcweir { 2849cdf0e10cSrcweir beans::Property aProp; 2850cdf0e10cSrcweir try 2851cdf0e10cSrcweir { 2852cdf0e10cSrcweir aProp = xPropSetInfo->getPropertyByName( pRequestedAttributes[i] ); 2853cdf0e10cSrcweir } 2854cdf0e10cSrcweir catch (beans::UnknownPropertyException &) 2855cdf0e10cSrcweir { 2856cdf0e10cSrcweir continue; 2857cdf0e10cSrcweir } 2858cdf0e10cSrcweir pProperties[ nCurLen++ ] = aProp; 2859cdf0e10cSrcweir } 2860cdf0e10cSrcweir aProperties.realloc( nCurLen ); 2861cdf0e10cSrcweir } 2862cdf0e10cSrcweir else 2863cdf0e10cSrcweir aProperties = xPropSetInfo->getProperties(); 2864cdf0e10cSrcweir 2865cdf0e10cSrcweir sal_Int32 nLength = aProperties.getLength(); 2866cdf0e10cSrcweir const beans::Property *pProperties = aProperties.getConstArray(); 2867cdf0e10cSrcweir 2868cdf0e10cSrcweir // build resulting sequence 2869cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aOutSequence( nLength ); 2870cdf0e10cSrcweir beans::PropertyValue* pOutSequence = aOutSequence.getArray(); 2871cdf0e10cSrcweir sal_Int32 nOutLen = 0; 2872cdf0e10cSrcweir for (sal_Int32 i = 0; i < nLength; ++i) 2873cdf0e10cSrcweir { 2874cdf0e10cSrcweir // calling implementation functions: 2875cdf0e10cSrcweir // _getPropertyState and _getPropertyValue (see below) to provide 2876cdf0e10cSrcweir // the proper paragraph number when retrieving paragraph attributes 2877cdf0e10cSrcweir PropertyState eState = aPropSet._getPropertyState( pProperties->Name, mnParagraphIndex ); 2878cdf0e10cSrcweir if ( eState == PropertyState_AMBIGUOUS_VALUE ) 2879cdf0e10cSrcweir { 2880cdf0e10cSrcweir OSL_ENSURE( false, "ambiguous property value encountered" ); 2881cdf0e10cSrcweir } 2882cdf0e10cSrcweir 2883cdf0e10cSrcweir //if (eState == PropertyState_DIRECT_VALUE) 2884cdf0e10cSrcweir // per definition all paragraph properties and all character 2885cdf0e10cSrcweir // properties spanning the whole paragraph should be returned 2886cdf0e10cSrcweir // and declared as default value 2887cdf0e10cSrcweir { 2888cdf0e10cSrcweir pOutSequence->Name = pProperties->Name; 2889cdf0e10cSrcweir pOutSequence->Handle = pProperties->Handle; 2890cdf0e10cSrcweir pOutSequence->Value = aPropSet._getPropertyValue( pProperties->Name, mnParagraphIndex ); 2891cdf0e10cSrcweir pOutSequence->State = PropertyState_DEFAULT_VALUE; 2892cdf0e10cSrcweir 2893cdf0e10cSrcweir ++pOutSequence; 2894cdf0e10cSrcweir ++nOutLen; 2895cdf0e10cSrcweir } 2896cdf0e10cSrcweir ++pProperties; 2897cdf0e10cSrcweir } 2898cdf0e10cSrcweir aOutSequence.realloc( nOutLen ); 2899cdf0e10cSrcweir 2900cdf0e10cSrcweir return aOutSequence; 2901cdf0e10cSrcweir } 2902cdf0e10cSrcweir 2903cdf0e10cSrcweir 2904cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > SAL_CALL AccessibleEditableTextPara::getRunAttributes( 2905cdf0e10cSrcweir sal_Int32 nIndex, 2906cdf0e10cSrcweir const uno::Sequence< ::rtl::OUString >& rRequestedAttributes ) 2907cdf0e10cSrcweir throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 2908cdf0e10cSrcweir { 2909cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2910cdf0e10cSrcweir 2911cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2912cdf0e10cSrcweir 2913cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 2914cdf0e10cSrcweir SvxAccessibleTextAdapter& rCacheTF = 2915cdf0e10cSrcweir #endif 2916cdf0e10cSrcweir GetTextForwarder(); 2917cdf0e10cSrcweir 2918cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 2919cdf0e10cSrcweir (void)rCacheTF; 2920cdf0e10cSrcweir #endif 2921cdf0e10cSrcweir 2922cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2923cdf0e10cSrcweir "AccessibleEditableTextPara::getCharacterAttributes: index value overflow"); 2924cdf0e10cSrcweir 29259b8096d0SSteve Yin if( getCharacterCount() > 0 ) 2926cdf0e10cSrcweir CheckIndex(nIndex); 29279b8096d0SSteve Yin else 29289b8096d0SSteve Yin CheckPosition(nIndex); 2929cdf0e10cSrcweir 2930cdf0e10cSrcweir SvxAccessibleTextPropertySet aPropSet( &GetEditSource(), 2931cdf0e10cSrcweir ImplGetSvxCharAndParaPropertiesSet() ); 2932cdf0e10cSrcweir aPropSet.SetSelection( MakeSelection( nIndex ) ); 2933cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > xPropSetInfo = aPropSet.getPropertySetInfo(); 2934cdf0e10cSrcweir if (!xPropSetInfo.is()) 2935cdf0e10cSrcweir throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Cannot query XPropertySetInfo")), 2936cdf0e10cSrcweir uno::Reference< uno::XInterface > 2937cdf0e10cSrcweir ( static_cast< XAccessible* > (this) ) ); // disambiguate hierarchy 2938cdf0e10cSrcweir 2939cdf0e10cSrcweir // build sequence of available properties to check 2940cdf0e10cSrcweir sal_Int32 nLenReqAttr = rRequestedAttributes.getLength(); 2941cdf0e10cSrcweir uno::Sequence< beans::Property > aProperties; 2942cdf0e10cSrcweir if (nLenReqAttr) 2943cdf0e10cSrcweir { 2944cdf0e10cSrcweir const rtl::OUString *pRequestedAttributes = rRequestedAttributes.getConstArray(); 2945cdf0e10cSrcweir 2946cdf0e10cSrcweir aProperties.realloc( nLenReqAttr ); 2947cdf0e10cSrcweir beans::Property *pProperties = aProperties.getArray(); 2948cdf0e10cSrcweir sal_Int32 nCurLen = 0; 2949cdf0e10cSrcweir for (sal_Int32 i = 0; i < nLenReqAttr; ++i) 2950cdf0e10cSrcweir { 2951cdf0e10cSrcweir beans::Property aProp; 2952cdf0e10cSrcweir try 2953cdf0e10cSrcweir { 2954cdf0e10cSrcweir aProp = xPropSetInfo->getPropertyByName( pRequestedAttributes[i] ); 2955cdf0e10cSrcweir } 2956cdf0e10cSrcweir catch (beans::UnknownPropertyException &) 2957cdf0e10cSrcweir { 2958cdf0e10cSrcweir continue; 2959cdf0e10cSrcweir } 2960cdf0e10cSrcweir pProperties[ nCurLen++ ] = aProp; 2961cdf0e10cSrcweir } 2962cdf0e10cSrcweir aProperties.realloc( nCurLen ); 2963cdf0e10cSrcweir } 2964cdf0e10cSrcweir else 2965cdf0e10cSrcweir aProperties = xPropSetInfo->getProperties(); 2966cdf0e10cSrcweir 2967cdf0e10cSrcweir sal_Int32 nLength = aProperties.getLength(); 2968cdf0e10cSrcweir const beans::Property *pProperties = aProperties.getConstArray(); 2969cdf0e10cSrcweir 2970cdf0e10cSrcweir // build resulting sequence 2971cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aOutSequence( nLength ); 2972cdf0e10cSrcweir beans::PropertyValue* pOutSequence = aOutSequence.getArray(); 2973cdf0e10cSrcweir sal_Int32 nOutLen = 0; 2974cdf0e10cSrcweir for (sal_Int32 i = 0; i < nLength; ++i) 2975cdf0e10cSrcweir { 2976cdf0e10cSrcweir // calling 'regular' functions that will operate on the selection 2977cdf0e10cSrcweir PropertyState eState = aPropSet.getPropertyState( pProperties->Name ); 2978cdf0e10cSrcweir if (eState == PropertyState_DIRECT_VALUE) 2979cdf0e10cSrcweir { 2980cdf0e10cSrcweir pOutSequence->Name = pProperties->Name; 2981cdf0e10cSrcweir pOutSequence->Handle = pProperties->Handle; 2982cdf0e10cSrcweir pOutSequence->Value = aPropSet.getPropertyValue( pProperties->Name ); 2983cdf0e10cSrcweir pOutSequence->State = eState; 2984cdf0e10cSrcweir 2985cdf0e10cSrcweir ++pOutSequence; 2986cdf0e10cSrcweir ++nOutLen; 2987cdf0e10cSrcweir } 2988cdf0e10cSrcweir ++pProperties; 2989cdf0e10cSrcweir } 2990cdf0e10cSrcweir aOutSequence.realloc( nOutLen ); 2991cdf0e10cSrcweir 2992cdf0e10cSrcweir return aOutSequence; 2993cdf0e10cSrcweir } 2994cdf0e10cSrcweir 2995cdf0e10cSrcweir // XAccessibleHypertext 2996cdf0e10cSrcweir ::sal_Int32 SAL_CALL AccessibleEditableTextPara::getHyperLinkCount( ) throw (::com::sun::star::uno::RuntimeException) 2997cdf0e10cSrcweir { 2998cdf0e10cSrcweir SvxAccessibleTextAdapter& rT = GetTextForwarder(); 2999cdf0e10cSrcweir const sal_Int32 nPara = GetParagraphIndex(); 3000cdf0e10cSrcweir 3001cdf0e10cSrcweir sal_uInt16 nHyperLinks = 0; 3002cdf0e10cSrcweir sal_uInt16 nFields = rT.GetFieldCount( nPara ); 3003cdf0e10cSrcweir for ( sal_uInt16 n = 0; n < nFields; n++ ) 3004cdf0e10cSrcweir { 3005cdf0e10cSrcweir EFieldInfo aField = rT.GetFieldInfo( nPara, n ); 3006cdf0e10cSrcweir if ( aField.pFieldItem->GetField()->ISA( SvxURLField ) ) 3007cdf0e10cSrcweir nHyperLinks++; 3008cdf0e10cSrcweir } 3009cdf0e10cSrcweir return nHyperLinks; 3010cdf0e10cSrcweir } 3011cdf0e10cSrcweir 3012cdf0e10cSrcweir ::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) 3013cdf0e10cSrcweir { 3014cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleHyperlink > xRef; 3015cdf0e10cSrcweir 3016cdf0e10cSrcweir SvxAccessibleTextAdapter& rT = GetTextForwarder(); 3017cdf0e10cSrcweir const sal_Int32 nPara = GetParagraphIndex(); 3018cdf0e10cSrcweir 3019cdf0e10cSrcweir sal_uInt16 nHyperLink = 0; 3020cdf0e10cSrcweir sal_uInt16 nFields = rT.GetFieldCount( nPara ); 3021cdf0e10cSrcweir for ( sal_uInt16 n = 0; n < nFields; n++ ) 3022cdf0e10cSrcweir { 3023cdf0e10cSrcweir EFieldInfo aField = rT.GetFieldInfo( nPara, n ); 3024cdf0e10cSrcweir if ( aField.pFieldItem->GetField()->ISA( SvxURLField ) ) 3025cdf0e10cSrcweir { 3026cdf0e10cSrcweir if ( nHyperLink == nLinkIndex ) 3027cdf0e10cSrcweir { 3028cdf0e10cSrcweir sal_uInt16 nEEStart = aField.aPosition.nIndex; 3029cdf0e10cSrcweir 3030cdf0e10cSrcweir // Translate EE Index to accessible index 3031cdf0e10cSrcweir sal_uInt16 nStart = rT.CalcEditEngineIndex( nPara, nEEStart ); 3032cdf0e10cSrcweir sal_uInt16 nEnd = nStart + aField.aCurrentText.Len(); 3033cdf0e10cSrcweir xRef = new AccessibleHyperlink( rT, new SvxFieldItem( *aField.pFieldItem ), nPara, nEEStart, nStart, nEnd, aField.aCurrentText ); 3034cdf0e10cSrcweir break; 3035cdf0e10cSrcweir } 3036cdf0e10cSrcweir nHyperLink++; 3037cdf0e10cSrcweir } 3038cdf0e10cSrcweir } 3039cdf0e10cSrcweir 3040cdf0e10cSrcweir return xRef; 3041cdf0e10cSrcweir } 3042cdf0e10cSrcweir 3043cdf0e10cSrcweir ::sal_Int32 SAL_CALL AccessibleEditableTextPara::getHyperLinkIndex( ::sal_Int32 nCharIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) 3044cdf0e10cSrcweir { 3045cdf0e10cSrcweir const sal_Int32 nPara = GetParagraphIndex(); 3046cdf0e10cSrcweir SvxAccessibleTextAdapter& rT = GetTextForwarder(); 3047cdf0e10cSrcweir 3048cdf0e10cSrcweir // SvxAccessibleTextIndex aIndex; 3049cdf0e10cSrcweir // aIndex.SetIndex(nPara, nCharIndex, rT); 3050cdf0e10cSrcweir // const sal_uInt16 nEEIndex = aIndex.GetEEIndex(); 3051cdf0e10cSrcweir 3052cdf0e10cSrcweir const sal_uInt16 nEEIndex = rT.CalcEditEngineIndex( nPara, nCharIndex ); 3053cdf0e10cSrcweir sal_Int32 nHLIndex = 0; 3054cdf0e10cSrcweir sal_uInt16 nHyperLink = 0; 3055cdf0e10cSrcweir sal_uInt16 nFields = rT.GetFieldCount( nPara ); 3056cdf0e10cSrcweir for ( sal_uInt16 n = 0; n < nFields; n++ ) 3057cdf0e10cSrcweir { 3058cdf0e10cSrcweir EFieldInfo aField = rT.GetFieldInfo( nPara, n ); 3059cdf0e10cSrcweir if ( aField.pFieldItem->GetField()->ISA( SvxURLField ) ) 3060cdf0e10cSrcweir { 3061cdf0e10cSrcweir if ( aField.aPosition.nIndex == nEEIndex ) 3062cdf0e10cSrcweir { 3063cdf0e10cSrcweir nHLIndex = nHyperLink; 3064cdf0e10cSrcweir break; 3065cdf0e10cSrcweir } 3066cdf0e10cSrcweir nHyperLink++; 3067cdf0e10cSrcweir } 3068cdf0e10cSrcweir } 3069cdf0e10cSrcweir 3070cdf0e10cSrcweir return nHLIndex; 3071cdf0e10cSrcweir } 3072cdf0e10cSrcweir 3073cdf0e10cSrcweir // XAccessibleMultiLineText 3074cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleEditableTextPara::getLineNumberAtIndex( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 3075cdf0e10cSrcweir { 3076cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 3077cdf0e10cSrcweir 3078cdf0e10cSrcweir sal_Int32 nRes = -1; 3079cdf0e10cSrcweir sal_Int32 nPara = GetParagraphIndex(); 3080cdf0e10cSrcweir 3081cdf0e10cSrcweir SvxTextForwarder &rCacheTF = GetTextForwarder(); 3082cdf0e10cSrcweir const bool bValidPara = 0 <= nPara && nPara < rCacheTF.GetParagraphCount(); 3083cdf0e10cSrcweir DBG_ASSERT( bValidPara, "getLineNumberAtIndex: current paragraph index out of range" ); 3084cdf0e10cSrcweir if (bValidPara) 3085cdf0e10cSrcweir { 3086cdf0e10cSrcweir // we explicitly allow for the index to point at the character right behind the text 3087cdf0e10cSrcweir if (0 <= nIndex && nIndex <= rCacheTF.GetTextLen( static_cast< sal_uInt16 >(nPara) )) 3088cdf0e10cSrcweir nRes = rCacheTF.GetLineNumberAtIndex( static_cast< sal_uInt16 >(nPara), static_cast< sal_uInt16 >(nIndex) ); 3089cdf0e10cSrcweir else 3090cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 3091cdf0e10cSrcweir } 3092cdf0e10cSrcweir return nRes; 3093cdf0e10cSrcweir } 3094cdf0e10cSrcweir 3095cdf0e10cSrcweir // XAccessibleMultiLineText 3096cdf0e10cSrcweir ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextAtLineNumber( sal_Int32 nLineNo ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 3097cdf0e10cSrcweir { 3098cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 3099cdf0e10cSrcweir 3100cdf0e10cSrcweir ::com::sun::star::accessibility::TextSegment aResult; 3101cdf0e10cSrcweir sal_Int32 nPara = GetParagraphIndex(); 3102cdf0e10cSrcweir SvxTextForwarder &rCacheTF = GetTextForwarder(); 3103cdf0e10cSrcweir const bool bValidPara = 0 <= nPara && nPara < rCacheTF.GetParagraphCount(); 3104cdf0e10cSrcweir DBG_ASSERT( bValidPara, "getTextAtLineNumber: current paragraph index out of range" ); 3105cdf0e10cSrcweir if (bValidPara) 3106cdf0e10cSrcweir { 3107cdf0e10cSrcweir if (0 <= nLineNo && nLineNo < rCacheTF.GetLineCount( static_cast< sal_uInt16 >(nPara) )) 3108cdf0e10cSrcweir { 3109cdf0e10cSrcweir sal_uInt16 nStart = 0, nEnd = 0; 3110cdf0e10cSrcweir rCacheTF.GetLineBoundaries( nStart, nEnd, static_cast< sal_uInt16 >(nPara), static_cast< sal_uInt16 >(nLineNo) ); 3111cdf0e10cSrcweir if (nStart != 0xFFFF && nEnd != 0xFFFF) 3112cdf0e10cSrcweir { 3113cdf0e10cSrcweir try 3114cdf0e10cSrcweir { 3115cdf0e10cSrcweir aResult.SegmentText = getTextRange( nStart, nEnd ); 3116cdf0e10cSrcweir aResult.SegmentStart = nStart; 3117cdf0e10cSrcweir aResult.SegmentEnd = nEnd; 3118cdf0e10cSrcweir } 3119cdf0e10cSrcweir catch (lang::IndexOutOfBoundsException) 3120cdf0e10cSrcweir { 3121cdf0e10cSrcweir // this is not the exception that should be raised in this function ... 3122cdf0e10cSrcweir DBG_ASSERT( 0, "unexpected exception" ); 3123cdf0e10cSrcweir } 3124cdf0e10cSrcweir } 3125cdf0e10cSrcweir } 3126cdf0e10cSrcweir else 3127cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 3128cdf0e10cSrcweir } 3129cdf0e10cSrcweir return aResult; 3130cdf0e10cSrcweir } 3131cdf0e10cSrcweir 3132cdf0e10cSrcweir // XAccessibleMultiLineText 3133cdf0e10cSrcweir ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextAtLineWithCaret( ) throw (uno::RuntimeException) 3134cdf0e10cSrcweir { 3135cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 3136cdf0e10cSrcweir 3137cdf0e10cSrcweir ::com::sun::star::accessibility::TextSegment aResult; 3138cdf0e10cSrcweir try 3139cdf0e10cSrcweir { 3140cdf0e10cSrcweir aResult = getTextAtLineNumber( getNumberOfLineWithCaret() ); 3141cdf0e10cSrcweir } 3142cdf0e10cSrcweir catch (lang::IndexOutOfBoundsException &) 3143cdf0e10cSrcweir { 3144cdf0e10cSrcweir // this one needs to be catched since this interface does not allow for it. 3145cdf0e10cSrcweir } 3146cdf0e10cSrcweir return aResult; 3147cdf0e10cSrcweir } 3148cdf0e10cSrcweir 3149cdf0e10cSrcweir // XAccessibleMultiLineText 3150cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleEditableTextPara::getNumberOfLineWithCaret( ) throw (uno::RuntimeException) 3151cdf0e10cSrcweir { 3152cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 3153cdf0e10cSrcweir 3154cdf0e10cSrcweir sal_Int32 nRes = -1; 3155cdf0e10cSrcweir try 3156cdf0e10cSrcweir { 3157cdf0e10cSrcweir nRes = getLineNumberAtIndex( getCaretPosition() ); 3158cdf0e10cSrcweir } 3159cdf0e10cSrcweir catch (lang::IndexOutOfBoundsException &) 3160cdf0e10cSrcweir { 3161cdf0e10cSrcweir // this one needs to be catched since this interface does not allow for it. 3162cdf0e10cSrcweir } 3163cdf0e10cSrcweir return nRes; 3164cdf0e10cSrcweir } 3165cdf0e10cSrcweir 3166cdf0e10cSrcweir 3167cdf0e10cSrcweir // XServiceInfo 3168cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getImplementationName (void) throw (uno::RuntimeException) 3169cdf0e10cSrcweir { 3170cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 3171cdf0e10cSrcweir 3172cdf0e10cSrcweir return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("AccessibleEditableTextPara")); 3173cdf0e10cSrcweir } 3174cdf0e10cSrcweir 3175cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleEditableTextPara::supportsService (const ::rtl::OUString& sServiceName) throw (uno::RuntimeException) 3176cdf0e10cSrcweir { 3177cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 3178cdf0e10cSrcweir 3179cdf0e10cSrcweir // Iterate over all supported service names and return true if on of them 3180cdf0e10cSrcweir // matches the given name. 3181cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> aSupportedServices ( 3182cdf0e10cSrcweir getSupportedServiceNames ()); 3183cdf0e10cSrcweir for (int i=0; i<aSupportedServices.getLength(); i++) 3184cdf0e10cSrcweir if (sServiceName == aSupportedServices[i]) 3185cdf0e10cSrcweir return sal_True; 3186cdf0e10cSrcweir return sal_False; 3187cdf0e10cSrcweir } 3188cdf0e10cSrcweir 3189cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> SAL_CALL AccessibleEditableTextPara::getSupportedServiceNames (void) throw (uno::RuntimeException) 3190cdf0e10cSrcweir { 3191cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 3192cdf0e10cSrcweir 3193cdf0e10cSrcweir const ::rtl::OUString sServiceName( getServiceName() ); 3194cdf0e10cSrcweir return uno::Sequence< ::rtl::OUString > (&sServiceName, 1); 3195cdf0e10cSrcweir } 3196cdf0e10cSrcweir 3197cdf0e10cSrcweir // XServiceName 3198cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getServiceName (void) throw (uno::RuntimeException) 3199cdf0e10cSrcweir { 3200cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 3201cdf0e10cSrcweir 3202cdf0e10cSrcweir // #105185# Using correct service now 3203cdf0e10cSrcweir return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.AccessibleParagraphView")); 3204cdf0e10cSrcweir } 3205cdf0e10cSrcweir 3206cdf0e10cSrcweir } // end of namespace accessibility 3207cdf0e10cSrcweir 3208cdf0e10cSrcweir //------------------------------------------------------------------------ 3209