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/filedlghelper.hxx>
28 #include <sfx2/minfitem.hxx>
29 #include <sfx2/sfxresid.hxx>
31 #include <sal/macros.h>
32 #include <vcl/event.hxx>
34 #include <strings.hrc>
35 #include <sfx2/strings.hrc>
36 #include <svx/svxids.hrc>
39 // include interface declarations
40 #include <com/sun/star/beans/XPropertySet.hpp>
41 #include <com/sun/star/embed/StorageFactory.hpp>
42 #include <com/sun/star/embed/XTransactedObject.hpp>
43 #include <com/sun/star/embed/ElementModes.hpp>
44 #include <com/sun/star/form/XReset.hpp>
45 #include <com/sun/star/frame/Desktop.hpp>
46 #include <com/sun/star/frame/XController.hpp>
47 #include <com/sun/star/frame/XModel.hpp>
48 #include <com/sun/star/frame/ModuleManager.hpp>
49 #include <com/sun/star/frame/theUICommandDescription.hpp>
50 #include <com/sun/star/ui/GlobalAcceleratorConfiguration.hpp>
51 #include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
52 #include <com/sun/star/ui/UIConfigurationManager.hpp>
53 #include <com/sun/star/ui/XUIConfigurationManager.hpp>
54 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
56 // include search util
57 #include <com/sun/star/util/SearchFlags.hpp>
58 #include <com/sun/star/util/SearchAlgorithms2.hpp>
59 #include <unotools/textsearch.hxx>
61 // include other projects
62 #include <comphelper/processfactory.hxx>
63 #include <svtools/acceleratorexecute.hxx>
64 #include <vcl/svapp.hxx>
65 #include <vcl/help.hxx>
66 #include <comphelper/sequenceashashmap.hxx>
71 static const char FOLDERNAME_UICONFIG
[] = "Configurations2";
73 static const char MEDIATYPE_PROPNAME
[] = "MediaType";
75 static const sal_uInt16 KEYCODE_ARRAY
[] =
138 KEY_SHIFT
| KEY_DOWN
,
140 KEY_SHIFT
| KEY_LEFT
,
141 KEY_SHIFT
| KEY_RIGHT
,
142 KEY_SHIFT
| KEY_HOME
,
144 KEY_SHIFT
| KEY_PAGEUP
,
145 KEY_SHIFT
| KEY_PAGEDOWN
,
146 KEY_SHIFT
| KEY_RETURN
,
147 KEY_SHIFT
| KEY_SPACE
,
148 KEY_SHIFT
| KEY_ESCAPE
,
149 KEY_SHIFT
| KEY_BACKSPACE
,
150 KEY_SHIFT
| KEY_INSERT
,
151 KEY_SHIFT
| KEY_DELETE
,
152 KEY_SHIFT
| KEY_EQUAL
,
190 KEY_MOD1
| KEY_SEMICOLON
,
191 KEY_MOD1
| KEY_QUOTERIGHT
,
192 KEY_MOD1
| KEY_BRACKETLEFT
,
193 KEY_MOD1
| KEY_BRACKETRIGHT
,
194 KEY_MOD1
| KEY_POINT
,
195 KEY_MOD1
| KEY_COMMA
,
196 KEY_MOD1
| KEY_TILDE
,
219 KEY_MOD1
| KEY_RIGHT
,
222 KEY_MOD1
| KEY_PAGEUP
,
223 KEY_MOD1
| KEY_PAGEDOWN
,
224 KEY_MOD1
| KEY_RETURN
,
225 KEY_MOD1
| KEY_SPACE
,
226 KEY_MOD1
| KEY_BACKSPACE
,
227 KEY_MOD1
| KEY_INSERT
,
228 KEY_MOD1
| KEY_DELETE
,
231 KEY_MOD1
| KEY_SUBTRACT
,
232 KEY_MOD1
| KEY_MULTIPLY
,
233 KEY_MOD1
| KEY_DIVIDE
,
234 KEY_MOD1
| KEY_EQUAL
,
236 KEY_SHIFT
| KEY_MOD1
| KEY_0
,
237 KEY_SHIFT
| KEY_MOD1
| KEY_1
,
238 KEY_SHIFT
| KEY_MOD1
| KEY_2
,
239 KEY_SHIFT
| KEY_MOD1
| KEY_3
,
240 KEY_SHIFT
| KEY_MOD1
| KEY_4
,
241 KEY_SHIFT
| KEY_MOD1
| KEY_5
,
242 KEY_SHIFT
| KEY_MOD1
| KEY_6
,
243 KEY_SHIFT
| KEY_MOD1
| KEY_7
,
244 KEY_SHIFT
| KEY_MOD1
| KEY_8
,
245 KEY_SHIFT
| KEY_MOD1
| KEY_9
,
246 KEY_SHIFT
| KEY_MOD1
| KEY_A
,
247 KEY_SHIFT
| KEY_MOD1
| KEY_B
,
248 KEY_SHIFT
| KEY_MOD1
| KEY_C
,
249 KEY_SHIFT
| KEY_MOD1
| KEY_D
,
250 KEY_SHIFT
| KEY_MOD1
| KEY_E
,
251 KEY_SHIFT
| KEY_MOD1
| KEY_F
,
252 KEY_SHIFT
| KEY_MOD1
| KEY_G
,
253 KEY_SHIFT
| KEY_MOD1
| KEY_H
,
254 KEY_SHIFT
| KEY_MOD1
| KEY_I
,
255 KEY_SHIFT
| KEY_MOD1
| KEY_J
,
256 KEY_SHIFT
| KEY_MOD1
| KEY_K
,
257 KEY_SHIFT
| KEY_MOD1
| KEY_L
,
258 KEY_SHIFT
| KEY_MOD1
| KEY_M
,
259 KEY_SHIFT
| KEY_MOD1
| KEY_N
,
260 KEY_SHIFT
| KEY_MOD1
| KEY_O
,
261 KEY_SHIFT
| KEY_MOD1
| KEY_P
,
262 KEY_SHIFT
| KEY_MOD1
| KEY_Q
,
263 KEY_SHIFT
| KEY_MOD1
| KEY_R
,
264 KEY_SHIFT
| KEY_MOD1
| KEY_S
,
265 KEY_SHIFT
| KEY_MOD1
| KEY_T
,
266 KEY_SHIFT
| KEY_MOD1
| KEY_U
,
267 KEY_SHIFT
| KEY_MOD1
| KEY_V
,
268 KEY_SHIFT
| KEY_MOD1
| KEY_W
,
269 KEY_SHIFT
| KEY_MOD1
| KEY_X
,
270 KEY_SHIFT
| KEY_MOD1
| KEY_Y
,
271 KEY_SHIFT
| KEY_MOD1
| KEY_Z
,
272 KEY_SHIFT
| KEY_MOD1
| KEY_SEMICOLON
,
273 KEY_SHIFT
| KEY_MOD1
| KEY_QUOTERIGHT
,
274 KEY_SHIFT
| KEY_MOD1
| KEY_BRACKETLEFT
,
275 KEY_SHIFT
| KEY_MOD1
| KEY_BRACKETRIGHT
,
276 KEY_SHIFT
| KEY_MOD1
| KEY_POINT
,
277 KEY_SHIFT
| KEY_MOD1
| KEY_COMMA
,
278 KEY_SHIFT
| KEY_MOD1
| KEY_TILDE
,
279 KEY_SHIFT
| KEY_MOD1
| KEY_TAB
,
281 KEY_SHIFT
| KEY_MOD1
| KEY_F1
,
282 KEY_SHIFT
| KEY_MOD1
| KEY_F2
,
283 KEY_SHIFT
| KEY_MOD1
| KEY_F3
,
284 KEY_SHIFT
| KEY_MOD1
| KEY_F4
,
285 KEY_SHIFT
| KEY_MOD1
| KEY_F5
,
286 KEY_SHIFT
| KEY_MOD1
| KEY_F6
,
287 KEY_SHIFT
| KEY_MOD1
| KEY_F7
,
288 KEY_SHIFT
| KEY_MOD1
| KEY_F8
,
289 KEY_SHIFT
| KEY_MOD1
| KEY_F9
,
290 KEY_SHIFT
| KEY_MOD1
| KEY_F10
,
291 KEY_SHIFT
| KEY_MOD1
| KEY_F11
,
292 KEY_SHIFT
| KEY_MOD1
| KEY_F12
,
293 KEY_SHIFT
| KEY_MOD1
| KEY_F13
,
294 KEY_SHIFT
| KEY_MOD1
| KEY_F14
,
295 KEY_SHIFT
| KEY_MOD1
| KEY_F15
,
296 KEY_SHIFT
| KEY_MOD1
| KEY_F16
,
298 KEY_SHIFT
| KEY_MOD1
| KEY_DOWN
,
299 KEY_SHIFT
| KEY_MOD1
| KEY_UP
,
300 KEY_SHIFT
| KEY_MOD1
| KEY_LEFT
,
301 KEY_SHIFT
| KEY_MOD1
| KEY_RIGHT
,
302 KEY_SHIFT
| KEY_MOD1
| KEY_HOME
,
303 KEY_SHIFT
| KEY_MOD1
| KEY_END
,
304 KEY_SHIFT
| KEY_MOD1
| KEY_PAGEUP
,
305 KEY_SHIFT
| KEY_MOD1
| KEY_PAGEDOWN
,
306 KEY_SHIFT
| KEY_MOD1
| KEY_RETURN
,
307 KEY_SHIFT
| KEY_MOD1
| KEY_ESCAPE
,
308 KEY_SHIFT
| KEY_MOD1
| KEY_SPACE
,
309 KEY_SHIFT
| KEY_MOD1
| KEY_BACKSPACE
,
310 KEY_SHIFT
| KEY_MOD1
| KEY_INSERT
,
311 KEY_SHIFT
| KEY_MOD1
| KEY_DELETE
,
312 KEY_SHIFT
| KEY_MOD1
| KEY_EQUAL
,
350 KEY_MOD2
| KEY_SEMICOLON
,
351 KEY_MOD2
| KEY_QUOTERIGHT
,
352 KEY_MOD2
| KEY_BRACKETLEFT
,
353 KEY_MOD2
| KEY_BRACKETRIGHT
,
354 KEY_MOD2
| KEY_POINT
,
355 KEY_MOD2
| KEY_COMMA
,
356 KEY_MOD2
| KEY_TILDE
,
378 KEY_MOD2
| KEY_RIGHT
,
381 KEY_MOD2
| KEY_PAGEUP
,
382 KEY_MOD2
| KEY_PAGEDOWN
,
383 KEY_MOD2
| KEY_RETURN
,
384 KEY_MOD2
| KEY_SPACE
,
385 KEY_MOD2
| KEY_BACKSPACE
,
386 KEY_MOD2
| KEY_INSERT
,
387 KEY_MOD2
| KEY_DELETE
,
388 KEY_MOD2
| KEY_EQUAL
,
390 KEY_SHIFT
| KEY_MOD2
| KEY_0
,
391 KEY_SHIFT
| KEY_MOD2
| KEY_1
,
392 KEY_SHIFT
| KEY_MOD2
| KEY_2
,
393 KEY_SHIFT
| KEY_MOD2
| KEY_3
,
394 KEY_SHIFT
| KEY_MOD2
| KEY_4
,
395 KEY_SHIFT
| KEY_MOD2
| KEY_5
,
396 KEY_SHIFT
| KEY_MOD2
| KEY_6
,
397 KEY_SHIFT
| KEY_MOD2
| KEY_7
,
398 KEY_SHIFT
| KEY_MOD2
| KEY_8
,
399 KEY_SHIFT
| KEY_MOD2
| KEY_9
,
400 KEY_SHIFT
| KEY_MOD2
| KEY_A
,
401 KEY_SHIFT
| KEY_MOD2
| KEY_B
,
402 KEY_SHIFT
| KEY_MOD2
| KEY_C
,
403 KEY_SHIFT
| KEY_MOD2
| KEY_D
,
404 KEY_SHIFT
| KEY_MOD2
| KEY_E
,
405 KEY_SHIFT
| KEY_MOD2
| KEY_F
,
406 KEY_SHIFT
| KEY_MOD2
| KEY_G
,
407 KEY_SHIFT
| KEY_MOD2
| KEY_H
,
408 KEY_SHIFT
| KEY_MOD2
| KEY_I
,
409 KEY_SHIFT
| KEY_MOD2
| KEY_J
,
410 KEY_SHIFT
| KEY_MOD2
| KEY_K
,
411 KEY_SHIFT
| KEY_MOD2
| KEY_L
,
412 KEY_SHIFT
| KEY_MOD2
| KEY_M
,
413 KEY_SHIFT
| KEY_MOD2
| KEY_N
,
414 KEY_SHIFT
| KEY_MOD2
| KEY_O
,
415 KEY_SHIFT
| KEY_MOD2
| KEY_P
,
416 KEY_SHIFT
| KEY_MOD2
| KEY_Q
,
417 KEY_SHIFT
| KEY_MOD2
| KEY_R
,
418 KEY_SHIFT
| KEY_MOD2
| KEY_S
,
419 KEY_SHIFT
| KEY_MOD2
| KEY_T
,
420 KEY_SHIFT
| KEY_MOD2
| KEY_U
,
421 KEY_SHIFT
| KEY_MOD2
| KEY_V
,
422 KEY_SHIFT
| KEY_MOD2
| KEY_W
,
423 KEY_SHIFT
| KEY_MOD2
| KEY_X
,
424 KEY_SHIFT
| KEY_MOD2
| KEY_Y
,
425 KEY_SHIFT
| KEY_MOD2
| KEY_Z
,
426 KEY_SHIFT
| KEY_MOD2
| KEY_SEMICOLON
,
427 KEY_SHIFT
| KEY_MOD2
| KEY_QUOTERIGHT
,
428 KEY_SHIFT
| KEY_MOD2
| KEY_BRACKETLEFT
,
429 KEY_SHIFT
| KEY_MOD2
| KEY_BRACKETRIGHT
,
430 KEY_SHIFT
| KEY_MOD2
| KEY_POINT
,
431 KEY_SHIFT
| KEY_MOD2
| KEY_COMMA
,
432 KEY_SHIFT
| KEY_MOD2
| KEY_TILDE
,
434 KEY_SHIFT
| KEY_MOD2
| KEY_F1
,
435 KEY_SHIFT
| KEY_MOD2
| KEY_F2
,
436 KEY_SHIFT
| KEY_MOD2
| KEY_F3
,
437 KEY_SHIFT
| KEY_MOD2
| KEY_F4
,
438 KEY_SHIFT
| KEY_MOD2
| KEY_F5
,
439 KEY_SHIFT
| KEY_MOD2
| KEY_F6
,
440 KEY_SHIFT
| KEY_MOD2
| KEY_F7
,
441 KEY_SHIFT
| KEY_MOD2
| KEY_F8
,
442 KEY_SHIFT
| KEY_MOD2
| KEY_F9
,
443 KEY_SHIFT
| KEY_MOD2
| KEY_F10
,
444 KEY_SHIFT
| KEY_MOD2
| KEY_F11
,
445 KEY_SHIFT
| KEY_MOD2
| KEY_F12
,
446 KEY_SHIFT
| KEY_MOD2
| KEY_F13
,
447 KEY_SHIFT
| KEY_MOD2
| KEY_F14
,
448 KEY_SHIFT
| KEY_MOD2
| KEY_F15
,
449 KEY_SHIFT
| KEY_MOD2
| KEY_F16
,
451 KEY_SHIFT
| KEY_MOD2
| KEY_DOWN
,
452 KEY_SHIFT
| KEY_MOD2
| KEY_UP
,
453 KEY_SHIFT
| KEY_MOD2
| KEY_LEFT
,
454 KEY_SHIFT
| KEY_MOD2
| KEY_RIGHT
,
455 KEY_SHIFT
| KEY_MOD2
| KEY_HOME
,
456 KEY_SHIFT
| KEY_MOD2
| KEY_END
,
457 KEY_SHIFT
| KEY_MOD2
| KEY_PAGEUP
,
458 KEY_SHIFT
| KEY_MOD2
| KEY_PAGEDOWN
,
459 KEY_SHIFT
| KEY_MOD2
| KEY_RETURN
,
460 KEY_SHIFT
| KEY_MOD2
| KEY_ESCAPE
,
461 KEY_SHIFT
| KEY_MOD2
| KEY_SPACE
,
462 KEY_SHIFT
| KEY_MOD2
| KEY_BACKSPACE
,
463 KEY_SHIFT
| KEY_MOD2
| KEY_INSERT
,
464 KEY_SHIFT
| KEY_MOD2
| KEY_DELETE
,
465 KEY_SHIFT
| KEY_MOD2
| KEY_EQUAL
,
467 KEY_MOD1
| KEY_MOD2
| KEY_0
,
468 KEY_MOD1
| KEY_MOD2
| KEY_1
,
469 KEY_MOD1
| KEY_MOD2
| KEY_2
,
470 KEY_MOD1
| KEY_MOD2
| KEY_3
,
471 KEY_MOD1
| KEY_MOD2
| KEY_4
,
472 KEY_MOD1
| KEY_MOD2
| KEY_5
,
473 KEY_MOD1
| KEY_MOD2
| KEY_6
,
474 KEY_MOD1
| KEY_MOD2
| KEY_7
,
475 KEY_MOD1
| KEY_MOD2
| KEY_8
,
476 KEY_MOD1
| KEY_MOD2
| KEY_9
,
477 KEY_MOD1
| KEY_MOD2
| KEY_A
,
478 KEY_MOD1
| KEY_MOD2
| KEY_B
,
479 KEY_MOD1
| KEY_MOD2
| KEY_C
,
480 KEY_MOD1
| KEY_MOD2
| KEY_D
,
481 KEY_MOD1
| KEY_MOD2
| KEY_E
,
482 KEY_MOD1
| KEY_MOD2
| KEY_F
,
483 KEY_MOD1
| KEY_MOD2
| KEY_G
,
484 KEY_MOD1
| KEY_MOD2
| KEY_H
,
485 KEY_MOD1
| KEY_MOD2
| KEY_I
,
486 KEY_MOD1
| KEY_MOD2
| KEY_J
,
487 KEY_MOD1
| KEY_MOD2
| KEY_K
,
488 KEY_MOD1
| KEY_MOD2
| KEY_L
,
489 KEY_MOD1
| KEY_MOD2
| KEY_M
,
490 KEY_MOD1
| KEY_MOD2
| KEY_N
,
491 KEY_MOD1
| KEY_MOD2
| KEY_O
,
492 KEY_MOD1
| KEY_MOD2
| KEY_P
,
493 KEY_MOD1
| KEY_MOD2
| KEY_Q
,
494 KEY_MOD1
| KEY_MOD2
| KEY_R
,
495 KEY_MOD1
| KEY_MOD2
| KEY_S
,
496 KEY_MOD1
| KEY_MOD2
| KEY_T
,
497 KEY_MOD1
| KEY_MOD2
| KEY_U
,
498 KEY_MOD1
| KEY_MOD2
| KEY_V
,
499 KEY_MOD1
| KEY_MOD2
| KEY_W
,
500 KEY_MOD1
| KEY_MOD2
| KEY_X
,
501 KEY_MOD1
| KEY_MOD2
| KEY_Y
,
502 KEY_MOD1
| KEY_MOD2
| KEY_Z
,
503 KEY_MOD1
| KEY_MOD2
| KEY_SEMICOLON
,
504 KEY_MOD1
| KEY_MOD2
| KEY_QUOTERIGHT
,
505 KEY_MOD1
| KEY_MOD2
| KEY_BRACKETLEFT
,
506 KEY_MOD1
| KEY_MOD2
| KEY_BRACKETRIGHT
,
507 KEY_MOD1
| KEY_MOD2
| KEY_POINT
,
508 KEY_MOD1
| KEY_MOD2
| KEY_COMMA
,
509 KEY_MOD1
| KEY_MOD2
| KEY_TILDE
,
511 KEY_MOD1
| KEY_MOD2
| KEY_F1
,
512 KEY_MOD1
| KEY_MOD2
| KEY_F2
,
513 KEY_MOD1
| KEY_MOD2
| KEY_F3
,
514 KEY_MOD1
| KEY_MOD2
| KEY_F4
,
515 KEY_MOD1
| KEY_MOD2
| KEY_F5
,
516 KEY_MOD1
| KEY_MOD2
| KEY_F6
,
517 KEY_MOD1
| KEY_MOD2
| KEY_F7
,
518 KEY_MOD1
| KEY_MOD2
| KEY_F8
,
519 KEY_MOD1
| KEY_MOD2
| KEY_F9
,
520 KEY_MOD1
| KEY_MOD2
| KEY_F10
,
521 KEY_MOD1
| KEY_MOD2
| KEY_F11
,
522 KEY_MOD1
| KEY_MOD2
| KEY_F12
,
523 KEY_MOD1
| KEY_MOD2
| KEY_F13
,
524 KEY_MOD1
| KEY_MOD2
| KEY_F14
,
525 KEY_MOD1
| KEY_MOD2
| KEY_F15
,
526 KEY_MOD1
| KEY_MOD2
| KEY_F16
,
528 KEY_MOD1
| KEY_MOD2
| KEY_DOWN
,
529 KEY_MOD1
| KEY_MOD2
| KEY_UP
,
530 KEY_MOD1
| KEY_MOD2
| KEY_LEFT
,
531 KEY_MOD1
| KEY_MOD2
| KEY_RIGHT
,
532 KEY_MOD1
| KEY_MOD2
| KEY_HOME
,
533 KEY_MOD1
| KEY_MOD2
| KEY_END
,
534 KEY_MOD1
| KEY_MOD2
| KEY_PAGEUP
,
535 KEY_MOD1
| KEY_MOD2
| KEY_PAGEDOWN
,
536 KEY_MOD1
| KEY_MOD2
| KEY_RETURN
,
537 KEY_MOD1
| KEY_MOD2
| KEY_SPACE
,
538 KEY_MOD1
| KEY_MOD2
| KEY_BACKSPACE
,
539 KEY_MOD1
| KEY_MOD2
| KEY_INSERT
,
540 KEY_MOD1
| KEY_MOD2
| KEY_DELETE
,
542 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_0
,
543 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_1
,
544 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_2
,
545 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_3
,
546 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_4
,
547 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_5
,
548 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_6
,
549 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_7
,
550 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_8
,
551 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_9
,
552 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_A
,
553 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_B
,
554 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_C
,
555 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_D
,
556 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_E
,
557 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F
,
558 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_G
,
559 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_H
,
560 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_I
,
561 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_J
,
562 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_K
,
563 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_L
,
564 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_M
,
565 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_N
,
566 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_O
,
567 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_P
,
568 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_Q
,
569 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_R
,
570 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_S
,
571 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_T
,
572 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_U
,
573 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_V
,
574 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_W
,
575 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_X
,
576 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_Y
,
577 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_Z
,
578 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_SEMICOLON
,
579 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_QUOTERIGHT
,
580 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_BRACKETLEFT
,
581 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_BRACKETRIGHT
,
582 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_POINT
,
583 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_COMMA
,
584 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_TILDE
,
586 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F1
,
587 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F2
,
588 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F3
,
589 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F4
,
590 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F5
,
591 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F6
,
592 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F7
,
593 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F8
,
594 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F9
,
595 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F10
,
596 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F11
,
597 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F12
,
598 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F13
,
599 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F14
,
600 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F15
,
601 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_F16
,
603 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_DOWN
,
604 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_UP
,
605 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_LEFT
,
606 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_RIGHT
,
607 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_HOME
,
608 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_END
,
609 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_PAGEUP
,
610 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_PAGEDOWN
,
611 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_RETURN
,
612 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_SPACE
,
613 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_BACKSPACE
,
614 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_INSERT
,
615 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_DELETE
,
616 KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
| KEY_EQUAL
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
,
699 KEY_MOD3
| KEY_EQUAL
,
701 KEY_SHIFT
| KEY_MOD3
| KEY_0
,
702 KEY_SHIFT
| KEY_MOD3
| KEY_1
,
703 KEY_SHIFT
| KEY_MOD3
| KEY_2
,
704 KEY_SHIFT
| KEY_MOD3
| KEY_3
,
705 KEY_SHIFT
| KEY_MOD3
| KEY_4
,
706 KEY_SHIFT
| KEY_MOD3
| KEY_5
,
707 KEY_SHIFT
| KEY_MOD3
| KEY_6
,
708 KEY_SHIFT
| KEY_MOD3
| KEY_7
,
709 KEY_SHIFT
| KEY_MOD3
| KEY_8
,
710 KEY_SHIFT
| KEY_MOD3
| KEY_9
,
711 KEY_SHIFT
| KEY_MOD3
| KEY_A
,
712 KEY_SHIFT
| KEY_MOD3
| KEY_B
,
713 KEY_SHIFT
| KEY_MOD3
| KEY_C
,
714 KEY_SHIFT
| KEY_MOD3
| KEY_D
,
715 KEY_SHIFT
| KEY_MOD3
| KEY_E
,
716 KEY_SHIFT
| KEY_MOD3
| KEY_F
,
717 KEY_SHIFT
| KEY_MOD3
| KEY_G
,
718 KEY_SHIFT
| KEY_MOD3
| KEY_H
,
719 KEY_SHIFT
| KEY_MOD3
| KEY_I
,
720 KEY_SHIFT
| KEY_MOD3
| KEY_J
,
721 KEY_SHIFT
| KEY_MOD3
| KEY_K
,
722 KEY_SHIFT
| KEY_MOD3
| KEY_L
,
723 KEY_SHIFT
| KEY_MOD3
| KEY_M
,
724 KEY_SHIFT
| KEY_MOD3
| KEY_N
,
725 KEY_SHIFT
| KEY_MOD3
| KEY_O
,
726 KEY_SHIFT
| KEY_MOD3
| KEY_P
,
727 KEY_SHIFT
| KEY_MOD3
| KEY_Q
,
728 KEY_SHIFT
| KEY_MOD3
| KEY_R
,
729 KEY_SHIFT
| KEY_MOD3
| KEY_S
,
730 KEY_SHIFT
| KEY_MOD3
| KEY_T
,
731 KEY_SHIFT
| KEY_MOD3
| KEY_U
,
732 KEY_SHIFT
| KEY_MOD3
| KEY_V
,
733 KEY_SHIFT
| KEY_MOD3
| KEY_W
,
734 KEY_SHIFT
| KEY_MOD3
| KEY_X
,
735 KEY_SHIFT
| KEY_MOD3
| KEY_Y
,
736 KEY_SHIFT
| KEY_MOD3
| KEY_Z
,
737 KEY_SHIFT
| KEY_MOD3
| KEY_SEMICOLON
,
738 KEY_SHIFT
| KEY_MOD3
| KEY_QUOTERIGHT
,
739 KEY_SHIFT
| KEY_MOD3
| KEY_BRACKETLEFT
,
740 KEY_SHIFT
| KEY_MOD3
| KEY_BRACKETRIGHT
,
741 KEY_SHIFT
| KEY_MOD3
| KEY_POINT
,
742 KEY_SHIFT
| KEY_MOD3
| KEY_COMMA
,
743 KEY_SHIFT
| KEY_MOD3
| KEY_TILDE
,
744 KEY_SHIFT
| KEY_MOD3
| KEY_TAB
,
746 KEY_SHIFT
| KEY_MOD3
| KEY_F1
,
747 KEY_SHIFT
| KEY_MOD3
| KEY_F2
,
748 KEY_SHIFT
| KEY_MOD3
| KEY_F3
,
749 KEY_SHIFT
| KEY_MOD3
| KEY_F4
,
750 KEY_SHIFT
| KEY_MOD3
| KEY_F5
,
751 KEY_SHIFT
| KEY_MOD3
| KEY_F6
,
752 KEY_SHIFT
| KEY_MOD3
| KEY_F7
,
753 KEY_SHIFT
| KEY_MOD3
| KEY_F8
,
754 KEY_SHIFT
| KEY_MOD3
| KEY_F9
,
755 KEY_SHIFT
| KEY_MOD3
| KEY_F10
,
756 KEY_SHIFT
| KEY_MOD3
| KEY_F11
,
757 KEY_SHIFT
| KEY_MOD3
| KEY_F12
,
758 KEY_SHIFT
| KEY_MOD3
| KEY_F13
,
759 KEY_SHIFT
| KEY_MOD3
| KEY_F14
,
760 KEY_SHIFT
| KEY_MOD3
| KEY_F15
,
761 KEY_SHIFT
| KEY_MOD3
| KEY_F16
,
763 KEY_SHIFT
| KEY_MOD3
| KEY_DOWN
,
764 KEY_SHIFT
| KEY_MOD3
| KEY_UP
,
765 KEY_SHIFT
| KEY_MOD3
| KEY_LEFT
,
766 KEY_SHIFT
| KEY_MOD3
| KEY_RIGHT
,
767 KEY_SHIFT
| KEY_MOD3
| KEY_HOME
,
768 KEY_SHIFT
| KEY_MOD3
| KEY_END
,
769 KEY_SHIFT
| KEY_MOD3
| KEY_PAGEUP
,
770 KEY_SHIFT
| KEY_MOD3
| KEY_PAGEDOWN
,
771 KEY_SHIFT
| KEY_MOD3
| KEY_RETURN
,
772 KEY_SHIFT
| KEY_MOD3
| KEY_ESCAPE
,
773 KEY_SHIFT
| KEY_MOD3
| KEY_SPACE
,
774 KEY_SHIFT
| KEY_MOD3
| KEY_BACKSPACE
,
775 KEY_SHIFT
| KEY_MOD3
| KEY_INSERT
,
776 KEY_SHIFT
| KEY_MOD3
| KEY_DELETE
,
777 KEY_SHIFT
| KEY_MOD3
| KEY_EQUAL
781 static const sal_uInt16 KEYCODE_ARRAY_SIZE
= SAL_N_ELEMENTS(KEYCODE_ARRAY
);
783 /** select the entry, which match the current key input ... excepting
784 keys, which are used for the dialog itself.
786 IMPL_LINK(SfxAcceleratorConfigPage
, KeyInputHdl
, const KeyEvent
&, rKey
, bool)
788 vcl::KeyCode aCode1
= rKey
.GetKeyCode();
789 sal_uInt16 nCode1
= aCode1
.GetCode();
790 sal_uInt16 nMod1
= aCode1
.GetModifier();
792 // is it related to our list box ?
794 (nCode1
!= KEY_DOWN
) &&
795 (nCode1
!= KEY_UP
) &&
796 (nCode1
!= KEY_LEFT
) &&
797 (nCode1
!= KEY_RIGHT
) &&
798 (nCode1
!= KEY_PAGEUP
) &&
799 (nCode1
!= KEY_PAGEDOWN
)
802 for (int i
= 0, nCount
= m_xEntriesBox
->n_children(); i
< nCount
; ++i
)
804 TAccInfo
* pUserData
= reinterpret_cast<TAccInfo
*>(m_xEntriesBox
->get_id(i
).toInt64());
807 sal_uInt16 nCode2
= pUserData
->m_aKey
.GetCode();
808 sal_uInt16 nMod2
= pUserData
->m_aKey
.GetModifier();
810 if (nCode1
== nCode2
&& nMod1
== nMod2
)
812 m_xEntriesBox
->select(i
);
813 m_xEntriesBox
->scroll_to_row(i
);
820 // no - handle it as normal dialog input
824 SfxAcceleratorConfigPage::SfxAcceleratorConfigPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
& aSet
)
825 : SfxTabPage(pPage
, pController
, "cui/ui/accelconfigpage.ui", "AccelConfigPage", &aSet
)
827 , aLoadAccelConfigStr(CuiResId(RID_SVXSTR_LOADACCELCONFIG
))
828 , aSaveAccelConfigStr(CuiResId(RID_SVXSTR_SAVEACCELCONFIG
))
829 , aFilterAllStr(SfxResId(STR_SFX_FILTERNAME_ALL
))
830 , aFilterCfgStr(CuiResId(RID_SVXSTR_FILTERNAME_CFG
))
831 , m_bStylesInfoInitialized(false)
835 , m_aUpdateDataTimer("UpdateDataTimer")
836 , m_xEntriesBox(m_xBuilder
->weld_tree_view("shortcuts"))
837 , m_xOfficeButton(m_xBuilder
->weld_radio_button("office"))
838 , m_xModuleButton(m_xBuilder
->weld_radio_button("module"))
839 , m_xChangeButton(m_xBuilder
->weld_button("change"))
840 , m_xRemoveButton(m_xBuilder
->weld_button("delete"))
841 , m_xGroupLBox(new CuiConfigGroupListBox(m_xBuilder
->weld_tree_view("category")))
842 , m_xFunctionBox(new CuiConfigFunctionListBox(m_xBuilder
->weld_tree_view("function")))
843 , m_xKeyBox(m_xBuilder
->weld_tree_view("keys"))
844 , m_xSearchEdit(m_xBuilder
->weld_entry("searchEntry"))
845 , m_xLoadButton(m_xBuilder
->weld_button("load"))
846 , m_xSaveButton(m_xBuilder
->weld_button("save"))
847 , m_xResetButton(m_xBuilder
->weld_button("reset"))
849 Size
aSize(m_xEntriesBox
->get_approximate_digit_width() * 40,
850 m_xEntriesBox
->get_height_rows(12));
851 m_xEntriesBox
->set_size_request(aSize
.Width(), aSize
.Height());
852 aSize
= Size(m_xEntriesBox
->get_approximate_digit_width() * 19,
853 m_xEntriesBox
->get_height_rows(10));
854 m_xGroupLBox
->set_size_request(aSize
.Width(), aSize
.Height());
855 aSize
= Size(m_xEntriesBox
->get_approximate_digit_width() * 21,
856 m_xEntriesBox
->get_height_rows(10));
857 m_xFunctionBox
->set_size_request(aSize
.Width(), aSize
.Height());
858 aSize
= Size(m_xEntriesBox
->get_approximate_digit_width() * 20,
859 m_xEntriesBox
->get_height_rows(10));
860 m_xKeyBox
->set_size_request(aSize
.Width(), aSize
.Height());
862 // install handler functions
863 m_xChangeButton
->connect_clicked( LINK( this, SfxAcceleratorConfigPage
, ChangeHdl
));
864 m_xRemoveButton
->connect_clicked( LINK( this, SfxAcceleratorConfigPage
, RemoveHdl
));
865 m_xEntriesBox
->connect_changed ( LINK( this, SfxAcceleratorConfigPage
, SelectHdl
));
866 m_xEntriesBox
->connect_key_press( LINK( this, SfxAcceleratorConfigPage
, KeyInputHdl
));
867 m_xGroupLBox
->connect_changed ( LINK( this, SfxAcceleratorConfigPage
, SelectHdl
));
868 m_xFunctionBox
->connect_changed( LINK( this, SfxAcceleratorConfigPage
, SelectHdl
));
869 m_xKeyBox
->connect_changed ( LINK( this, SfxAcceleratorConfigPage
, SelectHdl
));
870 m_xLoadButton
->connect_clicked ( LINK( this, SfxAcceleratorConfigPage
, Load
));
871 m_xSaveButton
->connect_clicked ( LINK( this, SfxAcceleratorConfigPage
, Save
));
872 m_xResetButton
->connect_clicked ( LINK( this, SfxAcceleratorConfigPage
, Default
));
873 m_xOfficeButton
->connect_clicked( LINK( this, SfxAcceleratorConfigPage
, RadioHdl
));
874 m_xModuleButton
->connect_clicked( LINK( this, SfxAcceleratorConfigPage
, RadioHdl
));
875 m_xSearchEdit
->connect_changed( LINK( this, SfxAcceleratorConfigPage
, SearchUpdateHdl
));
876 m_xSearchEdit
->connect_focus_out(LINK(this, SfxAcceleratorConfigPage
, FocusOut_Impl
));
878 // detect max keyname width
880 for (unsigned short i
: KEYCODE_ARRAY
)
882 int nTmp
= m_xEntriesBox
->get_pixel_size(vcl::KeyCode(i
).GetName()).Width();
883 if ( nTmp
> nMaxWidth
)
887 auto nNewTab
= nMaxWidth
+ 5; // additional space
889 // initialize Entriesbox
890 std::vector
<int> aWidths
;
891 aWidths
.push_back(nNewTab
);
892 m_xEntriesBox
->set_column_fixed_widths(aWidths
);
894 //Initialize search util
895 m_options
.AlgorithmType2
= util::SearchAlgorithms2::ABSOLUTE
;
896 m_options
.transliterateFlags
|= TransliterationFlags::IGNORE_CASE
;
897 m_options
.searchFlag
|= (util::SearchFlags::REG_NOT_BEGINOFLINE
|
898 util::SearchFlags::REG_NOT_ENDOFLINE
);
899 // initialize GroupBox
900 m_xGroupLBox
->SetFunctionListBox(m_xFunctionBox
.get());
903 m_xKeyBox
->make_sorted();
905 m_aUpdateDataTimer
.SetInvokeHandler(LINK(this, SfxAcceleratorConfigPage
, ImplUpdateDataHdl
));
906 m_aUpdateDataTimer
.SetDebugName( "SfxAcceleratorConfigPage UpdateDataTimer" );
907 m_aUpdateDataTimer
.SetTimeout(EDIT_UPDATEDATA_TIMEOUT
);
909 m_aFillGroupIdle
.SetInvokeHandler(LINK(this, SfxAcceleratorConfigPage
, TimeOut_Impl
));
910 m_aFillGroupIdle
.SetPriority(TaskPriority::HIGHEST
);
911 m_aFillGroupIdle
.SetDebugName("SfxAcceleratorConfigPage m_aFillGroupIdle");
914 SfxAcceleratorConfigPage::~SfxAcceleratorConfigPage()
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());
926 void SfxAcceleratorConfigPage::InitAccCfg()
928 // already initialized ?
930 return; // yes -> do nothing
934 // no - initialize this instance
935 m_xContext
= comphelper::getProcessComponentContext();
937 m_xUICmdDescription
= frame::theUICommandDescription::get(m_xContext
);
939 // get the current active frame, which should be our "parent"
941 m_xFrame
= GetFrame();
942 if ( !m_xFrame
.is() )
944 uno::Reference
<frame::XDesktop2
> xDesktop
= frame::Desktop::create( m_xContext
);
945 m_xFrame
= xDesktop
->getActiveFrame();
949 uno::Reference
<frame::XModuleManager2
> xModuleManager
=
950 frame::ModuleManager::create(m_xContext
);
951 m_sModuleLongName
= xModuleManager
->identify(m_xFrame
);
952 comphelper::SequenceAsHashMap
lModuleProps(xModuleManager
->getByName(m_sModuleLongName
));
953 m_sModuleUIName
= lModuleProps
.getUnpackedValueOrDefault("ooSetupFactoryUIName", OUString());
955 // get global accelerator configuration
956 m_xGlobal
= css::ui::GlobalAcceleratorConfiguration::create(m_xContext
);
958 // get module accelerator configuration
960 uno::Reference
<ui::XModuleUIConfigurationManagerSupplier
> xModuleCfgSupplier(
961 ui::theModuleUIConfigurationManagerSupplier::get(m_xContext
));
962 uno::Reference
<ui::XUIConfigurationManager
> xUICfgManager
=
963 xModuleCfgSupplier
->getUIConfigurationManager(m_sModuleLongName
);
964 m_xModule
= xUICfgManager
->getShortCutManager();
966 catch(const uno::RuntimeException
&)
970 catch(const uno::Exception
&)
976 void SfxAcceleratorConfigPage::Init(const uno::Reference
<ui::XAcceleratorConfiguration
>& xAccMgr
)
981 if (!m_bStylesInfoInitialized
)
983 uno::Reference
<frame::XController
> xController
;
984 uno::Reference
<frame::XModel
> xModel
;
986 xController
= m_xFrame
->getController();
987 if (xController
.is())
988 xModel
= xController
->getModel();
990 m_aStylesInfo
.init(m_sModuleLongName
, xModel
);
991 m_xGroupLBox
->SetStylesInfo(&m_aStylesInfo
);
992 m_bStylesInfoInitialized
= true;
995 // Insert all editable accelerators into list box. It is possible
996 // that some accelerators are not mapped on the current system/keyboard
997 // but we don't want to lose these mappings.
998 for (sal_Int32 i1
= 0; i1
< KEYCODE_ARRAY_SIZE
; ++i1
)
1000 vcl::KeyCode aKey
= KEYCODE_ARRAY
[i1
];
1001 OUString sKey
= aKey
.GetName();
1004 TAccInfo
* pEntry
= new TAccInfo(i1
, 0/*nListPos*/, aKey
);
1005 m_xEntriesBox
->append(OUString::number(reinterpret_cast<sal_Int64
>(pEntry
)), sKey
);
1006 int nPos
= m_xEntriesBox
->n_children() - 1;
1007 m_xEntriesBox
->set_text(nPos
, OUString(), 1);
1008 m_xEntriesBox
->set_sensitive(nPos
, true);
1011 // Assign all commands to its shortcuts - reading the accelerator config.
1012 uno::Sequence
<awt::KeyEvent
> lKeys
= xAccMgr
->getAllKeyEvents();
1013 sal_Int32 c2
= lKeys
.getLength();
1016 for (i2
=0; i2
<c2
; ++i2
)
1018 const awt::KeyEvent
& aAWTKey
= lKeys
[i2
];
1019 OUString sCommand
= xAccMgr
->getCommandByKeyEvent(aAWTKey
);
1020 OUString sLabel
= GetLabel4Command(sCommand
);
1021 vcl::KeyCode aKeyCode
= svt::AcceleratorExecute::st_AWTKey2VCLKey(aAWTKey
);
1022 sal_Int32 nPos
= MapKeyCodeToPos(aKeyCode
);
1027 m_xEntriesBox
->set_text(nPos
, sLabel
, 1);
1029 TAccInfo
* pEntry
= reinterpret_cast<TAccInfo
*>(m_xEntriesBox
->get_id(nPos
).toInt64());
1030 pEntry
->m_bIsConfigurable
= true;
1032 pEntry
->m_sCommand
= sCommand
;
1035 // Map the VCL hardcoded key codes and mark them as not changeable
1036 sal_uLong c3
= Application::GetReservedKeyCodeCount();
1038 for (i3
= 0; i3
< c3
; ++i3
)
1040 const vcl::KeyCode
* pKeyCode
= Application::GetReservedKeyCode(i3
);
1041 sal_Int32 nPos
= MapKeyCodeToPos(*pKeyCode
);
1046 // Hardcoded function mapped so no ID possible and mark entry as not changeable
1047 TAccInfo
* pEntry
= reinterpret_cast<TAccInfo
*>(m_xEntriesBox
->get_id(nPos
).toInt64());
1048 pEntry
->m_bIsConfigurable
= false;
1050 m_xEntriesBox
->set_sensitive(nPos
, false);
1054 void SfxAcceleratorConfigPage::Apply(const uno::Reference
<ui::XAcceleratorConfiguration
>& xAccMgr
)
1059 // Go through the list from the bottom to the top ...
1060 // because logical accelerator must be preferred instead of
1062 for (int i
= 0, nCount
= m_xEntriesBox
->n_children(); i
< nCount
; ++i
)
1064 TAccInfo
* pUserData
= reinterpret_cast<TAccInfo
*>(m_xEntriesBox
->get_id(i
).toInt64());
1066 awt::KeyEvent aAWTKey
;
1070 sCommand
= pUserData
->m_sCommand
;
1071 aAWTKey
= svt::AcceleratorExecute::st_VCLKey2AWTKey(pUserData
->m_aKey
);
1076 if (!sCommand
.isEmpty())
1077 xAccMgr
->setKeyEvent(aAWTKey
, sCommand
);
1079 xAccMgr
->removeKeyEvent(aAWTKey
);
1081 catch (const uno::RuntimeException
&)
1085 catch (const uno::Exception
&)
1091 void SfxAcceleratorConfigPage::ResetConfig()
1093 m_xEntriesBox
->clear();
1096 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, ImplUpdateDataHdl
, Timer
*, void)
1098 SelectHdl(m_xGroupLBox
->get_widget());
1101 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, SearchUpdateHdl
, weld::Entry
&, void)
1103 m_aUpdateDataTimer
.Start();
1106 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, FocusOut_Impl
, weld::Widget
&, void)
1108 if (m_aUpdateDataTimer
.IsActive())
1110 m_aUpdateDataTimer
.Stop();
1111 m_aUpdateDataTimer
.Invoke();
1115 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, Load
, weld::Button
&, void)
1117 // ask for filename, where we should load the new config data from
1118 StartFileDialog( StartFileDialogType::Open
, aLoadAccelConfigStr
);
1121 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, Save
, weld::Button
&, void)
1123 StartFileDialog( StartFileDialogType::SaveAs
, aSaveAccelConfigStr
);
1126 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, Default
, weld::Button
&, void)
1128 uno::Reference
<form::XReset
> xReset(m_xAct
, uno::UNO_QUERY
);
1132 m_xEntriesBox
->freeze();
1135 m_xEntriesBox
->thaw();
1136 m_xEntriesBox
->select(0);
1137 SelectHdl(*m_xEntriesBox
);
1140 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, ChangeHdl
, weld::Button
&, void)
1142 int nPos
= m_xEntriesBox
->get_selected_index();
1146 TAccInfo
* pEntry
= reinterpret_cast<TAccInfo
*>(m_xEntriesBox
->get_id(nPos
).toInt64());
1147 OUString sNewCommand
= m_xFunctionBox
->GetCurCommand();
1148 OUString sLabel
= m_xFunctionBox
->GetCurLabel();
1149 if (sLabel
.isEmpty())
1150 sLabel
= GetLabel4Command(sNewCommand
);
1152 pEntry
->m_sCommand
= sNewCommand
;
1153 m_xEntriesBox
->set_text(nPos
, sLabel
, 1);
1155 SelectHdl(m_xFunctionBox
->get_widget());
1158 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, RemoveHdl
, weld::Button
&, void)
1160 // get selected entry
1161 int nPos
= m_xEntriesBox
->get_selected_index();
1165 TAccInfo
* pEntry
= reinterpret_cast<TAccInfo
*>(m_xEntriesBox
->get_id(nPos
).toInt64());
1167 // remove function name from selected entry
1168 m_xEntriesBox
->set_text(nPos
, OUString(), 1);
1169 pEntry
->m_sCommand
.clear();
1171 SelectHdl(m_xFunctionBox
->get_widget());
1174 IMPL_LINK(SfxAcceleratorConfigPage
, SelectHdl
, weld::TreeView
&, rListBox
, void)
1176 if (&rListBox
== m_xEntriesBox
.get())
1178 TAccInfo
* pEntry
= reinterpret_cast<TAccInfo
*>(m_xEntriesBox
->get_selected_id().toInt64());
1180 OUString sPossibleNewCommand
= m_xFunctionBox
->GetCurCommand();
1182 m_xRemoveButton
->set_sensitive( false );
1183 m_xChangeButton
->set_sensitive( false );
1185 if (pEntry
&& pEntry
->m_bIsConfigurable
)
1187 if (pEntry
->isConfigured())
1188 m_xRemoveButton
->set_sensitive(true);
1189 m_xChangeButton
->set_sensitive( pEntry
->m_sCommand
!= sPossibleNewCommand
);
1192 else if (&rListBox
== &m_xGroupLBox
->get_widget())
1194 m_xGroupLBox
->GroupSelected();
1196 // Pause redraw (Do not redraw at each removal)
1197 m_xFunctionBox
->freeze();
1198 // Apply the search filter to the functions list
1199 OUString
aSearchTerm(m_xSearchEdit
->get_text());
1200 int nMatchFound
= applySearchFilter(aSearchTerm
);
1202 m_xFunctionBox
->thaw();
1203 if (nMatchFound
!= -1)
1205 m_xFunctionBox
->select(nMatchFound
);
1206 SelectHdl(m_xFunctionBox
->get_widget());
1211 m_xChangeButton
->set_sensitive(false);
1214 else if (&rListBox
== &m_xFunctionBox
->get_widget())
1216 m_xRemoveButton
->set_sensitive( false );
1217 m_xChangeButton
->set_sensitive( false );
1219 // #i36994 First selected can return zero!
1220 TAccInfo
* pEntry
= reinterpret_cast<TAccInfo
*>(m_xEntriesBox
->get_selected_id().toInt64());
1223 OUString sPossibleNewCommand
= m_xFunctionBox
->GetCurCommand();
1225 if (pEntry
->m_bIsConfigurable
)
1227 if (pEntry
->isConfigured())
1228 m_xRemoveButton
->set_sensitive(true);
1229 m_xChangeButton
->set_sensitive( pEntry
->m_sCommand
!= sPossibleNewCommand
);
1234 for (int i
= 0, nCount
= m_xEntriesBox
->n_children(); i
< nCount
; ++i
)
1236 TAccInfo
* pUserData
= reinterpret_cast<TAccInfo
*>(m_xEntriesBox
->get_id(i
).toInt64());
1237 if (pUserData
&& pUserData
->m_sCommand
== sPossibleNewCommand
)
1239 m_xKeyBox
->append(OUString::number(reinterpret_cast<sal_Int64
>(pUserData
)), pUserData
->m_aKey
.GetName());
1246 // goto selected "key" entry of the key box
1248 TAccInfo
* pU2
= reinterpret_cast<TAccInfo
*>(m_xKeyBox
->get_selected_id().toInt64());
1250 nP2
= MapKeyCodeToPos(pU2
->m_aKey
);
1253 m_xEntriesBox
->select(nP2
);
1254 m_xEntriesBox
->scroll_to_row(nP2
);
1255 SelectHdl(*m_xEntriesBox
);
1260 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, RadioHdl
, weld::Button
&, void)
1262 uno::Reference
<ui::XAcceleratorConfiguration
> xOld
= m_xAct
;
1264 if (m_xOfficeButton
->get_active())
1266 else if (m_xModuleButton
->get_active())
1269 // nothing changed? => do nothing!
1270 if ( m_xAct
.is() && ( xOld
== m_xAct
) )
1273 m_xEntriesBox
->freeze();
1276 m_xEntriesBox
->thaw();
1278 m_xGroupLBox
->Init(m_xContext
, m_xFrame
, m_sModuleLongName
, true);
1280 // pb: #133213# do not select NULL entries
1281 if (m_xEntriesBox
->n_children())
1282 m_xEntriesBox
->select(0);
1284 m_aFillGroupIdle
.Start();
1287 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, TimeOut_Impl
, Timer
*, void)
1289 // activating the selection, typically "all commands", can take a long time
1290 // -> show wait cursor and disable input
1291 weld::WaitObject
aWaitObject(GetFrameWeld());
1293 weld::TreeView
& rTreeView
= m_xGroupLBox
->get_widget();
1294 SelectHdl(rTreeView
);
1297 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, LoadHdl
, sfx2::FileDialogHelper
*, void)
1302 if ( ERRCODE_NONE
== m_pFileDlg
->GetError() )
1303 sCfgName
= m_pFileDlg
->GetPath();
1305 if ( sCfgName
.isEmpty() )
1308 weld::WaitObject
aWaitObject(GetFrameWeld());
1310 uno::Reference
<ui::XUIConfigurationManager
> xCfgMgr
;
1311 uno::Reference
<embed::XStorage
> xRootStorage
; // we must hold the root storage alive, if xCfgMgr is used!
1315 // don't forget to release the storage afterwards!
1316 uno::Reference
<lang::XSingleServiceFactory
> xStorageFactory(embed::StorageFactory::create(m_xContext
));
1317 uno::Sequence
<uno::Any
> lArgs(2);
1318 lArgs
[0] <<= sCfgName
;
1319 lArgs
[1] <<= css::embed::ElementModes::READ
;
1321 xRootStorage
.set(xStorageFactory
->createInstanceWithArguments(lArgs
), uno::UNO_QUERY_THROW
);
1322 uno::Reference
<embed::XStorage
> xUIConfig
= xRootStorage
->openStorageElement(FOLDERNAME_UICONFIG
, embed::ElementModes::READ
);
1325 uno::Reference
<ui::XUIConfigurationManager2
> xCfgMgr2
= ui::UIConfigurationManager::create(m_xContext
);
1326 xCfgMgr2
->setStorage(xUIConfig
);
1327 xCfgMgr
.set(xCfgMgr2
, uno::UNO_QUERY_THROW
);
1332 // open the configuration and update our UI
1333 uno::Reference
<ui::XAcceleratorConfiguration
> xTempAccMgr(xCfgMgr
->getShortCutManager(), uno::UNO_SET_THROW
);
1335 m_xEntriesBox
->freeze();
1338 m_xEntriesBox
->thaw();
1339 if (m_xEntriesBox
->n_children())
1341 m_xEntriesBox
->select(0);
1342 SelectHdl(m_xFunctionBox
->get_widget());
1346 // don't forget to close the new opened storage!
1347 // We are the owner of it.
1348 if (xRootStorage
.is())
1350 uno::Reference
<lang::XComponent
> xComponent
;
1351 xComponent
.set(xCfgMgr
, uno::UNO_QUERY
);
1352 if (xComponent
.is())
1353 xComponent
->dispose();
1354 xRootStorage
->dispose();
1357 catch(const uno::RuntimeException
&)
1361 catch(const uno::Exception
&)
1365 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, SaveHdl
, sfx2::FileDialogHelper
*, void)
1370 if ( ERRCODE_NONE
== m_pFileDlg
->GetError() )
1371 sCfgName
= m_pFileDlg
->GetPath();
1373 if ( sCfgName
.isEmpty() )
1376 weld::WaitObject
aWaitObject(GetFrameWeld());
1378 uno::Reference
<embed::XStorage
> xRootStorage
;
1382 uno::Reference
<lang::XSingleServiceFactory
> xStorageFactory(embed::StorageFactory::create(m_xContext
));
1383 uno::Sequence
<uno::Any
> lArgs(2);
1384 lArgs
[0] <<= sCfgName
;
1385 lArgs
[1] <<= embed::ElementModes::WRITE
;
1387 xRootStorage
.set( xStorageFactory
->createInstanceWithArguments(lArgs
),
1388 uno::UNO_QUERY_THROW
);
1390 uno::Reference
<embed::XStorage
> xUIConfig(
1391 xRootStorage
->openStorageElement(FOLDERNAME_UICONFIG
, embed::ElementModes::WRITE
),
1392 uno::UNO_SET_THROW
);
1393 uno::Reference
<beans::XPropertySet
> xUIConfigProps(
1395 uno::UNO_QUERY_THROW
);
1397 // set the correct media type if the storage was new created
1398 OUString sMediaType
;
1399 xUIConfigProps
->getPropertyValue(MEDIATYPE_PROPNAME
) >>= sMediaType
;
1400 if (sMediaType
.isEmpty())
1401 xUIConfigProps
->setPropertyValue(MEDIATYPE_PROPNAME
, uno::Any(OUString("application/vnd.sun.xml.ui.configuration")));
1403 uno::Reference
<ui::XUIConfigurationManager2
> xCfgMgr
= ui::UIConfigurationManager::create(m_xContext
);
1404 xCfgMgr
->setStorage(xUIConfig
);
1406 // get the target configuration access and update with all shortcuts
1407 // which are set currently at the UI!
1408 // Don't copy the m_xAct content to it... because m_xAct will be updated
1409 // from the UI on pressing the button "OK" only. And inbetween it's not up to date!
1410 uno::Reference
<ui::XAcceleratorConfiguration
> xTargetAccMgr(xCfgMgr
->getShortCutManager(), uno::UNO_SET_THROW
);
1411 Apply(xTargetAccMgr
);
1413 // commit (order is important!)
1414 uno::Reference
<ui::XUIConfigurationPersistence
> xCommit1(xTargetAccMgr
, uno::UNO_QUERY_THROW
);
1415 uno::Reference
<ui::XUIConfigurationPersistence
> xCommit2(xCfgMgr
, uno::UNO_QUERY_THROW
);
1419 if (xRootStorage
.is())
1421 // Commit root storage
1422 uno::Reference
<embed::XTransactedObject
> xCommit3(xRootStorage
, uno::UNO_QUERY_THROW
);
1426 if (xRootStorage
.is())
1430 xRootStorage
->dispose();
1433 catch(const uno::RuntimeException
&)
1437 catch(const uno::Exception
&)
1441 void SfxAcceleratorConfigPage::StartFileDialog( StartFileDialogType nType
, const OUString
& rTitle
)
1443 bool bSave
= nType
== StartFileDialogType::SaveAs
;
1444 short nDialogType
= bSave
? ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION
1445 : ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE
;
1446 m_pFileDlg
.reset(new sfx2::FileDialogHelper(nDialogType
, FileDialogFlags::NONE
, GetFrameWeld()));
1448 m_pFileDlg
->SetTitle( rTitle
);
1449 m_pFileDlg
->AddFilter( aFilterAllStr
, FILEDIALOG_FILTER_ALL
);
1450 m_pFileDlg
->AddFilter( aFilterCfgStr
, "*.cfg" );
1451 m_pFileDlg
->SetCurrentFilter( aFilterCfgStr
);
1453 Link
<sfx2::FileDialogHelper
*,void> aDlgClosedLink
= bSave
? LINK( this, SfxAcceleratorConfigPage
, SaveHdl
)
1454 : LINK( this, SfxAcceleratorConfigPage
, LoadHdl
);
1455 m_pFileDlg
->StartExecuteModal( aDlgClosedLink
);
1459 bool SfxAcceleratorConfigPage::FillItemSet( SfxItemSet
* )
1466 catch(const uno::RuntimeException
&)
1470 catch(const uno::Exception
&)
1479 void SfxAcceleratorConfigPage::Reset( const SfxItemSet
* rSet
)
1481 // open accelerator configs
1482 // Note: It initialize some other members too, which are needed here ...
1483 // e.g. m_sModuleUIName!
1486 // change the description of the radio button, which switch to the module
1487 // dependent accelerator configuration
1488 OUString sButtonText
= m_xModuleButton
->get_label();
1489 sButtonText
= m_xModuleButton
->strip_mnemonic(sButtonText
).replaceFirst("$(MODULE)", m_sModuleUIName
);
1490 m_xModuleButton
->set_label(sButtonText
);
1493 m_xModuleButton
->set_active(true);
1496 m_xModuleButton
->hide();
1497 m_xOfficeButton
->set_active(true);
1500 RadioHdl(*m_xOfficeButton
);
1502 const SfxPoolItem
* pMacroItem
=nullptr;
1503 if( SfxItemState::SET
== rSet
->GetItemState( SID_MACROINFO
, true, &pMacroItem
) )
1505 m_pMacroInfoItem
= &dynamic_cast<const SfxMacroInfoItem
&>(*pMacroItem
);
1506 m_xGroupLBox
->SelectMacro( m_pMacroInfoItem
);
1510 sal_Int32
SfxAcceleratorConfigPage::MapKeyCodeToPos(const vcl::KeyCode
& aKey
) const
1512 sal_uInt16 nCode1
= aKey
.GetCode() + aKey
.GetModifier();
1513 for (int i
= 0, nCount
= m_xEntriesBox
->n_children(); i
< nCount
; ++i
)
1515 TAccInfo
* pUserData
= reinterpret_cast<TAccInfo
*>(m_xEntriesBox
->get_id(i
).toInt64());
1518 sal_uInt16 nCode2
= pUserData
->m_aKey
.GetCode()+pUserData
->m_aKey
.GetModifier();
1519 if (nCode1
== nCode2
)
1528 OUString
SfxAcceleratorConfigPage::GetLabel4Command(const OUString
& sCommand
)
1532 // check global command configuration first
1533 uno::Reference
<container::XNameAccess
> xModuleConf
;
1534 m_xUICmdDescription
->getByName(m_sModuleLongName
) >>= xModuleConf
;
1535 if (xModuleConf
.is())
1537 ::comphelper::SequenceAsHashMap
lProps(xModuleConf
->getByName(sCommand
));
1538 OUString sLabel
= lProps
.getUnpackedValueOrDefault("Name", OUString());
1539 if (!sLabel
.isEmpty())
1543 catch(const uno::RuntimeException
&)
1547 catch(const uno::Exception
&)
1550 // may be it's a style URL .. they must be handled special
1551 SfxStyleInfo_Impl aStyle
;
1552 aStyle
.sCommand
= sCommand
;
1553 if (SfxStylesInfo_Impl::parseStyleCommand(aStyle
))
1555 m_aStylesInfo
.getLabel4Style(aStyle
);
1556 return aStyle
.sLabel
;
1563 * Remove entries which doesn't contain the search term
1565 int SfxAcceleratorConfigPage::applySearchFilter(OUString
const & rSearchTerm
)
1567 if (rSearchTerm
.isEmpty())
1570 m_options
.searchString
= rSearchTerm
;
1571 utl::TextSearch
textSearch( m_options
);
1573 for (int i
= m_xFunctionBox
->n_children(); i
> 0; --i
)
1576 OUString aStr
= m_xFunctionBox
->get_text(nEntry
);
1577 sal_Int32 aStartPos
= 0;
1578 sal_Int32 aEndPos
= aStr
.getLength();
1580 if (!textSearch
.SearchForward( aStr
, &aStartPos
, &aEndPos
))
1581 m_xFunctionBox
->remove(nEntry
);
1584 return m_xFunctionBox
->n_children() ? 0 : -1;
1587 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */