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
);
337 const css::uno::Reference
<css::frame::XModel
> GetDocModel() const { return mxDocModel
; }
340 css::uno::Reference
< css::frame::XModel
> mxDocModel
;
341 const GraphicHelper
& mrGraphicHelper
;
342 mutable PropertySet maAddressConverter
;
343 mutable PropertySet maRangeConverter
;
344 bool const mbDefaultColorBgr
;
348 /** Base class for all models of form controls. */
349 class OOX_DLLPUBLIC ControlModelBase
352 explicit ControlModelBase();
353 virtual ~ControlModelBase();
355 /** Sets this control model to AWT model mode. */
356 void setAwtModelMode() { mbAwtModel
= true; }
357 /** Sets this control model to form component mode. */
358 void setFormComponentMode() { mbAwtModel
= false; }
360 /** Returns the UNO service name used to construct the AWT control model,
361 or the control form component. */
362 OUString
getServiceName() const;
364 /** Derived classes set specific OOXML properties at the model structure. */
365 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
);
366 /** Derived classes set binary data (picture, mouse icon) at the model structure. */
367 virtual void importPictureData( sal_Int32 nPropId
, BinaryInputStream
& rInStrm
);
368 /** Derived classes import a form control model from the passed input stream. */
369 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) = 0;
370 /** Derived classes export a form control model to the passed output stream. */
371 virtual void exportBinaryModel( BinaryOutputStream
& /*rOutStrm*/ ) {}
372 /** Derived classes export CompObjStream contents. */
373 virtual void exportCompObj( BinaryOutputStream
& /*rOutStrm*/ ) {}
374 /** Derived classes return the UNO control type enum value. */
375 virtual ApiControlType
getControlType() const = 0;
376 /** Derived classes convert all control properties. */
377 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const;
378 /** Derived classes convert from uno control properties to equiv. MS values. */
379 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
);
381 /** Converts the control size to UNO properties. */
382 void convertSize( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const;
384 public: // direct access needed for legacy VML drawing controls
385 AxPairData maSize
; ///< Size of the control in 1/100 mm.
388 bool mbAwtModel
; ///< True = AWT control model, false = form component.
391 typedef std::shared_ptr
< ControlModelBase
> ControlModelRef
;
394 /** Base class for all models of ComCtl form controls. */
395 class ComCtlModelBase
: public ControlModelBase
398 explicit ComCtlModelBase(
399 sal_uInt32 nDataPartId5
, sal_uInt32 nDataPartId6
, sal_uInt16 nVersion
);
401 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
402 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
405 virtual void importControlData( BinaryInputStream
& rInStrm
) = 0;
408 /** Returns the data part identifier according to the model version. */
409 sal_uInt32
getDataPartId() const;
411 static bool readPartHeader( BinaryInputStream
& rInStrm
,
412 sal_uInt32 nExpPartId
,
413 sal_uInt16 nExpMajor
= SAL_MAX_UINT16
,
414 sal_uInt16 nExpMinor
= SAL_MAX_UINT16
);
416 bool importSizePart( BinaryInputStream
& rInStrm
);
417 bool importCommonPart( BinaryInputStream
& rInStrm
, sal_uInt32 nPartSize
);
418 bool importComplexPart( BinaryInputStream
& rInStrm
);
421 StdFontInfo maFontData
; ///< Font formatting.
422 StreamDataSequence maMouseIcon
; ///< Binary picture stream for mouse icon.
423 sal_uInt32 mnFlags
; ///< Common flags for ComCtl controls.
424 const sal_uInt16 mnVersion
; ///< Current version of the ComCtl control model.
427 sal_uInt32
const mnDataPartId5
; ///< Identifier for version 5.0 control data.
428 sal_uInt32
const mnDataPartId6
; ///< Identifier for version 6.0 control data.
432 /** Model for a ComCtl scroll bar. */
433 class ComCtlScrollBarModel
: 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
;
445 sal_uInt32 mnScrollBarFlags
; ///< Special flags for scroll bar model.
446 sal_Int32 mnLargeChange
; ///< Increment step size (thumb).
447 sal_Int32 mnSmallChange
; ///< Increment step size (buttons).
448 sal_Int32 mnMin
; ///< Minimum of the value range.
449 sal_Int32 mnMax
; ///< Maximum of the value range.
450 sal_Int32 mnPosition
; ///< Value of the spin button.
454 /** Model for a ComCtl progress bar. */
455 class ComCtlProgressBarModel
: public ComCtlModelBase
458 explicit ComCtlProgressBarModel( sal_uInt16 nVersion
);
460 virtual ApiControlType
getControlType() const override
;
461 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
464 virtual void importControlData( BinaryInputStream
& rInStrm
) override
;
467 float mfMin
; ///< Minimum of the value range.
468 float mfMax
; ///< Maximum of the value range.
469 sal_uInt16 mnVertical
; ///< 0 = horizontal, 1 = vertical.
470 sal_uInt16 mnSmooth
; ///< 0 = progress blocks, 1 = pixel resolution.
474 /** Base class for all models of Form 2.0 form controls. */
475 class OOX_DLLPUBLIC AxControlModelBase
: public ControlModelBase
478 explicit AxControlModelBase();
480 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) override
;
484 /** Base class for Forms 2.0 controls supporting text formatting. */
485 class OOX_DLLPUBLIC AxFontDataModel
: public AxControlModelBase
488 explicit AxFontDataModel( bool bSupportsAlign
= true );
490 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) override
;
491 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
492 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) override
;
493 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
494 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
496 /** Returns the font height in points. */
497 sal_Int16
getFontHeight() const { return maFontData
.getHeightPoints(); }
499 public: // direct access needed for legacy VML drawing controls
500 AxFontData maFontData
; ///< The font settings.
503 bool const mbSupportsAlign
; ///< True = UNO model supports Align property.
507 /** Model for a Forms 2.0 command button. */
508 class OOX_DLLPUBLIC AxCommandButtonModel
: public AxFontDataModel
511 explicit AxCommandButtonModel();
513 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) override
;
514 virtual void importPictureData( sal_Int32 nPropId
, BinaryInputStream
& rInStrm
) override
;
515 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
516 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) override
;
517 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
519 virtual ApiControlType
getControlType() const override
;
520 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
521 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
523 public: // direct access needed for legacy VML drawing controls
524 StreamDataSequence maPictureData
; ///< Binary picture stream.
525 OUString maCaption
; ///< Visible caption of the button.
526 sal_uInt32 mnTextColor
; ///< Text color.
527 sal_uInt32 mnBackColor
; ///< Fill color.
528 sal_uInt32 mnFlags
; ///< Various flags.
529 sal_uInt32 mnPicturePos
; ///< Position of the picture relative to text.
530 sal_Int32 mnVerticalAlign
; ///< Vertical alignment (legacy VML drawing controls only).
531 bool mbFocusOnClick
; ///< True = take focus on click.
535 /** Model for a Forms 2.0 label. */
536 class OOX_DLLPUBLIC AxLabelModel
: public AxFontDataModel
539 explicit AxLabelModel();
541 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) override
;
542 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
543 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) override
;
544 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
546 virtual ApiControlType
getControlType() const override
;
547 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
548 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
550 public: // direct access needed for legacy VML drawing controls
551 OUString maCaption
; ///< Visible caption of the button.
552 sal_uInt32 mnTextColor
; ///< Text color.
553 sal_uInt32 mnBackColor
; ///< Fill color.
554 sal_uInt32 mnFlags
; ///< Various flags.
555 sal_uInt32 mnBorderColor
; ///< Flat border color.
556 sal_Int32 mnBorderStyle
; ///< Flat border style.
557 sal_Int32 mnSpecialEffect
; ///< 3D border effect.
558 sal_Int32 mnVerticalAlign
; ///< Vertical alignment (legacy VML drawing controls only).
562 /** Model for a Forms 2.0 image. */
563 class OOX_DLLPUBLIC AxImageModel
: public AxControlModelBase
566 explicit AxImageModel();
568 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) override
;
569 virtual void importPictureData( sal_Int32 nPropId
, BinaryInputStream
& rInStrm
) override
;
570 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
571 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) override
;
572 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
574 virtual ApiControlType
getControlType() const override
;
575 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
578 StreamDataSequence maPictureData
; ///< Binary picture stream.
579 sal_uInt32 mnBackColor
; ///< Fill color.
580 sal_uInt32 mnFlags
; ///< Various flags.
581 sal_uInt32 mnBorderColor
; ///< Flat border color.
582 sal_Int32 mnBorderStyle
; ///< Flat border style.
583 sal_Int32 mnSpecialEffect
; ///< 3D border effect.
584 sal_Int32 mnPicSizeMode
; ///< Clip, stretch, zoom.
585 sal_Int32 mnPicAlign
; ///< Anchor position of the picture.
586 bool mbPicTiling
; ///< True = picture is repeated.
589 class OOX_DLLPUBLIC AxTabStripModel
: public AxFontDataModel
592 explicit AxTabStripModel();
594 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
596 virtual ApiControlType
getControlType() const override
;
599 sal_uInt32 mnListIndex
;
600 sal_uInt32 mnTabStyle
;
601 sal_uInt32 mnTabData
;
602 sal_uInt32 mnVariousPropertyBits
;
603 std::vector
< OUString
> maItems
; // captions for each tab
604 std::vector
< OUString
> maTabNames
; // names for each tab
608 /** Base class for a Forms 2.0 morph data control. */
609 class OOX_DLLPUBLIC AxMorphDataModelBase
: public AxFontDataModel
612 explicit AxMorphDataModelBase();
614 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) override
;
615 virtual void importPictureData( sal_Int32 nPropId
, BinaryInputStream
& rInStrm
) override
;
616 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
617 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) override
;
618 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
619 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
621 public: // direct access needed for legacy VML drawing controls
622 StreamDataSequence maPictureData
; ///< Binary picture stream.
623 OUString maCaption
; ///< Visible caption of the button.
624 OUString maValue
; ///< Current value of the control.
625 OUString maGroupName
; ///< Group name for option buttons.
626 sal_uInt32 mnTextColor
; ///< Text color.
627 sal_uInt32 mnBackColor
; ///< Fill color.
628 sal_uInt32 mnFlags
; ///< Various flags.
629 sal_uInt32 mnPicturePos
; ///< Position of the picture relative to text.
630 sal_uInt32 mnBorderColor
; ///< Flat border color.
631 sal_Int32 mnBorderStyle
; ///< Flat border style.
632 sal_Int32 mnSpecialEffect
; ///< 3D border effect.
633 sal_Int32 mnDisplayStyle
; ///< Type of the morph control.
634 sal_Int32 mnMultiSelect
; ///< Selection mode.
635 sal_Int32 mnScrollBars
; ///< Horizontal/vertical scroll bar.
636 sal_Int32 mnMatchEntry
; ///< Auto completion mode.
637 sal_Int32 mnShowDropButton
; ///< When to show the dropdown button.
638 sal_Int32 mnMaxLength
; ///< Maximum character count.
639 sal_Int32 mnPasswordChar
; ///< Password character in edit fields.
640 sal_Int32 mnListRows
; ///< Number of rows in dropdown box.
641 sal_Int32 mnVerticalAlign
; ///< Vertical alignment (legacy VML drawing controls only).
645 /** Model for a Forms 2.0 toggle button. */
646 class OOX_DLLPUBLIC AxToggleButtonModel
: public AxMorphDataModelBase
649 explicit AxToggleButtonModel();
651 virtual ApiControlType
getControlType() const override
;
652 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
653 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
654 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
658 /** Model for a Forms 2.0 check box. */
659 class OOX_DLLPUBLIC AxCheckBoxModel
: public AxMorphDataModelBase
662 explicit AxCheckBoxModel();
664 virtual ApiControlType
getControlType() const override
;
665 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
666 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
667 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
671 /** Model for a Forms 2.0 option button. */
672 class OOX_DLLPUBLIC AxOptionButtonModel
: public AxMorphDataModelBase
675 explicit AxOptionButtonModel();
677 /** Returns the group name used to goup several option buttons together. */
678 const OUString
& getGroupName() const { return maGroupName
; }
680 virtual ApiControlType
getControlType() const override
;
681 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
682 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
683 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
687 /** Model for a Forms 2.0 text box. */
688 class OOX_DLLPUBLIC AxTextBoxModel
: public AxMorphDataModelBase
691 explicit AxTextBoxModel();
693 virtual ApiControlType
getControlType() const override
;
694 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
695 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
696 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
700 /** Model for a numeric field (legacy drawing controls only). */
701 class OOX_DLLPUBLIC AxNumericFieldModel
: public AxMorphDataModelBase
704 explicit AxNumericFieldModel();
706 virtual ApiControlType
getControlType() const override
;
707 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
708 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
709 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
713 /** Model for a Forms 2.0 list box. */
714 class OOX_DLLPUBLIC AxListBoxModel
: public AxMorphDataModelBase
717 explicit AxListBoxModel();
719 virtual ApiControlType
getControlType() const override
;
720 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
721 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
722 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
726 /** Model for a Forms 2.0 combo box. */
727 class OOX_DLLPUBLIC AxComboBoxModel
: public AxMorphDataModelBase
730 explicit AxComboBoxModel();
732 virtual ApiControlType
getControlType() const override
;
733 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
734 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
735 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
739 /** Model for a Forms 2.0 spin button. */
740 class OOX_DLLPUBLIC AxSpinButtonModel
: public AxControlModelBase
743 explicit AxSpinButtonModel();
745 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) override
;
746 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
747 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) override
;
749 virtual ApiControlType
getControlType() const override
;
750 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
751 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
752 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
754 public: // direct access needed for legacy VML drawing controls
755 sal_uInt32 mnArrowColor
; ///< Button arrow color.
756 sal_uInt32 mnBackColor
; ///< Fill color.
757 sal_uInt32 mnFlags
; ///< Various flags.
758 sal_Int32 mnOrientation
; ///< Orientation of the buttons.
759 sal_Int32 mnMin
; ///< Minimum of the value range.
760 sal_Int32 mnMax
; ///< Maximum of the value range.
761 sal_Int32 mnPosition
; ///< Value of the spin button.
762 sal_Int32 mnSmallChange
; ///< Increment step size.
763 sal_Int32 mnDelay
; ///< Repeat delay in milliseconds.
767 /** Model for a Forms 2.0 scroll bar. */
768 class OOX_DLLPUBLIC AxScrollBarModel
: public AxControlModelBase
771 explicit AxScrollBarModel();
773 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) override
;
774 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
775 virtual void exportBinaryModel( BinaryOutputStream
& rOutStrm
) override
;
776 virtual void exportCompObj( BinaryOutputStream
& rOutStrm
) override
;
778 virtual ApiControlType
getControlType() const override
;
779 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
780 virtual void convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
) override
;
782 public: // direct access needed for legacy VML drawing controls
783 sal_uInt32 mnArrowColor
; ///< Button arrow color.
784 sal_uInt32 mnBackColor
; ///< Fill color.
785 sal_uInt32 mnFlags
; ///< Various flags.
786 sal_Int32 mnOrientation
; ///< Orientation of the buttons.
787 sal_Int32 mnPropThumb
; ///< Proportional thumb size.
788 sal_Int32 mnMin
; ///< Minimum of the value range.
789 sal_Int32 mnMax
; ///< Maximum of the value range.
790 sal_Int32 mnPosition
; ///< Value of the spin button.
791 sal_Int32 mnSmallChange
; ///< Increment step size (buttons).
792 sal_Int32 mnLargeChange
; ///< Increment step size (thumb).
793 sal_Int32 mnDelay
; ///< Repeat delay in milliseconds.
797 typedef ::std::vector
< OUString
> AxClassTable
;
799 /** Base class for ActiveX container controls. */
800 class OOX_DLLPUBLIC AxContainerModelBase
: public AxFontDataModel
803 explicit AxContainerModelBase( bool bFontSupport
= false );
805 /** Allows to set single properties specified by XML token identifier. */
806 virtual void importProperty( sal_Int32 nPropId
, const OUString
& rValue
) override
;
807 /** Reads the leading structure in the 'f' stream containing the model for
809 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
810 /** Converts font settings if supported. */
811 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
813 /** Reads the class table structure for embedded controls following the own
814 model from the 'f' stream. */
815 bool importClassTable( BinaryInputStream
& rInStrm
, AxClassTable
& orClassTable
);
817 public: // direct access needed for legacy VML drawing controls
818 StreamDataSequence maPictureData
; ///< Binary picture stream.
819 OUString maCaption
; ///< Visible caption of the form.
820 AxPairData maLogicalSize
; ///< Logical form size (scroll area).
821 AxPairData maScrollPos
; ///< Scroll position.
822 sal_uInt32 mnBackColor
; ///< Fill color.
823 sal_uInt32 mnTextColor
; ///< Text color.
824 sal_uInt32 mnFlags
; ///< Various flags.
825 sal_uInt32 mnBorderColor
; ///< Flat border color.
826 sal_Int32 mnBorderStyle
; ///< Flat border style.
827 sal_Int32 mnScrollBars
; ///< Horizontal/vertical scroll bar.
828 sal_Int32 mnCycleType
; ///< Cycle in all forms or in this form.
829 sal_Int32 mnSpecialEffect
; ///< 3D border effect.
830 sal_Int32 mnPicAlign
; ///< Anchor position of the picture.
831 sal_Int32 mnPicSizeMode
; ///< Clip, stretch, zoom.
832 bool mbPicTiling
; ///< True = picture is repeated.
833 bool const mbFontSupport
; ///< True = control supports the font property.
837 /** Model for a Forms 2.0 frame control. */
838 class OOX_DLLPUBLIC AxFrameModel
: public AxContainerModelBase
841 explicit AxFrameModel();
843 virtual ApiControlType
getControlType() const override
;
844 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
847 class OOX_DLLPUBLIC AxPageModel
: public AxContainerModelBase
850 explicit AxPageModel();
852 virtual ApiControlType
getControlType() const override
;
853 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
856 class OOX_DLLPUBLIC AxMultiPageModel
: public AxContainerModelBase
859 explicit AxMultiPageModel();
861 virtual ApiControlType
getControlType() const override
;
862 void importPageAndMultiPageProperties( BinaryInputStream
& rInStrm
, sal_Int32 nPages
);
863 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
864 std::vector
<sal_uInt32
> mnIDs
;
865 sal_uInt32 mnActiveTab
;
866 sal_uInt32 mnTabStyle
;
870 /** Model for a Forms 2.0 user form. */
871 class OOX_DLLPUBLIC AxUserFormModel
: public AxContainerModelBase
874 explicit AxUserFormModel();
876 virtual ApiControlType
getControlType() const override
;
877 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
880 class HtmlSelectModel
: public AxListBoxModel
882 css::uno::Sequence
< OUString
> msListData
;
883 css::uno::Sequence
< sal_Int16
> msIndices
;
886 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
887 virtual void convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const override
;
890 class HtmlTextBoxModel
: public AxTextBoxModel
893 explicit HtmlTextBoxModel();
894 virtual bool importBinaryModel( BinaryInputStream
& rInStrm
) override
;
898 /** A form control embedded in a document draw page. Contains a specific model
899 structure according to the type of the control. */
900 class OOX_DLLPUBLIC EmbeddedControl
903 explicit EmbeddedControl( const OUString
& rName
);
905 /** Creates and returns the internal control model of the specified type. */
906 template< typename ModelType
>
907 inline ModelType
& createModel();
909 /** Creates and returns the internal control model of the specified type. */
910 template< typename ModelType
, typename ParamType
>
911 inline ModelType
& createModel( const ParamType
& rParam
);
913 /** Creates and returns the internal control model according to the passed
914 MS class identifier. */
915 ControlModelBase
* createModelFromGuid( const OUString
& rClassId
);
917 /** Returns true, if the internal control model exists. */
918 bool hasModel() const { return mxModel
.get() != nullptr; }
919 /** Returns read-only access to the internal control model. */
920 const ControlModelBase
* getModel() const { return mxModel
.get(); }
921 /** Returns read/write access to the internal control model. */
922 ControlModelBase
* getModel() { return mxModel
.get(); }
924 /** Returns the UNO service name needed to construct the control model. */
925 OUString
getServiceName() const;
927 /** Converts all control properties and inserts them into the passed model. */
928 bool convertProperties(
929 const css::uno::Reference
< css::awt::XControlModel
>& rxCtrlModel
,
930 const ControlConverter
& rConv
) const;
932 void convertFromProperties(
933 const css::uno::Reference
< css::awt::XControlModel
>& rxCtrlModel
,
934 const ControlConverter
& rConv
);
937 ControlModelRef mxModel
; ///< Control model containing the properties.
938 OUString maName
; ///< Name of the control.
942 template< typename ModelType
>
943 inline ModelType
& EmbeddedControl::createModel()
945 std::shared_ptr
< ModelType
> xModel( new ModelType
);
947 xModel
->setFormComponentMode();
951 template< typename ModelType
, typename ParamType
>
952 inline ModelType
& EmbeddedControl::createModel( const ParamType
& rParam
)
954 std::shared_ptr
< ModelType
> xModel( new ModelType( rParam
) );
956 xModel
->setFormComponentMode();
961 /** A wrapper for a control form embedded directly in a draw page. */
965 explicit EmbeddedForm(
966 const css::uno::Reference
< css::frame::XModel
>& rxDocModel
,
967 const css::uno::Reference
< css::drawing::XDrawPage
>& rxDrawPage
,
968 const GraphicHelper
& rGraphicHelper
);
970 /** Converts the passed control and inserts the control model into the form.
971 @return The API control model, if conversion was successful. */
972 css::uno::Reference
< css::awt::XControlModel
>
973 convertAndInsert( const EmbeddedControl
& rControl
, sal_Int32
& rnCtrlIndex
);
975 /** Returns the XIndexContainer interface of the UNO control form, if existing. */
976 const css::uno::Reference
< css::container::XIndexContainer
>&
977 getXForm() const { return mxFormIC
; }
980 /** Creates the form that will hold the form controls. */
981 css::uno::Reference
< css::container::XIndexContainer
> const &
985 ControlConverter
const maControlConv
;
986 css::uno::Reference
< css::lang::XMultiServiceFactory
> mxModelFactory
;
987 css::uno::Reference
< css::form::XFormsSupplier
> mxFormsSupp
;
988 css::uno::Reference
< css::container::XIndexContainer
> mxFormIC
;
997 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */