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 
23 
24 #ifndef __FRAMEWORK_UIELEMENT_COMPLEXTOOLBARCONTROLLER_HXX_
25 #define __FRAMEWORK_UIELEMENT_COMPLEXTOOLBARCONTROLLER_HXX_
26 
27 #include <com/sun/star/util/URL.hpp>
28 #include <com/sun/star/beans/NamedValue.hpp>
29 #include <com/sun/star/frame/XDispatch.hpp>
30 #include <com/sun/star/frame/ControlCommand.hpp>
31 #include <com/sun/star/frame/XControlNotificationListener.hpp>
32 
33 //_________________________________________________________________________________________________________________
34 //	includes of other projects
35 //_________________________________________________________________________________________________________________
36 #include <svtools/toolboxcontroller.hxx>
37 
38 #include <vcl/toolbox.hxx>
39 
40 namespace framework
41 {
42 
43 struct ExecuteInfo
44 {
45     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >     xDispatch;
46     ::com::sun::star::util::URL                                                aTargetURL;
47     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >  aArgs;
48 };
49 
50 struct NotifyInfo
51 {
52     ::rtl::OUString                                                                           aEventName;
53     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XControlNotificationListener > xNotifyListener;
54     ::com::sun::star::util::URL                                                               aSourceURL;
55     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >                    aInfoSeq;
56 };
57 
58 class ToolBar;
59 
60 class ComplexToolbarController : public svt::ToolboxController
61 
62 {
63     public:
64         ComplexToolbarController( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager,
65                                   const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame,
66                                   ToolBox*     pToolBar,
67                                   sal_uInt16       nID,
68                                   const rtl::OUString& aCommand );
69         virtual ~ComplexToolbarController();
70 
71         // XComponent
72         virtual void SAL_CALL dispose() throw ( ::com::sun::star::uno::RuntimeException );
73 
74         // XToolbarController
75         virtual void SAL_CALL execute( sal_Int16 KeyModifier ) throw (::com::sun::star::uno::RuntimeException);
76 
77         // XStatusListener
78 		virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
79 
80         DECL_STATIC_LINK( ComplexToolbarController, ExecuteHdl_Impl, ExecuteInfo* );
81         DECL_STATIC_LINK( ComplexToolbarController, Notify_Impl, NotifyInfo* );
82 
83     protected:
84         static sal_Int32 getFontSizePixel( const Window* pWindow );
85         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > getDispatchFromCommand( const rtl::OUString& aCommand ) const;
86         void addNotifyInfo( const ::rtl::OUString&                                                        aEventName,
87                             const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >& xDispatch,
88                             const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rInfo );
89 
90         virtual void executeControlCommand( const ::com::sun::star::frame::ControlCommand& rControlCommand ) = 0;
91         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue> getExecuteArgs(sal_Int16 KeyModifier) const;
92         const ::com::sun::star::util::URL& getInitializedURL();
93         void notifyFocusGet();
94         void notifyFocusLost();
95         void notifyTextChanged( const ::rtl::OUString& aText );
96 
97         ToolBox*                                                                    m_pToolbar;
98         sal_uInt16                                                                  m_nID;
99         sal_Bool                                                                    m_bMadeInvisible;
100         mutable ::com::sun::star::util::URL                                         m_aURL;
101         ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer;
102 };
103 
104 }
105 
106 #endif // __FRAMEWORK_UIELEMENT_COMPLEXTOOLBARCONTROLLER_HXX_
107