LibreOffice Module sfx2 (master) 1
eventsupplier.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#ifndef INCLUDED_SFX2_SOURCE_INC_EVENTSUPPLIER_HXX
21#define INCLUDED_SFX2_SOURCE_INC_EVENTSUPPLIER_HXX
22
23#include <sal/types.h>
24
25#include <com/sun/star/document/DocumentEvent.hpp>
26#include <com/sun/star/container/XNameReplace.hpp>
27#include <com/sun/star/document/XDocumentEventListener.hpp>
28#include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
29#include <com/sun/star/uno/Reference.hxx>
30#include <com/sun/star/uno/Type.hxx>
32#include <mutex>
33#include <vector>
34
35namespace comphelper
36{
37 class NamedValueCollection;
38}
39
40class SfxObjectShell;
41class SvxMacro;
42
43
44class SfxEvents_Impl final : public ::cppu::WeakImplHelper< css::container::XNameReplace, css::document::XDocumentEventListener >
45{
46 css::uno::Sequence< OUString > maEventNames;
47 std::vector< css::uno::Sequence < css::beans::PropertyValue > > maEventData;
48 css::uno::Reference< css::document::XDocumentEventBroadcaster > mxBroadcaster;
49 std::mutex maMutex;
51
52public:
54 css::uno::Reference< css::document::XDocumentEventBroadcaster > const & xBroadcaster );
55 virtual ~SfxEvents_Impl() override;
56
57 // --- XNameReplace ---
58 virtual void SAL_CALL replaceByName( const OUString & aName, const css::uno::Any & aElement ) override;
59
60 // --- XNameAccess ( parent of XNameReplace ) ---
61 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
62 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
63 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
64
65 // --- XElementAccess ( parent of XNameAccess ) ---
66 virtual css::uno::Type SAL_CALL getElementType() override;
67 virtual sal_Bool SAL_CALL hasElements() override;
68
69 // --- ::document::XDocumentEventListener ---
70 virtual void SAL_CALL documentEventOccured(const css::document::DocumentEvent& aEvent) override;
71
72 // --- ::lang::XEventListener ---
73 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
74
75 // convert and normalize
76 static std::unique_ptr<SvxMacro> ConvertToMacro( const css::uno::Any& rElement, SfxObjectShell* pDoc );
77 static void NormalizeMacro( const css::uno::Any& rIn, css::uno::Any& rOut, SfxObjectShell* pDoc );
78 static void NormalizeMacro(
79 const ::comphelper::NamedValueCollection& i_eventDescriptor,
80 ::comphelper::NamedValueCollection& o_normalizedDescriptor,
81 SfxObjectShell* i_document );
82 static void Execute( css::uno::Sequence < css::beans::PropertyValue > const & aEventData, const css::document::DocumentEvent& aTrigger, SfxObjectShell* pDoc );
83
84private:
86 static bool isScriptURLAllowed(const OUString& aScriptURL);
87};
88
89#endif
90
91/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static std::unique_ptr< SvxMacro > ConvertToMacro(const css::uno::Any &rElement, SfxObjectShell *pDoc)
css::uno::Sequence< OUString > maEventNames
virtual ~SfxEvents_Impl() override
css::uno::Reference< css::document::XDocumentEventBroadcaster > mxBroadcaster
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
virtual void SAL_CALL replaceByName(const OUString &aName, const css::uno::Any &aElement) override
virtual sal_Bool SAL_CALL hasElements() override
SfxEvents_Impl(SfxObjectShell *pShell, css::uno::Reference< css::document::XDocumentEventBroadcaster > const &xBroadcaster)
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
virtual css::uno::Type SAL_CALL getElementType() override
virtual void SAL_CALL documentEventOccured(const css::document::DocumentEvent &aEvent) override
static void NormalizeMacro(const css::uno::Any &rIn, css::uno::Any &rOut, SfxObjectShell *pDoc)
std::vector< css::uno::Sequence< css::beans::PropertyValue > > maEventData
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
SfxObjectShell * mpObjShell
static bool isScriptURLAllowed(const OUString &aScriptURL)
Check if script URL whitelist exists, and if so, if current script url is part of it.
static void Execute(css::uno::Sequence< css::beans::PropertyValue > const &aEventData, const css::document::DocumentEvent &aTrigger, SfxObjectShell *pDoc)
std::mutex maMutex
unsigned char sal_Bool