1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SVX_FMGRIDCL_HXX
20 #define INCLUDED_SVX_FMGRIDCL_HXX
22 #include <svx/gridctrl.hxx>
23 #include <vcl/transfer.hxx>
24 #include <svx/svxdllapi.h>
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
; }
34 struct FmGridHeaderData
;
35 class SAL_WARN_UNUSED
UNLESS_MERGELIBS_MORE(SVXCORE_DLLPUBLIC
) FmGridHeader
36 :public ::svt::EditBrowserHeader
37 ,public DropTargetHelper
40 FmGridHeader( BrowseBox
* pParent
, WinBits nWinBits
= WB_STDHEADERBAR
| WB_DRAG
);
41 virtual ~FmGridHeader() override
;
42 virtual void dispose() override
;
44 // trigger context menu execution
45 void triggerColumnContextMenu( const ::Point
& _rPreferredPos
);
48 virtual void Command( const CommandEvent
& rCEvt
) override
;
49 virtual void RequestHelp( const HelpEvent
& rHEvt
) override
;
50 virtual void Select() override
;
52 /** the value returned by GetItemPos is meaningless for the grid model if there are hidden columns,
53 so use GetModelColumnPos instead
55 sal_uInt16
GetModelColumnPos(sal_uInt16 nId
) const;
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 ...
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.
69 virtual void PostExecuteColumnContextMenu(sal_uInt16 nColId
, const weld::Menu
& rMenu
, const OUString
& rExecutionResult
);
72 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
) override
;
73 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
) override
;
75 /** selects the column at the selection supplier.
79 void notifyColumnSelect(sal_uInt16 nColumnId
);
81 DECL_DLLPRIVATE_LINK( OnAsyncExecuteDrop
, void*, void );
83 std::unique_ptr
<FmGridHeaderData
> m_pImpl
;
90 class SAL_WARN_UNUSED
UNLESS_MERGELIBS_MORE(SVXCORE_DLLPUBLIC
) FmGridControl
: public DbGridControl
93 friend class FmGridHeader
;
94 friend class FmXGridPeer
;
97 sal_Int32 m_nCurrentSelectedColumn
; // this is the column model (not the view) position...
98 sal_uInt16 m_nMarkedColumnId
;
100 bool m_bInColumnMove
: 1;
104 const css::uno::Reference
< css::uno::XComponentContext
>&,
105 vcl::Window
* pParent
,
110 virtual void KeyInput( const KeyEvent
& rKEvt
) override
;
112 // css::beans::XPropertyChangeListener
113 void propertyChange(const css::beans::PropertyChangeEvent
& evt
);
115 // css::form::XPositioningListener
121 // css::form::XInsertListener
124 void markColumn(sal_uInt16 nId
);
125 bool isColumnMarked(sal_uInt16 nId
) const;
127 sal_Int32
GetSelectedColumn() const { return m_nCurrentSelectedColumn
;}
129 /** return the name of the specified object.
133 The position of a tablecell (index position), header bar column/row cell
135 The name of the specified object.
137 virtual OUString
GetAccessibleObjectName( AccessibleBrowseBoxObjType eObjType
,sal_Int32 _nPosition
= -1) const override
;
139 /** return the description of the specified object.
143 The position of a tablecell (index position), header bar column/row cell
145 The description of the specified object.
147 virtual OUString
GetAccessibleObjectDescription( AccessibleBrowseBoxObjType eObjType
,sal_Int32 _nPosition
= -1) const override
;
150 virtual void Command(const CommandEvent
& rEvt
) override
;
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
;
163 bool IsInColumnMove() const {return m_bInColumnMove
;}
165 virtual void BeginCursorAction() override
;
166 virtual void EndCursorAction() override
;
167 virtual void Select() override
;
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
;
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
183 FmXGridPeer
* GetPeer() const {return m_pPeer
;}
185 css::uno::Sequence
< css::uno::Any
>
186 getSelectionBookmarks();
187 bool selectBookmarks(const css::uno::Sequence
< css::uno::Any
>& _rBookmarks
);
189 /** returns if a column is selected
191 The column to compare with.
193 <TRUE/> if the column is selected, otherwise <FALSE/>
195 bool isColumnSelected(DbGridColumn
const * _pColumn
) const;
198 #endif // INCLUDED_SVX_FMGRIDCL_HXX
200 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */