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 .
24 #include <cfgutil.hxx>
25 #include <dialmgr.hxx>
27 #include <sfx2/msg.hxx>
28 #include <sfx2/app.hxx>
29 #include <sfx2/filedlghelper.hxx>
30 #include <sfx2/minfitem.hxx>
31 #include <sfx2/sfxresid.hxx>
32 #include <svl/stritem.hxx>
34 #include <sal/macros.h>
35 #include <vcl/edit.hxx>
36 #include <vcl/event.hxx>
38 #include <strings.hrc>
39 #include <sfx2/strings.hrc>
40 #include <svx/svxids.hrc>
43 // include interface declarations
44 #include <com/sun/star/awt/KeyModifier.hpp>
45 #include <com/sun/star/embed/StorageFactory.hpp>
46 #include <com/sun/star/embed/XTransactedObject.hpp>
47 #include <com/sun/star/embed/ElementModes.hpp>
48 #include <com/sun/star/form/XReset.hpp>
49 #include <com/sun/star/frame/Desktop.hpp>
50 #include <com/sun/star/frame/XController.hpp>
51 #include <com/sun/star/frame/XModel.hpp>
52 #include <com/sun/star/frame/ModuleManager.hpp>
53 #include <com/sun/star/frame/theUICommandDescription.hpp>
54 #include <com/sun/star/ui/GlobalAcceleratorConfiguration.hpp>
55 #include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
56 #include <com/sun/star/ui/UIConfigurationManager.hpp>
57 #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
58 #include <com/sun/star/ui/XUIConfigurationManager.hpp>
59 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
61 // include search util
62 #include <com/sun/star/util/SearchFlags.hpp>
63 #include <com/sun/star/util/SearchAlgorithms2.hpp>
64 #include <unotools/textsearch.hxx>
66 // include other projects
67 #include <comphelper/processfactory.hxx>
68 #include <svtools/acceleratorexecute.hxx>
69 #include <vcl/svapp.hxx>
70 #include <vcl/help.hxx>
71 #include <rtl/ustrbuf.hxx>
72 #include <comphelper/sequenceashashmap.hxx>
77 static const char FOLDERNAME_UICONFIG
[] = "Configurations2";
79 static const char MEDIATYPE_PROPNAME
[] = "MediaType";
81 static const sal_uInt16 KEYCODE_ARRAY
[] =
144 KEY_SHIFT
| KEY_DOWN
,
146 KEY_SHIFT
| KEY_LEFT
,
147 KEY_SHIFT
| KEY_RIGHT
,
148 KEY_SHIFT
| KEY_HOME
,
150 KEY_SHIFT
| KEY_PAGEUP
,
151 KEY_SHIFT
| KEY_PAGEDOWN
,
152 KEY_SHIFT
| KEY_RETURN
,
153 KEY_SHIFT
| KEY_SPACE
,
154 KEY_SHIFT
| KEY_ESCAPE
,
155 KEY_SHIFT
| KEY_BACKSPACE
,
156 KEY_SHIFT
| KEY_INSERT
,
157 KEY_SHIFT
| KEY_DELETE
,
195 KEY_MOD1
| KEY_SEMICOLON
,
196 KEY_MOD1
| KEY_QUOTERIGHT
,
197 KEY_MOD1
| KEY_BRACKETLEFT
,
198 KEY_MOD1
| KEY_BRACKETRIGHT
,
199 KEY_MOD1
| KEY_POINT
,
200 KEY_MOD1
| KEY_COMMA
,
201 KEY_MOD1
| KEY_TILDE
,
224 KEY_MOD1
| KEY_RIGHT
,
227 KEY_MOD1
| KEY_PAGEUP
,
228 KEY_MOD1
| KEY_PAGEDOWN
,
229 KEY_MOD1
| KEY_RETURN
,
230 KEY_MOD1
| KEY_SPACE
,
231 KEY_MOD1
| KEY_BACKSPACE
,
232 KEY_MOD1
| KEY_INSERT
,
233 KEY_MOD1
| KEY_DELETE
,
236 KEY_MOD1
| KEY_SUBTRACT
,
237 KEY_MOD1
| KEY_MULTIPLY
,
238 KEY_MOD1
| KEY_DIVIDE
,
240 KEY_SHIFT
| KEY_MOD1
| KEY_0
,
241 KEY_SHIFT
| KEY_MOD1
| KEY_1
,
242 KEY_SHIFT
| KEY_MOD1
| KEY_2
,
243 KEY_SHIFT
| KEY_MOD1
| KEY_3
,
244 KEY_SHIFT
| KEY_MOD1
| KEY_4
,
245 KEY_SHIFT
| KEY_MOD1
| KEY_5
,
246 KEY_SHIFT
| KEY_MOD1
| KEY_6
,
247 KEY_SHIFT
| KEY_MOD1
| KEY_7
,
248 KEY_SHIFT
| KEY_MOD1
| KEY_8
,
249 KEY_SHIFT
| KEY_MOD1
| KEY_9
,
250 KEY_SHIFT
| KEY_MOD1
| KEY_A
,
251 KEY_SHIFT
| KEY_MOD1
| KEY_B
,
252 KEY_SHIFT
| KEY_MOD1
| KEY_C
,
253 KEY_SHIFT
| KEY_MOD1
| KEY_D
,
254 KEY_SHIFT
| KEY_MOD1
| KEY_E
,
255 KEY_SHIFT
| KEY_MOD1
| KEY_F
,
256 KEY_SHIFT
| KEY_MOD1
| KEY_G
,
257 KEY_SHIFT
| KEY_MOD1
| KEY_H
,
258 KEY_SHIFT
| KEY_MOD1
| KEY_I
,
259 KEY_SHIFT
| KEY_MOD1
| KEY_J
,
260 KEY_SHIFT
| KEY_MOD1
| KEY_K
,
261 KEY_SHIFT
| KEY_MOD1
| KEY_L
,
262 KEY_SHIFT
| KEY_MOD1
| KEY_M
,
263 KEY_SHIFT
| KEY_MOD1
| KEY_N
,
264 KEY_SHIFT
| KEY_MOD1
| KEY_O
,
265 KEY_SHIFT
| KEY_MOD1
| KEY_P
,
266 KEY_SHIFT
| KEY_MOD1
| KEY_Q
,
267 KEY_SHIFT
| KEY_MOD1
| KEY_R
,
268 KEY_SHIFT
| KEY_MOD1
| KEY_S
,
269 KEY_SHIFT
| KEY_MOD1
| KEY_T
,
270 KEY_SHIFT
| KEY_MOD1
| KEY_U
,
271 KEY_SHIFT
| KEY_MOD1
| KEY_V
,
272 KEY_SHIFT
| KEY_MOD1
| KEY_W
,
273 KEY_SHIFT
| KEY_MOD1
| KEY_X
,
274 KEY_SHIFT
| KEY_MOD1
| KEY_Y
,
275 KEY_SHIFT
| KEY_MOD1
| KEY_Z
,
276 KEY_SHIFT
| KEY_MOD1
| KEY_SEMICOLON
,
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_POINT
,
281 KEY_SHIFT
| KEY_MOD1
| KEY_COMMA
,
282 KEY_SHIFT
| KEY_MOD1
| KEY_TILDE
,
283 KEY_SHIFT
| KEY_MOD1
| KEY_TAB
,
285 KEY_SHIFT
| KEY_MOD1
| KEY_F1
,
286 KEY_SHIFT
| KEY_MOD1
| KEY_F2
,
287 KEY_SHIFT
| KEY_MOD1
| KEY_F3
,
288 KEY_SHIFT
| KEY_MOD1
| KEY_F4
,
289 KEY_SHIFT
| KEY_MOD1
| KEY_F5
,
290 KEY_SHIFT
| KEY_MOD1
| KEY_F6
,
291 KEY_SHIFT
| KEY_MOD1
| KEY_F7
,
292 KEY_SHIFT
| KEY_MOD1
| KEY_F8
,
293 KEY_SHIFT
| KEY_MOD1
| KEY_F9
,
294 KEY_SHIFT
| KEY_MOD1
| KEY_F10
,
295 KEY_SHIFT
| KEY_MOD1
| KEY_F11
,
296 KEY_SHIFT
| KEY_MOD1
| KEY_F12
,
297 KEY_SHIFT
| KEY_MOD1
| KEY_F13
,
298 KEY_SHIFT
| KEY_MOD1
| KEY_F14
,
299 KEY_SHIFT
| KEY_MOD1
| KEY_F15
,
300 KEY_SHIFT
| KEY_MOD1
| KEY_F16
,
302 KEY_SHIFT
| KEY_MOD1
| KEY_DOWN
,
303 KEY_SHIFT
| KEY_MOD1
| KEY_UP
,
304 KEY_SHIFT
| KEY_MOD1
| KEY_LEFT
,
305 KEY_SHIFT
| KEY_MOD1
| KEY_RIGHT
,
306 KEY_SHIFT
| KEY_MOD1
| KEY_HOME
,
307 KEY_SHIFT
| KEY_MOD1
| KEY_END
,
308 KEY_SHIFT
| KEY_MOD1
| KEY_PAGEUP
,
309 KEY_SHIFT
| KEY_MOD1
| KEY_PAGEDOWN
,
310 KEY_SHIFT
| KEY_MOD1
| KEY_RETURN
,
311 KEY_SHIFT
| KEY_MOD1
| KEY_ESCAPE
,
312 KEY_SHIFT
| KEY_MOD1
| KEY_SPACE
,
313 KEY_SHIFT
| KEY_MOD1
| KEY_BACKSPACE
,
314 KEY_SHIFT
| KEY_MOD1
| KEY_INSERT
,
315 KEY_SHIFT
| KEY_MOD1
| KEY_DELETE
,
353 KEY_MOD2
| KEY_SEMICOLON
,
354 KEY_MOD2
| KEY_QUOTERIGHT
,
355 KEY_MOD2
| KEY_BRACKETLEFT
,
356 KEY_MOD2
| KEY_BRACKETRIGHT
,
357 KEY_MOD2
| KEY_POINT
,
358 KEY_MOD2
| KEY_COMMA
,
359 KEY_MOD2
| KEY_TILDE
,
381 KEY_MOD2
| KEY_RIGHT
,
384 KEY_MOD2
| KEY_PAGEUP
,
385 KEY_MOD2
| KEY_PAGEDOWN
,
386 KEY_MOD2
| KEY_RETURN
,
387 KEY_MOD2
| KEY_SPACE
,
388 KEY_MOD2
| KEY_BACKSPACE
,
389 KEY_MOD2
| KEY_INSERT
,
390 KEY_MOD2
| KEY_DELETE
,
392 KEY_SHIFT
| KEY_MOD2
| KEY_0
,
393 KEY_SHIFT
| KEY_MOD2
| KEY_1
,
394 KEY_SHIFT
| KEY_MOD2
| KEY_2
,
395 KEY_SHIFT
| KEY_MOD2
| KEY_3
,
396 KEY_SHIFT
| KEY_MOD2
| KEY_4
,
397 KEY_SHIFT
| KEY_MOD2
| KEY_5
,
398 KEY_SHIFT
| KEY_MOD2
| KEY_6
,
399 KEY_SHIFT
| KEY_MOD2
| KEY_7
,
400 KEY_SHIFT
| KEY_MOD2
| KEY_8
,
401 KEY_SHIFT
| KEY_MOD2
| KEY_9
,
402 KEY_SHIFT
| KEY_MOD2
| KEY_A
,
403 KEY_SHIFT
| KEY_MOD2
| KEY_B
,
404 KEY_SHIFT
| KEY_MOD2
| KEY_C
,
405 KEY_SHIFT
| KEY_MOD2
| KEY_D
,
406 KEY_SHIFT
| KEY_MOD2
| KEY_E
,
407 KEY_SHIFT
| KEY_MOD2
| KEY_F
,
408 KEY_SHIFT
| KEY_MOD2
| KEY_G
,
409 KEY_SHIFT
| KEY_MOD2
| KEY_H
,
410 KEY_SHIFT
| KEY_MOD2
| KEY_I
,
411 KEY_SHIFT
| KEY_MOD2
| KEY_J
,
412 KEY_SHIFT
| KEY_MOD2
| KEY_K
,
413 KEY_SHIFT
| KEY_MOD2
| KEY_L
,
414 KEY_SHIFT
| KEY_MOD2
| KEY_M
,
415 KEY_SHIFT
| KEY_MOD2
| KEY_N
,
416 KEY_SHIFT
| KEY_MOD2
| KEY_O
,
417 KEY_SHIFT
| KEY_MOD2
| KEY_P
,
418 KEY_SHIFT
| KEY_MOD2
| KEY_Q
,
419 KEY_SHIFT
| KEY_MOD2
| KEY_R
,
420 KEY_SHIFT
| KEY_MOD2
| KEY_S
,
421 KEY_SHIFT
| KEY_MOD2
| KEY_T
,
422 KEY_SHIFT
| KEY_MOD2
| KEY_U
,
423 KEY_SHIFT
| KEY_MOD2
| KEY_V
,
424 KEY_SHIFT
| KEY_MOD2
| KEY_W
,
425 KEY_SHIFT
| KEY_MOD2
| KEY_X
,
426 KEY_SHIFT
| KEY_MOD2
| KEY_Y
,
427 KEY_SHIFT
| KEY_MOD2
| KEY_Z
,
428 KEY_SHIFT
| KEY_MOD2
| KEY_SEMICOLON
,
429 KEY_SHIFT
| KEY_MOD2
| KEY_QUOTERIGHT
,
430 KEY_SHIFT
| KEY_MOD2
| KEY_BRACKETLEFT
,
431 KEY_SHIFT
| KEY_MOD2
| KEY_BRACKETRIGHT
,
432 KEY_SHIFT
| KEY_MOD2
| KEY_POINT
,
433 KEY_SHIFT
| KEY_MOD2
| KEY_COMMA
,
434 KEY_SHIFT
| KEY_MOD2
| KEY_TILDE
,
436 KEY_SHIFT
| KEY_MOD2
| KEY_F1
,
437 KEY_SHIFT
| KEY_MOD2
| KEY_F2
,
438 KEY_SHIFT
| KEY_MOD2
| KEY_F3
,
439 KEY_SHIFT
| KEY_MOD2
| KEY_F4
,
440 KEY_SHIFT
| KEY_MOD2
| KEY_F5
,
441 KEY_SHIFT
| KEY_MOD2
| KEY_F6
,
442 KEY_SHIFT
| KEY_MOD2
| KEY_F7
,
443 KEY_SHIFT
| KEY_MOD2
| KEY_F8
,
444 KEY_SHIFT
| KEY_MOD2
| KEY_F9
,
445 KEY_SHIFT
| KEY_MOD2
| KEY_F10
,
446 KEY_SHIFT
| KEY_MOD2
| KEY_F11
,
447 KEY_SHIFT
| KEY_MOD2
| KEY_F12
,
448 KEY_SHIFT
| KEY_MOD2
| KEY_F13
,
449 KEY_SHIFT
| KEY_MOD2
| KEY_F14
,
450 KEY_SHIFT
| KEY_MOD2
| KEY_F15
,
451 KEY_SHIFT
| KEY_MOD2
| KEY_F16
,
453 KEY_SHIFT
| KEY_MOD2
| KEY_DOWN
,
454 KEY_SHIFT
| KEY_MOD2
| KEY_UP
,
455 KEY_SHIFT
| KEY_MOD2
| KEY_LEFT
,
456 KEY_SHIFT
| KEY_MOD2
| KEY_RIGHT
,
457 KEY_SHIFT
| KEY_MOD2
| KEY_HOME
,
458 KEY_SHIFT
| KEY_MOD2
| KEY_END
,
459 KEY_SHIFT
| KEY_MOD2
| KEY_PAGEUP
,
460 KEY_SHIFT
| KEY_MOD2
| KEY_PAGEDOWN
,
461 KEY_SHIFT
| KEY_MOD2
| KEY_RETURN
,
462 KEY_SHIFT
| KEY_MOD2
| KEY_ESCAPE
,
463 KEY_SHIFT
| KEY_MOD2
| KEY_SPACE
,
464 KEY_SHIFT
| KEY_MOD2
| KEY_BACKSPACE
,
465 KEY_SHIFT
| KEY_MOD2
| KEY_INSERT
,
466 KEY_SHIFT
| KEY_MOD2
| KEY_DELETE
,
468 KEY_MOD1
| KEY_MOD2
| KEY_0
,
469 KEY_MOD1
| KEY_MOD2
| KEY_1
,
470 KEY_MOD1
| KEY_MOD2
| KEY_2
,
471 KEY_MOD1
| KEY_MOD2
| KEY_3
,
472 KEY_MOD1
| KEY_MOD2
| KEY_4
,
473 KEY_MOD1
| KEY_MOD2
| KEY_5
,
474 KEY_MOD1
| KEY_MOD2
| KEY_6
,
475 KEY_MOD1
| KEY_MOD2
| KEY_7
,
476 KEY_MOD1
| KEY_MOD2
| KEY_8
,
477 KEY_MOD1
| KEY_MOD2
| KEY_9
,
478 KEY_MOD1
| KEY_MOD2
| KEY_A
,
479 KEY_MOD1
| KEY_MOD2
| KEY_B
,
480 KEY_MOD1
| KEY_MOD2
| KEY_C
,
481 KEY_MOD1
| KEY_MOD2
| KEY_D
,
482 KEY_MOD1
| KEY_MOD2
| KEY_E
,
483 KEY_MOD1
| KEY_MOD2
| KEY_F
,
484 KEY_MOD1
| KEY_MOD2
| KEY_G
,
485 KEY_MOD1
| KEY_MOD2
| KEY_H
,
486 KEY_MOD1
| KEY_MOD2
| KEY_I
,
487 KEY_MOD1
| KEY_MOD2
| KEY_J
,
488 KEY_MOD1
| KEY_MOD2
| KEY_K
,
489 KEY_MOD1
| KEY_MOD2
| KEY_L
,
490 KEY_MOD1
| KEY_MOD2
| KEY_M
,
491 KEY_MOD1
| KEY_MOD2
| KEY_N
,
492 KEY_MOD1
| KEY_MOD2
| KEY_O
,
493 KEY_MOD1
| KEY_MOD2
| KEY_P
,
494 KEY_MOD1
| KEY_MOD2
| KEY_Q
,
495 KEY_MOD1
| KEY_MOD2
| KEY_R
,
496 KEY_MOD1
| KEY_MOD2
| KEY_S
,
497 KEY_MOD1
| KEY_MOD2
| KEY_T
,
498 KEY_MOD1
| KEY_MOD2
| KEY_U
,
499 KEY_MOD1
| KEY_MOD2
| KEY_V
,
500 KEY_MOD1
| KEY_MOD2
| KEY_W
,
501 KEY_MOD1
| KEY_MOD2
| KEY_X
,
502 KEY_MOD1
| KEY_MOD2
| KEY_Y
,
503 KEY_MOD1
| KEY_MOD2
| KEY_Z
,
504 KEY_MOD1
| KEY_MOD2
| KEY_SEMICOLON
,
505 KEY_MOD1
| KEY_MOD2
| KEY_QUOTERIGHT
,
506 KEY_MOD1
| KEY_MOD2
| KEY_BRACKETLEFT
,
507 KEY_MOD1
| KEY_MOD2
| KEY_BRACKETRIGHT
,
508 KEY_MOD1
| KEY_MOD2
| KEY_POINT
,
509 KEY_MOD1
| KEY_MOD2
| KEY_COMMA
,
510 KEY_MOD1
| KEY_MOD2
| KEY_TILDE
,
512 KEY_MOD1
| KEY_MOD2
| KEY_F1
,
513 KEY_MOD1
| KEY_MOD2
| KEY_F2
,
514 KEY_MOD1
| KEY_MOD2
| KEY_F3
,
515 KEY_MOD1
| KEY_MOD2
| KEY_F4
,
516 KEY_MOD1
| KEY_MOD2
| KEY_F5
,
517 KEY_MOD1
| KEY_MOD2
| KEY_F6
,
518 KEY_MOD1
| KEY_MOD2
| KEY_F7
,
519 KEY_MOD1
| KEY_MOD2
| KEY_F8
,
520 KEY_MOD1
| KEY_MOD2
| KEY_F9
,
521 KEY_MOD1
| KEY_MOD2
| KEY_F10
,
522 KEY_MOD1
| KEY_MOD2
| KEY_F11
,
523 KEY_MOD1
| KEY_MOD2
| KEY_F12
,
524 KEY_MOD1
| KEY_MOD2
| KEY_F13
,
525 KEY_MOD1
| KEY_MOD2
| KEY_F14
,
526 KEY_MOD1
| KEY_MOD2
| KEY_F15
,
527 KEY_MOD1
| KEY_MOD2
| KEY_F16
,
529 KEY_MOD1
| KEY_MOD2
| KEY_DOWN
,
530 KEY_MOD1
| KEY_MOD2
| KEY_UP
,
531 KEY_MOD1
| KEY_MOD2
| KEY_LEFT
,
532 KEY_MOD1
| KEY_MOD2
| KEY_RIGHT
,
533 KEY_MOD1
| KEY_MOD2
| KEY_HOME
,
534 KEY_MOD1
| KEY_MOD2
| KEY_END
,
535 KEY_MOD1
| KEY_MOD2
| KEY_PAGEUP
,
536 KEY_MOD1
| KEY_MOD2
| KEY_PAGEDOWN
,
537 KEY_MOD1
| KEY_MOD2
| KEY_RETURN
,
538 KEY_MOD1
| KEY_MOD2
| KEY_SPACE
,
539 KEY_MOD1
| KEY_MOD2
| KEY_BACKSPACE
,
540 KEY_MOD1
| KEY_MOD2
| KEY_INSERT
,
541 KEY_MOD1
| KEY_MOD2
| KEY_DELETE
,
543 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_0
,
544 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_1
,
545 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_2
,
546 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_3
,
547 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_4
,
548 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_5
,
549 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_6
,
550 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_7
,
551 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_8
,
552 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_9
,
553 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_A
,
554 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_B
,
555 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_C
,
556 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_D
,
557 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_E
,
558 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F
,
559 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_G
,
560 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_H
,
561 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_I
,
562 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_J
,
563 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_K
,
564 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_L
,
565 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_M
,
566 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_N
,
567 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_O
,
568 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_P
,
569 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_Q
,
570 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_R
,
571 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_S
,
572 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_T
,
573 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_U
,
574 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_V
,
575 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_W
,
576 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_X
,
577 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_Y
,
578 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_Z
,
579 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_SEMICOLON
,
580 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_QUOTERIGHT
,
581 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_BRACKETLEFT
,
582 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_BRACKETRIGHT
,
583 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_POINT
,
584 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_COMMA
,
585 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_TILDE
,
587 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F1
,
588 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F2
,
589 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F3
,
590 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F4
,
591 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F5
,
592 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F6
,
593 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F7
,
594 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F8
,
595 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F9
,
596 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F10
,
597 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F11
,
598 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F12
,
599 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F13
,
600 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F14
,
601 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F15
,
602 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F16
,
604 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_DOWN
,
605 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_UP
,
606 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_LEFT
,
607 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_RIGHT
,
608 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_HOME
,
609 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_END
,
610 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_PAGEUP
,
611 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_PAGEDOWN
,
612 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_RETURN
,
613 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_SPACE
,
614 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_BACKSPACE
,
615 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_INSERT
,
616 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_DELETE
655 KEY_MOD3
| KEY_SEMICOLON
,
656 KEY_MOD3
| KEY_QUOTERIGHT
,
657 KEY_MOD3
| KEY_BRACKETLEFT
,
658 KEY_MOD3
| KEY_BRACKETRIGHT
,
659 KEY_MOD3
| KEY_POINT
,
660 KEY_MOD3
| KEY_COMMA
,
661 KEY_MOD3
| KEY_TILDE
,
684 KEY_MOD3
| KEY_RIGHT
,
687 KEY_MOD3
| KEY_PAGEUP
,
688 KEY_MOD3
| KEY_PAGEDOWN
,
689 KEY_MOD3
| KEY_RETURN
,
690 KEY_MOD3
| KEY_SPACE
,
691 KEY_MOD3
| KEY_BACKSPACE
,
692 KEY_MOD3
| KEY_INSERT
,
693 KEY_MOD3
| KEY_DELETE
,
696 KEY_MOD3
| KEY_SUBTRACT
,
697 KEY_MOD3
| KEY_MULTIPLY
,
698 KEY_MOD3
| KEY_DIVIDE
,
700 KEY_SHIFT
| KEY_MOD3
| KEY_0
,
701 KEY_SHIFT
| KEY_MOD3
| KEY_1
,
702 KEY_SHIFT
| KEY_MOD3
| KEY_2
,
703 KEY_SHIFT
| KEY_MOD3
| KEY_3
,
704 KEY_SHIFT
| KEY_MOD3
| KEY_4
,
705 KEY_SHIFT
| KEY_MOD3
| KEY_5
,
706 KEY_SHIFT
| KEY_MOD3
| KEY_6
,
707 KEY_SHIFT
| KEY_MOD3
| KEY_7
,
708 KEY_SHIFT
| KEY_MOD3
| KEY_8
,
709 KEY_SHIFT
| KEY_MOD3
| KEY_9
,
710 KEY_SHIFT
| KEY_MOD3
| KEY_A
,
711 KEY_SHIFT
| KEY_MOD3
| KEY_B
,
712 KEY_SHIFT
| KEY_MOD3
| KEY_C
,
713 KEY_SHIFT
| KEY_MOD3
| KEY_D
,
714 KEY_SHIFT
| KEY_MOD3
| KEY_E
,
715 KEY_SHIFT
| KEY_MOD3
| KEY_F
,
716 KEY_SHIFT
| KEY_MOD3
| KEY_G
,
717 KEY_SHIFT
| KEY_MOD3
| KEY_H
,
718 KEY_SHIFT
| KEY_MOD3
| KEY_I
,
719 KEY_SHIFT
| KEY_MOD3
| KEY_J
,
720 KEY_SHIFT
| KEY_MOD3
| KEY_K
,
721 KEY_SHIFT
| KEY_MOD3
| KEY_L
,
722 KEY_SHIFT
| KEY_MOD3
| KEY_M
,
723 KEY_SHIFT
| KEY_MOD3
| KEY_N
,
724 KEY_SHIFT
| KEY_MOD3
| KEY_O
,
725 KEY_SHIFT
| KEY_MOD3
| KEY_P
,
726 KEY_SHIFT
| KEY_MOD3
| KEY_Q
,
727 KEY_SHIFT
| KEY_MOD3
| KEY_R
,
728 KEY_SHIFT
| KEY_MOD3
| KEY_S
,
729 KEY_SHIFT
| KEY_MOD3
| KEY_T
,
730 KEY_SHIFT
| KEY_MOD3
| KEY_U
,
731 KEY_SHIFT
| KEY_MOD3
| KEY_V
,
732 KEY_SHIFT
| KEY_MOD3
| KEY_W
,
733 KEY_SHIFT
| KEY_MOD3
| KEY_X
,
734 KEY_SHIFT
| KEY_MOD3
| KEY_Y
,
735 KEY_SHIFT
| KEY_MOD3
| KEY_Z
,
736 KEY_SHIFT
| KEY_MOD3
| KEY_SEMICOLON
,
737 KEY_SHIFT
| KEY_MOD3
| KEY_QUOTERIGHT
,
738 KEY_SHIFT
| KEY_MOD3
| KEY_BRACKETLEFT
,
739 KEY_SHIFT
| KEY_MOD3
| KEY_BRACKETRIGHT
,
740 KEY_SHIFT
| KEY_MOD3
| KEY_POINT
,
741 KEY_SHIFT
| KEY_MOD3
| KEY_COMMA
,
742 KEY_SHIFT
| KEY_MOD3
| KEY_TILDE
,
743 KEY_SHIFT
| KEY_MOD3
| KEY_TAB
,
745 KEY_SHIFT
| KEY_MOD3
| KEY_F1
,
746 KEY_SHIFT
| KEY_MOD3
| KEY_F2
,
747 KEY_SHIFT
| KEY_MOD3
| KEY_F3
,
748 KEY_SHIFT
| KEY_MOD3
| KEY_F4
,
749 KEY_SHIFT
| KEY_MOD3
| KEY_F5
,
750 KEY_SHIFT
| KEY_MOD3
| KEY_F6
,
751 KEY_SHIFT
| KEY_MOD3
| KEY_F7
,
752 KEY_SHIFT
| KEY_MOD3
| KEY_F8
,
753 KEY_SHIFT
| KEY_MOD3
| KEY_F9
,
754 KEY_SHIFT
| KEY_MOD3
| KEY_F10
,
755 KEY_SHIFT
| KEY_MOD3
| KEY_F11
,
756 KEY_SHIFT
| KEY_MOD3
| KEY_F12
,
757 KEY_SHIFT
| KEY_MOD3
| KEY_F13
,
758 KEY_SHIFT
| KEY_MOD3
| KEY_F14
,
759 KEY_SHIFT
| KEY_MOD3
| KEY_F15
,
760 KEY_SHIFT
| KEY_MOD3
| KEY_F16
,
762 KEY_SHIFT
| KEY_MOD3
| KEY_DOWN
,
763 KEY_SHIFT
| KEY_MOD3
| KEY_UP
,
764 KEY_SHIFT
| KEY_MOD3
| KEY_LEFT
,
765 KEY_SHIFT
| KEY_MOD3
| KEY_RIGHT
,
766 KEY_SHIFT
| KEY_MOD3
| KEY_HOME
,
767 KEY_SHIFT
| KEY_MOD3
| KEY_END
,
768 KEY_SHIFT
| KEY_MOD3
| KEY_PAGEUP
,
769 KEY_SHIFT
| KEY_MOD3
| KEY_PAGEDOWN
,
770 KEY_SHIFT
| KEY_MOD3
| KEY_RETURN
,
771 KEY_SHIFT
| KEY_MOD3
| KEY_ESCAPE
,
772 KEY_SHIFT
| KEY_MOD3
| KEY_SPACE
,
773 KEY_SHIFT
| KEY_MOD3
| KEY_BACKSPACE
,
774 KEY_SHIFT
| KEY_MOD3
| KEY_INSERT
,
775 KEY_SHIFT
| KEY_MOD3
| KEY_DELETE
779 static const sal_uInt16 KEYCODE_ARRAY_SIZE
= SAL_N_ELEMENTS(KEYCODE_ARRAY
);
781 /** select the entry, which match the current key input ... excepting
782 keys, which are used for the dialog itself.
784 IMPL_LINK(SfxAcceleratorConfigPage
, KeyInputHdl
, const KeyEvent
&, rKey
, bool)
786 vcl::KeyCode aCode1
= rKey
.GetKeyCode();
787 sal_uInt16 nCode1
= aCode1
.GetCode();
788 sal_uInt16 nMod1
= aCode1
.GetModifier();
790 // is it related to our list box ?
792 (nCode1
!= KEY_DOWN
) &&
793 (nCode1
!= KEY_UP
) &&
794 (nCode1
!= KEY_LEFT
) &&
795 (nCode1
!= KEY_RIGHT
) &&
796 (nCode1
!= KEY_PAGEUP
) &&
797 (nCode1
!= KEY_PAGEDOWN
)
800 for (int i
= 0, nCount
= m_xEntriesBox
->n_children(); i
< nCount
; ++i
)
802 TAccInfo
* pUserData
= reinterpret_cast<TAccInfo
*>(m_xEntriesBox
->get_id(i
).toInt64());
805 sal_uInt16 nCode2
= pUserData
->m_aKey
.GetCode();
806 sal_uInt16 nMod2
= pUserData
->m_aKey
.GetModifier();
808 if (nCode1
== nCode2
&& nMod1
== nMod2
)
810 m_xEntriesBox
->select(i
);
811 m_xEntriesBox
->scroll_to_row(i
);
818 // no - handle it as normal dialog input
822 SfxAcceleratorConfigPage::SfxAcceleratorConfigPage(TabPageParent pParent
, const SfxItemSet
& aSet
)
823 : SfxTabPage(pParent
, "cui/ui/accelconfigpage.ui", "AccelConfigPage", &aSet
)
825 , aLoadAccelConfigStr(CuiResId(RID_SVXSTR_LOADACCELCONFIG
))
826 , aSaveAccelConfigStr(CuiResId(RID_SVXSTR_SAVEACCELCONFIG
))
827 , aFilterCfgStr(CuiResId(RID_SVXSTR_FILTERNAME_CFG
))
828 , m_bStylesInfoInitialized(false)
832 , m_aUpdateDataTimer("UpdateDataTimer")
833 , m_xEntriesBox(m_xBuilder
->weld_tree_view("shortcuts"))
834 , m_xOfficeButton(m_xBuilder
->weld_radio_button("office"))
835 , m_xModuleButton(m_xBuilder
->weld_radio_button("module"))
836 , m_xChangeButton(m_xBuilder
->weld_button("change"))
837 , m_xRemoveButton(m_xBuilder
->weld_button("delete"))
838 , m_xGroupLBox(new CuiConfigGroupListBox(m_xBuilder
->weld_tree_view("category")))
839 , m_xFunctionBox(new CuiConfigFunctionListBox(m_xBuilder
->weld_tree_view("function")))
840 , m_xKeyBox(m_xBuilder
->weld_tree_view("keys"))
841 , m_xSearchEdit(m_xBuilder
->weld_entry("searchEntry"))
842 , m_xLoadButton(m_xBuilder
->weld_button("load"))
843 , m_xSaveButton(m_xBuilder
->weld_button("save"))
844 , m_xResetButton(m_xBuilder
->weld_button("reset"))
846 Size
aSize(LogicToPixel(Size(174, 100), MapMode(MapUnit::MapAppFont
)));
847 m_xEntriesBox
->set_size_request(aSize
.Width(), aSize
.Height());
848 aSize
= LogicToPixel(Size(78 , 91), MapMode(MapUnit::MapAppFont
));
849 m_xGroupLBox
->set_size_request(aSize
.Width(), aSize
.Height());
850 aSize
= LogicToPixel(Size(88, 91), MapMode(MapUnit::MapAppFont
));
851 m_xFunctionBox
->set_size_request(aSize
.Width(), aSize
.Height());
852 aSize
= LogicToPixel(Size(80, 91), MapMode(MapUnit::MapAppFont
));
853 m_xKeyBox
->set_size_request(aSize
.Width(), aSize
.Height());
855 aFilterAllStr
= SfxResId( STR_SFX_FILTERNAME_ALL
);
857 // install handler functions
858 m_xChangeButton
->connect_clicked( LINK( this, SfxAcceleratorConfigPage
, ChangeHdl
));
859 m_xRemoveButton
->connect_clicked( LINK( this, SfxAcceleratorConfigPage
, RemoveHdl
));
860 m_xEntriesBox
->connect_changed ( LINK( this, SfxAcceleratorConfigPage
, SelectHdl
));
861 m_xEntriesBox
->connect_key_press( LINK( this, SfxAcceleratorConfigPage
, KeyInputHdl
));
862 m_xGroupLBox
->connect_changed ( LINK( this, SfxAcceleratorConfigPage
, SelectHdl
));
863 m_xFunctionBox
->connect_changed( LINK( this, SfxAcceleratorConfigPage
, SelectHdl
));
864 m_xKeyBox
->connect_changed ( LINK( this, SfxAcceleratorConfigPage
, SelectHdl
));
865 m_xLoadButton
->connect_clicked ( LINK( this, SfxAcceleratorConfigPage
, Load
));
866 m_xSaveButton
->connect_clicked ( LINK( this, SfxAcceleratorConfigPage
, Save
));
867 m_xResetButton
->connect_clicked ( LINK( this, SfxAcceleratorConfigPage
, Default
));
868 m_xOfficeButton
->connect_clicked( LINK( this, SfxAcceleratorConfigPage
, RadioHdl
));
869 m_xModuleButton
->connect_clicked( LINK( this, SfxAcceleratorConfigPage
, RadioHdl
));
870 m_xSearchEdit
->connect_changed( LINK( this, SfxAcceleratorConfigPage
, SearchUpdateHdl
));
871 m_xSearchEdit
->connect_focus_out(LINK(this, SfxAcceleratorConfigPage
, FocusOut_Impl
));
873 // detect max keyname width
875 for (unsigned short i
: KEYCODE_ARRAY
)
877 int nTmp
= m_xEntriesBox
->get_pixel_size(vcl::KeyCode(i
).GetName()).Width();
878 if ( nTmp
> nMaxWidth
)
882 auto nNewTab
= nMaxWidth
+ 5; // additional space
884 // initialize Entriesbox
885 std::vector
<int> aWidths
;
886 aWidths
.push_back(nNewTab
);
887 m_xEntriesBox
->set_column_fixed_widths(aWidths
);
889 //Initialize search util
890 m_options
.AlgorithmType2
= util::SearchAlgorithms2::ABSOLUTE
;
891 m_options
.transliterateFlags
|= TransliterationFlags::IGNORE_CASE
;
892 m_options
.searchFlag
|= (util::SearchFlags::REG_NOT_BEGINOFLINE
|
893 util::SearchFlags::REG_NOT_ENDOFLINE
);
894 // initialize GroupBox
895 m_xGroupLBox
->SetFunctionListBox(m_xFunctionBox
.get());
898 m_xKeyBox
->make_sorted();
900 m_aUpdateDataTimer
.SetInvokeHandler(LINK(this, SfxAcceleratorConfigPage
, ImplUpdateDataHdl
));
901 m_aUpdateDataTimer
.SetDebugName( "SfxAcceleratorConfigPage UpdateDataTimer" );
902 m_aUpdateDataTimer
.SetTimeout(EDIT_UPDATEDATA_TIMEOUT
);
904 m_aFillGroupIdle
.SetInvokeHandler(LINK(this, SfxAcceleratorConfigPage
, TimeOut_Impl
));
905 m_aFillGroupIdle
.SetPriority(TaskPriority::HIGHEST
);
906 m_aFillGroupIdle
.SetDebugName("SfxAcceleratorConfigPage m_aFillGroupIdle");
909 SfxAcceleratorConfigPage::~SfxAcceleratorConfigPage()
914 void SfxAcceleratorConfigPage::dispose()
916 m_aFillGroupIdle
.Stop();
918 // free memory - remove all dynamic user data
919 for (int i
= 0, nCount
= m_xEntriesBox
->n_children(); i
< nCount
; ++i
)
921 TAccInfo
* pUserData
= reinterpret_cast<TAccInfo
*>(m_xEntriesBox
->get_id(i
).toInt64());
925 SfxTabPage::dispose();
928 void SfxAcceleratorConfigPage::InitAccCfg()
930 // already initialized ?
932 return; // yes -> do nothing
936 // no - initialize this instance
937 m_xContext
= comphelper::getProcessComponentContext();
939 m_xUICmdDescription
= frame::theUICommandDescription::get(m_xContext
);
941 // get the current active frame, which should be our "parent"
943 m_xFrame
= GetFrame();
944 if ( !m_xFrame
.is() )
946 uno::Reference
<frame::XDesktop2
> xDesktop
= frame::Desktop::create( m_xContext
);
947 m_xFrame
= xDesktop
->getActiveFrame();
951 uno::Reference
<frame::XModuleManager2
> xModuleManager
=
952 frame::ModuleManager::create(m_xContext
);
953 m_sModuleLongName
= xModuleManager
->identify(m_xFrame
);
954 comphelper::SequenceAsHashMap
lModuleProps(xModuleManager
->getByName(m_sModuleLongName
));
955 m_sModuleUIName
= lModuleProps
.getUnpackedValueOrDefault("ooSetupFactoryUIName", OUString());
957 // get global accelerator configuration
958 m_xGlobal
= css::ui::GlobalAcceleratorConfiguration::create(m_xContext
);
960 // get module accelerator configuration
962 uno::Reference
<ui::XModuleUIConfigurationManagerSupplier
> xModuleCfgSupplier(
963 ui::theModuleUIConfigurationManagerSupplier::get(m_xContext
));
964 uno::Reference
<ui::XUIConfigurationManager
> xUICfgManager
=
965 xModuleCfgSupplier
->getUIConfigurationManager(m_sModuleLongName
);
966 m_xModule
= xUICfgManager
->getShortCutManager();
968 catch(const uno::RuntimeException
&)
972 catch(const uno::Exception
&)
978 void SfxAcceleratorConfigPage::Init(const uno::Reference
<ui::XAcceleratorConfiguration
>& xAccMgr
)
983 if (!m_bStylesInfoInitialized
)
985 uno::Reference
<frame::XController
> xController
;
986 uno::Reference
<frame::XModel
> xModel
;
988 xController
= m_xFrame
->getController();
989 if (xController
.is())
990 xModel
= xController
->getModel();
992 m_aStylesInfo
.init(m_sModuleLongName
, xModel
);
993 m_xGroupLBox
->SetStylesInfo(&m_aStylesInfo
);
994 m_bStylesInfoInitialized
= true;
997 // Insert all editable accelerators into list box. It is possible
998 // that some accelerators are not mapped on the current system/keyboard
999 // but we don't want to lose these mappings.
1000 for (sal_Int32 i1
= 0; i1
< KEYCODE_ARRAY_SIZE
; ++i1
)
1002 vcl::KeyCode aKey
= KEYCODE_ARRAY
[i1
];
1003 OUString sKey
= aKey
.GetName();
1006 TAccInfo
* pEntry
= new TAccInfo(i1
, 0/*nListPos*/, aKey
);
1007 m_xEntriesBox
->append(OUString::number(reinterpret_cast<sal_Int64
>(pEntry
)), sKey
);
1008 int nPos
= m_xEntriesBox
->n_children() - 1;
1009 m_xEntriesBox
->set_text(nPos
, OUString(), 1);
1010 m_xEntriesBox
->set_sensitive(nPos
, true);
1013 // Assign all commands to its shortcuts - reading the accelerator config.
1014 uno::Sequence
<awt::KeyEvent
> lKeys
= xAccMgr
->getAllKeyEvents();
1015 sal_Int32 c2
= lKeys
.getLength();
1018 for (i2
=0; i2
<c2
; ++i2
)
1020 const awt::KeyEvent
& aAWTKey
= lKeys
[i2
];
1021 OUString sCommand
= xAccMgr
->getCommandByKeyEvent(aAWTKey
);
1022 OUString sLabel
= GetLabel4Command(sCommand
);
1023 vcl::KeyCode aKeyCode
= svt::AcceleratorExecute::st_AWTKey2VCLKey(aAWTKey
);
1024 sal_Int32 nPos
= MapKeyCodeToPos(aKeyCode
);
1029 m_xEntriesBox
->set_text(nPos
, sLabel
, 1);
1031 TAccInfo
* pEntry
= reinterpret_cast<TAccInfo
*>(m_xEntriesBox
->get_id(nPos
).toInt64());
1032 pEntry
->m_bIsConfigurable
= true;
1034 pEntry
->m_sCommand
= sCommand
;
1037 // Map the VCL hardcoded key codes and mark them as not changeable
1038 sal_uLong c3
= Application::GetReservedKeyCodeCount();
1040 for (i3
= 0; i3
< c3
; ++i3
)
1042 const vcl::KeyCode
* pKeyCode
= Application::GetReservedKeyCode(i3
);
1043 sal_Int32 nPos
= MapKeyCodeToPos(*pKeyCode
);
1048 // Hardcoded function mapped so no ID possible and mark entry as not changeable
1049 TAccInfo
* pEntry
= reinterpret_cast<TAccInfo
*>(m_xEntriesBox
->get_id(nPos
).toInt64());
1050 pEntry
->m_bIsConfigurable
= false;
1052 m_xEntriesBox
->set_sensitive(nPos
, false);
1056 void SfxAcceleratorConfigPage::Apply(const uno::Reference
<ui::XAcceleratorConfiguration
>& xAccMgr
)
1061 // Go through the list from the bottom to the top ...
1062 // because logical accelerator must be preferred instead of
1064 for (int i
= 0, nCount
= m_xEntriesBox
->n_children(); i
< nCount
; ++i
)
1066 TAccInfo
* pUserData
= reinterpret_cast<TAccInfo
*>(m_xEntriesBox
->get_id(i
).toInt64());
1068 awt::KeyEvent aAWTKey
;
1072 sCommand
= pUserData
->m_sCommand
;
1073 aAWTKey
= svt::AcceleratorExecute::st_VCLKey2AWTKey(pUserData
->m_aKey
);
1078 if (!sCommand
.isEmpty())
1079 xAccMgr
->setKeyEvent(aAWTKey
, sCommand
);
1081 xAccMgr
->removeKeyEvent(aAWTKey
);
1083 catch (const uno::RuntimeException
&)
1087 catch (const uno::Exception
&)
1093 void SfxAcceleratorConfigPage::ResetConfig()
1095 m_xEntriesBox
->clear();
1098 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, ImplUpdateDataHdl
, Timer
*, void)
1100 SelectHdl(m_xGroupLBox
->get_widget());
1103 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, SearchUpdateHdl
, weld::Entry
&, void)
1105 m_aUpdateDataTimer
.Start();
1108 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, FocusOut_Impl
, weld::Widget
&, void)
1110 if (m_aUpdateDataTimer
.IsActive())
1112 m_aUpdateDataTimer
.Stop();
1113 m_aUpdateDataTimer
.Invoke();
1117 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, Load
, weld::Button
&, void)
1119 // ask for filename, where we should load the new config data from
1120 StartFileDialog( StartFileDialogType::Open
, aLoadAccelConfigStr
);
1123 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, Save
, weld::Button
&, void)
1125 StartFileDialog( StartFileDialogType::SaveAs
, aSaveAccelConfigStr
);
1128 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, Default
, weld::Button
&, void)
1130 uno::Reference
<form::XReset
> xReset(m_xAct
, uno::UNO_QUERY
);
1134 m_xEntriesBox
->freeze();
1137 m_xEntriesBox
->thaw();
1138 m_xEntriesBox
->select(0);
1139 SelectHdl(*m_xEntriesBox
);
1142 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, ChangeHdl
, weld::Button
&, void)
1144 int nPos
= m_xEntriesBox
->get_selected_index();
1148 TAccInfo
* pEntry
= reinterpret_cast<TAccInfo
*>(m_xEntriesBox
->get_id(nPos
).toInt64());
1149 OUString sNewCommand
= m_xFunctionBox
->GetCurCommand();
1150 OUString sLabel
= m_xFunctionBox
->GetCurLabel();
1151 if (sLabel
.isEmpty())
1152 sLabel
= GetLabel4Command(sNewCommand
);
1154 pEntry
->m_sCommand
= sNewCommand
;
1155 m_xEntriesBox
->set_text(nPos
, sLabel
, 1);
1157 SelectHdl(m_xFunctionBox
->get_widget());
1160 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, RemoveHdl
, weld::Button
&, void)
1162 // get selected entry
1163 int nPos
= m_xEntriesBox
->get_selected_index();
1167 TAccInfo
* pEntry
= reinterpret_cast<TAccInfo
*>(m_xEntriesBox
->get_id(nPos
).toInt64());
1169 // remove function name from selected entry
1170 m_xEntriesBox
->set_text(nPos
, OUString(), 1);
1171 pEntry
->m_sCommand
.clear();
1173 SelectHdl(m_xFunctionBox
->get_widget());
1176 IMPL_LINK(SfxAcceleratorConfigPage
, SelectHdl
, weld::TreeView
&, rListBox
, void)
1179 Help::ShowBalloon( this, Point(), ::tools::Rectangle(), OUString() );
1180 if (&rListBox
== m_xEntriesBox
.get())
1182 TAccInfo
* pEntry
= reinterpret_cast<TAccInfo
*>(m_xEntriesBox
->get_selected_id().toInt64());
1184 OUString sPossibleNewCommand
= m_xFunctionBox
->GetCurCommand();
1186 m_xRemoveButton
->set_sensitive( false );
1187 m_xChangeButton
->set_sensitive( false );
1189 if (pEntry
->m_bIsConfigurable
)
1191 if (pEntry
->isConfigured())
1192 m_xRemoveButton
->set_sensitive(true);
1193 m_xChangeButton
->set_sensitive( pEntry
->m_sCommand
!= sPossibleNewCommand
);
1196 else if (&rListBox
== &m_xGroupLBox
->get_widget())
1198 m_xGroupLBox
->GroupSelected();
1200 // Pause redraw (Do not redraw at each removal)
1201 m_xFunctionBox
->freeze();
1202 // Apply the search filter to the functions list
1203 OUString
aSearchTerm(m_xSearchEdit
->get_text());
1204 int nMatchFound
= applySearchFilter(aSearchTerm
);
1206 m_xFunctionBox
->thaw();
1207 if (nMatchFound
!= -1)
1209 m_xFunctionBox
->select(nMatchFound
);
1210 SelectHdl(m_xFunctionBox
->get_widget());
1215 m_xChangeButton
->set_sensitive(false);
1218 else if (&rListBox
== &m_xFunctionBox
->get_widget())
1220 m_xRemoveButton
->set_sensitive( false );
1221 m_xChangeButton
->set_sensitive( false );
1223 // #i36994 First selected can return zero!
1224 TAccInfo
* pEntry
= reinterpret_cast<TAccInfo
*>(m_xEntriesBox
->get_selected_id().toInt64());
1227 OUString sPossibleNewCommand
= m_xFunctionBox
->GetCurCommand();
1229 if (pEntry
->m_bIsConfigurable
)
1231 if (pEntry
->isConfigured())
1232 m_xRemoveButton
->set_sensitive(true);
1233 m_xChangeButton
->set_sensitive( pEntry
->m_sCommand
!= sPossibleNewCommand
);
1238 for (int i
= 0, nCount
= m_xEntriesBox
->n_children(); i
< nCount
; ++i
)
1240 TAccInfo
* pUserData
= reinterpret_cast<TAccInfo
*>(m_xEntriesBox
->get_id(i
).toInt64());
1241 if (pUserData
&& pUserData
->m_sCommand
== sPossibleNewCommand
)
1243 m_xKeyBox
->append(OUString::number(reinterpret_cast<sal_Int64
>(pUserData
)), pUserData
->m_aKey
.GetName());
1250 // goto selected "key" entry of the key box
1252 TAccInfo
* pU2
= reinterpret_cast<TAccInfo
*>(m_xKeyBox
->get_selected_id().toInt64());
1254 nP2
= MapKeyCodeToPos(pU2
->m_aKey
);
1257 m_xEntriesBox
->select(nP2
);
1258 m_xEntriesBox
->scroll_to_row(nP2
);
1259 SelectHdl(*m_xEntriesBox
);
1264 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, RadioHdl
, weld::Button
&, void)
1266 uno::Reference
<ui::XAcceleratorConfiguration
> xOld
= m_xAct
;
1268 if (m_xOfficeButton
->get_active())
1270 else if (m_xModuleButton
->get_active())
1273 // nothing changed? => do nothing!
1274 if ( m_xAct
.is() && ( xOld
== m_xAct
) )
1277 m_xEntriesBox
->freeze();
1280 m_xEntriesBox
->thaw();
1282 m_xGroupLBox
->Init(m_xContext
, m_xFrame
, m_sModuleLongName
, true);
1284 // pb: #133213# do not select NULL entries
1285 if (m_xEntriesBox
->n_children())
1286 m_xEntriesBox
->select(0);
1288 m_aFillGroupIdle
.Start();
1291 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, TimeOut_Impl
, Timer
*, void)
1293 // activating the selection, typically "all commands", can take a long time
1294 // -> show wait cursor and disable input
1295 weld::WaitObject
aWaitObject(GetDialogFrameWeld());
1297 weld::TreeView
& rTreeView
= m_xGroupLBox
->get_widget();
1298 SelectHdl(rTreeView
);
1301 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, LoadHdl
, sfx2::FileDialogHelper
*, void)
1306 if ( ERRCODE_NONE
== m_pFileDlg
->GetError() )
1307 sCfgName
= m_pFileDlg
->GetPath();
1309 if ( sCfgName
.isEmpty() )
1312 weld::WaitObject
aWaitObject(GetDialogFrameWeld());
1314 uno::Reference
<ui::XUIConfigurationManager
> xCfgMgr
;
1315 uno::Reference
<embed::XStorage
> xRootStorage
; // we must hold the root storage alive, if xCfgMgr is used!
1319 // don't forget to release the storage afterwards!
1320 uno::Reference
<lang::XSingleServiceFactory
> xStorageFactory(embed::StorageFactory::create(m_xContext
));
1321 uno::Sequence
<uno::Any
> lArgs(2);
1322 lArgs
[0] <<= sCfgName
;
1323 lArgs
[1] <<= css::embed::ElementModes::READ
;
1325 xRootStorage
.set(xStorageFactory
->createInstanceWithArguments(lArgs
), uno::UNO_QUERY_THROW
);
1326 uno::Reference
<embed::XStorage
> xUIConfig
= xRootStorage
->openStorageElement(FOLDERNAME_UICONFIG
, embed::ElementModes::READ
);
1329 uno::Reference
<ui::XUIConfigurationManager2
> xCfgMgr2
= ui::UIConfigurationManager::create(m_xContext
);
1330 xCfgMgr2
->setStorage(xUIConfig
);
1331 xCfgMgr
.set(xCfgMgr2
, uno::UNO_QUERY_THROW
);
1336 // open the configuration and update our UI
1337 uno::Reference
<ui::XAcceleratorConfiguration
> xTempAccMgr(xCfgMgr
->getShortCutManager(), uno::UNO_SET_THROW
);
1339 m_xEntriesBox
->freeze();
1342 m_xEntriesBox
->thaw();
1343 if (m_xEntriesBox
->n_children())
1345 m_xEntriesBox
->select(0);
1346 SelectHdl(m_xFunctionBox
->get_widget());
1350 // don't forget to close the new opened storage!
1351 // We are the owner of it.
1352 if (xRootStorage
.is())
1354 uno::Reference
<lang::XComponent
> xComponent
;
1355 xComponent
.set(xCfgMgr
, uno::UNO_QUERY
);
1356 if (xComponent
.is())
1357 xComponent
->dispose();
1358 xComponent
.set(xRootStorage
, uno::UNO_QUERY
);
1359 if (xComponent
.is())
1360 xComponent
->dispose();
1363 catch(const uno::RuntimeException
&)
1367 catch(const uno::Exception
&)
1371 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, SaveHdl
, sfx2::FileDialogHelper
*, void)
1376 if ( ERRCODE_NONE
== m_pFileDlg
->GetError() )
1377 sCfgName
= m_pFileDlg
->GetPath();
1379 if ( sCfgName
.isEmpty() )
1382 weld::WaitObject
aWaitObject(GetDialogFrameWeld());
1384 uno::Reference
<embed::XStorage
> xRootStorage
;
1388 uno::Reference
<lang::XSingleServiceFactory
> xStorageFactory(embed::StorageFactory::create(m_xContext
));
1389 uno::Sequence
<uno::Any
> lArgs(2);
1390 lArgs
[0] <<= sCfgName
;
1391 lArgs
[1] <<= embed::ElementModes::WRITE
;
1393 xRootStorage
.set( xStorageFactory
->createInstanceWithArguments(lArgs
),
1394 uno::UNO_QUERY_THROW
);
1396 uno::Reference
<embed::XStorage
> xUIConfig(
1397 xRootStorage
->openStorageElement(FOLDERNAME_UICONFIG
, embed::ElementModes::WRITE
),
1398 uno::UNO_SET_THROW
);
1399 uno::Reference
<beans::XPropertySet
> xUIConfigProps(
1401 uno::UNO_QUERY_THROW
);
1403 // set the correct media type if the storage was new created
1404 OUString sMediaType
;
1405 xUIConfigProps
->getPropertyValue(MEDIATYPE_PROPNAME
) >>= sMediaType
;
1406 if (sMediaType
.isEmpty())
1407 xUIConfigProps
->setPropertyValue(MEDIATYPE_PROPNAME
, uno::Any(OUString("application/vnd.sun.xml.ui.configuration")));
1409 uno::Reference
<ui::XUIConfigurationManager2
> xCfgMgr
= ui::UIConfigurationManager::create(m_xContext
);
1410 xCfgMgr
->setStorage(xUIConfig
);
1412 // get the target configuration access and update with all shortcuts
1413 // which are set currently at the UI!
1414 // Don't copy the m_xAct content to it... because m_xAct will be updated
1415 // from the UI on pressing the button "OK" only. And inbetween it's not up to date!
1416 uno::Reference
<ui::XAcceleratorConfiguration
> xTargetAccMgr(xCfgMgr
->getShortCutManager(), uno::UNO_SET_THROW
);
1417 Apply(xTargetAccMgr
);
1419 // commit (order is important!)
1420 uno::Reference
<ui::XUIConfigurationPersistence
> xCommit1(xTargetAccMgr
, uno::UNO_QUERY_THROW
);
1421 uno::Reference
<ui::XUIConfigurationPersistence
> xCommit2(xCfgMgr
, uno::UNO_QUERY_THROW
);
1425 if (xRootStorage
.is())
1427 // Commit root storage
1428 uno::Reference
<embed::XTransactedObject
> xCommit3(xRootStorage
, uno::UNO_QUERY_THROW
);
1432 if (xRootStorage
.is())
1434 uno::Reference
<lang::XComponent
> xComponent(xCfgMgr
, uno::UNO_QUERY
);
1435 if (xComponent
.is())
1436 xComponent
->dispose();
1437 xComponent
.set(xRootStorage
, uno::UNO_QUERY
);
1438 if (xComponent
.is())
1439 xComponent
->dispose();
1442 catch(const uno::RuntimeException
&)
1446 catch(const uno::Exception
&)
1450 void SfxAcceleratorConfigPage::StartFileDialog( StartFileDialogType nType
, const OUString
& rTitle
)
1452 bool bSave
= nType
== StartFileDialogType::SaveAs
;
1453 short nDialogType
= bSave
? ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION
1454 : ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE
;
1455 m_pFileDlg
.reset(new sfx2::FileDialogHelper(nDialogType
, FileDialogFlags::NONE
, GetFrameWeld()));
1457 m_pFileDlg
->SetTitle( rTitle
);
1458 m_pFileDlg
->AddFilter( aFilterAllStr
, FILEDIALOG_FILTER_ALL
);
1459 m_pFileDlg
->AddFilter( aFilterCfgStr
, "*.cfg" );
1460 m_pFileDlg
->SetCurrentFilter( aFilterCfgStr
);
1462 Link
<sfx2::FileDialogHelper
*,void> aDlgClosedLink
= bSave
? LINK( this, SfxAcceleratorConfigPage
, SaveHdl
)
1463 : LINK( this, SfxAcceleratorConfigPage
, LoadHdl
);
1464 m_pFileDlg
->StartExecuteModal( aDlgClosedLink
);
1468 bool SfxAcceleratorConfigPage::FillItemSet( SfxItemSet
* )
1475 catch(const uno::RuntimeException
&)
1479 catch(const uno::Exception
&)
1488 void SfxAcceleratorConfigPage::Reset( const SfxItemSet
* rSet
)
1490 // open accelerator configs
1491 // Note: It initialize some other members too, which are needed here ...
1492 // e.g. m_sModuleUIName!
1495 // change the description of the radio button, which switch to the module
1496 // dependent accelerator configuration
1497 OUString sButtonText
= m_xModuleButton
->get_label();
1498 sButtonText
= m_xModuleButton
->strip_mnemonic(sButtonText
).replaceFirst("$(MODULE)", m_sModuleUIName
);
1499 m_xModuleButton
->set_label(sButtonText
);
1502 m_xModuleButton
->set_active(true);
1505 m_xModuleButton
->hide();
1506 m_xOfficeButton
->set_active(true);
1509 RadioHdl(*m_xOfficeButton
);
1511 const SfxPoolItem
* pMacroItem
=nullptr;
1512 if( SfxItemState::SET
== rSet
->GetItemState( SID_MACROINFO
, true, &pMacroItem
) )
1514 m_pMacroInfoItem
= &dynamic_cast<const SfxMacroInfoItem
&>(*pMacroItem
);
1515 m_xGroupLBox
->SelectMacro( m_pMacroInfoItem
);
1519 sal_Int32
SfxAcceleratorConfigPage::MapKeyCodeToPos(const vcl::KeyCode
& aKey
) const
1521 sal_uInt16 nCode1
= aKey
.GetCode() + aKey
.GetModifier();
1522 for (int i
= 0, nCount
= m_xEntriesBox
->n_children(); i
< nCount
; ++i
)
1524 TAccInfo
* pUserData
= reinterpret_cast<TAccInfo
*>(m_xEntriesBox
->get_id(i
).toInt64());
1527 sal_uInt16 nCode2
= pUserData
->m_aKey
.GetCode()+pUserData
->m_aKey
.GetModifier();
1528 if (nCode1
== nCode2
)
1537 OUString
SfxAcceleratorConfigPage::GetLabel4Command(const OUString
& sCommand
)
1541 // check global command configuration first
1542 uno::Reference
<container::XNameAccess
> xModuleConf
;
1543 m_xUICmdDescription
->getByName(m_sModuleLongName
) >>= xModuleConf
;
1544 if (xModuleConf
.is())
1546 ::comphelper::SequenceAsHashMap
lProps(xModuleConf
->getByName(sCommand
));
1547 OUString sLabel
= lProps
.getUnpackedValueOrDefault("Name", OUString());
1548 if (!sLabel
.isEmpty())
1552 catch(const uno::RuntimeException
&)
1556 catch(const uno::Exception
&)
1559 // may be it's a style URL .. they must be handled special
1560 SfxStyleInfo_Impl aStyle
;
1561 aStyle
.sCommand
= sCommand
;
1562 if (SfxStylesInfo_Impl::parseStyleCommand(aStyle
))
1564 m_aStylesInfo
.getLabel4Style(aStyle
);
1565 return aStyle
.sLabel
;
1572 * Remove entries which doesn't contain the search term
1574 int SfxAcceleratorConfigPage::applySearchFilter(OUString
const & rSearchTerm
)
1576 if (rSearchTerm
.isEmpty())
1579 m_options
.searchString
= rSearchTerm
;
1580 utl::TextSearch
textSearch( m_options
);
1582 for (int i
= m_xFunctionBox
->n_children(); i
> 0; --i
)
1585 OUString aStr
= m_xFunctionBox
->get_text(nEntry
);
1586 sal_Int32 aStartPos
= 0;
1587 sal_Int32 aEndPos
= aStr
.getLength();
1589 if (!textSearch
.SearchForward( aStr
, &aStartPos
, &aEndPos
))
1590 m_xFunctionBox
->remove(nEntry
);
1593 return m_xFunctionBox
->n_children() ? 0 : -1;
1596 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */