LibreOffice Module oox (master)  1
vbacontrol.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_VBACONTROL_HXX
21 #define INCLUDED_OOX_OLE_VBACONTROL_HXX
22 
23 #include <memory>
24 
25 #include <com/sun/star/uno/Reference.hxx>
26 #include <oox/helper/refvector.hxx>
28 #include <oox/ole/axcontrol.hxx>
29 #include <rtl/textenc.h>
30 #include <rtl/ustring.hxx>
31 #include <sal/types.h>
32 
33 namespace com::sun::star {
34  namespace awt { class XControlModel; }
35  namespace container { class XNameContainer; }
36  namespace frame { class XModel; }
37  namespace uno { class XComponentContext; }
38 }
39 
40 namespace oox {
41  class BinaryInputStream;
42  class GraphicHelper;
43  class PropertyMap;
44  class StorageBase;
45 }
46 
47 namespace oox::ole {
48 
49 
52 class VbaSiteModel final
53 {
54 public:
55  explicit VbaSiteModel();
56  ~VbaSiteModel();
57 
59  void importProperty( sal_Int32 nPropId, const OUString& rValue );
61  bool importBinaryModel( BinaryInputStream& rInStrm );
63  void moveRelative( const AxPairData& rDistance );
64 
66  const OUString& getName() const { return maName; }
68  const AxPairData& getPosition() const { return maPos; }
70  sal_Int32 getId() const { return mnId; }
72  bool isContainer() const;
74  sal_uInt32 getStreamLength() const;
76  OUString getSubStorageName() const;
78  sal_Int16 getTabIndex() const { return mnTabIndex; }
79 
81  ControlModelRef createControlModel( const AxClassTable& rClassTable ) const;
83  void convertProperties(
84  PropertyMap& rPropMap,
85  const ControlConverter& rConv,
86  ApiControlType eCtrlType,
87  sal_Int32 nCtrlIndex ) const;
88  const OUString& getControlSource() const { return maControlSource; }
89  const OUString& getRowSource() const { return maRowSource; }
90 private:
91  OUString maName;
92  OUString maTag;
93  OUString maToolTip;
94  OUString maControlSource;
95  OUString maRowSource;
96 
98  sal_Int32 mnId;
99  sal_Int32 mnHelpContextId;
100  sal_uInt32 mnFlags;
101  sal_uInt32 mnStreamLen;
102  sal_Int16 mnTabIndex;
103  sal_uInt16 mnClassIdOrCache;
104  sal_uInt16 mnGroupId;
105 };
106 
107 typedef std::shared_ptr< VbaSiteModel > VbaSiteModelRef;
108 
109 
118 {
119 public:
120  explicit VbaFormControl();
121  virtual ~VbaFormControl();
122 
126  BinaryInputStream& rInStrm,
127  StorageBase& rStrg,
128  const AxClassTable& rClassTable );
129 
131  OUString getControlName() const;
132 
135  void createAndConvert(
136  sal_Int32 nCtrlIndex,
137  const css::uno::Reference< css::container::XNameContainer >& rxParentNC,
138  const ControlConverter& rConv ) const;
139 
140 protected:
142  void importControlModel( BinaryInputStream& rInStrm, const AxClassTable& rClassTable );
145  void importStorage( StorageBase& rStrg, const AxClassTable& rClassTable );
146 
148  bool convertProperties(
149  const css::uno::Reference< css::awt::XControlModel >& rxCtrlModel,
150  const ControlConverter& rConv,
151  sal_Int32 nCtrlIndex ) const;
152 
153 private:
156 
158  void createControlModel( const AxClassTable& rClassTable );
160  bool importSiteModel( BinaryInputStream& rInStrm );
161 
164  /* Final processing of all embedded controls after import. */
166 
168  void moveRelative( const AxPairData& rDistance );
172 
174  static bool compareByTabIndex( const VbaFormControlRef& rxLeft, const VbaFormControlRef& rxRight );
175 
176 protected:
177  VbaSiteModelRef mxSiteModel;
179 
180 private:
181  VbaFormControlVector maControls;
183 };
184 
185 
186 class VbaUserForm final : public VbaFormControl
187 {
188 public:
189  explicit VbaUserForm(
190  const css::uno::Reference< css::uno::XComponentContext >& rxContext,
191  const css::uno::Reference< css::frame::XModel >& rxDocModel,
192  const GraphicHelper& rGraphicHelper,
193  bool bDefaultColorBgr );
194 
197  void importForm(
198  const css::uno::Reference< css::container::XNameContainer >& rxDialogLib,
199  StorageBase& rVbaFormStrg,
200  const OUString& rModuleName,
201  rtl_TextEncoding eTextEnc );
202 
203 private:
204  css::uno::Reference< css::uno::XComponentContext > mxContext;
205  css::uno::Reference< css::frame::XModel > mxDocModel;
207 };
208 
209 
210 } // namespace oox::ole
211 
212 #endif
213 
214 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Provides helper functions for colors, device measurement conversion, graphics, and graphic objects ha...
void importProperty(sal_Int32 nPropId, const OUString &rValue)
Allows to set single properties specified by XML token identifier.
Definition: vbacontrol.cxx:177
void importControlModel(BinaryInputStream &rInStrm, const AxClassTable &rClassTable)
Creates and imports the control model containing properties of the control.
Definition: vbacontrol.cxx:380
std::shared_ptr< VbaSiteModel > VbaSiteModelRef
Definition: vbacontrol.hxx:107
A helper that maps property identifiers to property values.
Definition: propertymap.hxx:52
sal_Int16 mnTabIndex
Tab order index.
Definition: vbacontrol.hxx:102
void moveRelative(const AxPairData &rDistance)
Moves the control relative to its current position by the passed distance.
Definition: vbacontrol.cxx:691
void createAndConvert(sal_Int32 nCtrlIndex, const css::uno::Reference< css::container::XNameContainer > &rxParentNC, const ControlConverter &rConv) const
Creates the UNO control model, inserts it into the passed container, and converts all control propert...
Definition: vbacontrol.cxx:351
VbaSiteModelRef mxSiteModel
Common control properties.
Definition: vbacontrol.hxx:177
const OUString & getControlSource() const
Definition: vbacontrol.hxx:88
exports com.sun.star. awt
sal_uInt16 mnClassIdOrCache
Class name identifier or GUID cache index.
Definition: vbacontrol.hxx:103
::std::pair< sal_Int32, sal_Int32 > AxPairData
A pair of integer values as a property.
bool isContainer() const
Returns true, if this control is a container control.
Definition: vbacontrol.cxx:214
sal_uInt16 mnGroupId
Group identifier for grouped controls.
Definition: vbacontrol.hxx:104
bool importBinaryModel(BinaryInputStream &rInStrm)
Imports the site model data from the passed input stream.
Definition: vbacontrol.cxx:187
VbaUserForm(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::frame::XModel > &rxDocModel, const GraphicHelper &rGraphicHelper, bool bDefaultColorBgr)
Definition: vbacontrol.cxx:778
sal_uInt32 mnStreamLen
Size of control stream data.
Definition: vbacontrol.hxx:101
exports com.sun.star. container
css::uno::Any const & rValue
VbaFormControlVector maControls
All embedded form controls.
Definition: vbacontrol.hxx:181
static bool compareByTabIndex(const VbaFormControlRef &rxLeft, const VbaFormControlRef &rxRight)
Functor for comparing controls by their tab index.
Definition: vbacontrol.cxx:718
ApiControlType
Enumerates all UNO API control types supported by these filters.
Definition: axcontrol.hxx:151
void createControlModel(const AxClassTable &rClassTable)
Creates the control model according to the current site model.
Definition: vbacontrol.cxx:525
::std::vector< OUString > AxClassTable
Definition: axcontrol.hxx:794
exports com.sun.star. frame
ControlConverter maConverter
Definition: vbacontrol.hxx:206
std::map< sal_Int32, STLPropertyMapEntry > PropertyMap
css::uno::Reference< css::frame::XModel > mxDocModel
Definition: vbacontrol.hxx:205
ControlModelRef mxCtrlModel
Specific control properties.
Definition: vbacontrol.hxx:178
Interface for binary input stream classes.
void importStorage(StorageBase &rStrg, const AxClassTable &rClassTable)
Creates and imports the control model, and imports all embedded controls from the passed substorage...
Definition: vbacontrol.cxx:387
OUString maControlSource
Linked cell for the control value in a spreadsheet.
Definition: vbacontrol.hxx:94
void importForm(const css::uno::Reference< css::container::XNameContainer > &rxDialogLib, StorageBase &rVbaFormStrg, const OUString &rModuleName, rtl_TextEncoding eTextEnc)
Imports the form and its embedded controls, and inserts the form with all its controls into the passe...
Definition: vbacontrol.cxx:788
Base class for storage access implementations.
Definition: storagebase.hxx:51
A base class with useful helper functions for something that is able to convert ActiveX and ComCtl fo...
Definition: axcontrol.hxx:193
container_type::value_type value_type
Definition: refvector.hxx:45
const OUString & getName() const
Returns the programmatical name of the control.
Definition: vbacontrol.hxx:66
OUString maToolTip
Tool tip for the control.
Definition: vbacontrol.hxx:93
const OUString & getRowSource() const
Definition: vbacontrol.hxx:89
sal_Int32 mnHelpContextId
Help context identifier.
Definition: vbacontrol.hxx:99
OUString maName
Name of the control.
Definition: vbacontrol.hxx:91
css::uno::Reference< css::uno::XComponentContext > mxContext
Definition: vbacontrol.hxx:204
bool convertProperties(const css::uno::Reference< css::awt::XControlModel > &rxCtrlModel, const ControlConverter &rConv, sal_Int32 nCtrlIndex) const
Converts all control properties, and inserts and converts embedded controls.
Definition: vbacontrol.cxx:485
sal_uInt32 getStreamLength() const
Returns the length of the stream data for stream based controls.
Definition: vbacontrol.cxx:219
Common properties for all controls that are part of a VBA user form or of another container control i...
Definition: vbacontrol.hxx:52
void importModelOrStorage(BinaryInputStream &rInStrm, StorageBase &rStrg, const AxClassTable &rClassTable)
Imports the model from the passed stream or storage, depending on the control's type.
Definition: vbacontrol.cxx:326
OUString maTag
User defined tag.
Definition: vbacontrol.hxx:92
RefVector< VbaFormControl > VbaFormControlVector
Definition: vbacontrol.hxx:154
const AxPairData & getPosition() const
Returns the position of the control in its parent.
Definition: vbacontrol.hxx:68
OUString getControlName() const
Returns the programmatical name of the control.
Definition: vbacontrol.cxx:346
OUString getSubStorageName() const
Returns the name of the substorage for the container control data.
Definition: vbacontrol.cxx:224
sal_uInt32 mnFlags
Various flags.
Definition: vbacontrol.hxx:100
void importEmbeddedSiteModels(BinaryInputStream &rInStrm)
Imports the site models of all embedded controls from the 'f' stream.
Definition: vbacontrol.cxx:538
void moveRelative(const AxPairData &rDistance)
Moves the control relative to its current position by the passed distance.
Definition: vbacontrol.cxx:208
A control that is embedded in a VBA user form or in another container control in a VBA user form...
Definition: vbacontrol.hxx:117
ControlModelRef createControlModel(const AxClassTable &rClassTable) const
Tries to create the control model according to the site model.
Definition: vbacontrol.cxx:238
AxClassTable maClassTable
Class identifiers for exotic embedded controls.
Definition: vbacontrol.hxx:182
sal_Int16 getTabIndex() const
Returns the tab index of the control.
Definition: vbacontrol.hxx:78
sal_Int32 mnId
Control identifier.
Definition: vbacontrol.hxx:98
sal_Int32 getId() const
Returns the unique identifier of this control.
Definition: vbacontrol.hxx:70
OUString maRowSource
Source data for the control in a spreadsheet.
Definition: vbacontrol.hxx:95
bool importSiteModel(BinaryInputStream &rInStrm)
Imports the site model data containing common properties of the control.
Definition: vbacontrol.cxx:532
std::shared_ptr< ControlModelBase > ControlModelRef
Definition: axcontrol.hxx:388
AxPairData maPos
Position in parent container.
Definition: vbacontrol.hxx:97
void convertProperties(PropertyMap &rPropMap, const ControlConverter &rConv, ApiControlType eCtrlType, sal_Int32 nCtrlIndex) const
Converts all form site properties.
Definition: vbacontrol.cxx:298
VbaFormControlVector::value_type VbaFormControlRef
Definition: vbacontrol.hxx:155
void moveEmbeddedToAbsoluteParent()
Moves all embedded controls from their relative position in this control to an absolute position in t...
Definition: vbacontrol.cxx:697