1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SDEXT_PRESENTER_PRESENTER_ACCESSIBILITY_HXX
25 #define SDEXT_PRESENTER_PRESENTER_ACCESSIBILITY_HXX
26 
27 #include "PresenterPaneContainer.hxx"
28 
29 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
30 #include <com/sun/star/accessibility/TextSegment.hpp>
31 #include <com/sun/star/accessibility/XAccessible.hpp>
32 #include <com/sun/star/awt/XFocusListener.hpp>
33 #include <com/sun/star/awt/XWindow2.hpp>
34 #include <com/sun/star/awt/WindowEvent.hpp>
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
37 #include <com/sun/star/drawing/framework/XPane.hpp>
38 #include <com/sun/star/drawing/framework/XPane2.hpp>
39 #include <com/sun/star/lang/XInitialization.hpp>
40 #include <com/sun/star/uno/XComponentContext.hpp>
41 #include <cppuhelper/compbase3.hxx>
42 #include <cppuhelper/basemutex.hxx>
43 #include <rtl/ref.hxx>
44 #include <boost/shared_ptr.hpp>
45 
46 namespace css = ::com::sun::star;
47 namespace cssu = ::com::sun::star::uno;
48 namespace cssa = ::com::sun::star::accessibility;
49 
50 
51 namespace sdext { namespace presenter {
52 
53 class PresenterController;
54 class PresenterTextView;
55 
56 namespace {
57     typedef ::cppu::WeakComponentImplHelper3 <
58         css::accessibility::XAccessible,
59         css::lang::XInitialization,
60         css::awt::XFocusListener
61     > PresenterAccessibleInterfaceBase;
62 }
63 
64 class PresenterAccessible
65     : public ::cppu::BaseMutex,
66       public PresenterAccessibleInterfaceBase
67 {
68 public:
69     PresenterAccessible (
70         const css::uno::Reference<css::uno::XComponentContext>& rxContext,
71         const ::rtl::Reference<PresenterController>& rpPresenterController,
72         const css::uno::Reference<css::drawing::framework::XPane>& rxMainPane);
73     virtual ~PresenterAccessible (void);
74 
75     void SetAccessibleParent (const cssu::Reference<cssa::XAccessible>& rxAccessibleParent);
76 
77     void UpdateAccessibilityHierarchy (void);
78 
79     void NotifyCurrentSlideChange (
80         const sal_Int32 nCurrentSlideIndex,
81         const sal_Int32 nSlideCount);
82 
83     /** Return whether accessibility support is active, i.e. whether
84         somebody has called getAccessibleContext() yet.
85     */
86     bool IsAccessibilityActive (void) const;
87 
88     virtual void SAL_CALL disposing (void);
89 
90 
91     //----- XAccessible -------------------------------------------------------
92 
93     virtual cssu::Reference<cssa::XAccessibleContext> SAL_CALL
94         getAccessibleContext (void)
95         throw (cssu::RuntimeException);
96 
97 
98     //----- XFocusListener ----------------------------------------------------
99 
100     virtual void SAL_CALL focusGained (const css::awt::FocusEvent& rEvent)
101         throw (cssu::RuntimeException);
102 
103     virtual void SAL_CALL focusLost (const css::awt::FocusEvent& rEvent)
104         throw (cssu::RuntimeException);
105 
106 
107     //----- XEventListener ----------------------------------------------------
108 
109     virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent)
110         throw (cssu::RuntimeException);
111 
112 
113     //----- XInitialization ---------------------------------------------------
114 
115     virtual void SAL_CALL initialize (const cssu::Sequence<cssu::Any>& rArguments)
116         throw (cssu::RuntimeException);
117 
118 
119     class AccessibleObject;
120     class AccessibleParagraph;
121 
122 private:
123     const css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
124     ::rtl::Reference<PresenterController> mpPresenterController;
125     css::uno::Reference<css::drawing::framework::XResourceId> mxMainPaneId;
126     css::uno::Reference<css::drawing::framework::XPane2> mxMainPane;
127     css::uno::Reference<css::awt::XWindow> mxMainWindow;
128     css::uno::Reference<css::awt::XWindow> mxPreviewContentWindow;
129     css::uno::Reference<css::awt::XWindow> mxPreviewBorderWindow;
130     css::uno::Reference<css::awt::XWindow> mxNotesContentWindow;
131     css::uno::Reference<css::awt::XWindow> mxNotesBorderWindow;
132     ::rtl::Reference<AccessibleObject> mpAccessibleConsole;
133     ::rtl::Reference<AccessibleObject> mpAccessiblePreview;
134     ::rtl::Reference<AccessibleObject> mpAccessibleNotes;
135     css::uno::Reference<css::accessibility::XAccessible> mxAccessibleParent;
136 
137     void UpdateAccessibilityHierarchy (
138         const css::uno::Reference<css::awt::XWindow>& rxPreviewContentWindow,
139         const css::uno::Reference<css::awt::XWindow>& rxPreviewBorderWindow,
140         const ::rtl::OUString& rsTitle,
141         const css::uno::Reference<css::awt::XWindow>& rxNotesContentWindow,
142         const css::uno::Reference<css::awt::XWindow>& rxNotesBorderWindow,
143         const ::boost::shared_ptr<PresenterTextView>& rpNotesTextView);
144     PresenterPaneContainer::SharedPaneDescriptor GetPreviewPane (void) const;
145 };
146 
147 
148 
149 
150 } } // end of namespace ::sd::presenter
151 
152 #endif
153