Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/sc/source/ui/inc/AccessibleSpreadsheet.hxx
Line
Count
Source (jump to first uncovered line)
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 <sal/config.h>
23
#include <unotools/weakref.hxx>
24
25
#include <rtl/ref.hxx>
26
27
#include "AccessibleTableBase.hxx"
28
#include "viewdata.hxx"
29
30
#include <vector>
31
32
#include <rangelst.hxx>
33
#include <map>
34
35
class ScMyAddress : public ScAddress
36
{
37
public:
38
0
    ScMyAddress(SCCOL nColP, SCROW nRowP, SCTAB nTabP) : ScAddress(nColP, nRowP, nTabP) {}
39
0
    ScMyAddress(const ScAddress& rAddress) : ScAddress(rAddress) {}
40
41
    bool operator< ( const ScMyAddress& rAddress ) const
42
0
    {
43
0
        if( Row() != rAddress.Row() )
44
0
            return (Row() < rAddress.Row());
45
0
        else
46
0
            return (Col() < rAddress.Col());
47
0
    }
48
};
49
50
class ScTabViewShell;
51
class ScAccessibleDocument;
52
class ScAccessibleCell;
53
54
/** @descr
55
        This base class provides an implementation of the
56
        <code>AccessibleTable</code> service.
57
*/
58
class ScAccessibleSpreadsheet final : public  ScAccessibleTableBase
59
{
60
public:
61
    ScAccessibleSpreadsheet(
62
        ScAccessibleDocument* pAccDoc,
63
        ScTabViewShell* pViewShell,
64
        SCTAB   nTab,
65
        ScSplitPos eSplitPos);
66
67
    using ScAccessibleTableBase::disposing;
68
69
    virtual void SAL_CALL disposing() override;
70
71
    void CompleteSelectionChanged(bool bNewState);
72
73
    void LostFocus();
74
    void GotFocus();
75
76
    void BoundingBoxChanged();
77
    void VisAreaChanged();
78
    void FireFirstCellFocus();
79
80
    bool IsScAddrFormulaSel (const ScAddress &addr) const;
81
    bool IsFormulaMode();
82
    ScMyAddress CalcScAddressFromRangeList(ScRangeList *pMarkedRanges,sal_Int32 nSelectedChildIndex);
83
    static bool CalcScRangeDifferenceMax(const ScRange & rSrc, const ScRange & rDest,int nMax,std::vector<ScMyAddress> &vecRet,int &nSize);
84
    static bool CalcScRangeListDifferenceMax(ScRangeList *pSrc,ScRangeList *pDest,int nMax,std::vector<ScMyAddress> &vecRet);
85
86
private:
87
    ScAccessibleSpreadsheet(
88
        ScAccessibleSpreadsheet& rParent,
89
        const ScRange& rRange );
90
91
    virtual ~ScAccessibleSpreadsheet() override;
92
93
    void ConstructScAccessibleSpreadsheet(
94
        ScAccessibleDocument* pAccDoc,
95
        ScTabViewShell* pViewShell,
96
        SCTAB nTab,
97
        ScSplitPos eSplitPos);
98
99
    using ScAccessibleTableBase::IsDefunc;
100
101
    ///=====  SfxListener  =====================================================
102
    virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
103
104
    ///=====  XAccessibleTable  ================================================
105
106
    /// Returns the row headers as an AccessibleTable.
107
    virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL
108
                getAccessibleRowHeaders(  ) override;
109
110
    /// Returns the column headers as an AccessibleTable.
111
    virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL
112
                getAccessibleColumnHeaders(  ) override;
113
114
    /// Returns the selected rows in a table.
115
    virtual css::uno::Sequence< sal_Int32 > SAL_CALL
116
                getSelectedAccessibleRows(  ) override;
117
118
    /// Returns the selected columns in a table.
119
    virtual css::uno::Sequence< sal_Int32 > SAL_CALL
120
                getSelectedAccessibleColumns(  ) override;
121
122
    /// Returns a boolean value indicating whether the specified row is selected.
123
    virtual sal_Bool SAL_CALL
124
                isAccessibleRowSelected( sal_Int32 nRow ) override;
125
126
    /// Returns a boolean value indicating whether the specified column is selected.
127
    virtual sal_Bool SAL_CALL
128
                isAccessibleColumnSelected( sal_Int32 nColumn ) override;
129
130
    /// Returns the Accessible at a specified row and column in the table.
131
    virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
132
                getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) override;
133
134
    rtl::Reference<ScAccessibleCell> GetAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn);
135
136
    /// Returns a boolean value indicating whether the accessible at a specified row and column is selected.
137
    virtual sal_Bool SAL_CALL
138
                isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) override;
139
140
    ///=====  XAccessibleComponent  ============================================
141
142
    virtual css::uno::Reference< css::accessibility::XAccessible >
143
        SAL_CALL getAccessibleAtPoint(
144
        const css::awt::Point& rPoint ) override;
145
146
    virtual void SAL_CALL grabFocus(  ) override;
147
148
    virtual sal_Int32 SAL_CALL getForeground(  ) override;
149
150
    virtual sal_Int32 SAL_CALL getBackground(  ) override;
151
152
    ///=====  XAccessibleContext  ==============================================
153
154
    /// Return NULL to indicate that an empty relation set.
155
    virtual css::uno::Reference<css::accessibility::XAccessibleRelationSet> SAL_CALL
156
        getAccessibleRelationSet() override;
157
158
    /// Return the set of current states.
159
    virtual sal_Int64 SAL_CALL
160
        getAccessibleStateSet() override;
161
162
    ///=====  XAccessibleSelection  ===========================================
163
164
    virtual void SAL_CALL
165
        selectAccessibleChild( sal_Int64 nChildIndex ) override;
166
167
    virtual void SAL_CALL
168
        clearAccessibleSelection(  ) override;
169
170
    virtual void SAL_CALL
171
        selectAllAccessibleChildren(  ) override;
172
173
    virtual sal_Int64 SAL_CALL
174
        getSelectedAccessibleChildCount(  ) override;
175
176
    virtual css::uno::Reference<css::accessibility::XAccessible > SAL_CALL
177
        getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex ) override;
178
179
    virtual void SAL_CALL
180
        deselectAccessibleChild( sal_Int64 nChildIndex ) override;
181
182
    //=====  XAccessibleTableSelection  ============================================
183
184
    virtual sal_Bool SAL_CALL selectRow( sal_Int32 row ) override;
185
    virtual sal_Bool SAL_CALL selectColumn( sal_Int32 column ) override;
186
    virtual sal_Bool SAL_CALL unselectRow( sal_Int32 row ) override;
187
    virtual sal_Bool SAL_CALL unselectColumn( sal_Int32 column ) override;
188
189
    /// Return the object's current bounding box relative to the desktop.
190
    virtual AbsoluteScreenPixelRectangle GetBoundingBoxOnScreen() override;
191
192
    /// Return the object's current bounding box relative to the parent object.
193
    virtual tools::Rectangle GetBoundingBox() override;
194
195
    bool IsDefunc(sal_Int64 nParentStates);
196
    bool IsEditable();
197
    bool IsFocused();
198
    bool IsCompleteSheetSelected();
199
200
    void SelectCell(sal_Int32 nRow, sal_Int32 nCol, bool bDeselect);
201
202
    static ScDocument* GetDocument(ScTabViewShell* pViewShell);
203
204
    void RemoveSelection(const ScMarkData &refScMarkData);
205
    void CommitFocusCell(const ScAddress &aNewCell);
206
207
0
    sal_Int32 GetRowAll() const { return m_nMaxY - m_nMinY + 1 ; }
208
0
    sal_uInt16  GetColAll() const { return m_nMaxX - m_nMinX + 1; }
209
    void NotifyRefMode();
210
    void RemoveFormulaSelection(bool bRemoveAll = false);
211
    bool CheckChildIndex(sal_Int64) const;
212
    ScAddress GetChildIndexAddress(sal_Int64) const;
213
    sal_Int64 GetAccessibleIndexFormula( sal_Int32 nRow, sal_Int32 nColumn );
214
    bool GetFormulaCurrentFocusCell(ScAddress &addr);
215
216
    ScTabViewShell* mpViewShell;
217
    std::unique_ptr<ScRangeList>  mpMarkedRanges;
218
    ScAccessibleDocument* mpAccDoc;
219
    rtl::Reference<ScAccessibleCell> mpAccCell;
220
    ScSplitPos      meSplitPos;
221
    ScAddress       maActiveCell;
222
    SCTAB           mnTab;
223
    bool            mbIsSpreadsheet;
224
    bool            mbDelIns;
225
    bool            mbIsFocusSend;
226
    typedef std::map<ScMyAddress, rtl::Reference<ScAccessibleCell> >
227
        MAP_ADDR_XACC;
228
    MAP_ADDR_XACC m_mapSelectionSend;
229
    bool          m_bFormulaMode;
230
    bool          m_bFormulaLastMode;
231
    ScAddress     m_aFormulaActiveCell;
232
    MAP_ADDR_XACC m_mapFormulaSelectionSend;
233
    std::vector<ScMyAddress>  m_vecFormulaLastMyAddr;
234
    rtl::Reference<ScAccessibleCell> m_pAccFormulaCell;
235
    sal_uInt16    m_nMinX;
236
    sal_uInt16    m_nMaxX;
237
    sal_Int32     m_nMinY;
238
    sal_Int32     m_nMaxY;
239
    ScRange       m_aLastWithInMarkRange;
240
    OUString      m_strCurCellValue;
241
    ScRangeList   m_LastMarkedRanges;
242
    OUString      m_strOldTabName;
243
    std::map<ScAddress, unotools::WeakReference<ScAccessibleCell>> m_mapCells;
244
};
245
246
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */