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

Generated by: LCOV version 1.10