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() );
803  ApplyTransliterationFlags_Impl( pSearchItem->GetTransliterationFlags() );
804 
806 
807  if ( pSearchItem->GetAppFlag() == SvxSearchApp::CALC )
808  {
809  m_xCalcGrid->show();
810  m_xSearchFormattedCB->set_active( aOpt.IsSearchFormatted() );
811  Link<weld::Toggleable&,void> aLink = LINK( this, SvxSearchDialog, FlagHdl_Impl );
812  m_xCalcSearchInLB->connect_changed( LINK( this, SvxSearchDialog, LBSelectHdl_Impl ) );
813  m_xRowsBtn->connect_toggled( aLink );
814  m_xColumnsBtn->connect_toggled( aLink );
815  m_xAllSheetsCB->connect_toggled( aLink );
816  m_xSearchFormattedCB->connect_toggled( aLink );
817 
818  ModifyFlags nModifyFlagCheck;
819  switch ( pSearchItem->GetCellType() )
820  {
821  case SvxSearchCellType::FORMULA:
822  nModifyFlagCheck = ModifyFlags::Formulas;
823  break;
824 
825  case SvxSearchCellType::VALUE:
826  nModifyFlagCheck = ModifyFlags::Values;
827  break;
828 
829  case SvxSearchCellType::NOTE:
830  nModifyFlagCheck = ModifyFlags::CalcNotes;
831  break;
832 
833  default:
834  std::abort(); // cannot happen
835  }
836  if ( !(nModifyFlag & nModifyFlagCheck) )
837  m_xCalcSearchInLB->set_active( static_cast<sal_Int32>(pSearchItem->GetCellType()) );
838 
839  m_xWordBtn->set_label( aCalcStr.getToken( 0, '#' ) );
840 
841  if ( pSearchItem->GetRowDirection() &&
843  m_xRowsBtn->set_active(true);
844  else if ( !pSearchItem->GetRowDirection() &&
846  m_xColumnsBtn->set_active(true);
847 
848  if ( !( nModifyFlag & ModifyFlags::AllTables ) )
849  m_xAllSheetsCB->set_active( pSearchItem->IsAllTables() );
850 
851  // only look for formatting in Writer
852  m_xFormatBtn->hide();
853  m_xNoFormatBtn->hide();
854  m_xAttributeBtn->hide();
855  }
856  else
857  {
858  m_xSearchFormattedCB->hide();
859  m_xWordBtn->set_label( aCalcStr.getToken( 1, '#' ) );
860 
861  if ( pSearchItem->GetAppFlag() == SvxSearchApp::DRAW )
862  {
863  m_xSearchAllBtn->hide();
864 
865  m_xRegExpBtn->hide();
866  m_xWildcardBtn->hide();
867  m_xLayoutBtn->hide();
868 
869  // only look for formatting in Writer
870  m_xFormatBtn->hide();
871  m_xNoFormatBtn->hide();
872  m_xAttributeBtn->hide();
873  }
874  else
875  {
876  m_xWildcardBtn->hide(); /* TODO:WILDCARD do not hide for other apps if they handle it */
877 
878  if ( !pSearchList )
879  {
880  // Get attribute sets, if it not has been done already
881  const SfxPoolItem* ppArgs[] = { pSearchItem.get(), nullptr };
882  const SvxSetItem* pSrchSetItem =
883  static_cast<const SvxSetItem*>(rBindings.GetDispatcher()->Execute( FID_SEARCH_SEARCHSET, SfxCallMode::SLOT, ppArgs ));
884 
885  if ( pSrchSetItem )
886  InitAttrList_Impl( &pSrchSetItem->GetItemSet(), nullptr );
887 
888  const SvxSetItem* pReplSetItem =
889  static_cast<const SvxSetItem*>( rBindings.GetDispatcher()->Execute( FID_SEARCH_REPLACESET, SfxCallMode::SLOT, ppArgs ) );
890 
891  if ( pReplSetItem )
892  InitAttrList_Impl( nullptr, &pReplSetItem->GetItemSet() );
893  }
894  }
895  }
896 
897  // similarity search?
899  m_xSimilarityBox->set_active( pSearchItem->IsLevenshtein() );
900  bSet = true;
901 
902  FlagHdl_Impl(*m_xSimilarityBox);
903  FlagHdl_Impl(*m_xJapOptionsCB);
904 
905  bool bDisableSearch = false;
906  SfxViewShell* pViewShell = SfxViewShell::Current();
907 
908  if ( pViewShell )
909  {
910  bool bText = !bSearchPattern;
911 
912  if ( pViewShell->HasSelection( bText ) )
914  else
915  {
916  m_xSelectionBtn->set_active( false );
917  m_xSelectionBtn->set_sensitive(false);
918  }
919  }
920 
921  // Pattern Search and there were no AttrSets given
922  if ( bSearchPattern )
923  {
925 
926  if ( pShell && pShell->GetStyleSheetPool() )
927  {
928  // Templates designed
929  m_xSearchTmplLB->clear();
930  m_xReplaceTmplLB->clear();
931  SfxStyleSheetBasePool* pStylePool = pShell->GetStyleSheetPool();
932  SfxStyleSheetBase* pBase = pStylePool->First(pSearchItem->GetFamily());
933 
934  while ( pBase )
935  {
936  if ( pBase->IsUsed() )
937  m_xSearchTmplLB->append_text( pBase->GetName() );
938  m_xReplaceTmplLB->append_text( pBase->GetName() );
939  pBase = pStylePool->Next();
940  }
941  m_xSearchTmplLB->set_active_text( pSearchItem->GetSearchString() );
942  m_xReplaceTmplLB->set_active_text( pSearchItem->GetReplaceString() );
943 
944  }
945  m_xSearchTmplLB->show();
946 
947  if ( bConstruct )
948  // Grab focus only after creating
949  m_xSearchTmplLB->grab_focus();
950  m_xReplaceTmplLB->show();
951  m_xSearchLB->hide();
952  m_xReplaceLB->hide();
953 
954  m_xWordBtn->set_sensitive(false);
955  m_xRegExpBtn->set_sensitive(false);
956  m_xWildcardBtn->set_sensitive(false);
957  m_xMatchCaseCB->set_sensitive(false);
958 
959  bDisableSearch = !m_xSearchTmplLB->get_count();
960  }
961  else
962  {
963  bool bSetSearch = !( nModifyFlag & ModifyFlags::Search );
964  bool bSetReplace = !( nModifyFlag & ModifyFlags::Replace );
965 
966  if ( !(pSearchItem->GetSearchString().isEmpty()) && bSetSearch )
967  m_xSearchLB->set_entry_text( pSearchItem->GetSearchString() );
968  else if (!aSearchStrings.empty())
969  {
970  bool bAttributes =
971  ( ( pSearchList && pSearchList->Count() ) ||
972  ( pReplaceList && pReplaceList->Count() ) );
973 
974  if ( bSetSearch && !bAttributes )
975  m_xSearchLB->set_entry_text(aSearchStrings[0]);
976 
977  OUString aReplaceTxt = pSearchItem->GetReplaceString();
978 
979  if (!aReplaceStrings.empty())
980  aReplaceTxt = aReplaceStrings[0];
981 
982  if ( bSetReplace && !bAttributes )
983  m_xReplaceLB->set_entry_text( aReplaceTxt );
984  }
985  m_xSearchLB->show();
986 
987  if ( bConstruct )
988  // Grab focus only after creating
989  m_xSearchLB->grab_focus();
990  m_xReplaceLB->show();
991  m_xSearchTmplLB->hide();
992  m_xReplaceTmplLB->hide();
993 
997 
998  if ( m_xRegExpBtn->get_active() )
999  m_xWordBtn->set_sensitive(false);
1000  else
1002 
1003  bDisableSearch = m_xSearchLB->get_active_text().isEmpty() &&
1004  m_xSearchAttrText->get_label().isEmpty();
1005  }
1006  FocusHdl_Impl(*m_xSearchLB);
1007 
1008  if ( bDisableSearch )
1009  {
1010  m_xSearchBtn->set_sensitive(false);
1011  m_xBackSearchBtn->set_sensitive(false);
1012  m_xSearchAllBtn->set_sensitive(false);
1013  m_xReplaceBtn->set_sensitive(false);
1014  m_xReplaceAllBtn->set_sensitive(false);
1015  m_xComponentFrame->set_sensitive(false);
1016  }
1017  else
1018  {
1022  if (!bWriter || !m_xNotesBtn->get_active())
1023  {
1026  }
1027  if (bWriter && pSearchItem->GetNotes())
1028  {
1029  m_xSearchAllBtn->set_sensitive(false);
1030  m_xReplaceAllBtn->set_sensitive(false);
1031  }
1032  }
1033 
1034  if (!m_xSearchAttrText->get_label().isEmpty())
1036  else
1037  m_xNoFormatBtn->set_sensitive(false);
1038 
1039  if ( !pSearchList )
1040  {
1041  m_xAttributeBtn->set_sensitive(false);
1042  m_xFormatBtn->set_sensitive(false);
1043  }
1044 
1045  if ( m_xLayoutBtn->get_active() )
1046  {
1047  pImpl->bSaveToModule = false;
1048  TemplateHdl_Impl(*m_xLayoutBtn);
1049  pImpl->bSaveToModule = true;
1050  }
1051 }
1052 
1053 
1055  const SfxItemSet* pRSet )
1056 {
1057  if ( !pSSet && !pRSet )
1058  return;
1059 
1060  if ( pImpl->pRanges.empty() && pSSet )
1061  pImpl->pRanges = pSSet->GetRanges();
1062 
1063  bool bSetOptimalLayoutSize = false;
1064 
1065  // See to it that are the texts of the attributes are correct
1066  OUString aDesc;
1067 
1068  if ( pSSet )
1069  {
1070  pSearchList.reset(new SearchAttrItemList);
1071 
1072  if ( pSSet->Count() )
1073  {
1074  pSearchList->Put( *pSSet );
1075 
1076  m_xSearchAttrText->set_label( BuildAttrText_Impl( aDesc, true ) );
1077 
1078  if ( !aDesc.isEmpty() )
1079  {
1080  if (!m_xSearchAttrText->get_visible())
1081  {
1082  m_xSearchAttrText->show();
1083  bSetOptimalLayoutSize = true;
1084  }
1085  bFormat |= true;
1086  }
1087  }
1088  }
1089 
1090  if ( pRSet )
1091  {
1092  pReplaceList.reset(new SearchAttrItemList);
1093 
1094  if ( pRSet->Count() )
1095  {
1096  pReplaceList->Put( *pRSet );
1097 
1098  m_xReplaceAttrText->set_label( BuildAttrText_Impl( aDesc, false ) );
1099 
1100  if ( !aDesc.isEmpty() )
1101  {
1102  if (!m_xReplaceAttrText->get_visible())
1103  {
1104  m_xReplaceAttrText->show();
1105  bSetOptimalLayoutSize = true;
1106  }
1107  bFormat |= true;
1108  }
1109  }
1110  }
1111 
1112  if (bSetOptimalLayoutSize)
1113  m_xDialog->resize_to_request();
1114 }
1115 
1116 IMPL_LINK( SvxSearchDialog, LBSelectHdl_Impl, weld::ComboBox&, rCtrl, void )
1117 {
1118  ClickHdl_Impl(&rCtrl);
1119 }
1120 
1121 IMPL_LINK( SvxSearchDialog, FlagHdl_Impl, weld::Toggleable&, rCtrl, void )
1122 {
1123  ClickHdl_Impl(&rCtrl);
1124 }
1125 
1127 {
1128  if ( pCtrl && !bSet )
1129  SetModifyFlag_Impl(pCtrl);
1130  else
1131  bSet = false;
1132 
1133  if (pCtrl == m_xSimilarityBox.get())
1134  {
1135  bool bIsChecked = m_xSimilarityBox->get_active();
1136 
1137  if ( bIsChecked )
1138  {
1139  m_xSimilarityBtn->set_sensitive(true);
1140  m_xRegExpBtn->set_active( false );
1141  m_xRegExpBtn->set_sensitive(false);
1142  m_xWildcardBtn->set_active( false );
1143  m_xWildcardBtn->set_sensitive(false);
1145 
1146  if ( m_xLayoutBtn->get_active() )
1147  {
1149  m_xLayoutBtn->set_active( false );
1150  }
1151  m_xRegExpBtn->set_sensitive(false);
1152  m_xWildcardBtn->set_sensitive(false);
1153  m_xLayoutBtn->set_sensitive(false);
1154  m_xFormatBtn->set_sensitive(false);
1155  m_xNoFormatBtn->set_sensitive(false);
1156  m_xAttributeBtn->set_sensitive(false);
1157  }
1158  else
1159  {
1162  if (!m_xNotesBtn->get_active())
1166  m_xSimilarityBtn->set_sensitive(false);
1167  }
1168  pSearchItem->SetLevenshtein( bIsChecked );
1169  }
1170  else if (pCtrl == m_xNotesBtn.get())
1171  {
1172  if (m_xNotesBtn->get_active())
1173  {
1174  m_xLayoutBtn->set_sensitive(false);
1175  m_xSearchAllBtn->set_sensitive(false);
1176  m_xReplaceAllBtn->set_sensitive(false);
1177  }
1178  else
1179  {
1181  ModifyHdl_Impl(*m_xSearchLB);
1182  }
1183  }
1184  else
1185  {
1186  if ( m_xLayoutBtn->get_active() && !bFormat )
1187  {
1188  m_xWordBtn->set_active( false );
1189  m_xWordBtn->set_sensitive(false);
1190  m_xRegExpBtn->set_active( false );
1191  m_xRegExpBtn->set_sensitive(false);
1192  m_xWildcardBtn->set_active( false );
1193  m_xWildcardBtn->set_sensitive(false);
1194  m_xMatchCaseCB->set_active( false );
1195  m_xMatchCaseCB->set_sensitive(false);
1196  m_xNotesBtn->set_sensitive(false);
1197 
1198  if ( m_xSearchTmplLB->get_count() )
1199  {
1205  }
1206  }
1207  else
1208  {
1213 
1214  if ( m_xRegExpBtn->get_active() )
1215  {
1216  m_xWordBtn->set_active( false );
1217  m_xWordBtn->set_sensitive(false);
1218  m_xWildcardBtn->set_active( false );
1219  m_xWildcardBtn->set_sensitive(false);
1220  m_xSimilarityBox->set_active( false );
1221  m_xSimilarityBox->set_sensitive(false);
1222  m_xSimilarityBtn->set_sensitive(false);
1223  }
1224  else if ( m_xWildcardBtn->get_active() )
1225  {
1226  m_xRegExpBtn->set_active( false );
1227  m_xRegExpBtn->set_sensitive(false);
1228  m_xSimilarityBox->set_active( false );
1229  m_xSimilarityBox->set_sensitive(false);
1230  m_xSimilarityBtn->set_sensitive(false);
1231  }
1232  else
1233  {
1236  }
1237 
1238  // Search-string in place? then enable Buttons
1239  bSet = true;
1240  ModifyHdl_Impl(*m_xSearchLB);
1241  }
1242  }
1243 
1244  if (pCtrl == m_xAllSheetsCB.get())
1245  {
1246  bSet = true;
1247  ModifyHdl_Impl(*m_xSearchLB);
1248  }
1249 
1250  if (pCtrl == m_xJapOptionsCB.get())
1251  {
1252  bool bEnableJapOpt = m_xJapOptionsCB->get_active();
1253  m_xMatchCaseCB->set_sensitive(!bEnableJapOpt );
1254  m_xJapMatchFullHalfWidthCB->set_sensitive(!bEnableJapOpt );
1255  m_xJapOptionsBtn->set_sensitive( bEnableJapOpt );
1256  }
1257 
1258  if ( pImpl->bSaveToModule )
1260 }
1261 
1262 IMPL_LINK(SvxSearchDialog, CommandHdl_Impl, weld::Button&, rBtn, void)
1263 {
1264  bool bInclusive = ( m_xLayoutBtn->get_label() == aLayoutStr );
1265 
1266  if ( ( &rBtn == m_xSearchBtn.get() ) ||
1267  (&rBtn == m_xBackSearchBtn.get()) ||
1268  ( &rBtn == m_xSearchAllBtn.get() )||
1269  ( &rBtn == m_xReplaceBtn.get() ) ||
1270  ( &rBtn == m_xReplaceAllBtn.get() ) )
1271  {
1272  if ( m_xLayoutBtn->get_active() && !bInclusive )
1273  {
1274  pSearchItem->SetSearchString ( m_xSearchTmplLB->get_active_text() );
1275  pSearchItem->SetReplaceString( m_xReplaceTmplLB->get_active_text() );
1276  }
1277  else
1278  {
1279  pSearchItem->SetSearchString ( m_xSearchLB->get_active_text() );
1280  pSearchItem->SetReplaceString( m_xReplaceLB->get_active_text() );
1281 
1282  if ( &rBtn == m_xReplaceBtn.get() )
1283  Remember_Impl( m_xReplaceLB->get_active_text(), false );
1284  else
1285  {
1286  Remember_Impl( m_xSearchLB->get_active_text(), true );
1287 
1288  if ( &rBtn == m_xReplaceAllBtn.get() )
1289  Remember_Impl( m_xReplaceLB->get_active_text(), false );
1290  }
1291  }
1292 
1293  pSearchItem->SetRegExp( false );
1294  pSearchItem->SetWildcard( false );
1295  pSearchItem->SetLevenshtein( false );
1296  if (GetCheckBoxValue(*m_xRegExpBtn))
1297  pSearchItem->SetRegExp( true );
1298  else if (GetCheckBoxValue(*m_xWildcardBtn))
1299  pSearchItem->SetWildcard( true );
1300  else if (GetCheckBoxValue(*m_xSimilarityBox))
1301  pSearchItem->SetLevenshtein( true );
1302 
1303  pSearchItem->SetWordOnly(GetCheckBoxValue(*m_xWordBtn));
1304 
1305  bool bSetBackwards = false;
1306  if( &rBtn == m_xBackSearchBtn.get())
1307  {
1308  bSetBackwards = true;
1309  }
1310  else if( &rBtn == m_xReplaceBtn.get())
1311  {
1312  bSetBackwards = GetCheckBoxValue(*m_xReplaceBackwardsCB);
1313  bReplaceBackwards = GetCheckBoxValue(*m_xReplaceBackwardsCB);
1314  }
1315 
1316  pSearchItem->SetBackward(bSetBackwards);
1317 
1318  pSearchItem->SetNotes(GetCheckBoxValue(*m_xNotesBtn));
1319  pSearchItem->SetPattern(GetCheckBoxValue(*m_xLayoutBtn));
1320  pSearchItem->SetSelection(GetCheckBoxValue(*m_xSelectionBtn));
1321  pSearchItem->SetUseAsianOptions(GetCheckBoxValue(*m_xJapOptionsCB));
1323  if( !pSearchItem->IsUseAsianOptions())
1324  nFlags &= TransliterationFlags::IGNORE_CASE |
1325  TransliterationFlags::IGNORE_WIDTH;
1326  if (GetNegatedCheckBoxValue(*m_xIncludeDiacritics))
1327  nFlags |= TransliterationFlags::IGNORE_DIACRITICS_CTL;
1328  if (GetNegatedCheckBoxValue(*m_xIncludeKashida))
1329  nFlags |= TransliterationFlags::IGNORE_KASHIDA_CTL;
1330  pSearchItem->SetTransliterationFlags( nFlags );
1331 
1332  if ( !bWriter )
1333  {
1334  if ( m_xCalcSearchInLB->get_active() != -1)
1335  pSearchItem->SetCellType( static_cast<SvxSearchCellType>(m_xCalcSearchInLB->get_active()) );
1336 
1337  pSearchItem->SetRowDirection( m_xRowsBtn->get_active() );
1338  pSearchItem->SetAllTables( m_xAllSheetsCB->get_active() );
1339  pSearchItem->SetSearchFormatted( m_xSearchFormattedCB->get_active() );
1340  }
1341 
1342  if ((&rBtn == m_xSearchBtn.get()) || (&rBtn == m_xBackSearchBtn.get()))
1343  pSearchItem->SetCommand( SvxSearchCmd::FIND );
1344  else if ( &rBtn == m_xSearchAllBtn.get() )
1345  pSearchItem->SetCommand( SvxSearchCmd::FIND_ALL );
1346  else if ( &rBtn == m_xReplaceBtn.get() )
1347  pSearchItem->SetCommand( SvxSearchCmd::REPLACE );
1348  else if ( &rBtn == m_xReplaceAllBtn.get() )
1349  pSearchItem->SetCommand( SvxSearchCmd::REPLACE_ALL );
1350 
1351  // when looking for templates, delete format lists
1352  if ( !bFormat && pSearchItem->GetPattern() )
1353  {
1354  if ( pSearchList )
1355  pSearchList->Clear();
1356 
1357  if ( pReplaceList )
1358  pReplaceList->Clear();
1359  }
1360  nModifyFlag = ModifyFlags::NONE;
1361  const SfxPoolItem* ppArgs[] = { pSearchItem.get(), nullptr };
1362  rBindings.ExecuteSynchron( FID_SEARCH_NOW, ppArgs );
1363  }
1364  else if ( &rBtn == m_xCloseBtn.get() )
1365  {
1366  if ( !m_xLayoutBtn->get_active() || bInclusive )
1367  {
1368  OUString aStr( m_xSearchLB->get_active_text() );
1369 
1370  if ( !aStr.isEmpty() )
1371  Remember_Impl( aStr, true );
1372  aStr = m_xReplaceLB->get_active_text();
1373 
1374  if ( !aStr.isEmpty() )
1375  Remember_Impl( aStr, false );
1376  }
1377  SaveToModule_Impl();
1378  Close();
1379  }
1380  else if (&rBtn == m_xSimilarityBtn.get())
1381  {
1384  pSearchItem->IsLEVRelaxed(),
1385  pSearchItem->GetLEVOther(),
1386  pSearchItem->GetLEVShorter(),
1387  pSearchItem->GetLEVLonger() ));
1388  if ( executeSubDialog(pDlg.get()) == RET_OK )
1389  {
1390  pSearchItem->SetLEVRelaxed( pDlg->IsRelaxed() );
1391  pSearchItem->SetLEVOther( pDlg->GetOther() );
1392  pSearchItem->SetLEVShorter( pDlg->GetShorter() );
1393  pSearchItem->SetLEVLonger( pDlg->GetLonger() );
1394  SaveToModule_Impl();
1395  }
1396  }
1397  else if (&rBtn == m_xJapOptionsBtn.get())
1398  {
1399  SfxItemSet aSet( SfxGetpApp()->GetPool() );
1400  pSearchItem->SetTransliterationFlags( GetTransliterationFlags() );
1403  pSearchItem->GetTransliterationFlags() ));
1404  int nRet = executeSubDialog(aDlg.get());
1405  if (RET_OK == nRet)
1406  {
1408  pSearchItem->SetTransliterationFlags( nFlags );
1409  ApplyTransliterationFlags_Impl( nFlags );
1410  }
1411  }
1412  else if (&rBtn == m_xSearchComponent1PB.get() || &rBtn == m_xSearchComponent2PB.get())
1413  {
1414  uno::Sequence < beans::PropertyValue > aArgs(2);
1415  beans::PropertyValue* pArgs = aArgs.getArray();
1416  pArgs[0].Name = "SearchString";
1417  pArgs[0].Value <<= m_xSearchLB->get_active_text();
1418  pArgs[1].Name = "ParentWindow";
1419  pArgs[1].Value <<= m_xDialog->GetXWindow();
1420  if (&rBtn == m_xSearchComponent1PB.get())
1421  {
1422  if ( pImpl->xCommand1Dispatch.is() )
1423  pImpl->xCommand1Dispatch->dispatch(pImpl->aCommand1URL, aArgs);
1424  }
1425  else
1426  {
1427  if ( pImpl->xCommand2Dispatch.is() )
1428  pImpl->xCommand2Dispatch->dispatch(pImpl->aCommand2URL, aArgs);
1429  }
1430  }
1431 }
1432 
1433 
1434 IMPL_LINK( SvxSearchDialog, ModifyHdl_Impl, weld::ComboBox&, rEd, void )
1435 {
1436  if ( !bSet )
1437  SetModifyFlag_Impl( &rEd );
1438  else
1439  bSet = false;
1440 
1441  // Calc allows searching for empty cells.
1442  bool bAllowEmptySearch = (pSearchItem->GetAppFlag() == SvxSearchApp::CALC);
1443 
1444  if (&rEd != m_xSearchLB.get() && &rEd != m_xReplaceLB.get())
1445  return;
1446 
1447  sal_Int32 nSrchTxtLen = m_xSearchLB->get_active_text().getLength();
1448  sal_Int32 nReplTxtLen = 0;
1449  if (bAllowEmptySearch)
1450  nReplTxtLen = m_xReplaceLB->get_active_text().getLength();
1451  sal_Int32 nAttrTxtLen = m_xSearchAttrText->get_label().getLength();
1452 
1453  if (nSrchTxtLen || nReplTxtLen || nAttrTxtLen)
1454  {
1455  EnableControl_Impl(*m_xSearchBtn);
1456  EnableControl_Impl(*m_xBackSearchBtn);
1457  EnableControl_Impl(*m_xReplaceBtn);
1458  if (!bWriter || !m_xNotesBtn->get_active())
1459  {
1460  EnableControl_Impl(*m_xSearchAllBtn);
1461  EnableControl_Impl(*m_xReplaceAllBtn);
1462  }
1463  }
1464  else
1465  {
1466  m_xComponentFrame->set_sensitive(false);
1467  m_xSearchBtn->set_sensitive(false);
1468  m_xBackSearchBtn->set_sensitive(false);
1469  m_xSearchAllBtn->set_sensitive(false);
1470  m_xReplaceBtn->set_sensitive(false);
1471  m_xReplaceAllBtn->set_sensitive(false);
1472  }
1473 }
1474 
1476 {
1477  if ( pImpl->bSaveToModule )
1478  SaveToModule_Impl();
1479 
1480  if ( bFormat )
1481  return;
1482  OUString sDesc;
1483 
1484  if ( m_xLayoutBtn->get_active() )
1485  {
1486  if ( !pFamilyController )
1487  {
1488  sal_uInt16 nId = 0;
1489 
1490  // Enable templates controller
1491  switch ( pSearchItem->GetFamily() )
1492  {
1493  case SfxStyleFamily::Char:
1494  nId = SID_STYLE_FAMILY1; break;
1495 
1496  case SfxStyleFamily::Para:
1497  nId = SID_STYLE_FAMILY2; break;
1498 
1499  case SfxStyleFamily::Frame:
1500  nId = SID_STYLE_FAMILY3; break;
1501 
1502  case SfxStyleFamily::Page:
1503  nId = SID_STYLE_FAMILY4; break;
1504 
1505  case SfxStyleFamily::All:
1506  break;
1507 
1508  default:
1509  OSL_FAIL( "StyleSheetFamily was changed?" );
1510  }
1511 
1512  rBindings.EnterRegistrations();
1513  pFamilyController.reset(
1514  new SvxSearchController( nId, rBindings, *this ) );
1515  rBindings.LeaveRegistrations();
1516  m_xSearchTmplLB->clear();
1517  m_xReplaceTmplLB->clear();
1518 
1519  m_xSearchTmplLB->show();
1520  m_xReplaceTmplLB->show();
1521  m_xSearchLB->hide();
1522  m_xReplaceLB->hide();
1523 
1524  m_xSearchAttrText->set_label( sDesc );
1525  m_xReplaceAttrText->set_label( sDesc );
1526 
1527  if(!sDesc.isEmpty())
1528  {
1529  if (!m_xReplaceAttrText->get_visible() || !m_xReplaceAttrText->get_visible())
1530  {
1531  m_xSearchAttrText->show();
1532  m_xReplaceAttrText->show();
1533  m_xDialog->resize_to_request();
1534  }
1535  }
1536  }
1537  m_xFormatBtn->set_sensitive(false);
1538  m_xNoFormatBtn->set_sensitive(false);
1539  m_xAttributeBtn->set_sensitive(false);
1540  m_xSimilarityBox->set_sensitive(false);
1541  m_xSimilarityBtn->set_sensitive(false);
1542  }
1543  else
1544  {
1545  // Disable templates controller
1546  rBindings.EnterRegistrations();
1547  pFamilyController.reset();
1548  rBindings.LeaveRegistrations();
1549 
1550  m_xSearchLB->show();
1551  m_xReplaceLB->show();
1552  m_xSearchTmplLB->hide();
1553  m_xReplaceTmplLB->hide();
1554 
1555  m_xSearchAttrText->set_label( BuildAttrText_Impl( sDesc, true ) );
1556  m_xReplaceAttrText->set_label( BuildAttrText_Impl( sDesc, false ) );
1557 
1558  if(!sDesc.isEmpty())
1559  {
1560  if (!m_xReplaceAttrText->get_visible() || !m_xReplaceAttrText->get_visible())
1561  {
1562  m_xSearchAttrText->show();
1563  m_xReplaceAttrText->show();
1564  m_xDialog->resize_to_request();
1565  }
1566  }
1567 
1568  EnableControl_Impl(*m_xFormatBtn);
1569  EnableControl_Impl(*m_xAttributeBtn);
1570  EnableControl_Impl(*m_xSimilarityBox);
1571 
1572  FocusHdl_Impl( bSearch ? *m_xSearchLB : *m_xReplaceLB );
1573  }
1574  bSet = true;
1575  pImpl->bSaveToModule = false;
1576  FlagHdl_Impl(*m_xLayoutBtn);
1577  pImpl->bSaveToModule = true;
1578 }
1579 
1580 void SvxSearchDialog::Remember_Impl( const OUString &rStr, bool _bSearch )
1581 {
1582  if ( rStr.isEmpty() )
1583  return;
1584 
1585  std::vector<OUString>* pArr = _bSearch ? &aSearchStrings : &aReplaceStrings;
1586  weld::ComboBox* pListBox = _bSearch ? m_xSearchLB.get() : m_xReplaceLB.get();
1587 
1588  // ignore identical strings
1589  if (std::find(pArr->begin(), pArr->end(), rStr) != pArr->end())
1590  return;
1591 
1592  pArr->insert(pArr->begin(), rStr);
1593  pListBox->insert_text(0, rStr);
1594 
1595  // delete oldest entry at maximum occupancy (ListBox and Array)
1596  size_t nArrSize = pArr->size();
1597  if (nArrSize > nRememberSize)
1598  {
1599  pListBox->remove(nArrSize - 1);
1600  pArr->erase(pArr->begin() + nArrSize - 1);
1601  }
1602 }
1603 
1605 {
1606  OUString aOldSrch( m_xSearchTmplLB->get_active_text() );
1607  OUString aOldRepl( m_xReplaceTmplLB->get_active_text() );
1608  m_xSearchTmplLB->clear();
1609  m_xReplaceTmplLB->clear();
1610  m_xSearchTmplLB->freeze();
1611  m_xReplaceTmplLB->freeze();
1612  SfxStyleSheetBase* pBase = rPool.First(pSearchItem->GetFamily());
1613 
1614  while ( pBase )
1615  {
1616  if ( pBase->IsUsed() )
1617  m_xSearchTmplLB->append_text( pBase->GetName() );
1618  m_xReplaceTmplLB->append_text( pBase->GetName() );
1619  pBase = rPool.Next();
1620  }
1621  m_xSearchTmplLB->thaw();
1622  m_xReplaceTmplLB->thaw();
1623  m_xSearchTmplLB->set_active(0);
1624 
1625  if ( !aOldSrch.isEmpty() )
1626  m_xSearchTmplLB->set_active_text( aOldSrch );
1627  m_xReplaceTmplLB->set_active(0);
1628 
1629  if ( !aOldRepl.isEmpty() )
1630  m_xReplaceTmplLB->set_active_text( aOldRepl );
1631 
1632  if ( m_xSearchTmplLB->get_count() )
1633  {
1639  }
1640 }
1641 
1642 
1644 {
1645  if ( nFlags == nOptions )
1646  return;
1647  else
1648  nOptions = nFlags;
1649 
1650  bool bNoSearch = true;
1651 
1652  bool bEnableSearch = bool( SearchOptionFlags::SEARCH & nOptions );
1653  m_xSearchBtn->set_sensitive(bEnableSearch);
1654  m_xBackSearchBtn->set_sensitive(bEnableSearch);
1655 
1656  if( bEnableSearch )
1657  bNoSearch = false;
1658 
1659 
1660  if ( SearchOptionFlags::SEARCHALL & nOptions )
1661  {
1662  m_xSearchAllBtn->set_sensitive(true);
1663  bNoSearch = false;
1664  }
1665  else
1666  m_xSearchAllBtn->set_sensitive(false);
1667  if ( SearchOptionFlags::REPLACE & nOptions )
1668  {
1669  m_xReplaceBtn->set_sensitive(true);
1670  m_xReplaceFrame->set_sensitive(true);
1671  m_xReplaceLB->set_sensitive(true);
1672  m_xReplaceTmplLB->set_sensitive(true);
1673  bNoSearch = false;
1674  }
1675  else
1676  {
1677  m_xReplaceBtn->set_sensitive(false);
1678  m_xReplaceFrame->set_sensitive(false);
1679  m_xReplaceLB->set_sensitive(false);
1680  m_xReplaceTmplLB->set_sensitive(false);
1681  }
1682  if ( SearchOptionFlags::REPLACE_ALL & nOptions )
1683  {
1684  m_xReplaceAllBtn->set_sensitive(true);
1685  bNoSearch = false;
1686  }
1687  else
1688  m_xReplaceAllBtn->set_sensitive(false);
1689  m_xComponentFrame->set_sensitive(!bNoSearch);
1690  m_xSearchBtn->set_sensitive( !bNoSearch );
1691  m_xBackSearchBtn->set_sensitive( !bNoSearch );
1692  m_xSearchFrame->set_sensitive( !bNoSearch );
1693  m_xSearchLB->set_sensitive( !bNoSearch );
1694  m_xNotesBtn->set_sensitive(true);
1695 
1696  if ( SearchOptionFlags::WHOLE_WORDS & nOptions )
1697  m_xWordBtn->set_sensitive(true);
1698  else
1699  m_xWordBtn->set_sensitive(false);
1700  if ( SearchOptionFlags::BACKWARDS & nOptions )
1701  {
1702  m_xBackSearchBtn->set_sensitive(true);
1703  m_xReplaceBackwardsCB->set_sensitive(true);
1704  }
1705  else
1706  {
1707  m_xBackSearchBtn->set_sensitive(false);
1708  m_xReplaceBackwardsCB->set_sensitive(false);
1709  }
1710  if ( SearchOptionFlags::REG_EXP & nOptions )
1711  m_xRegExpBtn->set_sensitive(true);
1712  else
1713  m_xRegExpBtn->set_sensitive(false);
1714  if ( SearchOptionFlags::WILDCARD & nOptions )
1715  m_xWildcardBtn->set_sensitive(true);
1716  else
1717  m_xWildcardBtn->set_sensitive(false);
1718  if ( SearchOptionFlags::EXACT & nOptions )
1719  m_xMatchCaseCB->set_sensitive(true);
1720  else
1721  m_xMatchCaseCB->set_sensitive(false);
1722  if ( SearchOptionFlags::SELECTION & nOptions )
1723  m_xSelectionBtn->set_sensitive(true);
1724  else
1725  m_xSelectionBtn->set_sensitive(false);
1726  if ( SearchOptionFlags::FAMILIES & nOptions )
1727  m_xLayoutBtn->set_sensitive(true);
1728  else
1729  m_xLayoutBtn->set_sensitive(false);
1730  if ( SearchOptionFlags::FORMAT & nOptions )
1731  {
1732  m_xAttributeBtn->set_sensitive(true);
1733  m_xFormatBtn->set_sensitive(true);
1734  m_xNoFormatBtn->set_sensitive(true);
1735  }
1736  else
1737  {
1738  m_xAttributeBtn->set_sensitive(false);
1739  m_xFormatBtn->set_sensitive(false);
1740  m_xNoFormatBtn->set_sensitive(false);
1741  }
1742 
1743  if ( SearchOptionFlags::SIMILARITY & nOptions )
1744  {
1745  m_xSimilarityBox->set_sensitive(true);
1746  m_xSimilarityBtn->set_sensitive(true);
1747  }
1748  else
1749  {
1750  m_xSimilarityBox->set_sensitive(false);
1751  m_xSimilarityBtn->set_sensitive(false);
1752  }
1753 
1754  if ( pSearchItem )
1755  {
1756  Init_Impl( pSearchItem->GetPattern() &&
1757  ( !pSearchList || !pSearchList->Count() ) );
1759  m_xOtherOptionsExpander->set_expanded(true);
1760  }
1761 }
1762 
1764 {
1765  if (m_xSearchBtn.get() == &rCtrl && ( SearchOptionFlags::SEARCH & nOptions ) )
1766  {
1767  m_xComponentFrame->set_sensitive(true);
1768  m_xSearchBtn->set_sensitive(true);
1769  return;
1770  }
1771  if ( m_xSearchAllBtn.get() == &rCtrl &&
1772  ( SearchOptionFlags::SEARCHALL & nOptions ) )
1773  {
1774  m_xSearchAllBtn->set_sensitive(true);
1775  return;
1776  }
1777  if ( m_xReplaceBtn.get() == &rCtrl && ( SearchOptionFlags::REPLACE & nOptions ) )
1778  {
1779  m_xReplaceBtn->set_sensitive(true);
1780  return;
1781  }
1782  if ( m_xReplaceAllBtn.get() == &rCtrl &&
1783  ( SearchOptionFlags::REPLACE_ALL & nOptions ) )
1784  {
1785  m_xReplaceAllBtn->set_sensitive(true);
1786  return;
1787  }
1788  if ( m_xWordBtn.get() == &rCtrl && ( SearchOptionFlags::WHOLE_WORDS & nOptions ) )
1789  {
1790  m_xWordBtn->set_sensitive(true);
1791  return;
1792  }
1793  if ( SearchOptionFlags::BACKWARDS & nOptions )
1794  {
1795  if( m_xBackSearchBtn.get() == &rCtrl )
1796  {
1797  m_xBackSearchBtn->set_sensitive(true);
1798  return;
1799  }
1800  else if ( m_xReplaceBackwardsCB.get() == &rCtrl )
1801  {
1802  m_xReplaceBackwardsCB->set_sensitive(true);
1803  return;
1804  }
1805  }
1806  if (m_xNotesBtn.get() == &rCtrl)
1807  {
1808  m_xNotesBtn->set_sensitive(true);
1809  return;
1810  }
1811  if ( m_xRegExpBtn.get() == &rCtrl && ( SearchOptionFlags::REG_EXP & nOptions )
1812  && !m_xSimilarityBox->get_active() && !m_xWildcardBtn->get_active())
1813  {
1814  m_xRegExpBtn->set_sensitive(true);
1815  return;
1816  }
1817  if ( m_xWildcardBtn.get() == &rCtrl && ( SearchOptionFlags::WILDCARD & nOptions )
1818  && !m_xSimilarityBox->get_active() && !m_xRegExpBtn->get_active())
1819  {
1820  m_xWildcardBtn->set_sensitive(true);
1821  return;
1822  }
1823  if ( m_xMatchCaseCB.get() == &rCtrl && ( SearchOptionFlags::EXACT & nOptions ) )
1824  {
1825  if (!m_xJapOptionsCB->get_active())
1826  m_xMatchCaseCB->set_sensitive(true);
1827  return;
1828  }
1829  if ( m_xSelectionBtn.get() == &rCtrl && ( SearchOptionFlags::SELECTION & nOptions ) )
1830  {
1831  m_xSelectionBtn->set_sensitive(true);
1832  return;
1833  }
1834  if ( m_xLayoutBtn.get() == &rCtrl && ( SearchOptionFlags::FAMILIES & nOptions ) )
1835  {
1836  m_xLayoutBtn->set_sensitive(true);
1837  return;
1838  }
1839  if ( m_xAttributeBtn.get() == &rCtrl
1840  && ( SearchOptionFlags::FORMAT & nOptions )
1841  && pSearchList )
1842  {
1843  m_xAttributeBtn->set_sensitive( pImpl->bFocusOnSearch );
1844  }
1845  if ( m_xFormatBtn.get() == &rCtrl && ( SearchOptionFlags::FORMAT & nOptions ) )
1846  {
1847  m_xFormatBtn->set_sensitive(true);
1848  return;
1849  }
1850  if ( m_xNoFormatBtn.get() == &rCtrl && ( SearchOptionFlags::FORMAT & nOptions ) )
1851  {
1852  m_xNoFormatBtn->set_sensitive(true);
1853  return;
1854  }
1855  if ( m_xSimilarityBox.get() == &rCtrl && ( SearchOptionFlags::SIMILARITY & nOptions )
1856  && !m_xRegExpBtn->get_active() && !m_xWildcardBtn->get_active())
1857  {
1858  m_xSimilarityBox->set_sensitive(true);
1859 
1860  if ( m_xSimilarityBox->get_active() )
1861  m_xSimilarityBtn->set_sensitive(true);
1862  }
1863 }
1864 
1866 {
1867  //TODO: save pItem and process later if m_executingSubDialog?
1868  if ( pItem && !m_executingSubDialog )
1869  {
1870  pSearchItem.reset(pItem->Clone());
1871  Init_Impl( pSearchItem->GetPattern() &&
1872  ( !pSearchList || !pSearchList->Count() ) );
1873  }
1874 }
1875 
1876 IMPL_LINK(SvxSearchDialog, FocusHdl_Impl, weld::Widget&, rControl, void)
1877 {
1878  sal_Int32 nTxtLen = m_xSearchAttrText->get_label().getLength();
1879  weld::Widget* pCtrl = &rControl;
1880  if (pCtrl == m_xSearchLB.get())
1881  {
1882  if (pCtrl->has_focus())
1883  pImpl->bFocusOnSearch = true;
1884  pCtrl = m_xSearchLB.get();
1885  bSearch = true;
1886 
1887  if( nTxtLen )
1888  EnableControl_Impl(*m_xNoFormatBtn);
1889  else
1890  m_xNoFormatBtn->set_sensitive(false);
1891  EnableControl_Impl(*m_xAttributeBtn);
1892  }
1893  else
1894  {
1895  pImpl->bFocusOnSearch = false;
1896  pCtrl = m_xReplaceLB.get();
1897  bSearch = false;
1898 
1899  if (!m_xReplaceAttrText->get_label().isEmpty())
1900  EnableControl_Impl(*m_xNoFormatBtn);
1901  else
1902  m_xNoFormatBtn->set_sensitive(false);
1903  m_xAttributeBtn->set_sensitive(false);
1904  }
1905  bSet = true;
1906 
1907  weld::ComboBox &rComboBox = dynamic_cast<weld::ComboBox&>(*pCtrl);
1908  rComboBox.select_entry_region(0, -1);
1909  ModifyHdl_Impl(rComboBox);
1910 
1911  if (bFormat && nTxtLen)
1912  m_xLayoutBtn->set_label(aLayoutStr);
1913  else
1914  {
1915  SvtModuleOptions::EFactory eFactory = getModule(rBindings);
1916  bool bWriterApp =
1917  eFactory == SvtModuleOptions::EFactory::WRITER ||
1920  bool bCalcApp = eFactory == SvtModuleOptions::EFactory::CALC;
1921 
1922  if (bWriterApp)
1923  m_xLayoutBtn->set_label(aLayoutWriterStr);
1924  else
1925  {
1926  if (bCalcApp)
1927  m_xLayoutBtn->set_label(aLayoutCalcStr);
1928  else
1929  m_xLayoutBtn->set_label(aStylesStr);
1930  }
1931  }
1932 }
1933 
1934 IMPL_LINK_NOARG(SvxSearchDialog, LoseFocusHdl_Impl, weld::Widget&, void)
1935 {
1936  SaveToModule_Impl();
1937 }
1938 
1940 {
1942 
1943  DBG_ASSERT( pSh, "no DocShell" );
1944 
1945  if ( !pSh || pImpl->pRanges.empty() )
1946  return;
1947 
1948  SfxItemPool& rPool = pSh->GetPool();
1949  SfxItemSet aSet(rPool, pImpl->pRanges);
1950 
1951  aSet.MergeRange(SID_ATTR_PARA_MODEL, SID_ATTR_PARA_MODEL);
1952 
1953  sal_uInt16 nBrushWhich = pSh->GetPool().GetWhich(SID_ATTR_BRUSH);
1954  aSet.MergeRange(nBrushWhich, nBrushWhich);
1955 
1957 
1958  OUString aTxt;
1959 
1960  aSet.InvalidateAllItems();
1961  aSet.Put(SvxBrushItem(nBrushWhich));
1962 
1963  if ( bSearch )
1964  {
1965  aTxt = SvxResId( RID_SVXSTR_SEARCH );
1966  pSearchList->Get( aSet );
1967  }
1968  else
1969  {
1970  aTxt = SvxResId( RID_SVXSTR_REPLACE );
1971  pReplaceList->Get( aSet );
1972  }
1973  aSet.DisableItem(SID_ATTR_PARA_MODEL);
1974  aSet.DisableItem(rPool.GetWhich(SID_ATTR_PARA_PAGEBREAK));
1975  aSet.DisableItem(rPool.GetWhich(SID_ATTR_PARA_KEEP));
1976 
1977 
1980  pDlg->SetText( aTxt );
1981 
1982  if ( executeSubDialog(pDlg.get()) != RET_OK )
1983  return;
1984 
1985  DBG_ASSERT( pDlg->GetOutputItemSet(), "invalid Output-Set" );
1986  SfxItemSet aOutSet( *pDlg->GetOutputItemSet() );
1987 
1988  SearchAttrItemList* pList = bSearch ? pSearchList.get() : pReplaceList.get();
1989 
1990  const SfxPoolItem* pItem;
1991  for( sal_uInt16 n = 0; n < pList->Count(); ++n )
1992  {
1993  SearchAttrItem* pAItem = &pList->GetObject(n);
1994  if( !IsInvalidItem( pAItem->pItem ) &&
1995  SfxItemState::SET == aOutSet.GetItemState(
1996  pAItem->pItem->Which(), false, &pItem ) )
1997  {
1998  delete pAItem->pItem;
1999  pAItem->pItem = pItem->Clone();
2000  aOutSet.ClearItem( pAItem->pItem->Which() );
2001  }
2002  }
2003 
2004  if( aOutSet.Count() )
2005  pList->Put( aOutSet );
2006 
2007  PaintAttrText_Impl(); // Set AttributeText in GroupBox
2008 }
2009 
2011 {
2012  SvtModuleOptions::EFactory eFactory = getModule(rBindings);
2013  bool bWriterApp =
2014  eFactory == SvtModuleOptions::EFactory::WRITER ||
2017  bool bCalcApp = eFactory == SvtModuleOptions::EFactory::CALC;
2018 
2019  if (bCalcApp)
2020  m_xLayoutBtn->set_label( aLayoutCalcStr );
2021  else
2022  {
2023  if (bWriterApp)
2024  m_xLayoutBtn->set_label( aLayoutWriterStr);
2025  else
2026  m_xLayoutBtn->set_label( aStylesStr );
2027  }
2028 
2029  bFormat = false;
2030  m_xLayoutBtn->set_active( false );
2031 
2032  bool bSetOptimalLayoutSize = false;
2033 
2034  if ( bSearch )
2035  {
2036  pSearchList->Clear();
2037  m_xSearchAttrText->set_label( "" );
2038  if (m_xSearchAttrText->get_visible())
2039  {
2040  m_xSearchAttrText->hide();
2041  bSetOptimalLayoutSize = true;
2042  }
2043  }
2044  else
2045  {
2046  pReplaceList->Clear();
2047  m_xReplaceAttrText->set_label( "" );
2048  if (m_xReplaceAttrText->get_visible())
2049  {
2050  m_xReplaceAttrText->hide();
2051  bSetOptimalLayoutSize = true;
2052  }
2053  }
2054 
2055  if (bSetOptimalLayoutSize)
2056  m_xDialog->resize_to_request();
2057 
2058  pImpl->bSaveToModule = false;
2059  TemplateHdl_Impl(*m_xLayoutBtn);
2060  pImpl->bSaveToModule = true;
2061  m_xNoFormatBtn->set_sensitive(false);
2062 }
2063 
2064 IMPL_LINK_NOARG(SvxSearchDialog, AttributeHdl_Impl, weld::Button&, void)
2065 {
2066  if ( !pSearchList || pImpl->pRanges.empty() )
2067  return;
2068 
2070  ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateSvxSearchAttributeDialog(m_xDialog.get(), *pSearchList, pImpl->pRanges));
2071  executeSubDialog(pDlg.get());
2072  PaintAttrText_Impl();
2073 }
2074 
2075 IMPL_LINK( SvxSearchDialog, TimeoutHdl_Impl, Timer *, pTimer, void )
2076 {
2077  SfxViewShell* pViewShell = SfxViewShell::Current();
2078 
2079  if ( pViewShell )
2080  {
2081  if ( pViewShell->HasSelection( m_xSearchLB->get_visible() ) )
2082  EnableControl_Impl(*m_xSelectionBtn);
2083  else
2084  {
2085  m_xSelectionBtn->set_active( false );
2086  m_xSelectionBtn->set_sensitive(false);
2087  }
2088  }
2089 
2090  pTimer->Start();
2091 }
2092 
2093 OUString& SvxSearchDialog::BuildAttrText_Impl( OUString& rStr,
2094  bool bSrchFlag ) const
2095 {
2096  rStr.clear();
2097 
2099  DBG_ASSERT( pSh, "no DocShell" );
2100 
2101  if ( !pSh )
2102  return rStr;
2103 
2104  SfxItemPool& rPool = pSh->GetPool();
2105  SearchAttrItemList* pList = bSrchFlag ? pSearchList.get() : pReplaceList.get();
2106 
2107  if ( !pList )
2108  return rStr;
2109 
2110  // Metric query
2111  MapUnit eMapUnit = MapUnit::MapCM;
2112  FieldUnit eFieldUnit = pSh->GetModule()->GetFieldUnit();
2113  switch ( eFieldUnit )
2114  {
2115  case FieldUnit::MM: eMapUnit = MapUnit::MapMM; break;
2116  case FieldUnit::CM:
2117  case FieldUnit::M:
2118  case FieldUnit::KM: eMapUnit = MapUnit::MapCM; break;
2119  case FieldUnit::TWIP: eMapUnit = MapUnit::MapTwip; break;
2120  case FieldUnit::POINT:
2121  case FieldUnit::PICA: eMapUnit = MapUnit::MapPoint; break;
2122  case FieldUnit::INCH:
2123  case FieldUnit::FOOT:
2124  case FieldUnit::MILE: eMapUnit = MapUnit::MapInch; break;
2125  case FieldUnit::MM_100TH: eMapUnit = MapUnit::Map100thMM; break;
2126  default: ;//prevent warning
2127  }
2128 
2129  IntlWrapper aIntlWrapper(SvtSysLocale().GetUILanguageTag());
2130  for ( sal_uInt16 i = 0; i < pList->Count(); ++i )
2131  {
2132  const SearchAttrItem& rItem = pList->GetObject(i);
2133 
2134  if ( !rStr.isEmpty() )
2135  rStr += ", ";
2136 
2137  if ( !IsInvalidItem( rItem.pItem ) )
2138  {
2139  OUString aStr;
2140  rPool.GetPresentation(*rItem.pItem, eMapUnit, aStr, aIntlWrapper);
2141  if (aStr.isEmpty())
2142  {
2143  if (rStr.endsWith(", "))
2144  rStr = rStr.copy(0, rStr.lastIndexOf(","));
2145  }
2146  else
2147  rStr += aStr;
2148  }
2149  else if ( rItem.nSlot == SID_ATTR_BRUSH_CHAR )
2150  {
2151  // Special treatment for text background
2152  rStr += SvxResId( RID_SVXITEMS_BRUSH_CHAR );
2153  }
2154  else
2155  {
2156  sal_uInt32 nId = SvxAttrNameTable::FindIndex(rItem.nSlot);
2157  if ( RESARRAY_INDEX_NOTFOUND != nId )
2158  rStr += SvxAttrNameTable::GetString(nId);
2159  }
2160  }
2161  return rStr;
2162 }
2163 
2164 
2166 {
2167  OUString aDesc;
2168  BuildAttrText_Impl( aDesc, bSearch );
2169 
2170  if ( !bFormat && !aDesc.isEmpty() )
2171  bFormat = true;
2172 
2173  bool bSetOptimalLayoutSize = false;
2174 
2175  if ( bSearch )
2176  {
2177  m_xSearchAttrText->set_label( aDesc );
2178  if (!aDesc.isEmpty() && !m_xSearchAttrText->get_visible())
2179  {
2180  m_xSearchAttrText->show();
2181  bSetOptimalLayoutSize = true;
2182  }
2183 
2184  FocusHdl_Impl(*m_xSearchLB);
2185  }
2186  else
2187  {
2188  m_xReplaceAttrText->set_label( aDesc );
2189  if (!aDesc.isEmpty() && !m_xReplaceAttrText->get_visible())
2190  {
2191  m_xReplaceAttrText->show();
2192  bSetOptimalLayoutSize = true;
2193  }
2194 
2195  FocusHdl_Impl(*m_xReplaceLB);
2196  }
2197 
2198  if (bSetOptimalLayoutSize)
2199  m_xDialog->resize_to_request();
2200 }
2201 
2203 {
2204  if (m_xSearchLB.get() == pCtrl)
2205  {
2207  m_xSearchLB->set_entry_message_type(weld::EntryMessageType::Normal);
2209  }
2210  else if ( m_xReplaceLB.get() == pCtrl )
2212  else if ( m_xWordBtn.get() == pCtrl )
2214  else if ( m_xMatchCaseCB.get() == pCtrl )
2216  else if ( m_xReplaceBackwardsCB.get() == pCtrl )
2218  else if ( m_xNotesBtn.get() == pCtrl )
2220  else if ( m_xSelectionBtn.get() == pCtrl )
2222  else if ( m_xRegExpBtn.get() == pCtrl )
2224  else if ( m_xWildcardBtn.get() == pCtrl )
2226  else if ( m_xLayoutBtn.get() == pCtrl )
2228  else if ( m_xSimilarityBox.get() == pCtrl )
2230  else if ( m_xCalcSearchInLB.get() == pCtrl )
2231  {
2235  }
2236  else if ( m_xRowsBtn.get() == pCtrl )
2238  else if ( m_xColumnsBtn.get() == pCtrl )
2240  else if ( m_xAllSheetsCB.get() == pCtrl )
2242 }
2243 
2245 {
2246  if ( !pSearchItem )
2247  return;
2248 
2249  if ( m_xLayoutBtn->get_active() )
2250  {
2251  pSearchItem->SetSearchString ( m_xSearchTmplLB->get_active_text() );
2252  pSearchItem->SetReplaceString( m_xReplaceTmplLB->get_active_text() );
2253  }
2254  else
2255  {
2256  pSearchItem->SetSearchString ( m_xSearchLB->get_active_text() );
2257  pSearchItem->SetReplaceString( m_xReplaceLB->get_active_text() );
2258  Remember_Impl( m_xSearchLB->get_active_text(), true );
2259  }
2260 
2261  pSearchItem->SetRegExp( false );
2262  pSearchItem->SetWildcard( false );
2263  pSearchItem->SetLevenshtein( false );
2264  if (GetCheckBoxValue(*m_xRegExpBtn))
2265  pSearchItem->SetRegExp( true );
2266  else if (GetCheckBoxValue(*m_xWildcardBtn))
2267  pSearchItem->SetWildcard( true );
2268  else if (GetCheckBoxValue(*m_xSimilarityBox))
2269  pSearchItem->SetLevenshtein( true );
2270 
2271  pSearchItem->SetWordOnly(GetCheckBoxValue(*m_xWordBtn));
2272  pSearchItem->SetBackward(GetCheckBoxValue(*m_xReplaceBackwardsCB));
2273  pSearchItem->SetNotes(GetCheckBoxValue(*m_xNotesBtn));
2274  pSearchItem->SetPattern(GetCheckBoxValue(*m_xLayoutBtn));
2275  pSearchItem->SetSelection(GetCheckBoxValue(*m_xSelectionBtn));
2276  pSearchItem->SetUseAsianOptions(GetCheckBoxValue(*m_xJapOptionsCB));
2277 
2278  SvtSearchOptions aOpt;
2279  aOpt.SetIgnoreDiacritics_CTL(GetNegatedCheckBoxValue(*m_xIncludeDiacritics));
2280  aOpt.SetIgnoreKashida_CTL(GetNegatedCheckBoxValue(*m_xIncludeKashida));
2281  aOpt.Commit();
2282 
2284  if( !pSearchItem->IsUseAsianOptions())
2285  nFlags &= TransliterationFlags::IGNORE_CASE |
2286  TransliterationFlags::IGNORE_WIDTH;
2287  if (GetNegatedCheckBoxValue(*m_xIncludeDiacritics))
2288  nFlags |= TransliterationFlags::IGNORE_DIACRITICS_CTL;
2289  if (GetNegatedCheckBoxValue(*m_xIncludeKashida))
2290  nFlags |= TransliterationFlags::IGNORE_KASHIDA_CTL;
2291  pSearchItem->SetTransliterationFlags( nFlags );
2292 
2293  if ( !bWriter )
2294  {
2295  if (m_xCalcSearchInLB->get_active() != -1)
2296  pSearchItem->SetCellType( static_cast<SvxSearchCellType>(m_xCalcSearchInLB->get_active()) );
2297 
2298  pSearchItem->SetRowDirection( m_xRowsBtn->get_active() );
2299  pSearchItem->SetAllTables( m_xAllSheetsCB->get_active() );
2300  pSearchItem->SetSearchFormatted( m_xSearchFormattedCB->get_active() );
2301  }
2302 
2303  pSearchItem->SetCommand( SvxSearchCmd::FIND );
2305  const SfxPoolItem* ppArgs[] = { pSearchItem.get(), nullptr };
2306  rBindings.GetDispatcher()->Execute( SID_SEARCH_ITEM, SfxCallMode::SLOT, ppArgs );
2307 }
2308 
2310  assert(!m_executingSubDialog);
2311  comphelper::ScopeGuard g([this] { m_executingSubDialog = false; });
2312  m_executingSubDialog = true;
2313  return dialog->Execute();
2314 }
2315 
2317 
2318 
2320  SfxBindings* pBindings,
2321  SfxChildWinInfo const * pInfo )
2322  : SfxChildWindow( _pParent, nId )
2323  , dialog(std::make_shared<SvxSearchDialog>(_pParent->GetFrameWeld(), this, *pBindings))
2324 {
2326  dialog->Initialize( pInfo );
2327 
2328  pBindings->Update( SID_SEARCH_ITEM );
2329  pBindings->Update( SID_SEARCH_OPTIONS );
2330  pBindings->Update( SID_SEARCH_SEARCHSET );
2331  pBindings->Update( SID_SEARCH_REPLACESET );
2332  dialog->bConstruct = false;
2333 }
2334 
2336 {
2337 }
2338 
2339 
2341 {
2343  aInfo.bVisible = false;
2344  return aInfo;
2345 }
2346 
2347 static void lcl_SetSearchLabelWindow(const OUString& rStr)
2348 {
2349  SfxViewFrame* pViewFrame = SfxViewFrame::Current();
2350  if (!pViewFrame)
2351  return;
2352 
2353  bool bNotFound = rStr == SvxResId(RID_SVXSTR_SEARCH_NOT_FOUND);
2354 
2355  css::uno::Reference< css::beans::XPropertySet > xPropSet(
2356  pViewFrame->GetFrame().GetFrameInterface(), css::uno::UNO_QUERY_THROW);
2357  css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
2358  xPropSet->getPropertyValue("LayoutManager") >>= xLayoutManager;
2359  css::uno::Reference< css::ui::XUIElement > xUIElement =
2360  xLayoutManager->getElement("private:resource/toolbar/findbar");
2361  if (!xUIElement.is())
2362  return;
2363  css::uno::Reference< css::awt::XWindow > xWindow(
2364  xUIElement->getRealInterface(), css::uno::UNO_QUERY_THROW);
2365  VclPtr< ToolBox > pToolBox = static_cast<ToolBox*>( VCLUnoHelper::GetWindow(xWindow) );
2366  for (ToolBox::ImplToolItems::size_type i = 0; pToolBox && i < pToolBox->GetItemCount(); ++i)
2367  {
2368  ToolBoxItemId id = pToolBox->GetItemId(i);
2369  if (pToolBox->GetItemCommand(id) == ".uno:SearchLabel")
2370  {
2371  LabelItemWindow* pSearchLabel = dynamic_cast<LabelItemWindow*>(pToolBox->GetItemWindow(id));
2372  assert(pSearchLabel);
2373  pSearchLabel->set_label(rStr);
2374  if (rStr.isEmpty())
2375  pSearchLabel->SetSizePixel(Size(16, pSearchLabel->GetSizePixel().Height()));
2376  else
2377  pSearchLabel->SetOptimalSize();
2378  }
2379 
2380  if (pToolBox->GetItemCommand(id) == ".uno:FindText")
2381  {
2382  FindTextFieldControl* pFindText = dynamic_cast<FindTextFieldControl*>(pToolBox->GetItemWindow(id));
2383  assert(pFindText);
2384  if (bNotFound)
2386  else
2388  }
2389  }
2390  xLayoutManager->doLayout();
2391  pToolBox->Resize();
2392 }
2393 
2395 {
2396  SfxViewFrame* pViewFrame = SfxViewFrame::Current();
2397  if (!pViewFrame)
2398  return OUString();
2399 
2400  css::uno::Reference< css::beans::XPropertySet > xPropSet(
2401  pViewFrame->GetFrame().GetFrameInterface(), css::uno::UNO_QUERY_THROW);
2402  css::uno::Reference< css::frame::XLayoutManager > xLayoutManager;
2403  xPropSet->getPropertyValue("LayoutManager") >>= xLayoutManager;
2404  if (!xLayoutManager.is())
2405  return OUString();
2406  css::uno::Reference< css::ui::XUIElement > xUIElement =
2407  xLayoutManager->getElement("private:resource/toolbar/findbar");
2408  if (!xUIElement.is())
2409  return OUString();
2410  css::uno::Reference< css::awt::XWindow > xWindow(
2411  xUIElement->getRealInterface(), css::uno::UNO_QUERY_THROW);
2412  VclPtr< ToolBox > pToolBox = static_cast<ToolBox*>( VCLUnoHelper::GetWindow(xWindow) );
2413  for (ToolBox::ImplToolItems::size_type i = 0; pToolBox && i < pToolBox->GetItemCount(); ++i)
2414  {
2415  ToolBoxItemId id = pToolBox->GetItemId(i);
2416  if (pToolBox->GetItemCommand(id) == ".uno:SearchLabel")
2417  {
2418  LabelItemWindow* pSearchLabel = dynamic_cast<LabelItemWindow*>(pToolBox->GetItemWindow(id));
2419  return pSearchLabel ? pSearchLabel->get_label() : OUString();
2420  }
2421  }
2422  return OUString();
2423 }
2424 
2426 {
2427  OUString sStr;
2428  if (rSL == SearchLabel::End)
2429  sStr = SvxResId(RID_SVXSTR_SEARCH_END);
2430  else if (rSL == SearchLabel::Start)
2431  sStr = SvxResId(RID_SVXSTR_SEARCH_START);
2432  else if (rSL == SearchLabel::EndWrapped)
2433  sStr = SvxResId(RID_SVXSTR_SEARCH_END_WRAPPED);
2434  else if (rSL == SearchLabel::StartWrapped)
2435  sStr = SvxResId(RID_SVXSTR_SEARCH_START_WRAPPED);
2436  else if (rSL == SearchLabel::EndSheet)
2437  sStr = SvxResId(RID_SVXSTR_SEARCH_END_SHEET);
2438  else if (rSL == SearchLabel::NotFound)
2439  sStr = SvxResId(RID_SVXSTR_SEARCH_NOT_FOUND);
2440  else if (rSL == SearchLabel::NavElementNotFound)
2441  sStr = SvxResId(RID_SVXSTR_SEARCH_NAV_ELEMENT_NOT_FOUND);
2442  else if (rSL == SearchLabel::ReminderEndWrapped)
2443  sStr = SvxResId(RID_SVXSTR_SEARCH_REMINDER_END_WRAPPED);
2444  else if (rSL == SearchLabel::ReminderStartWrapped)
2445  sStr = SvxResId(RID_SVXSTR_SEARCH_REMINDER_START_WRAPPED);
2446 
2448  if (SvxSearchDialogWrapper *pWrp = static_cast<SvxSearchDialogWrapper*>( SfxViewFrame::Current()->
2449  GetChildWindow( SvxSearchDialogWrapper::GetChildWindowId() )))
2450  pWrp->getDialog()->SetSearchLabel(sStr);
2451 }
2452 
2453 void SvxSearchDialogWrapper::SetSearchLabel(const OUString& sStr)
2454 {
2455 
2457  if (SvxSearchDialogWrapper *pWrp = static_cast<SvxSearchDialogWrapper*>( SfxViewFrame::Current()->
2458  GetChildWindow( SvxSearchDialogWrapper::GetChildWindowId() )))
2459  pWrp->getDialog()->SetSearchLabel(sStr);
2460 }
2461 
2462 /* 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
constexpr sal_uInt16 XATTR_FILL_LAST(XATTR_FILLUSESLIDEBACKGROUND)
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:1126
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:1643
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:1604
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:1580
SVX_DLLPRIVATE void PaintAttrText_Impl()
Definition: srchdlg.cxx:2165
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:2319
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:2093
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:2244
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:2394
int i
ModifyFlags nModifyFlag
Definition: srchdlg.hxx:150
static void lcl_SetSearchLabelWindow(const OUString &rStr)
Definition: srchdlg.cxx:2347
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:1054
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:2425
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
IMPL_LINK(SvxSearchDialog, LBSelectHdl_Impl, weld::ComboBox &, rCtrl, void)
Definition: srchdlg.cxx:1116
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:2309
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:1763
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:2202
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:2335
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()
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:1865
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
bool m_bDetectedRangeSegmentation false
void set_label(const OUString &rLabel)