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 #ifndef INCLUDED_SFX_HELPINTERCEPTOR_HXX
24 #define INCLUDED_SFX_HELPINTERCEPTOR_HXX
25 
26 #ifndef _CPPUHELPER_IMPLBASE2_HXX_
27 #include <cppuhelper/implbase3.hxx>
28 #endif
29 #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
30 #include <com/sun/star/frame/XInterceptorInfo.hpp>
31 #include <com/sun/star/frame/XDispatch.hpp>
32 #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
33 #include <com/sun/star/frame/XFrame.hpp>
34 #include <cppuhelper/implbase1.hxx>
35 #include <com/sun/star/frame/XStatusListener.hpp>
36 #include <tools/string.hxx>
37 #include <tools/list.hxx>
38 #include <tools/link.hxx>
39 
40 struct HelpHistoryEntry_Impl
41 {
42 	String	aURL;
43     com::sun::star::uno::Any    aViewData;
44 
HelpHistoryEntry_ImplHelpHistoryEntry_Impl45     HelpHistoryEntry_Impl( const String& rURL, const com::sun::star::uno::Any& rViewData ) :
46         aURL( rURL ), aViewData(rViewData) {}
47 };
48 
49 DECLARE_LIST(HelpHistoryList_Impl,HelpHistoryEntry_Impl*)
50 
51 class SfxHelpWindow_Impl;
52 class HelpInterceptor_Impl : public ::cppu::WeakImplHelper3<
53 
54 		::com::sun::star::frame::XDispatchProviderInterceptor,
55 		::com::sun::star::frame::XInterceptorInfo,
56 		::com::sun::star::frame::XDispatch >
57 
58 {
59 private:
60 friend class HelpDispatch_Impl;
61 friend class SfxHelpWindow_Impl;
62 
63 	// the component which's dispatches we're intercepting
64 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception > m_xIntercepted;
65 
66 	// chaining
67 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > m_xSlaveDispatcher;
68 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > m_xMasterDispatcher;
69 
70 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > m_xListener;
71 
72 	HelpHistoryList_Impl*		m_pHistory;
73 	SfxHelpWindow_Impl*			m_pWindow;
74 	sal_uIntPtr						m_nCurPos;
75 	String						m_aCurrentURL;
76     com::sun::star::uno::Any    m_aViewData;
77 
78 	void						addURL( const String& rURL );
79 
80 public:
81 	HelpInterceptor_Impl();
82 	~HelpInterceptor_Impl();
83 
84 	void 					setInterception( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame );
85 	void					SetStartURL( const String& rURL );
GetCurrentURL() const86 	String					GetCurrentURL() const { return m_aCurrentURL; }
87 
88 
89 
GetViewData() const90     const com::sun::star::uno::Any&     GetViewData()const {return m_aViewData;}
91 
92     sal_Bool                HasHistoryPred() const;     // is there a predecessor for the current in the history
93 	sal_Bool				HasHistorySucc() const;		// is there a successor for the current in the history
94 
95     // XDispatchProvider
96     virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL
97 							queryDispatch( const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw(::com::sun::star::uno::RuntimeException);
98     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL
99 							queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw(::com::sun::star::uno::RuntimeException);
100 
101 	// XDispatchProviderInterceptor
102     virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL
103 							getSlaveDispatchProvider(  ) throw(::com::sun::star::uno::RuntimeException);
104     virtual void SAL_CALL	setSlaveDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewSlave ) throw(::com::sun::star::uno::RuntimeException);
105     virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL
106 							getMasterDispatchProvider(  ) throw(::com::sun::star::uno::RuntimeException);
107     virtual void SAL_CALL	setMasterDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewMaster ) throw(::com::sun::star::uno::RuntimeException);
108 
109 	// XInterceptorInfo
110 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
111 							getInterceptedURLs(  ) throw(::com::sun::star::uno::RuntimeException);
112 
113     // XDispatch
114     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);
115     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);
116     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);
117 
118 	// extras
InitWaiter(SfxHelpWindow_Impl * pWindow)119 	void					InitWaiter( SfxHelpWindow_Impl* pWindow )
120 								{ m_pWindow = pWindow; }
GetHelpWindow() const121 	SfxHelpWindow_Impl*		GetHelpWindow() const { return m_pWindow; }
122 };
123 
124 // HelpListener_Impl -----------------------------------------------------
125 
126 class HelpListener_Impl : public ::cppu::WeakImplHelper1< ::com::sun::star::frame::XStatusListener >
127 {
128 private:
129 	HelpInterceptor_Impl*	pInterceptor;
130 	Link					aChangeLink;
131 	String					aFactory;
132 
133 public:
134 	HelpListener_Impl( HelpInterceptor_Impl* pInter );
135 
136 	virtual void SAL_CALL	statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event )
137 								throw( ::com::sun::star::uno::RuntimeException );
138 	virtual void SAL_CALL	disposing( const ::com::sun::star::lang::EventObject& obj )
139 								throw( ::com::sun::star::uno::RuntimeException );
140 
SetChangeHdl(const Link & rLink)141 	void					SetChangeHdl( const Link& rLink ) { aChangeLink = rLink; }
GetFactory() const142 	String					GetFactory() const { return aFactory; }
143 };
144 // HelpStatusListener_Impl -----------------------------------------------------
145 
146 class HelpStatusListener_Impl : public
147 ::cppu::WeakImplHelper1< ::com::sun::star::frame::XStatusListener >
148 {
149 private:
150     ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatch > xDispatch;
151     ::com::sun::star::frame::FeatureStateEvent                              aStateEvent;
152 
153 public:
154     HelpStatusListener_Impl(
155         ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatch > xDispatch,
156         com::sun::star::util::URL& rURL);
157     ~HelpStatusListener_Impl();
158 
159     virtual void SAL_CALL   statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event )
160 								throw( ::com::sun::star::uno::RuntimeException );
161 	virtual void SAL_CALL	disposing( const ::com::sun::star::lang::EventObject& obj )
162 								throw( ::com::sun::star::uno::RuntimeException );
163     const ::com::sun::star::frame::FeatureStateEvent&
GetStateEvent() const164                             GetStateEvent() const {return aStateEvent;}
165 };
166 
167 
168 #endif // #ifndef INCLUDED_SFX_HELPINTERCEPTOR_HXX
169 
170