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_UIELEMENT_GENERICTOOLBARCONTROLLER_HXX_
29 #define __FRAMEWORK_UIELEMENT_GENERICTOOLBARCONTROLLER_HXX_
30 
31 //_________________________________________________________________________________________________________________
32 //	includes of other projects
33 //_________________________________________________________________________________________________________________
34 
35 #include <svtools/toolboxcontroller.hxx>
36 #include <vcl/toolbox.hxx>
37 #include <memory>
38 
39 class PopupMenu;
40 
41 namespace framework
42 {
43 
44 struct ExecuteInfo;
45 class ToolBar;
46 class GenericToolbarController : public svt::ToolboxController
47 {
48     public:
49         GenericToolbarController( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager,
50                                   const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame,
51                                   ToolBox* pToolBar,
52                                   sal_uInt16   nID,
53                                   const rtl::OUString& aCommand );
54         virtual ~GenericToolbarController();
55 
56         // XComponent
57         virtual void SAL_CALL dispose() throw ( ::com::sun::star::uno::RuntimeException );
58 
59         // XToolbarController
60         virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw (::com::sun::star::uno::RuntimeException);
61 
62         // XStatusListener
63 		virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
64 
65          DECL_STATIC_LINK( GenericToolbarController, ExecuteHdl_Impl, ExecuteInfo* );
66 
67     protected:
68         ToolBox*        m_pToolbar;
69         sal_uInt16      m_nID;
70         sal_Bool        m_bEnumCommand : 1,
71                         m_bMadeInvisible : 1;
72         rtl::OUString   m_aEnumCommand;
73 };
74 
75 class MenuToolbarController : public GenericToolbarController
76 {
77     com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > m_xMenuDesc;
78     PopupMenu* pMenu;
79     com::sun::star::uno::Reference< com::sun::star::lang::XComponent > m_xMenuManager;
80     rtl::OUString m_aModuleIdentifier;
81     public:
82         MenuToolbarController( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager,
83                                   const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame,
84                                   ToolBox* pToolBar,
85                                   sal_uInt16   nID,
86                                   const rtl::OUString& aCommand,
87                                   const rtl::OUString& aModuleIdentifier,
88                                   const com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess >& xMenuDesc );
89 
90     ~MenuToolbarController();
91     // XToolbarController
92     virtual void SAL_CALL click() throw ( ::com::sun::star::uno::RuntimeException );
93     virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createPopupWindow() throw (::com::sun::star::uno::RuntimeException);
94 
95 };
96 
97 }
98 
99 #endif // __FRAMEWORK_UIELEMENT_GENERICTOOLBARCONTROLLER_HXX_
100