Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef __FRAMEWORK_UIELEMENT_NEWMENUCONTROLLER_HXX_
30 : : #define __FRAMEWORK_UIELEMENT_NEWMENUCONTROLLER_HXX_
31 : :
32 : : #include <macros/xserviceinfo.hxx>
33 : : #include <stdtypes.h>
34 : :
35 : : #include <com/sun/star/lang/XServiceInfo.hpp>
36 : : #include <com/sun/star/lang/XTypeProvider.hpp>
37 : : #include <com/sun/star/lang/XInitialization.hpp>
38 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
39 : : #include <com/sun/star/frame/XFrame.hpp>
40 : : #include <com/sun/star/frame/XDispatchProvider.hpp>
41 : : #include <com/sun/star/frame/XDispatch.hpp>
42 : : #include <com/sun/star/frame/XStatusListener.hpp>
43 : : #include <com/sun/star/frame/XPopupMenuController.hpp>
44 : : #include <com/sun/star/beans/XPropertySet.hpp>
45 : : #include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
46 : :
47 : : #include <svtools/popupmenucontrollerbase.hxx>
48 : : #include <toolkit/awt/vclxmenu.hxx>
49 : : #include <cppuhelper/weak.hxx>
50 : : #include <rtl/ustring.hxx>
51 : : #include <vcl/accel.hxx>
52 : : #include <vcl/menu.hxx>
53 : : #include <boost/unordered_map.hpp>
54 : :
55 : : namespace framework
56 : : {
57 [ # # ][ # # ]: 0 : struct NewDocument
58 : : {
59 : : ::com::sun::star::util::URL aTargetURL;
60 : : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgSeq;
61 : : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatch;
62 : : };
63 : :
64 : : class NewMenuController : public svt::PopupMenuControllerBase
65 : : {
66 : : using svt::PopupMenuControllerBase::disposing;
67 : :
68 : : public:
69 : : NewMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager );
70 : : virtual ~NewMenuController();
71 : :
72 : : // XServiceInfo
73 : : DECLARE_XSERVICEINFO
74 : :
75 : : // XInitialization
76 : : virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
77 : :
78 : : // XStatusListener
79 : : virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
80 : :
81 : : // XMenuListener
82 : : virtual void SAL_CALL select( const ::com::sun::star::awt::MenuEvent& rEvent ) throw (::com::sun::star::uno::RuntimeException);
83 : : virtual void SAL_CALL activate( const ::com::sun::star::awt::MenuEvent& rEvent ) throw (::com::sun::star::uno::RuntimeException);
84 : :
85 : : // XEventListener
86 : : virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException );
87 : :
88 : : DECL_STATIC_LINK( NewMenuController, ExecuteHdl_Impl, NewDocument* );
89 : :
90 : : private:
91 : : virtual void impl_setPopupMenu();
92 : 0 : struct AddInfo
93 : : {
94 : : rtl::OUString aTargetFrame;
95 : : rtl::OUString aImageId;
96 : : };
97 : :
98 : : typedef ::boost::unordered_map< int, AddInfo > AddInfoForId;
99 : :
100 : : void fillPopupMenu( com::sun::star::uno::Reference< com::sun::star::awt::XPopupMenu >& rPopupMenu );
101 : : void retrieveShortcutsFromConfiguration( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XAcceleratorConfiguration >& rAccelCfg,
102 : : const ::com::sun::star::uno::Sequence< rtl::OUString >& rCommands,
103 : : std::vector< KeyCode >& aMenuShortCuts );
104 : : void setAccelerators( PopupMenu* pPopupMenu );
105 : : void determineAndSetNewDocAccel( PopupMenu* pPopupMenu, const KeyCode& rKeyCode );
106 : : void setMenuImages( PopupMenu* pPopupMenu, sal_Bool bSetImages );
107 : :
108 : : private:
109 : : // members
110 : : sal_Bool m_bShowImages : 1,
111 : : m_bNewMenu : 1,
112 : : m_bModuleIdentified : 1,
113 : : m_bAcceleratorCfg : 1;
114 : : AddInfoForId m_aAddInfoForItem;
115 : : rtl::OUString m_aTargetFrame;
116 : : rtl::OUString m_aModuleIdentifier;
117 : : rtl::OUString m_aEmptyDocURL;
118 : : ::com::sun::star::uno::Reference< ::com::sun::star::ui::XAcceleratorConfiguration > m_xDocAcceleratorManager;
119 : : ::com::sun::star::uno::Reference< ::com::sun::star::ui::XAcceleratorConfiguration > m_xModuleAcceleratorManager;
120 : : ::com::sun::star::uno::Reference< ::com::sun::star::ui::XAcceleratorConfiguration > m_xGlobalAcceleratorManager;
121 : : };
122 : : }
123 : :
124 : : #endif // __FRAMEWORK_UIELEMENT_NEWMENUCONTROLLER_HXX_
125 : :
126 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|