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( sal_uInt16 nId, const std::vector<OUString>& rStrLst )
172{
173 DBG_ASSERT( !rStrLst.empty(), "check in advance");
174 SfxGetpApp()->PutItem( SfxStringListItem( nId, &rStrLst ) );
175}
176
178 SrchAttrItemList(std::move(rList))
179{
180 for ( size_t i = 0; i < size(); ++i )
181 if ( !IsInvalidItem( (*this)[i].pItem ) )
182 (*this)[i].pItem = (*this)[i].pItem->Clone();
183}
184
186 SrchAttrItemList(rList)
187{
188 for ( size_t i = 0; i < size(); ++i )
189 if ( !IsInvalidItem( (*this)[i].pItem ) )
190 (*this)[i].pItem = (*this)[i].pItem->Clone();
191}
192
194{
195 Clear();
196}
197
199{
200 if ( !rSet.Count() )
201 return;
202
203 SfxItemPool* pPool = rSet.GetPool();
204 SfxItemIter aIter( rSet );
205 SearchAttrItem aItem;
206 const SfxPoolItem* pItem = aIter.GetCurItem();
207 sal_uInt16 nWhich;
208
209 do
210 {
211 // only test that it is available?
212 if( IsInvalidItem( pItem ) )
213 {
214 nWhich = rSet.GetWhichByPos( aIter.GetCurPos() );
215 aItem.pItem = const_cast<SfxPoolItem*>(pItem);
216 }
217 else
218 {
219 nWhich = pItem->Which();
220 aItem.pItem = pItem->Clone();
221 }
222
223 aItem.nSlot = pPool->GetSlotId( nWhich );
224 Insert( aItem );
225
226 pItem = aIter.NextItem();
227 } while (pItem);
228}
229
230
232{
233 SfxItemPool* pPool = rSet.GetPool();
234
235 for ( size_t i = 0; i < size(); ++i )
236 if ( IsInvalidItem( (*this)[i].pItem ) )
237 rSet.InvalidateItem( pPool->GetWhich( (*this)[i].nSlot ) );
238 else
239 rSet.Put( *(*this)[i].pItem );
240 return rSet;
241}
242
243
245{
246 for ( size_t i = 0; i < size(); ++i )
247 if ( !IsInvalidItem( (*this)[i].pItem ) )
248 delete (*this)[i].pItem;
249 SrchAttrItemList::clear();
250}
251
252
253// Deletes the pointer to the items
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 SvtCTLOptions aCTLOptions;
448 // Do not disable and hide the m_xIncludeDiacritics button.
449 // Include Diacritics == Not Ignore Diacritics => A does not match A-Umlaut (Diaeresis).
450 // Confusingly these have negated names (following the UI) but the actual
451 // transliteration is to *ignore* diacritics if "included" (sensitive) is
452 // _not_ checked.
453 if(!aCTLOptions.IsCTLFontEnabled())
454 {
455 m_xIncludeDiacritics->set_active( true );
456 m_xIncludeKashida->set_active( true );
457 m_xIncludeKashida->hide();
458 }
459 //component extension - show component search buttons if the commands
460 // vnd.sun.star::SearchViaComponent1 and 2 are supported
461 const uno::Reference< frame::XFrame >xFrame = rBindings.GetActiveFrame();
462 const uno::Reference< frame::XDispatchProvider > xDispatchProv(xFrame, uno::UNO_QUERY);
463
464 bool bSearchComponent1 = false;
465 bool bSearchComponent2 = false;
466 if(xDispatchProv.is())
467 {
468 OUString sTarget("_self");
469 pImpl->xCommand1Dispatch = xDispatchProv->queryDispatch(pImpl->aCommand1URL, sTarget, 0);
470 if (pImpl->xCommand1Dispatch.is())
471 bSearchComponent1 = true;
472 pImpl->xCommand2Dispatch = xDispatchProv->queryDispatch(pImpl->aCommand2URL, sTarget, 0);
473 if (pImpl->xCommand2Dispatch.is())
474 bSearchComponent2 = true;
475 }
476
477 if( !(bSearchComponent1 || bSearchComponent2) )
478 return;
479
480 try
481 {
482 uno::Reference< lang::XMultiServiceFactory > xConfigurationProvider =
483 configuration::theDefaultProvider::get( comphelper::getProcessComponentContext() );
484 uno::Sequence< uno::Any > aArgs {
485 Any(OUString( "/org.openoffice.Office.Common/SearchOptions/")) };
486
487 uno::Reference< uno::XInterface > xIFace = xConfigurationProvider->createInstanceWithArguments(
488 "com.sun.star.configuration.ConfigurationUpdateAccess",
489 aArgs);
490 uno::Reference< container::XNameAccess> xDirectAccess(xIFace, uno::UNO_QUERY);
491 if(xDirectAccess.is())
492 {
493 OUString sTemp;
494 uno::Any aRet = xDirectAccess->getByName("ComponentSearchGroupLabel");
495 aRet >>= sTemp;
496 m_xComponentFrame->set_label(sTemp);
497 aRet = xDirectAccess->getByName("ComponentSearchCommandLabel1");
498 aRet >>= sTemp;
499 m_xSearchComponent1PB->set_label( sTemp );
500 aRet = xDirectAccess->getByName("ComponentSearchCommandLabel2");
501 aRet >>= sTemp;
502 m_xSearchComponent2PB->set_label( sTemp );
503 }
504 }
505 catch(uno::Exception&){}
506
507 if(!m_xSearchComponent1PB->get_label().isEmpty() && bSearchComponent1 )
508 {
509 m_xComponentFrame->show();
510 m_xSearchComponent1PB->show();
511 }
512 if( !m_xSearchComponent2PB->get_label().isEmpty() )
513 {
514 m_xComponentFrame->show();
515 m_xSearchComponent2PB->show();
516 }
517}
518
520{
521 // remember strings
522 if (!aSearchStrings.empty())
523 StrArrToList_Impl( SID_SEARCHDLG_SEARCHSTRINGS, aSearchStrings );
524
525 if (!aReplaceStrings.empty())
526 StrArrToList_Impl( SID_SEARCHDLG_REPLACESTRINGS, aReplaceStrings );
527
528 // save settings to configuration
529 SvtSearchOptions aOpt;
530 aOpt.SetWholeWordsOnly ( m_xWordBtn->get_active() );
531 aOpt.SetBackwards ( m_xReplaceBackwardsCB->get_active() );
532 aOpt.SetUseRegularExpression ( m_xRegExpBtn->get_active() );
533 aOpt.SetUseWildcard ( m_xWildcardBtn->get_active() );
534 aOpt.SetSearchForStyles ( m_xLayoutBtn->get_active() );
535 aOpt.SetSimilaritySearch ( m_xSimilarityBox->get_active() );
536 aOpt.SetUseAsianOptions ( m_xJapOptionsCB->get_active() );
537 aOpt.SetNotes ( m_xNotesBtn->get_active() );
538 aOpt.SetIgnoreDiacritics_CTL ( !m_xIncludeDiacritics->get_active() );
539 aOpt.SetIgnoreKashida_CTL ( !m_xIncludeKashida->get_active() );
540 aOpt.SetSearchFormatted ( m_xSearchFormattedCB->get_active() );
541 aOpt.Commit();
542
543 if (IsClosing())
544 return;
545
546 const SfxPoolItem* ppArgs[] = { pSearchItem.get(), nullptr };
547 rBindings.GetDispatcher()->Execute( FID_SEARCH_OFF, SfxCallMode::SLOT, ppArgs );
548 rBindings.Invalidate(SID_SEARCH_DLG);
549
550 SfxViewFrame* pViewFrame = SfxViewFrame::Current();
551 if (pViewFrame)
552 pViewFrame->ToggleChildWindow(SID_SEARCH_DLG);
553}
554
556{
557 if (!m_xMatchCaseCB->get_active())
558 nTransliterationFlags |= TransliterationFlags::IGNORE_CASE;
559 else
561 if ( !m_xJapMatchFullHalfWidthCB->get_active())
562 nTransliterationFlags |= TransliterationFlags::IGNORE_WIDTH;
563 else
566}
567
569{
570 pImpl->bSaveToModule = b;
571}
572
573void SvxSearchDialog::SetSearchLabel(const OUString& rStr)
574{
575 m_xSearchLabel->set_label(rStr);
576 if (!rStr.isEmpty())
577 {
578 // hide/show to fire SHOWING state change event so search label text
579 // is announced by screen reader
580 m_xSearchLabel->hide();
581 m_xSearchLabel->show();
582 }
583
584 if (rStr == SvxResId(RID_SVXSTR_SEARCH_NOT_FOUND))
585 m_xSearchLB->set_entry_message_type(weld::EntryMessageType::Error);
586}
587
589{
590 nTransliterationFlags = nSettings;
591 bool bVal(nSettings & TransliterationFlags::IGNORE_CASE);
592 m_xMatchCaseCB->set_active( !bVal );
593 bVal = bool(nSettings & TransliterationFlags::IGNORE_WIDTH);
594 m_xJapMatchFullHalfWidthCB->set_active( !bVal );
595}
596
597
599{
600 return m_xReplaceBackwardsCB->get_active() ||
601 m_xSelectionBtn->get_active() ||
602 m_xRegExpBtn->get_active() ||
603 m_xLayoutBtn->get_active() ||
604 m_xSimilarityBox->get_active() ||
605 m_xJapMatchFullHalfWidthCB->get_active() ||
606 m_xJapOptionsCB->get_active() ||
607 m_xWildcardBtn->get_active() ||
608 m_xNotesBtn->get_active() ||
609 m_xIncludeKashida->get_active() ||
610 !m_xIncludeDiacritics->get_active();//tdf#138173
611}
612
614{
615 // apply possible transliteration changes of the SvxSearchItem member
616 if (pSearchItem)
617 {
618 m_xMatchCaseCB->set_active( pSearchItem->GetExact() );
619 m_xJapMatchFullHalfWidthCB->set_active( !pSearchItem->IsMatchFullHalfWidthForms() );
620 }
621
623}
624
626{
627 // CaseSensitives AutoComplete
628 m_xSearchLB->set_entry_completion( true, true );
629 m_xSearchLB->show();
630 m_xReplaceLB->set_entry_completion( true, true );
631 m_xReplaceLB->show();
632
633 m_xFormatBtn->set_sensitive(false);
634 m_xAttributeBtn->set_sensitive(false);
635
636 m_xSearchLB->connect_changed( LINK( this, SvxSearchDialog, ModifyHdl_Impl ) );
637 m_xReplaceLB->connect_changed( LINK( this, SvxSearchDialog, ModifyHdl_Impl ) );
638
639 Link<weld::Widget&,void> aLink = LINK( this, SvxSearchDialog, FocusHdl_Impl );
640 m_xSearchLB->connect_focus_in( aLink );
641 m_xReplaceLB->connect_focus_in( aLink );
642
643 aLink = LINK( this, SvxSearchDialog, LoseFocusHdl_Impl );
644 m_xSearchLB->connect_focus_out( aLink );
645 m_xReplaceLB->connect_focus_out( aLink );
646
647 m_xSearchTmplLB->connect_focus_out( aLink );
648 m_xReplaceTmplLB->connect_focus_out( aLink );
649
650 Link<weld::Button&,void> aLink2 = LINK( this, SvxSearchDialog, CommandHdl_Impl );
651 m_xSearchBtn->connect_clicked( aLink2 );
652 m_xBackSearchBtn->connect_clicked( aLink2 );
653 m_xSearchAllBtn->connect_clicked( aLink2 );
654 m_xReplaceBtn->connect_clicked( aLink2 );
655 m_xReplaceAllBtn->connect_clicked( aLink2 );
656 m_xCloseBtn->connect_clicked( aLink2 );
657 m_xSimilarityBtn->connect_clicked( aLink2 );
658 m_xJapOptionsBtn->connect_clicked( aLink2 );
659 m_xSearchComponent1PB->connect_clicked( aLink2 );
660 m_xSearchComponent2PB->connect_clicked( aLink2 );
661
662 Link<weld::Toggleable&,void> aLink3 = LINK( this, SvxSearchDialog, FlagHdl_Impl );
663 m_xReplaceBackwardsCB->connect_toggled( aLink3 );
664 m_xWordBtn->connect_toggled( aLink3 );
665 m_xSelectionBtn->connect_toggled( aLink3 );
666 m_xMatchCaseCB->connect_toggled( aLink3 );
667 m_xRegExpBtn->connect_toggled( aLink3 );
668 m_xWildcardBtn->connect_toggled( aLink3 );
669 m_xNotesBtn->connect_toggled( aLink3 );
670 m_xSimilarityBox->connect_toggled( aLink3 );
671 m_xJapOptionsCB->connect_toggled( aLink3 );
672 m_xJapMatchFullHalfWidthCB->connect_toggled( aLink3 );
673 m_xIncludeDiacritics->connect_toggled( aLink3 );
674 m_xIncludeKashida->connect_toggled( aLink3 );
675 m_xLayoutBtn->connect_toggled( LINK( this, SvxSearchDialog, TemplateHdl_Impl ) );
676 m_xFormatBtn->connect_clicked( LINK( this, SvxSearchDialog, FormatHdl_Impl ) );
677 m_xNoFormatBtn->connect_clicked(
678 LINK( this, SvxSearchDialog, NoFormatHdl_Impl ) );
679 m_xAttributeBtn->connect_clicked(
680 LINK( this, SvxSearchDialog, AttributeHdl_Impl ) );
681}
682
683namespace
684{
685 SvtModuleOptions::EFactory getModule(SfxBindings const & rBindings)
686 {
688 try
689 {
690 const uno::Reference< frame::XFrame > xFrame =
691 rBindings.GetActiveFrame();
692 uno::Reference< frame::XModuleManager2 > xModuleManager(
693 frame::ModuleManager::create(::comphelper::getProcessComponentContext()));
694
695 OUString aModuleIdentifier = xModuleManager->identify( xFrame );
696 eFactory = SvtModuleOptions::ClassifyFactoryByServiceName(aModuleIdentifier);
697 }
698 catch (const uno::Exception&)
699 {
700 }
701 return eFactory;
702 }
703}
704
706{
707 DBG_ASSERT( pSearchItem, "no search item" );
708
709 SvtCTLOptions aCTLOptions;
710 SvtModuleOptions::EFactory eFactory = getModule(rBindings);
711 bool bDrawApp = eFactory == SvtModuleOptions::EFactory::DRAW;
712 bool bWriterApp =
716 bool bCalcApp = eFactory == SvtModuleOptions::EFactory::CALC;
717
718 m_xLayoutBtn->set_visible(!bDrawApp);
719 m_xNotesBtn->set_visible(bWriterApp);
720 m_xRegExpBtn->set_visible(!bDrawApp);
721 m_xWildcardBtn->set_visible(bCalcApp); /* TODO:WILDCARD enable for other apps if hey handle it */
722 m_xReplaceBackwardsCB->show();
723 m_xSimilarityBox->show();
724 m_xSimilarityBtn->show();
725 m_xSelectionBtn->show();
726 m_xIncludeDiacritics->show();
727 m_xIncludeKashida->set_visible(aCTLOptions.IsCTLFontEnabled());
731
732 if (bWriter)
733 {
734 m_xAttributeBtn->show();
735 m_xFormatBtn->show();
736 m_xNoFormatBtn->show();
737 }
738
739 if (bCalcApp)
740 {
741 m_xCalcSearchInFT->show();
742 m_xCalcSearchInLB->show();
743 m_xCalcSearchDirFT->show();
744 m_xRowsBtn->show();
745 m_xColumnsBtn->show();
746 m_xAllSheetsCB->show();
747 m_xSearchFormattedCB->show();
748 }
749}
750
751
752namespace {
753
754class ToggleSaveToModule
755{
756public:
757 ToggleSaveToModule(SvxSearchDialog& rDialog, bool bValue) :
758 mrDialog(rDialog), mbValue(bValue)
759 {
760 mrDialog.SetSaveToModule(mbValue);
761 }
762
763 ~ToggleSaveToModule()
764 {
765 mrDialog.SetSaveToModule(!mbValue);
766 }
767private:
768 SvxSearchDialog& mrDialog;
769 bool mbValue;
770};
771
772}
773
774void SvxSearchDialog::Init_Impl( bool bSearchPattern )
775{
776 DBG_ASSERT( pSearchItem, "SearchItem == 0" );
777
778 // We don't want to save any intermediate state to the module while the
779 // dialog is being initialized.
780 ToggleSaveToModule aNoModuleSave(*this, false);
781 SvtSearchOptions aOpt;
782
783 bWriter = ( pSearchItem->GetAppFlag() == SvxSearchApp::WRITER );
784
785 if ( !( nModifyFlag & ModifyFlags::Word ) )
786 m_xWordBtn->set_active( pSearchItem->GetWordOnly() );
787 if ( !( nModifyFlag & ModifyFlags::Exact ) )
788 m_xMatchCaseCB->set_active( pSearchItem->GetExact() );
790 m_xReplaceBackwardsCB->set_active( bReplaceBackwards ); //adjustment to replace backwards
791 if ( !( nModifyFlag & ModifyFlags::Notes ) )
792 m_xNotesBtn->set_active( pSearchItem->GetNotes() );
794 m_xSelectionBtn->set_active( pSearchItem->GetSelection() );
795 if ( !( nModifyFlag & ModifyFlags::Regexp ) )
796 m_xRegExpBtn->set_active( pSearchItem->GetRegExp() );
798 m_xWildcardBtn->set_active( pSearchItem->GetWildcard() );
799 if ( !( nModifyFlag & ModifyFlags::Layout ) )
800 m_xLayoutBtn->set_active( pSearchItem->GetPattern() );
801 if (m_xNotesBtn->get_active())
802 m_xLayoutBtn->set_sensitive(false);
803 m_xSimilarityBox->set_active( pSearchItem->IsLevenshtein() );
804 if ( m_xJapOptionsCB->get_visible() )
805 m_xJapOptionsCB->set_active( pSearchItem->IsUseAsianOptions() );
806 m_xIncludeDiacritics->set_active( !aOpt.IsIgnoreDiacritics_CTL() );
807 if ( m_xIncludeKashida->get_visible() )
808 m_xIncludeKashida->set_active( !aOpt.IsIgnoreKashida_CTL() );
809 ApplyTransliterationFlags_Impl( pSearchItem->GetTransliterationFlags() );
810
812
813 if ( pSearchItem->GetAppFlag() == SvxSearchApp::CALC )
814 {
815 m_xCalcGrid->show();
816 m_xSearchFormattedCB->set_active( aOpt.IsSearchFormatted() );
817 Link<weld::Toggleable&,void> aLink = LINK( this, SvxSearchDialog, FlagHdl_Impl );
818 m_xCalcSearchInLB->connect_changed( LINK( this, SvxSearchDialog, LBSelectHdl_Impl ) );
819 m_xRowsBtn->connect_toggled( aLink );
820 m_xColumnsBtn->connect_toggled( aLink );
821 m_xAllSheetsCB->connect_toggled( aLink );
822 m_xSearchFormattedCB->connect_toggled( aLink );
823
824 ModifyFlags nModifyFlagCheck;
825 switch ( pSearchItem->GetCellType() )
826 {
827 case SvxSearchCellType::FORMULA:
828 nModifyFlagCheck = ModifyFlags::Formulas;
829 break;
830
831 case SvxSearchCellType::VALUE:
832 nModifyFlagCheck = ModifyFlags::Values;
833 break;
834
835 case SvxSearchCellType::NOTE:
836 nModifyFlagCheck = ModifyFlags::CalcNotes;
837 break;
838
839 default:
840 std::abort(); // cannot happen
841 }
842 if ( !(nModifyFlag & nModifyFlagCheck) )
843 m_xCalcSearchInLB->set_active( static_cast<sal_Int32>(pSearchItem->GetCellType()) );
844
845 m_xWordBtn->set_label( aCalcStr.getToken( 0, '#' ) );
846
847 if ( pSearchItem->GetRowDirection() &&
849 m_xRowsBtn->set_active(true);
850 else if ( !pSearchItem->GetRowDirection() &&
852 m_xColumnsBtn->set_active(true);
853
855 m_xAllSheetsCB->set_active( pSearchItem->IsAllTables() );
856
857 // only look for formatting in Writer
858 m_xFormatBtn->hide();
859 m_xNoFormatBtn->hide();
860 m_xAttributeBtn->hide();
861 }
862 else
863 {
864 m_xSearchFormattedCB->hide();
865 m_xWordBtn->set_label( aCalcStr.getToken( 1, '#' ) );
866
867 if ( pSearchItem->GetAppFlag() == SvxSearchApp::DRAW )
868 {
869 m_xSearchAllBtn->hide();
870
871 m_xRegExpBtn->hide();
872 m_xWildcardBtn->hide();
873 m_xLayoutBtn->hide();
874
875 // only look for formatting in Writer
876 m_xFormatBtn->hide();
877 m_xNoFormatBtn->hide();
878 m_xAttributeBtn->hide();
879 }
880 else
881 {
882 m_xWildcardBtn->hide(); /* TODO:WILDCARD do not hide for other apps if they handle it */
883
884 if ( !pSearchList )
885 {
886 // Get attribute sets, if it not has been done already
887 const SfxPoolItem* ppArgs[] = { pSearchItem.get(), nullptr };
888 const SvxSetItem* pSrchSetItem =
889 static_cast<const SvxSetItem*>(rBindings.GetDispatcher()->Execute( FID_SEARCH_SEARCHSET, SfxCallMode::SLOT, ppArgs ));
890
891 if ( pSrchSetItem )
892 InitAttrList_Impl( &pSrchSetItem->GetItemSet(), nullptr );
893
894 const SvxSetItem* pReplSetItem =
895 static_cast<const SvxSetItem*>( rBindings.GetDispatcher()->Execute( FID_SEARCH_REPLACESET, SfxCallMode::SLOT, ppArgs ) );
896
897 if ( pReplSetItem )
898 InitAttrList_Impl( nullptr, &pReplSetItem->GetItemSet() );
899 }
900 }
901 }
902
903 // similarity search?
905 m_xSimilarityBox->set_active( pSearchItem->IsLevenshtein() );
906 bSet = true;
907
908 FlagHdl_Impl(*m_xSimilarityBox);
909 FlagHdl_Impl(*m_xJapOptionsCB);
910
911 bool bDisableSearch = false;
912 SfxViewShell* pViewShell = SfxViewShell::Current();
913
914 if ( pViewShell )
915 {
916 bool bText = !bSearchPattern;
917
918 if ( pViewShell->HasSelection( bText ) )
920 else
921 {
922 m_xSelectionBtn->set_active( false );
923 m_xSelectionBtn->set_sensitive(false);
924 }
925 }
926
927 // Pattern Search and there were no AttrSets given
928 if ( bSearchPattern )
929 {
931
932 if ( pShell && pShell->GetStyleSheetPool() )
933 {
934 // Templates designed
935 m_xSearchTmplLB->clear();
936 m_xReplaceTmplLB->clear();
937 SfxStyleSheetBasePool* pStylePool = pShell->GetStyleSheetPool();
938 SfxStyleSheetBase* pBase = pStylePool->First(pSearchItem->GetFamily());
939
940 while ( pBase )
941 {
942 if ( pBase->IsUsed() )
943 m_xSearchTmplLB->append_text( pBase->GetName() );
944 m_xReplaceTmplLB->append_text( pBase->GetName() );
945 pBase = pStylePool->Next();
946 }
947 m_xSearchTmplLB->set_active_text( pSearchItem->GetSearchString() );
948 m_xReplaceTmplLB->set_active_text( pSearchItem->GetReplaceString() );
949
950 }
951 m_xSearchTmplLB->show();
952
953 if ( bConstruct )
954 // Grab focus only after creating
955 m_xSearchTmplLB->grab_focus();
956 m_xReplaceTmplLB->show();
957 m_xSearchLB->hide();
958 m_xReplaceLB->hide();
959
960 m_xWordBtn->set_sensitive(false);
961 m_xRegExpBtn->set_sensitive(false);
962 m_xWildcardBtn->set_sensitive(false);
963 m_xMatchCaseCB->set_sensitive(false);
964
965 bDisableSearch = !m_xSearchTmplLB->get_count();
966 }
967 else
968 {
969 bool bSetSearch = !( nModifyFlag & ModifyFlags::Search );
970 bool bSetReplace = !( nModifyFlag & ModifyFlags::Replace );
971
972 if ( !(pSearchItem->GetSearchString().isEmpty()) && bSetSearch )
973 m_xSearchLB->set_entry_text( pSearchItem->GetSearchString() );
974 else if (!aSearchStrings.empty())
975 {
976 bool bAttributes =
977 ( ( pSearchList && pSearchList->Count() ) ||
978 ( pReplaceList && pReplaceList->Count() ) );
979
980 if ( bSetSearch && !bAttributes )
981 m_xSearchLB->set_entry_text(aSearchStrings[0]);
982
983 OUString aReplaceTxt = pSearchItem->GetReplaceString();
984
985 if (!aReplaceStrings.empty())
986 aReplaceTxt = aReplaceStrings[0];
987
988 if ( bSetReplace && !bAttributes )
989 m_xReplaceLB->set_entry_text( aReplaceTxt );
990 }
991 m_xSearchLB->show();
992
993 if ( bConstruct )
994 // Grab focus only after creating
995 m_xSearchLB->grab_focus();
996 m_xReplaceLB->show();
997 m_xSearchTmplLB->hide();
998 m_xReplaceTmplLB->hide();
999
1003
1004 if ( m_xRegExpBtn->get_active() )
1005 m_xWordBtn->set_sensitive(false);
1006 else
1008
1009 bDisableSearch = m_xSearchLB->get_active_text().isEmpty() &&
1010 m_xSearchAttrText->get_label().isEmpty();
1011 }
1012 FocusHdl_Impl(*m_xSearchLB);
1013
1014 if ( bDisableSearch )
1015 {
1016 m_xSearchBtn->set_sensitive(false);
1017 m_xBackSearchBtn->set_sensitive(false);
1018 m_xSearchAllBtn->set_sensitive(false);
1019 m_xReplaceBtn->set_sensitive(false);
1020 m_xReplaceAllBtn->set_sensitive(false);
1021 m_xComponentFrame->set_sensitive(false);
1022 }
1023 else
1024 {
1028 if (!bWriter || !m_xNotesBtn->get_active())
1029 {
1032 }
1033 if (bWriter && pSearchItem->GetNotes())
1034 {
1035 m_xSearchAllBtn->set_sensitive(false);
1036 m_xReplaceAllBtn->set_sensitive(false);
1037 }
1038 }
1039
1040 if (!m_xSearchAttrText->get_label().isEmpty())
1042 else
1043 m_xNoFormatBtn->set_sensitive(false);
1044
1045 if ( !pSearchList )
1046 {
1047 m_xAttributeBtn->set_sensitive(false);
1048 m_xFormatBtn->set_sensitive(false);
1049 }
1050
1051 if ( m_xLayoutBtn->get_active() )
1052 {
1053 pImpl->bSaveToModule = false;
1054 TemplateHdl_Impl(*m_xLayoutBtn);
1055 pImpl->bSaveToModule = true;
1056 }
1057}
1058
1059
1061 const SfxItemSet* pRSet )
1062{
1063 if ( !pSSet && !pRSet )
1064 return;
1065
1066 if ( pImpl->pRanges.empty() && pSSet )
1067 pImpl->pRanges = pSSet->GetRanges();
1068
1069 bool bSetOptimalLayoutSize = false;
1070
1071 // See to it that are the texts of the attributes are correct
1072 OUString aDesc;
1073
1074 if ( pSSet )
1075 {
1077
1078 if ( pSSet->Count() )
1079 {
1080 pSearchList->Put( *pSSet );
1081
1082 m_xSearchAttrText->set_label( BuildAttrText_Impl( aDesc, true ) );
1083
1084 if ( !aDesc.isEmpty() )
1085 {
1086 if (!m_xSearchAttrText->get_visible())
1087 {
1088 m_xSearchAttrText->show();
1089 bSetOptimalLayoutSize = true;
1090 }
1091 bFormat |= true;
1092 }
1093 }
1094 }
1095
1096 if ( pRSet )
1097 {
1099
1100 if ( pRSet->Count() )
1101 {
1102 pReplaceList->Put( *pRSet );
1103
1104 m_xReplaceAttrText->set_label( BuildAttrText_Impl( aDesc, false ) );
1105
1106 if ( !aDesc.isEmpty() )
1107 {
1108 if (!m_xReplaceAttrText->get_visible())
1109 {
1110 m_xReplaceAttrText->show();
1111 bSetOptimalLayoutSize = true;
1112 }
1113 bFormat |= true;
1114 }
1115 }
1116 }
1117
1118 if (bSetOptimalLayoutSize)
1119 m_xDialog->resize_to_request();
1120}
1121
1122IMPL_LINK( SvxSearchDialog, LBSelectHdl_Impl, weld::ComboBox&, rCtrl, void )
1123{
1124 ClickHdl_Impl(&rCtrl);
1125}
1126
1127IMPL_LINK( SvxSearchDialog, FlagHdl_Impl, weld::Toggleable&, rCtrl, void )
1128{
1129 ClickHdl_Impl(&rCtrl);
1130}
1131
1133{
1134 if ( pCtrl && !bSet )
1135 SetModifyFlag_Impl(pCtrl);
1136 else
1137 bSet = false;
1138
1139 if (pCtrl == m_xSimilarityBox.get())
1140 {
1141 bool bIsChecked = m_xSimilarityBox->get_active();
1142
1143 if ( bIsChecked )
1144 {
1145 m_xSimilarityBtn->set_sensitive(true);
1146 m_xRegExpBtn->set_active( false );
1147 m_xRegExpBtn->set_sensitive(false);
1148 m_xWildcardBtn->set_active( false );
1149 m_xWildcardBtn->set_sensitive(false);
1151
1152 if ( m_xLayoutBtn->get_active() )
1153 {
1155 m_xLayoutBtn->set_active( false );
1156 }
1157 m_xRegExpBtn->set_sensitive(false);
1158 m_xWildcardBtn->set_sensitive(false);
1159 m_xLayoutBtn->set_sensitive(false);
1160 m_xFormatBtn->set_sensitive(false);
1161 m_xNoFormatBtn->set_sensitive(false);
1162 m_xAttributeBtn->set_sensitive(false);
1163 }
1164 else
1165 {
1168 if (!m_xNotesBtn->get_active())
1172 m_xSimilarityBtn->set_sensitive(false);
1173 }
1174 pSearchItem->SetLevenshtein( bIsChecked );
1175 }
1176 else if (pCtrl == m_xNotesBtn.get())
1177 {
1178 if (m_xNotesBtn->get_active())
1179 {
1180 m_xLayoutBtn->set_sensitive(false);
1181 m_xSearchAllBtn->set_sensitive(false);
1182 m_xReplaceAllBtn->set_sensitive(false);
1183 }
1184 else
1185 {
1187 ModifyHdl_Impl(*m_xSearchLB);
1188 }
1189 }
1190 else
1191 {
1192 if ( m_xLayoutBtn->get_active() && !bFormat )
1193 {
1194 m_xWordBtn->set_active( false );
1195 m_xWordBtn->set_sensitive(false);
1196 m_xRegExpBtn->set_active( false );
1197 m_xRegExpBtn->set_sensitive(false);
1198 m_xWildcardBtn->set_active( false );
1199 m_xWildcardBtn->set_sensitive(false);
1200 m_xMatchCaseCB->set_active( false );
1201 m_xMatchCaseCB->set_sensitive(false);
1202 m_xNotesBtn->set_sensitive(false);
1203
1204 if ( m_xSearchTmplLB->get_count() )
1205 {
1211 }
1212 }
1213 else
1214 {
1219
1220 if ( m_xRegExpBtn->get_active() )
1221 {
1222 m_xWordBtn->set_active( false );
1223 m_xWordBtn->set_sensitive(false);
1224 m_xWildcardBtn->set_active( false );
1225 m_xWildcardBtn->set_sensitive(false);
1226 m_xSimilarityBox->set_active( false );
1227 m_xSimilarityBox->set_sensitive(false);
1228 m_xSimilarityBtn->set_sensitive(false);
1229 }
1230 else if ( m_xWildcardBtn->get_active() )
1231 {
1232 m_xRegExpBtn->set_active( false );
1233 m_xRegExpBtn->set_sensitive(false);
1234 m_xSimilarityBox->set_active( false );
1235 m_xSimilarityBox->set_sensitive(false);
1236 m_xSimilarityBtn->set_sensitive(false);
1237 }
1238 else
1239 {
1242 }
1243
1244 // Search-string in place? then enable Buttons
1245 bSet = true;
1246 ModifyHdl_Impl(*m_xSearchLB);
1247 }
1248 }
1249
1250 if (pCtrl == m_xAllSheetsCB.get())
1251 {
1252 bSet = true;
1253 ModifyHdl_Impl(*m_xSearchLB);
1254 }
1255
1256 if (pCtrl == m_xJapOptionsCB.get())
1257 {
1258 bool bEnableJapOpt = m_xJapOptionsCB->get_active();
1259 m_xMatchCaseCB->set_sensitive(!bEnableJapOpt );
1260 m_xJapMatchFullHalfWidthCB->set_sensitive(!bEnableJapOpt );
1261 m_xJapOptionsBtn->set_sensitive( bEnableJapOpt );
1262 }
1263
1264 if ( pImpl->bSaveToModule )
1266}
1267
1268IMPL_LINK(SvxSearchDialog, CommandHdl_Impl, weld::Button&, rBtn, void)
1269{
1270 bool bInclusive = ( m_xLayoutBtn->get_label() == aLayoutStr );
1271
1272 if ( ( &rBtn == m_xSearchBtn.get() ) ||
1273 (&rBtn == m_xBackSearchBtn.get()) ||
1274 ( &rBtn == m_xSearchAllBtn.get() )||
1275 ( &rBtn == m_xReplaceBtn.get() ) ||
1276 ( &rBtn == m_xReplaceAllBtn.get() ) )
1277 {
1278 if ( m_xLayoutBtn->get_active() && !bInclusive )
1279 {
1280 pSearchItem->SetSearchString ( m_xSearchTmplLB->get_active_text() );
1281 pSearchItem->SetReplaceString( m_xReplaceTmplLB->get_active_text() );
1282 }
1283 else
1284 {
1285 pSearchItem->SetSearchString ( m_xSearchLB->get_active_text() );
1286 pSearchItem->SetReplaceString( m_xReplaceLB->get_active_text() );
1287
1288 if ( &rBtn == m_xReplaceBtn.get() )
1289 Remember_Impl( m_xReplaceLB->get_active_text(), false );
1290 else
1291 {
1292 Remember_Impl( m_xSearchLB->get_active_text(), true );
1293
1294 if ( &rBtn == m_xReplaceAllBtn.get() )
1295 Remember_Impl( m_xReplaceLB->get_active_text(), false );
1296 }
1297 }
1298
1299 pSearchItem->SetRegExp( false );
1300 pSearchItem->SetWildcard( false );
1301 pSearchItem->SetLevenshtein( false );
1302 if (GetCheckBoxValue(*m_xRegExpBtn))
1303 pSearchItem->SetRegExp( true );
1304 else if (GetCheckBoxValue(*m_xWildcardBtn))
1305 pSearchItem->SetWildcard( true );
1306 else if (GetCheckBoxValue(*m_xSimilarityBox))
1307 pSearchItem->SetLevenshtein( true );
1308
1309 pSearchItem->SetWordOnly(GetCheckBoxValue(*m_xWordBtn));
1310
1311 bool bSetBackwards = false;
1312 if( &rBtn == m_xBackSearchBtn.get())
1313 {
1314 bSetBackwards = true;
1315 }
1316 else if( &rBtn == m_xReplaceBtn.get())
1317 {
1318 bSetBackwards = GetCheckBoxValue(*m_xReplaceBackwardsCB);
1319 bReplaceBackwards = GetCheckBoxValue(*m_xReplaceBackwardsCB);
1320 }
1321
1322 pSearchItem->SetBackward(bSetBackwards);
1323
1324 pSearchItem->SetNotes(GetCheckBoxValue(*m_xNotesBtn));
1325 pSearchItem->SetPattern(GetCheckBoxValue(*m_xLayoutBtn));
1326 pSearchItem->SetSelection(GetCheckBoxValue(*m_xSelectionBtn));
1327 pSearchItem->SetUseAsianOptions(GetCheckBoxValue(*m_xJapOptionsCB));
1329 if( !pSearchItem->IsUseAsianOptions())
1330 nFlags &= TransliterationFlags::IGNORE_CASE |
1331 TransliterationFlags::IGNORE_WIDTH;
1332 if (GetNegatedCheckBoxValue(*m_xIncludeDiacritics))
1333 nFlags |= TransliterationFlags::IGNORE_DIACRITICS_CTL;
1334 if (GetNegatedCheckBoxValue(*m_xIncludeKashida))
1335 nFlags |= TransliterationFlags::IGNORE_KASHIDA_CTL;
1336 pSearchItem->SetTransliterationFlags( nFlags );
1337
1338 if ( !bWriter )
1339 {
1340 if ( m_xCalcSearchInLB->get_active() != -1)
1341 pSearchItem->SetCellType( static_cast<SvxSearchCellType>(m_xCalcSearchInLB->get_active()) );
1342
1343 pSearchItem->SetRowDirection( m_xRowsBtn->get_active() );
1344 pSearchItem->SetAllTables( m_xAllSheetsCB->get_active() );
1345 pSearchItem->SetSearchFormatted( m_xSearchFormattedCB->get_active() );
1346 }
1347
1348 if ((&rBtn == m_xSearchBtn.get()) || (&rBtn == m_xBackSearchBtn.get()))
1349 pSearchItem->SetCommand( SvxSearchCmd::FIND );
1350 else if ( &rBtn == m_xSearchAllBtn.get() )
1351 pSearchItem->SetCommand( SvxSearchCmd::FIND_ALL );
1352 else if ( &rBtn == m_xReplaceBtn.get() )
1353 pSearchItem->SetCommand( SvxSearchCmd::REPLACE );
1354 else if ( &rBtn == m_xReplaceAllBtn.get() )
1355 pSearchItem->SetCommand( SvxSearchCmd::REPLACE_ALL );
1356
1357 // when looking for templates, delete format lists
1358 if ( !bFormat && pSearchItem->GetPattern() )
1359 {
1360 if ( pSearchList )
1361 pSearchList->Clear();
1362
1363 if ( pReplaceList )
1364 pReplaceList->Clear();
1365 }
1366 nModifyFlag = ModifyFlags::NONE;
1367 const SfxPoolItem* ppArgs[] = { pSearchItem.get(), nullptr };
1368 rBindings.ExecuteSynchron( FID_SEARCH_NOW, ppArgs );
1369 }
1370 else if ( &rBtn == m_xCloseBtn.get() )
1371 {
1372 if ( !m_xLayoutBtn->get_active() || bInclusive )
1373 {
1374 OUString aStr( m_xSearchLB->get_active_text() );
1375
1376 if ( !aStr.isEmpty() )
1377 Remember_Impl( aStr, true );
1378 aStr = m_xReplaceLB->get_active_text();
1379
1380 if ( !aStr.isEmpty() )
1381 Remember_Impl( aStr, false );
1382 }
1383 SaveToModule_Impl();
1384 Close();
1385 }
1386 else if (&rBtn == m_xSimilarityBtn.get())
1387 {
1390 pSearchItem->IsLEVRelaxed(),
1391 pSearchItem->GetLEVOther(),
1392 pSearchItem->GetLEVShorter(),
1393 pSearchItem->GetLEVLonger() ));
1394 if ( executeSubDialog(pDlg.get()) == RET_OK )
1395 {
1396 pSearchItem->SetLEVRelaxed( pDlg->IsRelaxed() );
1397 pSearchItem->SetLEVOther( pDlg->GetOther() );
1398 pSearchItem->SetLEVShorter( pDlg->GetShorter() );
1399 pSearchItem->SetLEVLonger( pDlg->GetLonger() );
1400 SaveToModule_Impl();
1401 }
1402 }
1403 else if (&rBtn == m_xJapOptionsBtn.get())
1404 {
1405 SfxItemSet aSet( SfxGetpApp()->GetPool() );
1406 pSearchItem->SetTransliterationFlags( GetTransliterationFlags() );
1409 pSearchItem->GetTransliterationFlags() ));
1410 int nRet = executeSubDialog(aDlg.get());
1411 if (RET_OK == nRet)
1412 {
1413 TransliterationFlags nFlags = aDlg->GetTransliterationFlags();
1414 pSearchItem->SetTransliterationFlags( nFlags );
1415 ApplyTransliterationFlags_Impl( nFlags );
1416 }
1417 }
1418 else if (&rBtn == m_xSearchComponent1PB.get() || &rBtn == m_xSearchComponent2PB.get())
1419 {
1420 uno::Sequence < beans::PropertyValue > aArgs(2);
1421 beans::PropertyValue* pArgs = aArgs.getArray();
1422 pArgs[0].Name = "SearchString";
1423 pArgs[0].Value <<= m_xSearchLB->get_active_text();
1424 pArgs[1].Name = "ParentWindow";
1425 pArgs[1].Value <<= m_xDialog->GetXWindow();
1426 if (&rBtn == m_xSearchComponent1PB.get())
1427 {
1428 if ( pImpl->xCommand1Dispatch.is() )
1429 pImpl->xCommand1Dispatch->dispatch(pImpl->aCommand1URL, aArgs);
1430 }
1431 else
1432 {
1433 if ( pImpl->xCommand2Dispatch.is() )
1434 pImpl->xCommand2Dispatch->dispatch(pImpl->aCommand2URL, aArgs);
1435 }
1436 }
1437}
1438
1439
1440IMPL_LINK( SvxSearchDialog, ModifyHdl_Impl, weld::ComboBox&, rEd, void )
1441{
1442 if ( !bSet )
1443 SetModifyFlag_Impl( &rEd );
1444 else
1445 bSet = false;
1446
1447 // Calc allows searching for empty cells.
1448 bool bAllowEmptySearch = (pSearchItem->GetAppFlag() == SvxSearchApp::CALC);
1449
1450 if (&rEd != m_xSearchLB.get() && &rEd != m_xReplaceLB.get())
1451 return;
1452
1453 sal_Int32 nSrchTxtLen = m_xSearchLB->get_active_text().getLength();
1454 sal_Int32 nReplTxtLen = 0;
1455 if (bAllowEmptySearch)
1456 nReplTxtLen = m_xReplaceLB->get_active_text().getLength();
1457 sal_Int32 nAttrTxtLen = m_xSearchAttrText->get_label().getLength();
1458
1459 if (nSrchTxtLen || nReplTxtLen || nAttrTxtLen)
1460 {
1461 EnableControl_Impl(*m_xSearchBtn);
1462 EnableControl_Impl(*m_xBackSearchBtn);
1463 EnableControl_Impl(*m_xReplaceBtn);
1464 if (!bWriter || !m_xNotesBtn->get_active())
1465 {
1466 EnableControl_Impl(*m_xSearchAllBtn);
1467 EnableControl_Impl(*m_xReplaceAllBtn);
1468 }
1469 }
1470 else
1471 {
1472 m_xComponentFrame->set_sensitive(false);
1473 m_xSearchBtn->set_sensitive(false);
1474 m_xBackSearchBtn->set_sensitive(false);
1475 m_xSearchAllBtn->set_sensitive(false);
1476 m_xReplaceBtn->set_sensitive(false);
1477 m_xReplaceAllBtn->set_sensitive(false);
1478 }
1479}
1480
1482{
1483 if ( pImpl->bSaveToModule )
1484 SaveToModule_Impl();
1485
1486 if ( bFormat )
1487 return;
1488 OUString sDesc;
1489
1490 if ( m_xLayoutBtn->get_active() )
1491 {
1492 if ( !pFamilyController )
1493 {
1494 sal_uInt16 nId = 0;
1495
1496 // Enable templates controller
1497 switch ( pSearchItem->GetFamily() )
1498 {
1499 case SfxStyleFamily::Char:
1500 nId = SID_STYLE_FAMILY1; break;
1501
1502 case SfxStyleFamily::Para:
1503 nId = SID_STYLE_FAMILY2; break;
1504
1505 case SfxStyleFamily::Frame:
1506 nId = SID_STYLE_FAMILY3; break;
1507
1508 case SfxStyleFamily::Page:
1509 nId = SID_STYLE_FAMILY4; break;
1510
1511 case SfxStyleFamily::All:
1512 break;
1513
1514 default:
1515 OSL_FAIL( "StyleSheetFamily was changed?" );
1516 }
1517
1518 rBindings.EnterRegistrations();
1519 pFamilyController.reset(
1520 new SvxSearchController( nId, rBindings, *this ) );
1521 rBindings.LeaveRegistrations();
1522 m_xSearchTmplLB->clear();
1523 m_xReplaceTmplLB->clear();
1524
1525 m_xSearchTmplLB->show();
1526 m_xReplaceTmplLB->show();
1527 m_xSearchLB->hide();
1528 m_xReplaceLB->hide();
1529
1530 m_xSearchAttrText->set_label( sDesc );
1531 m_xReplaceAttrText->set_label( sDesc );
1532
1533 if(!sDesc.isEmpty())
1534 {
1535 if (!m_xReplaceAttrText->get_visible() || !m_xReplaceAttrText->get_visible())
1536 {
1537 m_xSearchAttrText->show();
1538 m_xReplaceAttrText->show();
1539 m_xDialog->resize_to_request();
1540 }
1541 }
1542 }
1543 m_xFormatBtn->set_sensitive(false);
1544 m_xNoFormatBtn->set_sensitive(false);
1545 m_xAttributeBtn->set_sensitive(false);
1546 m_xSimilarityBox->set_sensitive(false);
1547 m_xSimilarityBtn->set_sensitive(false);
1548 }
1549 else
1550 {
1551 // Disable templates controller
1552 rBindings.EnterRegistrations();
1553 pFamilyController.reset();
1554 rBindings.LeaveRegistrations();
1555
1556 m_xSearchLB->show();
1557 m_xReplaceLB->show();
1558 m_xSearchTmplLB->hide();
1559 m_xReplaceTmplLB->hide();
1560
1561 m_xSearchAttrText->set_label( BuildAttrText_Impl( sDesc, true ) );
1562 m_xReplaceAttrText->set_label( BuildAttrText_Impl( sDesc, false ) );
1563
1564 if(!sDesc.isEmpty())
1565 {
1566 if (!m_xReplaceAttrText->get_visible() || !m_xReplaceAttrText->get_visible())
1567 {
1568 m_xSearchAttrText->show();
1569 m_xReplaceAttrText->show();
1570 m_xDialog->resize_to_request();
1571 }
1572 }
1573
1574 EnableControl_Impl(*m_xFormatBtn);
1575 EnableControl_Impl(*m_xAttributeBtn);
1576 EnableControl_Impl(*m_xSimilarityBox);
1577
1578 FocusHdl_Impl( bSearch ? *m_xSearchLB : *m_xReplaceLB );
1579 }
1580 bSet = true;
1581 pImpl->bSaveToModule = false;
1582 FlagHdl_Impl(*m_xLayoutBtn);
1583 pImpl->bSaveToModule = true;
1584}
1585
1586void SvxSearchDialog::Remember_Impl( const OUString &rStr, bool _bSearch )
1587{
1588 if ( rStr.isEmpty() )
1589 return;
1590
1591 std::vector<OUString>* pArr = _bSearch ? &aSearchStrings : &aReplaceStrings;
1592 weld::ComboBox* pListBox = _bSearch ? m_xSearchLB.get() : m_xReplaceLB.get();
1593
1594 // ignore identical strings
1595 if (std::find(pArr->begin(), pArr->end(), rStr) != pArr->end())
1596 return;
1597
1598 pArr->insert(pArr->begin(), rStr);
1599 pListBox->insert_text(0, rStr);
1600
1601 // delete oldest entry at maximum occupancy (ListBox and Array)
1602 size_t nArrSize = pArr->size();
1603 if (nArrSize > nRememberSize)
1604 {
1605 pListBox->remove(nArrSize - 1);
1606 pArr->erase(pArr->begin() + nArrSize - 1);
1607 }
1608}
1609
1611{
1612 OUString aOldSrch( m_xSearchTmplLB->get_active_text() );
1613 OUString aOldRepl( m_xReplaceTmplLB->get_active_text() );
1614 m_xSearchTmplLB->clear();
1615 m_xReplaceTmplLB->clear();
1616 m_xSearchTmplLB->freeze();
1617 m_xReplaceTmplLB->freeze();
1618 SfxStyleSheetBase* pBase = rPool.First(pSearchItem->GetFamily());
1619
1620 while ( pBase )
1621 {
1622 if ( pBase->IsUsed() )
1623 m_xSearchTmplLB->append_text( pBase->GetName() );
1624 m_xReplaceTmplLB->append_text( pBase->GetName() );
1625 pBase = rPool.Next();
1626 }
1627 m_xSearchTmplLB->thaw();
1628 m_xReplaceTmplLB->thaw();
1629 m_xSearchTmplLB->set_active(0);
1630
1631 if ( !aOldSrch.isEmpty() )
1632 m_xSearchTmplLB->set_active_text( aOldSrch );
1633 m_xReplaceTmplLB->set_active(0);
1634
1635 if ( !aOldRepl.isEmpty() )
1636 m_xReplaceTmplLB->set_active_text( aOldRepl );
1637
1638 if ( m_xSearchTmplLB->get_count() )
1639 {
1645 }
1646}
1647
1648
1650{
1651 if ( nFlags == nOptions )
1652 return;
1653 else
1654 nOptions = nFlags;
1655
1656 bool bNoSearch = true;
1657
1658 bool bEnableSearch = bool( SearchOptionFlags::SEARCH & nOptions );
1659 m_xSearchBtn->set_sensitive(bEnableSearch);
1660 m_xBackSearchBtn->set_sensitive(bEnableSearch);
1661
1662 if( bEnableSearch )
1663 bNoSearch = false;
1664
1665
1666 if ( SearchOptionFlags::SEARCHALL & nOptions )
1667 {
1668 m_xSearchAllBtn->set_sensitive(true);
1669 bNoSearch = false;
1670 }
1671 else
1672 m_xSearchAllBtn->set_sensitive(false);
1673 if ( SearchOptionFlags::REPLACE & nOptions )
1674 {
1675 m_xReplaceBtn->set_sensitive(true);
1676 m_xReplaceFrame->set_sensitive(true);
1677 m_xReplaceLB->set_sensitive(true);
1678 m_xReplaceTmplLB->set_sensitive(true);
1679 bNoSearch = false;
1680 }
1681 else
1682 {
1683 m_xReplaceBtn->set_sensitive(false);
1684 m_xReplaceFrame->set_sensitive(false);
1685 m_xReplaceLB->set_sensitive(false);
1686 m_xReplaceTmplLB->set_sensitive(false);
1687 }
1688 if ( SearchOptionFlags::REPLACE_ALL & nOptions )
1689 {
1690 m_xReplaceAllBtn->set_sensitive(true);
1691 bNoSearch = false;
1692 }
1693 else
1694 m_xReplaceAllBtn->set_sensitive(false);
1695 m_xComponentFrame->set_sensitive(!bNoSearch);
1696 m_xSearchBtn->set_sensitive( !bNoSearch );
1697 m_xBackSearchBtn->set_sensitive( !bNoSearch );
1698 m_xSearchFrame->set_sensitive( !bNoSearch );
1699 m_xSearchLB->set_sensitive( !bNoSearch );
1700 m_xNotesBtn->set_sensitive(true);
1701
1702 if ( SearchOptionFlags::WHOLE_WORDS & nOptions )
1703 m_xWordBtn->set_sensitive(true);
1704 else
1705 m_xWordBtn->set_sensitive(false);
1706 if ( SearchOptionFlags::BACKWARDS & nOptions )
1707 {
1708 m_xBackSearchBtn->set_sensitive(true);
1709 m_xReplaceBackwardsCB->set_sensitive(true);
1710 }
1711 else
1712 {
1713 m_xBackSearchBtn->set_sensitive(false);
1714 m_xReplaceBackwardsCB->set_sensitive(false);
1715 }
1716 if ( SearchOptionFlags::REG_EXP & nOptions )
1717 m_xRegExpBtn->set_sensitive(true);
1718 else
1719 m_xRegExpBtn->set_sensitive(false);
1720 if ( SearchOptionFlags::WILDCARD & nOptions )
1721 m_xWildcardBtn->set_sensitive(true);
1722 else
1723 m_xWildcardBtn->set_sensitive(false);
1724 if ( SearchOptionFlags::EXACT & nOptions )
1725 m_xMatchCaseCB->set_sensitive(true);
1726 else
1727 m_xMatchCaseCB->set_sensitive(false);
1728 if ( SearchOptionFlags::SELECTION & nOptions )
1729 m_xSelectionBtn->set_sensitive(true);
1730 else
1731 m_xSelectionBtn->set_sensitive(false);
1732 if ( SearchOptionFlags::FAMILIES & nOptions )
1733 m_xLayoutBtn->set_sensitive(true);
1734 else
1735 m_xLayoutBtn->set_sensitive(false);
1736 if ( SearchOptionFlags::FORMAT & nOptions )
1737 {
1738 m_xAttributeBtn->set_sensitive(true);
1739 m_xFormatBtn->set_sensitive(true);
1740 m_xNoFormatBtn->set_sensitive(true);
1741 }
1742 else
1743 {
1744 m_xAttributeBtn->set_sensitive(false);
1745 m_xFormatBtn->set_sensitive(false);
1746 m_xNoFormatBtn->set_sensitive(false);
1747 }
1748
1749 if ( SearchOptionFlags::SIMILARITY & nOptions )
1750 {
1751 m_xSimilarityBox->set_sensitive(true);
1752 m_xSimilarityBtn->set_sensitive(true);
1753 }
1754 else
1755 {
1756 m_xSimilarityBox->set_sensitive(false);
1757 m_xSimilarityBtn->set_sensitive(false);
1758 }
1759
1760 if ( pSearchItem )
1761 {
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
bool IsCTLFontEnabled() const
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:613
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:1586
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:774
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:1060
virtual void Close() override
Definition: srchdlg.cxx:519
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:573
std::unique_ptr< weld::Button > m_xCloseBtn
Definition: srchdlg.hxx:200
SVX_DLLPRIVATE void ClickHdl_Impl(const weld::Widget *pCtrl)
Definition: srchdlg.cxx:1132
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:705
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:625
virtual void ChildWinDispose() override
Definition: srchdlg.cxx:370
void SetSaveToModule(bool b)
Definition: srchdlg.cxx:568
std::unique_ptr< weld::CheckButton > m_xWildcardBtn
Definition: srchdlg.hxx:206
SVX_DLLPRIVATE bool IsOtherOptionsExpanded() const
Definition: srchdlg.cxx:598
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:555
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:588
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 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 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 StrArrToList_Impl(sal_uInt16 nId, const std::vector< OUString > &rStrLst)
Definition: srchdlg.cxx:171
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
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:1122
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)