xref: /AOO41X/main/sw/source/core/access/acccontext.cxx (revision 8394d9e9a1788603252cf11ac4b37486a033e539)
1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir #if (OSL_DEBUG_LEVEL > 1) && defined TEST_MIB
27cdf0e10cSrcweir 	#ifndef _STRING_HXX
28cdf0e10cSrcweir 	#include <tools/string.hxx>
29cdf0e10cSrcweir 	#endif
30cdf0e10cSrcweir 
31cdf0e10cSrcweir 	#ifndef _STREAM_HXX
32cdf0e10cSrcweir 	#include <tools/stream.hxx>
33cdf0e10cSrcweir 	#endif
34cdf0e10cSrcweir #endif // #if (OSL_DEBUG_LEVEL > 1) && defined TEST_MIB
35cdf0e10cSrcweir #include <tools/debug.hxx>
36cdf0e10cSrcweir #include <vcl/window.hxx>
37cdf0e10cSrcweir #include <errhdl.hxx>
38cdf0e10cSrcweir #include <swtypes.hxx>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessible.hpp>
41cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleStateSet.hpp>
42cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp>
43cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp>
44cdf0e10cSrcweir #include <vos/mutex.hxx>
45cdf0e10cSrcweir #include <vcl/svapp.hxx>
46cdf0e10cSrcweir #include <unotools/accessiblestatesethelper.hxx>
47cdf0e10cSrcweir #include <unotools/accessiblerelationsethelper.hxx>
48cdf0e10cSrcweir #include <viewsh.hxx>
49cdf0e10cSrcweir #include <crsrsh.hxx>
50cdf0e10cSrcweir #include <fesh.hxx>
51cdf0e10cSrcweir #include <txtfrm.hxx>
52cdf0e10cSrcweir #include <ndtxt.hxx>
53cdf0e10cSrcweir #include <pagefrm.hxx>
54cdf0e10cSrcweir #include <flyfrm.hxx>
55cdf0e10cSrcweir #include <dflyobj.hxx>
56cdf0e10cSrcweir #include <pam.hxx>
57cdf0e10cSrcweir #include <viewimp.hxx>
58cdf0e10cSrcweir #include <accmap.hxx>
59cdf0e10cSrcweir #include <accfrmobjslist.hxx>
60cdf0e10cSrcweir #include <acccontext.hxx>
61cdf0e10cSrcweir #include <svx/AccessibleShape.hxx>
62cdf0e10cSrcweir #include <comphelper/accessibleeventnotifier.hxx>
63ca62e2c2SSteve Yin #ifndef _ACCPARA_HXX
64ca62e2c2SSteve Yin #include "accpara.hxx"
65ca62e2c2SSteve Yin #endif
66cdf0e10cSrcweir #include <PostItMgr.hxx>
67cdf0e10cSrcweir 
68cdf0e10cSrcweir using namespace sw::access;
69cdf0e10cSrcweir 
70cdf0e10cSrcweir #if (OSL_DEBUG_LEVEL > 1) && defined TEST_MIB
71cdf0e10cSrcweir #define DBG_MSG( _msg ) \
72cdf0e10cSrcweir 	lcl_SwAccessibleContext_DbgMsg( this, _msg, 0, sal_False );
73cdf0e10cSrcweir #define DBG_MSG_CD( _msg ) \
74cdf0e10cSrcweir 	lcl_SwAccessibleContext_DbgMsg( this, _msg, 0, sal_True );
75cdf0e10cSrcweir #define DBG_MSG_PARAM( _msg, _param ) \
76cdf0e10cSrcweir 	lcl_SwAccessibleContext_DbgMsg( this, _msg, _param, sal_False );
77cdf0e10cSrcweir #define DBG_MSG_THIS_PARAM( _msg, _this, _param ) \
78cdf0e10cSrcweir 	lcl_SwAccessibleContext_DbgMsg( _this, _msg, _param, sal_False );
79cdf0e10cSrcweir 
80cdf0e10cSrcweir void lcl_SwAccessibleContext_DbgMsg( SwAccessibleContext *pThisAcc,
81cdf0e10cSrcweir 									 const char *pMsg,
82cdf0e10cSrcweir 								     SwAccessibleContext *pChildAcc,
83cdf0e10cSrcweir 								  	 sal_Bool bConstrDestr );
84cdf0e10cSrcweir #else
85cdf0e10cSrcweir #define DBG_MSG( _msg )
86cdf0e10cSrcweir #define DBG_MSG_PARAM( _msg, _param )
87cdf0e10cSrcweir #define DBG_MSG_THIS_PARAM( _msg, _this, _param )
88cdf0e10cSrcweir #define DBG_MSG_CD( _msg )
89cdf0e10cSrcweir #endif
90cdf0e10cSrcweir 
91cdf0e10cSrcweir using namespace ::com::sun::star;
92cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
93cdf0e10cSrcweir using ::rtl::OUString;
94cdf0e10cSrcweir 
InitStates()95cdf0e10cSrcweir void SwAccessibleContext::InitStates()
96cdf0e10cSrcweir {
97cdf0e10cSrcweir     bIsShowingState = GetMap() ? IsShowing( *(GetMap()) ) : sal_False;
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 	ViewShell *pVSh = GetMap()->GetShell();
100cdf0e10cSrcweir     bIsEditableState = pVSh && IsEditable( pVSh );
101cdf0e10cSrcweir 	bIsOpaqueState = pVSh && IsOpaque( pVSh );
102cdf0e10cSrcweir 	bIsDefuncState = sal_False;
103cdf0e10cSrcweir }
104cdf0e10cSrcweir 
SetParent(SwAccessibleContext * pParent)105cdf0e10cSrcweir void SwAccessibleContext::SetParent( SwAccessibleContext *pParent )
106cdf0e10cSrcweir {
107cdf0e10cSrcweir 	vos::OGuard aGuard( aMutex );
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 	uno::Reference < XAccessible > xParent( pParent );
110cdf0e10cSrcweir 	xWeakParent = xParent;
111cdf0e10cSrcweir }
112cdf0e10cSrcweir 
GetWeakParent() const113cdf0e10cSrcweir uno::Reference< XAccessible > SwAccessibleContext::GetWeakParent() const
114cdf0e10cSrcweir {
115cdf0e10cSrcweir 	vos::OGuard aGuard( aMutex );
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 	uno::Reference< XAccessible > xParent( xWeakParent );
118cdf0e10cSrcweir 	return xParent;
119cdf0e10cSrcweir }
120cdf0e10cSrcweir 
GetWindow()121cdf0e10cSrcweir Window *SwAccessibleContext::GetWindow()
122cdf0e10cSrcweir {
123cdf0e10cSrcweir 	Window *pWin = 0;
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 	if( GetMap() )
126cdf0e10cSrcweir 	{
127cdf0e10cSrcweir 		const ViewShell *pVSh = GetMap()->GetShell();
128cdf0e10cSrcweir 		ASSERT( pVSh, "no view shell" );
129cdf0e10cSrcweir 		if( pVSh )
130cdf0e10cSrcweir 			pWin = pVSh->GetWin();
131cdf0e10cSrcweir 
132cdf0e10cSrcweir 		ASSERT( pWin, "no window" );
133cdf0e10cSrcweir 	}
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 	return pWin;
136cdf0e10cSrcweir }
137cdf0e10cSrcweir 
138cdf0e10cSrcweir // get ViewShell from accessibility map, and cast to cursor shell
GetCrsrShell()139cdf0e10cSrcweir SwCrsrShell* SwAccessibleContext::GetCrsrShell()
140cdf0e10cSrcweir {
141cdf0e10cSrcweir     SwCrsrShell* pCrsrShell;
142cdf0e10cSrcweir     ViewShell* pViewShell = GetMap() ? GetMap()->GetShell() : 0;
143cdf0e10cSrcweir 	ASSERT( pViewShell, "no view shell" );
144cdf0e10cSrcweir     if( pViewShell && pViewShell->ISA( SwCrsrShell ) )
145cdf0e10cSrcweir         pCrsrShell = static_cast<SwCrsrShell*>( pViewShell );
146cdf0e10cSrcweir     else
147cdf0e10cSrcweir         pCrsrShell = NULL;
148cdf0e10cSrcweir 
149cdf0e10cSrcweir     return pCrsrShell;
150cdf0e10cSrcweir }
151cdf0e10cSrcweir 
GetCrsrShell() const152cdf0e10cSrcweir const SwCrsrShell* SwAccessibleContext::GetCrsrShell() const
153cdf0e10cSrcweir {
154cdf0e10cSrcweir     // just like non-const GetCrsrShell
155cdf0e10cSrcweir     const SwCrsrShell* pCrsrShell;
156cdf0e10cSrcweir     const ViewShell* pViewShell = GetMap() ? GetMap()->GetShell() : 0;
157cdf0e10cSrcweir 	ASSERT( pViewShell, "no view shell" );
158cdf0e10cSrcweir     if( pViewShell && pViewShell->ISA( SwCrsrShell ) )
159cdf0e10cSrcweir         pCrsrShell = static_cast<const SwCrsrShell*>( pViewShell );
160cdf0e10cSrcweir     else
161cdf0e10cSrcweir         pCrsrShell = NULL;
162cdf0e10cSrcweir 
163cdf0e10cSrcweir     return pCrsrShell;
164cdf0e10cSrcweir }
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 
167cdf0e10cSrcweir enum Action { NONE, SCROLLED, SCROLLED_WITHIN,
168cdf0e10cSrcweir 						  SCROLLED_IN, SCROLLED_OUT };
169cdf0e10cSrcweir 
ChildrenScrolled(const SwFrm * pFrm,const SwRect & rOldVisArea)170cdf0e10cSrcweir void SwAccessibleContext::ChildrenScrolled( const SwFrm *pFrm,
171cdf0e10cSrcweir                                             const SwRect& rOldVisArea )
172cdf0e10cSrcweir {
173cdf0e10cSrcweir 	const SwRect& rNewVisArea = GetVisArea();
174cdf0e10cSrcweir     const bool bVisibleChildrenOnly = SwAccessibleChild( pFrm ).IsVisibleChildrenOnly();
175cdf0e10cSrcweir 
176cdf0e10cSrcweir     const SwAccessibleChildSList aList( *pFrm, *(GetMap()) );
177cdf0e10cSrcweir     SwAccessibleChildSList::const_iterator aIter( aList.begin() );
178cdf0e10cSrcweir 	while( aIter != aList.end() )
179cdf0e10cSrcweir 	{
180cdf0e10cSrcweir         const SwAccessibleChild& rLower = *aIter;
181cdf0e10cSrcweir         const SwRect aBox( rLower.GetBox( *(GetMap()) ) );
182cdf0e10cSrcweir 		if( rLower.IsAccessible( GetShell()->IsPreView() ) )
183cdf0e10cSrcweir 		{
184cdf0e10cSrcweir 			Action eAction = NONE;
185cdf0e10cSrcweir 			if( aBox.IsOver( rNewVisArea ) )
186cdf0e10cSrcweir 			{
187cdf0e10cSrcweir 				if( aBox.IsOver( rOldVisArea ) )
188cdf0e10cSrcweir 				{
189cdf0e10cSrcweir 					eAction = SCROLLED_WITHIN;
190cdf0e10cSrcweir 				}
191cdf0e10cSrcweir 				else
192cdf0e10cSrcweir 				{
193cdf0e10cSrcweir                     if ( bVisibleChildrenOnly &&
194cdf0e10cSrcweir                          !rLower.AlwaysIncludeAsChild() )
195cdf0e10cSrcweir                     {
196cdf0e10cSrcweir 						eAction = SCROLLED_IN;
197cdf0e10cSrcweir                     }
198cdf0e10cSrcweir 					else
199cdf0e10cSrcweir                     {
200cdf0e10cSrcweir 						eAction = SCROLLED;
201cdf0e10cSrcweir                     }
202cdf0e10cSrcweir 				}
203cdf0e10cSrcweir 			}
204cdf0e10cSrcweir 			else if( aBox.IsOver( rOldVisArea ) )
205cdf0e10cSrcweir 			{
206cdf0e10cSrcweir                 if ( bVisibleChildrenOnly &&
207cdf0e10cSrcweir                      !rLower.AlwaysIncludeAsChild() )
208cdf0e10cSrcweir                 {
209cdf0e10cSrcweir 					eAction = SCROLLED_OUT;
210cdf0e10cSrcweir                 }
211cdf0e10cSrcweir 				else
212cdf0e10cSrcweir                 {
213cdf0e10cSrcweir 					eAction = SCROLLED;
214cdf0e10cSrcweir                 }
215cdf0e10cSrcweir 			}
216cdf0e10cSrcweir             else if( !bVisibleChildrenOnly ||
217cdf0e10cSrcweir                      rLower.AlwaysIncludeAsChild() )
218cdf0e10cSrcweir 			{
219cdf0e10cSrcweir 				// This wouldn't be required if the SwAccessibleFrame,
220cdf0e10cSrcweir 				// wouldn't know about the vis area.
221cdf0e10cSrcweir 				eAction = SCROLLED;
222cdf0e10cSrcweir 			}
223cdf0e10cSrcweir 			if( NONE != eAction )
224cdf0e10cSrcweir 			{
225cdf0e10cSrcweir                 if ( rLower.GetSwFrm() )
226cdf0e10cSrcweir 				{
227cdf0e10cSrcweir                     ASSERT( !rLower.AlwaysIncludeAsChild(),
228cdf0e10cSrcweir                             "<SwAccessibleContext::ChildrenScrolled(..)> - always included child not considered!" );
229cdf0e10cSrcweir                     const SwFrm* pLower( rLower.GetSwFrm() );
230cdf0e10cSrcweir 					::vos::ORef< SwAccessibleContext > xAccImpl =
231ca62e2c2SSteve Yin 						//O is: GetMap()->GetContextImpl( pLower, SCROLLED_OUT == eAction ||
232ca62e2c2SSteve Yin 						//						SCROLLED_IN == eAction );
233ca62e2c2SSteve Yin 						GetMap()->GetContextImpl( pLower, sal_True );
234cdf0e10cSrcweir 					if( xAccImpl.isValid() )
235cdf0e10cSrcweir 					{
236cdf0e10cSrcweir 						switch( eAction )
237cdf0e10cSrcweir 						{
238cdf0e10cSrcweir 						case SCROLLED:
239cdf0e10cSrcweir 							xAccImpl->Scrolled( rOldVisArea );
240cdf0e10cSrcweir 							break;
241cdf0e10cSrcweir 						case SCROLLED_WITHIN:
242cdf0e10cSrcweir 							xAccImpl->ScrolledWithin( rOldVisArea );
243cdf0e10cSrcweir 							break;
244cdf0e10cSrcweir 						case SCROLLED_IN:
245cdf0e10cSrcweir 							xAccImpl->ScrolledIn();
246cdf0e10cSrcweir 							break;
247cdf0e10cSrcweir 						case SCROLLED_OUT:
248cdf0e10cSrcweir 							xAccImpl->ScrolledOut( rOldVisArea );
249cdf0e10cSrcweir 							break;
250cdf0e10cSrcweir 						case NONE:
251cdf0e10cSrcweir 							break;
252cdf0e10cSrcweir 						}
253cdf0e10cSrcweir 					}
254cdf0e10cSrcweir 					else
255cdf0e10cSrcweir 					{
256cdf0e10cSrcweir 						ChildrenScrolled( pLower, rOldVisArea );
257cdf0e10cSrcweir 					}
258cdf0e10cSrcweir 				}
259cdf0e10cSrcweir                 else if ( rLower.GetDrawObject() )
260cdf0e10cSrcweir 				{
261cdf0e10cSrcweir                     ASSERT( !rLower.AlwaysIncludeAsChild(),
262cdf0e10cSrcweir                             "<SwAccessibleContext::ChildrenScrolled(..)> - always included child not considered!" );
263cdf0e10cSrcweir 					::vos::ORef< ::accessibility::AccessibleShape > xAccImpl =
264ca62e2c2SSteve Yin 						//O is:	GetMap()->GetContextImpl( rLower.GetSdrObject(),
265ca62e2c2SSteve Yin 						//						  this,
266ca62e2c2SSteve Yin 						//						  SCROLLED_OUT == eAction ||
267ca62e2c2SSteve Yin 						//						  SCROLLED_IN == eAction );
268cdf0e10cSrcweir                         GetMap()->GetContextImpl( rLower.GetDrawObject(),
269cdf0e10cSrcweir 												  this,
270ca62e2c2SSteve Yin 												  sal_True );
271cdf0e10cSrcweir 					if( xAccImpl.isValid() )
272cdf0e10cSrcweir 					{
273cdf0e10cSrcweir 						switch( eAction )
274cdf0e10cSrcweir 						{
275cdf0e10cSrcweir 						case SCROLLED:
276cdf0e10cSrcweir 						case SCROLLED_WITHIN:
277cdf0e10cSrcweir 							xAccImpl->ViewForwarderChanged(
278cdf0e10cSrcweir 								::accessibility::IAccessibleViewForwarderListener::VISIBLE_AREA,
279cdf0e10cSrcweir 								GetMap() );
280cdf0e10cSrcweir 							break;
281cdf0e10cSrcweir 						case SCROLLED_IN:
282cdf0e10cSrcweir                             ScrolledInShape( rLower.GetDrawObject(),
283cdf0e10cSrcweir 											 xAccImpl.getBodyPtr() );
284cdf0e10cSrcweir 							break;
285cdf0e10cSrcweir 						case SCROLLED_OUT:
286cdf0e10cSrcweir 							{
287cdf0e10cSrcweir 								xAccImpl->ViewForwarderChanged(
288cdf0e10cSrcweir 									::accessibility::IAccessibleViewForwarderListener::VISIBLE_AREA,
289cdf0e10cSrcweir 									GetMap() );
290ca62e2c2SSteve Yin 								//Remove
291ca62e2c2SSteve Yin 								//DisposeShape( rLower.GetDrawObject(),
292ca62e2c2SSteve Yin 								//			  xAccImpl.getBodyPtr() );
293cdf0e10cSrcweir 							}
294cdf0e10cSrcweir 							break;
295cdf0e10cSrcweir 						case NONE:
296cdf0e10cSrcweir 							break;
297cdf0e10cSrcweir 						}
298cdf0e10cSrcweir 					}
299cdf0e10cSrcweir 				}
300cdf0e10cSrcweir                 else if ( rLower.GetWindow() )
301cdf0e10cSrcweir                 {
302cdf0e10cSrcweir                     // nothing to do - as such children are always included as children.
303cdf0e10cSrcweir                     ASSERT( rLower.AlwaysIncludeAsChild(),
304cdf0e10cSrcweir                             "<SwAccessibleContext::ChildrenScrolled(..)> - not always included child not considered!" );
305cdf0e10cSrcweir                 }
306cdf0e10cSrcweir 			}
307cdf0e10cSrcweir 		}
308cdf0e10cSrcweir         else if ( rLower.GetSwFrm() &&
309cdf0e10cSrcweir                   ( !bVisibleChildrenOnly ||
310cdf0e10cSrcweir                     aBox.IsOver( rOldVisArea ) ||
311cdf0e10cSrcweir                     aBox.IsOver( rNewVisArea ) ) )
312cdf0e10cSrcweir 		{
313cdf0e10cSrcweir 			// There are no unaccessible SdrObjects that need to be notified
314cdf0e10cSrcweir             ChildrenScrolled( rLower.GetSwFrm(), rOldVisArea );
315cdf0e10cSrcweir 		}
316cdf0e10cSrcweir 		++aIter;
317cdf0e10cSrcweir 	}
318cdf0e10cSrcweir }
319cdf0e10cSrcweir 
Scrolled(const SwRect & rOldVisArea)320cdf0e10cSrcweir void SwAccessibleContext::Scrolled( const SwRect& rOldVisArea )
321cdf0e10cSrcweir {
322cdf0e10cSrcweir 	SetVisArea( GetMap()->GetVisArea() );
323cdf0e10cSrcweir 
324cdf0e10cSrcweir 	ChildrenScrolled( GetFrm(), rOldVisArea );
325cdf0e10cSrcweir 
326cdf0e10cSrcweir 	sal_Bool bIsOldShowingState;
327cdf0e10cSrcweir     sal_Bool bIsNewShowingState = IsShowing( *(GetMap()) );
328cdf0e10cSrcweir 	{
329cdf0e10cSrcweir 		vos::OGuard aGuard( aMutex );
330cdf0e10cSrcweir 		bIsOldShowingState = bIsShowingState;
331cdf0e10cSrcweir 		bIsShowingState = bIsNewShowingState;
332cdf0e10cSrcweir 	}
333cdf0e10cSrcweir 
334cdf0e10cSrcweir 	if( bIsOldShowingState != bIsNewShowingState )
335cdf0e10cSrcweir 		FireStateChangedEvent( AccessibleStateType::SHOWING,
336cdf0e10cSrcweir 							   bIsNewShowingState  );
337cdf0e10cSrcweir }
338cdf0e10cSrcweir 
ScrolledWithin(const SwRect & rOldVisArea)339cdf0e10cSrcweir void SwAccessibleContext::ScrolledWithin( const SwRect& rOldVisArea )
340cdf0e10cSrcweir {
341cdf0e10cSrcweir 	SetVisArea( GetMap()->GetVisArea() );
342cdf0e10cSrcweir 
343cdf0e10cSrcweir 	ChildrenScrolled( GetFrm(), rOldVisArea );
344cdf0e10cSrcweir 
345cdf0e10cSrcweir 	FireVisibleDataEvent();
346cdf0e10cSrcweir }
347cdf0e10cSrcweir 
ScrolledIn()348cdf0e10cSrcweir void SwAccessibleContext::ScrolledIn()
349cdf0e10cSrcweir {
350cdf0e10cSrcweir 	// This accessible should be freshly created, because it
351cdf0e10cSrcweir 	// was not visisble before. Therefor, its vis area must already
352cdf0e10cSrcweir 	// reflect the scrolling.
353cdf0e10cSrcweir 	ASSERT( GetVisArea() == GetMap()->GetVisArea(),
354cdf0e10cSrcweir 			"Vis area of child is wrong. Did it exist already?" );
355cdf0e10cSrcweir 
356cdf0e10cSrcweir 	// Send child event at parent. That's all we have to do here.
357cdf0e10cSrcweir     const SwFrm* pParent = GetParent();
358cdf0e10cSrcweir 	::vos::ORef< SwAccessibleContext > xParentImpl(
359cdf0e10cSrcweir 		 GetMap()->GetContextImpl( pParent, sal_False ) );
360cdf0e10cSrcweir 	uno::Reference < XAccessibleContext > xThis( this );
361cdf0e10cSrcweir 	if( xParentImpl.isValid() )
362cdf0e10cSrcweir 	{
363cdf0e10cSrcweir 		SetParent( xParentImpl.getBodyPtr() );
364cdf0e10cSrcweir 
365cdf0e10cSrcweir 		AccessibleEventObject aEvent;
366cdf0e10cSrcweir 		aEvent.EventId = AccessibleEventId::CHILD;
367cdf0e10cSrcweir 		aEvent.NewValue <<= xThis;
368cdf0e10cSrcweir 
369cdf0e10cSrcweir 		xParentImpl->FireAccessibleEvent( aEvent );
370cdf0e10cSrcweir 		DBG_MSG_PARAM( "AccessibleChild (added)", xChildImpl.getBodyPtr() );
371cdf0e10cSrcweir 
372cdf0e10cSrcweir 		if( HasCursor() )
373cdf0e10cSrcweir 		{
374cdf0e10cSrcweir 			Window *pWin = GetWindow();
375cdf0e10cSrcweir 			if( pWin && pWin->HasFocus() )
376cdf0e10cSrcweir 			{
377cdf0e10cSrcweir 				FireStateChangedEvent( AccessibleStateType::FOCUSED, sal_True );
378cdf0e10cSrcweir 			}
379cdf0e10cSrcweir 		}
380cdf0e10cSrcweir 
381cdf0e10cSrcweir 	}
382cdf0e10cSrcweir }
383cdf0e10cSrcweir 
ScrolledOut(const SwRect & rOldVisArea)384cdf0e10cSrcweir void SwAccessibleContext::ScrolledOut( const SwRect& rOldVisArea )
385cdf0e10cSrcweir {
386cdf0e10cSrcweir 	SetVisArea( GetMap()->GetVisArea() );
387cdf0e10cSrcweir 
388cdf0e10cSrcweir 	// First of all, update the children. That's required to dispose
389cdf0e10cSrcweir 	// all children that are existing only if they are visible. They
390cdf0e10cSrcweir 	// are not disposed by the recusive Dispose call that follows later on,
391cdf0e10cSrcweir 	// because this call will only dispose children that are in the
392cdf0e10cSrcweir 	// new vis area. The children we want to dispode however are in the
393cdf0e10cSrcweir 	// old vis area all.
394cdf0e10cSrcweir 	ChildrenScrolled( GetFrm(), rOldVisArea );
395cdf0e10cSrcweir 
396cdf0e10cSrcweir 	// Broadcast a state changed event for the showing state.
397cdf0e10cSrcweir 	// It might be that the child is freshly created just to send
398cdf0e10cSrcweir 	// the child event. In this case no listener will exist.
399cdf0e10cSrcweir 	FireStateChangedEvent( AccessibleStateType::SHOWING, sal_False );
400cdf0e10cSrcweir 
401ca62e2c2SSteve Yin 	//Remove Dispose When scrolledout
402cdf0e10cSrcweir 	// We now dispose the frame
403ca62e2c2SSteve Yin 	//	Dispose( sal_True );
404cdf0e10cSrcweir }
405cdf0e10cSrcweir 
406cdf0e10cSrcweir // --> OD 2005-12-12 #i27301# - use new type definition for <_nStates>
InvalidateChildrenStates(const SwFrm * _pFrm,tAccessibleStates _nStates)407cdf0e10cSrcweir void SwAccessibleContext::InvalidateChildrenStates( const SwFrm* _pFrm,
408cdf0e10cSrcweir                                                     tAccessibleStates _nStates )
409cdf0e10cSrcweir {
410cdf0e10cSrcweir     const SwAccessibleChildSList aVisList( GetVisArea(), *_pFrm, *(GetMap()) );
411cdf0e10cSrcweir 
412cdf0e10cSrcweir     SwAccessibleChildSList::const_iterator aIter( aVisList.begin() );
413cdf0e10cSrcweir 	while( aIter != aVisList.end() )
414cdf0e10cSrcweir 	{
415cdf0e10cSrcweir         const SwAccessibleChild& rLower = *aIter;
416cdf0e10cSrcweir         const SwFrm* pLower = rLower.GetSwFrm();
417cdf0e10cSrcweir 		if( pLower )
418cdf0e10cSrcweir 		{
419cdf0e10cSrcweir 			::vos::ORef< SwAccessibleContext > xAccImpl;
420cdf0e10cSrcweir 			if( rLower.IsAccessible( GetShell()->IsPreView() ) )
421cdf0e10cSrcweir 				xAccImpl = GetMap()->GetContextImpl( pLower, sal_False );
422cdf0e10cSrcweir 			if( xAccImpl.isValid() )
423cdf0e10cSrcweir                 xAccImpl->InvalidateStates( _nStates );
424cdf0e10cSrcweir 			else
425cdf0e10cSrcweir                 InvalidateChildrenStates( pLower, _nStates );
426cdf0e10cSrcweir 		}
427cdf0e10cSrcweir         else if ( rLower.GetDrawObject() )
428cdf0e10cSrcweir 		{
429cdf0e10cSrcweir 			// TODO: SdrObjects
430cdf0e10cSrcweir 		}
431cdf0e10cSrcweir         else if ( rLower.GetWindow() )
432cdf0e10cSrcweir         {
433cdf0e10cSrcweir             // nothing to do ?
434cdf0e10cSrcweir         }
435cdf0e10cSrcweir 
436cdf0e10cSrcweir 		++aIter;
437cdf0e10cSrcweir 	}
438cdf0e10cSrcweir }
439cdf0e10cSrcweir // <--
440cdf0e10cSrcweir 
DisposeChildren(const SwFrm * pFrm,sal_Bool bRecursive)441cdf0e10cSrcweir void SwAccessibleContext::DisposeChildren( const SwFrm *pFrm,
442cdf0e10cSrcweir 									   sal_Bool bRecursive )
443cdf0e10cSrcweir {
444cdf0e10cSrcweir     const SwAccessibleChildSList aVisList( GetVisArea(), *pFrm, *(GetMap()) );
445cdf0e10cSrcweir     SwAccessibleChildSList::const_iterator aIter( aVisList.begin() );
446cdf0e10cSrcweir 	while( aIter != aVisList.end() )
447cdf0e10cSrcweir 	{
448cdf0e10cSrcweir         const SwAccessibleChild& rLower = *aIter;
449cdf0e10cSrcweir         const SwFrm* pLower = rLower.GetSwFrm();
450cdf0e10cSrcweir 		if( pLower )
451cdf0e10cSrcweir 		{
452cdf0e10cSrcweir 			::vos::ORef< SwAccessibleContext > xAccImpl;
453cdf0e10cSrcweir 			if( rLower.IsAccessible( GetShell()->IsPreView() ) )
454cdf0e10cSrcweir 				xAccImpl = GetMap()->GetContextImpl( pLower, sal_False );
455cdf0e10cSrcweir 			if( xAccImpl.isValid() )
456cdf0e10cSrcweir 				xAccImpl->Dispose( bRecursive );
457cdf0e10cSrcweir 			else if( bRecursive )
458cdf0e10cSrcweir 				DisposeChildren( pLower, bRecursive );
459cdf0e10cSrcweir 		}
460cdf0e10cSrcweir         else if ( rLower.GetDrawObject() )
461cdf0e10cSrcweir 		{
462cdf0e10cSrcweir 			::vos::ORef< ::accessibility::AccessibleShape > xAccImpl(
463cdf0e10cSrcweir                     GetMap()->GetContextImpl( rLower.GetDrawObject(),
464cdf0e10cSrcweir 										  this, sal_False )  );
465cdf0e10cSrcweir 			if( xAccImpl.isValid() )
466cdf0e10cSrcweir                 DisposeShape( rLower.GetDrawObject(), xAccImpl.getBodyPtr() );
467cdf0e10cSrcweir 		}
468cdf0e10cSrcweir         else if ( rLower.GetWindow() )
469cdf0e10cSrcweir         {
470cdf0e10cSrcweir             DisposeChild( rLower, sal_False );
471cdf0e10cSrcweir         }
472cdf0e10cSrcweir 		++aIter;
473cdf0e10cSrcweir 	}
474cdf0e10cSrcweir }
475cdf0e10cSrcweir 
_InvalidateContent(sal_Bool)476cdf0e10cSrcweir void SwAccessibleContext::_InvalidateContent( sal_Bool )
477cdf0e10cSrcweir {
478cdf0e10cSrcweir }
479cdf0e10cSrcweir 
_InvalidateCursorPos()480cdf0e10cSrcweir void SwAccessibleContext::_InvalidateCursorPos()
481cdf0e10cSrcweir {
482cdf0e10cSrcweir }
483cdf0e10cSrcweir 
_InvalidateFocus()484cdf0e10cSrcweir void SwAccessibleContext::_InvalidateFocus()
485cdf0e10cSrcweir {
486cdf0e10cSrcweir }
487cdf0e10cSrcweir 
FireAccessibleEvent(AccessibleEventObject & rEvent)488cdf0e10cSrcweir void SwAccessibleContext::FireAccessibleEvent( AccessibleEventObject& rEvent )
489cdf0e10cSrcweir {
490cdf0e10cSrcweir 	ASSERT( GetFrm(), "fire event for diposed frame?" );
491cdf0e10cSrcweir 	if( !GetFrm() )
492cdf0e10cSrcweir 		return;
493cdf0e10cSrcweir 
494cdf0e10cSrcweir 	if( !rEvent.Source.is() )
495cdf0e10cSrcweir 	{
496cdf0e10cSrcweir 		uno::Reference < XAccessibleContext > xThis( this );
497cdf0e10cSrcweir 		rEvent.Source = xThis;
498cdf0e10cSrcweir 	}
499cdf0e10cSrcweir 
500cdf0e10cSrcweir 	if (nClientId)
501cdf0e10cSrcweir 		comphelper::AccessibleEventNotifier::addEvent( nClientId, rEvent );
502cdf0e10cSrcweir }
503cdf0e10cSrcweir 
FireVisibleDataEvent()504cdf0e10cSrcweir void SwAccessibleContext::FireVisibleDataEvent()
505cdf0e10cSrcweir {
506cdf0e10cSrcweir 	AccessibleEventObject aEvent;
507cdf0e10cSrcweir 	aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED;
508cdf0e10cSrcweir 
509cdf0e10cSrcweir 	FireAccessibleEvent( aEvent );
510cdf0e10cSrcweir 	DBG_MSG( "AccessibleVisibleData" )
511cdf0e10cSrcweir }
512cdf0e10cSrcweir 
FireStateChangedEvent(sal_Int16 nState,sal_Bool bNewState)513cdf0e10cSrcweir void SwAccessibleContext::FireStateChangedEvent( sal_Int16 nState,
514cdf0e10cSrcweir 												 sal_Bool bNewState )
515cdf0e10cSrcweir {
516cdf0e10cSrcweir 	AccessibleEventObject aEvent;
517cdf0e10cSrcweir 
518cdf0e10cSrcweir 	aEvent.EventId = AccessibleEventId::STATE_CHANGED;
519cdf0e10cSrcweir 	if( bNewState )
520cdf0e10cSrcweir 		aEvent.NewValue <<= nState;
521cdf0e10cSrcweir 	else
522cdf0e10cSrcweir 		aEvent.OldValue <<= nState;
523cdf0e10cSrcweir 
524cdf0e10cSrcweir 	FireAccessibleEvent( aEvent );
525cdf0e10cSrcweir 	DBG_MSG( "StateChanged" )
526cdf0e10cSrcweir }
527cdf0e10cSrcweir 
GetStates(::utl::AccessibleStateSetHelper & rStateSet)528cdf0e10cSrcweir void SwAccessibleContext::GetStates(
529cdf0e10cSrcweir 		::utl::AccessibleStateSetHelper& rStateSet )
530cdf0e10cSrcweir {
531cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
532cdf0e10cSrcweir 
533cdf0e10cSrcweir 	// SHOWING
534cdf0e10cSrcweir 	if( bIsShowingState )
535cdf0e10cSrcweir 		rStateSet.AddState( AccessibleStateType::SHOWING );
536cdf0e10cSrcweir 
537cdf0e10cSrcweir 	// EDITABLE
538cdf0e10cSrcweir 	if( bIsEditableState )
539ca62e2c2SSteve Yin 	//Solution:Set editable state to graphic and other object when the document is editable
540ca62e2c2SSteve Yin 	{
541cdf0e10cSrcweir 		rStateSet.AddState( AccessibleStateType::EDITABLE );
542ca62e2c2SSteve Yin 		rStateSet.AddState( AccessibleStateType::RESIZABLE );
543ca62e2c2SSteve Yin 		rStateSet.AddState( AccessibleStateType::MOVEABLE );
544ca62e2c2SSteve Yin 	}
545cdf0e10cSrcweir 	// ENABLED
546cdf0e10cSrcweir 	rStateSet.AddState( AccessibleStateType::ENABLED );
547cdf0e10cSrcweir 
548cdf0e10cSrcweir 	// OPAQUE
549cdf0e10cSrcweir 	if( bIsOpaqueState )
550cdf0e10cSrcweir 		rStateSet.AddState( AccessibleStateType::OPAQUE );
551cdf0e10cSrcweir 
552cdf0e10cSrcweir 	// VISIBLE
553cdf0e10cSrcweir 	rStateSet.AddState( AccessibleStateType::VISIBLE );
554cdf0e10cSrcweir 
555cdf0e10cSrcweir 	if( bIsDefuncState )
556cdf0e10cSrcweir 		rStateSet.AddState( AccessibleStateType::DEFUNC );
557cdf0e10cSrcweir }
558cdf0e10cSrcweir 
IsEditableState()559cdf0e10cSrcweir sal_Bool SwAccessibleContext::IsEditableState()
560cdf0e10cSrcweir {
561cdf0e10cSrcweir 	sal_Bool bRet;
562cdf0e10cSrcweir 	{
563cdf0e10cSrcweir 		vos::OGuard aGuard( aMutex );
564cdf0e10cSrcweir 		bRet = bIsEditableState;
565cdf0e10cSrcweir 	}
566cdf0e10cSrcweir 
567cdf0e10cSrcweir 	return bRet;
568cdf0e10cSrcweir }
569cdf0e10cSrcweir 
SwAccessibleContext(SwAccessibleMap * pM,sal_Int16 nR,const SwFrm * pF)570cdf0e10cSrcweir SwAccessibleContext::SwAccessibleContext( SwAccessibleMap *pM,
571cdf0e10cSrcweir 										  sal_Int16 nR,
572cdf0e10cSrcweir                                           const SwFrm *pF )
573cdf0e10cSrcweir     : SwAccessibleFrame( pM->GetVisArea().SVRect(), pF,
574cdf0e10cSrcweir                          pM->GetShell()->IsPreView() )
575cdf0e10cSrcweir     , pMap( pM )
576cdf0e10cSrcweir     , nClientId(0)
577cdf0e10cSrcweir     , nRole( nR )
578cdf0e10cSrcweir     , bDisposing( sal_False )
579cdf0e10cSrcweir     , bRegisteredAtAccessibleMap( true )
580ca62e2c2SSteve Yin     //Solution:Initialize the begin document load and IfAsynLoad to true
581ca62e2c2SSteve Yin     , bBeginDocumentLoad( sal_True )
582ca62e2c2SSteve Yin 	, isIfAsynLoad( sal_True )
583ca62e2c2SSteve Yin 	, bIsSeletedInDoc( sal_False)
584cdf0e10cSrcweir {
585cdf0e10cSrcweir 	InitStates();
586cdf0e10cSrcweir 	DBG_MSG_CD( "constructed" )
587cdf0e10cSrcweir }
588cdf0e10cSrcweir 
~SwAccessibleContext()589cdf0e10cSrcweir SwAccessibleContext::~SwAccessibleContext()
590cdf0e10cSrcweir {
591*8394d9e9SSteve Yin 	if(Application::GetUnoWrapper())
592cdf0e10cSrcweir 		vos::OGuard aGuard(Application::GetSolarMutex());
593cdf0e10cSrcweir 
594cdf0e10cSrcweir 	DBG_MSG_CD( "destructed" )
595cdf0e10cSrcweir     RemoveFrmFromAccessibleMap();
596cdf0e10cSrcweir }
597cdf0e10cSrcweir 
598cdf0e10cSrcweir uno::Reference< XAccessibleContext > SAL_CALL
getAccessibleContext(void)599cdf0e10cSrcweir 	SwAccessibleContext::getAccessibleContext( void )
600cdf0e10cSrcweir         throw (uno::RuntimeException)
601cdf0e10cSrcweir {
602cdf0e10cSrcweir 	uno::Reference < XAccessibleContext > xRet( this );
603cdf0e10cSrcweir 	return xRet;
604cdf0e10cSrcweir }
605cdf0e10cSrcweir 
getAccessibleChildCount(void)606cdf0e10cSrcweir sal_Int32 SAL_CALL SwAccessibleContext::getAccessibleChildCount( void )
607cdf0e10cSrcweir         throw (uno::RuntimeException)
608cdf0e10cSrcweir {
609cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
610cdf0e10cSrcweir 
611cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleContext )
612ca62e2c2SSteve Yin 	//Solution:Notify the frame is a document
613ca62e2c2SSteve Yin 	if( nRole == AccessibleRole::DOCUMENT )
614ca62e2c2SSteve Yin 		bIsAccDocUse = sal_True;
615cdf0e10cSrcweir 
616cdf0e10cSrcweir     return bDisposing ? 0 : GetChildCount( *(GetMap()) );
617cdf0e10cSrcweir }
618cdf0e10cSrcweir 
619cdf0e10cSrcweir uno::Reference< XAccessible> SAL_CALL
getAccessibleChild(sal_Int32 nIndex)620cdf0e10cSrcweir 	SwAccessibleContext::getAccessibleChild( sal_Int32 nIndex )
621cdf0e10cSrcweir         throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
622cdf0e10cSrcweir {
623cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
624cdf0e10cSrcweir 
625cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleContext )
626cdf0e10cSrcweir 
627ca62e2c2SSteve Yin 	//Solution:Notify the frame is a document
628ca62e2c2SSteve Yin 	if( nRole == AccessibleRole::DOCUMENT )
629ca62e2c2SSteve Yin 		bIsAccDocUse = sal_True;
630ca62e2c2SSteve Yin 
631cdf0e10cSrcweir     const SwAccessibleChild aChild( GetChild( *(GetMap()), nIndex ) );
632cdf0e10cSrcweir 	if( !aChild.IsValid() )
633cdf0e10cSrcweir 	{
634cdf0e10cSrcweir 		uno::Reference < XAccessibleContext > xThis( this );
635cdf0e10cSrcweir 		lang::IndexOutOfBoundsException aExcept(
636cdf0e10cSrcweir 				OUString( RTL_CONSTASCII_USTRINGPARAM("index out of bounds") ),
637cdf0e10cSrcweir 				xThis );
638cdf0e10cSrcweir 		throw aExcept;
639cdf0e10cSrcweir 	}
640cdf0e10cSrcweir 
641cdf0e10cSrcweir 	uno::Reference< XAccessible > xChild;
642cdf0e10cSrcweir 	if( aChild.GetSwFrm() )
643cdf0e10cSrcweir 	{
644cdf0e10cSrcweir 		::vos::ORef < SwAccessibleContext > xChildImpl(
645cdf0e10cSrcweir 				GetMap()->GetContextImpl( aChild.GetSwFrm(), !bDisposing )  );
646ca62e2c2SSteve Yin 		//Solution:Send out accessible event when begin load.
647ca62e2c2SSteve Yin 		if( bBeginDocumentLoad && nRole == AccessibleRole::DOCUMENT )
648ca62e2c2SSteve Yin 		{
649ca62e2c2SSteve Yin 
650ca62e2c2SSteve Yin 			FireStateChangedEvent( AccessibleStateType::FOCUSABLE,sal_True );
651ca62e2c2SSteve Yin 			FireStateChangedEvent( AccessibleStateType::BUSY,sal_True );
652ca62e2c2SSteve Yin 			if( !isIfAsynLoad )
653ca62e2c2SSteve Yin 			{
654ca62e2c2SSteve Yin 				FireStateChangedEvent( AccessibleStateType::FOCUSED,sal_True );
655ca62e2c2SSteve Yin 				// IA2 CWS. MT: OFFSCREEN == !SHOWING, should stay consistent
656ca62e2c2SSteve Yin 				// FireStateChangedEvent( AccessibleStateType::OFFSCREEN,sal_True );
657ca62e2c2SSteve Yin 				FireStateChangedEvent( AccessibleStateType::SHOWING,sal_True );
658ca62e2c2SSteve Yin 			    FireStateChangedEvent( AccessibleStateType::BUSY,sal_False );
659ca62e2c2SSteve Yin 				// MT: OFFSCREEN again?
660ca62e2c2SSteve Yin 			    // FireStateChangedEvent( AccessibleStateType::OFFSCREEN,sal_False );
661ca62e2c2SSteve Yin 			}
662ca62e2c2SSteve Yin 			bBeginDocumentLoad = sal_False;
663ca62e2c2SSteve Yin 		}
664cdf0e10cSrcweir 		if( xChildImpl.isValid() )
665cdf0e10cSrcweir 		{
666cdf0e10cSrcweir 			xChildImpl->SetParent( this );
667cdf0e10cSrcweir 			xChild = xChildImpl.getBodyPtr();
668cdf0e10cSrcweir 		}
669cdf0e10cSrcweir 	}
670cdf0e10cSrcweir     else if ( aChild.GetDrawObject() )
671cdf0e10cSrcweir 	{
672cdf0e10cSrcweir 		::vos::ORef < ::accessibility::AccessibleShape > xChildImpl(
673cdf0e10cSrcweir                 GetMap()->GetContextImpl( aChild.GetDrawObject(),
674cdf0e10cSrcweir 										  this, !bDisposing )  );
675cdf0e10cSrcweir 		if( xChildImpl.isValid() )
676cdf0e10cSrcweir 			xChild = xChildImpl.getBodyPtr();
677cdf0e10cSrcweir 	}
678cdf0e10cSrcweir     else if ( aChild.GetWindow() )
679cdf0e10cSrcweir     {
680cdf0e10cSrcweir         xChild = aChild.GetWindow()->GetAccessible();
681cdf0e10cSrcweir     }
682cdf0e10cSrcweir 
683cdf0e10cSrcweir 	return xChild;
684cdf0e10cSrcweir }
685cdf0e10cSrcweir 
getAccessibleParent(void)686cdf0e10cSrcweir uno::Reference< XAccessible> SAL_CALL SwAccessibleContext::getAccessibleParent (void)
687cdf0e10cSrcweir         throw (uno::RuntimeException)
688cdf0e10cSrcweir {
689cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
690cdf0e10cSrcweir 
691cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleContext )
692cdf0e10cSrcweir 
693cdf0e10cSrcweir 	const SwFrm *pUpper = GetParent();
694cdf0e10cSrcweir 	ASSERT( pUpper != 0 || bDisposing, "no upper found" );
695cdf0e10cSrcweir 
696cdf0e10cSrcweir 	uno::Reference< XAccessible > xAcc;
697cdf0e10cSrcweir 	if( pUpper )
698cdf0e10cSrcweir 		xAcc = GetMap()->GetContext( pUpper, !bDisposing );
699cdf0e10cSrcweir 
700cdf0e10cSrcweir 	ASSERT( xAcc.is() || bDisposing, "no parent found" );
701cdf0e10cSrcweir 
702cdf0e10cSrcweir 	// Remember the parent as weak ref.
703cdf0e10cSrcweir 	{
704cdf0e10cSrcweir         vos::OGuard aWeakParentGuard( aMutex );
705cdf0e10cSrcweir 		xWeakParent = xAcc;
706cdf0e10cSrcweir 	}
707cdf0e10cSrcweir 
708cdf0e10cSrcweir 	return xAcc;
709cdf0e10cSrcweir }
710cdf0e10cSrcweir 
getAccessibleIndexInParent(void)711cdf0e10cSrcweir sal_Int32 SAL_CALL SwAccessibleContext::getAccessibleIndexInParent (void)
712cdf0e10cSrcweir         throw (uno::RuntimeException)
713cdf0e10cSrcweir {
714cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
715cdf0e10cSrcweir 
716cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleContext )
717cdf0e10cSrcweir 
718cdf0e10cSrcweir 	const SwFrm *pUpper = GetParent();
719cdf0e10cSrcweir 	ASSERT( pUpper != 0 || bDisposing, "no upper found" );
720cdf0e10cSrcweir 
721cdf0e10cSrcweir 	sal_Int32 nIndex = -1;
722cdf0e10cSrcweir 	if( pUpper )
723cdf0e10cSrcweir 	{
724cdf0e10cSrcweir 		::vos::ORef < SwAccessibleContext > xAccImpl(
725cdf0e10cSrcweir 			GetMap()->GetContextImpl( pUpper, !bDisposing )  );
726cdf0e10cSrcweir 		ASSERT( xAccImpl.isValid() || bDisposing, "no parent found" );
727cdf0e10cSrcweir 		if( xAccImpl.isValid() )
728cdf0e10cSrcweir             nIndex = xAccImpl->GetChildIndex( *(GetMap()), SwAccessibleChild(GetFrm()) );
729cdf0e10cSrcweir 	}
730cdf0e10cSrcweir 
731cdf0e10cSrcweir 	return nIndex;
732cdf0e10cSrcweir }
733cdf0e10cSrcweir 
getAccessibleRole(void)734cdf0e10cSrcweir sal_Int16 SAL_CALL SwAccessibleContext::getAccessibleRole (void)
735cdf0e10cSrcweir         throw (uno::RuntimeException)
736cdf0e10cSrcweir {
737cdf0e10cSrcweir 	return nRole;
738cdf0e10cSrcweir }
739cdf0e10cSrcweir 
getAccessibleDescription(void)740cdf0e10cSrcweir OUString SAL_CALL SwAccessibleContext::getAccessibleDescription (void)
741cdf0e10cSrcweir         throw (uno::RuntimeException)
742cdf0e10cSrcweir {
743cdf0e10cSrcweir 	ASSERT( !this, "description needs to be overloaded" );
744cdf0e10cSrcweir 	THROW_RUNTIME_EXCEPTION( XAccessibleContext, "internal error (method must be overloaded)" );
745cdf0e10cSrcweir }
746cdf0e10cSrcweir 
getAccessibleName(void)747cdf0e10cSrcweir OUString SAL_CALL SwAccessibleContext::getAccessibleName (void)
748cdf0e10cSrcweir         throw (uno::RuntimeException)
749cdf0e10cSrcweir {
750cdf0e10cSrcweir 	return sName;
751cdf0e10cSrcweir }
752cdf0e10cSrcweir 
753cdf0e10cSrcweir uno::Reference< XAccessibleRelationSet> SAL_CALL
getAccessibleRelationSet(void)754cdf0e10cSrcweir 	SwAccessibleContext::getAccessibleRelationSet (void)
755cdf0e10cSrcweir         throw (uno::RuntimeException)
756cdf0e10cSrcweir {
757cdf0e10cSrcweir 	// by default there are no relations
758cdf0e10cSrcweir 	uno::Reference< XAccessibleRelationSet> xRet( new utl::AccessibleRelationSetHelper() );
759cdf0e10cSrcweir 	return xRet;
760cdf0e10cSrcweir }
761cdf0e10cSrcweir 
762cdf0e10cSrcweir uno::Reference<XAccessibleStateSet> SAL_CALL
getAccessibleStateSet(void)763cdf0e10cSrcweir 	SwAccessibleContext::getAccessibleStateSet (void)
764cdf0e10cSrcweir         throw (uno::RuntimeException)
765cdf0e10cSrcweir {
766cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
767cdf0e10cSrcweir 
768cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleContext )
769cdf0e10cSrcweir 
770cdf0e10cSrcweir 	::utl::AccessibleStateSetHelper *pStateSet =
771cdf0e10cSrcweir 		new ::utl::AccessibleStateSetHelper;
772cdf0e10cSrcweir 
773ca62e2c2SSteve Yin 	if( bIsSeletedInDoc )
774ca62e2c2SSteve Yin 		pStateSet->AddState( AccessibleStateType::SELECTED );
775ca62e2c2SSteve Yin 
776cdf0e10cSrcweir 	uno::Reference<XAccessibleStateSet> xStateSet( pStateSet );
777cdf0e10cSrcweir 	GetStates( *pStateSet );
778cdf0e10cSrcweir 
779cdf0e10cSrcweir 	return xStateSet;
780cdf0e10cSrcweir }
781cdf0e10cSrcweir 
getLocale(void)782cdf0e10cSrcweir lang::Locale SAL_CALL SwAccessibleContext::getLocale (void)
783cdf0e10cSrcweir 		throw (IllegalAccessibleComponentStateException, uno::RuntimeException)
784cdf0e10cSrcweir {
785cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
786cdf0e10cSrcweir 
787cdf0e10cSrcweir 	lang::Locale aLoc( Application::GetSettings().GetLocale() );
788cdf0e10cSrcweir 	return aLoc;
789cdf0e10cSrcweir }
790cdf0e10cSrcweir 
addEventListener(const uno::Reference<XAccessibleEventListener> & xListener)791cdf0e10cSrcweir void SAL_CALL SwAccessibleContext::addEventListener(
792cdf0e10cSrcweir 			const uno::Reference< XAccessibleEventListener >& xListener )
793cdf0e10cSrcweir 		throw (uno::RuntimeException)
794cdf0e10cSrcweir {
795cdf0e10cSrcweir 	DBG_MSG( "accessible event listener added" )
796cdf0e10cSrcweir 
797cdf0e10cSrcweir 	if (xListener.is())
798cdf0e10cSrcweir     {
799cdf0e10cSrcweir     	vos::OGuard aGuard(Application::GetSolarMutex());
800cdf0e10cSrcweir 		if (!nClientId)
801cdf0e10cSrcweir             nClientId = comphelper::AccessibleEventNotifier::registerClient( );
802cdf0e10cSrcweir 		comphelper::AccessibleEventNotifier::addEventListener( nClientId, xListener );
803cdf0e10cSrcweir     }
804cdf0e10cSrcweir }
805cdf0e10cSrcweir 
removeEventListener(const uno::Reference<XAccessibleEventListener> & xListener)806cdf0e10cSrcweir void SAL_CALL SwAccessibleContext::removeEventListener(
807cdf0e10cSrcweir 			const uno::Reference< XAccessibleEventListener >& xListener )
808cdf0e10cSrcweir 		throw (uno::RuntimeException)
809cdf0e10cSrcweir {
810cdf0e10cSrcweir 	DBG_MSG( "accessible event listener removed" )
811cdf0e10cSrcweir 
812cdf0e10cSrcweir 	if (xListener.is())
813cdf0e10cSrcweir 	{
814cdf0e10cSrcweir     	vos::OGuard aGuard(Application::GetSolarMutex());
815cdf0e10cSrcweir 		sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( nClientId, xListener );
816cdf0e10cSrcweir 		if ( !nListenerCount )
817cdf0e10cSrcweir 		{
818cdf0e10cSrcweir 			// no listeners anymore
819cdf0e10cSrcweir 			// -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
820cdf0e10cSrcweir 			// and at least to us not firing any events anymore, in case somebody calls
821cdf0e10cSrcweir 			// NotifyAccessibleEvent, again
822cdf0e10cSrcweir 			comphelper::AccessibleEventNotifier::revokeClient( nClientId );
823cdf0e10cSrcweir 			nClientId = 0;
824cdf0e10cSrcweir 		}
825cdf0e10cSrcweir 	}
826cdf0e10cSrcweir }
827cdf0e10cSrcweir 
lcl_PointInRectangle(const awt::Point & aPoint,const awt::Rectangle & aRect)828cdf0e10cSrcweir static sal_Bool lcl_PointInRectangle(const awt::Point & aPoint,
829cdf0e10cSrcweir                                      const awt::Rectangle & aRect)
830cdf0e10cSrcweir {
831cdf0e10cSrcweir     long nDiffX = aPoint.X - aRect.X;
832cdf0e10cSrcweir     long nDiffY = aPoint.Y - aRect.Y;
833cdf0e10cSrcweir 
834cdf0e10cSrcweir     return
835cdf0e10cSrcweir         nDiffX >= 0 && nDiffX < aRect.Width && nDiffY >= 0 &&
836cdf0e10cSrcweir         nDiffY < aRect.Height;
837cdf0e10cSrcweir 
838cdf0e10cSrcweir }
839cdf0e10cSrcweir 
containsPoint(const awt::Point & aPoint)840cdf0e10cSrcweir sal_Bool SAL_CALL SwAccessibleContext::containsPoint(
841cdf0e10cSrcweir 			const awt::Point& aPoint )
842cdf0e10cSrcweir 		throw (uno::RuntimeException)
843cdf0e10cSrcweir {
844cdf0e10cSrcweir     awt::Rectangle aPixBounds = getBoundsImpl(sal_True);
845cdf0e10cSrcweir     aPixBounds.X = 0;
846cdf0e10cSrcweir     aPixBounds.Y = 0;
847cdf0e10cSrcweir 
848cdf0e10cSrcweir     return lcl_PointInRectangle(aPoint, aPixBounds);
849cdf0e10cSrcweir }
850cdf0e10cSrcweir 
getAccessibleAtPoint(const awt::Point & aPoint)851cdf0e10cSrcweir uno::Reference< XAccessible > SAL_CALL SwAccessibleContext::getAccessibleAtPoint(
852cdf0e10cSrcweir 				const awt::Point& aPoint )
853cdf0e10cSrcweir 		throw (uno::RuntimeException)
854cdf0e10cSrcweir {
855cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
856cdf0e10cSrcweir 
857cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleComponent )
858cdf0e10cSrcweir 
859cdf0e10cSrcweir 	uno::Reference< XAccessible > xAcc;
860cdf0e10cSrcweir 
861cdf0e10cSrcweir 	Window *pWin = GetWindow();
862cdf0e10cSrcweir 	CHECK_FOR_WINDOW( XAccessibleComponent, pWin )
863cdf0e10cSrcweir 
864cdf0e10cSrcweir 	Point aPixPoint( aPoint.X, aPoint.Y ); // px rel to parent
865cdf0e10cSrcweir 	if( !GetFrm()->IsRootFrm() )
866cdf0e10cSrcweir 	{
867cdf0e10cSrcweir         SwRect aLogBounds( GetBounds( *(GetMap()), GetFrm() ) ); // twip rel to doc root
868cdf0e10cSrcweir 		Point aPixPos( GetMap()->CoreToPixel( aLogBounds.SVRect() ).TopLeft() );
869cdf0e10cSrcweir 		aPixPoint.X() += aPixPos.X();
870cdf0e10cSrcweir 		aPixPoint.Y() += aPixPos.Y();
871cdf0e10cSrcweir 	}
872cdf0e10cSrcweir 
873cdf0e10cSrcweir     const SwAccessibleChild aChild( GetChildAtPixel( aPixPoint, *(GetMap()) ) );
874cdf0e10cSrcweir 	if( aChild.GetSwFrm() )
875cdf0e10cSrcweir 	{
876cdf0e10cSrcweir 		xAcc = GetMap()->GetContext( aChild.GetSwFrm() );
877cdf0e10cSrcweir 	}
878cdf0e10cSrcweir     else if( aChild.GetDrawObject() )
879cdf0e10cSrcweir 	{
880cdf0e10cSrcweir         xAcc = GetMap()->GetContext( aChild.GetDrawObject(), this );
881cdf0e10cSrcweir 	}
882cdf0e10cSrcweir     else if ( aChild.GetWindow() )
883cdf0e10cSrcweir     {
884cdf0e10cSrcweir         xAcc = aChild.GetWindow()->GetAccessible();
885cdf0e10cSrcweir     }
886cdf0e10cSrcweir 
887cdf0e10cSrcweir 	return xAcc;
888cdf0e10cSrcweir }
889cdf0e10cSrcweir 
890cdf0e10cSrcweir 
891cdf0e10cSrcweir /**
892cdf0e10cSrcweir    Get bounding box.
893cdf0e10cSrcweir 
894cdf0e10cSrcweir    There are two modes.
895cdf0e10cSrcweir 
896cdf0e10cSrcweir    - realative
897cdf0e10cSrcweir 
898cdf0e10cSrcweir      Return bounding box relative to parent if parent is no root
899cdf0e10cSrcweir      frame. Otherwise return the absolute bounding box.
900cdf0e10cSrcweir 
901cdf0e10cSrcweir    - absolute
902cdf0e10cSrcweir 
903cdf0e10cSrcweir      Return the absolute bounding box.
904cdf0e10cSrcweir 
905cdf0e10cSrcweir    @param bRelative
906cdf0e10cSrcweir    true: Use relative mode.
907cdf0e10cSrcweir    false: Use absolute mode.
908cdf0e10cSrcweir */
getBoundsImpl(sal_Bool bRelative)909cdf0e10cSrcweir awt::Rectangle SAL_CALL SwAccessibleContext::getBoundsImpl(sal_Bool bRelative)
910cdf0e10cSrcweir 		throw (uno::RuntimeException)
911cdf0e10cSrcweir {
912cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
913cdf0e10cSrcweir 
914cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleComponent )
915cdf0e10cSrcweir 
916cdf0e10cSrcweir 	const SwFrm *pParent = GetParent();
917cdf0e10cSrcweir 	ASSERT( pParent, "no Parent found" );
918cdf0e10cSrcweir 	Window *pWin = GetWindow();
919cdf0e10cSrcweir 
920cdf0e10cSrcweir 	CHECK_FOR_WINDOW( XAccessibleComponent, pWin && pParent )
921cdf0e10cSrcweir 
922cdf0e10cSrcweir     SwRect aLogBounds( GetBounds( *(GetMap()), GetFrm() ) ); // twip rel to doc root
923cdf0e10cSrcweir 	Rectangle aPixBounds( 0, 0, 0, 0 );
924cdf0e10cSrcweir 	if( GetFrm()->IsPageFrm() &&
925cdf0e10cSrcweir 		static_cast < const SwPageFrm * >( GetFrm() )->IsEmptyPage() )
926cdf0e10cSrcweir 	{
927cdf0e10cSrcweir 		ASSERT( GetShell()->IsPreView(), "empty page accessible?" );
928cdf0e10cSrcweir 		if( GetShell()->IsPreView() )
929cdf0e10cSrcweir         {
930cdf0e10cSrcweir             // OD 15.01.2003 #103492# - adjust method call <GetMap()->GetPreViewPageSize()>
931cdf0e10cSrcweir             sal_uInt16 nPageNum =
932cdf0e10cSrcweir                 static_cast < const SwPageFrm * >( GetFrm() )->GetPhyPageNum();
933cdf0e10cSrcweir             aLogBounds.SSize( GetMap()->GetPreViewPageSize( nPageNum ) );
934cdf0e10cSrcweir         }
935cdf0e10cSrcweir 	}
936cdf0e10cSrcweir 	if( !aLogBounds.IsEmpty() )
937cdf0e10cSrcweir 	{
938cdf0e10cSrcweir 		aPixBounds = GetMap()->CoreToPixel( aLogBounds.SVRect() );
939cdf0e10cSrcweir 		if( !pParent->IsRootFrm() && bRelative)
940cdf0e10cSrcweir 		{
941cdf0e10cSrcweir             SwRect aParentLogBounds( GetBounds( *(GetMap()), pParent ) ); // twip rel to doc root
942cdf0e10cSrcweir 			Point aParentPixPos( GetMap()->CoreToPixel( aParentLogBounds.SVRect() ).TopLeft() );
943cdf0e10cSrcweir 			aPixBounds.Move( -aParentPixPos.X(), -aParentPixPos.Y() );
944cdf0e10cSrcweir 		}
945cdf0e10cSrcweir 	}
946cdf0e10cSrcweir 
947cdf0e10cSrcweir 	awt::Rectangle aBox( aPixBounds.Left(), aPixBounds.Top(),
948cdf0e10cSrcweir 						 aPixBounds.GetWidth(), aPixBounds.GetHeight() );
949cdf0e10cSrcweir 
950cdf0e10cSrcweir 	return aBox;
951cdf0e10cSrcweir }
952cdf0e10cSrcweir 
953cdf0e10cSrcweir 
getBounds()954cdf0e10cSrcweir awt::Rectangle SAL_CALL SwAccessibleContext::getBounds()
955cdf0e10cSrcweir 		throw (uno::RuntimeException)
956cdf0e10cSrcweir {
957cdf0e10cSrcweir     return getBoundsImpl(sal_True);
958cdf0e10cSrcweir }
959cdf0e10cSrcweir 
getLocation()960cdf0e10cSrcweir awt::Point SAL_CALL SwAccessibleContext::getLocation()
961cdf0e10cSrcweir     throw (uno::RuntimeException)
962cdf0e10cSrcweir {
963cdf0e10cSrcweir     awt::Rectangle aRect = getBoundsImpl(sal_True);
964cdf0e10cSrcweir     awt::Point aPoint(aRect.X, aRect.Y);
965cdf0e10cSrcweir 
966cdf0e10cSrcweir     return aPoint;
967cdf0e10cSrcweir }
968cdf0e10cSrcweir 
969cdf0e10cSrcweir 
970cdf0e10cSrcweir 
getLocationOnScreen()971cdf0e10cSrcweir awt::Point SAL_CALL SwAccessibleContext::getLocationOnScreen()
972cdf0e10cSrcweir 		throw (uno::RuntimeException)
973cdf0e10cSrcweir {
974cdf0e10cSrcweir     awt::Rectangle aRect = getBoundsImpl(sal_False);
975cdf0e10cSrcweir 
976cdf0e10cSrcweir     Point aPixPos(aRect.X, aRect.Y);
977cdf0e10cSrcweir 
978cdf0e10cSrcweir     /* getBoundsImpl already checked that GetWindow returns valid pointer. */
979cdf0e10cSrcweir     aPixPos = GetWindow()->OutputToAbsoluteScreenPixel(aPixPos);
980cdf0e10cSrcweir     awt::Point aPoint(aPixPos.X(), aPixPos.Y());
981cdf0e10cSrcweir 
982cdf0e10cSrcweir     return aPoint;
983cdf0e10cSrcweir }
984cdf0e10cSrcweir 
985cdf0e10cSrcweir 
getSize()986cdf0e10cSrcweir awt::Size SAL_CALL SwAccessibleContext::getSize()
987cdf0e10cSrcweir 		throw (uno::RuntimeException)
988cdf0e10cSrcweir {
989cdf0e10cSrcweir     awt::Rectangle aRect = getBoundsImpl(sal_False);
990cdf0e10cSrcweir 	awt::Size aSize( aRect.Width, aRect.Height );
991cdf0e10cSrcweir 
992cdf0e10cSrcweir 	return aSize;
993cdf0e10cSrcweir }
994cdf0e10cSrcweir 
grabFocus()995cdf0e10cSrcweir void SAL_CALL SwAccessibleContext::grabFocus()
996cdf0e10cSrcweir 		throw (uno::RuntimeException)
997cdf0e10cSrcweir {
998cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
999cdf0e10cSrcweir 
1000cdf0e10cSrcweir 	CHECK_FOR_DEFUNC( XAccessibleContext );
1001cdf0e10cSrcweir 
1002cdf0e10cSrcweir 	if( GetFrm()->IsFlyFrm() )
1003cdf0e10cSrcweir 	{
1004cdf0e10cSrcweir 		const SdrObject *pObj =
1005cdf0e10cSrcweir 			static_cast < const SwFlyFrm * >( GetFrm() )->GetVirtDrawObj();
1006cdf0e10cSrcweir 		if( pObj )
1007cdf0e10cSrcweir 			Select( const_cast < SdrObject * >( pObj ), sal_False );
1008cdf0e10cSrcweir 	}
1009cdf0e10cSrcweir 	else
1010cdf0e10cSrcweir 	{
1011cdf0e10cSrcweir 		const SwCntntFrm *pCFrm = 0;
1012cdf0e10cSrcweir 		if( GetFrm()->IsCntntFrm() )
1013cdf0e10cSrcweir 			pCFrm = static_cast< const SwCntntFrm * >( GetFrm() );
1014cdf0e10cSrcweir 		else if( GetFrm()->IsLayoutFrm() )
1015cdf0e10cSrcweir 			pCFrm = static_cast< const SwLayoutFrm * >( GetFrm() )->ContainsCntnt();
1016cdf0e10cSrcweir 
1017cdf0e10cSrcweir 		if( pCFrm && pCFrm->IsTxtFrm() )
1018cdf0e10cSrcweir 		{
1019cdf0e10cSrcweir 			const SwTxtFrm *pTxtFrm = static_cast< const SwTxtFrm * >( pCFrm );
1020cdf0e10cSrcweir 			const SwTxtNode *pTxtNd = pTxtFrm->GetTxtNode();
1021cdf0e10cSrcweir 			if( pTxtNd )
1022cdf0e10cSrcweir 			{
1023cdf0e10cSrcweir 				// create pam for selection
1024cdf0e10cSrcweir 				SwIndex aIndex( const_cast< SwTxtNode * >( pTxtNd ),
1025cdf0e10cSrcweir 								pTxtFrm->GetOfst() );
1026cdf0e10cSrcweir 				SwPosition aStartPos( *pTxtNd, aIndex );
1027cdf0e10cSrcweir 				SwPaM aPaM( aStartPos );
1028cdf0e10cSrcweir 
1029cdf0e10cSrcweir 				// set PaM at cursor shell
1030cdf0e10cSrcweir 				Select( aPaM );
1031cdf0e10cSrcweir 			}
1032cdf0e10cSrcweir 		}
1033cdf0e10cSrcweir 	}
1034cdf0e10cSrcweir }
1035cdf0e10cSrcweir 
1036cdf0e10cSrcweir 
getAccessibleKeyBinding()1037cdf0e10cSrcweir uno::Any SAL_CALL SwAccessibleContext::getAccessibleKeyBinding()
1038cdf0e10cSrcweir 		throw (uno::RuntimeException)
1039cdf0e10cSrcweir {
1040cdf0e10cSrcweir 	// There are no key bindings
1041cdf0e10cSrcweir 	return uno::Any();
1042cdf0e10cSrcweir }
1043cdf0e10cSrcweir 
getForeground()1044cdf0e10cSrcweir sal_Int32 SAL_CALL SwAccessibleContext::getForeground()
1045cdf0e10cSrcweir 		throw (uno::RuntimeException)
1046cdf0e10cSrcweir {
1047ca62e2c2SSteve Yin 	return COL_BLACK;
1048cdf0e10cSrcweir }
1049cdf0e10cSrcweir 
getBackground()1050cdf0e10cSrcweir sal_Int32 SAL_CALL SwAccessibleContext::getBackground()
1051cdf0e10cSrcweir 		throw (uno::RuntimeException)
1052cdf0e10cSrcweir {
1053ca62e2c2SSteve Yin 	return COL_WHITE;
1054cdf0e10cSrcweir }
1055cdf0e10cSrcweir 
1056cdf0e10cSrcweir 
getImplementationName()1057cdf0e10cSrcweir OUString SAL_CALL SwAccessibleContext::getImplementationName()
1058cdf0e10cSrcweir         throw( uno::RuntimeException )
1059cdf0e10cSrcweir {
1060cdf0e10cSrcweir 	ASSERT( !this, "implementation name needs to be overloaded" );
1061cdf0e10cSrcweir 
1062cdf0e10cSrcweir 	THROW_RUNTIME_EXCEPTION( lang::XServiceInfo, "implementation name needs to be overloaded" )
1063cdf0e10cSrcweir }
1064cdf0e10cSrcweir 
1065cdf0e10cSrcweir sal_Bool SAL_CALL
supportsService(const::rtl::OUString &)1066cdf0e10cSrcweir     SwAccessibleContext::supportsService (const ::rtl::OUString& )
1067cdf0e10cSrcweir         throw (uno::RuntimeException)
1068cdf0e10cSrcweir {
1069cdf0e10cSrcweir 	ASSERT( !this, "supports service needs to be overloaded" );
1070cdf0e10cSrcweir 	THROW_RUNTIME_EXCEPTION( lang::XServiceInfo, "supports service needs to be overloaded" )
1071cdf0e10cSrcweir }
1072cdf0e10cSrcweir 
getSupportedServiceNames()1073cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SwAccessibleContext::getSupportedServiceNames()
1074cdf0e10cSrcweir 		throw( uno::RuntimeException )
1075cdf0e10cSrcweir {
1076cdf0e10cSrcweir 	ASSERT( !this, "supported services names needs to be overloaded" );
1077cdf0e10cSrcweir 	THROW_RUNTIME_EXCEPTION( lang::XServiceInfo, "supported services needs to be overloaded" )
1078cdf0e10cSrcweir }
1079cdf0e10cSrcweir 
DisposeShape(const SdrObject * pObj,::accessibility::AccessibleShape * pAccImpl)1080cdf0e10cSrcweir void SwAccessibleContext::DisposeShape( const SdrObject *pObj,
1081cdf0e10cSrcweir 								::accessibility::AccessibleShape *pAccImpl )
1082cdf0e10cSrcweir {
1083cdf0e10cSrcweir 	::vos::ORef< ::accessibility::AccessibleShape > xAccImpl( pAccImpl );
1084cdf0e10cSrcweir 	if( !xAccImpl.isValid() )
1085cdf0e10cSrcweir 		xAccImpl = GetMap()->GetContextImpl( pObj, this, sal_True );
1086cdf0e10cSrcweir 
1087cdf0e10cSrcweir 	AccessibleEventObject aEvent;
1088cdf0e10cSrcweir 	aEvent.EventId = AccessibleEventId::CHILD;
1089cdf0e10cSrcweir 	uno::Reference< XAccessible > xAcc( xAccImpl.getBodyPtr() );
1090cdf0e10cSrcweir 	aEvent.OldValue <<= xAcc;
1091cdf0e10cSrcweir 	FireAccessibleEvent( aEvent );
1092cdf0e10cSrcweir 
1093cdf0e10cSrcweir 	GetMap()->RemoveContext( pObj );
1094cdf0e10cSrcweir 	xAccImpl->dispose();
1095cdf0e10cSrcweir }
1096cdf0e10cSrcweir 
ScrolledInShape(const SdrObject *,::accessibility::AccessibleShape * pAccImpl)1097cdf0e10cSrcweir void SwAccessibleContext::ScrolledInShape( const SdrObject* ,
1098cdf0e10cSrcweir 								::accessibility::AccessibleShape *pAccImpl )
1099cdf0e10cSrcweir {
1100ca62e2c2SSteve Yin 	if(NULL == pAccImpl)
1101ca62e2c2SSteve Yin 	{
1102ca62e2c2SSteve Yin 		return ;
1103ca62e2c2SSteve Yin 	}
1104cdf0e10cSrcweir 	AccessibleEventObject aEvent;
1105cdf0e10cSrcweir 	aEvent.EventId = AccessibleEventId::CHILD;
1106cdf0e10cSrcweir 	uno::Reference< XAccessible > xAcc( pAccImpl );
1107cdf0e10cSrcweir 	aEvent.NewValue <<= xAcc;
1108cdf0e10cSrcweir 	FireAccessibleEvent( aEvent );
1109cdf0e10cSrcweir 
1110cdf0e10cSrcweir 	if( pAccImpl->GetState( AccessibleStateType::FOCUSED ) )
1111cdf0e10cSrcweir 	{
1112cdf0e10cSrcweir 		Window *pWin = GetWindow();
1113cdf0e10cSrcweir 		if( pWin && pWin->HasFocus() )
1114cdf0e10cSrcweir 		{
1115cdf0e10cSrcweir             AccessibleEventObject aStateChangedEvent;
1116cdf0e10cSrcweir             aStateChangedEvent.EventId = AccessibleEventId::STATE_CHANGED;
1117cdf0e10cSrcweir             aStateChangedEvent.NewValue <<= AccessibleStateType::FOCUSED;
1118cdf0e10cSrcweir             aStateChangedEvent.Source = xAcc;
1119cdf0e10cSrcweir 
1120cdf0e10cSrcweir             FireAccessibleEvent( aStateChangedEvent );
1121cdf0e10cSrcweir 		}
1122cdf0e10cSrcweir 	}
1123cdf0e10cSrcweir }
1124cdf0e10cSrcweir 
Dispose(sal_Bool bRecursive)1125cdf0e10cSrcweir void SwAccessibleContext::Dispose( sal_Bool bRecursive )
1126cdf0e10cSrcweir {
1127cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1128cdf0e10cSrcweir 
1129cdf0e10cSrcweir 	ASSERT( GetFrm() && GetMap(), "already disposed" );
1130cdf0e10cSrcweir 	ASSERT( GetMap()->GetVisArea() == GetVisArea(),
1131cdf0e10cSrcweir 				"invalid vis area for dispose" );
1132cdf0e10cSrcweir 
1133cdf0e10cSrcweir 	bDisposing = sal_True;
1134cdf0e10cSrcweir 
1135cdf0e10cSrcweir 	// dispose children
1136cdf0e10cSrcweir 	if( bRecursive )
1137cdf0e10cSrcweir 		DisposeChildren( GetFrm(), bRecursive );
1138cdf0e10cSrcweir 
1139cdf0e10cSrcweir 	// get parent
1140cdf0e10cSrcweir 	uno::Reference< XAccessible > xParent( GetWeakParent() );
1141cdf0e10cSrcweir 	uno::Reference < XAccessibleContext > xThis( this );
1142cdf0e10cSrcweir 
1143cdf0e10cSrcweir 	// send child event at parent
1144cdf0e10cSrcweir 	if( xParent.is() )
1145cdf0e10cSrcweir 	{
1146cdf0e10cSrcweir 		SwAccessibleContext *pAcc = (SwAccessibleContext *)xParent.get();
1147cdf0e10cSrcweir 
1148cdf0e10cSrcweir 		AccessibleEventObject aEvent;
1149cdf0e10cSrcweir 		aEvent.EventId = AccessibleEventId::CHILD;
1150cdf0e10cSrcweir 		aEvent.OldValue <<= xThis;
1151cdf0e10cSrcweir 		pAcc->FireAccessibleEvent( aEvent );
1152cdf0e10cSrcweir 		DBG_MSG_THIS_PARAM( "AccessibleChild (removed)", pAcc, this )
1153cdf0e10cSrcweir 	}
1154cdf0e10cSrcweir 
1155cdf0e10cSrcweir 	// set defunc state (its not required to broadcast a state changed
1156cdf0e10cSrcweir 	// event if the object is diposed afterwards)
1157cdf0e10cSrcweir 	{
1158cdf0e10cSrcweir         vos::OGuard aDefuncStateGuard( aMutex );
1159cdf0e10cSrcweir 		bIsDefuncState = sal_True;
1160cdf0e10cSrcweir 	}
1161cdf0e10cSrcweir 
1162cdf0e10cSrcweir 	// broadcast dispose event
1163cdf0e10cSrcweir 	if ( nClientId )
1164cdf0e10cSrcweir 	{
1165cdf0e10cSrcweir         comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nClientId, *this );
1166cdf0e10cSrcweir 		nClientId =  0;
1167cdf0e10cSrcweir 		DBG_MSG_CD( "dispose" )
1168cdf0e10cSrcweir 	}
1169cdf0e10cSrcweir 
1170cdf0e10cSrcweir     RemoveFrmFromAccessibleMap();
1171cdf0e10cSrcweir 	ClearFrm();
1172cdf0e10cSrcweir 	pMap = 0;
1173cdf0e10cSrcweir 
1174cdf0e10cSrcweir 	bDisposing = sal_False;
1175cdf0e10cSrcweir }
1176cdf0e10cSrcweir 
DisposeChild(const SwAccessibleChild & rChildFrmOrObj,sal_Bool bRecursive)1177cdf0e10cSrcweir void SwAccessibleContext::DisposeChild( const SwAccessibleChild& rChildFrmOrObj,
1178cdf0e10cSrcweir 										sal_Bool bRecursive )
1179cdf0e10cSrcweir {
1180cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1181cdf0e10cSrcweir 
1182cdf0e10cSrcweir     if ( IsShowing( *(GetMap()), rChildFrmOrObj ) ||
1183cdf0e10cSrcweir          rChildFrmOrObj.AlwaysIncludeAsChild() ||
1184cdf0e10cSrcweir          !SwAccessibleChild( GetFrm() ).IsVisibleChildrenOnly() )
1185cdf0e10cSrcweir 	{
1186cdf0e10cSrcweir 		// If the object could have existed before, than there is nothing to do,
1187cdf0e10cSrcweir 		// because no wrapper exists now and therefor no one is interested to
1188cdf0e10cSrcweir 		// get notified of the movement.
1189cdf0e10cSrcweir 		if( rChildFrmOrObj.GetSwFrm() )
1190cdf0e10cSrcweir 		{
1191cdf0e10cSrcweir 			::vos::ORef< SwAccessibleContext > xAccImpl =
1192cdf0e10cSrcweir 					GetMap()->GetContextImpl( rChildFrmOrObj.GetSwFrm(),
1193cdf0e10cSrcweir 											  sal_True );
1194cdf0e10cSrcweir 			xAccImpl->Dispose( bRecursive );
1195cdf0e10cSrcweir 		}
1196cdf0e10cSrcweir         else if ( rChildFrmOrObj.GetDrawObject() )
1197cdf0e10cSrcweir 		{
1198cdf0e10cSrcweir 			::vos::ORef< ::accessibility::AccessibleShape > xAccImpl =
1199cdf0e10cSrcweir                     GetMap()->GetContextImpl( rChildFrmOrObj.GetDrawObject(),
1200cdf0e10cSrcweir 											  this, sal_True );
1201cdf0e10cSrcweir             DisposeShape( rChildFrmOrObj.GetDrawObject(),
1202cdf0e10cSrcweir 						  xAccImpl.getBodyPtr() );
1203cdf0e10cSrcweir 		}
1204cdf0e10cSrcweir         else if ( rChildFrmOrObj.GetWindow() )
1205cdf0e10cSrcweir         {
1206cdf0e10cSrcweir             AccessibleEventObject aEvent;
1207cdf0e10cSrcweir             aEvent.EventId = AccessibleEventId::CHILD;
1208cdf0e10cSrcweir             uno::Reference< XAccessible > xAcc =
1209cdf0e10cSrcweir                                     rChildFrmOrObj.GetWindow()->GetAccessible();
1210cdf0e10cSrcweir             aEvent.OldValue <<= xAcc;
1211cdf0e10cSrcweir             FireAccessibleEvent( aEvent );
1212cdf0e10cSrcweir         }
1213cdf0e10cSrcweir 	}
1214cdf0e10cSrcweir 	else if( bRecursive && rChildFrmOrObj.GetSwFrm() )
1215cdf0e10cSrcweir 		DisposeChildren( rChildFrmOrObj.GetSwFrm(), bRecursive );
1216cdf0e10cSrcweir }
1217cdf0e10cSrcweir 
InvalidatePosOrSize(const SwRect &)1218cdf0e10cSrcweir void SwAccessibleContext::InvalidatePosOrSize( const SwRect& )
1219cdf0e10cSrcweir {
1220cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1221cdf0e10cSrcweir 
1222cdf0e10cSrcweir 	ASSERT( GetFrm() && !GetFrm()->Frm().IsEmpty(), "context should have a size" );
1223cdf0e10cSrcweir 
1224cdf0e10cSrcweir 	sal_Bool bIsOldShowingState;
1225cdf0e10cSrcweir     sal_Bool bIsNewShowingState = IsShowing( *(GetMap()) );
1226cdf0e10cSrcweir 	{
1227cdf0e10cSrcweir         vos::OGuard aShowingStateGuard( aMutex );
1228cdf0e10cSrcweir 		bIsOldShowingState = bIsShowingState;
1229cdf0e10cSrcweir 		bIsShowingState = bIsNewShowingState;
1230cdf0e10cSrcweir 	}
1231cdf0e10cSrcweir 
1232cdf0e10cSrcweir 	if( bIsOldShowingState != bIsNewShowingState )
1233cdf0e10cSrcweir 	{
1234cdf0e10cSrcweir 		FireStateChangedEvent( AccessibleStateType::SHOWING,
1235cdf0e10cSrcweir 							   bIsNewShowingState  );
1236cdf0e10cSrcweir 	}
1237cdf0e10cSrcweir 	else if( bIsNewShowingState )
1238cdf0e10cSrcweir 	{
1239cdf0e10cSrcweir 		// The frame stays visible -> broadcast event
1240cdf0e10cSrcweir 		FireVisibleDataEvent();
1241cdf0e10cSrcweir 	}
1242cdf0e10cSrcweir 
1243cdf0e10cSrcweir     if( !bIsNewShowingState &&
1244cdf0e10cSrcweir         SwAccessibleChild( GetParent() ).IsVisibleChildrenOnly() )
1245cdf0e10cSrcweir 	{
1246cdf0e10cSrcweir 		// The frame is now invisible -> dispose it
1247ca62e2c2SSteve Yin 		//Remove
1248ca62e2c2SSteve Yin 		//Dispose( sal_True );
1249cdf0e10cSrcweir 	}
1250cdf0e10cSrcweir 	else
1251cdf0e10cSrcweir 	{
1252cdf0e10cSrcweir 		_InvalidateContent( sal_True );
1253cdf0e10cSrcweir 	}
1254cdf0e10cSrcweir }
1255cdf0e10cSrcweir 
InvalidateChildPosOrSize(const SwAccessibleChild & rChildFrmOrObj,const SwRect & rOldFrm)1256cdf0e10cSrcweir void SwAccessibleContext::InvalidateChildPosOrSize(
1257cdf0e10cSrcweir                     const SwAccessibleChild& rChildFrmOrObj,
1258cdf0e10cSrcweir 					const SwRect& rOldFrm )
1259cdf0e10cSrcweir {
1260cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1261cdf0e10cSrcweir 
1262cdf0e10cSrcweir 	ASSERT( !rChildFrmOrObj.GetSwFrm() ||
1263cdf0e10cSrcweir 			!rChildFrmOrObj.GetSwFrm()->Frm().IsEmpty(),
1264cdf0e10cSrcweir 			"child context should have a size" );
1265cdf0e10cSrcweir 
1266cdf0e10cSrcweir     if ( rChildFrmOrObj.AlwaysIncludeAsChild() )
1267cdf0e10cSrcweir     {
1268cdf0e10cSrcweir         // nothing to do;
1269cdf0e10cSrcweir         return;
1270cdf0e10cSrcweir     }
1271cdf0e10cSrcweir 
1272cdf0e10cSrcweir     const bool bVisibleChildrenOnly = SwAccessibleChild( GetFrm() ).IsVisibleChildrenOnly();
1273cdf0e10cSrcweir     const bool bNew = rOldFrm.IsEmpty() ||
1274cdf0e10cSrcweir                      ( rOldFrm.Left() == 0 && rOldFrm.Top() == 0 );
1275cdf0e10cSrcweir     if( IsShowing( *(GetMap()), rChildFrmOrObj ) )
1276cdf0e10cSrcweir 	{
1277cdf0e10cSrcweir 		// If the object could have existed before, than there is nothing to do,
1278cdf0e10cSrcweir 		// because no wrapper exists now and therefor no one is interested to
1279cdf0e10cSrcweir 		// get notified of the movement.
1280cdf0e10cSrcweir         if( bNew || (bVisibleChildrenOnly && !IsShowing( rOldFrm )) )
1281cdf0e10cSrcweir 		{
1282cdf0e10cSrcweir 			if( rChildFrmOrObj.GetSwFrm() )
1283cdf0e10cSrcweir 			{
1284cdf0e10cSrcweir 				// The frame becomes visible. A child event must be send.
1285cdf0e10cSrcweir 				::vos::ORef< SwAccessibleContext > xAccImpl =
1286cdf0e10cSrcweir 					GetMap()->GetContextImpl( rChildFrmOrObj.GetSwFrm(),
1287cdf0e10cSrcweir 											  sal_True );
1288cdf0e10cSrcweir 				xAccImpl->ScrolledIn();
1289cdf0e10cSrcweir 			}
1290cdf0e10cSrcweir             else if ( rChildFrmOrObj.GetDrawObject() )
1291cdf0e10cSrcweir 			{
1292cdf0e10cSrcweir 				::vos::ORef< ::accessibility::AccessibleShape > xAccImpl =
1293cdf0e10cSrcweir                         GetMap()->GetContextImpl( rChildFrmOrObj.GetDrawObject(),
1294cdf0e10cSrcweir 												  this, sal_True );
1295cdf0e10cSrcweir                 // --> OD 2004-11-29 #i37790#
1296cdf0e10cSrcweir                 if ( xAccImpl.isValid() )
1297cdf0e10cSrcweir                 {
1298cdf0e10cSrcweir                     ScrolledInShape( rChildFrmOrObj.GetDrawObject(),
1299cdf0e10cSrcweir                                      xAccImpl.getBodyPtr() );
1300cdf0e10cSrcweir                 }
1301cdf0e10cSrcweir                 else
1302cdf0e10cSrcweir                 {
1303cdf0e10cSrcweir                     ASSERT( false ,
1304cdf0e10cSrcweir                             "<SwAccessibleContext::InvalidateChildPosOrSize(..)> - no accessible shape found." );
1305cdf0e10cSrcweir                 }
1306cdf0e10cSrcweir                 // <--
1307cdf0e10cSrcweir 			}
1308cdf0e10cSrcweir             else if ( rChildFrmOrObj.GetWindow() )
1309cdf0e10cSrcweir             {
1310cdf0e10cSrcweir                 AccessibleEventObject aEvent;
1311cdf0e10cSrcweir                 aEvent.EventId = AccessibleEventId::CHILD;
1312cdf0e10cSrcweir                 aEvent.NewValue <<= (rChildFrmOrObj.GetWindow()->GetAccessible());
1313cdf0e10cSrcweir                 FireAccessibleEvent( aEvent );
1314cdf0e10cSrcweir             }
1315cdf0e10cSrcweir 		}
1316cdf0e10cSrcweir 	}
1317cdf0e10cSrcweir 	else
1318cdf0e10cSrcweir 	{
1319cdf0e10cSrcweir 		// If the frame was visible before, than a child event for the parent
1320cdf0e10cSrcweir 		// needs to be send. However, there is no wrapper existing, and so
1321cdf0e10cSrcweir 		// no notifications for grandchildren are required. If the are
1322cdf0e10cSrcweir 		// grandgrandchildren, they would be notified by the layout.
1323cdf0e10cSrcweir         if( bVisibleChildrenOnly &&
1324cdf0e10cSrcweir 			!bNew && IsShowing( rOldFrm ) )
1325cdf0e10cSrcweir 		{
1326cdf0e10cSrcweir 			if( rChildFrmOrObj.GetSwFrm() )
1327cdf0e10cSrcweir 			{
1328cdf0e10cSrcweir 				::vos::ORef< SwAccessibleContext > xAccImpl =
1329cdf0e10cSrcweir 					GetMap()->GetContextImpl( rChildFrmOrObj.GetSwFrm(),
1330cdf0e10cSrcweir 											  sal_True );
1331cdf0e10cSrcweir 				xAccImpl->SetParent( this );
1332cdf0e10cSrcweir 				xAccImpl->Dispose( sal_True );
1333cdf0e10cSrcweir 			}
1334cdf0e10cSrcweir             else if ( rChildFrmOrObj.GetDrawObject() )
1335cdf0e10cSrcweir 			{
1336cdf0e10cSrcweir 				::vos::ORef< ::accessibility::AccessibleShape > xAccImpl =
1337cdf0e10cSrcweir                         GetMap()->GetContextImpl( rChildFrmOrObj.GetDrawObject(),
1338cdf0e10cSrcweir 												  this, sal_True );
1339cdf0e10cSrcweir                 DisposeShape( rChildFrmOrObj.GetDrawObject(),
1340cdf0e10cSrcweir 						  xAccImpl.getBodyPtr() );
1341cdf0e10cSrcweir 			}
1342cdf0e10cSrcweir             else if ( rChildFrmOrObj.GetWindow() )
1343cdf0e10cSrcweir             {
1344cdf0e10cSrcweir                 ASSERT( false,
1345cdf0e10cSrcweir                         "<SwAccessibleContext::InvalidateChildPosOrSize(..)> - not expected to handle dispose of child of type <Window>." );
1346cdf0e10cSrcweir             }
1347cdf0e10cSrcweir 		}
1348cdf0e10cSrcweir 	}
1349cdf0e10cSrcweir }
1350cdf0e10cSrcweir 
InvalidateContent()1351cdf0e10cSrcweir void SwAccessibleContext::InvalidateContent()
1352cdf0e10cSrcweir {
1353cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1354cdf0e10cSrcweir 
1355cdf0e10cSrcweir 	_InvalidateContent( sal_False );
1356cdf0e10cSrcweir }
1357cdf0e10cSrcweir 
InvalidateCursorPos()1358cdf0e10cSrcweir void SwAccessibleContext::InvalidateCursorPos()
1359cdf0e10cSrcweir {
1360cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1361cdf0e10cSrcweir 
1362cdf0e10cSrcweir 	_InvalidateCursorPos();
1363cdf0e10cSrcweir }
1364cdf0e10cSrcweir 
InvalidateFocus()1365cdf0e10cSrcweir void SwAccessibleContext::InvalidateFocus()
1366cdf0e10cSrcweir {
1367cdf0e10cSrcweir 	vos::OGuard aGuard(Application::GetSolarMutex());
1368cdf0e10cSrcweir 
1369cdf0e10cSrcweir 	_InvalidateFocus();
1370cdf0e10cSrcweir }
1371cdf0e10cSrcweir 
1372cdf0e10cSrcweir // --> OD 2005-12-12 #i27301# - use new type definition for <_nStates>
InvalidateStates(tAccessibleStates _nStates)1373cdf0e10cSrcweir void SwAccessibleContext::InvalidateStates( tAccessibleStates _nStates )
1374cdf0e10cSrcweir {
1375cdf0e10cSrcweir 	if( GetMap() )
1376cdf0e10cSrcweir 	{
1377cdf0e10cSrcweir 		ViewShell *pVSh = GetMap()->GetShell();
1378cdf0e10cSrcweir 		if( pVSh )
1379cdf0e10cSrcweir 		{
1380cdf0e10cSrcweir             if( (_nStates & ACC_STATE_EDITABLE) != 0 )
1381cdf0e10cSrcweir 			{
1382cdf0e10cSrcweir 				sal_Bool bIsOldEditableState;
1383cdf0e10cSrcweir 				sal_Bool bIsNewEditableState = IsEditable( pVSh );
1384cdf0e10cSrcweir 				{
1385cdf0e10cSrcweir 					vos::OGuard aGuard( aMutex );
1386cdf0e10cSrcweir 					bIsOldEditableState = bIsEditableState;
1387cdf0e10cSrcweir 					bIsEditableState = bIsNewEditableState;
1388cdf0e10cSrcweir 				}
1389cdf0e10cSrcweir 
1390cdf0e10cSrcweir 				if( bIsOldEditableState != bIsNewEditableState )
1391cdf0e10cSrcweir 					FireStateChangedEvent( AccessibleStateType::EDITABLE,
1392cdf0e10cSrcweir 										   bIsNewEditableState  );
1393cdf0e10cSrcweir 			}
1394cdf0e10cSrcweir             if( (_nStates & ACC_STATE_OPAQUE) != 0 )
1395cdf0e10cSrcweir 			{
1396cdf0e10cSrcweir 				sal_Bool bIsOldOpaqueState;
1397cdf0e10cSrcweir 				sal_Bool bIsNewOpaqueState = IsOpaque( pVSh );
1398cdf0e10cSrcweir 				{
1399cdf0e10cSrcweir 					vos::OGuard aGuard( aMutex );
1400cdf0e10cSrcweir 					bIsOldOpaqueState = bIsOpaqueState;
1401cdf0e10cSrcweir 					bIsOpaqueState = bIsNewOpaqueState;
1402cdf0e10cSrcweir 				}
1403cdf0e10cSrcweir 
1404cdf0e10cSrcweir 				if( bIsOldOpaqueState != bIsNewOpaqueState )
1405cdf0e10cSrcweir 					FireStateChangedEvent( AccessibleStateType::OPAQUE,
1406cdf0e10cSrcweir 										   bIsNewOpaqueState  );
1407cdf0e10cSrcweir 			}
1408cdf0e10cSrcweir 		}
1409cdf0e10cSrcweir 
1410cdf0e10cSrcweir         InvalidateChildrenStates( GetFrm(), _nStates );
1411cdf0e10cSrcweir 	}
1412cdf0e10cSrcweir }
1413cdf0e10cSrcweir // <--
1414cdf0e10cSrcweir 
InvalidateRelation(sal_uInt16 nType)1415cdf0e10cSrcweir void SwAccessibleContext::InvalidateRelation( sal_uInt16 nType )
1416cdf0e10cSrcweir {
1417cdf0e10cSrcweir 	AccessibleEventObject aEvent;
1418cdf0e10cSrcweir 	aEvent.EventId = nType;
1419cdf0e10cSrcweir 
1420cdf0e10cSrcweir     FireAccessibleEvent( aEvent );
1421cdf0e10cSrcweir }
1422cdf0e10cSrcweir 
1423cdf0e10cSrcweir /** text selection has changed
1424cdf0e10cSrcweir 
1425cdf0e10cSrcweir     OD 2005-12-14 #i27301#
1426cdf0e10cSrcweir 
1427cdf0e10cSrcweir     @author OD
1428cdf0e10cSrcweir */
InvalidateTextSelection()1429cdf0e10cSrcweir void SwAccessibleContext::InvalidateTextSelection()
1430cdf0e10cSrcweir {
1431cdf0e10cSrcweir     AccessibleEventObject aEvent;
1432cdf0e10cSrcweir     aEvent.EventId = AccessibleEventId::TEXT_SELECTION_CHANGED;
1433cdf0e10cSrcweir 
1434cdf0e10cSrcweir     FireAccessibleEvent( aEvent );
1435cdf0e10cSrcweir }
1436cdf0e10cSrcweir 
1437cdf0e10cSrcweir /** attributes has changed
1438cdf0e10cSrcweir 
1439cdf0e10cSrcweir     OD 2009-01-06 #i88069#
1440cdf0e10cSrcweir 
1441cdf0e10cSrcweir     @author OD
1442cdf0e10cSrcweir */
InvalidateAttr()1443cdf0e10cSrcweir void SwAccessibleContext::InvalidateAttr()
1444cdf0e10cSrcweir {
1445cdf0e10cSrcweir     AccessibleEventObject aEvent;
1446cdf0e10cSrcweir     aEvent.EventId = AccessibleEventId::TEXT_ATTRIBUTE_CHANGED;
1447cdf0e10cSrcweir 
1448cdf0e10cSrcweir     FireAccessibleEvent( aEvent );
1449cdf0e10cSrcweir }
1450cdf0e10cSrcweir 
HasCursor()1451cdf0e10cSrcweir sal_Bool SwAccessibleContext::HasCursor()
1452cdf0e10cSrcweir {
1453cdf0e10cSrcweir 	return sal_False;
1454cdf0e10cSrcweir }
1455cdf0e10cSrcweir 
Select(SwPaM * pPaM,SdrObject * pObj,sal_Bool bAdd)1456cdf0e10cSrcweir sal_Bool SwAccessibleContext::Select( SwPaM *pPaM, SdrObject *pObj,
1457cdf0e10cSrcweir 									  sal_Bool bAdd )
1458cdf0e10cSrcweir {
1459cdf0e10cSrcweir     SwCrsrShell* pCrsrShell = GetCrsrShell();
1460cdf0e10cSrcweir 	if( !pCrsrShell )
1461cdf0e10cSrcweir 		return sal_False;
1462cdf0e10cSrcweir 
1463cdf0e10cSrcweir     SwFEShell* pFEShell = pCrsrShell->ISA( SwFEShell )
1464cdf0e10cSrcweir 								? static_cast<SwFEShell*>( pCrsrShell )
1465cdf0e10cSrcweir 								: 0;
1466cdf0e10cSrcweir 	// Get rid of activated OLE object
1467cdf0e10cSrcweir 	if( pFEShell )
1468cdf0e10cSrcweir 		pFEShell->FinishOLEObj();
1469cdf0e10cSrcweir 
1470cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
1471cdf0e10cSrcweir 	if( pObj )
1472cdf0e10cSrcweir 	{
1473cdf0e10cSrcweir 		if( pFEShell )
1474cdf0e10cSrcweir 		{
1475cdf0e10cSrcweir 			Point aDummy;
1476cdf0e10cSrcweir 			sal_uInt8 nFlags = bAdd ? SW_ADD_SELECT : 0;
1477cdf0e10cSrcweir 			pFEShell->SelectObj( aDummy, nFlags, pObj );
1478cdf0e10cSrcweir 			bRet = sal_True;
1479cdf0e10cSrcweir 		}
1480cdf0e10cSrcweir 	}
1481cdf0e10cSrcweir 	else if( pPaM )
1482cdf0e10cSrcweir 	{
1483cdf0e10cSrcweir 		// Get rid of frame selection. If there is one, make text cursor
1484cdf0e10cSrcweir 		// visible again.
1485cdf0e10cSrcweir 		sal_Bool bCallShowCrsr = sal_False;
1486cdf0e10cSrcweir 		if( pFEShell && (pFEShell->IsFrmSelected() ||
1487cdf0e10cSrcweir 						 pFEShell->IsObjSelected()) )
1488cdf0e10cSrcweir 		{
1489cdf0e10cSrcweir 			Point aPt( LONG_MIN, LONG_MIN );
1490cdf0e10cSrcweir 			pFEShell->SelectObj( aPt, 0 );
1491cdf0e10cSrcweir 			bCallShowCrsr = sal_True;
1492cdf0e10cSrcweir 		}
1493cdf0e10cSrcweir         pCrsrShell->KillPams();
1494cdf0e10cSrcweir         pCrsrShell->SetSelection( *pPaM );
1495cdf0e10cSrcweir 		if( bCallShowCrsr )
1496cdf0e10cSrcweir 			pCrsrShell->ShowCrsr();
1497cdf0e10cSrcweir 		bRet = sal_True;
1498cdf0e10cSrcweir 	}
1499cdf0e10cSrcweir 
1500cdf0e10cSrcweir 	return bRet;
1501cdf0e10cSrcweir }
1502cdf0e10cSrcweir 
GetResource(sal_uInt16 nResId,const OUString * pArg1,const OUString * pArg2)1503cdf0e10cSrcweir OUString SwAccessibleContext::GetResource( sal_uInt16 nResId,
1504cdf0e10cSrcweir 										   const OUString *pArg1,
1505cdf0e10cSrcweir 										   const OUString *pArg2 )
1506cdf0e10cSrcweir {
1507cdf0e10cSrcweir 	String sStr;
1508cdf0e10cSrcweir 	{
1509cdf0e10cSrcweir 		vos::OGuard aGuard(Application::GetSolarMutex());
1510cdf0e10cSrcweir 
1511cdf0e10cSrcweir 		sStr = SW_RES( nResId );
1512cdf0e10cSrcweir 	}
1513cdf0e10cSrcweir 
1514cdf0e10cSrcweir 	if( pArg1 )
1515cdf0e10cSrcweir 	{
1516cdf0e10cSrcweir 		sStr.SearchAndReplace( String::CreateFromAscii(
1517cdf0e10cSrcweir 									RTL_CONSTASCII_STRINGPARAM( "$(ARG1)" )),
1518cdf0e10cSrcweir 							   String( *pArg1 ) );
1519cdf0e10cSrcweir 	}
1520cdf0e10cSrcweir 	if( pArg2 )
1521cdf0e10cSrcweir 	{
1522cdf0e10cSrcweir 		sStr.SearchAndReplace( String::CreateFromAscii(
1523cdf0e10cSrcweir 									RTL_CONSTASCII_STRINGPARAM( "$(ARG2)" )),
1524cdf0e10cSrcweir 							   String( *pArg2 ) );
1525cdf0e10cSrcweir 	}
1526cdf0e10cSrcweir 
1527cdf0e10cSrcweir 	return OUString( sStr );
1528cdf0e10cSrcweir }
1529cdf0e10cSrcweir 
RemoveFrmFromAccessibleMap()1530cdf0e10cSrcweir void SwAccessibleContext::RemoveFrmFromAccessibleMap()
1531cdf0e10cSrcweir {
1532cdf0e10cSrcweir     if( bRegisteredAtAccessibleMap && GetFrm() && GetMap() )
1533cdf0e10cSrcweir         GetMap()->RemoveContext( GetFrm() );
1534cdf0e10cSrcweir }
1535cdf0e10cSrcweir 
HasAdditionalAccessibleChildren()1536cdf0e10cSrcweir bool SwAccessibleContext::HasAdditionalAccessibleChildren()
1537cdf0e10cSrcweir {
1538cdf0e10cSrcweir     bool bRet( false );
1539cdf0e10cSrcweir 
1540cdf0e10cSrcweir     if ( GetFrm()->IsTxtFrm() )
1541cdf0e10cSrcweir     {
1542cdf0e10cSrcweir         SwPostItMgr* pPostItMgr = GetMap()->GetShell()->GetPostItMgr();
1543cdf0e10cSrcweir         if ( pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() )
1544cdf0e10cSrcweir         {
1545cdf0e10cSrcweir             bRet = pPostItMgr->HasFrmConnectedSidebarWins( *(GetFrm()) );
1546cdf0e10cSrcweir         }
1547cdf0e10cSrcweir     }
1548cdf0e10cSrcweir 
1549cdf0e10cSrcweir     return bRet;
1550cdf0e10cSrcweir }
1551cdf0e10cSrcweir /** get additional accessible child by index
1552cdf0e10cSrcweir 
1553cdf0e10cSrcweir     OD 2010-01-27 #i88070#
1554cdf0e10cSrcweir 
1555cdf0e10cSrcweir     @author OD
1556cdf0e10cSrcweir */
GetAdditionalAccessibleChild(const sal_Int32 nIndex)1557cdf0e10cSrcweir Window* SwAccessibleContext::GetAdditionalAccessibleChild( const sal_Int32 nIndex )
1558cdf0e10cSrcweir {
1559cdf0e10cSrcweir     Window* pAdditionalAccessibleChild( 0 );
1560cdf0e10cSrcweir 
1561cdf0e10cSrcweir     if ( GetFrm()->IsTxtFrm() )
1562cdf0e10cSrcweir     {
1563cdf0e10cSrcweir         SwPostItMgr* pPostItMgr = GetMap()->GetShell()->GetPostItMgr();
1564cdf0e10cSrcweir         if ( pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() )
1565cdf0e10cSrcweir         {
1566cdf0e10cSrcweir             pAdditionalAccessibleChild =
1567cdf0e10cSrcweir                     pPostItMgr->GetSidebarWinForFrmByIndex( *(GetFrm()), nIndex );
1568cdf0e10cSrcweir         }
1569cdf0e10cSrcweir     }
1570cdf0e10cSrcweir 
1571cdf0e10cSrcweir     return pAdditionalAccessibleChild;
1572cdf0e10cSrcweir }
1573cdf0e10cSrcweir 
1574cdf0e10cSrcweir /** get all additional accessible children
1575cdf0e10cSrcweir 
1576cdf0e10cSrcweir     OD 2010-01-27 #i88070#
1577cdf0e10cSrcweir 
1578cdf0e10cSrcweir     @author OD
1579cdf0e10cSrcweir */
GetAdditionalAccessibleChildren(std::vector<Window * > * pChildren)1580cdf0e10cSrcweir void SwAccessibleContext::GetAdditionalAccessibleChildren( std::vector< Window* >* pChildren )
1581cdf0e10cSrcweir {
1582cdf0e10cSrcweir     if ( GetFrm()->IsTxtFrm() )
1583cdf0e10cSrcweir     {
1584cdf0e10cSrcweir         SwPostItMgr* pPostItMgr = GetMap()->GetShell()->GetPostItMgr();
1585cdf0e10cSrcweir         if ( pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() )
1586cdf0e10cSrcweir         {
1587cdf0e10cSrcweir             pPostItMgr->GetAllSidebarWinForFrm( *(GetFrm()), pChildren );
1588cdf0e10cSrcweir         }
1589cdf0e10cSrcweir     }
1590cdf0e10cSrcweir }
1591cdf0e10cSrcweir 
1592cdf0e10cSrcweir #if (OSL_DEBUG_LEVEL > 1) && defined TEST_MIB
lcl_SwAccessibleContext_DbgMsg(SwAccessibleContext * pThisAcc,const char * pMsg,SwAccessibleContext * pChildAcc,sal_Bool bConstrDestr)1593cdf0e10cSrcweir void lcl_SwAccessibleContext_DbgMsg( SwAccessibleContext *pThisAcc,
1594cdf0e10cSrcweir 									 const char *pMsg,
1595cdf0e10cSrcweir 								     SwAccessibleContext *pChildAcc,
1596cdf0e10cSrcweir 								  	 sal_Bool bConstrDestr )
1597cdf0e10cSrcweir {
1598cdf0e10cSrcweir 	static SvFileStream aStrm( String::CreateFromAscii("j:\\acc.log"),
1599cdf0e10cSrcweir 					STREAM_WRITE|STREAM_TRUNC|STREAM_SHARE_DENYNONE	);
1600cdf0e10cSrcweir 	ByteString aName( String(pThisAcc->GetName()),
1601cdf0e10cSrcweir 					  RTL_TEXTENCODING_ISO_8859_1 );
1602cdf0e10cSrcweir 	if( aName.Len() )
1603cdf0e10cSrcweir 	{
1604cdf0e10cSrcweir 		aStrm << aName.GetBuffer()
1605cdf0e10cSrcweir 			  << ": ";
1606cdf0e10cSrcweir 	}
1607cdf0e10cSrcweir 	aStrm << pMsg;
1608cdf0e10cSrcweir 	if( pChildAcc )
1609cdf0e10cSrcweir 	{
1610cdf0e10cSrcweir 		ByteString aChild( String(pChildAcc->GetName()),
1611cdf0e10cSrcweir 						   RTL_TEXTENCODING_ISO_8859_1 );
1612cdf0e10cSrcweir 		aStrm << ": "
1613cdf0e10cSrcweir 		      << aChild.GetBuffer();
1614cdf0e10cSrcweir 	}
1615cdf0e10cSrcweir 	aStrm << "\r\n    (";
1616cdf0e10cSrcweir 
1617cdf0e10cSrcweir 	if( !bConstrDestr )
1618cdf0e10cSrcweir 	{
1619cdf0e10cSrcweir 		ByteString aDesc( String(pThisAcc->getAccessibleDescription()),
1620cdf0e10cSrcweir 						   RTL_TEXTENCODING_ISO_8859_1 );
1621cdf0e10cSrcweir 		aStrm << aDesc.GetBuffer()
1622cdf0e10cSrcweir 			  << ", ";
1623cdf0e10cSrcweir 	}
1624cdf0e10cSrcweir 
1625cdf0e10cSrcweir 	Rectangle aVisArea( pThisAcc->GetVisArea() );
1626cdf0e10cSrcweir 	aStrm << "VA: "
1627cdf0e10cSrcweir 		  << ByteString::CreateFromInt32( aVisArea.Left() ).GetBuffer()
1628cdf0e10cSrcweir 		  << ","
1629cdf0e10cSrcweir 		  << ByteString::CreateFromInt32( aVisArea.Top() ).GetBuffer()
1630cdf0e10cSrcweir 		  << ","
1631cdf0e10cSrcweir 		  << ByteString::CreateFromInt32( aVisArea.GetWidth() ).GetBuffer()
1632cdf0e10cSrcweir 		  << ","
1633cdf0e10cSrcweir 		  << ByteString::CreateFromInt32( aVisArea.GetHeight() ).GetBuffer();
1634cdf0e10cSrcweir 
1635cdf0e10cSrcweir 	if( pThisAcc->GetFrm() )
1636cdf0e10cSrcweir 	{
1637cdf0e10cSrcweir 		Rectangle aBounds( pThisAcc->GetBounds( pThisAcc->GetFrm() ) );
1638cdf0e10cSrcweir 		aStrm << ", BB: "
1639cdf0e10cSrcweir 			  << ByteString::CreateFromInt32( aBounds.Left() ).GetBuffer()
1640cdf0e10cSrcweir 			  << ","
1641cdf0e10cSrcweir 			  << ByteString::CreateFromInt32( aBounds.Top() ).GetBuffer()
1642cdf0e10cSrcweir 			  << ","
1643cdf0e10cSrcweir 			  << ByteString::CreateFromInt32( aBounds.GetWidth() ).GetBuffer()
1644cdf0e10cSrcweir 			  << ","
1645cdf0e10cSrcweir 			  << ByteString::CreateFromInt32( aBounds.GetHeight() ).GetBuffer()
1646cdf0e10cSrcweir 			  << ")\r\n";
1647cdf0e10cSrcweir 	}
1648cdf0e10cSrcweir 
1649cdf0e10cSrcweir 	aStrm.Flush();
1650cdf0e10cSrcweir }
1651cdf0e10cSrcweir #endif
SetSelectedState(sal_Bool bSeleted)1652ca62e2c2SSteve Yin sal_Bool SwAccessibleContext::SetSelectedState(sal_Bool bSeleted)
1653ca62e2c2SSteve Yin {
1654ca62e2c2SSteve Yin 	if(bIsSeletedInDoc != bSeleted)
1655ca62e2c2SSteve Yin 	{
1656ca62e2c2SSteve Yin 		bIsSeletedInDoc = bSeleted;
1657ca62e2c2SSteve Yin 		FireStateChangedEvent( AccessibleStateType::SELECTED, bSeleted );
1658ca62e2c2SSteve Yin 		return sal_True;
1659ca62e2c2SSteve Yin 	}
1660ca62e2c2SSteve Yin 	return sal_False;
1661ca62e2c2SSteve Yin };
1662