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