1*353d8f4dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*353d8f4dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*353d8f4dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*353d8f4dSAndrew Rist  * distributed with this work for additional information
6*353d8f4dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*353d8f4dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*353d8f4dSAndrew Rist  * "License"); you may not use this file except in compliance
9*353d8f4dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*353d8f4dSAndrew Rist  *
11*353d8f4dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*353d8f4dSAndrew Rist  *
13*353d8f4dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*353d8f4dSAndrew Rist  * software distributed under the License is distributed on an
15*353d8f4dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*353d8f4dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*353d8f4dSAndrew Rist  * specific language governing permissions and limitations
18*353d8f4dSAndrew Rist  * under the License.
19*353d8f4dSAndrew Rist  *
20*353d8f4dSAndrew Rist  *************************************************************/
21*353d8f4dSAndrew Rist 
22*353d8f4dSAndrew Rist 
23cdf0e10cSrcweir #ifndef INCLUDED_SFX_HELPINTERCEPTOR_HXX
24cdf0e10cSrcweir #define INCLUDED_SFX_HELPINTERCEPTOR_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #ifndef _CPPUHELPER_IMPLBASE2_HXX_
27cdf0e10cSrcweir #include <cppuhelper/implbase3.hxx>
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
30cdf0e10cSrcweir #include <com/sun/star/frame/XInterceptorInfo.hpp>
31cdf0e10cSrcweir #include <com/sun/star/frame/XDispatch.hpp>
32cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
33cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
34cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
35cdf0e10cSrcweir #include <com/sun/star/frame/XStatusListener.hpp>
36cdf0e10cSrcweir #include <tools/string.hxx>
37cdf0e10cSrcweir #include <tools/list.hxx>
38cdf0e10cSrcweir #include <tools/link.hxx>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir struct HelpHistoryEntry_Impl
41cdf0e10cSrcweir {
42cdf0e10cSrcweir 	String	aURL;
43cdf0e10cSrcweir     com::sun::star::uno::Any    aViewData;
44cdf0e10cSrcweir 
HelpHistoryEntry_ImplHelpHistoryEntry_Impl45cdf0e10cSrcweir     HelpHistoryEntry_Impl( const String& rURL, const com::sun::star::uno::Any& rViewData ) :
46cdf0e10cSrcweir         aURL( rURL ), aViewData(rViewData) {}
47cdf0e10cSrcweir };
48cdf0e10cSrcweir 
49cdf0e10cSrcweir DECLARE_LIST(HelpHistoryList_Impl,HelpHistoryEntry_Impl*)
50cdf0e10cSrcweir 
51cdf0e10cSrcweir class SfxHelpWindow_Impl;
52cdf0e10cSrcweir class HelpInterceptor_Impl : public ::cppu::WeakImplHelper3<
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 		::com::sun::star::frame::XDispatchProviderInterceptor,
55cdf0e10cSrcweir 		::com::sun::star::frame::XInterceptorInfo,
56cdf0e10cSrcweir 		::com::sun::star::frame::XDispatch >
57cdf0e10cSrcweir 
58cdf0e10cSrcweir {
59cdf0e10cSrcweir private:
60cdf0e10cSrcweir friend class HelpDispatch_Impl;
61cdf0e10cSrcweir friend class SfxHelpWindow_Impl;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 	// the component which's dispatches we're intercepting
64cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception > m_xIntercepted;
65cdf0e10cSrcweir 
66cdf0e10cSrcweir 	// chaining
67cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > m_xSlaveDispatcher;
68cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > m_xMasterDispatcher;
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > m_xListener;
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 	HelpHistoryList_Impl*		m_pHistory;
73cdf0e10cSrcweir 	SfxHelpWindow_Impl*			m_pWindow;
74cdf0e10cSrcweir 	sal_uIntPtr						m_nCurPos;
75cdf0e10cSrcweir 	String						m_aCurrentURL;
76cdf0e10cSrcweir     com::sun::star::uno::Any    m_aViewData;
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	void						addURL( const String& rURL );
79cdf0e10cSrcweir 
80cdf0e10cSrcweir public:
81cdf0e10cSrcweir 	HelpInterceptor_Impl();
82cdf0e10cSrcweir 	~HelpInterceptor_Impl();
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 	void 					setInterception( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame );
85cdf0e10cSrcweir 	void					SetStartURL( const String& rURL );
GetCurrentURL() const86cdf0e10cSrcweir 	String					GetCurrentURL() const { return m_aCurrentURL; }
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 
GetViewData() const90cdf0e10cSrcweir     const com::sun::star::uno::Any&     GetViewData()const {return m_aViewData;}
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     sal_Bool                HasHistoryPred() const;     // is there a predecessor for the current in the history
93cdf0e10cSrcweir 	sal_Bool				HasHistorySucc() const;		// is there a successor for the current in the history
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     // XDispatchProvider
96cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL
97cdf0e10cSrcweir 							queryDispatch( const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw(::com::sun::star::uno::RuntimeException);
98cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL
99cdf0e10cSrcweir 							queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw(::com::sun::star::uno::RuntimeException);
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 	// XDispatchProviderInterceptor
102cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL
103cdf0e10cSrcweir 							getSlaveDispatchProvider(  ) throw(::com::sun::star::uno::RuntimeException);
104cdf0e10cSrcweir     virtual void SAL_CALL	setSlaveDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewSlave ) throw(::com::sun::star::uno::RuntimeException);
105cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL
106cdf0e10cSrcweir 							getMasterDispatchProvider(  ) throw(::com::sun::star::uno::RuntimeException);
107cdf0e10cSrcweir     virtual void SAL_CALL	setMasterDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewMaster ) throw(::com::sun::star::uno::RuntimeException);
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 	// XInterceptorInfo
110cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
111cdf0e10cSrcweir 							getInterceptedURLs(  ) throw(::com::sun::star::uno::RuntimeException);
112cdf0e10cSrcweir 
113cdf0e10cSrcweir     // XDispatch
114cdf0e10cSrcweir     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);
115cdf0e10cSrcweir     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);
116cdf0e10cSrcweir     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);
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 	// extras
InitWaiter(SfxHelpWindow_Impl * pWindow)119cdf0e10cSrcweir 	void					InitWaiter( SfxHelpWindow_Impl* pWindow )
120cdf0e10cSrcweir 								{ m_pWindow = pWindow; }
GetHelpWindow() const121cdf0e10cSrcweir 	SfxHelpWindow_Impl*		GetHelpWindow() const { return m_pWindow; }
122cdf0e10cSrcweir };
123cdf0e10cSrcweir 
124cdf0e10cSrcweir // HelpListener_Impl -----------------------------------------------------
125cdf0e10cSrcweir 
126cdf0e10cSrcweir class HelpListener_Impl : public ::cppu::WeakImplHelper1< ::com::sun::star::frame::XStatusListener >
127cdf0e10cSrcweir {
128cdf0e10cSrcweir private:
129cdf0e10cSrcweir 	HelpInterceptor_Impl*	pInterceptor;
130cdf0e10cSrcweir 	Link					aChangeLink;
131cdf0e10cSrcweir 	String					aFactory;
132cdf0e10cSrcweir 
133cdf0e10cSrcweir public:
134cdf0e10cSrcweir 	HelpListener_Impl( HelpInterceptor_Impl* pInter );
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 	virtual void SAL_CALL	statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event )
137cdf0e10cSrcweir 								throw( ::com::sun::star::uno::RuntimeException );
138cdf0e10cSrcweir 	virtual void SAL_CALL	disposing( const ::com::sun::star::lang::EventObject& obj )
139cdf0e10cSrcweir 								throw( ::com::sun::star::uno::RuntimeException );
140cdf0e10cSrcweir 
SetChangeHdl(const Link & rLink)141cdf0e10cSrcweir 	void					SetChangeHdl( const Link& rLink ) { aChangeLink = rLink; }
GetFactory() const142cdf0e10cSrcweir 	String					GetFactory() const { return aFactory; }
143cdf0e10cSrcweir };
144cdf0e10cSrcweir // HelpStatusListener_Impl -----------------------------------------------------
145cdf0e10cSrcweir 
146cdf0e10cSrcweir class HelpStatusListener_Impl : public
147cdf0e10cSrcweir ::cppu::WeakImplHelper1< ::com::sun::star::frame::XStatusListener >
148cdf0e10cSrcweir {
149cdf0e10cSrcweir private:
150cdf0e10cSrcweir     ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatch > xDispatch;
151cdf0e10cSrcweir     ::com::sun::star::frame::FeatureStateEvent                              aStateEvent;
152cdf0e10cSrcweir 
153cdf0e10cSrcweir public:
154cdf0e10cSrcweir     HelpStatusListener_Impl(
155cdf0e10cSrcweir         ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatch > xDispatch,
156cdf0e10cSrcweir         com::sun::star::util::URL& rURL);
157cdf0e10cSrcweir     ~HelpStatusListener_Impl();
158cdf0e10cSrcweir 
159cdf0e10cSrcweir     virtual void SAL_CALL   statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event )
160cdf0e10cSrcweir 								throw( ::com::sun::star::uno::RuntimeException );
161cdf0e10cSrcweir 	virtual void SAL_CALL	disposing( const ::com::sun::star::lang::EventObject& obj )
162cdf0e10cSrcweir 								throw( ::com::sun::star::uno::RuntimeException );
163cdf0e10cSrcweir     const ::com::sun::star::frame::FeatureStateEvent&
GetStateEvent() const164cdf0e10cSrcweir                             GetStateEvent() const {return aStateEvent;}
165cdf0e10cSrcweir };
166cdf0e10cSrcweir 
167cdf0e10cSrcweir 
168cdf0e10cSrcweir #endif // #ifndef INCLUDED_SFX_HELPINTERCEPTOR_HXX
169cdf0e10cSrcweir 
170