fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / framework / inc / dispatch / menudispatcher.hxx
blob633874b13f1e86064a8ea3df40323fe861ee5699
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_FRAMEWORK_INC_DISPATCH_MENUDISPATCHER_HXX
21 #define INCLUDED_FRAMEWORK_INC_DISPATCH_MENUDISPATCHER_HXX
23 #include <classes/taskcreator.hxx>
24 #include <macros/generic.hxx>
25 #include <macros/xinterface.hxx>
26 #include <macros/xtypeprovider.hxx>
27 #include <classes/menumanager.hxx>
28 #include <general.h>
29 #include <stdtypes.h>
31 #include <com/sun/star/lang/XTypeProvider.hpp>
32 #include <com/sun/star/frame/XDispatch.hpp>
33 #include <com/sun/star/util/URL.hpp>
34 #include <com/sun/star/frame/DispatchDescriptor.hpp>
35 #include <com/sun/star/beans/PropertyValue.hpp>
36 #include <com/sun/star/frame/XStatusListener.hpp>
37 #include <com/sun/star/frame/XFrameLoader.hpp>
38 #include <com/sun/star/frame/XLoadEventListener.hpp>
39 #include <com/sun/star/frame/XDesktop.hpp>
40 #include <com/sun/star/frame/FeatureStateEvent.hpp>
41 #include <com/sun/star/frame/XFrame.hpp>
42 #include <com/sun/star/frame/XFrameActionListener.hpp>
44 #include <cppuhelper/implbase2.hxx>
45 #include <cppuhelper/weakref.hxx>
46 #include <cppuhelper/interfacecontainer.h>
48 namespace framework{
50 typedef cppu::OMultiTypeInterfaceContainerHelperVar<OUString>
51 IMPL_ListenerHashContainer;
53 /*-************************************************************************************************************
54 @short helper for desktop only(!) to create new tasks on demand for dispatches
55 @descr Use this class as member only! Never use it as baseclass.
56 XInterface will be ambigous and we hold a weakcss::uno::Reference to our OWNER - not to our SUPERCLASS!
58 @implements XInterface
59 XDispatch
60 XLoadEventListener
61 XFrameActionListener
62 XEventListener
63 @base OWeakObject
65 @devstatus ready to use
66 *//*-*************************************************************************************************************/
67 class MenuDispatcher : public ::cppu::WeakImplHelper2<
68 css::frame::XDispatch ,
69 css::frame::XFrameActionListener >
72 // public methods
74 public:
76 // constructor / destructor
78 /*-****************************************************************************************************
79 @short standard ctor
80 @descr This initializes a new instance of the class with needed information for work.
82 @seealso using at owner
84 @param "rxContext" , css::uno::Reference to servicemanager for creation of new services
85 @param "xOwner" , css::uno::Reference to our owner, the Desktop!!!
86 *//*-*****************************************************************************************************/
88 MenuDispatcher( const css::uno::Reference< css::uno::XComponentContext >& rxContext ,
89 const css::uno::Reference< css::frame::XFrame >& xOwner );
91 // XDispatch
93 /*-****************************************************************************************************
94 @short dispatch URL with arguments
95 @descr Every dispatch create a new task. If load of URL failed task will deleted automatically!
96 @param "aURL" , URL to dispatch.
97 @param "seqArguments" , list of optional arguments.
98 *//*-*****************************************************************************************************/
100 virtual void SAL_CALL dispatch( const css::util::URL& aURL ,
101 const css::uno::Sequence< css::beans::PropertyValue >& seqProperties ) throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
103 /*-****************************************************************************************************
104 @short add listener for state events
105 @descr You can add a listener to get information about status of dispatch: OK or Failed.
107 @seealso method loadFinished()
108 @seealso method loadCancelled()
110 @param "xControl" , css::uno::Reference to a valid listener for state events.
111 @param "aURL" , URL about listener will be informed, if something occurred.
112 *//*-*****************************************************************************************************/
114 virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl,
115 const css::util::URL& aURL ) throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
117 /*-****************************************************************************************************
118 @short remove listener for state events
119 @descr You can remove a listener if information of dispatch isn't important for you any longer.
121 @seealso method loadFinished()
122 @seealso method loadCancelled()
124 @param "xControl" , css::uno::Reference to a valid listener.
125 @param "aURL" , URL on which listener has registered.
126 *//*-*****************************************************************************************************/
128 virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl,
129 const css::util::URL& aURL ) throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
131 // XFrameActionListener
133 virtual void SAL_CALL frameAction( const css::frame::FrameActionEvent& aEvent ) throw ( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
135 // XEventListener
137 /*-****************************************************************************************************
138 @short dispose current instance
139 @descr If service helper isn't required any longer call this method to release all used resources.
140 @param "aEvent", information about source of this event.
141 *//*-*****************************************************************************************************/
143 void SAL_CALL disposing( const css::lang::EventObject& aEvent ) throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
145 // protected methods
147 protected:
149 /*-****************************************************************************************************
150 @short standard destructor
151 @descr This method destruct an instance of this class and clear some member.
152 This method is protected, because its not allowed to use an instance of this class as a member!
153 You MUST use a pointer.
154 *//*-*****************************************************************************************************/
156 virtual ~MenuDispatcher();
159 private:
161 /*-****************************************************************************************************
162 *//*-*****************************************************************************************************/
164 bool impl_setMenuBar( MenuBar* pMenuBar, bool bMenuFromResource = false );
166 /*-****************************************************************************************************
167 *//*-*****************************************************************************************************/
169 void impl_setAccelerators( Menu* pMenu, const Accelerator& aAccel );
171 // variables
172 // (should be private everyway!)
174 private:
176 css::uno::WeakReference< css::frame::XFrame > m_xOwnerWeak; /// css::uno::WeakReference to owner (Don't use a hard css::uno::Reference. Owner can't delete us then!)
177 css::uno::Reference< css::uno::XComponentContext > m_xContext; /// factory shared with our owner to create new services!
178 osl::Mutex m_mutex;
179 IMPL_ListenerHashContainer m_aListenerContainer; /// hash table for listener at specified URLs
180 bool m_bAlreadyDisposed; /// Protection against multiple disposing calls.
181 bool m_bActivateListener; /// dispatcher is listener for frame activation
182 MenuManager* m_pMenuManager; /// menu manager controlling menu dispatches
184 }; // class MenuDispatcher
186 } // namespace framework
188 #endif // INCLUDED_FRAMEWORK_INC_DISPATCH_MENUDISPATCHER_HXX
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */