LibreOffice Module framework (master) 1
interceptionhelper.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <com/sun/star/frame/XDispatchProviderInterception.hpp>
23#include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
24#include <com/sun/star/frame/XDispatchProvider.hpp>
25#include <com/sun/star/frame/XDispatch.hpp>
26#include <com/sun/star/frame/XFrame.hpp>
27#include <com/sun/star/frame/DispatchDescriptor.hpp>
28
29#include <rtl/ref.hxx>
30#include <tools/wldcrd.hxx>
33
34#include <deque>
35#include <string_view>
36
37namespace framework{
38
39class DispatchProvider;
40
49class InterceptionHelper final : public ::cppu::WeakImplHelper<
50 css::frame::XDispatchProvider,
51 css::frame::XDispatchProviderInterception,
52 css::lang::XEventListener >
53{
54
55 // structs, helper
56
59 {
61 css::uno::Reference< css::frame::XDispatchProvider > xInterceptor;
62
69 css::uno::Sequence< OUString > lURLPattern;
70 };
71
78 class InterceptorList : public ::std::deque< InterceptorInfo >
79 {
80 public:
81
90 iterator findByReference(const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& xInterceptor)
91 {
92 iterator pIt;
93 for (pIt=begin(); pIt!=end(); ++pIt)
94 {
95 if (pIt->xInterceptor == xInterceptor)
96 return pIt;
97 }
98 return end();
99 }
100
109 iterator findByPattern(std::u16string_view sURL)
110 {
111 for (iterator pIt=begin(); pIt!=end(); ++pIt)
112 {
113 for (const OUString& pattern : pIt->lURLPattern)
114 {
115 WildCard aPattern(pattern);
116 if (aPattern.Matches(sURL))
117 return pIt;
118 }
119 }
120 return end();
121 }
122 };
123
124 // member
125
126 private:
127
131 css::uno::WeakReference< css::frame::XFrame > m_xOwnerWeak;
132
136
139
140 // native interface
141
142 public:
143
152 InterceptionHelper(const css::uno::Reference< css::frame::XFrame >& xOwner,
154
155 private:
156
163 virtual ~InterceptionHelper() override;
164
165 // uno interface
166
167 public:
168
169 // XDispatchProvider
170
191 virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch(const css::util::URL& aURL ,
192 const OUString& sTargetFrameName,
193 sal_Int32 nSearchFlags ) override;
194
195 // XDispatchProvider
196
208 virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches(const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptor) override;
209
210 // XDispatchProviderInterception
211
225 virtual void SAL_CALL registerDispatchProviderInterceptor(const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& xInterceptor) override;
226
227 // XDispatchProviderInterception
228
239 virtual void SAL_CALL releaseDispatchProviderInterceptor( const css::uno::Reference< css::frame::XDispatchProviderInterceptor >& xInterceptor ) override;
240
241 // XEventListener
242
248 virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) override;
249
251
252}; // class InterceptionHelper
253
254} // namespace framework
255
256/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool Matches(std::u16string_view rStr) const
implements a list of items of type InterceptorInfo, and provides some special functions on it.
iterator findByReference(const css::uno::Reference< css::frame::XDispatchProviderInterceptor > &xInterceptor)
search for an interceptor inside this list using it's reference.
iterator findByPattern(std::u16string_view sURL)
search for an interceptor inside this list using it's reference.
implements a helper to support interception with additional functionality.
virtual void SAL_CALL registerDispatchProviderInterceptor(const css::uno::Reference< css::frame::XDispatchProviderInterceptor > &xInterceptor) override
register an interceptor.
virtual void SAL_CALL releaseDispatchProviderInterceptor(const css::uno::Reference< css::frame::XDispatchProviderInterceptor > &xInterceptor) override
release an interceptor.
virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches(const css::uno::Sequence< css::frame::DispatchDescriptor > &lDescriptor) override
implements an optimized queryDispatch() for remote.
InterceptionHelper(const css::uno::Reference< css::frame::XFrame > &xOwner, rtl::Reference< DispatchProvider > xSlave)
creates a new interception helper instance.
css::uno::WeakReference< css::frame::XFrame > m_xOwnerWeak
reference to the frame, which uses this instance to implement its own interception.
rtl::Reference< DispatchProvider > GetSlave() const
InterceptorList m_lInterceptionRegs
contains all registered interceptor objects.
virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch(const css::util::URL &aURL, const OUString &sTargetFrameName, sal_Int32 nSearchFlags) override
query for a dispatch, which implements the requested feature.
virtual ~InterceptionHelper() override
standard destructor.
rtl::Reference< DispatchProvider > m_xSlave
this interception helper implements the top level master of an interceptor list .....
virtual void SAL_CALL disposing(const css::lang::EventObject &aEvent) override
Is called from our owner frame, in case he will be disposed.
enumrange< T >::Iterator begin(enumrange< T >)
end
bind an interceptor component to its URL pattern registration.
css::uno::Reference< css::frame::XDispatchProvider > xInterceptor
reference to the interceptor component.
css::uno::Sequence< OUString > lURLPattern
it's registration for URL patterns.