LibreOffice Module svx (master) 1
filtnav.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#ifndef INCLUDED_SVX_SOURCE_INC_FILTNAV_HXX
20#define INCLUDED_SVX_SOURCE_INC_FILTNAV_HXX
21
22#include <com/sun/star/form/XForm.hpp>
23#include <com/sun/star/form/runtime/XFormController.hpp>
24#include <com/sun/star/form/runtime/XFilterController.hpp>
25#include <svl/lstner.hxx>
27
28#include <utility>
29#include <vcl/window.hxx>
30#include <sfx2/childwin.hxx>
31#include <svl/poolitem.hxx>
32#include <sfx2/bindings.hxx>
33#include <sfx2/dockwin.hxx>
34#include <sfx2/ctrlitem.hxx>
35
36#include "fmexch.hxx"
37#include "sqlparserclient.hxx"
38
39class FmFormShell;
40
41namespace svxform
42{
43
44class FmFilterItem;
45class FmFilterItems;
46class FmParentData;
47class FmFilterAdapter;
48
49// data structure for the filter model
51{
53 OUString m_aText;
54
55public:
56 FmFilterData(FmParentData* pParent, OUString aText)
57 :m_pParent( pParent )
58 ,m_aText(std::move( aText ))
59 {}
60 virtual ~FmFilterData(){}
61
62 void SetText( const OUString& rText ){ m_aText = rText; }
63 const OUString& GetText() const { return m_aText; }
64 FmParentData* GetParent() const {return m_pParent;}
65
66 virtual OUString GetImage() const;
67};
68
70{
71protected:
72 ::std::vector< std::unique_ptr<FmFilterData> > m_aChildren;
73
74public:
75 FmParentData(FmParentData* pParent, const OUString& rText)
76 : FmFilterData(pParent, rText)
77 {}
78 virtual ~FmParentData() override;
79
80 ::std::vector< std::unique_ptr<FmFilterData> >& GetChildren() { return m_aChildren; }
81};
82
83// Item representing the forms and subforms
84class FmFormItem final : public FmParentData
85{
86 css::uno::Reference< css::form::runtime::XFormController > m_xController;
87 css::uno::Reference< css::form::runtime::XFilterController > m_xFilterController;
88
89public:
90
92 const css::uno::Reference< css::form::runtime::XFormController > & _xController,
93 const OUString& _rText)
94 :FmParentData( _pParent, _rText )
95 ,m_xController( _xController )
96 ,m_xFilterController( _xController, css::uno::UNO_QUERY_THROW )
97 {
98 }
99
100 const css::uno::Reference< css::form::runtime::XFormController >&
101 GetController() const { return m_xController; }
102
103 const css::uno::Reference< css::form::runtime::XFilterController >&
105
106 virtual OUString GetImage() const override;
107};
108
109class FmFilterItems final : public FmParentData
110{
111public:
112 FmFilterItems(FmFormItem* pParent, const OUString& rText ) : FmParentData(pParent, rText) {}
113
114 FmFilterItem* Find( const ::sal_Int32 _nFilterComponentIndex ) const;
115 virtual OUString GetImage() const override;
116};
117
118class FmFilterItem final : public FmFilterData
119{
120 OUString m_aFieldName;
122
123public:
125 FmFilterItems* pParent,
126 OUString aFieldName,
127 const OUString& aCondition,
128 const sal_Int32 _nComponentIndex
129 );
130
131 const OUString& GetFieldName() const {return m_aFieldName;}
132 sal_Int32 GetComponentIndex() const { return m_nComponentIndex; }
133
134 virtual OUString GetImage() const override;
135};
136
137class FmFilterModel final : public FmParentData
138 ,public SfxBroadcaster
139 ,public ::svxform::OSQLParserClient
140{
141 friend class FmFilterAdapter;
142
143 css::uno::Reference< css::container::XIndexAccess > m_xControllers;
144 css::uno::Reference< css::form::runtime::XFormController > m_xController;
147
148public:
150 virtual ~FmFilterModel() override;
151
152 void Update(const css::uno::Reference< css::container::XIndexAccess > & xControllers, const css::uno::Reference< css::form::runtime::XFormController > & xCurrent);
153 void Clear();
154 bool ValidateText(FmFilterItem const * pItem, OUString& rText, OUString& rErrorMsg) const;
155 void Append(FmFilterItems* pItems, std::unique_ptr<FmFilterItem> pFilterItem);
156 void SetTextForItem(FmFilterItem* pItem, const OUString& rText);
157
158 FmFormItem* GetCurrentForm() const {return m_pCurrentItems ? static_cast<FmFormItem*>(m_pCurrentItems->GetParent()) : nullptr;}
160 void SetCurrentItems(FmFilterItems* pCurrent);
161
162 const css::uno::Reference< css::form::runtime::XFormController > & GetCurrentController() const {return m_xController;}
163 void SetCurrentController(const css::uno::Reference< css::form::runtime::XFormController > & xController);
164
165 void Remove(FmFilterData* pFilterItem);
166 static void AppendFilterItems( FmFormItem& _rItem );
167 void EnsureEmptyFilterRows( FmParentData& _rItem );
168
169private:
170 void Insert(const ::std::vector<std::unique_ptr<FmFilterData>>::iterator& rPos, std::unique_ptr<FmFilterData> pFilterItem);
171 void Remove( const ::std::vector<std::unique_ptr<FmFilterData>>::iterator& rPos );
172 FmFormItem* Find(const ::std::vector<std::unique_ptr<FmFilterData>>& rItems, const css::uno::Reference< css::form::runtime::XFormController > & xController) const;
173 FmFormItem* Find(const ::std::vector<std::unique_ptr<FmFilterData>>& rItems, const css::uno::Reference< css::form::XForm >& xForm) const;
174 void Update(const css::uno::Reference< css::container::XIndexAccess > & xControllers, FmParentData* pParent);
175};
176
177
178class OFilterItemExchange final : public OLocalExchange
179{
180 ::std::vector<FmFilterItem*> m_aDraggedEntries;
181 FmFormItem* m_pFormItem; // ensure that we drop on the same form
182
183public:
185
187 inline static bool hasFormat( const DataFlavorExVector& _rFormats );
188
189 const ::std::vector<FmFilterItem*>& getDraggedEntries() const { return m_aDraggedEntries; }
190 void setDraggedEntries(::std::vector<FmFilterItem*>&& _rList) { m_aDraggedEntries = std::move(_rList); }
191 FmFormItem* getFormItem() const { return m_pFormItem; }
192
193 void setFormItem( FmFormItem* _pItem ) { m_pFormItem = _pItem; }
194
195private:
196 virtual void AddSupportedFormats() override;
197};
198
200{
201 return OLocalExchange::hasFormat( _rFormats, getFormatId() );
202}
203
204class OFilterExchangeHelper final : public OLocalExchangeHelper
205{
206public:
207 OFilterExchangeHelper() : OLocalExchangeHelper() { }
208
209 OFilterItemExchange* operator->() const { return static_cast<OFilterItemExchange*>(m_xTransferable.get()); }
210 OFilterItemExchange& operator*() const { return *static_cast<OFilterItemExchange*>(m_xTransferable.get()); }
211
212private:
213 virtual rtl::Reference<OLocalExchange> createExchange() const override;
214};
215
216class FmFilterNavigator;
217
218class FmFilterNavigatorDropTarget final : public DropTargetHelper
219{
220private:
222
223 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override;
224 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override;
225
226public:
228};
229
230class FmFilterNavigator final : public SfxListener
231{
233 std::unique_ptr<weld::TreeView> m_xTreeView;
235
236 std::unique_ptr<FmFilterModel> m_pModel;
237 std::unique_ptr<weld::TreeIter> m_xEditingCurrently;
239
241
242public:
243 FmFilterNavigator(vcl::Window* pTopLevel, std::unique_ptr<weld::TreeView> xTreeView);
244 virtual ~FmFilterNavigator() override;
245
246 void GrabFocus() { m_xTreeView->grab_focus(); }
247
248 void EndEditing();
249
250 void UpdateContent(
251 const css::uno::Reference< css::container::XIndexAccess > & xControllers,
252 const css::uno::Reference< css::form::runtime::XFormController > & xCurrent
253 );
254
256
259
260private:
261 DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
262 DECL_LINK(PopupMenuHdl, const CommandEvent&, bool);
263 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
264
267
268 DECL_LINK(SelectHdl, weld::TreeView&, void);
269 DECL_LINK(EditingEntryHdl, const weld::TreeIter&, bool);
270 typedef std::pair<const weld::TreeIter&, OUString> IterString;
271 DECL_LINK(EditedEntryHdl, const IterString&, bool);
272
273 DECL_LINK(DragBeginHdl, bool&, bool);
274
275 void DeleteSelection();
276 std::unique_ptr<weld::TreeIter> FindEntry(const FmFilterData* pItem) const;
277 void Insert(const FmFilterData* pItem, int nPos);
278 void Remove(FmFilterData const * pItem);
279
280 DECL_LINK(OnRemove, void*, void);
281
288 FmFormItem* getSelectedFilterItems(::std::vector<FmFilterItem*>& _rItemList);
289
299 void insertFilterItem(const ::std::vector<FmFilterItem*>& _rFilterList,FmFilterItems* _pTargetItems, bool _bCopy);
300
301 bool getPrevEntry(weld::TreeIter& rEntry);
302 bool getNextEntry(weld::TreeIter& rEntry);
303};
304
306{
307private:
308 std::unique_ptr<FmFilterNavigator> m_xNavigatorTree;
309
310 virtual bool Close() override;
311 virtual void GetFocus() override;
312 virtual Size CalcDockingSize( SfxChildAlignment ) override;
314
316
317public:
319 vcl::Window* pParent );
320 virtual ~FmFilterNavigatorWin() override;
321 virtual void dispose() override;
322
323 void UpdateContent( FmFormShell const * pFormShell );
324 void StateChangedAtToolBoxControl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) override;
325 void FillInfo( SfxChildWinInfo& rInfo ) const override;
326};
327
329{
330public:
332 SfxChildWinInfo *pInfo );
334};
335
336}
337
338#endif // INCLUDED_SVX_SOURCE_INC_FILTNAV_HXX
339
340/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxChildAlignment
VclPtr< vcl::Window > pParent
SfxBindings * pBindings
virtual void StateChanged(StateChangedType nStateChange) override
SfxChildWindow * pMgr
const OUString & GetText() const
Definition: filtnav.hxx:63
void SetText(const OUString &rText)
Definition: filtnav.hxx:62
virtual OUString GetImage() const
Definition: filtnav.cxx:112
FmParentData * GetParent() const
Definition: filtnav.hxx:64
FmFilterData(FmParentData *pParent, OUString aText)
Definition: filtnav.hxx:56
virtual ~FmFilterData()
Definition: filtnav.hxx:60
FmParentData * m_pParent
Definition: filtnav.hxx:52
sal_Int32 m_nComponentIndex
Definition: filtnav.hxx:121
sal_Int32 GetComponentIndex() const
Definition: filtnav.hxx:132
FmFilterItem(FmFilterItems *pParent, OUString aFieldName, const OUString &aCondition, const sal_Int32 _nComponentIndex)
Definition: filtnav.cxx:142
virtual OUString GetImage() const override
Definition: filtnav.cxx:152
const OUString & GetFieldName() const
Definition: filtnav.hxx:131
virtual OUString GetImage() const override
Definition: filtnav.cxx:137
FmFilterItems(FmFormItem *pParent, const OUString &rText)
Definition: filtnav.hxx:112
FmFilterItem * Find(const ::sal_Int32 _nFilterComponentIndex) const
Definition: filtnav.cxx:126
virtual ~FmFilterModel() override
Definition: filtnav.cxx:459
FmFormItem * Find(const ::std::vector< std::unique_ptr< FmFilterData > > &rItems, const css::uno::Reference< css::form::XForm > &xForm) const
FmFormItem * Find(const ::std::vector< std::unique_ptr< FmFilterData > > &rItems, const css::uno::Reference< css::form::runtime::XFormController > &xController) const
bool ValidateText(FmFilterItem const *pItem, OUString &rText, OUString &rErrorMsg) const
Definition: filtnav.cxx:768
static void AppendFilterItems(FmFormItem &_rItem)
Definition: filtnav.cxx:648
void Update(const css::uno::Reference< css::container::XIndexAccess > &xControllers, FmParentData *pParent)
void Update(const css::uno::Reference< css::container::XIndexAccess > &xControllers, const css::uno::Reference< css::form::runtime::XFormController > &xCurrent)
rtl::Reference< FmFilterAdapter > m_pAdapter
Definition: filtnav.hxx:145
void Remove(FmFilterData *pFilterItem)
Definition: filtnav.cxx:689
const css::uno::Reference< css::form::runtime::XFormController > & GetCurrentController() const
Definition: filtnav.hxx:162
void SetCurrentController(const css::uno::Reference< css::form::runtime::XFormController > &xController)
Definition: filtnav.cxx:622
void SetTextForItem(FmFilterItem *pItem, const OUString &rText)
Definition: filtnav.cxx:819
void Insert(const ::std::vector< std::unique_ptr< FmFilterData > >::iterator &rPos, std::unique_ptr< FmFilterData > pFilterItem)
Definition: filtnav.cxx:668
FmFilterItems * m_pCurrentItems
Definition: filtnav.hxx:146
FmFormItem * GetCurrentForm() const
Definition: filtnav.hxx:158
css::uno::Reference< css::form::runtime::XFormController > m_xController
Definition: filtnav.hxx:144
FmFilterItems * GetCurrentItems() const
Definition: filtnav.hxx:159
css::uno::Reference< css::container::XIndexAccess > m_xControllers
Definition: filtnav.hxx:143
void SetCurrentItems(FmFilterItems *pCurrent)
Definition: filtnav.cxx:840
void EnsureEmptyFilterRows(FmParentData &_rItem)
Definition: filtnav.cxx:886
void Append(FmFilterItems *pItems, std::unique_ptr< FmFilterItem > pFilterItem)
Definition: filtnav.cxx:813
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt) override
Definition: filtnav.cxx:1044
FmFilterNavigatorDropTarget(FmFilterNavigator &rTreeView)
Definition: filtnav.cxx:1024
FmFilterNavigator & m_rTreeView
Definition: filtnav.hxx:221
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt) override
Definition: filtnav.cxx:1030
FmFilterNavigatorWinMgr(vcl::Window *pParent, sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo *pInfo)
Definition: filtnav.cxx:1840
SFX_DECL_CHILDWINDOW(FmFilterNavigatorWinMgr)
void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
Definition: filtnav.cxx:1776
virtual ~FmFilterNavigatorWin() override
Definition: filtnav.cxx:1738
void FillInfo(SfxChildWinInfo &rInfo) const override
Definition: filtnav.cxx:1799
virtual Size CalcDockingSize(SfxChildAlignment) override
Definition: filtnav.cxx:1805
virtual SfxChildAlignment CheckAlignment(SfxChildAlignment, SfxChildAlignment) override
Definition: filtnav.cxx:1813
virtual bool Close() override
Definition: filtnav.cxx:1790
std::unique_ptr< FmFilterNavigator > m_xNavigatorTree
Definition: filtnav.hxx:308
virtual void GetFocus() override
Definition: filtnav.cxx:1828
virtual void dispose() override
Definition: filtnav.cxx:1743
void UpdateContent(FmFormShell const *pFormShell)
Definition: filtnav.cxx:1750
FmFilterNavigatorWin(SfxBindings *pBindings, SfxChildWindow *pMgr, vcl::Window *pParent)
Definition: filtnav.cxx:1726
bool getPrevEntry(weld::TreeIter &rEntry)
Definition: filtnav.cxx:1581
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: filtnav.cxx:1281
std::pair< const weld::TreeIter &, OUString > IterString
Definition: filtnav.hxx:270
void insertFilterItem(const ::std::vector< FmFilterItem * > &_rFilterList, FmFilterItems *_pTargetItems, bool _bCopy)
inserts the filter items into the tree model and creates new FilterItems if needed.
Definition: filtnav.cxx:1401
std::unique_ptr< weld::TreeIter > FindEntry(const FmFilterData *pItem) const
Definition: filtnav.cxx:1307
VclPtr< vcl::Window > m_xTopLevel
Definition: filtnav.hxx:232
FmFilterNavigator(vcl::Window *pTopLevel, std::unique_ptr< weld::TreeView > xTreeView)
Definition: filtnav.cxx:1049
sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt)
Definition: filtnav.cxx:1225
std::unique_ptr< weld::TreeIter > m_xEditingCurrently
Definition: filtnav.hxx:237
weld::TreeView & get_widget()
Definition: filtnav.hxx:255
void Remove(FmFilterData const *pItem)
Definition: filtnav.cxx:1353
DECL_LINK(EditedEntryHdl, const IterString &, bool)
DECL_LINK(DragBeginHdl, bool &, bool)
ImplSVEvent * m_nAsyncRemoveEvent
Definition: filtnav.hxx:240
void Insert(const FmFilterData *pItem, int nPos)
Definition: filtnav.cxx:1325
DECL_STATIC_LINK(FmFilterNavigator, CustomRenderHdl, weld::TreeView::render_args, void)
DECL_LINK(KeyInputHdl, const KeyEvent &, bool)
FmFilterNavigatorDropTarget m_aDropTargetHelper
Definition: filtnav.hxx:234
FmFormItem * getSelectedFilterItems(::std::vector< FmFilterItem * > &_rItemList)
returns the first form item and the selected FilterItems in the vector
Definition: filtnav.cxx:1366
DECL_LINK(EditingEntryHdl, const weld::TreeIter &, bool)
sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt)
Definition: filtnav.cxx:1172
std::unique_ptr< FmFilterModel > m_pModel
Definition: filtnav.hxx:236
DECL_LINK(SelectHdl, weld::TreeView &, void)
OFilterExchangeHelper m_aControlExchange
Definition: filtnav.hxx:238
void UpdateContent(const css::uno::Reference< css::container::XIndexAccess > &xControllers, const css::uno::Reference< css::form::runtime::XFormController > &xCurrent)
Definition: filtnav.cxx:1082
DECL_LINK(OnRemove, void *, void)
DECL_LINK(PopupMenuHdl, const CommandEvent &, bool)
DECL_STATIC_LINK(FmFilterNavigator, CustomGetSizeHdl, weld::TreeView::get_size_args, Size)
std::unique_ptr< weld::TreeView > m_xTreeView
Definition: filtnav.hxx:233
virtual ~FmFilterNavigator() override
Definition: filtnav.cxx:1074
bool getNextEntry(weld::TreeIter &rEntry)
Definition: filtnav.cxx:1564
FmFormItem(FmParentData *_pParent, const css::uno::Reference< css::form::runtime::XFormController > &_xController, const OUString &_rText)
Definition: filtnav.hxx:91
const css::uno::Reference< css::form::runtime::XFormController > & GetController() const
Definition: filtnav.hxx:101
const css::uno::Reference< css::form::runtime::XFilterController > & GetFilterController() const
Definition: filtnav.hxx:104
virtual OUString GetImage() const override
Definition: filtnav.cxx:121
css::uno::Reference< css::form::runtime::XFilterController > m_xFilterController
Definition: filtnav.hxx:87
css::uno::Reference< css::form::runtime::XFormController > m_xController
Definition: filtnav.hxx:86
FmParentData(FmParentData *pParent, const OUString &rText)
Definition: filtnav.hxx:75
::std::vector< std::unique_ptr< FmFilterData > > m_aChildren
Definition: filtnav.hxx:72
::std::vector< std::unique_ptr< FmFilterData > > & GetChildren()
Definition: filtnav.hxx:80
virtual ~FmParentData() override
Definition: filtnav.cxx:117
virtual rtl::Reference< OLocalExchange > createExchange() const override
Definition: filtnav.cxx:107
OFilterItemExchange & operator*() const
Definition: filtnav.hxx:210
OFilterItemExchange * operator->() const
Definition: filtnav.hxx:209
FmFormItem * getFormItem() const
Definition: filtnav.hxx:191
const ::std::vector< FmFilterItem * > & getDraggedEntries() const
Definition: filtnav.hxx:189
static SotClipboardFormatId getFormatId()
Definition: filtnav.cxx:99
void setDraggedEntries(::std::vector< FmFilterItem * > &&_rList)
Definition: filtnav.hxx:190
void setFormItem(FmFormItem *_pItem)
Definition: filtnav.hxx:193
virtual void AddSupportedFormats() override
Definition: filtnav.cxx:94
::std::vector< FmFilterItem * > m_aDraggedEntries
Definition: filtnav.hxx:180
static bool hasFormat(const DataFlavorExVector &_rFormats)
Definition: filtnav.hxx:199
std::tuple< vcl::RenderContext &, const tools::Rectangle &, bool, const OUString & > render_args
std::pair< vcl::RenderContext &, const OUString & > get_size_args
::std::vector< DataFlavorEx > DataFlavorExVector
SotClipboardFormatId
class FmSearchEngine - Impl class for FmSearchDialog
sal_Int16 nId
SfxItemState
signed char sal_Int8