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 <config_options.h>
27 #include <com/sun/star/uno/Reference.hxx>
28 #include <com/sun/star/uno/Sequence.hxx>
29 #include <oox/dllapi.h>
30 #include <oox/helper/binarystreambase.hxx>
31 #include <oox/helper/propertyset.hxx>
32 #include <oox/ole/axbinaryreader.hxx>
33 #include <oox/ole/axfontdata.hxx>
34 #include <oox/ole/olehelper.hxx>
35 #include <rtl/ustring.hxx>
36 #include <sal/types.h>
38 namespace com::sun::star
{
39 namespace awt
{ class XControlModel
; }
40 namespace container
{ class XIndexContainer
; }
41 namespace drawing
{ class XDrawPage
; }
42 namespace frame
{ class XModel
; }
43 namespace form
{ class XFormsSupplier
; }
44 namespace lang
{ class XMultiServiceFactory
; }
48 class BinaryInputStream
;
49 class BinaryOutputStream
;
57 #define COMCTL_GUID_SCROLLBAR_60 "{FE38753A-44A3-11D1-B5B7-0000C09000C4}"
58 #define COMCTL_GUID_PROGRESSBAR_50 "{0713E8D2-850A-101B-AFC0-4210102A8DA7}"
59 #define COMCTL_GUID_PROGRESSBAR_60 "{35053A22-8589-11D1-B16A-00C0F0283628}"
61 const sal_uInt16 COMCTL_VERSION_50
= 5;
62 const sal_uInt16 COMCTL_VERSION_60
= 6;
65 #define AX_GUID_COMMANDBUTTON "{D7053240-CE69-11CD-a777-00dd01143c57}"
66 #define AX_GUID_LABEL "{978C9E23-D4B0-11CE-bf2d-00aa003f40d0}"
67 #define AX_GUID_IMAGE "{4C599241-6926-101B-9992-00000b65c6f9}"
68 #define AX_GUID_TOGGLEBUTTON "{8BD21D60-EC42-11CE-9e0d-00aa006002f3}"
69 #define AX_GUID_CHECKBOX "{8BD21D40-EC42-11CE-9e0d-00aa006002f3}"
70 #define AX_GUID_OPTIONBUTTON "{8BD21D50-EC42-11CE-9e0d-00aa006002f3}"
71 #define AX_GUID_TEXTBOX "{8BD21D10-EC42-11CE-9e0d-00aa006002f3}"
72 #define AX_GUID_LISTBOX "{8BD21D20-EC42-11CE-9e0d-00aa006002f3}"
73 #define AX_GUID_COMBOBOX "{8BD21D30-EC42-11CE-9e0d-00aa006002f3}"
74 #define AX_GUID_SPINBUTTON "{79176FB0-B7F2-11CE-97ef-00aa006d2776}"
75 #define AX_GUID_SCROLLBAR "{DFD181E0-5E2F-11CE-a449-00aa004a803d}"
76 #define AX_GUID_FRAME "{6E182020-F460-11CE-9bcd-00aa00608e01}"
78 // Html control GUID(s)
80 #define HTML_GUID_SELECT "{5512D122-5CC6-11CF-8d67-00aa00bdce1d}"
81 #define HTML_GUID_TEXTBOX "{5512D124-5CC6-11CF-8d67-00aa00bdce1d}"
83 const sal_uInt32 AX_SYSCOLOR_WINDOWBACK
= 0x80000005;
84 const sal_uInt32 AX_SYSCOLOR_WINDOWFRAME
= 0x80000006;
85 const sal_uInt32 AX_SYSCOLOR_WINDOWTEXT
= 0x80000008;
86 const sal_uInt32 AX_SYSCOLOR_BUTTONFACE
= 0x8000000F;
87 const sal_uInt32 AX_SYSCOLOR_BUTTONTEXT
= 0x80000012;
89 const sal_uInt32 AX_FLAGS_ENABLED
= 0x00000002;
90 const sal_uInt32 AX_FLAGS_LOCKED
= 0x00000004;
91 const sal_uInt32 AX_FLAGS_OPAQUE
= 0x00000008;
92 const sal_uInt32 AX_FLAGS_COLUMNHEADS
= 0x00000400;
93 const sal_uInt32 AX_FLAGS_ENTIREROWS
= 0x00000800;
94 const sal_uInt32 AX_FLAGS_EXISTINGENTRIES
= 0x00001000;
95 const sal_uInt32 AX_FLAGS_CAPTIONLEFT
= 0x00002000;
96 const sal_uInt32 AX_FLAGS_EDITABLE
= 0x00004000;
97 const sal_uInt32 AX_FLAGS_IMEMODE_MASK
= 0x00078000;
98 const sal_uInt32 AX_FLAGS_DRAGENABLED
= 0x00080000;
99 const sal_uInt32 AX_FLAGS_ENTERASNEWLINE
= 0x00100000;
100 const sal_uInt32 AX_FLAGS_KEEPSELECTION
= 0x00200000;
101 const sal_uInt32 AX_FLAGS_TABASCHARACTER
= 0x00400000;
102 const sal_uInt32 AX_FLAGS_WORDWRAP
= 0x00800000;
103 const sal_uInt32 AX_FLAGS_BORDERSSUPPRESSED
= 0x02000000;
104 const sal_uInt32 AX_FLAGS_SELECTLINE
= 0x04000000;
105 const sal_uInt32 AX_FLAGS_SINGLECHARSELECT
= 0x08000000;
106 const sal_uInt32 AX_FLAGS_AUTOSIZE
= 0x10000000;
107 const sal_uInt32 AX_FLAGS_HIDESELECTION
= 0x20000000;
108 const sal_uInt32 AX_FLAGS_MAXLENAUTOTAB
= 0x40000000;
109 const sal_uInt32 AX_FLAGS_MULTILINE
= 0x80000000;
111 const sal_Int32 AX_BORDERSTYLE_NONE
= 0;
112 const sal_Int32 AX_BORDERSTYLE_SINGLE
= 1;
114 const sal_Int32 AX_SPECIALEFFECT_FLAT
= 0;
115 const sal_Int32 AX_SPECIALEFFECT_RAISED
= 1;
116 const sal_Int32 AX_SPECIALEFFECT_SUNKEN
= 2;
117 const sal_Int32 AX_SPECIALEFFECT_ETCHED
= 3;
118 const sal_Int32 AX_SPECIALEFFECT_BUMPED
= 6;
120 const sal_Int32 AX_PICSIZE_CLIP
= 0;
121 const sal_Int32 AX_PICSIZE_STRETCH
= 1;
122 const sal_Int32 AX_PICSIZE_ZOOM
= 3;
124 const sal_Int32 AX_PICALIGN_TOPLEFT
= 0;
125 const sal_Int32 AX_PICALIGN_TOPRIGHT
= 1;
126 const sal_Int32 AX_PICALIGN_CENTER
= 2;
127 const sal_Int32 AX_PICALIGN_BOTTOMLEFT
= 3;
128 const sal_Int32 AX_PICALIGN_BOTTOMRIGHT
= 4;
130 const sal_Int32 AX_DISPLAYSTYLE_TEXT
= 1;
131 const sal_Int32 AX_DISPLAYSTYLE_LISTBOX
= 2;
132 const sal_Int32 AX_DISPLAYSTYLE_COMBOBOX
= 3;
133 const sal_Int32 AX_DISPLAYSTYLE_CHECKBOX
= 4;
134 const sal_Int32 AX_DISPLAYSTYLE_OPTBUTTON
= 5;
135 const sal_Int32 AX_DISPLAYSTYLE_TOGGLE
= 6;
136 const sal_Int32 AX_DISPLAYSTYLE_DROPDOWN
= 7;
138 const sal_Int32 AX_SELECTION_SINGLE
= 0;
139 const sal_Int32 AX_SELECTION_MULTI
= 1;
140 const sal_Int32 AX_SELECTION_EXTENDED
= 2;
142 const sal_Int32 AX_SHOWDROPBUTTON_NEVER
= 0;
143 const sal_Int32 AX_SHOWDROPBUTTON_FOCUS
= 1;
144 const sal_Int32 AX_SHOWDROPBUTTON_ALWAYS
= 2;
146 const sal_Int32 AX_SCROLLBAR_NONE
= 0x00;
147 const sal_Int32 AX_SCROLLBAR_HORIZONTAL
= 0x01;
148 const sal_Int32 AX_SCROLLBAR_VERTICAL
= 0x02;
151 /** Enumerates all UNO API control types supported by these filters. */
155 API_CONTROL_FIXEDTEXT
,
157 API_CONTROL_CHECKBOX
,
158 API_CONTROL_RADIOBUTTON
,
162 API_CONTROL_COMBOBOX
,
163 API_CONTROL_SPINBUTTON
,
164 API_CONTROL_SCROLLBAR
,
165 API_CONTROL_TABSTRIP
, //11
166 API_CONTROL_PROGRESSBAR
,
167 API_CONTROL_GROUPBOX
,
168 API_CONTROL_FRAME
, // 14
169 API_CONTROL_PAGE
, // 15
170 API_CONTROL_MULTIPAGE
, // 16
171 API_CONTROL_DIALOG
// 17
175 /** Specifies how a form control supports transparent background. */
176 enum class ApiTransparencyMode
178 NotSupported
, ///< Control does not support transparency.
179 Void
, ///< Transparency is enabled by missing fill color.
182 /** Specifies how a form control supports the DefaultState property. */
183 enum ApiDefaultStateMode
185 API_DEFAULTSTATE_BOOLEAN
, ///< Control does not support tri-state, state is given as boolean.
186 API_DEFAULTSTATE_SHORT
, ///< Control does not support tri-state, state is given as short.
187 API_DEFAULTSTATE_TRISTATE
///< Control supports tri-state, state is given as short.
191 /** A base class with useful helper functions for something that is able to
192 convert ActiveX and ComCtl form controls.
194 class OOX_DLLPUBLIC ControlConverter final
197 explicit ControlConverter(
198 const css::uno::Reference
< css::frame::XModel
>& rxDocModel
,
199 const GraphicHelper
& rGraphicHelper
,
200 bool bDefaultColorBgr
= true );
203 // Generic conversion -----------------------------------------------------
205 /** Converts the passed position in 1/100 mm to UNO properties. */
206 void convertPosition(
207 PropertyMap
& rPropMap
,
208 const AxPairData
& rPos
) const;
210 /** Converts the passed size in 1/100 mm to UNO properties. */
212 PropertyMap
& rPropMap
,
213 const AxPairData
& rSize
) const;
215 /** Converts the passed encoded OLE color to UNO properties. */
217 PropertyMap
& rPropMap
,
219 sal_uInt32 nOleColor
) const;
221 static void convertToMSColor(
222 PropertySet
const & rPropSet
,
224 sal_uInt32
& nOleColor
,
225 sal_uInt32 nDefault
= 0 );
228 /** Converts the passed StdPic picture stream to UNO properties. */
230 PropertyMap
& rPropMap
,
231 const StreamDataSequence
& rPicData
) const;
233 /** Converts the control orientation to UNO properties. */
234 static void convertOrientation(
235 PropertyMap
& rPropMap
,
238 static void convertToMSOrientation(
239 PropertySet
const & rPropMap
,
242 /** Converts the vertical alignment to UNO properties. */
243 static void convertVerticalAlign(
244 PropertyMap
& rPropMap
,
245 sal_Int32 nVerticalAlign
);
247 /** Converts common scrollbar settings to UNO properties. */
248 static void convertScrollBar(
249 PropertyMap
& rPropMap
,
250 sal_Int32 nMin
, sal_Int32 nMax
, sal_Int32 nPosition
,
251 sal_Int32 nSmallChange
, sal_Int32 nLargeChange
, bool bAwtModel
);
253 /** Converts scrollability settings to UNO properties. */
254 void convertScrollabilitySettings(
255 PropertyMap
& rPropMap
,
256 const AxPairData
& rScrollPos
, const AxPairData
& rScrollArea
,
257 sal_Int32 nScrollBars
) const;
259 /** Binds the passed control model to the passed data sources. The
260 implementation will check which source types are supported. */
262 const css::uno::Reference
< css::awt::XControlModel
>& rxCtrlModel
,
263 const OUString
& rCtrlSource
,
264 const OUString
& rRowSource
,
265 sal_Int32 nRefSheet
= 0 ) const;
267 // ActiveX (Forms 2.0) specific conversion --------------------------------
269 /** Converts the Forms 2.0 background formatting to UNO properties. */
270 void convertAxBackground(
271 PropertyMap
& rPropMap
,
272 sal_uInt32 nBackColor
,
274 ApiTransparencyMode eTranspMode
) const;
276 /** Converts the Forms 2.0 border formatting to UNO properties. */
277 void convertAxBorder(
278 PropertyMap
& rPropMap
,
279 sal_uInt32 nBorderColor
,
280 sal_Int32 nBorderStyle
,
281 sal_Int32 nSpecialEffect
) const;
283 static void convertToAxBorder(
284 PropertySet
const & rPropSet
,
285 sal_uInt32
& nBorderColor
,
286 sal_Int32
& nBorderStyle
,
287 sal_Int32
& nSpecialEffect
);
289 /** Converts the Forms 2.0 special effect to UNO properties. */
290 static void convertAxVisualEffect(
291 PropertyMap
& rPropMap
,
292 sal_Int32 nSpecialEffect
);
294 static void convertToAxVisualEffect(
295 PropertySet
const & rPropSet
,
296 sal_Int32
& nSpecialEffect
);
298 /** Converts the passed picture stream and Forms 2.0 position to UNO
300 void convertAxPicture(
301 PropertyMap
& rPropMap
,
302 const StreamDataSequence
& rPicData
,
303 sal_uInt32 nPicPos
) const;
305 /** Converts the passed picture stream and Forms 2.0 position to UNO
307 void convertAxPicture(
308 PropertyMap
& rPropMap
,
309 const StreamDataSequence
& rPicData
,
310 sal_Int32 nPicSizeMode
) const;
312 /** Converts the Forms 2.0 value for checked/unchecked/dontknow to UNO
314 static void convertAxState(
315 PropertyMap
& rPropMap
,
316 std::u16string_view rValue
,
317 sal_Int32 nMultiSelect
,
318 ApiDefaultStateMode eDefStateMode
,
321 static void convertToAxState(
322 PropertySet
const & rPropSet
,
324 sal_Int32
& nMultiSelect
,
325 ApiDefaultStateMode eDefStateMode
);
327 /** Converts the Forms 2.0 control orientation to UNO properties. */
328 static void convertAxOrientation(
329 PropertyMap
& rPropMap
,
330 const AxPairData
& rSize
,
331 sal_Int32 nOrientation
);
333 static void convertToAxOrientation(
334 PropertySet
const & rPropSet
,
335 sal_Int32
& nOrientation
);
338 css::uno::Reference
< css::frame::XModel
> mxDocModel
;
339 const GraphicHelper
& mrGraphicHelper
;
340 mutable PropertySet maAddressConverter
;
341 mutable PropertySet maRangeConverter
;
342 bool mbDefaultColorBgr
;
346 /** Base class for all models of form controls. */
347 class OOX_DLLPUBLIC ControlModelBase
350 explicit ControlModelBase();
351 virtual ~ControlModelBase();
353 /** Sets this control model to AWT model mode. */
354 void setAwtModelMode() { mbAwtModel
= true; }
355 /** Sets this control model to form component mode. */
356 void setFormComponentMode() { mbAwtModel
= false; }
358 /** Returns the UNO service name used to construct the AWT control model,
359 or the control form component. */
360 OUString
getServiceName() const;
362 /** Derived classes set specific OOXML properties at the model structure. */
363 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
);
364 /** Derived classes set binary data (picture, mouse icon) at the model structure. */
365 virtual void importPictureData( sal_Int32 nPropId
, BinaryInputStream
& rInStrm
);
366 /** Derived classes import a form control model from the passed input stream. */
367 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) = 0;
368 /** Derived classes export a form control model to the passed output stream. */
369 virtual void exportBinaryModel( BinaryOutputStream
& /*rOutStrm*/ ) {}
370 /** Derived classes export CompObjStream contents. */
371 virtual void exportCompObj( BinaryOutputStream
& /*rOutStrm*/ ) {}
372 /** Derived classes return the UNO control type enum value. */
373 virtual ApiControlType
getControlType() const = 0;
374 /** Derived classes convert all control properties. */
375 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const;
376 /** Derived classes convert from uno control properties to equiv. MS values. */
377 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
);
379 /** Converts the control size to UNO properties. */
380 void convertSize( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const;
382 public: // direct access needed for legacy VML drawing controls
383 AxPairData maSize
; ///< Size of the control in 1/100 mm.
386 bool mbAwtModel
; ///< True = AWT control model, false = form component.
389 typedef std::shared_ptr
< ControlModelBase
> ControlModelRef
;
392 /** Base class for all models of ComCtl form controls. */
393 class ComCtlModelBase
: public ControlModelBase
396 explicit ComCtlModelBase(
397 sal_uInt32 nDataPartId5
, sal_uInt32 nDataPartId6
, sal_uInt16 nVersion
);
399 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
400 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
403 virtual void importControlData( BinaryInputStream
& rInStrm
) = 0;
406 /** Returns the data part identifier according to the model version. */
407 sal_uInt32
getDataPartId() const;
409 static bool readPartHeader( BinaryInputStream
& rInStrm
,
410 sal_uInt32 nExpPartId
,
411 sal_uInt16 nExpMajor
= SAL_MAX_UINT16
,
412 sal_uInt16 nExpMinor
= SAL_MAX_UINT16
);
414 bool importSizePart( BinaryInputStream
& rInStrm
);
415 bool importCommonPart( BinaryInputStream
& rInStrm
, sal_uInt32 nPartSize
);
416 bool importComplexPart( BinaryInputStream
& rInStrm
);
419 StdFontInfo maFontData
; ///< Font formatting.
420 StreamDataSequence maMouseIcon
; ///< Binary picture stream for mouse icon.
421 sal_uInt32 mnFlags
; ///< Common flags for ComCtl controls.
422 const sal_uInt16 mnVersion
; ///< Current version of the ComCtl control model.
425 sal_uInt32 mnDataPartId5
; ///< Identifier for version 5.0 control data.
426 sal_uInt32 mnDataPartId6
; ///< Identifier for version 6.0 control data.
427 bool mbCommonPart
; ///< True = the COMCTL_COMMONDATA part exists.
428 bool mbComplexPart
; ///< True = the COMCTL_COMPLEXDATA part exists.
432 /** Model for a ComCtl scroll bar. */
433 class ComCtlScrollBarModel final
: public ComCtlModelBase
436 explicit ComCtlScrollBarModel( sal_uInt16 nVersion
);
438 virtual ApiControlType
getControlType() const override
;
439 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
442 virtual void importControlData( BinaryInputStream
& rInStrm
) override
;
444 sal_uInt32 mnScrollBarFlags
; ///< Special flags for scroll bar model.
445 sal_Int32 mnLargeChange
; ///< Increment step size (thumb).
446 sal_Int32 mnSmallChange
; ///< Increment step size (buttons).
447 sal_Int32 mnMin
; ///< Minimum of the value range.
448 sal_Int32 mnMax
; ///< Maximum of the value range.
449 sal_Int32 mnPosition
; ///< Value of the spin button.
453 /** Model for a ComCtl progress bar. */
454 class ComCtlProgressBarModel final
: public ComCtlModelBase
457 explicit ComCtlProgressBarModel( sal_uInt16 nVersion
);
459 virtual ApiControlType
getControlType() const override
;
460 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
463 virtual void importControlData( BinaryInputStream
& rInStrm
) override
;
465 float mfMin
; ///< Minimum of the value range.
466 float mfMax
; ///< Maximum of the value range.
467 sal_uInt16 mnVertical
; ///< 0 = horizontal, 1 = vertical.
468 sal_uInt16 mnSmooth
; ///< 0 = progress blocks, 1 = pixel resolution.
472 /** Base class for all models of Form 2.0 form controls. */
473 class OOX_DLLPUBLIC AxControlModelBase
: public ControlModelBase
476 explicit AxControlModelBase();
478 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) override
;
482 /** Base class for Forms 2.0 controls supporting text formatting. */
483 class OOX_DLLPUBLIC AxFontDataModel
: public AxControlModelBase
486 explicit AxFontDataModel( bool bSupportsAlign
= true );
488 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) override
;
489 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
490 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) override
;
491 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
492 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
494 /** Returns the font height in points. */
495 sal_Int16
getFontHeight() const { return maFontData
.getHeightPoints(); }
497 public: // direct access needed for legacy VML drawing controls
498 AxFontData maFontData
; ///< The font settings.
501 bool mbSupportsAlign
; ///< True = UNO model supports Align property.
505 /** Model for a Forms 2.0 command button. */
506 class OOX_DLLPUBLIC AxCommandButtonModel final
: public AxFontDataModel
509 explicit AxCommandButtonModel();
511 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) override
;
512 virtual void importPictureData( sal_Int32 nPropId
, BinaryInputStream
& rInStrm
) override
;
513 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
514 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) override
;
515 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
517 virtual ApiControlType
getControlType() const override
;
518 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
519 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
521 public: // direct access needed for legacy VML drawing controls
522 StreamDataSequence maPictureData
; ///< Binary picture stream.
523 OUString maCaption
; ///< Visible caption of the button.
524 sal_uInt32 mnTextColor
; ///< Text color.
525 sal_uInt32 mnBackColor
; ///< Fill color.
526 sal_uInt32 mnFlags
; ///< Various flags.
527 sal_uInt32 mnPicturePos
; ///< Position of the picture relative to text.
528 sal_Int32 mnVerticalAlign
; ///< Vertical alignment (legacy VML drawing controls only).
529 bool mbFocusOnClick
; ///< True = take focus on click.
533 /** Model for a Forms 2.0 label. */
534 class OOX_DLLPUBLIC AxLabelModel final
: public AxFontDataModel
537 explicit AxLabelModel();
539 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) override
;
540 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
541 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) override
;
542 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
544 virtual ApiControlType
getControlType() const override
;
545 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
546 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
548 public: // direct access needed for legacy VML drawing controls
549 OUString maCaption
; ///< Visible caption of the button.
550 sal_uInt32 mnTextColor
; ///< Text color.
551 sal_uInt32 mnBackColor
; ///< Fill color.
552 sal_uInt32 mnFlags
; ///< Various flags.
553 sal_uInt32 mnBorderColor
; ///< Flat border color.
554 sal_Int32 mnBorderStyle
; ///< Flat border style.
555 sal_Int32 mnSpecialEffect
; ///< 3D border effect.
556 sal_Int32 mnVerticalAlign
; ///< Vertical alignment (legacy VML drawing controls only).
560 /** Model for a Forms 2.0 image. */
561 class UNLESS_MERGELIBS(OOX_DLLPUBLIC
) AxImageModel final
: public AxControlModelBase
564 explicit AxImageModel();
566 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) override
;
567 virtual void importPictureData( sal_Int32 nPropId
, BinaryInputStream
& rInStrm
) override
;
568 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
569 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) override
;
570 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
572 virtual ApiControlType
getControlType() const override
;
573 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
576 StreamDataSequence maPictureData
; ///< Binary picture stream.
577 sal_uInt32 mnBackColor
; ///< Fill color.
578 sal_uInt32 mnFlags
; ///< Various flags.
579 sal_uInt32 mnBorderColor
; ///< Flat border color.
580 sal_Int32 mnBorderStyle
; ///< Flat border style.
581 sal_Int32 mnSpecialEffect
; ///< 3D border effect.
582 sal_Int32 mnPicSizeMode
; ///< Clip, stretch, zoom.
583 sal_Int32 mnPicAlign
; ///< Anchor position of the picture.
584 bool mbPicTiling
; ///< True = picture is repeated.
587 class UNLESS_MERGELIBS(OOX_DLLPUBLIC
) AxTabStripModel final
: public AxFontDataModel
590 explicit AxTabStripModel();
592 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
594 virtual ApiControlType
getControlType() const override
;
597 sal_uInt32 mnListIndex
;
598 sal_uInt32 mnTabStyle
;
599 sal_uInt32 mnTabData
;
600 sal_uInt32 mnVariousPropertyBits
;
601 std::vector
< OUString
> maItems
; // captions for each tab
602 std::vector
< OUString
> maTabNames
; // names for each tab
606 /** Base class for a Forms 2.0 morph data control. */
607 class OOX_DLLPUBLIC AxMorphDataModelBase
: public AxFontDataModel
610 explicit AxMorphDataModelBase();
612 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) override
;
613 virtual void importPictureData( sal_Int32 nPropId
, BinaryInputStream
& rInStrm
) override
;
614 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
615 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) override
;
616 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
617 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
619 public: // direct access needed for legacy VML drawing controls
620 StreamDataSequence maPictureData
; ///< Binary picture stream.
621 OUString maCaption
; ///< Visible caption of the button.
622 OUString maValue
; ///< Current value of the control.
623 OUString maGroupName
; ///< Group name for option buttons.
624 sal_uInt32 mnTextColor
; ///< Text color.
625 sal_uInt32 mnBackColor
; ///< Fill color.
626 sal_uInt32 mnFlags
; ///< Various flags.
627 sal_uInt32 mnPicturePos
; ///< Position of the picture relative to text.
628 sal_uInt32 mnBorderColor
; ///< Flat border color.
629 sal_Int32 mnBorderStyle
; ///< Flat border style.
630 sal_Int32 mnSpecialEffect
; ///< 3D border effect.
631 sal_Int32 mnDisplayStyle
; ///< Type of the morph control.
632 sal_Int32 mnMultiSelect
; ///< Selection mode.
633 sal_Int32 mnScrollBars
; ///< Horizontal/vertical scroll bar.
634 sal_Int32 mnMatchEntry
; ///< Auto completion mode.
635 sal_Int32 mnShowDropButton
; ///< When to show the dropdown button.
636 sal_Int32 mnMaxLength
; ///< Maximum character count.
637 sal_Int32 mnPasswordChar
; ///< Password character in edit fields.
638 sal_Int32 mnListRows
; ///< Number of rows in dropdown box.
639 sal_Int32 mnVerticalAlign
; ///< Vertical alignment (legacy VML drawing controls only).
643 /** Model for a Forms 2.0 toggle button. */
644 class UNLESS_MERGELIBS(OOX_DLLPUBLIC
) AxToggleButtonModel final
: public AxMorphDataModelBase
647 explicit AxToggleButtonModel();
649 virtual ApiControlType
getControlType() const override
;
650 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
651 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
652 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
656 /** Model for a Forms 2.0 check box. */
657 class OOX_DLLPUBLIC AxCheckBoxModel final
: public AxMorphDataModelBase
660 explicit AxCheckBoxModel();
662 virtual ApiControlType
getControlType() const override
;
663 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
664 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
665 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
669 /** Model for a Forms 2.0 option button. */
670 class OOX_DLLPUBLIC AxOptionButtonModel final
: public AxMorphDataModelBase
673 explicit AxOptionButtonModel();
675 /** Returns the group name used to group several option buttons together. */
676 const OUString
& getGroupName() const { return maGroupName
; }
678 virtual ApiControlType
getControlType() const override
;
679 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
680 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
681 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
685 /** Model for a Forms 2.0 text box. */
686 class OOX_DLLPUBLIC AxTextBoxModel
: public AxMorphDataModelBase
689 explicit AxTextBoxModel();
691 virtual ApiControlType
getControlType() const override
;
692 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
693 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
694 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
698 /** Model for a numeric field (legacy drawing controls only). */
699 class OOX_DLLPUBLIC AxNumericFieldModel final
: public AxMorphDataModelBase
702 explicit AxNumericFieldModel();
704 virtual ApiControlType
getControlType() const override
;
705 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
706 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
707 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
711 /** Model for a Forms 2.0 list box. */
712 class OOX_DLLPUBLIC AxListBoxModel
: public AxMorphDataModelBase
715 explicit AxListBoxModel();
717 virtual ApiControlType
getControlType() const override
;
718 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
719 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
720 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
724 /** Model for a Forms 2.0 combo box. */
725 class OOX_DLLPUBLIC AxComboBoxModel final
: public AxMorphDataModelBase
728 explicit AxComboBoxModel();
730 virtual ApiControlType
getControlType() const override
;
731 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
732 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
733 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
737 /** Model for a Forms 2.0 spin button. */
738 class OOX_DLLPUBLIC AxSpinButtonModel final
: public AxControlModelBase
741 explicit AxSpinButtonModel();
743 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) override
;
744 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
745 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) override
;
747 virtual ApiControlType
getControlType() const override
;
748 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
749 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
750 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
752 public: // direct access needed for legacy VML drawing controls
753 sal_uInt32 mnArrowColor
; ///< Button arrow color.
754 sal_uInt32 mnBackColor
; ///< Fill color.
755 sal_uInt32 mnFlags
; ///< Various flags.
756 sal_Int32 mnOrientation
; ///< Orientation of the buttons.
757 sal_Int32 mnMin
; ///< Minimum of the value range.
758 sal_Int32 mnMax
; ///< Maximum of the value range.
759 sal_Int32 mnPosition
; ///< Value of the spin button.
760 sal_Int32 mnSmallChange
; ///< Increment step size.
761 sal_Int32 mnDelay
; ///< Repeat delay in milliseconds.
765 /** Model for a Forms 2.0 scroll bar. */
766 class OOX_DLLPUBLIC AxScrollBarModel final
: public AxControlModelBase
769 explicit AxScrollBarModel();
771 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) override
;
772 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
773 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) override
;
774 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
776 virtual ApiControlType
getControlType() const override
;
777 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
778 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
780 public: // direct access needed for legacy VML drawing controls
781 sal_uInt32 mnArrowColor
; ///< Button arrow color.
782 sal_uInt32 mnBackColor
; ///< Fill color.
783 sal_uInt32 mnFlags
; ///< Various flags.
784 sal_Int32 mnOrientation
; ///< Orientation of the buttons.
785 sal_Int32 mnPropThumb
; ///< Proportional thumb size.
786 sal_Int32 mnMin
; ///< Minimum of the value range.
787 sal_Int32 mnMax
; ///< Maximum of the value range.
788 sal_Int32 mnPosition
; ///< Value of the spin button.
789 sal_Int32 mnSmallChange
; ///< Increment step size (buttons).
790 sal_Int32 mnLargeChange
; ///< Increment step size (thumb).
791 sal_Int32 mnDelay
; ///< Repeat delay in milliseconds.
795 typedef ::std::vector
< OUString
> AxClassTable
;
797 /** Base class for ActiveX container controls. */
798 class OOX_DLLPUBLIC AxContainerModelBase
: public AxFontDataModel
801 explicit AxContainerModelBase( bool bFontSupport
= false );
803 /** Allows to set single properties specified by XML token identifier. */
804 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) override
;
805 /** Reads the leading structure in the 'f' stream containing the model for
807 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
808 /** Converts font settings if supported. */
809 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
811 /** Reads the class table structure for embedded controls following the own
812 model from the 'f' stream. */
813 bool importClassTable( BinaryInputStream
& rInStrm
, AxClassTable
& orClassTable
);
815 public: // direct access needed for legacy VML drawing controls
816 StreamDataSequence maPictureData
; ///< Binary picture stream.
817 OUString maCaption
; ///< Visible caption of the form.
818 AxPairData maLogicalSize
; ///< Logical form size (scroll area).
819 AxPairData maScrollPos
; ///< Scroll position.
820 sal_uInt32 mnBackColor
; ///< Fill color.
821 sal_uInt32 mnTextColor
; ///< Text color.
822 sal_uInt32 mnFlags
; ///< Various flags.
823 sal_uInt32 mnBorderColor
; ///< Flat border color.
824 sal_Int32 mnBorderStyle
; ///< Flat border style.
825 sal_Int32 mnScrollBars
; ///< Horizontal/vertical scroll bar.
826 sal_Int32 mnCycleType
; ///< Cycle in all forms or in this form.
827 sal_Int32 mnSpecialEffect
; ///< 3D border effect.
828 sal_Int32 mnPicAlign
; ///< Anchor position of the picture.
829 sal_Int32 mnPicSizeMode
; ///< Clip, stretch, zoom.
830 bool mbPicTiling
; ///< True = picture is repeated.
831 bool mbFontSupport
; ///< True = control supports the font property.
835 /** Model for a Forms 2.0 frame control. */
836 class OOX_DLLPUBLIC AxFrameModel final
: public AxContainerModelBase
839 explicit AxFrameModel();
841 virtual ApiControlType
getControlType() const override
;
842 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
845 class UNLESS_MERGELIBS(OOX_DLLPUBLIC
) AxPageModel final
: public AxContainerModelBase
848 explicit AxPageModel();
850 virtual ApiControlType
getControlType() const override
;
851 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
854 class UNLESS_MERGELIBS(OOX_DLLPUBLIC
) AxMultiPageModel final
: public AxContainerModelBase
857 explicit AxMultiPageModel();
859 virtual ApiControlType
getControlType() const override
;
860 void importPageAndMultiPageProperties( BinaryInputStream
& rInStrm
, sal_Int32 nPages
);
861 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
862 std::vector
<sal_uInt32
> mnIDs
;
863 sal_uInt32 mnActiveTab
;
864 sal_uInt32 mnTabStyle
;
868 /** Model for a Forms 2.0 user form. */
869 class UNLESS_MERGELIBS(OOX_DLLPUBLIC
) AxUserFormModel final
: public AxContainerModelBase
872 explicit AxUserFormModel();
874 virtual ApiControlType
getControlType() const override
;
875 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
878 class HtmlSelectModel final
: public AxListBoxModel
880 css::uno::Sequence
< OUString
> msListData
;
881 css::uno::Sequence
< sal_Int16
> msIndices
;
884 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
885 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
888 class HtmlTextBoxModel final
: public AxTextBoxModel
891 explicit HtmlTextBoxModel();
892 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
896 /** A form control embedded in a document draw page. Contains a specific model
897 structure according to the type of the control. */
898 class OOX_DLLPUBLIC EmbeddedControl
901 explicit EmbeddedControl( OUString aName
);
903 /** Creates and returns the internal control model of the specified type. */
904 template< typename ModelType
>
905 inline ModelType
& createModel();
907 /** Creates and returns the internal control model of the specified type. */
908 template< typename ModelType
, typename ParamType
>
909 inline ModelType
& createModel( const ParamType
& rParam
);
911 /** Creates and returns the internal control model according to the passed
912 MS class identifier. */
913 ControlModelBase
* createModelFromGuid( std::u16string_view rClassId
);
915 /** Returns true, if the internal control model exists. */
916 bool hasModel() const { return bool(mxModel
); }
917 /** Returns read-only access to the internal control model. */
918 const ControlModelBase
* getModel() const { return mxModel
.get(); }
919 /** Returns read/write access to the internal control model. */
920 ControlModelBase
* getModel() { return mxModel
.get(); }
922 /** Returns the UNO service name needed to construct the control model. */
923 OUString
getServiceName() const;
925 /** Converts all control properties and inserts them into the passed model. */
926 bool convertProperties(
927 const css::uno::Reference
< css::awt::XControlModel
>& rxCtrlModel
,
928 const ControlConverter
& rConv
) const;
930 void convertFromProperties(
931 const css::uno::Reference
< css::awt::XControlModel
>& rxCtrlModel
,
932 const ControlConverter
& rConv
);
935 ControlModelRef mxModel
; ///< Control model containing the properties.
936 OUString maName
; ///< Name of the control.
940 template< typename ModelType
>
941 inline ModelType
& EmbeddedControl::createModel()
943 auto xModel
= std::make_shared
<ModelType
>();
945 xModel
->setFormComponentMode();
949 template< typename ModelType
, typename ParamType
>
950 inline ModelType
& EmbeddedControl::createModel( const ParamType
& rParam
)
952 auto xModel
= std::make_shared
<ModelType
>( rParam
);
954 xModel
->setFormComponentMode();
959 /** A wrapper for a control form embedded directly in a draw page. */
963 explicit EmbeddedForm(
964 const css::uno::Reference
< css::frame::XModel
>& rxDocModel
,
965 const css::uno::Reference
< css::drawing::XDrawPage
>& rxDrawPage
,
966 const GraphicHelper
& rGraphicHelper
);
968 /** Converts the passed control and inserts the control model into the form.
969 @return The API control model, if conversion was successful. */
970 css::uno::Reference
< css::awt::XControlModel
>
971 convertAndInsert( const EmbeddedControl
& rControl
, sal_Int32
& rnCtrlIndex
);
973 /** Returns the XIndexContainer interface of the UNO control form, if existing. */
974 const css::uno::Reference
< css::container::XIndexContainer
>&
975 getXForm() const { return mxFormIC
; }
978 /** Creates the form that will hold the form controls. */
979 css::uno::Reference
< css::container::XIndexContainer
> const &
983 ControlConverter maControlConv
;
984 css::uno::Reference
< css::lang::XMultiServiceFactory
> mxModelFactory
;
985 css::uno::Reference
< css::form::XFormsSupplier
> mxFormsSupp
;
986 css::uno::Reference
< css::container::XIndexContainer
> mxFormIC
;
990 } // namespace oox::ole
994 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */