Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef INCLUDED_SFX2_SOURCE_APPL_HELPINTERCEPTOR_HXX
20 : #define INCLUDED_SFX2_SOURCE_APPL_HELPINTERCEPTOR_HXX
21 :
22 : #include <cppuhelper/implbase3.hxx>
23 : #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
24 : #include <com/sun/star/frame/XInterceptorInfo.hpp>
25 : #include <com/sun/star/frame/XDispatch.hpp>
26 : #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
27 : #include <com/sun/star/frame/XFrame.hpp>
28 : #include <cppuhelper/implbase1.hxx>
29 : #include <com/sun/star/frame/XStatusListener.hpp>
30 : #include <tools/link.hxx>
31 : #include <vector>
32 :
33 0 : struct HelpHistoryEntry_Impl
34 : {
35 : OUString aURL;
36 : com::sun::star::uno::Any aViewData;
37 :
38 0 : HelpHistoryEntry_Impl( const OUString& rURL, const com::sun::star::uno::Any& rViewData ) :
39 0 : aURL( rURL ), aViewData(rViewData) {}
40 : };
41 :
42 : typedef ::std::vector< HelpHistoryEntry_Impl* > HelpHistoryList_Impl;
43 :
44 : class SfxHelpWindow_Impl;
45 : class HelpInterceptor_Impl : public ::cppu::WeakImplHelper3<
46 :
47 : ::com::sun::star::frame::XDispatchProviderInterceptor,
48 : ::com::sun::star::frame::XInterceptorInfo,
49 : ::com::sun::star::frame::XDispatch >
50 :
51 : {
52 : private:
53 : friend class HelpDispatch_Impl;
54 : friend class SfxHelpWindow_Impl;
55 :
56 : // the component which's dispatches we're intercepting
57 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception > m_xIntercepted;
58 :
59 : // chaining
60 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > m_xSlaveDispatcher;
61 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > m_xMasterDispatcher;
62 :
63 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > m_xListener;
64 :
65 : HelpHistoryList_Impl* m_pHistory;
66 : SfxHelpWindow_Impl* m_pWindow;
67 : sal_uIntPtr m_nCurPos;
68 : OUString m_aCurrentURL;
69 : com::sun::star::uno::Any m_aViewData;
70 :
71 : void addURL( const OUString& rURL );
72 :
73 : public:
74 : HelpInterceptor_Impl();
75 : virtual ~HelpInterceptor_Impl();
76 :
77 : void setInterception( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame );
78 0 : OUString GetCurrentURL() const { return m_aCurrentURL; }
79 :
80 :
81 :
82 0 : const com::sun::star::uno::Any& GetViewData()const {return m_aViewData;}
83 :
84 : bool HasHistoryPred() const; // is there a predecessor for the current in the history
85 : bool HasHistorySucc() const; // is there a successor for the current in the history
86 :
87 : // XDispatchProvider
88 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL
89 : queryDispatch( const ::com::sun::star::util::URL& aURL, const OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
90 : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL
91 : queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
92 :
93 : // XDispatchProviderInterceptor
94 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL
95 : getSlaveDispatchProvider( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
96 : virtual void SAL_CALL setSlaveDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewSlave ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
97 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL
98 : getMasterDispatchProvider( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
99 : virtual void SAL_CALL setMasterDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewMaster ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
100 :
101 : // XInterceptorInfo
102 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL
103 : getInterceptedURLs( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
104 :
105 : // XDispatch
106 : 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;
107 : 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;
108 : 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;
109 :
110 : // extras
111 0 : void InitWaiter( SfxHelpWindow_Impl* pWindow )
112 0 : { m_pWindow = pWindow; }
113 0 : SfxHelpWindow_Impl* GetHelpWindow() const { return m_pWindow; }
114 : };
115 :
116 : // HelpListener_Impl -----------------------------------------------------
117 :
118 0 : class HelpListener_Impl : public ::cppu::WeakImplHelper1< ::com::sun::star::frame::XStatusListener >
119 : {
120 : private:
121 : HelpInterceptor_Impl* pInterceptor;
122 : Link aChangeLink;
123 : OUString aFactory;
124 :
125 : public:
126 : HelpListener_Impl( HelpInterceptor_Impl* pInter );
127 :
128 : virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event )
129 : throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
130 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& obj )
131 : throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
132 :
133 0 : void SetChangeHdl( const Link& rLink ) { aChangeLink = rLink; }
134 0 : OUString GetFactory() const { return aFactory; }
135 : };
136 : // HelpStatusListener_Impl -----------------------------------------------------
137 :
138 : class HelpStatusListener_Impl : public
139 : ::cppu::WeakImplHelper1< ::com::sun::star::frame::XStatusListener >
140 : {
141 : private:
142 : ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatch > xDispatch;
143 : ::com::sun::star::frame::FeatureStateEvent aStateEvent;
144 :
145 : public:
146 : HelpStatusListener_Impl(
147 : ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatch > xDispatch,
148 : com::sun::star::util::URL& rURL);
149 : virtual ~HelpStatusListener_Impl();
150 :
151 : virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event )
152 : throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
153 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& obj )
154 : throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
155 : const ::com::sun::star::frame::FeatureStateEvent&
156 0 : GetStateEvent() const {return aStateEvent;}
157 : };
158 :
159 :
160 : #endif // INCLUDED_SFX2_SOURCE_APPL_HELPINTERCEPTOR_HXX
161 :
162 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|