1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_SFX2_SIDEBAR_COMMANDINFOPROVIDER_HXX
20 #define INCLUDED_SFX2_SIDEBAR_COMMANDINFOPROVIDER_HXX
22 #include <sfx2/dllapi.h>
24 #include <com/sun/star/frame/XFrame.hpp>
25 #include <com/sun/star/uno/XComponentContext.hpp>
26 #include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
28 namespace cssu
= ::com::sun::star::uno
;
30 namespace sfx2
{ namespace sidebar
{
32 /** Provide information about UNO commands like tooltip text with
35 class SFX2_DLLPUBLIC CommandInfoProvider
38 /** Return the singleton instance.
40 It caches some objects for the last XFrame object given to
41 GetLabelForCommand. These objects are release and created new
42 when that method is called with a different XFrame from the
45 Lifetime control should work but could be more elegant.
47 static CommandInfoProvider
& Instance (void);
49 /** Return a label for the given command.
51 The command name is expected to start with .uno:
53 The frame is used to identify the module and document.
55 The returned label contains the keyboard accelerator, if
58 ::rtl::OUString
GetLabelForCommand (
59 const ::rtl::OUString
& rsCommandName
,
60 const cssu::Reference
<css::frame::XFrame
>& rxFrame
);
62 /** Do not call. Should be part of a local and hidden interface.
64 void SetFrame (const cssu::Reference
<css::frame::XFrame
>& rxFrame
);
67 cssu::Reference
<css::uno::XComponentContext
> mxContext
;
68 cssu::Reference
<css::frame::XFrame
> mxCachedDataFrame
;
69 cssu::Reference
<css::ui::XAcceleratorConfiguration
> mxCachedDocumentAcceleratorConfiguration
;
70 cssu::Reference
<css::ui::XAcceleratorConfiguration
> mxCachedModuleAcceleratorConfiguration
;
71 cssu::Reference
<css::ui::XAcceleratorConfiguration
> mxCachedGlobalAcceleratorConfiguration
;
72 ::rtl::OUString msCachedModuleIdentifier
;
73 cssu::Reference
<css::lang::XComponent
> mxFrameListener
;
75 CommandInfoProvider (void);
76 ~CommandInfoProvider (void);
78 cssu::Reference
<css::ui::XAcceleratorConfiguration
> GetDocumentAcceleratorConfiguration (void);
79 cssu::Reference
<css::ui::XAcceleratorConfiguration
> GetModuleAcceleratorConfiguration (void);
80 cssu::Reference
<css::ui::XAcceleratorConfiguration
> GetGlobalAcceleratorConfiguration(void);
81 ::rtl::OUString
GetModuleIdentifier (void);
82 ::rtl::OUString
GetCommandShortcut (const ::rtl::OUString
& rCommandName
);
83 cssu::Sequence
<css::beans::PropertyValue
> GetCommandProperties (
84 const ::rtl::OUString
& rsCommandName
);
85 ::rtl::OUString
GetCommandLabel (const ::rtl::OUString
& rsCommandName
);
86 rtl::OUString
RetrieveShortcutsFromConfiguration(
87 const cssu::Reference
<css::ui::XAcceleratorConfiguration
>& rxConfiguration
,
88 const rtl::OUString
& rsCommandName
);
91 } } // end of namespace sfx2/framework
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */