Line data Source code
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/ustring.hxx>
25 :
26 : namespace com { namespace sun { namespace star {
27 : namespace container { class XNameAccess; }
28 : namespace container { class XNameContainer; }
29 : namespace frame { class XModel; }
30 : namespace uno { class XComponentContext; }
31 : } } }
32 :
33 : namespace oox {
34 : class BinaryInputStream;
35 : class StorageBase;
36 : }
37 :
38 : namespace oox {
39 : namespace ole {
40 :
41 :
42 :
43 304 : class VbaModule
44 : {
45 : public:
46 : explicit VbaModule(
47 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
48 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxDocModel,
49 : const OUString& rName,
50 : rtl_TextEncoding eTextEnc,
51 : bool bExecutable );
52 :
53 : /** Returns the module type (com.sun.star.script.ModuleType constant). */
54 : sal_Int32 getType() const { return mnType; }
55 : /** Sets the passed module type. */
56 302 : void setType( sal_Int32 nType ) { mnType = nType; }
57 :
58 : /** Returns the name of the module. */
59 4 : const OUString& getName() const { return maName; }
60 : /** Returns the stream name of the module. */
61 304 : const OUString& getStreamName() const { return maStreamName; }
62 :
63 : /** Imports all records for this module until the MODULEEND record. */
64 : void importDirRecords( BinaryInputStream& rDirStrm );
65 :
66 : /** Imports the VBA source code into the passed Basic library. */
67 : void createAndImportModule(
68 : StorageBase& rVbaStrg,
69 : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib,
70 : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& rxDocObjectNA ) const;
71 : /** Creates an empty Basic module in the passed Basic library. */
72 : void createEmptyModule(
73 : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib,
74 : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& rxDocObjectNA ) const;
75 :
76 : private:
77 : /** Reads and returns the VBA source code from the passed storage. */
78 : OUString readSourceCode( StorageBase& rVbaStrg ) const;
79 :
80 : /** Creates a new Basic module and inserts it into the passed Basic library. */
81 : void createModule(
82 : const OUString& rVBASourceCode,
83 : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib,
84 : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& rxDocObjectNA ) const;
85 :
86 : private:
87 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
88 : mxContext; ///< Component context with service manager.
89 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
90 : mxDocModel; ///< Document model used to import/export the VBA project.
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;
99 : bool mbExecutable;
100 : };
101 :
102 :
103 :
104 : } // namespace ole
105 : } // namespace oox
106 :
107 : #endif
108 :
109 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|