2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 #ifndef SIDEBAR_COMMAND_INFO_PROVIDER_HXX
19 #define SIDEBAR_COMMAND_INFO_PROVIDER_HXX
21 #include "sfx2/dllapi.h"
23 #include <com/sun/star/frame/XFrame.hpp>
24 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
25 #include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
28 namespace css
= ::com::sun::star
;
29 namespace cssu
= ::com::sun::star::uno
;
31 namespace sfx2
{ namespace sidebar
{
33 /** Provide information about UNO commands like tooltip text with
36 class SFX2_DLLPUBLIC CommandInfoProvider
39 /** Return the singleton instance.
41 It caches some objects for the last XFrame object given to
42 GetLabelForCommand. These objects are release and created new
43 when that method is called with a different XFrame from the
46 Lifetime control should work but could be more elegant.
48 static CommandInfoProvider
& Instance (void);
50 /** Return a label for the given command.
52 The command name is expected to start with .uno:
54 The frame is used to identify the module and document.
56 The returned label contains the keyboard accelerator, if
59 ::rtl::OUString
GetLabelForCommand (
60 const ::rtl::OUString
& rsCommandName
,
61 const cssu::Reference
<css::frame::XFrame
>& rxFrame
);
63 /** Do not call. Should be part of a local and hidden interface.
65 void SetFrame (const cssu::Reference
<css::frame::XFrame
>& rxFrame
);
68 cssu::Reference
<css::lang::XMultiServiceFactory
> mxServiceFactory
;
69 cssu::Reference
<css::frame::XFrame
> mxCachedDataFrame
;
70 cssu::Reference
<css::ui::XAcceleratorConfiguration
> mxCachedDocumentAcceleratorConfiguration
;
71 cssu::Reference
<css::ui::XAcceleratorConfiguration
> mxCachedModuleAcceleratorConfiguration
;
72 cssu::Reference
<css::ui::XAcceleratorConfiguration
> mxCachedGlobalAcceleratorConfiguration
;
73 ::rtl::OUString msCachedModuleIdentifier
;
74 cssu::Reference
<css::lang::XComponent
> mxFrameListener
;
76 CommandInfoProvider (void);
77 ~CommandInfoProvider (void);
79 cssu::Reference
<css::ui::XAcceleratorConfiguration
> GetDocumentAcceleratorConfiguration (void);
80 cssu::Reference
<css::ui::XAcceleratorConfiguration
> GetModuleAcceleratorConfiguration (void);
81 cssu::Reference
<css::ui::XAcceleratorConfiguration
> GetGlobalAcceleratorConfiguration(void);
82 ::rtl::OUString
GetModuleIdentifier (void);
83 ::rtl::OUString
GetCommandShortcut (const ::rtl::OUString
& rCommandName
);
84 cssu::Sequence
<css::beans::PropertyValue
> GetCommandProperties (
85 const ::rtl::OUString
& rsCommandName
);
86 ::rtl::OUString
GetCommandLabel (const ::rtl::OUString
& rsCommandName
);
87 rtl::OUString
RetrieveShortcutsFromConfiguration(
88 const cssu::Reference
<css::ui::XAcceleratorConfiguration
>& rxConfiguration
,
89 const rtl::OUString
& rsCommandName
);
92 } } // end of namespace sfx2/framework