LCOV - code coverage report
Current view: top level - oox/source/ole - axcontrol.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 609 1492 40.8 %
Date: 2014-11-03 Functions: 80 183 43.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #include "oox/ole/axcontrol.hxx"
      21             : 
      22             : #include <com/sun/star/awt/FontSlant.hpp>
      23             : #include <com/sun/star/awt/FontStrikeout.hpp>
      24             : #include <com/sun/star/awt/FontUnderline.hpp>
      25             : #include <com/sun/star/awt/FontWeight.hpp>
      26             : #include <com/sun/star/awt/ImagePosition.hpp>
      27             : #include <com/sun/star/awt/ImageScaleMode.hpp>
      28             : #include <com/sun/star/awt/Point.hpp>
      29             : #include <com/sun/star/awt/ScrollBarOrientation.hpp>
      30             : #include <com/sun/star/awt/Size.hpp>
      31             : #include <com/sun/star/awt/TextAlign.hpp>
      32             : #include <com/sun/star/awt/VisualEffect.hpp>
      33             : #include <com/sun/star/awt/XControlModel.hpp>
      34             : #include <com/sun/star/beans/NamedValue.hpp>
      35             : #include <com/sun/star/container/XIndexContainer.hpp>
      36             : #include <com/sun/star/form/XForm.hpp>
      37             : #include <com/sun/star/form/XFormComponent.hpp>
      38             : #include <com/sun/star/form/XFormsSupplier.hpp>
      39             : #include <com/sun/star/form/binding/XBindableValue.hpp>
      40             : #include <com/sun/star/form/binding/XListEntrySink.hpp>
      41             : #include <com/sun/star/form/binding/XListEntrySource.hpp>
      42             : #include <com/sun/star/form/binding/XValueBinding.hpp>
      43             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      44             : #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
      45             : #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
      46             : #include <com/sun/star/style/VerticalAlignment.hpp>
      47             : #include <com/sun/star/table/CellAddress.hpp>
      48             : #include <com/sun/star/table/CellRangeAddress.hpp>
      49             : #include <comphelper/string.hxx>
      50             : #include <rtl/tencinfo.h>
      51             : #include "oox/helper/attributelist.hxx"
      52             : #include "oox/helper/binaryinputstream.hxx"
      53             : #include "oox/helper/containerhelper.hxx"
      54             : #include "oox/helper/graphichelper.hxx"
      55             : #include "oox/helper/propertymap.hxx"
      56             : #include "oox/ole/axbinarywriter.hxx"
      57             : namespace oox {
      58             : namespace ole {
      59             : 
      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;
      73             : 
      74             : namespace {
      75             : 
      76             : const sal_uInt32 COMCTL_ID_SIZE             = 0x12344321;
      77             : 
      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;
      82             : 
      83             : const sal_uInt32 COMCTL_ID_COMPLEXDATA      = 0xBDECDE1F;
      84             : const sal_uInt32 COMCTL_COMPLEX_FONT        = 0x00000001;
      85             : const sal_uInt32 COMCTL_COMPLEX_MOUSEICON   = 0x00000002;
      86             : 
      87             : const sal_uInt32 COMCTL_ID_SCROLLBAR_60     = 0x99470A83;
      88             : const sal_uInt32 COMCTL_SCROLLBAR_HOR       = 0x00000010;
      89             : 
      90             : const sal_uInt32 COMCTL_ID_PROGRESSBAR_50   = 0xE6E17E84;
      91             : const sal_uInt32 COMCTL_ID_PROGRESSBAR_60   = 0x97AB8A01;
      92             : 
      93             : const sal_uInt32 AX_CMDBUTTON_DEFFLAGS      = 0x0000001B;
      94             : const sal_uInt32 AX_LABEL_DEFFLAGS          = 0x0080001B;
      95             : const sal_uInt32 AX_IMAGE_DEFFLAGS          = 0x0000001B;
      96             : const sal_uInt32 AX_MORPHDATA_DEFFLAGS      = 0x2C80081B;
      97             : const sal_uInt32 AX_SPINBUTTON_DEFFLAGS     = 0x0000001B;
      98             : const sal_uInt32 AX_SCROLLBAR_DEFFLAGS      = 0x0000001B;
      99             : 
     100             : const sal_uInt16 AX_POS_TOPLEFT             = 0;
     101             : const sal_uInt16 AX_POS_TOP                 = 1;
     102             : const sal_uInt16 AX_POS_TOPRIGHT            = 2;
     103             : const sal_uInt16 AX_POS_LEFT                = 3;
     104             : const sal_uInt16 AX_POS_CENTER              = 4;
     105             : const sal_uInt16 AX_POS_RIGHT               = 5;
     106             : const sal_uInt16 AX_POS_BOTTOMLEFT          = 6;
     107             : const sal_uInt16 AX_POS_BOTTOM              = 7;
     108             : const sal_uInt16 AX_POS_BOTTOMRIGHT         = 8;
     109             : 
     110             : #define AX_PICPOS_IMPL( label, image ) ((AX_POS_##label << 16) | AX_POS_##image)
     111             : const sal_uInt32 AX_PICPOS_LEFTTOP          = AX_PICPOS_IMPL( TOPRIGHT,    TOPLEFT );
     112             : const sal_uInt32 AX_PICPOS_LEFTCENTER       = AX_PICPOS_IMPL( RIGHT,       LEFT );
     113             : const sal_uInt32 AX_PICPOS_LEFTBOTTOM       = AX_PICPOS_IMPL( BOTTOMRIGHT, BOTTOMLEFT );
     114             : const sal_uInt32 AX_PICPOS_RIGHTTOP         = AX_PICPOS_IMPL( TOPLEFT,     TOPRIGHT );
     115             : const sal_uInt32 AX_PICPOS_RIGHTCENTER      = AX_PICPOS_IMPL( LEFT,        RIGHT );
     116             : const sal_uInt32 AX_PICPOS_RIGHTBOTTOM      = AX_PICPOS_IMPL( BOTTOMLEFT,  BOTTOMRIGHT );
     117             : const sal_uInt32 AX_PICPOS_ABOVELEFT        = AX_PICPOS_IMPL( BOTTOMLEFT,  TOPLEFT );
     118             : const sal_uInt32 AX_PICPOS_ABOVECENTER      = AX_PICPOS_IMPL( BOTTOM,      TOP  );
     119             : const sal_uInt32 AX_PICPOS_ABOVERIGHT       = AX_PICPOS_IMPL( BOTTOMRIGHT, TOPRIGHT );
     120             : const sal_uInt32 AX_PICPOS_BELOWLEFT        = AX_PICPOS_IMPL( TOPLEFT,     BOTTOMLEFT );
     121             : const sal_uInt32 AX_PICPOS_BELOWCENTER      = AX_PICPOS_IMPL( TOP,         BOTTOM );
     122             : const sal_uInt32 AX_PICPOS_BELOWRIGHT       = AX_PICPOS_IMPL( TOPRIGHT,    BOTTOMRIGHT );
     123             : const sal_uInt32 AX_PICPOS_CENTER           = AX_PICPOS_IMPL( CENTER,      CENTER  );
     124             : #undef AX_PICPOS_IMPL
     125             : 
     126             : const sal_Int32 AX_MATCHENTRY_FIRSTLETTER   = 0;
     127             : const sal_Int32 AX_MATCHENTRY_COMPLETE      = 1;
     128             : const sal_Int32 AX_MATCHENTRY_NONE          = 2;
     129             : 
     130             : const sal_Int32 AX_ORIENTATION_AUTO         = -1;
     131             : const sal_Int32 AX_ORIENTATION_VERTICAL     = 0;
     132             : const sal_Int32 AX_ORIENTATION_HORIZONTAL   = 1;
     133             : 
     134             : const sal_Int32 AX_PROPTHUMB_ON             = -1;
     135             : 
     136             : const sal_uInt32 AX_TABSTRIP_TABS           = 0;
     137             : const sal_uInt32 AX_TABSTRIP_NONE           = 2;
     138             : 
     139             : const sal_uInt32 AX_CONTAINER_ENABLED       = 0x00000004;
     140             : const sal_uInt32 AX_CONTAINER_NOCLASSTABLE  = 0x00008000;
     141             : 
     142             : const sal_uInt32 AX_CONTAINER_DEFFLAGS      = 0x00000004;
     143             : 
     144             : const sal_Int32 AX_CONTAINER_DEFWIDTH       = 4000;
     145             : const sal_Int32 AX_CONTAINER_DEFHEIGHT      = 3000;
     146             : 
     147             : const sal_Int32 AX_CONTAINER_CYCLEALL       = 0;
     148             : 
     149             : const sal_Int32 AX_CONTAINER_SCR_NONE       = 0x00;
     150             : 
     151             : const sal_Int16 API_BORDER_NONE             = 0;
     152             : const sal_Int16 API_BORDER_SUNKEN           = 1;
     153             : const sal_Int16 API_BORDER_FLAT             = 2;
     154             : 
     155             : const sal_Int16 API_STATE_UNCHECKED         = 0;
     156             : const sal_Int16 API_STATE_CHECKED           = 1;
     157             : const sal_Int16 API_STATE_DONTKNOW          = 2;
     158             : 
     159             : /** Tries to extract a range address from a defined name. */
     160           2 : bool lclExtractRangeFromName( CellRangeAddress& orRangeAddr, const Reference< XModel >& rxDocModel, const OUString& rAddressString )
     161             : {
     162             :     try
     163             :     {
     164           2 :         PropertySet aPropSet( rxDocModel );
     165           4 :         Reference< XNameAccess > xRangesNA( aPropSet.getAnyProperty( PROP_NamedRanges ), UNO_QUERY_THROW );
     166           2 :         Reference< XCellRangeReferrer > xReferrer( xRangesNA->getByName( rAddressString ), UNO_QUERY_THROW );
     167           0 :         Reference< XCellRangeAddressable > xAddressable( xReferrer->getReferredCells(), UNO_QUERY_THROW );
     168           0 :         orRangeAddr = xAddressable->getRangeAddress();
     169           2 :         return true;
     170             :     }
     171           2 :     catch (const Exception& e)
     172             :     {
     173             :         SAL_WARN("oox", "exception: " << e.Message);
     174             :     }
     175           2 :     return false;
     176             : }
     177             : 
     178           0 : bool lclExtractAddressFromName( CellAddress& orAddress, const Reference< XModel >& rxDocModel, const OUString& rAddressString )
     179             : {
     180           0 :     CellRangeAddress aRangeAddr;
     181           0 :     if( lclExtractRangeFromName( aRangeAddr, rxDocModel, rAddressString ) &&
     182           0 :         (aRangeAddr.StartColumn == aRangeAddr.EndColumn) &&
     183           0 :         (aRangeAddr.StartRow == aRangeAddr.EndRow) )
     184             :     {
     185           0 :         orAddress.Sheet = aRangeAddr.Sheet;
     186           0 :         orAddress.Column = aRangeAddr.StartColumn;
     187           0 :         orAddress.Row = aRangeAddr.StartRow;
     188           0 :         return true;
     189             :     }
     190           0 :     return false;
     191             : }
     192             : 
     193           2 : void lclPrepareConverter( PropertySet& rConverter, const Reference< XModel >& rxDocModel,
     194             :         const OUString& rAddressString, sal_Int32 nRefSheet, bool bRange )
     195             : {
     196           2 :     if( !rConverter.is() ) try
     197             :     {
     198           2 :         Reference< XMultiServiceFactory > xModelFactory( rxDocModel, UNO_QUERY_THROW );
     199             :         OUString aServiceName = bRange ?
     200             :             OUString( "com.sun.star.table.CellRangeAddressConversion" ) :
     201           4 :             OUString( "com.sun.star.table.CellAddressConversion" );
     202           4 :         rConverter.set( xModelFactory->createInstance( aServiceName ) );
     203             :     }
     204           0 :     catch (const Exception& e)
     205             :     {
     206             :         SAL_WARN("oox", "exception: " << e.Message);
     207             :     }
     208           2 :     rConverter.setProperty( PROP_XLA1Representation, rAddressString );
     209           2 :     rConverter.setProperty( PROP_ReferenceSheet, nRefSheet );
     210           2 : }
     211             : 
     212             : } // namespace
     213             : 
     214         336 : ControlConverter::ControlConverter( const Reference< XModel >& rxDocModel,
     215             :         const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ) :
     216             :     mxDocModel( rxDocModel ),
     217             :     mrGraphicHelper( rGraphicHelper ),
     218         336 :     mbDefaultColorBgr( bDefaultColorBgr )
     219             : {
     220             :     OSL_ENSURE( mxDocModel.is(), "ControlConverter::ControlConverter - missing document model" );
     221         336 : }
     222             : 
     223         336 : ControlConverter::~ControlConverter()
     224             : {
     225         336 : }
     226             : 
     227             : // Generic conversion ---------------------------------------------------------
     228             : 
     229          12 : void ControlConverter::convertPosition( PropertyMap& rPropMap, const AxPairData& rPos ) const
     230             : {
     231             :     // position is given in 1/100 mm, UNO needs AppFont units
     232          12 :     awt::Point aAppFontPos = mrGraphicHelper.convertHmmToAppFont( awt::Point( rPos.first, rPos.second ) );
     233          12 :     rPropMap.setProperty( PROP_PositionX, aAppFontPos.X );
     234          12 :     rPropMap.setProperty( PROP_PositionY, aAppFontPos.Y );
     235          12 : }
     236             : 
     237          16 : void ControlConverter::convertSize( PropertyMap& rPropMap, const AxPairData& rSize ) const
     238             : {
     239             :     // size is given in 1/100 mm, UNO needs AppFont units
     240          16 :     awt::Size aAppFontSize = mrGraphicHelper.convertHmmToAppFont( awt::Size( rSize.first, rSize.second ) );
     241          16 :     rPropMap.setProperty( PROP_Width, aAppFontSize.Width );
     242          16 :     rPropMap.setProperty( PROP_Height, aAppFontSize.Height );
     243          16 : }
     244             : 
     245         184 : void ControlConverter::convertColor( PropertyMap& rPropMap, sal_Int32 nPropId, sal_uInt32 nOleColor ) const
     246             : {
     247         184 :     rPropMap.setProperty( nPropId, OleHelper::decodeOleColor( mrGraphicHelper, nOleColor, mbDefaultColorBgr ) );
     248         184 : }
     249             : 
     250           4 : void ControlConverter::convertToMSColor( PropertySet& rPropSet, sal_Int32 nPropId, sal_uInt32& nOleColor, sal_uInt32 nDefault ) const
     251             : {
     252           4 :     sal_uInt32 nRGB = 0;
     253           4 :     if (rPropSet.getProperty( nRGB, nPropId ))
     254           0 :         nOleColor = OleHelper::encodeOleColor( nRGB );
     255             :     else
     256           4 :         nOleColor = nDefault;
     257           4 : }
     258          68 : void ControlConverter::convertPicture( PropertyMap& rPropMap, const StreamDataSequence& rPicData ) const
     259             : {
     260          68 :     if( rPicData.hasElements() )
     261             :     {
     262           0 :         OUString aGraphicUrl = mrGraphicHelper.importGraphicObject( rPicData );
     263           0 :         if( !aGraphicUrl.isEmpty() )
     264           0 :             rPropMap.setProperty( PROP_ImageURL, aGraphicUrl );
     265             :     }
     266          68 : }
     267             : 
     268           0 : void ControlConverter::convertOrientation( PropertyMap& rPropMap, bool bHorizontal ) const
     269             : {
     270           0 :     sal_Int32 nScrollOrient = bHorizontal ? ScrollBarOrientation::HORIZONTAL : ScrollBarOrientation::VERTICAL;
     271           0 :     rPropMap.setProperty( PROP_Orientation, nScrollOrient );
     272           0 : }
     273             : 
     274           0 : void ControlConverter::convertToMSOrientation( PropertySet& rPropSet, bool& bHorizontal ) const
     275             : {
     276           0 :     sal_Int32 nScrollOrient = ScrollBarOrientation::HORIZONTAL;
     277           0 :     if ( rPropSet.getProperty( nScrollOrient, PROP_Orientation ) )
     278           0 :         bHorizontal = ( nScrollOrient == ScrollBarOrientation::HORIZONTAL );
     279           0 : }
     280             : 
     281          66 : void ControlConverter::convertVerticalAlign( PropertyMap& rPropMap, sal_Int32 nVerticalAlign ) const
     282             : {
     283          66 :     VerticalAlignment eAlign = VerticalAlignment_TOP;
     284          66 :     switch( nVerticalAlign )
     285             :     {
     286           2 :         case XML_Top:       eAlign = VerticalAlignment_TOP;     break;
     287          64 :         case XML_Center:    eAlign = VerticalAlignment_MIDDLE;  break;
     288           0 :         case XML_Bottom:    eAlign = VerticalAlignment_BOTTOM;  break;
     289             :     }
     290          66 :     rPropMap.setProperty( PROP_VerticalAlign, eAlign );
     291          66 : }
     292             : 
     293           4 : void ControlConverter::convertScrollabilitySettings( PropertyMap& rPropMap,
     294             :                                          const AxPairData& rScrollPos, const AxPairData& rScrollArea,
     295             :                                          sal_Int32 nScrollBars ) const
     296             : {
     297           4 :     awt::Size tmpSize = mrGraphicHelper.convertHmmToAppFont( awt::Size( rScrollArea.first, rScrollArea.second ) );
     298           4 :     awt::Point tmpPos = mrGraphicHelper.convertHmmToAppFont( awt::Point( rScrollPos.first, rScrollPos.second ) );
     299           4 :     rPropMap.setProperty( PROP_ScrollHeight, tmpSize.Height );
     300           4 :     rPropMap.setProperty( PROP_ScrollWidth, tmpSize.Width );
     301           4 :     rPropMap.setProperty( PROP_ScrollTop, tmpPos.Y );
     302           4 :     rPropMap.setProperty( PROP_ScrollLeft, tmpPos.X );
     303           4 :     rPropMap.setProperty( PROP_HScroll, ( nScrollBars & 0x1 ) == 0x1 );
     304           4 :     rPropMap.setProperty( PROP_VScroll, ( nScrollBars & 0x2 ) == 0x2 );
     305           4 : }
     306             : 
     307           0 : void ControlConverter::convertScrollBar( PropertyMap& rPropMap,
     308             :         sal_Int32 nMin, sal_Int32 nMax, sal_Int32 nPosition,
     309             :         sal_Int32 nSmallChange, sal_Int32 nLargeChange, bool bAwtModel ) const
     310             : {
     311           0 :     rPropMap.setProperty( PROP_ScrollValueMin, ::std::min( nMin, nMax ) );
     312           0 :     rPropMap.setProperty( PROP_ScrollValueMax, ::std::max( nMin, nMax ) );
     313           0 :     rPropMap.setProperty( PROP_LineIncrement, nSmallChange );
     314           0 :     rPropMap.setProperty( PROP_BlockIncrement, nLargeChange );
     315           0 :     rPropMap.setProperty( bAwtModel ? PROP_ScrollValue : PROP_DefaultScrollValue, nPosition );
     316           0 : }
     317             : 
     318          16 : void ControlConverter::bindToSources( const Reference< XControlModel >& rxCtrlModel,
     319             :         const OUString& rCtrlSource, const OUString& rRowSource, sal_Int32 nRefSheet ) const
     320             : {
     321             :     // value binding
     322          16 :     if( !rCtrlSource.isEmpty() ) try
     323             :     {
     324             :         // first check if the XBindableValue interface is supported
     325           0 :         Reference< XBindableValue > xBindable( rxCtrlModel, UNO_QUERY_THROW );
     326             : 
     327             :         // convert address string to cell address struct
     328           0 :         CellAddress aAddress;
     329           0 :         if( !lclExtractAddressFromName( aAddress, mxDocModel, rCtrlSource ) )
     330             :         {
     331           0 :             lclPrepareConverter( maAddressConverter, mxDocModel, rCtrlSource, nRefSheet, false );
     332           0 :             if( !maAddressConverter.getProperty( aAddress, PROP_Address ) )
     333           0 :                 throw RuntimeException();
     334             :         }
     335             : 
     336             :         // create argument sequence
     337           0 :         NamedValue aValue;
     338           0 :         aValue.Name = "BoundCell";
     339           0 :         aValue.Value <<= aAddress;
     340           0 :         Sequence< Any > aArgs( 1 );
     341           0 :         aArgs[ 0 ] <<= aValue;
     342             : 
     343             :         // create the CellValueBinding instance and set at the control model
     344           0 :         Reference< XMultiServiceFactory > xModelFactory( mxDocModel, UNO_QUERY_THROW );
     345           0 :         Reference< XValueBinding > xBinding( xModelFactory->createInstanceWithArguments( "com.sun.star.table.CellValueBinding", aArgs ), UNO_QUERY_THROW );
     346           0 :         xBindable->setValueBinding( xBinding );
     347             :     }
     348           0 :     catch (const Exception& e)
     349             :     {
     350             :         SAL_WARN("oox", "exception: " << e.Message);
     351             :     }
     352             : 
     353             :     // list entry source
     354          16 :     if( !rRowSource.isEmpty() ) try
     355             :     {
     356             :         // first check if the XListEntrySink interface is supported
     357           2 :         Reference< XListEntrySink > xEntrySink( rxCtrlModel, UNO_QUERY_THROW );
     358             : 
     359             :         // convert address string to cell range address struct
     360           2 :         CellRangeAddress aRangeAddr;
     361           2 :         if( !lclExtractRangeFromName( aRangeAddr, mxDocModel, rRowSource ) )
     362             :         {
     363           2 :             lclPrepareConverter( maRangeConverter, mxDocModel, rRowSource, nRefSheet, true );
     364           2 :             if( !maRangeConverter.getProperty( aRangeAddr, PROP_Address ) )
     365           0 :                 throw RuntimeException();
     366             :         }
     367             : 
     368             :         // create argument sequence
     369           4 :         NamedValue aValue;
     370           2 :         aValue.Name = "CellRange";
     371           2 :         aValue.Value <<= aRangeAddr;
     372           4 :         Sequence< Any > aArgs( 1 );
     373           2 :         aArgs[ 0 ] <<= aValue;
     374             : 
     375             :         // create the EntrySource instance and set at the control model
     376           4 :         Reference< XMultiServiceFactory > xModelFactory( mxDocModel, UNO_QUERY_THROW );
     377           4 :         Reference< XListEntrySource > xEntrySource( xModelFactory->createInstanceWithArguments("com.sun.star.table.CellRangeListSource", aArgs ), UNO_QUERY_THROW );
     378           4 :         xEntrySink->setListEntrySource( xEntrySource );
     379             :     }
     380           0 :     catch (const Exception& e)
     381             :     {
     382             :         SAL_WARN("oox", "exception: " << e.Message);
     383             :     }
     384          16 : }
     385             : 
     386             : // ActiveX (Forms 2.0) specific conversion ------------------------------------
     387             : 
     388          82 : void ControlConverter::convertAxBackground( PropertyMap& rPropMap,
     389             :         sal_uInt32 nBackColor, sal_uInt32 nFlags, ApiTransparencyMode eTranspMode ) const
     390             : {
     391          82 :     bool bOpaque = getFlag( nFlags, AX_FLAGS_OPAQUE );
     392          82 :     switch( eTranspMode )
     393             :     {
     394             :         case API_TRANSPARENCY_NOTSUPPORTED:
     395             :             // fake transparency by using system window background if needed
     396          46 :             convertColor( rPropMap, PROP_BackgroundColor, bOpaque ? nBackColor : AX_SYSCOLOR_WINDOWBACK );
     397          46 :         break;
     398             :         case API_TRANSPARENCY_PAINTTRANSPARENT:
     399           0 :             rPropMap.setProperty( PROP_PaintTransparent, !bOpaque );
     400             :             // run-through intended!
     401             :         case API_TRANSPARENCY_VOID:
     402             :             // keep transparency by leaving the (void) default property value
     403          36 :             if( bOpaque )
     404          34 :                 convertColor( rPropMap, PROP_BackgroundColor, nBackColor );
     405          36 :         break;
     406             :     }
     407          82 : }
     408             : 
     409          18 : void ControlConverter::convertAxBorder( PropertyMap& rPropMap,
     410             :         sal_uInt32 nBorderColor, sal_Int32 nBorderStyle, sal_Int32 nSpecialEffect ) const
     411             : {
     412             :     sal_Int16 nBorder = (nBorderStyle == AX_BORDERSTYLE_SINGLE) ? API_BORDER_FLAT :
     413          18 :         ((nSpecialEffect == AX_SPECIALEFFECT_FLAT) ? API_BORDER_NONE : API_BORDER_SUNKEN);
     414          18 :     rPropMap.setProperty( PROP_Border, nBorder );
     415          18 :     convertColor( rPropMap, PROP_BorderColor, nBorderColor );
     416          18 : }
     417             : 
     418           2 : void ControlConverter::convertToAxBorder( PropertySet& rPropSet,
     419             :         sal_uInt32& nBorderColor, sal_Int32& nBorderStyle, sal_Int32& nSpecialEffect ) const
     420             : {
     421           2 :     sal_Int16 nBorder = API_BORDER_NONE;
     422           2 :     rPropSet.getProperty( nBorder, PROP_Border );
     423           2 :     nBorderStyle = AX_BORDERSTYLE_NONE;
     424           2 :     nSpecialEffect =  AX_SPECIALEFFECT_FLAT;
     425           2 :     switch ( nBorder )
     426             :     {
     427             :         case API_BORDER_FLAT:
     428           0 :             nBorderStyle = AX_BORDERSTYLE_SINGLE;
     429           0 :             break;
     430             :         case API_BORDER_SUNKEN:
     431           2 :             nSpecialEffect =  AX_SPECIALEFFECT_SUNKEN;
     432             :         case API_BORDER_NONE:
     433             :         default:
     434           2 :             break;
     435             :     }
     436           2 :     convertToMSColor( rPropSet, PROP_BorderColor, nBorderColor );
     437           2 : }
     438             : 
     439          18 : void ControlConverter::convertAxVisualEffect( PropertyMap& rPropMap, sal_Int32 nSpecialEffect ) const
     440             : {
     441          18 :     sal_Int16 nVisualEffect = (nSpecialEffect == AX_SPECIALEFFECT_FLAT) ? VisualEffect::FLAT : VisualEffect::LOOK3D;
     442          18 :     rPropMap.setProperty( PROP_VisualEffect, nVisualEffect );
     443          18 : }
     444             : 
     445           0 : void ControlConverter::convertToAxVisualEffect( PropertySet& rPropSet, sal_Int32& nSpecialEffect ) const
     446             : {
     447           0 :     sal_Int16 nVisualEffect = AX_SPECIALEFFECT_FLAT;
     448           0 :     rPropSet.getProperty( nVisualEffect, PROP_VisualEffect );
     449             :     // is this appropriate AX_SPECIALEFFECT_XXXX value ?
     450           0 :     if (nVisualEffect == VisualEffect::LOOK3D )
     451           0 :         nSpecialEffect = AX_SPECIALEFFECT_RAISED;
     452           0 : }
     453             : 
     454          68 : void ControlConverter::convertAxPicture( PropertyMap& rPropMap, const StreamDataSequence& rPicData, sal_uInt32 nPicPos ) const
     455             : {
     456             :     // the picture
     457          68 :     convertPicture( rPropMap, rPicData );
     458             : 
     459             :     // picture position
     460          68 :     sal_Int16 nImagePos = ImagePosition::LeftCenter;
     461          68 :     switch( nPicPos )
     462             :     {
     463           0 :         case AX_PICPOS_LEFTTOP:     nImagePos = ImagePosition::LeftTop;     break;
     464           0 :         case AX_PICPOS_LEFTCENTER:  nImagePos = ImagePosition::LeftCenter;  break;
     465           0 :         case AX_PICPOS_LEFTBOTTOM:  nImagePos = ImagePosition::LeftBottom;  break;
     466           0 :         case AX_PICPOS_RIGHTTOP:    nImagePos = ImagePosition::RightTop;    break;
     467           0 :         case AX_PICPOS_RIGHTCENTER: nImagePos = ImagePosition::RightCenter; break;
     468           0 :         case AX_PICPOS_RIGHTBOTTOM: nImagePos = ImagePosition::RightBottom; break;
     469           0 :         case AX_PICPOS_ABOVELEFT:   nImagePos = ImagePosition::AboveLeft;   break;
     470          64 :         case AX_PICPOS_ABOVECENTER: nImagePos = ImagePosition::AboveCenter; break;
     471           0 :         case AX_PICPOS_ABOVERIGHT:  nImagePos = ImagePosition::AboveRight;  break;
     472           0 :         case AX_PICPOS_BELOWLEFT:   nImagePos = ImagePosition::BelowLeft;   break;
     473           0 :         case AX_PICPOS_BELOWCENTER: nImagePos = ImagePosition::BelowCenter; break;
     474           0 :         case AX_PICPOS_BELOWRIGHT:  nImagePos = ImagePosition::BelowRight;  break;
     475           4 :         case AX_PICPOS_CENTER:      nImagePos = ImagePosition::Centered;    break;
     476             :         default:    OSL_FAIL( "ControlConverter::convertAxPicture - unknown picture position" );
     477             :     }
     478          68 :     rPropMap.setProperty( PROP_ImagePosition, nImagePos );
     479          68 : }
     480             : 
     481           0 : void ControlConverter::convertAxPicture( PropertyMap& rPropMap, const StreamDataSequence& rPicData,
     482             :         sal_Int32 nPicSizeMode, sal_Int32 /*nPicAlign*/, bool /*bPicTiling*/ ) const
     483             : {
     484             :     // the picture
     485           0 :     convertPicture( rPropMap, rPicData );
     486             : 
     487             :     // picture scale mode
     488           0 :     sal_Int16 nScaleMode = ImageScaleMode::NONE;
     489           0 :     switch( nPicSizeMode )
     490             :     {
     491           0 :         case AX_PICSIZE_CLIP:       nScaleMode = ImageScaleMode::NONE;          break;
     492           0 :         case AX_PICSIZE_STRETCH:    nScaleMode = ImageScaleMode::ANISOTROPIC;   break;
     493           0 :         case AX_PICSIZE_ZOOM:       nScaleMode = ImageScaleMode::ISOTROPIC;     break;
     494             :         default:    OSL_FAIL( "ControlConverter::convertAxPicture - unknown picture size mode" );
     495             :     }
     496           0 :     rPropMap.setProperty( PROP_ScaleMode, nScaleMode );
     497           0 : }
     498             : 
     499          22 : void ControlConverter::convertAxState( PropertyMap& rPropMap,
     500             :         const OUString& rValue, sal_Int32 nMultiSelect, ApiDefaultStateMode eDefStateMode, bool bAwtModel ) const
     501             : {
     502          22 :     bool bBooleanState = eDefStateMode == API_DEFAULTSTATE_BOOLEAN;
     503          22 :     bool bSupportsTriState = eDefStateMode == API_DEFAULTSTATE_TRISTATE;
     504             : 
     505             :     // state
     506          22 :     sal_Int16 nState = bSupportsTriState ? API_STATE_DONTKNOW : API_STATE_UNCHECKED;
     507          22 :     if( rValue.getLength() == 1 ) switch( rValue[ 0 ] )
     508             :     {
     509          16 :         case '0':   nState = API_STATE_UNCHECKED;   break;
     510           6 :         case '1':   nState = API_STATE_CHECKED;     break;
     511             :         // any other string (also empty) means 'dontknow'
     512             :     }
     513          22 :     sal_Int32 nPropId = bAwtModel ? PROP_State : PROP_DefaultState;
     514          22 :     if( bBooleanState )
     515           4 :         rPropMap.setProperty( nPropId, nState != API_STATE_UNCHECKED );
     516             :     else
     517          18 :         rPropMap.setProperty( nPropId, nState );
     518             : 
     519             :     // tristate
     520          22 :     if( bSupportsTriState )
     521          10 :         rPropMap.setProperty( PROP_TriState, nMultiSelect == AX_SELECTION_MULTI );
     522          22 : }
     523             : 
     524           0 : void ControlConverter::convertToAxState( PropertySet& rPropSet,
     525             :         OUString& rValue, sal_Int32& nMultiSelect, ApiDefaultStateMode eDefStateMode, bool /*bAwtModel*/ ) const
     526             : {
     527           0 :     bool bSupportsTriState = eDefStateMode == API_DEFAULTSTATE_TRISTATE;
     528             : 
     529           0 :     sal_Int16 nState = API_STATE_DONTKNOW;
     530             : 
     531           0 :     bool bTmp = false;
     532             :     // need to use State for current state ( I think this is regardless of whether
     533             :     // control is awt or not )
     534           0 :     rPropSet.getProperty( nState, PROP_State );
     535             : 
     536           0 :     rValue = OUString(); // empty e.g. 'don't know'
     537           0 :     if ( nState == API_STATE_UNCHECKED )
     538           0 :         rValue = OUString('0');
     539           0 :     else if ( nState == API_STATE_CHECKED )
     540           0 :         rValue = OUString('1');
     541             : 
     542             :     // tristate
     543           0 :     if( bSupportsTriState && rPropSet.getProperty( bTmp, PROP_TriState ) )
     544           0 :         nMultiSelect = AX_SELECTION_MULTI;
     545           0 : }
     546             : 
     547           0 : void ControlConverter::convertAxOrientation( PropertyMap& rPropMap,
     548             :         const AxPairData& rSize, sal_Int32 nOrientation ) const
     549             : {
     550           0 :     bool bHorizontal = true;
     551           0 :     switch( nOrientation )
     552             :     {
     553           0 :         case AX_ORIENTATION_AUTO:       bHorizontal = rSize.first > rSize.second;   break;
     554           0 :         case AX_ORIENTATION_VERTICAL:   bHorizontal = false;                        break;
     555           0 :         case AX_ORIENTATION_HORIZONTAL: bHorizontal = true;                         break;
     556             :         default:    OSL_FAIL( "ControlConverter::convertAxOrientation - unknown orientation" );
     557             :     }
     558           0 :     convertOrientation( rPropMap, bHorizontal );
     559           0 : }
     560             : 
     561           0 : void ControlConverter::convertToAxOrientation( PropertySet& rPropSet,
     562             :         const AxPairData& /*rSize*/, sal_Int32& nOrientation ) const
     563             : {
     564           0 :     bool bHorizontal = true;
     565           0 :     convertToMSOrientation( rPropSet, bHorizontal );
     566             : 
     567           0 :     if ( bHorizontal )
     568           0 :         nOrientation = AX_ORIENTATION_HORIZONTAL;
     569             :     else
     570           0 :         nOrientation = AX_ORIENTATION_VERTICAL;
     571           0 : }
     572             : 
     573          88 : ControlModelBase::ControlModelBase() :
     574             :     maSize( 0, 0 ),
     575          88 :     mbAwtModel( false )
     576             : {
     577          88 : }
     578             : 
     579          88 : ControlModelBase::~ControlModelBase()
     580             : {
     581          88 : }
     582             : 
     583          86 : OUString ControlModelBase::getServiceName() const
     584             : {
     585          86 :     ApiControlType eCtrlType = getControlType();
     586          86 :     if( mbAwtModel ) switch( eCtrlType )
     587             :     {
     588           2 :         case API_CONTROL_BUTTON:        return OUString( "com.sun.star.awt.UnoControlButtonModel" );
     589           0 :         case API_CONTROL_FIXEDTEXT:     return OUString( "com.sun.star.awt.UnoControlFixedTextModel" );
     590           0 :         case API_CONTROL_IMAGE:         return OUString( "com.sun.star.awt.UnoControlImageControlModel" );
     591           2 :         case API_CONTROL_CHECKBOX:      return OUString( "com.sun.star.awt.UnoControlCheckBoxModel" );
     592           2 :         case API_CONTROL_RADIOBUTTON:   return OUString( "com.sun.star.form.component.RadioButton" );
     593           2 :         case API_CONTROL_EDIT:          return OUString( "com.sun.star.awt.UnoControlEditModel" );
     594           0 :         case API_CONTROL_NUMERIC:       return OUString( "com.sun.star.awt.UnoControlNumericFieldModel" );
     595           2 :         case API_CONTROL_LISTBOX:       return OUString( "com.sun.star.form.component.ListBox" );
     596           2 :         case API_CONTROL_COMBOBOX:      return OUString( "com.sun.star.form.component.ComboBox" );
     597           0 :         case API_CONTROL_SPINBUTTON:    return OUString( "com.sun.star.form.component.SpinButton" );
     598           0 :         case API_CONTROL_SCROLLBAR:     return OUString( "com.sun.star.form.component.ScrollBar" );
     599           0 :         case API_CONTROL_PROGRESSBAR:   return OUString( "com.sun.star.awt.UnoControlProgressBarModel" );
     600           0 :         case API_CONTROL_GROUPBOX:      return OUString( "com.sun.star.form.component.GroupBox" );
     601           0 :         case API_CONTROL_FRAME:         return OUString( "com.sun.star.awt.UnoFrameModel" );
     602           0 :         case API_CONTROL_PAGE:          return OUString( "com.sun.star.awt.UnoPageModel" );
     603           0 :         case API_CONTROL_MULTIPAGE:     return OUString( "com.sun.star.awt.UnoMultiPageModel" );
     604           4 :         case API_CONTROL_DIALOG:        return OUString( "com.sun.star.awt.UnoControlDialogModel" );
     605             :         default:    OSL_FAIL( "ControlModelBase::getServiceName - no AWT model service supported" );
     606             :     }
     607          70 :     else switch( eCtrlType )
     608             :     {
     609          44 :         case API_CONTROL_BUTTON:        return OUString( "com.sun.star.form.component.CommandButton" );
     610           2 :         case API_CONTROL_FIXEDTEXT:     return OUString( "com.sun.star.form.component.FixedText" );
     611           0 :         case API_CONTROL_IMAGE:         return OUString( "com.sun.star.form.component.DatabaseImageControl" );
     612           8 :         case API_CONTROL_CHECKBOX:      return OUString( "com.sun.star.form.component.CheckBox" );
     613           6 :         case API_CONTROL_RADIOBUTTON:   return OUString( "com.sun.star.form.component.RadioButton" );
     614           6 :         case API_CONTROL_EDIT:          return OUString( "com.sun.star.form.component.TextField" );
     615           0 :         case API_CONTROL_NUMERIC:       return OUString( "com.sun.star.form.component.NumericField" );
     616           2 :         case API_CONTROL_LISTBOX:       return OUString( "com.sun.star.form.component.ListBox" );
     617           2 :         case API_CONTROL_COMBOBOX:      return OUString( "com.sun.star.form.component.ComboBox" );
     618           0 :         case API_CONTROL_SPINBUTTON:    return OUString( "com.sun.star.form.component.SpinButton" );
     619           0 :         case API_CONTROL_SCROLLBAR:     return OUString( "com.sun.star.form.component.ScrollBar" );
     620           0 :         case API_CONTROL_GROUPBOX:      return OUString( "com.sun.star.form.component.GroupBox" );
     621             :         default:    OSL_FAIL( "ControlModelBase::getServiceName - no form component service supported" );
     622             :     }
     623           0 :     return OUString();
     624             : }
     625             : 
     626           0 : void ControlModelBase::importProperty( sal_Int32 /*nPropId*/, const OUString& /*rValue*/ )
     627             : {
     628           0 : }
     629             : 
     630           0 : void ControlModelBase::importPictureData( sal_Int32 /*nPropId*/, BinaryInputStream& /*rInStrm*/ )
     631             : {
     632           0 : }
     633             : 
     634          82 : void ControlModelBase::convertProperties( PropertyMap& /*rPropMap*/, const ControlConverter& /*rConv*/ ) const
     635             : {
     636          82 : }
     637             : 
     638           0 : void ControlModelBase::convertFromProperties( PropertySet& /*rPropMap*/, const ControlConverter& /*rConv*/ )
     639             : {
     640           0 : }
     641             : 
     642          16 : void ControlModelBase::convertSize( PropertyMap& rPropMap, const ControlConverter& rConv ) const
     643             : {
     644          16 :     rConv.convertSize( rPropMap, maSize );
     645          16 : }
     646             : 
     647           0 : ComCtlModelBase::ComCtlModelBase( sal_uInt32 nDataPartId5, sal_uInt32 nDataPartId6,
     648             :         sal_uInt16 nVersion, bool bCommonPart, bool bComplexPart ) :
     649             :     maFontData( "Tahoma", 82500 ),
     650             :     mnFlags( 0 ),
     651             :     mnVersion( nVersion ),
     652             :     mnDataPartId5( nDataPartId5 ),
     653             :     mnDataPartId6( nDataPartId6 ),
     654             :     mbCommonPart( bCommonPart ),
     655           0 :     mbComplexPart( bComplexPart )
     656             : {
     657           0 : }
     658             : 
     659           0 : bool ComCtlModelBase::importBinaryModel( BinaryInputStream& rInStrm )
     660             : {
     661             :     // read initial size part and header of the control data part
     662           0 :     if( importSizePart( rInStrm ) && readPartHeader( rInStrm, getDataPartId(), mnVersion ) )
     663             :     {
     664             :         // if flags part exists, the first int32 of the data part contains its size
     665           0 :         sal_uInt32 nCommonPartSize = mbCommonPart ? rInStrm.readuInt32() : 0;
     666             :         // implementations must read the exact amount of data, stream must point to its end afterwards
     667           0 :         importControlData( rInStrm );
     668             :         // read following parts
     669           0 :         if( !rInStrm.isEof() &&
     670           0 :             (!mbCommonPart || importCommonPart( rInStrm, nCommonPartSize )) &&
     671           0 :             (!mbComplexPart || importComplexPart( rInStrm )) )
     672             :         {
     673           0 :             return !rInStrm.isEof();
     674             :         }
     675             :     }
     676           0 :     return false;
     677             : }
     678             : 
     679           0 : void ComCtlModelBase::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
     680             : {
     681           0 :     if( mbCommonPart )
     682           0 :         rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, COMCTL_COMMON_ENABLED ) );
     683           0 :     ControlModelBase::convertProperties( rPropMap, rConv );
     684           0 : }
     685             : 
     686           0 : void ComCtlModelBase::importCommonExtraData( BinaryInputStream& /*rInStrm*/ )
     687             : {
     688           0 : }
     689             : 
     690           0 : void ComCtlModelBase::importCommonTrailingData( BinaryInputStream& /*rInStrm*/ )
     691             : {
     692           0 : }
     693             : 
     694           0 : sal_uInt32 ComCtlModelBase::getDataPartId() const
     695             : {
     696           0 :     switch( mnVersion )
     697             :     {
     698           0 :         case COMCTL_VERSION_50: return mnDataPartId5;
     699           0 :         case COMCTL_VERSION_60: return mnDataPartId6;
     700             :     }
     701             :     OSL_FAIL( "ComCtlObjectBase::getDataPartId - unxpected version" );
     702           0 :     return SAL_MAX_UINT32;
     703             : }
     704             : 
     705           0 : bool ComCtlModelBase::readPartHeader( BinaryInputStream& rInStrm, sal_uInt32 nExpPartId, sal_uInt16 nExpMajor, sal_uInt16 nExpMinor )
     706             : {
     707             :     // no idea if all this is correct...
     708             :     sal_uInt32 nPartId;
     709             :     sal_uInt16 nMajor, nMinor;
     710           0 :     rInStrm >> nPartId >> nMinor >> nMajor;
     711           0 :     bool bPartId = nPartId == nExpPartId;
     712             :     OSL_ENSURE( bPartId, "ComCtlObjectBase::readPartHeader - unexpected part identifier" );
     713           0 :     bool bVersion = ((nExpMajor == SAL_MAX_UINT16) || (nExpMajor == nMajor)) && ((nExpMinor == SAL_MAX_UINT16) || (nExpMinor == nMinor));
     714             :     OSL_ENSURE( bVersion, "ComCtlObjectBase::readPartHeader - unexpected part version" );
     715           0 :     return !rInStrm.isEof() && bPartId && bVersion;
     716             : }
     717             : 
     718           0 : bool ComCtlModelBase::importSizePart( BinaryInputStream& rInStrm )
     719             : {
     720           0 :     if( readPartHeader( rInStrm, COMCTL_ID_SIZE, 0, 8 ) )
     721             :     {
     722           0 :         rInStrm >> maSize.first >> maSize.second;
     723           0 :         return !rInStrm.isEof();
     724             :     }
     725           0 :     return false;
     726             : }
     727             : 
     728           0 : bool ComCtlModelBase::importCommonPart( BinaryInputStream& rInStrm, sal_uInt32 nPartSize )
     729             : {
     730           0 :     sal_Int64 nEndPos = rInStrm.tell() + nPartSize;
     731           0 :     if( (nPartSize >= 16) && readPartHeader( rInStrm, COMCTL_ID_COMMONDATA, 5, 0 ) )
     732             :     {
     733           0 :         rInStrm.skip( 4 );
     734           0 :         rInStrm >> mnFlags;
     735             :         // implementations may read less than the exact amount of data
     736           0 :         importCommonExtraData( rInStrm );
     737           0 :         rInStrm.seek( nEndPos );
     738             :         // implementations must read the exact amount of data, stream must point to its end afterwards
     739           0 :         importCommonTrailingData( rInStrm );
     740           0 :         return !rInStrm.isEof();
     741             :     }
     742           0 :     return false;
     743             : }
     744             : 
     745           0 : bool ComCtlModelBase::importComplexPart( BinaryInputStream& rInStrm )
     746             : {
     747           0 :     if( readPartHeader( rInStrm, COMCTL_ID_COMPLEXDATA, 5, 1 ) )
     748             :     {
     749             :         sal_uInt32 nContFlags;
     750           0 :         rInStrm >> nContFlags;
     751             :         bool bReadOk =
     752           0 :             (!getFlag( nContFlags, COMCTL_COMPLEX_FONT ) || OleHelper::importStdFont( maFontData, rInStrm, true )) &&
     753           0 :             (!getFlag( nContFlags, COMCTL_COMPLEX_MOUSEICON ) || OleHelper::importStdPic( maMouseIcon, rInStrm, true ));
     754           0 :         return bReadOk && !rInStrm.isEof();
     755             :     }
     756           0 :     return false;
     757             : }
     758             : 
     759           0 : ComCtlScrollBarModel::ComCtlScrollBarModel( sal_uInt16 nVersion ) :
     760             :     ComCtlModelBase( SAL_MAX_UINT32, COMCTL_ID_SCROLLBAR_60, nVersion, true, true ),
     761             :     mnScrollBarFlags( 0x00000011 ),
     762             :     mnLargeChange( 1 ),
     763             :     mnSmallChange( 1 ),
     764             :     mnMin( 0 ),
     765             :     mnMax( 32767 ),
     766           0 :     mnPosition( 0 )
     767             : {
     768           0 : }
     769             : 
     770           0 : ApiControlType ComCtlScrollBarModel::getControlType() const
     771             : {
     772           0 :     return API_CONTROL_SCROLLBAR;
     773             : }
     774             : 
     775           0 : void ComCtlScrollBarModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
     776             : {
     777           0 :     rPropMap.setProperty( PROP_Border, API_BORDER_NONE );
     778           0 :     rConv.convertOrientation( rPropMap, getFlag( mnScrollBarFlags, COMCTL_SCROLLBAR_HOR ) );
     779           0 :     rConv.convertScrollBar( rPropMap, mnMin, mnMax, mnPosition, mnSmallChange, mnLargeChange, mbAwtModel );
     780           0 :     ComCtlModelBase::convertProperties( rPropMap, rConv );
     781           0 : }
     782             : 
     783           0 : void ComCtlScrollBarModel::importControlData( BinaryInputStream& rInStrm )
     784             : {
     785           0 :     rInStrm >> mnScrollBarFlags >> mnLargeChange >> mnSmallChange >> mnMin >> mnMax >> mnPosition;
     786           0 : }
     787             : 
     788           0 : ComCtlProgressBarModel::ComCtlProgressBarModel( sal_uInt16 nVersion ) :
     789             :     ComCtlModelBase( COMCTL_ID_PROGRESSBAR_50, COMCTL_ID_PROGRESSBAR_60, nVersion, true, true ),
     790             :     mfMin( 0.0 ),
     791             :     mfMax( 100.0 ),
     792             :     mnVertical( 0 ),
     793           0 :     mnSmooth( 0 )
     794             : {
     795           0 : }
     796             : 
     797           0 : ApiControlType ComCtlProgressBarModel::getControlType() const
     798             : {
     799           0 :     return API_CONTROL_PROGRESSBAR;
     800             : }
     801             : 
     802           0 : void ComCtlProgressBarModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
     803             : {
     804           0 :     sal_uInt16 nBorder = getFlag( mnFlags, COMCTL_COMMON_3DBORDER ) ? API_BORDER_SUNKEN :
     805           0 :         (getFlag( mnFlags, COMCTL_COMMON_FLATBORDER ) ? API_BORDER_FLAT : API_BORDER_NONE);
     806           0 :     rPropMap.setProperty( PROP_Border, nBorder );
     807           0 :     rPropMap.setProperty( PROP_ProgressValueMin, getLimitedValue< sal_Int32, double >( ::std::min( mfMin, mfMax ), 0.0, SAL_MAX_INT32 ) );
     808           0 :     rPropMap.setProperty( PROP_ProgressValueMax, getLimitedValue< sal_Int32, double >( ::std::max( mfMin, mfMax ), 0.0, SAL_MAX_INT32 ) );
     809             :     // ComCtl model does not provide current value?
     810           0 :     ComCtlModelBase::convertProperties( rPropMap, rConv );
     811           0 : }
     812             : 
     813           0 : void ComCtlProgressBarModel::importControlData( BinaryInputStream& rInStrm )
     814             : {
     815           0 :     rInStrm >> mfMin >> mfMax;
     816           0 :     if( mnVersion == COMCTL_VERSION_60 )
     817           0 :         rInStrm >> mnVertical >> mnSmooth;
     818           0 : }
     819             : 
     820          88 : AxControlModelBase::AxControlModelBase()
     821             : {
     822          88 : }
     823             : 
     824           0 : void AxControlModelBase::importProperty( sal_Int32 nPropId, const OUString& rValue )
     825             : {
     826           0 :     switch( nPropId )
     827             :     {
     828             :         // size of the control shape: format is "width;height"
     829             :         case XML_Size:
     830             :         {
     831           0 :             sal_Int32 nSepPos = rValue.indexOf( ';' );
     832             :             OSL_ENSURE( nSepPos >= 0, "AxControlModelBase::importProperty - missing separator in 'Size' property" );
     833           0 :             if( nSepPos >= 0 )
     834             :             {
     835           0 :                 maSize.first = rValue.copy( 0, nSepPos ).toInt32();
     836           0 :                 maSize.second = rValue.copy( nSepPos + 1 ).toInt32();
     837             :             }
     838             :         }
     839           0 :         break;
     840             :     }
     841           0 : }
     842             : 
     843          88 : AxFontDataModel::AxFontDataModel( bool bSupportsAlign ) :
     844          88 :     mbSupportsAlign( bSupportsAlign )
     845             : {
     846          88 : }
     847             : 
     848           0 : void AxFontDataModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
     849             : {
     850           0 :     switch( nPropId )
     851             :     {
     852           0 :         case XML_FontName:          maFontData.maFontName = rValue;                                             break;
     853           0 :         case XML_FontEffects:       maFontData.mnFontEffects = AttributeConversion::decodeUnsigned( rValue );   break;
     854           0 :         case XML_FontHeight:        maFontData.mnFontHeight = AttributeConversion::decodeInteger( rValue );     break;
     855           0 :         case XML_FontCharSet:       maFontData.mnFontCharSet = AttributeConversion::decodeInteger( rValue );    break;
     856           0 :         case XML_ParagraphAlign:    maFontData.mnHorAlign = AttributeConversion::decodeInteger( rValue );       break;
     857           0 :         default:                    AxControlModelBase::importProperty( nPropId, rValue );
     858             :     }
     859           0 : }
     860             : 
     861          80 : bool AxFontDataModel::importBinaryModel( BinaryInputStream& rInStrm )
     862             : {
     863          80 :     return maFontData.importBinaryModel( rInStrm );
     864             : }
     865             : 
     866           2 : void AxFontDataModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
     867             : {
     868           2 :     maFontData.exportBinaryModel( rOutStrm );
     869           2 : }
     870          82 : void AxFontDataModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
     871             : {
     872             :     // font name
     873          82 :     if( !maFontData.maFontName.isEmpty() )
     874          76 :         rPropMap.setProperty( PROP_FontName, maFontData.maFontName );
     875             : 
     876             :     // font effects
     877          82 :     rPropMap.setProperty( PROP_FontWeight, getFlagValue( maFontData.mnFontEffects, AX_FONTDATA_BOLD, awt::FontWeight::BOLD, awt::FontWeight::NORMAL ) );
     878          82 :     rPropMap.setProperty( PROP_FontSlant, getFlagValue< sal_Int16 >( maFontData.mnFontEffects, AX_FONTDATA_ITALIC, FontSlant_ITALIC, FontSlant_NONE ) );
     879          82 :     rPropMap.setProperty( PROP_FontUnderline, getFlagValue( maFontData.mnFontEffects, AX_FONTDATA_UNDERLINE, maFontData.mbDblUnderline ? awt::FontUnderline::DOUBLE : awt::FontUnderline::SINGLE, awt::FontUnderline::NONE ) );
     880          82 :     rPropMap.setProperty( PROP_FontStrikeout, getFlagValue( maFontData.mnFontEffects, AX_FONTDATA_STRIKEOUT, awt::FontStrikeout::SINGLE, awt::FontStrikeout::NONE ) );
     881          82 :     rPropMap.setProperty( PROP_FontHeight, maFontData.getHeightPoints() );
     882             : 
     883             :     // font character set
     884          82 :     rtl_TextEncoding eFontEnc = RTL_TEXTENCODING_DONTKNOW;
     885          82 :     if( (0 <= maFontData.mnFontCharSet) && (maFontData.mnFontCharSet <= SAL_MAX_UINT8) )
     886          82 :         eFontEnc = rtl_getTextEncodingFromWindowsCharset( static_cast< sal_uInt8 >( maFontData.mnFontCharSet ) );
     887          82 :     if( eFontEnc != RTL_TEXTENCODING_DONTKNOW )
     888          78 :         rPropMap.setProperty( PROP_FontCharset, static_cast< sal_Int16 >( eFontEnc ) );
     889             : 
     890             :     // text alignment
     891          82 :     if( mbSupportsAlign )
     892             :     {
     893          82 :         sal_Int32 nAlign = awt::TextAlign::LEFT;
     894          82 :         switch( maFontData.mnHorAlign )
     895             :         {
     896          36 :             case AX_FONTDATA_LEFT:      nAlign = awt::TextAlign::LEFT;   break;
     897           0 :             case AX_FONTDATA_RIGHT:     nAlign = awt::TextAlign::RIGHT;  break;
     898          46 :             case AX_FONTDATA_CENTER:    nAlign = awt::TextAlign::CENTER; break;
     899             :             default:    OSL_FAIL( "AxFontDataModel::convertProperties - unknown text alignment" );
     900             :         }
     901             :         // form controls expect short value
     902          82 :         rPropMap.setProperty( PROP_Align, static_cast< sal_Int16 >( nAlign ) );
     903             :     }
     904             : 
     905             :     // process base class properties
     906          82 :     AxControlModelBase::convertProperties( rPropMap, rConv );
     907          82 : }
     908             : 
     909           2 : void AxFontDataModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& /*rConv */)
     910             : {
     911           2 :     rPropSet.getProperty( maFontData.maFontName, PROP_FontName );
     912           2 :     float fontWeight = (float)0;
     913           2 :     if ( rPropSet.getProperty(fontWeight, PROP_FontWeight ) )
     914           2 :         setFlag( maFontData.mnFontEffects, AX_FONTDATA_BOLD, ( fontWeight == awt::FontWeight::BOLD ) );
     915           2 :     sal_Int16 nSlant = FontSlant_NONE;
     916           2 :     if ( rPropSet.getProperty( nSlant, PROP_FontSlant ) )
     917           0 :         setFlag( maFontData.mnFontEffects, AX_FONTDATA_ITALIC, ( nSlant == FontSlant_ITALIC ) );
     918             : 
     919           2 :     sal_Int16 nUnderLine = awt::FontUnderline::NONE;
     920           2 :     if ( rPropSet.getProperty( nUnderLine, PROP_FontUnderline ) )
     921           2 :         setFlag( maFontData.mnFontEffects, AX_FONTDATA_UNDERLINE, nUnderLine != awt::FontUnderline::NONE );
     922           2 :     sal_Int16 nStrikeout = awt::FontStrikeout::NONE ;
     923           2 :     if ( rPropSet.getProperty( nStrikeout, PROP_FontStrikeout ) )
     924           2 :         setFlag( maFontData.mnFontEffects, AX_FONTDATA_STRIKEOUT, nStrikeout != awt::FontStrikeout::NONE );
     925             : 
     926           2 :     float fontHeight = 0.0;
     927           2 :     if ( rPropSet.getProperty( fontHeight, PROP_FontHeight ) )
     928           2 :         maFontData.setHeightPoints( static_cast< sal_Int16 >( fontHeight ) );
     929             : 
     930             :     // TODO - handle textencoding
     931           2 :     sal_Int16 nAlign = 0;
     932           2 :     if ( rPropSet.getProperty( nAlign, PROP_Align ) )
     933             :     {
     934           2 :         switch ( nAlign )
     935             :         {
     936           2 :             case awt::TextAlign::LEFT: maFontData.mnHorAlign = AX_FONTDATA_LEFT;   break;
     937           0 :             case awt::TextAlign::RIGHT: maFontData.mnHorAlign = AX_FONTDATA_RIGHT;  break;
     938           0 :             case awt::TextAlign::CENTER: maFontData.mnHorAlign = AX_FONTDATA_CENTER; break;
     939             :             default:    OSL_FAIL( "AxFontDataModel::convertFromProperties - unknown text alignment" );
     940             :         }
     941             :     }
     942           2 : }
     943             : 
     944          42 : AxCommandButtonModel::AxCommandButtonModel() :
     945             :     mnTextColor( AX_SYSCOLOR_BUTTONTEXT ),
     946             :     mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
     947             :     mnFlags( AX_CMDBUTTON_DEFFLAGS ),
     948             :     mnPicturePos( AX_PICPOS_ABOVECENTER ),
     949             :     mnVerticalAlign( XML_Center ),
     950          42 :     mbFocusOnClick( true )
     951             : {
     952          42 : }
     953             : 
     954           0 : void AxCommandButtonModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
     955             : {
     956           0 :     switch( nPropId )
     957             :     {
     958           0 :         case XML_Caption:               maCaption = rValue;                                                 break;
     959           0 :         case XML_ForeColor:             mnTextColor = AttributeConversion::decodeUnsigned( rValue );        break;
     960           0 :         case XML_BackColor:             mnBackColor = AttributeConversion::decodeUnsigned( rValue );        break;
     961           0 :         case XML_VariousPropertyBits:   mnFlags = AttributeConversion::decodeUnsigned( rValue );            break;
     962           0 :         case XML_PicturePosition:       mnPicturePos = AttributeConversion::decodeUnsigned( rValue );       break;
     963           0 :         case XML_TakeFocusOnClick:      mbFocusOnClick = AttributeConversion::decodeInteger( rValue ) != 0; break;
     964           0 :         default:                        AxFontDataModel::importProperty( nPropId, rValue );
     965             :     }
     966           0 : }
     967             : 
     968           0 : void AxCommandButtonModel::importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm )
     969             : {
     970           0 :     switch( nPropId )
     971             :     {
     972           0 :         case XML_Picture:   OleHelper::importStdPic( maPictureData, rInStrm, true );    break;
     973           0 :         default:            AxFontDataModel::importPictureData( nPropId, rInStrm );
     974             :     }
     975           0 : }
     976             : 
     977          42 : bool AxCommandButtonModel::importBinaryModel( BinaryInputStream& rInStrm )
     978             : {
     979          42 :     AxBinaryPropertyReader aReader( rInStrm );
     980          42 :     aReader.readIntProperty< sal_uInt32 >( mnTextColor );
     981          42 :     aReader.readIntProperty< sal_uInt32 >( mnBackColor );
     982          42 :     aReader.readIntProperty< sal_uInt32 >( mnFlags );
     983          42 :     aReader.readStringProperty( maCaption );
     984          42 :     aReader.readIntProperty< sal_uInt32 >( mnPicturePos );
     985          42 :     aReader.readPairProperty( maSize );
     986          42 :     aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
     987          42 :     aReader.readPictureProperty( maPictureData );
     988          42 :     aReader.skipIntProperty< sal_uInt16 >(); // accelerator
     989          42 :     aReader.readBoolProperty( mbFocusOnClick, true ); // binary flag means "do not take focus"
     990          42 :     aReader.skipPictureProperty(); // mouse icon
     991          42 :     return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm );
     992             : }
     993             : 
     994           0 : void AxCommandButtonModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
     995             : {
     996           0 :     AxBinaryPropertyWriter aWriter( rOutStrm );
     997           0 :     aWriter.writeIntProperty< sal_uInt32 >( mnTextColor );
     998           0 :     if ( mnBackColor )
     999           0 :         aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
    1000             :     else
    1001           0 :         aWriter.skipProperty(); // default backcolour
    1002           0 :     aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
    1003           0 :     aWriter.writeStringProperty( maCaption );
    1004           0 :     aWriter.skipProperty(); // pict pos
    1005           0 :     aWriter.writePairProperty( maSize );
    1006           0 :     aWriter.skipProperty(); // mouse pointer
    1007           0 :     aWriter.skipProperty(); // picture data
    1008           0 :     aWriter.skipProperty(); // accelerator
    1009           0 :     aWriter.writeBoolProperty( mbFocusOnClick ); // binary flag means "do not take focus"
    1010           0 :     aWriter.skipProperty(); // mouse icon
    1011           0 :     aWriter.finalizeExport();
    1012           0 :     AxFontDataModel::exportBinaryModel( rOutStrm );
    1013           0 : }
    1014             : 
    1015           0 : void AxCommandButtonModel::exportCompObj( BinaryOutputStream& rOutStream )
    1016             : {
    1017             :     // should be able to replace this hardcoded foo with
    1018             :     // proper export info from MS-OLEDS spec.
    1019             :     static sal_uInt8 const aCompObj[] = {
    1020             :         0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
    1021             :         0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x32, 0x05, 0xD7,
    1022             :         0x69, 0xCE, 0xCD, 0x11, 0xA7, 0x77, 0x00, 0xDD,
    1023             :         0x01, 0x14, 0x3C, 0x57, 0x22, 0x00, 0x00, 0x00,
    1024             :         0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
    1025             :         0x74, 0x20, 0x46, 0x6F, 0x72, 0x6d, 0x73, 0x20,
    1026             :         0x32, 0x2e, 0x30, 0x20, 0x43, 0x6F, 0x6D, 0x6D,
    1027             :         0x61, 0x6E, 0x64, 0x42, 0x75, 0x74, 0x74, 0x6F,
    1028             :         0x6E, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
    1029             :         0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
    1030             :         0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x16, 0x00,
    1031             :         0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
    1032             :         0x43, 0x6F, 0x6D, 0x6D, 0x61, 0x6E, 0x64, 0x42,
    1033             :         0x75, 0x74, 0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00,
    1034             :         0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
    1035             :         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    1036             :     };
    1037           0 :     rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
    1038           0 : }
    1039             : 
    1040          42 : ApiControlType AxCommandButtonModel::getControlType() const
    1041             : {
    1042          42 :     return API_CONTROL_BUTTON;
    1043             : }
    1044             : 
    1045          42 : void AxCommandButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
    1046             : {
    1047          42 :     rPropMap.setProperty( PROP_Label, maCaption );
    1048          42 :     rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
    1049          42 :     rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
    1050          42 :     rPropMap.setProperty( PROP_FocusOnClick, mbFocusOnClick );
    1051          42 :     rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor );
    1052          42 :     rConv.convertVerticalAlign( rPropMap, mnVerticalAlign );
    1053          42 :     rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED );
    1054          42 :     rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos );
    1055          42 :     AxFontDataModel::convertProperties( rPropMap, rConv );
    1056          42 : }
    1057             : 
    1058           0 : void AxCommandButtonModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
    1059             : {
    1060           0 :     (void)rPropSet.getProperty(maCaption, PROP_Label);
    1061           0 :     bool bRes = false;
    1062           0 :     if ( rPropSet.getProperty( bRes, PROP_Enabled ) )
    1063           0 :         setFlag( mnFlags, AX_FLAGS_ENABLED, bRes );
    1064           0 :     if ( rPropSet.getProperty( bRes,  PROP_MultiLine ) )
    1065           0 :         setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
    1066           0 :     (void)rPropSet.getProperty(mbFocusOnClick, PROP_FocusOnClick);
    1067             : 
    1068           0 :     rConv.convertToMSColor( rPropSet, PROP_TextColor, mnTextColor );
    1069           0 :     rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
    1070             : 
    1071           0 :     AxFontDataModel::convertFromProperties( rPropSet, rConv );
    1072           0 : }
    1073             : 
    1074           2 : AxLabelModel::AxLabelModel() :
    1075             :     mnTextColor( AX_SYSCOLOR_BUTTONTEXT ),
    1076             :     mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
    1077             :     mnFlags( AX_LABEL_DEFFLAGS ),
    1078             :     mnBorderColor( AX_SYSCOLOR_WINDOWFRAME ),
    1079             :     mnBorderStyle( AX_BORDERSTYLE_NONE ),
    1080             :     mnSpecialEffect( AX_SPECIALEFFECT_FLAT ),
    1081           2 :     mnVerticalAlign( XML_Top )
    1082             : {
    1083           2 : }
    1084             : 
    1085           0 : void AxLabelModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
    1086             : {
    1087           0 :     switch( nPropId )
    1088             :     {
    1089           0 :         case XML_Caption:               maCaption = rValue;                                             break;
    1090           0 :         case XML_ForeColor:             mnTextColor = AttributeConversion::decodeUnsigned( rValue );    break;
    1091           0 :         case XML_BackColor:             mnBackColor = AttributeConversion::decodeUnsigned( rValue );    break;
    1092           0 :         case XML_VariousPropertyBits:   mnFlags = AttributeConversion::decodeUnsigned( rValue );        break;
    1093           0 :         case XML_BorderColor:           mnBorderColor = AttributeConversion::decodeUnsigned( rValue );  break;
    1094           0 :         case XML_BorderStyle:           mnBorderStyle = AttributeConversion::decodeInteger( rValue );   break;
    1095           0 :         case XML_SpecialEffect:         mnSpecialEffect = AttributeConversion::decodeInteger( rValue ); break;
    1096           0 :         default:                        AxFontDataModel::importProperty( nPropId, rValue );
    1097             :     }
    1098           0 : }
    1099             : 
    1100           2 : bool AxLabelModel::importBinaryModel( BinaryInputStream& rInStrm )
    1101             : {
    1102           2 :     AxBinaryPropertyReader aReader( rInStrm );
    1103           2 :     aReader.readIntProperty< sal_uInt32 >( mnTextColor );
    1104           2 :     aReader.readIntProperty< sal_uInt32 >( mnBackColor );
    1105           2 :     aReader.readIntProperty< sal_uInt32 >( mnFlags );
    1106           2 :     aReader.readStringProperty( maCaption );
    1107           2 :     aReader.skipIntProperty< sal_uInt32 >(); // picture position
    1108           2 :     aReader.readPairProperty( maSize );
    1109           2 :     aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
    1110           2 :     aReader.readIntProperty< sal_uInt32 >( mnBorderColor );
    1111           2 :     aReader.readIntProperty< sal_uInt16 >( mnBorderStyle );
    1112           2 :     aReader.readIntProperty< sal_uInt16 >( mnSpecialEffect );
    1113           2 :     aReader.skipPictureProperty(); // picture
    1114           2 :     aReader.skipIntProperty< sal_uInt16 >(); // accelerator
    1115           2 :     aReader.skipPictureProperty(); // mouse icon
    1116           2 :     return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm );
    1117             : }
    1118             : 
    1119           0 : void AxLabelModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
    1120             : {
    1121           0 :     AxBinaryPropertyWriter aWriter( rOutStrm );
    1122           0 :     aWriter.writeIntProperty< sal_uInt32 >( mnTextColor );
    1123           0 :     if ( mnBackColor )
    1124           0 :         aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
    1125             :     else
    1126             :         // if mnBackColor == 0 then it's the libreoffice default backcolour is
    1127             :         // the MSO Label default which is AX_SYSCOLOR_BUTTONFACE
    1128           0 :         aWriter.writeIntProperty< sal_uInt32 >( AX_SYSCOLOR_WINDOWBACK );
    1129           0 :     aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
    1130           0 :     aWriter.writeStringProperty( maCaption );
    1131           0 :     aWriter.skipProperty(); // picture position
    1132           0 :     aWriter.writePairProperty( maSize );
    1133           0 :     aWriter.skipProperty(); // mouse pointer
    1134           0 :     aWriter.writeIntProperty< sal_uInt32 >( mnBorderColor );
    1135           0 :     aWriter.writeIntProperty< sal_uInt16 >( mnBorderStyle );
    1136           0 :     aWriter.writeIntProperty< sal_uInt16 >( mnSpecialEffect );
    1137           0 :     aWriter.skipProperty(); // picture
    1138           0 :     aWriter.skipProperty(); // accelerator
    1139           0 :     aWriter.skipProperty(); // mouse icon
    1140           0 :     aWriter.finalizeExport();
    1141           0 :     AxFontDataModel::exportBinaryModel( rOutStrm );
    1142           0 : }
    1143             : 
    1144           0 : void AxLabelModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
    1145             : {
    1146           0 :     rPropSet.getProperty( maCaption, PROP_Label );
    1147           0 :     bool bRes = false;
    1148           0 :     if ( rPropSet.getProperty( bRes, PROP_Enabled ) )
    1149           0 :         setFlag( mnFlags, AX_FLAGS_ENABLED, bRes );
    1150           0 :     if ( rPropSet.getProperty( bRes,  PROP_MultiLine ) )
    1151           0 :         setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
    1152             : 
    1153           0 :     rConv.convertToMSColor( rPropSet, PROP_TextColor, mnTextColor );
    1154             :     // VerticleAlign doesn't seem to be read from binary
    1155             : 
    1156             :     // not sure about background color, how do we decide when to set
    1157             :     // AX_FLAGS_OPAQUE ?
    1158           0 :     rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor  );
    1159           0 :     rConv.convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect );
    1160             : 
    1161           0 :     AxFontDataModel::convertFromProperties( rPropSet, rConv );
    1162           0 : }
    1163             : 
    1164           0 : void AxLabelModel::exportCompObj( BinaryOutputStream& rOutStream )
    1165             : {
    1166             :     // should be able to replace this hardcoded foo with
    1167             :     // proper export info from MS-OLEDS spec.
    1168             :     static sal_uInt8 const aCompObj[] = {
    1169             :         0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
    1170             :         0xFF, 0xFF, 0xFF, 0xFF, 0x23, 0x9E, 0x8C, 0x97,
    1171             :         0xB0, 0xD4, 0xCE, 0x11, 0xBF, 0x2D, 0x00, 0xAA,
    1172             :         0x00, 0x3F, 0x40, 0xD0, 0x1A, 0x00, 0x00, 0x00,
    1173             :         0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
    1174             :         0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
    1175             :         0x32, 0x2E, 0x30, 0x20, 0x4C, 0x61, 0x62, 0x65,
    1176             :         0x6C, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
    1177             :         0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
    1178             :         0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x0E, 0x00,
    1179             :         0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
    1180             :         0x4C, 0x61, 0x62, 0x65, 0x6C, 0x2E, 0x31, 0x00,
    1181             :         0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
    1182             :         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    1183             :     };
    1184           0 :     rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
    1185           0 : }
    1186             : 
    1187           2 : ApiControlType AxLabelModel::getControlType() const
    1188             : {
    1189           2 :     return API_CONTROL_FIXEDTEXT;
    1190             : }
    1191             : 
    1192           2 : void AxLabelModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
    1193             : {
    1194           2 :     rPropMap.setProperty( PROP_Label, maCaption );
    1195           2 :     rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
    1196           2 :     rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
    1197           2 :     rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor );
    1198           2 :     rConv.convertVerticalAlign( rPropMap, mnVerticalAlign );
    1199           2 :     rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID );
    1200           2 :     rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
    1201           2 :     AxFontDataModel::convertProperties( rPropMap, rConv );
    1202           2 : }
    1203             : 
    1204           0 : AxImageModel::AxImageModel() :
    1205             :     mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
    1206             :     mnFlags( AX_IMAGE_DEFFLAGS ),
    1207             :     mnBorderColor( AX_SYSCOLOR_WINDOWFRAME ),
    1208             :     mnBorderStyle( AX_BORDERSTYLE_SINGLE ),
    1209             :     mnSpecialEffect( AX_SPECIALEFFECT_FLAT ),
    1210             :     mnPicSizeMode( AX_PICSIZE_CLIP ),
    1211             :     mnPicAlign( AX_PICALIGN_CENTER ),
    1212           0 :     mbPicTiling( false )
    1213             : {
    1214           0 : }
    1215             : 
    1216           0 : void AxImageModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
    1217             : {
    1218           0 :     switch( nPropId )
    1219             :     {
    1220           0 :         case XML_BackColor:             mnBackColor = AttributeConversion::decodeUnsigned( rValue );      break;
    1221           0 :         case XML_VariousPropertyBits:   mnFlags = AttributeConversion::decodeUnsigned( rValue );          break;
    1222           0 :         case XML_BorderColor:           mnBorderColor = AttributeConversion::decodeUnsigned( rValue );    break;
    1223           0 :         case XML_BorderStyle:           mnBorderStyle = AttributeConversion::decodeInteger( rValue );     break;
    1224           0 :         case XML_SpecialEffect:         mnSpecialEffect = AttributeConversion::decodeInteger( rValue );   break;
    1225           0 :         case XML_SizeMode:              mnPicSizeMode = AttributeConversion::decodeInteger( rValue );     break;
    1226           0 :         case XML_PictureAlignment:      mnPicAlign = AttributeConversion::decodeInteger( rValue );        break;
    1227           0 :         case XML_PictureTiling:         mbPicTiling = AttributeConversion::decodeInteger( rValue ) != 0;  break;
    1228           0 :         default:                        AxControlModelBase::importProperty( nPropId, rValue );
    1229             :     }
    1230           0 : }
    1231             : 
    1232           0 : void AxImageModel::importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm )
    1233             : {
    1234           0 :     switch( nPropId )
    1235             :     {
    1236           0 :         case XML_Picture:   OleHelper::importStdPic( maPictureData, rInStrm, true );    break;
    1237           0 :         default:            AxControlModelBase::importPictureData( nPropId, rInStrm );
    1238             :     }
    1239           0 : }
    1240             : 
    1241           0 : bool AxImageModel::importBinaryModel( BinaryInputStream& rInStrm )
    1242             : {
    1243           0 :     AxBinaryPropertyReader aReader( rInStrm );
    1244           0 :     aReader.skipUndefinedProperty();
    1245           0 :     aReader.skipUndefinedProperty();
    1246           0 :     aReader.skipBoolProperty(); // auto-size
    1247           0 :     aReader.readIntProperty< sal_uInt32 >( mnBorderColor );
    1248           0 :     aReader.readIntProperty< sal_uInt32 >( mnBackColor );
    1249           0 :     aReader.readIntProperty< sal_uInt8 >( mnBorderStyle );
    1250           0 :     aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
    1251           0 :     aReader.readIntProperty< sal_uInt8 >( mnPicSizeMode );
    1252           0 :     aReader.readIntProperty< sal_uInt8 >( mnSpecialEffect );
    1253           0 :     aReader.readPairProperty( maSize );
    1254           0 :     aReader.readPictureProperty( maPictureData );
    1255           0 :     aReader.readIntProperty< sal_uInt8 >( mnPicAlign );
    1256           0 :     aReader.readBoolProperty( mbPicTiling );
    1257           0 :     aReader.readIntProperty< sal_uInt32 >( mnFlags );
    1258           0 :     aReader.skipPictureProperty(); // mouse icon
    1259           0 :     return aReader.finalizeImport();
    1260             : }
    1261             : 
    1262           0 : void AxImageModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
    1263             : {
    1264           0 :     AxBinaryPropertyWriter aWriter( rOutStrm );
    1265           0 :     aWriter.skipProperty(); //undefined
    1266           0 :     aWriter.skipProperty(); //undefined
    1267           0 :     aWriter.skipProperty(); //auto-size
    1268           0 :     aWriter.writeIntProperty< sal_uInt32 >( mnBorderColor );
    1269           0 :     if ( mnBackColor )
    1270           0 :         aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
    1271             :     else
    1272           0 :         aWriter.skipProperty(); // default backcolour
    1273           0 :     aWriter.writeIntProperty< sal_uInt8 >( mnBorderStyle );
    1274           0 :     aWriter.skipProperty(); // mouse pointer
    1275           0 :     aWriter.writeIntProperty< sal_uInt8 >( mnPicSizeMode );
    1276           0 :     aWriter.writeIntProperty< sal_uInt8 >( mnSpecialEffect );
    1277           0 :     aWriter.writePairProperty( maSize );
    1278           0 :     aWriter.skipProperty(); //maPictureData );
    1279           0 :     aWriter.writeIntProperty< sal_uInt8 >( mnPicAlign );
    1280           0 :     aWriter.writeBoolProperty( mbPicTiling );
    1281           0 :     aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
    1282           0 :     aWriter.skipProperty(); // mouse icon
    1283           0 :     aWriter.finalizeExport();
    1284           0 : }
    1285             : 
    1286           0 : void AxImageModel::exportCompObj( BinaryOutputStream& rOutStream )
    1287             : {
    1288             :     // should be able to replace this hardcoded foo with
    1289             :     // proper export info from MS-OLEDS spec.
    1290             :     static sal_uInt8 const aCompObj[] = {
    1291             :         0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
    1292             :         0xFF, 0xFF, 0xFF, 0xFF, 0x41, 0x92, 0x59, 0x4C,
    1293             :         0x26, 0x69, 0x1B, 0x10, 0x99, 0x92, 0x00, 0x00,
    1294             :         0x0B, 0x65, 0xC6, 0xF9, 0x1A, 0x00, 0x00, 0x00,
    1295             :         0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
    1296             :         0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
    1297             :         0x32, 0x2E, 0x30, 0x20, 0x49, 0x6D, 0x61, 0x67,
    1298             :         0x65, 0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D,
    1299             :         0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F,
    1300             :         0x62, 0x6A, 0x65, 0x63, 0x74, 0x00, 0x0E, 0x00,
    1301             :         0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E,
    1302             :         0x49, 0x6D, 0x61, 0x67, 0x65, 0x2E, 0x31, 0x00,
    1303             :         0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
    1304             :         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    1305             :     };
    1306           0 :     rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
    1307           0 : }
    1308             : 
    1309           0 : ApiControlType AxImageModel::getControlType() const
    1310             : {
    1311           0 :     return API_CONTROL_IMAGE;
    1312             : }
    1313             : 
    1314           0 : void AxImageModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
    1315             : {
    1316           0 :     rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
    1317           0 :     rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID );
    1318           0 :     rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
    1319           0 :     rConv.convertAxPicture( rPropMap, maPictureData, mnPicSizeMode, mnPicAlign, mbPicTiling );
    1320           0 :     AxControlModelBase::convertProperties( rPropMap, rConv );
    1321           0 : }
    1322             : 
    1323           0 : AxTabStripModel::AxTabStripModel() :
    1324             :     mnListIndex( 0 ),
    1325             :     mnTabStyle( 0 ),
    1326             :     mnTabData( 0 ),
    1327           0 :     mnVariousPropertyBits( 0 )
    1328             : {
    1329           0 : }
    1330             : 
    1331           0 : bool AxTabStripModel::importBinaryModel( BinaryInputStream& rInStrm )
    1332             : {
    1333             :     // not worth reading much here, basically we are interested
    1334             :     // in whether we have tabs, the width, the height and the
    1335             :     // captions, everything else we can pretty much discard ( for now )
    1336           0 :     AxBinaryPropertyReader aReader( rInStrm );
    1337           0 :     aReader.readIntProperty< sal_uInt32 >( mnListIndex ); // ListIndex
    1338           0 :     aReader.skipIntProperty< sal_uInt32 >(); // Backcolor
    1339           0 :     aReader.skipIntProperty< sal_uInt32 >(); // ForeColor
    1340           0 :     aReader.skipUndefinedProperty();
    1341           0 :     aReader.readPairProperty( maSize );
    1342           0 :     aReader.readArrayStringProperty( maItems );
    1343           0 :     aReader.skipIntProperty< sal_uInt8 >();  // MousePointer
    1344           0 :     aReader.skipUndefinedProperty();
    1345           0 :     aReader.skipIntProperty< sal_uInt32 >(); // TabOrientation
    1346           0 :     aReader.readIntProperty< sal_uInt32 >(mnTabStyle); // TabStyle
    1347           0 :     aReader.skipBoolProperty();              // MultiRow
    1348           0 :     aReader.skipIntProperty< sal_uInt32 >(); // TabFixedWidth
    1349           0 :     aReader.skipIntProperty< sal_uInt32 >(); // TabFixedHeight
    1350           0 :     aReader.skipBoolProperty();              // ToolTips
    1351           0 :     aReader.skipUndefinedProperty();
    1352           0 :     aReader.skipArrayStringProperty();  // ToolTip strings
    1353           0 :     aReader.skipUndefinedProperty();
    1354           0 :     aReader.readArrayStringProperty( maTabNames ); // Tab names
    1355           0 :     aReader.readIntProperty< sal_uInt32 >(mnVariousPropertyBits); // VariousPropertyBits
    1356           0 :     aReader.skipBoolProperty();// NewVersion
    1357           0 :     aReader.skipIntProperty< sal_uInt32 >(); // TabsAllocated
    1358           0 :     aReader.skipArrayStringProperty();  // Tags
    1359           0 :     aReader.readIntProperty<sal_uInt32 >(mnTabData);  // TabData
    1360           0 :     aReader.skipArrayStringProperty();  // Accelerators
    1361           0 :     aReader.skipPictureProperty(); // Mouse Icon
    1362           0 :     return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm );
    1363             : }
    1364             : 
    1365           0 : ApiControlType AxTabStripModel::getControlType() const
    1366             : {
    1367           0 :     return API_CONTROL_TABSTRIP;
    1368             : }
    1369             : 
    1370          40 : AxMorphDataModelBase::AxMorphDataModelBase() :
    1371             :     mnTextColor( AX_SYSCOLOR_WINDOWTEXT ),
    1372             :     mnBackColor( AX_SYSCOLOR_WINDOWBACK ),
    1373             :     mnFlags( AX_MORPHDATA_DEFFLAGS ),
    1374             :     mnPicturePos( AX_PICPOS_ABOVECENTER ),
    1375             :     mnBorderColor( AX_SYSCOLOR_WINDOWFRAME ),
    1376             :     mnBorderStyle( AX_BORDERSTYLE_NONE ),
    1377             :     mnSpecialEffect( AX_SPECIALEFFECT_SUNKEN ),
    1378             :     mnDisplayStyle( AX_DISPLAYSTYLE_TEXT ),
    1379             :     mnMultiSelect( AX_SELECTION_SINGLE ),
    1380             :     mnScrollBars( AX_SCROLLBAR_NONE ),
    1381             :     mnMatchEntry( AX_MATCHENTRY_NONE ),
    1382             :     mnShowDropButton( AX_SHOWDROPBUTTON_NEVER ),
    1383             :     mnMaxLength( 0 ),
    1384             :     mnPasswordChar( 0 ),
    1385             :     mnListRows( 8 ),
    1386          40 :     mnVerticalAlign( XML_Center )
    1387             : {
    1388          40 : }
    1389             : 
    1390           0 : void AxMorphDataModelBase::importProperty( sal_Int32 nPropId, const OUString& rValue )
    1391             : {
    1392           0 :     switch( nPropId )
    1393             :     {
    1394           0 :         case XML_Caption:               maCaption = rValue;                                             break;
    1395           0 :         case XML_Value:                 maValue = rValue;                                               break;
    1396           0 :         case XML_GroupName:             maGroupName = rValue;                                           break;
    1397           0 :         case XML_ForeColor:             mnTextColor = AttributeConversion::decodeUnsigned( rValue );    break;
    1398           0 :         case XML_BackColor:             mnBackColor = AttributeConversion::decodeUnsigned( rValue );    break;
    1399           0 :         case XML_VariousPropertyBits:   mnFlags = AttributeConversion::decodeUnsigned( rValue );        break;
    1400           0 :         case XML_PicturePosition:       mnPicturePos = AttributeConversion::decodeUnsigned( rValue );   break;
    1401           0 :         case XML_BorderColor:           mnBorderColor = AttributeConversion::decodeUnsigned( rValue );  break;
    1402           0 :         case XML_BorderStyle:           mnBorderStyle = AttributeConversion::decodeInteger( rValue );   break;
    1403           0 :         case XML_SpecialEffect:         mnSpecialEffect = AttributeConversion::decodeInteger( rValue ); break;
    1404           0 :         case XML_DisplayStyle:          mnDisplayStyle = AttributeConversion::decodeInteger( rValue );  break;
    1405           0 :         case XML_MultiSelect:           mnMultiSelect = AttributeConversion::decodeInteger( rValue );   break;
    1406           0 :         case XML_ScrollBars:            mnScrollBars = AttributeConversion::decodeInteger( rValue );    break;
    1407           0 :         case XML_MatchEntry:            mnMatchEntry = AttributeConversion::decodeInteger( rValue );    break;
    1408           0 :         case XML_ShowDropButtonWhen:    mnShowDropButton = AttributeConversion::decodeInteger( rValue );break;
    1409           0 :         case XML_MaxLength:             mnMaxLength = AttributeConversion::decodeInteger( rValue );     break;
    1410           0 :         case XML_PasswordChar:          mnPasswordChar = AttributeConversion::decodeInteger( rValue );  break;
    1411           0 :         case XML_ListRows:              mnListRows = AttributeConversion::decodeInteger( rValue );      break;
    1412           0 :         default:                        AxFontDataModel::importProperty( nPropId, rValue );
    1413             :     }
    1414           0 : }
    1415             : 
    1416           0 : void AxMorphDataModelBase::importPictureData( sal_Int32 nPropId, BinaryInputStream& rInStrm )
    1417             : {
    1418           0 :     switch( nPropId )
    1419             :     {
    1420           0 :         case XML_Picture:   OleHelper::importStdPic( maPictureData, rInStrm, true );    break;
    1421           0 :         default:            AxFontDataModel::importPictureData( nPropId, rInStrm );
    1422             :     }
    1423           0 : }
    1424             : 
    1425          36 : bool AxMorphDataModelBase::importBinaryModel( BinaryInputStream& rInStrm )
    1426             : {
    1427          36 :     AxBinaryPropertyReader aReader( rInStrm, true );
    1428          36 :     aReader.readIntProperty< sal_uInt32 >( mnFlags );
    1429          36 :     aReader.readIntProperty< sal_uInt32 >( mnBackColor );
    1430          36 :     aReader.readIntProperty< sal_uInt32 >( mnTextColor );
    1431          36 :     aReader.readIntProperty< sal_Int32 >( mnMaxLength );
    1432          36 :     aReader.readIntProperty< sal_uInt8 >( mnBorderStyle );
    1433          36 :     aReader.readIntProperty< sal_uInt8 >( mnScrollBars );
    1434          36 :     aReader.readIntProperty< sal_uInt8 >( mnDisplayStyle );
    1435          36 :     aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
    1436          36 :     aReader.readPairProperty( maSize );
    1437          36 :     aReader.readIntProperty< sal_uInt16 >( mnPasswordChar );
    1438          36 :     aReader.skipIntProperty< sal_uInt32 >(); // list width
    1439          36 :     aReader.skipIntProperty< sal_uInt16 >(); // bound column
    1440          36 :     aReader.skipIntProperty< sal_Int16 >(); // text column
    1441          36 :     aReader.skipIntProperty< sal_Int16 >(); // column count
    1442          36 :     aReader.readIntProperty< sal_uInt16 >( mnListRows );
    1443          36 :     aReader.skipIntProperty< sal_uInt16 >(); // column info count
    1444          36 :     aReader.readIntProperty< sal_uInt8 >( mnMatchEntry );
    1445          36 :     aReader.skipIntProperty< sal_uInt8 >(); // list style
    1446          36 :     aReader.readIntProperty< sal_uInt8 >( mnShowDropButton );
    1447          36 :     aReader.skipUndefinedProperty();
    1448          36 :     aReader.skipIntProperty< sal_uInt8 >(); // drop down style
    1449          36 :     aReader.readIntProperty< sal_uInt8 >( mnMultiSelect );
    1450          36 :     aReader.readStringProperty( maValue );
    1451          36 :     aReader.readStringProperty( maCaption );
    1452          36 :     aReader.readIntProperty< sal_uInt32 >( mnPicturePos );
    1453          36 :     aReader.readIntProperty< sal_uInt32 >( mnBorderColor );
    1454          36 :     aReader.readIntProperty< sal_uInt32 >( mnSpecialEffect );
    1455          36 :     aReader.skipPictureProperty(); // mouse icon
    1456          36 :     aReader.readPictureProperty( maPictureData );
    1457          36 :     aReader.skipIntProperty< sal_uInt16 >(); // accelerator
    1458          36 :     aReader.skipUndefinedProperty();
    1459          36 :     aReader.skipBoolProperty();
    1460          36 :     aReader.readStringProperty( maGroupName );
    1461          36 :     return aReader.finalizeImport() && AxFontDataModel::importBinaryModel( rInStrm );
    1462             : }
    1463             : 
    1464           2 : void AxMorphDataModelBase::exportBinaryModel( BinaryOutputStream& rOutStrm )
    1465             : {
    1466           2 :     AxBinaryPropertyWriter aWriter( rOutStrm, true );
    1467           2 :     if ( mnFlags != AX_MORPHDATA_DEFFLAGS )
    1468           2 :         aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
    1469             :     else
    1470           0 :         aWriter.skipProperty(); //mnFlags
    1471           2 :     if ( mnBackColor )
    1472           2 :         aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
    1473             :     else
    1474           0 :         aWriter.skipProperty(); // default backcolour
    1475           2 :     aWriter.writeIntProperty< sal_uInt32 >( mnTextColor );
    1476             : 
    1477             :     // only write if different from default
    1478           2 :     if ( ( ( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT ) || ( mnDisplayStyle == AX_DISPLAYSTYLE_COMBOBOX ) ) && mnMaxLength != 0 )
    1479           0 :         aWriter.writeIntProperty< sal_Int32 >( mnMaxLength );
    1480             :     else
    1481           2 :         aWriter.skipProperty(); //mnMaxLength
    1482           2 :     if ( ( ( mnDisplayStyle == AX_DISPLAYSTYLE_COMBOBOX ) || ( mnDisplayStyle == AX_DISPLAYSTYLE_LISTBOX ) || ( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT ) ) && mnBorderStyle != AX_BORDERSTYLE_NONE )
    1483           0 :         aWriter.writeIntProperty< sal_uInt8 >( mnBorderStyle );
    1484             :     else
    1485           2 :         aWriter.skipProperty(); //mnBorderStyle
    1486             : 
    1487           2 :     if ( ( mnDisplayStyle == AX_DISPLAYSTYLE_LISTBOX || mnDisplayStyle == AX_DISPLAYSTYLE_TEXT ) && mnScrollBars != AX_SCROLLBAR_NONE )
    1488           0 :         aWriter.writeIntProperty< sal_uInt8 >( mnScrollBars );
    1489             :     else
    1490           2 :         aWriter.skipProperty(); //mnScrollBars
    1491           2 :     aWriter.writeIntProperty< sal_uInt8 >( mnDisplayStyle );
    1492           2 :     aWriter.skipProperty(); // mouse pointer
    1493           2 :     aWriter.writePairProperty( maSize );
    1494           2 :     if  ( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT )
    1495           2 :         aWriter.writeIntProperty< sal_uInt16 >( mnPasswordChar );
    1496             :     else
    1497           0 :         aWriter.skipProperty(); // mnPasswordChar
    1498           2 :     aWriter.skipProperty(); // list width
    1499           2 :     aWriter.skipProperty(); // bound column
    1500           2 :     aWriter.skipProperty(); // text column
    1501           2 :     aWriter.skipProperty(); // column count
    1502           2 :     aWriter.skipProperty(); // mnListRows
    1503           2 :     aWriter.skipProperty(); // column info count
    1504           2 :     aWriter.skipProperty(); // mnMatchEntry
    1505           2 :     aWriter.skipProperty(); // list style
    1506           2 :     aWriter.skipProperty(); // mnShowDropButton );
    1507           2 :     aWriter.skipProperty();
    1508           2 :     aWriter.skipProperty(); // drop down style
    1509           2 :     if ( mnDisplayStyle == AX_DISPLAYSTYLE_LISTBOX && mnMultiSelect != AX_SELECTION_SINGLE )
    1510           0 :         aWriter.writeIntProperty< sal_uInt8 >( mnMultiSelect );
    1511             :     // although CheckBox, ListBox, OptionButton, ToggleButton are also supported
    1512             :     // they can only have the fileformat default
    1513             :     else
    1514           2 :         aWriter.skipProperty(); //mnMultiSelect
    1515           2 :     aWriter.writeStringProperty( maValue );
    1516             : 
    1517           2 :     if ( ( mnDisplayStyle == AX_DISPLAYSTYLE_CHECKBOX ) || ( mnDisplayStyle == AX_DISPLAYSTYLE_OPTBUTTON ) || ( mnDisplayStyle == AX_DISPLAYSTYLE_TOGGLE ) )
    1518           0 :         aWriter.writeStringProperty( maCaption );
    1519             :     else
    1520           2 :         aWriter.skipProperty(); // mnCaption
    1521           2 :     aWriter.skipProperty(); // mnPicturePos );
    1522           2 :     if ( ( mnDisplayStyle == AX_DISPLAYSTYLE_COMBOBOX || mnDisplayStyle == AX_DISPLAYSTYLE_LISTBOX ||  mnDisplayStyle == AX_DISPLAYSTYLE_TEXT ) && mnBorderColor != AX_SYSCOLOR_WINDOWFRAME )
    1523           2 :        aWriter.writeIntProperty< sal_uInt32 >( mnBorderColor );
    1524             :     else
    1525           0 :         aWriter.skipProperty(); // mnBorderColor
    1526           2 :     if (  mnSpecialEffect != AX_SPECIALEFFECT_SUNKEN  )
    1527           0 :         aWriter.writeIntProperty< sal_uInt32 >( mnSpecialEffect );
    1528             :     else
    1529           2 :         aWriter.skipProperty(); //mnSpecialEffect
    1530           2 :     aWriter.skipProperty(); // mouse icon
    1531           2 :     aWriter.skipProperty(); // maPictureData
    1532           2 :     aWriter.skipProperty(); // accelerator
    1533           2 :     aWriter.skipProperty(); // undefined
    1534           2 :     aWriter.writeBoolProperty(true); // must be 1 for morph
    1535           2 :     if ( ( mnDisplayStyle == AX_DISPLAYSTYLE_CHECKBOX ) || ( mnDisplayStyle == AX_DISPLAYSTYLE_OPTBUTTON ) )
    1536           0 :         aWriter.writeStringProperty( maGroupName );
    1537             :     else
    1538           2 :         aWriter.skipProperty(); //maGroupName
    1539           2 :     aWriter.finalizeExport();
    1540           2 :     AxFontDataModel::exportBinaryModel( rOutStrm );
    1541           2 : }
    1542             : 
    1543          38 : void AxMorphDataModelBase::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
    1544             : {
    1545          38 :     rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
    1546          38 :     rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor );
    1547          38 :     AxFontDataModel::convertProperties( rPropMap, rConv );
    1548          38 : }
    1549             : 
    1550           4 : AxToggleButtonModel::AxToggleButtonModel()
    1551             : {
    1552           4 :     mnDisplayStyle = AX_DISPLAYSTYLE_TOGGLE;
    1553           4 : }
    1554             : 
    1555          10 : ApiControlType AxToggleButtonModel::getControlType() const
    1556             : {
    1557             :     OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_TOGGLE, "AxToggleButtonModel::getControlType - invalid control type" );
    1558          10 :     return API_CONTROL_BUTTON;
    1559             : }
    1560             : 
    1561           0 : void AxToggleButtonModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
    1562             : {
    1563           0 :     rPropSet.getProperty( maCaption, PROP_Label );
    1564             : 
    1565           0 :     bool bRes = false;
    1566           0 :     if ( rPropSet.getProperty( bRes,  PROP_MultiLine ) )
    1567           0 :         setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
    1568             : 
    1569           0 :     rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
    1570             :     // need to process the image if one exists
    1571           0 :     rConv.convertToAxState( rPropSet, maValue, mnMultiSelect, API_DEFAULTSTATE_BOOLEAN, mbAwtModel );
    1572           0 :     AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
    1573           0 : }
    1574             : 
    1575           4 : void AxToggleButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
    1576             : {
    1577           4 :     rPropMap.setProperty( PROP_Label, maCaption );
    1578           4 :     rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
    1579           4 :     rPropMap.setProperty( PROP_Toggle, true );
    1580           4 :     rConv.convertVerticalAlign( rPropMap, mnVerticalAlign );
    1581           4 :     rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED );
    1582           4 :     rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos );
    1583           4 :     rConv.convertAxState( rPropMap, maValue, mnMultiSelect, API_DEFAULTSTATE_BOOLEAN, mbAwtModel );
    1584           4 :     AxMorphDataModelBase::convertProperties( rPropMap, rConv );
    1585           4 : }
    1586             : 
    1587           0 : void AxToggleButtonModel::exportCompObj( BinaryOutputStream& rOutStream )
    1588             : {
    1589             :     // should be able to replace this hardcoded foo with
    1590             :     // proper export info from MS-OLEDS spec.
    1591             :     static sal_uInt8 const aCompObj[] = {
    1592             :             0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
    1593             :             0xFF, 0xFF, 0xFF, 0xFF, 0x60, 0x1D, 0xD2, 0x8B,
    1594             :             0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
    1595             :             0x00, 0x60, 0x02, 0xF3, 0x21, 0x00, 0x00, 0x00,
    1596             :             0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
    1597             :             0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
    1598             :             0x32, 0x2E, 0x30, 0x20, 0x54, 0x6F, 0x67, 0x67,
    1599             :             0x6C, 0x65, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E,
    1600             :             0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62,
    1601             :             0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62,
    1602             :             0x6A, 0x65, 0x63, 0x74, 0x00, 0x15, 0x00, 0x00,
    1603             :             0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x54,
    1604             :             0x6F, 0x67, 0x67, 0x6C, 0x65, 0x42, 0x75, 0x74,
    1605             :             0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00, 0xF4, 0x39,
    1606             :             0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    1607             :             0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    1608             :     };
    1609           0 :     rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
    1610           0 : }
    1611             : 
    1612          10 : AxCheckBoxModel::AxCheckBoxModel()
    1613             : {
    1614          10 :     mnDisplayStyle = AX_DISPLAYSTYLE_CHECKBOX;
    1615          10 : }
    1616             : 
    1617          16 : ApiControlType AxCheckBoxModel::getControlType() const
    1618             : {
    1619             :     OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_CHECKBOX, "AxCheckBoxModel::getControlType - invalid control type" );
    1620          16 :     return API_CONTROL_CHECKBOX;
    1621             : }
    1622             : 
    1623          10 : void AxCheckBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
    1624             : {
    1625          10 :     rPropMap.setProperty( PROP_Label, maCaption );
    1626          10 :     rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
    1627          10 :     rConv.convertVerticalAlign( rPropMap, mnVerticalAlign );
    1628          10 :     rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID );
    1629          10 :     rConv.convertAxVisualEffect( rPropMap, mnSpecialEffect );
    1630          10 :     rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos );
    1631          10 :     rConv.convertAxState( rPropMap, maValue, mnMultiSelect, API_DEFAULTSTATE_TRISTATE, mbAwtModel );
    1632          10 :     AxMorphDataModelBase::convertProperties( rPropMap, rConv );
    1633          10 : }
    1634             : 
    1635           0 : void AxCheckBoxModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
    1636             : {
    1637           0 :     rPropSet.getProperty( maCaption, PROP_Label );
    1638             : 
    1639           0 :     bool bRes = false;
    1640           0 :     if ( rPropSet.getProperty( bRes,  PROP_MultiLine ) )
    1641           0 :         setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
    1642             : 
    1643           0 :     rConv.convertToAxVisualEffect( rPropSet, mnSpecialEffect );
    1644           0 :     rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
    1645             :     // need to process the image if one exists
    1646           0 :     rConv.convertToAxState( rPropSet, maValue, mnMultiSelect, API_DEFAULTSTATE_BOOLEAN, mbAwtModel );
    1647           0 :     AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
    1648           0 : }
    1649             : 
    1650           0 : void AxCheckBoxModel::exportCompObj( BinaryOutputStream& rOutStream )
    1651             : {
    1652             :     // should be able to replace this hardcoded foo with
    1653             :     // proper export info from MS-OLEDS spec.
    1654             :     static sal_uInt8 const aCompObj[] = {
    1655             :         0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
    1656             :         0xFF, 0xFF, 0xFF, 0xFF, 0x40, 0x1D, 0xD2, 0x8B,
    1657             :         0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
    1658             :         0x00, 0x60, 0x02, 0xF3, 0x1D, 0x00, 0x00, 0x00,
    1659             :         0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
    1660             :         0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
    1661             :         0x32, 0x2E, 0x30, 0x20, 0x43, 0x68, 0x65, 0x63,
    1662             :         0x6B, 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00,
    1663             :         0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65,
    1664             :         0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74,
    1665             :         0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72,
    1666             :         0x6D, 0x73, 0x2E, 0x43, 0x68, 0x65, 0x63, 0x6B,
    1667             :         0x42, 0x6F, 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39,
    1668             :         0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    1669             :         0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    1670             :     };
    1671           0 :     rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
    1672           0 : }
    1673             : 
    1674           8 : AxOptionButtonModel::AxOptionButtonModel()
    1675             : {
    1676           8 :     mnDisplayStyle = AX_DISPLAYSTYLE_OPTBUTTON;
    1677           8 : }
    1678             : 
    1679          12 : ApiControlType AxOptionButtonModel::getControlType() const
    1680             : {
    1681             :     OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_OPTBUTTON, "AxOptionButtonModel::getControlType - invalid control type" );
    1682          12 :     return API_CONTROL_RADIOBUTTON;
    1683             : }
    1684             : 
    1685           8 : void AxOptionButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
    1686             : {
    1687           8 :     rPropMap.setProperty( PROP_Label, maCaption );
    1688           8 :     rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_WORDWRAP ) );
    1689           8 :     rConv.convertVerticalAlign( rPropMap, mnVerticalAlign );
    1690           8 :     rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID );
    1691           8 :     rConv.convertAxVisualEffect( rPropMap, mnSpecialEffect );
    1692           8 :     rConv.convertAxPicture( rPropMap, maPictureData, mnPicturePos );
    1693           8 :     rConv.convertAxState( rPropMap, maValue, mnMultiSelect, API_DEFAULTSTATE_SHORT, mbAwtModel );
    1694           8 :     AxMorphDataModelBase::convertProperties( rPropMap, rConv );
    1695           8 : }
    1696             : 
    1697           0 : void AxOptionButtonModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
    1698             : {
    1699           0 :     rPropSet.getProperty( maCaption, PROP_Label );
    1700             : 
    1701           0 :     bool bRes = false;
    1702           0 :     if ( rPropSet.getProperty( bRes,  PROP_MultiLine ) )
    1703           0 :         setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
    1704             : 
    1705           0 :     rConv.convertToAxVisualEffect( rPropSet, mnSpecialEffect );
    1706           0 :     rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
    1707             :     // need to process the image if one exists
    1708           0 :     rConv.convertToAxState( rPropSet, maValue, mnMultiSelect, API_DEFAULTSTATE_BOOLEAN, mbAwtModel );
    1709           0 :     AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
    1710           0 : }
    1711             : 
    1712           0 : void AxOptionButtonModel::exportCompObj( BinaryOutputStream& rOutStream )
    1713             : {
    1714             :     // should be able to replace this hardcoded foo with
    1715             :     // proper export info from MS-OLEDS spec.
    1716             :     static sal_uInt8 const aCompObj[] = {
    1717             :         0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
    1718             :         0xFF, 0xFF, 0xFF, 0xFF, 0x50, 0x1D, 0xD2, 0x8B,
    1719             :         0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
    1720             :         0x00, 0x60, 0x02, 0xF3, 0x21, 0x00, 0x00, 0x00,
    1721             :         0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
    1722             :         0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
    1723             :         0x32, 0x2E, 0x30, 0x20, 0x4F, 0x70, 0x74, 0x69,
    1724             :         0x6F, 0x6E, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E,
    1725             :         0x00, 0x10, 0x00, 0x00, 0x00, 0x45, 0x6D, 0x62,
    1726             :         0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x4F, 0x62,
    1727             :         0x6A, 0x65, 0x63, 0x74, 0x00, 0x15, 0x00, 0x00,
    1728             :         0x00, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x4F,
    1729             :         0x70, 0x74, 0x69, 0x6F, 0x6E, 0x42, 0x75, 0x74,
    1730             :         0x74, 0x6F, 0x6E, 0x2E, 0x31, 0x00, 0xF4, 0x39,
    1731             :         0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    1732             :         0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    1733             :     };
    1734           0 :     rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
    1735           0 : }
    1736             : 
    1737          10 : AxTextBoxModel::AxTextBoxModel()
    1738             : {
    1739          10 :     mnDisplayStyle = AX_DISPLAYSTYLE_TEXT;
    1740          10 : }
    1741             : 
    1742          14 : ApiControlType AxTextBoxModel::getControlType() const
    1743             : {
    1744             :     OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT, "AxTextBoxModel::getControlType - invalid control type" );
    1745          14 :     return API_CONTROL_EDIT;
    1746             : }
    1747             : 
    1748           8 : void AxTextBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
    1749             : {
    1750           8 :     rPropMap.setProperty( PROP_MultiLine, getFlag( mnFlags, AX_FLAGS_MULTILINE ) );
    1751           8 :     rPropMap.setProperty( PROP_HideInactiveSelection, getFlag( mnFlags, AX_FLAGS_HIDESELECTION ) );
    1752           8 :     rPropMap.setProperty( mbAwtModel ? PROP_Text : PROP_DefaultText, maValue );
    1753           8 :     rPropMap.setProperty( PROP_MaxTextLen, getLimitedValue< sal_Int16, sal_Int32 >( mnMaxLength, 0, SAL_MAX_INT16 ) );
    1754           8 :     if( (0 < mnPasswordChar) && (mnPasswordChar <= SAL_MAX_INT16) )
    1755           0 :         rPropMap.setProperty( PROP_EchoChar, static_cast< sal_Int16 >( mnPasswordChar ) );
    1756           8 :     rPropMap.setProperty( PROP_HScroll, getFlag( mnScrollBars, AX_SCROLLBAR_HORIZONTAL ) );
    1757           8 :     rPropMap.setProperty( PROP_VScroll, getFlag( mnScrollBars, AX_SCROLLBAR_VERTICAL ) );
    1758           8 :     rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID );
    1759           8 :     rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
    1760           8 :     AxMorphDataModelBase::convertProperties( rPropMap, rConv );
    1761           8 : }
    1762             : 
    1763           2 : void AxTextBoxModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
    1764             : {
    1765           2 :     bool bRes = false;
    1766           2 :     if ( rPropSet.getProperty( bRes,  PROP_MultiLine ) )
    1767           2 :         setFlag( mnFlags, AX_FLAGS_WORDWRAP, bRes );
    1768           2 :     if ( rPropSet.getProperty( bRes,  PROP_HideInactiveSelection ) )
    1769           2 :         setFlag( mnFlags, AX_FLAGS_HIDESELECTION, bRes );
    1770           2 :     rPropSet.getProperty( maValue, ( mbAwtModel ? PROP_Text : PROP_DefaultText ) );
    1771           2 :     if (maValue.isEmpty() && !mbAwtModel)
    1772             :         // No default value? Then try exporting the current one.
    1773           2 :         rPropSet.getProperty( maValue, PROP_Text);
    1774           2 :     sal_Int16 nTmp(0);
    1775           2 :     if ( rPropSet.getProperty( nTmp, PROP_MaxTextLen ) )
    1776           2 :         mnMaxLength = nTmp;
    1777           2 :     if ( rPropSet.getProperty( nTmp, PROP_EchoChar ) )
    1778           2 :         mnPasswordChar = nTmp;
    1779           2 :     if ( rPropSet.getProperty( bRes,  PROP_HScroll ) )
    1780           2 :         setFlag( mnScrollBars, AX_SCROLLBAR_HORIZONTAL, bRes );
    1781           2 :     if ( rPropSet.getProperty( bRes,  PROP_VScroll ) )
    1782           2 :         setFlag( mnScrollBars, AX_SCROLLBAR_VERTICAL, bRes );
    1783             : 
    1784           2 :     rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor, 0x80000005L );
    1785             : 
    1786           2 :     rConv.convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect );
    1787           2 :     AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
    1788           2 : }
    1789             : 
    1790           2 : void AxTextBoxModel::exportCompObj( BinaryOutputStream& rOutStream )
    1791             : {
    1792             :     // should be able to replace this hardcoded foo with
    1793             :     // proper export info from MS-OLEDS spec.
    1794             :     static sal_uInt8 const aCompObj[] = {
    1795             :         0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
    1796             :         0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x1D, 0xD2, 0x8B,
    1797             :         0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
    1798             :         0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
    1799             :         0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
    1800             :         0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
    1801             :         0x32, 0x2E, 0x30, 0x20, 0x54, 0x65, 0x78, 0x74,
    1802             :         0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
    1803             :         0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
    1804             :         0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
    1805             :         0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
    1806             :         0x73, 0x2E, 0x54, 0x65, 0x78, 0x74, 0x42, 0x6F,
    1807             :         0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
    1808             :         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    1809             :         0x00, 0x00, 0x00, 0x00
    1810             :     };
    1811           2 :     rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
    1812           2 : }
    1813             : 
    1814           0 : AxNumericFieldModel::AxNumericFieldModel()
    1815             : {
    1816           0 :     mnDisplayStyle = AX_DISPLAYSTYLE_TEXT;
    1817           0 : }
    1818             : 
    1819           0 : ApiControlType AxNumericFieldModel::getControlType() const
    1820             : {
    1821             :     OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_TEXT, "AxNumericFieldModel::getControlType - invalid control type" );
    1822           0 :     return API_CONTROL_NUMERIC;
    1823             : }
    1824             : 
    1825           0 : void AxNumericFieldModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
    1826             : {
    1827           0 :     rPropMap.setProperty( PROP_HideInactiveSelection, getFlag( mnFlags, AX_FLAGS_HIDESELECTION ) );
    1828             :     // TODO: OUString::toDouble() does not handle local decimal separator
    1829           0 :     rPropMap.setProperty( mbAwtModel ? PROP_Value : PROP_DefaultValue, maValue.toDouble() );
    1830           0 :     rPropMap.setProperty( PROP_Spin, getFlag( mnScrollBars, AX_SCROLLBAR_VERTICAL ) );
    1831           0 :     rPropMap.setProperty( PROP_Repeat, true );
    1832           0 :     rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID );
    1833           0 :     rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
    1834           0 :     AxMorphDataModelBase::convertProperties( rPropMap, rConv );
    1835           0 : }
    1836             : 
    1837           0 : void AxNumericFieldModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
    1838             : {
    1839           0 :     bool bRes = false;
    1840           0 :     if ( rPropSet.getProperty( bRes,  PROP_HideInactiveSelection ) )
    1841           0 :         setFlag( mnFlags, AX_FLAGS_HIDESELECTION, bRes );
    1842           0 :     rPropSet.getProperty( maValue, ( mbAwtModel ? PROP_Text : PROP_DefaultText ) );
    1843           0 :     if ( rPropSet.getProperty( bRes,  PROP_Spin ) )
    1844           0 :         setFlag( mnScrollBars, AX_SCROLLBAR_VERTICAL, bRes );
    1845             : 
    1846           0 :     rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
    1847             : 
    1848           0 :     rConv.convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect );
    1849           0 :     AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
    1850           0 : }
    1851             : 
    1852           0 : void AxNumericFieldModel::exportCompObj( BinaryOutputStream& rOutStream )
    1853             : {
    1854             :     // should be able to replace this hardcoded foo with
    1855             :     // proper export info from MS-OLEDS spec.
    1856             :     static sal_uInt8 const aCompObj[] = {
    1857             :         0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
    1858             :         0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x1D, 0xD2, 0x8B,
    1859             :         0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
    1860             :         0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
    1861             :         0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
    1862             :         0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
    1863             :         0x32, 0x2E, 0x30, 0x20, 0x54, 0x65, 0x78, 0x74,
    1864             :         0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
    1865             :         0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
    1866             :         0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
    1867             :         0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
    1868             :         0x73, 0x2E, 0x54, 0x65, 0x78, 0x74, 0x42, 0x6F,
    1869             :         0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
    1870             :         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    1871             :         0x00, 0x00, 0x00, 0x00
    1872             :     };
    1873           0 :     rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
    1874           0 : }
    1875             : 
    1876           4 : AxListBoxModel::AxListBoxModel()
    1877             : {
    1878           4 :     mnDisplayStyle = AX_DISPLAYSTYLE_LISTBOX;
    1879           4 : }
    1880             : 
    1881          10 : ApiControlType AxListBoxModel::getControlType() const
    1882             : {
    1883             :     OSL_ENSURE( mnDisplayStyle == AX_DISPLAYSTYLE_LISTBOX, "AxListBoxModel::getControlType - invalid control type" );
    1884          10 :     return API_CONTROL_LISTBOX;
    1885             : }
    1886             : 
    1887           4 : void AxListBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
    1888             : {
    1889           4 :     bool bMultiSelect = (mnMultiSelect == AX_SELECTION_MULTI) || (mnMultiSelect == AX_SELECTION_EXTENDED);
    1890           4 :     rPropMap.setProperty( PROP_MultiSelection, bMultiSelect );
    1891           4 :     rPropMap.setProperty( PROP_Dropdown, false );
    1892           4 :     rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID );
    1893           4 :     rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
    1894           4 :     AxMorphDataModelBase::convertProperties( rPropMap, rConv );
    1895           4 : }
    1896             : 
    1897           0 : void AxListBoxModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
    1898             : {
    1899           0 :     bool bRes = false;
    1900           0 :     if ( rPropSet.getProperty( bRes, PROP_MultiSelection ) )
    1901             : 
    1902           0 :         rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
    1903             : 
    1904           0 :     rConv.convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect );
    1905           0 :     AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
    1906           0 : }
    1907             : 
    1908           0 : void AxListBoxModel::exportCompObj( BinaryOutputStream& rOutStream )
    1909             : {
    1910             :     // should be able to replace this hardcoded foo with
    1911             :     // proper export info from MS-OLEDS spec.
    1912             :     static sal_uInt8 const aCompObj[] = {
    1913             :         0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
    1914             :         0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0x1D, 0xD2, 0x8B,
    1915             :         0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
    1916             :         0x00, 0x60, 0x02, 0xF3, 0x1C, 0x00, 0x00, 0x00,
    1917             :         0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
    1918             :         0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
    1919             :         0x32, 0x2E, 0x30, 0x20, 0x4C, 0x69, 0x73, 0x74,
    1920             :         0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00, 0x00,
    1921             :         0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64,
    1922             :         0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x00,
    1923             :         0x10, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72, 0x6D,
    1924             :         0x73, 0x2E, 0x4C, 0x69, 0x73, 0x74, 0x42, 0x6F,
    1925             :         0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71,
    1926             :         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    1927             :         0x00, 0x00, 0x00, 0x00
    1928             :     };
    1929           0 :     rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
    1930           0 : }
    1931             : 
    1932           4 : AxComboBoxModel::AxComboBoxModel()
    1933             : {
    1934           4 :     mnDisplayStyle = AX_DISPLAYSTYLE_COMBOBOX;
    1935           4 :     mnFlags = 0x2c80481b;
    1936           4 : }
    1937             : 
    1938          10 : ApiControlType AxComboBoxModel::getControlType() const
    1939             : {
    1940             :     OSL_ENSURE( (mnDisplayStyle == AX_DISPLAYSTYLE_COMBOBOX) || (mnDisplayStyle == AX_DISPLAYSTYLE_DROPDOWN), "AxComboBoxModel::getControlType - invalid control type" );
    1941          10 :     return (mnDisplayStyle == AX_DISPLAYSTYLE_DROPDOWN) ? API_CONTROL_LISTBOX : API_CONTROL_COMBOBOX;
    1942             : }
    1943             : 
    1944           4 : void AxComboBoxModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
    1945             : {
    1946           4 :     if( mnDisplayStyle != AX_DISPLAYSTYLE_DROPDOWN )
    1947             :     {
    1948           4 :         rPropMap.setProperty( PROP_HideInactiveSelection, getFlag( mnFlags, AX_FLAGS_HIDESELECTION ) );
    1949           4 :         rPropMap.setProperty( mbAwtModel ? PROP_Text : PROP_DefaultText, maValue );
    1950           4 :         rPropMap.setProperty( PROP_MaxTextLen, getLimitedValue< sal_Int16, sal_Int32 >( mnMaxLength, 0, SAL_MAX_INT16 ) );
    1951           4 :         bool bAutoComplete = (mnMatchEntry == AX_MATCHENTRY_FIRSTLETTER) || (mnMatchEntry == AX_MATCHENTRY_COMPLETE);
    1952           4 :         rPropMap.setProperty( PROP_Autocomplete, bAutoComplete );
    1953             :     }
    1954           4 :     bool bShowDropdown = (mnShowDropButton == AX_SHOWDROPBUTTON_FOCUS) || (mnShowDropButton == AX_SHOWDROPBUTTON_ALWAYS);
    1955           4 :     rPropMap.setProperty( PROP_Dropdown, bShowDropdown );
    1956           4 :     rPropMap.setProperty( PROP_LineCount, getLimitedValue< sal_Int16, sal_Int32 >( mnListRows, 1, SAL_MAX_INT16 ) );
    1957           4 :     rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID );
    1958           4 :     rConv.convertAxBorder( rPropMap, mnBorderColor, mnBorderStyle, mnSpecialEffect );
    1959           4 :     AxMorphDataModelBase::convertProperties( rPropMap, rConv );
    1960           4 : }
    1961             : 
    1962           0 : void AxComboBoxModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
    1963             : {
    1964             :     // when would we have mnDisplayStyle = AX_DISPLAYSTYLE_DROPDOWN ?
    1965             :     // #TODO check against msocximex
    1966           0 :     mnDisplayStyle = AX_DISPLAYSTYLE_COMBOBOX;
    1967           0 :     bool bRes = false;
    1968             : 
    1969           0 :     if ( rPropSet.getProperty( bRes, PROP_HideInactiveSelection ) )
    1970           0 :         setFlag( mnFlags, AX_FLAGS_HIDESELECTION, bRes );
    1971           0 :     rPropSet.getProperty( maValue, ( mbAwtModel ? PROP_Text : PROP_DefaultText ) );
    1972             : 
    1973           0 :     sal_Int16 nTmp(0);
    1974           0 :     if ( rPropSet.getProperty( nTmp, PROP_MaxTextLen ) )
    1975           0 :         mnMaxLength = nTmp;
    1976           0 :     if ( rPropSet.getProperty( bRes, PROP_Autocomplete ) )
    1977             :     {
    1978             :         // when to choose AX_MATCHENTRY_FIRSTLETTER ?
    1979             :         // #TODO check against msocximex
    1980           0 :         if ( bRes )
    1981           0 :             mnMatchEntry = AX_MATCHENTRY_COMPLETE;
    1982             :     }
    1983           0 :     if ( rPropSet.getProperty( bRes, PROP_Dropdown ) )
    1984             :     {
    1985           0 :         rPropSet.getProperty( mnListRows, PROP_LineCount );
    1986           0 :         if ( !mnListRows )
    1987           0 :             mnListRows = 1;
    1988             :     }
    1989           0 :     rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
    1990             : 
    1991           0 :     rConv.convertToAxBorder( rPropSet, mnBorderColor, mnBorderStyle, mnSpecialEffect );
    1992           0 :     AxMorphDataModelBase::convertFromProperties( rPropSet, rConv );
    1993           0 : }
    1994             : 
    1995           0 : void AxComboBoxModel::exportCompObj( BinaryOutputStream& rOutStream )
    1996             : {
    1997             :     // should be able to replace this hardcoded foo with
    1998             :     // proper export info from MS-OLEDS spec.
    1999             :     static sal_uInt8 const aCompObj[] = {
    2000             :         0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
    2001             :         0xFF, 0xFF, 0xFF, 0xFF, 0x30, 0x1D, 0xD2, 0x8B,
    2002             :         0x42, 0xEC, 0xCE, 0x11, 0x9E, 0x0D, 0x00, 0xAA,
    2003             :         0x00, 0x60, 0x02, 0xF3, 0x1D, 0x00, 0x00, 0x00,
    2004             :         0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
    2005             :         0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
    2006             :         0x32, 0x2E, 0x30, 0x20, 0x43, 0x6F, 0x6D, 0x62,
    2007             :         0x6F, 0x42, 0x6F, 0x78, 0x00, 0x10, 0x00, 0x00,
    2008             :         0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64, 0x65,
    2009             :         0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74,
    2010             :         0x00, 0x11, 0x00, 0x00, 0x00, 0x46, 0x6F, 0x72,
    2011             :         0x6D, 0x73, 0x2E, 0x43, 0x6F, 0x6D, 0x62, 0x6F,
    2012             :         0x42, 0x6F, 0x78, 0x2E, 0x31, 0x00, 0xF4, 0x39,
    2013             :         0xB2, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    2014             :         0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    2015             :     };
    2016           0 :     rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
    2017           0 : }
    2018             : 
    2019           0 : AxSpinButtonModel::AxSpinButtonModel() :
    2020             :     mnArrowColor( AX_SYSCOLOR_BUTTONTEXT ),
    2021             :     mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
    2022             :     mnFlags( AX_SPINBUTTON_DEFFLAGS ),
    2023             :     mnOrientation( AX_ORIENTATION_AUTO ),
    2024             :     mnMin( 0 ),
    2025             :     mnMax( 100 ),
    2026             :     mnPosition( 0 ),
    2027             :     mnSmallChange( 1 ),
    2028           0 :     mnDelay( 50 )
    2029             : {
    2030           0 : }
    2031             : 
    2032           0 : ApiControlType AxSpinButtonModel::getControlType() const
    2033             : {
    2034           0 :     return API_CONTROL_SPINBUTTON;
    2035             : }
    2036             : 
    2037           0 : void AxSpinButtonModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
    2038             : {
    2039           0 :     switch( nPropId )
    2040             :     {
    2041           0 :         case XML_ForeColor:             mnArrowColor = AttributeConversion::decodeUnsigned( rValue );   break;
    2042           0 :         case XML_BackColor:             mnBackColor = AttributeConversion::decodeUnsigned( rValue );    break;
    2043           0 :         case XML_VariousPropertyBits:   mnFlags = AttributeConversion::decodeUnsigned( rValue );        break;
    2044           0 :         case XML_Orientation:           mnOrientation = AttributeConversion::decodeInteger( rValue );   break;
    2045           0 :         case XML_Min:                   mnMin = AttributeConversion::decodeInteger( rValue );           break;
    2046           0 :         case XML_Max:                   mnMax = AttributeConversion::decodeInteger( rValue );           break;
    2047           0 :         case XML_Position:              mnPosition = AttributeConversion::decodeInteger( rValue );      break;
    2048           0 :         case XML_SmallChange:           mnSmallChange = AttributeConversion::decodeInteger( rValue );   break;
    2049           0 :         case XML_Delay:                 mnDelay = AttributeConversion::decodeInteger( rValue );         break;
    2050           0 :         default:                        AxControlModelBase::importProperty( nPropId, rValue );
    2051             :     }
    2052           0 : }
    2053             : 
    2054           0 : bool AxSpinButtonModel::importBinaryModel( BinaryInputStream& rInStrm )
    2055             : {
    2056           0 :     AxBinaryPropertyReader aReader( rInStrm );
    2057           0 :     aReader.readIntProperty< sal_uInt32 >( mnArrowColor );
    2058           0 :     aReader.readIntProperty< sal_uInt32 >( mnBackColor );
    2059           0 :     aReader.readIntProperty< sal_uInt32 >( mnFlags );
    2060           0 :     aReader.readPairProperty( maSize );
    2061           0 :     aReader.skipIntProperty< sal_uInt32 >(); // unused
    2062           0 :     aReader.readIntProperty< sal_Int32 >( mnMin );
    2063           0 :     aReader.readIntProperty< sal_Int32 >( mnMax );
    2064           0 :     aReader.readIntProperty< sal_Int32 >( mnPosition );
    2065           0 :     aReader.skipIntProperty< sal_uInt32 >(); // prev enabled
    2066           0 :     aReader.skipIntProperty< sal_uInt32 >(); // next enabled
    2067           0 :     aReader.readIntProperty< sal_Int32 >( mnSmallChange );
    2068           0 :     aReader.readIntProperty< sal_Int32 >( mnOrientation );
    2069           0 :     aReader.readIntProperty< sal_Int32 >( mnDelay );
    2070           0 :     aReader.skipPictureProperty(); // mouse icon
    2071           0 :     aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
    2072           0 :     return aReader.finalizeImport();
    2073             : }
    2074             : 
    2075           0 : void AxSpinButtonModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
    2076             : {
    2077           0 :     AxBinaryPropertyWriter aWriter( rOutStrm );
    2078           0 :     aWriter.writeIntProperty< sal_uInt32 >( mnArrowColor );
    2079           0 :     if ( mnBackColor )
    2080           0 :         aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
    2081             :     else
    2082           0 :         aWriter.skipProperty(); // default backcolour
    2083           0 :     aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
    2084           0 :     aWriter.writePairProperty( maSize );
    2085           0 :     aWriter.skipProperty(); // unused
    2086           0 :     aWriter.writeIntProperty< sal_Int32 >( mnMin );
    2087           0 :     aWriter.writeIntProperty< sal_Int32 >( mnMax );
    2088           0 :     aWriter.writeIntProperty< sal_Int32 >( mnPosition );
    2089           0 :     aWriter.skipProperty(); // prev enabled
    2090           0 :     aWriter.skipProperty(); // next enabled
    2091           0 :     aWriter.writeIntProperty< sal_Int32 >( mnSmallChange );
    2092           0 :     aWriter.writeIntProperty< sal_Int32 >( mnOrientation );
    2093           0 :     aWriter.writeIntProperty< sal_Int32 >( mnDelay );
    2094           0 :     aWriter.skipProperty(); // mouse icon
    2095           0 :     aWriter.skipProperty(); // mouse pointer
    2096             : 
    2097           0 :     aWriter.finalizeExport();
    2098           0 : }
    2099             : 
    2100           0 : void AxSpinButtonModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
    2101             : {
    2102           0 :     sal_Int32 nMin = ::std::min( mnMin, mnMax );
    2103           0 :     sal_Int32 nMax = ::std::max( mnMin, mnMax );
    2104           0 :     rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
    2105           0 :     rPropMap.setProperty( PROP_SpinValueMin, nMin );
    2106           0 :     rPropMap.setProperty( PROP_SpinValueMax, nMax );
    2107           0 :     rPropMap.setProperty( PROP_SpinIncrement, mnSmallChange );
    2108           0 :     rPropMap.setProperty( mbAwtModel ? PROP_SpinValue : PROP_DefaultSpinValue, mnPosition );
    2109           0 :     rPropMap.setProperty( PROP_Repeat, true );
    2110           0 :     rPropMap.setProperty( PROP_RepeatDelay, mnDelay );
    2111           0 :     rPropMap.setProperty( PROP_Border, API_BORDER_NONE );
    2112           0 :     rConv.convertColor( rPropMap, PROP_SymbolColor, mnArrowColor );
    2113           0 :     rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED );
    2114           0 :     rConv.convertAxOrientation( rPropMap, maSize, mnOrientation );
    2115           0 :     AxControlModelBase::convertProperties( rPropMap, rConv );
    2116           0 : }
    2117             : 
    2118           0 : void AxSpinButtonModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
    2119             : {
    2120           0 :     bool bRes = false;
    2121           0 :     if ( rPropSet.getProperty( bRes,  PROP_Enabled ) )
    2122           0 :         setFlag( mnFlags, AX_FLAGS_ENABLED, bRes );
    2123           0 :     rPropSet.getProperty( mnMin, PROP_SpinValueMin );
    2124           0 :     rPropSet.getProperty( mnMax, PROP_SpinValueMax );
    2125           0 :     rPropSet.getProperty( mnSmallChange, PROP_SpinIncrement );
    2126           0 :     rPropSet.getProperty( mnPosition, ( mbAwtModel ? PROP_SpinValue : PROP_DefaultSpinValue ) );
    2127           0 :     rPropSet.getProperty( mnDelay, PROP_RepeatDelay );
    2128           0 :     rConv.convertToMSColor( rPropSet, PROP_SymbolColor, mnArrowColor);
    2129           0 :     rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
    2130             : 
    2131           0 :     rConv.convertToAxOrientation( rPropSet, maSize, mnOrientation );
    2132           0 : }
    2133             : 
    2134           0 : void AxSpinButtonModel::exportCompObj( BinaryOutputStream& rOutStream )
    2135             : {
    2136             :     // should be able to replace this hardcoded foo with
    2137             :     // proper export info from MS-OLEDS spec.
    2138             :     static sal_uInt8 const aCompObj[] =
    2139             :     {
    2140             :         0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
    2141             :         0xFF, 0xFF, 0xFF, 0xFF, 0xB0, 0x6F, 0x17, 0x79,
    2142             :         0xF2, 0xB7, 0xCE, 0x11, 0x97, 0xEF, 0x00, 0xAA,
    2143             :         0x00, 0x6D, 0x27, 0x76, 0x1F, 0x00, 0x00, 0x00,
    2144             :         0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
    2145             :         0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
    2146             :         0x32, 0x2E, 0x30, 0x20, 0x53, 0x70, 0x69, 0x6E,
    2147             :         0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x00, 0x10,
    2148             :         0x00, 0x00, 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64,
    2149             :         0x64, 0x65, 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65,
    2150             :         0x63, 0x74, 0x00, 0x13, 0x00, 0x00, 0x00, 0x46,
    2151             :         0x6F, 0x72, 0x6D, 0x73, 0x2E, 0x53, 0x70, 0x69,
    2152             :         0x6E, 0x42, 0x75, 0x74, 0x74, 0x6F, 0x6E, 0x2E,
    2153             :         0x31, 0x00, 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00,
    2154             :         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    2155             :         0x00, 0x00
    2156             :     };
    2157             : 
    2158           0 :     rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
    2159           0 : }
    2160             : 
    2161           0 : AxScrollBarModel::AxScrollBarModel() :
    2162             :     mnArrowColor( AX_SYSCOLOR_BUTTONTEXT ),
    2163             :     mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
    2164             :     mnFlags( AX_SCROLLBAR_DEFFLAGS ),
    2165             :     mnOrientation( AX_ORIENTATION_AUTO ),
    2166             :     mnPropThumb( AX_PROPTHUMB_ON ),
    2167             :     mnMin( 0 ),
    2168             :     mnMax( 32767 ),
    2169             :     mnPosition( 0 ),
    2170             :     mnSmallChange( 1 ),
    2171             :     mnLargeChange( 1 ),
    2172           0 :     mnDelay( 50 )
    2173             : {
    2174           0 : }
    2175             : 
    2176           0 : ApiControlType AxScrollBarModel::getControlType() const
    2177             : {
    2178           0 :     return API_CONTROL_SCROLLBAR;
    2179             : }
    2180             : 
    2181           0 : void AxScrollBarModel::importProperty( sal_Int32 nPropId, const OUString& rValue )
    2182             : {
    2183           0 :     switch( nPropId )
    2184             :     {
    2185           0 :         case XML_ForeColor:             mnArrowColor = AttributeConversion::decodeUnsigned( rValue );   break;
    2186           0 :         case XML_BackColor:             mnBackColor = AttributeConversion::decodeUnsigned( rValue );    break;
    2187           0 :         case XML_VariousPropertyBits:   mnFlags = AttributeConversion::decodeUnsigned( rValue );        break;
    2188           0 :         case XML_Orientation:           mnOrientation = AttributeConversion::decodeInteger( rValue );   break;
    2189           0 :         case XML_ProportionalThumb:     mnPropThumb = AttributeConversion::decodeInteger( rValue );     break;
    2190           0 :         case XML_Min:                   mnMin = AttributeConversion::decodeInteger( rValue );           break;
    2191           0 :         case XML_Max:                   mnMax = AttributeConversion::decodeInteger( rValue );           break;
    2192           0 :         case XML_Position:              mnPosition = AttributeConversion::decodeInteger( rValue );      break;
    2193           0 :         case XML_SmallChange:           mnSmallChange = AttributeConversion::decodeInteger( rValue );   break;
    2194           0 :         case XML_LargeChange:           mnLargeChange = AttributeConversion::decodeInteger( rValue );   break;
    2195           0 :         case XML_Delay:                 mnDelay = AttributeConversion::decodeInteger( rValue );         break;
    2196           0 :         default:                        AxControlModelBase::importProperty( nPropId, rValue );
    2197             :     }
    2198           0 : }
    2199             : 
    2200           0 : bool AxScrollBarModel::importBinaryModel( BinaryInputStream& rInStrm )
    2201             : {
    2202           0 :     AxBinaryPropertyReader aReader( rInStrm );
    2203           0 :     aReader.readIntProperty< sal_uInt32 >( mnArrowColor );
    2204           0 :     aReader.readIntProperty< sal_uInt32 >( mnBackColor );
    2205           0 :     aReader.readIntProperty< sal_uInt32 >( mnFlags );
    2206           0 :     aReader.readPairProperty( maSize );
    2207           0 :     aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
    2208           0 :     aReader.readIntProperty< sal_Int32 >( mnMin );
    2209           0 :     aReader.readIntProperty< sal_Int32 >( mnMax );
    2210           0 :     aReader.readIntProperty< sal_Int32 >( mnPosition );
    2211           0 :     aReader.skipIntProperty< sal_uInt32 >(); // unused
    2212           0 :     aReader.skipIntProperty< sal_uInt32 >(); // prev enabled
    2213           0 :     aReader.skipIntProperty< sal_uInt32 >(); // next enabled
    2214           0 :     aReader.readIntProperty< sal_Int32 >( mnSmallChange );
    2215           0 :     aReader.readIntProperty< sal_Int32 >( mnLargeChange );
    2216           0 :     aReader.readIntProperty< sal_Int32 >( mnOrientation );
    2217           0 :     aReader.readIntProperty< sal_Int16 >( mnPropThumb );
    2218           0 :     aReader.readIntProperty< sal_Int32 >( mnDelay );
    2219           0 :     aReader.skipPictureProperty(); // mouse icon
    2220           0 :     return aReader.finalizeImport();
    2221             : }
    2222             : 
    2223           0 : void AxScrollBarModel::exportBinaryModel( BinaryOutputStream& rOutStrm )
    2224             : {
    2225           0 :     AxBinaryPropertyWriter aWriter( rOutStrm );
    2226           0 :     aWriter.writeIntProperty< sal_uInt32 >( mnArrowColor );
    2227           0 :     if ( mnBackColor )
    2228           0 :         aWriter.writeIntProperty< sal_uInt32 >( mnBackColor );
    2229             :     else
    2230           0 :         aWriter.skipProperty(); // default backcolour
    2231           0 :     aWriter.writeIntProperty< sal_uInt32 >( mnFlags );
    2232           0 :     aWriter.writePairProperty( maSize );
    2233           0 :     aWriter.skipProperty(); // mouse pointer
    2234           0 :     aWriter.writeIntProperty< sal_Int32 >( mnMin );
    2235           0 :     aWriter.writeIntProperty< sal_Int32 >( mnMax );
    2236           0 :     aWriter.writeIntProperty< sal_Int32 >( mnPosition );
    2237           0 :     aWriter.skipProperty(); // unused
    2238           0 :     aWriter.skipProperty(); // prev enabled
    2239           0 :     aWriter.skipProperty(); // next enabled
    2240           0 :     aWriter.writeIntProperty< sal_Int32 >( mnSmallChange );
    2241           0 :     aWriter.writeIntProperty< sal_Int32 >( mnLargeChange );
    2242           0 :     aWriter.writeIntProperty< sal_Int32 >( mnOrientation );
    2243           0 :     aWriter.writeIntProperty< sal_Int16 >( mnPropThumb );
    2244           0 :     aWriter.writeIntProperty< sal_Int32 >( mnDelay );
    2245           0 :     aWriter.skipProperty(); // mouse icon
    2246           0 :     aWriter.finalizeExport();
    2247           0 : }
    2248             : 
    2249           0 : void AxScrollBarModel::exportCompObj( BinaryOutputStream& rOutStream )
    2250             : {
    2251             :     // should be able to replace this hardcoded foo with
    2252             :     // proper export info from MS-OLEDS spec.
    2253             :     static sal_uInt8 const aCompObj[] =
    2254             :     {
    2255             :         0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
    2256             :         0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0x81, 0xD1, 0xDF,
    2257             :         0x2F, 0x5E, 0xCE, 0x11, 0xA4, 0x49, 0x00, 0xAA,
    2258             :         0x00, 0x4A, 0x80, 0x3D, 0x1E, 0x00, 0x00, 0x00,
    2259             :         0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
    2260             :         0x74, 0x20, 0x46, 0x6F, 0x72, 0x6D, 0x73, 0x20,
    2261             :         0x32, 0x2E, 0x30, 0x20, 0x53, 0x63, 0x72, 0x6F,
    2262             :         0x6C, 0x6C, 0x42, 0x61, 0x72, 0x00, 0x10, 0x00,
    2263             :         0x00, 0x00, 0x45, 0x6D, 0x62, 0x65, 0x64, 0x64,
    2264             :         0x65, 0x64, 0x20, 0x4F, 0x62, 0x6A, 0x65, 0x63,
    2265             :         0x74, 0x00, 0x12, 0x00, 0x00, 0x00, 0x46, 0x6F,
    2266             :         0x72, 0x6D, 0x73, 0x2E, 0x53, 0x63, 0x72, 0x6F,
    2267             :         0x6C, 0x6C, 0x42, 0x61, 0x72, 0x2E, 0x31, 0x00,
    2268             :         0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00, 0x00, 0x00,
    2269             :         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
    2270             :     };
    2271           0 :     rOutStream.writeMemory( aCompObj, sizeof( aCompObj ) );
    2272           0 : }
    2273             : 
    2274           0 : void AxScrollBarModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
    2275             : {
    2276           0 :     rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_FLAGS_ENABLED ) );
    2277           0 :     rPropMap.setProperty( PROP_RepeatDelay, mnDelay );
    2278           0 :     rPropMap.setProperty( PROP_Border, API_BORDER_NONE );
    2279           0 :     if( (mnPropThumb == AX_PROPTHUMB_ON) && (mnMin != mnMax) && (mnLargeChange > 0) )
    2280             :     {
    2281             :         // use double to prevent integer overflow in division (fInterval+mnLargeChange may become 0 when performed as int)
    2282           0 :         double fInterval = fabs( static_cast< double >( mnMax - mnMin ) );
    2283           0 :         sal_Int32 nThumbLen = getLimitedValue< sal_Int32, double >( (fInterval * mnLargeChange) / (fInterval + mnLargeChange), 1, SAL_MAX_INT32 );
    2284           0 :         rPropMap.setProperty( PROP_VisibleSize, nThumbLen );
    2285             :     }
    2286           0 :     rConv.convertColor( rPropMap, PROP_SymbolColor, mnArrowColor );
    2287           0 :     rConv.convertAxBackground( rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED );
    2288           0 :     rConv.convertAxOrientation( rPropMap, maSize, mnOrientation );
    2289           0 :     rConv.convertScrollBar( rPropMap, mnMin, mnMax, mnPosition, mnSmallChange, mnLargeChange, mbAwtModel );
    2290           0 :     AxControlModelBase::convertProperties( rPropMap, rConv );
    2291           0 : }
    2292             : 
    2293           0 : void AxScrollBarModel::convertFromProperties( PropertySet& rPropSet, const ControlConverter& rConv )
    2294             : {
    2295           0 :     bool bRes = false;
    2296           0 :     if ( rPropSet.getProperty( bRes,  PROP_Enabled ) )
    2297           0 :         setFlag( mnFlags, AX_FLAGS_ENABLED, bRes );
    2298           0 :     rPropSet.getProperty( mnDelay, PROP_RepeatDelay );
    2299           0 :     mnPropThumb = AX_PROPTHUMB_ON; // default
    2300           0 :     rConv.convertToMSColor( rPropSet, PROP_SymbolColor, mnArrowColor);
    2301           0 :     rConv.convertToMSColor( rPropSet, PROP_BackgroundColor, mnBackColor );
    2302           0 :     rConv.convertToAxOrientation( rPropSet, maSize, mnOrientation );
    2303             : 
    2304           0 :     rPropSet.getProperty( mnMin, PROP_ScrollValueMin );
    2305           0 :     rPropSet.getProperty( mnMax, PROP_ScrollValueMax );
    2306           0 :     rPropSet.getProperty( mnSmallChange, PROP_LineIncrement );
    2307           0 :     rPropSet.getProperty( mnLargeChange, PROP_BlockIncrement );
    2308           0 :     rPropSet.getProperty( mnPosition, ( mbAwtModel ? PROP_ScrollValue : PROP_DefaultScrollValue ) );
    2309             : 
    2310           0 : }
    2311             : 
    2312           4 : AxContainerModelBase::AxContainerModelBase( bool bFontSupport ) :
    2313             :     AxFontDataModel( false ),   // no support for alignment properties
    2314             :     maLogicalSize( AX_CONTAINER_DEFWIDTH, AX_CONTAINER_DEFHEIGHT ),
    2315             :     maScrollPos( 0, 0 ),
    2316             :     mnBackColor( AX_SYSCOLOR_BUTTONFACE ),
    2317             :     mnTextColor( AX_SYSCOLOR_BUTTONTEXT ),
    2318             :     mnFlags( AX_CONTAINER_DEFFLAGS ),
    2319             :     mnBorderColor( AX_SYSCOLOR_BUTTONTEXT ),
    2320             :     mnBorderStyle( AX_BORDERSTYLE_NONE ),
    2321             :     mnScrollBars( AX_CONTAINER_SCR_NONE ),
    2322             :     mnCycleType( AX_CONTAINER_CYCLEALL ),
    2323             :     mnSpecialEffect( AX_SPECIALEFFECT_FLAT ),
    2324             :     mnPicAlign( AX_PICALIGN_CENTER ),
    2325             :     mnPicSizeMode( AX_PICSIZE_CLIP ),
    2326             :     mbPicTiling( false ),
    2327           4 :     mbFontSupport( bFontSupport )
    2328             : {
    2329           4 :     setAwtModelMode();
    2330             :     // different default size for frame
    2331           4 :     maSize = AxPairData( AX_CONTAINER_DEFWIDTH, AX_CONTAINER_DEFHEIGHT );
    2332           4 : }
    2333             : 
    2334           4 : void AxContainerModelBase::importProperty( sal_Int32 nPropId, const OUString& rValue )
    2335             : {
    2336           4 :     if( nPropId == XML_Caption )
    2337           4 :         maCaption = rValue;
    2338           4 : }
    2339             : 
    2340           4 : bool AxContainerModelBase::importBinaryModel( BinaryInputStream& rInStrm )
    2341             : {
    2342           4 :     AxBinaryPropertyReader aReader( rInStrm );
    2343           4 :     aReader.skipUndefinedProperty();
    2344           4 :     aReader.readIntProperty< sal_uInt32 >( mnBackColor );
    2345           4 :     aReader.readIntProperty< sal_uInt32 >( mnTextColor );
    2346           4 :     aReader.skipIntProperty< sal_uInt32 >(); // next availbale control ID
    2347           4 :     aReader.skipUndefinedProperty();
    2348           4 :     aReader.skipUndefinedProperty();
    2349           4 :     aReader.readIntProperty< sal_uInt32 >( mnFlags );
    2350           4 :     aReader.readIntProperty< sal_uInt8 >( mnBorderStyle );
    2351           4 :     aReader.skipIntProperty< sal_uInt8 >(); // mouse pointer
    2352           4 :     aReader.readIntProperty< sal_uInt8 >( mnScrollBars );
    2353           4 :     aReader.readPairProperty( maSize );
    2354           4 :     aReader.readPairProperty( maLogicalSize );
    2355           4 :     aReader.readPairProperty( maScrollPos );
    2356           4 :     aReader.skipIntProperty< sal_uInt32 >(); // number of control groups
    2357           4 :     aReader.skipUndefinedProperty();
    2358           4 :     aReader.skipPictureProperty(); // mouse icon
    2359           4 :     aReader.readIntProperty< sal_uInt8 >( mnCycleType );
    2360           4 :     aReader.readIntProperty< sal_uInt8 >( mnSpecialEffect );
    2361           4 :     aReader.readIntProperty< sal_uInt32 >( mnBorderColor );
    2362           4 :     aReader.readStringProperty( maCaption );
    2363           4 :     aReader.readFontProperty( maFontData );
    2364           4 :     aReader.readPictureProperty( maPictureData );
    2365           4 :     aReader.skipIntProperty< sal_Int32 >(); // zoom
    2366           4 :     aReader.readIntProperty< sal_uInt8 >( mnPicAlign );
    2367           4 :     aReader.readBoolProperty( mbPicTiling );
    2368           4 :     aReader.readIntProperty< sal_uInt8 >( mnPicSizeMode );
    2369           4 :     aReader.skipIntProperty< sal_uInt32 >(); // shape cookie
    2370           4 :     aReader.skipIntProperty< sal_uInt32 >(); // draw buffer size
    2371           4 :     return aReader.finalizeImport();
    2372             : }
    2373             : 
    2374           4 : void AxContainerModelBase::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
    2375             : {
    2376           4 :     if( mbFontSupport )
    2377             :     {
    2378           0 :         rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor );
    2379           0 :         AxFontDataModel::convertProperties( rPropMap, rConv );
    2380             :     }
    2381           4 : }
    2382             : 
    2383           4 : bool AxContainerModelBase::importClassTable( BinaryInputStream& rInStrm, AxClassTable& orClassTable )
    2384             : {
    2385           4 :     bool bValid = true;
    2386           4 :     orClassTable.clear();
    2387           4 :     if( !getFlag( mnFlags, AX_CONTAINER_NOCLASSTABLE ) )
    2388             :     {
    2389           4 :         sal_uInt16 nCount = rInStrm.readuInt16();
    2390           4 :         for( sal_uInt16 nIndex = 0; bValid && (nIndex < nCount); ++nIndex )
    2391             :         {
    2392           0 :             orClassTable.push_back( OUString() );
    2393           0 :             AxBinaryPropertyReader aReader( rInStrm );
    2394           0 :             aReader.readGuidProperty( orClassTable.back() );
    2395           0 :             aReader.skipGuidProperty(); // source interface GUID
    2396           0 :             aReader.skipUndefinedProperty();
    2397           0 :             aReader.skipGuidProperty(); // default interface GUID
    2398           0 :             aReader.skipIntProperty< sal_uInt32 >(); // class table and var flags
    2399           0 :             aReader.skipIntProperty< sal_uInt32 >(); // method count
    2400           0 :             aReader.skipIntProperty< sal_Int32 >(); // IDispatch identifier for linked cell access
    2401           0 :             aReader.skipIntProperty< sal_uInt16 >(); // get function index for linked cell access
    2402           0 :             aReader.skipIntProperty< sal_uInt16 >(); // put function index for linked cell access
    2403           0 :             aReader.skipIntProperty< sal_uInt16 >(); // linked cell access property type
    2404           0 :             aReader.skipIntProperty< sal_uInt16 >(); // get function index of value
    2405           0 :             aReader.skipIntProperty< sal_uInt16 >(); // put function index of value
    2406           0 :             aReader.skipIntProperty< sal_uInt16 >(); // value type
    2407           0 :             aReader.skipIntProperty< sal_Int32 >(); // IDispatch identifier for source range access
    2408           0 :             aReader.skipIntProperty< sal_uInt16 >(); // get function index for source range access
    2409           0 :             bValid = aReader.finalizeImport();
    2410           0 :         }
    2411             :     }
    2412           4 :     return bValid;
    2413             : }
    2414             : 
    2415           0 : AxFrameModel::AxFrameModel() :
    2416           0 :     AxContainerModelBase( true )
    2417             : {
    2418           0 : }
    2419             : 
    2420           0 : ApiControlType AxFrameModel::getControlType() const
    2421             : {
    2422           0 :     return mbAwtModel ? API_CONTROL_FRAME : API_CONTROL_GROUPBOX;
    2423             : }
    2424             : 
    2425           0 : void AxFrameModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
    2426             : {
    2427           0 :     rPropMap.setProperty( PROP_Label, maCaption );
    2428           0 :     rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_CONTAINER_ENABLED ) );
    2429           0 :     AxContainerModelBase::convertProperties( rPropMap, rConv );
    2430           0 : }
    2431             : 
    2432           0 : AxPageModel::AxPageModel()
    2433             : {
    2434           0 : }
    2435             : 
    2436           0 : ApiControlType AxPageModel::getControlType() const
    2437             : {
    2438           0 :     return API_CONTROL_PAGE;
    2439             : }
    2440             : 
    2441           0 : void AxPageModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
    2442             : {
    2443           0 :     rPropMap.setProperty( PROP_Title, maCaption );
    2444           0 :     rConv.convertColor( rPropMap, PROP_BackgroundColor, mnBackColor );
    2445           0 :     rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_CONTAINER_ENABLED ) );
    2446           0 :     AxContainerModelBase::convertProperties( rPropMap, rConv );
    2447           0 : }
    2448             : 
    2449           0 : AxMultiPageModel::AxMultiPageModel() :
    2450             :     mnActiveTab( 0 ),
    2451           0 :     mnTabStyle( AX_TABSTRIP_TABS )
    2452             : {
    2453           0 : }
    2454             : 
    2455           0 : ApiControlType AxMultiPageModel::getControlType() const
    2456             : {
    2457           0 :     return API_CONTROL_MULTIPAGE;
    2458             : }
    2459             : 
    2460           0 : bool AxMultiPageModel::importPageAndMultiPageProperties( BinaryInputStream& rInStrm, sal_Int32 nPages )
    2461             : {
    2462             :     // PageProperties
    2463           0 :     for ( sal_Int32 nPage = 0; nPage < nPages; ++nPage )
    2464             :     {
    2465           0 :         AxBinaryPropertyReader aReader( rInStrm );
    2466           0 :         aReader.skipUndefinedProperty();
    2467           0 :         aReader.skipIntProperty< sal_uInt32 >(); // TransistionEffect
    2468           0 :         aReader.skipIntProperty< sal_uInt32 >(); // TransitionPeriod
    2469           0 :     }
    2470             :     // MultiPageProperties
    2471           0 :     AxBinaryPropertyReader aReader( rInStrm );
    2472           0 :     sal_uInt32 nPageCount = 0;
    2473           0 :     aReader.skipUndefinedProperty();
    2474           0 :     aReader.readIntProperty< sal_uInt32 >(nPageCount); // PageCount
    2475           0 :     aReader.skipIntProperty< sal_uInt32 >(); //ID
    2476             : 
    2477             :     // IDs
    2478           0 :     for ( sal_uInt32 count = 0; count < nPageCount; ++count )
    2479             :     {
    2480           0 :         sal_Int32 nID = 0;
    2481           0 :         rInStrm >> nID;
    2482           0 :         mnIDs.push_back( nID );
    2483             :     }
    2484           0 :     return true;
    2485             : }
    2486             : 
    2487           0 : void AxMultiPageModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
    2488             : {
    2489           0 :     rPropMap.setProperty( PROP_Title, maCaption );
    2490           0 :     rPropMap.setProperty( PROP_MultiPageValue, mnActiveTab + 1);
    2491           0 :     rConv.convertColor( rPropMap, PROP_BackgroundColor, mnBackColor );
    2492           0 :     rPropMap.setProperty( PROP_Enabled, getFlag( mnFlags, AX_CONTAINER_ENABLED ) );
    2493           0 :     rPropMap.setProperty( PROP_Decoration, mnTabStyle != AX_TABSTRIP_NONE );
    2494             : 
    2495           0 :     AxContainerModelBase::convertProperties( rPropMap, rConv );
    2496           0 : }
    2497             : 
    2498           4 : AxUserFormModel::AxUserFormModel()
    2499             : {
    2500           4 : }
    2501             : 
    2502          12 : ApiControlType AxUserFormModel::getControlType() const
    2503             : {
    2504          12 :     return API_CONTROL_DIALOG;
    2505             : }
    2506             : 
    2507           4 : void AxUserFormModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
    2508             : {
    2509           4 :     rPropMap.setProperty( PROP_Title, maCaption );
    2510           4 :     rConv.convertColor( rPropMap, PROP_BackgroundColor, mnBackColor );
    2511           4 :     rConv.convertAxPicture( rPropMap, maPictureData, AX_PICPOS_CENTER  );
    2512           4 :     rConv.convertScrollabilitySettings( rPropMap, maScrollPos, maLogicalSize, mnScrollBars );
    2513           4 :     AxContainerModelBase::convertProperties( rPropMap, rConv );
    2514           4 : }
    2515             : 
    2516           0 : HtmlSelectModel::HtmlSelectModel()
    2517             : {
    2518           0 : }
    2519             : 
    2520             : bool
    2521           0 : HtmlSelectModel::importBinaryModel( BinaryInputStream& rInStrm )
    2522             : {
    2523           0 :     static OUString sMultiple( "<SELECT MULTIPLE" );
    2524           0 :     static OUString sSelected( "OPTION SELECTED" );
    2525             : 
    2526           0 :     OUString sStringContents = rInStrm.readUnicodeArray( rInStrm.size() );
    2527             : 
    2528           0 :     OUString data = sStringContents;
    2529             : 
    2530             :     // replace crlf with lf
    2531           0 :     data = data.replaceAll( "\x0D\x0A" , "\x0A" );
    2532           0 :     std::vector< OUString > listValues;
    2533           0 :     std::vector< sal_Int16 > selectedIndices;
    2534             : 
    2535             :     // Ultra hacky parser for the info
    2536           0 :     sal_Int32 nTokenCount = comphelper::string::getTokenCount(data, '\n');
    2537             : 
    2538           0 :     for ( sal_Int32 nToken = 0; nToken < nTokenCount; ++nToken )
    2539             :     {
    2540           0 :         OUString sLine( data.getToken( nToken, '\n' ) );
    2541           0 :         if ( !nToken ) // first line will tell us if multiselect is enabled
    2542             :         {
    2543           0 :             if ( sLine == sMultiple )
    2544           0 :                 mnMultiSelect = AX_SELECTION_MULTI;
    2545             :         }
    2546             :         // skip first and last lines, no data there
    2547           0 :         else if ( nToken < nTokenCount - 1)
    2548             :         {
    2549           0 :             if ( comphelper::string::getTokenCount(sLine, '>') )
    2550             :             {
    2551           0 :                 OUString displayValue  = sLine.getToken( 1, '>' );
    2552           0 :                 if ( displayValue.getLength() )
    2553             :                 {
    2554             :                     // Really we should be using a proper html parser
    2555             :                     // escaping some common bits to be escaped
    2556           0 :                     displayValue = displayValue.replaceAll( "&lt;", "<" );
    2557           0 :                     displayValue = displayValue.replaceAll( "&gt;", ">" );
    2558           0 :                     displayValue = displayValue.replaceAll( "&quot;", "\"" );
    2559           0 :                     displayValue = displayValue.replaceAll( "&amp;", "&" );
    2560           0 :                     listValues.push_back( displayValue );
    2561           0 :                     if( sLine.indexOf( sSelected ) != -1 )
    2562           0 :                         selectedIndices.push_back( static_cast< sal_Int16 >( listValues.size() ) - 1 );
    2563           0 :                 }
    2564             :             }
    2565             :         }
    2566           0 :     }
    2567           0 :     if ( !listValues.empty() )
    2568             :     {
    2569           0 :         msListData.realloc( listValues.size() );
    2570           0 :         sal_Int32 index = 0;
    2571           0 :         for( std::vector< OUString >::iterator it = listValues.begin(); it != listValues.end(); ++it, ++index )
    2572           0 :              msListData[ index ] = *it;
    2573             :     }
    2574           0 :     if ( !selectedIndices.empty() )
    2575             :     {
    2576           0 :         msIndices.realloc( selectedIndices.size() );
    2577           0 :         sal_Int32 index = 0;
    2578           0 :         for( std::vector< sal_Int16 >::iterator it = selectedIndices.begin(); it != selectedIndices.end(); ++it, ++index )
    2579           0 :              msIndices[ index ] = *it;
    2580             :     }
    2581           0 :     return true;
    2582             : }
    2583             : 
    2584             : void
    2585           0 : HtmlSelectModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const
    2586             : {
    2587           0 :    rPropMap.setProperty( PROP_StringItemList, msListData );
    2588           0 :    rPropMap.setProperty( PROP_SelectedItems, msIndices );
    2589           0 :    rPropMap.setProperty( PROP_Dropdown, true );
    2590           0 :    AxListBoxModel::convertProperties( rPropMap, rConv );
    2591           0 : }
    2592             : 
    2593           0 : HtmlTextBoxModel::HtmlTextBoxModel()
    2594             : {
    2595           0 : }
    2596             : 
    2597             : bool
    2598           0 : HtmlTextBoxModel::importBinaryModel( BinaryInputStream& rInStrm )
    2599             : {
    2600             : #ifdef DEBUG
    2601             :     OUString sStringContents = rInStrm.readUnicodeArray( rInStrm.size() );
    2602             :     // in msocximex ( where this is ported from, it appears *nothing* is read
    2603             :     // from the control stream ), surely there is some useful info there ?
    2604             :     OSL_TRACE("HtmlTextBoxModel::importBinaryModel - string contents of stream :");
    2605             :     OSL_TRACE("%s", OUStringToOString( sStringContents, RTL_TEXTENCODING_UTF8 ).getStr() );
    2606             : #else
    2607             :     (void) rInStrm;
    2608             : #endif
    2609           0 :     return true;
    2610             : }
    2611             : 
    2612         106 : EmbeddedControl::EmbeddedControl( const OUString& rName ) :
    2613         106 :     maName( rName )
    2614             : {
    2615         106 : }
    2616             : 
    2617         106 : EmbeddedControl::~EmbeddedControl()
    2618             : {
    2619         106 : }
    2620             : 
    2621         102 : ControlModelBase* EmbeddedControl::createModelFromGuid( const OUString& rClassId )
    2622             : {
    2623         102 :     OUString aClassId = rClassId;//.toAsciiUpperCase();
    2624             : 
    2625         102 :     if( aClassId.equalsIgnoreAsciiCase( AX_GUID_COMMANDBUTTON ) )     return &createModel< AxCommandButtonModel >();
    2626          60 :     if( aClassId.equalsIgnoreAsciiCase( AX_GUID_LABEL ) )             return &createModel< AxLabelModel >();
    2627          58 :     if( aClassId.equalsIgnoreAsciiCase( AX_GUID_IMAGE ) )             return &createModel< AxImageModel >();
    2628          58 :     if( aClassId.equalsIgnoreAsciiCase( AX_GUID_TOGGLEBUTTON ) )      return &createModel< AxToggleButtonModel >();
    2629          56 :     if( aClassId.equalsIgnoreAsciiCase( AX_GUID_CHECKBOX ) )          return &createModel< AxCheckBoxModel >();
    2630          50 :     if( aClassId.equalsIgnoreAsciiCase( AX_GUID_OPTIONBUTTON ) )      return &createModel< AxOptionButtonModel >();
    2631          44 :     if( aClassId.equalsIgnoreAsciiCase( AX_GUID_TEXTBOX ) )           return &createModel< AxTextBoxModel >();
    2632          36 :     if( aClassId.equalsIgnoreAsciiCase( AX_GUID_LISTBOX ) )           return &createModel< AxListBoxModel >();
    2633          34 :     if( aClassId.equalsIgnoreAsciiCase( AX_GUID_COMBOBOX ) )          return &createModel< AxComboBoxModel >();
    2634          32 :     if( aClassId.equalsIgnoreAsciiCase( AX_GUID_SPINBUTTON ) )        return &createModel< AxSpinButtonModel >();
    2635          32 :     if( aClassId.equalsIgnoreAsciiCase( AX_GUID_SCROLLBAR ) )         return &createModel< AxScrollBarModel >();
    2636          32 :     if( aClassId.equalsIgnoreAsciiCase( AX_GUID_FRAME ) )             return &createModel< AxFrameModel >();
    2637          32 :     if( aClassId.equalsIgnoreAsciiCase( COMCTL_GUID_SCROLLBAR_60 ) )  return &createModel< ComCtlScrollBarModel >( COMCTL_VERSION_60 );
    2638          32 :     if( aClassId.equalsIgnoreAsciiCase( HTML_GUID_SELECT ) )  return &createModel< HtmlSelectModel >();
    2639          32 :     if( aClassId.equalsIgnoreAsciiCase( HTML_GUID_TEXTBOX ) ) return &createModel< HtmlTextBoxModel >();
    2640             : 
    2641          32 :     mxModel.reset();
    2642          32 :     return 0;
    2643             : }
    2644             : 
    2645           2 : OUString EmbeddedControl::getServiceName() const
    2646             : {
    2647           2 :     return mxModel.get() ? mxModel->getServiceName() : OUString();
    2648             : }
    2649             : 
    2650          70 : bool EmbeddedControl::convertProperties( const Reference< XControlModel >& rxCtrlModel, const ControlConverter& rConv ) const
    2651             : {
    2652          70 :     if( mxModel.get() && rxCtrlModel.is() && !maName.isEmpty() )
    2653             :     {
    2654          70 :         PropertyMap aPropMap;
    2655          70 :         aPropMap.setProperty( PROP_Name, maName );
    2656             :         try
    2657             :         {
    2658          70 :             aPropMap.setProperty( PROP_GenerateVbaEvents, true);
    2659             :         }
    2660           0 :         catch (const Exception& e)
    2661             :         {
    2662             :             SAL_WARN("oox", "exception: " << e.Message);
    2663             :         }
    2664          70 :         mxModel->convertProperties( aPropMap, rConv );
    2665         140 :         PropertySet aPropSet( rxCtrlModel );
    2666          70 :         aPropSet.setProperties( aPropMap );
    2667         140 :         return true;
    2668             :     }
    2669           0 :     return false;
    2670             : }
    2671             : 
    2672           2 : bool EmbeddedControl::convertFromProperties( const Reference< XControlModel >& rxCtrlModel, const ControlConverter& rConv )
    2673             : {
    2674           2 :     if( mxModel.get() && rxCtrlModel.is() && !maName.isEmpty() )
    2675             :     {
    2676           2 :         PropertySet aPropSet( rxCtrlModel );
    2677           2 :         aPropSet.getProperty( maName, PROP_Name );
    2678           2 :         mxModel->convertFromProperties( aPropSet, rConv );
    2679           2 :         return true;
    2680             :     }
    2681           0 :     return false;
    2682             : }
    2683             : 
    2684           2 : EmbeddedForm::EmbeddedForm( const Reference< XModel >& rxDocModel,
    2685             :         const Reference< XDrawPage >& rxDrawPage, const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ) :
    2686             :     maControlConv( rxDocModel, rGraphicHelper, bDefaultColorBgr ),
    2687             :     mxModelFactory( rxDocModel, UNO_QUERY ),
    2688           2 :     mxFormsSupp( rxDrawPage, UNO_QUERY )
    2689             : {
    2690             :     OSL_ENSURE( mxModelFactory.is(), "EmbeddedForm::EmbeddedForm - missing service factory" );
    2691           2 : }
    2692             : 
    2693           2 : Reference< XControlModel > EmbeddedForm::convertAndInsert( const EmbeddedControl& rControl, sal_Int32& rnCtrlIndex )
    2694             : {
    2695           2 :     Reference< XControlModel > xRet;
    2696           2 :     if( mxModelFactory.is() && rControl.hasModel() ) try
    2697             :     {
    2698             :         // create the UNO control model
    2699           2 :         OUString aServiceName = rControl.getServiceName();
    2700           4 :         Reference< XFormComponent > xFormComp( mxModelFactory->createInstance( aServiceName ), UNO_QUERY_THROW );
    2701           4 :         Reference< XControlModel > xCtrlModel( xFormComp, UNO_QUERY_THROW );
    2702             : 
    2703             :         // convert the control properties
    2704           2 :         if( rControl.convertProperties( xCtrlModel, maControlConv ) )
    2705           2 :             xRet = xCtrlModel;
    2706             :         // insert the control into the form
    2707           4 :         Reference< XIndexContainer > xFormIC( createXForm(), UNO_SET_THROW );
    2708           2 :         rnCtrlIndex = xFormIC->getCount();
    2709           4 :         xFormIC->insertByIndex( rnCtrlIndex, Any( xFormComp ) );
    2710             :     }
    2711           0 :     catch (const Exception& e)
    2712             :     {
    2713             :         SAL_WARN("oox", "exception creating Control: " << e.Message);
    2714             :     }
    2715           2 :     return xRet;
    2716             : }
    2717             : 
    2718           2 : Reference< XIndexContainer > EmbeddedForm::createXForm()
    2719             : {
    2720           2 :     if( mxFormsSupp.is() )
    2721             :     {
    2722             :         try
    2723             :         {
    2724           2 :             Reference< XNameContainer > xFormsNC( mxFormsSupp->getForms(), UNO_SET_THROW );
    2725           4 :             OUString aFormName = "Standard";
    2726           2 :             if( xFormsNC->hasByName( aFormName ) )
    2727             :             {
    2728           0 :                 mxFormIC.set( xFormsNC->getByName( aFormName ), UNO_QUERY_THROW );
    2729             :             }
    2730           2 :             else if( mxModelFactory.is() )
    2731             :             {
    2732           2 :                 Reference< XForm > xForm( mxModelFactory->createInstance( "com.sun.star.form.component.Form" ), UNO_QUERY_THROW );
    2733           2 :                 xFormsNC->insertByName( aFormName, Any( xForm ) );
    2734           2 :                 mxFormIC.set( xForm, UNO_QUERY_THROW );
    2735           2 :             }
    2736             :         }
    2737           0 :         catch (const Exception& e)
    2738             :         {
    2739             :             SAL_WARN("oox", "exception creating Form: " << e.Message);
    2740             :         }
    2741             :         // always clear the forms supplier to not try to create the form again
    2742           2 :         mxFormsSupp.clear();
    2743             :     }
    2744           2 :     return mxFormIC;
    2745             : }
    2746             : 
    2747             : } // namespace ole
    2748         408 : } // namespace oox
    2749             : 
    2750             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10