1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
19 #ifndef INCLUDED_SFX2_UNOCTITM_HXX
20 #define INCLUDED_SFX2_UNOCTITM_HXX
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>
38 #include <sfx2/ctrlitem.hxx>
39 #include <osl/mutex.hxx>
45 class SfxUnoControllerItem
: public ::cppu::WeakImplHelper1
< css::frame::XStatusListener
>
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
;
52 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
> TryGetDispatch( SfxFrame
* pFrame
);
56 SfxUnoControllerItem( SfxControllerItem
*, SfxBindings
&, const OUString
& );
57 virtual ~SfxUnoControllerItem();
59 const ::com::sun::star::util::URL
& GetCommand() const
63 virtual void SAL_CALL
statusChanged(const ::com::sun::star::frame::FeatureStateEvent
& Event
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
66 virtual void SAL_CALL
disposing(const ::com::sun::star::lang::EventObject
& Source
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
68 void GetNewDispatch();
69 void ReleaseDispatch();
70 void ReleaseBindings();
73 typedef cppu::OMultiTypeInterfaceContainerHelperVar
<OUString
>
74 SfxStatusDispatcher_Impl_ListenerContainer
;
76 class SfxStatusDispatcher
: public ::cppu::WeakImplHelper1
< css::frame::XNotifyingDispatch
>
79 SfxStatusDispatcher_Impl_ListenerContainer aListeners
;
83 SfxStatusDispatcher();
86 virtual void SAL_CALL
dispatchWithNotification( const ::com::sun::star::util::URL
& aURL
,
87 const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& aArgs
,
88 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchResultListener
>& rListener
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
89 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
;
90 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
;
91 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
;
95 SfxStatusDispatcher_Impl_ListenerContainer
& GetListeners()
96 { return aListeners
; }
100 class SfxDispatchController_Impl
;
101 class SfxOfficeDispatch
: public ::cppu::ImplInheritanceHelper1
< SfxStatusDispatcher
, css::lang::XUnoTunnel
>
103 friend class SfxDispatchController_Impl
;
104 SfxDispatchController_Impl
* pControllerItem
;
106 SfxOfficeDispatch( SfxBindings
& rBind
,
107 SfxDispatcher
* pDispat
,
108 const SfxSlot
* pSlot
,
109 const ::com::sun::star::util::URL
& rURL
);
110 SfxOfficeDispatch( SfxDispatcher
* pDispat
,
111 const SfxSlot
* pSlot
,
112 const ::com::sun::star::util::URL
& rURL
);
113 virtual ~SfxOfficeDispatch();
115 virtual void SAL_CALL
dispatchWithNotification( const ::com::sun::star::util::URL
& aURL
,
116 const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& aArgs
,
117 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchResultListener
>& rListener
)
118 throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
119 virtual void SAL_CALL
dispatch( const ::com::sun::star::util::URL
& aURL
,
120 const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& aArgs
)
121 throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
122 virtual void SAL_CALL
addStatusListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XStatusListener
> & xControl
,
123 const ::com::sun::star::util::URL
& aURL
)
124 throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
127 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
;
128 static const ::com::sun::star::uno::Sequence
< sal_Int8
>& impl_getStaticIdentifier();
130 static bool IsMasterUnoCommand( const ::com::sun::star::util::URL
& aURL
);
131 static OUString
GetMasterUnoCommand( const ::com::sun::star::util::URL
& aURL
);
133 void SetFrame(const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& xFrame
);
135 void SetMasterUnoCommand( bool bSet
);
137 SfxDispatcher
* GetDispatcher_Impl();
140 class SfxDispatchController_Impl
: public SfxControllerItem
142 ::com::sun::star::util::URL aDispatchURL
;
143 SfxDispatcher
* pDispatcher
;
144 SfxBindings
* pBindings
;
145 const SfxPoolItem
* pLastState
;
147 SfxOfficeDispatch
* pDispatch
;
150 const char* pUnoName
;
151 ::com::sun::star::uno::WeakReference
< ::com::sun::star::frame::XFrame
> xFrame
;
153 static void addParametersToArgs( const com::sun::star::util::URL
& aURL
,
154 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& rArgs
);
155 static SfxMapUnit
GetCoreMetric( SfxItemPool
& rPool
, sal_uInt16 nSlot
);
158 SfxDispatchController_Impl( SfxOfficeDispatch
* pDisp
,
160 SfxDispatcher
* pDispat
,
161 const SfxSlot
* pSlot
,
162 const ::com::sun::star::util::URL
& rURL
);
163 virtual ~SfxDispatchController_Impl();
165 static OUString
getSlaveCommand( const ::com::sun::star::util::URL
& rURL
);
167 void StateChanged( sal_uInt16 nSID
, SfxItemState eState
, const SfxPoolItem
* pState
, SfxSlotServer
* pServ
);
168 virtual void StateChanged( sal_uInt16 nSID
, SfxItemState eState
, const SfxPoolItem
* pState
) SAL_OVERRIDE
;
169 void setMasterSlaveCommand( bool bSet
);
170 void SAL_CALL
dispatch( const ::com::sun::star::util::URL
& aURL
,
171 const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& aArgs
,
172 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchResultListener
>& rListener
)
173 throw (css::uno::RuntimeException
, std::exception
);
174 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
);
175 void UnBindController();
176 SfxDispatcher
* GetDispatcher();
177 void SetFrame(const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& xFrame
);
179 static void InterceptLOKStateChangeEvent(const SfxObjectShell
* objSh
, const ::com::sun::star::frame::FeatureStateEvent
& aEvent
);
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */