Avoid potential negative array index access to cached text.
[LibreOffice.git] / include / oox / ole / axcontrol.hxx
blob28559ecbd1b95ed295034539d2f545958a67d4ac
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::sun::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; }
46 namespace oox {
47 class BinaryInputStream;
48 class BinaryOutputStream;
49 class GraphicHelper;
50 class PropertyMap;
53 namespace oox::ole {
56 #define COMCTL_GUID_SCROLLBAR_60 "{FE38753A-44A3-11D1-B5B7-0000C09000C4}"
57 #define COMCTL_GUID_PROGRESSBAR_50 "{0713E8D2-850A-101B-AFC0-4210102A8DA7}"
58 #define COMCTL_GUID_PROGRESSBAR_60 "{35053A22-8589-11D1-B16A-00C0F0283628}"
60 const sal_uInt16 COMCTL_VERSION_50 = 5;
61 const sal_uInt16 COMCTL_VERSION_60 = 6;
64 #define AX_GUID_COMMANDBUTTON "{D7053240-CE69-11CD-a777-00dd01143c57}"
65 #define AX_GUID_LABEL "{978C9E23-D4B0-11CE-bf2d-00aa003f40d0}"
66 #define AX_GUID_IMAGE "{4C599241-6926-101B-9992-00000b65c6f9}"
67 #define AX_GUID_TOGGLEBUTTON "{8BD21D60-EC42-11CE-9e0d-00aa006002f3}"
68 #define AX_GUID_CHECKBOX "{8BD21D40-EC42-11CE-9e0d-00aa006002f3}"
69 #define AX_GUID_OPTIONBUTTON "{8BD21D50-EC42-11CE-9e0d-00aa006002f3}"
70 #define AX_GUID_TEXTBOX "{8BD21D10-EC42-11CE-9e0d-00aa006002f3}"
71 #define AX_GUID_LISTBOX "{8BD21D20-EC42-11CE-9e0d-00aa006002f3}"
72 #define AX_GUID_COMBOBOX "{8BD21D30-EC42-11CE-9e0d-00aa006002f3}"
73 #define AX_GUID_SPINBUTTON "{79176FB0-B7F2-11CE-97ef-00aa006d2776}"
74 #define AX_GUID_SCROLLBAR "{DFD181E0-5E2F-11CE-a449-00aa004a803d}"
75 #define AX_GUID_FRAME "{6E182020-F460-11CE-9bcd-00aa00608e01}"
77 // Html control GUID(s)
79 #define HTML_GUID_SELECT "{5512D122-5CC6-11CF-8d67-00aa00bdce1d}"
80 #define HTML_GUID_TEXTBOX "{5512D124-5CC6-11CF-8d67-00aa00bdce1d}"
82 const sal_uInt32 AX_SYSCOLOR_WINDOWBACK = 0x80000005;
83 const sal_uInt32 AX_SYSCOLOR_WINDOWFRAME = 0x80000006;
84 const sal_uInt32 AX_SYSCOLOR_WINDOWTEXT = 0x80000008;
85 const sal_uInt32 AX_SYSCOLOR_BUTTONFACE = 0x8000000F;
86 const sal_uInt32 AX_SYSCOLOR_BUTTONTEXT = 0x80000012;
88 const sal_uInt32 AX_FLAGS_ENABLED = 0x00000002;
89 const sal_uInt32 AX_FLAGS_LOCKED = 0x00000004;
90 const sal_uInt32 AX_FLAGS_OPAQUE = 0x00000008;
91 const sal_uInt32 AX_FLAGS_COLUMNHEADS = 0x00000400;
92 const sal_uInt32 AX_FLAGS_ENTIREROWS = 0x00000800;
93 const sal_uInt32 AX_FLAGS_EXISTINGENTRIES = 0x00001000;
94 const sal_uInt32 AX_FLAGS_CAPTIONLEFT = 0x00002000;
95 const sal_uInt32 AX_FLAGS_EDITABLE = 0x00004000;
96 const sal_uInt32 AX_FLAGS_IMEMODE_MASK = 0x00078000;
97 const sal_uInt32 AX_FLAGS_DRAGENABLED = 0x00080000;
98 const sal_uInt32 AX_FLAGS_ENTERASNEWLINE = 0x00100000;
99 const sal_uInt32 AX_FLAGS_KEEPSELECTION = 0x00200000;
100 const sal_uInt32 AX_FLAGS_TABASCHARACTER = 0x00400000;
101 const sal_uInt32 AX_FLAGS_WORDWRAP = 0x00800000;
102 const sal_uInt32 AX_FLAGS_BORDERSSUPPRESSED = 0x02000000;
103 const sal_uInt32 AX_FLAGS_SELECTLINE = 0x04000000;
104 const sal_uInt32 AX_FLAGS_SINGLECHARSELECT = 0x08000000;
105 const sal_uInt32 AX_FLAGS_AUTOSIZE = 0x10000000;
106 const sal_uInt32 AX_FLAGS_HIDESELECTION = 0x20000000;
107 const sal_uInt32 AX_FLAGS_MAXLENAUTOTAB = 0x40000000;
108 const sal_uInt32 AX_FLAGS_MULTILINE = 0x80000000;
110 const sal_Int32 AX_BORDERSTYLE_NONE = 0;
111 const sal_Int32 AX_BORDERSTYLE_SINGLE = 1;
113 const sal_Int32 AX_SPECIALEFFECT_FLAT = 0;
114 const sal_Int32 AX_SPECIALEFFECT_RAISED = 1;
115 const sal_Int32 AX_SPECIALEFFECT_SUNKEN = 2;
116 const sal_Int32 AX_SPECIALEFFECT_ETCHED = 3;
117 const sal_Int32 AX_SPECIALEFFECT_BUMPED = 6;
119 const sal_Int32 AX_PICSIZE_CLIP = 0;
120 const sal_Int32 AX_PICSIZE_STRETCH = 1;
121 const sal_Int32 AX_PICSIZE_ZOOM = 3;
123 const sal_Int32 AX_PICALIGN_TOPLEFT = 0;
124 const sal_Int32 AX_PICALIGN_TOPRIGHT = 1;
125 const sal_Int32 AX_PICALIGN_CENTER = 2;
126 const sal_Int32 AX_PICALIGN_BOTTOMLEFT = 3;
127 const sal_Int32 AX_PICALIGN_BOTTOMRIGHT = 4;
129 const sal_Int32 AX_DISPLAYSTYLE_TEXT = 1;
130 const sal_Int32 AX_DISPLAYSTYLE_LISTBOX = 2;
131 const sal_Int32 AX_DISPLAYSTYLE_COMBOBOX = 3;
132 const sal_Int32 AX_DISPLAYSTYLE_CHECKBOX = 4;
133 const sal_Int32 AX_DISPLAYSTYLE_OPTBUTTON = 5;
134 const sal_Int32 AX_DISPLAYSTYLE_TOGGLE = 6;
135 const sal_Int32 AX_DISPLAYSTYLE_DROPDOWN = 7;
137 const sal_Int32 AX_SELECTION_SINGLE = 0;
138 const sal_Int32 AX_SELECTION_MULTI = 1;
139 const sal_Int32 AX_SELECTION_EXTENDED = 2;
141 const sal_Int32 AX_SHOWDROPBUTTON_NEVER = 0;
142 const sal_Int32 AX_SHOWDROPBUTTON_FOCUS = 1;
143 const sal_Int32 AX_SHOWDROPBUTTON_ALWAYS = 2;
145 const sal_Int32 AX_SCROLLBAR_NONE = 0x00;
146 const sal_Int32 AX_SCROLLBAR_HORIZONTAL = 0x01;
147 const sal_Int32 AX_SCROLLBAR_VERTICAL = 0x02;
150 /** Enumerates all UNO API control types supported by these filters. */
151 enum ApiControlType
153 API_CONTROL_BUTTON,
154 API_CONTROL_FIXEDTEXT,
155 API_CONTROL_IMAGE,
156 API_CONTROL_CHECKBOX,
157 API_CONTROL_RADIOBUTTON,
158 API_CONTROL_EDIT,
159 API_CONTROL_NUMERIC,
160 API_CONTROL_LISTBOX,
161 API_CONTROL_COMBOBOX,
162 API_CONTROL_SPINBUTTON,
163 API_CONTROL_SCROLLBAR,
164 API_CONTROL_TABSTRIP, //11
165 API_CONTROL_PROGRESSBAR,
166 API_CONTROL_GROUPBOX,
167 API_CONTROL_FRAME, // 14
168 API_CONTROL_PAGE, // 15
169 API_CONTROL_MULTIPAGE, // 16
170 API_CONTROL_DIALOG // 17
174 /** Specifies how a form control supports transparent background. */
175 enum class ApiTransparencyMode
177 NotSupported, ///< Control does not support transparency.
178 Void, ///< Transparency is enabled by missing fill color.
181 /** Specifies how a form control supports the DefaultState property. */
182 enum ApiDefaultStateMode
184 API_DEFAULTSTATE_BOOLEAN, ///< Control does not support tri-state, state is given as boolean.
185 API_DEFAULTSTATE_SHORT, ///< Control does not support tri-state, state is given as short.
186 API_DEFAULTSTATE_TRISTATE ///< Control supports tri-state, state is given as short.
190 /** A base class with useful helper functions for something that is able to
191 convert ActiveX and ComCtl form controls.
193 class OOX_DLLPUBLIC ControlConverter final
195 public:
196 explicit ControlConverter(
197 const css::uno::Reference< css::frame::XModel >& rxDocModel,
198 const GraphicHelper& rGraphicHelper,
199 bool bDefaultColorBgr = true );
200 ~ControlConverter();
202 // Generic conversion -----------------------------------------------------
204 /** Converts the passed position in 1/100 mm to UNO properties. */
205 void convertPosition(
206 PropertyMap& rPropMap,
207 const AxPairData& rPos ) const;
209 /** Converts the passed size in 1/100 mm to UNO properties. */
210 void convertSize(
211 PropertyMap& rPropMap,
212 const AxPairData& rSize ) const;
214 /** Converts the passed encoded OLE color to UNO properties. */
215 void convertColor(
216 PropertyMap& rPropMap,
217 sal_Int32 nPropId,
218 sal_uInt32 nOleColor ) const;
220 static void convertToMSColor(
221 PropertySet const & rPropSet,
222 sal_Int32 nPropId,
223 sal_uInt32& nOleColor,
224 sal_uInt32 nDefault = 0 );
227 /** Converts the passed StdPic picture stream to UNO properties. */
228 void convertPicture(
229 PropertyMap& rPropMap,
230 const StreamDataSequence& rPicData ) const;
232 /** Converts the control orientation to UNO properties. */
233 static void convertOrientation(
234 PropertyMap& rPropMap,
235 bool bHorizontal );
237 static void convertToMSOrientation(
238 PropertySet const & rPropMap,
239 bool& bHorizontal );
241 /** Converts the vertical alignment to UNO properties. */
242 static void convertVerticalAlign(
243 PropertyMap& rPropMap,
244 sal_Int32 nVerticalAlign );
246 /** Converts common scrollbar settings to UNO properties. */
247 static void convertScrollBar(
248 PropertyMap& rPropMap,
249 sal_Int32 nMin, sal_Int32 nMax, sal_Int32 nPosition,
250 sal_Int32 nSmallChange, sal_Int32 nLargeChange, bool bAwtModel );
252 /** Converts scrollability settings to UNO properties. */
253 void convertScrollabilitySettings(
254 PropertyMap& rPropMap,
255 const AxPairData& rScrollPos, const AxPairData& rScrollArea,
256 sal_Int32 nScrollBars ) const;
258 /** Binds the passed control model to the passed data sources. The
259 implementation will check which source types are supported. */
260 void bindToSources(
261 const css::uno::Reference< css::awt::XControlModel >& rxCtrlModel,
262 const OUString& rCtrlSource,
263 const OUString& rRowSource,
264 sal_Int32 nRefSheet = 0 ) const;
266 // ActiveX (Forms 2.0) specific conversion --------------------------------
268 /** Converts the Forms 2.0 background formatting to UNO properties. */
269 void convertAxBackground(
270 PropertyMap& rPropMap,
271 sal_uInt32 nBackColor,
272 sal_uInt32 nFlags,
273 ApiTransparencyMode eTranspMode ) const;
275 /** Converts the Forms 2.0 border formatting to UNO properties. */
276 void convertAxBorder(
277 PropertyMap& rPropMap,
278 sal_uInt32 nBorderColor,
279 sal_Int32 nBorderStyle,
280 sal_Int32 nSpecialEffect ) const;
282 static void convertToAxBorder(
283 PropertySet const & rPropSet,
284 sal_uInt32& nBorderColor,
285 sal_Int32& nBorderStyle,
286 sal_Int32& nSpecialEffect );
288 /** Converts the Forms 2.0 special effect to UNO properties. */
289 static void convertAxVisualEffect(
290 PropertyMap& rPropMap,
291 sal_Int32 nSpecialEffect );
293 static void convertToAxVisualEffect(
294 PropertySet const & rPropSet,
295 sal_Int32& nSpecialEffect );
297 /** Converts the passed picture stream and Forms 2.0 position to UNO
298 properties. */
299 void convertAxPicture(
300 PropertyMap& rPropMap,
301 const StreamDataSequence& rPicData,
302 sal_uInt32 nPicPos ) const;
304 /** Converts the passed picture stream and Forms 2.0 position to UNO
305 properties. */
306 void convertAxPicture(
307 PropertyMap& rPropMap,
308 const StreamDataSequence& rPicData,
309 sal_Int32 nPicSizeMode ) const;
311 /** Converts the Forms 2.0 value for checked/unchecked/dontknow to UNO
312 properties. */
313 static void convertAxState(
314 PropertyMap& rPropMap,
315 std::u16string_view rValue,
316 sal_Int32 nMultiSelect,
317 ApiDefaultStateMode eDefStateMode,
318 bool bAwtModel );
320 static void convertToAxState(
321 PropertySet const & rPropSet,
322 OUString& rValue,
323 sal_Int32& nMultiSelect,
324 ApiDefaultStateMode eDefStateMode );
326 /** Converts the Forms 2.0 control orientation to UNO properties. */
327 static void convertAxOrientation(
328 PropertyMap& rPropMap,
329 const AxPairData& rSize,
330 sal_Int32 nOrientation );
332 static void convertToAxOrientation(
333 PropertySet const & rPropSet,
334 sal_Int32& nOrientation );
336 private:
337 css::uno::Reference< css::frame::XModel > mxDocModel;
338 const GraphicHelper& mrGraphicHelper;
339 mutable PropertySet maAddressConverter;
340 mutable PropertySet maRangeConverter;
341 bool mbDefaultColorBgr;
345 /** Base class for all models of form controls. */
346 class OOX_DLLPUBLIC ControlModelBase
348 public:
349 explicit ControlModelBase();
350 virtual ~ControlModelBase();
352 /** Sets this control model to AWT model mode. */
353 void setAwtModelMode() { mbAwtModel = true; }
354 /** Sets this control model to form component mode. */
355 void setFormComponentMode() { mbAwtModel = false; }
357 /** Returns the UNO service name used to construct the AWT control model,
358 or the control form component. */
359 OUString getServiceName() const;
361 /** Derived classes set specific OOXML properties at the model structure. */
362 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue );
363 /** Derived classes set binary data (picture, mouse icon) at the model structure. */
364 virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm );
365 /** Derived classes import a form control model from the passed input stream. */
366 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) = 0;
367 /** Derived classes export a form control model to the passed output stream. */
368 virtual void exportBinaryModel( BinaryOutputStream& /*rOutStrm*/ ) {}
369 /** Derived classes export CompObjStream contents. */
370 virtual void exportCompObj( BinaryOutputStream& /*rOutStrm*/ ) {}
371 /** Derived classes return the UNO control type enum value. */
372 virtual ApiControlType getControlType() const = 0;
373 /** Derived classes convert all control properties. */
374 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
375 /** Derived classes convert from uno control properties to equiv. MS values. */
376 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv );
378 /** Converts the control size to UNO properties. */
379 void convertSize( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
381 public: // direct access needed for legacy VML drawing controls
382 AxPairData maSize; ///< Size of the control in 1/100 mm.
384 protected:
385 bool mbAwtModel; ///< True = AWT control model, false = form component.
388 typedef std::shared_ptr< ControlModelBase > ControlModelRef;
391 /** Base class for all models of ComCtl form controls. */
392 class ComCtlModelBase : public ControlModelBase
394 public:
395 explicit ComCtlModelBase(
396 sal_uInt32 nDataPartId5, sal_uInt32 nDataPartId6, sal_uInt16 nVersion );
398 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
399 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
401 protected:
402 virtual void importControlData( BinaryInputStream& rInStrm ) = 0;
404 private:
405 /** Returns the data part identifier according to the model version. */
406 sal_uInt32 getDataPartId() const;
408 static bool readPartHeader( BinaryInputStream& rInStrm,
409 sal_uInt32 nExpPartId,
410 sal_uInt16 nExpMajor = SAL_MAX_UINT16,
411 sal_uInt16 nExpMinor = SAL_MAX_UINT16 );
413 bool importSizePart( BinaryInputStream& rInStrm );
414 bool importCommonPart( BinaryInputStream& rInStrm, sal_uInt32 nPartSize );
415 bool importComplexPart( BinaryInputStream& rInStrm );
417 protected:
418 StdFontInfo maFontData; ///< Font formatting.
419 StreamDataSequence maMouseIcon; ///< Binary picture stream for mouse icon.
420 sal_uInt32 mnFlags; ///< Common flags for ComCtl controls.
421 const sal_uInt16 mnVersion; ///< Current version of the ComCtl control model.
423 private:
424 sal_uInt32 mnDataPartId5; ///< Identifier for version 5.0 control data.
425 sal_uInt32 mnDataPartId6; ///< Identifier for version 6.0 control data.
426 bool mbCommonPart; ///< True = the COMCTL_COMMONDATA part exists.
427 bool mbComplexPart; ///< True = the COMCTL_COMPLEXDATA part exists.
431 /** Model for a ComCtl scroll bar. */
432 class ComCtlScrollBarModel final : public ComCtlModelBase
434 public:
435 explicit ComCtlScrollBarModel( sal_uInt16 nVersion );
437 virtual ApiControlType getControlType() const override;
438 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
440 private:
441 virtual void importControlData( BinaryInputStream& rInStrm ) override;
443 sal_uInt32 mnScrollBarFlags; ///< Special flags for scroll bar model.
444 sal_Int32 mnLargeChange; ///< Increment step size (thumb).
445 sal_Int32 mnSmallChange; ///< Increment step size (buttons).
446 sal_Int32 mnMin; ///< Minimum of the value range.
447 sal_Int32 mnMax; ///< Maximum of the value range.
448 sal_Int32 mnPosition; ///< Value of the spin button.
452 /** Model for a ComCtl progress bar. */
453 class ComCtlProgressBarModel final : public ComCtlModelBase
455 public:
456 explicit ComCtlProgressBarModel( sal_uInt16 nVersion );
458 virtual ApiControlType getControlType() const override;
459 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
461 private:
462 virtual void importControlData( BinaryInputStream& rInStrm ) override;
464 float mfMin; ///< Minimum of the value range.
465 float mfMax; ///< Maximum of the value range.
466 sal_uInt16 mnVertical; ///< 0 = horizontal, 1 = vertical.
467 sal_uInt16 mnSmooth; ///< 0 = progress blocks, 1 = pixel resolution.
471 /** Base class for all models of Form 2.0 form controls. */
472 class OOX_DLLPUBLIC AxControlModelBase : public ControlModelBase
474 public:
475 explicit AxControlModelBase();
477 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
481 /** Base class for Forms 2.0 controls supporting text formatting. */
482 class OOX_DLLPUBLIC AxFontDataModel : public AxControlModelBase
484 public:
485 explicit AxFontDataModel( bool bSupportsAlign = true );
487 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
488 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
489 virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
490 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
491 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
493 /** Returns the font height in points. */
494 sal_Int16 getFontHeight() const { return maFontData.getHeightPoints(); }
496 public: // direct access needed for legacy VML drawing controls
497 AxFontData maFontData; ///< The font settings.
499 private:
500 bool mbSupportsAlign; ///< True = UNO model supports Align property.
504 /** Model for a Forms 2.0 command button. */
505 class OOX_DLLPUBLIC AxCommandButtonModel final : public AxFontDataModel
507 public:
508 explicit AxCommandButtonModel();
510 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
511 virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ) override;
512 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
513 virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
514 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
516 virtual ApiControlType getControlType() const override;
517 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
518 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
520 public: // direct access needed for legacy VML drawing controls
521 StreamDataSequence maPictureData; ///< Binary picture stream.
522 OUString maCaption; ///< Visible caption of the button.
523 sal_uInt32 mnTextColor; ///< Text color.
524 sal_uInt32 mnBackColor; ///< Fill color.
525 sal_uInt32 mnFlags; ///< Various flags.
526 sal_uInt32 mnPicturePos; ///< Position of the picture relative to text.
527 sal_Int32 mnVerticalAlign; ///< Vertical alignment (legacy VML drawing controls only).
528 bool mbFocusOnClick; ///< True = take focus on click.
532 /** Model for a Forms 2.0 label. */
533 class OOX_DLLPUBLIC AxLabelModel final : public AxFontDataModel
535 public:
536 explicit AxLabelModel();
538 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
539 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
540 virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
541 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
543 virtual ApiControlType getControlType() const override;
544 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
545 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
547 public: // direct access needed for legacy VML drawing controls
548 OUString maCaption; ///< Visible caption of the button.
549 sal_uInt32 mnTextColor; ///< Text color.
550 sal_uInt32 mnBackColor; ///< Fill color.
551 sal_uInt32 mnFlags; ///< Various flags.
552 sal_uInt32 mnBorderColor; ///< Flat border color.
553 sal_Int32 mnBorderStyle; ///< Flat border style.
554 sal_Int32 mnSpecialEffect; ///< 3D border effect.
555 sal_Int32 mnVerticalAlign; ///< Vertical alignment (legacy VML drawing controls only).
559 /** Model for a Forms 2.0 image. */
560 class OOX_DLLPUBLIC AxImageModel final : public AxControlModelBase
562 public:
563 explicit AxImageModel();
565 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
566 virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ) override;
567 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
568 virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
569 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
571 virtual ApiControlType getControlType() const override;
572 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
574 private:
575 StreamDataSequence maPictureData; ///< Binary picture stream.
576 sal_uInt32 mnBackColor; ///< Fill color.
577 sal_uInt32 mnFlags; ///< Various flags.
578 sal_uInt32 mnBorderColor; ///< Flat border color.
579 sal_Int32 mnBorderStyle; ///< Flat border style.
580 sal_Int32 mnSpecialEffect; ///< 3D border effect.
581 sal_Int32 mnPicSizeMode; ///< Clip, stretch, zoom.
582 sal_Int32 mnPicAlign; ///< Anchor position of the picture.
583 bool mbPicTiling; ///< True = picture is repeated.
586 class OOX_DLLPUBLIC AxTabStripModel final : public AxFontDataModel
588 public:
589 explicit AxTabStripModel();
591 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
593 virtual ApiControlType getControlType() const override;
595 public:
596 sal_uInt32 mnListIndex;
597 sal_uInt32 mnTabStyle;
598 sal_uInt32 mnTabData;
599 sal_uInt32 mnVariousPropertyBits;
600 std::vector< OUString > maItems; // captions for each tab
601 std::vector< OUString > maTabNames; // names for each tab
605 /** Base class for a Forms 2.0 morph data control. */
606 class OOX_DLLPUBLIC AxMorphDataModelBase : public AxFontDataModel
608 public:
609 explicit AxMorphDataModelBase();
611 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
612 virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ) override;
613 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
614 virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
615 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
616 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
618 public: // direct access needed for legacy VML drawing controls
619 StreamDataSequence maPictureData; ///< Binary picture stream.
620 OUString maCaption; ///< Visible caption of the button.
621 OUString maValue; ///< Current value of the control.
622 OUString maGroupName; ///< Group name for option buttons.
623 sal_uInt32 mnTextColor; ///< Text color.
624 sal_uInt32 mnBackColor; ///< Fill color.
625 sal_uInt32 mnFlags; ///< Various flags.
626 sal_uInt32 mnPicturePos; ///< Position of the picture relative to text.
627 sal_uInt32 mnBorderColor; ///< Flat border color.
628 sal_Int32 mnBorderStyle; ///< Flat border style.
629 sal_Int32 mnSpecialEffect; ///< 3D border effect.
630 sal_Int32 mnDisplayStyle; ///< Type of the morph control.
631 sal_Int32 mnMultiSelect; ///< Selection mode.
632 sal_Int32 mnScrollBars; ///< Horizontal/vertical scroll bar.
633 sal_Int32 mnMatchEntry; ///< Auto completion mode.
634 sal_Int32 mnShowDropButton; ///< When to show the dropdown button.
635 sal_Int32 mnMaxLength; ///< Maximum character count.
636 sal_Int32 mnPasswordChar; ///< Password character in edit fields.
637 sal_Int32 mnListRows; ///< Number of rows in dropdown box.
638 sal_Int32 mnVerticalAlign; ///< Vertical alignment (legacy VML drawing controls only).
642 /** Model for a Forms 2.0 toggle button. */
643 class OOX_DLLPUBLIC AxToggleButtonModel final : public AxMorphDataModelBase
645 public:
646 explicit AxToggleButtonModel();
648 virtual ApiControlType getControlType() const override;
649 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
650 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
651 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
655 /** Model for a Forms 2.0 check box. */
656 class OOX_DLLPUBLIC AxCheckBoxModel final : public AxMorphDataModelBase
658 public:
659 explicit AxCheckBoxModel();
661 virtual ApiControlType getControlType() const override;
662 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
663 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
664 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
668 /** Model for a Forms 2.0 option button. */
669 class OOX_DLLPUBLIC AxOptionButtonModel final : public AxMorphDataModelBase
671 public:
672 explicit AxOptionButtonModel();
674 /** Returns the group name used to group several option buttons together. */
675 const OUString& getGroupName() const { return maGroupName; }
677 virtual ApiControlType getControlType() const override;
678 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
679 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
680 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
684 /** Model for a Forms 2.0 text box. */
685 class OOX_DLLPUBLIC AxTextBoxModel : public AxMorphDataModelBase
687 public:
688 explicit AxTextBoxModel();
690 virtual ApiControlType getControlType() const override;
691 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
692 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
693 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
697 /** Model for a numeric field (legacy drawing controls only). */
698 class OOX_DLLPUBLIC AxNumericFieldModel final : public AxMorphDataModelBase
700 public:
701 explicit AxNumericFieldModel();
703 virtual ApiControlType getControlType() const override;
704 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
705 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
706 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
710 /** Model for a Forms 2.0 list box. */
711 class OOX_DLLPUBLIC AxListBoxModel : public AxMorphDataModelBase
713 public:
714 explicit AxListBoxModel();
716 virtual ApiControlType getControlType() const override;
717 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
718 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
719 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
723 /** Model for a Forms 2.0 combo box. */
724 class OOX_DLLPUBLIC AxComboBoxModel final : public AxMorphDataModelBase
726 public:
727 explicit AxComboBoxModel();
729 virtual ApiControlType getControlType() const override;
730 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
731 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
732 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
736 /** Model for a Forms 2.0 spin button. */
737 class OOX_DLLPUBLIC AxSpinButtonModel final : public AxControlModelBase
739 public:
740 explicit AxSpinButtonModel();
742 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
743 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
744 virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
746 virtual ApiControlType getControlType() const override;
747 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
748 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
749 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
751 public: // direct access needed for legacy VML drawing controls
752 sal_uInt32 mnArrowColor; ///< Button arrow color.
753 sal_uInt32 mnBackColor; ///< Fill color.
754 sal_uInt32 mnFlags; ///< Various flags.
755 sal_Int32 mnOrientation; ///< Orientation of the buttons.
756 sal_Int32 mnMin; ///< Minimum of the value range.
757 sal_Int32 mnMax; ///< Maximum of the value range.
758 sal_Int32 mnPosition; ///< Value of the spin button.
759 sal_Int32 mnSmallChange; ///< Increment step size.
760 sal_Int32 mnDelay; ///< Repeat delay in milliseconds.
764 /** Model for a Forms 2.0 scroll bar. */
765 class OOX_DLLPUBLIC AxScrollBarModel final : public AxControlModelBase
767 public:
768 explicit AxScrollBarModel();
770 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
771 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
772 virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) override;
773 virtual void exportCompObj( BinaryOutputStream& rOutStrm ) override;
775 virtual ApiControlType getControlType() const override;
776 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
777 virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) override;
779 public: // direct access needed for legacy VML drawing controls
780 sal_uInt32 mnArrowColor; ///< Button arrow color.
781 sal_uInt32 mnBackColor; ///< Fill color.
782 sal_uInt32 mnFlags; ///< Various flags.
783 sal_Int32 mnOrientation; ///< Orientation of the buttons.
784 sal_Int32 mnPropThumb; ///< Proportional thumb size.
785 sal_Int32 mnMin; ///< Minimum of the value range.
786 sal_Int32 mnMax; ///< Maximum of the value range.
787 sal_Int32 mnPosition; ///< Value of the spin button.
788 sal_Int32 mnSmallChange; ///< Increment step size (buttons).
789 sal_Int32 mnLargeChange; ///< Increment step size (thumb).
790 sal_Int32 mnDelay; ///< Repeat delay in milliseconds.
794 typedef ::std::vector< OUString > AxClassTable;
796 /** Base class for ActiveX container controls. */
797 class OOX_DLLPUBLIC AxContainerModelBase : public AxFontDataModel
799 public:
800 explicit AxContainerModelBase( bool bFontSupport = false );
802 /** Allows to set single properties specified by XML token identifier. */
803 virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) override;
804 /** Reads the leading structure in the 'f' stream containing the model for
805 this control. */
806 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
807 /** Converts font settings if supported. */
808 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
810 /** Reads the class table structure for embedded controls following the own
811 model from the 'f' stream. */
812 bool importClassTable( BinaryInputStream& rInStrm, AxClassTable& orClassTable );
814 public: // direct access needed for legacy VML drawing controls
815 StreamDataSequence maPictureData; ///< Binary picture stream.
816 OUString maCaption; ///< Visible caption of the form.
817 AxPairData maLogicalSize; ///< Logical form size (scroll area).
818 AxPairData maScrollPos; ///< Scroll position.
819 sal_uInt32 mnBackColor; ///< Fill color.
820 sal_uInt32 mnTextColor; ///< Text color.
821 sal_uInt32 mnFlags; ///< Various flags.
822 sal_uInt32 mnBorderColor; ///< Flat border color.
823 sal_Int32 mnBorderStyle; ///< Flat border style.
824 sal_Int32 mnScrollBars; ///< Horizontal/vertical scroll bar.
825 sal_Int32 mnCycleType; ///< Cycle in all forms or in this form.
826 sal_Int32 mnSpecialEffect; ///< 3D border effect.
827 sal_Int32 mnPicAlign; ///< Anchor position of the picture.
828 sal_Int32 mnPicSizeMode; ///< Clip, stretch, zoom.
829 bool mbPicTiling; ///< True = picture is repeated.
830 bool mbFontSupport; ///< True = control supports the font property.
834 /** Model for a Forms 2.0 frame control. */
835 class OOX_DLLPUBLIC AxFrameModel final : public AxContainerModelBase
837 public:
838 explicit AxFrameModel();
840 virtual ApiControlType getControlType() const override;
841 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
844 class OOX_DLLPUBLIC AxPageModel final : public AxContainerModelBase
846 public:
847 explicit AxPageModel();
849 virtual ApiControlType getControlType() const override;
850 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
853 class OOX_DLLPUBLIC AxMultiPageModel final : public AxContainerModelBase
855 public:
856 explicit AxMultiPageModel();
858 virtual ApiControlType getControlType() const override;
859 void importPageAndMultiPageProperties( BinaryInputStream& rInStrm, sal_Int32 nPages );
860 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
861 std::vector<sal_uInt32> mnIDs;
862 sal_uInt32 mnActiveTab;
863 sal_uInt32 mnTabStyle;
867 /** Model for a Forms 2.0 user form. */
868 class OOX_DLLPUBLIC AxUserFormModel final : public AxContainerModelBase
870 public:
871 explicit AxUserFormModel();
873 virtual ApiControlType getControlType() const override;
874 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
877 class HtmlSelectModel final : public AxListBoxModel
879 css::uno::Sequence< OUString > msListData;
880 css::uno::Sequence< sal_Int16 > msIndices;
881 public:
882 HtmlSelectModel();
883 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
884 virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const override;
887 class HtmlTextBoxModel final : public AxTextBoxModel
889 public:
890 explicit HtmlTextBoxModel();
891 virtual bool importBinaryModel( BinaryInputStream& rInStrm ) override;
895 /** A form control embedded in a document draw page. Contains a specific model
896 structure according to the type of the control. */
897 class OOX_DLLPUBLIC EmbeddedControl
899 public:
900 explicit EmbeddedControl( OUString aName );
902 /** Creates and returns the internal control model of the specified type. */
903 template< typename ModelType >
904 inline ModelType& createModel();
906 /** Creates and returns the internal control model of the specified type. */
907 template< typename ModelType, typename ParamType >
908 inline ModelType& createModel( const ParamType& rParam );
910 /** Creates and returns the internal control model according to the passed
911 MS class identifier. */
912 ControlModelBase* createModelFromGuid( std::u16string_view rClassId );
914 /** Returns true, if the internal control model exists. */
915 bool hasModel() const { return bool(mxModel); }
916 /** Returns read-only access to the internal control model. */
917 const ControlModelBase* getModel() const { return mxModel.get(); }
918 /** Returns read/write access to the internal control model. */
919 ControlModelBase* getModel() { return mxModel.get(); }
921 /** Returns the UNO service name needed to construct the control model. */
922 OUString getServiceName() const;
924 /** Converts all control properties and inserts them into the passed model. */
925 bool convertProperties(
926 const css::uno::Reference< css::awt::XControlModel >& rxCtrlModel,
927 const ControlConverter& rConv ) const;
929 void convertFromProperties(
930 const css::uno::Reference< css::awt::XControlModel >& rxCtrlModel,
931 const ControlConverter& rConv );
933 private:
934 ControlModelRef mxModel; ///< Control model containing the properties.
935 OUString maName; ///< Name of the control.
939 template< typename ModelType >
940 inline ModelType& EmbeddedControl::createModel()
942 auto xModel = std::make_shared<ModelType>();
943 mxModel = xModel;
944 xModel->setFormComponentMode();
945 return *xModel;
948 template< typename ModelType, typename ParamType >
949 inline ModelType& EmbeddedControl::createModel( const ParamType& rParam )
951 auto xModel = std::make_shared<ModelType>( rParam );
952 mxModel = xModel;
953 xModel->setFormComponentMode();
954 return *xModel;
958 /** A wrapper for a control form embedded directly in a draw page. */
959 class EmbeddedForm
961 public:
962 explicit EmbeddedForm(
963 const css::uno::Reference< css::frame::XModel >& rxDocModel,
964 const css::uno::Reference< css::drawing::XDrawPage >& rxDrawPage,
965 const GraphicHelper& rGraphicHelper );
967 /** Converts the passed control and inserts the control model into the form.
968 @return The API control model, if conversion was successful. */
969 css::uno::Reference< css::awt::XControlModel >
970 convertAndInsert( const EmbeddedControl& rControl, sal_Int32& rnCtrlIndex );
972 /** Returns the XIndexContainer interface of the UNO control form, if existing. */
973 const css::uno::Reference< css::container::XIndexContainer >&
974 getXForm() const { return mxFormIC; }
976 private:
977 /** Creates the form that will hold the form controls. */
978 css::uno::Reference< css::container::XIndexContainer > const &
979 createXForm();
981 private:
982 ControlConverter maControlConv;
983 css::uno::Reference< css::lang::XMultiServiceFactory > mxModelFactory;
984 css::uno::Reference< css::form::XFormsSupplier > mxFormsSupp;
985 css::uno::Reference< css::container::XIndexContainer > mxFormIC;
989 } // namespace oox::ole
991 #endif
993 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */