Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_OOX_OLE_AXCONTROL_HXX
21 : #define INCLUDED_OOX_OLE_AXCONTROL_HXX
22 :
23 : #include <boost/shared_ptr.hpp>
24 : #include <oox/helper/binarystreambase.hxx>
25 : #include <oox/helper/propertyset.hxx>
26 : #include <oox/ole/axbinaryreader.hxx>
27 : #include <oox/ole/olehelper.hxx>
28 : #include <oox/dllapi.h>
29 :
30 : namespace com { namespace sun { namespace star {
31 : namespace awt { class XControlModel; }
32 : namespace container { class XIndexContainer; }
33 : namespace drawing { class XDrawPage; }
34 : namespace frame { class XModel; }
35 : namespace form { class XFormsSupplier; }
36 : namespace lang { class XMultiServiceFactory; }
37 : } } }
38 :
39 : namespace oox {
40 : class BinaryInputStream;
41 : class GraphicHelper;
42 : class PropertyMap;
43 : }
44 :
45 : namespace oox {
46 : namespace ole {
47 :
48 :
49 :
50 : #define COMCTL_GUID_SCROLLBAR_60 "{FE38753A-44A3-11D1-B5B7-0000C09000C4}"
51 : #define COMCTL_GUID_PROGRESSBAR_50 "{0713E8D2-850A-101B-AFC0-4210102A8DA7}"
52 : #define COMCTL_GUID_PROGRESSBAR_60 "{35053A22-8589-11D1-B16A-00C0F0283628}"
53 :
54 : const sal_uInt16 COMCTL_VERSION_50 = 5;
55 : const sal_uInt16 COMCTL_VERSION_60 = 6;
56 :
57 :
58 :
59 : #define AX_GUID_COMMANDBUTTON "{D7053240-CE69-11CD-a777-00dd01143c57}"
60 : #define AX_GUID_LABEL "{978C9E23-D4B0-11CE-bf2d-00aa003f40d0}"
61 : #define AX_GUID_IMAGE "{4C599241-6926-101B-9992-00000b65c6f9}"
62 : #define AX_GUID_TOGGLEBUTTON "{8BD21D60-EC42-11CE-9e0d-00aa006002f3}"
63 : #define AX_GUID_CHECKBOX "{8BD21D40-EC42-11CE-9e0d-00aa006002f3}"
64 : #define AX_GUID_OPTIONBUTTON "{8BD21D50-EC42-11CE-9e0d-00aa006002f3}"
65 : #define AX_GUID_TEXTBOX "{8BD21D10-EC42-11CE-9e0d-00aa006002f3}"
66 : #define AX_GUID_LISTBOX "{8BD21D20-EC42-11CE-9e0d-00aa006002f3}"
67 : #define AX_GUID_COMBOBOX "{8BD21D30-EC42-11CE-9e0d-00aa006002f3}"
68 : #define AX_GUID_SPINBUTTON "{79176FB0-B7F2-11CE-97ef-00aa006d2776}"
69 : #define AX_GUID_SCROLLBAR "{DFD181E0-5E2F-11CE-a449-00aa004a803d}"
70 : #define AX_GUID_FRAME "{6E182020-F460-11CE-9bcd-00aa00608e01}"
71 :
72 : // Html control GUID(s)
73 :
74 : #define HTML_GUID_SELECT "{5512D122-5CC6-11CF-8d67-00aa00bdce1d}"
75 : #define HTML_GUID_TEXTBOX "{5512D124-5CC6-11CF-8d67-00aa00bdce1d}"
76 :
77 : const sal_uInt32 AX_SYSCOLOR_WINDOWBACK = 0x80000005;
78 : const sal_uInt32 AX_SYSCOLOR_WINDOWFRAME = 0x80000006;
79 : const sal_uInt32 AX_SYSCOLOR_WINDOWTEXT = 0x80000008;
80 : const sal_uInt32 AX_SYSCOLOR_BUTTONFACE = 0x8000000F;
81 : const sal_uInt32 AX_SYSCOLOR_BUTTONTEXT = 0x80000012;
82 :
83 : const sal_uInt32 AX_FLAGS_ENABLED = 0x00000002;
84 : const sal_uInt32 AX_FLAGS_LOCKED = 0x00000004;
85 : const sal_uInt32 AX_FLAGS_OPAQUE = 0x00000008;
86 : const sal_uInt32 AX_FLAGS_COLUMNHEADS = 0x00000400;
87 : const sal_uInt32 AX_FLAGS_ENTIREROWS = 0x00000800;
88 : const sal_uInt32 AX_FLAGS_EXISTINGENTRIES = 0x00001000;
89 : const sal_uInt32 AX_FLAGS_CAPTIONLEFT = 0x00002000;
90 : const sal_uInt32 AX_FLAGS_EDITABLE = 0x00004000;
91 : const sal_uInt32 AX_FLAGS_IMEMODE_MASK = 0x00078000;
92 : const sal_uInt32 AX_FLAGS_DRAGENABLED = 0x00080000;
93 : const sal_uInt32 AX_FLAGS_ENTERASNEWLINE = 0x00100000;
94 : const sal_uInt32 AX_FLAGS_KEEPSELECTION = 0x00200000;
95 : const sal_uInt32 AX_FLAGS_TABASCHARACTER = 0x00400000;
96 : const sal_uInt32 AX_FLAGS_WORDWRAP = 0x00800000;
97 : const sal_uInt32 AX_FLAGS_BORDERSSUPPRESSED = 0x02000000;
98 : const sal_uInt32 AX_FLAGS_SELECTLINE = 0x04000000;
99 : const sal_uInt32 AX_FLAGS_SINGLECHARSELECT = 0x08000000;
100 : const sal_uInt32 AX_FLAGS_AUTOSIZE = 0x10000000;
101 : const sal_uInt32 AX_FLAGS_HIDESELECTION = 0x20000000;
102 : const sal_uInt32 AX_FLAGS_MAXLENAUTOTAB = 0x40000000;
103 : const sal_uInt32 AX_FLAGS_MULTILINE = 0x80000000;
104 :
105 : const sal_Int32 AX_BORDERSTYLE_NONE = 0;
106 : const sal_Int32 AX_BORDERSTYLE_SINGLE = 1;
107 :
108 : const sal_Int32 AX_SPECIALEFFECT_FLAT = 0;
109 : const sal_Int32 AX_SPECIALEFFECT_RAISED = 1;
110 : const sal_Int32 AX_SPECIALEFFECT_SUNKEN = 2;
111 : const sal_Int32 AX_SPECIALEFFECT_ETCHED = 3;
112 : const sal_Int32 AX_SPECIALEFFECT_BUMPED = 6;
113 :
114 : const sal_Int32 AX_PICSIZE_CLIP = 0;
115 : const sal_Int32 AX_PICSIZE_STRETCH = 1;
116 : const sal_Int32 AX_PICSIZE_ZOOM = 3;
117 :
118 : const sal_Int32 AX_PICALIGN_TOPLEFT = 0;
119 : const sal_Int32 AX_PICALIGN_TOPRIGHT = 1;
120 : const sal_Int32 AX_PICALIGN_CENTER = 2;
121 : const sal_Int32 AX_PICALIGN_BOTTOMLEFT = 3;
122 : const sal_Int32 AX_PICALIGN_BOTTOMRIGHT = 4;
123 :
124 : const sal_Int32 AX_DISPLAYSTYLE_TEXT = 1;
125 : const sal_Int32 AX_DISPLAYSTYLE_LISTBOX = 2;
126 : const sal_Int32 AX_DISPLAYSTYLE_COMBOBOX = 3;
127 : const sal_Int32 AX_DISPLAYSTYLE_CHECKBOX = 4;
128 : const sal_Int32 AX_DISPLAYSTYLE_OPTBUTTON = 5;
129 : const sal_Int32 AX_DISPLAYSTYLE_TOGGLE = 6;
130 : const sal_Int32 AX_DISPLAYSTYLE_DROPDOWN = 7;
131 :
132 : const sal_Int32 AX_SELECTION_SINGLE = 0;
133 : const sal_Int32 AX_SELECTION_MULTI = 1;
134 : const sal_Int32 AX_SELECTION_EXTENDED = 2;
135 :
136 : const sal_Int32 AX_SHOWDROPBUTTON_NEVER = 0;
137 : const sal_Int32 AX_SHOWDROPBUTTON_FOCUS = 1;
138 : const sal_Int32 AX_SHOWDROPBUTTON_ALWAYS = 2;
139 :
140 : const sal_Int32 AX_SCROLLBAR_NONE = 0x00;
141 : const sal_Int32 AX_SCROLLBAR_HORIZONTAL = 0x01;
142 : const sal_Int32 AX_SCROLLBAR_VERTICAL = 0x02;
143 :
144 :
145 :
146 : /** Enumerates all UNO API control types supported by these filters. */
147 : enum ApiControlType
148 : {
149 : API_CONTROL_BUTTON,
150 : API_CONTROL_FIXEDTEXT,
151 : API_CONTROL_IMAGE,
152 : API_CONTROL_CHECKBOX,
153 : API_CONTROL_RADIOBUTTON,
154 : API_CONTROL_EDIT,
155 : API_CONTROL_NUMERIC,
156 : API_CONTROL_LISTBOX,
157 : API_CONTROL_COMBOBOX,
158 : API_CONTROL_SPINBUTTON,
159 : API_CONTROL_SCROLLBAR,
160 : API_CONTROL_TABSTRIP, //11
161 : API_CONTROL_PROGRESSBAR,
162 : API_CONTROL_GROUPBOX,
163 : API_CONTROL_FRAME, // 14
164 : API_CONTROL_PAGE, // 15
165 : API_CONTROL_MULTIPAGE, // 16
166 : API_CONTROL_DIALOG // 17
167 : };
168 :
169 :
170 :
171 : /** Specifies how a form control supports transparent background. */
172 : enum ApiTransparencyMode
173 : {
174 : API_TRANSPARENCY_NOTSUPPORTED, ///< Control does not support transparency.
175 : API_TRANSPARENCY_VOID, ///< Transparency is enabled by missing fill color.
176 : API_TRANSPARENCY_PAINTTRANSPARENT ///< Transparency is enabled by the 'PaintTransparent' property.
177 : };
178 :
179 : /** Specifies how a form control supports the DefaultState property. */
180 : enum ApiDefaultStateMode
181 : {
182 : API_DEFAULTSTATE_BOOLEAN, ///< Control does not support tri-state, state is given as boolean.
183 : API_DEFAULTSTATE_SHORT, ///< Control does not support tri-state, state is given as short.
184 : API_DEFAULTSTATE_TRISTATE ///< Control supports tri-state, state is given as short.
185 : };
186 :
187 :
188 :
189 : /** A base class with useful helper functions for something that is able to
190 : convert ActiveX and ComCtl form controls.
191 : */
192 : class OOX_DLLPUBLIC ControlConverter
193 : {
194 : public:
195 : explicit ControlConverter(
196 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxDocModel,
197 : const GraphicHelper& rGraphicHelper,
198 : bool bDefaultColorBgr = true );
199 : virtual ~ControlConverter();
200 :
201 : // Generic conversion -----------------------------------------------------
202 :
203 : /** Converts the passed position in 1/100 mm to UNO properties. */
204 : void convertPosition(
205 : PropertyMap& rPropMap,
206 : const AxPairData& rPos ) const;
207 :
208 : /** Converts the passed size in 1/100 mm to UNO properties. */
209 : void convertSize(
210 : PropertyMap& rPropMap,
211 : const AxPairData& rSize ) const;
212 :
213 : /** Converts the passed encoded OLE color to UNO properties. */
214 : void convertColor(
215 : PropertyMap& rPropMap,
216 : sal_Int32 nPropId,
217 : sal_uInt32 nOleColor ) const;
218 :
219 : void convertToMSColor(
220 : PropertySet& rPropSet,
221 : sal_Int32 nPropId,
222 : sal_uInt32& nOleColor,
223 : sal_uInt32 nDefault = 0 ) const;
224 :
225 :
226 : /** Converts the passed StdPic picture stream to UNO properties. */
227 : void convertPicture(
228 : PropertyMap& rPropMap,
229 : const StreamDataSequence& rPicData ) const;
230 :
231 : /** Converts the control orientation to UNO properties. */
232 : void convertOrientation(
233 : PropertyMap& rPropMap,
234 : bool bHorizontal ) const;
235 :
236 : void convertToMSOrientation(
237 : PropertySet& rPropMap,
238 : bool& bHorizontal ) const;
239 :
240 : /** Converts the vertical alignment to UNO properties. */
241 : void convertVerticalAlign(
242 : PropertyMap& rPropMap,
243 : sal_Int32 nVerticalAlign ) const;
244 :
245 : /** Converts common scrollbar settings to UNO properties. */
246 : void convertScrollBar(
247 : PropertyMap& rPropMap,
248 : sal_Int32 nMin, sal_Int32 nMax, sal_Int32 nPosition,
249 : sal_Int32 nSmallChange, sal_Int32 nLargeChange, bool bAwtModel ) const;
250 :
251 : /** Converts scrollability settings to UNO properties. */
252 : void convertScrollabilitySettings(
253 : PropertyMap& rPropMap,
254 : const AxPairData& rScrollPos, const AxPairData& rScrollArea,
255 : sal_Int32 nScrollBars ) const;
256 :
257 : /** Binds the passed control model to the passed data sources. The
258 : implementation will check which source types are supported. */
259 : void bindToSources(
260 : const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel,
261 : const OUString& rCtrlSource,
262 : const OUString& rRowSource,
263 : sal_Int32 nRefSheet = 0 ) const;
264 :
265 : // ActiveX (Forms 2.0) specific conversion --------------------------------
266 :
267 : /** Converts the Forms 2.0 background formatting to UNO properties. */
268 : void convertAxBackground(
269 : PropertyMap& rPropMap,
270 : sal_uInt32 nBackColor,
271 : sal_uInt32 nFlags,
272 : ApiTransparencyMode eTranspMode ) const;
273 :
274 : /** Converts the Forms 2.0 border formatting to UNO properties. */
275 : void convertAxBorder(
276 : PropertyMap& rPropMap,
277 : sal_uInt32 nBorderColor,
278 : sal_Int32 nBorderStyle,
279 : sal_Int32 nSpecialEffect ) const;
280 :
281 : void convertToAxBorder(
282 : PropertySet& rPropSet,
283 : sal_uInt32& nBorderColor,
284 : sal_Int32& nBorderStyle,
285 : sal_Int32& nSpecialEffect ) const;
286 :
287 : /** Converts the Forms 2.0 special effect to UNO properties. */
288 : void convertAxVisualEffect(
289 : PropertyMap& rPropMap,
290 : sal_Int32 nSpecialEffect ) const;
291 :
292 : void convertToAxVisualEffect(
293 : PropertySet& rPropSet,
294 : sal_Int32& nSpecialEffect ) const;
295 :
296 : /** Converts the passed picture stream and Forms 2.0 position to UNO
297 : properties. */
298 : void convertAxPicture(
299 : PropertyMap& rPropMap,
300 : const StreamDataSequence& rPicData,
301 : sal_uInt32 nPicPos ) const;
302 :
303 : /** Converts the passed picture stream and Forms 2.0 position to UNO
304 : properties. */
305 : void convertAxPicture(
306 : PropertyMap& rPropMap,
307 : const StreamDataSequence& rPicData,
308 : sal_Int32 nPicSizeMode,
309 : sal_Int32 nPicAlign,
310 : bool bPicTiling ) const;
311 :
312 : /** Converts the Forms 2.0 value for checked/unchecked/dontknow to UNO
313 : properties. */
314 : void convertAxState(
315 : PropertyMap& rPropMap,
316 : const OUString& rValue,
317 : sal_Int32 nMultiSelect,
318 : ApiDefaultStateMode eDefStateMode,
319 : bool bAwtModel ) const;
320 :
321 : void convertToAxState(
322 : PropertySet& rPropSet,
323 : OUString& rValue,
324 : sal_Int32& nMultiSelect,
325 : ApiDefaultStateMode eDefStateMode,
326 : bool bAwtModel ) const;
327 :
328 : /** Converts the Forms 2.0 control orientation to UNO properties. */
329 : void convertAxOrientation(
330 : PropertyMap& rPropMap,
331 : const AxPairData& rSize,
332 : sal_Int32 nOrientation ) const;
333 :
334 : void convertToAxOrientation(
335 : PropertySet& rPropSet,
336 : const AxPairData& rSize,
337 : sal_Int32& nOrientation ) const;
338 :
339 : private:
340 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > mxDocModel;
341 : const GraphicHelper& mrGraphicHelper;
342 : mutable PropertySet maAddressConverter;
343 : mutable PropertySet maRangeConverter;
344 : bool mbDefaultColorBgr;
345 : };
346 :
347 :
348 :
349 : /** Base class for all models of form controls. */
350 : class OOX_DLLPUBLIC ControlModelBase
351 : {
352 : public:
353 : explicit ControlModelBase();
354 : virtual ~ControlModelBase();
355 :
356 : /** Sets this control model to AWT model mode. */
357 16 : void setAwtModelMode() { mbAwtModel = true; }
358 : /** Sets this control model to form component mode. */
359 72 : void setFormComponentMode() { mbAwtModel = false; }
360 :
361 : /** Returns the UNO service name used to construct the AWT control model,
362 : or the control form component. */
363 : OUString getServiceName() const;
364 :
365 : /** Derived classes set specific OOXML properties at the model structure. */
366 : virtual void importProperty( sal_Int32 nPropId, const OUString& rValue );
367 : /** Derived classes set binary data (picture, mouse icon) at the model structure. */
368 : virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm );
369 : /** Derived classes import a form control model from the passed input stream. */
370 : virtual bool importBinaryModel( BinaryInputStream& rInStrm ) = 0;
371 : /** Derived classes export a form control model to the passed output stream. */
372 0 : virtual void exportBinaryModel( BinaryOutputStream& /*rOutStrm*/ ) {}
373 : /** Derived classes export CompObjStream contents. */
374 0 : virtual void exportCompObj( BinaryOutputStream& /*rOutStrm*/ ) {}
375 : /** Derived classes return the UNO control type enum value. */
376 : virtual ApiControlType getControlType() const = 0;
377 : /** Derived classes convert all control properties. */
378 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
379 : /** Derived classes convert from uno control properties to equiv. MS values. */
380 : virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv );
381 :
382 : /** Converts the control size to UNO properties. */
383 : void convertSize( PropertyMap& rPropMap, const ControlConverter& rConv ) const;
384 :
385 : public: // direct access needed for legacy VML drawing controls
386 : AxPairData maSize; ///< Size of the control in 1/100 mm.
387 :
388 : protected:
389 : bool mbAwtModel; ///< True = AWT control model, false = form component.
390 : };
391 :
392 : typedef ::boost::shared_ptr< ControlModelBase > ControlModelRef;
393 :
394 :
395 :
396 : /** Base class for all models of ComCtl form controls. */
397 0 : class ComCtlModelBase : public ControlModelBase
398 : {
399 : public:
400 : explicit ComCtlModelBase(
401 : sal_uInt32 nDataPartId5, sal_uInt32 nDataPartId6, sal_uInt16 nVersion,
402 : bool bCommonPart, bool bComplexPart );
403 :
404 : virtual bool importBinaryModel( BinaryInputStream& rInStrm ) SAL_OVERRIDE;
405 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const SAL_OVERRIDE;
406 :
407 : protected:
408 : virtual void importControlData( BinaryInputStream& rInStrm ) = 0;
409 : virtual void importCommonExtraData( BinaryInputStream& rInStrm );
410 : virtual void importCommonTrailingData( BinaryInputStream& rInStrm );
411 :
412 : private:
413 : /** Returns the data part identifier according to the model version. */
414 : sal_uInt32 getDataPartId() const;
415 :
416 : bool readPartHeader( BinaryInputStream& rInStrm,
417 : sal_uInt32 nExpPartId,
418 : sal_uInt16 nExpMajor = SAL_MAX_UINT16,
419 : sal_uInt16 nExpMinor = SAL_MAX_UINT16 );
420 :
421 : bool importSizePart( BinaryInputStream& rInStrm );
422 : bool importCommonPart( BinaryInputStream& rInStrm, sal_uInt32 nPartSize );
423 : bool importComplexPart( BinaryInputStream& rInStrm );
424 :
425 : protected:
426 : StdFontInfo maFontData; ///< Font formatting.
427 : StreamDataSequence maMouseIcon; ///< Binary picture stream for mouse icon.
428 : sal_uInt32 mnFlags; ///< Common flags for ComCtl controls.
429 : const sal_uInt16 mnVersion; ///< Current version of the ComCtl control model.
430 :
431 : private:
432 : sal_uInt32 mnDataPartId5; ///< Identifier for version 5.0 control data.
433 : sal_uInt32 mnDataPartId6; ///< Identifier for version 6.0 control data.
434 : bool mbCommonPart; ///< True = the COMCTL_COMMONDATA part exists.
435 : bool mbComplexPart; ///< True = the COMCTL_COMPLEXDATA part exists.
436 : };
437 :
438 :
439 :
440 : /** Model for a ComCtl scroll bar. */
441 0 : class ComCtlScrollBarModel : public ComCtlModelBase
442 : {
443 : public:
444 : explicit ComCtlScrollBarModel( sal_uInt16 nVersion );
445 :
446 : virtual ApiControlType getControlType() const SAL_OVERRIDE;
447 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const SAL_OVERRIDE;
448 :
449 : protected:
450 : virtual void importControlData( BinaryInputStream& rInStrm ) SAL_OVERRIDE;
451 :
452 : private:
453 : sal_uInt32 mnScrollBarFlags; ///< Special flags for scroll bar model.
454 : sal_Int32 mnLargeChange; ///< Increment step size (thumb).
455 : sal_Int32 mnSmallChange; ///< Increment step size (buttons).
456 : sal_Int32 mnMin; ///< Minimum of the value range.
457 : sal_Int32 mnMax; ///< Maximum of the value range.
458 : sal_Int32 mnPosition; ///< Value of the spin button.
459 : };
460 :
461 :
462 :
463 : /** Model for a ComCtl progress bar. */
464 0 : class ComCtlProgressBarModel : public ComCtlModelBase
465 : {
466 : public:
467 : explicit ComCtlProgressBarModel( sal_uInt16 nVersion );
468 :
469 : virtual ApiControlType getControlType() const SAL_OVERRIDE;
470 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const SAL_OVERRIDE;
471 :
472 : protected:
473 : virtual void importControlData( BinaryInputStream& rInStrm ) SAL_OVERRIDE;
474 :
475 : private:
476 : float mfMin; ///< Minimum of the value range.
477 : float mfMax; ///< Maximum of the value range.
478 : sal_uInt16 mnVertical; ///< 0 = horizontal, 1 = vertical.
479 : sal_uInt16 mnSmooth; ///< 0 = progress blocks, 1 = pixel resolution.
480 : };
481 :
482 :
483 :
484 : /** Base class for all models of Form 2.0 form controls. */
485 88 : class OOX_DLLPUBLIC AxControlModelBase : public ControlModelBase
486 : {
487 : public:
488 : explicit AxControlModelBase();
489 :
490 : virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) SAL_OVERRIDE;
491 : };
492 :
493 :
494 :
495 : /** Base class for Forms 2.0 controls supporting text formatting. */
496 88 : class OOX_DLLPUBLIC AxFontDataModel : public AxControlModelBase
497 : {
498 : public:
499 : explicit AxFontDataModel( bool bSupportsAlign = true );
500 :
501 : virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) SAL_OVERRIDE;
502 : virtual bool importBinaryModel( BinaryInputStream& rInStrm ) SAL_OVERRIDE;
503 : virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) SAL_OVERRIDE;
504 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const SAL_OVERRIDE;
505 : virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) SAL_OVERRIDE;
506 :
507 : /** Returns the font height in points. */
508 0 : sal_Int16 getFontHeight() const { return maFontData.getHeightPoints(); }
509 :
510 : public: // direct access needed for legacy VML drawing controls
511 : AxFontData maFontData; ///< The font settings.
512 :
513 : private:
514 : bool mbSupportsAlign; ///< True = UNO model supports Align property.
515 : };
516 :
517 :
518 :
519 : /** Model for a Forms 2.0 command button. */
520 84 : class OOX_DLLPUBLIC AxCommandButtonModel : public AxFontDataModel
521 : {
522 : public:
523 : explicit AxCommandButtonModel();
524 :
525 : virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) SAL_OVERRIDE;
526 : virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ) SAL_OVERRIDE;
527 : virtual bool importBinaryModel( BinaryInputStream& rInStrm ) SAL_OVERRIDE;
528 : virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) SAL_OVERRIDE;
529 : virtual void exportCompObj( BinaryOutputStream& rOutStrm ) SAL_OVERRIDE;
530 :
531 : virtual ApiControlType getControlType() const SAL_OVERRIDE;
532 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const SAL_OVERRIDE;
533 : virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) SAL_OVERRIDE;
534 :
535 : public: // direct access needed for legacy VML drawing controls
536 : StreamDataSequence maPictureData; ///< Binary picture stream.
537 : OUString maCaption; ///< Visible caption of the button.
538 : sal_uInt32 mnTextColor; ///< Text color.
539 : sal_uInt32 mnBackColor; ///< Fill color.
540 : sal_uInt32 mnFlags; ///< Various flags.
541 : sal_uInt32 mnPicturePos; ///< Position of the picture relative to text.
542 : sal_Int32 mnVerticalAlign; ///< Vertical alignment (legacy VML drawing controls only).
543 : bool mbFocusOnClick; ///< True = take focus on click.
544 : };
545 :
546 :
547 :
548 : /** Model for a Forms 2.0 label. */
549 4 : class OOX_DLLPUBLIC AxLabelModel : public AxFontDataModel
550 : {
551 : public:
552 : explicit AxLabelModel();
553 :
554 : virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) SAL_OVERRIDE;
555 : virtual bool importBinaryModel( BinaryInputStream& rInStrm ) SAL_OVERRIDE;
556 : virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) SAL_OVERRIDE;
557 : virtual void exportCompObj( BinaryOutputStream& rOutStrm ) SAL_OVERRIDE;
558 :
559 : virtual ApiControlType getControlType() const SAL_OVERRIDE;
560 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const SAL_OVERRIDE;
561 : virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) SAL_OVERRIDE;
562 :
563 : public: // direct access needed for legacy VML drawing controls
564 : OUString maCaption; ///< Visible caption of the button.
565 : sal_uInt32 mnTextColor; ///< Text color.
566 : sal_uInt32 mnBackColor; ///< Fill color.
567 : sal_uInt32 mnFlags; ///< Various flags.
568 : sal_uInt32 mnBorderColor; ///< Flat border color.
569 : sal_Int32 mnBorderStyle; ///< Flat border style.
570 : sal_Int32 mnSpecialEffect; ///< 3D border effect.
571 : sal_Int32 mnVerticalAlign; ///< Vertical alignment (legacy VML drawing controls only).
572 : };
573 :
574 :
575 :
576 : /** Model for a Forms 2.0 image. */
577 0 : class OOX_DLLPUBLIC AxImageModel : public AxControlModelBase
578 : {
579 : public:
580 : explicit AxImageModel();
581 :
582 : virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) SAL_OVERRIDE;
583 : virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ) SAL_OVERRIDE;
584 : virtual bool importBinaryModel( BinaryInputStream& rInStrm ) SAL_OVERRIDE;
585 : virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) SAL_OVERRIDE;
586 : virtual void exportCompObj( BinaryOutputStream& rOutStrm ) SAL_OVERRIDE;
587 :
588 : virtual ApiControlType getControlType() const SAL_OVERRIDE;
589 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const SAL_OVERRIDE;
590 :
591 : private:
592 : StreamDataSequence maPictureData; ///< Binary picture stream.
593 : sal_uInt32 mnBackColor; ///< Fill color.
594 : sal_uInt32 mnFlags; ///< Various flags.
595 : sal_uInt32 mnBorderColor; ///< Flat border color.
596 : sal_Int32 mnBorderStyle; ///< Flat border style.
597 : sal_Int32 mnSpecialEffect; ///< 3D border effect.
598 : sal_Int32 mnPicSizeMode; ///< Clip, stretch, zoom.
599 : sal_Int32 mnPicAlign; ///< Anchor position of the picture.
600 : bool mbPicTiling; ///< True = picture is repeated.
601 : };
602 :
603 0 : class OOX_DLLPUBLIC AxTabStripModel : public AxFontDataModel
604 : {
605 : public:
606 : explicit AxTabStripModel();
607 :
608 : virtual bool importBinaryModel( BinaryInputStream& rInStrm ) SAL_OVERRIDE;
609 :
610 : virtual ApiControlType getControlType() const SAL_OVERRIDE;
611 :
612 : public:
613 : sal_uInt32 mnListIndex;
614 : sal_uInt32 mnTabStyle;
615 : sal_uInt32 mnTabData;
616 : sal_uInt32 mnVariousPropertyBits;
617 : std::vector< ::rtl::OUString > maItems; // captions for each tab
618 : std::vector< ::rtl::OUString > maTabNames; // names for each tab
619 : };
620 :
621 :
622 :
623 : /** Base class for a Forms 2.0 morph data control. */
624 40 : class OOX_DLLPUBLIC AxMorphDataModelBase : public AxFontDataModel
625 : {
626 : public:
627 : explicit AxMorphDataModelBase();
628 :
629 : virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) SAL_OVERRIDE;
630 : virtual void importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm ) SAL_OVERRIDE;
631 : virtual bool importBinaryModel( BinaryInputStream& rInStrm ) SAL_OVERRIDE;
632 : virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) SAL_OVERRIDE;
633 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const SAL_OVERRIDE;
634 :
635 : public: // direct access needed for legacy VML drawing controls
636 : StreamDataSequence maPictureData; ///< Binary picture stream.
637 : OUString maCaption; ///< Visible caption of the button.
638 : OUString maValue; ///< Current value of the control.
639 : OUString maGroupName; ///< Group name for option buttons.
640 : sal_uInt32 mnTextColor; ///< Text color.
641 : sal_uInt32 mnBackColor; ///< Fill color.
642 : sal_uInt32 mnFlags; ///< Various flags.
643 : sal_uInt32 mnPicturePos; ///< Position of the picture relative to text.
644 : sal_uInt32 mnBorderColor; ///< Flat border color.
645 : sal_Int32 mnBorderStyle; ///< Flat border style.
646 : sal_Int32 mnSpecialEffect; ///< 3D border effect.
647 : sal_Int32 mnDisplayStyle; ///< Type of the morph control.
648 : sal_Int32 mnMultiSelect; ///< Selection mode.
649 : sal_Int32 mnScrollBars; ///< Horizontal/vertical scroll bar.
650 : sal_Int32 mnMatchEntry; ///< Auto completion mode.
651 : sal_Int32 mnShowDropButton; ///< When to show the dropdown button.
652 : sal_Int32 mnMaxLength; ///< Maximum character count.
653 : sal_Int32 mnPasswordChar; ///< Password character in edit fields.
654 : sal_Int32 mnListRows; ///< Number of rows in dropdown box.
655 : sal_Int32 mnVerticalAlign; ///< Vertical alignment (legacy VML drawing controls only).
656 : };
657 :
658 :
659 :
660 : /** Model for a Forms 2.0 toggle button. */
661 8 : class OOX_DLLPUBLIC AxToggleButtonModel : public AxMorphDataModelBase
662 : {
663 : public:
664 : explicit AxToggleButtonModel();
665 :
666 : virtual ApiControlType getControlType() const SAL_OVERRIDE;
667 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const SAL_OVERRIDE;
668 : virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) SAL_OVERRIDE;
669 : virtual void exportCompObj( BinaryOutputStream& rOutStrm ) SAL_OVERRIDE;
670 : };
671 :
672 :
673 :
674 : /** Model for a Forms 2.0 check box. */
675 20 : class OOX_DLLPUBLIC AxCheckBoxModel : public AxMorphDataModelBase
676 : {
677 : public:
678 : explicit AxCheckBoxModel();
679 :
680 : virtual ApiControlType getControlType() const SAL_OVERRIDE;
681 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const SAL_OVERRIDE;
682 : virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) SAL_OVERRIDE;
683 : virtual void exportCompObj( BinaryOutputStream& rOutStrm ) SAL_OVERRIDE;
684 : };
685 :
686 :
687 :
688 : /** Model for a Forms 2.0 option button. */
689 16 : class OOX_DLLPUBLIC AxOptionButtonModel : public AxMorphDataModelBase
690 : {
691 : public:
692 : explicit AxOptionButtonModel();
693 :
694 : /** Returns the group name used to goup several option buttons gogether. */
695 2 : const OUString& getGroupName() const { return maGroupName; }
696 :
697 : virtual ApiControlType getControlType() const SAL_OVERRIDE;
698 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const SAL_OVERRIDE;
699 : virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) SAL_OVERRIDE;
700 : virtual void exportCompObj( BinaryOutputStream& rOutStrm ) SAL_OVERRIDE;
701 : };
702 :
703 :
704 :
705 : /** Model for a Forms 2.0 text box. */
706 20 : class OOX_DLLPUBLIC AxTextBoxModel : public AxMorphDataModelBase
707 : {
708 : public:
709 : explicit AxTextBoxModel();
710 :
711 : virtual ApiControlType getControlType() const SAL_OVERRIDE;
712 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const SAL_OVERRIDE;
713 : virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) SAL_OVERRIDE;
714 : virtual void exportCompObj( BinaryOutputStream& rOutStrm ) SAL_OVERRIDE;
715 : };
716 :
717 :
718 :
719 : /** Model for a numeric field (legacy drawing controls only). */
720 0 : class OOX_DLLPUBLIC AxNumericFieldModel : public AxMorphDataModelBase
721 : {
722 : public:
723 : explicit AxNumericFieldModel();
724 :
725 : virtual ApiControlType getControlType() const SAL_OVERRIDE;
726 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const SAL_OVERRIDE;
727 : virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) SAL_OVERRIDE;
728 : virtual void exportCompObj( BinaryOutputStream& rOutStrm ) SAL_OVERRIDE;
729 : };
730 :
731 :
732 :
733 : /** Model for a Forms 2.0 list box. */
734 8 : class OOX_DLLPUBLIC AxListBoxModel : public AxMorphDataModelBase
735 : {
736 : public:
737 : explicit AxListBoxModel();
738 :
739 : virtual ApiControlType getControlType() const SAL_OVERRIDE;
740 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const SAL_OVERRIDE;
741 : virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) SAL_OVERRIDE;
742 : virtual void exportCompObj( BinaryOutputStream& rOutStrm ) SAL_OVERRIDE;
743 : };
744 :
745 :
746 :
747 : /** Model for a Forms 2.0 combo box. */
748 8 : class OOX_DLLPUBLIC AxComboBoxModel : public AxMorphDataModelBase
749 : {
750 : public:
751 : explicit AxComboBoxModel();
752 :
753 : virtual ApiControlType getControlType() const SAL_OVERRIDE;
754 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const SAL_OVERRIDE;
755 : virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) SAL_OVERRIDE;
756 : virtual void exportCompObj( BinaryOutputStream& rOutStrm ) SAL_OVERRIDE;
757 : };
758 :
759 :
760 :
761 : /** Model for a Forms 2.0 spin button. */
762 0 : class OOX_DLLPUBLIC AxSpinButtonModel : public AxControlModelBase
763 : {
764 : public:
765 : explicit AxSpinButtonModel();
766 :
767 : virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) SAL_OVERRIDE;
768 : virtual bool importBinaryModel( BinaryInputStream& rInStrm ) SAL_OVERRIDE;
769 : virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) SAL_OVERRIDE;
770 :
771 : virtual ApiControlType getControlType() const SAL_OVERRIDE;
772 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const SAL_OVERRIDE;
773 : virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) SAL_OVERRIDE;
774 : virtual void exportCompObj( BinaryOutputStream& rOutStrm ) SAL_OVERRIDE;
775 :
776 : public: // direct access needed for legacy VML drawing controls
777 : sal_uInt32 mnArrowColor; ///< Button arrow color.
778 : sal_uInt32 mnBackColor; ///< Fill color.
779 : sal_uInt32 mnFlags; ///< Various flags.
780 : sal_Int32 mnOrientation; ///< Orientation of the buttons.
781 : sal_Int32 mnMin; ///< Minimum of the value range.
782 : sal_Int32 mnMax; ///< Maximum of the value range.
783 : sal_Int32 mnPosition; ///< Value of the spin button.
784 : sal_Int32 mnSmallChange; ///< Increment step size.
785 : sal_Int32 mnDelay; ///< Repeat delay in milliseconds.
786 : };
787 :
788 :
789 :
790 : /** Model for a Forms 2.0 scroll bar. */
791 0 : class OOX_DLLPUBLIC AxScrollBarModel : public AxControlModelBase
792 : {
793 : public:
794 : explicit AxScrollBarModel();
795 :
796 : virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) SAL_OVERRIDE;
797 : virtual bool importBinaryModel( BinaryInputStream& rInStrm ) SAL_OVERRIDE;
798 : virtual void exportBinaryModel( BinaryOutputStream& rOutStrm ) SAL_OVERRIDE;
799 : virtual void exportCompObj( BinaryOutputStream& rOutStrm ) SAL_OVERRIDE;
800 :
801 : virtual ApiControlType getControlType() const SAL_OVERRIDE;
802 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const SAL_OVERRIDE;
803 : virtual void convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv ) SAL_OVERRIDE;
804 :
805 : public: // direct access needed for legacy VML drawing controls
806 : sal_uInt32 mnArrowColor; ///< Button arrow color.
807 : sal_uInt32 mnBackColor; ///< Fill color.
808 : sal_uInt32 mnFlags; ///< Various flags.
809 : sal_Int32 mnOrientation; ///< Orientation of the buttons.
810 : sal_Int32 mnPropThumb; ///< Proportional thumb size.
811 : sal_Int32 mnMin; ///< Minimum of the value range.
812 : sal_Int32 mnMax; ///< Maximum of the value range.
813 : sal_Int32 mnPosition; ///< Value of the spin button.
814 : sal_Int32 mnSmallChange; ///< Increment step size (buttons).
815 : sal_Int32 mnLargeChange; ///< Increment step size (thumb).
816 : sal_Int32 mnDelay; ///< Repeat delay in milliseconds.
817 : };
818 :
819 :
820 :
821 : typedef ::std::vector< OUString > AxClassTable;
822 :
823 : /** Base class for ActiveX container controls. */
824 4 : class OOX_DLLPUBLIC AxContainerModelBase : public AxFontDataModel
825 : {
826 : public:
827 : explicit AxContainerModelBase( bool bFontSupport = false );
828 :
829 : /** Allows to set single properties specified by XML token identifier. */
830 : virtual void importProperty( sal_Int32 nPropId, const OUString& rValue ) SAL_OVERRIDE;
831 : /** Reads the leading structure in the 'f' stream containing the model for
832 : this control. */
833 : virtual bool importBinaryModel( BinaryInputStream& rInStrm ) SAL_OVERRIDE;
834 : /** Converts font settings if supported. */
835 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const SAL_OVERRIDE;
836 :
837 : /** Reads the class table structure for embedded controls following the own
838 : model from the 'f' stream. */
839 : bool importClassTable( BinaryInputStream& rInStrm, AxClassTable& orClassTable );
840 :
841 : public: // direct access needed for legacy VML drawing controls
842 : StreamDataSequence maPictureData; ///< Binary picture stream.
843 : OUString maCaption; ///< Visible caption of the form.
844 : AxPairData maLogicalSize; ///< Logical form size (scroll area).
845 : AxPairData maScrollPos; ///< Scroll position.
846 : sal_uInt32 mnBackColor; ///< Fill color.
847 : sal_uInt32 mnTextColor; ///< Text color.
848 : sal_uInt32 mnFlags; ///< Various flags.
849 : sal_uInt32 mnBorderColor; ///< Flat border color.
850 : sal_Int32 mnBorderStyle; ///< Flat border style.
851 : sal_Int32 mnScrollBars; ///< Horizontal/vertical scroll bar.
852 : sal_Int32 mnCycleType; ///< Cycle in all forms or in this form.
853 : sal_Int32 mnSpecialEffect; ///< 3D border effect.
854 : sal_Int32 mnPicAlign; ///< Anchor position of the picture.
855 : sal_Int32 mnPicSizeMode; ///< Clip, stretch, zoom.
856 : bool mbPicTiling; ///< True = picture is repeated.
857 : bool mbFontSupport; ///< True = control supports the font property.
858 : };
859 :
860 : typedef ::boost::shared_ptr< AxContainerModelBase > AxContainerModelRef;
861 :
862 :
863 :
864 : /** Model for a Forms 2.0 frame control. */
865 0 : class OOX_DLLPUBLIC AxFrameModel : public AxContainerModelBase
866 : {
867 : public:
868 : explicit AxFrameModel();
869 :
870 : virtual ApiControlType getControlType() const SAL_OVERRIDE;
871 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const SAL_OVERRIDE;
872 : };
873 :
874 0 : class OOX_DLLPUBLIC AxPageModel : public AxContainerModelBase
875 : {
876 : public:
877 : explicit AxPageModel();
878 :
879 : virtual ApiControlType getControlType() const SAL_OVERRIDE;
880 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const SAL_OVERRIDE;
881 : };
882 :
883 0 : class OOX_DLLPUBLIC AxMultiPageModel : public AxContainerModelBase
884 : {
885 : public:
886 : explicit AxMultiPageModel();
887 :
888 : virtual ApiControlType getControlType() const SAL_OVERRIDE;
889 : virtual bool importPageAndMultiPageProperties( BinaryInputStream& rInStrm, sal_Int32 nPages );
890 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const SAL_OVERRIDE;
891 : std::vector<sal_uInt32> mnIDs;
892 : sal_uInt32 mnActiveTab;
893 : sal_uInt32 mnTabStyle;
894 : };
895 :
896 :
897 :
898 :
899 : /** Model for a Forms 2.0 user form. */
900 8 : class OOX_DLLPUBLIC AxUserFormModel : public AxContainerModelBase
901 : {
902 : public:
903 : explicit AxUserFormModel();
904 :
905 : virtual ApiControlType getControlType() const SAL_OVERRIDE;
906 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const SAL_OVERRIDE;
907 : };
908 :
909 0 : class HtmlSelectModel : public AxListBoxModel
910 : {
911 : com::sun::star::uno::Sequence< OUString > msListData;
912 : com::sun::star::uno::Sequence< sal_Int16 > msIndices;
913 : public:
914 : HtmlSelectModel();
915 : virtual bool importBinaryModel( BinaryInputStream& rInStrm ) SAL_OVERRIDE;
916 : virtual void convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const SAL_OVERRIDE;
917 : };
918 :
919 0 : class HtmlTextBoxModel : public AxTextBoxModel
920 : {
921 : public:
922 : explicit HtmlTextBoxModel();
923 : virtual bool importBinaryModel( BinaryInputStream& rInStrm ) SAL_OVERRIDE;
924 : };
925 :
926 :
927 : /** A form control embedded in a document draw page. Contains a specific model
928 : structure according to the type of the control. */
929 2 : class OOX_DLLPUBLIC EmbeddedControl
930 : {
931 : public:
932 : explicit EmbeddedControl( const OUString& rName );
933 : virtual ~EmbeddedControl();
934 :
935 : /** Creates and returns the internal control model of the specified type. */
936 : template< typename ModelType >
937 : inline ModelType& createModel();
938 :
939 : /** Creates and returns the internal control model of the specified type. */
940 : template< typename ModelType, typename ParamType >
941 : inline ModelType& createModel( const ParamType& rParam );
942 :
943 : /** Creates and returns the internal control model according to the passed
944 : MS class identifier. */
945 : ControlModelBase* createModelFromGuid( const OUString& rClassId );
946 :
947 : /** Returns true, if the internal control model exists. */
948 2 : bool hasModel() const { return mxModel.get() != 0; }
949 : /** Returns read-only access to the internal control model. */
950 : const ControlModelBase* getModel() const { return mxModel.get(); }
951 : /** Returns read/write access to the internal control model. */
952 2 : ControlModelBase* getModel() { return mxModel.get(); }
953 :
954 : /** Returns the UNO service name needed to construct the control model. */
955 : OUString getServiceName() const;
956 :
957 : /** Converts all control properties and inserts them into the passed model. */
958 : bool convertProperties(
959 : const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel,
960 : const ControlConverter& rConv ) const;
961 :
962 : bool convertFromProperties(
963 : const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel,
964 : const ControlConverter& rConv );
965 :
966 : private:
967 : ControlModelRef mxModel; ///< Control model containing the properties.
968 : OUString maName; ///< Name of the control.
969 : };
970 :
971 :
972 :
973 : template< typename ModelType >
974 72 : inline ModelType& EmbeddedControl::createModel()
975 : {
976 72 : ::boost::shared_ptr< ModelType > xModel( new ModelType );
977 72 : mxModel = xModel;
978 72 : xModel->setFormComponentMode();
979 72 : return *xModel;
980 : }
981 :
982 : template< typename ModelType, typename ParamType >
983 0 : inline ModelType& EmbeddedControl::createModel( const ParamType& rParam )
984 : {
985 0 : ::boost::shared_ptr< ModelType > xModel( new ModelType( rParam ) );
986 0 : mxModel = xModel;
987 0 : xModel->setFormComponentMode();
988 0 : return *xModel;
989 : }
990 :
991 :
992 :
993 : /** A wrapper for a control form embedded directly in a draw page. */
994 2 : class EmbeddedForm
995 : {
996 : public:
997 : explicit EmbeddedForm(
998 : const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxDocModel,
999 : const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& rxDrawPage,
1000 : const GraphicHelper& rGraphicHelper,
1001 : bool bDefaultColorBgr = true );
1002 :
1003 : /** Converts the passed control and inserts the control model into the form.
1004 : @return The API control model, if conversion was successful. */
1005 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >
1006 : convertAndInsert( const EmbeddedControl& rControl, sal_Int32& rnCtrlIndex );
1007 :
1008 : /** Returns the XIndexContainer interface of the UNO control form, if existing. */
1009 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >
1010 0 : getXForm() const { return mxFormIC; }
1011 :
1012 : private:
1013 : /** Creates the form that will hold the form controls. */
1014 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >
1015 : createXForm();
1016 :
1017 : private:
1018 : ControlConverter maControlConv;
1019 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxModelFactory;
1020 : ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormsSupplier > mxFormsSupp;
1021 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > mxFormIC;
1022 : };
1023 :
1024 :
1025 :
1026 : } // namespace ole
1027 : } // namespace oox
1028 :
1029 : #endif
1030 :
1031 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|