bump product version to 4.1.6.2
[LibreOffice.git] / oox / source / ole / axcontrol.cxx
blobd5303a4eea7e02e16a3d45b8d252e5b58ecb30af
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/container/XIndexContainer.hpp>
36 #include <com/sun/star/form/XForm.hpp>
37 #include <com/sun/star/form/XFormComponent.hpp>
38 #include <com/sun/star/form/XFormsSupplier.hpp>
39 #include <com/sun/star/form/binding/XBindableValue.hpp>
40 #include <com/sun/star/form/binding/XListEntrySink.hpp>
41 #include <com/sun/star/form/binding/XListEntrySource.hpp>
42 #include <com/sun/star/form/binding/XValueBinding.hpp>
43 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
44 #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
45 #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
46 #include <com/sun/star/style/VerticalAlignment.hpp>
47 #include <com/sun/star/table/CellAddress.hpp>
48 #include <com/sun/star/table/CellRangeAddress.hpp>
49 #include <comphelper/string.hxx>
50 #include <rtl/tencinfo.h>
51 #include "oox/helper/attributelist.hxx"
52 #include "oox/helper/binaryinputstream.hxx"
53 #include "oox/helper/containerhelper.hxx"
54 #include "oox/helper/graphichelper.hxx"
55 #include "oox/helper/propertymap.hxx"
56 #include "oox/ole/axbinarywriter.hxx"
57 #include "tools/string.hxx"
58 namespace oox {
59 namespace ole {
61 using namespace ::com::sun::star;
62 using namespace ::com::sun::star::awt;
63 using namespace ::com::sun::star::beans;
64 using namespace ::com::sun::star::container;
65 using namespace ::com::sun::star::drawing;
66 using namespace ::com::sun::star::form;
67 using namespace ::com::sun::star::form::binding;
68 using namespace ::com::sun::star::frame;
69 using namespace ::com::sun::star::lang;
70 using namespace ::com::sun::star::sheet;
71 using namespace ::com::sun::star::style;
72 using namespace ::com::sun::star::table;
73 using namespace ::com::sun::star::uno;
75 namespace {
77 const sal_uInt32 COMCTL_ID_SIZE = 0x12344321;
79 const sal_uInt32 COMCTL_ID_COMMONDATA = 0xABCDEF01;
80 const sal_uInt32 COMCTL_COMMON_FLATBORDER = 0x00000001;
81 const sal_uInt32 COMCTL_COMMON_ENABLED = 0x00000002;
82 const sal_uInt32 COMCTL_COMMON_3DBORDER = 0x00000004;
83 const sal_uInt32 COMCTL_COMMON_OLEDROPMAN = 0x00002000;
85 const sal_uInt32 COMCTL_ID_COMPLEXDATA = 0xBDECDE1F;
86 const sal_uInt32 COMCTL_COMPLEX_FONT = 0x00000001;
87 const sal_uInt32 COMCTL_COMPLEX_MOUSEICON = 0x00000002;
89 const sal_uInt32 COMCTL_ID_SCROLLBAR_60 = 0x99470A83;
90 const sal_uInt32 COMCTL_SCROLLBAR_HOR = 0x00000010;
91 const sal_Int32 COMCTL_SCROLLBAR_3D = 0;
92 const sal_Int32 COMCTL_SCROLLBAR_FLAT = 1;
93 const sal_Int32 COMCTL_SCROLLBAR_TRACK3D = 2;
95 const sal_uInt32 COMCTL_ID_PROGRESSBAR_50 = 0xE6E17E84;
96 const sal_uInt32 COMCTL_ID_PROGRESSBAR_60 = 0x97AB8A01;
98 // ----------------------------------------------------------------------------
100 const sal_uInt32 AX_CMDBUTTON_DEFFLAGS = 0x0000001B;
101 const sal_uInt32 AX_LABEL_DEFFLAGS = 0x0080001B;
102 const sal_uInt32 AX_IMAGE_DEFFLAGS = 0x0000001B;
103 const sal_uInt32 AX_MORPHDATA_DEFFLAGS = 0x2C80081B;
104 const sal_uInt32 AX_SPINBUTTON_DEFFLAGS = 0x0000001B;
105 const sal_uInt32 AX_SCROLLBAR_DEFFLAGS = 0x0000001B;
106 const sal_uInt32 AX_TABSTRIP_DEFFLAGS = 0x0000001B;
108 const sal_uInt16 AX_POS_TOPLEFT = 0;
109 const sal_uInt16 AX_POS_TOP = 1;
110 const sal_uInt16 AX_POS_TOPRIGHT = 2;
111 const sal_uInt16 AX_POS_LEFT = 3;
112 const sal_uInt16 AX_POS_CENTER = 4;
113 const sal_uInt16 AX_POS_RIGHT = 5;
114 const sal_uInt16 AX_POS_BOTTOMLEFT = 6;
115 const sal_uInt16 AX_POS_BOTTOM = 7;
116 const sal_uInt16 AX_POS_BOTTOMRIGHT = 8;
118 #define AX_PICPOS_IMPL( label, image ) ((AX_POS_##label << 16) | AX_POS_##image)
119 const sal_uInt32 AX_PICPOS_LEFTTOP = AX_PICPOS_IMPL( TOPRIGHT, TOPLEFT );
120 const sal_uInt32 AX_PICPOS_LEFTCENTER = AX_PICPOS_IMPL( RIGHT, LEFT );
121 const sal_uInt32 AX_PICPOS_LEFTBOTTOM = AX_PICPOS_IMPL( BOTTOMRIGHT, BOTTOMLEFT );
122 const sal_uInt32 AX_PICPOS_RIGHTTOP = AX_PICPOS_IMPL( TOPLEFT, TOPRIGHT );
123 const sal_uInt32 AX_PICPOS_RIGHTCENTER = AX_PICPOS_IMPL( LEFT, RIGHT );
124 const sal_uInt32 AX_PICPOS_RIGHTBOTTOM = AX_PICPOS_IMPL( BOTTOMLEFT, BOTTOMRIGHT );
125 const sal_uInt32 AX_PICPOS_ABOVELEFT = AX_PICPOS_IMPL( BOTTOMLEFT, TOPLEFT );
126 const sal_uInt32 AX_PICPOS_ABOVECENTER = AX_PICPOS_IMPL( BOTTOM, TOP );
127 const sal_uInt32 AX_PICPOS_ABOVERIGHT = AX_PICPOS_IMPL( BOTTOMRIGHT, TOPRIGHT );
128 const sal_uInt32 AX_PICPOS_BELOWLEFT = AX_PICPOS_IMPL( TOPLEFT, BOTTOMLEFT );
129 const sal_uInt32 AX_PICPOS_BELOWCENTER = AX_PICPOS_IMPL( TOP, BOTTOM );
130 const sal_uInt32 AX_PICPOS_BELOWRIGHT = AX_PICPOS_IMPL( TOPRIGHT, BOTTOMRIGHT );
131 const sal_uInt32 AX_PICPOS_CENTER = AX_PICPOS_IMPL( CENTER, CENTER );
132 #undef AX_PICPOS_IMPL
134 const sal_Int32 AX_MATCHENTRY_FIRSTLETTER = 0;
135 const sal_Int32 AX_MATCHENTRY_COMPLETE = 1;
136 const sal_Int32 AX_MATCHENTRY_NONE = 2;
138 const sal_Int32 AX_ORIENTATION_AUTO = -1;
139 const sal_Int32 AX_ORIENTATION_VERTICAL = 0;
140 const sal_Int32 AX_ORIENTATION_HORIZONTAL = 1;
142 const sal_Int32 AX_PROPTHUMB_ON = -1;
143 const sal_Int32 AX_PROPTHUMB_OFF = 0;
145 const sal_uInt32 AX_TABSTRIP_TABS = 0;
146 const sal_uInt32 AX_TABSTRIP_BUTTONS = 1;
147 const sal_uInt32 AX_TABSTRIP_NONE = 2;
149 const sal_uInt32 AX_CONTAINER_ENABLED = 0x00000004;
150 const sal_uInt32 AX_CONTAINER_HASDESIGNEXT = 0x00004000;
151 const sal_uInt32 AX_CONTAINER_NOCLASSTABLE = 0x00008000;
153 const sal_uInt32 AX_CONTAINER_DEFFLAGS = 0x00000004;
155 const sal_Int32 AX_CONTAINER_DEFWIDTH = 4000;
156 const sal_Int32 AX_CONTAINER_DEFHEIGHT = 3000;
158 const sal_Int32 AX_CONTAINER_CYCLEALL = 0;
159 const sal_Int32 AX_CONTAINER_CYCLECURRENT = 2;
161 const sal_Int32 AX_CONTAINER_SCR_NONE = 0x00;
162 const sal_Int32 AX_CONTAINER_SCR_HOR = 0x01;
163 const sal_Int32 AX_CONTAINER_SCR_VER = 0x02;
164 const sal_Int32 AX_CONTAINER_SCR_KEEP_HOR = 0x04;
165 const sal_Int32 AX_CONTAINER_SCR_KEEP_VER = 0x08;
166 const sal_Int32 AX_CONTAINER_SCR_SHOW_LEFT = 0x10;
168 // ----------------------------------------------------------------------------
170 const sal_Int16 API_BORDER_NONE = 0;
171 const sal_Int16 API_BORDER_SUNKEN = 1;
172 const sal_Int16 API_BORDER_FLAT = 2;
174 const sal_Int16 API_STATE_UNCHECKED = 0;
175 const sal_Int16 API_STATE_CHECKED = 1;
176 const sal_Int16 API_STATE_DONTKNOW = 2;
178 // ----------------------------------------------------------------------------
180 /** Tries to extract a range address from a defined name. */
181 bool lclExtractRangeFromName( CellRangeAddress& orRangeAddr, const Reference< XModel >& rxDocModel, const OUString& rAddressString )
185 PropertySet aPropSet( rxDocModel );
186 Reference< XNameAccess > xRangesNA( aPropSet.getAnyProperty( PROP_NamedRanges ), UNO_QUERY_THROW );
187 Reference< XCellRangeReferrer > xReferrer( xRangesNA->getByName( rAddressString ), UNO_QUERY_THROW );
188 Reference< XCellRangeAddressable > xAddressable( xReferrer->getReferredCells(), UNO_QUERY_THROW );
189 orRangeAddr = xAddressable->getRangeAddress();
190 return true;
192 catch (const Exception& e)
194 SAL_WARN("oox", "exception: " << e.Message);
196 return false;
199 bool lclExtractAddressFromName( CellAddress& orAddress, const Reference< XModel >& rxDocModel, const OUString& rAddressString )
201 CellRangeAddress aRangeAddr;
202 if( lclExtractRangeFromName( aRangeAddr, rxDocModel, rAddressString ) &&
203 (aRangeAddr.StartColumn == aRangeAddr.EndColumn) &&
204 (aRangeAddr.StartRow == aRangeAddr.EndRow) )
206 orAddress.Sheet = aRangeAddr.Sheet;
207 orAddress.Column = aRangeAddr.StartColumn;
208 orAddress.Row = aRangeAddr.StartRow;
209 return true;
211 return false;
214 void lclPrepareConverter( PropertySet& rConverter, const Reference< XModel >& rxDocModel,
215 const OUString& rAddressString, sal_Int32 nRefSheet, bool bRange )
217 if( !rConverter.is() ) try
219 Reference< XMultiServiceFactory > xModelFactory( rxDocModel, UNO_QUERY_THROW );
220 OUString aServiceName = bRange ?
221 OUString( "com.sun.star.table.CellRangeAddressConversion" ) :
222 OUString( "com.sun.star.table.CellAddressConversion" );
223 rConverter.set( xModelFactory->createInstance( aServiceName ) );
225 catch (const Exception& e)
227 SAL_WARN("oox", "exception: " << e.Message);
229 rConverter.setProperty( PROP_XLA1Representation, rAddressString );
230 rConverter.setProperty( PROP_ReferenceSheet, nRefSheet );
233 } // namespace
235 // ============================================================================
237 ControlConverter::ControlConverter( const Reference< XModel >& rxDocModel,
238 const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ) :
239 mxDocModel( rxDocModel ),
240 mrGraphicHelper( rGraphicHelper ),
241 mbDefaultColorBgr( bDefaultColorBgr )
243 OSL_ENSURE( mxDocModel.is(), "ControlConverter::ControlConverter - missing document model" );
246 ControlConverter::~ControlConverter()
250 // Generic conversion ---------------------------------------------------------
252 void ControlConverter::convertPosition( PropertyMap& rPropMap, const AxPairData& rPos ) const
254 // position is given in 1/100 mm, UNO needs AppFont units
255 awt::Point aAppFontPos = mrGraphicHelper.convertHmmToAppFont( awt::Point( rPos.first, rPos.second ) );
256 rPropMap.setProperty( PROP_PositionX, aAppFontPos.X );
257 rPropMap.setProperty( PROP_PositionY, aAppFontPos.Y );
260 void ControlConverter::convertSize( PropertyMap& rPropMap, const AxPairData& rSize ) const
262 // size is given in 1/100 mm, UNO needs AppFont units
263 awt::Size aAppFontSize = mrGraphicHelper.convertHmmToAppFont( awt::Size( rSize.first, rSize.second ) );
264 rPropMap.setProperty( PROP_Width, aAppFontSize.Width );
265 rPropMap.setProperty( PROP_Height, aAppFontSize.Height );
268 void ControlConverter::convertColor( PropertyMap& rPropMap, sal_Int32 nPropId, sal_uInt32 nOleColor ) const
270 rPropMap.setProperty( nPropId, OleHelper::decodeOleColor( mrGraphicHelper, nOleColor, mbDefaultColorBgr ) );
273 void ControlConverter::convertToMSColor( PropertySet& rPropSet, sal_Int32 nPropId, sal_uInt32& nOleColor, sal_uInt32 nDefault ) const
275 sal_uInt32 nRGB = 0;
276 if (rPropSet.getProperty( nRGB, nPropId ))
277 nOleColor = OleHelper::encodeOleColor( nRGB );
278 else
279 nOleColor = nDefault;
281 void ControlConverter::convertPicture( PropertyMap& rPropMap, const StreamDataSequence& rPicData ) const
283 if( rPicData.hasElements() )
285 OUString aGraphicUrl = mrGraphicHelper.importGraphicObject( rPicData );
286 if( !aGraphicUrl.isEmpty() )
287 rPropMap.setProperty( PROP_ImageURL, aGraphicUrl );
291 void ControlConverter::convertOrientation( PropertyMap& rPropMap, bool bHorizontal ) const
293 sal_Int32 nScrollOrient = bHorizontal ? ScrollBarOrientation::HORIZONTAL : ScrollBarOrientation::VERTICAL;
294 rPropMap.setProperty( PROP_Orientation, nScrollOrient );
297 void ControlConverter::convertToMSOrientation( PropertySet& rPropSet, bool& bHorizontal ) const
299 sal_Int32 nScrollOrient = ScrollBarOrientation::HORIZONTAL;
300 if ( rPropSet.getProperty( nScrollOrient, PROP_Orientation ) )
301 bHorizontal = ( nScrollOrient == ScrollBarOrientation::HORIZONTAL );
304 void ControlConverter::convertVerticalAlign( PropertyMap& rPropMap, sal_Int32 nVerticalAlign ) const
306 VerticalAlignment eAlign = VerticalAlignment_TOP;
307 switch( nVerticalAlign )
309 case XML_Top: eAlign = VerticalAlignment_TOP; break;
310 case XML_Center: eAlign = VerticalAlignment_MIDDLE; break;
311 case XML_Bottom: eAlign = VerticalAlignment_BOTTOM; break;
313 rPropMap.setProperty( PROP_VerticalAlign, eAlign );
316 void ControlConverter::convertScrollabilitySettings( PropertyMap& rPropMap,
317 const AxPairData& rScrollPos, const AxPairData& rScrollArea,
318 sal_Int32 nScrollBars ) const
320 awt::Size tmpSize = mrGraphicHelper.convertHmmToAppFont( awt::Size( rScrollArea.first, rScrollArea.second ) );
321 awt::Point tmpPos = mrGraphicHelper.convertHmmToAppFont( awt::Point( rScrollPos.first, rScrollPos.second ) );
322 rPropMap.setProperty( PROP_ScrollHeight, tmpSize.Height );
323 rPropMap.setProperty( PROP_ScrollWidth, tmpSize.Width );
324 rPropMap.setProperty( PROP_ScrollTop, tmpPos.Y );
325 rPropMap.setProperty( PROP_ScrollLeft, tmpPos.X );
326 rPropMap.setProperty( PROP_HScroll, ( nScrollBars & 0x1 ) == 0x1 );
327 rPropMap.setProperty( PROP_VScroll, ( nScrollBars & 0x2 ) == 0x2 );
330 void ControlConverter::convertScrollBar( PropertyMap& rPropMap,
331 sal_Int32 nMin, sal_Int32 nMax, sal_Int32 nPosition,
332 sal_Int32 nSmallChange, sal_Int32 nLargeChange, bool bAwtModel ) const
334 rPropMap.setProperty( PROP_ScrollValueMin, ::std::min( nMin, nMax ) );
335 rPropMap.setProperty( PROP_ScrollValueMax, ::std::max( nMin, nMax ) );
336 rPropMap.setProperty( PROP_LineIncrement, nSmallChange );
337 rPropMap.setProperty( PROP_BlockIncrement, nLargeChange );
338 rPropMap.setProperty( bAwtModel ? PROP_ScrollValue : PROP_DefaultScrollValue, nPosition );
341 void ControlConverter::bindToSources( const Reference< XControlModel >& rxCtrlModel,
342 const OUString& rCtrlSource, const OUString& rRowSource, sal_Int32 nRefSheet ) const
344 // value binding
345 if( !rCtrlSource.isEmpty() ) try
347 // first check if the XBindableValue interface is supported
348 Reference< XBindableValue > xBindable( rxCtrlModel, UNO_QUERY_THROW );
350 // convert address string to cell address struct
351 CellAddress aAddress;
352 if( !lclExtractAddressFromName( aAddress, mxDocModel, rCtrlSource ) )
354 lclPrepareConverter( maAddressConverter, mxDocModel, rCtrlSource, nRefSheet, false );
355 if( !maAddressConverter.getProperty( aAddress, PROP_Address ) )
356 throw RuntimeException();
359 // create argument sequence
360 NamedValue aValue;
361 aValue.Name = "BoundCell";
362 aValue.Value <<= aAddress;
363 Sequence< Any > aArgs( 1 );
364 aArgs[ 0 ] <<= aValue;
366 // create the CellValueBinding instance and set at the control model
367 Reference< XMultiServiceFactory > xModelFactory( mxDocModel, UNO_QUERY_THROW );
368 Reference< XValueBinding > xBinding( xModelFactory->createInstanceWithArguments( "com.sun.star.table.CellValueBinding", aArgs ), UNO_QUERY_THROW );
369 xBindable->setValueBinding( xBinding );
371 catch (const Exception& e)
373 SAL_WARN("oox", "exception: " << e.Message);
376 // list entry source
377 if( !rRowSource.isEmpty() ) try
379 // first check if the XListEntrySink interface is supported
380 Reference< XListEntrySink > xEntrySink( rxCtrlModel, UNO_QUERY_THROW );
382 // convert address string to cell range address struct
383 CellRangeAddress aRangeAddr;
384 if( !lclExtractRangeFromName( aRangeAddr, mxDocModel, rRowSource ) )
386 lclPrepareConverter( maRangeConverter, mxDocModel, rRowSource, nRefSheet, true );
387 if( !maRangeConverter.getProperty( aRangeAddr, PROP_Address ) )
388 throw RuntimeException();
391 // create argument sequence
392 NamedValue aValue;
393 aValue.Name = "CellRange";
394 aValue.Value <<= aRangeAddr;
395 Sequence< Any > aArgs( 1 );
396 aArgs[ 0 ] <<= aValue;
398 // create the EntrySource instance and set at the control model
399 Reference< XMultiServiceFactory > xModelFactory( mxDocModel, UNO_QUERY_THROW );
400 Reference< XListEntrySource > xEntrySource( xModelFactory->createInstanceWithArguments("com.sun.star.table.CellRangeListSource", aArgs ), UNO_QUERY_THROW );
401 xEntrySink->setListEntrySource( xEntrySource );
403 catch (const Exception& e)
405 SAL_WARN("oox", "exception: " << e.Message);
409 // ActiveX (Forms 2.0) specific conversion ------------------------------------
411 void ControlConverter::convertAxBackground( PropertyMap& rPropMap,
412 sal_uInt32 nBackColor, sal_uInt32 nFlags, ApiTransparencyMode eTranspMode ) const
414 bool bOpaque = getFlag( nFlags, AX_FLAGS_OPAQUE );
415 switch( eTranspMode )
417 case API_TRANSPARENCY_NOTSUPPORTED:
418 // fake transparency by using system window background if needed
419 convertColor( rPropMap, PROP_BackgroundColor, bOpaque ? nBackColor : AX_SYSCOLOR_WINDOWBACK );
420 break;
421 case API_TRANSPARENCY_PAINTTRANSPARENT:
422 rPropMap.setProperty( PROP_PaintTransparent, !bOpaque );
423 // run-through intended!
424 case API_TRANSPARENCY_VOID:
425 // keep transparency by leaving the (void) default property value
426 if( bOpaque )
427 convertColor( rPropMap, PROP_BackgroundColor, nBackColor );
428 break;
432 void ControlConverter::convertAxBorder( PropertyMap& rPropMap,
433 sal_uInt32 nBorderColor, sal_Int32 nBorderStyle, sal_Int32 nSpecialEffect ) const
435 sal_Int16 nBorder = (nBorderStyle == AX_BORDERSTYLE_SINGLE) ? API_BORDER_FLAT :
436 ((nSpecialEffect == AX_SPECIALEFFECT_FLAT) ? API_BORDER_NONE : API_BORDER_SUNKEN);
437 rPropMap.setProperty( PROP_Border, nBorder );
438 convertColor( rPropMap, PROP_BorderColor, nBorderColor );
441 void ControlConverter::convertToAxBorder( PropertySet& rPropSet,
442 sal_uInt32& nBorderColor, sal_Int32& nBorderStyle, sal_Int32& nSpecialEffect ) const
444 sal_Int16 nBorder = API_BORDER_NONE;
445 rPropSet.getProperty( nBorder, PROP_Border );
446 nBorderStyle = AX_BORDERSTYLE_NONE;
447 nSpecialEffect = AX_SPECIALEFFECT_FLAT;
448 switch ( nBorder )
450 case API_BORDER_FLAT:
451 nBorderStyle = AX_BORDERSTYLE_SINGLE;
452 break;
453 case API_BORDER_SUNKEN:
454 nSpecialEffect = AX_SPECIALEFFECT_SUNKEN;
455 case API_BORDER_NONE:
456 default:
457 break;
459 convertToMSColor( rPropSet, PROP_BorderColor, nBorderColor );
462 void ControlConverter::convertAxVisualEffect( PropertyMap& rPropMap, sal_Int32 nSpecialEffect ) const
464 sal_Int16 nVisualEffect = (nSpecialEffect == AX_SPECIALEFFECT_FLAT) ? VisualEffect::FLAT : VisualEffect::LOOK3D;
465 rPropMap.setProperty( PROP_VisualEffect, nVisualEffect );
468 void ControlConverter::convertToAxVisualEffect( PropertySet& rPropSet, sal_Int32& nSpecialEffect ) const
470 sal_Int16 nVisualEffect = AX_SPECIALEFFECT_FLAT;
471 rPropSet.getProperty( nVisualEffect, PROP_VisualEffect );
472 // is this appropriate AX_SPECIALEFFECT_XXXX value ?
473 if (nVisualEffect == VisualEffect::LOOK3D )
474 nSpecialEffect = AX_SPECIALEFFECT_RAISED;
477 void ControlConverter::convertAxPicture( PropertyMap& rPropMap, const StreamDataSequence& rPicData, sal_uInt32 nPicPos ) const
479 // the picture
480 convertPicture( rPropMap, rPicData );
482 // picture position
483 sal_Int16 nImagePos = ImagePosition::LeftCenter;
484 switch( nPicPos )
486 case AX_PICPOS_LEFTTOP: nImagePos = ImagePosition::LeftTop; break;
487 case AX_PICPOS_LEFTCENTER: nImagePos = ImagePosition::LeftCenter; break;
488 case AX_PICPOS_LEFTBOTTOM: nImagePos = ImagePosition::LeftBottom; break;
489 case AX_PICPOS_RIGHTTOP: nImagePos = ImagePosition::RightTop; break;
490 case AX_PICPOS_RIGHTCENTER: nImagePos = ImagePosition::RightCenter; break;
491 case AX_PICPOS_RIGHTBOTTOM: nImagePos = ImagePosition::RightBottom; break;
492 case AX_PICPOS_ABOVELEFT: nImagePos = ImagePosition::AboveLeft; break;
493 case AX_PICPOS_ABOVECENTER: nImagePos = ImagePosition::AboveCenter; break;
494 case AX_PICPOS_ABOVERIGHT: nImagePos = ImagePosition::AboveRight; break;
495 case AX_PICPOS_BELOWLEFT: nImagePos = ImagePosition::BelowLeft; break;
496 case AX_PICPOS_BELOWCENTER: nImagePos = ImagePosition::BelowCenter; break;
497 case AX_PICPOS_BELOWRIGHT: nImagePos = ImagePosition::BelowRight; break;
498 case AX_PICPOS_CENTER: nImagePos = ImagePosition::Centered; break;
499 default: OSL_FAIL( "ControlConverter::convertAxPicture - unknown picture position" );
501 rPropMap.setProperty( PROP_ImagePosition, nImagePos );
504 void ControlConverter::convertAxPicture( PropertyMap& rPropMap, const StreamDataSequence& rPicData,
505 sal_Int32 nPicSizeMode, sal_Int32 /*nPicAlign*/, bool /*bPicTiling*/ ) const
507 // the picture
508 convertPicture( rPropMap, rPicData );
510 // picture scale mode
511 sal_Int16 nScaleMode = ImageScaleMode::None;
512 switch( nPicSizeMode )
514 case AX_PICSIZE_CLIP: nScaleMode = ImageScaleMode::None; break;
515 case AX_PICSIZE_STRETCH: nScaleMode = ImageScaleMode::Anisotropic; break;
516 case AX_PICSIZE_ZOOM: nScaleMode = ImageScaleMode::Isotropic; break;
517 default: OSL_FAIL( "ControlConverter::convertAxPicture - unknown picture size mode" );
519 rPropMap.setProperty( PROP_ScaleMode, nScaleMode );
522 void ControlConverter::convertAxState( PropertyMap& rPropMap,
523 const OUString& rValue, sal_Int32 nMultiSelect, ApiDefaultStateMode eDefStateMode, bool bAwtModel ) const
525 bool bBooleanState = eDefStateMode == API_DEFAULTSTATE_BOOLEAN;
526 bool bSupportsTriState = eDefStateMode == API_DEFAULTSTATE_TRISTATE;
528 // state
529 sal_Int16 nState = bSupportsTriState ? API_STATE_DONTKNOW : API_STATE_UNCHECKED;
530 if( rValue.getLength() == 1 ) switch( rValue[ 0 ] )
532 case '0': nState = API_STATE_UNCHECKED; break;
533 case '1': nState = API_STATE_CHECKED; break;
534 // any other string (also empty) means 'dontknow'
536 sal_Int32 nPropId = bAwtModel ? PROP_State : PROP_DefaultState;
537 if( bBooleanState )
538 rPropMap.setProperty( nPropId, nState != API_STATE_UNCHECKED );
539 else
540 rPropMap.setProperty( nPropId, nState );
542 // tristate
543 if( bSupportsTriState )
544 rPropMap.setProperty( PROP_TriState, nMultiSelect == AX_SELCTION_MULTI );
547 void ControlConverter::convertToAxState( PropertySet& rPropSet,
548 OUString& rValue, sal_Int32& nMultiSelect, ApiDefaultStateMode eDefStateMode, bool /*bAwtModel*/ ) const
550 bool bSupportsTriState = eDefStateMode == API_DEFAULTSTATE_TRISTATE;
552 sal_Int16 nState = API_STATE_DONTKNOW;
554 sal_Bool bTmp = sal_False;
555 // need to use State for current state ( I think this is regardless of whether
556 // control is awt or not )
557 rPropSet.getProperty( nState, PROP_State );
559 rValue = OUString(); // empty e.g. 'don't know'
560 if ( nState == API_STATE_UNCHECKED )
561 rValue = OUString('0');
562 else if ( nState == API_STATE_CHECKED )
563 rValue = OUString('1');
565 // tristate
566 if( bSupportsTriState && rPropSet.getProperty( bTmp, PROP_TriState ) )
567 nMultiSelect = AX_SELCTION_MULTI;
570 void ControlConverter::convertAxOrientation( PropertyMap& rPropMap,
571 const AxPairData& rSize, sal_Int32 nOrientation ) const
573 bool bHorizontal = true;
574 switch( nOrientation )
576 case AX_ORIENTATION_AUTO: bHorizontal = rSize.first > rSize.second; break;
577 case AX_ORIENTATION_VERTICAL: bHorizontal = false; break;
578 case AX_ORIENTATION_HORIZONTAL: bHorizontal = true; break;
579 default: OSL_FAIL( "ControlConverter::convertAxOrientation - unknown orientation" );
581 convertOrientation( rPropMap, bHorizontal );
584 void ControlConverter::convertToAxOrientation( PropertySet& rPropSet,
585 const AxPairData& /*rSize*/, sal_Int32& nOrientation ) const
587 bool bHorizontal = true;
588 convertToMSOrientation( rPropSet, bHorizontal );
590 if ( bHorizontal )
591 nOrientation = AX_ORIENTATION_HORIZONTAL;
592 else
593 nOrientation = AX_ORIENTATION_VERTICAL;
596 // ============================================================================
598 ControlModelBase::ControlModelBase() :
599 maSize( 0, 0 ),
600 mbAwtModel( false )
604 ControlModelBase::~ControlModelBase()
608 OUString ControlModelBase::getServiceName() const
610 ApiControlType eCtrlType = getControlType();
611 if( mbAwtModel ) switch( eCtrlType )
613 case API_CONTROL_BUTTON: return OUString( "com.sun.star.awt.UnoControlButtonModel" );
614 case API_CONTROL_FIXEDTEXT: return OUString( "com.sun.star.awt.UnoControlFixedTextModel" );
615 case API_CONTROL_IMAGE: return OUString( "com.sun.star.awt.UnoControlImageControlModel" );
616 case API_CONTROL_CHECKBOX: return OUString( "com.sun.star.awt.UnoControlCheckBoxModel" );
617 case API_CONTROL_RADIOBUTTON: return OUString( "com.sun.star.form.component.RadioButton" );
618 case API_CONTROL_EDIT: return OUString( "com.sun.star.awt.UnoControlEditModel" );
619 case API_CONTROL_NUMERIC: return OUString( "com.sun.star.awt.UnoControlNumericFieldModel" );
620 case API_CONTROL_LISTBOX: return OUString( "com.sun.star.form.component.ListBox" );
621 case API_CONTROL_COMBOBOX: return OUString( "com.sun.star.form.component.ComboBox" );
622 case API_CONTROL_SPINBUTTON: return OUString( "com.sun.star.form.component.SpinButton" );
623 case API_CONTROL_SCROLLBAR: return OUString( "com.sun.star.form.component.ScrollBar" );
624 case API_CONTROL_PROGRESSBAR: return OUString( "com.sun.star.awt.UnoControlProgressBarModel" );
625 case API_CONTROL_GROUPBOX: return OUString( "com.sun.star.form.component.GroupBox" );
626 case API_CONTROL_FRAME: return OUString( "com.sun.star.awt.UnoFrameModel" );
627 case API_CONTROL_PAGE: return OUString( "com.sun.star.awt.UnoPageModel" );
628 case API_CONTROL_MULTIPAGE: return OUString( "com.sun.star.awt.UnoMultiPageModel" );
629 case API_CONTROL_DIALOG: return OUString( "com.sun.star.awt.UnoControlDialogModel" );
630 default: OSL_FAIL( "ControlModelBase::getServiceName - no AWT model service supported" );
632 else switch( eCtrlType )
634 case API_CONTROL_BUTTON: return OUString( "com.sun.star.form.component.CommandButton" );
635 case API_CONTROL_FIXEDTEXT: return OUString( "com.sun.star.form.component.FixedText" );
636 case API_CONTROL_IMAGE: return OUString( "com.sun.star.form.component.DatabaseImageControl" );
637 case API_CONTROL_CHECKBOX: return OUString( "com.sun.star.form.component.CheckBox" );
638 case API_CONTROL_RADIOBUTTON: return OUString( "com.sun.star.form.component.RadioButton" );
639 case API_CONTROL_EDIT: return OUString( "com.sun.star.form.component.TextField" );
640 case API_CONTROL_NUMERIC: return OUString( "com.sun.star.form.component.NumericField" );
641 case API_CONTROL_LISTBOX: return OUString( "com.sun.star.form.component.ListBox" );
642 case API_CONTROL_COMBOBOX: return OUString( "com.sun.star.form.component.ComboBox" );
643 case API_CONTROL_SPINBUTTON: return OUString( "com.sun.star.form.component.SpinButton" );
644 case API_CONTROL_SCROLLBAR: return OUString( "com.sun.star.form.component.ScrollBar" );
645 case API_CONTROL_GROUPBOX: return OUString( "com.sun.star.form.component.GroupBox" );
646 default: OSL_FAIL( "ControlModelBase::getServiceName - no form component service supported" );
648 return OUString();
651 void ControlModelBase::importProperty( sal_Int32 /*nPropId*/, const OUString& /*rValue*/ )
655 void ControlModelBase::importPictureData( sal_Int32 /*nPropId*/, BinaryInputStream& /*rInStrm*/ )
659 void ControlModelBase::convertProperties( PropertyMap& /*rPropMap*/, const ControlConverter& /*rConv*/ ) const
663 void ControlModelBase::convertFromProperties( PropertySet& /*rPropMap*/, const ControlConverter& /*rConv*/ )
667 void ControlModelBase::convertSize( PropertyMap& rPropMap, const ControlConverter& rConv ) const
669 rConv.convertSize( rPropMap, maSize );
672 // ============================================================================
674 ComCtlModelBase::ComCtlModelBase( sal_uInt32 nDataPartId5, sal_uInt32 nDataPartId6,
675 sal_uInt16 nVersion, bool bCommonPart, bool bComplexPart ) :
676 maFontData( "Tahoma", 82500 ),
677 mnFlags( 0 ),
678 mnVersion( nVersion ),
679 mnDataPartId5( nDataPartId5 ),
680 mnDataPartId6( nDataPartId6 ),
681 mbCommonPart( bCommonPart ),
682 mbComplexPart( bComplexPart )
686 bool ComCtlModelBase::importBinaryModel( BinaryInputStream& rInStrm )
688 // read initial size part and header of the control data part
689 if( importSizePart( rInStrm ) && readPartHeader( rInStrm, getDataPartId(), mnVersion ) )
691 // if flags part exists, the first int32 of the data part contains its size
692 sal_uInt32 nCommonPartSize = mbCommonPart ? rInStrm.readuInt32() : 0;
693 // implementations must read the exact amount of data, stream must point to its end afterwards
694 importControlData( rInStrm );
695 // read following parts
696 if( !rInStrm.isEof() &&
697 (!mbCommonPart || importCommonPart( rInStrm, nCommonPartSize )) &&
698 (!mbComplexPart || importComplexPart( rInStrm )) )
700 return !rInStrm.isEof();
703 return false;
706 void ComCtlModelBase::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
708 if( mbCommonPart )
709 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, COMCTL_COMMON_ENABLED ) );
710 ControlModelBase::convertProperties( rPropMap, rConv );
713 void ComCtlModelBase::importCommonExtraData( BinaryInputStream& /*rInStrm*/ )
717 void ComCtlModelBase::importCommonTrailingData( BinaryInputStream& /*rInStrm*/ )
721 sal_uInt32 ComCtlModelBase::getDataPartId() const
723 switch( mnVersion )
725 case COMCTL_VERSION_50: return mnDataPartId5;
726 case COMCTL_VERSION_60: return mnDataPartId6;
728 OSL_FAIL( "ComCtlObjectBase::getDataPartId - unxpected version" );
729 return SAL_MAX_UINT32;
732 bool ComCtlModelBase::readPartHeader( BinaryInputStream& rInStrm, sal_uInt32 nExpPartId, sal_uInt16 nExpMajor, sal_uInt16 nExpMinor )
734 // no idea if all this is correct...
735 sal_uInt32 nPartId;
736 sal_uInt16 nMajor, nMinor;
737 rInStrm >> nPartId >> nMinor >> nMajor;
738 bool bPartId = nPartId == nExpPartId;
739 OSL_ENSURE( bPartId, "ComCtlObjectBase::readPartHeader - unexpected part identifier" );
740 bool bVersion = ((nExpMajor == SAL_MAX_UINT16) || (nExpMajor == nMajor)) && ((nExpMinor == SAL_MAX_UINT16) || (nExpMinor == nMinor));
741 OSL_ENSURE( bVersion, "ComCtlObjectBase::readPartHeader - unexpected part version" );
742 return !rInStrm.isEof() && bPartId && bVersion;
745 bool ComCtlModelBase::importSizePart( BinaryInputStream& rInStrm )
747 if( readPartHeader( rInStrm, COMCTL_ID_SIZE, 0, 8 ) )
749 rInStrm >> maSize.first >> maSize.second;
750 return !rInStrm.isEof();
752 return false;
755 bool ComCtlModelBase::importCommonPart( BinaryInputStream& rInStrm, sal_uInt32 nPartSize )
757 sal_Int64 nEndPos = rInStrm.tell() + nPartSize;
758 if( (nPartSize >= 16) && readPartHeader( rInStrm, COMCTL_ID_COMMONDATA, 5, 0 ) )
760 rInStrm.skip( 4 );
761 rInStrm >> mnFlags;
762 // implementations may read less than the exact amount of data
763 importCommonExtraData( rInStrm );
764 rInStrm.seek( nEndPos );
765 // implementations must read the exact amount of data, stream must point to its end afterwards
766 importCommonTrailingData( rInStrm );
767 return !rInStrm.isEof();
769 return false;
772 bool ComCtlModelBase::importComplexPart( BinaryInputStream& rInStrm )
774 if( readPartHeader( rInStrm, COMCTL_ID_COMPLEXDATA, 5, 1 ) )
776 sal_uInt32 nContFlags;
777 rInStrm >> nContFlags;
778 bool bReadOk =
779 (!getFlag( nContFlags, COMCTL_COMPLEX_FONT ) || OleHelper::importStdFont( maFontData, rInStrm, true )) &&
780 (!getFlag( nContFlags, COMCTL_COMPLEX_MOUSEICON ) || OleHelper::importStdPic( maMouseIcon, rInStrm, true ));
781 return bReadOk && !rInStrm.isEof();
783 return false;
786 // ============================================================================
788 ComCtlScrollBarModel::ComCtlScrollBarModel( sal_uInt16 nVersion ) :
789 ComCtlModelBase( SAL_MAX_UINT32, COMCTL_ID_SCROLLBAR_60, nVersion, true, true ),
790 mnScrollBarFlags( 0x00000011 ),
791 mnLargeChange( 1 ),
792 mnSmallChange( 1 ),
793 mnMin( 0 ),
794 mnMax( 32767 ),
795 mnPosition( 0 )
799 ApiControlType ComCtlScrollBarModel::getControlType() const
801 return API_CONTROL_SCROLLBAR;
804 void ComCtlScrollBarModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
806 rPropMap.setProperty( PROP_Border, API_BORDER_NONE );
807 rConv.convertOrientation( rPropMap, getFlag( mnScrollBarFlags, COMCTL_SCROLLBAR_HOR ) );
808 rConv.convertScrollBar( rPropMap, mnMin, mnMax, mnPosition, mnSmallChange, mnLargeChange, mbAwtModel );
809 ComCtlModelBase::convertProperties( rPropMap, rConv );
812 void ComCtlScrollBarModel::importControlData( BinaryInputStream& rInStrm )
814 rInStrm >> mnScrollBarFlags >> mnLargeChange >> mnSmallChange >> mnMin >> mnMax >> mnPosition;
817 // ============================================================================
819 ComCtlProgressBarModel::ComCtlProgressBarModel( sal_uInt16 nVersion ) :
820 ComCtlModelBase( COMCTL_ID_PROGRESSBAR_50, COMCTL_ID_PROGRESSBAR_60, nVersion, true, true ),
821 mfMin( 0.0 ),
822 mfMax( 100.0 ),
823 mnVertical( 0 ),
824 mnSmooth( 0 )
828 ApiControlType ComCtlProgressBarModel::getControlType() const
830 return API_CONTROL_PROGRESSBAR;
833 void ComCtlProgressBarModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
835 sal_uInt16 nBorder = getFlag( mnFlags, COMCTL_COMMON_3DBORDER ) ? API_BORDER_SUNKEN :
836 (getFlag( mnFlags, COMCTL_COMMON_FLATBORDER ) ? API_BORDER_FLAT : API_BORDER_NONE);
837 rPropMap.setProperty( PROP_Border, nBorder );
838 rPropMap.setProperty( PROP_ProgressValueMin, getLimitedValue< sal_Int32, double >( ::std::min( mfMin, mfMax ), 0.0, SAL_MAX_INT32 ) );
839 rPropMap.setProperty( PROP_ProgressValueMax, getLimitedValue< sal_Int32, double >( ::std::max( mfMin, mfMax ), 0.0, SAL_MAX_INT32 ) );
840 // ComCtl model does not provide current value?
841 ComCtlModelBase::convertProperties( rPropMap, rConv );
844 void ComCtlProgressBarModel::importControlData( BinaryInputStream& rInStrm )
846 rInStrm >> mfMin >> mfMax;
847 if( mnVersion == COMCTL_VERSION_60 )
848 rInStrm >> mnVertical >> mnSmooth;
851 // ============================================================================
853 AxControlModelBase::AxControlModelBase()
857 void AxControlModelBase::importProperty( sal_Int32 nPropId, const OUString& rValue )
859 switch( nPropId )
861 // size of the control shape: format is "width;height"
862 case XML_Size:
864 sal_Int32 nSepPos = rValue.indexOf( ';' );
865 OSL_ENSURE( nSepPos >= 0, "AxControlModelBase::importProperty - missing separator in 'Size' property" );
866 if( nSepPos >= 0 )
868 maSize.first = rValue.copy( 0, nSepPos ).toInt32();
869 maSize.second = rValue.copy( nSepPos + 1 ).toInt32();
872 break;
876 // ============================================================================
878 AxFontDataModel::AxFontDataModel( bool bSupportsAlign ) :
879 mbSupportsAlign( bSupportsAlign )
883 void AxFontDataModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
885 switch( nPropId )
887 case XML_FontName: maFontData.maFontName = rValue; break;
888 case XML_FontEffects: maFontData.mnFontEffects = AttributeConversion::decodeUnsigned( rValue ); break;
889 case XML_FontHeight: maFontData.mnFontHeight = AttributeConversion::decodeInteger( rValue ); break;
890 case XML_FontCharSet: maFontData.mnFontCharSet = AttributeConversion::decodeInteger( rValue ); break;
891 case XML_ParagraphAlign: maFontData.mnHorAlign = AttributeConversion::decodeInteger( rValue ); break;
892 default: AxControlModelBase::importProperty( nPropId, rValue );
896 bool AxFontDataModel::importBinaryModel( BinaryInputStream& rInStrm )
898 return maFontData.importBinaryModel( rInStrm );
901 void AxFontDataModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
903 maFontData.exportBinaryModel( rOutStrm );
905 void AxFontDataModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
907 // font name
908 if( !maFontData.maFontName.isEmpty() )
909 rPropMap.setProperty( PROP_FontName, maFontData.maFontName );
911 // font effects
912 rPropMap.setProperty( PROP_FontWeight, getFlagValue( maFontData.mnFontEffects, AX_FONTDATA_BOLD, awt::FontWeight::BOLD, awt::FontWeight::NORMAL ) );
913 rPropMap.setProperty( PROP_FontSlant, getFlagValue< sal_Int16 >( maFontData.mnFontEffects, AX_FONTDATA_ITALIC, FontSlant_ITALIC, FontSlant_NONE ) );
914 rPropMap.setProperty( PROP_FontUnderline, getFlagValue( maFontData.mnFontEffects, AX_FONTDATA_UNDERLINE, maFontData.mbDblUnderline ? awt::FontUnderline::DOUBLE : awt::FontUnderline::SINGLE, awt::FontUnderline::NONE ) );
915 rPropMap.setProperty( PROP_FontStrikeout, getFlagValue( maFontData.mnFontEffects, AX_FONTDATA_STRIKEOUT, awt::FontStrikeout::SINGLE, awt::FontStrikeout::NONE ) );
916 rPropMap.setProperty( PROP_FontHeight, maFontData.getHeightPoints() );
918 // font character set
919 rtl_TextEncoding eFontEnc = RTL_TEXTENCODING_DONTKNOW;
920 if( (0 <= maFontData.mnFontCharSet) && (maFontData.mnFontCharSet <= SAL_MAX_UINT8) )
921 eFontEnc = rtl_getTextEncodingFromWindowsCharset( static_cast< sal_uInt8 >( maFontData.mnFontCharSet ) );
922 if( eFontEnc != RTL_TEXTENCODING_DONTKNOW )
923 rPropMap.setProperty( PROP_FontCharset, static_cast< sal_Int16 >( eFontEnc ) );
925 // text alignment
926 if( mbSupportsAlign )
928 sal_Int32 nAlign = awt::TextAlign::LEFT;
929 switch( maFontData.mnHorAlign )
931 case AX_FONTDATA_LEFT: nAlign = awt::TextAlign::LEFT; break;
932 case AX_FONTDATA_RIGHT: nAlign = awt::TextAlign::RIGHT; break;
933 case AX_FONTDATA_CENTER: nAlign = awt::TextAlign::CENTER; break;
934 default: OSL_FAIL( "AxFontDataModel::convertProperties - unknown text alignment" );
936 // form controls expect short value
937 rPropMap.setProperty( PROP_Align, static_cast< sal_Int16 >( nAlign ) );
940 // process base class properties
941 AxControlModelBase::convertProperties( rPropMap, rConv );
944 void AxFontDataModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& /*rConv */)
946 rPropSet.getProperty( maFontData.maFontName, PROP_FontName );
947 float fontWeight = (float)0;
948 if ( rPropSet.getProperty(fontWeight, PROP_FontWeight ) )
949 setFlag( maFontData.mnFontEffects, AX_FONTDATA_BOLD, ( fontWeight == awt::FontWeight::BOLD ) );
950 sal_Int16 nSlant = FontSlant_NONE;
951 if ( rPropSet.getProperty( nSlant, PROP_FontSlant ) )
952 setFlag( maFontData.mnFontEffects, AX_FONTDATA_ITALIC, ( nSlant == FontSlant_ITALIC ) );
954 sal_Int16 nUnderLine = awt::FontUnderline::NONE;
955 if ( rPropSet.getProperty( nUnderLine, PROP_FontUnderline ) )
956 setFlag( maFontData.mnFontEffects, AX_FONTDATA_UNDERLINE, nUnderLine != awt::FontUnderline::NONE );
957 sal_Int16 nStrikeout = awt::FontStrikeout::NONE ;
958 if ( rPropSet.getProperty( nStrikeout, PROP_FontStrikeout ) )
959 setFlag( maFontData.mnFontEffects, AX_FONTDATA_STRIKEOUT, nStrikeout != awt::FontStrikeout::NONE );
961 float fontHeight = 0.0;
962 if ( rPropSet.getProperty( fontHeight, PROP_FontHeight ) )
963 maFontData.setHeightPoints( static_cast< sal_Int16 >( fontHeight ) );
965 // TODO - handle textencoding
966 sal_Int16 nAlign = 0;
967 if ( rPropSet.getProperty( nAlign, PROP_Align ) )
969 switch ( nAlign )
971 case awt::TextAlign::LEFT: maFontData.mnHorAlign = AX_FONTDATA_LEFT; break;
972 case awt::TextAlign::RIGHT: maFontData.mnHorAlign = AX_FONTDATA_RIGHT; break;
973 case awt::TextAlign::CENTER: maFontData.mnHorAlign = AX_FONTDATA_CENTER; break;
974 default: OSL_FAIL( "AxFontDataModel::convertFromProperties - unknown text alignment" );
979 // ============================================================================
981 AxCommandButtonModel::AxCommandButtonModel() :
982 mnTextColor( AX_SYSCOLOR_BUTTONTEXT ),
983 mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
984 mnFlags( AX_CMDBUTTON_DEFFLAGS ),
985 mnPicturePos( AX_PICPOS_ABOVECENTER ),
986 mnVerticalAlign( XML_Center ),
987 mbFocusOnClick( true )
991 void AxCommandButtonModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
993 switch( nPropId )
995 case XML_Caption: maCaption = rValue; break;
996 case XML_ForeColor: mnTextColor = AttributeConversion::decodeUnsigned( rValue ); break;
997 case XML_BackColor: mnBackColor = AttributeConversion::decodeUnsigned( rValue ); break;
998 case XML_VariousPropertyBits: mnFlags = AttributeConversion::decodeUnsigned( rValue ); break;
999 case XML_PicturePosition: mnPicturePos = AttributeConversion::decodeUnsigned( rValue ); break;
1000 case XML_TakeFocusOnClick: mbFocusOnClick = AttributeConversion::decodeInteger( rValue ) != 0; break;
1001 default: AxFontDataModel::importProperty( nPropId, rValue );
1005 void AxCommandButtonModel::importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm )
1007 switch( nPropId )
1009 case XML_Picture: OleHelper::importStdPic( maPictureData, rInStrm, true ); break;
1010 default: AxFontDataModel::importPictureData( nPropId, rInStrm );
1014 bool AxCommandButtonModel::importBinaryModel( BinaryInputStream& rInStrm )
1016 AxBinaryPropertyReader aReader( rInStrm );
1017 aReader.readIntProperty< sal_uInt32 >( mnTextColor );
1018 aReader.readIntProperty< sal_uInt32 >( mnBackColor );
1019 aReader.readIntProperty< sal_uInt32 >( mnFlags );
1020 aReader.readStringProperty( maCaption );
1021 aReader.readIntProperty< sal_uInt32 >( mnPicturePos );
1022 aReader.readPairProperty( maSize );
1023 aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
1024 aReader.readPictureProperty( maPictureData );
1025 aReader.skipIntProperty< sal_uInt16 >(); // accelerator
1026 aReader.readBoolProperty( mbFocusOnClick, true ); // binary flag means "do not take focus"
1027 aReader.skipPictureProperty(); // mouse icon
1028 return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm );
1032 void AxCommandButtonModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
1034 AxBinaryPropertyWriter aWriter( rOutStrm );
1035 aWriter.writeIntProperty< sal_uInt32 >( mnTextColor );
1036 aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
1037 aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
1038 aWriter.writeStringProperty( maCaption );
1039 aWriter.skipProperty(); // pict pos
1040 aWriter.writePairProperty( maSize );
1041 aWriter.skipProperty(); // mouse pointer
1042 aWriter.skipProperty(); // picture data
1043 aWriter.skipProperty(); // accelerator
1044 aWriter.writeBoolProperty( mbFocusOnClick ); // binary flag means "do not take focus"
1045 aWriter.skipProperty(); // mouse icon
1046 aWriter.finalizeExport();
1047 AxFontDataModel::exportBinaryModel( rOutStrm );
1050 void AxCommandButtonModel::exportCompObj( BinaryOutputStream& rOutStream )
1052 // should be able to replace this hardcoded foo with
1053 // proper export info from MS-OLEDS spec.
1054 static sal_uInt8 const aCompObj[] = {
1055 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1056 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x32, 0x05, 0xD7,
1057 0x69, 0xCE, 0xCD, 0x11, 0xA7, 0x77, 0x00, 0xDD,
1058 0x01, 0x14, 0x3C, 0x57, 0x22, 0x00, 0x00, 0x00,
1059 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1060 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6d, 0x73, 0x20,
1061 0x32, 0x2e, 0x30, 0x20, 0x43, 0x6F, 0x6D, 0x6D,
1062 0x61, 0x6E, 0x64, 0x42, 0x75, 0x74, 0x74, 0x6F,
1063 0x6E, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
1064 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
1065 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x16, 0x00,
1066 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
1067 0x43, 0x6F, 0x6D, 0x6D, 0x61, 0x6E, 0x64, 0x42,
1068 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00,
1069 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
1070 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1072 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1075 ApiControlType AxCommandButtonModel::getControlType() const
1077 return API_CONTROL_BUTTON;
1080 void AxCommandButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1082 rPropMap.setProperty( PROP_Label, maCaption );
1083 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
1084 rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
1085 rPropMap.setProperty( PROP_FocusOnClick, mbFocusOnClick );
1086 rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor );
1087 rConv.convertVerticalAlign( rPropMap, mnVerticalAlign );
1088 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED );
1089 rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos );
1090 AxFontDataModel::convertProperties( rPropMap, rConv );
1093 void AxCommandButtonModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1095 rPropSet.getProperty( maCaption, PROP_Label );
1096 bool bRes = false;
1097 if ( rPropSet.getProperty( bRes, PROP_Enabled ) )
1098 setFlag( mnFlags, AX_FLAGS_ENABLED, bRes );
1099 if ( rPropSet.getProperty( bRes, PROP_MultiLine ) )
1100 setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
1101 rPropSet.getProperty( mbFocusOnClick, PROP_FocusOnClick );
1103 rConv.convertToMSColor( rPropSet, PROP_TextColor, mnTextColor );
1104 rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1106 AxFontDataModel::convertFromProperties( rPropSet, rConv );
1108 // ============================================================================
1110 AxLabelModel::AxLabelModel() :
1111 mnTextColor( AX_SYSCOLOR_BUTTONTEXT ),
1112 mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
1113 mnFlags( AX_LABEL_DEFFLAGS ),
1114 mnBorderColor( AX_SYSCOLOR_WINDOWFRAME ),
1115 mnBorderStyle( AX_BORDERSTYLE_NONE ),
1116 mnSpecialEffect( AX_SPECIALEFFECT_FLAT ),
1117 mnVerticalAlign( XML_Top )
1121 void AxLabelModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
1123 switch( nPropId )
1125 case XML_Caption: maCaption = rValue; break;
1126 case XML_ForeColor: mnTextColor = AttributeConversion::decodeUnsigned( rValue ); break;
1127 case XML_BackColor: mnBackColor = AttributeConversion::decodeUnsigned( rValue ); break;
1128 case XML_VariousPropertyBits: mnFlags = AttributeConversion::decodeUnsigned( rValue ); break;
1129 case XML_BorderColor: mnBorderColor = AttributeConversion::decodeUnsigned( rValue ); break;
1130 case XML_BorderStyle: mnBorderStyle = AttributeConversion::decodeInteger( rValue ); break;
1131 case XML_SpecialEffect: mnSpecialEffect = AttributeConversion::decodeInteger( rValue ); break;
1132 default: AxFontDataModel::importProperty( nPropId, rValue );
1136 bool AxLabelModel::importBinaryModel( BinaryInputStream& rInStrm )
1138 AxBinaryPropertyReader aReader( rInStrm );
1139 aReader.readIntProperty< sal_uInt32 >( mnTextColor );
1140 aReader.readIntProperty< sal_uInt32 >( mnBackColor );
1141 aReader.readIntProperty< sal_uInt32 >( mnFlags );
1142 aReader.readStringProperty( maCaption );
1143 aReader.skipIntProperty< sal_uInt32 >(); // picture position
1144 aReader.readPairProperty( maSize );
1145 aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
1146 aReader.readIntProperty< sal_uInt32 >( mnBorderColor );
1147 aReader.readIntProperty< sal_uInt16 >( mnBorderStyle );
1148 aReader.readIntProperty< sal_uInt16 >( mnSpecialEffect );
1149 aReader.skipPictureProperty(); // picture
1150 aReader.skipIntProperty< sal_uInt16 >(); // accelerator
1151 aReader.skipPictureProperty(); // mouse icon
1152 return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm );
1155 void AxLabelModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
1157 AxBinaryPropertyWriter aWriter( rOutStrm );
1158 aWriter.writeIntProperty< sal_uInt32 >( mnTextColor );
1159 aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
1160 aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
1161 aWriter.writeStringProperty( maCaption );
1162 aWriter.skipProperty(); // picture position
1163 aWriter.writePairProperty( maSize );
1164 aWriter.skipProperty(); // mouse pointer
1165 aWriter.writeIntProperty< sal_uInt32 >( mnBorderColor );
1166 aWriter.writeIntProperty< sal_uInt16 >( mnBorderStyle );
1167 aWriter.writeIntProperty< sal_uInt16 >( mnSpecialEffect );
1168 aWriter.skipProperty(); // picture
1169 aWriter.skipProperty(); // accelerator
1170 aWriter.skipProperty(); // mouse icon
1171 aWriter.finalizeExport();
1172 AxFontDataModel::exportBinaryModel( rOutStrm );
1175 void AxLabelModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1177 rPropSet.getProperty( maCaption, PROP_Label );
1178 bool bRes = false;
1179 if ( rPropSet.getProperty( bRes, PROP_Enabled ) )
1180 setFlag( mnFlags, AX_FLAGS_ENABLED, bRes );
1181 if ( rPropSet.getProperty( bRes, PROP_MultiLine ) )
1182 setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
1184 rConv.convertToMSColor( rPropSet, PROP_TextColor, mnTextColor );
1185 // VerticleAlign doesn't seem to be read from binary
1187 // not sure about background color, how do we decide when to set
1188 // AX_FLAGS_OPAQUE ?
1189 rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1190 rConv.convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1192 AxFontDataModel::convertFromProperties( rPropSet, rConv );
1195 void AxLabelModel::exportCompObj( BinaryOutputStream& rOutStream )
1197 // should be able to replace this hardcoded foo with
1198 // proper export info from MS-OLEDS spec.
1199 static sal_uInt8 const aCompObj[] = {
1200 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1201 0xFF, 0xFF, 0xFF, 0xFF, 0x23, 0x9E, 0x8C, 0x97,
1202 0xB0, 0xD4, 0xCE, 0x11, 0xBF, 0x2D, 0x00, 0xAA,
1203 0x00, 0x3F, 0x40, 0xD0, 0x1A, 0x00, 0x00, 0x00,
1204 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1205 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1206 0x32, 0x2E, 0x30, 0x20, 0x4C, 0x61, 0x62, 0x65,
1207 0x6C, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
1208 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
1209 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x0E, 0x00,
1210 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
1211 0x4C, 0x61, 0x62, 0x65, 0x6C, 0x2E, 0x31, 0x00,
1212 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
1213 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1215 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1218 ApiControlType AxLabelModel::getControlType() const
1220 return API_CONTROL_FIXEDTEXT;
1223 void AxLabelModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1225 rPropMap.setProperty( PROP_Label, maCaption );
1226 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
1227 rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
1228 rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor );
1229 rConv.convertVerticalAlign( rPropMap, mnVerticalAlign );
1230 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID );
1231 rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1232 AxFontDataModel::convertProperties( rPropMap, rConv );
1235 // ============================================================================
1237 AxImageModel::AxImageModel() :
1238 mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
1239 mnFlags( AX_IMAGE_DEFFLAGS ),
1240 mnBorderColor( AX_SYSCOLOR_WINDOWFRAME ),
1241 mnBorderStyle( AX_BORDERSTYLE_SINGLE ),
1242 mnSpecialEffect( AX_SPECIALEFFECT_FLAT ),
1243 mnPicSizeMode( AX_PICSIZE_CLIP ),
1244 mnPicAlign( AX_PICALIGN_CENTER ),
1245 mbPicTiling( false )
1249 void AxImageModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
1251 switch( nPropId )
1253 case XML_BackColor: mnBackColor = AttributeConversion::decodeUnsigned( rValue ); break;
1254 case XML_VariousPropertyBits: mnFlags = AttributeConversion::decodeUnsigned( rValue ); break;
1255 case XML_BorderColor: mnBorderColor = AttributeConversion::decodeUnsigned( rValue ); break;
1256 case XML_BorderStyle: mnBorderStyle = AttributeConversion::decodeInteger( rValue ); break;
1257 case XML_SpecialEffect: mnSpecialEffect = AttributeConversion::decodeInteger( rValue ); break;
1258 case XML_SizeMode: mnPicSizeMode = AttributeConversion::decodeInteger( rValue ); break;
1259 case XML_PictureAlignment: mnPicAlign = AttributeConversion::decodeInteger( rValue ); break;
1260 case XML_PictureTiling: mbPicTiling = AttributeConversion::decodeInteger( rValue ) != 0; break;
1261 default: AxControlModelBase::importProperty( nPropId, rValue );
1265 void AxImageModel::importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm )
1267 switch( nPropId )
1269 case XML_Picture: OleHelper::importStdPic( maPictureData, rInStrm, true ); break;
1270 default: AxControlModelBase::importPictureData( nPropId, rInStrm );
1274 bool AxImageModel::importBinaryModel( BinaryInputStream& rInStrm )
1276 AxBinaryPropertyReader aReader( rInStrm );
1277 aReader.skipUndefinedProperty();
1278 aReader.skipUndefinedProperty();
1279 aReader.skipBoolProperty(); // auto-size
1280 aReader.readIntProperty< sal_uInt32 >( mnBorderColor );
1281 aReader.readIntProperty< sal_uInt32 >( mnBackColor );
1282 aReader.readIntProperty< sal_uInt8 >( mnBorderStyle );
1283 aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
1284 aReader.readIntProperty< sal_uInt8 >( mnPicSizeMode );
1285 aReader.readIntProperty< sal_uInt8 >( mnSpecialEffect );
1286 aReader.readPairProperty( maSize );
1287 aReader.readPictureProperty( maPictureData );
1288 aReader.readIntProperty< sal_uInt8 >( mnPicAlign );
1289 aReader.readBoolProperty( mbPicTiling );
1290 aReader.readIntProperty< sal_uInt32 >( mnFlags );
1291 aReader.skipPictureProperty(); // mouse icon
1292 return aReader.finalizeImport();
1295 void AxImageModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
1297 AxBinaryPropertyWriter aWriter( rOutStrm );
1298 aWriter.skipProperty(); //undefined
1299 aWriter.skipProperty(); //undefined
1300 aWriter.skipProperty(); //auto-size
1301 aWriter.writeIntProperty< sal_uInt32 >( mnBorderColor );
1302 aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
1303 aWriter.writeIntProperty< sal_uInt8 >( mnBorderStyle );
1304 aWriter.skipProperty(); // mouse pointer
1305 aWriter.writeIntProperty< sal_uInt8 >( mnPicSizeMode );
1306 aWriter.writeIntProperty< sal_uInt8 >( mnSpecialEffect );
1307 aWriter.writePairProperty( maSize );
1308 aWriter.skipProperty(); //maPictureData );
1309 aWriter.writeIntProperty< sal_uInt8 >( mnPicAlign );
1310 aWriter.writeBoolProperty( mbPicTiling );
1311 aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
1312 aWriter.skipProperty(); // mouse icon
1313 aWriter.finalizeExport();
1316 void AxImageModel::exportCompObj( BinaryOutputStream& rOutStream )
1318 // should be able to replace this hardcoded foo with
1319 // proper export info from MS-OLEDS spec.
1320 static sal_uInt8 const aCompObj[] = {
1321 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1322 0xFF, 0xFF, 0xFF, 0xFF, 0x41, 0x92, 0x59, 0x4C,
1323 0x26, 0x69, 0x1B, 0x10, 0x99, 0x92, 0x00, 0x00,
1324 0x0B, 0x65, 0xC6, 0xF9, 0x1A, 0x00, 0x00, 0x00,
1325 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1326 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1327 0x32, 0x2E, 0x30, 0x20, 0x49, 0x6D, 0x61, 0x67,
1328 0x65, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
1329 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
1330 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x0E, 0x00,
1331 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
1332 0x49, 0x6D, 0x61, 0x67, 0x65, 0x2E, 0x31, 0x00,
1333 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
1334 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1336 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1339 ApiControlType AxImageModel::getControlType() const
1341 return API_CONTROL_IMAGE;
1344 void AxImageModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1346 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
1347 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID );
1348 rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1349 rConv.convertAxPicture( rPropMap, maPictureData, mnPicSizeMode, mnPicAlign, mbPicTiling );
1350 AxControlModelBase::convertProperties( rPropMap, rConv );
1353 // ============================================================================
1355 AxTabStripModel::AxTabStripModel() :
1356 mnListIndex( 0 ),
1357 mnTabStyle( 0 ),
1358 mnTabData( 0 ),
1359 mnVariousPropertyBits( 0 )
1363 bool AxTabStripModel::importBinaryModel( BinaryInputStream& rInStrm )
1365 // not worth reading much here, basically we are interested
1366 // in whether we have tabs, the width, the height and the
1367 // captions, everything else we can pretty much discard ( for now )
1368 AxBinaryPropertyReader aReader( rInStrm );
1369 aReader.readIntProperty< sal_uInt32 >( mnListIndex ); // ListIndex
1370 aReader.skipIntProperty< sal_uInt32 >(); // Backcolor
1371 aReader.skipIntProperty< sal_uInt32 >(); // ForeColor
1372 aReader.skipUndefinedProperty();
1373 aReader.readPairProperty( maSize );
1374 aReader.readArrayStringProperty( maItems );
1375 aReader.skipIntProperty< sal_uInt8 >(); // MousePointer
1376 aReader.skipUndefinedProperty();
1377 aReader.skipIntProperty< sal_uInt32 >(); // TabOrientation
1378 aReader.readIntProperty< sal_uInt32 >(mnTabStyle); // TabStyle
1379 aReader.skipBoolProperty(); // MultiRow
1380 aReader.skipIntProperty< sal_uInt32 >(); // TabFixedWidth
1381 aReader.skipIntProperty< sal_uInt32 >(); // TabFixedHeight
1382 aReader.skipBoolProperty(); // ToolTips
1383 aReader.skipUndefinedProperty();
1384 aReader.skipArrayStringProperty(); // ToolTip strings
1385 aReader.skipUndefinedProperty();
1386 aReader.readArrayStringProperty( maTabNames ); // Tab names
1387 aReader.readIntProperty< sal_uInt32 >(mnVariousPropertyBits); // VariousPropertyBits
1388 aReader.skipBoolProperty();// NewVersion
1389 aReader.skipIntProperty< sal_uInt32 >(); // TabsAllocated
1390 aReader.skipArrayStringProperty(); // Tags
1391 aReader.readIntProperty<sal_uInt32 >(mnTabData); // TabData
1392 aReader.skipArrayStringProperty(); // Accelerators
1393 aReader.skipPictureProperty(); // Mouse Icon
1394 return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm );
1397 ApiControlType AxTabStripModel::getControlType() const
1399 return API_CONTROL_TABSTRIP;
1402 AxMorphDataModelBase::AxMorphDataModelBase() :
1403 mnTextColor( AX_SYSCOLOR_WINDOWTEXT ),
1404 mnBackColor( AX_SYSCOLOR_WINDOWBACK ),
1405 mnFlags( AX_MORPHDATA_DEFFLAGS ),
1406 mnPicturePos( AX_PICPOS_ABOVECENTER ),
1407 mnBorderColor( AX_SYSCOLOR_WINDOWFRAME ),
1408 mnBorderStyle( AX_BORDERSTYLE_NONE ),
1409 mnSpecialEffect( AX_SPECIALEFFECT_SUNKEN ),
1410 mnDisplayStyle( AX_DISPLAYSTYLE_TEXT ),
1411 mnMultiSelect( AX_SELCTION_SINGLE ),
1412 mnScrollBars( AX_SCROLLBAR_NONE ),
1413 mnMatchEntry( AX_MATCHENTRY_NONE ),
1414 mnShowDropButton( AX_SHOWDROPBUTTON_NEVER ),
1415 mnMaxLength( 0 ),
1416 mnPasswordChar( 0 ),
1417 mnListRows( 8 ),
1418 mnVerticalAlign( XML_Center )
1422 void AxMorphDataModelBase::importProperty( sal_Int32 nPropId, const OUString& rValue )
1424 switch( nPropId )
1426 case XML_Caption: maCaption = rValue; break;
1427 case XML_Value: maValue = rValue; break;
1428 case XML_GroupName: maGroupName = rValue; break;
1429 case XML_ForeColor: mnTextColor = AttributeConversion::decodeUnsigned( rValue ); break;
1430 case XML_BackColor: mnBackColor = AttributeConversion::decodeUnsigned( rValue ); break;
1431 case XML_VariousPropertyBits: mnFlags = AttributeConversion::decodeUnsigned( rValue ); break;
1432 case XML_PicturePosition: mnPicturePos = AttributeConversion::decodeUnsigned( rValue ); break;
1433 case XML_BorderColor: mnBorderColor = AttributeConversion::decodeUnsigned( rValue ); break;
1434 case XML_BorderStyle: mnBorderStyle = AttributeConversion::decodeInteger( rValue ); break;
1435 case XML_SpecialEffect: mnSpecialEffect = AttributeConversion::decodeInteger( rValue ); break;
1436 case XML_DisplayStyle: mnDisplayStyle = AttributeConversion::decodeInteger( rValue ); break;
1437 case XML_MultiSelect: mnMultiSelect = AttributeConversion::decodeInteger( rValue ); break;
1438 case XML_ScrollBars: mnScrollBars = AttributeConversion::decodeInteger( rValue ); break;
1439 case XML_MatchEntry: mnMatchEntry = AttributeConversion::decodeInteger( rValue ); break;
1440 case XML_ShowDropButtonWhen: mnShowDropButton = AttributeConversion::decodeInteger( rValue );break;
1441 case XML_MaxLength: mnMaxLength = AttributeConversion::decodeInteger( rValue ); break;
1442 case XML_PasswordChar: mnPasswordChar = AttributeConversion::decodeInteger( rValue ); break;
1443 case XML_ListRows: mnListRows = AttributeConversion::decodeInteger( rValue ); break;
1444 default: AxFontDataModel::importProperty( nPropId, rValue );
1448 void AxMorphDataModelBase::importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm )
1450 switch( nPropId )
1452 case XML_Picture: OleHelper::importStdPic( maPictureData, rInStrm, true ); break;
1453 default: AxFontDataModel::importPictureData( nPropId, rInStrm );
1457 bool AxMorphDataModelBase::importBinaryModel( BinaryInputStream& rInStrm )
1459 AxBinaryPropertyReader aReader( rInStrm, true );
1460 aReader.readIntProperty< sal_uInt32 >( mnFlags );
1461 aReader.readIntProperty< sal_uInt32 >( mnBackColor );
1462 aReader.readIntProperty< sal_uInt32 >( mnTextColor );
1463 aReader.readIntProperty< sal_Int32 >( mnMaxLength );
1464 aReader.readIntProperty< sal_uInt8 >( mnBorderStyle );
1465 aReader.readIntProperty< sal_uInt8 >( mnScrollBars );
1466 aReader.readIntProperty< sal_uInt8 >( mnDisplayStyle );
1467 aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
1468 aReader.readPairProperty( maSize );
1469 aReader.readIntProperty< sal_uInt16 >( mnPasswordChar );
1470 aReader.skipIntProperty< sal_uInt32 >(); // list width
1471 aReader.skipIntProperty< sal_uInt16 >(); // bound column
1472 aReader.skipIntProperty< sal_Int16 >(); // text column
1473 aReader.skipIntProperty< sal_Int16 >(); // column count
1474 aReader.readIntProperty< sal_uInt16 >( mnListRows );
1475 aReader.skipIntProperty< sal_uInt16 >(); // column info count
1476 aReader.readIntProperty< sal_uInt8 >( mnMatchEntry );
1477 aReader.skipIntProperty< sal_uInt8 >(); // list style
1478 aReader.readIntProperty< sal_uInt8 >( mnShowDropButton );
1479 aReader.skipUndefinedProperty();
1480 aReader.skipIntProperty< sal_uInt8 >(); // drop down style
1481 aReader.readIntProperty< sal_uInt8 >( mnMultiSelect );
1482 aReader.readStringProperty( maValue );
1483 aReader.readStringProperty( maCaption );
1484 aReader.readIntProperty< sal_uInt32 >( mnPicturePos );
1485 aReader.readIntProperty< sal_uInt32 >( mnBorderColor );
1486 aReader.readIntProperty< sal_uInt32 >( mnSpecialEffect );
1487 aReader.skipPictureProperty(); // mouse icon
1488 aReader.readPictureProperty( maPictureData );
1489 aReader.skipIntProperty< sal_uInt16 >(); // accelerator
1490 aReader.skipUndefinedProperty();
1491 aReader.skipBoolProperty();
1492 aReader.readStringProperty( maGroupName );
1493 return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm );
1496 void AxMorphDataModelBase::exportBinaryModel( BinaryOutputStream& rOutStrm )
1498 AxBinaryPropertyWriter aWriter( rOutStrm, true );
1499 aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
1500 aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
1501 aWriter.writeIntProperty< sal_uInt32 >( mnTextColor );
1502 aWriter.writeIntProperty< sal_Int32 >( mnMaxLength );
1503 aWriter.writeIntProperty< sal_uInt8 >( mnBorderStyle );
1504 aWriter.writeIntProperty< sal_uInt8 >( mnScrollBars );
1505 aWriter.writeIntProperty< sal_uInt8 >( mnDisplayStyle );
1506 aWriter.skipProperty(); // mouse pointer
1507 aWriter.writePairProperty( maSize );
1508 aWriter.writeIntProperty< sal_uInt16 >( mnPasswordChar );
1509 aWriter.skipProperty(); // list width
1510 aWriter.skipProperty(); // bound column
1511 aWriter.skipProperty(); // text column
1512 aWriter.skipProperty(); // column count
1513 aWriter.skipProperty(); // mnListRows
1514 aWriter.skipProperty(); // column info count
1515 aWriter.skipProperty(); // mnMatchEntry
1516 aWriter.skipProperty(); // list style
1517 aWriter.skipProperty(); // mnShowDropButton );
1518 aWriter.skipProperty();
1519 aWriter.skipProperty(); // drop down style
1520 aWriter.writeIntProperty< sal_uInt8 >( mnMultiSelect );
1521 aWriter.writeStringProperty( maValue );
1522 aWriter.writeStringProperty( maCaption );
1523 aWriter.skipProperty(); // mnPicturePos );
1524 aWriter.writeIntProperty< sal_uInt32 >( mnBorderColor );
1525 aWriter.writeIntProperty< sal_uInt32 >( mnSpecialEffect );
1526 aWriter.skipProperty(); // mouse icon
1527 aWriter.skipProperty(); // maPictureData
1528 aWriter.skipProperty(); // accelerator
1529 aWriter.skipProperty(); // undefined
1530 aWriter.writeBoolProperty(true); // must be 1 for morph
1531 aWriter.writeStringProperty( maGroupName );
1532 aWriter.finalizeExport();
1533 AxFontDataModel::exportBinaryModel( rOutStrm );
1536 void AxMorphDataModelBase::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1538 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
1539 rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor );
1540 AxFontDataModel::convertProperties( rPropMap, rConv );
1543 // ============================================================================
1545 AxToggleButtonModel::AxToggleButtonModel()
1547 mnDisplayStyle = AX_DISPLAYSTYLE_TOGGLE;
1550 ApiControlType AxToggleButtonModel::getControlType() const
1552 OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_TOGGLE, "AxToggleButtonModel::getControlType - invalid control type" );
1553 return API_CONTROL_BUTTON;
1556 void AxToggleButtonModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1558 rPropSet.getProperty( maCaption, PROP_Label );
1560 bool bRes = false;
1561 if ( rPropSet.getProperty( bRes, PROP_MultiLine ) )
1562 setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
1564 rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1565 // need to process the image if one exists
1566 rConv.convertToAxState( rPropSet, maValue, mnMultiSelect, API_DEFAULTSTATE_BOOLEAN, mbAwtModel );
1567 AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
1570 void AxToggleButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1572 rPropMap.setProperty( PROP_Label, maCaption );
1573 rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
1574 rPropMap.setProperty( PROP_Toggle, true );
1575 rConv.convertVerticalAlign( rPropMap, mnVerticalAlign );
1576 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED );
1577 rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos );
1578 rConv.convertAxState( rPropMap, maValue, mnMultiSelect, API_DEFAULTSTATE_BOOLEAN, mbAwtModel );
1579 AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1582 void AxToggleButtonModel::exportCompObj( BinaryOutputStream& rOutStream )
1584 // should be able to replace this hardcoded foo with
1585 // proper export info from MS-OLEDS spec.
1586 static sal_uInt8 const aCompObj[] = {
1587 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1588 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0x1D, 0xD2, 0x8B,
1589 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1590 0x00, 0x60, 0x02, 0xF3, 0x21, 0x00, 0x00, 0x00,
1591 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1592 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1593 0x32, 0x2E, 0x30, 0x20, 0x54, 0x6F, 0x67, 0x67,
1594 0x6C, 0x65, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E,
1595 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62,
1596 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62,
1597 0x6A, 0x65, 0x63, 0x74, 0x00, 0x15, 0x00, 0x00,
1598 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x54,
1599 0x6F, 0x67, 0x67, 0x6C, 0x65, 0x42, 0x75, 0x74,
1600 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00, 0xF4, 0x39,
1601 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1602 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1604 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1607 // ============================================================================
1609 AxCheckBoxModel::AxCheckBoxModel()
1611 mnDisplayStyle = AX_DISPLAYSTYLE_CHECKBOX;
1614 ApiControlType AxCheckBoxModel::getControlType() const
1616 OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_CHECKBOX, "AxCheckBoxModel::getControlType - invalid control type" );
1617 return API_CONTROL_CHECKBOX;
1620 void AxCheckBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1622 rPropMap.setProperty( PROP_Label, maCaption );
1623 rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
1624 rConv.convertVerticalAlign( rPropMap, mnVerticalAlign );
1625 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID );
1626 rConv.convertAxVisualEffect( rPropMap, mnSpecialEffect );
1627 rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos );
1628 rConv.convertAxState( rPropMap, maValue, mnMultiSelect, API_DEFAULTSTATE_TRISTATE, mbAwtModel );
1629 AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1632 void AxCheckBoxModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1634 rPropSet.getProperty( maCaption, PROP_Label );
1636 bool bRes = false;
1637 if ( rPropSet.getProperty( bRes, PROP_MultiLine ) )
1638 setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
1640 rConv.convertToAxVisualEffect( rPropSet, mnSpecialEffect );
1641 rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1642 // need to process the image if one exists
1643 rConv.convertToAxState( rPropSet, maValue, mnMultiSelect, API_DEFAULTSTATE_BOOLEAN, mbAwtModel );
1644 AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
1647 void AxCheckBoxModel::exportCompObj( BinaryOutputStream& rOutStream )
1649 // should be able to replace this hardcoded foo with
1650 // proper export info from MS-OLEDS spec.
1651 static sal_uInt8 const aCompObj[] = {
1652 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1653 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x1D, 0xD2, 0x8B,
1654 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1655 0x00, 0x60, 0x02, 0xF3, 0x1D, 0x00, 0x00, 0x00,
1656 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1657 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1658 0x32, 0x2E, 0x30, 0x20, 0x43, 0x68, 0x65, 0x63,
1659 0x6B, 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00,
1660 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65,
1661 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74,
1662 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72,
1663 0x6D, 0x73, 0x2E, 0x43, 0x68, 0x65, 0x63, 0x6B,
1664 0x42, 0x6F, 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39,
1665 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1666 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1668 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1670 // ============================================================================
1672 AxOptionButtonModel::AxOptionButtonModel()
1674 mnDisplayStyle = AX_DISPLAYSTYLE_OPTBUTTON;
1677 ApiControlType AxOptionButtonModel::getControlType() const
1679 OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_OPTBUTTON, "AxOptionButtonModel::getControlType - invalid control type" );
1680 return API_CONTROL_RADIOBUTTON;
1683 void AxOptionButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1685 rPropMap.setProperty( PROP_Label, maCaption );
1686 rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
1687 rConv.convertVerticalAlign( rPropMap, mnVerticalAlign );
1688 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID );
1689 rConv.convertAxVisualEffect( rPropMap, mnSpecialEffect );
1690 rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos );
1691 rConv.convertAxState( rPropMap, maValue, mnMultiSelect, API_DEFAULTSTATE_SHORT, mbAwtModel );
1692 AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1695 void AxOptionButtonModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1697 rPropSet.getProperty( maCaption, PROP_Label );
1699 bool bRes = false;
1700 if ( rPropSet.getProperty( bRes, PROP_MultiLine ) )
1701 setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
1703 rConv.convertToAxVisualEffect( rPropSet, mnSpecialEffect );
1704 rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1705 // need to process the image if one exists
1706 rConv.convertToAxState( rPropSet, maValue, mnMultiSelect, API_DEFAULTSTATE_BOOLEAN, mbAwtModel );
1707 AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
1710 void AxOptionButtonModel::exportCompObj( BinaryOutputStream& rOutStream )
1712 // should be able to replace this hardcoded foo with
1713 // proper export info from MS-OLEDS spec.
1714 static sal_uInt8 const aCompObj[] = {
1715 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1716 0xFF, 0xFF, 0xFF, 0xFF, 0x50, 0x1D, 0xD2, 0x8B,
1717 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1718 0x00, 0x60, 0x02, 0xF3, 0x21, 0x00, 0x00, 0x00,
1719 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1720 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1721 0x32, 0x2E, 0x30, 0x20, 0x4F, 0x70, 0x74, 0x69,
1722 0x6F, 0x6E, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E,
1723 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62,
1724 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62,
1725 0x6A, 0x65, 0x63, 0x74, 0x00, 0x15, 0x00, 0x00,
1726 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x4F,
1727 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x42, 0x75, 0x74,
1728 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00, 0xF4, 0x39,
1729 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1730 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1732 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1735 // ============================================================================
1737 AxTextBoxModel::AxTextBoxModel()
1739 mnDisplayStyle = AX_DISPLAYSTYLE_TEXT;
1742 ApiControlType AxTextBoxModel::getControlType() const
1744 OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT, "AxTextBoxModel::getControlType - invalid control type" );
1745 return API_CONTROL_EDIT;
1748 void AxTextBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1750 rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_MULTILINE ) );
1751 rPropMap.setProperty( PROP_HideInactiveSelection, getFlag( mnFlags, AX_FLAGS_HIDESELECTION ) );
1752 rPropMap.setProperty( mbAwtModel ? PROP_Text : PROP_DefaultText, maValue );
1753 rPropMap.setProperty( PROP_MaxTextLen, getLimitedValue< sal_Int16, sal_Int32 >( mnMaxLength, 0, SAL_MAX_INT16 ) );
1754 if( (0 < mnPasswordChar) && (mnPasswordChar <= SAL_MAX_INT16) )
1755 rPropMap.setProperty( PROP_EchoChar, static_cast< sal_Int16 >( mnPasswordChar ) );
1756 rPropMap.setProperty( PROP_HScroll, getFlag( mnScrollBars, AX_SCROLLBAR_HORIZONTAL ) );
1757 rPropMap.setProperty( PROP_VScroll, getFlag( mnScrollBars, AX_SCROLLBAR_VERTICAL ) );
1758 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID );
1759 rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1760 AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1763 void AxTextBoxModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1765 bool bRes = false;
1766 if ( rPropSet.getProperty( bRes, PROP_MultiLine ) )
1767 setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
1768 if ( rPropSet.getProperty( bRes, PROP_HideInactiveSelection ) )
1769 setFlag( mnFlags, AX_FLAGS_HIDESELECTION, bRes );
1770 rPropSet.getProperty( maValue, ( mbAwtModel ? PROP_Text : PROP_DefaultText ) );
1771 if (maValue.isEmpty() && !mbAwtModel)
1772 // No default value? Then try exporting the current one.
1773 rPropSet.getProperty( maValue, PROP_Text);
1774 sal_Int16 nTmp(0);
1775 if ( rPropSet.getProperty( nTmp, PROP_MaxTextLen ) )
1776 mnMaxLength = nTmp;
1777 if ( rPropSet.getProperty( nTmp, PROP_EchoChar ) )
1778 mnPasswordChar = nTmp;
1779 if ( rPropSet.getProperty( bRes, PROP_HScroll ) )
1780 setFlag( mnScrollBars, AX_SCROLLBAR_HORIZONTAL, bRes );
1781 if ( rPropSet.getProperty( bRes, PROP_VScroll ) )
1782 setFlag( mnScrollBars, AX_SCROLLBAR_VERTICAL, bRes );
1784 rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor, 0x80000005L );
1786 rConv.convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1787 AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
1790 void AxTextBoxModel::exportCompObj( BinaryOutputStream& rOutStream )
1792 // should be able to replace this hardcoded foo with
1793 // proper export info from MS-OLEDS spec.
1794 static sal_uInt8 const aCompObj[] = {
1795 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1796 0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x1D, 0xD2, 0x8B,
1797 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1798 0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
1799 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1800 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1801 0x32, 0x2E, 0x30, 0x20, 0x54, 0x65, 0x78, 0x74,
1802 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
1803 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
1804 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
1805 0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
1806 0x73, 0x2E, 0x54, 0x65, 0x78, 0x74, 0x42, 0x6F,
1807 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
1808 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1809 0x00, 0x00, 0x00, 0x00
1811 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1813 // ============================================================================
1815 AxNumericFieldModel::AxNumericFieldModel()
1817 mnDisplayStyle = AX_DISPLAYSTYLE_TEXT;
1820 ApiControlType AxNumericFieldModel::getControlType() const
1822 OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT, "AxNumericFieldModel::getControlType - invalid control type" );
1823 return API_CONTROL_NUMERIC;
1826 void AxNumericFieldModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1828 rPropMap.setProperty( PROP_HideInactiveSelection, getFlag( mnFlags, AX_FLAGS_HIDESELECTION ) );
1829 // TODO: OUString::toDouble() does not handle local decimal separator
1830 rPropMap.setProperty( mbAwtModel ? PROP_Value : PROP_DefaultValue, maValue.toDouble() );
1831 rPropMap.setProperty( PROP_Spin, getFlag( mnScrollBars, AX_SCROLLBAR_VERTICAL ) );
1832 rPropMap.setProperty( PROP_Repeat, true );
1833 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID );
1834 rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1835 AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1838 void AxNumericFieldModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1840 bool bRes = false;
1841 if ( rPropSet.getProperty( bRes, PROP_HideInactiveSelection ) )
1842 setFlag( mnFlags, AX_FLAGS_HIDESELECTION, bRes );
1843 rPropSet.getProperty( maValue, ( mbAwtModel ? PROP_Text : PROP_DefaultText ) );
1844 if ( rPropSet.getProperty( bRes, PROP_Spin ) )
1845 setFlag( mnScrollBars, AX_SCROLLBAR_VERTICAL, bRes );
1847 rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1849 rConv.convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1850 AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
1853 void AxNumericFieldModel::exportCompObj( BinaryOutputStream& rOutStream )
1855 // should be able to replace this hardcoded foo with
1856 // proper export info from MS-OLEDS spec.
1857 static sal_uInt8 const aCompObj[] = {
1858 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1859 0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x1D, 0xD2, 0x8B,
1860 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1861 0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
1862 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1863 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1864 0x32, 0x2E, 0x30, 0x20, 0x54, 0x65, 0x78, 0x74,
1865 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
1866 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
1867 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
1868 0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
1869 0x73, 0x2E, 0x54, 0x65, 0x78, 0x74, 0x42, 0x6F,
1870 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
1871 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1872 0x00, 0x00, 0x00, 0x00
1874 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1876 // ============================================================================
1878 AxListBoxModel::AxListBoxModel()
1880 mnDisplayStyle = AX_DISPLAYSTYLE_LISTBOX;
1883 ApiControlType AxListBoxModel::getControlType() const
1885 OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_LISTBOX, "AxListBoxModel::getControlType - invalid control type" );
1886 return API_CONTROL_LISTBOX;
1889 void AxListBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1891 bool bMultiSelect = (mnMultiSelect == AX_SELCTION_MULTI) || (mnMultiSelect == AX_SELCTION_EXTENDED);
1892 rPropMap.setProperty( PROP_MultiSelection, bMultiSelect );
1893 rPropMap.setProperty( PROP_Dropdown, false );
1894 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID );
1895 rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1896 AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1899 void AxListBoxModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1901 bool bRes = false;
1902 if ( rPropSet.getProperty( bRes, PROP_MultiSelection ) )
1904 rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1906 rConv.convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1907 AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
1910 void AxListBoxModel::exportCompObj( BinaryOutputStream& rOutStream )
1912 // should be able to replace this hardcoded foo with
1913 // proper export info from MS-OLEDS spec.
1914 static sal_uInt8 const aCompObj[] = {
1915 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1916 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0x1D, 0xD2, 0x8B,
1917 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1918 0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
1919 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1920 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1921 0x32, 0x2E, 0x30, 0x20, 0x4C, 0x69, 0x73, 0x74,
1922 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
1923 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
1924 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
1925 0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
1926 0x73, 0x2E, 0x4C, 0x69, 0x73, 0x74, 0x42, 0x6F,
1927 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
1928 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1929 0x00, 0x00, 0x00, 0x00
1931 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
1933 // ============================================================================
1935 AxComboBoxModel::AxComboBoxModel()
1937 mnDisplayStyle = AX_DISPLAYSTYLE_COMBOBOX;
1940 ApiControlType AxComboBoxModel::getControlType() const
1942 OSL_ENSURE( (mnDisplayStyle == AX_DISPLAYSTYLE_COMBOBOX) || (mnDisplayStyle == AX_DISPLAYSTYLE_DROPDOWN), "AxComboBoxModel::getControlType - invalid control type" );
1943 return (mnDisplayStyle == AX_DISPLAYSTYLE_DROPDOWN) ? API_CONTROL_LISTBOX : API_CONTROL_COMBOBOX;
1946 void AxComboBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
1948 if( mnDisplayStyle != AX_DISPLAYSTYLE_DROPDOWN )
1950 rPropMap.setProperty( PROP_HideInactiveSelection, getFlag( mnFlags, AX_FLAGS_HIDESELECTION ) );
1951 rPropMap.setProperty( mbAwtModel ? PROP_Text : PROP_DefaultText, maValue );
1952 rPropMap.setProperty( PROP_MaxTextLen, getLimitedValue< sal_Int16, sal_Int32 >( mnMaxLength, 0, SAL_MAX_INT16 ) );
1953 bool bAutoComplete = (mnMatchEntry == AX_MATCHENTRY_FIRSTLETTER) || (mnMatchEntry == AX_MATCHENTRY_COMPLETE);
1954 rPropMap.setProperty( PROP_Autocomplete, bAutoComplete );
1956 bool bShowDropdown = (mnShowDropButton == AX_SHOWDROPBUTTON_FOCUS) || (mnShowDropButton == AX_SHOWDROPBUTTON_ALWAYS);
1957 rPropMap.setProperty( PROP_Dropdown, bShowDropdown );
1958 rPropMap.setProperty( PROP_LineCount, getLimitedValue< sal_Int16, sal_Int32 >( mnListRows, 1, SAL_MAX_INT16 ) );
1959 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID );
1960 rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1961 AxMorphDataModelBase::convertProperties( rPropMap, rConv );
1964 void AxComboBoxModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
1966 // when would we have mnDisplayStyle = AX_DISPLAYSTYLE_DROPDOWN ?
1967 // #TODO check against msocximex
1968 mnDisplayStyle = AX_DISPLAYSTYLE_COMBOBOX;
1969 bool bRes = false;
1971 if ( rPropSet.getProperty( bRes, PROP_HideInactiveSelection ) )
1972 setFlag( mnFlags, AX_FLAGS_HIDESELECTION, bRes );
1973 rPropSet.getProperty( maValue, ( mbAwtModel ? PROP_Text : PROP_DefaultText ) );
1975 sal_Int16 nTmp(0);
1976 if ( rPropSet.getProperty( nTmp, PROP_MaxTextLen ) )
1977 mnMaxLength = nTmp;
1978 if ( rPropSet.getProperty( bRes, PROP_Autocomplete ) )
1980 // when to choose AX_MATCHENTRY_FIRSTLETTER ?
1981 // #TODO check against msocximex
1982 if ( bRes )
1983 mnMatchEntry = AX_MATCHENTRY_COMPLETE;
1985 if ( rPropSet.getProperty( bRes, PROP_Dropdown ) )
1987 rPropSet.getProperty( mnListRows, PROP_LineCount );
1988 if ( !mnListRows )
1989 mnListRows = 1;
1991 rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
1993 rConv.convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect );
1994 AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
1997 void AxComboBoxModel::exportCompObj( BinaryOutputStream& rOutStream )
1999 // should be able to replace this hardcoded foo with
2000 // proper export info from MS-OLEDS spec.
2001 static sal_uInt8 const aCompObj[] = {
2002 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2003 0xFF, 0xFF, 0xFF, 0xFF, 0x30, 0x1D, 0xD2, 0x8B,
2004 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
2005 0x00, 0x60, 0x02, 0xF3, 0x1D, 0x00, 0x00, 0x00,
2006 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2007 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2008 0x32, 0x2E, 0x30, 0x20, 0x43, 0x6F, 0x6D, 0x62,
2009 0x6F, 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00,
2010 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65,
2011 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74,
2012 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72,
2013 0x6D, 0x73, 0x2E, 0x43, 0x6F, 0x6D, 0x62, 0x6F,
2014 0x42, 0x6F, 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39,
2015 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2016 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2018 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
2020 // ============================================================================
2022 AxSpinButtonModel::AxSpinButtonModel() :
2023 mnArrowColor( AX_SYSCOLOR_BUTTONTEXT ),
2024 mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
2025 mnFlags( AX_SPINBUTTON_DEFFLAGS ),
2026 mnOrientation( AX_ORIENTATION_AUTO ),
2027 mnMin( 0 ),
2028 mnMax( 100 ),
2029 mnPosition( 0 ),
2030 mnSmallChange( 1 ),
2031 mnDelay( 50 )
2035 ApiControlType AxSpinButtonModel::getControlType() const
2037 return API_CONTROL_SPINBUTTON;
2040 void AxSpinButtonModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
2042 switch( nPropId )
2044 case XML_ForeColor: mnArrowColor = AttributeConversion::decodeUnsigned( rValue ); break;
2045 case XML_BackColor: mnBackColor = AttributeConversion::decodeUnsigned( rValue ); break;
2046 case XML_VariousPropertyBits: mnFlags = AttributeConversion::decodeUnsigned( rValue ); break;
2047 case XML_Orientation: mnOrientation = AttributeConversion::decodeInteger( rValue ); break;
2048 case XML_Min: mnMin = AttributeConversion::decodeInteger( rValue ); break;
2049 case XML_Max: mnMax = AttributeConversion::decodeInteger( rValue ); break;
2050 case XML_Position: mnPosition = AttributeConversion::decodeInteger( rValue ); break;
2051 case XML_SmallChange: mnSmallChange = AttributeConversion::decodeInteger( rValue ); break;
2052 case XML_Delay: mnDelay = AttributeConversion::decodeInteger( rValue ); break;
2053 default: AxControlModelBase::importProperty( nPropId, rValue );
2057 bool AxSpinButtonModel::importBinaryModel( BinaryInputStream& rInStrm )
2059 AxBinaryPropertyReader aReader( rInStrm );
2060 aReader.readIntProperty< sal_uInt32 >( mnArrowColor );
2061 aReader.readIntProperty< sal_uInt32 >( mnBackColor );
2062 aReader.readIntProperty< sal_uInt32 >( mnFlags );
2063 aReader.readPairProperty( maSize );
2064 aReader.skipIntProperty< sal_uInt32 >(); // unused
2065 aReader.readIntProperty< sal_Int32 >( mnMin );
2066 aReader.readIntProperty< sal_Int32 >( mnMax );
2067 aReader.readIntProperty< sal_Int32 >( mnPosition );
2068 aReader.skipIntProperty< sal_uInt32 >(); // prev enabled
2069 aReader.skipIntProperty< sal_uInt32 >(); // next enabled
2070 aReader.readIntProperty< sal_Int32 >( mnSmallChange );
2071 aReader.readIntProperty< sal_Int32 >( mnOrientation );
2072 aReader.readIntProperty< sal_Int32 >( mnDelay );
2073 aReader.skipPictureProperty(); // mouse icon
2074 aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
2075 return aReader.finalizeImport();
2078 void AxSpinButtonModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
2080 AxBinaryPropertyWriter aWriter( rOutStrm );
2081 aWriter.writeIntProperty< sal_uInt32 >( mnArrowColor );
2082 aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
2083 aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
2084 aWriter.writePairProperty( maSize );
2085 aWriter.skipProperty(); // unused
2086 aWriter.writeIntProperty< sal_Int32 >( mnMin );
2087 aWriter.writeIntProperty< sal_Int32 >( mnMax );
2088 aWriter.writeIntProperty< sal_Int32 >( mnPosition );
2089 aWriter.skipProperty(); // prev enabled
2090 aWriter.skipProperty(); // next enabled
2091 aWriter.writeIntProperty< sal_Int32 >( mnSmallChange );
2092 aWriter.writeIntProperty< sal_Int32 >( mnOrientation );
2093 aWriter.writeIntProperty< sal_Int32 >( mnDelay );
2094 aWriter.skipProperty(); // mouse icon
2095 aWriter.skipProperty(); // mouse pointer
2097 aWriter.finalizeExport();
2100 void AxSpinButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2102 sal_Int32 nMin = ::std::min( mnMin, mnMax );
2103 sal_Int32 nMax = ::std::max( mnMin, mnMax );
2104 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
2105 rPropMap.setProperty( PROP_SpinValueMin, nMin );
2106 rPropMap.setProperty( PROP_SpinValueMax, nMax );
2107 rPropMap.setProperty( PROP_SpinIncrement, mnSmallChange );
2108 rPropMap.setProperty( mbAwtModel ? PROP_SpinValue : PROP_DefaultSpinValue, mnPosition );
2109 rPropMap.setProperty( PROP_Repeat, true );
2110 rPropMap.setProperty( PROP_RepeatDelay, mnDelay );
2111 rPropMap.setProperty( PROP_Border, API_BORDER_NONE );
2112 rConv.convertColor( rPropMap, PROP_SymbolColor, mnArrowColor );
2113 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED );
2114 rConv.convertAxOrientation( rPropMap, maSize, mnOrientation );
2115 AxControlModelBase::convertProperties( rPropMap, rConv );
2118 void AxSpinButtonModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
2120 bool bRes = false;
2121 if ( rPropSet.getProperty( bRes, PROP_Enabled ) )
2122 setFlag( mnFlags, AX_FLAGS_ENABLED, bRes );
2123 rPropSet.getProperty( mnMin, PROP_SpinValueMin );
2124 rPropSet.getProperty( mnMax, PROP_SpinValueMax );
2125 rPropSet.getProperty( mnSmallChange, PROP_SpinIncrement );
2126 rPropSet.getProperty( mnPosition, ( mbAwtModel ? PROP_SpinValue : PROP_DefaultSpinValue ) );
2127 rPropSet.getProperty( mnDelay, PROP_RepeatDelay );
2128 rConv.convertToMSColor( rPropSet, PROP_SymbolColor, mnArrowColor);
2129 rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
2131 rConv.convertToAxOrientation( rPropSet, maSize, mnOrientation );
2134 void AxSpinButtonModel::exportCompObj( BinaryOutputStream& rOutStream )
2136 // should be able to replace this hardcoded foo with
2137 // proper export info from MS-OLEDS spec.
2138 static sal_uInt8 const aCompObj[] =
2140 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2141 0xFF, 0xFF, 0xFF, 0xFF, 0xB0, 0x6F, 0x17, 0x79,
2142 0xF2, 0xB7, 0xCE, 0x11, 0x97, 0xEF, 0x00, 0xAA,
2143 0x00, 0x6D, 0x27, 0x76, 0x1F, 0x00, 0x00, 0x00,
2144 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2145 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2146 0x32, 0x2E, 0x30, 0x20, 0x53, 0x70, 0x69, 0x6E,
2147 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x00, 0x10,
2148 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64,
2149 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65,
2150 0x63, 0x74, 0x00, 0x13, 0x00, 0x00, 0x00, 0x46,
2151 0x6E, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x2E,
2152 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00,
2153 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2154 0x00, 0x00
2157 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
2159 // ============================================================================
2161 AxScrollBarModel::AxScrollBarModel() :
2162 mnArrowColor( AX_SYSCOLOR_BUTTONTEXT ),
2163 mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
2164 mnFlags( AX_SCROLLBAR_DEFFLAGS ),
2165 mnOrientation( AX_ORIENTATION_AUTO ),
2166 mnPropThumb( AX_PROPTHUMB_ON ),
2167 mnMin( 0 ),
2168 mnMax( 32767 ),
2169 mnPosition( 0 ),
2170 mnSmallChange( 1 ),
2171 mnLargeChange( 1 ),
2172 mnDelay( 50 )
2176 ApiControlType AxScrollBarModel::getControlType() const
2178 return API_CONTROL_SCROLLBAR;
2181 void AxScrollBarModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
2183 switch( nPropId )
2185 case XML_ForeColor: mnArrowColor = AttributeConversion::decodeUnsigned( rValue ); break;
2186 case XML_BackColor: mnBackColor = AttributeConversion::decodeUnsigned( rValue ); break;
2187 case XML_VariousPropertyBits: mnFlags = AttributeConversion::decodeUnsigned( rValue ); break;
2188 case XML_Orientation: mnOrientation = AttributeConversion::decodeInteger( rValue ); break;
2189 case XML_ProportionalThumb: mnPropThumb = AttributeConversion::decodeInteger( rValue ); break;
2190 case XML_Min: mnMin = AttributeConversion::decodeInteger( rValue ); break;
2191 case XML_Max: mnMax = AttributeConversion::decodeInteger( rValue ); break;
2192 case XML_Position: mnPosition = AttributeConversion::decodeInteger( rValue ); break;
2193 case XML_SmallChange: mnSmallChange = AttributeConversion::decodeInteger( rValue ); break;
2194 case XML_LargeChange: mnLargeChange = AttributeConversion::decodeInteger( rValue ); break;
2195 case XML_Delay: mnDelay = AttributeConversion::decodeInteger( rValue ); break;
2196 default: AxControlModelBase::importProperty( nPropId, rValue );
2200 bool AxScrollBarModel::importBinaryModel( BinaryInputStream& rInStrm )
2202 AxBinaryPropertyReader aReader( rInStrm );
2203 aReader.readIntProperty< sal_uInt32 >( mnArrowColor );
2204 aReader.readIntProperty< sal_uInt32 >( mnBackColor );
2205 aReader.readIntProperty< sal_uInt32 >( mnFlags );
2206 aReader.readPairProperty( maSize );
2207 aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
2208 aReader.readIntProperty< sal_Int32 >( mnMin );
2209 aReader.readIntProperty< sal_Int32 >( mnMax );
2210 aReader.readIntProperty< sal_Int32 >( mnPosition );
2211 aReader.skipIntProperty< sal_uInt32 >(); // unused
2212 aReader.skipIntProperty< sal_uInt32 >(); // prev enabled
2213 aReader.skipIntProperty< sal_uInt32 >(); // next enabled
2214 aReader.readIntProperty< sal_Int32 >( mnSmallChange );
2215 aReader.readIntProperty< sal_Int32 >( mnLargeChange );
2216 aReader.readIntProperty< sal_Int32 >( mnOrientation );
2217 aReader.readIntProperty< sal_Int16 >( mnPropThumb );
2218 aReader.readIntProperty< sal_Int32 >( mnDelay );
2219 aReader.skipPictureProperty(); // mouse icon
2220 return aReader.finalizeImport();
2223 void AxScrollBarModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
2225 AxBinaryPropertyWriter aWriter( rOutStrm );
2226 aWriter.writeIntProperty< sal_uInt32 >( mnArrowColor );
2227 aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
2228 aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
2229 aWriter.writePairProperty( maSize );
2230 aWriter.skipProperty(); // mouse pointer
2231 aWriter.writeIntProperty< sal_Int32 >( mnMin );
2232 aWriter.writeIntProperty< sal_Int32 >( mnMax );
2233 aWriter.writeIntProperty< sal_Int32 >( mnPosition );
2234 aWriter.skipProperty(); // unused
2235 aWriter.skipProperty(); // prev enabled
2236 aWriter.skipProperty(); // next enabled
2237 aWriter.writeIntProperty< sal_Int32 >( mnSmallChange );
2238 aWriter.writeIntProperty< sal_Int32 >( mnLargeChange );
2239 aWriter.writeIntProperty< sal_Int32 >( mnOrientation );
2240 aWriter.writeIntProperty< sal_Int16 >( mnPropThumb );
2241 aWriter.writeIntProperty< sal_Int32 >( mnDelay );
2242 aWriter.skipProperty(); // mouse icon
2243 aWriter.finalizeExport();
2246 void AxScrollBarModel::exportCompObj( BinaryOutputStream& rOutStream )
2248 // should be able to replace this hardcoded foo with
2249 // proper export info from MS-OLEDS spec.
2250 static sal_uInt8 const aCompObj[] =
2252 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2253 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x81, 0xD1, 0xDF,
2254 0x2F, 0x5E, 0xCE, 0x11, 0xA4, 0x49, 0x00, 0xAA,
2255 0x00, 0x4A, 0x80, 0x3D, 0x1E, 0x00, 0x00, 0x00,
2256 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2257 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2258 0x32, 0x2E, 0x30, 0x20, 0x53, 0x63, 0x72, 0x6F,
2259 0x6C, 0x6C, 0x42, 0x61, 0x72, 0x00, 0x10, 0x00,
2260 0x00, 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64,
2261 0x65, 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63,
2262 0x74, 0x00, 0x12, 0x00, 0x00, 0x00, 0x46, 0x6F,
2263 0x72, 0x6D, 0x73, 0x2E, 0x53, 0x63, 0x72, 0x6F,
2264 0x6C, 0x6C, 0x42, 0x61, 0x72, 0x2E, 0x31, 0x00,
2265 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
2266 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2268 rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
2271 void AxScrollBarModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2273 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
2274 rPropMap.setProperty( PROP_RepeatDelay, mnDelay );
2275 rPropMap.setProperty( PROP_Border, API_BORDER_NONE );
2276 if( (mnPropThumb == AX_PROPTHUMB_ON) && (mnMin != mnMax) && (mnLargeChange > 0) )
2278 // use double to prevent integer overflow in division (fInterval+mnLargeChange may become 0 when performed as int)
2279 double fInterval = fabs( static_cast< double >( mnMax - mnMin ) );
2280 sal_Int32 nThumbLen = getLimitedValue< sal_Int32, double >( (fInterval * mnLargeChange) / (fInterval + mnLargeChange), 1, SAL_MAX_INT32 );
2281 rPropMap.setProperty( PROP_VisibleSize, nThumbLen );
2283 rConv.convertColor( rPropMap, PROP_SymbolColor, mnArrowColor );
2284 rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED );
2285 rConv.convertAxOrientation( rPropMap, maSize, mnOrientation );
2286 rConv.convertScrollBar( rPropMap, mnMin, mnMax, mnPosition, mnSmallChange, mnLargeChange, mbAwtModel );
2287 AxControlModelBase::convertProperties( rPropMap, rConv );
2290 void AxScrollBarModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
2292 bool bRes = false;
2293 if ( rPropSet.getProperty( bRes, PROP_Enabled ) )
2294 setFlag( mnFlags, AX_FLAGS_ENABLED, bRes );
2295 rPropSet.getProperty( mnDelay, PROP_RepeatDelay );
2296 mnPropThumb = AX_PROPTHUMB_ON; // default
2297 rConv.convertToMSColor( rPropSet, PROP_SymbolColor, mnArrowColor);
2298 rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
2299 rConv.convertToAxOrientation( rPropSet, maSize, mnOrientation );
2301 rPropSet.getProperty( mnMin, PROP_ScrollValueMin );
2302 rPropSet.getProperty( mnMax, PROP_ScrollValueMax );
2303 rPropSet.getProperty( mnSmallChange, PROP_LineIncrement );
2304 rPropSet.getProperty( mnLargeChange, PROP_BlockIncrement );
2305 rPropSet.getProperty( mnPosition, ( mbAwtModel ? PROP_ScrollValue : PROP_DefaultScrollValue ) );
2309 // ============================================================================
2311 AxContainerModelBase::AxContainerModelBase( bool bFontSupport ) :
2312 AxFontDataModel( false ), // no support for alignment properties
2313 maLogicalSize( AX_CONTAINER_DEFWIDTH, AX_CONTAINER_DEFHEIGHT ),
2314 maScrollPos( 0, 0 ),
2315 mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
2316 mnTextColor( AX_SYSCOLOR_BUTTONTEXT ),
2317 mnFlags( AX_CONTAINER_DEFFLAGS ),
2318 mnBorderColor( AX_SYSCOLOR_BUTTONTEXT ),
2319 mnBorderStyle( AX_BORDERSTYLE_NONE ),
2320 mnScrollBars( AX_CONTAINER_SCR_NONE ),
2321 mnCycleType( AX_CONTAINER_CYCLEALL ),
2322 mnSpecialEffect( AX_SPECIALEFFECT_FLAT ),
2323 mnPicAlign( AX_PICALIGN_CENTER ),
2324 mnPicSizeMode( AX_PICSIZE_CLIP ),
2325 mbPicTiling( false ),
2326 mbFontSupport( bFontSupport )
2328 setAwtModelMode();
2329 // different default size for frame
2330 maSize = AxPairData( AX_CONTAINER_DEFWIDTH, AX_CONTAINER_DEFHEIGHT );
2333 void AxContainerModelBase::importProperty( sal_Int32 nPropId, const OUString& rValue )
2335 if( nPropId == XML_Caption )
2336 maCaption = rValue;
2339 bool AxContainerModelBase::importBinaryModel( BinaryInputStream& rInStrm )
2341 AxBinaryPropertyReader aReader( rInStrm );
2342 aReader.skipUndefinedProperty();
2343 aReader.readIntProperty< sal_uInt32 >( mnBackColor );
2344 aReader.readIntProperty< sal_uInt32 >( mnTextColor );
2345 aReader.skipIntProperty< sal_uInt32 >(); // next availbale control ID
2346 aReader.skipUndefinedProperty();
2347 aReader.skipUndefinedProperty();
2348 aReader.readIntProperty< sal_uInt32 >( mnFlags );
2349 aReader.readIntProperty< sal_uInt8 >( mnBorderStyle );
2350 aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
2351 aReader.readIntProperty< sal_uInt8 >( mnScrollBars );
2352 aReader.readPairProperty( maSize );
2353 aReader.readPairProperty( maLogicalSize );
2354 aReader.readPairProperty( maScrollPos );
2355 aReader.skipIntProperty< sal_uInt32 >(); // number of control groups
2356 aReader.skipUndefinedProperty();
2357 aReader.skipPictureProperty(); // mouse icon
2358 aReader.readIntProperty< sal_uInt8 >( mnCycleType );
2359 aReader.readIntProperty< sal_uInt8 >( mnSpecialEffect );
2360 aReader.readIntProperty< sal_uInt32 >( mnBorderColor );
2361 aReader.readStringProperty( maCaption );
2362 aReader.readFontProperty( maFontData );
2363 aReader.readPictureProperty( maPictureData );
2364 aReader.skipIntProperty< sal_Int32 >(); // zoom
2365 aReader.readIntProperty< sal_uInt8 >( mnPicAlign );
2366 aReader.readBoolProperty( mbPicTiling );
2367 aReader.readIntProperty< sal_uInt8 >( mnPicSizeMode );
2368 aReader.skipIntProperty< sal_uInt32 >(); // shape cookie
2369 aReader.skipIntProperty< sal_uInt32 >(); // draw buffer size
2370 return aReader.finalizeImport();
2373 void AxContainerModelBase::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2375 if( mbFontSupport )
2377 rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor );
2378 AxFontDataModel::convertProperties( rPropMap, rConv );
2382 bool AxContainerModelBase::importClassTable( BinaryInputStream& rInStrm, AxClassTable& orClassTable )
2384 bool bValid = true;
2385 orClassTable.clear();
2386 if( !getFlag( mnFlags, AX_CONTAINER_NOCLASSTABLE ) )
2388 sal_uInt16 nCount = rInStrm.readuInt16();
2389 for( sal_uInt16 nIndex = 0; bValid && (nIndex < nCount); ++nIndex )
2391 orClassTable.push_back( OUString() );
2392 AxBinaryPropertyReader aReader( rInStrm );
2393 aReader.readGuidProperty( orClassTable.back() );
2394 aReader.skipGuidProperty(); // source interface GUID
2395 aReader.skipUndefinedProperty();
2396 aReader.skipGuidProperty(); // default interface GUID
2397 aReader.skipIntProperty< sal_uInt32 >(); // class table and var flags
2398 aReader.skipIntProperty< sal_uInt32 >(); // method count
2399 aReader.skipIntProperty< sal_Int32 >(); // IDispatch identifier for linked cell access
2400 aReader.skipIntProperty< sal_uInt16 >(); // get function index for linked cell access
2401 aReader.skipIntProperty< sal_uInt16 >(); // put function index for linked cell access
2402 aReader.skipIntProperty< sal_uInt16 >(); // linked cell access property type
2403 aReader.skipIntProperty< sal_uInt16 >(); // get function index of value
2404 aReader.skipIntProperty< sal_uInt16 >(); // put function index of value
2405 aReader.skipIntProperty< sal_uInt16 >(); // value type
2406 aReader.skipIntProperty< sal_Int32 >(); // IDispatch identifier for source range access
2407 aReader.skipIntProperty< sal_uInt16 >(); // get function index for source range access
2408 bValid = aReader.finalizeImport();
2411 return bValid;
2414 // ============================================================================
2416 AxFrameModel::AxFrameModel() :
2417 AxContainerModelBase( true )
2421 ApiControlType AxFrameModel::getControlType() const
2423 return mbAwtModel ? API_CONTROL_FRAME : API_CONTROL_GROUPBOX;
2426 void AxFrameModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2428 rPropMap.setProperty( PROP_Label, maCaption );
2429 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_CONTAINER_ENABLED ) );
2430 #ifdef SCROLLABLEFRAME
2431 rConv.convertScrollabilitySettings( rPropMap, maScrollPos, maLogicalSize, mnScrollBars );
2432 #endif
2433 AxContainerModelBase::convertProperties( rPropMap, rConv );
2436 AxPageModel::AxPageModel()
2440 ApiControlType AxPageModel::getControlType() const
2442 return API_CONTROL_PAGE;
2445 void AxPageModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2447 rPropMap.setProperty( PROP_Title, maCaption );
2448 rConv.convertColor( rPropMap, PROP_BackgroundColor, mnBackColor );
2449 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_CONTAINER_ENABLED ) );
2450 AxContainerModelBase::convertProperties( rPropMap, rConv );
2453 AxMultiPageModel::AxMultiPageModel() :
2454 mnActiveTab( 0 ),
2455 mnTabStyle( AX_TABSTRIP_TABS )
2459 ApiControlType AxMultiPageModel::getControlType() const
2461 return API_CONTROL_MULTIPAGE;
2465 bool AxMultiPageModel::importPageAndMultiPageProperties( BinaryInputStream& rInStrm, sal_Int32 nPages )
2467 // PageProperties
2468 for ( sal_Int32 nPage = 0; nPage < nPages; ++nPage )
2470 AxBinaryPropertyReader aReader( rInStrm );
2471 aReader.skipUndefinedProperty();
2472 aReader.skipIntProperty< sal_uInt32 >(); // TransistionEffect
2473 aReader.skipIntProperty< sal_uInt32 >(); // TransitionPeriod
2475 // MultiPageProperties
2476 AxBinaryPropertyReader aReader( rInStrm );
2477 sal_uInt32 nPageCount = 0;
2478 aReader.skipUndefinedProperty();
2479 aReader.readIntProperty< sal_uInt32 >(nPageCount); // PageCount
2480 aReader.skipIntProperty< sal_uInt32 >(); //ID
2482 // IDs
2483 for ( sal_uInt32 count = 0; count < nPageCount; ++count )
2485 sal_Int32 nID = 0;
2486 rInStrm >> nID;
2487 mnIDs.push_back( nID );
2489 return true;
2492 void AxMultiPageModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2494 rPropMap.setProperty( PROP_Title, maCaption );
2495 rPropMap.setProperty( PROP_MultiPageValue, mnActiveTab + 1);
2496 rConv.convertColor( rPropMap, PROP_BackgroundColor, mnBackColor );
2497 rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_CONTAINER_ENABLED ) );
2498 rPropMap.setProperty( PROP_Decoration, mnTabStyle != AX_TABSTRIP_NONE );
2500 AxContainerModelBase::convertProperties( rPropMap, rConv );
2504 // ============================================================================
2506 AxUserFormModel::AxUserFormModel()
2510 ApiControlType AxUserFormModel::getControlType() const
2512 return API_CONTROL_DIALOG;
2515 void AxUserFormModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2517 rPropMap.setProperty( PROP_Title, maCaption );
2518 rConv.convertColor( rPropMap, PROP_BackgroundColor, mnBackColor );
2519 rConv.convertAxPicture( rPropMap, maPictureData, AX_PICPOS_CENTER );
2520 rConv.convertScrollabilitySettings( rPropMap, maScrollPos, maLogicalSize, mnScrollBars );
2521 AxContainerModelBase::convertProperties( rPropMap, rConv );
2524 HtmlSelectModel::HtmlSelectModel()
2528 bool
2529 HtmlSelectModel::importBinaryModel( BinaryInputStream& rInStrm )
2531 static OUString sMultiple( "<SELECT MULTIPLE" );
2532 static OUString sSelected( "OPTION SELECTED" );
2534 OUString sStringContents = rInStrm.readUnicodeArray( rInStrm.size() );
2536 OUString data = sStringContents;
2538 // replace crlf with lf
2539 data = data.replaceAll( "\x0D\x0A" , "\x0A" );
2540 std::vector< OUString > listValues;
2541 std::vector< sal_Int16 > selectedIndices;
2543 // Ultra hacky parser for the info
2544 sal_Int32 nTokenCount = comphelper::string::getTokenCount(data, '\n');
2546 for ( sal_Int32 nToken = 0; nToken < nTokenCount; ++nToken )
2548 OUString sLine( data.getToken( nToken, '\n' ) );
2549 if ( !nToken ) // first line will tell us if multiselect is enabled
2551 if ( sLine == sMultiple )
2552 mnMultiSelect = true;
2554 // skip first and last lines, no data there
2555 else if ( nToken < nTokenCount - 1)
2557 if ( comphelper::string::getTokenCount(sLine, '>') )
2559 OUString displayValue = sLine.getToken( 1, '>' );
2560 if ( displayValue.getLength() )
2562 // Really we should be using a proper html parser
2563 // escaping some common bits to be escaped
2564 displayValue = displayValue.replaceAll( "&lt;", "<" );
2565 displayValue = displayValue.replaceAll( "&gt;", ">" );
2566 displayValue = displayValue.replaceAll( "&quot;", "\"" );
2567 displayValue = displayValue.replaceAll( "&amp;", "&" );
2568 listValues.push_back( displayValue );
2569 if( sLine.indexOf( sSelected ) != STRING_NOTFOUND )
2570 selectedIndices.push_back( static_cast< sal_Int16 >( listValues.size() ) - 1 );
2575 if ( !listValues.empty() )
2577 msListData.realloc( listValues.size() );
2578 sal_Int32 index = 0;
2579 for( std::vector< OUString >::iterator it = listValues.begin(); it != listValues.end(); ++it, ++index )
2580 msListData[ index ] = *it;
2582 if ( !selectedIndices.empty() )
2584 msIndices.realloc( selectedIndices.size() );
2585 sal_Int32 index = 0;
2586 for( std::vector< sal_Int16 >::iterator it = selectedIndices.begin(); it != selectedIndices.end(); ++it, ++index )
2587 msIndices[ index ] = *it;
2589 return sal_True;
2593 void
2594 HtmlSelectModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
2596 rPropMap.setProperty( PROP_StringItemList, msListData );
2597 rPropMap.setProperty( PROP_SelectedItems, msIndices );
2598 rPropMap.setProperty( PROP_Dropdown, true );
2599 AxListBoxModel::convertProperties( rPropMap, rConv );
2602 HtmlTextBoxModel::HtmlTextBoxModel()
2606 bool
2607 HtmlTextBoxModel::importBinaryModel( BinaryInputStream& rInStrm )
2609 #ifdef DEBUG
2610 OUString sStringContents = rInStrm.readUnicodeArray( rInStrm.size() );
2611 // in msocximex ( where this is ported from, it appears *nothing* is read
2612 // from the control stream ), surely there is some useful info there ?
2613 OSL_TRACE("HtmlTextBoxModel::importBinaryModel - string contents of stream :");
2614 OSL_TRACE("%s", OUStringToOString( sStringContents, RTL_TEXTENCODING_UTF8 ).getStr() );
2615 #else
2616 (void) rInStrm;
2617 #endif
2618 return true;
2620 // ============================================================================
2622 EmbeddedControl::EmbeddedControl( const OUString& rName ) :
2623 maName( rName )
2627 EmbeddedControl::~EmbeddedControl()
2631 ControlModelBase* EmbeddedControl::createModelFromGuid( const OUString& rClassId )
2633 OUString aClassId = rClassId;//.toAsciiUpperCase();
2635 if( aClassId.equalsIgnoreAsciiCase( AX_GUID_COMMANDBUTTON ) ) return &createModel< AxCommandButtonModel >();
2636 if( aClassId.equalsIgnoreAsciiCase( AX_GUID_LABEL ) ) return &createModel< AxLabelModel >();
2637 if( aClassId.equalsIgnoreAsciiCase( AX_GUID_IMAGE ) ) return &createModel< AxImageModel >();
2638 if( aClassId.equalsIgnoreAsciiCase( AX_GUID_TOGGLEBUTTON ) ) return &createModel< AxToggleButtonModel >();
2639 if( aClassId.equalsIgnoreAsciiCase( AX_GUID_CHECKBOX ) ) return &createModel< AxCheckBoxModel >();
2640 if( aClassId.equalsIgnoreAsciiCase( AX_GUID_OPTIONBUTTON ) ) return &createModel< AxOptionButtonModel >();
2641 if( aClassId.equalsIgnoreAsciiCase( AX_GUID_TEXTBOX ) ) return &createModel< AxTextBoxModel >();
2642 if( aClassId.equalsIgnoreAsciiCase( AX_GUID_LISTBOX ) ) return &createModel< AxListBoxModel >();
2643 if( aClassId.equalsIgnoreAsciiCase( AX_GUID_COMBOBOX ) ) return &createModel< AxComboBoxModel >();
2644 if( aClassId.equalsIgnoreAsciiCase( AX_GUID_SPINBUTTON ) ) return &createModel< AxSpinButtonModel >();
2645 if( aClassId.equalsIgnoreAsciiCase( AX_GUID_SCROLLBAR ) ) return &createModel< AxScrollBarModel >();
2646 if( aClassId.equalsIgnoreAsciiCase( AX_GUID_FRAME ) ) return &createModel< AxFrameModel >();
2647 if( aClassId.equalsIgnoreAsciiCase( COMCTL_GUID_SCROLLBAR_60 ) ) return &createModel< ComCtlScrollBarModel >( COMCTL_VERSION_60 );
2648 if( aClassId.equalsIgnoreAsciiCase( HTML_GUID_SELECT ) ) return &createModel< HtmlSelectModel >();
2649 if( aClassId.equalsIgnoreAsciiCase( HTML_GUID_TEXTBOX ) ) return &createModel< HtmlTextBoxModel >();
2651 mxModel.reset();
2652 return 0;
2655 OUString EmbeddedControl::getServiceName() const
2657 return mxModel.get() ? mxModel->getServiceName() : OUString();
2660 bool EmbeddedControl::convertProperties( const Reference< XControlModel >& rxCtrlModel, const ControlConverter& rConv ) const
2662 if( mxModel.get() && rxCtrlModel.is() && !maName.isEmpty() )
2664 PropertyMap aPropMap;
2665 aPropMap.setProperty( PROP_Name, maName );
2668 aPropMap.setProperty( PROP_GenerateVbaEvents, true);
2670 catch (const Exception& e)
2672 SAL_WARN("oox", "exception: " << e.Message);
2674 mxModel->convertProperties( aPropMap, rConv );
2675 PropertySet aPropSet( rxCtrlModel );
2676 aPropSet.setProperties( aPropMap );
2677 return true;
2679 return false;
2682 bool EmbeddedControl::convertFromProperties( const Reference< XControlModel >& rxCtrlModel, const ControlConverter& rConv )
2684 if( mxModel.get() && rxCtrlModel.is() && !maName.isEmpty() )
2686 PropertySet aPropSet( rxCtrlModel );
2687 aPropSet.getProperty( maName, PROP_Name );
2688 mxModel->convertFromProperties( aPropSet, rConv );
2689 return true;
2691 return false;
2694 // ============================================================================
2696 EmbeddedForm::EmbeddedForm( const Reference< XModel >& rxDocModel,
2697 const Reference< XDrawPage >& rxDrawPage, const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ) :
2698 maControlConv( rxDocModel, rGraphicHelper, bDefaultColorBgr ),
2699 mxModelFactory( rxDocModel, UNO_QUERY ),
2700 mxFormsSupp( rxDrawPage, UNO_QUERY )
2702 OSL_ENSURE( mxModelFactory.is(), "EmbeddedForm::EmbeddedForm - missing service factory" );
2705 Reference< XControlModel > EmbeddedForm::convertAndInsert( const EmbeddedControl& rControl, sal_Int32& rnCtrlIndex )
2707 if( mxModelFactory.is() && rControl.hasModel() ) try
2709 // create the UNO control model
2710 OUString aServiceName = rControl.getServiceName();
2711 Reference< XFormComponent > xFormComp( mxModelFactory->createInstance( aServiceName ), UNO_QUERY_THROW );
2712 Reference< XControlModel > xCtrlModel( xFormComp, UNO_QUERY_THROW );
2714 // insert the control into the form
2715 Reference< XIndexContainer > xFormIC( createXForm(), UNO_SET_THROW );
2716 rnCtrlIndex = xFormIC->getCount();
2717 xFormIC->insertByIndex( rnCtrlIndex, Any( xFormComp ) );
2719 // convert the control properties
2720 if( rControl.convertProperties( xCtrlModel, maControlConv ) )
2721 return xCtrlModel;
2723 catch (const Exception& e)
2725 SAL_WARN("oox", "exception creating Control: " << e.Message);
2727 return Reference< XControlModel >();
2730 Reference< XIndexContainer > EmbeddedForm::createXForm()
2732 if( mxFormsSupp.is() )
2736 Reference< XNameContainer > xFormsNC( mxFormsSupp->getForms(), UNO_SET_THROW );
2737 OUString aFormName = "Standard";
2738 if( xFormsNC->hasByName( aFormName ) )
2740 mxFormIC.set( xFormsNC->getByName( aFormName ), UNO_QUERY_THROW );
2742 else if( mxModelFactory.is() )
2744 Reference< XForm > xForm( mxModelFactory->createInstance( "com.sun.star.form.component.Form" ), UNO_QUERY_THROW );
2745 xFormsNC->insertByName( aFormName, Any( xForm ) );
2746 mxFormIC.set( xForm, UNO_QUERY_THROW );
2749 catch (const Exception& e)
2751 SAL_WARN("oox", "exception creating Form: " << e.Message);
2753 // always clear the forms supplier to not try to create the form again
2754 mxFormsSupp.clear();
2756 return mxFormIC;
2759 // ============================================================================
2761 } // namespace ole
2762 } // namespace oox
2764 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */