summaryrefslogtreecommitdiff
path: root/oox/inc/oox/ole/axcontrol.hxx
blob: 538e8aee961d3f98acbfdb469b5d4c7057a65a76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: axcontrol.hxx,v $
 * $Revision: 1.1 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

#ifndef OOX_OLE_AXCONTROL_HXX
#define OOX_OLE_AXCONTROL_HXX

#include <memory>
#include "oox/helper/binarystreambase.hxx"

namespace com { namespace sun { namespace star {
    namespace awt { class XControlModel; }
} } }

namespace oox {
    class BinaryInputStream;
    class PropertyMap;
}

namespace oox {
namespace ole {

class AxControlHelper;

// ============================================================================

/** Base class for all models of ActiveX form controls. */
class AxControlModelBase
{
public:
    virtual             ~AxControlModelBase();

    /** Derived classes set specific OOXML properties at the model structure. */
    virtual void        importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue );
    /** Derived classes set binary data (picture, mouse icon) at the model structure. */
    virtual void        importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm );
    /** Derived classes import a form control model from the passed input stream. */
    virtual void        importBinaryModel( BinaryInputStream& rInStrm );

    /** Derived classes return the UNO service name used to construct the control component. */
    virtual ::rtl::OUString getServiceName() const = 0;
    /** Derived classes convert all control properties. */
    virtual void        convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const;

protected:
    explicit            AxControlModelBase();

protected:
    sal_Int32           mnWidth;
    sal_Int32           mnHeight;
};

// ============================================================================

class AxFontDataModel : public AxControlModelBase
{
public:
    explicit            AxFontDataModel();

    virtual void        importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue );
    virtual void        importBinaryModel( BinaryInputStream& rInStrm );
    virtual void        convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const;

private:
    ::rtl::OUString     maFontName;         /// Name of the used font.
    sal_uInt32          mnFontEffects;      /// Font effect flags.
    sal_Int32           mnFontHeight;       /// Height of the font (not really twips, see code).
    sal_Int32           mnFontCharSet;      /// Windows character set of the font.
    sal_Int32           mnHorAlign;         /// Horizontal text alignment.
};

// ============================================================================

class AxCommandButtonModel : public AxFontDataModel
{
public:
    explicit            AxCommandButtonModel();

    virtual ::rtl::OUString getServiceName() const;
    virtual void        importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue );
    virtual void        importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm );
    virtual void        importBinaryModel( BinaryInputStream& rInStrm );
    virtual void        convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const;

private:
    StreamDataSequence  maPictureData;      /// Binary picture stream.
    ::rtl::OUString     maCaption;          /// Visible caption of the button.
    sal_uInt32          mnTextColor;        /// Text color.
    sal_uInt32          mnBackColor;        /// Fill color.
    sal_uInt32          mnFlags;            /// Various flags.
    sal_uInt32          mnPicturePos;       /// Position of the picture relative to text.
    bool                mbFocusOnClick;     /// True = take focus on click.
};

// ============================================================================

class AxLabelModel : public AxFontDataModel
{
public:
    explicit            AxLabelModel();

    virtual ::rtl::OUString getServiceName() const;
    virtual void        importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue );
    virtual void        importBinaryModel( BinaryInputStream& rInStrm );
    virtual void        convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const;

private:
    ::rtl::OUString     maCaption;          /// Visible caption of the button.
    sal_uInt32          mnTextColor;        /// Text color.
    sal_uInt32          mnBackColor;        /// Fill color.
    sal_uInt32          mnFlags;            /// Various flags.
    sal_uInt32          mnBorderColor;      /// Flat border color.
    sal_Int32           mnBorderStyle;      /// Flat border style.
    sal_Int32           mnSpecialEffect;    /// 3D border effect.
};

// ============================================================================

class AxImageModel : public AxControlModelBase
{
public:
    explicit            AxImageModel();

    virtual ::rtl::OUString getServiceName() const;
    virtual void        importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue );
    virtual void        importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm );
    virtual void        importBinaryModel( BinaryInputStream& rInStrm );
    virtual void        convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const;

private:
    StreamDataSequence  maPictureData;      /// Binary picture stream.
    sal_uInt32          mnBackColor;        /// Fill color.
    sal_uInt32          mnFlags;            /// Various flags.
    sal_uInt32          mnBorderColor;      /// Flat border color.
    sal_Int32           mnBorderStyle;      /// Flat border style.
    sal_Int32           mnSpecialEffect;    /// 3D border effect.
    sal_Int32           mnPicSizeMode;      /// Clip, stretch, zoom.
    sal_Int32           mnPicAlign;         /// Anchor position of the picture.
    bool                mbPicTiling;        /// True = picture is repeated.
};

// ============================================================================

class AxMorphDataModel : public AxFontDataModel
{
public:
    explicit            AxMorphDataModel();

    virtual void        importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue );
    virtual void        importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm );
    virtual void        importBinaryModel( BinaryInputStream& rInStrm );
    virtual void        convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const;

protected:
    StreamDataSequence  maPictureData;      /// Binary picture stream.
    ::rtl::OUString     maCaption;          /// Visible caption of the button.
    ::rtl::OUString     maValue;            /// Current value of the control.
    ::rtl::OUString     maGroupName;        /// Group name for option buttons.
    sal_uInt32          mnTextColor;        /// Text color.
    sal_uInt32          mnBackColor;        /// Fill color.
    sal_uInt32          mnFlags;            /// Various flags.
    sal_uInt32          mnPicturePos;       /// Position of the picture relative to text.
    sal_uInt32          mnBorderColor;      /// Flat border color.
    sal_Int32           mnBorderStyle;      /// Flat border style.
    sal_Int32           mnSpecialEffect;    /// 3D border effect.
    sal_Int32           mnDisplayStyle;     /// Type of the morph control.
    sal_Int32           mnMultiSelect;      /// Selection mode.
    sal_Int32           mnScrollBars;       /// Horizontal/vertical scroll bar.
    sal_Int32           mnMatchEntry;       /// Auto completion mode.
    sal_Int32           mnShowDropButton;   /// When to show the dropdown button.
    sal_Int32           mnMaxLength;        /// Maximum character count.
    sal_Int32           mnPasswordChar;     /// Password character in edit fields.
    sal_Int32           mnListRows;         /// Number of rows in dropdown box.
};

// ============================================================================

class AxToggleButtonModel : public AxMorphDataModel
{
public:
    explicit            AxToggleButtonModel();

    virtual ::rtl::OUString getServiceName() const;
    virtual void        convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const;
};

// ============================================================================

class AxCheckBoxModel : public AxMorphDataModel
{
public:
    explicit            AxCheckBoxModel();

    virtual ::rtl::OUString getServiceName() const;
    virtual void        convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const;
};

// ============================================================================

class AxOptionButtonModel : public AxMorphDataModel
{
public:
    explicit            AxOptionButtonModel();

    virtual ::rtl::OUString getServiceName() const;
    virtual void        convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const;
};

// ============================================================================

class AxTextBoxModel : public AxMorphDataModel
{
public:
    explicit            AxTextBoxModel();

    virtual ::rtl::OUString getServiceName() const;
    virtual void        convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const;
};

// ============================================================================

class AxListBoxModel : public AxMorphDataModel
{
public:
    explicit            AxListBoxModel();

    virtual ::rtl::OUString getServiceName() const;
    virtual void        convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const;
};

// ============================================================================

class AxComboBoxModel : public AxMorphDataModel
{
public:
    explicit            AxComboBoxModel();

    virtual ::rtl::OUString getServiceName() const;
    virtual void        convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const;
};

// ============================================================================

class AxSpinButtonModel : public AxControlModelBase
{
public:
    explicit            AxSpinButtonModel();

    virtual ::rtl::OUString getServiceName() const;
    virtual void        importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue );
    virtual void        importBinaryModel( BinaryInputStream& rInStrm );
    virtual void        convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const;

private:
    sal_uInt32          mnArrowColor;       /// Button arrow color.
    sal_uInt32          mnBackColor;        /// Fill color.
    sal_uInt32          mnFlags;            /// Various flags.
    sal_Int32           mnOrientation;      /// Orientation of the buttons.
    sal_Int32           mnMin;              /// Minimum of the value range.
    sal_Int32           mnMax;              /// Maximum of the value range.
    sal_Int32           mnPosition;         /// Value of the spin button.
    sal_Int32           mnSmallChange;      /// Increment step size.
    sal_Int32           mnDelay;            /// Repeat delay in milliseconds.
};

// ============================================================================

class AxScrollBarModel : public AxControlModelBase
{
public:
    explicit            AxScrollBarModel();

    virtual ::rtl::OUString getServiceName() const;
    virtual void        importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue );
    virtual void        importBinaryModel( BinaryInputStream& rInStrm );
    virtual void        convertProperties( AxControlHelper& rHelper, PropertyMap& rPropMap ) const;

private:
    sal_uInt32          mnArrowColor;       /// Button arrow color.
    sal_uInt32          mnBackColor;        /// Fill color.
    sal_uInt32          mnFlags;            /// Various flags.
    sal_Int32           mnOrientation;      /// Orientation of the buttons.
    sal_Int32           mnPropThumb;        /// Proportional thumb size.
    sal_Int32           mnMin;              /// Minimum of the value range.
    sal_Int32           mnMax;              /// Maximum of the value range.
    sal_Int32           mnPosition;         /// Value of the spin button.
    sal_Int32           mnSmallChange;      /// Increment step size (buttons).
    sal_Int32           mnLargeChange;      /// Increment step size (thumb).
    sal_Int32           mnDelay;            /// Repeat delay in milliseconds.
};

// ============================================================================

/** Container for all ActiveX form control model implementations. */
class AxControl
{
public:
    explicit            AxControl( const ::rtl::OUString& rName );
                        ~AxControl();

    /** Creates and returns the internal control model according to the passed
        MS class identifier. */
    AxControlModelBase* createModel( const ::rtl::OUString& rClassId );
    /** Imports a form control model from the passed input stream. */
    void                importBinaryModel( BinaryInputStream& rInStrm );

    /** Returns the internal control model. */
    inline const AxControlModelBase* getModel() const { return mxModel.get(); }
    /** Returns the MS class identifier used to create the internal control model. */
    inline const ::rtl::OUString& getClassId() const { return maClassId; }

    /** Creates and returns the UNO form component object for this control and
        inserts it into the form wrapped by the passed helper. */
    ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >
                        convertAndInsert( AxControlHelper& rHelper ) const;

private:
    ::std::auto_ptr< AxControlModelBase > mxModel;
    ::rtl::OUString     maClassId;          /// Class identifier of the control model.
    ::rtl::OUString     maName;             /// Name of the control.
};

// ============================================================================

} // namespace ole
} // namespace oox

#endif