1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_cui.hxx"
26
27 //-----------------------------------------------
28 // include own files
29
30 #include "acccfg.hxx"
31 #include "cfgutil.hxx"
32 #include <dialmgr.hxx>
33
34 #include <sfx2/msg.hxx>
35 #include <sfx2/app.hxx>
36 #include <sfx2/filedlghelper.hxx>
37 #include <sfx2/minfitem.hxx>
38 #include <sfx2/sfxresid.hxx>
39 #include <svl/stritem.hxx>
40
41 #include "cuires.hrc"
42 #include "acccfg.hrc"
43
44 #include <svx/svxids.hrc> // SID_CHARMAP, SID_ATTR_SPECIALCHAR
45
46 //-----------------------------------------------
47 // include interface declarations
48 #include <com/sun/star/frame/XFramesSupplier.hpp>
49 #include <com/sun/star/frame/XFrame.hpp>
50 #include <com/sun/star/frame/XController.hpp>
51 #include <com/sun/star/frame/XModel.hpp>
52 #include <com/sun/star/form/XReset.hpp>
53 #include <com/sun/star/frame/XModuleManager.hpp>
54 #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
55 #include <com/sun/star/frame/XModuleManager.hpp>
56
57 #ifndef _COM_SUN_STAR_UI_XUICONFIGURATIONMANAGERSUPLLIER_HPP_
58 #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
59 #endif
60 #include <com/sun/star/ui/XUIConfigurationManager.hpp>
61 #include <com/sun/star/awt/KeyModifier.hpp>
62 #include <com/sun/star/embed/XTransactedObject.hpp>
63 #include <com/sun/star/embed/ElementModes.hpp>
64
65 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
66
67 //-----------------------------------------------
68 // include other projects
69 #include <unotools/processfactory.hxx>
70 #include <svtools/acceleratorexecute.hxx>
71 #include <comphelper/processfactory.hxx>
72 #include <svtools/svlbitm.hxx>
73 #include <vcl/svapp.hxx>
74 #include <vcl/help.hxx>
75 #include <rtl/ustrbuf.hxx>
76 #include <comphelper/sequenceashashmap.hxx>
77
78 //-----------------------------------------------
79 // namespaces
80
81 #ifdef css
82 #error "ambigous praeprozessor directive for css ..."
83 #else
84 namespace css = ::com::sun::star;
85 #endif
86
87 using namespace com::sun::star;
88
89 //-----------------------------------------------
90 // definitions
91
92 //-----------------------------------------------
93 static ::rtl::OUString SERVICE_STORAGEFACTORY = ::rtl::OUString::createFromAscii("com.sun.star.embed.StorageFactory" );
94 static ::rtl::OUString SERVICE_UICONFIGMGR = ::rtl::OUString::createFromAscii("com.sun.star.ui.UIConfigurationManager" );
95 static ::rtl::OUString SERVICE_DESKTOP = ::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop" );
96 static ::rtl::OUString SERVICE_MODULEMANAGER = ::rtl::OUString::createFromAscii("com.sun.star.frame.ModuleManager" );
97 static ::rtl::OUString SERVICE_GLOBALACCCFG = ::rtl::OUString::createFromAscii("com.sun.star.ui.GlobalAcceleratorConfiguration" );
98 static ::rtl::OUString SERVICE_MODULEUICONFIGSUPPLIER = ::rtl::OUString::createFromAscii("com.sun.star.ui.ModuleUIConfigurationManagerSupplier");
99 static ::rtl::OUString SERVICE_UICMDDESCRIPTION = ::rtl::OUString::createFromAscii("com.sun.star.frame.UICommandDescription" );
100
101 static ::rtl::OUString MODULEPROP_SHORTNAME = ::rtl::OUString::createFromAscii("ooSetupFactoryShortName" );
102 static ::rtl::OUString MODULEPROP_UINAME = ::rtl::OUString::createFromAscii("ooSetupFactoryUIName" );
103 static ::rtl::OUString CMDPROP_UINAME = ::rtl::OUString::createFromAscii("Name" );
104
105 static ::rtl::OUString FOLDERNAME_UICONFIG = ::rtl::OUString::createFromAscii("Configurations2" );
106
107 static ::rtl::OUString MEDIATYPE_PROPNAME = ::rtl::OUString::createFromAscii("MediaType" );
108 static ::rtl::OUString MEDIATYPE_UICONFIG = ::rtl::OUString::createFromAscii("application/vnd.sun.xml.ui.configuration" );
109
110 //-----------------------------------------------
111 static sal_uInt16 __FAR_DATA KEYCODE_ARRAY[] =
112 {
113 KEY_F1 ,
114 KEY_F2 ,
115 KEY_F3 ,
116 KEY_F4 ,
117 KEY_F5 ,
118 KEY_F6 ,
119 KEY_F7 ,
120 KEY_F8 ,
121 KEY_F9 ,
122 KEY_F10 ,
123 KEY_F11 ,
124 KEY_F12 ,
125
126 KEY_DOWN ,
127 KEY_UP ,
128 KEY_LEFT ,
129 KEY_RIGHT ,
130 KEY_HOME ,
131 KEY_END ,
132 KEY_PAGEUP ,
133 KEY_PAGEDOWN ,
134 KEY_RETURN ,
135 KEY_ESCAPE ,
136 KEY_BACKSPACE,
137 KEY_INSERT ,
138 KEY_DELETE ,
139
140 KEY_OPEN ,
141 KEY_CUT ,
142 KEY_COPY ,
143 KEY_PASTE ,
144 KEY_UNDO ,
145 KEY_REPEAT ,
146 KEY_FIND ,
147 KEY_PROPERTIES ,
148 KEY_FRONT ,
149 KEY_CONTEXTMENU ,
150 KEY_MENU ,
151 KEY_HELP ,
152
153 KEY_F1 | KEY_SHIFT,
154 KEY_F2 | KEY_SHIFT,
155 KEY_F3 | KEY_SHIFT,
156 KEY_F4 | KEY_SHIFT,
157 KEY_F5 | KEY_SHIFT,
158 KEY_F6 | KEY_SHIFT,
159 KEY_F7 | KEY_SHIFT,
160 KEY_F8 | KEY_SHIFT,
161 KEY_F9 | KEY_SHIFT,
162 KEY_F10 | KEY_SHIFT,
163 KEY_F11 | KEY_SHIFT,
164 KEY_F12 | KEY_SHIFT,
165
166 KEY_DOWN | KEY_SHIFT,
167 KEY_UP | KEY_SHIFT,
168 KEY_LEFT | KEY_SHIFT,
169 KEY_RIGHT | KEY_SHIFT,
170 KEY_HOME | KEY_SHIFT,
171 KEY_END | KEY_SHIFT,
172 KEY_PAGEUP | KEY_SHIFT,
173 KEY_PAGEDOWN | KEY_SHIFT,
174 KEY_RETURN | KEY_SHIFT,
175 KEY_SPACE | KEY_SHIFT,
176 KEY_ESCAPE | KEY_SHIFT,
177 KEY_BACKSPACE | KEY_SHIFT,
178 KEY_INSERT | KEY_SHIFT,
179 KEY_DELETE | KEY_SHIFT,
180
181 KEY_0 | KEY_MOD1 ,
182 KEY_1 | KEY_MOD1 ,
183 KEY_2 | KEY_MOD1 ,
184 KEY_3 | KEY_MOD1 ,
185 KEY_4 | KEY_MOD1 ,
186 KEY_5 | KEY_MOD1 ,
187 KEY_6 | KEY_MOD1 ,
188 KEY_7 | KEY_MOD1 ,
189 KEY_8 | KEY_MOD1 ,
190 KEY_9 | KEY_MOD1 ,
191 KEY_A | KEY_MOD1 ,
192 KEY_B | KEY_MOD1 ,
193 KEY_C | KEY_MOD1 ,
194 KEY_D | KEY_MOD1 ,
195 KEY_E | KEY_MOD1 ,
196 KEY_F | KEY_MOD1 ,
197 KEY_G | KEY_MOD1 ,
198 KEY_H | KEY_MOD1 ,
199 KEY_I | KEY_MOD1 ,
200 KEY_J | KEY_MOD1 ,
201 KEY_K | KEY_MOD1 ,
202 KEY_L | KEY_MOD1 ,
203 KEY_M | KEY_MOD1 ,
204 KEY_N | KEY_MOD1 ,
205 KEY_O | KEY_MOD1 ,
206 KEY_P | KEY_MOD1 ,
207 KEY_Q | KEY_MOD1 ,
208 KEY_R | KEY_MOD1 ,
209 KEY_S | KEY_MOD1 ,
210 KEY_T | KEY_MOD1 ,
211 KEY_U | KEY_MOD1 ,
212 KEY_V | KEY_MOD1 ,
213 KEY_W | KEY_MOD1 ,
214 KEY_X | KEY_MOD1 ,
215 KEY_Y | KEY_MOD1 ,
216 KEY_Z | KEY_MOD1 ,
217
218 KEY_F1 | KEY_MOD1 ,
219 KEY_F2 | KEY_MOD1 ,
220 KEY_F3 | KEY_MOD1 ,
221 KEY_F4 | KEY_MOD1 ,
222 KEY_F5 | KEY_MOD1 ,
223 KEY_F6 | KEY_MOD1 ,
224 KEY_F7 | KEY_MOD1 ,
225 KEY_F8 | KEY_MOD1 ,
226 KEY_F9 | KEY_MOD1 ,
227 KEY_F10 | KEY_MOD1 ,
228 KEY_F11 | KEY_MOD1 ,
229 KEY_F12 | KEY_MOD1 ,
230
231 KEY_DOWN | KEY_MOD1 ,
232 KEY_UP | KEY_MOD1 ,
233 KEY_LEFT | KEY_MOD1 ,
234 KEY_RIGHT | KEY_MOD1 ,
235 KEY_HOME | KEY_MOD1 ,
236 KEY_END | KEY_MOD1 ,
237 KEY_PAGEUP | KEY_MOD1 ,
238 KEY_PAGEDOWN | KEY_MOD1 ,
239 KEY_RETURN | KEY_MOD1 ,
240 KEY_SPACE | KEY_MOD1 ,
241 KEY_BACKSPACE | KEY_MOD1 ,
242 KEY_INSERT | KEY_MOD1 ,
243 KEY_DELETE | KEY_MOD1 ,
244
245 KEY_ADD | KEY_MOD1 ,
246 KEY_SUBTRACT | KEY_MOD1 ,
247 KEY_MULTIPLY | KEY_MOD1 ,
248 KEY_DIVIDE | KEY_MOD1 ,
249
250 KEY_0 | KEY_SHIFT | KEY_MOD1,
251 KEY_1 | KEY_SHIFT | KEY_MOD1,
252 KEY_2 | KEY_SHIFT | KEY_MOD1,
253 KEY_3 | KEY_SHIFT | KEY_MOD1,
254 KEY_4 | KEY_SHIFT | KEY_MOD1,
255 KEY_5 | KEY_SHIFT | KEY_MOD1,
256 KEY_6 | KEY_SHIFT | KEY_MOD1,
257 KEY_7 | KEY_SHIFT | KEY_MOD1,
258 KEY_8 | KEY_SHIFT | KEY_MOD1,
259 KEY_9 | KEY_SHIFT | KEY_MOD1,
260 KEY_A | KEY_SHIFT | KEY_MOD1,
261 KEY_B | KEY_SHIFT | KEY_MOD1,
262 KEY_C | KEY_SHIFT | KEY_MOD1,
263 KEY_D | KEY_SHIFT | KEY_MOD1,
264 KEY_E | KEY_SHIFT | KEY_MOD1,
265 KEY_F | KEY_SHIFT | KEY_MOD1,
266 KEY_G | KEY_SHIFT | KEY_MOD1,
267 KEY_H | KEY_SHIFT | KEY_MOD1,
268 KEY_I | KEY_SHIFT | KEY_MOD1,
269 KEY_J | KEY_SHIFT | KEY_MOD1,
270 KEY_K | KEY_SHIFT | KEY_MOD1,
271 KEY_L | KEY_SHIFT | KEY_MOD1,
272 KEY_M | KEY_SHIFT | KEY_MOD1,
273 KEY_N | KEY_SHIFT | KEY_MOD1,
274 KEY_O | KEY_SHIFT | KEY_MOD1,
275 KEY_P | KEY_SHIFT | KEY_MOD1,
276 KEY_Q | KEY_SHIFT | KEY_MOD1,
277 KEY_R | KEY_SHIFT | KEY_MOD1,
278 KEY_S | KEY_SHIFT | KEY_MOD1,
279 KEY_T | KEY_SHIFT | KEY_MOD1,
280 KEY_U | KEY_SHIFT | KEY_MOD1,
281 KEY_V | KEY_SHIFT | KEY_MOD1,
282 KEY_W | KEY_SHIFT | KEY_MOD1,
283 KEY_X | KEY_SHIFT | KEY_MOD1,
284 KEY_Y | KEY_SHIFT | KEY_MOD1,
285 KEY_Z | KEY_SHIFT | KEY_MOD1,
286
287 KEY_F1 | KEY_SHIFT | KEY_MOD1,
288 KEY_F2 | KEY_SHIFT | KEY_MOD1,
289 KEY_F3 | KEY_SHIFT | KEY_MOD1,
290 KEY_F4 | KEY_SHIFT | KEY_MOD1,
291 KEY_F5 | KEY_SHIFT | KEY_MOD1,
292 KEY_F6 | KEY_SHIFT | KEY_MOD1,
293 KEY_F7 | KEY_SHIFT | KEY_MOD1,
294 KEY_F8 | KEY_SHIFT | KEY_MOD1,
295 KEY_F9 | KEY_SHIFT | KEY_MOD1,
296 KEY_F10 | KEY_SHIFT | KEY_MOD1,
297 KEY_F11 | KEY_SHIFT | KEY_MOD1,
298 KEY_F12 | KEY_SHIFT | KEY_MOD1,
299
300 KEY_DOWN | KEY_SHIFT | KEY_MOD1,
301 KEY_UP | KEY_SHIFT | KEY_MOD1,
302 KEY_LEFT | KEY_SHIFT | KEY_MOD1,
303 KEY_RIGHT | KEY_SHIFT | KEY_MOD1,
304 KEY_HOME | KEY_SHIFT | KEY_MOD1,
305 KEY_END | KEY_SHIFT | KEY_MOD1,
306 KEY_PAGEUP | KEY_SHIFT | KEY_MOD1,
307 KEY_PAGEDOWN | KEY_SHIFT | KEY_MOD1,
308 KEY_RETURN | KEY_SHIFT | KEY_MOD1,
309 KEY_SPACE | KEY_SHIFT | KEY_MOD1,
310 KEY_BACKSPACE | KEY_SHIFT | KEY_MOD1,
311 KEY_INSERT | KEY_SHIFT | KEY_MOD1,
312 KEY_DELETE | KEY_SHIFT | KEY_MOD1,
313
314 KEY_0 | KEY_MOD2 ,
315 KEY_1 | KEY_MOD2 ,
316 KEY_2 | KEY_MOD2 ,
317 KEY_3 | KEY_MOD2 ,
318 KEY_4 | KEY_MOD2 ,
319 KEY_5 | KEY_MOD2 ,
320 KEY_6 | KEY_MOD2 ,
321 KEY_7 | KEY_MOD2 ,
322 KEY_8 | KEY_MOD2 ,
323 KEY_9 | KEY_MOD2 ,
324 KEY_A | KEY_MOD2 ,
325 KEY_B | KEY_MOD2 ,
326 KEY_C | KEY_MOD2 ,
327 KEY_D | KEY_MOD2 ,
328 KEY_E | KEY_MOD2 ,
329 KEY_F | KEY_MOD2 ,
330 KEY_G | KEY_MOD2 ,
331 KEY_H | KEY_MOD2 ,
332 KEY_I | KEY_MOD2 ,
333 KEY_J | KEY_MOD2 ,
334 KEY_K | KEY_MOD2 ,
335 KEY_L | KEY_MOD2 ,
336 KEY_M | KEY_MOD2 ,
337 KEY_N | KEY_MOD2 ,
338 KEY_O | KEY_MOD2 ,
339 KEY_P | KEY_MOD2 ,
340 KEY_Q | KEY_MOD2 ,
341 KEY_R | KEY_MOD2 ,
342 KEY_S | KEY_MOD2 ,
343 KEY_T | KEY_MOD2 ,
344 KEY_U | KEY_MOD2 ,
345 KEY_V | KEY_MOD2 ,
346 KEY_W | KEY_MOD2 ,
347 KEY_X | KEY_MOD2 ,
348 KEY_Y | KEY_MOD2 ,
349 KEY_Z | KEY_MOD2 ,
350
351 KEY_F1 | KEY_MOD2 ,
352 KEY_F2 | KEY_MOD2 ,
353 KEY_F3 | KEY_MOD2 ,
354 KEY_F4 | KEY_MOD2 ,
355 KEY_F5 | KEY_MOD2 ,
356 KEY_F6 | KEY_MOD2 ,
357 KEY_F7 | KEY_MOD2 ,
358 KEY_F8 | KEY_MOD2 ,
359 KEY_F9 | KEY_MOD2 ,
360 KEY_F10 | KEY_MOD2 ,
361 KEY_F11 | KEY_MOD2 ,
362 KEY_F12 | KEY_MOD2 ,
363
364 KEY_DOWN | KEY_MOD2 ,
365 KEY_UP | KEY_MOD2 ,
366 KEY_LEFT | KEY_MOD2 ,
367 KEY_RIGHT | KEY_MOD2 ,
368 KEY_HOME | KEY_MOD2 ,
369 KEY_END | KEY_MOD2 ,
370 KEY_PAGEUP | KEY_MOD2 ,
371 KEY_PAGEDOWN | KEY_MOD2 ,
372 KEY_RETURN | KEY_MOD2 ,
373 KEY_SPACE | KEY_MOD2 ,
374 KEY_BACKSPACE | KEY_MOD2 ,
375 KEY_INSERT | KEY_MOD2 ,
376 KEY_DELETE | KEY_MOD2 ,
377
378 KEY_0 | KEY_SHIFT | KEY_MOD2,
379 KEY_1 | KEY_SHIFT | KEY_MOD2,
380 KEY_2 | KEY_SHIFT | KEY_MOD2,
381 KEY_3 | KEY_SHIFT | KEY_MOD2,
382 KEY_4 | KEY_SHIFT | KEY_MOD2,
383 KEY_5 | KEY_SHIFT | KEY_MOD2,
384 KEY_6 | KEY_SHIFT | KEY_MOD2,
385 KEY_7 | KEY_SHIFT | KEY_MOD2,
386 KEY_8 | KEY_SHIFT | KEY_MOD2,
387 KEY_9 | KEY_SHIFT | KEY_MOD2,
388 KEY_A | KEY_SHIFT | KEY_MOD2,
389 KEY_B | KEY_SHIFT | KEY_MOD2,
390 KEY_C | KEY_SHIFT | KEY_MOD2,
391 KEY_D | KEY_SHIFT | KEY_MOD2,
392 KEY_E | KEY_SHIFT | KEY_MOD2,
393 KEY_F | KEY_SHIFT | KEY_MOD2,
394 KEY_G | KEY_SHIFT | KEY_MOD2,
395 KEY_H | KEY_SHIFT | KEY_MOD2,
396 KEY_I | KEY_SHIFT | KEY_MOD2,
397 KEY_J | KEY_SHIFT | KEY_MOD2,
398 KEY_K | KEY_SHIFT | KEY_MOD2,
399 KEY_L | KEY_SHIFT | KEY_MOD2,
400 KEY_M | KEY_SHIFT | KEY_MOD2,
401 KEY_N | KEY_SHIFT | KEY_MOD2,
402 KEY_O | KEY_SHIFT | KEY_MOD2,
403 KEY_P | KEY_SHIFT | KEY_MOD2,
404 KEY_Q | KEY_SHIFT | KEY_MOD2,
405 KEY_R | KEY_SHIFT | KEY_MOD2,
406 KEY_S | KEY_SHIFT | KEY_MOD2,
407 KEY_T | KEY_SHIFT | KEY_MOD2,
408 KEY_U | KEY_SHIFT | KEY_MOD2,
409 KEY_V | KEY_SHIFT | KEY_MOD2,
410 KEY_W | KEY_SHIFT | KEY_MOD2,
411 KEY_X | KEY_SHIFT | KEY_MOD2,
412 KEY_Y | KEY_SHIFT | KEY_MOD2,
413 KEY_Z | KEY_SHIFT | KEY_MOD2,
414
415 KEY_F1 | KEY_SHIFT | KEY_MOD2,
416 KEY_F2 | KEY_SHIFT | KEY_MOD2,
417 KEY_F3 | KEY_SHIFT | KEY_MOD2,
418 KEY_F4 | KEY_SHIFT | KEY_MOD2,
419 KEY_F5 | KEY_SHIFT | KEY_MOD2,
420 KEY_F6 | KEY_SHIFT | KEY_MOD2,
421 KEY_F7 | KEY_SHIFT | KEY_MOD2,
422 KEY_F8 | KEY_SHIFT | KEY_MOD2,
423 KEY_F9 | KEY_SHIFT | KEY_MOD2,
424 KEY_F10 | KEY_SHIFT | KEY_MOD2,
425 KEY_F11 | KEY_SHIFT | KEY_MOD2,
426 KEY_F12 | KEY_SHIFT | KEY_MOD2,
427
428 KEY_DOWN | KEY_SHIFT | KEY_MOD2,
429 KEY_UP | KEY_SHIFT | KEY_MOD2,
430 KEY_LEFT | KEY_SHIFT | KEY_MOD2,
431 KEY_RIGHT | KEY_SHIFT | KEY_MOD2,
432 KEY_HOME | KEY_SHIFT | KEY_MOD2,
433 KEY_END | KEY_SHIFT | KEY_MOD2,
434 KEY_PAGEUP | KEY_SHIFT | KEY_MOD2,
435 KEY_PAGEDOWN | KEY_SHIFT | KEY_MOD2,
436 KEY_RETURN | KEY_SHIFT | KEY_MOD2,
437 KEY_SPACE | KEY_SHIFT | KEY_MOD2,
438 KEY_BACKSPACE | KEY_SHIFT | KEY_MOD2,
439 KEY_INSERT | KEY_SHIFT | KEY_MOD2,
440 KEY_DELETE | KEY_SHIFT | KEY_MOD2,
441
442 KEY_0 | KEY_MOD1 | KEY_MOD2 ,
443 KEY_1 | KEY_MOD1 | KEY_MOD2 ,
444 KEY_2 | KEY_MOD1 | KEY_MOD2 ,
445 KEY_3 | KEY_MOD1 | KEY_MOD2 ,
446 KEY_4 | KEY_MOD1 | KEY_MOD2 ,
447 KEY_5 | KEY_MOD1 | KEY_MOD2 ,
448 KEY_6 | KEY_MOD1 | KEY_MOD2 ,
449 KEY_7 | KEY_MOD1 | KEY_MOD2 ,
450 KEY_8 | KEY_MOD1 | KEY_MOD2 ,
451 KEY_9 | KEY_MOD1 | KEY_MOD2 ,
452 KEY_A | KEY_MOD1 | KEY_MOD2 ,
453 KEY_B | KEY_MOD1 | KEY_MOD2 ,
454 KEY_C | KEY_MOD1 | KEY_MOD2 ,
455 KEY_D | KEY_MOD1 | KEY_MOD2 ,
456 KEY_E | KEY_MOD1 | KEY_MOD2 ,
457 KEY_F | KEY_MOD1 | KEY_MOD2 ,
458 KEY_G | KEY_MOD1 | KEY_MOD2 ,
459 KEY_H | KEY_MOD1 | KEY_MOD2 ,
460 KEY_I | KEY_MOD1 | KEY_MOD2 ,
461 KEY_J | KEY_MOD1 | KEY_MOD2 ,
462 KEY_K | KEY_MOD1 | KEY_MOD2 ,
463 KEY_L | KEY_MOD1 | KEY_MOD2 ,
464 KEY_M | KEY_MOD1 | KEY_MOD2 ,
465 KEY_N | KEY_MOD1 | KEY_MOD2 ,
466 KEY_O | KEY_MOD1 | KEY_MOD2 ,
467 KEY_P | KEY_MOD1 | KEY_MOD2 ,
468 KEY_Q | KEY_MOD1 | KEY_MOD2 ,
469 KEY_R | KEY_MOD1 | KEY_MOD2 ,
470 KEY_S | KEY_MOD1 | KEY_MOD2 ,
471 KEY_T | KEY_MOD1 | KEY_MOD2 ,
472 KEY_U | KEY_MOD1 | KEY_MOD2 ,
473 KEY_V | KEY_MOD1 | KEY_MOD2 ,
474 KEY_W | KEY_MOD1 | KEY_MOD2 ,
475 KEY_X | KEY_MOD1 | KEY_MOD2 ,
476 KEY_Y | KEY_MOD1 | KEY_MOD2 ,
477 KEY_Z | KEY_MOD1 | KEY_MOD2 ,
478
479 KEY_F1 | KEY_MOD1 | KEY_MOD2 ,
480 KEY_F2 | KEY_MOD1 | KEY_MOD2 ,
481 KEY_F3 | KEY_MOD1 | KEY_MOD2 ,
482 KEY_F4 | KEY_MOD1 | KEY_MOD2 ,
483 KEY_F5 | KEY_MOD1 | KEY_MOD2 ,
484 KEY_F6 | KEY_MOD1 | KEY_MOD2 ,
485 KEY_F7 | KEY_MOD1 | KEY_MOD2 ,
486 KEY_F8 | KEY_MOD1 | KEY_MOD2 ,
487 KEY_F9 | KEY_MOD1 | KEY_MOD2 ,
488 KEY_F10 | KEY_MOD1 | KEY_MOD2 ,
489 KEY_F11 | KEY_MOD1 | KEY_MOD2 ,
490 KEY_F12 | KEY_MOD1 | KEY_MOD2 ,
491
492 KEY_DOWN | KEY_MOD1 | KEY_MOD2 ,
493 KEY_UP | KEY_MOD1 | KEY_MOD2 ,
494 KEY_LEFT | KEY_MOD1 | KEY_MOD2 ,
495 KEY_RIGHT | KEY_MOD1 | KEY_MOD2 ,
496 KEY_HOME | KEY_MOD1 | KEY_MOD2 ,
497 KEY_END | KEY_MOD1 | KEY_MOD2 ,
498 KEY_PAGEUP | KEY_MOD1 | KEY_MOD2 ,
499 KEY_PAGEDOWN | KEY_MOD1 | KEY_MOD2 ,
500 KEY_RETURN | KEY_MOD1 | KEY_MOD2 ,
501 KEY_SPACE | KEY_MOD1 | KEY_MOD2 ,
502 KEY_BACKSPACE | KEY_MOD1 | KEY_MOD2 ,
503 KEY_INSERT | KEY_MOD1 | KEY_MOD2 ,
504 KEY_DELETE | KEY_MOD1 | KEY_MOD2 ,
505
506 KEY_0 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
507 KEY_1 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
508 KEY_2 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
509 KEY_3 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
510 KEY_4 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
511 KEY_5 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
512 KEY_6 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
513 KEY_7 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
514 KEY_8 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
515 KEY_9 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
516 KEY_A | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
517 KEY_B | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
518 KEY_C | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
519 KEY_D | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
520 KEY_E | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
521 KEY_F | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
522 KEY_G | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
523 KEY_H | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
524 KEY_I | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
525 KEY_J | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
526 KEY_K | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
527 KEY_L | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
528 KEY_M | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
529 KEY_N | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
530 KEY_O | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
531 KEY_P | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
532 KEY_Q | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
533 KEY_R | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
534 KEY_S | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
535 KEY_T | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
536 KEY_U | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
537 KEY_V | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
538 KEY_W | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
539 KEY_X | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
540 KEY_Y | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
541 KEY_Z | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
542
543 KEY_F1 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
544 KEY_F2 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
545 KEY_F3 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
546 KEY_F4 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
547 KEY_F5 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
548 KEY_F6 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
549 KEY_F7 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
550 KEY_F8 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
551 KEY_F9 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
552 KEY_F10 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
553 KEY_F11 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
554 KEY_F12 | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
555
556 KEY_DOWN | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
557 KEY_UP | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
558 KEY_LEFT | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
559 KEY_RIGHT | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
560 KEY_HOME | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
561 KEY_END | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
562 KEY_PAGEUP | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
563 KEY_PAGEDOWN | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
564 KEY_RETURN | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
565 KEY_SPACE | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
566 KEY_BACKSPACE | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
567 KEY_INSERT | KEY_SHIFT | KEY_MOD1 | KEY_MOD2,
568 KEY_DELETE | KEY_SHIFT | KEY_MOD1 | KEY_MOD2
569 };
570
571 static sal_uInt16 KEYCODE_ARRAY_SIZE = (sizeof(KEYCODE_ARRAY) / sizeof(KEYCODE_ARRAY[0]));
572
573 //-----------------------------------------------
574 // seems to be needed to layout the list box, which shows all
575 // assignable shortcuts
576 static long AccCfgTabs[] =
577 {
578 2, // Number of Tabs
579 0,
580 120 // Function
581 };
582
583 //-----------------------------------------------
584 class SfxAccCfgLBoxString_Impl : public SvLBoxString
585 {
586 public:
587 SfxAccCfgLBoxString_Impl( SvLBoxEntry* pEntry,
588 sal_uInt16 nFlags,
589 const String& sText );
590
591 virtual ~SfxAccCfgLBoxString_Impl();
592
593 virtual void Paint(const Point& aPos ,
594 SvLBox& rDevice,
595 sal_uInt16 nFlags ,
596 SvLBoxEntry* pEntry );
597 };
598
599 //-----------------------------------------------
SfxAccCfgLBoxString_Impl(SvLBoxEntry * pEntry,sal_uInt16 nFlags,const String & sText)600 SfxAccCfgLBoxString_Impl::SfxAccCfgLBoxString_Impl( SvLBoxEntry* pEntry,
601 sal_uInt16 nFlags,
602 const String& sText )
603 : SvLBoxString(pEntry, nFlags, sText)
604 {
605 }
606
607 //-----------------------------------------------
~SfxAccCfgLBoxString_Impl()608 SfxAccCfgLBoxString_Impl::~SfxAccCfgLBoxString_Impl()
609 {
610 }
611
612 //-----------------------------------------------
Paint(const Point & aPos,SvLBox & rDevice,sal_uInt16,SvLBoxEntry * pEntry)613 void SfxAccCfgLBoxString_Impl::Paint(const Point& aPos ,
614 SvLBox& rDevice,
615 sal_uInt16 /*nFlags*/,
616 SvLBoxEntry* pEntry )
617 {
618 /*/ ??? realy needed !!!
619 Font aOldFont(rDevice.GetFont());
620 Font aNewFont(aOldFont );
621 rDevice.SetFont( aFont );
622 */
623
624 if (!pEntry)
625 return;
626
627 TAccInfo* pUserData = (TAccInfo*)pEntry->GetUserData();
628 if (!pUserData)
629 return;
630
631 if (pUserData->m_bIsConfigurable)
632 rDevice.DrawText(aPos, GetText());
633 else
634 rDevice.DrawCtrlText(aPos, GetText(), 0, STRING_LEN, TEXT_DRAW_DISABLE);
635
636 //rDev.SetFont( aOldFont );
637 }
638
639 //-----------------------------------------------
InitEntry(SvLBoxEntry * pEntry,const XubString & sText,const Image & aImage1,const Image & aImage2,SvLBoxButtonKind eButtonKind)640 void SfxAccCfgTabListBox_Impl::InitEntry( SvLBoxEntry* pEntry ,
641 const XubString& sText ,
642 const Image& aImage1,
643 const Image& aImage2,
644 SvLBoxButtonKind eButtonKind)
645 {
646 SvTabListBox::InitEntry(pEntry, sText, aImage1, aImage2, eButtonKind);
647 }
648
649 //-----------------------------------------------
650 /** select the entry, which match the current key input ... excepting
651 keys, which are used for the dialog itself.
652 */
KeyInput(const KeyEvent & aKey)653 void SfxAccCfgTabListBox_Impl::KeyInput(const KeyEvent& aKey)
654 {
655 KeyCode aCode1 = aKey.GetKeyCode();
656 sal_uInt16 nCode1 = aCode1.GetCode();
657 sal_uInt16 nMod1 = aCode1.GetModifier();
658
659 // is it related to our list box ?
660 if (
661 (nCode1 != KEY_DOWN ) &&
662 (nCode1 != KEY_UP ) &&
663 (nCode1 != KEY_LEFT ) &&
664 (nCode1 != KEY_RIGHT ) &&
665 (nCode1 != KEY_PAGEUP ) &&
666 (nCode1 != KEY_PAGEDOWN)
667 )
668 {
669 SvLBoxEntry* pEntry = First();
670 while (pEntry)
671 {
672 TAccInfo* pUserData = (TAccInfo*)pEntry->GetUserData();
673 if (pUserData)
674 {
675 sal_uInt16 nCode2 = pUserData->m_aKey.GetCode();
676 sal_uInt16 nMod2 = pUserData->m_aKey.GetModifier();
677 if (
678 (nCode1 == nCode2) &&
679 (nMod1 == nMod2 )
680 )
681 {
682 Select (pEntry);
683 MakeVisible(pEntry);
684 return;
685 }
686 }
687 pEntry = Next(pEntry);
688 }
689 }
690
691 // no - handle it as normal dialog input
692 SvTabListBox::KeyInput(aKey);
693 }
694
695 //-----------------------------------------------
SfxAcceleratorConfigPage(Window * pParent,const SfxItemSet & aSet)696 SfxAcceleratorConfigPage::SfxAcceleratorConfigPage( Window* pParent, const SfxItemSet& aSet )
697 : SfxTabPage (pParent, CUI_RES(RID_SVXPAGE_KEYBOARD), aSet)
698 , m_pMacroInfoItem ()
699 , m_pStringItem ()
700 , m_pFontItem ()
701 , m_pFileDlg (NULL)
702 , aEntriesBox (this , this, CUI_RES(BOX_ACC_ENTRIES ))
703 , aKeyboardGroup (this , CUI_RES(GRP_ACC_KEYBOARD ))
704 , aOfficeButton (this , CUI_RES(RB_OFFICE ))
705 , aModuleButton (this , CUI_RES(RB_MODULE ))
706 , aChangeButton (this , CUI_RES(BTN_ACC_CHANGE ))
707 , aRemoveButton (this , CUI_RES(BTN_ACC_REMOVE ))
708 , aGroupText (this , CUI_RES(TXT_ACC_GROUP ))
709 , pGroupLBox(new SfxConfigGroupListBox_Impl( this, CUI_RES(BOX_ACC_GROUP), SFX_SLOT_ACCELCONFIG ))
710 , aFunctionText (this , CUI_RES(TXT_ACC_FUNCTION ))
711 , pFunctionBox(new SfxConfigFunctionListBox_Impl( this, CUI_RES( BOX_ACC_FUNCTION )))
712 , aKeyText (this , CUI_RES(TXT_ACC_KEY ))
713 , aKeyBox (this , CUI_RES(BOX_ACC_KEY ))
714 , aFunctionsGroup (this , CUI_RES(GRP_ACC_FUNCTIONS ))
715 , aLoadButton (this , CUI_RES(BTN_LOAD ))
716 , aSaveButton (this , CUI_RES(BTN_SAVE ))
717 , aResetButton (this , CUI_RES(BTN_RESET ))
718 , aLoadAccelConfigStr ( CUI_RES( STR_LOADACCELCONFIG ) )
719 , aSaveAccelConfigStr ( CUI_RES( STR_SAVEACCELCONFIG ) )
720 , aFilterCfgStr ( CUI_RES( STR_FILTERNAME_CFG ) )
721 , m_bStylesInfoInitialized(sal_False)
722 , m_xGlobal ()
723 , m_xModule ()
724 , m_xAct ()
725 {
726 FreeResource();
727
728 aFilterAllStr = String( SfxResId( STR_SFX_FILTERNAME_ALL ) );
729
730 // install handler functions
731 aChangeButton.SetClickHdl( LINK( this, SfxAcceleratorConfigPage, ChangeHdl ));
732 aRemoveButton.SetClickHdl( LINK( this, SfxAcceleratorConfigPage, RemoveHdl ));
733 aEntriesBox.SetSelectHdl ( LINK( this, SfxAcceleratorConfigPage, SelectHdl ));
734 pGroupLBox->SetSelectHdl ( LINK( this, SfxAcceleratorConfigPage, SelectHdl ));
735 pFunctionBox->SetSelectHdl( LINK( this, SfxAcceleratorConfigPage, SelectHdl ));
736 aKeyBox.SetSelectHdl ( LINK( this, SfxAcceleratorConfigPage, SelectHdl ));
737 aLoadButton.SetClickHdl ( LINK( this, SfxAcceleratorConfigPage, Load ));
738 aSaveButton.SetClickHdl ( LINK( this, SfxAcceleratorConfigPage, Save ));
739 aResetButton.SetClickHdl ( LINK( this, SfxAcceleratorConfigPage, Default ));
740 aOfficeButton.SetClickHdl( LINK( this, SfxAcceleratorConfigPage, RadioHdl ));
741 aModuleButton.SetClickHdl( LINK( this, SfxAcceleratorConfigPage, RadioHdl ));
742
743 // initialize Entriesbox
744 aEntriesBox.SetStyle(aEntriesBox.GetStyle()|WB_HSCROLL|WB_CLIPCHILDREN);
745 aEntriesBox.SetSelectionMode(SINGLE_SELECTION);
746 aEntriesBox.SetTabs(&AccCfgTabs[0], MAP_APPFONT);
747 aEntriesBox.Resize(); // OS: Hack for right selection
748 aEntriesBox.SetSpaceBetweenEntries(0);
749 aEntriesBox.SetDragDropMode(0);
750
751 // detect max keyname width
752 long nMaxWidth = 0;
753 for ( sal_uInt16 i = 0; i < KEYCODE_ARRAY_SIZE; ++i )
754 {
755 long nTmp = GetTextWidth( KeyCode( KEYCODE_ARRAY[i] ).GetName() );
756 if ( nTmp > nMaxWidth )
757 nMaxWidth = nTmp;
758 }
759 // recalc second tab
760 long nNewTab = PixelToLogic( Size( nMaxWidth, 0 ), MAP_APPFONT ).Width();
761 nNewTab = nNewTab + 5; // additional space
762 aEntriesBox.SetTab( 1, nNewTab );
763
764 // initialize GroupBox
765 pGroupLBox->SetFunctionListBox(pFunctionBox);
766
767 // initialize KeyBox
768 aKeyBox.SetStyle(aKeyBox.GetStyle()|WB_CLIPCHILDREN|WB_HSCROLL|WB_SORT);
769 }
770
771 //-----------------------------------------------
~SfxAcceleratorConfigPage()772 SfxAcceleratorConfigPage::~SfxAcceleratorConfigPage()
773 {
774 // free memory - remove all dynamic user data
775 SvLBoxEntry* pEntry = aEntriesBox.First();
776 while (pEntry)
777 {
778 TAccInfo* pUserData = (TAccInfo*)pEntry->GetUserData();
779 if (pUserData)
780 delete pUserData;
781 pEntry = aEntriesBox.Next(pEntry);
782 }
783
784 pEntry = aKeyBox.First();
785 while (pEntry)
786 {
787 TAccInfo* pUserData = (TAccInfo*)pEntry->GetUserData();
788 if (pUserData)
789 delete pUserData;
790 pEntry = aKeyBox.Next(pEntry);
791 }
792
793 aEntriesBox.Clear();
794 aKeyBox.Clear();
795
796 delete m_pFileDlg;
797 delete pGroupLBox;
798 delete pFunctionBox;
799 }
800
801 //-----------------------------------------------
InitAccCfg()802 void SfxAcceleratorConfigPage::InitAccCfg()
803 {
804 // already initialized ?
805 if (m_xSMGR.is())
806 return; // yes -> do nothing
807
808 try
809 {
810 // no - initialize this instance
811 m_xSMGR = ::utl::getProcessServiceFactory();
812
813 m_xUICmdDescription = css::uno::Reference< css::container::XNameAccess >(m_xSMGR->createInstance(SERVICE_UICMDDESCRIPTION), css::uno::UNO_QUERY_THROW);
814
815 // get the current active frame, which should be our "parent"
816 // for this session
817 m_xFrame = GetFrame();
818 if ( !m_xFrame.is() )
819 {
820 css::uno::Reference< css::frame::XFramesSupplier > xDesktop(m_xSMGR->createInstance(SERVICE_DESKTOP), css::uno::UNO_QUERY_THROW);
821 m_xFrame = xDesktop->getActiveFrame();
822 }
823
824 // identify module
825 css::uno::Reference< css::frame::XModuleManager > xModuleManager (m_xSMGR->createInstance(SERVICE_MODULEMANAGER), css::uno::UNO_QUERY_THROW);
826 css::uno::Reference< css::container::XNameAccess > xModuleManagerCont(xModuleManager , css::uno::UNO_QUERY_THROW);
827 m_sModuleLongName = xModuleManager->identify(m_xFrame);
828 ::comphelper::SequenceAsHashMap lModuleProps(xModuleManagerCont->getByName(m_sModuleLongName));
829 m_sModuleShortName = lModuleProps.getUnpackedValueOrDefault(MODULEPROP_SHORTNAME, ::rtl::OUString());
830 m_sModuleUIName = lModuleProps.getUnpackedValueOrDefault(MODULEPROP_UINAME , ::rtl::OUString());
831
832 // get global accelerator configuration
833 m_xGlobal = css::uno::Reference< css::ui::XAcceleratorConfiguration >(m_xSMGR->createInstance(SERVICE_GLOBALACCCFG), css::uno::UNO_QUERY_THROW);
834
835 // get module accelerator configuration
836 css::uno::Reference< css::ui::XModuleUIConfigurationManagerSupplier > xModuleCfgSupplier(m_xSMGR->createInstance(SERVICE_MODULEUICONFIGSUPPLIER), css::uno::UNO_QUERY_THROW);
837 css::uno::Reference< css::ui::XUIConfigurationManager > xUICfgManager = xModuleCfgSupplier->getUIConfigurationManager(m_sModuleLongName);
838 m_xModule = css::uno::Reference< css::ui::XAcceleratorConfiguration >(xUICfgManager->getShortCutManager(), css::uno::UNO_QUERY_THROW);
839 }
840 catch(const css::uno::RuntimeException& exRun)
841 { throw exRun; }
842 catch(const css::uno::Exception&)
843 { m_xSMGR.clear(); }
844 }
845
846 //-----------------------------------------------
847 /** Initialize text columns with own class to enable custom painting
848 This is needed as we have to paint disabled entries by ourself. No support for that in the
849 original SvTabListBox!
850 */
CreateCustomItems(SvLBoxEntry * pEntry,const String & sCol1,const String & sCol2)851 void SfxAcceleratorConfigPage::CreateCustomItems( SvLBoxEntry* pEntry,
852 const String& sCol1 ,
853 const String& sCol2 )
854 {
855 SfxAccCfgLBoxString_Impl* pStringItem = new SfxAccCfgLBoxString_Impl(pEntry, 0, sCol1);
856 pEntry->ReplaceItem(pStringItem, 1);
857
858 pStringItem = new SfxAccCfgLBoxString_Impl(pEntry, 0, sCol2);
859 pEntry->ReplaceItem(pStringItem, 2);
860 }
861
862 //-----------------------------------------------
Init(const css::uno::Reference<css::ui::XAcceleratorConfiguration> & xAccMgr)863 void SfxAcceleratorConfigPage::Init(const css::uno::Reference< css::ui::XAcceleratorConfiguration >& xAccMgr)
864 {
865 if (!xAccMgr.is())
866 return;
867
868 if (!m_bStylesInfoInitialized)
869 {
870 css::uno::Reference< css::frame::XController > xController;
871 css::uno::Reference< css::frame::XModel > xModel;
872 if (m_xFrame.is())
873 xController = m_xFrame->getController();
874 if (xController.is())
875 xModel = xController->getModel();
876
877 m_aStylesInfo.setModel(xModel);
878 pFunctionBox->SetStylesInfo(&m_aStylesInfo);
879 pGroupLBox->SetStylesInfo(&m_aStylesInfo);
880 m_bStylesInfoInitialized = sal_True;
881 }
882
883 // Insert all editable accelerators into list box. It is possible
884 // that some accelerators are not mapped on the current system/keyboard
885 // but we don't want to lose these mappings.
886 sal_uInt16 c1 = KEYCODE_ARRAY_SIZE;
887 sal_uInt16 i1 = 0;
888 sal_uInt16 nListPos = 0;
889 for (i1=0; i1<c1; ++i1)
890 {
891 KeyCode aKey = KEYCODE_ARRAY[i1];
892 String sKey = aKey.GetName();
893 if (!sKey.Len())
894 continue;
895 TAccInfo* pEntry = new TAccInfo(i1, nListPos, aKey);
896 SvLBoxEntry* pLBEntry = aEntriesBox.InsertEntryToColumn(sKey, 0L, LIST_APPEND, 0xFFFF);
897 pLBEntry->SetUserData(pEntry);
898 }
899
900 // Assign all commands to its shortcuts - reading the accelerator config.
901 css::uno::Sequence< css::awt::KeyEvent > lKeys = xAccMgr->getAllKeyEvents();
902 sal_Int32 c2 = lKeys.getLength();
903 sal_Int32 i2 = 0;
904 sal_uInt16 nCol = aEntriesBox.TabCount()-1;
905
906 for (i2=0; i2<c2; ++i2)
907 {
908 const css::awt::KeyEvent& aAWTKey = lKeys[i2];
909 ::rtl::OUString sCommand = xAccMgr->getCommandByKeyEvent(aAWTKey);
910 String sLabel = GetLabel4Command(sCommand);
911 KeyCode aKeyCode = ::svt::AcceleratorExecute::st_AWTKey2VCLKey(aAWTKey);
912 sal_uInt16 nPos = MapKeyCodeToPos(aKeyCode);
913
914 if (nPos == LISTBOX_ENTRY_NOTFOUND)
915 continue;
916
917 aEntriesBox.SetEntryText(sLabel, nPos, nCol);
918
919 SvLBoxEntry* pLBEntry = aEntriesBox.GetEntry(0, nPos);
920 TAccInfo* pEntry = (TAccInfo*)pLBEntry->GetUserData();
921
922 pEntry->m_bIsConfigurable = sal_True;
923 pEntry->m_sCommand = sCommand;
924 CreateCustomItems(pLBEntry, aEntriesBox.GetEntryText(pLBEntry, 0), sLabel);
925 }
926
927 // Map the VCL hardcoded key codes and mark them as not changeable
928 sal_uLong c3 = Application::GetReservedKeyCodeCount();
929 sal_uLong i3 = 0;
930 for (i3=0; i3<c3; ++i3)
931 {
932 const KeyCode* pKeyCode = Application::GetReservedKeyCode(i3);
933 sal_uInt16 nPos = MapKeyCodeToPos(*pKeyCode);
934
935 if (nPos == LISTBOX_ENTRY_NOTFOUND)
936 continue;
937
938 // Hardcoded function mapped so no ID possible and mark entry as not changeable
939 SvLBoxEntry* pLBEntry = aEntriesBox.GetEntry(0, nPos);
940 TAccInfo* pEntry = (TAccInfo*)pLBEntry->GetUserData();
941
942 pEntry->m_bIsConfigurable = sal_False;
943 CreateCustomItems(pLBEntry, aEntriesBox.GetEntryText(pLBEntry, 0), String());
944 }
945 }
946
947 //-----------------------------------------------
Apply(const css::uno::Reference<css::ui::XAcceleratorConfiguration> & xAccMgr)948 void SfxAcceleratorConfigPage::Apply(const css::uno::Reference< css::ui::XAcceleratorConfiguration >& xAccMgr)
949 {
950 if (!xAccMgr.is())
951 return;
952
953 // Go through the list from the bottom to the top ...
954 // because logical accelerator must be preferred instead of
955 // physical ones!
956 SvLBoxEntry* pEntry = aEntriesBox.First();
957 while (pEntry)
958 {
959 TAccInfo* pUserData = (TAccInfo*)pEntry->GetUserData();
960 ::rtl::OUString sCommand ;
961 css::awt::KeyEvent aAWTKey ;
962
963 if (pUserData)
964 {
965 sCommand = pUserData->m_sCommand;
966 aAWTKey = ::svt::AcceleratorExecute::st_VCLKey2AWTKey(pUserData->m_aKey);
967 }
968
969 try
970 {
971 if (sCommand.getLength())
972 xAccMgr->setKeyEvent(aAWTKey, sCommand);
973 else
974 xAccMgr->removeKeyEvent(aAWTKey);
975 }
976 catch(const css::uno::RuntimeException& exRun)
977 { throw exRun; }
978 catch(const css::uno::Exception&)
979 {}
980
981 pEntry = aEntriesBox.Next(pEntry);
982 }
983 }
984
985 //-----------------------------------------------
ResetConfig()986 void SfxAcceleratorConfigPage::ResetConfig()
987 {
988 aEntriesBox.Clear();
989 }
990
991 //-----------------------------------------------
IMPL_LINK(SfxAcceleratorConfigPage,Load,Button *,EMPTYARG)992 IMPL_LINK( SfxAcceleratorConfigPage, Load, Button*, EMPTYARG )
993 {
994 // ask for filename, where we should load the new config data from
995 StartFileDialog( WB_OPEN | WB_STDMODAL | WB_3DLOOK, aLoadAccelConfigStr );
996 return 0;
997 }
998
999 //-----------------------------------------------
IMPL_LINK(SfxAcceleratorConfigPage,Save,Button *,EMPTYARG)1000 IMPL_LINK( SfxAcceleratorConfigPage, Save, Button*, EMPTYARG )
1001 {
1002 StartFileDialog( WB_SAVEAS | WB_STDMODAL | WB_3DLOOK, aSaveAccelConfigStr );
1003 return 0;
1004 }
1005
1006 //-----------------------------------------------
IMPL_LINK(SfxAcceleratorConfigPage,Default,PushButton *,EMPTYARG)1007 IMPL_LINK(SfxAcceleratorConfigPage, Default, PushButton*, EMPTYARG)
1008 {
1009 css::uno::Reference< css::form::XReset > xReset(m_xAct, css::uno::UNO_QUERY);
1010 if (xReset.is())
1011 xReset->reset();
1012
1013 aEntriesBox.SetUpdateMode(sal_False);
1014 ResetConfig();
1015 Init(m_xAct);
1016 aEntriesBox.SetUpdateMode(sal_True);
1017 aEntriesBox.Invalidate();
1018 aEntriesBox.Select(aEntriesBox.GetEntry(0, 0));
1019
1020 return 0;
1021 }
1022
1023 //-----------------------------------------------
IMPL_LINK(SfxAcceleratorConfigPage,ChangeHdl,Button *,EMPTYARG)1024 IMPL_LINK( SfxAcceleratorConfigPage, ChangeHdl, Button*, EMPTYARG )
1025 {
1026 sal_uInt16 nPos = (sal_uInt16) aEntriesBox.GetModel()->GetRelPos( aEntriesBox.FirstSelected() );
1027 TAccInfo* pEntry = (TAccInfo*)aEntriesBox.GetEntry(0, nPos)->GetUserData();
1028 String sNewCommand = pFunctionBox->GetCurCommand();
1029 String sLabel = pFunctionBox->GetCurLabel();
1030 if (!sLabel.Len())
1031 sLabel = GetLabel4Command(sNewCommand);
1032
1033 pEntry->m_sCommand = sNewCommand;
1034 sal_uInt16 nCol = aEntriesBox.TabCount() - 1;
1035 aEntriesBox.SetEntryText(sLabel, nPos, nCol);
1036
1037 ((Link &) pFunctionBox->GetSelectHdl()).Call( pFunctionBox );
1038 return 0;
1039 }
1040
1041 //-----------------------------------------------
IMPL_LINK(SfxAcceleratorConfigPage,RemoveHdl,Button *,EMPTYARG)1042 IMPL_LINK( SfxAcceleratorConfigPage, RemoveHdl, Button *, EMPTYARG )
1043 {
1044 // get selected entry
1045 sal_uInt16 nPos = (sal_uInt16) aEntriesBox.GetModel()->GetRelPos( aEntriesBox.FirstSelected() );
1046 TAccInfo* pEntry = (TAccInfo*)aEntriesBox.GetEntry(0, nPos)->GetUserData();
1047
1048 // remove function name from selected entry
1049 sal_uInt16 nCol = aEntriesBox.TabCount() - 1;
1050 aEntriesBox.SetEntryText( String(), nPos, nCol );
1051 pEntry->m_sCommand = ::rtl::OUString();
1052
1053 ((Link &) pFunctionBox->GetSelectHdl()).Call( pFunctionBox );
1054 return 0;
1055 }
1056
1057 //-----------------------------------------------
IMPL_LINK(SfxAcceleratorConfigPage,SelectHdl,Control *,pListBox)1058 IMPL_LINK( SfxAcceleratorConfigPage, SelectHdl, Control*, pListBox )
1059 {
1060 // disable help
1061 Help::ShowBalloon( this, Point(), String() );
1062 if ( pListBox == &aEntriesBox )
1063 {
1064 sal_uInt16 nPos = (sal_uInt16) aEntriesBox.GetModel()->GetRelPos( aEntriesBox.FirstSelected() );
1065 TAccInfo* pEntry = (TAccInfo*)aEntriesBox.GetEntry(0, nPos)->GetUserData();
1066 ::rtl::OUString sPossibleNewCommand = pFunctionBox->GetCurCommand();
1067
1068 aRemoveButton.Enable( sal_False );
1069 aChangeButton.Enable( sal_False );
1070
1071 if (pEntry->m_bIsConfigurable)
1072 {
1073 if (pEntry->isConfigured())
1074 aRemoveButton.Enable( sal_True );
1075 aChangeButton.Enable( pEntry->m_sCommand != sPossibleNewCommand );
1076 }
1077 }
1078 else if ( pListBox == pGroupLBox )
1079 {
1080 pGroupLBox->GroupSelected();
1081 if ( !pFunctionBox->FirstSelected() )
1082 aChangeButton.Enable( sal_False );
1083 }
1084 else if ( pListBox == pFunctionBox )
1085 {
1086 aRemoveButton.Enable( sal_False );
1087 aChangeButton.Enable( sal_False );
1088
1089 // #i36994 First selected can return zero!
1090 SvLBoxEntry* pLBEntry = aEntriesBox.FirstSelected();
1091 if ( pLBEntry != 0 )
1092 {
1093 sal_uInt16 nPos = (sal_uInt16) aEntriesBox.GetModel()->GetRelPos( pLBEntry );
1094 TAccInfo* pEntry = (TAccInfo*)aEntriesBox.GetEntry(0, nPos)->GetUserData();
1095 ::rtl::OUString sPossibleNewCommand = pFunctionBox->GetCurCommand();
1096
1097 if (pEntry->m_bIsConfigurable)
1098 {
1099 if (pEntry->isConfigured())
1100 aRemoveButton.Enable( sal_True );
1101 aChangeButton.Enable( pEntry->m_sCommand != sPossibleNewCommand );
1102 }
1103
1104 // update key box
1105 aKeyBox.Clear();
1106 SvLBoxEntry* pIt = aEntriesBox.First();
1107 while ( pIt )
1108 {
1109 TAccInfo* pUserData = (TAccInfo*)pIt->GetUserData();
1110 if ( pUserData && pUserData->m_sCommand == sPossibleNewCommand )
1111 {
1112 TAccInfo* pU1 = new TAccInfo(-1, -1, pUserData->m_aKey);
1113 SvLBoxEntry* pE1 = aKeyBox.InsertEntry( pUserData->m_aKey.GetName(), 0L, sal_True, LIST_APPEND );
1114 pE1->SetUserData(pU1);
1115 pE1->EnableChildsOnDemand( sal_False );
1116 }
1117 pIt = aEntriesBox.Next(pIt);
1118 }
1119 }
1120 }
1121 else
1122 {
1123 // goto selected "key" entry of the key box
1124 SvLBoxEntry* pE2 = 0;
1125 TAccInfo* pU2 = 0;
1126 sal_uInt16 nP2 = LISTBOX_ENTRY_NOTFOUND;
1127 SvLBoxEntry* pE3 = 0;
1128
1129 pE2 = aKeyBox.FirstSelected();
1130 if (pE2)
1131 pU2 = (TAccInfo*)pE2->GetUserData();
1132 if (pU2)
1133 nP2 = MapKeyCodeToPos(pU2->m_aKey);
1134 if (nP2 != LISTBOX_ENTRY_NOTFOUND)
1135 pE3 = aEntriesBox.GetEntry( 0, nP2 );
1136 if (pE3)
1137 {
1138 aEntriesBox.Select( pE3 );
1139 aEntriesBox.MakeVisible( pE3 );
1140 }
1141 }
1142
1143 return 0;
1144 }
1145
1146 //-----------------------------------------------
IMPL_LINK(SfxAcceleratorConfigPage,RadioHdl,RadioButton *,EMPTYARG)1147 IMPL_LINK( SfxAcceleratorConfigPage, RadioHdl, RadioButton *, EMPTYARG )
1148 {
1149 css::uno::Reference< css::ui::XAcceleratorConfiguration > xOld = m_xAct;
1150
1151 if (aOfficeButton.IsChecked())
1152 m_xAct = m_xGlobal;
1153 else if (aModuleButton.IsChecked())
1154 m_xAct = m_xModule;
1155
1156 // nothing changed? => do nothing!
1157 if ( m_xAct.is() && ( xOld == m_xAct ) )
1158 return 0;
1159
1160 aEntriesBox.SetUpdateMode( sal_False );
1161 ResetConfig();
1162 Init(m_xAct);
1163 aEntriesBox.SetUpdateMode( sal_True );
1164 aEntriesBox.Invalidate();
1165
1166 pGroupLBox->Init(m_xSMGR, m_xFrame, m_sModuleLongName);
1167
1168 // pb: #133213# do not select NULL entries
1169 SvLBoxEntry* pEntry = aEntriesBox.GetEntry( 0, 0 );
1170 if ( pEntry )
1171 aEntriesBox.Select( pEntry );
1172 pEntry = pGroupLBox->GetEntry( 0, 0 );
1173 if ( pEntry )
1174 pGroupLBox->Select( pEntry );
1175
1176 ((Link &) pFunctionBox->GetSelectHdl()).Call( pFunctionBox );
1177 return 1L;
1178 }
1179
1180 //-----------------------------------------------
IMPL_LINK(SfxAcceleratorConfigPage,LoadHdl,sfx2::FileDialogHelper *,EMPTYARG)1181 IMPL_LINK( SfxAcceleratorConfigPage, LoadHdl, sfx2::FileDialogHelper*, EMPTYARG )
1182 {
1183 DBG_ASSERT( m_pFileDlg, "SfxInternetPage::DialogClosedHdl(): no file dialog" );
1184
1185 ::rtl::OUString sCfgName;
1186 if ( ERRCODE_NONE == m_pFileDlg->GetError() )
1187 sCfgName = m_pFileDlg->GetPath();
1188
1189 if ( !sCfgName.getLength() )
1190 return 0;
1191
1192 GetTabDialog()->EnterWait();
1193
1194 css::uno::Reference< css::frame::XModel > xDoc ;
1195 css::uno::Reference< css::ui::XUIConfigurationManager > xCfgMgr ;
1196 css::uno::Reference< css::embed::XStorage > xRootStorage; // we must hold the root storage alive, if xCfgMgr is used!
1197
1198 try
1199 {
1200 // first check if URL points to a document already loaded
1201 xDoc = SearchForAlreadyLoadedDoc(sCfgName);
1202 if (xDoc.is())
1203 {
1204 // Get ui config manager. There should always be one at the model.
1205 css::uno::Reference< css::ui::XUIConfigurationManagerSupplier > xCfgSupplier(xDoc, css::uno::UNO_QUERY_THROW);
1206 xCfgMgr = xCfgSupplier->getUIConfigurationManager();
1207 }
1208 else
1209 {
1210 // URL doesn't point to a loaded document, try to access it as a single storage
1211 // dont forget to release the storage afterwards!
1212 css::uno::Reference< css::lang::XSingleServiceFactory > xStorageFactory(m_xSMGR->createInstance(SERVICE_STORAGEFACTORY), css::uno::UNO_QUERY_THROW);
1213 css::uno::Sequence< css::uno::Any > lArgs(2);
1214 lArgs[0] <<= sCfgName;
1215 lArgs[1] <<= css::embed::ElementModes::READ;
1216
1217 xRootStorage = css::uno::Reference< css::embed::XStorage >(xStorageFactory->createInstanceWithArguments(lArgs), css::uno::UNO_QUERY_THROW);
1218 css::uno::Reference< css::embed::XStorage > xUIConfig = xRootStorage->openStorageElement(FOLDERNAME_UICONFIG, css::embed::ElementModes::READ);
1219 if (xUIConfig.is())
1220 {
1221 xCfgMgr = css::uno::Reference< css::ui::XUIConfigurationManager >(m_xSMGR->createInstance(SERVICE_UICONFIGMGR), css::uno::UNO_QUERY_THROW);
1222 css::uno::Reference< css::ui::XUIConfigurationStorage > xCfgMgrStore(xCfgMgr, css::uno::UNO_QUERY_THROW);
1223 xCfgMgrStore->setStorage(xUIConfig);
1224 }
1225 }
1226
1227 if (xCfgMgr.is())
1228 {
1229 // open the configuration and update our UI
1230 css::uno::Reference< css::ui::XAcceleratorConfiguration > xTempAccMgr(xCfgMgr->getShortCutManager(), css::uno::UNO_QUERY_THROW);
1231
1232 aEntriesBox.SetUpdateMode(sal_False);
1233 ResetConfig();
1234 Init(xTempAccMgr);
1235 aEntriesBox.SetUpdateMode(sal_True);
1236 aEntriesBox.Invalidate();
1237 aEntriesBox.Select(aEntriesBox.GetEntry(0, 0));
1238
1239 }
1240
1241 // dont forget to close the new opened storage!
1242 // We are the owner of it.
1243 if (xRootStorage.is())
1244 {
1245 css::uno::Reference< css::lang::XComponent > xComponent;
1246 xComponent = css::uno::Reference< css::lang::XComponent >(xCfgMgr, css::uno::UNO_QUERY);
1247 if (xComponent.is())
1248 xComponent->dispose();
1249 xComponent = css::uno::Reference< css::lang::XComponent >(xRootStorage, css::uno::UNO_QUERY);
1250 if (xComponent.is())
1251 xComponent->dispose();
1252 }
1253 }
1254 catch(const css::uno::RuntimeException& exRun)
1255 { throw exRun; }
1256 catch(const css::uno::Exception&)
1257 {}
1258
1259 GetTabDialog()->LeaveWait();
1260
1261 return 0;
1262 }
1263
1264 //-----------------------------------------------
IMPL_LINK(SfxAcceleratorConfigPage,SaveHdl,sfx2::FileDialogHelper *,EMPTYARG)1265 IMPL_LINK( SfxAcceleratorConfigPage, SaveHdl, sfx2::FileDialogHelper*, EMPTYARG )
1266 {
1267 DBG_ASSERT( m_pFileDlg, "SfxInternetPage::DialogClosedHdl(): no file dialog" );
1268
1269 ::rtl::OUString sCfgName;
1270 if ( ERRCODE_NONE == m_pFileDlg->GetError() )
1271 sCfgName = m_pFileDlg->GetPath();
1272
1273 if ( !sCfgName.getLength() )
1274 return 0;
1275
1276 GetTabDialog()->EnterWait();
1277
1278 css::uno::Reference< css::frame::XModel > xDoc ;
1279 css::uno::Reference< css::ui::XUIConfigurationManager > xCfgMgr ;
1280 css::uno::Reference< css::embed::XStorage > xRootStorage;
1281
1282 try
1283 {
1284 // first check if URL points to a document already loaded
1285 xDoc = SearchForAlreadyLoadedDoc(sCfgName);
1286 if (xDoc.is())
1287 {
1288 // get config manager, force creation if there was none before
1289 css::uno::Reference< css::ui::XUIConfigurationManagerSupplier > xCfgSupplier(xDoc, css::uno::UNO_QUERY_THROW);
1290 xCfgMgr = xCfgSupplier->getUIConfigurationManager();
1291 }
1292 else
1293 {
1294 // URL doesn't point to a loaded document, try to access it as a single storage
1295 css::uno::Reference< css::lang::XSingleServiceFactory > xStorageFactory(m_xSMGR->createInstance(SERVICE_STORAGEFACTORY), css::uno::UNO_QUERY_THROW);
1296 css::uno::Sequence< css::uno::Any > lArgs(2);
1297 lArgs[0] <<= sCfgName;
1298 lArgs[1] <<= css::embed::ElementModes::WRITE;
1299
1300 xRootStorage = css::uno::Reference< css::embed::XStorage >(
1301 xStorageFactory->createInstanceWithArguments(lArgs),
1302 css::uno::UNO_QUERY_THROW);
1303
1304 css::uno::Reference< css::embed::XStorage > xUIConfig(
1305 xRootStorage->openStorageElement(FOLDERNAME_UICONFIG, css::embed::ElementModes::WRITE),
1306 css::uno::UNO_QUERY_THROW);
1307 css::uno::Reference< css::beans::XPropertySet > xUIConfigProps(
1308 xUIConfig,
1309 css::uno::UNO_QUERY_THROW);
1310
1311 // set the correct media type if the storage was new created
1312 ::rtl::OUString sMediaType;
1313 xUIConfigProps->getPropertyValue(MEDIATYPE_PROPNAME) >>= sMediaType;
1314 if (!sMediaType.getLength())
1315 xUIConfigProps->setPropertyValue(MEDIATYPE_PROPNAME, css::uno::makeAny(MEDIATYPE_UICONFIG));
1316
1317 xCfgMgr = css::uno::Reference< css::ui::XUIConfigurationManager >(m_xSMGR->createInstance(SERVICE_UICONFIGMGR), css::uno::UNO_QUERY_THROW);
1318 css::uno::Reference< css::ui::XUIConfigurationStorage > xUICfgStore(xCfgMgr, css::uno::UNO_QUERY_THROW);
1319 xUICfgStore->setStorage(xUIConfig);
1320 }
1321
1322 if (xCfgMgr.is())
1323 {
1324 // get the target configuration access and update with all shortcuts
1325 // which are set currently at the UI !
1326 // Dont copy the m_xAct content to it ... because m_xAct will be updated
1327 // from the UI on pressing the button "OK" only. And inbetween it's not up to date !
1328 css::uno::Reference< css::ui::XAcceleratorConfiguration > xTargetAccMgr(xCfgMgr->getShortCutManager(), css::uno::UNO_QUERY_THROW);
1329 Apply(xTargetAccMgr);
1330
1331 // commit (order is important!)
1332 css::uno::Reference< css::ui::XUIConfigurationPersistence > xCommit1(xTargetAccMgr, css::uno::UNO_QUERY_THROW);
1333 css::uno::Reference< css::ui::XUIConfigurationPersistence > xCommit2(xCfgMgr , css::uno::UNO_QUERY_THROW);
1334 xCommit1->store();
1335 xCommit2->store();
1336
1337 if (xRootStorage.is())
1338 {
1339 // Commit root storage
1340 css::uno::Reference< css::embed::XTransactedObject > xCommit3(xRootStorage, css::uno::UNO_QUERY_THROW);
1341 xCommit3->commit();
1342 }
1343 }
1344
1345 if (xRootStorage.is())
1346 {
1347 css::uno::Reference< css::lang::XComponent > xComponent;
1348 xComponent = css::uno::Reference< css::lang::XComponent >(xCfgMgr, css::uno::UNO_QUERY);
1349 if (xComponent.is())
1350 xComponent->dispose();
1351 xComponent = css::uno::Reference< css::lang::XComponent >(xRootStorage, css::uno::UNO_QUERY);
1352 if (xComponent.is())
1353 xComponent->dispose();
1354 }
1355 }
1356 catch(const css::uno::RuntimeException& exRun)
1357 { throw exRun; }
1358 catch(const css::uno::Exception&)
1359 {}
1360
1361 GetTabDialog()->LeaveWait();
1362
1363 return 0;
1364 }
1365
1366 //-----------------------------------------------
StartFileDialog(WinBits nBits,const String & rTitle)1367 void SfxAcceleratorConfigPage::StartFileDialog( WinBits nBits, const String& rTitle )
1368 {
1369 bool bSave = ( ( nBits & WB_SAVEAS ) == WB_SAVEAS );
1370 short nDialogType = bSave ? css::ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION
1371 : css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE;
1372 if ( m_pFileDlg )
1373 delete m_pFileDlg;
1374 m_pFileDlg = new sfx2::FileDialogHelper( nDialogType, 0 );
1375
1376 m_pFileDlg->SetTitle( rTitle );
1377 m_pFileDlg->AddFilter( aFilterAllStr, DEFINE_CONST_UNICODE( FILEDIALOG_FILTER_ALL ) );
1378 m_pFileDlg->AddFilter( aFilterCfgStr, DEFINE_CONST_UNICODE( "*.cfg" ) );
1379 m_pFileDlg->SetCurrentFilter( aFilterCfgStr );
1380
1381 Link aDlgClosedLink = bSave ? LINK( this, SfxAcceleratorConfigPage, SaveHdl )
1382 : LINK( this, SfxAcceleratorConfigPage, LoadHdl );
1383 m_pFileDlg->StartExecuteModal( aDlgClosedLink );
1384 }
1385
1386 //-----------------------------------------------
FillItemSet(SfxItemSet &)1387 sal_Bool SfxAcceleratorConfigPage::FillItemSet( SfxItemSet& )
1388 {
1389 Apply(m_xAct);
1390 try
1391 {
1392 m_xAct->store();
1393 }
1394 catch(const css::uno::RuntimeException& exRun)
1395 { throw exRun; }
1396 catch(const css::uno::Exception&)
1397 { return sal_False; }
1398
1399 return sal_True;
1400 }
1401
1402 //-----------------------------------------------
Reset(const SfxItemSet & rSet)1403 void SfxAcceleratorConfigPage::Reset( const SfxItemSet& rSet )
1404 {
1405 // open accelerator configs
1406 // Note: It initialize some other members too, which are needed here ...
1407 // e.g. m_sModuleUIName!
1408 InitAccCfg();
1409
1410 // change te description of the radio button, which switch to the module
1411 // dependend accelerator configuration
1412 String sButtonText = aModuleButton.GetText();
1413 sButtonText.SearchAndReplace(String::CreateFromAscii("$(MODULE)"), m_sModuleUIName);
1414 aModuleButton.SetText(sButtonText);
1415
1416 if (m_xModule.is())
1417 aModuleButton.Check();
1418 else
1419 {
1420 aModuleButton.Hide();
1421 aOfficeButton.Check();
1422 }
1423
1424 RadioHdl(0);
1425
1426 const SfxPoolItem* pMacroItem=0;
1427 if( SFX_ITEM_SET == rSet.GetItemState( SID_MACROINFO, sal_True, &pMacroItem ) )
1428 {
1429 m_pMacroInfoItem = PTR_CAST( SfxMacroInfoItem, pMacroItem );
1430 pGroupLBox->SelectMacro( m_pMacroInfoItem );
1431 }
1432 else
1433 {
1434 const SfxPoolItem* pStringItem=0;
1435 if( SFX_ITEM_SET == rSet.GetItemState( SID_CHARMAP, sal_True, &pStringItem ) )
1436 m_pStringItem = PTR_CAST( SfxStringItem, pStringItem );
1437
1438 const SfxPoolItem* pFontItem=0;
1439 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_SPECIALCHAR, sal_True, &pFontItem ) )
1440 m_pFontItem = PTR_CAST( SfxStringItem, pFontItem );
1441 }
1442 }
1443
1444 //-----------------------------------------------
MapKeyCodeToPos(const KeyCode & aKey) const1445 sal_uInt16 SfxAcceleratorConfigPage::MapKeyCodeToPos(const KeyCode& aKey) const
1446 {
1447 sal_uInt16 nCode1 = aKey.GetCode()+aKey.GetModifier();
1448 SvLBoxEntry* pEntry = aEntriesBox.First();
1449 sal_uInt16 i = 0;
1450
1451 while (pEntry)
1452 {
1453 TAccInfo* pUserData = (TAccInfo*)pEntry->GetUserData();
1454 if (pUserData)
1455 {
1456 sal_uInt16 nCode2 = pUserData->m_aKey.GetCode()+pUserData->m_aKey.GetModifier();
1457 if (nCode1 == nCode2)
1458 return i;
1459 }
1460 pEntry = aEntriesBox.Next(pEntry);
1461 ++i;
1462 }
1463
1464 return LISTBOX_ENTRY_NOTFOUND;
1465 }
1466
1467 //-----------------------------------------------
GetLabel4Command(const String & sCommand)1468 String SfxAcceleratorConfigPage::GetLabel4Command(const String& sCommand)
1469 {
1470 try
1471 {
1472 // check global command configuration first
1473 css::uno::Reference< css::container::XNameAccess > xModuleConf;
1474 m_xUICmdDescription->getByName(m_sModuleLongName) >>= xModuleConf;
1475 if (xModuleConf.is())
1476 {
1477 ::comphelper::SequenceAsHashMap lProps(xModuleConf->getByName(sCommand));
1478 String sLabel = String(lProps.getUnpackedValueOrDefault(CMDPROP_UINAME, ::rtl::OUString()));
1479 if (sLabel.Len())
1480 return sLabel;
1481 }
1482 }
1483 catch(const css::uno::RuntimeException& exRun)
1484 { throw exRun; }
1485 catch(const css::uno::Exception&)
1486 {}
1487
1488 // may be it's a style URL .. they must be handled special
1489 SfxStyleInfo_Impl aStyle;
1490 aStyle.sCommand = sCommand;
1491 if (m_aStylesInfo.parseStyleCommand(aStyle))
1492 {
1493 m_aStylesInfo.getLabel4Style(aStyle);
1494 return aStyle.sLabel;
1495 }
1496 else
1497 {
1498 String aRet( String::CreateFromAscii("Symbols: ") );
1499 xub_StrLen nPos = sCommand.SearchAscii(".uno:InsertSymbol?Symbols:string=");
1500 if ( nPos == 0 )
1501 {
1502 aRet += String( sCommand, 34, sCommand.Len()-34 );
1503 return aRet;
1504 }
1505 }
1506
1507 return sCommand;
1508 }
1509
Create(Window * pParent,const SfxItemSet & rAttrSet)1510 SfxTabPage* SfxAcceleratorConfigPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
1511 {
1512 return new SfxAcceleratorConfigPage( pParent, rAttrSet );
1513 }
1514
1515 //-----------------------------------------------
SearchForAlreadyLoadedDoc(const String &)1516 css::uno::Reference< css::frame::XModel > SfxAcceleratorConfigPage::SearchForAlreadyLoadedDoc(const String& /*sName*/)
1517 {
1518 return css::uno::Reference< css::frame::XModel >();
1519 }
1520
SvxShortcutAssignDlg(Window * pParent,const uno::Reference<frame::XFrame> & rxDocumentFrame,const SfxItemSet & rSet)1521 SvxShortcutAssignDlg::SvxShortcutAssignDlg( Window* pParent, const uno::Reference< frame::XFrame >& rxDocumentFrame, const SfxItemSet& rSet )
1522 : SfxSingleTabDialog( pParent, rSet, 0 )
1523 {
1524 SfxTabPage* pPage = SfxAcceleratorConfigPage::Create( this, rSet );
1525 pPage->SetFrame( rxDocumentFrame );
1526 SetTabPage( pPage );
1527
1528 }
1529
~SvxShortcutAssignDlg()1530 SvxShortcutAssignDlg::~SvxShortcutAssignDlg()
1531 {
1532 }
1533
1534
1535 // .uno:InsertSymbol?Symbols:string=bla
1536