2002-05-16 15:12:20 +00:00
/*************************************************************************
*
* $ RCSfile : AccessibleTextHelper . cxx , v $
*
2002-05-29 16:01:52 +00:00
* $ Revision : 1.8 $
2002-05-16 15:12:20 +00:00
*
2002-05-29 16:01:52 +00:00
* last change : $ Author : thb $ $ Date : 2002 - 05 - 29 17 : 01 : 52 $
2002-05-16 15:12:20 +00:00
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc . , October , 2000
*
* GNU Lesser General Public License Version 2.1
* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
* Copyright 2000 by Sun Microsystems , Inc .
* 901 San Antonio Road , Palo Alto , CA 94303 , USA
*
* This library is free software ; you can redistribute it and / or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1 , as published by the Free Software Foundation .
*
* This library is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
* Lesser General Public License for more details .
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library ; if not , write to the Free Software
* Foundation , Inc . , 59 Temple Place , Suite 330 , Boston ,
* MA 02111 - 1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 ( 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.openoffice.org/license.html.
*
* Software provided under this License is provided on an " AS IS " basis ,
* WITHOUT WARRANTY OF ANY KIND , EITHER EXPRESSED OR IMPLIED , INCLUDING ,
* WITHOUT LIMITATION , WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS ,
* MERCHANTABLE , FIT FOR A PARTICULAR PURPOSE , OR NON - INFRINGING .
* See the License for the specific provisions governing your rights and
* obligations concerning the Software .
*
* The Initial Developer of the Original Code is : Sun Microsystems , Inc .
*
* Copyright : 2000 by Sun Microsystems , Inc .
*
* All Rights Reserved .
*
* Contributor ( s ) : _______________________________________
*
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
# pragma hdrstop
//------------------------------------------------------------------------
//
// Global header
//
//------------------------------------------------------------------------
# include <limits.h>
# include <memory>
# include <algorithm>
# ifndef _VOS_MUTEX_HXX_
# include <vos/mutex.hxx>
# endif
# ifndef _COM_SUN_STAR_UNO_ANY_HXX_
# include <com/sun/star/uno/Any.hxx>
# endif
# ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_
# include <com/sun/star/uno/Reference.hxx>
# endif
# ifndef _CPPUHELPER_WEAKREF_HXX_
# include <cppuhelper/weakref.hxx>
# endif
# ifndef _COM_SUN_STAR_AWT_POINT_HPP_
# include <com/sun/star/awt/Point.hpp>
# endif
# ifndef _COM_SUN_STAR_AWT_RECTANGLE_HPP_
# include <com/sun/star/awt/Rectangle.hpp>
# endif
# ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTID_HPP_
# include <drafts/com/sun/star/accessibility/AccessibleEventId.hpp>
# endif
# ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLE_HPP_
# include <drafts/com/sun/star/accessibility/XAccessible.hpp>
# endif
# ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLECONTEXT_HPP_
# include <drafts/com/sun/star/accessibility/XAccessibleContext.hpp>
# endif
# ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLECOMPONENT_HPP_
# include <drafts/com/sun/star/accessibility/XAccessibleComponent.hpp>
# endif
# ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HPP_
# include <drafts/com/sun/star/accessibility/AccessibleRole.hpp>
# endif
# ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLETEXTTYPE_HPP_
# include <drafts/com/sun/star/accessibility/AccessibleTextType.hpp>
# endif
# ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLETEXT_HPP_
# include <drafts/com/sun/star/accessibility/XAccessibleText.hpp>
# endif
# ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLEEDITABLETEXT_HPP_
# include <drafts/com/sun/star/accessibility/XAccessibleEditableText.hpp>
# endif
# ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLESTATETYPE_HPP_
# include <drafts/com/sun/star/accessibility/AccessibleStateType.hpp>
# endif
# ifndef _UTL_ACCESSIBLESTATESETHELPER_HXX_
# include <unotools/accessiblestatesethelper.hxx>
# endif
//------------------------------------------------------------------------
//
// Project-local header
//
//------------------------------------------------------------------------
2002-05-17 18:12:44 +00:00
# ifndef _SVX_ACCESSILE_TEXT_HELPER_HXX_
# include "AccessibleTextHelper.hxx"
2002-05-16 15:12:20 +00:00
# endif
# ifndef _SVX_UNOSHAPE_HXX
# include "unoshape.hxx"
# endif
# ifndef _UNO_LINGU_HXX
# include "unolingu.hxx"
# endif
# ifndef _SVX_UNOTEXT_HXX
# include "unotext.hxx"
# endif
# include "unoedhlp.hxx"
# include "unopracc.hxx"
# include "AccessibleParaManager.hxx"
# include "AccessibleEditableTextPara.hxx"
# include "svdmodel.hxx"
# include "svdpntv.hxx"
# include "editdata.hxx"
# include "editeng.hxx"
# include "editview.hxx"
using namespace : : com : : sun : : star ;
using namespace : : drafts : : com : : sun : : star : : accessibility ;
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
//
//------------------------------------------------------------------------
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 :
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
AccessibleTextHelper_Impl ( const uno : : Reference < XAccessible > & rInterface ) ;
~ AccessibleTextHelper_Impl ( ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// XAccessibleContext child handling methods
sal_Int32 SAL_CALL getAccessibleChildCount ( ) throw ( uno : : RuntimeException ) ;
uno : : Reference < XAccessible > SAL_CALL getAccessibleChild ( sal_Int32 i ) 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
void SAL_CALL addEventListener ( const uno : : Reference < XAccessibleEventListener > & xListener ) throw ( uno : : RuntimeException ) ;
void SAL_CALL removeEventListener ( const uno : : Reference < XAccessibleEventListener > & xListener ) throw ( uno : : RuntimeException ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// XAccessibleComponent child related methods
uno : : Reference < XAccessible > SAL_CALL getAccessibleAt ( const awt : : Point & aPoint ) throw ( uno : : RuntimeException ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
SvxEditSourceAdapter & GetEditSource ( ) const throw ( uno : : RuntimeException ) ;
void SetEditSource ( : : std : : auto_ptr < SvxEditSource > pEditSource ) throw ( uno : : RuntimeException ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
void SetOffset ( const Point & ) ;
const Point & GetOffset ( ) const { return maOffset ; } // Strictly correct only with locked solar mutex!
2002-05-16 15:12:20 +00:00
2002-05-23 11:46:18 +00:00
void SetChildrenOffset ( sal_Int32 nOffset ) ;
sal_Int32 GetChildrenOffset ( ) const { return mnStartIndex ; }
2002-05-17 18:12:44 +00:00
sal_Bool IsSelected ( ) const ;
2002-05-16 15:12:20 +00:00
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-05-16 15:12:20 +00:00
2002-05-23 11:46:18 +00:00
void SetFocus ( sal_Bool bHaveFocus ) throw ( : : com : : sun : : star : : uno : : RuntimeException ) ;
sal_Bool HaveFocus ( ) throw ( : : com : : sun : : star : : uno : : RuntimeException ) ;
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
void UpdateVisibleChildren ( ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
private :
2002-05-16 15:12:20 +00:00
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.
void ShutdownEditSource ( ) throw ( uno : : RuntimeException ) ;
2002-05-16 15:12:20 +00:00
2002-05-23 11:46:18 +00:00
void SetChildrenState ( const sal_Int16 nStateId ) ;
2002-05-29 16:01:52 +00:00
void SetChildrenState ( sal_Int32 nStartPara , sal_Int32 nEndPara , const sal_Int16 nStateId ) ;
2002-05-23 11:46:18 +00:00
void UnSetChildrenState ( const sal_Int16 nStateId ) ;
2002-05-29 16:01:52 +00:00
void UnSetChildrenState ( sal_Int32 nStartPara , sal_Int32 nEndPara , const sal_Int16 nStateId ) ;
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
2002-05-17 18:12:44 +00:00
// lock solar mutex before
SvxTextForwarder & GetTextForwarder ( ) const throw ( uno : : RuntimeException ) ;
// lock solar mutex before
SvxViewForwarder & GetViewForwarder ( ) const throw ( uno : : RuntimeException ) ;
// lock solar mutex before
SvxEditViewForwarder & GetEditViewForwarder ( sal_Bool bCreate = sal_False ) const throw ( uno : : RuntimeException ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// are we in edit mode?
sal_Bool IsActive ( ) const throw ( uno : : RuntimeException ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
void UpdateVisibleData ( ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// calls SetSelection on the forwarder and updates maLastSelection
// cache. Caution: calls StateChangeEvent and sets object into
// edit mode!
void UpdateSelection ( const ESelection & ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
/// our current offset to the containing shape/cell (guarded by solar mutex)
Point maOffset ;
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!
const 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-05-23 11:46:18 +00:00
// offset to add to all our children
sal_Int32 mnStartIndex ;
2002-05-17 18:12:44 +00:00
// the object handling our children (guarded by solar mutex)
accessibility : : AccessibleParaManager maParaManager ;
2002-05-16 15:12:20 +00:00
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-05-23 11:46:18 +00:00
// whether we have the focus set (guarded by solar mutex)
sal_Bool mbHaveFocus ;
2002-05-17 18:12:44 +00:00
// must be before maStateListeners, has to live longer
mutable : : osl : : Mutex maMutex ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// handles our event listeners (guarded by maMutex)
: : cppu : : OInterfaceContainerHelper maStateListeners ;
2002-05-16 15:12:20 +00:00
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-05-17 18:12:44 +00:00
AccessibleTextHelper_Impl : : AccessibleTextHelper_Impl ( const uno : : Reference < XAccessible > & rInterface ) :
maOffset ( 0 , 0 ) ,
mxFrontEnd ( rInterface ) ,
maLastSelection ( 0 , 0 , 0 , 0 ) ,
mnFirstVisibleChild ( - 1 ) ,
mnLastVisibleChild ( - 2 ) ,
2002-05-23 11:46:18 +00:00
mnStartIndex ( 0 ) ,
2002-05-17 18:12:44 +00:00
mbInNotify ( sal_False ) ,
2002-05-23 11:46:18 +00:00
mbHaveFocus ( sal_False ) ,
2002-05-17 18:12:44 +00:00
maStateListeners ( maMutex )
2002-05-16 15:12:20 +00:00
{
}
2002-05-17 18:12:44 +00:00
AccessibleTextHelper_Impl : : ~ AccessibleTextHelper_Impl ( )
{
: : vos : : OGuard aGuard ( Application : : GetSolarMutex ( ) ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
try
{
// shutdown and release edit source
SetEditSource ( : : std : : auto_ptr < SvxEditSource > ( ) ) ;
}
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
// owner is responsible for dispose and clear on listeners
}
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
SvxTextForwarder & AccessibleTextHelper_Impl : : GetTextForwarder ( ) const throw ( uno : : RuntimeException )
{
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-05-17 18:12:44 +00:00
SvxViewForwarder & AccessibleTextHelper_Impl : : GetViewForwarder ( ) const throw ( uno : : RuntimeException )
{
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-05-17 18:12:44 +00:00
SvxEditViewForwarder & AccessibleTextHelper_Impl : : GetEditViewForwarder ( sal_Bool bCreate ) const throw ( uno : : RuntimeException )
2002-05-16 15:12:20 +00:00
{
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-05-17 18:12:44 +00:00
SvxEditSourceAdapter & AccessibleTextHelper_Impl : : GetEditSource ( ) const throw ( uno : : RuntimeException )
2002-05-16 15:12:20 +00:00
{
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
{
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)
class AccessibleTextHelper_OffsetChildIndex : public : : std : : unary_function < accessibility : : AccessibleEditableTextPara & , void >
{
public :
AccessibleTextHelper_OffsetChildIndex ( sal_Int32 nDifference ) : mnDifference ( nDifference ) { }
void operator ( ) ( accessibility : : AccessibleEditableTextPara & rPara )
{
rPara . SetIndexInParent ( rPara . GetIndexInParent ( ) + mnDifference ) ;
}
private :
const sal_Int32 mnDifference ;
} ;
void AccessibleTextHelper_Impl : : SetChildrenOffset ( sal_Int32 nOffset )
{
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 ) ) ;
}
}
void AccessibleTextHelper_Impl : : SetFocus ( sal_Bool bHaveFocus ) throw ( : : com : : sun : : star : : uno : : RuntimeException )
{
sal_Bool bOldFocus ( mbHaveFocus ) ;
mbHaveFocus = bHaveFocus ;
if ( IsActive ( ) )
{
try
{
// find the one with the cursor and get/set focus accordingly
ESelection aSelection ;
if ( GetEditViewForwarder ( ) . GetSelection ( aSelection ) )
{
AccessibleParaManager : : WeakPara : : HardRefType aChild ( maParaManager . GetChild ( aSelection . nEndPara ) . first . get ( ) ) ;
if ( maParaManager . IsReferencable ( aSelection . nEndPara ) )
{
if ( mbHaveFocus )
aChild - > SetState ( AccessibleStateType : : FOCUSED ) ;
else
aChild - > UnSetState ( AccessibleStateType : : FOCUSED ) ;
}
}
}
catch ( const uno : : Exception & ) { }
}
else if ( bOldFocus ! = bHaveFocus )
{
if ( mbHaveFocus )
GotPropertyEvent ( uno : : makeAny ( AccessibleStateType : : FOCUSED ) , AccessibleEventId : : ACCESSIBLE_STATE_EVENT ) ;
else
LostPropertyEvent ( uno : : makeAny ( AccessibleStateType : : FOCUSED ) , AccessibleEventId : : ACCESSIBLE_STATE_EVENT ) ;
}
}
sal_Bool AccessibleTextHelper_Impl : : HaveFocus ( ) throw ( : : com : : sun : : star : : uno : : RuntimeException )
{
: : vos : : OGuard aGuard ( Application : : GetSolarMutex ( ) ) ;
if ( mbHaveFocus & & ! IsActive ( ) )
return sal_True ;
else
return sal_False ;
}
2002-05-17 18:12:44 +00:00
sal_Bool AccessibleTextHelper_Impl : : IsActive ( ) const throw ( uno : : RuntimeException )
{
SvxEditSource & rEditSource = GetEditSource ( ) ;
SvxEditViewForwarder * pViewForwarder = rEditSource . GetEditViewForwarder ( ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
if ( ! pViewForwarder )
return sal_False ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
if ( pViewForwarder - > IsValid ( ) )
return sal_True ;
else
return sal_False ;
}
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
void AccessibleTextHelper_Impl : : UpdateSelection ( const ESelection & rSelection )
2002-05-16 15:12:20 +00:00
{
2002-05-17 18:12:44 +00:00
if ( ! maLastSelection . IsEqual ( rSelection ) )
{
// notify all affected paragraphs (TODO: may be suboptimal,
// since some paragraphs might stay selected)
2002-05-16 15:12:20 +00:00
2002-05-29 16:01:52 +00:00
UnSetChildrenState ( maLastSelection . nStartPara ,
maLastSelection . nEndPara ,
AccessibleStateType : : SELECTED ) ;
2002-05-17 18:12:44 +00:00
maParaManager . FireEvent ( maLastSelection . nStartPara ,
maLastSelection . nEndPara ,
AccessibleEventId : : ACCESSIBLE_SELECTION_EVENT ) ;
2002-05-16 15:12:20 +00:00
2002-05-29 15:09:56 +00:00
maParaManager . FireEvent ( maLastSelection . nEndPara ,
2002-05-29 16:01:52 +00:00
maLastSelection . nEndPara + 1 ,
2002-05-17 18:12:44 +00:00
AccessibleEventId : : ACCESSIBLE_CARET_EVENT ) ;
2002-05-16 15:12:20 +00:00
2002-05-29 16:01:52 +00:00
SetChildrenState ( rSelection . nStartPara ,
rSelection . nEndPara ,
AccessibleStateType : : SELECTED ) ;
2002-05-17 18:12:44 +00:00
maParaManager . FireEvent ( rSelection . nStartPara ,
rSelection . nEndPara ,
AccessibleEventId : : ACCESSIBLE_SELECTION_EVENT ) ;
2002-05-16 15:12:20 +00:00
2002-05-29 15:09:56 +00:00
maParaManager . FireEvent ( rSelection . nEndPara ,
2002-05-29 16:01:52 +00:00
rSelection . nEndPara + 1 ,
2002-05-17 18:12:44 +00:00
AccessibleEventId : : ACCESSIBLE_CARET_EVENT ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
maLastSelection = rSelection ;
}
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)
class AccessibleTextHelper_LostChildEvent : public : : std : : unary_function < const accessibility : : AccessibleParaManager : : WeakChild & , void >
2002-05-16 15:12:20 +00:00
{
2002-05-17 18:12:44 +00:00
public :
2002-05-23 11:46:18 +00:00
AccessibleTextHelper_LostChildEvent ( AccessibleTextHelper_Impl & rImpl ) : mrImpl ( rImpl ) { }
void operator ( ) ( const accessibility : : AccessibleParaManager : : WeakChild & rPara )
2002-05-17 18:12:44 +00:00
{
2002-05-23 11:46:18 +00:00
// retrieve hard reference from weak one
accessibility : : AccessibleParaManager : : WeakPara : : HardRefType aHardRef ( rPara . first . get ( ) ) ;
if ( aHardRef . is ( ) )
mrImpl . FireEvent ( AccessibleEventId : : ACCESSIBLE_CHILD_EVENT , uno : : Any ( ) , uno : : makeAny ( aHardRef . getRef ( ) ) ) ;
2002-05-17 18:12:44 +00:00
}
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-05-17 18:12:44 +00:00
void AccessibleTextHelper_Impl : : ShutdownEditSource ( ) throw ( uno : : RuntimeException )
{
// 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
// invalidate children
maParaManager . SetEditSource ( NULL ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// loosing all children
2002-05-23 11:46:18 +00:00
AccessibleTextHelper_LostChildEvent aFunctor ( * this ) ;
: : std : : for_each ( maParaManager . begin ( ) , maParaManager . end ( ) , aFunctor ) ;
2002-05-17 18:12:44 +00:00
maParaManager . SetNum ( 0 ) ;
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
2002-05-17 18:12:44 +00:00
maEditSource . SetEditSource ( : : std : : auto_ptr < SvxEditSource > ( NULL ) ) ;
}
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
void AccessibleTextHelper_Impl : : SetEditSource ( : : std : : auto_ptr < SvxEditSource > pEditSource ) throw ( uno : : RuntimeException )
{
// 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
}
2002-05-17 18:12:44 +00:00
void AccessibleTextHelper_Impl : : SetOffset ( const Point & rPoint )
{
maOffset = rPoint ;
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-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
void AccessibleTextHelper_Impl : : UpdateVisibleChildren ( )
2002-05-16 15:12:20 +00:00
{
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
2002-05-17 18:12:44 +00:00
aTmpBB = rCacheTF . GetParaBounds ( static_cast < USHORT > ( nCurrPara ) ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// convert to screen coordinates
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-05-29 15:09:56 +00:00
GotPropertyEvent ( uno : : makeAny ( maParaManager . CreateChild ( nCurrPara - mnFirstVisibleChild ,
mxFrontEnd , GetEditSource ( ) , nCurrPara ) . first ) ,
AccessibleEventId : : ACCESSIBLE_CHILD_EVENT ) ;
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-05-29 15:09:56 +00:00
LostPropertyEvent ( uno : : makeAny ( maParaManager . GetChild ( nCurrPara ) . first . get ( ) . getRef ( ) ) ,
AccessibleEventId : : ACCESSIBLE_CHILD_EVENT ) ;
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
{
DBG_ERROR ( " 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 ;
2002-05-16 15:12:20 +00:00
2002-05-23 11:46:18 +00:00
AccessibleTextHelper_LostChildEvent aFunctor ( * this ) ;
: : std : : for_each ( maParaManager . begin ( ) , maParaManager . end ( ) , aFunctor ) ;
2002-05-17 18:12:44 +00:00
maParaManager . SetNum ( 0 ) ;
}
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)
2002-05-17 18:12:44 +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 ) { }
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
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 )
{
// update bounds
return accessibility : : AccessibleParaManager : : WeakChild ( rChild . first , aNewRect ) ;
}
2002-05-29 15:09:56 +00:00
// visible data changed
aHardRef - > FireEvent ( AccessibleEventId : : ACCESSIBLE_VISIBLE_DATA_EVENT ) ;
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-05-17 18:12:44 +00:00
void AccessibleTextHelper_Impl : : UpdateVisibleData ( )
{
// send CHILD_EVENT 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
{
: : vos : : OGuard aGuard ( Application : : GetSolarMutex ( ) ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
if ( ! mxFrontEnd . is ( ) )
DBG_ERROR ( " AccessibleTextHelper: no frontend " ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
if ( mnFirstVisibleChild > = 0 & &
mnFirstVisibleChild > mnLastVisibleChild )
{
DBG_ERROR ( " AccessibleTextHelper: range invalid " ) ;
}
2002-05-16 15:12:20 +00:00
}
# endif
2002-05-29 16:01:52 +00:00
void AccessibleTextHelper_Impl : : SetChildrenState ( sal_Int32 nStartPara , sal_Int32 nEndPara , const sal_Int16 nStateId )
{
: : accessibility : : AccessibleParaManager : : VectorOfChildren : : const_iterator begin = maParaManager . begin ( ) ;
: : accessibility : : AccessibleParaManager : : VectorOfChildren : : const_iterator end = begin ;
: : std : : advance ( begin , nStartPara ) ;
: : std : : advance ( end , nEndPara ) ;
: : std : : for_each ( begin , end ,
AccessibleParaManager : : MemFunAdapter < const sal_Int16 > ( & AccessibleEditableTextPara : : SetState ,
nStateId ) ) ;
}
2002-05-23 11:46:18 +00:00
void AccessibleTextHelper_Impl : : SetChildrenState ( const sal_Int16 nStateId )
{
: : std : : for_each ( maParaManager . begin ( ) , maParaManager . end ( ) ,
AccessibleParaManager : : MemFunAdapter < const sal_Int16 > ( & AccessibleEditableTextPara : : SetState ,
nStateId ) ) ;
}
2002-05-29 16:01:52 +00:00
void AccessibleTextHelper_Impl : : UnSetChildrenState ( sal_Int32 nStartPara , sal_Int32 nEndPara , const sal_Int16 nStateId )
{
: : accessibility : : AccessibleParaManager : : VectorOfChildren : : const_iterator begin = maParaManager . begin ( ) ;
: : accessibility : : AccessibleParaManager : : VectorOfChildren : : const_iterator end = begin ;
: : std : : advance ( begin , nStartPara ) ;
: : std : : advance ( end , nEndPara ) ;
: : std : : for_each ( begin , end ,
AccessibleParaManager : : MemFunAdapter < const sal_Int16 > ( & AccessibleEditableTextPara : : UnSetState ,
nStateId ) ) ;
}
2002-05-23 11:46:18 +00:00
void AccessibleTextHelper_Impl : : UnSetChildrenState ( const sal_Int16 nStateId )
{
: : std : : for_each ( maParaManager . begin ( ) , maParaManager . end ( ) ,
AccessibleParaManager : : MemFunAdapter < const sal_Int16 > ( & AccessibleEditableTextPara : : UnSetState ,
nStateId ) ) ;
}
2002-05-17 18:12:44 +00:00
void AccessibleTextHelper_Impl : : Notify ( SfxBroadcaster & rBC , const SfxHint & rHint )
{
// do not recurse
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-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-05-17 18:12:44 +00:00
// precondition: solar mutex locked
if ( pEditSourceHint )
2002-05-16 15:12:20 +00:00
{
2002-05-27 15:43:06 +00:00
switch ( pEditSourceHint - > GetId ( ) )
2002-05-16 15:12:20 +00:00
{
2002-05-27 15:43:06 +00:00
case EDITSOURCE_HINT_PARASMOVED :
2002-05-16 15:12:20 +00:00
{
2002-05-27 15:43:06 +00:00
DBG_ASSERT ( pEditSourceHint - > GetStartValue ( ) < GetTextForwarder ( ) . GetParagraphCount ( ) & &
pEditSourceHint - > GetEndValue ( ) < GetTextForwarder ( ) . GetParagraphCount ( ) ,
" AccessibleTextHelper_Impl::NotifyHdl: Invalid notification " ) ;
const sal_Int32 nParas = GetTextForwarder ( ) . GetParagraphCount ( ) ;
2002-05-29 15:09:56 +00:00
DBG_ASSERT ( nParas = = maParaManager . GetNum ( ) , " AccessibleTextHelper_Impl::NotifyHdl: event PARASMOVED and paragraph number mismatch " ) ;
2002-05-27 15:43:06 +00:00
sal_Int32 nFirst , nMiddle , nLast ;
/* 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
*/
// sort nParagraph, nParam1 and nParam2 in ascending order, calc range
if ( pEditSourceHint - > GetValue ( ) < pEditSourceHint - > GetStartValue ( ) )
2002-05-16 15:12:20 +00:00
{
2002-05-27 15:43:06 +00:00
nFirst = pEditSourceHint - > GetValue ( ) ;
nMiddle = pEditSourceHint - > GetStartValue ( ) ;
nLast = pEditSourceHint - > GetEndValue ( ) ;
}
else if ( pEditSourceHint - > GetValue ( ) < pEditSourceHint - > GetEndValue ( ) )
{
nFirst = pEditSourceHint - > GetStartValue ( ) ;
nMiddle = pEditSourceHint - > GetValue ( ) ;
nLast = pEditSourceHint - > GetEndValue ( ) + nMiddle - nFirst ;
}
else
{
nFirst = pEditSourceHint - > GetStartValue ( ) ;
nMiddle = pEditSourceHint - > GetEndValue ( ) ;
nLast = pEditSourceHint - > GetValue ( ) + nMiddle - nFirst ;
}
2002-05-17 18:12:44 +00:00
2002-05-27 15:43:06 +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)
2002-05-17 18:12:44 +00:00
2002-05-27 15:43:06 +00:00
// maParaManager.Rotate( nFirst, nMiddle, nLast );
2002-05-17 18:12:44 +00:00
2002-05-27 15:43:06 +00:00
// send CHILD_EVENT to affected children
: : accessibility : : AccessibleParaManager : : VectorOfChildren : : const_iterator begin = maParaManager . begin ( ) ;
: : accessibility : : AccessibleParaManager : : VectorOfChildren : : const_iterator end = begin ;
2002-05-17 18:12:44 +00:00
2002-05-27 15:43:06 +00:00
: : std : : advance ( begin , nFirst ) ;
: : std : : advance ( end , nLast ) ;
2002-05-21 13:58:45 +00:00
2002-05-27 15:43:06 +00:00
AccessibleTextHelper_LostChildEvent aFunctor ( * this ) ;
2002-05-17 18:12:44 +00:00
2002-05-27 15:43:06 +00:00
: : std : : for_each ( begin , end , aFunctor ) ;
2002-05-29 15:09:56 +00:00
maParaManager . Release ( nFirst , nLast ) ;
// should be no need for UpdateVisibleData, since all affected children are cleared.
2002-05-27 15:43:06 +00:00
}
2002-05-17 18:12:44 +00:00
# ifdef DBG_UTIL
2002-05-27 15:43:06 +00:00
else
{
DBG_ERROR ( " AccessibleTextHelper_Impl::NotifyHdl: Invalid move ranges " ) ;
2002-05-16 15:12:20 +00:00
}
2002-05-27 15:43:06 +00:00
# endif
break ;
2002-05-17 18:12:44 +00:00
}
2002-05-27 15:43:06 +00:00
case EDITSOURCE_HINT_SELECTIONCHANGED :
// notify listeners
ESelection aSelection ;
try
{
if ( GetEditViewForwarder ( ) . GetSelection ( aSelection ) )
UpdateSelection ( aSelection ) ;
else
UpdateSelection ( ESelection ( ) ) ;
}
// maybe we're not in edit mode (this is not an error)
catch ( const uno : : Exception & ) { }
break ;
2002-05-17 18:12:44 +00:00
}
2002-05-27 15:43:06 +00:00
// in all cases, check visibility afterwards.
UpdateVisibleChildren ( ) ;
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-05-27 15:43:06 +00:00
case TEXT_HINT_MODIFIED :
// notify listeners
if ( pTextHint - > GetValue ( ) = = EE_PARA_ALL )
2002-05-29 15:09:56 +00:00
maParaManager . FireEvent ( 0 , GetTextForwarder ( ) . GetParagraphCount ( ) - 1 , AccessibleEventId : : ACCESSIBLE_TEXT_EVENT ) ;
2002-05-27 15:43:06 +00:00
else
maParaManager . FireEvent ( pTextHint - > GetValue ( ) , AccessibleEventId : : ACCESSIBLE_TEXT_EVENT ) ;
break ;
2002-05-17 18:12:44 +00:00
2002-05-27 15:43:06 +00:00
case TEXT_HINT_PARAINSERTED :
2002-05-17 18:12:44 +00:00
{
2002-05-27 15:43:06 +00:00
// resize child vector to the current child count
const sal_Int32 nParas = GetTextForwarder ( ) . GetParagraphCount ( ) ;
2002-05-17 18:12:44 +00:00
2002-05-27 15:43:06 +00:00
maParaManager . SetNum ( nParas ) ;
2002-05-17 18:12:44 +00:00
2002-05-29 15:09:56 +00:00
sal_Int32 nFirst ( pTextHint - > GetValue ( ) ) , nLast ( nParas - 1 ) ;
2002-05-17 18:12:44 +00:00
2002-05-27 15:43:06 +00:00
if ( pTextHint - > GetValue ( ) = = EE_PARA_ALL )
nFirst = 0 ; // all paragraphs
2002-05-16 15:12:20 +00:00
2002-05-27 15:43:06 +00:00
// since we have no "paragraph index
// changed" event on UAA, remove
// [first,last] and insert again later (in
// UpdateVisibleChildren)
2002-05-16 15:12:20 +00:00
2002-05-27 15:43:06 +00:00
// move successors of inserted paragraph one position further
//maParaManager.MoveRightFrom( pTextHint->GetValue() );
2002-05-16 15:12:20 +00:00
2002-05-27 15:43:06 +00:00
// release everything from the insertion position until the end
maParaManager . Release ( nFirst , nLast ) ;
2002-05-16 15:12:20 +00:00
2002-05-27 15:43:06 +00:00
// send CHILD_EVENT to affected children
: : accessibility : : AccessibleParaManager : : VectorOfChildren : : const_iterator begin = maParaManager . begin ( ) ;
: : accessibility : : AccessibleParaManager : : VectorOfChildren : : const_iterator end = begin ;
2002-05-16 15:12:20 +00:00
2002-05-27 15:43:06 +00:00
: : std : : advance ( begin , nFirst ) ;
: : std : : advance ( end , nLast ) ;
2002-05-16 15:12:20 +00:00
2002-05-27 15:43:06 +00:00
AccessibleTextHelper_LostChildEvent aFunctor ( * this ) ;
: : std : : for_each ( begin , end , aFunctor ) ;
break ;
}
2002-05-16 15:12:20 +00:00
2002-05-27 15:43:06 +00:00
case TEXT_HINT_PARAREMOVED :
{
const sal_Int32 nParas = GetTextForwarder ( ) . GetParagraphCount ( ) ;
2002-05-16 15:12:20 +00:00
2002-05-29 15:09:56 +00:00
sal_Int32 nFirst ( pTextHint - > GetValue ( ) ) , nLast ( nParas - 1 ) ;
2002-05-16 15:12:20 +00:00
2002-05-27 15:43:06 +00:00
if ( pTextHint - > GetValue ( ) = = EE_PARA_ALL )
nFirst = 0 ; // all paragraphs
2002-05-16 15:12:20 +00:00
2002-05-27 15:43:06 +00:00
// since we have no "paragraph index
// changed" event on UAA, remove
// [first,last] and insert again later (in
// UpdateVisibleChildren)
2002-05-16 15:12:20 +00:00
2002-05-27 15:43:06 +00:00
// move successors of removed paragraph one position closer
// maParaManager.MoveLeftFrom( pTextHint->GetValue() );
2002-05-16 15:12:20 +00:00
2002-05-27 15:43:06 +00:00
// release everything from the remove position until the end
maParaManager . Release ( nFirst , nLast ) ;
2002-05-16 15:12:20 +00:00
2002-05-27 15:43:06 +00:00
// 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 ) ;
2002-05-16 15:12:20 +00:00
2002-05-27 15:43:06 +00:00
AccessibleTextHelper_LostChildEvent aFunctor ( * this ) ;
: : std : : for_each ( begin , end , aFunctor ) ;
2002-05-16 15:12:20 +00:00
2002-05-27 15:43:06 +00:00
// resize child vector to the current child count
maParaManager . SetNum ( nParas ) ;
break ;
2002-05-16 15:12:20 +00:00
}
2002-05-27 15:43:06 +00:00
case TEXT_HINT_TEXTHEIGHTCHANGED :
break ;
2002-05-16 15:12:20 +00:00
2002-05-27 15:43:06 +00:00
case TEXT_HINT_VIEWSCROLLED :
break ;
2002-05-16 15:12:20 +00:00
}
2002-05-27 15:43:06 +00:00
// in all cases, check visibility afterwards.
UpdateVisibleChildren ( ) ;
2002-05-29 15:09:56 +00:00
UpdateVisibleData ( ) ;
2002-05-17 18:12:44 +00:00
}
else if ( pViewHint )
2002-05-16 15:12:20 +00:00
{
2002-05-17 18:12:44 +00:00
switch ( pViewHint - > GetId ( ) )
{
case SVX_HINT_VIEWCHANGED :
// just check visibility
UpdateVisibleChildren ( ) ;
2002-05-29 15:09:56 +00:00
UpdateVisibleData ( ) ;
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
else if ( pSdrHint )
{
switch ( pSdrHint - > GetKind ( ) )
{
case HINT_BEGEDIT :
{
// change children state
SetChildrenState ( AccessibleStateType : : ACTIVE ) ;
SetChildrenState ( AccessibleStateType : : EDITABLE ) ;
// find the one selected
ESelection aSelection ;
if ( GetEditViewForwarder ( ) . GetSelection ( aSelection ) )
2002-05-29 16:01:52 +00:00
UpdateSelection ( aSelection ) ;
2002-05-23 11:46:18 +00:00
break ;
}
case HINT_ENDEDIT :
// change children state
UnSetChildrenState ( AccessibleStateType : : EDITABLE ) ;
UnSetChildrenState ( AccessibleStateType : : ACTIVE ) ;
UnSetChildrenState ( AccessibleStateType : : SELECTED ) ;
2002-05-29 16:01:52 +00:00
maLastSelection = ESelection ( ) ;
2002-05-23 11:46:18 +00:00
break ;
}
}
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-05-17 18:12:44 +00:00
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 ( ) ;
}
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-05-17 18:12:44 +00:00
DBG_ERROR ( " AccessibleTextHelper_Impl::Notify: Unhandled exception. " ) ;
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
mbInNotify = sal_False ;
}
2002-05-16 15:12:20 +00:00
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
{
// -- object locked --
: : osl : : ClearableMutexGuard aGuard ( maMutex ) ;
2002-05-16 15:12:20 +00:00
2002-05-27 15:43:06 +00:00
AccessibleEventObject aEvent ;
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
2002-05-17 18:12:44 +00:00
: : cppu : : OInterfaceIteratorHelper aIter ( const_cast < AccessibleTextHelper_Impl * > ( this ) - > maStateListeners ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
// no locking necessary, OInterfaceIteratorHelper copies listeners if someone removes/adds in between
// Further locking, actually, might lead to deadlocks, since we're calling out of this object
aGuard . clear ( ) ;
// -- until here --
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
while ( aIter . hasMoreElements ( ) )
2002-05-16 15:12:20 +00:00
{
2002-05-17 18:12:44 +00:00
uno : : Reference < XAccessibleEventListener > xListener ( aIter . next ( ) , uno : : UNO_QUERY ) ;
if ( xListener . is ( ) )
2002-05-16 15:12:20 +00:00
{
2002-05-17 18:12:44 +00:00
try
{
xListener - > notifyEvent ( aEvent ) ;
}
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-05-17 18:12:44 +00:00
DBG_ERROR ( " AccessibleTextHelper_Impl::StateChangeEvent: Caught runtime exception from listener (bridge/listener dead?). " ) ;
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
sal_Int32 SAL_CALL AccessibleTextHelper_Impl : : getAccessibleChildCount ( ) throw ( uno : : RuntimeException )
2002-05-16 15:12:20 +00:00
{
2002-05-17 18:12:44 +00:00
: : vos : : OGuard aGuard ( Application : : GetSolarMutex ( ) ) ;
return mnLastVisibleChild - mnFirstVisibleChild + 1 ;
2002-05-16 15:12:20 +00:00
}
2002-05-17 18:12:44 +00:00
uno : : Reference < XAccessible > SAL_CALL AccessibleTextHelper_Impl : : getAccessibleChild ( sal_Int32 i ) throw ( lang : : IndexOutOfBoundsException , uno : : RuntimeException )
{
: : vos : : OGuard aGuard ( Application : : GetSolarMutex ( ) ) ;
2002-05-16 15:12:20 +00:00
2002-05-23 11:46:18 +00:00
i - = GetChildrenOffset ( ) ;
2002-05-17 18:12:44 +00:00
if ( 0 > i | | i > getAccessibleChildCount ( ) | |
GetTextForwarder ( ) . GetParagraphCount ( ) < = i )
{
throw lang : : IndexOutOfBoundsException ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Invalid child index " ) ) , mxFrontEnd ) ;
}
2002-05-16 15:12:20 +00:00
2002-05-23 11:46:18 +00:00
return maParaManager . CreateChild ( i , mxFrontEnd , GetEditSource ( ) , mnFirstVisibleChild + i ) . first ;
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 SAL_CALL AccessibleTextHelper_Impl : : addEventListener ( const uno : : Reference < XAccessibleEventListener > & xListener ) throw ( uno : : RuntimeException )
{
maStateListeners . addInterface ( xListener ) ;
}
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
void SAL_CALL AccessibleTextHelper_Impl : : removeEventListener ( const uno : : Reference < XAccessibleEventListener > & xListener ) throw ( uno : : RuntimeException )
{
maStateListeners . removeInterface ( xListener ) ;
}
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
uno : : Reference < XAccessible > SAL_CALL AccessibleTextHelper_Impl : : getAccessibleAt ( const awt : : Point & _aPoint ) throw ( uno : : RuntimeException )
{
// 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-05-17 18:12:44 +00:00
Point aPoint ( _aPoint . X , _aPoint . Y ) ;
awt : : Point aRefPoint = xFrontEndComponent - > getLocationOnScreen ( ) ;
aPoint - = Point ( aRefPoint . X , aRefPoint . 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 " ) ;
Rectangle aParaBounds ( rCacheTF . GetParaBounds ( static_cast < USHORT > ( nChild ) ) ) ;
if ( aParaBounds . IsInside ( aLogPoint ) )
{
DBG_ASSERT ( nChild - mnFirstVisibleChild > = 0 & & nChild - mnFirstVisibleChild < = USHRT_MAX ,
" AccessibleTextHelper_Impl::getAccessibleAt: index value overflow " ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
return getAccessibleChild ( static_cast < USHORT > ( nChild - mnFirstVisibleChild ) ) ;
}
2002-05-16 15:12:20 +00:00
}
2002-05-17 18:12:44 +00:00
// found none
return uno : : Reference < XAccessible > ( ) ;
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
2002-05-17 18:12:44 +00:00
AccessibleTextHelper : : AccessibleTextHelper ( const uno : : Reference < XAccessible > & rInterface ,
: : std : : auto_ptr < SvxEditSource > pEditSource ) :
mpImpl ( new AccessibleTextHelper_Impl ( rInterface ) )
{
: : vos : : OGuard aGuard ( Application : : GetSolarMutex ( ) ) ;
2002-05-16 15:12:20 +00:00
2002-05-17 18:12:44 +00:00
SetEditSource ( pEditSource ) ;
}
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-05-17 18:12:44 +00:00
SvxEditSource & AccessibleTextHelper : : GetEditSource ( ) const throw ( uno : : RuntimeException )
{
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
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
2002-05-17 18:12:44 +00:00
void AccessibleTextHelper : : SetEditSource ( : : std : : auto_ptr < SvxEditSource > pEditSource ) throw ( uno : : RuntimeException )
{
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
mpImpl - > SetEditSource ( pEditSource ) ;
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
2002-05-17 18:12:44 +00:00
mpImpl - > SetEditSource ( pEditSource ) ;
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 : : SetFocus ( sal_Bool bHaveFocus ) throw ( : : com : : sun : : star : : uno : : RuntimeException )
{
2002-05-23 11:46:18 +00:00
# ifdef DBG_UTIL
mpImpl - > CheckInvariants ( ) ;
mpImpl - > SetFocus ( bHaveFocus ) ;
mpImpl - > CheckInvariants ( ) ;
# else
mpImpl - > SetFocus ( bHaveFocus ) ;
# endif
2002-05-17 18:12:44 +00:00
}
sal_Bool AccessibleTextHelper : : HaveFocus ( ) throw ( : : com : : sun : : star : : uno : : RuntimeException )
{
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-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-05-17 18:12:44 +00:00
mpImpl - > CheckInvariants ( ) ;
2002-05-16 15:12:20 +00:00
# else
2002-05-21 13:58:45 +00:00
mpImpl - > FireEvent ( nEventId , rNewValue , rOldValue ) ;
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-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
mpImpl - > SetOffset ( rPoint ) ;
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
2002-05-17 18:12:44 +00:00
mpImpl - > SetOffset ( rPoint ) ;
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
const Point & AccessibleTextHelper : : GetOffset ( ) const
{
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
const Point & rRef = 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-05-17 18:12:44 +00:00
return rRef ;
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-05-17 18:12:44 +00:00
void AccessibleTextHelper : : SetChildrenOffset ( sal_Int32 nOffset )
{
2002-05-23 11:46:18 +00:00
# ifdef DBG_UTIL
mpImpl - > CheckInvariants ( ) ;
mpImpl - > SetChildrenOffset ( nOffset ) ;
mpImpl - > CheckInvariants ( ) ;
# else
mpImpl - > SetChildrenOffset ( nOffset ) ;
# endif
2002-05-17 18:12:44 +00:00
}
sal_Int32 AccessibleTextHelper : : GetChildrenOffset ( ) const
{
2002-05-23 11:46:18 +00:00
# ifdef DBG_UTIL
mpImpl - > CheckInvariants ( ) ;
sal_Int32 nOffset = mpImpl - > GetChildrenOffset ( ) ;
mpImpl - > CheckInvariants ( ) ;
return nOffset ;
# else
return mpImpl - > GetChildrenOffset ( ) ;
# endif
2002-05-17 18:12:44 +00:00
}
void AccessibleTextHelper : : UpdateChildren ( ) throw ( : : com : : sun : : star : : uno : : RuntimeException )
{
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
mpImpl - > UpdateVisibleChildren ( ) ;
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
2002-05-17 18:12:44 +00:00
mpImpl - > UpdateVisibleChildren ( ) ;
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
{
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
sal_Int32 AccessibleTextHelper : : GetChildCount ( ) throw ( uno : : RuntimeException )
{
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-05-17 18:12:44 +00:00
uno : : Reference < XAccessible > AccessibleTextHelper : : GetChild ( sal_Int32 i ) throw ( lang : : IndexOutOfBoundsException , uno : : RuntimeException )
{
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-05-17 18:12:44 +00:00
void AccessibleTextHelper : : AddEventListener ( const uno : : Reference < XAccessibleEventListener > & xListener ) throw ( uno : : RuntimeException )
{
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
mpImpl - > addEventListener ( 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
2002-05-17 18:12:44 +00:00
mpImpl - > addEventListener ( 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
void AccessibleTextHelper : : RemoveEventListener ( const uno : : Reference < XAccessibleEventListener > & xListener ) throw ( uno : : RuntimeException )
{
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
mpImpl - > removeEventListener ( 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
2002-05-17 18:12:44 +00:00
mpImpl - > removeEventListener ( 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
uno : : Reference < XAccessible > AccessibleTextHelper : : GetAt ( const awt : : Point & aPoint ) throw ( uno : : RuntimeException )
{
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 > xChild = mpImpl - > getAccessibleAt ( 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
2002-05-17 18:12:44 +00:00
return mpImpl - > getAccessibleAt ( 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
//------------------------------------------------------------------------