LibreOffice Module sw (master) 1
vbaeventshelper.cxx
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#include <sal/config.h>
21
22#include "vbaeventshelper.hxx"
23#include <com/sun/star/script/ModuleType.hpp>
24#include <com/sun/star/script/vba/VBAEventId.hpp>
26
27using namespace ::com::sun::star;
28using namespace ::com::sun::star::script::vba::VBAEventId;
29
30SwVbaEventsHelper::SwVbaEventsHelper( uno::Sequence< css::uno::Any > const& aArgs, uno::Reference< uno::XComponentContext > const& /*xContext*/ ) :
31 VbaEventsHelperBase( aArgs )
32{
33 using namespace ::com::sun::star::script::ModuleType;
34 registerEventHandler( DOCUMENT_NEW, DOCUMENT, "Document_New" );
35 registerEventHandler( AUTO_NEW, NORMAL, "AutoNew" );
36 registerEventHandler( DOCUMENT_OPEN, DOCUMENT, "Document_Open" );
37 registerEventHandler( AUTO_OPEN, NORMAL, "AutoOpen" );
38 registerEventHandler( DOCUMENT_CLOSE, DOCUMENT, "Document_Close" );
39 registerEventHandler( AUTO_CLOSE, NORMAL, "AutoClose" );
40}
41
43{
44}
45
47 const EventHandlerInfo& /*rInfo*/, const uno::Sequence<uno::Any>& /*rArgs*/)
48{
49 return true;
50}
51
52uno::Sequence< uno::Any > SwVbaEventsHelper::implBuildArgumentList( const EventHandlerInfo& /*rInfo*/,
53 const uno::Sequence< uno::Any >& /*rArgs*/ )
54{
55 // no event handler expects any arguments
56 return uno::Sequence< uno::Any >();
57}
58
60 const EventHandlerInfo& /*rInfo*/, bool /*bCancel*/ )
61{
62 // nothing to do after any event
63}
64
65OUString SwVbaEventsHelper::implGetDocumentModuleName( const EventHandlerInfo& /*rInfo*/,
66 const uno::Sequence< uno::Any >& /*rArgs*/ ) const
67{
68 // TODO: get actual codename from document
69 return "ThisDocument";
70}
71
72 // XServiceInfo
74{
75 return "SwVbaEventsHelper";
76}
77sal_Bool SwVbaEventsHelper::supportsService( const OUString& ServiceName )
78{
80}
81css::uno::Sequence< OUString > SwVbaEventsHelper::getSupportedServiceNames()
82{
83 return { "com.sun.star.script.vba.VBATextEventProcessor" };
84}
85
86
87extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
89 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& args)
90{
91 return cppu::acquire(new SwVbaEventsHelper(args, context));
92}
93
94/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ~SwVbaEventsHelper() override
virtual css::uno::Sequence< css::uno::Any > implBuildArgumentList(const EventHandlerInfo &rInfo, const css::uno::Sequence< css::uno::Any > &rArgs) override
virtual OUString SAL_CALL getImplementationName() override
virtual OUString implGetDocumentModuleName(const EventHandlerInfo &rInfo, const css::uno::Sequence< css::uno::Any > &rArgs) const override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual bool implPrepareEvent(EventQueue &rEventQueue, const EventHandlerInfo &rInfo, const css::uno::Sequence< css::uno::Any > &rArgs) override
SwVbaEventsHelper(const css::uno::Sequence< css::uno::Any > &rArgs, const css::uno::Reference< css::uno::XComponentContext > &rxContext)
virtual void implPostProcessEvent(EventQueue &rEventQueue, const EventHandlerInfo &rInfo, bool bCancel) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
::std::deque< EventQueueEntry > EventQueue
void registerEventHandler(sal_Int32 nEventId, sal_Int32 nModuleType, const char *pcMacroName, sal_Int32 nCancelIndex=-1, const css::uno::Any &rUserData=css::uno::Any())
NORMAL
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
args
DOCUMENT
unsigned char sal_Bool
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * Writer_SwVbaEventsHelper_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &args)