LibreOffice Module oox (master) 1
vbaproject.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_VBAPROJECT_HXX
21#define INCLUDED_OOX_OLE_VBAPROJECT_HXX
22
23#include <functional>
24#include <map>
25#include <string_view>
26
27#include <com/sun/star/uno/Reference.hxx>
28#include <oox/dllapi.h>
29#include <oox/helper/refmap.hxx>
31#include <rtl/ustring.hxx>
32#include <sal/types.h>
33
34namespace com::sun::star {
35 namespace container { class XNameContainer; }
36 namespace frame { class XModel; }
37 namespace script { class XLibraryContainer; }
38 namespace script::vba { class XVBAMacroResolver; }
39 namespace uno { class XComponentContext; }
40 namespace uno { class XInterface; }
41 namespace io { class XInputStream; }
42}
43
44namespace oox {
45 class GraphicHelper;
46 class StorageBase;
47}
48
49namespace oox::ole {
50
51class VbaModule;
52
54{
55public:
56 explicit VbaFilterConfig(
57 const css::uno::Reference< css::uno::XComponentContext >& rxContext,
58 std::u16string_view rConfigCompName );
60
62 bool isImportVba() const;
64 bool isImportVbaExecutable() const;
66 bool isExportVba() const;
67
68private:
69 css::uno::Reference< css::uno::XInterface >
71};
72
73
92{
93public:
94 explicit VbaMacroAttacherBase( OUString aMacroName );
95 virtual ~VbaMacroAttacherBase();
96
99 void resolveAndAttachMacro(
100 const css::uno::Reference< css::script::vba::XVBAMacroResolver >& rxResolver );
101
102private:
105 virtual void attachMacro( const OUString& rScriptUrl ) = 0;
106
107private:
108 OUString maMacroName;
109};
110
111typedef std::shared_ptr< VbaMacroAttacherBase > VbaMacroAttacherRef;
112
113
115{
116public:
117 explicit VbaProject(
118 const css::uno::Reference< css::uno::XComponentContext >& rxContext,
119 const css::uno::Reference< css::frame::XModel >& rxDocModel,
120 std::u16string_view rConfigCompName );
121 virtual ~VbaProject();
122
127 void importVbaProject(
128 StorageBase& rVbaPrjStrg,
129 const GraphicHelper& rGraphicHelper );
130
131 bool importVbaProject(
132 StorageBase& rVbaPrjStrg );
133
135 void importVbaData(const css::uno::Reference<css::io::XInputStream>& xInputStream);
136
138 void readVbaModules( StorageBase& rVbaPrjStrg );
141 void importModulesAndForms( StorageBase& rVbaPrjStrg, const GraphicHelper& rGraphicHelper );
144 void registerMacroAttacher( const VbaMacroAttacherRef& rxAttacher );
145
147 void attachMacros();
148
149 void setOleOverridesSink( css::uno::Reference< css::container::XNameContainer > const & rxOleOverridesSink ){ mxOleOverridesSink = rxOleOverridesSink; }
150
151protected:
154 void addDummyModule( const OUString& rName, sal_Int32 nType );
155
157 virtual void prepareImport();
158
159private:
160 VbaProject( const VbaProject& ) = delete;
161 VbaProject& operator=( const VbaProject& ) = delete;
162
164 css::uno::Reference< css::script::XLibraryContainer >
165 getLibraryContainer( sal_Int32 nPropId );
167 css::uno::Reference< css::container::XNameContainer >
168 openLibrary( sal_Int32 nPropId );
170 css::uno::Reference< css::container::XNameContainer > const &
171 createBasicLibrary();
173 css::uno::Reference< css::container::XNameContainer > const &
174 createDialogLibrary();
175
177 void importVba(
178 StorageBase& rVbaPrjStrg,
179 const GraphicHelper& rGraphicHelper );
180
182 void copyStorage( StorageBase& rVbaPrjStrg );
183
184private:
186 typedef ::std::map< OUString, sal_Int32 > DummyModuleMap;
187
188 css::uno::Reference< css::uno::XComponentContext >
190 css::uno::Reference< css::frame::XModel >
192 css::uno::Reference< css::container::XNameContainer >
194 css::uno::Reference< css::container::XNameContainer >
198 OUString maPrjName;
199 css::uno::Reference< css::container::XNameContainer >
204};
205
206
207} // namespace oox::ole
208
209#endif
210
211/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int16 script
Provides helper functions for colors, device measurement conversion, graphics, and graphic objects ha...
Base class for storage access implementations.
Definition: storagebase.hxx:52
VbaFilterConfig(const css::uno::Reference< css::uno::XComponentContext > &rxContext, std::u16string_view rConfigCompName)
Definition: vbaproject.cxx:84
css::uno::Reference< css::uno::XInterface > mxConfigAccess
Definition: vbaproject.hxx:70
bool isExportVba() const
Returns true, if the VBA source code and forms should be exported.
Definition: vbaproject.cxx:114
bool isImportVba() const
Returns true, if the VBA source code and forms should be imported.
Definition: vbaproject.cxx:104
bool isImportVbaExecutable() const
Returns true, if the VBA source code should be imported executable.
Definition: vbaproject.cxx:109
Base class for objects that attach a macro to a specific action.
Definition: vbaproject.hxx:92
virtual void attachMacro(const OUString &rScriptUrl)=0
Called after the VBA project has been imported.
css::uno::Reference< css::uno::XComponentContext > mxContext
Component context with service manager.
Definition: vbaproject.hxx:189
VbaProject(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::frame::XModel > &rxDocModel, std::u16string_view rConfigCompName)
DummyModuleMap maDummyModules
Additional empty modules created on import.
Definition: vbaproject.hxx:197
OUString maPrjName
Name of the VBA project.
Definition: vbaproject.hxx:198
::std::map< OUString, sal_Int32 > DummyModuleMap
Definition: vbaproject.hxx:186
VbaProject(const VbaProject &)=delete
VbaProject & operator=(const VbaProject &)=delete
css::uno::Reference< css::container::XNameContainer > mxBasicLib
The Basic library of the document used for import.
Definition: vbaproject.hxx:193
css::uno::Reference< css::container::XNameContainer > mxDialogLib
The dialog library of the document used for import.
Definition: vbaproject.hxx:195
VbaModuleMap maModulesByStrm
Definition: vbaproject.hxx:203
css::uno::Reference< css::frame::XModel > mxDocModel
Document model used to import/export the VBA project.
Definition: vbaproject.hxx:191
MacroAttacherVector maMacroAttachers
Objects that want to attach a VBA macro to an action.
Definition: vbaproject.hxx:196
void setOleOverridesSink(css::uno::Reference< css::container::XNameContainer > const &rxOleOverridesSink)
Definition: vbaproject.hxx:149
RefVector< VbaMacroAttacherBase > MacroAttacherVector
Definition: vbaproject.hxx:185
css::uno::Reference< css::container::XNameContainer > mxOleOverridesSink
Definition: vbaproject.hxx:200
RefMap< OUString, VbaModule > VbaModuleMap
Definition: vbaproject.hxx:201
VbaModuleMap maModules
Definition: vbaproject.hxx:202
#define OOX_DLLPUBLIC
Definition: dllapi.h:28
std::shared_ptr< VbaMacroAttacherBase > VbaMacroAttacherRef
Definition: vbaproject.hxx:111