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