1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_editeng.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir //------------------------------------------------------------------------ 32*cdf0e10cSrcweir // 33*cdf0e10cSrcweir // Global header 34*cdf0e10cSrcweir // 35*cdf0e10cSrcweir //------------------------------------------------------------------------ 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include <limits.h> 38*cdf0e10cSrcweir #include <vector> 39*cdf0e10cSrcweir #include <algorithm> 40*cdf0e10cSrcweir #include <vos/mutex.hxx> 41*cdf0e10cSrcweir #include <vcl/window.hxx> 42*cdf0e10cSrcweir #include <vcl/svapp.hxx> 43*cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx> 44*cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx> 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir //------------------------------------------------------------------------ 47*cdf0e10cSrcweir // 48*cdf0e10cSrcweir // Project-local header 49*cdf0e10cSrcweir // 50*cdf0e10cSrcweir //------------------------------------------------------------------------ 51*cdf0e10cSrcweir #include "editeng/unoedprx.hxx" 52*cdf0e10cSrcweir #include <editeng/unotext.hxx> 53*cdf0e10cSrcweir #include <editeng/unoedhlp.hxx> 54*cdf0e10cSrcweir #include <editeng/editdata.hxx> 55*cdf0e10cSrcweir #include <editeng/editeng.hxx> 56*cdf0e10cSrcweir #include <editeng/editview.hxx> 57*cdf0e10cSrcweir #include <editeng/AccessibleStringWrap.hxx> 58*cdf0e10cSrcweir #include <editeng/outliner.hxx> 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir using namespace ::com::sun::star; 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir class SvxAccessibleTextIndex 64*cdf0e10cSrcweir { 65*cdf0e10cSrcweir public: 66*cdf0e10cSrcweir SvxAccessibleTextIndex() : 67*cdf0e10cSrcweir mnPara(0), 68*cdf0e10cSrcweir mnIndex(0), 69*cdf0e10cSrcweir mnEEIndex(0), 70*cdf0e10cSrcweir mnFieldOffset(0), 71*cdf0e10cSrcweir mnFieldLen(0), 72*cdf0e10cSrcweir mbInField(sal_False), 73*cdf0e10cSrcweir mnBulletOffset(0), 74*cdf0e10cSrcweir mnBulletLen(0), 75*cdf0e10cSrcweir mbInBullet(sal_False) {}; 76*cdf0e10cSrcweir ~SvxAccessibleTextIndex() {}; 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir // Get/Set current paragraph 79*cdf0e10cSrcweir void SetParagraph( sal_uInt16 nPara ) 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir mnPara = nPara; 82*cdf0e10cSrcweir } 83*cdf0e10cSrcweir sal_uInt16 GetParagraph() const { return mnPara; } 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir /** Set the index in the UAA semantic 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir @param nIndex 88*cdf0e10cSrcweir The index from the UA API (fields and bullets are expanded) 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir @param rTF 91*cdf0e10cSrcweir The text forwarder to use in the calculations 92*cdf0e10cSrcweir */ 93*cdf0e10cSrcweir void SetIndex( sal_Int32 nIndex, const SvxTextForwarder& rTF ); 94*cdf0e10cSrcweir void SetIndex( sal_uInt16 nPara, sal_Int32 nIndex, const SvxTextForwarder& rTF ) { SetParagraph(nPara); SetIndex(nIndex, rTF); } 95*cdf0e10cSrcweir sal_Int32 GetIndex() const { return mnIndex; } 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir /** Set the index in the edit engine semantic 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir Update the object state to reflect the given index position in 100*cdf0e10cSrcweir EditEngine/Outliner index values 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir @param nEEIndex 103*cdf0e10cSrcweir The index from the edit engine (fields span exactly one index increment) 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir @param rTF 106*cdf0e10cSrcweir The text forwarder to use in the calculations 107*cdf0e10cSrcweir */ 108*cdf0e10cSrcweir void SetEEIndex( sal_uInt16 nEEIndex, const SvxTextForwarder& rTF ); 109*cdf0e10cSrcweir void SetEEIndex( sal_uInt16 nPara, sal_uInt16 nEEIndex, const SvxTextForwarder& rTF ) { SetParagraph(nPara); SetEEIndex(nEEIndex, rTF); } 110*cdf0e10cSrcweir sal_uInt16 GetEEIndex() const; 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir void SetFieldOffset( sal_Int32 nOffset, sal_Int32 nLen ) { mnFieldOffset = nOffset; mnFieldLen = nLen; } 113*cdf0e10cSrcweir sal_Int32 GetFieldOffset() const { return mnFieldOffset; } 114*cdf0e10cSrcweir sal_Int32 GetFieldLen() const { return mnFieldLen; } 115*cdf0e10cSrcweir void AreInField( sal_Bool bInField = sal_True ) { mbInField = bInField; } 116*cdf0e10cSrcweir sal_Bool InField() const { return mbInField; } 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir void SetBulletOffset( sal_Int32 nOffset, sal_Int32 nLen ) { mnBulletOffset = nOffset; mnBulletLen = nLen; } 119*cdf0e10cSrcweir sal_Int32 GetBulletOffset() const { return mnBulletOffset; } 120*cdf0e10cSrcweir sal_Int32 GetBulletLen() const { return mnBulletLen; } 121*cdf0e10cSrcweir void AreInBullet( sal_Bool bInBullet = sal_True ) { mbInBullet = bInBullet; } 122*cdf0e10cSrcweir sal_Bool InBullet() const { return mbInBullet; } 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir /// returns false if the current index contains non-editable text (e.g. bullets) 125*cdf0e10cSrcweir sal_Bool IsEditable() const; 126*cdf0e10cSrcweir 127*cdf0e10cSrcweir /// returns false if the given range is non-editable (e.g. contains bullets or _parts_ of fields) 128*cdf0e10cSrcweir sal_Bool IsEditableRange( const SvxAccessibleTextIndex& rEnd ) const; 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir private: 131*cdf0e10cSrcweir sal_uInt16 mnPara; 132*cdf0e10cSrcweir sal_Int32 mnIndex; 133*cdf0e10cSrcweir sal_Int32 mnEEIndex; 134*cdf0e10cSrcweir sal_Int32 mnFieldOffset; 135*cdf0e10cSrcweir sal_Int32 mnFieldLen; 136*cdf0e10cSrcweir sal_Bool mbInField; 137*cdf0e10cSrcweir sal_Int32 mnBulletOffset; 138*cdf0e10cSrcweir sal_Int32 mnBulletLen; 139*cdf0e10cSrcweir sal_Bool mbInBullet; 140*cdf0e10cSrcweir }; 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir ESelection MakeEESelection( const SvxAccessibleTextIndex& rStart, const SvxAccessibleTextIndex& rEnd ) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir // deal with field special case: to really get a field contained 145*cdf0e10cSrcweir // within a selection, the start index must be before or on the 146*cdf0e10cSrcweir // field, the end index after it. 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir // The SvxAccessibleTextIndex.GetEEIndex method gives the index on 149*cdf0e10cSrcweir // the field, as long the input index is on the field. Thus, 150*cdf0e10cSrcweir // correction necessary for the end index 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir // Therefore, for _ranges_, if part of the field is touched, all 153*cdf0e10cSrcweir // of the field must be selected 154*cdf0e10cSrcweir if( rStart.GetParagraph() <= rEnd.GetParagraph() || 155*cdf0e10cSrcweir (rStart.GetParagraph() == rEnd.GetParagraph() && 156*cdf0e10cSrcweir rStart.GetEEIndex() <= rEnd.GetEEIndex()) ) 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir if( rEnd.InField() && rEnd.GetFieldOffset() ) 159*cdf0e10cSrcweir return ESelection( rStart.GetParagraph(), rStart.GetEEIndex(), 160*cdf0e10cSrcweir rEnd.GetParagraph(), rEnd.GetEEIndex()+1 ); 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir else if( rStart.GetParagraph() > rEnd.GetParagraph() || 163*cdf0e10cSrcweir (rStart.GetParagraph() == rEnd.GetParagraph() && 164*cdf0e10cSrcweir rStart.GetEEIndex() > rEnd.GetEEIndex()) ) 165*cdf0e10cSrcweir { 166*cdf0e10cSrcweir if( rStart.InField() && rStart.GetFieldOffset() ) 167*cdf0e10cSrcweir return ESelection( rStart.GetParagraph(), rStart.GetEEIndex()+1, 168*cdf0e10cSrcweir rEnd.GetParagraph(), rEnd.GetEEIndex() ); 169*cdf0e10cSrcweir } 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir return ESelection( rStart.GetParagraph(), rStart.GetEEIndex(), 172*cdf0e10cSrcweir rEnd.GetParagraph(), rEnd.GetEEIndex() ); 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir ESelection MakeEESelection( const SvxAccessibleTextIndex& rIndex ) 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir return ESelection( rIndex.GetParagraph(), rIndex.GetEEIndex(), 178*cdf0e10cSrcweir rIndex.GetParagraph(), rIndex.GetEEIndex() + 1 ); 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir sal_uInt16 SvxAccessibleTextIndex::GetEEIndex() const 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir DBG_ASSERT(mnEEIndex >= 0 && mnEEIndex <= USHRT_MAX, 184*cdf0e10cSrcweir "SvxAccessibleTextIndex::GetEEIndex: index value overflow"); 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir return static_cast< sal_uInt16 > (mnEEIndex); 187*cdf0e10cSrcweir } 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir void SvxAccessibleTextIndex::SetEEIndex( sal_uInt16 nEEIndex, const SvxTextForwarder& rTF ) 190*cdf0e10cSrcweir { 191*cdf0e10cSrcweir // reset 192*cdf0e10cSrcweir mnFieldOffset = 0; 193*cdf0e10cSrcweir mbInField = sal_False; 194*cdf0e10cSrcweir mnFieldLen = 0; 195*cdf0e10cSrcweir mnBulletOffset = 0; 196*cdf0e10cSrcweir mbInBullet = sal_False; 197*cdf0e10cSrcweir mnBulletLen = 0; 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir // set known values 200*cdf0e10cSrcweir mnEEIndex = nEEIndex; 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir // calculate unknowns 203*cdf0e10cSrcweir sal_uInt16 nCurrField, nFieldCount = rTF.GetFieldCount( GetParagraph() ); 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir mnIndex = nEEIndex; 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir EBulletInfo aBulletInfo = rTF.GetBulletInfo( GetParagraph() ); 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir // any text bullets? 210*cdf0e10cSrcweir if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && 211*cdf0e10cSrcweir aBulletInfo.bVisible && 212*cdf0e10cSrcweir aBulletInfo.nType != SVX_NUM_BITMAP ) 213*cdf0e10cSrcweir { 214*cdf0e10cSrcweir mnIndex += aBulletInfo.aText.Len(); 215*cdf0e10cSrcweir } 216*cdf0e10cSrcweir 217*cdf0e10cSrcweir for( nCurrField=0; nCurrField < nFieldCount; ++nCurrField ) 218*cdf0e10cSrcweir { 219*cdf0e10cSrcweir EFieldInfo aFieldInfo( rTF.GetFieldInfo( GetParagraph(), nCurrField ) ); 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir if( aFieldInfo.aPosition.nIndex > nEEIndex ) 222*cdf0e10cSrcweir break; 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir if( aFieldInfo.aPosition.nIndex == nEEIndex ) 225*cdf0e10cSrcweir { 226*cdf0e10cSrcweir AreInField(); 227*cdf0e10cSrcweir break; 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir // #106010# 231*cdf0e10cSrcweir mnIndex += ::std::max(aFieldInfo.aCurrentText.Len()-1, 0); 232*cdf0e10cSrcweir } 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir void SvxAccessibleTextIndex::SetIndex( sal_Int32 nIndex, const SvxTextForwarder& rTF ) 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir // reset 238*cdf0e10cSrcweir mnFieldOffset = 0; 239*cdf0e10cSrcweir mbInField = sal_False; 240*cdf0e10cSrcweir mnFieldLen = 0; 241*cdf0e10cSrcweir mnBulletOffset = 0; 242*cdf0e10cSrcweir mbInBullet = sal_False; 243*cdf0e10cSrcweir mnBulletLen = 0; 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir // set known values 246*cdf0e10cSrcweir mnIndex = nIndex; 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir // calculate unknowns 249*cdf0e10cSrcweir sal_uInt16 nCurrField, nFieldCount = rTF.GetFieldCount( GetParagraph() ); 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir DBG_ASSERT(nIndex >= 0 && nIndex <= USHRT_MAX, 252*cdf0e10cSrcweir "SvxAccessibleTextIndex::SetIndex: index value overflow"); 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir mnEEIndex = nIndex; 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir EBulletInfo aBulletInfo = rTF.GetBulletInfo( GetParagraph() ); 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir // any text bullets? 259*cdf0e10cSrcweir if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && 260*cdf0e10cSrcweir aBulletInfo.bVisible && 261*cdf0e10cSrcweir aBulletInfo.nType != SVX_NUM_BITMAP ) 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir sal_Int32 nBulletLen = aBulletInfo.aText.Len(); 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir if( nIndex < nBulletLen ) 266*cdf0e10cSrcweir { 267*cdf0e10cSrcweir AreInBullet(); 268*cdf0e10cSrcweir SetBulletOffset( nIndex, nBulletLen ); 269*cdf0e10cSrcweir mnEEIndex = 0; 270*cdf0e10cSrcweir return; 271*cdf0e10cSrcweir } 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir mnEEIndex = mnEEIndex - nBulletLen; 274*cdf0e10cSrcweir } 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir for( nCurrField=0; nCurrField < nFieldCount; ++nCurrField ) 277*cdf0e10cSrcweir { 278*cdf0e10cSrcweir EFieldInfo aFieldInfo( rTF.GetFieldInfo( GetParagraph(), nCurrField ) ); 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir // we're before a field 281*cdf0e10cSrcweir if( aFieldInfo.aPosition.nIndex > mnEEIndex ) 282*cdf0e10cSrcweir break; 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir // #106010# 285*cdf0e10cSrcweir mnEEIndex -= ::std::max(aFieldInfo.aCurrentText.Len()-1, 0); 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir // we're within a field 288*cdf0e10cSrcweir if( aFieldInfo.aPosition.nIndex >= mnEEIndex ) 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir AreInField(); 291*cdf0e10cSrcweir SetFieldOffset( ::std::max(aFieldInfo.aCurrentText.Len()-1, 0) - (aFieldInfo.aPosition.nIndex - mnEEIndex), 292*cdf0e10cSrcweir aFieldInfo.aCurrentText.Len() ); 293*cdf0e10cSrcweir mnEEIndex = aFieldInfo.aPosition.nIndex ; 294*cdf0e10cSrcweir break; 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir } 297*cdf0e10cSrcweir } 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir sal_Bool SvxAccessibleTextIndex::IsEditable() const 300*cdf0e10cSrcweir { 301*cdf0e10cSrcweir if( InBullet() || InField() ) 302*cdf0e10cSrcweir return sal_False; 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir return sal_True; 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir sal_Bool SvxAccessibleTextIndex::IsEditableRange( const SvxAccessibleTextIndex& rEnd ) const 308*cdf0e10cSrcweir { 309*cdf0e10cSrcweir if( GetIndex() > rEnd.GetIndex() ) 310*cdf0e10cSrcweir return rEnd.IsEditableRange( *this ); 311*cdf0e10cSrcweir 312*cdf0e10cSrcweir if( InBullet() || rEnd.InBullet() ) 313*cdf0e10cSrcweir return sal_False; 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir if( InField() && GetFieldOffset() ) 316*cdf0e10cSrcweir return sal_False; // within field 317*cdf0e10cSrcweir 318*cdf0e10cSrcweir if( rEnd.InField() && rEnd.GetFieldOffset() >= rEnd.GetFieldLen() - 1 ) 319*cdf0e10cSrcweir return sal_False; // within field 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir return sal_True; 322*cdf0e10cSrcweir } 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir //--------------------------------------------------------------------------------- 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir SvxEditSourceAdapter::SvxEditSourceAdapter() : mbEditSourceValid( sal_False ) 327*cdf0e10cSrcweir { 328*cdf0e10cSrcweir } 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir SvxEditSourceAdapter::~SvxEditSourceAdapter() 331*cdf0e10cSrcweir { 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir SvxEditSource* SvxEditSourceAdapter::Clone() const 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir if( mbEditSourceValid && mpAdaptee.get() ) 337*cdf0e10cSrcweir { 338*cdf0e10cSrcweir ::std::auto_ptr< SvxEditSource > pClonedAdaptee( mpAdaptee->Clone() ); 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir if( pClonedAdaptee.get() ) 341*cdf0e10cSrcweir { 342*cdf0e10cSrcweir SvxEditSourceAdapter* pClone = new SvxEditSourceAdapter(); 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir if( pClone ) 345*cdf0e10cSrcweir { 346*cdf0e10cSrcweir pClone->SetEditSource( pClonedAdaptee ); 347*cdf0e10cSrcweir return pClone; 348*cdf0e10cSrcweir } 349*cdf0e10cSrcweir } 350*cdf0e10cSrcweir } 351*cdf0e10cSrcweir 352*cdf0e10cSrcweir return NULL; 353*cdf0e10cSrcweir } 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir SvxAccessibleTextAdapter* SvxEditSourceAdapter::GetTextForwarderAdapter() 356*cdf0e10cSrcweir { 357*cdf0e10cSrcweir if( mbEditSourceValid && mpAdaptee.get() ) 358*cdf0e10cSrcweir { 359*cdf0e10cSrcweir SvxTextForwarder* pTextForwarder = mpAdaptee->GetTextForwarder(); 360*cdf0e10cSrcweir 361*cdf0e10cSrcweir if( pTextForwarder ) 362*cdf0e10cSrcweir { 363*cdf0e10cSrcweir maTextAdapter.SetForwarder(*pTextForwarder); 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir return &maTextAdapter; 366*cdf0e10cSrcweir } 367*cdf0e10cSrcweir } 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir return NULL; 370*cdf0e10cSrcweir } 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir SvxTextForwarder* SvxEditSourceAdapter::GetTextForwarder() 373*cdf0e10cSrcweir { 374*cdf0e10cSrcweir return GetTextForwarderAdapter(); 375*cdf0e10cSrcweir } 376*cdf0e10cSrcweir 377*cdf0e10cSrcweir SvxViewForwarder* SvxEditSourceAdapter::GetViewForwarder() 378*cdf0e10cSrcweir { 379*cdf0e10cSrcweir if( mbEditSourceValid && mpAdaptee.get() ) 380*cdf0e10cSrcweir return mpAdaptee->GetViewForwarder(); 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir return NULL; 383*cdf0e10cSrcweir } 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir SvxAccessibleTextEditViewAdapter* SvxEditSourceAdapter::GetEditViewForwarderAdapter( sal_Bool bCreate ) 386*cdf0e10cSrcweir { 387*cdf0e10cSrcweir if( mbEditSourceValid && mpAdaptee.get() ) 388*cdf0e10cSrcweir { 389*cdf0e10cSrcweir SvxEditViewForwarder* pEditViewForwarder = mpAdaptee->GetEditViewForwarder(bCreate); 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir if( pEditViewForwarder ) 392*cdf0e10cSrcweir { 393*cdf0e10cSrcweir SvxAccessibleTextAdapter* pTextAdapter = GetTextForwarderAdapter(); 394*cdf0e10cSrcweir 395*cdf0e10cSrcweir if( pTextAdapter ) 396*cdf0e10cSrcweir { 397*cdf0e10cSrcweir maEditViewAdapter.SetForwarder(*pEditViewForwarder, *pTextAdapter); 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir return &maEditViewAdapter; 400*cdf0e10cSrcweir } 401*cdf0e10cSrcweir } 402*cdf0e10cSrcweir } 403*cdf0e10cSrcweir 404*cdf0e10cSrcweir return NULL; 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir 407*cdf0e10cSrcweir SvxEditViewForwarder* SvxEditSourceAdapter::GetEditViewForwarder( sal_Bool bCreate ) 408*cdf0e10cSrcweir { 409*cdf0e10cSrcweir return GetEditViewForwarderAdapter( bCreate ); 410*cdf0e10cSrcweir } 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir void SvxEditSourceAdapter::UpdateData() 413*cdf0e10cSrcweir { 414*cdf0e10cSrcweir if( mbEditSourceValid && mpAdaptee.get() ) 415*cdf0e10cSrcweir mpAdaptee->UpdateData(); 416*cdf0e10cSrcweir } 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir SfxBroadcaster& SvxEditSourceAdapter::GetBroadcaster() const 419*cdf0e10cSrcweir { 420*cdf0e10cSrcweir if( mbEditSourceValid && mpAdaptee.get() ) 421*cdf0e10cSrcweir return mpAdaptee->GetBroadcaster(); 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir return maDummyBroadcaster; 424*cdf0e10cSrcweir } 425*cdf0e10cSrcweir 426*cdf0e10cSrcweir void SvxEditSourceAdapter::SetEditSource( ::std::auto_ptr< SvxEditSource > pAdaptee ) 427*cdf0e10cSrcweir { 428*cdf0e10cSrcweir if( pAdaptee.get() ) 429*cdf0e10cSrcweir { 430*cdf0e10cSrcweir mpAdaptee = pAdaptee; 431*cdf0e10cSrcweir mbEditSourceValid = sal_True; 432*cdf0e10cSrcweir } 433*cdf0e10cSrcweir else 434*cdf0e10cSrcweir { 435*cdf0e10cSrcweir // do a lazy delete (prevents us from deleting the broadcaster 436*cdf0e10cSrcweir // from within a broadcast in 437*cdf0e10cSrcweir // AccessibleTextHelper_Impl::Notify) 438*cdf0e10cSrcweir mbEditSourceValid = sal_False; 439*cdf0e10cSrcweir } 440*cdf0e10cSrcweir } 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir sal_Bool SvxEditSourceAdapter::IsValid() const 443*cdf0e10cSrcweir { 444*cdf0e10cSrcweir return mbEditSourceValid; 445*cdf0e10cSrcweir } 446*cdf0e10cSrcweir 447*cdf0e10cSrcweir 448*cdf0e10cSrcweir //-------------------------------------------------------------------------------------- 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir SvxAccessibleTextAdapter::SvxAccessibleTextAdapter() : mrTextForwarder( NULL ) 451*cdf0e10cSrcweir { 452*cdf0e10cSrcweir } 453*cdf0e10cSrcweir 454*cdf0e10cSrcweir SvxAccessibleTextAdapter::~SvxAccessibleTextAdapter() 455*cdf0e10cSrcweir { 456*cdf0e10cSrcweir } 457*cdf0e10cSrcweir 458*cdf0e10cSrcweir sal_uInt16 SvxAccessibleTextAdapter::GetParagraphCount() const 459*cdf0e10cSrcweir { 460*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 461*cdf0e10cSrcweir 462*cdf0e10cSrcweir return mrTextForwarder->GetParagraphCount(); 463*cdf0e10cSrcweir } 464*cdf0e10cSrcweir 465*cdf0e10cSrcweir sal_uInt16 SvxAccessibleTextAdapter::GetTextLen( sal_uInt16 nParagraph ) const 466*cdf0e10cSrcweir { 467*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 468*cdf0e10cSrcweir 469*cdf0e10cSrcweir SvxAccessibleTextIndex aIndex; 470*cdf0e10cSrcweir aIndex.SetEEIndex( nParagraph, mrTextForwarder->GetTextLen( nParagraph ), *this ); 471*cdf0e10cSrcweir 472*cdf0e10cSrcweir return static_cast< sal_uInt16 >(aIndex.GetIndex()); 473*cdf0e10cSrcweir } 474*cdf0e10cSrcweir 475*cdf0e10cSrcweir String SvxAccessibleTextAdapter::GetText( const ESelection& rSel ) const 476*cdf0e10cSrcweir { 477*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 478*cdf0e10cSrcweir 479*cdf0e10cSrcweir SvxAccessibleTextIndex aStartIndex; 480*cdf0e10cSrcweir SvxAccessibleTextIndex aEndIndex; 481*cdf0e10cSrcweir 482*cdf0e10cSrcweir aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this ); 483*cdf0e10cSrcweir aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this ); 484*cdf0e10cSrcweir 485*cdf0e10cSrcweir // normalize selection 486*cdf0e10cSrcweir if( rSel.nStartPara > rSel.nEndPara || 487*cdf0e10cSrcweir (rSel.nStartPara == rSel.nEndPara && rSel.nStartPos > rSel.nEndPos) ) 488*cdf0e10cSrcweir { 489*cdf0e10cSrcweir ::std::swap( aStartIndex, aEndIndex ); 490*cdf0e10cSrcweir } 491*cdf0e10cSrcweir 492*cdf0e10cSrcweir String sStr = mrTextForwarder->GetText( MakeEESelection(aStartIndex, aEndIndex) ); 493*cdf0e10cSrcweir 494*cdf0e10cSrcweir // trim field text, if necessary 495*cdf0e10cSrcweir if( aStartIndex.InField() ) 496*cdf0e10cSrcweir { 497*cdf0e10cSrcweir DBG_ASSERT(aStartIndex.GetFieldOffset() >= 0 && 498*cdf0e10cSrcweir aStartIndex.GetFieldOffset() <= USHRT_MAX, 499*cdf0e10cSrcweir "SvxAccessibleTextIndex::GetText: index value overflow"); 500*cdf0e10cSrcweir 501*cdf0e10cSrcweir sStr.Erase(0, static_cast< sal_uInt16 > (aStartIndex.GetFieldOffset()) ); 502*cdf0e10cSrcweir } 503*cdf0e10cSrcweir if( aEndIndex.InField() && aEndIndex.GetFieldOffset() ) 504*cdf0e10cSrcweir { 505*cdf0e10cSrcweir DBG_ASSERT(sStr.Len() - (aEndIndex.GetFieldLen() - aEndIndex.GetFieldOffset()) >= 0 && 506*cdf0e10cSrcweir sStr.Len() - (aEndIndex.GetFieldLen() - aEndIndex.GetFieldOffset()) <= USHRT_MAX, 507*cdf0e10cSrcweir "SvxAccessibleTextIndex::GetText: index value overflow"); 508*cdf0e10cSrcweir 509*cdf0e10cSrcweir sStr = sStr.Copy(0, static_cast< sal_uInt16 > (sStr.Len() - (aEndIndex.GetFieldLen() - aEndIndex.GetFieldOffset())) ); 510*cdf0e10cSrcweir } 511*cdf0e10cSrcweir 512*cdf0e10cSrcweir EBulletInfo aBulletInfo1 = GetBulletInfo( static_cast< sal_uInt16 >(aStartIndex.GetParagraph()) ); 513*cdf0e10cSrcweir EBulletInfo aBulletInfo2 = GetBulletInfo( static_cast< sal_uInt16 >(aEndIndex.GetParagraph()) ); 514*cdf0e10cSrcweir 515*cdf0e10cSrcweir if( aStartIndex.InBullet() ) 516*cdf0e10cSrcweir { 517*cdf0e10cSrcweir // prepend leading bullet 518*cdf0e10cSrcweir String sBullet = aBulletInfo1.aText; 519*cdf0e10cSrcweir 520*cdf0e10cSrcweir DBG_ASSERT(aStartIndex.GetBulletOffset() >= 0 && 521*cdf0e10cSrcweir aStartIndex.GetBulletOffset() <= USHRT_MAX, 522*cdf0e10cSrcweir "SvxAccessibleTextIndex::GetText: index value overflow"); 523*cdf0e10cSrcweir 524*cdf0e10cSrcweir sBullet.Erase(0, static_cast< sal_uInt16 > (aStartIndex.GetBulletOffset()) ); 525*cdf0e10cSrcweir 526*cdf0e10cSrcweir sBullet += sStr; 527*cdf0e10cSrcweir sStr = sBullet; 528*cdf0e10cSrcweir } 529*cdf0e10cSrcweir 530*cdf0e10cSrcweir if( aEndIndex.InBullet() ) 531*cdf0e10cSrcweir { 532*cdf0e10cSrcweir // append trailing bullet 533*cdf0e10cSrcweir sStr += aBulletInfo2.aText;; 534*cdf0e10cSrcweir 535*cdf0e10cSrcweir DBG_ASSERT(sStr.Len() - (aEndIndex.GetBulletLen() - aEndIndex.GetBulletOffset()) >= 0 && 536*cdf0e10cSrcweir sStr.Len() - (aEndIndex.GetBulletLen() - aEndIndex.GetBulletOffset()) <= USHRT_MAX, 537*cdf0e10cSrcweir "SvxAccessibleTextIndex::GetText: index value overflow"); 538*cdf0e10cSrcweir 539*cdf0e10cSrcweir sStr = sStr.Copy(0, static_cast< sal_uInt16 > (sStr.Len() - (aEndIndex.GetBulletLen() - aEndIndex.GetBulletOffset())) ); 540*cdf0e10cSrcweir } 541*cdf0e10cSrcweir else if( aStartIndex.GetParagraph() != aEndIndex.GetParagraph() && 542*cdf0e10cSrcweir HaveTextBullet( aEndIndex.GetParagraph() ) ) 543*cdf0e10cSrcweir { 544*cdf0e10cSrcweir String sBullet = aBulletInfo2.aText; 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir DBG_ASSERT(sBullet.Len() - (aEndIndex.GetBulletLen() - aEndIndex.GetBulletOffset()) >= 0 && 547*cdf0e10cSrcweir sBullet.Len() - (aEndIndex.GetBulletLen() - aEndIndex.GetBulletOffset()) <= USHRT_MAX, 548*cdf0e10cSrcweir "SvxAccessibleTextIndex::GetText: index value overflow"); 549*cdf0e10cSrcweir 550*cdf0e10cSrcweir sBullet = sBullet.Copy(0, static_cast< sal_uInt16 > (sBullet.Len() - (aEndIndex.GetBulletLen() - aEndIndex.GetBulletOffset())) ); 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir // insert bullet 553*cdf0e10cSrcweir sStr.Insert( sBullet, 554*cdf0e10cSrcweir static_cast< sal_uInt16 > (GetTextLen(aStartIndex.GetParagraph()) - aStartIndex.GetIndex()) ); 555*cdf0e10cSrcweir } 556*cdf0e10cSrcweir 557*cdf0e10cSrcweir return sStr; 558*cdf0e10cSrcweir } 559*cdf0e10cSrcweir 560*cdf0e10cSrcweir SfxItemSet SvxAccessibleTextAdapter::GetAttribs( const ESelection& rSel, sal_Bool bOnlyHardAttrib ) const 561*cdf0e10cSrcweir { 562*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 563*cdf0e10cSrcweir 564*cdf0e10cSrcweir SvxAccessibleTextIndex aStartIndex; 565*cdf0e10cSrcweir SvxAccessibleTextIndex aEndIndex; 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this ); 568*cdf0e10cSrcweir aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this ); 569*cdf0e10cSrcweir 570*cdf0e10cSrcweir return mrTextForwarder->GetAttribs( MakeEESelection(aStartIndex, aEndIndex), 571*cdf0e10cSrcweir bOnlyHardAttrib ); 572*cdf0e10cSrcweir } 573*cdf0e10cSrcweir 574*cdf0e10cSrcweir SfxItemSet SvxAccessibleTextAdapter::GetParaAttribs( sal_uInt16 nPara ) const 575*cdf0e10cSrcweir { 576*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir return mrTextForwarder->GetParaAttribs( nPara ); 579*cdf0e10cSrcweir } 580*cdf0e10cSrcweir 581*cdf0e10cSrcweir void SvxAccessibleTextAdapter::SetParaAttribs( sal_uInt16 nPara, const SfxItemSet& rSet ) 582*cdf0e10cSrcweir { 583*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 584*cdf0e10cSrcweir 585*cdf0e10cSrcweir mrTextForwarder->SetParaAttribs( nPara, rSet ); 586*cdf0e10cSrcweir } 587*cdf0e10cSrcweir 588*cdf0e10cSrcweir void SvxAccessibleTextAdapter::RemoveAttribs( const ESelection& , sal_Bool , sal_uInt16 ) 589*cdf0e10cSrcweir { 590*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 591*cdf0e10cSrcweir } 592*cdf0e10cSrcweir 593*cdf0e10cSrcweir void SvxAccessibleTextAdapter::GetPortions( sal_uInt16 nPara, SvUShorts& rList ) const 594*cdf0e10cSrcweir { 595*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 596*cdf0e10cSrcweir 597*cdf0e10cSrcweir mrTextForwarder->GetPortions( nPara, rList ); 598*cdf0e10cSrcweir } 599*cdf0e10cSrcweir 600*cdf0e10cSrcweir sal_uInt16 SvxAccessibleTextAdapter::GetItemState( const ESelection& rSel, sal_uInt16 nWhich ) const 601*cdf0e10cSrcweir { 602*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 603*cdf0e10cSrcweir 604*cdf0e10cSrcweir SvxAccessibleTextIndex aStartIndex; 605*cdf0e10cSrcweir SvxAccessibleTextIndex aEndIndex; 606*cdf0e10cSrcweir 607*cdf0e10cSrcweir aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this ); 608*cdf0e10cSrcweir aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this ); 609*cdf0e10cSrcweir 610*cdf0e10cSrcweir return mrTextForwarder->GetItemState( MakeEESelection(aStartIndex, aEndIndex), 611*cdf0e10cSrcweir nWhich ); 612*cdf0e10cSrcweir } 613*cdf0e10cSrcweir 614*cdf0e10cSrcweir sal_uInt16 SvxAccessibleTextAdapter::GetItemState( sal_uInt16 nPara, sal_uInt16 nWhich ) const 615*cdf0e10cSrcweir { 616*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 617*cdf0e10cSrcweir 618*cdf0e10cSrcweir return mrTextForwarder->GetItemState( nPara, nWhich ); 619*cdf0e10cSrcweir } 620*cdf0e10cSrcweir 621*cdf0e10cSrcweir void SvxAccessibleTextAdapter::QuickInsertText( const String& rText, const ESelection& rSel ) 622*cdf0e10cSrcweir { 623*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 624*cdf0e10cSrcweir 625*cdf0e10cSrcweir SvxAccessibleTextIndex aStartIndex; 626*cdf0e10cSrcweir SvxAccessibleTextIndex aEndIndex; 627*cdf0e10cSrcweir 628*cdf0e10cSrcweir aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this ); 629*cdf0e10cSrcweir aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this ); 630*cdf0e10cSrcweir 631*cdf0e10cSrcweir mrTextForwarder->QuickInsertText( rText, 632*cdf0e10cSrcweir MakeEESelection(aStartIndex, aEndIndex) ); 633*cdf0e10cSrcweir } 634*cdf0e10cSrcweir 635*cdf0e10cSrcweir void SvxAccessibleTextAdapter::QuickInsertField( const SvxFieldItem& rFld, const ESelection& rSel ) 636*cdf0e10cSrcweir { 637*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 638*cdf0e10cSrcweir 639*cdf0e10cSrcweir SvxAccessibleTextIndex aStartIndex; 640*cdf0e10cSrcweir SvxAccessibleTextIndex aEndIndex; 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this ); 643*cdf0e10cSrcweir aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this ); 644*cdf0e10cSrcweir 645*cdf0e10cSrcweir mrTextForwarder->QuickInsertField( rFld, 646*cdf0e10cSrcweir MakeEESelection(aStartIndex, aEndIndex) ); 647*cdf0e10cSrcweir } 648*cdf0e10cSrcweir 649*cdf0e10cSrcweir void SvxAccessibleTextAdapter::QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel ) 650*cdf0e10cSrcweir { 651*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 652*cdf0e10cSrcweir 653*cdf0e10cSrcweir SvxAccessibleTextIndex aStartIndex; 654*cdf0e10cSrcweir SvxAccessibleTextIndex aEndIndex; 655*cdf0e10cSrcweir 656*cdf0e10cSrcweir aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this ); 657*cdf0e10cSrcweir aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this ); 658*cdf0e10cSrcweir 659*cdf0e10cSrcweir mrTextForwarder->QuickSetAttribs( rSet, 660*cdf0e10cSrcweir MakeEESelection(aStartIndex, aEndIndex) ); 661*cdf0e10cSrcweir } 662*cdf0e10cSrcweir 663*cdf0e10cSrcweir void SvxAccessibleTextAdapter::QuickInsertLineBreak( const ESelection& rSel ) 664*cdf0e10cSrcweir { 665*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 666*cdf0e10cSrcweir 667*cdf0e10cSrcweir SvxAccessibleTextIndex aStartIndex; 668*cdf0e10cSrcweir SvxAccessibleTextIndex aEndIndex; 669*cdf0e10cSrcweir 670*cdf0e10cSrcweir aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this ); 671*cdf0e10cSrcweir aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this ); 672*cdf0e10cSrcweir 673*cdf0e10cSrcweir mrTextForwarder->QuickInsertLineBreak( MakeEESelection(aStartIndex, aEndIndex) ); 674*cdf0e10cSrcweir } 675*cdf0e10cSrcweir 676*cdf0e10cSrcweir SfxItemPool* SvxAccessibleTextAdapter::GetPool() const 677*cdf0e10cSrcweir { 678*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 679*cdf0e10cSrcweir 680*cdf0e10cSrcweir return mrTextForwarder->GetPool(); 681*cdf0e10cSrcweir } 682*cdf0e10cSrcweir 683*cdf0e10cSrcweir XubString SvxAccessibleTextAdapter::CalcFieldValue( const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos, Color*& rpTxtColor, Color*& rpFldColor ) 684*cdf0e10cSrcweir { 685*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 686*cdf0e10cSrcweir 687*cdf0e10cSrcweir return mrTextForwarder->CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor ); 688*cdf0e10cSrcweir } 689*cdf0e10cSrcweir 690*cdf0e10cSrcweir void SvxAccessibleTextAdapter::FieldClicked( const SvxFieldItem& rField, sal_uInt16 nPara, xub_StrLen nPos ) 691*cdf0e10cSrcweir { 692*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 693*cdf0e10cSrcweir 694*cdf0e10cSrcweir mrTextForwarder->FieldClicked( rField, nPara, nPos ); 695*cdf0e10cSrcweir } 696*cdf0e10cSrcweir 697*cdf0e10cSrcweir sal_Int32 SvxAccessibleTextAdapter::CalcLogicalIndex( sal_uInt16 nPara, sal_uInt16 nEEIndex ) 698*cdf0e10cSrcweir { 699*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 700*cdf0e10cSrcweir 701*cdf0e10cSrcweir SvxAccessibleTextIndex aIndex; 702*cdf0e10cSrcweir aIndex.SetEEIndex(nPara, nEEIndex, *mrTextForwarder); 703*cdf0e10cSrcweir return aIndex.GetIndex(); 704*cdf0e10cSrcweir } 705*cdf0e10cSrcweir 706*cdf0e10cSrcweir sal_uInt16 SvxAccessibleTextAdapter::CalcEditEngineIndex( sal_uInt16 nPara, sal_Int32 nLogicalIndex ) 707*cdf0e10cSrcweir { 708*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 709*cdf0e10cSrcweir 710*cdf0e10cSrcweir SvxAccessibleTextIndex aIndex; 711*cdf0e10cSrcweir aIndex.SetIndex(nPara, nLogicalIndex, *mrTextForwarder); 712*cdf0e10cSrcweir return aIndex.GetEEIndex(); 713*cdf0e10cSrcweir } 714*cdf0e10cSrcweir 715*cdf0e10cSrcweir 716*cdf0e10cSrcweir 717*cdf0e10cSrcweir sal_Bool SvxAccessibleTextAdapter::IsValid() const 718*cdf0e10cSrcweir { 719*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 720*cdf0e10cSrcweir 721*cdf0e10cSrcweir if( mrTextForwarder ) 722*cdf0e10cSrcweir return mrTextForwarder->IsValid(); 723*cdf0e10cSrcweir else 724*cdf0e10cSrcweir return sal_False; 725*cdf0e10cSrcweir } 726*cdf0e10cSrcweir 727*cdf0e10cSrcweir LanguageType SvxAccessibleTextAdapter::GetLanguage( sal_uInt16 nPara, sal_uInt16 nPos ) const 728*cdf0e10cSrcweir { 729*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 730*cdf0e10cSrcweir 731*cdf0e10cSrcweir SvxAccessibleTextIndex aIndex; 732*cdf0e10cSrcweir 733*cdf0e10cSrcweir aIndex.SetIndex( nPara, nPos, *this ); 734*cdf0e10cSrcweir 735*cdf0e10cSrcweir return mrTextForwarder->GetLanguage( nPara, aIndex.GetEEIndex() ); 736*cdf0e10cSrcweir } 737*cdf0e10cSrcweir 738*cdf0e10cSrcweir sal_uInt16 SvxAccessibleTextAdapter::GetFieldCount( sal_uInt16 nPara ) const 739*cdf0e10cSrcweir { 740*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 741*cdf0e10cSrcweir 742*cdf0e10cSrcweir return mrTextForwarder->GetFieldCount( nPara ); 743*cdf0e10cSrcweir } 744*cdf0e10cSrcweir 745*cdf0e10cSrcweir EFieldInfo SvxAccessibleTextAdapter::GetFieldInfo( sal_uInt16 nPara, sal_uInt16 nField ) const 746*cdf0e10cSrcweir { 747*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 748*cdf0e10cSrcweir 749*cdf0e10cSrcweir return mrTextForwarder->GetFieldInfo( nPara, nField ); 750*cdf0e10cSrcweir } 751*cdf0e10cSrcweir 752*cdf0e10cSrcweir EBulletInfo SvxAccessibleTextAdapter::GetBulletInfo( sal_uInt16 nPara ) const 753*cdf0e10cSrcweir { 754*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 755*cdf0e10cSrcweir 756*cdf0e10cSrcweir return mrTextForwarder->GetBulletInfo( nPara ); 757*cdf0e10cSrcweir } 758*cdf0e10cSrcweir 759*cdf0e10cSrcweir Rectangle SvxAccessibleTextAdapter::GetCharBounds( sal_uInt16 nPara, sal_uInt16 nIndex ) const 760*cdf0e10cSrcweir { 761*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 762*cdf0e10cSrcweir 763*cdf0e10cSrcweir SvxAccessibleTextIndex aIndex; 764*cdf0e10cSrcweir aIndex.SetIndex( nPara, nIndex, *this ); 765*cdf0e10cSrcweir 766*cdf0e10cSrcweir // preset if anything goes wrong below 767*cdf0e10cSrcweir // n-th char in GetParagraphIndex's paragraph 768*cdf0e10cSrcweir Rectangle aRect = mrTextForwarder->GetCharBounds( nPara, static_cast< sal_uInt16 >( aIndex.GetEEIndex() ) ); 769*cdf0e10cSrcweir 770*cdf0e10cSrcweir if( aIndex.InBullet() ) 771*cdf0e10cSrcweir { 772*cdf0e10cSrcweir EBulletInfo aBulletInfo = GetBulletInfo( nPara ); 773*cdf0e10cSrcweir 774*cdf0e10cSrcweir OutputDevice* pOutDev = GetRefDevice(); 775*cdf0e10cSrcweir 776*cdf0e10cSrcweir DBG_ASSERT(pOutDev!=NULL, "SvxAccessibleTextAdapter::GetCharBounds: No ref device"); 777*cdf0e10cSrcweir 778*cdf0e10cSrcweir // preset if anything goes wrong below 779*cdf0e10cSrcweir aRect = aBulletInfo.aBounds; // better than nothing 780*cdf0e10cSrcweir if( pOutDev ) 781*cdf0e10cSrcweir { 782*cdf0e10cSrcweir AccessibleStringWrap aStringWrap( *pOutDev, aBulletInfo.aFont, aBulletInfo.aText ); 783*cdf0e10cSrcweir 784*cdf0e10cSrcweir if( aStringWrap.GetCharacterBounds( aIndex.GetBulletOffset(), aRect ) ) 785*cdf0e10cSrcweir aRect.Move( aBulletInfo.aBounds.Left(), aBulletInfo.aBounds.Top() ); 786*cdf0e10cSrcweir } 787*cdf0e10cSrcweir } 788*cdf0e10cSrcweir else 789*cdf0e10cSrcweir { 790*cdf0e10cSrcweir // handle field content manually 791*cdf0e10cSrcweir if( aIndex.InField() ) 792*cdf0e10cSrcweir { 793*cdf0e10cSrcweir OutputDevice* pOutDev = GetRefDevice(); 794*cdf0e10cSrcweir 795*cdf0e10cSrcweir DBG_ASSERT(pOutDev!=NULL, "SvxAccessibleTextAdapter::GetCharBounds: No ref device"); 796*cdf0e10cSrcweir 797*cdf0e10cSrcweir if( pOutDev ) 798*cdf0e10cSrcweir { 799*cdf0e10cSrcweir ESelection aSel = MakeEESelection( aIndex ); 800*cdf0e10cSrcweir 801*cdf0e10cSrcweir SvxFont aFont = EditEngine::CreateSvxFontFromItemSet( mrTextForwarder->GetAttribs( aSel ) ); 802*cdf0e10cSrcweir AccessibleStringWrap aStringWrap( *pOutDev, 803*cdf0e10cSrcweir aFont, 804*cdf0e10cSrcweir mrTextForwarder->GetText( aSel ) ); 805*cdf0e10cSrcweir 806*cdf0e10cSrcweir Rectangle aStartRect = mrTextForwarder->GetCharBounds( nPara, static_cast< sal_uInt16 >( aIndex.GetEEIndex() ) ); 807*cdf0e10cSrcweir 808*cdf0e10cSrcweir if( !aStringWrap.GetCharacterBounds( aIndex.GetFieldOffset(), aRect ) ) 809*cdf0e10cSrcweir aRect = aStartRect; 810*cdf0e10cSrcweir else 811*cdf0e10cSrcweir aRect.Move( aStartRect.Left(), aStartRect.Top() ); 812*cdf0e10cSrcweir } 813*cdf0e10cSrcweir } 814*cdf0e10cSrcweir } 815*cdf0e10cSrcweir 816*cdf0e10cSrcweir return aRect; 817*cdf0e10cSrcweir } 818*cdf0e10cSrcweir 819*cdf0e10cSrcweir Rectangle SvxAccessibleTextAdapter::GetParaBounds( sal_uInt16 nPara ) const 820*cdf0e10cSrcweir { 821*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 822*cdf0e10cSrcweir 823*cdf0e10cSrcweir EBulletInfo aBulletInfo = GetBulletInfo( nPara ); 824*cdf0e10cSrcweir 825*cdf0e10cSrcweir if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && 826*cdf0e10cSrcweir aBulletInfo.bVisible && 827*cdf0e10cSrcweir aBulletInfo.nType != SVX_NUM_BITMAP ) 828*cdf0e10cSrcweir { 829*cdf0e10cSrcweir // include bullet in para bounding box 830*cdf0e10cSrcweir Rectangle aRect( mrTextForwarder->GetParaBounds( nPara ) ); 831*cdf0e10cSrcweir 832*cdf0e10cSrcweir aRect.Union( aBulletInfo.aBounds ); 833*cdf0e10cSrcweir 834*cdf0e10cSrcweir return aRect; 835*cdf0e10cSrcweir } 836*cdf0e10cSrcweir 837*cdf0e10cSrcweir return mrTextForwarder->GetParaBounds( nPara ); 838*cdf0e10cSrcweir } 839*cdf0e10cSrcweir 840*cdf0e10cSrcweir MapMode SvxAccessibleTextAdapter::GetMapMode() const 841*cdf0e10cSrcweir { 842*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 843*cdf0e10cSrcweir 844*cdf0e10cSrcweir return mrTextForwarder->GetMapMode(); 845*cdf0e10cSrcweir } 846*cdf0e10cSrcweir 847*cdf0e10cSrcweir OutputDevice* SvxAccessibleTextAdapter::GetRefDevice() const 848*cdf0e10cSrcweir { 849*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 850*cdf0e10cSrcweir 851*cdf0e10cSrcweir return mrTextForwarder->GetRefDevice(); 852*cdf0e10cSrcweir } 853*cdf0e10cSrcweir 854*cdf0e10cSrcweir sal_Bool SvxAccessibleTextAdapter::GetIndexAtPoint( const Point& rPoint, sal_uInt16& nPara, sal_uInt16& nIndex ) const 855*cdf0e10cSrcweir { 856*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 857*cdf0e10cSrcweir 858*cdf0e10cSrcweir if( !mrTextForwarder->GetIndexAtPoint( rPoint, nPara, nIndex ) ) 859*cdf0e10cSrcweir return sal_False; 860*cdf0e10cSrcweir 861*cdf0e10cSrcweir SvxAccessibleTextIndex aIndex; 862*cdf0e10cSrcweir aIndex.SetEEIndex(nPara, nIndex, *this); 863*cdf0e10cSrcweir 864*cdf0e10cSrcweir DBG_ASSERT(aIndex.GetIndex() >= 0 && aIndex.GetIndex() <= USHRT_MAX, 865*cdf0e10cSrcweir "SvxAccessibleTextIndex::SetIndex: index value overflow"); 866*cdf0e10cSrcweir 867*cdf0e10cSrcweir nIndex = static_cast< sal_uInt16 > (aIndex.GetIndex()); 868*cdf0e10cSrcweir 869*cdf0e10cSrcweir EBulletInfo aBulletInfo = GetBulletInfo( nPara ); 870*cdf0e10cSrcweir 871*cdf0e10cSrcweir // any text bullets? 872*cdf0e10cSrcweir if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && 873*cdf0e10cSrcweir aBulletInfo.bVisible && 874*cdf0e10cSrcweir aBulletInfo.nType != SVX_NUM_BITMAP ) 875*cdf0e10cSrcweir { 876*cdf0e10cSrcweir if( aBulletInfo.aBounds.IsInside( rPoint) ) 877*cdf0e10cSrcweir { 878*cdf0e10cSrcweir OutputDevice* pOutDev = GetRefDevice(); 879*cdf0e10cSrcweir 880*cdf0e10cSrcweir DBG_ASSERT(pOutDev!=NULL, "SvxAccessibleTextAdapter::GetIndexAtPoint: No ref device"); 881*cdf0e10cSrcweir 882*cdf0e10cSrcweir if( !pOutDev ) 883*cdf0e10cSrcweir return sal_False; 884*cdf0e10cSrcweir 885*cdf0e10cSrcweir AccessibleStringWrap aStringWrap( *pOutDev, aBulletInfo.aFont, aBulletInfo.aText ); 886*cdf0e10cSrcweir 887*cdf0e10cSrcweir Point aPoint = rPoint; 888*cdf0e10cSrcweir aPoint.Move( -aBulletInfo.aBounds.Left(), -aBulletInfo.aBounds.Top() ); 889*cdf0e10cSrcweir 890*cdf0e10cSrcweir DBG_ASSERT(aStringWrap.GetIndexAtPoint( aPoint ) >= 0 && 891*cdf0e10cSrcweir aStringWrap.GetIndexAtPoint( aPoint ) <= USHRT_MAX, 892*cdf0e10cSrcweir "SvxAccessibleTextIndex::SetIndex: index value overflow"); 893*cdf0e10cSrcweir 894*cdf0e10cSrcweir nIndex = static_cast< sal_uInt16 > (aStringWrap.GetIndexAtPoint( aPoint )); 895*cdf0e10cSrcweir return sal_True; 896*cdf0e10cSrcweir } 897*cdf0e10cSrcweir } 898*cdf0e10cSrcweir 899*cdf0e10cSrcweir if( aIndex.InField() ) 900*cdf0e10cSrcweir { 901*cdf0e10cSrcweir OutputDevice* pOutDev = GetRefDevice(); 902*cdf0e10cSrcweir 903*cdf0e10cSrcweir DBG_ASSERT(pOutDev!=NULL, "SvxAccessibleTextAdapter::GetIndexAtPoint: No ref device"); 904*cdf0e10cSrcweir 905*cdf0e10cSrcweir if( !pOutDev ) 906*cdf0e10cSrcweir return sal_False; 907*cdf0e10cSrcweir 908*cdf0e10cSrcweir ESelection aSelection = MakeEESelection( aIndex ); 909*cdf0e10cSrcweir SvxFont aFont = EditEngine::CreateSvxFontFromItemSet( mrTextForwarder->GetAttribs( aSelection ) ); 910*cdf0e10cSrcweir AccessibleStringWrap aStringWrap( *pOutDev, 911*cdf0e10cSrcweir aFont, 912*cdf0e10cSrcweir mrTextForwarder->GetText( aSelection ) ); 913*cdf0e10cSrcweir 914*cdf0e10cSrcweir Rectangle aRect = mrTextForwarder->GetCharBounds( nPara, aIndex.GetEEIndex() ); 915*cdf0e10cSrcweir Point aPoint = rPoint; 916*cdf0e10cSrcweir aPoint.Move( -aRect.Left(), -aRect.Top() ); 917*cdf0e10cSrcweir 918*cdf0e10cSrcweir DBG_ASSERT(aIndex.GetIndex() + aStringWrap.GetIndexAtPoint( rPoint ) >= 0 && 919*cdf0e10cSrcweir aIndex.GetIndex() + aStringWrap.GetIndexAtPoint( rPoint ) <= USHRT_MAX, 920*cdf0e10cSrcweir "SvxAccessibleTextIndex::SetIndex: index value overflow"); 921*cdf0e10cSrcweir 922*cdf0e10cSrcweir nIndex = static_cast< sal_uInt16 >(aIndex.GetIndex() + aStringWrap.GetIndexAtPoint( aPoint )); 923*cdf0e10cSrcweir return sal_True; 924*cdf0e10cSrcweir } 925*cdf0e10cSrcweir 926*cdf0e10cSrcweir return sal_True; 927*cdf0e10cSrcweir } 928*cdf0e10cSrcweir 929*cdf0e10cSrcweir sal_Bool SvxAccessibleTextAdapter::GetWordIndices( sal_uInt16 nPara, sal_uInt16 nIndex, sal_uInt16& nStart, sal_uInt16& nEnd ) const 930*cdf0e10cSrcweir { 931*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 932*cdf0e10cSrcweir 933*cdf0e10cSrcweir SvxAccessibleTextIndex aIndex; 934*cdf0e10cSrcweir aIndex.SetIndex(nPara, nIndex, *this); 935*cdf0e10cSrcweir nIndex = aIndex.GetEEIndex(); 936*cdf0e10cSrcweir 937*cdf0e10cSrcweir if( aIndex.InBullet() ) 938*cdf0e10cSrcweir { 939*cdf0e10cSrcweir DBG_ASSERT(aIndex.GetBulletLen() >= 0 && 940*cdf0e10cSrcweir aIndex.GetBulletLen() <= USHRT_MAX, 941*cdf0e10cSrcweir "SvxAccessibleTextIndex::SetIndex: index value overflow"); 942*cdf0e10cSrcweir 943*cdf0e10cSrcweir // always treat bullet as separate word 944*cdf0e10cSrcweir nStart = 0; 945*cdf0e10cSrcweir nEnd = static_cast< sal_uInt16 > (aIndex.GetBulletLen()); 946*cdf0e10cSrcweir 947*cdf0e10cSrcweir return sal_True; 948*cdf0e10cSrcweir } 949*cdf0e10cSrcweir 950*cdf0e10cSrcweir if( aIndex.InField() ) 951*cdf0e10cSrcweir { 952*cdf0e10cSrcweir DBG_ASSERT(aIndex.GetIndex() - aIndex.GetFieldOffset() >= 0 && 953*cdf0e10cSrcweir aIndex.GetIndex() - aIndex.GetFieldOffset() <= USHRT_MAX && 954*cdf0e10cSrcweir nStart + aIndex.GetFieldLen() >= 0 && 955*cdf0e10cSrcweir nStart + aIndex.GetFieldLen() <= USHRT_MAX, 956*cdf0e10cSrcweir "SvxAccessibleTextIndex::SetIndex: index value overflow"); 957*cdf0e10cSrcweir 958*cdf0e10cSrcweir // always treat field as separate word 959*cdf0e10cSrcweir // TODO: to circumvent this, _we_ would have to do the break iterator stuff! 960*cdf0e10cSrcweir nStart = static_cast< sal_uInt16 > (aIndex.GetIndex() - aIndex.GetFieldOffset()); 961*cdf0e10cSrcweir nEnd = static_cast< sal_uInt16 > (nStart + aIndex.GetFieldLen()); 962*cdf0e10cSrcweir 963*cdf0e10cSrcweir return sal_True; 964*cdf0e10cSrcweir } 965*cdf0e10cSrcweir 966*cdf0e10cSrcweir if( !mrTextForwarder->GetWordIndices( nPara, nIndex, nStart, nEnd ) ) 967*cdf0e10cSrcweir return sal_False; 968*cdf0e10cSrcweir 969*cdf0e10cSrcweir aIndex.SetEEIndex( nPara, nStart, *this ); 970*cdf0e10cSrcweir DBG_ASSERT(aIndex.GetIndex() >= 0 && 971*cdf0e10cSrcweir aIndex.GetIndex() <= USHRT_MAX, 972*cdf0e10cSrcweir "SvxAccessibleTextIndex::SetIndex: index value overflow"); 973*cdf0e10cSrcweir nStart = static_cast< sal_uInt16 > (aIndex.GetIndex()); 974*cdf0e10cSrcweir 975*cdf0e10cSrcweir aIndex.SetEEIndex( nPara, nEnd, *this ); 976*cdf0e10cSrcweir DBG_ASSERT(aIndex.GetIndex() >= 0 && 977*cdf0e10cSrcweir aIndex.GetIndex() <= USHRT_MAX, 978*cdf0e10cSrcweir "SvxAccessibleTextIndex::SetIndex: index value overflow"); 979*cdf0e10cSrcweir nEnd = static_cast< sal_uInt16 > (aIndex.GetIndex()); 980*cdf0e10cSrcweir 981*cdf0e10cSrcweir return sal_True; 982*cdf0e10cSrcweir } 983*cdf0e10cSrcweir 984*cdf0e10cSrcweir sal_Bool SvxAccessibleTextAdapter::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, sal_uInt16 nPara, sal_uInt16 nIndex ) const 985*cdf0e10cSrcweir { 986*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 987*cdf0e10cSrcweir 988*cdf0e10cSrcweir SvxAccessibleTextIndex aIndex; 989*cdf0e10cSrcweir aIndex.SetIndex(nPara, nIndex, *this); 990*cdf0e10cSrcweir nIndex = aIndex.GetEEIndex(); 991*cdf0e10cSrcweir 992*cdf0e10cSrcweir if( aIndex.InBullet() ) 993*cdf0e10cSrcweir { 994*cdf0e10cSrcweir DBG_ASSERT(aIndex.GetBulletLen() >= 0 && 995*cdf0e10cSrcweir aIndex.GetBulletLen() <= USHRT_MAX, 996*cdf0e10cSrcweir "SvxAccessibleTextIndex::SetIndex: index value overflow"); 997*cdf0e10cSrcweir 998*cdf0e10cSrcweir // always treat bullet as distinct attribute 999*cdf0e10cSrcweir nStartIndex = 0; 1000*cdf0e10cSrcweir nEndIndex = static_cast< sal_uInt16 > (aIndex.GetBulletLen()); 1001*cdf0e10cSrcweir 1002*cdf0e10cSrcweir return sal_True; 1003*cdf0e10cSrcweir } 1004*cdf0e10cSrcweir 1005*cdf0e10cSrcweir if( aIndex.InField() ) 1006*cdf0e10cSrcweir { 1007*cdf0e10cSrcweir DBG_ASSERT(aIndex.GetIndex() - aIndex.GetFieldOffset() >= 0 && 1008*cdf0e10cSrcweir aIndex.GetIndex() - aIndex.GetFieldOffset() <= USHRT_MAX, 1009*cdf0e10cSrcweir "SvxAccessibleTextIndex::SetIndex: index value overflow"); 1010*cdf0e10cSrcweir 1011*cdf0e10cSrcweir // always treat field as distinct attribute 1012*cdf0e10cSrcweir nStartIndex = static_cast< sal_uInt16 > (aIndex.GetIndex() - aIndex.GetFieldOffset()); 1013*cdf0e10cSrcweir nEndIndex = static_cast< sal_uInt16 > (nStartIndex + aIndex.GetFieldLen()); 1014*cdf0e10cSrcweir 1015*cdf0e10cSrcweir return sal_True; 1016*cdf0e10cSrcweir } 1017*cdf0e10cSrcweir 1018*cdf0e10cSrcweir if( !mrTextForwarder->GetAttributeRun( nStartIndex, nEndIndex, nPara, nIndex ) ) 1019*cdf0e10cSrcweir return sal_False; 1020*cdf0e10cSrcweir 1021*cdf0e10cSrcweir aIndex.SetEEIndex( nPara, nStartIndex, *this ); 1022*cdf0e10cSrcweir DBG_ASSERT(aIndex.GetIndex() >= 0 && 1023*cdf0e10cSrcweir aIndex.GetIndex() <= USHRT_MAX, 1024*cdf0e10cSrcweir "SvxAccessibleTextIndex::SetIndex: index value overflow"); 1025*cdf0e10cSrcweir nStartIndex = static_cast< sal_uInt16 > (aIndex.GetIndex()); 1026*cdf0e10cSrcweir 1027*cdf0e10cSrcweir aIndex.SetEEIndex( nPara, nEndIndex, *this ); 1028*cdf0e10cSrcweir DBG_ASSERT(aIndex.GetIndex() >= 0 && 1029*cdf0e10cSrcweir aIndex.GetIndex() <= USHRT_MAX, 1030*cdf0e10cSrcweir "SvxAccessibleTextIndex::SetIndex: index value overflow"); 1031*cdf0e10cSrcweir nEndIndex = static_cast< sal_uInt16 > (aIndex.GetIndex()); 1032*cdf0e10cSrcweir 1033*cdf0e10cSrcweir return sal_True; 1034*cdf0e10cSrcweir } 1035*cdf0e10cSrcweir 1036*cdf0e10cSrcweir sal_uInt16 SvxAccessibleTextAdapter::GetLineCount( sal_uInt16 nPara ) const 1037*cdf0e10cSrcweir { 1038*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 1039*cdf0e10cSrcweir 1040*cdf0e10cSrcweir return mrTextForwarder->GetLineCount( nPara ); 1041*cdf0e10cSrcweir } 1042*cdf0e10cSrcweir 1043*cdf0e10cSrcweir sal_uInt16 SvxAccessibleTextAdapter::GetLineLen( sal_uInt16 nPara, sal_uInt16 nLine ) const 1044*cdf0e10cSrcweir { 1045*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 1046*cdf0e10cSrcweir 1047*cdf0e10cSrcweir SvxAccessibleTextIndex aStartIndex; 1048*cdf0e10cSrcweir SvxAccessibleTextIndex aEndIndex; 1049*cdf0e10cSrcweir sal_uInt16 nCurrLine; 1050*cdf0e10cSrcweir sal_uInt16 nCurrIndex, nLastIndex; 1051*cdf0e10cSrcweir for( nCurrLine=0, nCurrIndex=0, nLastIndex=0; nCurrLine<=nLine; ++nCurrLine ) 1052*cdf0e10cSrcweir { 1053*cdf0e10cSrcweir nLastIndex = nCurrIndex; 1054*cdf0e10cSrcweir nCurrIndex = 1055*cdf0e10cSrcweir nCurrIndex + mrTextForwarder->GetLineLen( nPara, nCurrLine ); 1056*cdf0e10cSrcweir } 1057*cdf0e10cSrcweir 1058*cdf0e10cSrcweir aEndIndex.SetEEIndex( nPara, nCurrIndex, *this ); 1059*cdf0e10cSrcweir if( nLine > 0 ) 1060*cdf0e10cSrcweir { 1061*cdf0e10cSrcweir aStartIndex.SetEEIndex( nPara, nLastIndex, *this ); 1062*cdf0e10cSrcweir 1063*cdf0e10cSrcweir return static_cast< sal_uInt16 >(aEndIndex.GetIndex() - aStartIndex.GetIndex()); 1064*cdf0e10cSrcweir } 1065*cdf0e10cSrcweir else 1066*cdf0e10cSrcweir return static_cast< sal_uInt16 >(aEndIndex.GetIndex()); 1067*cdf0e10cSrcweir } 1068*cdf0e10cSrcweir 1069*cdf0e10cSrcweir void SvxAccessibleTextAdapter::GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_uInt16 nParagraph, sal_uInt16 nLine ) const 1070*cdf0e10cSrcweir { 1071*cdf0e10cSrcweir mrTextForwarder->GetLineBoundaries( rStart, rEnd, nParagraph, nLine ); 1072*cdf0e10cSrcweir } 1073*cdf0e10cSrcweir 1074*cdf0e10cSrcweir sal_uInt16 SvxAccessibleTextAdapter::GetLineNumberAtIndex( sal_uInt16 nPara, sal_uInt16 nIndex ) const 1075*cdf0e10cSrcweir { 1076*cdf0e10cSrcweir return mrTextForwarder->GetLineNumberAtIndex( nPara, nIndex ); 1077*cdf0e10cSrcweir } 1078*cdf0e10cSrcweir 1079*cdf0e10cSrcweir sal_Bool SvxAccessibleTextAdapter::Delete( const ESelection& rSel ) 1080*cdf0e10cSrcweir { 1081*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 1082*cdf0e10cSrcweir 1083*cdf0e10cSrcweir SvxAccessibleTextIndex aStartIndex; 1084*cdf0e10cSrcweir SvxAccessibleTextIndex aEndIndex; 1085*cdf0e10cSrcweir 1086*cdf0e10cSrcweir aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this ); 1087*cdf0e10cSrcweir aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this ); 1088*cdf0e10cSrcweir 1089*cdf0e10cSrcweir return mrTextForwarder->Delete( MakeEESelection(aStartIndex, aEndIndex ) ); 1090*cdf0e10cSrcweir } 1091*cdf0e10cSrcweir 1092*cdf0e10cSrcweir sal_Bool SvxAccessibleTextAdapter::InsertText( const String& rStr, const ESelection& rSel ) 1093*cdf0e10cSrcweir { 1094*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 1095*cdf0e10cSrcweir 1096*cdf0e10cSrcweir SvxAccessibleTextIndex aStartIndex; 1097*cdf0e10cSrcweir SvxAccessibleTextIndex aEndIndex; 1098*cdf0e10cSrcweir 1099*cdf0e10cSrcweir aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this ); 1100*cdf0e10cSrcweir aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this ); 1101*cdf0e10cSrcweir 1102*cdf0e10cSrcweir return mrTextForwarder->InsertText( rStr, MakeEESelection(aStartIndex, aEndIndex) ); 1103*cdf0e10cSrcweir } 1104*cdf0e10cSrcweir 1105*cdf0e10cSrcweir sal_Bool SvxAccessibleTextAdapter::QuickFormatDoc( sal_Bool bFull ) 1106*cdf0e10cSrcweir { 1107*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 1108*cdf0e10cSrcweir 1109*cdf0e10cSrcweir return mrTextForwarder->QuickFormatDoc( bFull ); 1110*cdf0e10cSrcweir } 1111*cdf0e10cSrcweir 1112*cdf0e10cSrcweir sal_Int16 SvxAccessibleTextAdapter::GetDepth( sal_uInt16 nPara ) const 1113*cdf0e10cSrcweir { 1114*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 1115*cdf0e10cSrcweir 1116*cdf0e10cSrcweir return mrTextForwarder->GetDepth( nPara ); 1117*cdf0e10cSrcweir } 1118*cdf0e10cSrcweir 1119*cdf0e10cSrcweir sal_Bool SvxAccessibleTextAdapter::SetDepth( sal_uInt16 nPara, sal_Int16 nNewDepth ) 1120*cdf0e10cSrcweir { 1121*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 1122*cdf0e10cSrcweir 1123*cdf0e10cSrcweir return mrTextForwarder->SetDepth( nPara, nNewDepth ); 1124*cdf0e10cSrcweir } 1125*cdf0e10cSrcweir 1126*cdf0e10cSrcweir void SvxAccessibleTextAdapter::SetForwarder( SvxTextForwarder& rForwarder ) 1127*cdf0e10cSrcweir { 1128*cdf0e10cSrcweir mrTextForwarder = &rForwarder; 1129*cdf0e10cSrcweir } 1130*cdf0e10cSrcweir 1131*cdf0e10cSrcweir sal_Bool SvxAccessibleTextAdapter::HaveImageBullet( sal_uInt16 nPara ) const 1132*cdf0e10cSrcweir { 1133*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 1134*cdf0e10cSrcweir 1135*cdf0e10cSrcweir EBulletInfo aBulletInfo = GetBulletInfo( nPara ); 1136*cdf0e10cSrcweir 1137*cdf0e10cSrcweir if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && 1138*cdf0e10cSrcweir aBulletInfo.bVisible && 1139*cdf0e10cSrcweir aBulletInfo.nType == SVX_NUM_BITMAP ) 1140*cdf0e10cSrcweir { 1141*cdf0e10cSrcweir return sal_True; 1142*cdf0e10cSrcweir } 1143*cdf0e10cSrcweir else 1144*cdf0e10cSrcweir { 1145*cdf0e10cSrcweir return sal_False; 1146*cdf0e10cSrcweir } 1147*cdf0e10cSrcweir } 1148*cdf0e10cSrcweir 1149*cdf0e10cSrcweir sal_Bool SvxAccessibleTextAdapter::HaveTextBullet( sal_uInt16 nPara ) const 1150*cdf0e10cSrcweir { 1151*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 1152*cdf0e10cSrcweir 1153*cdf0e10cSrcweir EBulletInfo aBulletInfo = GetBulletInfo( nPara ); 1154*cdf0e10cSrcweir 1155*cdf0e10cSrcweir if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND && 1156*cdf0e10cSrcweir aBulletInfo.bVisible && 1157*cdf0e10cSrcweir aBulletInfo.nType != SVX_NUM_BITMAP ) 1158*cdf0e10cSrcweir { 1159*cdf0e10cSrcweir return sal_True; 1160*cdf0e10cSrcweir } 1161*cdf0e10cSrcweir else 1162*cdf0e10cSrcweir { 1163*cdf0e10cSrcweir return sal_False; 1164*cdf0e10cSrcweir } 1165*cdf0e10cSrcweir } 1166*cdf0e10cSrcweir 1167*cdf0e10cSrcweir sal_Bool SvxAccessibleTextAdapter::IsEditable( const ESelection& rSel ) 1168*cdf0e10cSrcweir { 1169*cdf0e10cSrcweir DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder"); 1170*cdf0e10cSrcweir 1171*cdf0e10cSrcweir SvxAccessibleTextIndex aStartIndex; 1172*cdf0e10cSrcweir SvxAccessibleTextIndex aEndIndex; 1173*cdf0e10cSrcweir 1174*cdf0e10cSrcweir aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this ); 1175*cdf0e10cSrcweir aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this ); 1176*cdf0e10cSrcweir 1177*cdf0e10cSrcweir // normalize selection 1178*cdf0e10cSrcweir if( rSel.nStartPara > rSel.nEndPara || 1179*cdf0e10cSrcweir (rSel.nStartPara == rSel.nEndPara && rSel.nStartPos > rSel.nEndPos) ) 1180*cdf0e10cSrcweir { 1181*cdf0e10cSrcweir ::std::swap( aStartIndex, aEndIndex ); 1182*cdf0e10cSrcweir } 1183*cdf0e10cSrcweir 1184*cdf0e10cSrcweir return aStartIndex.IsEditableRange( aEndIndex ); 1185*cdf0e10cSrcweir } 1186*cdf0e10cSrcweir 1187*cdf0e10cSrcweir const SfxItemSet * SvxAccessibleTextAdapter::GetEmptyItemSetPtr() 1188*cdf0e10cSrcweir { 1189*cdf0e10cSrcweir DBG_ERROR( "not implemented" ); 1190*cdf0e10cSrcweir return 0; 1191*cdf0e10cSrcweir } 1192*cdf0e10cSrcweir 1193*cdf0e10cSrcweir void SvxAccessibleTextAdapter::AppendParagraph() 1194*cdf0e10cSrcweir { 1195*cdf0e10cSrcweir DBG_ERROR( "not implemented" ); 1196*cdf0e10cSrcweir } 1197*cdf0e10cSrcweir 1198*cdf0e10cSrcweir xub_StrLen SvxAccessibleTextAdapter::AppendTextPortion( sal_uInt16, const String &, const SfxItemSet & ) 1199*cdf0e10cSrcweir { 1200*cdf0e10cSrcweir DBG_ERROR( "not implemented" ); 1201*cdf0e10cSrcweir return 0; 1202*cdf0e10cSrcweir } 1203*cdf0e10cSrcweir void SvxAccessibleTextAdapter::CopyText(const SvxTextForwarder&) 1204*cdf0e10cSrcweir { 1205*cdf0e10cSrcweir DBG_ERROR( "not implemented" ); 1206*cdf0e10cSrcweir } 1207*cdf0e10cSrcweir 1208*cdf0e10cSrcweir 1209*cdf0e10cSrcweir 1210*cdf0e10cSrcweir //--------------------------------------------------------------------------------------- 1211*cdf0e10cSrcweir 1212*cdf0e10cSrcweir SvxAccessibleTextEditViewAdapter::SvxAccessibleTextEditViewAdapter() 1213*cdf0e10cSrcweir { 1214*cdf0e10cSrcweir } 1215*cdf0e10cSrcweir 1216*cdf0e10cSrcweir SvxAccessibleTextEditViewAdapter::~SvxAccessibleTextEditViewAdapter() 1217*cdf0e10cSrcweir { 1218*cdf0e10cSrcweir } 1219*cdf0e10cSrcweir 1220*cdf0e10cSrcweir sal_Bool SvxAccessibleTextEditViewAdapter::IsValid() const 1221*cdf0e10cSrcweir { 1222*cdf0e10cSrcweir DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder"); 1223*cdf0e10cSrcweir 1224*cdf0e10cSrcweir if( mrViewForwarder ) 1225*cdf0e10cSrcweir return mrViewForwarder->IsValid(); 1226*cdf0e10cSrcweir else 1227*cdf0e10cSrcweir return sal_False; 1228*cdf0e10cSrcweir } 1229*cdf0e10cSrcweir 1230*cdf0e10cSrcweir Rectangle SvxAccessibleTextEditViewAdapter::GetVisArea() const 1231*cdf0e10cSrcweir { 1232*cdf0e10cSrcweir DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder"); 1233*cdf0e10cSrcweir 1234*cdf0e10cSrcweir return mrViewForwarder->GetVisArea(); 1235*cdf0e10cSrcweir } 1236*cdf0e10cSrcweir 1237*cdf0e10cSrcweir Point SvxAccessibleTextEditViewAdapter::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const 1238*cdf0e10cSrcweir { 1239*cdf0e10cSrcweir DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder"); 1240*cdf0e10cSrcweir 1241*cdf0e10cSrcweir return mrViewForwarder->LogicToPixel(rPoint, rMapMode); 1242*cdf0e10cSrcweir } 1243*cdf0e10cSrcweir 1244*cdf0e10cSrcweir Point SvxAccessibleTextEditViewAdapter::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const 1245*cdf0e10cSrcweir { 1246*cdf0e10cSrcweir DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder"); 1247*cdf0e10cSrcweir 1248*cdf0e10cSrcweir return mrViewForwarder->PixelToLogic(rPoint, rMapMode); 1249*cdf0e10cSrcweir } 1250*cdf0e10cSrcweir 1251*cdf0e10cSrcweir sal_Bool SvxAccessibleTextEditViewAdapter::GetSelection( ESelection& rSel ) const 1252*cdf0e10cSrcweir { 1253*cdf0e10cSrcweir DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder"); 1254*cdf0e10cSrcweir 1255*cdf0e10cSrcweir ESelection aSelection; 1256*cdf0e10cSrcweir 1257*cdf0e10cSrcweir if( !mrViewForwarder->GetSelection( aSelection ) ) 1258*cdf0e10cSrcweir return sal_False; 1259*cdf0e10cSrcweir 1260*cdf0e10cSrcweir SvxAccessibleTextIndex aStartIndex; 1261*cdf0e10cSrcweir SvxAccessibleTextIndex aEndIndex; 1262*cdf0e10cSrcweir 1263*cdf0e10cSrcweir aStartIndex.SetEEIndex( aSelection.nStartPara, aSelection.nStartPos, *mrTextForwarder ); 1264*cdf0e10cSrcweir aEndIndex.SetEEIndex( aSelection.nEndPara, aSelection.nEndPos, *mrTextForwarder ); 1265*cdf0e10cSrcweir 1266*cdf0e10cSrcweir DBG_ASSERT(aStartIndex.GetIndex() >= 0 && aStartIndex.GetIndex() <= USHRT_MAX && 1267*cdf0e10cSrcweir aEndIndex.GetIndex() >= 0 && aEndIndex.GetIndex() <= USHRT_MAX, 1268*cdf0e10cSrcweir "SvxAccessibleTextEditViewAdapter::GetSelection: index value overflow"); 1269*cdf0e10cSrcweir 1270*cdf0e10cSrcweir rSel = ESelection( aStartIndex.GetParagraph(), static_cast< sal_uInt16 > (aStartIndex.GetIndex()), 1271*cdf0e10cSrcweir aEndIndex.GetParagraph(), static_cast< sal_uInt16 > (aEndIndex.GetIndex()) ); 1272*cdf0e10cSrcweir 1273*cdf0e10cSrcweir return sal_True; 1274*cdf0e10cSrcweir } 1275*cdf0e10cSrcweir 1276*cdf0e10cSrcweir sal_Bool SvxAccessibleTextEditViewAdapter::SetSelection( const ESelection& rSel ) 1277*cdf0e10cSrcweir { 1278*cdf0e10cSrcweir DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder"); 1279*cdf0e10cSrcweir 1280*cdf0e10cSrcweir SvxAccessibleTextIndex aStartIndex; 1281*cdf0e10cSrcweir SvxAccessibleTextIndex aEndIndex; 1282*cdf0e10cSrcweir 1283*cdf0e10cSrcweir aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *mrTextForwarder ); 1284*cdf0e10cSrcweir aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *mrTextForwarder ); 1285*cdf0e10cSrcweir 1286*cdf0e10cSrcweir return mrViewForwarder->SetSelection( MakeEESelection(aStartIndex, aEndIndex) ); 1287*cdf0e10cSrcweir } 1288*cdf0e10cSrcweir 1289*cdf0e10cSrcweir sal_Bool SvxAccessibleTextEditViewAdapter::Copy() 1290*cdf0e10cSrcweir { 1291*cdf0e10cSrcweir DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder"); 1292*cdf0e10cSrcweir 1293*cdf0e10cSrcweir return mrViewForwarder->Copy(); 1294*cdf0e10cSrcweir } 1295*cdf0e10cSrcweir 1296*cdf0e10cSrcweir sal_Bool SvxAccessibleTextEditViewAdapter::Cut() 1297*cdf0e10cSrcweir { 1298*cdf0e10cSrcweir DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder"); 1299*cdf0e10cSrcweir 1300*cdf0e10cSrcweir return mrViewForwarder->Cut(); 1301*cdf0e10cSrcweir } 1302*cdf0e10cSrcweir 1303*cdf0e10cSrcweir sal_Bool SvxAccessibleTextEditViewAdapter::Paste() 1304*cdf0e10cSrcweir { 1305*cdf0e10cSrcweir DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder"); 1306*cdf0e10cSrcweir 1307*cdf0e10cSrcweir return mrViewForwarder->Paste(); 1308*cdf0e10cSrcweir } 1309*cdf0e10cSrcweir 1310*cdf0e10cSrcweir void SvxAccessibleTextEditViewAdapter::SetForwarder( SvxEditViewForwarder& rForwarder, 1311*cdf0e10cSrcweir SvxAccessibleTextAdapter& rTextForwarder ) 1312*cdf0e10cSrcweir { 1313*cdf0e10cSrcweir mrViewForwarder = &rForwarder; 1314*cdf0e10cSrcweir mrTextForwarder = &rTextForwarder; 1315*cdf0e10cSrcweir } 1316*cdf0e10cSrcweir 1317