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 .
20 //-----------------------------------------------
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>
33 #include "svtools/treelistentry.hxx"
35 #include <sal/macros.h>
40 #include <svx/svxids.hrc> // SID_CHARMAP, SID_ATTR_SPECIALCHAR
42 //-----------------------------------------------
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/XFramesSupplier.hpp>
51 #include <com/sun/star/frame/XFrame.hpp>
52 #include <com/sun/star/frame/XController.hpp>
53 #include <com/sun/star/frame/XModel.hpp>
54 #include <com/sun/star/frame/ModuleManager.hpp>
55 #include <com/sun/star/frame/UICommandDescription.hpp>
56 #include <com/sun/star/ui/GlobalAcceleratorConfiguration.hpp>
57 #include <com/sun/star/ui/ModuleUIConfigurationManagerSupplier.hpp>
58 #include <com/sun/star/ui/UIConfigurationManager.hpp>
59 #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
60 #include <com/sun/star/ui/XUIConfigurationManager.hpp>
61 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
63 //-----------------------------------------------
64 // include other projects
65 #include <comphelper/processfactory.hxx>
66 #include <svtools/acceleratorexecute.hxx>
67 #include <svtools/svlbitm.hxx>
68 #include <vcl/svapp.hxx>
69 #include <vcl/help.hxx>
70 #include <rtl/ustrbuf.hxx>
71 #include <comphelper/sequenceashashmap.hxx>
73 //-----------------------------------------------
76 using namespace com::sun::star
;
79 //-----------------------------------------------
81 static OUString
MODULEPROP_SHORTNAME ("ooSetupFactoryShortName" );
82 static OUString
MODULEPROP_UINAME ("ooSetupFactoryUIName" );
83 static OUString
CMDPROP_UINAME ("Name" );
85 static OUString
FOLDERNAME_UICONFIG ("Configurations2" );
87 static OUString
MEDIATYPE_PROPNAME ("MediaType" );
88 static OUString
MEDIATYPE_UICONFIG ("application/vnd.sun.xml.ui.configuration");
90 //-----------------------------------------------
91 static sal_uInt16 KEYCODE_ARRAY
[] =
154 KEY_DOWN
| KEY_SHIFT
,
156 KEY_LEFT
| KEY_SHIFT
,
157 KEY_RIGHT
| KEY_SHIFT
,
158 KEY_HOME
| KEY_SHIFT
,
160 KEY_PAGEUP
| KEY_SHIFT
,
161 KEY_PAGEDOWN
| KEY_SHIFT
,
162 KEY_RETURN
| KEY_SHIFT
,
163 KEY_SPACE
| KEY_SHIFT
,
164 KEY_ESCAPE
| KEY_SHIFT
,
165 KEY_BACKSPACE
| KEY_SHIFT
,
166 KEY_INSERT
| KEY_SHIFT
,
167 KEY_DELETE
| KEY_SHIFT
,
205 KEY_SEMICOLON
| KEY_MOD1
,
206 KEY_BRACKETLEFT
| KEY_MOD1
,
207 KEY_BRACKETRIGHT
| KEY_MOD1
,
208 KEY_POINT
| KEY_MOD1
,
227 KEY_DOWN
| KEY_MOD1
,
229 KEY_LEFT
| KEY_MOD1
,
230 KEY_RIGHT
| KEY_MOD1
,
231 KEY_HOME
| KEY_MOD1
,
233 KEY_PAGEUP
| KEY_MOD1
,
234 KEY_PAGEDOWN
| KEY_MOD1
,
235 KEY_RETURN
| KEY_MOD1
,
236 KEY_SPACE
| KEY_MOD1
,
237 KEY_BACKSPACE
| KEY_MOD1
,
238 KEY_INSERT
| KEY_MOD1
,
239 KEY_DELETE
| KEY_MOD1
,
242 KEY_SUBTRACT
| KEY_MOD1
,
243 KEY_MULTIPLY
| KEY_MOD1
,
244 KEY_DIVIDE
| KEY_MOD1
,
246 KEY_0
| KEY_SHIFT
| KEY_MOD1
,
247 KEY_1
| KEY_SHIFT
| KEY_MOD1
,
248 KEY_2
| KEY_SHIFT
| KEY_MOD1
,
249 KEY_3
| KEY_SHIFT
| KEY_MOD1
,
250 KEY_4
| KEY_SHIFT
| KEY_MOD1
,
251 KEY_5
| KEY_SHIFT
| KEY_MOD1
,
252 KEY_6
| KEY_SHIFT
| KEY_MOD1
,
253 KEY_7
| KEY_SHIFT
| KEY_MOD1
,
254 KEY_8
| KEY_SHIFT
| KEY_MOD1
,
255 KEY_9
| KEY_SHIFT
| KEY_MOD1
,
256 KEY_A
| KEY_SHIFT
| KEY_MOD1
,
257 KEY_B
| KEY_SHIFT
| KEY_MOD1
,
258 KEY_C
| KEY_SHIFT
| KEY_MOD1
,
259 KEY_D
| KEY_SHIFT
| KEY_MOD1
,
260 KEY_E
| KEY_SHIFT
| KEY_MOD1
,
261 KEY_F
| KEY_SHIFT
| KEY_MOD1
,
262 KEY_G
| KEY_SHIFT
| KEY_MOD1
,
263 KEY_H
| KEY_SHIFT
| KEY_MOD1
,
264 KEY_I
| KEY_SHIFT
| KEY_MOD1
,
265 KEY_J
| KEY_SHIFT
| KEY_MOD1
,
266 KEY_K
| KEY_SHIFT
| KEY_MOD1
,
267 KEY_L
| KEY_SHIFT
| KEY_MOD1
,
268 KEY_M
| KEY_SHIFT
| KEY_MOD1
,
269 KEY_N
| KEY_SHIFT
| KEY_MOD1
,
270 KEY_O
| KEY_SHIFT
| KEY_MOD1
,
271 KEY_P
| KEY_SHIFT
| KEY_MOD1
,
272 KEY_Q
| KEY_SHIFT
| KEY_MOD1
,
273 KEY_R
| KEY_SHIFT
| KEY_MOD1
,
274 KEY_S
| KEY_SHIFT
| KEY_MOD1
,
275 KEY_T
| KEY_SHIFT
| KEY_MOD1
,
276 KEY_U
| KEY_SHIFT
| KEY_MOD1
,
277 KEY_V
| KEY_SHIFT
| KEY_MOD1
,
278 KEY_W
| KEY_SHIFT
| KEY_MOD1
,
279 KEY_X
| KEY_SHIFT
| KEY_MOD1
,
280 KEY_Y
| KEY_SHIFT
| KEY_MOD1
,
281 KEY_Z
| KEY_SHIFT
| KEY_MOD1
,
282 KEY_SEMICOLON
| KEY_SHIFT
| KEY_MOD1
,
283 KEY_BRACKETLEFT
| KEY_SHIFT
| KEY_MOD1
,
284 KEY_BRACKETRIGHT
| KEY_SHIFT
| KEY_MOD1
,
285 KEY_POINT
| KEY_SHIFT
| KEY_MOD1
,
287 KEY_F1
| KEY_SHIFT
| KEY_MOD1
,
288 KEY_F2
| KEY_SHIFT
| KEY_MOD1
,
289 KEY_F3
| KEY_SHIFT
| KEY_MOD1
,
290 KEY_F4
| KEY_SHIFT
| KEY_MOD1
,
291 KEY_F5
| KEY_SHIFT
| KEY_MOD1
,
292 KEY_F6
| KEY_SHIFT
| KEY_MOD1
,
293 KEY_F7
| KEY_SHIFT
| KEY_MOD1
,
294 KEY_F8
| KEY_SHIFT
| KEY_MOD1
,
295 KEY_F9
| KEY_SHIFT
| KEY_MOD1
,
296 KEY_F10
| KEY_SHIFT
| KEY_MOD1
,
297 KEY_F11
| KEY_SHIFT
| KEY_MOD1
,
298 KEY_F12
| KEY_SHIFT
| KEY_MOD1
,
299 KEY_F13
| KEY_SHIFT
| KEY_MOD1
,
300 KEY_F14
| KEY_SHIFT
| KEY_MOD1
,
301 KEY_F15
| KEY_SHIFT
| KEY_MOD1
,
302 KEY_F16
| KEY_SHIFT
| KEY_MOD1
,
304 KEY_DOWN
| KEY_SHIFT
| KEY_MOD1
,
305 KEY_UP
| KEY_SHIFT
| KEY_MOD1
,
306 KEY_LEFT
| KEY_SHIFT
| KEY_MOD1
,
307 KEY_RIGHT
| KEY_SHIFT
| KEY_MOD1
,
308 KEY_HOME
| KEY_SHIFT
| KEY_MOD1
,
309 KEY_END
| KEY_SHIFT
| KEY_MOD1
,
310 KEY_PAGEUP
| KEY_SHIFT
| KEY_MOD1
,
311 KEY_PAGEDOWN
| KEY_SHIFT
| KEY_MOD1
,
312 KEY_RETURN
| KEY_SHIFT
| KEY_MOD1
,
313 KEY_SPACE
| KEY_SHIFT
| KEY_MOD1
,
314 KEY_BACKSPACE
| KEY_SHIFT
| KEY_MOD1
,
315 KEY_INSERT
| KEY_SHIFT
| KEY_MOD1
,
316 KEY_DELETE
| KEY_SHIFT
| KEY_MOD1
,
354 KEY_SEMICOLON
| KEY_MOD2
,
355 KEY_BRACKETLEFT
| KEY_MOD2
,
356 KEY_BRACKETRIGHT
| KEY_MOD2
,
357 KEY_POINT
| KEY_MOD2
,
376 KEY_DOWN
| KEY_MOD2
,
378 KEY_LEFT
| KEY_MOD2
,
379 KEY_RIGHT
| KEY_MOD2
,
380 KEY_HOME
| KEY_MOD2
,
382 KEY_PAGEUP
| KEY_MOD2
,
383 KEY_PAGEDOWN
| KEY_MOD2
,
384 KEY_RETURN
| KEY_MOD2
,
385 KEY_SPACE
| KEY_MOD2
,
386 KEY_BACKSPACE
| KEY_MOD2
,
387 KEY_INSERT
| KEY_MOD2
,
388 KEY_DELETE
| KEY_MOD2
,
390 KEY_0
| KEY_SHIFT
| KEY_MOD2
,
391 KEY_1
| KEY_SHIFT
| KEY_MOD2
,
392 KEY_2
| KEY_SHIFT
| KEY_MOD2
,
393 KEY_3
| KEY_SHIFT
| KEY_MOD2
,
394 KEY_4
| KEY_SHIFT
| KEY_MOD2
,
395 KEY_5
| KEY_SHIFT
| KEY_MOD2
,
396 KEY_6
| KEY_SHIFT
| KEY_MOD2
,
397 KEY_7
| KEY_SHIFT
| KEY_MOD2
,
398 KEY_8
| KEY_SHIFT
| KEY_MOD2
,
399 KEY_9
| KEY_SHIFT
| KEY_MOD2
,
400 KEY_A
| KEY_SHIFT
| KEY_MOD2
,
401 KEY_B
| KEY_SHIFT
| KEY_MOD2
,
402 KEY_C
| KEY_SHIFT
| KEY_MOD2
,
403 KEY_D
| KEY_SHIFT
| KEY_MOD2
,
404 KEY_E
| KEY_SHIFT
| KEY_MOD2
,
405 KEY_F
| KEY_SHIFT
| KEY_MOD2
,
406 KEY_G
| KEY_SHIFT
| KEY_MOD2
,
407 KEY_H
| KEY_SHIFT
| KEY_MOD2
,
408 KEY_I
| KEY_SHIFT
| KEY_MOD2
,
409 KEY_J
| KEY_SHIFT
| KEY_MOD2
,
410 KEY_K
| KEY_SHIFT
| KEY_MOD2
,
411 KEY_L
| KEY_SHIFT
| KEY_MOD2
,
412 KEY_M
| KEY_SHIFT
| KEY_MOD2
,
413 KEY_N
| KEY_SHIFT
| KEY_MOD2
,
414 KEY_O
| KEY_SHIFT
| KEY_MOD2
,
415 KEY_P
| KEY_SHIFT
| KEY_MOD2
,
416 KEY_Q
| KEY_SHIFT
| KEY_MOD2
,
417 KEY_R
| KEY_SHIFT
| KEY_MOD2
,
418 KEY_S
| KEY_SHIFT
| KEY_MOD2
,
419 KEY_T
| KEY_SHIFT
| KEY_MOD2
,
420 KEY_U
| KEY_SHIFT
| KEY_MOD2
,
421 KEY_V
| KEY_SHIFT
| KEY_MOD2
,
422 KEY_W
| KEY_SHIFT
| KEY_MOD2
,
423 KEY_X
| KEY_SHIFT
| KEY_MOD2
,
424 KEY_Y
| KEY_SHIFT
| KEY_MOD2
,
425 KEY_Z
| KEY_SHIFT
| KEY_MOD2
,
426 KEY_SEMICOLON
| KEY_SHIFT
| KEY_MOD2
,
427 KEY_BRACKETLEFT
| KEY_SHIFT
| KEY_MOD2
,
428 KEY_BRACKETRIGHT
| KEY_SHIFT
| KEY_MOD2
,
429 KEY_POINT
| KEY_SHIFT
| KEY_MOD2
,
431 KEY_F1
| KEY_SHIFT
| KEY_MOD2
,
432 KEY_F2
| KEY_SHIFT
| KEY_MOD2
,
433 KEY_F3
| KEY_SHIFT
| KEY_MOD2
,
434 KEY_F4
| KEY_SHIFT
| KEY_MOD2
,
435 KEY_F5
| KEY_SHIFT
| KEY_MOD2
,
436 KEY_F6
| KEY_SHIFT
| KEY_MOD2
,
437 KEY_F7
| KEY_SHIFT
| KEY_MOD2
,
438 KEY_F8
| KEY_SHIFT
| KEY_MOD2
,
439 KEY_F9
| KEY_SHIFT
| KEY_MOD2
,
440 KEY_F10
| KEY_SHIFT
| KEY_MOD2
,
441 KEY_F11
| KEY_SHIFT
| KEY_MOD2
,
442 KEY_F12
| KEY_SHIFT
| KEY_MOD2
,
443 KEY_F13
| KEY_SHIFT
| KEY_MOD2
,
444 KEY_F14
| KEY_SHIFT
| KEY_MOD2
,
445 KEY_F15
| KEY_SHIFT
| KEY_MOD2
,
446 KEY_F16
| KEY_SHIFT
| KEY_MOD2
,
448 KEY_DOWN
| KEY_SHIFT
| KEY_MOD2
,
449 KEY_UP
| KEY_SHIFT
| KEY_MOD2
,
450 KEY_LEFT
| KEY_SHIFT
| KEY_MOD2
,
451 KEY_RIGHT
| KEY_SHIFT
| KEY_MOD2
,
452 KEY_HOME
| KEY_SHIFT
| KEY_MOD2
,
453 KEY_END
| KEY_SHIFT
| KEY_MOD2
,
454 KEY_PAGEUP
| KEY_SHIFT
| KEY_MOD2
,
455 KEY_PAGEDOWN
| KEY_SHIFT
| KEY_MOD2
,
456 KEY_RETURN
| KEY_SHIFT
| KEY_MOD2
,
457 KEY_SPACE
| KEY_SHIFT
| KEY_MOD2
,
458 KEY_BACKSPACE
| KEY_SHIFT
| KEY_MOD2
,
459 KEY_INSERT
| KEY_SHIFT
| KEY_MOD2
,
460 KEY_DELETE
| KEY_SHIFT
| KEY_MOD2
,
462 KEY_0
| KEY_MOD1
| KEY_MOD2
,
463 KEY_1
| KEY_MOD1
| KEY_MOD2
,
464 KEY_2
| KEY_MOD1
| KEY_MOD2
,
465 KEY_3
| KEY_MOD1
| KEY_MOD2
,
466 KEY_4
| KEY_MOD1
| KEY_MOD2
,
467 KEY_5
| KEY_MOD1
| KEY_MOD2
,
468 KEY_6
| KEY_MOD1
| KEY_MOD2
,
469 KEY_7
| KEY_MOD1
| KEY_MOD2
,
470 KEY_8
| KEY_MOD1
| KEY_MOD2
,
471 KEY_9
| KEY_MOD1
| KEY_MOD2
,
472 KEY_A
| KEY_MOD1
| KEY_MOD2
,
473 KEY_B
| KEY_MOD1
| KEY_MOD2
,
474 KEY_C
| KEY_MOD1
| KEY_MOD2
,
475 KEY_D
| KEY_MOD1
| KEY_MOD2
,
476 KEY_E
| KEY_MOD1
| KEY_MOD2
,
477 KEY_F
| KEY_MOD1
| KEY_MOD2
,
478 KEY_G
| KEY_MOD1
| KEY_MOD2
,
479 KEY_H
| KEY_MOD1
| KEY_MOD2
,
480 KEY_I
| KEY_MOD1
| KEY_MOD2
,
481 KEY_J
| KEY_MOD1
| KEY_MOD2
,
482 KEY_K
| KEY_MOD1
| KEY_MOD2
,
483 KEY_L
| KEY_MOD1
| KEY_MOD2
,
484 KEY_M
| KEY_MOD1
| KEY_MOD2
,
485 KEY_N
| KEY_MOD1
| KEY_MOD2
,
486 KEY_O
| KEY_MOD1
| KEY_MOD2
,
487 KEY_P
| KEY_MOD1
| KEY_MOD2
,
488 KEY_Q
| KEY_MOD1
| KEY_MOD2
,
489 KEY_R
| KEY_MOD1
| KEY_MOD2
,
490 KEY_S
| KEY_MOD1
| KEY_MOD2
,
491 KEY_T
| KEY_MOD1
| KEY_MOD2
,
492 KEY_U
| KEY_MOD1
| KEY_MOD2
,
493 KEY_V
| KEY_MOD1
| KEY_MOD2
,
494 KEY_W
| KEY_MOD1
| KEY_MOD2
,
495 KEY_X
| KEY_MOD1
| KEY_MOD2
,
496 KEY_Y
| KEY_MOD1
| KEY_MOD2
,
497 KEY_Z
| KEY_MOD1
| KEY_MOD2
,
499 KEY_F1
| KEY_MOD1
| KEY_MOD2
,
500 KEY_F2
| KEY_MOD1
| KEY_MOD2
,
501 KEY_F3
| KEY_MOD1
| KEY_MOD2
,
502 KEY_F4
| KEY_MOD1
| KEY_MOD2
,
503 KEY_F5
| KEY_MOD1
| KEY_MOD2
,
504 KEY_F6
| KEY_MOD1
| KEY_MOD2
,
505 KEY_F7
| KEY_MOD1
| KEY_MOD2
,
506 KEY_F8
| KEY_MOD1
| KEY_MOD2
,
507 KEY_F9
| KEY_MOD1
| KEY_MOD2
,
508 KEY_F10
| KEY_MOD1
| KEY_MOD2
,
509 KEY_F11
| KEY_MOD1
| KEY_MOD2
,
510 KEY_F12
| KEY_MOD1
| KEY_MOD2
,
511 KEY_F13
| KEY_MOD1
| KEY_MOD2
,
512 KEY_F14
| KEY_MOD1
| KEY_MOD2
,
513 KEY_F15
| KEY_MOD1
| KEY_MOD2
,
514 KEY_F16
| KEY_MOD1
| KEY_MOD2
,
516 KEY_DOWN
| KEY_MOD1
| KEY_MOD2
,
517 KEY_UP
| KEY_MOD1
| KEY_MOD2
,
518 KEY_LEFT
| KEY_MOD1
| KEY_MOD2
,
519 KEY_RIGHT
| KEY_MOD1
| KEY_MOD2
,
520 KEY_HOME
| KEY_MOD1
| KEY_MOD2
,
521 KEY_END
| KEY_MOD1
| KEY_MOD2
,
522 KEY_PAGEUP
| KEY_MOD1
| KEY_MOD2
,
523 KEY_PAGEDOWN
| KEY_MOD1
| KEY_MOD2
,
524 KEY_RETURN
| KEY_MOD1
| KEY_MOD2
,
525 KEY_SPACE
| KEY_MOD1
| KEY_MOD2
,
526 KEY_BACKSPACE
| KEY_MOD1
| KEY_MOD2
,
527 KEY_INSERT
| KEY_MOD1
| KEY_MOD2
,
528 KEY_DELETE
| KEY_MOD1
| KEY_MOD2
,
530 KEY_0
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
531 KEY_1
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
532 KEY_2
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
533 KEY_3
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
534 KEY_4
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
535 KEY_5
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
536 KEY_6
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
537 KEY_7
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
538 KEY_8
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
539 KEY_9
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
540 KEY_A
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
541 KEY_B
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
542 KEY_C
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
543 KEY_D
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
544 KEY_E
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
545 KEY_F
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
546 KEY_G
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
547 KEY_H
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
548 KEY_I
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
549 KEY_J
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
550 KEY_K
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
551 KEY_L
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
552 KEY_M
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
553 KEY_N
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
554 KEY_O
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
555 KEY_P
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
556 KEY_Q
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
557 KEY_R
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
558 KEY_S
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
559 KEY_T
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
560 KEY_U
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
561 KEY_V
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
562 KEY_W
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
563 KEY_X
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
564 KEY_Y
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
565 KEY_Z
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
566 KEY_SEMICOLON
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
567 KEY_BRACKETLEFT
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
568 KEY_BRACKETRIGHT
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
569 KEY_POINT
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
571 KEY_F1
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
572 KEY_F2
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
573 KEY_F3
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
574 KEY_F4
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
575 KEY_F5
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
576 KEY_F6
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
577 KEY_F7
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
578 KEY_F8
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
579 KEY_F9
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
580 KEY_F10
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
581 KEY_F11
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
582 KEY_F12
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
583 KEY_F13
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
584 KEY_F14
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
585 KEY_F15
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
586 KEY_F16
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
588 KEY_DOWN
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
589 KEY_UP
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
590 KEY_LEFT
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
591 KEY_RIGHT
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
592 KEY_HOME
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
593 KEY_END
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
594 KEY_PAGEUP
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
595 KEY_PAGEDOWN
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
596 KEY_RETURN
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
597 KEY_SPACE
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
598 KEY_BACKSPACE
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
599 KEY_INSERT
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
600 KEY_DELETE
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
603 static sal_uInt16 KEYCODE_ARRAY_SIZE
= SAL_N_ELEMENTS(KEYCODE_ARRAY
);
605 //-----------------------------------------------
606 // seems to be needed to layout the list box, which shows all
607 // assignable shortcuts
608 static long AccCfgTabs
[] =
615 //-----------------------------------------------
616 class SfxAccCfgLBoxString_Impl
: public SvLBoxString
619 SfxAccCfgLBoxString_Impl( SvTreeListEntry
* pEntry
,
621 const String
& sText
);
623 virtual ~SfxAccCfgLBoxString_Impl();
626 const Point
& aPos
, SvTreeListBox
& rDevice
, const SvViewDataEntry
* pView
, const SvTreeListEntry
* pEntry
);
629 //-----------------------------------------------
630 SfxAccCfgLBoxString_Impl::SfxAccCfgLBoxString_Impl( SvTreeListEntry
* pEntry
,
632 const String
& sText
)
633 : SvLBoxString(pEntry
, nFlags
, sText
)
637 //-----------------------------------------------
638 SfxAccCfgLBoxString_Impl::~SfxAccCfgLBoxString_Impl()
642 void SfxAccCfgLBoxString_Impl::Paint(
643 const Point
& aPos
, SvTreeListBox
& rDevice
, const SvViewDataEntry
* /*pView*/, const SvTreeListEntry
* pEntry
)
648 TAccInfo
* pUserData
= (TAccInfo
*)pEntry
->GetUserData();
652 if (pUserData
->m_bIsConfigurable
)
653 rDevice
.DrawText(aPos
, GetText());
655 rDevice
.DrawCtrlText(aPos
, GetText(), 0, STRING_LEN
, TEXT_DRAW_DISABLE
);
659 //-----------------------------------------------
660 void SfxAccCfgTabListBox_Impl::InitEntry(SvTreeListEntry
* pEntry
,
661 const OUString
& rText
,
662 const Image
& rImage1
,
663 const Image
& rImage2
,
664 SvLBoxButtonKind eButtonKind
)
666 SvTabListBox::InitEntry(pEntry
, rText
, rImage1
, rImage2
, eButtonKind
);
669 //-----------------------------------------------
670 /** select the entry, which match the current key input ... excepting
671 keys, which are used for the dialog itself.
673 void SfxAccCfgTabListBox_Impl::KeyInput(const KeyEvent
& aKey
)
675 KeyCode aCode1
= aKey
.GetKeyCode();
676 sal_uInt16 nCode1
= aCode1
.GetCode();
677 sal_uInt16 nMod1
= aCode1
.GetModifier();
679 // is it related to our list box ?
681 (nCode1
!= KEY_DOWN
) &&
682 (nCode1
!= KEY_UP
) &&
683 (nCode1
!= KEY_LEFT
) &&
684 (nCode1
!= KEY_RIGHT
) &&
685 (nCode1
!= KEY_PAGEUP
) &&
686 (nCode1
!= KEY_PAGEDOWN
)
689 SvTreeListEntry
* pEntry
= First();
692 TAccInfo
* pUserData
= (TAccInfo
*)pEntry
->GetUserData();
695 sal_uInt16 nCode2
= pUserData
->m_aKey
.GetCode();
696 sal_uInt16 nMod2
= pUserData
->m_aKey
.GetModifier();
698 (nCode1
== nCode2
) &&
707 pEntry
= Next(pEntry
);
711 // no - handle it as normal dialog input
712 SvTabListBox::KeyInput(aKey
);
715 //-----------------------------------------------
716 SfxAcceleratorConfigPage::SfxAcceleratorConfigPage( Window
* pParent
, const SfxItemSet
& aSet
)
717 : SfxTabPage (pParent
, CUI_RES(RID_SVXPAGE_KEYBOARD
), aSet
)
718 , m_pMacroInfoItem ()
722 , aEntriesBox (this , this, CUI_RES(BOX_ACC_ENTRIES
))
723 , aKeyboardGroup (this , CUI_RES(GRP_ACC_KEYBOARD
))
724 , aOfficeButton (this , CUI_RES(RB_OFFICE
))
725 , aModuleButton (this , CUI_RES(RB_MODULE
))
726 , aChangeButton (this , CUI_RES(BTN_ACC_CHANGE
))
727 , aRemoveButton (this , CUI_RES(BTN_ACC_REMOVE
))
728 , aGroupText (this , CUI_RES(TXT_ACC_GROUP
))
729 , pGroupLBox(new SfxConfigGroupListBox_Impl( this, CUI_RES(BOX_ACC_GROUP
), SFX_SLOT_ACCELCONFIG
))
730 , aFunctionText (this , CUI_RES(TXT_ACC_FUNCTION
))
731 , pFunctionBox(new SfxConfigFunctionListBox_Impl( this, CUI_RES( BOX_ACC_FUNCTION
)))
732 , aKeyText (this , CUI_RES(TXT_ACC_KEY
))
733 , aKeyBox (this , CUI_RES(BOX_ACC_KEY
))
734 , aFunctionsGroup (this , CUI_RES(GRP_ACC_FUNCTIONS
))
735 , aLoadButton (this , CUI_RES(BTN_LOAD
))
736 , aSaveButton (this , CUI_RES(BTN_SAVE
))
737 , aResetButton (this , CUI_RES(BTN_RESET
))
738 , aLoadAccelConfigStr ( CUI_RES( STR_LOADACCELCONFIG
) )
739 , aSaveAccelConfigStr ( CUI_RES( STR_SAVEACCELCONFIG
) )
740 , aFilterCfgStr ( CUI_RES( STR_FILTERNAME_CFG
) )
741 , m_bStylesInfoInitialized(sal_False
)
748 aFilterAllStr
= String( SfxResId( STR_SFX_FILTERNAME_ALL
) );
750 // install handler functions
751 aChangeButton
.SetClickHdl( LINK( this, SfxAcceleratorConfigPage
, ChangeHdl
));
752 aRemoveButton
.SetClickHdl( LINK( this, SfxAcceleratorConfigPage
, RemoveHdl
));
753 aEntriesBox
.SetSelectHdl ( LINK( this, SfxAcceleratorConfigPage
, SelectHdl
));
754 pGroupLBox
->SetSelectHdl ( LINK( this, SfxAcceleratorConfigPage
, SelectHdl
));
755 pFunctionBox
->SetSelectHdl( LINK( this, SfxAcceleratorConfigPage
, SelectHdl
));
756 aKeyBox
.SetSelectHdl ( LINK( this, SfxAcceleratorConfigPage
, SelectHdl
));
757 aLoadButton
.SetClickHdl ( LINK( this, SfxAcceleratorConfigPage
, Load
));
758 aSaveButton
.SetClickHdl ( LINK( this, SfxAcceleratorConfigPage
, Save
));
759 aResetButton
.SetClickHdl ( LINK( this, SfxAcceleratorConfigPage
, Default
));
760 aOfficeButton
.SetClickHdl( LINK( this, SfxAcceleratorConfigPage
, RadioHdl
));
761 aModuleButton
.SetClickHdl( LINK( this, SfxAcceleratorConfigPage
, RadioHdl
));
763 // initialize Entriesbox
764 aEntriesBox
.SetStyle(aEntriesBox
.GetStyle()|WB_HSCROLL
|WB_CLIPCHILDREN
);
765 aEntriesBox
.SetSelectionMode(SINGLE_SELECTION
);
766 aEntriesBox
.SetTabs(&AccCfgTabs
[0], MAP_APPFONT
);
767 aEntriesBox
.Resize(); // OS: Hack for right selection
768 aEntriesBox
.SetSpaceBetweenEntries(0);
769 aEntriesBox
.SetDragDropMode(0);
771 // detect max keyname width
773 for ( sal_uInt16 i
= 0; i
< KEYCODE_ARRAY_SIZE
; ++i
)
775 long nTmp
= GetTextWidth( KeyCode( KEYCODE_ARRAY
[i
] ).GetName() );
776 if ( nTmp
> nMaxWidth
)
780 long nNewTab
= PixelToLogic( Size( nMaxWidth
, 0 ), MAP_APPFONT
).Width();
781 nNewTab
= nNewTab
+ 5; // additional space
782 aEntriesBox
.SetTab( 1, nNewTab
);
784 // initialize GroupBox
785 pGroupLBox
->SetFunctionListBox(pFunctionBox
);
788 aKeyBox
.SetStyle(aKeyBox
.GetStyle()|WB_CLIPCHILDREN
|WB_HSCROLL
|WB_SORT
);
791 //-----------------------------------------------
792 SfxAcceleratorConfigPage::~SfxAcceleratorConfigPage()
794 // free memory - remove all dynamic user data
795 SvTreeListEntry
* pEntry
= aEntriesBox
.First();
798 TAccInfo
* pUserData
= (TAccInfo
*)pEntry
->GetUserData();
801 pEntry
= aEntriesBox
.Next(pEntry
);
804 pEntry
= aKeyBox
.First();
807 TAccInfo
* pUserData
= (TAccInfo
*)pEntry
->GetUserData();
810 pEntry
= aKeyBox
.Next(pEntry
);
821 //-----------------------------------------------
822 void SfxAcceleratorConfigPage::InitAccCfg()
824 // already initialized ?
826 return; // yes -> do nothing
830 // no - initialize this instance
831 m_xContext
= ::comphelper::getProcessComponentContext();
833 m_xUICmdDescription
= css::frame::UICommandDescription::create(m_xContext
);
835 // get the current active frame, which should be our "parent"
837 m_xFrame
= GetFrame();
838 if ( !m_xFrame
.is() )
840 css::uno::Reference
< css::frame::XDesktop2
> xDesktop
= css::frame::Desktop::create( m_xContext
);
841 m_xFrame
= xDesktop
->getActiveFrame();
845 css::uno::Reference
< css::frame::XModuleManager2
> xModuleManager
=
846 css::frame::ModuleManager::create(m_xContext
);
847 m_sModuleLongName
= xModuleManager
->identify(m_xFrame
);
848 ::comphelper::SequenceAsHashMap
lModuleProps(xModuleManager
->getByName(m_sModuleLongName
));
849 m_sModuleShortName
= lModuleProps
.getUnpackedValueOrDefault(MODULEPROP_SHORTNAME
, OUString());
850 m_sModuleUIName
= lModuleProps
.getUnpackedValueOrDefault(MODULEPROP_UINAME
, OUString());
852 // get global accelerator configuration
853 m_xGlobal
= css::ui::GlobalAcceleratorConfiguration::create(m_xContext
);
855 // get module accelerator configuration
857 css::uno::Reference
< css::ui::XModuleUIConfigurationManagerSupplier
> xModuleCfgSupplier( css::ui::ModuleUIConfigurationManagerSupplier::create(m_xContext
) );
858 css::uno::Reference
< css::ui::XUIConfigurationManager
> xUICfgManager
= xModuleCfgSupplier
->getUIConfigurationManager(m_sModuleLongName
);
859 m_xModule
= css::uno::Reference
< css::ui::XAcceleratorConfiguration
>(xUICfgManager
->getShortCutManager(), css::uno::UNO_QUERY_THROW
);
861 catch(const css::uno::RuntimeException
&)
863 catch(const css::uno::Exception
&)
864 { m_xContext
.clear(); }
867 //-----------------------------------------------
868 /** Initialize text columns with own class to enable custom painting
869 This is needed as we have to paint disabled entries by ourself. No support for that in the
870 original SvTabListBox!
872 void SfxAcceleratorConfigPage::CreateCustomItems( SvTreeListEntry
* pEntry
,
873 const String
& sCol1
,
874 const String
& sCol2
)
876 SfxAccCfgLBoxString_Impl
* pStringItem
= new SfxAccCfgLBoxString_Impl(pEntry
, 0, sCol1
);
877 pEntry
->ReplaceItem(pStringItem
, 1);
879 pStringItem
= new SfxAccCfgLBoxString_Impl(pEntry
, 0, sCol2
);
880 pEntry
->ReplaceItem(pStringItem
, 2);
883 //-----------------------------------------------
884 void SfxAcceleratorConfigPage::Init(const css::uno::Reference
< css::ui::XAcceleratorConfiguration
>& xAccMgr
)
889 if (!m_bStylesInfoInitialized
)
891 css::uno::Reference
< css::frame::XController
> xController
;
892 css::uno::Reference
< css::frame::XModel
> xModel
;
894 xController
= m_xFrame
->getController();
895 if (xController
.is())
896 xModel
= xController
->getModel();
898 m_aStylesInfo
.setModel(xModel
);
899 pFunctionBox
->SetStylesInfo(&m_aStylesInfo
);
900 pGroupLBox
->SetStylesInfo(&m_aStylesInfo
);
901 m_bStylesInfoInitialized
= sal_True
;
904 // Insert all editable accelerators into list box. It is possible
905 // that some accelerators are not mapped on the current system/keyboard
906 // but we don't want to lose these mappings.
907 sal_uInt16 c1
= KEYCODE_ARRAY_SIZE
;
909 sal_uInt16 nListPos
= 0;
910 for (i1
=0; i1
<c1
; ++i1
)
912 KeyCode aKey
= KEYCODE_ARRAY
[i1
];
913 String sKey
= aKey
.GetName();
916 TAccInfo
* pEntry
= new TAccInfo(i1
, nListPos
, aKey
);
917 SvTreeListEntry
* pLBEntry
= aEntriesBox
.InsertEntryToColumn(sKey
, 0L, LIST_APPEND
, 0xFFFF);
918 pLBEntry
->SetUserData(pEntry
);
921 // Assign all commands to its shortcuts - reading the accelerator config.
922 css::uno::Sequence
< css::awt::KeyEvent
> lKeys
= xAccMgr
->getAllKeyEvents();
923 sal_Int32 c2
= lKeys
.getLength();
925 sal_uInt16 nCol
= aEntriesBox
.TabCount()-1;
927 for (i2
=0; i2
<c2
; ++i2
)
929 const css::awt::KeyEvent
& aAWTKey
= lKeys
[i2
];
930 OUString sCommand
= xAccMgr
->getCommandByKeyEvent(aAWTKey
);
931 String sLabel
= GetLabel4Command(sCommand
);
932 KeyCode aKeyCode
= ::svt::AcceleratorExecute::st_AWTKey2VCLKey(aAWTKey
);
933 sal_uInt16 nPos
= MapKeyCodeToPos(aKeyCode
);
935 if (nPos
== LISTBOX_ENTRY_NOTFOUND
)
938 aEntriesBox
.SetEntryText(sLabel
, nPos
, nCol
);
940 SvTreeListEntry
* pLBEntry
= aEntriesBox
.GetEntry(0, nPos
);
941 TAccInfo
* pEntry
= (TAccInfo
*)pLBEntry
->GetUserData();
943 pEntry
->m_bIsConfigurable
= sal_True
;
944 pEntry
->m_sCommand
= sCommand
;
945 CreateCustomItems(pLBEntry
, aEntriesBox
.GetEntryText(pLBEntry
, 0), sLabel
);
948 // Map the VCL hardcoded key codes and mark them as not changeable
949 sal_uLong c3
= Application::GetReservedKeyCodeCount();
951 for (i3
=0; i3
<c3
; ++i3
)
953 const KeyCode
* pKeyCode
= Application::GetReservedKeyCode(i3
);
954 sal_uInt16 nPos
= MapKeyCodeToPos(*pKeyCode
);
956 if (nPos
== LISTBOX_ENTRY_NOTFOUND
)
959 // Hardcoded function mapped so no ID possible and mark entry as not changeable
960 SvTreeListEntry
* pLBEntry
= aEntriesBox
.GetEntry(0, nPos
);
961 TAccInfo
* pEntry
= (TAccInfo
*)pLBEntry
->GetUserData();
963 pEntry
->m_bIsConfigurable
= sal_False
;
964 CreateCustomItems(pLBEntry
, aEntriesBox
.GetEntryText(pLBEntry
, 0), String());
968 //-----------------------------------------------
969 void SfxAcceleratorConfigPage::Apply(const css::uno::Reference
< css::ui::XAcceleratorConfiguration
>& xAccMgr
)
974 // Go through the list from the bottom to the top ...
975 // because logical accelerator must be preferred instead of
977 SvTreeListEntry
* pEntry
= aEntriesBox
.First();
980 TAccInfo
* pUserData
= (TAccInfo
*)pEntry
->GetUserData();
982 css::awt::KeyEvent aAWTKey
;
986 sCommand
= pUserData
->m_sCommand
;
987 aAWTKey
= ::svt::AcceleratorExecute::st_VCLKey2AWTKey(pUserData
->m_aKey
);
992 if (!sCommand
.isEmpty())
993 xAccMgr
->setKeyEvent(aAWTKey
, sCommand
);
995 xAccMgr
->removeKeyEvent(aAWTKey
);
997 catch(const css::uno::RuntimeException
&)
999 catch(const css::uno::Exception
&)
1002 pEntry
= aEntriesBox
.Next(pEntry
);
1006 //-----------------------------------------------
1007 void SfxAcceleratorConfigPage::ResetConfig()
1009 aEntriesBox
.Clear();
1012 //-----------------------------------------------
1013 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, Load
)
1015 // ask for filename, where we should load the new config data from
1016 StartFileDialog( 0, aLoadAccelConfigStr
);
1020 //-----------------------------------------------
1021 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, Save
)
1023 StartFileDialog( WB_SAVEAS
, aSaveAccelConfigStr
);
1027 //-----------------------------------------------
1028 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, Default
)
1030 css::uno::Reference
< css::form::XReset
> xReset(m_xAct
, css::uno::UNO_QUERY
);
1034 aEntriesBox
.SetUpdateMode(sal_False
);
1037 aEntriesBox
.SetUpdateMode(sal_True
);
1038 aEntriesBox
.Invalidate();
1039 aEntriesBox
.Select(aEntriesBox
.GetEntry(0, 0));
1044 //-----------------------------------------------
1045 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, ChangeHdl
)
1047 sal_uInt16 nPos
= (sal_uInt16
) aEntriesBox
.GetModel()->GetRelPos( aEntriesBox
.FirstSelected() );
1048 TAccInfo
* pEntry
= (TAccInfo
*)aEntriesBox
.GetEntry(0, nPos
)->GetUserData();
1049 String sNewCommand
= pFunctionBox
->GetCurCommand();
1050 String sLabel
= pFunctionBox
->GetCurLabel();
1052 sLabel
= GetLabel4Command(sNewCommand
);
1054 pEntry
->m_sCommand
= sNewCommand
;
1055 sal_uInt16 nCol
= aEntriesBox
.TabCount() - 1;
1056 aEntriesBox
.SetEntryText(sLabel
, nPos
, nCol
);
1058 ((Link
&) pFunctionBox
->GetSelectHdl()).Call( pFunctionBox
);
1062 //-----------------------------------------------
1063 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, RemoveHdl
)
1065 // get selected entry
1066 sal_uInt16 nPos
= (sal_uInt16
) aEntriesBox
.GetModel()->GetRelPos( aEntriesBox
.FirstSelected() );
1067 TAccInfo
* pEntry
= (TAccInfo
*)aEntriesBox
.GetEntry(0, nPos
)->GetUserData();
1069 // remove function name from selected entry
1070 sal_uInt16 nCol
= aEntriesBox
.TabCount() - 1;
1071 aEntriesBox
.SetEntryText( String(), nPos
, nCol
);
1072 pEntry
->m_sCommand
= OUString();
1074 ((Link
&) pFunctionBox
->GetSelectHdl()).Call( pFunctionBox
);
1078 //-----------------------------------------------
1079 IMPL_LINK( SfxAcceleratorConfigPage
, SelectHdl
, Control
*, pListBox
)
1082 Help::ShowBalloon( this, Point(), String() );
1083 if ( pListBox
== &aEntriesBox
)
1085 sal_uInt16 nPos
= (sal_uInt16
) aEntriesBox
.GetModel()->GetRelPos( aEntriesBox
.FirstSelected() );
1086 TAccInfo
* pEntry
= (TAccInfo
*)aEntriesBox
.GetEntry(0, nPos
)->GetUserData();
1087 OUString sPossibleNewCommand
= pFunctionBox
->GetCurCommand();
1089 aRemoveButton
.Enable( sal_False
);
1090 aChangeButton
.Enable( sal_False
);
1092 if (pEntry
->m_bIsConfigurable
)
1094 if (pEntry
->isConfigured())
1095 aRemoveButton
.Enable( sal_True
);
1096 aChangeButton
.Enable( pEntry
->m_sCommand
!= sPossibleNewCommand
);
1099 else if ( pListBox
== pGroupLBox
)
1101 pGroupLBox
->GroupSelected();
1102 if ( !pFunctionBox
->FirstSelected() )
1103 aChangeButton
.Enable( sal_False
);
1105 else if ( pListBox
== pFunctionBox
)
1107 aRemoveButton
.Enable( sal_False
);
1108 aChangeButton
.Enable( sal_False
);
1110 // #i36994 First selected can return zero!
1111 SvTreeListEntry
* pLBEntry
= aEntriesBox
.FirstSelected();
1112 if ( pLBEntry
!= 0 )
1114 sal_uInt16 nPos
= (sal_uInt16
) aEntriesBox
.GetModel()->GetRelPos( pLBEntry
);
1115 TAccInfo
* pEntry
= (TAccInfo
*)aEntriesBox
.GetEntry(0, nPos
)->GetUserData();
1116 OUString sPossibleNewCommand
= pFunctionBox
->GetCurCommand();
1118 if (pEntry
->m_bIsConfigurable
)
1120 if (pEntry
->isConfigured())
1121 aRemoveButton
.Enable( sal_True
);
1122 aChangeButton
.Enable( pEntry
->m_sCommand
!= sPossibleNewCommand
);
1127 SvTreeListEntry
* pIt
= aEntriesBox
.First();
1130 TAccInfo
* pUserData
= (TAccInfo
*)pIt
->GetUserData();
1131 if ( pUserData
&& pUserData
->m_sCommand
== sPossibleNewCommand
)
1133 TAccInfo
* pU1
= new TAccInfo(-1, -1, pUserData
->m_aKey
);
1134 SvTreeListEntry
* pE1
= aKeyBox
.InsertEntry( pUserData
->m_aKey
.GetName(), 0L, sal_True
, LIST_APPEND
);
1135 pE1
->SetUserData(pU1
);
1136 pE1
->EnableChildrenOnDemand( sal_False
);
1138 pIt
= aEntriesBox
.Next(pIt
);
1144 // goto selected "key" entry of the key box
1145 SvTreeListEntry
* pE2
= 0;
1147 sal_uInt16 nP2
= LISTBOX_ENTRY_NOTFOUND
;
1148 SvTreeListEntry
* pE3
= 0;
1150 pE2
= aKeyBox
.FirstSelected();
1152 pU2
= (TAccInfo
*)pE2
->GetUserData();
1154 nP2
= MapKeyCodeToPos(pU2
->m_aKey
);
1155 if (nP2
!= LISTBOX_ENTRY_NOTFOUND
)
1156 pE3
= aEntriesBox
.GetEntry( 0, nP2
);
1159 aEntriesBox
.Select( pE3
);
1160 aEntriesBox
.MakeVisible( pE3
);
1167 //-----------------------------------------------
1168 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, RadioHdl
)
1170 css::uno::Reference
< css::ui::XAcceleratorConfiguration
> xOld
= m_xAct
;
1172 if (aOfficeButton
.IsChecked())
1174 else if (aModuleButton
.IsChecked())
1177 // nothing changed? => do nothing!
1178 if ( m_xAct
.is() && ( xOld
== m_xAct
) )
1181 aEntriesBox
.SetUpdateMode( sal_False
);
1184 aEntriesBox
.SetUpdateMode( sal_True
);
1185 aEntriesBox
.Invalidate();
1187 pGroupLBox
->Init(m_xContext
, m_xFrame
, m_sModuleLongName
);
1189 // pb: #133213# do not select NULL entries
1190 SvTreeListEntry
* pEntry
= aEntriesBox
.GetEntry( 0, 0 );
1192 aEntriesBox
.Select( pEntry
);
1193 pEntry
= pGroupLBox
->GetEntry( 0, 0 );
1195 pGroupLBox
->Select( pEntry
);
1197 ((Link
&) pFunctionBox
->GetSelectHdl()).Call( pFunctionBox
);
1201 //-----------------------------------------------
1202 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, LoadHdl
)
1207 if ( ERRCODE_NONE
== m_pFileDlg
->GetError() )
1208 sCfgName
= m_pFileDlg
->GetPath();
1210 if ( sCfgName
.isEmpty() )
1213 GetTabDialog()->EnterWait();
1215 css::uno::Reference
< css::frame::XModel
> xDoc
;
1216 css::uno::Reference
< css::ui::XUIConfigurationManager
> xCfgMgr
;
1217 css::uno::Reference
< css::embed::XStorage
> xRootStorage
; // we must hold the root storage alive, if xCfgMgr is used!
1221 // first check if URL points to a document already loaded
1222 xDoc
= SearchForAlreadyLoadedDoc(sCfgName
);
1225 // Get ui config manager. There should always be one at the model.
1226 css::uno::Reference
< css::ui::XUIConfigurationManagerSupplier
> xCfgSupplier(xDoc
, css::uno::UNO_QUERY_THROW
);
1227 xCfgMgr
= xCfgSupplier
->getUIConfigurationManager();
1231 // URL doesn't point to a loaded document, try to access it as a single storage
1232 // dont forget to release the storage afterwards!
1233 css::uno::Reference
< css::lang::XSingleServiceFactory
> xStorageFactory( css::embed::StorageFactory::create( m_xContext
) );
1234 css::uno::Sequence
< css::uno::Any
> lArgs(2);
1235 lArgs
[0] <<= sCfgName
;
1236 lArgs
[1] <<= css::embed::ElementModes::READ
;
1238 xRootStorage
= css::uno::Reference
< css::embed::XStorage
>(xStorageFactory
->createInstanceWithArguments(lArgs
), css::uno::UNO_QUERY_THROW
);
1239 css::uno::Reference
< css::embed::XStorage
> xUIConfig
= xRootStorage
->openStorageElement(FOLDERNAME_UICONFIG
, css::embed::ElementModes::READ
);
1242 css::uno::Reference
< css::ui::XUIConfigurationManager2
> xCfgMgr2
= css::ui::UIConfigurationManager::create( m_xContext
);
1243 xCfgMgr2
->setStorage(xUIConfig
);
1244 xCfgMgr
.set( xCfgMgr2
, css::uno::UNO_QUERY_THROW
);
1250 // open the configuration and update our UI
1251 css::uno::Reference
< css::ui::XAcceleratorConfiguration
> xTempAccMgr(xCfgMgr
->getShortCutManager(), css::uno::UNO_QUERY_THROW
);
1253 aEntriesBox
.SetUpdateMode(sal_False
);
1256 aEntriesBox
.SetUpdateMode(sal_True
);
1257 aEntriesBox
.Invalidate();
1258 aEntriesBox
.Select(aEntriesBox
.GetEntry(0, 0));
1262 // dont forget to close the new opened storage!
1263 // We are the owner of it.
1264 if (xRootStorage
.is())
1266 css::uno::Reference
< css::lang::XComponent
> xComponent
;
1267 xComponent
= css::uno::Reference
< css::lang::XComponent
>(xCfgMgr
, css::uno::UNO_QUERY
);
1268 if (xComponent
.is())
1269 xComponent
->dispose();
1270 xComponent
= css::uno::Reference
< css::lang::XComponent
>(xRootStorage
, css::uno::UNO_QUERY
);
1271 if (xComponent
.is())
1272 xComponent
->dispose();
1275 catch(const css::uno::RuntimeException
&)
1277 catch(const css::uno::Exception
&)
1280 GetTabDialog()->LeaveWait();
1285 //-----------------------------------------------
1286 IMPL_LINK_NOARG(SfxAcceleratorConfigPage
, SaveHdl
)
1291 if ( ERRCODE_NONE
== m_pFileDlg
->GetError() )
1292 sCfgName
= m_pFileDlg
->GetPath();
1294 if ( sCfgName
.isEmpty() )
1297 GetTabDialog()->EnterWait();
1299 css::uno::Reference
< css::frame::XModel
> xDoc
;
1300 css::uno::Reference
< css::ui::XUIConfigurationManager
> xCfgMgr
;
1301 css::uno::Reference
< css::embed::XStorage
> xRootStorage
;
1305 // first check if URL points to a document already loaded
1306 xDoc
= SearchForAlreadyLoadedDoc(sCfgName
);
1309 // get config manager, force creation if there was none before
1310 css::uno::Reference
< css::ui::XUIConfigurationManagerSupplier
> xCfgSupplier(xDoc
, css::uno::UNO_QUERY_THROW
);
1311 xCfgMgr
= xCfgSupplier
->getUIConfigurationManager();
1315 // URL doesn't point to a loaded document, try to access it as a single storage
1316 css::uno::Reference
< css::lang::XSingleServiceFactory
> xStorageFactory( css::embed::StorageFactory::create( m_xContext
) );
1317 css::uno::Sequence
< css::uno::Any
> lArgs(2);
1318 lArgs
[0] <<= sCfgName
;
1319 lArgs
[1] <<= css::embed::ElementModes::WRITE
;
1321 xRootStorage
= css::uno::Reference
< css::embed::XStorage
>(
1322 xStorageFactory
->createInstanceWithArguments(lArgs
),
1323 css::uno::UNO_QUERY_THROW
);
1325 css::uno::Reference
< css::embed::XStorage
> xUIConfig(
1326 xRootStorage
->openStorageElement(FOLDERNAME_UICONFIG
, css::embed::ElementModes::WRITE
),
1327 css::uno::UNO_QUERY_THROW
);
1328 css::uno::Reference
< css::beans::XPropertySet
> xUIConfigProps(
1330 css::uno::UNO_QUERY_THROW
);
1332 // set the correct media type if the storage was new created
1333 OUString sMediaType
;
1334 xUIConfigProps
->getPropertyValue(MEDIATYPE_PROPNAME
) >>= sMediaType
;
1335 if (sMediaType
.isEmpty())
1336 xUIConfigProps
->setPropertyValue(MEDIATYPE_PROPNAME
, css::uno::makeAny(MEDIATYPE_UICONFIG
));
1338 css::uno::Reference
< css::ui::XUIConfigurationManager2
> xCfgMgr2
= css::ui::UIConfigurationManager::create( m_xContext
);
1339 xCfgMgr2
->setStorage(xUIConfig
);
1340 xCfgMgr
.set( xCfgMgr2
, css::uno::UNO_QUERY_THROW
);
1345 // get the target configuration access and update with all shortcuts
1346 // which are set currently at the UI !
1347 // Dont copy the m_xAct content to it ... because m_xAct will be updated
1348 // from the UI on pressing the button "OK" only. And inbetween it's not up to date !
1349 css::uno::Reference
< css::ui::XAcceleratorConfiguration
> xTargetAccMgr(xCfgMgr
->getShortCutManager(), css::uno::UNO_QUERY_THROW
);
1350 Apply(xTargetAccMgr
);
1352 // commit (order is important!)
1353 css::uno::Reference
< css::ui::XUIConfigurationPersistence
> xCommit1(xTargetAccMgr
, css::uno::UNO_QUERY_THROW
);
1354 css::uno::Reference
< css::ui::XUIConfigurationPersistence
> xCommit2(xCfgMgr
, css::uno::UNO_QUERY_THROW
);
1358 if (xRootStorage
.is())
1360 // Commit root storage
1361 css::uno::Reference
< css::embed::XTransactedObject
> xCommit3(xRootStorage
, css::uno::UNO_QUERY_THROW
);
1366 if (xRootStorage
.is())
1368 css::uno::Reference
< css::lang::XComponent
> xComponent(xCfgMgr
, css::uno::UNO_QUERY
);
1369 if (xComponent
.is())
1370 xComponent
->dispose();
1371 xComponent
.set(xRootStorage
, css::uno::UNO_QUERY
);
1372 if (xComponent
.is())
1373 xComponent
->dispose();
1376 catch(const css::uno::RuntimeException
&)
1378 catch(const css::uno::Exception
&)
1381 GetTabDialog()->LeaveWait();
1386 //-----------------------------------------------
1387 void SfxAcceleratorConfigPage::StartFileDialog( WinBits nBits
, const String
& rTitle
)
1389 bool bSave
= ( ( nBits
& WB_SAVEAS
) == WB_SAVEAS
);
1390 short nDialogType
= bSave
? css::ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION
1391 : css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE
;
1394 m_pFileDlg
= new sfx2::FileDialogHelper( nDialogType
, 0 );
1396 m_pFileDlg
->SetTitle( rTitle
);
1397 m_pFileDlg
->AddFilter( aFilterAllStr
, OUString(FILEDIALOG_FILTER_ALL
) );
1398 m_pFileDlg
->AddFilter( aFilterCfgStr
, OUString("*.cfg") );
1399 m_pFileDlg
->SetCurrentFilter( aFilterCfgStr
);
1401 Link aDlgClosedLink
= bSave
? LINK( this, SfxAcceleratorConfigPage
, SaveHdl
)
1402 : LINK( this, SfxAcceleratorConfigPage
, LoadHdl
);
1403 m_pFileDlg
->StartExecuteModal( aDlgClosedLink
);
1406 //-----------------------------------------------
1407 sal_Bool
SfxAcceleratorConfigPage::FillItemSet( SfxItemSet
& )
1414 catch(const css::uno::RuntimeException
&)
1416 catch(const css::uno::Exception
&)
1417 { return sal_False
; }
1422 //-----------------------------------------------
1423 void SfxAcceleratorConfigPage::Reset( const SfxItemSet
& rSet
)
1425 // open accelerator configs
1426 // Note: It initialize some other members too, which are needed here ...
1427 // e.g. m_sModuleUIName!
1430 // change te description of the radio button, which switch to the module
1431 // dependend accelerator configuration
1432 String sButtonText
= aModuleButton
.GetText();
1433 sButtonText
.SearchAndReplace(OUString("$(MODULE)"), m_sModuleUIName
);
1434 aModuleButton
.SetText(sButtonText
);
1437 aModuleButton
.Check();
1440 aModuleButton
.Hide();
1441 aOfficeButton
.Check();
1446 const SfxPoolItem
* pMacroItem
=0;
1447 if( SFX_ITEM_SET
== rSet
.GetItemState( SID_MACROINFO
, sal_True
, &pMacroItem
) )
1449 m_pMacroInfoItem
= PTR_CAST( SfxMacroInfoItem
, pMacroItem
);
1450 pGroupLBox
->SelectMacro( m_pMacroInfoItem
);
1454 const SfxPoolItem
* pStringItem
=0;
1455 if( SFX_ITEM_SET
== rSet
.GetItemState( SID_CHARMAP
, sal_True
, &pStringItem
) )
1456 m_pStringItem
= PTR_CAST( SfxStringItem
, pStringItem
);
1458 const SfxPoolItem
* pFontItem
=0;
1459 if( SFX_ITEM_SET
== rSet
.GetItemState( SID_ATTR_SPECIALCHAR
, sal_True
, &pFontItem
) )
1460 m_pFontItem
= PTR_CAST( SfxStringItem
, pFontItem
);
1464 //-----------------------------------------------
1465 sal_uInt16
SfxAcceleratorConfigPage::MapKeyCodeToPos(const KeyCode
& aKey
) const
1467 sal_uInt16 nCode1
= aKey
.GetCode()+aKey
.GetModifier();
1468 SvTreeListEntry
* pEntry
= aEntriesBox
.First();
1473 TAccInfo
* pUserData
= (TAccInfo
*)pEntry
->GetUserData();
1476 sal_uInt16 nCode2
= pUserData
->m_aKey
.GetCode()+pUserData
->m_aKey
.GetModifier();
1477 if (nCode1
== nCode2
)
1480 pEntry
= aEntriesBox
.Next(pEntry
);
1484 return LISTBOX_ENTRY_NOTFOUND
;
1487 //-----------------------------------------------
1488 String
SfxAcceleratorConfigPage::GetLabel4Command(const String
& sCommand
)
1492 // check global command configuration first
1493 css::uno::Reference
< css::container::XNameAccess
> xModuleConf
;
1494 m_xUICmdDescription
->getByName(m_sModuleLongName
) >>= xModuleConf
;
1495 if (xModuleConf
.is())
1497 ::comphelper::SequenceAsHashMap
lProps(xModuleConf
->getByName(sCommand
));
1498 String sLabel
= String(lProps
.getUnpackedValueOrDefault(CMDPROP_UINAME
, OUString()));
1503 catch(const css::uno::RuntimeException
&)
1505 catch(const css::uno::Exception
&)
1508 // may be it's a style URL .. they must be handled special
1509 SfxStyleInfo_Impl aStyle
;
1510 aStyle
.sCommand
= sCommand
;
1511 if (m_aStylesInfo
.parseStyleCommand(aStyle
))
1513 m_aStylesInfo
.getLabel4Style(aStyle
);
1514 return aStyle
.sLabel
;
1518 String
aRet(OUString("Symbols: "));
1519 xub_StrLen nPos
= sCommand
.SearchAscii(".uno:InsertSymbol?Symbols:string=");
1522 aRet
+= String( sCommand
, 34, sCommand
.Len()-34 );
1530 SfxTabPage
* SfxAcceleratorConfigPage::Create( Window
* pParent
, const SfxItemSet
& rAttrSet
)
1532 return new SfxAcceleratorConfigPage( pParent
, rAttrSet
);
1535 //-----------------------------------------------
1536 css::uno::Reference
< css::frame::XModel
> SfxAcceleratorConfigPage::SearchForAlreadyLoadedDoc(const String
& /*sName*/)
1538 return css::uno::Reference
< css::frame::XModel
>();
1541 SvxShortcutAssignDlg::SvxShortcutAssignDlg( Window
* pParent
, const uno::Reference
< frame::XFrame
>& rxDocumentFrame
, const SfxItemSet
& rSet
)
1542 : SfxNoLayoutSingleTabDialog( pParent
, rSet
, 0 )
1544 SfxTabPage
* pPage
= SfxAcceleratorConfigPage::Create( this, rSet
);
1545 pPage
->SetFrame( rxDocumentFrame
);
1546 SetTabPage( pPage
);
1550 SvxShortcutAssignDlg::~SvxShortcutAssignDlg()
1555 // .uno:InsertSymbol?Symbols:string=bla
1557 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */