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 <vcl/window.hxx>
29#include <sfx2/childwin.hxx>
30#include <svl/poolitem.hxx>
31#include <sfx2/bindings.hxx>
32#include <sfx2/dockwin.hxx>
33#include <sfx2/ctrlitem.hxx>
34
35#include "fmexch.hxx"
36#include "sqlparserclient.hxx"
37
38class FmFormShell;
39
40namespace svxform
41{
42
43class FmFilterItem;
44class FmFilterItems;
45class FmParentData;
46class FmFilterAdapter;
47
48// data structure for the filter model
50{
52 OUString m_aText;
53
54public:
55 FmFilterData(FmParentData* pParent, const OUString& rText)
56 :m_pParent( pParent )
57 ,m_aText( rText )
58 {}
59 virtual ~FmFilterData(){}
60
61 void SetText( const OUString& rText ){ m_aText = rText; }
62 const OUString& GetText() const { return m_aText; }
63 FmParentData* GetParent() const {return m_pParent;}
64
65 virtual OUString GetImage() const;
66};
67
69{
70protected:
71 ::std::vector< std::unique_ptr<FmFilterData> > m_aChildren;
72
73public:
74 FmParentData(FmParentData* pParent, const OUString& rText)
75 : FmFilterData(pParent, rText)
76 {}
77 virtual ~FmParentData() override;
78
79 ::std::vector< std::unique_ptr<FmFilterData> >& GetChildren() { return m_aChildren; }
80};
81
82// Item representing the forms and subforms
83class FmFormItem final : public FmParentData
84{
85 css::uno::Reference< css::form::runtime::XFormController > m_xController;
86 css::uno::Reference< css::form::runtime::XFilterController > m_xFilterController;
87
88public:
89
91 const css::uno::Reference< css::form::runtime::XFormController > & _xController,
92 const OUString& _rText)
93 :FmParentData( _pParent, _rText )
94 ,m_xController( _xController )
95 ,m_xFilterController( _xController, css::uno::UNO_QUERY_THROW )
96 {
97 }
98
99 const css::uno::Reference< css::form::runtime::XFormController >&
100 GetController() const { return m_xController; }
101
102 const css::uno::Reference< css::form::runtime::XFilterController >&
104
105 virtual OUString GetImage() const override;
106};
107
108class FmFilterItems final : public FmParentData
109{
110public:
111 FmFilterItems(FmFormItem* pParent, const OUString& rText ) : FmParentData(pParent, rText) {}
112
113 FmFilterItem* Find( const ::sal_Int32 _nFilterComponentIndex ) const;
114 virtual OUString GetImage() const override;
115};
116
117class FmFilterItem final : public FmFilterData
118{
119 OUString m_aFieldName;
121
122public:
124 FmFilterItems* pParent,
125 const OUString& aFieldName,
126 const OUString& aCondition,
127 const sal_Int32 _nComponentIndex
128 );
129
130 const OUString& GetFieldName() const {return m_aFieldName;}
131 sal_Int32 GetComponentIndex() const { return m_nComponentIndex; }
132
133 virtual OUString GetImage() const override;
134};
135
136class FmFilterModel final : public FmParentData
137 ,public SfxBroadcaster
138 ,public ::svxform::OSQLParserClient
139{
140 friend class FmFilterAdapter;
141
142 css::uno::Reference< css::container::XIndexAccess > m_xControllers;
143 css::uno::Reference< css::form::runtime::XFormController > m_xController;
146
147public:
149 virtual ~FmFilterModel() override;
150
151 void Update(const css::uno::Reference< css::container::XIndexAccess > & xControllers, const css::uno::Reference< css::form::runtime::XFormController > & xCurrent);
152 void Clear();
153 bool ValidateText(FmFilterItem const * pItem, OUString& rText, OUString& rErrorMsg) const;
154 void Append(FmFilterItems* pItems, std::unique_ptr<FmFilterItem> pFilterItem);
155 void SetTextForItem(FmFilterItem* pItem, const OUString& rText);
156
157 FmFormItem* GetCurrentForm() const {return m_pCurrentItems ? static_cast<FmFormItem*>(m_pCurrentItems->GetParent()) : nullptr;}
159 void SetCurrentItems(FmFilterItems* pCurrent);
160
161 const css::uno::Reference< css::form::runtime::XFormController > & GetCurrentController() const {return m_xController;}
162 void SetCurrentController(const css::uno::Reference< css::form::runtime::XFormController > & xController);
163
164 void Remove(FmFilterData* pFilterItem);
165 static void AppendFilterItems( FmFormItem& _rItem );
166 void EnsureEmptyFilterRows( FmParentData& _rItem );
167
168private:
169 void Insert(const ::std::vector<std::unique_ptr<FmFilterData>>::iterator& rPos, std::unique_ptr<FmFilterData> pFilterItem);
170 void Remove( const ::std::vector<std::unique_ptr<FmFilterData>>::iterator& rPos );
171 FmFormItem* Find(const ::std::vector<std::unique_ptr<FmFilterData>>& rItems, const css::uno::Reference< css::form::runtime::XFormController > & xController) const;
172 FmFormItem* Find(const ::std::vector<std::unique_ptr<FmFilterData>>& rItems, const css::uno::Reference< css::form::XForm >& xForm) const;
173 void Update(const css::uno::Reference< css::container::XIndexAccess > & xControllers, FmParentData* pParent);
174};
175
176
177class OFilterItemExchange final : public OLocalExchange
178{
179 ::std::vector<FmFilterItem*> m_aDraggedEntries;
180 FmFormItem* m_pFormItem; // ensure that we drop on the same form
181
182public:
184
186 inline static bool hasFormat( const DataFlavorExVector& _rFormats );
187
188 const ::std::vector<FmFilterItem*>& getDraggedEntries() const { return m_aDraggedEntries; }
189 void setDraggedEntries(::std::vector<FmFilterItem*>&& _rList) { m_aDraggedEntries = std::move(_rList); }
190 FmFormItem* getFormItem() const { return m_pFormItem; }
191
192 void setFormItem( FmFormItem* _pItem ) { m_pFormItem = _pItem; }
193
194private:
195 virtual void AddSupportedFormats() override;
196};
197
199{
200 return OLocalExchange::hasFormat( _rFormats, getFormatId() );
201}
202
203class OFilterExchangeHelper final : public OLocalExchangeHelper
204{
205public:
206 OFilterExchangeHelper() : OLocalExchangeHelper() { }
207
208 OFilterItemExchange* operator->() const { return static_cast<OFilterItemExchange*>(m_xTransferable.get()); }
209 OFilterItemExchange& operator*() const { return *static_cast<OFilterItemExchange*>(m_xTransferable.get()); }
210
211private:
212 virtual rtl::Reference<OLocalExchange> createExchange() const override;
213};
214
215class FmFilterNavigator;
216
218{
219private:
221
222 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override;
223 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) override;
224
225public:
227};
228
229class FmFilterNavigator final : public SfxListener
230{
232 std::unique_ptr<weld::TreeView> m_xTreeView;
234
235 std::unique_ptr<FmFilterModel> m_pModel;
236 std::unique_ptr<weld::TreeIter> m_xEditingCurrently;
238
240
241public:
242 FmFilterNavigator(vcl::Window* pTopLevel, std::unique_ptr<weld::TreeView> xTreeView);
243 virtual ~FmFilterNavigator() override;
244
245 void GrabFocus() { m_xTreeView->grab_focus(); }
246
247 void EndEditing();
248
249 void UpdateContent(
250 const css::uno::Reference< css::container::XIndexAccess > & xControllers,
251 const css::uno::Reference< css::form::runtime::XFormController > & xCurrent
252 );
253
255
258
259private:
260 DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
261 DECL_LINK(PopupMenuHdl, const CommandEvent&, bool);
262 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
263
266
267 DECL_LINK(SelectHdl, weld::TreeView&, void);
268 DECL_LINK(EditingEntryHdl, const weld::TreeIter&, bool);
269 typedef std::pair<const weld::TreeIter&, OUString> IterString;
270 DECL_LINK(EditedEntryHdl, const IterString&, bool);
271
272 DECL_LINK(DragBeginHdl, bool&, bool);
273
274 void DeleteSelection();
275 std::unique_ptr<weld::TreeIter> FindEntry(const FmFilterData* pItem) const;
276 void Insert(const FmFilterData* pItem, int nPos);
277 void Remove(FmFilterData const * pItem);
278
279 DECL_LINK(OnRemove, void*, void);
280
287 FmFormItem* getSelectedFilterItems(::std::vector<FmFilterItem*>& _rItemList);
288
298 void insertFilterItem(const ::std::vector<FmFilterItem*>& _rFilterList,FmFilterItems* _pTargetItems, bool _bCopy);
299
300 bool getPrevEntry(weld::TreeIter& rEntry);
301 bool getNextEntry(weld::TreeIter& rEntry);
302};
303
305{
306private:
307 std::unique_ptr<FmFilterNavigator> m_xNavigatorTree;
308
309 virtual bool Close() override;
310 virtual void GetFocus() override;
311 virtual Size CalcDockingSize( SfxChildAlignment ) override;
313
315
316public:
318 vcl::Window* pParent );
319 virtual ~FmFilterNavigatorWin() override;
320 virtual void dispose() override;
321
322 void UpdateContent( FmFormShell const * pFormShell );
323 void StateChangedAtToolBoxControl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) override;
324 void FillInfo( SfxChildWinInfo& rInfo ) const override;
325};
326
328{
329public:
331 SfxChildWinInfo *pInfo );
333};
334
335}
336
337#endif // INCLUDED_SVX_SOURCE_INC_FILTNAV_HXX
338
339/* 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:62
void SetText(const OUString &rText)
Definition: filtnav.hxx:61
virtual OUString GetImage() const
Definition: filtnav.cxx:111
FmParentData * GetParent() const
Definition: filtnav.hxx:63
virtual ~FmFilterData()
Definition: filtnav.hxx:59
FmFilterData(FmParentData *pParent, const OUString &rText)
Definition: filtnav.hxx:55
FmParentData * m_pParent
Definition: filtnav.hxx:51
sal_Int32 m_nComponentIndex
Definition: filtnav.hxx:120
FmFilterItem(FmFilterItems *pParent, const OUString &aFieldName, const OUString &aCondition, const sal_Int32 _nComponentIndex)
Definition: filtnav.cxx:141
sal_Int32 GetComponentIndex() const
Definition: filtnav.hxx:131
virtual OUString GetImage() const override
Definition: filtnav.cxx:151
const OUString & GetFieldName() const
Definition: filtnav.hxx:130
virtual OUString GetImage() const override
Definition: filtnav.cxx:136
FmFilterItems(FmFormItem *pParent, const OUString &rText)
Definition: filtnav.hxx:111
FmFilterItem * Find(const ::sal_Int32 _nFilterComponentIndex) const
Definition: filtnav.cxx:125
virtual ~FmFilterModel() override
Definition: filtnav.cxx:458
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:767
static void AppendFilterItems(FmFormItem &_rItem)
Definition: filtnav.cxx:647
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:144
void Remove(FmFilterData *pFilterItem)
Definition: filtnav.cxx:688
const css::uno::Reference< css::form::runtime::XFormController > & GetCurrentController() const
Definition: filtnav.hxx:161
void SetCurrentController(const css::uno::Reference< css::form::runtime::XFormController > &xController)
Definition: filtnav.cxx:621
void SetTextForItem(FmFilterItem *pItem, const OUString &rText)
Definition: filtnav.cxx:818
void Insert(const ::std::vector< std::unique_ptr< FmFilterData > >::iterator &rPos, std::unique_ptr< FmFilterData > pFilterItem)
Definition: filtnav.cxx:667
FmFilterItems * m_pCurrentItems
Definition: filtnav.hxx:145
FmFormItem * GetCurrentForm() const
Definition: filtnav.hxx:157
css::uno::Reference< css::form::runtime::XFormController > m_xController
Definition: filtnav.hxx:143
FmFilterItems * GetCurrentItems() const
Definition: filtnav.hxx:158
css::uno::Reference< css::container::XIndexAccess > m_xControllers
Definition: filtnav.hxx:142
void SetCurrentItems(FmFilterItems *pCurrent)
Definition: filtnav.cxx:839
void EnsureEmptyFilterRows(FmParentData &_rItem)
Definition: filtnav.cxx:885
void Append(FmFilterItems *pItems, std::unique_ptr< FmFilterItem > pFilterItem)
Definition: filtnav.cxx:812
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt) override
Definition: filtnav.cxx:1043
FmFilterNavigatorDropTarget(FmFilterNavigator &rTreeView)
Definition: filtnav.cxx:1023
FmFilterNavigator & m_rTreeView
Definition: filtnav.hxx:220
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt) override
Definition: filtnav.cxx:1029
FmFilterNavigatorWinMgr(vcl::Window *pParent, sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo *pInfo)
Definition: filtnav.cxx:1839
SFX_DECL_CHILDWINDOW(FmFilterNavigatorWinMgr)
void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
Definition: filtnav.cxx:1775
virtual ~FmFilterNavigatorWin() override
Definition: filtnav.cxx:1737
void FillInfo(SfxChildWinInfo &rInfo) const override
Definition: filtnav.cxx:1798
virtual Size CalcDockingSize(SfxChildAlignment) override
Definition: filtnav.cxx:1804
virtual SfxChildAlignment CheckAlignment(SfxChildAlignment, SfxChildAlignment) override
Definition: filtnav.cxx:1812
virtual bool Close() override
Definition: filtnav.cxx:1789
std::unique_ptr< FmFilterNavigator > m_xNavigatorTree
Definition: filtnav.hxx:307
virtual void GetFocus() override
Definition: filtnav.cxx:1827
virtual void dispose() override
Definition: filtnav.cxx:1742
void UpdateContent(FmFormShell const *pFormShell)
Definition: filtnav.cxx:1749
FmFilterNavigatorWin(SfxBindings *pBindings, SfxChildWindow *pMgr, vcl::Window *pParent)
Definition: filtnav.cxx:1725
bool getPrevEntry(weld::TreeIter &rEntry)
Definition: filtnav.cxx:1580
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: filtnav.cxx:1280
std::pair< const weld::TreeIter &, OUString > IterString
Definition: filtnav.hxx:269
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:1400
std::unique_ptr< weld::TreeIter > FindEntry(const FmFilterData *pItem) const
Definition: filtnav.cxx:1306
VclPtr< vcl::Window > m_xTopLevel
Definition: filtnav.hxx:231
FmFilterNavigator(vcl::Window *pTopLevel, std::unique_ptr< weld::TreeView > xTreeView)
Definition: filtnav.cxx:1048
sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt)
Definition: filtnav.cxx:1224
std::unique_ptr< weld::TreeIter > m_xEditingCurrently
Definition: filtnav.hxx:236
weld::TreeView & get_widget()
Definition: filtnav.hxx:254
void Remove(FmFilterData const *pItem)
Definition: filtnav.cxx:1352
DECL_LINK(EditedEntryHdl, const IterString &, bool)
DECL_LINK(DragBeginHdl, bool &, bool)
ImplSVEvent * m_nAsyncRemoveEvent
Definition: filtnav.hxx:239
void Insert(const FmFilterData *pItem, int nPos)
Definition: filtnav.cxx:1324
DECL_STATIC_LINK(FmFilterNavigator, CustomRenderHdl, weld::TreeView::render_args, void)
DECL_LINK(KeyInputHdl, const KeyEvent &, bool)
FmFilterNavigatorDropTarget m_aDropTargetHelper
Definition: filtnav.hxx:233
FmFormItem * getSelectedFilterItems(::std::vector< FmFilterItem * > &_rItemList)
returns the first form item and the selected FilterItems in the vector
Definition: filtnav.cxx:1365
DECL_LINK(EditingEntryHdl, const weld::TreeIter &, bool)
sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt)
Definition: filtnav.cxx:1171
std::unique_ptr< FmFilterModel > m_pModel
Definition: filtnav.hxx:235
DECL_LINK(SelectHdl, weld::TreeView &, void)
OFilterExchangeHelper m_aControlExchange
Definition: filtnav.hxx:237
void UpdateContent(const css::uno::Reference< css::container::XIndexAccess > &xControllers, const css::uno::Reference< css::form::runtime::XFormController > &xCurrent)
Definition: filtnav.cxx:1081
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:232
virtual ~FmFilterNavigator() override
Definition: filtnav.cxx:1073
bool getNextEntry(weld::TreeIter &rEntry)
Definition: filtnav.cxx:1563
FmFormItem(FmParentData *_pParent, const css::uno::Reference< css::form::runtime::XFormController > &_xController, const OUString &_rText)
Definition: filtnav.hxx:90
const css::uno::Reference< css::form::runtime::XFormController > & GetController() const
Definition: filtnav.hxx:100
const css::uno::Reference< css::form::runtime::XFilterController > & GetFilterController() const
Definition: filtnav.hxx:103
virtual OUString GetImage() const override
Definition: filtnav.cxx:120
css::uno::Reference< css::form::runtime::XFilterController > m_xFilterController
Definition: filtnav.hxx:86
css::uno::Reference< css::form::runtime::XFormController > m_xController
Definition: filtnav.hxx:85
FmParentData(FmParentData *pParent, const OUString &rText)
Definition: filtnav.hxx:74
::std::vector< std::unique_ptr< FmFilterData > > m_aChildren
Definition: filtnav.hxx:71
::std::vector< std::unique_ptr< FmFilterData > > & GetChildren()
Definition: filtnav.hxx:79
virtual ~FmParentData() override
Definition: filtnav.cxx:116
virtual rtl::Reference< OLocalExchange > createExchange() const override
Definition: filtnav.cxx:106
OFilterItemExchange & operator*() const
Definition: filtnav.hxx:209
OFilterItemExchange * operator->() const
Definition: filtnav.hxx:208
FmFormItem * getFormItem() const
Definition: filtnav.hxx:190
const ::std::vector< FmFilterItem * > & getDraggedEntries() const
Definition: filtnav.hxx:188
static SotClipboardFormatId getFormatId()
Definition: filtnav.cxx:98
void setDraggedEntries(::std::vector< FmFilterItem * > &&_rList)
Definition: filtnav.hxx:189
void setFormItem(FmFormItem *_pItem)
Definition: filtnav.hxx:192
virtual void AddSupportedFormats() override
Definition: filtnav.cxx:93
::std::vector< FmFilterItem * > m_aDraggedEntries
Definition: filtnav.hxx:179
static bool hasFormat(const DataFlavorExVector &_rFormats)
Definition: filtnav.hxx:198
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