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 OUStringLiteral FOLDERNAME_UICONFIG
= u
"Configurations2";
74 constexpr OUStringLiteral MEDIATYPE_PROPNAME
= u
"MediaType";
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_COLON
,
190 KEY_MOD1
| KEY_SEMICOLON
,
191 KEY_MOD1
| KEY_QUOTELEFT
,
192 KEY_MOD1
| KEY_QUOTERIGHT
,
193 KEY_MOD1
| KEY_BRACKETLEFT
,
194 KEY_MOD1
| KEY_BRACKETRIGHT
,
195 KEY_MOD1
| KEY_RIGHTCURLYBRACKET
,
196 KEY_MOD1
| KEY_POINT
,
197 KEY_MOD1
| KEY_COMMA
,
198 KEY_MOD1
| KEY_TILDE
,
221 KEY_MOD1
| KEY_RIGHT
,
224 KEY_MOD1
| KEY_PAGEUP
,
225 KEY_MOD1
| KEY_PAGEDOWN
,
226 KEY_MOD1
| KEY_RETURN
,
227 KEY_MOD1
| KEY_SPACE
,
228 KEY_MOD1
| KEY_BACKSPACE
,
229 KEY_MOD1
| KEY_INSERT
,
230 KEY_MOD1
| KEY_DELETE
,
233 KEY_MOD1
| KEY_SUBTRACT
,
234 KEY_MOD1
| KEY_MULTIPLY
,
235 KEY_MOD1
| KEY_DIVIDE
,
236 KEY_MOD1
| KEY_EQUAL
,
238 KEY_SHIFT
| KEY_MOD1
| KEY_0
,
239 KEY_SHIFT
| KEY_MOD1
| KEY_1
,
240 KEY_SHIFT
| KEY_MOD1
| KEY_2
,
241 KEY_SHIFT
| KEY_MOD1
| KEY_3
,
242 KEY_SHIFT
| KEY_MOD1
| KEY_4
,
243 KEY_SHIFT
| KEY_MOD1
| KEY_5
,
244 KEY_SHIFT
| KEY_MOD1
| KEY_6
,
245 KEY_SHIFT
| KEY_MOD1
| KEY_7
,
246 KEY_SHIFT
| KEY_MOD1
| KEY_8
,
247 KEY_SHIFT
| KEY_MOD1
| KEY_9
,
248 KEY_SHIFT
| KEY_MOD1
| KEY_A
,
249 KEY_SHIFT
| KEY_MOD1
| KEY_B
,
250 KEY_SHIFT
| KEY_MOD1
| KEY_C
,
251 KEY_SHIFT
| KEY_MOD1
| KEY_D
,
252 KEY_SHIFT
| KEY_MOD1
| KEY_E
,
253 KEY_SHIFT
| KEY_MOD1
| KEY_F
,
254 KEY_SHIFT
| KEY_MOD1
| KEY_G
,
255 KEY_SHIFT
| KEY_MOD1
| KEY_H
,
256 KEY_SHIFT
| KEY_MOD1
| KEY_I
,
257 KEY_SHIFT
| KEY_MOD1
| KEY_J
,
258 KEY_SHIFT
| KEY_MOD1
| KEY_K
,
259 KEY_SHIFT
| KEY_MOD1
| KEY_L
,
260 KEY_SHIFT
| KEY_MOD1
| KEY_M
,
261 KEY_SHIFT
| KEY_MOD1
| KEY_N
,
262 KEY_SHIFT
| KEY_MOD1
| KEY_O
,
263 KEY_SHIFT
| KEY_MOD1
| KEY_P
,
264 KEY_SHIFT
| KEY_MOD1
| KEY_Q
,
265 KEY_SHIFT
| KEY_MOD1
| KEY_R
,
266 KEY_SHIFT
| KEY_MOD1
| KEY_S
,
267 KEY_SHIFT
| KEY_MOD1
| KEY_T
,
268 KEY_SHIFT
| KEY_MOD1
| KEY_U
,
269 KEY_SHIFT
| KEY_MOD1
| KEY_V
,
270 KEY_SHIFT
| KEY_MOD1
| KEY_W
,
271 KEY_SHIFT
| KEY_MOD1
| KEY_X
,
272 KEY_SHIFT
| KEY_MOD1
| KEY_Y
,
273 KEY_SHIFT
| KEY_MOD1
| KEY_Z
,
274 KEY_SHIFT
| KEY_MOD1
| KEY_COLON
,
275 KEY_SHIFT
| KEY_MOD1
| KEY_SEMICOLON
,
276 KEY_SHIFT
| KEY_MOD1
| KEY_QUOTELEFT
,
277 KEY_SHIFT
| KEY_MOD1
| KEY_QUOTERIGHT
,
278 KEY_SHIFT
| KEY_MOD1
| KEY_BRACKETLEFT
,
279 KEY_SHIFT
| KEY_MOD1
| KEY_BRACKETRIGHT
,
280 KEY_SHIFT
| KEY_MOD1
| KEY_RIGHTCURLYBRACKET
,
281 KEY_SHIFT
| KEY_MOD1
| KEY_POINT
,
282 KEY_SHIFT
| KEY_MOD1
| KEY_COMMA
,
283 KEY_SHIFT
| KEY_MOD1
| KEY_TILDE
,
284 KEY_SHIFT
| KEY_MOD1
| KEY_TAB
,
286 KEY_SHIFT
| KEY_MOD1
| KEY_F1
,
287 KEY_SHIFT
| KEY_MOD1
| KEY_F2
,
288 KEY_SHIFT
| KEY_MOD1
| KEY_F3
,
289 KEY_SHIFT
| KEY_MOD1
| KEY_F4
,
290 KEY_SHIFT
| KEY_MOD1
| KEY_F5
,
291 KEY_SHIFT
| KEY_MOD1
| KEY_F6
,
292 KEY_SHIFT
| KEY_MOD1
| KEY_F7
,
293 KEY_SHIFT
| KEY_MOD1
| KEY_F8
,
294 KEY_SHIFT
| KEY_MOD1
| KEY_F9
,
295 KEY_SHIFT
| KEY_MOD1
| KEY_F10
,
296 KEY_SHIFT
| KEY_MOD1
| KEY_F11
,
297 KEY_SHIFT
| KEY_MOD1
| KEY_F12
,
298 KEY_SHIFT
| KEY_MOD1
| KEY_F13
,
299 KEY_SHIFT
| KEY_MOD1
| KEY_F14
,
300 KEY_SHIFT
| KEY_MOD1
| KEY_F15
,
301 KEY_SHIFT
| KEY_MOD1
| KEY_F16
,
303 KEY_SHIFT
| KEY_MOD1
| KEY_DOWN
,
304 KEY_SHIFT
| KEY_MOD1
| KEY_UP
,
305 KEY_SHIFT
| KEY_MOD1
| KEY_LEFT
,
306 KEY_SHIFT
| KEY_MOD1
| KEY_RIGHT
,
307 KEY_SHIFT
| KEY_MOD1
| KEY_HOME
,
308 KEY_SHIFT
| KEY_MOD1
| KEY_END
,
309 KEY_SHIFT
| KEY_MOD1
| KEY_PAGEUP
,
310 KEY_SHIFT
| KEY_MOD1
| KEY_PAGEDOWN
,
311 KEY_SHIFT
| KEY_MOD1
| KEY_RETURN
,
312 KEY_SHIFT
| KEY_MOD1
| KEY_ESCAPE
,
313 KEY_SHIFT
| KEY_MOD1
| KEY_SPACE
,
314 KEY_SHIFT
| KEY_MOD1
| KEY_BACKSPACE
,
315 KEY_SHIFT
| KEY_MOD1
| KEY_INSERT
,
316 KEY_SHIFT
| KEY_MOD1
| KEY_DELETE
,
317 KEY_SHIFT
| KEY_MOD1
| KEY_EQUAL
,
355 KEY_MOD2
| KEY_COLON
,
356 KEY_MOD2
| KEY_SEMICOLON
,
357 KEY_MOD2
| KEY_QUOTELEFT
,
358 KEY_MOD2
| KEY_QUOTERIGHT
,
359 KEY_MOD2
| KEY_BRACKETLEFT
,
360 KEY_MOD2
| KEY_BRACKETRIGHT
,
361 KEY_MOD2
| KEY_RIGHTCURLYBRACKET
,
362 KEY_MOD2
| KEY_POINT
,
363 KEY_MOD2
| KEY_COMMA
,
364 KEY_MOD2
| KEY_TILDE
,
386 KEY_MOD2
| KEY_RIGHT
,
389 KEY_MOD2
| KEY_PAGEUP
,
390 KEY_MOD2
| KEY_PAGEDOWN
,
391 KEY_MOD2
| KEY_RETURN
,
392 KEY_MOD2
| KEY_SPACE
,
393 KEY_MOD2
| KEY_BACKSPACE
,
394 KEY_MOD2
| KEY_INSERT
,
395 KEY_MOD2
| KEY_DELETE
,
396 KEY_MOD2
| KEY_EQUAL
,
398 KEY_SHIFT
| KEY_MOD2
| KEY_0
,
399 KEY_SHIFT
| KEY_MOD2
| KEY_1
,
400 KEY_SHIFT
| KEY_MOD2
| KEY_2
,
401 KEY_SHIFT
| KEY_MOD2
| KEY_3
,
402 KEY_SHIFT
| KEY_MOD2
| KEY_4
,
403 KEY_SHIFT
| KEY_MOD2
| KEY_5
,
404 KEY_SHIFT
| KEY_MOD2
| KEY_6
,
405 KEY_SHIFT
| KEY_MOD2
| KEY_7
,
406 KEY_SHIFT
| KEY_MOD2
| KEY_8
,
407 KEY_SHIFT
| KEY_MOD2
| KEY_9
,
408 KEY_SHIFT
| KEY_MOD2
| KEY_A
,
409 KEY_SHIFT
| KEY_MOD2
| KEY_B
,
410 KEY_SHIFT
| KEY_MOD2
| KEY_C
,
411 KEY_SHIFT
| KEY_MOD2
| KEY_D
,
412 KEY_SHIFT
| KEY_MOD2
| KEY_E
,
413 KEY_SHIFT
| KEY_MOD2
| KEY_F
,
414 KEY_SHIFT
| KEY_MOD2
| KEY_G
,
415 KEY_SHIFT
| KEY_MOD2
| KEY_H
,
416 KEY_SHIFT
| KEY_MOD2
| KEY_I
,
417 KEY_SHIFT
| KEY_MOD2
| KEY_J
,
418 KEY_SHIFT
| KEY_MOD2
| KEY_K
,
419 KEY_SHIFT
| KEY_MOD2
| KEY_L
,
420 KEY_SHIFT
| KEY_MOD2
| KEY_M
,
421 KEY_SHIFT
| KEY_MOD2
| KEY_N
,
422 KEY_SHIFT
| KEY_MOD2
| KEY_O
,
423 KEY_SHIFT
| KEY_MOD2
| KEY_P
,
424 KEY_SHIFT
| KEY_MOD2
| KEY_Q
,
425 KEY_SHIFT
| KEY_MOD2
| KEY_R
,
426 KEY_SHIFT
| KEY_MOD2
| KEY_S
,
427 KEY_SHIFT
| KEY_MOD2
| KEY_T
,
428 KEY_SHIFT
| KEY_MOD2
| KEY_U
,
429 KEY_SHIFT
| KEY_MOD2
| KEY_V
,
430 KEY_SHIFT
| KEY_MOD2
| KEY_W
,
431 KEY_SHIFT
| KEY_MOD2
| KEY_X
,
432 KEY_SHIFT
| KEY_MOD2
| KEY_Y
,
433 KEY_SHIFT
| KEY_MOD2
| KEY_Z
,
434 KEY_SHIFT
| KEY_MOD2
| KEY_COLON
,
435 KEY_SHIFT
| KEY_MOD2
| KEY_SEMICOLON
,
436 KEY_SHIFT
| KEY_MOD2
| KEY_QUOTELEFT
,
437 KEY_SHIFT
| KEY_MOD2
| KEY_QUOTERIGHT
,
438 KEY_SHIFT
| KEY_MOD2
| KEY_BRACKETLEFT
,
439 KEY_SHIFT
| KEY_MOD2
| KEY_BRACKETRIGHT
,
440 KEY_SHIFT
| KEY_MOD2
| KEY_RIGHTCURLYBRACKET
,
441 KEY_SHIFT
| KEY_MOD2
| KEY_POINT
,
442 KEY_SHIFT
| KEY_MOD2
| KEY_COMMA
,
443 KEY_SHIFT
| KEY_MOD2
| KEY_TILDE
,
445 KEY_SHIFT
| KEY_MOD2
| KEY_F1
,
446 KEY_SHIFT
| KEY_MOD2
| KEY_F2
,
447 KEY_SHIFT
| KEY_MOD2
| KEY_F3
,
448 KEY_SHIFT
| KEY_MOD2
| KEY_F4
,
449 KEY_SHIFT
| KEY_MOD2
| KEY_F5
,
450 KEY_SHIFT
| KEY_MOD2
| KEY_F6
,
451 KEY_SHIFT
| KEY_MOD2
| KEY_F7
,
452 KEY_SHIFT
| KEY_MOD2
| KEY_F8
,
453 KEY_SHIFT
| KEY_MOD2
| KEY_F9
,
454 KEY_SHIFT
| KEY_MOD2
| KEY_F10
,
455 KEY_SHIFT
| KEY_MOD2
| KEY_F11
,
456 KEY_SHIFT
| KEY_MOD2
| KEY_F12
,
457 KEY_SHIFT
| KEY_MOD2
| KEY_F13
,
458 KEY_SHIFT
| KEY_MOD2
| KEY_F14
,
459 KEY_SHIFT
| KEY_MOD2
| KEY_F15
,
460 KEY_SHIFT
| KEY_MOD2
| KEY_F16
,
462 KEY_SHIFT
| KEY_MOD2
| KEY_DOWN
,
463 KEY_SHIFT
| KEY_MOD2
| KEY_UP
,
464 KEY_SHIFT
| KEY_MOD2
| KEY_LEFT
,
465 KEY_SHIFT
| KEY_MOD2
| KEY_RIGHT
,
466 KEY_SHIFT
| KEY_MOD2
| KEY_HOME
,
467 KEY_SHIFT
| KEY_MOD2
| KEY_END
,
468 KEY_SHIFT
| KEY_MOD2
| KEY_PAGEUP
,
469 KEY_SHIFT
| KEY_MOD2
| KEY_PAGEDOWN
,
470 KEY_SHIFT
| KEY_MOD2
| KEY_RETURN
,
471 KEY_SHIFT
| KEY_MOD2
| KEY_ESCAPE
,
472 KEY_SHIFT
| KEY_MOD2
| KEY_SPACE
,
473 KEY_SHIFT
| KEY_MOD2
| KEY_BACKSPACE
,
474 KEY_SHIFT
| KEY_MOD2
| KEY_INSERT
,
475 KEY_SHIFT
| KEY_MOD2
| KEY_DELETE
,
476 KEY_SHIFT
| KEY_MOD2
| KEY_EQUAL
,
478 KEY_MOD1
| KEY_MOD2
| KEY_0
,
479 KEY_MOD1
| KEY_MOD2
| KEY_1
,
480 KEY_MOD1
| KEY_MOD2
| KEY_2
,
481 KEY_MOD1
| KEY_MOD2
| KEY_3
,
482 KEY_MOD1
| KEY_MOD2
| KEY_4
,
483 KEY_MOD1
| KEY_MOD2
| KEY_5
,
484 KEY_MOD1
| KEY_MOD2
| KEY_6
,
485 KEY_MOD1
| KEY_MOD2
| KEY_7
,
486 KEY_MOD1
| KEY_MOD2
| KEY_8
,
487 KEY_MOD1
| KEY_MOD2
| KEY_9
,
488 KEY_MOD1
| KEY_MOD2
| KEY_A
,
489 KEY_MOD1
| KEY_MOD2
| KEY_B
,
490 KEY_MOD1
| KEY_MOD2
| KEY_C
,
491 KEY_MOD1
| KEY_MOD2
| KEY_D
,
492 KEY_MOD1
| KEY_MOD2
| KEY_E
,
493 KEY_MOD1
| KEY_MOD2
| KEY_F
,
494 KEY_MOD1
| KEY_MOD2
| KEY_G
,
495 KEY_MOD1
| KEY_MOD2
| KEY_H
,
496 KEY_MOD1
| KEY_MOD2
| KEY_I
,
497 KEY_MOD1
| KEY_MOD2
| KEY_J
,
498 KEY_MOD1
| KEY_MOD2
| KEY_K
,
499 KEY_MOD1
| KEY_MOD2
| KEY_L
,
500 KEY_MOD1
| KEY_MOD2
| KEY_M
,
501 KEY_MOD1
| KEY_MOD2
| KEY_N
,
502 KEY_MOD1
| KEY_MOD2
| KEY_O
,
503 KEY_MOD1
| KEY_MOD2
| KEY_P
,
504 KEY_MOD1
| KEY_MOD2
| KEY_Q
,
505 KEY_MOD1
| KEY_MOD2
| KEY_R
,
506 KEY_MOD1
| KEY_MOD2
| KEY_S
,
507 KEY_MOD1
| KEY_MOD2
| KEY_T
,
508 KEY_MOD1
| KEY_MOD2
| KEY_U
,
509 KEY_MOD1
| KEY_MOD2
| KEY_V
,
510 KEY_MOD1
| KEY_MOD2
| KEY_W
,
511 KEY_MOD1
| KEY_MOD2
| KEY_X
,
512 KEY_MOD1
| KEY_MOD2
| KEY_Y
,
513 KEY_MOD1
| KEY_MOD2
| KEY_Z
,
514 KEY_MOD1
| KEY_MOD2
| KEY_COLON
,
515 KEY_MOD1
| KEY_MOD2
| KEY_SEMICOLON
,
516 KEY_MOD1
| KEY_MOD2
| KEY_QUOTELEFT
,
517 KEY_MOD1
| KEY_MOD2
| KEY_QUOTERIGHT
,
518 KEY_MOD1
| KEY_MOD2
| KEY_BRACKETLEFT
,
519 KEY_MOD1
| KEY_MOD2
| KEY_BRACKETRIGHT
,
520 KEY_MOD1
| KEY_MOD2
| KEY_RIGHTCURLYBRACKET
,
521 KEY_MOD1
| KEY_MOD2
| KEY_POINT
,
522 KEY_MOD1
| KEY_MOD2
| KEY_COMMA
,
523 KEY_MOD1
| KEY_MOD2
| KEY_TILDE
,
524 KEY_MOD1
| KEY_MOD2
| KEY_EQUAL
,
526 KEY_MOD1
| KEY_MOD2
| KEY_F1
,
527 KEY_MOD1
| KEY_MOD2
| KEY_F2
,
528 KEY_MOD1
| KEY_MOD2
| KEY_F3
,
529 KEY_MOD1
| KEY_MOD2
| KEY_F4
,
530 KEY_MOD1
| KEY_MOD2
| KEY_F5
,
531 KEY_MOD1
| KEY_MOD2
| KEY_F6
,
532 KEY_MOD1
| KEY_MOD2
| KEY_F7
,
533 KEY_MOD1
| KEY_MOD2
| KEY_F8
,
534 KEY_MOD1
| KEY_MOD2
| KEY_F9
,
535 KEY_MOD1
| KEY_MOD2
| KEY_F10
,
536 KEY_MOD1
| KEY_MOD2
| KEY_F11
,
537 KEY_MOD1
| KEY_MOD2
| KEY_F12
,
538 KEY_MOD1
| KEY_MOD2
| KEY_F13
,
539 KEY_MOD1
| KEY_MOD2
| KEY_F14
,
540 KEY_MOD1
| KEY_MOD2
| KEY_F15
,
541 KEY_MOD1
| KEY_MOD2
| KEY_F16
,
543 KEY_MOD1
| KEY_MOD2
| KEY_DOWN
,
544 KEY_MOD1
| KEY_MOD2
| KEY_UP
,
545 KEY_MOD1
| KEY_MOD2
| KEY_LEFT
,
546 KEY_MOD1
| KEY_MOD2
| KEY_RIGHT
,
547 KEY_MOD1
| KEY_MOD2
| KEY_HOME
,
548 KEY_MOD1
| KEY_MOD2
| KEY_END
,
549 KEY_MOD1
| KEY_MOD2
| KEY_PAGEUP
,
550 KEY_MOD1
| KEY_MOD2
| KEY_PAGEDOWN
,
551 KEY_MOD1
| KEY_MOD2
| KEY_RETURN
,
552 KEY_MOD1
| KEY_MOD2
| KEY_SPACE
,
553 KEY_MOD1
| KEY_MOD2
| KEY_BACKSPACE
,
554 KEY_MOD1
| KEY_MOD2
| KEY_INSERT
,
555 KEY_MOD1
| KEY_MOD2
| KEY_DELETE
,
557 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_0
,
558 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_1
,
559 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_2
,
560 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_3
,
561 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_4
,
562 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_5
,
563 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_6
,
564 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_7
,
565 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_8
,
566 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_9
,
567 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_A
,
568 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_B
,
569 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_C
,
570 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_D
,
571 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_E
,
572 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F
,
573 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_G
,
574 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_H
,
575 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_I
,
576 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_J
,
577 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_K
,
578 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_L
,
579 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_M
,
580 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_N
,
581 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_O
,
582 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_P
,
583 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_Q
,
584 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_R
,
585 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_S
,
586 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_T
,
587 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_U
,
588 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_V
,
589 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_W
,
590 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_X
,
591 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_Y
,
592 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_Z
,
593 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_COLON
,
594 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_SEMICOLON
,
595 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_QUOTELEFT
,
596 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_QUOTERIGHT
,
597 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_BRACKETLEFT
,
598 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_BRACKETRIGHT
,
599 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_RIGHTCURLYBRACKET
,
600 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_POINT
,
601 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_COMMA
,
602 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_TILDE
,
604 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F1
,
605 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F2
,
606 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F3
,
607 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F4
,
608 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F5
,
609 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F6
,
610 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F7
,
611 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F8
,
612 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F9
,
613 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F10
,
614 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F11
,
615 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F12
,
616 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F13
,
617 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F14
,
618 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F15
,
619 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F16
,
621 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_DOWN
,
622 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_UP
,
623 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_LEFT
,
624 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_RIGHT
,
625 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_HOME
,
626 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_END
,
627 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_PAGEUP
,
628 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_PAGEDOWN
,
629 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_RETURN
,
630 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_SPACE
,
631 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_BACKSPACE
,
632 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_INSERT
,
633 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_DELETE
,
634 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_EQUAL
674 KEY_MOD3
| KEY_COLON
,
675 KEY_MOD3
| KEY_SEMICOLON
,
676 KEY_MOD3
| KEY_QUOTELEFT
,
677 KEY_MOD3
| KEY_QUOTERIGHT
,
678 KEY_MOD3
| KEY_BRACKETLEFT
,
679 KEY_MOD3
| KEY_BRACKETRIGHT
,
680 KEY_MOD3
| KEY_RIGHTCURLYBRACKET
,
681 KEY_MOD3
| KEY_POINT
,
682 KEY_MOD3
| KEY_COMMA
,
683 KEY_MOD3
| KEY_TILDE
,
706 KEY_MOD3
| KEY_RIGHT
,
709 KEY_MOD3
| KEY_PAGEUP
,
710 KEY_MOD3
| KEY_PAGEDOWN
,
711 KEY_MOD3
| KEY_RETURN
,
712 KEY_MOD3
| KEY_SPACE
,
713 KEY_MOD3
| KEY_BACKSPACE
,
714 KEY_MOD3
| KEY_INSERT
,
715 KEY_MOD3
| KEY_DELETE
,
718 KEY_MOD3
| KEY_SUBTRACT
,
719 KEY_MOD3
| KEY_MULTIPLY
,
720 KEY_MOD3
| KEY_DIVIDE
,
721 KEY_MOD3
| KEY_EQUAL
,
723 KEY_SHIFT
| KEY_MOD3
| KEY_0
,
724 KEY_SHIFT
| KEY_MOD3
| KEY_1
,
725 KEY_SHIFT
| KEY_MOD3
| KEY_2
,
726 KEY_SHIFT
| KEY_MOD3
| KEY_3
,
727 KEY_SHIFT
| KEY_MOD3
| KEY_4
,
728 KEY_SHIFT
| KEY_MOD3
| KEY_5
,
729 KEY_SHIFT
| KEY_MOD3
| KEY_6
,
730 KEY_SHIFT
| KEY_MOD3
| KEY_7
,
731 KEY_SHIFT
| KEY_MOD3
| KEY_8
,
732 KEY_SHIFT
| KEY_MOD3
| KEY_9
,
733 KEY_SHIFT
| KEY_MOD3
| KEY_A
,
734 KEY_SHIFT
| KEY_MOD3
| KEY_B
,
735 KEY_SHIFT
| KEY_MOD3
| KEY_C
,
736 KEY_SHIFT
| KEY_MOD3
| KEY_D
,
737 KEY_SHIFT
| KEY_MOD3
| KEY_E
,
738 KEY_SHIFT
| KEY_MOD3
| KEY_F
,
739 KEY_SHIFT
| KEY_MOD3
| KEY_G
,
740 KEY_SHIFT
| KEY_MOD3
| KEY_H
,
741 KEY_SHIFT
| KEY_MOD3
| KEY_I
,
742 KEY_SHIFT
| KEY_MOD3
| KEY_J
,
743 KEY_SHIFT
| KEY_MOD3
| KEY_K
,
744 KEY_SHIFT
| KEY_MOD3
| KEY_L
,
745 KEY_SHIFT
| KEY_MOD3
| KEY_M
,
746 KEY_SHIFT
| KEY_MOD3
| KEY_N
,
747 KEY_SHIFT
| KEY_MOD3
| KEY_O
,
748 KEY_SHIFT
| KEY_MOD3
| KEY_P
,
749 KEY_SHIFT
| KEY_MOD3
| KEY_Q
,
750 KEY_SHIFT
| KEY_MOD3
| KEY_R
,
751 KEY_SHIFT
| KEY_MOD3
| KEY_S
,
752 KEY_SHIFT
| KEY_MOD3
| KEY_T
,
753 KEY_SHIFT
| KEY_MOD3
| KEY_U
,
754 KEY_SHIFT
| KEY_MOD3
| KEY_V
,
755 KEY_SHIFT
| KEY_MOD3
| KEY_W
,
756 KEY_SHIFT
| KEY_MOD3
| KEY_X
,
757 KEY_SHIFT
| KEY_MOD3
| KEY_Y
,
758 KEY_SHIFT
| KEY_MOD3
| KEY_Z
,
759 KEY_SHIFT
| KEY_MOD3
| KEY_COLON
,
760 KEY_SHIFT
| KEY_MOD3
| KEY_SEMICOLON
,
761 KEY_SHIFT
| KEY_MOD3
| KEY_QUOTELEFT
,
762 KEY_SHIFT
| KEY_MOD3
| KEY_QUOTERIGHT
,
763 KEY_SHIFT
| KEY_MOD3
| KEY_BRACKETLEFT
,
764 KEY_SHIFT
| KEY_MOD3
| KEY_BRACKETRIGHT
,
765 KEY_SHIFT
| KEY_MOD3
| KEY_RIGHTCURLYBRACKET
,
766 KEY_SHIFT
| KEY_MOD3
| KEY_POINT
,
767 KEY_SHIFT
| KEY_MOD3
| KEY_COMMA
,
768 KEY_SHIFT
| KEY_MOD3
| KEY_TILDE
,
769 KEY_SHIFT
| KEY_MOD3
| KEY_TAB
,
771 KEY_SHIFT
| KEY_MOD3
| KEY_F1
,
772 KEY_SHIFT
| KEY_MOD3
| KEY_F2
,
773 KEY_SHIFT
| KEY_MOD3
| KEY_F3
,
774 KEY_SHIFT
| KEY_MOD3
| KEY_F4
,
775 KEY_SHIFT
| KEY_MOD3
| KEY_F5
,
776 KEY_SHIFT
| KEY_MOD3
| KEY_F6
,
777 KEY_SHIFT
| KEY_MOD3
| KEY_F7
,
778 KEY_SHIFT
| KEY_MOD3
| KEY_F8
,
779 KEY_SHIFT
| KEY_MOD3
| KEY_F9
,
780 KEY_SHIFT
| KEY_MOD3
| KEY_F10
,
781 KEY_SHIFT
| KEY_MOD3
| KEY_F11
,
782 KEY_SHIFT
| KEY_MOD3
| KEY_F12
,
783 KEY_SHIFT
| KEY_MOD3
| KEY_F13
,
784 KEY_SHIFT
| KEY_MOD3
| KEY_F14
,
785 KEY_SHIFT
| KEY_MOD3
| KEY_F15
,
786 KEY_SHIFT
| KEY_MOD3
| KEY_F16
,
788 KEY_SHIFT
| KEY_MOD3
| KEY_DOWN
,
789 KEY_SHIFT
| KEY_MOD3
| KEY_UP
,
790 KEY_SHIFT
| KEY_MOD3
| KEY_LEFT
,
791 KEY_SHIFT
| KEY_MOD3
| KEY_RIGHT
,
792 KEY_SHIFT
| KEY_MOD3
| KEY_HOME
,
793 KEY_SHIFT
| KEY_MOD3
| KEY_END
,
794 KEY_SHIFT
| KEY_MOD3
| KEY_PAGEUP
,
795 KEY_SHIFT
| KEY_MOD3
| KEY_PAGEDOWN
,
796 KEY_SHIFT
| KEY_MOD3
| KEY_RETURN
,
797 KEY_SHIFT
| KEY_MOD3
| KEY_ESCAPE
,
798 KEY_SHIFT
| KEY_MOD3
| KEY_SPACE
,
799 KEY_SHIFT
| KEY_MOD3
| KEY_BACKSPACE
,
800 KEY_SHIFT
| KEY_MOD3
| KEY_INSERT
,
801 KEY_SHIFT
| KEY_MOD3
| KEY_DELETE
,
802 KEY_SHIFT
| KEY_MOD3
| KEY_EQUAL
806 const sal_uInt16 KEYCODE_ARRAY_SIZE
= std::size(KEYCODE_ARRAY
);
808 /** select the entry, which match the current key input ... excepting
809 keys, which are used for the dialog itself.
811 IMPL_LINK(SfxAcceleratorConfigPage
, KeyInputHdl
, const KeyEvent
&, rKey
, bool)
813 vcl::KeyCode aCode1
= rKey
.GetKeyCode();
814 sal_uInt16 nCode1
= aCode1
.GetCode();
815 sal_uInt16 nMod1
= aCode1
.GetModifier();
817 // is it related to our list box ?
818 if ((nCode1
== KEY_DOWN
) || (nCode1
== KEY_UP
) || (nCode1
== KEY_LEFT
) || (nCode1
== KEY_RIGHT
)
819 || (nCode1
== KEY_PAGEUP
) || (nCode1
== KEY_PAGEDOWN
))
820 // no - handle it as normal dialog input
823 for (int i
= 0, nCount
= m_xEntriesBox
->n_children(); i
< nCount
; ++i
)
825 TAccInfo
* pUserData
= weld::fromId
<TAccInfo
*>(m_xEntriesBox
->get_id(i
));
828 sal_uInt16 nCode2
= pUserData
->m_aKey
.GetCode();
829 sal_uInt16 nMod2
= pUserData
->m_aKey
.GetModifier();
831 if (nCode1
== nCode2
&& nMod1
== nMod2
)
833 m_xEntriesBox
->select(i
);
834 m_xEntriesBox
->scroll_to_row(i
);
840 // no - handle it as normal dialog input
844 SfxAcceleratorConfigPage::SfxAcceleratorConfigPage(weld::Container
* pPage
,
845 weld::DialogController
* pController
,
846 const SfxItemSet
& aSet
)
847 : SfxTabPage(pPage
, pController
, "cui/ui/accelconfigpage.ui", "AccelConfigPage", &aSet
)
848 #if HAVE_FEATURE_SCRIPTING
851 , aLoadAccelConfigStr(CuiResId(RID_CUISTR_LOADACCELCONFIG
))
852 , aSaveAccelConfigStr(CuiResId(RID_CUISTR_SAVEACCELCONFIG
))
853 , aFilterAllStr(SfxResId(STR_SFX_FILTERNAME_ALL
))
854 , aFilterCfgStr(CuiResId(RID_CUISTR_FILTERNAME_CFG
))
855 , m_bStylesInfoInitialized(false)
856 , m_aUpdateDataTimer("SfxAcceleratorConfigPage UpdateDataTimer")
857 , m_aFillGroupIdle("SfxAcceleratorConfigPage m_aFillGroupIdle")
858 , m_xEntriesBox(m_xBuilder
->weld_tree_view("shortcuts"))
859 , m_xOfficeButton(m_xBuilder
->weld_radio_button("office"))
860 , m_xModuleButton(m_xBuilder
->weld_radio_button("module"))
861 , m_xChangeButton(m_xBuilder
->weld_button("change"))
862 , m_xRemoveButton(m_xBuilder
->weld_button("delete"))
863 , m_xGroupLBox(new CuiConfigGroupListBox(m_xBuilder
->weld_tree_view("category")))
864 , m_xFunctionBox(new CuiConfigFunctionListBox(m_xBuilder
->weld_tree_view("function")))
865 , m_xKeyBox(m_xBuilder
->weld_tree_view("keys"))
866 , m_xSearchEdit(m_xBuilder
->weld_entry("searchEntry"))
867 , m_xLoadButton(m_xBuilder
->weld_button("load"))
868 , m_xSaveButton(m_xBuilder
->weld_button("save"))
869 , m_xResetButton(m_xBuilder
->weld_button("reset"))
871 Size
aSize(m_xEntriesBox
->get_approximate_digit_width() * 40,
872 m_xEntriesBox
->get_height_rows(10));
873 m_xEntriesBox
->set_size_request(aSize
.Width(), aSize
.Height());
874 aSize
= Size(m_xEntriesBox
->get_approximate_digit_width() * 19,
875 m_xEntriesBox
->get_height_rows(9));
876 m_xGroupLBox
->set_size_request(aSize
.Width(), aSize
.Height());
877 aSize
= Size(m_xEntriesBox
->get_approximate_digit_width() * 21,
878 m_xEntriesBox
->get_height_rows(9));
879 m_xFunctionBox
->set_size_request(aSize
.Width(), aSize
.Height());
880 aSize
= Size(m_xEntriesBox
->get_approximate_digit_width() * 20,
881 m_xEntriesBox
->get_height_rows(9));
882 m_xKeyBox
->set_size_request(aSize
.Width(), aSize
.Height());
884 // install handler functions
885 m_xChangeButton
->connect_clicked(LINK(this, SfxAcceleratorConfigPage
, ChangeHdl
));
886 m_xRemoveButton
->connect_clicked(LINK(this, SfxAcceleratorConfigPage
, RemoveHdl
));
887 m_xEntriesBox
->connect_changed(LINK(this, SfxAcceleratorConfigPage
, SelectHdl
));
888 m_xEntriesBox
->connect_key_press(LINK(this, SfxAcceleratorConfigPage
, KeyInputHdl
));
889 m_xGroupLBox
->connect_changed(LINK(this, SfxAcceleratorConfigPage
, SelectHdl
));
890 m_xFunctionBox
->connect_changed(LINK(this, SfxAcceleratorConfigPage
, SelectHdl
));
891 m_xKeyBox
->connect_changed(LINK(this, SfxAcceleratorConfigPage
, SelectHdl
));
892 m_xLoadButton
->connect_clicked(LINK(this, SfxAcceleratorConfigPage
, Load
));
893 m_xSaveButton
->connect_clicked(LINK(this, SfxAcceleratorConfigPage
, Save
));
894 m_xResetButton
->connect_clicked(LINK(this, SfxAcceleratorConfigPage
, Default
));
895 m_xOfficeButton
->connect_toggled(LINK(this, SfxAcceleratorConfigPage
, RadioHdl
));
896 m_xSearchEdit
->connect_changed(LINK(this, SfxAcceleratorConfigPage
, SearchUpdateHdl
));
897 m_xSearchEdit
->connect_focus_out(LINK(this, SfxAcceleratorConfigPage
, FocusOut_Impl
));
899 // detect max keyname width
901 for (unsigned short i
: KEYCODE_ARRAY
)
903 int nTmp
= m_xEntriesBox
->get_pixel_size(vcl::KeyCode(i
).GetName()).Width();
904 if (nTmp
> nMaxWidth
)
908 auto nNewTab
= nMaxWidth
+ 5; // additional space
910 // initialize Entriesbox
911 std::vector
<int> aWidths
{ nNewTab
};
912 m_xEntriesBox
->set_column_fixed_widths(aWidths
);
914 //Initialize search util
915 m_options
.AlgorithmType2
= util::SearchAlgorithms2::ABSOLUTE
;
916 m_options
.transliterateFlags
|= TransliterationFlags::IGNORE_CASE
;
918 |= (util::SearchFlags::REG_NOT_BEGINOFLINE
| util::SearchFlags::REG_NOT_ENDOFLINE
);
919 // initialize GroupBox
920 m_xGroupLBox
->SetFunctionListBox(m_xFunctionBox
.get());
923 m_xKeyBox
->make_sorted();
925 m_aUpdateDataTimer
.SetInvokeHandler(LINK(this, SfxAcceleratorConfigPage
, ImplUpdateDataHdl
));
926 m_aUpdateDataTimer
.SetTimeout(EDIT_UPDATEDATA_TIMEOUT
);
928 m_aFillGroupIdle
.SetInvokeHandler(LINK(this, SfxAcceleratorConfigPage
, TimeOut_Impl
));
929 m_aFillGroupIdle
.SetPriority(TaskPriority::HIGHEST
);
932 SfxAcceleratorConfigPage::~SfxAcceleratorConfigPage()
934 m_aFillGroupIdle
.Stop();
936 // free memory - remove all dynamic user data
937 for (int i
= 0, nCount
= m_xEntriesBox
->n_children(); i
< nCount
; ++i
)
939 TAccInfo
* pUserData
= weld::fromId
<TAccInfo
*>(m_xEntriesBox
->get_id(i
));
944 void SfxAcceleratorConfigPage::InitAccCfg()
946 // already initialized ?
948 return; // yes -> do nothing
952 // no - initialize this instance
953 m_xContext
= comphelper::getProcessComponentContext();
955 m_xUICmdDescription
= frame::theUICommandDescription::get(m_xContext
);
957 // get the current active frame, which should be our "parent"
959 m_xFrame
= GetFrame();
962 uno::Reference
<frame::XDesktop2
> xDesktop
= frame::Desktop::create(m_xContext
);
963 m_xFrame
= xDesktop
->getActiveFrame();
967 uno::Reference
<frame::XModuleManager2
> xModuleManager
968 = frame::ModuleManager::create(m_xContext
);
969 m_sModuleLongName
= xModuleManager
->identify(m_xFrame
);
970 comphelper::SequenceAsHashMap
lModuleProps(xModuleManager
->getByName(m_sModuleLongName
));
972 = lModuleProps
.getUnpackedValueOrDefault("ooSetupFactoryUIName", OUString());
974 // get global accelerator configuration
975 m_xGlobal
= css::ui::GlobalAcceleratorConfiguration::create(m_xContext
);
977 // get module accelerator configuration
979 uno::Reference
<ui::XModuleUIConfigurationManagerSupplier
> xModuleCfgSupplier(
980 ui::theModuleUIConfigurationManagerSupplier::get(m_xContext
));
981 uno::Reference
<ui::XUIConfigurationManager
> xUICfgManager
982 = xModuleCfgSupplier
->getUIConfigurationManager(m_sModuleLongName
);
983 m_xModule
= xUICfgManager
->getShortCutManager();
985 catch (const uno::RuntimeException
&)
989 catch (const uno::Exception
&)
995 void SfxAcceleratorConfigPage::Init(const uno::Reference
<ui::XAcceleratorConfiguration
>& xAccMgr
)
1000 if (!m_bStylesInfoInitialized
)
1002 uno::Reference
<frame::XController
> xController
;
1003 uno::Reference
<frame::XModel
> xModel
;
1005 xController
= m_xFrame
->getController();
1006 if (xController
.is())
1007 xModel
= xController
->getModel();
1009 m_aStylesInfo
.init(m_sModuleLongName
, xModel
);
1010 m_xGroupLBox
->SetStylesInfo(&m_aStylesInfo
);
1011 m_bStylesInfoInitialized
= true;
1014 // Insert all editable accelerators into list box. It is possible
1015 // that some accelerators are not mapped on the current system/keyboard
1016 // but we don't want to lose these mappings.
1017 for (sal_Int32 i1
= 0; i1
< KEYCODE_ARRAY_SIZE
; ++i1
)
1019 vcl::KeyCode aKey
= KEYCODE_ARRAY
[i1
];
1020 OUString sKey
= aKey
.GetName();
1023 TAccInfo
* pEntry
= new TAccInfo(i1
, 0 /*nListPos*/, aKey
);
1024 m_xEntriesBox
->append(weld::toId(pEntry
), sKey
);
1025 int nPos
= m_xEntriesBox
->n_children() - 1;
1026 m_xEntriesBox
->set_text(nPos
, OUString(), 1);
1027 m_xEntriesBox
->set_sensitive(nPos
, true);
1030 // Assign all commands to its shortcuts - reading the accelerator config.
1031 uno::Sequence
<awt::KeyEvent
> lKeys
= xAccMgr
->getAllKeyEvents();
1032 sal_Int32 c2
= lKeys
.getLength();
1035 for (i2
= 0; i2
< c2
; ++i2
)
1037 const awt::KeyEvent
& aAWTKey
= lKeys
[i2
];
1038 OUString sCommand
= xAccMgr
->getCommandByKeyEvent(aAWTKey
);
1039 OUString sLabel
= GetLabel4Command(sCommand
);
1040 vcl::KeyCode aKeyCode
= svt::AcceleratorExecute::st_AWTKey2VCLKey(aAWTKey
);
1041 sal_Int32 nPos
= MapKeyCodeToPos(aKeyCode
);
1046 m_xEntriesBox
->set_text(nPos
, sLabel
, 1);
1048 TAccInfo
* pEntry
= weld::fromId
<TAccInfo
*>(m_xEntriesBox
->get_id(nPos
));
1049 pEntry
->m_bIsConfigurable
= true;
1051 pEntry
->m_sCommand
= sCommand
;
1054 // Map the VCL hardcoded key codes and mark them as not changeable
1055 size_t c3
= Application::GetReservedKeyCodeCount();
1057 for (i3
= 0; i3
< c3
; ++i3
)
1059 const vcl::KeyCode
* pKeyCode
= Application::GetReservedKeyCode(i3
);
1060 sal_Int32 nPos
= MapKeyCodeToPos(*pKeyCode
);
1065 // Hardcoded function mapped so no ID possible and mark entry as not changeable
1066 TAccInfo
* pEntry
= weld::fromId
<TAccInfo
*>(m_xEntriesBox
->get_id(nPos
));
1067 pEntry
->m_bIsConfigurable
= false;
1069 m_xEntriesBox
->set_sensitive(nPos
, false);
1073 void SfxAcceleratorConfigPage::Apply(const uno::Reference
<ui::XAcceleratorConfiguration
>& xAccMgr
)
1078 // Go through the list from the bottom to the top ...
1079 // because logical accelerator must be preferred instead of
1081 for (int i
= 0, nCount
= m_xEntriesBox
->n_children(); i
< nCount
; ++i
)
1083 TAccInfo
* pUserData
= weld::fromId
<TAccInfo
*>(m_xEntriesBox
->get_id(i
));
1085 awt::KeyEvent aAWTKey
;
1089 sCommand
= pUserData
->m_sCommand
;
1090 aAWTKey
= svt::AcceleratorExecute::st_VCLKey2AWTKey(pUserData
->m_aKey
);
1095 if (!sCommand
.isEmpty())
1096 xAccMgr
->setKeyEvent(aAWTKey
, sCommand
);
1098 xAccMgr
->removeKeyEvent(aAWTKey
);
1100 catch (const uno::RuntimeException
&)
1104 catch (const uno::Exception
&)
1110 void SfxAcceleratorConfigPage::ResetConfig() { m_xEntriesBox
->clear(); }
1112 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, ImplUpdateDataHdl
, Timer
*, void)
1114 SelectHdl(m_xGroupLBox
->get_widget());
1117 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, SearchUpdateHdl
, weld::Entry
&, void)
1119 m_aUpdateDataTimer
.Start();
1122 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, FocusOut_Impl
, weld::Widget
&, void)
1124 if (m_aUpdateDataTimer
.IsActive())
1126 m_aUpdateDataTimer
.Stop();
1127 m_aUpdateDataTimer
.Invoke();
1131 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, Load
, weld::Button
&, void)
1133 // ask for filename, where we should load the new config data from
1134 StartFileDialog(StartFileDialogType::Open
, aLoadAccelConfigStr
);
1137 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, Save
, weld::Button
&, void)
1139 StartFileDialog(StartFileDialogType::SaveAs
, aSaveAccelConfigStr
);
1142 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, Default
, weld::Button
&, void)
1144 uno::Reference
<form::XReset
> xReset(m_xAct
, uno::UNO_QUERY
);
1148 m_xEntriesBox
->freeze();
1151 m_xEntriesBox
->thaw();
1152 m_xEntriesBox
->select(0);
1153 SelectHdl(*m_xEntriesBox
);
1156 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, ChangeHdl
, weld::Button
&, void)
1158 int nPos
= m_xEntriesBox
->get_selected_index();
1162 TAccInfo
* pEntry
= weld::fromId
<TAccInfo
*>(m_xEntriesBox
->get_id(nPos
));
1163 OUString sNewCommand
= m_xFunctionBox
->GetCurCommand();
1164 OUString sLabel
= m_xFunctionBox
->GetCurLabel();
1165 if (sLabel
.isEmpty())
1166 sLabel
= GetLabel4Command(sNewCommand
);
1168 pEntry
->m_sCommand
= sNewCommand
;
1169 m_xEntriesBox
->set_text(nPos
, sLabel
, 1);
1171 SelectHdl(m_xFunctionBox
->get_widget());
1174 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, RemoveHdl
, weld::Button
&, void)
1176 // get selected entry
1177 int nPos
= m_xEntriesBox
->get_selected_index();
1181 TAccInfo
* pEntry
= weld::fromId
<TAccInfo
*>(m_xEntriesBox
->get_id(nPos
));
1183 // remove function name from selected entry
1184 m_xEntriesBox
->set_text(nPos
, OUString(), 1);
1185 pEntry
->m_sCommand
.clear();
1187 SelectHdl(m_xFunctionBox
->get_widget());
1190 IMPL_LINK(SfxAcceleratorConfigPage
, SelectHdl
, weld::TreeView
&, rListBox
, void)
1192 if (&rListBox
== m_xEntriesBox
.get())
1194 TAccInfo
* pEntry
= weld::fromId
<TAccInfo
*>(m_xEntriesBox
->get_selected_id());
1196 OUString sPossibleNewCommand
= m_xFunctionBox
->GetCurCommand();
1198 m_xRemoveButton
->set_sensitive(false);
1199 m_xChangeButton
->set_sensitive(false);
1201 if (pEntry
&& pEntry
->m_bIsConfigurable
)
1203 if (pEntry
->isConfigured())
1204 m_xRemoveButton
->set_sensitive(true);
1205 m_xChangeButton
->set_sensitive(pEntry
->m_sCommand
!= sPossibleNewCommand
);
1208 else if (&rListBox
== &m_xGroupLBox
->get_widget())
1210 m_xGroupLBox
->GroupSelected();
1212 // Pause redraw (Do not redraw at each removal)
1213 m_xFunctionBox
->freeze();
1214 // Apply the search filter to the functions list
1215 OUString
aSearchTerm(m_xSearchEdit
->get_text());
1216 int nMatchFound
= applySearchFilter(aSearchTerm
);
1218 m_xFunctionBox
->thaw();
1219 if (nMatchFound
!= -1)
1221 m_xFunctionBox
->select(nMatchFound
);
1222 SelectHdl(m_xFunctionBox
->get_widget());
1227 m_xChangeButton
->set_sensitive(false);
1230 else if (&rListBox
== &m_xFunctionBox
->get_widget())
1232 m_xRemoveButton
->set_sensitive(false);
1233 m_xChangeButton
->set_sensitive(false);
1235 // #i36994 First selected can return null!
1236 TAccInfo
* pEntry
= weld::fromId
<TAccInfo
*>(m_xEntriesBox
->get_selected_id());
1239 OUString sPossibleNewCommand
= m_xFunctionBox
->GetCurCommand();
1241 if (pEntry
->m_bIsConfigurable
)
1243 if (pEntry
->isConfigured())
1244 m_xRemoveButton
->set_sensitive(true);
1245 m_xChangeButton
->set_sensitive(pEntry
->m_sCommand
!= sPossibleNewCommand
1246 && !sPossibleNewCommand
.isEmpty());
1251 if (!sPossibleNewCommand
.isEmpty())
1253 for (int i
= 0, nCount
= m_xEntriesBox
->n_children(); i
< nCount
; ++i
)
1255 TAccInfo
* pUserData
= weld::fromId
<TAccInfo
*>(m_xEntriesBox
->get_id(i
));
1256 if (pUserData
&& pUserData
->m_sCommand
== sPossibleNewCommand
)
1258 m_xKeyBox
->append(weld::toId(pUserData
), pUserData
->m_aKey
.GetName());
1266 // goto selected "key" entry of the key box
1268 TAccInfo
* pU2
= weld::fromId
<TAccInfo
*>(m_xKeyBox
->get_selected_id());
1270 nP2
= MapKeyCodeToPos(pU2
->m_aKey
);
1273 m_xEntriesBox
->select(nP2
);
1274 m_xEntriesBox
->scroll_to_row(nP2
);
1275 SelectHdl(*m_xEntriesBox
);
1280 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, RadioHdl
, weld::Toggleable
&, void)
1282 uno::Reference
<ui::XAcceleratorConfiguration
> xOld
= m_xAct
;
1284 if (m_xOfficeButton
->get_active())
1286 else if (m_xModuleButton
->get_active())
1289 // nothing changed? => do nothing!
1290 if (m_xAct
.is() && (xOld
== m_xAct
))
1293 m_xEntriesBox
->freeze();
1296 m_xEntriesBox
->thaw();
1298 m_xGroupLBox
->Init(m_xContext
, m_xFrame
, m_sModuleLongName
, true);
1300 // pb: #133213# do not select NULL entries
1301 if (m_xEntriesBox
->n_children())
1302 m_xEntriesBox
->select(0);
1304 m_aFillGroupIdle
.Start();
1307 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, TimeOut_Impl
, Timer
*, void)
1309 // activating the selection, typically "all commands", can take a long time
1310 // -> show wait cursor and disable input
1311 weld::WaitObject
aWaitObject(GetFrameWeld());
1313 weld::TreeView
& rTreeView
= m_xGroupLBox
->get_widget();
1314 SelectHdl(rTreeView
);
1317 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, LoadHdl
, sfx2::FileDialogHelper
*, void)
1322 if (ERRCODE_NONE
== m_pFileDlg
->GetError())
1323 sCfgName
= m_pFileDlg
->GetPath();
1325 if (sCfgName
.isEmpty())
1328 weld::WaitObject
aWaitObject(GetFrameWeld());
1330 uno::Reference
<ui::XUIConfigurationManager
> xCfgMgr
;
1331 uno::Reference
<embed::XStorage
>
1332 xRootStorage
; // we must hold the root storage alive, if xCfgMgr is used!
1336 // don't forget to release the storage afterwards!
1337 uno::Reference
<lang::XSingleServiceFactory
> xStorageFactory(
1338 embed::StorageFactory::create(m_xContext
));
1339 uno::Sequence
<uno::Any
> lArgs
{ uno::Any(sCfgName
),
1340 uno::Any(css::embed::ElementModes::READ
) };
1342 xRootStorage
.set(xStorageFactory
->createInstanceWithArguments(lArgs
), uno::UNO_QUERY_THROW
);
1343 uno::Reference
<embed::XStorage
> xUIConfig
1344 = xRootStorage
->openStorageElement(FOLDERNAME_UICONFIG
, embed::ElementModes::READ
);
1347 uno::Reference
<ui::XUIConfigurationManager2
> xCfgMgr2
1348 = ui::UIConfigurationManager::create(m_xContext
);
1349 xCfgMgr2
->setStorage(xUIConfig
);
1350 xCfgMgr
.set(xCfgMgr2
, uno::UNO_QUERY_THROW
);
1355 // open the configuration and update our UI
1356 uno::Reference
<ui::XAcceleratorConfiguration
> xTempAccMgr(xCfgMgr
->getShortCutManager(),
1357 uno::UNO_SET_THROW
);
1359 m_xEntriesBox
->freeze();
1362 m_xEntriesBox
->thaw();
1363 if (m_xEntriesBox
->n_children())
1365 m_xEntriesBox
->select(0);
1366 SelectHdl(m_xFunctionBox
->get_widget());
1370 // don't forget to close the new opened storage!
1371 // We are the owner of it.
1372 if (xRootStorage
.is())
1374 uno::Reference
<lang::XComponent
> xComponent
;
1375 xComponent
.set(xCfgMgr
, uno::UNO_QUERY
);
1376 if (xComponent
.is())
1377 xComponent
->dispose();
1378 xRootStorage
->dispose();
1381 catch (const uno::RuntimeException
&)
1385 catch (const uno::Exception
&)
1390 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, SaveHdl
, sfx2::FileDialogHelper
*, void)
1395 if (ERRCODE_NONE
== m_pFileDlg
->GetError())
1396 sCfgName
= m_pFileDlg
->GetPath();
1398 if (sCfgName
.isEmpty())
1401 weld::WaitObject
aWaitObject(GetFrameWeld());
1403 uno::Reference
<embed::XStorage
> xRootStorage
;
1407 uno::Reference
<lang::XSingleServiceFactory
> xStorageFactory(
1408 embed::StorageFactory::create(m_xContext
));
1409 uno::Sequence
<uno::Any
> lArgs
{ uno::Any(sCfgName
), uno::Any(embed::ElementModes::WRITE
) };
1411 xRootStorage
.set(xStorageFactory
->createInstanceWithArguments(lArgs
), uno::UNO_QUERY_THROW
);
1413 uno::Reference
<embed::XStorage
> xUIConfig(
1414 xRootStorage
->openStorageElement(FOLDERNAME_UICONFIG
, embed::ElementModes::WRITE
),
1415 uno::UNO_SET_THROW
);
1416 uno::Reference
<beans::XPropertySet
> xUIConfigProps(xUIConfig
, uno::UNO_QUERY_THROW
);
1418 // set the correct media type if the storage was new created
1419 OUString sMediaType
;
1420 xUIConfigProps
->getPropertyValue(MEDIATYPE_PROPNAME
) >>= sMediaType
;
1421 if (sMediaType
.isEmpty())
1422 xUIConfigProps
->setPropertyValue(
1423 MEDIATYPE_PROPNAME
, uno::Any(OUString("application/vnd.sun.xml.ui.configuration")));
1425 uno::Reference
<ui::XUIConfigurationManager2
> xCfgMgr
1426 = ui::UIConfigurationManager::create(m_xContext
);
1427 xCfgMgr
->setStorage(xUIConfig
);
1429 // get the target configuration access and update with all shortcuts
1430 // which are set currently at the UI!
1431 // Don't copy the m_xAct content to it... because m_xAct will be updated
1432 // from the UI on pressing the button "OK" only. And inbetween it's not up to date!
1433 uno::Reference
<ui::XAcceleratorConfiguration
> xTargetAccMgr(xCfgMgr
->getShortCutManager(),
1434 uno::UNO_SET_THROW
);
1435 Apply(xTargetAccMgr
);
1437 // commit (order is important!)
1438 uno::Reference
<ui::XUIConfigurationPersistence
> xCommit1(xTargetAccMgr
,
1439 uno::UNO_QUERY_THROW
);
1440 uno::Reference
<ui::XUIConfigurationPersistence
> xCommit2(xCfgMgr
, uno::UNO_QUERY_THROW
);
1444 if (xRootStorage
.is())
1446 // Commit root storage
1447 uno::Reference
<embed::XTransactedObject
> xCommit3(xRootStorage
, uno::UNO_QUERY_THROW
);
1451 if (xRootStorage
.is())
1455 xRootStorage
->dispose();
1458 catch (const uno::RuntimeException
&)
1462 catch (const uno::Exception
&)
1467 void SfxAcceleratorConfigPage::StartFileDialog(StartFileDialogType nType
, const OUString
& rTitle
)
1469 bool bSave
= nType
== StartFileDialogType::SaveAs
;
1470 short nDialogType
= bSave
? ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION
1471 : ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE
;
1473 new sfx2::FileDialogHelper(nDialogType
, FileDialogFlags::NONE
, GetFrameWeld()));
1475 m_pFileDlg
->SetTitle(rTitle
);
1476 m_pFileDlg
->AddFilter(aFilterAllStr
, FILEDIALOG_FILTER_ALL
);
1477 m_pFileDlg
->AddFilter(aFilterCfgStr
, "*.cfg");
1478 m_pFileDlg
->SetCurrentFilter(aFilterCfgStr
);
1479 m_pFileDlg
->SetContext(sfx2::FileDialogHelper::AcceleratorConfig
);
1481 Link
<sfx2::FileDialogHelper
*, void> aDlgClosedLink
1482 = bSave
? LINK(this, SfxAcceleratorConfigPage
, SaveHdl
)
1483 : LINK(this, SfxAcceleratorConfigPage
, LoadHdl
);
1484 m_pFileDlg
->StartExecuteModal(aDlgClosedLink
);
1487 bool SfxAcceleratorConfigPage::FillItemSet(SfxItemSet
*)
1493 css::uno::Reference
<css::beans::XPropertySet
> xFrameProps(m_xFrame
,
1494 css::uno::UNO_QUERY_THROW
);
1495 css::uno::Reference
<css::frame::XLayoutManager
> xLayoutManager
;
1496 xFrameProps
->getPropertyValue("LayoutManager") >>= xLayoutManager
;
1497 css::uno::Reference
<css::beans::XPropertySet
> xLayoutProps(xLayoutManager
,
1498 css::uno::UNO_QUERY_THROW
);
1499 xLayoutProps
->setPropertyValue("RefreshContextToolbarToolTip", css::uno::Any(true));
1501 catch (const uno::RuntimeException
&)
1505 catch (const uno::Exception
&)
1513 void SfxAcceleratorConfigPage::Reset(const SfxItemSet
* rSet
)
1515 // open accelerator configs
1516 // Note: It initialize some other members too, which are needed here ...
1517 // e.g. m_sModuleUIName!
1520 // change the description of the radio button, which switch to the module
1521 // dependent accelerator configuration
1522 OUString sButtonText
= m_xModuleButton
->get_label();
1524 = m_xModuleButton
->strip_mnemonic(sButtonText
).replaceFirst("$(MODULE)", m_sModuleUIName
);
1525 m_xModuleButton
->set_label(sButtonText
);
1528 m_xModuleButton
->set_active(true);
1531 m_xModuleButton
->hide();
1532 m_xOfficeButton
->set_active(true);
1535 RadioHdl(*m_xOfficeButton
);
1537 #if HAVE_FEATURE_SCRIPTING
1538 if (const SfxMacroInfoItem
* pMacroItem
= rSet
->GetItemIfSet(SID_MACROINFO
))
1540 m_pMacroInfoItem
= pMacroItem
;
1541 m_xGroupLBox
->SelectMacro(m_pMacroInfoItem
);
1548 sal_Int32
SfxAcceleratorConfigPage::MapKeyCodeToPos(const vcl::KeyCode
& aKey
) const
1550 sal_uInt16 nCode1
= aKey
.GetCode() + aKey
.GetModifier();
1551 for (int i
= 0, nCount
= m_xEntriesBox
->n_children(); i
< nCount
; ++i
)
1553 TAccInfo
* pUserData
= weld::fromId
<TAccInfo
*>(m_xEntriesBox
->get_id(i
));
1556 sal_uInt16 nCode2
= pUserData
->m_aKey
.GetCode() + pUserData
->m_aKey
.GetModifier();
1557 if (nCode1
== nCode2
)
1565 OUString
SfxAcceleratorConfigPage::GetLabel4Command(const OUString
& sCommand
)
1569 // check global command configuration first
1570 uno::Reference
<container::XNameAccess
> xModuleConf
;
1571 m_xUICmdDescription
->getByName(m_sModuleLongName
) >>= xModuleConf
;
1572 if (xModuleConf
.is())
1574 ::comphelper::SequenceAsHashMap
lProps(xModuleConf
->getByName(sCommand
));
1575 OUString sLabel
= lProps
.getUnpackedValueOrDefault("Name", OUString());
1576 if (!sLabel
.isEmpty())
1580 catch (const uno::RuntimeException
&)
1584 catch (const uno::Exception
&)
1588 // may be it's a style URL .. they must be handled special
1589 SfxStyleInfo_Impl aStyle
;
1590 aStyle
.sCommand
= sCommand
;
1591 if (SfxStylesInfo_Impl::parseStyleCommand(aStyle
))
1593 m_aStylesInfo
.getLabel4Style(aStyle
);
1594 return aStyle
.sLabel
;
1601 * Remove entries which doesn't contain the search term
1603 int SfxAcceleratorConfigPage::applySearchFilter(OUString
const& rSearchTerm
)
1605 if (rSearchTerm
.isEmpty())
1608 m_options
.searchString
= rSearchTerm
;
1609 utl::TextSearch
textSearch(m_options
);
1611 for (int i
= m_xFunctionBox
->n_children(); i
> 0; --i
)
1614 OUString aStr
= m_xFunctionBox
->get_text(nEntry
);
1615 sal_Int32 aStartPos
= 0;
1616 sal_Int32 aEndPos
= aStr
.getLength();
1618 if (!textSearch
.SearchForward(aStr
, &aStartPos
, &aEndPos
))
1619 m_xFunctionBox
->remove(nEntry
);
1622 return m_xFunctionBox
->n_children() ? 0 : -1;
1625 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */