LibreOffice Module oox (master) 1
vbamodule.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_OOX_OLE_VBAMODULE_HXX
21#define INCLUDED_OOX_OLE_VBAMODULE_HXX
22
23#include <com/sun/star/uno/Reference.hxx>
24#include <rtl/textenc.h>
25#include <rtl/ustring.hxx>
26#include <sal/types.h>
27#include <vector>
28
29namespace com::sun::star {
30 namespace container { class XNameAccess; }
31 namespace container { class XNameContainer; }
32 namespace frame { class XModel; }
33 namespace uno { class XComponentContext; }
34}
35
36namespace oox {
37 class BinaryInputStream;
38 class StorageBase;
39}
40
41namespace oox::ole {
42
45{
46 // This describes a key combination in "raw" VBA Macro form, that
47 // still needs translated to a key event that can be used in
48 // LibreOffice.
49 OUString msApiKey;
50 // The name of the macro method
51 OUString msMethodName;
52};
53
55{
56public:
57 explicit VbaModule(
58 const css::uno::Reference< css::uno::XComponentContext >& rxContext,
59 const css::uno::Reference< css::frame::XModel >& rxDocModel,
60 OUString aName,
61 rtl_TextEncoding eTextEnc,
62 bool bExecutable );
63
65 sal_Int32 getType() const { return mnType; }
67 void setType( sal_Int32 nType ) { mnType = nType; }
68
70 const OUString& getName() const { return maName; }
72 const OUString& getStreamName() const { return maStreamName; }
73
75 void importDirRecords( BinaryInputStream& rDirStrm );
76
79 StorageBase& rVbaStrg,
80 const css::uno::Reference< css::container::XNameContainer >& rxBasicLib,
81 const css::uno::Reference< css::container::XNameAccess >& rxDocObjectNA );
84 const css::uno::Reference< css::container::XNameContainer >& rxBasicLib,
85 const css::uno::Reference< css::container::XNameAccess >& rxDocObjectNA ) const;
86
88
89private:
91 OUString readSourceCode( StorageBase& rVbaStrg );
92
94 void createModule(
95 std::u16string_view rVBASourceCode,
96 const css::uno::Reference< css::container::XNameContainer >& rxBasicLib,
97 const css::uno::Reference< css::container::XNameAccess >& rxDocObjectNA ) const;
98
99private:
100 css::uno::Reference< css::uno::XComponentContext >
102 css::uno::Reference< css::frame::XModel >
104 OUString maName;
105 OUString maStreamName;
106 OUString maDocString;
107 rtl_TextEncoding meTextEnc;
108 sal_Int32 mnType;
109 sal_uInt32 mnOffset;
113
115 std::vector<VbaMacroKeyAndMethodBinding> maKeyBindings;
116};
117
118
119} // namespace oox::ole
120
121#endif
122
123/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Interface for binary input stream classes.
Base class for storage access implementations.
Definition: storagebase.hxx:52
css::uno::Reference< css::frame::XModel > mxDocModel
Document model used to import/export the VBA project.
Definition: vbamodule.hxx:103
void createAndImportModule(StorageBase &rVbaStrg, const css::uno::Reference< css::container::XNameContainer > &rxBasicLib, const css::uno::Reference< css::container::XNameAccess > &rxDocObjectNA)
Imports the VBA source code into the passed Basic library.
Definition: vbamodule.cxx:130
sal_uInt32 mnOffset
Definition: vbamodule.hxx:109
const OUString & getName() const
Returns the name of the module.
Definition: vbamodule.hxx:70
sal_Int32 getType() const
Returns the module type (com.sun.star.script.ModuleType constant).
Definition: vbamodule.hxx:65
const OUString & getStreamName() const
Returns the stream name of the module.
Definition: vbamodule.hxx:72
css::uno::Reference< css::uno::XComponentContext > mxContext
Component context with service manager.
Definition: vbamodule.hxx:101
rtl_TextEncoding meTextEnc
Definition: vbamodule.hxx:107
std::vector< VbaMacroKeyAndMethodBinding > maKeyBindings
Keys and VBA macro method bindings.
Definition: vbamodule.hxx:115
void setType(sal_Int32 nType)
Sets the passed module type.
Definition: vbamodule.hxx:67
void registerShortcutKeys()
Definition: vbamodule.cxx:139
void createModule(std::u16string_view rVBASourceCode, const css::uno::Reference< css::container::XNameContainer > &rxBasicLib, const css::uno::Reference< css::container::XNameAccess > &rxDocObjectNA) const
Creates a new Basic module and inserts it into the passed Basic library.
Definition: vbamodule.cxx:266
void importDirRecords(BinaryInputStream &rDirStrm)
Imports all records for this module until the MODULEEND record.
Definition: vbamodule.cxx:61
VbaModule(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::frame::XModel > &rxDocModel, OUString aName, rtl_TextEncoding eTextEnc, bool bExecutable)
Definition: vbamodule.cxx:46
void createEmptyModule(const css::uno::Reference< css::container::XNameContainer > &rxBasicLib, const css::uno::Reference< css::container::XNameAccess > &rxDocObjectNA) const
Creates an empty Basic module in the passed Basic library.
Definition: vbamodule.cxx:154
OUString readSourceCode(StorageBase &rVbaStrg)
Reads and returns the VBA source code from the passed storage.
Definition: vbamodule.cxx:160
OUString aName
QPRO_FUNC_TYPE nType
Stores, which key shortcut maps to which VBA macro method.
Definition: vbamodule.hxx:45