Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef INCLUDED_SFX2_UNOCTITM_HXX
20 : #define INCLUDED_SFX2_UNOCTITM_HXX
21 :
22 : #include <com/sun/star/frame/XNotifyingDispatch.hpp>
23 : #include <com/sun/star/frame/XDispatchResultListener.hpp>
24 : #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
25 : #include <com/sun/star/frame/XDispatch.hpp>
26 : #include <com/sun/star/frame/XDispatchProvider.hpp>
27 : #include <com/sun/star/frame/XStatusListener.hpp>
28 : #include <com/sun/star/frame/FrameSearchFlag.hpp>
29 : #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
30 : #include <com/sun/star/frame/FeatureStateEvent.hpp>
31 : #include <com/sun/star/frame/DispatchDescriptor.hpp>
32 : #include <com/sun/star/util/XURLTransformer.hpp>
33 : #include <com/sun/star/lang/XUnoTunnel.hpp>
34 : #include <com/sun/star/frame/XFrame.hpp>
35 : #include <cppuhelper/implbase1.hxx>
36 : #include <cppuhelper/interfacecontainer.hxx>
37 :
38 : #include <sfx2/ctrlitem.hxx>
39 : #include <osl/mutex.hxx>
40 :
41 : class SfxBindings;
42 : class SfxFrame;
43 : class SfxDispatcher;
44 :
45 : class SfxUnoControllerItem : public ::cppu::WeakImplHelper1< css::frame::XStatusListener >
46 : {
47 : ::com::sun::star::util::URL aCommand;
48 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatch;
49 : SfxControllerItem* pCtrlItem;
50 : SfxBindings* pBindings;
51 :
52 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > TryGetDispatch( SfxFrame* pFrame );
53 :
54 : public:
55 :
56 : SfxUnoControllerItem( SfxControllerItem*, SfxBindings&, const OUString& );
57 : virtual ~SfxUnoControllerItem();
58 :
59 : const ::com::sun::star::util::URL& GetCommand() const
60 : { return aCommand; }
61 :
62 : // XStatusListener
63 : virtual void SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
64 :
65 : // Something else
66 : virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
67 : void UnBind();
68 : void GetNewDispatch();
69 : void ReleaseDispatch();
70 : void ReleaseBindings();
71 : };
72 :
73 : struct SfxStatusDispatcher_Impl_hashType
74 : {
75 : size_t operator()(const OUString& s) const
76 : { return s.hashCode(); }
77 : };
78 :
79 : typedef ::cppu::OMultiTypeInterfaceContainerHelperVar< OUString, SfxStatusDispatcher_Impl_hashType > SfxStatusDispatcher_Impl_ListenerContainer ;
80 :
81 0 : class SfxStatusDispatcher : public ::cppu::WeakImplHelper1< css::frame::XNotifyingDispatch >
82 : {
83 : ::osl::Mutex aMutex;
84 : SfxStatusDispatcher_Impl_ListenerContainer aListeners;
85 :
86 : public:
87 :
88 : SfxStatusDispatcher();
89 :
90 : // XDispatch
91 : virtual void SAL_CALL dispatchWithNotification( const ::com::sun::star::util::URL& aURL,
92 : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs,
93 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchResultListener >& rListener ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
94 : virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& aURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs ) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
95 : virtual void SAL_CALL addStatusListener(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xControl, const ::com::sun::star::util::URL& aURL) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
96 : virtual void SAL_CALL removeStatusListener(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xControl, const ::com::sun::star::util::URL& aURL) throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
97 :
98 : // Something else
99 : void ReleaseAll();
100 0 : SfxStatusDispatcher_Impl_ListenerContainer& GetListeners()
101 0 : { return aListeners; }
102 : };
103 :
104 : class SfxSlotServer;
105 : class SfxDispatchController_Impl;
106 : class SfxOfficeDispatch : public ::cppu::ImplInheritanceHelper1< SfxStatusDispatcher, css::lang::XUnoTunnel >
107 : {
108 : friend class SfxDispatchController_Impl;
109 : SfxDispatchController_Impl* pControllerItem;
110 : public:
111 : SfxOfficeDispatch( SfxBindings& rBind,
112 : SfxDispatcher* pDispat,
113 : const SfxSlot* pSlot,
114 : const ::com::sun::star::util::URL& rURL );
115 : SfxOfficeDispatch( SfxDispatcher* pDispat,
116 : const SfxSlot* pSlot,
117 : const ::com::sun::star::util::URL& rURL );
118 : virtual ~SfxOfficeDispatch();
119 :
120 : virtual void SAL_CALL dispatchWithNotification( const ::com::sun::star::util::URL& aURL,
121 : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs,
122 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchResultListener >& rListener )
123 : throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
124 : virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& aURL,
125 : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs )
126 : throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
127 : virtual void SAL_CALL addStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xControl,
128 : const ::com::sun::star::util::URL& aURL)
129 : throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
130 :
131 : // XUnoTunnel
132 : virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
133 : static const ::com::sun::star::uno::Sequence< sal_Int8 >& impl_getStaticIdentifier();
134 :
135 : static bool IsMasterUnoCommand( const ::com::sun::star::util::URL& aURL );
136 : static OUString GetMasterUnoCommand( const ::com::sun::star::util::URL& aURL );
137 :
138 : void SetFrame(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame);
139 :
140 : void SetMasterUnoCommand( bool bSet );
141 :
142 : SfxDispatcher* GetDispatcher_Impl();
143 : };
144 :
145 : class SfxDispatchController_Impl : public SfxControllerItem
146 : {
147 : ::com::sun::star::util::URL aDispatchURL;
148 : SfxDispatcher* pDispatcher;
149 : SfxBindings* pBindings;
150 : const SfxPoolItem* pLastState;
151 : sal_uInt16 nSlot;
152 : SfxOfficeDispatch* pDispatch;
153 : bool bMasterSlave;
154 : bool bVisible;
155 : const char* pUnoName;
156 : ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XFrame > xFrame;
157 :
158 : void addParametersToArgs( const com::sun::star::util::URL& aURL,
159 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rArgs ) const;
160 : SfxMapUnit GetCoreMetric( SfxItemPool& rPool, sal_uInt16 nSlot );
161 :
162 : public:
163 : SfxDispatchController_Impl( SfxOfficeDispatch* pDisp,
164 : SfxBindings* pBind,
165 : SfxDispatcher* pDispat,
166 : const SfxSlot* pSlot,
167 : const ::com::sun::star::util::URL& rURL );
168 : virtual ~SfxDispatchController_Impl();
169 :
170 : static OUString getSlaveCommand( const ::com::sun::star::util::URL& rURL );
171 :
172 : void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState, SfxSlotServer* pServ );
173 : virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) SAL_OVERRIDE;
174 : void setMasterSlaveCommand( bool bSet );
175 : void SAL_CALL dispatch( const ::com::sun::star::util::URL& aURL,
176 : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs,
177 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchResultListener >& rListener ) throw( ::com::sun::star::uno::RuntimeException );
178 : void SAL_CALL addStatusListener(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xControl, const ::com::sun::star::util::URL& aURL) throw( ::com::sun::star::uno::RuntimeException );
179 : void UnBindController();
180 : SfxDispatcher* GetDispatcher();
181 : void SetFrame(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame);
182 : };
183 :
184 : #endif
185 :
186 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|