Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sd/source/ui/inc/AccessibleDocumentViewBase.hxx
Line
Count
Source
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_ACCESSIBLEDOCUMENTVIEWBASE_HXX
21
#define INCLUDED_SD_SOURCE_UI_INC_ACCESSIBLEDOCUMENTVIEWBASE_HXX
22
23
#include <editeng/AccessibleContextBase.hxx>
24
#include <editeng/AccessibleSelectionBase.hxx>
25
#include "AccessibleViewForwarder.hxx"
26
#include <svx/AccessibleShapeTreeInfo.hxx>
27
#include <svx/IAccessibleViewForwarderListener.hxx>
28
29
#include <com/sun/star/awt/XWindowListener.hpp>
30
#include <com/sun/star/awt/XFocusListener.hpp>
31
#include <com/sun/star/beans/XPropertyChangeListener.hpp>
32
#include <tools/link.hxx>
33
34
#include <com/sun/star/accessibility/XAccessibleExtendedAttributes.hpp>
35
36
#include "Window.hxx"
37
38
namespace com::sun::star::accessibility { class XAccessible; }
39
namespace com::sun::star::frame { class XModel; }
40
namespace com::sun::star::awt { class XWindow; }
41
42
class VclWindowEvent;
43
44
namespace sd {
45
class ViewShell;
46
}
47
48
namespace accessibility {
49
50
/** Base class for the various document views of the Draw and
51
    Impress applications.
52
53
    <p>The different view modes of the Draw and Impress applications
54
    are made accessible by derived classes.  When the view mode is
55
    changed then the object representing the document view is
56
    disposed and replaced by a new instance of the then appropriate
57
    derived class.</p>
58
59
    <p>This base class also manages an optionally active accessible OLE
60
    object.  If you overwrite the <member>getAccessibleChildCount</member>
61
    and <member>getAccessibleChild</member> methods then make sure to first
62
    call the corresponding method of this class and adapt your child count
63
    and indices accordingly.  Only one active OLE object is allowed at a
64
    time.  This class does not listen for disposing calls at the moment
65
    because it does not use the accessible OLE object directly and trusts on
66
    getting informed through VCL window events.</p>
67
68
    <p>This class implements three kinds of listeners:
69
    <ol><li>The property change listener is not used directly but exists as
70
    convenience for derived classes.  May be moved to those classes
71
    instead.</li>
72
    <li>As window listener it waits for changes of the window geometry and
73
    forwards those as view forwarder changes.</li>
74
    <li>As focus listener it keeps track of the focus to give this class and
75
    derived classes the opportunity to set and remove the focus to/from
76
    shapes.</li>
77
    </ol>
78
    </p>
79
*/
80
class AccessibleDocumentViewBase
81
    :   public AccessibleContextBase,
82
        public AccessibleSelectionBase,
83
        public IAccessibleViewForwarderListener,
84
        public css::beans::XPropertyChangeListener,
85
        public css::awt::XWindowListener,
86
        public css::awt::XFocusListener,
87
        public css::accessibility::XAccessibleExtendedAttributes
88
{
89
public:
90
    /** Create a new object.  Note that the caller has to call the
91
        Init method directly after this constructor has finished.
92
    @param pSdWindow
93
        The window whose content is to be made accessible.
94
    @param pViewShell
95
        The view shell associated with the given window.
96
    @param rxController
97
        The controller from which to get the model.
98
    @param rxParent
99
        The accessible parent of the new object.  Note that this parent does
100
        not necessarily correspond with the parent of the given window.
101
     */
102
    AccessibleDocumentViewBase (
103
        ::sd::Window* pSdWindow,
104
        ::sd::ViewShell* pViewShell,
105
        css::uno::Reference<css::frame::XController> xController,
106
        const css::uno::Reference<css::accessibility::XAccessible>& rxParent);
107
108
    virtual ~AccessibleDocumentViewBase() override;
109
110
    /** Initialize a new object.  Call this method directly after creating a
111
        new object.  It finished the initialization begun in the constructor
112
        but which needs a fully created object.
113
     */
114
    virtual void Init();
115
116
    /** Define callback for listening to window child events of VCL.
117
        Listen for creation or destruction of OLE objects.
118
    */
119
    DECL_LINK( WindowChildEventListener, VclWindowEvent&, void );
120
121
    //=====  IAccessibleViewForwarderListener  ================================
122
123
    /** A view forwarder change is signalled for instance when any of the
124
        window events is received.  Thus, instead of overriding the four
125
        windowResized... methods it will be sufficient in most cases just to
126
        override this method.
127
     */
128
    virtual void ViewForwarderChanged() override;
129
130
    //=====  XAccessibleContext  ==============================================
131
132
    virtual css::uno::Reference<css::accessibility::XAccessible> SAL_CALL
133
        getAccessibleParent() override;
134
135
    /** This implementation returns either 1 or 0 depending on whether there
136
        is an active accessible OLE object or not.
137
    */
138
    virtual sal_Int64 SAL_CALL
139
        getAccessibleChildCount() override;
140
141
    /** This implementation either returns the active accessible OLE object
142
        if it exists and the given index is 0 or throws an exception.
143
    */
144
    virtual css::uno::Reference<css::accessibility::XAccessible> SAL_CALL
145
        getAccessibleChild (sal_Int64 nIndex) override;
146
147
    // OAccessible
148
    virtual css::awt::Rectangle implGetBounds() override;
149
150
    //=====  XAccessibleComponent  ============================================
151
152
    virtual css::uno::Reference<css::accessibility::XAccessible > SAL_CALL
153
        getAccessibleAtPoint (const css::awt::Point& aPoint) override;
154
155
    //=====  XInterface  ======================================================
156
157
    virtual css::uno::Any SAL_CALL
158
        queryInterface (const css::uno::Type & rType) override;
159
160
    virtual void SAL_CALL
161
        acquire()
162
        noexcept override;
163
164
    virtual void SAL_CALL
165
        release()
166
        noexcept override;
167
168
    //=====  XServiceInfo  ====================================================
169
170
    /** Returns an identifier for the implementation of this object.
171
    */
172
    virtual OUString SAL_CALL
173
        getImplementationName() override;
174
175
    virtual css::uno::Sequence< OUString> SAL_CALL
176
        getSupportedServiceNames() override;
177
178
    //=====  lang::XEventListener  ============================================
179
180
    virtual void SAL_CALL
181
        disposing (const css::lang::EventObject& rEventObject) override;
182
183
    //=====  XPropertyChangeListener  =========================================
184
185
    virtual void SAL_CALL
186
        propertyChange (const css::beans::PropertyChangeEvent& rEventObject) override;
187
188
    //=====  XWindowListener  =================================================
189
190
    virtual void SAL_CALL
191
        windowResized (const css::awt::WindowEvent& e) override;
192
193
    virtual void SAL_CALL
194
        windowMoved (const css::awt::WindowEvent& e) override;
195
196
    virtual void SAL_CALL
197
        windowShown (const css::lang::EventObject& e) override;
198
199
    virtual void SAL_CALL
200
        windowHidden (const css::lang::EventObject& e) override;
201
202
    //=====  XFocusListener  =================================================
203
204
    virtual void SAL_CALL focusGained (const css::awt::FocusEvent& e) override;
205
    virtual void SAL_CALL focusLost (const css::awt::FocusEvent& e) override;
206
    //----------------------------xAttribute----------------------------
207
    virtual OUString SAL_CALL getExtendedAttributes() override;
208
     ::sd::ViewShell* mpViewShell;
209
private:
210
211
    // return the member maMutex;
212
    virtual ::osl::Mutex&
213
        implGetMutex() override;
214
215
    // return ourself as context in default case
216
    virtual css::uno::Reference< css::accessibility::XAccessibleContext >
217
        implGetAccessibleContext() override;
218
219
    // return sal_False in default case
220
    virtual bool
221
        implIsSelected( sal_Int64 nAccessibleChildIndex ) override;
222
223
    // return nothing in default case
224
    virtual void
225
        implSelect( sal_Int64 nAccessibleChildIndex, bool bSelect ) override;
226
227
protected:
228
    /// The API window that is made accessible.
229
    css::uno::Reference< css::awt::XWindow>
230
         mxWindow;
231
232
    /// The controller of the window in which this view is displayed.
233
    css::uno::Reference< css::frame::XController>
234
         mxController;
235
236
    /// Model of the document.
237
    css::uno::Reference < css::frame::XModel>
238
        mxModel;
239
240
    // Bundle of information that is passed down the shape tree.
241
    AccessibleShapeTreeInfo maShapeTreeInfo;
242
243
    /// The view forwarder passed to the children manager.
244
    AccessibleViewForwarder maViewForwarder;
245
246
    /** Accessible OLE object.  Set or removed by the
247
        <member>SetAccessibleOLEObject</member> method.
248
    */
249
    css::uno::Reference< css::accessibility::XAccessible>
250
        mxAccessibleOLEObject;
251
252
    Link<VclWindowEvent&,void> maWindowLink;
253
254
    // This method is called from the component helper base class while
255
    // disposing.
256
    virtual void SAL_CALL disposing() override;
257
258
    /** Create a name string.  The current name is not modified and,
259
        therefore, no events are sent.  This method is usually called once
260
        by the <member>getAccessibleName</member> method of the base class.
261
        @return
262
           A name string.
263
    */
264
    virtual OUString
265
        CreateAccessibleName () override;
266
267
    /** This method is called when (after) the frame containing this
268
        document has been activated.  Can be used to send FOCUSED state
269
        changes for the currently selected element.
270
271
        Note: Currently used as a substitute for FocusGained.  Should be
272
        renamed in the future.
273
    */
274
    virtual void Activated();
275
276
    /** This method is called when (before or after?) the frame containing
277
        this document has been deactivated.  Can be used to send FOCUSED
278
        state changes for the currently selected element.
279
280
        Note: Currently used as a substitute for FocusLost.  Should be
281
        renamed in the future.
282
    */
283
    virtual void Deactivated();
284
285
    /** Set or remove the currently active accessible OLE object.
286
        @param xOLEObject
287
            If this is a valid reference then a child event is send that
288
            informs the listeners of a new child.  If there has already been
289
            an active accessible OLE object then this is removed first and
290
            appropriate events are sent.
291
292
            If this is an empty reference then the currently active
293
            accessible OLE object (if there is one) is removed.
294
    */
295
    void SetAccessibleOLEObject (
296
        const css::uno::Reference<css::accessibility::XAccessible>& xOLEObject);
297
298
public:
299
0
    void SwitchViewActivated() { Activated(); }
300
     virtual sal_Int32 SAL_CALL getForeground(  ) override;
301
302
    virtual sal_Int32 SAL_CALL getBackground(  ) override;
303
    virtual void impl_dispose();
304
};
305
306
} // end of namespace accessibility
307
308
#endif
309
310
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */