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