1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
23 #include <cfgutil.hxx>
24 #include <dialmgr.hxx>
26 #include <sfx2/filedlghelper.hxx>
27 #include <sfx2/minfitem.hxx>
28 #include <sfx2/sfxresid.hxx>
30 #include <sal/macros.h>
31 #include <vcl/event.hxx>
33 #include <strings.hrc>
34 #include <sfx2/strings.hrc>
35 #include <svx/svxids.hrc>
37 // include interface declarations
38 #include <com/sun/star/beans/XPropertySet.hpp>
39 #include <com/sun/star/embed/StorageFactory.hpp>
40 #include <com/sun/star/embed/XTransactedObject.hpp>
41 #include <com/sun/star/embed/ElementModes.hpp>
42 #include <com/sun/star/form/XReset.hpp>
43 #include <com/sun/star/frame/Desktop.hpp>
44 #include <com/sun/star/frame/XController.hpp>
45 #include <com/sun/star/frame/XModel.hpp>
46 #include <com/sun/star/frame/ModuleManager.hpp>
47 #include <com/sun/star/frame/theUICommandDescription.hpp>
48 #include <com/sun/star/ui/GlobalAcceleratorConfiguration.hpp>
49 #include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
50 #include <com/sun/star/ui/UIConfigurationManager.hpp>
51 #include <com/sun/star/ui/XUIConfigurationManager.hpp>
52 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
54 // include search util
55 #include <com/sun/star/util/SearchFlags.hpp>
56 #include <com/sun/star/util/SearchAlgorithms2.hpp>
57 #include <unotools/textsearch.hxx>
59 // include other projects
60 #include <comphelper/processfactory.hxx>
61 #include <svtools/acceleratorexecute.hxx>
62 #include <vcl/svapp.hxx>
63 #include <comphelper/sequenceashashmap.hxx>
64 #include <config_features.h>
66 #include <com/sun/star/frame/LayoutManager.hpp>
72 constexpr OUString FOLDERNAME_UICONFIG
= u
"Configurations2"_ustr
;
74 constexpr OUString MEDIATYPE_PROPNAME
= u
"MediaType"_ustr
;
76 const sal_uInt16 KEYCODE_ARRAY
[] = { KEY_F1
,
137 KEY_SHIFT
| KEY_DOWN
,
139 KEY_SHIFT
| KEY_LEFT
,
140 KEY_SHIFT
| KEY_RIGHT
,
141 KEY_SHIFT
| KEY_HOME
,
143 KEY_SHIFT
| KEY_PAGEUP
,
144 KEY_SHIFT
| KEY_PAGEDOWN
,
145 KEY_SHIFT
| KEY_RETURN
,
146 KEY_SHIFT
| KEY_SPACE
,
147 KEY_SHIFT
| KEY_ESCAPE
,
148 KEY_SHIFT
| KEY_BACKSPACE
,
149 KEY_SHIFT
| KEY_INSERT
,
150 KEY_SHIFT
| KEY_DELETE
,
151 KEY_SHIFT
| KEY_EQUAL
,
189 KEY_MOD1
| KEY_NUMBERSIGN
,
190 KEY_MOD1
| KEY_COLON
,
191 KEY_MOD1
| KEY_SEMICOLON
,
192 KEY_MOD1
| KEY_QUOTELEFT
,
193 KEY_MOD1
| KEY_QUOTERIGHT
,
194 KEY_MOD1
| KEY_BRACKETLEFT
,
195 KEY_MOD1
| KEY_BRACKETRIGHT
,
196 KEY_MOD1
| KEY_RIGHTCURLYBRACKET
,
197 KEY_MOD1
| KEY_POINT
,
198 KEY_MOD1
| KEY_COMMA
,
199 KEY_MOD1
| KEY_TILDE
,
222 KEY_MOD1
| KEY_RIGHT
,
225 KEY_MOD1
| KEY_PAGEUP
,
226 KEY_MOD1
| KEY_PAGEDOWN
,
227 KEY_MOD1
| KEY_RETURN
,
228 KEY_MOD1
| KEY_SPACE
,
229 KEY_MOD1
| KEY_BACKSPACE
,
230 KEY_MOD1
| KEY_INSERT
,
231 KEY_MOD1
| KEY_DELETE
,
234 KEY_MOD1
| KEY_SUBTRACT
,
235 KEY_MOD1
| KEY_MULTIPLY
,
236 KEY_MOD1
| KEY_DIVIDE
,
237 KEY_MOD1
| KEY_EQUAL
,
239 KEY_SHIFT
| KEY_MOD1
| KEY_0
,
240 KEY_SHIFT
| KEY_MOD1
| KEY_1
,
241 KEY_SHIFT
| KEY_MOD1
| KEY_2
,
242 KEY_SHIFT
| KEY_MOD1
| KEY_3
,
243 KEY_SHIFT
| KEY_MOD1
| KEY_4
,
244 KEY_SHIFT
| KEY_MOD1
| KEY_5
,
245 KEY_SHIFT
| KEY_MOD1
| KEY_6
,
246 KEY_SHIFT
| KEY_MOD1
| KEY_7
,
247 KEY_SHIFT
| KEY_MOD1
| KEY_8
,
248 KEY_SHIFT
| KEY_MOD1
| KEY_9
,
249 KEY_SHIFT
| KEY_MOD1
| KEY_A
,
250 KEY_SHIFT
| KEY_MOD1
| KEY_B
,
251 KEY_SHIFT
| KEY_MOD1
| KEY_C
,
252 KEY_SHIFT
| KEY_MOD1
| KEY_D
,
253 KEY_SHIFT
| KEY_MOD1
| KEY_E
,
254 KEY_SHIFT
| KEY_MOD1
| KEY_F
,
255 KEY_SHIFT
| KEY_MOD1
| KEY_G
,
256 KEY_SHIFT
| KEY_MOD1
| KEY_H
,
257 KEY_SHIFT
| KEY_MOD1
| KEY_I
,
258 KEY_SHIFT
| KEY_MOD1
| KEY_J
,
259 KEY_SHIFT
| KEY_MOD1
| KEY_K
,
260 KEY_SHIFT
| KEY_MOD1
| KEY_L
,
261 KEY_SHIFT
| KEY_MOD1
| KEY_M
,
262 KEY_SHIFT
| KEY_MOD1
| KEY_N
,
263 KEY_SHIFT
| KEY_MOD1
| KEY_O
,
264 KEY_SHIFT
| KEY_MOD1
| KEY_P
,
265 KEY_SHIFT
| KEY_MOD1
| KEY_Q
,
266 KEY_SHIFT
| KEY_MOD1
| KEY_R
,
267 KEY_SHIFT
| KEY_MOD1
| KEY_S
,
268 KEY_SHIFT
| KEY_MOD1
| KEY_T
,
269 KEY_SHIFT
| KEY_MOD1
| KEY_U
,
270 KEY_SHIFT
| KEY_MOD1
| KEY_V
,
271 KEY_SHIFT
| KEY_MOD1
| KEY_W
,
272 KEY_SHIFT
| KEY_MOD1
| KEY_X
,
273 KEY_SHIFT
| KEY_MOD1
| KEY_Y
,
274 KEY_SHIFT
| KEY_MOD1
| KEY_Z
,
275 KEY_SHIFT
| KEY_MOD1
| KEY_NUMBERSIGN
,
276 KEY_SHIFT
| KEY_MOD1
| KEY_COLON
,
277 KEY_SHIFT
| KEY_MOD1
| KEY_SEMICOLON
,
278 KEY_SHIFT
| KEY_MOD1
| KEY_QUOTELEFT
,
279 KEY_SHIFT
| KEY_MOD1
| KEY_QUOTERIGHT
,
280 KEY_SHIFT
| KEY_MOD1
| KEY_BRACKETLEFT
,
281 KEY_SHIFT
| KEY_MOD1
| KEY_BRACKETRIGHT
,
282 KEY_SHIFT
| KEY_MOD1
| KEY_RIGHTCURLYBRACKET
,
283 KEY_SHIFT
| KEY_MOD1
| KEY_POINT
,
284 KEY_SHIFT
| KEY_MOD1
| KEY_COMMA
,
285 KEY_SHIFT
| KEY_MOD1
| KEY_TILDE
,
286 KEY_SHIFT
| KEY_MOD1
| KEY_TAB
,
288 KEY_SHIFT
| KEY_MOD1
| KEY_F1
,
289 KEY_SHIFT
| KEY_MOD1
| KEY_F2
,
290 KEY_SHIFT
| KEY_MOD1
| KEY_F3
,
291 KEY_SHIFT
| KEY_MOD1
| KEY_F4
,
292 KEY_SHIFT
| KEY_MOD1
| KEY_F5
,
293 KEY_SHIFT
| KEY_MOD1
| KEY_F6
,
294 KEY_SHIFT
| KEY_MOD1
| KEY_F7
,
295 KEY_SHIFT
| KEY_MOD1
| KEY_F8
,
296 KEY_SHIFT
| KEY_MOD1
| KEY_F9
,
297 KEY_SHIFT
| KEY_MOD1
| KEY_F10
,
298 KEY_SHIFT
| KEY_MOD1
| KEY_F11
,
299 KEY_SHIFT
| KEY_MOD1
| KEY_F12
,
300 KEY_SHIFT
| KEY_MOD1
| KEY_F13
,
301 KEY_SHIFT
| KEY_MOD1
| KEY_F14
,
302 KEY_SHIFT
| KEY_MOD1
| KEY_F15
,
303 KEY_SHIFT
| KEY_MOD1
| KEY_F16
,
305 KEY_SHIFT
| KEY_MOD1
| KEY_DOWN
,
306 KEY_SHIFT
| KEY_MOD1
| KEY_UP
,
307 KEY_SHIFT
| KEY_MOD1
| KEY_LEFT
,
308 KEY_SHIFT
| KEY_MOD1
| KEY_RIGHT
,
309 KEY_SHIFT
| KEY_MOD1
| KEY_HOME
,
310 KEY_SHIFT
| KEY_MOD1
| KEY_END
,
311 KEY_SHIFT
| KEY_MOD1
| KEY_PAGEUP
,
312 KEY_SHIFT
| KEY_MOD1
| KEY_PAGEDOWN
,
313 KEY_SHIFT
| KEY_MOD1
| KEY_RETURN
,
314 KEY_SHIFT
| KEY_MOD1
| KEY_ESCAPE
,
315 KEY_SHIFT
| KEY_MOD1
| KEY_SPACE
,
316 KEY_SHIFT
| KEY_MOD1
| KEY_BACKSPACE
,
317 KEY_SHIFT
| KEY_MOD1
| KEY_INSERT
,
318 KEY_SHIFT
| KEY_MOD1
| KEY_DELETE
,
319 KEY_SHIFT
| KEY_MOD1
| KEY_EQUAL
,
357 KEY_MOD2
| KEY_NUMBERSIGN
,
358 KEY_MOD2
| KEY_COLON
,
359 KEY_MOD2
| KEY_SEMICOLON
,
360 KEY_MOD2
| KEY_QUOTELEFT
,
361 KEY_MOD2
| KEY_QUOTERIGHT
,
362 KEY_MOD2
| KEY_BRACKETLEFT
,
363 KEY_MOD2
| KEY_BRACKETRIGHT
,
364 KEY_MOD2
| KEY_RIGHTCURLYBRACKET
,
365 KEY_MOD2
| KEY_POINT
,
366 KEY_MOD2
| KEY_COMMA
,
367 KEY_MOD2
| KEY_TILDE
,
389 KEY_MOD2
| KEY_RIGHT
,
392 KEY_MOD2
| KEY_PAGEUP
,
393 KEY_MOD2
| KEY_PAGEDOWN
,
394 KEY_MOD2
| KEY_RETURN
,
395 KEY_MOD2
| KEY_SPACE
,
396 KEY_MOD2
| KEY_BACKSPACE
,
397 KEY_MOD2
| KEY_INSERT
,
398 KEY_MOD2
| KEY_DELETE
,
399 KEY_MOD2
| KEY_EQUAL
,
401 KEY_SHIFT
| KEY_MOD2
| KEY_0
,
402 KEY_SHIFT
| KEY_MOD2
| KEY_1
,
403 KEY_SHIFT
| KEY_MOD2
| KEY_2
,
404 KEY_SHIFT
| KEY_MOD2
| KEY_3
,
405 KEY_SHIFT
| KEY_MOD2
| KEY_4
,
406 KEY_SHIFT
| KEY_MOD2
| KEY_5
,
407 KEY_SHIFT
| KEY_MOD2
| KEY_6
,
408 KEY_SHIFT
| KEY_MOD2
| KEY_7
,
409 KEY_SHIFT
| KEY_MOD2
| KEY_8
,
410 KEY_SHIFT
| KEY_MOD2
| KEY_9
,
411 KEY_SHIFT
| KEY_MOD2
| KEY_A
,
412 KEY_SHIFT
| KEY_MOD2
| KEY_B
,
413 KEY_SHIFT
| KEY_MOD2
| KEY_C
,
414 KEY_SHIFT
| KEY_MOD2
| KEY_D
,
415 KEY_SHIFT
| KEY_MOD2
| KEY_E
,
416 KEY_SHIFT
| KEY_MOD2
| KEY_F
,
417 KEY_SHIFT
| KEY_MOD2
| KEY_G
,
418 KEY_SHIFT
| KEY_MOD2
| KEY_H
,
419 KEY_SHIFT
| KEY_MOD2
| KEY_I
,
420 KEY_SHIFT
| KEY_MOD2
| KEY_J
,
421 KEY_SHIFT
| KEY_MOD2
| KEY_K
,
422 KEY_SHIFT
| KEY_MOD2
| KEY_L
,
423 KEY_SHIFT
| KEY_MOD2
| KEY_M
,
424 KEY_SHIFT
| KEY_MOD2
| KEY_N
,
425 KEY_SHIFT
| KEY_MOD2
| KEY_O
,
426 KEY_SHIFT
| KEY_MOD2
| KEY_P
,
427 KEY_SHIFT
| KEY_MOD2
| KEY_Q
,
428 KEY_SHIFT
| KEY_MOD2
| KEY_R
,
429 KEY_SHIFT
| KEY_MOD2
| KEY_S
,
430 KEY_SHIFT
| KEY_MOD2
| KEY_T
,
431 KEY_SHIFT
| KEY_MOD2
| KEY_U
,
432 KEY_SHIFT
| KEY_MOD2
| KEY_V
,
433 KEY_SHIFT
| KEY_MOD2
| KEY_W
,
434 KEY_SHIFT
| KEY_MOD2
| KEY_X
,
435 KEY_SHIFT
| KEY_MOD2
| KEY_Y
,
436 KEY_SHIFT
| KEY_MOD2
| KEY_Z
,
437 KEY_SHIFT
| KEY_MOD2
| KEY_NUMBERSIGN
,
438 KEY_SHIFT
| KEY_MOD2
| KEY_COLON
,
439 KEY_SHIFT
| KEY_MOD2
| KEY_SEMICOLON
,
440 KEY_SHIFT
| KEY_MOD2
| KEY_QUOTELEFT
,
441 KEY_SHIFT
| KEY_MOD2
| KEY_QUOTERIGHT
,
442 KEY_SHIFT
| KEY_MOD2
| KEY_BRACKETLEFT
,
443 KEY_SHIFT
| KEY_MOD2
| KEY_BRACKETRIGHT
,
444 KEY_SHIFT
| KEY_MOD2
| KEY_RIGHTCURLYBRACKET
,
445 KEY_SHIFT
| KEY_MOD2
| KEY_POINT
,
446 KEY_SHIFT
| KEY_MOD2
| KEY_COMMA
,
447 KEY_SHIFT
| KEY_MOD2
| KEY_TILDE
,
449 KEY_SHIFT
| KEY_MOD2
| KEY_F1
,
450 KEY_SHIFT
| KEY_MOD2
| KEY_F2
,
451 KEY_SHIFT
| KEY_MOD2
| KEY_F3
,
452 KEY_SHIFT
| KEY_MOD2
| KEY_F4
,
453 KEY_SHIFT
| KEY_MOD2
| KEY_F5
,
454 KEY_SHIFT
| KEY_MOD2
| KEY_F6
,
455 KEY_SHIFT
| KEY_MOD2
| KEY_F7
,
456 KEY_SHIFT
| KEY_MOD2
| KEY_F8
,
457 KEY_SHIFT
| KEY_MOD2
| KEY_F9
,
458 KEY_SHIFT
| KEY_MOD2
| KEY_F10
,
459 KEY_SHIFT
| KEY_MOD2
| KEY_F11
,
460 KEY_SHIFT
| KEY_MOD2
| KEY_F12
,
461 KEY_SHIFT
| KEY_MOD2
| KEY_F13
,
462 KEY_SHIFT
| KEY_MOD2
| KEY_F14
,
463 KEY_SHIFT
| KEY_MOD2
| KEY_F15
,
464 KEY_SHIFT
| KEY_MOD2
| KEY_F16
,
466 KEY_SHIFT
| KEY_MOD2
| KEY_DOWN
,
467 KEY_SHIFT
| KEY_MOD2
| KEY_UP
,
468 KEY_SHIFT
| KEY_MOD2
| KEY_LEFT
,
469 KEY_SHIFT
| KEY_MOD2
| KEY_RIGHT
,
470 KEY_SHIFT
| KEY_MOD2
| KEY_HOME
,
471 KEY_SHIFT
| KEY_MOD2
| KEY_END
,
472 KEY_SHIFT
| KEY_MOD2
| KEY_PAGEUP
,
473 KEY_SHIFT
| KEY_MOD2
| KEY_PAGEDOWN
,
474 KEY_SHIFT
| KEY_MOD2
| KEY_RETURN
,
475 KEY_SHIFT
| KEY_MOD2
| KEY_ESCAPE
,
476 KEY_SHIFT
| KEY_MOD2
| KEY_SPACE
,
477 KEY_SHIFT
| KEY_MOD2
| KEY_BACKSPACE
,
478 KEY_SHIFT
| KEY_MOD2
| KEY_INSERT
,
479 KEY_SHIFT
| KEY_MOD2
| KEY_DELETE
,
480 KEY_SHIFT
| KEY_MOD2
| KEY_EQUAL
,
482 KEY_MOD1
| KEY_MOD2
| KEY_0
,
483 KEY_MOD1
| KEY_MOD2
| KEY_1
,
484 KEY_MOD1
| KEY_MOD2
| KEY_2
,
485 KEY_MOD1
| KEY_MOD2
| KEY_3
,
486 KEY_MOD1
| KEY_MOD2
| KEY_4
,
487 KEY_MOD1
| KEY_MOD2
| KEY_5
,
488 KEY_MOD1
| KEY_MOD2
| KEY_6
,
489 KEY_MOD1
| KEY_MOD2
| KEY_7
,
490 KEY_MOD1
| KEY_MOD2
| KEY_8
,
491 KEY_MOD1
| KEY_MOD2
| KEY_9
,
492 KEY_MOD1
| KEY_MOD2
| KEY_A
,
493 KEY_MOD1
| KEY_MOD2
| KEY_B
,
494 KEY_MOD1
| KEY_MOD2
| KEY_C
,
495 KEY_MOD1
| KEY_MOD2
| KEY_D
,
496 KEY_MOD1
| KEY_MOD2
| KEY_E
,
497 KEY_MOD1
| KEY_MOD2
| KEY_F
,
498 KEY_MOD1
| KEY_MOD2
| KEY_G
,
499 KEY_MOD1
| KEY_MOD2
| KEY_H
,
500 KEY_MOD1
| KEY_MOD2
| KEY_I
,
501 KEY_MOD1
| KEY_MOD2
| KEY_J
,
502 KEY_MOD1
| KEY_MOD2
| KEY_K
,
503 KEY_MOD1
| KEY_MOD2
| KEY_L
,
504 KEY_MOD1
| KEY_MOD2
| KEY_M
,
505 KEY_MOD1
| KEY_MOD2
| KEY_N
,
506 KEY_MOD1
| KEY_MOD2
| KEY_O
,
507 KEY_MOD1
| KEY_MOD2
| KEY_P
,
508 KEY_MOD1
| KEY_MOD2
| KEY_Q
,
509 KEY_MOD1
| KEY_MOD2
| KEY_R
,
510 KEY_MOD1
| KEY_MOD2
| KEY_S
,
511 KEY_MOD1
| KEY_MOD2
| KEY_T
,
512 KEY_MOD1
| KEY_MOD2
| KEY_U
,
513 KEY_MOD1
| KEY_MOD2
| KEY_V
,
514 KEY_MOD1
| KEY_MOD2
| KEY_W
,
515 KEY_MOD1
| KEY_MOD2
| KEY_X
,
516 KEY_MOD1
| KEY_MOD2
| KEY_Y
,
517 KEY_MOD1
| KEY_MOD2
| KEY_Z
,
518 KEY_MOD1
| KEY_MOD2
| KEY_NUMBERSIGN
,
519 KEY_MOD1
| KEY_MOD2
| KEY_COLON
,
520 KEY_MOD1
| KEY_MOD2
| KEY_SEMICOLON
,
521 KEY_MOD1
| KEY_MOD2
| KEY_QUOTELEFT
,
522 KEY_MOD1
| KEY_MOD2
| KEY_QUOTERIGHT
,
523 KEY_MOD1
| KEY_MOD2
| KEY_BRACKETLEFT
,
524 KEY_MOD1
| KEY_MOD2
| KEY_BRACKETRIGHT
,
525 KEY_MOD1
| KEY_MOD2
| KEY_RIGHTCURLYBRACKET
,
526 KEY_MOD1
| KEY_MOD2
| KEY_POINT
,
527 KEY_MOD1
| KEY_MOD2
| KEY_COMMA
,
528 KEY_MOD1
| KEY_MOD2
| KEY_TILDE
,
529 KEY_MOD1
| KEY_MOD2
| KEY_EQUAL
,
531 KEY_MOD1
| KEY_MOD2
| KEY_F1
,
532 KEY_MOD1
| KEY_MOD2
| KEY_F2
,
533 KEY_MOD1
| KEY_MOD2
| KEY_F3
,
534 KEY_MOD1
| KEY_MOD2
| KEY_F4
,
535 KEY_MOD1
| KEY_MOD2
| KEY_F5
,
536 KEY_MOD1
| KEY_MOD2
| KEY_F6
,
537 KEY_MOD1
| KEY_MOD2
| KEY_F7
,
538 KEY_MOD1
| KEY_MOD2
| KEY_F8
,
539 KEY_MOD1
| KEY_MOD2
| KEY_F9
,
540 KEY_MOD1
| KEY_MOD2
| KEY_F10
,
541 KEY_MOD1
| KEY_MOD2
| KEY_F11
,
542 KEY_MOD1
| KEY_MOD2
| KEY_F12
,
543 KEY_MOD1
| KEY_MOD2
| KEY_F13
,
544 KEY_MOD1
| KEY_MOD2
| KEY_F14
,
545 KEY_MOD1
| KEY_MOD2
| KEY_F15
,
546 KEY_MOD1
| KEY_MOD2
| KEY_F16
,
548 KEY_MOD1
| KEY_MOD2
| KEY_DOWN
,
549 KEY_MOD1
| KEY_MOD2
| KEY_UP
,
550 KEY_MOD1
| KEY_MOD2
| KEY_LEFT
,
551 KEY_MOD1
| KEY_MOD2
| KEY_RIGHT
,
552 KEY_MOD1
| KEY_MOD2
| KEY_HOME
,
553 KEY_MOD1
| KEY_MOD2
| KEY_END
,
554 KEY_MOD1
| KEY_MOD2
| KEY_PAGEUP
,
555 KEY_MOD1
| KEY_MOD2
| KEY_PAGEDOWN
,
556 KEY_MOD1
| KEY_MOD2
| KEY_RETURN
,
557 KEY_MOD1
| KEY_MOD2
| KEY_SPACE
,
558 KEY_MOD1
| KEY_MOD2
| KEY_BACKSPACE
,
559 KEY_MOD1
| KEY_MOD2
| KEY_INSERT
,
560 KEY_MOD1
| KEY_MOD2
| KEY_DELETE
,
562 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_0
,
563 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_1
,
564 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_2
,
565 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_3
,
566 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_4
,
567 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_5
,
568 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_6
,
569 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_7
,
570 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_8
,
571 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_9
,
572 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_A
,
573 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_B
,
574 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_C
,
575 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_D
,
576 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_E
,
577 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F
,
578 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_G
,
579 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_H
,
580 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_I
,
581 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_J
,
582 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_K
,
583 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_L
,
584 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_M
,
585 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_N
,
586 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_O
,
587 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_P
,
588 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_Q
,
589 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_R
,
590 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_S
,
591 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_T
,
592 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_U
,
593 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_V
,
594 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_W
,
595 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_X
,
596 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_Y
,
597 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_Z
,
598 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_NUMBERSIGN
,
599 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_COLON
,
600 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_SEMICOLON
,
601 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_QUOTELEFT
,
602 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_QUOTERIGHT
,
603 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_BRACKETLEFT
,
604 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_BRACKETRIGHT
,
605 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_RIGHTCURLYBRACKET
,
606 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_POINT
,
607 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_COMMA
,
608 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_TILDE
,
610 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F1
,
611 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F2
,
612 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F3
,
613 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F4
,
614 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F5
,
615 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F6
,
616 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F7
,
617 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F8
,
618 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F9
,
619 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F10
,
620 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F11
,
621 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F12
,
622 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F13
,
623 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F14
,
624 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F15
,
625 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F16
,
627 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_DOWN
,
628 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_UP
,
629 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_LEFT
,
630 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_RIGHT
,
631 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_HOME
,
632 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_END
,
633 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_PAGEUP
,
634 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_PAGEDOWN
,
635 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_RETURN
,
636 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_SPACE
,
637 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_BACKSPACE
,
638 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_INSERT
,
639 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_DELETE
,
640 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_EQUAL
680 KEY_MOD2
| KEY_NUMBERSIGN
,
681 KEY_MOD3
| KEY_COLON
,
682 KEY_MOD3
| KEY_SEMICOLON
,
683 KEY_MOD3
| KEY_QUOTELEFT
,
684 KEY_MOD3
| KEY_QUOTERIGHT
,
685 KEY_MOD3
| KEY_BRACKETLEFT
,
686 KEY_MOD3
| KEY_BRACKETRIGHT
,
687 KEY_MOD3
| KEY_RIGHTCURLYBRACKET
,
688 KEY_MOD3
| KEY_POINT
,
689 KEY_MOD3
| KEY_COMMA
,
690 KEY_MOD3
| KEY_TILDE
,
713 KEY_MOD3
| KEY_RIGHT
,
716 KEY_MOD3
| KEY_PAGEUP
,
717 KEY_MOD3
| KEY_PAGEDOWN
,
718 KEY_MOD3
| KEY_RETURN
,
719 KEY_MOD3
| KEY_SPACE
,
720 KEY_MOD3
| KEY_BACKSPACE
,
721 KEY_MOD3
| KEY_INSERT
,
722 KEY_MOD3
| KEY_DELETE
,
725 KEY_MOD3
| KEY_SUBTRACT
,
726 KEY_MOD3
| KEY_MULTIPLY
,
727 KEY_MOD3
| KEY_DIVIDE
,
728 KEY_MOD3
| KEY_EQUAL
,
730 KEY_SHIFT
| KEY_MOD3
| KEY_0
,
731 KEY_SHIFT
| KEY_MOD3
| KEY_1
,
732 KEY_SHIFT
| KEY_MOD3
| KEY_2
,
733 KEY_SHIFT
| KEY_MOD3
| KEY_3
,
734 KEY_SHIFT
| KEY_MOD3
| KEY_4
,
735 KEY_SHIFT
| KEY_MOD3
| KEY_5
,
736 KEY_SHIFT
| KEY_MOD3
| KEY_6
,
737 KEY_SHIFT
| KEY_MOD3
| KEY_7
,
738 KEY_SHIFT
| KEY_MOD3
| KEY_8
,
739 KEY_SHIFT
| KEY_MOD3
| KEY_9
,
740 KEY_SHIFT
| KEY_MOD3
| KEY_A
,
741 KEY_SHIFT
| KEY_MOD3
| KEY_B
,
742 KEY_SHIFT
| KEY_MOD3
| KEY_C
,
743 KEY_SHIFT
| KEY_MOD3
| KEY_D
,
744 KEY_SHIFT
| KEY_MOD3
| KEY_E
,
745 KEY_SHIFT
| KEY_MOD3
| KEY_F
,
746 KEY_SHIFT
| KEY_MOD3
| KEY_G
,
747 KEY_SHIFT
| KEY_MOD3
| KEY_H
,
748 KEY_SHIFT
| KEY_MOD3
| KEY_I
,
749 KEY_SHIFT
| KEY_MOD3
| KEY_J
,
750 KEY_SHIFT
| KEY_MOD3
| KEY_K
,
751 KEY_SHIFT
| KEY_MOD3
| KEY_L
,
752 KEY_SHIFT
| KEY_MOD3
| KEY_M
,
753 KEY_SHIFT
| KEY_MOD3
| KEY_N
,
754 KEY_SHIFT
| KEY_MOD3
| KEY_O
,
755 KEY_SHIFT
| KEY_MOD3
| KEY_P
,
756 KEY_SHIFT
| KEY_MOD3
| KEY_Q
,
757 KEY_SHIFT
| KEY_MOD3
| KEY_R
,
758 KEY_SHIFT
| KEY_MOD3
| KEY_S
,
759 KEY_SHIFT
| KEY_MOD3
| KEY_T
,
760 KEY_SHIFT
| KEY_MOD3
| KEY_U
,
761 KEY_SHIFT
| KEY_MOD3
| KEY_V
,
762 KEY_SHIFT
| KEY_MOD3
| KEY_W
,
763 KEY_SHIFT
| KEY_MOD3
| KEY_X
,
764 KEY_SHIFT
| KEY_MOD3
| KEY_Y
,
765 KEY_SHIFT
| KEY_MOD3
| KEY_Z
,
766 KEY_SHIFT
| KEY_MOD3
| KEY_NUMBERSIGN
,
767 KEY_SHIFT
| KEY_MOD3
| KEY_COLON
,
768 KEY_SHIFT
| KEY_MOD3
| KEY_SEMICOLON
,
769 KEY_SHIFT
| KEY_MOD3
| KEY_QUOTELEFT
,
770 KEY_SHIFT
| KEY_MOD3
| KEY_QUOTERIGHT
,
771 KEY_SHIFT
| KEY_MOD3
| KEY_BRACKETLEFT
,
772 KEY_SHIFT
| KEY_MOD3
| KEY_BRACKETRIGHT
,
773 KEY_SHIFT
| KEY_MOD3
| KEY_RIGHTCURLYBRACKET
,
774 KEY_SHIFT
| KEY_MOD3
| KEY_POINT
,
775 KEY_SHIFT
| KEY_MOD3
| KEY_COMMA
,
776 KEY_SHIFT
| KEY_MOD3
| KEY_TILDE
,
777 KEY_SHIFT
| KEY_MOD3
| KEY_TAB
,
779 KEY_SHIFT
| KEY_MOD3
| KEY_F1
,
780 KEY_SHIFT
| KEY_MOD3
| KEY_F2
,
781 KEY_SHIFT
| KEY_MOD3
| KEY_F3
,
782 KEY_SHIFT
| KEY_MOD3
| KEY_F4
,
783 KEY_SHIFT
| KEY_MOD3
| KEY_F5
,
784 KEY_SHIFT
| KEY_MOD3
| KEY_F6
,
785 KEY_SHIFT
| KEY_MOD3
| KEY_F7
,
786 KEY_SHIFT
| KEY_MOD3
| KEY_F8
,
787 KEY_SHIFT
| KEY_MOD3
| KEY_F9
,
788 KEY_SHIFT
| KEY_MOD3
| KEY_F10
,
789 KEY_SHIFT
| KEY_MOD3
| KEY_F11
,
790 KEY_SHIFT
| KEY_MOD3
| KEY_F12
,
791 KEY_SHIFT
| KEY_MOD3
| KEY_F13
,
792 KEY_SHIFT
| KEY_MOD3
| KEY_F14
,
793 KEY_SHIFT
| KEY_MOD3
| KEY_F15
,
794 KEY_SHIFT
| KEY_MOD3
| KEY_F16
,
796 KEY_SHIFT
| KEY_MOD3
| KEY_DOWN
,
797 KEY_SHIFT
| KEY_MOD3
| KEY_UP
,
798 KEY_SHIFT
| KEY_MOD3
| KEY_LEFT
,
799 KEY_SHIFT
| KEY_MOD3
| KEY_RIGHT
,
800 KEY_SHIFT
| KEY_MOD3
| KEY_HOME
,
801 KEY_SHIFT
| KEY_MOD3
| KEY_END
,
802 KEY_SHIFT
| KEY_MOD3
| KEY_PAGEUP
,
803 KEY_SHIFT
| KEY_MOD3
| KEY_PAGEDOWN
,
804 KEY_SHIFT
| KEY_MOD3
| KEY_RETURN
,
805 KEY_SHIFT
| KEY_MOD3
| KEY_ESCAPE
,
806 KEY_SHIFT
| KEY_MOD3
| KEY_SPACE
,
807 KEY_SHIFT
| KEY_MOD3
| KEY_BACKSPACE
,
808 KEY_SHIFT
| KEY_MOD3
| KEY_INSERT
,
809 KEY_SHIFT
| KEY_MOD3
| KEY_DELETE
,
810 KEY_SHIFT
| KEY_MOD3
| KEY_EQUAL
814 const sal_uInt16 KEYCODE_ARRAY_SIZE
= std::size(KEYCODE_ARRAY
);
816 /** select the entry, which match the current key input ... excepting
817 keys, which are used for the dialog itself.
819 IMPL_LINK(SfxAcceleratorConfigPage
, KeyInputHdl
, const KeyEvent
&, rKey
, bool)
821 vcl::KeyCode aCode1
= rKey
.GetKeyCode();
822 sal_uInt16 nCode1
= aCode1
.GetCode();
823 sal_uInt16 nMod1
= aCode1
.GetModifier();
825 // is it related to our list box ?
826 if ((nCode1
== KEY_DOWN
) || (nCode1
== KEY_UP
) || (nCode1
== KEY_LEFT
) || (nCode1
== KEY_RIGHT
)
827 || (nCode1
== KEY_PAGEUP
) || (nCode1
== KEY_PAGEDOWN
))
828 // no - handle it as normal dialog input
831 for (int i
= 0, nCount
= m_xEntriesBox
->n_children(); i
< nCount
; ++i
)
833 TAccInfo
* pUserData
= weld::fromId
<TAccInfo
*>(m_xEntriesBox
->get_id(i
));
836 sal_uInt16 nCode2
= pUserData
->m_aKey
.GetCode();
837 sal_uInt16 nMod2
= pUserData
->m_aKey
.GetModifier();
839 if (nCode1
== nCode2
&& nMod1
== nMod2
)
841 m_xEntriesBox
->select(i
);
842 m_xEntriesBox
->scroll_to_row(i
);
848 // no - handle it as normal dialog input
852 SfxAcceleratorConfigPage::SfxAcceleratorConfigPage(weld::Container
* pPage
,
853 weld::DialogController
* pController
,
854 const SfxItemSet
& aSet
)
855 : SfxTabPage(pPage
, pController
, u
"cui/ui/accelconfigpage.ui"_ustr
, u
"AccelConfigPage"_ustr
,
857 #if HAVE_FEATURE_SCRIPTING
860 , aLoadAccelConfigStr(CuiResId(RID_CUISTR_LOADACCELCONFIG
))
861 , aSaveAccelConfigStr(CuiResId(RID_CUISTR_SAVEACCELCONFIG
))
862 , aFilterAllStr(SfxResId(STR_SFX_FILTERNAME_ALL
))
863 , aFilterCfgStr(CuiResId(RID_CUISTR_FILTERNAME_CFG
))
864 , m_bStylesInfoInitialized(false)
865 , m_aUpdateDataTimer("SfxAcceleratorConfigPage UpdateDataTimer")
866 , m_xEntriesBox(m_xBuilder
->weld_tree_view(u
"shortcuts"_ustr
))
867 , m_xOfficeButton(m_xBuilder
->weld_radio_button(u
"office"_ustr
))
868 , m_xModuleButton(m_xBuilder
->weld_radio_button(u
"module"_ustr
))
869 , m_xChangeButton(m_xBuilder
->weld_button(u
"change"_ustr
))
870 , m_xRemoveButton(m_xBuilder
->weld_button(u
"delete"_ustr
))
871 , m_xGroupLBox(new CuiConfigGroupListBox(m_xBuilder
->weld_tree_view(u
"category"_ustr
)))
872 , m_xFunctionBox(new CuiConfigFunctionListBox(m_xBuilder
->weld_tree_view(u
"function"_ustr
)))
873 , m_xKeyBox(m_xBuilder
->weld_tree_view(u
"keys"_ustr
))
874 , m_xSearchEdit(m_xBuilder
->weld_entry(u
"searchEntry"_ustr
))
875 , m_xLoadButton(m_xBuilder
->weld_button(u
"load"_ustr
))
876 , m_xSaveButton(m_xBuilder
->weld_button(u
"save"_ustr
))
877 , m_xResetButton(m_xBuilder
->weld_button(u
"reset"_ustr
))
879 Size
aSize(m_xEntriesBox
->get_approximate_digit_width() * 40,
880 m_xEntriesBox
->get_height_rows(10));
881 m_xEntriesBox
->set_size_request(aSize
.Width(), aSize
.Height());
882 aSize
= Size(m_xEntriesBox
->get_approximate_digit_width() * 19,
883 m_xEntriesBox
->get_height_rows(9));
884 m_xGroupLBox
->set_size_request(aSize
.Width(), aSize
.Height());
885 aSize
= Size(m_xEntriesBox
->get_approximate_digit_width() * 21,
886 m_xEntriesBox
->get_height_rows(9));
887 m_xFunctionBox
->set_size_request(aSize
.Width(), aSize
.Height());
888 aSize
= Size(m_xEntriesBox
->get_approximate_digit_width() * 20,
889 m_xEntriesBox
->get_height_rows(9));
890 m_xKeyBox
->set_size_request(aSize
.Width(), aSize
.Height());
892 // install handler functions
893 m_xChangeButton
->connect_clicked(LINK(this, SfxAcceleratorConfigPage
, ChangeHdl
));
894 m_xRemoveButton
->connect_clicked(LINK(this, SfxAcceleratorConfigPage
, RemoveHdl
));
895 m_xEntriesBox
->connect_selection_changed(LINK(this, SfxAcceleratorConfigPage
, SelectHdl
));
896 m_xEntriesBox
->connect_key_press(LINK(this, SfxAcceleratorConfigPage
, KeyInputHdl
));
897 m_xGroupLBox
->connect_changed(LINK(this, SfxAcceleratorConfigPage
, SelectHdl
));
898 m_xFunctionBox
->connect_changed(LINK(this, SfxAcceleratorConfigPage
, SelectHdl
));
899 m_xKeyBox
->connect_selection_changed(LINK(this, SfxAcceleratorConfigPage
, SelectHdl
));
900 m_xLoadButton
->connect_clicked(LINK(this, SfxAcceleratorConfigPage
, Load
));
901 m_xSaveButton
->connect_clicked(LINK(this, SfxAcceleratorConfigPage
, Save
));
902 m_xResetButton
->connect_clicked(LINK(this, SfxAcceleratorConfigPage
, Default
));
903 m_xOfficeButton
->connect_toggled(LINK(this, SfxAcceleratorConfigPage
, RadioHdl
));
904 m_xSearchEdit
->connect_changed(LINK(this, SfxAcceleratorConfigPage
, SearchUpdateHdl
));
905 m_xSearchEdit
->connect_focus_out(LINK(this, SfxAcceleratorConfigPage
, FocusOut_Impl
));
907 // detect max keyname width
909 for (unsigned short i
: KEYCODE_ARRAY
)
911 int nTmp
= m_xEntriesBox
->get_pixel_size(vcl::KeyCode(i
).GetName()).Width();
912 if (nTmp
> nMaxWidth
)
916 auto nNewTab
= nMaxWidth
+ 5; // additional space
918 // initialize Entriesbox
919 std::vector
<int> aWidths
{ nNewTab
};
920 m_xEntriesBox
->set_column_fixed_widths(aWidths
);
922 //Initialize search util
923 m_options
.AlgorithmType2
= util::SearchAlgorithms2::ABSOLUTE
;
924 m_options
.transliterateFlags
|= TransliterationFlags::IGNORE_CASE
;
926 |= (util::SearchFlags::REG_NOT_BEGINOFLINE
| util::SearchFlags::REG_NOT_ENDOFLINE
);
927 // initialize GroupBox
928 m_xGroupLBox
->SetFunctionListBox(m_xFunctionBox
.get());
931 m_xKeyBox
->make_sorted();
933 m_aUpdateDataTimer
.SetInvokeHandler(LINK(this, SfxAcceleratorConfigPage
, ImplUpdateDataHdl
));
934 m_aUpdateDataTimer
.SetTimeout(EDIT_UPDATEDATA_TIMEOUT
);
937 SfxAcceleratorConfigPage::~SfxAcceleratorConfigPage()
939 // free memory - remove all dynamic user data
940 for (int i
= 0, nCount
= m_xEntriesBox
->n_children(); i
< nCount
; ++i
)
942 TAccInfo
* pUserData
= weld::fromId
<TAccInfo
*>(m_xEntriesBox
->get_id(i
));
947 void SfxAcceleratorConfigPage::InitAccCfg()
949 // already initialized ?
951 return; // yes -> do nothing
955 // no - initialize this instance
956 m_xContext
= comphelper::getProcessComponentContext();
958 m_xUICmdDescription
= frame::theUICommandDescription::get(m_xContext
);
960 // get the current active frame, which should be our "parent"
962 m_xFrame
= GetFrame();
965 uno::Reference
<frame::XDesktop2
> xDesktop
= frame::Desktop::create(m_xContext
);
966 m_xFrame
= xDesktop
->getActiveFrame();
970 uno::Reference
<frame::XModuleManager2
> xModuleManager
971 = frame::ModuleManager::create(m_xContext
);
972 m_sModuleLongName
= xModuleManager
->identify(m_xFrame
);
973 comphelper::SequenceAsHashMap
lModuleProps(xModuleManager
->getByName(m_sModuleLongName
));
975 = lModuleProps
.getUnpackedValueOrDefault(u
"ooSetupFactoryUIName"_ustr
, OUString());
977 // get global accelerator configuration
978 m_xGlobal
= css::ui::GlobalAcceleratorConfiguration::create(m_xContext
);
980 // get module accelerator configuration
982 uno::Reference
<ui::XModuleUIConfigurationManagerSupplier
> xModuleCfgSupplier(
983 ui::theModuleUIConfigurationManagerSupplier::get(m_xContext
));
984 uno::Reference
<ui::XUIConfigurationManager
> xUICfgManager
985 = xModuleCfgSupplier
->getUIConfigurationManager(m_sModuleLongName
);
986 m_xModule
= xUICfgManager
->getShortCutManager();
988 catch (const uno::RuntimeException
&)
992 catch (const uno::Exception
&)
998 void SfxAcceleratorConfigPage::Init(const uno::Reference
<ui::XAcceleratorConfiguration
>& xAccMgr
)
1003 if (!m_bStylesInfoInitialized
)
1005 uno::Reference
<frame::XController
> xController
;
1006 uno::Reference
<frame::XModel
> xModel
;
1008 xController
= m_xFrame
->getController();
1009 if (xController
.is())
1010 xModel
= xController
->getModel();
1012 m_aStylesInfo
.init(m_sModuleLongName
, xModel
);
1013 m_xGroupLBox
->SetStylesInfo(&m_aStylesInfo
);
1014 m_bStylesInfoInitialized
= true;
1017 // Insert all editable accelerators into list box. It is possible
1018 // that some accelerators are not mapped on the current system/keyboard
1019 // but we don't want to lose these mappings.
1020 for (sal_Int32 i1
= 0; i1
< KEYCODE_ARRAY_SIZE
; ++i1
)
1022 vcl::KeyCode aKey
= KEYCODE_ARRAY
[i1
];
1023 OUString sKey
= aKey
.GetName();
1026 TAccInfo
* pEntry
= new TAccInfo(i1
, 0 /*nListPos*/, aKey
);
1027 m_xEntriesBox
->append(weld::toId(pEntry
), sKey
);
1028 int nPos
= m_xEntriesBox
->n_children() - 1;
1029 m_xEntriesBox
->set_text(nPos
, OUString(), 1);
1030 m_xEntriesBox
->set_sensitive(nPos
, true);
1033 // Assign all commands to its shortcuts - reading the accelerator config.
1034 uno::Sequence
<awt::KeyEvent
> lKeys
= xAccMgr
->getAllKeyEvents();
1035 sal_Int32 c2
= lKeys
.getLength();
1038 for (i2
= 0; i2
< c2
; ++i2
)
1040 const awt::KeyEvent
& aAWTKey
= lKeys
[i2
];
1041 OUString sCommand
= xAccMgr
->getCommandByKeyEvent(aAWTKey
);
1042 OUString sLabel
= GetLabel4Command(sCommand
);
1043 vcl::KeyCode aKeyCode
= svt::AcceleratorExecute::st_AWTKey2VCLKey(aAWTKey
);
1044 sal_Int32 nPos
= MapKeyCodeToPos(aKeyCode
);
1049 m_xEntriesBox
->set_text(nPos
, sLabel
, 1);
1051 TAccInfo
* pEntry
= weld::fromId
<TAccInfo
*>(m_xEntriesBox
->get_id(nPos
));
1052 pEntry
->m_bIsConfigurable
= true;
1054 pEntry
->m_sCommand
= sCommand
;
1057 // Map the VCL hardcoded key codes and mark them as not changeable
1058 size_t c3
= Application::GetReservedKeyCodeCount();
1060 for (i3
= 0; i3
< c3
; ++i3
)
1062 const vcl::KeyCode
* pKeyCode
= Application::GetReservedKeyCode(i3
);
1063 sal_Int32 nPos
= MapKeyCodeToPos(*pKeyCode
);
1068 // Hardcoded function mapped so no ID possible and mark entry as not changeable
1069 TAccInfo
* pEntry
= weld::fromId
<TAccInfo
*>(m_xEntriesBox
->get_id(nPos
));
1070 pEntry
->m_bIsConfigurable
= false;
1072 m_xEntriesBox
->set_sensitive(nPos
, false);
1076 void SfxAcceleratorConfigPage::Apply(const uno::Reference
<ui::XAcceleratorConfiguration
>& xAccMgr
)
1081 // Go through the list from the bottom to the top ...
1082 // because logical accelerator must be preferred instead of
1084 for (int i
= 0, nCount
= m_xEntriesBox
->n_children(); i
< nCount
; ++i
)
1086 TAccInfo
* pUserData
= weld::fromId
<TAccInfo
*>(m_xEntriesBox
->get_id(i
));
1088 awt::KeyEvent aAWTKey
;
1092 sCommand
= pUserData
->m_sCommand
;
1093 aAWTKey
= svt::AcceleratorExecute::st_VCLKey2AWTKey(pUserData
->m_aKey
);
1098 if (!sCommand
.isEmpty())
1099 xAccMgr
->setKeyEvent(aAWTKey
, sCommand
);
1101 xAccMgr
->removeKeyEvent(aAWTKey
);
1103 catch (const uno::RuntimeException
&)
1107 catch (const uno::Exception
&)
1113 void SfxAcceleratorConfigPage::ResetConfig() { m_xEntriesBox
->clear(); }
1115 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, ImplUpdateDataHdl
, Timer
*, void)
1117 SelectHdl(m_xGroupLBox
->get_widget());
1120 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, SearchUpdateHdl
, weld::Entry
&, void)
1122 m_aUpdateDataTimer
.Start();
1125 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, FocusOut_Impl
, weld::Widget
&, void)
1127 if (m_aUpdateDataTimer
.IsActive())
1129 m_aUpdateDataTimer
.Stop();
1130 m_aUpdateDataTimer
.Invoke();
1134 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, Load
, weld::Button
&, void)
1136 // ask for filename, where we should load the new config data from
1137 StartFileDialog(StartFileDialogType::Open
, aLoadAccelConfigStr
);
1140 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, Save
, weld::Button
&, void)
1142 StartFileDialog(StartFileDialogType::SaveAs
, aSaveAccelConfigStr
);
1145 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, Default
, weld::Button
&, void)
1147 uno::Reference
<form::XReset
> xReset(m_xAct
, uno::UNO_QUERY
);
1151 m_xEntriesBox
->freeze();
1154 m_xEntriesBox
->thaw();
1155 m_xEntriesBox
->select(0);
1156 SelectHdl(*m_xEntriesBox
);
1159 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, ChangeHdl
, weld::Button
&, void)
1161 int nPos
= m_xEntriesBox
->get_selected_index();
1165 TAccInfo
* pEntry
= weld::fromId
<TAccInfo
*>(m_xEntriesBox
->get_id(nPos
));
1166 OUString sNewCommand
= m_xFunctionBox
->GetCurCommand();
1167 OUString sLabel
= m_xFunctionBox
->GetCurLabel();
1168 if (sLabel
.isEmpty())
1169 sLabel
= GetLabel4Command(sNewCommand
);
1171 pEntry
->m_sCommand
= sNewCommand
;
1172 m_xEntriesBox
->set_text(nPos
, sLabel
, 1);
1174 SelectHdl(m_xFunctionBox
->get_widget());
1177 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, RemoveHdl
, weld::Button
&, void)
1179 // get selected entry
1180 int nPos
= m_xEntriesBox
->get_selected_index();
1184 TAccInfo
* pEntry
= weld::fromId
<TAccInfo
*>(m_xEntriesBox
->get_id(nPos
));
1186 // remove function name from selected entry
1187 m_xEntriesBox
->set_text(nPos
, OUString(), 1);
1188 pEntry
->m_sCommand
.clear();
1190 SelectHdl(m_xFunctionBox
->get_widget());
1193 IMPL_LINK(SfxAcceleratorConfigPage
, SelectHdl
, weld::TreeView
&, rListBox
, void)
1195 if (&rListBox
== m_xEntriesBox
.get())
1197 TAccInfo
* pEntry
= weld::fromId
<TAccInfo
*>(m_xEntriesBox
->get_selected_id());
1199 OUString sPossibleNewCommand
= m_xFunctionBox
->GetCurCommand();
1201 m_xRemoveButton
->set_sensitive(false);
1202 m_xChangeButton
->set_sensitive(false);
1204 if (pEntry
&& pEntry
->m_bIsConfigurable
)
1206 if (pEntry
->isConfigured())
1207 m_xRemoveButton
->set_sensitive(true);
1208 m_xChangeButton
->set_sensitive(pEntry
->m_sCommand
!= sPossibleNewCommand
);
1211 else if (&rListBox
== &m_xGroupLBox
->get_widget())
1213 m_xGroupLBox
->GroupSelected();
1215 // Pause redraw (Do not redraw at each removal)
1216 m_xFunctionBox
->freeze();
1217 // Apply the search filter to the functions list
1218 OUString
aSearchTerm(m_xSearchEdit
->get_text());
1219 int nMatchFound
= applySearchFilter(aSearchTerm
);
1221 m_xFunctionBox
->thaw();
1222 if (nMatchFound
!= -1)
1224 m_xFunctionBox
->select(nMatchFound
);
1225 SelectHdl(m_xFunctionBox
->get_widget());
1230 m_xChangeButton
->set_sensitive(false);
1233 else if (&rListBox
== &m_xFunctionBox
->get_widget())
1235 m_xRemoveButton
->set_sensitive(false);
1236 m_xChangeButton
->set_sensitive(false);
1238 // #i36994 First selected can return null!
1239 TAccInfo
* pEntry
= weld::fromId
<TAccInfo
*>(m_xEntriesBox
->get_selected_id());
1242 OUString sPossibleNewCommand
= m_xFunctionBox
->GetCurCommand();
1244 if (pEntry
->m_bIsConfigurable
)
1246 if (pEntry
->isConfigured())
1247 m_xRemoveButton
->set_sensitive(true);
1248 m_xChangeButton
->set_sensitive(pEntry
->m_sCommand
!= sPossibleNewCommand
1249 && !sPossibleNewCommand
.isEmpty());
1254 if (!sPossibleNewCommand
.isEmpty())
1256 for (int i
= 0, nCount
= m_xEntriesBox
->n_children(); i
< nCount
; ++i
)
1258 TAccInfo
* pUserData
= weld::fromId
<TAccInfo
*>(m_xEntriesBox
->get_id(i
));
1259 if (pUserData
&& pUserData
->m_sCommand
== sPossibleNewCommand
)
1261 m_xKeyBox
->append(weld::toId(pUserData
), pUserData
->m_aKey
.GetName());
1269 // goto selected "key" entry of the key box
1271 TAccInfo
* pU2
= weld::fromId
<TAccInfo
*>(m_xKeyBox
->get_selected_id());
1273 nP2
= MapKeyCodeToPos(pU2
->m_aKey
);
1276 m_xEntriesBox
->select(nP2
);
1277 m_xEntriesBox
->scroll_to_row(nP2
);
1278 SelectHdl(*m_xEntriesBox
);
1283 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, RadioHdl
, weld::Toggleable
&, void)
1285 uno::Reference
<ui::XAcceleratorConfiguration
> xOld
= m_xAct
;
1287 if (m_xOfficeButton
->get_active())
1289 else if (m_xModuleButton
->get_active())
1292 // nothing changed? => do nothing!
1293 if (m_xAct
.is() && (xOld
== m_xAct
))
1296 m_xEntriesBox
->freeze();
1299 m_xEntriesBox
->thaw();
1301 m_xGroupLBox
->Init(m_xContext
, m_xFrame
, m_sModuleLongName
, true);
1303 // pb: #133213# do not select NULL entries
1304 if (m_xEntriesBox
->n_children())
1305 m_xEntriesBox
->select(0);
1307 // activating the selection, typically "all commands", can take a long time
1308 // -> show wait cursor and disable input
1309 weld::WaitObject
aWaitObject(GetFrameWeld());
1310 weld::TreeView
& rTreeView
= m_xGroupLBox
->get_widget();
1311 SelectHdl(rTreeView
);
1314 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, LoadHdl
, sfx2::FileDialogHelper
*, void)
1319 if (ERRCODE_NONE
== m_pFileDlg
->GetError())
1320 sCfgName
= m_pFileDlg
->GetPath();
1322 if (sCfgName
.isEmpty())
1325 weld::WaitObject
aWaitObject(GetFrameWeld());
1327 uno::Reference
<ui::XUIConfigurationManager
> xCfgMgr
;
1328 uno::Reference
<embed::XStorage
>
1329 xRootStorage
; // we must hold the root storage alive, if xCfgMgr is used!
1333 // don't forget to release the storage afterwards!
1334 uno::Reference
<lang::XSingleServiceFactory
> xStorageFactory(
1335 embed::StorageFactory::create(m_xContext
));
1336 uno::Sequence
<uno::Any
> lArgs
{ uno::Any(sCfgName
),
1337 uno::Any(css::embed::ElementModes::READ
) };
1339 xRootStorage
.set(xStorageFactory
->createInstanceWithArguments(lArgs
), uno::UNO_QUERY_THROW
);
1340 uno::Reference
<embed::XStorage
> xUIConfig
1341 = xRootStorage
->openStorageElement(FOLDERNAME_UICONFIG
, embed::ElementModes::READ
);
1344 uno::Reference
<ui::XUIConfigurationManager2
> xCfgMgr2
1345 = ui::UIConfigurationManager::create(m_xContext
);
1346 xCfgMgr2
->setStorage(xUIConfig
);
1347 xCfgMgr
.set(xCfgMgr2
, uno::UNO_QUERY_THROW
);
1352 // open the configuration and update our UI
1353 uno::Reference
<ui::XAcceleratorConfiguration
> xTempAccMgr(xCfgMgr
->getShortCutManager(),
1354 uno::UNO_SET_THROW
);
1356 m_xEntriesBox
->freeze();
1359 m_xEntriesBox
->thaw();
1360 if (m_xEntriesBox
->n_children())
1362 m_xEntriesBox
->select(0);
1363 SelectHdl(m_xFunctionBox
->get_widget());
1367 // don't forget to close the new opened storage!
1368 // We are the owner of it.
1369 if (xRootStorage
.is())
1371 uno::Reference
<lang::XComponent
> xComponent
;
1372 xComponent
.set(xCfgMgr
, uno::UNO_QUERY
);
1373 if (xComponent
.is())
1374 xComponent
->dispose();
1375 xRootStorage
->dispose();
1378 catch (const uno::RuntimeException
&)
1382 catch (const uno::Exception
&)
1387 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, SaveHdl
, sfx2::FileDialogHelper
*, void)
1392 if (ERRCODE_NONE
== m_pFileDlg
->GetError())
1393 sCfgName
= m_pFileDlg
->GetPath();
1395 if (sCfgName
.isEmpty())
1398 weld::WaitObject
aWaitObject(GetFrameWeld());
1400 uno::Reference
<embed::XStorage
> xRootStorage
;
1404 uno::Reference
<lang::XSingleServiceFactory
> xStorageFactory(
1405 embed::StorageFactory::create(m_xContext
));
1406 uno::Sequence
<uno::Any
> lArgs
{ uno::Any(sCfgName
), uno::Any(embed::ElementModes::WRITE
) };
1408 xRootStorage
.set(xStorageFactory
->createInstanceWithArguments(lArgs
), uno::UNO_QUERY_THROW
);
1410 uno::Reference
<embed::XStorage
> xUIConfig(
1411 xRootStorage
->openStorageElement(FOLDERNAME_UICONFIG
, embed::ElementModes::WRITE
),
1412 uno::UNO_SET_THROW
);
1413 uno::Reference
<beans::XPropertySet
> xUIConfigProps(xUIConfig
, uno::UNO_QUERY_THROW
);
1415 // set the correct media type if the storage was new created
1416 OUString sMediaType
;
1417 xUIConfigProps
->getPropertyValue(MEDIATYPE_PROPNAME
) >>= sMediaType
;
1418 if (sMediaType
.isEmpty())
1419 xUIConfigProps
->setPropertyValue(
1420 MEDIATYPE_PROPNAME
, uno::Any(u
"application/vnd.sun.xml.ui.configuration"_ustr
));
1422 uno::Reference
<ui::XUIConfigurationManager2
> xCfgMgr
1423 = ui::UIConfigurationManager::create(m_xContext
);
1424 xCfgMgr
->setStorage(xUIConfig
);
1426 // get the target configuration access and update with all shortcuts
1427 // which are set currently at the UI!
1428 // Don't copy the m_xAct content to it... because m_xAct will be updated
1429 // from the UI on pressing the button "OK" only. And inbetween it's not up to date!
1430 uno::Reference
<ui::XAcceleratorConfiguration
> xTargetAccMgr(xCfgMgr
->getShortCutManager(),
1431 uno::UNO_SET_THROW
);
1432 Apply(xTargetAccMgr
);
1434 // commit (order is important!)
1435 uno::Reference
<ui::XUIConfigurationPersistence
> xCommit1(xTargetAccMgr
,
1436 uno::UNO_QUERY_THROW
);
1437 uno::Reference
<ui::XUIConfigurationPersistence
> xCommit2(xCfgMgr
, uno::UNO_QUERY_THROW
);
1441 if (xRootStorage
.is())
1443 // Commit root storage
1444 uno::Reference
<embed::XTransactedObject
> xCommit3(xRootStorage
, uno::UNO_QUERY_THROW
);
1448 if (xRootStorage
.is())
1452 xRootStorage
->dispose();
1455 catch (const uno::RuntimeException
&)
1459 catch (const uno::Exception
&)
1464 void SfxAcceleratorConfigPage::StartFileDialog(StartFileDialogType nType
, const OUString
& rTitle
)
1466 bool bSave
= nType
== StartFileDialogType::SaveAs
;
1467 short nDialogType
= bSave
? ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION
1468 : ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE
;
1470 new sfx2::FileDialogHelper(nDialogType
, FileDialogFlags::NONE
, GetFrameWeld()));
1472 m_pFileDlg
->SetTitle(rTitle
);
1473 m_pFileDlg
->AddFilter(aFilterAllStr
, FILEDIALOG_FILTER_ALL
);
1474 m_pFileDlg
->AddFilter(aFilterCfgStr
, u
"*.cfg"_ustr
);
1475 m_pFileDlg
->SetCurrentFilter(aFilterCfgStr
);
1476 m_pFileDlg
->SetContext(sfx2::FileDialogHelper::AcceleratorConfig
);
1478 Link
<sfx2::FileDialogHelper
*, void> aDlgClosedLink
1479 = bSave
? LINK(this, SfxAcceleratorConfigPage
, SaveHdl
)
1480 : LINK(this, SfxAcceleratorConfigPage
, LoadHdl
);
1481 m_pFileDlg
->StartExecuteModal(aDlgClosedLink
);
1484 bool SfxAcceleratorConfigPage::FillItemSet(SfxItemSet
*)
1490 css::uno::Reference
<css::beans::XPropertySet
> xFrameProps(m_xFrame
,
1491 css::uno::UNO_QUERY_THROW
);
1492 css::uno::Reference
<css::frame::XLayoutManager
> xLayoutManager
;
1493 xFrameProps
->getPropertyValue(u
"LayoutManager"_ustr
) >>= xLayoutManager
;
1494 css::uno::Reference
<css::beans::XPropertySet
> xLayoutProps(xLayoutManager
,
1495 css::uno::UNO_QUERY_THROW
);
1496 xLayoutProps
->setPropertyValue(u
"RefreshContextToolbarToolTip"_ustr
, css::uno::Any(true));
1498 catch (const uno::RuntimeException
&)
1502 catch (const uno::Exception
&)
1510 void SfxAcceleratorConfigPage::Reset(const SfxItemSet
* rSet
)
1512 // open accelerator configs
1513 // Note: It initialize some other members too, which are needed here ...
1514 // e.g. m_sModuleUIName!
1517 // change the description of the radio button, which switch to the module
1518 // dependent accelerator configuration
1519 OUString sButtonText
= m_xModuleButton
->get_label();
1521 = m_xModuleButton
->strip_mnemonic(sButtonText
).replaceFirst("$(MODULE)", m_sModuleUIName
);
1522 m_xModuleButton
->set_label(sButtonText
);
1525 m_xModuleButton
->set_active(true);
1528 m_xModuleButton
->hide();
1529 m_xOfficeButton
->set_active(true);
1532 RadioHdl(*m_xOfficeButton
);
1534 #if HAVE_FEATURE_SCRIPTING
1535 if (const SfxMacroInfoItem
* pMacroItem
= rSet
->GetItemIfSet(SID_MACROINFO
))
1537 m_pMacroInfoItem
= pMacroItem
;
1538 m_xGroupLBox
->SelectMacro(m_pMacroInfoItem
);
1545 sal_Int32
SfxAcceleratorConfigPage::MapKeyCodeToPos(const vcl::KeyCode
& aKey
) const
1547 sal_uInt16 nCode1
= aKey
.GetCode() + aKey
.GetModifier();
1548 for (int i
= 0, nCount
= m_xEntriesBox
->n_children(); i
< nCount
; ++i
)
1550 TAccInfo
* pUserData
= weld::fromId
<TAccInfo
*>(m_xEntriesBox
->get_id(i
));
1553 sal_uInt16 nCode2
= pUserData
->m_aKey
.GetCode() + pUserData
->m_aKey
.GetModifier();
1554 if (nCode1
== nCode2
)
1562 OUString
SfxAcceleratorConfigPage::GetLabel4Command(const OUString
& sCommand
)
1566 // check global command configuration first
1567 uno::Reference
<container::XNameAccess
> xModuleConf
;
1568 m_xUICmdDescription
->getByName(m_sModuleLongName
) >>= xModuleConf
;
1569 if (xModuleConf
.is())
1571 ::comphelper::SequenceAsHashMap
lProps(xModuleConf
->getByName(sCommand
));
1572 OUString sLabel
= lProps
.getUnpackedValueOrDefault(u
"Name"_ustr
, OUString());
1573 if (!sLabel
.isEmpty())
1577 catch (const uno::RuntimeException
&)
1581 catch (const uno::Exception
&)
1585 // may be it's a style URL .. they must be handled special
1586 SfxStyleInfo_Impl aStyle
;
1587 aStyle
.sCommand
= sCommand
;
1588 if (SfxStylesInfo_Impl::parseStyleCommand(aStyle
))
1590 m_aStylesInfo
.getLabel4Style(aStyle
);
1591 return aStyle
.sLabel
;
1598 * Remove entries which doesn't contain the search term
1600 int SfxAcceleratorConfigPage::applySearchFilter(OUString
const& rSearchTerm
)
1602 if (rSearchTerm
.isEmpty())
1605 m_options
.searchString
= rSearchTerm
;
1606 utl::TextSearch
textSearch(m_options
);
1608 for (int i
= m_xFunctionBox
->n_children(); i
> 0; --i
)
1611 OUString aStr
= m_xFunctionBox
->get_text(nEntry
);
1612 sal_Int32 aStartPos
= 0;
1613 sal_Int32 aEndPos
= aStr
.getLength();
1615 if (!textSearch
.SearchForward(aStr
, &aStartPos
, &aEndPos
))
1616 m_xFunctionBox
->remove(nEntry
);
1619 return m_xFunctionBox
->n_children() ? 0 : -1;
1622 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */