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>
34 class SfxUnoMenuControl
;
35 class SfxUnoControllerItem
;
36 struct SfxMenuCtrlFactory
;
38 class SFX2_DLLPUBLIC SfxMenuControl
: public SfxControllerItem
41 SfxVirtualMenu
* pOwnMenu
;
42 SfxVirtualMenu
* pSubMenu
;
43 sal_Bool b_ShowStrings
;
47 SfxMenuControl( sal_Bool bShowStrings
);
48 SfxMenuControl( sal_uInt16
, SfxBindings
&);
50 static SfxMenuControl
* CreateImpl( sal_uInt16 nId
, Menu
&rMenu
, SfxBindings
&rBindings
);
51 static void RegisterControl( sal_uInt16 nSlotId
= 0, SfxModule
*pMod
=NULL
);
55 using SfxControllerItem::Bind
;
56 void Bind( SfxVirtualMenu
* pOwnMenu
, sal_uInt16 nId
,
57 const OUString
& rTitle
, SfxBindings
& rBindings
);
58 void Bind( SfxVirtualMenu
* pOwnMenu
, sal_uInt16 nId
,
59 SfxVirtualMenu
& rSubMenu
,
60 const OUString
& rTitle
, SfxBindings
& rBindings
);
62 OUString
GetTitle() const;
63 SfxVirtualMenu
* GetPopupMenu() const;
64 virtual PopupMenu
* GetPopup() const;
66 virtual void StateChanged( sal_uInt16 nSID
, SfxItemState eState
,
67 const SfxPoolItem
* pState
);
69 static SfxMenuControl
* CreateControl( sal_uInt16 nId
, Menu
&, SfxBindings
& );
70 static SfxUnoMenuControl
* CreateControl( const OUString
&, sal_uInt16
, Menu
&, const OUString
& sItemText
, SfxBindings
&, SfxVirtualMenu
* );
71 static void RegisterMenuControl(SfxModule
*, SfxMenuCtrlFactory
*);
75 class SfxUnoMenuControl
: public SfxMenuControl
77 SfxUnoControllerItem
* pUnoCtrl
;
79 SfxUnoMenuControl( const OUString
&, sal_uInt16 nId
, Menu
&,
81 SfxBindings
&, SfxVirtualMenu
* );
85 typedef SfxMenuControl
* (*SfxMenuControlCtor
)( sal_uInt16 nId
, Menu
&, SfxBindings
& );
87 struct SfxMenuCtrlFactory
89 SfxMenuControlCtor pCtor
;
93 SfxMenuCtrlFactory( SfxMenuControlCtor pTheCtor
,
94 TypeId nTheTypeId
, sal_uInt16 nTheSlotId
):
101 inline OUString
SfxMenuControl::GetTitle() const
106 inline SfxVirtualMenu
* SfxMenuControl::GetPopupMenu() const
111 #define SFX_DECL_MENU_CONTROL() \
112 static SfxMenuControl* CreateImpl( sal_uInt16 nId, Menu &rMenu, SfxBindings &rBindings ); \
113 static void RegisterControl(sal_uInt16 nSlotId = 0, SfxModule *pMod=NULL)
115 #define SFX_IMPL_MENU_CONTROL(Class, nItemClass) \
116 SfxMenuControl* Class::CreateImpl( sal_uInt16 nId, Menu &rMenu, SfxBindings &rBindings ) \
117 { return new Class(nId, rMenu, rBindings); } \
118 void Class::RegisterControl(sal_uInt16 nSlotId, SfxModule *pMod) \
119 { SfxMenuControl::RegisterMenuControl( pMod, new SfxMenuCtrlFactory( \
120 Class::CreateImpl, TYPE(nItemClass), nSlotId ) ); }
122 class SfxAppMenuControl_Impl
: public SfxMenuControl
125 sal_uIntPtr m_nSymbolsStyle
;
126 sal_Bool m_bShowMenuImages
;
129 DECL_LINK( Activate
, Menu
* ); // Needed to support high contrast images
132 SFX_DECL_MENU_CONTROL();
133 SfxAppMenuControl_Impl( sal_uInt16 nPos
, Menu
& rMenu
, SfxBindings
& rBindings
);
134 ~SfxAppMenuControl_Impl();
138 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
> xDispatch
;
139 ::com::sun::star::util::URL aTargetURL
;
140 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> aArgs
;
143 DECL_STATIC_LINK( SfxAppMenuControl_Impl
, ExecuteHdl_Impl
, ExecuteInfo
* );
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */