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