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 
28 namespace com::sun::star {
29  namespace container { class XNameAccess; }
30  namespace container { class XNameContainer; }
31  namespace frame { class XModel; }
32  namespace uno { class XComponentContext; }
33 }
34 
35 namespace oox {
36  class BinaryInputStream;
37  class StorageBase;
38 }
39 
40 namespace oox::ole {
41 
42 
43 class VbaModule
44 {
45 public:
46  explicit VbaModule(
47  const css::uno::Reference< css::uno::XComponentContext >& rxContext,
48  const css::uno::Reference< css::frame::XModel >& rxDocModel,
49  const OUString& rName,
50  rtl_TextEncoding eTextEnc,
51  bool bExecutable );
52 
54  sal_Int32 getType() const { return mnType; }
56  void setType( sal_Int32 nType ) { mnType = nType; }
57 
59  const OUString& getName() const { return maName; }
61  const OUString& getStreamName() const { return maStreamName; }
62 
64  void importDirRecords( BinaryInputStream& rDirStrm );
65 
68  StorageBase& rVbaStrg,
69  const css::uno::Reference< css::container::XNameContainer >& rxBasicLib,
70  const css::uno::Reference< css::container::XNameAccess >& rxDocObjectNA ) const;
72  void createEmptyModule(
73  const css::uno::Reference< css::container::XNameContainer >& rxBasicLib,
74  const css::uno::Reference< css::container::XNameAccess >& rxDocObjectNA ) const;
75 
76 private:
78  OUString readSourceCode( StorageBase& rVbaStrg ) const;
79 
81  void createModule(
82  std::u16string_view rVBASourceCode,
83  const css::uno::Reference< css::container::XNameContainer >& rxBasicLib,
84  const css::uno::Reference< css::container::XNameAccess >& rxDocObjectNA ) const;
85 
86 private:
87  css::uno::Reference< css::uno::XComponentContext >
89  css::uno::Reference< css::frame::XModel >
91  OUString maName;
92  OUString maStreamName;
93  OUString maDocString;
94  rtl_TextEncoding meTextEnc;
95  sal_Int32 mnType;
96  sal_uInt32 mnOffset;
97  bool mbReadOnly;
98  bool mbPrivate;
100 };
101 
102 
103 } // namespace oox::ole
104 
105 #endif
106 
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
VbaModule(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::frame::XModel > &rxDocModel, const OUString &rName, rtl_TextEncoding eTextEnc, bool bExecutable)
Definition: vbamodule.cxx:44
const OUString & getName() const
Returns the name of the module.
Definition: vbamodule.hxx:59
OUString maDocString
Definition: vbamodule.hxx:93
css::uno::Reference< css::uno::XComponentContext > mxContext
Component context with service manager.
Definition: vbamodule.hxx:88
exports com.sun.star. container
exports com.sun.star. frame
void createAndImportModule(StorageBase &rVbaStrg, const css::uno::Reference< css::container::XNameContainer > &rxBasicLib, const css::uno::Reference< css::container::XNameAccess > &rxDocObjectNA) const
Imports the VBA source code into the passed Basic library.
Definition: vbamodule.cxx:128
css::uno::Reference< css::frame::XModel > mxDocModel
Document model used to import/export the VBA project.
Definition: vbamodule.hxx:90
Interface for binary input stream classes.
Base class for storage access implementations.
Definition: storagebase.hxx:51
OUString readSourceCode(StorageBase &rVbaStrg) const
Reads and returns the VBA source code from the passed storage.
Definition: vbamodule.cxx:142
rtl_TextEncoding meTextEnc
Definition: vbamodule.hxx:94
void setType(sal_Int32 nType)
Sets the passed module type.
Definition: vbamodule.hxx:56
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:255
void importDirRecords(BinaryInputStream &rDirStrm)
Imports all records for this module until the MODULEEND record.
Definition: vbamodule.cxx:59
OUString maStreamName
Definition: vbamodule.hxx:92
sal_Int32 getType() const
Returns the module type (com.sun.star.script.ModuleType constant).
Definition: vbamodule.hxx:54
const OUString & getStreamName() const
Returns the stream name of the module.
Definition: vbamodule.hxx:61
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:136
sal_uInt32 mnOffset
Definition: vbamodule.hxx:96