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_MNUITEM_HXX
20 #define INCLUDED_SFX2_MNUITEM_HXX
22 #include <com/sun/star/frame/XDispatch.hpp>
23 #include <com/sun/star/util/URL.hpp>
24 #include <rtl/ustring.hxx>
25 #include <sal/config.h>
26 #include <sfx2/ctrlitem.hxx>
27 #include <sfx2/dllapi.h>
28 #include <tools/link.hxx>
35 class SfxUnoMenuControl
;
36 class SfxUnoControllerItem
;
37 struct SfxMenuCtrlFactory
;
39 class SFX2_DLLPUBLIC SfxMenuControl
: public SfxControllerItem
42 SfxVirtualMenu
* pOwnMenu
;
43 SfxVirtualMenu
* pSubMenu
;
48 SfxMenuControl( bool bShowStrings
);
49 SfxMenuControl( sal_uInt16
, SfxBindings
&);
51 static SfxMenuControl
* CreateImpl( sal_uInt16 nId
, Menu
&rMenu
, SfxBindings
&rBindings
);
52 static void RegisterControl( sal_uInt16 nSlotId
= 0, SfxModule
*pMod
=NULL
);
54 virtual ~SfxMenuControl();
56 using SfxControllerItem::Bind
;
57 void Bind( SfxVirtualMenu
* pOwnMenu
, sal_uInt16 nId
,
58 const OUString
& rTitle
, SfxBindings
& rBindings
);
59 void Bind( SfxVirtualMenu
* pOwnMenu
, sal_uInt16 nId
,
60 SfxVirtualMenu
& rSubMenu
,
61 const OUString
& rTitle
, SfxBindings
& rBindings
);
63 OUString
GetTitle() const;
64 SfxVirtualMenu
* GetPopupMenu() const;
65 virtual PopupMenu
* GetPopup() const;
67 virtual void StateChanged( sal_uInt16 nSID
, SfxItemState eState
,
68 const SfxPoolItem
* pState
) SAL_OVERRIDE
;
70 static SfxMenuControl
* CreateControl( sal_uInt16 nId
, Menu
&, SfxBindings
& );
71 static SfxUnoMenuControl
* CreateControl( const OUString
&, sal_uInt16
, Menu
&, const OUString
& sItemText
, SfxBindings
&, SfxVirtualMenu
* );
72 static void RegisterMenuControl( SfxModule
*, SfxMenuCtrlFactory
* );
76 class SfxUnoMenuControl
: public SfxMenuControl
78 SfxUnoControllerItem
* pUnoCtrl
;
80 SfxUnoMenuControl( const OUString
&, sal_uInt16 nId
, Menu
&,
82 SfxBindings
&, SfxVirtualMenu
* );
83 virtual ~SfxUnoMenuControl();
86 typedef SfxMenuControl
* (*SfxMenuControlCtor
)( sal_uInt16 nId
, Menu
&, SfxBindings
& );
88 struct SfxMenuCtrlFactory
90 SfxMenuControlCtor pCtor
;
94 SfxMenuCtrlFactory( SfxMenuControlCtor pTheCtor
,
95 TypeId nTheTypeId
, sal_uInt16 nTheSlotId
):
102 inline OUString
SfxMenuControl::GetTitle() const
107 inline SfxVirtualMenu
* SfxMenuControl::GetPopupMenu() const
112 #define SFX_DECL_MENU_CONTROL() \
113 static SfxMenuControl* CreateImpl( sal_uInt16 nId, Menu &rMenu, SfxBindings &rBindings ); \
114 static void RegisterControl(sal_uInt16 nSlotId = 0, SfxModule *pMod=NULL)
116 #define SFX_IMPL_MENU_CONTROL(Class, nItemClass) \
117 SfxMenuControl* Class::CreateImpl( sal_uInt16 nId, Menu &rMenu, SfxBindings &rBindings ) \
118 { return new Class(nId, rMenu, rBindings); } \
119 void Class::RegisterControl(sal_uInt16 nSlotId, SfxModule *pMod) \
120 { SfxMenuControl::RegisterMenuControl( pMod, new SfxMenuCtrlFactory( \
121 Class::CreateImpl, TYPE(nItemClass), nSlotId ) ); }
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */