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