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 "service.hxx"
23 #include "vbaeventshelper.hxx"
24 #include <com/sun/star/script/ModuleType.hpp>
25 #include <com/sun/star/script/vba/VBAEventId.hpp>
27 
28 using namespace ::com::sun::star;
29 using namespace ::com::sun::star::script::vba::VBAEventId;
30 
31 SwVbaEventsHelper::SwVbaEventsHelper( uno::Sequence< css::uno::Any > const& aArgs, uno::Reference< uno::XComponentContext > const& /*xContext*/ ) :
32  VbaEventsHelperBase( aArgs )
33 {
34  using namespace ::com::sun::star::script::ModuleType;
35  registerEventHandler( DOCUMENT_NEW, DOCUMENT, "Document_New" );
36  registerEventHandler( AUTO_NEW, NORMAL, "AutoNew" );
37  registerEventHandler( DOCUMENT_OPEN, DOCUMENT, "Document_Open" );
38  registerEventHandler( AUTO_OPEN, NORMAL, "AutoOpen" );
39  registerEventHandler( DOCUMENT_CLOSE, DOCUMENT, "Document_Close" );
40  registerEventHandler( AUTO_CLOSE, NORMAL, "AutoClose" );
41 }
42 
44 {
45 }
46 
48  const EventHandlerInfo& rInfo, const uno::Sequence< uno::Any >& /*rArgs*/ )
49 {
50  switch( rInfo.mnEventId )
51  {
52  case DOCUMENT_NEW:
53  rEventQueue.emplace_back(AUTO_NEW );
54  break;
55  case DOCUMENT_OPEN:
56  rEventQueue.emplace_back(AUTO_OPEN );
57  break;
58  case DOCUMENT_CLOSE:
59  rEventQueue.emplace_back(AUTO_CLOSE );
60  break;
61  }
62  return true;
63 }
64 
65 uno::Sequence< uno::Any > SwVbaEventsHelper::implBuildArgumentList( const EventHandlerInfo& /*rInfo*/,
66  const uno::Sequence< uno::Any >& /*rArgs*/ )
67 {
68  // no event handler expects any arguments
69  return uno::Sequence< uno::Any >();
70 }
71 
73  const EventHandlerInfo& /*rInfo*/, bool /*bCancel*/ )
74 {
75  // nothing to do after any event
76 }
77 
78 OUString SwVbaEventsHelper::implGetDocumentModuleName( const EventHandlerInfo& /*rInfo*/,
79  const uno::Sequence< uno::Any >& /*rArgs*/ ) const
80 {
81  // TODO: get actual codename from document
82  return "ThisDocument";
83 }
84 
85 namespace vbaeventshelper
86 {
90  serviceImpl,
91  "SwVbaEventsHelper",
92  "com.sun.star.document.vba.VBATextEventProcessor" );
93 }
94 
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ~SwVbaEventsHelper() override
comphelper::service_decl::ServiceDecl const serviceDecl
sdecl::inheritingClass_< SwVbaEventsHelper, sdecl::with_args< true > > const serviceImpl
virtual void implPostProcessEvent(EventQueue &rEventQueue, const EventHandlerInfo &rInfo, bool bCancel) override
DOCUMENT
virtual css::uno::Sequence< css::uno::Any > implBuildArgumentList(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)
NORMAL
virtual OUString implGetDocumentModuleName(const EventHandlerInfo &rInfo, const css::uno::Sequence< css::uno::Any > &rArgs) const override
void registerEventHandler(sal_Int32 nEventId, sal_Int32 nModuleType, const char *pcMacroName, sal_Int32 nCancelIndex=-1, const css::uno::Any &rUserData=css::uno::Any())
::std::deque< EventQueueEntry > EventQueue
virtual bool implPrepareEvent(EventQueue &rEventQueue, const EventHandlerInfo &rInfo, const css::uno::Sequence< css::uno::Any > &rArgs) override