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 OOX_OLE_AXCONTROL_HXX
21 : #define OOX_OLE_AXCONTROL_HXX
22 :
23 : #include <boost/shared_ptr.hpp>
24 : #include "oox/helper/binarystreambase.hxx"
25 : #include "oox/helper/propertyset.hxx"
26 : #include "oox/ole/axbinaryreader.hxx"
27 : #include "oox/ole/olehelper.hxx"
28 : #include "oox/dllapi.h"
29 :
30 : namespace com { namespace sun { namespace star {
31 : namespace awt { class XControlModel; }
32 : namespace container { class XIndexContainer; }
33 : namespace drawing { class XDrawPage; }
34 : namespace frame { class XModel; }
35 : namespace form { class XFormsSupplier; }
36 : namespace lang { class XMultiServiceFactory; }
37 : } } }
38 :
39 : namespace oox {
40 : class BinaryInputStream;
41 : class GraphicHelper;
42 : class PropertyMap;
43 : }
44 :
45 : namespace oox {
46 : namespace ole {
47 :
48 : // ============================================================================
49 :
50 : #define COMCTL_GUID_SCROLLBAR_60 "{FE38753A-44A3-11D1-B5B7-0000C09000C4}"
51 : #define COMCTL_GUID_PROGRESSBAR_50 "{0713E8D2-850A-101B-AFC0-4210102A8DA7}"
52 : #define COMCTL_GUID_PROGRESSBAR_60 "{35053A22-8589-11D1-B16A-00C0F0283628}"
53 :
54 : const sal_uInt16 COMCTL_VERSION_50 = 5;
55 : const sal_uInt16 COMCTL_VERSION_60 = 6;
56 :
57 : // ----------------------------------------------------------------------------
58 :
59 : #define AX_GUID_COMMANDBUTTON "{D7053240-CE69-11CD-a777-00dd01143c57}"
60 : #define AX_GUID_LABEL "{978C9E23-D4B0-11CE-bf2d-00aa003f40d0}"
61 : #define AX_GUID_IMAGE "{4C599241-6926-101B-9992-00000b65c6f9}"
62 : #define AX_GUID_TOGGLEBUTTON "{8BD21D60-EC42-11CE-9e0d-00aa006002f3}"
63 : #define AX_GUID_CHECKBOX "{8BD21D40-EC42-11CE-9e0d-00aa006002f3}"
64 : #define AX_GUID_OPTIONBUTTON "{8BD21D50-EC42-11CE-9e0d-00aa006002f3}"
65 : #define AX_GUID_TEXTBOX "{8BD21D10-EC42-11CE-9e0d-00aa006002f3}"
66 : #define AX_GUID_LISTBOX "{8BD21D20-EC42-11CE-9e0d-00aa006002f3}"
67 : #define AX_GUID_COMBOBOX "{8BD21D30-EC42-11CE-9e0d-00aa006002f3}"
68 : #define AX_GUID_SPINBUTTON "{79176FB0-B7F2-11CE-97ef-00aa006d2776}"
69 : #define AX_GUID_SCROLLBAR "{DFD181E0-5E2F-11CE-a449-00aa004a803d}"
70 : #define AX_GUID_FRAME "{6E182020-F460-11CE-9bcd-00aa00608e01}"
71 :
72 : // Html control GUID(s)
73 :
74 : #define HTML_GUID_SELECT "{5512D122-5CC6-11CF-8d67-00aa00bdce1d}"
75 : #define HTML_GUID_TEXTBOX "{5512D124-5CC6-11CF-8d67-00aa00bdce1d}"
76 :
77 : const sal_uInt32 AX_SYSCOLOR_WINDOWBACK = 0x80000005;
78 : const sal_uInt32 AX_SYSCOLOR_WINDOWFRAME = 0x80000006;
79 : const sal_uInt32 AX_SYSCOLOR_WINDOWTEXT = 0x80000008;
80 : const sal_uInt32 AX_SYSCOLOR_BUTTONFACE = 0x8000000F;
81 : const sal_uInt32 AX_SYSCOLOR_BUTTONTEXT = 0x80000012;
82 :
83 : const sal_uInt32 AX_FLAGS_ENABLED = 0x00000002;
84 : const sal_uInt32 AX_FLAGS_LOCKED = 0x00000004;
85 : const sal_uInt32 AX_FLAGS_OPAQUE = 0x00000008;
86 : const sal_uInt32 AX_FLAGS_COLUMNHEADS = 0x00000400;
87 : const sal_uInt32 AX_FLAGS_ENTIREROWS = 0x00000800;
88 : const sal_uInt32 AX_FLAGS_EXISTINGENTRIES = 0x00001000;
89 : const sal_uInt32 AX_FLAGS_CAPTIONLEFT = 0x00002000;
90 : const sal_uInt32 AX_FLAGS_EDITABLE = 0x00004000;
91 : const sal_uInt32 AX_FLAGS_IMEMODE_MASK = 0x00078000;
92 : const sal_uInt32 AX_FLAGS_DRAGENABLED = 0x00080000;
93 : const sal_uInt32 AX_FLAGS_ENTERASNEWLINE = 0x00100000;
94 : const sal_uInt32 AX_FLAGS_KEEPSELECTION = 0x00200000;
95 : const sal_uInt32 AX_FLAGS_TABASCHARACTER = 0x00400000;
96 : const sal_uInt32 AX_FLAGS_WORDWRAP = 0x00800000;
97 : const sal_uInt32 AX_FLAGS_BORDERSSUPPRESSED = 0x02000000;
98 : const sal_uInt32 AX_FLAGS_SELECTLINE = 0x04000000;
99 : const sal_uInt32 AX_FLAGS_SINGLECHARSELECT = 0x08000000;
100 : const sal_uInt32 AX_FLAGS_AUTOSIZE = 0x10000000;
101 : const sal_uInt32 AX_FLAGS_HIDESELECTION = 0x20000000;
102 : const sal_uInt32 AX_FLAGS_MAXLENAUTOTAB = 0x40000000;
103 : const sal_uInt32 AX_FLAGS_MULTILINE = 0x80000000;
104 :
105 : const sal_Int32 AX_BORDERSTYLE_NONE = 0;
106 : const sal_Int32 AX_BORDERSTYLE_SINGLE = 1;
107 :
108 : const sal_Int32 AX_SPECIALEFFECT_FLAT = 0;
109 : const sal_Int32 AX_SPECIALEFFECT_RAISED = 1;
110 : const sal_Int32 AX_SPECIALEFFECT_SUNKEN = 2;
111 : const sal_Int32 AX_SPECIALEFFECT_ETCHED = 3;
112 : const sal_Int32 AX_SPECIALEFFECT_BUMPED = 6;
113 :
114 : const sal_Int32 AX_PICSIZE_CLIP = 0;
115 : const sal_Int32 AX_PICSIZE_STRETCH = 1;
116 : const sal_Int32 AX_PICSIZE_ZOOM = 3;
117 :
118 : const sal_Int32 AX_PICALIGN_TOPLEFT = 0;
119 : const sal_Int32 AX_PICALIGN_TOPRIGHT = 1;
120 : const sal_Int32 AX_PICALIGN_CENTER = 2;
121 : const sal_Int32 AX_PICALIGN_BOTTOMLEFT = 3;
122 : const sal_Int32 AX_PICALIGN_BOTTOMRIGHT = 4;
123 :
124 : const sal_Int32 AX_DISPLAYSTYLE_TEXT = 1;
125 : const sal_Int32 AX_DISPLAYSTYLE_LISTBOX = 2;
126 : const sal_Int32 AX_DISPLAYSTYLE_COMBOBOX = 3;
127 : const sal_Int32 AX_DISPLAYSTYLE_CHECKBOX = 4;
128 : const sal_Int32 AX_DISPLAYSTYLE_OPTBUTTON = 5;
129 : const sal_Int32 AX_DISPLAYSTYLE_TOGGLE = 6;
130 : const sal_Int32 AX_DISPLAYSTYLE_DROPDOWN = 7;
131 :
132 : const sal_Int32 AX_SELCTION_SINGLE = 0;
133 : const sal_Int32 AX_SELCTION_MULTI = 1;
134 : const sal_Int32 AX_SELCTION_EXTENDED = 2;
135 :
136 : const sal_Int32 AX_SHOWDROPBUTTON_NEVER = 0;
137 : const sal_Int32 AX_SHOWDROPBUTTON_FOCUS = 1;
138 : const sal_Int32 AX_SHOWDROPBUTTON_ALWAYS = 2;
139 :
140 : const sal_Int32 AX_SCROLLBAR_NONE = 0x00;
141 : const sal_Int32 AX_SCROLLBAR_HORIZONTAL = 0x01;
142 : const sal_Int32 AX_SCROLLBAR_VERTICAL = 0x02;
143 :
144 : // ----------------------------------------------------------------------------
145 :
146 : /** Enumerates all UNO API control types supported by these filters. */
147 : enum ApiControlType
148 : {
149 : API_CONTROL_BUTTON,
150 : API_CONTROL_FIXEDTEXT,
151 : API_CONTROL_IMAGE,
152 : API_CONTROL_CHECKBOX,
153 : API_CONTROL_RADIOBUTTON,
154 : API_CONTROL_EDIT,
155 : API_CONTROL_NUMERIC,
156 : API_CONTROL_LISTBOX,
157 : API_CONTROL_COMBOBOX,
158 : API_CONTROL_SPINBUTTON,
159 : API_CONTROL_SCROLLBAR,
160 : API_CONTROL_TABSTRIP,
161 : API_CONTROL_PROGRESSBAR,
162 : API_CONTROL_GROUPBOX,
163 : API_CONTROL_FRAME,
164 : API_CONTROL_PAGE,
165 : API_CONTROL_MULTIPAGE,
166 : API_CONTROL_DIALOG
167 : };
168 :
169 : // ============================================================================
170 :
171 : /** Specifies how a form control supports transparent background. */
172 : enum ApiTransparencyMode
173 : {
174 : API_TRANSPARENCY_NOTSUPPORTED, ///< Control does not support transparency.
175 : API_TRANSPARENCY_VOID, ///< Transparency is enabled by missing fill color.
176 : API_TRANSPARENCY_PAINTTRANSPARENT ///< Transparency is enabled by the 'PaintTransparent' property.
177 : };
178 :
179 : /** Specifies how a form control supports the DefaultState property. */
180 : enum ApiDefaultStateMode
181 : {
182 : API_DEFAULTSTATE_BOOLEAN, ///< Control does not support tri-state, state is given as boolean.
183 : API_DEFAULTSTATE_SHORT, ///< Control does not support tri-state, state is given as short.
184 : API_DEFAULTSTATE_TRISTATE ///< Control supports tri-state, state is given as short.
185 : };
186 :
187 : // ----------------------------------------------------------------------------
188 :
189 : /** A base class with useful helper functions for something that is able to
190 : convert ActiveX and ComCtl form controls.
191 : */
192 : class OOX_DLLPUBLIC ControlConverter
193 : {
194 : public:
195 : explicit ControlConverter(
196 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxDocModel,
197 : const GraphicHelper& rGraphicHelper,
198 : bool bDefaultColorBgr = true );
199 : virtual ~ControlConverter();
200 :
201 : // Generic conversion -----------------------------------------------------
202 :
203 : /** Converts the passed position in 1/100 mm to UNO properties. */
204 : void convertPosition(
205 : PropertyMap& rPropMap,
206 : const AxPairData& rPos ) const;
207 :
208 : /** Converts the passed size in 1/100 mm to UNO properties. */
209 : void convertSize(
210 : PropertyMap& rPropMap,
211 : const AxPairData& rSize ) const;
212 :
213 : /** Converts the passed encoded OLE color to UNO properties. */
214 : void convertColor(
215 : PropertyMap& rPropMap,
216 : sal_Int32 nPropId,
217 : sal_uInt32 nOleColor ) const;
218 :
219 : void convertToMSColor(
220 : PropertySet& rPropSet,
221 : sal_Int32 nPropId,
222 : sal_uInt32& nOleColor,
223 : sal_uInt32 nDefault = 0 ) const;
224 :
225 :
226 : /** Converts the passed StdPic picture stream to UNO properties. */
227 : void convertPicture(
228 : PropertyMap& rPropMap,
229 : const StreamDataSequence& rPicData ) const;
230 :
231 : /** Converts the control orientation to UNO properties. */
232 : void convertOrientation(
233 : PropertyMap& rPropMap,
234 : bool bHorizontal ) const;
235 :
236 : void convertToMSOrientation(
237 : PropertySet& rPropMap,
238 : bool& bHorizontal ) const;
239 :
240 : /** Converts the vertical alignment to UNO properties. */
241 : /** Converts the vertical alignment to UNO properties. */
242 : void convertVerticalAlign(
243 : PropertyMap& rPropMap,
244 : sal_Int32 nVerticalAlign ) const;
245 :
246 : /** Converts common scrollbar settings to UNO properties. */
247 : void convertScrollBar(
248 : PropertyMap& rPropMap,
249 : sal_Int32 nMin, sal_Int32 nMax, sal_Int32 nPosition,
250 : sal_Int32 nSmallChange, sal_Int32 nLargeChange, bool bAwtModel ) const;
251 :
252 : /** Converts scrollability settings to UNO properties. */
253 : void convertScrollabilitySettings(
254 : PropertyMap& rPropMap,
255 : const AxPairData& rScrollPos, const AxPairData& rScrollArea,
256 : sal_Int32 nScrollBars ) const;
257 :
258 : /** Binds the passed control model to the passed data sources. The
259 : implementation will check which source types are supported. */
260 : void bindToSources(
261 : const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel,
262 : const ::rtl::OUString& rCtrlSource,
263 : const ::rtl::OUString& rRowSource,
264 : sal_Int32 nRefSheet = 0 ) const;
265 :
266 : // ActiveX (Forms 2.0) specific conversion --------------------------------
267 :
268 : /** Converts the Forms 2.0 background formatting to UNO properties. */
269 : void convertAxBackground(
270 : PropertyMap& rPropMap,
271 : sal_uInt32 nBackColor,
272 : sal_uInt32 nFlags,
273 : ApiTransparencyMode eTranspMode ) const;
274 :
275 : /** Converts the Forms 2.0 border formatting to UNO properties. */
276 : void convertAxBorder(
277 : PropertyMap& rPropMap,
278 : sal_uInt32 nBorderColor,
279 : sal_Int32 nBorderStyle,
280 : sal_Int32 nSpecialEffect ) const;
281 :
282 : void convertToAxBorder(
283 : PropertySet& rPropSet,
284 : sal_uInt32& nBorderColor,
285 : sal_Int32& nBorderStyle,
286 : sal_Int32& nSpecialEffect ) const;
287 :
288 : /** Converts the Forms 2.0 special effect to UNO properties. */
289 : void convertAxVisualEffect(
290 : PropertyMap& rPropMap,
291 : sal_Int32 nSpecialEffect ) const;
292 :
293 : void convertToAxVisualEffect(
294 : PropertySet& rPropSet,
295 : sal_Int32& nSpecialEffect ) const;
296 :
297 : /** Converts the passed picture stream and Forms 2.0 position to UNO
298 : properties. */
299 : void convertAxPicture(
300 : PropertyMap& rPropMap,
301 : const StreamDataSequence& rPicData,
302 : sal_uInt32 nPicPos ) const;
303 :
304 : /** Converts the passed picture stream and Forms 2.0 position to UNO
305 : properties. */
306 : void convertAxPicture(
307 : PropertyMap& rPropMap,
308 : const StreamDataSequence& rPicData,
309 : sal_Int32 nPicSizeMode,
310 : sal_Int32 nPicAlign,
311 : bool bPicTiling ) const;
312 :
313 : /** Converts the Forms 2.0 value for checked/unchecked/dontknow to UNO
314 : properties. */
315 : void convertAxState(
316 : PropertyMap& rPropMap,
317 : const ::rtl::OUString& rValue,
318 : sal_Int32 nMultiSelect,
319 : ApiDefaultStateMode eDefStateMode,
320 : bool bAwtModel ) const;
321 :
322 : void convertToAxState(
323 : PropertySet& rPropSet,
324 : ::rtl::OUString& rValue,
325 : sal_Int32& nMultiSelect,
326 : ApiDefaultStateMode eDefStateMode,
327 : bool bAwtModel ) const;
328 :
329 : /** Converts the Forms 2.0 control orientation to UNO properties. */
330 : void convertAxOrientation(
331 : PropertyMap& rPropMap,
332 : const AxPairData& rSize,
333 : sal_Int32 nOrientation ) const;
334 :
335 : void convertToAxOrientation(
336 : PropertySet& rPropSet,
337 : const AxPairData& rSize,
338 : sal_Int32& nOrientation ) const;
339 :
340 : private:
341 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > mxDocModel;
342 : const GraphicHelper& mrGraphicHelper;
343 : mutable PropertySet maAddressConverter;
344 : mutable PropertySet maRangeConverter;
345 : bool mbDefaultColorBgr;
346 : };
347 :
348 : // ============================================================================
349 :
350 : /** Base class for all models of form controls. */
351 : class OOX_DLLPUBLIC ControlModelBase
352 : {
353 : public:
354 : explicit ControlModelBase();
355 : virtual ~ControlModelBase();
356 :
357 : /** Sets this control model to AWT model mode. */
358 0 : inline void setAwtModelMode() { mbAwtModel = true; }
359 : /** Sets this control model to form component mode. */
360 6 : inline void setFormComponentMode() { mbAwtModel = false; }
361 :
362 : /** Returns the UNO service name used to construct the AWT control model,
363 : or the control form component. */
364 : ::rtl::OUString getServiceName() const;
365 :
366 : /** Derived classes set specific OOXML properties at the model structure. */
367 : virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue );
368 : /** Derived classes set binary data (picture, mouse icon) at the model structure. */
369 : virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm );
370 : /** Derived classes import a form control model from the passed input stream. */
371 : virtual bool importBinaryModel( BinaryInputStream& rInStrm ) = 0;
372 : /** Derived classes export a form control model to the passed output stream. */
373 0 : virtual void exportBinaryModel( BinaryOutputStream& /*rOutStrm*/ ) {}
374 : /** Derived classes export CompObjStream contents. */
375 0 : virtual void exportCompObj( BinaryOutputStream& /*rOutStrm*/ ) {}
376 : /** Derived classes return the UNO control type enum value. */
377 : virtual ApiControlType getControlType() const = 0;
378 : /** Derived classes convert all control properties. */
379 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
380 : /** Derived classes convert from uno control properties to equiv. MS values. */
381 : virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv );
382 :
383 : /** Converts the control size to UNO properties. */
384 : void convertSize( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
385 :
386 : public: // direct access needed for legacy VML drawing controls
387 : AxPairData maSize; ///< Size of the control in 1/100 mm.
388 :
389 : protected:
390 : bool mbAwtModel; ///< True = AWT control model, false = form component.
391 : };
392 :
393 : typedef ::boost::shared_ptr< ControlModelBase > ControlModelRef;
394 :
395 : // ============================================================================
396 :
397 : /** Base class for all models of ComCtl form controls. */
398 0 : class ComCtlModelBase : public ControlModelBase
399 : {
400 : public:
401 : explicit ComCtlModelBase(
402 : sal_uInt32 nDataPartId5, sal_uInt32 nDataPartId6, sal_uInt16 nVersion,
403 : bool bCommonPart, bool bComplexPart );
404 :
405 : virtual bool importBinaryModel( BinaryInputStream& rInStrm );
406 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
407 :
408 : protected:
409 : virtual void importControlData( BinaryInputStream& rInStrm ) = 0;
410 : virtual void importCommonExtraData( BinaryInputStream& rInStrm );
411 : virtual void importCommonTrailingData( BinaryInputStream& rInStrm );
412 :
413 : private:
414 : /** Returns the data part identifier according to the model version. */
415 : sal_uInt32 getDataPartId() const;
416 :
417 : bool readPartHeader( BinaryInputStream& rInStrm,
418 : sal_uInt32 nExpPartId,
419 : sal_uInt16 nExpMajor = SAL_MAX_UINT16,
420 : sal_uInt16 nExpMinor = SAL_MAX_UINT16 );
421 :
422 : bool importSizePart( BinaryInputStream& rInStrm );
423 : bool importCommonPart( BinaryInputStream& rInStrm, sal_uInt32 nPartSize );
424 : bool importComplexPart( BinaryInputStream& rInStrm );
425 :
426 : protected:
427 : StdFontInfo maFontData; ///< Font formatting.
428 : StreamDataSequence maMouseIcon; ///< Binary picture stream for mouse icon.
429 : sal_uInt32 mnFlags; ///< Common flags for ComCtl controls.
430 : const sal_uInt16 mnVersion; ///< Current version of the ComCtl control model.
431 :
432 : private:
433 : sal_uInt32 mnDataPartId5; ///< Identifier for version 5.0 control data.
434 : sal_uInt32 mnDataPartId6; ///< Identifier for version 6.0 control data.
435 : bool mbCommonPart; ///< True = the COMCTL_COMMONDATA part exists.
436 : bool mbComplexPart; ///< True = the COMCTL_COMPLEXDATA part exists.
437 : };
438 :
439 : // ============================================================================
440 :
441 : /** Model for a ComCtl scroll bar. */
442 0 : class ComCtlScrollBarModel : public ComCtlModelBase
443 : {
444 : public:
445 : explicit ComCtlScrollBarModel( sal_uInt16 nVersion );
446 :
447 : virtual ApiControlType getControlType() const;
448 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
449 :
450 : protected:
451 : virtual void importControlData( BinaryInputStream& rInStrm );
452 :
453 : private:
454 : sal_uInt32 mnScrollBarFlags; ///< Special flags for scroll bar model.
455 : sal_Int32 mnLargeChange; ///< Increment step size (thumb).
456 : sal_Int32 mnSmallChange; ///< Increment step size (buttons).
457 : sal_Int32 mnMin; ///< Minimum of the value range.
458 : sal_Int32 mnMax; ///< Maximum of the value range.
459 : sal_Int32 mnPosition; ///< Value of the spin button.
460 : };
461 :
462 : // ============================================================================
463 :
464 : /** Model for a ComCtl progress bar. */
465 0 : class ComCtlProgressBarModel : public ComCtlModelBase
466 : {
467 : public:
468 : explicit ComCtlProgressBarModel( sal_uInt16 nVersion );
469 :
470 : virtual ApiControlType getControlType() const;
471 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
472 :
473 : protected:
474 : virtual void importControlData( BinaryInputStream& rInStrm );
475 :
476 : private:
477 : float mfMin; ///< Minimum of the value range.
478 : float mfMax; ///< Maximum of the value range.
479 : sal_uInt16 mnVertical; ///< 0 = horizontal, 1 = vertical.
480 : sal_uInt16 mnSmooth; ///< 0 = progress blocks, 1 = pixel resolution.
481 : };
482 :
483 : // ============================================================================
484 :
485 : /** Base class for all models of Form 2.0 form controls. */
486 6 : class OOX_DLLPUBLIC AxControlModelBase : public ControlModelBase
487 : {
488 : public:
489 : explicit AxControlModelBase();
490 :
491 : virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue );
492 : };
493 :
494 : // ============================================================================
495 :
496 : /** Base class for Forms 2.0 controls supporting text formatting. */
497 6 : class OOX_DLLPUBLIC AxFontDataModel : public AxControlModelBase
498 : {
499 : public:
500 : explicit AxFontDataModel( bool bSupportsAlign = true );
501 :
502 : virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue );
503 : virtual bool importBinaryModel( BinaryInputStream& rInStrm );
504 : virtual void exportBinaryModel( BinaryOutputStream& rOutStrm );
505 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
506 : virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv );
507 :
508 : /** Returns the font height in points. */
509 0 : inline sal_Int16 getFontHeight() const { return maFontData.getHeightPoints(); }
510 :
511 : public: // direct access needed for legacy VML drawing controls
512 : AxFontData maFontData; ///< The font settings.
513 :
514 : private:
515 : bool mbSupportsAlign; ///< True = UNO model supports Align property.
516 : };
517 :
518 : // ============================================================================
519 :
520 : /** Model for a Forms 2.0 command button. */
521 6 : class OOX_DLLPUBLIC AxCommandButtonModel : public AxFontDataModel
522 : {
523 : public:
524 : explicit AxCommandButtonModel();
525 :
526 : virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue );
527 : virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm );
528 : virtual bool importBinaryModel( BinaryInputStream& rInStrm );
529 : virtual void exportBinaryModel( BinaryOutputStream& rOutStrm );
530 : virtual void exportCompObj( BinaryOutputStream& rOutStrm );
531 :
532 : virtual ApiControlType getControlType() const;
533 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
534 : virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv );
535 :
536 : public: // direct access needed for legacy VML drawing controls
537 : StreamDataSequence maPictureData; ///< Binary picture stream.
538 : ::rtl::OUString maCaption; ///< Visible caption of the button.
539 : sal_uInt32 mnTextColor; ///< Text color.
540 : sal_uInt32 mnBackColor; ///< Fill color.
541 : sal_uInt32 mnFlags; ///< Various flags.
542 : sal_uInt32 mnPicturePos; ///< Position of the picture relative to text.
543 : sal_Int32 mnVerticalAlign; ///< Vertical alignment (legacy VML drawing controls only).
544 : bool mbFocusOnClick; ///< True = take focus on click.
545 : };
546 :
547 : // ============================================================================
548 :
549 : /** Model for a Forms 2.0 label. */
550 0 : class OOX_DLLPUBLIC AxLabelModel : public AxFontDataModel
551 : {
552 : public:
553 : explicit AxLabelModel();
554 :
555 : virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue );
556 : virtual bool importBinaryModel( BinaryInputStream& rInStrm );
557 : virtual void exportBinaryModel( BinaryOutputStream& rOutStrm );
558 : virtual void exportCompObj( BinaryOutputStream& rOutStrm );
559 :
560 : virtual ApiControlType getControlType() const;
561 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
562 : virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv );
563 :
564 : public: // direct access needed for legacy VML drawing controls
565 : ::rtl::OUString maCaption; ///< Visible caption of the button.
566 : sal_uInt32 mnTextColor; ///< Text color.
567 : sal_uInt32 mnBackColor; ///< Fill color.
568 : sal_uInt32 mnFlags; ///< Various flags.
569 : sal_uInt32 mnBorderColor; ///< Flat border color.
570 : sal_Int32 mnBorderStyle; ///< Flat border style.
571 : sal_Int32 mnSpecialEffect; ///< 3D border effect.
572 : sal_Int32 mnVerticalAlign; ///< Vertical alignment (legacy VML drawing controls only).
573 : };
574 :
575 : // ============================================================================
576 :
577 : /** Model for a Forms 2.0 image. */
578 0 : class OOX_DLLPUBLIC AxImageModel : public AxControlModelBase
579 : {
580 : public:
581 : explicit AxImageModel();
582 :
583 : virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue );
584 : virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm );
585 : virtual bool importBinaryModel( BinaryInputStream& rInStrm );
586 : virtual void exportBinaryModel( BinaryOutputStream& rOutStrm );
587 : virtual void exportCompObj( BinaryOutputStream& rOutStrm );
588 :
589 : virtual ApiControlType getControlType() const;
590 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
591 :
592 : private:
593 : StreamDataSequence maPictureData; ///< Binary picture stream.
594 : sal_uInt32 mnBackColor; ///< Fill color.
595 : sal_uInt32 mnFlags; ///< Various flags.
596 : sal_uInt32 mnBorderColor; ///< Flat border color.
597 : sal_Int32 mnBorderStyle; ///< Flat border style.
598 : sal_Int32 mnSpecialEffect; ///< 3D border effect.
599 : sal_Int32 mnPicSizeMode; ///< Clip, stretch, zoom.
600 : sal_Int32 mnPicAlign; ///< Anchor position of the picture.
601 : bool mbPicTiling; ///< True = picture is repeated.
602 : };
603 :
604 : // ============================================================================
605 :
606 : /** Base class for a Forms 2.0 morph data control. */
607 3 : class OOX_DLLPUBLIC AxMorphDataModelBase : public AxFontDataModel
608 : {
609 : public:
610 : explicit AxMorphDataModelBase();
611 :
612 : virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue );
613 : virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm );
614 : virtual bool importBinaryModel( BinaryInputStream& rInStrm );
615 : virtual void exportBinaryModel( BinaryOutputStream& rOutStrm );
616 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
617 :
618 : public: // direct access needed for legacy VML drawing controls
619 : StreamDataSequence maPictureData; ///< Binary picture stream.
620 : ::rtl::OUString maCaption; ///< Visible caption of the button.
621 : ::rtl::OUString maValue; ///< Current value of the control.
622 : ::rtl::OUString maGroupName; ///< Group name for option buttons.
623 : sal_uInt32 mnTextColor; ///< Text color.
624 : sal_uInt32 mnBackColor; ///< Fill color.
625 : sal_uInt32 mnFlags; ///< Various flags.
626 : sal_uInt32 mnPicturePos; ///< Position of the picture relative to text.
627 : sal_uInt32 mnBorderColor; ///< Flat border color.
628 : sal_Int32 mnBorderStyle; ///< Flat border style.
629 : sal_Int32 mnSpecialEffect; ///< 3D border effect.
630 : sal_Int32 mnDisplayStyle; ///< Type of the morph control.
631 : sal_Int32 mnMultiSelect; ///< Selection mode.
632 : sal_Int32 mnScrollBars; ///< Horizontal/vertical scroll bar.
633 : sal_Int32 mnMatchEntry; ///< Auto completion mode.
634 : sal_Int32 mnShowDropButton; ///< When to show the dropdown button.
635 : sal_Int32 mnMaxLength; ///< Maximum character count.
636 : sal_Int32 mnPasswordChar; ///< Password character in edit fields.
637 : sal_Int32 mnListRows; ///< Number of rows in dropdown box.
638 : sal_Int32 mnVerticalAlign; ///< Vertical alignment (legacy VML drawing controls only).
639 : };
640 :
641 : // ============================================================================
642 :
643 : /** Model for a Forms 2.0 toggle button. */
644 0 : class OOX_DLLPUBLIC AxToggleButtonModel : public AxMorphDataModelBase
645 : {
646 : public:
647 : explicit AxToggleButtonModel();
648 :
649 : virtual ApiControlType getControlType() const;
650 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
651 : virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv );
652 : virtual void exportCompObj( BinaryOutputStream& rOutStrm );
653 : };
654 :
655 : // ============================================================================
656 :
657 : /** Model for a Forms 2.0 check box. */
658 2 : class OOX_DLLPUBLIC AxCheckBoxModel : public AxMorphDataModelBase
659 : {
660 : public:
661 : explicit AxCheckBoxModel();
662 :
663 : virtual ApiControlType getControlType() const;
664 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
665 : virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv );
666 : virtual void exportCompObj( BinaryOutputStream& rOutStrm );
667 : };
668 :
669 : // ============================================================================
670 :
671 : /** Model for a Forms 2.0 option button. */
672 0 : class OOX_DLLPUBLIC AxOptionButtonModel : public AxMorphDataModelBase
673 : {
674 : public:
675 : explicit AxOptionButtonModel();
676 :
677 : /** Returns the group name used to goup several option buttons gogether. */
678 0 : inline const ::rtl::OUString& getGroupName() const { return maGroupName; }
679 :
680 : virtual ApiControlType getControlType() const;
681 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
682 : virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv );
683 : virtual void exportCompObj( BinaryOutputStream& rOutStrm );
684 : };
685 :
686 : // ============================================================================
687 :
688 : /** Model for a Forms 2.0 text box. */
689 4 : class OOX_DLLPUBLIC AxTextBoxModel : public AxMorphDataModelBase
690 : {
691 : public:
692 : explicit AxTextBoxModel();
693 :
694 : virtual ApiControlType getControlType() const;
695 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
696 : virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv );
697 : virtual void exportCompObj( BinaryOutputStream& rOutStrm );
698 : };
699 :
700 : // ============================================================================
701 :
702 : /** Model for a numeric field (legacy drawing controls only). */
703 0 : class OOX_DLLPUBLIC AxNumericFieldModel : public AxMorphDataModelBase
704 : {
705 : public:
706 : explicit AxNumericFieldModel();
707 :
708 : virtual ApiControlType getControlType() const;
709 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
710 : virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv );
711 : virtual void exportCompObj( BinaryOutputStream& rOutStrm );
712 : };
713 :
714 : // ============================================================================
715 :
716 : /** Model for a Forms 2.0 list box. */
717 0 : class OOX_DLLPUBLIC AxListBoxModel : public AxMorphDataModelBase
718 : {
719 : public:
720 : explicit AxListBoxModel();
721 :
722 : virtual ApiControlType getControlType() const;
723 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
724 : virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv );
725 : virtual void exportCompObj( BinaryOutputStream& rOutStrm );
726 : };
727 :
728 : // ============================================================================
729 :
730 : /** Model for a Forms 2.0 combo box. */
731 0 : class OOX_DLLPUBLIC AxComboBoxModel : public AxMorphDataModelBase
732 : {
733 : public:
734 : explicit AxComboBoxModel();
735 :
736 : virtual ApiControlType getControlType() const;
737 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
738 : virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv );
739 : virtual void exportCompObj( BinaryOutputStream& rOutStrm );
740 : };
741 :
742 : // ============================================================================
743 :
744 : /** Model for a Forms 2.0 spin button. */
745 0 : class OOX_DLLPUBLIC AxSpinButtonModel : public AxControlModelBase
746 : {
747 : public:
748 : explicit AxSpinButtonModel();
749 :
750 : virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue );
751 : virtual bool importBinaryModel( BinaryInputStream& rInStrm );
752 : virtual void exportBinaryModel( BinaryOutputStream& rOutStrm );
753 :
754 : virtual ApiControlType getControlType() const;
755 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
756 : virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv );
757 : virtual void exportCompObj( BinaryOutputStream& rOutStrm );
758 :
759 : public: // direct access needed for legacy VML drawing controls
760 : sal_uInt32 mnArrowColor; ///< Button arrow color.
761 : sal_uInt32 mnBackColor; ///< Fill color.
762 : sal_uInt32 mnFlags; ///< Various flags.
763 : sal_Int32 mnOrientation; ///< Orientation of the buttons.
764 : sal_Int32 mnMin; ///< Minimum of the value range.
765 : sal_Int32 mnMax; ///< Maximum of the value range.
766 : sal_Int32 mnPosition; ///< Value of the spin button.
767 : sal_Int32 mnSmallChange; ///< Increment step size.
768 : sal_Int32 mnDelay; ///< Repeat delay in milliseconds.
769 : };
770 :
771 : // ============================================================================
772 :
773 : /** Model for a Forms 2.0 scroll bar. */
774 0 : class OOX_DLLPUBLIC AxScrollBarModel : public AxControlModelBase
775 : {
776 : public:
777 : explicit AxScrollBarModel();
778 :
779 : virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue );
780 : virtual bool importBinaryModel( BinaryInputStream& rInStrm );
781 : virtual void exportBinaryModel( BinaryOutputStream& rOutStrm );
782 : virtual void exportCompObj( BinaryOutputStream& rOutStrm );
783 :
784 : virtual ApiControlType getControlType() const;
785 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
786 : virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv );
787 :
788 : public: // direct access needed for legacy VML drawing controls
789 : sal_uInt32 mnArrowColor; ///< Button arrow color.
790 : sal_uInt32 mnBackColor; ///< Fill color.
791 : sal_uInt32 mnFlags; ///< Various flags.
792 : sal_Int32 mnOrientation; ///< Orientation of the buttons.
793 : sal_Int32 mnPropThumb; ///< Proportional thumb size.
794 : sal_Int32 mnMin; ///< Minimum of the value range.
795 : sal_Int32 mnMax; ///< Maximum of the value range.
796 : sal_Int32 mnPosition; ///< Value of the spin button.
797 : sal_Int32 mnSmallChange; ///< Increment step size (buttons).
798 : sal_Int32 mnLargeChange; ///< Increment step size (thumb).
799 : sal_Int32 mnDelay; ///< Repeat delay in milliseconds.
800 : };
801 :
802 : // ============================================================================
803 :
804 : typedef ::std::vector< ::rtl::OUString > AxClassTable;
805 :
806 : /** Base class for ActiveX container controls. */
807 0 : class OOX_DLLPUBLIC AxContainerModelBase : public AxFontDataModel
808 : {
809 : public:
810 : explicit AxContainerModelBase( bool bFontSupport = false );
811 :
812 : /** Allows to set single properties specified by XML token identifier. */
813 : virtual void importProperty( sal_Int32 nPropId, const ::rtl::OUString& rValue );
814 : /** Reads the leading structure in the 'f' stream containing the model for
815 : this control. */
816 : virtual bool importBinaryModel( BinaryInputStream& rInStrm );
817 : /** Converts font settings if supported. */
818 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
819 :
820 : /** Reads the class table structure for embedded controls following the own
821 : model from the 'f' stream. */
822 : bool importClassTable( BinaryInputStream& rInStrm, AxClassTable& orClassTable );
823 :
824 : public: // direct access needed for legacy VML drawing controls
825 : StreamDataSequence maPictureData; ///< Binary picture stream.
826 : ::rtl::OUString maCaption; ///< Visible caption of the form.
827 : AxPairData maLogicalSize; ///< Logical form size (scroll area).
828 : AxPairData maScrollPos; ///< Scroll position.
829 : sal_uInt32 mnBackColor; ///< Fill color.
830 : sal_uInt32 mnTextColor; ///< Text color.
831 : sal_uInt32 mnFlags; ///< Various flags.
832 : sal_uInt32 mnBorderColor; ///< Flat border color.
833 : sal_Int32 mnBorderStyle; ///< Flat border style.
834 : sal_Int32 mnScrollBars; ///< Horizontal/vertical scroll bar.
835 : sal_Int32 mnCycleType; ///< Cycle in all forms or in this form.
836 : sal_Int32 mnSpecialEffect; ///< 3D border effect.
837 : sal_Int32 mnPicAlign; ///< Anchor position of the picture.
838 : sal_Int32 mnPicSizeMode; ///< Clip, stretch, zoom.
839 : bool mbPicTiling; ///< True = picture is repeated.
840 : bool mbFontSupport; ///< True = control supports the font property.
841 : };
842 :
843 : typedef ::boost::shared_ptr< AxContainerModelBase > AxContainerModelRef;
844 :
845 : // ============================================================================
846 :
847 : /** Model for a Forms 2.0 frame control. */
848 0 : class OOX_DLLPUBLIC AxFrameModel : public AxContainerModelBase
849 : {
850 : public:
851 : explicit AxFrameModel();
852 :
853 : virtual ApiControlType getControlType() const;
854 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
855 : };
856 :
857 : // ============================================================================
858 :
859 :
860 : /** Model for a Forms 2.0 user form. */
861 0 : class OOX_DLLPUBLIC AxUserFormModel : public AxContainerModelBase
862 : {
863 : public:
864 : explicit AxUserFormModel();
865 :
866 : virtual ApiControlType getControlType() const;
867 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
868 : };
869 :
870 0 : class HtmlSelectModel : public AxListBoxModel
871 : {
872 : com::sun::star::uno::Sequence< rtl::OUString > msListData;
873 : com::sun::star::uno::Sequence< sal_Int16 > msIndices;
874 : public:
875 : HtmlSelectModel();
876 : virtual bool importBinaryModel( BinaryInputStream& rInStrm );
877 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
878 : };
879 :
880 0 : class HtmlTextBoxModel : public AxTextBoxModel
881 : {
882 : public:
883 : explicit HtmlTextBoxModel();
884 : virtual bool importBinaryModel( BinaryInputStream& rInStrm );
885 : };
886 : // ============================================================================
887 :
888 : /** A form control embedded in a document draw page. Contains a specific model
889 : structure according to the type of the control. */
890 1 : class OOX_DLLPUBLIC EmbeddedControl
891 : {
892 : public:
893 : explicit EmbeddedControl( const ::rtl::OUString& rName );
894 : virtual ~EmbeddedControl();
895 :
896 : /** Creates and returns the internal control model of the specified type. */
897 : template< typename ModelType >
898 : inline ModelType& createModel();
899 :
900 : /** Creates and returns the internal control model of the specified type. */
901 : template< typename ModelType, typename ParamType >
902 : inline ModelType& createModel( const ParamType& rParam );
903 :
904 : /** Creates and returns the internal control model according to the passed
905 : MS class identifier. */
906 : ControlModelBase* createModelFromGuid( const ::rtl::OUString& rClassId );
907 :
908 : /** Returns true, if the internal control model exists. */
909 1 : inline bool hasModel() const { return mxModel.get() != 0; }
910 : /** Returns read-only access to the internal control model. */
911 : inline const ControlModelBase* getModel() const { return mxModel.get(); }
912 : /** Returns read/write access to the internal control model. */
913 1 : inline ControlModelBase* getModel() { return mxModel.get(); }
914 :
915 : /** Returns the UNO service name needed to construct the control model. */
916 : ::rtl::OUString getServiceName() const;
917 :
918 : /** Converts all control properties and inserts them into the passed model. */
919 : bool convertProperties(
920 : const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel,
921 : const ControlConverter& rConv ) const;
922 :
923 : bool convertFromProperties(
924 : const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel,
925 : const ControlConverter& rConv );
926 :
927 : private:
928 : ControlModelRef mxModel; ///< Control model containing the properties.
929 : ::rtl::OUString maName; ///< Name of the control.
930 : };
931 :
932 : // ----------------------------------------------------------------------------
933 :
934 : template< typename ModelType >
935 6 : inline ModelType& EmbeddedControl::createModel()
936 : {
937 6 : ::boost::shared_ptr< ModelType > xModel( new ModelType );
938 6 : mxModel = xModel;
939 6 : xModel->setFormComponentMode();
940 6 : return *xModel;
941 : }
942 :
943 : template< typename ModelType, typename ParamType >
944 0 : inline ModelType& EmbeddedControl::createModel( const ParamType& rParam )
945 : {
946 0 : ::boost::shared_ptr< ModelType > xModel( new ModelType( rParam ) );
947 0 : mxModel = xModel;
948 0 : xModel->setFormComponentMode();
949 0 : return *xModel;
950 : }
951 :
952 : // ============================================================================
953 :
954 : /** A wrapper for a control form embedded directly in a draw page. */
955 1 : class EmbeddedForm
956 : {
957 : public:
958 : explicit EmbeddedForm(
959 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxDocModel,
960 : const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& rxDrawPage,
961 : const GraphicHelper& rGraphicHelper,
962 : bool bDefaultColorBgr = true );
963 :
964 : /** Converts the passed control and inserts the control model into the form.
965 : @return The API control model, if conversion was successful. */
966 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >
967 : convertAndInsert( const EmbeddedControl& rControl, sal_Int32& rnCtrlIndex );
968 :
969 : /** Returns the XIndexContainer interface of the UNO control form, if existing. */
970 : inline ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >
971 0 : getXForm() const { return mxFormIC; }
972 :
973 : private:
974 : /** Creates the form that will hold the form controls. */
975 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >
976 : createXForm();
977 :
978 : private:
979 : ControlConverter maControlConv;
980 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxModelFactory;
981 : ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormsSupplier > mxFormsSupp;
982 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > mxFormIC;
983 : };
984 :
985 : // ============================================================================
986 :
987 : } // namespace ole
988 : } // namespace oox
989 :
990 : #endif
991 :
992 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|