1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <osl/diagnose.h>
52 #include "oox/helper/attributelist.hxx"
53 #include "oox/helper/binaryinputstream.hxx"
54 #include "oox/helper/containerhelper.hxx"
55 #include "oox/helper/graphichelper.hxx"
56 #include "oox/helper/propertymap.hxx"
57 #include "oox/ole/axbinarywriter.hxx"
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
;
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;
84 const sal_uInt32 COMCTL_ID_COMPLEXDATA
= 0xBDECDE1F;
85 const sal_uInt32 COMCTL_COMPLEX_FONT
= 0x00000001;
86 const sal_uInt32 COMCTL_COMPLEX_MOUSEICON
= 0x00000002;
88 const sal_uInt32 COMCTL_ID_SCROLLBAR_60
= 0x99470A83;
89 const sal_uInt32 COMCTL_SCROLLBAR_HOR
= 0x00000010;
91 const sal_uInt32 COMCTL_ID_PROGRESSBAR_50
= 0xE6E17E84;
92 const sal_uInt32 COMCTL_ID_PROGRESSBAR_60
= 0x97AB8A01;
94 const sal_uInt32 AX_CMDBUTTON_DEFFLAGS
= 0x0000001B;
95 const sal_uInt32 AX_LABEL_DEFFLAGS
= 0x0080001B;
96 const sal_uInt32 AX_IMAGE_DEFFLAGS
= 0x0000001B;
97 const sal_uInt32 AX_MORPHDATA_DEFFLAGS
= 0x2C80081B;
98 const sal_uInt32 AX_SPINBUTTON_DEFFLAGS
= 0x0000001B;
99 const sal_uInt32 AX_SCROLLBAR_DEFFLAGS
= 0x0000001B;
101 const sal_uInt16 AX_POS_TOPLEFT
= 0;
102 const sal_uInt16 AX_POS_TOP
= 1;
103 const sal_uInt16 AX_POS_TOPRIGHT
= 2;
104 const sal_uInt16 AX_POS_LEFT
= 3;
105 const sal_uInt16 AX_POS_CENTER
= 4;
106 const sal_uInt16 AX_POS_RIGHT
= 5;
107 const sal_uInt16 AX_POS_BOTTOMLEFT
= 6;
108 const sal_uInt16 AX_POS_BOTTOM
= 7;
109 const sal_uInt16 AX_POS_BOTTOMRIGHT
= 8;
111 #define AX_PICPOS_IMPL( label, image ) ((AX_POS_##label << 16) | AX_POS_##image)
112 const sal_uInt32 AX_PICPOS_LEFTTOP
= AX_PICPOS_IMPL( TOPRIGHT
, TOPLEFT
);
113 const sal_uInt32 AX_PICPOS_LEFTCENTER
= AX_PICPOS_IMPL( RIGHT
, LEFT
);
114 const sal_uInt32 AX_PICPOS_LEFTBOTTOM
= AX_PICPOS_IMPL( BOTTOMRIGHT
, BOTTOMLEFT
);
115 const sal_uInt32 AX_PICPOS_RIGHTTOP
= AX_PICPOS_IMPL( TOPLEFT
, TOPRIGHT
);
116 const sal_uInt32 AX_PICPOS_RIGHTCENTER
= AX_PICPOS_IMPL( LEFT
, RIGHT
);
117 const sal_uInt32 AX_PICPOS_RIGHTBOTTOM
= AX_PICPOS_IMPL( BOTTOMLEFT
, BOTTOMRIGHT
);
118 const sal_uInt32 AX_PICPOS_ABOVELEFT
= AX_PICPOS_IMPL( BOTTOMLEFT
, TOPLEFT
);
119 const sal_uInt32 AX_PICPOS_ABOVECENTER
= AX_PICPOS_IMPL( BOTTOM
, TOP
);
120 const sal_uInt32 AX_PICPOS_ABOVERIGHT
= AX_PICPOS_IMPL( BOTTOMRIGHT
, TOPRIGHT
);
121 const sal_uInt32 AX_PICPOS_BELOWLEFT
= AX_PICPOS_IMPL( TOPLEFT
, BOTTOMLEFT
);
122 const sal_uInt32 AX_PICPOS_BELOWCENTER
= AX_PICPOS_IMPL( TOP
, BOTTOM
);
123 const sal_uInt32 AX_PICPOS_BELOWRIGHT
= AX_PICPOS_IMPL( TOPRIGHT
, BOTTOMRIGHT
);
124 const sal_uInt32 AX_PICPOS_CENTER
= AX_PICPOS_IMPL( CENTER
, CENTER
);
125 #undef AX_PICPOS_IMPL
127 const sal_Int32 AX_MATCHENTRY_FIRSTLETTER
= 0;
128 const sal_Int32 AX_MATCHENTRY_COMPLETE
= 1;
129 const sal_Int32 AX_MATCHENTRY_NONE
= 2;
131 const sal_Int32 AX_ORIENTATION_AUTO
= -1;
132 const sal_Int32 AX_ORIENTATION_VERTICAL
= 0;
133 const sal_Int32 AX_ORIENTATION_HORIZONTAL
= 1;
135 const sal_Int32 AX_PROPTHUMB_ON
= -1;
137 const sal_uInt32 AX_TABSTRIP_TABS
= 0;
138 const sal_uInt32 AX_TABSTRIP_NONE
= 2;
140 const sal_uInt32 AX_CONTAINER_ENABLED
= 0x00000004;
141 const sal_uInt32 AX_CONTAINER_NOCLASSTABLE
= 0x00008000;
143 const sal_uInt32 AX_CONTAINER_DEFFLAGS
= 0x00000004;
145 const sal_Int32 AX_CONTAINER_DEFWIDTH
= 4000;
146 const sal_Int32 AX_CONTAINER_DEFHEIGHT
= 3000;
148 const sal_Int32 AX_CONTAINER_CYCLEALL
= 0;
150 const sal_Int32 AX_CONTAINER_SCR_NONE
= 0x00;
152 const sal_Int16 API_BORDER_NONE
= 0;
153 const sal_Int16 API_BORDER_SUNKEN
= 1;
154 const sal_Int16 API_BORDER_FLAT
= 2;
156 const sal_Int16 API_STATE_UNCHECKED
= 0;
157 const sal_Int16 API_STATE_CHECKED
= 1;
158 const sal_Int16 API_STATE_DONTKNOW
= 2;
160 /** Tries to extract a range address from a defined name. */
161 bool lclExtractRangeFromName( CellRangeAddress
& orRangeAddr
, const Reference
< XModel
>& rxDocModel
, const OUString
& rAddressString
)
165 PropertySet
aPropSet( rxDocModel
);
166 Reference
< XNameAccess
> xRangesNA( aPropSet
.getAnyProperty( PROP_NamedRanges
), UNO_QUERY_THROW
);
167 Reference
< XCellRangeReferrer
> xReferrer( xRangesNA
->getByName( rAddressString
), UNO_QUERY_THROW
);
168 Reference
< XCellRangeAddressable
> xAddressable( xReferrer
->getReferredCells(), UNO_QUERY_THROW
);
169 orRangeAddr
= xAddressable
->getRangeAddress();
172 catch (const Exception
& e
)
174 SAL_WARN("oox", "exception: " << e
.Message
);
179 bool lclExtractAddressFromName( CellAddress
& orAddress
, const Reference
< XModel
>& rxDocModel
, const OUString
& rAddressString
)
181 CellRangeAddress aRangeAddr
;
182 if( lclExtractRangeFromName( aRangeAddr
, rxDocModel
, rAddressString
) &&
183 (aRangeAddr
.StartColumn
== aRangeAddr
.EndColumn
) &&
184 (aRangeAddr
.StartRow
== aRangeAddr
.EndRow
) )
186 orAddress
.Sheet
= aRangeAddr
.Sheet
;
187 orAddress
.Column
= aRangeAddr
.StartColumn
;
188 orAddress
.Row
= aRangeAddr
.StartRow
;
194 void lclPrepareConverter( PropertySet
& rConverter
, const Reference
< XModel
>& rxDocModel
,
195 const OUString
& rAddressString
, sal_Int32 nRefSheet
, bool bRange
)
197 if( !rConverter
.is() ) try
199 Reference
< XMultiServiceFactory
> xModelFactory( rxDocModel
, UNO_QUERY_THROW
);
200 OUString aServiceName
= bRange
?
201 OUString( "com.sun.star.table.CellRangeAddressConversion" ) :
202 OUString( "com.sun.star.table.CellAddressConversion" );
203 rConverter
.set( xModelFactory
->createInstance( aServiceName
) );
205 catch (const Exception
& e
)
207 SAL_WARN("oox", "exception: " << e
.Message
);
209 rConverter
.setProperty( PROP_XLA1Representation
, rAddressString
);
210 rConverter
.setProperty( PROP_ReferenceSheet
, nRefSheet
);
215 ControlConverter::ControlConverter( const Reference
< XModel
>& rxDocModel
,
216 const GraphicHelper
& rGraphicHelper
, bool bDefaultColorBgr
) :
217 mxDocModel( rxDocModel
),
218 mrGraphicHelper( rGraphicHelper
),
219 mbDefaultColorBgr( bDefaultColorBgr
)
221 OSL_ENSURE( mxDocModel
.is(), "ControlConverter::ControlConverter - missing document model" );
224 ControlConverter::~ControlConverter()
228 // Generic conversion ---------------------------------------------------------
230 void ControlConverter::convertPosition( PropertyMap
& rPropMap
, const AxPairData
& rPos
) const
232 // position is given in 1/100 mm, UNO needs AppFont units
233 awt::Point aAppFontPos
= mrGraphicHelper
.convertHmmToAppFont( awt::Point( rPos
.first
, rPos
.second
) );
234 rPropMap
.setProperty( PROP_PositionX
, aAppFontPos
.X
);
235 rPropMap
.setProperty( PROP_PositionY
, aAppFontPos
.Y
);
238 void ControlConverter::convertSize( PropertyMap
& rPropMap
, const AxPairData
& rSize
) const
240 // size is given in 1/100 mm, UNO needs AppFont units
241 awt::Size aAppFontSize
= mrGraphicHelper
.convertHmmToAppFont( awt::Size( rSize
.first
, rSize
.second
) );
242 rPropMap
.setProperty( PROP_Width
, aAppFontSize
.Width
);
243 rPropMap
.setProperty( PROP_Height
, aAppFontSize
.Height
);
246 void ControlConverter::convertColor( PropertyMap
& rPropMap
, sal_Int32 nPropId
, sal_uInt32 nOleColor
) const
248 rPropMap
.setProperty( nPropId
, OleHelper::decodeOleColor( mrGraphicHelper
, nOleColor
, mbDefaultColorBgr
) );
251 void ControlConverter::convertToMSColor( PropertySet
& rPropSet
, sal_Int32 nPropId
, sal_uInt32
& nOleColor
, sal_uInt32 nDefault
)
254 if (rPropSet
.getProperty( nRGB
, nPropId
))
255 nOleColor
= OleHelper::encodeOleColor( nRGB
);
257 nOleColor
= nDefault
;
259 void ControlConverter::convertPicture( PropertyMap
& rPropMap
, const StreamDataSequence
& rPicData
) const
261 if( rPicData
.hasElements() )
263 OUString aGraphicUrl
= mrGraphicHelper
.importGraphicObject( rPicData
);
264 if( !aGraphicUrl
.isEmpty() )
265 rPropMap
.setProperty( PROP_ImageURL
, aGraphicUrl
);
269 void ControlConverter::convertOrientation( PropertyMap
& rPropMap
, bool bHorizontal
)
271 sal_Int32 nScrollOrient
= bHorizontal
? ScrollBarOrientation::HORIZONTAL
: ScrollBarOrientation::VERTICAL
;
272 rPropMap
.setProperty( PROP_Orientation
, nScrollOrient
);
275 void ControlConverter::convertToMSOrientation( PropertySet
& rPropSet
, bool& bHorizontal
)
277 sal_Int32 nScrollOrient
= ScrollBarOrientation::HORIZONTAL
;
278 if ( rPropSet
.getProperty( nScrollOrient
, PROP_Orientation
) )
279 bHorizontal
= ( nScrollOrient
== ScrollBarOrientation::HORIZONTAL
);
282 void ControlConverter::convertVerticalAlign( PropertyMap
& rPropMap
, sal_Int32 nVerticalAlign
)
284 VerticalAlignment eAlign
= VerticalAlignment_TOP
;
285 switch( nVerticalAlign
)
287 case XML_Top
: eAlign
= VerticalAlignment_TOP
; break;
288 case XML_Center
: eAlign
= VerticalAlignment_MIDDLE
; break;
289 case XML_Bottom
: eAlign
= VerticalAlignment_BOTTOM
; break;
291 rPropMap
.setProperty( PROP_VerticalAlign
, eAlign
);
294 void ControlConverter::convertScrollabilitySettings( PropertyMap
& rPropMap
,
295 const AxPairData
& rScrollPos
, const AxPairData
& rScrollArea
,
296 sal_Int32 nScrollBars
) const
298 awt::Size tmpSize
= mrGraphicHelper
.convertHmmToAppFont( awt::Size( rScrollArea
.first
, rScrollArea
.second
) );
299 awt::Point tmpPos
= mrGraphicHelper
.convertHmmToAppFont( awt::Point( rScrollPos
.first
, rScrollPos
.second
) );
300 rPropMap
.setProperty( PROP_ScrollHeight
, tmpSize
.Height
);
301 rPropMap
.setProperty( PROP_ScrollWidth
, tmpSize
.Width
);
302 rPropMap
.setProperty( PROP_ScrollTop
, tmpPos
.Y
);
303 rPropMap
.setProperty( PROP_ScrollLeft
, tmpPos
.X
);
304 rPropMap
.setProperty( PROP_HScroll
, ( nScrollBars
& 0x1 ) == 0x1 );
305 rPropMap
.setProperty( PROP_VScroll
, ( nScrollBars
& 0x2 ) == 0x2 );
308 void ControlConverter::convertScrollBar( PropertyMap
& rPropMap
,
309 sal_Int32 nMin
, sal_Int32 nMax
, sal_Int32 nPosition
,
310 sal_Int32 nSmallChange
, sal_Int32 nLargeChange
, bool bAwtModel
)
312 rPropMap
.setProperty( PROP_ScrollValueMin
, ::std::min( nMin
, nMax
) );
313 rPropMap
.setProperty( PROP_ScrollValueMax
, ::std::max( nMin
, nMax
) );
314 rPropMap
.setProperty( PROP_LineIncrement
, nSmallChange
);
315 rPropMap
.setProperty( PROP_BlockIncrement
, nLargeChange
);
316 rPropMap
.setProperty( bAwtModel
? PROP_ScrollValue
: PROP_DefaultScrollValue
, nPosition
);
319 void ControlConverter::bindToSources( const Reference
< XControlModel
>& rxCtrlModel
,
320 const OUString
& rCtrlSource
, const OUString
& rRowSource
, sal_Int32 nRefSheet
) const
323 if( !rCtrlSource
.isEmpty() ) try
325 // first check if the XBindableValue interface is supported
326 Reference
< XBindableValue
> xBindable( rxCtrlModel
, UNO_QUERY_THROW
);
328 // convert address string to cell address struct
329 CellAddress aAddress
;
330 if( !lclExtractAddressFromName( aAddress
, mxDocModel
, rCtrlSource
) )
332 lclPrepareConverter( maAddressConverter
, mxDocModel
, rCtrlSource
, nRefSheet
, false );
333 if( !maAddressConverter
.getProperty( aAddress
, PROP_Address
) )
334 throw RuntimeException();
337 // create argument sequence
339 aValue
.Name
= "BoundCell";
340 aValue
.Value
<<= aAddress
;
341 Sequence
< Any
> aArgs( 1 );
342 aArgs
[ 0 ] <<= aValue
;
344 // create the CellValueBinding instance and set at the control model
345 Reference
< XMultiServiceFactory
> xModelFactory( mxDocModel
, UNO_QUERY_THROW
);
346 Reference
< XValueBinding
> xBinding( xModelFactory
->createInstanceWithArguments( "com.sun.star.table.CellValueBinding", aArgs
), UNO_QUERY_THROW
);
347 xBindable
->setValueBinding( xBinding
);
349 catch (const Exception
& e
)
351 SAL_WARN("oox", "exception: " << e
.Message
);
355 if( !rRowSource
.isEmpty() ) try
357 // first check if the XListEntrySink interface is supported
358 Reference
< XListEntrySink
> xEntrySink( rxCtrlModel
, UNO_QUERY_THROW
);
360 // convert address string to cell range address struct
361 CellRangeAddress aRangeAddr
;
362 if( !lclExtractRangeFromName( aRangeAddr
, mxDocModel
, rRowSource
) )
364 lclPrepareConverter( maRangeConverter
, mxDocModel
, rRowSource
, nRefSheet
, true );
365 if( !maRangeConverter
.getProperty( aRangeAddr
, PROP_Address
) )
366 throw RuntimeException();
369 // create argument sequence
371 aValue
.Name
= "CellRange";
372 aValue
.Value
<<= aRangeAddr
;
373 Sequence
< Any
> aArgs( 1 );
374 aArgs
[ 0 ] <<= aValue
;
376 // create the EntrySource instance and set at the control model
377 Reference
< XMultiServiceFactory
> xModelFactory( mxDocModel
, UNO_QUERY_THROW
);
378 Reference
< XListEntrySource
> xEntrySource( xModelFactory
->createInstanceWithArguments("com.sun.star.table.CellRangeListSource", aArgs
), UNO_QUERY_THROW
);
379 xEntrySink
->setListEntrySource( xEntrySource
);
381 catch (const Exception
& e
)
383 SAL_WARN("oox", "exception: " << e
.Message
);
387 // ActiveX (Forms 2.0) specific conversion ------------------------------------
389 void ControlConverter::convertAxBackground( PropertyMap
& rPropMap
,
390 sal_uInt32 nBackColor
, sal_uInt32 nFlags
, ApiTransparencyMode eTranspMode
) const
392 bool bOpaque
= getFlag( nFlags
, AX_FLAGS_OPAQUE
);
393 switch( eTranspMode
)
395 case API_TRANSPARENCY_NOTSUPPORTED
:
396 // fake transparency by using system window background if needed
397 convertColor( rPropMap
, PROP_BackgroundColor
, bOpaque
? nBackColor
: AX_SYSCOLOR_WINDOWBACK
);
399 case API_TRANSPARENCY_PAINTTRANSPARENT
:
400 rPropMap
.setProperty( PROP_PaintTransparent
, !bOpaque
);
401 // run-through intended!
402 case API_TRANSPARENCY_VOID
:
403 // keep transparency by leaving the (void) default property value
405 convertColor( rPropMap
, PROP_BackgroundColor
, nBackColor
);
410 void ControlConverter::convertAxBorder( PropertyMap
& rPropMap
,
411 sal_uInt32 nBorderColor
, sal_Int32 nBorderStyle
, sal_Int32 nSpecialEffect
) const
413 sal_Int16 nBorder
= (nBorderStyle
== AX_BORDERSTYLE_SINGLE
) ? API_BORDER_FLAT
:
414 ((nSpecialEffect
== AX_SPECIALEFFECT_FLAT
) ? API_BORDER_NONE
: API_BORDER_SUNKEN
);
415 rPropMap
.setProperty( PROP_Border
, nBorder
);
416 convertColor( rPropMap
, PROP_BorderColor
, nBorderColor
);
419 void ControlConverter::convertToAxBorder( PropertySet
& rPropSet
,
420 sal_uInt32
& nBorderColor
, sal_Int32
& nBorderStyle
, sal_Int32
& nSpecialEffect
)
422 sal_Int16 nBorder
= API_BORDER_NONE
;
423 rPropSet
.getProperty( nBorder
, PROP_Border
);
424 nBorderStyle
= AX_BORDERSTYLE_NONE
;
425 nSpecialEffect
= AX_SPECIALEFFECT_FLAT
;
428 case API_BORDER_FLAT
:
429 nBorderStyle
= AX_BORDERSTYLE_SINGLE
;
431 case API_BORDER_SUNKEN
:
432 nSpecialEffect
= AX_SPECIALEFFECT_SUNKEN
;
433 case API_BORDER_NONE
:
437 convertToMSColor( rPropSet
, PROP_BorderColor
, nBorderColor
);
440 void ControlConverter::convertAxVisualEffect( PropertyMap
& rPropMap
, sal_Int32 nSpecialEffect
)
442 sal_Int16 nVisualEffect
= (nSpecialEffect
== AX_SPECIALEFFECT_FLAT
) ? VisualEffect::FLAT
: VisualEffect::LOOK3D
;
443 rPropMap
.setProperty( PROP_VisualEffect
, nVisualEffect
);
446 void ControlConverter::convertToAxVisualEffect( PropertySet
& rPropSet
, sal_Int32
& nSpecialEffect
)
448 sal_Int16 nVisualEffect
= AX_SPECIALEFFECT_FLAT
;
449 rPropSet
.getProperty( nVisualEffect
, PROP_VisualEffect
);
450 // is this appropriate AX_SPECIALEFFECT_XXXX value ?
451 if (nVisualEffect
== VisualEffect::LOOK3D
)
452 nSpecialEffect
= AX_SPECIALEFFECT_RAISED
;
455 void ControlConverter::convertAxPicture( PropertyMap
& rPropMap
, const StreamDataSequence
& rPicData
, sal_uInt32 nPicPos
) const
458 convertPicture( rPropMap
, rPicData
);
461 sal_Int16 nImagePos
= ImagePosition::LeftCenter
;
464 case AX_PICPOS_LEFTTOP
: nImagePos
= ImagePosition::LeftTop
; break;
465 case AX_PICPOS_LEFTCENTER
: nImagePos
= ImagePosition::LeftCenter
; break;
466 case AX_PICPOS_LEFTBOTTOM
: nImagePos
= ImagePosition::LeftBottom
; break;
467 case AX_PICPOS_RIGHTTOP
: nImagePos
= ImagePosition::RightTop
; break;
468 case AX_PICPOS_RIGHTCENTER
: nImagePos
= ImagePosition::RightCenter
; break;
469 case AX_PICPOS_RIGHTBOTTOM
: nImagePos
= ImagePosition::RightBottom
; break;
470 case AX_PICPOS_ABOVELEFT
: nImagePos
= ImagePosition::AboveLeft
; break;
471 case AX_PICPOS_ABOVECENTER
: nImagePos
= ImagePosition::AboveCenter
; break;
472 case AX_PICPOS_ABOVERIGHT
: nImagePos
= ImagePosition::AboveRight
; break;
473 case AX_PICPOS_BELOWLEFT
: nImagePos
= ImagePosition::BelowLeft
; break;
474 case AX_PICPOS_BELOWCENTER
: nImagePos
= ImagePosition::BelowCenter
; break;
475 case AX_PICPOS_BELOWRIGHT
: nImagePos
= ImagePosition::BelowRight
; break;
476 case AX_PICPOS_CENTER
: nImagePos
= ImagePosition::Centered
; break;
477 default: OSL_FAIL( "ControlConverter::convertAxPicture - unknown picture position" );
479 rPropMap
.setProperty( PROP_ImagePosition
, nImagePos
);
482 void ControlConverter::convertAxPicture( PropertyMap
& rPropMap
, const StreamDataSequence
& rPicData
,
483 sal_Int32 nPicSizeMode
, sal_Int32
/*nPicAlign*/, bool /*bPicTiling*/ ) const
486 convertPicture( rPropMap
, rPicData
);
488 // picture scale mode
489 sal_Int16 nScaleMode
= ImageScaleMode::NONE
;
490 switch( nPicSizeMode
)
492 case AX_PICSIZE_CLIP
: nScaleMode
= ImageScaleMode::NONE
; break;
493 case AX_PICSIZE_STRETCH
: nScaleMode
= ImageScaleMode::ANISOTROPIC
; break;
494 case AX_PICSIZE_ZOOM
: nScaleMode
= ImageScaleMode::ISOTROPIC
; break;
495 default: OSL_FAIL( "ControlConverter::convertAxPicture - unknown picture size mode" );
497 rPropMap
.setProperty( PROP_ScaleMode
, nScaleMode
);
500 void ControlConverter::convertAxState( PropertyMap
& rPropMap
,
501 const OUString
& rValue
, sal_Int32 nMultiSelect
, ApiDefaultStateMode eDefStateMode
, bool bAwtModel
)
503 bool bBooleanState
= eDefStateMode
== API_DEFAULTSTATE_BOOLEAN
;
504 bool bSupportsTriState
= eDefStateMode
== API_DEFAULTSTATE_TRISTATE
;
507 sal_Int16 nState
= bSupportsTriState
? API_STATE_DONTKNOW
: API_STATE_UNCHECKED
;
508 if( rValue
.getLength() == 1 ) switch( rValue
[ 0 ] )
510 case '0': nState
= API_STATE_UNCHECKED
; break;
511 case '1': nState
= API_STATE_CHECKED
; break;
512 // any other string (also empty) means 'dontknow'
514 sal_Int32 nPropId
= bAwtModel
? PROP_State
: PROP_DefaultState
;
516 rPropMap
.setProperty( nPropId
, nState
!= API_STATE_UNCHECKED
);
518 rPropMap
.setProperty( nPropId
, nState
);
521 if( bSupportsTriState
)
522 rPropMap
.setProperty( PROP_TriState
, nMultiSelect
== AX_SELECTION_MULTI
);
525 void ControlConverter::convertToAxState( PropertySet
& rPropSet
,
526 OUString
& rValue
, sal_Int32
& nMultiSelect
, ApiDefaultStateMode eDefStateMode
, bool /*bAwtModel*/ )
528 bool bSupportsTriState
= eDefStateMode
== API_DEFAULTSTATE_TRISTATE
;
530 sal_Int16 nState
= API_STATE_DONTKNOW
;
533 // need to use State for current state ( I think this is regardless of whether
534 // control is awt or not )
535 rPropSet
.getProperty( nState
, PROP_State
);
537 rValue
.clear(); // empty e.g. 'don't know'
538 if ( nState
== API_STATE_UNCHECKED
)
540 else if ( nState
== API_STATE_CHECKED
)
544 if( bSupportsTriState
&& rPropSet
.getProperty( bTmp
, PROP_TriState
) )
545 nMultiSelect
= AX_SELECTION_MULTI
;
548 void ControlConverter::convertAxOrientation( PropertyMap
& rPropMap
,
549 const AxPairData
& rSize
, sal_Int32 nOrientation
)
551 bool bHorizontal
= true;
552 switch( nOrientation
)
554 case AX_ORIENTATION_AUTO
: bHorizontal
= rSize
.first
> rSize
.second
; break;
555 case AX_ORIENTATION_VERTICAL
: bHorizontal
= false; break;
556 case AX_ORIENTATION_HORIZONTAL
: bHorizontal
= true; break;
557 default: OSL_FAIL( "ControlConverter::convertAxOrientation - unknown orientation" );
559 convertOrientation( rPropMap
, bHorizontal
);
562 void ControlConverter::convertToAxOrientation( PropertySet
& rPropSet
,
563 const AxPairData
& /*rSize*/, sal_Int32
& nOrientation
)
565 bool bHorizontal
= true;
566 convertToMSOrientation( rPropSet
, bHorizontal
);
569 nOrientation
= AX_ORIENTATION_HORIZONTAL
;
571 nOrientation
= AX_ORIENTATION_VERTICAL
;
574 ControlModelBase::ControlModelBase() :
580 ControlModelBase::~ControlModelBase()
584 OUString
ControlModelBase::getServiceName() const
586 ApiControlType eCtrlType
= getControlType();
587 if( mbAwtModel
) switch( eCtrlType
)
589 case API_CONTROL_BUTTON
: return OUString( "com.sun.star.awt.UnoControlButtonModel" );
590 case API_CONTROL_FIXEDTEXT
: return OUString( "com.sun.star.awt.UnoControlFixedTextModel" );
591 case API_CONTROL_IMAGE
: return OUString( "com.sun.star.awt.UnoControlImageControlModel" );
592 case API_CONTROL_CHECKBOX
: return OUString( "com.sun.star.awt.UnoControlCheckBoxModel" );
593 case API_CONTROL_RADIOBUTTON
: return OUString( "com.sun.star.form.component.RadioButton" );
594 case API_CONTROL_EDIT
: return OUString( "com.sun.star.awt.UnoControlEditModel" );
595 case API_CONTROL_NUMERIC
: return OUString( "com.sun.star.awt.UnoControlNumericFieldModel" );
596 case API_CONTROL_LISTBOX
: return OUString( "com.sun.star.form.component.ListBox" );
597 case API_CONTROL_COMBOBOX
: return OUString( "com.sun.star.form.component.ComboBox" );
598 case API_CONTROL_SPINBUTTON
: return OUString( "com.sun.star.form.component.SpinButton" );
599 case API_CONTROL_SCROLLBAR
: return OUString( "com.sun.star.form.component.ScrollBar" );
600 case API_CONTROL_PROGRESSBAR
: return OUString( "com.sun.star.awt.UnoControlProgressBarModel" );
601 case API_CONTROL_GROUPBOX
: return OUString( "com.sun.star.form.component.GroupBox" );
602 case API_CONTROL_FRAME
: return OUString( "com.sun.star.awt.UnoFrameModel" );
603 case API_CONTROL_PAGE
: return OUString( "com.sun.star.awt.UnoPageModel" );
604 case API_CONTROL_MULTIPAGE
: return OUString( "com.sun.star.awt.UnoMultiPageModel" );
605 case API_CONTROL_DIALOG
: return OUString( "com.sun.star.awt.UnoControlDialogModel" );
606 default: OSL_FAIL( "ControlModelBase::getServiceName - no AWT model service supported" );
608 else switch( eCtrlType
)
610 case API_CONTROL_BUTTON
: return OUString( "com.sun.star.form.component.CommandButton" );
611 case API_CONTROL_FIXEDTEXT
: return OUString( "com.sun.star.form.component.FixedText" );
612 case API_CONTROL_IMAGE
: return OUString( "com.sun.star.form.component.DatabaseImageControl" );
613 case API_CONTROL_CHECKBOX
: return OUString( "com.sun.star.form.component.CheckBox" );
614 case API_CONTROL_RADIOBUTTON
: return OUString( "com.sun.star.form.component.RadioButton" );
615 case API_CONTROL_EDIT
: return OUString( "com.sun.star.form.component.TextField" );
616 case API_CONTROL_NUMERIC
: return OUString( "com.sun.star.form.component.NumericField" );
617 case API_CONTROL_LISTBOX
: return OUString( "com.sun.star.form.component.ListBox" );
618 case API_CONTROL_COMBOBOX
: return OUString( "com.sun.star.form.component.ComboBox" );
619 case API_CONTROL_SPINBUTTON
: return OUString( "com.sun.star.form.component.SpinButton" );
620 case API_CONTROL_SCROLLBAR
: return OUString( "com.sun.star.form.component.ScrollBar" );
621 case API_CONTROL_GROUPBOX
: return OUString( "com.sun.star.form.component.GroupBox" );
622 default: OSL_FAIL( "ControlModelBase::getServiceName - no form component service supported" );
627 void ControlModelBase::importProperty( sal_Int32
/*nPropId*/, const OUString
& /*rValue*/ )
631 void ControlModelBase::importPictureData( sal_Int32
/*nPropId*/, BinaryInputStream
& /*rInStrm*/ )
635 void ControlModelBase::convertProperties( PropertyMap
& /*rPropMap*/, const ControlConverter
& /*rConv*/ ) const
639 void ControlModelBase::convertFromProperties( PropertySet
& /*rPropMap*/, const ControlConverter
& /*rConv*/ )
643 void ControlModelBase::convertSize( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
645 rConv
.convertSize( rPropMap
, maSize
);
648 ComCtlModelBase::ComCtlModelBase( sal_uInt32 nDataPartId5
, sal_uInt32 nDataPartId6
,
649 sal_uInt16 nVersion
, bool bCommonPart
, bool bComplexPart
) :
650 maFontData( "Tahoma", 82500 ),
652 mnVersion( nVersion
),
653 mnDataPartId5( nDataPartId5
),
654 mnDataPartId6( nDataPartId6
),
655 mbCommonPart( bCommonPart
),
656 mbComplexPart( bComplexPart
)
660 bool ComCtlModelBase::importBinaryModel( BinaryInputStream
& rInStrm
)
662 // read initial size part and header of the control data part
663 if( importSizePart( rInStrm
) && readPartHeader( rInStrm
, getDataPartId(), mnVersion
) )
665 // if flags part exists, the first int32 of the data part contains its size
666 sal_uInt32 nCommonPartSize
= 0;
668 nCommonPartSize
= rInStrm
.readuInt32();
669 // implementations must read the exact amount of data, stream must point to its end afterwards
670 importControlData( rInStrm
);
671 // read following parts
672 if( !rInStrm
.isEof() &&
673 (!mbCommonPart
|| importCommonPart( rInStrm
, nCommonPartSize
)) &&
674 (!mbComplexPart
|| importComplexPart( rInStrm
)) )
676 return !rInStrm
.isEof();
682 void ComCtlModelBase::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
685 rPropMap
.setProperty( PROP_Enabled
, getFlag( mnFlags
, COMCTL_COMMON_ENABLED
) );
686 ControlModelBase::convertProperties( rPropMap
, rConv
);
689 sal_uInt32
ComCtlModelBase::getDataPartId() const
693 case COMCTL_VERSION_50
: return mnDataPartId5
;
694 case COMCTL_VERSION_60
: return mnDataPartId6
;
696 OSL_FAIL( "ComCtlObjectBase::getDataPartId - unxpected version" );
697 return SAL_MAX_UINT32
;
700 bool ComCtlModelBase::readPartHeader( BinaryInputStream
& rInStrm
, sal_uInt32 nExpPartId
, sal_uInt16 nExpMajor
, sal_uInt16 nExpMinor
)
702 // no idea if all this is correct...
703 sal_uInt32 nPartId
= rInStrm
.readuInt32();
704 sal_uInt16 nMinor
= rInStrm
.readuInt16();
705 sal_uInt16 nMajor
= rInStrm
.readuInt16();
706 bool bPartId
= nPartId
== nExpPartId
;
707 OSL_ENSURE( bPartId
, "ComCtlObjectBase::readPartHeader - unexpected part identifier" );
708 bool bVersion
= ((nExpMajor
== SAL_MAX_UINT16
) || (nExpMajor
== nMajor
)) && ((nExpMinor
== SAL_MAX_UINT16
) || (nExpMinor
== nMinor
));
709 OSL_ENSURE( bVersion
, "ComCtlObjectBase::readPartHeader - unexpected part version" );
710 return !rInStrm
.isEof() && bPartId
&& bVersion
;
713 bool ComCtlModelBase::importSizePart( BinaryInputStream
& rInStrm
)
715 if( readPartHeader( rInStrm
, COMCTL_ID_SIZE
, 0, 8 ) )
717 maSize
.first
= rInStrm
.readInt32();
718 maSize
.second
= rInStrm
.readInt32();
719 return !rInStrm
.isEof();
724 bool ComCtlModelBase::importCommonPart( BinaryInputStream
& rInStrm
, sal_uInt32 nPartSize
)
726 sal_Int64 nEndPos
= rInStrm
.tell() + nPartSize
;
727 if( (nPartSize
>= 16) && readPartHeader( rInStrm
, COMCTL_ID_COMMONDATA
, 5, 0 ) )
730 mnFlags
= rInStrm
.readuInt32();
731 rInStrm
.seek( nEndPos
);
732 return !rInStrm
.isEof();
737 bool ComCtlModelBase::importComplexPart( BinaryInputStream
& rInStrm
)
739 if( readPartHeader( rInStrm
, COMCTL_ID_COMPLEXDATA
, 5, 1 ) )
741 sal_uInt32 nContFlags
= rInStrm
.readuInt32();
743 (!getFlag( nContFlags
, COMCTL_COMPLEX_FONT
) || OleHelper::importStdFont( maFontData
, rInStrm
, true )) &&
744 (!getFlag( nContFlags
, COMCTL_COMPLEX_MOUSEICON
) || OleHelper::importStdPic( maMouseIcon
, rInStrm
, true ));
745 return bReadOk
&& !rInStrm
.isEof();
750 ComCtlScrollBarModel::ComCtlScrollBarModel( sal_uInt16 nVersion
) :
751 ComCtlModelBase( SAL_MAX_UINT32
, COMCTL_ID_SCROLLBAR_60
, nVersion
, true, true ),
752 mnScrollBarFlags( 0x00000011 ),
761 ApiControlType
ComCtlScrollBarModel::getControlType() const
763 return API_CONTROL_SCROLLBAR
;
766 void ComCtlScrollBarModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
768 rPropMap
.setProperty( PROP_Border
, API_BORDER_NONE
);
769 ControlConverter::convertOrientation( rPropMap
, getFlag( mnScrollBarFlags
, COMCTL_SCROLLBAR_HOR
) );
770 ControlConverter::convertScrollBar( rPropMap
, mnMin
, mnMax
, mnPosition
, mnSmallChange
, mnLargeChange
, mbAwtModel
);
771 ComCtlModelBase::convertProperties( rPropMap
, rConv
);
774 void ComCtlScrollBarModel::importControlData( BinaryInputStream
& rInStrm
)
776 mnScrollBarFlags
= rInStrm
.readuInt32();
777 mnLargeChange
= rInStrm
.readInt32();
778 mnSmallChange
= rInStrm
.readInt32();
779 mnMin
= rInStrm
.readInt32();
780 mnMax
= rInStrm
.readInt32();
781 mnPosition
= rInStrm
.readInt32();
784 ComCtlProgressBarModel::ComCtlProgressBarModel( sal_uInt16 nVersion
) :
785 ComCtlModelBase( COMCTL_ID_PROGRESSBAR_50
, COMCTL_ID_PROGRESSBAR_60
, nVersion
, true, true ),
793 ApiControlType
ComCtlProgressBarModel::getControlType() const
795 return API_CONTROL_PROGRESSBAR
;
798 void ComCtlProgressBarModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
800 sal_uInt16 nBorder
= getFlag( mnFlags
, COMCTL_COMMON_3DBORDER
) ? API_BORDER_SUNKEN
:
801 (getFlag( mnFlags
, COMCTL_COMMON_FLATBORDER
) ? API_BORDER_FLAT
: API_BORDER_NONE
);
802 rPropMap
.setProperty( PROP_Border
, nBorder
);
803 rPropMap
.setProperty( PROP_ProgressValueMin
, getLimitedValue
< sal_Int32
, double >( ::std::min( mfMin
, mfMax
), 0.0, SAL_MAX_INT32
) );
804 rPropMap
.setProperty( PROP_ProgressValueMax
, getLimitedValue
< sal_Int32
, double >( ::std::max( mfMin
, mfMax
), 0.0, SAL_MAX_INT32
) );
805 // ComCtl model does not provide current value?
806 ComCtlModelBase::convertProperties( rPropMap
, rConv
);
809 void ComCtlProgressBarModel::importControlData( BinaryInputStream
& rInStrm
)
811 mfMin
= rInStrm
.readFloat();
812 mfMax
= rInStrm
.readFloat();
813 if( mnVersion
== COMCTL_VERSION_60
)
815 mnVertical
= rInStrm
.readuInt16();
816 mnSmooth
= rInStrm
.readuInt16();
820 AxControlModelBase::AxControlModelBase()
824 void AxControlModelBase::importProperty( sal_Int32 nPropId
, const OUString
& rValue
)
828 // size of the control shape: format is "width;height"
831 sal_Int32 nSepPos
= rValue
.indexOf( ';' );
832 OSL_ENSURE( nSepPos
>= 0, "AxControlModelBase::importProperty - missing separator in 'Size' property" );
835 maSize
.first
= rValue
.copy( 0, nSepPos
).toInt32();
836 maSize
.second
= rValue
.copy( nSepPos
+ 1 ).toInt32();
843 AxFontDataModel::AxFontDataModel( bool bSupportsAlign
) :
844 mbSupportsAlign( bSupportsAlign
)
848 void AxFontDataModel::importProperty( sal_Int32 nPropId
, const OUString
& rValue
)
852 case XML_FontName
: maFontData
.maFontName
= rValue
; break;
853 case XML_FontEffects
: maFontData
.mnFontEffects
= AttributeConversion::decodeUnsigned( rValue
); break;
854 case XML_FontHeight
: maFontData
.mnFontHeight
= AttributeConversion::decodeInteger( rValue
); break;
855 case XML_FontCharSet
: maFontData
.mnFontCharSet
= AttributeConversion::decodeInteger( rValue
); break;
856 case XML_ParagraphAlign
: maFontData
.mnHorAlign
= AttributeConversion::decodeInteger( rValue
); break;
857 default: AxControlModelBase::importProperty( nPropId
, rValue
);
861 bool AxFontDataModel::importBinaryModel( BinaryInputStream
& rInStrm
)
863 return maFontData
.importBinaryModel( rInStrm
);
866 void AxFontDataModel::exportBinaryModel( BinaryOutputStream
& rOutStrm
)
868 maFontData
.exportBinaryModel( rOutStrm
);
870 void AxFontDataModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
873 if( !maFontData
.maFontName
.isEmpty() )
874 rPropMap
.setProperty( PROP_FontName
, maFontData
.maFontName
);
877 rPropMap
.setProperty( PROP_FontWeight
, getFlagValue( maFontData
.mnFontEffects
, AX_FONTDATA_BOLD
, awt::FontWeight::BOLD
, awt::FontWeight::NORMAL
) );
878 rPropMap
.setProperty( PROP_FontSlant
, getFlagValue
< sal_Int16
>( maFontData
.mnFontEffects
, AX_FONTDATA_ITALIC
, FontSlant_ITALIC
, FontSlant_NONE
) );
879 rPropMap
.setProperty( PROP_FontUnderline
, getFlagValue( maFontData
.mnFontEffects
, AX_FONTDATA_UNDERLINE
, maFontData
.mbDblUnderline
? awt::FontUnderline::DOUBLE
: awt::FontUnderline::SINGLE
, awt::FontUnderline::NONE
) );
880 rPropMap
.setProperty( PROP_FontStrikeout
, getFlagValue( maFontData
.mnFontEffects
, AX_FONTDATA_STRIKEOUT
, awt::FontStrikeout::SINGLE
, awt::FontStrikeout::NONE
) );
881 rPropMap
.setProperty( PROP_FontHeight
, maFontData
.getHeightPoints() );
883 // font character set
884 rtl_TextEncoding eFontEnc
= RTL_TEXTENCODING_DONTKNOW
;
885 if( (0 <= maFontData
.mnFontCharSet
) && (maFontData
.mnFontCharSet
<= SAL_MAX_UINT8
) )
886 eFontEnc
= rtl_getTextEncodingFromWindowsCharset( static_cast< sal_uInt8
>( maFontData
.mnFontCharSet
) );
887 if( eFontEnc
!= RTL_TEXTENCODING_DONTKNOW
)
888 rPropMap
.setProperty( PROP_FontCharset
, static_cast< sal_Int16
>( eFontEnc
) );
891 if( mbSupportsAlign
)
893 sal_Int32 nAlign
= awt::TextAlign::LEFT
;
894 switch( maFontData
.mnHorAlign
)
896 case AX_FONTDATA_LEFT
: nAlign
= awt::TextAlign::LEFT
; break;
897 case AX_FONTDATA_RIGHT
: nAlign
= awt::TextAlign::RIGHT
; break;
898 case AX_FONTDATA_CENTER
: nAlign
= awt::TextAlign::CENTER
; break;
899 default: OSL_FAIL( "AxFontDataModel::convertProperties - unknown text alignment" );
901 // form controls expect short value
902 rPropMap
.setProperty( PROP_Align
, static_cast< sal_Int16
>( nAlign
) );
905 // process base class properties
906 AxControlModelBase::convertProperties( rPropMap
, rConv
);
909 void AxFontDataModel::convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& /*rConv */)
911 rPropSet
.getProperty( maFontData
.maFontName
, PROP_FontName
);
912 float fontWeight
= (float)0;
913 if ( rPropSet
.getProperty(fontWeight
, PROP_FontWeight
) )
914 setFlag( maFontData
.mnFontEffects
, AX_FONTDATA_BOLD
, ( fontWeight
== awt::FontWeight::BOLD
) );
915 sal_Int16 nSlant
= FontSlant_NONE
;
916 if ( rPropSet
.getProperty( nSlant
, PROP_FontSlant
) )
917 setFlag( maFontData
.mnFontEffects
, AX_FONTDATA_ITALIC
, ( nSlant
== FontSlant_ITALIC
) );
919 sal_Int16 nUnderLine
= awt::FontUnderline::NONE
;
920 if ( rPropSet
.getProperty( nUnderLine
, PROP_FontUnderline
) )
921 setFlag( maFontData
.mnFontEffects
, AX_FONTDATA_UNDERLINE
, nUnderLine
!= awt::FontUnderline::NONE
);
922 sal_Int16 nStrikeout
= awt::FontStrikeout::NONE
;
923 if ( rPropSet
.getProperty( nStrikeout
, PROP_FontStrikeout
) )
924 setFlag( maFontData
.mnFontEffects
, AX_FONTDATA_STRIKEOUT
, nStrikeout
!= awt::FontStrikeout::NONE
);
926 float fontHeight
= 0.0;
927 if ( rPropSet
.getProperty( fontHeight
, PROP_FontHeight
) )
928 maFontData
.setHeightPoints( static_cast< sal_Int16
>( fontHeight
) );
930 // TODO - handle textencoding
931 sal_Int16 nAlign
= 0;
932 if ( rPropSet
.getProperty( nAlign
, PROP_Align
) )
936 case awt::TextAlign::LEFT
: maFontData
.mnHorAlign
= AX_FONTDATA_LEFT
; break;
937 case awt::TextAlign::RIGHT
: maFontData
.mnHorAlign
= AX_FONTDATA_RIGHT
; break;
938 case awt::TextAlign::CENTER
: maFontData
.mnHorAlign
= AX_FONTDATA_CENTER
; break;
939 default: OSL_FAIL( "AxFontDataModel::convertFromProperties - unknown text alignment" );
944 AxCommandButtonModel::AxCommandButtonModel() :
945 mnTextColor( AX_SYSCOLOR_BUTTONTEXT
),
946 mnBackColor( AX_SYSCOLOR_BUTTONFACE
),
947 mnFlags( AX_CMDBUTTON_DEFFLAGS
),
948 mnPicturePos( AX_PICPOS_ABOVECENTER
),
949 mnVerticalAlign( XML_Center
),
950 mbFocusOnClick( true )
954 void AxCommandButtonModel::importProperty( sal_Int32 nPropId
, const OUString
& rValue
)
958 case XML_Caption
: maCaption
= rValue
; break;
959 case XML_ForeColor
: mnTextColor
= AttributeConversion::decodeUnsigned( rValue
); break;
960 case XML_BackColor
: mnBackColor
= AttributeConversion::decodeUnsigned( rValue
); break;
961 case XML_VariousPropertyBits
: mnFlags
= AttributeConversion::decodeUnsigned( rValue
); break;
962 case XML_PicturePosition
: mnPicturePos
= AttributeConversion::decodeUnsigned( rValue
); break;
963 case XML_TakeFocusOnClick
: mbFocusOnClick
= AttributeConversion::decodeInteger( rValue
) != 0; break;
964 default: AxFontDataModel::importProperty( nPropId
, rValue
);
968 void AxCommandButtonModel::importPictureData( sal_Int32 nPropId
, BinaryInputStream
& rInStrm
)
972 case XML_Picture
: OleHelper::importStdPic( maPictureData
, rInStrm
, true ); break;
973 default: AxFontDataModel::importPictureData( nPropId
, rInStrm
);
977 bool AxCommandButtonModel::importBinaryModel( BinaryInputStream
& rInStrm
)
979 AxBinaryPropertyReader
aReader( rInStrm
);
980 aReader
.readIntProperty
< sal_uInt32
>( mnTextColor
);
981 aReader
.readIntProperty
< sal_uInt32
>( mnBackColor
);
982 aReader
.readIntProperty
< sal_uInt32
>( mnFlags
);
983 aReader
.readStringProperty( maCaption
);
984 aReader
.readIntProperty
< sal_uInt32
>( mnPicturePos
);
985 aReader
.readPairProperty( maSize
);
986 aReader
.skipIntProperty
< sal_uInt8
>(); // mouse pointer
987 aReader
.readPictureProperty( maPictureData
);
988 aReader
.skipIntProperty
< sal_uInt16
>(); // accelerator
989 aReader
.readBoolProperty( mbFocusOnClick
, true ); // binary flag means "do not take focus"
990 aReader
.skipPictureProperty(); // mouse icon
991 return aReader
.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm
);
994 void AxCommandButtonModel::exportBinaryModel( BinaryOutputStream
& rOutStrm
)
996 AxBinaryPropertyWriter
aWriter( rOutStrm
);
997 aWriter
.writeIntProperty
< sal_uInt32
>( mnTextColor
);
999 aWriter
.writeIntProperty
< sal_uInt32
>( mnBackColor
);
1001 aWriter
.skipProperty(); // default backcolour
1002 aWriter
.writeIntProperty
< sal_uInt32
>( mnFlags
);
1003 aWriter
.writeStringProperty( maCaption
);
1004 aWriter
.skipProperty(); // pict pos
1005 aWriter
.writePairProperty( maSize
);
1006 aWriter
.skipProperty(); // mouse pointer
1007 aWriter
.skipProperty(); // picture data
1008 aWriter
.skipProperty(); // accelerator
1009 aWriter
.writeBoolProperty( mbFocusOnClick
); // binary flag means "do not take focus"
1010 aWriter
.skipProperty(); // mouse icon
1011 aWriter
.finalizeExport();
1012 AxFontDataModel::exportBinaryModel( rOutStrm
);
1015 void AxCommandButtonModel::exportCompObj( BinaryOutputStream
& rOutStream
)
1017 // should be able to replace this hardcoded foo with
1018 // proper export info from MS-OLEDS spec.
1019 static sal_uInt8
const aCompObj
[] = {
1020 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1021 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x32, 0x05, 0xD7,
1022 0x69, 0xCE, 0xCD, 0x11, 0xA7, 0x77, 0x00, 0xDD,
1023 0x01, 0x14, 0x3C, 0x57, 0x22, 0x00, 0x00, 0x00,
1024 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1025 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6d, 0x73, 0x20,
1026 0x32, 0x2e, 0x30, 0x20, 0x43, 0x6F, 0x6D, 0x6D,
1027 0x61, 0x6E, 0x64, 0x42, 0x75, 0x74, 0x74, 0x6F,
1028 0x6E, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
1029 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
1030 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x16, 0x00,
1031 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
1032 0x43, 0x6F, 0x6D, 0x6D, 0x61, 0x6E, 0x64, 0x42,
1033 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00,
1034 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
1035 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1037 rOutStream
.writeMemory( aCompObj
, sizeof( aCompObj
) );
1040 ApiControlType
AxCommandButtonModel::getControlType() const
1042 return API_CONTROL_BUTTON
;
1045 void AxCommandButtonModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
1047 rPropMap
.setProperty( PROP_Label
, maCaption
);
1048 rPropMap
.setProperty( PROP_Enabled
, getFlag( mnFlags
, AX_FLAGS_ENABLED
) );
1049 rPropMap
.setProperty( PROP_MultiLine
, getFlag( mnFlags
, AX_FLAGS_WORDWRAP
) );
1050 rPropMap
.setProperty( PROP_FocusOnClick
, mbFocusOnClick
);
1051 rConv
.convertColor( rPropMap
, PROP_TextColor
, mnTextColor
);
1052 ControlConverter::convertVerticalAlign( rPropMap
, mnVerticalAlign
);
1053 rConv
.convertAxBackground( rPropMap
, mnBackColor
, mnFlags
, API_TRANSPARENCY_NOTSUPPORTED
);
1054 rConv
.convertAxPicture( rPropMap
, maPictureData
, mnPicturePos
);
1055 AxFontDataModel::convertProperties( rPropMap
, rConv
);
1058 void AxCommandButtonModel::convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
)
1060 (void)rPropSet
.getProperty(maCaption
, PROP_Label
);
1062 if ( rPropSet
.getProperty( bRes
, PROP_Enabled
) )
1063 setFlag( mnFlags
, AX_FLAGS_ENABLED
, bRes
);
1064 if ( rPropSet
.getProperty( bRes
, PROP_MultiLine
) )
1065 setFlag( mnFlags
, AX_FLAGS_WORDWRAP
, bRes
);
1066 (void)rPropSet
.getProperty(mbFocusOnClick
, PROP_FocusOnClick
);
1068 ControlConverter::convertToMSColor( rPropSet
, PROP_TextColor
, mnTextColor
);
1069 ControlConverter::convertToMSColor( rPropSet
, PROP_BackgroundColor
, mnBackColor
);
1071 AxFontDataModel::convertFromProperties( rPropSet
, rConv
);
1074 AxLabelModel::AxLabelModel() :
1075 mnTextColor( AX_SYSCOLOR_BUTTONTEXT
),
1076 mnBackColor( AX_SYSCOLOR_BUTTONFACE
),
1077 mnFlags( AX_LABEL_DEFFLAGS
),
1078 mnBorderColor( AX_SYSCOLOR_WINDOWFRAME
),
1079 mnBorderStyle( AX_BORDERSTYLE_NONE
),
1080 mnSpecialEffect( AX_SPECIALEFFECT_FLAT
),
1081 mnVerticalAlign( XML_Top
)
1085 void AxLabelModel::importProperty( sal_Int32 nPropId
, const OUString
& rValue
)
1089 case XML_Caption
: maCaption
= rValue
; break;
1090 case XML_ForeColor
: mnTextColor
= AttributeConversion::decodeUnsigned( rValue
); break;
1091 case XML_BackColor
: mnBackColor
= AttributeConversion::decodeUnsigned( rValue
); break;
1092 case XML_VariousPropertyBits
: mnFlags
= AttributeConversion::decodeUnsigned( rValue
); break;
1093 case XML_BorderColor
: mnBorderColor
= AttributeConversion::decodeUnsigned( rValue
); break;
1094 case XML_BorderStyle
: mnBorderStyle
= AttributeConversion::decodeInteger( rValue
); break;
1095 case XML_SpecialEffect
: mnSpecialEffect
= AttributeConversion::decodeInteger( rValue
); break;
1096 default: AxFontDataModel::importProperty( nPropId
, rValue
);
1100 bool AxLabelModel::importBinaryModel( BinaryInputStream
& rInStrm
)
1102 AxBinaryPropertyReader
aReader( rInStrm
);
1103 aReader
.readIntProperty
< sal_uInt32
>( mnTextColor
);
1104 aReader
.readIntProperty
< sal_uInt32
>( mnBackColor
);
1105 aReader
.readIntProperty
< sal_uInt32
>( mnFlags
);
1106 aReader
.readStringProperty( maCaption
);
1107 aReader
.skipIntProperty
< sal_uInt32
>(); // picture position
1108 aReader
.readPairProperty( maSize
);
1109 aReader
.skipIntProperty
< sal_uInt8
>(); // mouse pointer
1110 aReader
.readIntProperty
< sal_uInt32
>( mnBorderColor
);
1111 aReader
.readIntProperty
< sal_uInt16
>( mnBorderStyle
);
1112 aReader
.readIntProperty
< sal_uInt16
>( mnSpecialEffect
);
1113 aReader
.skipPictureProperty(); // picture
1114 aReader
.skipIntProperty
< sal_uInt16
>(); // accelerator
1115 aReader
.skipPictureProperty(); // mouse icon
1116 return aReader
.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm
);
1119 void AxLabelModel::exportBinaryModel( BinaryOutputStream
& rOutStrm
)
1121 AxBinaryPropertyWriter
aWriter( rOutStrm
);
1122 aWriter
.writeIntProperty
< sal_uInt32
>( mnTextColor
);
1124 aWriter
.writeIntProperty
< sal_uInt32
>( mnBackColor
);
1126 // if mnBackColor == 0 then it's the libreoffice default backcolour is
1127 // the MSO Label default which is AX_SYSCOLOR_BUTTONFACE
1128 aWriter
.writeIntProperty
< sal_uInt32
>( AX_SYSCOLOR_WINDOWBACK
);
1129 aWriter
.writeIntProperty
< sal_uInt32
>( mnFlags
);
1130 aWriter
.writeStringProperty( maCaption
);
1131 aWriter
.skipProperty(); // picture position
1132 aWriter
.writePairProperty( maSize
);
1133 aWriter
.skipProperty(); // mouse pointer
1134 aWriter
.writeIntProperty
< sal_uInt32
>( mnBorderColor
);
1135 aWriter
.writeIntProperty
< sal_uInt16
>( mnBorderStyle
);
1136 aWriter
.writeIntProperty
< sal_uInt16
>( mnSpecialEffect
);
1137 aWriter
.skipProperty(); // picture
1138 aWriter
.skipProperty(); // accelerator
1139 aWriter
.skipProperty(); // mouse icon
1140 aWriter
.finalizeExport();
1141 AxFontDataModel::exportBinaryModel( rOutStrm
);
1144 void AxLabelModel::convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
)
1146 rPropSet
.getProperty( maCaption
, PROP_Label
);
1148 if ( rPropSet
.getProperty( bRes
, PROP_Enabled
) )
1149 setFlag( mnFlags
, AX_FLAGS_ENABLED
, bRes
);
1150 if ( rPropSet
.getProperty( bRes
, PROP_MultiLine
) )
1151 setFlag( mnFlags
, AX_FLAGS_WORDWRAP
, bRes
);
1153 ControlConverter::convertToMSColor( rPropSet
, PROP_TextColor
, mnTextColor
);
1154 // VerticleAlign doesn't seem to be read from binary
1156 // not sure about background color, how do we decide when to set
1157 // AX_FLAGS_OPAQUE ?
1158 ControlConverter::convertToMSColor( rPropSet
, PROP_BackgroundColor
, mnBackColor
);
1159 ControlConverter::convertToAxBorder( rPropSet
, mnBorderColor
, mnBorderStyle
, mnSpecialEffect
);
1161 AxFontDataModel::convertFromProperties( rPropSet
, rConv
);
1164 void AxLabelModel::exportCompObj( BinaryOutputStream
& rOutStream
)
1166 // should be able to replace this hardcoded foo with
1167 // proper export info from MS-OLEDS spec.
1168 static sal_uInt8
const aCompObj
[] = {
1169 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1170 0xFF, 0xFF, 0xFF, 0xFF, 0x23, 0x9E, 0x8C, 0x97,
1171 0xB0, 0xD4, 0xCE, 0x11, 0xBF, 0x2D, 0x00, 0xAA,
1172 0x00, 0x3F, 0x40, 0xD0, 0x1A, 0x00, 0x00, 0x00,
1173 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1174 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1175 0x32, 0x2E, 0x30, 0x20, 0x4C, 0x61, 0x62, 0x65,
1176 0x6C, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
1177 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
1178 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x0E, 0x00,
1179 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
1180 0x4C, 0x61, 0x62, 0x65, 0x6C, 0x2E, 0x31, 0x00,
1181 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
1182 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1184 rOutStream
.writeMemory( aCompObj
, sizeof( aCompObj
) );
1187 ApiControlType
AxLabelModel::getControlType() const
1189 return API_CONTROL_FIXEDTEXT
;
1192 void AxLabelModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
1194 rPropMap
.setProperty( PROP_Label
, maCaption
);
1195 rPropMap
.setProperty( PROP_Enabled
, getFlag( mnFlags
, AX_FLAGS_ENABLED
) );
1196 rPropMap
.setProperty( PROP_MultiLine
, getFlag( mnFlags
, AX_FLAGS_WORDWRAP
) );
1197 rConv
.convertColor( rPropMap
, PROP_TextColor
, mnTextColor
);
1198 ControlConverter::convertVerticalAlign( rPropMap
, mnVerticalAlign
);
1199 rConv
.convertAxBackground( rPropMap
, mnBackColor
, mnFlags
, API_TRANSPARENCY_VOID
);
1200 rConv
.convertAxBorder( rPropMap
, mnBorderColor
, mnBorderStyle
, mnSpecialEffect
);
1201 AxFontDataModel::convertProperties( rPropMap
, rConv
);
1204 AxImageModel::AxImageModel() :
1205 mnBackColor( AX_SYSCOLOR_BUTTONFACE
),
1206 mnFlags( AX_IMAGE_DEFFLAGS
),
1207 mnBorderColor( AX_SYSCOLOR_WINDOWFRAME
),
1208 mnBorderStyle( AX_BORDERSTYLE_SINGLE
),
1209 mnSpecialEffect( AX_SPECIALEFFECT_FLAT
),
1210 mnPicSizeMode( AX_PICSIZE_CLIP
),
1211 mnPicAlign( AX_PICALIGN_CENTER
),
1212 mbPicTiling( false )
1216 void AxImageModel::importProperty( sal_Int32 nPropId
, const OUString
& rValue
)
1220 case XML_BackColor
: mnBackColor
= AttributeConversion::decodeUnsigned( rValue
); break;
1221 case XML_VariousPropertyBits
: mnFlags
= AttributeConversion::decodeUnsigned( rValue
); break;
1222 case XML_BorderColor
: mnBorderColor
= AttributeConversion::decodeUnsigned( rValue
); break;
1223 case XML_BorderStyle
: mnBorderStyle
= AttributeConversion::decodeInteger( rValue
); break;
1224 case XML_SpecialEffect
: mnSpecialEffect
= AttributeConversion::decodeInteger( rValue
); break;
1225 case XML_SizeMode
: mnPicSizeMode
= AttributeConversion::decodeInteger( rValue
); break;
1226 case XML_PictureAlignment
: mnPicAlign
= AttributeConversion::decodeInteger( rValue
); break;
1227 case XML_PictureTiling
: mbPicTiling
= AttributeConversion::decodeInteger( rValue
) != 0; break;
1228 default: AxControlModelBase::importProperty( nPropId
, rValue
);
1232 void AxImageModel::importPictureData( sal_Int32 nPropId
, BinaryInputStream
& rInStrm
)
1236 case XML_Picture
: OleHelper::importStdPic( maPictureData
, rInStrm
, true ); break;
1237 default: AxControlModelBase::importPictureData( nPropId
, rInStrm
);
1241 bool AxImageModel::importBinaryModel( BinaryInputStream
& rInStrm
)
1243 AxBinaryPropertyReader
aReader( rInStrm
);
1244 aReader
.skipUndefinedProperty();
1245 aReader
.skipUndefinedProperty();
1246 aReader
.skipBoolProperty(); // auto-size
1247 aReader
.readIntProperty
< sal_uInt32
>( mnBorderColor
);
1248 aReader
.readIntProperty
< sal_uInt32
>( mnBackColor
);
1249 aReader
.readIntProperty
< sal_uInt8
>( mnBorderStyle
);
1250 aReader
.skipIntProperty
< sal_uInt8
>(); // mouse pointer
1251 aReader
.readIntProperty
< sal_uInt8
>( mnPicSizeMode
);
1252 aReader
.readIntProperty
< sal_uInt8
>( mnSpecialEffect
);
1253 aReader
.readPairProperty( maSize
);
1254 aReader
.readPictureProperty( maPictureData
);
1255 aReader
.readIntProperty
< sal_uInt8
>( mnPicAlign
);
1256 aReader
.readBoolProperty( mbPicTiling
);
1257 aReader
.readIntProperty
< sal_uInt32
>( mnFlags
);
1258 aReader
.skipPictureProperty(); // mouse icon
1259 return aReader
.finalizeImport();
1262 void AxImageModel::exportBinaryModel( BinaryOutputStream
& rOutStrm
)
1264 AxBinaryPropertyWriter
aWriter( rOutStrm
);
1265 aWriter
.skipProperty(); //undefined
1266 aWriter
.skipProperty(); //undefined
1267 aWriter
.skipProperty(); //auto-size
1268 aWriter
.writeIntProperty
< sal_uInt32
>( mnBorderColor
);
1270 aWriter
.writeIntProperty
< sal_uInt32
>( mnBackColor
);
1272 aWriter
.skipProperty(); // default backcolour
1273 aWriter
.writeIntProperty
< sal_uInt8
>( mnBorderStyle
);
1274 aWriter
.skipProperty(); // mouse pointer
1275 aWriter
.writeIntProperty
< sal_uInt8
>( mnPicSizeMode
);
1276 aWriter
.writeIntProperty
< sal_uInt8
>( mnSpecialEffect
);
1277 aWriter
.writePairProperty( maSize
);
1278 aWriter
.skipProperty(); //maPictureData );
1279 aWriter
.writeIntProperty
< sal_uInt8
>( mnPicAlign
);
1280 aWriter
.writeBoolProperty( mbPicTiling
);
1281 aWriter
.writeIntProperty
< sal_uInt32
>( mnFlags
);
1282 aWriter
.skipProperty(); // mouse icon
1283 aWriter
.finalizeExport();
1286 void AxImageModel::exportCompObj( BinaryOutputStream
& rOutStream
)
1288 // should be able to replace this hardcoded foo with
1289 // proper export info from MS-OLEDS spec.
1290 static sal_uInt8
const aCompObj
[] = {
1291 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1292 0xFF, 0xFF, 0xFF, 0xFF, 0x41, 0x92, 0x59, 0x4C,
1293 0x26, 0x69, 0x1B, 0x10, 0x99, 0x92, 0x00, 0x00,
1294 0x0B, 0x65, 0xC6, 0xF9, 0x1A, 0x00, 0x00, 0x00,
1295 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1296 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1297 0x32, 0x2E, 0x30, 0x20, 0x49, 0x6D, 0x61, 0x67,
1298 0x65, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
1299 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
1300 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x0E, 0x00,
1301 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
1302 0x49, 0x6D, 0x61, 0x67, 0x65, 0x2E, 0x31, 0x00,
1303 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
1304 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1306 rOutStream
.writeMemory( aCompObj
, sizeof( aCompObj
) );
1309 ApiControlType
AxImageModel::getControlType() const
1311 return API_CONTROL_IMAGE
;
1314 void AxImageModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
1316 rPropMap
.setProperty( PROP_Enabled
, getFlag( mnFlags
, AX_FLAGS_ENABLED
) );
1317 rConv
.convertAxBackground( rPropMap
, mnBackColor
, mnFlags
, API_TRANSPARENCY_VOID
);
1318 rConv
.convertAxBorder( rPropMap
, mnBorderColor
, mnBorderStyle
, mnSpecialEffect
);
1319 rConv
.convertAxPicture( rPropMap
, maPictureData
, mnPicSizeMode
, mnPicAlign
, mbPicTiling
);
1320 AxControlModelBase::convertProperties( rPropMap
, rConv
);
1323 AxTabStripModel::AxTabStripModel() :
1327 mnVariousPropertyBits( 0 )
1331 bool AxTabStripModel::importBinaryModel( BinaryInputStream
& rInStrm
)
1333 // not worth reading much here, basically we are interested
1334 // in whether we have tabs, the width, the height and the
1335 // captions, everything else we can pretty much discard ( for now )
1336 AxBinaryPropertyReader
aReader( rInStrm
);
1337 aReader
.readIntProperty
< sal_uInt32
>( mnListIndex
); // ListIndex
1338 aReader
.skipIntProperty
< sal_uInt32
>(); // Backcolor
1339 aReader
.skipIntProperty
< sal_uInt32
>(); // ForeColor
1340 aReader
.skipUndefinedProperty();
1341 aReader
.readPairProperty( maSize
);
1342 aReader
.readArrayStringProperty( maItems
);
1343 aReader
.skipIntProperty
< sal_uInt8
>(); // MousePointer
1344 aReader
.skipUndefinedProperty();
1345 aReader
.skipIntProperty
< sal_uInt32
>(); // TabOrientation
1346 aReader
.readIntProperty
< sal_uInt32
>(mnTabStyle
); // TabStyle
1347 aReader
.skipBoolProperty(); // MultiRow
1348 aReader
.skipIntProperty
< sal_uInt32
>(); // TabFixedWidth
1349 aReader
.skipIntProperty
< sal_uInt32
>(); // TabFixedHeight
1350 aReader
.skipBoolProperty(); // ToolTips
1351 aReader
.skipUndefinedProperty();
1352 aReader
.skipArrayStringProperty(); // ToolTip strings
1353 aReader
.skipUndefinedProperty();
1354 aReader
.readArrayStringProperty( maTabNames
); // Tab names
1355 aReader
.readIntProperty
< sal_uInt32
>(mnVariousPropertyBits
); // VariousPropertyBits
1356 aReader
.skipBoolProperty();// NewVersion
1357 aReader
.skipIntProperty
< sal_uInt32
>(); // TabsAllocated
1358 aReader
.skipArrayStringProperty(); // Tags
1359 aReader
.readIntProperty
<sal_uInt32
>(mnTabData
); // TabData
1360 aReader
.skipArrayStringProperty(); // Accelerators
1361 aReader
.skipPictureProperty(); // Mouse Icon
1362 return aReader
.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm
);
1365 ApiControlType
AxTabStripModel::getControlType() const
1367 return API_CONTROL_TABSTRIP
;
1370 AxMorphDataModelBase::AxMorphDataModelBase() :
1371 mnTextColor( AX_SYSCOLOR_WINDOWTEXT
),
1372 mnBackColor( AX_SYSCOLOR_WINDOWBACK
),
1373 mnFlags( AX_MORPHDATA_DEFFLAGS
),
1374 mnPicturePos( AX_PICPOS_ABOVECENTER
),
1375 mnBorderColor( AX_SYSCOLOR_WINDOWFRAME
),
1376 mnBorderStyle( AX_BORDERSTYLE_NONE
),
1377 mnSpecialEffect( AX_SPECIALEFFECT_SUNKEN
),
1378 mnDisplayStyle( AX_DISPLAYSTYLE_TEXT
),
1379 mnMultiSelect( AX_SELECTION_SINGLE
),
1380 mnScrollBars( AX_SCROLLBAR_NONE
),
1381 mnMatchEntry( AX_MATCHENTRY_NONE
),
1382 mnShowDropButton( AX_SHOWDROPBUTTON_NEVER
),
1384 mnPasswordChar( 0 ),
1386 mnVerticalAlign( XML_Center
)
1390 void AxMorphDataModelBase::importProperty( sal_Int32 nPropId
, const OUString
& rValue
)
1394 case XML_Caption
: maCaption
= rValue
; break;
1395 case XML_Value
: maValue
= rValue
; break;
1396 case XML_GroupName
: maGroupName
= rValue
; break;
1397 case XML_ForeColor
: mnTextColor
= AttributeConversion::decodeUnsigned( rValue
); break;
1398 case XML_BackColor
: mnBackColor
= AttributeConversion::decodeUnsigned( rValue
); break;
1399 case XML_VariousPropertyBits
: mnFlags
= AttributeConversion::decodeUnsigned( rValue
); break;
1400 case XML_PicturePosition
: mnPicturePos
= AttributeConversion::decodeUnsigned( rValue
); break;
1401 case XML_BorderColor
: mnBorderColor
= AttributeConversion::decodeUnsigned( rValue
); break;
1402 case XML_BorderStyle
: mnBorderStyle
= AttributeConversion::decodeInteger( rValue
); break;
1403 case XML_SpecialEffect
: mnSpecialEffect
= AttributeConversion::decodeInteger( rValue
); break;
1404 case XML_DisplayStyle
: mnDisplayStyle
= AttributeConversion::decodeInteger( rValue
); break;
1405 case XML_MultiSelect
: mnMultiSelect
= AttributeConversion::decodeInteger( rValue
); break;
1406 case XML_ScrollBars
: mnScrollBars
= AttributeConversion::decodeInteger( rValue
); break;
1407 case XML_MatchEntry
: mnMatchEntry
= AttributeConversion::decodeInteger( rValue
); break;
1408 case XML_ShowDropButtonWhen
: mnShowDropButton
= AttributeConversion::decodeInteger( rValue
);break;
1409 case XML_MaxLength
: mnMaxLength
= AttributeConversion::decodeInteger( rValue
); break;
1410 case XML_PasswordChar
: mnPasswordChar
= AttributeConversion::decodeInteger( rValue
); break;
1411 case XML_ListRows
: mnListRows
= AttributeConversion::decodeInteger( rValue
); break;
1412 default: AxFontDataModel::importProperty( nPropId
, rValue
);
1416 void AxMorphDataModelBase::importPictureData( sal_Int32 nPropId
, BinaryInputStream
& rInStrm
)
1420 case XML_Picture
: OleHelper::importStdPic( maPictureData
, rInStrm
, true ); break;
1421 default: AxFontDataModel::importPictureData( nPropId
, rInStrm
);
1425 bool AxMorphDataModelBase::importBinaryModel( BinaryInputStream
& rInStrm
)
1427 AxBinaryPropertyReader
aReader( rInStrm
, true );
1428 aReader
.readIntProperty
< sal_uInt32
>( mnFlags
);
1429 aReader
.readIntProperty
< sal_uInt32
>( mnBackColor
);
1430 aReader
.readIntProperty
< sal_uInt32
>( mnTextColor
);
1431 aReader
.readIntProperty
< sal_Int32
>( mnMaxLength
);
1432 aReader
.readIntProperty
< sal_uInt8
>( mnBorderStyle
);
1433 aReader
.readIntProperty
< sal_uInt8
>( mnScrollBars
);
1434 aReader
.readIntProperty
< sal_uInt8
>( mnDisplayStyle
);
1435 aReader
.skipIntProperty
< sal_uInt8
>(); // mouse pointer
1436 aReader
.readPairProperty( maSize
);
1437 aReader
.readIntProperty
< sal_uInt16
>( mnPasswordChar
);
1438 aReader
.skipIntProperty
< sal_uInt32
>(); // list width
1439 aReader
.skipIntProperty
< sal_uInt16
>(); // bound column
1440 aReader
.skipIntProperty
< sal_Int16
>(); // text column
1441 aReader
.skipIntProperty
< sal_Int16
>(); // column count
1442 aReader
.readIntProperty
< sal_uInt16
>( mnListRows
);
1443 aReader
.skipIntProperty
< sal_uInt16
>(); // column info count
1444 aReader
.readIntProperty
< sal_uInt8
>( mnMatchEntry
);
1445 aReader
.skipIntProperty
< sal_uInt8
>(); // list style
1446 aReader
.readIntProperty
< sal_uInt8
>( mnShowDropButton
);
1447 aReader
.skipUndefinedProperty();
1448 aReader
.skipIntProperty
< sal_uInt8
>(); // drop down style
1449 aReader
.readIntProperty
< sal_uInt8
>( mnMultiSelect
);
1450 aReader
.readStringProperty( maValue
);
1451 aReader
.readStringProperty( maCaption
);
1452 aReader
.readIntProperty
< sal_uInt32
>( mnPicturePos
);
1453 aReader
.readIntProperty
< sal_uInt32
>( mnBorderColor
);
1454 aReader
.readIntProperty
< sal_uInt32
>( mnSpecialEffect
);
1455 aReader
.skipPictureProperty(); // mouse icon
1456 aReader
.readPictureProperty( maPictureData
);
1457 aReader
.skipIntProperty
< sal_uInt16
>(); // accelerator
1458 aReader
.skipUndefinedProperty();
1459 aReader
.skipBoolProperty();
1460 aReader
.readStringProperty( maGroupName
);
1461 return aReader
.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm
);
1464 void AxMorphDataModelBase::exportBinaryModel( BinaryOutputStream
& rOutStrm
)
1466 AxBinaryPropertyWriter
aWriter( rOutStrm
, true );
1467 if ( mnFlags
!= AX_MORPHDATA_DEFFLAGS
)
1468 aWriter
.writeIntProperty
< sal_uInt32
>( mnFlags
);
1470 aWriter
.skipProperty(); //mnFlags
1472 aWriter
.writeIntProperty
< sal_uInt32
>( mnBackColor
);
1474 aWriter
.skipProperty(); // default backcolour
1475 aWriter
.writeIntProperty
< sal_uInt32
>( mnTextColor
);
1477 // only write if different from default
1478 if ( ( ( mnDisplayStyle
== AX_DISPLAYSTYLE_TEXT
) || ( mnDisplayStyle
== AX_DISPLAYSTYLE_COMBOBOX
) ) && mnMaxLength
!= 0 )
1479 aWriter
.writeIntProperty
< sal_Int32
>( mnMaxLength
);
1481 aWriter
.skipProperty(); //mnMaxLength
1482 if ( ( ( mnDisplayStyle
== AX_DISPLAYSTYLE_COMBOBOX
) || ( mnDisplayStyle
== AX_DISPLAYSTYLE_LISTBOX
) || ( mnDisplayStyle
== AX_DISPLAYSTYLE_TEXT
) ) && mnBorderStyle
!= AX_BORDERSTYLE_NONE
)
1483 aWriter
.writeIntProperty
< sal_uInt8
>( mnBorderStyle
);
1485 aWriter
.skipProperty(); //mnBorderStyle
1487 if ( ( mnDisplayStyle
== AX_DISPLAYSTYLE_LISTBOX
|| mnDisplayStyle
== AX_DISPLAYSTYLE_TEXT
) && mnScrollBars
!= AX_SCROLLBAR_NONE
)
1488 aWriter
.writeIntProperty
< sal_uInt8
>( mnScrollBars
);
1490 aWriter
.skipProperty(); //mnScrollBars
1491 aWriter
.writeIntProperty
< sal_uInt8
>( mnDisplayStyle
);
1492 aWriter
.skipProperty(); // mouse pointer
1493 aWriter
.writePairProperty( maSize
);
1494 if ( mnDisplayStyle
== AX_DISPLAYSTYLE_TEXT
)
1495 aWriter
.writeIntProperty
< sal_uInt16
>( mnPasswordChar
);
1497 aWriter
.skipProperty(); // mnPasswordChar
1498 aWriter
.skipProperty(); // list width
1499 aWriter
.skipProperty(); // bound column
1500 aWriter
.skipProperty(); // text column
1501 aWriter
.skipProperty(); // column count
1502 aWriter
.skipProperty(); // mnListRows
1503 aWriter
.skipProperty(); // column info count
1504 aWriter
.skipProperty(); // mnMatchEntry
1505 aWriter
.skipProperty(); // list style
1506 aWriter
.skipProperty(); // mnShowDropButton );
1507 aWriter
.skipProperty();
1508 aWriter
.skipProperty(); // drop down style
1509 if ( mnDisplayStyle
== AX_DISPLAYSTYLE_LISTBOX
&& mnMultiSelect
!= AX_SELECTION_SINGLE
)
1510 aWriter
.writeIntProperty
< sal_uInt8
>( mnMultiSelect
);
1511 // although CheckBox, ListBox, OptionButton, ToggleButton are also supported
1512 // they can only have the fileformat default
1514 aWriter
.skipProperty(); //mnMultiSelect
1515 aWriter
.writeStringProperty( maValue
);
1517 if ( ( mnDisplayStyle
== AX_DISPLAYSTYLE_CHECKBOX
) || ( mnDisplayStyle
== AX_DISPLAYSTYLE_OPTBUTTON
) || ( mnDisplayStyle
== AX_DISPLAYSTYLE_TOGGLE
) )
1518 aWriter
.writeStringProperty( maCaption
);
1520 aWriter
.skipProperty(); // mnCaption
1521 aWriter
.skipProperty(); // mnPicturePos );
1522 if ( ( mnDisplayStyle
== AX_DISPLAYSTYLE_COMBOBOX
|| mnDisplayStyle
== AX_DISPLAYSTYLE_LISTBOX
|| mnDisplayStyle
== AX_DISPLAYSTYLE_TEXT
) && mnBorderColor
!= AX_SYSCOLOR_WINDOWFRAME
)
1523 aWriter
.writeIntProperty
< sal_uInt32
>( mnBorderColor
);
1525 aWriter
.skipProperty(); // mnBorderColor
1526 if ( mnSpecialEffect
!= AX_SPECIALEFFECT_SUNKEN
)
1527 aWriter
.writeIntProperty
< sal_uInt32
>( mnSpecialEffect
);
1529 aWriter
.skipProperty(); //mnSpecialEffect
1530 aWriter
.skipProperty(); // mouse icon
1531 aWriter
.skipProperty(); // maPictureData
1532 aWriter
.skipProperty(); // accelerator
1533 aWriter
.skipProperty(); // undefined
1534 aWriter
.writeBoolProperty(true); // must be 1 for morph
1535 if ( ( mnDisplayStyle
== AX_DISPLAYSTYLE_CHECKBOX
) || ( mnDisplayStyle
== AX_DISPLAYSTYLE_OPTBUTTON
) )
1536 aWriter
.writeStringProperty( maGroupName
);
1538 aWriter
.skipProperty(); //maGroupName
1539 aWriter
.finalizeExport();
1540 AxFontDataModel::exportBinaryModel( rOutStrm
);
1543 void AxMorphDataModelBase::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
1545 rPropMap
.setProperty( PROP_Enabled
, getFlag( mnFlags
, AX_FLAGS_ENABLED
) );
1546 rConv
.convertColor( rPropMap
, PROP_TextColor
, mnTextColor
);
1547 AxFontDataModel::convertProperties( rPropMap
, rConv
);
1550 AxToggleButtonModel::AxToggleButtonModel()
1552 mnDisplayStyle
= AX_DISPLAYSTYLE_TOGGLE
;
1555 ApiControlType
AxToggleButtonModel::getControlType() const
1557 OSL_ENSURE( mnDisplayStyle
== AX_DISPLAYSTYLE_TOGGLE
, "AxToggleButtonModel::getControlType - invalid control type" );
1558 return API_CONTROL_BUTTON
;
1561 void AxToggleButtonModel::convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
)
1563 rPropSet
.getProperty( maCaption
, PROP_Label
);
1566 if ( rPropSet
.getProperty( bRes
, PROP_MultiLine
) )
1567 setFlag( mnFlags
, AX_FLAGS_WORDWRAP
, bRes
);
1569 ControlConverter::convertToMSColor( rPropSet
, PROP_BackgroundColor
, mnBackColor
);
1570 // need to process the image if one exists
1571 ControlConverter::convertToAxState( rPropSet
, maValue
, mnMultiSelect
, API_DEFAULTSTATE_BOOLEAN
, mbAwtModel
);
1572 AxMorphDataModelBase::convertFromProperties( rPropSet
, rConv
);
1575 void AxToggleButtonModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
1577 rPropMap
.setProperty( PROP_Label
, maCaption
);
1578 rPropMap
.setProperty( PROP_MultiLine
, getFlag( mnFlags
, AX_FLAGS_WORDWRAP
) );
1579 rPropMap
.setProperty( PROP_Toggle
, true );
1580 ControlConverter::convertVerticalAlign( rPropMap
, mnVerticalAlign
);
1581 rConv
.convertAxBackground( rPropMap
, mnBackColor
, mnFlags
, API_TRANSPARENCY_NOTSUPPORTED
);
1582 rConv
.convertAxPicture( rPropMap
, maPictureData
, mnPicturePos
);
1583 ControlConverter::convertAxState( rPropMap
, maValue
, mnMultiSelect
, API_DEFAULTSTATE_BOOLEAN
, mbAwtModel
);
1584 AxMorphDataModelBase::convertProperties( rPropMap
, rConv
);
1587 void AxToggleButtonModel::exportCompObj( BinaryOutputStream
& rOutStream
)
1589 // should be able to replace this hardcoded foo with
1590 // proper export info from MS-OLEDS spec.
1591 static sal_uInt8
const aCompObj
[] = {
1592 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1593 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0x1D, 0xD2, 0x8B,
1594 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1595 0x00, 0x60, 0x02, 0xF3, 0x21, 0x00, 0x00, 0x00,
1596 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1597 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1598 0x32, 0x2E, 0x30, 0x20, 0x54, 0x6F, 0x67, 0x67,
1599 0x6C, 0x65, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E,
1600 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62,
1601 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62,
1602 0x6A, 0x65, 0x63, 0x74, 0x00, 0x15, 0x00, 0x00,
1603 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x54,
1604 0x6F, 0x67, 0x67, 0x6C, 0x65, 0x42, 0x75, 0x74,
1605 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00, 0xF4, 0x39,
1606 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1607 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1609 rOutStream
.writeMemory( aCompObj
, sizeof( aCompObj
) );
1612 AxCheckBoxModel::AxCheckBoxModel()
1614 mnDisplayStyle
= AX_DISPLAYSTYLE_CHECKBOX
;
1617 ApiControlType
AxCheckBoxModel::getControlType() const
1619 OSL_ENSURE( mnDisplayStyle
== AX_DISPLAYSTYLE_CHECKBOX
, "AxCheckBoxModel::getControlType - invalid control type" );
1620 return API_CONTROL_CHECKBOX
;
1623 void AxCheckBoxModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
1625 rPropMap
.setProperty( PROP_Label
, maCaption
);
1626 rPropMap
.setProperty( PROP_MultiLine
, getFlag( mnFlags
, AX_FLAGS_WORDWRAP
) );
1627 ControlConverter::convertVerticalAlign( rPropMap
, mnVerticalAlign
);
1628 rConv
.convertAxBackground( rPropMap
, mnBackColor
, mnFlags
, API_TRANSPARENCY_VOID
);
1629 ControlConverter::convertAxVisualEffect( rPropMap
, mnSpecialEffect
);
1630 rConv
.convertAxPicture( rPropMap
, maPictureData
, mnPicturePos
);
1631 ControlConverter::convertAxState( rPropMap
, maValue
, mnMultiSelect
, API_DEFAULTSTATE_TRISTATE
, mbAwtModel
);
1632 AxMorphDataModelBase::convertProperties( rPropMap
, rConv
);
1635 void AxCheckBoxModel::convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
)
1637 rPropSet
.getProperty( maCaption
, PROP_Label
);
1640 if ( rPropSet
.getProperty( bRes
, PROP_MultiLine
) )
1641 setFlag( mnFlags
, AX_FLAGS_WORDWRAP
, bRes
);
1643 ControlConverter::convertToAxVisualEffect( rPropSet
, mnSpecialEffect
);
1644 ControlConverter::convertToMSColor( rPropSet
, PROP_BackgroundColor
, mnBackColor
);
1645 // need to process the image if one exists
1646 ControlConverter::convertToAxState( rPropSet
, maValue
, mnMultiSelect
, API_DEFAULTSTATE_BOOLEAN
, mbAwtModel
);
1647 AxMorphDataModelBase::convertFromProperties( rPropSet
, rConv
);
1650 void AxCheckBoxModel::exportCompObj( BinaryOutputStream
& rOutStream
)
1652 // should be able to replace this hardcoded foo with
1653 // proper export info from MS-OLEDS spec.
1654 static sal_uInt8
const aCompObj
[] = {
1655 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1656 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x1D, 0xD2, 0x8B,
1657 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1658 0x00, 0x60, 0x02, 0xF3, 0x1D, 0x00, 0x00, 0x00,
1659 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1660 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1661 0x32, 0x2E, 0x30, 0x20, 0x43, 0x68, 0x65, 0x63,
1662 0x6B, 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00,
1663 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65,
1664 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74,
1665 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72,
1666 0x6D, 0x73, 0x2E, 0x43, 0x68, 0x65, 0x63, 0x6B,
1667 0x42, 0x6F, 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39,
1668 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1669 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1671 rOutStream
.writeMemory( aCompObj
, sizeof( aCompObj
) );
1674 AxOptionButtonModel::AxOptionButtonModel()
1676 mnDisplayStyle
= AX_DISPLAYSTYLE_OPTBUTTON
;
1679 ApiControlType
AxOptionButtonModel::getControlType() const
1681 OSL_ENSURE( mnDisplayStyle
== AX_DISPLAYSTYLE_OPTBUTTON
, "AxOptionButtonModel::getControlType - invalid control type" );
1682 return API_CONTROL_RADIOBUTTON
;
1685 void AxOptionButtonModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
1687 rPropMap
.setProperty( PROP_Label
, maCaption
);
1688 rPropMap
.setProperty( PROP_MultiLine
, getFlag( mnFlags
, AX_FLAGS_WORDWRAP
) );
1689 ControlConverter::convertVerticalAlign( rPropMap
, mnVerticalAlign
);
1690 rConv
.convertAxBackground( rPropMap
, mnBackColor
, mnFlags
, API_TRANSPARENCY_VOID
);
1691 ControlConverter::convertAxVisualEffect( rPropMap
, mnSpecialEffect
);
1692 rConv
.convertAxPicture( rPropMap
, maPictureData
, mnPicturePos
);
1693 ControlConverter::convertAxState( rPropMap
, maValue
, mnMultiSelect
, API_DEFAULTSTATE_SHORT
, mbAwtModel
);
1694 AxMorphDataModelBase::convertProperties( rPropMap
, rConv
);
1697 void AxOptionButtonModel::convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
)
1699 rPropSet
.getProperty( maCaption
, PROP_Label
);
1702 if ( rPropSet
.getProperty( bRes
, PROP_MultiLine
) )
1703 setFlag( mnFlags
, AX_FLAGS_WORDWRAP
, bRes
);
1705 ControlConverter::convertToAxVisualEffect( rPropSet
, mnSpecialEffect
);
1706 ControlConverter::convertToMSColor( rPropSet
, PROP_BackgroundColor
, mnBackColor
);
1707 // need to process the image if one exists
1708 ControlConverter::convertToAxState( rPropSet
, maValue
, mnMultiSelect
, API_DEFAULTSTATE_BOOLEAN
, mbAwtModel
);
1709 AxMorphDataModelBase::convertFromProperties( rPropSet
, rConv
);
1712 void AxOptionButtonModel::exportCompObj( BinaryOutputStream
& rOutStream
)
1714 // should be able to replace this hardcoded foo with
1715 // proper export info from MS-OLEDS spec.
1716 static sal_uInt8
const aCompObj
[] = {
1717 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1718 0xFF, 0xFF, 0xFF, 0xFF, 0x50, 0x1D, 0xD2, 0x8B,
1719 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1720 0x00, 0x60, 0x02, 0xF3, 0x21, 0x00, 0x00, 0x00,
1721 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1722 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1723 0x32, 0x2E, 0x30, 0x20, 0x4F, 0x70, 0x74, 0x69,
1724 0x6F, 0x6E, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E,
1725 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62,
1726 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62,
1727 0x6A, 0x65, 0x63, 0x74, 0x00, 0x15, 0x00, 0x00,
1728 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x4F,
1729 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x42, 0x75, 0x74,
1730 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00, 0xF4, 0x39,
1731 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1732 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1734 rOutStream
.writeMemory( aCompObj
, sizeof( aCompObj
) );
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
)
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
);
1775 if ( rPropSet
.getProperty( nTmp
, PROP_MaxTextLen
) )
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 ControlConverter::convertToMSColor( rPropSet
, PROP_BackgroundColor
, mnBackColor
, 0x80000005L
);
1786 ControlConverter::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
) );
1814 AxNumericFieldModel::AxNumericFieldModel()
1816 mnDisplayStyle
= AX_DISPLAYSTYLE_TEXT
;
1819 ApiControlType
AxNumericFieldModel::getControlType() const
1821 OSL_ENSURE( mnDisplayStyle
== AX_DISPLAYSTYLE_TEXT
, "AxNumericFieldModel::getControlType - invalid control type" );
1822 return API_CONTROL_NUMERIC
;
1825 void AxNumericFieldModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
1827 rPropMap
.setProperty( PROP_HideInactiveSelection
, getFlag( mnFlags
, AX_FLAGS_HIDESELECTION
) );
1828 // TODO: OUString::toDouble() does not handle local decimal separator
1829 rPropMap
.setProperty( mbAwtModel
? PROP_Value
: PROP_DefaultValue
, maValue
.toDouble() );
1830 rPropMap
.setProperty( PROP_Spin
, getFlag( mnScrollBars
, AX_SCROLLBAR_VERTICAL
) );
1831 rPropMap
.setProperty( PROP_Repeat
, true );
1832 rConv
.convertAxBackground( rPropMap
, mnBackColor
, mnFlags
, API_TRANSPARENCY_VOID
);
1833 rConv
.convertAxBorder( rPropMap
, mnBorderColor
, mnBorderStyle
, mnSpecialEffect
);
1834 AxMorphDataModelBase::convertProperties( rPropMap
, rConv
);
1837 void AxNumericFieldModel::convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
)
1840 if ( rPropSet
.getProperty( bRes
, PROP_HideInactiveSelection
) )
1841 setFlag( mnFlags
, AX_FLAGS_HIDESELECTION
, bRes
);
1842 rPropSet
.getProperty( maValue
, ( mbAwtModel
? PROP_Text
: PROP_DefaultText
) );
1843 if ( rPropSet
.getProperty( bRes
, PROP_Spin
) )
1844 setFlag( mnScrollBars
, AX_SCROLLBAR_VERTICAL
, bRes
);
1846 ControlConverter::convertToMSColor( rPropSet
, PROP_BackgroundColor
, mnBackColor
);
1848 ControlConverter::convertToAxBorder( rPropSet
, mnBorderColor
, mnBorderStyle
, mnSpecialEffect
);
1849 AxMorphDataModelBase::convertFromProperties( rPropSet
, rConv
);
1852 void AxNumericFieldModel::exportCompObj( BinaryOutputStream
& rOutStream
)
1854 // should be able to replace this hardcoded foo with
1855 // proper export info from MS-OLEDS spec.
1856 static sal_uInt8
const aCompObj
[] = {
1857 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1858 0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x1D, 0xD2, 0x8B,
1859 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1860 0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
1861 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1862 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1863 0x32, 0x2E, 0x30, 0x20, 0x54, 0x65, 0x78, 0x74,
1864 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
1865 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
1866 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
1867 0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
1868 0x73, 0x2E, 0x54, 0x65, 0x78, 0x74, 0x42, 0x6F,
1869 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
1870 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1871 0x00, 0x00, 0x00, 0x00
1873 rOutStream
.writeMemory( aCompObj
, sizeof( aCompObj
) );
1876 AxListBoxModel::AxListBoxModel()
1878 mnDisplayStyle
= AX_DISPLAYSTYLE_LISTBOX
;
1881 ApiControlType
AxListBoxModel::getControlType() const
1883 OSL_ENSURE( mnDisplayStyle
== AX_DISPLAYSTYLE_LISTBOX
, "AxListBoxModel::getControlType - invalid control type" );
1884 return API_CONTROL_LISTBOX
;
1887 void AxListBoxModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
1889 bool bMultiSelect
= (mnMultiSelect
== AX_SELECTION_MULTI
) || (mnMultiSelect
== AX_SELECTION_EXTENDED
);
1890 rPropMap
.setProperty( PROP_MultiSelection
, bMultiSelect
);
1891 rPropMap
.setProperty( PROP_Dropdown
, false );
1892 rConv
.convertAxBackground( rPropMap
, mnBackColor
, mnFlags
, API_TRANSPARENCY_VOID
);
1893 rConv
.convertAxBorder( rPropMap
, mnBorderColor
, mnBorderStyle
, mnSpecialEffect
);
1894 AxMorphDataModelBase::convertProperties( rPropMap
, rConv
);
1897 void AxListBoxModel::convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
)
1900 if ( rPropSet
.getProperty( bRes
, PROP_MultiSelection
) )
1901 ControlConverter::convertToMSColor( rPropSet
, PROP_BackgroundColor
, mnBackColor
);
1903 ControlConverter::convertToAxBorder( rPropSet
, mnBorderColor
, mnBorderStyle
, mnSpecialEffect
);
1904 AxMorphDataModelBase::convertFromProperties( rPropSet
, rConv
);
1907 void AxListBoxModel::exportCompObj( BinaryOutputStream
& rOutStream
)
1909 // should be able to replace this hardcoded foo with
1910 // proper export info from MS-OLEDS spec.
1911 static sal_uInt8
const aCompObj
[] = {
1912 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1913 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0x1D, 0xD2, 0x8B,
1914 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1915 0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
1916 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1917 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1918 0x32, 0x2E, 0x30, 0x20, 0x4C, 0x69, 0x73, 0x74,
1919 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
1920 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
1921 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
1922 0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
1923 0x73, 0x2E, 0x4C, 0x69, 0x73, 0x74, 0x42, 0x6F,
1924 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
1925 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1926 0x00, 0x00, 0x00, 0x00
1928 rOutStream
.writeMemory( aCompObj
, sizeof( aCompObj
) );
1931 AxComboBoxModel::AxComboBoxModel()
1933 mnDisplayStyle
= AX_DISPLAYSTYLE_COMBOBOX
;
1934 mnFlags
= 0x2c80481b;
1937 ApiControlType
AxComboBoxModel::getControlType() const
1939 OSL_ENSURE( (mnDisplayStyle
== AX_DISPLAYSTYLE_COMBOBOX
) || (mnDisplayStyle
== AX_DISPLAYSTYLE_DROPDOWN
), "AxComboBoxModel::getControlType - invalid control type" );
1940 return (mnDisplayStyle
== AX_DISPLAYSTYLE_DROPDOWN
) ? API_CONTROL_LISTBOX
: API_CONTROL_COMBOBOX
;
1943 void AxComboBoxModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
1945 if( mnDisplayStyle
!= AX_DISPLAYSTYLE_DROPDOWN
)
1947 rPropMap
.setProperty( PROP_HideInactiveSelection
, getFlag( mnFlags
, AX_FLAGS_HIDESELECTION
) );
1948 rPropMap
.setProperty( mbAwtModel
? PROP_Text
: PROP_DefaultText
, maValue
);
1949 rPropMap
.setProperty( PROP_MaxTextLen
, getLimitedValue
< sal_Int16
, sal_Int32
>( mnMaxLength
, 0, SAL_MAX_INT16
) );
1950 bool bAutoComplete
= (mnMatchEntry
== AX_MATCHENTRY_FIRSTLETTER
) || (mnMatchEntry
== AX_MATCHENTRY_COMPLETE
);
1951 rPropMap
.setProperty( PROP_Autocomplete
, bAutoComplete
);
1953 bool bShowDropdown
= (mnShowDropButton
== AX_SHOWDROPBUTTON_FOCUS
) || (mnShowDropButton
== AX_SHOWDROPBUTTON_ALWAYS
);
1954 rPropMap
.setProperty( PROP_Dropdown
, bShowDropdown
);
1955 rPropMap
.setProperty( PROP_LineCount
, getLimitedValue
< sal_Int16
, sal_Int32
>( mnListRows
, 1, SAL_MAX_INT16
) );
1956 rConv
.convertAxBackground( rPropMap
, mnBackColor
, mnFlags
, API_TRANSPARENCY_VOID
);
1957 rConv
.convertAxBorder( rPropMap
, mnBorderColor
, mnBorderStyle
, mnSpecialEffect
);
1958 AxMorphDataModelBase::convertProperties( rPropMap
, rConv
);
1961 void AxComboBoxModel::convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
)
1963 // when would we have mnDisplayStyle = AX_DISPLAYSTYLE_DROPDOWN ?
1964 // #TODO check against msocximex
1965 mnDisplayStyle
= AX_DISPLAYSTYLE_COMBOBOX
;
1968 if ( rPropSet
.getProperty( bRes
, PROP_HideInactiveSelection
) )
1969 setFlag( mnFlags
, AX_FLAGS_HIDESELECTION
, bRes
);
1970 rPropSet
.getProperty( maValue
, ( mbAwtModel
? PROP_Text
: PROP_DefaultText
) );
1973 if ( rPropSet
.getProperty( nTmp
, PROP_MaxTextLen
) )
1975 if ( rPropSet
.getProperty( bRes
, PROP_Autocomplete
) )
1977 // when to choose AX_MATCHENTRY_FIRSTLETTER ?
1978 // #TODO check against msocximex
1980 mnMatchEntry
= AX_MATCHENTRY_COMPLETE
;
1982 if ( rPropSet
.getProperty( bRes
, PROP_Dropdown
) )
1984 rPropSet
.getProperty( mnListRows
, PROP_LineCount
);
1988 ControlConverter::convertToMSColor( rPropSet
, PROP_BackgroundColor
, mnBackColor
);
1990 ControlConverter::convertToAxBorder( rPropSet
, mnBorderColor
, mnBorderStyle
, mnSpecialEffect
);
1991 AxMorphDataModelBase::convertFromProperties( rPropSet
, rConv
);
1994 void AxComboBoxModel::exportCompObj( BinaryOutputStream
& rOutStream
)
1996 // should be able to replace this hardcoded foo with
1997 // proper export info from MS-OLEDS spec.
1998 static sal_uInt8
const aCompObj
[] = {
1999 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2000 0xFF, 0xFF, 0xFF, 0xFF, 0x30, 0x1D, 0xD2, 0x8B,
2001 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
2002 0x00, 0x60, 0x02, 0xF3, 0x1D, 0x00, 0x00, 0x00,
2003 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2004 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2005 0x32, 0x2E, 0x30, 0x20, 0x43, 0x6F, 0x6D, 0x62,
2006 0x6F, 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00,
2007 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65,
2008 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74,
2009 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72,
2010 0x6D, 0x73, 0x2E, 0x43, 0x6F, 0x6D, 0x62, 0x6F,
2011 0x42, 0x6F, 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39,
2012 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2013 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2015 rOutStream
.writeMemory( aCompObj
, sizeof( aCompObj
) );
2018 AxSpinButtonModel::AxSpinButtonModel() :
2019 mnArrowColor( AX_SYSCOLOR_BUTTONTEXT
),
2020 mnBackColor( AX_SYSCOLOR_BUTTONFACE
),
2021 mnFlags( AX_SPINBUTTON_DEFFLAGS
),
2022 mnOrientation( AX_ORIENTATION_AUTO
),
2031 ApiControlType
AxSpinButtonModel::getControlType() const
2033 return API_CONTROL_SPINBUTTON
;
2036 void AxSpinButtonModel::importProperty( sal_Int32 nPropId
, const OUString
& rValue
)
2040 case XML_ForeColor
: mnArrowColor
= AttributeConversion::decodeUnsigned( rValue
); break;
2041 case XML_BackColor
: mnBackColor
= AttributeConversion::decodeUnsigned( rValue
); break;
2042 case XML_VariousPropertyBits
: mnFlags
= AttributeConversion::decodeUnsigned( rValue
); break;
2043 case XML_Orientation
: mnOrientation
= AttributeConversion::decodeInteger( rValue
); break;
2044 case XML_Min
: mnMin
= AttributeConversion::decodeInteger( rValue
); break;
2045 case XML_Max
: mnMax
= AttributeConversion::decodeInteger( rValue
); break;
2046 case XML_Position
: mnPosition
= AttributeConversion::decodeInteger( rValue
); break;
2047 case XML_SmallChange
: mnSmallChange
= AttributeConversion::decodeInteger( rValue
); break;
2048 case XML_Delay
: mnDelay
= AttributeConversion::decodeInteger( rValue
); break;
2049 default: AxControlModelBase::importProperty( nPropId
, rValue
);
2053 bool AxSpinButtonModel::importBinaryModel( BinaryInputStream
& rInStrm
)
2055 AxBinaryPropertyReader
aReader( rInStrm
);
2056 aReader
.readIntProperty
< sal_uInt32
>( mnArrowColor
);
2057 aReader
.readIntProperty
< sal_uInt32
>( mnBackColor
);
2058 aReader
.readIntProperty
< sal_uInt32
>( mnFlags
);
2059 aReader
.readPairProperty( maSize
);
2060 aReader
.skipIntProperty
< sal_uInt32
>(); // unused
2061 aReader
.readIntProperty
< sal_Int32
>( mnMin
);
2062 aReader
.readIntProperty
< sal_Int32
>( mnMax
);
2063 aReader
.readIntProperty
< sal_Int32
>( mnPosition
);
2064 aReader
.skipIntProperty
< sal_uInt32
>(); // prev enabled
2065 aReader
.skipIntProperty
< sal_uInt32
>(); // next enabled
2066 aReader
.readIntProperty
< sal_Int32
>( mnSmallChange
);
2067 aReader
.readIntProperty
< sal_Int32
>( mnOrientation
);
2068 aReader
.readIntProperty
< sal_Int32
>( mnDelay
);
2069 aReader
.skipPictureProperty(); // mouse icon
2070 aReader
.skipIntProperty
< sal_uInt8
>(); // mouse pointer
2071 return aReader
.finalizeImport();
2074 void AxSpinButtonModel::exportBinaryModel( BinaryOutputStream
& rOutStrm
)
2076 AxBinaryPropertyWriter
aWriter( rOutStrm
);
2077 aWriter
.writeIntProperty
< sal_uInt32
>( mnArrowColor
);
2079 aWriter
.writeIntProperty
< sal_uInt32
>( mnBackColor
);
2081 aWriter
.skipProperty(); // default backcolour
2082 aWriter
.writeIntProperty
< sal_uInt32
>( mnFlags
);
2083 aWriter
.writePairProperty( maSize
);
2084 aWriter
.skipProperty(); // unused
2085 aWriter
.writeIntProperty
< sal_Int32
>( mnMin
);
2086 aWriter
.writeIntProperty
< sal_Int32
>( mnMax
);
2087 aWriter
.writeIntProperty
< sal_Int32
>( mnPosition
);
2088 aWriter
.skipProperty(); // prev enabled
2089 aWriter
.skipProperty(); // next enabled
2090 aWriter
.writeIntProperty
< sal_Int32
>( mnSmallChange
);
2091 aWriter
.writeIntProperty
< sal_Int32
>( mnOrientation
);
2092 aWriter
.writeIntProperty
< sal_Int32
>( mnDelay
);
2093 aWriter
.skipProperty(); // mouse icon
2094 aWriter
.skipProperty(); // mouse pointer
2096 aWriter
.finalizeExport();
2099 void AxSpinButtonModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
2101 sal_Int32 nMin
= ::std::min( mnMin
, mnMax
);
2102 sal_Int32 nMax
= ::std::max( mnMin
, mnMax
);
2103 rPropMap
.setProperty( PROP_Enabled
, getFlag( mnFlags
, AX_FLAGS_ENABLED
) );
2104 rPropMap
.setProperty( PROP_SpinValueMin
, nMin
);
2105 rPropMap
.setProperty( PROP_SpinValueMax
, nMax
);
2106 rPropMap
.setProperty( PROP_SpinIncrement
, mnSmallChange
);
2107 rPropMap
.setProperty( mbAwtModel
? PROP_SpinValue
: PROP_DefaultSpinValue
, mnPosition
);
2108 rPropMap
.setProperty( PROP_Repeat
, true );
2109 rPropMap
.setProperty( PROP_RepeatDelay
, mnDelay
);
2110 rPropMap
.setProperty( PROP_Border
, API_BORDER_NONE
);
2111 rConv
.convertColor( rPropMap
, PROP_SymbolColor
, mnArrowColor
);
2112 rConv
.convertAxBackground( rPropMap
, mnBackColor
, mnFlags
, API_TRANSPARENCY_NOTSUPPORTED
);
2113 ControlConverter::convertAxOrientation( rPropMap
, maSize
, mnOrientation
);
2114 AxControlModelBase::convertProperties( rPropMap
, rConv
);
2117 void AxSpinButtonModel::convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& )
2120 if ( rPropSet
.getProperty( bRes
, PROP_Enabled
) )
2121 setFlag( mnFlags
, AX_FLAGS_ENABLED
, bRes
);
2122 rPropSet
.getProperty( mnMin
, PROP_SpinValueMin
);
2123 rPropSet
.getProperty( mnMax
, PROP_SpinValueMax
);
2124 rPropSet
.getProperty( mnSmallChange
, PROP_SpinIncrement
);
2125 rPropSet
.getProperty( mnPosition
, ( mbAwtModel
? PROP_SpinValue
: PROP_DefaultSpinValue
) );
2126 rPropSet
.getProperty( mnDelay
, PROP_RepeatDelay
);
2127 ControlConverter::convertToMSColor( rPropSet
, PROP_SymbolColor
, mnArrowColor
);
2128 ControlConverter::convertToMSColor( rPropSet
, PROP_BackgroundColor
, mnBackColor
);
2130 ControlConverter::convertToAxOrientation( rPropSet
, maSize
, mnOrientation
);
2133 void AxSpinButtonModel::exportCompObj( BinaryOutputStream
& rOutStream
)
2135 // should be able to replace this hardcoded foo with
2136 // proper export info from MS-OLEDS spec.
2137 static sal_uInt8
const aCompObj
[] =
2139 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2140 0xFF, 0xFF, 0xFF, 0xFF, 0xB0, 0x6F, 0x17, 0x79,
2141 0xF2, 0xB7, 0xCE, 0x11, 0x97, 0xEF, 0x00, 0xAA,
2142 0x00, 0x6D, 0x27, 0x76, 0x1F, 0x00, 0x00, 0x00,
2143 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2144 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2145 0x32, 0x2E, 0x30, 0x20, 0x53, 0x70, 0x69, 0x6E,
2146 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x00, 0x10,
2147 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64,
2148 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65,
2149 0x63, 0x74, 0x00, 0x13, 0x00, 0x00, 0x00, 0x46,
2150 0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x53, 0x70, 0x69,
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,
2157 rOutStream
.writeMemory( aCompObj
, sizeof( aCompObj
) );
2160 AxScrollBarModel::AxScrollBarModel() :
2161 mnArrowColor( AX_SYSCOLOR_BUTTONTEXT
),
2162 mnBackColor( AX_SYSCOLOR_BUTTONFACE
),
2163 mnFlags( AX_SCROLLBAR_DEFFLAGS
),
2164 mnOrientation( AX_ORIENTATION_AUTO
),
2165 mnPropThumb( AX_PROPTHUMB_ON
),
2175 ApiControlType
AxScrollBarModel::getControlType() const
2177 return API_CONTROL_SCROLLBAR
;
2180 void AxScrollBarModel::importProperty( sal_Int32 nPropId
, const OUString
& rValue
)
2184 case XML_ForeColor
: mnArrowColor
= AttributeConversion::decodeUnsigned( rValue
); break;
2185 case XML_BackColor
: mnBackColor
= AttributeConversion::decodeUnsigned( rValue
); break;
2186 case XML_VariousPropertyBits
: mnFlags
= AttributeConversion::decodeUnsigned( rValue
); break;
2187 case XML_Orientation
: mnOrientation
= AttributeConversion::decodeInteger( rValue
); break;
2188 case XML_ProportionalThumb
: mnPropThumb
= AttributeConversion::decodeInteger( rValue
); break;
2189 case XML_Min
: mnMin
= AttributeConversion::decodeInteger( rValue
); break;
2190 case XML_Max
: mnMax
= AttributeConversion::decodeInteger( rValue
); break;
2191 case XML_Position
: mnPosition
= AttributeConversion::decodeInteger( rValue
); break;
2192 case XML_SmallChange
: mnSmallChange
= AttributeConversion::decodeInteger( rValue
); break;
2193 case XML_LargeChange
: mnLargeChange
= AttributeConversion::decodeInteger( rValue
); break;
2194 case XML_Delay
: mnDelay
= AttributeConversion::decodeInteger( rValue
); break;
2195 default: AxControlModelBase::importProperty( nPropId
, rValue
);
2199 bool AxScrollBarModel::importBinaryModel( BinaryInputStream
& rInStrm
)
2201 AxBinaryPropertyReader
aReader( rInStrm
);
2202 aReader
.readIntProperty
< sal_uInt32
>( mnArrowColor
);
2203 aReader
.readIntProperty
< sal_uInt32
>( mnBackColor
);
2204 aReader
.readIntProperty
< sal_uInt32
>( mnFlags
);
2205 aReader
.readPairProperty( maSize
);
2206 aReader
.skipIntProperty
< sal_uInt8
>(); // mouse pointer
2207 aReader
.readIntProperty
< sal_Int32
>( mnMin
);
2208 aReader
.readIntProperty
< sal_Int32
>( mnMax
);
2209 aReader
.readIntProperty
< sal_Int32
>( mnPosition
);
2210 aReader
.skipIntProperty
< sal_uInt32
>(); // unused
2211 aReader
.skipIntProperty
< sal_uInt32
>(); // prev enabled
2212 aReader
.skipIntProperty
< sal_uInt32
>(); // next enabled
2213 aReader
.readIntProperty
< sal_Int32
>( mnSmallChange
);
2214 aReader
.readIntProperty
< sal_Int32
>( mnLargeChange
);
2215 aReader
.readIntProperty
< sal_Int32
>( mnOrientation
);
2216 aReader
.readIntProperty
< sal_Int16
>( mnPropThumb
);
2217 aReader
.readIntProperty
< sal_Int32
>( mnDelay
);
2218 aReader
.skipPictureProperty(); // mouse icon
2219 return aReader
.finalizeImport();
2222 void AxScrollBarModel::exportBinaryModel( BinaryOutputStream
& rOutStrm
)
2224 AxBinaryPropertyWriter
aWriter( rOutStrm
);
2225 aWriter
.writeIntProperty
< sal_uInt32
>( mnArrowColor
);
2227 aWriter
.writeIntProperty
< sal_uInt32
>( mnBackColor
);
2229 aWriter
.skipProperty(); // default backcolour
2230 aWriter
.writeIntProperty
< sal_uInt32
>( mnFlags
);
2231 aWriter
.writePairProperty( maSize
);
2232 aWriter
.skipProperty(); // mouse pointer
2233 aWriter
.writeIntProperty
< sal_Int32
>( mnMin
);
2234 aWriter
.writeIntProperty
< sal_Int32
>( mnMax
);
2235 aWriter
.writeIntProperty
< sal_Int32
>( mnPosition
);
2236 aWriter
.skipProperty(); // unused
2237 aWriter
.skipProperty(); // prev enabled
2238 aWriter
.skipProperty(); // next enabled
2239 aWriter
.writeIntProperty
< sal_Int32
>( mnSmallChange
);
2240 aWriter
.writeIntProperty
< sal_Int32
>( mnLargeChange
);
2241 aWriter
.writeIntProperty
< sal_Int32
>( mnOrientation
);
2242 aWriter
.writeIntProperty
< sal_Int16
>( mnPropThumb
);
2243 aWriter
.writeIntProperty
< sal_Int32
>( mnDelay
);
2244 aWriter
.skipProperty(); // mouse icon
2245 aWriter
.finalizeExport();
2248 void AxScrollBarModel::exportCompObj( BinaryOutputStream
& rOutStream
)
2250 // should be able to replace this hardcoded foo with
2251 // proper export info from MS-OLEDS spec.
2252 static sal_uInt8
const aCompObj
[] =
2254 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2255 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x81, 0xD1, 0xDF,
2256 0x2F, 0x5E, 0xCE, 0x11, 0xA4, 0x49, 0x00, 0xAA,
2257 0x00, 0x4A, 0x80, 0x3D, 0x1E, 0x00, 0x00, 0x00,
2258 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2259 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2260 0x32, 0x2E, 0x30, 0x20, 0x53, 0x63, 0x72, 0x6F,
2261 0x6C, 0x6C, 0x42, 0x61, 0x72, 0x00, 0x10, 0x00,
2262 0x00, 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64,
2263 0x65, 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63,
2264 0x74, 0x00, 0x12, 0x00, 0x00, 0x00, 0x46, 0x6F,
2265 0x72, 0x6D, 0x73, 0x2E, 0x53, 0x63, 0x72, 0x6F,
2266 0x6C, 0x6C, 0x42, 0x61, 0x72, 0x2E, 0x31, 0x00,
2267 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
2268 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2270 rOutStream
.writeMemory( aCompObj
, sizeof( aCompObj
) );
2273 void AxScrollBarModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
2275 rPropMap
.setProperty( PROP_Enabled
, getFlag( mnFlags
, AX_FLAGS_ENABLED
) );
2276 rPropMap
.setProperty( PROP_RepeatDelay
, mnDelay
);
2277 rPropMap
.setProperty( PROP_Border
, API_BORDER_NONE
);
2278 if( (mnPropThumb
== AX_PROPTHUMB_ON
) && (mnMin
!= mnMax
) && (mnLargeChange
> 0) )
2280 // use double to prevent integer overflow in division (fInterval+mnLargeChange may become 0 when performed as int)
2281 double fInterval
= fabs( static_cast< double >( mnMax
- mnMin
) );
2282 sal_Int32 nThumbLen
= getLimitedValue
< sal_Int32
, double >( (fInterval
* mnLargeChange
) / (fInterval
+ mnLargeChange
), 1, SAL_MAX_INT32
);
2283 rPropMap
.setProperty( PROP_VisibleSize
, nThumbLen
);
2285 rConv
.convertColor( rPropMap
, PROP_SymbolColor
, mnArrowColor
);
2286 rConv
.convertAxBackground( rPropMap
, mnBackColor
, mnFlags
, API_TRANSPARENCY_NOTSUPPORTED
);
2287 ControlConverter::convertAxOrientation( rPropMap
, maSize
, mnOrientation
);
2288 ControlConverter::convertScrollBar( rPropMap
, mnMin
, mnMax
, mnPosition
, mnSmallChange
, mnLargeChange
, mbAwtModel
);
2289 AxControlModelBase::convertProperties( rPropMap
, rConv
);
2292 void AxScrollBarModel::convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& )
2295 if ( rPropSet
.getProperty( bRes
, PROP_Enabled
) )
2296 setFlag( mnFlags
, AX_FLAGS_ENABLED
, bRes
);
2297 rPropSet
.getProperty( mnDelay
, PROP_RepeatDelay
);
2298 mnPropThumb
= AX_PROPTHUMB_ON
; // default
2299 ControlConverter::convertToMSColor( rPropSet
, PROP_SymbolColor
, mnArrowColor
);
2300 ControlConverter::convertToMSColor( rPropSet
, PROP_BackgroundColor
, mnBackColor
);
2301 ControlConverter::convertToAxOrientation( rPropSet
, maSize
, mnOrientation
);
2303 rPropSet
.getProperty( mnMin
, PROP_ScrollValueMin
);
2304 rPropSet
.getProperty( mnMax
, PROP_ScrollValueMax
);
2305 rPropSet
.getProperty( mnSmallChange
, PROP_LineIncrement
);
2306 rPropSet
.getProperty( mnLargeChange
, PROP_BlockIncrement
);
2307 rPropSet
.getProperty( mnPosition
, ( mbAwtModel
? PROP_ScrollValue
: PROP_DefaultScrollValue
) );
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
)
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
)
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
2377 rConv
.convertColor( rPropMap
, PROP_TextColor
, mnTextColor
);
2378 AxFontDataModel::convertProperties( rPropMap
, rConv
);
2382 bool AxContainerModelBase::importClassTable( BinaryInputStream
& rInStrm
, AxClassTable
& orClassTable
)
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();
2414 AxFrameModel::AxFrameModel() :
2415 AxContainerModelBase( true )
2419 ApiControlType
AxFrameModel::getControlType() const
2421 return mbAwtModel
? API_CONTROL_FRAME
: API_CONTROL_GROUPBOX
;
2424 void AxFrameModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
2426 rPropMap
.setProperty( PROP_Label
, maCaption
);
2427 rPropMap
.setProperty( PROP_Enabled
, getFlag( mnFlags
, AX_CONTAINER_ENABLED
) );
2428 AxContainerModelBase::convertProperties( rPropMap
, rConv
);
2431 AxPageModel::AxPageModel()
2435 ApiControlType
AxPageModel::getControlType() const
2437 return API_CONTROL_PAGE
;
2440 void AxPageModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
2442 rPropMap
.setProperty( PROP_Title
, maCaption
);
2443 rConv
.convertColor( rPropMap
, PROP_BackgroundColor
, mnBackColor
);
2444 rPropMap
.setProperty( PROP_Enabled
, getFlag( mnFlags
, AX_CONTAINER_ENABLED
) );
2445 AxContainerModelBase::convertProperties( rPropMap
, rConv
);
2448 AxMultiPageModel::AxMultiPageModel() :
2450 mnTabStyle( AX_TABSTRIP_TABS
)
2454 ApiControlType
AxMultiPageModel::getControlType() const
2456 return API_CONTROL_MULTIPAGE
;
2459 bool AxMultiPageModel::importPageAndMultiPageProperties( BinaryInputStream
& rInStrm
, sal_Int32 nPages
)
2462 for ( sal_Int32 nPage
= 0; nPage
< nPages
; ++nPage
)
2464 AxBinaryPropertyReader
aReader( rInStrm
);
2465 aReader
.skipUndefinedProperty();
2466 aReader
.skipIntProperty
< sal_uInt32
>(); // TransistionEffect
2467 aReader
.skipIntProperty
< sal_uInt32
>(); // TransitionPeriod
2469 // MultiPageProperties
2470 AxBinaryPropertyReader
aReader( rInStrm
);
2471 sal_uInt32 nPageCount
= 0;
2472 aReader
.skipUndefinedProperty();
2473 aReader
.readIntProperty
< sal_uInt32
>(nPageCount
); // PageCount
2474 aReader
.skipIntProperty
< sal_uInt32
>(); //ID
2477 for ( sal_uInt32 count
= 0; count
< nPageCount
; ++count
)
2479 mnIDs
.push_back( rInStrm
.readInt32() );
2484 void AxMultiPageModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
2486 rPropMap
.setProperty( PROP_Title
, maCaption
);
2487 rPropMap
.setProperty( PROP_MultiPageValue
, mnActiveTab
+ 1);
2488 rConv
.convertColor( rPropMap
, PROP_BackgroundColor
, mnBackColor
);
2489 rPropMap
.setProperty( PROP_Enabled
, getFlag( mnFlags
, AX_CONTAINER_ENABLED
) );
2490 rPropMap
.setProperty( PROP_Decoration
, mnTabStyle
!= AX_TABSTRIP_NONE
);
2492 AxContainerModelBase::convertProperties( rPropMap
, rConv
);
2495 AxUserFormModel::AxUserFormModel()
2499 ApiControlType
AxUserFormModel::getControlType() const
2501 return API_CONTROL_DIALOG
;
2504 void AxUserFormModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
2506 rPropMap
.setProperty( PROP_Title
, maCaption
);
2507 rConv
.convertColor( rPropMap
, PROP_BackgroundColor
, mnBackColor
);
2508 rConv
.convertAxPicture( rPropMap
, maPictureData
, AX_PICPOS_CENTER
);
2509 rConv
.convertScrollabilitySettings( rPropMap
, maScrollPos
, maLogicalSize
, mnScrollBars
);
2510 AxContainerModelBase::convertProperties( rPropMap
, rConv
);
2513 HtmlSelectModel::HtmlSelectModel()
2518 HtmlSelectModel::importBinaryModel( BinaryInputStream
& rInStrm
)
2520 static const char sMultiple
[] = "<SELECT MULTIPLE";
2521 static const char sSelected
[] = "OPTION SELECTED";
2523 OUString sStringContents
= rInStrm
.readUnicodeArray( rInStrm
.size() );
2525 OUString data
= sStringContents
;
2527 // replace crlf with lf
2528 data
= data
.replaceAll( "\x0D\x0A" , "\x0A" );
2529 std::vector
< OUString
> listValues
;
2530 std::vector
< sal_Int16
> selectedIndices
;
2532 // Ultra hacky parser for the info
2533 sal_Int32 nTokenCount
= comphelper::string::getTokenCount(data
, '\n');
2535 for ( sal_Int32 nToken
= 0; nToken
< nTokenCount
; ++nToken
)
2537 OUString
sLine( data
.getToken( nToken
, '\n' ) );
2538 if ( !nToken
) // first line will tell us if multiselect is enabled
2540 if ( sLine
== sMultiple
)
2541 mnMultiSelect
= AX_SELECTION_MULTI
;
2543 // skip first and last lines, no data there
2544 else if ( nToken
< nTokenCount
- 1)
2546 if ( comphelper::string::getTokenCount(sLine
, '>') )
2548 OUString displayValue
= sLine
.getToken( 1, '>' );
2549 if ( displayValue
.getLength() )
2551 // Really we should be using a proper html parser
2552 // escaping some common bits to be escaped
2553 displayValue
= displayValue
.replaceAll( "<", "<" );
2554 displayValue
= displayValue
.replaceAll( ">", ">" );
2555 displayValue
= displayValue
.replaceAll( """, "\"" );
2556 displayValue
= displayValue
.replaceAll( "&", "&" );
2557 listValues
.push_back( displayValue
);
2558 if( sLine
.indexOf( sSelected
) != -1 )
2559 selectedIndices
.push_back( static_cast< sal_Int16
>( listValues
.size() ) - 1 );
2564 if ( !listValues
.empty() )
2566 msListData
.realloc( listValues
.size() );
2567 sal_Int32 index
= 0;
2568 for( std::vector
< OUString
>::iterator it
= listValues
.begin(); it
!= listValues
.end(); ++it
, ++index
)
2569 msListData
[ index
] = *it
;
2571 if ( !selectedIndices
.empty() )
2573 msIndices
.realloc( selectedIndices
.size() );
2574 sal_Int32 index
= 0;
2575 for( std::vector
< sal_Int16
>::iterator it
= selectedIndices
.begin(); it
!= selectedIndices
.end(); ++it
, ++index
)
2576 msIndices
[ index
] = *it
;
2582 HtmlSelectModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
2584 rPropMap
.setProperty( PROP_StringItemList
, msListData
);
2585 rPropMap
.setProperty( PROP_SelectedItems
, msIndices
);
2586 rPropMap
.setProperty( PROP_Dropdown
, true );
2587 AxListBoxModel::convertProperties( rPropMap
, rConv
);
2590 HtmlTextBoxModel::HtmlTextBoxModel()
2595 HtmlTextBoxModel::importBinaryModel( BinaryInputStream
& rInStrm
)
2598 OUString sStringContents
= rInStrm
.readUnicodeArray( rInStrm
.size() );
2599 // in msocximex ( where this is ported from, it appears *nothing* is read
2600 // from the control stream ), surely there is some useful info there ?
2601 OSL_TRACE("HtmlTextBoxModel::importBinaryModel - string contents of stream :");
2602 OSL_TRACE("%s", OUStringToOString( sStringContents
, RTL_TEXTENCODING_UTF8
).getStr() );
2609 EmbeddedControl::EmbeddedControl( const OUString
& rName
) :
2614 EmbeddedControl::~EmbeddedControl()
2618 ControlModelBase
* EmbeddedControl::createModelFromGuid( const OUString
& rClassId
)
2620 OUString aClassId
= rClassId
;//.toAsciiUpperCase();
2622 if( aClassId
.equalsIgnoreAsciiCase( AX_GUID_COMMANDBUTTON
) ) return &createModel
< AxCommandButtonModel
>();
2623 if( aClassId
.equalsIgnoreAsciiCase( AX_GUID_LABEL
) ) return &createModel
< AxLabelModel
>();
2624 if( aClassId
.equalsIgnoreAsciiCase( AX_GUID_IMAGE
) ) return &createModel
< AxImageModel
>();
2625 if( aClassId
.equalsIgnoreAsciiCase( AX_GUID_TOGGLEBUTTON
) ) return &createModel
< AxToggleButtonModel
>();
2626 if( aClassId
.equalsIgnoreAsciiCase( AX_GUID_CHECKBOX
) ) return &createModel
< AxCheckBoxModel
>();
2627 if( aClassId
.equalsIgnoreAsciiCase( AX_GUID_OPTIONBUTTON
) ) return &createModel
< AxOptionButtonModel
>();
2628 if( aClassId
.equalsIgnoreAsciiCase( AX_GUID_TEXTBOX
) ) return &createModel
< AxTextBoxModel
>();
2629 if( aClassId
.equalsIgnoreAsciiCase( AX_GUID_LISTBOX
) ) return &createModel
< AxListBoxModel
>();
2630 if( aClassId
.equalsIgnoreAsciiCase( AX_GUID_COMBOBOX
) ) return &createModel
< AxComboBoxModel
>();
2631 if( aClassId
.equalsIgnoreAsciiCase( AX_GUID_SPINBUTTON
) ) return &createModel
< AxSpinButtonModel
>();
2632 if( aClassId
.equalsIgnoreAsciiCase( AX_GUID_SCROLLBAR
) ) return &createModel
< AxScrollBarModel
>();
2633 if( aClassId
.equalsIgnoreAsciiCase( AX_GUID_FRAME
) ) return &createModel
< AxFrameModel
>();
2634 if( aClassId
.equalsIgnoreAsciiCase( COMCTL_GUID_SCROLLBAR_60
) ) return &createModel
< ComCtlScrollBarModel
>( COMCTL_VERSION_60
);
2635 if( aClassId
.equalsIgnoreAsciiCase( HTML_GUID_SELECT
) ) return &createModel
< HtmlSelectModel
>();
2636 if( aClassId
.equalsIgnoreAsciiCase( HTML_GUID_TEXTBOX
) ) return &createModel
< HtmlTextBoxModel
>();
2642 OUString
EmbeddedControl::getServiceName() const
2644 return mxModel
.get() ? mxModel
->getServiceName() : OUString();
2647 bool EmbeddedControl::convertProperties( const Reference
< XControlModel
>& rxCtrlModel
, const ControlConverter
& rConv
) const
2649 if( mxModel
.get() && rxCtrlModel
.is() && !maName
.isEmpty() )
2651 PropertyMap aPropMap
;
2652 aPropMap
.setProperty( PROP_Name
, maName
);
2655 aPropMap
.setProperty( PROP_GenerateVbaEvents
, true);
2657 catch (const Exception
& e
)
2659 SAL_WARN("oox", "exception: " << e
.Message
);
2661 mxModel
->convertProperties( aPropMap
, rConv
);
2662 PropertySet
aPropSet( rxCtrlModel
);
2663 aPropSet
.setProperties( aPropMap
);
2669 bool EmbeddedControl::convertFromProperties( const Reference
< XControlModel
>& rxCtrlModel
, const ControlConverter
& rConv
)
2671 if( mxModel
.get() && rxCtrlModel
.is() && !maName
.isEmpty() )
2673 PropertySet
aPropSet( rxCtrlModel
);
2674 aPropSet
.getProperty( maName
, PROP_Name
);
2675 mxModel
->convertFromProperties( aPropSet
, rConv
);
2681 EmbeddedForm::EmbeddedForm( const Reference
< XModel
>& rxDocModel
,
2682 const Reference
< XDrawPage
>& rxDrawPage
, const GraphicHelper
& rGraphicHelper
, bool bDefaultColorBgr
) :
2683 maControlConv( rxDocModel
, rGraphicHelper
, bDefaultColorBgr
),
2684 mxModelFactory( rxDocModel
, UNO_QUERY
),
2685 mxFormsSupp( rxDrawPage
, UNO_QUERY
)
2687 OSL_ENSURE( mxModelFactory
.is(), "EmbeddedForm::EmbeddedForm - missing service factory" );
2690 Reference
< XControlModel
> EmbeddedForm::convertAndInsert( const EmbeddedControl
& rControl
, sal_Int32
& rnCtrlIndex
)
2692 Reference
< XControlModel
> xRet
;
2693 if( mxModelFactory
.is() && rControl
.hasModel() ) try
2695 // create the UNO control model
2696 OUString aServiceName
= rControl
.getServiceName();
2697 Reference
< XFormComponent
> xFormComp( mxModelFactory
->createInstance( aServiceName
), UNO_QUERY_THROW
);
2698 Reference
< XControlModel
> xCtrlModel( xFormComp
, UNO_QUERY_THROW
);
2700 // convert the control properties
2701 if( rControl
.convertProperties( xCtrlModel
, maControlConv
) )
2703 // insert the control into the form
2704 Reference
< XIndexContainer
> xFormIC( createXForm(), UNO_SET_THROW
);
2705 rnCtrlIndex
= xFormIC
->getCount();
2706 xFormIC
->insertByIndex( rnCtrlIndex
, Any( xFormComp
) );
2708 catch (const Exception
& e
)
2710 SAL_WARN("oox", "exception creating Control: " << e
.Message
);
2715 Reference
< XIndexContainer
> EmbeddedForm::createXForm()
2717 if( mxFormsSupp
.is() )
2721 Reference
< XNameContainer
> xFormsNC( mxFormsSupp
->getForms(), UNO_SET_THROW
);
2722 OUString aFormName
= "Standard";
2723 if( xFormsNC
->hasByName( aFormName
) )
2725 mxFormIC
.set( xFormsNC
->getByName( aFormName
), UNO_QUERY_THROW
);
2727 else if( mxModelFactory
.is() )
2729 Reference
< XForm
> xForm( mxModelFactory
->createInstance( "com.sun.star.form.component.Form" ), UNO_QUERY_THROW
);
2730 xFormsNC
->insertByName( aFormName
, Any( xForm
) );
2731 mxFormIC
.set( xForm
, UNO_QUERY_THROW
);
2734 catch (const Exception
& e
)
2736 SAL_WARN("oox", "exception creating Form: " << e
.Message
);
2738 // always clear the forms supplier to not try to create the form again
2739 mxFormsSupp
.clear();
2747 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */