LibreOffice Module svx (master)  1
srchdlg.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 <osl/diagnose.h>
21 #include <vcl/timer.hxx>
22 #include <svl/slstitm.hxx>
23 #include <svl/itemiter.hxx>
24 #include <svl/style.hxx>
25 #include <unotools/intlwrapper.hxx>
27 #include <unotools/searchopt.hxx>
28 #include <unotools/syslocale.hxx>
29 #include <sfx2/dispatch.hxx>
30 #include <sfx2/objsh.hxx>
31 #include <sfx2/module.hxx>
32 #include <sfx2/viewsh.hxx>
33 #include <sfx2/basedlgs.hxx>
34 #include <sfx2/viewfrm.hxx>
35 #include <svl/cjkoptions.hxx>
36 #include <svl/ctloptions.hxx>
37 #include <com/sun/star/awt/XWindow.hpp>
38 #include <com/sun/star/container/XNameAccess.hpp>
39 #include <com/sun/star/frame/XDispatch.hpp>
40 #include <com/sun/star/frame/XDispatchProvider.hpp>
41 #include <com/sun/star/frame/XLayoutManager.hpp>
42 #include <com/sun/star/beans/PropertyValue.hpp>
43 #include <com/sun/star/beans/XPropertySet.hpp>
44 #include <com/sun/star/configuration/theDefaultProvider.hpp>
45 #include <com/sun/star/frame/ModuleManager.hpp>
46 #include <com/sun/star/ui/XUIElement.hpp>
49 #include <svl/itempool.hxx>
50 
51 #include <sfx2/app.hxx>
53 
54 #include <svx/srchdlg.hxx>
55 #include <svx/strarray.hxx>
56 
57 #include <svx/strings.hrc>
58 #include <svx/svxids.hrc>
59 
60 #include <svl/srchitem.hxx>
61 #include <svx/pageitem.hxx>
62 #include "srchctrl.hxx"
63 #include <svx/dialmgr.hxx>
64 #include <editeng/brushitem.hxx>
65 #include <tools/resary.hxx>
66 #include <svx/svxdlg.hxx>
67 #include <vcl/toolbox.hxx>
68 #include <o3tl/typed_flags_set.hxx>
69 #include <comphelper/lok.hxx>
70 
71 #include <cstdlib>
72 #include <memory>
73 
74 #include <findtextfield.hxx>
75 
76 #include <svx/labelitemwindow.hxx>
77 #include <svx/xdef.hxx>
78 #include <officecfg/Office/Common.hxx>
79 
80 using namespace com::sun::star::i18n;
81 using namespace com::sun::star::uno;
82 using namespace com::sun::star::accessibility;
83 using namespace com::sun::star;
84 using namespace comphelper;
85 
86 
87 #define IS_MOBILE (comphelper::LibreOfficeKit::isActive() && SfxViewShell::Current() && SfxViewShell::Current()->isLOKMobilePhone())
88 
89 enum class ModifyFlags {
90  NONE = 0x000000,
91  Search = 0x000001,
92  Replace = 0x000002,
93  Word = 0x000004,
94  Exact = 0x000008,
95  Backwards = 0x000010,
96  Selection = 0x000020,
97  Regexp = 0x000040,
98  Layout = 0x000080,
99  Similarity = 0x000100,
100  Formulas = 0x000200,
101  Values = 0x000400,
102  CalcNotes = 0x000800,
103  Rows = 0x001000,
104  Columns = 0x002000,
105  AllTables = 0x004000,
106  Notes = 0x008000,
107  Wildcard = 0x010000
108 };
109 namespace o3tl {
110  template<> struct typed_flags<ModifyFlags> : is_typed_flags<ModifyFlags, 0x01ffff> {};
111 }
112 
113 namespace
114 {
115  bool GetCheckBoxValue(const weld::CheckButton& rBox)
116  {
117  return rBox.get_sensitive() && rBox.get_active();
118  }
119 
120  bool GetNegatedCheckBoxValue(const weld::CheckButton& rBox)
121  {
122  return rBox.get_sensitive() && !rBox.get_active();
123  }
124 }
125 
127 {
128  bool bSaveToModule : 1,
129  bFocusOnSearch : 1;
131  Timer aSelectionTimer { "svx SearchDlg_Impl aSelectionTimer" };
132 
133  uno::Reference< frame::XDispatch > xCommand1Dispatch;
134  uno::Reference< frame::XDispatch > xCommand2Dispatch;
135  util::URL aCommand1URL;
136  util::URL aCommand2URL;
137 
139  : bSaveToModule(true)
140  , bFocusOnSearch(true)
141  {
142  aCommand1URL.Complete = aCommand1URL.Main = "vnd.sun.search:SearchViaComponent1";
143  aCommand1URL.Protocol = "vnd.sun.search:";
144  aCommand1URL.Path = "SearchViaComponent1";
145  aCommand2URL.Complete = aCommand2URL.Main = "vnd.sun.search:SearchViaComponent2";
146  aCommand2URL.Protocol = "vnd.sun.search:";
147  aCommand2URL.Path = "SearchViaComponent2";
148  }
149 };
150 
151 static void ListToStrArr_Impl(sal_uInt16 nId, std::vector<OUString>& rStrLst, weld::ComboBox& rCBox, sal_uInt16 nRememberSize)
152 {
153  const SfxStringListItem* pSrchItem =
154  static_cast<const SfxStringListItem*>(SfxGetpApp()->GetItem( nId ));
155 
156  if (!pSrchItem)
157  return;
158 
159  std::vector<OUString> aLst = pSrchItem->GetList();
160 
161  if (aLst.size() > nRememberSize)
162  aLst.resize(nRememberSize);
163 
164  for (const OUString & s : aLst)
165  {
166  rStrLst.push_back(s);
167  rCBox.append_text(s);
168  }
169 }
170 
171 static void StrArrToList_Impl( sal_uInt16 nId, const std::vector<OUString>& rStrLst )
172 {
173  DBG_ASSERT( !rStrLst.empty(), "check in advance");
174  SfxGetpApp()->PutItem( SfxStringListItem( nId, &rStrLst ) );
175 }
176 
178  SrchAttrItemList(std::move(rList))
179 {
180  for ( size_t i = 0; i < size(); ++i )
181  if ( !IsInvalidItem( (*this)[i].pItem ) )
182  (*this)[i].pItem = (*this)[i].pItem->Clone();
183 }
184 
186  SrchAttrItemList(rList)
187 {
188  for ( size_t i = 0; i < size(); ++i )
189  if ( !IsInvalidItem( (*this)[i].pItem ) )
190  (*this)[i].pItem = (*this)[i].pItem->Clone();
191 }
192 
194 {
195  Clear();
196 }
197 
199 {
200  if ( !rSet.Count() )
201  return;
202 
203  SfxItemPool* pPool = rSet.GetPool();
204  SfxItemIter aIter( rSet );
205  SearchAttrItem aItem;
206  const SfxPoolItem* pItem = aIter.GetCurItem();
207  sal_uInt16 nWhich;
208 
209  do
210  {
211  // only test that it is available?
212  if( IsInvalidItem( pItem ) )
213  {
214  nWhich = rSet.GetWhichByPos( aIter.GetCurPos() );
215  aItem.pItem = const_cast<SfxPoolItem*>(pItem);
216  }
217  else
218  {
219  nWhich = pItem->Which();
220  aItem.pItem = pItem->Clone();
221  }
222 
223  aItem.nSlot = pPool->GetSlotId( nWhich );
224  Insert( aItem );
225 
226  pItem = aIter.NextItem();
227  } while (pItem);
228 }
229 
230 
232 {
233  SfxItemPool* pPool = rSet.GetPool();
234 
235  for ( size_t i = 0; i < size(); ++i )
236  if ( IsInvalidItem( (*this)[i].pItem ) )
237  rSet.InvalidateItem( pPool->GetWhich( (*this)[i].nSlot ) );
238  else
239  rSet.Put( *(*this)[i].pItem );
240  return rSet;
241 }
242 
243 
245 {
246  for ( size_t i = 0; i < size(); ++i )
247  if ( !IsInvalidItem( (*this)[i].pItem ) )
248  delete (*this)[i].pItem;
249  SrchAttrItemList::clear();
250 }
251 
252 
253 // Deletes the pointer to the items
254 void SearchAttrItemList::Remove(size_t nPos)
255 {
256  size_t nLen = 1;
257  if ( nPos + nLen > size() )
258  nLen = size() - nPos;
259 
260  for ( size_t i = nPos; i < nPos + nLen; ++i )
261  if ( !IsInvalidItem( (*this)[i].pItem ) )
262  delete (*this)[i].pItem;
263 
264  SrchAttrItemList::erase( begin() + nPos, begin() + nPos + nLen );
265 }
266 
268  : SfxModelessDialogController(&rBind, pChildWin, pParent,
269  IS_MOBILE ? OUString("svx/ui/findreplacedialog-mobile.ui") : OUString("svx/ui/findreplacedialog.ui"),
270  "FindReplaceDialog")
271  , rBindings(rBind)
272  , m_aPresentIdle("Bring SvxSearchDialog to Foreground")
273  , bWriter(false)
274  , bSearch(true)
275  , bFormat(false)
276  , bReplaceBackwards(false)
277  , nOptions(SearchOptionFlags::ALL)
278  , bSet(false)
279  , bConstruct(true)
280  , nModifyFlag(ModifyFlags::NONE)
281  , pReplaceList(new SearchAttrItemList)
282  , nTransliterationFlags(TransliterationFlags::NONE)
283  , m_xSearchFrame(m_xBuilder->weld_frame("searchframe"))
284  , m_xSearchLB(m_xBuilder->weld_combo_box("searchterm"))
285  , m_xSearchTmplLB(m_xBuilder->weld_combo_box("searchlist"))
286  , m_xSearchAttrText(m_xBuilder->weld_label("searchdesc"))
287  , m_xSearchLabel(m_xBuilder->weld_label("searchlabel"))
288  , m_xReplaceFrame(m_xBuilder->weld_frame("replaceframe"))
289  , m_xReplaceLB(m_xBuilder->weld_combo_box("replaceterm"))
290  , m_xReplaceTmplLB(m_xBuilder->weld_combo_box("replacelist"))
291  , m_xReplaceAttrText(m_xBuilder->weld_label("replacedesc"))
292  , m_xSearchBtn(m_xBuilder->weld_button("search"))
293  , m_xBackSearchBtn(m_xBuilder->weld_button("backsearch"))
294  , m_xSearchAllBtn(m_xBuilder->weld_button("searchall"))
295  , m_xReplaceBtn(m_xBuilder->weld_button("replace"))
296  , m_xReplaceAllBtn(m_xBuilder->weld_button("replaceall"))
297  , m_xComponentFrame(m_xBuilder->weld_frame("componentframe"))
298  , m_xSearchComponent1PB(m_xBuilder->weld_button("component1"))
299  , m_xSearchComponent2PB(m_xBuilder->weld_button("component2"))
300  , m_xMatchCaseCB(m_xBuilder->weld_check_button("matchcase"))
301  , m_xSearchFormattedCB(m_xBuilder->weld_check_button("searchformatted"))
302  , m_xWordBtn(m_xBuilder->weld_check_button("wholewords"))
303  , m_xCloseBtn(m_xBuilder->weld_button("close"))
304  , m_xIncludeDiacritics(m_xBuilder->weld_check_button("includediacritics"))
305  , m_xIncludeKashida(m_xBuilder->weld_check_button("includekashida"))
306  , m_xOtherOptionsExpander(m_xBuilder->weld_expander("OptionsExpander"))
307  , m_xSelectionBtn(m_xBuilder->weld_check_button("selection"))
308  , m_xRegExpBtn(m_xBuilder->weld_check_button("regexp"))
309  , m_xWildcardBtn(m_xBuilder->weld_check_button("wildcard"))
310  , m_xSimilarityBox(m_xBuilder->weld_check_button("similarity"))
311  , m_xSimilarityBtn(m_xBuilder->weld_button("similaritybtn"))
312  , m_xLayoutBtn(m_xBuilder->weld_check_button("layout"))
313  , m_xNotesBtn(m_xBuilder->weld_check_button("notes"))
314  , m_xJapMatchFullHalfWidthCB(m_xBuilder->weld_check_button("matchcharwidth"))
315  , m_xJapOptionsCB(m_xBuilder->weld_check_button("soundslike"))
316  , m_xReplaceBackwardsCB(m_xBuilder->weld_check_button("replace_backwards"))
317  , m_xJapOptionsBtn(m_xBuilder->weld_button("soundslikebtn"))
318  , m_xAttributeBtn(m_xBuilder->weld_button("attributes"))
319  , m_xFormatBtn(m_xBuilder->weld_button("format"))
320  , m_xNoFormatBtn(m_xBuilder->weld_button("noformat"))
321  , m_xCalcGrid(m_xBuilder->weld_widget("calcgrid"))
322  , m_xCalcSearchInFT(m_xBuilder->weld_label("searchinlabel"))
323  , m_xCalcSearchInLB(m_xBuilder->weld_combo_box("calcsearchin"))
324  , m_xCalcSearchDirFT(m_xBuilder->weld_label("searchdir"))
325  , m_xRowsBtn(m_xBuilder->weld_radio_button("rows"))
326  , m_xColumnsBtn(m_xBuilder->weld_radio_button("cols"))
327  , m_xAllSheetsCB(m_xBuilder->weld_check_button("allsheets"))
328  , m_xCalcStrFT(m_xBuilder->weld_label("entirecells"))
329 {
331  m_aPresentIdle.SetInvokeHandler(LINK(this, SvxSearchDialog, PresentTimeoutHdl_Impl));
332 
333  m_xSearchTmplLB->make_sorted();
334  m_xSearchAttrText->hide();
335  m_xSearchLabel->show();
336 
337  m_xReplaceTmplLB->make_sorted();
338  m_xReplaceAttrText->hide();
339 
340  aCalcStr = m_xCalcStrFT->get_label();
341 
342  // m_xSimilarityBtn->set_height_request(m_xSimilarityBox->get_preferred_size().Height());
343  // m_xJapOptionsBtn->set_height_request(m_xJapOptionsCB->get_preferred_size().Height());
344 
345  //tdf#122322
346  nRememberSize = officecfg::Office::Common::Misc::FindReplaceRememberedSearches::get();
347  if (nRememberSize<1)
348  nRememberSize = 1; //0 crashes with no results found
349 
350  auto nTermWidth = m_xSearchLB->get_approximate_digit_width() * 28;
351  m_xSearchLB->set_size_request(nTermWidth, -1);
352  m_xSearchTmplLB->set_size_request(nTermWidth, -1);
353  m_xReplaceLB->set_size_request(nTermWidth, -1);
354  m_xReplaceTmplLB->set_size_request(nTermWidth, -1);
355 
356  Construct_Impl();
357 }
358 
359 IMPL_LINK_NOARG(SvxSearchDialog, PresentTimeoutHdl_Impl, Timer*, void)
360 {
361  getDialog()->present();
362 }
363 
365 {
366  PresentTimeoutHdl_Impl(nullptr);
367  // tdf#133807 try again in a short timeout
369 }
370 
372 {
374  pSearchController.reset();
375  pOptionsController.reset();
376  pFamilyController.reset();
379 }
380 
382 {
384  pSearchItem.reset();
385  pImpl.reset();
386 }
387 
389 {
390  pImpl.reset( new SearchDlg_Impl() );
391  pImpl->aSelectionTimer.SetTimeout( 500 );
392  pImpl->aSelectionTimer.SetInvokeHandler(
393  LINK( this, SvxSearchDialog, TimeoutHdl_Impl ) );
394  EnableControls_Impl( SearchOptionFlags::NONE );
395 
396  // Store old Text from m_xWordBtn
397  aCalcStr += "#";
398  aCalcStr += m_xWordBtn->get_label();
399 
400  aLayoutStr = SvxResId( RID_SVXSTR_SEARCH_STYLES );
401  aLayoutWriterStr = SvxResId( RID_SVXSTR_WRITER_STYLES );
402  aLayoutCalcStr = SvxResId( RID_SVXSTR_CALC_STYLES );
403  aStylesStr = m_xLayoutBtn->get_label();
404 
405  // Get stored search-strings from the application
406  ListToStrArr_Impl(SID_SEARCHDLG_SEARCHSTRINGS,
408  ListToStrArr_Impl(SID_SEARCHDLG_REPLACESTRINGS,
410 
412 
413  // Get attribute sets only once in constructor()
414  const SfxPoolItem* ppArgs[] = { pSearchItem.get(), nullptr };
415  const SvxSetItem* pSrchSetItem =
416  static_cast<const SvxSetItem*>( rBindings.GetDispatcher()->Execute( FID_SEARCH_SEARCHSET, SfxCallMode::SLOT, ppArgs ) );
417 
418  if ( pSrchSetItem )
419  InitAttrList_Impl( &pSrchSetItem->GetItemSet(), nullptr );
420 
421  const SvxSetItem* pReplSetItem =
422  static_cast<const SvxSetItem*>( rBindings.GetDispatcher()->Execute( FID_SEARCH_REPLACESET, SfxCallMode::SLOT, ppArgs ) );
423 
424  if ( pReplSetItem )
425  InitAttrList_Impl( nullptr, &pReplSetItem->GetItemSet() );
426 
427  // Create controller and update at once
429  pSearchController.reset(
430  new SvxSearchController( SID_SEARCH_ITEM, rBindings, *this ) );
431  pOptionsController.reset(
432  new SvxSearchController( SID_SEARCH_OPTIONS, rBindings, *this ) );
434  rBindings.GetDispatcher()->Execute( FID_SEARCH_ON, SfxCallMode::SLOT, ppArgs );
435  pImpl->aSelectionTimer.Start();
436 
437 
439  {
440  m_xJapOptionsCB->set_active( false );
441  m_xJapOptionsCB->hide();
442  m_xJapOptionsBtn->hide();
443  }
445  {
447  }
448  SvtCTLOptions aCTLOptions;
449  // Do not disable and hide the m_xIncludeDiacritics button.
450  // Include Diacritics == Not Ignore Diacritics => A does not match A-Umlaut (Diaeresis).
451  // Confusingly these have negated names (following the UI) but the actual
452  // transliteration is to *ignore* diacritics if "included" (sensitive) is
453  // _not_ checked.
454  if(!aCTLOptions.IsCTLFontEnabled())
455  {
456  m_xIncludeDiacritics->set_active( true );
457  m_xIncludeKashida->set_active( true );
458  m_xIncludeKashida->hide();
459  }
460  //component extension - show component search buttons if the commands
461  // vnd.sun.star::SearchViaComponent1 and 2 are supported
462  const uno::Reference< frame::XFrame >xFrame = rBindings.GetActiveFrame();
463  const uno::Reference< frame::XDispatchProvider > xDispatchProv(xFrame, uno::UNO_QUERY);
464 
465  bool bSearchComponent1 = false;
466  bool bSearchComponent2 = false;
467  if(xDispatchProv.is())
468  {
469  OUString sTarget("_self");
470  pImpl->xCommand1Dispatch = xDispatchProv->queryDispatch(pImpl->aCommand1URL, sTarget, 0);
471  if (pImpl->xCommand1Dispatch.is())
472  bSearchComponent1 = true;
473  pImpl->xCommand2Dispatch = xDispatchProv->queryDispatch(pImpl->aCommand2URL, sTarget, 0);
474  if (pImpl->xCommand2Dispatch.is())
475  bSearchComponent2 = true;
476  }
477 
478  if( !(bSearchComponent1 || bSearchComponent2) )
479  return;
480 
481  try
482  {
483  uno::Reference< lang::XMultiServiceFactory > xConfigurationProvider =
484  configuration::theDefaultProvider::get( comphelper::getProcessComponentContext() );
485  uno::Sequence< uno::Any > aArgs {
486  Any(OUString( "/org.openoffice.Office.Common/SearchOptions/")) };
487 
488  uno::Reference< uno::XInterface > xIFace = xConfigurationProvider->createInstanceWithArguments(
489  "com.sun.star.configuration.ConfigurationUpdateAccess",
490  aArgs);
491  uno::Reference< container::XNameAccess> xDirectAccess(xIFace, uno::UNO_QUERY);
492  if(xDirectAccess.is())
493  {
494  OUString sTemp;
495  uno::Any aRet = xDirectAccess->getByName("ComponentSearchGroupLabel");
496  aRet >>= sTemp;
497  m_xComponentFrame->set_label(sTemp);
498  aRet = xDirectAccess->getByName("ComponentSearchCommandLabel1");
499  aRet >>= sTemp;
500  m_xSearchComponent1PB->set_label( sTemp );
501  aRet = xDirectAccess->getByName("ComponentSearchCommandLabel2");
502  aRet >>= sTemp;
503  m_xSearchComponent2PB->set_label( sTemp );
504  }
505  }
506  catch(uno::Exception&){}
507 
508  if(!m_xSearchComponent1PB->get_label().isEmpty() && bSearchComponent1 )
509  {
510  m_xComponentFrame->show();
511  m_xSearchComponent1PB->show();
512  }
513  if( !m_xSearchComponent2PB->get_label().isEmpty() )
514  {
515  m_xComponentFrame->show();
516  m_xSearchComponent2PB->show();
517  }
518 }
519 
521 {
522  // remember strings
523  if (!aSearchStrings.empty())
524  StrArrToList_Impl( SID_SEARCHDLG_SEARCHSTRINGS, aSearchStrings );
525 
526  if (!aReplaceStrings.empty())
527  StrArrToList_Impl( SID_SEARCHDLG_REPLACESTRINGS, aReplaceStrings );
528 
529  // save settings to configuration
530  SvtSearchOptions aOpt;
531  aOpt.SetWholeWordsOnly ( m_xWordBtn->get_active() );
532  aOpt.SetBackwards ( m_xReplaceBackwardsCB->get_active() );
533  aOpt.SetUseRegularExpression ( m_xRegExpBtn->get_active() );
534  aOpt.SetUseWildcard ( m_xWildcardBtn->get_active() );
535  aOpt.SetSearchForStyles ( m_xLayoutBtn->get_active() );
536  aOpt.SetSimilaritySearch ( m_xSimilarityBox->get_active() );
537  aOpt.SetUseAsianOptions ( m_xJapOptionsCB->get_active() );
538  aOpt.SetNotes ( m_xNotesBtn->get_active() );
539  aOpt.SetIgnoreDiacritics_CTL ( !m_xIncludeDiacritics->get_active() );
540  aOpt.SetIgnoreKashida_CTL ( !m_xIncludeKashida->get_active() );
541  aOpt.SetSearchFormatted ( m_xSearchFormattedCB->get_active() );
542  aOpt.Commit();
543 
544  if (IsClosing())
545  return;
546 
547  const SfxPoolItem* ppArgs[] = { pSearchItem.get(), nullptr };
548  rBindings.GetDispatcher()->Execute( FID_SEARCH_OFF, SfxCallMode::SLOT, ppArgs );
549  rBindings.Invalidate(SID_SEARCH_DLG);
550 
551  SfxViewFrame* pViewFrame = SfxViewFrame::Current();
552  if (pViewFrame)
553  pViewFrame->ToggleChildWindow(SID_SEARCH_DLG);
554 }
555 
557 {
558  if (!m_xMatchCaseCB->get_active())
559  nTransliterationFlags |= TransliterationFlags::IGNORE_CASE;
560  else
562  if ( !m_xJapMatchFullHalfWidthCB->get_active())
563  nTransliterationFlags |= TransliterationFlags::IGNORE_WIDTH;
564  else
566  return nTransliterationFlags;
567 }
568 
570 {
571  pImpl->bSaveToModule = b;
572 }
573 
574 void SvxSearchDialog::SetSearchLabel(const OUString& rStr)
575 {
576  m_xSearchLabel->set_label(rStr);
577 
578  if (rStr == SvxResId(RID_SVXSTR_SEARCH_NOT_FOUND))
579  m_xSearchLB->set_entry_message_type(weld::EntryMessageType::Error);
580 }
581 
583 {
584  nTransliterationFlags = nSettings;
585  bool bVal(nSettings & TransliterationFlags::IGNORE_CASE);
586  m_xMatchCaseCB->set_active( !bVal );
587  bVal = bool(nSettings & TransliterationFlags::IGNORE_WIDTH);
588  m_xJapMatchFullHalfWidthCB->set_active( !bVal );
589 }
590 
591 
593 {
594  return m_xReplaceBackwardsCB->get_active() ||
595  m_xSelectionBtn->get_active() ||
596  m_xRegExpBtn->get_active() ||
597  m_xLayoutBtn->get_active() ||
598  m_xSimilarityBox->get_active() ||
599  m_xJapMatchFullHalfWidthCB->get_active() ||
600  m_xJapOptionsCB->get_active() ||
601  m_xWildcardBtn->get_active() ||
602  m_xNotesBtn->get_active() ||
603  m_xIncludeKashida->get_active() ||
604  !m_xIncludeDiacritics->get_active();//tdf#138173
605 }
606 
608 {
609  // apply possible transliteration changes of the SvxSearchItem member
610  if (pSearchItem)
611  {
612  m_xMatchCaseCB->set_active( pSearchItem->GetExact() );
613  m_xJapMatchFullHalfWidthCB->set_active( !pSearchItem->IsMatchFullHalfWidthForms() );
614  }
615 
617 }
618 
620 {
621  // CaseSensitives AutoComplete
622  m_xSearchLB->set_entry_completion( true, true );
623  m_xSearchLB->show();
624  m_xReplaceLB->set_entry_completion( true, true );
625  m_xReplaceLB->show();
626 
627  m_xFormatBtn->set_sensitive(false);
628  m_xAttributeBtn->set_sensitive(false);
629 
630  m_xSearchLB->connect_changed( LINK( this, SvxSearchDialog, ModifyHdl_Impl ) );
631  m_xReplaceLB->connect_changed( LINK( this, SvxSearchDialog, ModifyHdl_Impl ) );
632 
633  Link<weld::Widget&,void> aLink = LINK( this, SvxSearchDialog, FocusHdl_Impl );
634  m_xSearchLB->connect_focus_in( aLink );
635  m_xReplaceLB->connect_focus_in( aLink );
636 
637  aLink = LINK( this, SvxSearchDialog, LoseFocusHdl_Impl );
638  m_xSearchLB->connect_focus_out( aLink );
639  m_xReplaceLB->connect_focus_out( aLink );
640 
641  m_xSearchTmplLB->connect_focus_out( aLink );
642  m_xReplaceTmplLB->connect_focus_out( aLink );
643 
644  Link<weld::Button&,void> aLink2 = LINK( this, SvxSearchDialog, CommandHdl_Impl );
645  m_xSearchBtn->connect_clicked( aLink2 );
646  m_xBackSearchBtn->connect_clicked( aLink2 );
647  m_xSearchAllBtn->connect_clicked( aLink2 );
648  m_xReplaceBtn->connect_clicked( aLink2 );
649  m_xReplaceAllBtn->connect_clicked( aLink2 );
650  m_xCloseBtn->connect_clicked( aLink2 );
651  m_xSimilarityBtn->connect_clicked( aLink2 );
652  m_xJapOptionsBtn->connect_clicked( aLink2 );
653  m_xSearchComponent1PB->connect_clicked( aLink2 );
654  m_xSearchComponent2PB->connect_clicked( aLink2 );
655 
656  Link<weld::Toggleable&,void> aLink3 = LINK( this, SvxSearchDialog, FlagHdl_Impl );
657  m_xReplaceBackwardsCB->connect_toggled( aLink3 );
658  m_xWordBtn->connect_toggled( aLink3 );
659  m_xSelectionBtn->connect_toggled( aLink3 );
660  m_xMatchCaseCB->connect_toggled( aLink3 );
661  m_xRegExpBtn->connect_toggled( aLink3 );
662  m_xWildcardBtn->connect_toggled( aLink3 );
663  m_xNotesBtn->connect_toggled( aLink3 );
664  m_xSimilarityBox->connect_toggled( aLink3 );
665  m_xJapOptionsCB->connect_toggled( aLink3 );
666  m_xJapMatchFullHalfWidthCB->connect_toggled( aLink3 );
667  m_xIncludeDiacritics->connect_toggled( aLink3 );
668  m_xIncludeKashida->connect_toggled( aLink3 );
669  m_xLayoutBtn->connect_toggled( LINK( this, SvxSearchDialog, TemplateHdl_Impl ) );
670  m_xFormatBtn->connect_clicked( LINK( this, SvxSearchDialog, FormatHdl_Impl ) );
671  m_xNoFormatBtn->connect_clicked(
672  LINK( this, SvxSearchDialog, NoFormatHdl_Impl ) );
673  m_xAttributeBtn->connect_clicked(
674  LINK( this, SvxSearchDialog, AttributeHdl_Impl ) );
675 }
676 
677 namespace
678 {
679  SvtModuleOptions::EFactory getModule(SfxBindings const & rBindings)
680  {
682  try
683  {
684  const uno::Reference< frame::XFrame > xFrame =
685  rBindings.GetActiveFrame();
686  uno::Reference< frame::XModuleManager2 > xModuleManager(
687  frame::ModuleManager::create(::comphelper::getProcessComponentContext()));
688 
689  OUString aModuleIdentifier = xModuleManager->identify( xFrame );
690  eFactory = SvtModuleOptions::ClassifyFactoryByServiceName(aModuleIdentifier);
691  }
692  catch (const uno::Exception&)
693  {
694  }
695  return eFactory;
696  }
697 }
698 
700 {
701  DBG_ASSERT( pSearchItem, "no search item" );
702 
703  SvtCTLOptions aCTLOptions;
704  SvtModuleOptions::EFactory eFactory = getModule(rBindings);
705  bool bDrawApp = eFactory == SvtModuleOptions::EFactory::DRAW;
706  bool bWriterApp =
710  bool bCalcApp = eFactory == SvtModuleOptions::EFactory::CALC;
711 
712  m_xLayoutBtn->set_visible(!bDrawApp);
713  m_xNotesBtn->set_visible(bWriterApp);
714  m_xRegExpBtn->set_visible(!bDrawApp);
715  m_xWildcardBtn->set_visible(bCalcApp); /* TODO:WILDCARD enable for other apps if hey handle it */
716  m_xReplaceBackwardsCB->show();
717  m_xSimilarityBox->show();
718  m_xSimilarityBtn->show();
719  m_xSelectionBtn->show();
720  m_xIncludeDiacritics->show();
721  m_xIncludeKashida->set_visible(aCTLOptions.IsCTLFontEnabled());
725 
726  if (bWriter)
727  {
728  m_xAttributeBtn->show();
729  m_xFormatBtn->show();
730  m_xNoFormatBtn->show();
731  }
732 
733  if (bCalcApp)
734  {
735  m_xCalcSearchInFT->show();
736  m_xCalcSearchInLB->show();
737  m_xCalcSearchDirFT->show();
738  m_xRowsBtn->show();
739  m_xColumnsBtn->show();
740  m_xAllSheetsCB->show();
741  m_xSearchFormattedCB->show();
742  }
743 }
744 
745 
746 namespace {
747 
748 class ToggleSaveToModule
749 {
750 public:
751  ToggleSaveToModule(SvxSearchDialog& rDialog, bool bValue) :
752  mrDialog(rDialog), mbValue(bValue)
753  {
754  mrDialog.SetSaveToModule(mbValue);
755  }
756 
757  ~ToggleSaveToModule()
758  {
759  mrDialog.SetSaveToModule(!mbValue);
760  }
761 private:
762  SvxSearchDialog& mrDialog;
763  bool mbValue;
764 };
765 
766 }
767 
768 void SvxSearchDialog::Init_Impl( bool bSearchPattern )
769 {
770  DBG_ASSERT( pSearchItem, "SearchItem == 0" );
771 
772  // We don't want to save any intermediate state to the module while the
773  // dialog is being initialized.
774  ToggleSaveToModule aNoModuleSave(*this, false);
775  SvtSearchOptions aOpt;
776 
777  bWriter = ( pSearchItem->GetAppFlag() == SvxSearchApp::WRITER );
778 
779  if ( !( nModifyFlag & ModifyFlags::Word ) )
780  m_xWordBtn->set_active( pSearchItem->GetWordOnly() );
781  if ( !( nModifyFlag & ModifyFlags::Exact ) )
782  m_xMatchCaseCB->set_active( pSearchItem->GetExact() );
783  if ( !( nModifyFlag & ModifyFlags::Backwards ) )
784  m_xReplaceBackwardsCB->set_active( bReplaceBackwards ); //adjustment to replace backwards
785  if ( !( nModifyFlag & ModifyFlags::Notes ) )
786  m_xNotesBtn->set_active( pSearchItem->GetNotes() );
787  if ( !( nModifyFlag & ModifyFlags::Selection ) )
788  m_xSelectionBtn->set_active( pSearchItem->GetSelection() );
789  if ( !( nModifyFlag & ModifyFlags::Regexp ) )
790  m_xRegExpBtn->set_active( pSearchItem->GetRegExp() );
791  if ( !( nModifyFlag & ModifyFlags::Wildcard ) )
792  m_xWildcardBtn->set_active( pSearchItem->GetWildcard() );
793  if ( !( nModifyFlag & ModifyFlags::Layout ) )
794  m_xLayoutBtn->set_active( pSearchItem->GetPattern() );
795  if (m_xNotesBtn->get_active())
796  m_xLayoutBtn->set_sensitive(false);
797  m_xSimilarityBox->set_active( pSearchItem->IsLevenshtein() );
798  if ( m_xJapOptionsCB->get_visible() )
799  m_xJapOptionsCB->set_active( pSearchItem->IsUseAsianOptions() );
800  m_xIncludeDiacritics->set_active( !aOpt.IsIgnoreDiacritics_CTL() );
801  if ( m_xIncludeKashida->get_visible() )
802  m_xIncludeKashida->set_active( !aOpt.IsIgnoreKashida_CTL() );
804  m_xOtherOptionsExpander->set_expanded( true );
805  ApplyTransliterationFlags_Impl( pSearchItem->GetTransliterationFlags() );
806 
808 
809  if ( pSearchItem->GetAppFlag() == SvxSearchApp::CALC )
810  {
811  m_xCalcGrid->show();
812  m_xSearchFormattedCB->set_active( aOpt.IsSearchFormatted() );
813  Link<weld::Toggleable&,void> aLink = LINK( this, SvxSearchDialog, FlagHdl_Impl );
814  m_xCalcSearchInLB->connect_changed( LINK( this, SvxSearchDialog, LBSelectHdl_Impl ) );
815  m_xRowsBtn->connect_toggled( aLink );
816  m_xColumnsBtn->connect_toggled( aLink );
817  m_xAllSheetsCB->connect_toggled( aLink );
818  m_xSearchFormattedCB->connect_toggled( aLink );
819 
820  ModifyFlags nModifyFlagCheck;
821  switch ( pSearchItem->GetCellType() )
822  {
823  case SvxSearchCellType::FORMULA:
824  nModifyFlagCheck = ModifyFlags::Formulas;
825  break;
826 
827  case SvxSearchCellType::VALUE:
828  nModifyFlagCheck = ModifyFlags::Values;
829  break;
830 
831  case SvxSearchCellType::NOTE:
832  nModifyFlagCheck = ModifyFlags::CalcNotes;
833  break;
834 
835  default:
836  std::abort(); // cannot happen
837  }
838  if ( !(nModifyFlag & nModifyFlagCheck) )
839  m_xCalcSearchInLB->set_active( static_cast<sal_Int32>(pSearchItem->GetCellType()) );
840 
841  m_xWordBtn->set_label( aCalcStr.getToken( 0, '#' ) );
842 
843  if ( pSearchItem->GetRowDirection() &&
845  m_xRowsBtn->set_active(true);
846  else if ( !pSearchItem->GetRowDirection() &&
848  m_xColumnsBtn->set_active(true);
849 
850  if ( !( nModifyFlag & ModifyFlags::AllTables ) )
851  m_xAllSheetsCB->set_active( pSearchItem->IsAllTables() );
852 
853  // only look for formatting in Writer
854  m_xFormatBtn->hide();
855  m_xNoFormatBtn->hide();
856  m_xAttributeBtn->hide();
857  }
858  else
859  {
860  m_xSearchFormattedCB->hide();
861  m_xWordBtn->set_label( aCalcStr.getToken( 1, '#' ) );
862 
863  if ( pSearchItem->GetAppFlag() == SvxSearchApp::DRAW )
864  {
865  m_xSearchAllBtn->hide();
866 
867  m_xRegExpBtn->hide();
868  m_xWildcardBtn->hide();
869  m_xLayoutBtn->hide();
870 
871  // only look for formatting in Writer
872  m_xFormatBtn->hide();
873  m_xNoFormatBtn->hide();
874  m_xAttributeBtn->hide();
875  }
876  else
877  {
878  m_xWildcardBtn->hide(); /* TODO:WILDCARD do not hide for other apps if they handle it */
879 
880  if ( !pSearchList )
881  {
882  // Get attribute sets, if it not has been done already
883  const SfxPoolItem* ppArgs[] = { pSearchItem.get(), nullptr };
884  const SvxSetItem* pSrchSetItem =
885  static_cast<const SvxSetItem*>(rBindings.GetDispatcher()->Execute( FID_SEARCH_SEARCHSET, SfxCallMode::SLOT, ppArgs ));
886 
887  if ( pSrchSetItem )
888  InitAttrList_Impl( &pSrchSetItem->GetItemSet(), nullptr );
889 
890  const SvxSetItem* pReplSetItem =
891  static_cast<const SvxSetItem*>( rBindings.GetDispatcher()->Execute( FID_SEARCH_REPLACESET, SfxCallMode::SLOT, ppArgs ) );
892 
893  if ( pReplSetItem )
894  InitAttrList_Impl( nullptr, &pReplSetItem->GetItemSet() );
895  }
896  }
897  }
898 
899  // similarity search?
901  m_xSimilarityBox->set_active( pSearchItem->IsLevenshtein() );
902  bSet = true;
903 
904  FlagHdl_Impl(*m_xSimilarityBox);
905  FlagHdl_Impl(*m_xJapOptionsCB);
906 
907  bool bDisableSearch = false;
908  SfxViewShell* pViewShell = SfxViewShell::Current();
909 
910  if ( pViewShell )
911  {
912  bool bText = !bSearchPattern;
913 
914  if ( pViewShell->HasSelection( bText ) )
916  else
917  {
918  m_xSelectionBtn->set_active( false );
919  m_xSelectionBtn->set_sensitive(false);
920  }
921  }
922 
923  // Pattern Search and there were no AttrSets given
924  if ( bSearchPattern )
925  {
927 
928  if ( pShell && pShell->GetStyleSheetPool() )
929  {
930  // Templates designed
931  m_xSearchTmplLB->clear();
932  m_xReplaceTmplLB->clear();
933  SfxStyleSheetBasePool* pStylePool = pShell->GetStyleSheetPool();
934  SfxStyleSheetBase* pBase = pStylePool->First(pSearchItem->GetFamily());
935 
936  while ( pBase )
937  {
938  if ( pBase->IsUsed() )
939  m_xSearchTmplLB->append_text( pBase->GetName() );
940  m_xReplaceTmplLB->append_text( pBase->GetName() );
941  pBase = pStylePool->Next();
942  }
943  m_xSearchTmplLB->set_active_text( pSearchItem->GetSearchString() );
944  m_xReplaceTmplLB->set_active_text( pSearchItem->GetReplaceString() );
945 
946  }
947  m_xSearchTmplLB->show();
948 
949  if ( bConstruct )
950  // Grab focus only after creating
951  m_xSearchTmplLB->grab_focus();
952  m_xReplaceTmplLB->show();
953  m_xSearchLB->hide();
954  m_xReplaceLB->hide();
955 
956  m_xWordBtn->set_sensitive(false);
957  m_xRegExpBtn->set_sensitive(false);
958  m_xWildcardBtn->set_sensitive(false);
959  m_xMatchCaseCB->set_sensitive(false);
960 
961  bDisableSearch = !m_xSearchTmplLB->get_count();
962  }
963  else
964  {
965  bool bSetSearch = !( nModifyFlag & ModifyFlags::Search );
966  bool bSetReplace = !( nModifyFlag & ModifyFlags::Replace );
967 
968  if ( !(pSearchItem->GetSearchString().isEmpty()) && bSetSearch )
969  m_xSearchLB->set_entry_text( pSearchItem->GetSearchString() );
970  else if (!aSearchStrings.empty())
971  {
972  bool bAttributes =
973  ( ( pSearchList && pSearchList->Count() ) ||
974  ( pReplaceList && pReplaceList->Count() ) );
975 
976  if ( bSetSearch && !bAttributes )
977  m_xSearchLB->set_entry_text(aSearchStrings[0]);
978 
979  OUString aReplaceTxt = pSearchItem->GetReplaceString();
980 
981  if (!aReplaceStrings.empty())
982  aReplaceTxt = aReplaceStrings[0];
983 
984  if ( bSetReplace && !bAttributes )
985  m_xReplaceLB->set_entry_text( aReplaceTxt );
986  }
987  m_xSearchLB->show();
988 
989  if ( bConstruct )
990  // Grab focus only after creating
991  m_xSearchLB->grab_focus();
992  m_xReplaceLB->show();
993  m_xSearchTmplLB->hide();
994  m_xReplaceTmplLB->hide();
995 
999 
1000  if ( m_xRegExpBtn->get_active() )
1001  m_xWordBtn->set_sensitive(false);
1002  else
1004 
1005  bDisableSearch = m_xSearchLB->get_active_text().isEmpty() &&
1006  m_xSearchAttrText->get_label().isEmpty();
1007  }
1008  FocusHdl_Impl(*m_xSearchLB);
1009 
1010  if ( bDisableSearch )
1011  {
1012  m_xSearchBtn->set_sensitive(false);
1013  m_xBackSearchBtn->set_sensitive(false);
1014  m_xSearchAllBtn->set_sensitive(false);
1015  m_xReplaceBtn->set_sensitive(false);
1016  m_xReplaceAllBtn->set_sensitive(false);
1017  m_xComponentFrame->set_sensitive(false);
1018  }
1019  else
1020  {
1024  if (!bWriter || !m_xNotesBtn->get_active())
1025  {
1028  }
1029  if (bWriter && pSearchItem->GetNotes())
1030  {
1031  m_xSearchAllBtn->set_sensitive(false);
1032  m_xReplaceAllBtn->set_sensitive(false);
1033  }
1034  }
1035 
1036  if (!m_xSearchAttrText->get_label().isEmpty())
1038  else
1039  m_xNoFormatBtn->set_sensitive(false);
1040 
1041  if ( !pSearchList )
1042  {
1043  m_xAttributeBtn->set_sensitive(false);
1044  m_xFormatBtn->set_sensitive(false);
1045  }
1046 
1047  if ( m_xLayoutBtn->get_active() )
1048  {
1049  pImpl->bSaveToModule = false;
1050  TemplateHdl_Impl(*m_xLayoutBtn);
1051  pImpl->bSaveToModule = true;
1052  }
1053 }
1054 
1055 
1057  const SfxItemSet* pRSet )
1058 {
1059  if ( !pSSet && !pRSet )
1060  return;
1061 
1062  if ( pImpl->pRanges.empty() && pSSet )
1063  pImpl->pRanges = pSSet->GetRanges();
1064 
1065  bool bSetOptimalLayoutSize = false;
1066 
1067  // See to it that are the texts of the attributes are correct
1068  OUString aDesc;
1069 
1070  if ( pSSet )
1071  {
1072  pSearchList.reset(new SearchAttrItemList);
1073 
1074  if ( pSSet->Count() )
1075  {
1076  pSearchList->Put( *pSSet );
1077 
1078  m_xSearchAttrText->set_label( BuildAttrText_Impl( aDesc, true ) );
1079 
1080  if ( !aDesc.isEmpty() )
1081  {
1082  if (!m_xSearchAttrText->get_visible())
1083  {
1084  m_xSearchAttrText->show();
1085  bSetOptimalLayoutSize = true;
1086  }
1087  bFormat |= true;
1088  }
1089  }
1090  }
1091 
1092  if ( pRSet )
1093  {
1094  pReplaceList.reset(new SearchAttrItemList);
1095 
1096  if ( pRSet->Count() )
1097  {
1098  pReplaceList->Put( *pRSet );
1099 
1100  m_xReplaceAttrText->set_label( BuildAttrText_Impl( aDesc, false ) );
1101 
1102  if ( !aDesc.isEmpty() )
1103  {
1104  if (!m_xReplaceAttrText->get_visible())
1105  {
1106  m_xReplaceAttrText->show();
1107  bSetOptimalLayoutSize = true;
1108  }
1109  bFormat |= true;
1110  }
1111  }
1112  }
1113 
1114  if (bSetOptimalLayoutSize)
1115  m_xDialog->resize_to_request();
1116 }
1117 
1118 IMPL_LINK( SvxSearchDialog, LBSelectHdl_Impl, weld::ComboBox&, rCtrl, void )
1119 {
1120  ClickHdl_Impl(&rCtrl);
1121 }
1122 
1123 IMPL_LINK( SvxSearchDialog, FlagHdl_Impl, weld::Toggleable&, rCtrl, void )
1124 {
1125  ClickHdl_Impl(&rCtrl);
1126 }
1127 
1129 {
1130  if ( pCtrl && !bSet )
1131  SetModifyFlag_Impl(pCtrl);
1132  else
1133  bSet = false;
1134 
1135  if (pCtrl == m_xSimilarityBox.get())
1136  {
1137  bool bIsChecked = m_xSimilarityBox->get_active();
1138 
1139  if ( bIsChecked )
1140  {
1141  m_xSimilarityBtn->set_sensitive(true);
1142  m_xRegExpBtn->set_active( false );
1143  m_xRegExpBtn->set_sensitive(false);
1144  m_xWildcardBtn->set_active( false );
1145  m_xWildcardBtn->set_sensitive(false);
1147 
1148  if ( m_xLayoutBtn->get_active() )
1149  {
1151  m_xLayoutBtn->set_active( false );
1152  }
1153  m_xRegExpBtn->set_sensitive(false);
1154  m_xWildcardBtn->set_sensitive(false);
1155  m_xLayoutBtn->set_sensitive(false);
1156  m_xFormatBtn->set_sensitive(false);
1157  m_xNoFormatBtn->set_sensitive(false);
1158  m_xAttributeBtn->set_sensitive(false);
1159  }
1160  else
1161  {
1164  if (!m_xNotesBtn->get_active())
1168  m_xSimilarityBtn->set_sensitive(false);
1169  }
1170  pSearchItem->SetLevenshtein( bIsChecked );
1171  }
1172  else if (pCtrl == m_xNotesBtn.get())
1173  {
1174  if (m_xNotesBtn->get_active())
1175  {
1176  m_xLayoutBtn->set_sensitive(false);
1177  m_xSearchAllBtn->set_sensitive(false);
1178  m_xReplaceAllBtn->set_sensitive(false);
1179  }
1180  else
1181  {
1183  ModifyHdl_Impl(*m_xSearchLB);
1184  }
1185  }
1186  else
1187  {
1188  if ( m_xLayoutBtn->get_active() && !bFormat )
1189  {
1190  m_xWordBtn->set_active( false );
1191  m_xWordBtn->set_sensitive(false);
1192  m_xRegExpBtn->set_active( false );
1193  m_xRegExpBtn->set_sensitive(false);
1194  m_xWildcardBtn->set_active( false );
1195  m_xWildcardBtn->set_sensitive(false);
1196  m_xMatchCaseCB->set_active( false );
1197  m_xMatchCaseCB->set_sensitive(false);
1198  m_xNotesBtn->set_sensitive(false);
1199 
1200  if ( m_xSearchTmplLB->get_count() )
1201  {
1207  }
1208  }
1209  else
1210  {
1215 
1216  if ( m_xRegExpBtn->get_active() )
1217  {
1218  m_xWordBtn->set_active( false );
1219  m_xWordBtn->set_sensitive(false);
1220  m_xWildcardBtn->set_active( false );
1221  m_xWildcardBtn->set_sensitive(false);
1222  m_xSimilarityBox->set_active( false );
1223  m_xSimilarityBox->set_sensitive(false);
1224  m_xSimilarityBtn->set_sensitive(false);
1225  }
1226  else if ( m_xWildcardBtn->get_active() )
1227  {
1228  m_xRegExpBtn->set_active( false );
1229  m_xRegExpBtn->set_sensitive(false);
1230  m_xSimilarityBox->set_active( false );
1231  m_xSimilarityBox->set_sensitive(false);
1232  m_xSimilarityBtn->set_sensitive(false);
1233  }
1234  else
1235  {
1238  }
1239 
1240  // Search-string in place? then enable Buttons
1241  bSet = true;
1242  ModifyHdl_Impl(*m_xSearchLB);
1243  }
1244  }
1245 
1246  if (pCtrl == m_xAllSheetsCB.get())
1247  {
1248  bSet = true;
1249  ModifyHdl_Impl(*m_xSearchLB);
1250  }
1251 
1252  if (pCtrl == m_xJapOptionsCB.get())
1253  {
1254  bool bEnableJapOpt = m_xJapOptionsCB->get_active();
1255  m_xMatchCaseCB->set_sensitive(!bEnableJapOpt );
1256  m_xJapMatchFullHalfWidthCB->set_sensitive(!bEnableJapOpt );
1257  m_xJapOptionsBtn->set_sensitive( bEnableJapOpt );
1258  }
1259 
1260  if ( pImpl->bSaveToModule )
1262 }
1263 
1264 IMPL_LINK(SvxSearchDialog, CommandHdl_Impl, weld::Button&, rBtn, void)
1265 {
1266  bool bInclusive = ( m_xLayoutBtn->get_label() == aLayoutStr );
1267 
1268  if ( ( &rBtn == m_xSearchBtn.get() ) ||
1269  (&rBtn == m_xBackSearchBtn.get()) ||
1270  ( &rBtn == m_xSearchAllBtn.get() )||
1271  ( &rBtn == m_xReplaceBtn.get() ) ||
1272  ( &rBtn == m_xReplaceAllBtn.get() ) )
1273  {
1274  if ( m_xLayoutBtn->get_active() && !bInclusive )
1275  {
1276  pSearchItem->SetSearchString ( m_xSearchTmplLB->get_active_text() );
1277  pSearchItem->SetReplaceString( m_xReplaceTmplLB->get_active_text() );
1278  }
1279  else
1280  {
1281  pSearchItem->SetSearchString ( m_xSearchLB->get_active_text() );
1282  pSearchItem->SetReplaceString( m_xReplaceLB->get_active_text() );
1283 
1284  if ( &rBtn == m_xReplaceBtn.get() )
1285  Remember_Impl( m_xReplaceLB->get_active_text(), false );
1286  else
1287  {
1288  Remember_Impl( m_xSearchLB->get_active_text(), true );
1289 
1290  if ( &rBtn == m_xReplaceAllBtn.get() )
1291  Remember_Impl( m_xReplaceLB->get_active_text(), false );
1292  }
1293  }
1294 
1295  pSearchItem->SetRegExp( false );
1296  pSearchItem->SetWildcard( false );
1297  pSearchItem->SetLevenshtein( false );
1298  if (GetCheckBoxValue(*m_xRegExpBtn))
1299  pSearchItem->SetRegExp( true );
1300  else if (GetCheckBoxValue(*m_xWildcardBtn))
1301  pSearchItem->SetWildcard( true );
1302  else if (GetCheckBoxValue(*m_xSimilarityBox))
1303  pSearchItem->SetLevenshtein( true );
1304 
1305  pSearchItem->SetWordOnly(GetCheckBoxValue(*m_xWordBtn));
1306 
1307  bool bSetBackwards = false;
1308  if( &rBtn == m_xBackSearchBtn.get())
1309  {
1310  bSetBackwards = true;
1311  }
1312  else if( &rBtn == m_xReplaceBtn.get())
1313  {
1314  bSetBackwards = GetCheckBoxValue(*m_xReplaceBackwardsCB);
1315  bReplaceBackwards = GetCheckBoxValue(*m_xReplaceBackwardsCB);
1316  }
1317 
1318  pSearchItem->SetBackward(bSetBackwards);
1319 
1320  pSearchItem->SetNotes(GetCheckBoxValue(*m_xNotesBtn));
1321  pSearchItem->SetPattern(GetCheckBoxValue(*m_xLayoutBtn));
1322  pSearchItem->SetSelection(GetCheckBoxValue(*m_xSelectionBtn));
1323  pSearchItem->SetUseAsianOptions(GetCheckBoxValue(*m_xJapOptionsCB));
1325  if( !pSearchItem->IsUseAsianOptions())
1326  nFlags &= TransliterationFlags::IGNORE_CASE |
1327  TransliterationFlags::IGNORE_WIDTH;
1328  if (GetNegatedCheckBoxValue(*m_xIncludeDiacritics))
1329  nFlags |= TransliterationFlags::IGNORE_DIACRITICS_CTL;
1330  if (GetNegatedCheckBoxValue(*m_xIncludeKashida))
1331  nFlags |= TransliterationFlags::IGNORE_KASHIDA_CTL;
1332  pSearchItem->SetTransliterationFlags( nFlags );
1333 
1334  if ( !bWriter )
1335  {
1336  if ( m_xCalcSearchInLB->get_active() != -1)
1337  pSearchItem->SetCellType( static_cast<SvxSearchCellType>(m_xCalcSearchInLB->get_active()) );
1338 
1339  pSearchItem->SetRowDirection( m_xRowsBtn->get_active() );
1340  pSearchItem->SetAllTables( m_xAllSheetsCB->get_active() );
1341  pSearchItem->SetSearchFormatted( m_xSearchFormattedCB->get_active() );
1342  }
1343 
1344  if ((&rBtn == m_xSearchBtn.get()) || (&rBtn == m_xBackSearchBtn.get()))
1345  pSearchItem->SetCommand( SvxSearchCmd::FIND );
1346  else if ( &rBtn == m_xSearchAllBtn.get() )
1347  pSearchItem->SetCommand( SvxSearchCmd::FIND_ALL );
1348  else if ( &rBtn == m_xReplaceBtn.get() )
1349  pSearchItem->SetCommand( SvxSearchCmd::REPLACE );
1350  else if ( &rBtn == m_xReplaceAllBtn.get() )
1351  pSearchItem->SetCommand( SvxSearchCmd::REPLACE_ALL );
1352 
1353  // when looking for templates, delete format lists
1354  if ( !bFormat && pSearchItem->GetPattern() )
1355  {
1356  if ( pSearchList )
1357  pSearchList->Clear();
1358 
1359  if ( pReplaceList )
1360  pReplaceList->Clear();
1361  }
1362  nModifyFlag = ModifyFlags::NONE;
1363  const SfxPoolItem* ppArgs[] = { pSearchItem.get(), nullptr };
1364  rBindings.ExecuteSynchron( FID_SEARCH_NOW, ppArgs );
1365  }
1366  else if ( &rBtn == m_xCloseBtn.get() )
1367  {
1368  if ( !m_xLayoutBtn->get_active() || bInclusive )
1369  {
1370  OUString aStr( m_xSearchLB->get_active_text() );
1371 
1372  if ( !aStr.isEmpty() )
1373  Remember_Impl( aStr, true );
1374  aStr = m_xReplaceLB->get_active_text();
1375 
1376  if ( !aStr.isEmpty() )
1377  Remember_Impl( aStr, false );
1378  }
1379  SaveToModule_Impl();
1380  Close();
1381  }
1382  else if (&rBtn == m_xSimilarityBtn.get())
1383  {
1386  pSearchItem->IsLEVRelaxed(),
1387  pSearchItem->GetLEVOther(),
1388  pSearchItem->GetLEVShorter(),
1389  pSearchItem->GetLEVLonger() ));
1390  if ( executeSubDialog(pDlg.get()) == RET_OK )
1391  {
1392  pSearchItem->SetLEVRelaxed( pDlg->IsRelaxed() );
1393  pSearchItem->SetLEVOther( pDlg->GetOther() );
1394  pSearchItem->SetLEVShorter( pDlg->GetShorter() );
1395  pSearchItem->SetLEVLonger( pDlg->GetLonger() );
1396  SaveToModule_Impl();
1397  }
1398  }
1399  else if (&rBtn == m_xJapOptionsBtn.get())
1400  {
1401  SfxItemSet aSet( SfxGetpApp()->GetPool() );
1402  pSearchItem->SetTransliterationFlags( GetTransliterationFlags() );
1405  pSearchItem->GetTransliterationFlags() ));
1406  int nRet = executeSubDialog(aDlg.get());
1407  if (RET_OK == nRet)
1408  {
1410  pSearchItem->SetTransliterationFlags( nFlags );
1411  ApplyTransliterationFlags_Impl( nFlags );
1412  }
1413  }
1414  else if (&rBtn == m_xSearchComponent1PB.get() || &rBtn == m_xSearchComponent2PB.get())
1415  {
1416  uno::Sequence < beans::PropertyValue > aArgs(2);
1417  beans::PropertyValue* pArgs = aArgs.getArray();
1418  pArgs[0].Name = "SearchString";
1419  pArgs[0].Value <<= m_xSearchLB->get_active_text();
1420  pArgs[1].Name = "ParentWindow";
1421  pArgs[1].Value <<= m_xDialog->GetXWindow();
1422  if (&rBtn == m_xSearchComponent1PB.get())
1423  {
1424  if ( pImpl->xCommand1Dispatch.is() )
1425  pImpl->xCommand1Dispatch->dispatch(pImpl->aCommand1URL, aArgs);
1426  }
1427  else
1428  {
1429  if ( pImpl->xCommand2Dispatch.is() )
1430  pImpl->xCommand2Dispatch->dispatch(pImpl->aCommand2URL, aArgs);
1431  }
1432  }
1433 }
1434 
1435 
1436 IMPL_LINK( SvxSearchDialog, ModifyHdl_Impl, weld::ComboBox&, rEd, void )
1437 {
1438  if ( !bSet )
1439  SetModifyFlag_Impl( &rEd );
1440  else
1441  bSet = false;
1442 
1443  // Calc allows searching for empty cells.
1444  bool bAllowEmptySearch = (pSearchItem->GetAppFlag() == SvxSearchApp::CALC);
1445 
1446  if (&rEd != m_xSearchLB.get() && &rEd != m_xReplaceLB.get())
1447  return;
1448 
1449  sal_Int32 nSrchTxtLen = m_xSearchLB->get_active_text().getLength();
1450  sal_Int32 nReplTxtLen = 0;
1451  if (bAllowEmptySearch)
1452  nReplTxtLen = m_xReplaceLB->get_active_text().getLength();
1453  sal_Int32 nAttrTxtLen = m_xSearchAttrText->get_label().getLength();
1454 
1455  if (nSrchTxtLen || nReplTxtLen || nAttrTxtLen)
1456  {
1457  EnableControl_Impl(*m_xSearchBtn);
1458  EnableControl_Impl(*m_xBackSearchBtn);
1459  EnableControl_Impl(*m_xReplaceBtn);
1460  if (!bWriter || !m_xNotesBtn->get_active())
1461  {
1462  EnableControl_Impl(*m_xSearchAllBtn);
1463  EnableControl_Impl(*m_xReplaceAllBtn);
1464  }
1465  }
1466  else
1467  {
1468  m_xComponentFrame->set_sensitive(false);
1469  m_xSearchBtn->set_sensitive(false);
1470  m_xBackSearchBtn->set_sensitive(false);
1471  m_xSearchAllBtn->set_sensitive(false);
1472  m_xReplaceBtn->set_sensitive(false);
1473  m_xReplaceAllBtn->set_sensitive(false);
1474  }
1475 }
1476 
1478 {
1479  if ( pImpl->bSaveToModule )
1480  SaveToModule_Impl();
1481 
1482  if ( bFormat )
1483  return;
1484  OUString sDesc;
1485 
1486  if ( m_xLayoutBtn->get_active() )
1487  {
1488  if ( !pFamilyController )
1489  {
1490  sal_uInt16 nId = 0;
1491 
1492  // Enable templates controller
1493  switch ( pSearchItem->GetFamily() )
1494  {
1495  case SfxStyleFamily::Char:
1496  nId = SID_STYLE_FAMILY1; break;
1497 
1498  case SfxStyleFamily::Para:
1499  nId = SID_STYLE_FAMILY2; break;
1500 
1501  case SfxStyleFamily::Frame:
1502  nId = SID_STYLE_FAMILY3; break;
1503 
1504  case SfxStyleFamily::Page:
1505  nId = SID_STYLE_FAMILY4; break;
1506 
1507  case SfxStyleFamily::All:
1508  break;
1509 
1510  default:
1511  OSL_FAIL( "StyleSheetFamily was changed?" );
1512  }
1513 
1514  rBindings.EnterRegistrations();
1515  pFamilyController.reset(
1516  new SvxSearchController( nId, rBindings, *this ) );
1517  rBindings.LeaveRegistrations();
1518  m_xSearchTmplLB->clear();
1519  m_xReplaceTmplLB->clear();
1520 
1521  m_xSearchTmplLB->show();
1522  m_xReplaceTmplLB->show();
1523  m_xSearchLB->hide();
1524  m_xReplaceLB->hide();
1525 
1526  m_xSearchAttrText->set_label( sDesc );
1527  m_xReplaceAttrText->set_label( sDesc );
1528 
1529  if(!sDesc.isEmpty())
1530  {
1531  if (!m_xReplaceAttrText->get_visible() || !m_xReplaceAttrText->get_visible())
1532  {
1533  m_xSearchAttrText->show();
1534  m_xReplaceAttrText->show();
1535  m_xDialog->resize_to_request();
1536  }
1537  }
1538  }
1539  m_xFormatBtn->set_sensitive(false);
1540  m_xNoFormatBtn->set_sensitive(false);
1541  m_xAttributeBtn->set_sensitive(false);
1542  m_xSimilarityBox->set_sensitive(false);
1543  m_xSimilarityBtn->set_sensitive(false);
1544  }
1545  else
1546  {
1547  // Disable templates controller
1548  rBindings.EnterRegistrations();
1549  pFamilyController.reset();
1550  rBindings.LeaveRegistrations();
1551 
1552  m_xSearchLB->show();
1553  m_xReplaceLB->show();
1554  m_xSearchTmplLB->hide();
1555  m_xReplaceTmplLB->hide();
1556 
1557  m_xSearchAttrText->set_label( BuildAttrText_Impl( sDesc, true ) );
1558  m_xReplaceAttrText->set_label( BuildAttrText_Impl( sDesc, false ) );
1559 
1560  if(!sDesc.isEmpty())
1561  {
1562  if (!m_xReplaceAttrText->get_visible() || !m_xReplaceAttrText->get_visible())
1563  {
1564  m_xSearchAttrText->show();
1565  m_xReplaceAttrText->show();
1566  m_xDialog->resize_to_request();
1567  }
1568  }
1569 
1570  EnableControl_Impl(*m_xFormatBtn);
1571  EnableControl_Impl(*m_xAttributeBtn);
1572  EnableControl_Impl(*m_xSimilarityBox);
1573 
1574  FocusHdl_Impl( bSearch ? *m_xSearchLB : *m_xReplaceLB );
1575  }
1576  bSet = true;
1577  pImpl->bSaveToModule = false;
1578  FlagHdl_Impl(*m_xLayoutBtn);
1579  pImpl->bSaveToModule = true;
1580 }
1581 
1582 void SvxSearchDialog::Remember_Impl( const OUString &rStr, bool _bSearch )
1583 {
1584  if ( rStr.isEmpty() )
1585  return;
1586 
1587  std::vector<OUString>* pArr = _bSearch ? &aSearchStrings : &aReplaceStrings;
1588  weld::ComboBox* pListBox = _bSearch ? m_xSearchLB.get() : m_xReplaceLB.get();
1589 
1590  // ignore identical strings
1591  if (std::find(pArr->begin(), pArr->end(), rStr) != pArr->end())
1592  return;
1593 
1594  pArr->insert(pArr->begin(), rStr);
1595  pListBox->insert_text(0, rStr);
1596 
1597  // delete oldest entry at maximum occupancy (ListBox and Array)
1598  size_t nArrSize = pArr->size();
1599  if (nArrSize > nRememberSize)
1600  {
1601  pListBox->remove(nArrSize - 1);
1602  pArr->erase(pArr->begin() + nArrSize - 1);
1603  }
1604 }
1605 
1607 {
1608  OUString aOldSrch( m_xSearchTmplLB->get_active_text() );
1609  OUString aOldRepl( m_xReplaceTmplLB->get_active_text() );
1610  m_xSearchTmplLB->clear();
1611  m_xReplaceTmplLB->clear();
1612  m_xSearchTmplLB->freeze();
1613  m_xReplaceTmplLB->freeze();
1614  SfxStyleSheetBase* pBase = rPool.First(pSearchItem->GetFamily());
1615 
1616  while ( pBase )
1617  {
1618  if ( pBase->IsUsed() )
1619  m_xSearchTmplLB->append_text( pBase->GetName() );
1620  m_xReplaceTmplLB->append_text( pBase->GetName() );
1621  pBase = rPool.Next();
1622  }
1623  m_xSearchTmplLB->thaw();
1624  m_xReplaceTmplLB->thaw();
1625  m_xSearchTmplLB->set_active(0);
1626 
1627  if ( !aOldSrch.isEmpty() )
1628  m_xSearchTmplLB->set_active_text( aOldSrch );
1629  m_xReplaceTmplLB->set_active(0);
1630 
1631  if ( !aOldRepl.isEmpty() )
1632  m_xReplaceTmplLB->set_active_text( aOldRepl );
1633 
1634  if ( m_xSearchTmplLB->get_count() )
1635  {
1641  }
1642 }
1643 
1644 
1646 {
1647  if ( nFlags == nOptions )
1648  return;
1649  else
1650  nOptions = nFlags;
1651 
1652  bool bNoSearch = true;
1653 
1654  bool bEnableSearch = bool( SearchOptionFlags::SEARCH & nOptions );
1655  m_xSearchBtn->set_sensitive(bEnableSearch);
1656  m_xBackSearchBtn->set_sensitive(bEnableSearch);
1657 
1658  if( bEnableSearch )
1659  bNoSearch = false;
1660 
1661 
1662  if ( SearchOptionFlags::SEARCHALL & nOptions )
1663  {
1664  m_xSearchAllBtn->set_sensitive(true);
1665  bNoSearch = false;
1666  }
1667  else
1668  m_xSearchAllBtn->set_sensitive(false);
1669  if ( SearchOptionFlags::REPLACE & nOptions )
1670  {
1671  m_xReplaceBtn->set_sensitive(true);
1672  m_xReplaceFrame->set_sensitive(true);
1673  m_xReplaceLB->set_sensitive(true);
1674  m_xReplaceTmplLB->set_sensitive(true);
1675  bNoSearch = false;
1676  }
1677  else
1678  {
1679  m_xReplaceBtn->set_sensitive(false);
1680  m_xReplaceFrame->set_sensitive(false);
1681  m_xReplaceLB->set_sensitive(false);
1682  m_xReplaceTmplLB->set_sensitive(false);
1683  }
1684  if ( SearchOptionFlags::REPLACE_ALL & nOptions )
1685  {
1686  m_xReplaceAllBtn->set_sensitive(true);
1687  bNoSearch = false;
1688  }
1689  else
1690  m_xReplaceAllBtn->set_sensitive(false);
1691  m_xComponentFrame->set_sensitive(!bNoSearch);
1692  m_xSearchBtn->set_sensitive( !bNoSearch );
1693  m_xBackSearchBtn->set_sensitive( !bNoSearch );
1694  m_xSearchFrame->set_sensitive( !bNoSearch );
1695  m_xSearchLB->set_sensitive( !bNoSearch );
1696  m_xNotesBtn->set_sensitive(true);
1697 
1698  if ( SearchOptionFlags::WHOLE_WORDS & nOptions )
1699  m_xWordBtn->set_sensitive(true);
1700  else
1701  m_xWordBtn->set_sensitive(false);
1702  if ( SearchOptionFlags::BACKWARDS & nOptions )
1703  {
1704  m_xBackSearchBtn->set_sensitive(true);
1705  m_xReplaceBackwardsCB->set_sensitive(true);
1706  }
1707  else
1708  {
1709  m_xBackSearchBtn->set_sensitive(false);
1710  m_xReplaceBackwardsCB->set_sensitive(false);
1711  }
1712  if ( SearchOptionFlags::REG_EXP & nOptions )
1713  m_xRegExpBtn->set_sensitive(true);
1714  else
1715  m_xRegExpBtn->set_sensitive(false);
1716  if ( SearchOptionFlags::WILDCARD & nOptions )
1717  m_xWildcardBtn->set_sensitive(true);
1718  else
1719  m_xWildcardBtn->set_sensitive(false);
1720  if ( SearchOptionFlags::EXACT & nOptions )
1721  m_xMatchCaseCB->set_sensitive(true);
1722  else
1723  m_xMatchCaseCB->set_sensitive(false);
1724  if ( SearchOptionFlags::SELECTION & nOptions )
1725  m_xSelectionBtn->set_sensitive(true);
1726  else
1727  m_xSelectionBtn->set_sensitive(false);
1728  if ( SearchOptionFlags::FAMILIES & nOptions )
1729  m_xLayoutBtn->set_sensitive(true);
1730  else
1731  m_xLayoutBtn->set_sensitive(false);
1732  if ( SearchOptionFlags::FORMAT & nOptions )
1733  {
1734  m_xAttributeBtn->set_sensitive(true);
1735  m_xFormatBtn->set_sensitive(true);
1736  m_xNoFormatBtn->set_sensitive(true);
1737  }
1738  else
1739  {
1740  m_xAttributeBtn->set_sensitive(false);
1741  m_xFormatBtn->set_sensitive(false);
1742  m_xNoFormatBtn->set_sensitive(false);
1743  }
1744 
1745  if ( SearchOptionFlags::SIMILARITY & nOptions )
1746  {
1747  m_xSimilarityBox->set_sensitive(true);
1748  m_xSimilarityBtn->set_sensitive(true);
1749  }
1750  else
1751  {
1752  m_xSimilarityBox->set_sensitive(false);
1753  m_xSimilarityBtn->set_sensitive(false);
1754  }
1755 
1756  if ( pSearchItem )
1757  Init_Impl( pSearchItem->GetPattern() &&
1758  ( !pSearchList || !pSearchList->Count() ) );
1759 }
1760 
1762 {
1763  if (m_xSearchBtn.get() == &rCtrl && ( SearchOptionFlags::SEARCH & nOptions ) )
1764  {
1765  m_xComponentFrame->set_sensitive(true);
1766  m_xSearchBtn->set_sensitive(true);
1767  return;
1768  }
1769  if ( m_xSearchAllBtn.get() == &rCtrl &&
1770  ( SearchOptionFlags::SEARCHALL & nOptions ) )
1771  {
1772  m_xSearchAllBtn->set_sensitive(true);
1773  return;
1774  }
1775  if ( m_xReplaceBtn.get() == &rCtrl && ( SearchOptionFlags::REPLACE & nOptions ) )
1776  {
1777  m_xReplaceBtn->set_sensitive(true);
1778  return;
1779  }
1780  if ( m_xReplaceAllBtn.get() == &rCtrl &&
1781  ( SearchOptionFlags::REPLACE_ALL & nOptions ) )
1782  {
1783  m_xReplaceAllBtn->set_sensitive(true);
1784  return;
1785  }
1786  if ( m_xWordBtn.get() == &rCtrl && ( SearchOptionFlags::WHOLE_WORDS & nOptions ) )
1787  {
1788  m_xWordBtn->set_sensitive(true);
1789  return;
1790  }
1791  if ( SearchOptionFlags::BACKWARDS & nOptions )
1792  {
1793  if( m_xBackSearchBtn.get() == &rCtrl )
1794  {
1795  m_xBackSearchBtn->set_sensitive(true);
1796  return;
1797  }
1798  else if ( m_xReplaceBackwardsCB.get() == &rCtrl )
1799  {
1800  m_xReplaceBackwardsCB->set_sensitive(true);
1801  return;
1802  }
1803  }
1804  if (m_xNotesBtn.get() == &rCtrl)
1805  {
1806  m_xNotesBtn->set_sensitive(true);
1807  return;
1808  }
1809  if ( m_xRegExpBtn.get() == &rCtrl && ( SearchOptionFlags::REG_EXP & nOptions )
1810  && !m_xSimilarityBox->get_active() && !m_xWildcardBtn->get_active())
1811  {
1812  m_xRegExpBtn->set_sensitive(true);
1813  return;
1814  }
1815  if ( m_xWildcardBtn.get() == &rCtrl && ( SearchOptionFlags::WILDCARD & nOptions )
1816  && !m_xSimilarityBox->get_active() && !m_xRegExpBtn->get_active())
1817  {
1818  m_xWildcardBtn->set_sensitive(true);
1819  return;
1820  }
1821  if ( m_xMatchCaseCB.get() == &rCtrl && ( SearchOptionFlags::EXACT & nOptions ) )
1822  {
1823  if (!m_xJapOptionsCB->get_active())
1824  m_xMatchCaseCB->set_sensitive(true);
1825  return;
1826  }
1827  if ( m_xSelectionBtn.get() == &rCtrl && ( SearchOptionFlags::SELECTION & nOptions ) )
1828  {
1829  m_xSelectionBtn->set_sensitive(true);
1830  return;
1831  }
1832  if ( m_xLayoutBtn.get() == &rCtrl && ( SearchOptionFlags::FAMILIES & nOptions ) )
1833  {
1834  m_xLayoutBtn->set_sensitive(true);
1835  return;
1836  }
1837  if ( m_xAttributeBtn.get() == &rCtrl
1838  && ( SearchOptionFlags::FORMAT & nOptions )
1839  && pSearchList )
1840  {
1841  m_xAttributeBtn->set_sensitive( pImpl->bFocusOnSearch );
1842  }
1843  if ( m_xFormatBtn.get() == &rCtrl && ( SearchOptionFlags::FORMAT & nOptions ) )
1844  {
1845  m_xFormatBtn->set_sensitive(true);
1846  return;
1847  }
1848  if ( m_xNoFormatBtn.get() == &rCtrl && ( SearchOptionFlags::FORMAT & nOptions ) )
1849  {
1850  m_xNoFormatBtn->set_sensitive(true);
1851  return;
1852  }
1853  if ( m_xSimilarityBox.get() == &rCtrl && ( SearchOptionFlags::SIMILARITY & nOptions )
1854  && !m_xRegExpBtn->get_active() && !m_xWildcardBtn->get_active())
1855  {
1856  m_xSimilarityBox->set_sensitive(true);
1857 
1858  if ( m_xSimilarityBox->get_active() )
1859  m_xSimilarityBtn->set_sensitive(true);
1860  }
1861 }
1862 
1864 {
1865  //TODO: save pItem and process later if m_executingSubDialog?
1866  if ( pItem && !m_executingSubDialog )
1867  {
1868  pSearchItem.reset(pItem->Clone());
1869  Init_Impl( pSearchItem->GetPattern() &&
1870  ( !pSearchList || !pSearchList->Count() ) );
1871  }
1872 }
1873 
1874 IMPL_LINK(SvxSearchDialog, FocusHdl_Impl, weld::Widget&, rControl, void)
1875 {
1876  sal_Int32 nTxtLen = m_xSearchAttrText->get_label().getLength();
1877  weld::Widget* pCtrl = &rControl;
1878  if (pCtrl == m_xSearchLB.get())
1879  {
1880  if (pCtrl->has_focus())
1881  pImpl->bFocusOnSearch = true;
1882  pCtrl = m_xSearchLB.get();
1883  bSearch = true;
1884 
1885  if( nTxtLen )
1886  EnableControl_Impl(*m_xNoFormatBtn);
1887  else
1888  m_xNoFormatBtn->set_sensitive(false);
1889  EnableControl_Impl(*m_xAttributeBtn);
1890  }
1891  else
1892  {
1893  pImpl->bFocusOnSearch = false;
1894  pCtrl = m_xReplaceLB.get();
1895  bSearch = false;
1896 
1897  if (!m_xReplaceAttrText->get_label().isEmpty())
1898  EnableControl_Impl(*m_xNoFormatBtn);
1899  else
1900  m_xNoFormatBtn->set_sensitive(false);
1901  m_xAttributeBtn->set_sensitive(false);
1902  }
1903  bSet = true;
1904 
1905  weld::ComboBox &rComboBox = dynamic_cast<weld::ComboBox&>(*pCtrl);
1906  rComboBox.select_entry_region(0, -1);
1907  ModifyHdl_Impl(rComboBox);
1908 
1909  if (bFormat && nTxtLen)
1910  m_xLayoutBtn->set_label(aLayoutStr);
1911  else
1912  {
1913  SvtModuleOptions::EFactory eFactory = getModule(rBindings);
1914  bool bWriterApp =
1915  eFactory == SvtModuleOptions::EFactory::WRITER ||
1918  bool bCalcApp = eFactory == SvtModuleOptions::EFactory::CALC;
1919 
1920  if (bWriterApp)
1921  m_xLayoutBtn->set_label(aLayoutWriterStr);
1922  else
1923  {
1924  if (bCalcApp)
1925  m_xLayoutBtn->set_label(aLayoutCalcStr);
1926  else
1927  m_xLayoutBtn->set_label(aStylesStr);
1928  }
1929  }
1930 }
1931 
1932 IMPL_LINK_NOARG(SvxSearchDialog, LoseFocusHdl_Impl, weld::Widget&, void)
1933 {
1934  SaveToModule_Impl();
1935 }
1936 
1938 {
1940 
1941  DBG_ASSERT( pSh, "no DocShell" );
1942 
1943  if ( !pSh || pImpl->pRanges.empty() )
1944  return;
1945 
1946  SfxItemPool& rPool = pSh->GetPool();
1947  SfxItemSet aSet(rPool, pImpl->pRanges);
1948 
1949  aSet.MergeRange(SID_ATTR_PARA_MODEL, SID_ATTR_PARA_MODEL);
1950 
1951  sal_uInt16 nBrushWhich = pSh->GetPool().GetWhich(SID_ATTR_BRUSH);
1952  aSet.MergeRange(nBrushWhich, nBrushWhich);
1953 
1955 
1956  OUString aTxt;
1957 
1958  aSet.InvalidateAllItems();
1959  aSet.Put(SvxBrushItem(nBrushWhich));
1960 
1961  if ( bSearch )
1962  {
1963  aTxt = SvxResId( RID_SVXSTR_SEARCH );
1964  pSearchList->Get( aSet );
1965  }
1966  else
1967  {
1968  aTxt = SvxResId( RID_SVXSTR_REPLACE );
1969  pReplaceList->Get( aSet );
1970  }
1971  aSet.DisableItem(SID_ATTR_PARA_MODEL);
1972  aSet.DisableItem(rPool.GetWhich(SID_ATTR_PARA_PAGEBREAK));
1973  aSet.DisableItem(rPool.GetWhich(SID_ATTR_PARA_KEEP));
1974 
1975 
1978  pDlg->SetText( aTxt );
1979 
1980  if ( executeSubDialog(pDlg.get()) != RET_OK )
1981  return;
1982 
1983  DBG_ASSERT( pDlg->GetOutputItemSet(), "invalid Output-Set" );
1984  SfxItemSet aOutSet( *pDlg->GetOutputItemSet() );
1985 
1986  SearchAttrItemList* pList = bSearch ? pSearchList.get() : pReplaceList.get();
1987 
1988  const SfxPoolItem* pItem;
1989  for( sal_uInt16 n = 0; n < pList->Count(); ++n )
1990  {
1991  SearchAttrItem* pAItem = &pList->GetObject(n);
1992  if( !IsInvalidItem( pAItem->pItem ) &&
1993  SfxItemState::SET == aOutSet.GetItemState(
1994  pAItem->pItem->Which(), false, &pItem ) )
1995  {
1996  delete pAItem->pItem;
1997  pAItem->pItem = pItem->Clone();
1998  aOutSet.ClearItem( pAItem->pItem->Which() );
1999  }
2000  }
2001 
2002  if( aOutSet.Count() )
2003  pList->Put( aOutSet );
2004 
2005  PaintAttrText_Impl(); // Set AttributText in GroupBox
2006 }
2007 
2009 {
2010  SvtModuleOptions::EFactory eFactory = getModule(rBindings);
2011  bool bWriterApp =
2012  eFactory == SvtModuleOptions::EFactory::WRITER ||
2015  bool bCalcApp = eFactory == SvtModuleOptions::EFactory::CALC;
2016 
2017  if (bCalcApp)
2018  m_xLayoutBtn->set_label( aLayoutCalcStr );
2019  else
2020  {
2021  if (bWriterApp)
2022  m_xLayoutBtn->set_label( aLayoutWriterStr);
2023  else
2024  m_xLayoutBtn->set_label( aStylesStr );
2025  }
2026 
2027  bFormat = false;
2028  m_xLayoutBtn->set_active( false );
2029 
2030  bool bSetOptimalLayoutSize = false;
2031 
2032  if ( bSearch )
2033  {
2034  pSearchList->Clear();
2035  m_xSearchAttrText->set_label( "" );
2036  if (m_xSearchAttrText->get_visible())
2037  {
2038  m_xSearchAttrText->hide();
2039  bSetOptimalLayoutSize = true;
2040  }
2041  }
2042  else
2043  {
2044  pReplaceList->Clear();
2045  m_xReplaceAttrText->set_label( "" );
2046  if (m_xReplaceAttrText->get_visible())
2047  {
2048  m_xReplaceAttrText->hide();
2049  bSetOptimalLayoutSize = true;
2050  }
2051  }
2052 
2053  if (bSetOptimalLayoutSize)
2054  m_xDialog->resize_to_request();
2055 
2056  pImpl->bSaveToModule = false;
2057  TemplateHdl_Impl(*m_xLayoutBtn);
2058  pImpl->bSaveToModule = true;
2059  m_xNoFormatBtn->set_sensitive(false);
2060 }
2061 
2062 IMPL_LINK_NOARG(SvxSearchDialog, AttributeHdl_Impl, weld::Button&, void)
2063 {
2064  if ( !pSearchList || pImpl->pRanges.empty() )
2065  return;
2066 
2068  ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateSvxSearchAttributeDialog(m_xDialog.get(), *pSearchList, pImpl->pRanges));
2069  executeSubDialog(pDlg.get());
2070  PaintAttrText_Impl();
2071 }
2072 
2073 IMPL_LINK( SvxSearchDialog, TimeoutHdl_Impl, Timer *, pTimer, void )
2074 {
2075  SfxViewShell* pViewShell = SfxViewShell::Current();
2076 
2077  if ( pViewShell )
2078  {
2079  if ( pViewShell->HasSelection( m_xSearchLB->get_visible() ) )
2080  EnableControl_Impl(*m_xSelectionBtn);
2081  else
2082  {
2083  m_xSelectionBtn->set_active( false );
2084  m_xSelectionBtn->set_sensitive(false);
2085  }
2086  }
2087 
2088  pTimer->Start();
2089 }
2090 
2091 OUString& SvxSearchDialog::BuildAttrText_Impl( OUString& rStr,
2092  bool bSrchFlag ) const
2093 {
2094  rStr.clear();
2095 
2097  DBG_ASSERT( pSh, "no DocShell" );
2098 
2099  if ( !pSh )
2100  return rStr;
2101 
2102  SfxItemPool& rPool = pSh->GetPool();
2103  SearchAttrItemList* pList = bSrchFlag ? pSearchList.get() : pReplaceList.get();
2104 
2105  if ( !pList )
2106  return rStr;
2107 
2108  // Metric query
2109  MapUnit eMapUnit = MapUnit::MapCM;
2110  FieldUnit eFieldUnit = pSh->GetModule()->GetFieldUnit();
2111  switch ( eFieldUnit )
2112  {
2113  case FieldUnit::MM: eMapUnit = MapUnit::MapMM; break;
2114  case FieldUnit::CM:
2115  case FieldUnit::M:
2116  case FieldUnit::KM: eMapUnit = MapUnit::MapCM; break;
2117  case FieldUnit::TWIP: eMapUnit = MapUnit::MapTwip; break;
2118  case FieldUnit::POINT:
2119  case FieldUnit::PICA: eMapUnit = MapUnit::MapPoint; break;
2120  case FieldUnit::INCH:
2121  case FieldUnit::FOOT:
2122  case FieldUnit::MILE: eMapUnit = MapUnit::MapInch; break;
2123  case FieldUnit::MM_100TH: eMapUnit = MapUnit::Map100thMM; break;
2124  default: ;//prevent warning
2125  }
2126 
2127  IntlWrapper aIntlWrapper(SvtSysLocale().GetUILanguageTag());
2128  for ( sal_uInt16 i = 0; i < pList->Count(); ++i )
2129  {
2130  const SearchAttrItem& rItem = pList->GetObject(i);
2131 
2132  if ( !rStr.isEmpty() )
2133  rStr += ", ";
2134 
2135  if ( !IsInvalidItem( rItem.pItem ) )
2136  {
2137  OUString aStr;
2138  rPool.GetPresentation(*rItem.pItem, eMapUnit, aStr, aIntlWrapper);
2139  if (aStr.isEmpty())
2140  {
2141  if (rStr.endsWith(", "))
2142  rStr = rStr.copy(0, rStr.lastIndexOf(","));
2143  }
2144  else
2145  rStr += aStr;
2146  }
2147  else if ( rItem.nSlot == SID_ATTR_BRUSH_CHAR )
2148  {
2149  // Special treatment for text background
2150  rStr += SvxResId( RID_SVXITEMS_BRUSH_CHAR );
2151  }
2152  else
2153  {
2154  sal_uInt32 nId = SvxAttrNameTable::FindIndex(rItem.nSlot);
2155  if ( RESARRAY_INDEX_NOTFOUND != nId )
2156  rStr += SvxAttrNameTable::GetString(nId);
2157  }
2158  }
2159  return rStr;
2160 }
2161 
2162 
2164 {
2165  OUString aDesc;
2166  BuildAttrText_Impl( aDesc, bSearch );
2167 
2168  if ( !bFormat && !aDesc.isEmpty() )
2169  bFormat = true;
2170 
2171  bool bSetOptimalLayoutSize = false;
2172 
2173  if ( bSearch )
2174  {
2175  m_xSearchAttrText->set_label( aDesc );
2176  if (!aDesc.isEmpty() && !m_xSearchAttrText->get_visible())
2177  {
2178  m_xSearchAttrText->show();
2179  bSetOptimalLayoutSize = true;
2180  }
2181 
2182  FocusHdl_Impl(*m_xSearchLB);
2183  }
2184  else
2185  {
2186  m_xReplaceAttrText->set_label( aDesc );
2187  if (!aDesc.isEmpty() && !m_xReplaceAttrText->get_visible())
2188  {
2189  m_xReplaceAttrText->show();
2190  bSetOptimalLayoutSize = true;
2191  }
2192 
2193  FocusHdl_Impl(*m_xReplaceLB);
2194  }
2195 
2196  if (bSetOptimalLayoutSize)
2197  m_xDialog->resize_to_request();
2198 }
2199 
2201 {
2202  if (m_xSearchLB.get() == pCtrl)
2203  {
2205  m_xSearchLB->set_entry_message_type(weld::EntryMessageType::Normal);
2207  }
2208  else if ( m_xReplaceLB.get() == pCtrl )
2210  else if ( m_xWordBtn.get() == pCtrl )
2212  else if ( m_xMatchCaseCB.get() == pCtrl )
2214  else if ( m_xReplaceBackwardsCB.get() == pCtrl )
2216  else if ( m_xNotesBtn.get() == pCtrl )
2218  else if ( m_xSelectionBtn.get() == pCtrl )
2220  else if ( m_xRegExpBtn.get() == pCtrl )
2222  else if ( m_xWildcardBtn.get() == pCtrl )
2224  else if ( m_xLayoutBtn.get() == pCtrl )
2226  else if ( m_xSimilarityBox.get() == pCtrl )
2228  else if ( m_xCalcSearchInLB.get() == pCtrl )
2229  {
2233  }
2234  else if ( m_xRowsBtn.get() == pCtrl )
2236  else if ( m_xColumnsBtn.get() == pCtrl )
2238  else if ( m_xAllSheetsCB.get() == pCtrl )
2240 }
2241 
2243 {
2244  if ( !pSearchItem )
2245  return;
2246 
2247  if ( m_xLayoutBtn->get_active() )
2248  {
2249  pSearchItem->SetSearchString ( m_xSearchTmplLB->get_active_text() );
2250  pSearchItem->SetReplaceString( m_xReplaceTmplLB->get_active_text() );
2251  }
2252  else
2253  {
2254  pSearchItem->SetSearchString ( m_xSearchLB->get_active_text() );
2255  pSearchItem->SetReplaceString( m_xReplaceLB->get_active_text() );
2256  Remember_Impl( m_xSearchLB->get_active_text(), true );
2257  }
2258 
2259  pSearchItem->SetRegExp( false );
2260  pSearchItem->SetWildcard( false );
2261  pSearchItem->SetLevenshtein( false );
2262  if (GetCheckBoxValue(*m_xRegExpBtn))
2263  pSearchItem->SetRegExp( true );
2264  else if (GetCheckBoxValue(*m_xWildcardBtn))
2265  pSearchItem->SetWildcard( true );
2266  else if (GetCheckBoxValue(*m_xSimilarityBox))
2267  pSearchItem->SetLevenshtein( true );
2268 
2269  pSearchItem->SetWordOnly(GetCheckBoxValue(*m_xWordBtn));
2270  pSearchItem->SetBackward(GetCheckBoxValue(*m_xReplaceBackwardsCB));
2271  pSearchItem->SetNotes(GetCheckBoxValue(*m_xNotesBtn));
2272  pSearchItem->SetPattern(GetCheckBoxValue(*m_xLayoutBtn));
2273  pSearchItem->SetSelection(GetCheckBoxValue(*m_xSelectionBtn));
2274  pSearchItem->SetUseAsianOptions(GetCheckBoxValue(*m_xJapOptionsCB));
2275 
2276  SvtSearchOptions aOpt;
2277  aOpt.SetIgnoreDiacritics_CTL(GetNegatedCheckBoxValue(*m_xIncludeDiacritics));
2278  aOpt.SetIgnoreKashida_CTL(GetNegatedCheckBoxValue(*m_xIncludeKashida));
2279  aOpt.Commit();
2280 
2282  if( !pSearchItem->IsUseAsianOptions())
2283  nFlags &= TransliterationFlags::IGNORE_CASE |
2284  TransliterationFlags::IGNORE_WIDTH;
2285  if (GetNegatedCheckBoxValue(*m_xIncludeDiacritics))
2286  nFlags |= TransliterationFlags::IGNORE_DIACRITICS_CTL;
2287  if (GetNegatedCheckBoxValue(*m_xIncludeKashida))
2288  nFlags |= TransliterationFlags::IGNORE_KASHIDA_CTL;
2289  pSearchItem->SetTransliterationFlags( nFlags );
2290 
2291  if ( !bWriter )
2292  {
2293  if (m_xCalcSearchInLB->get_active() != -1)
2294  pSearchItem->SetCellType( static_cast<SvxSearchCellType>(m_xCalcSearchInLB->get_active()) );
2295 
2296  pSearchItem->SetRowDirection( m_xRowsBtn->get_active() );
2297  pSearchItem->SetAllTables( m_xAllSheetsCB->get_active() );
2298  pSearchItem->SetSearchFormatted( m_xSearchFormattedCB->get_active() );
2299  }
2300 
2301  pSearchItem->SetCommand( SvxSearchCmd::FIND );
2303  const SfxPoolItem* ppArgs[] = { pSearchItem.get(), nullptr };
2304  rBindings.GetDispatcher()->Execute( SID_SEARCH_ITEM, SfxCallMode::SLOT, ppArgs );
2305 }
2306 
2308  assert(!m_executingSubDialog);
2309  comphelper::ScopeGuard g([this] { m_executingSubDialog = false; });
2310  m_executingSubDialog = true;
2311  return dialog->Execute();
2312 }
2313 
2315 
2316 
2318  SfxBindings* pBindings,
2319  SfxChildWinInfo const * pInfo )
2320  : SfxChildWindow( _pParent, nId )
2321  , dialog(std::make_shared<SvxSearchDialog>(_pParent->GetFrameWeld(), this, *pBindings))
2322 {
2324  dialog->Initialize( pInfo );
2325 
2326  pBindings->Update( SID_SEARCH_ITEM );
2327  pBindings->Update( SID_SEARCH_OPTIONS );
2328  pBindings->Update( SID_SEARCH_SEARCHSET );
2329  pBindings->Update( SID_SEARCH_REPLACESET );
2330  dialog->bConstruct = false;
2331 }
2332 
2334 {
2335 }
2336 
2337 
2339 {
2341  aInfo.bVisible = false;
2342  return aInfo;
2343 }
2344 
2345 static void lcl_SetSearchLabelWindow(const OUString& rStr)
2346 {
2347  SfxViewFrame* pViewFrame = SfxViewFrame::Current();
2348  if (!pViewFrame)
2349  return;
2350 
2351  bool bNotFound = rStr == SvxResId(RID_SVXSTR_SEARCH_NOT_FOUND);
2352 
2353  css::uno::Reference< css::beans::XPropertySet > xPropSet(
2354  pViewFrame->GetFrame().GetFrameInterface(), css::uno::UNO_QUERY_THROW);
2355  css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
2356  xPropSet->getPropertyValue("LayoutManager") >>= xLayoutManager;
2357  css::uno::Reference< css::ui::XUIElement > xUIElement =
2358  xLayoutManager->getElement("private:resource/toolbar/findbar");
2359  if (!xUIElement.is())
2360  return;
2361  css::uno::Reference< css::awt::XWindow > xWindow(
2362  xUIElement->getRealInterface(), css::uno::UNO_QUERY_THROW);
2363  VclPtr< ToolBox > pToolBox = static_cast<ToolBox*>( VCLUnoHelper::GetWindow(xWindow) );
2364  for (ToolBox::ImplToolItems::size_type i = 0; pToolBox && i < pToolBox->GetItemCount(); ++i)
2365  {
2366  ToolBoxItemId id = pToolBox->GetItemId(i);
2367  if (pToolBox->GetItemCommand(id) == ".uno:SearchLabel")
2368  {
2369  LabelItemWindow* pSearchLabel = dynamic_cast<LabelItemWindow*>(pToolBox->GetItemWindow(id));
2370  assert(pSearchLabel);
2371  pSearchLabel->set_label(rStr);
2372  if (rStr.isEmpty())
2373  pSearchLabel->SetSizePixel(Size(16, pSearchLabel->GetSizePixel().Height()));
2374  else
2375  pSearchLabel->SetOptimalSize();
2376  }
2377 
2378  if (pToolBox->GetItemCommand(id) == ".uno:FindText")
2379  {
2380  FindTextFieldControl* pFindText = dynamic_cast<FindTextFieldControl*>(pToolBox->GetItemWindow(id));
2381  assert(pFindText);
2382  if (bNotFound)
2384  else
2386  }
2387  }
2388  xLayoutManager->doLayout();
2389  pToolBox->Resize();
2390 }
2391 
2393 {
2394  SfxViewFrame* pViewFrame = SfxViewFrame::Current();
2395  if (!pViewFrame)
2396  return OUString();
2397 
2398  css::uno::Reference< css::beans::XPropertySet > xPropSet(
2399  pViewFrame->GetFrame().GetFrameInterface(), css::uno::UNO_QUERY_THROW);
2400  css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
2401  xPropSet->getPropertyValue("LayoutManager") >>= xLayoutManager;
2402  if (!xLayoutManager.is())
2403  return OUString();
2404  css::uno::Reference< css::ui::XUIElement > xUIElement =
2405  xLayoutManager->getElement("private:resource/toolbar/findbar");
2406  if (!xUIElement.is())
2407  return OUString();
2408  css::uno::Reference< css::awt::XWindow > xWindow(
2409  xUIElement->getRealInterface(), css::uno::UNO_QUERY_THROW);
2410  VclPtr< ToolBox > pToolBox = static_cast<ToolBox*>( VCLUnoHelper::GetWindow(xWindow) );
2411  for (ToolBox::ImplToolItems::size_type i = 0; pToolBox && i < pToolBox->GetItemCount(); ++i)
2412  {
2413  ToolBoxItemId id = pToolBox->GetItemId(i);
2414  if (pToolBox->GetItemCommand(id) == ".uno:SearchLabel")
2415  {
2416  LabelItemWindow* pSearchLabel = dynamic_cast<LabelItemWindow*>(pToolBox->GetItemWindow(id));
2417  return pSearchLabel ? pSearchLabel->get_label() : OUString();
2418  }
2419  }
2420  return OUString();
2421 }
2422 
2424 {
2425  OUString sStr;
2426  if (rSL == SearchLabel::End)
2427  sStr = SvxResId(RID_SVXSTR_SEARCH_END);
2428  else if (rSL == SearchLabel::Start)
2429  sStr = SvxResId(RID_SVXSTR_SEARCH_START);
2430  else if (rSL == SearchLabel::EndWrapped)
2431  sStr = SvxResId(RID_SVXSTR_SEARCH_END_WRAPPED);
2432  else if (rSL == SearchLabel::StartWrapped)
2433  sStr = SvxResId(RID_SVXSTR_SEARCH_START_WRAPPED);
2434  else if (rSL == SearchLabel::EndSheet)
2435  sStr = SvxResId(RID_SVXSTR_SEARCH_END_SHEET);
2436  else if (rSL == SearchLabel::NotFound)
2437  sStr = SvxResId(RID_SVXSTR_SEARCH_NOT_FOUND);
2438  else if (rSL == SearchLabel::NavElementNotFound)
2439  sStr = SvxResId(RID_SVXSTR_SEARCH_NAV_ELEMENT_NOT_FOUND);
2440  else if (rSL == SearchLabel::ReminderEndWrapped)
2441  sStr = SvxResId(RID_SVXSTR_SEARCH_REMINDER_END_WRAPPED);
2442  else if (rSL == SearchLabel::ReminderStartWrapped)
2443  sStr = SvxResId(RID_SVXSTR_SEARCH_REMINDER_START_WRAPPED);
2444 
2446  if (SvxSearchDialogWrapper *pWrp = static_cast<SvxSearchDialogWrapper*>( SfxViewFrame::Current()->
2447  GetChildWindow( SvxSearchDialogWrapper::GetChildWindowId() )))
2448  pWrp->getDialog()->SetSearchLabel(sStr);
2449 }
2450 
2451 void SvxSearchDialogWrapper::SetSearchLabel(const OUString& sStr)
2452 {
2453 
2455  if (SvxSearchDialogWrapper *pWrp = static_cast<SvxSearchDialogWrapper*>( SfxViewFrame::Current()->
2456  GetChildWindow( SvxSearchDialogWrapper::GetChildWindowId() )))
2457  pWrp->getDialog()->SetSearchLabel(sStr);
2458 }
2459 
2460 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxStyleSheetBase * First(SfxStyleFamily eFamily, SfxStyleSearchBits eMask=SfxStyleSearchBits::All)
OUString aStylesStr
Definition: srchdlg.hxx:151
std::unique_ptr< weld::Button > m_xSearchComponent2PB
Definition: srchdlg.hxx:194
virtual bool IsUsed() const
FieldUnit
static EFactory ClassifyFactoryByServiceName(std::u16string_view sName)
util::URL aCommand1URL
Definition: srchdlg.cxx:135
std::unique_ptr< SearchAttrItemList > pReplaceList
Definition: srchdlg.hxx:163
virtual bool GetPresentation(const SfxPoolItem &rItem, MapUnit ePresentationMetric, OUString &rText, const IntlWrapper &rIntlWrapper) const
#define IS_MOBILE
Definition: srchdlg.cxx:87
uno::Reference< frame::XDispatch > xCommand2Dispatch
Definition: srchdlg.cxx:134
void SetSaveToModule(bool b)
Definition: srchdlg.cxx:569
std::unique_ptr< weld::Expander > m_xOtherOptionsExpander
Definition: srchdlg.hxx:203
void Remove(size_t nPos)
Definition: srchdlg.cxx:254
virtual void Activate() override
Definition: srchdlg.cxx:607
SVX_DLLPRIVATE void ClickHdl_Impl(const weld::Widget *pCtrl)
Definition: srchdlg.cxx:1128
std::unique_ptr< weld::Button > m_xSearchAllBtn
Definition: srchdlg.hxx:188
bool IsIgnoreKashida_CTL() const
SVX_DLLPRIVATE void EnableControls_Impl(const SearchOptionFlags nFlags)
Definition: srchdlg.cxx:1645
bool IsCJKFontEnabled()
std::unique_ptr< weld::Label > m_xReplaceAttrText
Definition: srchdlg.hxx:184
virtual const SfxItemSet * GetOutputItemSet() const =0
void insert_text(int pos, const OUString &rStr)
void set_entry_message_type(weld::EntryMessageType eType)
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
static SvxAbstractDialogFactory * Create()
Definition: svxdlg.cxx:22
std::unique_ptr< weld::ComboBox > m_xCalcSearchInLB
Definition: srchdlg.hxx:222
SfxPoolItem * pItem
Definition: srchdlg.hxx:44
Reference< XFrame > xFrame
css::uno::Reference< css::frame::XFrame > GetActiveFrame() const
sal_Int64 n
const WhichRangesContainer & GetRanges() const
SVX_DLLPRIVATE void TemplatesChanged_Impl(SfxStyleSheetBasePool &rPool)
Definition: srchdlg.cxx:1606
virtual Size GetSizePixel() const
virtual void SetSizePixel(const Size &rNewSize)
SearchOptionFlags nOptions
Definition: srchdlg.hxx:147
void InvalidateItem(sal_uInt16 nWhich)
sal_Int16 nId
const SfxItemSet & GetItemSet() const
void SetSimilaritySearch(bool bVal)
static OUString GetString(sal_uInt32 i)
Definition: strarray.cxx:43
SVX_DLLPRIVATE void Remember_Impl(const OUString &rStr, bool bSearch)
Definition: srchdlg.cxx:1582
SVX_DLLPRIVATE void PaintAttrText_Impl()
Definition: srchdlg.cxx:2163
void SetUseWildcard(bool bVal)
SVX_DLLPRIVATE void Construct_Impl()
Definition: srchdlg.cxx:388
std::vector< SearchAttrItem > SrchAttrItemList
Definition: srchdlg.hxx:47
static SfxObjectShell * Current()
SearchAttrItem & GetObject(sal_uInt16 nPos)
Definition: srchdlg.hxx:63
std::unique_ptr< weld::Button > m_xFormatBtn
Definition: srchdlg.hxx:217
TransliterationFlags nTransliterationFlags
Definition: srchdlg.hxx:171
std::shared_ptr< T > make_shared(Args &&...args)
SVX_DLLPRIVATE bool IsOtherOptionsExpanded() const
Definition: srchdlg.cxx:592
void Invalidate(sal_uInt16 nId)
void Put(const SfxItemSet &rSet)
Definition: srchdlg.cxx:198
bool IsCTLFontEnabled() const
virtual short Execute()=0
virtual VclPtr< SfxAbstractTabDialog > CreateTabItemDialog(weld::Window *pParent, const SfxItemSet &rSet)=0
void PutItem(const SfxPoolItem &rItem)
std::unique_ptr< weld::CheckButton > m_xIncludeKashida
Definition: srchdlg.hxx:202
#define RESARRAY_INDEX_NOTFOUND
static void StrArrToList_Impl(sal_uInt16 nId, const std::vector< OUString > &rStrLst)
Definition: srchdlg.cxx:171
SfxItemSet & Get(SfxItemSet &rSet)
Definition: srchdlg.cxx:231
SvxSearchDialogWrapper(vcl::Window *pParent, sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo const *pInfo)
Definition: srchdlg.cxx:2317
NONE
SfxApplication * SfxGetpApp()
SfxBindings & rBindings
Definition: srchdlg.hxx:141
virtual SfxStyleSheetBasePool * GetStyleSheetPool()
void ToggleChildWindow(sal_uInt16)
void Present()
Definition: srchdlg.cxx:364
static void ListToStrArr_Impl(sal_uInt16 nId, std::vector< OUString > &rStrLst, weld::ComboBox &rCBox, sal_uInt16 nRememberSize)
Definition: srchdlg.cxx:151
std::unique_ptr< weld::CheckButton > m_xRegExpBtn
Definition: srchdlg.hxx:205
SfxModule * GetModule() const
SVX_DLLPRIVATE OUString & BuildAttrText_Impl(OUString &rStr, bool bSrchFlag) const
Definition: srchdlg.cxx:2091
std::unique_ptr< weld::Frame > m_xComponentFrame
Definition: srchdlg.hxx:192
const SfxPoolItem * NextItem()
void MergeRange(sal_uInt16 nFrom, sal_uInt16 nTo)
SVX_DLLPRIVATE void SaveToModule_Impl()
Definition: srchdlg.cxx:2242
void SetUseRegularExpression(bool bVal)
virtual ~SvxSearchDialog() override
Definition: srchdlg.cxx:381
const OUString & GetName() const
std::unique_ptr< weld::CheckButton > m_xWordBtn
Definition: srchdlg.hxx:198
enumrange< T >::Iterator begin(enumrange< T >)
bool IsJapaneseFindEnabled()
std::vector< OUString > aReplaceStrings
Definition: srchdlg.hxx:159
static vcl::Window * GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
std::unique_ptr< weld::ComboBox > m_xSearchTmplLB
Definition: srchdlg.hxx:177
friend class SvxSearchController
Definition: srchdlg.hxx:112
SfxFrame & GetFrame() const
OUString SvxResId(TranslateId aId)
Definition: dialmgr.cxx:24
virtual void ChildWinDispose() override
Definition: srchdlg.cxx:371
SVX_DLLPRIVATE void ApplyTransliterationFlags_Impl(TransliterationFlags nSettings)
Definition: srchdlg.cxx:582
std::unique_ptr< weld::Widget > m_xCalcGrid
Definition: srchdlg.hxx:220
static SfxViewShell * Current()
Notes
std::unique_ptr< weld::CheckButton > m_xSimilarityBox
Definition: srchdlg.hxx:207
bool m_executingSubDialog
Definition: srchdlg.hxx:173
const SfxPoolItem * ExecuteSynchron(sal_uInt16 nSlot, const SfxPoolItem **pArgs=nullptr)
std::unique_ptr< weld::CheckButton > m_xReplaceBackwardsCB
Definition: srchdlg.hxx:213
std::unique_ptr< weld::ComboBox > m_xReplaceLB
Definition: srchdlg.hxx:182
void SetSearchLabel(const OUString &rStr)
Definition: srchdlg.cxx:574
std::unique_ptr< weld::CheckButton > m_xAllSheetsCB
Definition: srchdlg.hxx:226
std::unique_ptr< weld::Label > m_xCalcSearchInFT
Definition: srchdlg.hxx:221
std::unique_ptr< weld::Button > m_xBackSearchBtn
Definition: srchdlg.hxx:187
std::unique_ptr< weld::Button > m_xJapOptionsBtn
Definition: srchdlg.hxx:214
void SetIgnoreKashida_CTL(bool bVal)
std::unique_ptr< weld::CheckButton > m_xWildcardBtn
Definition: srchdlg.hxx:206
std::unique_ptr< weld::CheckButton > m_xSelectionBtn
Definition: srchdlg.hxx:204
TransliterationFlags
SfxItemPool & GetPool() const
std::unique_ptr< weld::CheckButton > m_xJapOptionsCB
Definition: srchdlg.hxx:212
void SetBackwards(bool bVal)
std::unique_ptr< weld::CheckButton > m_xIncludeDiacritics
Definition: srchdlg.hxx:201
sal_uInt16 nSlot
Definition: srchdlg.hxx:43
virtual VclPtr< VclAbstractDialog > CreateSvxSearchAttributeDialog(weld::Window *pParent, SearchAttrItemList &rLst, const WhichRangesContainer &pWhRanges)=0
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
virtual VclPtr< AbstractSvxSearchSimilarityDialog > CreateSvxSearchSimilarityDialog(weld::Window *pParent, bool bRelax, sal_uInt16 nOther, sal_uInt16 nShorter, sal_uInt16 nLonger)=0
std::unique_ptr< SearchDlg_Impl > pImpl
Definition: srchdlg.hxx:161
std::unique_ptr< SvxSearchController > pFamilyController
Definition: srchdlg.hxx:168
void SetWholeWordsOnly(bool bVal)
SVX_DLLPRIVATE void InitControls_Impl()
Definition: srchdlg.cxx:619
bool bReplaceBackwards
Definition: srchdlg.hxx:146
FieldUnit GetFieldUnit() const
virtual void SetText(const OUString &rStr)=0
SFX_IMPL_CHILDWINDOW_WITHID(SvxSearchDialogWrapper, SID_SEARCH_DLG)
virtual void select_entry_region(int nStartPos, int nEndPos)=0
#define DBG_ASSERT(sCon, aError)
static OUString GetSearchLabel()
Definition: srchdlg.cxx:2392
int i
ModifyFlags nModifyFlag
Definition: srchdlg.hxx:150
static void lcl_SetSearchLabelWindow(const OUString &rStr)
Definition: srchdlg.cxx:2345
virtual bool has_focus() const =0
OUString aLayoutWriterStr
Definition: srchdlg.hxx:153
SVX_DLLPRIVATE void InitAttrList_Impl(const SfxItemSet *pSSet, const SfxItemSet *pRSet)
Definition: srchdlg.cxx:1056
void SetSearchFormatted(bool bVal)
std::unique_ptr< weld::CheckButton > m_xLayoutBtn
Definition: srchdlg.hxx:209
void SetUseAsianOptions(bool bVal)
sal_uInt16 Count() const
virtual void ChildWinDispose() override
bool IsIgnoreDiacritics_CTL() const
constexpr sal_uInt16 XATTR_FILL_FIRST(XATTRSET_LINE+1)
virtual SvxSearchItem * Clone(SfxItemPool *pPool=nullptr) const override
virtual void Start(bool bStartTimer=true) override
sal_uInt16 nRememberSize
Definition: srchdlg.hxx:156
void LeaveRegistrations(const char *pFile=nullptr, int nLine=0)
virtual sal_uInt16 GetLonger()=0
sal_uInt16 Count() const
Definition: srchdlg.hxx:60
WhichRangesContainer pRanges
Definition: srchdlg.cxx:130
size
virtual TransliterationFlags GetTransliterationFlags() const =0
std::unique_ptr< weld::Button > m_xCloseBtn
Definition: srchdlg.hxx:200
std::unique_ptr< weld::Label > m_xCalcSearchDirFT
Definition: srchdlg.hxx:223
SearchLabel
Definition: srchdlg.hxx:73
std::unique_ptr< SvxSearchController > pOptionsController
Definition: srchdlg.hxx:167
sal_uInt16 GetSlotId(sal_uInt16 nWhich) const
sal_uInt16 GetWhichByPos(sal_uInt16 nPos) const
SVX_DLLPRIVATE void Init_Impl(bool bHasItemSet)
Definition: srchdlg.cxx:768
std::unique_ptr< SearchAttrItemList > pSearchList
Definition: srchdlg.hxx:162
std::unique_ptr< weld::Frame > m_xSearchFrame
Definition: srchdlg.hxx:175
virtual TransliterationFlags GetTransliterationFlags() const override
void SetTimeout(sal_uInt64 nTimeoutMs)
SfxItemPool * GetPool() const
std::shared_ptr< SvxSearchDialog > dialog
Definition: srchdlg.hxx:90
std::vector< OUString > & GetList()
static void SetSearchLabel(const SearchLabel &rSL)
Definition: srchdlg.cxx:2423
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
IMPL_LINK(SvxSearchDialog, LBSelectHdl_Impl, weld::ComboBox &, rCtrl, void)
Definition: srchdlg.cxx:1118
std::unique_ptr< weld::Label > m_xSearchLabel
Definition: srchdlg.hxx:179
std::unique_ptr< weld::RadioButton > m_xRowsBtn
Definition: srchdlg.hxx:224
TransliterationFlags GetTransliterationFlags() const
Definition: srchdlg.cxx:556
SVX_DLLPRIVATE short executeSubDialog(VclAbstractDialog *dialog)
Definition: srchdlg.cxx:2307
std::unique_ptr< weld::Button > m_xSearchComponent1PB
Definition: srchdlg.hxx:193
sal_uInt16 GetCurPos() const
void Update(sal_uInt16 nId)
std::unique_ptr< weld::Button > m_xAttributeBtn
Definition: srchdlg.hxx:216
virtual bool get_sensitive() const =0
std::unique_ptr< weld::Button > m_xSimilarityBtn
Definition: srchdlg.hxx:208
SVX_DLLPRIVATE void EnableControl_Impl(const weld::Widget &rCtrl)
Definition: srchdlg.cxx:1761
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void SetSearchForStyles(bool bVal)
std::unique_ptr< weld::CheckButton > m_xMatchCaseCB
Definition: srchdlg.hxx:196
virtual void Activate() override
static SfxViewFrame * Current()
std::unique_ptr< weld::Label > m_xCalcStrFT
Definition: srchdlg.hxx:227
std::unique_ptr< weld::RadioButton > m_xColumnsBtn
Definition: srchdlg.hxx:225
virtual VclPtr< AbstractSvxJSearchOptionsDialog > CreateSvxJSearchOptionsDialog(weld::Window *pParent, const SfxItemSet &rOptionsSet, TransliterationFlags nInitialFlags)=0
void DisableItem(sal_uInt16 nWhich)
std::unique_ptr< weld::Label > m_xSearchAttrText
Definition: srchdlg.hxx:178
std::unique_ptr< weld::Button > m_xReplaceAllBtn
Definition: srchdlg.hxx:190
void Stop()
static sal_uInt32 FindIndex(int nValue)
Definition: strarray.cxx:52
IMPL_LINK_NOARG(SvxSearchDialog, PresentTimeoutHdl_Impl, Timer *, void)
Definition: srchdlg.cxx:359
std::unique_ptr< weld::Button > m_xNoFormatBtn
Definition: srchdlg.hxx:218
std::unique_ptr< weld::Button > m_xSearchBtn
Definition: srchdlg.hxx:186
virtual sal_uInt16 GetOther()=0
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
constexpr tools::Long Height() const
void SetIgnoreDiacritics_CTL(bool bVal)
bool IsSearchFormatted() const
SfxStyleSheetBase * Next()
In this modeless dialog the attributes for a search are configured and a search is started from it...
Definition: srchdlg.hxx:110
virtual void Close() override
Definition: srchdlg.cxx:520
std::unique_ptr< weld::ComboBox > m_xSearchLB
Definition: srchdlg.hxx:176
Close
RET_OK
std::unique_ptr< weld::ComboBox > m_xReplaceTmplLB
Definition: srchdlg.hxx:183
void SetController(std::shared_ptr< SfxDialogController > controller)
Reference< XExecutableDialog > m_xDialog
void Insert(const SearchAttrItem &rItem)
Definition: srchdlg.hxx:67
std::unique_ptr< weld::Button > m_xReplaceBtn
Definition: srchdlg.hxx:189
Reference< XComponentContext > getProcessComponentContext()
SVX_DLLPRIVATE void SetModifyFlag_Impl(const weld::Widget *pCtrl)
Definition: srchdlg.cxx:2200
void SetInvokeHandler(const Link< Timer *, void > &rLink)
sal_uInt16 EnterRegistrations(const char *pFile=nullptr, int nLine=0)
SvxSearchDialog(weld::Window *pParent, SfxChildWindow *pChildWin, SfxBindings &rBind)
Definition: srchdlg.cxx:267
OUString get_label() const
ModifyFlags
Definition: srchdlg.cxx:89
virtual ~SvxSearchDialogWrapper() override
Definition: srchdlg.cxx:2333
Layout
std::unique_ptr< weld::CheckButton > m_xSearchFormattedCB
Definition: srchdlg.hxx:197
SfxDispatcher * GetDispatcher() const
Timer m_aPresentIdle
Definition: srchdlg.hxx:142
reference_type * get() const
virtual sal_uInt16 GetShorter()=0
OUString aCalcStr
Definition: srchdlg.hxx:155
MapUnit
virtual void remove(int pos)=0
util::URL aCommand2URL
Definition: srchdlg.cxx:136
std::unique_ptr< weld::CheckButton > m_xJapMatchFullHalfWidthCB
Definition: srchdlg.hxx:211
void append_text(const OUString &rStr)
void InvalidateAllItems()
constexpr sal_uInt16 XATTR_FILL_LAST(XATTR_FILLBACKGROUND)
std::unique_ptr< SvxSearchController > pSearchController
Definition: srchdlg.hxx:166
void SetNotes(bool bVal)
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
std::unique_ptr< weld::CheckButton > m_xNotesBtn
Definition: srchdlg.hxx:210
virtual bool HasSelection(bool bText=true) const
SVX_DLLPRIVATE void SetItem_Impl(const SvxSearchItem *pItem)
Definition: srchdlg.cxx:1863
OUString aLayoutStr
Definition: srchdlg.hxx:152
bool IsInvalidItem(const SfxPoolItem *pItem)
OUString aLayoutCalcStr
Definition: srchdlg.hxx:154
uno::Reference< frame::XDispatch > xCommand1Dispatch
Definition: srchdlg.cxx:133
SearchOptionFlags
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
virtual bool get_active() const =0
aStr
std::vector< OUString > aSearchStrings
Definition: srchdlg.hxx:158
virtual SfxChildWinInfo GetInfo() const
std::unique_ptr< weld::Frame > m_xReplaceFrame
Definition: srchdlg.hxx:181
sal_uInt16 Which() const
virtual void set_sensitive(bool sensitive)=0
const SfxPoolItem * GetCurItem() const
SVX_DLLPRIVATE void ShowOptionalControls_Impl()
Definition: srchdlg.cxx:699
std::unique_ptr< SvxSearchItem > pSearchItem
Definition: srchdlg.hxx:164
void set_label(const OUString &rLabel)