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