23#include <com/sun/star/frame/XInterceptorInfo.hpp>
24#include <com/sun/star/lang/DisposedException.hpp>
25#include <osl/diagnose.h>
36 : m_xOwnerWeak (xOwner )
37 , m_xSlave (
std::move(xSlave ))
46 const OUString& sTargetFrameName,
47 sal_Int32 nSearchFlags )
49 css::uno::Reference<css::frame::XDispatchProvider> xInterceptor;
58 xInterceptor = pIt->xInterceptor;
62 if (!xInterceptor.is())
66 if (!lInterceptionReg.lURLPattern.hasElements())
69 xInterceptor = lInterceptionReg.xInterceptor;
80 if (!xInterceptor.is() &&
m_xSlave.is())
85 css::uno::Reference< css::frame::XDispatch > xReturn;
86 if (xInterceptor.is())
87 xReturn = xInterceptor->queryDispatch(
aURL, sTargetFrameName, nSearchFlags);
91css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL
InterceptionHelper::queryDispatches(
const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptor )
93 sal_Int32 c = lDescriptor.getLength();
94 css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > lDispatches (c);
95 css::uno::Reference< css::frame::XDispatch >* pDispatches = lDispatches.getArray();
96 const css::frame::DispatchDescriptor* pDescriptor = lDescriptor.getConstArray();
98 for (sal_Int32
i=0;
i<c; ++
i)
99 pDispatches[
i] =
queryDispatch(pDescriptor[
i].FeatureURL, pDescriptor[
i].FrameName, pDescriptor[
i].SearchFlags);
107 css::uno::Reference< css::frame::XDispatchProvider > xThis(
this);
108 if (!xInterceptor.is())
109 throw css::uno::RuntimeException(
"NULL references not allowed as in parameter", xThis);
117 css::uno::Reference< css::frame::XInterceptorInfo > xInfo(xInterceptor, css::uno::UNO_QUERY);
131 xInterceptor->setMasterDispatchProvider(xThis );
132 xInterceptor->setSlaveDispatchProvider (
m_xSlave);
143 css::uno::Reference< css::frame::XDispatchProvider > xSlaveD =
m_lInterceptionRegs.begin()->xInterceptor;
144 css::uno::Reference< css::frame::XDispatchProviderInterceptor > xSlaveI (xSlaveD , css::uno::UNO_QUERY);
146 xInterceptor->setMasterDispatchProvider(xThis );
147 xInterceptor->setSlaveDispatchProvider (xSlaveD );
148 xSlaveI->setMasterDispatchProvider (aInfo.
xInterceptor);
153 css::uno::Reference< css::frame::XFrame > xOwner(
m_xOwnerWeak.get(), css::uno::UNO_QUERY);
161 xOwner->contextChanged();
167 css::uno::Reference< css::frame::XDispatchProvider > xThis(
this);
168 if (!xInterceptor.is())
169 throw css::uno::RuntimeException(
"NULL references not allowed as in parameter", xThis);
182 css::uno::Reference< css::frame::XDispatchProvider > xSlaveD = xInterceptor->getSlaveDispatchProvider();
183 css::uno::Reference< css::frame::XDispatchProvider > xMasterD = xInterceptor->getMasterDispatchProvider();
184 css::uno::Reference< css::frame::XDispatchProviderInterceptor > xSlaveI (xSlaveD , css::uno::UNO_QUERY);
185 css::uno::Reference< css::frame::XDispatchProviderInterceptor > xMasterI (xMasterD , css::uno::UNO_QUERY);
188 xMasterI->setSlaveDispatchProvider(xSlaveD);
194 xSlaveI->setMasterDispatchProvider(xMasterD);
196 catch (
const lang::DisposedException&)
199 "InterceptionHelper::releaseDispatchProviderInterceptor: "
200 "xSlaveI is disposed: ");
204 xInterceptor->setSlaveDispatchProvider (css::uno::Reference< css::frame::XDispatchProvider >());
205 xInterceptor->setMasterDispatchProvider(css::uno::Reference< css::frame::XDispatchProvider >());
210 css::uno::Reference< css::frame::XFrame > xOwner(
m_xOwnerWeak.get(), css::uno::UNO_QUERY);
218 xOwner->contextChanged();
221#define FORCE_DESTRUCTION_OF_INTERCEPTION_CHAIN
224 #ifdef FORCE_DESTRUCTION_OF_INTERCEPTION_CHAIN
229 css::uno::Reference< css::frame::XFrame > xOwner(
m_xOwnerWeak.get(), css::uno::UNO_QUERY);
230 if (
aEvent.Source != xOwner)
235 css::uno::Reference< css::frame::XDispatchProvider > xThis(
static_cast< ::
cppu::OWeakObject*
>(
this), css::uno::UNO_QUERY_THROW);
245 for (
auto & elem : aCopy)
247 if (elem.xInterceptor.is())
249 css::uno::Reference< css::frame::XDispatchProviderInterceptor > xInterceptor(elem.xInterceptor, css::uno::UNO_QUERY_THROW);
251 elem.xInterceptor.clear();
257 #if OSL_DEBUG_LEVEL > 0
261 OSL_FAIL(
"There are some pending interceptor objects, which seems to be registered during (!) the destruction of a frame.");
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.
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.
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.
#define TOOLS_WARN_EXCEPTION(area, stream)
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.