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 #include "precompiled_sdext.hxx"
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include "PresenterAccessibility.hxx"
31*cdf0e10cSrcweir #include "PresenterTextView.hxx"
32*cdf0e10cSrcweir #include "PresenterConfigurationAccess.hxx"
33*cdf0e10cSrcweir #include "PresenterNotesView.hxx"
34*cdf0e10cSrcweir #include "PresenterPaneBase.hxx"
35*cdf0e10cSrcweir #include "PresenterPaneContainer.hxx"
36*cdf0e10cSrcweir #include "PresenterPaneFactory.hxx"
37*cdf0e10cSrcweir #include "PresenterViewFactory.hxx"
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
41*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleContext.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleEditableText.hpp>
45*cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
46*cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessibleText.hpp>
47*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/ResourceId.hpp>
48*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XPane.hpp>
49*cdf0e10cSrcweir #include <com/sun/star/drawing/framework/XView.hpp>
50*cdf0e10cSrcweir #include <cppuhelper/compbase1.hxx>
51*cdf0e10cSrcweir #include <cppuhelper/compbase5.hxx>
52*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
53*cdf0e10cSrcweir #include <boost/bind.hpp>
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir using namespace ::com::sun::star;
56*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
57*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
58*cdf0e10cSrcweir using namespace ::com::sun::star::drawing::framework;
59*cdf0e10cSrcweir using ::rtl::OUString;
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir #define A2S(s) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)))
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir #define VERBOSE
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir //===== PresenterAccessibleObject =============================================
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir namespace sdext { namespace presenter {
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir namespace {
70*cdf0e10cSrcweir     typedef ::cppu::WeakComponentImplHelper5 <
71*cdf0e10cSrcweir         cssa::XAccessible,
72*cdf0e10cSrcweir         cssa::XAccessibleContext,
73*cdf0e10cSrcweir         cssa::XAccessibleComponent,
74*cdf0e10cSrcweir         cssa::XAccessibleEventBroadcaster,
75*cdf0e10cSrcweir         css::awt::XWindowListener
76*cdf0e10cSrcweir     > PresenterAccessibleObjectInterfaceBase;
77*cdf0e10cSrcweir }
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir class PresenterAccessible::AccessibleObject
80*cdf0e10cSrcweir     : public ::cppu::BaseMutex,
81*cdf0e10cSrcweir       public PresenterAccessibleObjectInterfaceBase
82*cdf0e10cSrcweir {
83*cdf0e10cSrcweir public:
84*cdf0e10cSrcweir     AccessibleObject (
85*cdf0e10cSrcweir         const css::lang::Locale aLocale,
86*cdf0e10cSrcweir         const sal_Int16 nRole,
87*cdf0e10cSrcweir         const ::rtl::OUString& rsName);
88*cdf0e10cSrcweir     void LateInitialization (void);
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir     virtual ~AccessibleObject (void);
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir     virtual void SetWindow (
93*cdf0e10cSrcweir         const cssu::Reference<css::awt::XWindow>& rxContentWindow,
94*cdf0e10cSrcweir         const cssu::Reference<css::awt::XWindow>& rxBorderWindow);
95*cdf0e10cSrcweir     void SetAccessibleParent (const cssu::Reference<cssa::XAccessible>& rxAccessibleParent);
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir     virtual void SAL_CALL disposing (void);
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir     void NotifyCurrentSlideChange (const sal_Int32 nCurrentSlideIndex);
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir     void AddChild (const ::rtl::Reference<AccessibleObject>& rpChild);
102*cdf0e10cSrcweir     void RemoveChild (const ::rtl::Reference<AccessibleObject>& rpChild);
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir     void SetIsFocused (const bool bIsFocused);
105*cdf0e10cSrcweir     void SetAccessibleName (const ::rtl::OUString& rsName);
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir     void FireAccessibleEvent (
108*cdf0e10cSrcweir         const sal_Int16 nEventId,
109*cdf0e10cSrcweir         const cssu::Any& rOldValue,
110*cdf0e10cSrcweir         const cssu::Any& rNewValue);
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir     void UpdateStateSet (void);
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir     //----- XAccessible -------------------------------------------------------
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir     virtual cssu::Reference<cssa::XAccessibleContext> SAL_CALL
118*cdf0e10cSrcweir         getAccessibleContext (void)
119*cdf0e10cSrcweir         throw (cssu::RuntimeException);
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir     //-----  XAccessibleContext  ----------------------------------------------
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getAccessibleChildCount (void)
125*cdf0e10cSrcweir         throw (cssu::RuntimeException);
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir     virtual cssu::Reference< cssa::XAccessible> SAL_CALL
128*cdf0e10cSrcweir         getAccessibleChild (sal_Int32 nIndex)
129*cdf0e10cSrcweir         throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException);
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir 	virtual cssu::Reference< cssa::XAccessible> SAL_CALL getAccessibleParent (void)
132*cdf0e10cSrcweir         throw (cssu::RuntimeException);
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir 	virtual	sal_Int32 SAL_CALL getAccessibleIndexInParent (void)
135*cdf0e10cSrcweir         throw (cssu::RuntimeException);
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir 	virtual sal_Int16 SAL_CALL getAccessibleRole (void)
138*cdf0e10cSrcweir         throw (cssu::RuntimeException);
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL getAccessibleDescription (void)
141*cdf0e10cSrcweir         throw (cssu::RuntimeException);
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL getAccessibleName (void)
144*cdf0e10cSrcweir         throw (cssu::RuntimeException);
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir 	virtual cssu::Reference<cssa::XAccessibleRelationSet> SAL_CALL
147*cdf0e10cSrcweir     	getAccessibleRelationSet (void)
148*cdf0e10cSrcweir         throw (cssu::RuntimeException);
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir 	virtual cssu::Reference<cssa::XAccessibleStateSet> SAL_CALL
151*cdf0e10cSrcweir     	getAccessibleStateSet (void)
152*cdf0e10cSrcweir         throw (cssu::RuntimeException);
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir 	virtual css::lang::Locale SAL_CALL getLocale (void)
155*cdf0e10cSrcweir 		throw (cssu::RuntimeException,
156*cdf0e10cSrcweir 			cssa::IllegalAccessibleComponentStateException);
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir     //-----  XAccessibleComponent  --------------------------------------------
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL containsPoint (
162*cdf0e10cSrcweir         const css::awt::Point& aPoint)
163*cdf0e10cSrcweir         throw (cssu::RuntimeException);
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir     virtual cssu::Reference<cssa::XAccessible> SAL_CALL
166*cdf0e10cSrcweir         getAccessibleAtPoint (
167*cdf0e10cSrcweir             const css::awt::Point& aPoint)
168*cdf0e10cSrcweir         throw (cssu::RuntimeException);
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir     virtual css::awt::Rectangle SAL_CALL getBounds (void)
171*cdf0e10cSrcweir         throw (cssu::RuntimeException);
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir     virtual css::awt::Point SAL_CALL getLocation (void)
174*cdf0e10cSrcweir         throw (cssu::RuntimeException);
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir     virtual css::awt::Point SAL_CALL getLocationOnScreen (void)
177*cdf0e10cSrcweir         throw (cssu::RuntimeException);
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir     virtual css::awt::Size SAL_CALL getSize (void)
180*cdf0e10cSrcweir         throw (cssu::RuntimeException);
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir     virtual void SAL_CALL grabFocus (void)
183*cdf0e10cSrcweir         throw (cssu::RuntimeException);
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getForeground (void)
186*cdf0e10cSrcweir         throw (cssu::RuntimeException);
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getBackground (void)
189*cdf0e10cSrcweir         throw (cssu::RuntimeException);
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir     //-----  XAccessibleEventBroadcaster --------------------------------------
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir     virtual void SAL_CALL addEventListener (
195*cdf0e10cSrcweir             const cssu::Reference<cssa::XAccessibleEventListener>& rxListener)
196*cdf0e10cSrcweir         throw (cssu::RuntimeException);
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir     virtual void SAL_CALL removeEventListener (
199*cdf0e10cSrcweir             const cssu::Reference<cssa::XAccessibleEventListener>& rxListener)
200*cdf0e10cSrcweir         throw (cssu::RuntimeException);
201*cdf0e10cSrcweir 
202*cdf0e10cSrcweir     using PresenterAccessibleObjectInterfaceBase::addEventListener;
203*cdf0e10cSrcweir     using PresenterAccessibleObjectInterfaceBase::removeEventListener;
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir     //----- XWindowListener ---------------------------------------------------
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir     virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent)
208*cdf0e10cSrcweir         throw (cssu::RuntimeException);
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir     virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent)
211*cdf0e10cSrcweir         throw (cssu::RuntimeException);
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir     virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent)
214*cdf0e10cSrcweir         throw (cssu::RuntimeException);
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir     virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent)
217*cdf0e10cSrcweir         throw (cssu::RuntimeException);
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir     //----- XEventListener ----------------------------------------------------
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir     virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent)
223*cdf0e10cSrcweir         throw (cssu::RuntimeException);
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir protected:
227*cdf0e10cSrcweir     ::rtl::OUString msName;
228*cdf0e10cSrcweir     cssu::Reference<css::awt::XWindow2> mxContentWindow;
229*cdf0e10cSrcweir     cssu::Reference<css::awt::XWindow2> mxBorderWindow;
230*cdf0e10cSrcweir     const css::lang::Locale maLocale;
231*cdf0e10cSrcweir     const sal_Int16 mnRole;
232*cdf0e10cSrcweir     sal_uInt32 mnStateSet;
233*cdf0e10cSrcweir     bool mbIsFocused;
234*cdf0e10cSrcweir     cssu::Reference<cssa::XAccessible> mxParentAccessible;
235*cdf0e10cSrcweir     ::std::vector<rtl::Reference<AccessibleObject> > maChildren;
236*cdf0e10cSrcweir     ::std::vector<Reference<XAccessibleEventListener> > maListeners;
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir     virtual awt::Point GetRelativeLocation (void);
239*cdf0e10cSrcweir     virtual awt::Size GetSize (void);
240*cdf0e10cSrcweir     virtual awt::Point GetAbsoluteParentLocation (void);
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir     virtual bool GetWindowState (const sal_Int16 nType) const;
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir     void UpdateState (const sal_Int16 aState, const bool bValue);
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir     sal_Bool IsDisposed (void) const;
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir     void ThrowIfDisposed (void) const
249*cdf0e10cSrcweir         throw (css::lang::DisposedException);
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir     enum ExceptionType { ET_Runtime, ET_Disposed, ET_IndexOutOfBounds };
252*cdf0e10cSrcweir     void ThrowException (const sal_Char* pMessage, const ExceptionType eExceptionType) const;
253*cdf0e10cSrcweir };
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir //===== AccessibleStateSet ====================================================
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir namespace {
261*cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper1 <
262*cdf0e10cSrcweir     cssa::XAccessibleStateSet
263*cdf0e10cSrcweir     > AccessibleStateSetInterfaceBase;
264*cdf0e10cSrcweir }
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir class AccessibleStateSet
267*cdf0e10cSrcweir     : public ::cppu::BaseMutex,
268*cdf0e10cSrcweir       public AccessibleStateSetInterfaceBase
269*cdf0e10cSrcweir {
270*cdf0e10cSrcweir public:
271*cdf0e10cSrcweir     AccessibleStateSet (const sal_Int32 nStateSet);
272*cdf0e10cSrcweir     virtual ~AccessibleStateSet (void);
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir     static sal_uInt32 GetStateMask (const sal_Int16 nType);
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir     //----- XAccessibleStateSet -----------------------------------------------
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL isEmpty (void)
279*cdf0e10cSrcweir         throw (cssu::RuntimeException);
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL contains (sal_Int16 nState)
282*cdf0e10cSrcweir         throw (cssu::RuntimeException);
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL containsAll (const cssu::Sequence<sal_Int16>& rStateSet)
285*cdf0e10cSrcweir         throw (cssu::RuntimeException);
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir     virtual cssu::Sequence<sal_Int16> SAL_CALL getStates (void)
288*cdf0e10cSrcweir         throw (cssu::RuntimeException);
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir private:
291*cdf0e10cSrcweir     const sal_Int32 mnStateSet;
292*cdf0e10cSrcweir };
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir 
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir //===== AccessibleRelationSet =================================================
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir namespace {
300*cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper1 <
301*cdf0e10cSrcweir     cssa::XAccessibleRelationSet
302*cdf0e10cSrcweir     > AccessibleRelationSetInterfaceBase;
303*cdf0e10cSrcweir }
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir class AccessibleRelationSet
306*cdf0e10cSrcweir     : public ::cppu::BaseMutex,
307*cdf0e10cSrcweir       public AccessibleRelationSetInterfaceBase
308*cdf0e10cSrcweir {
309*cdf0e10cSrcweir public:
310*cdf0e10cSrcweir     AccessibleRelationSet (void);
311*cdf0e10cSrcweir     virtual ~AccessibleRelationSet (void);
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir     void AddRelation (
314*cdf0e10cSrcweir         const sal_Int16 nRelationType,
315*cdf0e10cSrcweir         const Reference<XInterface>& rxObject);
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir     //----- XAccessibleRelationSet --------------------------------------------
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getRelationCount (void)
321*cdf0e10cSrcweir         throw (cssu::RuntimeException);
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir     virtual AccessibleRelation SAL_CALL getRelation (sal_Int32 nIndex)
324*cdf0e10cSrcweir         throw (cssu::RuntimeException, css::lang::IndexOutOfBoundsException);
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL containsRelation (sal_Int16 nRelationType)
327*cdf0e10cSrcweir         throw (cssu::RuntimeException);
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir     virtual AccessibleRelation SAL_CALL getRelationByType (sal_Int16 nRelationType)
330*cdf0e10cSrcweir         throw (cssu::RuntimeException);
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir private:
333*cdf0e10cSrcweir     ::std::vector<AccessibleRelation> maRelations;
334*cdf0e10cSrcweir };
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir //===== PresenterAccessibleParagraph ==========================================
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir namespace {
342*cdf0e10cSrcweir typedef ::cppu::ImplInheritanceHelper1 <
343*cdf0e10cSrcweir     PresenterAccessible::AccessibleObject,
344*cdf0e10cSrcweir     cssa::XAccessibleText
345*cdf0e10cSrcweir     > PresenterAccessibleParagraphInterfaceBase;
346*cdf0e10cSrcweir }
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir 
351*cdf0e10cSrcweir class PresenterAccessible::AccessibleParagraph
352*cdf0e10cSrcweir     : public PresenterAccessibleParagraphInterfaceBase
353*cdf0e10cSrcweir {
354*cdf0e10cSrcweir public:
355*cdf0e10cSrcweir     AccessibleParagraph (
356*cdf0e10cSrcweir         const css::lang::Locale aLocale,
357*cdf0e10cSrcweir         const sal_Int16 nRole,
358*cdf0e10cSrcweir         const ::rtl::OUString& rsName,
359*cdf0e10cSrcweir         const SharedPresenterTextParagraph& rpParagraph,
360*cdf0e10cSrcweir         const sal_Int32 nParagraphIndex);
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir     virtual ~AccessibleParagraph (void);
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir     //----- XAccessibleContext ------------------------------------------------
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir 	virtual cssu::Reference<cssa::XAccessibleRelationSet> SAL_CALL
368*cdf0e10cSrcweir     	getAccessibleRelationSet (void)
369*cdf0e10cSrcweir         throw (cssu::RuntimeException);
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir     //----- XAccessibleText ---------------------------------------------------
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getCaretPosition (void)
375*cdf0e10cSrcweir         throw (cssu::RuntimeException);
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL setCaretPosition (sal_Int32 nIndex)
378*cdf0e10cSrcweir         throw (::com::sun::star::lang::IndexOutOfBoundsException, cssu::RuntimeException);
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir     virtual sal_Unicode SAL_CALL getCharacter (sal_Int32 nIndex)
381*cdf0e10cSrcweir         throw (::com::sun::star::lang::IndexOutOfBoundsException, cssu::RuntimeException);
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir     virtual cssu::Sequence<css::beans::PropertyValue> SAL_CALL
384*cdf0e10cSrcweir         getCharacterAttributes (
385*cdf0e10cSrcweir             ::sal_Int32 nIndex,
386*cdf0e10cSrcweir             const cssu::Sequence<rtl::OUString>& rRequestedAttributes)
387*cdf0e10cSrcweir         throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException);
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir     virtual css::awt::Rectangle SAL_CALL getCharacterBounds (sal_Int32 nIndex)
390*cdf0e10cSrcweir         throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException);
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getCharacterCount (void)
393*cdf0e10cSrcweir         throw (cssu::RuntimeException);
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getIndexAtPoint (const css::awt::Point& rPoint)
396*cdf0e10cSrcweir         throw (cssu::RuntimeException);
397*cdf0e10cSrcweir 
398*cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getSelectedText (void)
399*cdf0e10cSrcweir         throw (cssu::RuntimeException);
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getSelectionStart (void)
402*cdf0e10cSrcweir         throw (cssu::RuntimeException);
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getSelectionEnd (void)
405*cdf0e10cSrcweir         throw (cssu::RuntimeException);
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL setSelection (sal_Int32 nStartIndex, sal_Int32 nEndIndex)
408*cdf0e10cSrcweir         throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException);
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getText (void)
411*cdf0e10cSrcweir         throw (cssu::RuntimeException);
412*cdf0e10cSrcweir 
413*cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getTextRange (
414*cdf0e10cSrcweir         sal_Int32 nStartIndex,
415*cdf0e10cSrcweir         sal_Int32 nEndIndex)
416*cdf0e10cSrcweir         throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException);
417*cdf0e10cSrcweir 
418*cdf0e10cSrcweir     virtual cssa::TextSegment SAL_CALL getTextAtIndex (
419*cdf0e10cSrcweir         sal_Int32 nIndex,
420*cdf0e10cSrcweir         sal_Int16 nTextType)
421*cdf0e10cSrcweir         throw (css::lang::IndexOutOfBoundsException,
422*cdf0e10cSrcweir             css::lang::IllegalArgumentException,
423*cdf0e10cSrcweir             cssu::RuntimeException);
424*cdf0e10cSrcweir 
425*cdf0e10cSrcweir     virtual cssa::TextSegment SAL_CALL getTextBeforeIndex (
426*cdf0e10cSrcweir         sal_Int32 nIndex,
427*cdf0e10cSrcweir         sal_Int16 nTextType)
428*cdf0e10cSrcweir         throw (css::lang::IndexOutOfBoundsException,
429*cdf0e10cSrcweir             css::lang::IllegalArgumentException,
430*cdf0e10cSrcweir             cssu::RuntimeException);
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir     virtual cssa::TextSegment SAL_CALL getTextBehindIndex (
433*cdf0e10cSrcweir         sal_Int32 nIndex,
434*cdf0e10cSrcweir         sal_Int16 nTextType)
435*cdf0e10cSrcweir         throw (css::lang::IndexOutOfBoundsException,
436*cdf0e10cSrcweir             css::lang::IllegalArgumentException,
437*cdf0e10cSrcweir             cssu::RuntimeException);
438*cdf0e10cSrcweir 
439*cdf0e10cSrcweir     virtual ::sal_Bool SAL_CALL copyText (sal_Int32 nStartIndex, sal_Int32 nEndIndex)
440*cdf0e10cSrcweir         throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException);
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir 
443*cdf0e10cSrcweir protected:
444*cdf0e10cSrcweir     virtual awt::Point GetRelativeLocation (void);
445*cdf0e10cSrcweir     virtual awt::Size GetSize (void);
446*cdf0e10cSrcweir     virtual awt::Point GetAbsoluteParentLocation (void);
447*cdf0e10cSrcweir     virtual bool GetWindowState (const sal_Int16 nType) const;
448*cdf0e10cSrcweir 
449*cdf0e10cSrcweir private:
450*cdf0e10cSrcweir     SharedPresenterTextParagraph mpParagraph;
451*cdf0e10cSrcweir     const sal_Int32 mnParagraphIndex;
452*cdf0e10cSrcweir };
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir 
455*cdf0e10cSrcweir 
456*cdf0e10cSrcweir 
457*cdf0e10cSrcweir //===== AccessibleConsole =====================================================
458*cdf0e10cSrcweir 
459*cdf0e10cSrcweir class AccessibleConsole
460*cdf0e10cSrcweir {
461*cdf0e10cSrcweir public:
462*cdf0e10cSrcweir     static rtl::Reference<PresenterAccessible::AccessibleObject> Create (
463*cdf0e10cSrcweir         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
464*cdf0e10cSrcweir         const lang::Locale aLocale)
465*cdf0e10cSrcweir     {
466*cdf0e10cSrcweir         OUString sName (A2S("Presenter Console"));
467*cdf0e10cSrcweir         PresenterConfigurationAccess aConfiguration (
468*cdf0e10cSrcweir             rxContext,
469*cdf0e10cSrcweir             OUString::createFromAscii("/org.openoffice.Office.extension.PresenterScreen/"),
470*cdf0e10cSrcweir             PresenterConfigurationAccess::READ_ONLY);
471*cdf0e10cSrcweir         aConfiguration.GetConfigurationNode(A2S("Presenter/Accessibility/Console/String"))
472*cdf0e10cSrcweir             >>= sName;
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir         rtl::Reference<PresenterAccessible::AccessibleObject> pObject (
475*cdf0e10cSrcweir             new PresenterAccessible::AccessibleObject(
476*cdf0e10cSrcweir                 aLocale, AccessibleRole::PANEL, sName));
477*cdf0e10cSrcweir         pObject->LateInitialization();
478*cdf0e10cSrcweir         pObject->UpdateStateSet();
479*cdf0e10cSrcweir 
480*cdf0e10cSrcweir         return pObject;
481*cdf0e10cSrcweir     }
482*cdf0e10cSrcweir };
483*cdf0e10cSrcweir 
484*cdf0e10cSrcweir 
485*cdf0e10cSrcweir 
486*cdf0e10cSrcweir 
487*cdf0e10cSrcweir //===== AccessiblePreview =====================================================
488*cdf0e10cSrcweir 
489*cdf0e10cSrcweir class AccessiblePreview
490*cdf0e10cSrcweir {
491*cdf0e10cSrcweir public:
492*cdf0e10cSrcweir     static rtl::Reference<PresenterAccessible::AccessibleObject> Create (
493*cdf0e10cSrcweir         const Reference<css::uno::XComponentContext>& rxContext,
494*cdf0e10cSrcweir         const lang::Locale aLocale,
495*cdf0e10cSrcweir         const Reference<awt::XWindow>& rxContentWindow,
496*cdf0e10cSrcweir         const Reference<awt::XWindow>& rxBorderWindow)
497*cdf0e10cSrcweir     {
498*cdf0e10cSrcweir         OUString sName (A2S("Presenter Notes Window"));
499*cdf0e10cSrcweir         {
500*cdf0e10cSrcweir             PresenterConfigurationAccess aConfiguration (
501*cdf0e10cSrcweir                 rxContext,
502*cdf0e10cSrcweir                 OUString::createFromAscii("/org.openoffice.Office.extension.PresenterScreen/"),
503*cdf0e10cSrcweir                 PresenterConfigurationAccess::READ_ONLY);
504*cdf0e10cSrcweir             aConfiguration.GetConfigurationNode(A2S("Presenter/Accessibility/Preview/String"))
505*cdf0e10cSrcweir                 >>= sName;
506*cdf0e10cSrcweir         }
507*cdf0e10cSrcweir 
508*cdf0e10cSrcweir         rtl::Reference<PresenterAccessible::AccessibleObject> pObject (
509*cdf0e10cSrcweir             new PresenterAccessible::AccessibleObject(
510*cdf0e10cSrcweir                 aLocale,
511*cdf0e10cSrcweir                 AccessibleRole::LABEL,
512*cdf0e10cSrcweir                 sName));
513*cdf0e10cSrcweir         pObject->LateInitialization();
514*cdf0e10cSrcweir         pObject->UpdateStateSet();
515*cdf0e10cSrcweir         pObject->SetWindow(rxContentWindow, rxBorderWindow);
516*cdf0e10cSrcweir 
517*cdf0e10cSrcweir         return pObject;
518*cdf0e10cSrcweir     }
519*cdf0e10cSrcweir };
520*cdf0e10cSrcweir 
521*cdf0e10cSrcweir 
522*cdf0e10cSrcweir 
523*cdf0e10cSrcweir 
524*cdf0e10cSrcweir //===== AccessibleNotes =======================================================
525*cdf0e10cSrcweir 
526*cdf0e10cSrcweir class AccessibleNotes : public PresenterAccessible::AccessibleObject
527*cdf0e10cSrcweir {
528*cdf0e10cSrcweir public:
529*cdf0e10cSrcweir     AccessibleNotes (
530*cdf0e10cSrcweir         const css::lang::Locale aLocale,
531*cdf0e10cSrcweir         const sal_Int16 nRole,
532*cdf0e10cSrcweir         const ::rtl::OUString& rsName);
533*cdf0e10cSrcweir 
534*cdf0e10cSrcweir 
535*cdf0e10cSrcweir     static rtl::Reference<PresenterAccessible::AccessibleObject> Create (
536*cdf0e10cSrcweir         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
537*cdf0e10cSrcweir         const lang::Locale aLocale,
538*cdf0e10cSrcweir         const Reference<awt::XWindow>& rxContentWindow,
539*cdf0e10cSrcweir         const Reference<awt::XWindow>& rxBorderWindow,
540*cdf0e10cSrcweir         const ::boost::shared_ptr<PresenterTextView>& rpTextView);
541*cdf0e10cSrcweir 
542*cdf0e10cSrcweir     void SetTextView (const ::boost::shared_ptr<PresenterTextView>& rpTextView);
543*cdf0e10cSrcweir 
544*cdf0e10cSrcweir     virtual void SetWindow (
545*cdf0e10cSrcweir         const cssu::Reference<css::awt::XWindow>& rxContentWindow,
546*cdf0e10cSrcweir         const cssu::Reference<css::awt::XWindow>& rxBorderWindow);
547*cdf0e10cSrcweir 
548*cdf0e10cSrcweir private:
549*cdf0e10cSrcweir     ::boost::shared_ptr<PresenterTextView> mpTextView;
550*cdf0e10cSrcweir 
551*cdf0e10cSrcweir     void NotifyCaretChange (
552*cdf0e10cSrcweir         const sal_Int32 nOldParagraphIndex,
553*cdf0e10cSrcweir         const sal_Int32 nOldCharacterIndex,
554*cdf0e10cSrcweir         const sal_Int32 nNewParagraphIndex,
555*cdf0e10cSrcweir         const sal_Int32 nNewCharacterIndex);
556*cdf0e10cSrcweir     void HandleTextChange (void);
557*cdf0e10cSrcweir };
558*cdf0e10cSrcweir 
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir 
561*cdf0e10cSrcweir 
562*cdf0e10cSrcweir //===== AccessibleFocusManager ================================================
563*cdf0e10cSrcweir 
564*cdf0e10cSrcweir /** A singleton class that makes sure that only one accessibility object in
565*cdf0e10cSrcweir     the PresenterConsole hierarchy has the focus.
566*cdf0e10cSrcweir */
567*cdf0e10cSrcweir class AccessibleFocusManager
568*cdf0e10cSrcweir {
569*cdf0e10cSrcweir public:
570*cdf0e10cSrcweir     static ::boost::shared_ptr<AccessibleFocusManager> Instance (void);
571*cdf0e10cSrcweir 
572*cdf0e10cSrcweir     void AddFocusableObject (const ::rtl::Reference<PresenterAccessible::AccessibleObject>& rpObject);
573*cdf0e10cSrcweir     void RemoveFocusableObject (const ::rtl::Reference<PresenterAccessible::AccessibleObject>& rpObject);
574*cdf0e10cSrcweir 
575*cdf0e10cSrcweir     void FocusObject (const ::rtl::Reference<PresenterAccessible::AccessibleObject>& rpObject);
576*cdf0e10cSrcweir 
577*cdf0e10cSrcweir private:
578*cdf0e10cSrcweir     static ::boost::shared_ptr<AccessibleFocusManager> mpInstance;
579*cdf0e10cSrcweir     ::std::vector<rtl::Reference<PresenterAccessible::AccessibleObject> > maFocusableObjects;
580*cdf0e10cSrcweir 
581*cdf0e10cSrcweir     AccessibleFocusManager (void);
582*cdf0e10cSrcweir };
583*cdf0e10cSrcweir 
584*cdf0e10cSrcweir 
585*cdf0e10cSrcweir 
586*cdf0e10cSrcweir 
587*cdf0e10cSrcweir //===== PresenterAccessible ===================================================
588*cdf0e10cSrcweir 
589*cdf0e10cSrcweir PresenterAccessible::PresenterAccessible (
590*cdf0e10cSrcweir     const css::uno::Reference<css::uno::XComponentContext>& rxContext,
591*cdf0e10cSrcweir     const ::rtl::Reference<PresenterController>& rpPresenterController,
592*cdf0e10cSrcweir     const Reference<drawing::framework::XPane>& rxMainPane)
593*cdf0e10cSrcweir     : PresenterAccessibleInterfaceBase(m_aMutex),
594*cdf0e10cSrcweir       mxComponentContext(rxContext),
595*cdf0e10cSrcweir       mpPresenterController(rpPresenterController),
596*cdf0e10cSrcweir       mxMainPaneId(rxMainPane.is() ? rxMainPane->getResourceId() : Reference<XResourceId>()),
597*cdf0e10cSrcweir       mxMainPane(rxMainPane, UNO_QUERY),
598*cdf0e10cSrcweir       mxMainWindow(),
599*cdf0e10cSrcweir       mxPreviewContentWindow(),
600*cdf0e10cSrcweir       mxPreviewBorderWindow(),
601*cdf0e10cSrcweir       mxNotesContentWindow(),
602*cdf0e10cSrcweir       mxNotesBorderWindow(),
603*cdf0e10cSrcweir       mpAccessibleConsole(),
604*cdf0e10cSrcweir       mpAccessiblePreview(),
605*cdf0e10cSrcweir       mpAccessibleNotes(),
606*cdf0e10cSrcweir       mxAccessibleParent()
607*cdf0e10cSrcweir {
608*cdf0e10cSrcweir     if (mxMainPane.is())
609*cdf0e10cSrcweir         mxMainPane->setAccessible(this);
610*cdf0e10cSrcweir }
611*cdf0e10cSrcweir 
612*cdf0e10cSrcweir 
613*cdf0e10cSrcweir 
614*cdf0e10cSrcweir 
615*cdf0e10cSrcweir PresenterAccessible::~PresenterAccessible (void)
616*cdf0e10cSrcweir {
617*cdf0e10cSrcweir }
618*cdf0e10cSrcweir 
619*cdf0e10cSrcweir 
620*cdf0e10cSrcweir 
621*cdf0e10cSrcweir 
622*cdf0e10cSrcweir PresenterPaneContainer::SharedPaneDescriptor PresenterAccessible::GetPreviewPane (void) const
623*cdf0e10cSrcweir {
624*cdf0e10cSrcweir     PresenterPaneContainer::SharedPaneDescriptor pPreviewPane;
625*cdf0e10cSrcweir 
626*cdf0e10cSrcweir     if ( ! mpPresenterController.is())
627*cdf0e10cSrcweir         return pPreviewPane;
628*cdf0e10cSrcweir 
629*cdf0e10cSrcweir     rtl::Reference<PresenterPaneContainer> pContainer (mpPresenterController->GetPaneContainer());
630*cdf0e10cSrcweir     if ( ! pContainer.is())
631*cdf0e10cSrcweir         return pPreviewPane;
632*cdf0e10cSrcweir 
633*cdf0e10cSrcweir     pPreviewPane = pContainer->FindPaneURL(PresenterPaneFactory::msCurrentSlidePreviewPaneURL);
634*cdf0e10cSrcweir     Reference<drawing::framework::XPane> xPreviewPane;
635*cdf0e10cSrcweir     if (pPreviewPane)
636*cdf0e10cSrcweir         xPreviewPane = pPreviewPane->mxPane.get();
637*cdf0e10cSrcweir     if ( ! xPreviewPane.is())
638*cdf0e10cSrcweir     {
639*cdf0e10cSrcweir         pPreviewPane = pContainer->FindPaneURL(PresenterPaneFactory::msSlideSorterPaneURL);
640*cdf0e10cSrcweir     }
641*cdf0e10cSrcweir     return pPreviewPane;
642*cdf0e10cSrcweir }
643*cdf0e10cSrcweir 
644*cdf0e10cSrcweir 
645*cdf0e10cSrcweir 
646*cdf0e10cSrcweir 
647*cdf0e10cSrcweir void PresenterAccessible::UpdateAccessibilityHierarchy (void)
648*cdf0e10cSrcweir {
649*cdf0e10cSrcweir     if ( ! mpPresenterController.is())
650*cdf0e10cSrcweir         return;
651*cdf0e10cSrcweir 
652*cdf0e10cSrcweir     Reference<drawing::framework::XConfigurationController> xConfigurationController(
653*cdf0e10cSrcweir         mpPresenterController->GetConfigurationController());
654*cdf0e10cSrcweir     if ( ! xConfigurationController.is())
655*cdf0e10cSrcweir         return;
656*cdf0e10cSrcweir 
657*cdf0e10cSrcweir     rtl::Reference<PresenterPaneContainer> pPaneContainer (
658*cdf0e10cSrcweir         mpPresenterController->GetPaneContainer());
659*cdf0e10cSrcweir     if ( ! pPaneContainer.is())
660*cdf0e10cSrcweir         return;
661*cdf0e10cSrcweir 
662*cdf0e10cSrcweir     if ( ! mpAccessibleConsole.is())
663*cdf0e10cSrcweir         return;
664*cdf0e10cSrcweir 
665*cdf0e10cSrcweir     // Get the preview pane (standard or notes view) or the slide overview
666*cdf0e10cSrcweir     // pane.
667*cdf0e10cSrcweir     PresenterPaneContainer::SharedPaneDescriptor pPreviewPane(GetPreviewPane());
668*cdf0e10cSrcweir     Reference<drawing::framework::XPane> xPreviewPane;
669*cdf0e10cSrcweir     if (pPreviewPane)
670*cdf0e10cSrcweir         xPreviewPane = pPreviewPane->mxPane.get();
671*cdf0e10cSrcweir 
672*cdf0e10cSrcweir     // Get the notes pane.
673*cdf0e10cSrcweir     PresenterPaneContainer::SharedPaneDescriptor pNotesPane(
674*cdf0e10cSrcweir         pPaneContainer->FindPaneURL(PresenterPaneFactory::msNotesPaneURL));
675*cdf0e10cSrcweir     Reference<drawing::framework::XPane> xNotesPane;
676*cdf0e10cSrcweir     if (pNotesPane)
677*cdf0e10cSrcweir         xNotesPane = pNotesPane->mxPane.get();
678*cdf0e10cSrcweir 
679*cdf0e10cSrcweir     // Get the notes view.
680*cdf0e10cSrcweir     Reference<drawing::framework::XView> xNotesView;
681*cdf0e10cSrcweir     if (pNotesPane)
682*cdf0e10cSrcweir         xNotesView = pNotesPane->mxView;
683*cdf0e10cSrcweir     rtl::Reference<PresenterNotesView> pNotesView (
684*cdf0e10cSrcweir         dynamic_cast<PresenterNotesView*>(xNotesView.get()));
685*cdf0e10cSrcweir 
686*cdf0e10cSrcweir     UpdateAccessibilityHierarchy(
687*cdf0e10cSrcweir         pPreviewPane ? pPreviewPane->mxContentWindow : Reference<awt::XWindow>(),
688*cdf0e10cSrcweir         pPreviewPane ? pPreviewPane->mxBorderWindow : Reference<awt::XWindow>(),
689*cdf0e10cSrcweir         (pPreviewPane&&pPreviewPane->mxPane.is()) ? pPreviewPane->mxPane->GetTitle() : OUString(),
690*cdf0e10cSrcweir         pNotesPane ? pNotesPane->mxContentWindow : Reference<awt::XWindow>(),
691*cdf0e10cSrcweir         pNotesPane ? pNotesPane->mxBorderWindow : Reference<awt::XWindow>(),
692*cdf0e10cSrcweir         pNotesView.is()
693*cdf0e10cSrcweir             ? pNotesView->GetTextView()
694*cdf0e10cSrcweir             : ::boost::shared_ptr<PresenterTextView>());
695*cdf0e10cSrcweir }
696*cdf0e10cSrcweir 
697*cdf0e10cSrcweir 
698*cdf0e10cSrcweir 
699*cdf0e10cSrcweir 
700*cdf0e10cSrcweir 
701*cdf0e10cSrcweir void PresenterAccessible::UpdateAccessibilityHierarchy (
702*cdf0e10cSrcweir     const Reference<awt::XWindow>& rxPreviewContentWindow,
703*cdf0e10cSrcweir     const Reference<awt::XWindow>& rxPreviewBorderWindow,
704*cdf0e10cSrcweir     const ::rtl::OUString& rsTitle,
705*cdf0e10cSrcweir     const Reference<awt::XWindow>& rxNotesContentWindow,
706*cdf0e10cSrcweir     const Reference<awt::XWindow>& rxNotesBorderWindow,
707*cdf0e10cSrcweir     const ::boost::shared_ptr<PresenterTextView>& rpNotesTextView)
708*cdf0e10cSrcweir {
709*cdf0e10cSrcweir     if ( ! mpAccessibleConsole.is())
710*cdf0e10cSrcweir         return;
711*cdf0e10cSrcweir 
712*cdf0e10cSrcweir     if (mxPreviewContentWindow != rxPreviewContentWindow)
713*cdf0e10cSrcweir     {
714*cdf0e10cSrcweir         if (mpAccessiblePreview.is())
715*cdf0e10cSrcweir         {
716*cdf0e10cSrcweir             mpAccessibleConsole->RemoveChild(mpAccessiblePreview);
717*cdf0e10cSrcweir             mpAccessiblePreview = NULL;
718*cdf0e10cSrcweir         }
719*cdf0e10cSrcweir 
720*cdf0e10cSrcweir         mxPreviewContentWindow = rxPreviewContentWindow;
721*cdf0e10cSrcweir         mxPreviewBorderWindow = rxPreviewBorderWindow;
722*cdf0e10cSrcweir 
723*cdf0e10cSrcweir         if (mxPreviewContentWindow.is())
724*cdf0e10cSrcweir         {
725*cdf0e10cSrcweir             mpAccessiblePreview = AccessiblePreview::Create(
726*cdf0e10cSrcweir                 mxComponentContext,
727*cdf0e10cSrcweir                 lang::Locale(),
728*cdf0e10cSrcweir                 mxPreviewContentWindow,
729*cdf0e10cSrcweir                 mxPreviewBorderWindow);
730*cdf0e10cSrcweir             mpAccessibleConsole->AddChild(mpAccessiblePreview);
731*cdf0e10cSrcweir             mpAccessiblePreview->SetAccessibleName(rsTitle);
732*cdf0e10cSrcweir         }
733*cdf0e10cSrcweir     }
734*cdf0e10cSrcweir 
735*cdf0e10cSrcweir     if (mxNotesContentWindow != rxNotesContentWindow)
736*cdf0e10cSrcweir     {
737*cdf0e10cSrcweir         if (mpAccessibleNotes.is())
738*cdf0e10cSrcweir         {
739*cdf0e10cSrcweir             mpAccessibleConsole->RemoveChild(mpAccessibleConsole.get());
740*cdf0e10cSrcweir             mpAccessibleNotes = NULL;
741*cdf0e10cSrcweir         }
742*cdf0e10cSrcweir 
743*cdf0e10cSrcweir         mxNotesContentWindow = rxNotesContentWindow;
744*cdf0e10cSrcweir         mxNotesBorderWindow = rxNotesBorderWindow;
745*cdf0e10cSrcweir 
746*cdf0e10cSrcweir         if (mxNotesContentWindow.is())
747*cdf0e10cSrcweir         {
748*cdf0e10cSrcweir             mpAccessibleNotes = AccessibleNotes::Create(
749*cdf0e10cSrcweir                 mxComponentContext,
750*cdf0e10cSrcweir                 lang::Locale(),
751*cdf0e10cSrcweir                 mxNotesContentWindow,
752*cdf0e10cSrcweir                 mxNotesBorderWindow,
753*cdf0e10cSrcweir                 rpNotesTextView);
754*cdf0e10cSrcweir             mpAccessibleConsole->AddChild(mpAccessibleNotes.get());
755*cdf0e10cSrcweir         }
756*cdf0e10cSrcweir     }
757*cdf0e10cSrcweir }
758*cdf0e10cSrcweir 
759*cdf0e10cSrcweir 
760*cdf0e10cSrcweir 
761*cdf0e10cSrcweir 
762*cdf0e10cSrcweir void PresenterAccessible::NotifyCurrentSlideChange (
763*cdf0e10cSrcweir     const sal_Int32 nCurrentSlideIndex,
764*cdf0e10cSrcweir     const sal_Int32 nSlideCount)
765*cdf0e10cSrcweir {
766*cdf0e10cSrcweir     (void)nCurrentSlideIndex;
767*cdf0e10cSrcweir     (void)nSlideCount;
768*cdf0e10cSrcweir 
769*cdf0e10cSrcweir     if (mpAccessiblePreview.is())
770*cdf0e10cSrcweir     {
771*cdf0e10cSrcweir         PresenterPaneContainer::SharedPaneDescriptor pPreviewPane (GetPreviewPane());
772*cdf0e10cSrcweir         mpAccessiblePreview->SetAccessibleName(
773*cdf0e10cSrcweir             (pPreviewPane&&pPreviewPane->mxPane.is()
774*cdf0e10cSrcweir                 ? pPreviewPane->mxPane->GetTitle()
775*cdf0e10cSrcweir                 : rtl::OUString()));
776*cdf0e10cSrcweir     }
777*cdf0e10cSrcweir 
778*cdf0e10cSrcweir     // Play some focus ping-pong to trigger AT tools.
779*cdf0e10cSrcweir     //AccessibleFocusManager::Instance()->FocusObject(mpAccessibleConsole);
780*cdf0e10cSrcweir     AccessibleFocusManager::Instance()->FocusObject(mpAccessiblePreview);
781*cdf0e10cSrcweir }
782*cdf0e10cSrcweir 
783*cdf0e10cSrcweir 
784*cdf0e10cSrcweir 
785*cdf0e10cSrcweir 
786*cdf0e10cSrcweir bool PresenterAccessible::IsAccessibilityActive (void) const
787*cdf0e10cSrcweir {
788*cdf0e10cSrcweir     return mpAccessibleConsole.is();
789*cdf0e10cSrcweir }
790*cdf0e10cSrcweir 
791*cdf0e10cSrcweir 
792*cdf0e10cSrcweir 
793*cdf0e10cSrcweir 
794*cdf0e10cSrcweir void SAL_CALL PresenterAccessible::disposing (void)
795*cdf0e10cSrcweir {
796*cdf0e10cSrcweir     UpdateAccessibilityHierarchy(
797*cdf0e10cSrcweir         NULL,
798*cdf0e10cSrcweir         NULL,
799*cdf0e10cSrcweir         OUString(),
800*cdf0e10cSrcweir         NULL,
801*cdf0e10cSrcweir         NULL,
802*cdf0e10cSrcweir         ::boost::shared_ptr<PresenterTextView>());
803*cdf0e10cSrcweir 
804*cdf0e10cSrcweir     if (mxMainWindow.is())
805*cdf0e10cSrcweir     {
806*cdf0e10cSrcweir         mxMainWindow->removeFocusListener(this);
807*cdf0e10cSrcweir 
808*cdf0e10cSrcweir         if (mxMainPane.is())
809*cdf0e10cSrcweir             mxMainPane->setAccessible(NULL);
810*cdf0e10cSrcweir     }
811*cdf0e10cSrcweir 
812*cdf0e10cSrcweir     mpAccessiblePreview = NULL;
813*cdf0e10cSrcweir     mpAccessibleNotes = NULL;
814*cdf0e10cSrcweir     mpAccessibleConsole = NULL;
815*cdf0e10cSrcweir }
816*cdf0e10cSrcweir 
817*cdf0e10cSrcweir 
818*cdf0e10cSrcweir 
819*cdf0e10cSrcweir 
820*cdf0e10cSrcweir //----- XAccessible -----------------------------------------------------------
821*cdf0e10cSrcweir 
822*cdf0e10cSrcweir Reference<XAccessibleContext> SAL_CALL PresenterAccessible::getAccessibleContext (void)
823*cdf0e10cSrcweir     throw (cssu::RuntimeException)
824*cdf0e10cSrcweir {
825*cdf0e10cSrcweir     if ( ! mpAccessibleConsole.is())
826*cdf0e10cSrcweir     {
827*cdf0e10cSrcweir         Reference<XPane> xMainPane (mxMainPane, UNO_QUERY);
828*cdf0e10cSrcweir         if (xMainPane.is())
829*cdf0e10cSrcweir         {
830*cdf0e10cSrcweir             mxMainWindow = Reference<awt::XWindow>(xMainPane->getWindow(), UNO_QUERY);
831*cdf0e10cSrcweir             mxMainWindow->addFocusListener(this);
832*cdf0e10cSrcweir         }
833*cdf0e10cSrcweir         mpAccessibleConsole = AccessibleConsole::Create(
834*cdf0e10cSrcweir             mxComponentContext, css::lang::Locale());
835*cdf0e10cSrcweir         mpAccessibleConsole->SetWindow(mxMainWindow, NULL);
836*cdf0e10cSrcweir         mpAccessibleConsole->SetAccessibleParent(mxAccessibleParent);
837*cdf0e10cSrcweir         UpdateAccessibilityHierarchy();
838*cdf0e10cSrcweir         if (mpPresenterController.is())
839*cdf0e10cSrcweir             mpPresenterController->SetAccessibilityActiveState(true);
840*cdf0e10cSrcweir     }
841*cdf0e10cSrcweir     return mpAccessibleConsole->getAccessibleContext();
842*cdf0e10cSrcweir }
843*cdf0e10cSrcweir 
844*cdf0e10cSrcweir 
845*cdf0e10cSrcweir 
846*cdf0e10cSrcweir 
847*cdf0e10cSrcweir 
848*cdf0e10cSrcweir //----- XFocusListener ----------------------------------------------------
849*cdf0e10cSrcweir 
850*cdf0e10cSrcweir void SAL_CALL PresenterAccessible::focusGained (const css::awt::FocusEvent& rEvent)
851*cdf0e10cSrcweir         throw (cssu::RuntimeException)
852*cdf0e10cSrcweir {
853*cdf0e10cSrcweir     (void)rEvent;
854*cdf0e10cSrcweir 
855*cdf0e10cSrcweir #ifdef VERBOSE
856*cdf0e10cSrcweir     OSL_TRACE("PresenterAccessible::focusGained at %x and window %x\r", this,
857*cdf0e10cSrcweir         mxMainWindow.get());
858*cdf0e10cSrcweir #endif
859*cdf0e10cSrcweir 
860*cdf0e10cSrcweir     AccessibleFocusManager::Instance()->FocusObject(mpAccessibleConsole);
861*cdf0e10cSrcweir }
862*cdf0e10cSrcweir 
863*cdf0e10cSrcweir 
864*cdf0e10cSrcweir 
865*cdf0e10cSrcweir 
866*cdf0e10cSrcweir void SAL_CALL PresenterAccessible::focusLost (const css::awt::FocusEvent& rEvent)
867*cdf0e10cSrcweir     throw (cssu::RuntimeException)
868*cdf0e10cSrcweir {
869*cdf0e10cSrcweir     (void)rEvent;
870*cdf0e10cSrcweir 
871*cdf0e10cSrcweir #ifdef VERBOSE
872*cdf0e10cSrcweir     OSL_TRACE("PresenterAccessible::focusLost at %x\r", this);
873*cdf0e10cSrcweir #endif
874*cdf0e10cSrcweir 
875*cdf0e10cSrcweir     AccessibleFocusManager::Instance()->FocusObject(NULL);
876*cdf0e10cSrcweir }
877*cdf0e10cSrcweir 
878*cdf0e10cSrcweir 
879*cdf0e10cSrcweir 
880*cdf0e10cSrcweir 
881*cdf0e10cSrcweir //----- XEventListener ----------------------------------------------------
882*cdf0e10cSrcweir 
883*cdf0e10cSrcweir void SAL_CALL PresenterAccessible::disposing (const css::lang::EventObject& rEvent)
884*cdf0e10cSrcweir     throw (cssu::RuntimeException)
885*cdf0e10cSrcweir {
886*cdf0e10cSrcweir     if (rEvent.Source == mxMainWindow)
887*cdf0e10cSrcweir         mxMainWindow = NULL;
888*cdf0e10cSrcweir }
889*cdf0e10cSrcweir 
890*cdf0e10cSrcweir 
891*cdf0e10cSrcweir 
892*cdf0e10cSrcweir 
893*cdf0e10cSrcweir //----- XInitialize -----------------------------------------------------------
894*cdf0e10cSrcweir 
895*cdf0e10cSrcweir void SAL_CALL PresenterAccessible::initialize (const cssu::Sequence<cssu::Any>& rArguments)
896*cdf0e10cSrcweir     throw (cssu::RuntimeException)
897*cdf0e10cSrcweir {
898*cdf0e10cSrcweir     if (rArguments.getLength() >= 1)
899*cdf0e10cSrcweir     {
900*cdf0e10cSrcweir         mxAccessibleParent = Reference<XAccessible>(rArguments[0], UNO_QUERY);
901*cdf0e10cSrcweir         if (mpAccessibleConsole.is())
902*cdf0e10cSrcweir             mpAccessibleConsole->SetAccessibleParent(mxAccessibleParent);
903*cdf0e10cSrcweir     }
904*cdf0e10cSrcweir }
905*cdf0e10cSrcweir 
906*cdf0e10cSrcweir 
907*cdf0e10cSrcweir 
908*cdf0e10cSrcweir 
909*cdf0e10cSrcweir //===== PresenterAccessible::AccessibleObject =========================================
910*cdf0e10cSrcweir 
911*cdf0e10cSrcweir PresenterAccessible::AccessibleObject::AccessibleObject (
912*cdf0e10cSrcweir     const lang::Locale aLocale,
913*cdf0e10cSrcweir     const sal_Int16 nRole,
914*cdf0e10cSrcweir     const OUString& rsName)
915*cdf0e10cSrcweir     : PresenterAccessibleObjectInterfaceBase(m_aMutex),
916*cdf0e10cSrcweir       msName(rsName),
917*cdf0e10cSrcweir       mxContentWindow(),
918*cdf0e10cSrcweir       mxBorderWindow(),
919*cdf0e10cSrcweir       maLocale(aLocale),
920*cdf0e10cSrcweir       mnRole(nRole),
921*cdf0e10cSrcweir       mnStateSet(0),
922*cdf0e10cSrcweir       mbIsFocused(false),
923*cdf0e10cSrcweir       mxParentAccessible(),
924*cdf0e10cSrcweir       maChildren(),
925*cdf0e10cSrcweir       maListeners()
926*cdf0e10cSrcweir {
927*cdf0e10cSrcweir }
928*cdf0e10cSrcweir 
929*cdf0e10cSrcweir 
930*cdf0e10cSrcweir 
931*cdf0e10cSrcweir 
932*cdf0e10cSrcweir void PresenterAccessible::AccessibleObject::LateInitialization (void)
933*cdf0e10cSrcweir {
934*cdf0e10cSrcweir     AccessibleFocusManager::Instance()->AddFocusableObject(this);
935*cdf0e10cSrcweir }
936*cdf0e10cSrcweir 
937*cdf0e10cSrcweir 
938*cdf0e10cSrcweir 
939*cdf0e10cSrcweir 
940*cdf0e10cSrcweir PresenterAccessible::AccessibleObject::~AccessibleObject (void)
941*cdf0e10cSrcweir {
942*cdf0e10cSrcweir }
943*cdf0e10cSrcweir 
944*cdf0e10cSrcweir 
945*cdf0e10cSrcweir 
946*cdf0e10cSrcweir 
947*cdf0e10cSrcweir void PresenterAccessible::AccessibleObject::SetWindow (
948*cdf0e10cSrcweir     const Reference<awt::XWindow>& rxContentWindow,
949*cdf0e10cSrcweir     const Reference<awt::XWindow>& rxBorderWindow)
950*cdf0e10cSrcweir {
951*cdf0e10cSrcweir     Reference<awt::XWindow2> xContentWindow (rxContentWindow, UNO_QUERY);
952*cdf0e10cSrcweir 
953*cdf0e10cSrcweir     if (mxContentWindow.get() != xContentWindow.get())
954*cdf0e10cSrcweir     {
955*cdf0e10cSrcweir         if (mxContentWindow.is())
956*cdf0e10cSrcweir         {
957*cdf0e10cSrcweir             mxContentWindow->removeWindowListener(this);
958*cdf0e10cSrcweir         }
959*cdf0e10cSrcweir 
960*cdf0e10cSrcweir         mxContentWindow = xContentWindow;
961*cdf0e10cSrcweir         mxBorderWindow = Reference<awt::XWindow2>(rxBorderWindow, UNO_QUERY);
962*cdf0e10cSrcweir 
963*cdf0e10cSrcweir         if (mxContentWindow.is())
964*cdf0e10cSrcweir         {
965*cdf0e10cSrcweir             mxContentWindow->addWindowListener(this);
966*cdf0e10cSrcweir         }
967*cdf0e10cSrcweir 
968*cdf0e10cSrcweir         UpdateStateSet();
969*cdf0e10cSrcweir     }
970*cdf0e10cSrcweir }
971*cdf0e10cSrcweir 
972*cdf0e10cSrcweir 
973*cdf0e10cSrcweir 
974*cdf0e10cSrcweir 
975*cdf0e10cSrcweir void PresenterAccessible::AccessibleObject::SetAccessibleParent (
976*cdf0e10cSrcweir     const Reference<XAccessible>& rxAccessibleParent)
977*cdf0e10cSrcweir {
978*cdf0e10cSrcweir     mxParentAccessible = rxAccessibleParent;
979*cdf0e10cSrcweir }
980*cdf0e10cSrcweir 
981*cdf0e10cSrcweir 
982*cdf0e10cSrcweir 
983*cdf0e10cSrcweir 
984*cdf0e10cSrcweir void SAL_CALL PresenterAccessible::AccessibleObject::disposing (void)
985*cdf0e10cSrcweir {
986*cdf0e10cSrcweir     AccessibleFocusManager::Instance()->RemoveFocusableObject(this);
987*cdf0e10cSrcweir     SetWindow(NULL, NULL);
988*cdf0e10cSrcweir }
989*cdf0e10cSrcweir 
990*cdf0e10cSrcweir 
991*cdf0e10cSrcweir 
992*cdf0e10cSrcweir 
993*cdf0e10cSrcweir //----- XAccessible -------------------------------------------------------
994*cdf0e10cSrcweir 
995*cdf0e10cSrcweir Reference<XAccessibleContext> SAL_CALL
996*cdf0e10cSrcweir     PresenterAccessible::AccessibleObject::getAccessibleContext (void)
997*cdf0e10cSrcweir     throw (RuntimeException)
998*cdf0e10cSrcweir {
999*cdf0e10cSrcweir     ThrowIfDisposed();
1000*cdf0e10cSrcweir 
1001*cdf0e10cSrcweir     return this;
1002*cdf0e10cSrcweir }
1003*cdf0e10cSrcweir 
1004*cdf0e10cSrcweir 
1005*cdf0e10cSrcweir 
1006*cdf0e10cSrcweir 
1007*cdf0e10cSrcweir //-----  XAccessibleContext  ----------------------------------------------
1008*cdf0e10cSrcweir 
1009*cdf0e10cSrcweir sal_Int32 SAL_CALL PresenterAccessible::AccessibleObject::getAccessibleChildCount (void)
1010*cdf0e10cSrcweir     throw (cssu::RuntimeException)
1011*cdf0e10cSrcweir {
1012*cdf0e10cSrcweir     ThrowIfDisposed();
1013*cdf0e10cSrcweir 
1014*cdf0e10cSrcweir     const sal_Int32 nChildCount (maChildren.size());
1015*cdf0e10cSrcweir 
1016*cdf0e10cSrcweir     return nChildCount;
1017*cdf0e10cSrcweir }
1018*cdf0e10cSrcweir 
1019*cdf0e10cSrcweir 
1020*cdf0e10cSrcweir 
1021*cdf0e10cSrcweir 
1022*cdf0e10cSrcweir Reference<XAccessible> SAL_CALL
1023*cdf0e10cSrcweir     PresenterAccessible::AccessibleObject::getAccessibleChild (sal_Int32 nIndex)
1024*cdf0e10cSrcweir     throw (lang::IndexOutOfBoundsException, RuntimeException)
1025*cdf0e10cSrcweir {
1026*cdf0e10cSrcweir     ThrowIfDisposed();
1027*cdf0e10cSrcweir 
1028*cdf0e10cSrcweir     if (nIndex<0 || nIndex>=sal_Int32(maChildren.size()))
1029*cdf0e10cSrcweir         ThrowException("invalid child index", ET_IndexOutOfBounds);
1030*cdf0e10cSrcweir 
1031*cdf0e10cSrcweir     return Reference<XAccessible>(maChildren[nIndex].get());
1032*cdf0e10cSrcweir }
1033*cdf0e10cSrcweir 
1034*cdf0e10cSrcweir 
1035*cdf0e10cSrcweir 
1036*cdf0e10cSrcweir 
1037*cdf0e10cSrcweir Reference<XAccessible> SAL_CALL
1038*cdf0e10cSrcweir     PresenterAccessible::AccessibleObject::getAccessibleParent (void)
1039*cdf0e10cSrcweir     throw (RuntimeException)
1040*cdf0e10cSrcweir {
1041*cdf0e10cSrcweir     ThrowIfDisposed();
1042*cdf0e10cSrcweir 
1043*cdf0e10cSrcweir     return mxParentAccessible;
1044*cdf0e10cSrcweir }
1045*cdf0e10cSrcweir 
1046*cdf0e10cSrcweir 
1047*cdf0e10cSrcweir 
1048*cdf0e10cSrcweir 
1049*cdf0e10cSrcweir sal_Int32 SAL_CALL
1050*cdf0e10cSrcweir     PresenterAccessible::AccessibleObject::getAccessibleIndexInParent (void)
1051*cdf0e10cSrcweir     throw (RuntimeException)
1052*cdf0e10cSrcweir {
1053*cdf0e10cSrcweir     ThrowIfDisposed();
1054*cdf0e10cSrcweir 
1055*cdf0e10cSrcweir     const Reference<XAccessible> xThis (this);
1056*cdf0e10cSrcweir     if (mxParentAccessible.is())
1057*cdf0e10cSrcweir     {
1058*cdf0e10cSrcweir         const Reference<XAccessibleContext> xContext (mxParentAccessible->getAccessibleContext());
1059*cdf0e10cSrcweir         for (sal_Int32 nIndex=0,nCount=xContext->getAccessibleChildCount();
1060*cdf0e10cSrcweir              nIndex<nCount;
1061*cdf0e10cSrcweir              ++nIndex)
1062*cdf0e10cSrcweir         {
1063*cdf0e10cSrcweir             if (xContext->getAccessibleChild(nIndex) == xThis)
1064*cdf0e10cSrcweir                 return nIndex;
1065*cdf0e10cSrcweir         }
1066*cdf0e10cSrcweir     }
1067*cdf0e10cSrcweir 
1068*cdf0e10cSrcweir     return 0;
1069*cdf0e10cSrcweir }
1070*cdf0e10cSrcweir 
1071*cdf0e10cSrcweir 
1072*cdf0e10cSrcweir 
1073*cdf0e10cSrcweir 
1074*cdf0e10cSrcweir sal_Int16 SAL_CALL
1075*cdf0e10cSrcweir     PresenterAccessible::AccessibleObject::getAccessibleRole (void)
1076*cdf0e10cSrcweir     throw (RuntimeException)
1077*cdf0e10cSrcweir {
1078*cdf0e10cSrcweir     ThrowIfDisposed();
1079*cdf0e10cSrcweir 
1080*cdf0e10cSrcweir     return mnRole;
1081*cdf0e10cSrcweir }
1082*cdf0e10cSrcweir 
1083*cdf0e10cSrcweir 
1084*cdf0e10cSrcweir 
1085*cdf0e10cSrcweir 
1086*cdf0e10cSrcweir OUString SAL_CALL
1087*cdf0e10cSrcweir     PresenterAccessible::AccessibleObject::getAccessibleDescription (void)
1088*cdf0e10cSrcweir     throw (RuntimeException)
1089*cdf0e10cSrcweir {
1090*cdf0e10cSrcweir     ThrowIfDisposed();
1091*cdf0e10cSrcweir 
1092*cdf0e10cSrcweir     return msName;
1093*cdf0e10cSrcweir }
1094*cdf0e10cSrcweir 
1095*cdf0e10cSrcweir 
1096*cdf0e10cSrcweir 
1097*cdf0e10cSrcweir 
1098*cdf0e10cSrcweir OUString SAL_CALL
1099*cdf0e10cSrcweir     PresenterAccessible::AccessibleObject::getAccessibleName (void)
1100*cdf0e10cSrcweir     throw (cssu::RuntimeException)
1101*cdf0e10cSrcweir {
1102*cdf0e10cSrcweir     ThrowIfDisposed();
1103*cdf0e10cSrcweir 
1104*cdf0e10cSrcweir     return msName;
1105*cdf0e10cSrcweir }
1106*cdf0e10cSrcweir 
1107*cdf0e10cSrcweir 
1108*cdf0e10cSrcweir 
1109*cdf0e10cSrcweir 
1110*cdf0e10cSrcweir Reference<XAccessibleRelationSet> SAL_CALL
1111*cdf0e10cSrcweir     PresenterAccessible::AccessibleObject::getAccessibleRelationSet (void)
1112*cdf0e10cSrcweir     throw (RuntimeException)
1113*cdf0e10cSrcweir {
1114*cdf0e10cSrcweir     ThrowIfDisposed();
1115*cdf0e10cSrcweir 
1116*cdf0e10cSrcweir     return NULL;
1117*cdf0e10cSrcweir }
1118*cdf0e10cSrcweir 
1119*cdf0e10cSrcweir 
1120*cdf0e10cSrcweir 
1121*cdf0e10cSrcweir 
1122*cdf0e10cSrcweir Reference<XAccessibleStateSet> SAL_CALL
1123*cdf0e10cSrcweir     PresenterAccessible::AccessibleObject::getAccessibleStateSet (void)
1124*cdf0e10cSrcweir     throw (RuntimeException)
1125*cdf0e10cSrcweir {
1126*cdf0e10cSrcweir     ThrowIfDisposed();
1127*cdf0e10cSrcweir 
1128*cdf0e10cSrcweir     return Reference<XAccessibleStateSet>(new AccessibleStateSet(mnStateSet));
1129*cdf0e10cSrcweir }
1130*cdf0e10cSrcweir 
1131*cdf0e10cSrcweir 
1132*cdf0e10cSrcweir 
1133*cdf0e10cSrcweir 
1134*cdf0e10cSrcweir lang::Locale SAL_CALL
1135*cdf0e10cSrcweir     PresenterAccessible::AccessibleObject::getLocale (void)
1136*cdf0e10cSrcweir     throw (RuntimeException,
1137*cdf0e10cSrcweir         IllegalAccessibleComponentStateException)
1138*cdf0e10cSrcweir {
1139*cdf0e10cSrcweir     ThrowIfDisposed();
1140*cdf0e10cSrcweir 
1141*cdf0e10cSrcweir     if (mxParentAccessible.is())
1142*cdf0e10cSrcweir     {
1143*cdf0e10cSrcweir         Reference<XAccessibleContext> xParentContext (mxParentAccessible->getAccessibleContext());
1144*cdf0e10cSrcweir         if (xParentContext.is())
1145*cdf0e10cSrcweir             return xParentContext->getLocale();
1146*cdf0e10cSrcweir     }
1147*cdf0e10cSrcweir     return maLocale;
1148*cdf0e10cSrcweir }
1149*cdf0e10cSrcweir 
1150*cdf0e10cSrcweir 
1151*cdf0e10cSrcweir 
1152*cdf0e10cSrcweir 
1153*cdf0e10cSrcweir //-----  XAccessibleComponent  ------------------------------------------------
1154*cdf0e10cSrcweir 
1155*cdf0e10cSrcweir sal_Bool SAL_CALL PresenterAccessible::AccessibleObject::containsPoint (
1156*cdf0e10cSrcweir     const awt::Point& rPoint)
1157*cdf0e10cSrcweir     throw (RuntimeException)
1158*cdf0e10cSrcweir {
1159*cdf0e10cSrcweir     ThrowIfDisposed();
1160*cdf0e10cSrcweir 
1161*cdf0e10cSrcweir     if (mxContentWindow.is())
1162*cdf0e10cSrcweir     {
1163*cdf0e10cSrcweir         const awt::Rectangle aBox (getBounds());
1164*cdf0e10cSrcweir         return rPoint.X>=aBox.X
1165*cdf0e10cSrcweir             && rPoint.Y>=aBox.Y
1166*cdf0e10cSrcweir             && rPoint.X<aBox.X+aBox.Width
1167*cdf0e10cSrcweir             && rPoint.Y<aBox.Y+aBox.Height;
1168*cdf0e10cSrcweir     }
1169*cdf0e10cSrcweir     else
1170*cdf0e10cSrcweir         return false;
1171*cdf0e10cSrcweir }
1172*cdf0e10cSrcweir 
1173*cdf0e10cSrcweir 
1174*cdf0e10cSrcweir 
1175*cdf0e10cSrcweir 
1176*cdf0e10cSrcweir Reference<XAccessible> SAL_CALL
1177*cdf0e10cSrcweir     PresenterAccessible::AccessibleObject::getAccessibleAtPoint (const awt::Point& rPoint)
1178*cdf0e10cSrcweir     throw (RuntimeException)
1179*cdf0e10cSrcweir {
1180*cdf0e10cSrcweir     (void)rPoint;
1181*cdf0e10cSrcweir     ThrowIfDisposed();
1182*cdf0e10cSrcweir 
1183*cdf0e10cSrcweir     return Reference<XAccessible>();
1184*cdf0e10cSrcweir }
1185*cdf0e10cSrcweir 
1186*cdf0e10cSrcweir 
1187*cdf0e10cSrcweir 
1188*cdf0e10cSrcweir 
1189*cdf0e10cSrcweir awt::Rectangle SAL_CALL PresenterAccessible::AccessibleObject::getBounds (void)
1190*cdf0e10cSrcweir     throw (RuntimeException)
1191*cdf0e10cSrcweir {
1192*cdf0e10cSrcweir     ThrowIfDisposed();
1193*cdf0e10cSrcweir 
1194*cdf0e10cSrcweir     awt::Rectangle aBox;
1195*cdf0e10cSrcweir 
1196*cdf0e10cSrcweir     const awt::Point aLocation (GetRelativeLocation());
1197*cdf0e10cSrcweir     const awt::Size aSize (GetSize());
1198*cdf0e10cSrcweir 
1199*cdf0e10cSrcweir     return awt::Rectangle (aLocation.X, aLocation.Y, aSize.Width, aSize.Height);
1200*cdf0e10cSrcweir }
1201*cdf0e10cSrcweir 
1202*cdf0e10cSrcweir 
1203*cdf0e10cSrcweir 
1204*cdf0e10cSrcweir 
1205*cdf0e10cSrcweir awt::Point SAL_CALL PresenterAccessible::AccessibleObject::getLocation (void)
1206*cdf0e10cSrcweir     throw (RuntimeException)
1207*cdf0e10cSrcweir {
1208*cdf0e10cSrcweir     ThrowIfDisposed();
1209*cdf0e10cSrcweir 
1210*cdf0e10cSrcweir     const awt::Point aLocation (GetRelativeLocation());
1211*cdf0e10cSrcweir 
1212*cdf0e10cSrcweir     return aLocation;
1213*cdf0e10cSrcweir }
1214*cdf0e10cSrcweir 
1215*cdf0e10cSrcweir 
1216*cdf0e10cSrcweir 
1217*cdf0e10cSrcweir 
1218*cdf0e10cSrcweir awt::Point SAL_CALL PresenterAccessible::AccessibleObject::getLocationOnScreen (void)
1219*cdf0e10cSrcweir     throw (RuntimeException)
1220*cdf0e10cSrcweir {
1221*cdf0e10cSrcweir     ThrowIfDisposed();
1222*cdf0e10cSrcweir 
1223*cdf0e10cSrcweir     awt::Point aRelativeLocation (GetRelativeLocation());
1224*cdf0e10cSrcweir     awt::Point aParentLocationOnScreen (GetAbsoluteParentLocation());
1225*cdf0e10cSrcweir 
1226*cdf0e10cSrcweir     return awt::Point(
1227*cdf0e10cSrcweir         aRelativeLocation.X + aParentLocationOnScreen.X,
1228*cdf0e10cSrcweir         aRelativeLocation.Y + aParentLocationOnScreen.Y);
1229*cdf0e10cSrcweir }
1230*cdf0e10cSrcweir 
1231*cdf0e10cSrcweir 
1232*cdf0e10cSrcweir 
1233*cdf0e10cSrcweir 
1234*cdf0e10cSrcweir awt::Size SAL_CALL PresenterAccessible::AccessibleObject::getSize (void)
1235*cdf0e10cSrcweir     throw (RuntimeException)
1236*cdf0e10cSrcweir {
1237*cdf0e10cSrcweir     ThrowIfDisposed();
1238*cdf0e10cSrcweir 
1239*cdf0e10cSrcweir     const awt::Size aSize (GetSize());
1240*cdf0e10cSrcweir 
1241*cdf0e10cSrcweir     return aSize;
1242*cdf0e10cSrcweir }
1243*cdf0e10cSrcweir 
1244*cdf0e10cSrcweir 
1245*cdf0e10cSrcweir 
1246*cdf0e10cSrcweir 
1247*cdf0e10cSrcweir void SAL_CALL PresenterAccessible::AccessibleObject::grabFocus (void)
1248*cdf0e10cSrcweir     throw (RuntimeException)
1249*cdf0e10cSrcweir {
1250*cdf0e10cSrcweir     ThrowIfDisposed();
1251*cdf0e10cSrcweir     if (mxBorderWindow.is())
1252*cdf0e10cSrcweir         mxBorderWindow->setFocus();
1253*cdf0e10cSrcweir     else if (mxContentWindow.is())
1254*cdf0e10cSrcweir         mxContentWindow->setFocus();
1255*cdf0e10cSrcweir }
1256*cdf0e10cSrcweir 
1257*cdf0e10cSrcweir 
1258*cdf0e10cSrcweir 
1259*cdf0e10cSrcweir 
1260*cdf0e10cSrcweir sal_Int32 SAL_CALL PresenterAccessible::AccessibleObject::getForeground (void)
1261*cdf0e10cSrcweir     throw (RuntimeException)
1262*cdf0e10cSrcweir {
1263*cdf0e10cSrcweir     ThrowIfDisposed();
1264*cdf0e10cSrcweir 
1265*cdf0e10cSrcweir     return 0x00ffffff;
1266*cdf0e10cSrcweir }
1267*cdf0e10cSrcweir 
1268*cdf0e10cSrcweir 
1269*cdf0e10cSrcweir 
1270*cdf0e10cSrcweir 
1271*cdf0e10cSrcweir sal_Int32 SAL_CALL PresenterAccessible::AccessibleObject::getBackground (void)
1272*cdf0e10cSrcweir     throw (RuntimeException)
1273*cdf0e10cSrcweir {
1274*cdf0e10cSrcweir     ThrowIfDisposed();
1275*cdf0e10cSrcweir 
1276*cdf0e10cSrcweir     return 0x00000000;
1277*cdf0e10cSrcweir }
1278*cdf0e10cSrcweir 
1279*cdf0e10cSrcweir 
1280*cdf0e10cSrcweir 
1281*cdf0e10cSrcweir 
1282*cdf0e10cSrcweir //----- XAccessibleEventBroadcaster -------------------------------------------
1283*cdf0e10cSrcweir 
1284*cdf0e10cSrcweir void SAL_CALL PresenterAccessible::AccessibleObject::addEventListener (
1285*cdf0e10cSrcweir     const Reference<XAccessibleEventListener>& rxListener)
1286*cdf0e10cSrcweir     throw (RuntimeException)
1287*cdf0e10cSrcweir {
1288*cdf0e10cSrcweir 	if (rxListener.is())
1289*cdf0e10cSrcweir     {
1290*cdf0e10cSrcweir         const osl::MutexGuard aGuard(m_aMutex);
1291*cdf0e10cSrcweir 
1292*cdf0e10cSrcweir         if (IsDisposed())
1293*cdf0e10cSrcweir         {
1294*cdf0e10cSrcweir             uno::Reference<uno::XInterface> xThis (static_cast<XWeak*>(this), UNO_QUERY);
1295*cdf0e10cSrcweir 		    rxListener->disposing (lang::EventObject(xThis));
1296*cdf0e10cSrcweir 	    }
1297*cdf0e10cSrcweir         else
1298*cdf0e10cSrcweir         {
1299*cdf0e10cSrcweir             maListeners.push_back(rxListener);
1300*cdf0e10cSrcweir         }
1301*cdf0e10cSrcweir     }
1302*cdf0e10cSrcweir }
1303*cdf0e10cSrcweir 
1304*cdf0e10cSrcweir 
1305*cdf0e10cSrcweir 
1306*cdf0e10cSrcweir 
1307*cdf0e10cSrcweir void SAL_CALL PresenterAccessible::AccessibleObject::removeEventListener (
1308*cdf0e10cSrcweir     const Reference<XAccessibleEventListener>& rxListener)
1309*cdf0e10cSrcweir     throw (RuntimeException)
1310*cdf0e10cSrcweir {
1311*cdf0e10cSrcweir     ThrowIfDisposed();
1312*cdf0e10cSrcweir 	if (rxListener.is())
1313*cdf0e10cSrcweir 	{
1314*cdf0e10cSrcweir         const osl::MutexGuard aGuard(m_aMutex);
1315*cdf0e10cSrcweir 
1316*cdf0e10cSrcweir         maListeners.erase(std::remove(maListeners.begin(), maListeners.end(), rxListener));
1317*cdf0e10cSrcweir 	}
1318*cdf0e10cSrcweir }
1319*cdf0e10cSrcweir 
1320*cdf0e10cSrcweir 
1321*cdf0e10cSrcweir 
1322*cdf0e10cSrcweir 
1323*cdf0e10cSrcweir //----- XWindowListener ---------------------------------------------------
1324*cdf0e10cSrcweir 
1325*cdf0e10cSrcweir void SAL_CALL PresenterAccessible::AccessibleObject::windowResized (
1326*cdf0e10cSrcweir     const css::awt::WindowEvent& rEvent)
1327*cdf0e10cSrcweir     throw (cssu::RuntimeException)
1328*cdf0e10cSrcweir {
1329*cdf0e10cSrcweir     (void)rEvent;
1330*cdf0e10cSrcweir 
1331*cdf0e10cSrcweir     FireAccessibleEvent(AccessibleEventId::BOUNDRECT_CHANGED, Any(), Any());
1332*cdf0e10cSrcweir }
1333*cdf0e10cSrcweir 
1334*cdf0e10cSrcweir 
1335*cdf0e10cSrcweir 
1336*cdf0e10cSrcweir 
1337*cdf0e10cSrcweir void SAL_CALL PresenterAccessible::AccessibleObject::windowMoved (
1338*cdf0e10cSrcweir     const css::awt::WindowEvent& rEvent)
1339*cdf0e10cSrcweir     throw (cssu::RuntimeException)
1340*cdf0e10cSrcweir {
1341*cdf0e10cSrcweir     (void)rEvent;
1342*cdf0e10cSrcweir 
1343*cdf0e10cSrcweir     FireAccessibleEvent(AccessibleEventId::BOUNDRECT_CHANGED, Any(), Any());
1344*cdf0e10cSrcweir }
1345*cdf0e10cSrcweir 
1346*cdf0e10cSrcweir 
1347*cdf0e10cSrcweir 
1348*cdf0e10cSrcweir 
1349*cdf0e10cSrcweir void SAL_CALL PresenterAccessible::AccessibleObject::windowShown (
1350*cdf0e10cSrcweir     const css::lang::EventObject& rEvent)
1351*cdf0e10cSrcweir     throw (cssu::RuntimeException)
1352*cdf0e10cSrcweir {
1353*cdf0e10cSrcweir     (void)rEvent;
1354*cdf0e10cSrcweir     UpdateStateSet();
1355*cdf0e10cSrcweir }
1356*cdf0e10cSrcweir 
1357*cdf0e10cSrcweir 
1358*cdf0e10cSrcweir 
1359*cdf0e10cSrcweir 
1360*cdf0e10cSrcweir void SAL_CALL PresenterAccessible::AccessibleObject::windowHidden (
1361*cdf0e10cSrcweir     const css::lang::EventObject& rEvent)
1362*cdf0e10cSrcweir     throw (cssu::RuntimeException)
1363*cdf0e10cSrcweir {
1364*cdf0e10cSrcweir     (void)rEvent;
1365*cdf0e10cSrcweir     UpdateStateSet();
1366*cdf0e10cSrcweir }
1367*cdf0e10cSrcweir 
1368*cdf0e10cSrcweir 
1369*cdf0e10cSrcweir 
1370*cdf0e10cSrcweir 
1371*cdf0e10cSrcweir //----- XEventListener --------------------------------------------------------
1372*cdf0e10cSrcweir 
1373*cdf0e10cSrcweir void SAL_CALL PresenterAccessible::AccessibleObject::disposing (const css::lang::EventObject& rEvent)
1374*cdf0e10cSrcweir     throw (cssu::RuntimeException)
1375*cdf0e10cSrcweir {
1376*cdf0e10cSrcweir     if (rEvent.Source == mxContentWindow)
1377*cdf0e10cSrcweir     {
1378*cdf0e10cSrcweir         mxContentWindow = NULL;
1379*cdf0e10cSrcweir         mxBorderWindow = NULL;
1380*cdf0e10cSrcweir     }
1381*cdf0e10cSrcweir     else
1382*cdf0e10cSrcweir     {
1383*cdf0e10cSrcweir         SetWindow(NULL, NULL);
1384*cdf0e10cSrcweir     }
1385*cdf0e10cSrcweir }
1386*cdf0e10cSrcweir 
1387*cdf0e10cSrcweir 
1388*cdf0e10cSrcweir 
1389*cdf0e10cSrcweir 
1390*cdf0e10cSrcweir //----- private ---------------------------------------------------------------
1391*cdf0e10cSrcweir 
1392*cdf0e10cSrcweir bool PresenterAccessible::AccessibleObject::GetWindowState (const sal_Int16 nType) const
1393*cdf0e10cSrcweir {
1394*cdf0e10cSrcweir     switch (nType)
1395*cdf0e10cSrcweir     {
1396*cdf0e10cSrcweir         case AccessibleStateType::ENABLED:
1397*cdf0e10cSrcweir             return mxContentWindow.is() && mxContentWindow->isEnabled();
1398*cdf0e10cSrcweir 
1399*cdf0e10cSrcweir         case AccessibleStateType::FOCUSABLE:
1400*cdf0e10cSrcweir             return true;
1401*cdf0e10cSrcweir 
1402*cdf0e10cSrcweir         case AccessibleStateType::FOCUSED:
1403*cdf0e10cSrcweir             return mbIsFocused;
1404*cdf0e10cSrcweir 
1405*cdf0e10cSrcweir         case AccessibleStateType::SHOWING:
1406*cdf0e10cSrcweir             return mxContentWindow.is() && mxContentWindow->isVisible();
1407*cdf0e10cSrcweir 
1408*cdf0e10cSrcweir         default:
1409*cdf0e10cSrcweir             return false;
1410*cdf0e10cSrcweir     }
1411*cdf0e10cSrcweir }
1412*cdf0e10cSrcweir 
1413*cdf0e10cSrcweir 
1414*cdf0e10cSrcweir 
1415*cdf0e10cSrcweir 
1416*cdf0e10cSrcweir void PresenterAccessible::AccessibleObject::UpdateStateSet (void)
1417*cdf0e10cSrcweir {
1418*cdf0e10cSrcweir     UpdateState(AccessibleStateType::FOCUSABLE, true);
1419*cdf0e10cSrcweir     UpdateState(AccessibleStateType::VISIBLE, true);
1420*cdf0e10cSrcweir     UpdateState(AccessibleStateType::ENABLED, true);
1421*cdf0e10cSrcweir     UpdateState(AccessibleStateType::MULTI_LINE, true);
1422*cdf0e10cSrcweir     UpdateState(AccessibleStateType::SENSITIVE, true);
1423*cdf0e10cSrcweir 
1424*cdf0e10cSrcweir     UpdateState(AccessibleStateType::ENABLED, GetWindowState(AccessibleStateType::ENABLED));
1425*cdf0e10cSrcweir     UpdateState(AccessibleStateType::FOCUSED, GetWindowState(AccessibleStateType::FOCUSED));
1426*cdf0e10cSrcweir     UpdateState(AccessibleStateType::SHOWING, GetWindowState(AccessibleStateType::SHOWING));
1427*cdf0e10cSrcweir     //    UpdateState(AccessibleStateType::ACTIVE, GetWindowState(AccessibleStateType::ACTIVE));
1428*cdf0e10cSrcweir }
1429*cdf0e10cSrcweir 
1430*cdf0e10cSrcweir 
1431*cdf0e10cSrcweir 
1432*cdf0e10cSrcweir 
1433*cdf0e10cSrcweir void PresenterAccessible::AccessibleObject::UpdateState(
1434*cdf0e10cSrcweir     const sal_Int16 nState,
1435*cdf0e10cSrcweir     const bool bValue)
1436*cdf0e10cSrcweir {
1437*cdf0e10cSrcweir     const sal_uInt32 nStateMask (AccessibleStateSet::GetStateMask(nState));
1438*cdf0e10cSrcweir     if (((mnStateSet & nStateMask)!=0) != bValue)
1439*cdf0e10cSrcweir     {
1440*cdf0e10cSrcweir         if (bValue)
1441*cdf0e10cSrcweir         {
1442*cdf0e10cSrcweir             mnStateSet |= nStateMask;
1443*cdf0e10cSrcweir             FireAccessibleEvent(AccessibleEventId::STATE_CHANGED, Any(), Any(nState));
1444*cdf0e10cSrcweir         }
1445*cdf0e10cSrcweir         else
1446*cdf0e10cSrcweir         {
1447*cdf0e10cSrcweir             mnStateSet &= ~nStateMask;
1448*cdf0e10cSrcweir             FireAccessibleEvent(AccessibleEventId::STATE_CHANGED, Any(nState), Any());
1449*cdf0e10cSrcweir         }
1450*cdf0e10cSrcweir     }
1451*cdf0e10cSrcweir }
1452*cdf0e10cSrcweir 
1453*cdf0e10cSrcweir 
1454*cdf0e10cSrcweir 
1455*cdf0e10cSrcweir 
1456*cdf0e10cSrcweir void PresenterAccessible::AccessibleObject::AddChild (
1457*cdf0e10cSrcweir     const ::rtl::Reference<AccessibleObject>& rpChild)
1458*cdf0e10cSrcweir {
1459*cdf0e10cSrcweir     maChildren.push_back(rpChild);
1460*cdf0e10cSrcweir     rpChild->SetAccessibleParent(this);
1461*cdf0e10cSrcweir     FireAccessibleEvent(AccessibleEventId::INVALIDATE_ALL_CHILDREN, Any(), Any());
1462*cdf0e10cSrcweir }
1463*cdf0e10cSrcweir 
1464*cdf0e10cSrcweir 
1465*cdf0e10cSrcweir 
1466*cdf0e10cSrcweir 
1467*cdf0e10cSrcweir void PresenterAccessible::AccessibleObject::RemoveChild (
1468*cdf0e10cSrcweir     const ::rtl::Reference<AccessibleObject>& rpChild)
1469*cdf0e10cSrcweir {
1470*cdf0e10cSrcweir     rpChild->SetAccessibleParent(Reference<XAccessible>());
1471*cdf0e10cSrcweir     maChildren.erase(::std::find(maChildren.begin(), maChildren.end(), rpChild));
1472*cdf0e10cSrcweir     FireAccessibleEvent(AccessibleEventId::INVALIDATE_ALL_CHILDREN, Any(), Any());
1473*cdf0e10cSrcweir }
1474*cdf0e10cSrcweir 
1475*cdf0e10cSrcweir 
1476*cdf0e10cSrcweir 
1477*cdf0e10cSrcweir 
1478*cdf0e10cSrcweir void PresenterAccessible::AccessibleObject::SetIsFocused (const bool bIsFocused)
1479*cdf0e10cSrcweir {
1480*cdf0e10cSrcweir     if (mbIsFocused != bIsFocused)
1481*cdf0e10cSrcweir     {
1482*cdf0e10cSrcweir         mbIsFocused = bIsFocused;
1483*cdf0e10cSrcweir         UpdateStateSet();
1484*cdf0e10cSrcweir     }
1485*cdf0e10cSrcweir }
1486*cdf0e10cSrcweir 
1487*cdf0e10cSrcweir 
1488*cdf0e10cSrcweir 
1489*cdf0e10cSrcweir 
1490*cdf0e10cSrcweir void PresenterAccessible::AccessibleObject::SetAccessibleName (const ::rtl::OUString& rsName)
1491*cdf0e10cSrcweir {
1492*cdf0e10cSrcweir     if (msName != rsName)
1493*cdf0e10cSrcweir     {
1494*cdf0e10cSrcweir         const OUString sOldName(msName);
1495*cdf0e10cSrcweir         msName = rsName;
1496*cdf0e10cSrcweir         FireAccessibleEvent(AccessibleEventId::NAME_CHANGED, Any(sOldName), Any(msName));
1497*cdf0e10cSrcweir     }
1498*cdf0e10cSrcweir }
1499*cdf0e10cSrcweir 
1500*cdf0e10cSrcweir 
1501*cdf0e10cSrcweir 
1502*cdf0e10cSrcweir 
1503*cdf0e10cSrcweir void PresenterAccessible::AccessibleObject::FireAccessibleEvent (
1504*cdf0e10cSrcweir     const sal_Int16 nEventId,
1505*cdf0e10cSrcweir     const uno::Any& rOldValue,
1506*cdf0e10cSrcweir     const uno::Any& rNewValue )
1507*cdf0e10cSrcweir {
1508*cdf0e10cSrcweir     AccessibleEventObject aEventObject;
1509*cdf0e10cSrcweir 
1510*cdf0e10cSrcweir     aEventObject.Source = Reference<XWeak>(this);
1511*cdf0e10cSrcweir     aEventObject.EventId = nEventId;
1512*cdf0e10cSrcweir     aEventObject.NewValue = rNewValue;
1513*cdf0e10cSrcweir     aEventObject.OldValue = rOldValue;
1514*cdf0e10cSrcweir 
1515*cdf0e10cSrcweir     ::std::vector<Reference<XAccessibleEventListener> > aListenerCopy(maListeners);
1516*cdf0e10cSrcweir     for (::std::vector<Reference<XAccessibleEventListener> >::const_iterator
1517*cdf0e10cSrcweir              iListener(aListenerCopy.begin()),
1518*cdf0e10cSrcweir              iEnd(aListenerCopy.end());
1519*cdf0e10cSrcweir          iListener!=iEnd;
1520*cdf0e10cSrcweir          ++iListener)
1521*cdf0e10cSrcweir     {
1522*cdf0e10cSrcweir         try
1523*cdf0e10cSrcweir         {
1524*cdf0e10cSrcweir             (*iListener)->notifyEvent(aEventObject);
1525*cdf0e10cSrcweir         }
1526*cdf0e10cSrcweir         catch(lang::DisposedException&)
1527*cdf0e10cSrcweir         {
1528*cdf0e10cSrcweir             // Listener has been disposed and should have been removed
1529*cdf0e10cSrcweir             // already.
1530*cdf0e10cSrcweir             removeEventListener(*iListener);
1531*cdf0e10cSrcweir         }
1532*cdf0e10cSrcweir         catch(Exception&)
1533*cdf0e10cSrcweir         {
1534*cdf0e10cSrcweir             // Ignore all other exceptions and assume that they are
1535*cdf0e10cSrcweir             // caused by a temporary problem.
1536*cdf0e10cSrcweir         }
1537*cdf0e10cSrcweir     }
1538*cdf0e10cSrcweir }
1539*cdf0e10cSrcweir 
1540*cdf0e10cSrcweir 
1541*cdf0e10cSrcweir 
1542*cdf0e10cSrcweir awt::Point PresenterAccessible::AccessibleObject::GetRelativeLocation (void)
1543*cdf0e10cSrcweir {
1544*cdf0e10cSrcweir     awt::Point aLocation;
1545*cdf0e10cSrcweir     if (mxContentWindow.is())
1546*cdf0e10cSrcweir     {
1547*cdf0e10cSrcweir         const awt::Rectangle aContentBox (mxContentWindow->getPosSize());
1548*cdf0e10cSrcweir         aLocation.X = aContentBox.X;
1549*cdf0e10cSrcweir         aLocation.Y = aContentBox.Y;
1550*cdf0e10cSrcweir         if (mxBorderWindow.is())
1551*cdf0e10cSrcweir         {
1552*cdf0e10cSrcweir             const awt::Rectangle aBorderBox (mxBorderWindow->getPosSize());
1553*cdf0e10cSrcweir             aLocation.X += aBorderBox.X;
1554*cdf0e10cSrcweir             aLocation.Y += aBorderBox.Y;
1555*cdf0e10cSrcweir         }
1556*cdf0e10cSrcweir     }
1557*cdf0e10cSrcweir     return aLocation;
1558*cdf0e10cSrcweir }
1559*cdf0e10cSrcweir 
1560*cdf0e10cSrcweir 
1561*cdf0e10cSrcweir 
1562*cdf0e10cSrcweir 
1563*cdf0e10cSrcweir awt::Size PresenterAccessible::AccessibleObject::GetSize (void)
1564*cdf0e10cSrcweir {
1565*cdf0e10cSrcweir     if (mxContentWindow.is())
1566*cdf0e10cSrcweir     {
1567*cdf0e10cSrcweir         const awt::Rectangle aBox (mxContentWindow->getPosSize());
1568*cdf0e10cSrcweir         return awt::Size(aBox.Width, aBox.Height);
1569*cdf0e10cSrcweir     }
1570*cdf0e10cSrcweir     else
1571*cdf0e10cSrcweir         return awt::Size();
1572*cdf0e10cSrcweir }
1573*cdf0e10cSrcweir 
1574*cdf0e10cSrcweir 
1575*cdf0e10cSrcweir 
1576*cdf0e10cSrcweir 
1577*cdf0e10cSrcweir awt::Point PresenterAccessible::AccessibleObject::GetAbsoluteParentLocation (void)
1578*cdf0e10cSrcweir {
1579*cdf0e10cSrcweir     Reference<XAccessibleComponent> xParentComponent;
1580*cdf0e10cSrcweir     if (mxParentAccessible.is())
1581*cdf0e10cSrcweir         xParentComponent = Reference<XAccessibleComponent>(
1582*cdf0e10cSrcweir             mxParentAccessible->getAccessibleContext(), UNO_QUERY);
1583*cdf0e10cSrcweir     if (xParentComponent.is())
1584*cdf0e10cSrcweir         return xParentComponent->getLocationOnScreen();
1585*cdf0e10cSrcweir     else
1586*cdf0e10cSrcweir         return awt::Point();
1587*cdf0e10cSrcweir }
1588*cdf0e10cSrcweir 
1589*cdf0e10cSrcweir 
1590*cdf0e10cSrcweir 
1591*cdf0e10cSrcweir 
1592*cdf0e10cSrcweir sal_Bool PresenterAccessible::AccessibleObject::IsDisposed (void) const
1593*cdf0e10cSrcweir {
1594*cdf0e10cSrcweir 	return (rBHelper.bDisposed || rBHelper.bInDispose);
1595*cdf0e10cSrcweir }
1596*cdf0e10cSrcweir 
1597*cdf0e10cSrcweir 
1598*cdf0e10cSrcweir 
1599*cdf0e10cSrcweir 
1600*cdf0e10cSrcweir void PresenterAccessible::AccessibleObject::ThrowIfDisposed (void) const
1601*cdf0e10cSrcweir     throw (lang::DisposedException)
1602*cdf0e10cSrcweir {
1603*cdf0e10cSrcweir 	if (rBHelper.bDisposed || rBHelper.bInDispose)
1604*cdf0e10cSrcweir         ThrowException("object has already been disposed", ET_Disposed);
1605*cdf0e10cSrcweir }
1606*cdf0e10cSrcweir 
1607*cdf0e10cSrcweir 
1608*cdf0e10cSrcweir 
1609*cdf0e10cSrcweir 
1610*cdf0e10cSrcweir void PresenterAccessible::AccessibleObject::ThrowException (
1611*cdf0e10cSrcweir     const sal_Char* pMessage,
1612*cdf0e10cSrcweir     const ExceptionType eExceptionType) const
1613*cdf0e10cSrcweir {
1614*cdf0e10cSrcweir     const OUString sMessage (OUString(A2S("PresenterAccessible: ")) + OUString(A2S(pMessage)));
1615*cdf0e10cSrcweir     const Reference<XInterface> xObject (
1616*cdf0e10cSrcweir         const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
1617*cdf0e10cSrcweir     switch (eExceptionType)
1618*cdf0e10cSrcweir     {
1619*cdf0e10cSrcweir         default:
1620*cdf0e10cSrcweir         case ET_Runtime:
1621*cdf0e10cSrcweir             throw RuntimeException(sMessage, xObject);
1622*cdf0e10cSrcweir         case ET_Disposed:
1623*cdf0e10cSrcweir             throw lang::DisposedException(sMessage, xObject);
1624*cdf0e10cSrcweir         case ET_IndexOutOfBounds:
1625*cdf0e10cSrcweir             throw lang::IndexOutOfBoundsException(sMessage, xObject);
1626*cdf0e10cSrcweir     }
1627*cdf0e10cSrcweir }
1628*cdf0e10cSrcweir 
1629*cdf0e10cSrcweir 
1630*cdf0e10cSrcweir 
1631*cdf0e10cSrcweir 
1632*cdf0e10cSrcweir 
1633*cdf0e10cSrcweir //===== AccessibleStateSet ====================================================
1634*cdf0e10cSrcweir 
1635*cdf0e10cSrcweir AccessibleStateSet::AccessibleStateSet (const sal_Int32 nStateSet)
1636*cdf0e10cSrcweir     : AccessibleStateSetInterfaceBase(m_aMutex),
1637*cdf0e10cSrcweir       mnStateSet (nStateSet)
1638*cdf0e10cSrcweir {
1639*cdf0e10cSrcweir }
1640*cdf0e10cSrcweir 
1641*cdf0e10cSrcweir 
1642*cdf0e10cSrcweir 
1643*cdf0e10cSrcweir 
1644*cdf0e10cSrcweir AccessibleStateSet::~AccessibleStateSet (void)
1645*cdf0e10cSrcweir {
1646*cdf0e10cSrcweir }
1647*cdf0e10cSrcweir 
1648*cdf0e10cSrcweir 
1649*cdf0e10cSrcweir 
1650*cdf0e10cSrcweir 
1651*cdf0e10cSrcweir sal_uInt32 AccessibleStateSet::GetStateMask (const sal_Int16 nState)
1652*cdf0e10cSrcweir {
1653*cdf0e10cSrcweir     if (nState<0 || nState>=sal_Int16(sizeof(sal_uInt32)*8))
1654*cdf0e10cSrcweir     {
1655*cdf0e10cSrcweir         throw RuntimeException(A2S("AccessibleStateSet::GetStateMask: invalid state"), NULL);
1656*cdf0e10cSrcweir     }
1657*cdf0e10cSrcweir 
1658*cdf0e10cSrcweir     return 1<<nState;
1659*cdf0e10cSrcweir }
1660*cdf0e10cSrcweir 
1661*cdf0e10cSrcweir 
1662*cdf0e10cSrcweir 
1663*cdf0e10cSrcweir 
1664*cdf0e10cSrcweir //----- XAccessibleStateSet ---------------------------------------------------
1665*cdf0e10cSrcweir 
1666*cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleStateSet::isEmpty (void)
1667*cdf0e10cSrcweir     throw (cssu::RuntimeException)
1668*cdf0e10cSrcweir {
1669*cdf0e10cSrcweir     return mnStateSet==0;
1670*cdf0e10cSrcweir }
1671*cdf0e10cSrcweir 
1672*cdf0e10cSrcweir 
1673*cdf0e10cSrcweir 
1674*cdf0e10cSrcweir 
1675*cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleStateSet::contains (sal_Int16 nState)
1676*cdf0e10cSrcweir     throw (cssu::RuntimeException)
1677*cdf0e10cSrcweir {
1678*cdf0e10cSrcweir     return (mnStateSet & GetStateMask(nState)) != 0;
1679*cdf0e10cSrcweir }
1680*cdf0e10cSrcweir 
1681*cdf0e10cSrcweir 
1682*cdf0e10cSrcweir 
1683*cdf0e10cSrcweir 
1684*cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleStateSet::containsAll (const cssu::Sequence<sal_Int16>& rStateSet)
1685*cdf0e10cSrcweir     throw (cssu::RuntimeException)
1686*cdf0e10cSrcweir {
1687*cdf0e10cSrcweir     for (sal_Int32 nIndex=0,nCount=rStateSet.getLength(); nIndex<nCount; ++nIndex)
1688*cdf0e10cSrcweir     {
1689*cdf0e10cSrcweir         if ((mnStateSet & GetStateMask(rStateSet[nIndex])) == 0)
1690*cdf0e10cSrcweir             return sal_False;
1691*cdf0e10cSrcweir     }
1692*cdf0e10cSrcweir     return sal_True;
1693*cdf0e10cSrcweir }
1694*cdf0e10cSrcweir 
1695*cdf0e10cSrcweir 
1696*cdf0e10cSrcweir 
1697*cdf0e10cSrcweir 
1698*cdf0e10cSrcweir cssu::Sequence<sal_Int16> SAL_CALL AccessibleStateSet::getStates (void)
1699*cdf0e10cSrcweir     throw (cssu::RuntimeException)
1700*cdf0e10cSrcweir {
1701*cdf0e10cSrcweir     ::std::vector<sal_Int16> aStates;
1702*cdf0e10cSrcweir     aStates.reserve(sizeof(mnStateSet)*8);
1703*cdf0e10cSrcweir     for (sal_uInt16 nIndex=0; nIndex<sizeof(mnStateSet)*8; ++nIndex)
1704*cdf0e10cSrcweir         if ((mnStateSet & GetStateMask(nIndex)) != 0)
1705*cdf0e10cSrcweir             aStates.push_back(nIndex);
1706*cdf0e10cSrcweir     return Sequence<sal_Int16>(&aStates.front(), aStates.size());
1707*cdf0e10cSrcweir }
1708*cdf0e10cSrcweir 
1709*cdf0e10cSrcweir 
1710*cdf0e10cSrcweir 
1711*cdf0e10cSrcweir 
1712*cdf0e10cSrcweir //===== AccessibleRelationSet =================================================
1713*cdf0e10cSrcweir 
1714*cdf0e10cSrcweir AccessibleRelationSet::AccessibleRelationSet (void)
1715*cdf0e10cSrcweir     : AccessibleRelationSetInterfaceBase(m_aMutex),
1716*cdf0e10cSrcweir       maRelations()
1717*cdf0e10cSrcweir {
1718*cdf0e10cSrcweir }
1719*cdf0e10cSrcweir 
1720*cdf0e10cSrcweir 
1721*cdf0e10cSrcweir 
1722*cdf0e10cSrcweir 
1723*cdf0e10cSrcweir AccessibleRelationSet::~AccessibleRelationSet (void)
1724*cdf0e10cSrcweir {
1725*cdf0e10cSrcweir }
1726*cdf0e10cSrcweir 
1727*cdf0e10cSrcweir 
1728*cdf0e10cSrcweir 
1729*cdf0e10cSrcweir 
1730*cdf0e10cSrcweir void AccessibleRelationSet::AddRelation (
1731*cdf0e10cSrcweir     const sal_Int16 nRelationType,
1732*cdf0e10cSrcweir     const Reference<XInterface>& rxObject)
1733*cdf0e10cSrcweir {
1734*cdf0e10cSrcweir     maRelations.resize(maRelations.size()+1);
1735*cdf0e10cSrcweir     maRelations.back().RelationType = nRelationType;
1736*cdf0e10cSrcweir     maRelations.back().TargetSet.realloc(1);
1737*cdf0e10cSrcweir     maRelations.back().TargetSet[0] = rxObject;
1738*cdf0e10cSrcweir }
1739*cdf0e10cSrcweir 
1740*cdf0e10cSrcweir 
1741*cdf0e10cSrcweir 
1742*cdf0e10cSrcweir 
1743*cdf0e10cSrcweir //----- XAccessibleRelationSet ------------------------------------------------
1744*cdf0e10cSrcweir 
1745*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleRelationSet::getRelationCount (void)
1746*cdf0e10cSrcweir     throw (cssu::RuntimeException)
1747*cdf0e10cSrcweir {
1748*cdf0e10cSrcweir     return maRelations.size();
1749*cdf0e10cSrcweir }
1750*cdf0e10cSrcweir 
1751*cdf0e10cSrcweir 
1752*cdf0e10cSrcweir 
1753*cdf0e10cSrcweir 
1754*cdf0e10cSrcweir AccessibleRelation SAL_CALL AccessibleRelationSet::getRelation (sal_Int32 nIndex)
1755*cdf0e10cSrcweir     throw (cssu::RuntimeException, css::lang::IndexOutOfBoundsException)
1756*cdf0e10cSrcweir {
1757*cdf0e10cSrcweir     if (nIndex<0 && sal_uInt32(nIndex)>=maRelations.size())
1758*cdf0e10cSrcweir         return AccessibleRelation();
1759*cdf0e10cSrcweir     else
1760*cdf0e10cSrcweir         return maRelations[nIndex];
1761*cdf0e10cSrcweir }
1762*cdf0e10cSrcweir 
1763*cdf0e10cSrcweir 
1764*cdf0e10cSrcweir 
1765*cdf0e10cSrcweir 
1766*cdf0e10cSrcweir sal_Bool SAL_CALL AccessibleRelationSet::containsRelation (sal_Int16 nRelationType)
1767*cdf0e10cSrcweir     throw (cssu::RuntimeException)
1768*cdf0e10cSrcweir {
1769*cdf0e10cSrcweir     for (::std::vector<AccessibleRelation>::const_iterator iRelation(maRelations.begin());
1770*cdf0e10cSrcweir          iRelation!=maRelations.end();
1771*cdf0e10cSrcweir          ++iRelation)
1772*cdf0e10cSrcweir     {
1773*cdf0e10cSrcweir         if (iRelation->RelationType == nRelationType)
1774*cdf0e10cSrcweir             return sal_True;
1775*cdf0e10cSrcweir     }
1776*cdf0e10cSrcweir     return sal_False;
1777*cdf0e10cSrcweir }
1778*cdf0e10cSrcweir 
1779*cdf0e10cSrcweir 
1780*cdf0e10cSrcweir 
1781*cdf0e10cSrcweir 
1782*cdf0e10cSrcweir AccessibleRelation SAL_CALL AccessibleRelationSet::getRelationByType (sal_Int16 nRelationType)
1783*cdf0e10cSrcweir     throw (cssu::RuntimeException)
1784*cdf0e10cSrcweir {
1785*cdf0e10cSrcweir     for (::std::vector<AccessibleRelation>::const_iterator iRelation(maRelations.begin());
1786*cdf0e10cSrcweir          iRelation!=maRelations.end();
1787*cdf0e10cSrcweir          ++iRelation)
1788*cdf0e10cSrcweir     {
1789*cdf0e10cSrcweir         if (iRelation->RelationType == nRelationType)
1790*cdf0e10cSrcweir             return *iRelation;
1791*cdf0e10cSrcweir     }
1792*cdf0e10cSrcweir     return AccessibleRelation();
1793*cdf0e10cSrcweir }
1794*cdf0e10cSrcweir 
1795*cdf0e10cSrcweir 
1796*cdf0e10cSrcweir 
1797*cdf0e10cSrcweir 
1798*cdf0e10cSrcweir //===== PresenterAccessible::AccessibleParagraph ==============================
1799*cdf0e10cSrcweir 
1800*cdf0e10cSrcweir PresenterAccessible::AccessibleParagraph::AccessibleParagraph (
1801*cdf0e10cSrcweir     const lang::Locale aLocale,
1802*cdf0e10cSrcweir     const sal_Int16 nRole,
1803*cdf0e10cSrcweir     const OUString& rsName,
1804*cdf0e10cSrcweir     const SharedPresenterTextParagraph& rpParagraph,
1805*cdf0e10cSrcweir     const sal_Int32 nParagraphIndex)
1806*cdf0e10cSrcweir     : PresenterAccessibleParagraphInterfaceBase(aLocale, nRole, rsName),
1807*cdf0e10cSrcweir       mpParagraph(rpParagraph),
1808*cdf0e10cSrcweir       mnParagraphIndex(nParagraphIndex)
1809*cdf0e10cSrcweir {
1810*cdf0e10cSrcweir }
1811*cdf0e10cSrcweir 
1812*cdf0e10cSrcweir 
1813*cdf0e10cSrcweir 
1814*cdf0e10cSrcweir 
1815*cdf0e10cSrcweir PresenterAccessible::AccessibleParagraph::~AccessibleParagraph (void)
1816*cdf0e10cSrcweir {
1817*cdf0e10cSrcweir }
1818*cdf0e10cSrcweir 
1819*cdf0e10cSrcweir 
1820*cdf0e10cSrcweir 
1821*cdf0e10cSrcweir 
1822*cdf0e10cSrcweir //----- XAccessibleContext ----------------------------------------------------
1823*cdf0e10cSrcweir 
1824*cdf0e10cSrcweir Reference<XAccessibleRelationSet> SAL_CALL
1825*cdf0e10cSrcweir     PresenterAccessible::AccessibleParagraph::getAccessibleRelationSet (void)
1826*cdf0e10cSrcweir     throw (RuntimeException)
1827*cdf0e10cSrcweir {
1828*cdf0e10cSrcweir     ThrowIfDisposed();
1829*cdf0e10cSrcweir 
1830*cdf0e10cSrcweir     rtl::Reference<AccessibleRelationSet> pSet (new AccessibleRelationSet);
1831*cdf0e10cSrcweir 
1832*cdf0e10cSrcweir     if (mxParentAccessible.is())
1833*cdf0e10cSrcweir     {
1834*cdf0e10cSrcweir         Reference<XAccessibleContext> xParentContext (mxParentAccessible->getAccessibleContext());
1835*cdf0e10cSrcweir         if (xParentContext.is())
1836*cdf0e10cSrcweir         {
1837*cdf0e10cSrcweir             if (mnParagraphIndex>0)
1838*cdf0e10cSrcweir                 pSet->AddRelation(
1839*cdf0e10cSrcweir                     AccessibleRelationType::CONTENT_FLOWS_FROM,
1840*cdf0e10cSrcweir                     xParentContext->getAccessibleChild(mnParagraphIndex-1));
1841*cdf0e10cSrcweir 
1842*cdf0e10cSrcweir             if (mnParagraphIndex<xParentContext->getAccessibleChildCount()-1)
1843*cdf0e10cSrcweir                 pSet->AddRelation(
1844*cdf0e10cSrcweir                     AccessibleRelationType::CONTENT_FLOWS_TO,
1845*cdf0e10cSrcweir                     xParentContext->getAccessibleChild(mnParagraphIndex+1));
1846*cdf0e10cSrcweir         }
1847*cdf0e10cSrcweir     }
1848*cdf0e10cSrcweir 
1849*cdf0e10cSrcweir     return Reference<XAccessibleRelationSet>(pSet.get());
1850*cdf0e10cSrcweir }
1851*cdf0e10cSrcweir 
1852*cdf0e10cSrcweir 
1853*cdf0e10cSrcweir 
1854*cdf0e10cSrcweir 
1855*cdf0e10cSrcweir 
1856*cdf0e10cSrcweir 
1857*cdf0e10cSrcweir //----- XAccessibleText -------------------------------------------------------
1858*cdf0e10cSrcweir 
1859*cdf0e10cSrcweir sal_Int32 SAL_CALL PresenterAccessible::AccessibleParagraph::getCaretPosition (void)
1860*cdf0e10cSrcweir     throw (cssu::RuntimeException)
1861*cdf0e10cSrcweir {
1862*cdf0e10cSrcweir     ThrowIfDisposed();
1863*cdf0e10cSrcweir 
1864*cdf0e10cSrcweir     sal_Int32 nPosition (-1);
1865*cdf0e10cSrcweir     if (mpParagraph)
1866*cdf0e10cSrcweir         nPosition = mpParagraph->GetCaretPosition();
1867*cdf0e10cSrcweir 
1868*cdf0e10cSrcweir     return nPosition;
1869*cdf0e10cSrcweir }
1870*cdf0e10cSrcweir 
1871*cdf0e10cSrcweir 
1872*cdf0e10cSrcweir 
1873*cdf0e10cSrcweir 
1874*cdf0e10cSrcweir sal_Bool SAL_CALL PresenterAccessible::AccessibleParagraph::setCaretPosition (sal_Int32 nIndex)
1875*cdf0e10cSrcweir     throw (::com::sun::star::lang::IndexOutOfBoundsException, cssu::RuntimeException)
1876*cdf0e10cSrcweir {
1877*cdf0e10cSrcweir     ThrowIfDisposed();
1878*cdf0e10cSrcweir 
1879*cdf0e10cSrcweir     if (mpParagraph)
1880*cdf0e10cSrcweir     {
1881*cdf0e10cSrcweir         mpParagraph->SetCaretPosition(nIndex);
1882*cdf0e10cSrcweir         return sal_True;
1883*cdf0e10cSrcweir     }
1884*cdf0e10cSrcweir     else
1885*cdf0e10cSrcweir         return sal_False;
1886*cdf0e10cSrcweir }
1887*cdf0e10cSrcweir 
1888*cdf0e10cSrcweir 
1889*cdf0e10cSrcweir 
1890*cdf0e10cSrcweir 
1891*cdf0e10cSrcweir sal_Unicode SAL_CALL PresenterAccessible::AccessibleParagraph::getCharacter (sal_Int32 nIndex)
1892*cdf0e10cSrcweir     throw (::com::sun::star::lang::IndexOutOfBoundsException, cssu::RuntimeException)
1893*cdf0e10cSrcweir {
1894*cdf0e10cSrcweir     ThrowIfDisposed();
1895*cdf0e10cSrcweir 
1896*cdf0e10cSrcweir     if (mpParagraph)
1897*cdf0e10cSrcweir         return mpParagraph->GetCharacter(nIndex);
1898*cdf0e10cSrcweir     else
1899*cdf0e10cSrcweir     {
1900*cdf0e10cSrcweir         ThrowException("no text support in current mode", ET_IndexOutOfBounds);
1901*cdf0e10cSrcweir         // The method above throws an exception and the following line is
1902*cdf0e10cSrcweir         // never reached.  But there is at least one compiler that can not
1903*cdf0e10cSrcweir         // detect this and we need the return to make it happy.
1904*cdf0e10cSrcweir         return sal_Unicode();
1905*cdf0e10cSrcweir     }
1906*cdf0e10cSrcweir }
1907*cdf0e10cSrcweir 
1908*cdf0e10cSrcweir 
1909*cdf0e10cSrcweir 
1910*cdf0e10cSrcweir 
1911*cdf0e10cSrcweir Sequence<css::beans::PropertyValue> SAL_CALL
1912*cdf0e10cSrcweir     PresenterAccessible::AccessibleParagraph::getCharacterAttributes (
1913*cdf0e10cSrcweir         ::sal_Int32 nIndex,
1914*cdf0e10cSrcweir         const cssu::Sequence<rtl::OUString>& rRequestedAttributes)
1915*cdf0e10cSrcweir     throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException)
1916*cdf0e10cSrcweir {
1917*cdf0e10cSrcweir     ThrowIfDisposed();
1918*cdf0e10cSrcweir 
1919*cdf0e10cSrcweir #ifdef VERBOSE
1920*cdf0e10cSrcweir     OSL_TRACE("PresenterAccessible::AccessibleParagraph::getCharacterAttributes at %x,%d returns empty set\r",
1921*cdf0e10cSrcweir         this,nIndex);
1922*cdf0e10cSrcweir     for (sal_Int32 nAttributeIndex(0),nAttributeCount(rRequestedAttributes.getLength());
1923*cdf0e10cSrcweir          nAttributeIndex<nAttributeCount;
1924*cdf0e10cSrcweir          ++nAttributeIndex)
1925*cdf0e10cSrcweir     {
1926*cdf0e10cSrcweir         OSL_TRACE("    requested attribute %d is %s\r",
1927*cdf0e10cSrcweir             nAttributeIndex,
1928*cdf0e10cSrcweir             OUStringToOString(rRequestedAttributes[nAttributeIndex], RTL_TEXTENCODING_UTF8).getStr());
1929*cdf0e10cSrcweir     }
1930*cdf0e10cSrcweir #endif
1931*cdf0e10cSrcweir 
1932*cdf0e10cSrcweir     // Character properties are not supported.
1933*cdf0e10cSrcweir     (void)nIndex;
1934*cdf0e10cSrcweir     (void)rRequestedAttributes;
1935*cdf0e10cSrcweir     return Sequence<css::beans::PropertyValue>();
1936*cdf0e10cSrcweir }
1937*cdf0e10cSrcweir 
1938*cdf0e10cSrcweir 
1939*cdf0e10cSrcweir 
1940*cdf0e10cSrcweir 
1941*cdf0e10cSrcweir awt::Rectangle SAL_CALL PresenterAccessible::AccessibleParagraph::getCharacterBounds (
1942*cdf0e10cSrcweir     sal_Int32 nIndex)
1943*cdf0e10cSrcweir     throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException)
1944*cdf0e10cSrcweir {
1945*cdf0e10cSrcweir     ThrowIfDisposed();
1946*cdf0e10cSrcweir 
1947*cdf0e10cSrcweir     awt::Rectangle aCharacterBox;
1948*cdf0e10cSrcweir     if (nIndex < 0)
1949*cdf0e10cSrcweir     {
1950*cdf0e10cSrcweir         ThrowException("invalid text index", ET_IndexOutOfBounds);
1951*cdf0e10cSrcweir     }
1952*cdf0e10cSrcweir     else if (mpParagraph)
1953*cdf0e10cSrcweir     {
1954*cdf0e10cSrcweir         aCharacterBox = mpParagraph->GetCharacterBounds(nIndex, false);
1955*cdf0e10cSrcweir         // Convert coordinates relative to the window origin into absolute
1956*cdf0e10cSrcweir         // screen coordinates.
1957*cdf0e10cSrcweir         const awt::Point aWindowLocationOnScreen (getLocationOnScreen());
1958*cdf0e10cSrcweir         aCharacterBox.X += aWindowLocationOnScreen.X;
1959*cdf0e10cSrcweir         aCharacterBox.Y += aWindowLocationOnScreen.Y;
1960*cdf0e10cSrcweir     }
1961*cdf0e10cSrcweir     else
1962*cdf0e10cSrcweir     {
1963*cdf0e10cSrcweir         ThrowException("no text support in current mode", ET_IndexOutOfBounds);
1964*cdf0e10cSrcweir     }
1965*cdf0e10cSrcweir 
1966*cdf0e10cSrcweir     return aCharacterBox;
1967*cdf0e10cSrcweir }
1968*cdf0e10cSrcweir 
1969*cdf0e10cSrcweir 
1970*cdf0e10cSrcweir 
1971*cdf0e10cSrcweir 
1972*cdf0e10cSrcweir sal_Int32 SAL_CALL PresenterAccessible::AccessibleParagraph::getCharacterCount (void)
1973*cdf0e10cSrcweir     throw (cssu::RuntimeException)
1974*cdf0e10cSrcweir {
1975*cdf0e10cSrcweir     ThrowIfDisposed();
1976*cdf0e10cSrcweir 
1977*cdf0e10cSrcweir     sal_Int32 nCount (0);
1978*cdf0e10cSrcweir     if (mpParagraph)
1979*cdf0e10cSrcweir         nCount = mpParagraph->GetCharacterCount();
1980*cdf0e10cSrcweir 
1981*cdf0e10cSrcweir     return nCount;
1982*cdf0e10cSrcweir }
1983*cdf0e10cSrcweir 
1984*cdf0e10cSrcweir 
1985*cdf0e10cSrcweir 
1986*cdf0e10cSrcweir 
1987*cdf0e10cSrcweir sal_Int32 SAL_CALL PresenterAccessible::AccessibleParagraph::getIndexAtPoint (
1988*cdf0e10cSrcweir     const css::awt::Point& rPoint)
1989*cdf0e10cSrcweir     throw (cssu::RuntimeException)
1990*cdf0e10cSrcweir {
1991*cdf0e10cSrcweir     ThrowIfDisposed();
1992*cdf0e10cSrcweir 
1993*cdf0e10cSrcweir     sal_Int32 nIndex (-1);
1994*cdf0e10cSrcweir     if (mpParagraph)
1995*cdf0e10cSrcweir         nIndex = mpParagraph->GetIndexAtPoint(rPoint);
1996*cdf0e10cSrcweir 
1997*cdf0e10cSrcweir     return nIndex;
1998*cdf0e10cSrcweir }
1999*cdf0e10cSrcweir 
2000*cdf0e10cSrcweir 
2001*cdf0e10cSrcweir 
2002*cdf0e10cSrcweir 
2003*cdf0e10cSrcweir ::rtl::OUString SAL_CALL PresenterAccessible::AccessibleParagraph::getSelectedText (void)
2004*cdf0e10cSrcweir     throw (cssu::RuntimeException)
2005*cdf0e10cSrcweir {
2006*cdf0e10cSrcweir     ThrowIfDisposed();
2007*cdf0e10cSrcweir 
2008*cdf0e10cSrcweir     return getTextRange(getSelectionStart(), getSelectionEnd());
2009*cdf0e10cSrcweir }
2010*cdf0e10cSrcweir 
2011*cdf0e10cSrcweir 
2012*cdf0e10cSrcweir 
2013*cdf0e10cSrcweir 
2014*cdf0e10cSrcweir sal_Int32 SAL_CALL PresenterAccessible::AccessibleParagraph::getSelectionStart (void)
2015*cdf0e10cSrcweir     throw (cssu::RuntimeException)
2016*cdf0e10cSrcweir {
2017*cdf0e10cSrcweir     ThrowIfDisposed();
2018*cdf0e10cSrcweir 
2019*cdf0e10cSrcweir     return getCaretPosition();
2020*cdf0e10cSrcweir }
2021*cdf0e10cSrcweir 
2022*cdf0e10cSrcweir 
2023*cdf0e10cSrcweir 
2024*cdf0e10cSrcweir 
2025*cdf0e10cSrcweir sal_Int32 SAL_CALL PresenterAccessible::AccessibleParagraph::getSelectionEnd (void)
2026*cdf0e10cSrcweir     throw (cssu::RuntimeException)
2027*cdf0e10cSrcweir {
2028*cdf0e10cSrcweir     ThrowIfDisposed();
2029*cdf0e10cSrcweir 
2030*cdf0e10cSrcweir     return getCaretPosition();
2031*cdf0e10cSrcweir }
2032*cdf0e10cSrcweir 
2033*cdf0e10cSrcweir 
2034*cdf0e10cSrcweir 
2035*cdf0e10cSrcweir 
2036*cdf0e10cSrcweir sal_Bool SAL_CALL PresenterAccessible::AccessibleParagraph::setSelection (
2037*cdf0e10cSrcweir     sal_Int32 nStartIndex,
2038*cdf0e10cSrcweir     sal_Int32 nEndIndex)
2039*cdf0e10cSrcweir     throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException)
2040*cdf0e10cSrcweir {
2041*cdf0e10cSrcweir     (void)nEndIndex;
2042*cdf0e10cSrcweir     ThrowIfDisposed();
2043*cdf0e10cSrcweir 
2044*cdf0e10cSrcweir     return setCaretPosition(nStartIndex);
2045*cdf0e10cSrcweir }
2046*cdf0e10cSrcweir 
2047*cdf0e10cSrcweir 
2048*cdf0e10cSrcweir 
2049*cdf0e10cSrcweir 
2050*cdf0e10cSrcweir ::rtl::OUString SAL_CALL PresenterAccessible::AccessibleParagraph::getText (void)
2051*cdf0e10cSrcweir     throw (cssu::RuntimeException)
2052*cdf0e10cSrcweir {
2053*cdf0e10cSrcweir     ThrowIfDisposed();
2054*cdf0e10cSrcweir 
2055*cdf0e10cSrcweir     ::rtl::OUString sText;
2056*cdf0e10cSrcweir     if (mpParagraph)
2057*cdf0e10cSrcweir         sText = mpParagraph->GetText();
2058*cdf0e10cSrcweir 
2059*cdf0e10cSrcweir     return sText;
2060*cdf0e10cSrcweir }
2061*cdf0e10cSrcweir 
2062*cdf0e10cSrcweir 
2063*cdf0e10cSrcweir 
2064*cdf0e10cSrcweir 
2065*cdf0e10cSrcweir ::rtl::OUString SAL_CALL PresenterAccessible::AccessibleParagraph::getTextRange (
2066*cdf0e10cSrcweir     sal_Int32 nLocalStartIndex,
2067*cdf0e10cSrcweir     sal_Int32 nLocalEndIndex)
2068*cdf0e10cSrcweir     throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException)
2069*cdf0e10cSrcweir {
2070*cdf0e10cSrcweir     ThrowIfDisposed();
2071*cdf0e10cSrcweir 
2072*cdf0e10cSrcweir     ::rtl::OUString sText;
2073*cdf0e10cSrcweir     if (mpParagraph)
2074*cdf0e10cSrcweir     {
2075*cdf0e10cSrcweir         const TextSegment aSegment (
2076*cdf0e10cSrcweir             mpParagraph->CreateTextSegment(nLocalStartIndex, nLocalEndIndex));
2077*cdf0e10cSrcweir         sText = aSegment.SegmentText;
2078*cdf0e10cSrcweir     }
2079*cdf0e10cSrcweir 
2080*cdf0e10cSrcweir     return sText;
2081*cdf0e10cSrcweir }
2082*cdf0e10cSrcweir 
2083*cdf0e10cSrcweir 
2084*cdf0e10cSrcweir 
2085*cdf0e10cSrcweir 
2086*cdf0e10cSrcweir TextSegment SAL_CALL PresenterAccessible::AccessibleParagraph::getTextAtIndex (
2087*cdf0e10cSrcweir     sal_Int32 nLocalCharacterIndex,
2088*cdf0e10cSrcweir     sal_Int16 nTextType)
2089*cdf0e10cSrcweir     throw (css::lang::IndexOutOfBoundsException,
2090*cdf0e10cSrcweir         css::lang::IllegalArgumentException,
2091*cdf0e10cSrcweir         cssu::RuntimeException)
2092*cdf0e10cSrcweir {
2093*cdf0e10cSrcweir     ThrowIfDisposed();
2094*cdf0e10cSrcweir 
2095*cdf0e10cSrcweir     TextSegment aSegment;
2096*cdf0e10cSrcweir     if (mpParagraph)
2097*cdf0e10cSrcweir         aSegment = mpParagraph->GetTextSegment(0, nLocalCharacterIndex, nTextType);
2098*cdf0e10cSrcweir 
2099*cdf0e10cSrcweir     return aSegment;
2100*cdf0e10cSrcweir }
2101*cdf0e10cSrcweir 
2102*cdf0e10cSrcweir 
2103*cdf0e10cSrcweir 
2104*cdf0e10cSrcweir 
2105*cdf0e10cSrcweir TextSegment SAL_CALL PresenterAccessible::AccessibleParagraph::getTextBeforeIndex (
2106*cdf0e10cSrcweir     sal_Int32 nLocalCharacterIndex,
2107*cdf0e10cSrcweir     sal_Int16 nTextType)
2108*cdf0e10cSrcweir     throw (css::lang::IndexOutOfBoundsException,
2109*cdf0e10cSrcweir         css::lang::IllegalArgumentException,
2110*cdf0e10cSrcweir         cssu::RuntimeException)
2111*cdf0e10cSrcweir {
2112*cdf0e10cSrcweir     ThrowIfDisposed();
2113*cdf0e10cSrcweir 
2114*cdf0e10cSrcweir     TextSegment aSegment;
2115*cdf0e10cSrcweir     if (mpParagraph)
2116*cdf0e10cSrcweir         aSegment = mpParagraph->GetTextSegment(-1, nLocalCharacterIndex, nTextType);
2117*cdf0e10cSrcweir 
2118*cdf0e10cSrcweir     return aSegment;
2119*cdf0e10cSrcweir }
2120*cdf0e10cSrcweir 
2121*cdf0e10cSrcweir 
2122*cdf0e10cSrcweir 
2123*cdf0e10cSrcweir 
2124*cdf0e10cSrcweir TextSegment SAL_CALL PresenterAccessible::AccessibleParagraph::getTextBehindIndex (
2125*cdf0e10cSrcweir     sal_Int32 nLocalCharacterIndex,
2126*cdf0e10cSrcweir     sal_Int16 nTextType)
2127*cdf0e10cSrcweir     throw (css::lang::IndexOutOfBoundsException,
2128*cdf0e10cSrcweir         css::lang::IllegalArgumentException,
2129*cdf0e10cSrcweir         cssu::RuntimeException)
2130*cdf0e10cSrcweir {
2131*cdf0e10cSrcweir     ThrowIfDisposed();
2132*cdf0e10cSrcweir 
2133*cdf0e10cSrcweir     TextSegment aSegment;
2134*cdf0e10cSrcweir     if (mpParagraph)
2135*cdf0e10cSrcweir         aSegment = mpParagraph->GetTextSegment(+1, nLocalCharacterIndex, nTextType);
2136*cdf0e10cSrcweir 
2137*cdf0e10cSrcweir     return aSegment;
2138*cdf0e10cSrcweir }
2139*cdf0e10cSrcweir 
2140*cdf0e10cSrcweir 
2141*cdf0e10cSrcweir 
2142*cdf0e10cSrcweir 
2143*cdf0e10cSrcweir sal_Bool SAL_CALL PresenterAccessible::AccessibleParagraph::copyText (
2144*cdf0e10cSrcweir     sal_Int32 nStartIndex,
2145*cdf0e10cSrcweir     sal_Int32 nEndIndex)
2146*cdf0e10cSrcweir     throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException)
2147*cdf0e10cSrcweir {
2148*cdf0e10cSrcweir     ThrowIfDisposed();
2149*cdf0e10cSrcweir 
2150*cdf0e10cSrcweir     // Return false because copying to clipboard is not supported.
2151*cdf0e10cSrcweir     // It IS supported in the notes view.  There is no need to duplicate
2152*cdf0e10cSrcweir     // this here.
2153*cdf0e10cSrcweir     (void)nStartIndex;
2154*cdf0e10cSrcweir     (void)nEndIndex;
2155*cdf0e10cSrcweir     return sal_False;
2156*cdf0e10cSrcweir }
2157*cdf0e10cSrcweir 
2158*cdf0e10cSrcweir 
2159*cdf0e10cSrcweir 
2160*cdf0e10cSrcweir 
2161*cdf0e10cSrcweir //----- protected -------------------------------------------------------------
2162*cdf0e10cSrcweir 
2163*cdf0e10cSrcweir awt::Point PresenterAccessible::AccessibleParagraph::GetRelativeLocation (void)
2164*cdf0e10cSrcweir {
2165*cdf0e10cSrcweir     awt::Point aLocation (AccessibleObject::GetRelativeLocation());
2166*cdf0e10cSrcweir     if (mpParagraph)
2167*cdf0e10cSrcweir     {
2168*cdf0e10cSrcweir         const awt::Point aParagraphLocation (mpParagraph->GetRelativeLocation());
2169*cdf0e10cSrcweir         aLocation.X += aParagraphLocation.X;
2170*cdf0e10cSrcweir         aLocation.Y += aParagraphLocation.Y;
2171*cdf0e10cSrcweir     }
2172*cdf0e10cSrcweir 
2173*cdf0e10cSrcweir     return aLocation;
2174*cdf0e10cSrcweir }
2175*cdf0e10cSrcweir 
2176*cdf0e10cSrcweir 
2177*cdf0e10cSrcweir 
2178*cdf0e10cSrcweir 
2179*cdf0e10cSrcweir awt::Size PresenterAccessible::AccessibleParagraph::GetSize (void)
2180*cdf0e10cSrcweir {
2181*cdf0e10cSrcweir     if (mpParagraph)
2182*cdf0e10cSrcweir         return mpParagraph->GetSize();
2183*cdf0e10cSrcweir     else
2184*cdf0e10cSrcweir         return AccessibleObject::GetSize();
2185*cdf0e10cSrcweir }
2186*cdf0e10cSrcweir 
2187*cdf0e10cSrcweir 
2188*cdf0e10cSrcweir 
2189*cdf0e10cSrcweir 
2190*cdf0e10cSrcweir awt::Point PresenterAccessible::AccessibleParagraph::GetAbsoluteParentLocation (void)
2191*cdf0e10cSrcweir {
2192*cdf0e10cSrcweir     if (mxParentAccessible.is())
2193*cdf0e10cSrcweir     {
2194*cdf0e10cSrcweir         Reference<XAccessibleContext> xParentContext(
2195*cdf0e10cSrcweir             mxParentAccessible->getAccessibleContext(), UNO_QUERY);
2196*cdf0e10cSrcweir         if (xParentContext.is())
2197*cdf0e10cSrcweir         {
2198*cdf0e10cSrcweir             Reference<XAccessibleComponent> xGrandParentComponent(
2199*cdf0e10cSrcweir                 xParentContext->getAccessibleParent(), UNO_QUERY);
2200*cdf0e10cSrcweir             if (xGrandParentComponent.is())
2201*cdf0e10cSrcweir                 return xGrandParentComponent->getLocationOnScreen();
2202*cdf0e10cSrcweir         }
2203*cdf0e10cSrcweir     }
2204*cdf0e10cSrcweir 
2205*cdf0e10cSrcweir     return awt::Point();
2206*cdf0e10cSrcweir }
2207*cdf0e10cSrcweir 
2208*cdf0e10cSrcweir 
2209*cdf0e10cSrcweir 
2210*cdf0e10cSrcweir 
2211*cdf0e10cSrcweir bool PresenterAccessible::AccessibleParagraph::GetWindowState (const sal_Int16 nType) const
2212*cdf0e10cSrcweir {
2213*cdf0e10cSrcweir     switch (nType)
2214*cdf0e10cSrcweir     {
2215*cdf0e10cSrcweir         case AccessibleStateType::EDITABLE:
2216*cdf0e10cSrcweir             return mpParagraph.get()!=NULL;
2217*cdf0e10cSrcweir 
2218*cdf0e10cSrcweir         case AccessibleStateType::ACTIVE:
2219*cdf0e10cSrcweir             return true;
2220*cdf0e10cSrcweir 
2221*cdf0e10cSrcweir         default:
2222*cdf0e10cSrcweir             return AccessibleObject::GetWindowState(nType);
2223*cdf0e10cSrcweir     }
2224*cdf0e10cSrcweir }
2225*cdf0e10cSrcweir 
2226*cdf0e10cSrcweir 
2227*cdf0e10cSrcweir 
2228*cdf0e10cSrcweir 
2229*cdf0e10cSrcweir 
2230*cdf0e10cSrcweir 
2231*cdf0e10cSrcweir //===== AccessibleNotes =======================================================
2232*cdf0e10cSrcweir 
2233*cdf0e10cSrcweir AccessibleNotes::AccessibleNotes (
2234*cdf0e10cSrcweir     const css::lang::Locale aLocale,
2235*cdf0e10cSrcweir     const sal_Int16 nRole,
2236*cdf0e10cSrcweir     const ::rtl::OUString& rsName)
2237*cdf0e10cSrcweir     : AccessibleObject(aLocale,nRole,rsName),
2238*cdf0e10cSrcweir       mpTextView()
2239*cdf0e10cSrcweir {
2240*cdf0e10cSrcweir }
2241*cdf0e10cSrcweir 
2242*cdf0e10cSrcweir 
2243*cdf0e10cSrcweir 
2244*cdf0e10cSrcweir 
2245*cdf0e10cSrcweir rtl::Reference<PresenterAccessible::AccessibleObject> AccessibleNotes::Create (
2246*cdf0e10cSrcweir     const css::uno::Reference<css::uno::XComponentContext>& rxContext,
2247*cdf0e10cSrcweir     const lang::Locale aLocale,
2248*cdf0e10cSrcweir     const Reference<awt::XWindow>& rxContentWindow,
2249*cdf0e10cSrcweir     const Reference<awt::XWindow>& rxBorderWindow,
2250*cdf0e10cSrcweir     const ::boost::shared_ptr<PresenterTextView>& rpTextView)
2251*cdf0e10cSrcweir {
2252*cdf0e10cSrcweir     OUString sName (A2S("Presenter Notes Text"));
2253*cdf0e10cSrcweir     {
2254*cdf0e10cSrcweir         PresenterConfigurationAccess aConfiguration (
2255*cdf0e10cSrcweir             rxContext,
2256*cdf0e10cSrcweir             OUString::createFromAscii("/org.openoffice.Office.extension.PresenterScreen/"),
2257*cdf0e10cSrcweir             PresenterConfigurationAccess::READ_ONLY);
2258*cdf0e10cSrcweir         aConfiguration.GetConfigurationNode(A2S("Presenter/Accessibility/Notes/String"))
2259*cdf0e10cSrcweir             >>= sName;
2260*cdf0e10cSrcweir     }
2261*cdf0e10cSrcweir 
2262*cdf0e10cSrcweir     rtl::Reference<AccessibleNotes> pObject (
2263*cdf0e10cSrcweir         new AccessibleNotes(
2264*cdf0e10cSrcweir             aLocale,
2265*cdf0e10cSrcweir             AccessibleRole::PANEL,
2266*cdf0e10cSrcweir             sName));
2267*cdf0e10cSrcweir     pObject->LateInitialization();
2268*cdf0e10cSrcweir     pObject->SetTextView(rpTextView);
2269*cdf0e10cSrcweir     pObject->UpdateStateSet();
2270*cdf0e10cSrcweir     pObject->SetWindow(rxContentWindow, rxBorderWindow);
2271*cdf0e10cSrcweir 
2272*cdf0e10cSrcweir     return rtl::Reference<PresenterAccessible::AccessibleObject>(pObject.get());
2273*cdf0e10cSrcweir }
2274*cdf0e10cSrcweir 
2275*cdf0e10cSrcweir 
2276*cdf0e10cSrcweir 
2277*cdf0e10cSrcweir 
2278*cdf0e10cSrcweir void AccessibleNotes::SetTextView (
2279*cdf0e10cSrcweir     const ::boost::shared_ptr<PresenterTextView>& rpTextView)
2280*cdf0e10cSrcweir {
2281*cdf0e10cSrcweir     ::std::vector<rtl::Reference<PresenterAccessible::AccessibleObject> > aChildren;
2282*cdf0e10cSrcweir 
2283*cdf0e10cSrcweir     // Release any listeners to the current text view.
2284*cdf0e10cSrcweir     if (mpTextView)
2285*cdf0e10cSrcweir     {
2286*cdf0e10cSrcweir         mpTextView->GetCaret()->SetCaretMotionBroadcaster(
2287*cdf0e10cSrcweir             ::boost::function<void(sal_Int32,sal_Int32,sal_Int32,sal_Int32)>());
2288*cdf0e10cSrcweir         mpTextView->SetTextChangeBroadcaster(
2289*cdf0e10cSrcweir             ::boost::function<void(void)>());
2290*cdf0e10cSrcweir     }
2291*cdf0e10cSrcweir 
2292*cdf0e10cSrcweir     mpTextView = rpTextView;
2293*cdf0e10cSrcweir 
2294*cdf0e10cSrcweir     if (mpTextView)
2295*cdf0e10cSrcweir     {
2296*cdf0e10cSrcweir         // Create a new set of children, one for each paragraph.
2297*cdf0e10cSrcweir         const sal_Int32 nParagraphCount (mpTextView->GetParagraphCount());
2298*cdf0e10cSrcweir         for (sal_Int32 nIndex=0; nIndex<nParagraphCount; ++nIndex)
2299*cdf0e10cSrcweir         {
2300*cdf0e10cSrcweir             rtl::Reference<PresenterAccessible::AccessibleParagraph> pParagraph (
2301*cdf0e10cSrcweir                 new PresenterAccessible::AccessibleParagraph(
2302*cdf0e10cSrcweir                     css::lang::Locale(),
2303*cdf0e10cSrcweir                     AccessibleRole::PARAGRAPH,
2304*cdf0e10cSrcweir                     A2S("Paragraph")+OUString::valueOf(nIndex),
2305*cdf0e10cSrcweir                     rpTextView->GetParagraph(nIndex),
2306*cdf0e10cSrcweir                     nIndex));
2307*cdf0e10cSrcweir             pParagraph->LateInitialization();
2308*cdf0e10cSrcweir             pParagraph->SetWindow(
2309*cdf0e10cSrcweir                 Reference<awt::XWindow>(mxContentWindow, UNO_QUERY),
2310*cdf0e10cSrcweir                 Reference<awt::XWindow>(mxBorderWindow, UNO_QUERY));
2311*cdf0e10cSrcweir             pParagraph->SetAccessibleParent(this);
2312*cdf0e10cSrcweir             aChildren.push_back(
2313*cdf0e10cSrcweir                 rtl::Reference<PresenterAccessible::AccessibleObject>(pParagraph.get()));
2314*cdf0e10cSrcweir         }
2315*cdf0e10cSrcweir         maChildren.swap(aChildren);
2316*cdf0e10cSrcweir         FireAccessibleEvent(AccessibleEventId::INVALIDATE_ALL_CHILDREN, Any(), Any());
2317*cdf0e10cSrcweir 
2318*cdf0e10cSrcweir         // Dispose the old children. (This will remove them from the focus
2319*cdf0e10cSrcweir         // manager).
2320*cdf0e10cSrcweir         for (std::vector<rtl::Reference<AccessibleObject> >::const_iterator
2321*cdf0e10cSrcweir                  iChild(aChildren.begin()), iEnd(aChildren.end());
2322*cdf0e10cSrcweir              iChild!=iEnd;
2323*cdf0e10cSrcweir              ++iChild)
2324*cdf0e10cSrcweir         {
2325*cdf0e10cSrcweir             Reference<lang::XComponent> xComponent (static_cast<XWeak*>(iChild->get()), UNO_QUERY);
2326*cdf0e10cSrcweir             if (xComponent.is())
2327*cdf0e10cSrcweir                 xComponent->dispose();
2328*cdf0e10cSrcweir         }
2329*cdf0e10cSrcweir 
2330*cdf0e10cSrcweir         // This class acts as a controller of who broadcasts caret motion
2331*cdf0e10cSrcweir         // events and handles text changes.  Register the corresponding
2332*cdf0e10cSrcweir         // listeners here.
2333*cdf0e10cSrcweir         mpTextView->GetCaret()->SetCaretMotionBroadcaster(
2334*cdf0e10cSrcweir             ::boost::bind(&AccessibleNotes::NotifyCaretChange, this, _1, _2, _3, _4));
2335*cdf0e10cSrcweir         mpTextView->SetTextChangeBroadcaster(
2336*cdf0e10cSrcweir             ::boost::bind(&AccessibleNotes::HandleTextChange, this));
2337*cdf0e10cSrcweir     }
2338*cdf0e10cSrcweir }
2339*cdf0e10cSrcweir 
2340*cdf0e10cSrcweir 
2341*cdf0e10cSrcweir 
2342*cdf0e10cSrcweir 
2343*cdf0e10cSrcweir void AccessibleNotes::SetWindow (
2344*cdf0e10cSrcweir     const cssu::Reference<css::awt::XWindow>& rxContentWindow,
2345*cdf0e10cSrcweir     const cssu::Reference<css::awt::XWindow>& rxBorderWindow)
2346*cdf0e10cSrcweir {
2347*cdf0e10cSrcweir     AccessibleObject::SetWindow(rxContentWindow, rxBorderWindow);
2348*cdf0e10cSrcweir 
2349*cdf0e10cSrcweir     // Set the windows at the children as well, so that every paragraph can
2350*cdf0e10cSrcweir     // setup its geometry.
2351*cdf0e10cSrcweir     for (::std::vector<rtl::Reference<AccessibleObject> >::const_iterator
2352*cdf0e10cSrcweir              iChild(maChildren.begin()),
2353*cdf0e10cSrcweir              iEnd(maChildren.end());
2354*cdf0e10cSrcweir          iChild!=iEnd;
2355*cdf0e10cSrcweir          ++iChild)
2356*cdf0e10cSrcweir     {
2357*cdf0e10cSrcweir         (*iChild)->SetWindow(rxContentWindow, rxBorderWindow);
2358*cdf0e10cSrcweir     }
2359*cdf0e10cSrcweir }
2360*cdf0e10cSrcweir 
2361*cdf0e10cSrcweir 
2362*cdf0e10cSrcweir 
2363*cdf0e10cSrcweir 
2364*cdf0e10cSrcweir void AccessibleNotes::NotifyCaretChange (
2365*cdf0e10cSrcweir     const sal_Int32 nOldParagraphIndex,
2366*cdf0e10cSrcweir     const sal_Int32 nOldCharacterIndex,
2367*cdf0e10cSrcweir     const sal_Int32 nNewParagraphIndex,
2368*cdf0e10cSrcweir     const sal_Int32 nNewCharacterIndex)
2369*cdf0e10cSrcweir {
2370*cdf0e10cSrcweir     AccessibleFocusManager::Instance()->FocusObject(
2371*cdf0e10cSrcweir         nNewParagraphIndex >= 0
2372*cdf0e10cSrcweir             ? maChildren[nNewParagraphIndex]
2373*cdf0e10cSrcweir             : this);
2374*cdf0e10cSrcweir 
2375*cdf0e10cSrcweir     if (nOldParagraphIndex != nNewParagraphIndex)
2376*cdf0e10cSrcweir     {
2377*cdf0e10cSrcweir         // Moved caret from one paragraph to another (or showed or
2378*cdf0e10cSrcweir         // hid the caret).  Move focuse from one accessible
2379*cdf0e10cSrcweir         // paragraph to another.
2380*cdf0e10cSrcweir         if (nOldParagraphIndex >= 0)
2381*cdf0e10cSrcweir         {
2382*cdf0e10cSrcweir             maChildren[nOldParagraphIndex]->FireAccessibleEvent(
2383*cdf0e10cSrcweir                 AccessibleEventId::CARET_CHANGED,
2384*cdf0e10cSrcweir                 Any(nOldCharacterIndex),
2385*cdf0e10cSrcweir                 Any(sal_Int32(-1)));
2386*cdf0e10cSrcweir         }
2387*cdf0e10cSrcweir         if (nNewParagraphIndex >= 0)
2388*cdf0e10cSrcweir         {
2389*cdf0e10cSrcweir             maChildren[nNewParagraphIndex]->FireAccessibleEvent(
2390*cdf0e10cSrcweir                 AccessibleEventId::CARET_CHANGED,
2391*cdf0e10cSrcweir                 Any(sal_Int32(-1)),
2392*cdf0e10cSrcweir                 Any(nNewCharacterIndex));
2393*cdf0e10cSrcweir         }
2394*cdf0e10cSrcweir     }
2395*cdf0e10cSrcweir     else if (nNewParagraphIndex >= 0)
2396*cdf0e10cSrcweir     {
2397*cdf0e10cSrcweir         // Caret moved inside one paragraph.
2398*cdf0e10cSrcweir         maChildren[nNewParagraphIndex]->FireAccessibleEvent(
2399*cdf0e10cSrcweir             AccessibleEventId::CARET_CHANGED,
2400*cdf0e10cSrcweir             Any(nOldCharacterIndex),
2401*cdf0e10cSrcweir             Any(nNewCharacterIndex));
2402*cdf0e10cSrcweir     }
2403*cdf0e10cSrcweir }
2404*cdf0e10cSrcweir 
2405*cdf0e10cSrcweir 
2406*cdf0e10cSrcweir 
2407*cdf0e10cSrcweir 
2408*cdf0e10cSrcweir void AccessibleNotes::HandleTextChange (void)
2409*cdf0e10cSrcweir {
2410*cdf0e10cSrcweir     SetTextView(mpTextView);
2411*cdf0e10cSrcweir }
2412*cdf0e10cSrcweir 
2413*cdf0e10cSrcweir 
2414*cdf0e10cSrcweir 
2415*cdf0e10cSrcweir 
2416*cdf0e10cSrcweir //===== AccessibleFocusManager ================================================
2417*cdf0e10cSrcweir 
2418*cdf0e10cSrcweir ::boost::shared_ptr<AccessibleFocusManager> AccessibleFocusManager::mpInstance;
2419*cdf0e10cSrcweir 
2420*cdf0e10cSrcweir ::boost::shared_ptr<AccessibleFocusManager> AccessibleFocusManager::Instance (void)
2421*cdf0e10cSrcweir {
2422*cdf0e10cSrcweir     if ( ! mpInstance)
2423*cdf0e10cSrcweir     {
2424*cdf0e10cSrcweir         mpInstance.reset(new AccessibleFocusManager());
2425*cdf0e10cSrcweir     }
2426*cdf0e10cSrcweir     return mpInstance;
2427*cdf0e10cSrcweir }
2428*cdf0e10cSrcweir 
2429*cdf0e10cSrcweir 
2430*cdf0e10cSrcweir 
2431*cdf0e10cSrcweir 
2432*cdf0e10cSrcweir AccessibleFocusManager::AccessibleFocusManager (void)
2433*cdf0e10cSrcweir     : maFocusableObjects()
2434*cdf0e10cSrcweir {
2435*cdf0e10cSrcweir }
2436*cdf0e10cSrcweir 
2437*cdf0e10cSrcweir 
2438*cdf0e10cSrcweir 
2439*cdf0e10cSrcweir 
2440*cdf0e10cSrcweir void AccessibleFocusManager::AddFocusableObject (
2441*cdf0e10cSrcweir     const ::rtl::Reference<PresenterAccessible::AccessibleObject>& rpObject)
2442*cdf0e10cSrcweir {
2443*cdf0e10cSrcweir     OSL_ASSERT(rpObject.is());
2444*cdf0e10cSrcweir     OSL_ASSERT(::std::find(maFocusableObjects.begin(),maFocusableObjects.end(), rpObject)==maFocusableObjects.end());
2445*cdf0e10cSrcweir 
2446*cdf0e10cSrcweir     maFocusableObjects.push_back(rpObject);
2447*cdf0e10cSrcweir }
2448*cdf0e10cSrcweir 
2449*cdf0e10cSrcweir 
2450*cdf0e10cSrcweir 
2451*cdf0e10cSrcweir 
2452*cdf0e10cSrcweir void AccessibleFocusManager::RemoveFocusableObject (
2453*cdf0e10cSrcweir     const ::rtl::Reference<PresenterAccessible::AccessibleObject>& rpObject)
2454*cdf0e10cSrcweir {
2455*cdf0e10cSrcweir     ::std::vector<rtl::Reference<PresenterAccessible::AccessibleObject> >::iterator iObject (
2456*cdf0e10cSrcweir         ::std::find(maFocusableObjects.begin(),maFocusableObjects.end(), rpObject));
2457*cdf0e10cSrcweir 
2458*cdf0e10cSrcweir     if (iObject != maFocusableObjects.end())
2459*cdf0e10cSrcweir         maFocusableObjects.erase(iObject);
2460*cdf0e10cSrcweir     else
2461*cdf0e10cSrcweir     {
2462*cdf0e10cSrcweir         OSL_ASSERT(iObject!=maFocusableObjects.end());
2463*cdf0e10cSrcweir     }
2464*cdf0e10cSrcweir }
2465*cdf0e10cSrcweir 
2466*cdf0e10cSrcweir 
2467*cdf0e10cSrcweir 
2468*cdf0e10cSrcweir 
2469*cdf0e10cSrcweir void AccessibleFocusManager::FocusObject (
2470*cdf0e10cSrcweir     const ::rtl::Reference<PresenterAccessible::AccessibleObject>& rpObject)
2471*cdf0e10cSrcweir {
2472*cdf0e10cSrcweir     // Remove the focus of any of the other focusable objects.
2473*cdf0e10cSrcweir     for (::std::vector<rtl::Reference<PresenterAccessible::AccessibleObject> >::const_iterator
2474*cdf0e10cSrcweir              iObject (maFocusableObjects.begin()),
2475*cdf0e10cSrcweir              iEnd (maFocusableObjects.end());
2476*cdf0e10cSrcweir          iObject != iEnd;
2477*cdf0e10cSrcweir          ++iObject)
2478*cdf0e10cSrcweir     {
2479*cdf0e10cSrcweir         if (*iObject!=rpObject)
2480*cdf0e10cSrcweir             (*iObject)->SetIsFocused(false);
2481*cdf0e10cSrcweir     }
2482*cdf0e10cSrcweir 
2483*cdf0e10cSrcweir     if (rpObject.is())
2484*cdf0e10cSrcweir         rpObject->SetIsFocused(true);
2485*cdf0e10cSrcweir }
2486*cdf0e10cSrcweir 
2487*cdf0e10cSrcweir } } // end of namespace ::sd::presenter
2488