LCOV - code coverage report
Current view: top level - libreoffice/editeng/source/accessibility - AccessibleEditableTextPara.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 849 0.0 %
Date: 2012-12-27 Functions: 0 101 0.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 <vector>
      29             : #include <algorithm>
      30             : #include <osl/mutex.hxx>
      31             : #include <vcl/window.hxx>
      32             : #include <vcl/svapp.hxx>
      33             : #include <editeng/flditem.hxx>
      34             : #include <com/sun/star/uno/Any.hxx>
      35             : #include <com/sun/star/uno/Reference.hxx>
      36             : #include <com/sun/star/awt/Point.hpp>
      37             : #include <com/sun/star/awt/Rectangle.hpp>
      38             : #include <com/sun/star/lang/DisposedException.hpp>
      39             : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      40             : #include <com/sun/star/accessibility/AccessibleTextType.hpp>
      41             : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      42             : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      43             : #include <comphelper/accessibleeventnotifier.hxx>
      44             : #include <comphelper/sequenceashashmap.hxx>
      45             : #include <unotools/accessiblestatesethelper.hxx>
      46             : #include <unotools/accessiblerelationsethelper.hxx>
      47             : #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
      48             : #include <vcl/unohelp.hxx>
      49             : #include <editeng/editeng.hxx>
      50             : #include <editeng/unoprnms.hxx>
      51             : #include <editeng/unoipset.hxx>
      52             : #include <editeng/outliner.hxx>
      53             : 
      54             : //------------------------------------------------------------------------
      55             : //
      56             : // Project-local header
      57             : //
      58             : //------------------------------------------------------------------------
      59             : 
      60             : #include <com/sun/star/beans/PropertyState.hpp>
      61             : 
      62             : //!!!#include <svx/unoshape.hxx>
      63             : //!!!#include <svx/dialmgr.hxx>
      64             : //!!!#include "accessibility.hrc"
      65             : 
      66             : #include <editeng/unolingu.hxx>
      67             : #include <editeng/unopracc.hxx>
      68             : #include "editeng/AccessibleEditableTextPara.hxx"
      69             : #include "AccessibleHyperlink.hxx"
      70             : 
      71             : #include <svtools/colorcfg.hxx>
      72             : 
      73             : 
      74             : using namespace ::com::sun::star;
      75             : using namespace ::com::sun::star::beans;
      76             : using namespace ::com::sun::star::accessibility;
      77             : 
      78             : 
      79             : //------------------------------------------------------------------------
      80             : //
      81             : // AccessibleEditableTextPara implementation
      82             : //
      83             : //------------------------------------------------------------------------
      84             : 
      85             : namespace accessibility
      86             : {
      87             : 
      88           0 :     const SvxItemPropertySet* ImplGetSvxCharAndParaPropertiesSet()
      89             :     {
      90             :         // PropertyMap for character and paragraph properties
      91             :         static const SfxItemPropertyMapEntry aPropMap[] =
      92             :         {
      93           0 :             SVX_UNOEDIT_CHAR_PROPERTIES,
      94           0 :             SVX_UNOEDIT_PARA_PROPERTIES,
      95           0 :             SVX_UNOEDIT_NUMBERING_PROPERTIE,
      96           0 :             {MAP_CHAR_LEN("TextUserDefinedAttributes"),     EE_CHAR_XMLATTRIBS,     &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0)  ,        0,     0},
      97           0 :             {MAP_CHAR_LEN("ParaUserDefinedAttributes"),     EE_PARA_XMLATTRIBS,     &::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >*)0)  ,        0,     0},
      98             :             {0,0,0,0,0,0}
      99           0 :         };
     100           0 :         static SvxItemPropertySet aPropSet( aPropMap, EditEngine::GetGlobalItemPool() );
     101           0 :         return &aPropSet;
     102             :     }
     103             : 
     104             : 
     105             :     DBG_NAME( AccessibleEditableTextPara )
     106             : 
     107             :     // #i27138# - add parameter <_pParaManager>
     108           0 :     AccessibleEditableTextPara::AccessibleEditableTextPara(
     109             :                                 const uno::Reference< XAccessible >& rParent,
     110             :                                 const AccessibleParaManager* _pParaManager )
     111             :         : AccessibleTextParaInterfaceBase( m_aMutex ),
     112             :           mnParagraphIndex( 0 ),
     113             :           mnIndexInParent( 0 ),
     114             :           mpEditSource( NULL ),
     115             :           maEEOffset( 0, 0 ),
     116             :           mxParent( rParent ),
     117             :           // well, that's strictly (UNO) exception safe, though not
     118             :           // really robust. We rely on the fact that this member is
     119             :           // constructed last, and that the constructor body catches
     120             :           // exceptions, thus no chance for exceptions once the Id is
     121             :           // fetched. Nevertheless, normally should employ RAII here...
     122           0 :           mnNotifierClientId(::comphelper::AccessibleEventNotifier::registerClient()),
     123             :           // #i27138#
     124           0 :           mpParaManager( _pParaManager )
     125             :     {
     126             : #ifdef DBG_UTIL
     127             :         DBG_CTOR( AccessibleEditableTextPara, NULL );
     128             :         OSL_TRACE( "AccessibleEditableTextPara received ID: %d", mnNotifierClientId );
     129             : #endif
     130             : 
     131             :         try
     132             :         {
     133             :             // Create the state set.
     134           0 :             ::utl::AccessibleStateSetHelper* pStateSet  = new ::utl::AccessibleStateSetHelper ();
     135           0 :             mxStateSet = pStateSet;
     136             : 
     137             :             // these are always on
     138           0 :             pStateSet->AddState( AccessibleStateType::MULTI_LINE );
     139           0 :             pStateSet->AddState( AccessibleStateType::FOCUSABLE );
     140           0 :             pStateSet->AddState( AccessibleStateType::VISIBLE );
     141           0 :             pStateSet->AddState( AccessibleStateType::SHOWING );
     142           0 :             pStateSet->AddState( AccessibleStateType::ENABLED );
     143           0 :             pStateSet->AddState( AccessibleStateType::SENSITIVE );
     144             :         }
     145           0 :         catch (const uno::Exception&)
     146             :         {
     147             :         }
     148           0 :     }
     149             : 
     150           0 :     AccessibleEditableTextPara::~AccessibleEditableTextPara()
     151             :     {
     152             :         DBG_DTOR( AccessibleEditableTextPara, NULL );
     153             : 
     154             :         // sign off from event notifier
     155           0 :         if( getNotifierClientId() != -1 )
     156             :         {
     157             :             try
     158             :             {
     159           0 :                 ::comphelper::AccessibleEventNotifier::revokeClient( getNotifierClientId() );
     160             : #ifdef DBG_UTIL
     161             :                 OSL_TRACE( "AccessibleEditableTextPara revoked ID: %d", mnNotifierClientId );
     162             : #endif
     163             :             }
     164           0 :             catch (const uno::Exception&)
     165             :             {
     166             :             }
     167             :         }
     168           0 :     }
     169             : 
     170           0 :     ::rtl::OUString AccessibleEditableTextPara::implGetText()
     171             :     {
     172             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     173             : 
     174           0 :         return GetTextRange( 0, GetTextLen() );
     175             :     }
     176             : 
     177           0 :     ::com::sun::star::lang::Locale AccessibleEditableTextPara::implGetLocale()
     178             :     {
     179             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     180             : 
     181             :         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
     182             :                    "AccessibleEditableTextPara::getLocale: paragraph index value overflow");
     183             : 
     184             :         // return locale of first character in the paragraph
     185           0 :         return LanguageTag(GetTextForwarder().GetLanguage( static_cast< sal_uInt16 >( GetParagraphIndex() ), 0 )).getLocale();
     186             :     }
     187             : 
     188           0 :     void AccessibleEditableTextPara::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
     189             :     {
     190             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     191             : 
     192             :         sal_uInt16 nStart, nEnd;
     193             : 
     194           0 :         if( GetSelection( nStart, nEnd ) )
     195             :         {
     196           0 :             nStartIndex = nStart;
     197           0 :             nEndIndex = nEnd;
     198             :         }
     199             :         else
     200             :         {
     201             :             // #102234# No exception, just set to 'invalid'
     202           0 :             nStartIndex = -1;
     203           0 :             nEndIndex = -1;
     204             :         }
     205           0 :     }
     206             : 
     207           0 :     void AccessibleEditableTextPara::implGetParagraphBoundary( ::com::sun::star::i18n::Boundary& rBoundary, sal_Int32 /*nIndex*/ )
     208             :     {
     209             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     210             :         DBG_WARNING( "AccessibleEditableTextPara::implGetParagraphBoundary: only a base implementation, ignoring the index" );
     211             : 
     212           0 :         rBoundary.startPos = 0;
     213           0 :         rBoundary.endPos = GetTextLen();
     214           0 :     }
     215             : 
     216           0 :     void AccessibleEditableTextPara::implGetLineBoundary( ::com::sun::star::i18n::Boundary& rBoundary, sal_Int32 nIndex )
     217             :     {
     218             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     219             : 
     220           0 :         SvxTextForwarder&   rCacheTF = GetTextForwarder();
     221           0 :         const sal_Int32     nParaIndex = GetParagraphIndex();
     222             : 
     223             :         DBG_ASSERT(nParaIndex >= 0 && nParaIndex <= USHRT_MAX,
     224             :                    "AccessibleEditableTextPara::implGetLineBoundary: paragraph index value overflow");
     225             : 
     226           0 :         const sal_Int32 nTextLen = rCacheTF.GetTextLen( static_cast< sal_uInt16 >( nParaIndex ) );
     227             : 
     228           0 :         CheckPosition(nIndex);
     229             : 
     230           0 :         rBoundary.startPos = rBoundary.endPos = -1;
     231             : 
     232           0 :         const sal_uInt16 nLineCount=rCacheTF.GetLineCount( static_cast< sal_uInt16 >( nParaIndex ) );
     233             : 
     234           0 :         if( nIndex == nTextLen )
     235             :         {
     236             :             // #i17014# Special-casing one-behind-the-end character
     237           0 :             if( nLineCount <= 1 )
     238           0 :                 rBoundary.startPos = 0;
     239             :             else
     240             :                 rBoundary.startPos = nTextLen - rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ),
     241           0 :                                                                      nLineCount-1 );
     242             : 
     243           0 :             rBoundary.endPos = nTextLen;
     244             :         }
     245             :         else
     246             :         {
     247             :             // normal line search
     248             :             sal_uInt16 nLine;
     249             :             sal_Int32 nCurIndex;
     250           0 :             for( nLine=0, nCurIndex=0; nLine<nLineCount; ++nLine )
     251             :             {
     252           0 :                 nCurIndex += rCacheTF.GetLineLen( static_cast< sal_uInt16 >( nParaIndex ), nLine);
     253             : 
     254           0 :                 if( nCurIndex > nIndex )
     255             :                 {
     256           0 :                     rBoundary.startPos = nCurIndex - rCacheTF.GetLineLen(static_cast< sal_uInt16 >( nParaIndex ), nLine);
     257           0 :                     rBoundary.endPos = nCurIndex;
     258           0 :                     break;
     259             :                 }
     260             :             }
     261             :         }
     262           0 :     }
     263             : 
     264           0 :     int AccessibleEditableTextPara::getNotifierClientId() const
     265             :     {
     266             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     267             : 
     268           0 :         return mnNotifierClientId;
     269             :     }
     270             : 
     271           0 :     void AccessibleEditableTextPara::SetIndexInParent( sal_Int32 nIndex )
     272             :     {
     273             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     274             : 
     275           0 :         mnIndexInParent = nIndex;
     276           0 :     }
     277             : 
     278           0 :     sal_Int32 AccessibleEditableTextPara::GetIndexInParent() const
     279             :     {
     280             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     281             : 
     282           0 :         return mnIndexInParent;
     283             :     }
     284             : 
     285           0 :     void AccessibleEditableTextPara::SetParagraphIndex( sal_Int32 nIndex )
     286             :     {
     287             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     288             : 
     289           0 :         sal_Int32 nOldIndex = mnParagraphIndex;
     290             : 
     291           0 :         mnParagraphIndex = nIndex;
     292             : 
     293           0 :         WeakBullet::HardRefType aChild( maImageBullet.get() );
     294           0 :         if( aChild.is() )
     295           0 :             aChild->SetParagraphIndex(mnParagraphIndex);
     296             : 
     297             :         try
     298             :         {
     299           0 :             if( nOldIndex != nIndex )
     300             :             {
     301           0 :                 uno::Any aOldDesc;
     302           0 :                 uno::Any aOldName;
     303             : 
     304             :                 try
     305             :                 {
     306           0 :                     aOldDesc <<= getAccessibleDescription();
     307           0 :                     aOldName <<= getAccessibleName();
     308             :                 }
     309           0 :                 catch (const uno::Exception&) // optional behaviour
     310             :                 {
     311             :                 }
     312             :                 // index and therefore description changed
     313           0 :                 FireEvent( AccessibleEventId::DESCRIPTION_CHANGED, uno::makeAny( getAccessibleDescription() ), aOldDesc );
     314           0 :                 FireEvent( AccessibleEventId::NAME_CHANGED, uno::makeAny( getAccessibleName() ), aOldName );
     315             :             }
     316             :         }
     317           0 :         catch (const uno::Exception&) // optional behaviour
     318             :         {
     319           0 :         }
     320           0 :     }
     321             : 
     322           0 :     sal_Int32 AccessibleEditableTextPara::GetParagraphIndex() const SAL_THROW((uno::RuntimeException))
     323             :     {
     324             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     325             : 
     326           0 :         return mnParagraphIndex;
     327             :     }
     328             : 
     329           0 :     void AccessibleEditableTextPara::Dispose()
     330             :     {
     331             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     332             : 
     333           0 :         int nClientId( getNotifierClientId() );
     334             : 
     335             :         // #108212# drop all references before notifying dispose
     336           0 :         mxParent = NULL;
     337           0 :         mnNotifierClientId = -1;
     338           0 :         mpEditSource = NULL;
     339             : 
     340             :         // notify listeners
     341           0 :         if( nClientId != -1 )
     342             :         {
     343             :             try
     344             :             {
     345           0 :                 uno::Reference < XAccessibleContext > xThis = getAccessibleContext();
     346             : 
     347             :                 // #106234# Delegate to EventNotifier
     348           0 :                 ::comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nClientId, xThis );
     349             : #ifdef DBG_UTIL
     350             :                 OSL_TRACE( "Disposed ID: %d", nClientId );
     351             : #endif
     352             :             }
     353           0 :             catch (const uno::Exception&)
     354             :             {
     355             :             }
     356             :         }
     357           0 :     }
     358             : 
     359           0 :     void AccessibleEditableTextPara::SetEditSource( SvxEditSourceAdapter* pEditSource )
     360             :     {
     361             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     362             : 
     363           0 :         mpEditSource = pEditSource;
     364             : 
     365           0 :         WeakBullet::HardRefType aChild( maImageBullet.get() );
     366           0 :         if( aChild.is() )
     367           0 :             aChild->SetEditSource(pEditSource);
     368             : 
     369           0 :         if( !mpEditSource )
     370             :         {
     371             :             // going defunc
     372           0 :             UnSetState( AccessibleStateType::SHOWING );
     373           0 :             UnSetState( AccessibleStateType::VISIBLE );
     374           0 :             SetState( AccessibleStateType::INVALID );
     375           0 :             SetState( AccessibleStateType::DEFUNC );
     376             : 
     377           0 :             Dispose();
     378             :         }
     379             : 
     380             :         // #108900# Init last text content
     381             :         try
     382             :         {
     383           0 :             TextChanged();
     384             :         }
     385           0 :         catch (const uno::RuntimeException&)
     386             :         {
     387           0 :         }
     388           0 :     }
     389             : 
     390           0 :     ESelection AccessibleEditableTextPara::MakeSelection( sal_Int32 nStartEEIndex, sal_Int32 nEndEEIndex )
     391             :     {
     392             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     393             : 
     394             :         // check overflow
     395             :         DBG_ASSERT(nStartEEIndex >= 0 && nStartEEIndex <= USHRT_MAX &&
     396             :                    nEndEEIndex >= 0 && nEndEEIndex <= USHRT_MAX &&
     397             :                    GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
     398             :                    "AccessibleEditableTextPara::MakeSelection: index value overflow");
     399             : 
     400           0 :         sal_uInt16 nParaIndex = static_cast< sal_uInt16 >( GetParagraphIndex() );
     401             :         return ESelection( nParaIndex, static_cast< sal_uInt16 >( nStartEEIndex ),
     402           0 :                            nParaIndex, static_cast< sal_uInt16 >( nEndEEIndex ) );
     403             :     }
     404             : 
     405           0 :     ESelection AccessibleEditableTextPara::MakeSelection( sal_Int32 nEEIndex )
     406             :     {
     407             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     408             : 
     409           0 :         return MakeSelection( nEEIndex, nEEIndex+1 );
     410             :     }
     411             : 
     412           0 :     ESelection AccessibleEditableTextPara::MakeCursor( sal_Int32 nEEIndex )
     413             :     {
     414             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     415             : 
     416           0 :         return MakeSelection( nEEIndex, nEEIndex );
     417             :     }
     418             : 
     419           0 :     void AccessibleEditableTextPara::CheckIndex( sal_Int32 nIndex ) SAL_THROW((lang::IndexOutOfBoundsException, uno::RuntimeException))
     420             :     {
     421             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     422             : 
     423           0 :         if( nIndex < 0 || nIndex >= getCharacterCount() )
     424             :             throw lang::IndexOutOfBoundsException(::rtl::OUString("AccessibleEditableTextPara: character index out of bounds"),
     425             :                                                   uno::Reference< uno::XInterface >
     426           0 :                                                   ( static_cast< ::cppu::OWeakObject* > (this) ) ); // disambiguate hierarchy
     427           0 :     }
     428             : 
     429           0 :     void AccessibleEditableTextPara::CheckPosition( sal_Int32 nIndex ) SAL_THROW((lang::IndexOutOfBoundsException, uno::RuntimeException))
     430             :     {
     431             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     432             : 
     433           0 :         if( nIndex < 0 || nIndex > getCharacterCount() )
     434             :             throw lang::IndexOutOfBoundsException(::rtl::OUString("AccessibleEditableTextPara: character position out of bounds"),
     435             :                                                   uno::Reference< uno::XInterface >
     436           0 :                                                   ( static_cast< ::cppu::OWeakObject* > (this) ) ); // disambiguate hierarchy
     437           0 :     }
     438             : 
     439           0 :     void AccessibleEditableTextPara::CheckRange( sal_Int32 nStart, sal_Int32 nEnd ) SAL_THROW((lang::IndexOutOfBoundsException, uno::RuntimeException))
     440             :     {
     441             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     442             : 
     443           0 :         CheckPosition( nStart );
     444           0 :         CheckPosition( nEnd );
     445           0 :     }
     446             : 
     447           0 :     sal_Bool AccessibleEditableTextPara::GetSelection( sal_uInt16& nStartPos, sal_uInt16& nEndPos ) SAL_THROW((uno::RuntimeException))
     448             :     {
     449             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     450             : 
     451           0 :         ESelection aSelection;
     452           0 :         sal_uInt16 nPara = static_cast< sal_uInt16 > ( GetParagraphIndex() );
     453           0 :         if( !GetEditViewForwarder().GetSelection( aSelection ) )
     454           0 :             return sal_False;
     455             : 
     456           0 :         if( aSelection.nStartPara < aSelection.nEndPara )
     457             :         {
     458           0 :             if( aSelection.nStartPara > nPara ||
     459             :                 aSelection.nEndPara < nPara )
     460           0 :                 return sal_False;
     461             : 
     462           0 :             if( nPara == aSelection.nStartPara )
     463           0 :                 nStartPos = aSelection.nStartPos;
     464             :             else
     465           0 :                 nStartPos = 0;
     466             : 
     467           0 :             if( nPara == aSelection.nEndPara )
     468           0 :                 nEndPos = aSelection.nEndPos;
     469             :             else
     470           0 :                 nEndPos = GetTextLen();
     471             :         }
     472             :         else
     473             :         {
     474           0 :             if( aSelection.nStartPara < nPara ||
     475             :                 aSelection.nEndPara > nPara )
     476           0 :                 return sal_False;
     477             : 
     478           0 :             if( nPara == aSelection.nStartPara )
     479           0 :                 nStartPos = aSelection.nStartPos;
     480             :             else
     481           0 :                 nStartPos = GetTextLen();
     482             : 
     483           0 :             if( nPara == aSelection.nEndPara )
     484           0 :                 nEndPos = aSelection.nEndPos;
     485             :             else
     486           0 :                 nEndPos = 0;
     487             :         }
     488             : 
     489           0 :         return sal_True;
     490             :     }
     491             : 
     492           0 :     String AccessibleEditableTextPara::GetTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) SAL_THROW((uno::RuntimeException))
     493             :     {
     494             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     495             : 
     496           0 :         return GetTextForwarder().GetText( MakeSelection(nStartIndex, nEndIndex) );
     497             :     }
     498             : 
     499           0 :     sal_uInt16 AccessibleEditableTextPara::GetTextLen() const SAL_THROW((uno::RuntimeException))
     500             :     {
     501             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     502             : 
     503           0 :         return GetTextForwarder().GetTextLen( static_cast< sal_uInt16 >( GetParagraphIndex() ) );
     504             :     }
     505             : 
     506           0 :     SvxEditSourceAdapter& AccessibleEditableTextPara::GetEditSource() const SAL_THROW((uno::RuntimeException))
     507             :     {
     508             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     509             : 
     510           0 :         if( mpEditSource )
     511           0 :             return *mpEditSource;
     512             :         else
     513             :             throw uno::RuntimeException(::rtl::OUString("No edit source, object is defunct"),
     514             :                                         uno::Reference< uno::XInterface >
     515             :                                         ( static_cast< ::cppu::OWeakObject* >
     516           0 :                                           ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy
     517             :     }
     518             : 
     519           0 :     SvxAccessibleTextAdapter& AccessibleEditableTextPara::GetTextForwarder() const SAL_THROW((uno::RuntimeException))
     520             :     {
     521             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     522             : 
     523           0 :         SvxEditSourceAdapter& rEditSource = GetEditSource();
     524           0 :         SvxAccessibleTextAdapter* pTextForwarder = rEditSource.GetTextForwarderAdapter();
     525             : 
     526           0 :         if( !pTextForwarder )
     527             :             throw uno::RuntimeException(::rtl::OUString("Unable to fetch text forwarder, object is defunct"),
     528             :                                         uno::Reference< uno::XInterface >
     529             :                                         ( static_cast< ::cppu::OWeakObject* >
     530           0 :                                           ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy
     531             : 
     532           0 :         if( pTextForwarder->IsValid() )
     533           0 :             return *pTextForwarder;
     534             :         else
     535             :             throw uno::RuntimeException(::rtl::OUString("Text forwarder is invalid, object is defunct"),
     536             :                                         uno::Reference< uno::XInterface >
     537             :                                         ( static_cast< ::cppu::OWeakObject* >
     538           0 :                                           ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy
     539             :     }
     540             : 
     541           0 :     SvxViewForwarder& AccessibleEditableTextPara::GetViewForwarder() const SAL_THROW((uno::RuntimeException))
     542             :     {
     543             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     544             : 
     545           0 :         SvxEditSource& rEditSource = GetEditSource();
     546           0 :         SvxViewForwarder* pViewForwarder = rEditSource.GetViewForwarder();
     547             : 
     548           0 :         if( !pViewForwarder )
     549             :         {
     550             :             throw uno::RuntimeException(::rtl::OUString("Unable to fetch view forwarder, object is defunct"),
     551             :                                         uno::Reference< uno::XInterface >
     552             :                                         ( static_cast< ::cppu::OWeakObject* >
     553           0 :                                           ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy
     554             :         }
     555             : 
     556           0 :         if( pViewForwarder->IsValid() )
     557           0 :             return *pViewForwarder;
     558             :         else
     559             :             throw uno::RuntimeException(::rtl::OUString("View forwarder is invalid, object is defunct"),
     560             :                                         uno::Reference< uno::XInterface >
     561             :                                         ( static_cast< ::cppu::OWeakObject* >
     562           0 :                                           ( const_cast< AccessibleEditableTextPara* > (this) )  ) );    // disambiguate hierarchy
     563             :     }
     564             : 
     565           0 :     SvxAccessibleTextEditViewAdapter& AccessibleEditableTextPara::GetEditViewForwarder( sal_Bool bCreate ) const SAL_THROW((uno::RuntimeException))
     566             :     {
     567             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     568             : 
     569           0 :         SvxEditSourceAdapter& rEditSource = GetEditSource();
     570           0 :         SvxAccessibleTextEditViewAdapter* pTextEditViewForwarder = rEditSource.GetEditViewForwarderAdapter( bCreate );
     571             : 
     572           0 :         if( !pTextEditViewForwarder )
     573             :         {
     574           0 :             if( bCreate )
     575             :                 throw uno::RuntimeException(::rtl::OUString("Unable to fetch view forwarder, object is defunct"),
     576             :                                             uno::Reference< uno::XInterface >
     577             :                                             ( static_cast< ::cppu::OWeakObject* >
     578           0 :                                               ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy
     579             :             else
     580             :                 throw uno::RuntimeException(::rtl::OUString("No view forwarder, object not in edit mode"),
     581             :                                             uno::Reference< uno::XInterface >
     582             :                                             ( static_cast< ::cppu::OWeakObject* >
     583           0 :                                               ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy
     584             :         }
     585             : 
     586           0 :         if( pTextEditViewForwarder->IsValid() )
     587           0 :             return *pTextEditViewForwarder;
     588             :         else
     589             :         {
     590           0 :             if( bCreate )
     591             :                 throw uno::RuntimeException(::rtl::OUString("View forwarder is invalid, object is defunct"),
     592             :                                             uno::Reference< uno::XInterface >
     593             :                                             ( static_cast< ::cppu::OWeakObject* >
     594           0 :                                               ( const_cast< AccessibleEditableTextPara* > (this) )  ) );    // disambiguate hierarchy
     595             :             else
     596             :                 throw uno::RuntimeException(::rtl::OUString("View forwarder is invalid, object not in edit mode"),
     597             :                                             uno::Reference< uno::XInterface >
     598             :                                             ( static_cast< ::cppu::OWeakObject* >
     599           0 :                                               ( const_cast< AccessibleEditableTextPara* > (this) )  ) );    // disambiguate hierarchy
     600             :         }
     601             :     }
     602             : 
     603           0 :     sal_Bool AccessibleEditableTextPara::HaveEditView() const
     604             :     {
     605             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     606             : 
     607           0 :         SvxEditSource& rEditSource = GetEditSource();
     608           0 :         SvxEditViewForwarder* pViewForwarder = rEditSource.GetEditViewForwarder();
     609             : 
     610           0 :         if( !pViewForwarder )
     611           0 :             return sal_False;
     612             : 
     613           0 :         if( !pViewForwarder->IsValid() )
     614           0 :             return sal_False;
     615             : 
     616           0 :         return sal_True;
     617             :     }
     618             : 
     619           0 :     sal_Bool AccessibleEditableTextPara::HaveChildren()
     620             :     {
     621             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     622             : 
     623             :         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
     624             :                    "AccessibleEditableTextPara::HaveChildren: paragraph index value overflow");
     625             : 
     626           0 :         return GetTextForwarder().HaveImageBullet( static_cast< sal_uInt16 >(GetParagraphIndex()) );
     627             :     }
     628             : 
     629           0 :     Rectangle AccessibleEditableTextPara::LogicToPixel( const Rectangle& rRect, const MapMode& rMapMode, SvxViewForwarder& rForwarder )
     630             :     {
     631             :         // convert to screen coordinates
     632           0 :         return Rectangle( rForwarder.LogicToPixel( rRect.TopLeft(), rMapMode ),
     633           0 :                           rForwarder.LogicToPixel( rRect.BottomRight(), rMapMode ) );
     634             :     }
     635             : 
     636           0 :     const Point& AccessibleEditableTextPara::GetEEOffset() const
     637             :     {
     638             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     639             : 
     640           0 :         return maEEOffset;
     641             :     }
     642             : 
     643           0 :     void AccessibleEditableTextPara::SetEEOffset( const Point& rOffset )
     644             :     {
     645             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     646             : 
     647           0 :         WeakBullet::HardRefType aChild( maImageBullet.get() );
     648           0 :         if( aChild.is() )
     649           0 :             aChild->SetEEOffset(rOffset);
     650             : 
     651           0 :         maEEOffset = rOffset;
     652           0 :     }
     653             : 
     654           0 :     void AccessibleEditableTextPara::FireEvent(const sal_Int16 nEventId, const uno::Any& rNewValue, const uno::Any& rOldValue) const
     655             :     {
     656             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     657             : 
     658           0 :         uno::Reference < XAccessibleContext > xThis( const_cast< AccessibleEditableTextPara* > (this)->getAccessibleContext() );
     659             : 
     660           0 :         AccessibleEventObject aEvent(xThis, nEventId, rNewValue, rOldValue);
     661             : 
     662             :         // #102261# Call global queue for focus events
     663           0 :         if( nEventId == AccessibleEventId::STATE_CHANGED )
     664           0 :             vcl::unohelper::NotifyAccessibleStateEventGlobally( aEvent );
     665             : 
     666             :         // #106234# Delegate to EventNotifier
     667           0 :         if( getNotifierClientId() != -1 )
     668           0 :             ::comphelper::AccessibleEventNotifier::addEvent( getNotifierClientId(),
     669           0 :                                                              aEvent );
     670           0 :     }
     671             : 
     672           0 :     void AccessibleEditableTextPara::GotPropertyEvent( const uno::Any& rNewValue, const sal_Int16 nEventId ) const
     673             :     {
     674             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     675             : 
     676           0 :         FireEvent( nEventId, rNewValue );
     677           0 :     }
     678             : 
     679           0 :     void AccessibleEditableTextPara::LostPropertyEvent( const uno::Any& rOldValue, const sal_Int16 nEventId ) const
     680             :     {
     681             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     682             : 
     683           0 :         FireEvent( nEventId, uno::Any(), rOldValue );
     684           0 :     }
     685             : 
     686           0 :     void AccessibleEditableTextPara::SetState( const sal_Int16 nStateId )
     687             :     {
     688             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     689             : 
     690           0 :         ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
     691           0 :         if( pStateSet != NULL &&
     692           0 :             !pStateSet->contains(nStateId) )
     693             :         {
     694           0 :             pStateSet->AddState( nStateId );
     695           0 :             GotPropertyEvent( uno::makeAny( nStateId ), AccessibleEventId::STATE_CHANGED );
     696             :         }
     697           0 :     }
     698             : 
     699           0 :     void AccessibleEditableTextPara::UnSetState( const sal_Int16 nStateId )
     700             :     {
     701             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     702             : 
     703           0 :         ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
     704           0 :         if( pStateSet != NULL &&
     705           0 :             pStateSet->contains(nStateId) )
     706             :         {
     707           0 :             pStateSet->RemoveState( nStateId );
     708           0 :             LostPropertyEvent( uno::makeAny( nStateId ), AccessibleEventId::STATE_CHANGED );
     709             :         }
     710           0 :     }
     711             : 
     712           0 :     void AccessibleEditableTextPara::TextChanged()
     713             :     {
     714           0 :         ::rtl::OUString aCurrentString( OCommonAccessibleText::getText() );
     715           0 :         uno::Any aDeleted;
     716           0 :         uno::Any aInserted;
     717           0 :         if( OCommonAccessibleText::implInitTextChangedEvent( maLastTextString, aCurrentString,
     718           0 :                                                              aDeleted, aInserted) )
     719             :         {
     720           0 :             FireEvent( AccessibleEventId::TEXT_CHANGED, aInserted, aDeleted );
     721           0 :             maLastTextString = aCurrentString;
     722           0 :         }
     723           0 :     }
     724             : 
     725           0 :     sal_Bool AccessibleEditableTextPara::GetAttributeRun( sal_uInt16& nStartIndex, sal_uInt16& nEndIndex, sal_Int32 nIndex )
     726             :     {
     727             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     728             : 
     729             :         DBG_ASSERT(nIndex >= 0 && nIndex <= USHRT_MAX,
     730             :                    "AccessibleEditableTextPara::GetAttributeRun: index value overflow");
     731             : 
     732             :         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
     733             :                    "AccessibleEditableTextPara::getLocale: paragraph index value overflow");
     734             : 
     735           0 :         return GetTextForwarder().GetAttributeRun( nStartIndex,
     736             :                                                    nEndIndex,
     737           0 :                                                    static_cast< sal_uInt16 >(GetParagraphIndex()),
     738           0 :                                                    static_cast< sal_uInt16 >(nIndex) );
     739             :     }
     740             : 
     741           0 :     uno::Any SAL_CALL AccessibleEditableTextPara::queryInterface (const uno::Type & rType) throw (uno::RuntimeException)
     742             :     {
     743             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     744             : 
     745           0 :         uno::Any aRet;
     746             : 
     747             :         // must provide XAccesibleText by hand, since it comes publicly inherited by XAccessibleEditableText
     748           0 :         if ( rType == ::getCppuType((uno::Reference< XAccessibleText > *)0) )
     749             :         {
     750           0 :             uno::Reference< XAccessibleText > aAccText = static_cast< XAccessibleEditableText * >(this);
     751           0 :             aRet <<= aAccText;
     752             :         }
     753           0 :         else if ( rType == ::getCppuType((uno::Reference< XAccessibleEditableText > *)0) )
     754             :         {
     755           0 :             uno::Reference< XAccessibleEditableText > aAccEditText = this;
     756           0 :             aRet <<= aAccEditText;
     757             :         }
     758           0 :         else if ( rType == ::getCppuType((uno::Reference< XAccessibleHypertext > *)0) )
     759             :         {
     760           0 :             uno::Reference< XAccessibleHypertext > aAccHyperText = this;
     761           0 :             aRet <<= aAccHyperText;
     762             :         }
     763             :         else
     764             :         {
     765           0 :             aRet = AccessibleTextParaInterfaceBase::queryInterface(rType);
     766             :         }
     767             : 
     768           0 :         return aRet;
     769             :     }
     770             : 
     771             :     // XAccessible
     772           0 :     uno::Reference< XAccessibleContext > SAL_CALL AccessibleEditableTextPara::getAccessibleContext() throw (uno::RuntimeException)
     773             :     {
     774             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     775             : 
     776             :         // We implement the XAccessibleContext interface in the same object
     777           0 :         return uno::Reference< XAccessibleContext > ( this );
     778             :     }
     779             : 
     780             :     // XAccessibleContext
     781           0 :     sal_Int32 SAL_CALL AccessibleEditableTextPara::getAccessibleChildCount() throw (uno::RuntimeException)
     782             :     {
     783             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     784             : 
     785           0 :         SolarMutexGuard aGuard;
     786             : 
     787           0 :         return HaveChildren() ? 1 : 0;
     788             :     }
     789             : 
     790           0 :     uno::Reference< XAccessible > SAL_CALL AccessibleEditableTextPara::getAccessibleChild( sal_Int32 i ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
     791             :     {
     792             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     793             : 
     794           0 :         SolarMutexGuard aGuard;
     795             : 
     796           0 :         if( !HaveChildren() )
     797             :             throw lang::IndexOutOfBoundsException(::rtl::OUString("No children available"),
     798             :                                                   uno::Reference< uno::XInterface >
     799           0 :                                                   ( static_cast< ::cppu::OWeakObject* > (this) ) ); // static_cast: disambiguate hierarchy
     800             : 
     801           0 :         if( i != 0 )
     802             :             throw lang::IndexOutOfBoundsException(::rtl::OUString("Invalid child index"),
     803             :                                                   uno::Reference< uno::XInterface >
     804           0 :                                                   ( static_cast< ::cppu::OWeakObject* > (this) ) ); // static_cast: disambiguate hierarchy
     805             : 
     806           0 :         WeakBullet::HardRefType aChild( maImageBullet.get() );
     807             : 
     808           0 :         if( !aChild.is() )
     809             :         {
     810             :             // there is no hard reference available, create object then
     811           0 :             AccessibleImageBullet* pChild = new AccessibleImageBullet( uno::Reference< XAccessible >( this ) );
     812           0 :             uno::Reference< XAccessible > xChild( static_cast< ::cppu::OWeakObject* > (pChild), uno::UNO_QUERY );
     813             : 
     814           0 :             if( !xChild.is() )
     815             :                 throw uno::RuntimeException(::rtl::OUString("Child creation failed"),
     816             :                                             uno::Reference< uno::XInterface >
     817           0 :                                             ( static_cast< ::cppu::OWeakObject* > (this) ) );
     818             : 
     819           0 :             aChild = WeakBullet::HardRefType( xChild, pChild );
     820             : 
     821           0 :             aChild->SetEditSource( &GetEditSource() );
     822           0 :             aChild->SetParagraphIndex( GetParagraphIndex() );
     823           0 :             aChild->SetIndexInParent( i );
     824             : 
     825           0 :             maImageBullet = aChild;
     826             :         }
     827             : 
     828           0 :         return aChild.getRef();
     829             :     }
     830             : 
     831           0 :     uno::Reference< XAccessible > SAL_CALL AccessibleEditableTextPara::getAccessibleParent() throw (uno::RuntimeException)
     832             :     {
     833             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     834             : 
     835             : #ifdef DBG_UTIL
     836             :         if( !mxParent.is() )
     837             :             OSL_TRACE( "AccessibleEditableTextPara::getAccessibleParent: no frontend set, did somebody forgot to call AccessibleTextHelper::SetEventSource()?");
     838             : #endif
     839             : 
     840           0 :         return mxParent;
     841             :     }
     842             : 
     843           0 :     sal_Int32 SAL_CALL AccessibleEditableTextPara::getAccessibleIndexInParent() throw (uno::RuntimeException)
     844             :     {
     845             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     846             : 
     847           0 :         return mnIndexInParent;
     848             :     }
     849             : 
     850           0 :     sal_Int16 SAL_CALL AccessibleEditableTextPara::getAccessibleRole() throw (uno::RuntimeException)
     851             :     {
     852             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     853             : 
     854           0 :         return AccessibleRole::PARAGRAPH;
     855             :     }
     856             : 
     857           0 :     ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getAccessibleDescription() throw (uno::RuntimeException)
     858             :     {
     859             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     860             : 
     861             : //        SolarMutexGuard aGuard;
     862             : 
     863           0 :         return ::rtl::OUString();
     864             :     }
     865             : 
     866           0 :     ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getAccessibleName() throw (uno::RuntimeException)
     867             :     {
     868             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     869             : 
     870             : //        SolarMutexGuard aGuard;
     871             : 
     872           0 :         return ::rtl::OUString();
     873             :     }
     874             : 
     875           0 :     uno::Reference< XAccessibleRelationSet > SAL_CALL AccessibleEditableTextPara::getAccessibleRelationSet() throw (uno::RuntimeException)
     876             :     {
     877             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     878             : 
     879             :         // #i27138# - provide relations CONTENT_FLOWS_FROM
     880             :         // and CONTENT_FLOWS_TO
     881           0 :         if ( mpParaManager )
     882             :         {
     883             :             utl::AccessibleRelationSetHelper* pAccRelSetHelper =
     884           0 :                                         new utl::AccessibleRelationSetHelper();
     885           0 :             sal_Int32 nMyParaIndex( GetParagraphIndex() );
     886             :             // relation CONTENT_FLOWS_FROM
     887           0 :             if ( nMyParaIndex > 0 &&
     888           0 :                  mpParaManager->IsReferencable( nMyParaIndex - 1 ) )
     889             :             {
     890           0 :                 uno::Sequence<uno::Reference<XInterface> > aSequence(1);
     891           0 :                 aSequence[0] =
     892           0 :                     mpParaManager->GetChild( nMyParaIndex - 1 ).first.get().getRef();
     893             :                 AccessibleRelation aAccRel( AccessibleRelationType::CONTENT_FLOWS_FROM,
     894           0 :                                             aSequence );
     895           0 :                 pAccRelSetHelper->AddRelation( aAccRel );
     896             :             }
     897             : 
     898             :             // relation CONTENT_FLOWS_TO
     899           0 :             if ( (nMyParaIndex + 1) < (sal_Int32)mpParaManager->GetNum() &&
     900           0 :                  mpParaManager->IsReferencable( nMyParaIndex + 1 ) )
     901             :             {
     902           0 :                 uno::Sequence<uno::Reference<XInterface> > aSequence(1);
     903           0 :                 aSequence[0] =
     904           0 :                     mpParaManager->GetChild( nMyParaIndex + 1 ).first.get().getRef();
     905             :                 AccessibleRelation aAccRel( AccessibleRelationType::CONTENT_FLOWS_TO,
     906           0 :                                             aSequence );
     907           0 :                 pAccRelSetHelper->AddRelation( aAccRel );
     908             :             }
     909             : 
     910           0 :             return pAccRelSetHelper;
     911             :         }
     912             :         else
     913             :         {
     914             :             // no relations, therefore empty
     915           0 :             return uno::Reference< XAccessibleRelationSet >();
     916             :         }
     917             :     }
     918             : 
     919           0 :     uno::Reference< XAccessibleStateSet > SAL_CALL AccessibleEditableTextPara::getAccessibleStateSet() throw (uno::RuntimeException)
     920             :     {
     921             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     922             : 
     923           0 :         SolarMutexGuard aGuard;
     924             : 
     925             :         // Create a copy of the state set and return it.
     926           0 :         ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
     927             : 
     928           0 :         if( !pStateSet )
     929           0 :             return uno::Reference<XAccessibleStateSet>();
     930             : 
     931           0 :         return uno::Reference<XAccessibleStateSet>( new ::utl::AccessibleStateSetHelper (*pStateSet) );
     932             :     }
     933             : 
     934           0 :     lang::Locale SAL_CALL AccessibleEditableTextPara::getLocale() throw (IllegalAccessibleComponentStateException, uno::RuntimeException)
     935             :     {
     936             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     937             : 
     938           0 :         SolarMutexGuard aGuard;
     939             : 
     940           0 :         return implGetLocale();
     941             :     }
     942             : 
     943           0 :     void SAL_CALL AccessibleEditableTextPara::addAccessibleEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) throw (uno::RuntimeException)
     944             :     {
     945             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     946             : 
     947           0 :         if( getNotifierClientId() != -1 )
     948           0 :             ::comphelper::AccessibleEventNotifier::addEventListener( getNotifierClientId(), xListener );
     949           0 :     }
     950             : 
     951           0 :     void SAL_CALL AccessibleEditableTextPara::removeAccessibleEventListener( const uno::Reference< XAccessibleEventListener >& xListener ) throw (uno::RuntimeException)
     952             :     {
     953             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     954             : 
     955           0 :         if( getNotifierClientId() != -1 )
     956           0 :             ::comphelper::AccessibleEventNotifier::removeEventListener( getNotifierClientId(), xListener );
     957           0 :     }
     958             : 
     959             :     // XAccessibleComponent
     960           0 :     sal_Bool SAL_CALL AccessibleEditableTextPara::containsPoint( const awt::Point& aTmpPoint ) throw (uno::RuntimeException)
     961             :     {
     962             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     963             : 
     964           0 :         SolarMutexGuard aGuard;
     965             : 
     966             :         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
     967             :                    "AccessibleEditableTextPara::contains: index value overflow");
     968             : 
     969           0 :         awt::Rectangle aTmpRect = getBounds();
     970           0 :         Rectangle aRect( Point(aTmpRect.X, aTmpRect.Y), Size(aTmpRect.Width, aTmpRect.Height) );
     971           0 :         Point aPoint( aTmpPoint.X, aTmpPoint.Y );
     972             : 
     973           0 :         return aRect.IsInside( aPoint );
     974             :     }
     975             : 
     976           0 :     uno::Reference< XAccessible > SAL_CALL AccessibleEditableTextPara::getAccessibleAtPoint( const awt::Point& _aPoint ) throw (uno::RuntimeException)
     977             :     {
     978             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
     979             : 
     980           0 :         SolarMutexGuard aGuard;
     981             : 
     982           0 :         if( HaveChildren() )
     983             :         {
     984             :             // #103862# No longer need to make given position relative
     985           0 :             Point aPoint( _aPoint.X, _aPoint.Y );
     986             : 
     987             :             // respect EditEngine offset to surrounding shape/cell
     988           0 :             aPoint -= GetEEOffset();
     989             : 
     990             :             // convert to EditEngine coordinate system
     991           0 :             SvxTextForwarder& rCacheTF = GetTextForwarder();
     992           0 :             Point aLogPoint( GetViewForwarder().PixelToLogic( aPoint, rCacheTF.GetMapMode() ) );
     993             : 
     994           0 :             EBulletInfo aBulletInfo = rCacheTF.GetBulletInfo( static_cast< sal_uInt16 > (GetParagraphIndex()) );
     995             : 
     996           0 :             if( aBulletInfo.nParagraph != EE_PARA_NOT_FOUND &&
     997             :                 aBulletInfo.bVisible &&
     998             :                 aBulletInfo.nType == SVX_NUM_BITMAP )
     999             :             {
    1000           0 :                 Rectangle aRect = aBulletInfo.aBounds;
    1001             : 
    1002           0 :                 if( aRect.IsInside( aLogPoint ) )
    1003           0 :                     return getAccessibleChild(0);
    1004           0 :             }
    1005             :         }
    1006             : 
    1007             :         // no children at all, or none at given position
    1008           0 :         return uno::Reference< XAccessible >();
    1009             :     }
    1010             : 
    1011           0 :     awt::Rectangle SAL_CALL AccessibleEditableTextPara::getBounds() throw (uno::RuntimeException)
    1012             :     {
    1013             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1014             : 
    1015           0 :         SolarMutexGuard aGuard;
    1016             : 
    1017             :         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
    1018             :                    "AccessibleEditableTextPara::getBounds: index value overflow");
    1019             : 
    1020           0 :         SvxTextForwarder& rCacheTF = GetTextForwarder();
    1021           0 :         Rectangle aRect = rCacheTF.GetParaBounds( static_cast< sal_uInt16 >( GetParagraphIndex() ) );
    1022             : 
    1023             :         // convert to screen coordinates
    1024             :         Rectangle aScreenRect = AccessibleEditableTextPara::LogicToPixel( aRect,
    1025           0 :                                                                           rCacheTF.GetMapMode(),
    1026           0 :                                                                           GetViewForwarder() );
    1027             : 
    1028             :         // offset from shape/cell
    1029           0 :         Point aOffset = GetEEOffset();
    1030             : 
    1031           0 :         return awt::Rectangle( aScreenRect.Left() + aOffset.X(),
    1032           0 :                                aScreenRect.Top() + aOffset.Y(),
    1033           0 :                                aScreenRect.GetSize().Width(),
    1034           0 :                                aScreenRect.GetSize().Height() );
    1035             :     }
    1036             : 
    1037           0 :     awt::Point SAL_CALL AccessibleEditableTextPara::getLocation(  ) throw (uno::RuntimeException)
    1038             :     {
    1039             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1040             : 
    1041           0 :         SolarMutexGuard aGuard;
    1042             : 
    1043           0 :         awt::Rectangle aRect = getBounds();
    1044             : 
    1045           0 :         return awt::Point( aRect.X, aRect.Y );
    1046             :     }
    1047             : 
    1048           0 :     awt::Point SAL_CALL AccessibleEditableTextPara::getLocationOnScreen(  ) throw (uno::RuntimeException)
    1049             :     {
    1050             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1051             : 
    1052           0 :         SolarMutexGuard aGuard;
    1053             : 
    1054             :         // relate us to parent
    1055           0 :         uno::Reference< XAccessible > xParent = getAccessibleParent();
    1056           0 :         if( xParent.is() )
    1057             :         {
    1058           0 :             uno::Reference< XAccessibleComponent > xParentComponent( xParent, uno::UNO_QUERY );
    1059           0 :             if( xParentComponent.is() )
    1060             :             {
    1061           0 :                 awt::Point aRefPoint = xParentComponent->getLocationOnScreen();
    1062           0 :                 awt::Point aPoint = getLocation();
    1063           0 :                 aPoint.X += aRefPoint.X;
    1064           0 :                 aPoint.Y += aRefPoint.Y;
    1065             : 
    1066           0 :                 return aPoint;
    1067             :             }
    1068             :             // #i88070#
    1069             :             // fallback to parent's <XAccessibleContext> instance
    1070             :             else
    1071             :             {
    1072           0 :                 uno::Reference< XAccessibleContext > xParentContext = xParent->getAccessibleContext();
    1073           0 :                 if ( xParentContext.is() )
    1074             :                 {
    1075           0 :                     uno::Reference< XAccessibleComponent > xParentContextComponent( xParentContext, uno::UNO_QUERY );
    1076           0 :                     if( xParentContextComponent.is() )
    1077             :                     {
    1078           0 :                         awt::Point aRefPoint = xParentContextComponent->getLocationOnScreen();
    1079           0 :                         awt::Point aPoint = getLocation();
    1080           0 :                         aPoint.X += aRefPoint.X;
    1081           0 :                         aPoint.Y += aRefPoint.Y;
    1082             : 
    1083           0 :                         return aPoint;
    1084           0 :                     }
    1085           0 :                 }
    1086           0 :             }
    1087             :         }
    1088             : 
    1089             :         throw uno::RuntimeException(::rtl::OUString("Cannot access parent"),
    1090             :                                     uno::Reference< uno::XInterface >
    1091           0 :                                     ( static_cast< XAccessible* > (this) ) );   // disambiguate hierarchy
    1092             :     }
    1093             : 
    1094           0 :     awt::Size SAL_CALL AccessibleEditableTextPara::getSize(  ) throw (uno::RuntimeException)
    1095             :     {
    1096             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1097             : 
    1098           0 :         SolarMutexGuard aGuard;
    1099             : 
    1100           0 :         awt::Rectangle aRect = getBounds();
    1101             : 
    1102           0 :         return awt::Size( aRect.Width, aRect.Height );
    1103             :     }
    1104             : 
    1105           0 :     void SAL_CALL AccessibleEditableTextPara::grabFocus(  ) throw (uno::RuntimeException)
    1106             :     {
    1107             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1108             : 
    1109             :         // set cursor to this paragraph
    1110           0 :         setSelection(0,0);
    1111           0 :     }
    1112             : 
    1113           0 :     sal_Int32 SAL_CALL AccessibleEditableTextPara::getForeground(  ) throw (::com::sun::star::uno::RuntimeException)
    1114             :     {
    1115             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1116             : 
    1117             :         // #104444# Added to XAccessibleComponent interface
    1118           0 :         svtools::ColorConfig aColorConfig;
    1119           0 :         sal_uInt32 nColor = aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor;
    1120           0 :         return static_cast<sal_Int32>(nColor);
    1121             :     }
    1122             : 
    1123           0 :     sal_Int32 SAL_CALL AccessibleEditableTextPara::getBackground(  ) throw (::com::sun::star::uno::RuntimeException)
    1124             :     {
    1125             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1126             : 
    1127             :         // #104444# Added to XAccessibleComponent interface
    1128           0 :         Color aColor( Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor() );
    1129             : 
    1130             :         // the background is transparent
    1131           0 :         aColor.SetTransparency( 0xFF);
    1132             : 
    1133           0 :         return static_cast<sal_Int32>( aColor.GetColor() );
    1134             :     }
    1135             : 
    1136             :     // XAccessibleText
    1137           0 :     sal_Int32 SAL_CALL AccessibleEditableTextPara::getCaretPosition() throw (uno::RuntimeException)
    1138             :     {
    1139             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1140             : 
    1141           0 :         SolarMutexGuard aGuard;
    1142             : 
    1143           0 :         if( !HaveEditView() )
    1144           0 :             return -1;
    1145             : 
    1146           0 :         ESelection aSelection;
    1147           0 :         if( GetEditViewForwarder().GetSelection( aSelection ) &&
    1148           0 :             GetParagraphIndex() == aSelection.nEndPara )
    1149             :         {
    1150             :             // caret is always nEndPara,nEndPos
    1151           0 :             return aSelection.nEndPos;
    1152             :         }
    1153             : 
    1154             :         // not within this paragraph
    1155           0 :         return -1;
    1156             :     }
    1157             : 
    1158           0 :     sal_Bool SAL_CALL AccessibleEditableTextPara::setCaretPosition( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
    1159             :     {
    1160             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1161             : 
    1162           0 :         return setSelection(nIndex, nIndex);
    1163             :     }
    1164             : 
    1165           0 :     sal_Unicode SAL_CALL AccessibleEditableTextPara::getCharacter( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
    1166             :     {
    1167             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1168             : 
    1169           0 :         SolarMutexGuard aGuard;
    1170             : 
    1171             :         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
    1172             :                    "AccessibleEditableTextPara::getCharacter: index value overflow");
    1173             : 
    1174           0 :         return OCommonAccessibleText::getCharacter( nIndex );
    1175             :     }
    1176             : 
    1177           0 :     uno::Sequence< beans::PropertyValue > SAL_CALL AccessibleEditableTextPara::getCharacterAttributes( sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& rRequestedAttributes ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
    1178             :     {
    1179             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1180           0 :         SolarMutexGuard aGuard;
    1181             : 
    1182           0 :         CheckIndex(nIndex); // may throw IndexOutOfBoundsException
    1183             : 
    1184             :         // get default attribues...
    1185           0 :         ::comphelper::SequenceAsHashMap aPropHashMap( getDefaultAttributes( rRequestedAttributes ) );
    1186             : 
    1187             :         // ... and override them with the direct attributes from the specific position
    1188           0 :         uno::Sequence< beans::PropertyValue > aRunAttribs( getRunAttributes( nIndex, rRequestedAttributes ) );
    1189           0 :         sal_Int32 nRunAttribs = aRunAttribs.getLength();
    1190           0 :         const beans::PropertyValue *pRunAttrib = aRunAttribs.getConstArray();
    1191           0 :         for (sal_Int32 k = 0;  k < nRunAttribs;  ++k)
    1192             :         {
    1193           0 :             const beans::PropertyValue &rRunAttrib = pRunAttrib[k];
    1194           0 :             aPropHashMap[ rRunAttrib.Name ] = rRunAttrib.Value; //!! should not only be the value !!
    1195             :         }
    1196             : 
    1197             :         // get resulting sequence
    1198           0 :         uno::Sequence< beans::PropertyValue > aRes;
    1199           0 :         aPropHashMap >> aRes;
    1200             : 
    1201             :         // since SequenceAsHashMap ignores property handles and property state
    1202             :         // we have to restore the property state here (property handles are
    1203             :         // of no use to the accessibility API).
    1204           0 :         sal_Int32 nRes = aRes.getLength();
    1205           0 :         beans::PropertyValue *pRes = aRes.getArray();
    1206           0 :         for (sal_Int32 i = 0;  i < nRes;  ++i)
    1207             :         {
    1208           0 :             beans::PropertyValue &rRes = pRes[i];
    1209           0 :             sal_Bool bIsDirectVal = sal_False;
    1210           0 :             for (sal_Int32 k = 0;  k < nRunAttribs && !bIsDirectVal;  ++k)
    1211             :             {
    1212           0 :                 if (rRes.Name == pRunAttrib[k].Name)
    1213           0 :                     bIsDirectVal = sal_True;
    1214             :             }
    1215           0 :             rRes.Handle = -1;
    1216           0 :             rRes.State  = bIsDirectVal ? PropertyState_DIRECT_VALUE : PropertyState_DEFAULT_VALUE;
    1217             :         }
    1218             : 
    1219           0 :         return aRes;
    1220             :     }
    1221             : 
    1222           0 :     awt::Rectangle SAL_CALL AccessibleEditableTextPara::getCharacterBounds( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
    1223             :     {
    1224             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1225             : 
    1226           0 :         SolarMutexGuard aGuard;
    1227             : 
    1228             :         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
    1229             :                    "AccessibleEditableTextPara::getCharacterBounds: index value overflow");
    1230             : 
    1231             :         // #108900# Have position semantics now for nIndex, as
    1232             :         // one-past-the-end values are legal, too.
    1233           0 :         CheckPosition( nIndex );
    1234             : 
    1235           0 :         SvxTextForwarder& rCacheTF = GetTextForwarder();
    1236           0 :         Rectangle aRect = rCacheTF.GetCharBounds( static_cast< sal_uInt16 >( GetParagraphIndex() ), static_cast< sal_uInt16 >( nIndex ) );
    1237             : 
    1238             :         // convert to screen
    1239             :         Rectangle aScreenRect = AccessibleEditableTextPara::LogicToPixel( aRect,
    1240           0 :                                                                           rCacheTF.GetMapMode(),
    1241           0 :                                                                           GetViewForwarder() );
    1242             :         // #109864# offset from parent (paragraph), but in screen
    1243             :         // coordinates. This makes sure the internal text offset in
    1244             :         // the outline view forwarder gets cancelled out here
    1245           0 :         awt::Rectangle aParaRect( getBounds() );
    1246           0 :         aScreenRect.Move( -aParaRect.X, -aParaRect.Y );
    1247             : 
    1248             :         // offset from shape/cell
    1249           0 :         Point aOffset = GetEEOffset();
    1250             : 
    1251           0 :         return awt::Rectangle( aScreenRect.Left() + aOffset.X(),
    1252           0 :                                aScreenRect.Top() + aOffset.Y(),
    1253           0 :                                aScreenRect.GetSize().Width(),
    1254           0 :                                aScreenRect.GetSize().Height() );
    1255             :     }
    1256             : 
    1257           0 :     sal_Int32 SAL_CALL AccessibleEditableTextPara::getCharacterCount() throw (uno::RuntimeException)
    1258             :     {
    1259             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1260             : 
    1261           0 :         SolarMutexGuard aGuard;
    1262             : 
    1263             :         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
    1264             :                    "AccessibleEditableTextPara::getCharacterCount: index value overflow");
    1265             : 
    1266           0 :         return OCommonAccessibleText::getCharacterCount();
    1267             :     }
    1268             : 
    1269           0 :     sal_Int32 SAL_CALL AccessibleEditableTextPara::getIndexAtPoint( const awt::Point& rPoint ) throw (uno::RuntimeException)
    1270             :     {
    1271             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1272             : 
    1273           0 :         SolarMutexGuard aGuard;
    1274             : 
    1275             :         sal_uInt16 nPara, nIndex;
    1276             : 
    1277             :         // offset from surrounding cell/shape
    1278           0 :         Point aOffset( GetEEOffset() );
    1279           0 :         Point aPoint( rPoint.X - aOffset.X(), rPoint.Y - aOffset.Y() );
    1280             : 
    1281             :         // convert to logical coordinates
    1282           0 :         SvxTextForwarder& rCacheTF = GetTextForwarder();
    1283           0 :         Point aLogPoint( GetViewForwarder().PixelToLogic( aPoint, rCacheTF.GetMapMode() ) );
    1284             : 
    1285             :         // re-offset to parent (paragraph)
    1286           0 :         Rectangle aParaRect = rCacheTF.GetParaBounds( static_cast< sal_uInt16 >( GetParagraphIndex() ) );
    1287           0 :         aLogPoint.Move( aParaRect.Left(), aParaRect.Top() );
    1288             : 
    1289           0 :         if( rCacheTF.GetIndexAtPoint( aLogPoint, nPara, nIndex ) &&
    1290           0 :             GetParagraphIndex() == nPara )
    1291             :         {
    1292             :             // #102259# Double-check if we're _really_ on the given character
    1293             :             try
    1294             :             {
    1295           0 :                 awt::Rectangle aRect1( getCharacterBounds(nIndex) );
    1296             :                 Rectangle aRect2( aRect1.X, aRect1.Y,
    1297           0 :                                   aRect1.Width + aRect1.X, aRect1.Height + aRect1.Y );
    1298           0 :                 if( aRect2.IsInside( Point( rPoint.X, rPoint.Y ) ) )
    1299           0 :                     return nIndex;
    1300             :                 else
    1301           0 :                     return -1;
    1302             :             }
    1303           0 :             catch (const lang::IndexOutOfBoundsException&)
    1304             :             {
    1305             :                 // #103927# Don't throw for invalid nIndex values
    1306           0 :                 return -1;
    1307             :             }
    1308             :         }
    1309             :         else
    1310             :         {
    1311             :             // not within our paragraph
    1312           0 :             return -1;
    1313           0 :         }
    1314             :     }
    1315             : 
    1316           0 :     ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getSelectedText() throw (uno::RuntimeException)
    1317             :     {
    1318             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1319             : 
    1320           0 :         SolarMutexGuard aGuard;
    1321             : 
    1322             :         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
    1323             :                    "AccessibleEditableTextPara::getSelectedText: index value overflow");
    1324             : 
    1325           0 :         if( !HaveEditView() )
    1326           0 :             return ::rtl::OUString();
    1327             : 
    1328           0 :         return OCommonAccessibleText::getSelectedText();
    1329             :     }
    1330             : 
    1331           0 :     sal_Int32 SAL_CALL AccessibleEditableTextPara::getSelectionStart() throw (uno::RuntimeException)
    1332             :     {
    1333             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1334             : 
    1335           0 :         SolarMutexGuard aGuard;
    1336             : 
    1337             :         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
    1338             :                    "AccessibleEditableTextPara::getSelectionStart: index value overflow");
    1339             : 
    1340           0 :         if( !HaveEditView() )
    1341           0 :             return -1;
    1342             : 
    1343           0 :         return OCommonAccessibleText::getSelectionStart();
    1344             :     }
    1345             : 
    1346           0 :     sal_Int32 SAL_CALL AccessibleEditableTextPara::getSelectionEnd() throw (uno::RuntimeException)
    1347             :     {
    1348             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1349             : 
    1350           0 :         SolarMutexGuard aGuard;
    1351             : 
    1352             :         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
    1353             :                    "AccessibleEditableTextPara::getSelectionEnd: index value overflow");
    1354             : 
    1355           0 :         if( !HaveEditView() )
    1356           0 :             return -1;
    1357             : 
    1358           0 :         return OCommonAccessibleText::getSelectionEnd();
    1359             :     }
    1360             : 
    1361           0 :     sal_Bool SAL_CALL AccessibleEditableTextPara::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
    1362             :     {
    1363             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1364             : 
    1365           0 :         SolarMutexGuard aGuard;
    1366             : 
    1367             :         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
    1368             :                    "AccessibleEditableTextPara::setSelection: paragraph index value overflow");
    1369             : 
    1370           0 :         CheckRange(nStartIndex, nEndIndex);
    1371             : 
    1372             :         try
    1373             :         {
    1374           0 :             SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_True );
    1375           0 :             return rCacheVF.SetSelection( MakeSelection(nStartIndex, nEndIndex) );
    1376             :         }
    1377           0 :         catch (const uno::RuntimeException&)
    1378             :         {
    1379           0 :             return sal_False;
    1380           0 :         }
    1381             :     }
    1382             : 
    1383           0 :     ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getText() throw (uno::RuntimeException)
    1384             :     {
    1385             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1386             : 
    1387           0 :         SolarMutexGuard aGuard;
    1388             : 
    1389             :         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
    1390             :                    "AccessibleEditableTextPara::getText: paragraph index value overflow");
    1391             : 
    1392           0 :         return OCommonAccessibleText::getText();
    1393             :     }
    1394             : 
    1395           0 :     ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
    1396             :     {
    1397             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1398             : 
    1399           0 :         SolarMutexGuard aGuard;
    1400             : 
    1401             :         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
    1402             :                    "AccessibleEditableTextPara::getTextRange: paragraph index value overflow");
    1403             : 
    1404           0 :         return OCommonAccessibleText::getTextRange(nStartIndex, nEndIndex);
    1405             :     }
    1406             : 
    1407           0 :     ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
    1408             :     {
    1409             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1410             : 
    1411           0 :         SolarMutexGuard aGuard;
    1412             : 
    1413             :         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
    1414             :                    "AccessibleEditableTextPara::getTextAtIndex: paragraph index value overflow");
    1415             : 
    1416           0 :         ::com::sun::star::accessibility::TextSegment aResult;
    1417           0 :         aResult.SegmentStart = -1;
    1418           0 :         aResult.SegmentEnd = -1;
    1419             : 
    1420           0 :         switch( aTextType )
    1421             :         {
    1422             :             // Not yet handled by OCommonAccessibleText. Missing
    1423             :             // implGetAttributeRunBoundary() method there
    1424             :             case AccessibleTextType::ATTRIBUTE_RUN:
    1425             :             {
    1426           0 :                 const sal_Int32 nTextLen = GetTextForwarder().GetTextLen( static_cast< sal_uInt16 >( GetParagraphIndex() ) );
    1427             : 
    1428           0 :                 if( nIndex == nTextLen )
    1429             :                 {
    1430             :                     // #i17014# Special-casing one-behind-the-end character
    1431           0 :                     aResult.SegmentStart = aResult.SegmentEnd = nTextLen;
    1432             :                 }
    1433             :                 else
    1434             :                 {
    1435             :                     sal_uInt16 nStartIndex, nEndIndex;
    1436             : 
    1437           0 :                     if( GetAttributeRun(nStartIndex, nEndIndex, nIndex) )
    1438             :                     {
    1439           0 :                         aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex);
    1440           0 :                         aResult.SegmentStart = nStartIndex;
    1441           0 :                         aResult.SegmentEnd = nEndIndex;
    1442             :                     }
    1443             :                 }
    1444           0 :                 break;
    1445             :             }
    1446             : 
    1447             :             default:
    1448           0 :                 aResult = OCommonAccessibleText::getTextAtIndex( nIndex, aTextType );
    1449           0 :                 break;
    1450             :         } /* end of switch( aTextType ) */
    1451             : 
    1452           0 :         return aResult;
    1453             :     }
    1454             : 
    1455           0 :     ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
    1456             :     {
    1457             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1458             : 
    1459           0 :         SolarMutexGuard aGuard;
    1460             : 
    1461             :         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
    1462             :                    "AccessibleEditableTextPara::getTextBeforeIndex: paragraph index value overflow");
    1463             : 
    1464           0 :         ::com::sun::star::accessibility::TextSegment aResult;
    1465           0 :         aResult.SegmentStart = -1;
    1466           0 :         aResult.SegmentEnd = -1;
    1467             : 
    1468           0 :         switch( aTextType )
    1469             :         {
    1470             :             // Not yet handled by OCommonAccessibleText. Missing
    1471             :             // implGetAttributeRunBoundary() method there
    1472             :             case AccessibleTextType::ATTRIBUTE_RUN:
    1473             :             {
    1474           0 :                 const sal_Int32 nTextLen = GetTextForwarder().GetTextLen( static_cast< sal_uInt16 >( GetParagraphIndex() ) );
    1475             :                 sal_uInt16 nStartIndex, nEndIndex;
    1476             : 
    1477           0 :                 if( nIndex == nTextLen )
    1478             :                 {
    1479             :                     // #i17014# Special-casing one-behind-the-end character
    1480           0 :                     if( nIndex > 0 &&
    1481           0 :                         GetAttributeRun(nStartIndex, nEndIndex, nIndex-1) )
    1482             :                     {
    1483           0 :                         aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex);
    1484           0 :                         aResult.SegmentStart = nStartIndex;
    1485           0 :                         aResult.SegmentEnd = nEndIndex;
    1486             :                     }
    1487             :                 }
    1488             :                 else
    1489             :                 {
    1490           0 :                     if( GetAttributeRun(nStartIndex, nEndIndex, nIndex) )
    1491             :                     {
    1492             :                         // already at the left border? If not, query
    1493             :                         // one index further left
    1494           0 :                         if( nStartIndex > 0 &&
    1495           0 :                             GetAttributeRun(nStartIndex, nEndIndex, nStartIndex-1) )
    1496             :                         {
    1497           0 :                             aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex);
    1498           0 :                             aResult.SegmentStart = nStartIndex;
    1499           0 :                             aResult.SegmentEnd = nEndIndex;
    1500             :                         }
    1501             :                     }
    1502             :                 }
    1503             :                 break;
    1504             :             }
    1505             : 
    1506             :             default:
    1507           0 :                 aResult = OCommonAccessibleText::getTextBeforeIndex( nIndex, aTextType );
    1508           0 :                 break;
    1509             :         } /* end of switch( aTextType ) */
    1510             : 
    1511           0 :         return aResult;
    1512             :     }
    1513             : 
    1514           0 :     ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
    1515             :     {
    1516             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1517             : 
    1518           0 :         SolarMutexGuard aGuard;
    1519             : 
    1520             :         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
    1521             :                    "AccessibleEditableTextPara::getTextBehindIndex: paragraph index value overflow");
    1522             : 
    1523           0 :         ::com::sun::star::accessibility::TextSegment aResult;
    1524           0 :         aResult.SegmentStart = -1;
    1525           0 :         aResult.SegmentEnd = -1;
    1526             : 
    1527           0 :         switch( aTextType )
    1528             :         {
    1529             :             case AccessibleTextType::ATTRIBUTE_RUN:
    1530             :             {
    1531             :                 sal_uInt16 nStartIndex, nEndIndex;
    1532             : 
    1533           0 :                 if( GetAttributeRun(nStartIndex, nEndIndex, nIndex) )
    1534             :                 {
    1535             :                     // already at the right border?
    1536           0 :                     if( nEndIndex < GetTextLen() )
    1537             :                     {
    1538           0 :                         if( GetAttributeRun(nStartIndex, nEndIndex, nEndIndex) )
    1539             :                         {
    1540           0 :                             aResult.SegmentText = GetTextRange(nStartIndex, nEndIndex);
    1541           0 :                             aResult.SegmentStart = nStartIndex;
    1542           0 :                             aResult.SegmentEnd = nEndIndex;
    1543             :                         }
    1544             :                     }
    1545             :                 }
    1546             :                 break;
    1547             :             }
    1548             : 
    1549             :             default:
    1550           0 :                 aResult = OCommonAccessibleText::getTextBehindIndex( nIndex, aTextType );
    1551           0 :                 break;
    1552             :         } /* end of switch( aTextType ) */
    1553             : 
    1554           0 :         return aResult;
    1555             :     }
    1556             : 
    1557           0 :     sal_Bool SAL_CALL AccessibleEditableTextPara::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
    1558             :     {
    1559             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1560             : 
    1561           0 :         SolarMutexGuard aGuard;
    1562             : 
    1563             :         try
    1564             :         {
    1565           0 :             SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_True );
    1566             :             #if OSL_DEBUG_LEVEL > 0
    1567             :             SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder();    // MUST be after GetEditViewForwarder(), see method docs
    1568             :             (void)rCacheTF;
    1569             :             #else
    1570           0 :             GetTextForwarder();                                         // MUST be after GetEditViewForwarder(), see method docs
    1571             :             #endif
    1572             : 
    1573             :             sal_Bool aRetVal;
    1574             : 
    1575             :             DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
    1576             :                        "AccessibleEditableTextPara::copyText: index value overflow");
    1577             : 
    1578           0 :             CheckRange(nStartIndex, nEndIndex);
    1579             : 
    1580             :             // save current selection
    1581           0 :             ESelection aOldSelection;
    1582             : 
    1583           0 :             rCacheVF.GetSelection( aOldSelection );
    1584           0 :             rCacheVF.SetSelection( MakeSelection(nStartIndex, nEndIndex) );
    1585           0 :             aRetVal = rCacheVF.Copy();
    1586           0 :             rCacheVF.SetSelection( aOldSelection ); // restore
    1587             : 
    1588           0 :             return aRetVal;
    1589             :         }
    1590           0 :         catch (const uno::RuntimeException&)
    1591             :         {
    1592           0 :             return sal_False;
    1593           0 :         }
    1594             :     }
    1595             : 
    1596             :     // XAccessibleEditableText
    1597           0 :     sal_Bool SAL_CALL AccessibleEditableTextPara::cutText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
    1598             :     {
    1599             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1600             : 
    1601           0 :         SolarMutexGuard aGuard;
    1602             : 
    1603             :         try
    1604             :         {
    1605           0 :             SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_True );
    1606           0 :             SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder();    // MUST be after GetEditViewForwarder(), see method docs
    1607             : 
    1608             :             DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
    1609             :                        "AccessibleEditableTextPara::cutText: index value overflow");
    1610             : 
    1611           0 :             CheckRange(nStartIndex, nEndIndex);
    1612             : 
    1613           0 :             if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) )
    1614           0 :                 return sal_False; // non-editable area selected
    1615             : 
    1616             :             // don't save selection, might become invalid after cut!
    1617           0 :             rCacheVF.SetSelection( MakeSelection(nStartIndex, nEndIndex) );
    1618             : 
    1619           0 :             return rCacheVF.Cut();
    1620             :         }
    1621           0 :         catch (const uno::RuntimeException&)
    1622             :         {
    1623           0 :             return sal_False;
    1624           0 :         }
    1625             :     }
    1626             : 
    1627           0 :     sal_Bool SAL_CALL AccessibleEditableTextPara::pasteText( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
    1628             :     {
    1629             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1630             : 
    1631           0 :         SolarMutexGuard aGuard;
    1632             : 
    1633             :         try
    1634             :         {
    1635           0 :             SvxEditViewForwarder& rCacheVF = GetEditViewForwarder( sal_True );
    1636           0 :             SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder();    // MUST be after GetEditViewForwarder(), see method docs
    1637             : 
    1638             :             DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
    1639             :                        "AccessibleEditableTextPara::pasteText: index value overflow");
    1640             : 
    1641           0 :             CheckPosition(nIndex);
    1642             : 
    1643           0 :             if( !rCacheTF.IsEditable( MakeSelection(nIndex) ) )
    1644           0 :                 return sal_False; // non-editable area selected
    1645             : 
    1646             :             // #104400# set empty selection (=> cursor) to given index
    1647           0 :             rCacheVF.SetSelection( MakeCursor(nIndex) );
    1648             : 
    1649           0 :             return rCacheVF.Paste();
    1650             :         }
    1651           0 :         catch (const uno::RuntimeException&)
    1652             :         {
    1653           0 :             return sal_False;
    1654           0 :         }
    1655             :     }
    1656             : 
    1657           0 :     sal_Bool SAL_CALL AccessibleEditableTextPara::deleteText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
    1658             :     {
    1659             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1660             : 
    1661           0 :         SolarMutexGuard aGuard;
    1662             : 
    1663             :         try
    1664             :         {
    1665             :             // #102710# Request edit view when doing changes
    1666             :             // AccessibleEmptyEditSource relies on this behaviour
    1667           0 :             GetEditViewForwarder( sal_True );
    1668           0 :             SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder();    // MUST be after GetEditViewForwarder(), see method docs
    1669             : 
    1670             :             DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
    1671             :                        "AccessibleEditableTextPara::deleteText: index value overflow");
    1672             : 
    1673           0 :             CheckRange(nStartIndex, nEndIndex);
    1674             : 
    1675           0 :             if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) )
    1676           0 :                 return sal_False; // non-editable area selected
    1677             : 
    1678           0 :             sal_Bool bRet = rCacheTF.Delete( MakeSelection(nStartIndex, nEndIndex) );
    1679             : 
    1680           0 :             GetEditSource().UpdateData();
    1681             : 
    1682           0 :             return bRet;
    1683             :         }
    1684           0 :         catch (const uno::RuntimeException&)
    1685             :         {
    1686           0 :             return sal_False;
    1687           0 :         }
    1688             :     }
    1689             : 
    1690           0 :     sal_Bool SAL_CALL AccessibleEditableTextPara::insertText( const ::rtl::OUString& sText, sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
    1691             :     {
    1692             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1693             : 
    1694           0 :         SolarMutexGuard aGuard;
    1695             : 
    1696             :         try
    1697             :         {
    1698             :             // #102710# Request edit view when doing changes
    1699             :             // AccessibleEmptyEditSource relies on this behaviour
    1700           0 :             GetEditViewForwarder( sal_True );
    1701           0 :             SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder();    // MUST be after GetEditViewForwarder(), see method docs
    1702             : 
    1703             :             DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
    1704             :                        "AccessibleEditableTextPara::insertText: index value overflow");
    1705             : 
    1706           0 :             CheckPosition(nIndex);
    1707             : 
    1708           0 :             if( !rCacheTF.IsEditable( MakeSelection(nIndex) ) )
    1709           0 :                 return sal_False; // non-editable area selected
    1710             : 
    1711             :             // #104400# insert given text at empty selection (=> cursor)
    1712           0 :             sal_Bool bRet = rCacheTF.InsertText( sText, MakeCursor(nIndex) );
    1713             : 
    1714           0 :             rCacheTF.QuickFormatDoc();
    1715           0 :             GetEditSource().UpdateData();
    1716             : 
    1717           0 :             return bRet;
    1718             :         }
    1719           0 :         catch (const uno::RuntimeException&)
    1720             :         {
    1721           0 :             return sal_False;
    1722           0 :         }
    1723             :     }
    1724             : 
    1725           0 :     sal_Bool SAL_CALL AccessibleEditableTextPara::replaceText( sal_Int32 nStartIndex, sal_Int32 nEndIndex, const ::rtl::OUString& sReplacement ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
    1726             :     {
    1727             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1728             : 
    1729           0 :         SolarMutexGuard aGuard;
    1730             : 
    1731             :         try
    1732             :         {
    1733             :             // #102710# Request edit view when doing changes
    1734             :             // AccessibleEmptyEditSource relies on this behaviour
    1735           0 :             GetEditViewForwarder( sal_True );
    1736           0 :             SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder();    // MUST be after GetEditViewForwarder(), see method docs
    1737             : 
    1738             :             DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
    1739             :                        "AccessibleEditableTextPara::replaceText: index value overflow");
    1740             : 
    1741           0 :             CheckRange(nStartIndex, nEndIndex);
    1742             : 
    1743           0 :             if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) )
    1744           0 :                 return sal_False; // non-editable area selected
    1745             : 
    1746             :             // insert given text into given range => replace
    1747           0 :             sal_Bool bRet = rCacheTF.InsertText( sReplacement, MakeSelection(nStartIndex, nEndIndex) );
    1748             : 
    1749           0 :             rCacheTF.QuickFormatDoc();
    1750           0 :             GetEditSource().UpdateData();
    1751             : 
    1752           0 :             return bRet;
    1753             :         }
    1754           0 :         catch (const uno::RuntimeException&)
    1755             :         {
    1756           0 :             return sal_False;
    1757           0 :         }
    1758             :     }
    1759             : 
    1760           0 :     sal_Bool SAL_CALL AccessibleEditableTextPara::setAttributes( sal_Int32 nStartIndex, sal_Int32 nEndIndex, const uno::Sequence< beans::PropertyValue >& aAttributeSet ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
    1761             :     {
    1762             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1763             : 
    1764           0 :         SolarMutexGuard aGuard;
    1765             : 
    1766             :         try
    1767             :         {
    1768             :             // #102710# Request edit view when doing changes
    1769             :             // AccessibleEmptyEditSource relies on this behaviour
    1770           0 :             GetEditViewForwarder( sal_True );
    1771           0 :             SvxAccessibleTextAdapter& rCacheTF = GetTextForwarder();    // MUST be after GetEditViewForwarder(), see method docs
    1772           0 :             sal_uInt16 nPara = static_cast< sal_uInt16 >( GetParagraphIndex() );
    1773             : 
    1774             :             DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
    1775             :                        "AccessibleEditableTextPara::setAttributes: index value overflow");
    1776             : 
    1777           0 :             CheckRange(nStartIndex, nEndIndex);
    1778             : 
    1779           0 :             if( !rCacheTF.IsEditable( MakeSelection(nStartIndex, nEndIndex) ) )
    1780           0 :                 return sal_False; // non-editable area selected
    1781             : 
    1782             :             // do the indices span the whole paragraph? Then use the outliner map
    1783             :             // TODO: hold it as a member?
    1784           0 :             SvxAccessibleTextPropertySet aPropSet( &GetEditSource(),
    1785             :                                                    0 == nStartIndex &&
    1786           0 :                                                    rCacheTF.GetTextLen(nPara) == nEndIndex ?
    1787             :                                                    ImplGetSvxUnoOutlinerTextCursorSvxPropertySet() :
    1788           0 :                                                    ImplGetSvxTextPortionSvxPropertySet() );
    1789             : 
    1790           0 :             aPropSet.SetSelection( MakeSelection(nStartIndex, nEndIndex) );
    1791             : 
    1792             :             // convert from PropertyValue to Any
    1793           0 :             sal_Int32 i, nLength( aAttributeSet.getLength() );
    1794           0 :             const beans::PropertyValue* pPropArray = aAttributeSet.getConstArray();
    1795           0 :             for(i=0; i<nLength; ++i)
    1796             :             {
    1797             :                 try
    1798             :                 {
    1799           0 :                     aPropSet.setPropertyValue(pPropArray->Name, pPropArray->Value);
    1800             :                 }
    1801           0 :                 catch (const uno::Exception&)
    1802             :                 {
    1803             :                     OSL_FAIL("AccessibleEditableTextPara::setAttributes exception in setPropertyValue");
    1804             :                 }
    1805             : 
    1806           0 :                 ++pPropArray;
    1807             :             }
    1808             : 
    1809           0 :             rCacheTF.QuickFormatDoc();
    1810           0 :             GetEditSource().UpdateData();
    1811             : 
    1812           0 :             return sal_True;
    1813             :         }
    1814           0 :         catch (const uno::RuntimeException&)
    1815             :         {
    1816           0 :             return sal_False;
    1817           0 :         }
    1818             :     }
    1819             : 
    1820           0 :     sal_Bool SAL_CALL AccessibleEditableTextPara::setText( const ::rtl::OUString& sText ) throw (uno::RuntimeException)
    1821             :     {
    1822             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1823             : 
    1824           0 :         SolarMutexGuard aGuard;
    1825             : 
    1826           0 :         return replaceText(0, getCharacterCount(), sText);
    1827             :     }
    1828             : 
    1829             :     // XAccessibleTextAttributes
    1830           0 :     uno::Sequence< beans::PropertyValue > SAL_CALL AccessibleEditableTextPara::getDefaultAttributes(
    1831             :             const uno::Sequence< ::rtl::OUString >& rRequestedAttributes )
    1832             :         throw (uno::RuntimeException)
    1833             :     {
    1834             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1835           0 :         SolarMutexGuard aGuard;
    1836             : 
    1837             :         #if OSL_DEBUG_LEVEL > 0
    1838             :         SvxAccessibleTextAdapter& rCacheTF =
    1839             :         #endif
    1840           0 :             GetTextForwarder();
    1841             : 
    1842             :         #if OSL_DEBUG_LEVEL > 0
    1843             :         (void)rCacheTF;
    1844             :         #endif
    1845             : 
    1846             :         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
    1847             :                    "AccessibleEditableTextPara::getCharacterAttributes: index value overflow");
    1848             : 
    1849             :         // get XPropertySetInfo for paragraph attributes and
    1850             :         // character attributes that span all the paragraphs text.
    1851           0 :         SvxAccessibleTextPropertySet aPropSet( &GetEditSource(),
    1852           0 :                 ImplGetSvxCharAndParaPropertiesSet() );
    1853           0 :         aPropSet.SetSelection( MakeSelection( 0, GetTextLen() ) );
    1854           0 :         uno::Reference< beans::XPropertySetInfo > xPropSetInfo = aPropSet.getPropertySetInfo();
    1855           0 :         if (!xPropSetInfo.is())
    1856             :             throw uno::RuntimeException(::rtl::OUString("Cannot query XPropertySetInfo"),
    1857             :                         uno::Reference< uno::XInterface >
    1858           0 :                         ( static_cast< XAccessible* > (this) ) );   // disambiguate hierarchy
    1859             : 
    1860             :         // build sequence of available properties to check
    1861           0 :         sal_Int32 nLenReqAttr = rRequestedAttributes.getLength();
    1862           0 :         uno::Sequence< beans::Property > aProperties;
    1863           0 :         if (nLenReqAttr)
    1864             :         {
    1865           0 :             const rtl::OUString *pRequestedAttributes = rRequestedAttributes.getConstArray();
    1866             : 
    1867           0 :             aProperties.realloc( nLenReqAttr );
    1868           0 :             beans::Property *pProperties = aProperties.getArray();
    1869           0 :             sal_Int32 nCurLen = 0;
    1870           0 :             for (sal_Int32 i = 0;  i < nLenReqAttr;  ++i)
    1871             :             {
    1872           0 :                 beans::Property aProp;
    1873             :                 try
    1874             :                 {
    1875           0 :                     aProp = xPropSetInfo->getPropertyByName( pRequestedAttributes[i] );
    1876             :                 }
    1877           0 :                 catch (const beans::UnknownPropertyException&)
    1878             :                 {
    1879           0 :                     continue;
    1880             :                 }
    1881           0 :                 pProperties[ nCurLen++ ] = aProp;
    1882           0 :             }
    1883           0 :             aProperties.realloc( nCurLen );
    1884             :         }
    1885             :         else
    1886           0 :             aProperties = xPropSetInfo->getProperties();
    1887             : 
    1888           0 :         sal_Int32 nLength = aProperties.getLength();
    1889           0 :         const beans::Property *pProperties = aProperties.getConstArray();
    1890             : 
    1891             :         // build resulting sequence
    1892           0 :         uno::Sequence< beans::PropertyValue > aOutSequence( nLength );
    1893           0 :         beans::PropertyValue* pOutSequence = aOutSequence.getArray();
    1894           0 :         sal_Int32 nOutLen = 0;
    1895           0 :         for (sal_Int32 i = 0;  i < nLength;  ++i)
    1896             :         {
    1897             :             // calling implementation functions:
    1898             :             // _getPropertyState and _getPropertyValue (see below) to provide
    1899             :             // the proper paragraph number when retrieving paragraph attributes
    1900           0 :             PropertyState eState = aPropSet._getPropertyState( pProperties->Name, mnParagraphIndex );
    1901             :             if ( eState == PropertyState_AMBIGUOUS_VALUE )
    1902             :             {
    1903             :                 OSL_FAIL( "ambiguous property value encountered" );
    1904             :             }
    1905             : 
    1906             :             //if (eState == PropertyState_DIRECT_VALUE)
    1907             :             // per definition all paragraph properties and all character
    1908             :             // properties spanning the whole paragraph should be returned
    1909             :             // and declared as default value
    1910             :             {
    1911           0 :                 pOutSequence->Name      = pProperties->Name;
    1912           0 :                 pOutSequence->Handle    = pProperties->Handle;
    1913           0 :                 pOutSequence->Value     = aPropSet._getPropertyValue( pProperties->Name, mnParagraphIndex );
    1914           0 :                 pOutSequence->State     = PropertyState_DEFAULT_VALUE;
    1915             : 
    1916           0 :                 ++pOutSequence;
    1917           0 :                 ++nOutLen;
    1918             :             }
    1919           0 :             ++pProperties;
    1920             :         }
    1921           0 :         aOutSequence.realloc( nOutLen );
    1922             : 
    1923           0 :         return aOutSequence;
    1924             :     }
    1925             : 
    1926             : 
    1927           0 :     uno::Sequence< beans::PropertyValue > SAL_CALL AccessibleEditableTextPara::getRunAttributes(
    1928             :             sal_Int32 nIndex,
    1929             :             const uno::Sequence< ::rtl::OUString >& rRequestedAttributes )
    1930             :         throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
    1931             :     {
    1932             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    1933             : 
    1934           0 :         SolarMutexGuard aGuard;
    1935             : 
    1936             :         #if OSL_DEBUG_LEVEL > 0
    1937             :         SvxAccessibleTextAdapter& rCacheTF =
    1938             :         #endif
    1939           0 :             GetTextForwarder();
    1940             : 
    1941             :         #if OSL_DEBUG_LEVEL > 0
    1942             :         (void)rCacheTF;
    1943             :         #endif
    1944             : 
    1945             :         DBG_ASSERT(GetParagraphIndex() >= 0 && GetParagraphIndex() <= USHRT_MAX,
    1946             :                    "AccessibleEditableTextPara::getCharacterAttributes: index value overflow");
    1947             : 
    1948           0 :         CheckIndex(nIndex);
    1949             : 
    1950           0 :         SvxAccessibleTextPropertySet aPropSet( &GetEditSource(),
    1951           0 :                                                ImplGetSvxCharAndParaPropertiesSet() );
    1952           0 :         aPropSet.SetSelection( MakeSelection( nIndex ) );
    1953           0 :         uno::Reference< beans::XPropertySetInfo > xPropSetInfo = aPropSet.getPropertySetInfo();
    1954           0 :         if (!xPropSetInfo.is())
    1955             :             throw uno::RuntimeException(::rtl::OUString("Cannot query XPropertySetInfo"),
    1956             :                                         uno::Reference< uno::XInterface >
    1957           0 :                                         ( static_cast< XAccessible* > (this) ) );   // disambiguate hierarchy
    1958             : 
    1959             :         // build sequence of available properties to check
    1960           0 :         sal_Int32 nLenReqAttr = rRequestedAttributes.getLength();
    1961           0 :         uno::Sequence< beans::Property > aProperties;
    1962           0 :         if (nLenReqAttr)
    1963             :         {
    1964           0 :             const rtl::OUString *pRequestedAttributes = rRequestedAttributes.getConstArray();
    1965             : 
    1966           0 :             aProperties.realloc( nLenReqAttr );
    1967           0 :             beans::Property *pProperties = aProperties.getArray();
    1968           0 :             sal_Int32 nCurLen = 0;
    1969           0 :             for (sal_Int32 i = 0;  i < nLenReqAttr;  ++i)
    1970             :             {
    1971           0 :                 beans::Property aProp;
    1972             :                 try
    1973             :                 {
    1974           0 :                     aProp = xPropSetInfo->getPropertyByName( pRequestedAttributes[i] );
    1975             :                 }
    1976           0 :                 catch (const beans::UnknownPropertyException&)
    1977             :                 {
    1978           0 :                     continue;
    1979             :                 }
    1980           0 :                 pProperties[ nCurLen++ ] = aProp;
    1981           0 :             }
    1982           0 :             aProperties.realloc( nCurLen );
    1983             :         }
    1984             :         else
    1985           0 :             aProperties = xPropSetInfo->getProperties();
    1986             : 
    1987           0 :         sal_Int32 nLength = aProperties.getLength();
    1988           0 :         const beans::Property *pProperties = aProperties.getConstArray();
    1989             : 
    1990             :         // build resulting sequence
    1991           0 :         uno::Sequence< beans::PropertyValue > aOutSequence( nLength );
    1992           0 :         beans::PropertyValue* pOutSequence = aOutSequence.getArray();
    1993           0 :         sal_Int32 nOutLen = 0;
    1994           0 :         for (sal_Int32 i = 0;  i < nLength;  ++i)
    1995             :         {
    1996             :             // calling 'regular' functions that will operate on the selection
    1997           0 :             PropertyState eState = aPropSet.getPropertyState( pProperties->Name );
    1998           0 :             if (eState == PropertyState_DIRECT_VALUE)
    1999             :             {
    2000           0 :                 pOutSequence->Name      = pProperties->Name;
    2001           0 :                 pOutSequence->Handle    = pProperties->Handle;
    2002           0 :                 pOutSequence->Value     = aPropSet.getPropertyValue( pProperties->Name );
    2003           0 :                 pOutSequence->State     = eState;
    2004             : 
    2005           0 :                 ++pOutSequence;
    2006           0 :                 ++nOutLen;
    2007             :             }
    2008           0 :             ++pProperties;
    2009             :         }
    2010           0 :         aOutSequence.realloc( nOutLen );
    2011             : 
    2012           0 :         return aOutSequence;
    2013             :     }
    2014             : 
    2015             :     // XAccessibleHypertext
    2016           0 :     ::sal_Int32 SAL_CALL AccessibleEditableTextPara::getHyperLinkCount(  ) throw (::com::sun::star::uno::RuntimeException)
    2017             :     {
    2018           0 :         SvxAccessibleTextAdapter& rT = GetTextForwarder();
    2019           0 :         const sal_Int32 nPara = GetParagraphIndex();
    2020             : 
    2021           0 :         sal_uInt16 nHyperLinks = 0;
    2022           0 :         sal_uInt16 nFields = rT.GetFieldCount( nPara );
    2023           0 :         for ( sal_uInt16 n = 0; n < nFields; n++ )
    2024             :         {
    2025           0 :             EFieldInfo aField = rT.GetFieldInfo( nPara, n );
    2026           0 :             if ( aField.pFieldItem->GetField()->ISA( SvxURLField ) )
    2027           0 :                 nHyperLinks++;
    2028           0 :         }
    2029           0 :         return nHyperLinks;
    2030             :     }
    2031             : 
    2032           0 :     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleHyperlink > SAL_CALL AccessibleEditableTextPara::getHyperLink( ::sal_Int32 nLinkIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
    2033             :     {
    2034           0 :         ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleHyperlink > xRef;
    2035             : 
    2036           0 :         SvxAccessibleTextAdapter& rT = GetTextForwarder();
    2037           0 :         const sal_Int32 nPara = GetParagraphIndex();
    2038             : 
    2039           0 :         sal_uInt16 nHyperLink = 0;
    2040           0 :         sal_uInt16 nFields = rT.GetFieldCount( nPara );
    2041           0 :         for ( sal_uInt16 n = 0; n < nFields; n++ )
    2042             :         {
    2043           0 :             EFieldInfo aField = rT.GetFieldInfo( nPara, n );
    2044           0 :             if ( aField.pFieldItem->GetField()->ISA( SvxURLField ) )
    2045             :             {
    2046           0 :                 if ( nHyperLink == nLinkIndex )
    2047             :                 {
    2048           0 :                     sal_uInt16 nEEStart = aField.aPosition.nIndex;
    2049             : 
    2050             :                     // Translate EE Index to accessible index
    2051           0 :                     sal_uInt16 nStart = rT.CalcEditEngineIndex( nPara, nEEStart );
    2052           0 :                     sal_uInt16 nEnd = nStart + aField.aCurrentText.Len();
    2053           0 :                     xRef = new AccessibleHyperlink( rT, new SvxFieldItem( *aField.pFieldItem ), nPara, nEEStart, nStart, nEnd, aField.aCurrentText );
    2054             :                     break;
    2055             :                 }
    2056           0 :                 nHyperLink++;
    2057             :             }
    2058           0 :         }
    2059             : 
    2060           0 :         return xRef;
    2061             :     }
    2062             : 
    2063           0 :     ::sal_Int32 SAL_CALL AccessibleEditableTextPara::getHyperLinkIndex( ::sal_Int32 nCharIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
    2064             :     {
    2065           0 :         const sal_Int32 nPara = GetParagraphIndex();
    2066           0 :         SvxAccessibleTextAdapter& rT = GetTextForwarder();
    2067             : 
    2068             : //        SvxAccessibleTextIndex aIndex;
    2069             : //        aIndex.SetIndex(nPara, nCharIndex, rT);
    2070             : //        const sal_uInt16 nEEIndex = aIndex.GetEEIndex();
    2071             : 
    2072           0 :         const sal_uInt16 nEEIndex = rT.CalcEditEngineIndex( nPara, nCharIndex );
    2073           0 :         sal_Int32 nHLIndex = 0;
    2074           0 :         sal_uInt16 nHyperLink = 0;
    2075           0 :         sal_uInt16 nFields = rT.GetFieldCount( nPara );
    2076           0 :         for ( sal_uInt16 n = 0; n < nFields; n++ )
    2077             :         {
    2078           0 :             EFieldInfo aField = rT.GetFieldInfo( nPara, n );
    2079           0 :             if ( aField.pFieldItem->GetField()->ISA( SvxURLField ) )
    2080             :             {
    2081           0 :                 if ( aField.aPosition.nIndex == nEEIndex )
    2082             :                 {
    2083           0 :                     nHLIndex = nHyperLink;
    2084             :                     break;
    2085             :                 }
    2086           0 :                 nHyperLink++;
    2087             :             }
    2088           0 :         }
    2089             : 
    2090           0 :         return nHLIndex;
    2091             :     }
    2092             : 
    2093             :     // XAccessibleMultiLineText
    2094           0 :     sal_Int32 SAL_CALL AccessibleEditableTextPara::getLineNumberAtIndex( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
    2095             :     {
    2096             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    2097             : 
    2098           0 :         sal_Int32 nRes = -1;
    2099           0 :         sal_Int32 nPara = GetParagraphIndex();
    2100             : 
    2101           0 :         SvxTextForwarder &rCacheTF = GetTextForwarder();
    2102           0 :         const bool bValidPara = 0 <= nPara && nPara < rCacheTF.GetParagraphCount();
    2103             :         DBG_ASSERT( bValidPara, "getLineNumberAtIndex: current paragraph index out of range" );
    2104           0 :         if (bValidPara)
    2105             :         {
    2106             :             // we explicitly allow for the index to point at the character right behind the text
    2107           0 :             if (0 <= nIndex && nIndex <= rCacheTF.GetTextLen( static_cast< sal_uInt16 >(nPara) ))
    2108           0 :                 nRes = rCacheTF.GetLineNumberAtIndex( static_cast< sal_uInt16 >(nPara), static_cast< sal_uInt16 >(nIndex) );
    2109             :             else
    2110           0 :                 throw lang::IndexOutOfBoundsException();
    2111             :         }
    2112           0 :         return nRes;
    2113             :     }
    2114             : 
    2115             :     // XAccessibleMultiLineText
    2116           0 :     ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextAtLineNumber( sal_Int32 nLineNo ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
    2117             :     {
    2118             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    2119             : 
    2120           0 :         ::com::sun::star::accessibility::TextSegment aResult;
    2121           0 :         sal_Int32 nPara = GetParagraphIndex();
    2122           0 :         SvxTextForwarder &rCacheTF = GetTextForwarder();
    2123           0 :         const bool bValidPara = 0 <= nPara && nPara < rCacheTF.GetParagraphCount();
    2124             :         DBG_ASSERT( bValidPara, "getTextAtLineNumber: current paragraph index out of range" );
    2125           0 :         if (bValidPara)
    2126             :         {
    2127           0 :             if (0 <= nLineNo && nLineNo < rCacheTF.GetLineCount( static_cast< sal_uInt16 >(nPara) ))
    2128             :             {
    2129           0 :                 sal_uInt16 nStart = 0, nEnd = 0;
    2130           0 :                 rCacheTF.GetLineBoundaries( nStart, nEnd, static_cast< sal_uInt16 >(nPara), static_cast< sal_uInt16 >(nLineNo) );
    2131           0 :                 if (nStart != 0xFFFF && nEnd != 0xFFFF)
    2132             :                 {
    2133             :                     try
    2134             :                     {
    2135           0 :                         aResult.SegmentText     = getTextRange( nStart, nEnd );
    2136           0 :                         aResult.SegmentStart    = nStart;
    2137           0 :                         aResult.SegmentEnd      = nEnd;
    2138             :                     }
    2139           0 :                     catch (const lang::IndexOutOfBoundsException&)
    2140             :                     {
    2141             :                         // this is not the exception that should be raised in this function ...
    2142             :                         DBG_ASSERT( 0, "unexpected exception" );
    2143             :                     }
    2144             :                 }
    2145             :             }
    2146             :             else
    2147           0 :                 throw lang::IndexOutOfBoundsException();
    2148             :         }
    2149           0 :         return aResult;
    2150             :     }
    2151             : 
    2152             :     // XAccessibleMultiLineText
    2153           0 :     ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleEditableTextPara::getTextAtLineWithCaret(  ) throw (uno::RuntimeException)
    2154             :     {
    2155             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    2156             : 
    2157           0 :         ::com::sun::star::accessibility::TextSegment aResult;
    2158             :         try
    2159             :         {
    2160           0 :             aResult = getTextAtLineNumber( getNumberOfLineWithCaret() );
    2161             :         }
    2162           0 :         catch (const lang::IndexOutOfBoundsException&)
    2163             :         {
    2164             :             // this one needs to be catched since this interface does not allow for it.
    2165             :         }
    2166           0 :         return aResult;
    2167             :     }
    2168             : 
    2169             :     // XAccessibleMultiLineText
    2170           0 :     sal_Int32 SAL_CALL AccessibleEditableTextPara::getNumberOfLineWithCaret(  ) throw (uno::RuntimeException)
    2171             :     {
    2172             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    2173             : 
    2174           0 :         sal_Int32 nRes = -1;
    2175             :         try
    2176             :         {
    2177           0 :             nRes = getLineNumberAtIndex( getCaretPosition() );
    2178             :         }
    2179           0 :         catch (const lang::IndexOutOfBoundsException&)
    2180             :         {
    2181             :             // this one needs to be catched since this interface does not allow for it.
    2182             :         }
    2183           0 :         return nRes;
    2184             :     }
    2185             : 
    2186             : 
    2187             :     // XServiceInfo
    2188           0 :     ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getImplementationName (void) throw (uno::RuntimeException)
    2189             :     {
    2190             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    2191             : 
    2192           0 :         return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("AccessibleEditableTextPara"));
    2193             :     }
    2194             : 
    2195           0 :     sal_Bool SAL_CALL AccessibleEditableTextPara::supportsService (const ::rtl::OUString& sServiceName) throw (uno::RuntimeException)
    2196             :     {
    2197             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    2198             : 
    2199             :         //  Iterate over all supported service names and return true if on of them
    2200             :         //  matches the given name.
    2201             :         uno::Sequence< ::rtl::OUString> aSupportedServices (
    2202           0 :             getSupportedServiceNames ());
    2203           0 :         for (int i=0; i<aSupportedServices.getLength(); i++)
    2204           0 :             if (sServiceName == aSupportedServices[i])
    2205           0 :                 return sal_True;
    2206           0 :         return sal_False;
    2207             :     }
    2208             : 
    2209           0 :     uno::Sequence< ::rtl::OUString> SAL_CALL AccessibleEditableTextPara::getSupportedServiceNames (void) throw (uno::RuntimeException)
    2210             :     {
    2211             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    2212             : 
    2213           0 :         const ::rtl::OUString sServiceName( getServiceName() );
    2214           0 :         return uno::Sequence< ::rtl::OUString > (&sServiceName, 1);
    2215             :     }
    2216             : 
    2217             :     // XServiceName
    2218           0 :     ::rtl::OUString SAL_CALL AccessibleEditableTextPara::getServiceName (void) throw (uno::RuntimeException)
    2219             :     {
    2220             :         DBG_CHKTHIS( AccessibleEditableTextPara, NULL );
    2221             : 
    2222             :         // #105185# Using correct service now
    2223           0 :         return ::rtl::OUString("com.sun.star.text.AccessibleParagraphView");
    2224             :     }
    2225             : 
    2226             : }  // end of namespace accessibility
    2227             : 
    2228             : //------------------------------------------------------------------------
    2229             : 
    2230             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10