xref: /AOO41X/main/framework/inc/framework/menuconfiguration.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef __FRAMEWORK_XML_MENUCONFIGURATION_HXX_
29 #define __FRAMEWORK_XML_MENUCONFIGURATION_HXX_
30 
31 //_________________________________________________________________________________________________________________
32 //	interface includes
33 //_________________________________________________________________________________________________________________
34 
35 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
36 #include <com/sun/star/lang/WrappedTargetException.hpp>
37 #include <com/sun/star/io/XInputStream.hpp>
38 #include <com/sun/star/io/XOutputStream.hpp>
39 #include <com/sun/star/frame/XFrame.hpp>
40 #include <com/sun/star/container/XIndexContainer.hpp>
41 #include <com/sun/star/container/XIndexAccess.hpp>
42 #include <com/sun/star/frame/XDispatchProvider.hpp>
43 #include <framework/fwedllapi.h>
44 
45 //_________________________________________________________________________________________________________________
46 //	includes of other projects
47 //_________________________________________________________________________________________________________________
48 
49 #include <cppuhelper/weak.hxx>
50 #include <vcl/menu.hxx>
51 #include <vcl/toolbox.hxx>
52 
53 #define BOOKMARK_NEWMENU		::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:menu_bookmark_new" ))
54 #define BOOKMARK_WIZARDMENU		::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:menu_bookmark_wizard" ))
55 #define ADDONS_POPUPMENU		::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:menu_addons_popup" ))
56 
57 // Prepare for inclusion by framework and sfx
58 // Please consider that there is a corresponding define also in sfxsids.hrc!! (SID_SFX_START)/(SID_ADDONS)
59 #define FWK_SID_SFX_START 5000
60 #define FWK_SID_ADDONS (FWK_SID_SFX_START+1678)
61 #define FWK_SID_ADDONHELP (FWK_SID_SFX_START+1684)
62 
63 const sal_uInt16 START_ITEMID_PICKLIST		= 4500;
64 const sal_uInt16 END_ITEMID_PICKLIST        = 4599;
65 const sal_uInt16 MAX_ITEMCOUNT_PICKLIST     =   99; // difference between START_... & END_... for picklist / must be changed too, if these values are changed!
66 const sal_uInt16 START_ITEMID_WINDOWLIST	= 4600;
67 const sal_uInt16 END_ITEMID_WINDOWLIST		= 4699;
68 const sal_uInt16 ITEMID_ADDONLIST			= FWK_SID_ADDONS;
69 const sal_uInt16 ITEMID_ADDONHELP			= FWK_SID_ADDONHELP;
70 
71 namespace framework
72 {
73 
74 class FWE_DLLPUBLIC MenuConfiguration
75 {
76 	public:
77 		struct Attributes
78 		{
79             Attributes() {}
80 			Attributes( const ::rtl::OUString& aFrame, const ::rtl::OUString& aImageIdStr ) :
81 			    aTargetFrame( aFrame ), aImageId( aImageIdStr ) {}
82 
83 			::rtl::OUString aTargetFrame;
84 			::rtl::OUString	aImageId;
85             ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XDispatchProvider > xDispatchProvider;
86                         sal_Int16 nStyle;
87 		};
88 
89 		MenuConfiguration(
90 			// #110897#-1 use const when giving a uno reference by reference
91 			const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rServiceManager );
92 
93 		virtual ~MenuConfiguration();
94 
95         ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > CreateMenuBarConfigurationFromXML(
96 			::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rInputStream )
97 			throw ( ::com::sun::star::lang::WrappedTargetException );
98 
99 		PopupMenu* CreateBookmarkMenu(
100 				::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame,
101 				const ::rtl::OUString& aURL )
102 			throw ( ::com::sun::star::lang::WrappedTargetException );
103 
104 		ToolBox* CreateToolBoxFromConfiguration(
105 			::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rInputStream )
106 			throw ( ::com::sun::star::lang::WrappedTargetException );
107 
108 		void StoreMenuBarConfigurationToXML( ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rMenuBarConfiguration,
109 					  ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& rOutputStream )
110 			throw ( ::com::sun::star::lang::WrappedTargetException );
111 
112 		void StoreToolBox( ToolBox* pToolBox,
113 					  ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& rOutputStream )
114 			throw ( ::com::sun::star::lang::WrappedTargetException );
115 
116 		static sal_Bool IsPickListItemId( sal_uInt16 nId );
117 		static sal_Bool IsWindowListItemId( sal_uInt16 nId );
118 
119 	private:
120 		// #110897#-1 do not hold the uno reference by reference
121 		const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& m_rxServiceManager;
122 };
123 
124 }
125 
126 #endif // __FRAMEWORK_XML_MENUCONFIGURATION_HXX_
127