LCOV - code coverage report
Current view: top level - libreoffice/oox/source/ole - axcontrol.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 368 1384 26.6 %
Date: 2012-12-27 Functions: 48 173 27.7 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10