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