LibreOffice Module dbaccess (master) 1
sbagrid.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <svx/fmgridcl.hxx>
23
24#include <svx/fmgridif.hxx>
25
26#include <com/sun/star/frame/XDispatch.hpp>
27#include <com/sun/star/util/URL.hpp>
30#include <comphelper/uno3.hxx>
31#include "sbamultiplex.hxx"
33#include <rtl/ref.hxx>
34#include <map>
35#include <queue>
36
38
39namespace com::sun::star {
40 namespace lang {
41 class XMultiServiceFactory;
42 }
43}
44
45namespace dbaui
46{
48 {
49 bool operator() (const css::util::URL& x, const css::util::URL& y) const { return x.Complete == y.Complete; }
50 };
51
52 class SbaXStatusMultiplexer;
54 :public FmXGridControl
55 ,public css::frame::XDispatch
56 {
57 typedef std::map<css::util::URL, rtl::Reference<SbaXStatusMultiplexer>, SbaURLCompare> StatusMultiplexerArray;
59
60 public:
61 SbaXGridControl(const css::uno::Reference< css::uno::XComponentContext >&);
62 virtual ~SbaXGridControl() override;
63
64 // UNO
66 virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type& _rType) override;
67
68 // XTypeProvider
69 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
70 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
71
72 // css::lang::XServiceInfo
73 OUString SAL_CALL getImplementationName() override;
74 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
75
76 // css::frame::XDispatch
77 virtual void SAL_CALL dispatch(const css::util::URL& aURL, const css::uno::Sequence< css::beans::PropertyValue >& aArgs) override;
78 virtual void SAL_CALL addStatusListener(const css::uno::Reference< css::frame::XStatusListener > & xControl, const css::util::URL& aURL) override;
79 virtual void SAL_CALL removeStatusListener(const css::uno::Reference< css::frame::XStatusListener > & xControl, const css::util::URL& aURL) override;
80
81 // css::lang::XComponent
82 virtual void SAL_CALL dispose() override;
83
84 virtual void SAL_CALL createPeer(const css::uno::Reference< css::awt::XToolkit > & rToolkit, const css::uno::Reference< css::awt::XWindowPeer > & rParentPeer) override;
85
86 protected:
88 };
89
90 // SbaXGridPeer
91
92 class SbaXGridPeer final
93 :public FmXGridPeer
94 ,public css::frame::XDispatch
95 {
96 comphelper::OMultiTypeInterfaceContainerHelperVar4< css::util::URL, css::frame::XStatusListener,
98
99 public:
100 SbaXGridPeer(const css::uno::Reference< css::uno::XComponentContext >&);
101 virtual ~SbaXGridPeer() override;
102
103 // UNO
104 virtual void SAL_CALL acquire() noexcept override { FmXGridPeer::acquire(); }
105 virtual void SAL_CALL release() noexcept override { FmXGridPeer::release(); }
106 virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type& _rType) override;
107
108 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
109
110 // css::frame::XDispatch
111 virtual void SAL_CALL dispatch(const css::util::URL& aURL, const css::uno::Sequence< css::beans::PropertyValue >& aArgs) override;
112 virtual void SAL_CALL addStatusListener(const css::uno::Reference< css::frame::XStatusListener > & xControl, const css::util::URL& aURL) override;
113 virtual void SAL_CALL removeStatusListener(const css::uno::Reference< css::frame::XStatusListener > & xControl, const css::util::URL& aURL) override;
114
115 // css::frame::XDispatchProvider
116 virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch(const css::util::URL& aURL, const OUString& aTargetFrameName, sal_Int32 nSearchFlags) override;
117
118 // css::lang::XComponent
119 virtual void SAL_CALL dispose() override;
120
121 private:
122 virtual VclPtr<FmGridControl> imp_CreateControl(vcl::Window* pParent, WinBits nStyle) override;
123 void NotifyStatusChanged(const css::util::URL& aUrl, const css::uno::Reference< css::frame::XStatusListener > & xControl);
124
125 // for any execution of XDispatch::dispatch
127 {
128 css::util::URL aURL;
129 css::uno::Sequence< css::beans::PropertyValue > aArgs;
130 };
131 std::queue< DispatchArgs > m_aDispatchArgs;
132 DECL_LINK( OnDispatchEvent, void*, void );
133
134 // for dynamic states of our 4 dispatchable URLs
136 {
141
143 };
144 static DispatchType classifyDispatchURL( const css::util::URL& _rURL );
145
146 typedef std::map<DispatchType, bool> MapDispatchToBool;
148 };
149
150 // SbaGridHeader
151
153 :public FmGridHeader
154 ,public DragSourceHelper
155 {
156 public:
157 SbaGridHeader(BrowseBox* pParent);
158 virtual void dispose() override;
159 virtual ~SbaGridHeader() override;
160 protected:
161
162 // FmGridHeader overridables
163 virtual void PreExecuteColumnContextMenu(sal_uInt16 nColId, weld::Menu& rMenu,
164 weld::Menu& rInsertMenu, weld::Menu& rChangeMenu,
165 weld::Menu& rShowMenu) override;
166 virtual void PostExecuteColumnContextMenu(sal_uInt16 nColId, const weld::Menu& rMenu, const OUString& rExecutionResult) override;
167
168 private:
169 // DragSourceHelper overridables
170 virtual void StartDrag( sal_Int8 _nAction, const Point& _rPosPixel ) override;
171
172 // Window overridables
173 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
174
175 void ImplStartColumnDrag(sal_Int8 _nAction, const Point& _rMousePos);
176 };
177
178 // interfaces for communication between the vcl grid control and a controller
180 {
181 public:
182 virtual void RowChanged() = 0;
183 virtual void ColumnChanged() = 0;
184 virtual void SelectionChanged() = 0;
185 virtual void CellActivated() = 0;
186 virtual void CellDeactivated() = 0;
187 virtual void BeforeDrop() = 0;
188 virtual void AfterDrop() = 0;
189
190 protected:
192 };
193
194 // SbaGridControl
195 class SbaGridControl final : public FmGridControl
196 {
197 friend class SbaGridHeader;
198 friend class SbaXGridPeer;
199
200 // Attributes
203
205
207
208 public:
209 SbaGridControl(css::uno::Reference< css::uno::XComponentContext > const & _rM, Window* pParent, FmXGridPeer* _pPeer, WinBits nBits);
210 virtual ~SbaGridControl() override;
211 virtual void dispose() override;
212
213 virtual void Select() override;
214
215 void SetMasterListener(SbaGridListener* pListener) { m_pMasterListener = pListener; }
216
217 virtual void ActivateCell(sal_Int32 nRow, sal_uInt16 nCol, bool bSetCellFocus = true) override;
218 virtual void DeactivateCell(bool bUpdate = true) override;
219 using FmGridControl::ActivateCell;
220
221 bool IsAllSelected() const { return (GetSelectRowCount() == GetRowCount()) && (GetRowCount() > 0); }
222
223 HeaderBar* GetHeaderBar() const { return FmGridControl::GetHeaderBar(); }
224
233 virtual OUString GetAccessibleObjectDescription( AccessibleBrowseBoxObjType eObjType,sal_Int32 _nPosition = -1) const override;
234
241
242 private:
243 // DragSourceHelper overridables
244 virtual void StartDrag( sal_Int8 _nAction, const Point& _rPosPixel ) override;
245
246 // BrowseBox overridables
247 virtual sal_Int8 AcceptDrop( const BrowserAcceptDropEvent& rEvt ) override;
248 virtual sal_Int8 ExecuteDrop( const BrowserExecuteDropEvent& rEvt ) override;
249 virtual void MouseButtonDown( const BrowserMouseEvent& rMEvt) override;
250
251 // EditBrowseBox overridables
252 virtual VclPtr<BrowserHeader> imp_CreateHeaderBar(BrowseBox* pParent) override;
253 virtual ::svt::CellController* GetController(sal_Int32 nRow, sal_uInt16 nCol) override;
254
255 // DbGridControl overridables
256 virtual void PreExecuteRowContextMenu(weld::Menu& rMenu) override;
257 virtual void PostExecuteRowContextMenu(const OUString& rExecutionResult) override;
258
259 // DbGridControl overridables
260 virtual void onRowChange() override;
261 virtual void onColumnChange() override;
262
263 // get a fields property set from a model pos
264 css::uno::Reference< css::beans::XPropertySet > getField(sal_uInt16 nModelPos);
265
266 // get my data source
267 css::uno::Reference< css::beans::XPropertySet > getDataSource() const;
268
269 // drag events
270 void DoColumnDrag(sal_uInt16 nColumnPos);
271 void DoFieldDrag(sal_uInt16 nColumnPos, sal_Int16 nRowPos);
272
273 void SetBrowserAttrs();
274 void SetColWidth(sal_uInt16 nColId);
275 void SetRowHeight();
276 void SetColAttrs(sal_uInt16 nColId);
277
279
280 DECL_LINK(AsynchDropEvent, void*, void);
281
282 bool IsReadOnlyDB() const;
283 void implTransferSelectedRows( sal_Int16 nRowPos, bool _bTrueIfClipboardFalseIfDrag );
284
285 using FmGridControl::AcceptDrop;
286 using FmGridControl::ExecuteDrop;
287 using FmGridControl::MouseButtonDown;
288 };
289}
290
291/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AccessibleBrowseBoxObjType
virtual void DeleteSelectedRows() override
SbaGridListener * m_pMasterListener
Definition: sbagrid.hxx:202
void SetMasterListener(SbaGridListener *pListener)
Definition: sbagrid.hxx:215
SvNumberFormatter * GetDatasourceFormatter()
Definition: sbagrid.cxx:665
virtual OUString GetAccessibleObjectDescription(AccessibleBrowseBoxObjType eObjType, sal_Int32 _nPosition=-1) const override
return the description of the specified object.
Definition: sbagrid.cxx:1354
virtual void onColumnChange() override
Definition: sbagrid.cxx:834
virtual sal_Int8 AcceptDrop(const BrowserAcceptDropEvent &rEvt) override
Definition: sbagrid.cxx:1131
HeaderBar * GetHeaderBar() const
Definition: sbagrid.hxx:223
DECL_LINK(AsynchDropEvent, void *, void)
void DoColumnDrag(sal_uInt16 nColumnPos)
Definition: sbagrid.cxx:1007
virtual void PreExecuteRowContextMenu(weld::Menu &rMenu) override
Definition: sbagrid.cxx:642
void SetColWidth(sal_uInt16 nColId)
Definition: sbagrid.cxx:677
void SetColAttrs(sal_uInt16 nColId)
Definition: sbagrid.cxx:751
bool IsAllSelected() const
Definition: sbagrid.hxx:221
virtual ::svt::CellController * GetController(sal_Int32 nRow, sal_uInt16 nCol) override
Definition: sbagrid.cxx:634
css::uno::Reference< css::beans::XPropertySet > getDataSource() const
Definition: sbagrid.cxx:1295
virtual sal_Int8 ExecuteDrop(const BrowserExecuteDropEvent &rEvt) override
Definition: sbagrid.cxx:1227
void CopySelectedRowsToClipboard()
copies the currently selected rows to the clipboard @precond at least one row is selected
Definition: sbagrid.cxx:1043
virtual void StartDrag(sal_Int8 _nAction, const Point &_rPosPixel) override
Definition: sbagrid.cxx:914
virtual void DeactivateCell(bool bUpdate=true) override
Definition: sbagrid.cxx:821
virtual void ActivateCell(sal_Int32 nRow, sal_uInt16 nCol, bool bSetCellFocus=true) override
Definition: sbagrid.cxx:814
bool IsReadOnlyDB() const
Definition: sbagrid.cxx:864
virtual void MouseButtonDown(const BrowserMouseEvent &rMEvt) override
Definition: sbagrid.cxx:899
virtual ~SbaGridControl() override
Definition: sbagrid.cxx:616
virtual void Select() override
Definition: sbagrid.cxx:805
SbaGridControl(css::uno::Reference< css::uno::XComponentContext > const &_rM, Window *pParent, FmXGridPeer *_pPeer, WinBits nBits)
Definition: sbagrid.cxx:607
virtual void PostExecuteRowContextMenu(const OUString &rExecutionResult) override
Definition: sbagrid.cxx:793
css::uno::Reference< css::beans::XPropertySet > getField(sal_uInt16 nModelPos)
Definition: sbagrid.cxx:840
void DoFieldDrag(sal_uInt16 nColumnPos, sal_Int16 nRowPos)
Definition: sbagrid.cxx:1084
virtual void dispose() override
Definition: sbagrid.cxx:621
ImplSVEvent * m_nAsyncDropEvent
Definition: sbagrid.hxx:204
virtual VclPtr< BrowserHeader > imp_CreateHeaderBar(BrowseBox *pParent) override
Definition: sbagrid.cxx:629
svx::ODataAccessDescriptor m_aDataDescriptor
Definition: sbagrid.hxx:201
virtual void onRowChange() override
Definition: sbagrid.cxx:828
void implTransferSelectedRows(sal_Int16 nRowPos, bool _bTrueIfClipboardFalseIfDrag)
Definition: sbagrid.cxx:1049
SbaGridHeader(BrowseBox *pParent)
Definition: sbagrid.cxx:477
virtual void StartDrag(sal_Int8 _nAction, const Point &_rPosPixel) override
Definition: sbagrid.cxx:494
void ImplStartColumnDrag(sal_Int8 _nAction, const Point &_rMousePos)
Definition: sbagrid.cxx:515
virtual void PreExecuteColumnContextMenu(sal_uInt16 nColId, weld::Menu &rMenu, weld::Menu &rInsertMenu, weld::Menu &rChangeMenu, weld::Menu &rShowMenu) override
Definition: sbagrid.cxx:545
virtual void dispose() override
Definition: sbagrid.cxx:488
virtual void PostExecuteColumnContextMenu(sal_uInt16 nColId, const weld::Menu &rMenu, const OUString &rExecutionResult) override
Definition: sbagrid.cxx:596
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: sbagrid.cxx:502
virtual ~SbaGridHeader() override
Definition: sbagrid.cxx:483
virtual void CellActivated()=0
virtual void SelectionChanged()=0
virtual void AfterDrop()=0
virtual void RowChanged()=0
virtual void CellDeactivated()=0
virtual void ColumnChanged()=0
virtual void BeforeDrop()=0
OUString SAL_CALL getImplementationName() override
Definition: sbagrid.cxx:92
SbaXGridControl(const css::uno::Reference< css::uno::XComponentContext > &)
Definition: sbagrid.cxx:97
virtual void SAL_CALL createPeer(const css::uno::Reference< css::awt::XToolkit > &rToolkit, const css::uno::Reference< css::awt::XWindowPeer > &rParentPeer) override
Definition: sbagrid.cxx:148
std::map< css::util::URL, rtl::Reference< SbaXStatusMultiplexer >, SbaURLCompare > StatusMultiplexerArray
Definition: sbagrid.hxx:57
StatusMultiplexerArray m_aStatusMultiplexer
Definition: sbagrid.hxx:58
virtual ~SbaXGridControl() override
Definition: sbagrid.cxx:102
virtual void SAL_CALL removeStatusListener(const css::uno::Reference< css::frame::XStatusListener > &xControl, const css::util::URL &aURL) override
Definition: sbagrid.cxx:199
virtual rtl::Reference< FmXGridPeer > imp_CreatePeer(vcl::Window *pParent) override
Definition: sbagrid.cxx:106
virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type &_rType) override
Definition: sbagrid.cxx:130
virtual void SAL_CALL dispatch(const css::util::URL &aURL, const css::uno::Sequence< css::beans::PropertyValue > &aArgs) override
Definition: sbagrid.cxx:165
virtual void SAL_CALL dispose() override
Definition: sbagrid.cxx:217
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: sbagrid.cxx:136
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: sbagrid.cxx:143
virtual void SAL_CALL addStatusListener(const css::uno::Reference< css::frame::XStatusListener > &xControl, const css::util::URL &aURL) override
Definition: sbagrid.cxx:172
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: sbagrid.cxx:83
virtual void SAL_CALL addStatusListener(const css::uno::Reference< css::frame::XStatusListener > &xControl, const css::util::URL &aURL) override
Definition: sbagrid.cxx:441
MapDispatchToBool m_aDispatchStates
Definition: sbagrid.hxx:147
virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch(const css::util::URL &aURL, const OUString &aTargetFrameName, sal_Int32 nSearchFlags) override
Definition: sbagrid.cxx:297
virtual VclPtr< FmGridControl > imp_CreateControl(vcl::Window *pParent, WinBits nStyle) override
Definition: sbagrid.cxx:470
SbaXGridPeer(const css::uno::Reference< css::uno::XComponentContext > &)
Definition: sbagrid.cxx:238
static DispatchType classifyDispatchURL(const css::util::URL &_rURL)
Definition: sbagrid.cxx:330
virtual void SAL_CALL dispatch(const css::util::URL &aURL, const css::uno::Sequence< css::beans::PropertyValue > &aArgs) override
Definition: sbagrid.cxx:344
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: sbagrid.cxx:463
DECL_LINK(OnDispatchEvent, void *, void)
virtual void SAL_CALL removeStatusListener(const css::uno::Reference< css::frame::XStatusListener > &xControl, const css::util::URL &aURL) override
Definition: sbagrid.cxx:455
virtual void SAL_CALL release() noexcept override
Definition: sbagrid.hxx:105
std::map< DispatchType, bool > MapDispatchToBool
Definition: sbagrid.hxx:146
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &_rType) override
Definition: sbagrid.cxx:289
virtual ~SbaXGridPeer() override
Definition: sbagrid.cxx:243
void NotifyStatusChanged(const css::util::URL &aUrl, const css::uno::Reference< css::frame::XStatusListener > &xControl)
Definition: sbagrid.cxx:257
virtual void SAL_CALL dispose() override
Definition: sbagrid.cxx:247
std::queue< DispatchArgs > m_aDispatchArgs
Definition: sbagrid.hxx:131
virtual void SAL_CALL acquire() noexcept override
Definition: sbagrid.hxx:104
comphelper::OMultiTypeInterfaceContainerHelperVar4< css::util::URL, css::frame::XStatusListener, SbaURLCompare > m_aStatusListeners
Definition: sbagrid.hxx:97
float y
float x
URL aURL
Definition: intercept.cxx:87
bool operator()(const css::util::URL &x, const css::util::URL &y) const
Definition: sbagrid.hxx:49
css::uno::Sequence< css::beans::PropertyValue > aArgs
Definition: sbagrid.hxx:129
signed char sal_Int8
#define DECLARE_UNO3_AGG_DEFAULTS(classname, baseclass)
sal_Int64 WinBits