bump product version to 4.2.0.1
[LibreOffice.git] / include / sfx2 / mnuitem.hxx
blob51d2c65d69d0d55da8fc2ec1ff42885d30dd5c35
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
29 class SfxVirtualMenu;
30 class SfxBindings;
31 class SfxModule;
32 class Menu;
33 class PopupMenu;
34 class SfxUnoMenuControl;
35 class SfxUnoControllerItem;
36 struct SfxMenuCtrlFactory;
38 class SFX2_DLLPUBLIC SfxMenuControl: public SfxControllerItem
40 OUString aTitle;
41 SfxVirtualMenu* pOwnMenu;
42 SfxVirtualMenu* pSubMenu;
43 sal_Bool b_ShowStrings;
45 public:
46 SfxMenuControl();
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 );
53 ~SfxMenuControl();
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;
78 public:
79 SfxUnoMenuControl( const OUString&, sal_uInt16 nId, Menu&,
80 const OUString&,
81 SfxBindings&, SfxVirtualMenu* );
82 ~SfxUnoMenuControl();
85 typedef SfxMenuControl* (*SfxMenuControlCtor)( sal_uInt16 nId, Menu &, SfxBindings & );
87 struct SfxMenuCtrlFactory
89 SfxMenuControlCtor pCtor;
90 TypeId nTypeId;
91 sal_uInt16 nSlotId;
93 SfxMenuCtrlFactory( SfxMenuControlCtor pTheCtor,
94 TypeId nTheTypeId, sal_uInt16 nTheSlotId ):
95 pCtor(pTheCtor),
96 nTypeId(nTheTypeId),
97 nSlotId(nTheSlotId)
101 inline OUString SfxMenuControl::GetTitle() const
103 return aTitle;
106 inline SfxVirtualMenu* SfxMenuControl::GetPopupMenu() const
108 return pSubMenu;
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
124 PopupMenu* pMenu;
125 sal_uIntPtr m_nSymbolsStyle;
126 sal_Bool m_bShowMenuImages;
128 protected:
129 DECL_LINK( Activate, Menu * ); // Needed to support high contrast images
131 public:
132 SFX_DECL_MENU_CONTROL();
133 SfxAppMenuControl_Impl( sal_uInt16 nPos, Menu& rMenu, SfxBindings& rBindings );
134 ~SfxAppMenuControl_Impl();
136 struct ExecuteInfo
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* );
146 #endif
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */