Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / framework / source / inc / dispatch / dispatchdisabler.hxx
blob662eeb5d7c2d753fd143379dd689236fa0ca953b
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/.
8 */
9 #pragma once
11 #include <set>
13 #include <cppuhelper/implbase.hxx>
15 #include <com/sun/star/lang/XServiceInfo.hpp>
16 #include <com/sun/star/lang/XInitialization.hpp>
17 #include <com/sun/star/uno/XComponentContext.hpp>
18 #include <com/sun/star/container/XNameContainer.hpp>
19 #include <com/sun/star/frame/XDispatch.hpp>
20 #include <com/sun/star/frame/XInterceptorInfo.hpp>
21 #include <com/sun/star/frame/XDispatchProvider.hpp>
22 #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
24 namespace framework {
26 /**
27 * Implementation of a service to make it easy to disable a whole
28 * suite of UNO commands in a batch - and have that act in-process.
30 * Often external re-use of LibreOffice wants a very cut-down set
31 * of functionality included, and disabling elements remotely one
32 * by one performs poorly.
34 class DispatchDisabler final : public ::cppu::WeakImplHelper<
35 css::lang::XInitialization,
36 css::container::XNameContainer,
37 css::frame::XDispatchProviderInterceptor,
38 css::frame::XInterceptorInfo,
39 css::lang::XServiceInfo >
41 std::set<OUString> maDisabledURLs;
42 css::uno::Reference< css::frame::XDispatchProvider > mxSlave;
43 css::uno::Reference< css::frame::XDispatchProvider > mxMaster;
44 public:
45 DispatchDisabler(const css::uno::Reference< css::uno::XComponentContext >& rxContext);
47 // XInitialization
48 virtual void SAL_CALL initialize( const ::css::uno::Sequence< ::css::uno::Any >& aArguments ) override;
50 // XDispatchProvider
51 virtual ::css::uno::Reference< ::css::frame::XDispatch > SAL_CALL
52 queryDispatch( const ::css::util::URL& URL,
53 const OUString& TargetFrameName,
54 ::sal_Int32 SearchFlags ) override;
55 virtual ::css::uno::Sequence< ::css::uno::Reference< ::css::frame::XDispatch > > SAL_CALL
56 queryDispatches( const ::css::uno::Sequence< ::css::frame::DispatchDescriptor >& Requests ) override;
58 // XDispatchProviderInterceptor
59 virtual ::css::uno::Reference< ::css::frame::XDispatchProvider > SAL_CALL
60 getSlaveDispatchProvider() override;
61 virtual void SAL_CALL
62 setSlaveDispatchProvider( const ::css::uno::Reference< ::css::frame::XDispatchProvider >& NewDispatchProvider ) override;
63 virtual ::css::uno::Reference< ::css::frame::XDispatchProvider > SAL_CALL
64 getMasterDispatchProvider() override;
65 virtual void SAL_CALL
66 setMasterDispatchProvider( const ::css::uno::Reference< ::css::frame::XDispatchProvider >& NewSupplier ) override;
68 // XInterceptorInfo
69 virtual ::css::uno::Sequence< OUString > SAL_CALL
70 getInterceptedURLs() override;
72 // XElementAccess
73 virtual ::css::uno::Type SAL_CALL getElementType() override;
74 virtual ::sal_Bool SAL_CALL hasElements() override;
76 // XNameAccess
77 virtual ::css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
78 virtual ::css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
79 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
81 // XNameReplace
82 virtual void SAL_CALL replaceByName( const OUString& aName, const ::css::uno::Any& aElement ) override;
84 // XNameContainer
85 virtual void SAL_CALL insertByName( const OUString& aName, const ::css::uno::Any& aElement ) override;
86 virtual void SAL_CALL removeByName( const OUString& Name ) override;
88 /* interface XServiceInfo */
89 virtual OUString SAL_CALL getImplementationName() override;
90 virtual sal_Bool SAL_CALL supportsService( const OUString& sServiceName ) override;
91 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
94 } // namespace framework
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */