1190118d0SAndrew Rist /************************************************************** 2190118d0SAndrew Rist * 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 10190118d0SAndrew Rist * 11190118d0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12190118d0SAndrew Rist * 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. 19190118d0SAndrew Rist * 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 #include <algorithm> 809b8096d0SSteve Yin using namespace std; 810deba7fbSSteve Yin #include "editeng.hrc" 820deba7fbSSteve Yin #include <editeng/eerdll.hxx> 839b8096d0SSteve Yin #include <editeng/numitem.hxx> 84cdf0e10cSrcweir 85cdf0e10cSrcweir using namespace ::com::sun::star; 86cdf0e10cSrcweir using namespace ::com::sun::star::beans; 87cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 88cdf0e10cSrcweir 89cdf0e10cSrcweir 90cdf0e10cSrcweir //------------------------------------------------------------------------ 91cdf0e10cSrcweir // 92cdf0e10cSrcweir // AccessibleEditableTextPara implementation 93cdf0e10cSrcweir // 94cdf0e10cSrcweir //------------------------------------------------------------------------ 95cdf0e10cSrcweir 96cdf0e10cSrcweir namespace accessibility 97cdf0e10cSrcweir { 98cdf0e10cSrcweir ImplGetSvxCharAndParaPropertiesSet()99cdf0e10cSrcweir const SvxItemPropertySet* ImplGetSvxCharAndParaPropertiesSet() 100cdf0e10cSrcweir { 101cdf0e10cSrcweir // PropertyMap for character and paragraph properties 102cdf0e10cSrcweir static const SfxItemPropertyMapEntry aPropMap[] = 103cdf0e10cSrcweir { 1049b8096d0SSteve Yin SVX_UNOEDIT_OUTLINER_PROPERTIES, 105cdf0e10cSrcweir SVX_UNOEDIT_CHAR_PROPERTIES, 106cdf0e10cSrcweir SVX_UNOEDIT_PARA_PROPERTIES, 107cdf0e10cSrcweir SVX_UNOEDIT_NUMBERING_PROPERTIE, 108cdf0e10cSrcweir {MAP_CHAR_LEN("TextUserDefinedAttributes"), EE_CHAR_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, 109cdf0e10cSrcweir {MAP_CHAR_LEN("ParaUserDefinedAttributes"), EE_PARA_XMLATTRIBS, &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0) , 0, 0}, 110cdf0e10cSrcweir {0,0,0,0,0,0} 111cdf0e10cSrcweir }; 112cdf0e10cSrcweir static SvxItemPropertySet aPropSet( aPropMap, EditEngine::GetGlobalItemPool() ); 113cdf0e10cSrcweir return &aPropSet; 114cdf0e10cSrcweir } 115cdf0e10cSrcweir 116cdf0e10cSrcweir DBG_NAME(AccessibleEditableTextPara)117cdf0e10cSrcweir DBG_NAME( AccessibleEditableTextPara ) 118cdf0e10cSrcweir 119cdf0e10cSrcweir // --> OD 2006-01-11 #i27138# - add parameter <_pParaManager> 120cdf0e10cSrcweir AccessibleEditableTextPara::AccessibleEditableTextPara( 121cdf0e10cSrcweir const uno::Reference< XAccessible >& rParent, 122cdf0e10cSrcweir const AccessibleParaManager* _pParaManager ) 123cdf0e10cSrcweir : AccessibleTextParaInterfaceBase( m_aMutex ), 124cdf0e10cSrcweir mnParagraphIndex( 0 ), 125cdf0e10cSrcweir mnIndexInParent( 0 ), 126cdf0e10cSrcweir mpEditSource( NULL ), 127cdf0e10cSrcweir maEEOffset( 0, 0 ), 128cdf0e10cSrcweir mxParent( rParent ), 129cdf0e10cSrcweir // well, that's strictly (UNO) exception safe, though not 130cdf0e10cSrcweir // really robust. We rely on the fact that this member is 131cdf0e10cSrcweir // constructed last, and that the constructor body catches 132cdf0e10cSrcweir // exceptions, thus no chance for exceptions once the Id is 133cdf0e10cSrcweir // fetched. Nevertheless, normally should employ RAII here... 134cdf0e10cSrcweir mnNotifierClientId(::comphelper::AccessibleEventNotifier::registerClient()), 135cdf0e10cSrcweir // --> OD 2006-01-11 #i27138# 136cdf0e10cSrcweir mpParaManager( _pParaManager ) 137cdf0e10cSrcweir // <-- 138cdf0e10cSrcweir { 139cdf0e10cSrcweir #ifdef DBG_UTIL 140cdf0e10cSrcweir DBG_CTOR( AccessibleEditableTextPara, NULL ); 141cdf0e10cSrcweir OSL_TRACE( "AccessibleEditableTextPara received ID: %d\n", mnNotifierClientId ); 142cdf0e10cSrcweir #endif 143cdf0e10cSrcweir 144cdf0e10cSrcweir try 145cdf0e10cSrcweir { 146cdf0e10cSrcweir // Create the state set. 147cdf0e10cSrcweir ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper (); 148cdf0e10cSrcweir mxStateSet = pStateSet; 149cdf0e10cSrcweir 150cdf0e10cSrcweir // these are always on 151cdf0e10cSrcweir pStateSet->AddState( AccessibleStateType::MULTI_LINE ); 152cdf0e10cSrcweir pStateSet->AddState( AccessibleStateType::FOCUSABLE ); 153cdf0e10cSrcweir pStateSet->AddState( AccessibleStateType::VISIBLE ); 154cdf0e10cSrcweir pStateSet->AddState( AccessibleStateType::SHOWING ); 155cdf0e10cSrcweir pStateSet->AddState( AccessibleStateType::ENABLED ); 156cdf0e10cSrcweir pStateSet->AddState( AccessibleStateType::SENSITIVE ); 157cdf0e10cSrcweir } 158cdf0e10cSrcweir catch( const uno::Exception& ) {} 159cdf0e10cSrcweir } 160cdf0e10cSrcweir ~AccessibleEditableTextPara()161cdf0e10cSrcweir AccessibleEditableTextPara::~AccessibleEditableTextPara() 162cdf0e10cSrcweir { 163cdf0e10cSrcweir DBG_DTOR( AccessibleEditableTextPara, NULL ); 164cdf0e10cSrcweir 165cdf0e10cSrcweir // sign off from event notifier 166cdf0e10cSrcweir if( getNotifierClientId() != -1 ) 167cdf0e10cSrcweir { 168cdf0e10cSrcweir try 169cdf0e10cSrcweir { 170cdf0e10cSrcweir ::comphelper::AccessibleEventNotifier::revokeClient( getNotifierClientId() ); 171cdf0e10cSrcweir #ifdef DBG_UTIL 172cdf0e10cSrcweir OSL_TRACE( "AccessibleEditableTextPara revoked ID: %d\n", mnNotifierClientId ); 173cdf0e10cSrcweir #endif 174cdf0e10cSrcweir } 175cdf0e10cSrcweir catch( const uno::Exception& ) {} 176cdf0e10cSrcweir } 177cdf0e10cSrcweir } 178cdf0e10cSrcweir implGetText()179cdf0e10cSrcweir ::rtl::OUString AccessibleEditableTextPara::implGetText() 180cdf0e10cSrcweir { 181cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 182cdf0e10cSrcweir 183cdf0e10cSrcweir return GetTextRange( 0, GetTextLen() ); 184cdf0e10cSrcweir } 185cdf0e10cSrcweir implGetLocale()186cdf0e10cSrcweir ::com::sun::star::lang::Locale AccessibleEditableTextPara::implGetLocale() 187cdf0e10cSrcweir { 188cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 189cdf0e10cSrcweir 190cdf0e10cSrcweir lang::Locale aLocale; 191cdf0e10cSrcweir 192cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 193cdf0e10cSrcweir "AccessibleEditableTextPara::getLocale: paragraph index value overflow"); 194cdf0e10cSrcweir 195cdf0e10cSrcweir // return locale of first character in the paragraph 196cdf0e10cSrcweir return SvxLanguageToLocale(aLocale, GetTextForwarder().GetLanguage( static_cast< sal_uInt16 >( GetParagraphIndex() ), 0 )); 197cdf0e10cSrcweir } 198cdf0e10cSrcweir implGetSelection(sal_Int32 & nStartIndex,sal_Int32 & nEndIndex)199cdf0e10cSrcweir void AccessibleEditableTextPara::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ) 200cdf0e10cSrcweir { 201cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 202cdf0e10cSrcweir 203cdf0e10cSrcweir sal_uInt16 nStart, nEnd; 204cdf0e10cSrcweir 205cdf0e10cSrcweir if( GetSelection( nStart, nEnd ) ) 206cdf0e10cSrcweir { 207cdf0e10cSrcweir nStartIndex = nStart; 208cdf0e10cSrcweir nEndIndex = nEnd; 209cdf0e10cSrcweir } 210cdf0e10cSrcweir else 211cdf0e10cSrcweir { 212cdf0e10cSrcweir // #102234# No exception, just set to 'invalid' 213cdf0e10cSrcweir nStartIndex = -1; 214cdf0e10cSrcweir nEndIndex = -1; 215cdf0e10cSrcweir } 216cdf0e10cSrcweir } 217cdf0e10cSrcweir implGetParagraphBoundary(::com::sun::star::i18n::Boundary & rBoundary,sal_Int32)218cdf0e10cSrcweir void AccessibleEditableTextPara::implGetParagraphBoundary( ::com::sun::star::i18n::Boundary& rBoundary, sal_Int32 /*nIndex*/ ) 219cdf0e10cSrcweir { 220cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 221cdf0e10cSrcweir DBG_WARNING( "AccessibleEditableTextPara::implGetParagraphBoundary: only a base implementation, ignoring the index" ); 222cdf0e10cSrcweir 223cdf0e10cSrcweir rBoundary.startPos = 0; 2249b8096d0SSteve Yin //rBoundary.endPos = GetTextLen(); 2259b8096d0SSteve Yin ::rtl::OUString sText( implGetText() ); 2269b8096d0SSteve Yin sal_Int32 nLength = sText.getLength(); 2279b8096d0SSteve Yin rBoundary.endPos = nLength; 228cdf0e10cSrcweir } 229cdf0e10cSrcweir implGetLineBoundary(::com::sun::star::i18n::Boundary & rBoundary,sal_Int32 nIndex)230cdf0e10cSrcweir void AccessibleEditableTextPara::implGetLineBoundary( ::com::sun::star::i18n::Boundary& rBoundary, sal_Int32 nIndex ) 231cdf0e10cSrcweir { 232cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 233cdf0e10cSrcweir 234cdf0e10cSrcweir SvxTextForwarder& rCacheTF = GetTextForwarder(); 235cdf0e10cSrcweir const sal_Int32 nParaIndex = GetParagraphIndex(); 236cdf0e10cSrcweir 237cdf0e10cSrcweir DBG_ASSERT(nParaIndex >= 0 && nParaIndex <= USHRT_MAX, 238cdf0e10cSrcweir "AccessibleEditableTextPara::implGetLineBoundary: paragraph index value overflow"); 239cdf0e10cSrcweir 240cdf0e10cSrcweir const sal_Int32 nTextLen = rCacheTF.GetTextLen( static_cast< sal_uInt16 >( nParaIndex ) ); 241cdf0e10cSrcweir 242cdf0e10cSrcweir CheckPosition(nIndex); 243cdf0e10cSrcweir 244cdf0e10cSrcweir rBoundary.startPos = rBoundary.endPos = -1; 245cdf0e10cSrcweir 246cdf0e10cSrcweir const sal_uInt16 nLineCount=rCacheTF.GetLineCount( static_cast< sal_uInt16 >( nParaIndex ) ); 247cdf0e10cSrcweir 248cdf0e10cSrcweir if( nIndex == nTextLen ) 249cdf0e10cSrcweir { 250cdf0e10cSrcweir // #i17014# Special-casing one-behind-the-end character 251cdf0e10cSrcweir if( nLineCount <= 1 ) 252cdf0e10cSrcweir rBoundary.startPos = 0; 253cdf0e10cSrcweir else 254cdf0e10cSrcweir rBoundary.startPos = nTextLen - rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ), 255cdf0e10cSrcweir nLineCount-1 ); 256cdf0e10cSrcweir 257cdf0e10cSrcweir rBoundary.endPos = nTextLen; 258cdf0e10cSrcweir } 259cdf0e10cSrcweir else 260cdf0e10cSrcweir { 261cdf0e10cSrcweir // normal line search 262cdf0e10cSrcweir sal_uInt16 nLine; 263cdf0e10cSrcweir sal_Int32 nCurIndex; 264cdf0e10cSrcweir for( nLine=0, nCurIndex=0; nLine<nLineCount; ++nLine ) 265cdf0e10cSrcweir { 266cdf0e10cSrcweir nCurIndex += rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ), nLine); 267cdf0e10cSrcweir 268cdf0e10cSrcweir if( nCurIndex > nIndex ) 269cdf0e10cSrcweir { 270cdf0e10cSrcweir rBoundary.startPos = nCurIndex - rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine); 271cdf0e10cSrcweir rBoundary.endPos = nCurIndex; 272cdf0e10cSrcweir break; 273cdf0e10cSrcweir } 274cdf0e10cSrcweir } 275cdf0e10cSrcweir } 276cdf0e10cSrcweir } 277cdf0e10cSrcweir getNotifierClientId() const278cdf0e10cSrcweir int AccessibleEditableTextPara::getNotifierClientId() const 279cdf0e10cSrcweir { 280cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 281cdf0e10cSrcweir 282cdf0e10cSrcweir return mnNotifierClientId; 283cdf0e10cSrcweir } 284cdf0e10cSrcweir SetIndexInParent(sal_Int32 nIndex)285cdf0e10cSrcweir void AccessibleEditableTextPara::SetIndexInParent( sal_Int32 nIndex ) 286cdf0e10cSrcweir { 287cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 288cdf0e10cSrcweir 289cdf0e10cSrcweir mnIndexInParent = nIndex; 290cdf0e10cSrcweir } 291cdf0e10cSrcweir GetIndexInParent() const292cdf0e10cSrcweir sal_Int32 AccessibleEditableTextPara::GetIndexInParent() const 293cdf0e10cSrcweir { 294cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 295cdf0e10cSrcweir 296cdf0e10cSrcweir return mnIndexInParent; 297cdf0e10cSrcweir } 298cdf0e10cSrcweir SetParagraphIndex(sal_Int32 nIndex)299cdf0e10cSrcweir void AccessibleEditableTextPara::SetParagraphIndex( sal_Int32 nIndex ) 300cdf0e10cSrcweir { 301cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 302cdf0e10cSrcweir 303cdf0e10cSrcweir sal_Int32 nOldIndex = mnParagraphIndex; 304cdf0e10cSrcweir 305cdf0e10cSrcweir mnParagraphIndex = nIndex; 306cdf0e10cSrcweir 307cdf0e10cSrcweir WeakBullet::HardRefType aChild( maImageBullet.get() ); 308cdf0e10cSrcweir if( aChild.is() ) 309cdf0e10cSrcweir aChild->SetParagraphIndex(mnParagraphIndex); 310cdf0e10cSrcweir 311cdf0e10cSrcweir try 312cdf0e10cSrcweir { 313cdf0e10cSrcweir if( nOldIndex != nIndex ) 314cdf0e10cSrcweir { 315cdf0e10cSrcweir uno::Any aOldDesc; 316cdf0e10cSrcweir uno::Any aOldName; 317cdf0e10cSrcweir 318cdf0e10cSrcweir try 319cdf0e10cSrcweir { 320cdf0e10cSrcweir aOldDesc <<= getAccessibleDescription(); 321cdf0e10cSrcweir aOldName <<= getAccessibleName(); 322cdf0e10cSrcweir } 323cdf0e10cSrcweir catch( const uno::Exception& ) {} // optional behaviour 324cdf0e10cSrcweir // index and therefore description changed 325cdf0e10cSrcweir FireEvent( AccessibleEventId::DESCRIPTION_CHANGED, uno::makeAny( getAccessibleDescription() ), aOldDesc ); 326cdf0e10cSrcweir FireEvent( AccessibleEventId::NAME_CHANGED, uno::makeAny( getAccessibleName() ), aOldName ); 327cdf0e10cSrcweir } 328cdf0e10cSrcweir } 329cdf0e10cSrcweir catch( const uno::Exception& ) {} // optional behaviour 330cdf0e10cSrcweir } 331cdf0e10cSrcweir GetParagraphIndex() const332cdf0e10cSrcweir sal_Int32 AccessibleEditableTextPara::GetParagraphIndex() const SAL_THROW((uno::RuntimeException)) 333cdf0e10cSrcweir { 334cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 335cdf0e10cSrcweir 336cdf0e10cSrcweir return mnParagraphIndex; 337cdf0e10cSrcweir } 338cdf0e10cSrcweir Dispose()339cdf0e10cSrcweir void AccessibleEditableTextPara::Dispose() 340cdf0e10cSrcweir { 341cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 342cdf0e10cSrcweir 343cdf0e10cSrcweir int nClientId( getNotifierClientId() ); 344cdf0e10cSrcweir 345cdf0e10cSrcweir // #108212# drop all references before notifying dispose 346cdf0e10cSrcweir mxParent = NULL; 347cdf0e10cSrcweir mnNotifierClientId = -1; 348cdf0e10cSrcweir mpEditSource = NULL; 349cdf0e10cSrcweir 350cdf0e10cSrcweir // notify listeners 351cdf0e10cSrcweir if( nClientId != -1 ) 352cdf0e10cSrcweir { 353cdf0e10cSrcweir try 354cdf0e10cSrcweir { 355cdf0e10cSrcweir uno::Reference < XAccessibleContext > xThis = getAccessibleContext(); 356cdf0e10cSrcweir 357cdf0e10cSrcweir // #106234# Delegate to EventNotifier 358cdf0e10cSrcweir ::comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nClientId, xThis ); 359cdf0e10cSrcweir #ifdef DBG_UTIL 360cdf0e10cSrcweir OSL_TRACE( "Disposed ID: %d\n", nClientId ); 361cdf0e10cSrcweir #endif 362cdf0e10cSrcweir } 363cdf0e10cSrcweir catch( const uno::Exception& ) {} 364cdf0e10cSrcweir } 365cdf0e10cSrcweir } 366cdf0e10cSrcweir SetEditSource(SvxEditSourceAdapter * pEditSource)367cdf0e10cSrcweir void AccessibleEditableTextPara::SetEditSource( SvxEditSourceAdapter* pEditSource ) 368cdf0e10cSrcweir { 369cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 370cdf0e10cSrcweir 371cdf0e10cSrcweir WeakBullet::HardRefType aChild( maImageBullet.get() ); 372cdf0e10cSrcweir if( aChild.is() ) 373cdf0e10cSrcweir aChild->SetEditSource(pEditSource); 374cdf0e10cSrcweir 3759b8096d0SSteve Yin if( !pEditSource ) 376cdf0e10cSrcweir { 377cdf0e10cSrcweir // going defunc 378cdf0e10cSrcweir UnSetState( AccessibleStateType::SHOWING ); 379cdf0e10cSrcweir UnSetState( AccessibleStateType::VISIBLE ); 380cdf0e10cSrcweir SetState( AccessibleStateType::INVALID ); 381cdf0e10cSrcweir SetState( AccessibleStateType::DEFUNC ); 382cdf0e10cSrcweir 383cdf0e10cSrcweir Dispose(); 384cdf0e10cSrcweir } 3859b8096d0SSteve Yin mpEditSource = pEditSource; 386cdf0e10cSrcweir // #108900# Init last text content 387cdf0e10cSrcweir try 388cdf0e10cSrcweir { 389cdf0e10cSrcweir TextChanged(); 390cdf0e10cSrcweir } 391cdf0e10cSrcweir catch( const uno::RuntimeException& ) {} 392cdf0e10cSrcweir } 393cdf0e10cSrcweir MakeSelection(sal_Int32 nStartEEIndex,sal_Int32 nEndEEIndex)394cdf0e10cSrcweir ESelection AccessibleEditableTextPara::MakeSelection( sal_Int32 nStartEEIndex, sal_Int32 nEndEEIndex ) 395cdf0e10cSrcweir { 396cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 397cdf0e10cSrcweir 398cdf0e10cSrcweir // check overflow 399cdf0e10cSrcweir DBG_ASSERT(nStartEEIndex >= 0 && nStartEEIndex <= USHRT_MAX && 400cdf0e10cSrcweir nEndEEIndex >= 0 && nEndEEIndex <= USHRT_MAX && 401cdf0e10cSrcweir GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 402cdf0e10cSrcweir "AccessibleEditableTextPara::MakeSelection: index value overflow"); 403cdf0e10cSrcweir 404cdf0e10cSrcweir sal_uInt16 nParaIndex = static_cast< sal_uInt16 >( GetParagraphIndex() ); 405cdf0e10cSrcweir return ESelection( nParaIndex, static_cast< sal_uInt16 >( nStartEEIndex ), 406cdf0e10cSrcweir nParaIndex, static_cast< sal_uInt16 >( nEndEEIndex ) ); 407cdf0e10cSrcweir } 408cdf0e10cSrcweir MakeSelection(sal_Int32 nEEIndex)409cdf0e10cSrcweir ESelection AccessibleEditableTextPara::MakeSelection( sal_Int32 nEEIndex ) 410cdf0e10cSrcweir { 411cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 412cdf0e10cSrcweir 413cdf0e10cSrcweir return MakeSelection( nEEIndex, nEEIndex+1 ); 414cdf0e10cSrcweir } 415cdf0e10cSrcweir MakeCursor(sal_Int32 nEEIndex)416cdf0e10cSrcweir ESelection AccessibleEditableTextPara::MakeCursor( sal_Int32 nEEIndex ) 417cdf0e10cSrcweir { 418cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 419cdf0e10cSrcweir 420cdf0e10cSrcweir return MakeSelection( nEEIndex, nEEIndex ); 421cdf0e10cSrcweir } 422cdf0e10cSrcweir CheckIndex(sal_Int32 nIndex)423cdf0e10cSrcweir void AccessibleEditableTextPara::CheckIndex( sal_Int32 nIndex ) SAL_THROW((lang::IndexOutOfBoundsException, uno::RuntimeException)) 424cdf0e10cSrcweir { 425cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 426cdf0e10cSrcweir 427cdf0e10cSrcweir if( nIndex < 0 || nIndex >= getCharacterCount() ) 428cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleEditableTextPara: character index out of bounds")), 429cdf0e10cSrcweir uno::Reference< uno::XInterface > 430cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > (this) ) ); // disambiguate hierarchy 431cdf0e10cSrcweir } 432cdf0e10cSrcweir CheckPosition(sal_Int32 nIndex)433cdf0e10cSrcweir void AccessibleEditableTextPara::CheckPosition( sal_Int32 nIndex ) SAL_THROW((lang::IndexOutOfBoundsException, uno::RuntimeException)) 434cdf0e10cSrcweir { 435cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 436cdf0e10cSrcweir 437cdf0e10cSrcweir if( nIndex < 0 || nIndex > getCharacterCount() ) 438cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleEditableTextPara: character position out of bounds")), 439cdf0e10cSrcweir uno::Reference< uno::XInterface > 440cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > (this) ) ); // disambiguate hierarchy 441cdf0e10cSrcweir } 442cdf0e10cSrcweir CheckRange(sal_Int32 nStart,sal_Int32 nEnd)443cdf0e10cSrcweir void AccessibleEditableTextPara::CheckRange( sal_Int32 nStart, sal_Int32 nEnd ) SAL_THROW((lang::IndexOutOfBoundsException, uno::RuntimeException)) 444cdf0e10cSrcweir { 445cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 446cdf0e10cSrcweir 447cdf0e10cSrcweir CheckPosition( nStart ); 448cdf0e10cSrcweir CheckPosition( nEnd ); 449cdf0e10cSrcweir } 450cdf0e10cSrcweir GetSelection(sal_uInt16 & nStartPos,sal_uInt16 & nEndPos)451cdf0e10cSrcweir sal_Bool AccessibleEditableTextPara::GetSelection( sal_uInt16& nStartPos, sal_uInt16& nEndPos ) SAL_THROW((uno::RuntimeException)) 452cdf0e10cSrcweir { 453cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 454cdf0e10cSrcweir 455cdf0e10cSrcweir ESelection aSelection; 456cdf0e10cSrcweir sal_uInt16 nPara = static_cast< sal_uInt16 > ( GetParagraphIndex() ); 457cdf0e10cSrcweir if( !GetEditViewForwarder().GetSelection( aSelection ) ) 458cdf0e10cSrcweir return sal_False; 459cdf0e10cSrcweir 460cdf0e10cSrcweir if( aSelection.nStartPara < aSelection.nEndPara ) 461cdf0e10cSrcweir { 462cdf0e10cSrcweir if( aSelection.nStartPara > nPara || 463cdf0e10cSrcweir aSelection.nEndPara < nPara ) 464cdf0e10cSrcweir return sal_False; 465cdf0e10cSrcweir 466cdf0e10cSrcweir if( nPara == aSelection.nStartPara ) 467cdf0e10cSrcweir nStartPos = aSelection.nStartPos; 468cdf0e10cSrcweir else 469cdf0e10cSrcweir nStartPos = 0; 470cdf0e10cSrcweir 471cdf0e10cSrcweir if( nPara == aSelection.nEndPara ) 472cdf0e10cSrcweir nEndPos = aSelection.nEndPos; 473cdf0e10cSrcweir else 474cdf0e10cSrcweir nEndPos = GetTextLen(); 475cdf0e10cSrcweir } 476cdf0e10cSrcweir else 477cdf0e10cSrcweir { 478cdf0e10cSrcweir if( aSelection.nStartPara < nPara || 479cdf0e10cSrcweir aSelection.nEndPara > nPara ) 480cdf0e10cSrcweir return sal_False; 481cdf0e10cSrcweir 482cdf0e10cSrcweir if( nPara == aSelection.nStartPara ) 483cdf0e10cSrcweir nStartPos = aSelection.nStartPos; 484cdf0e10cSrcweir else 485cdf0e10cSrcweir nStartPos = GetTextLen(); 486cdf0e10cSrcweir 487cdf0e10cSrcweir if( nPara == aSelection.nEndPara ) 488cdf0e10cSrcweir nEndPos = aSelection.nEndPos; 489cdf0e10cSrcweir else 490cdf0e10cSrcweir nEndPos = 0; 491cdf0e10cSrcweir } 492cdf0e10cSrcweir 493cdf0e10cSrcweir return sal_True; 494cdf0e10cSrcweir } 495cdf0e10cSrcweir GetText(sal_Int32 nIndex)496cdf0e10cSrcweir String AccessibleEditableTextPara::GetText( sal_Int32 nIndex ) SAL_THROW((uno::RuntimeException)) 497cdf0e10cSrcweir { 498cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 499cdf0e10cSrcweir 500cdf0e10cSrcweir return GetTextForwarder().GetText( MakeSelection(nIndex) ); 501cdf0e10cSrcweir } 502cdf0e10cSrcweir GetTextRange(sal_Int32 nStartIndex,sal_Int32 nEndIndex)503cdf0e10cSrcweir String AccessibleEditableTextPara::GetTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) SAL_THROW((uno::RuntimeException)) 504cdf0e10cSrcweir { 505cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 506cdf0e10cSrcweir 507cdf0e10cSrcweir return GetTextForwarder().GetText( MakeSelection(nStartIndex, nEndIndex) ); 508cdf0e10cSrcweir } 509cdf0e10cSrcweir GetTextLen() const510cdf0e10cSrcweir sal_uInt16 AccessibleEditableTextPara::GetTextLen() const SAL_THROW((uno::RuntimeException)) 511cdf0e10cSrcweir { 512cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 513cdf0e10cSrcweir 514cdf0e10cSrcweir return GetTextForwarder().GetTextLen( static_cast< sal_uInt16 >( GetParagraphIndex() ) ); 515cdf0e10cSrcweir } 516cdf0e10cSrcweir IsVisible() const517cdf0e10cSrcweir sal_Bool AccessibleEditableTextPara::IsVisible() const 518cdf0e10cSrcweir { 519cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 520cdf0e10cSrcweir 521cdf0e10cSrcweir return mpEditSource ? sal_True : sal_False ; 522cdf0e10cSrcweir } 523cdf0e10cSrcweir GetParaInterface(sal_Int32 nIndex)524cdf0e10cSrcweir uno::Reference< XAccessibleText > AccessibleEditableTextPara::GetParaInterface( sal_Int32 nIndex ) 525cdf0e10cSrcweir { 526cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 527cdf0e10cSrcweir 528cdf0e10cSrcweir uno::Reference< XAccessible > xParent = getAccessibleParent(); 529cdf0e10cSrcweir if( xParent.is() ) 530cdf0e10cSrcweir { 531cdf0e10cSrcweir uno::Reference< XAccessibleContext > xParentContext = xParent->getAccessibleContext(); 532cdf0e10cSrcweir if( xParentContext.is() ) 533cdf0e10cSrcweir { 534cdf0e10cSrcweir uno::Reference< XAccessible > xPara = xParentContext->getAccessibleChild( nIndex ); 535cdf0e10cSrcweir if( xPara.is() ) 536cdf0e10cSrcweir { 537cdf0e10cSrcweir return uno::Reference< XAccessibleText > ( xPara, uno::UNO_QUERY ); 538cdf0e10cSrcweir } 539cdf0e10cSrcweir } 540cdf0e10cSrcweir } 541cdf0e10cSrcweir 542cdf0e10cSrcweir return uno::Reference< XAccessibleText >(); 543cdf0e10cSrcweir } 544cdf0e10cSrcweir GetEditSource() const545cdf0e10cSrcweir SvxEditSourceAdapter& AccessibleEditableTextPara::GetEditSource() const SAL_THROW((uno::RuntimeException)) 546cdf0e10cSrcweir { 547cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 548cdf0e10cSrcweir 549cdf0e10cSrcweir if( mpEditSource ) 550cdf0e10cSrcweir return *mpEditSource; 551cdf0e10cSrcweir else 552cdf0e10cSrcweir throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No edit source, object is defunct")), 553cdf0e10cSrcweir uno::Reference< uno::XInterface > 554cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > 555cdf0e10cSrcweir ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy 556cdf0e10cSrcweir } 557cdf0e10cSrcweir GetTextForwarder() const558cdf0e10cSrcweir SvxAccessibleTextAdapter& AccessibleEditableTextPara::GetTextForwarder() const SAL_THROW((uno::RuntimeException)) 559cdf0e10cSrcweir { 560cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 561cdf0e10cSrcweir 562cdf0e10cSrcweir SvxEditSourceAdapter& rEditSource = GetEditSource(); 563cdf0e10cSrcweir SvxAccessibleTextAdapter* pTextForwarder = rEditSource.GetTextForwarderAdapter(); 564cdf0e10cSrcweir 565cdf0e10cSrcweir if( !pTextForwarder ) 566cdf0e10cSrcweir throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unable to fetch text forwarder, object is defunct")), 567cdf0e10cSrcweir uno::Reference< uno::XInterface > 568cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > 569cdf0e10cSrcweir ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy 570cdf0e10cSrcweir 571cdf0e10cSrcweir if( pTextForwarder->IsValid() ) 572cdf0e10cSrcweir return *pTextForwarder; 573cdf0e10cSrcweir else 574cdf0e10cSrcweir throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Text forwarder is invalid, object is defunct")), 575cdf0e10cSrcweir uno::Reference< uno::XInterface > 576cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > 577cdf0e10cSrcweir ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy 578cdf0e10cSrcweir } 579cdf0e10cSrcweir GetViewForwarder() const580cdf0e10cSrcweir SvxViewForwarder& AccessibleEditableTextPara::GetViewForwarder() const SAL_THROW((uno::RuntimeException)) 581cdf0e10cSrcweir { 582cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 583cdf0e10cSrcweir 584cdf0e10cSrcweir SvxEditSource& rEditSource = GetEditSource(); 585cdf0e10cSrcweir SvxViewForwarder* pViewForwarder = rEditSource.GetViewForwarder(); 586cdf0e10cSrcweir 587cdf0e10cSrcweir if( !pViewForwarder ) 588cdf0e10cSrcweir { 589cdf0e10cSrcweir throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unable to fetch view forwarder, object is defunct")), 590cdf0e10cSrcweir uno::Reference< uno::XInterface > 591cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > 592cdf0e10cSrcweir ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy 593cdf0e10cSrcweir } 594cdf0e10cSrcweir 595cdf0e10cSrcweir if( pViewForwarder->IsValid() ) 596cdf0e10cSrcweir return *pViewForwarder; 597cdf0e10cSrcweir else 598cdf0e10cSrcweir throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("View forwarder is invalid, object is defunct")), 599cdf0e10cSrcweir uno::Reference< uno::XInterface > 600cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > 601cdf0e10cSrcweir ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy 602cdf0e10cSrcweir } 603cdf0e10cSrcweir GetEditViewForwarder(sal_Bool bCreate) const604cdf0e10cSrcweir SvxAccessibleTextEditViewAdapter& AccessibleEditableTextPara::GetEditViewForwarder( sal_Bool bCreate ) const SAL_THROW((uno::RuntimeException)) 605cdf0e10cSrcweir { 606cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 607cdf0e10cSrcweir 608cdf0e10cSrcweir SvxEditSourceAdapter& rEditSource = GetEditSource(); 609cdf0e10cSrcweir SvxAccessibleTextEditViewAdapter* pTextEditViewForwarder = rEditSource.GetEditViewForwarderAdapter( bCreate ); 610cdf0e10cSrcweir 611cdf0e10cSrcweir if( !pTextEditViewForwarder ) 612cdf0e10cSrcweir { 613cdf0e10cSrcweir if( bCreate ) 614cdf0e10cSrcweir throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unable to fetch view forwarder, object is defunct")), 615cdf0e10cSrcweir uno::Reference< uno::XInterface > 616cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > 617cdf0e10cSrcweir ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy 618cdf0e10cSrcweir else 619cdf0e10cSrcweir throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No view forwarder, object not in edit mode")), 620cdf0e10cSrcweir uno::Reference< uno::XInterface > 621cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > 622cdf0e10cSrcweir ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy 623cdf0e10cSrcweir } 624cdf0e10cSrcweir 625cdf0e10cSrcweir if( pTextEditViewForwarder->IsValid() ) 626cdf0e10cSrcweir return *pTextEditViewForwarder; 627cdf0e10cSrcweir else 628cdf0e10cSrcweir { 629cdf0e10cSrcweir if( bCreate ) 630cdf0e10cSrcweir throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("View forwarder is invalid, object is defunct")), 631cdf0e10cSrcweir uno::Reference< uno::XInterface > 632cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > 633cdf0e10cSrcweir ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy 634cdf0e10cSrcweir else 635cdf0e10cSrcweir throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("View forwarder is invalid, object not in edit mode")), 636cdf0e10cSrcweir uno::Reference< uno::XInterface > 637cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > 638cdf0e10cSrcweir ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy 639cdf0e10cSrcweir } 640cdf0e10cSrcweir } 641cdf0e10cSrcweir HaveEditView() const642cdf0e10cSrcweir sal_Bool AccessibleEditableTextPara::HaveEditView() const 643cdf0e10cSrcweir { 644cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 645cdf0e10cSrcweir 646cdf0e10cSrcweir SvxEditSource& rEditSource = GetEditSource(); 647cdf0e10cSrcweir SvxEditViewForwarder* pViewForwarder = rEditSource.GetEditViewForwarder(); 648cdf0e10cSrcweir 649cdf0e10cSrcweir if( !pViewForwarder ) 650cdf0e10cSrcweir return sal_False; 651cdf0e10cSrcweir 652cdf0e10cSrcweir if( !pViewForwarder->IsValid() ) 653cdf0e10cSrcweir return sal_False; 654cdf0e10cSrcweir 655cdf0e10cSrcweir return sal_True; 656cdf0e10cSrcweir } 657cdf0e10cSrcweir HaveChildren()658cdf0e10cSrcweir sal_Bool AccessibleEditableTextPara::HaveChildren() 659cdf0e10cSrcweir { 660cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 661cdf0e10cSrcweir 662cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 663cdf0e10cSrcweir "AccessibleEditableTextPara::HaveChildren: paragraph index value overflow"); 664cdf0e10cSrcweir 665cdf0e10cSrcweir return GetTextForwarder().HaveImageBullet( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 666cdf0e10cSrcweir } 667cdf0e10cSrcweir IsActive() const668cdf0e10cSrcweir sal_Bool AccessibleEditableTextPara::IsActive() const SAL_THROW((uno::RuntimeException)) 669cdf0e10cSrcweir { 670cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 671cdf0e10cSrcweir 672cdf0e10cSrcweir SvxEditSource& rEditSource = GetEditSource(); 673cdf0e10cSrcweir SvxEditViewForwarder* pViewForwarder = rEditSource.GetEditViewForwarder(); 674cdf0e10cSrcweir 675cdf0e10cSrcweir if( !pViewForwarder ) 676cdf0e10cSrcweir return sal_False; 677cdf0e10cSrcweir 678cdf0e10cSrcweir if( pViewForwarder->IsValid() ) 679cdf0e10cSrcweir return sal_False; 680cdf0e10cSrcweir else 681cdf0e10cSrcweir return sal_True; 682cdf0e10cSrcweir } 683cdf0e10cSrcweir LogicToPixel(const Rectangle & rRect,const MapMode & rMapMode,SvxViewForwarder & rForwarder)684cdf0e10cSrcweir Rectangle AccessibleEditableTextPara::LogicToPixel( const Rectangle& rRect, const MapMode& rMapMode, SvxViewForwarder& rForwarder ) 685cdf0e10cSrcweir { 686cdf0e10cSrcweir // convert to screen coordinates 687cdf0e10cSrcweir return Rectangle( rForwarder.LogicToPixel( rRect.TopLeft(), rMapMode ), 688cdf0e10cSrcweir rForwarder.LogicToPixel( rRect.BottomRight(), rMapMode ) ); 689cdf0e10cSrcweir } 690cdf0e10cSrcweir GetEEOffset() const691cdf0e10cSrcweir const Point& AccessibleEditableTextPara::GetEEOffset() const 692cdf0e10cSrcweir { 693cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 694cdf0e10cSrcweir 695cdf0e10cSrcweir return maEEOffset; 696cdf0e10cSrcweir } 697cdf0e10cSrcweir SetEEOffset(const Point & rOffset)698cdf0e10cSrcweir void AccessibleEditableTextPara::SetEEOffset( const Point& rOffset ) 699cdf0e10cSrcweir { 700cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 701cdf0e10cSrcweir 702cdf0e10cSrcweir WeakBullet::HardRefType aChild( maImageBullet.get() ); 703cdf0e10cSrcweir if( aChild.is() ) 704cdf0e10cSrcweir aChild->SetEEOffset(rOffset); 705cdf0e10cSrcweir 706cdf0e10cSrcweir maEEOffset = rOffset; 707cdf0e10cSrcweir } 708cdf0e10cSrcweir FireEvent(const sal_Int16 nEventId,const uno::Any & rNewValue,const uno::Any & rOldValue) const709cdf0e10cSrcweir void AccessibleEditableTextPara::FireEvent(const sal_Int16 nEventId, const uno::Any& rNewValue, const uno::Any& rOldValue) const 710cdf0e10cSrcweir { 711cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 712cdf0e10cSrcweir 713cdf0e10cSrcweir uno::Reference < XAccessibleContext > xThis( const_cast< AccessibleEditableTextPara* > (this)->getAccessibleContext() ); 714cdf0e10cSrcweir 715cdf0e10cSrcweir AccessibleEventObject aEvent(xThis, nEventId, rNewValue, rOldValue); 716cdf0e10cSrcweir 717cdf0e10cSrcweir // #102261# Call global queue for focus events 718cdf0e10cSrcweir if( nEventId == AccessibleEventId::STATE_CHANGED ) 719cdf0e10cSrcweir vcl::unohelper::NotifyAccessibleStateEventGlobally( aEvent ); 720cdf0e10cSrcweir 721cdf0e10cSrcweir // #106234# Delegate to EventNotifier 722cdf0e10cSrcweir if( getNotifierClientId() != -1 ) 723cdf0e10cSrcweir ::comphelper::AccessibleEventNotifier::addEvent( getNotifierClientId(), 724cdf0e10cSrcweir aEvent ); 725cdf0e10cSrcweir } 726cdf0e10cSrcweir GotPropertyEvent(const uno::Any & rNewValue,const sal_Int16 nEventId) const727cdf0e10cSrcweir void AccessibleEditableTextPara::GotPropertyEvent( const uno::Any& rNewValue, const sal_Int16 nEventId ) const 728cdf0e10cSrcweir { 729cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 730cdf0e10cSrcweir 731cdf0e10cSrcweir FireEvent( nEventId, rNewValue ); 732cdf0e10cSrcweir } 733cdf0e10cSrcweir LostPropertyEvent(const uno::Any & rOldValue,const sal_Int16 nEventId) const734cdf0e10cSrcweir void AccessibleEditableTextPara::LostPropertyEvent( const uno::Any& rOldValue, const sal_Int16 nEventId ) const 735cdf0e10cSrcweir { 736cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 737cdf0e10cSrcweir 738cdf0e10cSrcweir FireEvent( nEventId, uno::Any(), rOldValue ); 739cdf0e10cSrcweir } 740cdf0e10cSrcweir HasState(const sal_Int16 nStateId)741cdf0e10cSrcweir bool AccessibleEditableTextPara::HasState( const sal_Int16 nStateId ) 742cdf0e10cSrcweir { 743cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 744cdf0e10cSrcweir 745cdf0e10cSrcweir ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get()); 746cdf0e10cSrcweir if( pStateSet != NULL ) 747cdf0e10cSrcweir return pStateSet->contains(nStateId) ? true : false; 748cdf0e10cSrcweir 749cdf0e10cSrcweir return false; 750cdf0e10cSrcweir } 751cdf0e10cSrcweir SetState(const sal_Int16 nStateId)752cdf0e10cSrcweir void AccessibleEditableTextPara::SetState( const sal_Int16 nStateId ) 753cdf0e10cSrcweir { 754cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 755cdf0e10cSrcweir 756cdf0e10cSrcweir ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get()); 757cdf0e10cSrcweir if( pStateSet != NULL && 758cdf0e10cSrcweir !pStateSet->contains(nStateId) ) 759cdf0e10cSrcweir { 760cdf0e10cSrcweir pStateSet->AddState( nStateId ); 7619b8096d0SSteve 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 7629b8096d0SSteve Yin // if(IsShapeParaFocusable()) 763cdf0e10cSrcweir GotPropertyEvent( uno::makeAny( nStateId ), AccessibleEventId::STATE_CHANGED ); 764cdf0e10cSrcweir } 765cdf0e10cSrcweir } 766cdf0e10cSrcweir UnSetState(const sal_Int16 nStateId)767cdf0e10cSrcweir void AccessibleEditableTextPara::UnSetState( const sal_Int16 nStateId ) 768cdf0e10cSrcweir { 769cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 770cdf0e10cSrcweir 771cdf0e10cSrcweir ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get()); 772cdf0e10cSrcweir if( pStateSet != NULL && 773cdf0e10cSrcweir pStateSet->contains(nStateId) ) 774cdf0e10cSrcweir { 775cdf0e10cSrcweir pStateSet->RemoveState( nStateId ); 776cdf0e10cSrcweir LostPropertyEvent( uno::makeAny( nStateId ), AccessibleEventId::STATE_CHANGED ); 777cdf0e10cSrcweir } 778cdf0e10cSrcweir } 779cdf0e10cSrcweir TextChanged()780cdf0e10cSrcweir void AccessibleEditableTextPara::TextChanged() 781cdf0e10cSrcweir { 782cdf0e10cSrcweir ::rtl::OUString aCurrentString( OCommonAccessibleText::getText() ); 783cdf0e10cSrcweir uno::Any aDeleted; 784cdf0e10cSrcweir uno::Any aInserted; 785cdf0e10cSrcweir if( OCommonAccessibleText::implInitTextChangedEvent( maLastTextString, aCurrentString, 786cdf0e10cSrcweir aDeleted, aInserted) ) 787cdf0e10cSrcweir { 788cdf0e10cSrcweir FireEvent( AccessibleEventId::TEXT_CHANGED, aInserted, aDeleted ); 789cdf0e10cSrcweir maLastTextString = aCurrentString; 790cdf0e10cSrcweir } 791cdf0e10cSrcweir } 792cdf0e10cSrcweir GetAttributeRun(sal_uInt16 & nStartIndex,sal_uInt16 & nEndIndex,sal_Int32 nIndex)793cdf0e10cSrcweir sal_Bool AccessibleEditableTextPara::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, sal_Int32 nIndex ) 794cdf0e10cSrcweir { 795cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 796cdf0e10cSrcweir 797cdf0e10cSrcweir DBG_ASSERT(nIndex >= 0 && nIndex <= USHRT_MAX, 798cdf0e10cSrcweir "AccessibleEditableTextPara::GetAttributeRun: index value overflow"); 799cdf0e10cSrcweir 800cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 801cdf0e10cSrcweir "AccessibleEditableTextPara::getLocale: paragraph index value overflow"); 802cdf0e10cSrcweir 803cdf0e10cSrcweir return GetTextForwarder().GetAttributeRun( nStartIndex, 804cdf0e10cSrcweir nEndIndex, 805cdf0e10cSrcweir static_cast< sal_uInt16 >(GetParagraphIndex()), 806cdf0e10cSrcweir static_cast< sal_uInt16 >(nIndex) ); 807cdf0e10cSrcweir } 808cdf0e10cSrcweir queryInterface(const uno::Type & rType)809cdf0e10cSrcweir uno::Any SAL_CALL AccessibleEditableTextPara::queryInterface (const uno::Type & rType) throw (uno::RuntimeException) 810cdf0e10cSrcweir { 811cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 812cdf0e10cSrcweir 813cdf0e10cSrcweir uno::Any aRet; 814cdf0e10cSrcweir 815cdf0e10cSrcweir // must provide XAccesibleText by hand, since it comes publicly inherited by XAccessibleEditableText 816cdf0e10cSrcweir if ( rType == ::getCppuType((uno::Reference< XAccessibleText > *)0) ) 817cdf0e10cSrcweir { 818cdf0e10cSrcweir uno::Reference< XAccessibleText > aAccText = static_cast< XAccessibleEditableText * >(this); 819cdf0e10cSrcweir aRet <<= aAccText; 820cdf0e10cSrcweir } 821cdf0e10cSrcweir else if ( rType == ::getCppuType((uno::Reference< XAccessibleEditableText > *)0) ) 822cdf0e10cSrcweir { 823cdf0e10cSrcweir uno::Reference< XAccessibleEditableText > aAccEditText = this; 824cdf0e10cSrcweir aRet <<= aAccEditText; 825cdf0e10cSrcweir } 8269b8096d0SSteve Yin else if ( rType == ::getCppuType((uno::Reference< XAccessibleHypertext > *)0) ) 827cdf0e10cSrcweir { 828cdf0e10cSrcweir uno::Reference< XAccessibleHypertext > aAccHyperText = this; 829cdf0e10cSrcweir aRet <<= aAccHyperText; 830cdf0e10cSrcweir } 831cdf0e10cSrcweir else 832cdf0e10cSrcweir { 833cdf0e10cSrcweir aRet = AccessibleTextParaInterfaceBase::queryInterface(rType); 834cdf0e10cSrcweir } 835cdf0e10cSrcweir 836cdf0e10cSrcweir return aRet; 837cdf0e10cSrcweir } 838cdf0e10cSrcweir 839cdf0e10cSrcweir // XAccessible getAccessibleContext()840cdf0e10cSrcweir uno::Reference< XAccessibleContext > SAL_CALL AccessibleEditableTextPara::getAccessibleContext() throw (uno::RuntimeException) 841cdf0e10cSrcweir { 842cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 843cdf0e10cSrcweir 844cdf0e10cSrcweir // We implement the XAccessibleContext interface in the same object 845cdf0e10cSrcweir return uno::Reference< XAccessibleContext > ( this ); 846cdf0e10cSrcweir } 847cdf0e10cSrcweir 848cdf0e10cSrcweir // XAccessibleContext getAccessibleChildCount()849cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleEditableTextPara::getAccessibleChildCount() throw (uno::RuntimeException) 850cdf0e10cSrcweir { 851cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 852cdf0e10cSrcweir 853cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 854cdf0e10cSrcweir 855cdf0e10cSrcweir return HaveChildren() ? 1 : 0; 856cdf0e10cSrcweir } 857cdf0e10cSrcweir getAccessibleChild(sal_Int32 i)858cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL AccessibleEditableTextPara::getAccessibleChild( sal_Int32 i ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 859cdf0e10cSrcweir { 860cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 861cdf0e10cSrcweir 862cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 863cdf0e10cSrcweir 864cdf0e10cSrcweir if( !HaveChildren() ) 865cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No childs available")), 866cdf0e10cSrcweir uno::Reference< uno::XInterface > 867cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > (this) ) ); // static_cast: disambiguate hierarchy 868cdf0e10cSrcweir 869cdf0e10cSrcweir if( i != 0 ) 870cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Invalid child index")), 871cdf0e10cSrcweir uno::Reference< uno::XInterface > 872cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > (this) ) ); // static_cast: disambiguate hierarchy 873cdf0e10cSrcweir 874cdf0e10cSrcweir WeakBullet::HardRefType aChild( maImageBullet.get() ); 875cdf0e10cSrcweir 876cdf0e10cSrcweir if( !aChild.is() ) 877cdf0e10cSrcweir { 878cdf0e10cSrcweir // there is no hard reference available, create object then 879cdf0e10cSrcweir AccessibleImageBullet* pChild = new AccessibleImageBullet( uno::Reference< XAccessible >( this ) ); 880cdf0e10cSrcweir uno::Reference< XAccessible > xChild( static_cast< ::cppu::OWeakObject* > (pChild), uno::UNO_QUERY ); 881cdf0e10cSrcweir 882cdf0e10cSrcweir if( !xChild.is() ) 883cdf0e10cSrcweir throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Child creation failed")), 884cdf0e10cSrcweir uno::Reference< uno::XInterface > 885cdf0e10cSrcweir ( static_cast< ::cppu::OWeakObject* > (this) ) ); 886cdf0e10cSrcweir 887cdf0e10cSrcweir aChild = WeakBullet::HardRefType( xChild, pChild ); 888cdf0e10cSrcweir 889cdf0e10cSrcweir aChild->SetEditSource( &GetEditSource() ); 890cdf0e10cSrcweir aChild->SetParagraphIndex( GetParagraphIndex() ); 891cdf0e10cSrcweir aChild->SetIndexInParent( i ); 892cdf0e10cSrcweir 893cdf0e10cSrcweir maImageBullet = aChild; 894cdf0e10cSrcweir } 895cdf0e10cSrcweir 896cdf0e10cSrcweir return aChild.getRef(); 897cdf0e10cSrcweir } 898cdf0e10cSrcweir getAccessibleParent()899cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL AccessibleEditableTextPara::getAccessibleParent() throw (uno::RuntimeException) 900cdf0e10cSrcweir { 901cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 902cdf0e10cSrcweir 903cdf0e10cSrcweir #ifdef DBG_UTIL 904cdf0e10cSrcweir if( !mxParent.is() ) 905cdf0e10cSrcweir DBG_TRACE( "AccessibleEditableTextPara::getAccessibleParent: no frontend set, did somebody forgot to call AccessibleTextHelper::SetEventSource()?"); 906cdf0e10cSrcweir #endif 907cdf0e10cSrcweir 908cdf0e10cSrcweir return mxParent; 909cdf0e10cSrcweir } 910cdf0e10cSrcweir getAccessibleIndexInParent()911cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleEditableTextPara::getAccessibleIndexInParent() throw (uno::RuntimeException) 912cdf0e10cSrcweir { 913cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 914cdf0e10cSrcweir 915cdf0e10cSrcweir return mnIndexInParent; 916cdf0e10cSrcweir } 917cdf0e10cSrcweir getAccessibleRole()918cdf0e10cSrcweir sal_Int16 SAL_CALL AccessibleEditableTextPara::getAccessibleRole() throw (uno::RuntimeException) 919cdf0e10cSrcweir { 920cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 921cdf0e10cSrcweir 922cdf0e10cSrcweir return AccessibleRole::PARAGRAPH; 923cdf0e10cSrcweir } 924cdf0e10cSrcweir getAccessibleDescription()925cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getAccessibleDescription() throw (uno::RuntimeException) 926cdf0e10cSrcweir { 927cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 9280deba7fbSSteve Yin ::vos::OGuard aGuard( Application::GetSolarMutex() ); 929cdf0e10cSrcweir 9300deba7fbSSteve Yin // append first 40 characters from text, or first line, if shorter 9310deba7fbSSteve Yin // (writer takes first sentence here, but that's not supported 9320deba7fbSSteve Yin // from EditEngine) 9330deba7fbSSteve Yin // throws if defunc 9340deba7fbSSteve Yin ::rtl::OUString aLine; 9350deba7fbSSteve Yin 9360deba7fbSSteve Yin if( getCharacterCount() ) 9370deba7fbSSteve Yin aLine = getTextAtIndex(0, AccessibleTextType::LINE).SegmentText; 9380deba7fbSSteve Yin 9390deba7fbSSteve Yin // Get the string from the resource for the specified id. 9400deba7fbSSteve Yin String sStr = ::rtl::OUString( String( EditResId (RID_SVXSTR_A11Y_PARAGRAPH_DESCRIPTION ) ) ); 9410deba7fbSSteve Yin String sParaIndex = ::rtl::OUString::valueOf( GetParagraphIndex() ); 9420deba7fbSSteve Yin sStr.SearchAndReplace( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "$(ARG)" )), 9430deba7fbSSteve Yin sParaIndex ); 9440deba7fbSSteve Yin 9450deba7fbSSteve Yin if( aLine.getLength() > MaxDescriptionLen ) 9460deba7fbSSteve Yin { 9470deba7fbSSteve Yin ::rtl::OUString aCurrWord; 9480deba7fbSSteve Yin sal_Int32 i; 9490deba7fbSSteve Yin 9500deba7fbSSteve Yin // search backward from MaxDescriptionLen for previous word start 9510deba7fbSSteve Yin for( aCurrWord=getTextAtIndex(MaxDescriptionLen, AccessibleTextType::WORD).SegmentText, 9520deba7fbSSteve Yin i=MaxDescriptionLen, 9530deba7fbSSteve Yin aLine=::rtl::OUString(); 9540deba7fbSSteve Yin i>=0; 9550deba7fbSSteve Yin --i ) 9560deba7fbSSteve Yin { 9570deba7fbSSteve Yin if( getTextAtIndex(i, AccessibleTextType::WORD).SegmentText != aCurrWord ) 9580deba7fbSSteve Yin { 9590deba7fbSSteve Yin if( i == 0 ) 9600deba7fbSSteve Yin // prevent completely empty string 9610deba7fbSSteve Yin aLine = getTextAtIndex(0, AccessibleTextType::WORD).SegmentText; 9620deba7fbSSteve Yin else 9630deba7fbSSteve Yin aLine = getTextRange(0, i); 9640deba7fbSSteve Yin } 9650deba7fbSSteve Yin } 9660deba7fbSSteve Yin } 967cdf0e10cSrcweir 9680deba7fbSSteve Yin return ::rtl::OUString( sStr ) + aLine; 969cdf0e10cSrcweir } 970cdf0e10cSrcweir getAccessibleName()971cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getAccessibleName() throw (uno::RuntimeException) 972cdf0e10cSrcweir { 973cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 974cdf0e10cSrcweir 9750deba7fbSSteve Yin ::vos::OGuard aGuard( Application::GetSolarMutex() ); 976cdf0e10cSrcweir 9770deba7fbSSteve Yin // throws if defunc 9780deba7fbSSteve Yin sal_Int32 nPara( GetParagraphIndex() ); 9790deba7fbSSteve Yin 9800deba7fbSSteve Yin // Get the string from the resource for the specified id. 9810deba7fbSSteve Yin String sStr = ::rtl::OUString( String( EditResId (RID_SVXSTR_A11Y_PARAGRAPH_NAME) ) ); 9820deba7fbSSteve Yin String sParaIndex = ::rtl::OUString::valueOf( nPara ); 9830deba7fbSSteve Yin sStr.SearchAndReplace( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "$(ARG)" )), 9840deba7fbSSteve Yin sParaIndex ); 9850deba7fbSSteve Yin 9860deba7fbSSteve Yin return ::rtl::OUString( sStr ); 987cdf0e10cSrcweir } 988cdf0e10cSrcweir getAccessibleRelationSet()989cdf0e10cSrcweir uno::Reference< XAccessibleRelationSet > SAL_CALL AccessibleEditableTextPara::getAccessibleRelationSet() throw (uno::RuntimeException) 990cdf0e10cSrcweir { 991cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 992cdf0e10cSrcweir 993cdf0e10cSrcweir // --> OD 2006-01-11 #i27138# - provide relations CONTENT_FLOWS_FROM 994cdf0e10cSrcweir // and CONTENT_FLOWS_TO 995cdf0e10cSrcweir if ( mpParaManager ) 996cdf0e10cSrcweir { 997cdf0e10cSrcweir utl::AccessibleRelationSetHelper* pAccRelSetHelper = 998cdf0e10cSrcweir new utl::AccessibleRelationSetHelper(); 999cdf0e10cSrcweir sal_Int32 nMyParaIndex( GetParagraphIndex() ); 1000cdf0e10cSrcweir // relation CONTENT_FLOWS_FROM 1001cdf0e10cSrcweir if ( nMyParaIndex > 0 && 1002cdf0e10cSrcweir mpParaManager->IsReferencable( nMyParaIndex - 1 ) ) 1003cdf0e10cSrcweir { 1004cdf0e10cSrcweir uno::Sequence<uno::Reference<XInterface> > aSequence(1); 1005cdf0e10cSrcweir aSequence[0] = 1006cdf0e10cSrcweir mpParaManager->GetChild( nMyParaIndex - 1 ).first.get().getRef(); 1007cdf0e10cSrcweir AccessibleRelation aAccRel( AccessibleRelationType::CONTENT_FLOWS_FROM, 1008cdf0e10cSrcweir aSequence ); 1009cdf0e10cSrcweir pAccRelSetHelper->AddRelation( aAccRel ); 1010cdf0e10cSrcweir } 1011cdf0e10cSrcweir 1012cdf0e10cSrcweir // relation CONTENT_FLOWS_TO 1013cdf0e10cSrcweir if ( (nMyParaIndex + 1) < (sal_Int32)mpParaManager->GetNum() && 1014cdf0e10cSrcweir mpParaManager->IsReferencable( nMyParaIndex + 1 ) ) 1015cdf0e10cSrcweir { 1016cdf0e10cSrcweir uno::Sequence<uno::Reference<XInterface> > aSequence(1); 1017cdf0e10cSrcweir aSequence[0] = 1018cdf0e10cSrcweir mpParaManager->GetChild( nMyParaIndex + 1 ).first.get().getRef(); 1019cdf0e10cSrcweir AccessibleRelation aAccRel( AccessibleRelationType::CONTENT_FLOWS_TO, 1020cdf0e10cSrcweir aSequence ); 1021cdf0e10cSrcweir pAccRelSetHelper->AddRelation( aAccRel ); 1022cdf0e10cSrcweir } 1023cdf0e10cSrcweir 1024cdf0e10cSrcweir return pAccRelSetHelper; 1025cdf0e10cSrcweir } 1026cdf0e10cSrcweir else 1027cdf0e10cSrcweir { 1028cdf0e10cSrcweir // no relations, therefore empty 1029cdf0e10cSrcweir return uno::Reference< XAccessibleRelationSet >(); 1030cdf0e10cSrcweir } 1031cdf0e10cSrcweir // <-- 1032cdf0e10cSrcweir } 1033cdf0e10cSrcweir getAccessibleStateSet()1034cdf0e10cSrcweir uno::Reference< XAccessibleStateSet > SAL_CALL AccessibleEditableTextPara::getAccessibleStateSet() throw (uno::RuntimeException) 1035cdf0e10cSrcweir { 1036cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1037cdf0e10cSrcweir 1038cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1039cdf0e10cSrcweir 1040cdf0e10cSrcweir // Create a copy of the state set and return it. 1041cdf0e10cSrcweir ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get()); 1042cdf0e10cSrcweir 1043cdf0e10cSrcweir if( !pStateSet ) 1044cdf0e10cSrcweir return uno::Reference<XAccessibleStateSet>(); 10459b8096d0SSteve Yin uno::Reference<XAccessibleStateSet> xParentStates; 10469b8096d0SSteve Yin if (getAccessibleParent().is()) 10479b8096d0SSteve Yin { 10489b8096d0SSteve Yin uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext(); 10499b8096d0SSteve Yin xParentStates = xParentContext->getAccessibleStateSet(); 10509b8096d0SSteve Yin } 10519b8096d0SSteve Yin if (xParentStates.is() && xParentStates->contains(AccessibleStateType::EDITABLE) ) 10529b8096d0SSteve Yin { 10539b8096d0SSteve Yin pStateSet->AddState(AccessibleStateType::EDITABLE); 10549b8096d0SSteve Yin } 1055cdf0e10cSrcweir return uno::Reference<XAccessibleStateSet>( new ::utl::AccessibleStateSetHelper (*pStateSet) ); 1056cdf0e10cSrcweir } 1057cdf0e10cSrcweir getLocale()1058cdf0e10cSrcweir lang::Locale SAL_CALL AccessibleEditableTextPara::getLocale() throw (IllegalAccessibleComponentStateException, uno::RuntimeException) 1059cdf0e10cSrcweir { 1060cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1061cdf0e10cSrcweir 1062cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1063cdf0e10cSrcweir 1064cdf0e10cSrcweir return implGetLocale(); 1065cdf0e10cSrcweir } 1066cdf0e10cSrcweir addEventListener(const uno::Reference<XAccessibleEventListener> & xListener)1067cdf0e10cSrcweir void SAL_CALL AccessibleEditableTextPara::addEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) throw (uno::RuntimeException) 1068cdf0e10cSrcweir { 1069cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1070cdf0e10cSrcweir 1071cdf0e10cSrcweir if( getNotifierClientId() != -1 ) 1072cdf0e10cSrcweir ::comphelper::AccessibleEventNotifier::addEventListener( getNotifierClientId(), xListener ); 1073cdf0e10cSrcweir } 1074cdf0e10cSrcweir removeEventListener(const uno::Reference<XAccessibleEventListener> & xListener)1075cdf0e10cSrcweir void SAL_CALL AccessibleEditableTextPara::removeEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) throw (uno::RuntimeException) 1076cdf0e10cSrcweir { 1077cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1078cdf0e10cSrcweir 1079cdf0e10cSrcweir if( getNotifierClientId() != -1 ) 1080cdf0e10cSrcweir ::comphelper::AccessibleEventNotifier::removeEventListener( getNotifierClientId(), xListener ); 1081cdf0e10cSrcweir } 1082cdf0e10cSrcweir 1083cdf0e10cSrcweir // XAccessibleComponent containsPoint(const awt::Point & aTmpPoint)1084cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleEditableTextPara::containsPoint( const awt::Point& aTmpPoint ) throw (uno::RuntimeException) 1085cdf0e10cSrcweir { 1086cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1087cdf0e10cSrcweir 1088cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1089cdf0e10cSrcweir 1090cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1091cdf0e10cSrcweir "AccessibleEditableTextPara::contains: index value overflow"); 1092cdf0e10cSrcweir 1093cdf0e10cSrcweir awt::Rectangle aTmpRect = getBounds(); 1094cdf0e10cSrcweir Rectangle aRect( Point(aTmpRect.X, aTmpRect.Y), Size(aTmpRect.Width, aTmpRect.Height) ); 1095cdf0e10cSrcweir Point aPoint( aTmpPoint.X, aTmpPoint.Y ); 1096cdf0e10cSrcweir 1097cdf0e10cSrcweir return aRect.IsInside( aPoint ); 1098cdf0e10cSrcweir } 1099cdf0e10cSrcweir getAccessibleAtPoint(const awt::Point & _aPoint)1100cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL AccessibleEditableTextPara::getAccessibleAtPoint( const awt::Point& _aPoint ) throw (uno::RuntimeException) 1101cdf0e10cSrcweir { 1102cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1103cdf0e10cSrcweir 1104cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1105cdf0e10cSrcweir 1106cdf0e10cSrcweir if( HaveChildren() ) 1107cdf0e10cSrcweir { 1108cdf0e10cSrcweir // #103862# No longer need to make given position relative 1109cdf0e10cSrcweir Point aPoint( _aPoint.X, _aPoint.Y ); 1110cdf0e10cSrcweir 1111cdf0e10cSrcweir // respect EditEngine offset to surrounding shape/cell 1112cdf0e10cSrcweir aPoint -= GetEEOffset(); 1113cdf0e10cSrcweir 1114cdf0e10cSrcweir // convert to EditEngine coordinate system 1115cdf0e10cSrcweir SvxTextForwarder& rCacheTF = GetTextForwarder(); 1116cdf0e10cSrcweir Point aLogPoint( GetViewForwarder().PixelToLogic( aPoint, rCacheTF.GetMapMode() ) ); 1117cdf0e10cSrcweir 1118cdf0e10cSrcweir EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 > (GetParagraphIndex()) ); 1119cdf0e10cSrcweir 1120cdf0e10cSrcweir if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && 1121cdf0e10cSrcweir aBulletInfo.bVisible && 1122cdf0e10cSrcweir aBulletInfo.nType == SVX_NUM_BITMAP ) 1123cdf0e10cSrcweir { 1124cdf0e10cSrcweir Rectangle aRect = aBulletInfo.aBounds; 1125cdf0e10cSrcweir 1126cdf0e10cSrcweir if( aRect.IsInside( aLogPoint ) ) 1127cdf0e10cSrcweir return getAccessibleChild(0); 1128cdf0e10cSrcweir } 1129cdf0e10cSrcweir } 1130cdf0e10cSrcweir 1131cdf0e10cSrcweir // no children at all, or none at given position 1132cdf0e10cSrcweir return uno::Reference< XAccessible >(); 1133cdf0e10cSrcweir } 1134cdf0e10cSrcweir getBounds()1135cdf0e10cSrcweir awt::Rectangle SAL_CALL AccessibleEditableTextPara::getBounds() throw (uno::RuntimeException) 1136cdf0e10cSrcweir { 1137cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1138cdf0e10cSrcweir 1139cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1140cdf0e10cSrcweir 1141cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1142cdf0e10cSrcweir "AccessibleEditableTextPara::getBounds: index value overflow"); 1143cdf0e10cSrcweir 1144cdf0e10cSrcweir SvxTextForwarder& rCacheTF = GetTextForwarder(); 1145cdf0e10cSrcweir Rectangle aRect = rCacheTF.GetParaBounds( static_cast< sal_uInt16 >( GetParagraphIndex() ) ); 1146cdf0e10cSrcweir 1147cdf0e10cSrcweir // convert to screen coordinates 1148cdf0e10cSrcweir Rectangle aScreenRect = AccessibleEditableTextPara::LogicToPixel( aRect, 1149cdf0e10cSrcweir rCacheTF.GetMapMode(), 1150cdf0e10cSrcweir GetViewForwarder() ); 1151cdf0e10cSrcweir 1152cdf0e10cSrcweir // offset from shape/cell 1153cdf0e10cSrcweir Point aOffset = GetEEOffset(); 1154cdf0e10cSrcweir 1155cdf0e10cSrcweir return awt::Rectangle( aScreenRect.Left() + aOffset.X(), 1156cdf0e10cSrcweir aScreenRect.Top() + aOffset.Y(), 1157cdf0e10cSrcweir aScreenRect.GetSize().Width(), 1158cdf0e10cSrcweir aScreenRect.GetSize().Height() ); 1159cdf0e10cSrcweir } 1160cdf0e10cSrcweir getLocation()1161cdf0e10cSrcweir awt::Point SAL_CALL AccessibleEditableTextPara::getLocation( ) throw (uno::RuntimeException) 1162cdf0e10cSrcweir { 1163cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1164cdf0e10cSrcweir 1165cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1166cdf0e10cSrcweir 1167cdf0e10cSrcweir awt::Rectangle aRect = getBounds(); 1168cdf0e10cSrcweir 1169cdf0e10cSrcweir return awt::Point( aRect.X, aRect.Y ); 1170cdf0e10cSrcweir } 1171cdf0e10cSrcweir getLocationOnScreen()1172cdf0e10cSrcweir awt::Point SAL_CALL AccessibleEditableTextPara::getLocationOnScreen( ) throw (uno::RuntimeException) 1173cdf0e10cSrcweir { 1174cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1175cdf0e10cSrcweir 1176cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1177cdf0e10cSrcweir 1178cdf0e10cSrcweir // relate us to parent 1179cdf0e10cSrcweir uno::Reference< XAccessible > xParent = getAccessibleParent(); 1180cdf0e10cSrcweir if( xParent.is() ) 1181cdf0e10cSrcweir { 1182cdf0e10cSrcweir uno::Reference< XAccessibleComponent > xParentComponent( xParent, uno::UNO_QUERY ); 1183cdf0e10cSrcweir if( xParentComponent.is() ) 1184cdf0e10cSrcweir { 1185cdf0e10cSrcweir awt::Point aRefPoint = xParentComponent->getLocationOnScreen(); 1186cdf0e10cSrcweir awt::Point aPoint = getLocation(); 1187cdf0e10cSrcweir aPoint.X += aRefPoint.X; 1188cdf0e10cSrcweir aPoint.Y += aRefPoint.Y; 1189cdf0e10cSrcweir 1190cdf0e10cSrcweir return aPoint; 1191cdf0e10cSrcweir } 1192cdf0e10cSrcweir // --> OD 2009-12-16 #i88070# 1193cdf0e10cSrcweir // fallback to parent's <XAccessibleContext> instance 1194cdf0e10cSrcweir else 1195cdf0e10cSrcweir { 1196cdf0e10cSrcweir uno::Reference< XAccessibleContext > xParentContext = xParent->getAccessibleContext(); 1197cdf0e10cSrcweir if ( xParentContext.is() ) 1198cdf0e10cSrcweir { 1199cdf0e10cSrcweir uno::Reference< XAccessibleComponent > xParentContextComponent( xParentContext, uno::UNO_QUERY ); 1200cdf0e10cSrcweir if( xParentContextComponent.is() ) 1201cdf0e10cSrcweir { 1202cdf0e10cSrcweir awt::Point aRefPoint = xParentContextComponent->getLocationOnScreen(); 1203cdf0e10cSrcweir awt::Point aPoint = getLocation(); 1204cdf0e10cSrcweir aPoint.X += aRefPoint.X; 1205cdf0e10cSrcweir aPoint.Y += aRefPoint.Y; 1206cdf0e10cSrcweir 1207cdf0e10cSrcweir return aPoint; 1208cdf0e10cSrcweir } 1209cdf0e10cSrcweir } 1210cdf0e10cSrcweir } 1211cdf0e10cSrcweir // <-- 1212cdf0e10cSrcweir } 1213cdf0e10cSrcweir 1214cdf0e10cSrcweir throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Cannot access parent")), 1215cdf0e10cSrcweir uno::Reference< uno::XInterface > 1216cdf0e10cSrcweir ( static_cast< XAccessible* > (this) ) ); // disambiguate hierarchy 1217cdf0e10cSrcweir } 1218cdf0e10cSrcweir getSize()1219cdf0e10cSrcweir awt::Size SAL_CALL AccessibleEditableTextPara::getSize( ) throw (uno::RuntimeException) 1220cdf0e10cSrcweir { 1221cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1222cdf0e10cSrcweir 1223cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1224cdf0e10cSrcweir 1225cdf0e10cSrcweir awt::Rectangle aRect = getBounds(); 1226cdf0e10cSrcweir 1227cdf0e10cSrcweir return awt::Size( aRect.Width, aRect.Height ); 1228cdf0e10cSrcweir } 1229cdf0e10cSrcweir grabFocus()1230cdf0e10cSrcweir void SAL_CALL AccessibleEditableTextPara::grabFocus( ) throw (uno::RuntimeException) 1231cdf0e10cSrcweir { 1232cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1233cdf0e10cSrcweir 1234cdf0e10cSrcweir // set cursor to this paragraph 1235cdf0e10cSrcweir setSelection(0,0); 1236cdf0e10cSrcweir } 1237cdf0e10cSrcweir getForeground()1238cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleEditableTextPara::getForeground( ) throw (::com::sun::star::uno::RuntimeException) 1239cdf0e10cSrcweir { 1240cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1241cdf0e10cSrcweir 1242cdf0e10cSrcweir // #104444# Added to XAccessibleComponent interface 1243cdf0e10cSrcweir svtools::ColorConfig aColorConfig; 1244cdf0e10cSrcweir sal_uInt32 nColor = aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor; 1245cdf0e10cSrcweir return static_cast<sal_Int32>(nColor); 1246cdf0e10cSrcweir } 1247cdf0e10cSrcweir getBackground()1248cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleEditableTextPara::getBackground( ) throw (::com::sun::star::uno::RuntimeException) 1249cdf0e10cSrcweir { 1250cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1251cdf0e10cSrcweir 1252cdf0e10cSrcweir // #104444# Added to XAccessibleComponent interface 1253cdf0e10cSrcweir Color aColor( Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor() ); 1254cdf0e10cSrcweir 1255cdf0e10cSrcweir // the background is transparent 1256cdf0e10cSrcweir aColor.SetTransparency( 0xFF); 1257cdf0e10cSrcweir 1258cdf0e10cSrcweir return static_cast<sal_Int32>( aColor.GetColor() ); 1259cdf0e10cSrcweir } 1260cdf0e10cSrcweir 1261cdf0e10cSrcweir // XAccessibleText getCaretPosition()1262cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleEditableTextPara::getCaretPosition() throw (uno::RuntimeException) 1263cdf0e10cSrcweir { 1264cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1265cdf0e10cSrcweir 1266cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1267cdf0e10cSrcweir 1268cdf0e10cSrcweir if( !HaveEditView() ) 1269cdf0e10cSrcweir return -1; 1270cdf0e10cSrcweir 1271cdf0e10cSrcweir ESelection aSelection; 1272cdf0e10cSrcweir if( GetEditViewForwarder().GetSelection( aSelection ) && 1273cdf0e10cSrcweir GetParagraphIndex() == aSelection.nEndPara ) 1274cdf0e10cSrcweir { 1275cdf0e10cSrcweir // caret is always nEndPara,nEndPos 12769b8096d0SSteve Yin EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 12779b8096d0SSteve Yin if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && 12789b8096d0SSteve Yin aBulletInfo.bVisible && 12799b8096d0SSteve Yin aBulletInfo.nType != SVX_NUM_BITMAP ) 12809b8096d0SSteve Yin { 12819b8096d0SSteve Yin sal_Int32 nBulletLen = aBulletInfo.aText.Len(); 12829b8096d0SSteve Yin if( aSelection.nEndPos - nBulletLen >= 0 ) 12839b8096d0SSteve Yin return aSelection.nEndPos - nBulletLen; 12849b8096d0SSteve Yin } 1285cdf0e10cSrcweir return aSelection.nEndPos; 1286cdf0e10cSrcweir } 1287cdf0e10cSrcweir 1288cdf0e10cSrcweir // not within this paragraph 1289cdf0e10cSrcweir return -1; 1290cdf0e10cSrcweir } 1291cdf0e10cSrcweir setCaretPosition(sal_Int32 nIndex)1292cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleEditableTextPara::setCaretPosition( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1293cdf0e10cSrcweir { 1294cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1295cdf0e10cSrcweir 1296cdf0e10cSrcweir return setSelection(nIndex, nIndex); 1297cdf0e10cSrcweir } 1298cdf0e10cSrcweir getCharacter(sal_Int32 nIndex)1299cdf0e10cSrcweir sal_Unicode SAL_CALL AccessibleEditableTextPara::getCharacter( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1300cdf0e10cSrcweir { 1301cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1302cdf0e10cSrcweir 1303cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1304cdf0e10cSrcweir 1305cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1306cdf0e10cSrcweir "AccessibleEditableTextPara::getCharacter: index value overflow"); 1307cdf0e10cSrcweir 1308cdf0e10cSrcweir return OCommonAccessibleText::getCharacter( nIndex ); 1309cdf0e10cSrcweir } getAttributeNames()13109b8096d0SSteve Yin static uno::Sequence< ::rtl::OUString > getAttributeNames() 13119b8096d0SSteve Yin { 13129b8096d0SSteve Yin static uno::Sequence< ::rtl::OUString >* pNames = NULL; 13139b8096d0SSteve Yin 13149b8096d0SSteve Yin if( pNames == NULL ) 13159b8096d0SSteve Yin { 13169b8096d0SSteve Yin uno::Sequence< ::rtl::OUString >* pSeq = new uno::Sequence< ::rtl::OUString >( 21 ); 13179b8096d0SSteve Yin ::rtl::OUString* pStrings = pSeq->getArray(); 13189b8096d0SSteve Yin sal_Int32 i = 0; 13199b8096d0SSteve Yin #define STR(x) pStrings[i++] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(x)) 13209b8096d0SSteve Yin //STR("CharBackColor"); 13219b8096d0SSteve Yin STR("CharColor"); 13229b8096d0SSteve Yin STR("CharContoured"); 13239b8096d0SSteve Yin STR("CharEmphasis"); 13249b8096d0SSteve Yin STR("CharEscapement"); 13259b8096d0SSteve Yin STR("CharFontName"); 13269b8096d0SSteve Yin STR("CharHeight"); 13279b8096d0SSteve Yin STR("CharPosture"); 13289b8096d0SSteve Yin STR("CharShadowed"); 13299b8096d0SSteve Yin STR("CharStrikeout"); 13309b8096d0SSteve Yin STR("CharUnderline"); 13319b8096d0SSteve Yin STR("CharUnderlineColor"); 13329b8096d0SSteve Yin STR("CharWeight"); 13339b8096d0SSteve Yin STR("NumberingLevel"); 13349b8096d0SSteve Yin STR("NumberingRules"); 13359b8096d0SSteve Yin STR("ParaAdjust"); 13369b8096d0SSteve Yin STR("ParaBottomMargin"); 13379b8096d0SSteve Yin STR("ParaFirstLineIndent"); 13389b8096d0SSteve Yin STR("ParaLeftMargin"); 13399b8096d0SSteve Yin STR("ParaLineSpacing"); 13409b8096d0SSteve Yin STR("ParaRightMargin"); 13419b8096d0SSteve Yin STR("ParaTabStops"); 13429b8096d0SSteve Yin #undef STR 13439b8096d0SSteve Yin DBG_ASSERT( i == pSeq->getLength(), "Please adjust length" ); 13449b8096d0SSteve Yin if( i != pSeq->getLength() ) 13459b8096d0SSteve Yin pSeq->realloc( i ); 13469b8096d0SSteve Yin pNames = pSeq; 13479b8096d0SSteve Yin } 13489b8096d0SSteve Yin return *pNames; 13499b8096d0SSteve Yin } 13509b8096d0SSteve Yin struct IndexCompare 13519b8096d0SSteve Yin { 13529b8096d0SSteve Yin const PropertyValue* pValues; IndexCompareaccessibility::IndexCompare13539b8096d0SSteve Yin IndexCompare( const PropertyValue* pVals ) : pValues(pVals) {} operator ()accessibility::IndexCompare13549b8096d0SSteve Yin bool operator() ( const sal_Int32& a, const sal_Int32& b ) const 13559b8096d0SSteve Yin { 13569b8096d0SSteve Yin return (pValues[a].Name < pValues[b].Name) ? true : false; 13579b8096d0SSteve Yin } 13589b8096d0SSteve Yin }; 13599b8096d0SSteve Yin GetFieldTypeNameAtIndex(sal_Int32 nIndex)13609b8096d0SSteve Yin String AccessibleEditableTextPara::GetFieldTypeNameAtIndex(sal_Int32 nIndex) 13619b8096d0SSteve Yin { 13629b8096d0SSteve Yin String strFldType; 13639b8096d0SSteve Yin SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); 13649b8096d0SSteve Yin //For field object info 13659b8096d0SSteve Yin sal_Int32 nParaIndex = GetParagraphIndex(); 13669b8096d0SSteve Yin sal_Int32 nAllFieldLen = 0; 13679b8096d0SSteve Yin sal_Int32 nField = rCacheTF.GetFieldCount(sal_uInt16(nParaIndex)), nFoundFieldIndex = -1; 13689b8096d0SSteve Yin EFieldInfo ree; 13699b8096d0SSteve Yin sal_Int32 reeBegin, reeEnd; 13709b8096d0SSteve Yin sal_Int32 nFieldType = -1; 13719b8096d0SSteve Yin for(sal_uInt16 j = 0; j < nField; j++) 13729b8096d0SSteve Yin { 13739b8096d0SSteve Yin ree = rCacheTF.GetFieldInfo(sal_uInt16(nParaIndex), j); 13749b8096d0SSteve Yin reeBegin = ree.aPosition.nIndex + nAllFieldLen; 13759b8096d0SSteve Yin reeEnd = reeBegin + ree.aCurrentText.Len(); 13769b8096d0SSteve Yin nAllFieldLen += (ree.aCurrentText.Len() - 1); 13779b8096d0SSteve Yin if( reeBegin > nIndex ) 13789b8096d0SSteve Yin { 13799b8096d0SSteve Yin break; 13809b8096d0SSteve Yin } 13819b8096d0SSteve Yin if( nIndex >= reeBegin && nIndex < reeEnd ) 13829b8096d0SSteve Yin { 13839b8096d0SSteve Yin nFoundFieldIndex = j; 13849b8096d0SSteve Yin break; 13859b8096d0SSteve Yin } 13869b8096d0SSteve Yin } 13879b8096d0SSteve Yin if( nFoundFieldIndex >= 0 ) 13889b8096d0SSteve Yin { 13899b8096d0SSteve Yin // So we get a field, check its type now. 13909b8096d0SSteve Yin nFieldType = ree.pFieldItem->GetField()->GetClassId() ; 13919b8096d0SSteve Yin } 13929b8096d0SSteve Yin switch(nFieldType) 13939b8096d0SSteve Yin { 13949b8096d0SSteve Yin case SVX_DATEFIELD: 13959b8096d0SSteve Yin { 13969b8096d0SSteve Yin const SvxDateField* pDateField = static_cast< const SvxDateField* >(ree.pFieldItem->GetField()); 13979b8096d0SSteve Yin if (pDateField) 13989b8096d0SSteve Yin { 13999b8096d0SSteve Yin if (pDateField->GetType() == SVXDATETYPE_FIX) 14009b8096d0SSteve Yin strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("date (fixed)")); 14019b8096d0SSteve Yin else if (pDateField->GetType() == SVXDATETYPE_VAR) 14029b8096d0SSteve Yin strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("date (variable)")); 14039b8096d0SSteve Yin } 14049b8096d0SSteve Yin } 14059b8096d0SSteve Yin break; 14069b8096d0SSteve Yin case SVX_PAGEFIELD: 14079b8096d0SSteve Yin strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("page-number")); 14089b8096d0SSteve Yin break; 14090deba7fbSSteve Yin //support the sheet name & pages fields 14109b8096d0SSteve Yin case SVX_PAGESFIELD: 14119b8096d0SSteve Yin strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("page-count")); 14129b8096d0SSteve Yin break; 14139b8096d0SSteve Yin case SVX_TABLEFIELD: 14149b8096d0SSteve Yin strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sheet-name")); 14159b8096d0SSteve Yin break; 14160deba7fbSSteve Yin //End 14179b8096d0SSteve Yin case SVX_TIMEFIELD: 14189b8096d0SSteve Yin strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("time")); 14199b8096d0SSteve Yin break; 14209b8096d0SSteve Yin case SVX_EXT_TIMEFIELD: 14219b8096d0SSteve Yin { 14229b8096d0SSteve Yin const SvxExtTimeField* pTimeField = static_cast< const SvxExtTimeField* >(ree.pFieldItem->GetField()); 14239b8096d0SSteve Yin if (pTimeField) 14249b8096d0SSteve Yin { 14259b8096d0SSteve Yin if (pTimeField->GetType() == SVXTIMETYPE_FIX) 14269b8096d0SSteve Yin strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("time (fixed)")); 14279b8096d0SSteve Yin else if (pTimeField->GetType() == SVXTIMETYPE_VAR) 14289b8096d0SSteve Yin strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("time (variable)")); 14299b8096d0SSteve Yin } 14309b8096d0SSteve Yin } 14319b8096d0SSteve Yin break; 14329b8096d0SSteve Yin case SVX_AUTHORFIELD: 14339b8096d0SSteve Yin strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("author")); 14349b8096d0SSteve Yin break; 14359b8096d0SSteve Yin case SVX_EXT_FILEFIELD: 14369b8096d0SSteve Yin case SVX_FILEFIELD: 14379b8096d0SSteve Yin strFldType = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file name")); 14389b8096d0SSteve Yin default: 14399b8096d0SSteve Yin break; 14409b8096d0SSteve Yin } 14419b8096d0SSteve Yin return strFldType; 14429b8096d0SSteve Yin } 1443cdf0e10cSrcweir getCharacterAttributes(sal_Int32 nIndex,const::com::sun::star::uno::Sequence<::rtl::OUString> & rRequestedAttributes)1444cdf0e10cSrcweir 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) 1445cdf0e10cSrcweir { 1446cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1447cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 14489b8096d0SSteve Yin 14499b8096d0SSteve Yin //Skip the bullet range to ingnore the bullet text 14509b8096d0SSteve Yin SvxTextForwarder& rCacheTF = GetTextForwarder(); 14519b8096d0SSteve Yin EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 14529b8096d0SSteve Yin if (aBulletInfo.bVisible) 14539b8096d0SSteve Yin nIndex += aBulletInfo.aText.Len(); 14549b8096d0SSteve Yin if (nIndex != 0 && nIndex >= getCharacterCount()) 14559b8096d0SSteve Yin nIndex = getCharacterCount()-1; 14569b8096d0SSteve Yin // 14579b8096d0SSteve Yin if (nIndex != 0) 14589b8096d0SSteve Yin CheckIndex(nIndex); // may throw IndexOutOfBoundsException 14599b8096d0SSteve Yin 14609b8096d0SSteve Yin bool bSupplementalMode = false; 14619b8096d0SSteve Yin uno::Sequence< ::rtl::OUString > aPropertyNames = rRequestedAttributes; 14629b8096d0SSteve Yin if (aPropertyNames.getLength() == 0) 14639b8096d0SSteve Yin { 14649b8096d0SSteve Yin bSupplementalMode = true; 14659b8096d0SSteve Yin aPropertyNames = getAttributeNames(); 14669b8096d0SSteve Yin } 1467cdf0e10cSrcweir // get default attribues... 14689b8096d0SSteve Yin ::comphelper::SequenceAsHashMap aPropHashMap( getDefaultAttributes( aPropertyNames ) ); 1469cdf0e10cSrcweir 1470cdf0e10cSrcweir // ... and override them with the direct attributes from the specific position 14719b8096d0SSteve Yin uno::Sequence< beans::PropertyValue > aRunAttribs( getRunAttributes( nIndex, aPropertyNames ) ); 1472cdf0e10cSrcweir sal_Int32 nRunAttribs = aRunAttribs.getLength(); 1473cdf0e10cSrcweir const beans::PropertyValue *pRunAttrib = aRunAttribs.getConstArray(); 1474cdf0e10cSrcweir for (sal_Int32 k = 0; k < nRunAttribs; ++k) 1475cdf0e10cSrcweir { 1476cdf0e10cSrcweir const beans::PropertyValue &rRunAttrib = pRunAttrib[k]; 1477cdf0e10cSrcweir aPropHashMap[ rRunAttrib.Name ] = rRunAttrib.Value; //!! should not only be the value !! 1478cdf0e10cSrcweir } 1479cdf0e10cSrcweir #ifdef TL_DEBUG 1480cdf0e10cSrcweir { 1481cdf0e10cSrcweir uno::Sequence< rtl::OUString > aNames(1); 1482cdf0e10cSrcweir aNames.getArray()[0] = rtl::OUString::createFromAscii("CharHeight"); 1483cdf0e10cSrcweir const rtl::OUString *pNames = aNames.getConstArray(); 1484cdf0e10cSrcweir const uno::Sequence< beans::PropertyValue > aAttribs( getRunAttributes( nIndex, aNames ) ); 1485cdf0e10cSrcweir const beans::PropertyValue *pAttribs = aAttribs.getConstArray(); 1486cdf0e10cSrcweir double d1 = -1.0; 1487cdf0e10cSrcweir float f1 = -1.0; 1488cdf0e10cSrcweir if (aAttribs.getLength()) 1489cdf0e10cSrcweir { 1490cdf0e10cSrcweir uno::Any aAny( pAttribs[0].Value ); 1491cdf0e10cSrcweir aAny >>= d1; 1492cdf0e10cSrcweir aAny >>= f1; 1493cdf0e10cSrcweir } 1494cdf0e10cSrcweir int i = 3; 1495cdf0e10cSrcweir } 1496cdf0e10cSrcweir #endif 1497cdf0e10cSrcweir 1498cdf0e10cSrcweir // get resulting sequence 1499cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aRes; 1500cdf0e10cSrcweir aPropHashMap >> aRes; 1501cdf0e10cSrcweir 1502cdf0e10cSrcweir // since SequenceAsHashMap ignores property handles and property state 1503cdf0e10cSrcweir // we have to restore the property state here (property handles are 1504cdf0e10cSrcweir // of no use to the accessibility API). 1505cdf0e10cSrcweir sal_Int32 nRes = aRes.getLength(); 1506cdf0e10cSrcweir beans::PropertyValue *pRes = aRes.getArray(); 1507cdf0e10cSrcweir for (sal_Int32 i = 0; i < nRes; ++i) 1508cdf0e10cSrcweir { 1509cdf0e10cSrcweir beans::PropertyValue &rRes = pRes[i]; 1510cdf0e10cSrcweir sal_Bool bIsDirectVal = sal_False; 1511cdf0e10cSrcweir for (sal_Int32 k = 0; k < nRunAttribs && !bIsDirectVal; ++k) 1512cdf0e10cSrcweir { 1513cdf0e10cSrcweir if (rRes.Name == pRunAttrib[k].Name) 1514cdf0e10cSrcweir bIsDirectVal = sal_True; 1515cdf0e10cSrcweir } 1516cdf0e10cSrcweir rRes.Handle = -1; 1517cdf0e10cSrcweir rRes.State = bIsDirectVal ? PropertyState_DIRECT_VALUE : PropertyState_DEFAULT_VALUE; 1518cdf0e10cSrcweir } 15199b8096d0SSteve Yin if( bSupplementalMode ) 15209b8096d0SSteve Yin { 15219b8096d0SSteve Yin _correctValues( nIndex, aRes ); 15229b8096d0SSteve Yin // NumberingPrefix 15239b8096d0SSteve Yin nRes = aRes.getLength(); 15249b8096d0SSteve Yin aRes.realloc( nRes + 1 ); 15259b8096d0SSteve Yin pRes = aRes.getArray(); 15269b8096d0SSteve Yin beans::PropertyValue &rRes = pRes[nRes]; 15279b8096d0SSteve Yin rRes.Name = rtl::OUString::createFromAscii("NumberingPrefix"); 15289b8096d0SSteve Yin ::rtl::OUString numStr; 15299b8096d0SSteve Yin if (aBulletInfo.nType != SVX_NUM_CHAR_SPECIAL && aBulletInfo.nType != SVX_NUM_BITMAP) 15309b8096d0SSteve Yin numStr = (::rtl::OUString)aBulletInfo.aText; 15319b8096d0SSteve Yin rRes.Value <<= numStr; 15329b8096d0SSteve Yin rRes.Handle = -1; 15339b8096d0SSteve Yin rRes.State = PropertyState_DIRECT_VALUE; 15349b8096d0SSteve Yin //For field object. 15359b8096d0SSteve Yin String strFieldType = GetFieldTypeNameAtIndex(nIndex); 15369b8096d0SSteve Yin if (strFieldType.Len() > 0) 15379b8096d0SSteve Yin { 15389b8096d0SSteve Yin nRes = aRes.getLength(); 15399b8096d0SSteve Yin aRes.realloc( nRes + 1 ); 15409b8096d0SSteve Yin pRes = aRes.getArray(); 15419b8096d0SSteve Yin beans::PropertyValue &rResField = pRes[nRes]; 15429b8096d0SSteve Yin beans::PropertyValue aFieldType; 15439b8096d0SSteve Yin rResField.Name = rtl::OUString::createFromAscii("FieldType"); 15449b8096d0SSteve Yin rResField.Value <<= rtl::OUString(strFieldType.ToLowerAscii()); 15459b8096d0SSteve Yin rResField.Handle = -1; 15469b8096d0SSteve Yin rResField.State = PropertyState_DIRECT_VALUE; 15479b8096d0SSteve Yin } 15489b8096d0SSteve Yin //sort property values 15499b8096d0SSteve Yin // build sorted index array 15509b8096d0SSteve Yin sal_Int32 nLength = aRes.getLength(); 15519b8096d0SSteve Yin const beans::PropertyValue* pPairs = aRes.getConstArray(); 15529b8096d0SSteve Yin sal_Int32* pIndices = new sal_Int32[nLength]; 15539b8096d0SSteve Yin sal_Int32 i = 0; 15549b8096d0SSteve Yin for( i = 0; i < nLength; i++ ) 15559b8096d0SSteve Yin pIndices[i] = i; 15569b8096d0SSteve Yin sort( &pIndices[0], &pIndices[nLength], IndexCompare(pPairs) ); 15579b8096d0SSteve Yin // create sorted sequences accoring to index array 15589b8096d0SSteve Yin uno::Sequence<beans::PropertyValue> aNewValues( nLength ); 15599b8096d0SSteve Yin beans::PropertyValue* pNewValues = aNewValues.getArray(); 15609b8096d0SSteve Yin for( i = 0; i < nLength; i++ ) 15619b8096d0SSteve Yin { 15629b8096d0SSteve Yin pNewValues[i] = pPairs[pIndices[i]]; 15639b8096d0SSteve Yin } 15649b8096d0SSteve Yin delete[] pIndices; 15659b8096d0SSteve Yin // 15669b8096d0SSteve Yin return aNewValues; 15679b8096d0SSteve Yin } 15689b8096d0SSteve Yin return aRes; 1569cdf0e10cSrcweir } 1570cdf0e10cSrcweir getCharacterBounds(sal_Int32 nIndex)1571cdf0e10cSrcweir awt::Rectangle SAL_CALL AccessibleEditableTextPara::getCharacterBounds( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1572cdf0e10cSrcweir { 1573cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1574cdf0e10cSrcweir 1575cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1576cdf0e10cSrcweir 1577cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1578cdf0e10cSrcweir "AccessibleEditableTextPara::getCharacterBounds: index value overflow"); 1579cdf0e10cSrcweir 1580cdf0e10cSrcweir // #108900# Have position semantics now for nIndex, as 1581cdf0e10cSrcweir // one-past-the-end values are legal, too. 1582cdf0e10cSrcweir CheckPosition( nIndex ); 1583cdf0e10cSrcweir 1584cdf0e10cSrcweir SvxTextForwarder& rCacheTF = GetTextForwarder(); 1585cdf0e10cSrcweir Rectangle aRect = rCacheTF.GetCharBounds( static_cast< sal_uInt16 >( GetParagraphIndex() ), static_cast< sal_uInt16 >( nIndex ) ); 1586cdf0e10cSrcweir 1587cdf0e10cSrcweir // convert to screen 1588cdf0e10cSrcweir Rectangle aScreenRect = AccessibleEditableTextPara::LogicToPixel( aRect, 1589cdf0e10cSrcweir rCacheTF.GetMapMode(), 1590cdf0e10cSrcweir GetViewForwarder() ); 1591cdf0e10cSrcweir // #109864# offset from parent (paragraph), but in screen 1592cdf0e10cSrcweir // coordinates. This makes sure the internal text offset in 1593cdf0e10cSrcweir // the outline view forwarder gets cancelled out here 1594cdf0e10cSrcweir awt::Rectangle aParaRect( getBounds() ); 1595cdf0e10cSrcweir aScreenRect.Move( -aParaRect.X, -aParaRect.Y ); 1596cdf0e10cSrcweir 1597cdf0e10cSrcweir // offset from shape/cell 1598cdf0e10cSrcweir Point aOffset = GetEEOffset(); 1599cdf0e10cSrcweir 1600cdf0e10cSrcweir return awt::Rectangle( aScreenRect.Left() + aOffset.X(), 1601cdf0e10cSrcweir aScreenRect.Top() + aOffset.Y(), 1602cdf0e10cSrcweir aScreenRect.GetSize().Width(), 1603cdf0e10cSrcweir aScreenRect.GetSize().Height() ); 1604cdf0e10cSrcweir } 1605cdf0e10cSrcweir getCharacterCount()1606cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleEditableTextPara::getCharacterCount() throw (uno::RuntimeException) 1607cdf0e10cSrcweir { 1608cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1609cdf0e10cSrcweir 1610cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1611cdf0e10cSrcweir 1612cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1613cdf0e10cSrcweir "AccessibleEditableTextPara::getCharacterCount: index value overflow"); 1614cdf0e10cSrcweir 1615cdf0e10cSrcweir return OCommonAccessibleText::getCharacterCount(); 1616cdf0e10cSrcweir } 1617cdf0e10cSrcweir getIndexAtPoint(const awt::Point & rPoint)1618cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleEditableTextPara::getIndexAtPoint( const awt::Point& rPoint ) throw (uno::RuntimeException) 1619cdf0e10cSrcweir { 1620cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1621cdf0e10cSrcweir 1622cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 16239b8096d0SSteve Yin if ((rPoint.X <= 0) && (rPoint.Y <= 0)) 16249b8096d0SSteve Yin return 0; 1625cdf0e10cSrcweir sal_uInt16 nPara, nIndex; 1626cdf0e10cSrcweir 1627cdf0e10cSrcweir // offset from surrounding cell/shape 1628cdf0e10cSrcweir Point aOffset( GetEEOffset() ); 1629cdf0e10cSrcweir Point aPoint( rPoint.X - aOffset.X(), rPoint.Y - aOffset.Y() ); 1630cdf0e10cSrcweir 1631cdf0e10cSrcweir // convert to logical coordinates 1632cdf0e10cSrcweir SvxTextForwarder& rCacheTF = GetTextForwarder(); 1633cdf0e10cSrcweir Point aLogPoint( GetViewForwarder().PixelToLogic( aPoint, rCacheTF.GetMapMode() ) ); 1634cdf0e10cSrcweir 1635cdf0e10cSrcweir // re-offset to parent (paragraph) 1636cdf0e10cSrcweir Rectangle aParaRect = rCacheTF.GetParaBounds( static_cast< sal_uInt16 >( GetParagraphIndex() ) ); 1637cdf0e10cSrcweir aLogPoint.Move( aParaRect.Left(), aParaRect.Top() ); 1638cdf0e10cSrcweir 1639cdf0e10cSrcweir if( rCacheTF.GetIndexAtPoint( aLogPoint, nPara, nIndex ) && 1640cdf0e10cSrcweir GetParagraphIndex() == nPara ) 1641cdf0e10cSrcweir { 1642cdf0e10cSrcweir // #102259# Double-check if we're _really_ on the given character 1643cdf0e10cSrcweir try 1644cdf0e10cSrcweir { 1645cdf0e10cSrcweir awt::Rectangle aRect1( getCharacterBounds(nIndex) ); 1646cdf0e10cSrcweir Rectangle aRect2( aRect1.X, aRect1.Y, 1647cdf0e10cSrcweir aRect1.Width + aRect1.X, aRect1.Height + aRect1.Y ); 1648cdf0e10cSrcweir if( aRect2.IsInside( Point( rPoint.X, rPoint.Y ) ) ) 1649cdf0e10cSrcweir return nIndex; 1650cdf0e10cSrcweir else 1651cdf0e10cSrcweir return -1; 1652cdf0e10cSrcweir } 1653cdf0e10cSrcweir catch( const lang::IndexOutOfBoundsException& ) 1654cdf0e10cSrcweir { 1655cdf0e10cSrcweir // #103927# Don't throw for invalid nIndex values 1656cdf0e10cSrcweir return -1; 1657cdf0e10cSrcweir } 1658cdf0e10cSrcweir } 1659cdf0e10cSrcweir else 1660cdf0e10cSrcweir { 1661cdf0e10cSrcweir // not within our paragraph 1662cdf0e10cSrcweir return -1; 1663cdf0e10cSrcweir } 1664cdf0e10cSrcweir } 1665cdf0e10cSrcweir getSelectedText()1666cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getSelectedText() throw (uno::RuntimeException) 1667cdf0e10cSrcweir { 1668cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1669cdf0e10cSrcweir 1670cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1671cdf0e10cSrcweir 1672cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1673cdf0e10cSrcweir "AccessibleEditableTextPara::getSelectedText: index value overflow"); 1674cdf0e10cSrcweir 1675cdf0e10cSrcweir if( !HaveEditView() ) 1676cdf0e10cSrcweir return ::rtl::OUString(); 1677cdf0e10cSrcweir 1678cdf0e10cSrcweir return OCommonAccessibleText::getSelectedText(); 1679cdf0e10cSrcweir } 1680cdf0e10cSrcweir getSelectionStart()1681cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleEditableTextPara::getSelectionStart() throw (uno::RuntimeException) 1682cdf0e10cSrcweir { 1683cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1684cdf0e10cSrcweir 1685cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1686cdf0e10cSrcweir 1687cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1688cdf0e10cSrcweir "AccessibleEditableTextPara::getSelectionStart: index value overflow"); 1689cdf0e10cSrcweir 1690cdf0e10cSrcweir if( !HaveEditView() ) 1691cdf0e10cSrcweir return -1; 1692cdf0e10cSrcweir 1693cdf0e10cSrcweir return OCommonAccessibleText::getSelectionStart(); 1694cdf0e10cSrcweir } 1695cdf0e10cSrcweir getSelectionEnd()1696cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleEditableTextPara::getSelectionEnd() throw (uno::RuntimeException) 1697cdf0e10cSrcweir { 1698cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1699cdf0e10cSrcweir 1700cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1701cdf0e10cSrcweir 1702cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1703cdf0e10cSrcweir "AccessibleEditableTextPara::getSelectionEnd: index value overflow"); 1704cdf0e10cSrcweir 1705cdf0e10cSrcweir if( !HaveEditView() ) 1706cdf0e10cSrcweir return -1; 1707cdf0e10cSrcweir 1708cdf0e10cSrcweir return OCommonAccessibleText::getSelectionEnd(); 1709cdf0e10cSrcweir } 1710cdf0e10cSrcweir setSelection(sal_Int32 nStartIndex,sal_Int32 nEndIndex)1711cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleEditableTextPara::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1712cdf0e10cSrcweir { 1713cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1714cdf0e10cSrcweir 1715cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1716cdf0e10cSrcweir 1717cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1718cdf0e10cSrcweir "AccessibleEditableTextPara::setSelection: paragraph index value overflow"); 1719cdf0e10cSrcweir 1720cdf0e10cSrcweir CheckRange(nStartIndex, nEndIndex); 1721cdf0e10cSrcweir 1722cdf0e10cSrcweir try 1723cdf0e10cSrcweir { 1724cdf0e10cSrcweir SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_True ); 1725cdf0e10cSrcweir return rCacheVF.SetSelection( MakeSelection(nStartIndex, nEndIndex) ); 1726cdf0e10cSrcweir } 1727cdf0e10cSrcweir catch( const uno::RuntimeException& ) 1728cdf0e10cSrcweir { 1729cdf0e10cSrcweir return sal_False; 1730cdf0e10cSrcweir } 1731cdf0e10cSrcweir } 1732cdf0e10cSrcweir getText()1733cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getText() throw (uno::RuntimeException) 1734cdf0e10cSrcweir { 1735cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1736cdf0e10cSrcweir 1737cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1738cdf0e10cSrcweir 1739cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1740cdf0e10cSrcweir "AccessibleEditableTextPara::getText: paragraph index value overflow"); 1741cdf0e10cSrcweir 1742cdf0e10cSrcweir return OCommonAccessibleText::getText(); 1743cdf0e10cSrcweir } 1744cdf0e10cSrcweir getTextRange(sal_Int32 nStartIndex,sal_Int32 nEndIndex)1745cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 1746cdf0e10cSrcweir { 1747cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 1748cdf0e10cSrcweir 1749cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 1750cdf0e10cSrcweir 1751cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 1752cdf0e10cSrcweir "AccessibleEditableTextPara::getTextRange: paragraph index value overflow"); 1753cdf0e10cSrcweir 1754cdf0e10cSrcweir return OCommonAccessibleText::getTextRange(nStartIndex, nEndIndex); 1755cdf0e10cSrcweir } _correctValues(const sal_Int32,uno::Sequence<PropertyValue> & rValues)1756a16d9e18SPavel Janík void AccessibleEditableTextPara::_correctValues( const sal_Int32 /* nIndex */, 17579b8096d0SSteve Yin uno::Sequence< PropertyValue >& rValues) 17589b8096d0SSteve Yin { 17599b8096d0SSteve Yin SvxTextForwarder& rCacheTF = GetTextForwarder(); 17609b8096d0SSteve Yin sal_Int32 nRes = rValues.getLength(); 17619b8096d0SSteve Yin beans::PropertyValue *pRes = rValues.getArray(); 17629b8096d0SSteve Yin for (sal_Int32 i = 0; i < nRes; ++i) 17639b8096d0SSteve Yin { 17649b8096d0SSteve Yin beans::PropertyValue &rRes = pRes[i]; 17659b8096d0SSteve Yin // Char color 17669b8096d0SSteve Yin if (rRes.Name.compareTo(::rtl::OUString::createFromAscii("CharColor"))==0) 17679b8096d0SSteve Yin { 17689b8096d0SSteve Yin uno::Any &anyChar = rRes.Value; 1769b98ff797SHerbert Dürr sal_uInt32 crChar = static_cast<sal_uInt32>( reinterpret_cast<sal_uIntPtr>(anyChar.pReserved)); 17709b8096d0SSteve Yin if (COL_AUTO == crChar ) 17719b8096d0SSteve Yin { 17729b8096d0SSteve Yin uno::Reference< ::com::sun::star::accessibility::XAccessibleComponent > xComponent; 17739b8096d0SSteve Yin if (mxParent.is()) 17749b8096d0SSteve Yin { 17759b8096d0SSteve Yin xComponent.set(mxParent,uno::UNO_QUERY); 17769b8096d0SSteve Yin } 17779b8096d0SSteve Yin else 17789b8096d0SSteve Yin { 17799b8096d0SSteve Yin xComponent.set(m_xAccInfo,uno::UNO_QUERY); 17809b8096d0SSteve Yin } 17819b8096d0SSteve Yin if (xComponent.is()) 17829b8096d0SSteve Yin { 17839b8096d0SSteve Yin uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > xContext(xComponent,uno::UNO_QUERY); 17849b8096d0SSteve Yin if (xContext->getAccessibleRole() == AccessibleRole::SHAPE 17859b8096d0SSteve Yin || xContext->getAccessibleRole() == AccessibleRole::TABLE_CELL) 17869b8096d0SSteve Yin { 17879b8096d0SSteve Yin anyChar <<= COL_BLACK; 17889b8096d0SSteve Yin } 17899b8096d0SSteve Yin else 17909b8096d0SSteve Yin { 17919b8096d0SSteve Yin Color cr(xComponent->getBackground()); 17929b8096d0SSteve Yin crChar = cr.IsDark() ? COL_WHITE : COL_BLACK; 17939b8096d0SSteve Yin anyChar <<= crChar; 17949b8096d0SSteve Yin } 17959b8096d0SSteve Yin } 17969b8096d0SSteve Yin } 17979b8096d0SSteve Yin continue; 17989b8096d0SSteve Yin } 17999b8096d0SSteve Yin // Underline 18009b8096d0SSteve Yin if(rRes.Name.compareTo(::rtl::OUString::createFromAscii("CharUnderline"))==0) 18019b8096d0SSteve Yin { 18029b8096d0SSteve Yin /* 18039b8096d0SSteve Yin // MT: Implement XAccessibleTextMarkup, mark with TextMarkupType::SPELLCHECK. This way done in SW. 18049b8096d0SSteve Yin if (IsCurrentEditorEnableAutoSpell( mxParent )) 18059b8096d0SSteve Yin { 18069b8096d0SSteve Yin try 18079b8096d0SSteve Yin { 18089b8096d0SSteve Yin SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_False ); 18099b8096d0SSteve Yin sal_Bool bWrong = rCacheVF.IsWrongSpelledWordAtPos( GetParagraphIndex(), nIndex ); 18109b8096d0SSteve Yin if ( bWrong ) 18119b8096d0SSteve Yin { 18129b8096d0SSteve Yin uno::Any &anyUnderLine = pRes[9].Value; 18139b8096d0SSteve Yin // MT IA2: Not needed? sal_uInt16 crUnderLine = (sal_uInt16)(anyUnderLine.pReserved); 18149b8096d0SSteve Yin anyUnderLine <<= (sal_uInt16)UNDERLINE_WAVE; 18159b8096d0SSteve Yin } 18169b8096d0SSteve Yin } 18179b8096d0SSteve Yin catch( const uno::RuntimeException& ) 18189b8096d0SSteve Yin { 18199b8096d0SSteve Yin } 18209b8096d0SSteve Yin } 18219b8096d0SSteve Yin */ 18229b8096d0SSteve Yin continue; 18239b8096d0SSteve Yin } 18249b8096d0SSteve Yin // Underline color && Mis-spell 18259b8096d0SSteve Yin if(rRes.Name.compareTo(::rtl::OUString::createFromAscii("CharUnderlineColor"))==0) 18269b8096d0SSteve Yin { 18279b8096d0SSteve Yin uno::Any &anyCharUnderLine = rRes.Value; 1828b98ff797SHerbert Dürr sal_uInt32 crCharUnderLine = static_cast<sal_uInt32>( reinterpret_cast<sal_uIntPtr>( anyCharUnderLine.pReserved)); 18299b8096d0SSteve Yin if (COL_AUTO == crCharUnderLine ) 18309b8096d0SSteve Yin { 18319b8096d0SSteve Yin uno::Reference< ::com::sun::star::accessibility::XAccessibleComponent > xComponent; 18329b8096d0SSteve Yin if (mxParent.is()) 18339b8096d0SSteve Yin { 18349b8096d0SSteve Yin xComponent.set(mxParent,uno::UNO_QUERY); 18359b8096d0SSteve Yin } 18369b8096d0SSteve Yin else 18379b8096d0SSteve Yin { 18389b8096d0SSteve Yin xComponent.set(m_xAccInfo,uno::UNO_QUERY); 18399b8096d0SSteve Yin } 18409b8096d0SSteve Yin if (xComponent.is()) 18419b8096d0SSteve Yin { 18429b8096d0SSteve Yin uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > xContext(xComponent,uno::UNO_QUERY); 18439b8096d0SSteve Yin if (xContext->getAccessibleRole() == AccessibleRole::SHAPE 18449b8096d0SSteve Yin || xContext->getAccessibleRole() == AccessibleRole::TABLE_CELL) 18459b8096d0SSteve Yin { 18469b8096d0SSteve Yin anyCharUnderLine <<= COL_BLACK; 18479b8096d0SSteve Yin } 18489b8096d0SSteve Yin else 18499b8096d0SSteve Yin { 18509b8096d0SSteve Yin Color cr(xComponent->getBackground()); 18519b8096d0SSteve Yin crCharUnderLine = cr.IsDark() ? COL_WHITE : COL_BLACK; 18529b8096d0SSteve Yin anyCharUnderLine <<= crCharUnderLine; 18539b8096d0SSteve Yin } 18549b8096d0SSteve Yin } 18559b8096d0SSteve Yin } 18569b8096d0SSteve Yin // MT: Implement XAccessibleTextMarkup, mark with TextMarkupType::SPELLCHECK. This way done in SW. 18579b8096d0SSteve Yin /* 18589b8096d0SSteve Yin if (IsCurrentEditorEnableAutoSpell( mxParent )) 18599b8096d0SSteve Yin { 18609b8096d0SSteve Yin try 18619b8096d0SSteve Yin { 18629b8096d0SSteve Yin SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_False ); 18639b8096d0SSteve Yin sal_Bool bWrong = rCacheVF.IsWrongSpelledWordAtPos( GetParagraphIndex(), nIndex ); 18649b8096d0SSteve Yin if ( bWrong ) 18659b8096d0SSteve Yin { 18669b8096d0SSteve Yin uno::Any &anyUnderLineColor = rRes.Value; 18679b8096d0SSteve Yin // MT IA2: Not needed? sal_uInt16 crUnderLineColor = (sal_uInt16)(anyUnderLineColor.pReserved); 18689b8096d0SSteve Yin anyUnderLineColor <<= COL_LIGHTRED; 18699b8096d0SSteve Yin } 18709b8096d0SSteve Yin } 18719b8096d0SSteve Yin catch( const uno::RuntimeException& ) 18729b8096d0SSteve Yin { 18739b8096d0SSteve Yin } 18749b8096d0SSteve Yin } 18759b8096d0SSteve Yin */ 18769b8096d0SSteve Yin continue; 18779b8096d0SSteve Yin } 18789b8096d0SSteve Yin // NumberingLevel 18799b8096d0SSteve Yin if(rRes.Name.compareTo(::rtl::OUString::createFromAscii("NumberingLevel"))==0) 18809b8096d0SSteve Yin { 18819b8096d0SSteve Yin const SvxNumBulletItem& rNumBullet = ( SvxNumBulletItem& )rCacheTF.GetParaAttribs(static_cast< sal_uInt16 >(GetParagraphIndex())).Get(EE_PARA_NUMBULLET); 18829b8096d0SSteve Yin if(rNumBullet.GetNumRule()->GetLevelCount()==0) 18839b8096d0SSteve Yin { 18849b8096d0SSteve Yin rRes.Value <<= (sal_Int16)-1; 18859b8096d0SSteve Yin rRes.Handle = -1; 18869b8096d0SSteve Yin rRes.State = PropertyState_DIRECT_VALUE; 18879b8096d0SSteve Yin } 18889b8096d0SSteve Yin else 18899b8096d0SSteve Yin { 18909b8096d0SSteve Yin // SvxAccessibleTextPropertySet aPropSet( &GetEditSource(), 18919b8096d0SSteve Yin // ImplGetSvxCharAndParaPropertiesMap() ); 18929b8096d0SSteve Yin // MT IA2 TODO: Check if this is the correct replacement for ImplGetSvxCharAndParaPropertiesMap 18939b8096d0SSteve Yin SvxAccessibleTextPropertySet aPropSet( &GetEditSource(), ImplGetSvxTextPortionSvxPropertySet() ); 18949b8096d0SSteve Yin 18959b8096d0SSteve Yin aPropSet.SetSelection( MakeSelection( 0, GetTextLen() ) ); 18969b8096d0SSteve Yin rRes.Value = aPropSet._getPropertyValue( rRes.Name, mnParagraphIndex ); 18979b8096d0SSteve Yin rRes.State = aPropSet._getPropertyState( rRes.Name, mnParagraphIndex ); 18989b8096d0SSteve Yin rRes.Handle = -1; 18999b8096d0SSteve Yin } 19009b8096d0SSteve Yin continue; 19019b8096d0SSteve Yin } 19029b8096d0SSteve Yin // NumberingRules 19039b8096d0SSteve Yin if(rRes.Name.compareTo(::rtl::OUString::createFromAscii("NumberingRules"))==0) 19049b8096d0SSteve Yin { 19059b8096d0SSteve Yin SfxItemSet aAttribs = rCacheTF.GetParaAttribs( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 19069b8096d0SSteve Yin sal_Bool bVis = ((const SfxUInt16Item&)aAttribs.Get( EE_PARA_BULLETSTATE )).GetValue() ? sal_True : sal_False; 19079b8096d0SSteve Yin if(bVis) 19089b8096d0SSteve Yin { 19099b8096d0SSteve Yin rRes.Value <<= (sal_Int16)-1; 19109b8096d0SSteve Yin rRes.Handle = -1; 19119b8096d0SSteve Yin rRes.State = PropertyState_DIRECT_VALUE; 19129b8096d0SSteve Yin } 19139b8096d0SSteve Yin else 19149b8096d0SSteve Yin { 19159b8096d0SSteve Yin // MT IA2 TODO: Check if this is the correct replacement for ImplGetSvxCharAndParaPropertiesMap 19169b8096d0SSteve Yin SvxAccessibleTextPropertySet aPropSet( &GetEditSource(), ImplGetSvxTextPortionSvxPropertySet() ); 19179b8096d0SSteve Yin aPropSet.SetSelection( MakeSelection( 0, GetTextLen() ) ); 19189b8096d0SSteve Yin rRes.Value = aPropSet._getPropertyValue( rRes.Name, mnParagraphIndex ); 19199b8096d0SSteve Yin rRes.State = aPropSet._getPropertyState( rRes.Name, mnParagraphIndex ); 19209b8096d0SSteve Yin rRes.Handle = -1; 19219b8096d0SSteve Yin } 19229b8096d0SSteve Yin continue; 19239b8096d0SSteve Yin } 19249b8096d0SSteve Yin } 19259b8096d0SSteve Yin } SkipField(sal_Int32 nIndex,sal_Bool bForward)19269b8096d0SSteve Yin sal_Int32 AccessibleEditableTextPara::SkipField(sal_Int32 nIndex, sal_Bool bForward) 19279b8096d0SSteve Yin { 19289b8096d0SSteve Yin sal_Int32 nParaIndex = GetParagraphIndex(); 19299b8096d0SSteve Yin SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); 19309b8096d0SSteve Yin sal_Int32 nAllFieldLen = 0; 19319b8096d0SSteve Yin sal_Int32 nField = rCacheTF.GetFieldCount(sal_uInt16(nParaIndex)), nFoundFieldIndex = -1; 19329b8096d0SSteve Yin EFieldInfo ree; 19339b8096d0SSteve Yin sal_Int32 reeBegin=0, reeEnd=0; 19349b8096d0SSteve Yin for(sal_uInt16 j = 0; j < nField; j++) 19359b8096d0SSteve Yin { 19369b8096d0SSteve Yin ree = rCacheTF.GetFieldInfo(sal_uInt16(nParaIndex), j); 19379b8096d0SSteve Yin reeBegin = ree.aPosition.nIndex + nAllFieldLen; 19389b8096d0SSteve Yin reeEnd = reeBegin + ree.aCurrentText.Len(); 19399b8096d0SSteve Yin nAllFieldLen += (ree.aCurrentText.Len() - 1); 19409b8096d0SSteve Yin if( reeBegin > nIndex ) 19419b8096d0SSteve Yin { 19429b8096d0SSteve Yin break; 19439b8096d0SSteve Yin } 19449b8096d0SSteve Yin if( nIndex >= reeBegin && nIndex < reeEnd ) 19459b8096d0SSteve Yin { 19469b8096d0SSteve Yin if(ree.pFieldItem->GetField()->GetClassId() != SVX_URLFIELD) 19479b8096d0SSteve Yin { 19489b8096d0SSteve Yin nFoundFieldIndex = j; 19499b8096d0SSteve Yin break; 19509b8096d0SSteve Yin } 19519b8096d0SSteve Yin } 19529b8096d0SSteve Yin } 19539b8096d0SSteve Yin if( nFoundFieldIndex >= 0 ) 19549b8096d0SSteve Yin { 19559b8096d0SSteve Yin if( bForward ) 19569b8096d0SSteve Yin return reeEnd - 1; 19579b8096d0SSteve Yin else 19589b8096d0SSteve Yin return reeBegin; 19599b8096d0SSteve Yin } 19609b8096d0SSteve Yin return nIndex; 19619b8096d0SSteve Yin } ExtendByField(::com::sun::star::accessibility::TextSegment & Segment)19629b8096d0SSteve Yin sal_Bool AccessibleEditableTextPara::ExtendByField( ::com::sun::star::accessibility::TextSegment& Segment ) 19639b8096d0SSteve Yin { 19649b8096d0SSteve Yin sal_Int32 nParaIndex = GetParagraphIndex(); 19659b8096d0SSteve Yin SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); 19669b8096d0SSteve Yin sal_Int32 nAllFieldLen = 0; 19679b8096d0SSteve Yin sal_Int32 nField = rCacheTF.GetFieldCount(sal_uInt16(nParaIndex)), nFoundFieldIndex = -1; 19689b8096d0SSteve Yin EFieldInfo ree; 19699b8096d0SSteve Yin sal_Int32 reeBegin=0, reeEnd=0; 19709b8096d0SSteve Yin for(sal_uInt16 j = 0; j < nField; j++) 19719b8096d0SSteve Yin { 19729b8096d0SSteve Yin ree = rCacheTF.GetFieldInfo(sal_uInt16(nParaIndex), j); 19739b8096d0SSteve Yin reeBegin = ree.aPosition.nIndex + nAllFieldLen; 19749b8096d0SSteve Yin reeEnd = reeBegin + ree.aCurrentText.Len(); 19759b8096d0SSteve Yin nAllFieldLen += (ree.aCurrentText.Len() - 1); 19769b8096d0SSteve Yin if( reeBegin > Segment.SegmentEnd ) 19779b8096d0SSteve Yin { 19789b8096d0SSteve Yin break; 19799b8096d0SSteve Yin } 19809b8096d0SSteve Yin if( (Segment.SegmentEnd > reeBegin && Segment.SegmentEnd <= reeEnd) || 19819b8096d0SSteve Yin (Segment.SegmentStart >= reeBegin && Segment.SegmentStart < reeEnd) ) 19829b8096d0SSteve Yin { 19839b8096d0SSteve Yin if(ree.pFieldItem->GetField()->GetClassId() != SVX_URLFIELD) 19849b8096d0SSteve Yin { 19859b8096d0SSteve Yin nFoundFieldIndex = j; 19869b8096d0SSteve Yin break; 19879b8096d0SSteve Yin } 19889b8096d0SSteve Yin } 19899b8096d0SSteve Yin } 19909b8096d0SSteve Yin sal_Bool bExtend = sal_False; 19919b8096d0SSteve Yin if( nFoundFieldIndex >= 0 ) 19929b8096d0SSteve Yin { 19939b8096d0SSteve Yin if( Segment.SegmentEnd < reeEnd ) 19949b8096d0SSteve Yin { 19959b8096d0SSteve Yin Segment.SegmentEnd = reeEnd; 19969b8096d0SSteve Yin bExtend = sal_True; 19979b8096d0SSteve Yin } 19989b8096d0SSteve Yin if( Segment.SegmentStart > reeBegin ) 19999b8096d0SSteve Yin { 20009b8096d0SSteve Yin Segment.SegmentStart = reeBegin; 20019b8096d0SSteve Yin bExtend = sal_True; 20029b8096d0SSteve Yin } 20039b8096d0SSteve Yin if( bExtend ) 20040deba7fbSSteve Yin { 20059b8096d0SSteve Yin //If there is a bullet before the field, should add the bullet length into the segment. 20069b8096d0SSteve Yin EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo(sal_uInt16(nParaIndex)); 20079b8096d0SSteve Yin int nBulletLen = aBulletInfo.aText.Len(); 20089b8096d0SSteve Yin if (nBulletLen > 0) 20099b8096d0SSteve Yin { 20109b8096d0SSteve Yin Segment.SegmentEnd += nBulletLen; 20119b8096d0SSteve Yin if (nFoundFieldIndex > 0) 20129b8096d0SSteve Yin Segment.SegmentStart += nBulletLen; 20139b8096d0SSteve Yin Segment.SegmentText = GetTextRange(Segment.SegmentStart, Segment.SegmentEnd); 20149b8096d0SSteve Yin //After get the correct field name, should restore the offset value which don't contain the bullet. 20159b8096d0SSteve Yin Segment.SegmentEnd -= nBulletLen; 20169b8096d0SSteve Yin if (nFoundFieldIndex > 0) 20179b8096d0SSteve Yin Segment.SegmentStart -= nBulletLen; 20189b8096d0SSteve Yin } 20199b8096d0SSteve Yin else 20200deba7fbSSteve Yin Segment.SegmentText = GetTextRange(Segment.SegmentStart, Segment.SegmentEnd); 20219b8096d0SSteve Yin } 20229b8096d0SSteve Yin } 20239b8096d0SSteve Yin return bExtend; 20249b8096d0SSteve Yin } getTextAtIndex(sal_Int32 nIndex,sal_Int16 aTextType)2025cdf0e10cSrcweir ::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) 2026cdf0e10cSrcweir { 2027cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2028cdf0e10cSrcweir 2029cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2030cdf0e10cSrcweir 2031cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2032cdf0e10cSrcweir "AccessibleEditableTextPara::getTextAtIndex: paragraph index value overflow"); 2033cdf0e10cSrcweir 2034cdf0e10cSrcweir ::com::sun::star::accessibility::TextSegment aResult; 2035cdf0e10cSrcweir aResult.SegmentStart = -1; 2036cdf0e10cSrcweir aResult.SegmentEnd = -1; 2037cdf0e10cSrcweir 2038cdf0e10cSrcweir switch( aTextType ) 2039cdf0e10cSrcweir { 20409b8096d0SSteve Yin case AccessibleTextType::CHARACTER: 20419b8096d0SSteve Yin case AccessibleTextType::WORD: 20429b8096d0SSteve Yin { 20439b8096d0SSteve Yin aResult = OCommonAccessibleText::getTextAtIndex( nIndex, aTextType ); 20449b8096d0SSteve Yin ExtendByField( aResult ); 20459b8096d0SSteve Yin break; 20469b8096d0SSteve Yin } 2047cdf0e10cSrcweir // Not yet handled by OCommonAccessibleText. Missing 2048cdf0e10cSrcweir // implGetAttributeRunBoundary() method there 2049cdf0e10cSrcweir case AccessibleTextType::ATTRIBUTE_RUN: 2050cdf0e10cSrcweir { 2051cdf0e10cSrcweir const sal_Int32 nTextLen = GetTextForwarder().GetTextLen( static_cast< sal_uInt16 >( GetParagraphIndex() ) ); 2052cdf0e10cSrcweir 2053cdf0e10cSrcweir if( nIndex == nTextLen ) 2054cdf0e10cSrcweir { 2055cdf0e10cSrcweir // #i17014# Special-casing one-behind-the-end character 2056cdf0e10cSrcweir aResult.SegmentStart = aResult.SegmentEnd = nTextLen; 2057cdf0e10cSrcweir } 2058cdf0e10cSrcweir else 2059cdf0e10cSrcweir { 2060cdf0e10cSrcweir sal_uInt16 nStartIndex, nEndIndex; 20619b8096d0SSteve Yin //For the bullet paragraph, the bullet string is ingnored for IAText::attributes() function. 20629b8096d0SSteve Yin SvxTextForwarder& rCacheTF = GetTextForwarder(); 20639b8096d0SSteve Yin // MT IA2: Not used? sal_Int32 nBulletLen = 0; 20649b8096d0SSteve Yin EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 20659b8096d0SSteve Yin if (aBulletInfo.bVisible) 20669b8096d0SSteve Yin nIndex += aBulletInfo.aText.Len(); 20679b8096d0SSteve Yin if (nIndex != 0 && nIndex >= getCharacterCount()) 20689b8096d0SSteve Yin nIndex = getCharacterCount()-1; 20699b8096d0SSteve Yin CheckPosition(nIndex); 2070cdf0e10cSrcweir if( GetAttributeRun(nStartIndex, nEndIndex, nIndex) ) 2071cdf0e10cSrcweir { 2072cdf0e10cSrcweir aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex); 20739b8096d0SSteve Yin if (aBulletInfo.bVisible) 20749b8096d0SSteve Yin { 20759b8096d0SSteve Yin nStartIndex -= aBulletInfo.aText.Len(); 20769b8096d0SSteve Yin nEndIndex -= aBulletInfo.aText.Len(); 20779b8096d0SSteve Yin } 2078cdf0e10cSrcweir aResult.SegmentStart = nStartIndex; 2079cdf0e10cSrcweir aResult.SegmentEnd = nEndIndex; 2080cdf0e10cSrcweir } 20819b8096d0SSteve Yin } 20829b8096d0SSteve Yin break; 20839b8096d0SSteve Yin } 20849b8096d0SSteve Yin case AccessibleTextType::LINE: 20859b8096d0SSteve Yin { 20869b8096d0SSteve Yin SvxTextForwarder& rCacheTF = GetTextForwarder(); 20879b8096d0SSteve Yin sal_Int32 nParaIndex = GetParagraphIndex(); 20889b8096d0SSteve Yin // MT IA2: Not needed? sal_Int32 nTextLen = rCacheTF.GetTextLen( static_cast< sal_uInt16 >( nParaIndex ) ); 20899b8096d0SSteve Yin CheckPosition(nIndex); 20909b8096d0SSteve Yin if (nIndex != 0 && nIndex == getCharacterCount()) 20919b8096d0SSteve Yin --nIndex; 20929b8096d0SSteve Yin sal_uInt16 nLine, nLineCount=rCacheTF.GetLineCount( static_cast< sal_uInt16 >( nParaIndex ) ); 20939b8096d0SSteve Yin sal_Int32 nCurIndex; 20949b8096d0SSteve Yin //the problem is that rCacheTF.GetLineLen() will include the bullet length. But for the bullet line, 20959b8096d0SSteve Yin //the text value doesn't contain the bullet characters. all of the bullet and numbering info are exposed 20969b8096d0SSteve Yin //by the IAText::attributes(). So here must do special support for bullet line. 20979b8096d0SSteve Yin sal_Int32 nBulletLen = 0; 20989b8096d0SSteve Yin for( nLine=0, nCurIndex=0; nLine<nLineCount; ++nLine ) 20999b8096d0SSteve Yin { 21009b8096d0SSteve Yin if (nLine == 0) 21019b8096d0SSteve Yin { 21029b8096d0SSteve Yin EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 >(nParaIndex) ); 21039b8096d0SSteve Yin if (aBulletInfo.bVisible) 21049b8096d0SSteve Yin { 21059b8096d0SSteve Yin //in bullet or numbering; 21069b8096d0SSteve Yin nBulletLen = aBulletInfo.aText.Len(); 21079b8096d0SSteve Yin } 21089b8096d0SSteve Yin } 21099b8096d0SSteve Yin //nCurIndex += rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ), nLine); 21109b8096d0SSteve Yin sal_Int32 nLineLen = rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ), nLine); 21119b8096d0SSteve Yin if (nLine == 0) 21129b8096d0SSteve Yin nCurIndex += nLineLen - nBulletLen; 21139b8096d0SSteve Yin else 21149b8096d0SSteve Yin nCurIndex += nLineLen; 21159b8096d0SSteve Yin if( nCurIndex > nIndex ) 21169b8096d0SSteve Yin { 21179b8096d0SSteve Yin if (nLine ==0) 21189b8096d0SSteve Yin { 21199b8096d0SSteve Yin //aResult.SegmentStart = nCurIndex - rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine); 21209b8096d0SSteve Yin aResult.SegmentStart = 0; 21219b8096d0SSteve Yin aResult.SegmentEnd = nCurIndex; 21229b8096d0SSteve Yin //aResult.SegmentText = GetTextRange( aResult.SegmentStart, aResult.SegmentEnd ); 21239b8096d0SSteve Yin aResult.SegmentText = GetTextRange( aResult.SegmentStart, aResult.SegmentEnd + nBulletLen); 21249b8096d0SSteve Yin break; 21259b8096d0SSteve Yin } 21269b8096d0SSteve Yin else 21279b8096d0SSteve Yin { 21289b8096d0SSteve Yin //aResult.SegmentStart = nCurIndex - rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine); 21299b8096d0SSteve Yin aResult.SegmentStart = nCurIndex - nLineLen; 21309b8096d0SSteve Yin aResult.SegmentEnd = nCurIndex; 21319b8096d0SSteve Yin //aResult.SegmentText = GetTextRange( aResult.SegmentStart, aResult.SegmentEnd ); 21329b8096d0SSteve Yin aResult.SegmentText = GetTextRange( aResult.SegmentStart + nBulletLen, aResult.SegmentEnd + nBulletLen); 21339b8096d0SSteve Yin break; 21349b8096d0SSteve Yin } 21359b8096d0SSteve Yin } 2136cdf0e10cSrcweir } 2137cdf0e10cSrcweir break; 2138cdf0e10cSrcweir } 2139cdf0e10cSrcweir default: 2140cdf0e10cSrcweir aResult = OCommonAccessibleText::getTextAtIndex( nIndex, aTextType ); 2141cdf0e10cSrcweir break; 2142cdf0e10cSrcweir } /* end of switch( aTextType ) */ 2143cdf0e10cSrcweir 2144cdf0e10cSrcweir return aResult; 2145cdf0e10cSrcweir } 2146cdf0e10cSrcweir getTextBeforeIndex(sal_Int32 nIndex,sal_Int16 aTextType)2147cdf0e10cSrcweir ::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) 2148cdf0e10cSrcweir { 2149cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2150cdf0e10cSrcweir 2151cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2152cdf0e10cSrcweir 2153cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2154cdf0e10cSrcweir "AccessibleEditableTextPara::getTextBeforeIndex: paragraph index value overflow"); 2155cdf0e10cSrcweir 2156cdf0e10cSrcweir ::com::sun::star::accessibility::TextSegment aResult; 2157cdf0e10cSrcweir aResult.SegmentStart = -1; 2158cdf0e10cSrcweir aResult.SegmentEnd = -1; 21599b8096d0SSteve Yin i18n::Boundary aBoundary; 2160cdf0e10cSrcweir switch( aTextType ) 2161cdf0e10cSrcweir { 2162cdf0e10cSrcweir // Not yet handled by OCommonAccessibleText. Missing 2163cdf0e10cSrcweir // implGetAttributeRunBoundary() method there 2164cdf0e10cSrcweir case AccessibleTextType::ATTRIBUTE_RUN: 2165cdf0e10cSrcweir { 2166cdf0e10cSrcweir const sal_Int32 nTextLen = GetTextForwarder().GetTextLen( static_cast< sal_uInt16 >( GetParagraphIndex() ) ); 2167cdf0e10cSrcweir sal_uInt16 nStartIndex, nEndIndex; 2168cdf0e10cSrcweir 2169cdf0e10cSrcweir if( nIndex == nTextLen ) 2170cdf0e10cSrcweir { 2171cdf0e10cSrcweir // #i17014# Special-casing one-behind-the-end character 2172cdf0e10cSrcweir if( nIndex > 0 && 2173cdf0e10cSrcweir GetAttributeRun(nStartIndex, nEndIndex, nIndex-1) ) 2174cdf0e10cSrcweir { 2175cdf0e10cSrcweir aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex); 2176cdf0e10cSrcweir aResult.SegmentStart = nStartIndex; 2177cdf0e10cSrcweir aResult.SegmentEnd = nEndIndex; 2178cdf0e10cSrcweir } 2179cdf0e10cSrcweir } 2180cdf0e10cSrcweir else 2181cdf0e10cSrcweir { 2182cdf0e10cSrcweir if( GetAttributeRun(nStartIndex, nEndIndex, nIndex) ) 2183cdf0e10cSrcweir { 2184cdf0e10cSrcweir // already at the left border? If not, query 2185cdf0e10cSrcweir // one index further left 2186cdf0e10cSrcweir if( nStartIndex > 0 && 2187cdf0e10cSrcweir GetAttributeRun(nStartIndex, nEndIndex, nStartIndex-1) ) 2188cdf0e10cSrcweir { 2189cdf0e10cSrcweir aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex); 2190cdf0e10cSrcweir aResult.SegmentStart = nStartIndex; 2191cdf0e10cSrcweir aResult.SegmentEnd = nEndIndex; 2192cdf0e10cSrcweir } 2193cdf0e10cSrcweir } 2194cdf0e10cSrcweir } 2195cdf0e10cSrcweir break; 2196cdf0e10cSrcweir } 21979b8096d0SSteve Yin case AccessibleTextType::LINE: 21989b8096d0SSteve Yin { 21999b8096d0SSteve Yin SvxTextForwarder& rCacheTF = GetTextForwarder(); 22009b8096d0SSteve Yin sal_Int32 nParaIndex = GetParagraphIndex(); 22019b8096d0SSteve Yin // MT IA2 not needed? sal_Int32 nTextLen = rCacheTF.GetTextLen( static_cast< sal_uInt16 >( nParaIndex ) ); 22029b8096d0SSteve Yin 22039b8096d0SSteve Yin CheckPosition(nIndex); 22049b8096d0SSteve Yin 22059b8096d0SSteve Yin sal_uInt16 nLine, nLineCount=rCacheTF.GetLineCount( static_cast< sal_uInt16 >( nParaIndex ) ); 22069b8096d0SSteve Yin //the problem is that rCacheTF.GetLineLen() will include the bullet length. But for the bullet line, 22079b8096d0SSteve Yin //the text value doesn't contain the bullet characters. all of the bullet and numbering info are exposed 22089b8096d0SSteve Yin //by the IAText::attributes(). So here must do special support for bullet line. 22099b8096d0SSteve Yin sal_Int32 nCurIndex=0, nLastIndex=0, nCurLineLen=0; 22109b8096d0SSteve Yin sal_Int32 nLastLineLen = 0, nBulletLen = 0;; 22119b8096d0SSteve Yin // get the line before the line the index points into 22129b8096d0SSteve Yin for( nLine=0, nCurIndex=0, nLastIndex=0; nLine<nLineCount; ++nLine ) 22139b8096d0SSteve Yin { 22149b8096d0SSteve Yin nLastIndex = nCurIndex; 22159b8096d0SSteve Yin if (nLine == 0) 22169b8096d0SSteve Yin { 22179b8096d0SSteve Yin EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 >(nParaIndex) ); 22189b8096d0SSteve Yin if (aBulletInfo.bVisible) 22199b8096d0SSteve Yin { 22209b8096d0SSteve Yin //in bullet or numbering; 22219b8096d0SSteve Yin nBulletLen = aBulletInfo.aText.Len(); 22229b8096d0SSteve Yin } 22239b8096d0SSteve Yin } 22249b8096d0SSteve Yin if (nLine == 1) 22259b8096d0SSteve Yin nLastLineLen = nCurLineLen - nBulletLen; 22269b8096d0SSteve Yin else 22279b8096d0SSteve Yin nLastLineLen = nCurLineLen; 22289b8096d0SSteve Yin nCurLineLen = rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine); 22299b8096d0SSteve Yin //nCurIndex += nCurLineLen; 22309b8096d0SSteve Yin if (nLine == 0) 22319b8096d0SSteve Yin nCurIndex += nCurLineLen - nBulletLen; 22329b8096d0SSteve Yin else 22339b8096d0SSteve Yin nCurIndex += nCurLineLen; 22349b8096d0SSteve Yin 22359b8096d0SSteve Yin //if( nCurIndex > nIndex && 22369b8096d0SSteve Yin //nLastIndex > nCurLineLen ) 22379b8096d0SSteve Yin if (nCurIndex > nIndex) 22389b8096d0SSteve Yin { 22399b8096d0SSteve Yin if (nLine == 0) 22409b8096d0SSteve Yin { 22419b8096d0SSteve Yin break; 22429b8096d0SSteve Yin } 22439b8096d0SSteve Yin else if (nLine == 1) 22449b8096d0SSteve Yin { 22459b8096d0SSteve Yin aResult.SegmentStart = 0; 22469b8096d0SSteve Yin aResult.SegmentEnd = static_cast< sal_uInt16 >( nLastIndex ); 22479b8096d0SSteve Yin aResult.SegmentText = GetTextRange( aResult.SegmentStart, aResult.SegmentEnd + nBulletLen); 22489b8096d0SSteve Yin break; 22499b8096d0SSteve Yin } 22509b8096d0SSteve Yin else 22519b8096d0SSteve Yin { 22529b8096d0SSteve Yin //aResult.SegmentStart = nLastIndex - nCurLineLen; 22539b8096d0SSteve Yin aResult.SegmentStart = nLastIndex - nLastLineLen; 22549b8096d0SSteve Yin aResult.SegmentEnd = static_cast< sal_uInt16 >( nLastIndex ); 22559b8096d0SSteve Yin aResult.SegmentText = GetTextRange( aResult.SegmentStart + nBulletLen, aResult.SegmentEnd + nBulletLen); 22569b8096d0SSteve Yin break; 22579b8096d0SSteve Yin } 22589b8096d0SSteve Yin } 22599b8096d0SSteve Yin } 2260cdf0e10cSrcweir 22619b8096d0SSteve Yin break; 22629b8096d0SSteve Yin } 22639b8096d0SSteve Yin case AccessibleTextType::WORD: 22649b8096d0SSteve Yin { 22659b8096d0SSteve Yin nIndex = SkipField( nIndex, sal_False); 22669b8096d0SSteve Yin ::rtl::OUString sText( implGetText() ); 22679b8096d0SSteve Yin sal_Int32 nLength = sText.getLength(); 22689b8096d0SSteve Yin 22699b8096d0SSteve Yin // get word at index 22709b8096d0SSteve Yin implGetWordBoundary( aBoundary, nIndex ); 22719b8096d0SSteve Yin 22729b8096d0SSteve Yin 22739b8096d0SSteve Yin //sal_Int32 curWordStart = aBoundary.startPos; 22749b8096d0SSteve Yin //sal_Int32 preWordStart = curWordStart; 22759b8096d0SSteve Yin sal_Int32 curWordStart , preWordStart; 22769b8096d0SSteve Yin if( aBoundary.startPos == -1 || aBoundary.startPos > nIndex) 22779b8096d0SSteve Yin curWordStart = preWordStart = nIndex; 22789b8096d0SSteve Yin else 22799b8096d0SSteve Yin curWordStart = preWordStart = aBoundary.startPos; 22809b8096d0SSteve Yin 22819b8096d0SSteve Yin // get previous word 22829b8096d0SSteve Yin 22839b8096d0SSteve Yin sal_Bool bWord = sal_False; 22849b8096d0SSteve Yin 22859b8096d0SSteve Yin //while ( preWordStart > 0 && aBoundary.startPos == curWordStart) 22869b8096d0SSteve Yin while ( (preWordStart >= 0 && !bWord ) || ( aBoundary.endPos > curWordStart ) ) 22879b8096d0SSteve Yin { 22889b8096d0SSteve Yin preWordStart--; 22899b8096d0SSteve Yin bWord = implGetWordBoundary( aBoundary, preWordStart ); 22909b8096d0SSteve Yin } 22919b8096d0SSteve Yin if ( bWord && implIsValidBoundary( aBoundary, nLength ) ) 22929b8096d0SSteve Yin { 22939b8096d0SSteve Yin aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos ); 22949b8096d0SSteve Yin aResult.SegmentStart = aBoundary.startPos; 22959b8096d0SSteve Yin aResult.SegmentEnd = aBoundary.endPos; 22969b8096d0SSteve Yin ExtendByField( aResult ); 22979b8096d0SSteve Yin } 22989b8096d0SSteve Yin } 22999b8096d0SSteve Yin break; 23009b8096d0SSteve Yin case AccessibleTextType::CHARACTER: 23019b8096d0SSteve Yin { 23029b8096d0SSteve Yin nIndex = SkipField( nIndex, sal_False); 23039b8096d0SSteve Yin aResult = OCommonAccessibleText::getTextBeforeIndex( nIndex, aTextType ); 23049b8096d0SSteve Yin ExtendByField( aResult ); 23059b8096d0SSteve Yin break; 23069b8096d0SSteve Yin } 2307cdf0e10cSrcweir default: 2308cdf0e10cSrcweir aResult = OCommonAccessibleText::getTextBeforeIndex( nIndex, aTextType ); 2309cdf0e10cSrcweir break; 2310cdf0e10cSrcweir } /* end of switch( aTextType ) */ 2311cdf0e10cSrcweir 2312cdf0e10cSrcweir return aResult; 2313cdf0e10cSrcweir } 2314cdf0e10cSrcweir getTextBehindIndex(sal_Int32 nIndex,sal_Int16 aTextType)2315cdf0e10cSrcweir ::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) 2316cdf0e10cSrcweir { 2317cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2318cdf0e10cSrcweir 2319cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2320cdf0e10cSrcweir 2321cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2322cdf0e10cSrcweir "AccessibleEditableTextPara::getTextBehindIndex: paragraph index value overflow"); 2323cdf0e10cSrcweir 2324cdf0e10cSrcweir ::com::sun::star::accessibility::TextSegment aResult; 2325cdf0e10cSrcweir aResult.SegmentStart = -1; 2326cdf0e10cSrcweir aResult.SegmentEnd = -1; 23279b8096d0SSteve Yin i18n::Boundary aBoundary; 2328cdf0e10cSrcweir switch( aTextType ) 2329cdf0e10cSrcweir { 2330cdf0e10cSrcweir case AccessibleTextType::ATTRIBUTE_RUN: 2331cdf0e10cSrcweir { 2332cdf0e10cSrcweir sal_uInt16 nStartIndex, nEndIndex; 2333cdf0e10cSrcweir 2334cdf0e10cSrcweir if( GetAttributeRun(nStartIndex, nEndIndex, nIndex) ) 2335cdf0e10cSrcweir { 2336cdf0e10cSrcweir // already at the right border? 2337cdf0e10cSrcweir if( nEndIndex < GetTextLen() ) 2338cdf0e10cSrcweir { 2339cdf0e10cSrcweir if( GetAttributeRun(nStartIndex, nEndIndex, nEndIndex) ) 2340cdf0e10cSrcweir { 2341cdf0e10cSrcweir aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex); 2342cdf0e10cSrcweir aResult.SegmentStart = nStartIndex; 2343cdf0e10cSrcweir aResult.SegmentEnd = nEndIndex; 2344cdf0e10cSrcweir } 2345cdf0e10cSrcweir } 2346cdf0e10cSrcweir } 2347cdf0e10cSrcweir break; 2348cdf0e10cSrcweir } 2349cdf0e10cSrcweir 23509b8096d0SSteve Yin case AccessibleTextType::LINE: 23519b8096d0SSteve Yin { 23529b8096d0SSteve Yin SvxTextForwarder& rCacheTF = GetTextForwarder(); 23539b8096d0SSteve Yin sal_Int32 nParaIndex = GetParagraphIndex(); 23549b8096d0SSteve Yin // MT IA2 not needed? sal_Int32 nTextLen = rCacheTF.GetTextLen( static_cast< sal_uInt16 >( nParaIndex ) ); 23559b8096d0SSteve Yin 23569b8096d0SSteve Yin CheckPosition(nIndex); 23579b8096d0SSteve Yin 23589b8096d0SSteve Yin sal_uInt16 nLine, nLineCount=rCacheTF.GetLineCount( static_cast< sal_uInt16 >( nParaIndex ) ); 23599b8096d0SSteve Yin sal_Int32 nCurIndex; 23609b8096d0SSteve Yin //the problem is that rCacheTF.GetLineLen() will include the bullet length. But for the bullet line, 23619b8096d0SSteve Yin //the text value doesn't contain the bullet characters. all of the bullet and numbering info are exposed 23629b8096d0SSteve Yin //by the IAText::attributes(). So here must do special support for bullet line. 23639b8096d0SSteve Yin sal_Int32 nBulletLen = 0; 23649b8096d0SSteve Yin // get the line after the line the index points into 23659b8096d0SSteve Yin for( nLine=0, nCurIndex=0; nLine<nLineCount; ++nLine ) 23669b8096d0SSteve Yin { 23679b8096d0SSteve Yin if (nLine == 0) 23689b8096d0SSteve Yin { 23699b8096d0SSteve Yin EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 >(nParaIndex) ); 23709b8096d0SSteve Yin if (aBulletInfo.bVisible) 23719b8096d0SSteve Yin { 23729b8096d0SSteve Yin //in bullet or numbering; 23739b8096d0SSteve Yin nBulletLen = aBulletInfo.aText.Len(); 23749b8096d0SSteve Yin } 23759b8096d0SSteve Yin } 23769b8096d0SSteve Yin //nCurIndex += rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine); 23779b8096d0SSteve Yin sal_Int32 nLineLen = rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ), nLine); 23789b8096d0SSteve Yin 23799b8096d0SSteve Yin if (nLine == 0) 23809b8096d0SSteve Yin nCurIndex += nLineLen - nBulletLen; 23819b8096d0SSteve Yin else 23829b8096d0SSteve Yin nCurIndex += nLineLen; 23839b8096d0SSteve Yin 23849b8096d0SSteve Yin if( nCurIndex > nIndex && 23859b8096d0SSteve Yin nLine < nLineCount-1 ) 23869b8096d0SSteve Yin { 23879b8096d0SSteve Yin aResult.SegmentStart = nCurIndex; 23889b8096d0SSteve Yin aResult.SegmentEnd = nCurIndex + rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine+1); 23899b8096d0SSteve Yin aResult.SegmentText = GetTextRange( aResult.SegmentStart + nBulletLen, aResult.SegmentEnd + nBulletLen); 23909b8096d0SSteve Yin break; 23919b8096d0SSteve Yin } 23929b8096d0SSteve Yin } 23939b8096d0SSteve Yin 23949b8096d0SSteve Yin break; 23959b8096d0SSteve Yin } 23969b8096d0SSteve Yin case AccessibleTextType::WORD: 23979b8096d0SSteve Yin { 23989b8096d0SSteve Yin nIndex = SkipField( nIndex, sal_True); 23999b8096d0SSteve Yin ::rtl::OUString sText( implGetText() ); 24009b8096d0SSteve Yin sal_Int32 nLength = sText.getLength(); 24019b8096d0SSteve Yin 24029b8096d0SSteve Yin // get word at index 24039b8096d0SSteve Yin sal_Bool bWord = implGetWordBoundary( aBoundary, nIndex ); 24049b8096d0SSteve Yin 24059b8096d0SSteve Yin // real current world 24069b8096d0SSteve Yin sal_Int32 nextWord = nIndex; 24079b8096d0SSteve Yin //if( nIndex >= aBoundary.startPos && nIndex <= aBoundary.endPos ) 24089b8096d0SSteve Yin if( nIndex <= aBoundary.endPos ) 24099b8096d0SSteve Yin { 24109b8096d0SSteve Yin nextWord = aBoundary.endPos; 24119b8096d0SSteve Yin if( sText.getStr()[nextWord] == sal_Unicode(' ') ) nextWord++; 24129b8096d0SSteve Yin bWord = implGetWordBoundary( aBoundary, nextWord ); 24139b8096d0SSteve Yin } 24149b8096d0SSteve Yin 24159b8096d0SSteve Yin if ( bWord && implIsValidBoundary( aBoundary, nLength ) ) 24169b8096d0SSteve Yin { 24179b8096d0SSteve Yin aResult.SegmentText = sText.copy( aBoundary.startPos, aBoundary.endPos - aBoundary.startPos ); 24189b8096d0SSteve Yin aResult.SegmentStart = aBoundary.startPos; 24199b8096d0SSteve Yin aResult.SegmentEnd = aBoundary.endPos; 24209b8096d0SSteve Yin 24219b8096d0SSteve Yin // If the end position of aBoundary is inside a field, extend the result to the end of the field 24229b8096d0SSteve Yin 24239b8096d0SSteve Yin ExtendByField( aResult ); 24249b8096d0SSteve Yin } 24259b8096d0SSteve Yin } 24269b8096d0SSteve Yin break; 24279b8096d0SSteve Yin 24289b8096d0SSteve Yin case AccessibleTextType::CHARACTER: 24299b8096d0SSteve Yin { 24309b8096d0SSteve Yin nIndex = SkipField( nIndex, sal_True); 24319b8096d0SSteve Yin aResult = OCommonAccessibleText::getTextBehindIndex( nIndex, aTextType ); 24329b8096d0SSteve Yin ExtendByField( aResult ); 24339b8096d0SSteve Yin break; 24349b8096d0SSteve Yin } 2435cdf0e10cSrcweir default: 2436cdf0e10cSrcweir aResult = OCommonAccessibleText::getTextBehindIndex( nIndex, aTextType ); 2437cdf0e10cSrcweir break; 2438cdf0e10cSrcweir } /* end of switch( aTextType ) */ 2439cdf0e10cSrcweir 2440cdf0e10cSrcweir return aResult; 2441cdf0e10cSrcweir } 2442cdf0e10cSrcweir copyText(sal_Int32 nStartIndex,sal_Int32 nEndIndex)2443cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleEditableTextPara::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 2444cdf0e10cSrcweir { 2445cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2446cdf0e10cSrcweir 2447cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2448cdf0e10cSrcweir 2449cdf0e10cSrcweir try 2450cdf0e10cSrcweir { 2451cdf0e10cSrcweir SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_True ); 2452cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 2453cdf0e10cSrcweir SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs 2454cdf0e10cSrcweir (void)rCacheTF; 2455cdf0e10cSrcweir #else 2456cdf0e10cSrcweir GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs 2457cdf0e10cSrcweir #endif 2458cdf0e10cSrcweir 2459cdf0e10cSrcweir sal_Bool aRetVal; 2460cdf0e10cSrcweir 2461cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2462cdf0e10cSrcweir "AccessibleEditableTextPara::copyText: index value overflow"); 2463cdf0e10cSrcweir 2464cdf0e10cSrcweir CheckRange(nStartIndex, nEndIndex); 2465cdf0e10cSrcweir 24669b8096d0SSteve Yin //Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet 24679b8096d0SSteve Yin sal_Int32 nBulletLen = 0; 24689b8096d0SSteve Yin EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 24699b8096d0SSteve Yin if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible ) 24709b8096d0SSteve Yin nBulletLen = aBulletInfo.aText.Len(); 2471cdf0e10cSrcweir // save current selection 2472cdf0e10cSrcweir ESelection aOldSelection; 2473cdf0e10cSrcweir 2474cdf0e10cSrcweir rCacheVF.GetSelection( aOldSelection ); 24759b8096d0SSteve Yin //rCacheVF.SetSelection( MakeSelection(nStartIndex, nEndIndex) ); 24769b8096d0SSteve Yin rCacheVF.SetSelection( MakeSelection(nStartIndex + nBulletLen, nEndIndex + nBulletLen) ); 2477cdf0e10cSrcweir aRetVal = rCacheVF.Copy(); 2478cdf0e10cSrcweir rCacheVF.SetSelection( aOldSelection ); // restore 2479cdf0e10cSrcweir 2480cdf0e10cSrcweir return aRetVal; 2481cdf0e10cSrcweir } 2482cdf0e10cSrcweir catch( const uno::RuntimeException& ) 2483cdf0e10cSrcweir { 2484cdf0e10cSrcweir return sal_False; 2485cdf0e10cSrcweir } 2486cdf0e10cSrcweir } 2487cdf0e10cSrcweir 2488cdf0e10cSrcweir // XAccessibleEditableText cutText(sal_Int32 nStartIndex,sal_Int32 nEndIndex)2489cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleEditableTextPara::cutText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 2490cdf0e10cSrcweir { 2491cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2492cdf0e10cSrcweir 2493cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2494cdf0e10cSrcweir 2495cdf0e10cSrcweir try 2496cdf0e10cSrcweir { 2497cdf0e10cSrcweir SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_True ); 2498cdf0e10cSrcweir SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs 2499cdf0e10cSrcweir 2500cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2501cdf0e10cSrcweir "AccessibleEditableTextPara::cutText: index value overflow"); 2502cdf0e10cSrcweir 2503cdf0e10cSrcweir CheckRange(nStartIndex, nEndIndex); 2504cdf0e10cSrcweir 25059b8096d0SSteve Yin // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet 25069b8096d0SSteve Yin sal_Int32 nBulletLen = 0; 25079b8096d0SSteve Yin EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 25089b8096d0SSteve Yin if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible ) 25099b8096d0SSteve Yin nBulletLen = aBulletInfo.aText.Len(); 25109b8096d0SSteve Yin ESelection aSelection = MakeSelection (nStartIndex + nBulletLen, nEndIndex + nBulletLen); 25119b8096d0SSteve Yin if( !rCacheTF.IsEditable( aSelection ) ) 2512cdf0e10cSrcweir return sal_False; // non-editable area selected 2513cdf0e10cSrcweir 2514cdf0e10cSrcweir // don't save selection, might become invalid after cut! 25159b8096d0SSteve Yin //rCacheVF.SetSelection( MakeSelection(nStartIndex, nEndIndex) ); 25169b8096d0SSteve Yin rCacheVF.SetSelection( aSelection ); 2517cdf0e10cSrcweir 2518cdf0e10cSrcweir return rCacheVF.Cut(); 2519cdf0e10cSrcweir } 2520cdf0e10cSrcweir catch( const uno::RuntimeException& ) 2521cdf0e10cSrcweir { 2522cdf0e10cSrcweir return sal_False; 2523cdf0e10cSrcweir } 2524cdf0e10cSrcweir } 2525cdf0e10cSrcweir pasteText(sal_Int32 nIndex)2526cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleEditableTextPara::pasteText( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 2527cdf0e10cSrcweir { 2528cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2529cdf0e10cSrcweir 2530cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2531cdf0e10cSrcweir 2532cdf0e10cSrcweir try 2533cdf0e10cSrcweir { 2534cdf0e10cSrcweir SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_True ); 2535cdf0e10cSrcweir SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs 2536cdf0e10cSrcweir 2537cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2538cdf0e10cSrcweir "AccessibleEditableTextPara::pasteText: index value overflow"); 2539cdf0e10cSrcweir 2540cdf0e10cSrcweir CheckPosition(nIndex); 2541cdf0e10cSrcweir 25429b8096d0SSteve Yin // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet 25439b8096d0SSteve Yin sal_Int32 nBulletLen = 0; 25449b8096d0SSteve Yin EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 25459b8096d0SSteve Yin if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible ) 25469b8096d0SSteve Yin nBulletLen = aBulletInfo.aText.Len(); 25479b8096d0SSteve Yin //if( !rCacheTF.IsEditable( MakeSelection(nIndex) ) ) 25489b8096d0SSteve Yin if( !rCacheTF.IsEditable( MakeSelection(nIndex + nBulletLen) ) ) 2549cdf0e10cSrcweir return sal_False; // non-editable area selected 2550cdf0e10cSrcweir 2551cdf0e10cSrcweir // #104400# set empty selection (=> cursor) to given index 25529b8096d0SSteve Yin //rCacheVF.SetSelection( MakeCursor(nIndex) ); 25539b8096d0SSteve Yin rCacheVF.SetSelection( MakeCursor(nIndex + nBulletLen) ); 2554cdf0e10cSrcweir 2555cdf0e10cSrcweir return rCacheVF.Paste(); 2556cdf0e10cSrcweir } 2557cdf0e10cSrcweir catch( const uno::RuntimeException& ) 2558cdf0e10cSrcweir { 2559cdf0e10cSrcweir return sal_False; 2560cdf0e10cSrcweir } 2561cdf0e10cSrcweir } 2562cdf0e10cSrcweir deleteText(sal_Int32 nStartIndex,sal_Int32 nEndIndex)2563cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleEditableTextPara::deleteText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 2564cdf0e10cSrcweir { 2565cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2566cdf0e10cSrcweir 2567cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2568cdf0e10cSrcweir 2569cdf0e10cSrcweir try 2570cdf0e10cSrcweir { 2571cdf0e10cSrcweir // #102710# Request edit view when doing changes 2572cdf0e10cSrcweir // AccessibleEmptyEditSource relies on this behaviour 2573cdf0e10cSrcweir GetEditViewForwarder( sal_True ); 2574cdf0e10cSrcweir SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs 2575cdf0e10cSrcweir 2576cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2577cdf0e10cSrcweir "AccessibleEditableTextPara::deleteText: index value overflow"); 2578cdf0e10cSrcweir 2579cdf0e10cSrcweir CheckRange(nStartIndex, nEndIndex); 2580cdf0e10cSrcweir 25819b8096d0SSteve Yin // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet 25829b8096d0SSteve Yin sal_Int32 nBulletLen = 0; 25839b8096d0SSteve Yin EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 25849b8096d0SSteve Yin if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible ) 25859b8096d0SSteve Yin nBulletLen = aBulletInfo.aText.Len(); 25869b8096d0SSteve Yin ESelection aSelection = MakeSelection (nStartIndex + nBulletLen, nEndIndex + nBulletLen); 25879b8096d0SSteve Yin 25889b8096d0SSteve Yin //if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) ) 25899b8096d0SSteve Yin if( !rCacheTF.IsEditable( aSelection ) ) 2590cdf0e10cSrcweir return sal_False; // non-editable area selected 2591cdf0e10cSrcweir 25929b8096d0SSteve Yin //sal_Bool bRet = rCacheTF.Delete( MakeSelection(nStartIndex, nEndIndex) ); 25939b8096d0SSteve Yin sal_Bool bRet = rCacheTF.Delete( aSelection ); 2594cdf0e10cSrcweir 2595cdf0e10cSrcweir GetEditSource().UpdateData(); 2596cdf0e10cSrcweir 2597cdf0e10cSrcweir return bRet; 2598cdf0e10cSrcweir } 2599cdf0e10cSrcweir catch( const uno::RuntimeException& ) 2600cdf0e10cSrcweir { 2601cdf0e10cSrcweir return sal_False; 2602cdf0e10cSrcweir } 2603cdf0e10cSrcweir } 2604cdf0e10cSrcweir insertText(const::rtl::OUString & sText,sal_Int32 nIndex)2605cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleEditableTextPara::insertText( const ::rtl::OUString& sText, sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 2606cdf0e10cSrcweir { 2607cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2608cdf0e10cSrcweir 2609cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2610cdf0e10cSrcweir 2611cdf0e10cSrcweir try 2612cdf0e10cSrcweir { 2613cdf0e10cSrcweir // #102710# Request edit view when doing changes 2614cdf0e10cSrcweir // AccessibleEmptyEditSource relies on this behaviour 2615cdf0e10cSrcweir GetEditViewForwarder( sal_True ); 2616cdf0e10cSrcweir SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs 2617cdf0e10cSrcweir 2618cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2619cdf0e10cSrcweir "AccessibleEditableTextPara::insertText: index value overflow"); 2620cdf0e10cSrcweir 2621cdf0e10cSrcweir CheckPosition(nIndex); 2622cdf0e10cSrcweir 26239b8096d0SSteve Yin // Because bullet may occupy one or more characters, the TextAdapter will include bullet to calculate the selection. Add offset to handle bullet 26249b8096d0SSteve Yin sal_Int32 nBulletLen = 0; 26259b8096d0SSteve Yin EBulletInfo aBulletInfo = GetTextForwarder().GetBulletInfo( static_cast< sal_uInt16 >(GetParagraphIndex()) ); 26269b8096d0SSteve Yin if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && aBulletInfo.bVisible ) 26279b8096d0SSteve Yin nBulletLen = aBulletInfo.aText.Len(); 26289b8096d0SSteve Yin 26299b8096d0SSteve Yin //if( !rCacheTF.IsEditable( MakeSelection(nIndex) ) ) 26309b8096d0SSteve Yin if( !rCacheTF.IsEditable( MakeSelection(nIndex + nBulletLen) ) ) 2631cdf0e10cSrcweir return sal_False; // non-editable area selected 2632cdf0e10cSrcweir 2633cdf0e10cSrcweir // #104400# insert given text at empty selection (=> cursor) 26349b8096d0SSteve Yin //sal_Bool bRet = rCacheTF.InsertText( sText, MakeCursor(nIndex) ); 26359b8096d0SSteve Yin sal_Bool bRet = rCacheTF.InsertText( sText, MakeCursor(nIndex + nBulletLen) ); 2636cdf0e10cSrcweir 2637cdf0e10cSrcweir rCacheTF.QuickFormatDoc(); 2638cdf0e10cSrcweir GetEditSource().UpdateData(); 2639cdf0e10cSrcweir 2640cdf0e10cSrcweir return bRet; 2641cdf0e10cSrcweir } 2642cdf0e10cSrcweir catch( const uno::RuntimeException& ) 2643cdf0e10cSrcweir { 2644cdf0e10cSrcweir return sal_False; 2645cdf0e10cSrcweir } 2646cdf0e10cSrcweir } 2647cdf0e10cSrcweir replaceText(sal_Int32 nStartIndex,sal_Int32 nEndIndex,const::rtl::OUString & sReplacement)2648cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleEditableTextPara::replaceText( sal_Int32 nStartIndex, sal_Int32 nEndIndex, const ::rtl::OUString& sReplacement ) 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::replaceText: index value overflow"); 2663cdf0e10cSrcweir 2664cdf0e10cSrcweir CheckRange(nStartIndex, nEndIndex); 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 ESelection aSelection = MakeSelection (nStartIndex + nBulletLen, nEndIndex + nBulletLen); 26729b8096d0SSteve Yin 26739b8096d0SSteve Yin //if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) ) 26749b8096d0SSteve Yin if( !rCacheTF.IsEditable( aSelection ) ) 2675cdf0e10cSrcweir return sal_False; // non-editable area selected 2676cdf0e10cSrcweir 2677cdf0e10cSrcweir // insert given text into given range => replace 26789b8096d0SSteve Yin //sal_Bool bRet = rCacheTF.InsertText( sReplacement, MakeSelection(nStartIndex, nEndIndex) ); 26799b8096d0SSteve Yin sal_Bool bRet = rCacheTF.InsertText( sReplacement, aSelection ); 2680cdf0e10cSrcweir 2681cdf0e10cSrcweir rCacheTF.QuickFormatDoc(); 2682cdf0e10cSrcweir GetEditSource().UpdateData(); 2683cdf0e10cSrcweir 2684cdf0e10cSrcweir return bRet; 2685cdf0e10cSrcweir } 2686cdf0e10cSrcweir catch( const uno::RuntimeException& ) 2687cdf0e10cSrcweir { 2688cdf0e10cSrcweir return sal_False; 2689cdf0e10cSrcweir } 2690cdf0e10cSrcweir } 2691cdf0e10cSrcweir setAttributes(sal_Int32 nStartIndex,sal_Int32 nEndIndex,const uno::Sequence<beans::PropertyValue> & aAttributeSet)2692cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleEditableTextPara::setAttributes( sal_Int32 nStartIndex, sal_Int32 nEndIndex, const uno::Sequence< beans::PropertyValue >& aAttributeSet ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 2693cdf0e10cSrcweir { 2694cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2695cdf0e10cSrcweir 2696cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2697cdf0e10cSrcweir 2698cdf0e10cSrcweir try 2699cdf0e10cSrcweir { 2700cdf0e10cSrcweir // #102710# Request edit view when doing changes 2701cdf0e10cSrcweir // AccessibleEmptyEditSource relies on this behaviour 2702cdf0e10cSrcweir GetEditViewForwarder( sal_True ); 2703cdf0e10cSrcweir SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder(); // MUST be after GetEditViewForwarder(), see method docs 2704cdf0e10cSrcweir sal_uInt16 nPara = static_cast< sal_uInt16 >( GetParagraphIndex() ); 2705cdf0e10cSrcweir 2706cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2707cdf0e10cSrcweir "AccessibleEditableTextPara::setAttributes: index value overflow"); 2708cdf0e10cSrcweir 2709cdf0e10cSrcweir CheckRange(nStartIndex, nEndIndex); 2710cdf0e10cSrcweir 2711cdf0e10cSrcweir if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) ) 2712cdf0e10cSrcweir return sal_False; // non-editable area selected 2713cdf0e10cSrcweir 2714cdf0e10cSrcweir // do the indices span the whole paragraph? Then use the outliner map 2715cdf0e10cSrcweir // TODO: hold it as a member? 2716cdf0e10cSrcweir SvxAccessibleTextPropertySet aPropSet( &GetEditSource(), 2717cdf0e10cSrcweir 0 == nStartIndex && 2718cdf0e10cSrcweir rCacheTF.GetTextLen(nPara) == nEndIndex ? 2719cdf0e10cSrcweir ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() : 2720cdf0e10cSrcweir ImplGetSvxTextPortionSvxPropertySet() ); 2721cdf0e10cSrcweir 2722cdf0e10cSrcweir aPropSet.SetSelection( MakeSelection(nStartIndex, nEndIndex) ); 2723cdf0e10cSrcweir 2724cdf0e10cSrcweir // convert from PropertyValue to Any 2725cdf0e10cSrcweir sal_Int32 i, nLength( aAttributeSet.getLength() ); 2726cdf0e10cSrcweir const beans::PropertyValue* pPropArray = aAttributeSet.getConstArray(); 2727cdf0e10cSrcweir for(i=0; i<nLength; ++i) 2728cdf0e10cSrcweir { 2729cdf0e10cSrcweir try 2730cdf0e10cSrcweir { 2731cdf0e10cSrcweir aPropSet.setPropertyValue(pPropArray->Name, pPropArray->Value); 2732cdf0e10cSrcweir } 2733cdf0e10cSrcweir catch( const uno::Exception& ) 2734cdf0e10cSrcweir { 2735cdf0e10cSrcweir DBG_ERROR("AccessibleEditableTextPara::setAttributes exception in setPropertyValue"); 2736cdf0e10cSrcweir } 2737cdf0e10cSrcweir 2738cdf0e10cSrcweir ++pPropArray; 2739cdf0e10cSrcweir } 2740cdf0e10cSrcweir 2741cdf0e10cSrcweir rCacheTF.QuickFormatDoc(); 2742cdf0e10cSrcweir GetEditSource().UpdateData(); 2743cdf0e10cSrcweir 2744cdf0e10cSrcweir return sal_True; 2745cdf0e10cSrcweir } 2746cdf0e10cSrcweir catch( const uno::RuntimeException& ) 2747cdf0e10cSrcweir { 2748cdf0e10cSrcweir return sal_False; 2749cdf0e10cSrcweir } 2750cdf0e10cSrcweir } 2751cdf0e10cSrcweir setText(const::rtl::OUString & sText)2752cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleEditableTextPara::setText( const ::rtl::OUString& sText ) throw (uno::RuntimeException) 2753cdf0e10cSrcweir { 2754cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2755cdf0e10cSrcweir 2756cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2757cdf0e10cSrcweir 2758cdf0e10cSrcweir return replaceText(0, getCharacterCount(), sText); 2759cdf0e10cSrcweir } 2760cdf0e10cSrcweir 2761cdf0e10cSrcweir // XAccessibleTextAttributes getDefaultAttributes(const uno::Sequence<::rtl::OUString> & rRequestedAttributes)2762cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > SAL_CALL AccessibleEditableTextPara::getDefaultAttributes( 2763cdf0e10cSrcweir const uno::Sequence< ::rtl::OUString >& rRequestedAttributes ) 2764cdf0e10cSrcweir throw (uno::RuntimeException) 2765cdf0e10cSrcweir { 2766cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2767cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2768cdf0e10cSrcweir 2769cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 2770cdf0e10cSrcweir SvxAccessibleTextAdapter& rCacheTF = 2771cdf0e10cSrcweir #endif 2772cdf0e10cSrcweir GetTextForwarder(); 2773cdf0e10cSrcweir 2774cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 2775cdf0e10cSrcweir (void)rCacheTF; 2776cdf0e10cSrcweir #endif 2777cdf0e10cSrcweir 2778cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2779cdf0e10cSrcweir "AccessibleEditableTextPara::getCharacterAttributes: index value overflow"); 2780cdf0e10cSrcweir 2781cdf0e10cSrcweir // get XPropertySetInfo for paragraph attributes and 2782cdf0e10cSrcweir // character attributes that span all the paragraphs text. 2783cdf0e10cSrcweir SvxAccessibleTextPropertySet aPropSet( &GetEditSource(), 2784cdf0e10cSrcweir ImplGetSvxCharAndParaPropertiesSet() ); 2785cdf0e10cSrcweir aPropSet.SetSelection( MakeSelection( 0, GetTextLen() ) ); 2786cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > xPropSetInfo = aPropSet.getPropertySetInfo(); 2787cdf0e10cSrcweir if (!xPropSetInfo.is()) 2788cdf0e10cSrcweir throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Cannot query XPropertySetInfo")), 2789cdf0e10cSrcweir uno::Reference< uno::XInterface > 2790cdf0e10cSrcweir ( static_cast< XAccessible* > (this) ) ); // disambiguate hierarchy 2791cdf0e10cSrcweir 2792cdf0e10cSrcweir // build sequence of available properties to check 2793cdf0e10cSrcweir sal_Int32 nLenReqAttr = rRequestedAttributes.getLength(); 2794cdf0e10cSrcweir uno::Sequence< beans::Property > aProperties; 2795cdf0e10cSrcweir if (nLenReqAttr) 2796cdf0e10cSrcweir { 2797cdf0e10cSrcweir const rtl::OUString *pRequestedAttributes = rRequestedAttributes.getConstArray(); 2798cdf0e10cSrcweir 2799cdf0e10cSrcweir aProperties.realloc( nLenReqAttr ); 2800cdf0e10cSrcweir beans::Property *pProperties = aProperties.getArray(); 2801cdf0e10cSrcweir sal_Int32 nCurLen = 0; 2802cdf0e10cSrcweir for (sal_Int32 i = 0; i < nLenReqAttr; ++i) 2803cdf0e10cSrcweir { 2804cdf0e10cSrcweir beans::Property aProp; 2805cdf0e10cSrcweir try 2806cdf0e10cSrcweir { 2807cdf0e10cSrcweir aProp = xPropSetInfo->getPropertyByName( pRequestedAttributes[i] ); 2808cdf0e10cSrcweir } 2809cdf0e10cSrcweir catch (beans::UnknownPropertyException &) 2810cdf0e10cSrcweir { 2811cdf0e10cSrcweir continue; 2812cdf0e10cSrcweir } 2813cdf0e10cSrcweir pProperties[ nCurLen++ ] = aProp; 2814cdf0e10cSrcweir } 2815cdf0e10cSrcweir aProperties.realloc( nCurLen ); 2816cdf0e10cSrcweir } 2817cdf0e10cSrcweir else 2818cdf0e10cSrcweir aProperties = xPropSetInfo->getProperties(); 2819cdf0e10cSrcweir 2820cdf0e10cSrcweir sal_Int32 nLength = aProperties.getLength(); 2821cdf0e10cSrcweir const beans::Property *pProperties = aProperties.getConstArray(); 2822cdf0e10cSrcweir 2823cdf0e10cSrcweir // build resulting sequence 2824cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aOutSequence( nLength ); 2825cdf0e10cSrcweir beans::PropertyValue* pOutSequence = aOutSequence.getArray(); 2826cdf0e10cSrcweir sal_Int32 nOutLen = 0; 2827cdf0e10cSrcweir for (sal_Int32 i = 0; i < nLength; ++i) 2828cdf0e10cSrcweir { 2829cdf0e10cSrcweir // calling implementation functions: 2830cdf0e10cSrcweir // _getPropertyState and _getPropertyValue (see below) to provide 2831cdf0e10cSrcweir // the proper paragraph number when retrieving paragraph attributes 2832cdf0e10cSrcweir PropertyState eState = aPropSet._getPropertyState( pProperties->Name, mnParagraphIndex ); 2833cdf0e10cSrcweir if ( eState == PropertyState_AMBIGUOUS_VALUE ) 2834cdf0e10cSrcweir { 2835cdf0e10cSrcweir OSL_ENSURE( false, "ambiguous property value encountered" ); 2836cdf0e10cSrcweir } 2837cdf0e10cSrcweir 2838cdf0e10cSrcweir //if (eState == PropertyState_DIRECT_VALUE) 2839cdf0e10cSrcweir // per definition all paragraph properties and all character 2840cdf0e10cSrcweir // properties spanning the whole paragraph should be returned 2841cdf0e10cSrcweir // and declared as default value 2842cdf0e10cSrcweir { 2843cdf0e10cSrcweir pOutSequence->Name = pProperties->Name; 2844cdf0e10cSrcweir pOutSequence->Handle = pProperties->Handle; 2845cdf0e10cSrcweir pOutSequence->Value = aPropSet._getPropertyValue( pProperties->Name, mnParagraphIndex ); 2846cdf0e10cSrcweir pOutSequence->State = PropertyState_DEFAULT_VALUE; 2847cdf0e10cSrcweir 2848cdf0e10cSrcweir ++pOutSequence; 2849cdf0e10cSrcweir ++nOutLen; 2850cdf0e10cSrcweir } 2851cdf0e10cSrcweir ++pProperties; 2852cdf0e10cSrcweir } 2853cdf0e10cSrcweir aOutSequence.realloc( nOutLen ); 2854cdf0e10cSrcweir 2855cdf0e10cSrcweir return aOutSequence; 2856cdf0e10cSrcweir } 2857cdf0e10cSrcweir 2858cdf0e10cSrcweir getRunAttributes(sal_Int32 nIndex,const uno::Sequence<::rtl::OUString> & rRequestedAttributes)2859cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > SAL_CALL AccessibleEditableTextPara::getRunAttributes( 2860cdf0e10cSrcweir sal_Int32 nIndex, 2861cdf0e10cSrcweir const uno::Sequence< ::rtl::OUString >& rRequestedAttributes ) 2862cdf0e10cSrcweir throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 2863cdf0e10cSrcweir { 2864cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 2865cdf0e10cSrcweir 2866cdf0e10cSrcweir ::vos::OGuard aGuard( Application::GetSolarMutex() ); 2867cdf0e10cSrcweir 2868cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 2869cdf0e10cSrcweir SvxAccessibleTextAdapter& rCacheTF = 2870cdf0e10cSrcweir #endif 2871cdf0e10cSrcweir GetTextForwarder(); 2872cdf0e10cSrcweir 2873cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 2874cdf0e10cSrcweir (void)rCacheTF; 2875cdf0e10cSrcweir #endif 2876cdf0e10cSrcweir 2877cdf0e10cSrcweir DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX, 2878cdf0e10cSrcweir "AccessibleEditableTextPara::getCharacterAttributes: index value overflow"); 2879cdf0e10cSrcweir 28809b8096d0SSteve Yin if( getCharacterCount() > 0 ) 28819b8096d0SSteve Yin CheckIndex(nIndex); 28829b8096d0SSteve Yin else 28839b8096d0SSteve Yin CheckPosition(nIndex); 2884cdf0e10cSrcweir 2885cdf0e10cSrcweir SvxAccessibleTextPropertySet aPropSet( &GetEditSource(), 2886cdf0e10cSrcweir ImplGetSvxCharAndParaPropertiesSet() ); 2887cdf0e10cSrcweir aPropSet.SetSelection( MakeSelection( nIndex ) ); 2888cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > xPropSetInfo = aPropSet.getPropertySetInfo(); 2889cdf0e10cSrcweir if (!xPropSetInfo.is()) 2890cdf0e10cSrcweir throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Cannot query XPropertySetInfo")), 2891cdf0e10cSrcweir uno::Reference< uno::XInterface > 2892cdf0e10cSrcweir ( static_cast< XAccessible* > (this) ) ); // disambiguate hierarchy 2893cdf0e10cSrcweir 2894cdf0e10cSrcweir // build sequence of available properties to check 2895cdf0e10cSrcweir sal_Int32 nLenReqAttr = rRequestedAttributes.getLength(); 2896cdf0e10cSrcweir uno::Sequence< beans::Property > aProperties; 2897cdf0e10cSrcweir if (nLenReqAttr) 2898cdf0e10cSrcweir { 2899cdf0e10cSrcweir const rtl::OUString *pRequestedAttributes = rRequestedAttributes.getConstArray(); 2900cdf0e10cSrcweir 2901cdf0e10cSrcweir aProperties.realloc( nLenReqAttr ); 2902cdf0e10cSrcweir beans::Property *pProperties = aProperties.getArray(); 2903cdf0e10cSrcweir sal_Int32 nCurLen = 0; 2904cdf0e10cSrcweir for (sal_Int32 i = 0; i < nLenReqAttr; ++i) 2905cdf0e10cSrcweir { 2906cdf0e10cSrcweir beans::Property aProp; 2907cdf0e10cSrcweir try 2908cdf0e10cSrcweir { 2909cdf0e10cSrcweir aProp = xPropSetInfo->getPropertyByName( pRequestedAttributes[i] ); 2910cdf0e10cSrcweir } 2911cdf0e10cSrcweir catch (beans::UnknownPropertyException &) 2912cdf0e10cSrcweir { 2913cdf0e10cSrcweir continue; 2914cdf0e10cSrcweir } 2915cdf0e10cSrcweir pProperties[ nCurLen++ ] = aProp; 2916cdf0e10cSrcweir } 2917cdf0e10cSrcweir aProperties.realloc( nCurLen ); 2918cdf0e10cSrcweir } 2919cdf0e10cSrcweir else 2920cdf0e10cSrcweir aProperties = xPropSetInfo->getProperties(); 2921cdf0e10cSrcweir 2922cdf0e10cSrcweir sal_Int32 nLength = aProperties.getLength(); 2923cdf0e10cSrcweir const beans::Property *pProperties = aProperties.getConstArray(); 2924cdf0e10cSrcweir 2925cdf0e10cSrcweir // build resulting sequence 2926cdf0e10cSrcweir uno::Sequence< beans::PropertyValue > aOutSequence( nLength ); 2927cdf0e10cSrcweir beans::PropertyValue* pOutSequence = aOutSequence.getArray(); 2928cdf0e10cSrcweir sal_Int32 nOutLen = 0; 2929cdf0e10cSrcweir for (sal_Int32 i = 0; i < nLength; ++i) 2930cdf0e10cSrcweir { 2931cdf0e10cSrcweir // calling 'regular' functions that will operate on the selection 2932cdf0e10cSrcweir PropertyState eState = aPropSet.getPropertyState( pProperties->Name ); 2933cdf0e10cSrcweir if (eState == PropertyState_DIRECT_VALUE) 2934cdf0e10cSrcweir { 2935cdf0e10cSrcweir pOutSequence->Name = pProperties->Name; 2936cdf0e10cSrcweir pOutSequence->Handle = pProperties->Handle; 2937cdf0e10cSrcweir pOutSequence->Value = aPropSet.getPropertyValue( pProperties->Name ); 2938cdf0e10cSrcweir pOutSequence->State = eState; 2939cdf0e10cSrcweir 2940cdf0e10cSrcweir ++pOutSequence; 2941cdf0e10cSrcweir ++nOutLen; 2942cdf0e10cSrcweir } 2943cdf0e10cSrcweir ++pProperties; 2944cdf0e10cSrcweir } 2945cdf0e10cSrcweir aOutSequence.realloc( nOutLen ); 2946cdf0e10cSrcweir 2947cdf0e10cSrcweir return aOutSequence; 2948cdf0e10cSrcweir } 2949cdf0e10cSrcweir 2950cdf0e10cSrcweir // XAccessibleHypertext getHyperLinkCount()2951cdf0e10cSrcweir ::sal_Int32 SAL_CALL AccessibleEditableTextPara::getHyperLinkCount( ) throw (::com::sun::star::uno::RuntimeException) 2952cdf0e10cSrcweir { 2953cdf0e10cSrcweir SvxAccessibleTextAdapter& rT = GetTextForwarder(); 2954cdf0e10cSrcweir const sal_Int32 nPara = GetParagraphIndex(); 2955cdf0e10cSrcweir 2956cdf0e10cSrcweir sal_uInt16 nHyperLinks = 0; 2957cdf0e10cSrcweir sal_uInt16 nFields = rT.GetFieldCount( nPara ); 2958cdf0e10cSrcweir for ( sal_uInt16 n = 0; n < nFields; n++ ) 2959cdf0e10cSrcweir { 2960cdf0e10cSrcweir EFieldInfo aField = rT.GetFieldInfo( nPara, n ); 2961cdf0e10cSrcweir if ( aField.pFieldItem->GetField()->ISA( SvxURLField ) ) 2962cdf0e10cSrcweir nHyperLinks++; 2963cdf0e10cSrcweir } 2964cdf0e10cSrcweir return nHyperLinks; 2965cdf0e10cSrcweir } 2966cdf0e10cSrcweir getHyperLink(::sal_Int32 nLinkIndex)2967cdf0e10cSrcweir ::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) 2968cdf0e10cSrcweir { 2969cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleHyperlink > xRef; 2970cdf0e10cSrcweir 2971cdf0e10cSrcweir SvxAccessibleTextAdapter& rT = GetTextForwarder(); 2972cdf0e10cSrcweir const sal_Int32 nPara = GetParagraphIndex(); 2973cdf0e10cSrcweir 2974cdf0e10cSrcweir sal_uInt16 nHyperLink = 0; 2975cdf0e10cSrcweir sal_uInt16 nFields = rT.GetFieldCount( nPara ); 2976cdf0e10cSrcweir for ( sal_uInt16 n = 0; n < nFields; n++ ) 2977cdf0e10cSrcweir { 2978cdf0e10cSrcweir EFieldInfo aField = rT.GetFieldInfo( nPara, n ); 2979cdf0e10cSrcweir if ( aField.pFieldItem->GetField()->ISA( SvxURLField ) ) 2980cdf0e10cSrcweir { 2981cdf0e10cSrcweir if ( nHyperLink == nLinkIndex ) 2982cdf0e10cSrcweir { 2983cdf0e10cSrcweir sal_uInt16 nEEStart = aField.aPosition.nIndex; 2984cdf0e10cSrcweir 2985cdf0e10cSrcweir // Translate EE Index to accessible index 2986cdf0e10cSrcweir sal_uInt16 nStart = rT.CalcEditEngineIndex( nPara, nEEStart ); 2987cdf0e10cSrcweir sal_uInt16 nEnd = nStart + aField.aCurrentText.Len(); 2988cdf0e10cSrcweir xRef = new AccessibleHyperlink( rT, new SvxFieldItem( *aField.pFieldItem ), nPara, nEEStart, nStart, nEnd, aField.aCurrentText ); 2989cdf0e10cSrcweir break; 2990cdf0e10cSrcweir } 2991cdf0e10cSrcweir nHyperLink++; 2992cdf0e10cSrcweir } 2993cdf0e10cSrcweir } 2994cdf0e10cSrcweir 2995cdf0e10cSrcweir return xRef; 2996cdf0e10cSrcweir } 2997cdf0e10cSrcweir getHyperLinkIndex(::sal_Int32 nCharIndex)2998cdf0e10cSrcweir ::sal_Int32 SAL_CALL AccessibleEditableTextPara::getHyperLinkIndex( ::sal_Int32 nCharIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) 2999cdf0e10cSrcweir { 3000cdf0e10cSrcweir const sal_Int32 nPara = GetParagraphIndex(); 3001cdf0e10cSrcweir SvxAccessibleTextAdapter& rT = GetTextForwarder(); 3002cdf0e10cSrcweir 3003cdf0e10cSrcweir // SvxAccessibleTextIndex aIndex; 3004cdf0e10cSrcweir // aIndex.SetIndex(nPara, nCharIndex, rT); 3005cdf0e10cSrcweir // const sal_uInt16 nEEIndex = aIndex.GetEEIndex(); 3006cdf0e10cSrcweir 3007cdf0e10cSrcweir const sal_uInt16 nEEIndex = rT.CalcEditEngineIndex( nPara, nCharIndex ); 3008*fd080abbSSteve Yin sal_Int32 nHLIndex = -1; //i123620 3009cdf0e10cSrcweir sal_uInt16 nHyperLink = 0; 3010cdf0e10cSrcweir sal_uInt16 nFields = rT.GetFieldCount( nPara ); 3011cdf0e10cSrcweir for ( sal_uInt16 n = 0; n < nFields; n++ ) 3012cdf0e10cSrcweir { 3013cdf0e10cSrcweir EFieldInfo aField = rT.GetFieldInfo( nPara, n ); 3014cdf0e10cSrcweir if ( aField.pFieldItem->GetField()->ISA( SvxURLField ) ) 3015cdf0e10cSrcweir { 3016cdf0e10cSrcweir if ( aField.aPosition.nIndex == nEEIndex ) 3017cdf0e10cSrcweir { 3018cdf0e10cSrcweir nHLIndex = nHyperLink; 3019cdf0e10cSrcweir break; 3020cdf0e10cSrcweir } 3021cdf0e10cSrcweir nHyperLink++; 3022cdf0e10cSrcweir } 3023cdf0e10cSrcweir } 3024cdf0e10cSrcweir 3025cdf0e10cSrcweir return nHLIndex; 3026cdf0e10cSrcweir } 3027cdf0e10cSrcweir 3028cdf0e10cSrcweir // XAccessibleMultiLineText getLineNumberAtIndex(sal_Int32 nIndex)3029cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleEditableTextPara::getLineNumberAtIndex( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 3030cdf0e10cSrcweir { 3031cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 3032cdf0e10cSrcweir 3033cdf0e10cSrcweir sal_Int32 nRes = -1; 3034cdf0e10cSrcweir sal_Int32 nPara = GetParagraphIndex(); 3035cdf0e10cSrcweir 3036cdf0e10cSrcweir SvxTextForwarder &rCacheTF = GetTextForwarder(); 3037cdf0e10cSrcweir const bool bValidPara = 0 <= nPara && nPara < rCacheTF.GetParagraphCount(); 3038cdf0e10cSrcweir DBG_ASSERT( bValidPara, "getLineNumberAtIndex: current paragraph index out of range" ); 3039cdf0e10cSrcweir if (bValidPara) 3040cdf0e10cSrcweir { 3041cdf0e10cSrcweir // we explicitly allow for the index to point at the character right behind the text 3042cdf0e10cSrcweir if (0 <= nIndex && nIndex <= rCacheTF.GetTextLen( static_cast< sal_uInt16 >(nPara) )) 3043cdf0e10cSrcweir nRes = rCacheTF.GetLineNumberAtIndex( static_cast< sal_uInt16 >(nPara), static_cast< sal_uInt16 >(nIndex) ); 3044cdf0e10cSrcweir else 3045cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 3046cdf0e10cSrcweir } 3047cdf0e10cSrcweir return nRes; 3048cdf0e10cSrcweir } 3049cdf0e10cSrcweir 3050cdf0e10cSrcweir // XAccessibleMultiLineText getTextAtLineNumber(sal_Int32 nLineNo)3051cdf0e10cSrcweir ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextAtLineNumber( sal_Int32 nLineNo ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 3052cdf0e10cSrcweir { 3053cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 3054cdf0e10cSrcweir 3055cdf0e10cSrcweir ::com::sun::star::accessibility::TextSegment aResult; 3056cdf0e10cSrcweir sal_Int32 nPara = GetParagraphIndex(); 3057cdf0e10cSrcweir SvxTextForwarder &rCacheTF = GetTextForwarder(); 3058cdf0e10cSrcweir const bool bValidPara = 0 <= nPara && nPara < rCacheTF.GetParagraphCount(); 3059cdf0e10cSrcweir DBG_ASSERT( bValidPara, "getTextAtLineNumber: current paragraph index out of range" ); 3060cdf0e10cSrcweir if (bValidPara) 3061cdf0e10cSrcweir { 3062cdf0e10cSrcweir if (0 <= nLineNo && nLineNo < rCacheTF.GetLineCount( static_cast< sal_uInt16 >(nPara) )) 3063cdf0e10cSrcweir { 3064cdf0e10cSrcweir sal_uInt16 nStart = 0, nEnd = 0; 3065cdf0e10cSrcweir rCacheTF.GetLineBoundaries( nStart, nEnd, static_cast< sal_uInt16 >(nPara), static_cast< sal_uInt16 >(nLineNo) ); 3066cdf0e10cSrcweir if (nStart != 0xFFFF && nEnd != 0xFFFF) 3067cdf0e10cSrcweir { 3068cdf0e10cSrcweir try 3069cdf0e10cSrcweir { 3070cdf0e10cSrcweir aResult.SegmentText = getTextRange( nStart, nEnd ); 3071cdf0e10cSrcweir aResult.SegmentStart = nStart; 3072cdf0e10cSrcweir aResult.SegmentEnd = nEnd; 3073cdf0e10cSrcweir } 3074cdf0e10cSrcweir catch (lang::IndexOutOfBoundsException) 3075cdf0e10cSrcweir { 3076cdf0e10cSrcweir // this is not the exception that should be raised in this function ... 3077cdf0e10cSrcweir DBG_ASSERT( 0, "unexpected exception" ); 3078cdf0e10cSrcweir } 3079cdf0e10cSrcweir } 3080cdf0e10cSrcweir } 3081cdf0e10cSrcweir else 3082cdf0e10cSrcweir throw lang::IndexOutOfBoundsException(); 3083cdf0e10cSrcweir } 3084cdf0e10cSrcweir return aResult; 3085cdf0e10cSrcweir } 3086cdf0e10cSrcweir 3087cdf0e10cSrcweir // XAccessibleMultiLineText getTextAtLineWithCaret()3088cdf0e10cSrcweir ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextAtLineWithCaret( ) throw (uno::RuntimeException) 3089cdf0e10cSrcweir { 3090cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 3091cdf0e10cSrcweir 3092cdf0e10cSrcweir ::com::sun::star::accessibility::TextSegment aResult; 3093cdf0e10cSrcweir try 3094cdf0e10cSrcweir { 3095cdf0e10cSrcweir aResult = getTextAtLineNumber( getNumberOfLineWithCaret() ); 3096cdf0e10cSrcweir } 3097cdf0e10cSrcweir catch (lang::IndexOutOfBoundsException &) 3098cdf0e10cSrcweir { 3099cdf0e10cSrcweir // this one needs to be catched since this interface does not allow for it. 3100cdf0e10cSrcweir } 3101cdf0e10cSrcweir return aResult; 3102cdf0e10cSrcweir } 3103cdf0e10cSrcweir 3104cdf0e10cSrcweir // XAccessibleMultiLineText getNumberOfLineWithCaret()3105cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleEditableTextPara::getNumberOfLineWithCaret( ) throw (uno::RuntimeException) 3106cdf0e10cSrcweir { 3107cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 3108cdf0e10cSrcweir 3109cdf0e10cSrcweir sal_Int32 nRes = -1; 3110cdf0e10cSrcweir try 3111cdf0e10cSrcweir { 3112cdf0e10cSrcweir nRes = getLineNumberAtIndex( getCaretPosition() ); 3113cdf0e10cSrcweir } 3114cdf0e10cSrcweir catch (lang::IndexOutOfBoundsException &) 3115cdf0e10cSrcweir { 3116cdf0e10cSrcweir // this one needs to be catched since this interface does not allow for it. 3117cdf0e10cSrcweir } 3118cdf0e10cSrcweir return nRes; 3119cdf0e10cSrcweir } 3120cdf0e10cSrcweir 3121cdf0e10cSrcweir 3122cdf0e10cSrcweir // XServiceInfo getImplementationName(void)3123cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getImplementationName (void) throw (uno::RuntimeException) 3124cdf0e10cSrcweir { 3125cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 3126cdf0e10cSrcweir 3127cdf0e10cSrcweir return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("AccessibleEditableTextPara")); 3128cdf0e10cSrcweir } 3129cdf0e10cSrcweir supportsService(const::rtl::OUString & sServiceName)3130cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleEditableTextPara::supportsService (const ::rtl::OUString& sServiceName) throw (uno::RuntimeException) 3131cdf0e10cSrcweir { 3132cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 3133cdf0e10cSrcweir 3134cdf0e10cSrcweir // Iterate over all supported service names and return true if on of them 3135cdf0e10cSrcweir // matches the given name. 3136cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> aSupportedServices ( 3137cdf0e10cSrcweir getSupportedServiceNames ()); 3138cdf0e10cSrcweir for (int i=0; i<aSupportedServices.getLength(); i++) 3139cdf0e10cSrcweir if (sServiceName == aSupportedServices[i]) 3140cdf0e10cSrcweir return sal_True; 3141cdf0e10cSrcweir return sal_False; 3142cdf0e10cSrcweir } 3143cdf0e10cSrcweir getSupportedServiceNames(void)3144cdf0e10cSrcweir uno::Sequence< ::rtl::OUString> SAL_CALL AccessibleEditableTextPara::getSupportedServiceNames (void) throw (uno::RuntimeException) 3145cdf0e10cSrcweir { 3146cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 3147cdf0e10cSrcweir 3148cdf0e10cSrcweir const ::rtl::OUString sServiceName( getServiceName() ); 3149cdf0e10cSrcweir return uno::Sequence< ::rtl::OUString > (&sServiceName, 1); 3150cdf0e10cSrcweir } 3151cdf0e10cSrcweir 3152cdf0e10cSrcweir // XServiceName getServiceName(void)3153cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getServiceName (void) throw (uno::RuntimeException) 3154cdf0e10cSrcweir { 3155cdf0e10cSrcweir DBG_CHKTHIS( AccessibleEditableTextPara, NULL ); 3156cdf0e10cSrcweir 3157cdf0e10cSrcweir // #105185# Using correct service now 3158cdf0e10cSrcweir return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.AccessibleParagraphView")); 3159cdf0e10cSrcweir } 3160cdf0e10cSrcweir 3161cdf0e10cSrcweir } // end of namespace accessibility 3162cdf0e10cSrcweir 3163cdf0e10cSrcweir //------------------------------------------------------------------------ 3164