Update ooo320-m1
[ooovba.git] / sdext / source / presenter / PresenterAccessibility.cxx
blob568853f2c90d4b02ad24ff5a596aa2ba2414ce67
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: PresenterPane.hxx,v $
11 * $Revision: 1.4 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #include "precompiled_sdext.hxx"
34 #include "PresenterAccessibility.hxx"
35 #include "PresenterTextView.hxx"
36 #include "PresenterConfigurationAccess.hxx"
37 #include "PresenterNotesView.hxx"
38 #include "PresenterPaneBase.hxx"
39 #include "PresenterPaneContainer.hxx"
40 #include "PresenterPaneFactory.hxx"
41 #include "PresenterViewFactory.hxx"
43 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
44 #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
45 #include <com/sun/star/accessibility/AccessibleRole.hpp>
46 #include <com/sun/star/accessibility/XAccessibleComponent.hpp>
47 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
48 #include <com/sun/star/accessibility/XAccessibleEditableText.hpp>
49 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
50 #include <com/sun/star/accessibility/XAccessibleText.hpp>
51 #include <com/sun/star/drawing/framework/ResourceId.hpp>
52 #include <com/sun/star/drawing/framework/XPane.hpp>
53 #include <com/sun/star/drawing/framework/XView.hpp>
54 #include <vcl/svapp.hxx>
55 #include <cppuhelper/compbase1.hxx>
56 #include <cppuhelper/compbase5.hxx>
57 #include <cppuhelper/implbase1.hxx>
58 #include <boost/bind.hpp>
60 using namespace ::com::sun::star;
61 using namespace ::com::sun::star::accessibility;
62 using namespace ::com::sun::star::uno;
63 using namespace ::com::sun::star::drawing::framework;
64 using ::rtl::OUString;
66 #define A2S(s) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)))
68 #define VERBOSE
70 //===== PresenterAccessibleObject =============================================
72 namespace sdext { namespace presenter {
74 namespace {
75 typedef ::cppu::WeakComponentImplHelper5 <
76 cssa::XAccessible,
77 cssa::XAccessibleContext,
78 cssa::XAccessibleComponent,
79 cssa::XAccessibleEventBroadcaster,
80 css::awt::XWindowListener
81 > PresenterAccessibleObjectInterfaceBase;
84 class PresenterAccessible::AccessibleObject
85 : public ::cppu::BaseMutex,
86 public PresenterAccessibleObjectInterfaceBase
88 public:
89 AccessibleObject (
90 const css::lang::Locale aLocale,
91 const sal_Int16 nRole,
92 const ::rtl::OUString& rsName);
93 void LateInitialization (void);
95 virtual ~AccessibleObject (void);
97 virtual void SetWindow (
98 const cssu::Reference<css::awt::XWindow>& rxContentWindow,
99 const cssu::Reference<css::awt::XWindow>& rxBorderWindow);
100 void SetAccessibleParent (const cssu::Reference<cssa::XAccessible>& rxAccessibleParent);
102 virtual void SAL_CALL disposing (void);
104 void NotifyCurrentSlideChange (const sal_Int32 nCurrentSlideIndex);
106 void AddChild (const ::rtl::Reference<AccessibleObject>& rpChild);
107 void RemoveChild (const ::rtl::Reference<AccessibleObject>& rpChild);
109 void SetIsFocused (const bool bIsFocused);
110 void SetAccessibleName (const ::rtl::OUString& rsName);
112 void FireAccessibleEvent (
113 const sal_Int16 nEventId,
114 const cssu::Any& rOldValue,
115 const cssu::Any& rNewValue);
117 void UpdateStateSet (void);
120 //----- XAccessible -------------------------------------------------------
122 virtual cssu::Reference<cssa::XAccessibleContext> SAL_CALL
123 getAccessibleContext (void)
124 throw (cssu::RuntimeException);
127 //----- XAccessibleContext ----------------------------------------------
129 virtual sal_Int32 SAL_CALL getAccessibleChildCount (void)
130 throw (cssu::RuntimeException);
132 virtual cssu::Reference< cssa::XAccessible> SAL_CALL
133 getAccessibleChild (sal_Int32 nIndex)
134 throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException);
136 virtual cssu::Reference< cssa::XAccessible> SAL_CALL getAccessibleParent (void)
137 throw (cssu::RuntimeException);
139 virtual sal_Int32 SAL_CALL getAccessibleIndexInParent (void)
140 throw (cssu::RuntimeException);
142 virtual sal_Int16 SAL_CALL getAccessibleRole (void)
143 throw (cssu::RuntimeException);
145 virtual ::rtl::OUString SAL_CALL getAccessibleDescription (void)
146 throw (cssu::RuntimeException);
148 virtual ::rtl::OUString SAL_CALL getAccessibleName (void)
149 throw (cssu::RuntimeException);
151 virtual cssu::Reference<cssa::XAccessibleRelationSet> SAL_CALL
152 getAccessibleRelationSet (void)
153 throw (cssu::RuntimeException);
155 virtual cssu::Reference<cssa::XAccessibleStateSet> SAL_CALL
156 getAccessibleStateSet (void)
157 throw (cssu::RuntimeException);
159 virtual css::lang::Locale SAL_CALL getLocale (void)
160 throw (cssu::RuntimeException,
161 cssa::IllegalAccessibleComponentStateException);
164 //----- XAccessibleComponent --------------------------------------------
166 virtual sal_Bool SAL_CALL containsPoint (
167 const css::awt::Point& aPoint)
168 throw (cssu::RuntimeException);
170 virtual cssu::Reference<cssa::XAccessible> SAL_CALL
171 getAccessibleAtPoint (
172 const css::awt::Point& aPoint)
173 throw (cssu::RuntimeException);
175 virtual css::awt::Rectangle SAL_CALL getBounds (void)
176 throw (cssu::RuntimeException);
178 virtual css::awt::Point SAL_CALL getLocation (void)
179 throw (cssu::RuntimeException);
181 virtual css::awt::Point SAL_CALL getLocationOnScreen (void)
182 throw (cssu::RuntimeException);
184 virtual css::awt::Size SAL_CALL getSize (void)
185 throw (cssu::RuntimeException);
187 virtual void SAL_CALL grabFocus (void)
188 throw (cssu::RuntimeException);
190 virtual sal_Int32 SAL_CALL getForeground (void)
191 throw (cssu::RuntimeException);
193 virtual sal_Int32 SAL_CALL getBackground (void)
194 throw (cssu::RuntimeException);
197 //----- XAccessibleEventBroadcaster --------------------------------------
199 virtual void SAL_CALL addEventListener (
200 const cssu::Reference<cssa::XAccessibleEventListener>& rxListener)
201 throw (cssu::RuntimeException);
203 virtual void SAL_CALL removeEventListener (
204 const cssu::Reference<cssa::XAccessibleEventListener>& rxListener)
205 throw (cssu::RuntimeException);
207 using PresenterAccessibleObjectInterfaceBase::addEventListener;
208 using PresenterAccessibleObjectInterfaceBase::removeEventListener;
210 //----- XWindowListener ---------------------------------------------------
212 virtual void SAL_CALL windowResized (const css::awt::WindowEvent& rEvent)
213 throw (cssu::RuntimeException);
215 virtual void SAL_CALL windowMoved (const css::awt::WindowEvent& rEvent)
216 throw (cssu::RuntimeException);
218 virtual void SAL_CALL windowShown (const css::lang::EventObject& rEvent)
219 throw (cssu::RuntimeException);
221 virtual void SAL_CALL windowHidden (const css::lang::EventObject& rEvent)
222 throw (cssu::RuntimeException);
225 //----- XEventListener ----------------------------------------------------
227 virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent)
228 throw (cssu::RuntimeException);
231 protected:
232 ::rtl::OUString msName;
233 cssu::Reference<css::awt::XWindow2> mxContentWindow;
234 cssu::Reference<css::awt::XWindow2> mxBorderWindow;
235 const css::lang::Locale maLocale;
236 const sal_Int16 mnRole;
237 sal_uInt32 mnStateSet;
238 bool mbIsFocused;
239 cssu::Reference<cssa::XAccessible> mxParentAccessible;
240 ::std::vector<rtl::Reference<AccessibleObject> > maChildren;
241 ::std::vector<Reference<XAccessibleEventListener> > maListeners;
243 virtual awt::Point GetRelativeLocation (void);
244 virtual awt::Size GetSize (void);
245 virtual awt::Point GetAbsoluteParentLocation (void);
247 virtual bool GetWindowState (const sal_Int16 nType) const;
249 void UpdateState (const sal_Int16 aState, const bool bValue);
251 sal_Bool IsDisposed (void) const;
253 void ThrowIfDisposed (void) const
254 throw (css::lang::DisposedException);
256 enum ExceptionType { ET_Runtime, ET_Disposed, ET_IndexOutOfBounds };
257 void ThrowException (const sal_Char* pMessage, const ExceptionType eExceptionType) const;
263 //===== AccessibleStateSet ====================================================
265 namespace {
266 typedef ::cppu::WeakComponentImplHelper1 <
267 cssa::XAccessibleStateSet
268 > AccessibleStateSetInterfaceBase;
271 class AccessibleStateSet
272 : public ::cppu::BaseMutex,
273 public AccessibleStateSetInterfaceBase
275 public:
276 AccessibleStateSet (const sal_Int32 nStateSet);
277 virtual ~AccessibleStateSet (void);
279 static sal_uInt32 GetStateMask (const sal_Int16 nType);
281 //----- XAccessibleStateSet -----------------------------------------------
283 virtual sal_Bool SAL_CALL isEmpty (void)
284 throw (cssu::RuntimeException);
286 virtual sal_Bool SAL_CALL contains (sal_Int16 nState)
287 throw (cssu::RuntimeException);
289 virtual sal_Bool SAL_CALL containsAll (const cssu::Sequence<sal_Int16>& rStateSet)
290 throw (cssu::RuntimeException);
292 virtual cssu::Sequence<sal_Int16> SAL_CALL getStates (void)
293 throw (cssu::RuntimeException);
295 private:
296 const sal_Int32 mnStateSet;
302 //===== AccessibleRelationSet =================================================
304 namespace {
305 typedef ::cppu::WeakComponentImplHelper1 <
306 cssa::XAccessibleRelationSet
307 > AccessibleRelationSetInterfaceBase;
310 class AccessibleRelationSet
311 : public ::cppu::BaseMutex,
312 public AccessibleRelationSetInterfaceBase
314 public:
315 AccessibleRelationSet (void);
316 virtual ~AccessibleRelationSet (void);
318 void AddRelation (
319 const sal_Int16 nRelationType,
320 const Reference<XInterface>& rxObject);
323 //----- XAccessibleRelationSet --------------------------------------------
325 virtual sal_Int32 SAL_CALL getRelationCount (void)
326 throw (cssu::RuntimeException);
328 virtual AccessibleRelation SAL_CALL getRelation (sal_Int32 nIndex)
329 throw (cssu::RuntimeException, css::lang::IndexOutOfBoundsException);
331 virtual sal_Bool SAL_CALL containsRelation (sal_Int16 nRelationType)
332 throw (cssu::RuntimeException);
334 virtual AccessibleRelation SAL_CALL getRelationByType (sal_Int16 nRelationType)
335 throw (cssu::RuntimeException);
337 private:
338 ::std::vector<AccessibleRelation> maRelations;
344 //===== PresenterAccessibleParagraph ==========================================
346 namespace {
347 typedef ::cppu::ImplInheritanceHelper1 <
348 PresenterAccessible::AccessibleObject,
349 cssa::XAccessibleText
350 > PresenterAccessibleParagraphInterfaceBase;
356 class PresenterAccessible::AccessibleParagraph
357 : public PresenterAccessibleParagraphInterfaceBase
359 public:
360 AccessibleParagraph (
361 const css::lang::Locale aLocale,
362 const sal_Int16 nRole,
363 const ::rtl::OUString& rsName,
364 const SharedPresenterTextParagraph& rpParagraph,
365 const sal_Int32 nParagraphIndex);
367 virtual ~AccessibleParagraph (void);
370 //----- XAccessibleContext ------------------------------------------------
372 virtual cssu::Reference<cssa::XAccessibleRelationSet> SAL_CALL
373 getAccessibleRelationSet (void)
374 throw (cssu::RuntimeException);
377 //----- XAccessibleText ---------------------------------------------------
379 virtual sal_Int32 SAL_CALL getCaretPosition (void)
380 throw (cssu::RuntimeException);
382 virtual sal_Bool SAL_CALL setCaretPosition (sal_Int32 nIndex)
383 throw (::com::sun::star::lang::IndexOutOfBoundsException, cssu::RuntimeException);
385 virtual sal_Unicode SAL_CALL getCharacter (sal_Int32 nIndex)
386 throw (::com::sun::star::lang::IndexOutOfBoundsException, cssu::RuntimeException);
388 virtual cssu::Sequence<css::beans::PropertyValue> SAL_CALL
389 getCharacterAttributes (
390 ::sal_Int32 nIndex,
391 const cssu::Sequence<rtl::OUString>& rRequestedAttributes)
392 throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException);
394 virtual css::awt::Rectangle SAL_CALL getCharacterBounds (sal_Int32 nIndex)
395 throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException);
397 virtual sal_Int32 SAL_CALL getCharacterCount (void)
398 throw (cssu::RuntimeException);
400 virtual sal_Int32 SAL_CALL getIndexAtPoint (const css::awt::Point& rPoint)
401 throw (cssu::RuntimeException);
403 virtual ::rtl::OUString SAL_CALL getSelectedText (void)
404 throw (cssu::RuntimeException);
406 virtual sal_Int32 SAL_CALL getSelectionStart (void)
407 throw (cssu::RuntimeException);
409 virtual sal_Int32 SAL_CALL getSelectionEnd (void)
410 throw (cssu::RuntimeException);
412 virtual sal_Bool SAL_CALL setSelection (sal_Int32 nStartIndex, sal_Int32 nEndIndex)
413 throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException);
415 virtual ::rtl::OUString SAL_CALL getText (void)
416 throw (cssu::RuntimeException);
418 virtual ::rtl::OUString SAL_CALL getTextRange (
419 sal_Int32 nStartIndex,
420 sal_Int32 nEndIndex)
421 throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException);
423 virtual cssa::TextSegment SAL_CALL getTextAtIndex (
424 sal_Int32 nIndex,
425 sal_Int16 nTextType)
426 throw (css::lang::IndexOutOfBoundsException,
427 css::lang::IllegalArgumentException,
428 cssu::RuntimeException);
430 virtual cssa::TextSegment SAL_CALL getTextBeforeIndex (
431 sal_Int32 nIndex,
432 sal_Int16 nTextType)
433 throw (css::lang::IndexOutOfBoundsException,
434 css::lang::IllegalArgumentException,
435 cssu::RuntimeException);
437 virtual cssa::TextSegment SAL_CALL getTextBehindIndex (
438 sal_Int32 nIndex,
439 sal_Int16 nTextType)
440 throw (css::lang::IndexOutOfBoundsException,
441 css::lang::IllegalArgumentException,
442 cssu::RuntimeException);
444 virtual ::sal_Bool SAL_CALL copyText (sal_Int32 nStartIndex, sal_Int32 nEndIndex)
445 throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException);
448 protected:
449 virtual awt::Point GetRelativeLocation (void);
450 virtual awt::Size GetSize (void);
451 virtual awt::Point GetAbsoluteParentLocation (void);
452 virtual bool GetWindowState (const sal_Int16 nType) const;
454 private:
455 SharedPresenterTextParagraph mpParagraph;
456 const sal_Int32 mnParagraphIndex;
462 //===== AccessibleConsole =====================================================
464 class AccessibleConsole
466 public:
467 static rtl::Reference<PresenterAccessible::AccessibleObject> Create (
468 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
469 const lang::Locale aLocale)
471 OUString sName (A2S("Presenter Console"));
472 PresenterConfigurationAccess aConfiguration (
473 rxContext,
474 OUString::createFromAscii("/org.openoffice.Office.extension.PresenterScreen/"),
475 PresenterConfigurationAccess::READ_ONLY);
476 aConfiguration.GetConfigurationNode(A2S("Presenter/Accessibility/Console/String"))
477 >>= sName;
479 rtl::Reference<PresenterAccessible::AccessibleObject> pObject (
480 new PresenterAccessible::AccessibleObject(
481 aLocale, AccessibleRole::PANEL, sName));
482 pObject->LateInitialization();
483 pObject->UpdateStateSet();
485 return pObject;
492 //===== AccessiblePreview =====================================================
494 class AccessiblePreview
496 public:
497 static rtl::Reference<PresenterAccessible::AccessibleObject> Create (
498 const Reference<css::uno::XComponentContext>& rxContext,
499 const lang::Locale aLocale,
500 const Reference<awt::XWindow>& rxContentWindow,
501 const Reference<awt::XWindow>& rxBorderWindow)
503 OUString sName (A2S("Presenter Notes Window"));
505 PresenterConfigurationAccess aConfiguration (
506 rxContext,
507 OUString::createFromAscii("/org.openoffice.Office.extension.PresenterScreen/"),
508 PresenterConfigurationAccess::READ_ONLY);
509 aConfiguration.GetConfigurationNode(A2S("Presenter/Accessibility/Preview/String"))
510 >>= sName;
513 rtl::Reference<PresenterAccessible::AccessibleObject> pObject (
514 new PresenterAccessible::AccessibleObject(
515 aLocale,
516 AccessibleRole::LABEL,
517 sName));
518 pObject->LateInitialization();
519 pObject->UpdateStateSet();
520 pObject->SetWindow(rxContentWindow, rxBorderWindow);
522 return pObject;
529 //===== AccessibleNotes =======================================================
531 class AccessibleNotes : public PresenterAccessible::AccessibleObject
533 public:
534 AccessibleNotes (
535 const css::lang::Locale aLocale,
536 const sal_Int16 nRole,
537 const ::rtl::OUString& rsName);
540 static rtl::Reference<PresenterAccessible::AccessibleObject> Create (
541 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
542 const lang::Locale aLocale,
543 const Reference<awt::XWindow>& rxContentWindow,
544 const Reference<awt::XWindow>& rxBorderWindow,
545 const ::boost::shared_ptr<PresenterTextView>& rpTextView);
547 void SetTextView (const ::boost::shared_ptr<PresenterTextView>& rpTextView);
549 virtual void SetWindow (
550 const cssu::Reference<css::awt::XWindow>& rxContentWindow,
551 const cssu::Reference<css::awt::XWindow>& rxBorderWindow);
553 private:
554 ::boost::shared_ptr<PresenterTextView> mpTextView;
556 void NotifyCaretChange (
557 const sal_Int32 nOldParagraphIndex,
558 const sal_Int32 nOldCharacterIndex,
559 const sal_Int32 nNewParagraphIndex,
560 const sal_Int32 nNewCharacterIndex);
561 void HandleTextChange (void);
567 //===== AccessibleFocusManager ================================================
569 /** A singleton class that makes sure that only one accessibility object in
570 the PresenterConsole hierarchy has the focus.
572 class AccessibleFocusManager
574 public:
575 static ::boost::shared_ptr<AccessibleFocusManager> Instance (void);
577 void AddFocusableObject (const ::rtl::Reference<PresenterAccessible::AccessibleObject>& rpObject);
578 void RemoveFocusableObject (const ::rtl::Reference<PresenterAccessible::AccessibleObject>& rpObject);
580 void FocusObject (const ::rtl::Reference<PresenterAccessible::AccessibleObject>& rpObject);
582 private:
583 static ::boost::shared_ptr<AccessibleFocusManager> mpInstance;
584 ::std::vector<rtl::Reference<PresenterAccessible::AccessibleObject> > maFocusableObjects;
586 AccessibleFocusManager (void);
592 //===== PresenterAccessible ===================================================
594 PresenterAccessible::PresenterAccessible (
595 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
596 const ::rtl::Reference<PresenterController>& rpPresenterController,
597 const Reference<drawing::framework::XPane>& rxMainPane)
598 : PresenterAccessibleInterfaceBase(m_aMutex),
599 mxComponentContext(rxContext),
600 mpPresenterController(rpPresenterController),
601 mxMainPaneId(rxMainPane.is() ? rxMainPane->getResourceId() : Reference<XResourceId>()),
602 mxMainPane(rxMainPane, UNO_QUERY),
603 mxMainWindow(),
604 mxPreviewContentWindow(),
605 mxPreviewBorderWindow(),
606 mxNotesContentWindow(),
607 mxNotesBorderWindow(),
608 mpAccessibleConsole(),
609 mpAccessiblePreview(),
610 mpAccessibleNotes(),
611 mxAccessibleParent()
613 if (mxMainPane.is())
614 mxMainPane->setAccessible(this);
620 PresenterAccessible::~PresenterAccessible (void)
627 PresenterPaneContainer::SharedPaneDescriptor PresenterAccessible::GetPreviewPane (void) const
629 PresenterPaneContainer::SharedPaneDescriptor pPreviewPane;
631 if ( ! mpPresenterController.is())
632 return pPreviewPane;
634 rtl::Reference<PresenterPaneContainer> pContainer (mpPresenterController->GetPaneContainer());
635 if ( ! pContainer.is())
636 return pPreviewPane;
638 pPreviewPane = pContainer->FindPaneURL(PresenterPaneFactory::msCurrentSlidePreviewPaneURL);
639 Reference<drawing::framework::XPane> xPreviewPane;
640 if (pPreviewPane)
641 xPreviewPane = pPreviewPane->mxPane.get();
642 if ( ! xPreviewPane.is())
644 pPreviewPane = pContainer->FindPaneURL(PresenterPaneFactory::msSlideSorterPaneURL);
646 return pPreviewPane;
652 void PresenterAccessible::UpdateAccessibilityHierarchy (void)
654 if ( ! mpPresenterController.is())
655 return;
657 Reference<drawing::framework::XConfigurationController> xConfigurationController(
658 mpPresenterController->GetConfigurationController());
659 if ( ! xConfigurationController.is())
660 return;
662 rtl::Reference<PresenterPaneContainer> pPaneContainer (
663 mpPresenterController->GetPaneContainer());
664 if ( ! pPaneContainer.is())
665 return;
667 if ( ! mpAccessibleConsole.is())
668 return;
670 // Get the preview pane (standard or notes view) or the slide overview
671 // pane.
672 PresenterPaneContainer::SharedPaneDescriptor pPreviewPane(GetPreviewPane());
673 Reference<drawing::framework::XPane> xPreviewPane;
674 if (pPreviewPane)
675 xPreviewPane = pPreviewPane->mxPane.get();
677 // Get the notes pane.
678 PresenterPaneContainer::SharedPaneDescriptor pNotesPane(
679 pPaneContainer->FindPaneURL(PresenterPaneFactory::msNotesPaneURL));
680 Reference<drawing::framework::XPane> xNotesPane;
681 if (pNotesPane)
682 xNotesPane = pNotesPane->mxPane.get();
684 // Get the notes view.
685 Reference<drawing::framework::XView> xNotesView;
686 if (pNotesPane)
687 xNotesView = pNotesPane->mxView;
688 rtl::Reference<PresenterNotesView> pNotesView (
689 dynamic_cast<PresenterNotesView*>(xNotesView.get()));
691 UpdateAccessibilityHierarchy(
692 pPreviewPane ? pPreviewPane->mxContentWindow : Reference<awt::XWindow>(),
693 pPreviewPane ? pPreviewPane->mxBorderWindow : Reference<awt::XWindow>(),
694 (pPreviewPane&&pPreviewPane->mxPane.is()) ? pPreviewPane->mxPane->GetTitle() : OUString(),
695 pNotesPane ? pNotesPane->mxContentWindow : Reference<awt::XWindow>(),
696 pNotesPane ? pNotesPane->mxBorderWindow : Reference<awt::XWindow>(),
697 pNotesView.is()
698 ? pNotesView->GetTextView()
699 : ::boost::shared_ptr<PresenterTextView>());
706 void PresenterAccessible::UpdateAccessibilityHierarchy (
707 const Reference<awt::XWindow>& rxPreviewContentWindow,
708 const Reference<awt::XWindow>& rxPreviewBorderWindow,
709 const ::rtl::OUString& rsTitle,
710 const Reference<awt::XWindow>& rxNotesContentWindow,
711 const Reference<awt::XWindow>& rxNotesBorderWindow,
712 const ::boost::shared_ptr<PresenterTextView>& rpNotesTextView)
714 if ( ! mpAccessibleConsole.is())
715 return;
717 if (mxPreviewContentWindow != rxPreviewContentWindow)
719 if (mpAccessiblePreview.is())
721 mpAccessibleConsole->RemoveChild(mpAccessiblePreview);
722 mpAccessiblePreview = NULL;
725 mxPreviewContentWindow = rxPreviewContentWindow;
726 mxPreviewBorderWindow = rxPreviewBorderWindow;
728 if (mxPreviewContentWindow.is())
730 mpAccessiblePreview = AccessiblePreview::Create(
731 mxComponentContext,
732 lang::Locale(),
733 mxPreviewContentWindow,
734 mxPreviewBorderWindow);
735 mpAccessibleConsole->AddChild(mpAccessiblePreview);
736 mpAccessiblePreview->SetAccessibleName(rsTitle);
740 if (mxNotesContentWindow != rxNotesContentWindow)
742 if (mpAccessibleNotes.is())
744 mpAccessibleConsole->RemoveChild(mpAccessibleConsole.get());
745 mpAccessibleNotes = NULL;
748 mxNotesContentWindow = rxNotesContentWindow;
749 mxNotesBorderWindow = rxNotesBorderWindow;
751 if (mxNotesContentWindow.is())
753 mpAccessibleNotes = AccessibleNotes::Create(
754 mxComponentContext,
755 lang::Locale(),
756 mxNotesContentWindow,
757 mxNotesBorderWindow,
758 rpNotesTextView);
759 mpAccessibleConsole->AddChild(mpAccessibleNotes.get());
767 void PresenterAccessible::NotifyCurrentSlideChange (
768 const sal_Int32 nCurrentSlideIndex,
769 const sal_Int32 nSlideCount)
771 (void)nCurrentSlideIndex;
772 (void)nSlideCount;
774 if (mpAccessiblePreview.is())
776 PresenterPaneContainer::SharedPaneDescriptor pPreviewPane (GetPreviewPane());
777 mpAccessiblePreview->SetAccessibleName(
778 (pPreviewPane&&pPreviewPane->mxPane.is()
779 ? pPreviewPane->mxPane->GetTitle()
780 : rtl::OUString()));
783 // Play some focus ping-pong to trigger AT tools.
784 //AccessibleFocusManager::Instance()->FocusObject(mpAccessibleConsole);
785 AccessibleFocusManager::Instance()->FocusObject(mpAccessiblePreview);
791 bool PresenterAccessible::IsAccessibilityActive (void) const
793 return mpAccessibleConsole.is();
799 void SAL_CALL PresenterAccessible::disposing (void)
801 UpdateAccessibilityHierarchy(
802 NULL,
803 NULL,
804 OUString(),
805 NULL,
806 NULL,
807 ::boost::shared_ptr<PresenterTextView>());
809 if (mxMainWindow.is())
811 mxMainWindow->removeFocusListener(this);
813 if (mxMainPane.is())
814 mxMainPane->setAccessible(NULL);
817 mpAccessiblePreview = NULL;
818 mpAccessibleNotes = NULL;
819 mpAccessibleConsole = NULL;
825 //----- XAccessible -----------------------------------------------------------
827 Reference<XAccessibleContext> SAL_CALL PresenterAccessible::getAccessibleContext (void)
828 throw (cssu::RuntimeException)
830 if ( ! mpAccessibleConsole.is())
832 Reference<XPane> xMainPane (mxMainPane, UNO_QUERY);
833 if (xMainPane.is())
835 mxMainWindow = Reference<awt::XWindow>(xMainPane->getWindow(), UNO_QUERY);
836 mxMainWindow->addFocusListener(this);
838 mpAccessibleConsole = AccessibleConsole::Create(
839 mxComponentContext, css::lang::Locale());
840 mpAccessibleConsole->SetWindow(mxMainWindow, NULL);
841 mpAccessibleConsole->SetAccessibleParent(mxAccessibleParent);
842 UpdateAccessibilityHierarchy();
843 if (mpPresenterController.is())
844 mpPresenterController->SetAccessibilityActiveState(true);
846 return mpAccessibleConsole->getAccessibleContext();
853 //----- XFocusListener ----------------------------------------------------
855 void SAL_CALL PresenterAccessible::focusGained (const css::awt::FocusEvent& rEvent)
856 throw (cssu::RuntimeException)
858 (void)rEvent;
860 #ifdef VERBOSE
861 OSL_TRACE("PresenterAccessible::focusGained at %x and window %x\r", this,
862 mxMainWindow.get());
863 #endif
865 AccessibleFocusManager::Instance()->FocusObject(mpAccessibleConsole);
871 void SAL_CALL PresenterAccessible::focusLost (const css::awt::FocusEvent& rEvent)
872 throw (cssu::RuntimeException)
874 (void)rEvent;
876 #ifdef VERBOSE
877 OSL_TRACE("PresenterAccessible::focusLost at %x\r", this);
878 #endif
880 AccessibleFocusManager::Instance()->FocusObject(NULL);
886 //----- XEventListener ----------------------------------------------------
888 void SAL_CALL PresenterAccessible::disposing (const css::lang::EventObject& rEvent)
889 throw (cssu::RuntimeException)
891 if (rEvent.Source == mxMainWindow)
892 mxMainWindow = NULL;
898 //----- XInitialize -----------------------------------------------------------
900 void SAL_CALL PresenterAccessible::initialize (const cssu::Sequence<cssu::Any>& rArguments)
901 throw (cssu::RuntimeException)
903 if (rArguments.getLength() >= 1)
905 mxAccessibleParent = Reference<XAccessible>(rArguments[0], UNO_QUERY);
906 if (mpAccessibleConsole.is())
907 mpAccessibleConsole->SetAccessibleParent(mxAccessibleParent);
914 //===== PresenterAccessible::AccessibleObject =========================================
916 PresenterAccessible::AccessibleObject::AccessibleObject (
917 const lang::Locale aLocale,
918 const sal_Int16 nRole,
919 const OUString& rsName)
920 : PresenterAccessibleObjectInterfaceBase(m_aMutex),
921 msName(rsName),
922 mxContentWindow(),
923 mxBorderWindow(),
924 maLocale(aLocale),
925 mnRole(nRole),
926 mnStateSet(0),
927 mbIsFocused(false),
928 mxParentAccessible(),
929 maChildren(),
930 maListeners()
937 void PresenterAccessible::AccessibleObject::LateInitialization (void)
939 AccessibleFocusManager::Instance()->AddFocusableObject(this);
945 PresenterAccessible::AccessibleObject::~AccessibleObject (void)
952 void PresenterAccessible::AccessibleObject::SetWindow (
953 const Reference<awt::XWindow>& rxContentWindow,
954 const Reference<awt::XWindow>& rxBorderWindow)
956 Reference<awt::XWindow2> xContentWindow (rxContentWindow, UNO_QUERY);
958 if (mxContentWindow.get() != xContentWindow.get())
960 if (mxContentWindow.is())
962 mxContentWindow->removeWindowListener(this);
965 mxContentWindow = xContentWindow;
966 mxBorderWindow = Reference<awt::XWindow2>(rxBorderWindow, UNO_QUERY);
968 if (mxContentWindow.is())
970 mxContentWindow->addWindowListener(this);
973 UpdateStateSet();
980 void PresenterAccessible::AccessibleObject::SetAccessibleParent (
981 const Reference<XAccessible>& rxAccessibleParent)
983 mxParentAccessible = rxAccessibleParent;
989 void SAL_CALL PresenterAccessible::AccessibleObject::disposing (void)
991 AccessibleFocusManager::Instance()->RemoveFocusableObject(this);
992 SetWindow(NULL, NULL);
998 //----- XAccessible -------------------------------------------------------
1000 Reference<XAccessibleContext> SAL_CALL
1001 PresenterAccessible::AccessibleObject::getAccessibleContext (void)
1002 throw (RuntimeException)
1004 ThrowIfDisposed();
1006 return this;
1012 //----- XAccessibleContext ----------------------------------------------
1014 sal_Int32 SAL_CALL PresenterAccessible::AccessibleObject::getAccessibleChildCount (void)
1015 throw (cssu::RuntimeException)
1017 ThrowIfDisposed();
1019 const sal_Int32 nChildCount (maChildren.size());
1021 return nChildCount;
1027 Reference<XAccessible> SAL_CALL
1028 PresenterAccessible::AccessibleObject::getAccessibleChild (sal_Int32 nIndex)
1029 throw (lang::IndexOutOfBoundsException, RuntimeException)
1031 ThrowIfDisposed();
1033 if (nIndex<0 || nIndex>=sal_Int32(maChildren.size()))
1034 ThrowException("invalid child index", ET_IndexOutOfBounds);
1036 return Reference<XAccessible>(maChildren[nIndex].get());
1042 Reference<XAccessible> SAL_CALL
1043 PresenterAccessible::AccessibleObject::getAccessibleParent (void)
1044 throw (RuntimeException)
1046 ThrowIfDisposed();
1048 return mxParentAccessible;
1054 sal_Int32 SAL_CALL
1055 PresenterAccessible::AccessibleObject::getAccessibleIndexInParent (void)
1056 throw (RuntimeException)
1058 ThrowIfDisposed();
1060 const Reference<XAccessible> xThis (this);
1061 if (mxParentAccessible.is())
1063 const Reference<XAccessibleContext> xContext (mxParentAccessible->getAccessibleContext());
1064 for (sal_Int32 nIndex=0,nCount=xContext->getAccessibleChildCount();
1065 nIndex<nCount;
1066 ++nIndex)
1068 if (xContext->getAccessibleChild(nIndex) == xThis)
1069 return nIndex;
1073 return 0;
1079 sal_Int16 SAL_CALL
1080 PresenterAccessible::AccessibleObject::getAccessibleRole (void)
1081 throw (RuntimeException)
1083 ThrowIfDisposed();
1085 return mnRole;
1091 OUString SAL_CALL
1092 PresenterAccessible::AccessibleObject::getAccessibleDescription (void)
1093 throw (RuntimeException)
1095 ThrowIfDisposed();
1097 return msName;
1103 OUString SAL_CALL
1104 PresenterAccessible::AccessibleObject::getAccessibleName (void)
1105 throw (cssu::RuntimeException)
1107 ThrowIfDisposed();
1109 return msName;
1115 Reference<XAccessibleRelationSet> SAL_CALL
1116 PresenterAccessible::AccessibleObject::getAccessibleRelationSet (void)
1117 throw (RuntimeException)
1119 ThrowIfDisposed();
1121 return NULL;
1127 Reference<XAccessibleStateSet> SAL_CALL
1128 PresenterAccessible::AccessibleObject::getAccessibleStateSet (void)
1129 throw (RuntimeException)
1131 ThrowIfDisposed();
1133 return Reference<XAccessibleStateSet>(new AccessibleStateSet(mnStateSet));
1139 lang::Locale SAL_CALL
1140 PresenterAccessible::AccessibleObject::getLocale (void)
1141 throw (RuntimeException,
1142 IllegalAccessibleComponentStateException)
1144 ThrowIfDisposed();
1146 if (mxParentAccessible.is())
1148 Reference<XAccessibleContext> xParentContext (mxParentAccessible->getAccessibleContext());
1149 if (xParentContext.is())
1150 return xParentContext->getLocale();
1152 return maLocale;
1158 //----- XAccessibleComponent ------------------------------------------------
1160 sal_Bool SAL_CALL PresenterAccessible::AccessibleObject::containsPoint (
1161 const awt::Point& rPoint)
1162 throw (RuntimeException)
1164 ThrowIfDisposed();
1166 if (mxContentWindow.is())
1168 const awt::Rectangle aBox (getBounds());
1169 return rPoint.X>=aBox.X
1170 && rPoint.Y>=aBox.Y
1171 && rPoint.X<aBox.X+aBox.Width
1172 && rPoint.Y<aBox.Y+aBox.Height;
1174 else
1175 return false;
1181 Reference<XAccessible> SAL_CALL
1182 PresenterAccessible::AccessibleObject::getAccessibleAtPoint (const awt::Point& rPoint)
1183 throw (RuntimeException)
1185 (void)rPoint;
1186 ThrowIfDisposed();
1188 return Reference<XAccessible>();
1194 awt::Rectangle SAL_CALL PresenterAccessible::AccessibleObject::getBounds (void)
1195 throw (RuntimeException)
1197 ThrowIfDisposed();
1199 awt::Rectangle aBox;
1201 const awt::Point aLocation (GetRelativeLocation());
1202 const awt::Size aSize (GetSize());
1204 return awt::Rectangle (aLocation.X, aLocation.Y, aSize.Width, aSize.Height);
1210 awt::Point SAL_CALL PresenterAccessible::AccessibleObject::getLocation (void)
1211 throw (RuntimeException)
1213 ThrowIfDisposed();
1215 const awt::Point aLocation (GetRelativeLocation());
1217 return aLocation;
1223 awt::Point SAL_CALL PresenterAccessible::AccessibleObject::getLocationOnScreen (void)
1224 throw (RuntimeException)
1226 ThrowIfDisposed();
1228 awt::Point aRelativeLocation (GetRelativeLocation());
1229 awt::Point aParentLocationOnScreen (GetAbsoluteParentLocation());
1231 return awt::Point(
1232 aRelativeLocation.X + aParentLocationOnScreen.X,
1233 aRelativeLocation.Y + aParentLocationOnScreen.Y);
1239 awt::Size SAL_CALL PresenterAccessible::AccessibleObject::getSize (void)
1240 throw (RuntimeException)
1242 ThrowIfDisposed();
1244 const awt::Size aSize (GetSize());
1246 return aSize;
1252 void SAL_CALL PresenterAccessible::AccessibleObject::grabFocus (void)
1253 throw (RuntimeException)
1255 ThrowIfDisposed();
1256 if (mxBorderWindow.is())
1257 mxBorderWindow->setFocus();
1258 else if (mxContentWindow.is())
1259 mxContentWindow->setFocus();
1265 sal_Int32 SAL_CALL PresenterAccessible::AccessibleObject::getForeground (void)
1266 throw (RuntimeException)
1268 ThrowIfDisposed();
1270 return 0x00ffffff;
1276 sal_Int32 SAL_CALL PresenterAccessible::AccessibleObject::getBackground (void)
1277 throw (RuntimeException)
1279 ThrowIfDisposed();
1281 return 0x00000000;
1287 //----- XAccessibleEventBroadcaster -------------------------------------------
1289 void SAL_CALL PresenterAccessible::AccessibleObject::addEventListener (
1290 const Reference<XAccessibleEventListener>& rxListener)
1291 throw (RuntimeException)
1293 if (rxListener.is())
1295 const osl::MutexGuard aGuard(m_aMutex);
1297 if (IsDisposed())
1299 uno::Reference<uno::XInterface> xThis (static_cast<XWeak*>(this), UNO_QUERY);
1300 rxListener->disposing (lang::EventObject(xThis));
1302 else
1304 maListeners.push_back(rxListener);
1312 void SAL_CALL PresenterAccessible::AccessibleObject::removeEventListener (
1313 const Reference<XAccessibleEventListener>& rxListener)
1314 throw (RuntimeException)
1316 ThrowIfDisposed();
1317 if (rxListener.is())
1319 const osl::MutexGuard aGuard(m_aMutex);
1321 maListeners.erase(std::remove(maListeners.begin(), maListeners.end(), rxListener));
1328 //----- XWindowListener ---------------------------------------------------
1330 void SAL_CALL PresenterAccessible::AccessibleObject::windowResized (
1331 const css::awt::WindowEvent& rEvent)
1332 throw (cssu::RuntimeException)
1334 (void)rEvent;
1336 FireAccessibleEvent(AccessibleEventId::BOUNDRECT_CHANGED, Any(), Any());
1342 void SAL_CALL PresenterAccessible::AccessibleObject::windowMoved (
1343 const css::awt::WindowEvent& rEvent)
1344 throw (cssu::RuntimeException)
1346 (void)rEvent;
1348 FireAccessibleEvent(AccessibleEventId::BOUNDRECT_CHANGED, Any(), Any());
1354 void SAL_CALL PresenterAccessible::AccessibleObject::windowShown (
1355 const css::lang::EventObject& rEvent)
1356 throw (cssu::RuntimeException)
1358 (void)rEvent;
1359 UpdateStateSet();
1365 void SAL_CALL PresenterAccessible::AccessibleObject::windowHidden (
1366 const css::lang::EventObject& rEvent)
1367 throw (cssu::RuntimeException)
1369 (void)rEvent;
1370 UpdateStateSet();
1376 //----- XEventListener --------------------------------------------------------
1378 void SAL_CALL PresenterAccessible::AccessibleObject::disposing (const css::lang::EventObject& rEvent)
1379 throw (cssu::RuntimeException)
1381 if (rEvent.Source == mxContentWindow)
1383 mxContentWindow = NULL;
1384 mxBorderWindow = NULL;
1386 else
1388 SetWindow(NULL, NULL);
1395 //----- private ---------------------------------------------------------------
1397 bool PresenterAccessible::AccessibleObject::GetWindowState (const sal_Int16 nType) const
1399 switch (nType)
1401 case AccessibleStateType::ENABLED:
1402 return mxContentWindow.is() && mxContentWindow->isEnabled();
1404 case AccessibleStateType::FOCUSABLE:
1405 return true;
1407 case AccessibleStateType::FOCUSED:
1408 return mbIsFocused;
1410 case AccessibleStateType::SHOWING:
1411 return mxContentWindow.is() && mxContentWindow->isVisible();
1413 default:
1414 return false;
1421 void PresenterAccessible::AccessibleObject::UpdateStateSet (void)
1423 UpdateState(AccessibleStateType::FOCUSABLE, true);
1424 UpdateState(AccessibleStateType::VISIBLE, true);
1425 UpdateState(AccessibleStateType::ENABLED, true);
1426 UpdateState(AccessibleStateType::MULTI_LINE, true);
1427 UpdateState(AccessibleStateType::SENSITIVE, true);
1429 UpdateState(AccessibleStateType::ENABLED, GetWindowState(AccessibleStateType::ENABLED));
1430 UpdateState(AccessibleStateType::FOCUSED, GetWindowState(AccessibleStateType::FOCUSED));
1431 UpdateState(AccessibleStateType::SHOWING, GetWindowState(AccessibleStateType::SHOWING));
1432 // UpdateState(AccessibleStateType::ACTIVE, GetWindowState(AccessibleStateType::ACTIVE));
1438 void PresenterAccessible::AccessibleObject::UpdateState(
1439 const sal_Int16 nState,
1440 const bool bValue)
1442 const sal_uInt32 nStateMask (AccessibleStateSet::GetStateMask(nState));
1443 if (((mnStateSet & nStateMask)!=0) != bValue)
1445 if (bValue)
1447 mnStateSet |= nStateMask;
1448 FireAccessibleEvent(AccessibleEventId::STATE_CHANGED, Any(), Any(nState));
1450 else
1452 mnStateSet &= ~nStateMask;
1453 FireAccessibleEvent(AccessibleEventId::STATE_CHANGED, Any(nState), Any());
1461 void PresenterAccessible::AccessibleObject::AddChild (
1462 const ::rtl::Reference<AccessibleObject>& rpChild)
1464 maChildren.push_back(rpChild);
1465 rpChild->SetAccessibleParent(this);
1466 FireAccessibleEvent(AccessibleEventId::INVALIDATE_ALL_CHILDREN, Any(), Any());
1472 void PresenterAccessible::AccessibleObject::RemoveChild (
1473 const ::rtl::Reference<AccessibleObject>& rpChild)
1475 rpChild->SetAccessibleParent(Reference<XAccessible>());
1476 maChildren.erase(::std::find(maChildren.begin(), maChildren.end(), rpChild));
1477 FireAccessibleEvent(AccessibleEventId::INVALIDATE_ALL_CHILDREN, Any(), Any());
1483 void PresenterAccessible::AccessibleObject::SetIsFocused (const bool bIsFocused)
1485 if (mbIsFocused != bIsFocused)
1487 mbIsFocused = bIsFocused;
1488 UpdateStateSet();
1495 void PresenterAccessible::AccessibleObject::SetAccessibleName (const ::rtl::OUString& rsName)
1497 if (msName != rsName)
1499 const OUString sOldName(msName);
1500 msName = rsName;
1501 FireAccessibleEvent(AccessibleEventId::NAME_CHANGED, Any(sOldName), Any(msName));
1508 void PresenterAccessible::AccessibleObject::FireAccessibleEvent (
1509 const sal_Int16 nEventId,
1510 const uno::Any& rOldValue,
1511 const uno::Any& rNewValue )
1513 AccessibleEventObject aEventObject;
1515 aEventObject.Source = Reference<XWeak>(this);
1516 aEventObject.EventId = nEventId;
1517 aEventObject.NewValue = rNewValue;
1518 aEventObject.OldValue = rOldValue;
1520 ::std::vector<Reference<XAccessibleEventListener> > aListenerCopy(maListeners);
1521 for (::std::vector<Reference<XAccessibleEventListener> >::const_iterator
1522 iListener(aListenerCopy.begin()),
1523 iEnd(aListenerCopy.end());
1524 iListener!=iEnd;
1525 ++iListener)
1529 (*iListener)->notifyEvent(aEventObject);
1531 catch(lang::DisposedException&)
1533 // Listener has been disposed and should have been removed
1534 // already.
1535 removeEventListener(*iListener);
1537 catch(Exception&)
1539 // Ignore all other exceptions and assume that they are
1540 // caused by a temporary problem.
1547 awt::Point PresenterAccessible::AccessibleObject::GetRelativeLocation (void)
1549 awt::Point aLocation;
1550 if (mxContentWindow.is())
1552 const awt::Rectangle aContentBox (mxContentWindow->getPosSize());
1553 aLocation.X = aContentBox.X;
1554 aLocation.Y = aContentBox.Y;
1555 if (mxBorderWindow.is())
1557 const awt::Rectangle aBorderBox (mxBorderWindow->getPosSize());
1558 aLocation.X += aBorderBox.X;
1559 aLocation.Y += aBorderBox.Y;
1562 return aLocation;
1568 awt::Size PresenterAccessible::AccessibleObject::GetSize (void)
1570 if (mxContentWindow.is())
1572 const awt::Rectangle aBox (mxContentWindow->getPosSize());
1573 return awt::Size(aBox.Width, aBox.Height);
1575 else
1576 return awt::Size();
1582 awt::Point PresenterAccessible::AccessibleObject::GetAbsoluteParentLocation (void)
1584 Reference<XAccessibleComponent> xParentComponent;
1585 if (mxParentAccessible.is())
1586 xParentComponent = Reference<XAccessibleComponent>(
1587 mxParentAccessible->getAccessibleContext(), UNO_QUERY);
1588 if (xParentComponent.is())
1589 return xParentComponent->getLocationOnScreen();
1590 else
1591 return awt::Point();
1597 sal_Bool PresenterAccessible::AccessibleObject::IsDisposed (void) const
1599 return (rBHelper.bDisposed || rBHelper.bInDispose);
1605 void PresenterAccessible::AccessibleObject::ThrowIfDisposed (void) const
1606 throw (lang::DisposedException)
1608 if (rBHelper.bDisposed || rBHelper.bInDispose)
1609 ThrowException("object has already been disposed", ET_Disposed);
1615 void PresenterAccessible::AccessibleObject::ThrowException (
1616 const sal_Char* pMessage,
1617 const ExceptionType eExceptionType) const
1619 const OUString sMessage (OUString(A2S("PresenterAccessible: ")) + OUString(A2S(pMessage)));
1620 const Reference<XInterface> xObject (
1621 const_cast<uno::XWeak*>(static_cast<const uno::XWeak*>(this)));
1622 switch (eExceptionType)
1624 default:
1625 case ET_Runtime:
1626 throw RuntimeException(sMessage, xObject);
1627 case ET_Disposed:
1628 throw lang::DisposedException(sMessage, xObject);
1629 case ET_IndexOutOfBounds:
1630 throw lang::IndexOutOfBoundsException(sMessage, xObject);
1638 //===== AccessibleStateSet ====================================================
1640 AccessibleStateSet::AccessibleStateSet (const sal_Int32 nStateSet)
1641 : AccessibleStateSetInterfaceBase(m_aMutex),
1642 mnStateSet (nStateSet)
1649 AccessibleStateSet::~AccessibleStateSet (void)
1656 sal_uInt32 AccessibleStateSet::GetStateMask (const sal_Int16 nState)
1658 if (nState<0 || nState>=sal_Int16(sizeof(sal_uInt32)*8))
1660 throw RuntimeException(A2S("AccessibleStateSet::GetStateMask: invalid state"), NULL);
1663 return 1<<nState;
1669 //----- XAccessibleStateSet ---------------------------------------------------
1671 sal_Bool SAL_CALL AccessibleStateSet::isEmpty (void)
1672 throw (cssu::RuntimeException)
1674 return mnStateSet==0;
1680 sal_Bool SAL_CALL AccessibleStateSet::contains (sal_Int16 nState)
1681 throw (cssu::RuntimeException)
1683 return (mnStateSet & GetStateMask(nState)) != 0;
1689 sal_Bool SAL_CALL AccessibleStateSet::containsAll (const cssu::Sequence<sal_Int16>& rStateSet)
1690 throw (cssu::RuntimeException)
1692 for (sal_Int32 nIndex=0,nCount=rStateSet.getLength(); nIndex<nCount; ++nIndex)
1694 if ((mnStateSet & GetStateMask(rStateSet[nIndex])) == 0)
1695 return sal_False;
1697 return sal_True;
1703 cssu::Sequence<sal_Int16> SAL_CALL AccessibleStateSet::getStates (void)
1704 throw (cssu::RuntimeException)
1706 ::std::vector<sal_Int16> aStates;
1707 aStates.reserve(sizeof(mnStateSet)*8);
1708 for (sal_uInt16 nIndex=0; nIndex<sizeof(mnStateSet)*8; ++nIndex)
1709 if ((mnStateSet & GetStateMask(nIndex)) != 0)
1710 aStates.push_back(nIndex);
1711 return Sequence<sal_Int16>(&aStates.front(), aStates.size());
1717 //===== AccessibleRelationSet =================================================
1719 AccessibleRelationSet::AccessibleRelationSet (void)
1720 : AccessibleRelationSetInterfaceBase(m_aMutex),
1721 maRelations()
1728 AccessibleRelationSet::~AccessibleRelationSet (void)
1735 void AccessibleRelationSet::AddRelation (
1736 const sal_Int16 nRelationType,
1737 const Reference<XInterface>& rxObject)
1739 maRelations.resize(maRelations.size()+1);
1740 maRelations.back().RelationType = nRelationType;
1741 maRelations.back().TargetSet.realloc(1);
1742 maRelations.back().TargetSet[0] = rxObject;
1748 //----- XAccessibleRelationSet ------------------------------------------------
1750 sal_Int32 SAL_CALL AccessibleRelationSet::getRelationCount (void)
1751 throw (cssu::RuntimeException)
1753 return maRelations.size();
1759 AccessibleRelation SAL_CALL AccessibleRelationSet::getRelation (sal_Int32 nIndex)
1760 throw (cssu::RuntimeException, css::lang::IndexOutOfBoundsException)
1762 if (nIndex<0 && sal_uInt32(nIndex)>=maRelations.size())
1763 return AccessibleRelation();
1764 else
1765 return maRelations[nIndex];
1771 sal_Bool SAL_CALL AccessibleRelationSet::containsRelation (sal_Int16 nRelationType)
1772 throw (cssu::RuntimeException)
1774 for (::std::vector<AccessibleRelation>::const_iterator iRelation(maRelations.begin());
1775 iRelation!=maRelations.end();
1776 ++iRelation)
1778 if (iRelation->RelationType == nRelationType)
1779 return sal_True;
1781 return sal_False;
1787 AccessibleRelation SAL_CALL AccessibleRelationSet::getRelationByType (sal_Int16 nRelationType)
1788 throw (cssu::RuntimeException)
1790 for (::std::vector<AccessibleRelation>::const_iterator iRelation(maRelations.begin());
1791 iRelation!=maRelations.end();
1792 ++iRelation)
1794 if (iRelation->RelationType == nRelationType)
1795 return *iRelation;
1797 return AccessibleRelation();
1803 //===== PresenterAccessible::AccessibleParagraph ==============================
1805 PresenterAccessible::AccessibleParagraph::AccessibleParagraph (
1806 const lang::Locale aLocale,
1807 const sal_Int16 nRole,
1808 const OUString& rsName,
1809 const SharedPresenterTextParagraph& rpParagraph,
1810 const sal_Int32 nParagraphIndex)
1811 : PresenterAccessibleParagraphInterfaceBase(aLocale, nRole, rsName),
1812 mpParagraph(rpParagraph),
1813 mnParagraphIndex(nParagraphIndex)
1820 PresenterAccessible::AccessibleParagraph::~AccessibleParagraph (void)
1827 //----- XAccessibleContext ----------------------------------------------------
1829 Reference<XAccessibleRelationSet> SAL_CALL
1830 PresenterAccessible::AccessibleParagraph::getAccessibleRelationSet (void)
1831 throw (RuntimeException)
1833 ThrowIfDisposed();
1835 rtl::Reference<AccessibleRelationSet> pSet (new AccessibleRelationSet);
1837 if (mxParentAccessible.is())
1839 Reference<XAccessibleContext> xParentContext (mxParentAccessible->getAccessibleContext());
1840 if (xParentContext.is())
1842 if (mnParagraphIndex>0)
1843 pSet->AddRelation(
1844 AccessibleRelationType::CONTENT_FLOWS_FROM,
1845 xParentContext->getAccessibleChild(mnParagraphIndex-1));
1847 if (mnParagraphIndex<xParentContext->getAccessibleChildCount()-1)
1848 pSet->AddRelation(
1849 AccessibleRelationType::CONTENT_FLOWS_TO,
1850 xParentContext->getAccessibleChild(mnParagraphIndex+1));
1854 return Reference<XAccessibleRelationSet>(pSet.get());
1862 //----- XAccessibleText -------------------------------------------------------
1864 sal_Int32 SAL_CALL PresenterAccessible::AccessibleParagraph::getCaretPosition (void)
1865 throw (cssu::RuntimeException)
1867 ThrowIfDisposed();
1869 sal_Int32 nPosition (-1);
1870 if (mpParagraph)
1871 nPosition = mpParagraph->GetCaretPosition();
1873 return nPosition;
1879 sal_Bool SAL_CALL PresenterAccessible::AccessibleParagraph::setCaretPosition (sal_Int32 nIndex)
1880 throw (::com::sun::star::lang::IndexOutOfBoundsException, cssu::RuntimeException)
1882 ThrowIfDisposed();
1884 if (mpParagraph)
1886 mpParagraph->SetCaretPosition(nIndex);
1887 return sal_True;
1889 else
1890 return sal_False;
1896 sal_Unicode SAL_CALL PresenterAccessible::AccessibleParagraph::getCharacter (sal_Int32 nIndex)
1897 throw (::com::sun::star::lang::IndexOutOfBoundsException, cssu::RuntimeException)
1899 ThrowIfDisposed();
1901 if (mpParagraph)
1902 return mpParagraph->GetCharacter(nIndex);
1903 else
1905 ThrowException("no text support in current mode", ET_IndexOutOfBounds);
1906 // The method above throws an exception and the following line is
1907 // never reached. But there is at least one compiler that can not
1908 // detect this and we need the return to make it happy.
1909 return sal_Unicode();
1916 Sequence<css::beans::PropertyValue> SAL_CALL
1917 PresenterAccessible::AccessibleParagraph::getCharacterAttributes (
1918 ::sal_Int32 nIndex,
1919 const cssu::Sequence<rtl::OUString>& rRequestedAttributes)
1920 throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException)
1922 ThrowIfDisposed();
1924 #ifdef VERBOSE
1925 OSL_TRACE("PresenterAccessible::AccessibleParagraph::getCharacterAttributes at %x,%d returns empty set\r",
1926 this,nIndex);
1927 for (sal_Int32 nAttributeIndex(0),nAttributeCount(rRequestedAttributes.getLength());
1928 nAttributeIndex<nAttributeCount;
1929 ++nAttributeIndex)
1931 OSL_TRACE(" requested attribute %d is %s\r",
1932 nAttributeIndex,
1933 OUStringToOString(rRequestedAttributes[nAttributeIndex], RTL_TEXTENCODING_UTF8).getStr());
1935 #endif
1937 // Character properties are not supported.
1938 (void)nIndex;
1939 (void)rRequestedAttributes;
1940 return Sequence<css::beans::PropertyValue>();
1946 awt::Rectangle SAL_CALL PresenterAccessible::AccessibleParagraph::getCharacterBounds (
1947 sal_Int32 nIndex)
1948 throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException)
1950 ThrowIfDisposed();
1952 awt::Rectangle aCharacterBox;
1953 if (nIndex < 0)
1955 ThrowException("invalid text index", ET_IndexOutOfBounds);
1957 else if (mpParagraph)
1959 aCharacterBox = mpParagraph->GetCharacterBounds(nIndex, false);
1960 // Convert coordinates relative to the window origin into absolute
1961 // screen coordinates.
1962 const awt::Point aWindowLocationOnScreen (getLocationOnScreen());
1963 aCharacterBox.X += aWindowLocationOnScreen.X;
1964 aCharacterBox.Y += aWindowLocationOnScreen.Y;
1966 else
1968 ThrowException("no text support in current mode", ET_IndexOutOfBounds);
1971 return aCharacterBox;
1977 sal_Int32 SAL_CALL PresenterAccessible::AccessibleParagraph::getCharacterCount (void)
1978 throw (cssu::RuntimeException)
1980 ThrowIfDisposed();
1982 sal_Int32 nCount (0);
1983 if (mpParagraph)
1984 nCount = mpParagraph->GetCharacterCount();
1986 return nCount;
1992 sal_Int32 SAL_CALL PresenterAccessible::AccessibleParagraph::getIndexAtPoint (
1993 const css::awt::Point& rPoint)
1994 throw (cssu::RuntimeException)
1996 ThrowIfDisposed();
1998 sal_Int32 nIndex (-1);
1999 if (mpParagraph)
2000 nIndex = mpParagraph->GetIndexAtPoint(rPoint);
2002 return nIndex;
2008 ::rtl::OUString SAL_CALL PresenterAccessible::AccessibleParagraph::getSelectedText (void)
2009 throw (cssu::RuntimeException)
2011 ThrowIfDisposed();
2013 return getTextRange(getSelectionStart(), getSelectionEnd());
2019 sal_Int32 SAL_CALL PresenterAccessible::AccessibleParagraph::getSelectionStart (void)
2020 throw (cssu::RuntimeException)
2022 ThrowIfDisposed();
2024 return getCaretPosition();
2030 sal_Int32 SAL_CALL PresenterAccessible::AccessibleParagraph::getSelectionEnd (void)
2031 throw (cssu::RuntimeException)
2033 ThrowIfDisposed();
2035 return getCaretPosition();
2041 sal_Bool SAL_CALL PresenterAccessible::AccessibleParagraph::setSelection (
2042 sal_Int32 nStartIndex,
2043 sal_Int32 nEndIndex)
2044 throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException)
2046 (void)nEndIndex;
2047 ThrowIfDisposed();
2049 return setCaretPosition(nStartIndex);
2055 ::rtl::OUString SAL_CALL PresenterAccessible::AccessibleParagraph::getText (void)
2056 throw (cssu::RuntimeException)
2058 ThrowIfDisposed();
2060 ::rtl::OUString sText;
2061 if (mpParagraph)
2062 sText = mpParagraph->GetText();
2064 return sText;
2070 ::rtl::OUString SAL_CALL PresenterAccessible::AccessibleParagraph::getTextRange (
2071 sal_Int32 nLocalStartIndex,
2072 sal_Int32 nLocalEndIndex)
2073 throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException)
2075 ThrowIfDisposed();
2077 ::rtl::OUString sText;
2078 if (mpParagraph)
2080 const TextSegment aSegment (
2081 mpParagraph->CreateTextSegment(nLocalStartIndex, nLocalEndIndex));
2082 sText = aSegment.SegmentText;
2085 return sText;
2091 TextSegment SAL_CALL PresenterAccessible::AccessibleParagraph::getTextAtIndex (
2092 sal_Int32 nLocalCharacterIndex,
2093 sal_Int16 nTextType)
2094 throw (css::lang::IndexOutOfBoundsException,
2095 css::lang::IllegalArgumentException,
2096 cssu::RuntimeException)
2098 ThrowIfDisposed();
2100 TextSegment aSegment;
2101 if (mpParagraph)
2102 aSegment = mpParagraph->GetTextSegment(0, nLocalCharacterIndex, nTextType);
2104 return aSegment;
2110 TextSegment SAL_CALL PresenterAccessible::AccessibleParagraph::getTextBeforeIndex (
2111 sal_Int32 nLocalCharacterIndex,
2112 sal_Int16 nTextType)
2113 throw (css::lang::IndexOutOfBoundsException,
2114 css::lang::IllegalArgumentException,
2115 cssu::RuntimeException)
2117 ThrowIfDisposed();
2119 TextSegment aSegment;
2120 if (mpParagraph)
2121 aSegment = mpParagraph->GetTextSegment(-1, nLocalCharacterIndex, nTextType);
2123 return aSegment;
2129 TextSegment SAL_CALL PresenterAccessible::AccessibleParagraph::getTextBehindIndex (
2130 sal_Int32 nLocalCharacterIndex,
2131 sal_Int16 nTextType)
2132 throw (css::lang::IndexOutOfBoundsException,
2133 css::lang::IllegalArgumentException,
2134 cssu::RuntimeException)
2136 ThrowIfDisposed();
2138 TextSegment aSegment;
2139 if (mpParagraph)
2140 aSegment = mpParagraph->GetTextSegment(+1, nLocalCharacterIndex, nTextType);
2142 return aSegment;
2148 sal_Bool SAL_CALL PresenterAccessible::AccessibleParagraph::copyText (
2149 sal_Int32 nStartIndex,
2150 sal_Int32 nEndIndex)
2151 throw (css::lang::IndexOutOfBoundsException, cssu::RuntimeException)
2153 ThrowIfDisposed();
2155 // Return false because copying to clipboard is not supported.
2156 // It IS supported in the notes view. There is no need to duplicate
2157 // this here.
2158 (void)nStartIndex;
2159 (void)nEndIndex;
2160 return sal_False;
2166 //----- protected -------------------------------------------------------------
2168 awt::Point PresenterAccessible::AccessibleParagraph::GetRelativeLocation (void)
2170 awt::Point aLocation (AccessibleObject::GetRelativeLocation());
2171 if (mpParagraph)
2173 const awt::Point aParagraphLocation (mpParagraph->GetRelativeLocation());
2174 aLocation.X += aParagraphLocation.X;
2175 aLocation.Y += aParagraphLocation.Y;
2178 return aLocation;
2184 awt::Size PresenterAccessible::AccessibleParagraph::GetSize (void)
2186 if (mpParagraph)
2187 return mpParagraph->GetSize();
2188 else
2189 return AccessibleObject::GetSize();
2195 awt::Point PresenterAccessible::AccessibleParagraph::GetAbsoluteParentLocation (void)
2197 if (mxParentAccessible.is())
2199 Reference<XAccessibleContext> xParentContext(
2200 mxParentAccessible->getAccessibleContext(), UNO_QUERY);
2201 if (xParentContext.is())
2203 Reference<XAccessibleComponent> xGrandParentComponent(
2204 xParentContext->getAccessibleParent(), UNO_QUERY);
2205 if (xGrandParentComponent.is())
2206 return xGrandParentComponent->getLocationOnScreen();
2210 return awt::Point();
2216 bool PresenterAccessible::AccessibleParagraph::GetWindowState (const sal_Int16 nType) const
2218 switch (nType)
2220 case AccessibleStateType::EDITABLE:
2221 return mpParagraph.get()!=NULL;
2223 case AccessibleStateType::ACTIVE:
2224 return true;
2226 default:
2227 return AccessibleObject::GetWindowState(nType);
2236 //===== AccessibleNotes =======================================================
2238 AccessibleNotes::AccessibleNotes (
2239 const css::lang::Locale aLocale,
2240 const sal_Int16 nRole,
2241 const ::rtl::OUString& rsName)
2242 : AccessibleObject(aLocale,nRole,rsName),
2243 mpTextView()
2250 rtl::Reference<PresenterAccessible::AccessibleObject> AccessibleNotes::Create (
2251 const css::uno::Reference<css::uno::XComponentContext>& rxContext,
2252 const lang::Locale aLocale,
2253 const Reference<awt::XWindow>& rxContentWindow,
2254 const Reference<awt::XWindow>& rxBorderWindow,
2255 const ::boost::shared_ptr<PresenterTextView>& rpTextView)
2257 OUString sName (A2S("Presenter Notes Text"));
2259 PresenterConfigurationAccess aConfiguration (
2260 rxContext,
2261 OUString::createFromAscii("/org.openoffice.Office.extension.PresenterScreen/"),
2262 PresenterConfigurationAccess::READ_ONLY);
2263 aConfiguration.GetConfigurationNode(A2S("Presenter/Accessibility/Notes/String"))
2264 >>= sName;
2267 rtl::Reference<AccessibleNotes> pObject (
2268 new AccessibleNotes(
2269 aLocale,
2270 AccessibleRole::PANEL,
2271 sName));
2272 pObject->LateInitialization();
2273 pObject->SetTextView(rpTextView);
2274 pObject->UpdateStateSet();
2275 pObject->SetWindow(rxContentWindow, rxBorderWindow);
2277 return rtl::Reference<PresenterAccessible::AccessibleObject>(pObject.get());
2283 void AccessibleNotes::SetTextView (
2284 const ::boost::shared_ptr<PresenterTextView>& rpTextView)
2286 ::std::vector<rtl::Reference<PresenterAccessible::AccessibleObject> > aChildren;
2288 // Release any listeners to the current text view.
2289 if (mpTextView)
2291 mpTextView->GetCaret()->SetCaretMotionBroadcaster(
2292 ::boost::function<void(sal_Int32,sal_Int32,sal_Int32,sal_Int32)>());
2293 mpTextView->SetTextChangeBroadcaster(
2294 ::boost::function<void(void)>());
2297 mpTextView = rpTextView;
2299 if (mpTextView)
2301 // Create a new set of children, one for each paragraph.
2302 const sal_Int32 nParagraphCount (mpTextView->GetParagraphCount());
2303 for (sal_Int32 nIndex=0; nIndex<nParagraphCount; ++nIndex)
2305 rtl::Reference<PresenterAccessible::AccessibleParagraph> pParagraph (
2306 new PresenterAccessible::AccessibleParagraph(
2307 css::lang::Locale(),
2308 AccessibleRole::PARAGRAPH,
2309 A2S("Paragraph")+OUString::valueOf(nIndex),
2310 rpTextView->GetParagraph(nIndex),
2311 nIndex));
2312 pParagraph->LateInitialization();
2313 pParagraph->SetWindow(
2314 Reference<awt::XWindow>(mxContentWindow, UNO_QUERY),
2315 Reference<awt::XWindow>(mxBorderWindow, UNO_QUERY));
2316 pParagraph->SetAccessibleParent(this);
2317 aChildren.push_back(
2318 rtl::Reference<PresenterAccessible::AccessibleObject>(pParagraph.get()));
2320 maChildren.swap(aChildren);
2321 FireAccessibleEvent(AccessibleEventId::INVALIDATE_ALL_CHILDREN, Any(), Any());
2323 // Dispose the old children. (This will remove them from the focus
2324 // manager).
2325 for (std::vector<rtl::Reference<AccessibleObject> >::const_iterator
2326 iChild(aChildren.begin()), iEnd(aChildren.end());
2327 iChild!=iEnd;
2328 ++iChild)
2330 Reference<lang::XComponent> xComponent (static_cast<XWeak*>(iChild->get()), UNO_QUERY);
2331 if (xComponent.is())
2332 xComponent->dispose();
2335 // This class acts as a controller of who broadcasts caret motion
2336 // events and handles text changes. Register the corresponding
2337 // listeners here.
2338 mpTextView->GetCaret()->SetCaretMotionBroadcaster(
2339 ::boost::bind(&AccessibleNotes::NotifyCaretChange, this, _1, _2, _3, _4));
2340 mpTextView->SetTextChangeBroadcaster(
2341 ::boost::bind(&AccessibleNotes::HandleTextChange, this));
2348 void AccessibleNotes::SetWindow (
2349 const cssu::Reference<css::awt::XWindow>& rxContentWindow,
2350 const cssu::Reference<css::awt::XWindow>& rxBorderWindow)
2352 AccessibleObject::SetWindow(rxContentWindow, rxBorderWindow);
2354 // Set the windows at the children as well, so that every paragraph can
2355 // setup its geometry.
2356 for (::std::vector<rtl::Reference<AccessibleObject> >::const_iterator
2357 iChild(maChildren.begin()),
2358 iEnd(maChildren.end());
2359 iChild!=iEnd;
2360 ++iChild)
2362 (*iChild)->SetWindow(rxContentWindow, rxBorderWindow);
2369 void AccessibleNotes::NotifyCaretChange (
2370 const sal_Int32 nOldParagraphIndex,
2371 const sal_Int32 nOldCharacterIndex,
2372 const sal_Int32 nNewParagraphIndex,
2373 const sal_Int32 nNewCharacterIndex)
2375 AccessibleFocusManager::Instance()->FocusObject(
2376 nNewParagraphIndex >= 0
2377 ? maChildren[nNewParagraphIndex]
2378 : this);
2380 if (nOldParagraphIndex != nNewParagraphIndex)
2382 // Moved caret from one paragraph to another (or showed or
2383 // hid the caret). Move focuse from one accessible
2384 // paragraph to another.
2385 if (nOldParagraphIndex >= 0)
2387 maChildren[nOldParagraphIndex]->FireAccessibleEvent(
2388 AccessibleEventId::CARET_CHANGED,
2389 Any(nOldCharacterIndex),
2390 Any(sal_Int32(-1)));
2392 if (nNewParagraphIndex >= 0)
2394 maChildren[nNewParagraphIndex]->FireAccessibleEvent(
2395 AccessibleEventId::CARET_CHANGED,
2396 Any(sal_Int32(-1)),
2397 Any(nNewCharacterIndex));
2400 else if (nNewParagraphIndex >= 0)
2402 // Caret moved inside one paragraph.
2403 maChildren[nNewParagraphIndex]->FireAccessibleEvent(
2404 AccessibleEventId::CARET_CHANGED,
2405 Any(nOldCharacterIndex),
2406 Any(nNewCharacterIndex));
2413 void AccessibleNotes::HandleTextChange (void)
2415 SetTextView(mpTextView);
2421 //===== AccessibleFocusManager ================================================
2423 ::boost::shared_ptr<AccessibleFocusManager> AccessibleFocusManager::mpInstance;
2425 ::boost::shared_ptr<AccessibleFocusManager> AccessibleFocusManager::Instance (void)
2427 if ( ! mpInstance)
2429 mpInstance.reset(new AccessibleFocusManager());
2431 return mpInstance;
2437 AccessibleFocusManager::AccessibleFocusManager (void)
2438 : maFocusableObjects()
2445 void AccessibleFocusManager::AddFocusableObject (
2446 const ::rtl::Reference<PresenterAccessible::AccessibleObject>& rpObject)
2448 OSL_ASSERT(rpObject.is());
2449 OSL_ASSERT(::std::find(maFocusableObjects.begin(),maFocusableObjects.end(), rpObject)==maFocusableObjects.end());
2451 maFocusableObjects.push_back(rpObject);
2457 void AccessibleFocusManager::RemoveFocusableObject (
2458 const ::rtl::Reference<PresenterAccessible::AccessibleObject>& rpObject)
2460 ::std::vector<rtl::Reference<PresenterAccessible::AccessibleObject> >::iterator iObject (
2461 ::std::find(maFocusableObjects.begin(),maFocusableObjects.end(), rpObject));
2463 if (iObject != maFocusableObjects.end())
2464 maFocusableObjects.erase(iObject);
2465 else
2467 OSL_ASSERT(iObject!=maFocusableObjects.end());
2474 void AccessibleFocusManager::FocusObject (
2475 const ::rtl::Reference<PresenterAccessible::AccessibleObject>& rpObject)
2477 // Remove the focus of any of the other focusable objects.
2478 for (::std::vector<rtl::Reference<PresenterAccessible::AccessibleObject> >::const_iterator
2479 iObject (maFocusableObjects.begin()),
2480 iEnd (maFocusableObjects.end());
2481 iObject != iEnd;
2482 ++iObject)
2484 if (*iObject!=rpObject)
2485 (*iObject)->SetIsFocused(false);
2488 if (rpObject.is())
2489 rpObject->SetIsFocused(true);
2492 } } // end of namespace ::sd::presenter