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 #ifndef SIDEBAR_COMMAND_INFO_PROVIDER_HXX 23 #define SIDEBAR_COMMAND_INFO_PROVIDER_HXX 24 25 #include "sfx2/dllapi.h" 26 27 #include <com/sun/star/frame/XFrame.hpp> 28 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 29 #include <com/sun/star/ui/XAcceleratorConfiguration.hpp> 30 31 32 namespace css = ::com::sun::star; 33 namespace cssu = ::com::sun::star::uno; 34 35 namespace sfx2 { namespace sidebar { 36 37 /** Provide information about UNO commands like tooltip text with 38 keyboard accelerator. 39 */ 40 class SFX2_DLLPUBLIC CommandInfoProvider 41 { 42 public: 43 /** Return the singleton instance. 44 45 It caches some objects for the last XFrame object given to 46 GetLabelForCommand. These objects are release and created new 47 when that method is called with a different XFrame from the 48 last call. 49 50 Lifetime control should work but could be more elegant. 51 */ 52 static CommandInfoProvider& Instance (void); 53 54 /** Return a label for the given command. 55 @param rsCommandName 56 The command name is expected to start with .uno: 57 @param rxFrame 58 The frame is used to identify the module and document. 59 @return 60 The returned label contains the keyboard accelerator, if 61 one is defined. 62 */ 63 ::rtl::OUString GetLabelForCommand ( 64 const ::rtl::OUString& rsCommandName, 65 const cssu::Reference<css::frame::XFrame>& rxFrame); 66 67 /** Do not call. Should be part of a local and hidden interface. 68 */ 69 void SetFrame (const cssu::Reference<css::frame::XFrame>& rxFrame); 70 71 private: 72 cssu::Reference<css::lang::XMultiServiceFactory> mxServiceFactory; 73 cssu::Reference<css::frame::XFrame> mxCachedDataFrame; 74 cssu::Reference<css::ui::XAcceleratorConfiguration> mxCachedDocumentAcceleratorConfiguration; 75 cssu::Reference<css::ui::XAcceleratorConfiguration> mxCachedModuleAcceleratorConfiguration; 76 cssu::Reference<css::ui::XAcceleratorConfiguration> mxCachedGlobalAcceleratorConfiguration; 77 ::rtl::OUString msCachedModuleIdentifier; 78 cssu::Reference<css::lang::XComponent> mxFrameListener; 79 80 CommandInfoProvider (void); 81 ~CommandInfoProvider (void); 82 83 cssu::Reference<css::ui::XAcceleratorConfiguration> GetDocumentAcceleratorConfiguration (void); 84 cssu::Reference<css::ui::XAcceleratorConfiguration> GetModuleAcceleratorConfiguration (void); 85 cssu::Reference<css::ui::XAcceleratorConfiguration> GetGlobalAcceleratorConfiguration(void); 86 ::rtl::OUString GetModuleIdentifier (void); 87 ::rtl::OUString GetCommandShortcut (const ::rtl::OUString& rCommandName); 88 cssu::Sequence<css::beans::PropertyValue> GetCommandProperties ( 89 const ::rtl::OUString& rsCommandName); 90 ::rtl::OUString GetCommandLabel (const ::rtl::OUString& rsCommandName); 91 rtl::OUString RetrieveShortcutsFromConfiguration( 92 const cssu::Reference<css::ui::XAcceleratorConfiguration>& rxConfiguration, 93 const rtl::OUString& rsCommandName); 94 }; 95 96 } } // end of namespace sfx2/framework 97 98 #endif 99