1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #ifndef __FRAMEWORK_UIELEMENT_POPUPMENU_TOOLBARCONTROLLER_HXX__
23 #define __FRAMEWORK_UIELEMENT_POPUPMENU_TOOLBARCONTROLLER_HXX__
24 
25 #include <com/sun/star/awt/XPopupMenu.hpp>
26 #include <com/sun/star/frame/XPopupMenuController.hpp>
27 #include <com/sun/star/frame/XUIControllerFactory.hpp>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <cppuhelper/implbase1.hxx>
30 #include <macros/xserviceinfo.hxx>
31 #include <svtools/toolboxcontroller.hxx>
32 
33 namespace framework
34 {
35     class PopupMenuToolbarController : public svt::ToolboxController
36     {
37     public:
38         virtual ~PopupMenuToolbarController();
39 
40         // XComponent
41         virtual void SAL_CALL dispose() throw ( ::com::sun::star::uno::RuntimeException );
42         // XInitialization
43         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);
44         // XToolbarController
45         virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createPopupWindow() throw (::com::sun::star::uno::RuntimeException);
46         // XStatusListener
47         virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& rEvent ) throw ( ::com::sun::star::uno::RuntimeException );
48 
49     protected:
50         PopupMenuToolbarController( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
51                                     const ::rtl::OUString &rPopupCommand = rtl::OUString() );
52         virtual void functionExecuted( const rtl::OUString &rCommand );
53         virtual sal_uInt16 getDropDownStyle() const;
54         void createPopupMenuController();
55 
56         com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >      m_xContext;
57         sal_Bool                                                                      m_bHasController;
58         com::sun::star::uno::Reference< com::sun::star::awt::XPopupMenu >             m_xPopupMenu;
59 
60     private:
61         rtl::OUString                                                                 m_aPopupCommand;
62         com::sun::star::uno::Reference< com::sun::star::frame::XUIControllerFactory > m_xPopupMenuFactory;
63         com::sun::star::uno::Reference< com::sun::star::frame::XPopupMenuController > m_xPopupMenuController;
64     };
65 
66     class OpenToolbarController : public PopupMenuToolbarController
67     {
68     public:
69         OpenToolbarController( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
70 
71         // XServiceInfo
72         DECLARE_XSERVICEINFO
73     };
74 
75     class NewToolbarController : public PopupMenuToolbarController
76     {
77     public:
78         NewToolbarController( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
79 
80         // XServiceInfo
81         DECLARE_XSERVICEINFO
82     private:
83         void functionExecuted( const rtl::OUString &rCommand );
84         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);
85         void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& rEvent ) throw ( ::com::sun::star::uno::RuntimeException );
86         void SAL_CALL execute( sal_Int16 KeyModifier ) throw (::com::sun::star::uno::RuntimeException);
87         void setItemImage( const rtl::OUString &rCommand );
88 
89         rtl::OUString m_aLastURL;
90     };
91 
92     class WizardsToolbarController : public PopupMenuToolbarController
93     {
94     public:
95         WizardsToolbarController( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
96 
97         // XServiceInfo
98         DECLARE_XSERVICEINFO
99     private:
100         sal_uInt16 getDropDownStyle() const;
101     };
102 }
103 
104 #endif
105