LCOV - code coverage report
Current view: top level - editeng/source/uno - unoedprx.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 204 489 41.7 %
Date: 2014-11-03 Functions: 52 102 51.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10