Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / include / oox / ole / axcontrol.hxx
blob4d91f975fc1cd0e84db168083f8b3c6499847df4
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 ApiTransparencyMode
178 API_TRANSPARENCY_NOTSUPPORTED, ///< Control does not support transparency.
179 API_TRANSPARENCY_VOID, ///< Transparency is enabled by missing fill color.
180 API_TRANSPARENCY_PAINTTRANSPARENT ///< Transparency is enabled by the 'PaintTransparent' property.
183 /** Specifies how a form control supports the DefaultState property. */
184 enum ApiDefaultStateMode
186 API_DEFAULTSTATE_BOOLEAN, ///< Control does not support tri-state, state is given as boolean.
187 API_DEFAULTSTATE_SHORT, ///< Control does not support tri-state, state is given as short.
188 API_DEFAULTSTATE_TRISTATE ///< Control supports tri-state, state is given as short.
192 /** A base class with useful helper functions for something that is able to
193 convert ActiveX and ComCtl form controls.
195 class OOX_DLLPUBLIC ControlConverter
197 public:
198 explicit ControlConverter(
199 const css::uno::Reference< css::frame::XModel >& rxDocModel,
200 const GraphicHelper& rGraphicHelper,
201 bool bDefaultColorBgr = true );
202 virtual ~ControlConverter();
204 // Generic conversion -----------------------------------------------------
206 /** Converts the passed position in 1/100 mm to UNO properties. */
207 void convertPosition(
208 PropertyMap& rPropMap,
209 const AxPairData& rPos ) const;
211 /** Converts the passed size in 1/100 mm to UNO properties. */
212 void convertSize(
213 PropertyMap& rPropMap,
214 const AxPairData& rSize ) const;
216 /** Converts the passed encoded OLE color to UNO properties. */
217 void convertColor(
218 PropertyMap& rPropMap,
219 sal_Int32 nPropId,
220 sal_uInt32 nOleColor ) const;
222 static void convertToMSColor(
223 PropertySet& rPropSet,
224 sal_Int32 nPropId,
225 sal_uInt32& nOleColor,
226 sal_uInt32 nDefault = 0 );
229 /** Converts the passed StdPic picture stream to UNO properties. */
230 void convertPicture(
231 PropertyMap& rPropMap,
232 const StreamDataSequence& rPicData ) const;
234 /** Converts the control orientation to UNO properties. */
235 static void convertOrientation(
236 PropertyMap& rPropMap,
237 bool bHorizontal );
239 static void convertToMSOrientation(
240 PropertySet& rPropMap,
241 bool& bHorizontal );
243 /** Converts the vertical alignment to UNO properties. */
244 static void convertVerticalAlign(
245 PropertyMap& rPropMap,
246 sal_Int32 nVerticalAlign );
248 /** Converts common scrollbar settings to UNO properties. */
249 static void convertScrollBar(
250 PropertyMap& rPropMap,
251 sal_Int32 nMin, sal_Int32 nMax, sal_Int32 nPosition,
252 sal_Int32 nSmallChange, sal_Int32 nLargeChange, bool bAwtModel );
254 /** Converts scrollability settings to UNO properties. */
255 void convertScrollabilitySettings(
256 PropertyMap& rPropMap,
257 const AxPairData& rScrollPos, const AxPairData& rScrollArea,
258 sal_Int32 nScrollBars ) const;
260 /** Binds the passed control model to the passed data sources. The
261 implementation will check which source types are supported. */
262 void bindToSources(
263 const css::uno::Reference< css::awt::XControlModel >& rxCtrlModel,
264 const OUString& rCtrlSource,
265 const OUString& rRowSource,
266 sal_Int32 nRefSheet = 0 ) const;
268 // ActiveX (Forms 2.0) specific conversion --------------------------------
270 /** Converts the Forms 2.0 background formatting to UNO properties. */
271 void convertAxBackground(
272 PropertyMap& rPropMap,
273 sal_uInt32 nBackColor,
274 sal_uInt32 nFlags,
275 ApiTransparencyMode eTranspMode ) const;
277 /** Converts the Forms 2.0 border formatting to UNO properties. */
278 void convertAxBorder(
279 PropertyMap& rPropMap,
280 sal_uInt32 nBorderColor,
281 sal_Int32 nBorderStyle,
282 sal_Int32 nSpecialEffect ) const;
284 static void convertToAxBorder(
285 PropertySet& rPropSet,
286 sal_uInt32& nBorderColor,
287 sal_Int32& nBorderStyle,
288 sal_Int32& nSpecialEffect );
290 /** Converts the Forms 2.0 special effect to UNO properties. */
291 static void convertAxVisualEffect(
292 PropertyMap& rPropMap,
293 sal_Int32 nSpecialEffect );
295 static void convertToAxVisualEffect(
296 PropertySet& rPropSet,
297 sal_Int32& nSpecialEffect );
299 /** Converts the passed picture stream and Forms 2.0 position to UNO
300 properties. */
301 void convertAxPicture(
302 PropertyMap& rPropMap,
303 const StreamDataSequence& rPicData,
304 sal_uInt32 nPicPos ) const;
306 /** Converts the passed picture stream and Forms 2.0 position to UNO
307 properties. */
308 void convertAxPicture(
309 PropertyMap& rPropMap,
310 const StreamDataSequence& rPicData,
311 sal_Int32 nPicSizeMode,
312 sal_Int32 nPicAlign,
313 bool bPicTiling ) const;
315 /** Converts the Forms 2.0 value for checked/unchecked/dontknow to UNO
316 properties. */
317 static void convertAxState(
318 PropertyMap& rPropMap,
319 const OUString& rValue,
320 sal_Int32 nMultiSelect,
321 ApiDefaultStateMode eDefStateMode,
322 bool bAwtModel );
324 static void convertToAxState(
325 PropertySet& rPropSet,
326 OUString& rValue,
327 sal_Int32& nMultiSelect,
328 ApiDefaultStateMode eDefStateMode,
329 bool bAwtModel );
331 /** Converts the Forms 2.0 control orientation to UNO properties. */
332 static void convertAxOrientation(
333 PropertyMap& rPropMap,
334 const AxPairData& rSize,
335 sal_Int32 nOrientation );
337 static void convertToAxOrientation(
338 PropertySet& rPropSet,
339 const AxPairData& rSize,
340 sal_Int32& nOrientation );
342 private:
343 css::uno::Reference< css::frame::XModel > mxDocModel;
344 const GraphicHelper& mrGraphicHelper;
345 mutable PropertySet maAddressConverter;
346 mutable PropertySet maRangeConverter;
347 bool mbDefaultColorBgr;
351 /** Base class for all models of form controls. */
352 class OOX_DLLPUBLIC ControlModelBase
354 public:
355 explicit ControlModelBase();
356 virtual ~ControlModelBase();
358 /** Sets this control model to AWT model mode. */
359 void setAwtModelMode() { mbAwtModel = true; }
360 /** Sets this control model to form component mode. */
361 void setFormComponentMode() { mbAwtModel = false; }
363 /** Returns the UNO service name used to construct the AWT control model,
364 or the control form component. */
365 OUString getServiceName() const;
367 /** Derived classes set specific OOXML properties at the model structure. */
368 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue );
369 /** Derived classes set binary data (picture, mouse icon) at the model structure. */
370 virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm );
371 /** Derived classes import a form control model from the passed input stream. */
372 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) = 0;
373 /** Derived classes export a form control model to the passed output stream. */
374 virtual void exportBinaryModel( BinaryOutputStream& /*rOutStrm*/ ) {}
375 /** Derived classes export CompObjStream contents. */
376 virtual void exportCompObj( BinaryOutputStream& /*rOutStrm*/ ) {}
377 /** Derived classes return the UNO control type enum value. */
378 virtual ApiControlType getControlType() const = 0;
379 /** Derived classes convert all control properties. */
380 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
381 /** Derived classes convert from uno control properties to equiv. MS values. */
382 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv );
384 /** Converts the control size to UNO properties. */
385 void convertSize( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
387 public: // direct access needed for legacy VML drawing controls
388 AxPairData maSize; ///< Size of the control in 1/100 mm.
390 protected:
391 bool mbAwtModel; ///< True = AWT control model, false = form component.
394 typedef std::shared_ptr< ControlModelBase > ControlModelRef;
397 /** Base class for all models of ComCtl form controls. */
398 class ComCtlModelBase : public ControlModelBase
400 public:
401 explicit ComCtlModelBase(
402 sal_uInt32 nDataPartId5, sal_uInt32 nDataPartId6, sal_uInt16 nVersion,
403 bool bCommonPart, bool bComplexPart );
405 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
406 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
408 protected:
409 virtual void importControlData( BinaryInputStream& rInStrm ) = 0;
411 private:
412 /** Returns the data part identifier according to the model version. */
413 sal_uInt32 getDataPartId() const;
415 static bool readPartHeader( BinaryInputStream& rInStrm,
416 sal_uInt32 nExpPartId,
417 sal_uInt16 nExpMajor = SAL_MAX_UINT16,
418 sal_uInt16 nExpMinor = SAL_MAX_UINT16 );
420 bool importSizePart( BinaryInputStream& rInStrm );
421 bool importCommonPart( BinaryInputStream& rInStrm, sal_uInt32 nPartSize );
422 bool importComplexPart( BinaryInputStream& rInStrm );
424 protected:
425 StdFontInfo maFontData; ///< Font formatting.
426 StreamDataSequence maMouseIcon; ///< Binary picture stream for mouse icon.
427 sal_uInt32 mnFlags; ///< Common flags for ComCtl controls.
428 const sal_uInt16 mnVersion; ///< Current version of the ComCtl control model.
430 private:
431 sal_uInt32 mnDataPartId5; ///< Identifier for version 5.0 control data.
432 sal_uInt32 mnDataPartId6; ///< Identifier for version 6.0 control data.
433 bool mbCommonPart; ///< True = the COMCTL_COMMONDATA part exists.
434 bool mbComplexPart; ///< True = the COMCTL_COMPLEXDATA part exists.
438 /** Model for a ComCtl scroll bar. */
439 class ComCtlScrollBarModel : public ComCtlModelBase
441 public:
442 explicit ComCtlScrollBarModel( sal_uInt16 nVersion );
444 virtual ApiControlType getControlType() const override;
445 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
447 protected:
448 virtual void importControlData( BinaryInputStream& rInStrm ) override;
450 private:
451 sal_uInt32 mnScrollBarFlags; ///< Special flags for scroll bar model.
452 sal_Int32 mnLargeChange; ///< Increment step size (thumb).
453 sal_Int32 mnSmallChange; ///< Increment step size (buttons).
454 sal_Int32 mnMin; ///< Minimum of the value range.
455 sal_Int32 mnMax; ///< Maximum of the value range.
456 sal_Int32 mnPosition; ///< Value of the spin button.
460 /** Model for a ComCtl progress bar. */
461 class ComCtlProgressBarModel : public ComCtlModelBase
463 public:
464 explicit ComCtlProgressBarModel( sal_uInt16 nVersion );
466 virtual ApiControlType getControlType() const override;
467 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
469 protected:
470 virtual void importControlData( BinaryInputStream& rInStrm ) override;
472 private:
473 float mfMin; ///< Minimum of the value range.
474 float mfMax; ///< Maximum of the value range.
475 sal_uInt16 mnVertical; ///< 0 = horizontal, 1 = vertical.
476 sal_uInt16 mnSmooth; ///< 0 = progress blocks, 1 = pixel resolution.
480 /** Base class for all models of Form 2.0 form controls. */
481 class OOX_DLLPUBLIC AxControlModelBase : public ControlModelBase
483 public:
484 explicit AxControlModelBase();
486 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
490 /** Base class for Forms 2.0 controls supporting text formatting. */
491 class OOX_DLLPUBLIC AxFontDataModel : public AxControlModelBase
493 public:
494 explicit AxFontDataModel( bool bSupportsAlign = true );
496 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
497 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
498 virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
499 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
500 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
502 /** Returns the font height in points. */
503 sal_Int16 getFontHeight() const { return maFontData.getHeightPoints(); }
505 public: // direct access needed for legacy VML drawing controls
506 AxFontData maFontData; ///< The font settings.
508 private:
509 bool mbSupportsAlign; ///< True = UNO model supports Align property.
513 /** Model for a Forms 2.0 command button. */
514 class OOX_DLLPUBLIC AxCommandButtonModel : public AxFontDataModel
516 public:
517 explicit AxCommandButtonModel();
519 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
520 virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ) override;
521 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
522 virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
523 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
525 virtual ApiControlType getControlType() const override;
526 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
527 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
529 public: // direct access needed for legacy VML drawing controls
530 StreamDataSequence maPictureData; ///< Binary picture stream.
531 OUString maCaption; ///< Visible caption of the button.
532 sal_uInt32 mnTextColor; ///< Text color.
533 sal_uInt32 mnBackColor; ///< Fill color.
534 sal_uInt32 mnFlags; ///< Various flags.
535 sal_uInt32 mnPicturePos; ///< Position of the picture relative to text.
536 sal_Int32 mnVerticalAlign; ///< Vertical alignment (legacy VML drawing controls only).
537 bool mbFocusOnClick; ///< True = take focus on click.
541 /** Model for a Forms 2.0 label. */
542 class OOX_DLLPUBLIC AxLabelModel : public AxFontDataModel
544 public:
545 explicit AxLabelModel();
547 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
548 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
549 virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
550 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
552 virtual ApiControlType getControlType() const override;
553 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
554 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
556 public: // direct access needed for legacy VML drawing controls
557 OUString maCaption; ///< Visible caption of the button.
558 sal_uInt32 mnTextColor; ///< Text color.
559 sal_uInt32 mnBackColor; ///< Fill color.
560 sal_uInt32 mnFlags; ///< Various flags.
561 sal_uInt32 mnBorderColor; ///< Flat border color.
562 sal_Int32 mnBorderStyle; ///< Flat border style.
563 sal_Int32 mnSpecialEffect; ///< 3D border effect.
564 sal_Int32 mnVerticalAlign; ///< Vertical alignment (legacy VML drawing controls only).
568 /** Model for a Forms 2.0 image. */
569 class OOX_DLLPUBLIC AxImageModel : public AxControlModelBase
571 public:
572 explicit AxImageModel();
574 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
575 virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ) override;
576 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
577 virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
578 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
580 virtual ApiControlType getControlType() const override;
581 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
583 private:
584 StreamDataSequence maPictureData; ///< Binary picture stream.
585 sal_uInt32 mnBackColor; ///< Fill color.
586 sal_uInt32 mnFlags; ///< Various flags.
587 sal_uInt32 mnBorderColor; ///< Flat border color.
588 sal_Int32 mnBorderStyle; ///< Flat border style.
589 sal_Int32 mnSpecialEffect; ///< 3D border effect.
590 sal_Int32 mnPicSizeMode; ///< Clip, stretch, zoom.
591 sal_Int32 mnPicAlign; ///< Anchor position of the picture.
592 bool mbPicTiling; ///< True = picture is repeated.
595 class OOX_DLLPUBLIC AxTabStripModel : public AxFontDataModel
597 public:
598 explicit AxTabStripModel();
600 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
602 virtual ApiControlType getControlType() const override;
604 public:
605 sal_uInt32 mnListIndex;
606 sal_uInt32 mnTabStyle;
607 sal_uInt32 mnTabData;
608 sal_uInt32 mnVariousPropertyBits;
609 std::vector< ::rtl::OUString > maItems; // captions for each tab
610 std::vector< ::rtl::OUString > maTabNames; // names for each tab
614 /** Base class for a Forms 2.0 morph data control. */
615 class OOX_DLLPUBLIC AxMorphDataModelBase : public AxFontDataModel
617 public:
618 explicit AxMorphDataModelBase();
620 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
621 virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ) override;
622 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
623 virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
624 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
626 public: // direct access needed for legacy VML drawing controls
627 StreamDataSequence maPictureData; ///< Binary picture stream.
628 OUString maCaption; ///< Visible caption of the button.
629 OUString maValue; ///< Current value of the control.
630 OUString maGroupName; ///< Group name for option buttons.
631 sal_uInt32 mnTextColor; ///< Text color.
632 sal_uInt32 mnBackColor; ///< Fill color.
633 sal_uInt32 mnFlags; ///< Various flags.
634 sal_uInt32 mnPicturePos; ///< Position of the picture relative to text.
635 sal_uInt32 mnBorderColor; ///< Flat border color.
636 sal_Int32 mnBorderStyle; ///< Flat border style.
637 sal_Int32 mnSpecialEffect; ///< 3D border effect.
638 sal_Int32 mnDisplayStyle; ///< Type of the morph control.
639 sal_Int32 mnMultiSelect; ///< Selection mode.
640 sal_Int32 mnScrollBars; ///< Horizontal/vertical scroll bar.
641 sal_Int32 mnMatchEntry; ///< Auto completion mode.
642 sal_Int32 mnShowDropButton; ///< When to show the dropdown button.
643 sal_Int32 mnMaxLength; ///< Maximum character count.
644 sal_Int32 mnPasswordChar; ///< Password character in edit fields.
645 sal_Int32 mnListRows; ///< Number of rows in dropdown box.
646 sal_Int32 mnVerticalAlign; ///< Vertical alignment (legacy VML drawing controls only).
650 /** Model for a Forms 2.0 toggle button. */
651 class OOX_DLLPUBLIC AxToggleButtonModel : public AxMorphDataModelBase
653 public:
654 explicit AxToggleButtonModel();
656 virtual ApiControlType getControlType() const override;
657 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
658 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
659 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
663 /** Model for a Forms 2.0 check box. */
664 class OOX_DLLPUBLIC AxCheckBoxModel : public AxMorphDataModelBase
666 public:
667 explicit AxCheckBoxModel();
669 virtual ApiControlType getControlType() const override;
670 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
671 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
672 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
676 /** Model for a Forms 2.0 option button. */
677 class OOX_DLLPUBLIC AxOptionButtonModel : public AxMorphDataModelBase
679 public:
680 explicit AxOptionButtonModel();
682 /** Returns the group name used to goup several option buttons together. */
683 const OUString& getGroupName() const { return maGroupName; }
685 virtual ApiControlType getControlType() const override;
686 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
687 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
688 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
692 /** Model for a Forms 2.0 text box. */
693 class OOX_DLLPUBLIC AxTextBoxModel : public AxMorphDataModelBase
695 public:
696 explicit AxTextBoxModel();
698 virtual ApiControlType getControlType() const override;
699 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
700 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
701 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
705 /** Model for a numeric field (legacy drawing controls only). */
706 class OOX_DLLPUBLIC AxNumericFieldModel : public AxMorphDataModelBase
708 public:
709 explicit AxNumericFieldModel();
711 virtual ApiControlType getControlType() const override;
712 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
713 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
714 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
718 /** Model for a Forms 2.0 list box. */
719 class OOX_DLLPUBLIC AxListBoxModel : public AxMorphDataModelBase
721 public:
722 explicit AxListBoxModel();
724 virtual ApiControlType getControlType() const override;
725 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
726 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
727 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
731 /** Model for a Forms 2.0 combo box. */
732 class OOX_DLLPUBLIC AxComboBoxModel : public AxMorphDataModelBase
734 public:
735 explicit AxComboBoxModel();
737 virtual ApiControlType getControlType() const override;
738 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
739 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
740 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
744 /** Model for a Forms 2.0 spin button. */
745 class OOX_DLLPUBLIC AxSpinButtonModel : public AxControlModelBase
747 public:
748 explicit AxSpinButtonModel();
750 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
751 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
752 virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
754 virtual ApiControlType getControlType() const override;
755 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
756 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
757 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
759 public: // direct access needed for legacy VML drawing controls
760 sal_uInt32 mnArrowColor; ///< Button arrow color.
761 sal_uInt32 mnBackColor; ///< Fill color.
762 sal_uInt32 mnFlags; ///< Various flags.
763 sal_Int32 mnOrientation; ///< Orientation of the buttons.
764 sal_Int32 mnMin; ///< Minimum of the value range.
765 sal_Int32 mnMax; ///< Maximum of the value range.
766 sal_Int32 mnPosition; ///< Value of the spin button.
767 sal_Int32 mnSmallChange; ///< Increment step size.
768 sal_Int32 mnDelay; ///< Repeat delay in milliseconds.
772 /** Model for a Forms 2.0 scroll bar. */
773 class OOX_DLLPUBLIC AxScrollBarModel : public AxControlModelBase
775 public:
776 explicit AxScrollBarModel();
778 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
779 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
780 virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
781 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
783 virtual ApiControlType getControlType() const override;
784 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
785 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
787 public: // direct access needed for legacy VML drawing controls
788 sal_uInt32 mnArrowColor; ///< Button arrow color.
789 sal_uInt32 mnBackColor; ///< Fill color.
790 sal_uInt32 mnFlags; ///< Various flags.
791 sal_Int32 mnOrientation; ///< Orientation of the buttons.
792 sal_Int32 mnPropThumb; ///< Proportional thumb size.
793 sal_Int32 mnMin; ///< Minimum of the value range.
794 sal_Int32 mnMax; ///< Maximum of the value range.
795 sal_Int32 mnPosition; ///< Value of the spin button.
796 sal_Int32 mnSmallChange; ///< Increment step size (buttons).
797 sal_Int32 mnLargeChange; ///< Increment step size (thumb).
798 sal_Int32 mnDelay; ///< Repeat delay in milliseconds.
802 typedef ::std::vector< OUString > AxClassTable;
804 /** Base class for ActiveX container controls. */
805 class OOX_DLLPUBLIC AxContainerModelBase : public AxFontDataModel
807 public:
808 explicit AxContainerModelBase( bool bFontSupport = false );
810 /** Allows to set single properties specified by XML token identifier. */
811 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
812 /** Reads the leading structure in the 'f' stream containing the model for
813 this control. */
814 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
815 /** Converts font settings if supported. */
816 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
818 /** Reads the class table structure for embedded controls following the own
819 model from the 'f' stream. */
820 bool importClassTable( BinaryInputStream& rInStrm, AxClassTable& orClassTable );
822 public: // direct access needed for legacy VML drawing controls
823 StreamDataSequence maPictureData; ///< Binary picture stream.
824 OUString maCaption; ///< Visible caption of the form.
825 AxPairData maLogicalSize; ///< Logical form size (scroll area).
826 AxPairData maScrollPos; ///< Scroll position.
827 sal_uInt32 mnBackColor; ///< Fill color.
828 sal_uInt32 mnTextColor; ///< Text color.
829 sal_uInt32 mnFlags; ///< Various flags.
830 sal_uInt32 mnBorderColor; ///< Flat border color.
831 sal_Int32 mnBorderStyle; ///< Flat border style.
832 sal_Int32 mnScrollBars; ///< Horizontal/vertical scroll bar.
833 sal_Int32 mnCycleType; ///< Cycle in all forms or in this form.
834 sal_Int32 mnSpecialEffect; ///< 3D border effect.
835 sal_Int32 mnPicAlign; ///< Anchor position of the picture.
836 sal_Int32 mnPicSizeMode; ///< Clip, stretch, zoom.
837 bool mbPicTiling; ///< True = picture is repeated.
838 bool mbFontSupport; ///< True = control supports the font property.
842 /** Model for a Forms 2.0 frame control. */
843 class OOX_DLLPUBLIC AxFrameModel : public AxContainerModelBase
845 public:
846 explicit AxFrameModel();
848 virtual ApiControlType getControlType() const override;
849 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
852 class OOX_DLLPUBLIC AxPageModel : public AxContainerModelBase
854 public:
855 explicit AxPageModel();
857 virtual ApiControlType getControlType() const override;
858 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
861 class OOX_DLLPUBLIC AxMultiPageModel : public AxContainerModelBase
863 public:
864 explicit AxMultiPageModel();
866 virtual ApiControlType getControlType() const override;
867 void importPageAndMultiPageProperties( BinaryInputStream& rInStrm, sal_Int32 nPages );
868 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
869 std::vector<sal_uInt32> mnIDs;
870 sal_uInt32 mnActiveTab;
871 sal_uInt32 mnTabStyle;
875 /** Model for a Forms 2.0 user form. */
876 class OOX_DLLPUBLIC AxUserFormModel : public AxContainerModelBase
878 public:
879 explicit AxUserFormModel();
881 virtual ApiControlType getControlType() const override;
882 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
885 class HtmlSelectModel : public AxListBoxModel
887 css::uno::Sequence< OUString > msListData;
888 css::uno::Sequence< sal_Int16 > msIndices;
889 public:
890 HtmlSelectModel();
891 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
892 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
895 class HtmlTextBoxModel : public AxTextBoxModel
897 public:
898 explicit HtmlTextBoxModel();
899 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
903 /** A form control embedded in a document draw page. Contains a specific model
904 structure according to the type of the control. */
905 class OOX_DLLPUBLIC EmbeddedControl
907 public:
908 explicit EmbeddedControl( const OUString& rName );
909 virtual ~EmbeddedControl();
911 /** Creates and returns the internal control model of the specified type. */
912 template< typename ModelType >
913 inline ModelType& createModel();
915 /** Creates and returns the internal control model of the specified type. */
916 template< typename ModelType, typename ParamType >
917 inline ModelType& createModel( const ParamType& rParam );
919 /** Creates and returns the internal control model according to the passed
920 MS class identifier. */
921 ControlModelBase* createModelFromGuid( const OUString& rClassId );
923 /** Returns true, if the internal control model exists. */
924 bool hasModel() const { return mxModel.get() != nullptr; }
925 /** Returns read-only access to the internal control model. */
926 const ControlModelBase* getModel() const { return mxModel.get(); }
927 /** Returns read/write access to the internal control model. */
928 ControlModelBase* getModel() { return mxModel.get(); }
930 /** Returns the UNO service name needed to construct the control model. */
931 OUString getServiceName() const;
933 /** Converts all control properties and inserts them into the passed model. */
934 bool convertProperties(
935 const css::uno::Reference< css::awt::XControlModel >& rxCtrlModel,
936 const ControlConverter& rConv ) const;
938 void convertFromProperties(
939 const css::uno::Reference< css::awt::XControlModel >& rxCtrlModel,
940 const ControlConverter& rConv );
942 private:
943 ControlModelRef mxModel; ///< Control model containing the properties.
944 OUString maName; ///< Name of the control.
948 template< typename ModelType >
949 inline ModelType& EmbeddedControl::createModel()
951 std::shared_ptr< ModelType > xModel( new ModelType );
952 mxModel = xModel;
953 xModel->setFormComponentMode();
954 return *xModel;
957 template< typename ModelType, typename ParamType >
958 inline ModelType& EmbeddedControl::createModel( const ParamType& rParam )
960 std::shared_ptr< ModelType > xModel( new ModelType( rParam ) );
961 mxModel = xModel;
962 xModel->setFormComponentMode();
963 return *xModel;
967 /** A wrapper for a control form embedded directly in a draw page. */
968 class EmbeddedForm
970 public:
971 explicit EmbeddedForm(
972 const css::uno::Reference< css::frame::XModel >& rxDocModel,
973 const css::uno::Reference< css::drawing::XDrawPage >& rxDrawPage,
974 const GraphicHelper& rGraphicHelper,
975 bool bDefaultColorBgr = true );
977 /** Converts the passed control and inserts the control model into the form.
978 @return The API control model, if conversion was successful. */
979 css::uno::Reference< css::awt::XControlModel >
980 convertAndInsert( const EmbeddedControl& rControl, sal_Int32& rnCtrlIndex );
982 /** Returns the XIndexContainer interface of the UNO control form, if existing. */
983 const css::uno::Reference< css::container::XIndexContainer >&
984 getXForm() const { return mxFormIC; }
986 private:
987 /** Creates the form that will hold the form controls. */
988 css::uno::Reference< css::container::XIndexContainer >
989 createXForm();
991 private:
992 ControlConverter maControlConv;
993 css::uno::Reference< css::lang::XMultiServiceFactory > mxModelFactory;
994 css::uno::Reference< css::form::XFormsSupplier > mxFormsSupp;
995 css::uno::Reference< css::container::XIndexContainer > mxFormIC;
999 } // namespace ole
1000 } // namespace oox
1002 #endif
1004 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */