1*b1cdbd2cSJim Jagielski/**************************************************************
2*b1cdbd2cSJim Jagielski *
3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski * or more contributor license agreements.  See the NOTICE file
5*b1cdbd2cSJim Jagielski * distributed with this work for additional information
6*b1cdbd2cSJim Jagielski * regarding copyright ownership.  The ASF licenses this file
7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski * with the License.  You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski *
11*b1cdbd2cSJim Jagielski *   http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski *
13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski * KIND, either express or implied.  See the License for the
17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski * under the License.
19*b1cdbd2cSJim Jagielski *
20*b1cdbd2cSJim Jagielski *************************************************************/
21*b1cdbd2cSJim Jagielski
22*b1cdbd2cSJim Jagielski
23*b1cdbd2cSJim Jagielski#ifndef __com_sun_star_ui_XAcceleratorConfiguration_idl__
24*b1cdbd2cSJim Jagielski#define __com_sun_star_ui_XAcceleratorConfiguration_idl__
25*b1cdbd2cSJim Jagielski
26*b1cdbd2cSJim Jagielski#ifndef __com_sun_star_ui_XUIConfiguration_idl__
27*b1cdbd2cSJim Jagielski#include <com/sun/star/ui/XUIConfiguration.idl>
28*b1cdbd2cSJim Jagielski#endif
29*b1cdbd2cSJim Jagielski
30*b1cdbd2cSJim Jagielski#ifndef __com_sun_star_ui_XUIConfigurationPersistence_idl__
31*b1cdbd2cSJim Jagielski#include <com/sun/star/ui/XUIConfigurationPersistence.idl>
32*b1cdbd2cSJim Jagielski#endif
33*b1cdbd2cSJim Jagielski
34*b1cdbd2cSJim Jagielski#ifndef __com_sun_star_ui_XUIConfigurationStorage_idl__
35*b1cdbd2cSJim Jagielski#include <com/sun/star/ui/XUIConfigurationStorage.idl>
36*b1cdbd2cSJim Jagielski#endif
37*b1cdbd2cSJim Jagielski
38*b1cdbd2cSJim Jagielski#ifndef __com_sun_star_awt_KeyEvent_idl__
39*b1cdbd2cSJim Jagielski#include <com/sun/star/awt/KeyEvent.idl>
40*b1cdbd2cSJim Jagielski#endif
41*b1cdbd2cSJim Jagielski
42*b1cdbd2cSJim Jagielski#ifndef __com_sun_star_lang_IllegalArgumentException_idl__
43*b1cdbd2cSJim Jagielski#include <com/sun/star/lang/IllegalArgumentException.idl>
44*b1cdbd2cSJim Jagielski#endif
45*b1cdbd2cSJim Jagielski
46*b1cdbd2cSJim Jagielski#ifndef __com_sun_star_container_NoSuchElementException_idl__
47*b1cdbd2cSJim Jagielski#include <com/sun/star/container/NoSuchElementException.idl>
48*b1cdbd2cSJim Jagielski#endif
49*b1cdbd2cSJim Jagielski
50*b1cdbd2cSJim Jagielskimodule com {  module sun {  module star {  module ui {
51*b1cdbd2cSJim Jagielski
52*b1cdbd2cSJim Jagielski//-----------------------------------------------
53*b1cdbd2cSJim Jagielski/** provides read/write access to an accelerator configuration set.
54*b1cdbd2cSJim Jagielski
55*b1cdbd2cSJim Jagielski    <p>
56*b1cdbd2cSJim Jagielski    Such configuration set base on:<br>
57*b1cdbd2cSJim Jagielski    <ul>
58*b1cdbd2cSJim Jagielski        <li>Key events structure</li>
59*b1cdbd2cSJim Jagielski        <li>and Commands, which are represented as URLs; describing
60*b1cdbd2cSJim Jagielski            a function, which and can be executed using the dispatch API.</li>
61*b1cdbd2cSJim Jagielski    </ul>
62*b1cdbd2cSJim Jagielski    </p>
63*b1cdbd2cSJim Jagielski
64*b1cdbd2cSJim Jagielski	<p>
65*b1cdbd2cSJim Jagielski    Note further:<br>
66*b1cdbd2cSJim Jagielski    All changes you made on this configration access modify the
67*b1cdbd2cSJim Jagielski    the configuration set inside memory only. You have to use
68*b1cdbd2cSJim Jagielski    the <type scope="com::sun::star::util">XFlushable</type> interface
69*b1cdbd2cSJim Jagielski    (which must be available at the same implementation object too), to
70*b1cdbd2cSJim Jagielski    make it persistent.
71*b1cdbd2cSJim Jagielski    </p>
72*b1cdbd2cSJim Jagielski
73*b1cdbd2cSJim Jagielski    @see    AcceleratorConfiguration
74*b1cdbd2cSJim Jagielski    @see    <type scope="dom::sun::star::util">XFlushable</type>
75*b1cdbd2cSJim Jagielski
76*b1cdbd2cSJim Jagielski    @since OpenOffice 2.0
77*b1cdbd2cSJim Jagielski*/
78*b1cdbd2cSJim Jagielskiinterface XAcceleratorConfiguration
79*b1cdbd2cSJim Jagielski{
80*b1cdbd2cSJim Jagielski    //-------------------------------------------
81*b1cdbd2cSJim Jagielski    /** return the list of all key events, which
82*b1cdbd2cSJim Jagielski        are available at this configration set.
83*b1cdbd2cSJim Jagielski
84*b1cdbd2cSJim Jagielski        <p>
85*b1cdbd2cSJim Jagielski        The key events are the "primary keys" of this configuration sets.
86*b1cdbd2cSJim Jagielski        Means: Commands are registerd for key events.
87*b1cdbd2cSJim Jagielski        </p>
88*b1cdbd2cSJim Jagielski
89*b1cdbd2cSJim Jagielski        <p>
90*b1cdbd2cSJim Jagielski        Such key event can be mapped to its bound command,
91*b1cdbd2cSJim Jagielski        using the method getCommandForKeyEvent().
92*b1cdbd2cSJim Jagielski        </p>
93*b1cdbd2cSJim Jagielski
94*b1cdbd2cSJim Jagielski        @see        getCommandForKeyEvent().
95*b1cdbd2cSJim Jagielski
96*b1cdbd2cSJim Jagielski        @return     A list of key events.
97*b1cdbd2cSJim Jagielski      */
98*b1cdbd2cSJim Jagielski    sequence< com::sun::star::awt::KeyEvent > getAllKeyEvents();
99*b1cdbd2cSJim Jagielski
100*b1cdbd2cSJim Jagielski    //-------------------------------------------
101*b1cdbd2cSJim Jagielski    /** return the registered command for the specified key event.
102*b1cdbd2cSJim Jagielski
103*b1cdbd2cSJim Jagielski        <p>
104*b1cdbd2cSJim Jagielski        This function can be used to:<br>
105*b1cdbd2cSJim Jagielski        <ul>
106*b1cdbd2cSJim Jagielski            <li>by a generic service, which can execute commands if a
107*b1cdbd2cSJim Jagielski                keyboard event occures.</li>
108*b1cdbd2cSJim Jagielski            <li>or to iterate over the whole container and change some
109*b1cdbd2cSJim Jagielski                accelerator bindings.</li>
110*b1cdbd2cSJim Jagielski        </ul>
111*b1cdbd2cSJim Jagielski        </p>
112*b1cdbd2cSJim Jagielski
113*b1cdbd2cSJim Jagielski        @param  aKeyEvent
114*b1cdbd2cSJim Jagielski                the key event, where the registered command is searched for.
115*b1cdbd2cSJim Jagielski
116*b1cdbd2cSJim Jagielski        @return The registered command for the specified key event.
117*b1cdbd2cSJim Jagielski
118*b1cdbd2cSJim Jagielski        @throws ::com::sun::star::container::NoSuchElementException
119*b1cdbd2cSJim Jagielski                if the key event is an invalid one or does not exists
120*b1cdbd2cSJim Jagielski                inside this configuration set.
121*b1cdbd2cSJim Jagielski     */
122*b1cdbd2cSJim Jagielski    string getCommandByKeyEvent( [in] com::sun::star::awt::KeyEvent aKeyEvent )
123*b1cdbd2cSJim Jagielski        raises(com::sun::star::container::NoSuchElementException);
124*b1cdbd2cSJim Jagielski
125*b1cdbd2cSJim Jagielski    //-------------------------------------------
126*b1cdbd2cSJim Jagielski    /** modify or create a key - command - binding.
127*b1cdbd2cSJim Jagielski
128*b1cdbd2cSJim Jagielski        <p>
129*b1cdbd2cSJim Jagielski        If the specified key event does not already exists inside this
130*b1cdbd2cSJim Jagielski        configuration access, it will be created and the command will be
131*b1cdbd2cSJim Jagielski        registered for it.
132*b1cdbd2cSJim Jagielski        </p>
133*b1cdbd2cSJim Jagielski
134*b1cdbd2cSJim Jagielski        <p>
135*b1cdbd2cSJim Jagielski        If the specified key event already exists, its command will
136*b1cdbd2cSJim Jagielski        be overwritten with the new command. There is no warning nor any error
137*b1cdbd2cSJim Jagielski        about that! The outside code has to use the method getCommandForKeyEvent()
138*b1cdbd2cSJim Jagielski        to check for possible collisions.
139*b1cdbd2cSJim Jagielski        </p>
140*b1cdbd2cSJim Jagielski
141*b1cdbd2cSJim Jagielski        <p>
142*b1cdbd2cSJim Jagielski        Note: This method cant be used to remove entities from the configuration set.
143*b1cdbd2cSJim Jagielski        Empty parameters will result into an exception!
144*b1cdbd2cSJim Jagielski        Use the method removeKeyEvent() instead.
145*b1cdbd2cSJim Jagielski        </p>
146*b1cdbd2cSJim Jagielski
147*b1cdbd2cSJim Jagielski        @see    removeKeyEvent()
148*b1cdbd2cSJim Jagielski
149*b1cdbd2cSJim Jagielski        @param  aKeyEvent
150*b1cdbd2cSJim Jagielski                specify the key event, which must be updated or new created.
151*b1cdbd2cSJim Jagielski
152*b1cdbd2cSJim Jagielski        @param  sCommand
153*b1cdbd2cSJim Jagielski                the new command for the specified key event.
154*b1cdbd2cSJim Jagielski
155*b1cdbd2cSJim Jagielski        @throws ::com::sun::star::lang::IllegalArgumentException
156*b1cdbd2cSJim Jagielski                if the key event isnt a valid one. Commands can be
157*b1cdbd2cSJim Jagielski                checked only, if they are empty. Because every URL schema can be used
158*b1cdbd2cSJim Jagielski                by commands in general, so its not possible to validate it.
159*b1cdbd2cSJim Jagielski     */
160*b1cdbd2cSJim Jagielski    void setKeyEvent( [in] com::sun::star::awt::KeyEvent aKeyEvent,
161*b1cdbd2cSJim Jagielski                      [in] string                        sCommand )
162*b1cdbd2cSJim Jagielski        raises(com::sun::star::lang::IllegalArgumentException);
163*b1cdbd2cSJim Jagielski
164*b1cdbd2cSJim Jagielski    //-------------------------------------------
165*b1cdbd2cSJim Jagielski    /** remove a key-command-binding from this configuration set.
166*b1cdbd2cSJim Jagielski
167*b1cdbd2cSJim Jagielski        @param  aKeyEvent
168*b1cdbd2cSJim Jagielski                the key event, which should be removed.
169*b1cdbd2cSJim Jagielski
170*b1cdbd2cSJim Jagielski        @throws ::com::sun::star::container::NoSuchElementException
171*b1cdbd2cSJim Jagielski                if the key event does not exists inside this configuration set.
172*b1cdbd2cSJim Jagielski     */
173*b1cdbd2cSJim Jagielski    void removeKeyEvent( [in] com::sun::star::awt::KeyEvent aKeyEvent )
174*b1cdbd2cSJim Jagielski        raises(com::sun::star::container::NoSuchElementException);
175*b1cdbd2cSJim Jagielski
176*b1cdbd2cSJim Jagielski    //-------------------------------------------
177*b1cdbd2cSJim Jagielski    /** optimized access to the relation "command-key" instead
178*b1cdbd2cSJim Jagielski        of "key-command" which is provided normaly by this interface.
179*b1cdbd2cSJim Jagielski
180*b1cdbd2cSJim Jagielski        <p>
181*b1cdbd2cSJim Jagielski        It can be used to implement collision handling, if more then one
182*b1cdbd2cSJim Jagielski        key event match to the same command. The returned list contains all
183*b1cdbd2cSJim Jagielski        possible key events - and the outside code can select an possible one.
184*b1cdbd2cSJim Jagielski        Of course - mostly this list will contain only one key event ...
185*b1cdbd2cSJim Jagielski        </p>
186*b1cdbd2cSJim Jagielski
187*b1cdbd2cSJim Jagielski        @param  sCommand
188*b1cdbd2cSJim Jagielski                the command, where key bindings are searched for.
189*b1cdbd2cSJim Jagielski
190*b1cdbd2cSJim Jagielski        @return A list of <type scope="com::sun::star::awt">KeyEvent</type> structures,
191*b1cdbd2cSJim Jagielski                where the pecified command is registered for.
192*b1cdbd2cSJim Jagielski
193*b1cdbd2cSJim Jagielski        @throws ::com::sun::star::lang::IllegalArgumentException
194*b1cdbd2cSJim Jagielski                if the specified command is empty. It cant be checked, if a command
195*b1cdbd2cSJim Jagielski                is valid - because every URL schema can be used here.
196*b1cdbd2cSJim Jagielski
197*b1cdbd2cSJim Jagielski        @throws ::com::sun::star::container::NoSuchElementException
198*b1cdbd2cSJim Jagielski                if the specified command isnt empty but does not
199*b1cdbd2cSJim Jagielski                occure inside this configuration set.
200*b1cdbd2cSJim Jagielski     */
201*b1cdbd2cSJim Jagielski    sequence< com::sun::star::awt::KeyEvent > getKeyEventsByCommand( [in] string sCommand )
202*b1cdbd2cSJim Jagielski        raises(com::sun::star::lang::IllegalArgumentException   ,
203*b1cdbd2cSJim Jagielski               com::sun::star::container::NoSuchElementException);
204*b1cdbd2cSJim Jagielski
205*b1cdbd2cSJim Jagielski    //-------------------------------------------
206*b1cdbd2cSJim Jagielski    /** optimized function to map a list of commands to a corresponding
207*b1cdbd2cSJim Jagielski        list of key events.
208*b1cdbd2cSJim Jagielski
209*b1cdbd2cSJim Jagielski        <p>
210*b1cdbd2cSJim Jagielski        It provides a fast mapping, which is e.g. needed by a menu or toolbar implementation.
211*b1cdbd2cSJim Jagielski        E.g. a sub menu is described by a list of commands - and the implementation of the menu
212*b1cdbd2cSJim Jagielski        must show the corresponding shortcuts. Iteration over all items of this configuration
213*b1cdbd2cSJim Jagielski        set can be very expensive.
214*b1cdbd2cSJim Jagielski        </p>
215*b1cdbd2cSJim Jagielski
216*b1cdbd2cSJim Jagielski        <p>
217*b1cdbd2cSJim Jagielski        Instead to the method getKeyEventsForCommand() the returned list contains only
218*b1cdbd2cSJim Jagielski        one(!) key event bound to one(!) requested command. If more then one key event
219*b1cdbd2cSJim Jagielski        is bound to a command - a selection is done inside this method.
220*b1cdbd2cSJim Jagielski        This internal selection cant be influenced from outside.
221*b1cdbd2cSJim Jagielski        </p>
222*b1cdbd2cSJim Jagielski
223*b1cdbd2cSJim Jagielski        @attention  Because its not defined, that any command (e.g. configured inside a menu)
224*b1cdbd2cSJim Jagielski                    must have an accelerator - we cant reject the call if at least one command
225*b1cdbd2cSJim Jagielski                    does not occure inside this configuration set ...
226*b1cdbd2cSJim Jagielski                    We handle it more gracefully - and return an empty item instead of throwing
227*b1cdbd2cSJim Jagielski                    and exception.
228*b1cdbd2cSJim Jagielski
229*b1cdbd2cSJim Jagielski        @param  lCommandList
230*b1cdbd2cSJim Jagielski                a list of commands
231*b1cdbd2cSJim Jagielski
232*b1cdbd2cSJim Jagielski        @return A (non packed!) list of key events, where every item match by index
233*b1cdbd2cSJim Jagielski                directly to a command of the specified <var>CommandList</var>.
234*b1cdbd2cSJim Jagielski                If a command does not exists inside this configuration set, the
235*b1cdbd2cSJim Jagielski                corresponding any value will be empty.
236*b1cdbd2cSJim Jagielski
237*b1cdbd2cSJim Jagielski        @throws ::com::sun::star::lang::IllegalArgumentException
238*b1cdbd2cSJim Jagielski                if at least one of the specified commands is empty.
239*b1cdbd2cSJim Jagielski                It cant be checked, if a command is valid -
240*b1cdbd2cSJim Jagielski                because every URL schema can be used here.
241*b1cdbd2cSJim Jagielski     */
242*b1cdbd2cSJim Jagielski    sequence< any > getPreferredKeyEventsForCommandList( [in] sequence< string > lCommandList )
243*b1cdbd2cSJim Jagielski        raises(com::sun::star::lang::IllegalArgumentException);
244*b1cdbd2cSJim Jagielski
245*b1cdbd2cSJim Jagielski    //-------------------------------------------
246*b1cdbd2cSJim Jagielski    /** search for an key-command-binding inside this configuration set,
247*b1cdbd2cSJim Jagielski        where the specified command is used.
248*b1cdbd2cSJim Jagielski
249*b1cdbd2cSJim Jagielski        <p>
250*b1cdbd2cSJim Jagielski        If such binding could be located, the command will be removed
251*b1cdbd2cSJim Jagielski        from it. If as result of that the key binding will be empty,
252*b1cdbd2cSJim Jagielski        if will be removed too.
253*b1cdbd2cSJim Jagielski        </p>
254*b1cdbd2cSJim Jagielski
255*b1cdbd2cSJim Jagielski        <p>
256*b1cdbd2cSJim Jagielski        This is an optimized method, which can perform removing of commands
257*b1cdbd2cSJim Jagielski        from this configuration set. Because normaly Commands are "foreign keys"
258*b1cdbd2cSJim Jagielski        and key identifier the "primary keys" - it needs some work to remove
259*b1cdbd2cSJim Jagielski        all commands outside this container ...
260*b1cdbd2cSJim Jagielski        </p>
261*b1cdbd2cSJim Jagielski
262*b1cdbd2cSJim Jagielski        @param  sCommand
263*b1cdbd2cSJim Jagielski                the command, which should be removed from any key binding.
264*b1cdbd2cSJim Jagielski
265*b1cdbd2cSJim Jagielski        @throws ::com::sun::star::lang::IllegalArgumentException
266*b1cdbd2cSJim Jagielski                if the specified command is empty.
267*b1cdbd2cSJim Jagielski
268*b1cdbd2cSJim Jagielski        @throws ::com::sun::star::container::NoSuchElementException
269*b1cdbd2cSJim Jagielski                if the specified command isnt used inside this configuration set.
270*b1cdbd2cSJim Jagielski     */
271*b1cdbd2cSJim Jagielski    void removeCommandFromAllKeyEvents( [in] string sCommand )
272*b1cdbd2cSJim Jagielski        raises(com::sun::star::lang::IllegalArgumentException   ,
273*b1cdbd2cSJim Jagielski               com::sun::star::container::NoSuchElementException);
274*b1cdbd2cSJim Jagielski
275*b1cdbd2cSJim Jagielski    //-------------------------------------------
276*b1cdbd2cSJim Jagielski    /** specifies a persistence interface which supports to
277*b1cdbd2cSJim Jagielski        load/store accelerator configuration data to a storage
278*b1cdbd2cSJim Jagielski        and to retrieve information about the current state.
279*b1cdbd2cSJim Jagielski     */
280*b1cdbd2cSJim Jagielski    interface com::sun::star::ui::XUIConfigurationPersistence;
281*b1cdbd2cSJim Jagielski
282*b1cdbd2cSJim Jagielski    //-------------------------------------------
283*b1cdbd2cSJim Jagielski    /** connects this configuration to a new storage
284*b1cdbd2cSJim Jagielski        which must be used further on subsequent calls of
285*b1cdbd2cSJim Jagielski        <type scope="com::sun::star::util::">XConfigurationPersistence.load()</type>
286*b1cdbd2cSJim Jagielski        and <type scope="com::sun::star::util::">XConfigurationPersistence.store()</type>.
287*b1cdbd2cSJim Jagielski     */
288*b1cdbd2cSJim Jagielski    interface com::sun::star::ui::XUIConfigurationStorage;
289*b1cdbd2cSJim Jagielski
290*b1cdbd2cSJim Jagielski    //-------------------------------------------
291*b1cdbd2cSJim Jagielski    /** supports to notify other implementations about
292*b1cdbd2cSJim Jagielski        changes of this accelerator configuration.
293*b1cdbd2cSJim Jagielski     */
294*b1cdbd2cSJim Jagielski    interface com::sun::star::ui::XUIConfiguration;
295*b1cdbd2cSJim Jagielski
296*b1cdbd2cSJim Jagielski}; // interface XAcceleratorConfiguration
297*b1cdbd2cSJim Jagielski
298*b1cdbd2cSJim Jagielski}; }; }; }; // com.sun.star
299*b1cdbd2cSJim Jagielski
300*b1cdbd2cSJim Jagielski#endif
301