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>
30 #include <oox/helper/refvector.hxx>
31 #include <rtl/ustring.hxx>
32 #include <sal/types.h>
33 
34 namespace 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 
44 namespace oox {
45  class GraphicHelper;
46  class StorageBase;
47 }
48 
49 namespace oox::ole {
50 
51 class VbaModule;
52 
54 {
55 public:
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 
68 private:
69  css::uno::Reference< css::uno::XInterface >
71 };
72 
73 
92 {
93 public:
94  explicit VbaMacroAttacherBase( const OUString& rMacroName );
95  virtual ~VbaMacroAttacherBase();
96 
99  void resolveAndAttachMacro(
100  const css::uno::Reference< css::script::vba::XVBAMacroResolver >& rxResolver );
101 
102 private:
105  virtual void attachMacro( const OUString& rScriptUrl ) = 0;
106 
107 private:
108  OUString maMacroName;
109 };
110 
111 typedef std::shared_ptr< VbaMacroAttacherBase > VbaMacroAttacherRef;
112 
113 
115 {
116 public:
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 
151 protected:
154  void addDummyModule( const OUString& rName, sal_Int32 nType );
155 
157  virtual void prepareImport();
158 
159 private:
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 
184 private:
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 >
196  MacroAttacherVector maMacroAttachers;
197  DummyModuleMap maDummyModules;
198  OUString maPrjName;
199  css::uno::Reference< css::container::XNameContainer >
202  VbaModuleMap maModules;
203  VbaModuleMap maModulesByStrm;
204 };
205 
206 
207 } // namespace oox::ole
208 
209 #endif
210 
211 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
RefVector< VbaMacroAttacherBase > MacroAttacherVector
Definition: vbaproject.hxx:185
Provides helper functions for colors, device measurement conversion, graphics, and graphic objects ha...
::std::map< OUString, sal_Int32 > DummyModuleMap
Definition: vbaproject.hxx:186
bool isImportVba() const
Returns true, if the VBA source code and forms should be imported.
Definition: vbaproject.cxx:101
exports com.sun.star. io
OUString maPrjName
Name of the VBA project.
Definition: vbaproject.hxx:198
Base class for objects that attach a macro to a specific action.
Definition: vbaproject.hxx:91
sal_Int16 script
VbaFilterConfig(const css::uno::Reference< css::uno::XComponentContext > &rxContext, std::u16string_view rConfigCompName)
Definition: vbaproject.cxx:82
bool isImportVbaExecutable() const
Returns true, if the VBA source code should be imported executable.
Definition: vbaproject.cxx:106
VbaModuleMap maModulesByStrm
Definition: vbaproject.hxx:203
exports com.sun.star. container
bool isExportVba() const
Returns true, if the VBA source code and forms should be exported.
Definition: vbaproject.cxx:111
exports com.sun.star. frame
void setOleOverridesSink(css::uno::Reference< css::container::XNameContainer > const &rxOleOverridesSink)
Definition: vbaproject.hxx:149
css::uno::Reference< css::uno::XInterface > mxConfigAccess
Definition: vbaproject.hxx:70
Base class for storage access implementations.
Definition: storagebase.hxx:51
css::uno::Reference< css::container::XNameContainer > mxOleOverridesSink
Definition: vbaproject.hxx:200
DummyModuleMap maDummyModules
Additional empty modules created on import.
Definition: vbaproject.hxx:197
VbaModuleMap maModules
Definition: vbaproject.hxx:202
css::uno::Reference< css::frame::XModel > mxDocModel
Document model used to import/export the VBA project.
Definition: vbaproject.hxx:191
std::shared_ptr< VbaMacroAttacherBase > VbaMacroAttacherRef
Definition: vbaproject.hxx:111
RefMap< OUString, VbaModule > VbaModuleMap
Definition: vbaproject.hxx:201
css::uno::Reference< css::container::XNameContainer > mxBasicLib
The Basic library of the document used for import.
Definition: vbaproject.hxx:193
css::uno::Reference< css::uno::XComponentContext > mxContext
Component context with service manager.
Definition: vbaproject.hxx:189
#define OOX_DLLPUBLIC
Definition: dllapi.h:28
MacroAttacherVector maMacroAttachers
Objects that want to attach a VBA macro to an action.
Definition: vbaproject.hxx:196
css::uno::Reference< css::container::XNameContainer > mxDialogLib
The dialog library of the document used for import.
Definition: vbaproject.hxx:195