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_OOX_OLE_VBAMODULE_HXX
21 #define INCLUDED_OOX_OLE_VBAMODULE_HXX
23 #include <com/sun/star/uno/Reference.hxx>
24 #include <rtl/textenc.h>
25 #include <rtl/ustring.hxx>
26 #include <sal/types.h>
29 namespace com::sun::star
{
30 namespace container
{ class XNameAccess
; }
31 namespace container
{ class XNameContainer
; }
32 namespace frame
{ class XModel
; }
33 namespace uno
{ class XComponentContext
; }
37 class BinaryInputStream
;
43 /** Stores, which key shortcut maps to which VBA macro method. */
44 struct VbaMacroKeyAndMethodBinding
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
50 // The name of the macro method
51 OUString msMethodName
;
58 const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
,
59 const css::uno::Reference
< css::frame::XModel
>& rxDocModel
,
61 rtl_TextEncoding eTextEnc
,
64 /** Returns the module type (com.sun.star.script.ModuleType constant). */
65 sal_Int32
getType() const { return mnType
; }
66 /** Sets the passed module type. */
67 void setType( sal_Int32 nType
) { mnType
= nType
; }
69 /** Returns the name of the module. */
70 const OUString
& getName() const { return maName
; }
71 /** Returns the stream name of the module. */
72 const OUString
& getStreamName() const { return maStreamName
; }
74 /** Imports all records for this module until the MODULEEND record. */
75 void importDirRecords( BinaryInputStream
& rDirStrm
);
77 /** Imports the VBA source code into the passed Basic library. */
78 void createAndImportModule(
79 StorageBase
& rVbaStrg
,
80 const css::uno::Reference
< css::container::XNameContainer
>& rxBasicLib
,
81 const css::uno::Reference
< css::container::XNameAccess
>& rxDocObjectNA
);
82 /** Creates an empty Basic module in the passed Basic library. */
83 void createEmptyModule(
84 const css::uno::Reference
< css::container::XNameContainer
>& rxBasicLib
,
85 const css::uno::Reference
< css::container::XNameAccess
>& rxDocObjectNA
) const;
87 void registerShortcutKeys();
90 /** Reads and returns the VBA source code from the passed storage. */
91 OUString
readSourceCode( StorageBase
& rVbaStrg
);
93 /** Creates a new Basic module and inserts it into the passed Basic library. */
95 std::u16string_view rVBASourceCode
,
96 const css::uno::Reference
< css::container::XNameContainer
>& rxBasicLib
,
97 const css::uno::Reference
< css::container::XNameAccess
>& rxDocObjectNA
) const;
100 css::uno::Reference
< css::uno::XComponentContext
>
101 mxContext
; ///< Component context with service manager.
102 css::uno::Reference
< css::frame::XModel
>
103 mxDocModel
; ///< Document model used to import/export the VBA project.
105 OUString maStreamName
;
106 OUString maDocString
;
107 rtl_TextEncoding meTextEnc
;
114 /** Keys and VBA macro method bindings */
115 std::vector
<VbaMacroKeyAndMethodBinding
> maKeyBindings
;
119 } // namespace oox::ole
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */