fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / ui / inc / sbagrid.hxx
blob3a0796ecf102a298084a2b3db61aae69c3ffff2c
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 .
20 #ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_SBAGRID_HXX
21 #define INCLUDED_DBACCESS_SOURCE_UI_INC_SBAGRID_HXX
23 #include <svx/fmgridcl.hxx>
25 #include <svx/fmgridif.hxx>
27 #include <com/sun/star/sdb/XSQLQueryComposer.hpp>
28 #include <com/sun/star/frame/XDispatch.hpp>
29 #include <com/sun/star/util/URL.hpp>
30 #include <comphelper/uno3.hxx>
31 #include "sbamultiplex.hxx"
32 #include <svx/dataaccessdescriptor.hxx>
33 #include <map>
34 #include <queue>
36 class SvNumberFormatter;
38 namespace com { namespace sun { namespace star {
39 namespace lang {
40 class XMultiServiceFactory;
42 }}}
44 namespace dbaui
46 struct SbaURLCompare : public ::std::binary_function< ::com::sun::star::util::URL, ::com::sun::star::util::URL, bool>
48 bool operator() (const ::com::sun::star::util::URL& x, const ::com::sun::star::util::URL& y) const { return x.Complete == y.Complete; }
51 class SbaXStatusMultiplexer;
52 class SbaXGridControl
53 :public FmXGridControl
54 ,public ::com::sun::star::frame::XDispatch
56 typedef std::map<css::util::URL, SbaXStatusMultiplexer*, SbaURLCompare> StatusMultiplexerArray;
57 StatusMultiplexerArray m_aStatusMultiplexer;
59 public:
60 SbaXGridControl(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
61 virtual ~SbaXGridControl();
63 // UNO
64 DECLARE_UNO3_DEFAULTS(SbaXGridControl, FmXGridControl)
65 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
67 // XTypeProvider
68 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
69 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
71 // ::com::sun::star::lang::XServiceInfo
72 OUString SAL_CALL getImplementationName() throw(std::exception) SAL_OVERRIDE;
73 virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(std::exception) SAL_OVERRIDE;
74 // need by registration
75 static OUString getImplementationName_Static() throw( ::com::sun::star::uno::RuntimeException );
76 static ::com::sun::star::uno::Sequence< OUString > getSupportedServiceNames_Static() throw( ::com::sun::star::uno::RuntimeException );
77 static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
78 SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&);
80 // ::com::sun::star::frame::XDispatch
81 virtual void SAL_CALL dispatch(const ::com::sun::star::util::URL& aURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
82 virtual void SAL_CALL addStatusListener(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xControl, const ::com::sun::star::util::URL& aURL) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
83 virtual void SAL_CALL removeStatusListener(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xControl, const ::com::sun::star::util::URL& aURL) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
85 // ::com::sun::star::lang::XComponent
86 virtual void SAL_CALL dispose() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
88 virtual void SAL_CALL createPeer(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > & rToolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > & rParentPeer) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
90 protected:
91 virtual FmXGridPeer* imp_CreatePeer(vcl::Window* pParent) SAL_OVERRIDE;
94 // SbaXGridPeer
96 class SbaXGridPeer
97 :public FmXGridPeer
98 ,public ::com::sun::star::frame::XDispatch
100 cppu::OMultiTypeInterfaceContainerHelperVar<
101 css::util::URL, void, SbaURLCompare> m_aStatusListeners;
103 public:
104 SbaXGridPeer(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
105 virtual ~SbaXGridPeer();
107 // UNO
108 virtual void SAL_CALL acquire() throw() SAL_OVERRIDE { FmXGridPeer::acquire(); }
109 virtual void SAL_CALL release() throw() SAL_OVERRIDE { FmXGridPeer::release(); }
110 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
112 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
114 static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
115 sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 > & rId ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
116 static SbaXGridPeer* getImplementation(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _rxIFace);
118 // ::com::sun::star::frame::XDispatch
119 virtual void SAL_CALL dispatch(const ::com::sun::star::util::URL& aURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
120 virtual void SAL_CALL addStatusListener(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xControl, const ::com::sun::star::util::URL& aURL) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
121 virtual void SAL_CALL removeStatusListener(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xControl, const ::com::sun::star::util::URL& aURL) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
123 // ::com::sun::star::frame::XDispatchProvider
124 virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch(const ::com::sun::star::util::URL& aURL, const OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
126 // ::com::sun::star::lang::XComponent
127 virtual void SAL_CALL dispose() throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
129 protected:
130 virtual VclPtr<FmGridControl> imp_CreateControl(vcl::Window* pParent, WinBits nStyle) SAL_OVERRIDE;
131 #ifdef _MSC_VER
132 typedef ::com::sun::star::frame::XStatusListener xstlist_type;
133 typedef ::com::sun::star::uno::Reference< xstlist_type > xlistener_type;
134 void NotifyStatusChanged(const ::com::sun::star::util::URL& aUrl, const xlistener_type & xControl = xlistener_type() );
135 #else
136 void NotifyStatusChanged(const ::com::sun::star::util::URL& aUrl, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xControl = ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > ());
137 #endif // # _MSC_VER
139 private:
140 // for asny execution of XDispatch::dispatch
141 struct DispatchArgs
143 ::com::sun::star::util::URL aURL;
144 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs;
146 ::std::queue< DispatchArgs > m_aDispatchArgs;
147 DECL_LINK( OnDispatchEvent, void* );
149 // for dynamic states of our 4 dispatchable URLs
150 enum DispatchType
152 dtBrowserAttribs,
153 dtRowHeight,
154 dtColumnAttribs,
155 dtColumnWidth,
157 dtUnknown
159 static DispatchType classifyDispatchURL( const ::com::sun::star::util::URL& _rURL );
161 typedef std::map<DispatchType, sal_Bool> MapDispatchToBool;
162 MapDispatchToBool m_aDispatchStates;
165 // SbaGridHeader
167 class SbaGridHeader
168 :public FmGridHeader
169 ,public DragSourceHelper
171 public:
172 SbaGridHeader(BrowseBox* pParent, WinBits nWinBits = WB_STDHEADERBAR | WB_DRAG);
174 protected:
176 // FmGridHeader overridables
177 virtual void PreExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMenu) SAL_OVERRIDE;
178 virtual void PostExecuteColumnContextMenu(sal_uInt16 nColId, const PopupMenu& rMenu, sal_uInt16 nExecutionResult) SAL_OVERRIDE;
180 private:
181 // DragSourceHelper overridables
182 virtual void StartDrag( sal_Int8 _nAction, const Point& _rPosPixel ) SAL_OVERRIDE;
184 // Window overridables
185 virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
187 bool ImplStartColumnDrag(sal_Int8 _nAction, const Point& _rMousePos);
189 private:
190 using FmGridHeader::StartDrag;
193 // interfaces for communication between the vcl grid control and a controller
194 class SbaGridListener
196 public:
197 virtual void RowChanged() = 0;
198 virtual void ColumnChanged() = 0;
199 virtual void SelectionChanged() = 0;
200 virtual void CellActivated() = 0;
201 virtual void CellDeactivated() = 0;
202 virtual void BeforeDrop() = 0;
203 virtual void AfterDrop() = 0;
205 protected:
206 ~SbaGridListener() {}
209 // SbaGridControl
210 class SbaGridControl : public FmGridControl
212 friend class SbaGridHeader;
213 friend class SbaXGridPeer;
215 // Attributes
216 protected:
217 svx::ODataAccessDescriptor m_aDataDescriptor;
218 SbaGridListener* m_pMasterListener;
220 ImplSVEvent * m_nAsyncDropEvent;
222 sal_uInt16 m_nCurrentActionColId;
223 // ui actions (e.g. a context menu) may be performed on columns which aren't the current one
224 // and aren't selected, so we have to track this column id
226 bool m_bActivatingForDrop;
227 // Attribute Access
228 public:
229 sal_uInt16 GetCurrentActionColumn() const { return m_nCurrentActionColId; }
231 public:
232 SbaGridControl(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >,Window* pParent, FmXGridPeer* _pPeer, WinBits nBits = WB_TABSTOP);
233 virtual ~SbaGridControl();
234 virtual void dispose() SAL_OVERRIDE;
236 virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
237 virtual void Select() SAL_OVERRIDE;
239 void SetMasterListener(SbaGridListener* pListener) { m_pMasterListener = pListener; }
241 virtual void ActivateCell(long nRow, sal_uInt16 nCol, bool bSetCellFocus = true) SAL_OVERRIDE;
242 virtual void DeactivateCell(bool bUpdate = true) SAL_OVERRIDE;
243 void ActivateCell() { FmGridControl::ActivateCell(); }
245 bool IsAllSelected() const { return (GetSelectRowCount() == GetRowCount()) && (GetRowCount() > 0); }
247 HeaderBar* GetHeaderBar() const { return FmGridControl::GetHeaderBar(); }
249 /** return the description of the specified object.
250 @param eObjType
251 The type to ask for
252 @param _nPosition
253 The position of a tablecell (index position), header bar column/row cell
254 @return
255 The description of the specified object.
257 virtual OUString GetAccessibleObjectDescription( ::svt::AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition = -1) const SAL_OVERRIDE;
259 virtual void DeleteSelectedRows() SAL_OVERRIDE;
260 /** copies the currently selected rows to the clipboard
261 @precond
262 at least one row is selected
264 void CopySelectedRowsToClipboard();
266 protected:
267 // DragSourceHelper overridables
268 virtual void StartDrag( sal_Int8 _nAction, const Point& _rPosPixel ) SAL_OVERRIDE;
270 // BrowseBox overridables
271 virtual void CursorMoved() SAL_OVERRIDE;
272 virtual sal_Int8 AcceptDrop( const BrowserAcceptDropEvent& rEvt ) SAL_OVERRIDE;
273 virtual sal_Int8 ExecuteDrop( const BrowserExecuteDropEvent& rEvt ) SAL_OVERRIDE;
274 virtual void MouseButtonDown( const BrowserMouseEvent& rMEvt) SAL_OVERRIDE;
276 // EditBrowseBox overridables
277 virtual VclPtr<BrowserHeader> imp_CreateHeaderBar(BrowseBox* pParent) SAL_OVERRIDE;
278 virtual ::svt::CellController* GetController(long nRow, sal_uInt16 nCol) SAL_OVERRIDE;
280 // DbGridControl overridables
281 virtual void PreExecuteRowContextMenu(sal_uInt16 nRow, PopupMenu& rMenu) SAL_OVERRIDE;
282 virtual void PostExecuteRowContextMenu(sal_uInt16 nRow, const PopupMenu& rMenu, sal_uInt16 nExecutionResult) SAL_OVERRIDE;
284 // DbGridControl overridables
285 virtual void onRowChange() SAL_OVERRIDE;
286 virtual void onColumnChange() SAL_OVERRIDE;
288 // my own overridables
289 void BeforeDrop();
290 void AfterDrop();
292 // get a fields property set from a model pos
293 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getField(sal_uInt16 nModelPos);
295 // get my data source
296 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getDataSource() const;
298 // drag events
299 void DoColumnDrag(sal_uInt16 nColumnPos);
300 void DoRowDrag(sal_Int16 nRowPos);
301 void DoFieldDrag(sal_uInt16 nColumnPos, sal_Int16 nRowPos);
303 void SetBrowserAttrs();
304 void SetColWidth(sal_uInt16 nColId);
305 void SetRowHeight();
306 void SetColAttrs(sal_uInt16 nColId);
308 SvNumberFormatter* GetDatasourceFormatter();
310 DECL_LINK(AsynchDropEvent, void*);
312 private:
313 bool IsReadOnlyDB() const;
314 void implTransferSelectedRows( sal_Int16 nRowPos, bool _bTrueIfClipboardFalseIfDrag );
316 private:
317 using FmGridControl::AcceptDrop;
318 using FmGridControl::ExecuteDrop;
319 using FmGridControl::MouseButtonDown;
322 #endif // INCLUDED_DBACCESS_SOURCE_UI_INC_SBAGRID_HXX
324 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */