1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef INCLUDED_SFX_HELPINTERCEPTOR_HXX
28 #define INCLUDED_SFX_HELPINTERCEPTOR_HXX
29 
30 #ifndef _CPPUHELPER_IMPLBASE2_HXX_
31 #include <cppuhelper/implbase3.hxx>
32 #endif
33 #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
34 #include <com/sun/star/frame/XInterceptorInfo.hpp>
35 #include <com/sun/star/frame/XDispatch.hpp>
36 #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
37 #include <com/sun/star/frame/XFrame.hpp>
38 #include <cppuhelper/implbase1.hxx>
39 #include <com/sun/star/frame/XStatusListener.hpp>
40 #include <tools/string.hxx>
41 #include <tools/list.hxx>
42 #include <tools/link.hxx>
43 
44 struct HelpHistoryEntry_Impl
45 {
46 	String	aURL;
47     com::sun::star::uno::Any    aViewData;
48 
49     HelpHistoryEntry_Impl( const String& rURL, const com::sun::star::uno::Any& rViewData ) :
50         aURL( rURL ), aViewData(rViewData) {}
51 };
52 
53 DECLARE_LIST(HelpHistoryList_Impl,HelpHistoryEntry_Impl*)
54 
55 class SfxHelpWindow_Impl;
56 class HelpInterceptor_Impl : public ::cppu::WeakImplHelper3<
57 
58 		::com::sun::star::frame::XDispatchProviderInterceptor,
59 		::com::sun::star::frame::XInterceptorInfo,
60 		::com::sun::star::frame::XDispatch >
61 
62 {
63 private:
64 friend class HelpDispatch_Impl;
65 friend class SfxHelpWindow_Impl;
66 
67 	// the component which's dispatches we're intercepting
68 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception > m_xIntercepted;
69 
70 	// chaining
71 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > m_xSlaveDispatcher;
72 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > m_xMasterDispatcher;
73 
74 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > m_xListener;
75 
76 	HelpHistoryList_Impl*		m_pHistory;
77 	SfxHelpWindow_Impl*			m_pWindow;
78 	sal_uIntPtr						m_nCurPos;
79 	String						m_aCurrentURL;
80     com::sun::star::uno::Any    m_aViewData;
81 
82 	void						addURL( const String& rURL );
83 
84 public:
85 	HelpInterceptor_Impl();
86 	~HelpInterceptor_Impl();
87 
88 	void 					setInterception( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame );
89 	void					SetStartURL( const String& rURL );
90 	String					GetCurrentURL() const { return m_aCurrentURL; }
91 
92 
93 
94     const com::sun::star::uno::Any&     GetViewData()const {return m_aViewData;}
95 
96     sal_Bool                HasHistoryPred() const;     // is there a predecessor for the current in the history
97 	sal_Bool				HasHistorySucc() const;		// is there a successor for the current in the history
98 
99     // XDispatchProvider
100     virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL
101 							queryDispatch( const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw(::com::sun::star::uno::RuntimeException);
102     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL
103 							queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw(::com::sun::star::uno::RuntimeException);
104 
105 	// XDispatchProviderInterceptor
106     virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL
107 							getSlaveDispatchProvider(  ) throw(::com::sun::star::uno::RuntimeException);
108     virtual void SAL_CALL	setSlaveDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewSlave ) throw(::com::sun::star::uno::RuntimeException);
109     virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL
110 							getMasterDispatchProvider(  ) throw(::com::sun::star::uno::RuntimeException);
111     virtual void SAL_CALL	setMasterDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewMaster ) throw(::com::sun::star::uno::RuntimeException);
112 
113 	// XInterceptorInfo
114 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
115 							getInterceptedURLs(  ) throw(::com::sun::star::uno::RuntimeException);
116 
117     // XDispatch
118     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);
119     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);
120     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);
121 
122 	// extras
123 	void					InitWaiter( SfxHelpWindow_Impl* pWindow )
124 								{ m_pWindow = pWindow; }
125 	SfxHelpWindow_Impl*		GetHelpWindow() const { return m_pWindow; }
126 };
127 
128 // HelpListener_Impl -----------------------------------------------------
129 
130 class HelpListener_Impl : public ::cppu::WeakImplHelper1< ::com::sun::star::frame::XStatusListener >
131 {
132 private:
133 	HelpInterceptor_Impl*	pInterceptor;
134 	Link					aChangeLink;
135 	String					aFactory;
136 
137 public:
138 	HelpListener_Impl( HelpInterceptor_Impl* pInter );
139 
140 	virtual void SAL_CALL	statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event )
141 								throw( ::com::sun::star::uno::RuntimeException );
142 	virtual void SAL_CALL	disposing( const ::com::sun::star::lang::EventObject& obj )
143 								throw( ::com::sun::star::uno::RuntimeException );
144 
145 	void					SetChangeHdl( const Link& rLink ) { aChangeLink = rLink; }
146 	String					GetFactory() const { return aFactory; }
147 };
148 // HelpStatusListener_Impl -----------------------------------------------------
149 
150 class HelpStatusListener_Impl : public
151 ::cppu::WeakImplHelper1< ::com::sun::star::frame::XStatusListener >
152 {
153 private:
154     ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatch > xDispatch;
155     ::com::sun::star::frame::FeatureStateEvent                              aStateEvent;
156 
157 public:
158     HelpStatusListener_Impl(
159         ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatch > xDispatch,
160         com::sun::star::util::URL& rURL);
161     ~HelpStatusListener_Impl();
162 
163     virtual void SAL_CALL   statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event )
164 								throw( ::com::sun::star::uno::RuntimeException );
165 	virtual void SAL_CALL	disposing( const ::com::sun::star::lang::EventObject& obj )
166 								throw( ::com::sun::star::uno::RuntimeException );
167     const ::com::sun::star::frame::FeatureStateEvent&
168                             GetStateEvent() const {return aStateEvent;}
169 };
170 
171 
172 #endif // #ifndef INCLUDED_SFX_HELPINTERCEPTOR_HXX
173 
174