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

Generated by: LCOV version 1.11