/src/libreoffice/sc/source/ui/dbgui/filtdlg.cxx
Line | Count | Source |
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 | | #include <sfx2/dispatch.hxx> |
21 | | #include <sal/log.hxx> |
22 | | |
23 | | #include <uiitems.hxx> |
24 | | #include <reffact.hxx> |
25 | | #include <viewdata.hxx> |
26 | | #include <document.hxx> |
27 | | #include <docsh.hxx> |
28 | | #include <scresid.hxx> |
29 | | #include <queryentry.hxx> |
30 | | |
31 | | #include <foptmgr.hxx> |
32 | | |
33 | | #include <globstr.hrc> |
34 | | #include <strings.hrc> |
35 | | |
36 | | #include <filtdlg.hxx> |
37 | | #include <svx/colorwindow.hxx> |
38 | | #include <vcl/svapp.hxx> |
39 | | #include <vcl/settings.hxx> |
40 | | #include <vcl/virdev.hxx> |
41 | | #include <vcl/weld/ComboBox.hxx> |
42 | | #include <vcl/weld/Expander.hxx> |
43 | | #include <vcl/weld/ScrolledWindow.hxx> |
44 | | #include <vcl/weld/Dialog.hxx> |
45 | | #include <vcl/weld/MessageDialog.hxx> |
46 | | #include <vcl/weld/WaitObject.hxx> |
47 | | #include <svl/numformat.hxx> |
48 | | #include <svl/sharedstringpool.hxx> |
49 | | |
50 | | #include <limits> |
51 | | |
52 | 0 | #define QUERY_ENTRY_COUNT 4 |
53 | 0 | #define INVALID_HEADER_POS std::numeric_limits<size_t>::max() |
54 | | |
55 | | ScFilterDlg::EntryList::EntryList() : |
56 | 0 | mnHeaderPos(INVALID_HEADER_POS) {} |
57 | | |
58 | | ScFilterDlg::ScFilterDlg(SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent, ScViewData& rData, |
59 | | const SfxItemSet& rArgSet) |
60 | 0 | : ScAnyRefDlgController(pB, pCW, pParent, |
61 | 0 | u"modules/scalc/ui/standardfilterdialog.ui"_ustr, u"StandardFilterDialog"_ustr) |
62 | 0 | , aStrUndefined(ScResId(SCSTR_UNDEFINED)) |
63 | 0 | , aStrNone(ScResId(SCSTR_NONE)) |
64 | 0 | , aStrEmpty(ScResId(SCSTR_FILTER_EMPTY)) |
65 | 0 | , aStrNotEmpty(ScResId(SCSTR_FILTER_NOTEMPTY)) |
66 | 0 | , aStrColumn(ScResId(SCSTR_COLUMN_LETTER)) |
67 | 0 | , aStrFontColor(ScResId(SCSTR_FILTER_FONT_COLOR_COND)) |
68 | 0 | , aStrBackgroundColor(ScResId(SCSTR_FILTER_BACKGROUND_COLOR_COND)) |
69 | 0 | , nWhichQuery(rArgSet.GetPool()->GetWhichIDFromSlotID(SID_QUERY)) |
70 | 0 | , theQueryData(static_cast<const ScQueryItem&>(rArgSet.Get(nWhichQuery)).GetQueryData()) |
71 | 0 | , rViewData(rData) |
72 | 0 | , rDoc(rViewData.GetDocument()) |
73 | 0 | , nSrcTab(rViewData.CurrentTabForData()) |
74 | 0 | , bRefInputMode(false) |
75 | 0 | , m_xLbConnect1(m_xBuilder->weld_combo_box(u"connect1"_ustr)) |
76 | 0 | , m_xLbField1(m_xBuilder->weld_combo_box(u"field1"_ustr)) |
77 | 0 | , m_xLbCond1(m_xBuilder->weld_combo_box(u"cond1"_ustr)) |
78 | 0 | , m_xEdVal1(m_xBuilder->weld_combo_box(u"val1"_ustr)) |
79 | 0 | , m_xLbColor1(m_xBuilder->weld_combo_box(u"color1"_ustr)) |
80 | 0 | , m_xBtnRemove1(m_xBuilder->weld_button(u"remove1"_ustr)) |
81 | 0 | , m_xLbConnect2(m_xBuilder->weld_combo_box(u"connect2"_ustr)) |
82 | 0 | , m_xLbField2(m_xBuilder->weld_combo_box(u"field2"_ustr)) |
83 | 0 | , m_xLbCond2(m_xBuilder->weld_combo_box(u"cond2"_ustr)) |
84 | 0 | , m_xEdVal2(m_xBuilder->weld_combo_box(u"val2"_ustr)) |
85 | 0 | , m_xLbColor2(m_xBuilder->weld_combo_box(u"color2"_ustr)) |
86 | 0 | , m_xBtnRemove2(m_xBuilder->weld_button(u"remove2"_ustr)) |
87 | 0 | , m_xLbConnect3(m_xBuilder->weld_combo_box(u"connect3"_ustr)) |
88 | 0 | , m_xLbField3(m_xBuilder->weld_combo_box(u"field3"_ustr)) |
89 | 0 | , m_xLbCond3(m_xBuilder->weld_combo_box(u"cond3"_ustr)) |
90 | 0 | , m_xEdVal3(m_xBuilder->weld_combo_box(u"val3"_ustr)) |
91 | 0 | , m_xLbColor3(m_xBuilder->weld_combo_box(u"color3"_ustr)) |
92 | 0 | , m_xBtnRemove3(m_xBuilder->weld_button(u"remove3"_ustr)) |
93 | 0 | , m_xLbConnect4(m_xBuilder->weld_combo_box(u"connect4"_ustr)) |
94 | 0 | , m_xLbField4(m_xBuilder->weld_combo_box(u"field4"_ustr)) |
95 | 0 | , m_xLbCond4(m_xBuilder->weld_combo_box(u"cond4"_ustr)) |
96 | 0 | , m_xEdVal4(m_xBuilder->weld_combo_box(u"val4"_ustr)) |
97 | 0 | , m_xLbColor4(m_xBuilder->weld_combo_box(u"color4"_ustr)) |
98 | 0 | , m_xBtnRemove4(m_xBuilder->weld_button(u"remove4"_ustr)) |
99 | 0 | , m_xContents(m_xBuilder->weld_widget(u"grid"_ustr)) |
100 | 0 | , m_xScrollBar(m_xBuilder->weld_scrolled_window(u"scrollbar"_ustr, true)) |
101 | 0 | , m_xExpander(m_xBuilder->weld_expander(u"more"_ustr)) |
102 | 0 | , m_xBtnClear(m_xBuilder->weld_button(u"clear"_ustr)) |
103 | 0 | , m_xBtnOk(m_xBuilder->weld_button(u"ok"_ustr)) |
104 | 0 | , m_xBtnCancel(m_xBuilder->weld_button(u"cancel"_ustr)) |
105 | 0 | , m_xBtnCase(m_xBuilder->weld_check_button(u"case"_ustr)) |
106 | 0 | , m_xBtnRegExp(m_xBuilder->weld_check_button(u"regexp"_ustr)) |
107 | 0 | , m_xBtnHeader(m_xBuilder->weld_check_button(u"header"_ustr)) |
108 | 0 | , m_xBtnUnique(m_xBuilder->weld_check_button(u"unique"_ustr)) |
109 | 0 | , m_xBtnCopyResult(m_xBuilder->weld_check_button(u"copyresult"_ustr)) |
110 | 0 | , m_xLbCopyArea(m_xBuilder->weld_combo_box(u"lbcopyarea"_ustr)) |
111 | 0 | , m_xEdCopyArea(new formula::RefEdit(m_xBuilder->weld_entry(u"edcopyarea"_ustr))) |
112 | 0 | , m_xRbCopyArea(new formula::RefButton(m_xBuilder->weld_button(u"rbcopyarea"_ustr))) |
113 | 0 | , m_xBtnDestPers(m_xBuilder->weld_check_button(u"destpers"_ustr)) |
114 | 0 | , m_xFtDbAreaLabel(m_xBuilder->weld_label(u"dbarealabel"_ustr)) |
115 | 0 | , m_xFtDbArea(m_xBuilder->weld_label(u"dbarea"_ustr)) |
116 | 0 | { |
117 | 0 | m_xExpander->connect_expanded(LINK(this, ScFilterDlg, MoreExpandedHdl)); |
118 | 0 | m_xEdCopyArea->SetReferences(this, m_xFtDbAreaLabel.get()); |
119 | 0 | m_xRbCopyArea->SetReferences(this, m_xEdCopyArea.get()); |
120 | |
|
121 | 0 | assert(m_xLbCond1->find_text(aStrFontColor) != -1); |
122 | 0 | assert(m_xLbCond1->find_text(aStrBackgroundColor) != -1); |
123 | |
|
124 | 0 | Init(); |
125 | | |
126 | | // Hack: RefInput control |
127 | 0 | pTimer.reset( new Timer("ScFilterTimer") ); |
128 | 0 | pTimer->SetTimeout( 50 ); // Wait 50ms |
129 | 0 | pTimer->SetInvokeHandler( LINK( this, ScFilterDlg, TimeOutHdl ) ); |
130 | 0 | } |
131 | | |
132 | | ScFilterDlg::~ScFilterDlg() |
133 | 0 | { |
134 | 0 | pOptionsMgr.reset(); |
135 | 0 | pOutItem.reset(); |
136 | | |
137 | | // Hack: RefInput control |
138 | 0 | pTimer->Stop(); |
139 | 0 | pTimer.reset(); |
140 | 0 | } |
141 | | |
142 | | namespace { |
143 | | ScopedVclPtr<VirtualDevice> lcl_getColorImage(const Color &rColor) |
144 | 0 | { |
145 | 0 | const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); |
146 | 0 | Size aImageSize(rStyleSettings.GetListBoxPreviewDefaultPixelSize()); |
147 | |
|
148 | 0 | VclPtrInstance<VirtualDevice> xDevice; |
149 | 0 | xDevice->SetOutputSize(aImageSize); |
150 | 0 | const tools::Rectangle aRect(Point(0, 0), aImageSize); |
151 | 0 | if (rColor == COL_NONE_COLOR) |
152 | 0 | { |
153 | 0 | const Color aW(COL_WHITE); |
154 | 0 | const Color aG(0xef, 0xef, 0xef); |
155 | 0 | xDevice->DrawCheckered(aRect.TopLeft(), aRect.GetSize(), 8, aW, aG); |
156 | 0 | xDevice->SetFillColor(); |
157 | 0 | } |
158 | 0 | else |
159 | 0 | { |
160 | 0 | xDevice->SetFillColor(rColor); |
161 | 0 | } |
162 | |
|
163 | 0 | xDevice->DrawRect(aRect); |
164 | |
|
165 | 0 | return xDevice; |
166 | 0 | } |
167 | | } |
168 | | |
169 | | void ScFilterDlg::Init() |
170 | 0 | { |
171 | 0 | m_xLbField1->append_text(u"0000000000"_ustr); |
172 | 0 | m_xLbField1->set_active(0); |
173 | 0 | auto nPrefWidth = m_xLbField1->get_preferred_size().Width(); |
174 | 0 | m_xLbField1->clear(); |
175 | |
|
176 | 0 | m_xLbField1->set_size_request(nPrefWidth, -1); |
177 | 0 | m_xLbField2->set_size_request(nPrefWidth, -1); |
178 | 0 | m_xLbField3->set_size_request(nPrefWidth, -1); |
179 | 0 | m_xLbField4->set_size_request(nPrefWidth, -1); |
180 | |
|
181 | 0 | m_xBtnClear->connect_clicked ( LINK( this, ScFilterDlg, BtnClearHdl ) ); |
182 | 0 | m_xBtnOk->connect_clicked ( LINK( this, ScFilterDlg, EndDlgHdl ) ); |
183 | 0 | m_xBtnCancel->connect_clicked ( LINK( this, ScFilterDlg, EndDlgHdl ) ); |
184 | 0 | m_xBtnHeader->connect_toggled ( LINK( this, ScFilterDlg, CheckBoxHdl ) ); |
185 | 0 | m_xBtnCase->connect_toggled ( LINK( this, ScFilterDlg, CheckBoxHdl ) ); |
186 | |
|
187 | 0 | m_xLbField1->connect_changed ( LINK( this, ScFilterDlg, LbSelectHdl ) ); |
188 | 0 | m_xLbField2->connect_changed ( LINK( this, ScFilterDlg, LbSelectHdl ) ); |
189 | 0 | m_xLbField3->connect_changed ( LINK( this, ScFilterDlg, LbSelectHdl ) ); |
190 | 0 | m_xLbField4->connect_changed ( LINK( this, ScFilterDlg, LbSelectHdl ) ); |
191 | 0 | m_xLbConnect1->connect_changed( LINK( this, ScFilterDlg, LbSelectHdl ) ); |
192 | 0 | m_xLbConnect2->connect_changed( LINK( this, ScFilterDlg, LbSelectHdl ) ); |
193 | 0 | m_xLbConnect3->connect_changed( LINK( this, ScFilterDlg, LbSelectHdl ) ); |
194 | 0 | m_xLbConnect4->connect_changed( LINK( this, ScFilterDlg, LbSelectHdl ) ); |
195 | |
|
196 | 0 | m_xLbCond1->connect_changed( LINK( this, ScFilterDlg, LbSelectHdl ) ); |
197 | 0 | m_xLbCond2->connect_changed( LINK( this, ScFilterDlg, LbSelectHdl ) ); |
198 | 0 | m_xLbCond3->connect_changed( LINK( this, ScFilterDlg, LbSelectHdl ) ); |
199 | 0 | m_xLbCond4->connect_changed( LINK( this, ScFilterDlg, LbSelectHdl ) ); |
200 | |
|
201 | 0 | m_xLbColor1->connect_changed( LINK( this, ScFilterDlg, LbSelectHdl ) ); |
202 | 0 | m_xLbColor2->connect_changed( LINK( this, ScFilterDlg, LbSelectHdl ) ); |
203 | 0 | m_xLbColor3->connect_changed( LINK( this, ScFilterDlg, LbSelectHdl ) ); |
204 | 0 | m_xLbColor4->connect_changed( LINK( this, ScFilterDlg, LbSelectHdl ) ); |
205 | |
|
206 | 0 | m_xBtnRemove1->connect_clicked( LINK( this, ScFilterDlg, BtnRemoveHdl ) ); |
207 | 0 | m_xBtnRemove2->connect_clicked( LINK( this, ScFilterDlg, BtnRemoveHdl ) ); |
208 | 0 | m_xBtnRemove3->connect_clicked( LINK( this, ScFilterDlg, BtnRemoveHdl ) ); |
209 | 0 | m_xBtnRemove4->connect_clicked( LINK( this, ScFilterDlg, BtnRemoveHdl ) ); |
210 | | |
211 | | // for easier access: |
212 | 0 | maFieldLbArr.reserve(QUERY_ENTRY_COUNT); |
213 | 0 | maFieldLbArr.push_back(m_xLbField1.get()); |
214 | 0 | maFieldLbArr.push_back(m_xLbField2.get()); |
215 | 0 | maFieldLbArr.push_back(m_xLbField3.get()); |
216 | 0 | maFieldLbArr.push_back(m_xLbField4.get()); |
217 | 0 | maValueEdArr.reserve(QUERY_ENTRY_COUNT); |
218 | 0 | maValueEdArr.push_back(m_xEdVal1.get()); |
219 | 0 | maValueEdArr.push_back(m_xEdVal2.get()); |
220 | 0 | maValueEdArr.push_back(m_xEdVal3.get()); |
221 | 0 | maValueEdArr.push_back(m_xEdVal4.get()); |
222 | 0 | maCondLbArr.reserve(QUERY_ENTRY_COUNT); |
223 | 0 | maCondLbArr.push_back(m_xLbCond1.get()); |
224 | 0 | maCondLbArr.push_back(m_xLbCond2.get()); |
225 | 0 | maCondLbArr.push_back(m_xLbCond3.get()); |
226 | 0 | maCondLbArr.push_back(m_xLbCond4.get()); |
227 | 0 | maConnLbArr.reserve(QUERY_ENTRY_COUNT); |
228 | 0 | maConnLbArr.push_back(m_xLbConnect1.get()); |
229 | 0 | maConnLbArr.push_back(m_xLbConnect2.get()); |
230 | 0 | maConnLbArr.push_back(m_xLbConnect3.get()); |
231 | 0 | maConnLbArr.push_back(m_xLbConnect4.get()); |
232 | 0 | maColorLbArr.reserve(QUERY_ENTRY_COUNT); |
233 | 0 | maColorLbArr.push_back(m_xLbColor1.get()); |
234 | 0 | maColorLbArr.push_back(m_xLbColor2.get()); |
235 | 0 | maColorLbArr.push_back(m_xLbColor3.get()); |
236 | 0 | maColorLbArr.push_back(m_xLbColor4.get()); |
237 | 0 | maRemoveBtnArr.reserve(QUERY_ENTRY_COUNT); |
238 | 0 | maRemoveBtnArr.push_back(m_xBtnRemove1.get()); |
239 | 0 | maRemoveBtnArr.push_back(m_xBtnRemove2.get()); |
240 | 0 | maRemoveBtnArr.push_back(m_xBtnRemove3.get()); |
241 | 0 | maRemoveBtnArr.push_back(m_xBtnRemove4.get()); |
242 | | |
243 | | // Option initialization: |
244 | 0 | pOptionsMgr.reset( new ScFilterOptionsMgr( |
245 | 0 | rViewData, |
246 | 0 | theQueryData, |
247 | 0 | m_xBtnCase.get(), |
248 | 0 | m_xBtnRegExp.get(), |
249 | 0 | m_xBtnHeader.get(), |
250 | 0 | m_xBtnUnique.get(), |
251 | 0 | m_xBtnCopyResult.get(), |
252 | 0 | m_xBtnDestPers.get(), |
253 | 0 | m_xLbCopyArea.get(), |
254 | 0 | m_xEdCopyArea.get(), |
255 | 0 | m_xRbCopyArea.get(), |
256 | 0 | m_xFtDbAreaLabel.get(), |
257 | 0 | m_xFtDbArea.get(), |
258 | 0 | aStrUndefined ) ); |
259 | | // Read in field lists and select entries |
260 | |
|
261 | 0 | FillFieldLists(); |
262 | |
|
263 | 0 | for (size_t i = 0; i < QUERY_ENTRY_COUNT; ++i) |
264 | 0 | { |
265 | 0 | OUString aValStr; |
266 | 0 | size_t nCondPos = 0; |
267 | 0 | size_t nFieldSelPos = 0; |
268 | |
|
269 | 0 | maColorLbArr[i]->set_visible(false); |
270 | |
|
271 | 0 | ScQueryEntry& rEntry = theQueryData.GetEntry(i); |
272 | 0 | if ( rEntry.bDoQuery ) |
273 | 0 | { |
274 | 0 | nCondPos = static_cast<size_t>(rEntry.eOp); |
275 | 0 | nFieldSelPos = GetFieldSelPos( static_cast<SCCOL>(rEntry.nField) ); |
276 | 0 | if (rEntry.IsQueryByEmpty()) |
277 | 0 | { |
278 | 0 | aValStr = aStrEmpty; |
279 | 0 | maCondLbArr[i]->set_sensitive(false); |
280 | 0 | } |
281 | 0 | else if (rEntry.IsQueryByNonEmpty()) |
282 | 0 | { |
283 | 0 | aValStr = aStrNotEmpty; |
284 | 0 | maCondLbArr[i]->set_sensitive(false); |
285 | 0 | } |
286 | 0 | else if (rEntry.IsQueryByTextColor() || rEntry.IsQueryByBackgroundColor()) |
287 | 0 | { |
288 | 0 | nCondPos = maCondLbArr[i]->find_text( |
289 | 0 | rEntry.IsQueryByTextColor() ? aStrFontColor : aStrBackgroundColor); |
290 | 0 | maValueEdArr[i]->set_visible(false); |
291 | 0 | maColorLbArr[i]->set_visible(true); |
292 | 0 | maColorLbArr[i]->set_sensitive(true); |
293 | 0 | } |
294 | 0 | else |
295 | 0 | { |
296 | 0 | const ScQueryEntry::Item& rItem = rEntry.GetQueryItem(); |
297 | 0 | OUString aQueryStr = rItem.maString.getString(); |
298 | 0 | SetValString(aQueryStr, rItem, aValStr); |
299 | 0 | } |
300 | 0 | } |
301 | 0 | else if ( i == 0 ) |
302 | 0 | { |
303 | 0 | nFieldSelPos = GetFieldSelPos(rViewData.GetCurX()); |
304 | 0 | rEntry.nField = nFieldSelPos ? (theQueryData.nCol1 + |
305 | 0 | static_cast<SCCOL>(nFieldSelPos) - 1) : static_cast<SCCOL>(0); |
306 | 0 | rEntry.bDoQuery=true; |
307 | 0 | if (maRefreshExceptQuery.size() < i + 1) |
308 | 0 | maRefreshExceptQuery.resize(i + 1, false); |
309 | 0 | maRefreshExceptQuery[i] = true; |
310 | |
|
311 | 0 | } |
312 | 0 | maFieldLbArr[i]->set_active( nFieldSelPos ); |
313 | 0 | maCondLbArr [i]->set_active( nCondPos ); |
314 | 0 | maValueEdArr[i]->set_entry_text( aValStr ); |
315 | 0 | maValueEdArr[i]->set_entry_completion(false); |
316 | 0 | maValueEdArr[i]->connect_changed( LINK( this, ScFilterDlg, ValModifyHdl ) ); |
317 | 0 | UpdateValueList(i+1); |
318 | 0 | UpdateColorList(i+1); |
319 | 0 | } |
320 | |
|
321 | 0 | m_xScrollBar->connect_vadjustment_value_changed( LINK( this, ScFilterDlg, ScrollHdl ) ); |
322 | 0 | m_xScrollBar->vadjustment_configure(0, 8, 1, 3, 4); |
323 | 0 | Size aSize(m_xContents->get_preferred_size()); |
324 | 0 | m_xContents->set_size_request(aSize.Width(), aSize.Height()); |
325 | |
|
326 | 0 | m_xLbConnect1->hide(); |
327 | | // Disable/Enable Logic: |
328 | |
|
329 | 0 | (m_xLbField1->get_active() != 0) |
330 | 0 | && (m_xLbField2->get_active() != 0) |
331 | 0 | ? m_xLbConnect2->set_active( static_cast<sal_uInt16>(theQueryData.GetEntry(1).eConnect) ) |
332 | 0 | : m_xLbConnect2->set_active(-1); |
333 | |
|
334 | 0 | (m_xLbField2->get_active() != 0) |
335 | 0 | && (m_xLbField3->get_active() != 0) |
336 | 0 | ? m_xLbConnect3->set_active( static_cast<sal_uInt16>(theQueryData.GetEntry(2).eConnect) ) |
337 | 0 | : m_xLbConnect3->set_active(-1); |
338 | |
|
339 | 0 | (m_xLbField3->get_active() != 0) |
340 | 0 | && (m_xLbField4->get_active() != 0) |
341 | 0 | ? m_xLbConnect4->set_active( static_cast<sal_uInt16>(theQueryData.GetEntry(3).eConnect) ) |
342 | 0 | : m_xLbConnect4->set_active(-1); |
343 | 0 | if ( m_xLbField1->get_active() == 0 ) |
344 | 0 | { |
345 | 0 | m_xLbConnect2->set_sensitive(false); |
346 | 0 | m_xLbField2->set_sensitive(false); |
347 | 0 | m_xLbCond2->set_sensitive(false); |
348 | 0 | m_xEdVal2->set_sensitive(false); |
349 | 0 | m_xLbColor2->set_sensitive(false); |
350 | 0 | m_xBtnRemove2->set_sensitive(false); |
351 | 0 | } |
352 | 0 | else if ( m_xLbConnect2->get_active() == -1 ) |
353 | 0 | { |
354 | 0 | m_xLbField2->set_sensitive(false); |
355 | 0 | m_xLbCond2->set_sensitive(false); |
356 | 0 | m_xEdVal2->set_sensitive(false); |
357 | 0 | m_xLbColor2->set_sensitive(false); |
358 | 0 | m_xBtnRemove2->set_sensitive(false); |
359 | 0 | } |
360 | |
|
361 | 0 | if ( m_xLbField2->get_active() == 0 ) |
362 | 0 | { |
363 | 0 | m_xLbConnect3->set_sensitive(false); |
364 | 0 | m_xLbField3->set_sensitive(false); |
365 | 0 | m_xLbCond3->set_sensitive(false); |
366 | 0 | m_xEdVal3->set_sensitive(false); |
367 | 0 | m_xLbColor3->set_sensitive(false); |
368 | 0 | m_xBtnRemove3->set_sensitive(false); |
369 | 0 | } |
370 | 0 | else if ( m_xLbConnect3->get_active() == -1 ) |
371 | 0 | { |
372 | 0 | m_xLbField3->set_sensitive(false); |
373 | 0 | m_xLbCond3->set_sensitive(false); |
374 | 0 | m_xEdVal3->set_sensitive(false); |
375 | 0 | m_xLbColor3->set_sensitive(false); |
376 | 0 | m_xBtnRemove3->set_sensitive(false); |
377 | 0 | } |
378 | 0 | if ( m_xLbField3->get_active() == 0 ) |
379 | 0 | { |
380 | 0 | m_xLbConnect4->set_sensitive(false); |
381 | 0 | m_xLbField4->set_sensitive(false); |
382 | 0 | m_xLbCond4->set_sensitive(false); |
383 | 0 | m_xEdVal4->set_sensitive(false); |
384 | 0 | m_xLbColor4->set_sensitive(false); |
385 | 0 | m_xBtnRemove4->set_sensitive(false); |
386 | 0 | } |
387 | 0 | else if ( m_xLbConnect4->get_active() == -1 ) |
388 | 0 | { |
389 | 0 | m_xLbField4->set_sensitive(false); |
390 | 0 | m_xLbCond4->set_sensitive(false); |
391 | 0 | m_xEdVal4->set_sensitive(false); |
392 | 0 | m_xLbColor4->set_sensitive(false); |
393 | 0 | m_xBtnRemove4->set_sensitive(false); |
394 | 0 | } |
395 | |
|
396 | 0 | m_xEdVal1->set_entry_width_chars(10); |
397 | 0 | m_xEdVal2->set_entry_width_chars(10); |
398 | 0 | m_xEdVal3->set_entry_width_chars(10); |
399 | 0 | m_xEdVal4->set_entry_width_chars(10); |
400 | |
|
401 | 0 | if (rDoc.GetChangeTrack() != nullptr) |
402 | 0 | m_xBtnCopyResult->set_sensitive(false); |
403 | 0 | } |
404 | | |
405 | | void ScFilterDlg::Close() |
406 | 0 | { |
407 | 0 | rViewData.GetDocShell()->CancelAutoDBRange(); |
408 | |
|
409 | 0 | DoClose( ScFilterDlgWrapper::GetChildWindowId() ); |
410 | 0 | } |
411 | | |
412 | | // Mouse-selected cell area becomes the new selection and is shown in the |
413 | | // reference text box |
414 | | |
415 | | void ScFilterDlg::SetReference( const ScRange& rRef, ScDocument& rDocP ) |
416 | 0 | { |
417 | 0 | if ( bRefInputMode ) // Only possible if in reference edit mode |
418 | 0 | { |
419 | 0 | if ( rRef.aStart != rRef.aEnd ) |
420 | 0 | RefInputStart( m_xEdCopyArea.get() ); |
421 | 0 | OUString aRefStr(rRef.aStart.Format(ScRefFlags::ADDR_ABS_3D, &rDocP, rDocP.GetAddressConvention())); |
422 | 0 | m_xEdCopyArea->SetRefString( aRefStr ); |
423 | 0 | } |
424 | 0 | } |
425 | | |
426 | | void ScFilterDlg::SetActive() |
427 | 0 | { |
428 | 0 | if ( bRefInputMode ) |
429 | 0 | { |
430 | 0 | m_xEdCopyArea->GrabFocus(); |
431 | 0 | m_xEdCopyArea->GetModifyHdl().Call( *m_xEdCopyArea ); |
432 | 0 | } |
433 | 0 | else |
434 | 0 | m_xDialog->grab_focus(); |
435 | |
|
436 | 0 | RefInputDone(); |
437 | 0 | } |
438 | | |
439 | | void ScFilterDlg::FillFieldLists() |
440 | 0 | { |
441 | 0 | m_xLbField1->freeze(); |
442 | 0 | m_xLbField2->freeze(); |
443 | 0 | m_xLbField3->freeze(); |
444 | 0 | m_xLbField4->freeze(); |
445 | |
|
446 | 0 | m_xLbField1->clear(); |
447 | 0 | m_xLbField2->clear(); |
448 | 0 | m_xLbField3->clear(); |
449 | 0 | m_xLbField4->clear(); |
450 | 0 | m_xLbField1->append_text( aStrNone ); |
451 | 0 | m_xLbField2->append_text( aStrNone ); |
452 | 0 | m_xLbField3->append_text( aStrNone ); |
453 | 0 | m_xLbField4->append_text( aStrNone ); |
454 | |
|
455 | 0 | OUString aFieldName; |
456 | 0 | SCTAB nTab = nSrcTab; |
457 | 0 | SCCOL nFirstCol = theQueryData.nCol1; |
458 | 0 | SCROW nFirstRow = theQueryData.nRow1; |
459 | 0 | SCCOL nMaxCol = theQueryData.nCol2; |
460 | 0 | SCCOL col = 0; |
461 | |
|
462 | 0 | for ( col=nFirstCol; col<=nMaxCol; col++ ) |
463 | 0 | { |
464 | 0 | aFieldName = rDoc.GetString(col, nFirstRow, nTab); |
465 | 0 | if (!m_xBtnHeader->get_active() || aFieldName.isEmpty()) |
466 | 0 | { |
467 | 0 | aFieldName = ScGlobal::ReplaceOrAppend( aStrColumn, u"%1", ScColToAlpha( col )); |
468 | 0 | } |
469 | 0 | m_xLbField1->append_text( aFieldName ); |
470 | 0 | m_xLbField2->append_text( aFieldName ); |
471 | 0 | m_xLbField3->append_text( aFieldName ); |
472 | 0 | m_xLbField4->append_text( aFieldName ); |
473 | 0 | } |
474 | |
|
475 | 0 | m_xLbField4->thaw(); |
476 | 0 | m_xLbField3->thaw(); |
477 | 0 | m_xLbField2->thaw(); |
478 | 0 | m_xLbField1->thaw(); |
479 | 0 | } |
480 | | |
481 | | void ScFilterDlg::UpdateValueList( size_t nList ) |
482 | 0 | { |
483 | 0 | bool bCaseSens = m_xBtnCase->get_active(); |
484 | |
|
485 | 0 | if (nList > 0 && nList <= QUERY_ENTRY_COUNT) |
486 | 0 | { |
487 | 0 | weld::ComboBox* pValList = maValueEdArr[nList-1]; |
488 | 0 | const sal_Int32 nFieldSelPos = maFieldLbArr[nList-1]->get_active(); |
489 | 0 | OUString aCurValue = pValList->get_active_text(); |
490 | |
|
491 | 0 | std::unique_ptr<weld::WaitObject> xWaiter; |
492 | 0 | std::vector<weld::ComboBoxEntry> aEntries; |
493 | 0 | aEntries.emplace_back(aStrNotEmpty); |
494 | 0 | aEntries.emplace_back(aStrEmpty); |
495 | |
|
496 | 0 | if (nFieldSelPos) |
497 | 0 | { |
498 | 0 | xWaiter.reset(new weld::WaitObject(m_xDialog.get())); // even if only the list box has content |
499 | 0 | SCCOL nColumn = theQueryData.nCol1 + static_cast<SCCOL>(nFieldSelPos) - 1; |
500 | 0 | EntryList* pList = nullptr; |
501 | 0 | if (!m_EntryLists.count(nColumn)) |
502 | 0 | { |
503 | 0 | size_t nOffset = GetSliderPos(); |
504 | 0 | SCTAB nTab = nSrcTab; |
505 | 0 | SCROW nFirstRow = theQueryData.nRow1; |
506 | 0 | SCROW nLastRow = theQueryData.nRow2; |
507 | 0 | if (maHasDates.size() < nOffset+nList) |
508 | 0 | maHasDates.resize(nOffset+nList, false); |
509 | 0 | maHasDates[nOffset+nList-1] = false; |
510 | | |
511 | | // first without the first line |
512 | 0 | std::pair<EntryListsMap::iterator, bool> r = |
513 | 0 | m_EntryLists.insert(std::make_pair(nColumn, std::make_unique<EntryList>())); |
514 | 0 | if (!r.second) |
515 | | // insertion failed. |
516 | 0 | return; |
517 | | |
518 | 0 | pList = r.first->second.get(); |
519 | 0 | rDoc.GetFilterEntriesArea( |
520 | 0 | nColumn, nFirstRow+1, nLastRow, |
521 | 0 | nTab, bCaseSens, pList->maFilterEntries); |
522 | 0 | maHasDates[nOffset+nList-1] = pList->maFilterEntries.mbHasDates; |
523 | | |
524 | | // Entry for the first line |
525 | | //! Entry (pHdrEntry) doesn't generate collection? |
526 | |
|
527 | 0 | pList->mnHeaderPos = INVALID_HEADER_POS; |
528 | 0 | ScFilterEntries aHdrColl; |
529 | 0 | rDoc.GetFilterEntriesArea( |
530 | 0 | nColumn, nFirstRow, nFirstRow, nTab, true, aHdrColl ); |
531 | 0 | if (!aHdrColl.empty()) |
532 | 0 | { |
533 | | // See if the header value is already in the list. |
534 | 0 | std::vector<ScTypedStrData>::iterator itBeg = pList->maFilterEntries.begin(), itEnd = pList->maFilterEntries.end(); |
535 | 0 | if (std::none_of(itBeg, itEnd, FindTypedStrData(aHdrColl.front(), bCaseSens))) |
536 | 0 | { |
537 | | // Not in the list. Insert it. |
538 | 0 | pList->maFilterEntries.push_back(aHdrColl.front()); |
539 | 0 | if (bCaseSens) |
540 | 0 | std::sort(pList->maFilterEntries.begin(), pList->maFilterEntries.end(), ScTypedStrData::LessCaseSensitive()); |
541 | 0 | else |
542 | 0 | std::sort(pList->maFilterEntries.begin(), pList->maFilterEntries.end(), ScTypedStrData::LessCaseInsensitive()); |
543 | | |
544 | | // Record its position. |
545 | 0 | itBeg = pList->maFilterEntries.begin(); |
546 | 0 | itEnd = pList->maFilterEntries.end(); |
547 | 0 | auto it = std::find_if(itBeg, itEnd, FindTypedStrData(aHdrColl.front(), bCaseSens)); |
548 | 0 | pList->mnHeaderPos = std::distance(itBeg, it); |
549 | 0 | } |
550 | 0 | } |
551 | 0 | } |
552 | 0 | else |
553 | 0 | pList = m_EntryLists[nColumn].get(); |
554 | | |
555 | 0 | assert(pList); |
556 | |
|
557 | 0 | for (const auto& rEntry : pList->maFilterEntries) |
558 | 0 | aEntries.emplace_back(rEntry.GetString()); |
559 | 0 | } |
560 | 0 | pValList->insert_vector(aEntries, false); |
561 | 0 | pValList->set_entry_text(aCurValue); |
562 | 0 | } |
563 | | |
564 | 0 | UpdateHdrInValueList( nList ); |
565 | 0 | } |
566 | | |
567 | | void ScFilterDlg::UpdateHdrInValueList( size_t nList ) |
568 | 0 | { |
569 | | //! GetText / SetText ?? |
570 | |
|
571 | 0 | if (nList == 0 || nList > QUERY_ENTRY_COUNT) |
572 | 0 | return; |
573 | | |
574 | 0 | size_t nFieldSelPos = maFieldLbArr[nList-1]->get_active(); |
575 | 0 | if (!nFieldSelPos) |
576 | 0 | return; |
577 | | |
578 | 0 | SCCOL nColumn = theQueryData.nCol1 + static_cast<SCCOL>(nFieldSelPos) - 1; |
579 | 0 | if (!m_EntryLists.count(nColumn)) |
580 | 0 | { |
581 | 0 | OSL_FAIL("column not yet initialized"); |
582 | 0 | return; |
583 | 0 | } |
584 | | |
585 | 0 | size_t const nPos = m_EntryLists[nColumn]->mnHeaderPos; |
586 | 0 | if (nPos == INVALID_HEADER_POS) |
587 | 0 | return; |
588 | | |
589 | 0 | weld::ComboBox* pValList = maValueEdArr[nList-1]; |
590 | 0 | int nListPos = nPos + 2; // for "empty" and "non-empty" |
591 | |
|
592 | 0 | const ScTypedStrData& rHdrEntry = m_EntryLists[nColumn]->maFilterEntries.maStrData[nPos]; |
593 | |
|
594 | 0 | const OUString& aHdrStr = rHdrEntry.GetString(); |
595 | 0 | bool bWasThere = nListPos < pValList->get_count() && aHdrStr == pValList->get_text(nListPos); |
596 | 0 | bool bInclude = !m_xBtnHeader->get_active(); |
597 | |
|
598 | 0 | if (bInclude) // Include entry |
599 | 0 | { |
600 | 0 | if (!bWasThere) |
601 | 0 | pValList->insert_text(nListPos, aHdrStr); |
602 | 0 | } |
603 | 0 | else // Omit entry |
604 | 0 | { |
605 | 0 | if (bWasThere) |
606 | 0 | pValList->remove(nListPos); |
607 | 0 | } |
608 | 0 | } |
609 | | |
610 | | void ScFilterDlg::ClearValueList( size_t nList ) |
611 | 0 | { |
612 | 0 | if (nList > 0 && nList <= QUERY_ENTRY_COUNT) |
613 | 0 | { |
614 | 0 | weld::ComboBox* pValList = maValueEdArr[nList-1]; |
615 | 0 | pValList->clear(); |
616 | 0 | pValList->append_text( aStrNotEmpty ); |
617 | 0 | pValList->append_text( aStrEmpty ); |
618 | 0 | pValList->set_entry_text( OUString() ); |
619 | 0 | } |
620 | 0 | } |
621 | | |
622 | | void ScFilterDlg::UpdateColorList(size_t nList) |
623 | 0 | { |
624 | 0 | if (nList <= 0 || nList > QUERY_ENTRY_COUNT) |
625 | 0 | return; |
626 | | |
627 | 0 | size_t nPos = nList - 1; |
628 | 0 | ScQueryEntry& rEntry = theQueryData.GetEntry(nPos); |
629 | 0 | const sal_Int32 nFieldSelPos = maFieldLbArr[nPos]->get_active(); |
630 | 0 | if (!nFieldSelPos) |
631 | 0 | return; |
632 | | |
633 | 0 | SCCOL nColumn = theQueryData.nCol1 + static_cast<SCCOL>(nFieldSelPos) - 1; |
634 | 0 | EntryList* pList = m_EntryLists[nColumn].get(); |
635 | 0 | if (!pList) |
636 | 0 | return; |
637 | | |
638 | 0 | std::set<Color> aColors; |
639 | 0 | OUString sSelectedCondition = maCondLbArr[nPos]->get_active_text(); |
640 | 0 | if (sSelectedCondition == aStrFontColor) |
641 | 0 | aColors = pList->maFilterEntries.getTextColors(); |
642 | 0 | else if (sSelectedCondition == aStrBackgroundColor) |
643 | 0 | aColors = pList->maFilterEntries.getBackgroundColors(); |
644 | 0 | else |
645 | 0 | return; |
646 | | |
647 | 0 | maColorLbArr[nPos]->clear(); |
648 | 0 | for (const auto& rColor : aColors) |
649 | 0 | { |
650 | 0 | OUString sId = rColor.AsRGBHexString(); |
651 | 0 | if (rColor == COL_AUTO) |
652 | 0 | { |
653 | 0 | OUString sText = sSelectedCondition == aStrFontColor |
654 | 0 | ? ScResId(SCSTR_FILTER_AUTOMATIC_COLOR) |
655 | 0 | : ScResId(SCSTR_FILTER_NO_FILL); |
656 | 0 | maColorLbArr[nPos]->append(sId, sText); |
657 | 0 | } |
658 | 0 | else |
659 | 0 | { |
660 | 0 | maColorLbArr[nPos]->append(sId, OUString(), *lcl_getColorImage(rColor)); |
661 | 0 | } |
662 | |
|
663 | 0 | const auto& rItem = rEntry.GetQueryItem(); |
664 | 0 | if (rItem.maColor == rColor |
665 | 0 | && ((sSelectedCondition == aStrFontColor && rItem.meType == ScQueryEntry::ByTextColor) |
666 | 0 | || (sSelectedCondition == aStrBackgroundColor |
667 | 0 | && rItem.meType == ScQueryEntry::ByBackgroundColor))) |
668 | 0 | { |
669 | 0 | maColorLbArr[nPos]->set_active_id(sId); |
670 | 0 | } |
671 | 0 | } |
672 | 0 | } |
673 | | |
674 | | size_t ScFilterDlg::GetFieldSelPos( SCCOL nField ) |
675 | 0 | { |
676 | 0 | if ( nField >= theQueryData.nCol1 && nField <= theQueryData.nCol2 ) |
677 | 0 | return static_cast<size_t>(nField) - theQueryData.nCol1 + 1; |
678 | 0 | else |
679 | 0 | return 0; |
680 | 0 | } |
681 | | |
682 | | ScQueryItem* ScFilterDlg::GetOutputItem() |
683 | 0 | { |
684 | 0 | ScAddress theCopyPos; |
685 | 0 | ScQueryParam theParam( theQueryData ); |
686 | 0 | bool bCopyPosOk = false; |
687 | |
|
688 | 0 | if ( m_xBtnCopyResult->get_active() ) |
689 | 0 | { |
690 | 0 | ScRefFlags nResult = theCopyPos.Parse( |
691 | 0 | m_xEdCopyArea->GetText(), rDoc, rDoc.GetAddressConvention()); |
692 | 0 | bCopyPosOk = (nResult & ScRefFlags::VALID) == ScRefFlags::VALID; |
693 | 0 | } |
694 | |
|
695 | 0 | if ( m_xBtnCopyResult->get_active() && bCopyPosOk ) |
696 | 0 | { |
697 | 0 | theParam.bInplace = false; |
698 | 0 | theParam.nDestTab = theCopyPos.Tab(); |
699 | 0 | theParam.nDestCol = theCopyPos.Col(); |
700 | 0 | theParam.nDestRow = theCopyPos.Row(); |
701 | 0 | } |
702 | 0 | else |
703 | 0 | { |
704 | 0 | theParam.bInplace = true; |
705 | 0 | theParam.nDestTab = 0; |
706 | 0 | theParam.nDestCol = 0; |
707 | 0 | theParam.nDestRow = 0; |
708 | 0 | } |
709 | |
|
710 | 0 | theParam.bHasHeader = m_xBtnHeader->get_active(); |
711 | 0 | theParam.bByRow = true; |
712 | 0 | theParam.bDuplicate = !m_xBtnUnique->get_active(); |
713 | 0 | theParam.bCaseSens = m_xBtnCase->get_active(); |
714 | 0 | theParam.eSearchType = m_xBtnRegExp->get_active() ? utl::SearchParam::SearchType::Regexp : utl::SearchParam::SearchType::Normal; |
715 | 0 | theParam.bDestPers = m_xBtnDestPers->get_active(); |
716 | | |
717 | | // only set the three - reset everything else |
718 | |
|
719 | 0 | pOutItem.reset( new ScQueryItem( nWhichQuery, &theParam ) ); |
720 | |
|
721 | 0 | return pOutItem.get(); |
722 | 0 | } |
723 | | |
724 | | bool ScFilterDlg::IsRefInputMode() const |
725 | 0 | { |
726 | 0 | return bRefInputMode; |
727 | 0 | } |
728 | | |
729 | | // Handler: |
730 | | |
731 | | IMPL_LINK( ScFilterDlg, BtnClearHdl, weld::Button&, rBtn, void ) |
732 | 0 | { |
733 | 0 | if ( &rBtn != m_xBtnClear.get() ) |
734 | 0 | return; |
735 | | |
736 | | // scroll to the top |
737 | 0 | m_xScrollBar->vadjustment_set_value(0); |
738 | 0 | size_t nOffset = 0; |
739 | 0 | RefreshEditRow( nOffset); |
740 | | |
741 | | // clear all conditions |
742 | 0 | m_xLbConnect1->set_active(-1); |
743 | 0 | m_xLbConnect2->set_active(-1); |
744 | 0 | m_xLbConnect3->set_active(-1); |
745 | 0 | m_xLbConnect4->set_active(-1); |
746 | 0 | m_xLbField1->set_active(0); |
747 | 0 | m_xLbField2->set_active(0); |
748 | 0 | m_xLbField3->set_active(0); |
749 | 0 | m_xLbField4->set_active(0); |
750 | 0 | m_xLbCond1->set_active(0); |
751 | 0 | m_xLbCond2->set_active(0); |
752 | 0 | m_xLbCond3->set_active(0); |
753 | 0 | m_xLbCond4->set_active(0); |
754 | 0 | ClearValueList( 1 ); |
755 | 0 | ClearValueList( 2 ); |
756 | 0 | ClearValueList( 3 ); |
757 | 0 | ClearValueList( 4 ); |
758 | | |
759 | | // disable fields for second row onward |
760 | 0 | m_xLbConnect2->set_sensitive(false); |
761 | 0 | m_xLbConnect3->set_sensitive(false); |
762 | 0 | m_xLbConnect4->set_sensitive(false); |
763 | 0 | m_xLbField2->set_sensitive(false); |
764 | 0 | m_xLbField3->set_sensitive(false); |
765 | 0 | m_xLbField4->set_sensitive(false); |
766 | 0 | m_xLbCond2->set_sensitive(false); |
767 | 0 | m_xLbCond3->set_sensitive(false); |
768 | 0 | m_xLbCond4->set_sensitive(false); |
769 | 0 | m_xEdVal2->set_sensitive(false); |
770 | 0 | m_xEdVal3->set_sensitive(false); |
771 | 0 | m_xEdVal4->set_sensitive(false); |
772 | 0 | m_xLbColor2->set_sensitive(false); |
773 | 0 | m_xLbColor3->set_sensitive(false); |
774 | 0 | m_xLbColor4->set_sensitive(false); |
775 | 0 | m_xBtnRemove2->set_sensitive(false); |
776 | 0 | m_xBtnRemove3->set_sensitive(false); |
777 | 0 | m_xBtnRemove4->set_sensitive(false); |
778 | | |
779 | | // clear query data objects |
780 | 0 | SCSIZE nCount = theQueryData.GetEntryCount(); |
781 | 0 | if (maRefreshExceptQuery.size() < nCount + 1) |
782 | 0 | maRefreshExceptQuery.resize(nCount + 1, false); |
783 | 0 | for (SCSIZE i = 0; i < nCount; ++i) |
784 | 0 | { |
785 | 0 | theQueryData.GetEntry(i).bDoQuery = false; |
786 | 0 | maRefreshExceptQuery[i] = false; |
787 | 0 | theQueryData.GetEntry(i).nField = static_cast<SCCOL>(0); |
788 | 0 | } |
789 | 0 | maRefreshExceptQuery[0] = true; |
790 | 0 | } |
791 | | |
792 | | IMPL_LINK( ScFilterDlg, EndDlgHdl, weld::Button&, rBtn, void ) |
793 | 0 | { |
794 | 0 | if ( &rBtn == m_xBtnOk.get() ) |
795 | 0 | { |
796 | 0 | bool bAreaInputOk = true; |
797 | |
|
798 | 0 | if ( m_xBtnCopyResult->get_active() ) |
799 | 0 | { |
800 | 0 | if ( !pOptionsMgr->VerifyPosStr( m_xEdCopyArea->GetText() ) ) |
801 | 0 | { |
802 | 0 | if (!m_xExpander->get_expanded()) |
803 | 0 | m_xExpander->set_expanded(true); |
804 | |
|
805 | 0 | std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(), |
806 | 0 | VclMessageType::Warning, VclButtonsType::Ok, |
807 | 0 | ScResId(STR_INVALID_TABREF))); |
808 | 0 | xBox->run(); |
809 | 0 | m_xEdCopyArea->GrabFocus(); |
810 | 0 | bAreaInputOk = false; |
811 | 0 | } |
812 | 0 | } |
813 | |
|
814 | 0 | if ( bAreaInputOk ) |
815 | 0 | { |
816 | 0 | SetDispatcherLock( false ); |
817 | 0 | SwitchToDocument(); |
818 | 0 | GetBindings().GetDispatcher()->ExecuteList(FID_FILTER_OK, |
819 | 0 | SfxCallMode::SLOT | SfxCallMode::RECORD, |
820 | 0 | { GetOutputItem() }); |
821 | 0 | response(RET_OK); |
822 | 0 | } |
823 | 0 | } |
824 | 0 | else if ( &rBtn == m_xBtnCancel.get() ) |
825 | 0 | { |
826 | 0 | response(RET_CANCEL); |
827 | 0 | } |
828 | 0 | } |
829 | | |
830 | | IMPL_LINK_NOARG(ScFilterDlg, MoreExpandedHdl, weld::Expander&, void) |
831 | 0 | { |
832 | 0 | if ( m_xExpander->get_expanded() ) |
833 | 0 | pTimer->Start(); |
834 | 0 | else |
835 | 0 | { |
836 | 0 | pTimer->Stop(); |
837 | 0 | bRefInputMode = false; |
838 | | //@BugID 54702 Enable/disable only in Basic class |
839 | | //SFX_APPWINDOW->Disable(FALSE); //! general method in ScAnyRefDlg |
840 | 0 | } |
841 | 0 | } |
842 | | |
843 | | IMPL_LINK( ScFilterDlg, TimeOutHdl, Timer*, _pTimer, void ) |
844 | 0 | { |
845 | | // Check if RefInputMode is still true every 50ms |
846 | 0 | if (_pTimer == pTimer.get() && m_xDialog->has_toplevel_focus()) |
847 | 0 | bRefInputMode = (m_xEdCopyArea->GetWidget()->has_focus() || m_xRbCopyArea->GetWidget()->has_focus()); |
848 | |
|
849 | 0 | if ( m_xExpander->get_expanded() ) |
850 | 0 | pTimer->Start(); |
851 | 0 | } |
852 | | |
853 | | IMPL_LINK(ScFilterDlg, LbSelectHdl, weld::ComboBox&, rLb, void) |
854 | 0 | { |
855 | | /* |
856 | | * Handle enable/disable logic depending on which ListBox was selected |
857 | | */ |
858 | 0 | const size_t nOffset = GetSliderPos(); |
859 | 0 | for (size_t nRow = 0; nRow < QUERY_ENTRY_COUNT; ++nRow) |
860 | 0 | { |
861 | 0 | const size_t nQE = nRow + nOffset; |
862 | |
|
863 | 0 | if (&rLb == maConnLbArr[nRow]) |
864 | 0 | { |
865 | 0 | maFieldLbArr[nRow]->set_sensitive(true); |
866 | 0 | maCondLbArr[nRow]->set_sensitive(true); |
867 | 0 | maValueEdArr[nRow]->set_sensitive(true); |
868 | 0 | maRemoveBtnArr[nRow]->set_sensitive(true); |
869 | |
|
870 | 0 | theQueryData.GetEntry(nQE).eConnect = static_cast<ScQueryConnect>(rLb.get_active()); |
871 | 0 | if (maRefreshExceptQuery.size() < nQE + 1) |
872 | 0 | maRefreshExceptQuery.resize(nQE + 1, false); |
873 | 0 | maRefreshExceptQuery[nQE] = true; |
874 | 0 | return; |
875 | 0 | } |
876 | | |
877 | 0 | if (&rLb == maFieldLbArr[nRow]) |
878 | 0 | { |
879 | 0 | const sal_Int32 nField = rLb.get_active(); |
880 | 0 | if (nField == 0) |
881 | 0 | { |
882 | | // tdf#82008 - remove a single query entry and keep the following criteria |
883 | 0 | RemoveQueryEntry(nQE, nOffset); |
884 | 0 | return; |
885 | 0 | } |
886 | | |
887 | 0 | UpdateValueList(nRow + 1); |
888 | 0 | UpdateColorList(nRow + 1); |
889 | 0 | if (nRow + 1 < QUERY_ENTRY_COUNT) |
890 | 0 | maConnLbArr[nRow + 1]->set_sensitive(true); |
891 | |
|
892 | 0 | ScQueryEntry& rEntry = theQueryData.GetEntry(nQE); |
893 | 0 | rEntry.bDoQuery = true; |
894 | 0 | rEntry.nField = theQueryData.nCol1 + static_cast<SCCOL>(nField) - 1; |
895 | 0 | return; |
896 | 0 | } |
897 | | |
898 | 0 | if (&rLb == maCondLbArr[nRow]) |
899 | 0 | { |
900 | 0 | const OUString aCond = rLb.get_active_text(); |
901 | 0 | const bool bByColor = aCond == aStrFontColor || aCond == aStrBackgroundColor; |
902 | |
|
903 | 0 | maColorLbArr[nRow]->set_visible(bByColor); |
904 | 0 | maColorLbArr[nRow]->set_sensitive(bByColor); |
905 | 0 | maValueEdArr[nRow]->set_visible(!bByColor); |
906 | 0 | UpdateColorList(nRow + 1); |
907 | |
|
908 | 0 | theQueryData.GetEntry(nQE).eOp |
909 | 0 | = bByColor ? SC_EQUAL : static_cast<ScQueryOp>(rLb.get_active()); |
910 | 0 | return; |
911 | 0 | } |
912 | | |
913 | 0 | if (&rLb == maColorLbArr[nRow]) |
914 | 0 | { |
915 | 0 | ScQueryEntry& rEntry = theQueryData.GetEntry(nQE); |
916 | 0 | const Color aColor = Color::STRtoRGB(rLb.get_active_id()); |
917 | 0 | if (maCondLbArr[nRow]->get_active_text() == aStrFontColor) |
918 | 0 | rEntry.SetQueryByTextColor(aColor); |
919 | 0 | else if (maCondLbArr[nRow]->get_active_text() == aStrBackgroundColor) |
920 | 0 | rEntry.SetQueryByBackgroundColor(aColor); |
921 | 0 | return; |
922 | 0 | } |
923 | 0 | } |
924 | 0 | } |
925 | | |
926 | | IMPL_LINK( ScFilterDlg, CheckBoxHdl, weld::Toggleable&, rBox, void ) |
927 | 0 | { |
928 | | // Column headers: |
929 | | // Field list: Columnxx <-> column header string |
930 | | // Value list: Column header value not applicable. |
931 | | // Upper/lower case: |
932 | | // Value list: completely new |
933 | |
|
934 | 0 | if ( &rBox == m_xBtnHeader.get() ) // Field list and value list |
935 | 0 | { |
936 | 0 | const sal_Int32 nCurSel1 = m_xLbField1->get_active(); |
937 | 0 | const sal_Int32 nCurSel2 = m_xLbField2->get_active(); |
938 | 0 | const sal_Int32 nCurSel3 = m_xLbField3->get_active(); |
939 | 0 | const sal_Int32 nCurSel4 = m_xLbField4->get_active(); |
940 | 0 | FillFieldLists(); |
941 | 0 | m_xLbField1->set_active( nCurSel1 ); |
942 | 0 | m_xLbField2->set_active( nCurSel2 ); |
943 | 0 | m_xLbField3->set_active( nCurSel3 ); |
944 | 0 | m_xLbField4->set_active( nCurSel4 ); |
945 | |
|
946 | 0 | UpdateHdrInValueList( 1 ); |
947 | 0 | UpdateHdrInValueList( 2 ); |
948 | 0 | UpdateHdrInValueList( 3 ); |
949 | 0 | UpdateHdrInValueList( 4 ); |
950 | 0 | } |
951 | |
|
952 | 0 | if ( &rBox != m_xBtnCase.get() ) // Complete value list |
953 | 0 | return; |
954 | | |
955 | 0 | m_EntryLists.clear(); |
956 | 0 | UpdateValueList( 1 ); // current text is recorded |
957 | 0 | UpdateValueList( 2 ); |
958 | 0 | UpdateValueList( 3 ); |
959 | 0 | UpdateValueList( 4 ); |
960 | |
|
961 | 0 | UpdateColorList( 1 ); |
962 | 0 | UpdateColorList( 2 ); |
963 | 0 | UpdateColorList( 3 ); |
964 | 0 | UpdateColorList( 4 ); |
965 | 0 | } |
966 | | |
967 | | IMPL_LINK( ScFilterDlg, ValModifyHdl, weld::ComboBox&, rEd, void ) |
968 | 0 | { |
969 | 0 | size_t nOffset = GetSliderPos(); |
970 | 0 | size_t i = 0; |
971 | 0 | size_t nQE = i + nOffset; |
972 | 0 | OUString aStrVal = rEd.get_active_text(); |
973 | 0 | weld::ComboBox* pLbCond = m_xLbCond1.get(); |
974 | 0 | weld::ComboBox* pLbField = m_xLbField1.get(); |
975 | 0 | if ( &rEd == m_xEdVal2.get() ) |
976 | 0 | { |
977 | 0 | pLbCond = m_xLbCond2.get(); |
978 | 0 | pLbField = m_xLbField2.get(); |
979 | 0 | i=1; |
980 | 0 | nQE=i+nOffset; |
981 | 0 | } |
982 | 0 | if ( &rEd == m_xEdVal3.get() ) |
983 | 0 | { |
984 | 0 | pLbCond = m_xLbCond3.get(); |
985 | 0 | pLbField = m_xLbField3.get(); |
986 | 0 | i=2; |
987 | 0 | nQE=i+nOffset; |
988 | 0 | } |
989 | 0 | if ( &rEd == m_xEdVal4.get() ) |
990 | 0 | { |
991 | 0 | pLbCond = m_xLbCond4.get(); |
992 | 0 | pLbField = m_xLbField4.get(); |
993 | 0 | i=3; |
994 | 0 | nQE=i+nOffset; |
995 | 0 | } |
996 | |
|
997 | 0 | if ( aStrEmpty == aStrVal || aStrNotEmpty == aStrVal ) |
998 | 0 | { |
999 | 0 | pLbCond->set_active_text(OUString('=')); |
1000 | 0 | pLbCond->set_sensitive(false); |
1001 | 0 | } |
1002 | 0 | else |
1003 | 0 | pLbCond->set_sensitive(true); |
1004 | |
|
1005 | 0 | if (maHasDates.size() < nQE + 1) |
1006 | 0 | maHasDates.resize(nQE + 1, false); |
1007 | 0 | if (maRefreshExceptQuery.size() < nQE + 1) |
1008 | 0 | maRefreshExceptQuery.resize(nQE + 1, false); |
1009 | |
|
1010 | 0 | ScQueryEntry& rEntry = theQueryData.GetEntry( nQE ); |
1011 | 0 | ScQueryEntry::Item& rItem = rEntry.GetQueryItem(); |
1012 | 0 | bool bDoThis = (pLbField->get_active() != 0); |
1013 | 0 | rEntry.bDoQuery = bDoThis; |
1014 | |
|
1015 | 0 | if ( !(rEntry.bDoQuery || maRefreshExceptQuery[nQE]) ) |
1016 | 0 | return; |
1017 | | |
1018 | 0 | bool bByEmptyOrNotByEmpty = false; |
1019 | 0 | if ( aStrEmpty == aStrVal ) |
1020 | 0 | { |
1021 | 0 | bByEmptyOrNotByEmpty = true; |
1022 | 0 | rEntry.SetQueryByEmpty(); |
1023 | 0 | } |
1024 | 0 | else if ( aStrNotEmpty == aStrVal ) |
1025 | 0 | { |
1026 | 0 | bByEmptyOrNotByEmpty = true; |
1027 | 0 | rEntry.SetQueryByNonEmpty(); |
1028 | 0 | } |
1029 | 0 | else |
1030 | 0 | { |
1031 | 0 | rItem.maString = rDoc.GetSharedStringPool().intern(aStrVal); |
1032 | 0 | rItem.mfVal = 0.0; |
1033 | |
|
1034 | 0 | sal_uInt32 nIndex = 0; |
1035 | 0 | bool bNumber = rDoc.GetFormatTable()->IsNumberFormat( |
1036 | 0 | rItem.maString.getString(), nIndex, rItem.mfVal); |
1037 | 0 | rItem.meType = bNumber ? ScQueryEntry::ByValue : ScQueryEntry::ByString; |
1038 | 0 | } |
1039 | |
|
1040 | 0 | const sal_Int32 nField = pLbField->get_active(); |
1041 | 0 | rEntry.nField = nField ? (theQueryData.nCol1 + |
1042 | 0 | static_cast<SCCOL>(nField) - 1) : static_cast<SCCOL>(0); |
1043 | |
|
1044 | 0 | ScQueryOp eOp = static_cast<ScQueryOp>(pLbCond->get_active()); |
1045 | 0 | rEntry.eOp = eOp; |
1046 | 0 | if (maHasDates[nQE] && !bByEmptyOrNotByEmpty) |
1047 | 0 | rItem.meType = ScQueryEntry::ByDate; |
1048 | 0 | } |
1049 | | |
1050 | | IMPL_LINK( ScFilterDlg, BtnRemoveHdl, weld::Button&, rBtn, void ) |
1051 | 0 | { |
1052 | | // Calculate the row to delete |
1053 | 0 | sal_uInt16 nOffset = GetSliderPos(); |
1054 | 0 | int nButtonIndex = 0; |
1055 | 0 | if ( &rBtn == m_xBtnRemove2.get() ) |
1056 | 0 | nButtonIndex = 1; |
1057 | 0 | if ( &rBtn == m_xBtnRemove3.get() ) |
1058 | 0 | nButtonIndex = 2; |
1059 | 0 | if ( &rBtn == m_xBtnRemove4.get() ) |
1060 | 0 | nButtonIndex = 3; |
1061 | | // tdf#82008 - remove a single query entry and keep the following criteria |
1062 | 0 | RemoveQueryEntry(nOffset + nButtonIndex, nOffset); |
1063 | 0 | } |
1064 | | |
1065 | | void ScFilterDlg::RemoveQueryEntry(SCSIZE nRowToDelete, size_t nOffset) |
1066 | 0 | { |
1067 | | // Check that the index is sensible |
1068 | 0 | SCSIZE nCount = theQueryData.GetEntryCount(); |
1069 | 0 | if (nRowToDelete >= nCount) |
1070 | 0 | { |
1071 | 0 | SAL_WARN( "sc", "ScFilterDlg::RemoveQueryEntry: could not delete row - invalid index."); |
1072 | 0 | return; |
1073 | 0 | } |
1074 | | |
1075 | | // Resize maRefreshExceptQuery |
1076 | 0 | if (maRefreshExceptQuery.size() < nCount + 1) |
1077 | 0 | maRefreshExceptQuery.resize(nCount + 1, false); |
1078 | | |
1079 | | // Move all the subsequent rows back one position; |
1080 | | // also find the last row, which we will delete |
1081 | 0 | SCSIZE nRowToClear = nCount-1; |
1082 | 0 | for (SCSIZE i = nRowToDelete; i < nCount-1; ++i) |
1083 | 0 | { |
1084 | 0 | if (theQueryData.GetEntry(i+1).bDoQuery) |
1085 | 0 | { |
1086 | 0 | theQueryData.GetEntry(i) = theQueryData.GetEntry(i+1); |
1087 | 0 | } |
1088 | 0 | else |
1089 | 0 | { |
1090 | 0 | nRowToClear = i; |
1091 | 0 | break; |
1092 | 0 | } |
1093 | 0 | } |
1094 | | |
1095 | | // If the next row is being edited, but not confirmed, move it back |
1096 | | // one position |
1097 | 0 | if (nRowToClear < nCount-1 && maRefreshExceptQuery[nRowToClear+1]) |
1098 | 0 | { |
1099 | 0 | theQueryData.GetEntry(nRowToClear) = theQueryData.GetEntry(nRowToClear+1); |
1100 | 0 | maRefreshExceptQuery[nRowToClear] = true; |
1101 | 0 | maRefreshExceptQuery[nRowToClear+1] = false; |
1102 | 0 | } |
1103 | 0 | else |
1104 | 0 | { |
1105 | | // Remove the very last one, since everything has moved back |
1106 | 0 | theQueryData.GetEntry(nRowToClear).bDoQuery = false; |
1107 | 0 | theQueryData.GetEntry(nRowToClear).nField = static_cast<SCCOL>(0); |
1108 | 0 | maRefreshExceptQuery[nRowToClear] = false; |
1109 | 0 | } |
1110 | | |
1111 | | // Always enable the very first row |
1112 | 0 | if (!theQueryData.GetEntry(0).bDoQuery) |
1113 | 0 | { |
1114 | 0 | maRefreshExceptQuery[0] = true; |
1115 | 0 | } |
1116 | | |
1117 | | // Refresh the UI |
1118 | 0 | RefreshEditRow( nOffset ); |
1119 | | |
1120 | | // Special handling if the very first row was cleared |
1121 | 0 | if (!theQueryData.GetEntry(0).bDoQuery) |
1122 | 0 | { |
1123 | 0 | m_xLbConnect1->set_active(-1); |
1124 | 0 | m_xLbField1->set_active(0); |
1125 | 0 | m_xLbField1->set_sensitive(true); |
1126 | 0 | m_xLbCond1->set_active(0); |
1127 | 0 | m_xLbCond1->set_sensitive(true); |
1128 | 0 | ClearValueList(1); |
1129 | 0 | } |
1130 | 0 | } |
1131 | | |
1132 | | IMPL_LINK_NOARG(ScFilterDlg, ScrollHdl, weld::ScrolledWindow&, void) |
1133 | 0 | { |
1134 | 0 | SliderMoved(); |
1135 | 0 | } |
1136 | | |
1137 | | void ScFilterDlg::SliderMoved() |
1138 | 0 | { |
1139 | 0 | size_t nOffset = GetSliderPos(); |
1140 | 0 | RefreshEditRow( nOffset); |
1141 | 0 | } |
1142 | | |
1143 | | size_t ScFilterDlg::GetSliderPos() const |
1144 | 0 | { |
1145 | 0 | return static_cast<size_t>(m_xScrollBar->vadjustment_get_value()); |
1146 | 0 | } |
1147 | | |
1148 | | void ScFilterDlg::RefreshEditRow( size_t nOffset ) |
1149 | 0 | { |
1150 | 0 | if (nOffset==0) |
1151 | 0 | maConnLbArr[0]->hide(); |
1152 | 0 | else |
1153 | 0 | maConnLbArr[0]->show(); |
1154 | |
|
1155 | 0 | for (size_t i = 0; i < QUERY_ENTRY_COUNT; ++i) |
1156 | 0 | { |
1157 | 0 | OUString aValStr; |
1158 | 0 | size_t nCondPos = 0; |
1159 | 0 | size_t nFieldSelPos = 0; |
1160 | 0 | size_t nQE = i + nOffset; |
1161 | |
|
1162 | 0 | maColorLbArr[i]->set_visible(false); |
1163 | |
|
1164 | 0 | if (maRefreshExceptQuery.size() < nQE + 1) |
1165 | 0 | maRefreshExceptQuery.resize(nQE + 1, false); |
1166 | |
|
1167 | 0 | ScQueryEntry& rEntry = theQueryData.GetEntry( nQE); |
1168 | 0 | if ( rEntry.bDoQuery || maRefreshExceptQuery[nQE] ) |
1169 | 0 | { |
1170 | 0 | nCondPos = static_cast<size_t>(rEntry.eOp); |
1171 | 0 | if(rEntry.bDoQuery) |
1172 | 0 | nFieldSelPos = GetFieldSelPos( static_cast<SCCOL>(rEntry.nField) ); |
1173 | |
|
1174 | 0 | const ScQueryEntry::Item& rItem = rEntry.GetQueryItem(); |
1175 | 0 | OUString aQueryStr = rItem.maString.getString(); |
1176 | 0 | if (rEntry.IsQueryByEmpty()) |
1177 | 0 | { |
1178 | 0 | aValStr = aStrEmpty; |
1179 | 0 | maCondLbArr[i]->set_sensitive(false); |
1180 | 0 | } |
1181 | 0 | else if (rEntry.IsQueryByNonEmpty()) |
1182 | 0 | { |
1183 | 0 | aValStr = aStrNotEmpty; |
1184 | 0 | maCondLbArr[i]->set_sensitive(false); |
1185 | 0 | } |
1186 | 0 | else if (rEntry.IsQueryByTextColor() || rEntry.IsQueryByBackgroundColor()) |
1187 | 0 | { |
1188 | 0 | nCondPos = maCondLbArr[i]->find_text( |
1189 | 0 | rEntry.IsQueryByTextColor() ? aStrFontColor : aStrBackgroundColor); |
1190 | |
|
1191 | 0 | maValueEdArr[i]->set_visible(false); |
1192 | 0 | maColorLbArr[i]->set_visible(true); |
1193 | 0 | maColorLbArr[i]->set_sensitive(true); |
1194 | 0 | } |
1195 | 0 | else |
1196 | 0 | { |
1197 | 0 | SetValString(aQueryStr, rItem, aValStr); |
1198 | 0 | maCondLbArr[i]->set_sensitive(true); |
1199 | 0 | } |
1200 | 0 | maFieldLbArr[i]->set_sensitive(true); |
1201 | 0 | maValueEdArr[i]->set_sensitive(true); |
1202 | 0 | maRemoveBtnArr[i]->set_sensitive(true); |
1203 | |
|
1204 | 0 | if (nOffset==0) |
1205 | 0 | { |
1206 | 0 | if (i<3) |
1207 | 0 | { |
1208 | 0 | if(rEntry.bDoQuery) |
1209 | 0 | maConnLbArr[i+1]->set_sensitive(true); |
1210 | 0 | else |
1211 | 0 | maConnLbArr[i+1]->set_sensitive(false); |
1212 | 0 | size_t nQENext = nQE + 1; |
1213 | 0 | if (maRefreshExceptQuery.size() < nQENext + 1) |
1214 | 0 | maRefreshExceptQuery.resize(nQENext + 1, false); |
1215 | 0 | if (theQueryData.GetEntry(nQENext).bDoQuery || maRefreshExceptQuery[nQENext]) |
1216 | 0 | maConnLbArr[i+1]->set_active( static_cast<sal_uInt16>(theQueryData.GetEntry(nQENext).eConnect) ); |
1217 | 0 | else |
1218 | 0 | maConnLbArr[i+1]->set_active(-1); |
1219 | 0 | } |
1220 | 0 | } |
1221 | 0 | else |
1222 | 0 | { |
1223 | 0 | if(theQueryData.GetEntry( nQE-1).bDoQuery) |
1224 | 0 | maConnLbArr[i]->set_sensitive(true); |
1225 | 0 | else |
1226 | 0 | maConnLbArr[i]->set_sensitive(false); |
1227 | |
|
1228 | 0 | if (maRefreshExceptQuery.size() < nQE + 1) |
1229 | 0 | maRefreshExceptQuery.resize(nQE + 1, false); |
1230 | 0 | if(rEntry.bDoQuery || maRefreshExceptQuery[nQE]) |
1231 | 0 | maConnLbArr[i]->set_active( static_cast<sal_uInt16>(rEntry.eConnect) ); |
1232 | 0 | else |
1233 | 0 | maConnLbArr[i]->set_active(-1); |
1234 | 0 | } |
1235 | |
|
1236 | 0 | } |
1237 | 0 | else |
1238 | 0 | { |
1239 | 0 | if (nOffset==0) |
1240 | 0 | { |
1241 | 0 | if(i<3) |
1242 | 0 | { |
1243 | 0 | maConnLbArr[i+1]->set_active(-1); |
1244 | 0 | maConnLbArr[i+1]->set_sensitive(false); |
1245 | 0 | } |
1246 | 0 | } |
1247 | 0 | else |
1248 | 0 | { |
1249 | 0 | if(theQueryData.GetEntry( nQE-1).bDoQuery) |
1250 | 0 | maConnLbArr[i]->set_sensitive(true); |
1251 | 0 | else |
1252 | 0 | maConnLbArr[i]->set_sensitive(false); |
1253 | 0 | maConnLbArr[i]->set_active(-1); |
1254 | 0 | } |
1255 | 0 | maFieldLbArr[i]->set_sensitive(false); |
1256 | 0 | maCondLbArr[i]->set_sensitive(false); |
1257 | 0 | maValueEdArr[i]->set_sensitive(false); |
1258 | 0 | maRemoveBtnArr[i]->set_sensitive(false); |
1259 | 0 | } |
1260 | 0 | maFieldLbArr[i]->set_active( nFieldSelPos ); |
1261 | 0 | maCondLbArr [i]->set_active( nCondPos ); |
1262 | 0 | maValueEdArr[i]->set_entry_text( aValStr ); |
1263 | 0 | UpdateValueList(i+1); |
1264 | 0 | UpdateColorList(i+1); |
1265 | 0 | } |
1266 | 0 | } |
1267 | | |
1268 | | void ScFilterDlg::SetValString( const OUString& rQueryStr, const ScQueryEntry::Item& rItem, |
1269 | | OUString& rValStr ) |
1270 | 0 | { |
1271 | 0 | if (rQueryStr.isEmpty()) |
1272 | 0 | { |
1273 | 0 | if (rItem.meType == ScQueryEntry::ByValue) |
1274 | 0 | { |
1275 | 0 | rValStr = rDoc.GetFormatTable()->GetInputLineString(rItem.mfVal, 0); |
1276 | 0 | } |
1277 | 0 | else if (rItem.meType == ScQueryEntry::ByDate) |
1278 | 0 | { |
1279 | 0 | SvNumberFormatter* pFormatter = rDoc.GetFormatTable(); |
1280 | 0 | rValStr = pFormatter->GetInputLineString(rItem.mfVal, |
1281 | 0 | pFormatter->GetStandardFormat( SvNumFormatType::DATE)); |
1282 | 0 | } |
1283 | 0 | else |
1284 | 0 | { |
1285 | 0 | SAL_WARN( "sc", "ScFilterDlg::SetValString: empty query string, really?"); |
1286 | 0 | rValStr = rQueryStr; |
1287 | 0 | } |
1288 | 0 | } |
1289 | 0 | else |
1290 | 0 | { |
1291 | | // XXX NOTE: if not ByString we just assume this has been |
1292 | | // set to a proper string corresponding to the numeric |
1293 | | // value earlier! |
1294 | 0 | rValStr = rQueryStr; |
1295 | 0 | } |
1296 | 0 | } |
1297 | | |
1298 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |