Coverage Report

Created: 2026-10-14 09:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sc/source/ui/inc/AccessibleEditObject.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
#pragma once
21
22
#include "AccessibleContextBase.hxx"
23
#include "AccessibleDocument.hxx"
24
25
#include <com/sun/star/accessibility/XAccessibleSelection.hpp>
26
#include <address.hxx>
27
#include <vcl/vclptr.hxx>
28
#include <vcl/weld/customweld.hxx>
29
30
#include <memory>
31
32
namespace accessibility
33
{
34
    class AccessibleTextHelper;
35
}
36
class EditView;
37
class ScTextWnd;
38
namespace vcl { class Window; }
39
40
/** @descr
41
        This base class provides an implementation of the
42
        <code>AccessibleCell</code> service.
43
*/
44
class ScAccessibleEditObject
45
    : public cppu::ImplInheritanceHelper<ScAccessibleContextBase,
46
                                         css::accessibility::XAccessibleSelection>
47
{
48
public:
49
    enum EditObjectType
50
    {
51
        CellInEditMode,
52
        EditLine,
53
        EditControl
54
    };
55
56
    ScAccessibleEditObject(
57
        const rtl::Reference<ScAccessibleDocument>& rpParent,
58
        EditView* pEditView, vcl::Window* pWin, const OUString& rName,
59
        const OUString& rDescription, EditObjectType eObjectType);
60
61
    void InitAcc(const rtl::Reference<ScAccessibleDocument>& rpParent, EditView* pEditView,
62
                 const OUString& rName, const OUString& rDescription);
63
64
protected:
65
    virtual ~ScAccessibleEditObject() override;
66
67
    ScAccessibleEditObject(EditObjectType eObjectType);
68
69
    using ScAccessibleContextBase::IsDefunc;
70
71
public:
72
    using ScAccessibleContextBase::disposing;
73
74
    virtual void SAL_CALL disposing() override;
75
76
    void LostFocus();
77
78
    void GotFocus();
79
80
    ///=====  XAccessibleComponent  ============================================
81
82
    virtual css::uno::Reference< css::accessibility::XAccessible >
83
        SAL_CALL getAccessibleAtPoint(
84
        const css::awt::Point& rPoint ) override;
85
86
    virtual OutputDevice* GetOutputDeviceForView();
87
88
protected:
89
    /// Return the object's current bounding box relative to the desktop.
90
    virtual AbsoluteScreenPixelRectangle GetBoundingBoxOnScreen() override;
91
92
    /// Return the object's current bounding box relative to the parent object.
93
    virtual tools::Rectangle GetBoundingBox() override;
94
95
public:
96
    ///=====  XAccessibleContext  ==============================================
97
98
    /// Return the number of currently visible children.
99
    /// override to calculate this on demand
100
    virtual sal_Int64 SAL_CALL
101
        getAccessibleChildCount() override;
102
103
    /// Return the specified child or NULL if index is invalid.
104
    /// override to calculate this on demand
105
    virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL
106
        getAccessibleChild(sal_Int64 nIndex) override;
107
108
    /// Return the set of current states.
109
    virtual sal_Int64 SAL_CALL getAccessibleStateSet() override;
110
111
    //=====  XAccessibleSelection  ============================================
112
113
        virtual void SAL_CALL selectAccessibleChild(
114
            sal_Int64 nChildIndex ) override;
115
        virtual sal_Bool SAL_CALL isAccessibleChildSelected(
116
            sal_Int64 nChildIndex ) override;
117
        virtual void SAL_CALL clearAccessibleSelection(  ) override;
118
        virtual void SAL_CALL selectAllAccessibleChildren(  ) override;
119
        virtual sal_Int64 SAL_CALL getSelectedAccessibleChildCount(  ) override;
120
        virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild(
121
            sal_Int64 nSelectedChildIndex ) override;
122
        virtual void SAL_CALL deselectAccessibleChild(
123
            sal_Int64 nSelectedChildIndex ) override;
124
    virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet(  ) override;
125
protected:
126
    /// Return this object's description.
127
    virtual OUString
128
        createAccessibleDescription() override;
129
130
    /// Return the object's current name.
131
    virtual OUString
132
        createAccessibleName() override;
133
134
public:
135
    ///=====  XAccessibleEventBroadcaster  =====================================
136
137
    /** Add listener that is informed of future changes of name,
138
          description and so on events.
139
    */
140
    virtual void SAL_CALL
141
        addAccessibleEventListener(
142
            const css::uno::Reference<css::accessibility::XAccessibleEventListener>& xListener) override;
143
144
    //  Remove an existing event listener.
145
    virtual void SAL_CALL
146
        removeAccessibleEventListener(
147
            const css::uno::Reference<css::accessibility::XAccessibleEventListener>& xListener) override;
148
149
private:
150
    std::unique_ptr<accessibility::AccessibleTextHelper> mpTextHelper;
151
    EditView*      mpEditView;
152
    VclPtr<vcl::Window> mpWindow;
153
protected:
154
    ScTextWnd* mpTextWnd;
155
private:
156
    EditObjectType meObjectType;
157
    bool           mbHasFocus;
158
159
    bool IsDefunc(sal_Int64 nParentStates);
160
161
    void CreateTextHelper();
162
    ScDocument *m_pScDoc;
163
    ScAddress m_curCellAddress;
164
165
    ///=====  XAccessibleComponent  ============================================
166
    virtual sal_Int32 SAL_CALL getForeground(  ) override;
167
168
    virtual sal_Int32 SAL_CALL getBackground(  ) override;
169
170
    sal_Int32 GetFgBgColor(  const OUString &strPropColor) ;
171
};
172
173
class ScAccessibleEditControlObject : public ScAccessibleEditObject
174
{
175
private:
176
    weld::CustomWidgetController* m_pController;
177
178
protected:
179
    /// Return the object's current bounding box relative to the desktop.
180
    virtual AbsoluteScreenPixelRectangle GetBoundingBoxOnScreen() override;
181
182
    /// Return the object's current bounding box relative to the parent object.
183
    virtual tools::Rectangle GetBoundingBox() override;
184
185
public:
186
    ScAccessibleEditControlObject(weld::CustomWidgetController* pController, EditObjectType eObjectType)
187
0
        : ScAccessibleEditObject(eObjectType)
188
0
        , m_pController(pController)
189
0
    {
190
0
    }
191
192
    virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet(  ) override;
193
194
    // for mapping positions/sizes within the TextView to a11y
195
    virtual OutputDevice* GetOutputDeviceForView() override;
196
197
    using ScAccessibleContextBase::disposing;
198
    virtual void SAL_CALL disposing() override;
199
};
200
201
class ScAccessibleEditLineObject final : public ScAccessibleEditControlObject
202
{
203
public:
204
    ScAccessibleEditLineObject(ScTextWnd* pTextWnd);
205
};
206
207
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */