Branch libreoffice-5-0-4
[LibreOffice.git] / include / svx / fmgridcl.hxx
blob7bb356852b28bc6e16eea9742631acfa902229ba
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <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>
30 // FmGridHeader
32 struct FmGridHeaderData;
33 class SVX_DLLPUBLIC SAL_WARN_UNUSED FmGridHeader
34 :public ::svt::EditBrowserHeader
35 ,public DropTargetHelper
37 protected:
38 FmGridHeaderData* m_pImpl;
40 // trigger context menu execution
41 void triggerColumnContextMenu( const ::Point& _rPreferredPos );
43 public:
44 FmGridHeader( BrowseBox* pParent, WinBits nWinBits = WB_STDHEADERBAR | WB_DRAG );
45 virtual ~FmGridHeader();
46 virtual void dispose() SAL_OVERRIDE;
48 public:
49 struct AccessControl { friend class FmGridControl; private: AccessControl() { } };
51 inline void triggerColumnContextMenu( const ::Point& _rPreferredPos, const AccessControl& )
53 triggerColumnContextMenu( _rPreferredPos );
56 protected:
57 virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
58 virtual void RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE;
59 virtual void Select() SAL_OVERRIDE;
61 /** the value returned by GetItemPos is meaningless for the grid model if there are hidden columns,
62 so use GetModelColumnPos instead
64 sal_uInt16 GetModelColumnPos(sal_uInt16 nId) const;
66 /** This is called before executing a context menu for a column. rMenu contains the initial entries
67 handled by this base class' method (which always has to be called).
68 Derived classes may alter the menu in any way and handle any additional entries in
69 PostExecuteColumnContextMenu.
70 All disabled entries will be removed before executing the menu, so be careful with separators
71 near entries you probably wish to disable ...
73 virtual void PreExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMenu);
74 /** After executing the context menu for a column this method is called.
76 virtual void PostExecuteColumnContextMenu(sal_uInt16 nColId, const PopupMenu& rMenu, sal_uInt16 nExecutionResult);
78 // DropTargetHelper
79 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) SAL_OVERRIDE;
80 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE;
82 /** selects the column at the selection supplier.
83 @param nColumnId
84 The column id.
86 void notifyColumnSelect(sal_uInt16 nColumnId);
87 private:
88 DECL_LINK( OnAsyncExecuteDrop, void* );
92 // FmGridControl
94 class FmXGridPeer;
95 class SVX_DLLPUBLIC SAL_WARN_UNUSED FmGridControl : public DbGridControl
98 friend class FmGridHeader;
99 friend class FmXGridPeer;
101 FmXGridPeer* m_pPeer;
102 sal_Int32 m_nCurrentSelectedColumn; // this is the column model (not the view) posisition ...
103 sal_uInt16 m_nMarkedColumnId;
104 bool m_bSelecting;
105 bool m_bInColumnMove : 1;
107 public:
108 FmGridControl(
109 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&,
110 vcl::Window* pParent,
111 FmXGridPeer* _pPeer,
112 WinBits nBits);
114 // Window
115 virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
117 // ::com::sun::star::beans::XPropertyChangeListener
118 void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt);
120 // ::com::sun::star::form::XPositioningListener
121 void positioned(const ::com::sun::star::lang::EventObject& rEvent);
123 // XBound
124 bool commit();
126 // ::com::sun::star::form::XInsertListener
127 void inserted(const ::com::sun::star::lang::EventObject& rEvent);
129 void markColumn(sal_uInt16 nId);
130 bool isColumnMarked(sal_uInt16 nId) const;
132 sal_Int32 GetSelectedColumn() const { return m_nCurrentSelectedColumn;}
134 /** return the name of the specified object.
135 @param eObjType
136 The type to ask for
137 @param _nPosition
138 The position of a tablecell (index position), header bar column/row cell
139 @return
140 The name of the specified object.
142 virtual OUString GetAccessibleObjectName( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition = -1) const SAL_OVERRIDE;
144 /** return the description of the specified object.
145 @param eObjType
146 The type to ask for
147 @param _nPosition
148 The position of a tablecell (index position), header bar column/row cell
149 @return
150 The description of the specified object.
152 virtual OUString GetAccessibleObjectDescription( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition = -1) const SAL_OVERRIDE;
154 protected:
155 virtual void Command(const CommandEvent& rEvt) SAL_OVERRIDE;
157 virtual VclPtr<BrowserHeader> imp_CreateHeaderBar(BrowseBox* pParent) SAL_OVERRIDE;
158 virtual long QueryMinimumRowHeight() SAL_OVERRIDE;
159 virtual void RowHeightChanged() SAL_OVERRIDE;
160 virtual void ColumnResized(sal_uInt16 nId) SAL_OVERRIDE;
161 virtual void ColumnMoved(sal_uInt16 nId) SAL_OVERRIDE;
162 virtual void DeleteSelectedRows() SAL_OVERRIDE;
163 virtual void SetDesignMode(bool bMode) SAL_OVERRIDE;
164 virtual void CellModified() SAL_OVERRIDE;
165 virtual void HideColumn(sal_uInt16 nId) SAL_OVERRIDE;
166 virtual void ShowColumn(sal_uInt16 nId) SAL_OVERRIDE;
168 bool IsInColumnMove() const {return m_bInColumnMove;}
170 virtual void BeginCursorAction() SAL_OVERRIDE;
171 virtual void EndCursorAction() SAL_OVERRIDE;
172 virtual void Select() SAL_OVERRIDE;
174 // Initialize columns
175 // a.) only by column description
176 virtual void InitColumnsByModels(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& xColumns);
177 // b.) during alivemode by database fields
178 virtual void InitColumnsByFields(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xFields) SAL_OVERRIDE;
180 // some kind of impl version (for one single column) of our version of InitColumnsByFields
181 static void InitColumnByField(
182 DbGridColumn* _pColumn,
183 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumnModel,
184 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxFieldsByNames,
185 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& _rxFieldsByIndex
188 FmXGridPeer* GetPeer() const {return m_pPeer;}
190 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any>
191 getSelectionBookmarks();
192 bool selectBookmarks(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any>& _rBookmarks);
194 /** returns if a column is selected
195 @param nColumnId
196 The column id.
197 @param _pColumn
198 The column to compare with.
199 @return
200 <TRUE/> if the column is selected, otherwise <FALSE/>
202 bool isColumnSelected(sal_uInt16 nColumnId,DbGridColumn* _pColumn);
205 #endif // INCLUDED_SVX_FMGRIDCL_HXX
207 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */