fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / include / sfx2 / sidebar / ControllerItem.hxx
blob70b4c3d3d7f3173ce33d4b61349f5da2de20c782
1 /*
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 SVX_SIDEBAR_CONTROLLER_ITEM_HXX
19 #define SVX_SIDEBAR_CONTROLLER_ITEM_HXX
21 #include <sfx2/ctrlitem.hxx>
23 #include <cppuhelper/compbase1.hxx>
24 #include <cppuhelper/basemutex.hxx>
25 #include <unotools/cmdoptions.hxx>
26 #include <vcl/image.hxx>
28 #include <com/sun/star/frame/XFrame.hpp>
30 #include <boost/function.hpp>
33 namespace css = ::com::sun::star;
34 namespace cssu = ::com::sun::star::uno;
36 class SfxViewFrame;
37 class ToolBox;
40 namespace sfx2 { namespace sidebar {
42 /** The sfx2::sidebar::ControllerItem is a wrapper around the
43 SfxControllerItem that becomes necessary to allow objects (think
44 sidebar panels) to receive state changes without having one
45 SfxControllerItem per supported item as base class (which is not
46 possible in C++ anyway).
48 It also gives access to the label and icon of a slot/command.
50 class SFX2_DLLPUBLIC ControllerItem
51 : public SfxControllerItem
53 public:
54 class SFX2_DLLPUBLIC ItemUpdateReceiverInterface
56 public:
57 virtual void NotifyItemUpdate(
58 const sal_uInt16 nSId,
59 const SfxItemState eState,
60 const SfxPoolItem* pState,
61 const bool bIsEnabled) = 0;
62 virtual ~ItemUpdateReceiverInterface();
65 /** This is the preferred constructor that allows the created
66 controller item to return non-empty values for GetLable() and
67 GetIcon() calls.
69 ControllerItem (
70 const sal_uInt16 nSlotId,
71 SfxBindings &rBindings,
72 ItemUpdateReceiverInterface& rItemUpdateReceiver,
73 const ::rtl::OUString& rsCommandName,
74 const cssu::Reference<css::frame::XFrame>& rxFrame);
76 /** This is the simpler constructor variant that still exists for
77 compatibility resons. Note that GetLabel() and GetIcon() will
78 return empty strings/images.
80 ControllerItem (
81 const sal_uInt16 nId,
82 SfxBindings &rBindings,
83 ItemUpdateReceiverInterface& rItemUpdateReceiver);
85 virtual ~ControllerItem();
87 /** Returns </TRUE> when the slot/command has not been disabled.
88 Changes of this state are notified via the
89 ItemUpdateReceiverInterface::NotifyContextChang() method.
91 bool IsEnabled (const SfxItemState eState) const;
93 /** Force the controller item to call its NotifyItemUpdate
94 callback with up-to-date data.
96 void RequestUpdate (void);
98 /** Return the label for the command. It contains the keyboard
99 accelerator when one exists.
101 ::rtl::OUString GetLabel (void) const;
103 /** Return the extended help text for the command.
104 Returns an empty string when the UNO command name is not available.
106 ::rtl::OUString GetHelpText (void) const;
108 /** Return the icon for the command.
110 Image GetIcon (void) const;
112 /** Convenience method for setting all relevant properties for the
113 slot/command represented by the called object at the given tool
114 box.
116 void SetupToolBoxItem (ToolBox& rToolBox, const sal_uInt16 nIndex);
118 /** Do not call. Used by local class only. Should be a member of
119 a local and hidden interface.
121 void NotifyFrameContextChange (void);
122 /** Do not call. Used by local class only. Should be a member of
123 a local and hidden interface.
125 void ResetFrame (void);
127 protected:
129 virtual void StateChanged (sal_uInt16 nSId, SfxItemState eState, const SfxPoolItem* pState);
131 private:
132 ItemUpdateReceiverInterface& mrItemUpdateReceiver;
133 cssu::Reference<css::frame::XFrame> mxFrame;
134 cssu::Reference<css::lang::XComponent> mxFrameActionListener;
135 const ::rtl::OUString msCommandName;
137 void SetupCommandURL (const sal_Char* sCommandName);
140 } } // end of namespace sfx2::sidebar
142 #endif