xref: /AOO41X/main/editeng/source/accessibility/AccessibleParaManager.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 #include <com/sun/star/uno/Any.hxx>
37*cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx>
38*cdf0e10cSrcweir #include <cppuhelper/weakref.hxx>
39*cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessible.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir //------------------------------------------------------------------------
43*cdf0e10cSrcweir //
44*cdf0e10cSrcweir // Project-local header
45*cdf0e10cSrcweir //
46*cdf0e10cSrcweir //------------------------------------------------------------------------
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir #include <editeng/unoedhlp.hxx>
49*cdf0e10cSrcweir #include <editeng/unopracc.hxx>
50*cdf0e10cSrcweir #include <editeng/unoedsrc.hxx>
51*cdf0e10cSrcweir #include "editeng/AccessibleParaManager.hxx"
52*cdf0e10cSrcweir #include "editeng/AccessibleEditableTextPara.hxx"
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir using namespace ::com::sun::star;
56*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir namespace accessibility
61*cdf0e10cSrcweir {
62*cdf0e10cSrcweir     AccessibleParaManager::AccessibleParaManager() :
63*cdf0e10cSrcweir         maChildren(1),
64*cdf0e10cSrcweir         maEEOffset( 0, 0 ),
65*cdf0e10cSrcweir         mnFocusedChild( -1 ),
66*cdf0e10cSrcweir         mbActive( sal_False )
67*cdf0e10cSrcweir     {
68*cdf0e10cSrcweir     }
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir     AccessibleParaManager::~AccessibleParaManager()
71*cdf0e10cSrcweir     {
72*cdf0e10cSrcweir         // owner is responsible for possible child defuncs
73*cdf0e10cSrcweir     }
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir     void AccessibleParaManager::SetAdditionalChildStates( const VectorOfStates& rChildStates )
76*cdf0e10cSrcweir     {
77*cdf0e10cSrcweir         maChildStates = rChildStates;
78*cdf0e10cSrcweir     }
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir     const AccessibleParaManager::VectorOfStates& AccessibleParaManager::GetAdditionalChildStates() const
81*cdf0e10cSrcweir     {
82*cdf0e10cSrcweir         return maChildStates;
83*cdf0e10cSrcweir     }
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir     void AccessibleParaManager::SetNum( sal_Int32 nNumParas )
86*cdf0e10cSrcweir     {
87*cdf0e10cSrcweir         if( (size_t)nNumParas < maChildren.size() )
88*cdf0e10cSrcweir             Release( nNumParas, maChildren.size() );
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir         maChildren.resize( nNumParas );
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir         if( mnFocusedChild >= nNumParas )
93*cdf0e10cSrcweir             mnFocusedChild = -1;
94*cdf0e10cSrcweir     }
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir     sal_uInt32 AccessibleParaManager::GetNum() const
97*cdf0e10cSrcweir     {
98*cdf0e10cSrcweir         return maChildren.size();
99*cdf0e10cSrcweir     }
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir     AccessibleParaManager::VectorOfChildren::iterator AccessibleParaManager::begin()
102*cdf0e10cSrcweir     {
103*cdf0e10cSrcweir         return maChildren.begin();
104*cdf0e10cSrcweir     }
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir     AccessibleParaManager::VectorOfChildren::iterator AccessibleParaManager::end()
107*cdf0e10cSrcweir     {
108*cdf0e10cSrcweir         return maChildren.end();
109*cdf0e10cSrcweir     }
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir     AccessibleParaManager::VectorOfChildren::const_iterator AccessibleParaManager::begin() const
112*cdf0e10cSrcweir     {
113*cdf0e10cSrcweir         return maChildren.begin();
114*cdf0e10cSrcweir     }
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir     AccessibleParaManager::VectorOfChildren::const_iterator AccessibleParaManager::end() const
117*cdf0e10cSrcweir     {
118*cdf0e10cSrcweir         return maChildren.end();
119*cdf0e10cSrcweir     }
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir     void AccessibleParaManager::Release( sal_uInt32 nPara )
122*cdf0e10cSrcweir     {
123*cdf0e10cSrcweir         DBG_ASSERT( maChildren.size() > nPara, "AccessibleParaManager::Release: invalid index" );
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir         if( maChildren.size() > nPara )
126*cdf0e10cSrcweir         {
127*cdf0e10cSrcweir             ShutdownPara( GetChild( nPara ) );
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir             // clear reference and rect
130*cdf0e10cSrcweir             maChildren[ nPara ] = WeakChild();
131*cdf0e10cSrcweir         }
132*cdf0e10cSrcweir     }
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir     void AccessibleParaManager::FireEvent( sal_uInt32 nPara,
135*cdf0e10cSrcweir                                            const sal_Int16 nEventId,
136*cdf0e10cSrcweir                                            const uno::Any& rNewValue,
137*cdf0e10cSrcweir                                            const uno::Any& rOldValue ) const
138*cdf0e10cSrcweir     {
139*cdf0e10cSrcweir         DBG_ASSERT( maChildren.size() > nPara, "AccessibleParaManager::FireEvent: invalid index" );
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir         if( maChildren.size() > nPara )
142*cdf0e10cSrcweir         {
143*cdf0e10cSrcweir             WeakPara::HardRefType maChild( GetChild( nPara ).first.get() );
144*cdf0e10cSrcweir             if( maChild.is() )
145*cdf0e10cSrcweir                 maChild->FireEvent( nEventId, rNewValue, rOldValue );
146*cdf0e10cSrcweir         }
147*cdf0e10cSrcweir     }
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir     sal_Bool AccessibleParaManager::IsReferencable( WeakPara::HardRefType aChild )
150*cdf0e10cSrcweir     {
151*cdf0e10cSrcweir         return aChild.is();
152*cdf0e10cSrcweir     }
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir     sal_Bool AccessibleParaManager::IsReferencable( sal_uInt32 nChild ) const
155*cdf0e10cSrcweir     {
156*cdf0e10cSrcweir         DBG_ASSERT( maChildren.size() > nChild, "AccessibleParaManager::IsReferencable: invalid index" );
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir         if( maChildren.size() > nChild )
159*cdf0e10cSrcweir         {
160*cdf0e10cSrcweir             // retrieve hard reference from weak one
161*cdf0e10cSrcweir             return IsReferencable( GetChild( nChild ).first.get() );
162*cdf0e10cSrcweir         }
163*cdf0e10cSrcweir         else
164*cdf0e10cSrcweir         {
165*cdf0e10cSrcweir             return sal_False;
166*cdf0e10cSrcweir         }
167*cdf0e10cSrcweir     }
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir     AccessibleParaManager::WeakChild AccessibleParaManager::GetChild( sal_uInt32 nParagraphIndex ) const
170*cdf0e10cSrcweir     {
171*cdf0e10cSrcweir         DBG_ASSERT( maChildren.size() > nParagraphIndex, "AccessibleParaManager::GetChild: invalid index" );
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir         if( maChildren.size() > nParagraphIndex )
174*cdf0e10cSrcweir         {
175*cdf0e10cSrcweir             return maChildren[ nParagraphIndex ];
176*cdf0e10cSrcweir         }
177*cdf0e10cSrcweir         else
178*cdf0e10cSrcweir         {
179*cdf0e10cSrcweir             return WeakChild();
180*cdf0e10cSrcweir         }
181*cdf0e10cSrcweir     }
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir     AccessibleParaManager::Child AccessibleParaManager::CreateChild( sal_Int32 								nChild,
184*cdf0e10cSrcweir                                                                      const uno::Reference< XAccessible >& 	xFrontEnd,
185*cdf0e10cSrcweir                                                                      SvxEditSourceAdapter& 					rEditSource,
186*cdf0e10cSrcweir                                                                      sal_uInt32 							nParagraphIndex	)
187*cdf0e10cSrcweir     {
188*cdf0e10cSrcweir         DBG_ASSERT( maChildren.size() > nParagraphIndex, "AccessibleParaManager::CreateChild: invalid index" );
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir         if( maChildren.size() > nParagraphIndex )
191*cdf0e10cSrcweir         {
192*cdf0e10cSrcweir             // retrieve hard reference from weak one
193*cdf0e10cSrcweir             WeakPara::HardRefType aChild( GetChild( nParagraphIndex ).first.get() );
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir             if( !IsReferencable( nParagraphIndex ) )
196*cdf0e10cSrcweir             {
197*cdf0e10cSrcweir                 // there is no hard reference available, create object then
198*cdf0e10cSrcweir                 // --> OD 2006-01-11 #i27138#
199*cdf0e10cSrcweir                 AccessibleEditableTextPara* pChild = new AccessibleEditableTextPara( xFrontEnd, this );
200*cdf0e10cSrcweir                 // <--
201*cdf0e10cSrcweir                 uno::Reference< XAccessible > xChild( static_cast< ::cppu::OWeakObject* > (pChild), uno::UNO_QUERY );
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir                 if( !xChild.is() )
204*cdf0e10cSrcweir                     throw uno::RuntimeException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Child creation failed")), xFrontEnd);
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir                 aChild = WeakPara::HardRefType( xChild, pChild );
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir                 InitChild( *aChild, rEditSource, nChild, nParagraphIndex );
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir                 maChildren[ nParagraphIndex ] = WeakChild( aChild, pChild->getBounds() );
211*cdf0e10cSrcweir             }
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir             return Child( aChild.getRef(), GetChild( nParagraphIndex ).second );
214*cdf0e10cSrcweir         }
215*cdf0e10cSrcweir         else
216*cdf0e10cSrcweir         {
217*cdf0e10cSrcweir             return Child();
218*cdf0e10cSrcweir         }
219*cdf0e10cSrcweir     }
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir     void AccessibleParaManager::SetEEOffset( const Point& rOffset )
222*cdf0e10cSrcweir     {
223*cdf0e10cSrcweir         maEEOffset = rOffset;
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir         MemFunAdapter< const Point& > aAdapter( &::accessibility::AccessibleEditableTextPara::SetEEOffset, rOffset );
226*cdf0e10cSrcweir         ::std::for_each( begin(), end(), aAdapter );
227*cdf0e10cSrcweir     }
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir     void AccessibleParaManager::SetActive( sal_Bool bActive )
230*cdf0e10cSrcweir     {
231*cdf0e10cSrcweir         mbActive = bActive;
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir         if( bActive )
234*cdf0e10cSrcweir         {
235*cdf0e10cSrcweir             SetState( AccessibleStateType::ACTIVE );
236*cdf0e10cSrcweir             SetState( AccessibleStateType::EDITABLE );
237*cdf0e10cSrcweir         }
238*cdf0e10cSrcweir         else
239*cdf0e10cSrcweir         {
240*cdf0e10cSrcweir             UnSetState( AccessibleStateType::ACTIVE );
241*cdf0e10cSrcweir             UnSetState( AccessibleStateType::EDITABLE );
242*cdf0e10cSrcweir         }
243*cdf0e10cSrcweir     }
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir     void AccessibleParaManager::SetFocus( sal_Int32 nChild )
246*cdf0e10cSrcweir     {
247*cdf0e10cSrcweir         if( mnFocusedChild != -1 )
248*cdf0e10cSrcweir             UnSetState( mnFocusedChild, AccessibleStateType::FOCUSED );
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir         mnFocusedChild = nChild;
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir         if( mnFocusedChild != -1 )
253*cdf0e10cSrcweir             SetState( mnFocusedChild, AccessibleStateType::FOCUSED );
254*cdf0e10cSrcweir     }
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir     void AccessibleParaManager::InitChild( AccessibleEditableTextPara& 	rChild,
257*cdf0e10cSrcweir                                            SvxEditSourceAdapter& 		rEditSource,
258*cdf0e10cSrcweir                                            sal_Int32 					nChild,
259*cdf0e10cSrcweir                                            sal_uInt32 					nParagraphIndex ) const
260*cdf0e10cSrcweir     {
261*cdf0e10cSrcweir         rChild.SetEditSource( &rEditSource );
262*cdf0e10cSrcweir         rChild.SetIndexInParent( nChild );
263*cdf0e10cSrcweir         rChild.SetParagraphIndex( nParagraphIndex );
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir         rChild.SetEEOffset( maEEOffset );
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir         if( mbActive )
268*cdf0e10cSrcweir         {
269*cdf0e10cSrcweir             rChild.SetState( AccessibleStateType::ACTIVE );
270*cdf0e10cSrcweir             rChild.SetState( AccessibleStateType::EDITABLE );
271*cdf0e10cSrcweir         }
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir         if( mnFocusedChild == static_cast<sal_Int32>(nParagraphIndex) )
274*cdf0e10cSrcweir             rChild.SetState( AccessibleStateType::FOCUSED );
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir         // add states passed from outside
277*cdf0e10cSrcweir         for( VectorOfStates::const_iterator aIt = maChildStates.begin(), aEnd = maChildStates.end(); aIt != aEnd; ++aIt )
278*cdf0e10cSrcweir             rChild.SetState( *aIt );
279*cdf0e10cSrcweir     }
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir     void AccessibleParaManager::SetState( sal_Int32 nChild, const sal_Int16 nStateId )
282*cdf0e10cSrcweir     {
283*cdf0e10cSrcweir         MemFunAdapter< const sal_Int16 > aFunc( &AccessibleEditableTextPara::SetState,
284*cdf0e10cSrcweir                                                 nStateId );
285*cdf0e10cSrcweir         aFunc( GetChild(nChild) );
286*cdf0e10cSrcweir     }
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir     void AccessibleParaManager::SetState( const sal_Int16 nStateId )
289*cdf0e10cSrcweir     {
290*cdf0e10cSrcweir         ::std::for_each( begin(), end(),
291*cdf0e10cSrcweir                          MemFunAdapter< const sal_Int16 >( &AccessibleEditableTextPara::SetState,
292*cdf0e10cSrcweir                                                            nStateId ) );
293*cdf0e10cSrcweir     }
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir     void AccessibleParaManager::UnSetState( sal_Int32 nChild, const sal_Int16 nStateId )
296*cdf0e10cSrcweir     {
297*cdf0e10cSrcweir         MemFunAdapter< const sal_Int16 > aFunc( &AccessibleEditableTextPara::UnSetState,
298*cdf0e10cSrcweir                                                 nStateId );
299*cdf0e10cSrcweir         aFunc( GetChild(nChild) );
300*cdf0e10cSrcweir     }
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir     void AccessibleParaManager::UnSetState( const sal_Int16 nStateId )
303*cdf0e10cSrcweir     {
304*cdf0e10cSrcweir         ::std::for_each( begin(), end(),
305*cdf0e10cSrcweir                          MemFunAdapter< const sal_Int16 >( &AccessibleEditableTextPara::UnSetState,
306*cdf0e10cSrcweir                                                            nStateId ) );
307*cdf0e10cSrcweir     }
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir     void AccessibleParaManager::SetEditSource( SvxEditSourceAdapter* pEditSource )
310*cdf0e10cSrcweir     {
311*cdf0e10cSrcweir         MemFunAdapter< SvxEditSourceAdapter* > aAdapter( &::accessibility::AccessibleEditableTextPara::SetEditSource, pEditSource );
312*cdf0e10cSrcweir         ::std::for_each( begin(), end(), aAdapter );
313*cdf0e10cSrcweir     }
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir     // not generic yet, no arguments...
316*cdf0e10cSrcweir     class AccessibleParaManager_DisposeChildren : public ::std::unary_function< ::accessibility::AccessibleEditableTextPara&, void >
317*cdf0e10cSrcweir     {
318*cdf0e10cSrcweir     public:
319*cdf0e10cSrcweir         AccessibleParaManager_DisposeChildren() {}
320*cdf0e10cSrcweir         void operator()( ::accessibility::AccessibleEditableTextPara& rPara )
321*cdf0e10cSrcweir         {
322*cdf0e10cSrcweir             rPara.Dispose();
323*cdf0e10cSrcweir         }
324*cdf0e10cSrcweir     };
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir     void AccessibleParaManager::Dispose()
327*cdf0e10cSrcweir     {
328*cdf0e10cSrcweir         AccessibleParaManager_DisposeChildren aFunctor;
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir         ::std::for_each( begin(), end(),
331*cdf0e10cSrcweir                          WeakChildAdapter< AccessibleParaManager_DisposeChildren > (aFunctor) );
332*cdf0e10cSrcweir     }
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir     // not generic yet, too many method arguments...
335*cdf0e10cSrcweir     class StateChangeEvent : public ::std::unary_function< ::accessibility::AccessibleEditableTextPara&, void >
336*cdf0e10cSrcweir     {
337*cdf0e10cSrcweir     public:
338*cdf0e10cSrcweir         typedef void return_type;
339*cdf0e10cSrcweir         StateChangeEvent( const sal_Int16 nEventId,
340*cdf0e10cSrcweir                           const uno::Any& rNewValue,
341*cdf0e10cSrcweir                           const uno::Any& rOldValue ) :
342*cdf0e10cSrcweir             mnEventId( nEventId ),
343*cdf0e10cSrcweir             mrNewValue( rNewValue ),
344*cdf0e10cSrcweir             mrOldValue( rOldValue ) {}
345*cdf0e10cSrcweir         void operator()( ::accessibility::AccessibleEditableTextPara& rPara )
346*cdf0e10cSrcweir         {
347*cdf0e10cSrcweir             rPara.FireEvent( mnEventId, mrNewValue, mrOldValue );
348*cdf0e10cSrcweir         }
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir     private:
351*cdf0e10cSrcweir         const sal_Int16 mnEventId;
352*cdf0e10cSrcweir         const uno::Any& mrNewValue;
353*cdf0e10cSrcweir         const uno::Any& mrOldValue;
354*cdf0e10cSrcweir     };
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir     void AccessibleParaManager::FireEvent( sal_uInt32 nStartPara,
357*cdf0e10cSrcweir                                            sal_uInt32 nEndPara,
358*cdf0e10cSrcweir                                            const sal_Int16 nEventId,
359*cdf0e10cSrcweir                                            const uno::Any& rNewValue,
360*cdf0e10cSrcweir                                            const uno::Any& rOldValue ) const
361*cdf0e10cSrcweir     {
362*cdf0e10cSrcweir         DBG_ASSERT( maChildren.size() > nStartPara &&
363*cdf0e10cSrcweir                     maChildren.size() >= nEndPara , "AccessibleParaManager::FireEvent: invalid index" );
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir         if( maChildren.size() > nStartPara &&
366*cdf0e10cSrcweir             maChildren.size() >= nEndPara )
367*cdf0e10cSrcweir         {
368*cdf0e10cSrcweir             VectorOfChildren::const_iterator front = maChildren.begin();
369*cdf0e10cSrcweir             VectorOfChildren::const_iterator back = front;
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir             ::std::advance( front, nStartPara );
372*cdf0e10cSrcweir             ::std::advance( back, nEndPara );
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir             StateChangeEvent aFunctor( nEventId, rNewValue, rOldValue );
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir             ::std::for_each( front, back, AccessibleParaManager::WeakChildAdapter< StateChangeEvent >( aFunctor ) );
377*cdf0e10cSrcweir         }
378*cdf0e10cSrcweir     }
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir     class ReleaseChild : public ::std::unary_function< const AccessibleParaManager::WeakChild&, AccessibleParaManager::WeakChild >
381*cdf0e10cSrcweir     {
382*cdf0e10cSrcweir     public:
383*cdf0e10cSrcweir         AccessibleParaManager::WeakChild operator()( const AccessibleParaManager::WeakChild& rPara )
384*cdf0e10cSrcweir         {
385*cdf0e10cSrcweir             AccessibleParaManager::ShutdownPara( rPara );
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir             // clear reference
388*cdf0e10cSrcweir             return AccessibleParaManager::WeakChild();
389*cdf0e10cSrcweir         }
390*cdf0e10cSrcweir     };
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir     void AccessibleParaManager::Release( sal_uInt32 nStartPara, sal_uInt32 nEndPara )
393*cdf0e10cSrcweir     {
394*cdf0e10cSrcweir         DBG_ASSERT( maChildren.size() > nStartPara &&
395*cdf0e10cSrcweir                     maChildren.size() >= nEndPara, "AccessibleParaManager::Release: invalid index" );
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir         if( maChildren.size() > nStartPara &&
398*cdf0e10cSrcweir             maChildren.size() >= nEndPara )
399*cdf0e10cSrcweir         {
400*cdf0e10cSrcweir             VectorOfChildren::iterator front = maChildren.begin();
401*cdf0e10cSrcweir             VectorOfChildren::iterator back = front;
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir             ::std::advance( front, nStartPara );
404*cdf0e10cSrcweir             ::std::advance( back, nEndPara );
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir             ::std::transform( front, back, front, ReleaseChild() );
407*cdf0e10cSrcweir         }
408*cdf0e10cSrcweir     }
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir     void AccessibleParaManager::ShutdownPara( const WeakChild& rChild )
411*cdf0e10cSrcweir     {
412*cdf0e10cSrcweir         WeakPara::HardRefType aChild( rChild.first.get() );
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir         if( IsReferencable( aChild ) )
415*cdf0e10cSrcweir             aChild->SetEditSource( NULL );
416*cdf0e10cSrcweir     }
417*cdf0e10cSrcweir 
418*cdf0e10cSrcweir }
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir //------------------------------------------------------------------------
421