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