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 _SVX_FMGRIDCL_HXX
20 #define _SVX_FMGRIDCL_HXX
22 #include <com/sun/star/container/XIndexContainer.hpp>
23 #include <com/sun/star/container/XNameContainer.hpp>
25 #include <svx/gridctrl.hxx>
26 #include <svtools/transfer.hxx>
27 #include "svx/svxdllapi.h"
29 //==================================================================
31 //==================================================================
32 struct FmGridHeaderData
;
33 class SVX_DLLPUBLIC FmGridHeader
34 :public ::svt::EditBrowserHeader
35 ,public DropTargetHelper
38 FmGridHeaderData
* m_pImpl
;
40 // trigger context menu execution
41 void triggerColumnContextMenu( const ::Point
& _rPreferredPos
);
44 FmGridHeader( BrowseBox
* pParent
, WinBits nWinBits
= WB_STDHEADERBAR
| WB_DRAG
);
48 struct AccessControl
{ friend class FmGridControl
; private: AccessControl() { } };
50 inline void triggerColumnContextMenu( const ::Point
& _rPreferredPos
, const AccessControl
& )
52 triggerColumnContextMenu( _rPreferredPos
);
56 virtual void Command( const CommandEvent
& rCEvt
);
57 virtual void RequestHelp( const HelpEvent
& rHEvt
);
58 virtual void Select();
60 /** the value returned by GetItemPos is meaningless for the grid model if there are hidden columns,
61 so use GetModelColumnPos instead
63 sal_uInt16
GetModelColumnPos(sal_uInt16 nId
) const;
65 /** This is called before executing a context menu for a column. rMenu contains the initial entries
66 handled by this base class' method (which always has to be called).
67 Derived classes may alter the menu in any way and handle any additional entries in
68 PostExecuteColumnContextMenu.
69 All disabled entries will be removed before executing the menu, so be careful with separators
70 near entries you probably wish to disable ...
72 virtual void PreExecuteColumnContextMenu(sal_uInt16 nColId
, PopupMenu
& rMenu
);
73 /** After executing the context menu for a column this method is called.
75 virtual void PostExecuteColumnContextMenu(sal_uInt16 nColId
, const PopupMenu
& rMenu
, sal_uInt16 nExecutionResult
);
78 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
);
79 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
);
81 /** selects the column at the selection supplier.
85 void notifyColumnSelect(sal_uInt16 nColumnId
);
87 DECL_LINK( OnAsyncExecuteDrop
, void* );
90 //==================================================================
92 //==================================================================
94 class SVX_DLLPUBLIC FmGridControl
: public DbGridControl
97 friend class FmGridHeader
;
98 friend class FmXGridPeer
;
100 FmXGridPeer
* m_pPeer
;
101 sal_Int32 m_nCurrentSelectedColumn
; // this is the column model (not the view) posisition ...
102 sal_uInt16 m_nMarkedColumnId
;
103 sal_Bool m_bSelecting
;
104 sal_Bool m_bInColumnMove
: 1;
108 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>&,
114 virtual void KeyInput( const KeyEvent
& rKEvt
);
116 // ::com::sun::star::beans::XPropertyChangeListener
117 void SAL_CALL
propertyChange(const ::com::sun::star::beans::PropertyChangeEvent
& evt
);
119 // ::com::sun::star::form::XPositioningListener
120 void positioned(const ::com::sun::star::lang::EventObject
& rEvent
);
125 // ::com::sun::star::form::XInsertListener
126 void inserted(const ::com::sun::star::lang::EventObject
& rEvent
);
128 void markColumn(sal_uInt16 nId
);
129 sal_Bool
isColumnMarked(sal_uInt16 nId
) const;
131 sal_Int32
GetSelectedColumn() const;
133 /** return the name of the specified object.
137 The position of a tablecell (index position), header bar colum/row cell
139 The name of the specified object.
141 virtual OUString
GetAccessibleObjectName( ::svt::AccessibleBrowseBoxObjType eObjType
,sal_Int32 _nPosition
= -1) const;
143 /** return the description of the specified object.
147 The position of a tablecell (index position), header bar colum/row cell
149 The description of the specified object.
151 virtual OUString
GetAccessibleObjectDescription( ::svt::AccessibleBrowseBoxObjType eObjType
,sal_Int32 _nPosition
= -1) const;
154 virtual void Command(const CommandEvent
& rEvt
);
156 virtual BrowserHeader
* imp_CreateHeaderBar(BrowseBox
* pParent
);
157 virtual long QueryMinimumRowHeight();
158 virtual void RowHeightChanged();
159 virtual void ColumnResized(sal_uInt16 nId
);
160 virtual void ColumnMoved(sal_uInt16 nId
);
161 virtual void DeleteSelectedRows();
162 virtual void SetDesignMode(sal_Bool bMode
);
163 virtual void CellModified();
164 virtual void HideColumn(sal_uInt16 nId
);
165 virtual void ShowColumn(sal_uInt16 nId
);
167 sal_Bool
IsInColumnMove() const {return m_bInColumnMove
;}
169 virtual void BeginCursorAction();
170 virtual void EndCursorAction();
171 virtual void Select();
173 // Initialize columns
174 // a.) only by column description
175 virtual void InitColumnsByModels(const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexContainer
>& xColumns
);
176 // b.) during alivemode by database fields
177 virtual void InitColumnsByFields(const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
>& xFields
);
179 // some kind of impl version (for one single column) of our version of InitColumnsByFields
180 void InitColumnByField(
181 DbGridColumn
* _pColumn
,
182 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxColumnModel
,
183 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
>& _rxFieldsByNames
,
184 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
>& _rxFieldsByIndex
187 FmXGridPeer
* GetPeer() const {return m_pPeer
;}
189 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>
190 getSelectionBookmarks();
191 sal_Bool
selectBookmarks(const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& _rBookmarks
);
193 /** returns if a column is selected
197 The column to compare with.
199 <TRUE/> if the column is selected, otherwise <FALSE/>
201 sal_Bool
isColumnSelected(sal_uInt16 nColumnId
,DbGridColumn
* _pColumn
);
204 #endif // _SVX_FMGRIDCL_HXX
206 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */