1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_OOX_OLE_AXCONTROL_HXX
21 #define INCLUDED_OOX_OLE_AXCONTROL_HXX
23 #include <oox/helper/binarystreambase.hxx>
24 #include <oox/helper/propertyset.hxx>
25 #include <oox/ole/axbinaryreader.hxx>
26 #include <oox/ole/olehelper.hxx>
27 #include <oox/dllapi.h>
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
; }
40 class BinaryInputStream
;
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}"
54 const sal_uInt16 COMCTL_VERSION_50
= 5;
55 const sal_uInt16 COMCTL_VERSION_60
= 6;
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}"
72 // Html control GUID(s)
74 #define HTML_GUID_SELECT "{5512D122-5CC6-11CF-8d67-00aa00bdce1d}"
75 #define HTML_GUID_TEXTBOX "{5512D124-5CC6-11CF-8d67-00aa00bdce1d}"
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;
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;
105 const sal_Int32 AX_BORDERSTYLE_NONE
= 0;
106 const sal_Int32 AX_BORDERSTYLE_SINGLE
= 1;
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;
114 const sal_Int32 AX_PICSIZE_CLIP
= 0;
115 const sal_Int32 AX_PICSIZE_STRETCH
= 1;
116 const sal_Int32 AX_PICSIZE_ZOOM
= 3;
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;
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;
132 const sal_Int32 AX_SELECTION_SINGLE
= 0;
133 const sal_Int32 AX_SELECTION_MULTI
= 1;
134 const sal_Int32 AX_SELECTION_EXTENDED
= 2;
136 const sal_Int32 AX_SHOWDROPBUTTON_NEVER
= 0;
137 const sal_Int32 AX_SHOWDROPBUTTON_FOCUS
= 1;
138 const sal_Int32 AX_SHOWDROPBUTTON_ALWAYS
= 2;
140 const sal_Int32 AX_SCROLLBAR_NONE
= 0x00;
141 const sal_Int32 AX_SCROLLBAR_HORIZONTAL
= 0x01;
142 const sal_Int32 AX_SCROLLBAR_VERTICAL
= 0x02;
146 /** Enumerates all UNO API control types supported by these filters. */
150 API_CONTROL_FIXEDTEXT
,
152 API_CONTROL_CHECKBOX
,
153 API_CONTROL_RADIOBUTTON
,
157 API_CONTROL_COMBOBOX
,
158 API_CONTROL_SPINBUTTON
,
159 API_CONTROL_SCROLLBAR
,
160 API_CONTROL_TABSTRIP
, //11
161 API_CONTROL_PROGRESSBAR
,
162 API_CONTROL_GROUPBOX
,
163 API_CONTROL_FRAME
, // 14
164 API_CONTROL_PAGE
, // 15
165 API_CONTROL_MULTIPAGE
, // 16
166 API_CONTROL_DIALOG
// 17
171 /** Specifies how a form control supports transparent background. */
172 enum ApiTransparencyMode
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.
179 /** Specifies how a form control supports the DefaultState property. */
180 enum ApiDefaultStateMode
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.
189 /** A base class with useful helper functions for something that is able to
190 convert ActiveX and ComCtl form controls.
192 class OOX_DLLPUBLIC ControlConverter
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();
201 // Generic conversion -----------------------------------------------------
203 /** Converts the passed position in 1/100 mm to UNO properties. */
204 void convertPosition(
205 PropertyMap
& rPropMap
,
206 const AxPairData
& rPos
) const;
208 /** Converts the passed size in 1/100 mm to UNO properties. */
210 PropertyMap
& rPropMap
,
211 const AxPairData
& rSize
) const;
213 /** Converts the passed encoded OLE color to UNO properties. */
215 PropertyMap
& rPropMap
,
217 sal_uInt32 nOleColor
) const;
219 static void convertToMSColor(
220 PropertySet
& rPropSet
,
222 sal_uInt32
& nOleColor
,
223 sal_uInt32 nDefault
= 0 );
226 /** Converts the passed StdPic picture stream to UNO properties. */
228 PropertyMap
& rPropMap
,
229 const StreamDataSequence
& rPicData
) const;
231 /** Converts the control orientation to UNO properties. */
232 static void convertOrientation(
233 PropertyMap
& rPropMap
,
236 static void convertToMSOrientation(
237 PropertySet
& rPropMap
,
240 /** Converts the vertical alignment to UNO properties. */
241 static void convertVerticalAlign(
242 PropertyMap
& rPropMap
,
243 sal_Int32 nVerticalAlign
);
245 /** Converts common scrollbar settings to UNO properties. */
246 static void convertScrollBar(
247 PropertyMap
& rPropMap
,
248 sal_Int32 nMin
, sal_Int32 nMax
, sal_Int32 nPosition
,
249 sal_Int32 nSmallChange
, sal_Int32 nLargeChange
, bool bAwtModel
);
251 /** Converts scrollability settings to UNO properties. */
252 void convertScrollabilitySettings(
253 PropertyMap
& rPropMap
,
254 const AxPairData
& rScrollPos
, const AxPairData
& rScrollArea
,
255 sal_Int32 nScrollBars
) const;
257 /** Binds the passed control model to the passed data sources. The
258 implementation will check which source types are supported. */
260 const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlModel
>& rxCtrlModel
,
261 const OUString
& rCtrlSource
,
262 const OUString
& rRowSource
,
263 sal_Int32 nRefSheet
= 0 ) const;
265 // ActiveX (Forms 2.0) specific conversion --------------------------------
267 /** Converts the Forms 2.0 background formatting to UNO properties. */
268 void convertAxBackground(
269 PropertyMap
& rPropMap
,
270 sal_uInt32 nBackColor
,
272 ApiTransparencyMode eTranspMode
) const;
274 /** Converts the Forms 2.0 border formatting to UNO properties. */
275 void convertAxBorder(
276 PropertyMap
& rPropMap
,
277 sal_uInt32 nBorderColor
,
278 sal_Int32 nBorderStyle
,
279 sal_Int32 nSpecialEffect
) const;
281 static void convertToAxBorder(
282 PropertySet
& rPropSet
,
283 sal_uInt32
& nBorderColor
,
284 sal_Int32
& nBorderStyle
,
285 sal_Int32
& nSpecialEffect
);
287 /** Converts the Forms 2.0 special effect to UNO properties. */
288 static void convertAxVisualEffect(
289 PropertyMap
& rPropMap
,
290 sal_Int32 nSpecialEffect
);
292 static void convertToAxVisualEffect(
293 PropertySet
& rPropSet
,
294 sal_Int32
& nSpecialEffect
);
296 /** Converts the passed picture stream and Forms 2.0 position to UNO
298 void convertAxPicture(
299 PropertyMap
& rPropMap
,
300 const StreamDataSequence
& rPicData
,
301 sal_uInt32 nPicPos
) const;
303 /** Converts the passed picture stream and Forms 2.0 position to UNO
305 void convertAxPicture(
306 PropertyMap
& rPropMap
,
307 const StreamDataSequence
& rPicData
,
308 sal_Int32 nPicSizeMode
,
310 bool bPicTiling
) const;
312 /** Converts the Forms 2.0 value for checked/unchecked/dontknow to UNO
314 static void convertAxState(
315 PropertyMap
& rPropMap
,
316 const OUString
& rValue
,
317 sal_Int32 nMultiSelect
,
318 ApiDefaultStateMode eDefStateMode
,
321 static void convertToAxState(
322 PropertySet
& rPropSet
,
324 sal_Int32
& nMultiSelect
,
325 ApiDefaultStateMode eDefStateMode
,
328 /** Converts the Forms 2.0 control orientation to UNO properties. */
329 static void convertAxOrientation(
330 PropertyMap
& rPropMap
,
331 const AxPairData
& rSize
,
332 sal_Int32 nOrientation
);
334 static void convertToAxOrientation(
335 PropertySet
& rPropSet
,
336 const AxPairData
& rSize
,
337 sal_Int32
& nOrientation
);
340 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
> mxDocModel
;
341 const GraphicHelper
& mrGraphicHelper
;
342 mutable PropertySet maAddressConverter
;
343 mutable PropertySet maRangeConverter
;
344 bool mbDefaultColorBgr
;
349 /** Base class for all models of form controls. */
350 class OOX_DLLPUBLIC ControlModelBase
353 explicit ControlModelBase();
354 virtual ~ControlModelBase();
356 /** Sets this control model to AWT model mode. */
357 void setAwtModelMode() { mbAwtModel
= true; }
358 /** Sets this control model to form component mode. */
359 void setFormComponentMode() { mbAwtModel
= false; }
361 /** Returns the UNO service name used to construct the AWT control model,
362 or the control form component. */
363 OUString
getServiceName() const;
365 /** Derived classes set specific OOXML properties at the model structure. */
366 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
);
367 /** Derived classes set binary data (picture, mouse icon) at the model structure. */
368 virtual void importPictureData( sal_Int32 nPropId
, BinaryInputStream
& rInStrm
);
369 /** Derived classes import a form control model from the passed input stream. */
370 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) = 0;
371 /** Derived classes export a form control model to the passed output stream. */
372 virtual void exportBinaryModel( BinaryOutputStream
& /*rOutStrm*/ ) {}
373 /** Derived classes export CompObjStream contents. */
374 virtual void exportCompObj( BinaryOutputStream
& /*rOutStrm*/ ) {}
375 /** Derived classes return the UNO control type enum value. */
376 virtual ApiControlType
getControlType() const = 0;
377 /** Derived classes convert all control properties. */
378 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const;
379 /** Derived classes convert from uno control properties to equiv. MS values. */
380 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
);
382 /** Converts the control size to UNO properties. */
383 void convertSize( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const;
385 public: // direct access needed for legacy VML drawing controls
386 AxPairData maSize
; ///< Size of the control in 1/100 mm.
389 bool mbAwtModel
; ///< True = AWT control model, false = form component.
392 typedef std::shared_ptr
< ControlModelBase
> ControlModelRef
;
396 /** Base class for all models of ComCtl form controls. */
397 class ComCtlModelBase
: public ControlModelBase
400 explicit ComCtlModelBase(
401 sal_uInt32 nDataPartId5
, sal_uInt32 nDataPartId6
, sal_uInt16 nVersion
,
402 bool bCommonPart
, bool bComplexPart
);
404 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) SAL_OVERRIDE
;
405 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const SAL_OVERRIDE
;
408 virtual void importControlData( BinaryInputStream
& rInStrm
) = 0;
411 /** Returns the data part identifier according to the model version. */
412 sal_uInt32
getDataPartId() const;
414 static bool readPartHeader( BinaryInputStream
& rInStrm
,
415 sal_uInt32 nExpPartId
,
416 sal_uInt16 nExpMajor
= SAL_MAX_UINT16
,
417 sal_uInt16 nExpMinor
= SAL_MAX_UINT16
);
419 bool importSizePart( BinaryInputStream
& rInStrm
);
420 bool importCommonPart( BinaryInputStream
& rInStrm
, sal_uInt32 nPartSize
);
421 bool importComplexPart( BinaryInputStream
& rInStrm
);
424 StdFontInfo maFontData
; ///< Font formatting.
425 StreamDataSequence maMouseIcon
; ///< Binary picture stream for mouse icon.
426 sal_uInt32 mnFlags
; ///< Common flags for ComCtl controls.
427 const sal_uInt16 mnVersion
; ///< Current version of the ComCtl control model.
430 sal_uInt32 mnDataPartId5
; ///< Identifier for version 5.0 control data.
431 sal_uInt32 mnDataPartId6
; ///< Identifier for version 6.0 control data.
432 bool mbCommonPart
; ///< True = the COMCTL_COMMONDATA part exists.
433 bool mbComplexPart
; ///< True = the COMCTL_COMPLEXDATA part exists.
438 /** Model for a ComCtl scroll bar. */
439 class ComCtlScrollBarModel
: public ComCtlModelBase
442 explicit ComCtlScrollBarModel( sal_uInt16 nVersion
);
444 virtual ApiControlType
getControlType() const SAL_OVERRIDE
;
445 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const SAL_OVERRIDE
;
448 virtual void importControlData( BinaryInputStream
& rInStrm
) SAL_OVERRIDE
;
451 sal_uInt32 mnScrollBarFlags
; ///< Special flags for scroll bar model.
452 sal_Int32 mnLargeChange
; ///< Increment step size (thumb).
453 sal_Int32 mnSmallChange
; ///< Increment step size (buttons).
454 sal_Int32 mnMin
; ///< Minimum of the value range.
455 sal_Int32 mnMax
; ///< Maximum of the value range.
456 sal_Int32 mnPosition
; ///< Value of the spin button.
461 /** Model for a ComCtl progress bar. */
462 class ComCtlProgressBarModel
: public ComCtlModelBase
465 explicit ComCtlProgressBarModel( sal_uInt16 nVersion
);
467 virtual ApiControlType
getControlType() const SAL_OVERRIDE
;
468 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const SAL_OVERRIDE
;
471 virtual void importControlData( BinaryInputStream
& rInStrm
) SAL_OVERRIDE
;
474 float mfMin
; ///< Minimum of the value range.
475 float mfMax
; ///< Maximum of the value range.
476 sal_uInt16 mnVertical
; ///< 0 = horizontal, 1 = vertical.
477 sal_uInt16 mnSmooth
; ///< 0 = progress blocks, 1 = pixel resolution.
482 /** Base class for all models of Form 2.0 form controls. */
483 class OOX_DLLPUBLIC AxControlModelBase
: public ControlModelBase
486 explicit AxControlModelBase();
488 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) SAL_OVERRIDE
;
493 /** Base class for Forms 2.0 controls supporting text formatting. */
494 class OOX_DLLPUBLIC AxFontDataModel
: public AxControlModelBase
497 explicit AxFontDataModel( bool bSupportsAlign
= true );
499 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) SAL_OVERRIDE
;
500 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) SAL_OVERRIDE
;
501 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) SAL_OVERRIDE
;
502 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const SAL_OVERRIDE
;
503 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) SAL_OVERRIDE
;
505 /** Returns the font height in points. */
506 sal_Int16
getFontHeight() const { return maFontData
.getHeightPoints(); }
508 public: // direct access needed for legacy VML drawing controls
509 AxFontData maFontData
; ///< The font settings.
512 bool mbSupportsAlign
; ///< True = UNO model supports Align property.
517 /** Model for a Forms 2.0 command button. */
518 class OOX_DLLPUBLIC AxCommandButtonModel
: public AxFontDataModel
521 explicit AxCommandButtonModel();
523 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) SAL_OVERRIDE
;
524 virtual void importPictureData( sal_Int32 nPropId
, BinaryInputStream
& rInStrm
) SAL_OVERRIDE
;
525 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) SAL_OVERRIDE
;
526 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) SAL_OVERRIDE
;
527 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) SAL_OVERRIDE
;
529 virtual ApiControlType
getControlType() const SAL_OVERRIDE
;
530 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const SAL_OVERRIDE
;
531 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) SAL_OVERRIDE
;
533 public: // direct access needed for legacy VML drawing controls
534 StreamDataSequence maPictureData
; ///< Binary picture stream.
535 OUString maCaption
; ///< Visible caption of the button.
536 sal_uInt32 mnTextColor
; ///< Text color.
537 sal_uInt32 mnBackColor
; ///< Fill color.
538 sal_uInt32 mnFlags
; ///< Various flags.
539 sal_uInt32 mnPicturePos
; ///< Position of the picture relative to text.
540 sal_Int32 mnVerticalAlign
; ///< Vertical alignment (legacy VML drawing controls only).
541 bool mbFocusOnClick
; ///< True = take focus on click.
546 /** Model for a Forms 2.0 label. */
547 class OOX_DLLPUBLIC AxLabelModel
: public AxFontDataModel
550 explicit AxLabelModel();
552 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) SAL_OVERRIDE
;
553 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) SAL_OVERRIDE
;
554 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) SAL_OVERRIDE
;
555 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) SAL_OVERRIDE
;
557 virtual ApiControlType
getControlType() const SAL_OVERRIDE
;
558 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const SAL_OVERRIDE
;
559 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) SAL_OVERRIDE
;
561 public: // direct access needed for legacy VML drawing controls
562 OUString maCaption
; ///< Visible caption of the button.
563 sal_uInt32 mnTextColor
; ///< Text color.
564 sal_uInt32 mnBackColor
; ///< Fill color.
565 sal_uInt32 mnFlags
; ///< Various flags.
566 sal_uInt32 mnBorderColor
; ///< Flat border color.
567 sal_Int32 mnBorderStyle
; ///< Flat border style.
568 sal_Int32 mnSpecialEffect
; ///< 3D border effect.
569 sal_Int32 mnVerticalAlign
; ///< Vertical alignment (legacy VML drawing controls only).
574 /** Model for a Forms 2.0 image. */
575 class OOX_DLLPUBLIC AxImageModel
: public AxControlModelBase
578 explicit AxImageModel();
580 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) SAL_OVERRIDE
;
581 virtual void importPictureData( sal_Int32 nPropId
, BinaryInputStream
& rInStrm
) SAL_OVERRIDE
;
582 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) SAL_OVERRIDE
;
583 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) SAL_OVERRIDE
;
584 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) SAL_OVERRIDE
;
586 virtual ApiControlType
getControlType() const SAL_OVERRIDE
;
587 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const SAL_OVERRIDE
;
590 StreamDataSequence maPictureData
; ///< Binary picture stream.
591 sal_uInt32 mnBackColor
; ///< Fill color.
592 sal_uInt32 mnFlags
; ///< Various flags.
593 sal_uInt32 mnBorderColor
; ///< Flat border color.
594 sal_Int32 mnBorderStyle
; ///< Flat border style.
595 sal_Int32 mnSpecialEffect
; ///< 3D border effect.
596 sal_Int32 mnPicSizeMode
; ///< Clip, stretch, zoom.
597 sal_Int32 mnPicAlign
; ///< Anchor position of the picture.
598 bool mbPicTiling
; ///< True = picture is repeated.
601 class OOX_DLLPUBLIC AxTabStripModel
: public AxFontDataModel
604 explicit AxTabStripModel();
606 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) SAL_OVERRIDE
;
608 virtual ApiControlType
getControlType() const SAL_OVERRIDE
;
611 sal_uInt32 mnListIndex
;
612 sal_uInt32 mnTabStyle
;
613 sal_uInt32 mnTabData
;
614 sal_uInt32 mnVariousPropertyBits
;
615 std::vector
< ::rtl::OUString
> maItems
; // captions for each tab
616 std::vector
< ::rtl::OUString
> maTabNames
; // names for each tab
621 /** Base class for a Forms 2.0 morph data control. */
622 class OOX_DLLPUBLIC AxMorphDataModelBase
: public AxFontDataModel
625 explicit AxMorphDataModelBase();
627 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) SAL_OVERRIDE
;
628 virtual void importPictureData( sal_Int32 nPropId
, BinaryInputStream
& rInStrm
) SAL_OVERRIDE
;
629 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) SAL_OVERRIDE
;
630 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) SAL_OVERRIDE
;
631 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const SAL_OVERRIDE
;
633 public: // direct access needed for legacy VML drawing controls
634 StreamDataSequence maPictureData
; ///< Binary picture stream.
635 OUString maCaption
; ///< Visible caption of the button.
636 OUString maValue
; ///< Current value of the control.
637 OUString maGroupName
; ///< Group name for option buttons.
638 sal_uInt32 mnTextColor
; ///< Text color.
639 sal_uInt32 mnBackColor
; ///< Fill color.
640 sal_uInt32 mnFlags
; ///< Various flags.
641 sal_uInt32 mnPicturePos
; ///< Position of the picture relative to text.
642 sal_uInt32 mnBorderColor
; ///< Flat border color.
643 sal_Int32 mnBorderStyle
; ///< Flat border style.
644 sal_Int32 mnSpecialEffect
; ///< 3D border effect.
645 sal_Int32 mnDisplayStyle
; ///< Type of the morph control.
646 sal_Int32 mnMultiSelect
; ///< Selection mode.
647 sal_Int32 mnScrollBars
; ///< Horizontal/vertical scroll bar.
648 sal_Int32 mnMatchEntry
; ///< Auto completion mode.
649 sal_Int32 mnShowDropButton
; ///< When to show the dropdown button.
650 sal_Int32 mnMaxLength
; ///< Maximum character count.
651 sal_Int32 mnPasswordChar
; ///< Password character in edit fields.
652 sal_Int32 mnListRows
; ///< Number of rows in dropdown box.
653 sal_Int32 mnVerticalAlign
; ///< Vertical alignment (legacy VML drawing controls only).
658 /** Model for a Forms 2.0 toggle button. */
659 class OOX_DLLPUBLIC AxToggleButtonModel
: public AxMorphDataModelBase
662 explicit AxToggleButtonModel();
664 virtual ApiControlType
getControlType() const SAL_OVERRIDE
;
665 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const SAL_OVERRIDE
;
666 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) SAL_OVERRIDE
;
667 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) SAL_OVERRIDE
;
672 /** Model for a Forms 2.0 check box. */
673 class OOX_DLLPUBLIC AxCheckBoxModel
: public AxMorphDataModelBase
676 explicit AxCheckBoxModel();
678 virtual ApiControlType
getControlType() const SAL_OVERRIDE
;
679 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const SAL_OVERRIDE
;
680 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) SAL_OVERRIDE
;
681 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) SAL_OVERRIDE
;
686 /** Model for a Forms 2.0 option button. */
687 class OOX_DLLPUBLIC AxOptionButtonModel
: public AxMorphDataModelBase
690 explicit AxOptionButtonModel();
692 /** Returns the group name used to goup several option buttons gogether. */
693 const OUString
& getGroupName() const { return maGroupName
; }
695 virtual ApiControlType
getControlType() const SAL_OVERRIDE
;
696 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const SAL_OVERRIDE
;
697 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) SAL_OVERRIDE
;
698 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) SAL_OVERRIDE
;
703 /** Model for a Forms 2.0 text box. */
704 class OOX_DLLPUBLIC AxTextBoxModel
: public AxMorphDataModelBase
707 explicit AxTextBoxModel();
709 virtual ApiControlType
getControlType() const SAL_OVERRIDE
;
710 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const SAL_OVERRIDE
;
711 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) SAL_OVERRIDE
;
712 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) SAL_OVERRIDE
;
717 /** Model for a numeric field (legacy drawing controls only). */
718 class OOX_DLLPUBLIC AxNumericFieldModel
: public AxMorphDataModelBase
721 explicit AxNumericFieldModel();
723 virtual ApiControlType
getControlType() const SAL_OVERRIDE
;
724 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const SAL_OVERRIDE
;
725 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) SAL_OVERRIDE
;
726 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) SAL_OVERRIDE
;
731 /** Model for a Forms 2.0 list box. */
732 class OOX_DLLPUBLIC AxListBoxModel
: public AxMorphDataModelBase
735 explicit AxListBoxModel();
737 virtual ApiControlType
getControlType() const SAL_OVERRIDE
;
738 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const SAL_OVERRIDE
;
739 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) SAL_OVERRIDE
;
740 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) SAL_OVERRIDE
;
745 /** Model for a Forms 2.0 combo box. */
746 class OOX_DLLPUBLIC AxComboBoxModel
: public AxMorphDataModelBase
749 explicit AxComboBoxModel();
751 virtual ApiControlType
getControlType() const SAL_OVERRIDE
;
752 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const SAL_OVERRIDE
;
753 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) SAL_OVERRIDE
;
754 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) SAL_OVERRIDE
;
759 /** Model for a Forms 2.0 spin button. */
760 class OOX_DLLPUBLIC AxSpinButtonModel
: public AxControlModelBase
763 explicit AxSpinButtonModel();
765 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) SAL_OVERRIDE
;
766 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) SAL_OVERRIDE
;
767 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) SAL_OVERRIDE
;
769 virtual ApiControlType
getControlType() const SAL_OVERRIDE
;
770 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const SAL_OVERRIDE
;
771 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) SAL_OVERRIDE
;
772 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) SAL_OVERRIDE
;
774 public: // direct access needed for legacy VML drawing controls
775 sal_uInt32 mnArrowColor
; ///< Button arrow color.
776 sal_uInt32 mnBackColor
; ///< Fill color.
777 sal_uInt32 mnFlags
; ///< Various flags.
778 sal_Int32 mnOrientation
; ///< Orientation of the buttons.
779 sal_Int32 mnMin
; ///< Minimum of the value range.
780 sal_Int32 mnMax
; ///< Maximum of the value range.
781 sal_Int32 mnPosition
; ///< Value of the spin button.
782 sal_Int32 mnSmallChange
; ///< Increment step size.
783 sal_Int32 mnDelay
; ///< Repeat delay in milliseconds.
788 /** Model for a Forms 2.0 scroll bar. */
789 class OOX_DLLPUBLIC AxScrollBarModel
: public AxControlModelBase
792 explicit AxScrollBarModel();
794 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) SAL_OVERRIDE
;
795 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) SAL_OVERRIDE
;
796 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) SAL_OVERRIDE
;
797 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) SAL_OVERRIDE
;
799 virtual ApiControlType
getControlType() const SAL_OVERRIDE
;
800 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const SAL_OVERRIDE
;
801 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) SAL_OVERRIDE
;
803 public: // direct access needed for legacy VML drawing controls
804 sal_uInt32 mnArrowColor
; ///< Button arrow color.
805 sal_uInt32 mnBackColor
; ///< Fill color.
806 sal_uInt32 mnFlags
; ///< Various flags.
807 sal_Int32 mnOrientation
; ///< Orientation of the buttons.
808 sal_Int32 mnPropThumb
; ///< Proportional thumb size.
809 sal_Int32 mnMin
; ///< Minimum of the value range.
810 sal_Int32 mnMax
; ///< Maximum of the value range.
811 sal_Int32 mnPosition
; ///< Value of the spin button.
812 sal_Int32 mnSmallChange
; ///< Increment step size (buttons).
813 sal_Int32 mnLargeChange
; ///< Increment step size (thumb).
814 sal_Int32 mnDelay
; ///< Repeat delay in milliseconds.
819 typedef ::std::vector
< OUString
> AxClassTable
;
821 /** Base class for ActiveX container controls. */
822 class OOX_DLLPUBLIC AxContainerModelBase
: public AxFontDataModel
825 explicit AxContainerModelBase( bool bFontSupport
= false );
827 /** Allows to set single properties specified by XML token identifier. */
828 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) SAL_OVERRIDE
;
829 /** Reads the leading structure in the 'f' stream containing the model for
831 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) SAL_OVERRIDE
;
832 /** Converts font settings if supported. */
833 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const SAL_OVERRIDE
;
835 /** Reads the class table structure for embedded controls following the own
836 model from the 'f' stream. */
837 bool importClassTable( BinaryInputStream
& rInStrm
, AxClassTable
& orClassTable
);
839 public: // direct access needed for legacy VML drawing controls
840 StreamDataSequence maPictureData
; ///< Binary picture stream.
841 OUString maCaption
; ///< Visible caption of the form.
842 AxPairData maLogicalSize
; ///< Logical form size (scroll area).
843 AxPairData maScrollPos
; ///< Scroll position.
844 sal_uInt32 mnBackColor
; ///< Fill color.
845 sal_uInt32 mnTextColor
; ///< Text color.
846 sal_uInt32 mnFlags
; ///< Various flags.
847 sal_uInt32 mnBorderColor
; ///< Flat border color.
848 sal_Int32 mnBorderStyle
; ///< Flat border style.
849 sal_Int32 mnScrollBars
; ///< Horizontal/vertical scroll bar.
850 sal_Int32 mnCycleType
; ///< Cycle in all forms or in this form.
851 sal_Int32 mnSpecialEffect
; ///< 3D border effect.
852 sal_Int32 mnPicAlign
; ///< Anchor position of the picture.
853 sal_Int32 mnPicSizeMode
; ///< Clip, stretch, zoom.
854 bool mbPicTiling
; ///< True = picture is repeated.
855 bool mbFontSupport
; ///< True = control supports the font property.
861 /** Model for a Forms 2.0 frame control. */
862 class OOX_DLLPUBLIC AxFrameModel
: public AxContainerModelBase
865 explicit AxFrameModel();
867 virtual ApiControlType
getControlType() const SAL_OVERRIDE
;
868 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const SAL_OVERRIDE
;
871 class OOX_DLLPUBLIC AxPageModel
: public AxContainerModelBase
874 explicit AxPageModel();
876 virtual ApiControlType
getControlType() const SAL_OVERRIDE
;
877 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const SAL_OVERRIDE
;
880 class OOX_DLLPUBLIC AxMultiPageModel
: public AxContainerModelBase
883 explicit AxMultiPageModel();
885 virtual ApiControlType
getControlType() const SAL_OVERRIDE
;
886 bool importPageAndMultiPageProperties( BinaryInputStream
& rInStrm
, sal_Int32 nPages
);
887 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const SAL_OVERRIDE
;
888 std::vector
<sal_uInt32
> mnIDs
;
889 sal_uInt32 mnActiveTab
;
890 sal_uInt32 mnTabStyle
;
896 /** Model for a Forms 2.0 user form. */
897 class OOX_DLLPUBLIC AxUserFormModel
: public AxContainerModelBase
900 explicit AxUserFormModel();
902 virtual ApiControlType
getControlType() const SAL_OVERRIDE
;
903 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const SAL_OVERRIDE
;
906 class HtmlSelectModel
: public AxListBoxModel
908 com::sun::star::uno::Sequence
< OUString
> msListData
;
909 com::sun::star::uno::Sequence
< sal_Int16
> msIndices
;
912 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) SAL_OVERRIDE
;
913 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const SAL_OVERRIDE
;
916 class HtmlTextBoxModel
: public AxTextBoxModel
919 explicit HtmlTextBoxModel();
920 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) SAL_OVERRIDE
;
924 /** A form control embedded in a document draw page. Contains a specific model
925 structure according to the type of the control. */
926 class OOX_DLLPUBLIC EmbeddedControl
929 explicit EmbeddedControl( const OUString
& rName
);
930 virtual ~EmbeddedControl();
932 /** Creates and returns the internal control model of the specified type. */
933 template< typename ModelType
>
934 inline ModelType
& createModel();
936 /** Creates and returns the internal control model of the specified type. */
937 template< typename ModelType
, typename ParamType
>
938 inline ModelType
& createModel( const ParamType
& rParam
);
940 /** Creates and returns the internal control model according to the passed
941 MS class identifier. */
942 ControlModelBase
* createModelFromGuid( const OUString
& rClassId
);
944 /** Returns true, if the internal control model exists. */
945 bool hasModel() const { return mxModel
.get() != 0; }
946 /** Returns read-only access to the internal control model. */
947 const ControlModelBase
* getModel() const { return mxModel
.get(); }
948 /** Returns read/write access to the internal control model. */
949 ControlModelBase
* getModel() { return mxModel
.get(); }
951 /** Returns the UNO service name needed to construct the control model. */
952 OUString
getServiceName() const;
954 /** Converts all control properties and inserts them into the passed model. */
955 bool convertProperties(
956 const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlModel
>& rxCtrlModel
,
957 const ControlConverter
& rConv
) const;
959 bool convertFromProperties(
960 const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlModel
>& rxCtrlModel
,
961 const ControlConverter
& rConv
);
964 ControlModelRef mxModel
; ///< Control model containing the properties.
965 OUString maName
; ///< Name of the control.
970 template< typename ModelType
>
971 inline ModelType
& EmbeddedControl::createModel()
973 std::shared_ptr
< ModelType
> xModel( new ModelType
);
975 xModel
->setFormComponentMode();
979 template< typename ModelType
, typename ParamType
>
980 inline ModelType
& EmbeddedControl::createModel( const ParamType
& rParam
)
982 std::shared_ptr
< ModelType
> xModel( new ModelType( rParam
) );
984 xModel
->setFormComponentMode();
990 /** A wrapper for a control form embedded directly in a draw page. */
994 explicit EmbeddedForm(
995 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& rxDocModel
,
996 const ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XDrawPage
>& rxDrawPage
,
997 const GraphicHelper
& rGraphicHelper
,
998 bool bDefaultColorBgr
= true );
1000 /** Converts the passed control and inserts the control model into the form.
1001 @return The API control model, if conversion was successful. */
1002 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlModel
>
1003 convertAndInsert( const EmbeddedControl
& rControl
, sal_Int32
& rnCtrlIndex
);
1005 /** Returns the XIndexContainer interface of the UNO control form, if existing. */
1006 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexContainer
>
1007 getXForm() const { return mxFormIC
; }
1010 /** Creates the form that will hold the form controls. */
1011 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexContainer
>
1015 ControlConverter maControlConv
;
1016 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> mxModelFactory
;
1017 ::com::sun::star::uno::Reference
< ::com::sun::star::form::XFormsSupplier
> mxFormsSupp
;
1018 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XIndexContainer
> mxFormIC
;
1028 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */