1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #ifndef INCLUDED_SFX2_SOURCE_INC_EVENTSUPPLIER_HXX
21 #define INCLUDED_SFX2_SOURCE_INC_EVENTSUPPLIER_HXX
23 #include <sal/types.h>
25 #include <com/sun/star/document/DocumentEvent.hpp>
26 #include <com/sun/star/container/XNameReplace.hpp>
27 #include <com/sun/star/document/XEventListener.hpp>
28 #include <com/sun/star/document/XEventBroadcaster.hpp>
29 #include <com/sun/star/uno/Reference.hxx>
30 #include <com/sun/star/uno/Type.hxx>
31 #include <cppuhelper/implbase.hxx>
35 class NamedValueCollection
;
42 class SfxEvents_Impl
: public ::cppu::WeakImplHelper
< css::container::XNameReplace
, css::document::XEventListener
>
44 css::uno::Sequence
< OUString
> maEventNames
;
45 css::uno::Sequence
< css::uno::Any
> maEventData
;
46 css::uno::Reference
< css::document::XEventBroadcaster
> mxBroadcaster
;
48 SfxObjectShell
*mpObjShell
;
51 SfxEvents_Impl( SfxObjectShell
* pShell
,
52 css::uno::Reference
< css::document::XEventBroadcaster
> const & xBroadcaster
);
53 virtual ~SfxEvents_Impl() override
;
55 // --- XNameReplace ---
56 virtual void SAL_CALL
replaceByName( const OUString
& aName
, const css::uno::Any
& aElement
) override
;
58 // --- XNameAccess ( parent of XNameReplace ) ---
59 virtual css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
60 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames() override
;
61 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
63 // --- XElementAccess ( parent of XNameAccess ) ---
64 virtual css::uno::Type SAL_CALL
getElementType() override
;
65 virtual sal_Bool SAL_CALL
hasElements() override
;
67 // --- ::document::XEventListener ---
68 virtual void SAL_CALL
notifyEvent( const css::document::EventObject
& aEvent
) override
;
70 // --- ::lang::XEventListener ---
71 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
73 // convert and normalize
74 static std::unique_ptr
<SvxMacro
> ConvertToMacro( const css::uno::Any
& rElement
, SfxObjectShell
* pDoc
);
75 static void NormalizeMacro( const css::uno::Any
& rIn
, css::uno::Any
& rOut
, SfxObjectShell
* pDoc
);
76 static void NormalizeMacro(
77 const ::comphelper::NamedValueCollection
& i_eventDescriptor
,
78 ::comphelper::NamedValueCollection
& o_normalizedDescriptor
,
79 SfxObjectShell
* i_document
);
80 static void Execute( css::uno::Any
const & aEventData
, const css::document::DocumentEvent
& aTrigger
, SfxObjectShell
* pDoc
);
83 /// Check if script URL whitelist exists, and if so, if current script url is part of it
84 static bool isScriptURLAllowed(const OUString
& aScriptURL
);
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */