Coverage Report

Created: 2025-12-31 10:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/svx/fmgridcl.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
#ifndef INCLUDED_SVX_FMGRIDCL_HXX
20
#define INCLUDED_SVX_FMGRIDCL_HXX
21
22
#include <svx/gridctrl.hxx>
23
#include <vcl/transfer.hxx>
24
#include <svx/svxdllapi.h>
25
#include <memory>
26
27
namespace com::sun::star::beans { class XPropertySet; }
28
namespace com::sun::star::container { class XIndexContainer; }
29
namespace com::sun::star::container { class XNameAccess; }
30
namespace weld { class Menu; }
31
32
// FmGridHeader
33
34
struct FmGridHeaderData;
35
class SAL_WARN_UNUSED UNLESS_MERGELIBS_MORE(SVXCORE_DLLPUBLIC) FmGridHeader
36
            :public ::svt::EditBrowserHeader
37
            ,public DropTargetHelper
38
{
39
public:
40
    FmGridHeader( BrowseBox* pParent, WinBits nWinBits = WB_STDHEADERBAR | WB_DRAG );
41
    virtual ~FmGridHeader() override;
42
    virtual void dispose() override;
43
44
    // trigger context menu execution
45
    void    triggerColumnContextMenu( const ::Point& _rPreferredPos );
46
47
protected:
48
    virtual void Command( const CommandEvent& rCEvt ) override;
49
    virtual void RequestHelp( const HelpEvent& rHEvt ) override;
50
    virtual void Select() override;
51
52
    /** the value returned by GetItemPos is meaningless for the grid model if there are hidden columns,
53
        so use GetModelColumnPos instead
54
    */
55
    sal_uInt16 GetModelColumnPos(sal_uInt16 nId) const;
56
57
    /** This is called before executing a context menu for a column. rMenu contains the initial entries
58
        handled by this base class' method (which always has to be called).
59
        Derived classes may alter the menu in any way and handle any additional entries in
60
        PostExecuteColumnContextMenu.
61
        All disabled entries will be removed before executing the menu, so be careful with separators
62
        near entries you probably wish to disable ...
63
    */
64
    virtual void    PreExecuteColumnContextMenu(sal_uInt16 nColId, weld::Menu& rMenu,
65
                                                weld::Menu& rInsertMenu, weld::Menu& rChangeMenu,
66
                                                weld::Menu& rShowMenu);
67
    /** After executing the context menu for a column this method is called.
68
    */
69
    virtual void    PostExecuteColumnContextMenu(sal_uInt16 nColId, const weld::Menu& rMenu, const OUString& rExecutionResult);
70
71
    // DropTargetHelper
72
    virtual sal_Int8    AcceptDrop( const AcceptDropEvent& rEvt ) override;
73
    virtual sal_Int8    ExecuteDrop( const ExecuteDropEvent& rEvt ) override;
74
75
    /** selects the column at the selection supplier.
76
        @param  nColumnId
77
            The column id.
78
    */
79
    void notifyColumnSelect(sal_uInt16 nColumnId);
80
private:
81
    DECL_DLLPRIVATE_LINK( OnAsyncExecuteDrop, void*, void );
82
83
    std::unique_ptr<FmGridHeaderData>       m_pImpl;
84
};
85
86
87
// FmGridControl
88
89
class FmXGridPeer;
90
class SAL_WARN_UNUSED UNLESS_MERGELIBS_MORE(SVXCORE_DLLPUBLIC) FmGridControl : public DbGridControl
91
92
{
93
    friend class FmGridHeader;
94
    friend class FmXGridPeer;
95
96
    FmXGridPeer*        m_pPeer;
97
    sal_Int32           m_nCurrentSelectedColumn;   // this is the column model (not the view) position...
98
    sal_uInt16          m_nMarkedColumnId;
99
    bool                m_bSelecting;
100
    bool                m_bInColumnMove : 1;
101
102
public:
103
    FmGridControl(
104
        const css::uno::Reference< css::uno::XComponentContext >&,
105
        vcl::Window* pParent,
106
        FmXGridPeer* _pPeer,
107
        WinBits nBits);
108
109
    // Window
110
    virtual void KeyInput( const KeyEvent& rKEvt ) override;
111
112
    // css::beans::XPropertyChangeListener
113
    void propertyChange(const css::beans::PropertyChangeEvent& evt);
114
115
    // css::form::XPositioningListener
116
    void positioned();
117
118
    // XBound
119
    bool commit();
120
121
    // css::form::XInsertListener
122
    void inserted();
123
124
    void markColumn(sal_uInt16 nId);
125
    bool isColumnMarked(sal_uInt16 nId) const;
126
127
0
    sal_Int32   GetSelectedColumn() const { return m_nCurrentSelectedColumn;}
128
129
    /** return the name of the specified object.
130
        @param  eObjType
131
            The type to ask for
132
        @param  _nPosition
133
            The position of a tablecell (index position), header bar  column/row cell
134
        @return
135
            The name of the specified object.
136
    */
137
    virtual OUString GetAccessibleObjectName( AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition = -1) const override;
138
139
    /** return the description of the specified object.
140
        @param  eObjType
141
            The type to ask for
142
        @param  _nPosition
143
            The position of a tablecell (index position), header bar  column/row cell
144
        @return
145
            The description of the specified object.
146
    */
147
    virtual OUString GetAccessibleObjectDescription( AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition = -1) const override;
148
149
protected:
150
    virtual void Command(const CommandEvent& rEvt) override;
151
152
    virtual VclPtr<BrowserHeader> imp_CreateHeaderBar(BrowseBox* pParent) override;
153
    virtual tools::Long QueryMinimumRowHeight() override;
154
    virtual void RowHeightChanged() override;
155
    virtual void ColumnResized(sal_uInt16 nId) override;
156
    virtual void ColumnMoved(sal_uInt16 nId) override;
157
    virtual void DeleteSelectedRows() override;
158
    virtual void SetDesignMode(bool bMode) override;
159
    virtual void CellModified() override;
160
    virtual void HideColumn(sal_uInt16 nId) override;
161
    virtual void ShowColumn(sal_uInt16 nId) override;
162
163
0
    bool    IsInColumnMove() const {return m_bInColumnMove;}
164
165
    virtual void BeginCursorAction() override;
166
    virtual void EndCursorAction() override;
167
    virtual void Select() override;
168
169
    // Initialize columns
170
    // a.) only by column description
171
    void InitColumnsByModels(const css::uno::Reference< css::container::XIndexContainer >& xColumns);
172
    // b.) during alivemode by database fields
173
    virtual void InitColumnsByFields(const css::uno::Reference< css::container::XIndexAccess >& xFields) override;
174
175
            // some kind of impl version (for one single column) of our version of InitColumnsByFields
176
            static void InitColumnByField(
177
                    DbGridColumn* _pColumn,
178
                    const css::uno::Reference< css::beans::XPropertySet >& _rxColumnModel,
179
                    const css::uno::Reference< css::container::XNameAccess >& _rxFieldsByNames,
180
                    const css::uno::Reference< css::container::XIndexAccess >& _rxFieldsByIndex
181
                );
182
183
0
    FmXGridPeer* GetPeer() const {return m_pPeer;}
184
185
    css::uno::Sequence< css::uno::Any>
186
            getSelectionBookmarks();
187
    bool selectBookmarks(const css::uno::Sequence< css::uno::Any>& _rBookmarks);
188
189
    /** returns if a column is selected
190
        @param  _pColumn
191
            The column to compare with.
192
        @return
193
            <TRUE/> if the column is selected, otherwise <FALSE/>
194
    */
195
    bool isColumnSelected(DbGridColumn const * _pColumn) const;
196
};
197
198
#endif // INCLUDED_SVX_FMGRIDCL_HXX
199
200
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */