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 "oox/helper/attributelist.hxx"
52 #include "oox/helper/binaryinputstream.hxx"
53 #include "oox/helper/containerhelper.hxx"
54 #include "oox/helper/graphichelper.hxx"
55 #include "oox/helper/propertymap.hxx"
56 #include "oox/ole/axbinarywriter.hxx"
60 using namespace ::com::sun::star
;
61 using namespace ::com::sun::star::awt
;
62 using namespace ::com::sun::star::beans
;
63 using namespace ::com::sun::star::container
;
64 using namespace ::com::sun::star::drawing
;
65 using namespace ::com::sun::star::form
;
66 using namespace ::com::sun::star::form::binding
;
67 using namespace ::com::sun::star::frame
;
68 using namespace ::com::sun::star::lang
;
69 using namespace ::com::sun::star::sheet
;
70 using namespace ::com::sun::star::style
;
71 using namespace ::com::sun::star::table
;
72 using namespace ::com::sun::star::uno
;
76 const sal_uInt32 COMCTL_ID_SIZE
= 0x12344321;
78 const sal_uInt32 COMCTL_ID_COMMONDATA
= 0xABCDEF01;
79 const sal_uInt32 COMCTL_COMMON_FLATBORDER
= 0x00000001;
80 const sal_uInt32 COMCTL_COMMON_ENABLED
= 0x00000002;
81 const sal_uInt32 COMCTL_COMMON_3DBORDER
= 0x00000004;
83 const sal_uInt32 COMCTL_ID_COMPLEXDATA
= 0xBDECDE1F;
84 const sal_uInt32 COMCTL_COMPLEX_FONT
= 0x00000001;
85 const sal_uInt32 COMCTL_COMPLEX_MOUSEICON
= 0x00000002;
87 const sal_uInt32 COMCTL_ID_SCROLLBAR_60
= 0x99470A83;
88 const sal_uInt32 COMCTL_SCROLLBAR_HOR
= 0x00000010;
90 const sal_uInt32 COMCTL_ID_PROGRESSBAR_50
= 0xE6E17E84;
91 const sal_uInt32 COMCTL_ID_PROGRESSBAR_60
= 0x97AB8A01;
93 // ----------------------------------------------------------------------------
95 const sal_uInt32 AX_CMDBUTTON_DEFFLAGS
= 0x0000001B;
96 const sal_uInt32 AX_LABEL_DEFFLAGS
= 0x0080001B;
97 const sal_uInt32 AX_IMAGE_DEFFLAGS
= 0x0000001B;
98 const sal_uInt32 AX_MORPHDATA_DEFFLAGS
= 0x2C80081B;
99 const sal_uInt32 AX_SPINBUTTON_DEFFLAGS
= 0x0000001B;
100 const sal_uInt32 AX_SCROLLBAR_DEFFLAGS
= 0x0000001B;
102 const sal_uInt16 AX_POS_TOPLEFT
= 0;
103 const sal_uInt16 AX_POS_TOP
= 1;
104 const sal_uInt16 AX_POS_TOPRIGHT
= 2;
105 const sal_uInt16 AX_POS_LEFT
= 3;
106 const sal_uInt16 AX_POS_CENTER
= 4;
107 const sal_uInt16 AX_POS_RIGHT
= 5;
108 const sal_uInt16 AX_POS_BOTTOMLEFT
= 6;
109 const sal_uInt16 AX_POS_BOTTOM
= 7;
110 const sal_uInt16 AX_POS_BOTTOMRIGHT
= 8;
112 #define AX_PICPOS_IMPL( label, image ) ((AX_POS_##label << 16) | AX_POS_##image)
113 const sal_uInt32 AX_PICPOS_LEFTTOP
= AX_PICPOS_IMPL( TOPRIGHT
, TOPLEFT
);
114 const sal_uInt32 AX_PICPOS_LEFTCENTER
= AX_PICPOS_IMPL( RIGHT
, LEFT
);
115 const sal_uInt32 AX_PICPOS_LEFTBOTTOM
= AX_PICPOS_IMPL( BOTTOMRIGHT
, BOTTOMLEFT
);
116 const sal_uInt32 AX_PICPOS_RIGHTTOP
= AX_PICPOS_IMPL( TOPLEFT
, TOPRIGHT
);
117 const sal_uInt32 AX_PICPOS_RIGHTCENTER
= AX_PICPOS_IMPL( LEFT
, RIGHT
);
118 const sal_uInt32 AX_PICPOS_RIGHTBOTTOM
= AX_PICPOS_IMPL( BOTTOMLEFT
, BOTTOMRIGHT
);
119 const sal_uInt32 AX_PICPOS_ABOVELEFT
= AX_PICPOS_IMPL( BOTTOMLEFT
, TOPLEFT
);
120 const sal_uInt32 AX_PICPOS_ABOVECENTER
= AX_PICPOS_IMPL( BOTTOM
, TOP
);
121 const sal_uInt32 AX_PICPOS_ABOVERIGHT
= AX_PICPOS_IMPL( BOTTOMRIGHT
, TOPRIGHT
);
122 const sal_uInt32 AX_PICPOS_BELOWLEFT
= AX_PICPOS_IMPL( TOPLEFT
, BOTTOMLEFT
);
123 const sal_uInt32 AX_PICPOS_BELOWCENTER
= AX_PICPOS_IMPL( TOP
, BOTTOM
);
124 const sal_uInt32 AX_PICPOS_BELOWRIGHT
= AX_PICPOS_IMPL( TOPRIGHT
, BOTTOMRIGHT
);
125 const sal_uInt32 AX_PICPOS_CENTER
= AX_PICPOS_IMPL( CENTER
, CENTER
);
126 #undef AX_PICPOS_IMPL
128 const sal_Int32 AX_MATCHENTRY_FIRSTLETTER
= 0;
129 const sal_Int32 AX_MATCHENTRY_COMPLETE
= 1;
130 const sal_Int32 AX_MATCHENTRY_NONE
= 2;
132 const sal_Int32 AX_ORIENTATION_AUTO
= -1;
133 const sal_Int32 AX_ORIENTATION_VERTICAL
= 0;
134 const sal_Int32 AX_ORIENTATION_HORIZONTAL
= 1;
136 const sal_Int32 AX_PROPTHUMB_ON
= -1;
138 const sal_uInt32 AX_TABSTRIP_TABS
= 0;
139 const sal_uInt32 AX_TABSTRIP_NONE
= 2;
141 const sal_uInt32 AX_CONTAINER_ENABLED
= 0x00000004;
142 const sal_uInt32 AX_CONTAINER_NOCLASSTABLE
= 0x00008000;
144 const sal_uInt32 AX_CONTAINER_DEFFLAGS
= 0x00000004;
146 const sal_Int32 AX_CONTAINER_DEFWIDTH
= 4000;
147 const sal_Int32 AX_CONTAINER_DEFHEIGHT
= 3000;
149 const sal_Int32 AX_CONTAINER_CYCLEALL
= 0;
151 const sal_Int32 AX_CONTAINER_SCR_NONE
= 0x00;
153 // ----------------------------------------------------------------------------
155 const sal_Int16 API_BORDER_NONE
= 0;
156 const sal_Int16 API_BORDER_SUNKEN
= 1;
157 const sal_Int16 API_BORDER_FLAT
= 2;
159 const sal_Int16 API_STATE_UNCHECKED
= 0;
160 const sal_Int16 API_STATE_CHECKED
= 1;
161 const sal_Int16 API_STATE_DONTKNOW
= 2;
163 // ----------------------------------------------------------------------------
165 /** Tries to extract a range address from a defined name. */
166 bool lclExtractRangeFromName( CellRangeAddress
& orRangeAddr
, const Reference
< XModel
>& rxDocModel
, const OUString
& rAddressString
)
170 PropertySet
aPropSet( rxDocModel
);
171 Reference
< XNameAccess
> xRangesNA( aPropSet
.getAnyProperty( PROP_NamedRanges
), UNO_QUERY_THROW
);
172 Reference
< XCellRangeReferrer
> xReferrer( xRangesNA
->getByName( rAddressString
), UNO_QUERY_THROW
);
173 Reference
< XCellRangeAddressable
> xAddressable( xReferrer
->getReferredCells(), UNO_QUERY_THROW
);
174 orRangeAddr
= xAddressable
->getRangeAddress();
177 catch (const Exception
& e
)
179 SAL_WARN("oox", "exception: " << e
.Message
);
184 bool lclExtractAddressFromName( CellAddress
& orAddress
, const Reference
< XModel
>& rxDocModel
, const OUString
& rAddressString
)
186 CellRangeAddress aRangeAddr
;
187 if( lclExtractRangeFromName( aRangeAddr
, rxDocModel
, rAddressString
) &&
188 (aRangeAddr
.StartColumn
== aRangeAddr
.EndColumn
) &&
189 (aRangeAddr
.StartRow
== aRangeAddr
.EndRow
) )
191 orAddress
.Sheet
= aRangeAddr
.Sheet
;
192 orAddress
.Column
= aRangeAddr
.StartColumn
;
193 orAddress
.Row
= aRangeAddr
.StartRow
;
199 void lclPrepareConverter( PropertySet
& rConverter
, const Reference
< XModel
>& rxDocModel
,
200 const OUString
& rAddressString
, sal_Int32 nRefSheet
, bool bRange
)
202 if( !rConverter
.is() ) try
204 Reference
< XMultiServiceFactory
> xModelFactory( rxDocModel
, UNO_QUERY_THROW
);
205 OUString aServiceName
= bRange
?
206 OUString( "com.sun.star.table.CellRangeAddressConversion" ) :
207 OUString( "com.sun.star.table.CellAddressConversion" );
208 rConverter
.set( xModelFactory
->createInstance( aServiceName
) );
210 catch (const Exception
& e
)
212 SAL_WARN("oox", "exception: " << e
.Message
);
214 rConverter
.setProperty( PROP_XLA1Representation
, rAddressString
);
215 rConverter
.setProperty( PROP_ReferenceSheet
, nRefSheet
);
220 // ============================================================================
222 ControlConverter::ControlConverter( const Reference
< XModel
>& rxDocModel
,
223 const GraphicHelper
& rGraphicHelper
, bool bDefaultColorBgr
) :
224 mxDocModel( rxDocModel
),
225 mrGraphicHelper( rGraphicHelper
),
226 mbDefaultColorBgr( bDefaultColorBgr
)
228 OSL_ENSURE( mxDocModel
.is(), "ControlConverter::ControlConverter - missing document model" );
231 ControlConverter::~ControlConverter()
235 // Generic conversion ---------------------------------------------------------
237 void ControlConverter::convertPosition( PropertyMap
& rPropMap
, const AxPairData
& rPos
) const
239 // position is given in 1/100 mm, UNO needs AppFont units
240 awt::Point aAppFontPos
= mrGraphicHelper
.convertHmmToAppFont( awt::Point( rPos
.first
, rPos
.second
) );
241 rPropMap
.setProperty( PROP_PositionX
, aAppFontPos
.X
);
242 rPropMap
.setProperty( PROP_PositionY
, aAppFontPos
.Y
);
245 void ControlConverter::convertSize( PropertyMap
& rPropMap
, const AxPairData
& rSize
) const
247 // size is given in 1/100 mm, UNO needs AppFont units
248 awt::Size aAppFontSize
= mrGraphicHelper
.convertHmmToAppFont( awt::Size( rSize
.first
, rSize
.second
) );
249 rPropMap
.setProperty( PROP_Width
, aAppFontSize
.Width
);
250 rPropMap
.setProperty( PROP_Height
, aAppFontSize
.Height
);
253 void ControlConverter::convertColor( PropertyMap
& rPropMap
, sal_Int32 nPropId
, sal_uInt32 nOleColor
) const
255 rPropMap
.setProperty( nPropId
, OleHelper::decodeOleColor( mrGraphicHelper
, nOleColor
, mbDefaultColorBgr
) );
258 void ControlConverter::convertToMSColor( PropertySet
& rPropSet
, sal_Int32 nPropId
, sal_uInt32
& nOleColor
, sal_uInt32 nDefault
) const
261 if (rPropSet
.getProperty( nRGB
, nPropId
))
262 nOleColor
= OleHelper::encodeOleColor( nRGB
);
264 nOleColor
= nDefault
;
266 void ControlConverter::convertPicture( PropertyMap
& rPropMap
, const StreamDataSequence
& rPicData
) const
268 if( rPicData
.hasElements() )
270 OUString aGraphicUrl
= mrGraphicHelper
.importGraphicObject( rPicData
);
271 if( !aGraphicUrl
.isEmpty() )
272 rPropMap
.setProperty( PROP_ImageURL
, aGraphicUrl
);
276 void ControlConverter::convertOrientation( PropertyMap
& rPropMap
, bool bHorizontal
) const
278 sal_Int32 nScrollOrient
= bHorizontal
? ScrollBarOrientation::HORIZONTAL
: ScrollBarOrientation::VERTICAL
;
279 rPropMap
.setProperty( PROP_Orientation
, nScrollOrient
);
282 void ControlConverter::convertToMSOrientation( PropertySet
& rPropSet
, bool& bHorizontal
) const
284 sal_Int32 nScrollOrient
= ScrollBarOrientation::HORIZONTAL
;
285 if ( rPropSet
.getProperty( nScrollOrient
, PROP_Orientation
) )
286 bHorizontal
= ( nScrollOrient
== ScrollBarOrientation::HORIZONTAL
);
289 void ControlConverter::convertVerticalAlign( PropertyMap
& rPropMap
, sal_Int32 nVerticalAlign
) const
291 VerticalAlignment eAlign
= VerticalAlignment_TOP
;
292 switch( nVerticalAlign
)
294 case XML_Top
: eAlign
= VerticalAlignment_TOP
; break;
295 case XML_Center
: eAlign
= VerticalAlignment_MIDDLE
; break;
296 case XML_Bottom
: eAlign
= VerticalAlignment_BOTTOM
; break;
298 rPropMap
.setProperty( PROP_VerticalAlign
, eAlign
);
301 void ControlConverter::convertScrollabilitySettings( PropertyMap
& rPropMap
,
302 const AxPairData
& rScrollPos
, const AxPairData
& rScrollArea
,
303 sal_Int32 nScrollBars
) const
305 awt::Size tmpSize
= mrGraphicHelper
.convertHmmToAppFont( awt::Size( rScrollArea
.first
, rScrollArea
.second
) );
306 awt::Point tmpPos
= mrGraphicHelper
.convertHmmToAppFont( awt::Point( rScrollPos
.first
, rScrollPos
.second
) );
307 rPropMap
.setProperty( PROP_ScrollHeight
, tmpSize
.Height
);
308 rPropMap
.setProperty( PROP_ScrollWidth
, tmpSize
.Width
);
309 rPropMap
.setProperty( PROP_ScrollTop
, tmpPos
.Y
);
310 rPropMap
.setProperty( PROP_ScrollLeft
, tmpPos
.X
);
311 rPropMap
.setProperty( PROP_HScroll
, ( nScrollBars
& 0x1 ) == 0x1 );
312 rPropMap
.setProperty( PROP_VScroll
, ( nScrollBars
& 0x2 ) == 0x2 );
315 void ControlConverter::convertScrollBar( PropertyMap
& rPropMap
,
316 sal_Int32 nMin
, sal_Int32 nMax
, sal_Int32 nPosition
,
317 sal_Int32 nSmallChange
, sal_Int32 nLargeChange
, bool bAwtModel
) const
319 rPropMap
.setProperty( PROP_ScrollValueMin
, ::std::min( nMin
, nMax
) );
320 rPropMap
.setProperty( PROP_ScrollValueMax
, ::std::max( nMin
, nMax
) );
321 rPropMap
.setProperty( PROP_LineIncrement
, nSmallChange
);
322 rPropMap
.setProperty( PROP_BlockIncrement
, nLargeChange
);
323 rPropMap
.setProperty( bAwtModel
? PROP_ScrollValue
: PROP_DefaultScrollValue
, nPosition
);
326 void ControlConverter::bindToSources( const Reference
< XControlModel
>& rxCtrlModel
,
327 const OUString
& rCtrlSource
, const OUString
& rRowSource
, sal_Int32 nRefSheet
) const
330 if( !rCtrlSource
.isEmpty() ) try
332 // first check if the XBindableValue interface is supported
333 Reference
< XBindableValue
> xBindable( rxCtrlModel
, UNO_QUERY_THROW
);
335 // convert address string to cell address struct
336 CellAddress aAddress
;
337 if( !lclExtractAddressFromName( aAddress
, mxDocModel
, rCtrlSource
) )
339 lclPrepareConverter( maAddressConverter
, mxDocModel
, rCtrlSource
, nRefSheet
, false );
340 if( !maAddressConverter
.getProperty( aAddress
, PROP_Address
) )
341 throw RuntimeException();
344 // create argument sequence
346 aValue
.Name
= "BoundCell";
347 aValue
.Value
<<= aAddress
;
348 Sequence
< Any
> aArgs( 1 );
349 aArgs
[ 0 ] <<= aValue
;
351 // create the CellValueBinding instance and set at the control model
352 Reference
< XMultiServiceFactory
> xModelFactory( mxDocModel
, UNO_QUERY_THROW
);
353 Reference
< XValueBinding
> xBinding( xModelFactory
->createInstanceWithArguments( "com.sun.star.table.CellValueBinding", aArgs
), UNO_QUERY_THROW
);
354 xBindable
->setValueBinding( xBinding
);
356 catch (const Exception
& e
)
358 SAL_WARN("oox", "exception: " << e
.Message
);
362 if( !rRowSource
.isEmpty() ) try
364 // first check if the XListEntrySink interface is supported
365 Reference
< XListEntrySink
> xEntrySink( rxCtrlModel
, UNO_QUERY_THROW
);
367 // convert address string to cell range address struct
368 CellRangeAddress aRangeAddr
;
369 if( !lclExtractRangeFromName( aRangeAddr
, mxDocModel
, rRowSource
) )
371 lclPrepareConverter( maRangeConverter
, mxDocModel
, rRowSource
, nRefSheet
, true );
372 if( !maRangeConverter
.getProperty( aRangeAddr
, PROP_Address
) )
373 throw RuntimeException();
376 // create argument sequence
378 aValue
.Name
= "CellRange";
379 aValue
.Value
<<= aRangeAddr
;
380 Sequence
< Any
> aArgs( 1 );
381 aArgs
[ 0 ] <<= aValue
;
383 // create the EntrySource instance and set at the control model
384 Reference
< XMultiServiceFactory
> xModelFactory( mxDocModel
, UNO_QUERY_THROW
);
385 Reference
< XListEntrySource
> xEntrySource( xModelFactory
->createInstanceWithArguments("com.sun.star.table.CellRangeListSource", aArgs
), UNO_QUERY_THROW
);
386 xEntrySink
->setListEntrySource( xEntrySource
);
388 catch (const Exception
& e
)
390 SAL_WARN("oox", "exception: " << e
.Message
);
394 // ActiveX (Forms 2.0) specific conversion ------------------------------------
396 void ControlConverter::convertAxBackground( PropertyMap
& rPropMap
,
397 sal_uInt32 nBackColor
, sal_uInt32 nFlags
, ApiTransparencyMode eTranspMode
) const
399 bool bOpaque
= getFlag( nFlags
, AX_FLAGS_OPAQUE
);
400 switch( eTranspMode
)
402 case API_TRANSPARENCY_NOTSUPPORTED
:
403 // fake transparency by using system window background if needed
404 convertColor( rPropMap
, PROP_BackgroundColor
, bOpaque
? nBackColor
: AX_SYSCOLOR_WINDOWBACK
);
406 case API_TRANSPARENCY_PAINTTRANSPARENT
:
407 rPropMap
.setProperty( PROP_PaintTransparent
, !bOpaque
);
408 // run-through intended!
409 case API_TRANSPARENCY_VOID
:
410 // keep transparency by leaving the (void) default property value
412 convertColor( rPropMap
, PROP_BackgroundColor
, nBackColor
);
417 void ControlConverter::convertAxBorder( PropertyMap
& rPropMap
,
418 sal_uInt32 nBorderColor
, sal_Int32 nBorderStyle
, sal_Int32 nSpecialEffect
) const
420 sal_Int16 nBorder
= (nBorderStyle
== AX_BORDERSTYLE_SINGLE
) ? API_BORDER_FLAT
:
421 ((nSpecialEffect
== AX_SPECIALEFFECT_FLAT
) ? API_BORDER_NONE
: API_BORDER_SUNKEN
);
422 rPropMap
.setProperty( PROP_Border
, nBorder
);
423 convertColor( rPropMap
, PROP_BorderColor
, nBorderColor
);
426 void ControlConverter::convertToAxBorder( PropertySet
& rPropSet
,
427 sal_uInt32
& nBorderColor
, sal_Int32
& nBorderStyle
, sal_Int32
& nSpecialEffect
) const
429 sal_Int16 nBorder
= API_BORDER_NONE
;
430 rPropSet
.getProperty( nBorder
, PROP_Border
);
431 nBorderStyle
= AX_BORDERSTYLE_NONE
;
432 nSpecialEffect
= AX_SPECIALEFFECT_FLAT
;
435 case API_BORDER_FLAT
:
436 nBorderStyle
= AX_BORDERSTYLE_SINGLE
;
438 case API_BORDER_SUNKEN
:
439 nSpecialEffect
= AX_SPECIALEFFECT_SUNKEN
;
440 case API_BORDER_NONE
:
444 convertToMSColor( rPropSet
, PROP_BorderColor
, nBorderColor
);
447 void ControlConverter::convertAxVisualEffect( PropertyMap
& rPropMap
, sal_Int32 nSpecialEffect
) const
449 sal_Int16 nVisualEffect
= (nSpecialEffect
== AX_SPECIALEFFECT_FLAT
) ? VisualEffect::FLAT
: VisualEffect::LOOK3D
;
450 rPropMap
.setProperty( PROP_VisualEffect
, nVisualEffect
);
453 void ControlConverter::convertToAxVisualEffect( PropertySet
& rPropSet
, sal_Int32
& nSpecialEffect
) const
455 sal_Int16 nVisualEffect
= AX_SPECIALEFFECT_FLAT
;
456 rPropSet
.getProperty( nVisualEffect
, PROP_VisualEffect
);
457 // is this appropriate AX_SPECIALEFFECT_XXXX value ?
458 if (nVisualEffect
== VisualEffect::LOOK3D
)
459 nSpecialEffect
= AX_SPECIALEFFECT_RAISED
;
462 void ControlConverter::convertAxPicture( PropertyMap
& rPropMap
, const StreamDataSequence
& rPicData
, sal_uInt32 nPicPos
) const
465 convertPicture( rPropMap
, rPicData
);
468 sal_Int16 nImagePos
= ImagePosition::LeftCenter
;
471 case AX_PICPOS_LEFTTOP
: nImagePos
= ImagePosition::LeftTop
; break;
472 case AX_PICPOS_LEFTCENTER
: nImagePos
= ImagePosition::LeftCenter
; break;
473 case AX_PICPOS_LEFTBOTTOM
: nImagePos
= ImagePosition::LeftBottom
; break;
474 case AX_PICPOS_RIGHTTOP
: nImagePos
= ImagePosition::RightTop
; break;
475 case AX_PICPOS_RIGHTCENTER
: nImagePos
= ImagePosition::RightCenter
; break;
476 case AX_PICPOS_RIGHTBOTTOM
: nImagePos
= ImagePosition::RightBottom
; break;
477 case AX_PICPOS_ABOVELEFT
: nImagePos
= ImagePosition::AboveLeft
; break;
478 case AX_PICPOS_ABOVECENTER
: nImagePos
= ImagePosition::AboveCenter
; break;
479 case AX_PICPOS_ABOVERIGHT
: nImagePos
= ImagePosition::AboveRight
; break;
480 case AX_PICPOS_BELOWLEFT
: nImagePos
= ImagePosition::BelowLeft
; break;
481 case AX_PICPOS_BELOWCENTER
: nImagePos
= ImagePosition::BelowCenter
; break;
482 case AX_PICPOS_BELOWRIGHT
: nImagePos
= ImagePosition::BelowRight
; break;
483 case AX_PICPOS_CENTER
: nImagePos
= ImagePosition::Centered
; break;
484 default: OSL_FAIL( "ControlConverter::convertAxPicture - unknown picture position" );
486 rPropMap
.setProperty( PROP_ImagePosition
, nImagePos
);
489 void ControlConverter::convertAxPicture( PropertyMap
& rPropMap
, const StreamDataSequence
& rPicData
,
490 sal_Int32 nPicSizeMode
, sal_Int32
/*nPicAlign*/, bool /*bPicTiling*/ ) const
493 convertPicture( rPropMap
, rPicData
);
495 // picture scale mode
496 sal_Int16 nScaleMode
= ImageScaleMode::NONE
;
497 switch( nPicSizeMode
)
499 case AX_PICSIZE_CLIP
: nScaleMode
= ImageScaleMode::NONE
; break;
500 case AX_PICSIZE_STRETCH
: nScaleMode
= ImageScaleMode::ANISOTROPIC
; break;
501 case AX_PICSIZE_ZOOM
: nScaleMode
= ImageScaleMode::ISOTROPIC
; break;
502 default: OSL_FAIL( "ControlConverter::convertAxPicture - unknown picture size mode" );
504 rPropMap
.setProperty( PROP_ScaleMode
, nScaleMode
);
507 void ControlConverter::convertAxState( PropertyMap
& rPropMap
,
508 const OUString
& rValue
, sal_Int32 nMultiSelect
, ApiDefaultStateMode eDefStateMode
, bool bAwtModel
) const
510 bool bBooleanState
= eDefStateMode
== API_DEFAULTSTATE_BOOLEAN
;
511 bool bSupportsTriState
= eDefStateMode
== API_DEFAULTSTATE_TRISTATE
;
514 sal_Int16 nState
= bSupportsTriState
? API_STATE_DONTKNOW
: API_STATE_UNCHECKED
;
515 if( rValue
.getLength() == 1 ) switch( rValue
[ 0 ] )
517 case '0': nState
= API_STATE_UNCHECKED
; break;
518 case '1': nState
= API_STATE_CHECKED
; break;
519 // any other string (also empty) means 'dontknow'
521 sal_Int32 nPropId
= bAwtModel
? PROP_State
: PROP_DefaultState
;
523 rPropMap
.setProperty( nPropId
, nState
!= API_STATE_UNCHECKED
);
525 rPropMap
.setProperty( nPropId
, nState
);
528 if( bSupportsTriState
)
529 rPropMap
.setProperty( PROP_TriState
, nMultiSelect
== AX_SELECTION_MULTI
);
532 void ControlConverter::convertToAxState( PropertySet
& rPropSet
,
533 OUString
& rValue
, sal_Int32
& nMultiSelect
, ApiDefaultStateMode eDefStateMode
, bool /*bAwtModel*/ ) const
535 bool bSupportsTriState
= eDefStateMode
== API_DEFAULTSTATE_TRISTATE
;
537 sal_Int16 nState
= API_STATE_DONTKNOW
;
539 sal_Bool bTmp
= sal_False
;
540 // need to use State for current state ( I think this is regardless of whether
541 // control is awt or not )
542 rPropSet
.getProperty( nState
, PROP_State
);
544 rValue
= OUString(); // empty e.g. 'don't know'
545 if ( nState
== API_STATE_UNCHECKED
)
546 rValue
= OUString('0');
547 else if ( nState
== API_STATE_CHECKED
)
548 rValue
= OUString('1');
551 if( bSupportsTriState
&& rPropSet
.getProperty( bTmp
, PROP_TriState
) )
552 nMultiSelect
= AX_SELECTION_MULTI
;
555 void ControlConverter::convertAxOrientation( PropertyMap
& rPropMap
,
556 const AxPairData
& rSize
, sal_Int32 nOrientation
) const
558 bool bHorizontal
= true;
559 switch( nOrientation
)
561 case AX_ORIENTATION_AUTO
: bHorizontal
= rSize
.first
> rSize
.second
; break;
562 case AX_ORIENTATION_VERTICAL
: bHorizontal
= false; break;
563 case AX_ORIENTATION_HORIZONTAL
: bHorizontal
= true; break;
564 default: OSL_FAIL( "ControlConverter::convertAxOrientation - unknown orientation" );
566 convertOrientation( rPropMap
, bHorizontal
);
569 void ControlConverter::convertToAxOrientation( PropertySet
& rPropSet
,
570 const AxPairData
& /*rSize*/, sal_Int32
& nOrientation
) const
572 bool bHorizontal
= true;
573 convertToMSOrientation( rPropSet
, bHorizontal
);
576 nOrientation
= AX_ORIENTATION_HORIZONTAL
;
578 nOrientation
= AX_ORIENTATION_VERTICAL
;
581 // ============================================================================
583 ControlModelBase::ControlModelBase() :
589 ControlModelBase::~ControlModelBase()
593 OUString
ControlModelBase::getServiceName() const
595 ApiControlType eCtrlType
= getControlType();
596 if( mbAwtModel
) switch( eCtrlType
)
598 case API_CONTROL_BUTTON
: return OUString( "com.sun.star.awt.UnoControlButtonModel" );
599 case API_CONTROL_FIXEDTEXT
: return OUString( "com.sun.star.awt.UnoControlFixedTextModel" );
600 case API_CONTROL_IMAGE
: return OUString( "com.sun.star.awt.UnoControlImageControlModel" );
601 case API_CONTROL_CHECKBOX
: return OUString( "com.sun.star.awt.UnoControlCheckBoxModel" );
602 case API_CONTROL_RADIOBUTTON
: return OUString( "com.sun.star.form.component.RadioButton" );
603 case API_CONTROL_EDIT
: return OUString( "com.sun.star.awt.UnoControlEditModel" );
604 case API_CONTROL_NUMERIC
: return OUString( "com.sun.star.awt.UnoControlNumericFieldModel" );
605 case API_CONTROL_LISTBOX
: return OUString( "com.sun.star.form.component.ListBox" );
606 case API_CONTROL_COMBOBOX
: return OUString( "com.sun.star.form.component.ComboBox" );
607 case API_CONTROL_SPINBUTTON
: return OUString( "com.sun.star.form.component.SpinButton" );
608 case API_CONTROL_SCROLLBAR
: return OUString( "com.sun.star.form.component.ScrollBar" );
609 case API_CONTROL_PROGRESSBAR
: return OUString( "com.sun.star.awt.UnoControlProgressBarModel" );
610 case API_CONTROL_GROUPBOX
: return OUString( "com.sun.star.form.component.GroupBox" );
611 case API_CONTROL_FRAME
: return OUString( "com.sun.star.awt.UnoFrameModel" );
612 case API_CONTROL_PAGE
: return OUString( "com.sun.star.awt.UnoPageModel" );
613 case API_CONTROL_MULTIPAGE
: return OUString( "com.sun.star.awt.UnoMultiPageModel" );
614 case API_CONTROL_DIALOG
: return OUString( "com.sun.star.awt.UnoControlDialogModel" );
615 default: OSL_FAIL( "ControlModelBase::getServiceName - no AWT model service supported" );
617 else switch( eCtrlType
)
619 case API_CONTROL_BUTTON
: return OUString( "com.sun.star.form.component.CommandButton" );
620 case API_CONTROL_FIXEDTEXT
: return OUString( "com.sun.star.form.component.FixedText" );
621 case API_CONTROL_IMAGE
: return OUString( "com.sun.star.form.component.DatabaseImageControl" );
622 case API_CONTROL_CHECKBOX
: return OUString( "com.sun.star.form.component.CheckBox" );
623 case API_CONTROL_RADIOBUTTON
: return OUString( "com.sun.star.form.component.RadioButton" );
624 case API_CONTROL_EDIT
: return OUString( "com.sun.star.form.component.TextField" );
625 case API_CONTROL_NUMERIC
: return OUString( "com.sun.star.form.component.NumericField" );
626 case API_CONTROL_LISTBOX
: return OUString( "com.sun.star.form.component.ListBox" );
627 case API_CONTROL_COMBOBOX
: return OUString( "com.sun.star.form.component.ComboBox" );
628 case API_CONTROL_SPINBUTTON
: return OUString( "com.sun.star.form.component.SpinButton" );
629 case API_CONTROL_SCROLLBAR
: return OUString( "com.sun.star.form.component.ScrollBar" );
630 case API_CONTROL_GROUPBOX
: return OUString( "com.sun.star.form.component.GroupBox" );
631 default: OSL_FAIL( "ControlModelBase::getServiceName - no form component service supported" );
636 void ControlModelBase::importProperty( sal_Int32
/*nPropId*/, const OUString
& /*rValue*/ )
640 void ControlModelBase::importPictureData( sal_Int32
/*nPropId*/, BinaryInputStream
& /*rInStrm*/ )
644 void ControlModelBase::convertProperties( PropertyMap
& /*rPropMap*/, const ControlConverter
& /*rConv*/ ) const
648 void ControlModelBase::convertFromProperties( PropertySet
& /*rPropMap*/, const ControlConverter
& /*rConv*/ )
652 void ControlModelBase::convertSize( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
654 rConv
.convertSize( rPropMap
, maSize
);
657 // ============================================================================
659 ComCtlModelBase::ComCtlModelBase( sal_uInt32 nDataPartId5
, sal_uInt32 nDataPartId6
,
660 sal_uInt16 nVersion
, bool bCommonPart
, bool bComplexPart
) :
661 maFontData( "Tahoma", 82500 ),
663 mnVersion( nVersion
),
664 mnDataPartId5( nDataPartId5
),
665 mnDataPartId6( nDataPartId6
),
666 mbCommonPart( bCommonPart
),
667 mbComplexPart( bComplexPart
)
671 bool ComCtlModelBase::importBinaryModel( BinaryInputStream
& rInStrm
)
673 // read initial size part and header of the control data part
674 if( importSizePart( rInStrm
) && readPartHeader( rInStrm
, getDataPartId(), mnVersion
) )
676 // if flags part exists, the first int32 of the data part contains its size
677 sal_uInt32 nCommonPartSize
= mbCommonPart
? rInStrm
.readuInt32() : 0;
678 // implementations must read the exact amount of data, stream must point to its end afterwards
679 importControlData( rInStrm
);
680 // read following parts
681 if( !rInStrm
.isEof() &&
682 (!mbCommonPart
|| importCommonPart( rInStrm
, nCommonPartSize
)) &&
683 (!mbComplexPart
|| importComplexPart( rInStrm
)) )
685 return !rInStrm
.isEof();
691 void ComCtlModelBase::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
694 rPropMap
.setProperty( PROP_Enabled
, getFlag( mnFlags
, COMCTL_COMMON_ENABLED
) );
695 ControlModelBase::convertProperties( rPropMap
, rConv
);
698 void ComCtlModelBase::importCommonExtraData( BinaryInputStream
& /*rInStrm*/ )
702 void ComCtlModelBase::importCommonTrailingData( BinaryInputStream
& /*rInStrm*/ )
706 sal_uInt32
ComCtlModelBase::getDataPartId() const
710 case COMCTL_VERSION_50
: return mnDataPartId5
;
711 case COMCTL_VERSION_60
: return mnDataPartId6
;
713 OSL_FAIL( "ComCtlObjectBase::getDataPartId - unxpected version" );
714 return SAL_MAX_UINT32
;
717 bool ComCtlModelBase::readPartHeader( BinaryInputStream
& rInStrm
, sal_uInt32 nExpPartId
, sal_uInt16 nExpMajor
, sal_uInt16 nExpMinor
)
719 // no idea if all this is correct...
721 sal_uInt16 nMajor
, nMinor
;
722 rInStrm
>> nPartId
>> nMinor
>> nMajor
;
723 bool bPartId
= nPartId
== nExpPartId
;
724 OSL_ENSURE( bPartId
, "ComCtlObjectBase::readPartHeader - unexpected part identifier" );
725 bool bVersion
= ((nExpMajor
== SAL_MAX_UINT16
) || (nExpMajor
== nMajor
)) && ((nExpMinor
== SAL_MAX_UINT16
) || (nExpMinor
== nMinor
));
726 OSL_ENSURE( bVersion
, "ComCtlObjectBase::readPartHeader - unexpected part version" );
727 return !rInStrm
.isEof() && bPartId
&& bVersion
;
730 bool ComCtlModelBase::importSizePart( BinaryInputStream
& rInStrm
)
732 if( readPartHeader( rInStrm
, COMCTL_ID_SIZE
, 0, 8 ) )
734 rInStrm
>> maSize
.first
>> maSize
.second
;
735 return !rInStrm
.isEof();
740 bool ComCtlModelBase::importCommonPart( BinaryInputStream
& rInStrm
, sal_uInt32 nPartSize
)
742 sal_Int64 nEndPos
= rInStrm
.tell() + nPartSize
;
743 if( (nPartSize
>= 16) && readPartHeader( rInStrm
, COMCTL_ID_COMMONDATA
, 5, 0 ) )
747 // implementations may read less than the exact amount of data
748 importCommonExtraData( rInStrm
);
749 rInStrm
.seek( nEndPos
);
750 // implementations must read the exact amount of data, stream must point to its end afterwards
751 importCommonTrailingData( rInStrm
);
752 return !rInStrm
.isEof();
757 bool ComCtlModelBase::importComplexPart( BinaryInputStream
& rInStrm
)
759 if( readPartHeader( rInStrm
, COMCTL_ID_COMPLEXDATA
, 5, 1 ) )
761 sal_uInt32 nContFlags
;
762 rInStrm
>> nContFlags
;
764 (!getFlag( nContFlags
, COMCTL_COMPLEX_FONT
) || OleHelper::importStdFont( maFontData
, rInStrm
, true )) &&
765 (!getFlag( nContFlags
, COMCTL_COMPLEX_MOUSEICON
) || OleHelper::importStdPic( maMouseIcon
, rInStrm
, true ));
766 return bReadOk
&& !rInStrm
.isEof();
771 // ============================================================================
773 ComCtlScrollBarModel::ComCtlScrollBarModel( sal_uInt16 nVersion
) :
774 ComCtlModelBase( SAL_MAX_UINT32
, COMCTL_ID_SCROLLBAR_60
, nVersion
, true, true ),
775 mnScrollBarFlags( 0x00000011 ),
784 ApiControlType
ComCtlScrollBarModel::getControlType() const
786 return API_CONTROL_SCROLLBAR
;
789 void ComCtlScrollBarModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
791 rPropMap
.setProperty( PROP_Border
, API_BORDER_NONE
);
792 rConv
.convertOrientation( rPropMap
, getFlag( mnScrollBarFlags
, COMCTL_SCROLLBAR_HOR
) );
793 rConv
.convertScrollBar( rPropMap
, mnMin
, mnMax
, mnPosition
, mnSmallChange
, mnLargeChange
, mbAwtModel
);
794 ComCtlModelBase::convertProperties( rPropMap
, rConv
);
797 void ComCtlScrollBarModel::importControlData( BinaryInputStream
& rInStrm
)
799 rInStrm
>> mnScrollBarFlags
>> mnLargeChange
>> mnSmallChange
>> mnMin
>> mnMax
>> mnPosition
;
802 // ============================================================================
804 ComCtlProgressBarModel::ComCtlProgressBarModel( sal_uInt16 nVersion
) :
805 ComCtlModelBase( COMCTL_ID_PROGRESSBAR_50
, COMCTL_ID_PROGRESSBAR_60
, nVersion
, true, true ),
813 ApiControlType
ComCtlProgressBarModel::getControlType() const
815 return API_CONTROL_PROGRESSBAR
;
818 void ComCtlProgressBarModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
820 sal_uInt16 nBorder
= getFlag( mnFlags
, COMCTL_COMMON_3DBORDER
) ? API_BORDER_SUNKEN
:
821 (getFlag( mnFlags
, COMCTL_COMMON_FLATBORDER
) ? API_BORDER_FLAT
: API_BORDER_NONE
);
822 rPropMap
.setProperty( PROP_Border
, nBorder
);
823 rPropMap
.setProperty( PROP_ProgressValueMin
, getLimitedValue
< sal_Int32
, double >( ::std::min( mfMin
, mfMax
), 0.0, SAL_MAX_INT32
) );
824 rPropMap
.setProperty( PROP_ProgressValueMax
, getLimitedValue
< sal_Int32
, double >( ::std::max( mfMin
, mfMax
), 0.0, SAL_MAX_INT32
) );
825 // ComCtl model does not provide current value?
826 ComCtlModelBase::convertProperties( rPropMap
, rConv
);
829 void ComCtlProgressBarModel::importControlData( BinaryInputStream
& rInStrm
)
831 rInStrm
>> mfMin
>> mfMax
;
832 if( mnVersion
== COMCTL_VERSION_60
)
833 rInStrm
>> mnVertical
>> mnSmooth
;
836 // ============================================================================
838 AxControlModelBase::AxControlModelBase()
842 void AxControlModelBase::importProperty( sal_Int32 nPropId
, const OUString
& rValue
)
846 // size of the control shape: format is "width;height"
849 sal_Int32 nSepPos
= rValue
.indexOf( ';' );
850 OSL_ENSURE( nSepPos
>= 0, "AxControlModelBase::importProperty - missing separator in 'Size' property" );
853 maSize
.first
= rValue
.copy( 0, nSepPos
).toInt32();
854 maSize
.second
= rValue
.copy( nSepPos
+ 1 ).toInt32();
861 // ============================================================================
863 AxFontDataModel::AxFontDataModel( bool bSupportsAlign
) :
864 mbSupportsAlign( bSupportsAlign
)
868 void AxFontDataModel::importProperty( sal_Int32 nPropId
, const OUString
& rValue
)
872 case XML_FontName
: maFontData
.maFontName
= rValue
; break;
873 case XML_FontEffects
: maFontData
.mnFontEffects
= AttributeConversion::decodeUnsigned( rValue
); break;
874 case XML_FontHeight
: maFontData
.mnFontHeight
= AttributeConversion::decodeInteger( rValue
); break;
875 case XML_FontCharSet
: maFontData
.mnFontCharSet
= AttributeConversion::decodeInteger( rValue
); break;
876 case XML_ParagraphAlign
: maFontData
.mnHorAlign
= AttributeConversion::decodeInteger( rValue
); break;
877 default: AxControlModelBase::importProperty( nPropId
, rValue
);
881 bool AxFontDataModel::importBinaryModel( BinaryInputStream
& rInStrm
)
883 return maFontData
.importBinaryModel( rInStrm
);
886 void AxFontDataModel::exportBinaryModel( BinaryOutputStream
& rOutStrm
)
888 maFontData
.exportBinaryModel( rOutStrm
);
890 void AxFontDataModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
893 if( !maFontData
.maFontName
.isEmpty() )
894 rPropMap
.setProperty( PROP_FontName
, maFontData
.maFontName
);
897 rPropMap
.setProperty( PROP_FontWeight
, getFlagValue( maFontData
.mnFontEffects
, AX_FONTDATA_BOLD
, awt::FontWeight::BOLD
, awt::FontWeight::NORMAL
) );
898 rPropMap
.setProperty( PROP_FontSlant
, getFlagValue
< sal_Int16
>( maFontData
.mnFontEffects
, AX_FONTDATA_ITALIC
, FontSlant_ITALIC
, FontSlant_NONE
) );
899 rPropMap
.setProperty( PROP_FontUnderline
, getFlagValue( maFontData
.mnFontEffects
, AX_FONTDATA_UNDERLINE
, maFontData
.mbDblUnderline
? awt::FontUnderline::DOUBLE
: awt::FontUnderline::SINGLE
, awt::FontUnderline::NONE
) );
900 rPropMap
.setProperty( PROP_FontStrikeout
, getFlagValue( maFontData
.mnFontEffects
, AX_FONTDATA_STRIKEOUT
, awt::FontStrikeout::SINGLE
, awt::FontStrikeout::NONE
) );
901 rPropMap
.setProperty( PROP_FontHeight
, maFontData
.getHeightPoints() );
903 // font character set
904 rtl_TextEncoding eFontEnc
= RTL_TEXTENCODING_DONTKNOW
;
905 if( (0 <= maFontData
.mnFontCharSet
) && (maFontData
.mnFontCharSet
<= SAL_MAX_UINT8
) )
906 eFontEnc
= rtl_getTextEncodingFromWindowsCharset( static_cast< sal_uInt8
>( maFontData
.mnFontCharSet
) );
907 if( eFontEnc
!= RTL_TEXTENCODING_DONTKNOW
)
908 rPropMap
.setProperty( PROP_FontCharset
, static_cast< sal_Int16
>( eFontEnc
) );
911 if( mbSupportsAlign
)
913 sal_Int32 nAlign
= awt::TextAlign::LEFT
;
914 switch( maFontData
.mnHorAlign
)
916 case AX_FONTDATA_LEFT
: nAlign
= awt::TextAlign::LEFT
; break;
917 case AX_FONTDATA_RIGHT
: nAlign
= awt::TextAlign::RIGHT
; break;
918 case AX_FONTDATA_CENTER
: nAlign
= awt::TextAlign::CENTER
; break;
919 default: OSL_FAIL( "AxFontDataModel::convertProperties - unknown text alignment" );
921 // form controls expect short value
922 rPropMap
.setProperty( PROP_Align
, static_cast< sal_Int16
>( nAlign
) );
925 // process base class properties
926 AxControlModelBase::convertProperties( rPropMap
, rConv
);
929 void AxFontDataModel::convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& /*rConv */)
931 rPropSet
.getProperty( maFontData
.maFontName
, PROP_FontName
);
932 float fontWeight
= (float)0;
933 if ( rPropSet
.getProperty(fontWeight
, PROP_FontWeight
) )
934 setFlag( maFontData
.mnFontEffects
, AX_FONTDATA_BOLD
, ( fontWeight
== awt::FontWeight::BOLD
) );
935 sal_Int16 nSlant
= FontSlant_NONE
;
936 if ( rPropSet
.getProperty( nSlant
, PROP_FontSlant
) )
937 setFlag( maFontData
.mnFontEffects
, AX_FONTDATA_ITALIC
, ( nSlant
== FontSlant_ITALIC
) );
939 sal_Int16 nUnderLine
= awt::FontUnderline::NONE
;
940 if ( rPropSet
.getProperty( nUnderLine
, PROP_FontUnderline
) )
941 setFlag( maFontData
.mnFontEffects
, AX_FONTDATA_UNDERLINE
, nUnderLine
!= awt::FontUnderline::NONE
);
942 sal_Int16 nStrikeout
= awt::FontStrikeout::NONE
;
943 if ( rPropSet
.getProperty( nStrikeout
, PROP_FontStrikeout
) )
944 setFlag( maFontData
.mnFontEffects
, AX_FONTDATA_STRIKEOUT
, nStrikeout
!= awt::FontStrikeout::NONE
);
946 float fontHeight
= 0.0;
947 if ( rPropSet
.getProperty( fontHeight
, PROP_FontHeight
) )
948 maFontData
.setHeightPoints( static_cast< sal_Int16
>( fontHeight
) );
950 // TODO - handle textencoding
951 sal_Int16 nAlign
= 0;
952 if ( rPropSet
.getProperty( nAlign
, PROP_Align
) )
956 case awt::TextAlign::LEFT
: maFontData
.mnHorAlign
= AX_FONTDATA_LEFT
; break;
957 case awt::TextAlign::RIGHT
: maFontData
.mnHorAlign
= AX_FONTDATA_RIGHT
; break;
958 case awt::TextAlign::CENTER
: maFontData
.mnHorAlign
= AX_FONTDATA_CENTER
; break;
959 default: OSL_FAIL( "AxFontDataModel::convertFromProperties - unknown text alignment" );
964 // ============================================================================
966 AxCommandButtonModel::AxCommandButtonModel() :
967 mnTextColor( AX_SYSCOLOR_BUTTONTEXT
),
968 mnBackColor( AX_SYSCOLOR_BUTTONFACE
),
969 mnFlags( AX_CMDBUTTON_DEFFLAGS
),
970 mnPicturePos( AX_PICPOS_ABOVECENTER
),
971 mnVerticalAlign( XML_Center
),
972 mbFocusOnClick( true )
976 void AxCommandButtonModel::importProperty( sal_Int32 nPropId
, const OUString
& rValue
)
980 case XML_Caption
: maCaption
= rValue
; break;
981 case XML_ForeColor
: mnTextColor
= AttributeConversion::decodeUnsigned( rValue
); break;
982 case XML_BackColor
: mnBackColor
= AttributeConversion::decodeUnsigned( rValue
); break;
983 case XML_VariousPropertyBits
: mnFlags
= AttributeConversion::decodeUnsigned( rValue
); break;
984 case XML_PicturePosition
: mnPicturePos
= AttributeConversion::decodeUnsigned( rValue
); break;
985 case XML_TakeFocusOnClick
: mbFocusOnClick
= AttributeConversion::decodeInteger( rValue
) != 0; break;
986 default: AxFontDataModel::importProperty( nPropId
, rValue
);
990 void AxCommandButtonModel::importPictureData( sal_Int32 nPropId
, BinaryInputStream
& rInStrm
)
994 case XML_Picture
: OleHelper::importStdPic( maPictureData
, rInStrm
, true ); break;
995 default: AxFontDataModel::importPictureData( nPropId
, rInStrm
);
999 bool AxCommandButtonModel::importBinaryModel( BinaryInputStream
& rInStrm
)
1001 AxBinaryPropertyReader
aReader( rInStrm
);
1002 aReader
.readIntProperty
< sal_uInt32
>( mnTextColor
);
1003 aReader
.readIntProperty
< sal_uInt32
>( mnBackColor
);
1004 aReader
.readIntProperty
< sal_uInt32
>( mnFlags
);
1005 aReader
.readStringProperty( maCaption
);
1006 aReader
.readIntProperty
< sal_uInt32
>( mnPicturePos
);
1007 aReader
.readPairProperty( maSize
);
1008 aReader
.skipIntProperty
< sal_uInt8
>(); // mouse pointer
1009 aReader
.readPictureProperty( maPictureData
);
1010 aReader
.skipIntProperty
< sal_uInt16
>(); // accelerator
1011 aReader
.readBoolProperty( mbFocusOnClick
, true ); // binary flag means "do not take focus"
1012 aReader
.skipPictureProperty(); // mouse icon
1013 return aReader
.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm
);
1017 void AxCommandButtonModel::exportBinaryModel( BinaryOutputStream
& rOutStrm
)
1019 AxBinaryPropertyWriter
aWriter( rOutStrm
);
1020 aWriter
.writeIntProperty
< sal_uInt32
>( mnTextColor
);
1022 aWriter
.writeIntProperty
< sal_uInt32
>( mnBackColor
);
1024 aWriter
.skipProperty(); // default backcolour
1025 aWriter
.writeIntProperty
< sal_uInt32
>( mnFlags
);
1026 aWriter
.writeStringProperty( maCaption
);
1027 aWriter
.skipProperty(); // pict pos
1028 aWriter
.writePairProperty( maSize
);
1029 aWriter
.skipProperty(); // mouse pointer
1030 aWriter
.skipProperty(); // picture data
1031 aWriter
.skipProperty(); // accelerator
1032 aWriter
.writeBoolProperty( mbFocusOnClick
); // binary flag means "do not take focus"
1033 aWriter
.skipProperty(); // mouse icon
1034 aWriter
.finalizeExport();
1035 AxFontDataModel::exportBinaryModel( rOutStrm
);
1038 void AxCommandButtonModel::exportCompObj( BinaryOutputStream
& rOutStream
)
1040 // should be able to replace this hardcoded foo with
1041 // proper export info from MS-OLEDS spec.
1042 static sal_uInt8
const aCompObj
[] = {
1043 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1044 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x32, 0x05, 0xD7,
1045 0x69, 0xCE, 0xCD, 0x11, 0xA7, 0x77, 0x00, 0xDD,
1046 0x01, 0x14, 0x3C, 0x57, 0x22, 0x00, 0x00, 0x00,
1047 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1048 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6d, 0x73, 0x20,
1049 0x32, 0x2e, 0x30, 0x20, 0x43, 0x6F, 0x6D, 0x6D,
1050 0x61, 0x6E, 0x64, 0x42, 0x75, 0x74, 0x74, 0x6F,
1051 0x6E, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
1052 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
1053 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x16, 0x00,
1054 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
1055 0x43, 0x6F, 0x6D, 0x6D, 0x61, 0x6E, 0x64, 0x42,
1056 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00,
1057 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
1058 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1060 rOutStream
.writeMemory( aCompObj
, sizeof( aCompObj
) );
1063 ApiControlType
AxCommandButtonModel::getControlType() const
1065 return API_CONTROL_BUTTON
;
1068 void AxCommandButtonModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
1070 rPropMap
.setProperty( PROP_Label
, maCaption
);
1071 rPropMap
.setProperty( PROP_Enabled
, getFlag( mnFlags
, AX_FLAGS_ENABLED
) );
1072 rPropMap
.setProperty( PROP_MultiLine
, getFlag( mnFlags
, AX_FLAGS_WORDWRAP
) );
1073 rPropMap
.setProperty( PROP_FocusOnClick
, mbFocusOnClick
);
1074 rConv
.convertColor( rPropMap
, PROP_TextColor
, mnTextColor
);
1075 rConv
.convertVerticalAlign( rPropMap
, mnVerticalAlign
);
1076 rConv
.convertAxBackground( rPropMap
, mnBackColor
, mnFlags
, API_TRANSPARENCY_NOTSUPPORTED
);
1077 rConv
.convertAxPicture( rPropMap
, maPictureData
, mnPicturePos
);
1078 AxFontDataModel::convertProperties( rPropMap
, rConv
);
1081 void AxCommandButtonModel::convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
)
1083 rPropSet
.getProperty( maCaption
, PROP_Label
);
1085 if ( rPropSet
.getProperty( bRes
, PROP_Enabled
) )
1086 setFlag( mnFlags
, AX_FLAGS_ENABLED
, bRes
);
1087 if ( rPropSet
.getProperty( bRes
, PROP_MultiLine
) )
1088 setFlag( mnFlags
, AX_FLAGS_WORDWRAP
, bRes
);
1089 rPropSet
.getProperty( mbFocusOnClick
, PROP_FocusOnClick
);
1091 rConv
.convertToMSColor( rPropSet
, PROP_TextColor
, mnTextColor
);
1092 rConv
.convertToMSColor( rPropSet
, PROP_BackgroundColor
, mnBackColor
);
1094 AxFontDataModel::convertFromProperties( rPropSet
, rConv
);
1096 // ============================================================================
1098 AxLabelModel::AxLabelModel() :
1099 mnTextColor( AX_SYSCOLOR_BUTTONTEXT
),
1100 mnBackColor( AX_SYSCOLOR_BUTTONFACE
),
1101 mnFlags( AX_LABEL_DEFFLAGS
),
1102 mnBorderColor( AX_SYSCOLOR_WINDOWFRAME
),
1103 mnBorderStyle( AX_BORDERSTYLE_NONE
),
1104 mnSpecialEffect( AX_SPECIALEFFECT_FLAT
),
1105 mnVerticalAlign( XML_Top
)
1109 void AxLabelModel::importProperty( sal_Int32 nPropId
, const OUString
& rValue
)
1113 case XML_Caption
: maCaption
= rValue
; break;
1114 case XML_ForeColor
: mnTextColor
= AttributeConversion::decodeUnsigned( rValue
); break;
1115 case XML_BackColor
: mnBackColor
= AttributeConversion::decodeUnsigned( rValue
); break;
1116 case XML_VariousPropertyBits
: mnFlags
= AttributeConversion::decodeUnsigned( rValue
); break;
1117 case XML_BorderColor
: mnBorderColor
= AttributeConversion::decodeUnsigned( rValue
); break;
1118 case XML_BorderStyle
: mnBorderStyle
= AttributeConversion::decodeInteger( rValue
); break;
1119 case XML_SpecialEffect
: mnSpecialEffect
= AttributeConversion::decodeInteger( rValue
); break;
1120 default: AxFontDataModel::importProperty( nPropId
, rValue
);
1124 bool AxLabelModel::importBinaryModel( BinaryInputStream
& rInStrm
)
1126 AxBinaryPropertyReader
aReader( rInStrm
);
1127 aReader
.readIntProperty
< sal_uInt32
>( mnTextColor
);
1128 aReader
.readIntProperty
< sal_uInt32
>( mnBackColor
);
1129 aReader
.readIntProperty
< sal_uInt32
>( mnFlags
);
1130 aReader
.readStringProperty( maCaption
);
1131 aReader
.skipIntProperty
< sal_uInt32
>(); // picture position
1132 aReader
.readPairProperty( maSize
);
1133 aReader
.skipIntProperty
< sal_uInt8
>(); // mouse pointer
1134 aReader
.readIntProperty
< sal_uInt32
>( mnBorderColor
);
1135 aReader
.readIntProperty
< sal_uInt16
>( mnBorderStyle
);
1136 aReader
.readIntProperty
< sal_uInt16
>( mnSpecialEffect
);
1137 aReader
.skipPictureProperty(); // picture
1138 aReader
.skipIntProperty
< sal_uInt16
>(); // accelerator
1139 aReader
.skipPictureProperty(); // mouse icon
1140 return aReader
.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm
);
1143 void AxLabelModel::exportBinaryModel( BinaryOutputStream
& rOutStrm
)
1145 AxBinaryPropertyWriter
aWriter( rOutStrm
);
1146 aWriter
.writeIntProperty
< sal_uInt32
>( mnTextColor
);
1148 aWriter
.writeIntProperty
< sal_uInt32
>( mnBackColor
);
1150 // if mnBackColor == 0 then it's the libreoffice default backcolour is
1151 // the MSO Label default which is AX_SYSCOLOR_BUTTONFACE
1152 aWriter
.writeIntProperty
< sal_uInt32
>( AX_SYSCOLOR_WINDOWBACK
);
1153 aWriter
.writeIntProperty
< sal_uInt32
>( mnFlags
);
1154 aWriter
.writeStringProperty( maCaption
);
1155 aWriter
.skipProperty(); // picture position
1156 aWriter
.writePairProperty( maSize
);
1157 aWriter
.skipProperty(); // mouse pointer
1158 aWriter
.writeIntProperty
< sal_uInt32
>( mnBorderColor
);
1159 aWriter
.writeIntProperty
< sal_uInt16
>( mnBorderStyle
);
1160 aWriter
.writeIntProperty
< sal_uInt16
>( mnSpecialEffect
);
1161 aWriter
.skipProperty(); // picture
1162 aWriter
.skipProperty(); // accelerator
1163 aWriter
.skipProperty(); // mouse icon
1164 aWriter
.finalizeExport();
1165 AxFontDataModel::exportBinaryModel( rOutStrm
);
1168 void AxLabelModel::convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
)
1170 rPropSet
.getProperty( maCaption
, PROP_Label
);
1172 if ( rPropSet
.getProperty( bRes
, PROP_Enabled
) )
1173 setFlag( mnFlags
, AX_FLAGS_ENABLED
, bRes
);
1174 if ( rPropSet
.getProperty( bRes
, PROP_MultiLine
) )
1175 setFlag( mnFlags
, AX_FLAGS_WORDWRAP
, bRes
);
1177 rConv
.convertToMSColor( rPropSet
, PROP_TextColor
, mnTextColor
);
1178 // VerticleAlign doesn't seem to be read from binary
1180 // not sure about background color, how do we decide when to set
1181 // AX_FLAGS_OPAQUE ?
1182 rConv
.convertToMSColor( rPropSet
, PROP_BackgroundColor
, mnBackColor
);
1183 rConv
.convertToAxBorder( rPropSet
, mnBorderColor
, mnBorderStyle
, mnSpecialEffect
);
1185 AxFontDataModel::convertFromProperties( rPropSet
, rConv
);
1188 void AxLabelModel::exportCompObj( BinaryOutputStream
& rOutStream
)
1190 // should be able to replace this hardcoded foo with
1191 // proper export info from MS-OLEDS spec.
1192 static sal_uInt8
const aCompObj
[] = {
1193 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1194 0xFF, 0xFF, 0xFF, 0xFF, 0x23, 0x9E, 0x8C, 0x97,
1195 0xB0, 0xD4, 0xCE, 0x11, 0xBF, 0x2D, 0x00, 0xAA,
1196 0x00, 0x3F, 0x40, 0xD0, 0x1A, 0x00, 0x00, 0x00,
1197 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1198 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1199 0x32, 0x2E, 0x30, 0x20, 0x4C, 0x61, 0x62, 0x65,
1200 0x6C, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
1201 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
1202 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x0E, 0x00,
1203 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
1204 0x4C, 0x61, 0x62, 0x65, 0x6C, 0x2E, 0x31, 0x00,
1205 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
1206 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1208 rOutStream
.writeMemory( aCompObj
, sizeof( aCompObj
) );
1211 ApiControlType
AxLabelModel::getControlType() const
1213 return API_CONTROL_FIXEDTEXT
;
1216 void AxLabelModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
1218 rPropMap
.setProperty( PROP_Label
, maCaption
);
1219 rPropMap
.setProperty( PROP_Enabled
, getFlag( mnFlags
, AX_FLAGS_ENABLED
) );
1220 rPropMap
.setProperty( PROP_MultiLine
, getFlag( mnFlags
, AX_FLAGS_WORDWRAP
) );
1221 rConv
.convertColor( rPropMap
, PROP_TextColor
, mnTextColor
);
1222 rConv
.convertVerticalAlign( rPropMap
, mnVerticalAlign
);
1223 rConv
.convertAxBackground( rPropMap
, mnBackColor
, mnFlags
, API_TRANSPARENCY_VOID
);
1224 rConv
.convertAxBorder( rPropMap
, mnBorderColor
, mnBorderStyle
, mnSpecialEffect
);
1225 AxFontDataModel::convertProperties( rPropMap
, rConv
);
1228 // ============================================================================
1230 AxImageModel::AxImageModel() :
1231 mnBackColor( AX_SYSCOLOR_BUTTONFACE
),
1232 mnFlags( AX_IMAGE_DEFFLAGS
),
1233 mnBorderColor( AX_SYSCOLOR_WINDOWFRAME
),
1234 mnBorderStyle( AX_BORDERSTYLE_SINGLE
),
1235 mnSpecialEffect( AX_SPECIALEFFECT_FLAT
),
1236 mnPicSizeMode( AX_PICSIZE_CLIP
),
1237 mnPicAlign( AX_PICALIGN_CENTER
),
1238 mbPicTiling( false )
1242 void AxImageModel::importProperty( sal_Int32 nPropId
, const OUString
& rValue
)
1246 case XML_BackColor
: mnBackColor
= AttributeConversion::decodeUnsigned( rValue
); break;
1247 case XML_VariousPropertyBits
: mnFlags
= AttributeConversion::decodeUnsigned( rValue
); break;
1248 case XML_BorderColor
: mnBorderColor
= AttributeConversion::decodeUnsigned( rValue
); break;
1249 case XML_BorderStyle
: mnBorderStyle
= AttributeConversion::decodeInteger( rValue
); break;
1250 case XML_SpecialEffect
: mnSpecialEffect
= AttributeConversion::decodeInteger( rValue
); break;
1251 case XML_SizeMode
: mnPicSizeMode
= AttributeConversion::decodeInteger( rValue
); break;
1252 case XML_PictureAlignment
: mnPicAlign
= AttributeConversion::decodeInteger( rValue
); break;
1253 case XML_PictureTiling
: mbPicTiling
= AttributeConversion::decodeInteger( rValue
) != 0; break;
1254 default: AxControlModelBase::importProperty( nPropId
, rValue
);
1258 void AxImageModel::importPictureData( sal_Int32 nPropId
, BinaryInputStream
& rInStrm
)
1262 case XML_Picture
: OleHelper::importStdPic( maPictureData
, rInStrm
, true ); break;
1263 default: AxControlModelBase::importPictureData( nPropId
, rInStrm
);
1267 bool AxImageModel::importBinaryModel( BinaryInputStream
& rInStrm
)
1269 AxBinaryPropertyReader
aReader( rInStrm
);
1270 aReader
.skipUndefinedProperty();
1271 aReader
.skipUndefinedProperty();
1272 aReader
.skipBoolProperty(); // auto-size
1273 aReader
.readIntProperty
< sal_uInt32
>( mnBorderColor
);
1274 aReader
.readIntProperty
< sal_uInt32
>( mnBackColor
);
1275 aReader
.readIntProperty
< sal_uInt8
>( mnBorderStyle
);
1276 aReader
.skipIntProperty
< sal_uInt8
>(); // mouse pointer
1277 aReader
.readIntProperty
< sal_uInt8
>( mnPicSizeMode
);
1278 aReader
.readIntProperty
< sal_uInt8
>( mnSpecialEffect
);
1279 aReader
.readPairProperty( maSize
);
1280 aReader
.readPictureProperty( maPictureData
);
1281 aReader
.readIntProperty
< sal_uInt8
>( mnPicAlign
);
1282 aReader
.readBoolProperty( mbPicTiling
);
1283 aReader
.readIntProperty
< sal_uInt32
>( mnFlags
);
1284 aReader
.skipPictureProperty(); // mouse icon
1285 return aReader
.finalizeImport();
1288 void AxImageModel::exportBinaryModel( BinaryOutputStream
& rOutStrm
)
1290 AxBinaryPropertyWriter
aWriter( rOutStrm
);
1291 aWriter
.skipProperty(); //undefined
1292 aWriter
.skipProperty(); //undefined
1293 aWriter
.skipProperty(); //auto-size
1294 aWriter
.writeIntProperty
< sal_uInt32
>( mnBorderColor
);
1296 aWriter
.writeIntProperty
< sal_uInt32
>( mnBackColor
);
1298 aWriter
.skipProperty(); // default backcolour
1299 aWriter
.writeIntProperty
< sal_uInt8
>( mnBorderStyle
);
1300 aWriter
.skipProperty(); // mouse pointer
1301 aWriter
.writeIntProperty
< sal_uInt8
>( mnPicSizeMode
);
1302 aWriter
.writeIntProperty
< sal_uInt8
>( mnSpecialEffect
);
1303 aWriter
.writePairProperty( maSize
);
1304 aWriter
.skipProperty(); //maPictureData );
1305 aWriter
.writeIntProperty
< sal_uInt8
>( mnPicAlign
);
1306 aWriter
.writeBoolProperty( mbPicTiling
);
1307 aWriter
.writeIntProperty
< sal_uInt32
>( mnFlags
);
1308 aWriter
.skipProperty(); // mouse icon
1309 aWriter
.finalizeExport();
1312 void AxImageModel::exportCompObj( BinaryOutputStream
& rOutStream
)
1314 // should be able to replace this hardcoded foo with
1315 // proper export info from MS-OLEDS spec.
1316 static sal_uInt8
const aCompObj
[] = {
1317 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1318 0xFF, 0xFF, 0xFF, 0xFF, 0x41, 0x92, 0x59, 0x4C,
1319 0x26, 0x69, 0x1B, 0x10, 0x99, 0x92, 0x00, 0x00,
1320 0x0B, 0x65, 0xC6, 0xF9, 0x1A, 0x00, 0x00, 0x00,
1321 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1322 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1323 0x32, 0x2E, 0x30, 0x20, 0x49, 0x6D, 0x61, 0x67,
1324 0x65, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
1325 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
1326 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x0E, 0x00,
1327 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
1328 0x49, 0x6D, 0x61, 0x67, 0x65, 0x2E, 0x31, 0x00,
1329 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
1330 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1332 rOutStream
.writeMemory( aCompObj
, sizeof( aCompObj
) );
1335 ApiControlType
AxImageModel::getControlType() const
1337 return API_CONTROL_IMAGE
;
1340 void AxImageModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
1342 rPropMap
.setProperty( PROP_Enabled
, getFlag( mnFlags
, AX_FLAGS_ENABLED
) );
1343 rConv
.convertAxBackground( rPropMap
, mnBackColor
, mnFlags
, API_TRANSPARENCY_VOID
);
1344 rConv
.convertAxBorder( rPropMap
, mnBorderColor
, mnBorderStyle
, mnSpecialEffect
);
1345 rConv
.convertAxPicture( rPropMap
, maPictureData
, mnPicSizeMode
, mnPicAlign
, mbPicTiling
);
1346 AxControlModelBase::convertProperties( rPropMap
, rConv
);
1349 // ============================================================================
1351 AxTabStripModel::AxTabStripModel() :
1355 mnVariousPropertyBits( 0 )
1359 bool AxTabStripModel::importBinaryModel( BinaryInputStream
& rInStrm
)
1361 // not worth reading much here, basically we are interested
1362 // in whether we have tabs, the width, the height and the
1363 // captions, everything else we can pretty much discard ( for now )
1364 AxBinaryPropertyReader
aReader( rInStrm
);
1365 aReader
.readIntProperty
< sal_uInt32
>( mnListIndex
); // ListIndex
1366 aReader
.skipIntProperty
< sal_uInt32
>(); // Backcolor
1367 aReader
.skipIntProperty
< sal_uInt32
>(); // ForeColor
1368 aReader
.skipUndefinedProperty();
1369 aReader
.readPairProperty( maSize
);
1370 aReader
.readArrayStringProperty( maItems
);
1371 aReader
.skipIntProperty
< sal_uInt8
>(); // MousePointer
1372 aReader
.skipUndefinedProperty();
1373 aReader
.skipIntProperty
< sal_uInt32
>(); // TabOrientation
1374 aReader
.readIntProperty
< sal_uInt32
>(mnTabStyle
); // TabStyle
1375 aReader
.skipBoolProperty(); // MultiRow
1376 aReader
.skipIntProperty
< sal_uInt32
>(); // TabFixedWidth
1377 aReader
.skipIntProperty
< sal_uInt32
>(); // TabFixedHeight
1378 aReader
.skipBoolProperty(); // ToolTips
1379 aReader
.skipUndefinedProperty();
1380 aReader
.skipArrayStringProperty(); // ToolTip strings
1381 aReader
.skipUndefinedProperty();
1382 aReader
.readArrayStringProperty( maTabNames
); // Tab names
1383 aReader
.readIntProperty
< sal_uInt32
>(mnVariousPropertyBits
); // VariousPropertyBits
1384 aReader
.skipBoolProperty();// NewVersion
1385 aReader
.skipIntProperty
< sal_uInt32
>(); // TabsAllocated
1386 aReader
.skipArrayStringProperty(); // Tags
1387 aReader
.readIntProperty
<sal_uInt32
>(mnTabData
); // TabData
1388 aReader
.skipArrayStringProperty(); // Accelerators
1389 aReader
.skipPictureProperty(); // Mouse Icon
1390 return aReader
.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm
);
1393 ApiControlType
AxTabStripModel::getControlType() const
1395 return API_CONTROL_TABSTRIP
;
1398 AxMorphDataModelBase::AxMorphDataModelBase() :
1399 mnTextColor( AX_SYSCOLOR_WINDOWTEXT
),
1400 mnBackColor( AX_SYSCOLOR_WINDOWBACK
),
1401 mnFlags( AX_MORPHDATA_DEFFLAGS
),
1402 mnPicturePos( AX_PICPOS_ABOVECENTER
),
1403 mnBorderColor( AX_SYSCOLOR_WINDOWFRAME
),
1404 mnBorderStyle( AX_BORDERSTYLE_NONE
),
1405 mnSpecialEffect( AX_SPECIALEFFECT_SUNKEN
),
1406 mnDisplayStyle( AX_DISPLAYSTYLE_TEXT
),
1407 mnMultiSelect( AX_SELECTION_SINGLE
),
1408 mnScrollBars( AX_SCROLLBAR_NONE
),
1409 mnMatchEntry( AX_MATCHENTRY_NONE
),
1410 mnShowDropButton( AX_SHOWDROPBUTTON_NEVER
),
1412 mnPasswordChar( 0 ),
1414 mnVerticalAlign( XML_Center
)
1418 void AxMorphDataModelBase::importProperty( sal_Int32 nPropId
, const OUString
& rValue
)
1422 case XML_Caption
: maCaption
= rValue
; break;
1423 case XML_Value
: maValue
= rValue
; break;
1424 case XML_GroupName
: maGroupName
= rValue
; break;
1425 case XML_ForeColor
: mnTextColor
= AttributeConversion::decodeUnsigned( rValue
); break;
1426 case XML_BackColor
: mnBackColor
= AttributeConversion::decodeUnsigned( rValue
); break;
1427 case XML_VariousPropertyBits
: mnFlags
= AttributeConversion::decodeUnsigned( rValue
); break;
1428 case XML_PicturePosition
: mnPicturePos
= AttributeConversion::decodeUnsigned( rValue
); break;
1429 case XML_BorderColor
: mnBorderColor
= AttributeConversion::decodeUnsigned( rValue
); break;
1430 case XML_BorderStyle
: mnBorderStyle
= AttributeConversion::decodeInteger( rValue
); break;
1431 case XML_SpecialEffect
: mnSpecialEffect
= AttributeConversion::decodeInteger( rValue
); break;
1432 case XML_DisplayStyle
: mnDisplayStyle
= AttributeConversion::decodeInteger( rValue
); break;
1433 case XML_MultiSelect
: mnMultiSelect
= AttributeConversion::decodeInteger( rValue
); break;
1434 case XML_ScrollBars
: mnScrollBars
= AttributeConversion::decodeInteger( rValue
); break;
1435 case XML_MatchEntry
: mnMatchEntry
= AttributeConversion::decodeInteger( rValue
); break;
1436 case XML_ShowDropButtonWhen
: mnShowDropButton
= AttributeConversion::decodeInteger( rValue
);break;
1437 case XML_MaxLength
: mnMaxLength
= AttributeConversion::decodeInteger( rValue
); break;
1438 case XML_PasswordChar
: mnPasswordChar
= AttributeConversion::decodeInteger( rValue
); break;
1439 case XML_ListRows
: mnListRows
= AttributeConversion::decodeInteger( rValue
); break;
1440 default: AxFontDataModel::importProperty( nPropId
, rValue
);
1444 void AxMorphDataModelBase::importPictureData( sal_Int32 nPropId
, BinaryInputStream
& rInStrm
)
1448 case XML_Picture
: OleHelper::importStdPic( maPictureData
, rInStrm
, true ); break;
1449 default: AxFontDataModel::importPictureData( nPropId
, rInStrm
);
1453 bool AxMorphDataModelBase::importBinaryModel( BinaryInputStream
& rInStrm
)
1455 AxBinaryPropertyReader
aReader( rInStrm
, true );
1456 aReader
.readIntProperty
< sal_uInt32
>( mnFlags
);
1457 aReader
.readIntProperty
< sal_uInt32
>( mnBackColor
);
1458 aReader
.readIntProperty
< sal_uInt32
>( mnTextColor
);
1459 aReader
.readIntProperty
< sal_Int32
>( mnMaxLength
);
1460 aReader
.readIntProperty
< sal_uInt8
>( mnBorderStyle
);
1461 aReader
.readIntProperty
< sal_uInt8
>( mnScrollBars
);
1462 aReader
.readIntProperty
< sal_uInt8
>( mnDisplayStyle
);
1463 aReader
.skipIntProperty
< sal_uInt8
>(); // mouse pointer
1464 aReader
.readPairProperty( maSize
);
1465 aReader
.readIntProperty
< sal_uInt16
>( mnPasswordChar
);
1466 aReader
.skipIntProperty
< sal_uInt32
>(); // list width
1467 aReader
.skipIntProperty
< sal_uInt16
>(); // bound column
1468 aReader
.skipIntProperty
< sal_Int16
>(); // text column
1469 aReader
.skipIntProperty
< sal_Int16
>(); // column count
1470 aReader
.readIntProperty
< sal_uInt16
>( mnListRows
);
1471 aReader
.skipIntProperty
< sal_uInt16
>(); // column info count
1472 aReader
.readIntProperty
< sal_uInt8
>( mnMatchEntry
);
1473 aReader
.skipIntProperty
< sal_uInt8
>(); // list style
1474 aReader
.readIntProperty
< sal_uInt8
>( mnShowDropButton
);
1475 aReader
.skipUndefinedProperty();
1476 aReader
.skipIntProperty
< sal_uInt8
>(); // drop down style
1477 aReader
.readIntProperty
< sal_uInt8
>( mnMultiSelect
);
1478 aReader
.readStringProperty( maValue
);
1479 aReader
.readStringProperty( maCaption
);
1480 aReader
.readIntProperty
< sal_uInt32
>( mnPicturePos
);
1481 aReader
.readIntProperty
< sal_uInt32
>( mnBorderColor
);
1482 aReader
.readIntProperty
< sal_uInt32
>( mnSpecialEffect
);
1483 aReader
.skipPictureProperty(); // mouse icon
1484 aReader
.readPictureProperty( maPictureData
);
1485 aReader
.skipIntProperty
< sal_uInt16
>(); // accelerator
1486 aReader
.skipUndefinedProperty();
1487 aReader
.skipBoolProperty();
1488 aReader
.readStringProperty( maGroupName
);
1489 return aReader
.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm
);
1492 void AxMorphDataModelBase::exportBinaryModel( BinaryOutputStream
& rOutStrm
)
1494 AxBinaryPropertyWriter
aWriter( rOutStrm
, true );
1495 if ( mnFlags
!= AX_MORPHDATA_DEFFLAGS
)
1496 aWriter
.writeIntProperty
< sal_uInt32
>( mnFlags
);
1498 aWriter
.skipProperty(); //mnFlags
1500 aWriter
.writeIntProperty
< sal_uInt32
>( mnBackColor
);
1502 aWriter
.skipProperty(); // default backcolour
1503 aWriter
.writeIntProperty
< sal_uInt32
>( mnTextColor
);
1505 // only write if different from default
1506 if ( ( ( mnDisplayStyle
== AX_DISPLAYSTYLE_TEXT
) || ( mnDisplayStyle
== AX_DISPLAYSTYLE_COMBOBOX
) ) && mnMaxLength
!= 0 )
1507 aWriter
.writeIntProperty
< sal_Int32
>( mnMaxLength
);
1509 aWriter
.skipProperty(); //mnMaxLength
1510 if ( ( ( mnDisplayStyle
== AX_DISPLAYSTYLE_COMBOBOX
) || ( mnDisplayStyle
== AX_DISPLAYSTYLE_LISTBOX
) || ( mnDisplayStyle
== AX_DISPLAYSTYLE_TEXT
) ) && mnBorderStyle
!= AX_BORDERSTYLE_NONE
)
1511 aWriter
.writeIntProperty
< sal_uInt8
>( mnBorderStyle
);
1513 aWriter
.skipProperty(); //mnBorderStyle
1515 if ( ( mnDisplayStyle
== AX_DISPLAYSTYLE_LISTBOX
|| mnDisplayStyle
== AX_DISPLAYSTYLE_TEXT
) && mnScrollBars
!= AX_SCROLLBAR_NONE
)
1516 aWriter
.writeIntProperty
< sal_uInt8
>( mnScrollBars
);
1518 aWriter
.skipProperty(); //mnScrollBars
1519 aWriter
.writeIntProperty
< sal_uInt8
>( mnDisplayStyle
);
1520 aWriter
.skipProperty(); // mouse pointer
1521 aWriter
.writePairProperty( maSize
);
1522 if ( mnDisplayStyle
== AX_DISPLAYSTYLE_TEXT
)
1523 aWriter
.writeIntProperty
< sal_uInt16
>( mnPasswordChar
);
1525 aWriter
.skipProperty(); // mnPasswordChar
1526 aWriter
.skipProperty(); // list width
1527 aWriter
.skipProperty(); // bound column
1528 aWriter
.skipProperty(); // text column
1529 aWriter
.skipProperty(); // column count
1530 aWriter
.skipProperty(); // mnListRows
1531 aWriter
.skipProperty(); // column info count
1532 aWriter
.skipProperty(); // mnMatchEntry
1533 aWriter
.skipProperty(); // list style
1534 aWriter
.skipProperty(); // mnShowDropButton );
1535 aWriter
.skipProperty();
1536 aWriter
.skipProperty(); // drop down style
1537 if ( mnDisplayStyle
== AX_DISPLAYSTYLE_LISTBOX
&& mnMultiSelect
!= AX_SELECTION_SINGLE
)
1538 aWriter
.writeIntProperty
< sal_uInt8
>( mnMultiSelect
);
1539 // although CheckBox, ListBox, OptionButton, ToggleButton are also supported
1540 // they can only have the fileformat default
1542 aWriter
.skipProperty(); //mnMultiSelect
1543 aWriter
.writeStringProperty( maValue
);
1545 if ( ( mnDisplayStyle
== AX_DISPLAYSTYLE_CHECKBOX
) || ( mnDisplayStyle
== AX_DISPLAYSTYLE_OPTBUTTON
) || ( mnDisplayStyle
== AX_DISPLAYSTYLE_TOGGLE
) )
1546 aWriter
.writeStringProperty( maCaption
);
1548 aWriter
.skipProperty(); // mnCaption
1549 aWriter
.skipProperty(); // mnPicturePos );
1550 if ( ( mnDisplayStyle
== AX_DISPLAYSTYLE_COMBOBOX
|| mnDisplayStyle
== AX_DISPLAYSTYLE_LISTBOX
|| mnDisplayStyle
== AX_DISPLAYSTYLE_TEXT
) && mnBorderColor
!= AX_SYSCOLOR_WINDOWFRAME
)
1551 aWriter
.writeIntProperty
< sal_uInt32
>( mnBorderColor
);
1553 aWriter
.skipProperty(); // mnBorderColor
1554 if ( mnSpecialEffect
!= AX_SPECIALEFFECT_SUNKEN
)
1555 aWriter
.writeIntProperty
< sal_uInt32
>( mnSpecialEffect
);
1557 aWriter
.skipProperty(); //mnSpecialEffect
1558 aWriter
.skipProperty(); // mouse icon
1559 aWriter
.skipProperty(); // maPictureData
1560 aWriter
.skipProperty(); // accelerator
1561 aWriter
.skipProperty(); // undefined
1562 aWriter
.writeBoolProperty(true); // must be 1 for morph
1563 if ( ( mnDisplayStyle
== AX_DISPLAYSTYLE_CHECKBOX
) || ( mnDisplayStyle
== AX_DISPLAYSTYLE_OPTBUTTON
) )
1564 aWriter
.writeStringProperty( maGroupName
);
1566 aWriter
.skipProperty(); //maGroupName
1567 aWriter
.finalizeExport();
1568 AxFontDataModel::exportBinaryModel( rOutStrm
);
1571 void AxMorphDataModelBase::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
1573 rPropMap
.setProperty( PROP_Enabled
, getFlag( mnFlags
, AX_FLAGS_ENABLED
) );
1574 rConv
.convertColor( rPropMap
, PROP_TextColor
, mnTextColor
);
1575 AxFontDataModel::convertProperties( rPropMap
, rConv
);
1578 // ============================================================================
1580 AxToggleButtonModel::AxToggleButtonModel()
1582 mnDisplayStyle
= AX_DISPLAYSTYLE_TOGGLE
;
1585 ApiControlType
AxToggleButtonModel::getControlType() const
1587 OSL_ENSURE( mnDisplayStyle
== AX_DISPLAYSTYLE_TOGGLE
, "AxToggleButtonModel::getControlType - invalid control type" );
1588 return API_CONTROL_BUTTON
;
1591 void AxToggleButtonModel::convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
)
1593 rPropSet
.getProperty( maCaption
, PROP_Label
);
1596 if ( rPropSet
.getProperty( bRes
, PROP_MultiLine
) )
1597 setFlag( mnFlags
, AX_FLAGS_WORDWRAP
, bRes
);
1599 rConv
.convertToMSColor( rPropSet
, PROP_BackgroundColor
, mnBackColor
);
1600 // need to process the image if one exists
1601 rConv
.convertToAxState( rPropSet
, maValue
, mnMultiSelect
, API_DEFAULTSTATE_BOOLEAN
, mbAwtModel
);
1602 AxMorphDataModelBase::convertFromProperties( rPropSet
, rConv
);
1605 void AxToggleButtonModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
1607 rPropMap
.setProperty( PROP_Label
, maCaption
);
1608 rPropMap
.setProperty( PROP_MultiLine
, getFlag( mnFlags
, AX_FLAGS_WORDWRAP
) );
1609 rPropMap
.setProperty( PROP_Toggle
, true );
1610 rConv
.convertVerticalAlign( rPropMap
, mnVerticalAlign
);
1611 rConv
.convertAxBackground( rPropMap
, mnBackColor
, mnFlags
, API_TRANSPARENCY_NOTSUPPORTED
);
1612 rConv
.convertAxPicture( rPropMap
, maPictureData
, mnPicturePos
);
1613 rConv
.convertAxState( rPropMap
, maValue
, mnMultiSelect
, API_DEFAULTSTATE_BOOLEAN
, mbAwtModel
);
1614 AxMorphDataModelBase::convertProperties( rPropMap
, rConv
);
1617 void AxToggleButtonModel::exportCompObj( BinaryOutputStream
& rOutStream
)
1619 // should be able to replace this hardcoded foo with
1620 // proper export info from MS-OLEDS spec.
1621 static sal_uInt8
const aCompObj
[] = {
1622 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1623 0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0x1D, 0xD2, 0x8B,
1624 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1625 0x00, 0x60, 0x02, 0xF3, 0x21, 0x00, 0x00, 0x00,
1626 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1627 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1628 0x32, 0x2E, 0x30, 0x20, 0x54, 0x6F, 0x67, 0x67,
1629 0x6C, 0x65, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E,
1630 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62,
1631 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62,
1632 0x6A, 0x65, 0x63, 0x74, 0x00, 0x15, 0x00, 0x00,
1633 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x54,
1634 0x6F, 0x67, 0x67, 0x6C, 0x65, 0x42, 0x75, 0x74,
1635 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00, 0xF4, 0x39,
1636 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1637 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1639 rOutStream
.writeMemory( aCompObj
, sizeof( aCompObj
) );
1642 // ============================================================================
1644 AxCheckBoxModel::AxCheckBoxModel()
1646 mnDisplayStyle
= AX_DISPLAYSTYLE_CHECKBOX
;
1649 ApiControlType
AxCheckBoxModel::getControlType() const
1651 OSL_ENSURE( mnDisplayStyle
== AX_DISPLAYSTYLE_CHECKBOX
, "AxCheckBoxModel::getControlType - invalid control type" );
1652 return API_CONTROL_CHECKBOX
;
1655 void AxCheckBoxModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
1657 rPropMap
.setProperty( PROP_Label
, maCaption
);
1658 rPropMap
.setProperty( PROP_MultiLine
, getFlag( mnFlags
, AX_FLAGS_WORDWRAP
) );
1659 rConv
.convertVerticalAlign( rPropMap
, mnVerticalAlign
);
1660 rConv
.convertAxBackground( rPropMap
, mnBackColor
, mnFlags
, API_TRANSPARENCY_VOID
);
1661 rConv
.convertAxVisualEffect( rPropMap
, mnSpecialEffect
);
1662 rConv
.convertAxPicture( rPropMap
, maPictureData
, mnPicturePos
);
1663 rConv
.convertAxState( rPropMap
, maValue
, mnMultiSelect
, API_DEFAULTSTATE_TRISTATE
, mbAwtModel
);
1664 AxMorphDataModelBase::convertProperties( rPropMap
, rConv
);
1667 void AxCheckBoxModel::convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
)
1669 rPropSet
.getProperty( maCaption
, PROP_Label
);
1672 if ( rPropSet
.getProperty( bRes
, PROP_MultiLine
) )
1673 setFlag( mnFlags
, AX_FLAGS_WORDWRAP
, bRes
);
1675 rConv
.convertToAxVisualEffect( rPropSet
, mnSpecialEffect
);
1676 rConv
.convertToMSColor( rPropSet
, PROP_BackgroundColor
, mnBackColor
);
1677 // need to process the image if one exists
1678 rConv
.convertToAxState( rPropSet
, maValue
, mnMultiSelect
, API_DEFAULTSTATE_BOOLEAN
, mbAwtModel
);
1679 AxMorphDataModelBase::convertFromProperties( rPropSet
, rConv
);
1682 void AxCheckBoxModel::exportCompObj( BinaryOutputStream
& rOutStream
)
1684 // should be able to replace this hardcoded foo with
1685 // proper export info from MS-OLEDS spec.
1686 static sal_uInt8
const aCompObj
[] = {
1687 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1688 0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x1D, 0xD2, 0x8B,
1689 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1690 0x00, 0x60, 0x02, 0xF3, 0x1D, 0x00, 0x00, 0x00,
1691 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1692 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1693 0x32, 0x2E, 0x30, 0x20, 0x43, 0x68, 0x65, 0x63,
1694 0x6B, 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00,
1695 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65,
1696 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74,
1697 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72,
1698 0x6D, 0x73, 0x2E, 0x43, 0x68, 0x65, 0x63, 0x6B,
1699 0x42, 0x6F, 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39,
1700 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1701 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1703 rOutStream
.writeMemory( aCompObj
, sizeof( aCompObj
) );
1705 // ============================================================================
1707 AxOptionButtonModel::AxOptionButtonModel()
1709 mnDisplayStyle
= AX_DISPLAYSTYLE_OPTBUTTON
;
1712 ApiControlType
AxOptionButtonModel::getControlType() const
1714 OSL_ENSURE( mnDisplayStyle
== AX_DISPLAYSTYLE_OPTBUTTON
, "AxOptionButtonModel::getControlType - invalid control type" );
1715 return API_CONTROL_RADIOBUTTON
;
1718 void AxOptionButtonModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
1720 rPropMap
.setProperty( PROP_Label
, maCaption
);
1721 rPropMap
.setProperty( PROP_MultiLine
, getFlag( mnFlags
, AX_FLAGS_WORDWRAP
) );
1722 rConv
.convertVerticalAlign( rPropMap
, mnVerticalAlign
);
1723 rConv
.convertAxBackground( rPropMap
, mnBackColor
, mnFlags
, API_TRANSPARENCY_VOID
);
1724 rConv
.convertAxVisualEffect( rPropMap
, mnSpecialEffect
);
1725 rConv
.convertAxPicture( rPropMap
, maPictureData
, mnPicturePos
);
1726 rConv
.convertAxState( rPropMap
, maValue
, mnMultiSelect
, API_DEFAULTSTATE_SHORT
, mbAwtModel
);
1727 AxMorphDataModelBase::convertProperties( rPropMap
, rConv
);
1730 void AxOptionButtonModel::convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
)
1732 rPropSet
.getProperty( maCaption
, PROP_Label
);
1735 if ( rPropSet
.getProperty( bRes
, PROP_MultiLine
) )
1736 setFlag( mnFlags
, AX_FLAGS_WORDWRAP
, bRes
);
1738 rConv
.convertToAxVisualEffect( rPropSet
, mnSpecialEffect
);
1739 rConv
.convertToMSColor( rPropSet
, PROP_BackgroundColor
, mnBackColor
);
1740 // need to process the image if one exists
1741 rConv
.convertToAxState( rPropSet
, maValue
, mnMultiSelect
, API_DEFAULTSTATE_BOOLEAN
, mbAwtModel
);
1742 AxMorphDataModelBase::convertFromProperties( rPropSet
, rConv
);
1745 void AxOptionButtonModel::exportCompObj( BinaryOutputStream
& rOutStream
)
1747 // should be able to replace this hardcoded foo with
1748 // proper export info from MS-OLEDS spec.
1749 static sal_uInt8
const aCompObj
[] = {
1750 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1751 0xFF, 0xFF, 0xFF, 0xFF, 0x50, 0x1D, 0xD2, 0x8B,
1752 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1753 0x00, 0x60, 0x02, 0xF3, 0x21, 0x00, 0x00, 0x00,
1754 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1755 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1756 0x32, 0x2E, 0x30, 0x20, 0x4F, 0x70, 0x74, 0x69,
1757 0x6F, 0x6E, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E,
1758 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62,
1759 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62,
1760 0x6A, 0x65, 0x63, 0x74, 0x00, 0x15, 0x00, 0x00,
1761 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x4F,
1762 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x42, 0x75, 0x74,
1763 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00, 0xF4, 0x39,
1764 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1765 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1767 rOutStream
.writeMemory( aCompObj
, sizeof( aCompObj
) );
1770 // ============================================================================
1772 AxTextBoxModel::AxTextBoxModel()
1774 mnDisplayStyle
= AX_DISPLAYSTYLE_TEXT
;
1777 ApiControlType
AxTextBoxModel::getControlType() const
1779 OSL_ENSURE( mnDisplayStyle
== AX_DISPLAYSTYLE_TEXT
, "AxTextBoxModel::getControlType - invalid control type" );
1780 return API_CONTROL_EDIT
;
1783 void AxTextBoxModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
1785 rPropMap
.setProperty( PROP_MultiLine
, getFlag( mnFlags
, AX_FLAGS_MULTILINE
) );
1786 rPropMap
.setProperty( PROP_HideInactiveSelection
, getFlag( mnFlags
, AX_FLAGS_HIDESELECTION
) );
1787 rPropMap
.setProperty( mbAwtModel
? PROP_Text
: PROP_DefaultText
, maValue
);
1788 rPropMap
.setProperty( PROP_MaxTextLen
, getLimitedValue
< sal_Int16
, sal_Int32
>( mnMaxLength
, 0, SAL_MAX_INT16
) );
1789 if( (0 < mnPasswordChar
) && (mnPasswordChar
<= SAL_MAX_INT16
) )
1790 rPropMap
.setProperty( PROP_EchoChar
, static_cast< sal_Int16
>( mnPasswordChar
) );
1791 rPropMap
.setProperty( PROP_HScroll
, getFlag( mnScrollBars
, AX_SCROLLBAR_HORIZONTAL
) );
1792 rPropMap
.setProperty( PROP_VScroll
, getFlag( mnScrollBars
, AX_SCROLLBAR_VERTICAL
) );
1793 rConv
.convertAxBackground( rPropMap
, mnBackColor
, mnFlags
, API_TRANSPARENCY_VOID
);
1794 rConv
.convertAxBorder( rPropMap
, mnBorderColor
, mnBorderStyle
, mnSpecialEffect
);
1795 AxMorphDataModelBase::convertProperties( rPropMap
, rConv
);
1798 void AxTextBoxModel::convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
)
1801 if ( rPropSet
.getProperty( bRes
, PROP_MultiLine
) )
1802 setFlag( mnFlags
, AX_FLAGS_WORDWRAP
, bRes
);
1803 if ( rPropSet
.getProperty( bRes
, PROP_HideInactiveSelection
) )
1804 setFlag( mnFlags
, AX_FLAGS_HIDESELECTION
, bRes
);
1805 rPropSet
.getProperty( maValue
, ( mbAwtModel
? PROP_Text
: PROP_DefaultText
) );
1806 if (maValue
.isEmpty() && !mbAwtModel
)
1807 // No default value? Then try exporting the current one.
1808 rPropSet
.getProperty( maValue
, PROP_Text
);
1810 if ( rPropSet
.getProperty( nTmp
, PROP_MaxTextLen
) )
1812 if ( rPropSet
.getProperty( nTmp
, PROP_EchoChar
) )
1813 mnPasswordChar
= nTmp
;
1814 if ( rPropSet
.getProperty( bRes
, PROP_HScroll
) )
1815 setFlag( mnScrollBars
, AX_SCROLLBAR_HORIZONTAL
, bRes
);
1816 if ( rPropSet
.getProperty( bRes
, PROP_VScroll
) )
1817 setFlag( mnScrollBars
, AX_SCROLLBAR_VERTICAL
, bRes
);
1819 rConv
.convertToMSColor( rPropSet
, PROP_BackgroundColor
, mnBackColor
, 0x80000005L
);
1821 rConv
.convertToAxBorder( rPropSet
, mnBorderColor
, mnBorderStyle
, mnSpecialEffect
);
1822 AxMorphDataModelBase::convertFromProperties( rPropSet
, rConv
);
1825 void AxTextBoxModel::exportCompObj( BinaryOutputStream
& rOutStream
)
1827 // should be able to replace this hardcoded foo with
1828 // proper export info from MS-OLEDS spec.
1829 static sal_uInt8
const aCompObj
[] = {
1830 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1831 0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x1D, 0xD2, 0x8B,
1832 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1833 0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
1834 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1835 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1836 0x32, 0x2E, 0x30, 0x20, 0x54, 0x65, 0x78, 0x74,
1837 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
1838 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
1839 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
1840 0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
1841 0x73, 0x2E, 0x54, 0x65, 0x78, 0x74, 0x42, 0x6F,
1842 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
1843 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1844 0x00, 0x00, 0x00, 0x00
1846 rOutStream
.writeMemory( aCompObj
, sizeof( aCompObj
) );
1848 // ============================================================================
1850 AxNumericFieldModel::AxNumericFieldModel()
1852 mnDisplayStyle
= AX_DISPLAYSTYLE_TEXT
;
1855 ApiControlType
AxNumericFieldModel::getControlType() const
1857 OSL_ENSURE( mnDisplayStyle
== AX_DISPLAYSTYLE_TEXT
, "AxNumericFieldModel::getControlType - invalid control type" );
1858 return API_CONTROL_NUMERIC
;
1861 void AxNumericFieldModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
1863 rPropMap
.setProperty( PROP_HideInactiveSelection
, getFlag( mnFlags
, AX_FLAGS_HIDESELECTION
) );
1864 // TODO: OUString::toDouble() does not handle local decimal separator
1865 rPropMap
.setProperty( mbAwtModel
? PROP_Value
: PROP_DefaultValue
, maValue
.toDouble() );
1866 rPropMap
.setProperty( PROP_Spin
, getFlag( mnScrollBars
, AX_SCROLLBAR_VERTICAL
) );
1867 rPropMap
.setProperty( PROP_Repeat
, true );
1868 rConv
.convertAxBackground( rPropMap
, mnBackColor
, mnFlags
, API_TRANSPARENCY_VOID
);
1869 rConv
.convertAxBorder( rPropMap
, mnBorderColor
, mnBorderStyle
, mnSpecialEffect
);
1870 AxMorphDataModelBase::convertProperties( rPropMap
, rConv
);
1873 void AxNumericFieldModel::convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
)
1876 if ( rPropSet
.getProperty( bRes
, PROP_HideInactiveSelection
) )
1877 setFlag( mnFlags
, AX_FLAGS_HIDESELECTION
, bRes
);
1878 rPropSet
.getProperty( maValue
, ( mbAwtModel
? PROP_Text
: PROP_DefaultText
) );
1879 if ( rPropSet
.getProperty( bRes
, PROP_Spin
) )
1880 setFlag( mnScrollBars
, AX_SCROLLBAR_VERTICAL
, bRes
);
1882 rConv
.convertToMSColor( rPropSet
, PROP_BackgroundColor
, mnBackColor
);
1884 rConv
.convertToAxBorder( rPropSet
, mnBorderColor
, mnBorderStyle
, mnSpecialEffect
);
1885 AxMorphDataModelBase::convertFromProperties( rPropSet
, rConv
);
1888 void AxNumericFieldModel::exportCompObj( BinaryOutputStream
& rOutStream
)
1890 // should be able to replace this hardcoded foo with
1891 // proper export info from MS-OLEDS spec.
1892 static sal_uInt8
const aCompObj
[] = {
1893 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1894 0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x1D, 0xD2, 0x8B,
1895 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1896 0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
1897 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1898 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1899 0x32, 0x2E, 0x30, 0x20, 0x54, 0x65, 0x78, 0x74,
1900 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
1901 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
1902 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
1903 0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
1904 0x73, 0x2E, 0x54, 0x65, 0x78, 0x74, 0x42, 0x6F,
1905 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
1906 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1907 0x00, 0x00, 0x00, 0x00
1909 rOutStream
.writeMemory( aCompObj
, sizeof( aCompObj
) );
1911 // ============================================================================
1913 AxListBoxModel::AxListBoxModel()
1915 mnDisplayStyle
= AX_DISPLAYSTYLE_LISTBOX
;
1918 ApiControlType
AxListBoxModel::getControlType() const
1920 OSL_ENSURE( mnDisplayStyle
== AX_DISPLAYSTYLE_LISTBOX
, "AxListBoxModel::getControlType - invalid control type" );
1921 return API_CONTROL_LISTBOX
;
1924 void AxListBoxModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
1926 bool bMultiSelect
= (mnMultiSelect
== AX_SELECTION_MULTI
) || (mnMultiSelect
== AX_SELECTION_EXTENDED
);
1927 rPropMap
.setProperty( PROP_MultiSelection
, bMultiSelect
);
1928 rPropMap
.setProperty( PROP_Dropdown
, false );
1929 rConv
.convertAxBackground( rPropMap
, mnBackColor
, mnFlags
, API_TRANSPARENCY_VOID
);
1930 rConv
.convertAxBorder( rPropMap
, mnBorderColor
, mnBorderStyle
, mnSpecialEffect
);
1931 AxMorphDataModelBase::convertProperties( rPropMap
, rConv
);
1934 void AxListBoxModel::convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
)
1937 if ( rPropSet
.getProperty( bRes
, PROP_MultiSelection
) )
1939 rConv
.convertToMSColor( rPropSet
, PROP_BackgroundColor
, mnBackColor
);
1941 rConv
.convertToAxBorder( rPropSet
, mnBorderColor
, mnBorderStyle
, mnSpecialEffect
);
1942 AxMorphDataModelBase::convertFromProperties( rPropSet
, rConv
);
1945 void AxListBoxModel::exportCompObj( BinaryOutputStream
& rOutStream
)
1947 // should be able to replace this hardcoded foo with
1948 // proper export info from MS-OLEDS spec.
1949 static sal_uInt8
const aCompObj
[] = {
1950 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
1951 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0x1D, 0xD2, 0x8B,
1952 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
1953 0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
1954 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
1955 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
1956 0x32, 0x2E, 0x30, 0x20, 0x4C, 0x69, 0x73, 0x74,
1957 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
1958 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
1959 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
1960 0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
1961 0x73, 0x2E, 0x4C, 0x69, 0x73, 0x74, 0x42, 0x6F,
1962 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
1963 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1964 0x00, 0x00, 0x00, 0x00
1966 rOutStream
.writeMemory( aCompObj
, sizeof( aCompObj
) );
1968 // ============================================================================
1970 AxComboBoxModel::AxComboBoxModel()
1972 mnDisplayStyle
= AX_DISPLAYSTYLE_COMBOBOX
;
1973 mnFlags
= 0x2c80481b;
1976 ApiControlType
AxComboBoxModel::getControlType() const
1978 OSL_ENSURE( (mnDisplayStyle
== AX_DISPLAYSTYLE_COMBOBOX
) || (mnDisplayStyle
== AX_DISPLAYSTYLE_DROPDOWN
), "AxComboBoxModel::getControlType - invalid control type" );
1979 return (mnDisplayStyle
== AX_DISPLAYSTYLE_DROPDOWN
) ? API_CONTROL_LISTBOX
: API_CONTROL_COMBOBOX
;
1982 void AxComboBoxModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
1984 if( mnDisplayStyle
!= AX_DISPLAYSTYLE_DROPDOWN
)
1986 rPropMap
.setProperty( PROP_HideInactiveSelection
, getFlag( mnFlags
, AX_FLAGS_HIDESELECTION
) );
1987 rPropMap
.setProperty( mbAwtModel
? PROP_Text
: PROP_DefaultText
, maValue
);
1988 rPropMap
.setProperty( PROP_MaxTextLen
, getLimitedValue
< sal_Int16
, sal_Int32
>( mnMaxLength
, 0, SAL_MAX_INT16
) );
1989 bool bAutoComplete
= (mnMatchEntry
== AX_MATCHENTRY_FIRSTLETTER
) || (mnMatchEntry
== AX_MATCHENTRY_COMPLETE
);
1990 rPropMap
.setProperty( PROP_Autocomplete
, bAutoComplete
);
1992 bool bShowDropdown
= (mnShowDropButton
== AX_SHOWDROPBUTTON_FOCUS
) || (mnShowDropButton
== AX_SHOWDROPBUTTON_ALWAYS
);
1993 rPropMap
.setProperty( PROP_Dropdown
, bShowDropdown
);
1994 rPropMap
.setProperty( PROP_LineCount
, getLimitedValue
< sal_Int16
, sal_Int32
>( mnListRows
, 1, SAL_MAX_INT16
) );
1995 rConv
.convertAxBackground( rPropMap
, mnBackColor
, mnFlags
, API_TRANSPARENCY_VOID
);
1996 rConv
.convertAxBorder( rPropMap
, mnBorderColor
, mnBorderStyle
, mnSpecialEffect
);
1997 AxMorphDataModelBase::convertProperties( rPropMap
, rConv
);
2000 void AxComboBoxModel::convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
)
2002 // when would we have mnDisplayStyle = AX_DISPLAYSTYLE_DROPDOWN ?
2003 // #TODO check against msocximex
2004 mnDisplayStyle
= AX_DISPLAYSTYLE_COMBOBOX
;
2007 if ( rPropSet
.getProperty( bRes
, PROP_HideInactiveSelection
) )
2008 setFlag( mnFlags
, AX_FLAGS_HIDESELECTION
, bRes
);
2009 rPropSet
.getProperty( maValue
, ( mbAwtModel
? PROP_Text
: PROP_DefaultText
) );
2012 if ( rPropSet
.getProperty( nTmp
, PROP_MaxTextLen
) )
2014 if ( rPropSet
.getProperty( bRes
, PROP_Autocomplete
) )
2016 // when to choose AX_MATCHENTRY_FIRSTLETTER ?
2017 // #TODO check against msocximex
2019 mnMatchEntry
= AX_MATCHENTRY_COMPLETE
;
2021 if ( rPropSet
.getProperty( bRes
, PROP_Dropdown
) )
2023 rPropSet
.getProperty( mnListRows
, PROP_LineCount
);
2027 rConv
.convertToMSColor( rPropSet
, PROP_BackgroundColor
, mnBackColor
);
2029 rConv
.convertToAxBorder( rPropSet
, mnBorderColor
, mnBorderStyle
, mnSpecialEffect
);
2030 AxMorphDataModelBase::convertFromProperties( rPropSet
, rConv
);
2033 void AxComboBoxModel::exportCompObj( BinaryOutputStream
& rOutStream
)
2035 // should be able to replace this hardcoded foo with
2036 // proper export info from MS-OLEDS spec.
2037 static sal_uInt8
const aCompObj
[] = {
2038 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2039 0xFF, 0xFF, 0xFF, 0xFF, 0x30, 0x1D, 0xD2, 0x8B,
2040 0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
2041 0x00, 0x60, 0x02, 0xF3, 0x1D, 0x00, 0x00, 0x00,
2042 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2043 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2044 0x32, 0x2E, 0x30, 0x20, 0x43, 0x6F, 0x6D, 0x62,
2045 0x6F, 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00,
2046 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65,
2047 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74,
2048 0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72,
2049 0x6D, 0x73, 0x2E, 0x43, 0x6F, 0x6D, 0x62, 0x6F,
2050 0x42, 0x6F, 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39,
2051 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2052 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2054 rOutStream
.writeMemory( aCompObj
, sizeof( aCompObj
) );
2056 // ============================================================================
2058 AxSpinButtonModel::AxSpinButtonModel() :
2059 mnArrowColor( AX_SYSCOLOR_BUTTONTEXT
),
2060 mnBackColor( AX_SYSCOLOR_BUTTONFACE
),
2061 mnFlags( AX_SPINBUTTON_DEFFLAGS
),
2062 mnOrientation( AX_ORIENTATION_AUTO
),
2071 ApiControlType
AxSpinButtonModel::getControlType() const
2073 return API_CONTROL_SPINBUTTON
;
2076 void AxSpinButtonModel::importProperty( sal_Int32 nPropId
, const OUString
& rValue
)
2080 case XML_ForeColor
: mnArrowColor
= AttributeConversion::decodeUnsigned( rValue
); break;
2081 case XML_BackColor
: mnBackColor
= AttributeConversion::decodeUnsigned( rValue
); break;
2082 case XML_VariousPropertyBits
: mnFlags
= AttributeConversion::decodeUnsigned( rValue
); break;
2083 case XML_Orientation
: mnOrientation
= AttributeConversion::decodeInteger( rValue
); break;
2084 case XML_Min
: mnMin
= AttributeConversion::decodeInteger( rValue
); break;
2085 case XML_Max
: mnMax
= AttributeConversion::decodeInteger( rValue
); break;
2086 case XML_Position
: mnPosition
= AttributeConversion::decodeInteger( rValue
); break;
2087 case XML_SmallChange
: mnSmallChange
= AttributeConversion::decodeInteger( rValue
); break;
2088 case XML_Delay
: mnDelay
= AttributeConversion::decodeInteger( rValue
); break;
2089 default: AxControlModelBase::importProperty( nPropId
, rValue
);
2093 bool AxSpinButtonModel::importBinaryModel( BinaryInputStream
& rInStrm
)
2095 AxBinaryPropertyReader
aReader( rInStrm
);
2096 aReader
.readIntProperty
< sal_uInt32
>( mnArrowColor
);
2097 aReader
.readIntProperty
< sal_uInt32
>( mnBackColor
);
2098 aReader
.readIntProperty
< sal_uInt32
>( mnFlags
);
2099 aReader
.readPairProperty( maSize
);
2100 aReader
.skipIntProperty
< sal_uInt32
>(); // unused
2101 aReader
.readIntProperty
< sal_Int32
>( mnMin
);
2102 aReader
.readIntProperty
< sal_Int32
>( mnMax
);
2103 aReader
.readIntProperty
< sal_Int32
>( mnPosition
);
2104 aReader
.skipIntProperty
< sal_uInt32
>(); // prev enabled
2105 aReader
.skipIntProperty
< sal_uInt32
>(); // next enabled
2106 aReader
.readIntProperty
< sal_Int32
>( mnSmallChange
);
2107 aReader
.readIntProperty
< sal_Int32
>( mnOrientation
);
2108 aReader
.readIntProperty
< sal_Int32
>( mnDelay
);
2109 aReader
.skipPictureProperty(); // mouse icon
2110 aReader
.skipIntProperty
< sal_uInt8
>(); // mouse pointer
2111 return aReader
.finalizeImport();
2114 void AxSpinButtonModel::exportBinaryModel( BinaryOutputStream
& rOutStrm
)
2116 AxBinaryPropertyWriter
aWriter( rOutStrm
);
2117 aWriter
.writeIntProperty
< sal_uInt32
>( mnArrowColor
);
2119 aWriter
.writeIntProperty
< sal_uInt32
>( mnBackColor
);
2121 aWriter
.skipProperty(); // default backcolour
2122 aWriter
.writeIntProperty
< sal_uInt32
>( mnFlags
);
2123 aWriter
.writePairProperty( maSize
);
2124 aWriter
.skipProperty(); // unused
2125 aWriter
.writeIntProperty
< sal_Int32
>( mnMin
);
2126 aWriter
.writeIntProperty
< sal_Int32
>( mnMax
);
2127 aWriter
.writeIntProperty
< sal_Int32
>( mnPosition
);
2128 aWriter
.skipProperty(); // prev enabled
2129 aWriter
.skipProperty(); // next enabled
2130 aWriter
.writeIntProperty
< sal_Int32
>( mnSmallChange
);
2131 aWriter
.writeIntProperty
< sal_Int32
>( mnOrientation
);
2132 aWriter
.writeIntProperty
< sal_Int32
>( mnDelay
);
2133 aWriter
.skipProperty(); // mouse icon
2134 aWriter
.skipProperty(); // mouse pointer
2136 aWriter
.finalizeExport();
2139 void AxSpinButtonModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
2141 sal_Int32 nMin
= ::std::min( mnMin
, mnMax
);
2142 sal_Int32 nMax
= ::std::max( mnMin
, mnMax
);
2143 rPropMap
.setProperty( PROP_Enabled
, getFlag( mnFlags
, AX_FLAGS_ENABLED
) );
2144 rPropMap
.setProperty( PROP_SpinValueMin
, nMin
);
2145 rPropMap
.setProperty( PROP_SpinValueMax
, nMax
);
2146 rPropMap
.setProperty( PROP_SpinIncrement
, mnSmallChange
);
2147 rPropMap
.setProperty( mbAwtModel
? PROP_SpinValue
: PROP_DefaultSpinValue
, mnPosition
);
2148 rPropMap
.setProperty( PROP_Repeat
, true );
2149 rPropMap
.setProperty( PROP_RepeatDelay
, mnDelay
);
2150 rPropMap
.setProperty( PROP_Border
, API_BORDER_NONE
);
2151 rConv
.convertColor( rPropMap
, PROP_SymbolColor
, mnArrowColor
);
2152 rConv
.convertAxBackground( rPropMap
, mnBackColor
, mnFlags
, API_TRANSPARENCY_NOTSUPPORTED
);
2153 rConv
.convertAxOrientation( rPropMap
, maSize
, mnOrientation
);
2154 AxControlModelBase::convertProperties( rPropMap
, rConv
);
2157 void AxSpinButtonModel::convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
)
2160 if ( rPropSet
.getProperty( bRes
, PROP_Enabled
) )
2161 setFlag( mnFlags
, AX_FLAGS_ENABLED
, bRes
);
2162 rPropSet
.getProperty( mnMin
, PROP_SpinValueMin
);
2163 rPropSet
.getProperty( mnMax
, PROP_SpinValueMax
);
2164 rPropSet
.getProperty( mnSmallChange
, PROP_SpinIncrement
);
2165 rPropSet
.getProperty( mnPosition
, ( mbAwtModel
? PROP_SpinValue
: PROP_DefaultSpinValue
) );
2166 rPropSet
.getProperty( mnDelay
, PROP_RepeatDelay
);
2167 rConv
.convertToMSColor( rPropSet
, PROP_SymbolColor
, mnArrowColor
);
2168 rConv
.convertToMSColor( rPropSet
, PROP_BackgroundColor
, mnBackColor
);
2170 rConv
.convertToAxOrientation( rPropSet
, maSize
, mnOrientation
);
2173 void AxSpinButtonModel::exportCompObj( BinaryOutputStream
& rOutStream
)
2175 // should be able to replace this hardcoded foo with
2176 // proper export info from MS-OLEDS spec.
2177 static sal_uInt8
const aCompObj
[] =
2179 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2180 0xFF, 0xFF, 0xFF, 0xFF, 0xB0, 0x6F, 0x17, 0x79,
2181 0xF2, 0xB7, 0xCE, 0x11, 0x97, 0xEF, 0x00, 0xAA,
2182 0x00, 0x6D, 0x27, 0x76, 0x1F, 0x00, 0x00, 0x00,
2183 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2184 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2185 0x32, 0x2E, 0x30, 0x20, 0x53, 0x70, 0x69, 0x6E,
2186 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x00, 0x10,
2187 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64,
2188 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65,
2189 0x63, 0x74, 0x00, 0x13, 0x00, 0x00, 0x00, 0x46,
2190 0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x53, 0x70, 0x69,
2191 0x6E, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x2E,
2192 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00,
2193 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2197 rOutStream
.writeMemory( aCompObj
, sizeof( aCompObj
) );
2199 // ============================================================================
2201 AxScrollBarModel::AxScrollBarModel() :
2202 mnArrowColor( AX_SYSCOLOR_BUTTONTEXT
),
2203 mnBackColor( AX_SYSCOLOR_BUTTONFACE
),
2204 mnFlags( AX_SCROLLBAR_DEFFLAGS
),
2205 mnOrientation( AX_ORIENTATION_AUTO
),
2206 mnPropThumb( AX_PROPTHUMB_ON
),
2216 ApiControlType
AxScrollBarModel::getControlType() const
2218 return API_CONTROL_SCROLLBAR
;
2221 void AxScrollBarModel::importProperty( sal_Int32 nPropId
, const OUString
& rValue
)
2225 case XML_ForeColor
: mnArrowColor
= AttributeConversion::decodeUnsigned( rValue
); break;
2226 case XML_BackColor
: mnBackColor
= AttributeConversion::decodeUnsigned( rValue
); break;
2227 case XML_VariousPropertyBits
: mnFlags
= AttributeConversion::decodeUnsigned( rValue
); break;
2228 case XML_Orientation
: mnOrientation
= AttributeConversion::decodeInteger( rValue
); break;
2229 case XML_ProportionalThumb
: mnPropThumb
= AttributeConversion::decodeInteger( rValue
); break;
2230 case XML_Min
: mnMin
= AttributeConversion::decodeInteger( rValue
); break;
2231 case XML_Max
: mnMax
= AttributeConversion::decodeInteger( rValue
); break;
2232 case XML_Position
: mnPosition
= AttributeConversion::decodeInteger( rValue
); break;
2233 case XML_SmallChange
: mnSmallChange
= AttributeConversion::decodeInteger( rValue
); break;
2234 case XML_LargeChange
: mnLargeChange
= AttributeConversion::decodeInteger( rValue
); break;
2235 case XML_Delay
: mnDelay
= AttributeConversion::decodeInteger( rValue
); break;
2236 default: AxControlModelBase::importProperty( nPropId
, rValue
);
2240 bool AxScrollBarModel::importBinaryModel( BinaryInputStream
& rInStrm
)
2242 AxBinaryPropertyReader
aReader( rInStrm
);
2243 aReader
.readIntProperty
< sal_uInt32
>( mnArrowColor
);
2244 aReader
.readIntProperty
< sal_uInt32
>( mnBackColor
);
2245 aReader
.readIntProperty
< sal_uInt32
>( mnFlags
);
2246 aReader
.readPairProperty( maSize
);
2247 aReader
.skipIntProperty
< sal_uInt8
>(); // mouse pointer
2248 aReader
.readIntProperty
< sal_Int32
>( mnMin
);
2249 aReader
.readIntProperty
< sal_Int32
>( mnMax
);
2250 aReader
.readIntProperty
< sal_Int32
>( mnPosition
);
2251 aReader
.skipIntProperty
< sal_uInt32
>(); // unused
2252 aReader
.skipIntProperty
< sal_uInt32
>(); // prev enabled
2253 aReader
.skipIntProperty
< sal_uInt32
>(); // next enabled
2254 aReader
.readIntProperty
< sal_Int32
>( mnSmallChange
);
2255 aReader
.readIntProperty
< sal_Int32
>( mnLargeChange
);
2256 aReader
.readIntProperty
< sal_Int32
>( mnOrientation
);
2257 aReader
.readIntProperty
< sal_Int16
>( mnPropThumb
);
2258 aReader
.readIntProperty
< sal_Int32
>( mnDelay
);
2259 aReader
.skipPictureProperty(); // mouse icon
2260 return aReader
.finalizeImport();
2263 void AxScrollBarModel::exportBinaryModel( BinaryOutputStream
& rOutStrm
)
2265 AxBinaryPropertyWriter
aWriter( rOutStrm
);
2266 aWriter
.writeIntProperty
< sal_uInt32
>( mnArrowColor
);
2268 aWriter
.writeIntProperty
< sal_uInt32
>( mnBackColor
);
2270 aWriter
.skipProperty(); // default backcolour
2271 aWriter
.writeIntProperty
< sal_uInt32
>( mnFlags
);
2272 aWriter
.writePairProperty( maSize
);
2273 aWriter
.skipProperty(); // mouse pointer
2274 aWriter
.writeIntProperty
< sal_Int32
>( mnMin
);
2275 aWriter
.writeIntProperty
< sal_Int32
>( mnMax
);
2276 aWriter
.writeIntProperty
< sal_Int32
>( mnPosition
);
2277 aWriter
.skipProperty(); // unused
2278 aWriter
.skipProperty(); // prev enabled
2279 aWriter
.skipProperty(); // next enabled
2280 aWriter
.writeIntProperty
< sal_Int32
>( mnSmallChange
);
2281 aWriter
.writeIntProperty
< sal_Int32
>( mnLargeChange
);
2282 aWriter
.writeIntProperty
< sal_Int32
>( mnOrientation
);
2283 aWriter
.writeIntProperty
< sal_Int16
>( mnPropThumb
);
2284 aWriter
.writeIntProperty
< sal_Int32
>( mnDelay
);
2285 aWriter
.skipProperty(); // mouse icon
2286 aWriter
.finalizeExport();
2289 void AxScrollBarModel::exportCompObj( BinaryOutputStream
& rOutStream
)
2291 // should be able to replace this hardcoded foo with
2292 // proper export info from MS-OLEDS spec.
2293 static sal_uInt8
const aCompObj
[] =
2295 0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
2296 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x81, 0xD1, 0xDF,
2297 0x2F, 0x5E, 0xCE, 0x11, 0xA4, 0x49, 0x00, 0xAA,
2298 0x00, 0x4A, 0x80, 0x3D, 0x1E, 0x00, 0x00, 0x00,
2299 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
2300 0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
2301 0x32, 0x2E, 0x30, 0x20, 0x53, 0x63, 0x72, 0x6F,
2302 0x6C, 0x6C, 0x42, 0x61, 0x72, 0x00, 0x10, 0x00,
2303 0x00, 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64,
2304 0x65, 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63,
2305 0x74, 0x00, 0x12, 0x00, 0x00, 0x00, 0x46, 0x6F,
2306 0x72, 0x6D, 0x73, 0x2E, 0x53, 0x63, 0x72, 0x6F,
2307 0x6C, 0x6C, 0x42, 0x61, 0x72, 0x2E, 0x31, 0x00,
2308 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
2309 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2311 rOutStream
.writeMemory( aCompObj
, sizeof( aCompObj
) );
2314 void AxScrollBarModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
2316 rPropMap
.setProperty( PROP_Enabled
, getFlag( mnFlags
, AX_FLAGS_ENABLED
) );
2317 rPropMap
.setProperty( PROP_RepeatDelay
, mnDelay
);
2318 rPropMap
.setProperty( PROP_Border
, API_BORDER_NONE
);
2319 if( (mnPropThumb
== AX_PROPTHUMB_ON
) && (mnMin
!= mnMax
) && (mnLargeChange
> 0) )
2321 // use double to prevent integer overflow in division (fInterval+mnLargeChange may become 0 when performed as int)
2322 double fInterval
= fabs( static_cast< double >( mnMax
- mnMin
) );
2323 sal_Int32 nThumbLen
= getLimitedValue
< sal_Int32
, double >( (fInterval
* mnLargeChange
) / (fInterval
+ mnLargeChange
), 1, SAL_MAX_INT32
);
2324 rPropMap
.setProperty( PROP_VisibleSize
, nThumbLen
);
2326 rConv
.convertColor( rPropMap
, PROP_SymbolColor
, mnArrowColor
);
2327 rConv
.convertAxBackground( rPropMap
, mnBackColor
, mnFlags
, API_TRANSPARENCY_NOTSUPPORTED
);
2328 rConv
.convertAxOrientation( rPropMap
, maSize
, mnOrientation
);
2329 rConv
.convertScrollBar( rPropMap
, mnMin
, mnMax
, mnPosition
, mnSmallChange
, mnLargeChange
, mbAwtModel
);
2330 AxControlModelBase::convertProperties( rPropMap
, rConv
);
2333 void AxScrollBarModel::convertFromProperties( PropertySet
& rPropSet
, const ControlConverter
& rConv
)
2336 if ( rPropSet
.getProperty( bRes
, PROP_Enabled
) )
2337 setFlag( mnFlags
, AX_FLAGS_ENABLED
, bRes
);
2338 rPropSet
.getProperty( mnDelay
, PROP_RepeatDelay
);
2339 mnPropThumb
= AX_PROPTHUMB_ON
; // default
2340 rConv
.convertToMSColor( rPropSet
, PROP_SymbolColor
, mnArrowColor
);
2341 rConv
.convertToMSColor( rPropSet
, PROP_BackgroundColor
, mnBackColor
);
2342 rConv
.convertToAxOrientation( rPropSet
, maSize
, mnOrientation
);
2344 rPropSet
.getProperty( mnMin
, PROP_ScrollValueMin
);
2345 rPropSet
.getProperty( mnMax
, PROP_ScrollValueMax
);
2346 rPropSet
.getProperty( mnSmallChange
, PROP_LineIncrement
);
2347 rPropSet
.getProperty( mnLargeChange
, PROP_BlockIncrement
);
2348 rPropSet
.getProperty( mnPosition
, ( mbAwtModel
? PROP_ScrollValue
: PROP_DefaultScrollValue
) );
2352 // ============================================================================
2354 AxContainerModelBase::AxContainerModelBase( bool bFontSupport
) :
2355 AxFontDataModel( false ), // no support for alignment properties
2356 maLogicalSize( AX_CONTAINER_DEFWIDTH
, AX_CONTAINER_DEFHEIGHT
),
2357 maScrollPos( 0, 0 ),
2358 mnBackColor( AX_SYSCOLOR_BUTTONFACE
),
2359 mnTextColor( AX_SYSCOLOR_BUTTONTEXT
),
2360 mnFlags( AX_CONTAINER_DEFFLAGS
),
2361 mnBorderColor( AX_SYSCOLOR_BUTTONTEXT
),
2362 mnBorderStyle( AX_BORDERSTYLE_NONE
),
2363 mnScrollBars( AX_CONTAINER_SCR_NONE
),
2364 mnCycleType( AX_CONTAINER_CYCLEALL
),
2365 mnSpecialEffect( AX_SPECIALEFFECT_FLAT
),
2366 mnPicAlign( AX_PICALIGN_CENTER
),
2367 mnPicSizeMode( AX_PICSIZE_CLIP
),
2368 mbPicTiling( false ),
2369 mbFontSupport( bFontSupport
)
2372 // different default size for frame
2373 maSize
= AxPairData( AX_CONTAINER_DEFWIDTH
, AX_CONTAINER_DEFHEIGHT
);
2376 void AxContainerModelBase::importProperty( sal_Int32 nPropId
, const OUString
& rValue
)
2378 if( nPropId
== XML_Caption
)
2382 bool AxContainerModelBase::importBinaryModel( BinaryInputStream
& rInStrm
)
2384 AxBinaryPropertyReader
aReader( rInStrm
);
2385 aReader
.skipUndefinedProperty();
2386 aReader
.readIntProperty
< sal_uInt32
>( mnBackColor
);
2387 aReader
.readIntProperty
< sal_uInt32
>( mnTextColor
);
2388 aReader
.skipIntProperty
< sal_uInt32
>(); // next availbale control ID
2389 aReader
.skipUndefinedProperty();
2390 aReader
.skipUndefinedProperty();
2391 aReader
.readIntProperty
< sal_uInt32
>( mnFlags
);
2392 aReader
.readIntProperty
< sal_uInt8
>( mnBorderStyle
);
2393 aReader
.skipIntProperty
< sal_uInt8
>(); // mouse pointer
2394 aReader
.readIntProperty
< sal_uInt8
>( mnScrollBars
);
2395 aReader
.readPairProperty( maSize
);
2396 aReader
.readPairProperty( maLogicalSize
);
2397 aReader
.readPairProperty( maScrollPos
);
2398 aReader
.skipIntProperty
< sal_uInt32
>(); // number of control groups
2399 aReader
.skipUndefinedProperty();
2400 aReader
.skipPictureProperty(); // mouse icon
2401 aReader
.readIntProperty
< sal_uInt8
>( mnCycleType
);
2402 aReader
.readIntProperty
< sal_uInt8
>( mnSpecialEffect
);
2403 aReader
.readIntProperty
< sal_uInt32
>( mnBorderColor
);
2404 aReader
.readStringProperty( maCaption
);
2405 aReader
.readFontProperty( maFontData
);
2406 aReader
.readPictureProperty( maPictureData
);
2407 aReader
.skipIntProperty
< sal_Int32
>(); // zoom
2408 aReader
.readIntProperty
< sal_uInt8
>( mnPicAlign
);
2409 aReader
.readBoolProperty( mbPicTiling
);
2410 aReader
.readIntProperty
< sal_uInt8
>( mnPicSizeMode
);
2411 aReader
.skipIntProperty
< sal_uInt32
>(); // shape cookie
2412 aReader
.skipIntProperty
< sal_uInt32
>(); // draw buffer size
2413 return aReader
.finalizeImport();
2416 void AxContainerModelBase::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
2420 rConv
.convertColor( rPropMap
, PROP_TextColor
, mnTextColor
);
2421 AxFontDataModel::convertProperties( rPropMap
, rConv
);
2425 bool AxContainerModelBase::importClassTable( BinaryInputStream
& rInStrm
, AxClassTable
& orClassTable
)
2428 orClassTable
.clear();
2429 if( !getFlag( mnFlags
, AX_CONTAINER_NOCLASSTABLE
) )
2431 sal_uInt16 nCount
= rInStrm
.readuInt16();
2432 for( sal_uInt16 nIndex
= 0; bValid
&& (nIndex
< nCount
); ++nIndex
)
2434 orClassTable
.push_back( OUString() );
2435 AxBinaryPropertyReader
aReader( rInStrm
);
2436 aReader
.readGuidProperty( orClassTable
.back() );
2437 aReader
.skipGuidProperty(); // source interface GUID
2438 aReader
.skipUndefinedProperty();
2439 aReader
.skipGuidProperty(); // default interface GUID
2440 aReader
.skipIntProperty
< sal_uInt32
>(); // class table and var flags
2441 aReader
.skipIntProperty
< sal_uInt32
>(); // method count
2442 aReader
.skipIntProperty
< sal_Int32
>(); // IDispatch identifier for linked cell access
2443 aReader
.skipIntProperty
< sal_uInt16
>(); // get function index for linked cell access
2444 aReader
.skipIntProperty
< sal_uInt16
>(); // put function index for linked cell access
2445 aReader
.skipIntProperty
< sal_uInt16
>(); // linked cell access property type
2446 aReader
.skipIntProperty
< sal_uInt16
>(); // get function index of value
2447 aReader
.skipIntProperty
< sal_uInt16
>(); // put function index of value
2448 aReader
.skipIntProperty
< sal_uInt16
>(); // value type
2449 aReader
.skipIntProperty
< sal_Int32
>(); // IDispatch identifier for source range access
2450 aReader
.skipIntProperty
< sal_uInt16
>(); // get function index for source range access
2451 bValid
= aReader
.finalizeImport();
2457 // ============================================================================
2459 AxFrameModel::AxFrameModel() :
2460 AxContainerModelBase( true )
2464 ApiControlType
AxFrameModel::getControlType() const
2466 return mbAwtModel
? API_CONTROL_FRAME
: API_CONTROL_GROUPBOX
;
2469 void AxFrameModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
2471 rPropMap
.setProperty( PROP_Label
, maCaption
);
2472 rPropMap
.setProperty( PROP_Enabled
, getFlag( mnFlags
, AX_CONTAINER_ENABLED
) );
2473 #ifdef SCROLLABLEFRAME
2474 rConv
.convertScrollabilitySettings( rPropMap
, maScrollPos
, maLogicalSize
, mnScrollBars
);
2476 AxContainerModelBase::convertProperties( rPropMap
, rConv
);
2479 AxPageModel::AxPageModel()
2483 ApiControlType
AxPageModel::getControlType() const
2485 return API_CONTROL_PAGE
;
2488 void AxPageModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
2490 rPropMap
.setProperty( PROP_Title
, maCaption
);
2491 rConv
.convertColor( rPropMap
, PROP_BackgroundColor
, mnBackColor
);
2492 rPropMap
.setProperty( PROP_Enabled
, getFlag( mnFlags
, AX_CONTAINER_ENABLED
) );
2493 AxContainerModelBase::convertProperties( rPropMap
, rConv
);
2496 AxMultiPageModel::AxMultiPageModel() :
2498 mnTabStyle( AX_TABSTRIP_TABS
)
2502 ApiControlType
AxMultiPageModel::getControlType() const
2504 return API_CONTROL_MULTIPAGE
;
2508 bool AxMultiPageModel::importPageAndMultiPageProperties( BinaryInputStream
& rInStrm
, sal_Int32 nPages
)
2511 for ( sal_Int32 nPage
= 0; nPage
< nPages
; ++nPage
)
2513 AxBinaryPropertyReader
aReader( rInStrm
);
2514 aReader
.skipUndefinedProperty();
2515 aReader
.skipIntProperty
< sal_uInt32
>(); // TransistionEffect
2516 aReader
.skipIntProperty
< sal_uInt32
>(); // TransitionPeriod
2518 // MultiPageProperties
2519 AxBinaryPropertyReader
aReader( rInStrm
);
2520 sal_uInt32 nPageCount
= 0;
2521 aReader
.skipUndefinedProperty();
2522 aReader
.readIntProperty
< sal_uInt32
>(nPageCount
); // PageCount
2523 aReader
.skipIntProperty
< sal_uInt32
>(); //ID
2526 for ( sal_uInt32 count
= 0; count
< nPageCount
; ++count
)
2530 mnIDs
.push_back( nID
);
2535 void AxMultiPageModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
2537 rPropMap
.setProperty( PROP_Title
, maCaption
);
2538 rPropMap
.setProperty( PROP_MultiPageValue
, mnActiveTab
+ 1);
2539 rConv
.convertColor( rPropMap
, PROP_BackgroundColor
, mnBackColor
);
2540 rPropMap
.setProperty( PROP_Enabled
, getFlag( mnFlags
, AX_CONTAINER_ENABLED
) );
2541 rPropMap
.setProperty( PROP_Decoration
, mnTabStyle
!= AX_TABSTRIP_NONE
);
2543 AxContainerModelBase::convertProperties( rPropMap
, rConv
);
2547 // ============================================================================
2549 AxUserFormModel::AxUserFormModel()
2553 ApiControlType
AxUserFormModel::getControlType() const
2555 return API_CONTROL_DIALOG
;
2558 void AxUserFormModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
2560 rPropMap
.setProperty( PROP_Title
, maCaption
);
2561 rConv
.convertColor( rPropMap
, PROP_BackgroundColor
, mnBackColor
);
2562 rConv
.convertAxPicture( rPropMap
, maPictureData
, AX_PICPOS_CENTER
);
2563 rConv
.convertScrollabilitySettings( rPropMap
, maScrollPos
, maLogicalSize
, mnScrollBars
);
2564 AxContainerModelBase::convertProperties( rPropMap
, rConv
);
2567 HtmlSelectModel::HtmlSelectModel()
2572 HtmlSelectModel::importBinaryModel( BinaryInputStream
& rInStrm
)
2574 static OUString
sMultiple( "<SELECT MULTIPLE" );
2575 static OUString
sSelected( "OPTION SELECTED" );
2577 OUString sStringContents
= rInStrm
.readUnicodeArray( rInStrm
.size() );
2579 OUString data
= sStringContents
;
2581 // replace crlf with lf
2582 data
= data
.replaceAll( "\x0D\x0A" , "\x0A" );
2583 std::vector
< OUString
> listValues
;
2584 std::vector
< sal_Int16
> selectedIndices
;
2586 // Ultra hacky parser for the info
2587 sal_Int32 nTokenCount
= comphelper::string::getTokenCount(data
, '\n');
2589 for ( sal_Int32 nToken
= 0; nToken
< nTokenCount
; ++nToken
)
2591 OUString
sLine( data
.getToken( nToken
, '\n' ) );
2592 if ( !nToken
) // first line will tell us if multiselect is enabled
2594 if ( sLine
== sMultiple
)
2595 mnMultiSelect
= true;
2597 // skip first and last lines, no data there
2598 else if ( nToken
< nTokenCount
- 1)
2600 if ( comphelper::string::getTokenCount(sLine
, '>') )
2602 OUString displayValue
= sLine
.getToken( 1, '>' );
2603 if ( displayValue
.getLength() )
2605 // Really we should be using a proper html parser
2606 // escaping some common bits to be escaped
2607 displayValue
= displayValue
.replaceAll( "<", "<" );
2608 displayValue
= displayValue
.replaceAll( ">", ">" );
2609 displayValue
= displayValue
.replaceAll( """, "\"" );
2610 displayValue
= displayValue
.replaceAll( "&", "&" );
2611 listValues
.push_back( displayValue
);
2612 if( sLine
.indexOf( sSelected
) != -1 )
2613 selectedIndices
.push_back( static_cast< sal_Int16
>( listValues
.size() ) - 1 );
2618 if ( !listValues
.empty() )
2620 msListData
.realloc( listValues
.size() );
2621 sal_Int32 index
= 0;
2622 for( std::vector
< OUString
>::iterator it
= listValues
.begin(); it
!= listValues
.end(); ++it
, ++index
)
2623 msListData
[ index
] = *it
;
2625 if ( !selectedIndices
.empty() )
2627 msIndices
.realloc( selectedIndices
.size() );
2628 sal_Int32 index
= 0;
2629 for( std::vector
< sal_Int16
>::iterator it
= selectedIndices
.begin(); it
!= selectedIndices
.end(); ++it
, ++index
)
2630 msIndices
[ index
] = *it
;
2637 HtmlSelectModel::convertProperties( PropertyMap
& rPropMap
, const ControlConverter
& rConv
) const
2639 rPropMap
.setProperty( PROP_StringItemList
, msListData
);
2640 rPropMap
.setProperty( PROP_SelectedItems
, msIndices
);
2641 rPropMap
.setProperty( PROP_Dropdown
, true );
2642 AxListBoxModel::convertProperties( rPropMap
, rConv
);
2645 HtmlTextBoxModel::HtmlTextBoxModel()
2650 HtmlTextBoxModel::importBinaryModel( BinaryInputStream
& rInStrm
)
2653 OUString sStringContents
= rInStrm
.readUnicodeArray( rInStrm
.size() );
2654 // in msocximex ( where this is ported from, it appears *nothing* is read
2655 // from the control stream ), surely there is some useful info there ?
2656 OSL_TRACE("HtmlTextBoxModel::importBinaryModel - string contents of stream :");
2657 OSL_TRACE("%s", OUStringToOString( sStringContents
, RTL_TEXTENCODING_UTF8
).getStr() );
2663 // ============================================================================
2665 EmbeddedControl::EmbeddedControl( const OUString
& rName
) :
2670 EmbeddedControl::~EmbeddedControl()
2674 ControlModelBase
* EmbeddedControl::createModelFromGuid( const OUString
& rClassId
)
2676 OUString aClassId
= rClassId
;//.toAsciiUpperCase();
2678 if( aClassId
.equalsIgnoreAsciiCase( AX_GUID_COMMANDBUTTON
) ) return &createModel
< AxCommandButtonModel
>();
2679 if( aClassId
.equalsIgnoreAsciiCase( AX_GUID_LABEL
) ) return &createModel
< AxLabelModel
>();
2680 if( aClassId
.equalsIgnoreAsciiCase( AX_GUID_IMAGE
) ) return &createModel
< AxImageModel
>();
2681 if( aClassId
.equalsIgnoreAsciiCase( AX_GUID_TOGGLEBUTTON
) ) return &createModel
< AxToggleButtonModel
>();
2682 if( aClassId
.equalsIgnoreAsciiCase( AX_GUID_CHECKBOX
) ) return &createModel
< AxCheckBoxModel
>();
2683 if( aClassId
.equalsIgnoreAsciiCase( AX_GUID_OPTIONBUTTON
) ) return &createModel
< AxOptionButtonModel
>();
2684 if( aClassId
.equalsIgnoreAsciiCase( AX_GUID_TEXTBOX
) ) return &createModel
< AxTextBoxModel
>();
2685 if( aClassId
.equalsIgnoreAsciiCase( AX_GUID_LISTBOX
) ) return &createModel
< AxListBoxModel
>();
2686 if( aClassId
.equalsIgnoreAsciiCase( AX_GUID_COMBOBOX
) ) return &createModel
< AxComboBoxModel
>();
2687 if( aClassId
.equalsIgnoreAsciiCase( AX_GUID_SPINBUTTON
) ) return &createModel
< AxSpinButtonModel
>();
2688 if( aClassId
.equalsIgnoreAsciiCase( AX_GUID_SCROLLBAR
) ) return &createModel
< AxScrollBarModel
>();
2689 if( aClassId
.equalsIgnoreAsciiCase( AX_GUID_FRAME
) ) return &createModel
< AxFrameModel
>();
2690 if( aClassId
.equalsIgnoreAsciiCase( COMCTL_GUID_SCROLLBAR_60
) ) return &createModel
< ComCtlScrollBarModel
>( COMCTL_VERSION_60
);
2691 if( aClassId
.equalsIgnoreAsciiCase( HTML_GUID_SELECT
) ) return &createModel
< HtmlSelectModel
>();
2692 if( aClassId
.equalsIgnoreAsciiCase( HTML_GUID_TEXTBOX
) ) return &createModel
< HtmlTextBoxModel
>();
2698 OUString
EmbeddedControl::getServiceName() const
2700 return mxModel
.get() ? mxModel
->getServiceName() : OUString();
2703 bool EmbeddedControl::convertProperties( const Reference
< XControlModel
>& rxCtrlModel
, const ControlConverter
& rConv
) const
2705 if( mxModel
.get() && rxCtrlModel
.is() && !maName
.isEmpty() )
2707 PropertyMap aPropMap
;
2708 aPropMap
.setProperty( PROP_Name
, maName
);
2711 aPropMap
.setProperty( PROP_GenerateVbaEvents
, true);
2713 catch (const Exception
& e
)
2715 SAL_WARN("oox", "exception: " << e
.Message
);
2717 mxModel
->convertProperties( aPropMap
, rConv
);
2718 PropertySet
aPropSet( rxCtrlModel
);
2719 aPropSet
.setProperties( aPropMap
);
2725 bool EmbeddedControl::convertFromProperties( const Reference
< XControlModel
>& rxCtrlModel
, const ControlConverter
& rConv
)
2727 if( mxModel
.get() && rxCtrlModel
.is() && !maName
.isEmpty() )
2729 PropertySet
aPropSet( rxCtrlModel
);
2730 aPropSet
.getProperty( maName
, PROP_Name
);
2731 mxModel
->convertFromProperties( aPropSet
, rConv
);
2737 // ============================================================================
2739 EmbeddedForm::EmbeddedForm( const Reference
< XModel
>& rxDocModel
,
2740 const Reference
< XDrawPage
>& rxDrawPage
, const GraphicHelper
& rGraphicHelper
, bool bDefaultColorBgr
) :
2741 maControlConv( rxDocModel
, rGraphicHelper
, bDefaultColorBgr
),
2742 mxModelFactory( rxDocModel
, UNO_QUERY
),
2743 mxFormsSupp( rxDrawPage
, UNO_QUERY
)
2745 OSL_ENSURE( mxModelFactory
.is(), "EmbeddedForm::EmbeddedForm - missing service factory" );
2748 Reference
< XControlModel
> EmbeddedForm::convertAndInsert( const EmbeddedControl
& rControl
, sal_Int32
& rnCtrlIndex
)
2750 Reference
< XControlModel
> xRet
;
2751 if( mxModelFactory
.is() && rControl
.hasModel() ) try
2753 // create the UNO control model
2754 OUString aServiceName
= rControl
.getServiceName();
2755 Reference
< XFormComponent
> xFormComp( mxModelFactory
->createInstance( aServiceName
), UNO_QUERY_THROW
);
2756 Reference
< XControlModel
> xCtrlModel( xFormComp
, UNO_QUERY_THROW
);
2758 // convert the control properties
2759 if( rControl
.convertProperties( xCtrlModel
, maControlConv
) )
2761 // insert the control into the form
2762 Reference
< XIndexContainer
> xFormIC( createXForm(), UNO_SET_THROW
);
2763 rnCtrlIndex
= xFormIC
->getCount();
2764 xFormIC
->insertByIndex( rnCtrlIndex
, Any( xFormComp
) );
2766 catch (const Exception
& e
)
2768 SAL_WARN("oox", "exception creating Control: " << e
.Message
);
2773 Reference
< XIndexContainer
> EmbeddedForm::createXForm()
2775 if( mxFormsSupp
.is() )
2779 Reference
< XNameContainer
> xFormsNC( mxFormsSupp
->getForms(), UNO_SET_THROW
);
2780 OUString aFormName
= "Standard";
2781 if( xFormsNC
->hasByName( aFormName
) )
2783 mxFormIC
.set( xFormsNC
->getByName( aFormName
), UNO_QUERY_THROW
);
2785 else if( mxModelFactory
.is() )
2787 Reference
< XForm
> xForm( mxModelFactory
->createInstance( "com.sun.star.form.component.Form" ), UNO_QUERY_THROW
);
2788 xFormsNC
->insertByName( aFormName
, Any( xForm
) );
2789 mxFormIC
.set( xForm
, UNO_QUERY_THROW
);
2792 catch (const Exception
& e
)
2794 SAL_WARN("oox", "exception creating Form: " << e
.Message
);
2796 // always clear the forms supplier to not try to create the form again
2797 mxFormsSupp
.clear();
2802 // ============================================================================
2807 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */