Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / oox / source / ole / axcontrol.cxx
blob57606fa1ce0be7f899295bb99306b8625aef8cb0
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 #include <oox/ole/axcontrol.hxx>
22 #include <com/sun/star/awt/FontSlant.hpp>
23 #include <com/sun/star/awt/FontStrikeout.hpp>
24 #include <com/sun/star/awt/FontUnderline.hpp>
25 #include <com/sun/star/awt/FontWeight.hpp>
26 #include <com/sun/star/awt/ImagePosition.hpp>
27 #include <com/sun/star/awt/ImageScaleMode.hpp>
28 #include <com/sun/star/awt/Point.hpp>
29 #include <com/sun/star/awt/ScrollBarOrientation.hpp>
30 #include <com/sun/star/awt/Size.hpp>
31 #include <com/sun/star/awt/TextAlign.hpp>
32 #include <com/sun/star/awt/VisualEffect.hpp>
33 #include <com/sun/star/awt/XControlModel.hpp>
34 #include <com/sun/star/beans/NamedValue.hpp>
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <com/sun/star/container/XIndexContainer.hpp>
37 #include <com/sun/star/form/XForm.hpp>
38 #include <com/sun/star/form/XFormComponent.hpp>
39 #include <com/sun/star/form/XFormsSupplier.hpp>
40 #include <com/sun/star/form/binding/XBindableValue.hpp>
41 #include <com/sun/star/form/binding/XListEntrySink.hpp>
42 #include <com/sun/star/form/binding/XListEntrySource.hpp>
43 #include <com/sun/star/form/binding/XValueBinding.hpp>
44 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
45 #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
46 #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
47 #include <com/sun/star/style/VerticalAlignment.hpp>
48 #include <com/sun/star/table/CellAddress.hpp>
49 #include <com/sun/star/table/CellRangeAddress.hpp>
50 #include <rtl/tencinfo.h>
51 #include <osl/diagnose.h>
52 #include <sal/log.hxx>
53 #include <vcl/font.hxx>
54 #include <vcl/outdev.hxx>
55 #include <vcl/settings.hxx>
56 #include <vcl/svapp.hxx>
57 #include <oox/helper/attributelist.hxx>
58 #include <oox/helper/binaryinputstream.hxx>
59 #include <oox/helper/containerhelper.hxx>
60 #include <oox/helper/graphichelper.hxx>
61 #include <oox/helper/propertymap.hxx>
62 #include <oox/ole/axbinarywriter.hxx>
63 #include <oox/token/properties.hxx>
64 #include <oox/token/tokens.hxx>
65 #include <tools/diagnose_ex.h>
67 namespace oox {
68 namespace ole {
70 using namespace ::com::sun::star;
71 using namespace ::com::sun::star::awt;
72 using namespace ::com::sun::star::beans;
73 using namespace ::com::sun::star::container;
74 using namespace ::com::sun::star::drawing;
75 using namespace ::com::sun::star::form;
76 using namespace ::com::sun::star::form::binding;
77 using namespace ::com::sun::star::frame;
78 using namespace ::com::sun::star::lang;
79 using namespace ::com::sun::star::sheet;
80 using namespace ::com::sun::star::style;
81 using namespace ::com::sun::star::table;
82 using namespace ::com::sun::star::uno;
84 namespace {
86 const sal_uInt32 COMCTL_ID_SIZE = 0x12344321;
88 const sal_uInt32 COMCTL_ID_COMMONDATA = 0xABCDEF01;
89 const sal_uInt32 COMCTL_COMMON_FLATBORDER = 0x00000001;
90 const sal_uInt32 COMCTL_COMMON_ENABLED = 0x00000002;
91 const sal_uInt32 COMCTL_COMMON_3DBORDER = 0x00000004;
93 const sal_uInt32 COMCTL_ID_COMPLEXDATA = 0xBDECDE1F;
94 const sal_uInt32 COMCTL_COMPLEX_FONT = 0x00000001;
95 const sal_uInt32 COMCTL_COMPLEX_MOUSEICON = 0x00000002;
97 const sal_uInt32 COMCTL_ID_SCROLLBAR_60 = 0x99470A83;
98 const sal_uInt32 COMCTL_SCROLLBAR_HOR = 0x00000010;
100 const sal_uInt32 COMCTL_ID_PROGRESSBAR_50 = 0xE6E17E84;
101 const sal_uInt32 COMCTL_ID_PROGRESSBAR_60 = 0x97AB8A01;
103 const sal_uInt32 AX_CMDBUTTON_DEFFLAGS = 0x0000001B;
104 const sal_uInt32 AX_LABEL_DEFFLAGS = 0x0080001B;
105 const sal_uInt32 AX_IMAGE_DEFFLAGS = 0x0000001B;
106 const sal_uInt32 AX_MORPHDATA_DEFFLAGS = 0x2C80081B;
107 const sal_uInt32 AX_SPINBUTTON_DEFFLAGS = 0x0000001B;
108 const sal_uInt32 AX_SCROLLBAR_DEFFLAGS = 0x0000001B;
110 const sal_uInt16 AX_POS_TOPLEFT = 0;
111 const sal_uInt16 AX_POS_TOP = 1;
112 const sal_uInt16 AX_POS_TOPRIGHT = 2;
113 const sal_uInt16 AX_POS_LEFT = 3;
114 const sal_uInt16 AX_POS_CENTER = 4;
115 const sal_uInt16 AX_POS_RIGHT = 5;
116 const sal_uInt16 AX_POS_BOTTOMLEFT = 6;
117 const sal_uInt16 AX_POS_BOTTOM = 7;
118 const sal_uInt16 AX_POS_BOTTOMRIGHT = 8;
120 #define AX_PICPOS_IMPL( label, image ) ((AX_POS_##label << 16) | AX_POS_##image)
121 const sal_uInt32 AX_PICPOS_LEFTTOP = AX_PICPOS_IMPL( TOPRIGHT, TOPLEFT );
122 const sal_uInt32 AX_PICPOS_LEFTCENTER = AX_PICPOS_IMPL( RIGHT, LEFT );
123 const sal_uInt32 AX_PICPOS_LEFTBOTTOM = AX_PICPOS_IMPL( BOTTOMRIGHT, BOTTOMLEFT );
124 const sal_uInt32 AX_PICPOS_RIGHTTOP = AX_PICPOS_IMPL( TOPLEFT, TOPRIGHT );
125 const sal_uInt32 AX_PICPOS_RIGHTCENTER = AX_PICPOS_IMPL( LEFT, RIGHT );
126 const sal_uInt32 AX_PICPOS_RIGHTBOTTOM = AX_PICPOS_IMPL( BOTTOMLEFT, BOTTOMRIGHT );
127 const sal_uInt32 AX_PICPOS_ABOVELEFT = AX_PICPOS_IMPL( BOTTOMLEFT, TOPLEFT );
128 const sal_uInt32 AX_PICPOS_ABOVECENTER = AX_PICPOS_IMPL( BOTTOM, TOP );
129 const sal_uInt32 AX_PICPOS_ABOVERIGHT = AX_PICPOS_IMPL( BOTTOMRIGHT, TOPRIGHT );
130 const sal_uInt32 AX_PICPOS_BELOWLEFT = AX_PICPOS_IMPL( TOPLEFT, BOTTOMLEFT );
131 const sal_uInt32 AX_PICPOS_BELOWCENTER = AX_PICPOS_IMPL( TOP, BOTTOM );
132 const sal_uInt32 AX_PICPOS_BELOWRIGHT = AX_PICPOS_IMPL( TOPRIGHT, BOTTOMRIGHT );
133 const sal_uInt32 AX_PICPOS_CENTER = AX_PICPOS_IMPL( CENTER, CENTER );
134 #undef AX_PICPOS_IMPL
136 const sal_Int32 AX_MATCHENTRY_FIRSTLETTER = 0;
137 const sal_Int32 AX_MATCHENTRY_COMPLETE = 1;
138 const sal_Int32 AX_MATCHENTRY_NONE = 2;
140 const sal_Int32 AX_ORIENTATION_AUTO = -1;
141 const sal_Int32 AX_ORIENTATION_VERTICAL = 0;
142 const sal_Int32 AX_ORIENTATION_HORIZONTAL = 1;
144 const sal_Int32 AX_PROPTHUMB_ON = -1;
146 const sal_uInt32 AX_TABSTRIP_TABS = 0;
147 const sal_uInt32 AX_TABSTRIP_NONE = 2;
149 const sal_uInt32 AX_CONTAINER_ENABLED = 0x00000004;
150 const sal_uInt32 AX_CONTAINER_NOCLASSTABLE = 0x00008000;
152 const sal_uInt32 AX_CONTAINER_DEFFLAGS = 0x00000004;
154 const sal_Int32 AX_CONTAINER_DEFWIDTH = 4000;
155 const sal_Int32 AX_CONTAINER_DEFHEIGHT = 3000;
157 const sal_Int32 AX_CONTAINER_CYCLEALL = 0;
159 const sal_Int32 AX_CONTAINER_SCR_NONE = 0x00;
161 const sal_Int16 API_BORDER_NONE = 0;
162 const sal_Int16 API_BORDER_SUNKEN = 1;
163 const sal_Int16 API_BORDER_FLAT = 2;
165 const sal_Int16 API_STATE_UNCHECKED = 0;
166 const sal_Int16 API_STATE_CHECKED = 1;
167 const sal_Int16 API_STATE_DONTKNOW = 2;
169 /** Tries to extract a range address from a defined name. */
170 bool lclExtractRangeFromName( CellRangeAddress& orRangeAddr, const Reference< XModel >& rxDocModel, const OUString& rAddressString )
174 PropertySet aPropSet( rxDocModel );
175 Reference< XNameAccess > xRangesNA( aPropSet.getAnyProperty( PROP_NamedRanges ), UNO_QUERY_THROW );
176 Reference< XCellRangeReferrer > xReferrer( xRangesNA->getByName( rAddressString ), UNO_QUERY_THROW );
177 Reference< XCellRangeAddressable > xAddressable( xReferrer->getReferredCells(), UNO_QUERY_THROW );
178 orRangeAddr = xAddressable->getRangeAddress();
179 return true;
181 catch (const Exception&)
183 TOOLS_WARN_EXCEPTION("oox", "");
185 return false;
188 bool lclExtractAddressFromName( CellAddress& orAddress, const Reference< XModel >& rxDocModel, const OUString& rAddressString )
190 CellRangeAddress aRangeAddr;
191 if( lclExtractRangeFromName( aRangeAddr, rxDocModel, rAddressString ) &&
192 (aRangeAddr.StartColumn == aRangeAddr.EndColumn) &&
193 (aRangeAddr.StartRow == aRangeAddr.EndRow) )
195 orAddress.Sheet = aRangeAddr.Sheet;
196 orAddress.Column = aRangeAddr.StartColumn;
197 orAddress.Row = aRangeAddr.StartRow;
198 return true;
200 return false;
203 void lclPrepareConverter( PropertySet& rConverter, const Reference< XModel >& rxDocModel,
204 const OUString& rAddressString, sal_Int32 nRefSheet, bool bRange )
206 if( !rConverter.is() ) try
208 Reference< XMultiServiceFactory > xModelFactory( rxDocModel, UNO_QUERY_THROW );
209 OUString aServiceName = bRange ?
210 OUString( "com.sun.star.table.CellRangeAddressConversion" ) :
211 OUString( "com.sun.star.table.CellAddressConversion" );
212 rConverter.set( xModelFactory->createInstance( aServiceName ) );
214 catch (const Exception&)
216 TOOLS_WARN_EXCEPTION("oox", "");
218 rConverter.setProperty( PROP_XLA1Representation, rAddressString );
219 rConverter.setProperty( PROP_ReferenceSheet, nRefSheet );
222 } // namespace
224 ControlConverter::ControlConverter( const Reference< XModel >& rxDocModel,
225 const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ) :
226 mxDocModel( rxDocModel ),
227 mrGraphicHelper( rGraphicHelper ),
228 mbDefaultColorBgr( bDefaultColorBgr )
230 OSL_ENSURE( mxDocModel.is(), "ControlConverter::ControlConverter - missing document model" );
233 ControlConverter::~ControlConverter()
237 // Generic conversion ---------------------------------------------------------
239 void ControlConverter::convertPosition( PropertyMap& rPropMap, const AxPairData& rPos ) const
241 // position is given in 1/100 mm, UNO needs AppFont units
242 awt::Point aAppFontPos = mrGraphicHelper.convertHmmToAppFont( awt::Point( rPos.first, rPos.second ) );
243 rPropMap.setProperty( PROP_PositionX, aAppFontPos.X );
244 rPropMap.setProperty( PROP_PositionY, aAppFontPos.Y );
247 void ControlConverter::convertSize( PropertyMap& rPropMap, const AxPairData& rSize ) const
249 // size is given in 1/100 mm, UNO needs AppFont units
250 awt::Size aAppFontSize = mrGraphicHelper.convertHmmToAppFont( awt::Size( rSize.first, rSize.second ) );
251 rPropMap.setProperty( PROP_Width, aAppFontSize.Width );
252 rPropMap.setProperty( PROP_Height, aAppFontSize.Height );
255 void ControlConverter::convertColor( PropertyMap& rPropMap, sal_Int32 nPropId, sal_uInt32 nOleColor ) const
257 rPropMap.setProperty( nPropId, OleHelper::decodeOleColor( mrGraphicHelper, nOleColor, mbDefaultColorBgr ) );
260 void ControlConverter::convertToMSColor( PropertySet const & rPropSet, sal_Int32 nPropId, sal_uInt32& nOleColor, sal_uInt32 nDefault )
262 sal_uInt32 nRGB = 0;
263 if (rPropSet.getProperty( nRGB, nPropId ))
264 nOleColor = OleHelper::encodeOleColor( nRGB );
265 else
266 nOleColor = nDefault;
268 void ControlConverter::convertPicture( PropertyMap& rPropMap, const StreamDataSequence& rPicData ) const
270 if( rPicData.hasElements() )
272 uno::Reference<graphic::XGraphic> xGraphic = mrGraphicHelper.importGraphic(rPicData);
273 if (xGraphic.is())
274 rPropMap.setProperty(PROP_Graphic, xGraphic);
278 void ControlConverter::convertOrientation( PropertyMap& rPropMap, bool bHorizontal )
280 sal_Int32 nScrollOrient = bHorizontal ? ScrollBarOrientation::HORIZONTAL : ScrollBarOrientation::VERTICAL;
281 rPropMap.setProperty( PROP_Orientation, nScrollOrient );
284 void ControlConverter::convertToMSOrientation( PropertySet const & rPropSet, bool& bHorizontal )
286 sal_Int32 nScrollOrient = ScrollBarOrientation::HORIZONTAL;
287 if ( rPropSet.getProperty( nScrollOrient, PROP_Orientation ) )
288 bHorizontal = ( nScrollOrient == ScrollBarOrientation::HORIZONTAL );
291 void ControlConverter::convertVerticalAlign( PropertyMap& rPropMap, sal_Int32 nVerticalAlign )
293 VerticalAlignment eAlign = VerticalAlignment_TOP;
294 switch( nVerticalAlign )
296 case XML_Top: eAlign = VerticalAlignment_TOP; break;
297 case XML_Center: eAlign = VerticalAlignment_MIDDLE; break;
298 case XML_Bottom: eAlign = VerticalAlignment_BOTTOM; break;
300 rPropMap.setProperty( PROP_VerticalAlign, eAlign );
303 void ControlConverter::convertScrollabilitySettings( PropertyMap& rPropMap,
304 const AxPairData& rScrollPos, const AxPairData& rScrollArea,
305 sal_Int32 nScrollBars ) const
307 awt::Size tmpSize = mrGraphicHelper.convertHmmToAppFont( awt::Size( rScrollArea.first, rScrollArea.second ) );
308 awt::Point tmpPos = mrGraphicHelper.convertHmmToAppFont( awt::Point( rScrollPos.first, rScrollPos.second ) );
309 rPropMap.setProperty( PROP_ScrollHeight, tmpSize.Height );
310 rPropMap.setProperty( PROP_ScrollWidth, tmpSize.Width );
311 rPropMap.setProperty( PROP_ScrollTop, tmpPos.Y );
312 rPropMap.setProperty( PROP_ScrollLeft, tmpPos.X );
313 rPropMap.setProperty( PROP_HScroll, ( nScrollBars & 0x1 ) == 0x1 );
314 rPropMap.setProperty( PROP_VScroll, ( nScrollBars & 0x2 ) == 0x2 );
317 void ControlConverter::convertScrollBar( PropertyMap& rPropMap,
318 sal_Int32 nMin, sal_Int32 nMax, sal_Int32 nPosition,
319 sal_Int32 nSmallChange, sal_Int32 nLargeChange, bool bAwtModel )
321 rPropMap.setProperty( PROP_ScrollValueMin, ::std::min( nMin, nMax ) );
322 rPropMap.setProperty( PROP_ScrollValueMax, ::std::max( nMin, nMax ) );
323 rPropMap.setProperty( PROP_LineIncrement, nSmallChange );
324 rPropMap.setProperty( PROP_BlockIncrement, nLargeChange );
325 rPropMap.setProperty( bAwtModel ? PROP_ScrollValue : PROP_DefaultScrollValue, nPosition );
328 void ControlConverter::bindToSources( const Reference< XControlModel >& rxCtrlModel,
329 const OUString& rCtrlSource, const OUString& rRowSource, sal_Int32 nRefSheet ) const
331 // value binding
332 if( !rCtrlSource.isEmpty() ) try
334 // first check if the XBindableValue interface is supported
335 Reference< XBindableValue > xBindable( rxCtrlModel, UNO_QUERY_THROW );
337 // convert address string to cell address struct
338 CellAddress aAddress;
339 if( !lclExtractAddressFromName( aAddress, mxDocModel, rCtrlSource ) )
341 lclPrepareConverter( maAddressConverter, mxDocModel, rCtrlSource, nRefSheet, false );
342 if( !maAddressConverter.getProperty( aAddress, PROP_Address ) )
343 throw RuntimeException();
346 // create argument sequence
347 NamedValue aValue;
348 aValue.Name = "BoundCell";
349 aValue.Value <<= aAddress;
350 Sequence< Any > aArgs( 1 );
351 aArgs[ 0 ] <<= aValue;
353 // create the CellValueBinding instance and set at the control model
354 Reference< XMultiServiceFactory > xModelFactory( mxDocModel, UNO_QUERY_THROW );
355 Reference< XValueBinding > xBinding( xModelFactory->createInstanceWithArguments( "com.sun.star.table.CellValueBinding", aArgs ), UNO_QUERY_THROW );
356 xBindable->setValueBinding( xBinding );
358 catch (const Exception&)
360 TOOLS_WARN_EXCEPTION("oox", "");
363 // list entry source
364 if( !rRowSource.isEmpty() ) try
366 // first check if the XListEntrySink interface is supported
367 Reference< XListEntrySink > xEntrySink( rxCtrlModel, UNO_QUERY_THROW );
369 // convert address string to cell range address struct
370 CellRangeAddress aRangeAddr;
371 if( !lclExtractRangeFromName( aRangeAddr, mxDocModel, rRowSource ) )
373 lclPrepareConverter( maRangeConverter, mxDocModel, rRowSource, nRefSheet, true );
374 if( !maRangeConverter.getProperty( aRangeAddr, PROP_Address ) )
375 throw RuntimeException();
378 // create argument sequence
379 NamedValue aValue;
380 aValue.Name = "CellRange";
381 aValue.Value <<= aRangeAddr;
382 Sequence< Any > aArgs( 1 );
383 aArgs[ 0 ] <<= aValue;
385 // create the EntrySource instance and set at the control model
386 Reference< XMultiServiceFactory > xModelFactory( mxDocModel, UNO_QUERY_THROW );
387 Reference< XListEntrySource > xEntrySource( xModelFactory->createInstanceWithArguments("com.sun.star.table.CellRangeListSource", aArgs ), UNO_QUERY_THROW );
388 xEntrySink->setListEntrySource( xEntrySource );
390 catch (const Exception&)
392 TOOLS_WARN_EXCEPTION("oox", "");
396 // ActiveX (Forms 2.0) specific conversion ------------------------------------
398 void ControlConverter::convertAxBackground( PropertyMap& rPropMap,
399 sal_uInt32 nBackColor, sal_uInt32 nFlags, ApiTransparencyMode eTranspMode ) const
401 bool bOpaque = getFlag( nFlags, AX_FLAGS_OPAQUE );
402 switch( eTranspMode )
404 case ApiTransparencyMode::NotSupported:
405 // fake transparency by using system window background if needed
406 convertColor( rPropMap, PROP_BackgroundColor, bOpaque ? nBackColor : AX_SYSCOLOR_WINDOWBACK );
407 break;
408 case ApiTransparencyMode::Void:
409 // keep transparency by leaving the (void) default property value
410 if( bOpaque )
411 convertColor( rPropMap, PROP_BackgroundColor, nBackColor );
412 break;
416 void ControlConverter::convertAxBorder( PropertyMap& rPropMap,
417 sal_uInt32 nBorderColor, sal_Int32 nBorderStyle, sal_Int32 nSpecialEffect ) const
419 sal_Int16 nBorder = (nBorderStyle == AX_BORDERSTYLE_SINGLE) ? API_BORDER_FLAT :
420 ((nSpecialEffect == AX_SPECIALEFFECT_FLAT) ? API_BORDER_NONE : API_BORDER_SUNKEN);
421 rPropMap.setProperty( PROP_Border, nBorder );
422 convertColor( rPropMap, PROP_BorderColor, nBorderColor );
425 void ControlConverter::convertToAxBorder( PropertySet const & rPropSet,
426 sal_uInt32& nBorderColor, sal_Int32& nBorderStyle, sal_Int32& nSpecialEffect )
428 sal_Int16 nBorder = API_BORDER_NONE;
429 rPropSet.getProperty( nBorder, PROP_Border );
430 nBorderStyle = AX_BORDERSTYLE_NONE;
431 nSpecialEffect = AX_SPECIALEFFECT_FLAT;
432 switch ( nBorder )
434 case API_BORDER_FLAT:
435 nBorderStyle = AX_BORDERSTYLE_SINGLE;
436 break;
437 case API_BORDER_SUNKEN:
438 nSpecialEffect = AX_SPECIALEFFECT_SUNKEN;
439 break;
440 case API_BORDER_NONE:
441 default:
442 break;
444 convertToMSColor( rPropSet, PROP_BorderColor, nBorderColor );
447 void ControlConverter::convertAxVisualEffect( PropertyMap& rPropMap, sal_Int32 nSpecialEffect )
449 sal_Int16 nVisualEffect = (nSpecialEffect == AX_SPECIALEFFECT_FLAT) ? VisualEffect::FLAT : VisualEffect::LOOK3D;
450 rPropMap.setProperty( PROP_VisualEffect, nVisualEffect );
453 void ControlConverter::convertToAxVisualEffect( PropertySet const & rPropSet, sal_Int32& nSpecialEffect )
455 sal_Int16 nVisualEffect = AX_SPECIALEFFECT_FLAT;
456 rPropSet.getProperty( nVisualEffect, PROP_VisualEffect );
457 // is this appropriate AX_SPECIALEFFECT_XXXX value ?
458 if (nVisualEffect == VisualEffect::LOOK3D )
459 nSpecialEffect = AX_SPECIALEFFECT_RAISED;
462 void ControlConverter::convertAxPicture( PropertyMap& rPropMap, const StreamDataSequence& rPicData, sal_uInt32 nPicPos ) const
464 // the picture
465 convertPicture( rPropMap, rPicData );
467 // picture position
468 sal_Int16 nImagePos = ImagePosition::LeftCenter;
469 switch( nPicPos )
471 case AX_PICPOS_LEFTTOP: nImagePos = ImagePosition::LeftTop; break;
472 case AX_PICPOS_LEFTCENTER: nImagePos = ImagePosition::LeftCenter; break;
473 case AX_PICPOS_LEFTBOTTOM: nImagePos = ImagePosition::LeftBottom; break;
474 case AX_PICPOS_RIGHTTOP: nImagePos = ImagePosition::RightTop; break;
475 case AX_PICPOS_RIGHTCENTER: nImagePos = ImagePosition::RightCenter; break;
476 case AX_PICPOS_RIGHTBOTTOM: nImagePos = ImagePosition::RightBottom; break;
477 case AX_PICPOS_ABOVELEFT: nImagePos = ImagePosition::AboveLeft; break;
478 case AX_PICPOS_ABOVECENTER: nImagePos = ImagePosition::AboveCenter; break;
479 case AX_PICPOS_ABOVERIGHT: nImagePos = ImagePosition::AboveRight; break;
480 case AX_PICPOS_BELOWLEFT: nImagePos = ImagePosition::BelowLeft; break;
481 case AX_PICPOS_BELOWCENTER: nImagePos = ImagePosition::BelowCenter; break;
482 case AX_PICPOS_BELOWRIGHT: nImagePos = ImagePosition::BelowRight; break;
483 case AX_PICPOS_CENTER: nImagePos = ImagePosition::Centered; break;
484 default: OSL_FAIL( "ControlConverter::convertAxPicture - unknown picture position" );
486 rPropMap.setProperty( PROP_ImagePosition, nImagePos );
489 void ControlConverter::convertAxPicture( PropertyMap& rPropMap, const StreamDataSequence& rPicData,
490 sal_Int32 nPicSizeMode ) const
492 // the picture
493 convertPicture( rPropMap, rPicData );
495 // picture scale mode
496 sal_Int16 nScaleMode = ImageScaleMode::NONE;
497 switch( nPicSizeMode )
499 case AX_PICSIZE_CLIP: nScaleMode = ImageScaleMode::NONE; break;
500 case AX_PICSIZE_STRETCH: nScaleMode = ImageScaleMode::ANISOTROPIC; break;
501 case AX_PICSIZE_ZOOM: nScaleMode = ImageScaleMode::ISOTROPIC; break;
502 default: OSL_FAIL( "ControlConverter::convertAxPicture - unknown picture size mode" );
504 rPropMap.setProperty( PROP_ScaleMode, nScaleMode );
507 void ControlConverter::convertAxState( PropertyMap& rPropMap,
508 const OUString& rValue, sal_Int32 nMultiSelect, ApiDefaultStateMode eDefStateMode, bool bAwtModel )
510 bool bBooleanState = eDefStateMode == API_DEFAULTSTATE_BOOLEAN;
511 bool bSupportsTriState = eDefStateMode == API_DEFAULTSTATE_TRISTATE;
513 // state
514 sal_Int16 nState = bSupportsTriState ? API_STATE_DONTKNOW : API_STATE_UNCHECKED;
515 if( rValue.getLength() == 1 ) switch( rValue[ 0 ] )
517 case '0': nState = API_STATE_UNCHECKED; break;
518 case '1': nState = API_STATE_CHECKED; break;
519 // any other string (also empty) means 'dontknow'
521 sal_Int32 nPropId = bAwtModel ? PROP_State : PROP_DefaultState;
522 if( bBooleanState )
523 rPropMap.setProperty( nPropId, nState != API_STATE_UNCHECKED );
524 else
525 rPropMap.setProperty( nPropId, nState );
527 // tristate
528 if( bSupportsTriState )
529 rPropMap.setProperty( PROP_TriState, nMultiSelect == AX_SELECTION_MULTI );
532 void ControlConverter::convertToAxState( PropertySet const & rPropSet,
533 OUString& rValue, sal_Int32& nMultiSelect, ApiDefaultStateMode eDefStateMode )
535 bool bSupportsTriState = eDefStateMode == API_DEFAULTSTATE_TRISTATE;
537 sal_Int16 nState = API_STATE_DONTKNOW;
539 bool bTriStateEnabled = false;
540 // need to use State for current state ( I think this is regardless of whether
541 // control is awt or not )
542 rPropSet.getProperty( nState, PROP_State );
544 rValue.clear(); // empty e.g. 'don't know'
545 if ( nState == API_STATE_UNCHECKED )
546 rValue = "0";
547 else if ( nState == API_STATE_CHECKED )
548 rValue = "1";
550 // tristate
551 if( bSupportsTriState )
553 bool bPropertyExists = rPropSet.getProperty( bTriStateEnabled, PROP_TriState );
554 if( bPropertyExists && bTriStateEnabled )
555 nMultiSelect = AX_SELECTION_MULTI;
559 void ControlConverter::convertAxOrientation( PropertyMap& rPropMap,
560 const AxPairData& rSize, sal_Int32 nOrientation )
562 bool bHorizontal = true;
563 switch( nOrientation )
565 case AX_ORIENTATION_AUTO: bHorizontal = rSize.first > rSize.second; break;
566 case AX_ORIENTATION_VERTICAL: bHorizontal = false; break;
567 case AX_ORIENTATION_HORIZONTAL: bHorizontal = true; break;
568 default: OSL_FAIL( "ControlConverter::convertAxOrientation - unknown orientation" );
570 convertOrientation( rPropMap, bHorizontal );
573 void ControlConverter::convertToAxOrientation( PropertySet const & rPropSet,
574 sal_Int32& nOrientation )
576 bool bHorizontal = true;
577 convertToMSOrientation( rPropSet, bHorizontal );
579 if ( bHorizontal )
580 nOrientation = AX_ORIENTATION_HORIZONTAL;
581 else
582 nOrientation = AX_ORIENTATION_VERTICAL;
585 ControlModelBase::ControlModelBase() :
586 maSize( 0, 0 ),
587 mbAwtModel( false )
591 ControlModelBase::~ControlModelBase()
595 OUString ControlModelBase::getServiceName() const
597 ApiControlType eCtrlType = getControlType();
598 if( mbAwtModel ) switch( eCtrlType )
600 case API_CONTROL_BUTTON: return "com.sun.star.awt.UnoControlButtonModel";
601 case API_CONTROL_FIXEDTEXT: return "com.sun.star.awt.UnoControlFixedTextModel";
602 case API_CONTROL_IMAGE: return "com.sun.star.awt.UnoControlImageControlModel";
603 case API_CONTROL_CHECKBOX: return "com.sun.star.awt.UnoControlCheckBoxModel";
604 case API_CONTROL_RADIOBUTTON: return "com.sun.star.form.component.RadioButton";
605 case API_CONTROL_EDIT: return "com.sun.star.awt.UnoControlEditModel";
606 case API_CONTROL_NUMERIC: return "com.sun.star.awt.UnoControlNumericFieldModel";
607 case API_CONTROL_LISTBOX: return "com.sun.star.form.component.ListBox";
608 case API_CONTROL_COMBOBOX: return "com.sun.star.form.component.ComboBox";
609 case API_CONTROL_SPINBUTTON: return "com.sun.star.form.component.SpinButton";
610 case API_CONTROL_SCROLLBAR: return "com.sun.star.form.component.ScrollBar";
611 case API_CONTROL_PROGRESSBAR: return "com.sun.star.awt.UnoControlProgressBarModel";
612 case API_CONTROL_GROUPBOX: return "com.sun.star.form.component.GroupBox";
613 case API_CONTROL_FRAME: return "com.sun.star.awt.UnoFrameModel";
614 case API_CONTROL_PAGE: return "com.sun.star.awt.UnoPageModel";
615 case API_CONTROL_MULTIPAGE: return "com.sun.star.awt.UnoMultiPageModel";
616 case API_CONTROL_DIALOG: return "com.sun.star.awt.UnoControlDialogModel";
617 default: OSL_FAIL( "ControlModelBase::getServiceName - no AWT model service supported" );
619 else switch( eCtrlType )
621 case API_CONTROL_BUTTON: return "com.sun.star.form.component.CommandButton";
622 case API_CONTROL_FIXEDTEXT: return "com.sun.star.form.component.FixedText";
623 case API_CONTROL_IMAGE: return "com.sun.star.form.component.DatabaseImageControl";
624 case API_CONTROL_CHECKBOX: return "com.sun.star.form.component.CheckBox";
625 case API_CONTROL_RADIOBUTTON: return "com.sun.star.form.component.RadioButton";
626 case API_CONTROL_EDIT: return "com.sun.star.form.component.TextField";
627 case API_CONTROL_NUMERIC: return "com.sun.star.form.component.NumericField";
628 case API_CONTROL_LISTBOX: return "com.sun.star.form.component.ListBox";
629 case API_CONTROL_COMBOBOX: return "com.sun.star.form.component.ComboBox";
630 case API_CONTROL_SPINBUTTON: return "com.sun.star.form.component.SpinButton";
631 case API_CONTROL_SCROLLBAR: return "com.sun.star.form.component.ScrollBar";
632 case API_CONTROL_GROUPBOX: return "com.sun.star.form.component.GroupBox";
633 default: OSL_FAIL( "ControlModelBase::getServiceName - no form component service supported" );
635 return OUString();
638 void ControlModelBase::importProperty( sal_Int32 /*nPropId*/, const OUString& /*rValue*/ )
642 void ControlModelBase::importPictureData( sal_Int32 /*nPropId*/, BinaryInputStream& /*rInStrm*/ )
646 void ControlModelBase::convertProperties( PropertyMap& /*rPropMap*/, const ControlConverter& /*rConv*/ ) const
650 void ControlModelBase::convertFromProperties( PropertySet& /*rPropMap*/, const ControlConverter& /*rConv*/ )
654 void ControlModelBase::convertSize( PropertyMap& rPropMap, const ControlConverter& rConv ) const
656 rConv.convertSize( rPropMap, maSize );
659 ComCtlModelBase::ComCtlModelBase( sal_uInt32 nDataPartId5, sal_uInt32 nDataPartId6,
660 sal_uInt16 nVersion ) :
661 maFontData( "Tahoma", 82500 ),
662 mnFlags( 0 ),
663 mnVersion( nVersion ),
664 mnDataPartId5( nDataPartId5 ),
665 mnDataPartId6( nDataPartId6 )
669 bool ComCtlModelBase::importBinaryModel( BinaryInputStream& rInStrm )
671 // read initial size part and header of the control data part
672 if( importSizePart( rInStrm ) && readPartHeader( rInStrm, getDataPartId(), mnVersion ) )
674 // if flags part exists, the first int32 of the data part contains its size
675 sal_uInt32 nCommonPartSize = rInStrm.readuInt32();
676 // implementations must read the exact amount of data, stream must point to its end afterwards
677 importControlData( rInStrm );
678 // read following parts
679 if( !rInStrm.isEof() &&
680 importCommonPart( rInStrm, nCommonPartSize ) &&
681 importComplexPart( rInStrm ) )
683 return !rInStrm.isEof();
686 return false;
689 void ComCtlModelBase::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
691 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, COMCTL_COMMON_ENABLED ) );
692 ControlModelBase::convertProperties( rPropMap, rConv );
695 sal_uInt32 ComCtlModelBase::getDataPartId() const
697 switch( mnVersion )
699 case COMCTL_VERSION_50: return mnDataPartId5;
700 case COMCTL_VERSION_60: return mnDataPartId6;
702 OSL_FAIL( "ComCtlObjectBase::getDataPartId - unexpected version" );
703 return SAL_MAX_UINT32;
706 bool ComCtlModelBase::readPartHeader( BinaryInputStream& rInStrm, sal_uInt32 nExpPartId, sal_uInt16 nExpMajor, sal_uInt16 nExpMinor )
708 // no idea if all this is correct...
709 sal_uInt32 nPartId = rInStrm.readuInt32();
710 sal_uInt16 nMinor = rInStrm.readuInt16();
711 sal_uInt16 nMajor = rInStrm.readuInt16();
712 bool bPartId = nPartId == nExpPartId;
713 OSL_ENSURE( bPartId, "ComCtlObjectBase::readPartHeader - unexpected part identifier" );
714 bool bVersion = ((nExpMajor == SAL_MAX_UINT16) || (nExpMajor == nMajor)) && ((nExpMinor == SAL_MAX_UINT16) || (nExpMinor == nMinor));
715 OSL_ENSURE( bVersion, "ComCtlObjectBase::readPartHeader - unexpected part version" );
716 return !rInStrm.isEof() && bPartId && bVersion;
719 bool ComCtlModelBase::importSizePart( BinaryInputStream& rInStrm )
721 if( readPartHeader( rInStrm, COMCTL_ID_SIZE, 0, 8 ) )
723 maSize.first = rInStrm.readInt32();
724 maSize.second = rInStrm.readInt32();
725 return !rInStrm.isEof();
727 return false;
730 bool ComCtlModelBase::importCommonPart( BinaryInputStream& rInStrm, sal_uInt32 nPartSize )
732 sal_Int64 nEndPos = rInStrm.tell() + nPartSize;
733 if( (nPartSize >= 16) && readPartHeader( rInStrm, COMCTL_ID_COMMONDATA, 5, 0 ) )
735 rInStrm.skip( 4 );
736 mnFlags = rInStrm.readuInt32();
737 rInStrm.seek( nEndPos );
738 return !rInStrm.isEof();
740 return false;
743 bool ComCtlModelBase::importComplexPart( BinaryInputStream& rInStrm )
745 if( readPartHeader( rInStrm, COMCTL_ID_COMPLEXDATA, 5, 1 ) )
747 sal_uInt32 nContFlags = rInStrm.readuInt32();
748 bool bReadOk =
749 (!getFlag( nContFlags, COMCTL_COMPLEX_FONT ) || OleHelper::importStdFont( maFontData, rInStrm, true )) &&
750 (!getFlag( nContFlags, COMCTL_COMPLEX_MOUSEICON ) || OleHelper::importStdPic( maMouseIcon, rInStrm ));
751 return bReadOk && !rInStrm.isEof();
753 return false;
756 ComCtlScrollBarModel::ComCtlScrollBarModel( sal_uInt16 nVersion ) :
757 ComCtlModelBase( SAL_MAX_UINT32, COMCTL_ID_SCROLLBAR_60, nVersion ),
758 mnScrollBarFlags( 0x00000011 ),
759 mnLargeChange( 1 ),
760 mnSmallChange( 1 ),
761 mnMin( 0 ),
762 mnMax( 32767 ),
763 mnPosition( 0 )
767 ApiControlType ComCtlScrollBarModel::getControlType() const
769 return API_CONTROL_SCROLLBAR;
772 void ComCtlScrollBarModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
774 rPropMap.setProperty( PROP_Border, API_BORDER_NONE );
775 ControlConverter::convertOrientation( rPropMap, getFlag( mnScrollBarFlags, COMCTL_SCROLLBAR_HOR ) );
776 ControlConverter::convertScrollBar( rPropMap, mnMin, mnMax, mnPosition, mnSmallChange, mnLargeChange, mbAwtModel );
777 ComCtlModelBase::convertProperties( rPropMap, rConv );
780 void ComCtlScrollBarModel::importControlData( BinaryInputStream& rInStrm )
782 mnScrollBarFlags = rInStrm.readuInt32();
783 mnLargeChange = rInStrm.readInt32();
784 mnSmallChange = rInStrm.readInt32();
785 mnMin = rInStrm.readInt32();
786 mnMax = rInStrm.readInt32();
787 mnPosition = rInStrm.readInt32();
790 ComCtlProgressBarModel::ComCtlProgressBarModel( sal_uInt16 nVersion ) :
791 ComCtlModelBase( COMCTL_ID_PROGRESSBAR_50, COMCTL_ID_PROGRESSBAR_60, nVersion ),
792 mfMin( 0.0 ),
793 mfMax( 100.0 ),
794 mnVertical( 0 ),
795 mnSmooth( 0 )
799 ApiControlType ComCtlProgressBarModel::getControlType() const
801 return API_CONTROL_PROGRESSBAR;
804 void ComCtlProgressBarModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
806 sal_uInt16 nBorder = getFlag( mnFlags, COMCTL_COMMON_3DBORDER ) ? API_BORDER_SUNKEN :
807 (getFlag( mnFlags, COMCTL_COMMON_FLATBORDER ) ? API_BORDER_FLAT : API_BORDER_NONE);
808 rPropMap.setProperty( PROP_Border, nBorder );
809 rPropMap.setProperty( PROP_ProgressValueMin, getLimitedValue< sal_Int32, double >( ::std::min( mfMin, mfMax ), 0.0, SAL_MAX_INT32 ) );
810 rPropMap.setProperty( PROP_ProgressValueMax, getLimitedValue< sal_Int32, double >( ::std::max( mfMin, mfMax ), 0.0, SAL_MAX_INT32 ) );
811 // ComCtl model does not provide current value?
812 ComCtlModelBase::convertProperties( rPropMap, rConv );
815 void ComCtlProgressBarModel::importControlData( BinaryInputStream& rInStrm )
817 mfMin = rInStrm.readFloat();
818 mfMax = rInStrm.readFloat();
819 if( mnVersion == COMCTL_VERSION_60 )
821 mnVertical = rInStrm.readuInt16();
822 mnSmooth = rInStrm.readuInt16();
826 AxControlModelBase::AxControlModelBase()
830 void AxControlModelBase::importProperty( sal_Int32 nPropId, const OUString& rValue )
832 switch( nPropId )
834 // size of the control shape: format is "width;height"
835 case XML_Size:
837 sal_Int32 nSepPos = rValue.indexOf( ';' );
838 OSL_ENSURE( nSepPos >= 0, "AxControlModelBase::importProperty - missing separator in 'Size' property" );
839 if( nSepPos >= 0 )
841 maSize.first = rValue.copy( 0, nSepPos ).toInt32();
842 maSize.second = rValue.copy( nSepPos + 1 ).toInt32();
845 break;
849 AxFontDataModel::AxFontDataModel( bool bSupportsAlign ) :
850 mbSupportsAlign( bSupportsAlign )
854 void AxFontDataModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
856 switch( nPropId )
858 case XML_FontName: maFontData.maFontName = rValue; break;
859 case XML_FontEffects:
860 maFontData.mnFontEffects = static_cast<AxFontFlags>(AttributeConversion::decodeUnsigned( rValue ));
861 break;
862 case XML_FontHeight: maFontData.mnFontHeight = AttributeConversion::decodeInteger( rValue ); break;
863 case XML_FontCharSet: maFontData.mnFontCharSet = AttributeConversion::decodeInteger( rValue ); break;
864 case XML_ParagraphAlign:
865 maFontData.mnHorAlign = static_cast<AxHorizontalAlign>(AttributeConversion::decodeInteger( rValue ));
866 break;
867 default: AxControlModelBase::importProperty( nPropId, rValue );
871 bool AxFontDataModel::importBinaryModel( BinaryInputStream& rInStrm )
873 return maFontData.importBinaryModel( rInStrm );
876 void AxFontDataModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
878 maFontData.exportBinaryModel( rOutStrm );
880 void AxFontDataModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
882 // font name
883 if( !maFontData.maFontName.isEmpty() )
884 rPropMap.setProperty( PROP_FontName, maFontData.maFontName );
886 // font effects
887 rPropMap.setProperty( PROP_FontWeight, maFontData.mnFontEffects & AxFontFlags::Bold ? awt::FontWeight::BOLD : awt::FontWeight::NORMAL );
888 rPropMap.setProperty( PROP_FontSlant, maFontData.mnFontEffects & AxFontFlags::Italic ? FontSlant_ITALIC : FontSlant_NONE );
889 if (maFontData.mnFontEffects & AxFontFlags::Underline)
890 rPropMap.setProperty( PROP_FontUnderline, maFontData.mbDblUnderline ? awt::FontUnderline::DOUBLE : awt::FontUnderline::SINGLE );
891 else
892 rPropMap.setProperty( PROP_FontUnderline, awt::FontUnderline::NONE );
893 rPropMap.setProperty( PROP_FontStrikeout, maFontData.mnFontEffects & AxFontFlags::Strikeout ? awt::FontStrikeout::SINGLE : awt::FontStrikeout::NONE );
894 rPropMap.setProperty( PROP_FontHeight, maFontData.getHeightPoints() );
896 // font character set
897 rtl_TextEncoding eFontEnc = RTL_TEXTENCODING_DONTKNOW;
898 if( (0 <= maFontData.mnFontCharSet) && (maFontData.mnFontCharSet <= SAL_MAX_UINT8) )
899 eFontEnc = rtl_getTextEncodingFromWindowsCharset( static_cast< sal_uInt8 >( maFontData.mnFontCharSet ) );
900 if( eFontEnc != RTL_TEXTENCODING_DONTKNOW )
901 rPropMap.setProperty( PROP_FontCharset, static_cast< sal_Int16 >( eFontEnc ) );
903 // text alignment
904 if( mbSupportsAlign )
906 sal_Int32 nAlign = awt::TextAlign::LEFT;
907 switch( maFontData.mnHorAlign )
909 case AxHorizontalAlign::Left: nAlign = awt::TextAlign::LEFT; break;
910 case AxHorizontalAlign::Right: nAlign = awt::TextAlign::RIGHT; break;
911 case AxHorizontalAlign::Center: nAlign = awt::TextAlign::CENTER; break;
912 default: OSL_FAIL( "AxFontDataModel::convertProperties - unknown text alignment" );
914 // form controls expect short value
915 rPropMap.setProperty( PROP_Align, static_cast< sal_Int16 >( nAlign ) );
918 // process base class properties
919 AxControlModelBase::convertProperties( rPropMap, rConv );
922 void AxFontDataModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& /*rConv */)
924 rPropSet.getProperty( maFontData.maFontName, PROP_FontName );
925 float fontWeight = float(0);
926 if ( rPropSet.getProperty(fontWeight, PROP_FontWeight ) )
927 setFlag( maFontData.mnFontEffects, AxFontFlags::Bold, ( fontWeight == awt::FontWeight::BOLD ) );
928 FontSlant nSlant = FontSlant_NONE;
929 if ( rPropSet.getProperty( nSlant, PROP_FontSlant ) )
930 setFlag( maFontData.mnFontEffects, AxFontFlags::Italic, ( nSlant == FontSlant_ITALIC ) );
932 sal_Int16 nUnderLine = awt::FontUnderline::NONE;
933 if ( rPropSet.getProperty( nUnderLine, PROP_FontUnderline ) )
934 setFlag( maFontData.mnFontEffects, AxFontFlags::Underline, nUnderLine != awt::FontUnderline::NONE && nUnderLine != awt::FontUnderline::DONTKNOW);
935 sal_Int16 nStrikeout = awt::FontStrikeout::NONE ;
936 if ( rPropSet.getProperty( nStrikeout, PROP_FontStrikeout ) )
937 setFlag( maFontData.mnFontEffects, AxFontFlags::Strikeout, nStrikeout != awt::FontStrikeout::NONE && nStrikeout != awt::FontStrikeout::DONTKNOW);
939 float fontHeight = 0.0;
940 if ( rPropSet.getProperty( fontHeight, PROP_FontHeight ) )
942 if ( fontHeight == 0 ) // tdf#118684
944 vcl::Font aDefaultVCLFont = Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont();
945 fontHeight = static_cast< float >( aDefaultVCLFont.GetFontHeight() );
947 maFontData.setHeightPoints( static_cast< sal_Int16 >( fontHeight ) );
950 // TODO - handle textencoding
951 sal_Int16 nAlign = 0;
952 if ( rPropSet.getProperty( nAlign, PROP_Align ) )
954 switch ( nAlign )
956 case awt::TextAlign::LEFT: maFontData.mnHorAlign = AxHorizontalAlign::Left; break;
957 case awt::TextAlign::RIGHT: maFontData.mnHorAlign = AxHorizontalAlign::Right; break;
958 case awt::TextAlign::CENTER: maFontData.mnHorAlign = AxHorizontalAlign::Center; break;
959 default: OSL_FAIL( "AxFontDataModel::convertFromProperties - unknown text alignment" );
964 AxCommandButtonModel::AxCommandButtonModel() :
965 mnTextColor( AX_SYSCOLOR_BUTTONTEXT ),
966 mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
967 mnFlags( AX_CMDBUTTON_DEFFLAGS ),
968 mnPicturePos( AX_PICPOS_ABOVECENTER ),
969 mnVerticalAlign( XML_Center ),
970 mbFocusOnClick( true )
974 void AxCommandButtonModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
976 switch( nPropId )
978 case XML_Caption: maCaption = rValue; break;
979 case XML_ForeColor: mnTextColor = AttributeConversion::decodeUnsigned( rValue ); break;
980 case XML_BackColor: mnBackColor = AttributeConversion::decodeUnsigned( rValue ); break;
981 case XML_VariousPropertyBits: mnFlags = AttributeConversion::decodeUnsigned( rValue ); break;
982 case XML_PicturePosition: mnPicturePos = AttributeConversion::decodeUnsigned( rValue ); break;
983 case XML_TakeFocusOnClick: mbFocusOnClick = AttributeConversion::decodeInteger( rValue ) != 0; break;
984 default: AxFontDataModel::importProperty( nPropId, rValue );
988 void AxCommandButtonModel::importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm )
990 switch( nPropId )
992 case XML_Picture: OleHelper::importStdPic( maPictureData, rInStrm ); break;
993 default: AxFontDataModel::importPictureData( nPropId, rInStrm );
997 bool AxCommandButtonModel::importBinaryModel( BinaryInputStream& rInStrm )
999 AxBinaryPropertyReader aReader( rInStrm );
1000 aReader.readIntProperty< sal_uInt32 >( mnTextColor );
1001 aReader.readIntProperty< sal_uInt32 >( mnBackColor );
1002 aReader.readIntProperty< sal_uInt32 >( mnFlags );
1003 aReader.readStringProperty( maCaption );
1004 aReader.readIntProperty< sal_uInt32 >( mnPicturePos );
1005 aReader.readPairProperty( maSize );
1006 aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
1007 aReader.readPictureProperty( maPictureData );
1008 aReader.skipIntProperty< sal_uInt16 >(); // accelerator
1009 aReader.readBoolProperty( mbFocusOnClick, true ); // binary flag means "do not take focus"
1010 aReader.skipPictureProperty(); // mouse icon
1011 return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm );
1014 void AxCommandButtonModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
1016 AxBinaryPropertyWriter aWriter( rOutStrm );
1017 aWriter.writeIntProperty< sal_uInt32 >( mnTextColor );
1018 if ( mnBackColor )
1019 aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
1020 else
1021 aWriter.skipProperty(); // default backcolour
1022 aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
1023 aWriter.writeStringProperty( maCaption );
1024 aWriter.skipProperty(); // pict pos
1025 aWriter.writePairProperty( maSize );
1026 aWriter.skipProperty(); // mouse pointer
1027 aWriter.skipProperty(); // picture data
1028 aWriter.skipProperty(); // accelerator
1029 aWriter.writeBoolProperty( mbFocusOnClick ); // binary flag means "do not take focus"
1030 aWriter.skipProperty(); // mouse icon
1031 aWriter.finalizeExport();
1032 AxFontDataModel::exportBinaryModel( rOutStrm );
1035 void AxCommandButtonModel::exportCompObj( BinaryOutputStream& rOutStream )
1037 // should be able to replace this hardcoded foo with
1038 // proper export info from MS-OLEDS spec.
1039 static sal_uInt8 const aCompObj[] = {
1040 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1041 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x32, 0x05, 0xD7,
1042 0x69, 0xCE, 0xCD, 0x11, 0xA7, 0x77, 0x00, 0xDD,
1043 0x01, 0x14, 0x3C, 0x57, 0x22, 0x00, 0x00, 0x00,
1044 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1045 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6d, 0x73, 0x20,
1046 0x32, 0x2e, 0x30, 0x20, 0x43, 0x6F, 0x6D, 0x6D,
1047 0x61, 0x6E, 0x64, 0x42, 0x75, 0x74, 0x74, 0x6F,
1048 0x6E, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
1049 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
1050 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x16, 0x00,
1051 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
1052 0x43, 0x6F, 0x6D, 0x6D, 0x61, 0x6E, 0x64, 0x42,
1053 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00,
1054 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
1055 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1057 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1060 ApiControlType AxCommandButtonModel::getControlType() const
1062 return API_CONTROL_BUTTON;
1065 void AxCommandButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1067 rPropMap.setProperty( PROP_Label, maCaption );
1068 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
1069 rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
1070 rPropMap.setProperty( PROP_FocusOnClick, mbFocusOnClick );
1071 rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor );
1072 ControlConverter::convertVerticalAlign( rPropMap, mnVerticalAlign );
1073 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::NotSupported );
1074 rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos );
1075 AxFontDataModel::convertProperties( rPropMap, rConv );
1078 void AxCommandButtonModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1080 (void)rPropSet.getProperty(maCaption, PROP_Label);
1081 bool bRes = false;
1082 if ( rPropSet.getProperty( bRes, PROP_Enabled ) )
1083 setFlag( mnFlags, AX_FLAGS_ENABLED, bRes );
1084 if ( rPropSet.getProperty( bRes, PROP_MultiLine ) )
1085 setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
1086 (void)rPropSet.getProperty(mbFocusOnClick, PROP_FocusOnClick);
1088 ControlConverter::convertToMSColor( rPropSet, PROP_TextColor, mnTextColor );
1089 ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1091 AxFontDataModel::convertFromProperties( rPropSet, rConv );
1094 AxLabelModel::AxLabelModel() :
1095 mnTextColor( AX_SYSCOLOR_BUTTONTEXT ),
1096 mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
1097 mnFlags( AX_LABEL_DEFFLAGS ),
1098 mnBorderColor( AX_SYSCOLOR_WINDOWFRAME ),
1099 mnBorderStyle( AX_BORDERSTYLE_NONE ),
1100 mnSpecialEffect( AX_SPECIALEFFECT_FLAT ),
1101 mnVerticalAlign( XML_Top )
1105 void AxLabelModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
1107 switch( nPropId )
1109 case XML_Caption: maCaption = rValue; break;
1110 case XML_ForeColor: mnTextColor = AttributeConversion::decodeUnsigned( rValue ); break;
1111 case XML_BackColor: mnBackColor = AttributeConversion::decodeUnsigned( rValue ); break;
1112 case XML_VariousPropertyBits: mnFlags = AttributeConversion::decodeUnsigned( rValue ); break;
1113 case XML_BorderColor: mnBorderColor = AttributeConversion::decodeUnsigned( rValue ); break;
1114 case XML_BorderStyle: mnBorderStyle = AttributeConversion::decodeInteger( rValue ); break;
1115 case XML_SpecialEffect: mnSpecialEffect = AttributeConversion::decodeInteger( rValue ); break;
1116 default: AxFontDataModel::importProperty( nPropId, rValue );
1120 bool AxLabelModel::importBinaryModel( BinaryInputStream& rInStrm )
1122 AxBinaryPropertyReader aReader( rInStrm );
1123 aReader.readIntProperty< sal_uInt32 >( mnTextColor );
1124 aReader.readIntProperty< sal_uInt32 >( mnBackColor );
1125 aReader.readIntProperty< sal_uInt32 >( mnFlags );
1126 aReader.readStringProperty( maCaption );
1127 aReader.skipIntProperty< sal_uInt32 >(); // picture position
1128 aReader.readPairProperty( maSize );
1129 aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
1130 aReader.readIntProperty< sal_uInt32 >( mnBorderColor );
1131 aReader.readIntProperty< sal_uInt16 >( mnBorderStyle );
1132 aReader.readIntProperty< sal_uInt16 >( mnSpecialEffect );
1133 aReader.skipPictureProperty(); // picture
1134 aReader.skipIntProperty< sal_uInt16 >(); // accelerator
1135 aReader.skipPictureProperty(); // mouse icon
1136 return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm );
1139 void AxLabelModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
1141 AxBinaryPropertyWriter aWriter( rOutStrm );
1142 aWriter.writeIntProperty< sal_uInt32 >( mnTextColor );
1143 if ( mnBackColor )
1144 aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
1145 else
1146 // if mnBackColor == 0 then it's the libreoffice default backcolour is
1147 // the MSO Label default which is AX_SYSCOLOR_BUTTONFACE
1148 aWriter.writeIntProperty< sal_uInt32 >( AX_SYSCOLOR_WINDOWBACK );
1149 aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
1150 aWriter.writeStringProperty( maCaption );
1151 aWriter.skipProperty(); // picture position
1152 aWriter.writePairProperty( maSize );
1153 aWriter.skipProperty(); // mouse pointer
1154 aWriter.writeIntProperty< sal_uInt32 >( mnBorderColor );
1155 aWriter.writeIntProperty< sal_uInt16 >( mnBorderStyle );
1156 aWriter.writeIntProperty< sal_uInt16 >( mnSpecialEffect );
1157 aWriter.skipProperty(); // picture
1158 aWriter.skipProperty(); // accelerator
1159 aWriter.skipProperty(); // mouse icon
1160 aWriter.finalizeExport();
1161 AxFontDataModel::exportBinaryModel( rOutStrm );
1164 void AxLabelModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1166 rPropSet.getProperty( maCaption, PROP_Label );
1167 bool bRes = false;
1168 if ( rPropSet.getProperty( bRes, PROP_Enabled ) )
1169 setFlag( mnFlags, AX_FLAGS_ENABLED, bRes );
1170 if ( rPropSet.getProperty( bRes, PROP_MultiLine ) )
1171 setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
1173 ControlConverter::convertToMSColor( rPropSet, PROP_TextColor, mnTextColor );
1174 // VerticalAlign doesn't seem to be read from binary
1176 // not sure about background color, how do we decide when to set
1177 // AX_FLAGS_OPAQUE ?
1178 ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1179 ControlConverter::convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1181 AxFontDataModel::convertFromProperties( rPropSet, rConv );
1184 void AxLabelModel::exportCompObj( BinaryOutputStream& rOutStream )
1186 // should be able to replace this hardcoded foo with
1187 // proper export info from MS-OLEDS spec.
1188 static sal_uInt8 const aCompObj[] = {
1189 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1190 0xFF, 0xFF, 0xFF, 0xFF, 0x23, 0x9E, 0x8C, 0x97,
1191 0xB0, 0xD4, 0xCE, 0x11, 0xBF, 0x2D, 0x00, 0xAA,
1192 0x00, 0x3F, 0x40, 0xD0, 0x1A, 0x00, 0x00, 0x00,
1193 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1194 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1195 0x32, 0x2E, 0x30, 0x20, 0x4C, 0x61, 0x62, 0x65,
1196 0x6C, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
1197 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
1198 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x0E, 0x00,
1199 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
1200 0x4C, 0x61, 0x62, 0x65, 0x6C, 0x2E, 0x31, 0x00,
1201 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
1202 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1204 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1207 ApiControlType AxLabelModel::getControlType() const
1209 return API_CONTROL_FIXEDTEXT;
1212 void AxLabelModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1214 rPropMap.setProperty( PROP_Label, maCaption );
1215 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
1216 rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
1217 rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor );
1218 ControlConverter::convertVerticalAlign( rPropMap, mnVerticalAlign );
1219 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::Void );
1220 rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1221 AxFontDataModel::convertProperties( rPropMap, rConv );
1224 AxImageModel::AxImageModel() :
1225 mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
1226 mnFlags( AX_IMAGE_DEFFLAGS ),
1227 mnBorderColor( AX_SYSCOLOR_WINDOWFRAME ),
1228 mnBorderStyle( AX_BORDERSTYLE_SINGLE ),
1229 mnSpecialEffect( AX_SPECIALEFFECT_FLAT ),
1230 mnPicSizeMode( AX_PICSIZE_CLIP ),
1231 mnPicAlign( AX_PICALIGN_CENTER ),
1232 mbPicTiling( false )
1236 void AxImageModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
1238 switch( nPropId )
1240 case XML_BackColor: mnBackColor = AttributeConversion::decodeUnsigned( rValue ); break;
1241 case XML_VariousPropertyBits: mnFlags = AttributeConversion::decodeUnsigned( rValue ); break;
1242 case XML_BorderColor: mnBorderColor = AttributeConversion::decodeUnsigned( rValue ); break;
1243 case XML_BorderStyle: mnBorderStyle = AttributeConversion::decodeInteger( rValue ); break;
1244 case XML_SpecialEffect: mnSpecialEffect = AttributeConversion::decodeInteger( rValue ); break;
1245 case XML_SizeMode: mnPicSizeMode = AttributeConversion::decodeInteger( rValue ); break;
1246 case XML_PictureAlignment: mnPicAlign = AttributeConversion::decodeInteger( rValue ); break;
1247 case XML_PictureTiling: mbPicTiling = AttributeConversion::decodeInteger( rValue ) != 0; break;
1248 default: AxControlModelBase::importProperty( nPropId, rValue );
1252 void AxImageModel::importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm )
1254 switch( nPropId )
1256 case XML_Picture: OleHelper::importStdPic( maPictureData, rInStrm ); break;
1257 default: AxControlModelBase::importPictureData( nPropId, rInStrm );
1261 bool AxImageModel::importBinaryModel( BinaryInputStream& rInStrm )
1263 AxBinaryPropertyReader aReader( rInStrm );
1264 aReader.skipUndefinedProperty();
1265 aReader.skipUndefinedProperty();
1266 aReader.skipBoolProperty(); // auto-size
1267 aReader.readIntProperty< sal_uInt32 >( mnBorderColor );
1268 aReader.readIntProperty< sal_uInt32 >( mnBackColor );
1269 aReader.readIntProperty< sal_uInt8 >( mnBorderStyle );
1270 aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
1271 aReader.readIntProperty< sal_uInt8 >( mnPicSizeMode );
1272 aReader.readIntProperty< sal_uInt8 >( mnSpecialEffect );
1273 aReader.readPairProperty( maSize );
1274 aReader.readPictureProperty( maPictureData );
1275 aReader.readIntProperty< sal_uInt8 >( mnPicAlign );
1276 aReader.readBoolProperty( mbPicTiling );
1277 aReader.readIntProperty< sal_uInt32 >( mnFlags );
1278 aReader.skipPictureProperty(); // mouse icon
1279 return aReader.finalizeImport();
1282 void AxImageModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
1284 AxBinaryPropertyWriter aWriter( rOutStrm );
1285 aWriter.skipProperty(); //undefined
1286 aWriter.skipProperty(); //undefined
1287 aWriter.skipProperty(); //auto-size
1288 aWriter.writeIntProperty< sal_uInt32 >( mnBorderColor );
1289 if ( mnBackColor )
1290 aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
1291 else
1292 aWriter.skipProperty(); // default backcolour
1293 aWriter.writeIntProperty< sal_uInt8 >( mnBorderStyle );
1294 aWriter.skipProperty(); // mouse pointer
1295 aWriter.writeIntProperty< sal_uInt8 >( mnPicSizeMode );
1296 aWriter.writeIntProperty< sal_uInt8 >( mnSpecialEffect );
1297 aWriter.writePairProperty( maSize );
1298 aWriter.skipProperty(); //maPictureData );
1299 aWriter.writeIntProperty< sal_uInt8 >( mnPicAlign );
1300 aWriter.writeBoolProperty( mbPicTiling );
1301 aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
1302 aWriter.skipProperty(); // mouse icon
1303 aWriter.finalizeExport();
1306 void AxImageModel::exportCompObj( BinaryOutputStream& rOutStream )
1308 // should be able to replace this hardcoded foo with
1309 // proper export info from MS-OLEDS spec.
1310 static sal_uInt8 const aCompObj[] = {
1311 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1312 0xFF, 0xFF, 0xFF, 0xFF, 0x41, 0x92, 0x59, 0x4C,
1313 0x26, 0x69, 0x1B, 0x10, 0x99, 0x92, 0x00, 0x00,
1314 0x0B, 0x65, 0xC6, 0xF9, 0x1A, 0x00, 0x00, 0x00,
1315 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1316 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1317 0x32, 0x2E, 0x30, 0x20, 0x49, 0x6D, 0x61, 0x67,
1318 0x65, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
1319 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
1320 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x0E, 0x00,
1321 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
1322 0x49, 0x6D, 0x61, 0x67, 0x65, 0x2E, 0x31, 0x00,
1323 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
1324 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1326 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1329 ApiControlType AxImageModel::getControlType() const
1331 return API_CONTROL_IMAGE;
1334 void AxImageModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1336 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
1337 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::Void );
1338 rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1339 rConv.convertAxPicture( rPropMap, maPictureData, mnPicSizeMode );
1340 AxControlModelBase::convertProperties( rPropMap, rConv );
1343 AxTabStripModel::AxTabStripModel() :
1344 mnListIndex( 0 ),
1345 mnTabStyle( 0 ),
1346 mnTabData( 0 ),
1347 mnVariousPropertyBits( 0 )
1351 bool AxTabStripModel::importBinaryModel( BinaryInputStream& rInStrm )
1353 // not worth reading much here, basically we are interested
1354 // in whether we have tabs, the width, the height and the
1355 // captions, everything else we can pretty much discard ( for now )
1356 AxBinaryPropertyReader aReader( rInStrm );
1357 aReader.readIntProperty< sal_uInt32 >( mnListIndex ); // ListIndex
1358 aReader.skipIntProperty< sal_uInt32 >(); // Backcolor
1359 aReader.skipIntProperty< sal_uInt32 >(); // ForeColor
1360 aReader.skipUndefinedProperty();
1361 aReader.readPairProperty( maSize );
1362 aReader.readArrayStringProperty( maItems );
1363 aReader.skipIntProperty< sal_uInt8 >(); // MousePointer
1364 aReader.skipUndefinedProperty();
1365 aReader.skipIntProperty< sal_uInt32 >(); // TabOrientation
1366 aReader.readIntProperty< sal_uInt32 >(mnTabStyle); // TabStyle
1367 aReader.skipBoolProperty(); // MultiRow
1368 aReader.skipIntProperty< sal_uInt32 >(); // TabFixedWidth
1369 aReader.skipIntProperty< sal_uInt32 >(); // TabFixedHeight
1370 aReader.skipBoolProperty(); // ToolTips
1371 aReader.skipUndefinedProperty();
1372 aReader.skipArrayStringProperty(); // ToolTip strings
1373 aReader.skipUndefinedProperty();
1374 aReader.readArrayStringProperty( maTabNames ); // Tab names
1375 aReader.readIntProperty< sal_uInt32 >(mnVariousPropertyBits); // VariousPropertyBits
1376 aReader.skipBoolProperty();// NewVersion
1377 aReader.skipIntProperty< sal_uInt32 >(); // TabsAllocated
1378 aReader.skipArrayStringProperty(); // Tags
1379 aReader.readIntProperty<sal_uInt32 >(mnTabData); // TabData
1380 aReader.skipArrayStringProperty(); // Accelerators
1381 aReader.skipPictureProperty(); // Mouse Icon
1382 return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm );
1385 ApiControlType AxTabStripModel::getControlType() const
1387 return API_CONTROL_TABSTRIP;
1390 AxMorphDataModelBase::AxMorphDataModelBase() :
1391 mnTextColor( AX_SYSCOLOR_WINDOWTEXT ),
1392 mnBackColor( AX_SYSCOLOR_WINDOWBACK ),
1393 mnFlags( AX_MORPHDATA_DEFFLAGS ),
1394 mnPicturePos( AX_PICPOS_ABOVECENTER ),
1395 mnBorderColor( AX_SYSCOLOR_WINDOWFRAME ),
1396 mnBorderStyle( AX_BORDERSTYLE_NONE ),
1397 mnSpecialEffect( AX_SPECIALEFFECT_SUNKEN ),
1398 mnDisplayStyle( AX_DISPLAYSTYLE_TEXT ),
1399 mnMultiSelect( AX_SELECTION_SINGLE ),
1400 mnScrollBars( AX_SCROLLBAR_NONE ),
1401 mnMatchEntry( AX_MATCHENTRY_NONE ),
1402 mnShowDropButton( AX_SHOWDROPBUTTON_NEVER ),
1403 mnMaxLength( 0 ),
1404 mnPasswordChar( 0 ),
1405 mnListRows( 8 ),
1406 mnVerticalAlign( XML_Center )
1410 void AxMorphDataModelBase::importProperty( sal_Int32 nPropId, const OUString& rValue )
1412 switch( nPropId )
1414 case XML_Caption: maCaption = rValue; break;
1415 case XML_Value: maValue = rValue; break;
1416 case XML_GroupName: maGroupName = rValue; break;
1417 case XML_ForeColor: mnTextColor = AttributeConversion::decodeUnsigned( rValue ); break;
1418 case XML_BackColor: mnBackColor = AttributeConversion::decodeUnsigned( rValue ); break;
1419 case XML_VariousPropertyBits: mnFlags = AttributeConversion::decodeUnsigned( rValue ); break;
1420 case XML_PicturePosition: mnPicturePos = AttributeConversion::decodeUnsigned( rValue ); break;
1421 case XML_BorderColor: mnBorderColor = AttributeConversion::decodeUnsigned( rValue ); break;
1422 case XML_BorderStyle: mnBorderStyle = AttributeConversion::decodeInteger( rValue ); break;
1423 case XML_SpecialEffect: mnSpecialEffect = AttributeConversion::decodeInteger( rValue ); break;
1424 case XML_DisplayStyle: mnDisplayStyle = AttributeConversion::decodeInteger( rValue ); break;
1425 case XML_MultiSelect: mnMultiSelect = AttributeConversion::decodeInteger( rValue ); break;
1426 case XML_ScrollBars: mnScrollBars = AttributeConversion::decodeInteger( rValue ); break;
1427 case XML_MatchEntry: mnMatchEntry = AttributeConversion::decodeInteger( rValue ); break;
1428 case XML_ShowDropButtonWhen: mnShowDropButton = AttributeConversion::decodeInteger( rValue );break;
1429 case XML_MaxLength: mnMaxLength = AttributeConversion::decodeInteger( rValue ); break;
1430 case XML_PasswordChar: mnPasswordChar = AttributeConversion::decodeInteger( rValue ); break;
1431 case XML_ListRows: mnListRows = AttributeConversion::decodeInteger( rValue ); break;
1432 default: AxFontDataModel::importProperty( nPropId, rValue );
1436 void AxMorphDataModelBase::importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm )
1438 switch( nPropId )
1440 case XML_Picture: OleHelper::importStdPic( maPictureData, rInStrm ); break;
1441 default: AxFontDataModel::importPictureData( nPropId, rInStrm );
1445 bool AxMorphDataModelBase::importBinaryModel( BinaryInputStream& rInStrm )
1447 AxBinaryPropertyReader aReader( rInStrm, true );
1448 aReader.readIntProperty< sal_uInt32 >( mnFlags );
1449 aReader.readIntProperty< sal_uInt32 >( mnBackColor );
1450 aReader.readIntProperty< sal_uInt32 >( mnTextColor );
1451 aReader.readIntProperty< sal_Int32 >( mnMaxLength );
1452 aReader.readIntProperty< sal_uInt8 >( mnBorderStyle );
1453 aReader.readIntProperty< sal_uInt8 >( mnScrollBars );
1454 aReader.readIntProperty< sal_uInt8 >( mnDisplayStyle );
1455 aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
1456 aReader.readPairProperty( maSize );
1457 aReader.readIntProperty< sal_uInt16 >( mnPasswordChar );
1458 aReader.skipIntProperty< sal_uInt32 >(); // list width
1459 aReader.skipIntProperty< sal_uInt16 >(); // bound column
1460 aReader.skipIntProperty< sal_Int16 >(); // text column
1461 aReader.skipIntProperty< sal_Int16 >(); // column count
1462 aReader.readIntProperty< sal_uInt16 >( mnListRows );
1463 aReader.skipIntProperty< sal_uInt16 >(); // column info count
1464 aReader.readIntProperty< sal_uInt8 >( mnMatchEntry );
1465 aReader.skipIntProperty< sal_uInt8 >(); // list style
1466 aReader.readIntProperty< sal_uInt8 >( mnShowDropButton );
1467 aReader.skipUndefinedProperty();
1468 aReader.skipIntProperty< sal_uInt8 >(); // drop down style
1469 aReader.readIntProperty< sal_uInt8 >( mnMultiSelect );
1470 aReader.readStringProperty( maValue );
1471 aReader.readStringProperty( maCaption );
1472 aReader.readIntProperty< sal_uInt32 >( mnPicturePos );
1473 aReader.readIntProperty< sal_uInt32 >( mnBorderColor );
1474 aReader.readIntProperty< sal_uInt32 >( mnSpecialEffect );
1475 aReader.skipPictureProperty(); // mouse icon
1476 aReader.readPictureProperty( maPictureData );
1477 aReader.skipIntProperty< sal_uInt16 >(); // accelerator
1478 aReader.skipUndefinedProperty();
1479 aReader.skipBoolProperty();
1480 aReader.readStringProperty( maGroupName );
1481 return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm );
1484 void AxMorphDataModelBase::exportBinaryModel( BinaryOutputStream& rOutStrm )
1486 AxBinaryPropertyWriter aWriter( rOutStrm, true );
1487 if ( mnFlags != AX_MORPHDATA_DEFFLAGS )
1488 aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
1489 else
1490 aWriter.skipProperty(); //mnFlags
1491 if ( mnBackColor )
1492 aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
1493 else
1494 aWriter.skipProperty(); // default backcolour
1495 aWriter.writeIntProperty< sal_uInt32 >( mnTextColor );
1497 // only write if different from default
1498 if ( ( ( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT ) || ( mnDisplayStyle == AX_DISPLAYSTYLE_COMBOBOX ) ) && mnMaxLength != 0 )
1499 aWriter.writeIntProperty< sal_Int32 >( mnMaxLength );
1500 else
1501 aWriter.skipProperty(); //mnMaxLength
1502 if ( ( ( mnDisplayStyle == AX_DISPLAYSTYLE_COMBOBOX ) || ( mnDisplayStyle == AX_DISPLAYSTYLE_LISTBOX ) || ( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT ) ) && mnBorderStyle != AX_BORDERSTYLE_NONE )
1503 aWriter.writeIntProperty< sal_uInt8 >( mnBorderStyle );
1504 else
1505 aWriter.skipProperty(); //mnBorderStyle
1507 if ( ( mnDisplayStyle == AX_DISPLAYSTYLE_LISTBOX || mnDisplayStyle == AX_DISPLAYSTYLE_TEXT ) && mnScrollBars != AX_SCROLLBAR_NONE )
1508 aWriter.writeIntProperty< sal_uInt8 >( mnScrollBars );
1509 else
1510 aWriter.skipProperty(); //mnScrollBars
1511 aWriter.writeIntProperty< sal_uInt8 >( mnDisplayStyle );
1512 aWriter.skipProperty(); // mouse pointer
1513 aWriter.writePairProperty( maSize );
1514 if ( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT )
1515 aWriter.writeIntProperty< sal_uInt16 >( mnPasswordChar );
1516 else
1517 aWriter.skipProperty(); // mnPasswordChar
1518 aWriter.skipProperty(); // list width
1519 aWriter.skipProperty(); // bound column
1520 aWriter.skipProperty(); // text column
1521 aWriter.skipProperty(); // column count
1522 aWriter.skipProperty(); // mnListRows
1523 aWriter.skipProperty(); // column info count
1524 aWriter.skipProperty(); // mnMatchEntry
1525 aWriter.skipProperty(); // list style
1526 aWriter.skipProperty(); // mnShowDropButton );
1527 aWriter.skipProperty();
1528 aWriter.skipProperty(); // drop down style
1529 if ( (mnDisplayStyle == AX_DISPLAYSTYLE_LISTBOX || mnDisplayStyle == AX_DISPLAYSTYLE_CHECKBOX) && mnMultiSelect != AX_SELECTION_SINGLE )
1530 aWriter.writeIntProperty< sal_uInt8 >( mnMultiSelect );
1531 // although CheckBox, ListBox, OptionButton, ToggleButton are also supported
1532 // they can only have the fileformat default
1533 else
1534 aWriter.skipProperty(); //mnMultiSelect
1535 aWriter.writeStringProperty( maValue );
1537 if ( ( mnDisplayStyle == AX_DISPLAYSTYLE_CHECKBOX ) || ( mnDisplayStyle == AX_DISPLAYSTYLE_OPTBUTTON ) || ( mnDisplayStyle == AX_DISPLAYSTYLE_TOGGLE ) )
1538 aWriter.writeStringProperty( maCaption );
1539 else
1540 aWriter.skipProperty(); // mnCaption
1541 aWriter.skipProperty(); // mnPicturePos );
1542 if ( ( mnDisplayStyle == AX_DISPLAYSTYLE_COMBOBOX || mnDisplayStyle == AX_DISPLAYSTYLE_LISTBOX || mnDisplayStyle == AX_DISPLAYSTYLE_TEXT ) && mnBorderColor != AX_SYSCOLOR_WINDOWFRAME )
1543 aWriter.writeIntProperty< sal_uInt32 >( mnBorderColor );
1544 else
1545 aWriter.skipProperty(); // mnBorderColor
1546 if ( mnSpecialEffect != AX_SPECIALEFFECT_SUNKEN )
1547 aWriter.writeIntProperty< sal_uInt32 >( mnSpecialEffect );
1548 else
1549 aWriter.skipProperty(); //mnSpecialEffect
1550 aWriter.skipProperty(); // mouse icon
1551 aWriter.skipProperty(); // maPictureData
1552 aWriter.skipProperty(); // accelerator
1553 aWriter.skipProperty(); // undefined
1554 aWriter.writeBoolProperty(true); // must be 1 for morph
1555 if ( mnDisplayStyle == AX_DISPLAYSTYLE_OPTBUTTON )
1556 aWriter.writeStringProperty( maGroupName );
1557 else
1558 aWriter.skipProperty(); //maGroupName
1559 aWriter.finalizeExport();
1560 AxFontDataModel::exportBinaryModel( rOutStrm );
1563 void AxMorphDataModelBase::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1565 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
1566 rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor );
1567 if ( mnDisplayStyle == AX_DISPLAYSTYLE_OPTBUTTON )
1569 // If unspecified, radio buttons autoGroup in the same document/sheet
1570 // NOTE: form controls should not autoGroup with ActiveX controls - see drawingfragment.cxx
1571 OUString sGroupName = !maGroupName.isEmpty() ? maGroupName : "autoGroup_";
1572 rPropMap.setProperty( PROP_GroupName, sGroupName );
1574 AxFontDataModel::convertProperties( rPropMap, rConv );
1577 void AxMorphDataModelBase::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1579 if ( mnDisplayStyle == AX_DISPLAYSTYLE_OPTBUTTON )
1580 rPropSet.getProperty( maGroupName, PROP_GroupName );
1581 AxFontDataModel::convertFromProperties( rPropSet, rConv );
1584 AxToggleButtonModel::AxToggleButtonModel()
1586 mnDisplayStyle = AX_DISPLAYSTYLE_TOGGLE;
1589 ApiControlType AxToggleButtonModel::getControlType() const
1591 OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_TOGGLE, "AxToggleButtonModel::getControlType - invalid control type" );
1592 return API_CONTROL_BUTTON;
1595 void AxToggleButtonModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1597 rPropSet.getProperty( maCaption, PROP_Label );
1599 bool bRes = false;
1600 if ( rPropSet.getProperty( bRes, PROP_MultiLine ) )
1601 setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
1603 ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1604 ControlConverter::convertToMSColor( rPropSet, PROP_TextColor, mnTextColor );
1605 // need to process the image if one exists
1606 ControlConverter::convertToAxState( rPropSet, maValue, mnMultiSelect, API_DEFAULTSTATE_BOOLEAN );
1607 AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
1610 void AxToggleButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1612 rPropMap.setProperty( PROP_Label, maCaption );
1613 rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
1614 rPropMap.setProperty( PROP_Toggle, true );
1615 ControlConverter::convertVerticalAlign( rPropMap, mnVerticalAlign );
1616 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::NotSupported );
1617 rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos );
1618 ControlConverter::convertAxState( rPropMap, maValue, mnMultiSelect, API_DEFAULTSTATE_BOOLEAN, mbAwtModel );
1619 AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1622 void AxToggleButtonModel::exportCompObj( BinaryOutputStream& rOutStream )
1624 // should be able to replace this hardcoded foo with
1625 // proper export info from MS-OLEDS spec.
1626 static sal_uInt8 const aCompObj[] = {
1627 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1628 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0x1D, 0xD2, 0x8B,
1629 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1630 0x00, 0x60, 0x02, 0xF3, 0x21, 0x00, 0x00, 0x00,
1631 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1632 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1633 0x32, 0x2E, 0x30, 0x20, 0x54, 0x6F, 0x67, 0x67,
1634 0x6C, 0x65, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E,
1635 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62,
1636 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62,
1637 0x6A, 0x65, 0x63, 0x74, 0x00, 0x15, 0x00, 0x00,
1638 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x54,
1639 0x6F, 0x67, 0x67, 0x6C, 0x65, 0x42, 0x75, 0x74,
1640 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00, 0xF4, 0x39,
1641 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1642 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1644 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1647 AxCheckBoxModel::AxCheckBoxModel()
1649 mnDisplayStyle = AX_DISPLAYSTYLE_CHECKBOX;
1652 ApiControlType AxCheckBoxModel::getControlType() const
1654 OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_CHECKBOX, "AxCheckBoxModel::getControlType - invalid control type" );
1655 return API_CONTROL_CHECKBOX;
1658 void AxCheckBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1660 rPropMap.setProperty( PROP_Label, maCaption );
1661 rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
1662 ControlConverter::convertVerticalAlign( rPropMap, mnVerticalAlign );
1663 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::Void );
1664 ControlConverter::convertAxVisualEffect( rPropMap, mnSpecialEffect );
1665 rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos );
1666 ControlConverter::convertAxState( rPropMap, maValue, mnMultiSelect, API_DEFAULTSTATE_TRISTATE, mbAwtModel );
1667 AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1670 void AxCheckBoxModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1672 rPropSet.getProperty( maCaption, PROP_Label );
1674 bool bRes = false;
1675 if ( rPropSet.getProperty( bRes, PROP_MultiLine ) )
1676 setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
1678 ControlConverter::convertToAxVisualEffect( rPropSet, mnSpecialEffect );
1679 ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1680 ControlConverter::convertToMSColor( rPropSet, PROP_TextColor, mnTextColor );
1681 // need to process the image if one exists
1682 ControlConverter::convertToAxState( rPropSet, maValue, mnMultiSelect, API_DEFAULTSTATE_TRISTATE );
1683 AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
1686 void AxCheckBoxModel::exportCompObj( BinaryOutputStream& rOutStream )
1688 // should be able to replace this hardcoded foo with
1689 // proper export info from MS-OLEDS spec.
1690 static sal_uInt8 const aCompObj[] = {
1691 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1692 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x1D, 0xD2, 0x8B,
1693 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1694 0x00, 0x60, 0x02, 0xF3, 0x1D, 0x00, 0x00, 0x00,
1695 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1696 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1697 0x32, 0x2E, 0x30, 0x20, 0x43, 0x68, 0x65, 0x63,
1698 0x6B, 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00,
1699 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65,
1700 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74,
1701 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72,
1702 0x6D, 0x73, 0x2E, 0x43, 0x68, 0x65, 0x63, 0x6B,
1703 0x42, 0x6F, 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39,
1704 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1705 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1707 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1710 AxOptionButtonModel::AxOptionButtonModel()
1712 mnDisplayStyle = AX_DISPLAYSTYLE_OPTBUTTON;
1715 ApiControlType AxOptionButtonModel::getControlType() const
1717 OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_OPTBUTTON, "AxOptionButtonModel::getControlType - invalid control type" );
1718 return API_CONTROL_RADIOBUTTON;
1721 void AxOptionButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1723 rPropMap.setProperty( PROP_Label, maCaption );
1724 rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
1725 ControlConverter::convertVerticalAlign( rPropMap, mnVerticalAlign );
1726 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::Void );
1727 ControlConverter::convertAxVisualEffect( rPropMap, mnSpecialEffect );
1728 rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos );
1729 ControlConverter::convertAxState( rPropMap, maValue, mnMultiSelect, API_DEFAULTSTATE_SHORT, mbAwtModel );
1730 AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1733 void AxOptionButtonModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1735 rPropSet.getProperty( maCaption, PROP_Label );
1737 bool bRes = false;
1738 if ( rPropSet.getProperty( bRes, PROP_MultiLine ) )
1739 setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
1741 ControlConverter::convertToAxVisualEffect( rPropSet, mnSpecialEffect );
1742 ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1743 ControlConverter::convertToMSColor( rPropSet, PROP_TextColor, mnTextColor );
1744 // need to process the image if one exists
1745 ControlConverter::convertToAxState( rPropSet, maValue, mnMultiSelect, API_DEFAULTSTATE_BOOLEAN );
1746 AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
1749 void AxOptionButtonModel::exportCompObj( BinaryOutputStream& rOutStream )
1751 // should be able to replace this hardcoded foo with
1752 // proper export info from MS-OLEDS spec.
1753 static sal_uInt8 const aCompObj[] = {
1754 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1755 0xFF, 0xFF, 0xFF, 0xFF, 0x50, 0x1D, 0xD2, 0x8B,
1756 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1757 0x00, 0x60, 0x02, 0xF3, 0x21, 0x00, 0x00, 0x00,
1758 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1759 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1760 0x32, 0x2E, 0x30, 0x20, 0x4F, 0x70, 0x74, 0x69,
1761 0x6F, 0x6E, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E,
1762 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62,
1763 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62,
1764 0x6A, 0x65, 0x63, 0x74, 0x00, 0x15, 0x00, 0x00,
1765 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x4F,
1766 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x42, 0x75, 0x74,
1767 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00, 0xF4, 0x39,
1768 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1769 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1771 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1774 AxTextBoxModel::AxTextBoxModel()
1776 mnDisplayStyle = AX_DISPLAYSTYLE_TEXT;
1779 ApiControlType AxTextBoxModel::getControlType() const
1781 OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT, "AxTextBoxModel::getControlType - invalid control type" );
1782 return API_CONTROL_EDIT;
1785 void AxTextBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1787 if (getFlag( mnFlags, AX_FLAGS_MULTILINE ) && getFlag( mnFlags, AX_FLAGS_WORDWRAP ))
1788 rPropMap.setProperty( PROP_MultiLine, true );
1789 else
1790 rPropMap.setProperty( PROP_MultiLine, false );
1791 rPropMap.setProperty( PROP_HideInactiveSelection, getFlag( mnFlags, AX_FLAGS_HIDESELECTION ) );
1792 rPropMap.setProperty( PROP_ReadOnly, getFlag( mnFlags, AX_FLAGS_LOCKED ) );
1793 rPropMap.setProperty( mbAwtModel ? PROP_Text : PROP_DefaultText, maValue );
1794 rPropMap.setProperty( PROP_MaxTextLen, getLimitedValue< sal_Int16, sal_Int32 >( mnMaxLength, 0, SAL_MAX_INT16 ) );
1795 if( (0 < mnPasswordChar) && (mnPasswordChar <= SAL_MAX_INT16) )
1796 rPropMap.setProperty( PROP_EchoChar, static_cast< sal_Int16 >( mnPasswordChar ) );
1797 rPropMap.setProperty( PROP_HScroll, getFlag( mnScrollBars, AX_SCROLLBAR_HORIZONTAL ) );
1798 rPropMap.setProperty( PROP_VScroll, getFlag( mnScrollBars, AX_SCROLLBAR_VERTICAL ) );
1799 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::Void );
1800 rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1801 AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1804 void AxTextBoxModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1806 bool bRes = false;
1807 if ( rPropSet.getProperty( bRes, PROP_MultiLine ) ) {
1808 setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
1809 setFlag( mnFlags, AX_FLAGS_MULTILINE, bRes );
1811 if ( rPropSet.getProperty( bRes, PROP_HideInactiveSelection ) )
1812 setFlag( mnFlags, AX_FLAGS_HIDESELECTION, bRes );
1813 if ( rPropSet.getProperty( bRes, PROP_ReadOnly ) )
1814 setFlag( mnFlags, AX_FLAGS_LOCKED, bRes );
1815 rPropSet.getProperty( maValue, ( mbAwtModel ? PROP_Text : PROP_DefaultText ) );
1816 if (maValue.isEmpty() && !mbAwtModel)
1817 // No default value? Then try exporting the current one.
1818 rPropSet.getProperty( maValue, PROP_Text);
1819 sal_Int16 nTmp(0);
1820 if ( rPropSet.getProperty( nTmp, PROP_MaxTextLen ) )
1821 mnMaxLength = nTmp;
1822 if ( rPropSet.getProperty( nTmp, PROP_EchoChar ) )
1823 mnPasswordChar = nTmp;
1824 if ( rPropSet.getProperty( bRes, PROP_HScroll ) )
1825 setFlag( mnScrollBars, AX_SCROLLBAR_HORIZONTAL, bRes );
1826 if ( rPropSet.getProperty( bRes, PROP_VScroll ) )
1827 setFlag( mnScrollBars, AX_SCROLLBAR_VERTICAL, bRes );
1829 ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor, 0x80000005L );
1830 ControlConverter::convertToMSColor( rPropSet, PROP_TextColor, mnTextColor );
1832 ControlConverter::convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1833 AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
1836 void AxTextBoxModel::exportCompObj( BinaryOutputStream& rOutStream )
1838 // should be able to replace this hardcoded foo with
1839 // proper export info from MS-OLEDS spec.
1840 static sal_uInt8 const aCompObj[] = {
1841 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1842 0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x1D, 0xD2, 0x8B,
1843 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1844 0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
1845 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1846 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1847 0x32, 0x2E, 0x30, 0x20, 0x54, 0x65, 0x78, 0x74,
1848 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
1849 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
1850 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
1851 0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
1852 0x73, 0x2E, 0x54, 0x65, 0x78, 0x74, 0x42, 0x6F,
1853 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
1854 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1855 0x00, 0x00, 0x00, 0x00
1857 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1860 AxNumericFieldModel::AxNumericFieldModel()
1862 mnDisplayStyle = AX_DISPLAYSTYLE_TEXT;
1865 ApiControlType AxNumericFieldModel::getControlType() const
1867 OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT, "AxNumericFieldModel::getControlType - invalid control type" );
1868 return API_CONTROL_NUMERIC;
1871 void AxNumericFieldModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1873 rPropMap.setProperty( PROP_HideInactiveSelection, getFlag( mnFlags, AX_FLAGS_HIDESELECTION ) );
1874 // TODO: OUString::toDouble() does not handle local decimal separator
1875 rPropMap.setProperty( mbAwtModel ? PROP_Value : PROP_DefaultValue, maValue.toDouble() );
1876 rPropMap.setProperty( PROP_Spin, getFlag( mnScrollBars, AX_SCROLLBAR_VERTICAL ) );
1877 rPropMap.setProperty( PROP_Repeat, true );
1878 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::Void );
1879 rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1880 AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1883 void AxNumericFieldModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1885 bool bRes = false;
1886 if ( rPropSet.getProperty( bRes, PROP_HideInactiveSelection ) )
1887 setFlag( mnFlags, AX_FLAGS_HIDESELECTION, bRes );
1888 rPropSet.getProperty( maValue, ( mbAwtModel ? PROP_Text : PROP_DefaultText ) );
1889 if ( rPropSet.getProperty( bRes, PROP_Spin ) )
1890 setFlag( mnScrollBars, AX_SCROLLBAR_VERTICAL, bRes );
1892 ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1893 ControlConverter::convertToMSColor( rPropSet, PROP_TextColor, mnTextColor );
1895 ControlConverter::convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1896 AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
1899 void AxNumericFieldModel::exportCompObj( BinaryOutputStream& rOutStream )
1901 // should be able to replace this hardcoded foo with
1902 // proper export info from MS-OLEDS spec.
1903 static sal_uInt8 const aCompObj[] = {
1904 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1905 0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x1D, 0xD2, 0x8B,
1906 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1907 0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
1908 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1909 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1910 0x32, 0x2E, 0x30, 0x20, 0x54, 0x65, 0x78, 0x74,
1911 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
1912 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
1913 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
1914 0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
1915 0x73, 0x2E, 0x54, 0x65, 0x78, 0x74, 0x42, 0x6F,
1916 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
1917 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1918 0x00, 0x00, 0x00, 0x00
1920 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1923 AxListBoxModel::AxListBoxModel()
1925 mnDisplayStyle = AX_DISPLAYSTYLE_LISTBOX;
1928 ApiControlType AxListBoxModel::getControlType() const
1930 OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_LISTBOX, "AxListBoxModel::getControlType - invalid control type" );
1931 return API_CONTROL_LISTBOX;
1934 void AxListBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1936 bool bMultiSelect = (mnMultiSelect == AX_SELECTION_MULTI) || (mnMultiSelect == AX_SELECTION_EXTENDED);
1937 rPropMap.setProperty( PROP_MultiSelection, bMultiSelect );
1938 rPropMap.setProperty( PROP_Dropdown, false );
1939 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::Void );
1940 rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1941 AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1944 void AxListBoxModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1946 bool bRes = false;
1947 if ( rPropSet.getProperty( bRes, PROP_MultiSelection ) )
1948 ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1950 ControlConverter::convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1951 ControlConverter::convertToMSColor( rPropSet, PROP_TextColor, mnTextColor );
1952 AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
1955 void AxListBoxModel::exportCompObj( BinaryOutputStream& rOutStream )
1957 // should be able to replace this hardcoded foo with
1958 // proper export info from MS-OLEDS spec.
1959 static sal_uInt8 const aCompObj[] = {
1960 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1961 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0x1D, 0xD2, 0x8B,
1962 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1963 0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
1964 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1965 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1966 0x32, 0x2E, 0x30, 0x20, 0x4C, 0x69, 0x73, 0x74,
1967 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
1968 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
1969 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
1970 0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
1971 0x73, 0x2E, 0x4C, 0x69, 0x73, 0x74, 0x42, 0x6F,
1972 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
1973 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1974 0x00, 0x00, 0x00, 0x00
1976 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1979 AxComboBoxModel::AxComboBoxModel()
1981 mnDisplayStyle = AX_DISPLAYSTYLE_COMBOBOX;
1982 mnFlags = 0x2c80481b;
1985 ApiControlType AxComboBoxModel::getControlType() const
1987 OSL_ENSURE( (mnDisplayStyle == AX_DISPLAYSTYLE_COMBOBOX) || (mnDisplayStyle == AX_DISPLAYSTYLE_DROPDOWN), "AxComboBoxModel::getControlType - invalid control type" );
1988 return (mnDisplayStyle == AX_DISPLAYSTYLE_DROPDOWN) ? API_CONTROL_LISTBOX : API_CONTROL_COMBOBOX;
1991 void AxComboBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1993 if( mnDisplayStyle != AX_DISPLAYSTYLE_DROPDOWN )
1995 rPropMap.setProperty( PROP_HideInactiveSelection, getFlag( mnFlags, AX_FLAGS_HIDESELECTION ) );
1996 rPropMap.setProperty( mbAwtModel ? PROP_Text : PROP_DefaultText, maValue );
1997 rPropMap.setProperty( PROP_MaxTextLen, getLimitedValue< sal_Int16, sal_Int32 >( mnMaxLength, 0, SAL_MAX_INT16 ) );
1998 bool bAutoComplete = (mnMatchEntry == AX_MATCHENTRY_FIRSTLETTER) || (mnMatchEntry == AX_MATCHENTRY_COMPLETE);
1999 rPropMap.setProperty( PROP_Autocomplete, bAutoComplete );
2001 bool bShowDropdown = (mnShowDropButton == AX_SHOWDROPBUTTON_FOCUS) || (mnShowDropButton == AX_SHOWDROPBUTTON_ALWAYS);
2002 rPropMap.setProperty( PROP_Dropdown, bShowDropdown );
2003 rPropMap.setProperty( PROP_LineCount, getLimitedValue< sal_Int16, sal_Int32 >( mnListRows, 1, SAL_MAX_INT16 ) );
2004 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::Void );
2005 rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
2006 AxMorphDataModelBase::convertProperties( rPropMap, rConv );
2009 void AxComboBoxModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
2011 // when would we have mnDisplayStyle = AX_DISPLAYSTYLE_DROPDOWN ?
2012 // #TODO check against msocximex
2013 mnDisplayStyle = AX_DISPLAYSTYLE_COMBOBOX;
2014 bool bRes = false;
2016 if ( rPropSet.getProperty( bRes, PROP_HideInactiveSelection ) )
2017 setFlag( mnFlags, AX_FLAGS_HIDESELECTION, bRes );
2018 rPropSet.getProperty( maValue, ( mbAwtModel ? PROP_Text : PROP_DefaultText ) );
2020 sal_Int16 nTmp(0);
2021 if ( rPropSet.getProperty( nTmp, PROP_MaxTextLen ) )
2022 mnMaxLength = nTmp;
2023 if ( rPropSet.getProperty( bRes, PROP_Autocomplete ) )
2025 // when to choose AX_MATCHENTRY_FIRSTLETTER ?
2026 // #TODO check against msocximex
2027 if ( bRes )
2028 mnMatchEntry = AX_MATCHENTRY_COMPLETE;
2030 if ( rPropSet.getProperty( bRes, PROP_Dropdown ) )
2032 rPropSet.getProperty( mnListRows, PROP_LineCount );
2033 if ( !mnListRows )
2034 mnListRows = 1;
2036 ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
2037 ControlConverter::convertToMSColor( rPropSet, PROP_TextColor, mnTextColor );
2039 ControlConverter::convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect );
2040 AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
2043 void AxComboBoxModel::exportCompObj( BinaryOutputStream& rOutStream )
2045 // should be able to replace this hardcoded foo with
2046 // proper export info from MS-OLEDS spec.
2047 static sal_uInt8 const aCompObj[] = {
2048 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2049 0xFF, 0xFF, 0xFF, 0xFF, 0x30, 0x1D, 0xD2, 0x8B,
2050 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
2051 0x00, 0x60, 0x02, 0xF3, 0x1D, 0x00, 0x00, 0x00,
2052 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2053 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2054 0x32, 0x2E, 0x30, 0x20, 0x43, 0x6F, 0x6D, 0x62,
2055 0x6F, 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00,
2056 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65,
2057 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74,
2058 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72,
2059 0x6D, 0x73, 0x2E, 0x43, 0x6F, 0x6D, 0x62, 0x6F,
2060 0x42, 0x6F, 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39,
2061 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2062 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2064 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
2067 AxSpinButtonModel::AxSpinButtonModel() :
2068 mnArrowColor( AX_SYSCOLOR_BUTTONTEXT ),
2069 mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
2070 mnFlags( AX_SPINBUTTON_DEFFLAGS ),
2071 mnOrientation( AX_ORIENTATION_AUTO ),
2072 mnMin( 0 ),
2073 mnMax( 100 ),
2074 mnPosition( 0 ),
2075 mnSmallChange( 1 ),
2076 mnDelay( 50 )
2080 ApiControlType AxSpinButtonModel::getControlType() const
2082 return API_CONTROL_SPINBUTTON;
2085 void AxSpinButtonModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
2087 switch( nPropId )
2089 case XML_ForeColor: mnArrowColor = AttributeConversion::decodeUnsigned( rValue ); break;
2090 case XML_BackColor: mnBackColor = AttributeConversion::decodeUnsigned( rValue ); break;
2091 case XML_VariousPropertyBits: mnFlags = AttributeConversion::decodeUnsigned( rValue ); break;
2092 case XML_Orientation: mnOrientation = AttributeConversion::decodeInteger( rValue ); break;
2093 case XML_Min: mnMin = AttributeConversion::decodeInteger( rValue ); break;
2094 case XML_Max: mnMax = AttributeConversion::decodeInteger( rValue ); break;
2095 case XML_Position: mnPosition = AttributeConversion::decodeInteger( rValue ); break;
2096 case XML_SmallChange: mnSmallChange = AttributeConversion::decodeInteger( rValue ); break;
2097 case XML_Delay: mnDelay = AttributeConversion::decodeInteger( rValue ); break;
2098 default: AxControlModelBase::importProperty( nPropId, rValue );
2102 bool AxSpinButtonModel::importBinaryModel( BinaryInputStream& rInStrm )
2104 AxBinaryPropertyReader aReader( rInStrm );
2105 aReader.readIntProperty< sal_uInt32 >( mnArrowColor );
2106 aReader.readIntProperty< sal_uInt32 >( mnBackColor );
2107 aReader.readIntProperty< sal_uInt32 >( mnFlags );
2108 aReader.readPairProperty( maSize );
2109 aReader.skipIntProperty< sal_uInt32 >(); // unused
2110 aReader.readIntProperty< sal_Int32 >( mnMin );
2111 aReader.readIntProperty< sal_Int32 >( mnMax );
2112 aReader.readIntProperty< sal_Int32 >( mnPosition );
2113 aReader.skipIntProperty< sal_uInt32 >(); // prev enabled
2114 aReader.skipIntProperty< sal_uInt32 >(); // next enabled
2115 aReader.readIntProperty< sal_Int32 >( mnSmallChange );
2116 aReader.readIntProperty< sal_Int32 >( mnOrientation );
2117 aReader.readIntProperty< sal_Int32 >( mnDelay );
2118 aReader.skipPictureProperty(); // mouse icon
2119 aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
2120 return aReader.finalizeImport();
2123 void AxSpinButtonModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
2125 AxBinaryPropertyWriter aWriter( rOutStrm );
2126 aWriter.writeIntProperty< sal_uInt32 >( mnArrowColor );
2127 if ( mnBackColor )
2128 aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
2129 else
2130 aWriter.skipProperty(); // default backcolour
2131 aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
2132 aWriter.writePairProperty( maSize );
2133 aWriter.skipProperty(); // unused
2134 aWriter.writeIntProperty< sal_Int32 >( mnMin );
2135 aWriter.writeIntProperty< sal_Int32 >( mnMax );
2136 aWriter.writeIntProperty< sal_Int32 >( mnPosition );
2137 aWriter.skipProperty(); // prev enabled
2138 aWriter.skipProperty(); // next enabled
2139 aWriter.writeIntProperty< sal_Int32 >( mnSmallChange );
2140 aWriter.writeIntProperty< sal_Int32 >( mnOrientation );
2141 aWriter.writeIntProperty< sal_Int32 >( mnDelay );
2142 aWriter.skipProperty(); // mouse icon
2143 aWriter.skipProperty(); // mouse pointer
2145 aWriter.finalizeExport();
2148 void AxSpinButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2150 sal_Int32 nMin = ::std::min( mnMin, mnMax );
2151 sal_Int32 nMax = ::std::max( mnMin, mnMax );
2152 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
2153 rPropMap.setProperty( PROP_SpinValueMin, nMin );
2154 rPropMap.setProperty( PROP_SpinValueMax, nMax );
2155 rPropMap.setProperty( PROP_SpinIncrement, mnSmallChange );
2156 rPropMap.setProperty( mbAwtModel ? PROP_SpinValue : PROP_DefaultSpinValue, mnPosition );
2157 rPropMap.setProperty( PROP_Repeat, true );
2158 rPropMap.setProperty( PROP_RepeatDelay, mnDelay );
2159 rPropMap.setProperty( PROP_Border, API_BORDER_NONE );
2160 rConv.convertColor( rPropMap, PROP_SymbolColor, mnArrowColor );
2161 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::NotSupported );
2162 ControlConverter::convertAxOrientation( rPropMap, maSize, mnOrientation );
2163 AxControlModelBase::convertProperties( rPropMap, rConv );
2166 void AxSpinButtonModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& )
2168 bool bRes = false;
2169 if ( rPropSet.getProperty( bRes, PROP_Enabled ) )
2170 setFlag( mnFlags, AX_FLAGS_ENABLED, bRes );
2171 rPropSet.getProperty( mnMin, PROP_SpinValueMin );
2172 rPropSet.getProperty( mnMax, PROP_SpinValueMax );
2173 rPropSet.getProperty( mnSmallChange, PROP_SpinIncrement );
2174 rPropSet.getProperty( mnPosition, ( mbAwtModel ? PROP_SpinValue : PROP_DefaultSpinValue ) );
2175 rPropSet.getProperty( mnDelay, PROP_RepeatDelay );
2176 ControlConverter::convertToMSColor( rPropSet, PROP_SymbolColor, mnArrowColor);
2177 ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
2179 ControlConverter::convertToAxOrientation( rPropSet, mnOrientation );
2182 void AxSpinButtonModel::exportCompObj( BinaryOutputStream& rOutStream )
2184 // should be able to replace this hardcoded foo with
2185 // proper export info from MS-OLEDS spec.
2186 static sal_uInt8 const aCompObj[] =
2188 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2189 0xFF, 0xFF, 0xFF, 0xFF, 0xB0, 0x6F, 0x17, 0x79,
2190 0xF2, 0xB7, 0xCE, 0x11, 0x97, 0xEF, 0x00, 0xAA,
2191 0x00, 0x6D, 0x27, 0x76, 0x1F, 0x00, 0x00, 0x00,
2192 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2193 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2194 0x32, 0x2E, 0x30, 0x20, 0x53, 0x70, 0x69, 0x6E,
2195 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x00, 0x10,
2196 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64,
2197 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65,
2198 0x63, 0x74, 0x00, 0x13, 0x00, 0x00, 0x00, 0x46,
2199 0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x53, 0x70, 0x69,
2200 0x6E, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x2E,
2201 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00,
2202 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2203 0x00, 0x00
2206 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
2209 AxScrollBarModel::AxScrollBarModel() :
2210 mnArrowColor( AX_SYSCOLOR_BUTTONTEXT ),
2211 mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
2212 mnFlags( AX_SCROLLBAR_DEFFLAGS ),
2213 mnOrientation( AX_ORIENTATION_AUTO ),
2214 mnPropThumb( AX_PROPTHUMB_ON ),
2215 mnMin( 0 ),
2216 mnMax( 32767 ),
2217 mnPosition( 0 ),
2218 mnSmallChange( 1 ),
2219 mnLargeChange( 1 ),
2220 mnDelay( 50 )
2224 ApiControlType AxScrollBarModel::getControlType() const
2226 return API_CONTROL_SCROLLBAR;
2229 void AxScrollBarModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
2231 switch( nPropId )
2233 case XML_ForeColor: mnArrowColor = AttributeConversion::decodeUnsigned( rValue ); break;
2234 case XML_BackColor: mnBackColor = AttributeConversion::decodeUnsigned( rValue ); break;
2235 case XML_VariousPropertyBits: mnFlags = AttributeConversion::decodeUnsigned( rValue ); break;
2236 case XML_Orientation: mnOrientation = AttributeConversion::decodeInteger( rValue ); break;
2237 case XML_ProportionalThumb: mnPropThumb = AttributeConversion::decodeInteger( rValue ); break;
2238 case XML_Min: mnMin = AttributeConversion::decodeInteger( rValue ); break;
2239 case XML_Max: mnMax = AttributeConversion::decodeInteger( rValue ); break;
2240 case XML_Position: mnPosition = AttributeConversion::decodeInteger( rValue ); break;
2241 case XML_SmallChange: mnSmallChange = AttributeConversion::decodeInteger( rValue ); break;
2242 case XML_LargeChange: mnLargeChange = AttributeConversion::decodeInteger( rValue ); break;
2243 case XML_Delay: mnDelay = AttributeConversion::decodeInteger( rValue ); break;
2244 default: AxControlModelBase::importProperty( nPropId, rValue );
2248 bool AxScrollBarModel::importBinaryModel( BinaryInputStream& rInStrm )
2250 AxBinaryPropertyReader aReader( rInStrm );
2251 aReader.readIntProperty< sal_uInt32 >( mnArrowColor );
2252 aReader.readIntProperty< sal_uInt32 >( mnBackColor );
2253 aReader.readIntProperty< sal_uInt32 >( mnFlags );
2254 aReader.readPairProperty( maSize );
2255 aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
2256 aReader.readIntProperty< sal_Int32 >( mnMin );
2257 aReader.readIntProperty< sal_Int32 >( mnMax );
2258 aReader.readIntProperty< sal_Int32 >( mnPosition );
2259 aReader.skipIntProperty< sal_uInt32 >(); // unused
2260 aReader.skipIntProperty< sal_uInt32 >(); // prev enabled
2261 aReader.skipIntProperty< sal_uInt32 >(); // next enabled
2262 aReader.readIntProperty< sal_Int32 >( mnSmallChange );
2263 aReader.readIntProperty< sal_Int32 >( mnLargeChange );
2264 aReader.readIntProperty< sal_Int32 >( mnOrientation );
2265 aReader.readIntProperty< sal_Int16 >( mnPropThumb );
2266 aReader.readIntProperty< sal_Int32 >( mnDelay );
2267 aReader.skipPictureProperty(); // mouse icon
2268 return aReader.finalizeImport();
2271 void AxScrollBarModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
2273 AxBinaryPropertyWriter aWriter( rOutStrm );
2274 aWriter.writeIntProperty< sal_uInt32 >( mnArrowColor );
2275 if ( mnBackColor )
2276 aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
2277 else
2278 aWriter.skipProperty(); // default backcolour
2279 aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
2280 aWriter.writePairProperty( maSize );
2281 aWriter.skipProperty(); // mouse pointer
2282 aWriter.writeIntProperty< sal_Int32 >( mnMin );
2283 aWriter.writeIntProperty< sal_Int32 >( mnMax );
2284 aWriter.writeIntProperty< sal_Int32 >( mnPosition );
2285 aWriter.skipProperty(); // unused
2286 aWriter.skipProperty(); // prev enabled
2287 aWriter.skipProperty(); // next enabled
2288 aWriter.writeIntProperty< sal_Int32 >( mnSmallChange );
2289 aWriter.writeIntProperty< sal_Int32 >( mnLargeChange );
2290 aWriter.writeIntProperty< sal_Int32 >( mnOrientation );
2291 aWriter.writeIntProperty< sal_Int16 >( mnPropThumb );
2292 aWriter.writeIntProperty< sal_Int32 >( mnDelay );
2293 aWriter.skipProperty(); // mouse icon
2294 aWriter.finalizeExport();
2297 void AxScrollBarModel::exportCompObj( BinaryOutputStream& rOutStream )
2299 // should be able to replace this hardcoded foo with
2300 // proper export info from MS-OLEDS spec.
2301 static sal_uInt8 const aCompObj[] =
2303 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2304 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x81, 0xD1, 0xDF,
2305 0x2F, 0x5E, 0xCE, 0x11, 0xA4, 0x49, 0x00, 0xAA,
2306 0x00, 0x4A, 0x80, 0x3D, 0x1E, 0x00, 0x00, 0x00,
2307 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2308 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2309 0x32, 0x2E, 0x30, 0x20, 0x53, 0x63, 0x72, 0x6F,
2310 0x6C, 0x6C, 0x42, 0x61, 0x72, 0x00, 0x10, 0x00,
2311 0x00, 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64,
2312 0x65, 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63,
2313 0x74, 0x00, 0x12, 0x00, 0x00, 0x00, 0x46, 0x6F,
2314 0x72, 0x6D, 0x73, 0x2E, 0x53, 0x63, 0x72, 0x6F,
2315 0x6C, 0x6C, 0x42, 0x61, 0x72, 0x2E, 0x31, 0x00,
2316 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
2317 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2319 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
2322 void AxScrollBarModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2324 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
2325 rPropMap.setProperty( PROP_RepeatDelay, mnDelay );
2326 rPropMap.setProperty( PROP_Border, API_BORDER_NONE );
2327 if( (mnPropThumb == AX_PROPTHUMB_ON) && (mnMin != mnMax) && (mnLargeChange > 0) )
2329 // use double to prevent integer overflow in division (fInterval+mnLargeChange may become 0 when performed as int)
2330 double fInterval = fabs( static_cast< double >( mnMax - mnMin ) );
2331 sal_Int32 nThumbLen = getLimitedValue< sal_Int32, double >( (fInterval * mnLargeChange) / (fInterval + mnLargeChange), 1, SAL_MAX_INT32 );
2332 rPropMap.setProperty( PROP_VisibleSize, nThumbLen );
2334 rConv.convertColor( rPropMap, PROP_SymbolColor, mnArrowColor );
2335 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::NotSupported );
2336 ControlConverter::convertAxOrientation( rPropMap, maSize, mnOrientation );
2337 ControlConverter::convertScrollBar( rPropMap, mnMin, mnMax, mnPosition, mnSmallChange, mnLargeChange, mbAwtModel );
2338 AxControlModelBase::convertProperties( rPropMap, rConv );
2341 void AxScrollBarModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& )
2343 bool bRes = false;
2344 if ( rPropSet.getProperty( bRes, PROP_Enabled ) )
2345 setFlag( mnFlags, AX_FLAGS_ENABLED, bRes );
2346 rPropSet.getProperty( mnDelay, PROP_RepeatDelay );
2347 mnPropThumb = AX_PROPTHUMB_ON; // default
2348 ControlConverter::convertToMSColor( rPropSet, PROP_SymbolColor, mnArrowColor);
2349 ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
2350 ControlConverter::convertToAxOrientation( rPropSet, mnOrientation );
2352 rPropSet.getProperty( mnMin, PROP_ScrollValueMin );
2353 rPropSet.getProperty( mnMax, PROP_ScrollValueMax );
2354 rPropSet.getProperty( mnSmallChange, PROP_LineIncrement );
2355 rPropSet.getProperty( mnLargeChange, PROP_BlockIncrement );
2356 rPropSet.getProperty( mnPosition, ( mbAwtModel ? PROP_ScrollValue : PROP_DefaultScrollValue ) );
2360 AxContainerModelBase::AxContainerModelBase( bool bFontSupport ) :
2361 AxFontDataModel( false ), // no support for alignment properties
2362 maLogicalSize( AX_CONTAINER_DEFWIDTH, AX_CONTAINER_DEFHEIGHT ),
2363 maScrollPos( 0, 0 ),
2364 mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
2365 mnTextColor( AX_SYSCOLOR_BUTTONTEXT ),
2366 mnFlags( AX_CONTAINER_DEFFLAGS ),
2367 mnBorderColor( AX_SYSCOLOR_BUTTONTEXT ),
2368 mnBorderStyle( AX_BORDERSTYLE_NONE ),
2369 mnScrollBars( AX_CONTAINER_SCR_NONE ),
2370 mnCycleType( AX_CONTAINER_CYCLEALL ),
2371 mnSpecialEffect( AX_SPECIALEFFECT_FLAT ),
2372 mnPicAlign( AX_PICALIGN_CENTER ),
2373 mnPicSizeMode( AX_PICSIZE_CLIP ),
2374 mbPicTiling( false ),
2375 mbFontSupport( bFontSupport )
2377 setAwtModelMode();
2378 // different default size for frame
2379 maSize = AxPairData( AX_CONTAINER_DEFWIDTH, AX_CONTAINER_DEFHEIGHT );
2382 void AxContainerModelBase::importProperty( sal_Int32 nPropId, const OUString& rValue )
2384 if( nPropId == XML_Caption )
2385 maCaption = rValue;
2388 bool AxContainerModelBase::importBinaryModel( BinaryInputStream& rInStrm )
2390 AxBinaryPropertyReader aReader( rInStrm );
2391 aReader.skipUndefinedProperty();
2392 aReader.readIntProperty< sal_uInt32 >( mnBackColor );
2393 aReader.readIntProperty< sal_uInt32 >( mnTextColor );
2394 aReader.skipIntProperty< sal_uInt32 >(); // next available control ID
2395 aReader.skipUndefinedProperty();
2396 aReader.skipUndefinedProperty();
2397 aReader.readIntProperty< sal_uInt32 >( mnFlags );
2398 aReader.readIntProperty< sal_uInt8 >( mnBorderStyle );
2399 aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
2400 aReader.readIntProperty< sal_uInt8 >( mnScrollBars );
2401 aReader.readPairProperty( maSize );
2402 aReader.readPairProperty( maLogicalSize );
2403 aReader.readPairProperty( maScrollPos );
2404 aReader.skipIntProperty< sal_uInt32 >(); // number of control groups
2405 aReader.skipUndefinedProperty();
2406 aReader.skipPictureProperty(); // mouse icon
2407 aReader.readIntProperty< sal_uInt8 >( mnCycleType );
2408 aReader.readIntProperty< sal_uInt8 >( mnSpecialEffect );
2409 aReader.readIntProperty< sal_uInt32 >( mnBorderColor );
2410 aReader.readStringProperty( maCaption );
2411 aReader.readFontProperty( maFontData );
2412 aReader.readPictureProperty( maPictureData );
2413 aReader.skipIntProperty< sal_Int32 >(); // zoom
2414 aReader.readIntProperty< sal_uInt8 >( mnPicAlign );
2415 aReader.readBoolProperty( mbPicTiling );
2416 aReader.readIntProperty< sal_uInt8 >( mnPicSizeMode );
2417 aReader.skipIntProperty< sal_uInt32 >(); // shape cookie
2418 aReader.skipIntProperty< sal_uInt32 >(); // draw buffer size
2419 return aReader.finalizeImport();
2422 void AxContainerModelBase::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2424 if( mbFontSupport )
2426 rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor );
2427 AxFontDataModel::convertProperties( rPropMap, rConv );
2431 bool AxContainerModelBase::importClassTable( BinaryInputStream& rInStrm, AxClassTable& orClassTable )
2433 bool bValid = true;
2434 orClassTable.clear();
2435 if( !getFlag( mnFlags, AX_CONTAINER_NOCLASSTABLE ) )
2437 sal_uInt16 nCount = rInStrm.readuInt16();
2438 for( sal_uInt16 nIndex = 0; bValid && (nIndex < nCount); ++nIndex )
2440 orClassTable.emplace_back( );
2441 AxBinaryPropertyReader aReader( rInStrm );
2442 aReader.readGuidProperty( orClassTable.back() );
2443 aReader.skipGuidProperty(); // source interface GUID
2444 aReader.skipUndefinedProperty();
2445 aReader.skipGuidProperty(); // default interface GUID
2446 aReader.skipIntProperty< sal_uInt32 >(); // class table and var flags
2447 aReader.skipIntProperty< sal_uInt32 >(); // method count
2448 aReader.skipIntProperty< sal_Int32 >(); // IDispatch identifier for linked cell access
2449 aReader.skipIntProperty< sal_uInt16 >(); // get function index for linked cell access
2450 aReader.skipIntProperty< sal_uInt16 >(); // put function index for linked cell access
2451 aReader.skipIntProperty< sal_uInt16 >(); // linked cell access property type
2452 aReader.skipIntProperty< sal_uInt16 >(); // get function index of value
2453 aReader.skipIntProperty< sal_uInt16 >(); // put function index of value
2454 aReader.skipIntProperty< sal_uInt16 >(); // value type
2455 aReader.skipIntProperty< sal_Int32 >(); // IDispatch identifier for source range access
2456 aReader.skipIntProperty< sal_uInt16 >(); // get function index for source range access
2457 bValid = aReader.finalizeImport();
2460 return bValid;
2463 AxFrameModel::AxFrameModel() :
2464 AxContainerModelBase( true )
2468 ApiControlType AxFrameModel::getControlType() const
2470 return mbAwtModel ? API_CONTROL_FRAME : API_CONTROL_GROUPBOX;
2473 void AxFrameModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2475 rPropMap.setProperty( PROP_Label, maCaption );
2476 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_CONTAINER_ENABLED ) );
2477 AxContainerModelBase::convertProperties( rPropMap, rConv );
2480 AxPageModel::AxPageModel()
2484 ApiControlType AxPageModel::getControlType() const
2486 return API_CONTROL_PAGE;
2489 void AxPageModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2491 rPropMap.setProperty( PROP_Title, maCaption );
2492 rConv.convertColor( rPropMap, PROP_BackgroundColor, mnBackColor );
2493 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_CONTAINER_ENABLED ) );
2494 AxContainerModelBase::convertProperties( rPropMap, rConv );
2497 AxMultiPageModel::AxMultiPageModel() :
2498 mnActiveTab( 0 ),
2499 mnTabStyle( AX_TABSTRIP_TABS )
2503 ApiControlType AxMultiPageModel::getControlType() const
2505 return API_CONTROL_MULTIPAGE;
2508 void AxMultiPageModel::importPageAndMultiPageProperties( BinaryInputStream& rInStrm, sal_Int32 nPages )
2510 // PageProperties
2511 for ( sal_Int32 nPage = 0; nPage < nPages; ++nPage )
2513 AxBinaryPropertyReader aReader( rInStrm );
2514 aReader.skipUndefinedProperty();
2515 aReader.skipIntProperty< sal_uInt32 >(); // TransistionEffect
2516 aReader.skipIntProperty< sal_uInt32 >(); // TransitionPeriod
2518 // MultiPageProperties
2519 AxBinaryPropertyReader aReader( rInStrm );
2520 sal_uInt32 nPageCount = 0;
2521 aReader.skipUndefinedProperty();
2522 aReader.readIntProperty< sal_uInt32 >(nPageCount); // PageCount
2523 aReader.skipIntProperty< sal_uInt32 >(); //ID
2525 // IDs
2526 for ( sal_uInt32 count = 0; count < nPageCount; ++count )
2528 mnIDs.push_back( rInStrm.readInt32() );
2532 void AxMultiPageModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2534 rPropMap.setProperty( PROP_Title, maCaption );
2535 rPropMap.setProperty( PROP_MultiPageValue, mnActiveTab + 1);
2536 rConv.convertColor( rPropMap, PROP_BackgroundColor, mnBackColor );
2537 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_CONTAINER_ENABLED ) );
2538 rPropMap.setProperty( PROP_Decoration, mnTabStyle != AX_TABSTRIP_NONE );
2540 AxContainerModelBase::convertProperties( rPropMap, rConv );
2543 AxUserFormModel::AxUserFormModel()
2547 ApiControlType AxUserFormModel::getControlType() const
2549 return API_CONTROL_DIALOG;
2552 void AxUserFormModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2554 rPropMap.setProperty( PROP_Title, maCaption );
2555 rConv.convertColor( rPropMap, PROP_BackgroundColor, mnBackColor );
2556 rConv.convertAxPicture( rPropMap, maPictureData, AX_PICPOS_CENTER );
2557 rConv.convertScrollabilitySettings( rPropMap, maScrollPos, maLogicalSize, mnScrollBars );
2558 AxContainerModelBase::convertProperties( rPropMap, rConv );
2561 HtmlSelectModel::HtmlSelectModel()
2565 bool
2566 HtmlSelectModel::importBinaryModel( BinaryInputStream& rInStrm )
2568 if (rInStrm.size()<=0)
2569 return true;
2571 OUString sStringContents = rInStrm.readUnicodeArray( rInStrm.size() );
2573 // replace crlf with lf
2574 OUString data = sStringContents.replaceAll( "\x0D\x0A" , "\x0A" );
2576 std::vector< OUString > listValues;
2577 std::vector< sal_Int16 > selectedIndices;
2579 // Ultra hacky parser for the info
2580 sal_Int32 nLineIdx {0};
2581 // first line will tell us if multiselect is enabled
2582 if (data.getToken( 0, '\n', nLineIdx )=="<SELECT MULTIPLE")
2583 mnMultiSelect = AX_SELECTION_MULTI;
2584 // skip first and last lines, no data there
2585 if (nLineIdx>0)
2587 for (;;)
2589 OUString sLine( data.getToken( 0, '\n', nLineIdx ) );
2590 if (nLineIdx<0)
2591 break; // skip last line
2593 if ( !sLine.isEmpty() )
2595 OUString displayValue = sLine.getToken( 1, '>' );
2596 if ( displayValue.getLength() )
2598 // Really we should be using a proper html parser
2599 // escaping some common bits to be escaped
2600 displayValue = displayValue.replaceAll( "&lt;", "<" );
2601 displayValue = displayValue.replaceAll( "&gt;", ">" );
2602 displayValue = displayValue.replaceAll( "&quot;", "\"" );
2603 displayValue = displayValue.replaceAll( "&amp;", "&" );
2604 listValues.push_back( displayValue );
2605 if( sLine.indexOf( "OPTION SELECTED" ) != -1 )
2606 selectedIndices.push_back( static_cast< sal_Int16 >( listValues.size() ) - 1 );
2611 if ( !listValues.empty() )
2613 msListData.realloc( listValues.size() );
2614 sal_Int32 index = 0;
2615 for (auto const& listValue : listValues)
2616 msListData[ index++ ] = listValue;
2618 if ( !selectedIndices.empty() )
2620 msIndices.realloc( selectedIndices.size() );
2621 sal_Int32 index = 0;
2622 for (auto const& selectedIndice : selectedIndices)
2623 msIndices[ index++ ] = selectedIndice;
2625 return true;
2628 void
2629 HtmlSelectModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2631 rPropMap.setProperty( PROP_StringItemList, msListData );
2632 rPropMap.setProperty( PROP_SelectedItems, msIndices );
2633 rPropMap.setProperty( PROP_Dropdown, true );
2634 AxListBoxModel::convertProperties( rPropMap, rConv );
2637 HtmlTextBoxModel::HtmlTextBoxModel()
2641 bool
2642 HtmlTextBoxModel::importBinaryModel( BinaryInputStream& rInStrm )
2644 #ifdef DEBUG
2645 OUString sStringContents = rInStrm.readUnicodeArray( rInStrm.size() );
2646 // in msocximex ( where this is ported from, it appears *nothing* is read
2647 // from the control stream ), surely there is some useful info there ?
2648 SAL_WARN("oox", "HtmlTextBoxModel::importBinaryModel - string contents of stream: " << sStringContents );
2649 #else
2650 (void) rInStrm;
2651 #endif
2652 return true;
2655 EmbeddedControl::EmbeddedControl( const OUString& rName ) :
2656 maName( rName )
2660 ControlModelBase* EmbeddedControl::createModelFromGuid( const OUString& rClassId )
2662 if( rClassId.equalsIgnoreAsciiCase( AX_GUID_COMMANDBUTTON ) ) return &createModel< AxCommandButtonModel >();
2663 if( rClassId.equalsIgnoreAsciiCase( AX_GUID_LABEL ) ) return &createModel< AxLabelModel >();
2664 if( rClassId.equalsIgnoreAsciiCase( AX_GUID_IMAGE ) ) return &createModel< AxImageModel >();
2665 if( rClassId.equalsIgnoreAsciiCase( AX_GUID_TOGGLEBUTTON ) ) return &createModel< AxToggleButtonModel >();
2666 if( rClassId.equalsIgnoreAsciiCase( AX_GUID_CHECKBOX ) ) return &createModel< AxCheckBoxModel >();
2667 if( rClassId.equalsIgnoreAsciiCase( AX_GUID_OPTIONBUTTON ) ) return &createModel< AxOptionButtonModel >();
2668 if( rClassId.equalsIgnoreAsciiCase( AX_GUID_TEXTBOX ) ) return &createModel< AxTextBoxModel >();
2669 if( rClassId.equalsIgnoreAsciiCase( AX_GUID_LISTBOX ) ) return &createModel< AxListBoxModel >();
2670 if( rClassId.equalsIgnoreAsciiCase( AX_GUID_COMBOBOX ) ) return &createModel< AxComboBoxModel >();
2671 if( rClassId.equalsIgnoreAsciiCase( AX_GUID_SPINBUTTON ) ) return &createModel< AxSpinButtonModel >();
2672 if( rClassId.equalsIgnoreAsciiCase( AX_GUID_SCROLLBAR ) ) return &createModel< AxScrollBarModel >();
2673 if( rClassId.equalsIgnoreAsciiCase( AX_GUID_FRAME ) ) return &createModel< AxFrameModel >();
2674 if( rClassId.equalsIgnoreAsciiCase( COMCTL_GUID_SCROLLBAR_60 ) ) return &createModel< ComCtlScrollBarModel >( COMCTL_VERSION_60 );
2675 if( rClassId.equalsIgnoreAsciiCase( HTML_GUID_SELECT ) ) return &createModel< HtmlSelectModel >();
2676 if( rClassId.equalsIgnoreAsciiCase( HTML_GUID_TEXTBOX ) ) return &createModel< HtmlTextBoxModel >();
2678 mxModel.reset();
2679 return nullptr;
2682 OUString EmbeddedControl::getServiceName() const
2684 return mxModel.get() ? mxModel->getServiceName() : OUString();
2687 bool EmbeddedControl::convertProperties( const Reference< XControlModel >& rxCtrlModel, const ControlConverter& rConv ) const
2689 if( mxModel.get() && rxCtrlModel.is() && !maName.isEmpty() )
2691 PropertyMap aPropMap;
2692 aPropMap.setProperty( PROP_Name, maName );
2695 aPropMap.setProperty( PROP_GenerateVbaEvents, true);
2697 catch (const Exception&)
2699 TOOLS_WARN_EXCEPTION("oox", "");
2701 mxModel->convertProperties( aPropMap, rConv );
2702 PropertySet aPropSet( rxCtrlModel );
2703 aPropSet.setProperties( aPropMap );
2704 return true;
2706 return false;
2709 void EmbeddedControl::convertFromProperties( const Reference< XControlModel >& rxCtrlModel, const ControlConverter& rConv )
2711 if( mxModel.get() && rxCtrlModel.is() && !maName.isEmpty() )
2713 PropertySet aPropSet( rxCtrlModel );
2714 aPropSet.getProperty( maName, PROP_Name );
2715 mxModel->convertFromProperties( aPropSet, rConv );
2719 EmbeddedForm::EmbeddedForm( const Reference< XModel >& rxDocModel,
2720 const Reference< XDrawPage >& rxDrawPage, const GraphicHelper& rGraphicHelper ) :
2721 maControlConv( rxDocModel, rGraphicHelper, true/*bDefaultColorBgr*/ ),
2722 mxModelFactory( rxDocModel, UNO_QUERY ),
2723 mxFormsSupp( rxDrawPage, UNO_QUERY )
2725 OSL_ENSURE( mxModelFactory.is(), "EmbeddedForm::EmbeddedForm - missing service factory" );
2728 Reference< XControlModel > EmbeddedForm::convertAndInsert( const EmbeddedControl& rControl, sal_Int32& rnCtrlIndex )
2730 Reference< XControlModel > xRet;
2731 if( mxModelFactory.is() && rControl.hasModel() ) try
2733 // create the UNO control model
2734 OUString aServiceName = rControl.getServiceName();
2735 Reference< XFormComponent > xFormComp( mxModelFactory->createInstance( aServiceName ), UNO_QUERY_THROW );
2736 Reference< XControlModel > xCtrlModel( xFormComp, UNO_QUERY_THROW );
2738 // convert the control properties
2739 if( rControl.convertProperties( xCtrlModel, maControlConv ) )
2740 xRet = xCtrlModel;
2741 // insert the control into the form
2742 Reference< XIndexContainer > xFormIC( createXForm(), UNO_SET_THROW );
2743 rnCtrlIndex = xFormIC->getCount();
2744 xFormIC->insertByIndex( rnCtrlIndex, Any( xFormComp ) );
2746 catch (const Exception&)
2748 TOOLS_WARN_EXCEPTION("oox", "exception creating Control");
2750 return xRet;
2753 Reference< XIndexContainer > const & EmbeddedForm::createXForm()
2755 if( mxFormsSupp.is() )
2759 Reference< XNameContainer > xFormsNC( mxFormsSupp->getForms(), UNO_SET_THROW );
2760 OUString aFormName = "Standard";
2761 if( xFormsNC->hasByName( aFormName ) )
2763 mxFormIC.set( xFormsNC->getByName( aFormName ), UNO_QUERY_THROW );
2765 else if( mxModelFactory.is() )
2767 Reference< XForm > xForm( mxModelFactory->createInstance( "com.sun.star.form.component.Form" ), UNO_QUERY_THROW );
2768 xFormsNC->insertByName( aFormName, Any( xForm ) );
2769 mxFormIC.set( xForm, UNO_QUERY_THROW );
2772 catch (const Exception&)
2774 TOOLS_WARN_EXCEPTION("oox", "exception creating Form");
2776 // always clear the forms supplier to not try to create the form again
2777 mxFormsSupp.clear();
2779 return mxFormIC;
2782 } // namespace ole
2783 } // namespace oox
2785 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */