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