/src/libreoffice/sc/source/ui/formdlg/dwfunctr.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 <basctl/basctldllpublic.hxx> |
21 | | #include <comphelper/string.hxx> |
22 | | #include <editeng/editview.hxx> |
23 | | #include <sfx2/dispatch.hxx> |
24 | | #include <sfx2/viewsh.hxx> |
25 | | #include <formula/funcvarargs.h> |
26 | | #include <unotools/charclass.hxx> |
27 | | #include <unotools/textsearch.hxx> |
28 | | #include <vcl/svapp.hxx> |
29 | | #include <vcl/help.hxx> |
30 | | |
31 | | #include <global.hxx> |
32 | | #include <scmod.hxx> |
33 | | #include <sc.hrc> |
34 | | #include <svl/stritem.hxx> |
35 | | #include <inputhdl.hxx> |
36 | | #include <tabvwsh.hxx> |
37 | | #include <funcdesc.hxx> |
38 | | #include <compiler.hxx> |
39 | | |
40 | | #include <dwfunctr.hxx> |
41 | | |
42 | | /************************************************************************* |
43 | | #* Member: ScFunctionWin |
44 | | #*------------------------------------------------------------------------ |
45 | | #* |
46 | | #* Class: ScFunctionWin |
47 | | #* |
48 | | #* Function: Constructor of ScFunctionWin Class |
49 | | #* |
50 | | #* Input: Sfx - links, window, resource |
51 | | #* |
52 | | #* Output: --- |
53 | | #* |
54 | | #************************************************************************/ |
55 | | |
56 | | ScFunctionWin::ScFunctionWin(weld::Widget* pParent, SfxBindings* pBindings) |
57 | 0 | : PanelLayout(pParent, u"FunctionPanel"_ustr, u"modules/scalc/ui/functionpanel.ui"_ustr) |
58 | 0 | , xCatBox(m_xBuilder->weld_combo_box(u"category"_ustr)) |
59 | 0 | , xFuncList(m_xBuilder->weld_tree_view(u"funclist"_ustr)) |
60 | 0 | , xScratchIter(xFuncList->make_iterator()) |
61 | 0 | , xInsertButton(m_xBuilder->weld_button(u"insert"_ustr)) |
62 | 0 | , xHelpButton(m_xBuilder->weld_button(u"help"_ustr)) |
63 | 0 | , xSimilaritySearch(m_xBuilder->weld_check_button(u"similaritysearch"_ustr)) |
64 | 0 | , xFiFuncDesc(m_xBuilder->weld_text_view(u"funcdesc"_ustr)) |
65 | 0 | , m_xSearchString(m_xBuilder->weld_entry(u"search"_ustr)) |
66 | 0 | , m_pBindings(pBindings) |
67 | 0 | , xConfigListener(new comphelper::ConfigurationListener(u"/org.openoffice.Office.Calc/Formula/Syntax"_ustr)) |
68 | 0 | , xConfigChange(std::make_unique<EnglishFunctionNameChange>(xConfigListener, this)) |
69 | 0 | , pFuncDesc(nullptr) |
70 | 0 | { |
71 | 0 | InitLRUList(); |
72 | 0 | UpdateFavouritesList(); |
73 | |
|
74 | 0 | m_aListHelpId = xFuncList->get_help_id(); |
75 | 0 | m_aSearchHelpId = m_xSearchString->get_help_id(); |
76 | | |
77 | | // Description box has a height of 8 lines of text |
78 | 0 | xFiFuncDesc->set_size_request(-1, 8 * xFiFuncDesc->get_text_height()); |
79 | |
|
80 | 0 | m_xSearchString->connect_changed(LINK(this, ScFunctionWin, ModifyHdl)); |
81 | 0 | m_xSearchString->connect_key_press(LINK(this, ScFunctionWin, KeyInputHdl)); |
82 | |
|
83 | 0 | xCatBox->connect_changed(LINK( this, ScFunctionWin, SelComboHdl)); |
84 | 0 | xFuncList->connect_selection_changed(LINK(this, ScFunctionWin, SelTreeHdl)); |
85 | |
|
86 | 0 | xFuncList->connect_row_activated(LINK( this, ScFunctionWin, SetRowActivatedHdl)); |
87 | 0 | xInsertButton->connect_clicked(LINK( this, ScFunctionWin, SetSelectionClickHdl)); |
88 | 0 | xHelpButton->connect_clicked(LINK( this, ScFunctionWin, SetHelpClickHdl)); |
89 | 0 | xSimilaritySearch->connect_toggled(LINK(this, ScFunctionWin, SetSimilarityToggleHdl)); |
90 | |
|
91 | 0 | xCatBox->set_active(0); |
92 | |
|
93 | 0 | SelComboHdl(*xCatBox); |
94 | 0 | } |
95 | | |
96 | | /************************************************************************* |
97 | | #* Member: ScFunctionWin |
98 | | #*------------------------------------------------------------------------ |
99 | | #* |
100 | | #* Class: ScFunctionWin |
101 | | #* |
102 | | #* Function: Destructor of ScFunctionWin Class |
103 | | #* |
104 | | #* Input: --- |
105 | | #* |
106 | | #* Output: --- |
107 | | #* |
108 | | #************************************************************************/ |
109 | | |
110 | | ScFunctionWin::~ScFunctionWin() |
111 | 0 | { |
112 | 0 | xConfigChange.reset(); |
113 | 0 | xConfigListener->dispose(); |
114 | 0 | xConfigListener.clear(); |
115 | |
|
116 | 0 | xCatBox.reset(); |
117 | 0 | xFuncList.reset(); |
118 | 0 | xInsertButton.reset(); |
119 | 0 | xHelpButton.reset(); |
120 | 0 | xSimilaritySearch.reset(); |
121 | 0 | xFiFuncDesc.reset(); |
122 | 0 | } |
123 | | |
124 | | /************************************************************************* |
125 | | #* Member: InitLRUList |
126 | | #*------------------------------------------------------------------------ |
127 | | #* |
128 | | #* Class: ScFunctionWin |
129 | | #* |
130 | | #* Function: Updates the list of functions depending on the set category |
131 | | #* |
132 | | #* Input: --- |
133 | | #* |
134 | | #* Output: --- |
135 | | #* |
136 | | #************************************************************************/ |
137 | | |
138 | | void ScFunctionWin::InitLRUList() |
139 | 0 | { |
140 | 0 | ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr(); |
141 | 0 | pFuncMgr->fillLastRecentlyUsedFunctions(aLRUList); |
142 | |
|
143 | 0 | sal_Int32 nSelPos = xCatBox->get_active(); |
144 | |
|
145 | 0 | if (nSelPos == 0) |
146 | 0 | UpdateFunctionList(u""_ustr); |
147 | 0 | } |
148 | | |
149 | | void ScFunctionWin::UpdateFavouritesList() |
150 | 0 | { |
151 | 0 | ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr(); |
152 | 0 | pFuncMgr->fillFavouriteFunctions(aFavouritesList); |
153 | |
|
154 | 0 | if (xCatBox->get_active() == 0) |
155 | 0 | UpdateFunctionList(u""_ustr); |
156 | 0 | } |
157 | | |
158 | | /************************************************************************* |
159 | | #* Member: FillCategoriesMap |
160 | | #*------------------------------------------------------------------------ |
161 | | #* |
162 | | #* Class: ScFunctionWin |
163 | | #* |
164 | | #* Function: Fills the categories map. |
165 | | #* |
166 | | #* Input: --- |
167 | | #* |
168 | | #* Output: --- |
169 | | #* |
170 | | #************************************************************************/ |
171 | | |
172 | | weld::TreeIter* ScFunctionWin::FillCategoriesMap(const OUString& aCategory, bool bFill) |
173 | 0 | { |
174 | 0 | if (!bFill) |
175 | 0 | return nullptr; |
176 | | |
177 | 0 | if (mCategories.find(aCategory) == mCategories.end()) |
178 | 0 | { |
179 | 0 | mCategories[aCategory] = xFuncList->make_iterator(); |
180 | 0 | xFuncList->insert(nullptr, -1, &aCategory, nullptr, nullptr, nullptr, false, |
181 | 0 | mCategories[aCategory].get()); |
182 | 0 | } |
183 | 0 | return mCategories[aCategory].get(); |
184 | 0 | } |
185 | | |
186 | | /************************************************************************* |
187 | | #* Member: UpdateLRUList |
188 | | #*------------------------------------------------------------------------ |
189 | | #* |
190 | | #* Class: ScFunctionWin |
191 | | #* |
192 | | #* Function: Updates the list of last used functions. |
193 | | #* |
194 | | #* Input: --- |
195 | | #* |
196 | | #* Output: --- |
197 | | #* |
198 | | #************************************************************************/ |
199 | | |
200 | | void ScFunctionWin::UpdateLRUList() |
201 | 0 | { |
202 | 0 | if (pFuncDesc && pFuncDesc->nFIndex!=0) |
203 | 0 | { |
204 | 0 | ScModule::get()->InsertEntryToLRUList(pFuncDesc->nFIndex); |
205 | 0 | } |
206 | 0 | } |
207 | | |
208 | | void ScFunctionWin::SearchFunction(const OUString& rFuncName, const OUString& rSearchString, |
209 | | const ScFuncDesc* pDesc, const bool bSimilaritySearch) |
210 | 0 | { |
211 | 0 | std::pair<sal_Int32, sal_Int32> score = std::make_pair(0, 0); |
212 | 0 | if (bSimilaritySearch && !utl::TextSearch::SimilaritySearch(rFuncName, rSearchString, score)) |
213 | 0 | return; |
214 | 0 | if (!bSimilaritySearch && rFuncName.indexOf(rSearchString) < 0 |
215 | 0 | && rSearchString.indexOf(rFuncName) < 0) |
216 | 0 | return; |
217 | | |
218 | 0 | sFuncScores.insert(std::make_pair(score, std::make_pair(rFuncName, pDesc))); |
219 | 0 | } |
220 | | |
221 | | /************************************************************************* |
222 | | #* Member: SetDescription |
223 | | #*------------------------------------------------------------------------ |
224 | | #* |
225 | | #* Class: ScFunctionWin |
226 | | #* |
227 | | #* Function: |
228 | | #* |
229 | | #* Input: --- |
230 | | #* |
231 | | #* Output: --- |
232 | | #* |
233 | | #************************************************************************/ |
234 | | |
235 | | void ScFunctionWin::SetDescription() |
236 | 0 | { |
237 | 0 | xFiFuncDesc->set_text(OUString()); |
238 | 0 | const ScFuncDesc* pDesc = |
239 | 0 | weld::fromId<const ScFuncDesc*>(xFuncList->get_selected_id()); |
240 | 0 | if (pDesc) |
241 | 0 | { |
242 | 0 | pDesc->initArgumentInfo(); // full argument info is needed |
243 | |
|
244 | 0 | OUString aBuf = xFuncList->get_selected_text() + |
245 | 0 | ":\n\n" + |
246 | 0 | pDesc->GetParamList() + |
247 | 0 | "\n\n" + |
248 | 0 | *pDesc->mxFuncDesc; |
249 | |
|
250 | 0 | xFiFuncDesc->set_text(aBuf); |
251 | | |
252 | | // Update help ID for the selected entry |
253 | 0 | const OUString sHelpId = pDesc->getHelpId(); |
254 | 0 | if (!sHelpId.isEmpty()) |
255 | 0 | xFuncList->set_help_id(pDesc->getHelpId()); |
256 | 0 | else |
257 | 0 | xFuncList->set_help_id(m_aListHelpId); |
258 | 0 | } |
259 | 0 | } |
260 | | |
261 | | /************************************************************************* |
262 | | #* Member: UpdateFunctionList |
263 | | #*------------------------------------------------------------------------ |
264 | | #* |
265 | | #* Class: ScFunctionWin |
266 | | #* |
267 | | #* Function: Updates the list of functions depending on the set category |
268 | | #* |
269 | | #* Input: Search string used to filter the list of functions |
270 | | #* |
271 | | #* Output: --- |
272 | | #* |
273 | | #************************************************************************/ |
274 | | |
275 | | void ScFunctionWin::UpdateFunctionList(const OUString& rSearchString) |
276 | 0 | { |
277 | 0 | sal_Int32 nSelPos = xCatBox->get_active(); |
278 | 0 | sal_Int32 nCategory = ( -1 != nSelPos ) |
279 | 0 | ? (nSelPos-ALL_CATEGORY) : 0; |
280 | |
|
281 | 0 | xFuncList->clear(); |
282 | 0 | xFuncList->freeze(); |
283 | 0 | mCategories.clear(); |
284 | 0 | sFuncScores.clear(); |
285 | |
|
286 | 0 | bool bCollapse = nSelPos == ALL_CATEGORY; |
287 | 0 | bool bFilter = !rSearchString.isEmpty(); |
288 | 0 | if (nSelPos >= ALL_CATEGORY) |
289 | 0 | { |
290 | 0 | ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr(); |
291 | | |
292 | | // Use the corresponding CharClass for uppercase() depending on whether |
293 | | // English function names are used, or localized names. |
294 | 0 | const CharClass* pCharClass = (ScGlobal::GetStarCalcFunctionList()->IsEnglishFunctionNames() |
295 | 0 | ? ScCompiler::GetCharClassEnglish() |
296 | 0 | : ScCompiler::GetCharClassLocalized()); |
297 | |
|
298 | 0 | const OUString aSearchStr(pCharClass->uppercase(rSearchString)); |
299 | |
|
300 | 0 | const ScFuncDesc* pDesc = pFuncMgr->First(nCategory); |
301 | 0 | while (pDesc) |
302 | 0 | { |
303 | 0 | const OUString aCategory(pDesc->getCategory()->getName()); |
304 | 0 | const OUString aFunction(pCharClass->uppercase(pDesc->getFunctionName())); |
305 | 0 | const OUString aFuncDescId(weld::toId(pDesc)); |
306 | |
|
307 | 0 | if (bFilter) |
308 | 0 | SearchFunction(aFunction, aSearchStr, pDesc, xSimilaritySearch->get_active()); |
309 | 0 | else |
310 | 0 | { |
311 | 0 | weld::TreeIter* pCategory = FillCategoriesMap(aCategory, bCollapse); |
312 | 0 | xFuncList->insert(pCategory, -1, &aFunction, &aFuncDescId, nullptr, nullptr, |
313 | 0 | false, xScratchIter.get()); |
314 | 0 | } |
315 | 0 | pDesc = pFuncMgr->Next(); |
316 | 0 | } |
317 | |
|
318 | 0 | for (const auto& func : sFuncScores) |
319 | 0 | { |
320 | 0 | pDesc = func.second.second; |
321 | 0 | const OUString aCategory(pDesc->getCategory()->getName()); |
322 | 0 | const OUString aFunction(func.second.first); |
323 | 0 | const OUString aFuncDescId(weld::toId(pDesc)); |
324 | 0 | weld::TreeIter* pCategory = FillCategoriesMap(aCategory, bCollapse); |
325 | |
|
326 | 0 | xFuncList->insert(pCategory, -1, &aFunction, &aFuncDescId, nullptr, nullptr, false, |
327 | 0 | xScratchIter.get()); |
328 | 0 | } |
329 | 0 | } |
330 | 0 | else if (nSelPos == LRU_CATEGORY) // LRU list |
331 | 0 | { |
332 | 0 | for (const formula::IFunctionDescription* pDesc : aLRUList) |
333 | 0 | { |
334 | 0 | if (pDesc) |
335 | 0 | { |
336 | 0 | OUString aFunction = pDesc->getFunctionName(); |
337 | 0 | OUString aFuncDescId = weld::toId(pDesc); |
338 | |
|
339 | 0 | xFuncList->insert(nullptr, -1, &aFunction, &aFuncDescId, nullptr, nullptr, |
340 | 0 | false, xScratchIter.get()); |
341 | 0 | } |
342 | 0 | } |
343 | 0 | } |
344 | 0 | else // Favourites List |
345 | 0 | { |
346 | 0 | ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr(); |
347 | 0 | for (const auto& elem : aFavouritesList) |
348 | 0 | { |
349 | 0 | const formula::IFunctionDescription* pDesc(pFuncMgr->Get(elem)); |
350 | 0 | if (pDesc) |
351 | 0 | { |
352 | 0 | OUString aFunction(pDesc->getFunctionName()); |
353 | 0 | OUString aFuncDescId(weld::toId(pDesc)); |
354 | |
|
355 | 0 | xFuncList->insert(nullptr, -1, &aFunction, &aFuncDescId, nullptr, nullptr, false, |
356 | 0 | xScratchIter.get()); |
357 | 0 | } |
358 | 0 | } |
359 | 0 | } |
360 | |
|
361 | 0 | xFuncList->thaw(); |
362 | |
|
363 | 0 | if (bCollapse && bFilter) |
364 | 0 | { |
365 | 0 | for (const auto& category : mCategories) |
366 | 0 | xFuncList->expand_row(*category.second); |
367 | 0 | } |
368 | |
|
369 | 0 | if (xFuncList->n_children() > 0) |
370 | 0 | { |
371 | 0 | xFuncList->set_sensitive(true); |
372 | 0 | xFuncList->select(0); |
373 | 0 | } |
374 | 0 | else |
375 | 0 | { |
376 | 0 | xFuncList->set_sensitive(false); |
377 | 0 | } |
378 | 0 | } |
379 | | |
380 | | /************************************************************************* |
381 | | #* Member: DoEnter |
382 | | #*------------------------------------------------------------------------ |
383 | | #* |
384 | | #* Class: ScFunctionWin |
385 | | #* |
386 | | #* Function: Save input into document. Is called after clicking the |
387 | | #* Apply button or a double-click on the function list. |
388 | | #* |
389 | | #* Input: Boolean to know if I double-clicked/press-enter or not |
390 | | #* |
391 | | #* Output: --- |
392 | | #* |
393 | | #************************************************************************/ |
394 | | |
395 | | void ScFunctionWin::DoEnter(bool bDoubleOrEnter) |
396 | 0 | { |
397 | 0 | OUString aString=xFuncList->get_selected_text(); |
398 | 0 | const bool isCategory = mCategories.find(aString) != mCategories.end(); |
399 | 0 | if (isCategory && !bDoubleOrEnter) |
400 | 0 | return; |
401 | | |
402 | 0 | if (isCategory) |
403 | 0 | { |
404 | 0 | const auto& categoryRow = *(mCategories[aString]); |
405 | 0 | if (xFuncList->get_row_expanded(categoryRow)) |
406 | 0 | xFuncList->collapse_row(categoryRow); |
407 | 0 | else |
408 | 0 | xFuncList->expand_row(categoryRow); |
409 | 0 | return; |
410 | 0 | } |
411 | | |
412 | 0 | SfxViewShell* pCurSh = SfxViewShell::Current(); |
413 | |
|
414 | 0 | if(!aString.isEmpty()) |
415 | 0 | { |
416 | 0 | const ScFuncDesc* pDesc = |
417 | 0 | weld::fromId<const ScFuncDesc*>(xFuncList->get_selected_id()); |
418 | 0 | if (pDesc) |
419 | 0 | { |
420 | 0 | pFuncDesc=pDesc; |
421 | 0 | UpdateLRUList(); |
422 | 0 | } |
423 | 0 | InitLRUList(); |
424 | 0 | } |
425 | |
|
426 | 0 | const SfxStringItem aFunction(FN_PARAM_1, aString); |
427 | | // -1 when function-id is available, category index otherwise |
428 | 0 | const SfxInt16Item nCategory(FN_PARAM_2, -1); |
429 | 0 | const SfxStringItem aFunctionId(FN_PARAM_3, xFuncList->get_selected_id()); |
430 | 0 | GetBindings().GetDispatcher()->ExecuteList(SID_INS_FUNCTION, SfxCallMode::SYNCHRON, |
431 | 0 | { &aFunction, &nCategory, &aFunctionId }); |
432 | |
|
433 | 0 | if ( pCurSh ) |
434 | 0 | { |
435 | 0 | vcl::Window* pShellWnd = pCurSh->GetWindow(); |
436 | |
|
437 | 0 | if ( pShellWnd ) |
438 | 0 | pShellWnd->GrabFocus(); |
439 | 0 | } |
440 | |
|
441 | 0 | } |
442 | | |
443 | | /************************************************************************* |
444 | | #* Handle: ModifyHdl |
445 | | #*------------------------------------------------------------------------ |
446 | | #* |
447 | | #* Class: ScFunctionWin |
448 | | #* |
449 | | #* Function: Handles changes in the search text |
450 | | #* |
451 | | #************************************************************************/ |
452 | | |
453 | | IMPL_LINK_NOARG(ScFunctionWin, ModifyHdl, weld::Entry&, void) |
454 | 0 | { |
455 | 0 | if (xCatBox->get_active() == LRU_CATEGORY || xCatBox->get_active() == FAVOURITES_CATEGORY) |
456 | 0 | { |
457 | 0 | xCatBox->set_active(ALL_CATEGORY); |
458 | 0 | xHelpButton->set_sensitive(false); |
459 | 0 | } |
460 | 0 | OUString searchStr = m_xSearchString->get_text(); |
461 | 0 | UpdateFunctionList(searchStr); |
462 | 0 | SetDescription(); |
463 | 0 | } |
464 | | |
465 | | /************************************************************************* |
466 | | #* Handle: KeyInputHdl |
467 | | #*------------------------------------------------------------------------ |
468 | | #* |
469 | | #* Class: ScFunctionWin |
470 | | #* |
471 | | #* Function: Processes key inputs when the search entry has focus |
472 | | #* |
473 | | #************************************************************************/ |
474 | | |
475 | | IMPL_LINK(ScFunctionWin, KeyInputHdl, const KeyEvent&, rEvent, bool) |
476 | 0 | { |
477 | 0 | bool bHandled = false; |
478 | |
|
479 | 0 | switch (rEvent.GetKeyCode().GetCode()) |
480 | 0 | { |
481 | 0 | case KEY_RETURN: |
482 | 0 | { |
483 | 0 | DoEnter(true); |
484 | 0 | bHandled = true; |
485 | 0 | } |
486 | 0 | break; |
487 | 0 | case KEY_DOWN: |
488 | 0 | { |
489 | 0 | int nNewIndex = std::min(xFuncList->get_selected_index() + 1, xFuncList->n_children() - 1); |
490 | 0 | xFuncList->select(nNewIndex); |
491 | 0 | SetDescription(); |
492 | 0 | bHandled = true; |
493 | 0 | } |
494 | 0 | break; |
495 | 0 | case KEY_UP: |
496 | 0 | { |
497 | 0 | int nNewIndex = std::max(xFuncList->get_selected_index() - 1, 0); |
498 | 0 | xFuncList->select(nNewIndex); |
499 | 0 | SetDescription(); |
500 | 0 | bHandled = true; |
501 | 0 | } |
502 | 0 | break; |
503 | 0 | case KEY_ESCAPE: |
504 | 0 | { |
505 | | // Escape in an empty search field should move focus to the document, |
506 | | // adhering to Sidebar guidelines |
507 | 0 | if (m_xSearchString->get_text().isEmpty()) |
508 | 0 | { |
509 | 0 | if (SfxViewShell* pCurSh = SfxViewShell::Current()) |
510 | 0 | { |
511 | 0 | vcl::Window* pShellWnd = pCurSh->GetWindow(); |
512 | |
|
513 | 0 | if (pShellWnd) |
514 | 0 | pShellWnd->GrabFocusToDocument(); |
515 | 0 | } |
516 | 0 | bHandled = true; |
517 | 0 | break; |
518 | 0 | } |
519 | 0 | m_xSearchString->set_text(u""_ustr); |
520 | 0 | UpdateFunctionList(u""_ustr); |
521 | 0 | bHandled = true; |
522 | 0 | } |
523 | 0 | break; |
524 | 0 | case KEY_F1: |
525 | 0 | { |
526 | 0 | const ScFuncDesc* pDesc = weld::fromId<const ScFuncDesc*>(xFuncList->get_selected_id()); |
527 | 0 | OUString sHelpId; |
528 | 0 | if (pDesc) |
529 | 0 | sHelpId = pDesc->getHelpId(); |
530 | |
|
531 | 0 | if (!sHelpId.isEmpty()) |
532 | 0 | m_xSearchString->set_help_id(sHelpId); |
533 | 0 | else |
534 | 0 | m_xSearchString->set_help_id(m_aSearchHelpId); |
535 | 0 | bHandled = false; |
536 | 0 | } |
537 | 0 | break; |
538 | 0 | } |
539 | | |
540 | 0 | return bHandled; |
541 | 0 | } |
542 | | |
543 | | /************************************************************************* |
544 | | #* Handle: SelComboHdl |
545 | | #*------------------------------------------------------------------------ |
546 | | #* |
547 | | #* Class: ScFunctionWin |
548 | | #* |
549 | | #* Function: A change of the category will update the list of functions. |
550 | | #* |
551 | | #* Input: --- |
552 | | #* |
553 | | #* Output: --- |
554 | | #* |
555 | | #************************************************************************/ |
556 | | |
557 | | IMPL_LINK_NOARG(ScFunctionWin, SelComboHdl, weld::ComboBox&, void) |
558 | 0 | { |
559 | 0 | if (xCatBox->get_active() == LRU_CATEGORY || xCatBox->get_active() == FAVOURITES_CATEGORY) |
560 | 0 | m_xSearchString->set_text(u""_ustr); |
561 | 0 | xHelpButton->set_sensitive(xCatBox->get_active() != ALL_CATEGORY); |
562 | 0 | OUString searchStr = m_xSearchString->get_text(); |
563 | 0 | UpdateFavouritesList(); |
564 | 0 | UpdateFunctionList(searchStr); |
565 | 0 | SetDescription(); |
566 | 0 | } |
567 | | |
568 | | IMPL_LINK_NOARG(ScFunctionWin, SelTreeHdl, weld::TreeView&, void) |
569 | 0 | { |
570 | 0 | bool bSensitivity = weld::fromId<const ScFuncDesc*>(xFuncList->get_selected_id()); |
571 | 0 | xHelpButton->set_sensitive(bSensitivity); |
572 | 0 | SetDescription(); |
573 | 0 | } |
574 | | |
575 | | /************************************************************************* |
576 | | #* Handle: SetSelectionClickHdl |
577 | | #*------------------------------------------------------------------------ |
578 | | #* |
579 | | #* Class: ScFunctionWin |
580 | | #* |
581 | | #* Function: A change of the category will update the list of functions. |
582 | | #* |
583 | | #* Input: --- |
584 | | #* |
585 | | #* Output: --- |
586 | | #* |
587 | | #************************************************************************/ |
588 | | |
589 | | IMPL_LINK_NOARG( ScFunctionWin, SetSelectionClickHdl, weld::Button&, void ) |
590 | 0 | { |
591 | 0 | DoEnter(); // saves the input |
592 | 0 | } |
593 | | |
594 | | /************************************************************************* |
595 | | #* Handle: SetHelpClickHdl |
596 | | #*------------------------------------------------------------------------ |
597 | | #* |
598 | | #* Class: ScFunctionWin |
599 | | #* |
600 | | #* Function: Get selected function's official help. |
601 | | #* |
602 | | #* Input: --- |
603 | | #* |
604 | | #* Output: --- |
605 | | #* |
606 | | #************************************************************************/ |
607 | | |
608 | | IMPL_LINK_NOARG( ScFunctionWin, SetHelpClickHdl, weld::Button&, void ) |
609 | 0 | { |
610 | 0 | if (const auto pDesc = weld::fromId<const ScFuncDesc*>(xFuncList->get_selected_id())) |
611 | 0 | { |
612 | 0 | if (Help* pHelp = Application::GetHelp()) |
613 | 0 | { |
614 | 0 | const OUString sHelpId = pDesc->getHelpId(); |
615 | 0 | if (!sHelpId.isEmpty()) |
616 | 0 | { |
617 | 0 | pHelp->Start(sHelpId); |
618 | 0 | } |
619 | 0 | } |
620 | 0 | } |
621 | 0 | } |
622 | | |
623 | | IMPL_LINK_NOARG(ScFunctionWin, SetSimilarityToggleHdl, weld::Toggleable&, void) |
624 | 0 | { |
625 | 0 | OUString searchStr = m_xSearchString->get_text(); |
626 | 0 | UpdateFunctionList(searchStr); |
627 | 0 | SetDescription(); |
628 | 0 | } |
629 | | |
630 | | IMPL_LINK_NOARG( ScFunctionWin, SetRowActivatedHdl, weld::TreeView&, bool ) |
631 | 0 | { |
632 | 0 | DoEnter(true); // saves the input |
633 | 0 | return true; |
634 | 0 | } |
635 | | |
636 | | void EnglishFunctionNameChange::setProperty(const css::uno::Any &rProperty) |
637 | 0 | { |
638 | 0 | ConfigurationListenerProperty::setProperty(rProperty); |
639 | 0 | m_pFunctionWin->InitLRUList(); |
640 | 0 | m_pFunctionWin->UpdateFunctionList(u""_ustr); |
641 | 0 | } |
642 | | |
643 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |