Avoid potential negative array index access to cached text.
[LibreOffice.git] / embedserv / source / inc / intercept.hxx
blob665f26aa82b9011a4212435777c78e9bad9eb720
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 .
20 #pragma once
22 #include <osl/mutex.hxx>
23 #include <cppuhelper/implbase.hxx>
24 #include <comphelper/multiinterfacecontainer3.hxx>
25 #include <comphelper/interfacecontainer2.hxx>
26 #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
27 #include <com/sun/star/frame/XInterceptorInfo.hpp>
28 #include <com/sun/star/frame/XDispatch.hpp>
30 #include <rtl/ref.hxx>
31 #include "embeddocaccess.hxx"
34 class EmbedDocument_Impl;
35 class DocumentHolder;
37 using StatusChangeListenerContainer = comphelper::OMultiTypeInterfaceContainerHelperVar3<css::frame::XStatusListener, OUString>;
39 class Interceptor
40 : public ::cppu::WeakImplHelper<
41 css::frame::XDispatchProviderInterceptor,
42 css::frame::XInterceptorInfo,
43 css::frame::XDispatch>
45 public:
47 Interceptor(
48 const ::rtl::Reference< EmbeddedDocumentInstanceAccess_Impl >& xOleAccess,
49 DocumentHolder* pDocH,
50 bool bLink );
52 ~Interceptor() override;
54 void DisconnectDocHolder();
56 void generateFeatureStateEvent();
58 // overwritten to release the statuslistener.
61 // XComponent
62 /// @throws css::uno::RuntimeException
63 virtual void
64 addEventListener(
65 const css::uno::Reference< css::lang::XEventListener >& xListener );
67 /// @throws css::uno::RuntimeException
68 virtual void
69 removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener );
71 /// @throws css::uno::RuntimeException
72 void
73 dispose();
76 //XDispatch
77 virtual void SAL_CALL
78 dispatch(
79 const css::util::URL& URL,
80 const css::uno::Sequence< css::beans::PropertyValue >& Arguments ) override;
82 virtual void SAL_CALL
83 addStatusListener(
84 const css::uno::Reference< css::frame::XStatusListener >& Control,
85 const css::util::URL& URL ) override;
87 virtual void SAL_CALL
88 removeStatusListener(
89 const css::uno::Reference< css::frame::XStatusListener >& Control,
90 const css::util::URL& URL ) override;
92 //XInterceptorInfo
93 virtual css::uno::Sequence< OUString >
94 SAL_CALL getInterceptedURLs( ) override;
97 //XDispatchProvider ( inherited by XDispatchProviderInterceptor )
98 virtual css::uno::Reference<
99 css::frame::XDispatch > SAL_CALL
100 queryDispatch(
101 const css::util::URL& URL,
102 const OUString& TargetFrameName,
103 sal_Int32 SearchFlags ) override;
105 virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL
106 queryDispatches(
107 const css::uno::Sequence<
108 css::frame::DispatchDescriptor >& Requests ) override;
111 //XDispatchProviderInterceptor
112 virtual css::uno::Reference< css::frame::XDispatchProvider > SAL_CALL
113 getSlaveDispatchProvider( ) override;
115 virtual void SAL_CALL
116 setSlaveDispatchProvider(
117 const css::uno::Reference< css::frame::XDispatchProvider >& NewDispatchProvider ) override;
119 virtual css::uno::Reference< css::frame::XDispatchProvider > SAL_CALL
120 getMasterDispatchProvider( ) override;
122 virtual void SAL_CALL
123 setMasterDispatchProvider(
124 const css::uno::Reference< css::frame::XDispatchProvider >& NewSupplier ) override;
127 private:
129 osl::Mutex m_aMutex;
131 ::rtl::Reference< EmbeddedDocumentInstanceAccess_Impl > m_xOleAccess;
133 css::uno::WeakReference< css::uno::XInterface > m_xDocHLocker;
134 DocumentHolder* m_pDocH;
136 css::uno::Reference< css::frame::XDispatchProvider > m_xSlaveDispatchProvider;
138 css::uno::Reference< css::frame::XDispatchProvider > m_xMasterDispatchProvider;
140 static const css::uno::Sequence< OUString > m_aInterceptedURL;
142 comphelper::OInterfaceContainerHelper2* m_pDisposeEventListeners;
143 StatusChangeListenerContainer* m_pStatCL;
145 bool m_bLink;
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */