fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sdext / source / presenter / PresenterAccessibility.cxx
blobbeb609a83ede52c709450ed542e726aa635ac9e0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "PresenterAccessibility.hxx"
21 #include "PresenterTextView.hxx"
22 #include "PresenterConfigurationAccess.hxx"
23 #include "PresenterNotesView.hxx"
24 #include "PresenterPaneBase.hxx"
25 #include "PresenterPaneContainer.hxx"
26 #include "PresenterPaneFactory.hxx"
27 #include "PresenterViewFactory.hxx"
29 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
30 #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
31 #include <com/sun/star/accessibility/AccessibleRole.hpp>
32 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
33 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
34 #include <com/sun/star/accessibility/XAccessibleEditableText.hpp>
35 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
36 #include <com/sun/star/accessibility/XAccessibleText.hpp>
37 #include <com/sun/star/drawing/framework/ResourceId.hpp>
38 #include <com/sun/star/drawing/framework/XPane.hpp>
39 #include <com/sun/star/drawing/framework/XView.hpp>
40 #include <cppuhelper/compbase1.hxx>
41 #include <cppuhelper/compbase5.hxx>
42 #include <cppuhelper/implbase1.hxx>
43 #include <boost/bind.hpp>
45 using namespace ::com::sun::star;
46 using namespace ::com::sun::star::accessibility;
47 using namespace ::com::sun::star::uno;
48 using namespace ::com::sun::star::drawing::framework;
50 //===== PresenterAccessibleObject =============================================
52 namespace sdext { namespace presenter {
54 namespace {
55 typedef ::cppu::WeakComponentImplHelper5 <
56 css::accessibility::XAccessible,
57 css::accessibility::XAccessibleContext,
58 css::accessibility::XAccessibleComponent,
59 css::accessibility::XAccessibleEventBroadcaster,
60 css::awt::XWindowListener
61 > PresenterAccessibleObjectInterfaceBase;
64 class PresenterAccessible::AccessibleObject
65 : public ::cppu::BaseMutex,
66 public PresenterAccessibleObjectInterfaceBase
68 public:
69 AccessibleObject (
70 const css::lang::Locale& rLocale,
71 const sal_Int16 nRole,
72 const OUString& rsName);
73 void LateInitialization();
75 virtual ~AccessibleObject();
77 virtual void SetWindow (
78 const css::uno::Reference<css::awt::XWindow>& rxContentWindow,
79 const css::uno::Reference<css::awt::XWindow>& rxBorderWindow);
80 void SetAccessibleParent (const css::uno::Reference<css::accessibility::XAccessible>& rxAccessibleParent);
82 virtual void SAL_CALL disposing() SAL_OVERRIDE;
84 void AddChild (const ::rtl::Reference<AccessibleObject>& rpChild);
85 void RemoveChild (const ::rtl::Reference<AccessibleObject>& rpChild);
87 void SetIsFocused (const bool bIsFocused);
88 void SetAccessibleName (const OUString& rsName);
90 void FireAccessibleEvent (
91 const sal_Int16 nEventId,
92 const css::uno::Any& rOldValue,
93 const css::uno::Any& rNewValue);
95 void UpdateStateSet();
97 //----- XAccessible -------------------------------------------------------
99 virtual css::uno::Reference<css::accessibility::XAccessibleContext> SAL_CALL
100 getAccessibleContext()
101 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
103 //----- XAccessibleContext ----------------------------------------------
105 virtual sal_Int32 SAL_CALL getAccessibleChildCount()
106 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
108 virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL
109 getAccessibleChild (sal_Int32 nIndex)
110 throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
112 virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL getAccessibleParent()
113 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
115 virtual sal_Int32 SAL_CALL getAccessibleIndexInParent()
116 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
118 virtual sal_Int16 SAL_CALL getAccessibleRole()
119 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
121 virtual OUString SAL_CALL getAccessibleDescription()
122 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
124 virtual OUString SAL_CALL getAccessibleName()
125 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
127 virtual css::uno::Reference<css::accessibility::XAccessibleRelationSet> SAL_CALL
128 getAccessibleRelationSet()
129 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
131 virtual css::uno::Reference<css::accessibility::XAccessibleStateSet> SAL_CALL
132 getAccessibleStateSet()
133 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
135 virtual css::lang::Locale SAL_CALL getLocale()
136 throw (css::uno::RuntimeException,
137 css::accessibility::IllegalAccessibleComponentStateException, std::exception) SAL_OVERRIDE;
139 //----- XAccessibleComponent --------------------------------------------
141 virtual sal_Bool SAL_CALL containsPoint (
142 const css::awt::Point& aPoint)
143 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
145 virtual css::uno::Reference<css::accessibility::XAccessible> SAL_CALL
146 getAccessibleAtPoint (
147 const css::awt::Point& aPoint)
148 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
150 virtual css::awt::Rectangle SAL_CALL getBounds()
151 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
153 virtual css::awt::Point SAL_CALL getLocation()
154 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
156 virtual css::awt::Point SAL_CALL getLocationOnScreen()
157 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
159 virtual css::awt::Size SAL_CALL getSize()
160 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
162 virtual void SAL_CALL grabFocus()
163 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
165 virtual sal_Int32 SAL_CALL getForeground()
166 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
168 virtual sal_Int32 SAL_CALL getBackground()
169 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
171 //----- XAccessibleEventBroadcaster --------------------------------------
173 virtual void SAL_CALL addAccessibleEventListener (
174 const css::uno::Reference<css::accessibility::XAccessibleEventListener>& rxListener)
175 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
177 virtual void SAL_CALL removeAccessibleEventListener (
178 const css::uno::Reference<css::accessibility::XAccessibleEventListener>& rxListener)
179 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
181 //----- XWindowListener ---------------------------------------------------
183 virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent)
184 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
186 virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent)
187 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
189 virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent)
190 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
192 virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent)
193 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
195 //----- XEventListener ----------------------------------------------------
197 virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent)
198 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
200 protected:
201 OUString msName;
202 css::uno::Reference<css::awt::XWindow2> mxContentWindow;
203 css::uno::Reference<css::awt::XWindow2> mxBorderWindow;
204 const css::lang::Locale maLocale;
205 const sal_Int16 mnRole;
206 sal_uInt32 mnStateSet;
207 bool mbIsFocused;
208 css::uno::Reference<css::accessibility::XAccessible> mxParentAccessible;
209 ::std::vector<rtl::Reference<AccessibleObject> > maChildren;
210 ::std::vector<Reference<XAccessibleEventListener> > maListeners;
212 virtual awt::Point GetRelativeLocation();
213 virtual awt::Size GetSize();
214 virtual awt::Point GetAbsoluteParentLocation();
216 virtual bool GetWindowState (const sal_Int16 nType) const;
218 void UpdateState (const sal_Int16 aState, const bool bValue);
220 bool IsDisposed() const;
222 void ThrowIfDisposed() const
223 throw (css::lang::DisposedException);
226 //===== AccessibleStateSet ====================================================
228 namespace {
229 typedef ::cppu::WeakComponentImplHelper1 <
230 css::accessibility::XAccessibleStateSet
231 > AccessibleStateSetInterfaceBase;
234 class AccessibleStateSet
235 : public ::cppu::BaseMutex,
236 public AccessibleStateSetInterfaceBase
238 public:
239 AccessibleStateSet (const sal_Int32 nStateSet);
240 virtual ~AccessibleStateSet();
242 static sal_uInt32 GetStateMask (const sal_Int16 nType);
244 //----- XAccessibleStateSet -----------------------------------------------
246 virtual sal_Bool SAL_CALL isEmpty()
247 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
249 virtual sal_Bool SAL_CALL contains (sal_Int16 nState)
250 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
252 virtual sal_Bool SAL_CALL containsAll (const css::uno::Sequence<sal_Int16>& rStateSet)
253 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
255 virtual css::uno::Sequence<sal_Int16> SAL_CALL getStates()
256 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
258 private:
259 const sal_Int32 mnStateSet;
262 //===== AccessibleRelationSet =================================================
264 namespace {
265 typedef ::cppu::WeakComponentImplHelper1 <
266 css::accessibility::XAccessibleRelationSet
267 > AccessibleRelationSetInterfaceBase;
270 class AccessibleRelationSet
271 : public ::cppu::BaseMutex,
272 public AccessibleRelationSetInterfaceBase
274 public:
275 AccessibleRelationSet();
276 virtual ~AccessibleRelationSet();
278 void AddRelation (
279 const sal_Int16 nRelationType,
280 const Reference<XInterface>& rxObject);
282 //----- XAccessibleRelationSet --------------------------------------------
284 virtual sal_Int32 SAL_CALL getRelationCount()
285 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
287 virtual AccessibleRelation SAL_CALL getRelation (sal_Int32 nIndex)
288 throw (css::uno::RuntimeException, css::lang::IndexOutOfBoundsException, std::exception) SAL_OVERRIDE;
290 virtual sal_Bool SAL_CALL containsRelation (sal_Int16 nRelationType)
291 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
293 virtual AccessibleRelation SAL_CALL getRelationByType (sal_Int16 nRelationType)
294 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
296 private:
297 ::std::vector<AccessibleRelation> maRelations;
300 //===== PresenterAccessibleParagraph ==========================================
302 namespace {
303 typedef ::cppu::ImplInheritanceHelper1 <
304 PresenterAccessible::AccessibleObject,
305 css::accessibility::XAccessibleText
306 > PresenterAccessibleParagraphInterfaceBase;
309 class PresenterAccessible::AccessibleParagraph
310 : public PresenterAccessibleParagraphInterfaceBase
312 public:
313 AccessibleParagraph (
314 const css::lang::Locale& rLocale,
315 const sal_Int16 nRole,
316 const OUString& rsName,
317 const SharedPresenterTextParagraph& rpParagraph,
318 const sal_Int32 nParagraphIndex);
320 virtual ~AccessibleParagraph();
322 //----- XAccessibleContext ------------------------------------------------
324 virtual css::uno::Reference<css::accessibility::XAccessibleRelationSet> SAL_CALL
325 getAccessibleRelationSet()
326 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
328 //----- XAccessibleText ---------------------------------------------------
330 virtual sal_Int32 SAL_CALL getCaretPosition()
331 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
333 virtual sal_Bool SAL_CALL setCaretPosition (sal_Int32 nIndex)
334 throw (::com::sun::star::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
336 virtual sal_Unicode SAL_CALL getCharacter (sal_Int32 nIndex)
337 throw (::com::sun::star::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
339 virtual css::uno::Sequence<css::beans::PropertyValue> SAL_CALL
340 getCharacterAttributes (
341 ::sal_Int32 nIndex,
342 const css::uno::Sequence<OUString>& rRequestedAttributes)
343 throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
345 virtual css::awt::Rectangle SAL_CALL getCharacterBounds (sal_Int32 nIndex)
346 throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
348 virtual sal_Int32 SAL_CALL getCharacterCount()
349 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
351 virtual sal_Int32 SAL_CALL getIndexAtPoint (const css::awt::Point& rPoint)
352 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
354 virtual OUString SAL_CALL getSelectedText()
355 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
357 virtual sal_Int32 SAL_CALL getSelectionStart()
358 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
360 virtual sal_Int32 SAL_CALL getSelectionEnd()
361 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
363 virtual sal_Bool SAL_CALL setSelection (sal_Int32 nStartIndex, sal_Int32 nEndIndex)
364 throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
366 virtual OUString SAL_CALL getText()
367 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
369 virtual OUString SAL_CALL getTextRange (
370 sal_Int32 nStartIndex,
371 sal_Int32 nEndIndex)
372 throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
374 virtual css::accessibility::TextSegment SAL_CALL getTextAtIndex (
375 sal_Int32 nIndex,
376 sal_Int16 nTextType)
377 throw (css::lang::IndexOutOfBoundsException,
378 css::lang::IllegalArgumentException,
379 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
381 virtual css::accessibility::TextSegment SAL_CALL getTextBeforeIndex (
382 sal_Int32 nIndex,
383 sal_Int16 nTextType)
384 throw (css::lang::IndexOutOfBoundsException,
385 css::lang::IllegalArgumentException,
386 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
388 virtual css::accessibility::TextSegment SAL_CALL getTextBehindIndex (
389 sal_Int32 nIndex,
390 sal_Int16 nTextType)
391 throw (css::lang::IndexOutOfBoundsException,
392 css::lang::IllegalArgumentException,
393 css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
395 virtual sal_Bool SAL_CALL copyText (sal_Int32 nStartIndex, sal_Int32 nEndIndex)
396 throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
398 protected:
399 virtual awt::Point GetRelativeLocation() SAL_OVERRIDE;
400 virtual awt::Size GetSize() SAL_OVERRIDE;
401 virtual awt::Point GetAbsoluteParentLocation() SAL_OVERRIDE;
402 virtual bool GetWindowState (const sal_Int16 nType) const SAL_OVERRIDE;
404 private:
405 SharedPresenterTextParagraph mpParagraph;
406 const sal_Int32 mnParagraphIndex;
409 //===== AccessibleConsole =====================================================
411 class AccessibleConsole
413 public:
414 static rtl::Reference<PresenterAccessible::AccessibleObject> Create (
415 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
416 const lang::Locale& rLocale)
418 OUString sName ("Presenter Console");
419 PresenterConfigurationAccess aConfiguration (
420 rxContext,
421 OUString("/org.openoffice.Office.PresenterScreen/"),
422 PresenterConfigurationAccess::READ_ONLY);
423 aConfiguration.GetConfigurationNode("Presenter/Accessibility/Console/String")
424 >>= sName;
426 rtl::Reference<PresenterAccessible::AccessibleObject> pObject (
427 new PresenterAccessible::AccessibleObject(
428 rLocale, AccessibleRole::PANEL, sName));
429 pObject->LateInitialization();
430 pObject->UpdateStateSet();
432 return pObject;
436 //===== AccessiblePreview =====================================================
438 class AccessiblePreview
440 public:
441 static rtl::Reference<PresenterAccessible::AccessibleObject> Create (
442 const Reference<css::uno::XComponentContext>& rxContext,
443 const lang::Locale& rLocale,
444 const Reference<awt::XWindow>& rxContentWindow,
445 const Reference<awt::XWindow>& rxBorderWindow)
447 OUString sName ("Presenter Notes Window");
449 PresenterConfigurationAccess aConfiguration (
450 rxContext,
451 OUString("/org.openoffice.Office.PresenterScreen/"),
452 PresenterConfigurationAccess::READ_ONLY);
453 aConfiguration.GetConfigurationNode("Presenter/Accessibility/Preview/String")
454 >>= sName;
457 rtl::Reference<PresenterAccessible::AccessibleObject> pObject (
458 new PresenterAccessible::AccessibleObject(
459 rLocale,
460 AccessibleRole::LABEL,
461 sName));
462 pObject->LateInitialization();
463 pObject->UpdateStateSet();
464 pObject->SetWindow(rxContentWindow, rxBorderWindow);
466 return pObject;
470 //===== AccessibleNotes =======================================================
472 class AccessibleNotes : public PresenterAccessible::AccessibleObject
474 public:
475 AccessibleNotes (
476 const css::lang::Locale& rLocale,
477 const sal_Int16 nRole,
478 const OUString& rsName);
480 static rtl::Reference<PresenterAccessible::AccessibleObject> Create (
481 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
482 const lang::Locale& rLocale,
483 const Reference<awt::XWindow>& rxContentWindow,
484 const Reference<awt::XWindow>& rxBorderWindow,
485 const ::boost::shared_ptr<PresenterTextView>& rpTextView);
487 void SetTextView (const ::boost::shared_ptr<PresenterTextView>& rpTextView);
489 virtual void SetWindow (
490 const css::uno::Reference<css::awt::XWindow>& rxContentWindow,
491 const css::uno::Reference<css::awt::XWindow>& rxBorderWindow) SAL_OVERRIDE;
493 private:
494 ::boost::shared_ptr<PresenterTextView> mpTextView;
496 void NotifyCaretChange (
497 const sal_Int32 nOldParagraphIndex,
498 const sal_Int32 nOldCharacterIndex,
499 const sal_Int32 nNewParagraphIndex,
500 const sal_Int32 nNewCharacterIndex);
501 void HandleTextChange();
504 //===== AccessibleFocusManager ================================================
506 /** A singleton class that makes sure that only one accessibility object in
507 the PresenterConsole hierarchy has the focus.
509 class AccessibleFocusManager
511 public:
512 static ::boost::shared_ptr<AccessibleFocusManager> Instance();
514 void AddFocusableObject (const ::rtl::Reference<PresenterAccessible::AccessibleObject>& rpObject);
515 void RemoveFocusableObject (const ::rtl::Reference<PresenterAccessible::AccessibleObject>& rpObject);
517 void FocusObject (const ::rtl::Reference<PresenterAccessible::AccessibleObject>& rpObject);
519 private:
520 static ::boost::shared_ptr<AccessibleFocusManager> mpInstance;
521 ::std::vector<rtl::Reference<PresenterAccessible::AccessibleObject> > maFocusableObjects;
523 AccessibleFocusManager();
526 //===== PresenterAccessible ===================================================
528 PresenterAccessible::PresenterAccessible (
529 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
530 const ::rtl::Reference<PresenterController>& rpPresenterController,
531 const Reference<drawing::framework::XPane>& rxMainPane)
532 : PresenterAccessibleInterfaceBase(m_aMutex),
533 mxComponentContext(rxContext),
534 mpPresenterController(rpPresenterController),
535 mxMainPaneId(rxMainPane.is() ? rxMainPane->getResourceId() : Reference<XResourceId>()),
536 mxMainPane(rxMainPane, UNO_QUERY),
537 mxMainWindow(),
538 mxPreviewContentWindow(),
539 mxPreviewBorderWindow(),
540 mxNotesContentWindow(),
541 mxNotesBorderWindow(),
542 mpAccessibleConsole(),
543 mpAccessiblePreview(),
544 mpAccessibleNotes(),
545 mxAccessibleParent()
547 if (mxMainPane.is())
548 mxMainPane->setAccessible(this);
551 PresenterAccessible::~PresenterAccessible()
555 PresenterPaneContainer::SharedPaneDescriptor PresenterAccessible::GetPreviewPane() const
557 PresenterPaneContainer::SharedPaneDescriptor pPreviewPane;
559 if ( ! mpPresenterController.is())
560 return pPreviewPane;
562 rtl::Reference<PresenterPaneContainer> pContainer (mpPresenterController->GetPaneContainer());
563 if ( ! pContainer.is())
564 return pPreviewPane;
566 pPreviewPane = pContainer->FindPaneURL(PresenterPaneFactory::msCurrentSlidePreviewPaneURL);
567 Reference<drawing::framework::XPane> xPreviewPane;
568 if (pPreviewPane)
569 xPreviewPane = pPreviewPane->mxPane.get();
570 if ( ! xPreviewPane.is())
572 pPreviewPane = pContainer->FindPaneURL(PresenterPaneFactory::msSlideSorterPaneURL);
574 return pPreviewPane;
577 void PresenterAccessible::UpdateAccessibilityHierarchy()
579 if ( ! mpPresenterController.is())
580 return;
582 Reference<drawing::framework::XConfigurationController> xConfigurationController(
583 mpPresenterController->GetConfigurationController());
584 if ( ! xConfigurationController.is())
585 return;
587 rtl::Reference<PresenterPaneContainer> pPaneContainer (
588 mpPresenterController->GetPaneContainer());
589 if ( ! pPaneContainer.is())
590 return;
592 if ( ! mpAccessibleConsole.is())
593 return;
595 // Get the preview pane (standard or notes view) or the slide overview
596 // pane.
597 PresenterPaneContainer::SharedPaneDescriptor pPreviewPane(GetPreviewPane());
598 Reference<drawing::framework::XPane> xPreviewPane;
599 if (pPreviewPane)
600 xPreviewPane = pPreviewPane->mxPane.get();
602 // Get the notes pane.
603 PresenterPaneContainer::SharedPaneDescriptor pNotesPane(
604 pPaneContainer->FindPaneURL(PresenterPaneFactory::msNotesPaneURL));
605 Reference<drawing::framework::XPane> xNotesPane;
606 if (pNotesPane)
607 xNotesPane = pNotesPane->mxPane.get();
609 // Get the notes view.
610 Reference<drawing::framework::XView> xNotesView;
611 if (pNotesPane)
612 xNotesView = pNotesPane->mxView;
613 rtl::Reference<PresenterNotesView> pNotesView (
614 dynamic_cast<PresenterNotesView*>(xNotesView.get()));
616 UpdateAccessibilityHierarchy(
617 pPreviewPane ? pPreviewPane->mxContentWindow : Reference<awt::XWindow>(),
618 pPreviewPane ? pPreviewPane->mxBorderWindow : Reference<awt::XWindow>(),
619 (pPreviewPane&&pPreviewPane->mxPane.is()) ? pPreviewPane->mxPane->GetTitle() : OUString(),
620 pNotesPane ? pNotesPane->mxContentWindow : Reference<awt::XWindow>(),
621 pNotesPane ? pNotesPane->mxBorderWindow : Reference<awt::XWindow>(),
622 pNotesView.is()
623 ? pNotesView->GetTextView()
624 : ::boost::shared_ptr<PresenterTextView>());
627 void PresenterAccessible::UpdateAccessibilityHierarchy (
628 const Reference<awt::XWindow>& rxPreviewContentWindow,
629 const Reference<awt::XWindow>& rxPreviewBorderWindow,
630 const OUString& rsTitle,
631 const Reference<awt::XWindow>& rxNotesContentWindow,
632 const Reference<awt::XWindow>& rxNotesBorderWindow,
633 const ::boost::shared_ptr<PresenterTextView>& rpNotesTextView)
635 if ( ! mpAccessibleConsole.is())
636 return;
638 if (mxPreviewContentWindow != rxPreviewContentWindow)
640 if (mpAccessiblePreview.is())
642 mpAccessibleConsole->RemoveChild(mpAccessiblePreview);
643 mpAccessiblePreview = NULL;
646 mxPreviewContentWindow = rxPreviewContentWindow;
647 mxPreviewBorderWindow = rxPreviewBorderWindow;
649 if (mxPreviewContentWindow.is())
651 mpAccessiblePreview = AccessiblePreview::Create(
652 mxComponentContext,
653 lang::Locale(),
654 mxPreviewContentWindow,
655 mxPreviewBorderWindow);
656 mpAccessibleConsole->AddChild(mpAccessiblePreview);
657 mpAccessiblePreview->SetAccessibleName(rsTitle);
661 if (mxNotesContentWindow != rxNotesContentWindow)
663 if (mpAccessibleNotes.is())
665 mpAccessibleConsole->RemoveChild(mpAccessibleNotes);
666 mpAccessibleNotes = NULL;
669 mxNotesContentWindow = rxNotesContentWindow;
670 mxNotesBorderWindow = rxNotesBorderWindow;
672 if (mxNotesContentWindow.is())
674 mpAccessibleNotes = AccessibleNotes::Create(
675 mxComponentContext,
676 lang::Locale(),
677 mxNotesContentWindow,
678 mxNotesBorderWindow,
679 rpNotesTextView);
680 mpAccessibleConsole->AddChild(mpAccessibleNotes.get());
685 void PresenterAccessible::NotifyCurrentSlideChange (
686 const sal_Int32 nCurrentSlideIndex,
687 const sal_Int32 nSlideCount)
689 (void)nCurrentSlideIndex;
690 (void)nSlideCount;
692 if (mpAccessiblePreview.is())
694 PresenterPaneContainer::SharedPaneDescriptor pPreviewPane (GetPreviewPane());
695 mpAccessiblePreview->SetAccessibleName(
696 (pPreviewPane&&pPreviewPane->mxPane.is()
697 ? pPreviewPane->mxPane->GetTitle()
698 : OUString()));
701 // Play some focus ping-pong to trigger AT tools.
702 //AccessibleFocusManager::Instance()->FocusObject(mpAccessibleConsole);
703 AccessibleFocusManager::Instance()->FocusObject(mpAccessiblePreview);
706 void SAL_CALL PresenterAccessible::disposing()
708 UpdateAccessibilityHierarchy(
709 NULL,
710 NULL,
711 OUString(),
712 NULL,
713 NULL,
714 ::boost::shared_ptr<PresenterTextView>());
716 if (mxMainWindow.is())
718 mxMainWindow->removeFocusListener(this);
720 if (mxMainPane.is())
721 mxMainPane->setAccessible(NULL);
724 mpAccessiblePreview = NULL;
725 mpAccessibleNotes = NULL;
726 mpAccessibleConsole = NULL;
729 //----- XAccessible -----------------------------------------------------------
731 Reference<XAccessibleContext> SAL_CALL PresenterAccessible::getAccessibleContext()
732 throw (css::uno::RuntimeException, std::exception)
734 if ( ! mpAccessibleConsole.is())
736 Reference<XPane> xMainPane (mxMainPane, UNO_QUERY);
737 if (xMainPane.is())
739 mxMainWindow = Reference<awt::XWindow>(xMainPane->getWindow(), UNO_QUERY);
740 mxMainWindow->addFocusListener(this);
742 mpAccessibleConsole = AccessibleConsole::Create(
743 mxComponentContext, css::lang::Locale());
744 mpAccessibleConsole->SetWindow(mxMainWindow, NULL);
745 mpAccessibleConsole->SetAccessibleParent(mxAccessibleParent);
746 UpdateAccessibilityHierarchy();
747 if (mpPresenterController.is())
748 mpPresenterController->SetAccessibilityActiveState(true);
750 return mpAccessibleConsole->getAccessibleContext();
753 //----- XFocusListener ----------------------------------------------------
755 void SAL_CALL PresenterAccessible::focusGained (const css::awt::FocusEvent& rEvent)
756 throw (css::uno::RuntimeException, std::exception)
758 (void)rEvent;
759 SAL_INFO("sdext.presenter", OSL_THIS_FUNC << ": PresenterAccessible::focusGained at " << this
760 << " and window " << mxMainWindow.get());
761 AccessibleFocusManager::Instance()->FocusObject(mpAccessibleConsole);
764 void SAL_CALL PresenterAccessible::focusLost (const css::awt::FocusEvent& rEvent)
765 throw (css::uno::RuntimeException, std::exception)
767 (void)rEvent;
768 SAL_INFO("sdext.presenter", OSL_THIS_FUNC << ": PresenterAccessible::focusLost at " << this);
769 AccessibleFocusManager::Instance()->FocusObject(NULL);
772 //----- XEventListener ----------------------------------------------------
774 void SAL_CALL PresenterAccessible::disposing (const css::lang::EventObject& rEvent)
775 throw (css::uno::RuntimeException, std::exception)
777 if (rEvent.Source == mxMainWindow)
778 mxMainWindow = NULL;
781 //----- XInitialize -----------------------------------------------------------
783 void SAL_CALL PresenterAccessible::initialize (const css::uno::Sequence<css::uno::Any>& rArguments)
784 throw (css::uno::RuntimeException, std::exception)
786 if (rArguments.getLength() >= 1)
788 mxAccessibleParent = Reference<XAccessible>(rArguments[0], UNO_QUERY);
789 if (mpAccessibleConsole.is())
790 mpAccessibleConsole->SetAccessibleParent(mxAccessibleParent);
794 //===== PresenterAccessible::AccessibleObject =========================================
796 PresenterAccessible::AccessibleObject::AccessibleObject (
797 const lang::Locale& rLocale,
798 const sal_Int16 nRole,
799 const OUString& rsName)
800 : PresenterAccessibleObjectInterfaceBase(m_aMutex),
801 msName(rsName),
802 mxContentWindow(),
803 mxBorderWindow(),
804 maLocale(rLocale),
805 mnRole(nRole),
806 mnStateSet(0),
807 mbIsFocused(false),
808 mxParentAccessible(),
809 maChildren(),
810 maListeners()
814 void PresenterAccessible::AccessibleObject::LateInitialization()
816 AccessibleFocusManager::Instance()->AddFocusableObject(this);
819 PresenterAccessible::AccessibleObject::~AccessibleObject()
823 void PresenterAccessible::AccessibleObject::SetWindow (
824 const Reference<awt::XWindow>& rxContentWindow,
825 const Reference<awt::XWindow>& rxBorderWindow)
827 Reference<awt::XWindow2> xContentWindow (rxContentWindow, UNO_QUERY);
829 if (mxContentWindow.get() != xContentWindow.get())
831 if (mxContentWindow.is())
833 mxContentWindow->removeWindowListener(this);
836 mxContentWindow = xContentWindow;
837 mxBorderWindow = Reference<awt::XWindow2>(rxBorderWindow, UNO_QUERY);
839 if (mxContentWindow.is())
841 mxContentWindow->addWindowListener(this);
844 UpdateStateSet();
848 void PresenterAccessible::AccessibleObject::SetAccessibleParent (
849 const Reference<XAccessible>& rxAccessibleParent)
851 mxParentAccessible = rxAccessibleParent;
854 void SAL_CALL PresenterAccessible::AccessibleObject::disposing()
856 AccessibleFocusManager::Instance()->RemoveFocusableObject(this);
857 SetWindow(NULL, NULL);
860 //----- XAccessible -------------------------------------------------------
862 Reference<XAccessibleContext> SAL_CALL
863 PresenterAccessible::AccessibleObject::getAccessibleContext()
864 throw (RuntimeException, std::exception)
866 ThrowIfDisposed();
868 return this;
871 //----- XAccessibleContext ----------------------------------------------
873 sal_Int32 SAL_CALL PresenterAccessible::AccessibleObject::getAccessibleChildCount()
874 throw (css::uno::RuntimeException, std::exception)
876 ThrowIfDisposed();
878 const sal_Int32 nChildCount (maChildren.size());
880 return nChildCount;
883 Reference<XAccessible> SAL_CALL
884 PresenterAccessible::AccessibleObject::getAccessibleChild (sal_Int32 nIndex)
885 throw (lang::IndexOutOfBoundsException, RuntimeException, std::exception)
887 ThrowIfDisposed();
889 if (nIndex<0 || nIndex>=sal_Int32(maChildren.size()))
890 throw lang::IndexOutOfBoundsException("invalid child index", static_cast<uno::XWeak*>(this));
892 return Reference<XAccessible>(maChildren[nIndex].get());
895 Reference<XAccessible> SAL_CALL
896 PresenterAccessible::AccessibleObject::getAccessibleParent()
897 throw (RuntimeException, std::exception)
899 ThrowIfDisposed();
901 return mxParentAccessible;
904 sal_Int32 SAL_CALL
905 PresenterAccessible::AccessibleObject::getAccessibleIndexInParent()
906 throw (RuntimeException, std::exception)
908 ThrowIfDisposed();
910 const Reference<XAccessible> xThis (this);
911 if (mxParentAccessible.is())
913 const Reference<XAccessibleContext> xContext (mxParentAccessible->getAccessibleContext());
914 for (sal_Int32 nIndex=0,nCount=xContext->getAccessibleChildCount();
915 nIndex<nCount;
916 ++nIndex)
918 if (xContext->getAccessibleChild(nIndex) == xThis)
919 return nIndex;
923 return 0;
926 sal_Int16 SAL_CALL
927 PresenterAccessible::AccessibleObject::getAccessibleRole()
928 throw (RuntimeException, std::exception)
930 ThrowIfDisposed();
932 return mnRole;
935 OUString SAL_CALL
936 PresenterAccessible::AccessibleObject::getAccessibleDescription()
937 throw (RuntimeException, std::exception)
939 ThrowIfDisposed();
941 return msName;
944 OUString SAL_CALL
945 PresenterAccessible::AccessibleObject::getAccessibleName()
946 throw (css::uno::RuntimeException, std::exception)
948 ThrowIfDisposed();
950 return msName;
953 Reference<XAccessibleRelationSet> SAL_CALL
954 PresenterAccessible::AccessibleObject::getAccessibleRelationSet()
955 throw (RuntimeException, std::exception)
957 ThrowIfDisposed();
959 return NULL;
962 Reference<XAccessibleStateSet> SAL_CALL
963 PresenterAccessible::AccessibleObject::getAccessibleStateSet()
964 throw (RuntimeException, std::exception)
966 ThrowIfDisposed();
968 return Reference<XAccessibleStateSet>(new AccessibleStateSet(mnStateSet));
971 lang::Locale SAL_CALL
972 PresenterAccessible::AccessibleObject::getLocale()
973 throw (RuntimeException,
974 IllegalAccessibleComponentStateException, std::exception)
976 ThrowIfDisposed();
978 if (mxParentAccessible.is())
980 Reference<XAccessibleContext> xParentContext (mxParentAccessible->getAccessibleContext());
981 if (xParentContext.is())
982 return xParentContext->getLocale();
984 return maLocale;
987 //----- XAccessibleComponent ------------------------------------------------
989 sal_Bool SAL_CALL PresenterAccessible::AccessibleObject::containsPoint (
990 const awt::Point& rPoint)
991 throw (RuntimeException, std::exception)
993 ThrowIfDisposed();
995 if (mxContentWindow.is())
997 const awt::Rectangle aBox (getBounds());
998 return rPoint.X>=aBox.X
999 && rPoint.Y>=aBox.Y
1000 && rPoint.X<aBox.X+aBox.Width
1001 && rPoint.Y<aBox.Y+aBox.Height;
1003 else
1004 return false;
1007 Reference<XAccessible> SAL_CALL
1008 PresenterAccessible::AccessibleObject::getAccessibleAtPoint (const awt::Point& rPoint)
1009 throw (RuntimeException, std::exception)
1011 (void)rPoint;
1012 ThrowIfDisposed();
1014 return Reference<XAccessible>();
1017 awt::Rectangle SAL_CALL PresenterAccessible::AccessibleObject::getBounds()
1018 throw (RuntimeException, std::exception)
1020 ThrowIfDisposed();
1022 awt::Rectangle aBox;
1024 const awt::Point aLocation (GetRelativeLocation());
1025 const awt::Size aSize (GetSize());
1027 return awt::Rectangle (aLocation.X, aLocation.Y, aSize.Width, aSize.Height);
1030 awt::Point SAL_CALL PresenterAccessible::AccessibleObject::getLocation()
1031 throw (RuntimeException, std::exception)
1033 ThrowIfDisposed();
1035 const awt::Point aLocation (GetRelativeLocation());
1037 return aLocation;
1040 awt::Point SAL_CALL PresenterAccessible::AccessibleObject::getLocationOnScreen()
1041 throw (RuntimeException, std::exception)
1043 ThrowIfDisposed();
1045 awt::Point aRelativeLocation (GetRelativeLocation());
1046 awt::Point aParentLocationOnScreen (GetAbsoluteParentLocation());
1048 return awt::Point(
1049 aRelativeLocation.X + aParentLocationOnScreen.X,
1050 aRelativeLocation.Y + aParentLocationOnScreen.Y);
1053 awt::Size SAL_CALL PresenterAccessible::AccessibleObject::getSize()
1054 throw (RuntimeException, std::exception)
1056 ThrowIfDisposed();
1058 const awt::Size aSize (GetSize());
1060 return aSize;
1063 void SAL_CALL PresenterAccessible::AccessibleObject::grabFocus()
1064 throw (RuntimeException, std::exception)
1066 ThrowIfDisposed();
1067 if (mxBorderWindow.is())
1068 mxBorderWindow->setFocus();
1069 else if (mxContentWindow.is())
1070 mxContentWindow->setFocus();
1073 sal_Int32 SAL_CALL PresenterAccessible::AccessibleObject::getForeground()
1074 throw (RuntimeException, std::exception)
1076 ThrowIfDisposed();
1078 return 0x00ffffff;
1081 sal_Int32 SAL_CALL PresenterAccessible::AccessibleObject::getBackground()
1082 throw (RuntimeException, std::exception)
1084 ThrowIfDisposed();
1086 return 0x00000000;
1089 //----- XAccessibleEventBroadcaster -------------------------------------------
1091 void SAL_CALL PresenterAccessible::AccessibleObject::addAccessibleEventListener (
1092 const Reference<XAccessibleEventListener>& rxListener)
1093 throw (RuntimeException, std::exception)
1095 if (rxListener.is())
1097 const osl::MutexGuard aGuard(m_aMutex);
1099 if (IsDisposed())
1101 uno::Reference<uno::XInterface> xThis (static_cast<XWeak*>(this), UNO_QUERY);
1102 rxListener->disposing (lang::EventObject(xThis));
1104 else
1106 maListeners.push_back(rxListener);
1111 void SAL_CALL PresenterAccessible::AccessibleObject::removeAccessibleEventListener (
1112 const Reference<XAccessibleEventListener>& rxListener)
1113 throw (RuntimeException, std::exception)
1115 ThrowIfDisposed();
1116 if (rxListener.is())
1118 const osl::MutexGuard aGuard(m_aMutex);
1120 maListeners.erase(std::remove(maListeners.begin(), maListeners.end(), rxListener));
1124 //----- XWindowListener ---------------------------------------------------
1126 void SAL_CALL PresenterAccessible::AccessibleObject::windowResized (
1127 const css::awt::WindowEvent& rEvent)
1128 throw (css::uno::RuntimeException, std::exception)
1130 (void)rEvent;
1132 FireAccessibleEvent(AccessibleEventId::BOUNDRECT_CHANGED, Any(), Any());
1135 void SAL_CALL PresenterAccessible::AccessibleObject::windowMoved (
1136 const css::awt::WindowEvent& rEvent)
1137 throw (css::uno::RuntimeException, std::exception)
1139 (void)rEvent;
1141 FireAccessibleEvent(AccessibleEventId::BOUNDRECT_CHANGED, Any(), Any());
1144 void SAL_CALL PresenterAccessible::AccessibleObject::windowShown (
1145 const css::lang::EventObject& rEvent)
1146 throw (css::uno::RuntimeException, std::exception)
1148 (void)rEvent;
1149 UpdateStateSet();
1152 void SAL_CALL PresenterAccessible::AccessibleObject::windowHidden (
1153 const css::lang::EventObject& rEvent)
1154 throw (css::uno::RuntimeException, std::exception)
1156 (void)rEvent;
1157 UpdateStateSet();
1160 //----- XEventListener --------------------------------------------------------
1162 void SAL_CALL PresenterAccessible::AccessibleObject::disposing (const css::lang::EventObject& rEvent)
1163 throw (css::uno::RuntimeException, std::exception)
1165 if (rEvent.Source == mxContentWindow)
1167 mxContentWindow = NULL;
1168 mxBorderWindow = NULL;
1170 else
1172 SetWindow(NULL, NULL);
1176 //----- private ---------------------------------------------------------------
1178 bool PresenterAccessible::AccessibleObject::GetWindowState (const sal_Int16 nType) const
1180 switch (nType)
1182 case AccessibleStateType::ENABLED:
1183 return mxContentWindow.is() && mxContentWindow->isEnabled();
1185 case AccessibleStateType::FOCUSABLE:
1186 return true;
1188 case AccessibleStateType::FOCUSED:
1189 return mbIsFocused;
1191 case AccessibleStateType::SHOWING:
1192 return mxContentWindow.is() && mxContentWindow->isVisible();
1194 default:
1195 return false;
1199 void PresenterAccessible::AccessibleObject::UpdateStateSet()
1201 UpdateState(AccessibleStateType::FOCUSABLE, true);
1202 UpdateState(AccessibleStateType::VISIBLE, true);
1203 UpdateState(AccessibleStateType::ENABLED, true);
1204 UpdateState(AccessibleStateType::MULTI_LINE, true);
1205 UpdateState(AccessibleStateType::SENSITIVE, true);
1207 UpdateState(AccessibleStateType::ENABLED, GetWindowState(AccessibleStateType::ENABLED));
1208 UpdateState(AccessibleStateType::FOCUSED, GetWindowState(AccessibleStateType::FOCUSED));
1209 UpdateState(AccessibleStateType::SHOWING, GetWindowState(AccessibleStateType::SHOWING));
1210 // UpdateState(AccessibleStateType::ACTIVE, GetWindowState(AccessibleStateType::ACTIVE));
1213 void PresenterAccessible::AccessibleObject::UpdateState(
1214 const sal_Int16 nState,
1215 const bool bValue)
1217 const sal_uInt32 nStateMask (AccessibleStateSet::GetStateMask(nState));
1218 if (((mnStateSet & nStateMask)!=0) != bValue)
1220 if (bValue)
1222 mnStateSet |= nStateMask;
1223 FireAccessibleEvent(AccessibleEventId::STATE_CHANGED, Any(), Any(nState));
1225 else
1227 mnStateSet &= ~nStateMask;
1228 FireAccessibleEvent(AccessibleEventId::STATE_CHANGED, Any(nState), Any());
1233 void PresenterAccessible::AccessibleObject::AddChild (
1234 const ::rtl::Reference<AccessibleObject>& rpChild)
1236 maChildren.push_back(rpChild);
1237 rpChild->SetAccessibleParent(this);
1238 FireAccessibleEvent(AccessibleEventId::INVALIDATE_ALL_CHILDREN, Any(), Any());
1241 void PresenterAccessible::AccessibleObject::RemoveChild (
1242 const ::rtl::Reference<AccessibleObject>& rpChild)
1244 rpChild->SetAccessibleParent(Reference<XAccessible>());
1245 maChildren.erase(::std::find(maChildren.begin(), maChildren.end(), rpChild));
1246 FireAccessibleEvent(AccessibleEventId::INVALIDATE_ALL_CHILDREN, Any(), Any());
1249 void PresenterAccessible::AccessibleObject::SetIsFocused (const bool bIsFocused)
1251 if (mbIsFocused != bIsFocused)
1253 mbIsFocused = bIsFocused;
1254 UpdateStateSet();
1258 void PresenterAccessible::AccessibleObject::SetAccessibleName (const OUString& rsName)
1260 if (msName != rsName)
1262 const OUString sOldName(msName);
1263 msName = rsName;
1264 FireAccessibleEvent(AccessibleEventId::NAME_CHANGED, Any(sOldName), Any(msName));
1268 void PresenterAccessible::AccessibleObject::FireAccessibleEvent (
1269 const sal_Int16 nEventId,
1270 const uno::Any& rOldValue,
1271 const uno::Any& rNewValue )
1273 AccessibleEventObject aEventObject;
1275 aEventObject.Source = Reference<XWeak>(this);
1276 aEventObject.EventId = nEventId;
1277 aEventObject.NewValue = rNewValue;
1278 aEventObject.OldValue = rOldValue;
1280 ::std::vector<Reference<XAccessibleEventListener> > aListenerCopy(maListeners);
1281 for (::std::vector<Reference<XAccessibleEventListener> >::const_iterator
1282 iListener(aListenerCopy.begin()),
1283 iEnd(aListenerCopy.end());
1284 iListener!=iEnd;
1285 ++iListener)
1289 (*iListener)->notifyEvent(aEventObject);
1291 catch (const lang::DisposedException&)
1293 // Listener has been disposed and should have been removed
1294 // already.
1295 removeAccessibleEventListener(*iListener);
1297 catch (const Exception&)
1299 // Ignore all other exceptions and assume that they are
1300 // caused by a temporary problem.
1305 awt::Point PresenterAccessible::AccessibleObject::GetRelativeLocation()
1307 awt::Point aLocation;
1308 if (mxContentWindow.is())
1310 const awt::Rectangle aContentBox (mxContentWindow->getPosSize());
1311 aLocation.X = aContentBox.X;
1312 aLocation.Y = aContentBox.Y;
1313 if (mxBorderWindow.is())
1315 const awt::Rectangle aBorderBox (mxBorderWindow->getPosSize());
1316 aLocation.X += aBorderBox.X;
1317 aLocation.Y += aBorderBox.Y;
1320 return aLocation;
1323 awt::Size PresenterAccessible::AccessibleObject::GetSize()
1325 if (mxContentWindow.is())
1327 const awt::Rectangle aBox (mxContentWindow->getPosSize());
1328 return awt::Size(aBox.Width, aBox.Height);
1330 else
1331 return awt::Size();
1334 awt::Point PresenterAccessible::AccessibleObject::GetAbsoluteParentLocation()
1336 Reference<XAccessibleComponent> xParentComponent;
1337 if (mxParentAccessible.is())
1338 xParentComponent = Reference<XAccessibleComponent>(
1339 mxParentAccessible->getAccessibleContext(), UNO_QUERY);
1340 if (xParentComponent.is())
1341 return xParentComponent->getLocationOnScreen();
1342 else
1343 return awt::Point();
1346 bool PresenterAccessible::AccessibleObject::IsDisposed() const
1348 return (rBHelper.bDisposed || rBHelper.bInDispose);
1351 void PresenterAccessible::AccessibleObject::ThrowIfDisposed() const
1352 throw (lang::DisposedException)
1354 if (rBHelper.bDisposed || rBHelper.bInDispose)
1355 throw lang::DisposedException("object has already been disposed", uno::Reference<uno::XInterface>((uno::XWeak*)(this)));
1358 //===== AccessibleStateSet ====================================================
1360 AccessibleStateSet::AccessibleStateSet (const sal_Int32 nStateSet)
1361 : AccessibleStateSetInterfaceBase(m_aMutex),
1362 mnStateSet (nStateSet)
1366 AccessibleStateSet::~AccessibleStateSet()
1370 sal_uInt32 AccessibleStateSet::GetStateMask (const sal_Int16 nState)
1372 if (nState<0 || nState>=sal_Int16(sizeof(sal_uInt32)*8))
1374 throw RuntimeException("AccessibleStateSet::GetStateMask: invalid state");
1377 return 1<<nState;
1380 //----- XAccessibleStateSet ---------------------------------------------------
1382 sal_Bool SAL_CALL AccessibleStateSet::isEmpty()
1383 throw (css::uno::RuntimeException, std::exception)
1385 return mnStateSet==0;
1388 sal_Bool SAL_CALL AccessibleStateSet::contains (sal_Int16 nState)
1389 throw (css::uno::RuntimeException, std::exception)
1391 return (mnStateSet & GetStateMask(nState)) != 0;
1394 sal_Bool SAL_CALL AccessibleStateSet::containsAll (const css::uno::Sequence<sal_Int16>& rStateSet)
1395 throw (css::uno::RuntimeException, std::exception)
1397 for (sal_Int32 nIndex=0,nCount=rStateSet.getLength(); nIndex<nCount; ++nIndex)
1399 if ((mnStateSet & GetStateMask(rStateSet[nIndex])) == 0)
1400 return sal_False;
1402 return sal_True;
1405 css::uno::Sequence<sal_Int16> SAL_CALL AccessibleStateSet::getStates()
1406 throw (css::uno::RuntimeException, std::exception)
1408 ::std::vector<sal_Int16> aStates;
1409 aStates.reserve(sizeof(mnStateSet)*8);
1410 for (sal_uInt16 nIndex=0; nIndex<sizeof(mnStateSet)*8; ++nIndex)
1411 if ((mnStateSet & GetStateMask(nIndex)) != 0)
1412 aStates.push_back(nIndex);
1413 return Sequence<sal_Int16>(&aStates.front(), aStates.size());
1416 //===== AccessibleRelationSet =================================================
1418 AccessibleRelationSet::AccessibleRelationSet()
1419 : AccessibleRelationSetInterfaceBase(m_aMutex),
1420 maRelations()
1424 AccessibleRelationSet::~AccessibleRelationSet()
1428 void AccessibleRelationSet::AddRelation (
1429 const sal_Int16 nRelationType,
1430 const Reference<XInterface>& rxObject)
1432 maRelations.resize(maRelations.size()+1);
1433 maRelations.back().RelationType = nRelationType;
1434 maRelations.back().TargetSet.realloc(1);
1435 maRelations.back().TargetSet[0] = rxObject;
1438 //----- XAccessibleRelationSet ------------------------------------------------
1440 sal_Int32 SAL_CALL AccessibleRelationSet::getRelationCount()
1441 throw (css::uno::RuntimeException, std::exception)
1443 return maRelations.size();
1446 AccessibleRelation SAL_CALL AccessibleRelationSet::getRelation (sal_Int32 nIndex)
1447 throw (css::uno::RuntimeException, css::lang::IndexOutOfBoundsException, std::exception)
1449 if (nIndex<0 && sal_uInt32(nIndex)>=maRelations.size())
1450 return AccessibleRelation();
1451 else
1452 return maRelations[nIndex];
1455 sal_Bool SAL_CALL AccessibleRelationSet::containsRelation (sal_Int16 nRelationType)
1456 throw (css::uno::RuntimeException, std::exception)
1458 for (::std::vector<AccessibleRelation>::const_iterator iRelation(maRelations.begin());
1459 iRelation!=maRelations.end();
1460 ++iRelation)
1462 if (iRelation->RelationType == nRelationType)
1463 return sal_True;
1465 return sal_False;
1468 AccessibleRelation SAL_CALL AccessibleRelationSet::getRelationByType (sal_Int16 nRelationType)
1469 throw (css::uno::RuntimeException, std::exception)
1471 for (::std::vector<AccessibleRelation>::const_iterator iRelation(maRelations.begin());
1472 iRelation!=maRelations.end();
1473 ++iRelation)
1475 if (iRelation->RelationType == nRelationType)
1476 return *iRelation;
1478 return AccessibleRelation();
1481 //===== PresenterAccessible::AccessibleParagraph ==============================
1483 PresenterAccessible::AccessibleParagraph::AccessibleParagraph (
1484 const lang::Locale& rLocale,
1485 const sal_Int16 nRole,
1486 const OUString& rsName,
1487 const SharedPresenterTextParagraph& rpParagraph,
1488 const sal_Int32 nParagraphIndex)
1489 : PresenterAccessibleParagraphInterfaceBase(rLocale, nRole, rsName),
1490 mpParagraph(rpParagraph),
1491 mnParagraphIndex(nParagraphIndex)
1495 PresenterAccessible::AccessibleParagraph::~AccessibleParagraph()
1499 //----- XAccessibleContext ----------------------------------------------------
1501 Reference<XAccessibleRelationSet> SAL_CALL
1502 PresenterAccessible::AccessibleParagraph::getAccessibleRelationSet()
1503 throw (RuntimeException, std::exception)
1505 ThrowIfDisposed();
1507 rtl::Reference<AccessibleRelationSet> pSet (new AccessibleRelationSet);
1509 if (mxParentAccessible.is())
1511 Reference<XAccessibleContext> xParentContext (mxParentAccessible->getAccessibleContext());
1512 if (xParentContext.is())
1514 if (mnParagraphIndex>0)
1515 pSet->AddRelation(
1516 AccessibleRelationType::CONTENT_FLOWS_FROM,
1517 xParentContext->getAccessibleChild(mnParagraphIndex-1));
1519 if (mnParagraphIndex<xParentContext->getAccessibleChildCount()-1)
1520 pSet->AddRelation(
1521 AccessibleRelationType::CONTENT_FLOWS_TO,
1522 xParentContext->getAccessibleChild(mnParagraphIndex+1));
1526 return Reference<XAccessibleRelationSet>(pSet.get());
1529 //----- XAccessibleText -------------------------------------------------------
1531 sal_Int32 SAL_CALL PresenterAccessible::AccessibleParagraph::getCaretPosition()
1532 throw (css::uno::RuntimeException, std::exception)
1534 ThrowIfDisposed();
1536 sal_Int32 nPosition (-1);
1537 if (mpParagraph)
1538 nPosition = mpParagraph->GetCaretPosition();
1540 return nPosition;
1543 sal_Bool SAL_CALL PresenterAccessible::AccessibleParagraph::setCaretPosition (sal_Int32 nIndex)
1544 throw (::com::sun::star::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception)
1546 ThrowIfDisposed();
1548 if (mpParagraph)
1550 mpParagraph->SetCaretPosition(nIndex);
1551 return sal_True;
1553 else
1554 return sal_False;
1557 sal_Unicode SAL_CALL PresenterAccessible::AccessibleParagraph::getCharacter (sal_Int32 nIndex)
1558 throw (::com::sun::star::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception)
1560 ThrowIfDisposed();
1562 if (!mpParagraph)
1563 throw lang::IndexOutOfBoundsException("no text support in current mode", static_cast<uno::XWeak*>(this));
1564 return mpParagraph->GetCharacter(nIndex);
1567 Sequence<css::beans::PropertyValue> SAL_CALL
1568 PresenterAccessible::AccessibleParagraph::getCharacterAttributes (
1569 ::sal_Int32 nIndex,
1570 const css::uno::Sequence<OUString>& rRequestedAttributes)
1571 throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception)
1573 ThrowIfDisposed();
1575 #if OSL_DEBUG_LEVEL > 1
1576 OSL_TRACE("PresenterAccessible::AccessibleParagraph::getCharacterAttributes at %p,%d returns empty set\r",
1577 this,nIndex);
1578 for (sal_Int32 nAttributeIndex(0),nAttributeCount(rRequestedAttributes.getLength());
1579 nAttributeIndex<nAttributeCount;
1580 ++nAttributeIndex)
1582 OSL_TRACE(" requested attribute %d is %s\r",
1583 nAttributeIndex,
1584 OUStringToOString(rRequestedAttributes[nAttributeIndex], RTL_TEXTENCODING_UTF8).getStr());
1586 #endif
1588 // Character properties are not supported.
1589 (void)nIndex;
1590 (void)rRequestedAttributes;
1591 return Sequence<css::beans::PropertyValue>();
1594 awt::Rectangle SAL_CALL PresenterAccessible::AccessibleParagraph::getCharacterBounds (
1595 sal_Int32 nIndex)
1596 throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception)
1598 ThrowIfDisposed();
1600 awt::Rectangle aCharacterBox;
1601 if (nIndex < 0)
1603 throw lang::IndexOutOfBoundsException("invalid text index", static_cast<uno::XWeak*>(this));
1605 else if (mpParagraph)
1607 aCharacterBox = mpParagraph->GetCharacterBounds(nIndex, false);
1608 // Convert coordinates relative to the window origin into absolute
1609 // screen coordinates.
1610 const awt::Point aWindowLocationOnScreen (getLocationOnScreen());
1611 aCharacterBox.X += aWindowLocationOnScreen.X;
1612 aCharacterBox.Y += aWindowLocationOnScreen.Y;
1614 else
1616 throw lang::IndexOutOfBoundsException("no text support in current mode", static_cast<uno::XWeak*>(this));
1619 return aCharacterBox;
1622 sal_Int32 SAL_CALL PresenterAccessible::AccessibleParagraph::getCharacterCount()
1623 throw (css::uno::RuntimeException, std::exception)
1625 ThrowIfDisposed();
1627 sal_Int32 nCount (0);
1628 if (mpParagraph)
1629 nCount = mpParagraph->GetCharacterCount();
1631 return nCount;
1634 sal_Int32 SAL_CALL PresenterAccessible::AccessibleParagraph::getIndexAtPoint (
1635 const css::awt::Point& )
1636 throw (css::uno::RuntimeException, std::exception)
1638 ThrowIfDisposed();
1639 sal_Int32 nIndex (-1);
1640 return nIndex;
1643 OUString SAL_CALL PresenterAccessible::AccessibleParagraph::getSelectedText()
1644 throw (css::uno::RuntimeException, std::exception)
1646 ThrowIfDisposed();
1648 return getTextRange(getSelectionStart(), getSelectionEnd());
1651 sal_Int32 SAL_CALL PresenterAccessible::AccessibleParagraph::getSelectionStart()
1652 throw (css::uno::RuntimeException, std::exception)
1654 ThrowIfDisposed();
1656 return getCaretPosition();
1659 sal_Int32 SAL_CALL PresenterAccessible::AccessibleParagraph::getSelectionEnd()
1660 throw (css::uno::RuntimeException, std::exception)
1662 ThrowIfDisposed();
1664 return getCaretPosition();
1667 sal_Bool SAL_CALL PresenterAccessible::AccessibleParagraph::setSelection (
1668 sal_Int32 nStartIndex,
1669 sal_Int32 nEndIndex)
1670 throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception)
1672 (void)nEndIndex;
1673 ThrowIfDisposed();
1675 return setCaretPosition(nStartIndex);
1678 OUString SAL_CALL PresenterAccessible::AccessibleParagraph::getText()
1679 throw (css::uno::RuntimeException, std::exception)
1681 ThrowIfDisposed();
1683 OUString sText;
1684 if (mpParagraph)
1685 sText = mpParagraph->GetText();
1687 return sText;
1690 OUString SAL_CALL PresenterAccessible::AccessibleParagraph::getTextRange (
1691 sal_Int32 nLocalStartIndex,
1692 sal_Int32 nLocalEndIndex)
1693 throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception)
1695 ThrowIfDisposed();
1697 OUString sText;
1698 if (mpParagraph)
1700 const TextSegment aSegment (
1701 mpParagraph->CreateTextSegment(nLocalStartIndex, nLocalEndIndex));
1702 sText = aSegment.SegmentText;
1705 return sText;
1708 TextSegment SAL_CALL PresenterAccessible::AccessibleParagraph::getTextAtIndex (
1709 sal_Int32 nLocalCharacterIndex,
1710 sal_Int16 nTextType)
1711 throw (css::lang::IndexOutOfBoundsException,
1712 css::lang::IllegalArgumentException,
1713 css::uno::RuntimeException, std::exception)
1715 ThrowIfDisposed();
1717 TextSegment aSegment;
1718 if (mpParagraph)
1719 aSegment = mpParagraph->GetTextSegment(0, nLocalCharacterIndex, nTextType);
1721 return aSegment;
1724 TextSegment SAL_CALL PresenterAccessible::AccessibleParagraph::getTextBeforeIndex (
1725 sal_Int32 nLocalCharacterIndex,
1726 sal_Int16 nTextType)
1727 throw (css::lang::IndexOutOfBoundsException,
1728 css::lang::IllegalArgumentException,
1729 css::uno::RuntimeException, std::exception)
1731 ThrowIfDisposed();
1733 TextSegment aSegment;
1734 if (mpParagraph)
1735 aSegment = mpParagraph->GetTextSegment(-1, nLocalCharacterIndex, nTextType);
1737 return aSegment;
1740 TextSegment SAL_CALL PresenterAccessible::AccessibleParagraph::getTextBehindIndex (
1741 sal_Int32 nLocalCharacterIndex,
1742 sal_Int16 nTextType)
1743 throw (css::lang::IndexOutOfBoundsException,
1744 css::lang::IllegalArgumentException,
1745 css::uno::RuntimeException, std::exception)
1747 ThrowIfDisposed();
1749 TextSegment aSegment;
1750 if (mpParagraph)
1751 aSegment = mpParagraph->GetTextSegment(+1, nLocalCharacterIndex, nTextType);
1753 return aSegment;
1756 sal_Bool SAL_CALL PresenterAccessible::AccessibleParagraph::copyText (
1757 sal_Int32 nStartIndex,
1758 sal_Int32 nEndIndex)
1759 throw (css::lang::IndexOutOfBoundsException, css::uno::RuntimeException, std::exception)
1761 ThrowIfDisposed();
1763 // Return false because copying to clipboard is not supported.
1764 // It IS supported in the notes view. There is no need to duplicate
1765 // this here.
1766 (void)nStartIndex;
1767 (void)nEndIndex;
1768 return sal_False;
1771 //----- protected -------------------------------------------------------------
1773 awt::Point PresenterAccessible::AccessibleParagraph::GetRelativeLocation()
1775 awt::Point aLocation (AccessibleObject::GetRelativeLocation());
1776 if (mpParagraph)
1778 const awt::Point aParagraphLocation (mpParagraph->GetRelativeLocation());
1779 aLocation.X += aParagraphLocation.X;
1780 aLocation.Y += aParagraphLocation.Y;
1783 return aLocation;
1786 awt::Size PresenterAccessible::AccessibleParagraph::GetSize()
1788 if (mpParagraph)
1789 return mpParagraph->GetSize();
1790 else
1791 return AccessibleObject::GetSize();
1794 awt::Point PresenterAccessible::AccessibleParagraph::GetAbsoluteParentLocation()
1796 if (mxParentAccessible.is())
1798 Reference<XAccessibleContext> xParentContext(
1799 mxParentAccessible->getAccessibleContext(), UNO_QUERY);
1800 if (xParentContext.is())
1802 Reference<XAccessibleComponent> xGrandParentComponent(
1803 xParentContext->getAccessibleParent(), UNO_QUERY);
1804 if (xGrandParentComponent.is())
1805 return xGrandParentComponent->getLocationOnScreen();
1809 return awt::Point();
1812 bool PresenterAccessible::AccessibleParagraph::GetWindowState (const sal_Int16 nType) const
1814 switch (nType)
1816 case AccessibleStateType::EDITABLE:
1817 return mpParagraph.get()!=NULL;
1819 case AccessibleStateType::ACTIVE:
1820 return true;
1822 default:
1823 return AccessibleObject::GetWindowState(nType);
1827 //===== AccessibleNotes =======================================================
1829 AccessibleNotes::AccessibleNotes (
1830 const css::lang::Locale& rLocale,
1831 const sal_Int16 nRole,
1832 const OUString& rsName)
1833 : AccessibleObject(rLocale,nRole,rsName),
1834 mpTextView()
1838 rtl::Reference<PresenterAccessible::AccessibleObject> AccessibleNotes::Create (
1839 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
1840 const lang::Locale& rLocale,
1841 const Reference<awt::XWindow>& rxContentWindow,
1842 const Reference<awt::XWindow>& rxBorderWindow,
1843 const ::boost::shared_ptr<PresenterTextView>& rpTextView)
1845 OUString sName ("Presenter Notes Text");
1847 PresenterConfigurationAccess aConfiguration (
1848 rxContext,
1849 OUString("/org.openoffice.Office.PresenterScreen/"),
1850 PresenterConfigurationAccess::READ_ONLY);
1851 aConfiguration.GetConfigurationNode("Presenter/Accessibility/Notes/String")
1852 >>= sName;
1855 rtl::Reference<AccessibleNotes> pObject (
1856 new AccessibleNotes(
1857 rLocale,
1858 AccessibleRole::PANEL,
1859 sName));
1860 pObject->LateInitialization();
1861 pObject->SetTextView(rpTextView);
1862 pObject->UpdateStateSet();
1863 pObject->SetWindow(rxContentWindow, rxBorderWindow);
1865 return rtl::Reference<PresenterAccessible::AccessibleObject>(pObject.get());
1868 void AccessibleNotes::SetTextView (
1869 const ::boost::shared_ptr<PresenterTextView>& rpTextView)
1871 ::std::vector<rtl::Reference<PresenterAccessible::AccessibleObject> > aChildren;
1873 // Release any listeners to the current text view.
1874 if (mpTextView)
1876 mpTextView->GetCaret()->SetCaretMotionBroadcaster(
1877 ::boost::function<void(sal_Int32,sal_Int32,sal_Int32,sal_Int32)>());
1878 mpTextView->SetTextChangeBroadcaster(
1879 ::boost::function<void()>());
1882 mpTextView = rpTextView;
1884 if (mpTextView)
1886 // Create a new set of children, one for each paragraph.
1887 const sal_Int32 nParagraphCount (mpTextView->GetParagraphCount());
1888 for (sal_Int32 nIndex=0; nIndex<nParagraphCount; ++nIndex)
1890 rtl::Reference<PresenterAccessible::AccessibleParagraph> pParagraph (
1891 new PresenterAccessible::AccessibleParagraph(
1892 css::lang::Locale(),
1893 AccessibleRole::PARAGRAPH,
1894 "Paragraph"+OUString::number(nIndex),
1895 rpTextView->GetParagraph(nIndex),
1896 nIndex));
1897 pParagraph->LateInitialization();
1898 pParagraph->SetWindow(
1899 Reference<awt::XWindow>(mxContentWindow, UNO_QUERY),
1900 Reference<awt::XWindow>(mxBorderWindow, UNO_QUERY));
1901 pParagraph->SetAccessibleParent(this);
1902 aChildren.push_back(
1903 rtl::Reference<PresenterAccessible::AccessibleObject>(pParagraph.get()));
1905 maChildren.swap(aChildren);
1906 FireAccessibleEvent(AccessibleEventId::INVALIDATE_ALL_CHILDREN, Any(), Any());
1908 // Dispose the old children. (This will remove them from the focus
1909 // manager).
1910 for (std::vector<rtl::Reference<AccessibleObject> >::const_iterator
1911 iChild(aChildren.begin()), iEnd(aChildren.end());
1912 iChild!=iEnd;
1913 ++iChild)
1915 Reference<lang::XComponent> xComponent (static_cast<XWeak*>(iChild->get()), UNO_QUERY);
1916 if (xComponent.is())
1917 xComponent->dispose();
1920 // This class acts as a controller of who broadcasts caret motion
1921 // events and handles text changes. Register the corresponding
1922 // listeners here.
1923 mpTextView->GetCaret()->SetCaretMotionBroadcaster(
1924 ::boost::bind(&AccessibleNotes::NotifyCaretChange, this, _1, _2, _3, _4));
1925 mpTextView->SetTextChangeBroadcaster(
1926 ::boost::bind(&AccessibleNotes::HandleTextChange, this));
1930 void AccessibleNotes::SetWindow (
1931 const css::uno::Reference<css::awt::XWindow>& rxContentWindow,
1932 const css::uno::Reference<css::awt::XWindow>& rxBorderWindow)
1934 AccessibleObject::SetWindow(rxContentWindow, rxBorderWindow);
1936 // Set the windows at the children as well, so that every paragraph can
1937 // setup its geometry.
1938 for (::std::vector<rtl::Reference<AccessibleObject> >::const_iterator
1939 iChild(maChildren.begin()),
1940 iEnd(maChildren.end());
1941 iChild!=iEnd;
1942 ++iChild)
1944 (*iChild)->SetWindow(rxContentWindow, rxBorderWindow);
1948 void AccessibleNotes::NotifyCaretChange (
1949 const sal_Int32 nOldParagraphIndex,
1950 const sal_Int32 nOldCharacterIndex,
1951 const sal_Int32 nNewParagraphIndex,
1952 const sal_Int32 nNewCharacterIndex)
1954 AccessibleFocusManager::Instance()->FocusObject(
1955 nNewParagraphIndex >= 0
1956 ? maChildren[nNewParagraphIndex]
1957 : this);
1959 if (nOldParagraphIndex != nNewParagraphIndex)
1961 // Moved caret from one paragraph to another (or showed or
1962 // hid the caret). Move focuse from one accessible
1963 // paragraph to another.
1964 if (nOldParagraphIndex >= 0)
1966 maChildren[nOldParagraphIndex]->FireAccessibleEvent(
1967 AccessibleEventId::CARET_CHANGED,
1968 Any(nOldCharacterIndex),
1969 Any(sal_Int32(-1)));
1971 if (nNewParagraphIndex >= 0)
1973 maChildren[nNewParagraphIndex]->FireAccessibleEvent(
1974 AccessibleEventId::CARET_CHANGED,
1975 Any(sal_Int32(-1)),
1976 Any(nNewCharacterIndex));
1979 else if (nNewParagraphIndex >= 0)
1981 // Caret moved inside one paragraph.
1982 maChildren[nNewParagraphIndex]->FireAccessibleEvent(
1983 AccessibleEventId::CARET_CHANGED,
1984 Any(nOldCharacterIndex),
1985 Any(nNewCharacterIndex));
1989 void AccessibleNotes::HandleTextChange()
1991 SetTextView(mpTextView);
1994 //===== AccessibleFocusManager ================================================
1996 ::boost::shared_ptr<AccessibleFocusManager> AccessibleFocusManager::mpInstance;
1998 ::boost::shared_ptr<AccessibleFocusManager> AccessibleFocusManager::Instance()
2000 if ( ! mpInstance)
2002 mpInstance.reset(new AccessibleFocusManager());
2004 return mpInstance;
2007 AccessibleFocusManager::AccessibleFocusManager()
2008 : maFocusableObjects()
2012 void AccessibleFocusManager::AddFocusableObject (
2013 const ::rtl::Reference<PresenterAccessible::AccessibleObject>& rpObject)
2015 OSL_ASSERT(rpObject.is());
2016 OSL_ASSERT(::std::find(maFocusableObjects.begin(),maFocusableObjects.end(), rpObject)==maFocusableObjects.end());
2018 maFocusableObjects.push_back(rpObject);
2021 void AccessibleFocusManager::RemoveFocusableObject (
2022 const ::rtl::Reference<PresenterAccessible::AccessibleObject>& rpObject)
2024 ::std::vector<rtl::Reference<PresenterAccessible::AccessibleObject> >::iterator iObject (
2025 ::std::find(maFocusableObjects.begin(),maFocusableObjects.end(), rpObject));
2027 if (iObject != maFocusableObjects.end())
2028 maFocusableObjects.erase(iObject);
2029 else
2031 OSL_ASSERT(iObject!=maFocusableObjects.end());
2035 void AccessibleFocusManager::FocusObject (
2036 const ::rtl::Reference<PresenterAccessible::AccessibleObject>& rpObject)
2038 // Remove the focus of any of the other focusable objects.
2039 for (::std::vector<rtl::Reference<PresenterAccessible::AccessibleObject> >::const_iterator
2040 iObject (maFocusableObjects.begin()),
2041 iEnd (maFocusableObjects.end());
2042 iObject != iEnd;
2043 ++iObject)
2045 if (*iObject!=rpObject)
2046 (*iObject)->SetIsFocused(false);
2049 if (rpObject.is())
2050 rpObject->SetIsFocused(true);
2053 } } // end of namespace ::sd::presenter
2055 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */