update dev300-m58
[ooovba.git] / svx / source / cui / acccfg.cxx
blob43e0bb5baea794c27fdad942d40f5a20a6d7e06e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: acccfg.cxx,v $
10 * $Revision: 1.40 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 //-----------------------------------------------
35 // include own files
37 #include "acccfg.hxx"
38 #include "cfgutil.hxx"
39 #include <svx/dialmgr.hxx>
41 #include <sfx2/msg.hxx>
42 #include <sfx2/macrconf.hxx>
43 #include <sfx2/app.hxx>
44 #include <sfx2/filedlghelper.hxx>
45 #include <sfx2/minfitem.hxx>
46 #include <svtools/stritem.hxx>
48 #include "svx/dialogs.hrc"
49 #include "acccfg.hrc"
51 //-----------------------------------------------
52 // include interface declarations
53 #include <com/sun/star/frame/XFramesSupplier.hpp>
54 #include <com/sun/star/frame/XFrame.hpp>
55 #include <com/sun/star/frame/XController.hpp>
56 #include <com/sun/star/frame/XModel.hpp>
57 #include <com/sun/star/form/XReset.hpp>
58 #include <com/sun/star/frame/XModuleManager.hpp>
59 #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
60 #include <com/sun/star/frame/XModuleManager.hpp>
62 #ifndef _COM_SUN_STAR_UI_XUICONFIGURATIONMANAGERSUPLLIER_HPP_
63 #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
64 #endif
65 #include <com/sun/star/ui/XUIConfigurationManager.hpp>
66 #include <com/sun/star/awt/KeyModifier.hpp>
67 #include <com/sun/star/embed/XTransactedObject.hpp>
68 #include <com/sun/star/embed/ElementModes.hpp>
70 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
72 //-----------------------------------------------
73 // include other projects
74 #include <unotools/processfactory.hxx>
75 #include <svtools/acceleratorexecute.hxx>
76 #include <comphelper/processfactory.hxx>
77 #include <svtools/svlbitm.hxx>
78 #include <vcl/svapp.hxx>
79 #include <vcl/help.hxx>
80 #include <rtl/ustrbuf.hxx>
81 #include <comphelper/sequenceashashmap.hxx>
83 //-----------------------------------------------
84 // namespaces
86 #ifdef css
87 #error "ambigous praeprozessor directive for css ..."
88 #else
89 namespace css = ::com::sun::star;
90 #endif
92 using namespace com::sun::star;
94 //-----------------------------------------------
95 // definitions
97 //-----------------------------------------------
98 static ::rtl::OUString SERVICE_STORAGEFACTORY = ::rtl::OUString::createFromAscii("com.sun.star.embed.StorageFactory" );
99 static ::rtl::OUString SERVICE_UICONFIGMGR = ::rtl::OUString::createFromAscii("com.sun.star.ui.UIConfigurationManager" );
100 static ::rtl::OUString SERVICE_DESKTOP = ::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop" );
101 static ::rtl::OUString SERVICE_MODULEMANAGER = ::rtl::OUString::createFromAscii("com.sun.star.frame.ModuleManager" );
102 static ::rtl::OUString SERVICE_GLOBALACCCFG = ::rtl::OUString::createFromAscii("com.sun.star.ui.GlobalAcceleratorConfiguration" );
103 static ::rtl::OUString SERVICE_MODULEUICONFIGSUPPLIER = ::rtl::OUString::createFromAscii("com.sun.star.ui.ModuleUIConfigurationManagerSupplier");
104 static ::rtl::OUString SERVICE_UICMDDESCRIPTION = ::rtl::OUString::createFromAscii("com.sun.star.frame.UICommandDescription" );
106 static ::rtl::OUString MODULEPROP_SHORTNAME = ::rtl::OUString::createFromAscii("ooSetupFactoryShortName" );
107 static ::rtl::OUString MODULEPROP_UINAME = ::rtl::OUString::createFromAscii("ooSetupFactoryUIName" );
108 static ::rtl::OUString CMDPROP_UINAME = ::rtl::OUString::createFromAscii("Name" );
110 static ::rtl::OUString FOLDERNAME_UICONFIG = ::rtl::OUString::createFromAscii("Configurations2" );
112 static ::rtl::OUString MEDIATYPE_PROPNAME = ::rtl::OUString::createFromAscii("MediaType" );
113 static ::rtl::OUString MEDIATYPE_UICONFIG = ::rtl::OUString::createFromAscii("application/vnd.sun.xml.ui.configuration" );
115 //-----------------------------------------------
116 static USHORT __FAR_DATA KEYCODE_ARRAY[] =
118 KEY_F1 ,
119 KEY_F2 ,
120 KEY_F3 ,
121 KEY_F4 ,
122 KEY_F5 ,
123 KEY_F6 ,
124 KEY_F7 ,
125 KEY_F8 ,
126 KEY_F9 ,
127 KEY_F10 ,
128 KEY_F11 ,
129 KEY_F12 ,
131 KEY_DOWN ,
132 KEY_UP ,
133 KEY_LEFT ,
134 KEY_RIGHT ,
135 KEY_HOME ,
136 KEY_END ,
137 KEY_PAGEUP ,
138 KEY_PAGEDOWN ,
139 KEY_RETURN ,
140 KEY_ESCAPE ,
141 KEY_BACKSPACE,
142 KEY_INSERT ,
143 KEY_DELETE ,
145 KEY_OPEN ,
146 KEY_CUT ,
147 KEY_COPY ,
148 KEY_PASTE ,
149 KEY_UNDO ,
150 KEY_REPEAT ,
151 KEY_FIND ,
152 KEY_PROPERTIES ,
153 KEY_FRONT ,
154 KEY_CONTEXTMENU ,
155 KEY_MENU ,
156 KEY_HELP ,
158 KEY_F1 | KEY_SHIFT,
159 KEY_F2 | KEY_SHIFT,
160 KEY_F3 | KEY_SHIFT,
161 KEY_F4 | KEY_SHIFT,
162 KEY_F5 | KEY_SHIFT,
163 KEY_F6 | KEY_SHIFT,
164 KEY_F7 | KEY_SHIFT,
165 KEY_F8 | KEY_SHIFT,
166 KEY_F9 | KEY_SHIFT,
167 KEY_F10 | KEY_SHIFT,
168 KEY_F11 | KEY_SHIFT,
169 KEY_F12 | KEY_SHIFT,
171 KEY_DOWN | KEY_SHIFT,
172 KEY_UP | KEY_SHIFT,
173 KEY_LEFT | KEY_SHIFT,
174 KEY_RIGHT | KEY_SHIFT,
175 KEY_HOME | KEY_SHIFT,
176 KEY_END | KEY_SHIFT,
177 KEY_PAGEUP | KEY_SHIFT,
178 KEY_PAGEDOWN | KEY_SHIFT,
179 KEY_RETURN | KEY_SHIFT,
180 KEY_SPACE | KEY_SHIFT,
181 KEY_ESCAPE | KEY_SHIFT,
182 KEY_BACKSPACE | KEY_SHIFT,
183 KEY_INSERT | KEY_SHIFT,
184 KEY_DELETE | KEY_SHIFT,
186 KEY_0 | KEY_MOD1 ,
187 KEY_1 | KEY_MOD1 ,
188 KEY_2 | KEY_MOD1 ,
189 KEY_3 | KEY_MOD1 ,
190 KEY_4 | KEY_MOD1 ,
191 KEY_5 | KEY_MOD1 ,
192 KEY_6 | KEY_MOD1 ,
193 KEY_7 | KEY_MOD1 ,
194 KEY_8 | KEY_MOD1 ,
195 KEY_9 | KEY_MOD1 ,
196 KEY_A | KEY_MOD1 ,
197 KEY_B | KEY_MOD1 ,
198 KEY_C | KEY_MOD1 ,
199 KEY_D | KEY_MOD1 ,
200 KEY_E | KEY_MOD1 ,
201 KEY_F | KEY_MOD1 ,
202 KEY_G | KEY_MOD1 ,
203 KEY_H | KEY_MOD1 ,
204 KEY_I | KEY_MOD1 ,
205 KEY_J | KEY_MOD1 ,
206 KEY_K | KEY_MOD1 ,
207 KEY_L | KEY_MOD1 ,
208 KEY_M | KEY_MOD1 ,
209 KEY_N | KEY_MOD1 ,
210 KEY_O | KEY_MOD1 ,
211 KEY_P | KEY_MOD1 ,
212 KEY_Q | KEY_MOD1 ,
213 KEY_R | KEY_MOD1 ,
214 KEY_S | KEY_MOD1 ,
215 KEY_T | KEY_MOD1 ,
216 KEY_U | KEY_MOD1 ,
217 KEY_V | KEY_MOD1 ,
218 KEY_W | KEY_MOD1 ,
219 KEY_X | KEY_MOD1 ,
220 KEY_Y | KEY_MOD1 ,
221 KEY_Z | KEY_MOD1 ,
223 KEY_F1 | KEY_MOD1 ,
224 KEY_F2 | KEY_MOD1 ,
225 KEY_F3 | KEY_MOD1 ,
226 KEY_F4 | KEY_MOD1 ,
227 KEY_F5 | KEY_MOD1 ,
228 KEY_F6 | KEY_MOD1 ,
229 KEY_F7 | KEY_MOD1 ,
230 KEY_F8 | KEY_MOD1 ,
231 KEY_F9 | KEY_MOD1 ,
232 KEY_F10 | KEY_MOD1 ,
233 KEY_F11 | KEY_MOD1 ,
234 KEY_F12 | KEY_MOD1 ,
236 KEY_DOWN | KEY_MOD1 ,
237 KEY_UP | KEY_MOD1 ,
238 KEY_LEFT | KEY_MOD1 ,
239 KEY_RIGHT | KEY_MOD1 ,
240 KEY_HOME | KEY_MOD1 ,
241 KEY_END | KEY_MOD1 ,
242 KEY_PAGEUP | KEY_MOD1 ,
243 KEY_PAGEDOWN | KEY_MOD1 ,
244 KEY_RETURN | KEY_MOD1 ,
245 KEY_SPACE | KEY_MOD1 ,
246 KEY_BACKSPACE | KEY_MOD1 ,
247 KEY_INSERT | KEY_MOD1 ,
248 KEY_DELETE | KEY_MOD1 ,
250 KEY_ADD | KEY_MOD1 ,
251 KEY_SUBTRACT | KEY_MOD1 ,
252 KEY_MULTIPLY | KEY_MOD1 ,
253 KEY_DIVIDE | KEY_MOD1 ,
255 KEY_0 | KEY_SHIFT | KEY_MOD1,
256 KEY_1 | KEY_SHIFT | KEY_MOD1,
257 KEY_2 | KEY_SHIFT | KEY_MOD1,
258 KEY_3 | KEY_SHIFT | KEY_MOD1,
259 KEY_4 | KEY_SHIFT | KEY_MOD1,
260 KEY_5 | KEY_SHIFT | KEY_MOD1,
261 KEY_6 | KEY_SHIFT | KEY_MOD1,
262 KEY_7 | KEY_SHIFT | KEY_MOD1,
263 KEY_8 | KEY_SHIFT | KEY_MOD1,
264 KEY_9 | KEY_SHIFT | KEY_MOD1,
265 KEY_A | KEY_SHIFT | KEY_MOD1,
266 KEY_B | KEY_SHIFT | KEY_MOD1,
267 KEY_C | KEY_SHIFT | KEY_MOD1,
268 KEY_D | KEY_SHIFT | KEY_MOD1,
269 KEY_E | KEY_SHIFT | KEY_MOD1,
270 KEY_F | KEY_SHIFT | KEY_MOD1,
271 KEY_G | KEY_SHIFT | KEY_MOD1,
272 KEY_H | KEY_SHIFT | KEY_MOD1,
273 KEY_I | KEY_SHIFT | KEY_MOD1,
274 KEY_J | KEY_SHIFT | KEY_MOD1,
275 KEY_K | KEY_SHIFT | KEY_MOD1,
276 KEY_L | KEY_SHIFT | KEY_MOD1,
277 KEY_M | KEY_SHIFT | KEY_MOD1,
278 KEY_N | KEY_SHIFT | KEY_MOD1,
279 KEY_O | KEY_SHIFT | KEY_MOD1,
280 KEY_P | KEY_SHIFT | KEY_MOD1,
281 KEY_Q | KEY_SHIFT | KEY_MOD1,
282 KEY_R | KEY_SHIFT | KEY_MOD1,
283 KEY_S | KEY_SHIFT | KEY_MOD1,
284 KEY_T | KEY_SHIFT | KEY_MOD1,
285 KEY_U | KEY_SHIFT | KEY_MOD1,
286 KEY_V | KEY_SHIFT | KEY_MOD1,
287 KEY_W | KEY_SHIFT | KEY_MOD1,
288 KEY_X | KEY_SHIFT | KEY_MOD1,
289 KEY_Y | KEY_SHIFT | KEY_MOD1,
290 KEY_Z | KEY_SHIFT | KEY_MOD1,
292 KEY_F1 | KEY_SHIFT | KEY_MOD1,
293 KEY_F2 | KEY_SHIFT | KEY_MOD1,
294 KEY_F3 | KEY_SHIFT | KEY_MOD1,
295 KEY_F4 | KEY_SHIFT | KEY_MOD1,
296 KEY_F5 | KEY_SHIFT | KEY_MOD1,
297 KEY_F6 | KEY_SHIFT | KEY_MOD1,
298 KEY_F7 | KEY_SHIFT | KEY_MOD1,
299 KEY_F8 | KEY_SHIFT | KEY_MOD1,
300 KEY_F9 | KEY_SHIFT | KEY_MOD1,
301 KEY_F10 | KEY_SHIFT | KEY_MOD1,
302 KEY_F11 | KEY_SHIFT | KEY_MOD1,
303 KEY_F12 | KEY_SHIFT | KEY_MOD1,
305 KEY_DOWN | KEY_SHIFT | KEY_MOD1,
306 KEY_UP | KEY_SHIFT | KEY_MOD1,
307 KEY_LEFT | KEY_SHIFT | KEY_MOD1,
308 KEY_RIGHT | KEY_SHIFT | KEY_MOD1,
309 KEY_HOME | KEY_SHIFT | KEY_MOD1,
310 KEY_END | KEY_SHIFT | KEY_MOD1,
311 KEY_PAGEUP | KEY_SHIFT | KEY_MOD1,
312 KEY_PAGEDOWN | KEY_SHIFT | KEY_MOD1,
313 KEY_RETURN | KEY_SHIFT | KEY_MOD1,
314 KEY_SPACE | KEY_SHIFT | KEY_MOD1,
315 KEY_BACKSPACE | KEY_SHIFT | KEY_MOD1,
316 KEY_INSERT | KEY_SHIFT | KEY_MOD1,
317 KEY_DELETE | KEY_SHIFT | KEY_MOD1,
319 KEY_0 | KEY_MOD2 ,
320 KEY_1 | KEY_MOD2 ,
321 KEY_2 | KEY_MOD2 ,
322 KEY_3 | KEY_MOD2 ,
323 KEY_4 | KEY_MOD2 ,
324 KEY_5 | KEY_MOD2 ,
325 KEY_6 | KEY_MOD2 ,
326 KEY_7 | KEY_MOD2 ,
327 KEY_8 | KEY_MOD2 ,
328 KEY_9 | KEY_MOD2 ,
329 KEY_A | KEY_MOD2 ,
330 KEY_B | KEY_MOD2 ,
331 KEY_C | KEY_MOD2 ,
332 KEY_D | KEY_MOD2 ,
333 KEY_E | KEY_MOD2 ,
334 KEY_F | KEY_MOD2 ,
335 KEY_G | KEY_MOD2 ,
336 KEY_H | KEY_MOD2 ,
337 KEY_I | KEY_MOD2 ,
338 KEY_J | KEY_MOD2 ,
339 KEY_K | KEY_MOD2 ,
340 KEY_L | KEY_MOD2 ,
341 KEY_M | KEY_MOD2 ,
342 KEY_N | KEY_MOD2 ,
343 KEY_O | KEY_MOD2 ,
344 KEY_P | KEY_MOD2 ,
345 KEY_Q | KEY_MOD2 ,
346 KEY_R | KEY_MOD2 ,
347 KEY_S | KEY_MOD2 ,
348 KEY_T | KEY_MOD2 ,
349 KEY_U | KEY_MOD2 ,
350 KEY_V | KEY_MOD2 ,
351 KEY_W | KEY_MOD2 ,
352 KEY_X | KEY_MOD2 ,
353 KEY_Y | KEY_MOD2 ,
354 KEY_Z | KEY_MOD2 ,
356 KEY_F1 | KEY_MOD2 ,
357 KEY_F2 | KEY_MOD2 ,
358 KEY_F3 | KEY_MOD2 ,
359 KEY_F4 | KEY_MOD2 ,
360 KEY_F5 | KEY_MOD2 ,
361 KEY_F6 | KEY_MOD2 ,
362 KEY_F7 | KEY_MOD2 ,
363 KEY_F8 | KEY_MOD2 ,
364 KEY_F9 | KEY_MOD2 ,
365 KEY_F10 | KEY_MOD2 ,
366 KEY_F11 | KEY_MOD2 ,
367 KEY_F12 | KEY_MOD2 ,
369 KEY_DOWN | KEY_MOD2 ,
370 KEY_UP | KEY_MOD2 ,
371 KEY_LEFT | KEY_MOD2 ,
372 KEY_RIGHT | KEY_MOD2 ,
373 KEY_HOME | KEY_MOD2 ,
374 KEY_END | KEY_MOD2 ,
375 KEY_PAGEUP | KEY_MOD2 ,
376 KEY_PAGEDOWN | KEY_MOD2 ,
377 KEY_RETURN | KEY_MOD2 ,
378 KEY_SPACE | KEY_MOD2 ,
379 KEY_BACKSPACE | KEY_MOD2 ,
380 KEY_INSERT | KEY_MOD2 ,
381 KEY_DELETE | KEY_MOD2 ,
383 KEY_0 | KEY_SHIFT | KEY_MOD2,
384 KEY_1 | KEY_SHIFT | KEY_MOD2,
385 KEY_2 | KEY_SHIFT | KEY_MOD2,
386 KEY_3 | KEY_SHIFT | KEY_MOD2,
387 KEY_4 | KEY_SHIFT | KEY_MOD2,
388 KEY_5 | KEY_SHIFT | KEY_MOD2,
389 KEY_6 | KEY_SHIFT | KEY_MOD2,
390 KEY_7 | KEY_SHIFT | KEY_MOD2,
391 KEY_8 | KEY_SHIFT | KEY_MOD2,
392 KEY_9 | KEY_SHIFT | KEY_MOD2,
393 KEY_A | KEY_SHIFT | KEY_MOD2,
394 KEY_B | KEY_SHIFT | KEY_MOD2,
395 KEY_C | KEY_SHIFT | KEY_MOD2,
396 KEY_D | KEY_SHIFT | KEY_MOD2,
397 KEY_E | KEY_SHIFT | KEY_MOD2,
398 KEY_F | KEY_SHIFT | KEY_MOD2,
399 KEY_G | KEY_SHIFT | KEY_MOD2,
400 KEY_H | KEY_SHIFT | KEY_MOD2,
401 KEY_I | KEY_SHIFT | KEY_MOD2,
402 KEY_J | KEY_SHIFT | KEY_MOD2,
403 KEY_K | KEY_SHIFT | KEY_MOD2,
404 KEY_L | KEY_SHIFT | KEY_MOD2,
405 KEY_M | KEY_SHIFT | KEY_MOD2,
406 KEY_N | KEY_SHIFT | KEY_MOD2,
407 KEY_O | KEY_SHIFT | KEY_MOD2,
408 KEY_P | KEY_SHIFT | KEY_MOD2,
409 KEY_Q | KEY_SHIFT | KEY_MOD2,
410 KEY_R | KEY_SHIFT | KEY_MOD2,
411 KEY_S | KEY_SHIFT | KEY_MOD2,
412 KEY_T | KEY_SHIFT | KEY_MOD2,
413 KEY_U | KEY_SHIFT | KEY_MOD2,
414 KEY_V | KEY_SHIFT | KEY_MOD2,
415 KEY_W | KEY_SHIFT | KEY_MOD2,
416 KEY_X | KEY_SHIFT | KEY_MOD2,
417 KEY_Y | KEY_SHIFT | KEY_MOD2,
418 KEY_Z | KEY_SHIFT | KEY_MOD2,
420 KEY_F1 | KEY_SHIFT | KEY_MOD2,
421 KEY_F2 | KEY_SHIFT | KEY_MOD2,
422 KEY_F3 | KEY_SHIFT | KEY_MOD2,
423 KEY_F4 | KEY_SHIFT | KEY_MOD2,
424 KEY_F5 | KEY_SHIFT | KEY_MOD2,
425 KEY_F6 | KEY_SHIFT | KEY_MOD2,
426 KEY_F7 | KEY_SHIFT | KEY_MOD2,
427 KEY_F8 | KEY_SHIFT | KEY_MOD2,
428 KEY_F9 | KEY_SHIFT | KEY_MOD2,
429 KEY_F10 | KEY_SHIFT | KEY_MOD2,
430 KEY_F11 | KEY_SHIFT | KEY_MOD2,
431 KEY_F12 | KEY_SHIFT | KEY_MOD2,
433 KEY_DOWN | KEY_SHIFT | KEY_MOD2,
434 KEY_UP | KEY_SHIFT | KEY_MOD2,
435 KEY_LEFT | KEY_SHIFT | KEY_MOD2,
436 KEY_RIGHT | KEY_SHIFT | KEY_MOD2,
437 KEY_HOME | KEY_SHIFT | KEY_MOD2,
438 KEY_END | KEY_SHIFT | KEY_MOD2,
439 KEY_PAGEUP | KEY_SHIFT | KEY_MOD2,
440 KEY_PAGEDOWN | KEY_SHIFT | KEY_MOD2,
441 KEY_RETURN | KEY_SHIFT | KEY_MOD2,
442 KEY_SPACE | KEY_SHIFT | KEY_MOD2,
443 KEY_BACKSPACE | KEY_SHIFT | KEY_MOD2,
444 KEY_INSERT | KEY_SHIFT | KEY_MOD2,
445 KEY_DELETE | KEY_SHIFT | KEY_MOD2,
447 KEY_0 | KEY_MOD1 | KEY_MOD2 ,
448 KEY_1 | KEY_MOD1 | KEY_MOD2 ,
449 KEY_2 | KEY_MOD1 | KEY_MOD2 ,
450 KEY_3 | KEY_MOD1 | KEY_MOD2 ,
451 KEY_4 | KEY_MOD1 | KEY_MOD2 ,
452 KEY_5 | KEY_MOD1 | KEY_MOD2 ,
453 KEY_6 | KEY_MOD1 | KEY_MOD2 ,
454 KEY_7 | KEY_MOD1 | KEY_MOD2 ,
455 KEY_8 | KEY_MOD1 | KEY_MOD2 ,
456 KEY_9 | KEY_MOD1 | KEY_MOD2 ,
457 KEY_A | KEY_MOD1 | KEY_MOD2 ,
458 KEY_B | KEY_MOD1 | KEY_MOD2 ,
459 KEY_C | KEY_MOD1 | KEY_MOD2 ,
460 KEY_D | KEY_MOD1 | KEY_MOD2 ,
461 KEY_E | KEY_MOD1 | KEY_MOD2 ,
462 KEY_F | KEY_MOD1 | KEY_MOD2 ,
463 KEY_G | KEY_MOD1 | KEY_MOD2 ,
464 KEY_H | KEY_MOD1 | KEY_MOD2 ,
465 KEY_I | KEY_MOD1 | KEY_MOD2 ,
466 KEY_J | KEY_MOD1 | KEY_MOD2 ,
467 KEY_K | KEY_MOD1 | KEY_MOD2 ,
468 KEY_L | KEY_MOD1 | KEY_MOD2 ,
469 KEY_M | KEY_MOD1 | KEY_MOD2 ,
470 KEY_N | KEY_MOD1 | KEY_MOD2 ,
471 KEY_O | KEY_MOD1 | KEY_MOD2 ,
472 KEY_P | KEY_MOD1 | KEY_MOD2 ,
473 KEY_Q | KEY_MOD1 | KEY_MOD2 ,
474 KEY_R | KEY_MOD1 | KEY_MOD2 ,
475 KEY_S | KEY_MOD1 | KEY_MOD2 ,
476 KEY_T | KEY_MOD1 | KEY_MOD2 ,
477 KEY_U | KEY_MOD1 | KEY_MOD2 ,
478 KEY_V | KEY_MOD1 | KEY_MOD2 ,
479 KEY_W | KEY_MOD1 | KEY_MOD2 ,
480 KEY_X | KEY_MOD1 | KEY_MOD2 ,
481 KEY_Y | KEY_MOD1 | KEY_MOD2 ,
482 KEY_Z | KEY_MOD1 | KEY_MOD2 ,
484 KEY_F1 | KEY_MOD1 | KEY_MOD2 ,
485 KEY_F2 | KEY_MOD1 | KEY_MOD2 ,
486 KEY_F3 | KEY_MOD1 | KEY_MOD2 ,
487 KEY_F4 | KEY_MOD1 | KEY_MOD2 ,
488 KEY_F5 | KEY_MOD1 | KEY_MOD2 ,
489 KEY_F6 | KEY_MOD1 | KEY_MOD2 ,
490 KEY_F7 | KEY_MOD1 | KEY_MOD2 ,
491 KEY_F8 | KEY_MOD1 | KEY_MOD2 ,
492 KEY_F9 | KEY_MOD1 | KEY_MOD2 ,
493 KEY_F10 | KEY_MOD1 | KEY_MOD2 ,
494 KEY_F11 | KEY_MOD1 | KEY_MOD2 ,
495 KEY_F12 | KEY_MOD1 | KEY_MOD2 ,
497 KEY_DOWN | KEY_MOD1 | KEY_MOD2 ,
498 KEY_UP | KEY_MOD1 | KEY_MOD2 ,
499 KEY_LEFT | KEY_MOD1 | KEY_MOD2 ,
500 KEY_RIGHT | KEY_MOD1 | KEY_MOD2 ,
501 KEY_HOME | KEY_MOD1 | KEY_MOD2 ,
502 KEY_END | KEY_MOD1 | KEY_MOD2 ,
503 KEY_PAGEUP | KEY_MOD1 | KEY_MOD2 ,
504 KEY_PAGEDOWN | KEY_MOD1 | KEY_MOD2 ,
505 KEY_RETURN | KEY_MOD1 | KEY_MOD2 ,
506 KEY_SPACE | KEY_MOD1 | KEY_MOD2 ,
507 KEY_BACKSPACE | KEY_MOD1 | KEY_MOD2 ,
508 KEY_INSERT | KEY_MOD1 | KEY_MOD2 ,
509 KEY_DELETE | KEY_MOD1 | KEY_MOD2 ,
511 KEY_0 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
512 KEY_1 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
513 KEY_2 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
514 KEY_3 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
515 KEY_4 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
516 KEY_5 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
517 KEY_6 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
518 KEY_7 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
519 KEY_8 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
520 KEY_9 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
521 KEY_A | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
522 KEY_B | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
523 KEY_C | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
524 KEY_D | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
525 KEY_E | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
526 KEY_F | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
527 KEY_G | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
528 KEY_H | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
529 KEY_I | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
530 KEY_J | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
531 KEY_K | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
532 KEY_L | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
533 KEY_M | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
534 KEY_N | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
535 KEY_O | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
536 KEY_P | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
537 KEY_Q | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
538 KEY_R | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
539 KEY_S | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
540 KEY_T | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
541 KEY_U | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
542 KEY_V | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
543 KEY_W | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
544 KEY_X | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
545 KEY_Y | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
546 KEY_Z | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
548 KEY_F1 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
549 KEY_F2 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
550 KEY_F3 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
551 KEY_F4 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
552 KEY_F5 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
553 KEY_F6 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
554 KEY_F7 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
555 KEY_F8 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
556 KEY_F9 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
557 KEY_F10 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
558 KEY_F11 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
559 KEY_F12 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
561 KEY_DOWN | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
562 KEY_UP | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
563 KEY_LEFT | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
564 KEY_RIGHT | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
565 KEY_HOME | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
566 KEY_END | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
567 KEY_PAGEUP | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
568 KEY_PAGEDOWN | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
569 KEY_RETURN | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
570 KEY_SPACE | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
571 KEY_BACKSPACE | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
572 KEY_INSERT | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
573 KEY_DELETE | KEY_SHIFT | KEY_MOD1 | KEY_MOD2
576 static USHORT KEYCODE_ARRAY_SIZE = (sizeof(KEYCODE_ARRAY) / sizeof(KEYCODE_ARRAY[0]));
578 //-----------------------------------------------
579 // seems to be needed to layout the list box, which shows all
580 // assignable shortcuts
581 static long AccCfgTabs[] =
583 2, // Number of Tabs
585 120 // Function
588 //-----------------------------------------------
589 class SfxAccCfgLBoxString_Impl : public SvLBoxString
591 public:
592 SfxAccCfgLBoxString_Impl( SvLBoxEntry* pEntry,
593 USHORT nFlags,
594 const String& sText );
596 virtual ~SfxAccCfgLBoxString_Impl();
598 virtual void Paint(const Point& aPos ,
599 SvLBox& rDevice,
600 USHORT nFlags ,
601 SvLBoxEntry* pEntry );
604 //-----------------------------------------------
605 SfxAccCfgLBoxString_Impl::SfxAccCfgLBoxString_Impl( SvLBoxEntry* pEntry,
606 USHORT nFlags,
607 const String& sText )
608 : SvLBoxString(pEntry, nFlags, sText)
612 //-----------------------------------------------
613 SfxAccCfgLBoxString_Impl::~SfxAccCfgLBoxString_Impl()
617 //-----------------------------------------------
618 void SfxAccCfgLBoxString_Impl::Paint(const Point& aPos ,
619 SvLBox& rDevice,
620 USHORT /*nFlags*/,
621 SvLBoxEntry* pEntry )
623 /*/ ??? realy needed !!!
624 Font aOldFont(rDevice.GetFont());
625 Font aNewFont(aOldFont );
626 rDevice.SetFont( aFont );
629 if (!pEntry)
630 return;
632 TAccInfo* pUserData = (TAccInfo*)pEntry->GetUserData();
633 if (!pUserData)
634 return;
636 if (pUserData->m_bIsConfigurable)
637 rDevice.DrawText(aPos, GetText());
638 else
639 rDevice.DrawCtrlText(aPos, GetText(), 0, STRING_LEN, TEXT_DRAW_DISABLE);
641 //rDev.SetFont( aOldFont );
644 //-----------------------------------------------
645 void SfxAccCfgTabListBox_Impl::InitEntry( SvLBoxEntry* pEntry ,
646 const XubString& sText ,
647 const Image& aImage1,
648 const Image& aImage2,
649 SvLBoxButtonKind eButtonKind)
651 SvTabListBox::InitEntry(pEntry, sText, aImage1, aImage2, eButtonKind);
654 //-----------------------------------------------
655 /** select the entry, which match the current key input ... excepting
656 keys, which are used for the dialog itself.
658 void SfxAccCfgTabListBox_Impl::KeyInput(const KeyEvent& aKey)
660 KeyCode aCode1 = aKey.GetKeyCode();
661 USHORT nCode1 = aCode1.GetCode();
662 USHORT nMod1 = aCode1.GetModifier();
664 // is it related to our list box ?
665 if (
666 (nCode1 != KEY_DOWN ) &&
667 (nCode1 != KEY_UP ) &&
668 (nCode1 != KEY_LEFT ) &&
669 (nCode1 != KEY_RIGHT ) &&
670 (nCode1 != KEY_PAGEUP ) &&
671 (nCode1 != KEY_PAGEDOWN)
674 SvLBoxEntry* pEntry = First();
675 while (pEntry)
677 TAccInfo* pUserData = (TAccInfo*)pEntry->GetUserData();
678 if (pUserData)
680 USHORT nCode2 = pUserData->m_aKey.GetCode();
681 USHORT nMod2 = pUserData->m_aKey.GetModifier();
682 if (
683 (nCode1 == nCode2) &&
684 (nMod1 == nMod2 )
687 Select (pEntry);
688 MakeVisible(pEntry);
689 return;
692 pEntry = Next(pEntry);
696 // no - handle it as normal dialog input
697 SvTabListBox::KeyInput(aKey);
700 //-----------------------------------------------
701 SfxAcceleratorConfigPage::SfxAcceleratorConfigPage( Window* pParent, const SfxItemSet& aSet )
702 : SfxTabPage (pParent, SVX_RES(RID_SVXPAGE_KEYBOARD), aSet)
703 , m_pMacroInfoItem ()
704 , m_pStringItem ()
705 , m_pFontItem ()
706 , m_pFileDlg (NULL)
707 , aEntriesBox (this , this, SVX_RES(BOX_ACC_ENTRIES ))
708 , aKeyboardGroup (this , SVX_RES(GRP_ACC_KEYBOARD ))
709 , aOfficeButton (this , SVX_RES(RB_OFFICE ))
710 , aModuleButton (this , SVX_RES(RB_MODULE ))
711 , aChangeButton (this , SVX_RES(BTN_ACC_CHANGE ))
712 , aRemoveButton (this , SVX_RES(BTN_ACC_REMOVE ))
713 , aGroupText (this , SVX_RES(TXT_ACC_GROUP ))
714 , pGroupLBox(new SfxConfigGroupListBox_Impl( this, SVX_RES(BOX_ACC_GROUP), SFX_SLOT_ACCELCONFIG ))
715 , aFunctionText (this , SVX_RES(TXT_ACC_FUNCTION ))
716 , pFunctionBox(new SfxConfigFunctionListBox_Impl( this, SVX_RES( BOX_ACC_FUNCTION )))
717 , aKeyText (this , SVX_RES(TXT_ACC_KEY ))
718 , aKeyBox (this , SVX_RES(BOX_ACC_KEY ))
719 , aFunctionsGroup (this , SVX_RES(GRP_ACC_FUNCTIONS ))
720 , aLoadButton (this , SVX_RES(BTN_LOAD ))
721 , aSaveButton (this , SVX_RES(BTN_SAVE ))
722 , aResetButton (this , SVX_RES(BTN_RESET ))
723 , aLoadAccelConfigStr ( SVX_RES( STR_LOADACCELCONFIG ) )
724 , aSaveAccelConfigStr ( SVX_RES( STR_SAVEACCELCONFIG ) )
725 , aFilterAllStr ( SVX_RES( STR_SFX_FILTERNAME_ALL ) )
726 , aFilterCfgStr ( SVX_RES( STR_FILTERNAME_CFG ) )
727 , m_bStylesInfoInitialized(sal_False)
728 , m_xGlobal ()
729 , m_xModule ()
730 , m_xAct ()
732 FreeResource();
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.SetWindowBits(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
756 long nMaxWidth = 0;
757 for ( USHORT i = 0; i < KEYCODE_ARRAY_SIZE; ++i )
759 long nTmp = GetTextWidth( KeyCode( KEYCODE_ARRAY[i] ).GetName() );
760 if ( nTmp > nMaxWidth )
761 nMaxWidth = nTmp;
763 // recalc second tab
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);
771 // initialize KeyBox
772 aKeyBox.SetWindowBits(WB_CLIPCHILDREN|WB_HSCROLL|WB_SORT);
775 //-----------------------------------------------
776 SfxAcceleratorConfigPage::~SfxAcceleratorConfigPage()
778 // free memory - remove all dynamic user data
779 SvLBoxEntry* pEntry = aEntriesBox.First();
780 while (pEntry)
782 TAccInfo* pUserData = (TAccInfo*)pEntry->GetUserData();
783 if (pUserData)
784 delete pUserData;
785 pEntry = aEntriesBox.Next(pEntry);
788 pEntry = aKeyBox.First();
789 while (pEntry)
791 TAccInfo* pUserData = (TAccInfo*)pEntry->GetUserData();
792 if (pUserData)
793 delete pUserData;
794 pEntry = aKeyBox.Next(pEntry);
797 aEntriesBox.Clear();
798 aKeyBox.Clear();
800 delete m_pFileDlg;
801 delete pGroupLBox;
802 delete pFunctionBox;
805 //-----------------------------------------------
806 void SfxAcceleratorConfigPage::InitAccCfg()
808 // already initialized ?
809 if (m_xSMGR.is())
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"
820 // for this session
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();
828 // identify module
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)
845 { throw exRun; }
846 catch(const css::uno::Exception&)
847 { m_xSMGR.clear(); }
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)
869 if (!xAccMgr.is())
870 return;
872 if (!m_bStylesInfoInitialized)
874 css::uno::Reference< css::frame::XController > xController;
875 css::uno::Reference< css::frame::XModel > xModel;
876 if (m_xFrame.is())
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 USHORT c1 = KEYCODE_ARRAY_SIZE;
891 USHORT i1 = 0;
892 USHORT nListPos = 0;
893 for (i1=0; i1<c1; ++i1)
895 KeyCode aKey = KEYCODE_ARRAY[i1];
896 String sKey = aKey.GetName();
897 if (!sKey.Len())
898 continue;
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();
907 sal_Int32 i2 = 0;
908 USHORT 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 USHORT nPos = MapKeyCodeToPos(aKeyCode);
918 if (nPos == LISTBOX_ENTRY_NOTFOUND)
919 continue;
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 ULONG c3 = Application::GetReservedKeyCodeCount();
933 ULONG i3 = 0;
934 for (i3=0; i3<c3; ++i3)
936 const KeyCode* pKeyCode = Application::GetReservedKeyCode(i3);
937 USHORT nPos = MapKeyCodeToPos(*pKeyCode);
939 if (nPos == LISTBOX_ENTRY_NOTFOUND)
940 continue;
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)
954 if (!xAccMgr.is())
955 return;
957 // Go through the list from the bottom to the top ...
958 // because logical accelerator must be preferred instead of
959 // physical ones!
960 SvLBoxEntry* pEntry = aEntriesBox.First();
961 while (pEntry)
963 TAccInfo* pUserData = (TAccInfo*)pEntry->GetUserData();
964 ::rtl::OUString sCommand ;
965 css::awt::KeyEvent aAWTKey ;
967 if (pUserData)
969 sCommand = pUserData->m_sCommand;
970 aAWTKey = ::svt::AcceleratorExecute::st_VCLKey2AWTKey(pUserData->m_aKey);
975 if (sCommand.getLength())
976 xAccMgr->setKeyEvent(aAWTKey, sCommand);
977 else
978 xAccMgr->removeKeyEvent(aAWTKey);
980 catch(const css::uno::RuntimeException& exRun)
981 { throw exRun; }
982 catch(const css::uno::Exception&)
985 pEntry = aEntriesBox.Next(pEntry);
989 //-----------------------------------------------
990 void SfxAcceleratorConfigPage::ResetConfig()
992 aEntriesBox.Clear();
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 );
1000 return 0;
1003 //-----------------------------------------------
1004 IMPL_LINK( SfxAcceleratorConfigPage, Save, Button*, EMPTYARG )
1006 StartFileDialog( WB_SAVEAS | WB_STDMODAL | WB_3DLOOK, aLoadAccelConfigStr );
1007 return 0;
1010 //-----------------------------------------------
1011 IMPL_LINK(SfxAcceleratorConfigPage, Default, PushButton*, EMPTYARG)
1013 css::uno::Reference< css::form::XReset > xReset(m_xAct, css::uno::UNO_QUERY);
1014 if (xReset.is())
1015 xReset->reset();
1017 aEntriesBox.SetUpdateMode(FALSE);
1018 ResetConfig();
1019 Init(m_xAct);
1020 aEntriesBox.SetUpdateMode(TRUE);
1021 aEntriesBox.Invalidate();
1022 aEntriesBox.Select(aEntriesBox.GetEntry(0, 0));
1024 return 0;
1027 //-----------------------------------------------
1028 IMPL_LINK( SfxAcceleratorConfigPage, ChangeHdl, Button*, EMPTYARG )
1030 USHORT nPos = (USHORT) aEntriesBox.GetModel()->GetRelPos( aEntriesBox.FirstSelected() );
1031 TAccInfo* pEntry = (TAccInfo*)aEntriesBox.GetEntry(0, nPos)->GetUserData();
1032 String sNewCommand = pFunctionBox->GetCurCommand();
1033 String sLabel = pFunctionBox->GetCurLabel();
1034 if (!sLabel.Len())
1035 sLabel = GetLabel4Command(sNewCommand);
1037 pEntry->m_sCommand = sNewCommand;
1038 USHORT nCol = aEntriesBox.TabCount() - 1;
1039 aEntriesBox.SetEntryText(sLabel, nPos, nCol);
1041 ((Link &) pFunctionBox->GetSelectHdl()).Call( pFunctionBox );
1042 return 0;
1045 //-----------------------------------------------
1046 IMPL_LINK( SfxAcceleratorConfigPage, RemoveHdl, Button *, EMPTYARG )
1048 // get selected entry
1049 USHORT nPos = (USHORT) aEntriesBox.GetModel()->GetRelPos( aEntriesBox.FirstSelected() );
1050 TAccInfo* pEntry = (TAccInfo*)aEntriesBox.GetEntry(0, nPos)->GetUserData();
1052 // remove function name from selected entry
1053 USHORT nCol = aEntriesBox.TabCount() - 1;
1054 aEntriesBox.SetEntryText( String(), nPos, nCol );
1055 pEntry->m_sCommand = ::rtl::OUString();
1057 ((Link &) pFunctionBox->GetSelectHdl()).Call( pFunctionBox );
1058 return 0;
1061 //-----------------------------------------------
1062 IMPL_LINK( SfxAcceleratorConfigPage, SelectHdl, Control*, pListBox )
1064 // disable help
1065 Help::ShowBalloon( this, Point(), String() );
1066 if ( pListBox == &aEntriesBox )
1068 USHORT nPos = (USHORT) aEntriesBox.GetModel()->GetRelPos( aEntriesBox.FirstSelected() );
1069 TAccInfo* pEntry = (TAccInfo*)aEntriesBox.GetEntry(0, nPos)->GetUserData();
1070 ::rtl::OUString sPossibleNewCommand = pFunctionBox->GetCurCommand();
1072 aRemoveButton.Enable( FALSE );
1073 aChangeButton.Enable( FALSE );
1075 if (pEntry->m_bIsConfigurable)
1077 if (pEntry->isConfigured())
1078 aRemoveButton.Enable( TRUE );
1079 aChangeButton.Enable( pEntry->m_sCommand != sPossibleNewCommand );
1082 else if ( pListBox == pGroupLBox )
1084 pGroupLBox->GroupSelected();
1085 if ( !pFunctionBox->FirstSelected() )
1086 aChangeButton.Enable( FALSE );
1088 else if ( pListBox == pFunctionBox )
1090 aRemoveButton.Enable( FALSE );
1091 aChangeButton.Enable( FALSE );
1093 // #i36994 First selected can return zero!
1094 SvLBoxEntry* pLBEntry = aEntriesBox.FirstSelected();
1095 if ( pLBEntry != 0 )
1097 USHORT nPos = (USHORT) 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( TRUE );
1105 aChangeButton.Enable( pEntry->m_sCommand != sPossibleNewCommand );
1108 // update key box
1109 aKeyBox.Clear();
1110 SvLBoxEntry* pIt = aEntriesBox.First();
1111 while ( pIt )
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, TRUE, LIST_APPEND );
1118 pE1->SetUserData(pU1);
1119 pE1->EnableChildsOnDemand( FALSE );
1121 pIt = aEntriesBox.Next(pIt);
1125 else
1127 // goto selected "key" entry of the key box
1128 SvLBoxEntry* pE2 = 0;
1129 TAccInfo* pU2 = 0;
1130 USHORT nP2 = LISTBOX_ENTRY_NOTFOUND;
1131 SvLBoxEntry* pE3 = 0;
1133 pE2 = aKeyBox.FirstSelected();
1134 if (pE2)
1135 pU2 = (TAccInfo*)pE2->GetUserData();
1136 if (pU2)
1137 nP2 = MapKeyCodeToPos(pU2->m_aKey);
1138 if (nP2 != LISTBOX_ENTRY_NOTFOUND)
1139 pE3 = aEntriesBox.GetEntry( 0, nP2 );
1140 if (pE3)
1142 aEntriesBox.Select( pE3 );
1143 aEntriesBox.MakeVisible( pE3 );
1147 return 0;
1150 //-----------------------------------------------
1151 IMPL_LINK( SfxAcceleratorConfigPage, RadioHdl, RadioButton *, EMPTYARG )
1153 css::uno::Reference< css::ui::XAcceleratorConfiguration > xOld = m_xAct;
1155 if (aOfficeButton.IsChecked())
1156 m_xAct = m_xGlobal;
1157 else if (aModuleButton.IsChecked())
1158 m_xAct = m_xModule;
1160 // nothing changed? => do nothing!
1161 if ( m_xAct.is() && ( xOld == m_xAct ) )
1162 return 0;
1164 aEntriesBox.SetUpdateMode( FALSE );
1165 ResetConfig();
1166 Init(m_xAct);
1167 aEntriesBox.SetUpdateMode( 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 );
1174 if ( pEntry )
1175 aEntriesBox.Select( pEntry );
1176 pEntry = pGroupLBox->GetEntry( 0, 0 );
1177 if ( pEntry )
1178 pGroupLBox->Select( pEntry );
1180 ((Link &) pFunctionBox->GetSelectHdl()).Call( pFunctionBox );
1181 return 1L;
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() )
1194 return 0;
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);
1206 if (xDoc.is())
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();
1212 else
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);
1223 if (xUIConfig.is())
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);
1231 if (xCfgMgr.is())
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(FALSE);
1237 ResetConfig();
1238 Init(xTempAccMgr);
1239 aEntriesBox.SetUpdateMode(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)
1259 { throw exRun; }
1260 catch(const css::uno::Exception&)
1263 GetTabDialog()->LeaveWait();
1265 return 0;
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() )
1278 return 0;
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);
1290 if (xDoc.is())
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();
1296 else
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(
1312 xUIConfig,
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);
1326 if (xCfgMgr.is())
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);
1338 xCommit1->store();
1339 xCommit2->store();
1341 if (xRootStorage.is())
1343 // Commit root storage
1344 css::uno::Reference< css::embed::XTransactedObject > xCommit3(xRootStorage, css::uno::UNO_QUERY_THROW);
1345 xCommit3->commit();
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)
1361 { throw exRun; }
1362 catch(const css::uno::Exception&)
1365 GetTabDialog()->LeaveWait();
1367 return 0;
1370 ::rtl::OUString RetrieveLabelFromCommand( const ::rtl::OUString& aCmdURL )
1372 ::rtl::OUString aLabel;
1373 if ( aCmdURL.getLength() )
1377 uno::Reference< container::XNameAccess > xNameAccess( ::comphelper::getProcessServiceFactory()->createInstance( rtl::OUString::createFromAscii("com.sun.star.frame.UICommandDescription") ), uno::UNO_QUERY );
1378 if ( xNameAccess.is() )
1380 uno::Reference< container::XNameAccess > xUICommandLabels;
1381 const ::rtl::OUString aModule( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextDocument" ) );
1382 uno::Any a = xNameAccess->getByName( aModule );
1383 uno::Reference< container::XNameAccess > xUICommands;
1384 a >>= xUICommandLabels;
1385 rtl::OUString aStr;
1386 uno::Sequence< beans::PropertyValue > aPropSeq;
1387 a = xUICommandLabels->getByName( aCmdURL );
1388 if ( a >>= aPropSeq )
1390 for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
1392 if ( aPropSeq[i].Name.equalsAscii( "Name" ))
1394 aPropSeq[i].Value >>= aStr;
1395 break;
1399 aLabel = aStr;
1402 catch ( uno::Exception& )
1407 return aLabel;
1411 //-----------------------------------------------
1412 String SfxAcceleratorConfigPage::GetFunctionName(KeyFuncType eType) const
1414 ::rtl::OUStringBuffer sName(256);
1415 sName.appendAscii("\"");
1416 switch(eType)
1418 case KEYFUNC_NEW :
1419 sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:NewDoc") ) );
1420 break;
1422 case KEYFUNC_OPEN :
1423 sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Open") ) );
1424 break;
1426 case KEYFUNC_SAVE :
1427 sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Save") ) );
1428 break;
1430 case KEYFUNC_SAVEAS :
1431 sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:SaveAs") ) );
1432 break;
1434 case KEYFUNC_PRINT :
1435 sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Print") ) );
1436 break;
1438 case KEYFUNC_CLOSE :
1439 sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Close") ) );
1440 break;
1442 case KEYFUNC_QUIT :
1443 sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Quit") ) );
1444 break;
1446 case KEYFUNC_CUT :
1447 sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Cut") ) );
1448 break;
1450 case KEYFUNC_COPY :
1451 sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Copy") ) );
1452 break;
1454 case KEYFUNC_PASTE :
1455 sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Paste") ) );
1456 break;
1458 case KEYFUNC_UNDO :
1459 sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Undo") ) );
1460 break;
1462 case KEYFUNC_REDO :
1463 sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Redo") ) );
1464 break;
1466 case KEYFUNC_DELETE :
1467 sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Delete") ) );
1468 break;
1470 case KEYFUNC_REPEAT :
1471 sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Repeat") ) );
1472 break;
1474 case KEYFUNC_FIND :
1475 sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Search") ) );
1476 break;
1478 case KEYFUNC_FINDBACKWARD :
1479 sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:SearchBackwards") ) );
1480 break;
1482 case KEYFUNC_PROPERTIES :
1483 sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:Options") ) );
1484 break;
1486 case KEYFUNC_FRONT :
1487 sName.append( RetrieveLabelFromCommand( ::rtl::OUString::createFromAscii(".uno:ToFront") ) );
1488 break;
1490 default:
1491 break;
1493 sName.appendAscii("\"");
1494 return String(sName.makeStringAndClear());
1497 //-----------------------------------------------
1498 void SfxAcceleratorConfigPage::StartFileDialog( WinBits nBits, const String& rTitle )
1500 bool bSave = ( ( nBits & WB_SAVEAS ) == WB_SAVEAS );
1501 short nDialogType = bSave ? css::ui::dialogs::TemplateDescription::FILESAVE_SIMPLE
1502 : css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE;
1503 if ( m_pFileDlg )
1504 delete m_pFileDlg;
1505 m_pFileDlg = new sfx2::FileDialogHelper( nDialogType, 0 );
1507 m_pFileDlg->SetTitle( rTitle );
1508 // m_pFileDlg->SetDialogHelpId( bSave ? HID_CONFIG_SAVE : HID_CONFIG_LOAD );
1509 m_pFileDlg->AddFilter( aFilterAllStr, DEFINE_CONST_UNICODE( FILEDIALOG_FILTER_ALL ) );
1510 m_pFileDlg->AddFilter( aFilterCfgStr, DEFINE_CONST_UNICODE( "*.cfg" ) );
1512 Link aDlgClosedLink = bSave ? LINK( this, SfxAcceleratorConfigPage, SaveHdl )
1513 : LINK( this, SfxAcceleratorConfigPage, LoadHdl );
1514 m_pFileDlg->StartExecuteModal( aDlgClosedLink );
1517 //-----------------------------------------------
1518 BOOL SfxAcceleratorConfigPage::FillItemSet( SfxItemSet& )
1520 Apply(m_xAct);
1523 m_xAct->store();
1525 catch(const css::uno::RuntimeException& exRun)
1526 { throw exRun; }
1527 catch(const css::uno::Exception&)
1528 { return FALSE; }
1530 return TRUE;
1533 //-----------------------------------------------
1534 void SfxAcceleratorConfigPage::Reset( const SfxItemSet& rSet )
1536 // open accelerator configs
1537 // Note: It initialize some other members too, which are needed here ...
1538 // e.g. m_sModuleUIName!
1539 InitAccCfg();
1541 // change te description of the radio button, which switch to the module
1542 // dependend accelerator configuration
1543 String sButtonText = aModuleButton.GetText();
1544 sButtonText.SearchAndReplace(String::CreateFromAscii("$(MODULE)"), m_sModuleUIName);
1545 aModuleButton.SetText(sButtonText);
1547 if (m_xModule.is())
1548 aModuleButton.Check();
1549 else
1551 aModuleButton.Hide();
1552 aOfficeButton.Check();
1555 RadioHdl(0);
1557 const SfxPoolItem* pMacroItem=0;
1558 if( SFX_ITEM_SET == rSet.GetItemState( SID_MACROINFO, TRUE, &pMacroItem ) )
1560 m_pMacroInfoItem = PTR_CAST( SfxMacroInfoItem, pMacroItem );
1561 pGroupLBox->SelectMacro( m_pMacroInfoItem );
1563 else
1565 const SfxPoolItem* pStringItem=0;
1566 if( SFX_ITEM_SET == rSet.GetItemState( SID_CHARMAP, TRUE, &pStringItem ) )
1567 m_pStringItem = PTR_CAST( SfxStringItem, pStringItem );
1569 const SfxPoolItem* pFontItem=0;
1570 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_SPECIALCHAR, TRUE, &pFontItem ) )
1571 m_pFontItem = PTR_CAST( SfxStringItem, pFontItem );
1573 if ( m_pStringItem )
1574 pGroupLBox->AddAndSelect( m_pStringItem, m_pFontItem );
1578 //-----------------------------------------------
1579 void SfxAcceleratorConfigPage::SelectMacro(const SfxMacroInfoItem *pItem)
1581 m_pMacroInfoItem = pItem;
1582 pGroupLBox->SelectMacro( pItem );
1585 //-----------------------------------------------
1586 void SfxAcceleratorConfigPage::CopySource2Target(const css::uno::Reference< css::ui::XAcceleratorConfiguration >& xSourceAccMgr,
1587 const css::uno::Reference< css::ui::XAcceleratorConfiguration >& xTargetAccMgr)
1589 const css::uno::Sequence< css::awt::KeyEvent > lKeys = xSourceAccMgr->getAllKeyEvents();
1590 sal_Int32 c = lKeys.getLength();
1591 sal_Int32 i = 0;
1592 for (i=0; i<c; ++i)
1594 const css::awt::KeyEvent& rKey = lKeys[i];
1595 ::rtl::OUString sCommand = xSourceAccMgr->getCommandByKeyEvent(rKey);
1596 xTargetAccMgr->setKeyEvent(rKey, sCommand);
1600 //-----------------------------------------------
1601 KeyCode SfxAcceleratorConfigPage::MapPosToKeyCode(USHORT nPos) const
1603 TAccInfo* pEntry = (TAccInfo*)aEntriesBox.GetEntry(0, nPos)->GetUserData();
1604 KeyCode aCode(KEYCODE_ARRAY[pEntry->m_nKeyPos] & 0xFFF ,
1605 KEYCODE_ARRAY[pEntry->m_nKeyPos] & (KEY_SHIFT | KEY_MOD2));
1606 return aCode;
1609 //-----------------------------------------------
1610 USHORT SfxAcceleratorConfigPage::MapKeyCodeToPos(const KeyCode& aKey) const
1612 USHORT nCode1 = aKey.GetCode()+aKey.GetModifier();
1613 SvLBoxEntry* pEntry = aEntriesBox.First();
1614 USHORT i = 0;
1616 while (pEntry)
1618 TAccInfo* pUserData = (TAccInfo*)pEntry->GetUserData();
1619 if (pUserData)
1621 USHORT nCode2 = pUserData->m_aKey.GetCode()+pUserData->m_aKey.GetModifier();
1622 if (nCode1 == nCode2)
1623 return i;
1625 pEntry = aEntriesBox.Next(pEntry);
1626 ++i;
1629 return LISTBOX_ENTRY_NOTFOUND;
1632 //-----------------------------------------------
1633 String SfxAcceleratorConfigPage::GetLabel4Command(const String& sCommand)
1637 // check global command configuration first
1638 css::uno::Reference< css::container::XNameAccess > xModuleConf;
1639 m_xUICmdDescription->getByName(m_sModuleLongName) >>= xModuleConf;
1640 if (xModuleConf.is())
1642 ::comphelper::SequenceAsHashMap lProps(xModuleConf->getByName(sCommand));
1643 String sLabel = String(lProps.getUnpackedValueOrDefault(CMDPROP_UINAME, ::rtl::OUString()));
1644 if (sLabel.Len())
1645 return sLabel;
1648 catch(const css::uno::RuntimeException& exRun)
1649 { throw exRun; }
1650 catch(const css::uno::Exception&)
1653 // may be it's a style URL .. they must be handled special
1654 SfxStyleInfo_Impl aStyle;
1655 aStyle.sCommand = sCommand;
1656 if (m_aStylesInfo.parseStyleCommand(aStyle))
1658 m_aStylesInfo.getLabel4Style(aStyle);
1659 return aStyle.sLabel;
1661 else
1663 String aRet( String::CreateFromAscii("Symbols: ") );
1664 xub_StrLen nPos = sCommand.SearchAscii(".uno:InsertSymbol?Symbols:string=");
1665 if ( nPos == 0 )
1667 aRet += String( sCommand, 34, sCommand.Len()-34 );
1668 return aRet;
1672 return sCommand;
1675 SfxTabPage* SfxAcceleratorConfigPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
1677 return new SfxAcceleratorConfigPage( pParent, rAttrSet );
1680 //-----------------------------------------------
1681 css::uno::Reference< css::frame::XModel > SfxAcceleratorConfigPage::SearchForAlreadyLoadedDoc(const String& /*sName*/)
1683 return css::uno::Reference< css::frame::XModel >();
1686 SvxShortcutAssignDlg::SvxShortcutAssignDlg( Window* pParent, const uno::Reference< frame::XFrame >& rxDocumentFrame, const SfxItemSet& rSet )
1687 : SfxSingleTabDialog( pParent, rSet, 0 )
1689 SfxTabPage* pPage = SfxAcceleratorConfigPage::Create( this, rSet );
1690 pPage->SetFrame( rxDocumentFrame );
1691 SetTabPage( pPage );
1695 SvxShortcutAssignDlg::~SvxShortcutAssignDlg()
1700 // .uno:InsertSymbol?Symbols:string=bla