Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / oox / ole / axcontrol.hxx
blob25a91398a201fe290c43f9af64a7aa6ddb1e4db7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <memory>
24 #include <vector>
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; }
44 } } }
46 namespace oox {
47 class BinaryInputStream;
48 class BinaryOutputStream;
49 class GraphicHelper;
50 class PropertyMap;
53 namespace oox {
54 namespace ole {
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. */
152 enum ApiControlType
154 API_CONTROL_BUTTON,
155 API_CONTROL_FIXEDTEXT,
156 API_CONTROL_IMAGE,
157 API_CONTROL_CHECKBOX,
158 API_CONTROL_RADIOBUTTON,
159 API_CONTROL_EDIT,
160 API_CONTROL_NUMERIC,
161 API_CONTROL_LISTBOX,
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
196 public:
197 explicit ControlConverter(
198 const css::uno::Reference< css::frame::XModel >& rxDocModel,
199 const GraphicHelper& rGraphicHelper,
200 bool bDefaultColorBgr = true );
201 ~ControlConverter();
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. */
211 void convertSize(
212 PropertyMap& rPropMap,
213 const AxPairData& rSize ) const;
215 /** Converts the passed encoded OLE color to UNO properties. */
216 void convertColor(
217 PropertyMap& rPropMap,
218 sal_Int32 nPropId,
219 sal_uInt32 nOleColor ) const;
221 static void convertToMSColor(
222 PropertySet& rPropSet,
223 sal_Int32 nPropId,
224 sal_uInt32& nOleColor,
225 sal_uInt32 nDefault = 0 );
228 /** Converts the passed StdPic picture stream to UNO properties. */
229 void convertPicture(
230 PropertyMap& rPropMap,
231 const StreamDataSequence& rPicData ) const;
233 /** Converts the control orientation to UNO properties. */
234 static void convertOrientation(
235 PropertyMap& rPropMap,
236 bool bHorizontal );
238 static void convertToMSOrientation(
239 PropertySet& rPropMap,
240 bool& bHorizontal );
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. */
261 void bindToSources(
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,
273 sal_uInt32 nFlags,
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& 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& rPropSet,
296 sal_Int32& nSpecialEffect );
298 /** Converts the passed picture stream and Forms 2.0 position to UNO
299 properties. */
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
306 properties. */
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
313 properties. */
314 static void convertAxState(
315 PropertyMap& rPropMap,
316 const OUString& rValue,
317 sal_Int32 nMultiSelect,
318 ApiDefaultStateMode eDefStateMode,
319 bool bAwtModel );
321 static void convertToAxState(
322 PropertySet& rPropSet,
323 OUString& rValue,
324 sal_Int32& nMultiSelect,
325 ApiDefaultStateMode eDefStateMode,
326 bool bAwtModel );
328 /** Converts the Forms 2.0 control orientation to UNO properties. */
329 static void convertAxOrientation(
330 PropertyMap& rPropMap,
331 const AxPairData& rSize,
332 sal_Int32 nOrientation );
334 static void convertToAxOrientation(
335 PropertySet& rPropSet,
336 const AxPairData& rSize,
337 sal_Int32& nOrientation );
339 private:
340 css::uno::Reference< css::frame::XModel > mxDocModel;
341 const GraphicHelper& mrGraphicHelper;
342 mutable PropertySet maAddressConverter;
343 mutable PropertySet maRangeConverter;
344 bool mbDefaultColorBgr;
348 /** Base class for all models of form controls. */
349 class OOX_DLLPUBLIC ControlModelBase
351 public:
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.
387 protected:
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
397 public:
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;
404 protected:
405 virtual void importControlData( BinaryInputStream& rInStrm ) = 0;
407 private:
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 );
420 protected:
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.
426 private:
427 sal_uInt32 mnDataPartId5; ///< Identifier for version 5.0 control data.
428 sal_uInt32 mnDataPartId6; ///< Identifier for version 6.0 control data.
429 bool mbCommonPart; ///< True = the COMCTL_COMMONDATA part exists.
430 bool mbComplexPart; ///< True = the COMCTL_COMPLEXDATA part exists.
434 /** Model for a ComCtl scroll bar. */
435 class ComCtlScrollBarModel : public ComCtlModelBase
437 public:
438 explicit ComCtlScrollBarModel( sal_uInt16 nVersion );
440 virtual ApiControlType getControlType() const override;
441 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
443 protected:
444 virtual void importControlData( BinaryInputStream& rInStrm ) override;
446 private:
447 sal_uInt32 mnScrollBarFlags; ///< Special flags for scroll bar model.
448 sal_Int32 mnLargeChange; ///< Increment step size (thumb).
449 sal_Int32 mnSmallChange; ///< Increment step size (buttons).
450 sal_Int32 mnMin; ///< Minimum of the value range.
451 sal_Int32 mnMax; ///< Maximum of the value range.
452 sal_Int32 mnPosition; ///< Value of the spin button.
456 /** Model for a ComCtl progress bar. */
457 class ComCtlProgressBarModel : public ComCtlModelBase
459 public:
460 explicit ComCtlProgressBarModel( sal_uInt16 nVersion );
462 virtual ApiControlType getControlType() const override;
463 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
465 protected:
466 virtual void importControlData( BinaryInputStream& rInStrm ) override;
468 private:
469 float mfMin; ///< Minimum of the value range.
470 float mfMax; ///< Maximum of the value range.
471 sal_uInt16 mnVertical; ///< 0 = horizontal, 1 = vertical.
472 sal_uInt16 mnSmooth; ///< 0 = progress blocks, 1 = pixel resolution.
476 /** Base class for all models of Form 2.0 form controls. */
477 class OOX_DLLPUBLIC AxControlModelBase : public ControlModelBase
479 public:
480 explicit AxControlModelBase();
482 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
486 /** Base class for Forms 2.0 controls supporting text formatting. */
487 class OOX_DLLPUBLIC AxFontDataModel : public AxControlModelBase
489 public:
490 explicit AxFontDataModel( bool bSupportsAlign = true );
492 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
493 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
494 virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
495 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
496 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
498 /** Returns the font height in points. */
499 sal_Int16 getFontHeight() const { return maFontData.getHeightPoints(); }
501 public: // direct access needed for legacy VML drawing controls
502 AxFontData maFontData; ///< The font settings.
504 private:
505 bool mbSupportsAlign; ///< True = UNO model supports Align property.
509 /** Model for a Forms 2.0 command button. */
510 class OOX_DLLPUBLIC AxCommandButtonModel : public AxFontDataModel
512 public:
513 explicit AxCommandButtonModel();
515 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
516 virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ) override;
517 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
518 virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
519 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
521 virtual ApiControlType getControlType() const override;
522 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
523 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
525 public: // direct access needed for legacy VML drawing controls
526 StreamDataSequence maPictureData; ///< Binary picture stream.
527 OUString maCaption; ///< Visible caption of the button.
528 sal_uInt32 mnTextColor; ///< Text color.
529 sal_uInt32 mnBackColor; ///< Fill color.
530 sal_uInt32 mnFlags; ///< Various flags.
531 sal_uInt32 mnPicturePos; ///< Position of the picture relative to text.
532 sal_Int32 mnVerticalAlign; ///< Vertical alignment (legacy VML drawing controls only).
533 bool mbFocusOnClick; ///< True = take focus on click.
537 /** Model for a Forms 2.0 label. */
538 class OOX_DLLPUBLIC AxLabelModel : public AxFontDataModel
540 public:
541 explicit AxLabelModel();
543 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
544 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
545 virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
546 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
548 virtual ApiControlType getControlType() const override;
549 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
550 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
552 public: // direct access needed for legacy VML drawing controls
553 OUString maCaption; ///< Visible caption of the button.
554 sal_uInt32 mnTextColor; ///< Text color.
555 sal_uInt32 mnBackColor; ///< Fill color.
556 sal_uInt32 mnFlags; ///< Various flags.
557 sal_uInt32 mnBorderColor; ///< Flat border color.
558 sal_Int32 mnBorderStyle; ///< Flat border style.
559 sal_Int32 mnSpecialEffect; ///< 3D border effect.
560 sal_Int32 mnVerticalAlign; ///< Vertical alignment (legacy VML drawing controls only).
564 /** Model for a Forms 2.0 image. */
565 class OOX_DLLPUBLIC AxImageModel : public AxControlModelBase
567 public:
568 explicit AxImageModel();
570 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
571 virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ) override;
572 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
573 virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
574 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
576 virtual ApiControlType getControlType() const override;
577 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
579 private:
580 StreamDataSequence maPictureData; ///< Binary picture stream.
581 sal_uInt32 mnBackColor; ///< Fill color.
582 sal_uInt32 mnFlags; ///< Various flags.
583 sal_uInt32 mnBorderColor; ///< Flat border color.
584 sal_Int32 mnBorderStyle; ///< Flat border style.
585 sal_Int32 mnSpecialEffect; ///< 3D border effect.
586 sal_Int32 mnPicSizeMode; ///< Clip, stretch, zoom.
587 sal_Int32 mnPicAlign; ///< Anchor position of the picture.
588 bool mbPicTiling; ///< True = picture is repeated.
591 class OOX_DLLPUBLIC AxTabStripModel : public AxFontDataModel
593 public:
594 explicit AxTabStripModel();
596 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
598 virtual ApiControlType getControlType() const override;
600 public:
601 sal_uInt32 mnListIndex;
602 sal_uInt32 mnTabStyle;
603 sal_uInt32 mnTabData;
604 sal_uInt32 mnVariousPropertyBits;
605 std::vector< ::rtl::OUString > maItems; // captions for each tab
606 std::vector< ::rtl::OUString > maTabNames; // names for each tab
610 /** Base class for a Forms 2.0 morph data control. */
611 class OOX_DLLPUBLIC AxMorphDataModelBase : public AxFontDataModel
613 public:
614 explicit AxMorphDataModelBase();
616 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
617 virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ) override;
618 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
619 virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
620 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
622 public: // direct access needed for legacy VML drawing controls
623 StreamDataSequence maPictureData; ///< Binary picture stream.
624 OUString maCaption; ///< Visible caption of the button.
625 OUString maValue; ///< Current value of the control.
626 OUString maGroupName; ///< Group name for option buttons.
627 sal_uInt32 mnTextColor; ///< Text color.
628 sal_uInt32 mnBackColor; ///< Fill color.
629 sal_uInt32 mnFlags; ///< Various flags.
630 sal_uInt32 mnPicturePos; ///< Position of the picture relative to text.
631 sal_uInt32 mnBorderColor; ///< Flat border color.
632 sal_Int32 mnBorderStyle; ///< Flat border style.
633 sal_Int32 mnSpecialEffect; ///< 3D border effect.
634 sal_Int32 mnDisplayStyle; ///< Type of the morph control.
635 sal_Int32 mnMultiSelect; ///< Selection mode.
636 sal_Int32 mnScrollBars; ///< Horizontal/vertical scroll bar.
637 sal_Int32 mnMatchEntry; ///< Auto completion mode.
638 sal_Int32 mnShowDropButton; ///< When to show the dropdown button.
639 sal_Int32 mnMaxLength; ///< Maximum character count.
640 sal_Int32 mnPasswordChar; ///< Password character in edit fields.
641 sal_Int32 mnListRows; ///< Number of rows in dropdown box.
642 sal_Int32 mnVerticalAlign; ///< Vertical alignment (legacy VML drawing controls only).
646 /** Model for a Forms 2.0 toggle button. */
647 class OOX_DLLPUBLIC AxToggleButtonModel : public AxMorphDataModelBase
649 public:
650 explicit AxToggleButtonModel();
652 virtual ApiControlType getControlType() const override;
653 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
654 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
655 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
659 /** Model for a Forms 2.0 check box. */
660 class OOX_DLLPUBLIC AxCheckBoxModel : public AxMorphDataModelBase
662 public:
663 explicit AxCheckBoxModel();
665 virtual ApiControlType getControlType() const override;
666 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
667 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
668 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
672 /** Model for a Forms 2.0 option button. */
673 class OOX_DLLPUBLIC AxOptionButtonModel : public AxMorphDataModelBase
675 public:
676 explicit AxOptionButtonModel();
678 /** Returns the group name used to goup several option buttons together. */
679 const OUString& getGroupName() const { return maGroupName; }
681 virtual ApiControlType getControlType() const override;
682 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
683 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
684 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
688 /** Model for a Forms 2.0 text box. */
689 class OOX_DLLPUBLIC AxTextBoxModel : public AxMorphDataModelBase
691 public:
692 explicit AxTextBoxModel();
694 virtual ApiControlType getControlType() const override;
695 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
696 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
697 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
701 /** Model for a numeric field (legacy drawing controls only). */
702 class OOX_DLLPUBLIC AxNumericFieldModel : public AxMorphDataModelBase
704 public:
705 explicit AxNumericFieldModel();
707 virtual ApiControlType getControlType() const override;
708 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
709 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
710 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
714 /** Model for a Forms 2.0 list box. */
715 class OOX_DLLPUBLIC AxListBoxModel : public AxMorphDataModelBase
717 public:
718 explicit AxListBoxModel();
720 virtual ApiControlType getControlType() const override;
721 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
722 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
723 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
727 /** Model for a Forms 2.0 combo box. */
728 class OOX_DLLPUBLIC AxComboBoxModel : public AxMorphDataModelBase
730 public:
731 explicit AxComboBoxModel();
733 virtual ApiControlType getControlType() const override;
734 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
735 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
736 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
740 /** Model for a Forms 2.0 spin button. */
741 class OOX_DLLPUBLIC AxSpinButtonModel : public AxControlModelBase
743 public:
744 explicit AxSpinButtonModel();
746 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
747 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
748 virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
750 virtual ApiControlType getControlType() const override;
751 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
752 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
753 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
755 public: // direct access needed for legacy VML drawing controls
756 sal_uInt32 mnArrowColor; ///< Button arrow color.
757 sal_uInt32 mnBackColor; ///< Fill color.
758 sal_uInt32 mnFlags; ///< Various flags.
759 sal_Int32 mnOrientation; ///< Orientation of the buttons.
760 sal_Int32 mnMin; ///< Minimum of the value range.
761 sal_Int32 mnMax; ///< Maximum of the value range.
762 sal_Int32 mnPosition; ///< Value of the spin button.
763 sal_Int32 mnSmallChange; ///< Increment step size.
764 sal_Int32 mnDelay; ///< Repeat delay in milliseconds.
768 /** Model for a Forms 2.0 scroll bar. */
769 class OOX_DLLPUBLIC AxScrollBarModel : public AxControlModelBase
771 public:
772 explicit AxScrollBarModel();
774 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
775 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
776 virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
777 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
779 virtual ApiControlType getControlType() const override;
780 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
781 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
783 public: // direct access needed for legacy VML drawing controls
784 sal_uInt32 mnArrowColor; ///< Button arrow color.
785 sal_uInt32 mnBackColor; ///< Fill color.
786 sal_uInt32 mnFlags; ///< Various flags.
787 sal_Int32 mnOrientation; ///< Orientation of the buttons.
788 sal_Int32 mnPropThumb; ///< Proportional thumb size.
789 sal_Int32 mnMin; ///< Minimum of the value range.
790 sal_Int32 mnMax; ///< Maximum of the value range.
791 sal_Int32 mnPosition; ///< Value of the spin button.
792 sal_Int32 mnSmallChange; ///< Increment step size (buttons).
793 sal_Int32 mnLargeChange; ///< Increment step size (thumb).
794 sal_Int32 mnDelay; ///< Repeat delay in milliseconds.
798 typedef ::std::vector< OUString > AxClassTable;
800 /** Base class for ActiveX container controls. */
801 class OOX_DLLPUBLIC AxContainerModelBase : public AxFontDataModel
803 public:
804 explicit AxContainerModelBase( bool bFontSupport = false );
806 /** Allows to set single properties specified by XML token identifier. */
807 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
808 /** Reads the leading structure in the 'f' stream containing the model for
809 this control. */
810 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
811 /** Converts font settings if supported. */
812 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
814 /** Reads the class table structure for embedded controls following the own
815 model from the 'f' stream. */
816 bool importClassTable( BinaryInputStream& rInStrm, AxClassTable& orClassTable );
818 public: // direct access needed for legacy VML drawing controls
819 StreamDataSequence maPictureData; ///< Binary picture stream.
820 OUString maCaption; ///< Visible caption of the form.
821 AxPairData maLogicalSize; ///< Logical form size (scroll area).
822 AxPairData maScrollPos; ///< Scroll position.
823 sal_uInt32 mnBackColor; ///< Fill color.
824 sal_uInt32 mnTextColor; ///< Text color.
825 sal_uInt32 mnFlags; ///< Various flags.
826 sal_uInt32 mnBorderColor; ///< Flat border color.
827 sal_Int32 mnBorderStyle; ///< Flat border style.
828 sal_Int32 mnScrollBars; ///< Horizontal/vertical scroll bar.
829 sal_Int32 mnCycleType; ///< Cycle in all forms or in this form.
830 sal_Int32 mnSpecialEffect; ///< 3D border effect.
831 sal_Int32 mnPicAlign; ///< Anchor position of the picture.
832 sal_Int32 mnPicSizeMode; ///< Clip, stretch, zoom.
833 bool mbPicTiling; ///< True = picture is repeated.
834 bool mbFontSupport; ///< True = control supports the font property.
838 /** Model for a Forms 2.0 frame control. */
839 class OOX_DLLPUBLIC AxFrameModel : public AxContainerModelBase
841 public:
842 explicit AxFrameModel();
844 virtual ApiControlType getControlType() const override;
845 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
848 class OOX_DLLPUBLIC AxPageModel : public AxContainerModelBase
850 public:
851 explicit AxPageModel();
853 virtual ApiControlType getControlType() const override;
854 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
857 class OOX_DLLPUBLIC AxMultiPageModel : public AxContainerModelBase
859 public:
860 explicit AxMultiPageModel();
862 virtual ApiControlType getControlType() const override;
863 void importPageAndMultiPageProperties( BinaryInputStream& rInStrm, sal_Int32 nPages );
864 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
865 std::vector<sal_uInt32> mnIDs;
866 sal_uInt32 mnActiveTab;
867 sal_uInt32 mnTabStyle;
871 /** Model for a Forms 2.0 user form. */
872 class OOX_DLLPUBLIC AxUserFormModel : public AxContainerModelBase
874 public:
875 explicit AxUserFormModel();
877 virtual ApiControlType getControlType() const override;
878 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
881 class HtmlSelectModel : public AxListBoxModel
883 css::uno::Sequence< OUString > msListData;
884 css::uno::Sequence< sal_Int16 > msIndices;
885 public:
886 HtmlSelectModel();
887 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
888 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
891 class HtmlTextBoxModel : public AxTextBoxModel
893 public:
894 explicit HtmlTextBoxModel();
895 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
899 /** A form control embedded in a document draw page. Contains a specific model
900 structure according to the type of the control. */
901 class OOX_DLLPUBLIC EmbeddedControl
903 public:
904 explicit EmbeddedControl( const OUString& rName );
906 /** Creates and returns the internal control model of the specified type. */
907 template< typename ModelType >
908 inline ModelType& createModel();
910 /** Creates and returns the internal control model of the specified type. */
911 template< typename ModelType, typename ParamType >
912 inline ModelType& createModel( const ParamType& rParam );
914 /** Creates and returns the internal control model according to the passed
915 MS class identifier. */
916 ControlModelBase* createModelFromGuid( const OUString& rClassId );
918 /** Returns true, if the internal control model exists. */
919 bool hasModel() const { return mxModel.get() != nullptr; }
920 /** Returns read-only access to the internal control model. */
921 const ControlModelBase* getModel() const { return mxModel.get(); }
922 /** Returns read/write access to the internal control model. */
923 ControlModelBase* getModel() { return mxModel.get(); }
925 /** Returns the UNO service name needed to construct the control model. */
926 OUString getServiceName() const;
928 /** Converts all control properties and inserts them into the passed model. */
929 bool convertProperties(
930 const css::uno::Reference< css::awt::XControlModel >& rxCtrlModel,
931 const ControlConverter& rConv ) const;
933 void convertFromProperties(
934 const css::uno::Reference< css::awt::XControlModel >& rxCtrlModel,
935 const ControlConverter& rConv );
937 private:
938 ControlModelRef mxModel; ///< Control model containing the properties.
939 OUString maName; ///< Name of the control.
943 template< typename ModelType >
944 inline ModelType& EmbeddedControl::createModel()
946 std::shared_ptr< ModelType > xModel( new ModelType );
947 mxModel = xModel;
948 xModel->setFormComponentMode();
949 return *xModel;
952 template< typename ModelType, typename ParamType >
953 inline ModelType& EmbeddedControl::createModel( const ParamType& rParam )
955 std::shared_ptr< ModelType > xModel( new ModelType( rParam ) );
956 mxModel = xModel;
957 xModel->setFormComponentMode();
958 return *xModel;
962 /** A wrapper for a control form embedded directly in a draw page. */
963 class EmbeddedForm
965 public:
966 explicit EmbeddedForm(
967 const css::uno::Reference< css::frame::XModel >& rxDocModel,
968 const css::uno::Reference< css::drawing::XDrawPage >& rxDrawPage,
969 const GraphicHelper& rGraphicHelper );
971 /** Converts the passed control and inserts the control model into the form.
972 @return The API control model, if conversion was successful. */
973 css::uno::Reference< css::awt::XControlModel >
974 convertAndInsert( const EmbeddedControl& rControl, sal_Int32& rnCtrlIndex );
976 /** Returns the XIndexContainer interface of the UNO control form, if existing. */
977 const css::uno::Reference< css::container::XIndexContainer >&
978 getXForm() const { return mxFormIC; }
980 private:
981 /** Creates the form that will hold the form controls. */
982 css::uno::Reference< css::container::XIndexContainer > const &
983 createXForm();
985 private:
986 ControlConverter maControlConv;
987 css::uno::Reference< css::lang::XMultiServiceFactory > mxModelFactory;
988 css::uno::Reference< css::form::XFormsSupplier > mxFormsSupp;
989 css::uno::Reference< css::container::XIndexContainer > mxFormIC;
993 } // namespace ole
994 } // namespace oox
996 #endif
998 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */