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 .
20 #ifndef INCLUDED_FRAMEWORK_INC_CLASSES_MENUMANAGER_HXX
21 #define INCLUDED_FRAMEWORK_INC_CLASSES_MENUMANAGER_HXX
25 #include <com/sun/star/frame/XFrame.hpp>
26 #include <com/sun/star/frame/XDispatch.hpp>
27 #include <com/sun/star/frame/FeatureStateEvent.hpp>
28 #include <com/sun/star/beans/PropertyValue.hpp>
29 #include <com/sun/star/util/XURLTransformer.hpp>
31 #include <rtl/ustring.hxx>
32 #include <vcl/menu.hxx>
33 #include <vcl/accel.hxx>
34 #include <cppuhelper/implbase1.hxx>
36 namespace com
{ namespace sun
{ namespace star
{ namespace uno
{
37 class XComponentContext
;
46 class MenuManager
: public ::cppu::WeakImplHelper1
< css::frame::XStatusListener
>
50 const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
,
51 css::uno::Reference
< css::frame::XFrame
>& rFrame
,
54 bool bDeleteChildren
);
56 virtual ~MenuManager();
59 virtual void SAL_CALL
statusChanged( const css::frame::FeatureStateEvent
& Event
) throw ( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
62 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) throw ( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
64 DECL_LINK( Select
, Menu
* );
66 Menu
* GetMenu() const { return m_pVCLMenu
; }
68 void RemoveListener();
70 static void UpdateSpecialWindowMenu( Menu
* pMenu
,const css::uno::Reference
< css::uno::XComponentContext
>& xContext
);
71 static void FillMenuImages(
72 css::uno::Reference
< css::frame::XFrame
>& xFrame
,
78 DECL_LINK_TYPED(Highlight
, Menu
*, bool);
79 DECL_LINK_TYPED( Activate
, Menu
*, bool );
80 DECL_LINK_TYPED( Deactivate
, Menu
*, bool );
83 void UpdateSpecialFileMenu( Menu
* pMenu
);
84 void UpdateSpecialWindowMenu( Menu
* pMenu
);
85 void ClearMenuDispatch(const css::lang::EventObject
& Source
= css::lang::EventObject(),bool _bRemoveOnly
= true);
87 void AddMenu(PopupMenu
* _pPopupMenu
,const OUString
& _sItemCommand
,sal_uInt16 _nItemId
,bool _bDelete
,bool _bDeleteChildren
);
88 sal_uInt16
FillItemCommand(OUString
& _rItemCommand
, Menu
* _pMenu
,sal_uInt16 _nIndex
) const;
90 struct MenuItemHandler
92 MenuItemHandler( sal_uInt16 aItemId
, MenuManager
* pManager
, css::uno::Reference
< css::frame::XDispatch
>& rDispatch
) :
93 nItemId( aItemId
), pSubMenuManager( pManager
), xMenuItemDispatch( rDispatch
) {}
96 OUString aTargetFrame
;
97 OUString aMenuItemURL
;
101 MenuManager
* pSubMenuManager
;
102 css::uno::Reference
< css::frame::XDispatch
> xMenuItemDispatch
;
105 void CreatePicklistArguments(
106 css::uno::Sequence
< css::beans::PropertyValue
>& aArgsList
,
107 const MenuItemHandler
* );
109 MenuItemHandler
* GetMenuItemHandler( sal_uInt16 nItemId
);
113 bool m_bDeleteChildren
;
115 bool m_bIsBookmarkMenu
;
116 bool m_bShowMenuImages
;
117 OUString m_aMenuItemCommand
;
119 css::uno::Reference
< css::frame::XFrame
> m_xFrame
;
120 ::std::vector
< MenuItemHandler
* > m_aMenuItemHandlerVector
;
122 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
123 css::uno::Reference
< css::util::XURLTransformer
> m_xURLTransformer
;
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */