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 
20 #ifndef INCLUDED_FORMS_SOURCE_INC_CONTROLFEATUREINTERCEPTION_HXX
21 #define INCLUDED_FORMS_SOURCE_INC_CONTROLFEATUREINTERCEPTION_HXX
22 
23 #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
24 #include <com/sun/star/uno/XComponentContext.hpp>
25 
26 #include <memory>
27 
28 #include "urltransformer.hxx"
29 
30 
31 namespace frm
32 {
33 
34 
35     class UrlTransformer;
36 
37     //= ControlFeatureInterception
38 
39     /** helper class for controls which allow some of their features to be intercepted
40         by external instances
41 
42         For using this class, instantiate it as member, derive yourself from
43         <type scope="css::frame">XDispatchProviderInterception</type>, and forward all
44         respective methods to this member.
45 
46         Additionally, don't forget to call <member>dispose</member> when your class is disposed itself.
47     */
48     class ControlFeatureInterception
49     {
50     private:
51         css::uno::Reference< css::frame::XDispatchProviderInterceptor >
52                                               m_xFirstDispatchInterceptor;
53         ::std::unique_ptr< UrlTransformer >   m_pUrlTransformer;
54 
55     public:
56         /** retrieves our URL transformer, so our clients may use it, too
57         */
58         const UrlTransformer& getTransformer() const { return *m_pUrlTransformer; }
59 
60     public:
61         ControlFeatureInterception( const css::uno::Reference< css::uno::XComponentContext >& _rxORB );
62 
63         // XDispatchProviderInterception
64         /// @throws css::uno::RuntimeException
65         void registerDispatchProviderInterceptor( const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& Interceptor );
66         /// @throws css::uno::RuntimeException
67         void releaseDispatchProviderInterceptor( const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& Interceptor );
68 
69         // XComponent
70         void dispose();
71 
72         /** queries the interceptor chain for the given dispatch, with a blank target frame and no frame search flags
73         */
74         css::uno::Reference< css::frame::XDispatch >
75             queryDispatch( const css::util::URL& _rURL );
76 
77         /** queries the interceptor chain for the URL given as ASCII string,
78             with a blank target frame and no frame search flags
79         */
80         css::uno::Reference< css::frame::XDispatch >
81             queryDispatch( const char* _pAsciiURL );
82     };
83 
84 
85 } // namespace frm
86 
87 
88 #endif // INCLUDED_FORMS_SOURCE_INC_CONTROLFEATUREINTERCEPTION_HXX
89 
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
91