1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cui.hxx"
31 //-----------------------------------------------
35 #include "cfgutil.hxx"
36 #include <dialmgr.hxx>
38 #include <sfx2/msg.hxx>
39 #include <sfx2/app.hxx>
40 #include <sfx2/filedlghelper.hxx>
41 #include <sfx2/minfitem.hxx>
42 #include <sfx2/sfxresid.hxx>
43 #include <svl/stritem.hxx>
48 #include <svx/svxids.hrc> // SID_CHARMAP, SID_ATTR_SPECIALCHAR
50 //-----------------------------------------------
51 // include interface declarations
52 #include <com/sun/star/frame/XFramesSupplier.hpp>
53 #include <com/sun/star/frame/XFrame.hpp>
54 #include <com/sun/star/frame/XController.hpp>
55 #include <com/sun/star/frame/XModel.hpp>
56 #include <com/sun/star/form/XReset.hpp>
57 #include <com/sun/star/frame/XModuleManager.hpp>
58 #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
59 #include <com/sun/star/frame/XModuleManager.hpp>
61 #ifndef _COM_SUN_STAR_UI_XUICONFIGURATIONMANAGERSUPLLIER_HPP_
62 #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
64 #include <com/sun/star/ui/XUIConfigurationManager.hpp>
65 #include <com/sun/star/awt/KeyModifier.hpp>
66 #include <com/sun/star/embed/XTransactedObject.hpp>
67 #include <com/sun/star/embed/ElementModes.hpp>
69 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
71 //-----------------------------------------------
72 // include other projects
73 #include <unotools/processfactory.hxx>
74 #include <svtools/acceleratorexecute.hxx>
75 #include <comphelper/processfactory.hxx>
76 #include <svtools/svlbitm.hxx>
77 #include <vcl/svapp.hxx>
78 #include <vcl/help.hxx>
79 #include <rtl/ustrbuf.hxx>
80 #include <comphelper/sequenceashashmap.hxx>
82 //-----------------------------------------------
86 #error "ambigous praeprozessor directive for css ..."
88 namespace css
= ::com::sun::star
;
91 using namespace com::sun::star
;
93 //-----------------------------------------------
96 //-----------------------------------------------
97 static ::rtl::OUString SERVICE_STORAGEFACTORY
= ::rtl::OUString::createFromAscii("com.sun.star.embed.StorageFactory" );
98 static ::rtl::OUString SERVICE_UICONFIGMGR
= ::rtl::OUString::createFromAscii("com.sun.star.ui.UIConfigurationManager" );
99 static ::rtl::OUString SERVICE_DESKTOP
= ::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop" );
100 static ::rtl::OUString SERVICE_MODULEMANAGER
= ::rtl::OUString::createFromAscii("com.sun.star.frame.ModuleManager" );
101 static ::rtl::OUString SERVICE_GLOBALACCCFG
= ::rtl::OUString::createFromAscii("com.sun.star.ui.GlobalAcceleratorConfiguration" );
102 static ::rtl::OUString SERVICE_MODULEUICONFIGSUPPLIER
= ::rtl::OUString::createFromAscii("com.sun.star.ui.ModuleUIConfigurationManagerSupplier");
103 static ::rtl::OUString SERVICE_UICMDDESCRIPTION
= ::rtl::OUString::createFromAscii("com.sun.star.frame.UICommandDescription" );
105 static ::rtl::OUString MODULEPROP_SHORTNAME
= ::rtl::OUString::createFromAscii("ooSetupFactoryShortName" );
106 static ::rtl::OUString MODULEPROP_UINAME
= ::rtl::OUString::createFromAscii("ooSetupFactoryUIName" );
107 static ::rtl::OUString CMDPROP_UINAME
= ::rtl::OUString::createFromAscii("Name" );
109 static ::rtl::OUString FOLDERNAME_UICONFIG
= ::rtl::OUString::createFromAscii("Configurations2" );
111 static ::rtl::OUString MEDIATYPE_PROPNAME
= ::rtl::OUString::createFromAscii("MediaType" );
112 static ::rtl::OUString MEDIATYPE_UICONFIG
= ::rtl::OUString::createFromAscii("application/vnd.sun.xml.ui.configuration" );
114 //-----------------------------------------------
115 static sal_uInt16 __FAR_DATA KEYCODE_ARRAY
[] =
170 KEY_DOWN
| KEY_SHIFT
,
172 KEY_LEFT
| KEY_SHIFT
,
173 KEY_RIGHT
| KEY_SHIFT
,
174 KEY_HOME
| KEY_SHIFT
,
176 KEY_PAGEUP
| KEY_SHIFT
,
177 KEY_PAGEDOWN
| KEY_SHIFT
,
178 KEY_RETURN
| KEY_SHIFT
,
179 KEY_SPACE
| KEY_SHIFT
,
180 KEY_ESCAPE
| KEY_SHIFT
,
181 KEY_BACKSPACE
| KEY_SHIFT
,
182 KEY_INSERT
| KEY_SHIFT
,
183 KEY_DELETE
| KEY_SHIFT
,
235 KEY_DOWN
| KEY_MOD1
,
237 KEY_LEFT
| KEY_MOD1
,
238 KEY_RIGHT
| KEY_MOD1
,
239 KEY_HOME
| KEY_MOD1
,
241 KEY_PAGEUP
| KEY_MOD1
,
242 KEY_PAGEDOWN
| KEY_MOD1
,
243 KEY_RETURN
| KEY_MOD1
,
244 KEY_SPACE
| KEY_MOD1
,
245 KEY_BACKSPACE
| KEY_MOD1
,
246 KEY_INSERT
| KEY_MOD1
,
247 KEY_DELETE
| KEY_MOD1
,
250 KEY_SUBTRACT
| KEY_MOD1
,
251 KEY_MULTIPLY
| KEY_MOD1
,
252 KEY_DIVIDE
| KEY_MOD1
,
254 KEY_0
| KEY_SHIFT
| KEY_MOD1
,
255 KEY_1
| KEY_SHIFT
| KEY_MOD1
,
256 KEY_2
| KEY_SHIFT
| KEY_MOD1
,
257 KEY_3
| KEY_SHIFT
| KEY_MOD1
,
258 KEY_4
| KEY_SHIFT
| KEY_MOD1
,
259 KEY_5
| KEY_SHIFT
| KEY_MOD1
,
260 KEY_6
| KEY_SHIFT
| KEY_MOD1
,
261 KEY_7
| KEY_SHIFT
| KEY_MOD1
,
262 KEY_8
| KEY_SHIFT
| KEY_MOD1
,
263 KEY_9
| KEY_SHIFT
| KEY_MOD1
,
264 KEY_A
| KEY_SHIFT
| KEY_MOD1
,
265 KEY_B
| KEY_SHIFT
| KEY_MOD1
,
266 KEY_C
| KEY_SHIFT
| KEY_MOD1
,
267 KEY_D
| KEY_SHIFT
| KEY_MOD1
,
268 KEY_E
| KEY_SHIFT
| KEY_MOD1
,
269 KEY_F
| KEY_SHIFT
| KEY_MOD1
,
270 KEY_G
| KEY_SHIFT
| KEY_MOD1
,
271 KEY_H
| KEY_SHIFT
| KEY_MOD1
,
272 KEY_I
| KEY_SHIFT
| KEY_MOD1
,
273 KEY_J
| KEY_SHIFT
| KEY_MOD1
,
274 KEY_K
| KEY_SHIFT
| KEY_MOD1
,
275 KEY_L
| KEY_SHIFT
| KEY_MOD1
,
276 KEY_M
| KEY_SHIFT
| KEY_MOD1
,
277 KEY_N
| KEY_SHIFT
| KEY_MOD1
,
278 KEY_O
| KEY_SHIFT
| KEY_MOD1
,
279 KEY_P
| KEY_SHIFT
| KEY_MOD1
,
280 KEY_Q
| KEY_SHIFT
| KEY_MOD1
,
281 KEY_R
| KEY_SHIFT
| KEY_MOD1
,
282 KEY_S
| KEY_SHIFT
| KEY_MOD1
,
283 KEY_T
| KEY_SHIFT
| KEY_MOD1
,
284 KEY_U
| KEY_SHIFT
| KEY_MOD1
,
285 KEY_V
| KEY_SHIFT
| KEY_MOD1
,
286 KEY_W
| KEY_SHIFT
| KEY_MOD1
,
287 KEY_X
| KEY_SHIFT
| KEY_MOD1
,
288 KEY_Y
| KEY_SHIFT
| KEY_MOD1
,
289 KEY_Z
| KEY_SHIFT
| KEY_MOD1
,
291 KEY_F1
| KEY_SHIFT
| KEY_MOD1
,
292 KEY_F2
| KEY_SHIFT
| KEY_MOD1
,
293 KEY_F3
| KEY_SHIFT
| KEY_MOD1
,
294 KEY_F4
| KEY_SHIFT
| KEY_MOD1
,
295 KEY_F5
| KEY_SHIFT
| KEY_MOD1
,
296 KEY_F6
| KEY_SHIFT
| KEY_MOD1
,
297 KEY_F7
| KEY_SHIFT
| KEY_MOD1
,
298 KEY_F8
| KEY_SHIFT
| KEY_MOD1
,
299 KEY_F9
| KEY_SHIFT
| KEY_MOD1
,
300 KEY_F10
| KEY_SHIFT
| KEY_MOD1
,
301 KEY_F11
| KEY_SHIFT
| KEY_MOD1
,
302 KEY_F12
| 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
,
368 KEY_DOWN
| KEY_MOD2
,
370 KEY_LEFT
| KEY_MOD2
,
371 KEY_RIGHT
| KEY_MOD2
,
372 KEY_HOME
| KEY_MOD2
,
374 KEY_PAGEUP
| KEY_MOD2
,
375 KEY_PAGEDOWN
| KEY_MOD2
,
376 KEY_RETURN
| KEY_MOD2
,
377 KEY_SPACE
| KEY_MOD2
,
378 KEY_BACKSPACE
| KEY_MOD2
,
379 KEY_INSERT
| KEY_MOD2
,
380 KEY_DELETE
| KEY_MOD2
,
382 KEY_0
| KEY_SHIFT
| KEY_MOD2
,
383 KEY_1
| KEY_SHIFT
| KEY_MOD2
,
384 KEY_2
| KEY_SHIFT
| KEY_MOD2
,
385 KEY_3
| KEY_SHIFT
| KEY_MOD2
,
386 KEY_4
| KEY_SHIFT
| KEY_MOD2
,
387 KEY_5
| KEY_SHIFT
| KEY_MOD2
,
388 KEY_6
| KEY_SHIFT
| KEY_MOD2
,
389 KEY_7
| KEY_SHIFT
| KEY_MOD2
,
390 KEY_8
| KEY_SHIFT
| KEY_MOD2
,
391 KEY_9
| KEY_SHIFT
| KEY_MOD2
,
392 KEY_A
| KEY_SHIFT
| KEY_MOD2
,
393 KEY_B
| KEY_SHIFT
| KEY_MOD2
,
394 KEY_C
| KEY_SHIFT
| KEY_MOD2
,
395 KEY_D
| KEY_SHIFT
| KEY_MOD2
,
396 KEY_E
| KEY_SHIFT
| KEY_MOD2
,
397 KEY_F
| KEY_SHIFT
| KEY_MOD2
,
398 KEY_G
| KEY_SHIFT
| KEY_MOD2
,
399 KEY_H
| KEY_SHIFT
| KEY_MOD2
,
400 KEY_I
| KEY_SHIFT
| KEY_MOD2
,
401 KEY_J
| KEY_SHIFT
| KEY_MOD2
,
402 KEY_K
| KEY_SHIFT
| KEY_MOD2
,
403 KEY_L
| KEY_SHIFT
| KEY_MOD2
,
404 KEY_M
| KEY_SHIFT
| KEY_MOD2
,
405 KEY_N
| KEY_SHIFT
| KEY_MOD2
,
406 KEY_O
| KEY_SHIFT
| KEY_MOD2
,
407 KEY_P
| KEY_SHIFT
| KEY_MOD2
,
408 KEY_Q
| KEY_SHIFT
| KEY_MOD2
,
409 KEY_R
| KEY_SHIFT
| KEY_MOD2
,
410 KEY_S
| KEY_SHIFT
| KEY_MOD2
,
411 KEY_T
| KEY_SHIFT
| KEY_MOD2
,
412 KEY_U
| KEY_SHIFT
| KEY_MOD2
,
413 KEY_V
| KEY_SHIFT
| KEY_MOD2
,
414 KEY_W
| KEY_SHIFT
| KEY_MOD2
,
415 KEY_X
| KEY_SHIFT
| KEY_MOD2
,
416 KEY_Y
| KEY_SHIFT
| KEY_MOD2
,
417 KEY_Z
| KEY_SHIFT
| KEY_MOD2
,
419 KEY_F1
| KEY_SHIFT
| KEY_MOD2
,
420 KEY_F2
| KEY_SHIFT
| KEY_MOD2
,
421 KEY_F3
| KEY_SHIFT
| KEY_MOD2
,
422 KEY_F4
| KEY_SHIFT
| KEY_MOD2
,
423 KEY_F5
| KEY_SHIFT
| KEY_MOD2
,
424 KEY_F6
| KEY_SHIFT
| KEY_MOD2
,
425 KEY_F7
| KEY_SHIFT
| KEY_MOD2
,
426 KEY_F8
| KEY_SHIFT
| KEY_MOD2
,
427 KEY_F9
| KEY_SHIFT
| KEY_MOD2
,
428 KEY_F10
| KEY_SHIFT
| KEY_MOD2
,
429 KEY_F11
| KEY_SHIFT
| KEY_MOD2
,
430 KEY_F12
| KEY_SHIFT
| KEY_MOD2
,
432 KEY_DOWN
| KEY_SHIFT
| KEY_MOD2
,
433 KEY_UP
| KEY_SHIFT
| KEY_MOD2
,
434 KEY_LEFT
| KEY_SHIFT
| KEY_MOD2
,
435 KEY_RIGHT
| KEY_SHIFT
| KEY_MOD2
,
436 KEY_HOME
| KEY_SHIFT
| KEY_MOD2
,
437 KEY_END
| KEY_SHIFT
| KEY_MOD2
,
438 KEY_PAGEUP
| KEY_SHIFT
| KEY_MOD2
,
439 KEY_PAGEDOWN
| KEY_SHIFT
| KEY_MOD2
,
440 KEY_RETURN
| KEY_SHIFT
| KEY_MOD2
,
441 KEY_SPACE
| KEY_SHIFT
| KEY_MOD2
,
442 KEY_BACKSPACE
| KEY_SHIFT
| KEY_MOD2
,
443 KEY_INSERT
| KEY_SHIFT
| KEY_MOD2
,
444 KEY_DELETE
| KEY_SHIFT
| KEY_MOD2
,
446 KEY_0
| KEY_MOD1
| KEY_MOD2
,
447 KEY_1
| KEY_MOD1
| KEY_MOD2
,
448 KEY_2
| KEY_MOD1
| KEY_MOD2
,
449 KEY_3
| KEY_MOD1
| KEY_MOD2
,
450 KEY_4
| KEY_MOD1
| KEY_MOD2
,
451 KEY_5
| KEY_MOD1
| KEY_MOD2
,
452 KEY_6
| KEY_MOD1
| KEY_MOD2
,
453 KEY_7
| KEY_MOD1
| KEY_MOD2
,
454 KEY_8
| KEY_MOD1
| KEY_MOD2
,
455 KEY_9
| KEY_MOD1
| KEY_MOD2
,
456 KEY_A
| KEY_MOD1
| KEY_MOD2
,
457 KEY_B
| KEY_MOD1
| KEY_MOD2
,
458 KEY_C
| KEY_MOD1
| KEY_MOD2
,
459 KEY_D
| KEY_MOD1
| KEY_MOD2
,
460 KEY_E
| KEY_MOD1
| KEY_MOD2
,
461 KEY_F
| KEY_MOD1
| KEY_MOD2
,
462 KEY_G
| KEY_MOD1
| KEY_MOD2
,
463 KEY_H
| KEY_MOD1
| KEY_MOD2
,
464 KEY_I
| KEY_MOD1
| KEY_MOD2
,
465 KEY_J
| KEY_MOD1
| KEY_MOD2
,
466 KEY_K
| KEY_MOD1
| KEY_MOD2
,
467 KEY_L
| KEY_MOD1
| KEY_MOD2
,
468 KEY_M
| KEY_MOD1
| KEY_MOD2
,
469 KEY_N
| KEY_MOD1
| KEY_MOD2
,
470 KEY_O
| KEY_MOD1
| KEY_MOD2
,
471 KEY_P
| KEY_MOD1
| KEY_MOD2
,
472 KEY_Q
| KEY_MOD1
| KEY_MOD2
,
473 KEY_R
| KEY_MOD1
| KEY_MOD2
,
474 KEY_S
| KEY_MOD1
| KEY_MOD2
,
475 KEY_T
| KEY_MOD1
| KEY_MOD2
,
476 KEY_U
| KEY_MOD1
| KEY_MOD2
,
477 KEY_V
| KEY_MOD1
| KEY_MOD2
,
478 KEY_W
| KEY_MOD1
| KEY_MOD2
,
479 KEY_X
| KEY_MOD1
| KEY_MOD2
,
480 KEY_Y
| KEY_MOD1
| KEY_MOD2
,
481 KEY_Z
| KEY_MOD1
| KEY_MOD2
,
483 KEY_F1
| KEY_MOD1
| KEY_MOD2
,
484 KEY_F2
| KEY_MOD1
| KEY_MOD2
,
485 KEY_F3
| KEY_MOD1
| KEY_MOD2
,
486 KEY_F4
| KEY_MOD1
| KEY_MOD2
,
487 KEY_F5
| KEY_MOD1
| KEY_MOD2
,
488 KEY_F6
| KEY_MOD1
| KEY_MOD2
,
489 KEY_F7
| KEY_MOD1
| KEY_MOD2
,
490 KEY_F8
| KEY_MOD1
| KEY_MOD2
,
491 KEY_F9
| KEY_MOD1
| KEY_MOD2
,
492 KEY_F10
| KEY_MOD1
| KEY_MOD2
,
493 KEY_F11
| KEY_MOD1
| KEY_MOD2
,
494 KEY_F12
| KEY_MOD1
| KEY_MOD2
,
496 KEY_DOWN
| KEY_MOD1
| KEY_MOD2
,
497 KEY_UP
| KEY_MOD1
| KEY_MOD2
,
498 KEY_LEFT
| KEY_MOD1
| KEY_MOD2
,
499 KEY_RIGHT
| KEY_MOD1
| KEY_MOD2
,
500 KEY_HOME
| KEY_MOD1
| KEY_MOD2
,
501 KEY_END
| KEY_MOD1
| KEY_MOD2
,
502 KEY_PAGEUP
| KEY_MOD1
| KEY_MOD2
,
503 KEY_PAGEDOWN
| KEY_MOD1
| KEY_MOD2
,
504 KEY_RETURN
| KEY_MOD1
| KEY_MOD2
,
505 KEY_SPACE
| KEY_MOD1
| KEY_MOD2
,
506 KEY_BACKSPACE
| KEY_MOD1
| KEY_MOD2
,
507 KEY_INSERT
| KEY_MOD1
| KEY_MOD2
,
508 KEY_DELETE
| KEY_MOD1
| KEY_MOD2
,
510 KEY_0
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
511 KEY_1
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
512 KEY_2
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
513 KEY_3
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
514 KEY_4
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
515 KEY_5
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
516 KEY_6
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
517 KEY_7
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
518 KEY_8
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
519 KEY_9
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
520 KEY_A
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
521 KEY_B
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
522 KEY_C
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
523 KEY_D
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
524 KEY_E
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
525 KEY_F
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
526 KEY_G
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
527 KEY_H
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
528 KEY_I
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
529 KEY_J
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
530 KEY_K
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
531 KEY_L
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
532 KEY_M
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
533 KEY_N
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
534 KEY_O
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
535 KEY_P
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
536 KEY_Q
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
537 KEY_R
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
538 KEY_S
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
539 KEY_T
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
540 KEY_U
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
541 KEY_V
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
542 KEY_W
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
543 KEY_X
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
544 KEY_Y
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
545 KEY_Z
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
547 KEY_F1
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
548 KEY_F2
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
549 KEY_F3
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
550 KEY_F4
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
551 KEY_F5
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
552 KEY_F6
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
553 KEY_F7
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
554 KEY_F8
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
555 KEY_F9
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
556 KEY_F10
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
557 KEY_F11
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
558 KEY_F12
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
560 KEY_DOWN
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
561 KEY_UP
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
562 KEY_LEFT
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
563 KEY_RIGHT
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
564 KEY_HOME
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
565 KEY_END
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
566 KEY_PAGEUP
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
567 KEY_PAGEDOWN
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
568 KEY_RETURN
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
569 KEY_SPACE
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
570 KEY_BACKSPACE
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
571 KEY_INSERT
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
,
572 KEY_DELETE
| KEY_SHIFT
| KEY_MOD1
| KEY_MOD2
575 static sal_uInt16 KEYCODE_ARRAY_SIZE
= (sizeof(KEYCODE_ARRAY
) / sizeof(KEYCODE_ARRAY
[0]));
577 //-----------------------------------------------
578 // seems to be needed to layout the list box, which shows all
579 // assignable shortcuts
580 static long AccCfgTabs
[] =
587 //-----------------------------------------------
588 class SfxAccCfgLBoxString_Impl
: public SvLBoxString
591 SfxAccCfgLBoxString_Impl( SvLBoxEntry
* pEntry
,
593 const String
& sText
);
595 virtual ~SfxAccCfgLBoxString_Impl();
597 virtual void Paint(const Point
& aPos
,
600 SvLBoxEntry
* pEntry
);
603 //-----------------------------------------------
604 SfxAccCfgLBoxString_Impl::SfxAccCfgLBoxString_Impl( SvLBoxEntry
* pEntry
,
606 const String
& sText
)
607 : SvLBoxString(pEntry
, nFlags
, sText
)
611 //-----------------------------------------------
612 SfxAccCfgLBoxString_Impl::~SfxAccCfgLBoxString_Impl()
616 //-----------------------------------------------
617 void SfxAccCfgLBoxString_Impl::Paint(const Point
& aPos
,
619 sal_uInt16
/*nFlags*/,
620 SvLBoxEntry
* pEntry
)
622 /*/ ??? realy needed !!!
623 Font aOldFont(rDevice.GetFont());
624 Font aNewFont(aOldFont );
625 rDevice.SetFont( aFont );
631 TAccInfo
* pUserData
= (TAccInfo
*)pEntry
->GetUserData();
635 if (pUserData
->m_bIsConfigurable
)
636 rDevice
.DrawText(aPos
, GetText());
638 rDevice
.DrawCtrlText(aPos
, GetText(), 0, STRING_LEN
, TEXT_DRAW_DISABLE
);
640 //rDev.SetFont( aOldFont );
643 //-----------------------------------------------
644 void SfxAccCfgTabListBox_Impl::InitEntry( SvLBoxEntry
* pEntry
,
645 const XubString
& sText
,
646 const Image
& aImage1
,
647 const Image
& aImage2
,
648 SvLBoxButtonKind eButtonKind
)
650 SvTabListBox::InitEntry(pEntry
, sText
, aImage1
, aImage2
, eButtonKind
);
653 //-----------------------------------------------
654 /** select the entry, which match the current key input ... excepting
655 keys, which are used for the dialog itself.
657 void SfxAccCfgTabListBox_Impl::KeyInput(const KeyEvent
& aKey
)
659 KeyCode aCode1
= aKey
.GetKeyCode();
660 sal_uInt16 nCode1
= aCode1
.GetCode();
661 sal_uInt16 nMod1
= aCode1
.GetModifier();
663 // is it related to our list box ?
665 (nCode1
!= KEY_DOWN
) &&
666 (nCode1
!= KEY_UP
) &&
667 (nCode1
!= KEY_LEFT
) &&
668 (nCode1
!= KEY_RIGHT
) &&
669 (nCode1
!= KEY_PAGEUP
) &&
670 (nCode1
!= KEY_PAGEDOWN
)
673 SvLBoxEntry
* pEntry
= First();
676 TAccInfo
* pUserData
= (TAccInfo
*)pEntry
->GetUserData();
679 sal_uInt16 nCode2
= pUserData
->m_aKey
.GetCode();
680 sal_uInt16 nMod2
= pUserData
->m_aKey
.GetModifier();
682 (nCode1
== nCode2
) &&
691 pEntry
= Next(pEntry
);
695 // no - handle it as normal dialog input
696 SvTabListBox::KeyInput(aKey
);
699 //-----------------------------------------------
700 SfxAcceleratorConfigPage::SfxAcceleratorConfigPage( Window
* pParent
, const SfxItemSet
& aSet
)
701 : SfxTabPage (pParent
, CUI_RES(RID_SVXPAGE_KEYBOARD
), aSet
)
702 , m_pMacroInfoItem ()
706 , aEntriesBox (this , this, CUI_RES(BOX_ACC_ENTRIES
))
707 , aKeyboardGroup (this , CUI_RES(GRP_ACC_KEYBOARD
))
708 , aOfficeButton (this , CUI_RES(RB_OFFICE
))
709 , aModuleButton (this , CUI_RES(RB_MODULE
))
710 , aChangeButton (this , CUI_RES(BTN_ACC_CHANGE
))
711 , aRemoveButton (this , CUI_RES(BTN_ACC_REMOVE
))
712 , aGroupText (this , CUI_RES(TXT_ACC_GROUP
))
713 , pGroupLBox(new SfxConfigGroupListBox_Impl( this, CUI_RES(BOX_ACC_GROUP
), SFX_SLOT_ACCELCONFIG
))
714 , aFunctionText (this , CUI_RES(TXT_ACC_FUNCTION
))
715 , pFunctionBox(new SfxConfigFunctionListBox_Impl( this, CUI_RES( BOX_ACC_FUNCTION
)))
716 , aKeyText (this , CUI_RES(TXT_ACC_KEY
))
717 , aKeyBox (this , CUI_RES(BOX_ACC_KEY
))
718 , aFunctionsGroup (this , CUI_RES(GRP_ACC_FUNCTIONS
))
719 , aLoadButton (this , CUI_RES(BTN_LOAD
))
720 , aSaveButton (this , CUI_RES(BTN_SAVE
))
721 , aResetButton (this , CUI_RES(BTN_RESET
))
722 , aLoadAccelConfigStr ( CUI_RES( STR_LOADACCELCONFIG
) )
723 , aSaveAccelConfigStr ( CUI_RES( STR_SAVEACCELCONFIG
) )
724 , aFilterCfgStr ( CUI_RES( STR_FILTERNAME_CFG
) )
725 , m_bStylesInfoInitialized(sal_False
)
732 aFilterAllStr
= String( SfxResId( STR_SFX_FILTERNAME_ALL
) );
734 // install handler functions
735 aChangeButton
.SetClickHdl( LINK( this, SfxAcceleratorConfigPage
, ChangeHdl
));
736 aRemoveButton
.SetClickHdl( LINK( this, SfxAcceleratorConfigPage
, RemoveHdl
));
737 aEntriesBox
.SetSelectHdl ( LINK( this, SfxAcceleratorConfigPage
, SelectHdl
));
738 pGroupLBox
->SetSelectHdl ( LINK( this, SfxAcceleratorConfigPage
, SelectHdl
));
739 pFunctionBox
->SetSelectHdl( LINK( this, SfxAcceleratorConfigPage
, SelectHdl
));
740 aKeyBox
.SetSelectHdl ( LINK( this, SfxAcceleratorConfigPage
, SelectHdl
));
741 aLoadButton
.SetClickHdl ( LINK( this, SfxAcceleratorConfigPage
, Load
));
742 aSaveButton
.SetClickHdl ( LINK( this, SfxAcceleratorConfigPage
, Save
));
743 aResetButton
.SetClickHdl ( LINK( this, SfxAcceleratorConfigPage
, Default
));
744 aOfficeButton
.SetClickHdl( LINK( this, SfxAcceleratorConfigPage
, RadioHdl
));
745 aModuleButton
.SetClickHdl( LINK( this, SfxAcceleratorConfigPage
, RadioHdl
));
747 // initialize Entriesbox
748 aEntriesBox
.SetStyle(aEntriesBox
.GetStyle()|WB_HSCROLL
|WB_CLIPCHILDREN
);
749 aEntriesBox
.SetSelectionMode(SINGLE_SELECTION
);
750 aEntriesBox
.SetTabs(&AccCfgTabs
[0], MAP_APPFONT
);
751 aEntriesBox
.Resize(); // OS: Hack for right selection
752 aEntriesBox
.SetSpaceBetweenEntries(0);
753 aEntriesBox
.SetDragDropMode(0);
755 // detect max keyname width
757 for ( sal_uInt16 i
= 0; i
< KEYCODE_ARRAY_SIZE
; ++i
)
759 long nTmp
= GetTextWidth( KeyCode( KEYCODE_ARRAY
[i
] ).GetName() );
760 if ( nTmp
> nMaxWidth
)
764 long nNewTab
= PixelToLogic( Size( nMaxWidth
, 0 ), MAP_APPFONT
).Width();
765 nNewTab
= nNewTab
+ 5; // additional space
766 aEntriesBox
.SetTab( 1, nNewTab
);
768 // initialize GroupBox
769 pGroupLBox
->SetFunctionListBox(pFunctionBox
);
772 aKeyBox
.SetStyle(aKeyBox
.GetStyle()|WB_CLIPCHILDREN
|WB_HSCROLL
|WB_SORT
);
775 //-----------------------------------------------
776 SfxAcceleratorConfigPage::~SfxAcceleratorConfigPage()
778 // free memory - remove all dynamic user data
779 SvLBoxEntry
* pEntry
= aEntriesBox
.First();
782 TAccInfo
* pUserData
= (TAccInfo
*)pEntry
->GetUserData();
785 pEntry
= aEntriesBox
.Next(pEntry
);
788 pEntry
= aKeyBox
.First();
791 TAccInfo
* pUserData
= (TAccInfo
*)pEntry
->GetUserData();
794 pEntry
= aKeyBox
.Next(pEntry
);
805 //-----------------------------------------------
806 void SfxAcceleratorConfigPage::InitAccCfg()
808 // already initialized ?
810 return; // yes -> do nothing
814 // no - initialize this instance
815 m_xSMGR
= ::utl::getProcessServiceFactory();
817 m_xUICmdDescription
= css::uno::Reference
< css::container::XNameAccess
>(m_xSMGR
->createInstance(SERVICE_UICMDDESCRIPTION
), css::uno::UNO_QUERY_THROW
);
819 // get the current active frame, which should be our "parent"
821 m_xFrame
= GetFrame();
822 if ( !m_xFrame
.is() )
824 css::uno::Reference
< css::frame::XFramesSupplier
> xDesktop(m_xSMGR
->createInstance(SERVICE_DESKTOP
), css::uno::UNO_QUERY_THROW
);
825 m_xFrame
= xDesktop
->getActiveFrame();
829 css::uno::Reference
< css::frame::XModuleManager
> xModuleManager (m_xSMGR
->createInstance(SERVICE_MODULEMANAGER
), css::uno::UNO_QUERY_THROW
);
830 css::uno::Reference
< css::container::XNameAccess
> xModuleManagerCont(xModuleManager
, css::uno::UNO_QUERY_THROW
);
831 m_sModuleLongName
= xModuleManager
->identify(m_xFrame
);
832 ::comphelper::SequenceAsHashMap
lModuleProps(xModuleManagerCont
->getByName(m_sModuleLongName
));
833 m_sModuleShortName
= lModuleProps
.getUnpackedValueOrDefault(MODULEPROP_SHORTNAME
, ::rtl::OUString());
834 m_sModuleUIName
= lModuleProps
.getUnpackedValueOrDefault(MODULEPROP_UINAME
, ::rtl::OUString());
836 // get global accelerator configuration
837 m_xGlobal
= css::uno::Reference
< css::ui::XAcceleratorConfiguration
>(m_xSMGR
->createInstance(SERVICE_GLOBALACCCFG
), css::uno::UNO_QUERY_THROW
);
839 // get module accelerator configuration
840 css::uno::Reference
< css::ui::XModuleUIConfigurationManagerSupplier
> xModuleCfgSupplier(m_xSMGR
->createInstance(SERVICE_MODULEUICONFIGSUPPLIER
), css::uno::UNO_QUERY_THROW
);
841 css::uno::Reference
< css::ui::XUIConfigurationManager
> xUICfgManager
= xModuleCfgSupplier
->getUIConfigurationManager(m_sModuleLongName
);
842 m_xModule
= css::uno::Reference
< css::ui::XAcceleratorConfiguration
>(xUICfgManager
->getShortCutManager(), css::uno::UNO_QUERY_THROW
);
844 catch(const css::uno::RuntimeException
& exRun
)
846 catch(const css::uno::Exception
&)
850 //-----------------------------------------------
851 /** Initialize text columns with own class to enable custom painting
852 This is needed as we have to paint disabled entries by ourself. No support for that in the
853 original SvTabListBox!
855 void SfxAcceleratorConfigPage::CreateCustomItems( SvLBoxEntry
* pEntry
,
856 const String
& sCol1
,
857 const String
& sCol2
)
859 SfxAccCfgLBoxString_Impl
* pStringItem
= new SfxAccCfgLBoxString_Impl(pEntry
, 0, sCol1
);
860 pEntry
->ReplaceItem(pStringItem
, 1);
862 pStringItem
= new SfxAccCfgLBoxString_Impl(pEntry
, 0, sCol2
);
863 pEntry
->ReplaceItem(pStringItem
, 2);
866 //-----------------------------------------------
867 void SfxAcceleratorConfigPage::Init(const css::uno::Reference
< css::ui::XAcceleratorConfiguration
>& xAccMgr
)
872 if (!m_bStylesInfoInitialized
)
874 css::uno::Reference
< css::frame::XController
> xController
;
875 css::uno::Reference
< css::frame::XModel
> xModel
;
877 xController
= m_xFrame
->getController();
878 if (xController
.is())
879 xModel
= xController
->getModel();
881 m_aStylesInfo
.setModel(xModel
);
882 pFunctionBox
->SetStylesInfo(&m_aStylesInfo
);
883 pGroupLBox
->SetStylesInfo(&m_aStylesInfo
);
884 m_bStylesInfoInitialized
= sal_True
;
887 // Insert all editable accelerators into list box. It is possible
888 // that some accelerators are not mapped on the current system/keyboard
889 // but we don't want to lose these mappings.
890 sal_uInt16 c1
= KEYCODE_ARRAY_SIZE
;
892 sal_uInt16 nListPos
= 0;
893 for (i1
=0; i1
<c1
; ++i1
)
895 KeyCode aKey
= KEYCODE_ARRAY
[i1
];
896 String sKey
= aKey
.GetName();
899 TAccInfo
* pEntry
= new TAccInfo(i1
, nListPos
, aKey
);
900 SvLBoxEntry
* pLBEntry
= aEntriesBox
.InsertEntryToColumn(sKey
, 0L, LIST_APPEND
, 0xFFFF);
901 pLBEntry
->SetUserData(pEntry
);
904 // Assign all commands to its shortcuts - reading the accelerator config.
905 css::uno::Sequence
< css::awt::KeyEvent
> lKeys
= xAccMgr
->getAllKeyEvents();
906 sal_Int32 c2
= lKeys
.getLength();
908 sal_uInt16 nCol
= aEntriesBox
.TabCount()-1;
910 for (i2
=0; i2
<c2
; ++i2
)
912 const css::awt::KeyEvent
& aAWTKey
= lKeys
[i2
];
913 ::rtl::OUString sCommand
= xAccMgr
->getCommandByKeyEvent(aAWTKey
);
914 String sLabel
= GetLabel4Command(sCommand
);
915 KeyCode aKeyCode
= ::svt::AcceleratorExecute::st_AWTKey2VCLKey(aAWTKey
);
916 sal_uInt16 nPos
= MapKeyCodeToPos(aKeyCode
);
918 if (nPos
== LISTBOX_ENTRY_NOTFOUND
)
921 aEntriesBox
.SetEntryText(sLabel
, nPos
, nCol
);
923 SvLBoxEntry
* pLBEntry
= aEntriesBox
.GetEntry(0, nPos
);
924 TAccInfo
* pEntry
= (TAccInfo
*)pLBEntry
->GetUserData();
926 pEntry
->m_bIsConfigurable
= sal_True
;
927 pEntry
->m_sCommand
= sCommand
;
928 CreateCustomItems(pLBEntry
, aEntriesBox
.GetEntryText(pLBEntry
, 0), sLabel
);
931 // Map the VCL hardcoded key codes and mark them as not changeable
932 sal_uLong c3
= Application::GetReservedKeyCodeCount();
934 for (i3
=0; i3
<c3
; ++i3
)
936 const KeyCode
* pKeyCode
= Application::GetReservedKeyCode(i3
);
937 sal_uInt16 nPos
= MapKeyCodeToPos(*pKeyCode
);
939 if (nPos
== LISTBOX_ENTRY_NOTFOUND
)
942 // Hardcoded function mapped so no ID possible and mark entry as not changeable
943 SvLBoxEntry
* pLBEntry
= aEntriesBox
.GetEntry(0, nPos
);
944 TAccInfo
* pEntry
= (TAccInfo
*)pLBEntry
->GetUserData();
946 pEntry
->m_bIsConfigurable
= sal_False
;
947 CreateCustomItems(pLBEntry
, aEntriesBox
.GetEntryText(pLBEntry
, 0), String());
951 //-----------------------------------------------
952 void SfxAcceleratorConfigPage::Apply(const css::uno::Reference
< css::ui::XAcceleratorConfiguration
>& xAccMgr
)
957 // Go through the list from the bottom to the top ...
958 // because logical accelerator must be preferred instead of
960 SvLBoxEntry
* pEntry
= aEntriesBox
.First();
963 TAccInfo
* pUserData
= (TAccInfo
*)pEntry
->GetUserData();
964 ::rtl::OUString sCommand
;
965 css::awt::KeyEvent aAWTKey
;
969 sCommand
= pUserData
->m_sCommand
;
970 aAWTKey
= ::svt::AcceleratorExecute::st_VCLKey2AWTKey(pUserData
->m_aKey
);
975 if (sCommand
.getLength())
976 xAccMgr
->setKeyEvent(aAWTKey
, sCommand
);
978 xAccMgr
->removeKeyEvent(aAWTKey
);
980 catch(const css::uno::RuntimeException
& exRun
)
982 catch(const css::uno::Exception
&)
985 pEntry
= aEntriesBox
.Next(pEntry
);
989 //-----------------------------------------------
990 void SfxAcceleratorConfigPage::ResetConfig()
995 //-----------------------------------------------
996 IMPL_LINK( SfxAcceleratorConfigPage
, Load
, Button
*, EMPTYARG
)
998 // ask for filename, where we should load the new config data from
999 StartFileDialog( WB_OPEN
| WB_STDMODAL
| WB_3DLOOK
, aLoadAccelConfigStr
);
1003 //-----------------------------------------------
1004 IMPL_LINK( SfxAcceleratorConfigPage
, Save
, Button
*, EMPTYARG
)
1006 StartFileDialog( WB_SAVEAS
| WB_STDMODAL
| WB_3DLOOK
, aLoadAccelConfigStr
);
1010 //-----------------------------------------------
1011 IMPL_LINK(SfxAcceleratorConfigPage
, Default
, PushButton
*, EMPTYARG
)
1013 css::uno::Reference
< css::form::XReset
> xReset(m_xAct
, css::uno::UNO_QUERY
);
1017 aEntriesBox
.SetUpdateMode(sal_False
);
1020 aEntriesBox
.SetUpdateMode(sal_True
);
1021 aEntriesBox
.Invalidate();
1022 aEntriesBox
.Select(aEntriesBox
.GetEntry(0, 0));
1027 //-----------------------------------------------
1028 IMPL_LINK( SfxAcceleratorConfigPage
, ChangeHdl
, Button
*, EMPTYARG
)
1030 sal_uInt16 nPos
= (sal_uInt16
) aEntriesBox
.GetModel()->GetRelPos( aEntriesBox
.FirstSelected() );
1031 TAccInfo
* pEntry
= (TAccInfo
*)aEntriesBox
.GetEntry(0, nPos
)->GetUserData();
1032 String sNewCommand
= pFunctionBox
->GetCurCommand();
1033 String sLabel
= pFunctionBox
->GetCurLabel();
1035 sLabel
= GetLabel4Command(sNewCommand
);
1037 pEntry
->m_sCommand
= sNewCommand
;
1038 sal_uInt16 nCol
= aEntriesBox
.TabCount() - 1;
1039 aEntriesBox
.SetEntryText(sLabel
, nPos
, nCol
);
1041 ((Link
&) pFunctionBox
->GetSelectHdl()).Call( pFunctionBox
);
1045 //-----------------------------------------------
1046 IMPL_LINK( SfxAcceleratorConfigPage
, RemoveHdl
, Button
*, EMPTYARG
)
1048 // get selected entry
1049 sal_uInt16 nPos
= (sal_uInt16
) aEntriesBox
.GetModel()->GetRelPos( aEntriesBox
.FirstSelected() );
1050 TAccInfo
* pEntry
= (TAccInfo
*)aEntriesBox
.GetEntry(0, nPos
)->GetUserData();
1052 // remove function name from selected entry
1053 sal_uInt16 nCol
= aEntriesBox
.TabCount() - 1;
1054 aEntriesBox
.SetEntryText( String(), nPos
, nCol
);
1055 pEntry
->m_sCommand
= ::rtl::OUString();
1057 ((Link
&) pFunctionBox
->GetSelectHdl()).Call( pFunctionBox
);
1061 //-----------------------------------------------
1062 IMPL_LINK( SfxAcceleratorConfigPage
, SelectHdl
, Control
*, pListBox
)
1065 Help::ShowBalloon( this, Point(), String() );
1066 if ( pListBox
== &aEntriesBox
)
1068 sal_uInt16 nPos
= (sal_uInt16
) aEntriesBox
.GetModel()->GetRelPos( aEntriesBox
.FirstSelected() );
1069 TAccInfo
* pEntry
= (TAccInfo
*)aEntriesBox
.GetEntry(0, nPos
)->GetUserData();
1070 ::rtl::OUString sPossibleNewCommand
= pFunctionBox
->GetCurCommand();
1072 aRemoveButton
.Enable( sal_False
);
1073 aChangeButton
.Enable( sal_False
);
1075 if (pEntry
->m_bIsConfigurable
)
1077 if (pEntry
->isConfigured())
1078 aRemoveButton
.Enable( sal_True
);
1079 aChangeButton
.Enable( pEntry
->m_sCommand
!= sPossibleNewCommand
);
1082 else if ( pListBox
== pGroupLBox
)
1084 pGroupLBox
->GroupSelected();
1085 if ( !pFunctionBox
->FirstSelected() )
1086 aChangeButton
.Enable( sal_False
);
1088 else if ( pListBox
== pFunctionBox
)
1090 aRemoveButton
.Enable( sal_False
);
1091 aChangeButton
.Enable( sal_False
);
1093 // #i36994 First selected can return zero!
1094 SvLBoxEntry
* pLBEntry
= aEntriesBox
.FirstSelected();
1095 if ( pLBEntry
!= 0 )
1097 sal_uInt16 nPos
= (sal_uInt16
) aEntriesBox
.GetModel()->GetRelPos( pLBEntry
);
1098 TAccInfo
* pEntry
= (TAccInfo
*)aEntriesBox
.GetEntry(0, nPos
)->GetUserData();
1099 ::rtl::OUString sPossibleNewCommand
= pFunctionBox
->GetCurCommand();
1101 if (pEntry
->m_bIsConfigurable
)
1103 if (pEntry
->isConfigured())
1104 aRemoveButton
.Enable( sal_True
);
1105 aChangeButton
.Enable( pEntry
->m_sCommand
!= sPossibleNewCommand
);
1110 SvLBoxEntry
* pIt
= aEntriesBox
.First();
1113 TAccInfo
* pUserData
= (TAccInfo
*)pIt
->GetUserData();
1114 if ( pUserData
&& pUserData
->m_sCommand
== sPossibleNewCommand
)
1116 TAccInfo
* pU1
= new TAccInfo(-1, -1, pUserData
->m_aKey
);
1117 SvLBoxEntry
* pE1
= aKeyBox
.InsertEntry( pUserData
->m_aKey
.GetName(), 0L, sal_True
, LIST_APPEND
);
1118 pE1
->SetUserData(pU1
);
1119 pE1
->EnableChildsOnDemand( sal_False
);
1121 pIt
= aEntriesBox
.Next(pIt
);
1127 // goto selected "key" entry of the key box
1128 SvLBoxEntry
* pE2
= 0;
1130 sal_uInt16 nP2
= LISTBOX_ENTRY_NOTFOUND
;
1131 SvLBoxEntry
* pE3
= 0;
1133 pE2
= aKeyBox
.FirstSelected();
1135 pU2
= (TAccInfo
*)pE2
->GetUserData();
1137 nP2
= MapKeyCodeToPos(pU2
->m_aKey
);
1138 if (nP2
!= LISTBOX_ENTRY_NOTFOUND
)
1139 pE3
= aEntriesBox
.GetEntry( 0, nP2
);
1142 aEntriesBox
.Select( pE3
);
1143 aEntriesBox
.MakeVisible( pE3
);
1150 //-----------------------------------------------
1151 IMPL_LINK( SfxAcceleratorConfigPage
, RadioHdl
, RadioButton
*, EMPTYARG
)
1153 css::uno::Reference
< css::ui::XAcceleratorConfiguration
> xOld
= m_xAct
;
1155 if (aOfficeButton
.IsChecked())
1157 else if (aModuleButton
.IsChecked())
1160 // nothing changed? => do nothing!
1161 if ( m_xAct
.is() && ( xOld
== m_xAct
) )
1164 aEntriesBox
.SetUpdateMode( sal_False
);
1167 aEntriesBox
.SetUpdateMode( sal_True
);
1168 aEntriesBox
.Invalidate();
1170 pGroupLBox
->Init(m_xSMGR
, m_xFrame
, m_sModuleLongName
);
1172 // pb: #133213# do not select NULL entries
1173 SvLBoxEntry
* pEntry
= aEntriesBox
.GetEntry( 0, 0 );
1175 aEntriesBox
.Select( pEntry
);
1176 pEntry
= pGroupLBox
->GetEntry( 0, 0 );
1178 pGroupLBox
->Select( pEntry
);
1180 ((Link
&) pFunctionBox
->GetSelectHdl()).Call( pFunctionBox
);
1184 //-----------------------------------------------
1185 IMPL_LINK( SfxAcceleratorConfigPage
, LoadHdl
, sfx2::FileDialogHelper
*, EMPTYARG
)
1187 DBG_ASSERT( m_pFileDlg
, "SfxInternetPage::DialogClosedHdl(): no file dialog" );
1189 ::rtl::OUString sCfgName
;
1190 if ( ERRCODE_NONE
== m_pFileDlg
->GetError() )
1191 sCfgName
= m_pFileDlg
->GetPath();
1193 if ( !sCfgName
.getLength() )
1196 GetTabDialog()->EnterWait();
1198 css::uno::Reference
< css::frame::XModel
> xDoc
;
1199 css::uno::Reference
< css::ui::XUIConfigurationManager
> xCfgMgr
;
1200 css::uno::Reference
< css::embed::XStorage
> xRootStorage
; // we must hold the root storage alive, if xCfgMgr is used!
1204 // first check if URL points to a document already loaded
1205 xDoc
= SearchForAlreadyLoadedDoc(sCfgName
);
1208 // Get ui config manager. There should always be one at the model.
1209 css::uno::Reference
< css::ui::XUIConfigurationManagerSupplier
> xCfgSupplier(xDoc
, css::uno::UNO_QUERY_THROW
);
1210 xCfgMgr
= xCfgSupplier
->getUIConfigurationManager();
1214 // URL doesn't point to a loaded document, try to access it as a single storage
1215 // dont forget to release the storage afterwards!
1216 css::uno::Reference
< css::lang::XSingleServiceFactory
> xStorageFactory(m_xSMGR
->createInstance(SERVICE_STORAGEFACTORY
), css::uno::UNO_QUERY_THROW
);
1217 css::uno::Sequence
< css::uno::Any
> lArgs(2);
1218 lArgs
[0] <<= sCfgName
;
1219 lArgs
[1] <<= css::embed::ElementModes::READ
;
1221 xRootStorage
= css::uno::Reference
< css::embed::XStorage
>(xStorageFactory
->createInstanceWithArguments(lArgs
), css::uno::UNO_QUERY_THROW
);
1222 css::uno::Reference
< css::embed::XStorage
> xUIConfig
= xRootStorage
->openStorageElement(FOLDERNAME_UICONFIG
, css::embed::ElementModes::READ
);
1225 xCfgMgr
= css::uno::Reference
< css::ui::XUIConfigurationManager
>(m_xSMGR
->createInstance(SERVICE_UICONFIGMGR
), css::uno::UNO_QUERY_THROW
);
1226 css::uno::Reference
< css::ui::XUIConfigurationStorage
> xCfgMgrStore(xCfgMgr
, css::uno::UNO_QUERY_THROW
);
1227 xCfgMgrStore
->setStorage(xUIConfig
);
1233 // open the configuration and update our UI
1234 css::uno::Reference
< css::ui::XAcceleratorConfiguration
> xTempAccMgr(xCfgMgr
->getShortCutManager(), css::uno::UNO_QUERY_THROW
);
1236 aEntriesBox
.SetUpdateMode(sal_False
);
1239 aEntriesBox
.SetUpdateMode(sal_True
);
1240 aEntriesBox
.Invalidate();
1241 aEntriesBox
.Select(aEntriesBox
.GetEntry(0, 0));
1245 // dont forget to close the new opened storage!
1246 // We are the owner of it.
1247 if (xRootStorage
.is())
1249 css::uno::Reference
< css::lang::XComponent
> xComponent
;
1250 xComponent
= css::uno::Reference
< css::lang::XComponent
>(xCfgMgr
, css::uno::UNO_QUERY
);
1251 if (xComponent
.is())
1252 xComponent
->dispose();
1253 xComponent
= css::uno::Reference
< css::lang::XComponent
>(xRootStorage
, css::uno::UNO_QUERY
);
1254 if (xComponent
.is())
1255 xComponent
->dispose();
1258 catch(const css::uno::RuntimeException
& exRun
)
1260 catch(const css::uno::Exception
&)
1263 GetTabDialog()->LeaveWait();
1268 //-----------------------------------------------
1269 IMPL_LINK( SfxAcceleratorConfigPage
, SaveHdl
, sfx2::FileDialogHelper
*, EMPTYARG
)
1271 DBG_ASSERT( m_pFileDlg
, "SfxInternetPage::DialogClosedHdl(): no file dialog" );
1273 ::rtl::OUString sCfgName
;
1274 if ( ERRCODE_NONE
== m_pFileDlg
->GetError() )
1275 sCfgName
= m_pFileDlg
->GetPath();
1277 if ( !sCfgName
.getLength() )
1280 GetTabDialog()->EnterWait();
1282 css::uno::Reference
< css::frame::XModel
> xDoc
;
1283 css::uno::Reference
< css::ui::XUIConfigurationManager
> xCfgMgr
;
1284 css::uno::Reference
< css::embed::XStorage
> xRootStorage
;
1288 // first check if URL points to a document already loaded
1289 xDoc
= SearchForAlreadyLoadedDoc(sCfgName
);
1292 // get config manager, force creation if there was none before
1293 css::uno::Reference
< css::ui::XUIConfigurationManagerSupplier
> xCfgSupplier(xDoc
, css::uno::UNO_QUERY_THROW
);
1294 xCfgMgr
= xCfgSupplier
->getUIConfigurationManager();
1298 // URL doesn't point to a loaded document, try to access it as a single storage
1299 css::uno::Reference
< css::lang::XSingleServiceFactory
> xStorageFactory(m_xSMGR
->createInstance(SERVICE_STORAGEFACTORY
), css::uno::UNO_QUERY_THROW
);
1300 css::uno::Sequence
< css::uno::Any
> lArgs(2);
1301 lArgs
[0] <<= sCfgName
;
1302 lArgs
[1] <<= css::embed::ElementModes::WRITE
;
1304 xRootStorage
= css::uno::Reference
< css::embed::XStorage
>(
1305 xStorageFactory
->createInstanceWithArguments(lArgs
),
1306 css::uno::UNO_QUERY_THROW
);
1308 css::uno::Reference
< css::embed::XStorage
> xUIConfig(
1309 xRootStorage
->openStorageElement(FOLDERNAME_UICONFIG
, css::embed::ElementModes::WRITE
),
1310 css::uno::UNO_QUERY_THROW
);
1311 css::uno::Reference
< css::beans::XPropertySet
> xUIConfigProps(
1313 css::uno::UNO_QUERY_THROW
);
1315 // set the correct media type if the storage was new created
1316 ::rtl::OUString sMediaType
;
1317 xUIConfigProps
->getPropertyValue(MEDIATYPE_PROPNAME
) >>= sMediaType
;
1318 if (!sMediaType
.getLength())
1319 xUIConfigProps
->setPropertyValue(MEDIATYPE_PROPNAME
, css::uno::makeAny(MEDIATYPE_UICONFIG
));
1321 xCfgMgr
= css::uno::Reference
< css::ui::XUIConfigurationManager
>(m_xSMGR
->createInstance(SERVICE_UICONFIGMGR
), css::uno::UNO_QUERY_THROW
);
1322 css::uno::Reference
< css::ui::XUIConfigurationStorage
> xUICfgStore(xCfgMgr
, css::uno::UNO_QUERY_THROW
);
1323 xUICfgStore
->setStorage(xUIConfig
);
1328 // get the target configuration access and update with all shortcuts
1329 // which are set currently at the UI !
1330 // Dont copy the m_xAct content to it ... because m_xAct will be updated
1331 // from the UI on pressing the button "OK" only. And inbetween it's not up to date !
1332 css::uno::Reference
< css::ui::XAcceleratorConfiguration
> xTargetAccMgr(xCfgMgr
->getShortCutManager(), css::uno::UNO_QUERY_THROW
);
1333 Apply(xTargetAccMgr
);
1335 // commit (order is important!)
1336 css::uno::Reference
< css::ui::XUIConfigurationPersistence
> xCommit1(xTargetAccMgr
, css::uno::UNO_QUERY_THROW
);
1337 css::uno::Reference
< css::ui::XUIConfigurationPersistence
> xCommit2(xCfgMgr
, css::uno::UNO_QUERY_THROW
);
1341 if (xRootStorage
.is())
1343 // Commit root storage
1344 css::uno::Reference
< css::embed::XTransactedObject
> xCommit3(xRootStorage
, css::uno::UNO_QUERY_THROW
);
1349 if (xRootStorage
.is())
1351 css::uno::Reference
< css::lang::XComponent
> xComponent
;
1352 xComponent
= css::uno::Reference
< css::lang::XComponent
>(xCfgMgr
, css::uno::UNO_QUERY
);
1353 if (xComponent
.is())
1354 xComponent
->dispose();
1355 xComponent
= css::uno::Reference
< css::lang::XComponent
>(xRootStorage
, css::uno::UNO_QUERY
);
1356 if (xComponent
.is())
1357 xComponent
->dispose();
1360 catch(const css::uno::RuntimeException
& exRun
)
1362 catch(const css::uno::Exception
&)
1365 GetTabDialog()->LeaveWait();
1370 //-----------------------------------------------
1371 void SfxAcceleratorConfigPage::StartFileDialog( WinBits nBits
, const String
& rTitle
)
1373 bool bSave
= ( ( nBits
& WB_SAVEAS
) == WB_SAVEAS
);
1374 short nDialogType
= bSave
? css::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE
1375 : css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE
;
1378 m_pFileDlg
= new sfx2::FileDialogHelper( nDialogType
, 0 );
1380 m_pFileDlg
->SetTitle( rTitle
);
1381 m_pFileDlg
->AddFilter( aFilterAllStr
, DEFINE_CONST_UNICODE( FILEDIALOG_FILTER_ALL
) );
1382 m_pFileDlg
->AddFilter( aFilterCfgStr
, DEFINE_CONST_UNICODE( "*.cfg" ) );
1384 Link aDlgClosedLink
= bSave
? LINK( this, SfxAcceleratorConfigPage
, SaveHdl
)
1385 : LINK( this, SfxAcceleratorConfigPage
, LoadHdl
);
1386 m_pFileDlg
->StartExecuteModal( aDlgClosedLink
);
1389 //-----------------------------------------------
1390 sal_Bool
SfxAcceleratorConfigPage::FillItemSet( SfxItemSet
& )
1397 catch(const css::uno::RuntimeException
& exRun
)
1399 catch(const css::uno::Exception
&)
1400 { return sal_False
; }
1405 //-----------------------------------------------
1406 void SfxAcceleratorConfigPage::Reset( const SfxItemSet
& rSet
)
1408 // open accelerator configs
1409 // Note: It initialize some other members too, which are needed here ...
1410 // e.g. m_sModuleUIName!
1413 // change te description of the radio button, which switch to the module
1414 // dependend accelerator configuration
1415 String sButtonText
= aModuleButton
.GetText();
1416 sButtonText
.SearchAndReplace(String::CreateFromAscii("$(MODULE)"), m_sModuleUIName
);
1417 aModuleButton
.SetText(sButtonText
);
1420 aModuleButton
.Check();
1423 aModuleButton
.Hide();
1424 aOfficeButton
.Check();
1429 const SfxPoolItem
* pMacroItem
=0;
1430 if( SFX_ITEM_SET
== rSet
.GetItemState( SID_MACROINFO
, sal_True
, &pMacroItem
) )
1432 m_pMacroInfoItem
= PTR_CAST( SfxMacroInfoItem
, pMacroItem
);
1433 pGroupLBox
->SelectMacro( m_pMacroInfoItem
);
1437 const SfxPoolItem
* pStringItem
=0;
1438 if( SFX_ITEM_SET
== rSet
.GetItemState( SID_CHARMAP
, sal_True
, &pStringItem
) )
1439 m_pStringItem
= PTR_CAST( SfxStringItem
, pStringItem
);
1441 const SfxPoolItem
* pFontItem
=0;
1442 if( SFX_ITEM_SET
== rSet
.GetItemState( SID_ATTR_SPECIALCHAR
, sal_True
, &pFontItem
) )
1443 m_pFontItem
= PTR_CAST( SfxStringItem
, pFontItem
);
1447 //-----------------------------------------------
1448 sal_uInt16
SfxAcceleratorConfigPage::MapKeyCodeToPos(const KeyCode
& aKey
) const
1450 sal_uInt16 nCode1
= aKey
.GetCode()+aKey
.GetModifier();
1451 SvLBoxEntry
* pEntry
= aEntriesBox
.First();
1456 TAccInfo
* pUserData
= (TAccInfo
*)pEntry
->GetUserData();
1459 sal_uInt16 nCode2
= pUserData
->m_aKey
.GetCode()+pUserData
->m_aKey
.GetModifier();
1460 if (nCode1
== nCode2
)
1463 pEntry
= aEntriesBox
.Next(pEntry
);
1467 return LISTBOX_ENTRY_NOTFOUND
;
1470 //-----------------------------------------------
1471 String
SfxAcceleratorConfigPage::GetLabel4Command(const String
& sCommand
)
1475 // check global command configuration first
1476 css::uno::Reference
< css::container::XNameAccess
> xModuleConf
;
1477 m_xUICmdDescription
->getByName(m_sModuleLongName
) >>= xModuleConf
;
1478 if (xModuleConf
.is())
1480 ::comphelper::SequenceAsHashMap
lProps(xModuleConf
->getByName(sCommand
));
1481 String sLabel
= String(lProps
.getUnpackedValueOrDefault(CMDPROP_UINAME
, ::rtl::OUString()));
1486 catch(const css::uno::RuntimeException
& exRun
)
1488 catch(const css::uno::Exception
&)
1491 // may be it's a style URL .. they must be handled special
1492 SfxStyleInfo_Impl aStyle
;
1493 aStyle
.sCommand
= sCommand
;
1494 if (m_aStylesInfo
.parseStyleCommand(aStyle
))
1496 m_aStylesInfo
.getLabel4Style(aStyle
);
1497 return aStyle
.sLabel
;
1501 String
aRet( String::CreateFromAscii("Symbols: ") );
1502 xub_StrLen nPos
= sCommand
.SearchAscii(".uno:InsertSymbol?Symbols:string=");
1505 aRet
+= String( sCommand
, 34, sCommand
.Len()-34 );
1513 SfxTabPage
* SfxAcceleratorConfigPage::Create( Window
* pParent
, const SfxItemSet
& rAttrSet
)
1515 return new SfxAcceleratorConfigPage( pParent
, rAttrSet
);
1518 //-----------------------------------------------
1519 css::uno::Reference
< css::frame::XModel
> SfxAcceleratorConfigPage::SearchForAlreadyLoadedDoc(const String
& /*sName*/)
1521 return css::uno::Reference
< css::frame::XModel
>();
1524 SvxShortcutAssignDlg::SvxShortcutAssignDlg( Window
* pParent
, const uno::Reference
< frame::XFrame
>& rxDocumentFrame
, const SfxItemSet
& rSet
)
1525 : SfxSingleTabDialog( pParent
, rSet
, 0 )
1527 SfxTabPage
* pPage
= SfxAcceleratorConfigPage::Create( this, rSet
);
1528 pPage
->SetFrame( rxDocumentFrame
);
1529 SetTabPage( pPage
);
1533 SvxShortcutAssignDlg::~SvxShortcutAssignDlg()
1538 // .uno:InsertSymbol?Symbols:string=bla