xref: /aoo41x/main/svx/inc/svx/fmgridcl.hxx (revision 3334a7e6)
1*3334a7e6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*3334a7e6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*3334a7e6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*3334a7e6SAndrew Rist  * distributed with this work for additional information
6*3334a7e6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*3334a7e6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*3334a7e6SAndrew Rist  * "License"); you may not use this file except in compliance
9*3334a7e6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*3334a7e6SAndrew Rist  *
11*3334a7e6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*3334a7e6SAndrew Rist  *
13*3334a7e6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*3334a7e6SAndrew Rist  * software distributed under the License is distributed on an
15*3334a7e6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*3334a7e6SAndrew Rist  * KIND, either express or implied.  See the License for the
17*3334a7e6SAndrew Rist  * specific language governing permissions and limitations
18*3334a7e6SAndrew Rist  * under the License.
19*3334a7e6SAndrew Rist  *
20*3334a7e6SAndrew Rist  *************************************************************/
21*3334a7e6SAndrew Rist 
22*3334a7e6SAndrew Rist 
23cdf0e10cSrcweir #ifndef _SVX_FMGRIDCL_HXX
24cdf0e10cSrcweir #define _SVX_FMGRIDCL_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <com/sun/star/container/XIndexContainer.hpp>
27cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <svx/gridctrl.hxx>
30cdf0e10cSrcweir #include <svtools/transfer.hxx>
31cdf0e10cSrcweir #include "svx/svxdllapi.h"
32cdf0e10cSrcweir 
33cdf0e10cSrcweir //==================================================================
34cdf0e10cSrcweir // FmGridHeader
35cdf0e10cSrcweir //==================================================================
36cdf0e10cSrcweir struct FmGridHeaderData;
37cdf0e10cSrcweir class SVX_DLLPUBLIC FmGridHeader
38cdf0e10cSrcweir 			:public ::svt::EditBrowserHeader
39cdf0e10cSrcweir 			,public DropTargetHelper
40cdf0e10cSrcweir {
41cdf0e10cSrcweir protected:
42cdf0e10cSrcweir 	FmGridHeaderData*		m_pImpl;
43cdf0e10cSrcweir 
44cdf0e10cSrcweir 	// trigger context menu execution
45cdf0e10cSrcweir 	void	triggerColumnContextMenu( const ::Point& _rPreferredPos );
46cdf0e10cSrcweir 
47cdf0e10cSrcweir public:
48cdf0e10cSrcweir 	FmGridHeader( BrowseBox* pParent, WinBits nWinBits = WB_STDHEADERBAR | WB_DRAG );
49cdf0e10cSrcweir 	~FmGridHeader();
50cdf0e10cSrcweir 
51cdf0e10cSrcweir public:
AccessControlFmGridHeader::AccessControl52cdf0e10cSrcweir 	struct AccessControl { friend class FmGridControl; private: AccessControl() { } };
53cdf0e10cSrcweir 
triggerColumnContextMenu(const::Point & _rPreferredPos,const AccessControl &)54cdf0e10cSrcweir 	inline	void	triggerColumnContextMenu( const ::Point& _rPreferredPos, const AccessControl& )
55cdf0e10cSrcweir 	{
56cdf0e10cSrcweir 		triggerColumnContextMenu( _rPreferredPos );
57cdf0e10cSrcweir 	}
58cdf0e10cSrcweir 
59cdf0e10cSrcweir protected:
60cdf0e10cSrcweir 	virtual void Command( const CommandEvent& rCEvt );
61cdf0e10cSrcweir 	virtual void RequestHelp( const HelpEvent& rHEvt );
62cdf0e10cSrcweir 	virtual void Select();
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 	/**	the value returned by GetItemPos is meaningless for the grid model if there are hidden columns,
65cdf0e10cSrcweir 		so use GetModelColumnPos instead
66cdf0e10cSrcweir 	*/
67cdf0e10cSrcweir 	sal_uInt16 GetModelColumnPos(sal_uInt16 nId) const;
68cdf0e10cSrcweir 
69cdf0e10cSrcweir 	/**	This is called before executing a context menu for a column. rMenu contains the initial entries
70cdf0e10cSrcweir 		handled by this base class' method (which always has to be called).
71cdf0e10cSrcweir 		Derived classes may alter the menu in any way and handle any additional entries in
72cdf0e10cSrcweir 		PostExecuteColumnContextMenu.
73cdf0e10cSrcweir 		All disabled entries will be removed before executing the menu, so be careful with separators
74cdf0e10cSrcweir 		near entries you probably wish to disable ...
75cdf0e10cSrcweir 	*/
76cdf0e10cSrcweir 	virtual void	PreExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMenu);
77cdf0e10cSrcweir 	/**	After executing the context menu for a column this method is called.
78cdf0e10cSrcweir 	*/
79cdf0e10cSrcweir 	virtual	void	PostExecuteColumnContextMenu(sal_uInt16 nColId, const PopupMenu& rMenu, sal_uInt16 nExecutionResult);
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 	// DropTargetHelper
82cdf0e10cSrcweir 	virtual sal_Int8	AcceptDrop( const AcceptDropEvent& rEvt );
83cdf0e10cSrcweir 	virtual sal_Int8	ExecuteDrop( const ExecuteDropEvent& rEvt );
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 	/** selects the column at the selection supplier.
86cdf0e10cSrcweir 		@param	nColumnId
87cdf0e10cSrcweir 			The column id.
88cdf0e10cSrcweir 	*/
89cdf0e10cSrcweir 	void notifyColumnSelect(sal_uInt16 nColumnId);
90cdf0e10cSrcweir private:
91cdf0e10cSrcweir 	DECL_LINK( OnAsyncExecuteDrop, void* );
92cdf0e10cSrcweir };
93cdf0e10cSrcweir 
94cdf0e10cSrcweir //==================================================================
95cdf0e10cSrcweir // FmGridControl
96cdf0e10cSrcweir //==================================================================
97cdf0e10cSrcweir class FmXGridPeer;
98cdf0e10cSrcweir class SVX_DLLPUBLIC FmGridControl : public DbGridControl
99cdf0e10cSrcweir 
100cdf0e10cSrcweir {
101cdf0e10cSrcweir 	friend class FmGridHeader;
102cdf0e10cSrcweir 	friend class FmXGridPeer;
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 	FmXGridPeer*		m_pPeer;
105cdf0e10cSrcweir 	sal_Int32			m_nCurrentSelectedColumn;	// this is the column model (not the view) posisition ...
106cdf0e10cSrcweir 	sal_uInt16			m_nMarkedColumnId;
107cdf0e10cSrcweir 	sal_Bool			m_bSelecting;
108cdf0e10cSrcweir 	sal_Bool			m_bInColumnMove	: 1;
109cdf0e10cSrcweir 
110cdf0e10cSrcweir public:
111cdf0e10cSrcweir 	FmGridControl(
112cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >,
113cdf0e10cSrcweir 		Window* pParent,
114cdf0e10cSrcweir 		FmXGridPeer* _pPeer,
115cdf0e10cSrcweir 		WinBits nBits);
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 	// Window
118cdf0e10cSrcweir 	virtual void KeyInput( const KeyEvent& rKEvt );
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 	// ::com::sun::star::beans::XPropertyChangeListener
121cdf0e10cSrcweir 	void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt);
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 	// ::com::sun::star::form::XPositioningListener
124cdf0e10cSrcweir 	void positioned(const ::com::sun::star::lang::EventObject& rEvent);
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 	// XBound
127cdf0e10cSrcweir 	sal_Bool commit();
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 	// ::com::sun::star::form::XInsertListener
130cdf0e10cSrcweir 	void inserted(const ::com::sun::star::lang::EventObject& rEvent);
131cdf0e10cSrcweir 
132cdf0e10cSrcweir 	// ::com::sun::star::form::XRestoreListener
133cdf0e10cSrcweir 	void restored(const ::com::sun::star::lang::EventObject& rEvent);
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 	void markColumn(sal_uInt16 nId);
136cdf0e10cSrcweir 	sal_Bool isColumnMarked(sal_uInt16 nId) const;
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 	sal_Int32	GetSelectedColumn() const;
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 	/** return the name of the specified object.
141cdf0e10cSrcweir 		@param	eObjType
142cdf0e10cSrcweir 			The type to ask for
143cdf0e10cSrcweir 		@param	_nPosition
144cdf0e10cSrcweir 			The position of a tablecell (index position), header bar  colum/row cell
145cdf0e10cSrcweir 		@return
146cdf0e10cSrcweir 			The name of the specified object.
147cdf0e10cSrcweir 	*/
148cdf0e10cSrcweir     virtual ::rtl::OUString GetAccessibleObjectName( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition = -1) const;
149cdf0e10cSrcweir 
150cdf0e10cSrcweir     /** return the description of the specified object.
151cdf0e10cSrcweir 		@param	eObjType
152cdf0e10cSrcweir 			The type to ask for
153cdf0e10cSrcweir 		@param	_nPosition
154cdf0e10cSrcweir 			The position of a tablecell (index position), header bar  colum/row cell
155cdf0e10cSrcweir 		@return
156cdf0e10cSrcweir 			The description of the specified object.
157cdf0e10cSrcweir 	*/
158cdf0e10cSrcweir     virtual ::rtl::OUString GetAccessibleObjectDescription( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition = -1) const;
159cdf0e10cSrcweir 
160cdf0e10cSrcweir protected:
161cdf0e10cSrcweir 	virtual void Command(const CommandEvent& rEvt);
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	virtual BrowserHeader* imp_CreateHeaderBar(BrowseBox* pParent);
164cdf0e10cSrcweir     virtual long QueryMinimumRowHeight();
165cdf0e10cSrcweir     virtual void RowHeightChanged();
166cdf0e10cSrcweir 	virtual void ColumnResized(sal_uInt16 nId);
167cdf0e10cSrcweir 	virtual void ColumnMoved(sal_uInt16 nId);
168cdf0e10cSrcweir 	virtual void DeleteSelectedRows();
169cdf0e10cSrcweir 	virtual void SetDesignMode(sal_Bool bMode);
170cdf0e10cSrcweir 	virtual void CellModified();
171cdf0e10cSrcweir 	virtual void HideColumn(sal_uInt16 nId);
172cdf0e10cSrcweir 	virtual void ShowColumn(sal_uInt16 nId);
173cdf0e10cSrcweir 
IsInColumnMove() const174cdf0e10cSrcweir 	sal_Bool	IsInColumnMove() const {return m_bInColumnMove;}
175cdf0e10cSrcweir 
176cdf0e10cSrcweir 	virtual void BeginCursorAction();
177cdf0e10cSrcweir 	virtual void EndCursorAction();
178cdf0e10cSrcweir 	virtual void Select();
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 	// Initialisieren der Spalten
181cdf0e10cSrcweir 	// a.) nur ueber Spaltenbeschreibung
182cdf0e10cSrcweir 	virtual void InitColumnsByModels(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& xColumns);
183cdf0e10cSrcweir 	// b.) im alivemode ueber Datenbankfelder
184cdf0e10cSrcweir 	virtual void InitColumnsByFields(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xFields);
185cdf0e10cSrcweir 
186cdf0e10cSrcweir 			// some kind of impl version (for one single column) of our version of InitColumnsByFields
187cdf0e10cSrcweir 			void InitColumnByField(
188cdf0e10cSrcweir 					DbGridColumn* _pColumn,
189cdf0e10cSrcweir 					const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumnModel,
190cdf0e10cSrcweir 					const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxFieldsByNames,
191cdf0e10cSrcweir 					const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& _rxFieldsByIndex
192cdf0e10cSrcweir 				);
193cdf0e10cSrcweir 
GetPeer() const194cdf0e10cSrcweir 	FmXGridPeer* GetPeer() const {return m_pPeer;}
195cdf0e10cSrcweir 
196cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any>
197cdf0e10cSrcweir 			getSelectionBookmarks();
198cdf0e10cSrcweir 	sal_Bool selectBookmarks(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any>& _rBookmarks);
199cdf0e10cSrcweir 
200cdf0e10cSrcweir 	/** returns if a column is selected
201cdf0e10cSrcweir 		@param	nColumnId
202cdf0e10cSrcweir 			The column id.
203cdf0e10cSrcweir 		@param	_pColumn
204cdf0e10cSrcweir 			The column to compare with.
205cdf0e10cSrcweir 		@return
206cdf0e10cSrcweir 			<TRUE/> if the column is selected, otherwise <FALSE/>
207cdf0e10cSrcweir 	*/
208cdf0e10cSrcweir 	sal_Bool isColumnSelected(sal_uInt16 nColumnId,DbGridColumn* _pColumn);
209cdf0e10cSrcweir };
210cdf0e10cSrcweir 
211cdf0e10cSrcweir #endif // _SVX_FMGRIDCL_HXX
212cdf0e10cSrcweir 
213