1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_SVX_SOURCE_INC_FILTNAV_HXX
#define INCLUDED_SVX_SOURCE_INC_FILTNAV_HXX
#include <com/sun/star/form/XForm.hpp>
#include <com/sun/star/form/runtime/XFormController.hpp>
#include <com/sun/star/form/runtime/XFilterController.hpp>
#include <svl/lstner.hxx>
#include <svl/SfxBroadcaster.hxx>
#include <vcl/window.hxx>
#include <sfx2/childwin.hxx>
#include <svl/poolitem.hxx>
#include <sfx2/bindings.hxx>
#include <sfx2/dockwin.hxx>
#include <sfx2/ctrlitem.hxx>
#include <vcl/image.hxx>
#include <svtools/treelistbox.hxx>
#include <vcl/dialog.hxx>
#include <vcl/group.hxx>
#include <vcl/dockwin.hxx>
#include "svx/fmtools.hxx"
#include "fmexch.hxx"
#include "sqlparserclient.hxx"
class FmFormShell;
namespace svxform
{
class FmFilterItem;
class FmFilterItems;
class FmParentData;
class FmFilterAdapter;
// data structure for the filter model
class FmFilterData
{
FmParentData* m_pParent;
OUString m_aText;
public:
TYPEINFO();
FmFilterData(FmParentData* pParent = NULL, const OUString& rText = OUString())
:m_pParent( pParent )
,m_aText( rText )
{}
virtual ~FmFilterData(){}
void SetText( const OUString& rText ){ m_aText = rText; }
OUString GetText() const { return m_aText; }
FmParentData* GetParent() const {return m_pParent;}
virtual Image GetImage() const;
};
class FmParentData : public FmFilterData
{
protected:
::std::vector< FmFilterData* > m_aChildren;
public:
TYPEINFO_OVERRIDE();
FmParentData(FmParentData* pParent, const OUString& rText)
: FmFilterData(pParent, rText)
{}
virtual ~FmParentData();
::std::vector< FmFilterData* >& GetChildren() { return m_aChildren; }
};
// Item representing the forms and subforms
class FmFormItem : public FmParentData
{
::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xController;
::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFilterController > m_xFilterController;
public:
TYPEINFO_OVERRIDE();
FmFormItem( FmParentData* _pParent,
const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & _xController,
const OUString& _rText)
:FmParentData( _pParent, _rText )
,m_xController( _xController )
,m_xFilterController( _xController, ::com::sun::star::uno::UNO_QUERY_THROW )
{
}
inline const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >&
GetController() { return m_xController; }
inline const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFilterController >&
GetFilterController() { return m_xFilterController; }
virtual Image GetImage() const SAL_OVERRIDE;
};
class FmFilterItems : public FmParentData
{
public:
TYPEINFO_OVERRIDE();
FmFilterItems() : FmParentData(NULL, OUString()) {}
FmFilterItems(FmFormItem* pParent, const OUString& rText ) : FmParentData(pParent, rText) {}
FmFilterItem* Find( const ::sal_Int32 _nFilterComponentIndex ) const;
virtual Image GetImage() const SAL_OVERRIDE;
};
class FmFilterItem : public FmFilterData
{
OUString m_aFieldName;
const sal_Int32 m_nComponentIndex;
public:
TYPEINFO_OVERRIDE();
FmFilterItem(
FmFilterItems* pParent,
const OUString& aFieldName,
const OUString& aCondition,
const sal_Int32 _nComponentIndex
);
const OUString& GetFieldName() const {return m_aFieldName;}
sal_Int32 GetComponentIndex() const { return m_nComponentIndex; }
virtual Image GetImage() const SAL_OVERRIDE;
};
class FmFilterModel : public FmParentData
,public SfxBroadcaster
,public ::svxform::OSQLParserClient
{
friend class FmFilterAdapter;
::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > m_xControllers;
::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xController;
FmFilterAdapter* m_pAdapter;
FmFilterItems* m_pCurrentItems;
public:
TYPEINFO_OVERRIDE();
FmFilterModel();
virtual ~FmFilterModel();
void Update(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & xControllers, const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & xCurrent);
void Clear();
bool ValidateText(FmFilterItem* pItem, OUString& rText, OUString& rErrorMsg) const;
void Append(FmFilterItems* pItems, FmFilterItem* pFilterItem);
void SetTextForItem(FmFilterItem* pItem, const OUString& rText);
FmFormItem* GetCurrentForm() const {return m_pCurrentItems ? static_cast<FmFormItem*>(m_pCurrentItems->GetParent()) : NULL;}
FmFilterItems* GetCurrentItems() const {return m_pCurrentItems;}
void SetCurrentItems(FmFilterItems* pCurrent);
const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & GetCurrentController() const {return m_xController;}
void SetCurrentController(const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & xController);
void Remove(FmFilterData* pFilterItem);
static void AppendFilterItems( FmFormItem& _rItem );
void EnsureEmptyFilterRows( FmParentData& _rItem );
protected:
void Insert(const ::std::vector<FmFilterData*>::iterator& rPos, FmFilterData* pFilterItem);
void Remove( const ::std::vector<FmFilterData*>::iterator& rPos );
FmFormItem* Find(const ::std::vector<FmFilterData*>& rItems, const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & xController) const;
FmFormItem* Find(const ::std::vector<FmFilterData*>& rItems, const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& xForm) const;
void Update(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & xControllers, FmParentData* pParent);
};
class OFilterItemExchange : public OLocalExchange
{
::std::vector<FmFilterItem*> m_aDraggedEntries;
FmFormItem* m_pFormItem; // ensure that we drop on the same form
public:
OFilterItemExchange();
static SotClipboardFormatId getFormatId( );
inline static bool hasFormat( const DataFlavorExVector& _rFormats );
const ::std::vector<FmFilterItem*>& getDraggedEntries() const { return m_aDraggedEntries; }
void setDraggedEntries(const ::std::vector<FmFilterItem*>& _rList) { m_aDraggedEntries = _rList; }
FmFormItem* getFormItem() const { return m_pFormItem; }
void setFormItem( FmFormItem* _pItem ) { m_pFormItem = _pItem; }
protected:
virtual void AddSupportedFormats() SAL_OVERRIDE;
};
inline bool OFilterItemExchange::hasFormat( const DataFlavorExVector& _rFormats )
{
return OLocalExchange::hasFormat( _rFormats, getFormatId() );
}
class OFilterExchangeHelper : public OLocalExchangeHelper
{
public:
OFilterExchangeHelper(vcl::Window* _pDragSource) : OLocalExchangeHelper(_pDragSource) { }
OFilterItemExchange* operator->() const { return static_cast<OFilterItemExchange*>(m_pTransferable); }
protected:
virtual OLocalExchange* createExchange() const SAL_OVERRIDE;
};
class FmFilterNavigator : public SvTreeListBox, public SfxListener
{
enum DROP_ACTION{ DA_SCROLLUP, DA_SCROLLDOWN, DA_EXPANDNODE };
FmFilterModel* m_pModel;
SvTreeListEntry* m_pEditingCurrently;
OFilterExchangeHelper m_aControlExchange;
AutoTimer m_aDropActionTimer;
unsigned short m_aTimerCounter;
Point m_aTimerTriggered; // position, where DropTimer was started
DROP_ACTION m_aDropActionType;
public:
FmFilterNavigator( vcl::Window* pParent );
virtual ~FmFilterNavigator();
virtual void dispose() SAL_OVERRIDE;
void UpdateContent(
const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & xControllers,
const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & xCurrent
);
const FmFilterModel* GetFilterModel() const {return m_pModel;}
protected:
using Control::Notify;
virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
virtual void Command( const CommandEvent& rEvt ) SAL_OVERRIDE;
virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
virtual void InitEntry(SvTreeListEntry* pEntry, const OUString& rStr, const Image& rImg1, const Image& rImg2, SvLBoxButtonKind eButtonKind) SAL_OVERRIDE;
virtual bool Select( SvTreeListEntry* pEntry, bool bSelect=true ) SAL_OVERRIDE;
virtual bool EditingEntry( SvTreeListEntry* pEntry, Selection& rSelection ) SAL_OVERRIDE;
virtual bool EditedEntry( SvTreeListEntry* pEntry, const OUString& rNewText ) SAL_OVERRIDE;
virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) SAL_OVERRIDE;
virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE;
virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ) SAL_OVERRIDE;
void DeleteSelection();
SvTreeListEntry* FindEntry(const FmFilterData* pItem) const;
void Insert(FmFilterData* pItem, sal_uLong nPos);
void Remove(FmFilterData* pItem);
DECL_LINK_TYPED(OnRemove, void*, void);
DECL_LINK_TYPED(OnDropActionTimer, Timer*, void);
private:
/** returns the first form item and the selected FilterItems in the vector
@param _rItemList
Is filled inside. <OUT/>
@return
The first form item.
*/
FmFormItem* getSelectedFilterItems(::std::vector<FmFilterItem*>& _rItemList);
/**
* inserts the filter items into the tree model and creates new FilterItems if needed.
* @param _rFilterList
* The items which should be inserted.
* @param _pTargetItems
* The target where to insert the items.
* @param _bCopy
* If <TRUE/> the items will not be removed from the model, otherwise they will.
*/
void insertFilterItem(const ::std::vector<FmFilterItem*>& _rFilterList,FmFilterItems* _pTargetItems, bool _bCopy = false);
SvTreeListEntry* getPrevEntry(SvTreeListEntry* _pStartWith = NULL);
SvTreeListEntry* getNextEntry(SvTreeListEntry* _pStartWith = NULL);
using SvTreeListBox::Select;
using SvTreeListBox::ExecuteDrop;
using SvTreeListBox::Insert;
};
class FmFilterNavigatorWin : public SfxDockingWindow, public SfxControllerItem
{
private:
VclPtr<FmFilterNavigator> m_pNavigator;
protected:
virtual void Resize() SAL_OVERRIDE;
virtual bool Close() SAL_OVERRIDE;
virtual Size CalcDockingSize( SfxChildAlignment ) SAL_OVERRIDE;
virtual SfxChildAlignment CheckAlignment( SfxChildAlignment, SfxChildAlignment ) SAL_OVERRIDE;
public:
FmFilterNavigatorWin( SfxBindings *pBindings, SfxChildWindow *pMgr,
vcl::Window* pParent );
virtual ~FmFilterNavigatorWin();
virtual void dispose() SAL_OVERRIDE;
void UpdateContent( FmFormShell* pFormShell );
void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) SAL_OVERRIDE;
void FillInfo( SfxChildWinInfo& rInfo ) const SAL_OVERRIDE;
using SfxDockingWindow::StateChanged;
virtual void GetFocus() SAL_OVERRIDE;
};
class FmFilterNavigatorWinMgr : public SfxChildWindow
{
public:
FmFilterNavigatorWinMgr( vcl::Window *pParent, sal_uInt16 nId, SfxBindings *pBindings,
SfxChildWinInfo *pInfo );
SFX_DECL_CHILDWINDOW( FmFilterNavigatorWinMgr );
};
}
#endif // INCLUDED_SVX_SOURCE_INC_FILTNAV_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|