Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / oox / source / ole / axcontrol.cxx
blob96ecfbf91b6940b5fdab1ca9d85df99dcdd5e0b1
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 <comphelper/string.hxx>
51 #include <rtl/tencinfo.h>
52 #include <osl/diagnose.h>
53 #include "oox/helper/attributelist.hxx"
54 #include "oox/helper/binaryinputstream.hxx"
55 #include "oox/helper/containerhelper.hxx"
56 #include "oox/helper/graphichelper.hxx"
57 #include "oox/helper/propertymap.hxx"
58 #include "oox/ole/axbinarywriter.hxx"
59 #include <oox/token/properties.hxx>
60 #include <oox/token/tokens.hxx>
61 namespace oox {
62 namespace ole {
64 using namespace ::com::sun::star;
65 using namespace ::com::sun::star::awt;
66 using namespace ::com::sun::star::beans;
67 using namespace ::com::sun::star::container;
68 using namespace ::com::sun::star::drawing;
69 using namespace ::com::sun::star::form;
70 using namespace ::com::sun::star::form::binding;
71 using namespace ::com::sun::star::frame;
72 using namespace ::com::sun::star::lang;
73 using namespace ::com::sun::star::sheet;
74 using namespace ::com::sun::star::style;
75 using namespace ::com::sun::star::table;
76 using namespace ::com::sun::star::uno;
78 namespace {
80 const sal_uInt32 COMCTL_ID_SIZE = 0x12344321;
82 const sal_uInt32 COMCTL_ID_COMMONDATA = 0xABCDEF01;
83 const sal_uInt32 COMCTL_COMMON_FLATBORDER = 0x00000001;
84 const sal_uInt32 COMCTL_COMMON_ENABLED = 0x00000002;
85 const sal_uInt32 COMCTL_COMMON_3DBORDER = 0x00000004;
87 const sal_uInt32 COMCTL_ID_COMPLEXDATA = 0xBDECDE1F;
88 const sal_uInt32 COMCTL_COMPLEX_FONT = 0x00000001;
89 const sal_uInt32 COMCTL_COMPLEX_MOUSEICON = 0x00000002;
91 const sal_uInt32 COMCTL_ID_SCROLLBAR_60 = 0x99470A83;
92 const sal_uInt32 COMCTL_SCROLLBAR_HOR = 0x00000010;
94 const sal_uInt32 COMCTL_ID_PROGRESSBAR_50 = 0xE6E17E84;
95 const sal_uInt32 COMCTL_ID_PROGRESSBAR_60 = 0x97AB8A01;
97 const sal_uInt32 AX_CMDBUTTON_DEFFLAGS = 0x0000001B;
98 const sal_uInt32 AX_LABEL_DEFFLAGS = 0x0080001B;
99 const sal_uInt32 AX_IMAGE_DEFFLAGS = 0x0000001B;
100 const sal_uInt32 AX_MORPHDATA_DEFFLAGS = 0x2C80081B;
101 const sal_uInt32 AX_SPINBUTTON_DEFFLAGS = 0x0000001B;
102 const sal_uInt32 AX_SCROLLBAR_DEFFLAGS = 0x0000001B;
104 const sal_uInt16 AX_POS_TOPLEFT = 0;
105 const sal_uInt16 AX_POS_TOP = 1;
106 const sal_uInt16 AX_POS_TOPRIGHT = 2;
107 const sal_uInt16 AX_POS_LEFT = 3;
108 const sal_uInt16 AX_POS_CENTER = 4;
109 const sal_uInt16 AX_POS_RIGHT = 5;
110 const sal_uInt16 AX_POS_BOTTOMLEFT = 6;
111 const sal_uInt16 AX_POS_BOTTOM = 7;
112 const sal_uInt16 AX_POS_BOTTOMRIGHT = 8;
114 #define AX_PICPOS_IMPL( label, image ) ((AX_POS_##label << 16) | AX_POS_##image)
115 const sal_uInt32 AX_PICPOS_LEFTTOP = AX_PICPOS_IMPL( TOPRIGHT, TOPLEFT );
116 const sal_uInt32 AX_PICPOS_LEFTCENTER = AX_PICPOS_IMPL( RIGHT, LEFT );
117 const sal_uInt32 AX_PICPOS_LEFTBOTTOM = AX_PICPOS_IMPL( BOTTOMRIGHT, BOTTOMLEFT );
118 const sal_uInt32 AX_PICPOS_RIGHTTOP = AX_PICPOS_IMPL( TOPLEFT, TOPRIGHT );
119 const sal_uInt32 AX_PICPOS_RIGHTCENTER = AX_PICPOS_IMPL( LEFT, RIGHT );
120 const sal_uInt32 AX_PICPOS_RIGHTBOTTOM = AX_PICPOS_IMPL( BOTTOMLEFT, BOTTOMRIGHT );
121 const sal_uInt32 AX_PICPOS_ABOVELEFT = AX_PICPOS_IMPL( BOTTOMLEFT, TOPLEFT );
122 const sal_uInt32 AX_PICPOS_ABOVECENTER = AX_PICPOS_IMPL( BOTTOM, TOP );
123 const sal_uInt32 AX_PICPOS_ABOVERIGHT = AX_PICPOS_IMPL( BOTTOMRIGHT, TOPRIGHT );
124 const sal_uInt32 AX_PICPOS_BELOWLEFT = AX_PICPOS_IMPL( TOPLEFT, BOTTOMLEFT );
125 const sal_uInt32 AX_PICPOS_BELOWCENTER = AX_PICPOS_IMPL( TOP, BOTTOM );
126 const sal_uInt32 AX_PICPOS_BELOWRIGHT = AX_PICPOS_IMPL( TOPRIGHT, BOTTOMRIGHT );
127 const sal_uInt32 AX_PICPOS_CENTER = AX_PICPOS_IMPL( CENTER, CENTER );
128 #undef AX_PICPOS_IMPL
130 const sal_Int32 AX_MATCHENTRY_FIRSTLETTER = 0;
131 const sal_Int32 AX_MATCHENTRY_COMPLETE = 1;
132 const sal_Int32 AX_MATCHENTRY_NONE = 2;
134 const sal_Int32 AX_ORIENTATION_AUTO = -1;
135 const sal_Int32 AX_ORIENTATION_VERTICAL = 0;
136 const sal_Int32 AX_ORIENTATION_HORIZONTAL = 1;
138 const sal_Int32 AX_PROPTHUMB_ON = -1;
140 const sal_uInt32 AX_TABSTRIP_TABS = 0;
141 const sal_uInt32 AX_TABSTRIP_NONE = 2;
143 const sal_uInt32 AX_CONTAINER_ENABLED = 0x00000004;
144 const sal_uInt32 AX_CONTAINER_NOCLASSTABLE = 0x00008000;
146 const sal_uInt32 AX_CONTAINER_DEFFLAGS = 0x00000004;
148 const sal_Int32 AX_CONTAINER_DEFWIDTH = 4000;
149 const sal_Int32 AX_CONTAINER_DEFHEIGHT = 3000;
151 const sal_Int32 AX_CONTAINER_CYCLEALL = 0;
153 const sal_Int32 AX_CONTAINER_SCR_NONE = 0x00;
155 const sal_Int16 API_BORDER_NONE = 0;
156 const sal_Int16 API_BORDER_SUNKEN = 1;
157 const sal_Int16 API_BORDER_FLAT = 2;
159 const sal_Int16 API_STATE_UNCHECKED = 0;
160 const sal_Int16 API_STATE_CHECKED = 1;
161 const sal_Int16 API_STATE_DONTKNOW = 2;
163 /** Tries to extract a range address from a defined name. */
164 bool lclExtractRangeFromName( CellRangeAddress& orRangeAddr, const Reference< XModel >& rxDocModel, const OUString& rAddressString )
168 PropertySet aPropSet( rxDocModel );
169 Reference< XNameAccess > xRangesNA( aPropSet.getAnyProperty( PROP_NamedRanges ), UNO_QUERY_THROW );
170 Reference< XCellRangeReferrer > xReferrer( xRangesNA->getByName( rAddressString ), UNO_QUERY_THROW );
171 Reference< XCellRangeAddressable > xAddressable( xReferrer->getReferredCells(), UNO_QUERY_THROW );
172 orRangeAddr = xAddressable->getRangeAddress();
173 return true;
175 catch (const Exception& e)
177 SAL_WARN("oox", "exception: " << e.Message);
179 return false;
182 bool lclExtractAddressFromName( CellAddress& orAddress, const Reference< XModel >& rxDocModel, const OUString& rAddressString )
184 CellRangeAddress aRangeAddr;
185 if( lclExtractRangeFromName( aRangeAddr, rxDocModel, rAddressString ) &&
186 (aRangeAddr.StartColumn == aRangeAddr.EndColumn) &&
187 (aRangeAddr.StartRow == aRangeAddr.EndRow) )
189 orAddress.Sheet = aRangeAddr.Sheet;
190 orAddress.Column = aRangeAddr.StartColumn;
191 orAddress.Row = aRangeAddr.StartRow;
192 return true;
194 return false;
197 void lclPrepareConverter( PropertySet& rConverter, const Reference< XModel >& rxDocModel,
198 const OUString& rAddressString, sal_Int32 nRefSheet, bool bRange )
200 if( !rConverter.is() ) try
202 Reference< XMultiServiceFactory > xModelFactory( rxDocModel, UNO_QUERY_THROW );
203 OUString aServiceName = bRange ?
204 OUString( "com.sun.star.table.CellRangeAddressConversion" ) :
205 OUString( "com.sun.star.table.CellAddressConversion" );
206 rConverter.set( xModelFactory->createInstance( aServiceName ) );
208 catch (const Exception& e)
210 SAL_WARN("oox", "exception: " << e.Message);
212 rConverter.setProperty( PROP_XLA1Representation, rAddressString );
213 rConverter.setProperty( PROP_ReferenceSheet, nRefSheet );
216 } // namespace
218 ControlConverter::ControlConverter( const Reference< XModel >& rxDocModel,
219 const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ) :
220 mxDocModel( rxDocModel ),
221 mrGraphicHelper( rGraphicHelper ),
222 mbDefaultColorBgr( bDefaultColorBgr )
224 OSL_ENSURE( mxDocModel.is(), "ControlConverter::ControlConverter - missing document model" );
227 ControlConverter::~ControlConverter()
231 // Generic conversion ---------------------------------------------------------
233 void ControlConverter::convertPosition( PropertyMap& rPropMap, const AxPairData& rPos ) const
235 // position is given in 1/100 mm, UNO needs AppFont units
236 awt::Point aAppFontPos = mrGraphicHelper.convertHmmToAppFont( awt::Point( rPos.first, rPos.second ) );
237 rPropMap.setProperty( PROP_PositionX, aAppFontPos.X );
238 rPropMap.setProperty( PROP_PositionY, aAppFontPos.Y );
241 void ControlConverter::convertSize( PropertyMap& rPropMap, const AxPairData& rSize ) const
243 // size is given in 1/100 mm, UNO needs AppFont units
244 awt::Size aAppFontSize = mrGraphicHelper.convertHmmToAppFont( awt::Size( rSize.first, rSize.second ) );
245 rPropMap.setProperty( PROP_Width, aAppFontSize.Width );
246 rPropMap.setProperty( PROP_Height, aAppFontSize.Height );
249 void ControlConverter::convertColor( PropertyMap& rPropMap, sal_Int32 nPropId, sal_uInt32 nOleColor ) const
251 rPropMap.setProperty( nPropId, OleHelper::decodeOleColor( mrGraphicHelper, nOleColor, mbDefaultColorBgr ) );
254 void ControlConverter::convertToMSColor( PropertySet& rPropSet, sal_Int32 nPropId, sal_uInt32& nOleColor, sal_uInt32 nDefault )
256 sal_uInt32 nRGB = 0;
257 if (rPropSet.getProperty( nRGB, nPropId ))
258 nOleColor = OleHelper::encodeOleColor( nRGB );
259 else
260 nOleColor = nDefault;
262 void ControlConverter::convertPicture( PropertyMap& rPropMap, const StreamDataSequence& rPicData ) const
264 if( rPicData.hasElements() )
266 OUString aGraphicUrl = mrGraphicHelper.importGraphicObject( rPicData );
267 if( !aGraphicUrl.isEmpty() )
268 rPropMap.setProperty( PROP_ImageURL, aGraphicUrl );
272 void ControlConverter::convertOrientation( PropertyMap& rPropMap, bool bHorizontal )
274 sal_Int32 nScrollOrient = bHorizontal ? ScrollBarOrientation::HORIZONTAL : ScrollBarOrientation::VERTICAL;
275 rPropMap.setProperty( PROP_Orientation, nScrollOrient );
278 void ControlConverter::convertToMSOrientation( PropertySet& rPropSet, bool& bHorizontal )
280 sal_Int32 nScrollOrient = ScrollBarOrientation::HORIZONTAL;
281 if ( rPropSet.getProperty( nScrollOrient, PROP_Orientation ) )
282 bHorizontal = ( nScrollOrient == ScrollBarOrientation::HORIZONTAL );
285 void ControlConverter::convertVerticalAlign( PropertyMap& rPropMap, sal_Int32 nVerticalAlign )
287 VerticalAlignment eAlign = VerticalAlignment_TOP;
288 switch( nVerticalAlign )
290 case XML_Top: eAlign = VerticalAlignment_TOP; break;
291 case XML_Center: eAlign = VerticalAlignment_MIDDLE; break;
292 case XML_Bottom: eAlign = VerticalAlignment_BOTTOM; break;
294 rPropMap.setProperty( PROP_VerticalAlign, eAlign );
297 void ControlConverter::convertScrollabilitySettings( PropertyMap& rPropMap,
298 const AxPairData& rScrollPos, const AxPairData& rScrollArea,
299 sal_Int32 nScrollBars ) const
301 awt::Size tmpSize = mrGraphicHelper.convertHmmToAppFont( awt::Size( rScrollArea.first, rScrollArea.second ) );
302 awt::Point tmpPos = mrGraphicHelper.convertHmmToAppFont( awt::Point( rScrollPos.first, rScrollPos.second ) );
303 rPropMap.setProperty( PROP_ScrollHeight, tmpSize.Height );
304 rPropMap.setProperty( PROP_ScrollWidth, tmpSize.Width );
305 rPropMap.setProperty( PROP_ScrollTop, tmpPos.Y );
306 rPropMap.setProperty( PROP_ScrollLeft, tmpPos.X );
307 rPropMap.setProperty( PROP_HScroll, ( nScrollBars & 0x1 ) == 0x1 );
308 rPropMap.setProperty( PROP_VScroll, ( nScrollBars & 0x2 ) == 0x2 );
311 void ControlConverter::convertScrollBar( PropertyMap& rPropMap,
312 sal_Int32 nMin, sal_Int32 nMax, sal_Int32 nPosition,
313 sal_Int32 nSmallChange, sal_Int32 nLargeChange, bool bAwtModel )
315 rPropMap.setProperty( PROP_ScrollValueMin, ::std::min( nMin, nMax ) );
316 rPropMap.setProperty( PROP_ScrollValueMax, ::std::max( nMin, nMax ) );
317 rPropMap.setProperty( PROP_LineIncrement, nSmallChange );
318 rPropMap.setProperty( PROP_BlockIncrement, nLargeChange );
319 rPropMap.setProperty( bAwtModel ? PROP_ScrollValue : PROP_DefaultScrollValue, nPosition );
322 void ControlConverter::bindToSources( const Reference< XControlModel >& rxCtrlModel,
323 const OUString& rCtrlSource, const OUString& rRowSource, sal_Int32 nRefSheet ) const
325 // value binding
326 if( !rCtrlSource.isEmpty() ) try
328 // first check if the XBindableValue interface is supported
329 Reference< XBindableValue > xBindable( rxCtrlModel, UNO_QUERY_THROW );
331 // convert address string to cell address struct
332 CellAddress aAddress;
333 if( !lclExtractAddressFromName( aAddress, mxDocModel, rCtrlSource ) )
335 lclPrepareConverter( maAddressConverter, mxDocModel, rCtrlSource, nRefSheet, false );
336 if( !maAddressConverter.getProperty( aAddress, PROP_Address ) )
337 throw RuntimeException();
340 // create argument sequence
341 NamedValue aValue;
342 aValue.Name = "BoundCell";
343 aValue.Value <<= aAddress;
344 Sequence< Any > aArgs( 1 );
345 aArgs[ 0 ] <<= aValue;
347 // create the CellValueBinding instance and set at the control model
348 Reference< XMultiServiceFactory > xModelFactory( mxDocModel, UNO_QUERY_THROW );
349 Reference< XValueBinding > xBinding( xModelFactory->createInstanceWithArguments( "com.sun.star.table.CellValueBinding", aArgs ), UNO_QUERY_THROW );
350 xBindable->setValueBinding( xBinding );
352 catch (const Exception& e)
354 SAL_WARN("oox", "exception: " << e.Message);
357 // list entry source
358 if( !rRowSource.isEmpty() ) try
360 // first check if the XListEntrySink interface is supported
361 Reference< XListEntrySink > xEntrySink( rxCtrlModel, UNO_QUERY_THROW );
363 // convert address string to cell range address struct
364 CellRangeAddress aRangeAddr;
365 if( !lclExtractRangeFromName( aRangeAddr, mxDocModel, rRowSource ) )
367 lclPrepareConverter( maRangeConverter, mxDocModel, rRowSource, nRefSheet, true );
368 if( !maRangeConverter.getProperty( aRangeAddr, PROP_Address ) )
369 throw RuntimeException();
372 // create argument sequence
373 NamedValue aValue;
374 aValue.Name = "CellRange";
375 aValue.Value <<= aRangeAddr;
376 Sequence< Any > aArgs( 1 );
377 aArgs[ 0 ] <<= aValue;
379 // create the EntrySource instance and set at the control model
380 Reference< XMultiServiceFactory > xModelFactory( mxDocModel, UNO_QUERY_THROW );
381 Reference< XListEntrySource > xEntrySource( xModelFactory->createInstanceWithArguments("com.sun.star.table.CellRangeListSource", aArgs ), UNO_QUERY_THROW );
382 xEntrySink->setListEntrySource( xEntrySource );
384 catch (const Exception& e)
386 SAL_WARN("oox", "exception: " << e.Message);
390 // ActiveX (Forms 2.0) specific conversion ------------------------------------
392 void ControlConverter::convertAxBackground( PropertyMap& rPropMap,
393 sal_uInt32 nBackColor, sal_uInt32 nFlags, ApiTransparencyMode eTranspMode ) const
395 bool bOpaque = getFlag( nFlags, AX_FLAGS_OPAQUE );
396 switch( eTranspMode )
398 case ApiTransparencyMode::NotSupported:
399 // fake transparency by using system window background if needed
400 convertColor( rPropMap, PROP_BackgroundColor, bOpaque ? nBackColor : AX_SYSCOLOR_WINDOWBACK );
401 break;
402 case ApiTransparencyMode::Void:
403 // keep transparency by leaving the (void) default property value
404 if( bOpaque )
405 convertColor( rPropMap, PROP_BackgroundColor, nBackColor );
406 break;
410 void ControlConverter::convertAxBorder( PropertyMap& rPropMap,
411 sal_uInt32 nBorderColor, sal_Int32 nBorderStyle, sal_Int32 nSpecialEffect ) const
413 sal_Int16 nBorder = (nBorderStyle == AX_BORDERSTYLE_SINGLE) ? API_BORDER_FLAT :
414 ((nSpecialEffect == AX_SPECIALEFFECT_FLAT) ? API_BORDER_NONE : API_BORDER_SUNKEN);
415 rPropMap.setProperty( PROP_Border, nBorder );
416 convertColor( rPropMap, PROP_BorderColor, nBorderColor );
419 void ControlConverter::convertToAxBorder( PropertySet& rPropSet,
420 sal_uInt32& nBorderColor, sal_Int32& nBorderStyle, sal_Int32& nSpecialEffect )
422 sal_Int16 nBorder = API_BORDER_NONE;
423 rPropSet.getProperty( nBorder, PROP_Border );
424 nBorderStyle = AX_BORDERSTYLE_NONE;
425 nSpecialEffect = AX_SPECIALEFFECT_FLAT;
426 switch ( nBorder )
428 case API_BORDER_FLAT:
429 nBorderStyle = AX_BORDERSTYLE_SINGLE;
430 break;
431 case API_BORDER_SUNKEN:
432 nSpecialEffect = AX_SPECIALEFFECT_SUNKEN;
433 break;
434 case API_BORDER_NONE:
435 default:
436 break;
438 convertToMSColor( rPropSet, PROP_BorderColor, nBorderColor );
441 void ControlConverter::convertAxVisualEffect( PropertyMap& rPropMap, sal_Int32 nSpecialEffect )
443 sal_Int16 nVisualEffect = (nSpecialEffect == AX_SPECIALEFFECT_FLAT) ? VisualEffect::FLAT : VisualEffect::LOOK3D;
444 rPropMap.setProperty( PROP_VisualEffect, nVisualEffect );
447 void ControlConverter::convertToAxVisualEffect( PropertySet& rPropSet, sal_Int32& nSpecialEffect )
449 sal_Int16 nVisualEffect = AX_SPECIALEFFECT_FLAT;
450 rPropSet.getProperty( nVisualEffect, PROP_VisualEffect );
451 // is this appropriate AX_SPECIALEFFECT_XXXX value ?
452 if (nVisualEffect == VisualEffect::LOOK3D )
453 nSpecialEffect = AX_SPECIALEFFECT_RAISED;
456 void ControlConverter::convertAxPicture( PropertyMap& rPropMap, const StreamDataSequence& rPicData, sal_uInt32 nPicPos ) const
458 // the picture
459 convertPicture( rPropMap, rPicData );
461 // picture position
462 sal_Int16 nImagePos = ImagePosition::LeftCenter;
463 switch( nPicPos )
465 case AX_PICPOS_LEFTTOP: nImagePos = ImagePosition::LeftTop; break;
466 case AX_PICPOS_LEFTCENTER: nImagePos = ImagePosition::LeftCenter; break;
467 case AX_PICPOS_LEFTBOTTOM: nImagePos = ImagePosition::LeftBottom; break;
468 case AX_PICPOS_RIGHTTOP: nImagePos = ImagePosition::RightTop; break;
469 case AX_PICPOS_RIGHTCENTER: nImagePos = ImagePosition::RightCenter; break;
470 case AX_PICPOS_RIGHTBOTTOM: nImagePos = ImagePosition::RightBottom; break;
471 case AX_PICPOS_ABOVELEFT: nImagePos = ImagePosition::AboveLeft; break;
472 case AX_PICPOS_ABOVECENTER: nImagePos = ImagePosition::AboveCenter; break;
473 case AX_PICPOS_ABOVERIGHT: nImagePos = ImagePosition::AboveRight; break;
474 case AX_PICPOS_BELOWLEFT: nImagePos = ImagePosition::BelowLeft; break;
475 case AX_PICPOS_BELOWCENTER: nImagePos = ImagePosition::BelowCenter; break;
476 case AX_PICPOS_BELOWRIGHT: nImagePos = ImagePosition::BelowRight; break;
477 case AX_PICPOS_CENTER: nImagePos = ImagePosition::Centered; break;
478 default: OSL_FAIL( "ControlConverter::convertAxPicture - unknown picture position" );
480 rPropMap.setProperty( PROP_ImagePosition, nImagePos );
483 void ControlConverter::convertAxPicture( PropertyMap& rPropMap, const StreamDataSequence& rPicData,
484 sal_Int32 nPicSizeMode ) const
486 // the picture
487 convertPicture( rPropMap, rPicData );
489 // picture scale mode
490 sal_Int16 nScaleMode = ImageScaleMode::NONE;
491 switch( nPicSizeMode )
493 case AX_PICSIZE_CLIP: nScaleMode = ImageScaleMode::NONE; break;
494 case AX_PICSIZE_STRETCH: nScaleMode = ImageScaleMode::ANISOTROPIC; break;
495 case AX_PICSIZE_ZOOM: nScaleMode = ImageScaleMode::ISOTROPIC; break;
496 default: OSL_FAIL( "ControlConverter::convertAxPicture - unknown picture size mode" );
498 rPropMap.setProperty( PROP_ScaleMode, nScaleMode );
501 void ControlConverter::convertAxState( PropertyMap& rPropMap,
502 const OUString& rValue, sal_Int32 nMultiSelect, ApiDefaultStateMode eDefStateMode, bool bAwtModel )
504 bool bBooleanState = eDefStateMode == API_DEFAULTSTATE_BOOLEAN;
505 bool bSupportsTriState = eDefStateMode == API_DEFAULTSTATE_TRISTATE;
507 // state
508 sal_Int16 nState = bSupportsTriState ? API_STATE_DONTKNOW : API_STATE_UNCHECKED;
509 if( rValue.getLength() == 1 ) switch( rValue[ 0 ] )
511 case '0': nState = API_STATE_UNCHECKED; break;
512 case '1': nState = API_STATE_CHECKED; break;
513 // any other string (also empty) means 'dontknow'
515 sal_Int32 nPropId = bAwtModel ? PROP_State : PROP_DefaultState;
516 if( bBooleanState )
517 rPropMap.setProperty( nPropId, nState != API_STATE_UNCHECKED );
518 else
519 rPropMap.setProperty( nPropId, nState );
521 // tristate
522 if( bSupportsTriState )
523 rPropMap.setProperty( PROP_TriState, nMultiSelect == AX_SELECTION_MULTI );
526 void ControlConverter::convertToAxState( PropertySet& rPropSet,
527 OUString& rValue, sal_Int32& nMultiSelect, ApiDefaultStateMode eDefStateMode, bool /*bAwtModel*/ )
529 bool bSupportsTriState = eDefStateMode == API_DEFAULTSTATE_TRISTATE;
531 sal_Int16 nState = API_STATE_DONTKNOW;
533 bool bTmp = false;
534 // need to use State for current state ( I think this is regardless of whether
535 // control is awt or not )
536 rPropSet.getProperty( nState, PROP_State );
538 rValue.clear(); // empty e.g. 'don't know'
539 if ( nState == API_STATE_UNCHECKED )
540 rValue = "0";
541 else if ( nState == API_STATE_CHECKED )
542 rValue = "1";
544 // tristate
545 if( bSupportsTriState && rPropSet.getProperty( bTmp, PROP_TriState ) )
546 nMultiSelect = AX_SELECTION_MULTI;
549 void ControlConverter::convertAxOrientation( PropertyMap& rPropMap,
550 const AxPairData& rSize, sal_Int32 nOrientation )
552 bool bHorizontal = true;
553 switch( nOrientation )
555 case AX_ORIENTATION_AUTO: bHorizontal = rSize.first > rSize.second; break;
556 case AX_ORIENTATION_VERTICAL: bHorizontal = false; break;
557 case AX_ORIENTATION_HORIZONTAL: bHorizontal = true; break;
558 default: OSL_FAIL( "ControlConverter::convertAxOrientation - unknown orientation" );
560 convertOrientation( rPropMap, bHorizontal );
563 void ControlConverter::convertToAxOrientation( PropertySet& rPropSet,
564 const AxPairData& /*rSize*/, sal_Int32& nOrientation )
566 bool bHorizontal = true;
567 convertToMSOrientation( rPropSet, bHorizontal );
569 if ( bHorizontal )
570 nOrientation = AX_ORIENTATION_HORIZONTAL;
571 else
572 nOrientation = AX_ORIENTATION_VERTICAL;
575 ControlModelBase::ControlModelBase() :
576 maSize( 0, 0 ),
577 mbAwtModel( false )
581 ControlModelBase::~ControlModelBase()
585 OUString ControlModelBase::getServiceName() const
587 ApiControlType eCtrlType = getControlType();
588 if( mbAwtModel ) switch( eCtrlType )
590 case API_CONTROL_BUTTON: return OUString( "com.sun.star.awt.UnoControlButtonModel" );
591 case API_CONTROL_FIXEDTEXT: return OUString( "com.sun.star.awt.UnoControlFixedTextModel" );
592 case API_CONTROL_IMAGE: return OUString( "com.sun.star.awt.UnoControlImageControlModel" );
593 case API_CONTROL_CHECKBOX: return OUString( "com.sun.star.awt.UnoControlCheckBoxModel" );
594 case API_CONTROL_RADIOBUTTON: return OUString( "com.sun.star.form.component.RadioButton" );
595 case API_CONTROL_EDIT: return OUString( "com.sun.star.awt.UnoControlEditModel" );
596 case API_CONTROL_NUMERIC: return OUString( "com.sun.star.awt.UnoControlNumericFieldModel" );
597 case API_CONTROL_LISTBOX: return OUString( "com.sun.star.form.component.ListBox" );
598 case API_CONTROL_COMBOBOX: return OUString( "com.sun.star.form.component.ComboBox" );
599 case API_CONTROL_SPINBUTTON: return OUString( "com.sun.star.form.component.SpinButton" );
600 case API_CONTROL_SCROLLBAR: return OUString( "com.sun.star.form.component.ScrollBar" );
601 case API_CONTROL_PROGRESSBAR: return OUString( "com.sun.star.awt.UnoControlProgressBarModel" );
602 case API_CONTROL_GROUPBOX: return OUString( "com.sun.star.form.component.GroupBox" );
603 case API_CONTROL_FRAME: return OUString( "com.sun.star.awt.UnoFrameModel" );
604 case API_CONTROL_PAGE: return OUString( "com.sun.star.awt.UnoPageModel" );
605 case API_CONTROL_MULTIPAGE: return OUString( "com.sun.star.awt.UnoMultiPageModel" );
606 case API_CONTROL_DIALOG: return OUString( "com.sun.star.awt.UnoControlDialogModel" );
607 default: OSL_FAIL( "ControlModelBase::getServiceName - no AWT model service supported" );
609 else switch( eCtrlType )
611 case API_CONTROL_BUTTON: return OUString( "com.sun.star.form.component.CommandButton" );
612 case API_CONTROL_FIXEDTEXT: return OUString( "com.sun.star.form.component.FixedText" );
613 case API_CONTROL_IMAGE: return OUString( "com.sun.star.form.component.DatabaseImageControl" );
614 case API_CONTROL_CHECKBOX: return OUString( "com.sun.star.form.component.CheckBox" );
615 case API_CONTROL_RADIOBUTTON: return OUString( "com.sun.star.form.component.RadioButton" );
616 case API_CONTROL_EDIT: return OUString( "com.sun.star.form.component.TextField" );
617 case API_CONTROL_NUMERIC: return OUString( "com.sun.star.form.component.NumericField" );
618 case API_CONTROL_LISTBOX: return OUString( "com.sun.star.form.component.ListBox" );
619 case API_CONTROL_COMBOBOX: return OUString( "com.sun.star.form.component.ComboBox" );
620 case API_CONTROL_SPINBUTTON: return OUString( "com.sun.star.form.component.SpinButton" );
621 case API_CONTROL_SCROLLBAR: return OUString( "com.sun.star.form.component.ScrollBar" );
622 case API_CONTROL_GROUPBOX: return OUString( "com.sun.star.form.component.GroupBox" );
623 default: OSL_FAIL( "ControlModelBase::getServiceName - no form component service supported" );
625 return OUString();
628 void ControlModelBase::importProperty( sal_Int32 /*nPropId*/, const OUString& /*rValue*/ )
632 void ControlModelBase::importPictureData( sal_Int32 /*nPropId*/, BinaryInputStream& /*rInStrm*/ )
636 void ControlModelBase::convertProperties( PropertyMap& /*rPropMap*/, const ControlConverter& /*rConv*/ ) const
640 void ControlModelBase::convertFromProperties( PropertySet& /*rPropMap*/, const ControlConverter& /*rConv*/ )
644 void ControlModelBase::convertSize( PropertyMap& rPropMap, const ControlConverter& rConv ) const
646 rConv.convertSize( rPropMap, maSize );
649 ComCtlModelBase::ComCtlModelBase( sal_uInt32 nDataPartId5, sal_uInt32 nDataPartId6,
650 sal_uInt16 nVersion ) :
651 maFontData( "Tahoma", 82500 ),
652 mnFlags( 0 ),
653 mnVersion( nVersion ),
654 mnDataPartId5( nDataPartId5 ),
655 mnDataPartId6( nDataPartId6 ),
656 mbCommonPart( true ),
657 mbComplexPart( true )
661 bool ComCtlModelBase::importBinaryModel( BinaryInputStream& rInStrm )
663 // read initial size part and header of the control data part
664 if( importSizePart( rInStrm ) && readPartHeader( rInStrm, getDataPartId(), mnVersion ) )
666 // if flags part exists, the first int32 of the data part contains its size
667 sal_uInt32 nCommonPartSize = 0;
668 if (mbCommonPart)
669 nCommonPartSize = rInStrm.readuInt32();
670 // implementations must read the exact amount of data, stream must point to its end afterwards
671 importControlData( rInStrm );
672 // read following parts
673 if( !rInStrm.isEof() &&
674 (!mbCommonPart || importCommonPart( rInStrm, nCommonPartSize )) &&
675 (!mbComplexPart || importComplexPart( rInStrm )) )
677 return !rInStrm.isEof();
680 return false;
683 void ComCtlModelBase::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
685 if( mbCommonPart )
686 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, COMCTL_COMMON_ENABLED ) );
687 ControlModelBase::convertProperties( rPropMap, rConv );
690 sal_uInt32 ComCtlModelBase::getDataPartId() const
692 switch( mnVersion )
694 case COMCTL_VERSION_50: return mnDataPartId5;
695 case COMCTL_VERSION_60: return mnDataPartId6;
697 OSL_FAIL( "ComCtlObjectBase::getDataPartId - unexpected version" );
698 return SAL_MAX_UINT32;
701 bool ComCtlModelBase::readPartHeader( BinaryInputStream& rInStrm, sal_uInt32 nExpPartId, sal_uInt16 nExpMajor, sal_uInt16 nExpMinor )
703 // no idea if all this is correct...
704 sal_uInt32 nPartId = rInStrm.readuInt32();
705 sal_uInt16 nMinor = rInStrm.readuInt16();
706 sal_uInt16 nMajor = rInStrm.readuInt16();
707 bool bPartId = nPartId == nExpPartId;
708 OSL_ENSURE( bPartId, "ComCtlObjectBase::readPartHeader - unexpected part identifier" );
709 bool bVersion = ((nExpMajor == SAL_MAX_UINT16) || (nExpMajor == nMajor)) && ((nExpMinor == SAL_MAX_UINT16) || (nExpMinor == nMinor));
710 OSL_ENSURE( bVersion, "ComCtlObjectBase::readPartHeader - unexpected part version" );
711 return !rInStrm.isEof() && bPartId && bVersion;
714 bool ComCtlModelBase::importSizePart( BinaryInputStream& rInStrm )
716 if( readPartHeader( rInStrm, COMCTL_ID_SIZE, 0, 8 ) )
718 maSize.first = rInStrm.readInt32();
719 maSize.second = rInStrm.readInt32();
720 return !rInStrm.isEof();
722 return false;
725 bool ComCtlModelBase::importCommonPart( BinaryInputStream& rInStrm, sal_uInt32 nPartSize )
727 sal_Int64 nEndPos = rInStrm.tell() + nPartSize;
728 if( (nPartSize >= 16) && readPartHeader( rInStrm, COMCTL_ID_COMMONDATA, 5, 0 ) )
730 rInStrm.skip( 4 );
731 mnFlags = rInStrm.readuInt32();
732 rInStrm.seek( nEndPos );
733 return !rInStrm.isEof();
735 return false;
738 bool ComCtlModelBase::importComplexPart( BinaryInputStream& rInStrm )
740 if( readPartHeader( rInStrm, COMCTL_ID_COMPLEXDATA, 5, 1 ) )
742 sal_uInt32 nContFlags = rInStrm.readuInt32();
743 bool bReadOk =
744 (!getFlag( nContFlags, COMCTL_COMPLEX_FONT ) || OleHelper::importStdFont( maFontData, rInStrm, true )) &&
745 (!getFlag( nContFlags, COMCTL_COMPLEX_MOUSEICON ) || OleHelper::importStdPic( maMouseIcon, rInStrm, true ));
746 return bReadOk && !rInStrm.isEof();
748 return false;
751 ComCtlScrollBarModel::ComCtlScrollBarModel( sal_uInt16 nVersion ) :
752 ComCtlModelBase( SAL_MAX_UINT32, COMCTL_ID_SCROLLBAR_60, nVersion ),
753 mnScrollBarFlags( 0x00000011 ),
754 mnLargeChange( 1 ),
755 mnSmallChange( 1 ),
756 mnMin( 0 ),
757 mnMax( 32767 ),
758 mnPosition( 0 )
762 ApiControlType ComCtlScrollBarModel::getControlType() const
764 return API_CONTROL_SCROLLBAR;
767 void ComCtlScrollBarModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
769 rPropMap.setProperty( PROP_Border, API_BORDER_NONE );
770 ControlConverter::convertOrientation( rPropMap, getFlag( mnScrollBarFlags, COMCTL_SCROLLBAR_HOR ) );
771 ControlConverter::convertScrollBar( rPropMap, mnMin, mnMax, mnPosition, mnSmallChange, mnLargeChange, mbAwtModel );
772 ComCtlModelBase::convertProperties( rPropMap, rConv );
775 void ComCtlScrollBarModel::importControlData( BinaryInputStream& rInStrm )
777 mnScrollBarFlags = rInStrm.readuInt32();
778 mnLargeChange = rInStrm.readInt32();
779 mnSmallChange = rInStrm.readInt32();
780 mnMin = rInStrm.readInt32();
781 mnMax = rInStrm.readInt32();
782 mnPosition = rInStrm.readInt32();
785 ComCtlProgressBarModel::ComCtlProgressBarModel( sal_uInt16 nVersion ) :
786 ComCtlModelBase( COMCTL_ID_PROGRESSBAR_50, COMCTL_ID_PROGRESSBAR_60, nVersion ),
787 mfMin( 0.0 ),
788 mfMax( 100.0 ),
789 mnVertical( 0 ),
790 mnSmooth( 0 )
794 ApiControlType ComCtlProgressBarModel::getControlType() const
796 return API_CONTROL_PROGRESSBAR;
799 void ComCtlProgressBarModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
801 sal_uInt16 nBorder = getFlag( mnFlags, COMCTL_COMMON_3DBORDER ) ? API_BORDER_SUNKEN :
802 (getFlag( mnFlags, COMCTL_COMMON_FLATBORDER ) ? API_BORDER_FLAT : API_BORDER_NONE);
803 rPropMap.setProperty( PROP_Border, nBorder );
804 rPropMap.setProperty( PROP_ProgressValueMin, getLimitedValue< sal_Int32, double >( ::std::min( mfMin, mfMax ), 0.0, SAL_MAX_INT32 ) );
805 rPropMap.setProperty( PROP_ProgressValueMax, getLimitedValue< sal_Int32, double >( ::std::max( mfMin, mfMax ), 0.0, SAL_MAX_INT32 ) );
806 // ComCtl model does not provide current value?
807 ComCtlModelBase::convertProperties( rPropMap, rConv );
810 void ComCtlProgressBarModel::importControlData( BinaryInputStream& rInStrm )
812 mfMin = rInStrm.readFloat();
813 mfMax = rInStrm.readFloat();
814 if( mnVersion == COMCTL_VERSION_60 )
816 mnVertical = rInStrm.readuInt16();
817 mnSmooth = rInStrm.readuInt16();
821 AxControlModelBase::AxControlModelBase()
825 void AxControlModelBase::importProperty( sal_Int32 nPropId, const OUString& rValue )
827 switch( nPropId )
829 // size of the control shape: format is "width;height"
830 case XML_Size:
832 sal_Int32 nSepPos = rValue.indexOf( ';' );
833 OSL_ENSURE( nSepPos >= 0, "AxControlModelBase::importProperty - missing separator in 'Size' property" );
834 if( nSepPos >= 0 )
836 maSize.first = rValue.copy( 0, nSepPos ).toInt32();
837 maSize.second = rValue.copy( nSepPos + 1 ).toInt32();
840 break;
844 AxFontDataModel::AxFontDataModel( bool bSupportsAlign ) :
845 mbSupportsAlign( bSupportsAlign )
849 void AxFontDataModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
851 switch( nPropId )
853 case XML_FontName: maFontData.maFontName = rValue; break;
854 case XML_FontEffects:
855 maFontData.mnFontEffects = static_cast<AxFontFlags>(AttributeConversion::decodeUnsigned( rValue ));
856 break;
857 case XML_FontHeight: maFontData.mnFontHeight = AttributeConversion::decodeInteger( rValue ); break;
858 case XML_FontCharSet: maFontData.mnFontCharSet = AttributeConversion::decodeInteger( rValue ); break;
859 case XML_ParagraphAlign:
860 maFontData.mnHorAlign = static_cast<AxHorizontalAlign>(AttributeConversion::decodeInteger( rValue ));
861 break;
862 default: AxControlModelBase::importProperty( nPropId, rValue );
866 bool AxFontDataModel::importBinaryModel( BinaryInputStream& rInStrm )
868 return maFontData.importBinaryModel( rInStrm );
871 void AxFontDataModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
873 maFontData.exportBinaryModel( rOutStrm );
875 void AxFontDataModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
877 // font name
878 if( !maFontData.maFontName.isEmpty() )
879 rPropMap.setProperty( PROP_FontName, maFontData.maFontName );
881 // font effects
882 rPropMap.setProperty( PROP_FontWeight, maFontData.mnFontEffects & AxFontFlags::Bold ? awt::FontWeight::BOLD : awt::FontWeight::NORMAL );
883 rPropMap.setProperty( PROP_FontSlant, maFontData.mnFontEffects & AxFontFlags::Italic ? FontSlant_ITALIC : FontSlant_NONE );
884 if (maFontData.mnFontEffects & AxFontFlags::Underline)
885 rPropMap.setProperty( PROP_FontUnderline, maFontData.mbDblUnderline ? awt::FontUnderline::DOUBLE : awt::FontUnderline::SINGLE );
886 else
887 rPropMap.setProperty( PROP_FontUnderline, awt::FontUnderline::NONE );
888 rPropMap.setProperty( PROP_FontStrikeout, maFontData.mnFontEffects & AxFontFlags::Strikeout ? awt::FontStrikeout::SINGLE : awt::FontStrikeout::NONE );
889 rPropMap.setProperty( PROP_FontHeight, maFontData.getHeightPoints() );
891 // font character set
892 rtl_TextEncoding eFontEnc = RTL_TEXTENCODING_DONTKNOW;
893 if( (0 <= maFontData.mnFontCharSet) && (maFontData.mnFontCharSet <= SAL_MAX_UINT8) )
894 eFontEnc = rtl_getTextEncodingFromWindowsCharset( static_cast< sal_uInt8 >( maFontData.mnFontCharSet ) );
895 if( eFontEnc != RTL_TEXTENCODING_DONTKNOW )
896 rPropMap.setProperty( PROP_FontCharset, static_cast< sal_Int16 >( eFontEnc ) );
898 // text alignment
899 if( mbSupportsAlign )
901 sal_Int32 nAlign = awt::TextAlign::LEFT;
902 switch( maFontData.mnHorAlign )
904 case AxHorizontalAlign::Left: nAlign = awt::TextAlign::LEFT; break;
905 case AxHorizontalAlign::Right: nAlign = awt::TextAlign::RIGHT; break;
906 case AxHorizontalAlign::Center: nAlign = awt::TextAlign::CENTER; break;
907 default: OSL_FAIL( "AxFontDataModel::convertProperties - unknown text alignment" );
909 // form controls expect short value
910 rPropMap.setProperty( PROP_Align, static_cast< sal_Int16 >( nAlign ) );
913 // process base class properties
914 AxControlModelBase::convertProperties( rPropMap, rConv );
917 void AxFontDataModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& /*rConv */)
919 rPropSet.getProperty( maFontData.maFontName, PROP_FontName );
920 float fontWeight = (float)0;
921 if ( rPropSet.getProperty(fontWeight, PROP_FontWeight ) )
922 setFlag( maFontData.mnFontEffects, AxFontFlags::Bold, ( fontWeight == awt::FontWeight::BOLD ) );
923 FontSlant nSlant = FontSlant_NONE;
924 if ( rPropSet.getProperty( nSlant, PROP_FontSlant ) )
925 setFlag( maFontData.mnFontEffects, AxFontFlags::Italic, ( nSlant == FontSlant_ITALIC ) );
927 sal_Int16 nUnderLine = awt::FontUnderline::NONE;
928 if ( rPropSet.getProperty( nUnderLine, PROP_FontUnderline ) )
929 setFlag( maFontData.mnFontEffects, AxFontFlags::Underline, nUnderLine != awt::FontUnderline::NONE );
930 sal_Int16 nStrikeout = awt::FontStrikeout::NONE ;
931 if ( rPropSet.getProperty( nStrikeout, PROP_FontStrikeout ) )
932 setFlag( maFontData.mnFontEffects, AxFontFlags::Strikeout, nStrikeout != awt::FontStrikeout::NONE );
934 float fontHeight = 0.0;
935 if ( rPropSet.getProperty( fontHeight, PROP_FontHeight ) )
936 maFontData.setHeightPoints( static_cast< sal_Int16 >( fontHeight ) );
938 // TODO - handle textencoding
939 sal_Int16 nAlign = 0;
940 if ( rPropSet.getProperty( nAlign, PROP_Align ) )
942 switch ( nAlign )
944 case awt::TextAlign::LEFT: maFontData.mnHorAlign = AxHorizontalAlign::Left; break;
945 case awt::TextAlign::RIGHT: maFontData.mnHorAlign = AxHorizontalAlign::Right; break;
946 case awt::TextAlign::CENTER: maFontData.mnHorAlign = AxHorizontalAlign::Center; break;
947 default: OSL_FAIL( "AxFontDataModel::convertFromProperties - unknown text alignment" );
952 AxCommandButtonModel::AxCommandButtonModel() :
953 mnTextColor( AX_SYSCOLOR_BUTTONTEXT ),
954 mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
955 mnFlags( AX_CMDBUTTON_DEFFLAGS ),
956 mnPicturePos( AX_PICPOS_ABOVECENTER ),
957 mnVerticalAlign( XML_Center ),
958 mbFocusOnClick( true )
962 void AxCommandButtonModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
964 switch( nPropId )
966 case XML_Caption: maCaption = rValue; break;
967 case XML_ForeColor: mnTextColor = AttributeConversion::decodeUnsigned( rValue ); break;
968 case XML_BackColor: mnBackColor = AttributeConversion::decodeUnsigned( rValue ); break;
969 case XML_VariousPropertyBits: mnFlags = AttributeConversion::decodeUnsigned( rValue ); break;
970 case XML_PicturePosition: mnPicturePos = AttributeConversion::decodeUnsigned( rValue ); break;
971 case XML_TakeFocusOnClick: mbFocusOnClick = AttributeConversion::decodeInteger( rValue ) != 0; break;
972 default: AxFontDataModel::importProperty( nPropId, rValue );
976 void AxCommandButtonModel::importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm )
978 switch( nPropId )
980 case XML_Picture: OleHelper::importStdPic( maPictureData, rInStrm, true ); break;
981 default: AxFontDataModel::importPictureData( nPropId, rInStrm );
985 bool AxCommandButtonModel::importBinaryModel( BinaryInputStream& rInStrm )
987 AxBinaryPropertyReader aReader( rInStrm );
988 aReader.readIntProperty< sal_uInt32 >( mnTextColor );
989 aReader.readIntProperty< sal_uInt32 >( mnBackColor );
990 aReader.readIntProperty< sal_uInt32 >( mnFlags );
991 aReader.readStringProperty( maCaption );
992 aReader.readIntProperty< sal_uInt32 >( mnPicturePos );
993 aReader.readPairProperty( maSize );
994 aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
995 aReader.readPictureProperty( maPictureData );
996 aReader.skipIntProperty< sal_uInt16 >(); // accelerator
997 aReader.readBoolProperty( mbFocusOnClick, true ); // binary flag means "do not take focus"
998 aReader.skipPictureProperty(); // mouse icon
999 return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm );
1002 void AxCommandButtonModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
1004 AxBinaryPropertyWriter aWriter( rOutStrm );
1005 aWriter.writeIntProperty< sal_uInt32 >( mnTextColor );
1006 if ( mnBackColor )
1007 aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
1008 else
1009 aWriter.skipProperty(); // default backcolour
1010 aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
1011 aWriter.writeStringProperty( maCaption );
1012 aWriter.skipProperty(); // pict pos
1013 aWriter.writePairProperty( maSize );
1014 aWriter.skipProperty(); // mouse pointer
1015 aWriter.skipProperty(); // picture data
1016 aWriter.skipProperty(); // accelerator
1017 aWriter.writeBoolProperty( mbFocusOnClick ); // binary flag means "do not take focus"
1018 aWriter.skipProperty(); // mouse icon
1019 aWriter.finalizeExport();
1020 AxFontDataModel::exportBinaryModel( rOutStrm );
1023 void AxCommandButtonModel::exportCompObj( BinaryOutputStream& rOutStream )
1025 // should be able to replace this hardcoded foo with
1026 // proper export info from MS-OLEDS spec.
1027 static sal_uInt8 const aCompObj[] = {
1028 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1029 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x32, 0x05, 0xD7,
1030 0x69, 0xCE, 0xCD, 0x11, 0xA7, 0x77, 0x00, 0xDD,
1031 0x01, 0x14, 0x3C, 0x57, 0x22, 0x00, 0x00, 0x00,
1032 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1033 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6d, 0x73, 0x20,
1034 0x32, 0x2e, 0x30, 0x20, 0x43, 0x6F, 0x6D, 0x6D,
1035 0x61, 0x6E, 0x64, 0x42, 0x75, 0x74, 0x74, 0x6F,
1036 0x6E, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
1037 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
1038 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x16, 0x00,
1039 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
1040 0x43, 0x6F, 0x6D, 0x6D, 0x61, 0x6E, 0x64, 0x42,
1041 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00,
1042 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
1043 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1045 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1048 ApiControlType AxCommandButtonModel::getControlType() const
1050 return API_CONTROL_BUTTON;
1053 void AxCommandButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1055 rPropMap.setProperty( PROP_Label, maCaption );
1056 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
1057 rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
1058 rPropMap.setProperty( PROP_FocusOnClick, mbFocusOnClick );
1059 rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor );
1060 ControlConverter::convertVerticalAlign( rPropMap, mnVerticalAlign );
1061 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::NotSupported );
1062 rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos );
1063 AxFontDataModel::convertProperties( rPropMap, rConv );
1066 void AxCommandButtonModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1068 (void)rPropSet.getProperty(maCaption, PROP_Label);
1069 bool bRes = false;
1070 if ( rPropSet.getProperty( bRes, PROP_Enabled ) )
1071 setFlag( mnFlags, AX_FLAGS_ENABLED, bRes );
1072 if ( rPropSet.getProperty( bRes, PROP_MultiLine ) )
1073 setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
1074 (void)rPropSet.getProperty(mbFocusOnClick, PROP_FocusOnClick);
1076 ControlConverter::convertToMSColor( rPropSet, PROP_TextColor, mnTextColor );
1077 ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1079 AxFontDataModel::convertFromProperties( rPropSet, rConv );
1082 AxLabelModel::AxLabelModel() :
1083 mnTextColor( AX_SYSCOLOR_BUTTONTEXT ),
1084 mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
1085 mnFlags( AX_LABEL_DEFFLAGS ),
1086 mnBorderColor( AX_SYSCOLOR_WINDOWFRAME ),
1087 mnBorderStyle( AX_BORDERSTYLE_NONE ),
1088 mnSpecialEffect( AX_SPECIALEFFECT_FLAT ),
1089 mnVerticalAlign( XML_Top )
1093 void AxLabelModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
1095 switch( nPropId )
1097 case XML_Caption: maCaption = rValue; break;
1098 case XML_ForeColor: mnTextColor = AttributeConversion::decodeUnsigned( rValue ); break;
1099 case XML_BackColor: mnBackColor = AttributeConversion::decodeUnsigned( rValue ); break;
1100 case XML_VariousPropertyBits: mnFlags = AttributeConversion::decodeUnsigned( rValue ); break;
1101 case XML_BorderColor: mnBorderColor = AttributeConversion::decodeUnsigned( rValue ); break;
1102 case XML_BorderStyle: mnBorderStyle = AttributeConversion::decodeInteger( rValue ); break;
1103 case XML_SpecialEffect: mnSpecialEffect = AttributeConversion::decodeInteger( rValue ); break;
1104 default: AxFontDataModel::importProperty( nPropId, rValue );
1108 bool AxLabelModel::importBinaryModel( BinaryInputStream& rInStrm )
1110 AxBinaryPropertyReader aReader( rInStrm );
1111 aReader.readIntProperty< sal_uInt32 >( mnTextColor );
1112 aReader.readIntProperty< sal_uInt32 >( mnBackColor );
1113 aReader.readIntProperty< sal_uInt32 >( mnFlags );
1114 aReader.readStringProperty( maCaption );
1115 aReader.skipIntProperty< sal_uInt32 >(); // picture position
1116 aReader.readPairProperty( maSize );
1117 aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
1118 aReader.readIntProperty< sal_uInt32 >( mnBorderColor );
1119 aReader.readIntProperty< sal_uInt16 >( mnBorderStyle );
1120 aReader.readIntProperty< sal_uInt16 >( mnSpecialEffect );
1121 aReader.skipPictureProperty(); // picture
1122 aReader.skipIntProperty< sal_uInt16 >(); // accelerator
1123 aReader.skipPictureProperty(); // mouse icon
1124 return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm );
1127 void AxLabelModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
1129 AxBinaryPropertyWriter aWriter( rOutStrm );
1130 aWriter.writeIntProperty< sal_uInt32 >( mnTextColor );
1131 if ( mnBackColor )
1132 aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
1133 else
1134 // if mnBackColor == 0 then it's the libreoffice default backcolour is
1135 // the MSO Label default which is AX_SYSCOLOR_BUTTONFACE
1136 aWriter.writeIntProperty< sal_uInt32 >( AX_SYSCOLOR_WINDOWBACK );
1137 aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
1138 aWriter.writeStringProperty( maCaption );
1139 aWriter.skipProperty(); // picture position
1140 aWriter.writePairProperty( maSize );
1141 aWriter.skipProperty(); // mouse pointer
1142 aWriter.writeIntProperty< sal_uInt32 >( mnBorderColor );
1143 aWriter.writeIntProperty< sal_uInt16 >( mnBorderStyle );
1144 aWriter.writeIntProperty< sal_uInt16 >( mnSpecialEffect );
1145 aWriter.skipProperty(); // picture
1146 aWriter.skipProperty(); // accelerator
1147 aWriter.skipProperty(); // mouse icon
1148 aWriter.finalizeExport();
1149 AxFontDataModel::exportBinaryModel( rOutStrm );
1152 void AxLabelModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1154 rPropSet.getProperty( maCaption, PROP_Label );
1155 bool bRes = false;
1156 if ( rPropSet.getProperty( bRes, PROP_Enabled ) )
1157 setFlag( mnFlags, AX_FLAGS_ENABLED, bRes );
1158 if ( rPropSet.getProperty( bRes, PROP_MultiLine ) )
1159 setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
1161 ControlConverter::convertToMSColor( rPropSet, PROP_TextColor, mnTextColor );
1162 // VerticalAlign doesn't seem to be read from binary
1164 // not sure about background color, how do we decide when to set
1165 // AX_FLAGS_OPAQUE ?
1166 ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1167 ControlConverter::convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1169 AxFontDataModel::convertFromProperties( rPropSet, rConv );
1172 void AxLabelModel::exportCompObj( BinaryOutputStream& rOutStream )
1174 // should be able to replace this hardcoded foo with
1175 // proper export info from MS-OLEDS spec.
1176 static sal_uInt8 const aCompObj[] = {
1177 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1178 0xFF, 0xFF, 0xFF, 0xFF, 0x23, 0x9E, 0x8C, 0x97,
1179 0xB0, 0xD4, 0xCE, 0x11, 0xBF, 0x2D, 0x00, 0xAA,
1180 0x00, 0x3F, 0x40, 0xD0, 0x1A, 0x00, 0x00, 0x00,
1181 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1182 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1183 0x32, 0x2E, 0x30, 0x20, 0x4C, 0x61, 0x62, 0x65,
1184 0x6C, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
1185 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
1186 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x0E, 0x00,
1187 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
1188 0x4C, 0x61, 0x62, 0x65, 0x6C, 0x2E, 0x31, 0x00,
1189 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
1190 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1192 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1195 ApiControlType AxLabelModel::getControlType() const
1197 return API_CONTROL_FIXEDTEXT;
1200 void AxLabelModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1202 rPropMap.setProperty( PROP_Label, maCaption );
1203 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
1204 rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
1205 rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor );
1206 ControlConverter::convertVerticalAlign( rPropMap, mnVerticalAlign );
1207 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::Void );
1208 rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1209 AxFontDataModel::convertProperties( rPropMap, rConv );
1212 AxImageModel::AxImageModel() :
1213 mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
1214 mnFlags( AX_IMAGE_DEFFLAGS ),
1215 mnBorderColor( AX_SYSCOLOR_WINDOWFRAME ),
1216 mnBorderStyle( AX_BORDERSTYLE_SINGLE ),
1217 mnSpecialEffect( AX_SPECIALEFFECT_FLAT ),
1218 mnPicSizeMode( AX_PICSIZE_CLIP ),
1219 mnPicAlign( AX_PICALIGN_CENTER ),
1220 mbPicTiling( false )
1224 void AxImageModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
1226 switch( nPropId )
1228 case XML_BackColor: mnBackColor = AttributeConversion::decodeUnsigned( rValue ); break;
1229 case XML_VariousPropertyBits: mnFlags = AttributeConversion::decodeUnsigned( rValue ); break;
1230 case XML_BorderColor: mnBorderColor = AttributeConversion::decodeUnsigned( rValue ); break;
1231 case XML_BorderStyle: mnBorderStyle = AttributeConversion::decodeInteger( rValue ); break;
1232 case XML_SpecialEffect: mnSpecialEffect = AttributeConversion::decodeInteger( rValue ); break;
1233 case XML_SizeMode: mnPicSizeMode = AttributeConversion::decodeInteger( rValue ); break;
1234 case XML_PictureAlignment: mnPicAlign = AttributeConversion::decodeInteger( rValue ); break;
1235 case XML_PictureTiling: mbPicTiling = AttributeConversion::decodeInteger( rValue ) != 0; break;
1236 default: AxControlModelBase::importProperty( nPropId, rValue );
1240 void AxImageModel::importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm )
1242 switch( nPropId )
1244 case XML_Picture: OleHelper::importStdPic( maPictureData, rInStrm, true ); break;
1245 default: AxControlModelBase::importPictureData( nPropId, rInStrm );
1249 bool AxImageModel::importBinaryModel( BinaryInputStream& rInStrm )
1251 AxBinaryPropertyReader aReader( rInStrm );
1252 aReader.skipUndefinedProperty();
1253 aReader.skipUndefinedProperty();
1254 aReader.skipBoolProperty(); // auto-size
1255 aReader.readIntProperty< sal_uInt32 >( mnBorderColor );
1256 aReader.readIntProperty< sal_uInt32 >( mnBackColor );
1257 aReader.readIntProperty< sal_uInt8 >( mnBorderStyle );
1258 aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
1259 aReader.readIntProperty< sal_uInt8 >( mnPicSizeMode );
1260 aReader.readIntProperty< sal_uInt8 >( mnSpecialEffect );
1261 aReader.readPairProperty( maSize );
1262 aReader.readPictureProperty( maPictureData );
1263 aReader.readIntProperty< sal_uInt8 >( mnPicAlign );
1264 aReader.readBoolProperty( mbPicTiling );
1265 aReader.readIntProperty< sal_uInt32 >( mnFlags );
1266 aReader.skipPictureProperty(); // mouse icon
1267 return aReader.finalizeImport();
1270 void AxImageModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
1272 AxBinaryPropertyWriter aWriter( rOutStrm );
1273 aWriter.skipProperty(); //undefined
1274 aWriter.skipProperty(); //undefined
1275 aWriter.skipProperty(); //auto-size
1276 aWriter.writeIntProperty< sal_uInt32 >( mnBorderColor );
1277 if ( mnBackColor )
1278 aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
1279 else
1280 aWriter.skipProperty(); // default backcolour
1281 aWriter.writeIntProperty< sal_uInt8 >( mnBorderStyle );
1282 aWriter.skipProperty(); // mouse pointer
1283 aWriter.writeIntProperty< sal_uInt8 >( mnPicSizeMode );
1284 aWriter.writeIntProperty< sal_uInt8 >( mnSpecialEffect );
1285 aWriter.writePairProperty( maSize );
1286 aWriter.skipProperty(); //maPictureData );
1287 aWriter.writeIntProperty< sal_uInt8 >( mnPicAlign );
1288 aWriter.writeBoolProperty( mbPicTiling );
1289 aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
1290 aWriter.skipProperty(); // mouse icon
1291 aWriter.finalizeExport();
1294 void AxImageModel::exportCompObj( BinaryOutputStream& rOutStream )
1296 // should be able to replace this hardcoded foo with
1297 // proper export info from MS-OLEDS spec.
1298 static sal_uInt8 const aCompObj[] = {
1299 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1300 0xFF, 0xFF, 0xFF, 0xFF, 0x41, 0x92, 0x59, 0x4C,
1301 0x26, 0x69, 0x1B, 0x10, 0x99, 0x92, 0x00, 0x00,
1302 0x0B, 0x65, 0xC6, 0xF9, 0x1A, 0x00, 0x00, 0x00,
1303 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1304 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1305 0x32, 0x2E, 0x30, 0x20, 0x49, 0x6D, 0x61, 0x67,
1306 0x65, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
1307 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
1308 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x0E, 0x00,
1309 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
1310 0x49, 0x6D, 0x61, 0x67, 0x65, 0x2E, 0x31, 0x00,
1311 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
1312 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1314 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1317 ApiControlType AxImageModel::getControlType() const
1319 return API_CONTROL_IMAGE;
1322 void AxImageModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1324 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
1325 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::Void );
1326 rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1327 rConv.convertAxPicture( rPropMap, maPictureData, mnPicSizeMode );
1328 AxControlModelBase::convertProperties( rPropMap, rConv );
1331 AxTabStripModel::AxTabStripModel() :
1332 mnListIndex( 0 ),
1333 mnTabStyle( 0 ),
1334 mnTabData( 0 ),
1335 mnVariousPropertyBits( 0 )
1339 bool AxTabStripModel::importBinaryModel( BinaryInputStream& rInStrm )
1341 // not worth reading much here, basically we are interested
1342 // in whether we have tabs, the width, the height and the
1343 // captions, everything else we can pretty much discard ( for now )
1344 AxBinaryPropertyReader aReader( rInStrm );
1345 aReader.readIntProperty< sal_uInt32 >( mnListIndex ); // ListIndex
1346 aReader.skipIntProperty< sal_uInt32 >(); // Backcolor
1347 aReader.skipIntProperty< sal_uInt32 >(); // ForeColor
1348 aReader.skipUndefinedProperty();
1349 aReader.readPairProperty( maSize );
1350 aReader.readArrayStringProperty( maItems );
1351 aReader.skipIntProperty< sal_uInt8 >(); // MousePointer
1352 aReader.skipUndefinedProperty();
1353 aReader.skipIntProperty< sal_uInt32 >(); // TabOrientation
1354 aReader.readIntProperty< sal_uInt32 >(mnTabStyle); // TabStyle
1355 aReader.skipBoolProperty(); // MultiRow
1356 aReader.skipIntProperty< sal_uInt32 >(); // TabFixedWidth
1357 aReader.skipIntProperty< sal_uInt32 >(); // TabFixedHeight
1358 aReader.skipBoolProperty(); // ToolTips
1359 aReader.skipUndefinedProperty();
1360 aReader.skipArrayStringProperty(); // ToolTip strings
1361 aReader.skipUndefinedProperty();
1362 aReader.readArrayStringProperty( maTabNames ); // Tab names
1363 aReader.readIntProperty< sal_uInt32 >(mnVariousPropertyBits); // VariousPropertyBits
1364 aReader.skipBoolProperty();// NewVersion
1365 aReader.skipIntProperty< sal_uInt32 >(); // TabsAllocated
1366 aReader.skipArrayStringProperty(); // Tags
1367 aReader.readIntProperty<sal_uInt32 >(mnTabData); // TabData
1368 aReader.skipArrayStringProperty(); // Accelerators
1369 aReader.skipPictureProperty(); // Mouse Icon
1370 return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm );
1373 ApiControlType AxTabStripModel::getControlType() const
1375 return API_CONTROL_TABSTRIP;
1378 AxMorphDataModelBase::AxMorphDataModelBase() :
1379 mnTextColor( AX_SYSCOLOR_WINDOWTEXT ),
1380 mnBackColor( AX_SYSCOLOR_WINDOWBACK ),
1381 mnFlags( AX_MORPHDATA_DEFFLAGS ),
1382 mnPicturePos( AX_PICPOS_ABOVECENTER ),
1383 mnBorderColor( AX_SYSCOLOR_WINDOWFRAME ),
1384 mnBorderStyle( AX_BORDERSTYLE_NONE ),
1385 mnSpecialEffect( AX_SPECIALEFFECT_SUNKEN ),
1386 mnDisplayStyle( AX_DISPLAYSTYLE_TEXT ),
1387 mnMultiSelect( AX_SELECTION_SINGLE ),
1388 mnScrollBars( AX_SCROLLBAR_NONE ),
1389 mnMatchEntry( AX_MATCHENTRY_NONE ),
1390 mnShowDropButton( AX_SHOWDROPBUTTON_NEVER ),
1391 mnMaxLength( 0 ),
1392 mnPasswordChar( 0 ),
1393 mnListRows( 8 ),
1394 mnVerticalAlign( XML_Center )
1398 void AxMorphDataModelBase::importProperty( sal_Int32 nPropId, const OUString& rValue )
1400 switch( nPropId )
1402 case XML_Caption: maCaption = rValue; break;
1403 case XML_Value: maValue = rValue; break;
1404 case XML_GroupName: maGroupName = rValue; break;
1405 case XML_ForeColor: mnTextColor = AttributeConversion::decodeUnsigned( rValue ); break;
1406 case XML_BackColor: mnBackColor = AttributeConversion::decodeUnsigned( rValue ); break;
1407 case XML_VariousPropertyBits: mnFlags = AttributeConversion::decodeUnsigned( rValue ); break;
1408 case XML_PicturePosition: mnPicturePos = AttributeConversion::decodeUnsigned( rValue ); break;
1409 case XML_BorderColor: mnBorderColor = AttributeConversion::decodeUnsigned( rValue ); break;
1410 case XML_BorderStyle: mnBorderStyle = AttributeConversion::decodeInteger( rValue ); break;
1411 case XML_SpecialEffect: mnSpecialEffect = AttributeConversion::decodeInteger( rValue ); break;
1412 case XML_DisplayStyle: mnDisplayStyle = AttributeConversion::decodeInteger( rValue ); break;
1413 case XML_MultiSelect: mnMultiSelect = AttributeConversion::decodeInteger( rValue ); break;
1414 case XML_ScrollBars: mnScrollBars = AttributeConversion::decodeInteger( rValue ); break;
1415 case XML_MatchEntry: mnMatchEntry = AttributeConversion::decodeInteger( rValue ); break;
1416 case XML_ShowDropButtonWhen: mnShowDropButton = AttributeConversion::decodeInteger( rValue );break;
1417 case XML_MaxLength: mnMaxLength = AttributeConversion::decodeInteger( rValue ); break;
1418 case XML_PasswordChar: mnPasswordChar = AttributeConversion::decodeInteger( rValue ); break;
1419 case XML_ListRows: mnListRows = AttributeConversion::decodeInteger( rValue ); break;
1420 default: AxFontDataModel::importProperty( nPropId, rValue );
1424 void AxMorphDataModelBase::importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm )
1426 switch( nPropId )
1428 case XML_Picture: OleHelper::importStdPic( maPictureData, rInStrm, true ); break;
1429 default: AxFontDataModel::importPictureData( nPropId, rInStrm );
1433 bool AxMorphDataModelBase::importBinaryModel( BinaryInputStream& rInStrm )
1435 AxBinaryPropertyReader aReader( rInStrm, true );
1436 aReader.readIntProperty< sal_uInt32 >( mnFlags );
1437 aReader.readIntProperty< sal_uInt32 >( mnBackColor );
1438 aReader.readIntProperty< sal_uInt32 >( mnTextColor );
1439 aReader.readIntProperty< sal_Int32 >( mnMaxLength );
1440 aReader.readIntProperty< sal_uInt8 >( mnBorderStyle );
1441 aReader.readIntProperty< sal_uInt8 >( mnScrollBars );
1442 aReader.readIntProperty< sal_uInt8 >( mnDisplayStyle );
1443 aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
1444 aReader.readPairProperty( maSize );
1445 aReader.readIntProperty< sal_uInt16 >( mnPasswordChar );
1446 aReader.skipIntProperty< sal_uInt32 >(); // list width
1447 aReader.skipIntProperty< sal_uInt16 >(); // bound column
1448 aReader.skipIntProperty< sal_Int16 >(); // text column
1449 aReader.skipIntProperty< sal_Int16 >(); // column count
1450 aReader.readIntProperty< sal_uInt16 >( mnListRows );
1451 aReader.skipIntProperty< sal_uInt16 >(); // column info count
1452 aReader.readIntProperty< sal_uInt8 >( mnMatchEntry );
1453 aReader.skipIntProperty< sal_uInt8 >(); // list style
1454 aReader.readIntProperty< sal_uInt8 >( mnShowDropButton );
1455 aReader.skipUndefinedProperty();
1456 aReader.skipIntProperty< sal_uInt8 >(); // drop down style
1457 aReader.readIntProperty< sal_uInt8 >( mnMultiSelect );
1458 aReader.readStringProperty( maValue );
1459 aReader.readStringProperty( maCaption );
1460 aReader.readIntProperty< sal_uInt32 >( mnPicturePos );
1461 aReader.readIntProperty< sal_uInt32 >( mnBorderColor );
1462 aReader.readIntProperty< sal_uInt32 >( mnSpecialEffect );
1463 aReader.skipPictureProperty(); // mouse icon
1464 aReader.readPictureProperty( maPictureData );
1465 aReader.skipIntProperty< sal_uInt16 >(); // accelerator
1466 aReader.skipUndefinedProperty();
1467 aReader.skipBoolProperty();
1468 aReader.readStringProperty( maGroupName );
1469 return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm );
1472 void AxMorphDataModelBase::exportBinaryModel( BinaryOutputStream& rOutStrm )
1474 AxBinaryPropertyWriter aWriter( rOutStrm, true );
1475 if ( mnFlags != AX_MORPHDATA_DEFFLAGS )
1476 aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
1477 else
1478 aWriter.skipProperty(); //mnFlags
1479 if ( mnBackColor )
1480 aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
1481 else
1482 aWriter.skipProperty(); // default backcolour
1483 aWriter.writeIntProperty< sal_uInt32 >( mnTextColor );
1485 // only write if different from default
1486 if ( ( ( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT ) || ( mnDisplayStyle == AX_DISPLAYSTYLE_COMBOBOX ) ) && mnMaxLength != 0 )
1487 aWriter.writeIntProperty< sal_Int32 >( mnMaxLength );
1488 else
1489 aWriter.skipProperty(); //mnMaxLength
1490 if ( ( ( mnDisplayStyle == AX_DISPLAYSTYLE_COMBOBOX ) || ( mnDisplayStyle == AX_DISPLAYSTYLE_LISTBOX ) || ( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT ) ) && mnBorderStyle != AX_BORDERSTYLE_NONE )
1491 aWriter.writeIntProperty< sal_uInt8 >( mnBorderStyle );
1492 else
1493 aWriter.skipProperty(); //mnBorderStyle
1495 if ( ( mnDisplayStyle == AX_DISPLAYSTYLE_LISTBOX || mnDisplayStyle == AX_DISPLAYSTYLE_TEXT ) && mnScrollBars != AX_SCROLLBAR_NONE )
1496 aWriter.writeIntProperty< sal_uInt8 >( mnScrollBars );
1497 else
1498 aWriter.skipProperty(); //mnScrollBars
1499 aWriter.writeIntProperty< sal_uInt8 >( mnDisplayStyle );
1500 aWriter.skipProperty(); // mouse pointer
1501 aWriter.writePairProperty( maSize );
1502 if ( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT )
1503 aWriter.writeIntProperty< sal_uInt16 >( mnPasswordChar );
1504 else
1505 aWriter.skipProperty(); // mnPasswordChar
1506 aWriter.skipProperty(); // list width
1507 aWriter.skipProperty(); // bound column
1508 aWriter.skipProperty(); // text column
1509 aWriter.skipProperty(); // column count
1510 aWriter.skipProperty(); // mnListRows
1511 aWriter.skipProperty(); // column info count
1512 aWriter.skipProperty(); // mnMatchEntry
1513 aWriter.skipProperty(); // list style
1514 aWriter.skipProperty(); // mnShowDropButton );
1515 aWriter.skipProperty();
1516 aWriter.skipProperty(); // drop down style
1517 if ( mnDisplayStyle == AX_DISPLAYSTYLE_LISTBOX && mnMultiSelect != AX_SELECTION_SINGLE )
1518 aWriter.writeIntProperty< sal_uInt8 >( mnMultiSelect );
1519 // although CheckBox, ListBox, OptionButton, ToggleButton are also supported
1520 // they can only have the fileformat default
1521 else
1522 aWriter.skipProperty(); //mnMultiSelect
1523 aWriter.writeStringProperty( maValue );
1525 if ( ( mnDisplayStyle == AX_DISPLAYSTYLE_CHECKBOX ) || ( mnDisplayStyle == AX_DISPLAYSTYLE_OPTBUTTON ) || ( mnDisplayStyle == AX_DISPLAYSTYLE_TOGGLE ) )
1526 aWriter.writeStringProperty( maCaption );
1527 else
1528 aWriter.skipProperty(); // mnCaption
1529 aWriter.skipProperty(); // mnPicturePos );
1530 if ( ( mnDisplayStyle == AX_DISPLAYSTYLE_COMBOBOX || mnDisplayStyle == AX_DISPLAYSTYLE_LISTBOX || mnDisplayStyle == AX_DISPLAYSTYLE_TEXT ) && mnBorderColor != AX_SYSCOLOR_WINDOWFRAME )
1531 aWriter.writeIntProperty< sal_uInt32 >( mnBorderColor );
1532 else
1533 aWriter.skipProperty(); // mnBorderColor
1534 if ( mnSpecialEffect != AX_SPECIALEFFECT_SUNKEN )
1535 aWriter.writeIntProperty< sal_uInt32 >( mnSpecialEffect );
1536 else
1537 aWriter.skipProperty(); //mnSpecialEffect
1538 aWriter.skipProperty(); // mouse icon
1539 aWriter.skipProperty(); // maPictureData
1540 aWriter.skipProperty(); // accelerator
1541 aWriter.skipProperty(); // undefined
1542 aWriter.writeBoolProperty(true); // must be 1 for morph
1543 if ( ( mnDisplayStyle == AX_DISPLAYSTYLE_CHECKBOX ) || ( mnDisplayStyle == AX_DISPLAYSTYLE_OPTBUTTON ) )
1544 aWriter.writeStringProperty( maGroupName );
1545 else
1546 aWriter.skipProperty(); //maGroupName
1547 aWriter.finalizeExport();
1548 AxFontDataModel::exportBinaryModel( rOutStrm );
1551 void AxMorphDataModelBase::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1553 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
1554 rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor );
1555 AxFontDataModel::convertProperties( rPropMap, rConv );
1558 AxToggleButtonModel::AxToggleButtonModel()
1560 mnDisplayStyle = AX_DISPLAYSTYLE_TOGGLE;
1563 ApiControlType AxToggleButtonModel::getControlType() const
1565 OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_TOGGLE, "AxToggleButtonModel::getControlType - invalid control type" );
1566 return API_CONTROL_BUTTON;
1569 void AxToggleButtonModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1571 rPropSet.getProperty( maCaption, PROP_Label );
1573 bool bRes = false;
1574 if ( rPropSet.getProperty( bRes, PROP_MultiLine ) )
1575 setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
1577 ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1578 // need to process the image if one exists
1579 ControlConverter::convertToAxState( rPropSet, maValue, mnMultiSelect, API_DEFAULTSTATE_BOOLEAN, mbAwtModel );
1580 AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
1583 void AxToggleButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1585 rPropMap.setProperty( PROP_Label, maCaption );
1586 rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
1587 rPropMap.setProperty( PROP_Toggle, true );
1588 ControlConverter::convertVerticalAlign( rPropMap, mnVerticalAlign );
1589 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::NotSupported );
1590 rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos );
1591 ControlConverter::convertAxState( rPropMap, maValue, mnMultiSelect, API_DEFAULTSTATE_BOOLEAN, mbAwtModel );
1592 AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1595 void AxToggleButtonModel::exportCompObj( BinaryOutputStream& rOutStream )
1597 // should be able to replace this hardcoded foo with
1598 // proper export info from MS-OLEDS spec.
1599 static sal_uInt8 const aCompObj[] = {
1600 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1601 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0x1D, 0xD2, 0x8B,
1602 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1603 0x00, 0x60, 0x02, 0xF3, 0x21, 0x00, 0x00, 0x00,
1604 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1605 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1606 0x32, 0x2E, 0x30, 0x20, 0x54, 0x6F, 0x67, 0x67,
1607 0x6C, 0x65, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E,
1608 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62,
1609 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62,
1610 0x6A, 0x65, 0x63, 0x74, 0x00, 0x15, 0x00, 0x00,
1611 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x54,
1612 0x6F, 0x67, 0x67, 0x6C, 0x65, 0x42, 0x75, 0x74,
1613 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00, 0xF4, 0x39,
1614 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1615 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1617 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1620 AxCheckBoxModel::AxCheckBoxModel()
1622 mnDisplayStyle = AX_DISPLAYSTYLE_CHECKBOX;
1625 ApiControlType AxCheckBoxModel::getControlType() const
1627 OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_CHECKBOX, "AxCheckBoxModel::getControlType - invalid control type" );
1628 return API_CONTROL_CHECKBOX;
1631 void AxCheckBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1633 rPropMap.setProperty( PROP_Label, maCaption );
1634 rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
1635 ControlConverter::convertVerticalAlign( rPropMap, mnVerticalAlign );
1636 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::Void );
1637 ControlConverter::convertAxVisualEffect( rPropMap, mnSpecialEffect );
1638 rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos );
1639 ControlConverter::convertAxState( rPropMap, maValue, mnMultiSelect, API_DEFAULTSTATE_TRISTATE, mbAwtModel );
1640 AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1643 void AxCheckBoxModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1645 rPropSet.getProperty( maCaption, PROP_Label );
1647 bool bRes = false;
1648 if ( rPropSet.getProperty( bRes, PROP_MultiLine ) )
1649 setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
1651 ControlConverter::convertToAxVisualEffect( rPropSet, mnSpecialEffect );
1652 ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1653 // need to process the image if one exists
1654 ControlConverter::convertToAxState( rPropSet, maValue, mnMultiSelect, API_DEFAULTSTATE_BOOLEAN, mbAwtModel );
1655 AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
1658 void AxCheckBoxModel::exportCompObj( BinaryOutputStream& rOutStream )
1660 // should be able to replace this hardcoded foo with
1661 // proper export info from MS-OLEDS spec.
1662 static sal_uInt8 const aCompObj[] = {
1663 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1664 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x1D, 0xD2, 0x8B,
1665 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1666 0x00, 0x60, 0x02, 0xF3, 0x1D, 0x00, 0x00, 0x00,
1667 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1668 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1669 0x32, 0x2E, 0x30, 0x20, 0x43, 0x68, 0x65, 0x63,
1670 0x6B, 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00,
1671 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65,
1672 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74,
1673 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72,
1674 0x6D, 0x73, 0x2E, 0x43, 0x68, 0x65, 0x63, 0x6B,
1675 0x42, 0x6F, 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39,
1676 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1677 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1679 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1682 AxOptionButtonModel::AxOptionButtonModel()
1684 mnDisplayStyle = AX_DISPLAYSTYLE_OPTBUTTON;
1687 ApiControlType AxOptionButtonModel::getControlType() const
1689 OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_OPTBUTTON, "AxOptionButtonModel::getControlType - invalid control type" );
1690 return API_CONTROL_RADIOBUTTON;
1693 void AxOptionButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1695 rPropMap.setProperty( PROP_Label, maCaption );
1696 rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
1697 ControlConverter::convertVerticalAlign( rPropMap, mnVerticalAlign );
1698 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::Void );
1699 ControlConverter::convertAxVisualEffect( rPropMap, mnSpecialEffect );
1700 rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos );
1701 ControlConverter::convertAxState( rPropMap, maValue, mnMultiSelect, API_DEFAULTSTATE_SHORT, mbAwtModel );
1702 AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1705 void AxOptionButtonModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1707 rPropSet.getProperty( maCaption, PROP_Label );
1709 bool bRes = false;
1710 if ( rPropSet.getProperty( bRes, PROP_MultiLine ) )
1711 setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
1713 ControlConverter::convertToAxVisualEffect( rPropSet, mnSpecialEffect );
1714 ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1715 // need to process the image if one exists
1716 ControlConverter::convertToAxState( rPropSet, maValue, mnMultiSelect, API_DEFAULTSTATE_BOOLEAN, mbAwtModel );
1717 AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
1720 void AxOptionButtonModel::exportCompObj( BinaryOutputStream& rOutStream )
1722 // should be able to replace this hardcoded foo with
1723 // proper export info from MS-OLEDS spec.
1724 static sal_uInt8 const aCompObj[] = {
1725 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1726 0xFF, 0xFF, 0xFF, 0xFF, 0x50, 0x1D, 0xD2, 0x8B,
1727 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1728 0x00, 0x60, 0x02, 0xF3, 0x21, 0x00, 0x00, 0x00,
1729 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1730 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1731 0x32, 0x2E, 0x30, 0x20, 0x4F, 0x70, 0x74, 0x69,
1732 0x6F, 0x6E, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E,
1733 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62,
1734 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62,
1735 0x6A, 0x65, 0x63, 0x74, 0x00, 0x15, 0x00, 0x00,
1736 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x4F,
1737 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x42, 0x75, 0x74,
1738 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00, 0xF4, 0x39,
1739 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1740 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1742 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1745 AxTextBoxModel::AxTextBoxModel()
1747 mnDisplayStyle = AX_DISPLAYSTYLE_TEXT;
1750 ApiControlType AxTextBoxModel::getControlType() const
1752 OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT, "AxTextBoxModel::getControlType - invalid control type" );
1753 return API_CONTROL_EDIT;
1756 void AxTextBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1758 rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_MULTILINE ) );
1759 rPropMap.setProperty( PROP_HideInactiveSelection, getFlag( mnFlags, AX_FLAGS_HIDESELECTION ) );
1760 rPropMap.setProperty( mbAwtModel ? PROP_Text : PROP_DefaultText, maValue );
1761 rPropMap.setProperty( PROP_MaxTextLen, getLimitedValue< sal_Int16, sal_Int32 >( mnMaxLength, 0, SAL_MAX_INT16 ) );
1762 if( (0 < mnPasswordChar) && (mnPasswordChar <= SAL_MAX_INT16) )
1763 rPropMap.setProperty( PROP_EchoChar, static_cast< sal_Int16 >( mnPasswordChar ) );
1764 rPropMap.setProperty( PROP_HScroll, getFlag( mnScrollBars, AX_SCROLLBAR_HORIZONTAL ) );
1765 rPropMap.setProperty( PROP_VScroll, getFlag( mnScrollBars, AX_SCROLLBAR_VERTICAL ) );
1766 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::Void );
1767 rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1768 AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1771 void AxTextBoxModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1773 bool bRes = false;
1774 if ( rPropSet.getProperty( bRes, PROP_MultiLine ) )
1775 setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
1776 if ( rPropSet.getProperty( bRes, PROP_HideInactiveSelection ) )
1777 setFlag( mnFlags, AX_FLAGS_HIDESELECTION, bRes );
1778 rPropSet.getProperty( maValue, ( mbAwtModel ? PROP_Text : PROP_DefaultText ) );
1779 if (maValue.isEmpty() && !mbAwtModel)
1780 // No default value? Then try exporting the current one.
1781 rPropSet.getProperty( maValue, PROP_Text);
1782 sal_Int16 nTmp(0);
1783 if ( rPropSet.getProperty( nTmp, PROP_MaxTextLen ) )
1784 mnMaxLength = nTmp;
1785 if ( rPropSet.getProperty( nTmp, PROP_EchoChar ) )
1786 mnPasswordChar = nTmp;
1787 if ( rPropSet.getProperty( bRes, PROP_HScroll ) )
1788 setFlag( mnScrollBars, AX_SCROLLBAR_HORIZONTAL, bRes );
1789 if ( rPropSet.getProperty( bRes, PROP_VScroll ) )
1790 setFlag( mnScrollBars, AX_SCROLLBAR_VERTICAL, bRes );
1792 ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor, 0x80000005L );
1794 ControlConverter::convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1795 AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
1798 void AxTextBoxModel::exportCompObj( BinaryOutputStream& rOutStream )
1800 // should be able to replace this hardcoded foo with
1801 // proper export info from MS-OLEDS spec.
1802 static sal_uInt8 const aCompObj[] = {
1803 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1804 0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x1D, 0xD2, 0x8B,
1805 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1806 0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
1807 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1808 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1809 0x32, 0x2E, 0x30, 0x20, 0x54, 0x65, 0x78, 0x74,
1810 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
1811 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
1812 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
1813 0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
1814 0x73, 0x2E, 0x54, 0x65, 0x78, 0x74, 0x42, 0x6F,
1815 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
1816 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1817 0x00, 0x00, 0x00, 0x00
1819 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1822 AxNumericFieldModel::AxNumericFieldModel()
1824 mnDisplayStyle = AX_DISPLAYSTYLE_TEXT;
1827 ApiControlType AxNumericFieldModel::getControlType() const
1829 OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT, "AxNumericFieldModel::getControlType - invalid control type" );
1830 return API_CONTROL_NUMERIC;
1833 void AxNumericFieldModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1835 rPropMap.setProperty( PROP_HideInactiveSelection, getFlag( mnFlags, AX_FLAGS_HIDESELECTION ) );
1836 // TODO: OUString::toDouble() does not handle local decimal separator
1837 rPropMap.setProperty( mbAwtModel ? PROP_Value : PROP_DefaultValue, maValue.toDouble() );
1838 rPropMap.setProperty( PROP_Spin, getFlag( mnScrollBars, AX_SCROLLBAR_VERTICAL ) );
1839 rPropMap.setProperty( PROP_Repeat, true );
1840 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::Void );
1841 rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1842 AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1845 void AxNumericFieldModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1847 bool bRes = false;
1848 if ( rPropSet.getProperty( bRes, PROP_HideInactiveSelection ) )
1849 setFlag( mnFlags, AX_FLAGS_HIDESELECTION, bRes );
1850 rPropSet.getProperty( maValue, ( mbAwtModel ? PROP_Text : PROP_DefaultText ) );
1851 if ( rPropSet.getProperty( bRes, PROP_Spin ) )
1852 setFlag( mnScrollBars, AX_SCROLLBAR_VERTICAL, bRes );
1854 ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1856 ControlConverter::convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1857 AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
1860 void AxNumericFieldModel::exportCompObj( BinaryOutputStream& rOutStream )
1862 // should be able to replace this hardcoded foo with
1863 // proper export info from MS-OLEDS spec.
1864 static sal_uInt8 const aCompObj[] = {
1865 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1866 0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x1D, 0xD2, 0x8B,
1867 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1868 0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
1869 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1870 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1871 0x32, 0x2E, 0x30, 0x20, 0x54, 0x65, 0x78, 0x74,
1872 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
1873 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
1874 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
1875 0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
1876 0x73, 0x2E, 0x54, 0x65, 0x78, 0x74, 0x42, 0x6F,
1877 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
1878 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1879 0x00, 0x00, 0x00, 0x00
1881 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1884 AxListBoxModel::AxListBoxModel()
1886 mnDisplayStyle = AX_DISPLAYSTYLE_LISTBOX;
1889 ApiControlType AxListBoxModel::getControlType() const
1891 OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_LISTBOX, "AxListBoxModel::getControlType - invalid control type" );
1892 return API_CONTROL_LISTBOX;
1895 void AxListBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1897 bool bMultiSelect = (mnMultiSelect == AX_SELECTION_MULTI) || (mnMultiSelect == AX_SELECTION_EXTENDED);
1898 rPropMap.setProperty( PROP_MultiSelection, bMultiSelect );
1899 rPropMap.setProperty( PROP_Dropdown, false );
1900 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::Void );
1901 rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1902 AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1905 void AxListBoxModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1907 bool bRes = false;
1908 if ( rPropSet.getProperty( bRes, PROP_MultiSelection ) )
1909 ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1911 ControlConverter::convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1912 AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
1915 void AxListBoxModel::exportCompObj( BinaryOutputStream& rOutStream )
1917 // should be able to replace this hardcoded foo with
1918 // proper export info from MS-OLEDS spec.
1919 static sal_uInt8 const aCompObj[] = {
1920 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1921 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0x1D, 0xD2, 0x8B,
1922 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1923 0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
1924 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1925 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1926 0x32, 0x2E, 0x30, 0x20, 0x4C, 0x69, 0x73, 0x74,
1927 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
1928 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
1929 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
1930 0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
1931 0x73, 0x2E, 0x4C, 0x69, 0x73, 0x74, 0x42, 0x6F,
1932 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
1933 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1934 0x00, 0x00, 0x00, 0x00
1936 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1939 AxComboBoxModel::AxComboBoxModel()
1941 mnDisplayStyle = AX_DISPLAYSTYLE_COMBOBOX;
1942 mnFlags = 0x2c80481b;
1945 ApiControlType AxComboBoxModel::getControlType() const
1947 OSL_ENSURE( (mnDisplayStyle == AX_DISPLAYSTYLE_COMBOBOX) || (mnDisplayStyle == AX_DISPLAYSTYLE_DROPDOWN), "AxComboBoxModel::getControlType - invalid control type" );
1948 return (mnDisplayStyle == AX_DISPLAYSTYLE_DROPDOWN) ? API_CONTROL_LISTBOX : API_CONTROL_COMBOBOX;
1951 void AxComboBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1953 if( mnDisplayStyle != AX_DISPLAYSTYLE_DROPDOWN )
1955 rPropMap.setProperty( PROP_HideInactiveSelection, getFlag( mnFlags, AX_FLAGS_HIDESELECTION ) );
1956 rPropMap.setProperty( mbAwtModel ? PROP_Text : PROP_DefaultText, maValue );
1957 rPropMap.setProperty( PROP_MaxTextLen, getLimitedValue< sal_Int16, sal_Int32 >( mnMaxLength, 0, SAL_MAX_INT16 ) );
1958 bool bAutoComplete = (mnMatchEntry == AX_MATCHENTRY_FIRSTLETTER) || (mnMatchEntry == AX_MATCHENTRY_COMPLETE);
1959 rPropMap.setProperty( PROP_Autocomplete, bAutoComplete );
1961 bool bShowDropdown = (mnShowDropButton == AX_SHOWDROPBUTTON_FOCUS) || (mnShowDropButton == AX_SHOWDROPBUTTON_ALWAYS);
1962 rPropMap.setProperty( PROP_Dropdown, bShowDropdown );
1963 rPropMap.setProperty( PROP_LineCount, getLimitedValue< sal_Int16, sal_Int32 >( mnListRows, 1, SAL_MAX_INT16 ) );
1964 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::Void );
1965 rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1966 AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1969 void AxComboBoxModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1971 // when would we have mnDisplayStyle = AX_DISPLAYSTYLE_DROPDOWN ?
1972 // #TODO check against msocximex
1973 mnDisplayStyle = AX_DISPLAYSTYLE_COMBOBOX;
1974 bool bRes = false;
1976 if ( rPropSet.getProperty( bRes, PROP_HideInactiveSelection ) )
1977 setFlag( mnFlags, AX_FLAGS_HIDESELECTION, bRes );
1978 rPropSet.getProperty( maValue, ( mbAwtModel ? PROP_Text : PROP_DefaultText ) );
1980 sal_Int16 nTmp(0);
1981 if ( rPropSet.getProperty( nTmp, PROP_MaxTextLen ) )
1982 mnMaxLength = nTmp;
1983 if ( rPropSet.getProperty( bRes, PROP_Autocomplete ) )
1985 // when to choose AX_MATCHENTRY_FIRSTLETTER ?
1986 // #TODO check against msocximex
1987 if ( bRes )
1988 mnMatchEntry = AX_MATCHENTRY_COMPLETE;
1990 if ( rPropSet.getProperty( bRes, PROP_Dropdown ) )
1992 rPropSet.getProperty( mnListRows, PROP_LineCount );
1993 if ( !mnListRows )
1994 mnListRows = 1;
1996 ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1998 ControlConverter::convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1999 AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
2002 void AxComboBoxModel::exportCompObj( BinaryOutputStream& rOutStream )
2004 // should be able to replace this hardcoded foo with
2005 // proper export info from MS-OLEDS spec.
2006 static sal_uInt8 const aCompObj[] = {
2007 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2008 0xFF, 0xFF, 0xFF, 0xFF, 0x30, 0x1D, 0xD2, 0x8B,
2009 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
2010 0x00, 0x60, 0x02, 0xF3, 0x1D, 0x00, 0x00, 0x00,
2011 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2012 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2013 0x32, 0x2E, 0x30, 0x20, 0x43, 0x6F, 0x6D, 0x62,
2014 0x6F, 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00,
2015 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65,
2016 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74,
2017 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72,
2018 0x6D, 0x73, 0x2E, 0x43, 0x6F, 0x6D, 0x62, 0x6F,
2019 0x42, 0x6F, 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39,
2020 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2021 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2023 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
2026 AxSpinButtonModel::AxSpinButtonModel() :
2027 mnArrowColor( AX_SYSCOLOR_BUTTONTEXT ),
2028 mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
2029 mnFlags( AX_SPINBUTTON_DEFFLAGS ),
2030 mnOrientation( AX_ORIENTATION_AUTO ),
2031 mnMin( 0 ),
2032 mnMax( 100 ),
2033 mnPosition( 0 ),
2034 mnSmallChange( 1 ),
2035 mnDelay( 50 )
2039 ApiControlType AxSpinButtonModel::getControlType() const
2041 return API_CONTROL_SPINBUTTON;
2044 void AxSpinButtonModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
2046 switch( nPropId )
2048 case XML_ForeColor: mnArrowColor = AttributeConversion::decodeUnsigned( rValue ); break;
2049 case XML_BackColor: mnBackColor = AttributeConversion::decodeUnsigned( rValue ); break;
2050 case XML_VariousPropertyBits: mnFlags = AttributeConversion::decodeUnsigned( rValue ); break;
2051 case XML_Orientation: mnOrientation = AttributeConversion::decodeInteger( rValue ); break;
2052 case XML_Min: mnMin = AttributeConversion::decodeInteger( rValue ); break;
2053 case XML_Max: mnMax = AttributeConversion::decodeInteger( rValue ); break;
2054 case XML_Position: mnPosition = AttributeConversion::decodeInteger( rValue ); break;
2055 case XML_SmallChange: mnSmallChange = AttributeConversion::decodeInteger( rValue ); break;
2056 case XML_Delay: mnDelay = AttributeConversion::decodeInteger( rValue ); break;
2057 default: AxControlModelBase::importProperty( nPropId, rValue );
2061 bool AxSpinButtonModel::importBinaryModel( BinaryInputStream& rInStrm )
2063 AxBinaryPropertyReader aReader( rInStrm );
2064 aReader.readIntProperty< sal_uInt32 >( mnArrowColor );
2065 aReader.readIntProperty< sal_uInt32 >( mnBackColor );
2066 aReader.readIntProperty< sal_uInt32 >( mnFlags );
2067 aReader.readPairProperty( maSize );
2068 aReader.skipIntProperty< sal_uInt32 >(); // unused
2069 aReader.readIntProperty< sal_Int32 >( mnMin );
2070 aReader.readIntProperty< sal_Int32 >( mnMax );
2071 aReader.readIntProperty< sal_Int32 >( mnPosition );
2072 aReader.skipIntProperty< sal_uInt32 >(); // prev enabled
2073 aReader.skipIntProperty< sal_uInt32 >(); // next enabled
2074 aReader.readIntProperty< sal_Int32 >( mnSmallChange );
2075 aReader.readIntProperty< sal_Int32 >( mnOrientation );
2076 aReader.readIntProperty< sal_Int32 >( mnDelay );
2077 aReader.skipPictureProperty(); // mouse icon
2078 aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
2079 return aReader.finalizeImport();
2082 void AxSpinButtonModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
2084 AxBinaryPropertyWriter aWriter( rOutStrm );
2085 aWriter.writeIntProperty< sal_uInt32 >( mnArrowColor );
2086 if ( mnBackColor )
2087 aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
2088 else
2089 aWriter.skipProperty(); // default backcolour
2090 aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
2091 aWriter.writePairProperty( maSize );
2092 aWriter.skipProperty(); // unused
2093 aWriter.writeIntProperty< sal_Int32 >( mnMin );
2094 aWriter.writeIntProperty< sal_Int32 >( mnMax );
2095 aWriter.writeIntProperty< sal_Int32 >( mnPosition );
2096 aWriter.skipProperty(); // prev enabled
2097 aWriter.skipProperty(); // next enabled
2098 aWriter.writeIntProperty< sal_Int32 >( mnSmallChange );
2099 aWriter.writeIntProperty< sal_Int32 >( mnOrientation );
2100 aWriter.writeIntProperty< sal_Int32 >( mnDelay );
2101 aWriter.skipProperty(); // mouse icon
2102 aWriter.skipProperty(); // mouse pointer
2104 aWriter.finalizeExport();
2107 void AxSpinButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2109 sal_Int32 nMin = ::std::min( mnMin, mnMax );
2110 sal_Int32 nMax = ::std::max( mnMin, mnMax );
2111 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
2112 rPropMap.setProperty( PROP_SpinValueMin, nMin );
2113 rPropMap.setProperty( PROP_SpinValueMax, nMax );
2114 rPropMap.setProperty( PROP_SpinIncrement, mnSmallChange );
2115 rPropMap.setProperty( mbAwtModel ? PROP_SpinValue : PROP_DefaultSpinValue, mnPosition );
2116 rPropMap.setProperty( PROP_Repeat, true );
2117 rPropMap.setProperty( PROP_RepeatDelay, mnDelay );
2118 rPropMap.setProperty( PROP_Border, API_BORDER_NONE );
2119 rConv.convertColor( rPropMap, PROP_SymbolColor, mnArrowColor );
2120 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::NotSupported );
2121 ControlConverter::convertAxOrientation( rPropMap, maSize, mnOrientation );
2122 AxControlModelBase::convertProperties( rPropMap, rConv );
2125 void AxSpinButtonModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& )
2127 bool bRes = false;
2128 if ( rPropSet.getProperty( bRes, PROP_Enabled ) )
2129 setFlag( mnFlags, AX_FLAGS_ENABLED, bRes );
2130 rPropSet.getProperty( mnMin, PROP_SpinValueMin );
2131 rPropSet.getProperty( mnMax, PROP_SpinValueMax );
2132 rPropSet.getProperty( mnSmallChange, PROP_SpinIncrement );
2133 rPropSet.getProperty( mnPosition, ( mbAwtModel ? PROP_SpinValue : PROP_DefaultSpinValue ) );
2134 rPropSet.getProperty( mnDelay, PROP_RepeatDelay );
2135 ControlConverter::convertToMSColor( rPropSet, PROP_SymbolColor, mnArrowColor);
2136 ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
2138 ControlConverter::convertToAxOrientation( rPropSet, maSize, mnOrientation );
2141 void AxSpinButtonModel::exportCompObj( BinaryOutputStream& rOutStream )
2143 // should be able to replace this hardcoded foo with
2144 // proper export info from MS-OLEDS spec.
2145 static sal_uInt8 const aCompObj[] =
2147 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2148 0xFF, 0xFF, 0xFF, 0xFF, 0xB0, 0x6F, 0x17, 0x79,
2149 0xF2, 0xB7, 0xCE, 0x11, 0x97, 0xEF, 0x00, 0xAA,
2150 0x00, 0x6D, 0x27, 0x76, 0x1F, 0x00, 0x00, 0x00,
2151 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2152 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2153 0x32, 0x2E, 0x30, 0x20, 0x53, 0x70, 0x69, 0x6E,
2154 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x00, 0x10,
2155 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64,
2156 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65,
2157 0x63, 0x74, 0x00, 0x13, 0x00, 0x00, 0x00, 0x46,
2158 0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x53, 0x70, 0x69,
2159 0x6E, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x2E,
2160 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00,
2161 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2162 0x00, 0x00
2165 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
2168 AxScrollBarModel::AxScrollBarModel() :
2169 mnArrowColor( AX_SYSCOLOR_BUTTONTEXT ),
2170 mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
2171 mnFlags( AX_SCROLLBAR_DEFFLAGS ),
2172 mnOrientation( AX_ORIENTATION_AUTO ),
2173 mnPropThumb( AX_PROPTHUMB_ON ),
2174 mnMin( 0 ),
2175 mnMax( 32767 ),
2176 mnPosition( 0 ),
2177 mnSmallChange( 1 ),
2178 mnLargeChange( 1 ),
2179 mnDelay( 50 )
2183 ApiControlType AxScrollBarModel::getControlType() const
2185 return API_CONTROL_SCROLLBAR;
2188 void AxScrollBarModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
2190 switch( nPropId )
2192 case XML_ForeColor: mnArrowColor = AttributeConversion::decodeUnsigned( rValue ); break;
2193 case XML_BackColor: mnBackColor = AttributeConversion::decodeUnsigned( rValue ); break;
2194 case XML_VariousPropertyBits: mnFlags = AttributeConversion::decodeUnsigned( rValue ); break;
2195 case XML_Orientation: mnOrientation = AttributeConversion::decodeInteger( rValue ); break;
2196 case XML_ProportionalThumb: mnPropThumb = AttributeConversion::decodeInteger( rValue ); break;
2197 case XML_Min: mnMin = AttributeConversion::decodeInteger( rValue ); break;
2198 case XML_Max: mnMax = AttributeConversion::decodeInteger( rValue ); break;
2199 case XML_Position: mnPosition = AttributeConversion::decodeInteger( rValue ); break;
2200 case XML_SmallChange: mnSmallChange = AttributeConversion::decodeInteger( rValue ); break;
2201 case XML_LargeChange: mnLargeChange = AttributeConversion::decodeInteger( rValue ); break;
2202 case XML_Delay: mnDelay = AttributeConversion::decodeInteger( rValue ); break;
2203 default: AxControlModelBase::importProperty( nPropId, rValue );
2207 bool AxScrollBarModel::importBinaryModel( BinaryInputStream& rInStrm )
2209 AxBinaryPropertyReader aReader( rInStrm );
2210 aReader.readIntProperty< sal_uInt32 >( mnArrowColor );
2211 aReader.readIntProperty< sal_uInt32 >( mnBackColor );
2212 aReader.readIntProperty< sal_uInt32 >( mnFlags );
2213 aReader.readPairProperty( maSize );
2214 aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
2215 aReader.readIntProperty< sal_Int32 >( mnMin );
2216 aReader.readIntProperty< sal_Int32 >( mnMax );
2217 aReader.readIntProperty< sal_Int32 >( mnPosition );
2218 aReader.skipIntProperty< sal_uInt32 >(); // unused
2219 aReader.skipIntProperty< sal_uInt32 >(); // prev enabled
2220 aReader.skipIntProperty< sal_uInt32 >(); // next enabled
2221 aReader.readIntProperty< sal_Int32 >( mnSmallChange );
2222 aReader.readIntProperty< sal_Int32 >( mnLargeChange );
2223 aReader.readIntProperty< sal_Int32 >( mnOrientation );
2224 aReader.readIntProperty< sal_Int16 >( mnPropThumb );
2225 aReader.readIntProperty< sal_Int32 >( mnDelay );
2226 aReader.skipPictureProperty(); // mouse icon
2227 return aReader.finalizeImport();
2230 void AxScrollBarModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
2232 AxBinaryPropertyWriter aWriter( rOutStrm );
2233 aWriter.writeIntProperty< sal_uInt32 >( mnArrowColor );
2234 if ( mnBackColor )
2235 aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
2236 else
2237 aWriter.skipProperty(); // default backcolour
2238 aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
2239 aWriter.writePairProperty( maSize );
2240 aWriter.skipProperty(); // mouse pointer
2241 aWriter.writeIntProperty< sal_Int32 >( mnMin );
2242 aWriter.writeIntProperty< sal_Int32 >( mnMax );
2243 aWriter.writeIntProperty< sal_Int32 >( mnPosition );
2244 aWriter.skipProperty(); // unused
2245 aWriter.skipProperty(); // prev enabled
2246 aWriter.skipProperty(); // next enabled
2247 aWriter.writeIntProperty< sal_Int32 >( mnSmallChange );
2248 aWriter.writeIntProperty< sal_Int32 >( mnLargeChange );
2249 aWriter.writeIntProperty< sal_Int32 >( mnOrientation );
2250 aWriter.writeIntProperty< sal_Int16 >( mnPropThumb );
2251 aWriter.writeIntProperty< sal_Int32 >( mnDelay );
2252 aWriter.skipProperty(); // mouse icon
2253 aWriter.finalizeExport();
2256 void AxScrollBarModel::exportCompObj( BinaryOutputStream& rOutStream )
2258 // should be able to replace this hardcoded foo with
2259 // proper export info from MS-OLEDS spec.
2260 static sal_uInt8 const aCompObj[] =
2262 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2263 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x81, 0xD1, 0xDF,
2264 0x2F, 0x5E, 0xCE, 0x11, 0xA4, 0x49, 0x00, 0xAA,
2265 0x00, 0x4A, 0x80, 0x3D, 0x1E, 0x00, 0x00, 0x00,
2266 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2267 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2268 0x32, 0x2E, 0x30, 0x20, 0x53, 0x63, 0x72, 0x6F,
2269 0x6C, 0x6C, 0x42, 0x61, 0x72, 0x00, 0x10, 0x00,
2270 0x00, 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64,
2271 0x65, 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63,
2272 0x74, 0x00, 0x12, 0x00, 0x00, 0x00, 0x46, 0x6F,
2273 0x72, 0x6D, 0x73, 0x2E, 0x53, 0x63, 0x72, 0x6F,
2274 0x6C, 0x6C, 0x42, 0x61, 0x72, 0x2E, 0x31, 0x00,
2275 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
2276 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2278 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
2281 void AxScrollBarModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2283 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
2284 rPropMap.setProperty( PROP_RepeatDelay, mnDelay );
2285 rPropMap.setProperty( PROP_Border, API_BORDER_NONE );
2286 if( (mnPropThumb == AX_PROPTHUMB_ON) && (mnMin != mnMax) && (mnLargeChange > 0) )
2288 // use double to prevent integer overflow in division (fInterval+mnLargeChange may become 0 when performed as int)
2289 double fInterval = fabs( static_cast< double >( mnMax - mnMin ) );
2290 sal_Int32 nThumbLen = getLimitedValue< sal_Int32, double >( (fInterval * mnLargeChange) / (fInterval + mnLargeChange), 1, SAL_MAX_INT32 );
2291 rPropMap.setProperty( PROP_VisibleSize, nThumbLen );
2293 rConv.convertColor( rPropMap, PROP_SymbolColor, mnArrowColor );
2294 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, ApiTransparencyMode::NotSupported );
2295 ControlConverter::convertAxOrientation( rPropMap, maSize, mnOrientation );
2296 ControlConverter::convertScrollBar( rPropMap, mnMin, mnMax, mnPosition, mnSmallChange, mnLargeChange, mbAwtModel );
2297 AxControlModelBase::convertProperties( rPropMap, rConv );
2300 void AxScrollBarModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& )
2302 bool bRes = false;
2303 if ( rPropSet.getProperty( bRes, PROP_Enabled ) )
2304 setFlag( mnFlags, AX_FLAGS_ENABLED, bRes );
2305 rPropSet.getProperty( mnDelay, PROP_RepeatDelay );
2306 mnPropThumb = AX_PROPTHUMB_ON; // default
2307 ControlConverter::convertToMSColor( rPropSet, PROP_SymbolColor, mnArrowColor);
2308 ControlConverter::convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
2309 ControlConverter::convertToAxOrientation( rPropSet, maSize, mnOrientation );
2311 rPropSet.getProperty( mnMin, PROP_ScrollValueMin );
2312 rPropSet.getProperty( mnMax, PROP_ScrollValueMax );
2313 rPropSet.getProperty( mnSmallChange, PROP_LineIncrement );
2314 rPropSet.getProperty( mnLargeChange, PROP_BlockIncrement );
2315 rPropSet.getProperty( mnPosition, ( mbAwtModel ? PROP_ScrollValue : PROP_DefaultScrollValue ) );
2319 AxContainerModelBase::AxContainerModelBase( bool bFontSupport ) :
2320 AxFontDataModel( false ), // no support for alignment properties
2321 maLogicalSize( AX_CONTAINER_DEFWIDTH, AX_CONTAINER_DEFHEIGHT ),
2322 maScrollPos( 0, 0 ),
2323 mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
2324 mnTextColor( AX_SYSCOLOR_BUTTONTEXT ),
2325 mnFlags( AX_CONTAINER_DEFFLAGS ),
2326 mnBorderColor( AX_SYSCOLOR_BUTTONTEXT ),
2327 mnBorderStyle( AX_BORDERSTYLE_NONE ),
2328 mnScrollBars( AX_CONTAINER_SCR_NONE ),
2329 mnCycleType( AX_CONTAINER_CYCLEALL ),
2330 mnSpecialEffect( AX_SPECIALEFFECT_FLAT ),
2331 mnPicAlign( AX_PICALIGN_CENTER ),
2332 mnPicSizeMode( AX_PICSIZE_CLIP ),
2333 mbPicTiling( false ),
2334 mbFontSupport( bFontSupport )
2336 setAwtModelMode();
2337 // different default size for frame
2338 maSize = AxPairData( AX_CONTAINER_DEFWIDTH, AX_CONTAINER_DEFHEIGHT );
2341 void AxContainerModelBase::importProperty( sal_Int32 nPropId, const OUString& rValue )
2343 if( nPropId == XML_Caption )
2344 maCaption = rValue;
2347 bool AxContainerModelBase::importBinaryModel( BinaryInputStream& rInStrm )
2349 AxBinaryPropertyReader aReader( rInStrm );
2350 aReader.skipUndefinedProperty();
2351 aReader.readIntProperty< sal_uInt32 >( mnBackColor );
2352 aReader.readIntProperty< sal_uInt32 >( mnTextColor );
2353 aReader.skipIntProperty< sal_uInt32 >(); // next availbale control ID
2354 aReader.skipUndefinedProperty();
2355 aReader.skipUndefinedProperty();
2356 aReader.readIntProperty< sal_uInt32 >( mnFlags );
2357 aReader.readIntProperty< sal_uInt8 >( mnBorderStyle );
2358 aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
2359 aReader.readIntProperty< sal_uInt8 >( mnScrollBars );
2360 aReader.readPairProperty( maSize );
2361 aReader.readPairProperty( maLogicalSize );
2362 aReader.readPairProperty( maScrollPos );
2363 aReader.skipIntProperty< sal_uInt32 >(); // number of control groups
2364 aReader.skipUndefinedProperty();
2365 aReader.skipPictureProperty(); // mouse icon
2366 aReader.readIntProperty< sal_uInt8 >( mnCycleType );
2367 aReader.readIntProperty< sal_uInt8 >( mnSpecialEffect );
2368 aReader.readIntProperty< sal_uInt32 >( mnBorderColor );
2369 aReader.readStringProperty( maCaption );
2370 aReader.readFontProperty( maFontData );
2371 aReader.readPictureProperty( maPictureData );
2372 aReader.skipIntProperty< sal_Int32 >(); // zoom
2373 aReader.readIntProperty< sal_uInt8 >( mnPicAlign );
2374 aReader.readBoolProperty( mbPicTiling );
2375 aReader.readIntProperty< sal_uInt8 >( mnPicSizeMode );
2376 aReader.skipIntProperty< sal_uInt32 >(); // shape cookie
2377 aReader.skipIntProperty< sal_uInt32 >(); // draw buffer size
2378 return aReader.finalizeImport();
2381 void AxContainerModelBase::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2383 if( mbFontSupport )
2385 rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor );
2386 AxFontDataModel::convertProperties( rPropMap, rConv );
2390 bool AxContainerModelBase::importClassTable( BinaryInputStream& rInStrm, AxClassTable& orClassTable )
2392 bool bValid = true;
2393 orClassTable.clear();
2394 if( !getFlag( mnFlags, AX_CONTAINER_NOCLASSTABLE ) )
2396 sal_uInt16 nCount = rInStrm.readuInt16();
2397 for( sal_uInt16 nIndex = 0; bValid && (nIndex < nCount); ++nIndex )
2399 orClassTable.push_back( OUString() );
2400 AxBinaryPropertyReader aReader( rInStrm );
2401 aReader.readGuidProperty( orClassTable.back() );
2402 aReader.skipGuidProperty(); // source interface GUID
2403 aReader.skipUndefinedProperty();
2404 aReader.skipGuidProperty(); // default interface GUID
2405 aReader.skipIntProperty< sal_uInt32 >(); // class table and var flags
2406 aReader.skipIntProperty< sal_uInt32 >(); // method count
2407 aReader.skipIntProperty< sal_Int32 >(); // IDispatch identifier for linked cell access
2408 aReader.skipIntProperty< sal_uInt16 >(); // get function index for linked cell access
2409 aReader.skipIntProperty< sal_uInt16 >(); // put function index for linked cell access
2410 aReader.skipIntProperty< sal_uInt16 >(); // linked cell access property type
2411 aReader.skipIntProperty< sal_uInt16 >(); // get function index of value
2412 aReader.skipIntProperty< sal_uInt16 >(); // put function index of value
2413 aReader.skipIntProperty< sal_uInt16 >(); // value type
2414 aReader.skipIntProperty< sal_Int32 >(); // IDispatch identifier for source range access
2415 aReader.skipIntProperty< sal_uInt16 >(); // get function index for source range access
2416 bValid = aReader.finalizeImport();
2419 return bValid;
2422 AxFrameModel::AxFrameModel() :
2423 AxContainerModelBase( true )
2427 ApiControlType AxFrameModel::getControlType() const
2429 return mbAwtModel ? API_CONTROL_FRAME : API_CONTROL_GROUPBOX;
2432 void AxFrameModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2434 rPropMap.setProperty( PROP_Label, maCaption );
2435 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_CONTAINER_ENABLED ) );
2436 AxContainerModelBase::convertProperties( rPropMap, rConv );
2439 AxPageModel::AxPageModel()
2443 ApiControlType AxPageModel::getControlType() const
2445 return API_CONTROL_PAGE;
2448 void AxPageModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2450 rPropMap.setProperty( PROP_Title, maCaption );
2451 rConv.convertColor( rPropMap, PROP_BackgroundColor, mnBackColor );
2452 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_CONTAINER_ENABLED ) );
2453 AxContainerModelBase::convertProperties( rPropMap, rConv );
2456 AxMultiPageModel::AxMultiPageModel() :
2457 mnActiveTab( 0 ),
2458 mnTabStyle( AX_TABSTRIP_TABS )
2462 ApiControlType AxMultiPageModel::getControlType() const
2464 return API_CONTROL_MULTIPAGE;
2467 void AxMultiPageModel::importPageAndMultiPageProperties( BinaryInputStream& rInStrm, sal_Int32 nPages )
2469 // PageProperties
2470 for ( sal_Int32 nPage = 0; nPage < nPages; ++nPage )
2472 AxBinaryPropertyReader aReader( rInStrm );
2473 aReader.skipUndefinedProperty();
2474 aReader.skipIntProperty< sal_uInt32 >(); // TransistionEffect
2475 aReader.skipIntProperty< sal_uInt32 >(); // TransitionPeriod
2477 // MultiPageProperties
2478 AxBinaryPropertyReader aReader( rInStrm );
2479 sal_uInt32 nPageCount = 0;
2480 aReader.skipUndefinedProperty();
2481 aReader.readIntProperty< sal_uInt32 >(nPageCount); // PageCount
2482 aReader.skipIntProperty< sal_uInt32 >(); //ID
2484 // IDs
2485 for ( sal_uInt32 count = 0; count < nPageCount; ++count )
2487 mnIDs.push_back( rInStrm.readInt32() );
2491 void AxMultiPageModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2493 rPropMap.setProperty( PROP_Title, maCaption );
2494 rPropMap.setProperty( PROP_MultiPageValue, mnActiveTab + 1);
2495 rConv.convertColor( rPropMap, PROP_BackgroundColor, mnBackColor );
2496 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_CONTAINER_ENABLED ) );
2497 rPropMap.setProperty( PROP_Decoration, mnTabStyle != AX_TABSTRIP_NONE );
2499 AxContainerModelBase::convertProperties( rPropMap, rConv );
2502 AxUserFormModel::AxUserFormModel()
2506 ApiControlType AxUserFormModel::getControlType() const
2508 return API_CONTROL_DIALOG;
2511 void AxUserFormModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2513 rPropMap.setProperty( PROP_Title, maCaption );
2514 rConv.convertColor( rPropMap, PROP_BackgroundColor, mnBackColor );
2515 rConv.convertAxPicture( rPropMap, maPictureData, AX_PICPOS_CENTER );
2516 rConv.convertScrollabilitySettings( rPropMap, maScrollPos, maLogicalSize, mnScrollBars );
2517 AxContainerModelBase::convertProperties( rPropMap, rConv );
2520 HtmlSelectModel::HtmlSelectModel()
2524 bool
2525 HtmlSelectModel::importBinaryModel( BinaryInputStream& rInStrm )
2527 OUString sStringContents = rInStrm.readUnicodeArray( rInStrm.size() );
2529 OUString data = sStringContents;
2531 // replace crlf with lf
2532 data = data.replaceAll( "\x0D\x0A" , "\x0A" );
2533 std::vector< OUString > listValues;
2534 std::vector< sal_Int16 > selectedIndices;
2536 // Ultra hacky parser for the info
2537 sal_Int32 nTokenCount = comphelper::string::getTokenCount(data, '\n');
2539 for ( sal_Int32 nToken = 0; nToken < nTokenCount; ++nToken )
2541 OUString sLine( data.getToken( nToken, '\n' ) );
2542 if ( !nToken ) // first line will tell us if multiselect is enabled
2544 if ( sLine == "<SELECT MULTIPLE" )
2545 mnMultiSelect = AX_SELECTION_MULTI;
2547 // skip first and last lines, no data there
2548 else if ( nToken < nTokenCount - 1)
2550 if ( comphelper::string::getTokenCount(sLine, '>') )
2552 OUString displayValue = sLine.getToken( 1, '>' );
2553 if ( displayValue.getLength() )
2555 // Really we should be using a proper html parser
2556 // escaping some common bits to be escaped
2557 displayValue = displayValue.replaceAll( "&lt;", "<" );
2558 displayValue = displayValue.replaceAll( "&gt;", ">" );
2559 displayValue = displayValue.replaceAll( "&quot;", "\"" );
2560 displayValue = displayValue.replaceAll( "&amp;", "&" );
2561 listValues.push_back( displayValue );
2562 if( sLine.indexOf( "OPTION SELECTED" ) != -1 )
2563 selectedIndices.push_back( static_cast< sal_Int16 >( listValues.size() ) - 1 );
2568 if ( !listValues.empty() )
2570 msListData.realloc( listValues.size() );
2571 sal_Int32 index = 0;
2572 for( std::vector< OUString >::iterator it = listValues.begin(); it != listValues.end(); ++it, ++index )
2573 msListData[ index ] = *it;
2575 if ( !selectedIndices.empty() )
2577 msIndices.realloc( selectedIndices.size() );
2578 sal_Int32 index = 0;
2579 for( std::vector< sal_Int16 >::iterator it = selectedIndices.begin(); it != selectedIndices.end(); ++it, ++index )
2580 msIndices[ index ] = *it;
2582 return true;
2585 void
2586 HtmlSelectModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2588 rPropMap.setProperty( PROP_StringItemList, msListData );
2589 rPropMap.setProperty( PROP_SelectedItems, msIndices );
2590 rPropMap.setProperty( PROP_Dropdown, true );
2591 AxListBoxModel::convertProperties( rPropMap, rConv );
2594 HtmlTextBoxModel::HtmlTextBoxModel()
2598 bool
2599 HtmlTextBoxModel::importBinaryModel( BinaryInputStream& rInStrm )
2601 #ifdef DEBUG
2602 OUString sStringContents = rInStrm.readUnicodeArray( rInStrm.size() );
2603 // in msocximex ( where this is ported from, it appears *nothing* is read
2604 // from the control stream ), surely there is some useful info there ?
2605 SAL_WARN("oox", "HtmlTextBoxModel::importBinaryModel - string contents of stream: " << sStringContents );
2606 #else
2607 (void) rInStrm;
2608 #endif
2609 return true;
2612 EmbeddedControl::EmbeddedControl( const OUString& rName ) :
2613 maName( rName )
2617 ControlModelBase* EmbeddedControl::createModelFromGuid( const OUString& rClassId )
2619 if( rClassId.equalsIgnoreAsciiCase( AX_GUID_COMMANDBUTTON ) ) return &createModel< AxCommandButtonModel >();
2620 if( rClassId.equalsIgnoreAsciiCase( AX_GUID_LABEL ) ) return &createModel< AxLabelModel >();
2621 if( rClassId.equalsIgnoreAsciiCase( AX_GUID_IMAGE ) ) return &createModel< AxImageModel >();
2622 if( rClassId.equalsIgnoreAsciiCase( AX_GUID_TOGGLEBUTTON ) ) return &createModel< AxToggleButtonModel >();
2623 if( rClassId.equalsIgnoreAsciiCase( AX_GUID_CHECKBOX ) ) return &createModel< AxCheckBoxModel >();
2624 if( rClassId.equalsIgnoreAsciiCase( AX_GUID_OPTIONBUTTON ) ) return &createModel< AxOptionButtonModel >();
2625 if( rClassId.equalsIgnoreAsciiCase( AX_GUID_TEXTBOX ) ) return &createModel< AxTextBoxModel >();
2626 if( rClassId.equalsIgnoreAsciiCase( AX_GUID_LISTBOX ) ) return &createModel< AxListBoxModel >();
2627 if( rClassId.equalsIgnoreAsciiCase( AX_GUID_COMBOBOX ) ) return &createModel< AxComboBoxModel >();
2628 if( rClassId.equalsIgnoreAsciiCase( AX_GUID_SPINBUTTON ) ) return &createModel< AxSpinButtonModel >();
2629 if( rClassId.equalsIgnoreAsciiCase( AX_GUID_SCROLLBAR ) ) return &createModel< AxScrollBarModel >();
2630 if( rClassId.equalsIgnoreAsciiCase( AX_GUID_FRAME ) ) return &createModel< AxFrameModel >();
2631 if( rClassId.equalsIgnoreAsciiCase( COMCTL_GUID_SCROLLBAR_60 ) ) return &createModel< ComCtlScrollBarModel >( COMCTL_VERSION_60 );
2632 if( rClassId.equalsIgnoreAsciiCase( HTML_GUID_SELECT ) ) return &createModel< HtmlSelectModel >();
2633 if( rClassId.equalsIgnoreAsciiCase( HTML_GUID_TEXTBOX ) ) return &createModel< HtmlTextBoxModel >();
2635 mxModel.reset();
2636 return nullptr;
2639 OUString EmbeddedControl::getServiceName() const
2641 return mxModel.get() ? mxModel->getServiceName() : OUString();
2644 bool EmbeddedControl::convertProperties( const Reference< XControlModel >& rxCtrlModel, const ControlConverter& rConv ) const
2646 if( mxModel.get() && rxCtrlModel.is() && !maName.isEmpty() )
2648 PropertyMap aPropMap;
2649 aPropMap.setProperty( PROP_Name, maName );
2652 aPropMap.setProperty( PROP_GenerateVbaEvents, true);
2654 catch (const Exception& e)
2656 SAL_WARN("oox", "exception: " << e.Message);
2658 mxModel->convertProperties( aPropMap, rConv );
2659 PropertySet aPropSet( rxCtrlModel );
2660 aPropSet.setProperties( aPropMap );
2661 return true;
2663 return false;
2666 void EmbeddedControl::convertFromProperties( const Reference< XControlModel >& rxCtrlModel, const ControlConverter& rConv )
2668 if( mxModel.get() && rxCtrlModel.is() && !maName.isEmpty() )
2670 PropertySet aPropSet( rxCtrlModel );
2671 aPropSet.getProperty( maName, PROP_Name );
2672 mxModel->convertFromProperties( aPropSet, rConv );
2676 EmbeddedForm::EmbeddedForm( const Reference< XModel >& rxDocModel,
2677 const Reference< XDrawPage >& rxDrawPage, const GraphicHelper& rGraphicHelper ) :
2678 maControlConv( rxDocModel, rGraphicHelper, true/*bDefaultColorBgr*/ ),
2679 mxModelFactory( rxDocModel, UNO_QUERY ),
2680 mxFormsSupp( rxDrawPage, UNO_QUERY )
2682 OSL_ENSURE( mxModelFactory.is(), "EmbeddedForm::EmbeddedForm - missing service factory" );
2685 Reference< XControlModel > EmbeddedForm::convertAndInsert( const EmbeddedControl& rControl, sal_Int32& rnCtrlIndex )
2687 Reference< XControlModel > xRet;
2688 if( mxModelFactory.is() && rControl.hasModel() ) try
2690 // create the UNO control model
2691 OUString aServiceName = rControl.getServiceName();
2692 Reference< XFormComponent > xFormComp( mxModelFactory->createInstance( aServiceName ), UNO_QUERY_THROW );
2693 Reference< XControlModel > xCtrlModel( xFormComp, UNO_QUERY_THROW );
2695 // convert the control properties
2696 if( rControl.convertProperties( xCtrlModel, maControlConv ) )
2697 xRet = xCtrlModel;
2698 // insert the control into the form
2699 Reference< XIndexContainer > xFormIC( createXForm(), UNO_SET_THROW );
2700 rnCtrlIndex = xFormIC->getCount();
2701 xFormIC->insertByIndex( rnCtrlIndex, Any( xFormComp ) );
2703 catch (const Exception& e)
2705 SAL_WARN("oox", "exception creating Control: " << e.Message);
2707 return xRet;
2710 Reference< XIndexContainer > const & EmbeddedForm::createXForm()
2712 if( mxFormsSupp.is() )
2716 Reference< XNameContainer > xFormsNC( mxFormsSupp->getForms(), UNO_SET_THROW );
2717 OUString aFormName = "Standard";
2718 if( xFormsNC->hasByName( aFormName ) )
2720 mxFormIC.set( xFormsNC->getByName( aFormName ), UNO_QUERY_THROW );
2722 else if( mxModelFactory.is() )
2724 Reference< XForm > xForm( mxModelFactory->createInstance( "com.sun.star.form.component.Form" ), UNO_QUERY_THROW );
2725 xFormsNC->insertByName( aFormName, Any( xForm ) );
2726 mxFormIC.set( xForm, UNO_QUERY_THROW );
2729 catch (const Exception& e)
2731 SAL_WARN("oox", "exception creating Form: " << e.Message);
2733 // always clear the forms supplier to not try to create the form again
2734 mxFormsSupp.clear();
2736 return mxFormIC;
2739 } // namespace ole
2740 } // namespace oox
2742 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */