summaryrefslogtreecommitdiffstats
path: root/sc/source/ui/inc/filtdlg.hxx
blob: cac9bc71ee26df137deefe4bd39ec5d02ac6b9a1 (plain)
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
/* -*- 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 .
 */

#pragma once

#include <address.hxx>
#include "anyrefdg.hxx"
#include <queryparam.hxx>
#include <filterentries.hxx>
#include <queryentry.hxx>

#include <memory>
#include <deque>
#include <vector>
#include <map>

class ScFilterOptionsMgr;
class ScViewData;
class ScDocument;
class ScQueryItem;

class ScFilterDlg : public ScAnyRefDlgController
{
    struct EntryList
    {
        ScFilterEntries maFilterEntries;
        size_t mnHeaderPos;

        EntryList(const EntryList&) = delete;
        const EntryList& operator=(const EntryList&) = delete;

        EntryList();
    };
    typedef std::map<SCCOL, std::unique_ptr<EntryList>> EntryListsMap;
public:
    ScFilterDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent,
                const SfxItemSet& rArgSet);
    virtual ~ScFilterDlg() override;

    virtual void    SetReference( const ScRange& rRef, ScDocument& rDoc ) override;

    virtual bool    IsRefInputMode() const override;
    virtual void    SetActive() override;

    virtual void    Close() override;
    void            SliderMoved();
    size_t          GetSliderPos() const;
    void            RefreshEditRow( size_t nOffset );

private:
    const OUString aStrUndefined;
    const OUString aStrNone;

    const OUString aStrEmpty;
    const OUString aStrNotEmpty;
    const OUString aStrColumn;
    const OUString aStrTextColor;
    const OUString aStrBackgroundColor;

    std::unique_ptr<ScFilterOptionsMgr> pOptionsMgr;

    const sal_uInt16        nWhichQuery;
    ScQueryParam        theQueryData;
    std::unique_ptr<ScQueryItem> pOutItem;
    ScViewData*         pViewData;
    ScDocument*         pDoc;
    SCTAB               nSrcTab;

    std::vector<weld::ComboBox*> maValueEdArr;
    std::vector<weld::ComboBox*> maFieldLbArr;
    std::vector<weld::ComboBox*> maCondLbArr;
    std::vector<weld::ComboBox*> maConnLbArr;
    std::vector<weld::ComboBox*> maColorLbArr;
    std::vector<weld::Button*>   maRemoveBtnArr;

    std::deque<bool>   maHasDates;
    std::deque<bool>   maRefreshExceptQuery;
    bool                bRefInputMode;

    EntryListsMap m_EntryLists;

    // Hack: RefInput control
    std::unique_ptr<Timer>  pTimer;

    std::unique_ptr<weld::ComboBox> m_xLbConnect1;
    std::unique_ptr<weld::ComboBox> m_xLbField1;
    std::unique_ptr<weld::ComboBox> m_xLbCond1;
    std::unique_ptr<weld::ComboBox> m_xEdVal1;
    std::unique_ptr<weld::ComboBox> m_xLbColor1;
    std::unique_ptr<weld::Button>   m_xBtnRemove1;

    std::unique_ptr<weld::ComboBox> m_xLbConnect2;
    std::unique_ptr<weld::ComboBox> m_xLbField2;
    std::unique_ptr<weld::ComboBox> m_xLbCond2;
    std::unique_ptr<weld::ComboBox> m_xEdVal2;
    std::unique_ptr<weld::ComboBox> m_xLbColor2;
    std::unique_ptr<weld::Button>   m_xBtnRemove2;

    std::unique_ptr<weld::ComboBox> m_xLbConnect3;
    std::unique_ptr<weld::ComboBox> m_xLbField3;
    std::unique_ptr<weld::ComboBox> m_xLbCond3;
    std::unique_ptr<weld::ComboBox> m_xEdVal3;
    std::unique_ptr<weld::ComboBox> m_xLbColor3;
    std::unique_ptr<weld::Button>   m_xBtnRemove3;

    std::unique_ptr<weld::ComboBox> m_xLbConnect4;
    std::unique_ptr<weld::ComboBox> m_xLbField4;
    std::unique_ptr<weld::ComboBox> m_xLbCond4;
    std::unique_ptr<weld::ComboBox> m_xEdVal4;
    std::unique_ptr<weld::ComboBox> m_xLbColor4;
    std::unique_ptr<weld::Button>   m_xBtnRemove4;

    std::unique_ptr<weld::Widget> m_xContents;
    std::unique_ptr<weld::ScrolledWindow> m_xScrollBar;
    std::unique_ptr<weld::Expander> m_xExpander;

    std::unique_ptr<weld::Button> m_xBtnClear;
    std::unique_ptr<weld::Button> m_xBtnOk;
    std::unique_ptr<weld::Button> m_xBtnCancel;

    std::unique_ptr<weld::CheckButton> m_xBtnCase;
    std::unique_ptr<weld::CheckButton> m_xBtnRegExp;
    std::unique_ptr<weld::CheckButton> m_xBtnHeader;
    std::unique_ptr<weld::CheckButton> m_xBtnUnique;
    std::unique_ptr<weld::CheckButton> m_xBtnCopyResult;
    std::unique_ptr<weld::ComboBox> m_xLbCopyArea;
    std::unique_ptr<formula::RefEdit> m_xEdCopyArea;
    std::unique_ptr<formula::RefButton> m_xRbCopyArea;
    std::unique_ptr<weld::CheckButton> m_xBtnDestPers;
    std::unique_ptr<weld::Label> m_xFtDbAreaLabel;
    std::unique_ptr<weld::Label> m_xFtDbArea;

private:
    void            Init            ( const SfxItemSet& rArgSet );
    void            FillFieldLists  ();
    void            UpdateValueList ( size_t nList );
    void            UpdateHdrInValueList( size_t nList );
    void            ClearValueList  ( size_t nList );
    void            UpdateColorList ( size_t nList );
    size_t          GetFieldSelPos  ( SCCOL nField );
    ScQueryItem*    GetOutputItem   ();
    void            SetValString    ( const OUString& rQueryStr,
                                      const ScQueryEntry::Item& rItem,
                                      OUString& rValStr );

    // Handler:
    DECL_LINK( LbSelectHdl,  weld::ComboBox&, void );
    DECL_LINK( ValModifyHdl, weld::ComboBox&, void );
    DECL_LINK( CheckBoxHdl,  weld::Toggleable&, void );
    DECL_LINK( BtnClearHdl,  weld::Button&, void );
    DECL_LINK( BtnRemoveHdl, weld::Button&, void );
    DECL_LINK( EndDlgHdl,    weld::Button&, void );
    DECL_LINK( ScrollHdl, weld::ScrolledWindow&, void );
    DECL_LINK( MoreExpandedHdl, weld::Expander&, void );

    // Hack: RefInput control
    DECL_LINK( TimeOutHdl, Timer*, void );
};

class ScSpecialFilterDlg : public ScAnyRefDlgController
{
public:
    ScSpecialFilterDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent,
                       const SfxItemSet& rArgSet);
    virtual ~ScSpecialFilterDlg() override;

    virtual void    SetReference( const ScRange& rRef, ScDocument& rDoc ) override;

    virtual bool    IsRefInputMode() const override;
    virtual void    SetActive() override;

    virtual void    Close() override;

private:
    const OUString aStrUndefined;

    std::unique_ptr<ScFilterOptionsMgr> pOptionsMgr;

    const sal_uInt16    nWhichQuery;
    const ScQueryParam  theQueryData;
    std::unique_ptr<ScQueryItem> pOutItem;
    ScViewData*         pViewData;
    ScDocument*         pDoc;

    bool                bRefInputMode;

    formula::RefEdit* m_pRefInputEdit;

    std::unique_ptr<weld::ComboBox> m_xLbFilterArea;
    std::unique_ptr<formula::RefEdit> m_xEdFilterArea;
    std::unique_ptr<formula::RefButton> m_xRbFilterArea;

    std::unique_ptr<weld::Expander> m_xExpander;
    std::unique_ptr<weld::CheckButton> m_xBtnCase;
    std::unique_ptr<weld::CheckButton> m_xBtnRegExp;
    std::unique_ptr<weld::CheckButton> m_xBtnHeader;
    std::unique_ptr<weld::CheckButton> m_xBtnUnique;
    std::unique_ptr<weld::CheckButton> m_xBtnCopyResult;
    std::unique_ptr<weld::ComboBox> m_xLbCopyArea;
    std::unique_ptr<formula::RefEdit> m_xEdCopyArea;
    std::unique_ptr<formula::RefButton> m_xRbCopyArea;
    std::unique_ptr<weld::CheckButton> m_xBtnDestPers;
    std::unique_ptr<weld::Label> m_xFtDbAreaLabel;
    std::unique_ptr<weld::Label> m_xFtDbArea;

    std::unique_ptr<weld::Button> m_xBtnOk;
    std::unique_ptr<weld::Button> m_xBtnCancel;

    std::unique_ptr<weld::Frame> m_xFilterFrame;
    std::unique_ptr<weld::Label> m_xFilterLabel;

private:
    void            Init( const SfxItemSet& rArgSet );
    ScQueryItem*    GetOutputItem( const ScQueryParam& rParam,
                                    const ScRange& rSource );

    // Handler
    DECL_LINK( FilterAreaSelHdl, weld::ComboBox&, void );
    DECL_LINK( FilterAreaModHdl, formula::RefEdit&, void );
    DECL_LINK( EndDlgHdl,  weld::Button&, void );

    // RefInput control
    DECL_LINK( RefInputEditHdl, formula::RefEdit&, void );
    DECL_LINK( RefInputButtonHdl, formula::RefButton&, void );
    void RefInputHdl();
};

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */