Branch libreoffice-5-0-4
[LibreOffice.git] / sfx2 / source / appl / helpinterceptor.hxx
blobf5ce4bb9d1ace011bfcd0fd7ea7981fbd582fb62
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SFX2_SOURCE_APPL_HELPINTERCEPTOR_HXX
20 #define INCLUDED_SFX2_SOURCE_APPL_HELPINTERCEPTOR_HXX
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 <vcl/vclptr.hxx>
32 #include <vector>
34 struct HelpHistoryEntry_Impl
36 OUString aURL;
37 com::sun::star::uno::Any aViewData;
39 HelpHistoryEntry_Impl( const OUString& rURL, const com::sun::star::uno::Any& rViewData ) :
40 aURL( rURL ), aViewData(rViewData) {}
43 typedef ::std::vector< HelpHistoryEntry_Impl* > HelpHistoryList_Impl;
45 class SfxHelpWindow_Impl;
46 class HelpInterceptor_Impl : public ::cppu::WeakImplHelper3<
48 ::com::sun::star::frame::XDispatchProviderInterceptor,
49 ::com::sun::star::frame::XInterceptorInfo,
50 ::com::sun::star::frame::XDispatch >
53 private:
54 friend class HelpDispatch_Impl;
55 friend class SfxHelpWindow_Impl;
57 // the component which's dispatches we're intercepting
58 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception > m_xIntercepted;
60 // chaining
61 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > m_xSlaveDispatcher;
62 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > m_xMasterDispatcher;
64 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > m_xListener;
66 HelpHistoryList_Impl* m_pHistory;
67 VclPtr<SfxHelpWindow_Impl> m_pWindow;
68 sal_uIntPtr m_nCurPos;
69 OUString m_aCurrentURL;
70 com::sun::star::uno::Any m_aViewData;
72 void addURL( const OUString& rURL );
74 public:
75 HelpInterceptor_Impl();
76 virtual ~HelpInterceptor_Impl();
78 void setInterception( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame );
79 OUString GetCurrentURL() const { return m_aCurrentURL; }
83 const com::sun::star::uno::Any& GetViewData()const {return m_aViewData;}
85 bool HasHistoryPred() const; // is there a predecessor for the current in the history
86 bool HasHistorySucc() const; // is there a successor for the current in the history
88 // XDispatchProvider
89 virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL
90 queryDispatch( const ::com::sun::star::util::URL& aURL, const OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
91 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL
92 queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
94 // XDispatchProviderInterceptor
95 virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL
96 getSlaveDispatchProvider( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
97 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;
98 virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL
99 getMasterDispatchProvider( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
100 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;
102 // XInterceptorInfo
103 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL
104 getInterceptedURLs( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
106 // XDispatch
107 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;
108 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;
109 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;
111 // extras
112 void InitWaiter( SfxHelpWindow_Impl* pWindow )
113 { m_pWindow = pWindow; }
114 SfxHelpWindow_Impl* GetHelpWindow() const { return m_pWindow; }
117 // HelpListener_Impl -----------------------------------------------------
119 class HelpListener_Impl : public ::cppu::WeakImplHelper1< ::com::sun::star::frame::XStatusListener >
121 private:
122 HelpInterceptor_Impl* pInterceptor;
123 Link<> aChangeLink;
124 OUString aFactory;
126 public:
127 HelpListener_Impl( HelpInterceptor_Impl* pInter );
129 virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event )
130 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
131 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& obj )
132 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
134 void SetChangeHdl( const Link<>& rLink ) { aChangeLink = rLink; }
135 OUString GetFactory() const { return aFactory; }
137 // HelpStatusListener_Impl -----------------------------------------------------
139 class HelpStatusListener_Impl : public
140 ::cppu::WeakImplHelper1< ::com::sun::star::frame::XStatusListener >
142 private:
143 ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatch > xDispatch;
144 ::com::sun::star::frame::FeatureStateEvent aStateEvent;
146 public:
147 HelpStatusListener_Impl(
148 ::com::sun::star::uno::Reference < ::com::sun::star::frame::XDispatch > xDispatch,
149 com::sun::star::util::URL& rURL);
150 virtual ~HelpStatusListener_Impl();
152 virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event )
153 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
154 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& obj )
155 throw( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
156 const ::com::sun::star::frame::FeatureStateEvent&
157 GetStateEvent() const {return aStateEvent;}
161 #endif // INCLUDED_SFX2_SOURCE_APPL_HELPINTERCEPTOR_HXX
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */