xref: /trunk/main/sfx2/source/appl/helpinterceptor.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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 );
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 );
100 
101     // XDispatchProviderInterceptor
102     virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL
103                             getSlaveDispatchProvider(  );
104     virtual void SAL_CALL   setSlaveDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewSlave );
105     virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL
106                             getMasterDispatchProvider(  );
107     virtual void SAL_CALL   setMasterDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewMaster );
108 
109     // XInterceptorInfo
110     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
111                             getInterceptedURLs(  );
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 );
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 );
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 );
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     virtual void SAL_CALL   disposing( const ::com::sun::star::lang::EventObject& obj );
138 
SetChangeHdl(const Link & rLink)139     void                    SetChangeHdl( const Link& rLink ) { aChangeLink = rLink; }
GetFactory() const140     String                  GetFactory() const { return aFactory; }
141 };
142 // HelpStatusListener_Impl -----------------------------------------------------
143 
144 class HelpStatusListener_Impl : public
145 ::cppu::WeakImplHelper1< ::com::sun::star::frame::XStatusListener >
146 {
147 private:
148     ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatch > xDispatch;
149     ::com::sun::star::frame::FeatureStateEvent                              aStateEvent;
150 
151 public:
152     HelpStatusListener_Impl(
153         ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatch > xDispatch,
154         com::sun::star::util::URL& rURL);
155     ~HelpStatusListener_Impl();
156 
157     virtual void SAL_CALL   statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event );
158     virtual void SAL_CALL   disposing( const ::com::sun::star::lang::EventObject& obj );
159     const ::com::sun::star::frame::FeatureStateEvent&
GetStateEvent() const160                             GetStateEvent() const {return aStateEvent;}
161 };
162 
163 
164 #endif // #ifndef INCLUDED_SFX_HELPINTERCEPTOR_HXX
165