Bump for 3.6-28
[LibreOffice.git] / editeng / source / uno / unoedprx.cxx
blobdcce120e4fbc3c7ae77620c49deadcd348611328
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 //------------------------------------------------------------------------
32 // Global header
34 //------------------------------------------------------------------------
36 #include <limits.h>
37 #include <vector>
38 #include <algorithm>
39 #include <osl/mutex.hxx>
40 #include <vcl/window.hxx>
41 #include <vcl/svapp.hxx>
42 #include <com/sun/star/uno/Any.hxx>
43 #include <com/sun/star/uno/Reference.hxx>
45 //------------------------------------------------------------------------
47 // Project-local header
49 //------------------------------------------------------------------------
50 #include "editeng/unoedprx.hxx"
51 #include <editeng/unotext.hxx>
52 #include <editeng/unoedhlp.hxx>
53 #include <editeng/editdata.hxx>
54 #include <editeng/editeng.hxx>
55 #include <editeng/editview.hxx>
56 #include <editeng/AccessibleStringWrap.hxx>
57 #include <editeng/outliner.hxx>
59 using namespace ::com::sun::star;
62 class SvxAccessibleTextIndex
64 public:
65 SvxAccessibleTextIndex() :
66 mnPara(0),
67 mnIndex(0),
68 mnEEIndex(0),
69 mnFieldOffset(0),
70 mnFieldLen(0),
71 mbInField(sal_False),
72 mnBulletOffset(0),
73 mnBulletLen(0),
74 mbInBullet(sal_False) {};
75 ~SvxAccessibleTextIndex() {};
77 // Get/Set current paragraph
78 void SetParagraph( sal_uInt16 nPara )
80 mnPara = nPara;
82 sal_uInt16 GetParagraph() const { return mnPara; }
84 /** Set the index in the UAA semantic
86 @param nIndex
87 The index from the UA API (fields and bullets are expanded)
89 @param rTF
90 The text forwarder to use in the calculations
92 void SetIndex( sal_Int32 nIndex, const SvxTextForwarder& rTF );
93 void SetIndex( sal_uInt16 nPara, sal_Int32 nIndex, const SvxTextForwarder& rTF ) { SetParagraph(nPara); SetIndex(nIndex, rTF); }
94 sal_Int32 GetIndex() const { return mnIndex; }
96 /** Set the index in the edit engine semantic
98 Update the object state to reflect the given index position in
99 EditEngine/Outliner index values
101 @param nEEIndex
102 The index from the edit engine (fields span exactly one index increment)
104 @param rTF
105 The text forwarder to use in the calculations
107 void SetEEIndex( sal_uInt16 nEEIndex, const SvxTextForwarder& rTF );
108 void SetEEIndex( sal_uInt16 nPara, sal_uInt16 nEEIndex, const SvxTextForwarder& rTF ) { SetParagraph(nPara); SetEEIndex(nEEIndex, rTF); }
109 sal_uInt16 GetEEIndex() const;
111 void SetFieldOffset( sal_Int32 nOffset, sal_Int32 nLen ) { mnFieldOffset = nOffset; mnFieldLen = nLen; }
112 sal_Int32 GetFieldOffset() const { return mnFieldOffset; }
113 sal_Int32 GetFieldLen() const { return mnFieldLen; }
114 void AreInField( sal_Bool bInField = sal_True ) { mbInField = bInField; }
115 sal_Bool InField() const { return mbInField; }
117 void SetBulletOffset( sal_Int32 nOffset, sal_Int32 nLen ) { mnBulletOffset = nOffset; mnBulletLen = nLen; }
118 sal_Int32 GetBulletOffset() const { return mnBulletOffset; }
119 sal_Int32 GetBulletLen() const { return mnBulletLen; }
120 void AreInBullet( sal_Bool bInBullet = sal_True ) { mbInBullet = bInBullet; }
121 sal_Bool InBullet() const { return mbInBullet; }
123 /// returns false if the given range is non-editable (e.g. contains bullets or _parts_ of fields)
124 sal_Bool IsEditableRange( const SvxAccessibleTextIndex& rEnd ) const;
126 private:
127 sal_uInt16 mnPara;
128 sal_Int32 mnIndex;
129 sal_Int32 mnEEIndex;
130 sal_Int32 mnFieldOffset;
131 sal_Int32 mnFieldLen;
132 sal_Bool mbInField;
133 sal_Int32 mnBulletOffset;
134 sal_Int32 mnBulletLen;
135 sal_Bool mbInBullet;
138 ESelection MakeEESelection( const SvxAccessibleTextIndex& rStart, const SvxAccessibleTextIndex& rEnd )
140 // deal with field special case: to really get a field contained
141 // within a selection, the start index must be before or on the
142 // field, the end index after it.
144 // The SvxAccessibleTextIndex.GetEEIndex method gives the index on
145 // the field, as long the input index is on the field. Thus,
146 // correction necessary for the end index
148 // Therefore, for _ranges_, if part of the field is touched, all
149 // of the field must be selected
150 if( rStart.GetParagraph() <= rEnd.GetParagraph() ||
151 (rStart.GetParagraph() == rEnd.GetParagraph() &&
152 rStart.GetEEIndex() <= rEnd.GetEEIndex()) )
154 if( rEnd.InField() && rEnd.GetFieldOffset() )
155 return ESelection( rStart.GetParagraph(), rStart.GetEEIndex(),
156 rEnd.GetParagraph(), rEnd.GetEEIndex()+1 );
158 else if( rStart.GetParagraph() > rEnd.GetParagraph() ||
159 (rStart.GetParagraph() == rEnd.GetParagraph() &&
160 rStart.GetEEIndex() > rEnd.GetEEIndex()) )
162 if( rStart.InField() && rStart.GetFieldOffset() )
163 return ESelection( rStart.GetParagraph(), rStart.GetEEIndex()+1,
164 rEnd.GetParagraph(), rEnd.GetEEIndex() );
167 return ESelection( rStart.GetParagraph(), rStart.GetEEIndex(),
168 rEnd.GetParagraph(), rEnd.GetEEIndex() );
171 ESelection MakeEESelection( const SvxAccessibleTextIndex& rIndex )
173 return ESelection( rIndex.GetParagraph(), rIndex.GetEEIndex(),
174 rIndex.GetParagraph(), rIndex.GetEEIndex() + 1 );
177 sal_uInt16 SvxAccessibleTextIndex::GetEEIndex() const
179 DBG_ASSERT(mnEEIndex >= 0 && mnEEIndex <= USHRT_MAX,
180 "SvxAccessibleTextIndex::GetEEIndex: index value overflow");
182 return static_cast< sal_uInt16 > (mnEEIndex);
185 void SvxAccessibleTextIndex::SetEEIndex( sal_uInt16 nEEIndex, const SvxTextForwarder& rTF )
187 // reset
188 mnFieldOffset = 0;
189 mbInField = sal_False;
190 mnFieldLen = 0;
191 mnBulletOffset = 0;
192 mbInBullet = sal_False;
193 mnBulletLen = 0;
195 // set known values
196 mnEEIndex = nEEIndex;
198 // calculate unknowns
199 sal_uInt16 nCurrField, nFieldCount = rTF.GetFieldCount( GetParagraph() );
201 mnIndex = nEEIndex;
203 EBulletInfo aBulletInfo = rTF.GetBulletInfo( GetParagraph() );
205 // any text bullets?
206 if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND &&
207 aBulletInfo.bVisible &&
208 aBulletInfo.nType != SVX_NUM_BITMAP )
210 mnIndex += aBulletInfo.aText.Len();
213 for( nCurrField=0; nCurrField < nFieldCount; ++nCurrField )
215 EFieldInfo aFieldInfo( rTF.GetFieldInfo( GetParagraph(), nCurrField ) );
217 if( aFieldInfo.aPosition.nIndex > nEEIndex )
218 break;
220 if( aFieldInfo.aPosition.nIndex == nEEIndex )
222 AreInField();
223 break;
226 // #106010#
227 mnIndex += ::std::max(aFieldInfo.aCurrentText.Len()-1, 0);
231 void SvxAccessibleTextIndex::SetIndex( sal_Int32 nIndex, const SvxTextForwarder& rTF )
233 // reset
234 mnFieldOffset = 0;
235 mbInField = sal_False;
236 mnFieldLen = 0;
237 mnBulletOffset = 0;
238 mbInBullet = sal_False;
239 mnBulletLen = 0;
241 // set known values
242 mnIndex = nIndex;
244 // calculate unknowns
245 sal_uInt16 nCurrField, nFieldCount = rTF.GetFieldCount( GetParagraph() );
247 DBG_ASSERT(nIndex >= 0 && nIndex <= USHRT_MAX,
248 "SvxAccessibleTextIndex::SetIndex: index value overflow");
250 mnEEIndex = nIndex;
252 EBulletInfo aBulletInfo = rTF.GetBulletInfo( GetParagraph() );
254 // any text bullets?
255 if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND &&
256 aBulletInfo.bVisible &&
257 aBulletInfo.nType != SVX_NUM_BITMAP )
259 sal_Int32 nBulletLen = aBulletInfo.aText.Len();
261 if( nIndex < nBulletLen )
263 AreInBullet();
264 SetBulletOffset( nIndex, nBulletLen );
265 mnEEIndex = 0;
266 return;
269 mnEEIndex = mnEEIndex - nBulletLen;
272 for( nCurrField=0; nCurrField < nFieldCount; ++nCurrField )
274 EFieldInfo aFieldInfo( rTF.GetFieldInfo( GetParagraph(), nCurrField ) );
276 // we're before a field
277 if( aFieldInfo.aPosition.nIndex > mnEEIndex )
278 break;
280 // #106010#
281 mnEEIndex -= ::std::max(aFieldInfo.aCurrentText.Len()-1, 0);
283 // we're within a field
284 if( aFieldInfo.aPosition.nIndex >= mnEEIndex )
286 AreInField();
287 SetFieldOffset( ::std::max(aFieldInfo.aCurrentText.Len()-1, 0) - (aFieldInfo.aPosition.nIndex - mnEEIndex),
288 aFieldInfo.aCurrentText.Len() );
289 mnEEIndex = aFieldInfo.aPosition.nIndex ;
290 break;
295 sal_Bool SvxAccessibleTextIndex::IsEditableRange( const SvxAccessibleTextIndex& rEnd ) const
297 if( GetIndex() > rEnd.GetIndex() )
298 return rEnd.IsEditableRange( *this );
300 if( InBullet() || rEnd.InBullet() )
301 return sal_False;
303 if( InField() && GetFieldOffset() )
304 return sal_False; // within field
306 if( rEnd.InField() && rEnd.GetFieldOffset() >= rEnd.GetFieldLen() - 1 )
307 return sal_False; // within field
309 return sal_True;
312 //---------------------------------------------------------------------------------
314 SvxEditSourceAdapter::SvxEditSourceAdapter() : mbEditSourceValid( sal_False )
318 SvxEditSourceAdapter::~SvxEditSourceAdapter()
322 SvxEditSource* SvxEditSourceAdapter::Clone() const
324 if( mbEditSourceValid && mpAdaptee.get() )
326 SAL_WNODEPRECATED_DECLARATIONS_PUSH
327 ::std::auto_ptr< SvxEditSource > pClonedAdaptee( mpAdaptee->Clone() );
328 SAL_WNODEPRECATED_DECLARATIONS_POP
330 if( pClonedAdaptee.get() )
332 SvxEditSourceAdapter* pClone = new SvxEditSourceAdapter();
334 if( pClone )
336 pClone->SetEditSource( pClonedAdaptee );
337 return pClone;
342 return NULL;
345 SvxAccessibleTextAdapter* SvxEditSourceAdapter::GetTextForwarderAdapter()
347 if( mbEditSourceValid && mpAdaptee.get() )
349 SvxTextForwarder* pTextForwarder = mpAdaptee->GetTextForwarder();
351 if( pTextForwarder )
353 maTextAdapter.SetForwarder(*pTextForwarder);
355 return &maTextAdapter;
359 return NULL;
362 SvxTextForwarder* SvxEditSourceAdapter::GetTextForwarder()
364 return GetTextForwarderAdapter();
367 SvxViewForwarder* SvxEditSourceAdapter::GetViewForwarder()
369 if( mbEditSourceValid && mpAdaptee.get() )
370 return mpAdaptee->GetViewForwarder();
372 return NULL;
375 SvxAccessibleTextEditViewAdapter* SvxEditSourceAdapter::GetEditViewForwarderAdapter( sal_Bool bCreate )
377 if( mbEditSourceValid && mpAdaptee.get() )
379 SvxEditViewForwarder* pEditViewForwarder = mpAdaptee->GetEditViewForwarder(bCreate);
381 if( pEditViewForwarder )
383 SvxAccessibleTextAdapter* pTextAdapter = GetTextForwarderAdapter();
385 if( pTextAdapter )
387 maEditViewAdapter.SetForwarder(*pEditViewForwarder, *pTextAdapter);
389 return &maEditViewAdapter;
394 return NULL;
397 SvxEditViewForwarder* SvxEditSourceAdapter::GetEditViewForwarder( sal_Bool bCreate )
399 return GetEditViewForwarderAdapter( bCreate );
402 void SvxEditSourceAdapter::UpdateData()
404 if( mbEditSourceValid && mpAdaptee.get() )
405 mpAdaptee->UpdateData();
408 SfxBroadcaster& SvxEditSourceAdapter::GetBroadcaster() const
410 if( mbEditSourceValid && mpAdaptee.get() )
411 return mpAdaptee->GetBroadcaster();
413 return maDummyBroadcaster;
416 SAL_WNODEPRECATED_DECLARATIONS_PUSH
417 void SvxEditSourceAdapter::SetEditSource( ::std::auto_ptr< SvxEditSource > pAdaptee )
419 if( pAdaptee.get() )
421 mpAdaptee = pAdaptee;
422 mbEditSourceValid = sal_True;
424 else
426 // do a lazy delete (prevents us from deleting the broadcaster
427 // from within a broadcast in
428 // AccessibleTextHelper_Impl::Notify)
429 mbEditSourceValid = sal_False;
432 SAL_WNODEPRECATED_DECLARATIONS_POP
434 sal_Bool SvxEditSourceAdapter::IsValid() const
436 return mbEditSourceValid;
440 //--------------------------------------------------------------------------------------
442 SvxAccessibleTextAdapter::SvxAccessibleTextAdapter() : mrTextForwarder( NULL )
446 SvxAccessibleTextAdapter::~SvxAccessibleTextAdapter()
450 sal_uInt16 SvxAccessibleTextAdapter::GetParagraphCount() const
452 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
454 return mrTextForwarder->GetParagraphCount();
457 sal_uInt16 SvxAccessibleTextAdapter::GetTextLen( sal_uInt16 nParagraph ) const
459 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
461 SvxAccessibleTextIndex aIndex;
462 aIndex.SetEEIndex( nParagraph, mrTextForwarder->GetTextLen( nParagraph ), *this );
464 return static_cast< sal_uInt16 >(aIndex.GetIndex());
467 String SvxAccessibleTextAdapter::GetText( const ESelection& rSel ) const
469 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
471 SvxAccessibleTextIndex aStartIndex;
472 SvxAccessibleTextIndex aEndIndex;
474 aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
475 aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
477 // normalize selection
478 if( rSel.nStartPara > rSel.nEndPara ||
479 (rSel.nStartPara == rSel.nEndPara && rSel.nStartPos > rSel.nEndPos) )
481 ::std::swap( aStartIndex, aEndIndex );
484 String sStr = mrTextForwarder->GetText( MakeEESelection(aStartIndex, aEndIndex) );
486 // trim field text, if necessary
487 if( aStartIndex.InField() )
489 DBG_ASSERT(aStartIndex.GetFieldOffset() >= 0 &&
490 aStartIndex.GetFieldOffset() <= USHRT_MAX,
491 "SvxAccessibleTextIndex::GetText: index value overflow");
493 sStr.Erase(0, static_cast< sal_uInt16 > (aStartIndex.GetFieldOffset()) );
495 if( aEndIndex.InField() && aEndIndex.GetFieldOffset() )
497 DBG_ASSERT(sStr.Len() - (aEndIndex.GetFieldLen() - aEndIndex.GetFieldOffset()) >= 0 &&
498 sStr.Len() - (aEndIndex.GetFieldLen() - aEndIndex.GetFieldOffset()) <= USHRT_MAX,
499 "SvxAccessibleTextIndex::GetText: index value overflow");
501 sStr = sStr.Copy(0, static_cast< sal_uInt16 > (sStr.Len() - (aEndIndex.GetFieldLen() - aEndIndex.GetFieldOffset())) );
504 EBulletInfo aBulletInfo1 = GetBulletInfo( static_cast< sal_uInt16 >(aStartIndex.GetParagraph()) );
505 EBulletInfo aBulletInfo2 = GetBulletInfo( static_cast< sal_uInt16 >(aEndIndex.GetParagraph()) );
507 if( aStartIndex.InBullet() )
509 // prepend leading bullet
510 String sBullet = aBulletInfo1.aText;
512 DBG_ASSERT(aStartIndex.GetBulletOffset() >= 0 &&
513 aStartIndex.GetBulletOffset() <= USHRT_MAX,
514 "SvxAccessibleTextIndex::GetText: index value overflow");
516 sBullet.Erase(0, static_cast< sal_uInt16 > (aStartIndex.GetBulletOffset()) );
518 sBullet += sStr;
519 sStr = sBullet;
522 if( aEndIndex.InBullet() )
524 // append trailing bullet
525 sStr += aBulletInfo2.aText;
527 DBG_ASSERT(sStr.Len() - (aEndIndex.GetBulletLen() - aEndIndex.GetBulletOffset()) >= 0 &&
528 sStr.Len() - (aEndIndex.GetBulletLen() - aEndIndex.GetBulletOffset()) <= USHRT_MAX,
529 "SvxAccessibleTextIndex::GetText: index value overflow");
531 sStr = sStr.Copy(0, static_cast< sal_uInt16 > (sStr.Len() - (aEndIndex.GetBulletLen() - aEndIndex.GetBulletOffset())) );
533 else if( aStartIndex.GetParagraph() != aEndIndex.GetParagraph() &&
534 HaveTextBullet( aEndIndex.GetParagraph() ) )
536 String sBullet = aBulletInfo2.aText;
538 DBG_ASSERT(sBullet.Len() - (aEndIndex.GetBulletLen() - aEndIndex.GetBulletOffset()) >= 0 &&
539 sBullet.Len() - (aEndIndex.GetBulletLen() - aEndIndex.GetBulletOffset()) <= USHRT_MAX,
540 "SvxAccessibleTextIndex::GetText: index value overflow");
542 sBullet = sBullet.Copy(0, static_cast< sal_uInt16 > (sBullet.Len() - (aEndIndex.GetBulletLen() - aEndIndex.GetBulletOffset())) );
544 // insert bullet
545 sStr.Insert( sBullet,
546 static_cast< sal_uInt16 > (GetTextLen(aStartIndex.GetParagraph()) - aStartIndex.GetIndex()) );
549 return sStr;
552 SfxItemSet SvxAccessibleTextAdapter::GetAttribs( const ESelection& rSel, sal_Bool bOnlyHardAttrib ) const
554 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
556 SvxAccessibleTextIndex aStartIndex;
557 SvxAccessibleTextIndex aEndIndex;
559 aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
560 aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
562 return mrTextForwarder->GetAttribs( MakeEESelection(aStartIndex, aEndIndex),
563 bOnlyHardAttrib );
566 SfxItemSet SvxAccessibleTextAdapter::GetParaAttribs( sal_uInt16 nPara ) const
568 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
570 return mrTextForwarder->GetParaAttribs( nPara );
573 void SvxAccessibleTextAdapter::SetParaAttribs( sal_uInt16 nPara, const SfxItemSet& rSet )
575 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
577 mrTextForwarder->SetParaAttribs( nPara, rSet );
580 void SvxAccessibleTextAdapter::RemoveAttribs( const ESelection& , sal_Bool , sal_uInt16 )
582 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
585 void SvxAccessibleTextAdapter::GetPortions( sal_uInt16 nPara, std::vector<sal_uInt16>& rList ) const
587 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
589 mrTextForwarder->GetPortions( nPara, rList );
592 sal_uInt16 SvxAccessibleTextAdapter::GetItemState( const ESelection& rSel, sal_uInt16 nWhich ) const
594 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
596 SvxAccessibleTextIndex aStartIndex;
597 SvxAccessibleTextIndex aEndIndex;
599 aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
600 aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
602 return mrTextForwarder->GetItemState( MakeEESelection(aStartIndex, aEndIndex),
603 nWhich );
606 sal_uInt16 SvxAccessibleTextAdapter::GetItemState( sal_uInt16 nPara, sal_uInt16 nWhich ) const
608 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
610 return mrTextForwarder->GetItemState( nPara, nWhich );
613 void SvxAccessibleTextAdapter::QuickInsertText( const String& rText, const ESelection& rSel )
615 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
617 SvxAccessibleTextIndex aStartIndex;
618 SvxAccessibleTextIndex aEndIndex;
620 aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
621 aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
623 mrTextForwarder->QuickInsertText( rText,
624 MakeEESelection(aStartIndex, aEndIndex) );
627 void SvxAccessibleTextAdapter::QuickInsertField( const SvxFieldItem& rFld, const ESelection& rSel )
629 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
631 SvxAccessibleTextIndex aStartIndex;
632 SvxAccessibleTextIndex aEndIndex;
634 aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
635 aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
637 mrTextForwarder->QuickInsertField( rFld,
638 MakeEESelection(aStartIndex, aEndIndex) );
641 void SvxAccessibleTextAdapter::QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel )
643 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
645 SvxAccessibleTextIndex aStartIndex;
646 SvxAccessibleTextIndex aEndIndex;
648 aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
649 aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
651 mrTextForwarder->QuickSetAttribs( rSet,
652 MakeEESelection(aStartIndex, aEndIndex) );
655 void SvxAccessibleTextAdapter::QuickInsertLineBreak( const ESelection& rSel )
657 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
659 SvxAccessibleTextIndex aStartIndex;
660 SvxAccessibleTextIndex aEndIndex;
662 aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
663 aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
665 mrTextForwarder->QuickInsertLineBreak( MakeEESelection(aStartIndex, aEndIndex) );
668 SfxItemPool* SvxAccessibleTextAdapter::GetPool() const
670 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
672 return mrTextForwarder->GetPool();
675 XubString SvxAccessibleTextAdapter::CalcFieldValue( const SvxFieldItem& rField, sal_uInt16 nPara, sal_uInt16 nPos, Color*& rpTxtColor, Color*& rpFldColor )
677 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
679 return mrTextForwarder->CalcFieldValue( rField, nPara, nPos, rpTxtColor, rpFldColor );
682 void SvxAccessibleTextAdapter::FieldClicked( const SvxFieldItem& rField, sal_uInt16 nPara, xub_StrLen nPos )
684 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
686 mrTextForwarder->FieldClicked( rField, nPara, nPos );
689 sal_Int32 SvxAccessibleTextAdapter::CalcLogicalIndex( sal_uInt16 nPara, sal_uInt16 nEEIndex )
691 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
693 SvxAccessibleTextIndex aIndex;
694 aIndex.SetEEIndex(nPara, nEEIndex, *mrTextForwarder);
695 return aIndex.GetIndex();
698 sal_uInt16 SvxAccessibleTextAdapter::CalcEditEngineIndex( sal_uInt16 nPara, sal_Int32 nLogicalIndex )
700 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
702 SvxAccessibleTextIndex aIndex;
703 aIndex.SetIndex(nPara, nLogicalIndex, *mrTextForwarder);
704 return aIndex.GetEEIndex();
709 sal_Bool SvxAccessibleTextAdapter::IsValid() const
711 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
713 if( mrTextForwarder )
714 return mrTextForwarder->IsValid();
715 else
716 return sal_False;
719 LanguageType SvxAccessibleTextAdapter::GetLanguage( sal_uInt16 nPara, sal_uInt16 nPos ) const
721 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
723 SvxAccessibleTextIndex aIndex;
725 aIndex.SetIndex( nPara, nPos, *this );
727 return mrTextForwarder->GetLanguage( nPara, aIndex.GetEEIndex() );
730 sal_uInt16 SvxAccessibleTextAdapter::GetFieldCount( sal_uInt16 nPara ) const
732 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
734 return mrTextForwarder->GetFieldCount( nPara );
737 EFieldInfo SvxAccessibleTextAdapter::GetFieldInfo( sal_uInt16 nPara, sal_uInt16 nField ) const
739 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
741 return mrTextForwarder->GetFieldInfo( nPara, nField );
744 EBulletInfo SvxAccessibleTextAdapter::GetBulletInfo( sal_uInt16 nPara ) const
746 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
748 return mrTextForwarder->GetBulletInfo( nPara );
751 Rectangle SvxAccessibleTextAdapter::GetCharBounds( sal_uInt16 nPara, sal_uInt16 nIndex ) const
753 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
755 SvxAccessibleTextIndex aIndex;
756 aIndex.SetIndex( nPara, nIndex, *this );
758 // preset if anything goes wrong below
759 // n-th char in GetParagraphIndex's paragraph
760 Rectangle aRect = mrTextForwarder->GetCharBounds( nPara, static_cast< sal_uInt16 >( aIndex.GetEEIndex() ) );
762 if( aIndex.InBullet() )
764 EBulletInfo aBulletInfo = GetBulletInfo( nPara );
766 OutputDevice* pOutDev = GetRefDevice();
768 DBG_ASSERT(pOutDev!=NULL, "SvxAccessibleTextAdapter::GetCharBounds: No ref device");
770 // preset if anything goes wrong below
771 aRect = aBulletInfo.aBounds; // better than nothing
772 if( pOutDev )
774 AccessibleStringWrap aStringWrap( *pOutDev, aBulletInfo.aFont, aBulletInfo.aText );
776 if( aStringWrap.GetCharacterBounds( aIndex.GetBulletOffset(), aRect ) )
777 aRect.Move( aBulletInfo.aBounds.Left(), aBulletInfo.aBounds.Top() );
780 else
782 // handle field content manually
783 if( aIndex.InField() )
785 OutputDevice* pOutDev = GetRefDevice();
787 DBG_ASSERT(pOutDev!=NULL, "SvxAccessibleTextAdapter::GetCharBounds: No ref device");
789 if( pOutDev )
791 ESelection aSel = MakeEESelection( aIndex );
793 SvxFont aFont = EditEngine::CreateSvxFontFromItemSet( mrTextForwarder->GetAttribs( aSel ) );
794 AccessibleStringWrap aStringWrap( *pOutDev,
795 aFont,
796 mrTextForwarder->GetText( aSel ) );
798 Rectangle aStartRect = mrTextForwarder->GetCharBounds( nPara, static_cast< sal_uInt16 >( aIndex.GetEEIndex() ) );
800 if( !aStringWrap.GetCharacterBounds( aIndex.GetFieldOffset(), aRect ) )
801 aRect = aStartRect;
802 else
803 aRect.Move( aStartRect.Left(), aStartRect.Top() );
808 return aRect;
811 Rectangle SvxAccessibleTextAdapter::GetParaBounds( sal_uInt16 nPara ) const
813 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
815 EBulletInfo aBulletInfo = GetBulletInfo( nPara );
817 if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND &&
818 aBulletInfo.bVisible &&
819 aBulletInfo.nType != SVX_NUM_BITMAP )
821 // include bullet in para bounding box
822 Rectangle aRect( mrTextForwarder->GetParaBounds( nPara ) );
824 aRect.Union( aBulletInfo.aBounds );
826 return aRect;
829 return mrTextForwarder->GetParaBounds( nPara );
832 MapMode SvxAccessibleTextAdapter::GetMapMode() const
834 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
836 return mrTextForwarder->GetMapMode();
839 OutputDevice* SvxAccessibleTextAdapter::GetRefDevice() const
841 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
843 return mrTextForwarder->GetRefDevice();
846 sal_Bool SvxAccessibleTextAdapter::GetIndexAtPoint( const Point& rPoint, sal_uInt16& nPara, sal_uInt16& nIndex ) const
848 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
850 if( !mrTextForwarder->GetIndexAtPoint( rPoint, nPara, nIndex ) )
851 return sal_False;
853 SvxAccessibleTextIndex aIndex;
854 aIndex.SetEEIndex(nPara, nIndex, *this);
856 DBG_ASSERT(aIndex.GetIndex() >= 0 && aIndex.GetIndex() <= USHRT_MAX,
857 "SvxAccessibleTextIndex::SetIndex: index value overflow");
859 nIndex = static_cast< sal_uInt16 > (aIndex.GetIndex());
861 EBulletInfo aBulletInfo = GetBulletInfo( nPara );
863 // any text bullets?
864 if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND &&
865 aBulletInfo.bVisible &&
866 aBulletInfo.nType != SVX_NUM_BITMAP )
868 if( aBulletInfo.aBounds.IsInside( rPoint) )
870 OutputDevice* pOutDev = GetRefDevice();
872 DBG_ASSERT(pOutDev!=NULL, "SvxAccessibleTextAdapter::GetIndexAtPoint: No ref device");
874 if( !pOutDev )
875 return sal_False;
877 AccessibleStringWrap aStringWrap( *pOutDev, aBulletInfo.aFont, aBulletInfo.aText );
879 Point aPoint = rPoint;
880 aPoint.Move( -aBulletInfo.aBounds.Left(), -aBulletInfo.aBounds.Top() );
882 DBG_ASSERT(aStringWrap.GetIndexAtPoint( aPoint ) >= 0 &&
883 aStringWrap.GetIndexAtPoint( aPoint ) <= USHRT_MAX,
884 "SvxAccessibleTextIndex::SetIndex: index value overflow");
886 nIndex = static_cast< sal_uInt16 > (aStringWrap.GetIndexAtPoint( aPoint ));
887 return sal_True;
891 if( aIndex.InField() )
893 OutputDevice* pOutDev = GetRefDevice();
895 DBG_ASSERT(pOutDev!=NULL, "SvxAccessibleTextAdapter::GetIndexAtPoint: No ref device");
897 if( !pOutDev )
898 return sal_False;
900 ESelection aSelection = MakeEESelection( aIndex );
901 SvxFont aFont = EditEngine::CreateSvxFontFromItemSet( mrTextForwarder->GetAttribs( aSelection ) );
902 AccessibleStringWrap aStringWrap( *pOutDev,
903 aFont,
904 mrTextForwarder->GetText( aSelection ) );
906 Rectangle aRect = mrTextForwarder->GetCharBounds( nPara, aIndex.GetEEIndex() );
907 Point aPoint = rPoint;
908 aPoint.Move( -aRect.Left(), -aRect.Top() );
910 DBG_ASSERT(aIndex.GetIndex() + aStringWrap.GetIndexAtPoint( rPoint ) >= 0 &&
911 aIndex.GetIndex() + aStringWrap.GetIndexAtPoint( rPoint ) <= USHRT_MAX,
912 "SvxAccessibleTextIndex::SetIndex: index value overflow");
914 nIndex = static_cast< sal_uInt16 >(aIndex.GetIndex() + aStringWrap.GetIndexAtPoint( aPoint ));
915 return sal_True;
918 return sal_True;
921 sal_Bool SvxAccessibleTextAdapter::GetWordIndices( sal_uInt16 nPara, sal_uInt16 nIndex, sal_uInt16& nStart, sal_uInt16& nEnd ) const
923 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
925 SvxAccessibleTextIndex aIndex;
926 aIndex.SetIndex(nPara, nIndex, *this);
927 nIndex = aIndex.GetEEIndex();
929 if( aIndex.InBullet() )
931 DBG_ASSERT(aIndex.GetBulletLen() >= 0 &&
932 aIndex.GetBulletLen() <= USHRT_MAX,
933 "SvxAccessibleTextIndex::SetIndex: index value overflow");
935 // always treat bullet as separate word
936 nStart = 0;
937 nEnd = static_cast< sal_uInt16 > (aIndex.GetBulletLen());
939 return sal_True;
942 if( aIndex.InField() )
944 DBG_ASSERT(aIndex.GetIndex() - aIndex.GetFieldOffset() >= 0 &&
945 aIndex.GetIndex() - aIndex.GetFieldOffset() <= USHRT_MAX &&
946 nStart + aIndex.GetFieldLen() >= 0 &&
947 nStart + aIndex.GetFieldLen() <= USHRT_MAX,
948 "SvxAccessibleTextIndex::SetIndex: index value overflow");
950 // always treat field as separate word
951 // TODO: to circumvent this, _we_ would have to do the break iterator stuff!
952 nStart = static_cast< sal_uInt16 > (aIndex.GetIndex() - aIndex.GetFieldOffset());
953 nEnd = static_cast< sal_uInt16 > (nStart + aIndex.GetFieldLen());
955 return sal_True;
958 if( !mrTextForwarder->GetWordIndices( nPara, nIndex, nStart, nEnd ) )
959 return sal_False;
961 aIndex.SetEEIndex( nPara, nStart, *this );
962 DBG_ASSERT(aIndex.GetIndex() >= 0 &&
963 aIndex.GetIndex() <= USHRT_MAX,
964 "SvxAccessibleTextIndex::SetIndex: index value overflow");
965 nStart = static_cast< sal_uInt16 > (aIndex.GetIndex());
967 aIndex.SetEEIndex( nPara, nEnd, *this );
968 DBG_ASSERT(aIndex.GetIndex() >= 0 &&
969 aIndex.GetIndex() <= USHRT_MAX,
970 "SvxAccessibleTextIndex::SetIndex: index value overflow");
971 nEnd = static_cast< sal_uInt16 > (aIndex.GetIndex());
973 return sal_True;
976 sal_Bool SvxAccessibleTextAdapter::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, sal_uInt16 nPara, sal_uInt16 nIndex ) const
978 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
980 SvxAccessibleTextIndex aIndex;
981 aIndex.SetIndex(nPara, nIndex, *this);
982 nIndex = aIndex.GetEEIndex();
984 if( aIndex.InBullet() )
986 DBG_ASSERT(aIndex.GetBulletLen() >= 0 &&
987 aIndex.GetBulletLen() <= USHRT_MAX,
988 "SvxAccessibleTextIndex::SetIndex: index value overflow");
990 // always treat bullet as distinct attribute
991 nStartIndex = 0;
992 nEndIndex = static_cast< sal_uInt16 > (aIndex.GetBulletLen());
994 return sal_True;
997 if( aIndex.InField() )
999 DBG_ASSERT(aIndex.GetIndex() - aIndex.GetFieldOffset() >= 0 &&
1000 aIndex.GetIndex() - aIndex.GetFieldOffset() <= USHRT_MAX,
1001 "SvxAccessibleTextIndex::SetIndex: index value overflow");
1003 // always treat field as distinct attribute
1004 nStartIndex = static_cast< sal_uInt16 > (aIndex.GetIndex() - aIndex.GetFieldOffset());
1005 nEndIndex = static_cast< sal_uInt16 > (nStartIndex + aIndex.GetFieldLen());
1007 return sal_True;
1010 if( !mrTextForwarder->GetAttributeRun( nStartIndex, nEndIndex, nPara, nIndex ) )
1011 return sal_False;
1013 aIndex.SetEEIndex( nPara, nStartIndex, *this );
1014 DBG_ASSERT(aIndex.GetIndex() >= 0 &&
1015 aIndex.GetIndex() <= USHRT_MAX,
1016 "SvxAccessibleTextIndex::SetIndex: index value overflow");
1017 nStartIndex = static_cast< sal_uInt16 > (aIndex.GetIndex());
1019 aIndex.SetEEIndex( nPara, nEndIndex, *this );
1020 DBG_ASSERT(aIndex.GetIndex() >= 0 &&
1021 aIndex.GetIndex() <= USHRT_MAX,
1022 "SvxAccessibleTextIndex::SetIndex: index value overflow");
1023 nEndIndex = static_cast< sal_uInt16 > (aIndex.GetIndex());
1025 return sal_True;
1028 sal_uInt16 SvxAccessibleTextAdapter::GetLineCount( sal_uInt16 nPara ) const
1030 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1032 return mrTextForwarder->GetLineCount( nPara );
1035 sal_uInt16 SvxAccessibleTextAdapter::GetLineLen( sal_uInt16 nPara, sal_uInt16 nLine ) const
1037 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1039 SvxAccessibleTextIndex aStartIndex;
1040 SvxAccessibleTextIndex aEndIndex;
1041 sal_uInt16 nCurrLine;
1042 sal_uInt16 nCurrIndex, nLastIndex;
1043 for( nCurrLine=0, nCurrIndex=0, nLastIndex=0; nCurrLine<=nLine; ++nCurrLine )
1045 nLastIndex = nCurrIndex;
1046 nCurrIndex =
1047 nCurrIndex + mrTextForwarder->GetLineLen( nPara, nCurrLine );
1050 aEndIndex.SetEEIndex( nPara, nCurrIndex, *this );
1051 if( nLine > 0 )
1053 aStartIndex.SetEEIndex( nPara, nLastIndex, *this );
1055 return static_cast< sal_uInt16 >(aEndIndex.GetIndex() - aStartIndex.GetIndex());
1057 else
1058 return static_cast< sal_uInt16 >(aEndIndex.GetIndex());
1061 void SvxAccessibleTextAdapter::GetLineBoundaries( /*out*/sal_uInt16 &rStart, /*out*/sal_uInt16 &rEnd, sal_uInt16 nParagraph, sal_uInt16 nLine ) const
1063 mrTextForwarder->GetLineBoundaries( rStart, rEnd, nParagraph, nLine );
1066 sal_uInt16 SvxAccessibleTextAdapter::GetLineNumberAtIndex( sal_uInt16 nPara, sal_uInt16 nIndex ) const
1068 return mrTextForwarder->GetLineNumberAtIndex( nPara, nIndex );
1071 sal_Bool SvxAccessibleTextAdapter::Delete( const ESelection& rSel )
1073 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1075 SvxAccessibleTextIndex aStartIndex;
1076 SvxAccessibleTextIndex aEndIndex;
1078 aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
1079 aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
1081 return mrTextForwarder->Delete( MakeEESelection(aStartIndex, aEndIndex ) );
1084 sal_Bool SvxAccessibleTextAdapter::InsertText( const String& rStr, const ESelection& rSel )
1086 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1088 SvxAccessibleTextIndex aStartIndex;
1089 SvxAccessibleTextIndex aEndIndex;
1091 aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
1092 aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
1094 return mrTextForwarder->InsertText( rStr, MakeEESelection(aStartIndex, aEndIndex) );
1097 sal_Bool SvxAccessibleTextAdapter::QuickFormatDoc( sal_Bool bFull )
1099 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1101 return mrTextForwarder->QuickFormatDoc( bFull );
1104 sal_Int16 SvxAccessibleTextAdapter::GetDepth( sal_uInt16 nPara ) const
1106 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1108 return mrTextForwarder->GetDepth( nPara );
1111 sal_Bool SvxAccessibleTextAdapter::SetDepth( sal_uInt16 nPara, sal_Int16 nNewDepth )
1113 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1115 return mrTextForwarder->SetDepth( nPara, nNewDepth );
1118 void SvxAccessibleTextAdapter::SetForwarder( SvxTextForwarder& rForwarder )
1120 mrTextForwarder = &rForwarder;
1123 sal_Bool SvxAccessibleTextAdapter::HaveImageBullet( sal_uInt16 nPara ) const
1125 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1127 EBulletInfo aBulletInfo = GetBulletInfo( nPara );
1129 if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND &&
1130 aBulletInfo.bVisible &&
1131 aBulletInfo.nType == SVX_NUM_BITMAP )
1133 return sal_True;
1135 else
1137 return sal_False;
1141 sal_Bool SvxAccessibleTextAdapter::HaveTextBullet( sal_uInt16 nPara ) const
1143 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1145 EBulletInfo aBulletInfo = GetBulletInfo( nPara );
1147 if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND &&
1148 aBulletInfo.bVisible &&
1149 aBulletInfo.nType != SVX_NUM_BITMAP )
1151 return sal_True;
1153 else
1155 return sal_False;
1159 sal_Bool SvxAccessibleTextAdapter::IsEditable( const ESelection& rSel )
1161 DBG_ASSERT(mrTextForwarder, "SvxAccessibleTextAdapter: no forwarder");
1163 SvxAccessibleTextIndex aStartIndex;
1164 SvxAccessibleTextIndex aEndIndex;
1166 aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *this );
1167 aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *this );
1169 // normalize selection
1170 if( rSel.nStartPara > rSel.nEndPara ||
1171 (rSel.nStartPara == rSel.nEndPara && rSel.nStartPos > rSel.nEndPos) )
1173 ::std::swap( aStartIndex, aEndIndex );
1176 return aStartIndex.IsEditableRange( aEndIndex );
1179 const SfxItemSet * SvxAccessibleTextAdapter::GetEmptyItemSetPtr()
1181 OSL_FAIL( "not implemented" );
1182 return 0;
1185 void SvxAccessibleTextAdapter::AppendParagraph()
1187 OSL_FAIL( "not implemented" );
1190 xub_StrLen SvxAccessibleTextAdapter::AppendTextPortion( sal_uInt16, const String &, const SfxItemSet & )
1192 OSL_FAIL( "not implemented" );
1193 return 0;
1195 void SvxAccessibleTextAdapter::CopyText(const SvxTextForwarder&)
1197 OSL_FAIL( "not implemented" );
1202 //---------------------------------------------------------------------------------------
1204 SvxAccessibleTextEditViewAdapter::SvxAccessibleTextEditViewAdapter()
1208 SvxAccessibleTextEditViewAdapter::~SvxAccessibleTextEditViewAdapter()
1212 sal_Bool SvxAccessibleTextEditViewAdapter::IsValid() const
1214 DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder");
1216 if( mrViewForwarder )
1217 return mrViewForwarder->IsValid();
1218 else
1219 return sal_False;
1222 Rectangle SvxAccessibleTextEditViewAdapter::GetVisArea() const
1224 DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder");
1226 return mrViewForwarder->GetVisArea();
1229 Point SvxAccessibleTextEditViewAdapter::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
1231 DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder");
1233 return mrViewForwarder->LogicToPixel(rPoint, rMapMode);
1236 Point SvxAccessibleTextEditViewAdapter::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
1238 DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder");
1240 return mrViewForwarder->PixelToLogic(rPoint, rMapMode);
1243 sal_Bool SvxAccessibleTextEditViewAdapter::GetSelection( ESelection& rSel ) const
1245 DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder");
1247 ESelection aSelection;
1249 if( !mrViewForwarder->GetSelection( aSelection ) )
1250 return sal_False;
1252 SvxAccessibleTextIndex aStartIndex;
1253 SvxAccessibleTextIndex aEndIndex;
1255 aStartIndex.SetEEIndex( aSelection.nStartPara, aSelection.nStartPos, *mrTextForwarder );
1256 aEndIndex.SetEEIndex( aSelection.nEndPara, aSelection.nEndPos, *mrTextForwarder );
1258 DBG_ASSERT(aStartIndex.GetIndex() >= 0 && aStartIndex.GetIndex() <= USHRT_MAX &&
1259 aEndIndex.GetIndex() >= 0 && aEndIndex.GetIndex() <= USHRT_MAX,
1260 "SvxAccessibleTextEditViewAdapter::GetSelection: index value overflow");
1262 rSel = ESelection( aStartIndex.GetParagraph(), static_cast< sal_uInt16 > (aStartIndex.GetIndex()),
1263 aEndIndex.GetParagraph(), static_cast< sal_uInt16 > (aEndIndex.GetIndex()) );
1265 return sal_True;
1268 sal_Bool SvxAccessibleTextEditViewAdapter::SetSelection( const ESelection& rSel )
1270 DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder");
1272 SvxAccessibleTextIndex aStartIndex;
1273 SvxAccessibleTextIndex aEndIndex;
1275 aStartIndex.SetIndex( rSel.nStartPara, rSel.nStartPos, *mrTextForwarder );
1276 aEndIndex.SetIndex( rSel.nEndPara, rSel.nEndPos, *mrTextForwarder );
1278 return mrViewForwarder->SetSelection( MakeEESelection(aStartIndex, aEndIndex) );
1281 sal_Bool SvxAccessibleTextEditViewAdapter::Copy()
1283 DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder");
1285 return mrViewForwarder->Copy();
1288 sal_Bool SvxAccessibleTextEditViewAdapter::Cut()
1290 DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder");
1292 return mrViewForwarder->Cut();
1295 sal_Bool SvxAccessibleTextEditViewAdapter::Paste()
1297 DBG_ASSERT(mrViewForwarder, "SvxAccessibleTextEditViewAdapter: no forwarder");
1299 return mrViewForwarder->Paste();
1302 void SvxAccessibleTextEditViewAdapter::SetForwarder( SvxEditViewForwarder& rForwarder,
1303 SvxAccessibleTextAdapter& rTextForwarder )
1305 mrViewForwarder = &rForwarder;
1306 mrTextForwarder = &rTextForwarder;
1309 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */