Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _SVX_FMGRIDCL_HXX
29 : : #define _SVX_FMGRIDCL_HXX
30 : :
31 : : #include <com/sun/star/container/XIndexContainer.hpp>
32 : : #include <com/sun/star/container/XNameContainer.hpp>
33 : :
34 : : #include <svx/gridctrl.hxx>
35 : : #include <svtools/transfer.hxx>
36 : : #include "svx/svxdllapi.h"
37 : :
38 : : //==================================================================
39 : : // FmGridHeader
40 : : //==================================================================
41 : : struct FmGridHeaderData;
42 : : class SVX_DLLPUBLIC FmGridHeader
43 : : :public ::svt::EditBrowserHeader
44 : : ,public DropTargetHelper
45 : : {
46 : : protected:
47 : : FmGridHeaderData* m_pImpl;
48 : :
49 : : // trigger context menu execution
50 : : void triggerColumnContextMenu( const ::Point& _rPreferredPos );
51 : :
52 : : public:
53 : : FmGridHeader( BrowseBox* pParent, WinBits nWinBits = WB_STDHEADERBAR | WB_DRAG );
54 : : ~FmGridHeader();
55 : :
56 : : public:
57 : : struct AccessControl { friend class FmGridControl; private: AccessControl() { } };
58 : :
59 : : inline void triggerColumnContextMenu( const ::Point& _rPreferredPos, const AccessControl& )
60 : : {
61 : : triggerColumnContextMenu( _rPreferredPos );
62 : : }
63 : :
64 : : protected:
65 : : virtual void Command( const CommandEvent& rCEvt );
66 : : virtual void RequestHelp( const HelpEvent& rHEvt );
67 : : virtual void Select();
68 : :
69 : : /** the value returned by GetItemPos is meaningless for the grid model if there are hidden columns,
70 : : so use GetModelColumnPos instead
71 : : */
72 : : sal_uInt16 GetModelColumnPos(sal_uInt16 nId) const;
73 : :
74 : : /** This is called before executing a context menu for a column. rMenu contains the initial entries
75 : : handled by this base class' method (which always has to be called).
76 : : Derived classes may alter the menu in any way and handle any additional entries in
77 : : PostExecuteColumnContextMenu.
78 : : All disabled entries will be removed before executing the menu, so be careful with separators
79 : : near entries you probably wish to disable ...
80 : : */
81 : : virtual void PreExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMenu);
82 : : /** After executing the context menu for a column this method is called.
83 : : */
84 : : virtual void PostExecuteColumnContextMenu(sal_uInt16 nColId, const PopupMenu& rMenu, sal_uInt16 nExecutionResult);
85 : :
86 : : // DropTargetHelper
87 : : virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
88 : : virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
89 : :
90 : : /** selects the column at the selection supplier.
91 : : @param nColumnId
92 : : The column id.
93 : : */
94 : : void notifyColumnSelect(sal_uInt16 nColumnId);
95 : : private:
96 : : DECL_LINK( OnAsyncExecuteDrop, void* );
97 : : };
98 : :
99 : : //==================================================================
100 : : // FmGridControl
101 : : //==================================================================
102 : : class FmXGridPeer;
103 [ - + ]: 40 : class SVX_DLLPUBLIC FmGridControl : public DbGridControl
104 : :
105 : : {
106 : : friend class FmGridHeader;
107 : : friend class FmXGridPeer;
108 : :
109 : : FmXGridPeer* m_pPeer;
110 : : sal_Int32 m_nCurrentSelectedColumn; // this is the column model (not the view) posisition ...
111 : : sal_uInt16 m_nMarkedColumnId;
112 : : sal_Bool m_bSelecting;
113 : : sal_Bool m_bInColumnMove : 1;
114 : :
115 : : public:
116 : : FmGridControl(
117 : : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >,
118 : : Window* pParent,
119 : : FmXGridPeer* _pPeer,
120 : : WinBits nBits);
121 : :
122 : : // Window
123 : : virtual void KeyInput( const KeyEvent& rKEvt );
124 : :
125 : : // ::com::sun::star::beans::XPropertyChangeListener
126 : : void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt);
127 : :
128 : : // ::com::sun::star::form::XPositioningListener
129 : : void positioned(const ::com::sun::star::lang::EventObject& rEvent);
130 : :
131 : : // XBound
132 : : sal_Bool commit();
133 : :
134 : : // ::com::sun::star::form::XInsertListener
135 : : void inserted(const ::com::sun::star::lang::EventObject& rEvent);
136 : :
137 : : void markColumn(sal_uInt16 nId);
138 : : sal_Bool isColumnMarked(sal_uInt16 nId) const;
139 : :
140 : : sal_Int32 GetSelectedColumn() const;
141 : :
142 : : /** return the name of the specified object.
143 : : @param eObjType
144 : : The type to ask for
145 : : @param _nPosition
146 : : The position of a tablecell (index position), header bar colum/row cell
147 : : @return
148 : : The name of the specified object.
149 : : */
150 : : virtual ::rtl::OUString GetAccessibleObjectName( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition = -1) const;
151 : :
152 : : /** return the description of the specified object.
153 : : @param eObjType
154 : : The type to ask for
155 : : @param _nPosition
156 : : The position of a tablecell (index position), header bar colum/row cell
157 : : @return
158 : : The description of the specified object.
159 : : */
160 : : virtual ::rtl::OUString GetAccessibleObjectDescription( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition = -1) const;
161 : :
162 : : protected:
163 : : virtual void Command(const CommandEvent& rEvt);
164 : :
165 : : virtual BrowserHeader* imp_CreateHeaderBar(BrowseBox* pParent);
166 : : virtual long QueryMinimumRowHeight();
167 : : virtual void RowHeightChanged();
168 : : virtual void ColumnResized(sal_uInt16 nId);
169 : : virtual void ColumnMoved(sal_uInt16 nId);
170 : : virtual void DeleteSelectedRows();
171 : : virtual void SetDesignMode(sal_Bool bMode);
172 : : virtual void CellModified();
173 : : virtual void HideColumn(sal_uInt16 nId);
174 : : virtual void ShowColumn(sal_uInt16 nId);
175 : :
176 : : sal_Bool IsInColumnMove() const {return m_bInColumnMove;}
177 : :
178 : : virtual void BeginCursorAction();
179 : : virtual void EndCursorAction();
180 : : virtual void Select();
181 : :
182 : : // Initialize columns
183 : : // a.) only by column description
184 : : virtual void InitColumnsByModels(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& xColumns);
185 : : // b.) during alivemode by database fields
186 : : virtual void InitColumnsByFields(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& xFields);
187 : :
188 : : // some kind of impl version (for one single column) of our version of InitColumnsByFields
189 : : void InitColumnByField(
190 : : DbGridColumn* _pColumn,
191 : : const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxColumnModel,
192 : : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxFieldsByNames,
193 : : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& _rxFieldsByIndex
194 : : );
195 : :
196 : 0 : FmXGridPeer* GetPeer() const {return m_pPeer;}
197 : :
198 : : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any>
199 : : getSelectionBookmarks();
200 : : sal_Bool selectBookmarks(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any>& _rBookmarks);
201 : :
202 : : /** returns if a column is selected
203 : : @param nColumnId
204 : : The column id.
205 : : @param _pColumn
206 : : The column to compare with.
207 : : @return
208 : : <TRUE/> if the column is selected, otherwise <FALSE/>
209 : : */
210 : : sal_Bool isColumnSelected(sal_uInt16 nColumnId,DbGridColumn* _pColumn);
211 : : };
212 : :
213 : : #endif // _SVX_FMGRIDCL_HXX
214 : :
215 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|