1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fmgridcl.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _SVX_FMGRIDCL_HXX
31 #define _SVX_FMGRIDCL_HXX
33 #ifndef _COM_SUN_STAR_CONTAINER_XINDEXCONTAINER_HPP_
34 #include <com/sun/star/container/XIndexContainer.hpp>
37 #ifndef _COM_SUN_STAR_FORM_XINDEXCONTAINER_HPP_
38 #include <com/sun/star/container/XIndexContainer.hpp>
40 #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
41 #include <com/sun/star/container/XNameContainer.hpp>
45 #ifndef _SVX_GRIDCTRL_HXX
46 #include <bf_svx/gridctrl.hxx>
49 #include <svtools/transfer.hxx>
53 //==================================================================
55 //==================================================================
56 struct FmGridHeaderData
;
58 :public EditBrowserHeader
59 ,public DropTargetHelper
62 FmGridHeaderData
* m_pImpl
;
64 // trigger context menu execution
65 void triggerColumnContextMenu( const ::Point
& _rPreferredPos
);
68 FmGridHeader( BrowseBox
* pParent
, WinBits nWinBits
= WB_STDHEADERBAR
| WB_DRAG
);
72 struct AccessControl
{ friend class FmGridControl
; private: AccessControl() { } };
74 inline void triggerColumnContextMenu( const ::Point
& _rPreferredPos
, const AccessControl
& )
76 triggerColumnContextMenu( _rPreferredPos
);
80 virtual void Command( const CommandEvent
& rCEvt
);
81 virtual void RequestHelp( const HelpEvent
& rHEvt
);
82 virtual void Select();
84 /** the value returned by GetItemPos is meaningless for the grid model if there are hidden columns,
85 so use GetModelColumnPos instead
87 sal_uInt16
GetModelColumnPos(sal_uInt16 nId
) const;
89 /** This is called before executing a context menu for a column. rMenu contains the initial entries
90 handled by this base class' method (which always has to be called).
91 Derived classes may alter the menu in any way and handle any additional entries in
92 PostExecuteColumnContextMenu.
93 All disabled entries will be removed before executing the menu, so be careful with separators
94 near entries you probably wish to disable ...
96 virtual void PreExecuteColumnContextMenu(sal_uInt16 nColId
, PopupMenu
& rMenu
);
97 /** After executing the context menu for a column this method is called.
99 virtual void PostExecuteColumnContextMenu(sal_uInt16 nColId
, const PopupMenu
& rMenu
, sal_uInt16 nExecutionResult
);
102 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
);
103 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
);
105 /** selects the column at the selection supplier.
109 void notifyColumnSelect(sal_uInt16 nColumnId
);
111 DECL_LINK( OnAsyncExecuteDrop
, void* );
114 //==================================================================
116 //==================================================================
117 class FmGridControl
: public DbGridControl
120 friend class FmGridHeader
;
121 friend class FmXGridPeer
;
123 FmXGridPeer
* m_pPeer
;
124 sal_Int32 m_nCurrentSelectedColumn
; // this is the column model (not the view) posisition ...
125 sal_uInt16 m_nMarkedColumnId
;
126 sal_Bool m_bSelecting
;
127 sal_Bool m_bInColumnMove
: 1;
131 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>,
137 virtual void KeyInput( const KeyEvent
& rKEvt
);
139 // ::com::sun::star::beans::XPropertyChangeListener
140 void SAL_CALL
propertyChange(const ::com::sun::star::beans::PropertyChangeEvent
& evt
);
142 // ::com::sun::star::form::XPositioningListener
143 void positioned(const ::com::sun::star::lang::EventObject
& rEvent
);
148 // ::com::sun::star::form::XInsertListener
149 void inserted(const ::com::sun::star::lang::EventObject
& rEvent
);
151 // ::com::sun::star::form::XRestoreListener
152 void restored(const ::com::sun::star::lang::EventObject
& rEvent
);
154 void markColumn(sal_uInt16 nId
);
155 sal_Bool
isColumnMarked(sal_uInt16 nId
) const;
157 sal_Int32
GetSelectedColumn() const;
159 /** return the name of the specified object.
163 The position of a tablecell (index position), header bar colum/row cell
165 The name of the specified object.
167 virtual ::rtl::OUString
GetAccessibleName( AccessibleBrowseBoxObjType eObjType
,sal_Int32 _nPosition
= -1) const;
169 /** return the description of the specified object.
173 The position of a tablecell (index position), header bar colum/row cell
175 The description of the specified object.
177 virtual ::rtl::OUString
GetAccessibleDescription( AccessibleBrowseBoxObjType eObjType
,sal_Int32 _nPosition
= -1) const;
180 virtual void Command(const CommandEvent
& rEvt
);
182 virtual BrowserHeader
* imp_CreateHeaderBar(BrowseBox
* pParent
);
183 virtual void ColumnResized(sal_uInt16 nId
);
184 virtual void ColumnMoved(sal_uInt16 nId
);
185 virtual void DeleteSelectedRows();
186 virtual void SetDesignMode(sal_Bool bMode
);
187 virtual void CellModified();
188 virtual void HideColumn(sal_uInt16 nId
);
189 virtual void ShowColumn(sal_uInt16 nId
);
191 sal_Bool
IsInColumnMove() const {return m_bInColumnMove
;}
193 virtual void BeginCursorAction();
194 virtual void EndCursorAction();
195 virtual void Select();
197 // Initialisieren der Spalten
198 // a.) nur ueber Spaltenbeschreibung
199 virtual void InitColumnsByModels(const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexContainer
>& xColumns
);
200 // b.) im alivemode ueber Datenbankfelder
201 virtual void InitColumnsByFields(const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
>& xFields
);
203 // some kind of impl version (for one single column) of our version of InitColumnsByFields
204 void InitColumnByField(
205 DbGridColumn
* _pColumn
,
206 const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxColumnModel
,
207 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
>& _rxFieldsByNames
,
208 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexAccess
>& _rxFieldsByIndex
211 FmXGridPeer
* GetPeer() const {return m_pPeer
;}
213 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>
214 getSelectionBookmarks();
215 sal_Bool
selectBookmarks(const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& _rBookmarks
);
217 /** returns if a column is selected
221 The column to compare with.
223 <TRUE/> if the column is selected, otherwise <FALSE/>
225 sal_Bool
isColumnSelected(sal_uInt16 nColumnId
,DbGridColumn
* _pColumn
);
228 }//end of namespace binfilter
229 #endif // _SVX_FMGRIDCL_HXX