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
26 #include <com/sun/star/uno/Reference.hxx>
27 #include <com/sun/star/uno/Sequence.hxx>
28 #include <oox/dllapi.h>
29 #include <oox/helper/binarystreambase.hxx>
30 #include <oox/helper/propertyset.hxx>
31 #include <oox/ole/axbinaryreader.hxx>
32 #include <oox/ole/axfontdata.hxx>
33 #include <oox/ole/olehelper.hxx>
34 #include <rtl/ustring.hxx>
35 #include <sal/types.h>
37 namespace com
{ namespace sun
{ namespace star
{
38 namespace awt
{ class XControlModel
; }
39 namespace container
{ class XIndexContainer
; }
40 namespace drawing
{ class XDrawPage
; }
41 namespace frame
{ class XModel
; }
42 namespace form
{ class XFormsSupplier
; }
43 namespace lang
{ class XMultiServiceFactory
; }
47 class BinaryInputStream
;
48 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 const OUString
& 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 const 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
const mnDataPartId5
; ///< Identifier for version 5.0 control data.
426 sal_uInt32
const mnDataPartId6
; ///< Identifier for version 6.0 control data.
430 /** Model for a ComCtl scroll bar. */
431 class ComCtlScrollBarModel final
: public ComCtlModelBase
434 explicit ComCtlScrollBarModel( sal_uInt16 nVersion
);
436 virtual ApiControlType
getControlType() const override
;
437 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
440 virtual void importControlData( BinaryInputStream
& rInStrm
) override
;
442 sal_uInt32 mnScrollBarFlags
; ///< Special flags for scroll bar model.
443 sal_Int32 mnLargeChange
; ///< Increment step size (thumb).
444 sal_Int32 mnSmallChange
; ///< Increment step size (buttons).
445 sal_Int32 mnMin
; ///< Minimum of the value range.
446 sal_Int32 mnMax
; ///< Maximum of the value range.
447 sal_Int32 mnPosition
; ///< Value of the spin button.
451 /** Model for a ComCtl progress bar. */
452 class ComCtlProgressBarModel final
: public ComCtlModelBase
455 explicit ComCtlProgressBarModel( sal_uInt16 nVersion
);
457 virtual ApiControlType
getControlType() const override
;
458 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
461 virtual void importControlData( BinaryInputStream
& rInStrm
) override
;
463 float mfMin
; ///< Minimum of the value range.
464 float mfMax
; ///< Maximum of the value range.
465 sal_uInt16 mnVertical
; ///< 0 = horizontal, 1 = vertical.
466 sal_uInt16 mnSmooth
; ///< 0 = progress blocks, 1 = pixel resolution.
470 /** Base class for all models of Form 2.0 form controls. */
471 class OOX_DLLPUBLIC AxControlModelBase
: public ControlModelBase
474 explicit AxControlModelBase();
476 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) override
;
480 /** Base class for Forms 2.0 controls supporting text formatting. */
481 class OOX_DLLPUBLIC AxFontDataModel
: public AxControlModelBase
484 explicit AxFontDataModel( bool bSupportsAlign
= true );
486 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) override
;
487 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
488 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) override
;
489 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
490 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
492 /** Returns the font height in points. */
493 sal_Int16
getFontHeight() const { return maFontData
.getHeightPoints(); }
495 public: // direct access needed for legacy VML drawing controls
496 AxFontData maFontData
; ///< The font settings.
499 bool const mbSupportsAlign
; ///< True = UNO model supports Align property.
503 /** Model for a Forms 2.0 command button. */
504 class OOX_DLLPUBLIC AxCommandButtonModel final
: public AxFontDataModel
507 explicit AxCommandButtonModel();
509 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) override
;
510 virtual void importPictureData( sal_Int32 nPropId
, BinaryInputStream
& rInStrm
) override
;
511 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
512 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) override
;
513 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
515 virtual ApiControlType
getControlType() const override
;
516 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
517 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
519 public: // direct access needed for legacy VML drawing controls
520 StreamDataSequence maPictureData
; ///< Binary picture stream.
521 OUString maCaption
; ///< Visible caption of the button.
522 sal_uInt32 mnTextColor
; ///< Text color.
523 sal_uInt32 mnBackColor
; ///< Fill color.
524 sal_uInt32 mnFlags
; ///< Various flags.
525 sal_uInt32 mnPicturePos
; ///< Position of the picture relative to text.
526 sal_Int32 mnVerticalAlign
; ///< Vertical alignment (legacy VML drawing controls only).
527 bool mbFocusOnClick
; ///< True = take focus on click.
531 /** Model for a Forms 2.0 label. */
532 class OOX_DLLPUBLIC AxLabelModel final
: public AxFontDataModel
535 explicit AxLabelModel();
537 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) override
;
538 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
539 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) override
;
540 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
542 virtual ApiControlType
getControlType() const override
;
543 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
544 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
546 public: // direct access needed for legacy VML drawing controls
547 OUString maCaption
; ///< Visible caption of the button.
548 sal_uInt32 mnTextColor
; ///< Text color.
549 sal_uInt32 mnBackColor
; ///< Fill color.
550 sal_uInt32 mnFlags
; ///< Various flags.
551 sal_uInt32 mnBorderColor
; ///< Flat border color.
552 sal_Int32 mnBorderStyle
; ///< Flat border style.
553 sal_Int32 mnSpecialEffect
; ///< 3D border effect.
554 sal_Int32 mnVerticalAlign
; ///< Vertical alignment (legacy VML drawing controls only).
558 /** Model for a Forms 2.0 image. */
559 class OOX_DLLPUBLIC AxImageModel final
: public AxControlModelBase
562 explicit AxImageModel();
564 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) override
;
565 virtual void importPictureData( sal_Int32 nPropId
, BinaryInputStream
& rInStrm
) override
;
566 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
567 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) override
;
568 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
570 virtual ApiControlType
getControlType() const override
;
571 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
574 StreamDataSequence maPictureData
; ///< Binary picture stream.
575 sal_uInt32 mnBackColor
; ///< Fill color.
576 sal_uInt32 mnFlags
; ///< Various flags.
577 sal_uInt32 mnBorderColor
; ///< Flat border color.
578 sal_Int32 mnBorderStyle
; ///< Flat border style.
579 sal_Int32 mnSpecialEffect
; ///< 3D border effect.
580 sal_Int32 mnPicSizeMode
; ///< Clip, stretch, zoom.
581 sal_Int32 mnPicAlign
; ///< Anchor position of the picture.
582 bool mbPicTiling
; ///< True = picture is repeated.
585 class OOX_DLLPUBLIC AxTabStripModel final
: public AxFontDataModel
588 explicit AxTabStripModel();
590 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
592 virtual ApiControlType
getControlType() const override
;
595 sal_uInt32 mnListIndex
;
596 sal_uInt32 mnTabStyle
;
597 sal_uInt32 mnTabData
;
598 sal_uInt32 mnVariousPropertyBits
;
599 std::vector
< OUString
> maItems
; // captions for each tab
600 std::vector
< OUString
> maTabNames
; // names for each tab
604 /** Base class for a Forms 2.0 morph data control. */
605 class OOX_DLLPUBLIC AxMorphDataModelBase
: public AxFontDataModel
608 explicit AxMorphDataModelBase();
610 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) override
;
611 virtual void importPictureData( sal_Int32 nPropId
, BinaryInputStream
& rInStrm
) override
;
612 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
613 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) override
;
614 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
615 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
617 public: // direct access needed for legacy VML drawing controls
618 StreamDataSequence maPictureData
; ///< Binary picture stream.
619 OUString maCaption
; ///< Visible caption of the button.
620 OUString maValue
; ///< Current value of the control.
621 OUString maGroupName
; ///< Group name for option buttons.
622 sal_uInt32 mnTextColor
; ///< Text color.
623 sal_uInt32 mnBackColor
; ///< Fill color.
624 sal_uInt32 mnFlags
; ///< Various flags.
625 sal_uInt32 mnPicturePos
; ///< Position of the picture relative to text.
626 sal_uInt32 mnBorderColor
; ///< Flat border color.
627 sal_Int32 mnBorderStyle
; ///< Flat border style.
628 sal_Int32 mnSpecialEffect
; ///< 3D border effect.
629 sal_Int32 mnDisplayStyle
; ///< Type of the morph control.
630 sal_Int32 mnMultiSelect
; ///< Selection mode.
631 sal_Int32 mnScrollBars
; ///< Horizontal/vertical scroll bar.
632 sal_Int32 mnMatchEntry
; ///< Auto completion mode.
633 sal_Int32 mnShowDropButton
; ///< When to show the dropdown button.
634 sal_Int32 mnMaxLength
; ///< Maximum character count.
635 sal_Int32 mnPasswordChar
; ///< Password character in edit fields.
636 sal_Int32 mnListRows
; ///< Number of rows in dropdown box.
637 sal_Int32 mnVerticalAlign
; ///< Vertical alignment (legacy VML drawing controls only).
641 /** Model for a Forms 2.0 toggle button. */
642 class OOX_DLLPUBLIC AxToggleButtonModel final
: public AxMorphDataModelBase
645 explicit AxToggleButtonModel();
647 virtual ApiControlType
getControlType() const override
;
648 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
649 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
650 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
654 /** Model for a Forms 2.0 check box. */
655 class OOX_DLLPUBLIC AxCheckBoxModel final
: public AxMorphDataModelBase
658 explicit AxCheckBoxModel();
660 virtual ApiControlType
getControlType() const override
;
661 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
662 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
663 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
667 /** Model for a Forms 2.0 option button. */
668 class OOX_DLLPUBLIC AxOptionButtonModel final
: public AxMorphDataModelBase
671 explicit AxOptionButtonModel();
673 /** Returns the group name used to goup several option buttons together. */
674 const OUString
& getGroupName() const { return maGroupName
; }
676 virtual ApiControlType
getControlType() const override
;
677 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
678 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
679 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
683 /** Model for a Forms 2.0 text box. */
684 class OOX_DLLPUBLIC AxTextBoxModel
: public AxMorphDataModelBase
687 explicit AxTextBoxModel();
689 virtual ApiControlType
getControlType() const override
;
690 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
691 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
692 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
696 /** Model for a numeric field (legacy drawing controls only). */
697 class OOX_DLLPUBLIC AxNumericFieldModel final
: public AxMorphDataModelBase
700 explicit AxNumericFieldModel();
702 virtual ApiControlType
getControlType() const override
;
703 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
704 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
705 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
709 /** Model for a Forms 2.0 list box. */
710 class OOX_DLLPUBLIC AxListBoxModel
: public AxMorphDataModelBase
713 explicit AxListBoxModel();
715 virtual ApiControlType
getControlType() const override
;
716 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
717 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
718 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
722 /** Model for a Forms 2.0 combo box. */
723 class OOX_DLLPUBLIC AxComboBoxModel final
: public AxMorphDataModelBase
726 explicit AxComboBoxModel();
728 virtual ApiControlType
getControlType() const override
;
729 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
730 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
731 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
735 /** Model for a Forms 2.0 spin button. */
736 class OOX_DLLPUBLIC AxSpinButtonModel final
: public AxControlModelBase
739 explicit AxSpinButtonModel();
741 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) override
;
742 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
743 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) override
;
745 virtual ApiControlType
getControlType() const override
;
746 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
747 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
748 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
750 public: // direct access needed for legacy VML drawing controls
751 sal_uInt32 mnArrowColor
; ///< Button arrow color.
752 sal_uInt32 mnBackColor
; ///< Fill color.
753 sal_uInt32 mnFlags
; ///< Various flags.
754 sal_Int32 mnOrientation
; ///< Orientation of the buttons.
755 sal_Int32 mnMin
; ///< Minimum of the value range.
756 sal_Int32 mnMax
; ///< Maximum of the value range.
757 sal_Int32 mnPosition
; ///< Value of the spin button.
758 sal_Int32 mnSmallChange
; ///< Increment step size.
759 sal_Int32 mnDelay
; ///< Repeat delay in milliseconds.
763 /** Model for a Forms 2.0 scroll bar. */
764 class OOX_DLLPUBLIC AxScrollBarModel final
: public AxControlModelBase
767 explicit AxScrollBarModel();
769 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) override
;
770 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
771 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) override
;
772 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
774 virtual ApiControlType
getControlType() const override
;
775 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
776 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
778 public: // direct access needed for legacy VML drawing controls
779 sal_uInt32 mnArrowColor
; ///< Button arrow color.
780 sal_uInt32 mnBackColor
; ///< Fill color.
781 sal_uInt32 mnFlags
; ///< Various flags.
782 sal_Int32 mnOrientation
; ///< Orientation of the buttons.
783 sal_Int32 mnPropThumb
; ///< Proportional thumb size.
784 sal_Int32 mnMin
; ///< Minimum of the value range.
785 sal_Int32 mnMax
; ///< Maximum of the value range.
786 sal_Int32 mnPosition
; ///< Value of the spin button.
787 sal_Int32 mnSmallChange
; ///< Increment step size (buttons).
788 sal_Int32 mnLargeChange
; ///< Increment step size (thumb).
789 sal_Int32 mnDelay
; ///< Repeat delay in milliseconds.
793 typedef ::std::vector
< OUString
> AxClassTable
;
795 /** Base class for ActiveX container controls. */
796 class OOX_DLLPUBLIC AxContainerModelBase
: public AxFontDataModel
799 explicit AxContainerModelBase( bool bFontSupport
= false );
801 /** Allows to set single properties specified by XML token identifier. */
802 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) override
;
803 /** Reads the leading structure in the 'f' stream containing the model for
805 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
806 /** Converts font settings if supported. */
807 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
809 /** Reads the class table structure for embedded controls following the own
810 model from the 'f' stream. */
811 bool importClassTable( BinaryInputStream
& rInStrm
, AxClassTable
& orClassTable
);
813 public: // direct access needed for legacy VML drawing controls
814 StreamDataSequence maPictureData
; ///< Binary picture stream.
815 OUString maCaption
; ///< Visible caption of the form.
816 AxPairData maLogicalSize
; ///< Logical form size (scroll area).
817 AxPairData maScrollPos
; ///< Scroll position.
818 sal_uInt32 mnBackColor
; ///< Fill color.
819 sal_uInt32 mnTextColor
; ///< Text color.
820 sal_uInt32 mnFlags
; ///< Various flags.
821 sal_uInt32 mnBorderColor
; ///< Flat border color.
822 sal_Int32 mnBorderStyle
; ///< Flat border style.
823 sal_Int32 mnScrollBars
; ///< Horizontal/vertical scroll bar.
824 sal_Int32 mnCycleType
; ///< Cycle in all forms or in this form.
825 sal_Int32 mnSpecialEffect
; ///< 3D border effect.
826 sal_Int32 mnPicAlign
; ///< Anchor position of the picture.
827 sal_Int32 mnPicSizeMode
; ///< Clip, stretch, zoom.
828 bool mbPicTiling
; ///< True = picture is repeated.
829 bool const mbFontSupport
; ///< True = control supports the font property.
833 /** Model for a Forms 2.0 frame control. */
834 class OOX_DLLPUBLIC AxFrameModel final
: public AxContainerModelBase
837 explicit AxFrameModel();
839 virtual ApiControlType
getControlType() const override
;
840 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
843 class OOX_DLLPUBLIC AxPageModel final
: public AxContainerModelBase
846 explicit AxPageModel();
848 virtual ApiControlType
getControlType() const override
;
849 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
852 class OOX_DLLPUBLIC AxMultiPageModel final
: public AxContainerModelBase
855 explicit AxMultiPageModel();
857 virtual ApiControlType
getControlType() const override
;
858 void importPageAndMultiPageProperties( BinaryInputStream
& rInStrm
, sal_Int32 nPages
);
859 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
860 std::vector
<sal_uInt32
> mnIDs
;
861 sal_uInt32 mnActiveTab
;
862 sal_uInt32 mnTabStyle
;
866 /** Model for a Forms 2.0 user form. */
867 class OOX_DLLPUBLIC AxUserFormModel final
: public AxContainerModelBase
870 explicit AxUserFormModel();
872 virtual ApiControlType
getControlType() const override
;
873 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
876 class HtmlSelectModel final
: public AxListBoxModel
878 css::uno::Sequence
< OUString
> msListData
;
879 css::uno::Sequence
< sal_Int16
> msIndices
;
882 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
883 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
886 class HtmlTextBoxModel final
: public AxTextBoxModel
889 explicit HtmlTextBoxModel();
890 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
894 /** A form control embedded in a document draw page. Contains a specific model
895 structure according to the type of the control. */
896 class OOX_DLLPUBLIC EmbeddedControl
899 explicit EmbeddedControl( const OUString
& rName
);
901 /** Creates and returns the internal control model of the specified type. */
902 template< typename ModelType
>
903 inline ModelType
& createModel();
905 /** Creates and returns the internal control model of the specified type. */
906 template< typename ModelType
, typename ParamType
>
907 inline ModelType
& createModel( const ParamType
& rParam
);
909 /** Creates and returns the internal control model according to the passed
910 MS class identifier. */
911 ControlModelBase
* createModelFromGuid( const OUString
& rClassId
);
913 /** Returns true, if the internal control model exists. */
914 bool hasModel() const { return mxModel
.get() != nullptr; }
915 /** Returns read-only access to the internal control model. */
916 const ControlModelBase
* getModel() const { return mxModel
.get(); }
917 /** Returns read/write access to the internal control model. */
918 ControlModelBase
* getModel() { return mxModel
.get(); }
920 /** Returns the UNO service name needed to construct the control model. */
921 OUString
getServiceName() const;
923 /** Converts all control properties and inserts them into the passed model. */
924 bool convertProperties(
925 const css::uno::Reference
< css::awt::XControlModel
>& rxCtrlModel
,
926 const ControlConverter
& rConv
) const;
928 void convertFromProperties(
929 const css::uno::Reference
< css::awt::XControlModel
>& rxCtrlModel
,
930 const ControlConverter
& rConv
);
933 ControlModelRef mxModel
; ///< Control model containing the properties.
934 OUString maName
; ///< Name of the control.
938 template< typename ModelType
>
939 inline ModelType
& EmbeddedControl::createModel()
941 std::shared_ptr
< ModelType
> xModel( new ModelType
);
943 xModel
->setFormComponentMode();
947 template< typename ModelType
, typename ParamType
>
948 inline ModelType
& EmbeddedControl::createModel( const ParamType
& rParam
)
950 std::shared_ptr
< ModelType
> xModel( new ModelType( rParam
) );
952 xModel
->setFormComponentMode();
957 /** A wrapper for a control form embedded directly in a draw page. */
961 explicit EmbeddedForm(
962 const css::uno::Reference
< css::frame::XModel
>& rxDocModel
,
963 const css::uno::Reference
< css::drawing::XDrawPage
>& rxDrawPage
,
964 const GraphicHelper
& rGraphicHelper
);
966 /** Converts the passed control and inserts the control model into the form.
967 @return The API control model, if conversion was successful. */
968 css::uno::Reference
< css::awt::XControlModel
>
969 convertAndInsert( const EmbeddedControl
& rControl
, sal_Int32
& rnCtrlIndex
);
971 /** Returns the XIndexContainer interface of the UNO control form, if existing. */
972 const css::uno::Reference
< css::container::XIndexContainer
>&
973 getXForm() const { return mxFormIC
; }
976 /** Creates the form that will hold the form controls. */
977 css::uno::Reference
< css::container::XIndexContainer
> const &
981 ControlConverter
const maControlConv
;
982 css::uno::Reference
< css::lang::XMultiServiceFactory
> mxModelFactory
;
983 css::uno::Reference
< css::form::XFormsSupplier
> mxFormsSupp
;
984 css::uno::Reference
< css::container::XIndexContainer
> mxFormIC
;
993 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */