1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_SD_SOURCE_UI_INC_ACCESSIBLEDRAWDOCUMENTVIEW_HXX
21 #define INCLUDED_SD_SOURCE_UI_INC_ACCESSIBLEDRAWDOCUMENTVIEW_HXX
22 
23 #include "AccessibleDocumentViewBase.hxx"
24 
25 #include <com/sun/star/accessibility/XAccessibleGroupPosition.hpp>
26 
27 namespace accessibility { class AccessiblePageShape; }
28 namespace accessibility { class ChildrenManager; }
29 
30 namespace accessibility {
31 
32 /** This class makes draw documents in the general view modes
33     accessible.  It passes all shapes on the current draw page to a
34     children manager and additionally creates a new shape that
35     represents the actual draw page.
36 
37     Please see the documentation of the base class for further
38     explanations of the individual methods.
39 */
40 class AccessibleDrawDocumentView final :
41     public AccessibleDocumentViewBase
42     ,public css::accessibility::XAccessibleGroupPosition
43 {
44 public:
45     //=====  internal  ========================================================
46 
47     AccessibleDrawDocumentView (::sd::Window* pSdWindow,
48         ::sd::ViewShell* pViewShell,
49         const css::uno::Reference<css::frame::XController>& rxController,
50         const css::uno::Reference<css::accessibility::XAccessible>& rxParent);
51 
52     virtual ~AccessibleDrawDocumentView() override;
53 
54     /** Complete the initialization begun in the constructor.
55     */
56     virtual void Init() override;
57 
58     //=====  IAccessibleViewForwarderListener  ================================
59 
60     virtual void ViewForwarderChanged() override;
61 
62     //=====  XAccessibleContext  ==============================================
63 
64     virtual sal_Int32 SAL_CALL
65         getAccessibleChildCount() override;
66 
67     virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL
68         getAccessibleChild (sal_Int32 nIndex) override;
69 
70     virtual OUString SAL_CALL
71         getAccessibleName() override;
72 
73     //=====  lang::XEventListener  ============================================
74 
75     virtual void SAL_CALL
76         disposing (const css::lang::EventObject& rEventObject) override;
77 
78     //=====  XPropertyChangeListener  =========================================
79 
80     virtual void SAL_CALL
81         propertyChange (const css::beans::PropertyChangeEvent& rEventObject) override;
82     //=====  XInterface  ======================================================
83 
84     virtual css::uno::Any SAL_CALL
85         queryInterface (const css::uno::Type & rType) override;
86 
87     virtual void SAL_CALL
88         acquire()
89         throw () override;
90 
91     virtual void SAL_CALL
92         release()
93         throw () override;
94 
95     //=====  XAccessibleGroupPosition  =========================================
96     virtual css::uno::Sequence< sal_Int32 > SAL_CALL
97         getGroupPosition( const css::uno::Any& rAny ) override;
98     virtual OUString SAL_CALL getObjectLink( const css::uno::Any& accoject ) override;
99 
100 private:
101 
102     //=====  XServiceInfo  ====================================================
103 
104     virtual OUString SAL_CALL
105         getImplementationName() override;
106 
107     virtual css::uno::Sequence< OUString> SAL_CALL
108         getSupportedServiceNames() override;
109 
110     virtual bool
111         implIsSelected( sal_Int32 nAccessibleChildIndex ) override;
112 
113     /** Select or deselect the specified child or all children if the given
114         index has the special value ACCESSIBLE_SELECTION_CHILD_ALL.
115         Selecting or deselecting a child sets or resets the
116         <const>SELECTED</const> state and selects or deselects the UNO shape
117         being made accessible by the child.
118         @param nAccessibleChildIndex
119             Index of the child to select or deselect.  If the parameter has
120             the value ACCESSIBLE_SELECTION_CHILD_ALL then all children are
121             selected or deselected.
122         @param bSelect
123             Indicates whether to select or deselect the specified child
124             reps. children.
125     */
126     virtual void
127         implSelect( sal_Int32 nAccessibleChildIndex, bool bSelect ) override;
128 
129     ::sd::ViewShell* const mpSdViewSh;
130 
131     /** This object manages the shapes of the represented draw page.  It is
132         responsible to determine the visible shapes and create on demand the
133         accessible objects representing them.
134     */
135     std::unique_ptr<ChildrenManager> mpChildrenManager;
136 
137     // This method is called from the component helper base class while
138     // disposing.
139     virtual void SAL_CALL disposing() override;
140 
141     /** Create a shape the represents the page as seen on the screen.
142     */
143     rtl::Reference<AccessiblePageShape> CreateDrawPageShape();
144 
145     /// Create an accessible name that contains the current view mode.
146     virtual OUString
147         CreateAccessibleName () override;
148 
149     /** Make sure that the currently focused shape sends a FOCUSED state
150         change event indicating that it has (regained) the focus.
151     */
152     virtual void Activated() override;
153 
154     /** Make sure that the currently focused shape sends a FOCUSED state
155         change event indicating that it has lost the focus.
156     */
157     virtual void Deactivated() override;
158 
159     virtual void impl_dispose() override;
160 
161     void UpdateAccessibleName();
162 };
163 
164 } // end of namespace accessibility
165 
166 #endif
167 
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
169