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 .
21 #include <sfx2/ctrlitem.hxx>
24 namespace sfx2::sidebar
{
26 /** The sfx2::sidebar::ControllerItem is a wrapper around the
27 SfxControllerItem that becomes necessary to allow objects (think
28 sidebar panels) to receive state changes without having one
29 SfxControllerItem per supported item as base class (which is not
30 possible in C++ anyway).
32 It also gives access to the label and icon of a slot/command.
34 class SFX2_DLLPUBLIC ControllerItem final
35 : public SfxControllerItem
38 class SFX2_DLLPUBLIC ItemUpdateReceiverInterface
41 virtual void NotifyItemUpdate(
42 const sal_uInt16 nSId
,
43 const SfxItemState eState
,
44 const SfxPoolItem
* pState
) = 0;
45 virtual void GetControlState(
46 const sal_uInt16 nSId
,
47 boost::property_tree::ptree
& rState
) = 0;
48 virtual ~ItemUpdateReceiverInterface();
51 /** This is the simpler constructor variant that still exists for
52 compatibility reasons. Note that GetLabel() and GetIcon() will
53 return empty strings/images.
57 SfxBindings
&rBindings
,
58 ItemUpdateReceiverInterface
& rItemUpdateReceiver
);
60 virtual ~ControllerItem() override
;
62 /** Force the controller item to call its NotifyItemUpdate
63 callback with up-to-date data.
69 virtual void StateChangedAtToolBoxControl (sal_uInt16 nSId
, SfxItemState eState
, const SfxPoolItem
* pState
) override
;
70 virtual void GetControlState (sal_uInt16 nSId
, boost::property_tree::ptree
& rState
) override
;
71 void ReceiverNotifyItemUpdate(sal_uInt16 nSID
, SfxItemState eState
, const SfxPoolItem
* pState
);
73 ItemUpdateReceiverInterface
& mrItemUpdateReceiver
;
76 } // end of namespace sfx2::sidebar
78 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */