2010-10-12 15:53:47 +02:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2012-11-21 22:06:52 +00:00
/*
* This file is part of the LibreOffice project .
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License , v . 2.0 . If a copy of the MPL was not distributed with this
* file , You can obtain one at http : //mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice :
*
* Licensed to the Apache Software Foundation ( ASF ) under one or more
* contributor license agreements . See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership . The ASF licenses this file to you under the Apache
* License , Version 2.0 ( the " License " ) ; you may not use this file
* except in compliance with the License . You may obtain a copy of
* the License at http : //www.apache.org/licenses/LICENSE-2.0 .
*/
2002-05-16 15:12:20 +00:00
2006-09-17 03:03:45 +00:00
2002-05-16 15:12:20 +00:00
//------------------------------------------------------------------------
//
// Global header
//
//------------------------------------------------------------------------
# include <limits.h>
# include <memory>
# include <algorithm>
2002-12-12 11:36:51 +00:00
# include <deque>
2010-10-16 03:18:35 -05:00
# include <osl/mutex.hxx>
2002-05-16 15:12:20 +00:00
# include <com/sun/star/uno/Any.hxx>
# include <com/sun/star/uno/Reference.hxx>
# include <cppuhelper/weakref.hxx>
# include <com/sun/star/awt/Point.hpp>
# include <com/sun/star/awt/Rectangle.hpp>
2002-06-04 17:44:27 +00:00
# include <com/sun/star/lang/DisposedException.hpp>
2003-04-24 16:11:28 +00:00
# include <com/sun/star/accessibility/AccessibleEventId.hpp>
# include <com/sun/star/accessibility/XAccessible.hpp>
# include <com/sun/star/accessibility/XAccessibleContext.hpp>
# include <com/sun/star/accessibility/XAccessibleComponent.hpp>
# include <com/sun/star/accessibility/AccessibleStateType.hpp>
2003-03-27 14:06:05 +00:00
# include <comphelper/accessibleeventnotifier.hxx>
2002-05-16 15:12:20 +00:00
# include <unotools/accessiblestatesethelper.hxx>
2002-08-23 16:50:51 +00:00
# include <vcl/unohelp.hxx>
2006-11-14 12:12:51 +00:00
# include <vcl/svapp.hxx>
2002-05-16 15:12:20 +00:00
//------------------------------------------------------------------------
//
// Project-local header
//
//------------------------------------------------------------------------
2002-12-12 11:36:51 +00:00
# include "AccessibleTextEventQueue.hxx"
2007-06-27 15:40:25 +00:00
# include <svx/AccessibleTextHelper.hxx>
# include <svx/unoshape.hxx>
2010-01-07 18:52:36 +01:00
# include "editeng/unolingu.hxx"
# include <editeng/unotext.hxx>
2002-05-16 15:12:20 +00:00
2010-01-07 18:52:36 +01:00
# include "editeng/unoedhlp.hxx"
# include "editeng/unopracc.hxx"
# include "editeng/AccessibleParaManager.hxx"
# include "editeng/AccessibleEditableTextPara.hxx"
2007-06-27 15:40:25 +00:00
# include <svx/svdmodel.hxx>
# include <svx/svdpntv.hxx>
2010-01-07 18:52:36 +01:00
# include <editeng/editdata.hxx>
# include <editeng/editeng.hxx>
# include <editeng/editview.hxx>
2002-05-16 15:12:20 +00:00
using namespace : : com : : sun : : star ;
2003-04-24 16:11:28 +00:00
using namespace : : com : : sun : : star : : accessibility ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
namespace accessibility
{
2002-05-16 15:12:20 +00:00
//------------------------------------------------------------------------
//
2002-05-17 18:12:44 +00:00
// AccessibleTextHelper_Impl declaration
2002-05-16 15:12:20 +00:00
//
//------------------------------------------------------------------------
2003-03-27 14:06:05 +00:00
DBG_NAME ( AccessibleTextHelper_Impl )
2003-04-24 12:26:10 +00:00
template < typename first_type , typename second_type >
: : std : : pair < first_type , second_type > makeSortedPair ( first_type first ,
second_type second )
{
if ( first > second )
return : : std : : make_pair ( second , first ) ;
else
return : : std : : make_pair ( first , second ) ;
}
2002-05-17 18:12:44 +00:00
class AccessibleTextHelper_Impl : public SfxListener
{
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
public :
2006-01-13 16:18:22 +00:00
typedef : : std : : vector < sal_Int16 > VectorOfStates ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// receive pointer to our frontend class and view window
2002-06-26 10:38:03 +00:00
AccessibleTextHelper_Impl ( ) ;
2002-05-17 18:12:44 +00:00
~ AccessibleTextHelper_Impl ( ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// XAccessibleContext child handling methods
2002-06-26 10:38:03 +00:00
sal_Int32 SAL_CALL getAccessibleChildCount ( ) SAL_THROW ( ( uno : : RuntimeException ) ) ;
uno : : Reference < XAccessible > SAL_CALL getAccessibleChild ( sal_Int32 i ) SAL_THROW ( ( lang : : IndexOutOfBoundsException , uno : : RuntimeException ) ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// XAccessibleEventBroadcaster child related methods
2012-11-29 00:27:03 +01:00
void SAL_CALL addAccessibleEventListener ( const uno : : Reference < XAccessibleEventListener > & xListener ) SAL_THROW ( ( uno : : RuntimeException ) ) ;
void SAL_CALL removeAccessibleEventListener ( const uno : : Reference < XAccessibleEventListener > & xListener ) SAL_THROW ( ( uno : : RuntimeException ) ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// XAccessibleComponent child related methods
2003-04-24 16:11:28 +00:00
uno : : Reference < XAccessible > SAL_CALL getAccessibleAtPoint ( const awt : : Point & aPoint ) SAL_THROW ( ( uno : : RuntimeException ) ) ;
2002-05-16 15:12:20 +00:00
2002-06-26 10:38:03 +00:00
SvxEditSourceAdapter & GetEditSource ( ) const SAL_THROW ( ( uno : : RuntimeException ) ) ;
2011-09-22 15:00:08 +01:00
SAL_WNODEPRECATED_DECLARATIONS_PUSH
2002-06-26 10:38:03 +00:00
void SetEditSource ( : : std : : auto_ptr < SvxEditSource > pEditSource ) SAL_THROW ( ( uno : : RuntimeException ) ) ;
2011-09-22 15:00:08 +01:00
SAL_WNODEPRECATED_DECLARATIONS_POP
2002-06-26 10:38:03 +00:00
2003-03-27 14:06:05 +00:00
void SetEventSource ( const uno : : Reference < XAccessible > & rInterface )
{
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
mxFrontEnd = rInterface ;
}
uno : : Reference < XAccessible > GetEventSource ( ) const
{
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
return mxFrontEnd ;
}
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
void SetOffset ( const Point & ) ;
2003-03-27 14:06:05 +00:00
Point GetOffset ( ) const
{
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
: : osl : : MutexGuard aGuard ( maMutex ) ; Point aPoint ( maOffset ) ;
return aPoint ;
}
2002-05-16 15:12:20 +00:00
2002-06-26 10:38:03 +00:00
void SetStartIndex ( sal_Int32 nOffset ) ;
sal_Int32 GetStartIndex ( ) const
2002-06-07 11:19:53 +00:00
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
2002-06-07 11:19:53 +00:00
// Strictly correct only with locked solar mutex, // but
// here we rely on the fact that sal_Int32 access is
// atomic
return mnStartIndex ;
}
2002-05-23 11:46:18 +00:00
2006-01-13 16:18:22 +00:00
void SetAdditionalChildStates ( const VectorOfStates & rChildStates ) ;
2002-05-17 18:12:44 +00:00
sal_Bool IsSelected ( ) const ;
2002-05-16 15:12:20 +00:00
2002-06-26 10:38:03 +00:00
void Dispose ( ) ;
2002-05-17 18:12:44 +00:00
// do NOT hold object mutex when calling this! Danger of deadlock
void FireEvent ( const sal_Int16 nEventId , const uno : : Any & rNewValue = uno : : Any ( ) , const uno : : Any & rOldValue = uno : : Any ( ) ) const ;
2002-06-12 16:20:45 +00:00
void FireEvent ( const AccessibleEventObject & rEvent ) const ;
2002-05-16 15:12:20 +00:00
2002-06-26 10:38:03 +00:00
void SetFocus ( sal_Bool bHaveFocus ) SAL_THROW ( ( : : com : : sun : : star : : uno : : RuntimeException ) ) ;
sal_Bool HaveFocus ( ) SAL_THROW ( ( : : com : : sun : : star : : uno : : RuntimeException ) ) ;
void SetChildFocus ( sal_Int32 nChild , sal_Bool bHaveFocus ) SAL_THROW ( ( : : com : : sun : : star : : uno : : RuntimeException ) ) ;
void SetShapeFocus ( sal_Bool bHaveFocus ) SAL_THROW ( ( : : com : : sun : : star : : uno : : RuntimeException ) ) ;
void ChangeChildFocus ( sal_Int32 nNewChild ) SAL_THROW ( ( : : com : : sun : : star : : uno : : RuntimeException ) ) ;
2002-05-23 11:46:18 +00:00
2002-05-16 15:12:20 +00:00
# ifdef DBG_UTIL
2002-05-17 18:12:44 +00:00
void CheckInvariants ( ) const ;
2002-05-16 15:12:20 +00:00
# endif
2002-05-17 18:12:44 +00:00
// checks all children for visibility, throws away invisible ones
2002-12-12 11:36:51 +00:00
void UpdateVisibleChildren ( bool bBroadcastEvents = true ) ;
2002-05-16 15:12:20 +00:00
2010-11-09 01:42:14 +05:00
// check all children for changes in position and size
2002-08-02 10:35:10 +00:00
void UpdateBoundRect ( ) ;
2002-06-06 13:06:17 +00:00
2002-06-12 12:41:41 +00:00
// calls SetSelection on the forwarder and updates maLastSelection
// cache.
void UpdateSelection ( ) ;
2002-05-17 18:12:44 +00:00
private :
2002-05-16 15:12:20 +00:00
2002-12-12 11:36:51 +00:00
// Process event queue
void ProcessQueue ( ) ;
2002-05-17 18:12:44 +00:00
// syntactic sugar for FireEvent
void GotPropertyEvent ( const uno : : Any & rNewValue , const sal_Int16 nEventId ) const { FireEvent ( nEventId , rNewValue ) ; }
void LostPropertyEvent ( const uno : : Any & rOldValue , const sal_Int16 nEventId ) const { FireEvent ( nEventId , uno : : Any ( ) , rOldValue ) ; }
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// shutdown usage of current edit source on myself and the children.
2002-06-26 10:38:03 +00:00
void ShutdownEditSource ( ) SAL_THROW ( ( uno : : RuntimeException ) ) ;
2002-05-16 15:12:20 +00:00
2002-06-12 12:41:41 +00:00
void ParagraphsMoved ( sal_Int32 nFirst , sal_Int32 nMiddle , sal_Int32 nLast ) ;
2002-05-23 11:46:18 +00:00
2002-05-17 18:12:44 +00:00
virtual void Notify ( SfxBroadcaster & rBC , const SfxHint & rHint ) ;
2002-05-16 15:12:20 +00:00
2003-03-27 14:06:05 +00:00
int getNotifierClientId ( ) const { return mnNotifierClientId ; }
2002-05-17 18:12:44 +00:00
// lock solar mutex before
2002-06-26 10:38:03 +00:00
SvxTextForwarder & GetTextForwarder ( ) const SAL_THROW ( ( uno : : RuntimeException ) ) ;
2002-05-17 18:12:44 +00:00
// lock solar mutex before
2002-06-26 10:38:03 +00:00
SvxViewForwarder & GetViewForwarder ( ) const SAL_THROW ( ( uno : : RuntimeException ) ) ;
2002-05-17 18:12:44 +00:00
// lock solar mutex before
2002-06-26 10:38:03 +00:00
SvxEditViewForwarder & GetEditViewForwarder ( sal_Bool bCreate = sal_False ) const SAL_THROW ( ( uno : : RuntimeException ) ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// are we in edit mode?
2002-06-26 10:38:03 +00:00
sal_Bool IsActive ( ) const SAL_THROW ( ( uno : : RuntimeException ) ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// our frontend class (the one implementing the actual
// interface). That's not necessarily the one containing the impl
// pointer!
2002-06-26 10:38:03 +00:00
uno : : Reference < XAccessible > mxFrontEnd ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// a wrapper for the text forwarders (guarded by solar mutex)
mutable SvxEditSourceAdapter maEditSource ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// store last selection (to correctly report selection changes, guarded by solar mutex)
ESelection maLastSelection ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// cache range of visible children (guarded by solar mutex)
sal_Int32 mnFirstVisibleChild ;
sal_Int32 mnLastVisibleChild ;
2002-05-17 16:35:10 +00:00
2002-06-07 11:19:53 +00:00
// offset to add to all our children (unguarded, relying on
// the fact that sal_Int32 access is atomic)
2002-05-23 11:46:18 +00:00
sal_Int32 mnStartIndex ;
2002-05-17 18:12:44 +00:00
// the object handling our children (guarded by solar mutex)
2003-04-24 16:11:28 +00:00
: : accessibility : : AccessibleParaManager maParaManager ;
2002-05-16 15:12:20 +00:00
2002-12-12 11:36:51 +00:00
// number of not-yet-closed event frames (BEGIN/END sequences) (guarded by solar mutex)
sal_Int32 maEventOpenFrames ;
// Queued events from Notify() (guarded by solar mutex)
AccessibleTextEventQueue maEventQueue ;
2002-05-23 11:46:18 +00:00
// spin lock to prevent notify in notify (guarded by solar mutex)
2002-05-17 18:12:44 +00:00
sal_Bool mbInNotify ;
2002-05-16 15:12:20 +00:00
2002-06-04 17:44:27 +00:00
// whether the object or it's children has the focus set (guarded by solar mutex)
sal_Bool mbGroupHasFocus ;
// whether we (this object) has the focus set (guarded by solar mutex)
sal_Bool mbThisHasFocus ;
2002-05-23 11:46:18 +00:00
2002-05-17 18:12:44 +00:00
mutable : : osl : : Mutex maMutex ;
2002-05-16 15:12:20 +00:00
2002-06-07 11:19:53 +00:00
/// our current offset to the containing shape/cell (guarded by maMutex)
Point maOffset ;
2003-03-27 14:06:05 +00:00
/// client Id from AccessibleEventNotifier
int mnNotifierClientId ;
2002-05-17 18:12:44 +00:00
} ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
//------------------------------------------------------------------------
//
// AccessibleTextHelper_Impl implementation
//
//------------------------------------------------------------------------
2002-05-16 15:12:20 +00:00
2002-06-26 10:38:03 +00:00
AccessibleTextHelper_Impl : : AccessibleTextHelper_Impl ( ) :
mxFrontEnd ( NULL ) ,
2002-06-06 13:06:17 +00:00
maLastSelection ( EE_PARA_NOT_FOUND , EE_PARA_NOT_FOUND , EE_PARA_NOT_FOUND , EE_PARA_NOT_FOUND ) ,
2002-05-17 18:12:44 +00:00
mnFirstVisibleChild ( - 1 ) ,
mnLastVisibleChild ( - 2 ) ,
2002-05-23 11:46:18 +00:00
mnStartIndex ( 0 ) ,
2002-12-12 11:36:51 +00:00
maEventOpenFrames ( 0 ) ,
2002-05-17 18:12:44 +00:00
mbInNotify ( sal_False ) ,
2002-06-04 17:44:27 +00:00
mbGroupHasFocus ( sal_False ) ,
mbThisHasFocus ( sal_False ) ,
2002-06-07 11:19:53 +00:00
maOffset ( 0 , 0 ) ,
2003-03-27 14:06:05 +00:00
// well, that's strictly exception safe, though not really
// robust. We rely on the fact that this member is constructed
// last, and that the constructor body is empty, thus no
// chance for exceptions once the Id is fetched. Nevertheless,
// normally should employ RAII here...
mnNotifierClientId ( : : comphelper : : AccessibleEventNotifier : : registerClient ( ) )
2002-05-16 15:12:20 +00:00
{
2003-03-27 14:06:05 +00:00
DBG_CTOR ( AccessibleTextHelper_Impl , NULL ) ;
# ifdef DBG_UTIL
OSL_TRACE ( " AccessibleTextHelper_Impl received ID: %d " , mnNotifierClientId ) ;
# endif
2002-05-16 15:12:20 +00:00
}
2002-05-17 18:12:44 +00:00
AccessibleTextHelper_Impl : : ~ AccessibleTextHelper_Impl ( )
{
2003-03-27 14:06:05 +00:00
DBG_DTOR ( AccessibleTextHelper_Impl , NULL ) ;
2010-10-13 02:47:36 -05:00
SolarMutexGuard aGuard ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
try
{
2003-03-27 14:06:05 +00:00
// call Dispose here, too, since we've some resources not
// automatically freed otherwise
2002-07-25 07:35:13 +00:00
Dispose ( ) ;
2002-05-17 18:12:44 +00:00
}
2002-05-23 11:46:18 +00:00
catch ( const uno : : Exception & ) { }
2002-05-17 18:12:44 +00:00
}
2002-05-16 15:12:20 +00:00
2002-06-26 10:38:03 +00:00
SvxTextForwarder & AccessibleTextHelper_Impl : : GetTextForwarder ( ) const SAL_THROW ( ( uno : : RuntimeException ) )
2002-05-17 18:12:44 +00:00
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
2002-05-17 18:12:44 +00:00
if ( ! maEditSource . IsValid ( ) )
throw uno : : RuntimeException ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Unknown edit source " ) ) , mxFrontEnd ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
SvxTextForwarder * pTextForwarder = maEditSource . GetTextForwarder ( ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
if ( ! pTextForwarder )
throw uno : : RuntimeException ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Unable to fetch text forwarder, model might be dead " ) ) , mxFrontEnd ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
if ( pTextForwarder - > IsValid ( ) )
return * pTextForwarder ;
else
throw uno : : RuntimeException ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Text forwarder is invalid, model might be dead " ) ) , mxFrontEnd ) ;
}
2002-05-16 15:12:20 +00:00
2002-06-26 10:38:03 +00:00
SvxViewForwarder & AccessibleTextHelper_Impl : : GetViewForwarder ( ) const SAL_THROW ( ( uno : : RuntimeException ) )
2002-05-17 18:12:44 +00:00
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
2002-05-17 18:12:44 +00:00
if ( ! maEditSource . IsValid ( ) )
throw uno : : RuntimeException ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Unknown edit source " ) ) , mxFrontEnd ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
SvxViewForwarder * pViewForwarder = maEditSource . GetViewForwarder ( ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
if ( ! pViewForwarder )
throw uno : : RuntimeException ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Unable to fetch view forwarder, model might be dead " ) ) , mxFrontEnd ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
if ( pViewForwarder - > IsValid ( ) )
return * pViewForwarder ;
else
throw uno : : RuntimeException ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " View forwarder is invalid, model might be dead " ) ) , mxFrontEnd ) ;
}
2002-05-16 15:12:20 +00:00
2002-06-26 10:38:03 +00:00
SvxEditViewForwarder & AccessibleTextHelper_Impl : : GetEditViewForwarder ( sal_Bool bCreate ) const SAL_THROW ( ( uno : : RuntimeException ) )
2002-05-16 15:12:20 +00:00
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
2002-05-17 18:12:44 +00:00
if ( ! maEditSource . IsValid ( ) )
throw uno : : RuntimeException ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Unknown edit source " ) ) , mxFrontEnd ) ;
SvxEditViewForwarder * pViewForwarder = maEditSource . GetEditViewForwarder ( bCreate ) ;
if ( ! pViewForwarder )
{
if ( bCreate )
throw uno : : RuntimeException ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Unable to fetch edit view forwarder, model might be dead " ) ) , mxFrontEnd ) ;
else
throw uno : : RuntimeException ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " No edit view forwarder, object not in edit mode " ) ) , mxFrontEnd ) ;
}
if ( pViewForwarder - > IsValid ( ) )
return * pViewForwarder ;
2002-05-16 15:12:20 +00:00
else
2002-05-17 18:12:44 +00:00
{
if ( bCreate )
throw uno : : RuntimeException ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " View forwarder is invalid, model might be dead " ) ) , mxFrontEnd ) ;
else
throw uno : : RuntimeException ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " View forwarder is invalid, object not in edit mode " ) ) , mxFrontEnd ) ;
}
2002-05-16 15:12:20 +00:00
}
2002-06-26 10:38:03 +00:00
SvxEditSourceAdapter & AccessibleTextHelper_Impl : : GetEditSource ( ) const SAL_THROW ( ( uno : : RuntimeException ) )
2002-05-16 15:12:20 +00:00
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
2002-05-17 18:12:44 +00:00
if ( maEditSource . IsValid ( ) )
return maEditSource ;
2002-05-16 15:12:20 +00:00
else
2002-05-17 18:12:44 +00:00
throw uno : : RuntimeException ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " AccessibleTextHelper_Impl::GetEditSource: no edit source " ) ) , mxFrontEnd ) ;
2002-05-16 15:12:20 +00:00
}
2002-05-17 18:12:44 +00:00
sal_Bool AccessibleTextHelper_Impl : : IsSelected ( ) const
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
2002-05-17 18:12:44 +00:00
sal_Bool bRet = sal_False ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
try
{
ESelection aSelection ;
bRet = GetEditViewForwarder ( ) . GetSelection ( aSelection ) ;
}
2002-05-23 11:46:18 +00:00
catch ( const uno : : Exception & ) { }
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
return bRet ;
2002-05-16 15:12:20 +00:00
}
2002-05-23 11:46:18 +00:00
// functor for sending child events (no stand-alone function, they are maybe not inlined)
2003-04-24 16:11:28 +00:00
class AccessibleTextHelper_OffsetChildIndex : public : : std : : unary_function < : : accessibility : : AccessibleEditableTextPara & , void >
2002-05-23 11:46:18 +00:00
{
public :
AccessibleTextHelper_OffsetChildIndex ( sal_Int32 nDifference ) : mnDifference ( nDifference ) { }
2003-04-24 16:11:28 +00:00
void operator ( ) ( : : accessibility : : AccessibleEditableTextPara & rPara )
2002-05-23 11:46:18 +00:00
{
rPara . SetIndexInParent ( rPara . GetIndexInParent ( ) + mnDifference ) ;
}
private :
const sal_Int32 mnDifference ;
} ;
2002-06-26 10:38:03 +00:00
void AccessibleTextHelper_Impl : : SetStartIndex ( sal_Int32 nOffset )
2002-05-23 11:46:18 +00:00
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
2002-05-23 11:46:18 +00:00
sal_Int32 nOldOffset ( mnStartIndex ) ;
mnStartIndex = nOffset ;
if ( nOldOffset ! = nOffset )
{
// update children
AccessibleTextHelper_OffsetChildIndex aFunctor ( nOffset - nOldOffset ) ;
: : std : : for_each ( maParaManager . begin ( ) , maParaManager . end ( ) ,
AccessibleParaManager : : WeakChildAdapter < AccessibleTextHelper_OffsetChildIndex > ( aFunctor ) ) ;
}
}
2006-01-13 16:18:22 +00:00
void AccessibleTextHelper_Impl : : SetAdditionalChildStates ( const VectorOfStates & rChildStates )
{
maParaManager . SetAdditionalChildStates ( rChildStates ) ;
}
2002-06-26 10:38:03 +00:00
void AccessibleTextHelper_Impl : : SetChildFocus ( sal_Int32 nChild , sal_Bool bHaveFocus ) SAL_THROW ( ( : : com : : sun : : star : : uno : : RuntimeException ) )
2002-06-04 17:44:27 +00:00
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
2002-06-04 17:44:27 +00:00
if ( bHaveFocus )
{
if ( mbThisHasFocus )
SetShapeFocus ( sal_False ) ;
2002-06-12 12:41:41 +00:00
maParaManager . SetFocus ( nChild ) ;
2002-06-13 17:46:17 +00:00
// we just received the focus, also send caret event then
UpdateSelection ( ) ;
2002-10-23 11:09:43 +00:00
2011-03-07 13:13:02 +01:00
OSL_TRACE ( " AccessibleTextHelper_Impl::SetChildFocus(): Paragraph %d received focus " , nChild ) ;
2002-06-04 17:44:27 +00:00
}
else
{
2002-06-12 12:41:41 +00:00
maParaManager . SetFocus ( - 1 ) ;
2002-06-04 17:44:27 +00:00
2011-03-07 13:13:02 +01:00
OSL_TRACE ( " AccessibleTextHelper_Impl::SetChildFocus(): Paragraph %d lost focus " , nChild ) ;
2002-10-23 11:09:43 +00:00
2002-06-04 17:44:27 +00:00
if ( mbGroupHasFocus )
SetShapeFocus ( sal_True ) ;
}
}
2002-06-26 10:38:03 +00:00
void AccessibleTextHelper_Impl : : ChangeChildFocus ( sal_Int32 nNewChild ) SAL_THROW ( ( : : com : : sun : : star : : uno : : RuntimeException ) )
2002-06-12 12:41:41 +00:00
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
2002-06-12 12:41:41 +00:00
if ( mbThisHasFocus )
SetShapeFocus ( sal_False ) ;
mbGroupHasFocus = sal_True ;
maParaManager . SetFocus ( nNewChild ) ;
2002-10-23 11:09:43 +00:00
2011-03-07 13:13:02 +01:00
OSL_TRACE ( " AccessibleTextHelper_Impl::ChangeChildFocus(): Paragraph %d received focus " , nNewChild ) ;
2002-06-12 12:41:41 +00:00
}
2002-06-26 10:38:03 +00:00
void AccessibleTextHelper_Impl : : SetShapeFocus ( sal_Bool bHaveFocus ) SAL_THROW ( ( : : com : : sun : : star : : uno : : RuntimeException ) )
2002-06-04 17:44:27 +00:00
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
2002-06-04 17:44:27 +00:00
sal_Bool bOldFocus ( mbThisHasFocus ) ;
mbThisHasFocus = bHaveFocus ;
if ( bOldFocus ! = bHaveFocus )
{
if ( bHaveFocus )
2002-10-23 11:09:43 +00:00
{
2003-04-24 16:11:28 +00:00
GotPropertyEvent ( uno : : makeAny ( AccessibleStateType : : FOCUSED ) , AccessibleEventId : : STATE_CHANGED ) ;
2011-03-08 13:48:14 +01:00
OSL_TRACE ( " AccessibleTextHelper_Impl::SetShapeFocus(): Parent object received focus " ) ;
2002-10-23 11:09:43 +00:00
}
2002-06-04 17:44:27 +00:00
else
2002-10-23 11:09:43 +00:00
{
2003-04-24 16:11:28 +00:00
LostPropertyEvent ( uno : : makeAny ( AccessibleStateType : : FOCUSED ) , AccessibleEventId : : STATE_CHANGED ) ;
2011-03-08 13:48:14 +01:00
OSL_TRACE ( " AccessibleTextHelper_Impl::SetShapeFocus(): Parent object lost focus " ) ;
2002-10-23 11:09:43 +00:00
}
2002-06-04 17:44:27 +00:00
}
}
2002-06-26 10:38:03 +00:00
void AccessibleTextHelper_Impl : : SetFocus ( sal_Bool bHaveFocus ) SAL_THROW ( ( : : com : : sun : : star : : uno : : RuntimeException ) )
2002-05-23 11:46:18 +00:00
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
2002-06-04 17:44:27 +00:00
sal_Bool bOldFocus ( mbGroupHasFocus ) ;
2002-05-23 11:46:18 +00:00
2002-06-04 17:44:27 +00:00
mbGroupHasFocus = bHaveFocus ;
2002-05-23 11:46:18 +00:00
if ( IsActive ( ) )
{
try
{
// find the one with the cursor and get/set focus accordingly
ESelection aSelection ;
if ( GetEditViewForwarder ( ) . GetSelection ( aSelection ) )
2002-06-04 17:44:27 +00:00
SetChildFocus ( aSelection . nEndPara , bHaveFocus ) ;
2002-05-23 11:46:18 +00:00
}
catch ( const uno : : Exception & ) { }
}
else if ( bOldFocus ! = bHaveFocus )
{
2002-06-04 17:44:27 +00:00
SetShapeFocus ( bHaveFocus ) ;
2002-05-23 11:46:18 +00:00
}
2002-07-05 09:39:58 +00:00
2011-03-07 13:16:49 +01:00
OSL_TRACE ( " AccessibleTextHelper_Impl::SetFocus: focus changed, Object %d, state: %s " , this , bHaveFocus ? " focused " : " not focused " ) ;
2002-05-23 11:46:18 +00:00
}
2002-06-26 10:38:03 +00:00
sal_Bool AccessibleTextHelper_Impl : : HaveFocus ( ) SAL_THROW ( ( : : com : : sun : : star : : uno : : RuntimeException ) )
2002-05-23 11:46:18 +00:00
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
2002-06-07 11:19:53 +00:00
// No locking of solar mutex here, since we rely on the fact
// that sal_Bool access is atomic
2002-06-04 17:44:27 +00:00
return mbThisHasFocus ;
2002-05-23 11:46:18 +00:00
}
2002-06-26 10:38:03 +00:00
sal_Bool AccessibleTextHelper_Impl : : IsActive ( ) const SAL_THROW ( ( uno : : RuntimeException ) )
2002-05-17 18:12:44 +00:00
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
2002-06-14 11:16:33 +00:00
try
{
SvxEditSource & rEditSource = GetEditSource ( ) ;
SvxEditViewForwarder * pViewForwarder = rEditSource . GetEditViewForwarder ( ) ;
2002-05-16 15:12:20 +00:00
2002-06-14 11:16:33 +00:00
if ( ! pViewForwarder )
return sal_False ;
2002-05-16 15:12:20 +00:00
2002-06-14 11:16:33 +00:00
if ( pViewForwarder - > IsValid ( ) )
return sal_True ;
else
return sal_False ;
}
catch ( const uno : : RuntimeException & )
{
2002-05-17 18:12:44 +00:00
return sal_False ;
2002-06-14 11:16:33 +00:00
}
2002-05-17 18:12:44 +00:00
}
2002-05-16 15:12:20 +00:00
2002-06-12 12:41:41 +00:00
void AccessibleTextHelper_Impl : : UpdateSelection ( )
2002-05-16 15:12:20 +00:00
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
2002-06-14 11:16:33 +00:00
try
2002-05-17 18:12:44 +00:00
{
2002-06-14 11:16:33 +00:00
ESelection aSelection ;
if ( GetEditViewForwarder ( ) . GetSelection ( aSelection ) )
2002-06-04 17:44:27 +00:00
{
2003-03-27 14:06:05 +00:00
if ( ! maLastSelection . IsEqual ( aSelection ) & &
aSelection . nEndPara < maParaManager . GetNum ( ) )
2002-06-06 13:06:17 +00:00
{
2002-10-23 11:09:43 +00:00
// #103998# Not that important, changed from assertion to trace
if ( mbThisHasFocus )
2006-10-12 11:01:00 +00:00
{
2011-03-08 13:48:14 +01:00
OSL_TRACE ( " AccessibleTextHelper_Impl::UpdateSelection(): Parent has focus! " ) ;
2006-10-12 11:01:00 +00:00
}
2002-05-16 15:12:20 +00:00
2011-01-10 16:11:35 +01:00
sal_uInt16 nMaxValidParaIndex ( static_cast < sal_uInt16 > ( GetTextForwarder ( ) . GetParagraphCount ( ) ) - 1 ) ;
2003-03-27 14:06:05 +00:00
2002-06-14 11:16:33 +00:00
// notify all affected paragraphs (TODO: may be suboptimal,
// since some paragraphs might stay selected)
if ( maLastSelection . nStartPara ! = EE_PARA_NOT_FOUND )
{
// Did the caret move from one paragraph to another?
2002-07-05 09:39:58 +00:00
// #100530# no caret events if not focused.
if ( mbGroupHasFocus & &
maLastSelection . nEndPara ! = aSelection . nEndPara )
2002-06-14 11:16:33 +00:00
{
2003-03-27 14:06:05 +00:00
if ( maLastSelection . nEndPara < maParaManager . GetNum ( ) )
{
2003-04-08 14:23:36 +00:00
maParaManager . FireEvent ( : : std : : min ( maLastSelection . nEndPara , nMaxValidParaIndex ) ,
: : std : : min ( maLastSelection . nEndPara , nMaxValidParaIndex ) + 1 ,
2003-04-24 16:11:28 +00:00
AccessibleEventId : : CARET_CHANGED ,
2003-03-27 14:06:05 +00:00
uno : : makeAny ( static_cast < sal_Int32 > ( - 1 ) ) ,
uno : : makeAny ( static_cast < sal_Int32 > ( maLastSelection . nEndPos ) ) ) ;
}
2002-06-14 11:16:33 +00:00
ChangeChildFocus ( aSelection . nEndPara ) ;
2002-07-05 09:39:58 +00:00
2011-03-07 13:18:23 +01:00
OSL_TRACE ( " AccessibleTextHelper_Impl::UpdateSelection(): focus changed, Object: %d, Paragraph: %d, Last paragraph: %d " ,
2002-07-05 09:39:58 +00:00
this , aSelection . nEndPara , maLastSelection . nEndPara ) ;
2002-06-14 11:16:33 +00:00
}
2002-06-12 12:41:41 +00:00
}
2002-06-06 13:06:17 +00:00
2002-07-05 09:39:58 +00:00
// #100530# no caret events if not focused.
if ( mbGroupHasFocus )
{
2006-02-01 14:01:55 +00:00
uno : : Any aOldCursor ;
// #i13705# The old cursor can only contain valid
// values if it's the same paragraph!
if ( maLastSelection . nStartPara ! = EE_PARA_NOT_FOUND & &
maLastSelection . nEndPara = = aSelection . nEndPara )
{
aOldCursor < < = static_cast < sal_Int32 > ( maLastSelection . nEndPos ) ;
}
else
{
aOldCursor < < = static_cast < sal_Int32 > ( - 1 ) ;
}
2002-07-05 09:39:58 +00:00
maParaManager . FireEvent ( aSelection . nEndPara ,
aSelection . nEndPara + 1 ,
2003-04-24 16:11:28 +00:00
AccessibleEventId : : CARET_CHANGED ,
2002-07-05 09:39:58 +00:00
uno : : makeAny ( static_cast < sal_Int32 > ( aSelection . nEndPos ) ) ,
aOldCursor ) ;
}
2002-06-04 17:44:27 +00:00
2011-03-07 13:20:43 +01:00
OSL_TRACE ( " AccessibleTextHelper_Impl::UpdateSelection(): caret changed, Object: %d, New pos: %d, Old pos: %d, New para: %d, Old para: %d " ,
2002-07-05 09:39:58 +00:00
this , aSelection . nEndPos , maLastSelection . nEndPos , aSelection . nEndPara , maLastSelection . nEndPara ) ;
2002-10-23 11:09:43 +00:00
2003-05-22 09:26:37 +00:00
// #108947# Sort new range before calling FireEvent
: : std : : pair < xub_StrLen , xub_StrLen > sortedSelection (
makeSortedPair ( : : std : : min ( aSelection . nStartPara , nMaxValidParaIndex ) ,
: : std : : min ( aSelection . nEndPara , nMaxValidParaIndex ) ) ) ;
// #108947# Sort last range before calling FireEvent
: : std : : pair < xub_StrLen , xub_StrLen > sortedLastSelection (
makeSortedPair ( : : std : : min ( maLastSelection . nStartPara , nMaxValidParaIndex ) ,
: : std : : min ( maLastSelection . nEndPara , nMaxValidParaIndex ) ) ) ;
2010-11-09 01:42:14 +05:00
// event TEXT_SELECTION_CHANGED has to be submitted. (#i27299#)
2006-02-01 14:01:55 +00:00
const sal_Int16 nTextSelChgEventId =
AccessibleEventId : : TEXT_SELECTION_CHANGED ;
2003-03-27 14:06:05 +00:00
// #107037# notify selection change
if ( maLastSelection . nStartPara = = EE_PARA_NOT_FOUND )
{
// last selection is undefined
2010-11-09 01:42:14 +05:00
// use method <ESelection::HasRange()> (#i27299#)
2006-02-01 14:01:55 +00:00
if ( aSelection . HasRange ( ) )
2003-03-27 14:06:05 +00:00
{
// selection was undefined, now is on
2003-05-22 09:26:37 +00:00
maParaManager . FireEvent ( sortedSelection . first ,
sortedSelection . second + 1 ,
2006-02-01 14:01:55 +00:00
nTextSelChgEventId ) ;
2003-03-27 14:06:05 +00:00
}
}
else
{
// last selection is valid
2010-11-09 01:42:14 +05:00
// use method <ESelection::HasRange()> (#i27299#)
2006-02-01 14:01:55 +00:00
if ( maLastSelection . HasRange ( ) & &
! aSelection . HasRange ( ) )
2003-03-27 14:06:05 +00:00
{
// selection was on, now is empty
2003-05-22 09:26:37 +00:00
maParaManager . FireEvent ( sortedLastSelection . first ,
sortedLastSelection . second + 1 ,
2006-02-01 14:01:55 +00:00
nTextSelChgEventId ) ;
2003-03-27 14:06:05 +00:00
}
2010-11-09 01:42:14 +05:00
// use method <ESelection::HasRange()> (#i27299#)
2006-02-01 14:01:55 +00:00
else if ( ! maLastSelection . HasRange ( ) & &
aSelection . HasRange ( ) )
2003-03-27 14:06:05 +00:00
{
// selection was empty, now is on
2003-05-22 09:26:37 +00:00
maParaManager . FireEvent ( sortedSelection . first ,
sortedSelection . second + 1 ,
2006-02-01 14:01:55 +00:00
nTextSelChgEventId ) ;
2003-03-27 14:06:05 +00:00
}
2010-11-09 01:42:14 +05:00
// no event TEXT_SELECTION_CHANGED event, if new and
// last selection are empty. (#i27299#)
2006-02-01 14:01:55 +00:00
else if ( maLastSelection . HasRange ( ) & &
aSelection . HasRange ( ) )
2003-03-27 14:06:05 +00:00
{
2006-02-01 14:01:55 +00:00
// use sorted last and new selection
ESelection aTmpLastSel ( maLastSelection ) ;
aTmpLastSel . Adjust ( ) ;
ESelection aTmpSel ( aSelection ) ;
aTmpSel . Adjust ( ) ;
// first submit event for new and changed selection
sal_uInt32 nPara = aTmpSel . nStartPara ;
for ( ; nPara < = aTmpSel . nEndPara ; + + nPara )
{
if ( nPara < aTmpLastSel . nStartPara | |
nPara > aTmpLastSel . nEndPara )
{
// new selection on paragraph <nPara>
maParaManager . FireEvent ( nPara ,
nTextSelChgEventId ) ;
}
else
{
// check for changed selection on paragraph <nPara>
const xub_StrLen nParaStartPos =
nPara = = aTmpSel . nStartPara
? aTmpSel . nStartPos : 0 ;
const xub_StrLen nParaEndPos =
nPara = = aTmpSel . nEndPara
? aTmpSel . nEndPos : STRING_LEN ;
const xub_StrLen nLastParaStartPos =
nPara = = aTmpLastSel . nStartPara
? aTmpLastSel . nStartPos : 0 ;
const xub_StrLen nLastParaEndPos =
nPara = = aTmpLastSel . nEndPara
? aTmpLastSel . nEndPos : STRING_LEN ;
if ( nParaStartPos ! = nLastParaStartPos | |
nParaEndPos ! = nLastParaEndPos )
{
maParaManager . FireEvent (
nPara , nTextSelChgEventId ) ;
}
}
}
// second submit event for 'old' selections
nPara = aTmpLastSel . nStartPara ;
for ( ; nPara < = aTmpLastSel . nEndPara ; + + nPara )
{
if ( nPara < aTmpSel . nStartPara | |
nPara > aTmpSel . nEndPara )
{
maParaManager . FireEvent ( nPara ,
nTextSelChgEventId ) ;
}
}
2003-03-27 14:06:05 +00:00
}
}
2002-10-23 11:09:43 +00:00
maLastSelection = aSelection ;
2002-06-14 11:16:33 +00:00
}
2002-06-06 13:06:17 +00:00
}
2002-05-17 18:12:44 +00:00
}
2002-06-14 11:16:33 +00:00
// no selection? no update actions
catch ( const uno : : RuntimeException & ) { }
2002-05-16 15:12:20 +00:00
}
2002-06-26 10:38:03 +00:00
void AccessibleTextHelper_Impl : : ShutdownEditSource ( ) SAL_THROW ( ( uno : : RuntimeException ) )
2002-05-17 18:12:44 +00:00
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
2002-05-17 18:12:44 +00:00
// This should only be called with solar mutex locked, i.e. from the main office thread
2002-05-16 15:12:20 +00:00
2002-06-13 08:46:38 +00:00
// This here is somewhat clumsy: As soon as our children have
// a NULL EditSource (maParaManager.SetEditSource()), they
// enter the disposed state and cannot be reanimated. Thus, it
// is unavoidable and a hard requirement to let go and create
// from scratch each and every child.
2002-05-17 18:12:44 +00:00
// invalidate children
2002-07-24 15:19:19 +00:00
maParaManager . Dispose ( ) ;
2002-08-02 10:35:10 +00:00
maParaManager . SetNum ( 0 ) ;
2002-05-16 15:12:20 +00:00
2002-07-24 15:19:19 +00:00
// lost all children
2002-08-02 10:35:10 +00:00
if ( mxFrontEnd . is ( ) )
2003-04-24 16:11:28 +00:00
FireEvent ( AccessibleEventId : : INVALIDATE_ALL_CHILDREN ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// quit listen on stale edit source
if ( maEditSource . IsValid ( ) )
EndListening ( maEditSource . GetBroadcaster ( ) ) ;
2002-05-16 15:12:20 +00:00
2011-09-22 15:00:08 +01:00
SAL_WNODEPRECATED_DECLARATIONS_PUSH
2002-05-17 18:12:44 +00:00
maEditSource . SetEditSource ( : : std : : auto_ptr < SvxEditSource > ( NULL ) ) ;
2011-09-22 15:00:08 +01:00
SAL_WNODEPRECATED_DECLARATIONS_POP
2002-05-17 18:12:44 +00:00
}
2002-05-16 15:12:20 +00:00
2011-09-22 15:00:08 +01:00
SAL_WNODEPRECATED_DECLARATIONS_PUSH
2002-06-26 10:38:03 +00:00
void AccessibleTextHelper_Impl : : SetEditSource ( : : std : : auto_ptr < SvxEditSource > pEditSource ) SAL_THROW ( ( uno : : RuntimeException ) )
2002-05-17 18:12:44 +00:00
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
2002-05-17 18:12:44 +00:00
// This should only be called with solar mutex locked, i.e. from the main office thread
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// shutdown old edit source
ShutdownEditSource ( ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// set new edit source
maEditSource . SetEditSource ( pEditSource ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// init child vector to the current child count
if ( maEditSource . IsValid ( ) )
{
maParaManager . SetNum ( GetTextForwarder ( ) . GetParagraphCount ( ) ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// listen on new edit source
StartListening ( maEditSource . GetBroadcaster ( ) ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
UpdateVisibleChildren ( ) ;
}
2002-05-16 15:12:20 +00:00
}
2011-09-22 15:00:08 +01:00
SAL_WNODEPRECATED_DECLARATIONS_POP
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
void AccessibleTextHelper_Impl : : SetOffset ( const Point & rPoint )
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
2002-06-07 11:19:53 +00:00
// guard against non-atomic access to maOffset data structure
{
: : osl : : MutexGuard aGuard ( maMutex ) ;
maOffset = rPoint ;
}
2002-05-17 18:12:44 +00:00
maParaManager . SetEEOffset ( rPoint ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// in all cases, check visibility afterwards.
UpdateVisibleChildren ( ) ;
2002-08-02 10:35:10 +00:00
UpdateBoundRect ( ) ;
2002-05-17 18:12:44 +00:00
}
2002-05-16 15:12:20 +00:00
2002-12-12 11:36:51 +00:00
void AccessibleTextHelper_Impl : : UpdateVisibleChildren ( bool bBroadcastEvents )
2002-05-16 15:12:20 +00:00
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
2002-05-17 18:12:44 +00:00
try
{
SvxTextForwarder & rCacheTF = GetTextForwarder ( ) ;
SvxViewForwarder & rCacheVF = GetViewForwarder ( ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
Rectangle aViewArea = rCacheVF . GetVisArea ( ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
if ( IsActive ( ) )
{
// maybe the edit view scrolls, adapt aViewArea
Rectangle aEditViewArea = GetEditViewForwarder ( ) . GetVisArea ( ) ;
aViewArea + = aEditViewArea . TopLeft ( ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// now determine intersection
aViewArea . Intersection ( aEditViewArea ) ;
}
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
Rectangle aTmpBB , aParaBB ;
sal_Bool bFirstChild = sal_True ;
sal_Int32 nCurrPara ;
sal_Int32 nParas = rCacheTF . GetParagraphCount ( ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
mnFirstVisibleChild = - 1 ;
mnLastVisibleChild = - 2 ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
for ( nCurrPara = 0 ; nCurrPara < nParas ; + + nCurrPara )
{
DBG_ASSERT ( nCurrPara > = 0 & & nCurrPara < = USHRT_MAX ,
" AccessibleTextHelper_Impl::UpdateVisibleChildren: index value overflow " ) ;
2002-05-16 15:12:20 +00:00
2011-01-10 16:11:35 +01:00
aTmpBB = rCacheTF . GetParaBounds ( static_cast < sal_uInt16 > ( nCurrPara ) ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// convert to screen coordinates
2003-04-24 16:11:28 +00:00
aParaBB = : : accessibility : : AccessibleEditableTextPara : : LogicToPixel ( aTmpBB , rCacheTF . GetMapMode ( ) , rCacheVF ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
if ( aParaBB . IsOver ( aViewArea ) )
2002-05-16 15:12:20 +00:00
{
2002-05-17 18:12:44 +00:00
// at least partially visible
if ( bFirstChild )
{
bFirstChild = sal_False ;
mnFirstVisibleChild = nCurrPara ;
}
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
mnLastVisibleChild = nCurrPara ;
2002-05-16 15:12:20 +00:00
2002-06-06 13:06:17 +00:00
// child not yet created?
2003-04-24 16:11:28 +00:00
: : accessibility : : AccessibleParaManager : : WeakChild aChild ( maParaManager . GetChild ( nCurrPara ) ) ;
2002-06-06 13:06:17 +00:00
if ( aChild . second . Width = = 0 & &
2002-06-26 10:38:03 +00:00
aChild . second . Height = = 0 & &
2002-12-12 11:36:51 +00:00
mxFrontEnd . is ( ) & &
bBroadcastEvents )
2002-06-06 13:06:17 +00:00
{
GotPropertyEvent ( uno : : makeAny ( maParaManager . CreateChild ( nCurrPara - mnFirstVisibleChild ,
mxFrontEnd , GetEditSource ( ) , nCurrPara ) . first ) ,
2003-04-24 16:11:28 +00:00
AccessibleEventId : : CHILD ) ;
2002-06-06 13:06:17 +00:00
}
2002-05-17 18:12:44 +00:00
}
else
2002-05-16 15:12:20 +00:00
{
2002-05-17 18:12:44 +00:00
// not or no longer visible
if ( maParaManager . IsReferencable ( nCurrPara ) )
{
2002-12-12 11:36:51 +00:00
if ( bBroadcastEvents )
LostPropertyEvent ( uno : : makeAny ( maParaManager . GetChild ( nCurrPara ) . first . get ( ) . getRef ( ) ) ,
2003-04-24 16:11:28 +00:00
AccessibleEventId : : CHILD ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// clear reference
maParaManager . Release ( nCurrPara ) ;
}
2002-05-16 15:12:20 +00:00
}
}
}
2002-05-23 11:46:18 +00:00
catch ( const uno : : Exception & )
2002-05-17 18:12:44 +00:00
{
2011-03-01 19:07:44 +01:00
OSL_FAIL ( " AccessibleTextHelper_Impl::UpdateVisibleChildren error while determining visible children " ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// something failed - currently no children
mnFirstVisibleChild = - 1 ;
mnLastVisibleChild = - 2 ;
maParaManager . SetNum ( 0 ) ;
2002-08-02 10:35:10 +00:00
// lost all children
2002-12-12 11:36:51 +00:00
if ( bBroadcastEvents )
2003-04-24 16:11:28 +00:00
FireEvent ( AccessibleEventId : : INVALIDATE_ALL_CHILDREN ) ;
2002-05-17 18:12:44 +00:00
}
2002-05-16 15:12:20 +00:00
}
2002-05-23 11:46:18 +00:00
// functor for checking changes in paragraph bounding boxes (no stand-alone function, maybe not inlined)
2003-04-24 16:11:28 +00:00
class AccessibleTextHelper_UpdateChildBounds : public : : std : : unary_function < const : : accessibility : : AccessibleParaManager : : WeakChild & ,
: : accessibility : : AccessibleParaManager : : WeakChild >
2002-05-16 15:12:20 +00:00
{
2002-05-17 18:12:44 +00:00
public :
AccessibleTextHelper_UpdateChildBounds ( AccessibleTextHelper_Impl & rImpl ) : mrImpl ( rImpl ) { }
2003-04-24 16:11:28 +00:00
: : accessibility : : AccessibleParaManager : : WeakChild operator ( ) ( const : : accessibility : : AccessibleParaManager : : WeakChild & rChild )
2002-05-16 15:12:20 +00:00
{
2002-05-17 18:12:44 +00:00
// retrieve hard reference from weak one
2003-04-24 16:11:28 +00:00
: : accessibility : : AccessibleParaManager : : WeakPara : : HardRefType aHardRef ( rChild . first . get ( ) ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
if ( aHardRef . is ( ) )
2002-05-16 15:12:20 +00:00
{
2002-05-17 18:12:44 +00:00
awt : : Rectangle aNewRect = aHardRef - > getBounds ( ) ;
const awt : : Rectangle & aOldRect = rChild . second ;
if ( aNewRect . X ! = aOldRect . X | |
aNewRect . Y ! = aOldRect . Y | |
aNewRect . Width ! = aOldRect . Width | |
aNewRect . Height ! = aOldRect . Height )
{
2002-08-13 10:54:00 +00:00
// visible data changed
2003-04-24 16:11:28 +00:00
aHardRef - > FireEvent ( AccessibleEventId : : BOUNDRECT_CHANGED ) ;
2002-08-13 10:54:00 +00:00
// update internal bounds
2003-04-24 16:11:28 +00:00
return : : accessibility : : AccessibleParaManager : : WeakChild ( rChild . first , aNewRect ) ;
2002-05-17 18:12:44 +00:00
}
2002-05-16 15:12:20 +00:00
}
2002-05-17 18:12:44 +00:00
// identity transform
return rChild ;
}
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
private :
AccessibleTextHelper_Impl & mrImpl ;
} ;
2002-05-16 15:12:20 +00:00
2002-08-02 10:35:10 +00:00
void AccessibleTextHelper_Impl : : UpdateBoundRect ( )
2002-05-17 18:12:44 +00:00
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
2003-04-24 16:11:28 +00:00
// send BOUNDRECT_CHANGED to affected children
2002-05-21 13:58:45 +00:00
AccessibleTextHelper_UpdateChildBounds aFunctor ( * this ) ;
2002-05-29 15:09:56 +00:00
: : std : : transform ( maParaManager . begin ( ) , maParaManager . end ( ) , maParaManager . begin ( ) , aFunctor ) ;
2002-05-17 18:12:44 +00:00
}
2002-05-16 15:12:20 +00:00
# ifdef DBG_UTIL
2002-05-17 18:12:44 +00:00
void AccessibleTextHelper_Impl : : CheckInvariants ( ) const
{
if ( mnFirstVisibleChild > = 0 & &
mnFirstVisibleChild > mnLastVisibleChild )
{
2011-03-01 19:07:44 +01:00
OSL_FAIL ( " AccessibleTextHelper: range invalid " ) ;
2002-05-17 18:12:44 +00:00
}
2002-05-16 15:12:20 +00:00
}
# endif
2002-08-02 10:35:10 +00:00
// functor for sending child events (no stand-alone function, they are maybe not inlined)
2003-04-24 16:11:28 +00:00
class AccessibleTextHelper_LostChildEvent : public : : std : : unary_function < const : : accessibility : : AccessibleParaManager : : WeakChild & , void >
2002-08-02 10:35:10 +00:00
{
public :
AccessibleTextHelper_LostChildEvent ( AccessibleTextHelper_Impl & rImpl ) : mrImpl ( rImpl ) { }
2003-04-24 16:11:28 +00:00
void operator ( ) ( const : : accessibility : : AccessibleParaManager : : WeakChild & rPara )
2002-08-02 10:35:10 +00:00
{
// retrieve hard reference from weak one
2003-04-24 16:11:28 +00:00
: : accessibility : : AccessibleParaManager : : WeakPara : : HardRefType aHardRef ( rPara . first . get ( ) ) ;
2002-08-02 10:35:10 +00:00
if ( aHardRef . is ( ) )
2003-04-24 16:11:28 +00:00
mrImpl . FireEvent ( AccessibleEventId : : CHILD , uno : : Any ( ) , uno : : makeAny ( aHardRef . getRef ( ) ) ) ;
2002-08-02 10:35:10 +00:00
}
private :
AccessibleTextHelper_Impl & mrImpl ;
} ;
2002-06-12 12:41:41 +00:00
void AccessibleTextHelper_Impl : : ParagraphsMoved ( sal_Int32 nFirst , sal_Int32 nMiddle , sal_Int32 nLast )
2002-05-29 16:01:52 +00:00
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
2002-06-12 12:41:41 +00:00
const sal_Int32 nParas = GetTextForwarder ( ) . GetParagraphCount ( ) ;
/* rotate paragraphs
* = = = = = = = = = = = = = = = = =
*
* Three cases :
*
* 1.
* . . . nParagraph . . . nParam1 . . . nParam2 . . .
* | ______________ [ xxxxxxxxxxx ]
* becomes
* [ xxxxxxxxxxx ] | ______________
*
* tail is 0
*
* 2.
* . . . nParam1 . . . nParagraph . . . nParam2 . . .
* [ xxxxxxxxxxx | xxxxxxxxxxxxxx ] ____________
* becomes
* ____________ [ xxxxxxxxxxx | xxxxxxxxxxxxxx ]
*
* tail is nParagraph - nParam1
*
* 3.
* . . . nParam1 . . . nParam2 . . . nParagraph . . .
* [ xxxxxxxxxxx ] ___________ | ____________
* becomes
* ___________ | ____________ [ xxxxxxxxxxx ]
*
* tail is nParam2 - nParam1
*/
2002-05-29 16:01:52 +00:00
2002-06-12 12:41:41 +00:00
// sort nParagraph, nParam1 and nParam2 in ascending order, calc range
if ( nMiddle < nFirst )
{
: : std : : swap ( nFirst , nMiddle ) ;
}
else if ( nMiddle < nLast )
{
nLast = nLast + nMiddle - nFirst ;
}
else
{
: : std : : swap ( nMiddle , nLast ) ;
nLast = nLast + nMiddle - nFirst ;
}
2002-05-29 16:01:52 +00:00
2002-06-12 12:41:41 +00:00
if ( nFirst < nParas & & nMiddle < nParas & & nLast < nParas )
{
// since we have no "paragraph index
// changed" event on UAA, remove
// [first,last] and insert again later (in
// UpdateVisibleChildren)
// maParaManager.Rotate( nFirst, nMiddle, nLast );
// send CHILD_EVENT to affected children
: : accessibility : : AccessibleParaManager : : VectorOfChildren : : const_iterator begin = maParaManager . begin ( ) ;
: : accessibility : : AccessibleParaManager : : VectorOfChildren : : const_iterator end = begin ;
: : std : : advance ( begin , nFirst ) ;
: : std : : advance ( end , nLast + 1 ) ;
2002-08-02 10:35:10 +00:00
// TODO: maybe optimize here in the following way. If the
// number of removed children exceeds a certain threshold,
2003-04-24 16:11:28 +00:00
// use INVALIDATE_CHILDREN
2002-06-12 12:41:41 +00:00
AccessibleTextHelper_LostChildEvent aFunctor ( * this ) ;
: : std : : for_each ( begin , end , aFunctor ) ;
maParaManager . Release ( nFirst , nLast + 1 ) ;
2002-08-02 10:35:10 +00:00
// should be no need for UpdateBoundRect, since all affected children are cleared.
2002-06-12 12:41:41 +00:00
}
2002-05-29 16:01:52 +00:00
}
2003-04-24 16:11:28 +00:00
// functor for sending child events (no stand-alone function, they are maybe not inlined)
class AccessibleTextHelper_ChildrenTextChanged : public : : std : : unary_function < : : accessibility : : AccessibleEditableTextPara & , void >
{
public :
void operator ( ) ( : : accessibility : : AccessibleEditableTextPara & rPara )
{
rPara . TextChanged ( ) ;
}
} ;
2002-12-12 11:36:51 +00:00
/** functor processing queue events
Reacts on TEXT_HINT_PARAINSERTED / REMOVED events and stores
their content
*/
class AccessibleTextHelper_QueueFunctor : public : : std : : unary_function < const SfxHint * , void >
2002-05-23 11:46:18 +00:00
{
2002-12-12 11:36:51 +00:00
public :
AccessibleTextHelper_QueueFunctor ( ) :
mnParasChanged ( 0 ) ,
mnParaIndex ( - 1 ) ,
mnHintId ( - 1 )
{ }
void operator ( ) ( const SfxHint * pEvent )
{
if ( pEvent & &
mnParasChanged ! = - 1 )
{
// determine hint type
const TextHint * pTextHint = PTR_CAST ( TextHint , pEvent ) ;
const SvxEditSourceHint * pEditSourceHint = PTR_CAST ( SvxEditSourceHint , pEvent ) ;
2002-06-12 12:41:41 +00:00
2002-12-12 11:36:51 +00:00
if ( ! pEditSourceHint & & pTextHint & &
( pTextHint - > GetId ( ) = = TEXT_HINT_PARAINSERTED | |
pTextHint - > GetId ( ) = = TEXT_HINT_PARAREMOVED ) )
{
if ( pTextHint - > GetValue ( ) = = EE_PARA_ALL )
{
mnParasChanged = - 1 ;
}
else
{
mnHintId = pTextHint - > GetId ( ) ;
mnParaIndex = pTextHint - > GetValue ( ) ;
+ + mnParasChanged ;
}
}
}
}
2002-06-12 12:41:41 +00:00
2002-12-12 11:36:51 +00:00
/** Query number of paragraphs changed during queue processing.
2002-06-12 12:41:41 +00:00
2002-12-12 11:36:51 +00:00
@ return number of changed paragraphs , - 1 for
" every paragraph changed "
*/
int GetNumberOfParasChanged ( ) { return mnParasChanged ; }
/** Query index of last added/removed paragraph
2002-06-12 12:41:41 +00:00
2002-12-12 11:36:51 +00:00
@ return index of lastly added paragraphs , - 1 for none
added so far .
*/
int GetParaIndex ( ) { return mnParaIndex ; }
/** Query hint id of last interesting event
2002-06-12 12:41:41 +00:00
2002-12-12 11:36:51 +00:00
@ return hint id of last interesting event ( REMOVED / INSERTED ) .
*/
int GetHintId ( ) { return mnHintId ; }
2002-06-12 12:41:41 +00:00
2002-12-12 11:36:51 +00:00
private :
/** number of paragraphs changed during queue processing. -1 for
" every paragraph changed "
*/
int mnParasChanged ;
/// index of paragraph added/removed last
int mnParaIndex ;
/// TextHint ID (removed/inserted) of last interesting event
int mnHintId ;
} ;
2002-08-13 10:54:00 +00:00
2002-12-12 11:36:51 +00:00
void AccessibleTextHelper_Impl : : ProcessQueue ( )
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
2002-12-12 11:36:51 +00:00
// inspect queue for paragraph insert/remove events. If there
// is exactly _one_ of those in the queue, and the number of
// paragraphs has changed by exactly one, use that event to
// determine a priori which paragraph was added/removed. This
// is necessary, since I must sync right here with the
// EditEngine state (number of paragraphs etc.), since I'm
// potentially sending listener events right away.
AccessibleTextHelper_QueueFunctor aFunctor ;
maEventQueue . ForEach ( aFunctor ) ;
const sal_Int32 nNewParas ( GetTextForwarder ( ) . GetParagraphCount ( ) ) ;
const sal_Int32 nCurrParas ( maParaManager . GetNum ( ) ) ;
// whether every paragraph already is updated (no need to
// repeat that later on, e.g. for PARA_MOVED events)
bool bEverythingUpdated ( false ) ;
if ( labs ( nNewParas - nCurrParas ) = = 1 & &
aFunctor . GetNumberOfParasChanged ( ) = = 1 )
{
// #103483# Exactly one paragraph added/removed. This is
// the normal case, optimize event handling here.
if ( aFunctor . GetHintId ( ) = = TEXT_HINT_PARAINSERTED )
{
// update num of paras
maParaManager . SetNum ( nNewParas ) ;
// release everything from the insertion position until the end
maParaManager . Release ( aFunctor . GetParaIndex ( ) , nCurrParas ) ;
// TODO: Clarify whether this behaviour _really_ saves
// anybody anything!
// update children, _don't_ broadcast
UpdateVisibleChildren ( false ) ;
UpdateBoundRect ( ) ;
// send insert event
2003-06-24 06:39:36 +00:00
// #109864# Enforce creation of this paragraph
try
{
GotPropertyEvent ( uno : : makeAny ( getAccessibleChild ( aFunctor . GetParaIndex ( ) -
mnFirstVisibleChild + GetStartIndex ( ) ) ) ,
AccessibleEventId : : CHILD ) ;
}
catch ( const uno : : Exception & )
{
2011-03-01 19:07:44 +01:00
OSL_FAIL ( " AccessibleTextHelper_Impl::ProcessQueue: could not create new paragraph " ) ;
2003-06-24 06:39:36 +00:00
}
2002-12-12 11:36:51 +00:00
}
else if ( aFunctor . GetHintId ( ) = = TEXT_HINT_PARAREMOVED )
{
: : accessibility : : AccessibleParaManager : : VectorOfChildren : : const_iterator begin = maParaManager . begin ( ) ;
: : std : : advance ( begin , aFunctor . GetParaIndex ( ) ) ;
: : accessibility : : AccessibleParaManager : : VectorOfChildren : : const_iterator end = begin ;
: : std : : advance ( end , 1 ) ;
2007-08-02 12:59:06 +00:00
// #i61812# remember para to be removed for later notification
// AFTER the new state is applied (that after the para got removed)
: : uno : : Reference < XAccessible > xPara ;
: : accessibility : : AccessibleParaManager : : WeakPara : : HardRefType aHardRef ( begin - > first . get ( ) ) ;
if ( aHardRef . is ( ) )
xPara = : : uno : : Reference < XAccessible > ( aHardRef . getRef ( ) , : : uno : : UNO_QUERY ) ;
2002-12-12 11:36:51 +00:00
// release everything from the remove position until the end
maParaManager . Release ( aFunctor . GetParaIndex ( ) , nCurrParas ) ;
// update num of paras
maParaManager . SetNum ( nNewParas ) ;
// TODO: Clarify whether this behaviour _really_ saves
// anybody anything!
// update children, _don't_ broadcast
UpdateVisibleChildren ( false ) ;
UpdateBoundRect ( ) ;
2007-08-02 12:59:06 +00:00
// #i61812# notification for removed para
if ( xPara . is ( ) )
FireEvent ( AccessibleEventId : : CHILD , uno : : Any ( ) , uno : : makeAny ( xPara ) ) ;
2002-12-12 11:36:51 +00:00
}
# ifdef DBG_UTIL
else
2011-03-01 19:07:44 +01:00
OSL_FAIL ( " AccessibleTextHelper_Impl::ProcessQueue() invalid hint id " ) ;
2002-12-12 11:36:51 +00:00
# endif
2002-06-12 12:41:41 +00:00
}
2002-12-12 11:36:51 +00:00
else if ( nNewParas ! = nCurrParas )
{
// release all paras
maParaManager . Release ( 0 , nCurrParas ) ;
2002-06-12 12:41:41 +00:00
2002-12-12 11:36:51 +00:00
// update num of paras
maParaManager . SetNum ( nNewParas ) ;
2002-06-12 12:41:41 +00:00
2003-06-24 06:39:36 +00:00
// #109864# create from scratch, don't broadcast
UpdateVisibleChildren ( false ) ;
2002-12-12 11:36:51 +00:00
UpdateBoundRect ( ) ;
2002-06-12 12:41:41 +00:00
2007-08-02 12:59:06 +00:00
// number of paragraphs somehow changed - but we have no
// chance determining how. Thus, throw away everything and
// create from scratch.
// (child events should be broadcast after the changes are done...)
FireEvent ( AccessibleEventId : : INVALIDATE_ALL_CHILDREN ) ;
2002-12-12 11:36:51 +00:00
// no need for further updates later on
bEverythingUpdated = true ;
}
while ( ! maEventQueue . IsEmpty ( ) )
{
2011-09-22 15:00:08 +01:00
SAL_WNODEPRECATED_DECLARATIONS_PUSH
2002-12-12 11:36:51 +00:00
: : std : : auto_ptr < SfxHint > pHint ( maEventQueue . PopFront ( ) ) ;
2011-09-22 15:00:08 +01:00
SAL_WNODEPRECATED_DECLARATIONS_POP
2002-12-12 11:36:51 +00:00
if ( pHint . get ( ) )
{
const SfxHint & rHint = * ( pHint . get ( ) ) ;
2002-05-29 16:01:52 +00:00
2002-12-12 11:36:51 +00:00
// determine hint type
const SdrHint * pSdrHint = PTR_CAST ( SdrHint , & rHint ) ;
const SfxSimpleHint * pSimpleHint = PTR_CAST ( SfxSimpleHint , & rHint ) ;
const TextHint * pTextHint = PTR_CAST ( TextHint , & rHint ) ;
const SvxViewHint * pViewHint = PTR_CAST ( SvxViewHint , & rHint ) ;
const SvxEditSourceHint * pEditSourceHint = PTR_CAST ( SvxEditSourceHint , & rHint ) ;
2002-05-29 16:01:52 +00:00
2002-12-12 11:36:51 +00:00
try
{
const sal_Int32 nParas = GetTextForwarder ( ) . GetParagraphCount ( ) ;
2002-05-29 16:01:52 +00:00
2002-12-12 11:36:51 +00:00
if ( pEditSourceHint )
{
switch ( pEditSourceHint - > GetId ( ) )
{
case EDITSOURCE_HINT_PARASMOVED :
{
DBG_ASSERT ( pEditSourceHint - > GetStartValue ( ) < GetTextForwarder ( ) . GetParagraphCount ( ) & &
pEditSourceHint - > GetEndValue ( ) < GetTextForwarder ( ) . GetParagraphCount ( ) ,
" AccessibleTextHelper_Impl::NotifyHdl: Invalid notification " ) ;
if ( ! bEverythingUpdated )
{
ParagraphsMoved ( pEditSourceHint - > GetStartValue ( ) ,
pEditSourceHint - > GetValue ( ) ,
pEditSourceHint - > GetEndValue ( ) ) ;
// in all cases, check visibility afterwards.
UpdateVisibleChildren ( ) ;
}
break ;
}
case EDITSOURCE_HINT_SELECTIONCHANGED :
// notify listeners
try
{
UpdateSelection ( ) ;
}
// maybe we're not in edit mode (this is not an error)
catch ( const uno : : Exception & ) { }
break ;
}
}
else if ( pTextHint )
{
switch ( pTextHint - > GetId ( ) )
{
case TEXT_HINT_MODIFIED :
{
// notify listeners
sal_Int32 nPara ( pTextHint - > GetValue ( ) ) ;
2003-04-24 16:11:28 +00:00
// #108900# Delegate change event to children
2006-06-19 13:54:35 +00:00
AccessibleTextHelper_ChildrenTextChanged aNotifyChildrenFunctor ;
2003-04-24 16:11:28 +00:00
2002-12-12 11:36:51 +00:00
if ( nPara = = static_cast < sal_Int32 > ( EE_PARA_ALL ) )
2003-04-24 16:11:28 +00:00
{
// #108900# Call every child
: : std : : for_each ( maParaManager . begin ( ) , maParaManager . end ( ) ,
2006-06-19 13:54:35 +00:00
AccessibleParaManager : : WeakChildAdapter < AccessibleTextHelper_ChildrenTextChanged > ( aNotifyChildrenFunctor ) ) ;
2003-04-24 16:11:28 +00:00
}
2002-12-12 11:36:51 +00:00
else
if ( nPara < nParas )
2003-04-24 16:11:28 +00:00
{
// #108900# Call child at index nPara
: : std : : for_each ( maParaManager . begin ( ) + nPara , maParaManager . begin ( ) + nPara + 1 ,
2006-06-19 13:54:35 +00:00
AccessibleParaManager : : WeakChildAdapter < AccessibleTextHelper_ChildrenTextChanged > ( aNotifyChildrenFunctor ) ) ;
2003-04-24 16:11:28 +00:00
}
2002-12-12 11:36:51 +00:00
break ;
}
case TEXT_HINT_PARAINSERTED :
// already happened above
break ;
case TEXT_HINT_PARAREMOVED :
// already happened above
break ;
case TEXT_HINT_TEXTHEIGHTCHANGED :
// visibility changed, done below
break ;
case TEXT_HINT_VIEWSCROLLED :
// visibility changed, done below
break ;
}
2002-08-13 10:54:00 +00:00
2002-12-12 11:36:51 +00:00
// in all cases, check visibility afterwards.
UpdateVisibleChildren ( ) ;
UpdateBoundRect ( ) ;
}
else if ( pViewHint )
{
2006-07-13 09:35:17 +00:00
switch ( pViewHint - > GetHintType ( ) )
2002-12-12 11:36:51 +00:00
{
2006-07-13 09:35:17 +00:00
case SvxViewHint : : SVX_HINT_VIEWCHANGED :
2002-12-12 11:36:51 +00:00
// just check visibility
UpdateVisibleChildren ( ) ;
UpdateBoundRect ( ) ;
break ;
}
}
else if ( pSdrHint )
{
switch ( pSdrHint - > GetKind ( ) )
{
case HINT_BEGEDIT :
{
// change children state
maParaManager . SetActive ( ) ;
// per definition, edit mode text has the focus
SetFocus ( sal_True ) ;
break ;
}
case HINT_ENDEDIT :
2006-06-19 13:54:35 +00:00
{
2002-12-12 11:36:51 +00:00
// focused child now looses focus
ESelection aSelection ;
if ( GetEditViewForwarder ( ) . GetSelection ( aSelection ) )
SetChildFocus ( aSelection . nEndPara , sal_False ) ;
// change children state
maParaManager . SetActive ( sal_False ) ;
maLastSelection = ESelection ( EE_PARA_NOT_FOUND , EE_PARA_NOT_FOUND ,
EE_PARA_NOT_FOUND , EE_PARA_NOT_FOUND ) ;
break ;
2006-06-19 13:54:35 +00:00
}
default :
break ;
2002-12-12 11:36:51 +00:00
}
}
// it's VITAL to keep the SfxSimpleHint last! It's the base of some classes above!
else if ( pSimpleHint )
{
switch ( pSimpleHint - > GetId ( ) )
{
case SFX_HINT_DYING :
// edit source is dying under us, become defunc then
try
{
// make edit source inaccessible
// Note: cannot destroy it here, since we're called from there!
ShutdownEditSource ( ) ;
}
catch ( const uno : : Exception & ) { }
break ;
}
}
}
catch ( const uno : : Exception & )
{
# ifdef DBG_UTIL
OSL_TRACE ( " AccessibleTextHelper_Impl::ProcessQueue: Unhandled exception. " ) ;
# endif
}
}
}
2002-05-23 11:46:18 +00:00
}
2006-06-19 13:54:35 +00:00
void AccessibleTextHelper_Impl : : Notify ( SfxBroadcaster & /*rBC*/ , const SfxHint & rHint )
2002-05-17 18:12:44 +00:00
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
2002-06-12 12:41:41 +00:00
// precondition: solar mutex locked
DBG_TESTSOLARMUTEX ( ) ;
// precondition: not in a recursion
2002-05-17 18:12:44 +00:00
if ( mbInNotify )
return ;
2002-05-17 16:35:10 +00:00
2002-05-17 18:12:44 +00:00
mbInNotify = sal_True ;
2002-05-17 16:35:10 +00:00
2002-06-12 12:41:41 +00:00
// determine hint type
2002-05-23 11:46:18 +00:00
const SdrHint * pSdrHint = PTR_CAST ( SdrHint , & rHint ) ;
2002-05-17 18:12:44 +00:00
const SfxSimpleHint * pSimpleHint = PTR_CAST ( SfxSimpleHint , & rHint ) ;
const TextHint * pTextHint = PTR_CAST ( TextHint , & rHint ) ;
const SvxViewHint * pViewHint = PTR_CAST ( SvxViewHint , & rHint ) ;
const SvxEditSourceHint * pEditSourceHint = PTR_CAST ( SvxEditSourceHint , & rHint ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
try
2002-05-16 15:12:20 +00:00
{
2002-12-12 11:36:51 +00:00
// Process notification event
2002-05-17 18:12:44 +00:00
if ( pEditSourceHint )
2002-05-16 15:12:20 +00:00
{
2002-12-12 11:36:51 +00:00
maEventQueue . Append ( * pEditSourceHint ) ;
2010-11-09 01:42:14 +05:00
// EditEngine should emit TEXT_SELECTION_CHANGED events (#i27299#)
2006-02-01 14:01:55 +00:00
if ( maEventOpenFrames = = 0 )
ProcessQueue ( ) ;
2002-05-17 18:12:44 +00:00
}
else if ( pTextHint )
{
2002-05-27 15:43:06 +00:00
switch ( pTextHint - > GetId ( ) )
2002-05-17 18:12:44 +00:00
{
2002-12-12 11:36:51 +00:00
case TEXT_HINT_BLOCKNOTIFICATION_END :
case TEXT_HINT_INPUT_END :
- - maEventOpenFrames ;
2002-05-17 18:12:44 +00:00
2002-12-12 11:36:51 +00:00
if ( maEventOpenFrames = = 0 )
{
// #103483#
/* All information should have arrived
* now , process queue . As stated in the
* above bug , we can often avoid throwing
* away all paragraphs by looking forward
* in the event queue ( searching for
* PARAINSERT / REMOVE events ) . Furthermore ,
* processing the event queue only at the
* end of an interaction cycle , ensures
* that the EditEngine state and the
* AccessibleText state are the same
* ( well , mostly . If there are _multiple_
* interaction cycles in the EE queues , it
* can still happen that EE state is
* different . That ' s so to say broken by
* design with that delayed EE event
* concept ) .
*/
ProcessQueue ( ) ;
}
2002-05-27 15:43:06 +00:00
break ;
2002-05-16 15:12:20 +00:00
2002-12-12 11:36:51 +00:00
case TEXT_HINT_BLOCKNOTIFICATION_START :
case TEXT_HINT_INPUT_START :
+ + maEventOpenFrames ;
2010-11-09 01:42:14 +05:00
// no FALLTHROUGH reason: event will not be processed,
// thus appending the event isn't necessary. (#i27299#)
2006-02-01 14:01:55 +00:00
break ;
2002-12-12 11:36:51 +00:00
default :
maEventQueue . Append ( * pTextHint ) ;
2010-11-09 01:42:14 +05:00
// EditEngine should emit TEXT_SELECTION_CHANGED events (#i27299#)
2006-02-01 14:01:55 +00:00
if ( maEventOpenFrames = = 0 )
ProcessQueue ( ) ;
2002-05-27 15:43:06 +00:00
break ;
2002-05-16 15:12:20 +00:00
}
2002-05-17 18:12:44 +00:00
}
else if ( pViewHint )
2002-05-16 15:12:20 +00:00
{
2002-12-12 11:36:51 +00:00
maEventQueue . Append ( * pViewHint ) ;
// process visibility right away, if not within an
// open EE notification frame. Otherwise, event
// processing would be delayed until next EE
// notification sequence.
if ( maEventOpenFrames = = 0 )
ProcessQueue ( ) ;
2002-05-16 15:12:20 +00:00
}
2002-05-23 11:46:18 +00:00
else if ( pSdrHint )
{
2002-12-12 11:36:51 +00:00
maEventQueue . Append ( * pSdrHint ) ;
// process drawing layer events right away, if not
// within an open EE notification frame. Otherwise,
// event processing would be delayed until next EE
// notification sequence.
if ( maEventOpenFrames = = 0 )
ProcessQueue ( ) ;
2002-05-23 11:46:18 +00:00
}
2002-05-17 18:12:44 +00:00
// it's VITAL to keep the SfxSimpleHint last! It's the base of some classes above!
else if ( pSimpleHint )
2002-05-16 15:12:20 +00:00
{
2002-12-12 11:36:51 +00:00
// handle this event _at once_, because after that, objects are invalid
2002-05-17 18:12:44 +00:00
switch ( pSimpleHint - > GetId ( ) )
{
case SFX_HINT_DYING :
// edit source is dying under us, become defunc then
2002-12-12 11:36:51 +00:00
maEventQueue . Clear ( ) ;
2002-05-17 18:12:44 +00:00
try
{
// make edit source inaccessible
// Note: cannot destroy it here, since we're called from there!
ShutdownEditSource ( ) ;
}
2002-05-23 11:46:18 +00:00
catch ( const uno : : Exception & ) { }
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
break ;
}
2002-05-16 15:12:20 +00:00
}
}
2002-05-23 11:46:18 +00:00
catch ( const uno : : Exception & )
2002-05-17 18:12:44 +00:00
{
2002-05-16 15:12:20 +00:00
# ifdef DBG_UTIL
2002-06-12 12:41:41 +00:00
OSL_TRACE ( " AccessibleTextHelper_Impl::Notify: Unhandled exception. " ) ;
2002-05-16 15:12:20 +00:00
# endif
2002-06-04 17:44:27 +00:00
mbInNotify = sal_False ;
2002-05-17 18:12:44 +00:00
}
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
mbInNotify = sal_False ;
}
2002-05-16 15:12:20 +00:00
2002-06-26 10:38:03 +00:00
void AccessibleTextHelper_Impl : : Dispose ( )
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
if ( getNotifierClientId ( ) ! = - 1 )
{
try
{
// #106234# Unregister from EventNotifier
: : comphelper : : AccessibleEventNotifier : : revokeClient ( getNotifierClientId ( ) ) ;
# ifdef DBG_UTIL
OSL_TRACE ( " AccessibleTextHelper_Impl disposed ID: %d " , mnNotifierClientId ) ;
# endif
}
catch ( const uno : : Exception & ) { }
mnNotifierClientId = - 1 ;
}
try
{
// dispose children
maParaManager . Dispose ( ) ;
}
catch ( const uno : : Exception & ) { }
2002-07-24 15:19:19 +00:00
// quit listen on stale edit source
if ( maEditSource . IsValid ( ) )
EndListening ( maEditSource . GetBroadcaster ( ) ) ;
// clear references
2011-09-22 15:00:08 +01:00
SAL_WNODEPRECATED_DECLARATIONS_PUSH
2002-07-24 15:19:19 +00:00
maEditSource . SetEditSource ( : : std : : auto_ptr < SvxEditSource > ( NULL ) ) ;
2011-09-22 15:00:08 +01:00
SAL_WNODEPRECATED_DECLARATIONS_POP
2002-06-26 10:38:03 +00:00
mxFrontEnd = NULL ;
}
2002-05-17 18:12:44 +00:00
void AccessibleTextHelper_Impl : : FireEvent ( const sal_Int16 nEventId , const uno : : Any & rNewValue , const uno : : Any & rOldValue ) const
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
2002-05-17 18:12:44 +00:00
// -- object locked --
: : osl : : ClearableMutexGuard aGuard ( maMutex ) ;
2002-05-16 15:12:20 +00:00
2002-05-27 15:43:06 +00:00
AccessibleEventObject aEvent ;
2002-06-26 10:38:03 +00:00
DBG_ASSERT ( mxFrontEnd . is ( ) , " AccessibleTextHelper::FireEvent: no event source set " ) ;
2002-05-27 15:43:06 +00:00
if ( mxFrontEnd . is ( ) )
aEvent = AccessibleEventObject ( mxFrontEnd - > getAccessibleContext ( ) , nEventId , rNewValue , rOldValue ) ;
else
aEvent = AccessibleEventObject ( uno : : Reference < uno : : XInterface > ( ) , nEventId , rNewValue , rOldValue ) ;
2002-05-16 15:12:20 +00:00
2003-03-27 14:06:05 +00:00
// no locking necessary, FireEvent internally copies listeners
// if someone removes/adds in between Further locking,
// actually, might lead to deadlocks, since we're calling out
// of this object
2002-06-12 16:20:45 +00:00
aGuard . clear ( ) ;
// -- until here --
FireEvent ( aEvent ) ;
}
void AccessibleTextHelper_Impl : : FireEvent ( const AccessibleEventObject & rEvent ) const
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
2002-05-16 15:12:20 +00:00
2002-08-23 16:50:51 +00:00
// #102261# Call global queue for focus events
if ( rEvent . EventId = = AccessibleStateType : : FOCUSED )
vcl : : unohelper : : NotifyAccessibleStateEventGlobally ( rEvent ) ;
2003-03-27 14:06:05 +00:00
// #106234# Delegate to EventNotifier
: : comphelper : : AccessibleEventNotifier : : addEvent ( getNotifierClientId ( ) ,
rEvent ) ;
2002-05-16 15:12:20 +00:00
}
2002-05-17 18:12:44 +00:00
// XAccessibleContext
2002-06-26 10:38:03 +00:00
sal_Int32 SAL_CALL AccessibleTextHelper_Impl : : getAccessibleChildCount ( ) SAL_THROW ( ( uno : : RuntimeException ) )
2002-05-16 15:12:20 +00:00
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
2002-05-17 18:12:44 +00:00
return mnLastVisibleChild - mnFirstVisibleChild + 1 ;
2002-05-16 15:12:20 +00:00
}
2002-06-26 10:38:03 +00:00
uno : : Reference < XAccessible > SAL_CALL AccessibleTextHelper_Impl : : getAccessibleChild ( sal_Int32 i ) SAL_THROW ( ( lang : : IndexOutOfBoundsException , uno : : RuntimeException ) )
2002-05-17 18:12:44 +00:00
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
2002-06-26 10:38:03 +00:00
i - = GetStartIndex ( ) ;
2002-05-23 11:46:18 +00:00
2002-07-31 08:24:19 +00:00
if ( 0 > i | | i > = getAccessibleChildCount ( ) | |
2002-05-17 18:12:44 +00:00
GetTextForwarder ( ) . GetParagraphCount ( ) < = i )
{
throw lang : : IndexOutOfBoundsException ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Invalid child index " ) ) , mxFrontEnd ) ;
}
2002-05-16 15:12:20 +00:00
2002-06-26 10:38:03 +00:00
DBG_ASSERT ( mxFrontEnd . is ( ) , " AccessibleTextHelper_Impl::UpdateVisibleChildren: no frontend set " ) ;
if ( mxFrontEnd . is ( ) )
return maParaManager . CreateChild ( i , mxFrontEnd , GetEditSource ( ) , mnFirstVisibleChild + i ) . first ;
else
return NULL ;
2002-05-17 18:12:44 +00:00
}
2002-05-16 15:12:20 +00:00
2012-11-29 00:27:03 +01:00
void SAL_CALL AccessibleTextHelper_Impl : : addAccessibleEventListener ( const uno : : Reference < XAccessibleEventListener > & xListener ) SAL_THROW ( ( uno : : RuntimeException ) )
2002-05-17 18:12:44 +00:00
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
if ( getNotifierClientId ( ) ! = - 1 )
: : comphelper : : AccessibleEventNotifier : : addEventListener ( getNotifierClientId ( ) , xListener ) ;
2002-05-17 18:12:44 +00:00
}
2002-05-16 15:12:20 +00:00
2012-11-29 00:27:03 +01:00
void SAL_CALL AccessibleTextHelper_Impl : : removeAccessibleEventListener ( const uno : : Reference < XAccessibleEventListener > & xListener ) SAL_THROW ( ( uno : : RuntimeException ) )
2002-05-17 18:12:44 +00:00
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
if ( getNotifierClientId ( ) ! = - 1 )
: : comphelper : : AccessibleEventNotifier : : removeEventListener ( getNotifierClientId ( ) , xListener ) ;
2002-05-17 18:12:44 +00:00
}
2002-05-16 15:12:20 +00:00
2003-04-24 16:11:28 +00:00
uno : : Reference < XAccessible > SAL_CALL AccessibleTextHelper_Impl : : getAccessibleAtPoint ( const awt : : Point & _aPoint ) SAL_THROW ( ( uno : : RuntimeException ) )
2002-05-17 18:12:44 +00:00
{
2003-03-27 14:06:05 +00:00
DBG_CHKTHIS ( AccessibleTextHelper_Impl , NULL ) ;
2002-05-17 18:12:44 +00:00
// make given position relative
if ( ! mxFrontEnd . is ( ) )
throw uno : : RuntimeException ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " AccessibleTextHelper_Impl::getAccessibleAt: frontend invalid " ) ) , mxFrontEnd ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
uno : : Reference < XAccessibleContext > xFrontEndContext = mxFrontEnd - > getAccessibleContext ( ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
if ( ! xFrontEndContext . is ( ) )
throw uno : : RuntimeException ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " AccessibleTextHelper_Impl::getAccessibleAt: frontend invalid " ) ) , mxFrontEnd ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
uno : : Reference < XAccessibleComponent > xFrontEndComponent ( xFrontEndContext , uno : : UNO_QUERY ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
if ( ! xFrontEndComponent . is ( ) )
throw uno : : RuntimeException ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " AccessibleTextHelper_Impl::getAccessibleAt: frontend is no XAccessibleComponent " ) ) ,
mxFrontEnd ) ;
2002-05-16 15:12:20 +00:00
2002-10-02 16:09:36 +00:00
// #103862# No longer need to make given position relative
2002-05-17 18:12:44 +00:00
Point aPoint ( _aPoint . X , _aPoint . Y ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// respect EditEngine offset to surrounding shape/cell
aPoint - = GetOffset ( ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// convert to EditEngine coordinate system
SvxTextForwarder & rCacheTF = GetTextForwarder ( ) ;
Point aLogPoint ( GetViewForwarder ( ) . PixelToLogic ( aPoint , rCacheTF . GetMapMode ( ) ) ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// iterate over all visible children (including those not yet created)
sal_Int32 nChild ;
for ( nChild = mnFirstVisibleChild ; nChild < = mnLastVisibleChild ; + + nChild )
2002-05-16 15:12:20 +00:00
{
2002-05-17 18:12:44 +00:00
DBG_ASSERT ( nChild > = 0 & & nChild < = USHRT_MAX ,
" AccessibleTextHelper_Impl::getAccessibleAt: index value overflow " ) ;
2011-01-10 16:11:35 +01:00
Rectangle aParaBounds ( rCacheTF . GetParaBounds ( static_cast < sal_uInt16 > ( nChild ) ) ) ;
2002-05-17 18:12:44 +00:00
if ( aParaBounds . IsInside ( aLogPoint ) )
2003-06-24 06:39:36 +00:00
return getAccessibleChild ( nChild - mnFirstVisibleChild + GetStartIndex ( ) ) ;
2002-05-16 15:12:20 +00:00
}
2002-05-17 18:12:44 +00:00
// found none
2002-06-26 10:38:03 +00:00
return NULL ;
2002-05-16 15:12:20 +00:00
}
2002-05-17 18:12:44 +00:00
//------------------------------------------------------------------------
//
// AccessibleTextHelper implementation (simply forwards to impl)
//
//------------------------------------------------------------------------
2002-05-16 15:12:20 +00:00
2011-09-22 15:00:08 +01:00
SAL_WNODEPRECATED_DECLARATIONS_PUSH
2002-06-26 10:38:03 +00:00
AccessibleTextHelper : : AccessibleTextHelper ( : : std : : auto_ptr < SvxEditSource > pEditSource ) :
2006-02-01 14:01:55 +00:00
mpImpl ( new AccessibleTextHelper_Impl ( ) )
2002-05-17 18:12:44 +00:00
{
2010-10-13 02:47:36 -05:00
SolarMutexGuard aGuard ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
SetEditSource ( pEditSource ) ;
}
2011-09-22 15:00:08 +01:00
SAL_WNODEPRECATED_DECLARATIONS_PUSH
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
AccessibleTextHelper : : ~ AccessibleTextHelper ( )
{
}
2002-05-16 15:12:20 +00:00
2002-06-26 10:38:03 +00:00
const SvxEditSource & AccessibleTextHelper : : GetEditSource ( ) const SAL_THROW ( ( uno : : RuntimeException ) )
2002-05-17 18:12:44 +00:00
{
2002-05-16 15:12:20 +00:00
# ifdef DBG_UTIL
2002-05-17 18:12:44 +00:00
mpImpl - > CheckInvariants ( ) ;
2002-05-16 15:12:20 +00:00
2002-06-07 11:19:53 +00:00
const SvxEditSource & aEditSource = mpImpl - > GetEditSource ( ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
mpImpl - > CheckInvariants ( ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
return aEditSource ;
2002-05-16 15:12:20 +00:00
# else
2002-05-17 18:12:44 +00:00
return mpImpl - > GetEditSource ( ) ;
2002-05-16 15:12:20 +00:00
# endif
2002-05-17 18:12:44 +00:00
}
2002-05-16 15:12:20 +00:00
2011-09-22 15:00:08 +01:00
SAL_WNODEPRECATED_DECLARATIONS_PUSH
2002-06-26 10:38:03 +00:00
void AccessibleTextHelper : : SetEditSource ( : : std : : auto_ptr < SvxEditSource > pEditSource ) SAL_THROW ( ( uno : : RuntimeException ) )
2002-05-17 18:12:44 +00:00
{
2002-05-16 15:12:20 +00:00
# ifdef DBG_UTIL
2002-06-12 12:41:41 +00:00
// precondition: solar mutex locked
DBG_TESTSOLARMUTEX ( ) ;
2002-05-17 18:12:44 +00:00
mpImpl - > CheckInvariants ( ) ;
2002-06-12 12:41:41 +00:00
# endif
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
mpImpl - > SetEditSource ( pEditSource ) ;
2002-05-16 15:12:20 +00:00
2002-06-12 12:41:41 +00:00
# ifdef DBG_UTIL
2002-05-17 18:12:44 +00:00
mpImpl - > CheckInvariants ( ) ;
2002-05-16 15:12:20 +00:00
# endif
2002-05-17 18:12:44 +00:00
}
2011-09-22 15:00:08 +01:00
SAL_WNODEPRECATED_DECLARATIONS_POP
2002-05-16 15:12:20 +00:00
2002-06-26 10:38:03 +00:00
void AccessibleTextHelper : : SetEventSource ( const uno : : Reference < XAccessible > & rInterface )
{
# ifdef DBG_UTIL
mpImpl - > CheckInvariants ( ) ;
# endif
mpImpl - > SetEventSource ( rInterface ) ;
# ifdef DBG_UTIL
mpImpl - > CheckInvariants ( ) ;
# endif
}
uno : : Reference < XAccessible > AccessibleTextHelper : : GetEventSource ( ) const
{
# ifdef DBG_UTIL
mpImpl - > CheckInvariants ( ) ;
uno : : Reference < XAccessible > xRet ( mpImpl - > GetEventSource ( ) ) ;
mpImpl - > CheckInvariants ( ) ;
return xRet ;
# else
return mpImpl - > GetEventSource ( ) ;
# endif
}
void AccessibleTextHelper : : SetFocus ( sal_Bool bHaveFocus ) SAL_THROW ( ( : : com : : sun : : star : : uno : : RuntimeException ) )
2002-05-17 18:12:44 +00:00
{
2002-05-23 11:46:18 +00:00
# ifdef DBG_UTIL
2002-06-12 12:41:41 +00:00
// precondition: solar mutex locked
DBG_TESTSOLARMUTEX ( ) ;
2002-05-23 11:46:18 +00:00
mpImpl - > CheckInvariants ( ) ;
2002-06-12 12:41:41 +00:00
# endif
2002-05-23 11:46:18 +00:00
mpImpl - > SetFocus ( bHaveFocus ) ;
2002-06-12 12:41:41 +00:00
# ifdef DBG_UTIL
2002-05-23 11:46:18 +00:00
mpImpl - > CheckInvariants ( ) ;
# endif
2002-05-17 18:12:44 +00:00
}
2002-06-26 10:38:03 +00:00
sal_Bool AccessibleTextHelper : : HaveFocus ( ) SAL_THROW ( ( : : com : : sun : : star : : uno : : RuntimeException ) )
2002-05-17 18:12:44 +00:00
{
2002-05-23 11:46:18 +00:00
# ifdef DBG_UTIL
mpImpl - > CheckInvariants ( ) ;
sal_Bool bRet ( mpImpl - > HaveFocus ( ) ) ;
mpImpl - > CheckInvariants ( ) ;
return bRet ;
# else
return mpImpl - > HaveFocus ( ) ;
# endif
2002-05-17 18:12:44 +00:00
}
void AccessibleTextHelper : : FireEvent ( const sal_Int16 nEventId , const uno : : Any & rNewValue , const uno : : Any & rOldValue ) const
{
2002-05-16 15:12:20 +00:00
# ifdef DBG_UTIL
2002-05-17 18:12:44 +00:00
mpImpl - > CheckInvariants ( ) ;
2002-06-12 12:41:41 +00:00
# endif
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
mpImpl - > FireEvent ( nEventId , rNewValue , rOldValue ) ;
2002-05-16 15:12:20 +00:00
2002-06-12 16:20:45 +00:00
# ifdef DBG_UTIL
mpImpl - > CheckInvariants ( ) ;
# endif
}
void AccessibleTextHelper : : FireEvent ( const AccessibleEventObject & rEvent ) const
{
# ifdef DBG_UTIL
mpImpl - > CheckInvariants ( ) ;
# endif
mpImpl - > FireEvent ( rEvent ) ;
2002-06-12 12:41:41 +00:00
# ifdef DBG_UTIL
2002-05-17 18:12:44 +00:00
mpImpl - > CheckInvariants ( ) ;
2002-05-16 15:12:20 +00:00
# endif
2002-05-17 18:12:44 +00:00
}
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
void AccessibleTextHelper : : SetOffset ( const Point & rPoint )
{
2002-05-16 15:12:20 +00:00
# ifdef DBG_UTIL
2002-06-12 12:41:41 +00:00
// precondition: solar mutex locked
DBG_TESTSOLARMUTEX ( ) ;
2002-05-17 18:12:44 +00:00
mpImpl - > CheckInvariants ( ) ;
2002-06-12 12:41:41 +00:00
# endif
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
mpImpl - > SetOffset ( rPoint ) ;
2002-05-16 15:12:20 +00:00
2002-06-12 12:41:41 +00:00
# ifdef DBG_UTIL
2002-05-17 18:12:44 +00:00
mpImpl - > CheckInvariants ( ) ;
2002-05-16 15:12:20 +00:00
# endif
2002-05-17 18:12:44 +00:00
}
2002-05-16 15:12:20 +00:00
2002-06-07 11:19:53 +00:00
Point AccessibleTextHelper : : GetOffset ( ) const
2002-05-17 18:12:44 +00:00
{
2002-05-16 15:12:20 +00:00
# ifdef DBG_UTIL
2002-05-17 18:12:44 +00:00
mpImpl - > CheckInvariants ( ) ;
2002-05-16 15:12:20 +00:00
2002-06-07 11:19:53 +00:00
Point aPoint ( mpImpl - > GetOffset ( ) ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
mpImpl - > CheckInvariants ( ) ;
2002-05-16 15:12:20 +00:00
2002-06-07 11:19:53 +00:00
return aPoint ;
2002-05-16 15:12:20 +00:00
# else
2002-05-17 18:12:44 +00:00
return mpImpl - > GetOffset ( ) ;
2002-05-16 15:12:20 +00:00
# endif
2002-05-17 18:12:44 +00:00
}
2002-05-16 15:12:20 +00:00
2002-06-26 10:38:03 +00:00
void AccessibleTextHelper : : SetStartIndex ( sal_Int32 nOffset )
2002-05-17 18:12:44 +00:00
{
2002-05-23 11:46:18 +00:00
# ifdef DBG_UTIL
2002-06-12 12:41:41 +00:00
// precondition: solar mutex locked
DBG_TESTSOLARMUTEX ( ) ;
2002-05-23 11:46:18 +00:00
mpImpl - > CheckInvariants ( ) ;
2002-06-12 12:41:41 +00:00
# endif
2002-05-23 11:46:18 +00:00
2002-06-26 10:38:03 +00:00
mpImpl - > SetStartIndex ( nOffset ) ;
2002-05-23 11:46:18 +00:00
2002-06-12 12:41:41 +00:00
# ifdef DBG_UTIL
2002-05-23 11:46:18 +00:00
mpImpl - > CheckInvariants ( ) ;
# endif
2002-05-17 18:12:44 +00:00
}
2002-06-26 10:38:03 +00:00
sal_Int32 AccessibleTextHelper : : GetStartIndex ( ) const
2002-05-17 18:12:44 +00:00
{
2002-05-23 11:46:18 +00:00
# ifdef DBG_UTIL
mpImpl - > CheckInvariants ( ) ;
2002-06-26 10:38:03 +00:00
sal_Int32 nOffset = mpImpl - > GetStartIndex ( ) ;
2002-05-23 11:46:18 +00:00
mpImpl - > CheckInvariants ( ) ;
return nOffset ;
# else
2002-06-26 10:38:03 +00:00
return mpImpl - > GetStartIndex ( ) ;
2002-05-23 11:46:18 +00:00
# endif
2002-05-17 18:12:44 +00:00
}
2006-01-13 16:18:22 +00:00
void AccessibleTextHelper : : SetAdditionalChildStates ( const VectorOfStates & rChildStates )
{
mpImpl - > SetAdditionalChildStates ( rChildStates ) ;
}
2002-06-26 10:38:03 +00:00
void AccessibleTextHelper : : UpdateChildren ( ) SAL_THROW ( ( : : com : : sun : : star : : uno : : RuntimeException ) )
2002-05-17 18:12:44 +00:00
{
2002-05-16 15:12:20 +00:00
# ifdef DBG_UTIL
2002-06-12 12:41:41 +00:00
// precondition: solar mutex locked
DBG_TESTSOLARMUTEX ( ) ;
2002-05-17 18:12:44 +00:00
mpImpl - > CheckInvariants ( ) ;
2002-06-12 12:41:41 +00:00
# endif
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
mpImpl - > UpdateVisibleChildren ( ) ;
2002-08-02 10:35:10 +00:00
mpImpl - > UpdateBoundRect ( ) ;
2002-05-16 15:12:20 +00:00
2002-06-12 12:41:41 +00:00
mpImpl - > UpdateSelection ( ) ;
2002-06-26 10:38:03 +00:00
# ifdef DBG_UTIL
mpImpl - > CheckInvariants ( ) ;
# endif
}
void AccessibleTextHelper : : Dispose ( )
{
2002-07-05 12:51:38 +00:00
// As Dispose calls ShutdownEditSource, which in turn
// deregisters as listener on the edit source, have to lock
// here
2010-10-13 02:47:36 -05:00
SolarMutexGuard aGuard ;
2002-07-05 12:51:38 +00:00
2002-06-26 10:38:03 +00:00
# ifdef DBG_UTIL
mpImpl - > CheckInvariants ( ) ;
# endif
mpImpl - > Dispose ( ) ;
2002-06-12 12:41:41 +00:00
# ifdef DBG_UTIL
2002-05-17 18:12:44 +00:00
mpImpl - > CheckInvariants ( ) ;
2002-05-16 15:12:20 +00:00
# endif
2002-05-17 18:12:44 +00:00
}
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
sal_Bool AccessibleTextHelper : : IsSelected ( ) const
{
2010-10-13 02:47:36 -05:00
SolarMutexGuard aGuard ;
2002-06-07 11:19:53 +00:00
2002-05-16 15:12:20 +00:00
# ifdef DBG_UTIL
2002-05-17 18:12:44 +00:00
mpImpl - > CheckInvariants ( ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
sal_Bool aRet = mpImpl - > IsSelected ( ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
mpImpl - > CheckInvariants ( ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
return aRet ;
2002-05-16 15:12:20 +00:00
# else
2002-05-17 18:12:44 +00:00
return mpImpl - > IsSelected ( ) ;
2002-05-16 15:12:20 +00:00
# endif
2002-05-17 18:12:44 +00:00
}
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// XAccessibleContext
2002-06-26 10:38:03 +00:00
sal_Int32 AccessibleTextHelper : : GetChildCount ( ) SAL_THROW ( ( uno : : RuntimeException ) )
2002-05-17 18:12:44 +00:00
{
2010-10-13 02:47:36 -05:00
SolarMutexGuard aGuard ;
2002-06-07 11:19:53 +00:00
2002-05-16 15:12:20 +00:00
# ifdef DBG_UTIL
2002-05-17 18:12:44 +00:00
mpImpl - > CheckInvariants ( ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
sal_Int32 nRet = mpImpl - > getAccessibleChildCount ( ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
mpImpl - > CheckInvariants ( ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
return nRet ;
2002-05-16 15:12:20 +00:00
# else
2002-05-17 18:12:44 +00:00
return mpImpl - > getAccessibleChildCount ( ) ;
2002-05-16 15:12:20 +00:00
# endif
2002-05-17 18:12:44 +00:00
}
2002-05-16 15:12:20 +00:00
2002-06-26 10:38:03 +00:00
uno : : Reference < XAccessible > AccessibleTextHelper : : GetChild ( sal_Int32 i ) SAL_THROW ( ( lang : : IndexOutOfBoundsException , uno : : RuntimeException ) )
2002-05-17 18:12:44 +00:00
{
2010-10-13 02:47:36 -05:00
SolarMutexGuard aGuard ;
2002-06-07 11:19:53 +00:00
2002-05-16 15:12:20 +00:00
# ifdef DBG_UTIL
2002-05-17 18:12:44 +00:00
mpImpl - > CheckInvariants ( ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
uno : : Reference < XAccessible > xRet = mpImpl - > getAccessibleChild ( i ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
mpImpl - > CheckInvariants ( ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
return xRet ;
2002-05-16 15:12:20 +00:00
# else
2002-05-17 18:12:44 +00:00
return mpImpl - > getAccessibleChild ( i ) ;
2002-05-16 15:12:20 +00:00
# endif
2002-05-17 18:12:44 +00:00
}
2002-05-16 15:12:20 +00:00
2002-06-26 10:38:03 +00:00
void AccessibleTextHelper : : AddEventListener ( const uno : : Reference < XAccessibleEventListener > & xListener ) SAL_THROW ( ( uno : : RuntimeException ) )
2002-05-17 18:12:44 +00:00
{
2002-05-16 15:12:20 +00:00
# ifdef DBG_UTIL
2002-05-17 18:12:44 +00:00
mpImpl - > CheckInvariants ( ) ;
2002-05-16 15:12:20 +00:00
2012-11-29 00:27:03 +01:00
mpImpl - > addAccessibleEventListener ( xListener ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
mpImpl - > CheckInvariants ( ) ;
2002-05-16 15:12:20 +00:00
# else
2012-11-29 00:27:03 +01:00
mpImpl - > addAccessibleEventListener ( xListener ) ;
2002-05-16 15:12:20 +00:00
# endif
2002-05-17 18:12:44 +00:00
}
2002-05-16 15:12:20 +00:00
2002-06-26 10:38:03 +00:00
void AccessibleTextHelper : : RemoveEventListener ( const uno : : Reference < XAccessibleEventListener > & xListener ) SAL_THROW ( ( uno : : RuntimeException ) )
2002-05-17 18:12:44 +00:00
{
2002-05-16 15:12:20 +00:00
# ifdef DBG_UTIL
2002-05-17 18:12:44 +00:00
mpImpl - > CheckInvariants ( ) ;
2002-05-16 15:12:20 +00:00
2012-11-29 00:27:03 +01:00
mpImpl - > removeAccessibleEventListener ( xListener ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
mpImpl - > CheckInvariants ( ) ;
2002-05-16 15:12:20 +00:00
# else
2012-11-29 00:27:03 +01:00
mpImpl - > removeAccessibleEventListener ( xListener ) ;
2002-05-16 15:12:20 +00:00
# endif
2002-05-17 18:12:44 +00:00
}
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// XAccessibleComponent
2002-06-26 10:38:03 +00:00
uno : : Reference < XAccessible > AccessibleTextHelper : : GetAt ( const awt : : Point & aPoint ) SAL_THROW ( ( uno : : RuntimeException ) )
2002-05-17 18:12:44 +00:00
{
2010-10-13 02:47:36 -05:00
SolarMutexGuard aGuard ;
2002-06-07 11:19:53 +00:00
2002-05-16 15:12:20 +00:00
# ifdef DBG_UTIL
2002-05-17 18:12:44 +00:00
mpImpl - > CheckInvariants ( ) ;
2002-05-16 15:12:20 +00:00
2003-04-24 16:11:28 +00:00
uno : : Reference < XAccessible > xChild = mpImpl - > getAccessibleAtPoint ( aPoint ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
mpImpl - > CheckInvariants ( ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
return xChild ;
2002-05-16 15:12:20 +00:00
# else
2003-04-24 16:11:28 +00:00
return mpImpl - > getAccessibleAtPoint ( aPoint ) ;
2002-05-16 15:12:20 +00:00
# endif
2002-05-17 18:12:44 +00:00
}
} // end of namespace accessibility
2002-05-16 15:12:20 +00:00
//------------------------------------------------------------------------
2010-10-12 15:53:47 +02:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */