LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/toolkit/source/controls - unocontrols.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1597 2254 70.9 %
Date: 2013-07-09 Functions: 344 477 72.1 %
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 <com/sun/star/awt/XTextArea.hpp>
      21             : #include <com/sun/star/awt/XVclWindowPeer.hpp>
      22             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      23             : #include <com/sun/star/awt/PosSize.hpp>
      24             : #include <com/sun/star/awt/VisualEffect.hpp>
      25             : #include <com/sun/star/awt/LineEndFormat.hpp>
      26             : #include <com/sun/star/graphic/GraphicProvider.hpp>
      27             : #include <com/sun/star/graphic/XGraphicProvider.hpp>
      28             : #include <com/sun/star/graphic/GraphicObject.hpp>
      29             : #include <com/sun/star/util/Date.hpp>
      30             : #include <com/sun/star/awt/ImageScaleMode.hpp>
      31             : 
      32             : 
      33             : #include <toolkit/controls/formattedcontrol.hxx>
      34             : #include <toolkit/controls/roadmapcontrol.hxx>
      35             : #include <toolkit/controls/unocontrols.hxx>
      36             : #include <toolkit/controls/stdtabcontroller.hxx>
      37             : #include <toolkit/helper/property.hxx>
      38             : #include <toolkit/helper/unopropertyarrayhelper.hxx>
      39             : #include <toolkit/helper/servicenames.hxx>
      40             : #include <toolkit/helper/macros.hxx>
      41             : #include <toolkit/helper/imagealign.hxx>
      42             : 
      43             : // for introspection
      44             : #include <toolkit/awt/vclxwindows.hxx>
      45             : #include <cppuhelper/typeprovider.hxx>
      46             : #include <comphelper/processfactory.hxx>
      47             : #include <comphelper/extract.hxx>
      48             : #include <vcl/wrkwin.hxx>
      49             : #include <vcl/svapp.hxx>
      50             : #include <vcl/edit.hxx>
      51             : #include <vcl/button.hxx>
      52             : #include <vcl/group.hxx>
      53             : #include <vcl/fixed.hxx>
      54             : #include <vcl/lstbox.hxx>
      55             : #include <vcl/combobox.hxx>
      56             : #include <tools/debug.hxx>
      57             : #include <tools/diagnose_ex.h>
      58             : #include <tools/date.hxx>
      59             : #include <tools/time.hxx>
      60             : 
      61             : #include <algorithm>
      62             : #include <functional>
      63             : 
      64             : using namespace css;
      65             : using namespace css::awt;
      66             : using namespace css::lang;
      67             : using namespace css::uno;
      68             : using ::com::sun::star::graphic::XGraphic;
      69             : using ::com::sun::star::uno::Reference;
      70             : using namespace ::toolkit;
      71             : 
      72             : #define IMPL_SERVICEINFO_DERIVED( ImplName, BaseClass, ServiceName ) \
      73             :     OUString SAL_CALL ImplName::getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException) { return OUString( "stardiv.Toolkit." #ImplName ); } \
      74             :     ::com::sun::star::uno::Sequence< OUString > SAL_CALL ImplName::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException) \
      75             :                             { \
      76             :                                 ::com::sun::star::uno::Sequence< OUString > aNames = BaseClass::getSupportedServiceNames( ); \
      77             :                                 aNames.realloc( aNames.getLength() + 1 ); \
      78             :                                 aNames[ aNames.getLength() - 1 ] = OUString::createFromAscii( ServiceName ); \
      79             :                                 return aNames; \
      80             :                             } \
      81             : 
      82             : 
      83             : uno::Reference< graphic::XGraphic >
      84           2 : ImageHelper::getGraphicAndGraphicObjectFromURL_nothrow( uno::Reference< graphic::XGraphicObject >& xOutGraphicObj, const OUString& _rURL )
      85             : {
      86           2 :     if ( _rURL.startsWith( UNO_NAME_GRAPHOBJ_URLPREFIX ) )
      87             :     {
      88             :         // graphic manager uniqueid
      89           0 :         OUString sID = _rURL.copy( sizeof( UNO_NAME_GRAPHOBJ_URLPREFIX ) - 1 );
      90           0 :         xOutGraphicObj = graphic::GraphicObject::createWithId( ::comphelper::getProcessComponentContext(), sID );
      91             :     }
      92             :     else // linked
      93           2 :         xOutGraphicObj = NULL; // release the GraphicObject
      94             : 
      95           2 :     return ImageHelper::getGraphicFromURL_nothrow( _rURL );
      96             : }
      97             : 
      98             : ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >
      99          28 : ImageHelper::getGraphicFromURL_nothrow( const OUString& _rURL )
     100             : {
     101          28 :     uno::Reference< graphic::XGraphic > xGraphic;
     102          28 :     if ( _rURL.isEmpty() )
     103           0 :         return xGraphic;
     104             : 
     105             :     try
     106             :     {
     107          28 :         uno::Reference< uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
     108          56 :         uno::Reference< graphic::XGraphicProvider > xProvider( graphic::GraphicProvider::create(xContext) );
     109          56 :         uno::Sequence< beans::PropertyValue > aMediaProperties(1);
     110          28 :         aMediaProperties[0].Name = OUString( "URL" );
     111          28 :         aMediaProperties[0].Value <<= _rURL;
     112          56 :         xGraphic = xProvider->queryGraphic( aMediaProperties );
     113             :     }
     114           0 :     catch (const Exception&)
     115             :     {
     116             :         DBG_UNHANDLED_EXCEPTION();
     117             :     }
     118             : 
     119          28 :     return xGraphic;
     120             : }
     121             : //  ----------------------------------------------------
     122             : //  class UnoControlEditModel
     123             : //  ----------------------------------------------------
     124          10 : UnoControlEditModel::UnoControlEditModel( const Reference< XComponentContext >& rxContext )
     125          10 :     :UnoControlModel( rxContext )
     126             : {
     127          10 :     UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXEdit );
     128          10 : }
     129             : 
     130           1 : OUString UnoControlEditModel::getServiceName( ) throw(::com::sun::star::uno::RuntimeException)
     131             : {
     132           1 :     return OUString::createFromAscii( szServiceName_UnoControlEditModel );
     133             : }
     134             : 
     135         435 : uno::Any UnoControlEditModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
     136             : {
     137         435 :     uno::Any aReturn;
     138             : 
     139         435 :     switch ( nPropId )
     140             :     {
     141             :     case BASEPROPERTY_LINE_END_FORMAT:
     142          14 :         aReturn <<= (sal_Int16)awt::LineEndFormat::LINE_FEED;   // LF
     143          14 :         break;
     144             :     case BASEPROPERTY_DEFAULTCONTROL:
     145          13 :         aReturn <<= OUString::createFromAscii( szServiceName_UnoControlEdit );
     146          13 :         break;
     147             :     default:
     148         408 :         aReturn = UnoControlModel::ImplGetDefaultValue( nPropId );
     149         408 :         break;
     150             :     }
     151         435 :     return aReturn;
     152             : }
     153             : 
     154        1948 : ::cppu::IPropertyArrayHelper& UnoControlEditModel::getInfoHelper()
     155             : {
     156             :     static UnoPropertyArrayHelper* pHelper = NULL;
     157        1948 :     if ( !pHelper )
     158             :     {
     159           3 :         uno::Sequence<sal_Int32>    aIDs = ImplGetPropertyIds();
     160           3 :         pHelper = new UnoPropertyArrayHelper( aIDs );
     161             :     }
     162        1948 :     return *pHelper;
     163             : }
     164             : 
     165             : // beans::XMultiPropertySet
     166          62 : uno::Reference< beans::XPropertySetInfo > UnoControlEditModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
     167             : {
     168          62 :     static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
     169          62 :     return xInfo;
     170             : }
     171             : 
     172             : 
     173             : //  ----------------------------------------------------
     174             : //  class UnoEditControl
     175             : //  ----------------------------------------------------
     176         111 : UnoEditControl::UnoEditControl()
     177             :     :UnoControlBase()
     178             :     ,maTextListeners( *this )
     179             :     ,mnMaxTextLen( 0 )
     180             :     ,mbSetTextInPeer( sal_False )
     181             :     ,mbSetMaxTextLenInPeer( sal_False )
     182         111 :     ,mbHasTextProperty( sal_False )
     183             : {
     184         111 :     maComponentInfos.nWidth = 100;
     185         111 :     maComponentInfos.nHeight = 12;
     186         111 :     mnMaxTextLen = 0;
     187         111 :     mbSetMaxTextLenInPeer = sal_False;
     188         111 : }
     189             : 
     190        4627 : uno::Any SAL_CALL UnoEditControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
     191             : {
     192        4627 :     uno::Any aReturn = UnoControlBase::queryAggregation( rType );
     193        4627 :     if ( !aReturn.hasValue() )
     194         383 :         aReturn = UnoEditControl_Base::queryInterface( rType );
     195        4627 :     return aReturn;
     196             : }
     197             : 
     198        4945 : uno::Any SAL_CALL UnoEditControl::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException)
     199             : {
     200        4945 :     return UnoControlBase::queryInterface( rType );
     201             : }
     202             : 
     203        7341 : void SAL_CALL UnoEditControl::acquire(  ) throw ()
     204             : {
     205        7341 :     UnoControlBase::acquire();
     206        7341 : }
     207             : 
     208        7296 : void SAL_CALL UnoEditControl::release(  ) throw ()
     209             : {
     210        7296 :     UnoControlBase::release();
     211        7296 : }
     212             : 
     213          21 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( UnoEditControl, UnoControlBase, UnoEditControl_Base )
     214             : 
     215          64 : OUString UnoEditControl::GetComponentServiceName()
     216             : {
     217             :     // by default, we want a simple edit field
     218          64 :     OUString sName( "Edit" );
     219             : 
     220             :     // but maybe we are to display multi-line text?
     221         128 :     uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_MULTILINE ) );
     222          64 :     sal_Bool b = sal_Bool();
     223          64 :     if ( ( aVal >>= b ) && b )
     224          11 :         sName= OUString("MultiLineEdit");
     225             : 
     226         128 :     return sName;
     227             : }
     228             : 
     229         216 : sal_Bool SAL_CALL UnoEditControl::setModel(const uno::Reference< awt::XControlModel >& _rModel) throw ( uno::RuntimeException )
     230             : {
     231         216 :     sal_Bool bReturn = UnoControlBase::setModel( _rModel );
     232         216 :     mbHasTextProperty = ImplHasProperty( BASEPROPERTY_TEXT );
     233         216 :     return bReturn;
     234             : }
     235             : 
     236       20109 : void UnoEditControl::ImplSetPeerProperty( const OUString& rPropName, const uno::Any& rVal )
     237             : {
     238       20109 :     sal_Bool bDone = sal_False;
     239       20109 :     if ( GetPropertyId( rPropName ) == BASEPROPERTY_TEXT )
     240             :     {
     241             :         // #96986# use setText(), or text listener will not be called.
     242         294 :         uno::Reference < awt::XTextComponent > xTextComponent( getPeer(), uno::UNO_QUERY );
     243         294 :         if ( xTextComponent.is() )
     244             :         {
     245         270 :             OUString sText;
     246         270 :             rVal >>= sText;
     247         270 :             ImplCheckLocalize( sText );
     248         270 :             xTextComponent->setText( sText );
     249         270 :             bDone = sal_True;
     250         294 :         }
     251             :     }
     252             : 
     253       20109 :     if ( !bDone )
     254       19839 :         UnoControlBase::ImplSetPeerProperty( rPropName, rVal );
     255       20109 : }
     256             : 
     257          84 : void UnoEditControl::dispose() throw(uno::RuntimeException)
     258             : {
     259          84 :     lang::EventObject aEvt( *this );
     260          84 :     maTextListeners.disposeAndClear( aEvt );
     261          84 :     UnoControl::dispose();
     262          84 : }
     263             : 
     264         188 : void UnoEditControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer >  & rParentPeer ) throw(uno::RuntimeException)
     265             : {
     266         188 :     UnoControl::createPeer( rxToolkit, rParentPeer );
     267             : 
     268         188 :     uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
     269         188 :     if ( xText.is() )
     270             :     {
     271         188 :     xText->addTextListener( this );
     272             : 
     273         188 :     if ( mbSetMaxTextLenInPeer )
     274           0 :         xText->setMaxTextLen( mnMaxTextLen );
     275         188 :     if ( mbSetTextInPeer )
     276           0 :         xText->setText( maText );
     277         188 :     }
     278         188 : }
     279             : 
     280           0 : void UnoEditControl::textChanged(const awt::TextEvent& e) throw(uno::RuntimeException)
     281             : {
     282           0 :     uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
     283             : 
     284           0 :     if ( mbHasTextProperty )
     285             :     {
     286           0 :         uno::Any aAny;
     287           0 :         aAny <<= xText->getText();
     288           0 :         ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TEXT ), aAny, sal_False );
     289             :     }
     290             :     else
     291             :     {
     292           0 :         maText = xText->getText();
     293             :     }
     294             : 
     295           0 :     if ( maTextListeners.getLength() )
     296           0 :         maTextListeners.textChanged( e );
     297           0 : }
     298             : 
     299          32 : void UnoEditControl::addTextListener(const uno::Reference< awt::XTextListener > & l) throw(uno::RuntimeException)
     300             : {
     301          32 :     maTextListeners.addInterface( l );
     302          32 : }
     303             : 
     304          15 : void UnoEditControl::removeTextListener(const uno::Reference< awt::XTextListener > & l) throw(uno::RuntimeException)
     305             : {
     306          15 :     maTextListeners.removeInterface( l );
     307          15 : }
     308             : 
     309         137 : void UnoEditControl::setText( const OUString& aText ) throw(uno::RuntimeException)
     310             : {
     311         137 :     if ( mbHasTextProperty )
     312             :     {
     313         101 :         uno::Any aAny;
     314         101 :         aAny <<= aText;
     315         101 :         ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TEXT ), aAny, sal_True );
     316             :     }
     317             :     else
     318             :     {
     319          36 :         maText = aText;
     320          36 :         mbSetTextInPeer = sal_True;
     321          36 :             uno::Reference < awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
     322          36 :         if ( xText.is() )
     323          36 :             xText->setText( maText );
     324             :         }
     325             : 
     326             :     // Setting the property to the VCLXWindow doesn't call textChanged
     327         137 :     if ( maTextListeners.getLength() )
     328             :     {
     329         137 :         awt::TextEvent aEvent;
     330         137 :         aEvent.Source = *this;
     331         137 :         maTextListeners.textChanged( aEvent );
     332             :     }
     333         137 : }
     334             : 
     335             : namespace
     336             : {
     337          15 :     static void lcl_normalize( awt::Selection& _rSel )
     338             :     {
     339          15 :         if ( _rSel.Min > _rSel.Max )
     340           0 :             ::std::swap( _rSel.Min, _rSel.Max );
     341          15 :     }
     342             : }
     343             : 
     344          15 : void UnoEditControl::insertText( const awt::Selection& rSel, const OUString& rNewText ) throw(uno::RuntimeException)
     345             : {
     346             :     // normalize the selection - OUString::replaceAt has a strange behaviour if the min is greater than the max
     347          15 :     awt::Selection aSelection( rSel );
     348          15 :     lcl_normalize( aSelection );
     349             : 
     350             :     // preserve the selection resp. cursor position
     351          15 :     awt::Selection aNewSelection( getSelection() );
     352             : #ifdef ALSO_PRESERVE_COMPLETE_SELECTION
     353             :         // (not sure - looks uglier ...)
     354             :     sal_Int32 nDeletedCharacters = ( aSelection.Max - aSelection.Min ) - rNewText.getLength();
     355             :     if ( aNewSelection.Min > aSelection.Min )
     356             :         aNewSelection.Min -= nDeletedCharacters;
     357             :     if ( aNewSelection.Max > aSelection.Max )
     358             :         aNewSelection.Max -= nDeletedCharacters;
     359             : #else
     360          15 :     aNewSelection.Max = ::std::min( aNewSelection.Min, aNewSelection.Max ) + rNewText.getLength();
     361          15 :     aNewSelection.Min = aNewSelection.Max;
     362             : #endif
     363             : 
     364          15 :     OUString aOldText = getText();
     365          30 :     OUString  aNewText = aOldText.replaceAt( aSelection.Min, aSelection.Max - aSelection.Min, rNewText );
     366          15 :     setText( aNewText );
     367             : 
     368          30 :     setSelection( aNewSelection );
     369          15 : }
     370             : 
     371          94 : OUString UnoEditControl::getText() throw(uno::RuntimeException)
     372             : {
     373          94 :     OUString aText = maText;
     374             : 
     375          94 :     if ( mbHasTextProperty )
     376          70 :         aText = ImplGetPropertyValue_UString( BASEPROPERTY_TEXT );
     377             :     else
     378             :     {
     379          24 :         uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
     380          24 :         if ( xText.is() )
     381          24 :             aText = xText->getText();
     382             :     }
     383             : 
     384          94 :     return aText;
     385             : }
     386             : 
     387          15 : OUString UnoEditControl::getSelectedText( void ) throw(uno::RuntimeException)
     388             : {
     389          15 :     OUString sSelected;
     390          30 :         uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
     391          15 :     if ( xText.is() )
     392          15 :         sSelected = xText->getSelectedText();
     393             : 
     394          30 :     return sSelected;
     395             : }
     396             : 
     397          60 : void UnoEditControl::setSelection( const awt::Selection& aSelection ) throw(uno::RuntimeException)
     398             : {
     399          60 :         uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
     400          60 :     if ( xText.is() )
     401          60 :         xText->setSelection( aSelection );
     402          60 : }
     403             : 
     404          45 : awt::Selection UnoEditControl::getSelection( void ) throw(uno::RuntimeException)
     405             : {
     406          45 :     awt::Selection aSel;
     407          45 :         uno::Reference< awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
     408          45 :     if ( xText.is() )
     409          45 :         aSel = xText->getSelection();
     410          45 :     return aSel;
     411             : }
     412             : 
     413          30 : sal_Bool UnoEditControl::isEditable( void ) throw(uno::RuntimeException)
     414             : {
     415          30 :     return !ImplGetPropertyValue_BOOL( BASEPROPERTY_READONLY );
     416             : }
     417             : 
     418          30 : void UnoEditControl::setEditable( sal_Bool bEditable ) throw(uno::RuntimeException)
     419             : {
     420          30 :     uno::Any aAny;
     421          30 :     aAny <<= (sal_Bool)!bEditable;
     422          30 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_READONLY ), aAny, sal_True );
     423          30 : }
     424             : 
     425          45 : sal_Int16 UnoEditControl::getMaxTextLen() throw(uno::RuntimeException)
     426             : {
     427          45 :     sal_Int16 nMaxLen = mnMaxTextLen;
     428             : 
     429          45 :     if ( ImplHasProperty( BASEPROPERTY_MAXTEXTLEN ) )
     430          21 :         nMaxLen = ImplGetPropertyValue_INT16( BASEPROPERTY_MAXTEXTLEN );
     431             : 
     432          45 :     return nMaxLen;
     433             : }
     434             : 
     435          30 : void UnoEditControl::setMaxTextLen( sal_Int16 nLen ) throw(uno::RuntimeException)
     436             : {
     437          30 :     if ( ImplHasProperty( BASEPROPERTY_MAXTEXTLEN) )
     438             :     {
     439          14 :         uno::Any aAny;
     440          14 :         aAny <<= (sal_Int16)nLen;
     441          14 :         ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MAXTEXTLEN ), aAny, sal_True );
     442             :     }
     443             :     else
     444             :     {
     445          16 :         mnMaxTextLen = nLen;
     446          16 :         mbSetMaxTextLenInPeer = sal_True;
     447          16 :             uno::Reference < awt::XTextComponent > xText( getPeer(), uno::UNO_QUERY );
     448          16 :         if ( xText.is() )
     449          16 :             xText->setMaxTextLen( mnMaxTextLen );
     450             :     }
     451          30 : }
     452             : 
     453          15 : awt::Size UnoEditControl::getMinimumSize(  ) throw(uno::RuntimeException)
     454             : {
     455          15 :     return Impl_getMinimumSize();
     456             : }
     457             : 
     458          15 : awt::Size UnoEditControl::getPreferredSize(  ) throw(uno::RuntimeException)
     459             : {
     460          15 :     return Impl_getPreferredSize();
     461             : }
     462             : 
     463          15 : awt::Size UnoEditControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
     464             : {
     465          15 :     return Impl_calcAdjustedSize( rNewSize );
     466             : }
     467             : 
     468          15 : awt::Size UnoEditControl::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(uno::RuntimeException)
     469             : {
     470          15 :     return Impl_getMinimumSize( nCols, nLines );
     471             : }
     472             : 
     473          15 : void UnoEditControl::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(uno::RuntimeException)
     474             : {
     475          15 :     Impl_getColumnsAndLines( nCols, nLines );
     476          15 : }
     477             : 
     478           1 : OUString UnoEditControl::getImplementationName(  ) throw(uno::RuntimeException)
     479             : {
     480           1 :     return OUString( "stardiv.Toolkit.UnoEditControl" );
     481             : }
     482             : 
     483           0 : uno::Sequence< OUString > UnoEditControl::getSupportedServiceNames() throw(uno::RuntimeException)
     484             : {
     485           0 :     uno::Sequence< OUString > aNames = UnoControlBase::getSupportedServiceNames( );
     486           0 :     aNames.realloc( aNames.getLength() + 1 );
     487           0 :     aNames[ aNames.getLength() - 1 ] = OUString::createFromAscii( szServiceName2_UnoControlEdit );
     488           0 :     return aNames;
     489             : }
     490             : 
     491             : //  ----------------------------------------------------
     492             : //  class UnoControlFileControlModel
     493             : //  ----------------------------------------------------
     494           7 : UnoControlFileControlModel::UnoControlFileControlModel( const Reference< XComponentContext >& rxContext )
     495           7 :     :UnoControlModel( rxContext )
     496             : {
     497           7 :     ImplRegisterProperty( BASEPROPERTY_ALIGN );
     498           7 :     ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
     499           7 :     ImplRegisterProperty( BASEPROPERTY_BORDER );
     500           7 :     ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR );
     501           7 :     ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
     502           7 :     ImplRegisterProperty( BASEPROPERTY_ENABLED );
     503           7 :     ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
     504           7 :     ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
     505           7 :     ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
     506           7 :     ImplRegisterProperty( BASEPROPERTY_HELPURL );
     507           7 :     ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
     508           7 :     ImplRegisterProperty( BASEPROPERTY_READONLY );
     509           7 :     ImplRegisterProperty( BASEPROPERTY_TABSTOP );
     510           7 :     ImplRegisterProperty( BASEPROPERTY_TEXT );
     511           7 :     ImplRegisterProperty( BASEPROPERTY_VERTICALALIGN );
     512           7 :     ImplRegisterProperty( BASEPROPERTY_WRITING_MODE );
     513           7 :     ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE );
     514           7 :     ImplRegisterProperty( BASEPROPERTY_HIDEINACTIVESELECTION );
     515           7 : }
     516             : 
     517           1 : OUString UnoControlFileControlModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
     518             : {
     519           1 :     return OUString::createFromAscii( szServiceName_UnoControlFileControlModel );
     520             : }
     521             : 
     522         175 : uno::Any UnoControlFileControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
     523             : {
     524         175 :     if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
     525             :     {
     526           8 :         uno::Any aAny;
     527           8 :         aAny <<= OUString::createFromAscii( szServiceName_UnoControlFileControl );
     528           8 :         return aAny;
     529             :     }
     530         167 :     return UnoControlModel::ImplGetDefaultValue( nPropId );
     531             : }
     532             : 
     533         847 : ::cppu::IPropertyArrayHelper& UnoControlFileControlModel::getInfoHelper()
     534             : {
     535             :     static UnoPropertyArrayHelper* pHelper = NULL;
     536         847 :     if ( !pHelper )
     537             :     {
     538           1 :         uno::Sequence<sal_Int32>    aIDs = ImplGetPropertyIds();
     539           1 :         pHelper = new UnoPropertyArrayHelper( aIDs );
     540             :     }
     541         847 :     return *pHelper;
     542             : }
     543             : 
     544             : // beans::XMultiPropertySet
     545          41 : uno::Reference< beans::XPropertySetInfo > UnoControlFileControlModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
     546             : {
     547          41 :     static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
     548          41 :     return xInfo;
     549             : }
     550             : 
     551             : //  ----------------------------------------------------
     552             : //  class UnoFileControl
     553             : //  ----------------------------------------------------
     554           0 : UnoFileControl::UnoFileControl()
     555           0 :     :UnoEditControl()
     556             : {
     557           0 : }
     558             : 
     559           0 : OUString UnoFileControl::GetComponentServiceName()
     560             : {
     561           0 :     return OUString("filecontrol");
     562             : }
     563             : 
     564             : //  ----------------------------------------------------
     565             : //  class GraphicControlModel
     566             : //  ----------------------------------------------------
     567        3311 : uno::Any GraphicControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
     568             : {
     569        3311 :     if ( nPropId == BASEPROPERTY_GRAPHIC )
     570         130 :         return uno::makeAny( uno::Reference< graphic::XGraphic >() );
     571             : 
     572        3181 :     return UnoControlModel::ImplGetDefaultValue( nPropId );
     573             : }
     574             : 
     575        1656 : void SAL_CALL GraphicControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception)
     576             : {
     577        1656 :     UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue );
     578             : 
     579             :     // - ImageAlign and ImagePosition need to correspond to each other
     580             :     // - Graphic and ImageURL need to correspond to each other
     581             :     try
     582             :     {
     583        1656 :         switch ( nHandle )
     584             :         {
     585             :         case BASEPROPERTY_IMAGEURL:
     586          24 :             if ( !mbAdjustingGraphic && ImplHasProperty( BASEPROPERTY_GRAPHIC ) )
     587             :             {
     588          24 :                 mbAdjustingGraphic = true;
     589          24 :                 OUString sImageURL;
     590          24 :                 OSL_VERIFY( rValue >>= sImageURL );
     591          24 :                 setDependentFastPropertyValue( BASEPROPERTY_GRAPHIC, uno::makeAny( ImageHelper::getGraphicFromURL_nothrow( sImageURL ) ) );
     592          24 :                 mbAdjustingGraphic = false;
     593             :             }
     594          24 :             break;
     595             : 
     596             :         case BASEPROPERTY_GRAPHIC:
     597           0 :             if ( !mbAdjustingGraphic && ImplHasProperty( BASEPROPERTY_IMAGEURL ) )
     598             :             {
     599           0 :                 mbAdjustingGraphic = true;
     600           0 :                 setDependentFastPropertyValue( BASEPROPERTY_IMAGEURL, uno::makeAny( OUString() ) );
     601           0 :                 mbAdjustingGraphic = false;
     602             :             }
     603           0 :             break;
     604             : 
     605             :         case BASEPROPERTY_IMAGEALIGN:
     606           8 :             if ( !mbAdjustingImagePosition && ImplHasProperty( BASEPROPERTY_IMAGEPOSITION ) )
     607             :             {
     608           6 :                 mbAdjustingImagePosition = true;
     609           6 :                 sal_Int16 nUNOValue = 0;
     610           6 :                 OSL_VERIFY( rValue >>= nUNOValue );
     611           6 :                 setDependentFastPropertyValue( BASEPROPERTY_IMAGEPOSITION, uno::makeAny( getExtendedImagePosition( nUNOValue ) ) );
     612           6 :                 mbAdjustingImagePosition = false;
     613             :             }
     614           8 :             break;
     615             :         case BASEPROPERTY_IMAGEPOSITION:
     616         132 :             if ( !mbAdjustingImagePosition && ImplHasProperty( BASEPROPERTY_IMAGEALIGN ) )
     617             :             {
     618          87 :                 mbAdjustingImagePosition = true;
     619          87 :                 sal_Int16 nUNOValue = 0;
     620          87 :                 OSL_VERIFY( rValue >>= nUNOValue );
     621          87 :                 setDependentFastPropertyValue( BASEPROPERTY_IMAGEALIGN, uno::makeAny( getCompatibleImageAlign( translateImagePosition( nUNOValue ) ) ) );
     622          87 :                 mbAdjustingImagePosition = false;
     623             :             }
     624         132 :             break;
     625             :         }
     626             :     }
     627           0 :     catch( const ::com::sun::star::uno::Exception& )
     628             :     {
     629             :         OSL_FAIL( "GraphicControlModel::setFastPropertyValue_NoBroadcast: caught an exception while aligning the ImagePosition/ImageAlign properties!" );
     630           0 :         mbAdjustingImagePosition = sal_False;
     631             :     }
     632        1656 : }
     633             : 
     634             : //  ----------------------------------------------------
     635             : //  class UnoControlButtonModel
     636             : //  ----------------------------------------------------
     637          57 : UnoControlButtonModel::UnoControlButtonModel( const Reference< XComponentContext >& rxContext )
     638          57 :     :GraphicControlModel( rxContext )
     639             : {
     640          57 :     UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXButton );
     641             : 
     642          57 :     osl_atomic_increment( &m_refCount );
     643             :     {
     644          57 :         setFastPropertyValue_NoBroadcast( BASEPROPERTY_IMAGEPOSITION, ImplGetDefaultValue( BASEPROPERTY_IMAGEPOSITION ) );
     645             :         // this ensures that our ImagePosition is consistent with our ImageAlign property (since both
     646             :         // defaults are not per se consistent), since both are coupled in setFastPropertyValue_NoBroadcast
     647             :     }
     648          57 :     osl_atomic_decrement( &m_refCount );
     649          57 : }
     650             : 
     651           1 : OUString UnoControlButtonModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
     652             : {
     653           1 :     return OUString::createFromAscii( szServiceName_UnoControlButtonModel );
     654             : }
     655             : 
     656        1873 : uno::Any UnoControlButtonModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
     657             : {
     658        1873 :     switch ( nPropId )
     659             :     {
     660             :     case BASEPROPERTY_DEFAULTCONTROL:
     661          58 :         return uno::makeAny( OUString::createFromAscii( szServiceName_UnoControlButton ) );
     662             :     case BASEPROPERTY_TOGGLE:
     663          58 :         return uno::makeAny( (sal_Bool)sal_False );
     664             :     case BASEPROPERTY_ALIGN:
     665          59 :         return uno::makeAny( (sal_Int16)PROPERTY_ALIGN_CENTER );
     666             :     case BASEPROPERTY_FOCUSONCLICK:
     667          59 :         return uno::makeAny( (sal_Bool)sal_True );
     668             :     }
     669             : 
     670        1639 :     return GraphicControlModel::ImplGetDefaultValue( nPropId );
     671             : }
     672             : 
     673        4997 : ::cppu::IPropertyArrayHelper& UnoControlButtonModel::getInfoHelper()
     674             : {
     675             :     static UnoPropertyArrayHelper* pHelper = NULL;
     676        4997 :     if ( !pHelper )
     677             :     {
     678          11 :         uno::Sequence<sal_Int32>    aIDs = ImplGetPropertyIds();
     679          11 :         pHelper = new UnoPropertyArrayHelper( aIDs );
     680             :     }
     681        4997 :     return *pHelper;
     682             : }
     683             : 
     684             : // beans::XMultiPropertySet
     685          62 : uno::Reference< beans::XPropertySetInfo > UnoControlButtonModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
     686             : {
     687          62 :     static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
     688          62 :     return xInfo;
     689             : }
     690             : 
     691             : //  ----------------------------------------------------
     692             : //  class UnoButtonControl
     693             : //  ----------------------------------------------------
     694         127 : UnoButtonControl::UnoButtonControl()
     695             :     :UnoButtonControl_Base()
     696             :     ,maActionListeners( *this )
     697         127 :     ,maItemListeners( *this )
     698             : {
     699         127 :     maComponentInfos.nWidth = 50;
     700         127 :     maComponentInfos.nHeight = 14;
     701         127 : }
     702             : 
     703          48 : OUString UnoButtonControl::GetComponentServiceName()
     704             : {
     705          48 :     OUString aName( "pushbutton" );
     706          96 :     uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_PUSHBUTTONTYPE ) );
     707          48 :     sal_Int16 n = sal_Int16();
     708          48 :     if ( ( aVal >>= n ) && n )
     709             :     {
     710             :         // Use PushButtonType later when available...
     711           0 :         switch ( n )
     712             :         {
     713           0 :             case 1 /*PushButtonType::OK*/:      aName= OUString("okbutton");
     714           0 :                                                 break;
     715           0 :             case 2 /*PushButtonType::CANCEL*/:  aName= OUString("cancelbutton");
     716           0 :                                                 break;
     717           0 :             case 3 /*PushButtonType::HELP*/:    aName= OUString("helpbutton");
     718           0 :                                                 break;
     719             :             default:
     720             :             {
     721             :                 OSL_FAIL( "Unknown Button Type!" );
     722             :             }
     723             :         }
     724             :     }
     725          96 :     return aName;
     726             : }
     727             : 
     728         182 : void UnoButtonControl::dispose() throw(uno::RuntimeException)
     729             : {
     730         182 :     lang::EventObject aEvt;
     731         182 :     aEvt.Source = (::cppu::OWeakObject*)this;
     732         182 :     maActionListeners.disposeAndClear( aEvt );
     733         182 :     maItemListeners.disposeAndClear( aEvt );
     734         182 :     UnoControlBase::dispose();
     735         182 : }
     736             : 
     737          50 : void UnoButtonControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer >  & rParentPeer ) throw(uno::RuntimeException)
     738             : {
     739          50 :     UnoControlBase::createPeer( rxToolkit, rParentPeer );
     740             : 
     741          50 :     uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
     742          50 :     xButton->setActionCommand( maActionCommand );
     743          50 :     if ( maActionListeners.getLength() )
     744          45 :         xButton->addActionListener( &maActionListeners );
     745             : 
     746         100 :     uno::Reference< XToggleButton > xPushButton( getPeer(), uno::UNO_QUERY );
     747          50 :     if ( xPushButton.is() )
     748         100 :         xPushButton->addItemListener( this );
     749          50 : }
     750             : 
     751         121 : void UnoButtonControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
     752             : {
     753         121 :     maActionListeners.addInterface( l );
     754         121 :     if( getPeer().is() && maActionListeners.getLength() == 1 )
     755             :     {
     756           2 :         uno::Reference < awt::XButton >  xButton( getPeer(), uno::UNO_QUERY );
     757           2 :         xButton->addActionListener( &maActionListeners );
     758             :     }
     759         121 : }
     760             : 
     761           1 : void UnoButtonControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
     762             : {
     763           1 :     if( getPeer().is() && maActionListeners.getLength() == 1 )
     764             :     {
     765           1 :         uno::Reference < awt::XButton >  xButton( getPeer(), uno::UNO_QUERY );
     766           1 :         xButton->removeActionListener( &maActionListeners );
     767             :     }
     768           1 :     maActionListeners.removeInterface( l );
     769           1 : }
     770             : 
     771           2 : void UnoButtonControl::addItemListener(const uno::Reference< awt::XItemListener > & l) throw(uno::RuntimeException)
     772             : {
     773           2 :     maItemListeners.addInterface( l );
     774           2 : }
     775             : 
     776           1 : void UnoButtonControl::removeItemListener(const uno::Reference< awt::XItemListener > & l) throw(uno::RuntimeException)
     777             : {
     778           1 :     maItemListeners.removeInterface( l );
     779           1 : }
     780             : 
     781         319 : void SAL_CALL UnoButtonControl::disposing( const lang::EventObject& Source ) throw (uno::RuntimeException)
     782             : {
     783         319 :     UnoControlBase::disposing( Source );
     784         319 : }
     785             : 
     786           0 : void SAL_CALL UnoButtonControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw (uno::RuntimeException)
     787             : {
     788             :     // forward to model
     789           0 :     uno::Any aAny;
     790           0 :     aAny <<= (sal_Int16)rEvent.Selected;
     791           0 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, sal_False );
     792             : 
     793             :     // multiplex
     794           0 :     ItemEvent aEvent( rEvent );
     795           0 :     aEvent.Source = *this;
     796           0 :     maItemListeners.itemStateChanged( aEvent );
     797           0 : }
     798             : 
     799           2 : void UnoButtonControl::setLabel( const OUString&  rLabel ) throw(uno::RuntimeException)
     800             : {
     801           2 :     uno::Any aAny;
     802           2 :     aAny <<= rLabel;
     803           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, sal_True );
     804           2 : }
     805             : 
     806           2 : void UnoButtonControl::setActionCommand( const OUString& rCommand ) throw(uno::RuntimeException)
     807             : {
     808           2 :     maActionCommand = rCommand;
     809           2 :     if ( getPeer().is() )
     810             :     {
     811           2 :         uno::Reference < awt::XButton >  xButton( getPeer(), uno::UNO_QUERY );
     812           2 :         xButton->setActionCommand( rCommand );
     813             :     }
     814           2 : }
     815             : 
     816           2 : awt::Size UnoButtonControl::getMinimumSize(  ) throw(uno::RuntimeException)
     817             : {
     818           2 :     return Impl_getMinimumSize();
     819             : }
     820             : 
     821           2 : awt::Size UnoButtonControl::getPreferredSize(  ) throw(uno::RuntimeException)
     822             : {
     823           2 :     return Impl_getPreferredSize();
     824             : }
     825             : 
     826           2 : awt::Size UnoButtonControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
     827             : {
     828           2 :     return Impl_calcAdjustedSize( rNewSize );
     829             : }
     830             : 
     831             : //  ----------------------------------------------------
     832             : //  class UnoControlImageControlModel
     833             : //  ----------------------------------------------------
     834          24 : UnoControlImageControlModel::UnoControlImageControlModel( const Reference< XComponentContext >& rxContext )
     835             :     :GraphicControlModel( rxContext )
     836          24 :     ,mbAdjustingImageScaleMode( false )
     837             : {
     838          24 :     UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXImageControl );
     839          24 : }
     840             : 
     841           1 : OUString UnoControlImageControlModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
     842             : {
     843           1 :     return OUString::createFromAscii( szServiceName_UnoControlImageControlModel );
     844             : }
     845             : 
     846         434 : uno::Any UnoControlImageControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
     847             : {
     848         434 :     if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
     849          27 :         return uno::makeAny( OUString::createFromAscii( szServiceName_UnoControlImageControl ) );
     850             : 
     851         407 :     if ( nPropId == BASEPROPERTY_IMAGE_SCALE_MODE )
     852          27 :         return makeAny( awt::ImageScaleMode::ANISOTROPIC );
     853             : 
     854         380 :     return GraphicControlModel::ImplGetDefaultValue( nPropId );
     855             : }
     856             : 
     857        2492 : ::cppu::IPropertyArrayHelper& UnoControlImageControlModel::getInfoHelper()
     858             : {
     859             :     static UnoPropertyArrayHelper* pHelper = NULL;
     860        2492 :     if ( !pHelper )
     861             :     {
     862           3 :         uno::Sequence<sal_Int32>    aIDs = ImplGetPropertyIds();
     863           3 :         pHelper = new UnoPropertyArrayHelper( aIDs );
     864             :     }
     865        2492 :     return *pHelper;
     866             : }
     867             : 
     868             : // beans::XMultiPropertySet
     869          38 : uno::Reference< beans::XPropertySetInfo > UnoControlImageControlModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
     870             : {
     871          38 :     static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
     872          38 :     return xInfo;
     873             : }
     874             : 
     875         308 : void SAL_CALL UnoControlImageControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::uno::Exception)
     876             : {
     877         308 :     GraphicControlModel::setFastPropertyValue_NoBroadcast( _nHandle, _rValue );
     878             : 
     879             :     // ScaleImage is an older (and less powerful) version of ScaleMode, but keep both in sync as far as possible
     880             :     try
     881             :     {
     882         308 :         switch ( _nHandle )
     883             :         {
     884             :         case BASEPROPERTY_IMAGE_SCALE_MODE:
     885          44 :             if ( !mbAdjustingImageScaleMode && ImplHasProperty( BASEPROPERTY_SCALEIMAGE ) )
     886             :             {
     887          22 :                 mbAdjustingImageScaleMode = true;
     888          22 :                 sal_Int16 nScaleMode( awt::ImageScaleMode::ANISOTROPIC );
     889          22 :                 OSL_VERIFY( _rValue >>= nScaleMode );
     890          22 :                 setDependentFastPropertyValue( BASEPROPERTY_SCALEIMAGE, uno::makeAny( sal_Bool( nScaleMode != awt::ImageScaleMode::NONE ) ) );
     891          22 :                 mbAdjustingImageScaleMode = false;
     892             :             }
     893          44 :             break;
     894             :         case BASEPROPERTY_SCALEIMAGE:
     895          44 :             if ( !mbAdjustingImageScaleMode && ImplHasProperty( BASEPROPERTY_IMAGE_SCALE_MODE ) )
     896             :             {
     897          22 :                 mbAdjustingImageScaleMode = true;
     898          22 :                 sal_Bool bScale = sal_True;
     899          22 :                 OSL_VERIFY( _rValue >>= bScale );
     900          22 :                 setDependentFastPropertyValue( BASEPROPERTY_IMAGE_SCALE_MODE, uno::makeAny( bScale ? awt::ImageScaleMode::ANISOTROPIC : awt::ImageScaleMode::NONE ) );
     901          22 :                 mbAdjustingImageScaleMode = false;
     902             :             }
     903          44 :             break;
     904             :         }
     905             :     }
     906           0 :     catch( const Exception& )
     907             :     {
     908           0 :         mbAdjustingImageScaleMode = false;
     909           0 :         throw;
     910             :     }
     911         308 : }
     912             : 
     913             : //  ----------------------------------------------------
     914             : //  class UnoImageControlControl
     915             : //  ----------------------------------------------------
     916          11 : UnoImageControlControl::UnoImageControlControl()
     917             :     :UnoImageControlControl_Base()
     918          11 :     ,maActionListeners( *this )
     919             : {
     920             :     // TODO: Where should I look for defaults?
     921          11 :     maComponentInfos.nWidth = 100;
     922          11 :     maComponentInfos.nHeight = 100;
     923          11 : }
     924             : 
     925          11 : OUString UnoImageControlControl::GetComponentServiceName()
     926             : {
     927          11 :     return OUString("fixedimage");
     928             : }
     929             : 
     930          12 : void UnoImageControlControl::dispose() throw(uno::RuntimeException)
     931             : {
     932          12 :     lang::EventObject aEvt;
     933          12 :     aEvt.Source = (::cppu::OWeakObject*)this;
     934          12 :     maActionListeners.disposeAndClear( aEvt );
     935          12 :     UnoControl::dispose();
     936          12 : }
     937             : 
     938           2 : sal_Bool UnoImageControlControl::isTransparent() throw(uno::RuntimeException)
     939             : {
     940           2 :     return sal_True;
     941             : }
     942             : 
     943           3 : awt::Size UnoImageControlControl::getMinimumSize(  ) throw(uno::RuntimeException)
     944             : {
     945           3 :     return Impl_getMinimumSize();
     946             : }
     947             : 
     948           3 : awt::Size UnoImageControlControl::getPreferredSize(  ) throw(uno::RuntimeException)
     949             : {
     950           3 :     return Impl_getPreferredSize();
     951             : }
     952             : 
     953           3 : awt::Size UnoImageControlControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
     954             : {
     955           3 :     return Impl_calcAdjustedSize( rNewSize );
     956             : }
     957             : 
     958             : //  ----------------------------------------------------
     959             : //  class UnoControlRadioButtonModel
     960             : //  ----------------------------------------------------
     961          25 : UnoControlRadioButtonModel::UnoControlRadioButtonModel( const Reference< XComponentContext >& rxContext )
     962          25 :     :GraphicControlModel( rxContext )
     963             : {
     964          25 :     UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXRadioButton );
     965          25 : }
     966             : 
     967           1 : OUString UnoControlRadioButtonModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
     968             : {
     969           1 :     return OUString::createFromAscii( szServiceName_UnoControlRadioButtonModel );
     970             : }
     971             : 
     972         719 : uno::Any UnoControlRadioButtonModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
     973             : {
     974         719 :     switch ( nPropId )
     975             :     {
     976             :     case BASEPROPERTY_DEFAULTCONTROL:
     977          27 :         return uno::makeAny( OUString::createFromAscii( szServiceName_UnoControlRadioButton ) );
     978             : 
     979             :     case BASEPROPERTY_VISUALEFFECT:
     980          28 :         return uno::makeAny( (sal_Int16)awt::VisualEffect::LOOK3D );
     981             :     }
     982             : 
     983         664 :     return GraphicControlModel::ImplGetDefaultValue( nPropId );
     984             : }
     985             : 
     986        5561 : ::cppu::IPropertyArrayHelper& UnoControlRadioButtonModel::getInfoHelper()
     987             : {
     988             :     static UnoPropertyArrayHelper* pHelper = NULL;
     989        5561 :     if ( !pHelper )
     990             :     {
     991           5 :         uno::Sequence<sal_Int32>    aIDs = ImplGetPropertyIds();
     992           5 :         pHelper = new UnoPropertyArrayHelper( aIDs );
     993             :     }
     994        5561 :     return *pHelper;
     995             : }
     996             : 
     997             : // beans::XMultiPropertySet
     998          62 : uno::Reference< beans::XPropertySetInfo > UnoControlRadioButtonModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
     999             : {
    1000          62 :     static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
    1001          62 :     return xInfo;
    1002             : }
    1003             : 
    1004             : 
    1005             : 
    1006             : //  ----------------------------------------------------
    1007             : //  class UnoRadioButtonControl
    1008             : //  ----------------------------------------------------
    1009          17 : UnoRadioButtonControl::UnoRadioButtonControl()
    1010             :     :UnoRadioButtonControl_Base()
    1011             :     ,maItemListeners( *this )
    1012          17 :     ,maActionListeners( *this )
    1013             : {
    1014          17 :     maComponentInfos.nWidth = 100;
    1015          17 :     maComponentInfos.nHeight = 12;
    1016          17 : }
    1017             : 
    1018          19 : OUString UnoRadioButtonControl::GetComponentServiceName()
    1019             : {
    1020          19 :     return OUString("radiobutton");
    1021             : }
    1022             : 
    1023          16 : void UnoRadioButtonControl::dispose() throw(uno::RuntimeException)
    1024             : {
    1025          16 :     lang::EventObject aEvt;
    1026          16 :     aEvt.Source = (::cppu::OWeakObject*)this;
    1027          16 :     maItemListeners.disposeAndClear( aEvt );
    1028          16 :     UnoControlBase::dispose();
    1029          16 : }
    1030             : 
    1031             : 
    1032           2 : sal_Bool UnoRadioButtonControl::isTransparent() throw(uno::RuntimeException)
    1033             : {
    1034           2 :     return sal_True;
    1035             : }
    1036             : 
    1037          21 : void UnoRadioButtonControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer >  & rParentPeer ) throw(uno::RuntimeException)
    1038             : {
    1039          21 :     UnoControlBase::createPeer( rxToolkit, rParentPeer );
    1040             : 
    1041          21 :     uno::Reference < awt::XRadioButton >  xRadioButton( getPeer(), uno::UNO_QUERY );
    1042          21 :     xRadioButton->addItemListener( this );
    1043             : 
    1044          42 :     uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
    1045          21 :     xButton->setActionCommand( maActionCommand );
    1046          21 :     if ( maActionListeners.getLength() )
    1047           0 :         xButton->addActionListener( &maActionListeners );
    1048             : 
    1049             :     // as default, set the "AutoToggle" to true
    1050             :     // (it is set to false in VCLXToolkit::ImplCreateWindow because of #87254#, but we want to
    1051             :     // have it enabled by default because of 85071)
    1052          42 :     uno::Reference< awt::XVclWindowPeer >  xVclWindowPeer( getPeer(), uno::UNO_QUERY );
    1053          21 :     if ( xVclWindowPeer.is() )
    1054          42 :         xVclWindowPeer->setProperty( GetPropertyName( BASEPROPERTY_AUTOTOGGLE ), ::cppu::bool2any( sal_True ) );
    1055          21 : }
    1056             : 
    1057           3 : void UnoRadioButtonControl::addItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
    1058             : {
    1059           3 :     maItemListeners.addInterface( l );
    1060           3 : }
    1061             : 
    1062           0 : void UnoRadioButtonControl::removeItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
    1063             : {
    1064           0 :     maItemListeners.removeInterface( l );
    1065           0 : }
    1066             : 
    1067           1 : void UnoRadioButtonControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
    1068             : {
    1069           1 :     maActionListeners.addInterface( l );
    1070           1 :     if( getPeer().is() && maActionListeners.getLength() == 1 )
    1071             :     {
    1072           1 :         uno::Reference < awt::XButton >  xButton( getPeer(), uno::UNO_QUERY );
    1073           1 :         xButton->addActionListener( &maActionListeners );
    1074             :     }
    1075           1 : }
    1076             : 
    1077           0 : void UnoRadioButtonControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
    1078             : {
    1079           0 :     if( getPeer().is() && maActionListeners.getLength() == 1 )
    1080             :     {
    1081           0 :         uno::Reference < awt::XButton >  xButton( getPeer(), uno::UNO_QUERY );
    1082           0 :         xButton->removeActionListener( &maActionListeners );
    1083             :     }
    1084           0 :     maActionListeners.removeInterface( l );
    1085           0 : }
    1086             : 
    1087           2 : void UnoRadioButtonControl::setLabel( const OUString&  rLabel ) throw(uno::RuntimeException)
    1088             : {
    1089           2 :     uno::Any aAny;
    1090           2 :     aAny <<= rLabel;
    1091           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, sal_True );
    1092           2 : }
    1093             : 
    1094           0 : void UnoRadioButtonControl::setActionCommand( const OUString& rCommand ) throw(uno::RuntimeException)
    1095             : {
    1096           0 :     maActionCommand = rCommand;
    1097           0 :     if ( getPeer().is() )
    1098             :     {
    1099           0 :         uno::Reference < awt::XButton >  xButton( getPeer(), uno::UNO_QUERY );
    1100           0 :         xButton->setActionCommand( rCommand );
    1101             :     }
    1102           0 : }
    1103             : 
    1104           2 : void UnoRadioButtonControl::setState( sal_Bool bOn ) throw(uno::RuntimeException)
    1105             : {
    1106           2 :     sal_Int16 nState = bOn ? 1 : 0;
    1107           2 :     uno::Any aAny;
    1108           2 :     aAny <<= nState;
    1109           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, sal_True );
    1110           2 : }
    1111             : 
    1112           4 : sal_Bool UnoRadioButtonControl::getState() throw(uno::RuntimeException)
    1113             : {
    1114           4 :     sal_Int16 nState = 0;
    1115           4 :     uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ) );
    1116           4 :     aVal >>= nState;
    1117           4 :     return nState ? sal_True : sal_False;
    1118             : }
    1119             : 
    1120           0 : void UnoRadioButtonControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw(uno::RuntimeException)
    1121             : {
    1122           0 :     uno::Any aAny;
    1123           0 :     aAny <<= (sal_Int16)rEvent.Selected;
    1124           0 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, sal_False );
    1125             : 
    1126             :     // compatibility:
    1127             :     // in OOo 1.0.x, when the user clicked a radio button in a group of buttons, this resulted
    1128             :     // in _one_ itemStateChanged call for exactly the radio button which's state changed from
    1129             :     // "0" to "1".
    1130             :     // Nowadays, since the listener handling changed a lot towards 1.1 (the VCLXWindow reacts on more
    1131             :     // basic events from the VCL-windows, not anymore on the Link-based events like in 1.0.x), this
    1132             :     // isn't the case anymore: For instance, this method here gets called for the radio button
    1133             :     // which is being implicitily _de_selected, too. This is pretty bad for compatibility.
    1134             :     // Thus, we suppress all events with a new state other than "1". This is unlogical, and weird, when looking
    1135             :     // from a pure API perspective, but it's _compatible_ with older product versions, and this is
    1136             :     // all which matters here.
    1137             :     // #i14703#
    1138           0 :     if ( 1 == rEvent.Selected )
    1139             :     {
    1140           0 :         if ( maItemListeners.getLength() )
    1141           0 :             maItemListeners.itemStateChanged( rEvent );
    1142           0 :     }
    1143             :         // note that speaking stricly, this is wrong: When in 1.0.x, the user would have de-selected
    1144             :         // a radio button _without_ selecing another one, this would have caused a notification.
    1145             :         // With the change done here, this today won't cause a notification anymore.
    1146             :         //
    1147             :         // Fortunately, it's not possible for the user to de-select a radio button without selecting another on,
    1148             :         // at least not via the regular UI. It _would_ be possible via the Accessibility API, which
    1149             :         // counts as "user input", too. But in 1.0.x, there was no Accessibility API, so there is nothing
    1150             :         // to be inconsistent with.
    1151           0 : }
    1152             : 
    1153           2 : awt::Size UnoRadioButtonControl::getMinimumSize(  ) throw(uno::RuntimeException)
    1154             : {
    1155           2 :     return Impl_getMinimumSize();
    1156             : }
    1157             : 
    1158           2 : awt::Size UnoRadioButtonControl::getPreferredSize(  ) throw(uno::RuntimeException)
    1159             : {
    1160           2 :     return Impl_getPreferredSize();
    1161             : }
    1162             : 
    1163           2 : awt::Size UnoRadioButtonControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
    1164             : {
    1165           2 :     return Impl_calcAdjustedSize( rNewSize );
    1166             : }
    1167             : 
    1168             : //  ----------------------------------------------------
    1169             : //  class UnoControlCheckBoxModel
    1170             : //  ----------------------------------------------------
    1171          23 : UnoControlCheckBoxModel::UnoControlCheckBoxModel( const Reference< XComponentContext >& rxContext )
    1172          23 :     :GraphicControlModel( rxContext )
    1173             : {
    1174          23 :     UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXCheckBox );
    1175          23 : }
    1176             : 
    1177           1 : OUString UnoControlCheckBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
    1178             : {
    1179           1 :     return OUString::createFromAscii( szServiceName_UnoControlCheckBoxModel );
    1180             : }
    1181             : 
    1182         666 : uno::Any UnoControlCheckBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
    1183             : {
    1184         666 :     switch ( nPropId )
    1185             :     {
    1186             :     case BASEPROPERTY_DEFAULTCONTROL:
    1187          25 :         return uno::makeAny( OUString::createFromAscii( szServiceName_UnoControlCheckBox ) );
    1188             : 
    1189             :     case BASEPROPERTY_VISUALEFFECT:
    1190          26 :         return uno::makeAny( (sal_Int16)awt::VisualEffect::LOOK3D );
    1191             :     }
    1192             : 
    1193         615 :     return GraphicControlModel::ImplGetDefaultValue( nPropId );
    1194             : }
    1195             : 
    1196        5223 : ::cppu::IPropertyArrayHelper& UnoControlCheckBoxModel::getInfoHelper()
    1197             : {
    1198             :     static UnoPropertyArrayHelper* pHelper = NULL;
    1199        5223 :     if ( !pHelper )
    1200             :     {
    1201           6 :         uno::Sequence<sal_Int32>    aIDs = ImplGetPropertyIds();
    1202           6 :         pHelper = new UnoPropertyArrayHelper( aIDs );
    1203             :     }
    1204        5223 :     return *pHelper;
    1205             : }
    1206             : 
    1207             : // beans::XMultiPropertySet
    1208          55 : uno::Reference< beans::XPropertySetInfo > UnoControlCheckBoxModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
    1209             : {
    1210          55 :     static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
    1211          55 :     return xInfo;
    1212             : }
    1213             : 
    1214             : 
    1215             : 
    1216             : //  ----------------------------------------------------
    1217             : //  class UnoCheckBoxControl
    1218             : //  ----------------------------------------------------
    1219          18 : UnoCheckBoxControl::UnoCheckBoxControl()
    1220             :     :UnoCheckBoxControl_Base()
    1221          18 :     ,maItemListeners( *this ), maActionListeners( *this )
    1222             : {
    1223          18 :     maComponentInfos.nWidth = 100;
    1224          18 :     maComponentInfos.nHeight = 12;
    1225          18 : }
    1226             : 
    1227          19 : OUString UnoCheckBoxControl::GetComponentServiceName()
    1228             : {
    1229          19 :     return OUString("checkbox");
    1230             : }
    1231             : 
    1232          17 : void UnoCheckBoxControl::dispose() throw(uno::RuntimeException)
    1233             : {
    1234          17 :     lang::EventObject aEvt;
    1235          17 :     aEvt.Source = (::cppu::OWeakObject*)this;
    1236          17 :     maItemListeners.disposeAndClear( aEvt );
    1237          17 :     UnoControlBase::dispose();
    1238          17 : }
    1239             : 
    1240           2 : sal_Bool UnoCheckBoxControl::isTransparent() throw(uno::RuntimeException)
    1241             : {
    1242           2 :     return sal_True;
    1243             : }
    1244             : 
    1245          21 : void UnoCheckBoxControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer >  & rParentPeer ) throw(uno::RuntimeException)
    1246             : {
    1247          21 :     UnoControlBase::createPeer( rxToolkit, rParentPeer );
    1248             : 
    1249          21 :     uno::Reference < awt::XCheckBox >  xCheckBox( getPeer(), uno::UNO_QUERY );
    1250          21 :     xCheckBox->addItemListener( this );
    1251             : 
    1252          42 :     uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
    1253          21 :     xButton->setActionCommand( maActionCommand );
    1254          21 :     if ( maActionListeners.getLength() )
    1255          21 :         xButton->addActionListener( &maActionListeners );
    1256          21 : }
    1257             : 
    1258           5 : void UnoCheckBoxControl::addItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
    1259             : {
    1260           5 :     maItemListeners.addInterface( l );
    1261           5 : }
    1262             : 
    1263           2 : void UnoCheckBoxControl::removeItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
    1264             : {
    1265           2 :     maItemListeners.removeInterface( l );
    1266           2 : }
    1267             : 
    1268           1 : void UnoCheckBoxControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
    1269             : {
    1270           1 :     maActionListeners.addInterface( l );
    1271           1 :     if( getPeer().is() && maActionListeners.getLength() == 1 )
    1272             :     {
    1273           1 :         uno::Reference < awt::XButton >  xButton( getPeer(), uno::UNO_QUERY );
    1274           1 :         xButton->addActionListener( &maActionListeners );
    1275             :     }
    1276           1 : }
    1277             : 
    1278           0 : void UnoCheckBoxControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
    1279             : {
    1280           0 :     if( getPeer().is() && maActionListeners.getLength() == 1 )
    1281             :     {
    1282           0 :         uno::Reference < awt::XButton >  xButton( getPeer(), uno::UNO_QUERY );
    1283           0 :         xButton->removeActionListener( &maActionListeners );
    1284             :     }
    1285           0 :     maActionListeners.removeInterface( l );
    1286           0 : }
    1287             : 
    1288           0 : void UnoCheckBoxControl::setActionCommand( const OUString& rCommand ) throw(uno::RuntimeException)
    1289             : {
    1290           0 :     maActionCommand = rCommand;
    1291           0 :     if ( getPeer().is() )
    1292             :     {
    1293           0 :         uno::Reference < awt::XButton > xButton( getPeer(), uno::UNO_QUERY );
    1294           0 :         xButton->setActionCommand( rCommand );
    1295             :     }
    1296           0 : }
    1297             : 
    1298             : 
    1299           2 : void UnoCheckBoxControl::setLabel( const OUString&  rLabel ) throw(uno::RuntimeException)
    1300             : {
    1301           2 :     uno::Any aAny;
    1302           2 :     aAny <<= rLabel;
    1303           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, sal_True );
    1304           2 : }
    1305             : 
    1306           2 : void UnoCheckBoxControl::setState( short n ) throw(uno::RuntimeException)
    1307             : {
    1308           2 :     uno::Any aAny;
    1309           2 :     aAny <<= (sal_Int16)n;
    1310           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, sal_True );
    1311           2 : }
    1312             : 
    1313           4 : short UnoCheckBoxControl::getState() throw(uno::RuntimeException)
    1314             : {
    1315           4 :     short nState = 0;
    1316           4 :     uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ) );
    1317           4 :     aVal >>= nState;
    1318           4 :     return nState;
    1319             : }
    1320             : 
    1321           2 : void UnoCheckBoxControl::enableTriState( sal_Bool b ) throw(uno::RuntimeException)
    1322             : {
    1323           2 :     uno::Any aAny;
    1324           2 :     aAny <<= b;
    1325           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TRISTATE ), aAny, sal_True );
    1326           2 : }
    1327             : 
    1328           0 : void UnoCheckBoxControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw(uno::RuntimeException)
    1329             : {
    1330           0 :     uno::Any aAny;
    1331           0 :     aAny <<= (sal_Int16)rEvent.Selected;
    1332           0 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STATE ), aAny, sal_False );
    1333             : 
    1334           0 :     if ( maItemListeners.getLength() )
    1335           0 :         maItemListeners.itemStateChanged( rEvent );
    1336           0 : }
    1337             : 
    1338           2 : awt::Size UnoCheckBoxControl::getMinimumSize(  ) throw(uno::RuntimeException)
    1339             : {
    1340           2 :     return Impl_getMinimumSize();
    1341             : }
    1342             : 
    1343           2 : awt::Size UnoCheckBoxControl::getPreferredSize(  ) throw(uno::RuntimeException)
    1344             : {
    1345           2 :     return Impl_getPreferredSize();
    1346             : }
    1347             : 
    1348           2 : awt::Size UnoCheckBoxControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
    1349             : {
    1350           2 :     return Impl_calcAdjustedSize( rNewSize );
    1351             : }
    1352             : 
    1353             : //  ----------------------------------------------------
    1354             : //  class UnoControlFixedHyperlinkModel
    1355             : //  ----------------------------------------------------
    1356           0 : UnoControlFixedHyperlinkModel::UnoControlFixedHyperlinkModel( const Reference< XComponentContext >& rxContext )
    1357           0 :     :UnoControlModel( rxContext )
    1358             : {
    1359           0 :     UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXFixedHyperlink );
    1360           0 : }
    1361             : 
    1362           0 : OUString UnoControlFixedHyperlinkModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
    1363             : {
    1364           0 :     return OUString::createFromAscii( szServiceName_UnoControlFixedHyperlinkModel );
    1365             : }
    1366             : 
    1367           0 : uno::Any UnoControlFixedHyperlinkModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
    1368             : {
    1369           0 :     if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
    1370             :     {
    1371           0 :         uno::Any aAny;
    1372           0 :         aAny <<= OUString::createFromAscii( szServiceName_UnoControlFixedHyperlink );
    1373           0 :         return aAny;
    1374             :     }
    1375           0 :     else if ( nPropId == BASEPROPERTY_BORDER )
    1376             :     {
    1377           0 :         uno::Any aAny;
    1378           0 :         aAny <<= (sal_Int16)0;
    1379           0 :         return aAny;
    1380             :     }
    1381           0 :     else if ( nPropId == BASEPROPERTY_URL )
    1382             :     {
    1383           0 :         uno::Any aAny;
    1384           0 :         aAny <<= OUString();
    1385           0 :         return aAny;
    1386             :     }
    1387             : 
    1388           0 :     return UnoControlModel::ImplGetDefaultValue( nPropId );
    1389             : }
    1390             : 
    1391           0 : ::cppu::IPropertyArrayHelper& UnoControlFixedHyperlinkModel::getInfoHelper()
    1392             : {
    1393             :     static UnoPropertyArrayHelper* pHelper = NULL;
    1394           0 :     if ( !pHelper )
    1395             :     {
    1396           0 :         uno::Sequence<sal_Int32>    aIDs = ImplGetPropertyIds();
    1397           0 :         pHelper = new UnoPropertyArrayHelper( aIDs );
    1398             :     }
    1399           0 :     return *pHelper;
    1400             : }
    1401             : 
    1402             : // beans::XMultiPropertySet
    1403           0 : uno::Reference< beans::XPropertySetInfo > UnoControlFixedHyperlinkModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
    1404             : {
    1405           0 :     static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
    1406           0 :     return xInfo;
    1407             : }
    1408             : 
    1409             : //  ----------------------------------------------------
    1410             : //  class UnoFixedHyperlinkControl
    1411             : //  ----------------------------------------------------
    1412           0 : UnoFixedHyperlinkControl::UnoFixedHyperlinkControl()
    1413             :     :UnoControlBase()
    1414           0 :     ,maActionListeners( *this )
    1415             : {
    1416           0 :     maComponentInfos.nWidth = 100;
    1417           0 :     maComponentInfos.nHeight = 12;
    1418           0 : }
    1419             : 
    1420           0 : OUString UnoFixedHyperlinkControl::GetComponentServiceName()
    1421             : {
    1422           0 :     return OUString("fixedhyperlink");
    1423             : }
    1424             : 
    1425             : // uno::XInterface
    1426           0 : uno::Any UnoFixedHyperlinkControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
    1427             : {
    1428             :     uno::Any aRet = ::cppu::queryInterface( rType,
    1429             :                                         (static_cast< awt::XFixedHyperlink* >(this)),
    1430           0 :                                         (static_cast< awt::XLayoutConstrains* >(this)) );
    1431           0 :     return (aRet.hasValue() ? aRet : UnoControlBase::queryAggregation( rType ));
    1432             : }
    1433             : 
    1434             : // lang::XTypeProvider
    1435           0 : IMPL_XTYPEPROVIDER_START( UnoFixedHyperlinkControl )
    1436           0 :     getCppuType( ( uno::Reference< awt::XFixedHyperlink>* ) NULL ),
    1437           0 :     getCppuType( ( uno::Reference< awt::XLayoutConstrains>* ) NULL ),
    1438             :     UnoControlBase::getTypes()
    1439           0 : IMPL_XTYPEPROVIDER_END
    1440             : 
    1441           0 : sal_Bool UnoFixedHyperlinkControl::isTransparent() throw(uno::RuntimeException)
    1442             : {
    1443           0 :     return sal_True;
    1444             : }
    1445             : 
    1446           0 : void UnoFixedHyperlinkControl::setText( const OUString& Text ) throw(uno::RuntimeException)
    1447             : {
    1448           0 :     uno::Any aAny;
    1449           0 :     aAny <<= Text;
    1450           0 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, sal_True );
    1451           0 : }
    1452             : 
    1453           0 : OUString UnoFixedHyperlinkControl::getText() throw(uno::RuntimeException)
    1454             : {
    1455           0 :     return ImplGetPropertyValue_UString( BASEPROPERTY_LABEL );
    1456             : }
    1457             : 
    1458           0 : void UnoFixedHyperlinkControl::setURL( const OUString& URL ) throw(::com::sun::star::uno::RuntimeException)
    1459             : {
    1460           0 :     uno::Any aAny;
    1461           0 :     aAny <<= URL;
    1462           0 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_URL ), aAny, sal_True );
    1463           0 : }
    1464             : 
    1465           0 : OUString UnoFixedHyperlinkControl::getURL(  ) throw(::com::sun::star::uno::RuntimeException)
    1466             : {
    1467           0 :     return ImplGetPropertyValue_UString( BASEPROPERTY_URL );
    1468             : }
    1469             : 
    1470           0 : void UnoFixedHyperlinkControl::setAlignment( short nAlign ) throw(uno::RuntimeException)
    1471             : {
    1472           0 :     uno::Any aAny;
    1473           0 :     aAny <<= (sal_Int16)nAlign;
    1474           0 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN ), aAny, sal_True );
    1475           0 : }
    1476             : 
    1477           0 : short UnoFixedHyperlinkControl::getAlignment() throw(uno::RuntimeException)
    1478             : {
    1479           0 :     short nAlign = 0;
    1480           0 :     if ( mxModel.is() )
    1481             :     {
    1482           0 :         uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN ) );
    1483           0 :         aVal >>= nAlign;
    1484             :     }
    1485           0 :     return nAlign;
    1486             : }
    1487             : 
    1488           0 : awt::Size UnoFixedHyperlinkControl::getMinimumSize(  ) throw(uno::RuntimeException)
    1489             : {
    1490           0 :     return Impl_getMinimumSize();
    1491             : }
    1492             : 
    1493           0 : awt::Size UnoFixedHyperlinkControl::getPreferredSize(  ) throw(uno::RuntimeException)
    1494             : {
    1495           0 :     return Impl_getPreferredSize();
    1496             : }
    1497             : 
    1498           0 : awt::Size UnoFixedHyperlinkControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
    1499             : {
    1500           0 :     return Impl_calcAdjustedSize( rNewSize );
    1501             : }
    1502             : 
    1503           0 : void UnoFixedHyperlinkControl::dispose() throw(uno::RuntimeException)
    1504             : {
    1505           0 :     lang::EventObject aEvt;
    1506           0 :     aEvt.Source = (::cppu::OWeakObject*)this;
    1507           0 :     maActionListeners.disposeAndClear( aEvt );
    1508           0 :     UnoControlBase::dispose();
    1509           0 : }
    1510             : 
    1511           0 : void UnoFixedHyperlinkControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer >  & rParentPeer ) throw(uno::RuntimeException)
    1512             : {
    1513           0 :     UnoControlBase::createPeer( rxToolkit, rParentPeer );
    1514             : 
    1515           0 :     uno::Reference < awt::XFixedHyperlink > xFixedHyperlink( getPeer(), uno::UNO_QUERY );
    1516           0 :     if ( maActionListeners.getLength() )
    1517           0 :         xFixedHyperlink->addActionListener( &maActionListeners );
    1518           0 : }
    1519             : 
    1520           0 : void UnoFixedHyperlinkControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
    1521             : {
    1522           0 :     maActionListeners.addInterface( l );
    1523           0 :     if( getPeer().is() && maActionListeners.getLength() == 1 )
    1524             :     {
    1525           0 :         uno::Reference < awt::XFixedHyperlink >  xFixedHyperlink( getPeer(), uno::UNO_QUERY );
    1526           0 :         xFixedHyperlink->addActionListener( &maActionListeners );
    1527             :     }
    1528           0 : }
    1529             : 
    1530           0 : void UnoFixedHyperlinkControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
    1531             : {
    1532           0 :     if( getPeer().is() && maActionListeners.getLength() == 1 )
    1533             :     {
    1534           0 :         uno::Reference < awt::XFixedHyperlink >  xFixedHyperlink( getPeer(), uno::UNO_QUERY );
    1535           0 :         xFixedHyperlink->removeActionListener( &maActionListeners );
    1536             :     }
    1537           0 :     maActionListeners.removeInterface( l );
    1538           0 : }
    1539             : 
    1540             : //  ----------------------------------------------------
    1541             : //  class UnoControlFixedTextModel
    1542             : //  ----------------------------------------------------
    1543          79 : UnoControlFixedTextModel::UnoControlFixedTextModel( const Reference< XComponentContext >& rxContext )
    1544          79 :     :UnoControlModel( rxContext )
    1545             : {
    1546          79 :     UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXFixedText );
    1547          79 : }
    1548             : 
    1549           1 : OUString UnoControlFixedTextModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
    1550             : {
    1551           1 :     return OUString::createFromAscii( szServiceName_UnoControlFixedTextModel );
    1552             : }
    1553             : 
    1554        1863 : uno::Any UnoControlFixedTextModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
    1555             : {
    1556        1863 :     if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
    1557             :     {
    1558          81 :         uno::Any aAny;
    1559          81 :         aAny <<= OUString::createFromAscii( szServiceName_UnoControlFixedText );
    1560          81 :         return aAny;
    1561             :     }
    1562        1782 :     else if ( nPropId == BASEPROPERTY_BORDER )
    1563             :     {
    1564          81 :         uno::Any aAny;
    1565          81 :         aAny <<= (sal_Int16)0;
    1566          81 :         return aAny;
    1567             :     }
    1568             : 
    1569        1701 :     return UnoControlModel::ImplGetDefaultValue( nPropId );
    1570             : }
    1571             : 
    1572        3352 : ::cppu::IPropertyArrayHelper& UnoControlFixedTextModel::getInfoHelper()
    1573             : {
    1574             :     static UnoPropertyArrayHelper* pHelper = NULL;
    1575        3352 :     if ( !pHelper )
    1576             :     {
    1577           3 :         uno::Sequence<sal_Int32>    aIDs = ImplGetPropertyIds();
    1578           3 :         pHelper = new UnoPropertyArrayHelper( aIDs );
    1579             :     }
    1580        3352 :     return *pHelper;
    1581             : }
    1582             : 
    1583             : // beans::XMultiPropertySet
    1584          96 : uno::Reference< beans::XPropertySetInfo > UnoControlFixedTextModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
    1585             : {
    1586          96 :     static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
    1587          96 :     return xInfo;
    1588             : }
    1589             : 
    1590             : 
    1591             : //  ----------------------------------------------------
    1592             : //  class UnoFixedTextControl
    1593             : //  ----------------------------------------------------
    1594          12 : UnoFixedTextControl::UnoFixedTextControl()
    1595          12 :     :UnoControlBase()
    1596             : {
    1597          12 :     maComponentInfos.nWidth = 100;
    1598          12 :     maComponentInfos.nHeight = 12;
    1599          12 : }
    1600             : 
    1601           2 : OUString UnoFixedTextControl::GetComponentServiceName()
    1602             : {
    1603           2 :     return OUString("fixedtext");
    1604             : }
    1605             : 
    1606             : // uno::XInterface
    1607          82 : uno::Any UnoFixedTextControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
    1608             : {
    1609             :     uno::Any aRet = ::cppu::queryInterface( rType,
    1610             :                                         (static_cast< awt::XFixedText* >(this)),
    1611          82 :                                         (static_cast< awt::XLayoutConstrains* >(this)) );
    1612          82 :     return (aRet.hasValue() ? aRet : UnoControlBase::queryAggregation( rType ));
    1613             : }
    1614             : 
    1615             : // lang::XTypeProvider
    1616           0 : IMPL_XTYPEPROVIDER_START( UnoFixedTextControl )
    1617           0 :     getCppuType( ( uno::Reference< awt::XFixedText>* ) NULL ),
    1618           0 :     getCppuType( ( uno::Reference< awt::XLayoutConstrains>* ) NULL ),
    1619             :     UnoControlBase::getTypes()
    1620           0 : IMPL_XTYPEPROVIDER_END
    1621             : 
    1622           1 : sal_Bool UnoFixedTextControl::isTransparent() throw(uno::RuntimeException)
    1623             : {
    1624           1 :     return sal_True;
    1625             : }
    1626             : 
    1627           2 : void UnoFixedTextControl::setText( const OUString& Text ) throw(uno::RuntimeException)
    1628             : {
    1629           2 :     uno::Any aAny;
    1630           2 :     aAny <<= Text;
    1631           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LABEL ), aAny, sal_True );
    1632           2 : }
    1633             : 
    1634           2 : OUString UnoFixedTextControl::getText() throw(uno::RuntimeException)
    1635             : {
    1636           2 :     return ImplGetPropertyValue_UString( BASEPROPERTY_LABEL );
    1637             : }
    1638             : 
    1639           1 : void UnoFixedTextControl::setAlignment( short nAlign ) throw(uno::RuntimeException)
    1640             : {
    1641           1 :     uno::Any aAny;
    1642           1 :     aAny <<= (sal_Int16)nAlign;
    1643           1 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN ), aAny, sal_True );
    1644           1 : }
    1645             : 
    1646           2 : short UnoFixedTextControl::getAlignment() throw(uno::RuntimeException)
    1647             : {
    1648           2 :     short nAlign = 0;
    1649           2 :     if ( mxModel.is() )
    1650             :     {
    1651           2 :         uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_ALIGN ) );
    1652           2 :         aVal >>= nAlign;
    1653             :     }
    1654           2 :     return nAlign;
    1655             : }
    1656             : 
    1657           1 : awt::Size UnoFixedTextControl::getMinimumSize(  ) throw(uno::RuntimeException)
    1658             : {
    1659           1 :     return Impl_getMinimumSize();
    1660             : }
    1661             : 
    1662           1 : awt::Size UnoFixedTextControl::getPreferredSize(  ) throw(uno::RuntimeException)
    1663             : {
    1664           1 :     return Impl_getPreferredSize();
    1665             : }
    1666             : 
    1667           1 : awt::Size UnoFixedTextControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
    1668             : {
    1669           1 :     return Impl_calcAdjustedSize( rNewSize );
    1670             : }
    1671             : 
    1672             : //  ----------------------------------------------------
    1673             : //  class UnoControlGroupBoxModel
    1674             : //  ----------------------------------------------------
    1675          19 : UnoControlGroupBoxModel::UnoControlGroupBoxModel( const Reference< XComponentContext >& rxContext )
    1676          19 :     :UnoControlModel( rxContext )
    1677             : {
    1678          19 :     ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
    1679          19 :     ImplRegisterProperty( BASEPROPERTY_ENABLED );
    1680          19 :     ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
    1681          19 :     ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
    1682          19 :     ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
    1683          19 :     ImplRegisterProperty( BASEPROPERTY_HELPURL );
    1684          19 :     ImplRegisterProperty( BASEPROPERTY_LABEL );
    1685          19 :     ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
    1686          19 :     ImplRegisterProperty( BASEPROPERTY_WRITING_MODE );
    1687          19 :     ImplRegisterProperty( BASEPROPERTY_CONTEXT_WRITING_MODE );
    1688          19 : }
    1689             : 
    1690           1 : OUString UnoControlGroupBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
    1691             : {
    1692           1 :     return OUString::createFromAscii( szServiceName_UnoControlGroupBoxModel );
    1693             : }
    1694             : 
    1695         296 : uno::Any UnoControlGroupBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
    1696             : {
    1697         296 :     if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
    1698             :     {
    1699          21 :         uno::Any aAny;
    1700          21 :         aAny <<= OUString::createFromAscii( szServiceName_UnoControlGroupBox );
    1701          21 :         return aAny;
    1702             :     }
    1703         275 :     return UnoControlModel::ImplGetDefaultValue( nPropId );
    1704             : }
    1705             : 
    1706        3334 : ::cppu::IPropertyArrayHelper& UnoControlGroupBoxModel::getInfoHelper()
    1707             : {
    1708             :     static UnoPropertyArrayHelper* pHelper = NULL;
    1709        3334 :     if ( !pHelper )
    1710             :     {
    1711           5 :         uno::Sequence<sal_Int32>    aIDs = ImplGetPropertyIds();
    1712           5 :         pHelper = new UnoPropertyArrayHelper( aIDs );
    1713             :     }
    1714        3334 :     return *pHelper;
    1715             : }
    1716             : 
    1717             : // beans::XMultiPropertySet
    1718          48 : uno::Reference< beans::XPropertySetInfo > UnoControlGroupBoxModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
    1719             : {
    1720          48 :     static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
    1721          48 :     return xInfo;
    1722             : }
    1723             : 
    1724             : //  ----------------------------------------------------
    1725             : //  class UnoGroupBoxControl
    1726             : //  ----------------------------------------------------
    1727          13 : UnoGroupBoxControl::UnoGroupBoxControl()
    1728          13 :     :UnoControlBase()
    1729             : {
    1730          13 :     maComponentInfos.nWidth = 100;
    1731          13 :     maComponentInfos.nHeight = 100;
    1732          13 : }
    1733             : 
    1734          13 : OUString UnoGroupBoxControl::GetComponentServiceName()
    1735             : {
    1736          13 :     return OUString("groupbox");
    1737             : }
    1738             : 
    1739           2 : sal_Bool UnoGroupBoxControl::isTransparent() throw(uno::RuntimeException)
    1740             : {
    1741           2 :     return sal_True;
    1742             : }
    1743             : 
    1744             : // =====================================================================================================================
    1745             : // = UnoControlListBoxModel_Data
    1746             : // =====================================================================================================================
    1747         582 : struct ListItem
    1748             : {
    1749             :     OUString ItemText;
    1750             :     OUString ItemImageURL;
    1751             :     Any             ItemData;
    1752             : 
    1753         118 :     ListItem()
    1754             :         :ItemText()
    1755             :         ,ItemImageURL()
    1756         118 :         ,ItemData()
    1757             :     {
    1758         118 :     }
    1759             : 
    1760         118 :     ListItem( const OUString& i_rItemText )
    1761             :         :ItemText( i_rItemText )
    1762             :         ,ItemImageURL()
    1763         118 :         ,ItemData()
    1764             :     {
    1765         118 :     }
    1766             : };
    1767             : 
    1768             : typedef beans::Pair< OUString, OUString > UnoListItem;
    1769             : 
    1770             : struct StripItemData : public ::std::unary_function< ListItem, UnoListItem >
    1771             : {
    1772         113 :     UnoListItem operator()( const ListItem& i_rItem )
    1773             :     {
    1774         113 :         return UnoListItem( i_rItem.ItemText, i_rItem.ItemImageURL );
    1775             :     }
    1776             : };
    1777             : 
    1778          30 : struct UnoControlListBoxModel_Data
    1779             : {
    1780          36 :     UnoControlListBoxModel_Data( UnoControlListBoxModel& i_rAntiImpl )
    1781             :         :m_bSettingLegacyProperty( false )
    1782             :         ,m_rAntiImpl( i_rAntiImpl )
    1783          36 :         ,m_aListItems()
    1784             :     {
    1785          36 :     }
    1786             : 
    1787           0 :     sal_Int32 getItemCount() const { return sal_Int32( m_aListItems.size() ); }
    1788             : 
    1789           0 :     const ListItem& getItem( const sal_Int32 i_nIndex ) const
    1790             :     {
    1791           0 :         if ( ( i_nIndex < 0 ) || ( i_nIndex >= sal_Int32( m_aListItems.size() ) ) )
    1792           0 :             throw IndexOutOfBoundsException( OUString(), m_rAntiImpl );
    1793           0 :         return m_aListItems[ i_nIndex ];
    1794             :     }
    1795             : 
    1796           0 :     ListItem& getItem( const sal_Int32 i_nIndex )
    1797             :     {
    1798           0 :         return const_cast< ListItem& >( static_cast< const UnoControlListBoxModel_Data* >( this )->getItem( i_nIndex ) );
    1799             :     }
    1800             : 
    1801           0 :     ListItem& insertItem( const sal_Int32 i_nIndex )
    1802             :     {
    1803           0 :         if ( ( i_nIndex < 0 ) || ( i_nIndex > sal_Int32( m_aListItems.size() ) ) )
    1804           0 :             throw IndexOutOfBoundsException( OUString(), m_rAntiImpl );
    1805           0 :         return *m_aListItems.insert( m_aListItems.begin() + i_nIndex, ListItem() );
    1806             :     }
    1807             : 
    1808          79 :     Sequence< UnoListItem > getAllItems() const
    1809             :     {
    1810          79 :         Sequence< UnoListItem > aItems( sal_Int32( m_aListItems.size() ) );
    1811          79 :         ::std::transform( m_aListItems.begin(), m_aListItems.end(), aItems.getArray(), StripItemData() );
    1812          79 :         return aItems;
    1813             :     }
    1814             : 
    1815           4 :     void copyItems( const UnoControlListBoxModel_Data& i_copySource )
    1816             :     {
    1817           4 :         m_aListItems = i_copySource.m_aListItems;
    1818           4 :     }
    1819             : 
    1820          54 :     void    setAllItems( const ::std::vector< ListItem >& i_rItems )
    1821             :     {
    1822          54 :         m_aListItems = i_rItems;
    1823          54 :     }
    1824             : 
    1825           0 :     void    removeItem( const sal_Int32 i_nIndex )
    1826             :     {
    1827           0 :         if ( ( i_nIndex < 0 ) || ( i_nIndex >= sal_Int32( m_aListItems.size() ) ) )
    1828           0 :             throw IndexOutOfBoundsException( OUString(), m_rAntiImpl );
    1829           0 :         m_aListItems.erase( m_aListItems.begin() + i_nIndex );
    1830           0 :     }
    1831             : 
    1832           0 :     void removeAllItems()
    1833             :     {
    1834           0 :         ::std::vector< ListItem > aEmpty;
    1835           0 :         m_aListItems.swap( aEmpty );
    1836           0 :     }
    1837             : 
    1838             : public:
    1839             :     bool                        m_bSettingLegacyProperty;
    1840             : 
    1841             : private:
    1842             :     UnoControlListBoxModel&     m_rAntiImpl;
    1843             :     ::std::vector< ListItem >   m_aListItems;
    1844             : };
    1845             : 
    1846             : // =====================================================================================================================
    1847             : // = UnoControlListBoxModel
    1848             : // =====================================================================================================================
    1849             : // ---------------------------------------------------------------------------------------------------------------------
    1850          32 : UnoControlListBoxModel::UnoControlListBoxModel( const Reference< XComponentContext >& rxContext, ConstructorMode const i_mode )
    1851             :     :UnoControlListBoxModel_Base( rxContext )
    1852          32 :     ,m_pData( new UnoControlListBoxModel_Data( *this ) )
    1853          64 :     ,m_aItemListListeners( GetMutex() )
    1854             : {
    1855          32 :     if ( i_mode == ConstructDefault )
    1856             :     {
    1857          14 :         UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXListBox );
    1858             :     }
    1859          32 : }
    1860             : // ---------------------------------------------------------------------------------------------------------------------
    1861           4 : UnoControlListBoxModel::UnoControlListBoxModel( const UnoControlListBoxModel& i_rSource )
    1862             :     :UnoControlListBoxModel_Base( i_rSource )
    1863           4 :     ,m_pData( new UnoControlListBoxModel_Data( *this ) )
    1864           8 :     ,m_aItemListListeners( GetMutex() )
    1865             : {
    1866           4 :     m_pData->copyItems( *i_rSource.m_pData );
    1867           4 : }
    1868          43 : UnoControlListBoxModel::~UnoControlListBoxModel()
    1869             : {
    1870          43 : }
    1871          96 : IMPL_SERVICEINFO_DERIVED( UnoControlListBoxModel, UnoControlModel, szServiceName2_UnoControlListBoxModel )
    1872             : // ---------------------------------------------------------------------------------------------------------------------
    1873           1 : OUString UnoControlListBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
    1874             : {
    1875           1 :     return OUString::createFromAscii( szServiceName_UnoControlListBoxModel );
    1876             : }
    1877             : 
    1878             : // ---------------------------------------------------------------------------------------------------------------------
    1879         464 : uno::Any UnoControlListBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
    1880             : {
    1881         464 :     if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
    1882             :     {
    1883          16 :         uno::Any aAny;
    1884          16 :         aAny <<= OUString::createFromAscii( szServiceName_UnoControlListBox );
    1885          16 :         return aAny;
    1886             :     }
    1887         448 :     return UnoControlModel::ImplGetDefaultValue( nPropId );
    1888             : }
    1889             : 
    1890             : // ---------------------------------------------------------------------------------------------------------------------
    1891        6128 : ::cppu::IPropertyArrayHelper& UnoControlListBoxModel::getInfoHelper()
    1892             : {
    1893             :     static UnoPropertyArrayHelper* pHelper = NULL;
    1894        6128 :     if ( !pHelper )
    1895             :     {
    1896           4 :         uno::Sequence<sal_Int32>    aIDs = ImplGetPropertyIds();
    1897           4 :         pHelper = new UnoPropertyArrayHelper( aIDs );
    1898             :     }
    1899        6128 :     return *pHelper;
    1900             : }
    1901             : 
    1902             : // ---------------------------------------------------------------------------------------------------------------------
    1903             : // beans::XMultiPropertySet
    1904          75 : uno::Reference< beans::XPropertySetInfo > UnoControlListBoxModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
    1905             : {
    1906          75 :     static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
    1907          75 :     return xInfo;
    1908             : }
    1909             : 
    1910             : // ---------------------------------------------------------------------------------------------------------------------
    1911             : namespace
    1912             : {
    1913             :     struct CreateListItem : public ::std::unary_function< OUString, ListItem >
    1914             :     {
    1915         118 :         ListItem operator()( const OUString& i_rItemText )
    1916             :         {
    1917         118 :             return ListItem( i_rItemText );
    1918             :         }
    1919             :     };
    1920             : }
    1921             : 
    1922             : // ---------------------------------------------------------------------------------------------------------------------
    1923         581 : void SAL_CALL UnoControlListBoxModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const uno::Any& rValue ) throw (uno::Exception)
    1924             : {
    1925         581 :     UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue );
    1926             : 
    1927         581 :     if ( nHandle == BASEPROPERTY_STRINGITEMLIST )
    1928             :     {
    1929             :         // reset selection
    1930          26 :         uno::Sequence<sal_Int16> aSeq;
    1931          52 :         uno::Any aAny;
    1932          26 :         aAny <<= aSeq;
    1933          26 :         setDependentFastPropertyValue( BASEPROPERTY_SELECTEDITEMS, aAny );
    1934             : 
    1935          26 :         if ( !m_pData->m_bSettingLegacyProperty )
    1936             :         {
    1937             :             // synchronize the legacy StringItemList property with our list items
    1938          26 :             Sequence< OUString > aStringItemList;
    1939          52 :             Any aPropValue;
    1940          26 :             getFastPropertyValue( aPropValue, BASEPROPERTY_STRINGITEMLIST );
    1941          26 :             OSL_VERIFY( aPropValue >>= aStringItemList );
    1942             : 
    1943          52 :             ::std::vector< ListItem > aItems( aStringItemList.getLength() );
    1944             :             ::std::transform(
    1945             :                 aStringItemList.getConstArray(),
    1946          26 :                 aStringItemList.getConstArray() + aStringItemList.getLength(),
    1947             :                 aItems.begin(),
    1948             :                 CreateListItem()
    1949          52 :             );
    1950          26 :             m_pData->setAllItems( aItems );
    1951             : 
    1952             :             // since an XItemListListener does not have a "all items modified" or some such method,
    1953             :             // we simulate this by notifying removal of all items, followed by insertion of all new
    1954             :             // items
    1955          52 :             lang::EventObject aEvent;
    1956          26 :             aEvent.Source = *this;
    1957          52 :             m_aItemListListeners.notifyEach( &XItemListListener::itemListChanged, aEvent );
    1958             :             // TODO: OPropertySetHelper calls into this method with the mutex locked ...
    1959             :             // which is wrong for the above notifications ...
    1960          26 :         }
    1961             :     }
    1962         581 : }
    1963             : 
    1964             : // ---------------------------------------------------------------------------------------------------------------------
    1965         180 : void UnoControlListBoxModel::ImplNormalizePropertySequence( const sal_Int32 _nCount, sal_Int32* _pHandles,
    1966             :     uno::Any* _pValues, sal_Int32* _pValidHandles ) const SAL_THROW(())
    1967             : {
    1968             :     // dependencies we know:
    1969             :     // BASEPROPERTY_STRINGITEMLIST->BASEPROPERTY_SELECTEDITEMS
    1970         180 :     ImplEnsureHandleOrder( _nCount, _pHandles, _pValues, BASEPROPERTY_STRINGITEMLIST, BASEPROPERTY_SELECTEDITEMS );
    1971             : 
    1972         180 :     UnoControlModel::ImplNormalizePropertySequence( _nCount, _pHandles, _pValues, _pValidHandles );
    1973         180 : }
    1974             : 
    1975             : // ---------------------------------------------------------------------------------------------------------------------
    1976           0 : ::sal_Int32 SAL_CALL UnoControlListBoxModel::getItemCount() throw (RuntimeException)
    1977             : {
    1978           0 :     ::osl::MutexGuard aGuard( GetMutex() );
    1979           0 :     return m_pData->getItemCount();
    1980             : }
    1981             : 
    1982             : // ---------------------------------------------------------------------------------------------------------------------
    1983           0 : void SAL_CALL UnoControlListBoxModel::insertItem( ::sal_Int32 i_nPosition, const OUString& i_rItemText, const OUString& i_rItemImageURL ) throw (IndexOutOfBoundsException, RuntimeException)
    1984             : {
    1985           0 :     ::osl::ClearableMutexGuard aGuard( GetMutex() );
    1986             :     // SYNCHRONIZED ----->
    1987           0 :     ListItem& rItem( m_pData->insertItem( i_nPosition ) );
    1988           0 :     rItem.ItemText = i_rItemText;
    1989           0 :     rItem.ItemImageURL = i_rItemImageURL;
    1990             : 
    1991           0 :     impl_handleInsert( i_nPosition, i_rItemText, i_rItemImageURL, aGuard );
    1992             :     // <----- SYNCHRONIZED
    1993           0 : }
    1994             : 
    1995             : // ---------------------------------------------------------------------------------------------------------------------
    1996           0 : void SAL_CALL UnoControlListBoxModel::insertItemText( ::sal_Int32 i_nPosition, const OUString& i_rItemText ) throw (IndexOutOfBoundsException, RuntimeException)
    1997             : {
    1998           0 :     ::osl::ClearableMutexGuard aGuard( GetMutex() );
    1999             :     // SYNCHRONIZED ----->
    2000           0 :     ListItem& rItem( m_pData->insertItem( i_nPosition ) );
    2001           0 :     rItem.ItemText = i_rItemText;
    2002             : 
    2003           0 :     impl_handleInsert( i_nPosition, i_rItemText, ::boost::optional< OUString >(), aGuard );
    2004             :     // <----- SYNCHRONIZED
    2005           0 : }
    2006             : 
    2007             : // ---------------------------------------------------------------------------------------------------------------------
    2008           0 : void SAL_CALL UnoControlListBoxModel::insertItemImage( ::sal_Int32 i_nPosition, const OUString& i_rItemImageURL ) throw (IndexOutOfBoundsException, RuntimeException)
    2009             : {
    2010           0 :     ::osl::ClearableMutexGuard aGuard( GetMutex() );
    2011             :     // SYNCHRONIZED ----->
    2012           0 :     ListItem& rItem( m_pData->insertItem( i_nPosition ) );
    2013           0 :     rItem.ItemImageURL = i_rItemImageURL;
    2014             : 
    2015           0 :     impl_handleInsert( i_nPosition, ::boost::optional< OUString >(), i_rItemImageURL, aGuard );
    2016             :     // <----- SYNCHRONIZED
    2017           0 : }
    2018             : 
    2019             : // ---------------------------------------------------------------------------------------------------------------------
    2020           0 : void SAL_CALL UnoControlListBoxModel::removeItem( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException)
    2021             : {
    2022           0 :     ::osl::ClearableMutexGuard aGuard( GetMutex() );
    2023             :     // SYNCHRONIZED ----->
    2024           0 :     m_pData->removeItem( i_nPosition );
    2025             : 
    2026           0 :     impl_handleRemove( i_nPosition, aGuard );
    2027             :     // <----- SYNCHRONIZED
    2028           0 : }
    2029             : 
    2030             : // ---------------------------------------------------------------------------------------------------------------------
    2031           0 : void SAL_CALL UnoControlListBoxModel::removeAllItems(  ) throw (::com::sun::star::uno::RuntimeException)
    2032             : {
    2033           0 :     ::osl::ClearableMutexGuard aGuard( GetMutex() );
    2034             :     // SYNCHRONIZED ----->
    2035           0 :     m_pData->removeAllItems();
    2036             : 
    2037           0 :     impl_handleRemove( -1, aGuard );
    2038             :     // <----- SYNCHRONIZED
    2039           0 : }
    2040             : 
    2041             : // ---------------------------------------------------------------------------------------------------------------------
    2042           0 : void SAL_CALL UnoControlListBoxModel::setItemText( ::sal_Int32 i_nPosition, const OUString& i_rItemText ) throw (IndexOutOfBoundsException, RuntimeException)
    2043             : {
    2044           0 :     ::osl::ClearableMutexGuard aGuard( GetMutex() );
    2045             :     // SYNCHRONIZED ----->
    2046           0 :     ListItem& rItem( m_pData->getItem( i_nPosition ) );
    2047           0 :     rItem.ItemText = i_rItemText;
    2048             : 
    2049           0 :     impl_handleModify( i_nPosition, i_rItemText, ::boost::optional< OUString >(), aGuard );
    2050             :     // <----- SYNCHRONIZED
    2051           0 : }
    2052             : 
    2053             : // ---------------------------------------------------------------------------------------------------------------------
    2054           0 : void SAL_CALL UnoControlListBoxModel::setItemImage( ::sal_Int32 i_nPosition, const OUString& i_rItemImageURL ) throw (IndexOutOfBoundsException, RuntimeException)
    2055             : {
    2056           0 :     ::osl::ClearableMutexGuard aGuard( GetMutex() );
    2057             :     // SYNCHRONIZED ----->
    2058           0 :     ListItem& rItem( m_pData->getItem( i_nPosition ) );
    2059           0 :     rItem.ItemImageURL = i_rItemImageURL;
    2060             : 
    2061           0 :     impl_handleModify( i_nPosition, ::boost::optional< OUString >(), i_rItemImageURL, aGuard );
    2062             :     // <----- SYNCHRONIZED
    2063           0 : }
    2064             : 
    2065             : // ---------------------------------------------------------------------------------------------------------------------
    2066           0 : void SAL_CALL UnoControlListBoxModel::setItemTextAndImage( ::sal_Int32 i_nPosition, const OUString& i_rItemText, const OUString& i_rItemImageURL ) throw (IndexOutOfBoundsException, RuntimeException)
    2067             : {
    2068           0 :     ::osl::ClearableMutexGuard aGuard( GetMutex() );
    2069             :     // SYNCHRONIZED ----->
    2070           0 :     ListItem& rItem( m_pData->getItem( i_nPosition ) );
    2071           0 :     rItem.ItemText = i_rItemText;
    2072           0 :     rItem.ItemImageURL = i_rItemImageURL;
    2073             : 
    2074           0 :     impl_handleModify( i_nPosition, i_rItemText, i_rItemImageURL, aGuard );
    2075             :     // <----- SYNCHRONIZED
    2076           0 : }
    2077             : 
    2078             : // ---------------------------------------------------------------------------------------------------------------------
    2079           0 : void SAL_CALL UnoControlListBoxModel::setItemData( ::sal_Int32 i_nPosition, const Any& i_rDataValue ) throw (IndexOutOfBoundsException, RuntimeException)
    2080             : {
    2081           0 :     ::osl::ClearableMutexGuard aGuard( GetMutex() );
    2082           0 :     ListItem& rItem( m_pData->getItem( i_nPosition ) );
    2083           0 :     rItem.ItemData = i_rDataValue;
    2084           0 : }
    2085             : 
    2086             : // ---------------------------------------------------------------------------------------------------------------------
    2087           0 : OUString SAL_CALL UnoControlListBoxModel::getItemText( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException)
    2088             : {
    2089           0 :     ::osl::MutexGuard aGuard( GetMutex() );
    2090           0 :     const ListItem& rItem( m_pData->getItem( i_nPosition ) );
    2091           0 :     return rItem.ItemText;
    2092             : }
    2093             : 
    2094             : // ---------------------------------------------------------------------------------------------------------------------
    2095           0 : OUString SAL_CALL UnoControlListBoxModel::getItemImage( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException)
    2096             : {
    2097           0 :     ::osl::MutexGuard aGuard( GetMutex() );
    2098           0 :     const ListItem& rItem( m_pData->getItem( i_nPosition ) );
    2099           0 :     return rItem.ItemImageURL;
    2100             : }
    2101             : 
    2102             : // ---------------------------------------------------------------------------------------------------------------------
    2103           0 : beans::Pair< OUString, OUString > SAL_CALL UnoControlListBoxModel::getItemTextAndImage( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException)
    2104             : {
    2105           0 :     ::osl::MutexGuard aGuard( GetMutex() );
    2106           0 :     const ListItem& rItem( m_pData->getItem( i_nPosition ) );
    2107           0 :     return beans::Pair< OUString, OUString >( rItem.ItemText, rItem.ItemImageURL );
    2108             : }
    2109             : 
    2110             : // ---------------------------------------------------------------------------------------------------------------------
    2111           0 : Any SAL_CALL UnoControlListBoxModel::getItemData( ::sal_Int32 i_nPosition ) throw (IndexOutOfBoundsException, RuntimeException)
    2112             : {
    2113           0 :     ::osl::ClearableMutexGuard aGuard( GetMutex() );
    2114           0 :     const ListItem& rItem( m_pData->getItem( i_nPosition ) );
    2115           0 :     return rItem.ItemData;
    2116             : }
    2117             : 
    2118             : // ---------------------------------------------------------------------------------------------------------------------
    2119          79 : Sequence< beans::Pair< OUString, OUString > > SAL_CALL UnoControlListBoxModel::getAllItems(  ) throw (RuntimeException)
    2120             : {
    2121          79 :     ::osl::MutexGuard aGuard( GetMutex() );
    2122          79 :     return m_pData->getAllItems();
    2123             : }
    2124             : 
    2125             : // ---------------------------------------------------------------------------------------------------------------------
    2126          20 : void SAL_CALL UnoControlListBoxModel::addItemListListener( const uno::Reference< awt::XItemListListener >& i_Listener ) throw (uno::RuntimeException)
    2127             : {
    2128          20 :     if ( i_Listener.is() )
    2129          20 :         m_aItemListListeners.addInterface( i_Listener );
    2130          20 : }
    2131             : 
    2132             : // ---------------------------------------------------------------------------------------------------------------------
    2133           4 : void SAL_CALL UnoControlListBoxModel::removeItemListListener( const uno::Reference< awt::XItemListListener >& i_Listener ) throw (uno::RuntimeException)
    2134             : {
    2135           4 :     if ( i_Listener.is() )
    2136           4 :         m_aItemListListeners.removeInterface( i_Listener );
    2137           4 : }
    2138             : 
    2139             : // ---------------------------------------------------------------------------------------------------------------------
    2140           0 : void UnoControlListBoxModel::impl_getStringItemList( ::std::vector< OUString >& o_rStringItems ) const
    2141             : {
    2142           0 :     Sequence< OUString > aStringItemList;
    2143           0 :     Any aPropValue;
    2144           0 :     getFastPropertyValue( aPropValue, BASEPROPERTY_STRINGITEMLIST );
    2145           0 :     OSL_VERIFY( aPropValue >>= aStringItemList );
    2146             : 
    2147           0 :     o_rStringItems.resize( size_t( aStringItemList.getLength() ) );
    2148             :     ::std::copy(
    2149             :         aStringItemList.getConstArray(),
    2150           0 :         aStringItemList.getConstArray() + aStringItemList.getLength(),
    2151             :         o_rStringItems.begin()
    2152           0 :     );
    2153           0 : }
    2154             : 
    2155             : // ---------------------------------------------------------------------------------------------------------------------
    2156           0 : void UnoControlListBoxModel::impl_setStringItemList_nolck( const ::std::vector< OUString >& i_rStringItems )
    2157             : {
    2158           0 :     Sequence< OUString > aStringItems( i_rStringItems.size() );
    2159             :     ::std::copy(
    2160             :         i_rStringItems.begin(),
    2161             :         i_rStringItems.end(),
    2162             :         aStringItems.getArray()
    2163           0 :     );
    2164           0 :     m_pData->m_bSettingLegacyProperty = true;
    2165             :     try
    2166             :     {
    2167           0 :         setFastPropertyValue( BASEPROPERTY_STRINGITEMLIST, uno::makeAny( aStringItems ) );
    2168             :     }
    2169           0 :     catch( const Exception& )
    2170             :     {
    2171           0 :         m_pData->m_bSettingLegacyProperty = false;
    2172           0 :         throw;
    2173             :     }
    2174           0 :     m_pData->m_bSettingLegacyProperty = false;
    2175           0 : }
    2176             : 
    2177             : // ---------------------------------------------------------------------------------------------------------------------
    2178           0 : void UnoControlListBoxModel::impl_handleInsert( const sal_Int32 i_nItemPosition, const ::boost::optional< OUString >& i_rItemText,
    2179             :         const ::boost::optional< OUString >& i_rItemImageURL, ::osl::ClearableMutexGuard& i_rClearBeforeNotify )
    2180             : {
    2181             :     // SYNCHRONIZED ----->
    2182             :     // sync with legacy StringItemList property
    2183           0 :     ::std::vector< OUString > aStringItems;
    2184           0 :     impl_getStringItemList( aStringItems );
    2185             :     OSL_ENSURE( size_t( i_nItemPosition ) <= aStringItems.size(), "UnoControlListBoxModel::impl_handleInsert" );
    2186           0 :     if ( size_t( i_nItemPosition ) <= aStringItems.size() )
    2187             :     {
    2188           0 :         const OUString sItemText( !!i_rItemText ? *i_rItemText : OUString() );
    2189           0 :         aStringItems.insert( aStringItems.begin() + i_nItemPosition, sItemText );
    2190             :     }
    2191             : 
    2192           0 :     i_rClearBeforeNotify.clear();
    2193             :     // <----- SYNCHRONIZED
    2194           0 :     impl_setStringItemList_nolck( aStringItems );
    2195             : 
    2196             :     // notify ItemListListeners
    2197           0 :     impl_notifyItemListEvent_nolck( i_nItemPosition, i_rItemText, i_rItemImageURL, &XItemListListener::listItemInserted );
    2198           0 : }
    2199             : 
    2200             : // ---------------------------------------------------------------------------------------------------------------------
    2201           0 : void UnoControlListBoxModel::impl_handleRemove( const sal_Int32 i_nItemPosition, ::osl::ClearableMutexGuard& i_rClearBeforeNotify )
    2202             : {
    2203             :     // SYNCHRONIZED ----->
    2204           0 :     const bool bAllItems = ( i_nItemPosition < 0 );
    2205             :     // sync with legacy StringItemList property
    2206           0 :     ::std::vector< OUString > aStringItems;
    2207           0 :     impl_getStringItemList( aStringItems );
    2208           0 :     if ( !bAllItems )
    2209             :     {
    2210             :         OSL_ENSURE( size_t( i_nItemPosition ) < aStringItems.size(), "UnoControlListBoxModel::impl_handleRemove" );
    2211           0 :         if ( size_t( i_nItemPosition ) < aStringItems.size() )
    2212             :         {
    2213           0 :             aStringItems.erase( aStringItems.begin() + i_nItemPosition );
    2214             :         }
    2215             :     }
    2216             :     else
    2217             :     {
    2218           0 :         aStringItems.resize(0);
    2219             :     }
    2220             : 
    2221           0 :     i_rClearBeforeNotify.clear();
    2222             :     // <----- SYNCHRONIZED
    2223           0 :     impl_setStringItemList_nolck( aStringItems );
    2224             : 
    2225             :     // notify ItemListListeners
    2226           0 :     if ( bAllItems )
    2227             :     {
    2228           0 :         EventObject aEvent( *this );
    2229           0 :         m_aItemListListeners.notifyEach( &XItemListListener::allItemsRemoved, aEvent );
    2230             :     }
    2231             :     else
    2232             :     {
    2233             :         impl_notifyItemListEvent_nolck( i_nItemPosition, ::boost::optional< OUString >(), ::boost::optional< OUString >(),
    2234           0 :             &XItemListListener::listItemRemoved );
    2235           0 :     }
    2236           0 : }
    2237             : 
    2238             : // ---------------------------------------------------------------------------------------------------------------------
    2239           0 : void UnoControlListBoxModel::impl_handleModify( const sal_Int32 i_nItemPosition, const ::boost::optional< OUString >& i_rItemText,
    2240             :         const ::boost::optional< OUString >& i_rItemImageURL, ::osl::ClearableMutexGuard& i_rClearBeforeNotify )
    2241             : {
    2242             :     // SYNCHRONIZED ----->
    2243           0 :     if ( !!i_rItemText )
    2244             :     {
    2245             :         // sync with legacy StringItemList property
    2246           0 :         ::std::vector< OUString > aStringItems;
    2247           0 :         impl_getStringItemList( aStringItems );
    2248             :         OSL_ENSURE( size_t( i_nItemPosition ) < aStringItems.size(), "UnoControlListBoxModel::impl_handleModify" );
    2249           0 :         if ( size_t( i_nItemPosition ) < aStringItems.size() )
    2250             :         {
    2251           0 :             aStringItems[ i_nItemPosition] = *i_rItemText;
    2252             :         }
    2253             : 
    2254           0 :         i_rClearBeforeNotify.clear();
    2255             :         // <----- SYNCHRONIZED
    2256           0 :         impl_setStringItemList_nolck( aStringItems );
    2257             :     }
    2258             :     else
    2259             :     {
    2260           0 :         i_rClearBeforeNotify.clear();
    2261             :         // <----- SYNCHRONIZED
    2262             :     }
    2263             : 
    2264             :     // notify ItemListListeners
    2265           0 :     impl_notifyItemListEvent_nolck( i_nItemPosition, i_rItemText, i_rItemImageURL, &XItemListListener::listItemModified );
    2266           0 : }
    2267             : 
    2268             : // ---------------------------------------------------------------------------------------------------------------------
    2269           0 : void UnoControlListBoxModel::impl_notifyItemListEvent_nolck( const sal_Int32 i_nItemPosition, const ::boost::optional< OUString >& i_rItemText,
    2270             :     const ::boost::optional< OUString >& i_rItemImageURL,
    2271             :     void ( SAL_CALL XItemListListener::*NotificationMethod )( const ItemListEvent& ) )
    2272             : {
    2273           0 :     ItemListEvent aEvent;
    2274           0 :     aEvent.Source = *this;
    2275           0 :     aEvent.ItemPosition = i_nItemPosition;
    2276           0 :     if ( !!i_rItemText )
    2277             :     {
    2278           0 :         aEvent.ItemText.IsPresent = sal_True;
    2279           0 :         aEvent.ItemText.Value = *i_rItemText;
    2280             :     }
    2281           0 :     if ( !!i_rItemImageURL )
    2282             :     {
    2283           0 :         aEvent.ItemImageURL.IsPresent = sal_True;
    2284           0 :         aEvent.ItemImageURL.Value = *i_rItemImageURL;
    2285             :     }
    2286             : 
    2287           0 :     m_aItemListListeners.notifyEach( NotificationMethod, aEvent );
    2288           0 : }
    2289             : 
    2290             : //  ----------------------------------------------------
    2291             : //  class UnoListBoxControl
    2292             : //  ----------------------------------------------------
    2293          18 : UnoListBoxControl::UnoListBoxControl()
    2294             :     :UnoListBoxControl_Base()
    2295             :     ,maActionListeners( *this )
    2296          18 :     ,maItemListeners( *this )
    2297             : {
    2298          18 :     maComponentInfos.nWidth = 100;
    2299          18 :     maComponentInfos.nHeight = 12;
    2300          18 : }
    2301             : 
    2302          21 : OUString UnoListBoxControl::GetComponentServiceName()
    2303             : {
    2304          21 :     return OUString("listbox");
    2305             : }
    2306           0 : IMPL_SERVICEINFO_DERIVED( UnoListBoxControl, UnoControlBase, szServiceName2_UnoControlListBox )
    2307             : 
    2308           7 : void UnoListBoxControl::dispose() throw(uno::RuntimeException)
    2309             : {
    2310           7 :     lang::EventObject aEvt;
    2311           7 :     aEvt.Source = (::cppu::OWeakObject*)this;
    2312           7 :     maActionListeners.disposeAndClear( aEvt );
    2313           7 :     maItemListeners.disposeAndClear( aEvt );
    2314           7 :     UnoControl::dispose();
    2315           7 : }
    2316             : 
    2317           0 : void UnoListBoxControl::ImplUpdateSelectedItemsProperty()
    2318             : {
    2319           0 :     if ( getPeer().is() )
    2320             :     {
    2321           0 :         uno::Reference < awt::XListBox > xListBox( getPeer(), uno::UNO_QUERY );
    2322             :         DBG_ASSERT( xListBox.is(), "XListBox?" );
    2323             : 
    2324           0 :         uno::Sequence<sal_Int16> aSeq = xListBox->getSelectedItemsPos();
    2325           0 :         uno::Any aAny;
    2326           0 :         aAny <<= aSeq;
    2327           0 :         ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_SELECTEDITEMS ), aAny, sal_False );
    2328             :     }
    2329           0 : }
    2330             : 
    2331          21 : void UnoListBoxControl::updateFromModel()
    2332             : {
    2333          21 :     UnoControlBase::updateFromModel();
    2334             : 
    2335          21 :     Reference< XItemListListener > xItemListListener( getPeer(), UNO_QUERY );
    2336          42 :     ENSURE_OR_RETURN_VOID( xItemListListener.is(), "UnoListBoxControl::updateFromModel: a peer which is no ItemListListener?!" );
    2337             : 
    2338          42 :     EventObject aEvent( getModel() );
    2339          21 :     xItemListListener->itemListChanged( aEvent );
    2340             : 
    2341             :     // notify the change of the SelectedItems property, again. While our base class, in updateFromModel,
    2342             :     // already did this, our peer(s) can only legitimately set the selection after they have the string
    2343             :     // item list, which we just notified with the itemListChanged call.
    2344          42 :     const OUString sSelectedItemsPropName( GetPropertyName( BASEPROPERTY_SELECTEDITEMS ) );
    2345          42 :     ImplSetPeerProperty( sSelectedItemsPropName, ImplGetPropertyValue( sSelectedItemsPropName ) );
    2346             : }
    2347             : 
    2348        1864 : void UnoListBoxControl::ImplSetPeerProperty( const OUString& rPropName, const uno::Any& rVal )
    2349             : {
    2350        1864 :     if ( rPropName == GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) )
    2351             :         // do not forward this to our peer. We are a XItemListListener at our model, and changes in the string item
    2352             :         // list (which is a legacy property) will, later, arrive as changes in the ItemList. Those latter changes
    2353             :         // will be forwarded to the peer, which will update itself accordingly.
    2354        1923 :         return;
    2355             : 
    2356        1805 :     UnoControl::ImplSetPeerProperty( rPropName, rVal );
    2357             : }
    2358             : 
    2359          21 : void UnoListBoxControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer >  & rParentPeer ) throw(uno::RuntimeException)
    2360             : {
    2361          21 :     UnoControl::createPeer( rxToolkit, rParentPeer );
    2362             : 
    2363          21 :     uno::Reference < awt::XListBox >  xListBox( getPeer(), uno::UNO_QUERY );
    2364          21 :     xListBox->addItemListener( this );
    2365             : 
    2366          21 :     if ( maActionListeners.getLength() )
    2367           0 :         xListBox->addActionListener( &maActionListeners );
    2368          21 : }
    2369             : 
    2370           1 : void UnoListBoxControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
    2371             : {
    2372           1 :     maActionListeners.addInterface( l );
    2373           1 :     if( getPeer().is() && maActionListeners.getLength() == 1 )
    2374             :     {
    2375           1 :         uno::Reference < awt::XListBox >  xListBox( getPeer(), uno::UNO_QUERY );
    2376           1 :         xListBox->addActionListener( &maActionListeners );
    2377             :     }
    2378           1 : }
    2379             : 
    2380           0 : void UnoListBoxControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
    2381             : {
    2382           0 :     if( getPeer().is() && maActionListeners.getLength() == 1 )
    2383             :     {
    2384           0 :         uno::Reference < awt::XListBox >  xListBox( getPeer(), uno::UNO_QUERY );
    2385           0 :         xListBox->removeActionListener( &maActionListeners );
    2386             :     }
    2387           0 :     maActionListeners.removeInterface( l );
    2388           0 : }
    2389             : 
    2390          18 : void UnoListBoxControl::addItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
    2391             : {
    2392          18 :     maItemListeners.addInterface( l );
    2393          18 : }
    2394             : 
    2395           0 : void UnoListBoxControl::removeItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
    2396             : {
    2397           0 :     maItemListeners.removeInterface( l );
    2398           0 : }
    2399             : 
    2400           0 : void UnoListBoxControl::addItem( const OUString& aItem, sal_Int16 nPos ) throw(uno::RuntimeException)
    2401             : {
    2402           0 :     uno::Sequence< OUString> aSeq( 1 );
    2403           0 :     aSeq.getArray()[0] = aItem;
    2404           0 :     addItems( aSeq, nPos );
    2405           0 : }
    2406             : 
    2407           0 : void UnoListBoxControl::addItems( const uno::Sequence< OUString>& aItems, sal_Int16 nPos ) throw(uno::RuntimeException)
    2408             : {
    2409           0 :     uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
    2410           0 :     uno::Sequence< OUString> aSeq;
    2411           0 :     aVal >>= aSeq;
    2412           0 :     sal_uInt16 nNewItems = (sal_uInt16)aItems.getLength();
    2413           0 :     sal_uInt16 nOldLen = (sal_uInt16)aSeq.getLength();
    2414           0 :     sal_uInt16 nNewLen = nOldLen + nNewItems;
    2415             : 
    2416           0 :     uno::Sequence< OUString> aNewSeq( nNewLen );
    2417           0 :     OUString* pNewData = aNewSeq.getArray();
    2418           0 :     OUString* pOldData = aSeq.getArray();
    2419             : 
    2420           0 :     if ( ( nPos < 0 ) || ( nPos > nOldLen ) )
    2421           0 :         nPos = (sal_uInt16) nOldLen;
    2422             : 
    2423             :     sal_uInt16 n;
    2424             :     // Items vor der Einfuege-Position
    2425           0 :     for ( n = 0; n < nPos; n++ )
    2426           0 :         pNewData[n] = pOldData[n];
    2427             : 
    2428             :     // Neue Items
    2429           0 :     for ( n = 0; n < nNewItems; n++ )
    2430           0 :         pNewData[nPos+n] = aItems.getConstArray()[n];
    2431             : 
    2432             :     // Rest der alten Items
    2433           0 :     for ( n = nPos; n < nOldLen; n++ )
    2434           0 :         pNewData[nNewItems+n] = pOldData[n];
    2435             : 
    2436           0 :     uno::Any aAny;
    2437           0 :     aAny <<= aNewSeq;
    2438           0 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), aAny, sal_True );
    2439           0 : }
    2440             : 
    2441           0 : void UnoListBoxControl::removeItems( sal_Int16 nPos, sal_Int16 nCount ) throw(uno::RuntimeException)
    2442             : {
    2443           0 :     uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
    2444           0 :     uno::Sequence< OUString> aSeq;
    2445           0 :     aVal >>= aSeq;
    2446           0 :     sal_uInt16 nOldLen = (sal_uInt16)aSeq.getLength();
    2447           0 :     if ( nOldLen && ( nPos < nOldLen ) )
    2448             :     {
    2449           0 :         if ( nCount > ( nOldLen-nPos ) )
    2450           0 :             nCount = nOldLen-nPos;
    2451             : 
    2452           0 :         sal_uInt16 nNewLen = nOldLen - nCount;
    2453             : 
    2454           0 :         uno::Sequence< OUString> aNewSeq( nNewLen );
    2455           0 :         OUString* pNewData = aNewSeq.getArray();
    2456           0 :         OUString* pOldData = aSeq.getArray();
    2457             : 
    2458             :         sal_uInt16 n;
    2459             :         // Items vor der Entfern-Position
    2460           0 :         for ( n = 0; n < nPos; n++ )
    2461           0 :             pNewData[n] = pOldData[n];
    2462             : 
    2463             :         // Rest der Items
    2464           0 :         for ( n = nPos; n < (nOldLen-nCount); n++ )
    2465           0 :             pNewData[n] = pOldData[n+nCount];
    2466             : 
    2467           0 :         uno::Any aAny;
    2468           0 :         aAny <<= aNewSeq;
    2469           0 :         ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), aAny, sal_True );
    2470           0 :     }
    2471           0 : }
    2472             : 
    2473           0 : sal_Int16 UnoListBoxControl::getItemCount() throw(uno::RuntimeException)
    2474             : {
    2475           0 :     uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
    2476           0 :     uno::Sequence< OUString> aSeq;
    2477           0 :     aVal >>= aSeq;
    2478           0 :     return (sal_Int16)aSeq.getLength();
    2479             : }
    2480             : 
    2481           0 : OUString UnoListBoxControl::getItem( sal_Int16 nPos ) throw(uno::RuntimeException)
    2482             : {
    2483           0 :     OUString aItem;
    2484           0 :     uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
    2485           0 :     uno::Sequence< OUString> aSeq;
    2486           0 :     aVal >>= aSeq;
    2487           0 :     if ( nPos < aSeq.getLength() )
    2488           0 :         aItem = aSeq.getConstArray()[nPos];
    2489           0 :     return aItem;
    2490             : }
    2491             : 
    2492           0 : uno::Sequence< OUString> UnoListBoxControl::getItems() throw(uno::RuntimeException)
    2493             : {
    2494           0 :     uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
    2495           0 :     uno::Sequence< OUString> aSeq;
    2496           0 :     aVal >>= aSeq;
    2497           0 :     return aSeq;
    2498             : }
    2499             : 
    2500           0 : sal_Int16 UnoListBoxControl::getSelectedItemPos() throw(uno::RuntimeException)
    2501             : {
    2502           0 :     sal_Int16 n = -1;
    2503           0 :     if ( getPeer().is() )
    2504             :     {
    2505           0 :         uno::Reference < awt::XListBox >  xListBox( getPeer(), uno::UNO_QUERY );
    2506           0 :         n = xListBox->getSelectedItemPos();
    2507             :     }
    2508           0 :     return n;
    2509             : }
    2510             : 
    2511           0 : uno::Sequence<sal_Int16> UnoListBoxControl::getSelectedItemsPos() throw(uno::RuntimeException)
    2512             : {
    2513           0 :     uno::Sequence<sal_Int16> aSeq;
    2514           0 :     if ( getPeer().is() )
    2515             :     {
    2516           0 :         uno::Reference < awt::XListBox >  xListBox( getPeer(), uno::UNO_QUERY );
    2517           0 :         aSeq = xListBox->getSelectedItemsPos();
    2518             :     }
    2519           0 :     return aSeq;
    2520             : }
    2521             : 
    2522           0 : OUString UnoListBoxControl::getSelectedItem() throw(uno::RuntimeException)
    2523             : {
    2524           0 :     OUString aItem;
    2525           0 :     if ( getPeer().is() )
    2526             :     {
    2527           0 :         uno::Reference < awt::XListBox >  xListBox( getPeer(), uno::UNO_QUERY );
    2528           0 :         aItem = xListBox->getSelectedItem();
    2529             :     }
    2530           0 :     return aItem;
    2531             : }
    2532             : 
    2533           0 : uno::Sequence< OUString> UnoListBoxControl::getSelectedItems() throw(uno::RuntimeException)
    2534             : {
    2535           0 :     uno::Sequence< OUString> aSeq;
    2536           0 :     if ( getPeer().is() )
    2537             :     {
    2538           0 :         uno::Reference < awt::XListBox >  xListBox( getPeer(), uno::UNO_QUERY );
    2539           0 :         aSeq = xListBox->getSelectedItems();
    2540             :     }
    2541           0 :     return aSeq;
    2542             : }
    2543             : 
    2544           0 : void UnoListBoxControl::selectItemPos( sal_Int16 nPos, sal_Bool bSelect ) throw(uno::RuntimeException)
    2545             : {
    2546           0 :     if ( getPeer().is() )
    2547             :     {
    2548           0 :         uno::Reference < awt::XListBox >  xListBox( getPeer(), uno::UNO_QUERY );
    2549           0 :         xListBox->selectItemPos( nPos, bSelect );
    2550             :     }
    2551           0 :     ImplUpdateSelectedItemsProperty();
    2552           0 : }
    2553             : 
    2554           0 : void UnoListBoxControl::selectItemsPos( const uno::Sequence<sal_Int16>& aPositions, sal_Bool bSelect ) throw(uno::RuntimeException)
    2555             : {
    2556           0 :     if ( getPeer().is() )
    2557             :     {
    2558           0 :         uno::Reference < awt::XListBox >  xListBox( getPeer(), uno::UNO_QUERY );
    2559           0 :         xListBox->selectItemsPos( aPositions, bSelect );
    2560             :     }
    2561           0 :     ImplUpdateSelectedItemsProperty();
    2562           0 : }
    2563             : 
    2564           0 : void UnoListBoxControl::selectItem( const OUString& aItem, sal_Bool bSelect ) throw(uno::RuntimeException)
    2565             : {
    2566           0 :     if ( getPeer().is() )
    2567             :     {
    2568           0 :         uno::Reference < awt::XListBox >  xListBox( getPeer(), uno::UNO_QUERY );
    2569           0 :         xListBox->selectItem( aItem, bSelect );
    2570             :     }
    2571           0 :     ImplUpdateSelectedItemsProperty();
    2572           0 : }
    2573             : 
    2574           0 : void UnoListBoxControl::makeVisible( sal_Int16 nEntry ) throw(uno::RuntimeException)
    2575             : {
    2576           0 :     if ( getPeer().is() )
    2577             :     {
    2578           0 :         uno::Reference < awt::XListBox >  xListBox( getPeer(), uno::UNO_QUERY );
    2579           0 :         xListBox->makeVisible( nEntry );
    2580             :     }
    2581           0 : }
    2582             : 
    2583           0 : void UnoListBoxControl::setDropDownLineCount( sal_Int16 nLines ) throw(uno::RuntimeException)
    2584             : {
    2585           0 :     uno::Any aAny;
    2586           0 :     aAny <<= (sal_Int16)nLines;
    2587           0 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINECOUNT ), aAny, sal_True );
    2588           0 : }
    2589             : 
    2590           0 : sal_Int16 UnoListBoxControl::getDropDownLineCount() throw(uno::RuntimeException)
    2591             : {
    2592           0 :     return ImplGetPropertyValue_INT16( BASEPROPERTY_LINECOUNT );
    2593             : }
    2594             : 
    2595           0 : sal_Bool UnoListBoxControl::isMutipleMode() throw(uno::RuntimeException)
    2596             : {
    2597           0 :     return ImplGetPropertyValue_BOOL( BASEPROPERTY_MULTISELECTION );
    2598             : }
    2599             : 
    2600           0 : void UnoListBoxControl::setMultipleMode( sal_Bool bMulti ) throw(uno::RuntimeException)
    2601             : {
    2602           0 :     uno::Any aAny;
    2603           0 :     aAny <<= bMulti;
    2604           0 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_MULTISELECTION ), aAny, sal_True );
    2605           0 : }
    2606             : 
    2607           0 : void UnoListBoxControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw(uno::RuntimeException)
    2608             : {
    2609           0 :     ImplUpdateSelectedItemsProperty();
    2610           0 :     if ( maItemListeners.getLength() )
    2611             :     {
    2612             :         try
    2613             :         {
    2614           0 :             maItemListeners.itemStateChanged( rEvent );
    2615             :         }
    2616           0 :         catch( const Exception& e )
    2617             :         {
    2618             : #if OSL_DEBUG_LEVEL == 0
    2619             :             (void) e; // suppress warning
    2620             : #else
    2621             :             OString sMessage( "UnoListBoxControl::itemStateChanged: caught an exception:\n" );
    2622             :             sMessage += OString( e.Message.getStr(), e.Message.getLength(), RTL_TEXTENCODING_ASCII_US );
    2623             :             OSL_FAIL( sMessage.getStr() );
    2624             : #endif
    2625             :         }
    2626             :     }
    2627           0 : }
    2628             : 
    2629           0 : awt::Size UnoListBoxControl::getMinimumSize(  ) throw(uno::RuntimeException)
    2630             : {
    2631           0 :     return Impl_getMinimumSize();
    2632             : }
    2633             : 
    2634           0 : awt::Size UnoListBoxControl::getPreferredSize(  ) throw(uno::RuntimeException)
    2635             : {
    2636           0 :     return Impl_getPreferredSize();
    2637             : }
    2638             : 
    2639           0 : awt::Size UnoListBoxControl::calcAdjustedSize( const awt::Size& rNewSize ) throw(uno::RuntimeException)
    2640             : {
    2641           0 :     return Impl_calcAdjustedSize( rNewSize );
    2642             : }
    2643             : 
    2644           0 : awt::Size UnoListBoxControl::getMinimumSize( sal_Int16 nCols, sal_Int16 nLines ) throw(uno::RuntimeException)
    2645             : {
    2646           0 :     return Impl_getMinimumSize( nCols, nLines );
    2647             : }
    2648             : 
    2649           0 : void UnoListBoxControl::getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines ) throw(uno::RuntimeException)
    2650             : {
    2651           0 :     Impl_getColumnsAndLines( nCols, nLines );
    2652           0 : }
    2653             : 
    2654          14 : sal_Bool SAL_CALL UnoListBoxControl::setModel( const uno::Reference< awt::XControlModel >& i_rModel ) throw ( uno::RuntimeException )
    2655             : {
    2656          14 :     ::osl::MutexGuard aGuard( GetMutex() );
    2657             : 
    2658          28 :     const Reference< XItemList > xOldItems( getModel(), UNO_QUERY );
    2659             :     OSL_ENSURE( xOldItems.is() || !getModel().is(), "UnoListBoxControl::setModel: illegal old model!" );
    2660          28 :     const Reference< XItemList > xNewItems( i_rModel, UNO_QUERY );
    2661             :     OSL_ENSURE( xNewItems.is() || !i_rModel.is(), "UnoListBoxControl::setModel: illegal new model!" );
    2662             : 
    2663          14 :     if ( !UnoListBoxControl_Base::setModel( i_rModel ) )
    2664           7 :         return sal_False;
    2665             : 
    2666           7 :     if ( xOldItems.is() )
    2667           0 :         xOldItems->removeItemListListener( this );
    2668           7 :     if ( xNewItems.is() )
    2669           7 :         xNewItems->addItemListListener( this );
    2670             : 
    2671          21 :     return sal_True;
    2672             : }
    2673             : 
    2674           0 : void SAL_CALL UnoListBoxControl::listItemInserted( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException)
    2675             : {
    2676           0 :     const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY );
    2677             :     OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoListBoxControl::listItemInserted: invalid peer!" );
    2678           0 :     if ( xPeerListener.is() )
    2679           0 :         xPeerListener->listItemInserted( i_rEvent );
    2680           0 : }
    2681             : 
    2682           0 : void SAL_CALL UnoListBoxControl::listItemRemoved( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException)
    2683             : {
    2684           0 :     const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY );
    2685             :     OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoListBoxControl::listItemRemoved: invalid peer!" );
    2686           0 :     if ( xPeerListener.is() )
    2687           0 :         xPeerListener->listItemRemoved( i_rEvent );
    2688           0 : }
    2689             : 
    2690           0 : void SAL_CALL UnoListBoxControl::listItemModified( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException)
    2691             : {
    2692           0 :     const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY );
    2693             :     OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoListBoxControl::listItemModified: invalid peer!" );
    2694           0 :     if ( xPeerListener.is() )
    2695           0 :         xPeerListener->listItemModified( i_rEvent );
    2696           0 : }
    2697             : 
    2698           0 : void SAL_CALL UnoListBoxControl::allItemsRemoved( const lang::EventObject& i_rEvent ) throw (uno::RuntimeException)
    2699             : {
    2700           0 :     const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY );
    2701             :     OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoListBoxControl::allItemsRemoved: invalid peer!" );
    2702           0 :     if ( xPeerListener.is() )
    2703           0 :         xPeerListener->allItemsRemoved( i_rEvent );
    2704           0 : }
    2705             : 
    2706          19 : void SAL_CALL UnoListBoxControl::itemListChanged( const lang::EventObject& i_rEvent ) throw (uno::RuntimeException)
    2707             : {
    2708          19 :     const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY );
    2709             :     OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoListBoxControl::itemListChanged: invalid peer!" );
    2710          19 :     if ( xPeerListener.is() )
    2711          19 :         xPeerListener->itemListChanged( i_rEvent );
    2712          19 : }
    2713             : 
    2714             : //  ----------------------------------------------------
    2715             : //  class UnoControlComboBoxModel
    2716             : //  ----------------------------------------------------
    2717          18 : UnoControlComboBoxModel::UnoControlComboBoxModel( const Reference< XComponentContext >& rxContext )
    2718          18 :     :UnoControlListBoxModel( rxContext, ConstructWithoutProperties )
    2719             : {
    2720          18 :     UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXComboBox );
    2721          18 : }
    2722             : 
    2723          24 : IMPL_SERVICEINFO_DERIVED( UnoControlComboBoxModel, UnoControlModel, szServiceName2_UnoControlComboBoxModel )
    2724             : 
    2725          87 : uno::Reference< beans::XPropertySetInfo > UnoControlComboBoxModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
    2726             : {
    2727          87 :     static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
    2728          87 :     return xInfo;
    2729             : }
    2730             : // ---------------------------------------------------------------------------------------------------------------------
    2731        6139 : ::cppu::IPropertyArrayHelper& UnoControlComboBoxModel::getInfoHelper()
    2732             : {
    2733             :     static UnoPropertyArrayHelper* pHelper = NULL;
    2734        6139 :     if ( !pHelper )
    2735             :     {
    2736           6 :         uno::Sequence<sal_Int32>    aIDs = ImplGetPropertyIds();
    2737           6 :         pHelper = new UnoPropertyArrayHelper( aIDs );
    2738             :     }
    2739        6139 :     return *pHelper;
    2740             : }
    2741             : 
    2742             : 
    2743           1 : OUString UnoControlComboBoxModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
    2744             : {
    2745           1 :     return OUString::createFromAscii( szServiceName_UnoControlComboBoxModel );
    2746             : }
    2747         617 : void SAL_CALL UnoControlComboBoxModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const uno::Any& rValue ) throw (uno::Exception)
    2748             : {
    2749         617 :     UnoControlModel::setFastPropertyValue_NoBroadcast( nHandle, rValue );
    2750             : 
    2751         617 :     if ( nHandle == BASEPROPERTY_STRINGITEMLIST && !m_pData->m_bSettingLegacyProperty)
    2752             :     {
    2753             :         // synchronize the legacy StringItemList property with our list items
    2754          28 :         Sequence< OUString > aStringItemList;
    2755          56 :         Any aPropValue;
    2756          28 :         getFastPropertyValue( aPropValue, BASEPROPERTY_STRINGITEMLIST );
    2757          28 :         OSL_VERIFY( aPropValue >>= aStringItemList );
    2758             : 
    2759          56 :         ::std::vector< ListItem > aItems( aStringItemList.getLength() );
    2760             :         ::std::transform(
    2761             :             aStringItemList.getConstArray(),
    2762          28 :             aStringItemList.getConstArray() + aStringItemList.getLength(),
    2763             :             aItems.begin(),
    2764             :             CreateListItem()
    2765          56 :         );
    2766          28 :         m_pData->setAllItems( aItems );
    2767             : 
    2768             :         // since an XItemListListener does not have a "all items modified" or some such method,
    2769             :         // we simulate this by notifying removal of all items, followed by insertion of all new
    2770             :         // items
    2771          56 :         lang::EventObject aEvent;
    2772          28 :         aEvent.Source = *this;
    2773          56 :         m_aItemListListeners.notifyEach( &XItemListListener::itemListChanged, aEvent );
    2774             :         // TODO: OPropertySetHelper calls into this method with the mutex locked ...
    2775             :         // which is wrong for the above notifications ...
    2776             :     }
    2777         617 : }
    2778             : 
    2779         579 : uno::Any UnoControlComboBoxModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
    2780             : {
    2781         579 :     if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
    2782             :     {
    2783          20 :         uno::Any aAny;
    2784          20 :         aAny <<= OUString::createFromAscii( szServiceName_UnoControlComboBox );
    2785          20 :         return aAny;
    2786             :     }
    2787         559 :     return UnoControlModel::ImplGetDefaultValue( nPropId );
    2788             : }
    2789             : 
    2790             : //  ----------------------------------------------------
    2791             : //  class UnoComboBoxControl
    2792             : //  ----------------------------------------------------
    2793          16 : UnoComboBoxControl::UnoComboBoxControl()
    2794             :     :UnoEditControl()
    2795             :     ,maActionListeners( *this )
    2796          16 :     ,maItemListeners( *this )
    2797             : {
    2798          16 :     maComponentInfos.nWidth = 100;
    2799          16 :     maComponentInfos.nHeight = 12;
    2800          16 : }
    2801           1 : IMPL_SERVICEINFO_DERIVED( UnoComboBoxControl, UnoEditControl, szServiceName2_UnoControlComboBox )
    2802             : 
    2803          22 : OUString UnoComboBoxControl::GetComponentServiceName()
    2804             : {
    2805          22 :     return OUString("combobox");
    2806             : }
    2807             : 
    2808          15 : void UnoComboBoxControl::dispose() throw(uno::RuntimeException)
    2809             : {
    2810          15 :     lang::EventObject aEvt;
    2811          15 :     aEvt.Source = (::cppu::OWeakObject*)this;
    2812          15 :     maActionListeners.disposeAndClear( aEvt );
    2813          15 :     maItemListeners.disposeAndClear( aEvt );
    2814          15 :     UnoControl::dispose();
    2815          15 : }
    2816         622 : uno::Any UnoComboBoxControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
    2817             : {
    2818             :     uno::Any aRet = ::cppu::queryInterface( rType,
    2819         622 :                                         (static_cast< awt::XComboBox* >(this)) );
    2820         622 :     if ( !aRet.hasValue() )
    2821             :     {
    2822        1236 :         aRet = ::cppu::queryInterface( rType,
    2823         618 :                                         (static_cast< awt::XItemListener* >(this)) );
    2824         618 :         if ( !aRet.hasValue() )
    2825             :         {
    2826        1236 :             aRet = ::cppu::queryInterface( rType,
    2827         618 :                                             (static_cast< awt::XItemListListener* >(this)) );
    2828             :         }
    2829             :     }
    2830         622 :     return (aRet.hasValue() ? aRet : UnoEditControl::queryAggregation( rType ));
    2831             : }
    2832             : // lang::XTypeProvider
    2833          25 : IMPL_XTYPEPROVIDER_START( UnoComboBoxControl )
    2834           1 :     getCppuType( ( uno::Reference< awt::XComboBox>* ) NULL ),
    2835           1 :     getCppuType( ( uno::Reference< awt::XItemListener>* ) NULL ),
    2836           1 :     getCppuType( ( uno::Reference< awt::XItemListListener>* ) NULL ),
    2837             :     UnoEditControl::getTypes()
    2838           2 : IMPL_XTYPEPROVIDER_END
    2839             : 
    2840          22 : void UnoComboBoxControl::updateFromModel()
    2841             : {
    2842          22 :     UnoEditControl::updateFromModel();
    2843             : 
    2844          22 :     Reference< XItemListListener > xItemListListener( getPeer(), UNO_QUERY );
    2845          44 :     ENSURE_OR_RETURN_VOID( xItemListListener.is(), "UnoComboBoxControl::updateFromModel: a peer which is no ItemListListener?!" );
    2846             : 
    2847          44 :     EventObject aEvent( getModel() );
    2848          44 :     xItemListListener->itemListChanged( aEvent );
    2849             : }
    2850        1840 : void UnoComboBoxControl::ImplSetPeerProperty( const OUString& rPropName, const uno::Any& rVal )
    2851             : {
    2852        1840 :     if ( rPropName == GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) )
    2853             :         // do not forward this to our peer. We are a XItemListListener at our model, and changes in the string item
    2854             :         // list (which is a legacy property) will, later, arrive as changes in the ItemList. Those latter changes
    2855             :         // will be forwarded to the peer, which will update itself accordingly.
    2856        1896 :         return;
    2857             : 
    2858        1784 :     UnoEditControl::ImplSetPeerProperty( rPropName, rVal );
    2859             : }
    2860          24 : void UnoComboBoxControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer >  & rParentPeer ) throw(uno::RuntimeException)
    2861             : {
    2862          24 :     UnoEditControl::createPeer( rxToolkit, rParentPeer );
    2863             : 
    2864          24 :     uno::Reference < awt::XComboBox >  xComboBox( getPeer(), uno::UNO_QUERY );
    2865          24 :     if ( maActionListeners.getLength() )
    2866           0 :         xComboBox->addActionListener( &maActionListeners );
    2867          24 :     if ( maItemListeners.getLength() )
    2868           0 :         xComboBox->addItemListener( &maItemListeners );
    2869          24 : }
    2870             : 
    2871           3 : void UnoComboBoxControl::addActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
    2872             : {
    2873           3 :     maActionListeners.addInterface( l );
    2874           3 :     if( getPeer().is() && maActionListeners.getLength() == 1 )
    2875             :     {
    2876           3 :         uno::Reference < awt::XComboBox >  xComboBox( getPeer(), uno::UNO_QUERY );
    2877           3 :         xComboBox->addActionListener( &maActionListeners );
    2878             :     }
    2879           3 : }
    2880             : 
    2881           0 : void UnoComboBoxControl::removeActionListener(const uno::Reference< awt::XActionListener > & l) throw(uno::RuntimeException)
    2882             : {
    2883           0 :     if( getPeer().is() && maActionListeners.getLength() == 1 )
    2884             :     {
    2885           0 :         uno::Reference < awt::XComboBox >  xComboBox( getPeer(), uno::UNO_QUERY );
    2886           0 :         xComboBox->removeActionListener( &maActionListeners );
    2887             :     }
    2888           0 :     maActionListeners.removeInterface( l );
    2889           0 : }
    2890             : 
    2891           3 : void UnoComboBoxControl::addItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
    2892             : {
    2893           3 :     maItemListeners.addInterface( l );
    2894           3 :     if( getPeer().is() && maItemListeners.getLength() == 1 )
    2895             :     {
    2896           3 :         uno::Reference < awt::XComboBox >  xComboBox( getPeer(), uno::UNO_QUERY );
    2897           3 :         xComboBox->addItemListener( &maItemListeners );
    2898             :     }
    2899           3 : }
    2900             : 
    2901           0 : void UnoComboBoxControl::removeItemListener(const uno::Reference < awt::XItemListener > & l) throw(uno::RuntimeException)
    2902             : {
    2903           0 :     if( getPeer().is() && maItemListeners.getLength() == 1 )
    2904             :     {
    2905             :         // This call is prettier than creating a Ref and calling query
    2906           0 :         uno::Reference < awt::XComboBox >  xComboBox( getPeer(), uno::UNO_QUERY );
    2907           0 :         xComboBox->removeItemListener( &maItemListeners );
    2908             :     }
    2909           0 :     maItemListeners.removeInterface( l );
    2910           0 : }
    2911           0 : void UnoComboBoxControl::itemStateChanged( const awt::ItemEvent& rEvent ) throw(uno::RuntimeException)
    2912             : {
    2913           0 :     if ( maItemListeners.getLength() )
    2914             :     {
    2915             :         try
    2916             :         {
    2917           0 :             maItemListeners.itemStateChanged( rEvent );
    2918             :         }
    2919           0 :         catch( const Exception& e )
    2920             :         {
    2921             : #if OSL_DEBUG_LEVEL == 0
    2922             :             (void) e; // suppress warning
    2923             : #else
    2924             :             OString sMessage( "UnoComboBoxControl::itemStateChanged: caught an exception:\n" );
    2925             :             sMessage += OString( e.Message.getStr(), e.Message.getLength(), RTL_TEXTENCODING_ASCII_US );
    2926             :             OSL_FAIL( sMessage.getStr() );
    2927             : #endif
    2928             :         }
    2929             :     }
    2930           0 : }
    2931          28 : sal_Bool SAL_CALL UnoComboBoxControl::setModel( const uno::Reference< awt::XControlModel >& i_rModel ) throw ( uno::RuntimeException )
    2932             : {
    2933          28 :     ::osl::MutexGuard aGuard( GetMutex() );
    2934             : 
    2935          56 :     const Reference< XItemList > xOldItems( getModel(), UNO_QUERY );
    2936             :     OSL_ENSURE( xOldItems.is() || !getModel().is(), "UnoComboBoxControl::setModel: illegal old model!" );
    2937          56 :     const Reference< XItemList > xNewItems( i_rModel, UNO_QUERY );
    2938             :     OSL_ENSURE( xNewItems.is() || !i_rModel.is(), "UnoComboBoxControl::setModel: illegal new model!" );
    2939             : 
    2940          28 :     if ( !UnoEditControl::setModel( i_rModel ) )
    2941          15 :         return sal_False;
    2942             : 
    2943          13 :     if ( xOldItems.is() )
    2944           4 :         xOldItems->removeItemListListener( this );
    2945          13 :     if ( xNewItems.is() )
    2946          13 :         xNewItems->addItemListListener( this );
    2947             : 
    2948          41 :     return sal_True;
    2949             : }
    2950             : 
    2951           0 : void SAL_CALL UnoComboBoxControl::listItemInserted( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException)
    2952             : {
    2953           0 :     const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY );
    2954             :     OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoComboBoxControl::listItemInserted: invalid peer!" );
    2955           0 :     if ( xPeerListener.is() )
    2956           0 :         xPeerListener->listItemInserted( i_rEvent );
    2957           0 : }
    2958             : 
    2959           0 : void SAL_CALL UnoComboBoxControl::listItemRemoved( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException)
    2960             : {
    2961           0 :     const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY );
    2962             :     OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoComboBoxControl::listItemRemoved: invalid peer!" );
    2963           0 :     if ( xPeerListener.is() )
    2964           0 :         xPeerListener->listItemRemoved( i_rEvent );
    2965           0 : }
    2966             : 
    2967           0 : void SAL_CALL UnoComboBoxControl::listItemModified( const awt::ItemListEvent& i_rEvent ) throw (uno::RuntimeException)
    2968             : {
    2969           0 :     const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY );
    2970             :     OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoComboBoxControl::listItemModified: invalid peer!" );
    2971           0 :     if ( xPeerListener.is() )
    2972           0 :         xPeerListener->listItemModified( i_rEvent );
    2973           0 : }
    2974             : 
    2975           0 : void SAL_CALL UnoComboBoxControl::allItemsRemoved( const lang::EventObject& i_rEvent ) throw (uno::RuntimeException)
    2976             : {
    2977           0 :     const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY );
    2978             :     OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoComboBoxControl::allItemsRemoved: invalid peer!" );
    2979           0 :     if ( xPeerListener.is() )
    2980           0 :         xPeerListener->allItemsRemoved( i_rEvent );
    2981           0 : }
    2982             : 
    2983          17 : void SAL_CALL UnoComboBoxControl::itemListChanged( const lang::EventObject& i_rEvent ) throw (uno::RuntimeException)
    2984             : {
    2985          17 :     const Reference< XItemListListener > xPeerListener( getPeer(), UNO_QUERY );
    2986             :     OSL_ENSURE( xPeerListener.is() || !getPeer().is(), "UnoComboBoxControl::itemListChanged: invalid peer!" );
    2987          17 :     if ( xPeerListener.is() )
    2988          17 :         xPeerListener->itemListChanged( i_rEvent );
    2989          17 : }
    2990             : 
    2991           2 : void UnoComboBoxControl::addItem( const OUString& aItem, sal_Int16 nPos ) throw(uno::RuntimeException)
    2992             : {
    2993           2 :     uno::Sequence< OUString> aSeq( 1 );
    2994           2 :     aSeq.getArray()[0] = aItem;
    2995           2 :     addItems( aSeq, nPos );
    2996           2 : }
    2997             : 
    2998           4 : void UnoComboBoxControl::addItems( const uno::Sequence< OUString>& aItems, sal_Int16 nPos ) throw(uno::RuntimeException)
    2999             : {
    3000           4 :     uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
    3001           8 :     uno::Sequence< OUString> aSeq;
    3002           4 :     aVal >>= aSeq;
    3003           4 :     sal_uInt16 nNewItems = (sal_uInt16)aItems.getLength();
    3004           4 :     sal_uInt16 nOldLen = (sal_uInt16)aSeq.getLength();
    3005           4 :     sal_uInt16 nNewLen = nOldLen + nNewItems;
    3006             : 
    3007           8 :     uno::Sequence< OUString> aNewSeq( nNewLen );
    3008           4 :     OUString* pNewData = aNewSeq.getArray();
    3009           4 :     const OUString* pOldData = aSeq.getConstArray();
    3010             : 
    3011           4 :     if ( ( nPos < 0 ) || ( nPos > nOldLen ) )
    3012           0 :         nPos = (sal_uInt16) nOldLen;
    3013             : 
    3014             :     sal_uInt16 n;
    3015             :     // items before the insert position
    3016           6 :     for ( n = 0; n < nPos; n++ )
    3017           2 :         pNewData[n] = pOldData[n];
    3018             : 
    3019             :     // New items
    3020          10 :     for ( n = 0; n < nNewItems; n++ )
    3021           6 :         pNewData[nPos+n] = aItems.getConstArray()[n];
    3022             : 
    3023             :     // remainder of old items
    3024           4 :     for ( n = nPos; n < nOldLen; n++ )
    3025           0 :         pNewData[nNewItems+n] = pOldData[n];
    3026             : 
    3027           8 :     uno::Any aAny;
    3028           4 :     aAny <<= aNewSeq;
    3029           8 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), aAny, sal_True );
    3030           4 : }
    3031             : 
    3032           2 : void UnoComboBoxControl::removeItems( sal_Int16 nPos, sal_Int16 nCount ) throw(uno::RuntimeException)
    3033             : {
    3034           2 :     uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
    3035           4 :     uno::Sequence< OUString> aSeq;
    3036           2 :     aVal >>= aSeq;
    3037           2 :     sal_uInt16 nOldLen = (sal_uInt16)aSeq.getLength();
    3038           2 :     if ( nOldLen && ( nPos < nOldLen ) )
    3039             :     {
    3040           2 :         if ( nCount > ( nOldLen-nPos ) )
    3041           0 :             nCount = nOldLen-nPos;
    3042             : 
    3043           2 :         sal_uInt16 nNewLen = nOldLen - nCount;
    3044             : 
    3045           2 :         uno::Sequence< OUString> aNewSeq( nNewLen );
    3046           2 :         OUString* pNewData = aNewSeq.getArray();
    3047           2 :         OUString* pOldData = aSeq.getArray();
    3048             : 
    3049             :         sal_uInt16 n;
    3050             :         // items before the deletion position
    3051           2 :         for ( n = 0; n < nPos; n++ )
    3052           0 :             pNewData[n] = pOldData[n];
    3053             : 
    3054             :         // remainder of old items
    3055           2 :         for ( n = nPos; n < (nOldLen-nCount); n++ )
    3056           0 :             pNewData[n] = pOldData[n+nCount];
    3057             : 
    3058           4 :         uno::Any aAny;
    3059           2 :         aAny <<= aNewSeq;
    3060           4 :         ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ), aAny, sal_True );
    3061           2 :     }
    3062           2 : }
    3063             : 
    3064          12 : sal_Int16 UnoComboBoxControl::getItemCount() throw(uno::RuntimeException)
    3065             : {
    3066          12 :     uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
    3067          24 :     uno::Sequence< OUString> aSeq;
    3068          12 :     aVal >>= aSeq;
    3069          24 :     return (sal_Int16)aSeq.getLength();
    3070             : }
    3071             : 
    3072           2 : OUString UnoComboBoxControl::getItem( sal_Int16 nPos ) throw(uno::RuntimeException)
    3073             : {
    3074           2 :     OUString aItem;
    3075           4 :     uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
    3076           4 :     uno::Sequence< OUString> aSeq;
    3077           2 :     aVal >>= aSeq;
    3078           2 :     if ( nPos < aSeq.getLength() )
    3079           2 :         aItem = aSeq.getConstArray()[nPos];
    3080           4 :     return aItem;
    3081             : }
    3082             : 
    3083           2 : uno::Sequence< OUString> UnoComboBoxControl::getItems() throw(uno::RuntimeException)
    3084             : {
    3085           2 :     uno::Any aVal = ImplGetPropertyValue( GetPropertyName( BASEPROPERTY_STRINGITEMLIST ) );
    3086           2 :     uno::Sequence< OUString> aSeq;
    3087           2 :     aVal >>= aSeq;
    3088           2 :     return aSeq;
    3089             : }
    3090             : 
    3091           2 : void UnoComboBoxControl::setDropDownLineCount( sal_Int16 nLines ) throw(uno::RuntimeException)
    3092             : {
    3093           2 :     uno::Any aAny;
    3094           2 :     aAny <<= nLines;
    3095           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LINECOUNT ), aAny, sal_True );
    3096           2 : }
    3097             : 
    3098           4 : sal_Int16 UnoComboBoxControl::getDropDownLineCount() throw(uno::RuntimeException)
    3099             : {
    3100           4 :     return ImplGetPropertyValue_INT16( BASEPROPERTY_LINECOUNT );
    3101             : }
    3102             : 
    3103             : 
    3104             : //  ----------------------------------------------------
    3105             : //  UnoSpinFieldControl
    3106             : //  ----------------------------------------------------
    3107          36 : UnoSpinFieldControl::UnoSpinFieldControl()
    3108             :     :UnoEditControl()
    3109          36 :     ,maSpinListeners( *this )
    3110             : {
    3111          36 :     mbRepeat = sal_False;
    3112          36 : }
    3113             : 
    3114             : // uno::XInterface
    3115        2492 : uno::Any UnoSpinFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
    3116             : {
    3117             :     uno::Any aRet = ::cppu::queryInterface( rType,
    3118        2492 :                                         (static_cast< awt::XSpinField* >(this)) );
    3119        2492 :     return (aRet.hasValue() ? aRet : UnoEditControl::queryAggregation( rType ));
    3120             : }
    3121             : 
    3122             : // lang::XTypeProvider
    3123           0 : IMPL_XTYPEPROVIDER_START( UnoSpinFieldControl )
    3124           0 :     getCppuType( ( uno::Reference< awt::XSpinField>* ) NULL ),
    3125             :     UnoEditControl::getTypes()
    3126           0 : IMPL_XTYPEPROVIDER_END
    3127             : 
    3128          98 : void UnoSpinFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer >  & rParentPeer ) throw(uno::RuntimeException)
    3129             : {
    3130          98 :     UnoEditControl::createPeer( rxToolkit, rParentPeer );
    3131             : 
    3132          98 :     uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
    3133          98 :     xField->enableRepeat( mbRepeat );
    3134          98 :     if ( maSpinListeners.getLength() )
    3135           0 :         xField->addSpinListener( &maSpinListeners );
    3136          98 : }
    3137             : 
    3138             :     // ::com::sun::star::awt::XSpinField
    3139          11 : void UnoSpinFieldControl::addSpinListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinListener >& l ) throw(::com::sun::star::uno::RuntimeException)
    3140             : {
    3141          11 :     maSpinListeners.addInterface( l );
    3142          11 :     if( getPeer().is() && maSpinListeners.getLength() == 1 )
    3143             :     {
    3144          11 :         uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
    3145          11 :         xField->addSpinListener( &maSpinListeners );
    3146             :     }
    3147          11 : }
    3148             : 
    3149          11 : void UnoSpinFieldControl::removeSpinListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XSpinListener >& l ) throw(::com::sun::star::uno::RuntimeException)
    3150             : {
    3151          11 :     if( getPeer().is() && maSpinListeners.getLength() == 1 )
    3152             :     {
    3153          11 :         uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
    3154          11 :         xField->removeSpinListener( &maSpinListeners );
    3155             :     }
    3156          11 :     maSpinListeners.removeInterface( l );
    3157          11 : }
    3158             : 
    3159          22 : void UnoSpinFieldControl::up() throw(::com::sun::star::uno::RuntimeException)
    3160             : {
    3161          22 :     uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
    3162          22 :     if ( xField.is() )
    3163          22 :         xField->up();
    3164          22 : }
    3165             : 
    3166          11 : void UnoSpinFieldControl::down() throw(::com::sun::star::uno::RuntimeException)
    3167             : {
    3168          11 :     uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
    3169          11 :     if ( xField.is() )
    3170          11 :         xField->down();
    3171          11 : }
    3172             : 
    3173          11 : void UnoSpinFieldControl::first() throw(::com::sun::star::uno::RuntimeException)
    3174             : {
    3175          11 :     uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
    3176          11 :     if ( xField.is() )
    3177          11 :         xField->first();
    3178          11 : }
    3179             : 
    3180          11 : void UnoSpinFieldControl::last() throw(::com::sun::star::uno::RuntimeException)
    3181             : {
    3182          11 :     uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
    3183          11 :     if ( xField.is() )
    3184          11 :         xField->last();
    3185          11 : }
    3186             : 
    3187          22 : void UnoSpinFieldControl::enableRepeat( sal_Bool bRepeat ) throw(::com::sun::star::uno::RuntimeException)
    3188             : {
    3189          22 :     mbRepeat = bRepeat;
    3190             : 
    3191          22 :     uno::Reference < awt::XSpinField > xField( getPeer(), uno::UNO_QUERY );
    3192          22 :     if ( xField.is() )
    3193          22 :         xField->enableRepeat( bRepeat );
    3194          22 : }
    3195             : 
    3196             : //  ----------------------------------------------------
    3197             : //  class UnoControlDateFieldModel
    3198             : //  ----------------------------------------------------
    3199          24 : UnoControlDateFieldModel::UnoControlDateFieldModel( const Reference< XComponentContext >& rxContext )
    3200          24 :     :UnoControlModel( rxContext )
    3201             : {
    3202          24 :     UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXDateField );
    3203          24 : }
    3204             : 
    3205           1 : OUString UnoControlDateFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
    3206             : {
    3207           1 :     return OUString::createFromAscii( szServiceName_UnoControlDateFieldModel );
    3208             : }
    3209             : 
    3210         919 : uno::Any UnoControlDateFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
    3211             : {
    3212         919 :     if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
    3213             :     {
    3214          27 :         uno::Any aAny;
    3215          27 :         aAny <<= OUString::createFromAscii( szServiceName_UnoControlDateField );
    3216          27 :         return aAny;
    3217             :     }
    3218         892 :     return UnoControlModel::ImplGetDefaultValue( nPropId );
    3219             : }
    3220             : 
    3221             : 
    3222        7475 : ::cppu::IPropertyArrayHelper& UnoControlDateFieldModel::getInfoHelper()
    3223             : {
    3224             :     static UnoPropertyArrayHelper* pHelper = NULL;
    3225        7475 :     if ( !pHelper )
    3226             :     {
    3227           5 :         uno::Sequence<sal_Int32>    aIDs = ImplGetPropertyIds();
    3228           5 :         pHelper = new UnoPropertyArrayHelper( aIDs );
    3229             :     }
    3230        7475 :     return *pHelper;
    3231             : }
    3232             : 
    3233             : // beans::XMultiPropertySet
    3234         107 : uno::Reference< beans::XPropertySetInfo > UnoControlDateFieldModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
    3235             : {
    3236         107 :     static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
    3237         107 :     return xInfo;
    3238             : }
    3239             : 
    3240             : 
    3241             : 
    3242             : //  ----------------------------------------------------
    3243             : //  class UnoDateFieldControl
    3244             : //  ----------------------------------------------------
    3245           7 : UnoDateFieldControl::UnoDateFieldControl()
    3246           7 :     :UnoSpinFieldControl()
    3247             : {
    3248           7 :     mnFirst = Date( 1, 1, 1900 ).GetDate();
    3249           7 :     mnLast = Date( 31, 12, 2200 ).GetDate();
    3250           7 :     mbLongFormat = 2;
    3251           7 : }
    3252             : 
    3253          27 : OUString UnoDateFieldControl::GetComponentServiceName()
    3254             : {
    3255          27 :     return OUString("datefield");
    3256             : }
    3257             : 
    3258             : // uno::XInterface
    3259         531 : uno::Any UnoDateFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
    3260             : {
    3261             :     uno::Any aRet = ::cppu::queryInterface( rType,
    3262         531 :                                         (static_cast< awt::XDateField* >(this)) );
    3263         531 :     return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType ));
    3264             : }
    3265             : 
    3266             : // lang::XTypeProvider
    3267           0 : IMPL_XTYPEPROVIDER_START( UnoDateFieldControl )
    3268           0 :     getCppuType( ( uno::Reference< awt::XDateField>* ) NULL ),
    3269             :     UnoSpinFieldControl::getTypes()
    3270           0 : IMPL_XTYPEPROVIDER_END
    3271             : 
    3272          29 : void UnoDateFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer >  & rParentPeer ) throw(uno::RuntimeException)
    3273             : {
    3274          29 :     UnoSpinFieldControl::createPeer( rxToolkit, rParentPeer );
    3275             : 
    3276          29 :     uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
    3277          29 :     xField->setFirst( mnFirst );
    3278          29 :     xField->setLast( mnLast );
    3279          29 :     if ( mbLongFormat != 2 )    // not set
    3280           2 :         xField->setLongFormat( mbLongFormat );
    3281          29 : }
    3282             : 
    3283             : 
    3284          24 : void UnoDateFieldControl::textChanged( const awt::TextEvent& e ) throw(uno::RuntimeException)
    3285             : {
    3286          24 :     uno::Reference< awt::XVclWindowPeer > xPeer( getPeer(), uno::UNO_QUERY );
    3287             : 
    3288             :     // also change the text property (#i25106#)
    3289          24 :     if ( xPeer.is() )
    3290             :     {
    3291          24 :         OUString sTextPropertyName = GetPropertyName( BASEPROPERTY_TEXT );
    3292          24 :         ImplSetPropertyValue( sTextPropertyName, xPeer->getProperty( sTextPropertyName ), sal_False );
    3293             :     }
    3294             : 
    3295             :     // re-calc the Date property
    3296          48 :     uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
    3297          48 :     uno::Any aValue;
    3298          24 :     if ( xField->isEmpty() )
    3299             :     {
    3300             :         // the field says it's empty
    3301           4 :         sal_Bool bEnforceFormat = sal_True;
    3302           4 :         if ( xPeer.is() )
    3303           4 :             xPeer->getProperty( GetPropertyName( BASEPROPERTY_ENFORCE_FORMAT ) ) >>= bEnforceFormat;
    3304           4 :         if ( !bEnforceFormat )
    3305             :         {
    3306             :             // and it also says that it is currently accepting invalid inputs, without
    3307             :             // forcing it to a valid date
    3308           0 :             uno::Reference< awt::XTextComponent > xText( xPeer, uno::UNO_QUERY );
    3309           0 :             if ( xText.is() && xText->getText().getLength() )
    3310             :                 // and in real, the text of the peer is *not* empty
    3311             :                 // -> simulate an invalid date, which is different from "no date"
    3312           0 :                 aValue <<= util::Date( 0, 0, 0 );
    3313             :         }
    3314             :     }
    3315             :     else
    3316          20 :         aValue <<= xField->getDate();
    3317             : 
    3318          24 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATE ), aValue, sal_False );
    3319             : 
    3320             :     // multiplex the event
    3321          24 :     if ( GetTextListeners().getLength() )
    3322          48 :         GetTextListeners().textChanged( e );
    3323          24 : }
    3324             : 
    3325           2 : void UnoDateFieldControl::setDate( sal_Int32 Date ) throw(uno::RuntimeException)
    3326             : {
    3327           2 :     uno::Any aAny;
    3328           2 :     aAny <<= Date;
    3329           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATE ), aAny, sal_True );
    3330           2 : }
    3331             : 
    3332           4 : sal_Int32 UnoDateFieldControl::getDate() throw(uno::RuntimeException)
    3333             : {
    3334           4 :     return ImplGetPropertyValue_INT32( BASEPROPERTY_DATE );
    3335             : }
    3336             : 
    3337           2 : void UnoDateFieldControl::setMin( sal_Int32 Date ) throw(uno::RuntimeException)
    3338             : {
    3339           2 :     uno::Any aAny;
    3340           2 :     aAny <<= Date;
    3341           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATEMIN ), aAny, sal_True );
    3342           2 : }
    3343             : 
    3344           4 : sal_Int32 UnoDateFieldControl::getMin() throw(uno::RuntimeException)
    3345             : {
    3346           4 :     return ImplGetPropertyValue_INT32( BASEPROPERTY_DATEMIN );
    3347             : }
    3348             : 
    3349           2 : void UnoDateFieldControl::setMax( sal_Int32 Date ) throw(uno::RuntimeException)
    3350             : {
    3351           2 :     uno::Any aAny;
    3352           2 :     aAny <<= Date;
    3353           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DATEMAX ), aAny, sal_True );
    3354           2 : }
    3355             : 
    3356           4 : sal_Int32 UnoDateFieldControl::getMax() throw(uno::RuntimeException)
    3357             : {
    3358           4 :     return ImplGetPropertyValue_INT32( BASEPROPERTY_DATEMAX );
    3359             : }
    3360             : 
    3361           2 : void UnoDateFieldControl::setFirst( sal_Int32 Date ) throw(uno::RuntimeException)
    3362             : {
    3363           2 :     mnFirst = Date;
    3364           2 :     if ( getPeer().is() )
    3365             :     {
    3366           2 :         uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
    3367           2 :         xField->setFirst( Date );
    3368             :     }
    3369           2 : }
    3370             : 
    3371           4 : sal_Int32 UnoDateFieldControl::getFirst() throw(uno::RuntimeException)
    3372             : {
    3373           4 :     return mnFirst;
    3374             : }
    3375             : 
    3376           2 : void UnoDateFieldControl::setLast( sal_Int32 Date ) throw(uno::RuntimeException)
    3377             : {
    3378           2 :     mnLast = Date;
    3379           2 :     if ( getPeer().is() )
    3380             :     {
    3381           2 :         uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
    3382           2 :         xField->setLast( Date );
    3383             :     }
    3384           2 : }
    3385             : 
    3386           4 : sal_Int32 UnoDateFieldControl::getLast() throw(uno::RuntimeException)
    3387             : {
    3388           4 :     return mnLast;
    3389             : }
    3390             : 
    3391           2 : void UnoDateFieldControl::setLongFormat( sal_Bool bLong ) throw(uno::RuntimeException)
    3392             : {
    3393           2 :     mbLongFormat = bLong;
    3394           2 :     if ( getPeer().is() )
    3395             :     {
    3396           2 :         uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
    3397           2 :         xField->setLongFormat( bLong );
    3398             :     }
    3399           2 : }
    3400             : 
    3401           4 : sal_Bool UnoDateFieldControl::isLongFormat() throw(uno::RuntimeException)
    3402             : {
    3403           4 :     return ( mbLongFormat != 2 ) ? mbLongFormat : sal_False;
    3404             : }
    3405             : 
    3406           2 : void UnoDateFieldControl::setEmpty() throw(uno::RuntimeException)
    3407             : {
    3408           2 :     if ( getPeer().is() )
    3409             :     {
    3410           2 :         uno::Reference < awt::XDateField >  xField( getPeer(), uno::UNO_QUERY );
    3411           2 :         xField->setEmpty();
    3412             :     }
    3413           2 : }
    3414             : 
    3415           2 : sal_Bool UnoDateFieldControl::isEmpty() throw(uno::RuntimeException)
    3416             : {
    3417           2 :     sal_Bool bEmpty = sal_False;
    3418           2 :     if ( getPeer().is() )
    3419             :     {
    3420           2 :         uno::Reference < awt::XDateField > xField( getPeer(), uno::UNO_QUERY );
    3421           2 :         bEmpty = xField->isEmpty();
    3422             :     }
    3423           2 :     return bEmpty;
    3424             : }
    3425             : 
    3426           2 : void UnoDateFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException)
    3427             : {
    3428           2 :     uno::Any aAny;
    3429           2 :     aAny <<= bStrict;
    3430           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, sal_True );
    3431           2 : }
    3432             : 
    3433           4 : sal_Bool UnoDateFieldControl::isStrictFormat() throw(uno::RuntimeException)
    3434             : {
    3435           4 :     return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT );
    3436             : }
    3437             : 
    3438             : //  ----------------------------------------------------
    3439             : //  class UnoControlTimeFieldModel
    3440             : //  ----------------------------------------------------
    3441          14 : UnoControlTimeFieldModel::UnoControlTimeFieldModel( const Reference< XComponentContext >& rxContext )
    3442          14 :     :UnoControlModel( rxContext )
    3443             : {
    3444          14 :     UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXTimeField );
    3445          14 : }
    3446             : 
    3447           1 : OUString UnoControlTimeFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
    3448             : {
    3449           1 :     return OUString::createFromAscii( szServiceName_UnoControlTimeFieldModel );
    3450             : }
    3451             : 
    3452         514 : uno::Any UnoControlTimeFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
    3453             : {
    3454         514 :     if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
    3455             :     {
    3456          16 :         uno::Any aAny;
    3457          16 :         aAny <<= OUString::createFromAscii( szServiceName_UnoControlTimeField );
    3458          16 :         return aAny;
    3459             :     }
    3460         498 :     return UnoControlModel::ImplGetDefaultValue( nPropId );
    3461             : }
    3462             : 
    3463             : 
    3464        5928 : ::cppu::IPropertyArrayHelper& UnoControlTimeFieldModel::getInfoHelper()
    3465             : {
    3466             :     static UnoPropertyArrayHelper* pHelper = NULL;
    3467        5928 :     if ( !pHelper )
    3468             :     {
    3469           3 :         uno::Sequence<sal_Int32>    aIDs = ImplGetPropertyIds();
    3470           3 :         pHelper = new UnoPropertyArrayHelper( aIDs );
    3471             :     }
    3472        5928 :     return *pHelper;
    3473             : }
    3474             : 
    3475             : // beans::XMultiPropertySet
    3476          81 : uno::Reference< beans::XPropertySetInfo > UnoControlTimeFieldModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
    3477             : {
    3478          81 :     static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
    3479          81 :     return xInfo;
    3480             : }
    3481             : 
    3482             : 
    3483             : 
    3484             : //  ----------------------------------------------------
    3485             : //  class UnoTimeFieldControl
    3486             : //  ----------------------------------------------------
    3487           7 : UnoTimeFieldControl::UnoTimeFieldControl()
    3488           7 :     :UnoSpinFieldControl()
    3489             : {
    3490           7 :     mnFirst = Time( 0, 0 ).GetTime();
    3491           7 :     mnLast = Time( 23, 59, 59, 99 ).GetTime();
    3492           7 : }
    3493             : 
    3494          17 : OUString UnoTimeFieldControl::GetComponentServiceName()
    3495             : {
    3496          17 :     return OUString("timefield");
    3497             : }
    3498             : 
    3499             : // uno::XInterface
    3500         435 : uno::Any UnoTimeFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
    3501             : {
    3502             :     uno::Any aRet = ::cppu::queryInterface( rType,
    3503         435 :                                         (static_cast< awt::XTimeField* >(this)) );
    3504         435 :     return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType ));
    3505             : }
    3506             : 
    3507             : // lang::XTypeProvider
    3508           0 : IMPL_XTYPEPROVIDER_START( UnoTimeFieldControl )
    3509           0 :     getCppuType( ( uno::Reference< awt::XTimeField>* ) NULL ),
    3510             :     UnoSpinFieldControl::getTypes()
    3511           0 : IMPL_XTYPEPROVIDER_END
    3512             : 
    3513          19 : void UnoTimeFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer >  & rParentPeer ) throw(uno::RuntimeException)
    3514             : {
    3515          19 :     UnoSpinFieldControl::createPeer( rxToolkit, rParentPeer );
    3516             : 
    3517          19 :     uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY );
    3518          19 :     xField->setFirst( mnFirst );
    3519          19 :     xField->setLast( mnLast );
    3520          19 : }
    3521             : 
    3522          14 : void UnoTimeFieldControl::textChanged( const awt::TextEvent& e ) throw(uno::RuntimeException)
    3523             : {
    3524             :     // also change the text property (#i25106#)
    3525          14 :     uno::Reference< awt::XVclWindowPeer > xPeer( getPeer(), uno::UNO_QUERY );
    3526          28 :     OUString sTextPropertyName = GetPropertyName( BASEPROPERTY_TEXT );
    3527          14 :     ImplSetPropertyValue( sTextPropertyName, xPeer->getProperty( sTextPropertyName ), sal_False );
    3528             : 
    3529             :     // re-calc the Time property
    3530          28 :     uno::Reference < awt::XTimeField >  xField( getPeer(), uno::UNO_QUERY );
    3531          28 :     uno::Any aValue;
    3532          14 :     if ( !xField->isEmpty() )
    3533          12 :         aValue <<= xField->getTime();
    3534          14 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIME ), aValue, sal_False );
    3535             : 
    3536             :     // multiplex the event
    3537          14 :     if ( GetTextListeners().getLength() )
    3538          28 :         GetTextListeners().textChanged( e );
    3539          14 : }
    3540             : 
    3541           2 : void UnoTimeFieldControl::setTime( sal_Int32 Time ) throw(uno::RuntimeException)
    3542             : {
    3543           2 :     uno::Any aAny;
    3544           2 :     aAny <<= Time;
    3545           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIME ), aAny, sal_True );
    3546           2 : }
    3547             : 
    3548           4 : sal_Int32 UnoTimeFieldControl::getTime() throw(uno::RuntimeException)
    3549             : {
    3550           4 :     return ImplGetPropertyValue_INT32( BASEPROPERTY_TIME );
    3551             : }
    3552             : 
    3553           2 : void UnoTimeFieldControl::setMin( sal_Int32 Time ) throw(uno::RuntimeException)
    3554             : {
    3555           2 :     uno::Any aAny;
    3556           2 :     aAny <<= Time;
    3557           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIMEMIN ), aAny, sal_True );
    3558           2 : }
    3559             : 
    3560           4 : sal_Int32 UnoTimeFieldControl::getMin() throw(uno::RuntimeException)
    3561             : {
    3562           4 :     return ImplGetPropertyValue_INT32( BASEPROPERTY_TIMEMIN );
    3563             : }
    3564             : 
    3565           2 : void UnoTimeFieldControl::setMax( sal_Int32 Time ) throw(uno::RuntimeException)
    3566             : {
    3567           2 :     uno::Any aAny;
    3568           2 :     aAny <<= Time;
    3569           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_TIMEMAX ), aAny, sal_True );
    3570           2 : }
    3571             : 
    3572           4 : sal_Int32 UnoTimeFieldControl::getMax() throw(uno::RuntimeException)
    3573             : {
    3574           4 :     return ImplGetPropertyValue_INT32( BASEPROPERTY_TIMEMAX );
    3575             : }
    3576             : 
    3577           2 : void UnoTimeFieldControl::setFirst( sal_Int32 Time ) throw(uno::RuntimeException)
    3578             : {
    3579           2 :     mnFirst = Time;
    3580           2 :     if ( getPeer().is() )
    3581             :     {
    3582           2 :         uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY );
    3583           2 :         xField->setFirst( mnFirst );
    3584             :     }
    3585           2 : }
    3586             : 
    3587           4 : sal_Int32 UnoTimeFieldControl::getFirst() throw(uno::RuntimeException)
    3588             : {
    3589           4 :     return mnFirst;
    3590             : }
    3591             : 
    3592           2 : void UnoTimeFieldControl::setLast( sal_Int32 Time ) throw(uno::RuntimeException)
    3593             : {
    3594           2 :     mnLast = Time;
    3595           2 :     if ( getPeer().is() )
    3596             :     {
    3597           2 :         uno::Reference < awt::XTimeField > xField( getPeer(), uno::UNO_QUERY );
    3598           2 :         xField->setFirst( mnLast );
    3599             :     }
    3600           2 : }
    3601             : 
    3602           4 : sal_Int32 UnoTimeFieldControl::getLast() throw(uno::RuntimeException)
    3603             : {
    3604           4 :     return mnLast;
    3605             : }
    3606             : 
    3607           2 : void UnoTimeFieldControl::setEmpty() throw(uno::RuntimeException)
    3608             : {
    3609           2 :     if ( getPeer().is() )
    3610             :     {
    3611           2 :         uno::Reference < awt::XTimeField >  xField( getPeer(), uno::UNO_QUERY );
    3612           2 :         xField->setEmpty();
    3613             :     }
    3614           2 : }
    3615             : 
    3616           2 : sal_Bool UnoTimeFieldControl::isEmpty() throw(uno::RuntimeException)
    3617             : {
    3618           2 :     sal_Bool bEmpty = sal_False;
    3619           2 :     if ( getPeer().is() )
    3620             :     {
    3621           2 :         uno::Reference < awt::XTimeField >  xField( getPeer(), uno::UNO_QUERY );
    3622           2 :         bEmpty = xField->isEmpty();
    3623             :     }
    3624           2 :     return bEmpty;
    3625             : }
    3626             : 
    3627           2 : void UnoTimeFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException)
    3628             : {
    3629           2 :     uno::Any aAny;
    3630           2 :     aAny <<= bStrict;
    3631           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, sal_True );
    3632           2 : }
    3633             : 
    3634           4 : sal_Bool UnoTimeFieldControl::isStrictFormat() throw(uno::RuntimeException)
    3635             : {
    3636           4 :     return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT );
    3637             : }
    3638             : 
    3639             : //  ----------------------------------------------------
    3640             : //  class UnoControlNumericFieldModel
    3641             : //  ----------------------------------------------------
    3642          14 : UnoControlNumericFieldModel::UnoControlNumericFieldModel( const Reference< XComponentContext >& rxContext )
    3643          14 :     :UnoControlModel( rxContext )
    3644             : {
    3645          14 :     UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXNumericField );
    3646          14 : }
    3647             : 
    3648           1 : OUString UnoControlNumericFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
    3649             : {
    3650           1 :     return OUString::createFromAscii( szServiceName_UnoControlNumericFieldModel );
    3651             : }
    3652             : 
    3653         530 : uno::Any UnoControlNumericFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
    3654             : {
    3655         530 :     if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
    3656             :     {
    3657          16 :         uno::Any aAny;
    3658          16 :         aAny <<= OUString::createFromAscii( szServiceName_UnoControlNumericField );
    3659          16 :         return aAny;
    3660             :     }
    3661         514 :     return UnoControlModel::ImplGetDefaultValue( nPropId );
    3662             : }
    3663             : 
    3664             : 
    3665        6172 : ::cppu::IPropertyArrayHelper& UnoControlNumericFieldModel::getInfoHelper()
    3666             : {
    3667             :     static UnoPropertyArrayHelper* pHelper = NULL;
    3668        6172 :     if ( !pHelper )
    3669             :     {
    3670           3 :         uno::Sequence<sal_Int32>    aIDs = ImplGetPropertyIds();
    3671           3 :         pHelper = new UnoPropertyArrayHelper( aIDs );
    3672             :     }
    3673        6172 :     return *pHelper;
    3674             : }
    3675             : 
    3676             : // beans::XMultiPropertySet
    3677          82 : uno::Reference< beans::XPropertySetInfo > UnoControlNumericFieldModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
    3678             : {
    3679          82 :     static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
    3680          82 :     return xInfo;
    3681             : }
    3682             : 
    3683             : 
    3684             : 
    3685             : //  ----------------------------------------------------
    3686             : //  class UnoNumericFieldControl
    3687             : //  ----------------------------------------------------
    3688           7 : UnoNumericFieldControl::UnoNumericFieldControl()
    3689           7 :     :UnoSpinFieldControl()
    3690             : {
    3691           7 :     mnFirst = 0;
    3692           7 :     mnLast = 0x7FFFFFFF;
    3693           7 : }
    3694             : 
    3695          17 : OUString UnoNumericFieldControl::GetComponentServiceName()
    3696             : {
    3697          17 :     return OUString("numericfield");
    3698             : }
    3699             : 
    3700             : // uno::XInterface
    3701         538 : uno::Any UnoNumericFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
    3702             : {
    3703             :     uno::Any aRet = ::cppu::queryInterface( rType,
    3704         538 :                                         (static_cast< awt::XNumericField* >(this)) );
    3705         538 :     return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType ));
    3706             : }
    3707             : 
    3708             : // lang::XTypeProvider
    3709           0 : IMPL_XTYPEPROVIDER_START( UnoNumericFieldControl )
    3710           0 :     getCppuType( ( uno::Reference< awt::XNumericField>* ) NULL ),
    3711             :     UnoSpinFieldControl::getTypes()
    3712           0 : IMPL_XTYPEPROVIDER_END
    3713             : 
    3714          19 : void UnoNumericFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer >  & rParentPeer ) throw(uno::RuntimeException)
    3715             : {
    3716          19 :     UnoSpinFieldControl::createPeer( rxToolkit, rParentPeer );
    3717             : 
    3718          19 :     uno::Reference < awt::XNumericField > xField( getPeer(), uno::UNO_QUERY );
    3719          19 :     xField->setFirst( mnFirst );
    3720          19 :     xField->setLast( mnLast );
    3721          19 : }
    3722             : 
    3723             : 
    3724         106 : void UnoNumericFieldControl::textChanged( const awt::TextEvent& e ) throw(uno::RuntimeException)
    3725             : {
    3726         106 :     uno::Reference < awt::XNumericField >  xField( getPeer(), uno::UNO_QUERY );
    3727         212 :     uno::Any aAny;
    3728         106 :     aAny <<= xField->getValue();
    3729         106 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE ), aAny, sal_False );
    3730             : 
    3731         106 :     if ( GetTextListeners().getLength() )
    3732         212 :         GetTextListeners().textChanged( e );
    3733         106 : }
    3734             : 
    3735           2 : void UnoNumericFieldControl::setValue( double Value ) throw(uno::RuntimeException)
    3736             : {
    3737           2 :     uno::Any aAny;
    3738           2 :     aAny <<= Value;
    3739           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE ), aAny, sal_True );
    3740           2 : }
    3741             : 
    3742           4 : double UnoNumericFieldControl::getValue() throw(uno::RuntimeException)
    3743             : {
    3744           4 :     return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUE_DOUBLE );
    3745             : }
    3746             : 
    3747           2 : void UnoNumericFieldControl::setMin( double Value ) throw(uno::RuntimeException)
    3748             : {
    3749           2 :     uno::Any aAny;
    3750           2 :     aAny <<= Value;
    3751           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMIN_DOUBLE ), aAny, sal_True );
    3752           2 : }
    3753             : 
    3754           4 : double UnoNumericFieldControl::getMin() throw(uno::RuntimeException)
    3755             : {
    3756           4 :     return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMIN_DOUBLE );
    3757             : }
    3758             : 
    3759           2 : void UnoNumericFieldControl::setMax( double Value ) throw(uno::RuntimeException)
    3760             : {
    3761           2 :     uno::Any aAny;
    3762           2 :     aAny <<= Value;
    3763           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMAX_DOUBLE ), aAny, sal_True );
    3764           2 : }
    3765             : 
    3766           4 : double UnoNumericFieldControl::getMax() throw(uno::RuntimeException)
    3767             : {
    3768           4 :     return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMAX_DOUBLE );
    3769             : }
    3770             : 
    3771           2 : void UnoNumericFieldControl::setFirst( double Value ) throw(uno::RuntimeException)
    3772             : {
    3773           2 :     mnFirst = Value;
    3774           2 :     if ( getPeer().is() )
    3775             :     {
    3776           2 :         uno::Reference < awt::XNumericField > xField( getPeer(), uno::UNO_QUERY );
    3777           2 :         xField->setFirst( mnFirst );
    3778             :     }
    3779           2 : }
    3780             : 
    3781           4 : double UnoNumericFieldControl::getFirst() throw(uno::RuntimeException)
    3782             : {
    3783           4 :     return mnFirst;
    3784             : }
    3785             : 
    3786           2 : void UnoNumericFieldControl::setLast( double Value ) throw(uno::RuntimeException)
    3787             : {
    3788           2 :     mnLast = Value;
    3789           2 :     if ( getPeer().is() )
    3790             :     {
    3791           2 :         uno::Reference < awt::XNumericField > xField( getPeer(), uno::UNO_QUERY );
    3792           2 :         xField->setLast( mnLast );
    3793             :     }
    3794           2 : }
    3795             : 
    3796           4 : double UnoNumericFieldControl::getLast() throw(uno::RuntimeException)
    3797             : {
    3798           4 :     return mnLast;
    3799             : }
    3800             : 
    3801           2 : void UnoNumericFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException)
    3802             : {
    3803           2 :     uno::Any aAny;
    3804           2 :     aAny <<= bStrict;
    3805           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, sal_True );
    3806           2 : }
    3807             : 
    3808           4 : sal_Bool UnoNumericFieldControl::isStrictFormat() throw(uno::RuntimeException)
    3809             : {
    3810           4 :     return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT );
    3811             : }
    3812             : 
    3813           2 : void UnoNumericFieldControl::setSpinSize( double Digits ) throw(uno::RuntimeException)
    3814             : {
    3815           2 :     uno::Any aAny;
    3816           2 :     aAny <<= Digits;
    3817           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUESTEP_DOUBLE ), aAny, sal_True );
    3818           2 : }
    3819             : 
    3820           4 : double UnoNumericFieldControl::getSpinSize() throw(uno::RuntimeException)
    3821             : {
    3822           4 :     return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUESTEP_DOUBLE );
    3823             : }
    3824             : 
    3825           2 : void UnoNumericFieldControl::setDecimalDigits( sal_Int16 Digits ) throw(uno::RuntimeException)
    3826             : {
    3827           2 :     uno::Any aAny;
    3828           2 :     aAny <<= Digits;
    3829           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DECIMALACCURACY ), aAny, sal_True );
    3830           2 : }
    3831             : 
    3832           4 : sal_Int16 UnoNumericFieldControl::getDecimalDigits() throw(uno::RuntimeException)
    3833             : {
    3834           4 :     return ImplGetPropertyValue_INT16( BASEPROPERTY_DECIMALACCURACY );
    3835             : }
    3836             : 
    3837             : //  ----------------------------------------------------
    3838             : //  class UnoControlCurrencyFieldModel
    3839             : //  ----------------------------------------------------
    3840          13 : UnoControlCurrencyFieldModel::UnoControlCurrencyFieldModel( const Reference< XComponentContext >& rxContext )
    3841          13 :     :UnoControlModel( rxContext )
    3842             : {
    3843          13 :     UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXCurrencyField );
    3844          13 : }
    3845             : 
    3846           1 : OUString UnoControlCurrencyFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
    3847             : {
    3848           1 :     return OUString::createFromAscii( szServiceName_UnoControlCurrencyFieldModel );
    3849             : }
    3850             : 
    3851         527 : uno::Any UnoControlCurrencyFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
    3852             : {
    3853         527 :     if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
    3854             :     {
    3855          15 :         uno::Any aAny;
    3856          15 :         aAny <<= OUString::createFromAscii( szServiceName_UnoControlCurrencyField );
    3857          15 :         return aAny;
    3858             :     }
    3859         512 :     if ( nPropId == BASEPROPERTY_CURSYM_POSITION )
    3860             :     {
    3861          15 :         uno::Any aAny;
    3862          15 :         aAny <<= (sal_Bool)sal_False;
    3863          15 :         return aAny;
    3864             :     }
    3865             : 
    3866         497 :     return UnoControlModel::ImplGetDefaultValue( nPropId );
    3867             : }
    3868             : 
    3869        6906 : ::cppu::IPropertyArrayHelper& UnoControlCurrencyFieldModel::getInfoHelper()
    3870             : {
    3871             :     static UnoPropertyArrayHelper* pHelper = NULL;
    3872        6906 :     if ( !pHelper )
    3873             :     {
    3874           3 :         uno::Sequence<sal_Int32>    aIDs = ImplGetPropertyIds();
    3875           3 :         pHelper = new UnoPropertyArrayHelper( aIDs );
    3876             :     }
    3877        6906 :     return *pHelper;
    3878             : }
    3879             : 
    3880             : // beans::XMultiPropertySet
    3881          86 : uno::Reference< beans::XPropertySetInfo > UnoControlCurrencyFieldModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
    3882             : {
    3883          86 :     static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
    3884          86 :     return xInfo;
    3885             : }
    3886             : 
    3887             : //  ----------------------------------------------------
    3888             : //  class UnoCurrencyFieldControl
    3889             : //  ----------------------------------------------------
    3890           7 : UnoCurrencyFieldControl::UnoCurrencyFieldControl()
    3891           7 :     :UnoSpinFieldControl()
    3892             : {
    3893           7 :     mnFirst = 0;
    3894           7 :     mnLast = 0x7FFFFFFF;
    3895           7 : }
    3896             : 
    3897          17 : OUString UnoCurrencyFieldControl::GetComponentServiceName()
    3898             : {
    3899          17 :     return OUString("longcurrencyfield");
    3900             : }
    3901             : 
    3902             : // uno::XInterface
    3903         570 : uno::Any UnoCurrencyFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
    3904             : {
    3905             :     uno::Any aRet = ::cppu::queryInterface( rType,
    3906         570 :                                         (static_cast< awt::XCurrencyField* >(this)) );
    3907         570 :     return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType ));
    3908             : }
    3909             : 
    3910             : // lang::XTypeProvider
    3911           0 : IMPL_XTYPEPROVIDER_START( UnoCurrencyFieldControl )
    3912           0 :     getCppuType( ( uno::Reference< awt::XCurrencyField>* ) NULL ),
    3913             :     UnoSpinFieldControl::getTypes()
    3914           0 : IMPL_XTYPEPROVIDER_END
    3915             : 
    3916          19 : void UnoCurrencyFieldControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer >  & rParentPeer ) throw(uno::RuntimeException)
    3917             : {
    3918          19 :     UnoSpinFieldControl::createPeer( rxToolkit, rParentPeer );
    3919             : 
    3920          19 :     uno::Reference < awt::XCurrencyField > xField( getPeer(), uno::UNO_QUERY );
    3921          19 :     xField->setFirst( mnFirst );
    3922          19 :     xField->setLast( mnLast );
    3923          19 : }
    3924             : 
    3925          90 : void UnoCurrencyFieldControl::textChanged( const awt::TextEvent& e ) throw(uno::RuntimeException)
    3926             : {
    3927          90 :     uno::Reference < awt::XCurrencyField >  xField( getPeer(), uno::UNO_QUERY );
    3928         180 :     uno::Any aAny;
    3929          90 :     aAny <<= xField->getValue();
    3930          90 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE ), aAny, sal_False );
    3931             : 
    3932          90 :     if ( GetTextListeners().getLength() )
    3933         180 :         GetTextListeners().textChanged( e );
    3934          90 : }
    3935             : 
    3936           2 : void UnoCurrencyFieldControl::setValue( double Value ) throw(uno::RuntimeException)
    3937             : {
    3938           2 :     uno::Any aAny;
    3939           2 :     aAny <<= Value;
    3940           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUE_DOUBLE ), aAny, sal_True );
    3941           2 : }
    3942             : 
    3943           4 : double UnoCurrencyFieldControl::getValue() throw(uno::RuntimeException)
    3944             : {
    3945           4 :     return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUE_DOUBLE );
    3946             : }
    3947             : 
    3948           2 : void UnoCurrencyFieldControl::setMin( double Value ) throw(uno::RuntimeException)
    3949             : {
    3950           2 :     uno::Any aAny;
    3951           2 :     aAny <<= Value;
    3952           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMIN_DOUBLE ), aAny, sal_True );
    3953           2 : }
    3954             : 
    3955           4 : double UnoCurrencyFieldControl::getMin() throw(uno::RuntimeException)
    3956             : {
    3957           4 :     return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMIN_DOUBLE );
    3958             : }
    3959             : 
    3960           2 : void UnoCurrencyFieldControl::setMax( double Value ) throw(uno::RuntimeException)
    3961             : {
    3962           2 :     uno::Any aAny;
    3963           2 :     aAny <<= Value;
    3964           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUEMAX_DOUBLE ), aAny, sal_True );
    3965           2 : }
    3966             : 
    3967           4 : double UnoCurrencyFieldControl::getMax() throw(uno::RuntimeException)
    3968             : {
    3969           4 :     return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUEMAX_DOUBLE );
    3970             : }
    3971             : 
    3972           2 : void UnoCurrencyFieldControl::setFirst( double Value ) throw(uno::RuntimeException)
    3973             : {
    3974           2 :     mnFirst = Value;
    3975           2 :     if ( getPeer().is() )
    3976             :     {
    3977           2 :         uno::Reference < awt::XCurrencyField > xField( getPeer(), uno::UNO_QUERY );
    3978           2 :         xField->setFirst( mnFirst );
    3979             :     }
    3980           2 : }
    3981             : 
    3982           4 : double UnoCurrencyFieldControl::getFirst() throw(uno::RuntimeException)
    3983             : {
    3984           4 :     return mnFirst;
    3985             : }
    3986             : 
    3987           2 : void UnoCurrencyFieldControl::setLast( double Value ) throw(uno::RuntimeException)
    3988             : {
    3989           2 :     mnLast = Value;
    3990           2 :     if ( getPeer().is() )
    3991             :     {
    3992           2 :         uno::Reference < awt::XCurrencyField > xField( getPeer(), uno::UNO_QUERY );
    3993           2 :         xField->setLast( mnLast );
    3994             :     }
    3995           2 : }
    3996             : 
    3997           4 : double UnoCurrencyFieldControl::getLast() throw(uno::RuntimeException)
    3998             : {
    3999           4 :     return mnLast;
    4000             : }
    4001             : 
    4002           2 : void UnoCurrencyFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException)
    4003             : {
    4004           2 :     uno::Any aAny;
    4005           2 :     aAny <<= bStrict;
    4006           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, sal_True );
    4007           2 : }
    4008             : 
    4009           4 : sal_Bool UnoCurrencyFieldControl::isStrictFormat() throw(uno::RuntimeException)
    4010             : {
    4011           4 :     return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT );
    4012             : }
    4013             : 
    4014           2 : void UnoCurrencyFieldControl::setSpinSize( double Digits ) throw(uno::RuntimeException)
    4015             : {
    4016           2 :     uno::Any aAny;
    4017           2 :     aAny <<= Digits;
    4018           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_VALUESTEP_DOUBLE ), aAny, sal_True );
    4019           2 : }
    4020             : 
    4021           4 : double UnoCurrencyFieldControl::getSpinSize() throw(uno::RuntimeException)
    4022             : {
    4023           4 :     return ImplGetPropertyValue_DOUBLE( BASEPROPERTY_VALUESTEP_DOUBLE );
    4024             : }
    4025             : 
    4026           2 : void UnoCurrencyFieldControl::setDecimalDigits( sal_Int16 Digits ) throw(uno::RuntimeException)
    4027             : {
    4028           2 :     uno::Any aAny;
    4029           2 :     aAny <<= Digits;
    4030           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_DECIMALACCURACY ), aAny, sal_True );
    4031           2 : }
    4032             : 
    4033           4 : sal_Int16 UnoCurrencyFieldControl::getDecimalDigits() throw(uno::RuntimeException)
    4034             : {
    4035           4 :     return ImplGetPropertyValue_INT16( BASEPROPERTY_DECIMALACCURACY );
    4036             : }
    4037             : 
    4038             : //  ----------------------------------------------------
    4039             : //  class UnoControlPatternFieldModel
    4040             : //  ----------------------------------------------------
    4041          13 : UnoControlPatternFieldModel::UnoControlPatternFieldModel( const Reference< XComponentContext >& rxContext )
    4042          13 :     :UnoControlModel( rxContext )
    4043             : {
    4044          13 :     UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXPatternField );
    4045          13 : }
    4046             : 
    4047           1 : OUString UnoControlPatternFieldModel::getServiceName() throw(::com::sun::star::uno::RuntimeException)
    4048             : {
    4049           1 :     return OUString::createFromAscii( szServiceName_UnoControlPatternFieldModel );
    4050             : }
    4051             : 
    4052         407 : uno::Any UnoControlPatternFieldModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
    4053             : {
    4054         407 :     if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
    4055             :     {
    4056          15 :         uno::Any aAny;
    4057          15 :         aAny <<= OUString::createFromAscii( szServiceName_UnoControlPatternField );
    4058          15 :         return aAny;
    4059             :     }
    4060         392 :     return UnoControlModel::ImplGetDefaultValue( nPropId );
    4061             : }
    4062             : 
    4063        5205 : ::cppu::IPropertyArrayHelper& UnoControlPatternFieldModel::getInfoHelper()
    4064             : {
    4065             :     static UnoPropertyArrayHelper* pHelper = NULL;
    4066        5205 :     if ( !pHelper )
    4067             :     {
    4068           3 :         uno::Sequence<sal_Int32>    aIDs = ImplGetPropertyIds();
    4069           3 :         pHelper = new UnoPropertyArrayHelper( aIDs );
    4070             :     }
    4071        5205 :     return *pHelper;
    4072             : }
    4073             : 
    4074             : // beans::XMultiPropertySet
    4075          69 : uno::Reference< beans::XPropertySetInfo > UnoControlPatternFieldModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
    4076             : {
    4077          69 :     static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
    4078          69 :     return xInfo;
    4079             : }
    4080             : 
    4081             : 
    4082             : //  ----------------------------------------------------
    4083             : //  class UnoPatternFieldControl
    4084             : //  ----------------------------------------------------
    4085           7 : UnoPatternFieldControl::UnoPatternFieldControl()
    4086           7 :     :UnoSpinFieldControl()
    4087             : {
    4088           7 : }
    4089             : 
    4090           8 : OUString UnoPatternFieldControl::GetComponentServiceName()
    4091             : {
    4092           8 :     return OUString("patternfield");
    4093             : }
    4094             : 
    4095         925 : void UnoPatternFieldControl::ImplSetPeerProperty( const OUString& rPropName, const uno::Any& rVal )
    4096             : {
    4097         925 :     sal_uInt16 nType = GetPropertyId( rPropName );
    4098         925 :     if ( ( nType == BASEPROPERTY_TEXT ) || ( nType == BASEPROPERTY_EDITMASK ) || ( nType == BASEPROPERTY_LITERALMASK ) )
    4099             :     {
    4100             :         // These masks cannot be set consecutively
    4101          80 :         OUString Text = ImplGetPropertyValue_UString( BASEPROPERTY_TEXT );
    4102         160 :         OUString EditMask = ImplGetPropertyValue_UString( BASEPROPERTY_EDITMASK );
    4103         160 :         OUString LiteralMask = ImplGetPropertyValue_UString( BASEPROPERTY_LITERALMASK );
    4104             : 
    4105         160 :         uno::Reference < awt::XPatternField >  xPF( getPeer(), uno::UNO_QUERY );
    4106          80 :         if (xPF.is())
    4107             :         {
    4108             :             // same comment as in UnoControl::ImplSetPeerProperty - see there
    4109          80 :             OUString sText( Text );
    4110          80 :             ImplCheckLocalize( sText );
    4111          80 :             xPF->setString( sText );
    4112          80 :             xPF->setMasks( EditMask, LiteralMask );
    4113          80 :         }
    4114             :     }
    4115             :     else
    4116         845 :         UnoSpinFieldControl::ImplSetPeerProperty( rPropName, rVal );
    4117         925 : }
    4118             : 
    4119             : 
    4120             : // uno::XInterface
    4121         388 : uno::Any UnoPatternFieldControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
    4122             : {
    4123             :     uno::Any aRet = ::cppu::queryInterface( rType,
    4124         388 :                                         (static_cast< awt::XPatternField* >(this)) );
    4125         388 :     return (aRet.hasValue() ? aRet : UnoSpinFieldControl::queryAggregation( rType ));
    4126             : }
    4127             : 
    4128             : // lang::XTypeProvider
    4129           0 : IMPL_XTYPEPROVIDER_START( UnoPatternFieldControl )
    4130           0 :     getCppuType( ( uno::Reference< awt::XPatternField>* ) NULL ),
    4131             :     UnoSpinFieldControl::getTypes()
    4132           0 : IMPL_XTYPEPROVIDER_END
    4133             : 
    4134           2 : void UnoPatternFieldControl::setString( const OUString& rString ) throw(uno::RuntimeException)
    4135             : {
    4136           2 :     setText( rString );
    4137           2 : }
    4138             : 
    4139           4 : OUString UnoPatternFieldControl::getString() throw(uno::RuntimeException)
    4140             : {
    4141           4 :     return getText();
    4142             : }
    4143             : 
    4144           2 : void UnoPatternFieldControl::setMasks( const OUString& EditMask, const OUString& LiteralMask ) throw(uno::RuntimeException)
    4145             : {
    4146           2 :     uno::Any aAny;
    4147           2 :     aAny <<= EditMask;
    4148           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_EDITMASK ), aAny, sal_True );
    4149           2 :     aAny <<= LiteralMask;
    4150           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_LITERALMASK ), aAny, sal_True );
    4151           2 : }
    4152             : 
    4153           4 : void UnoPatternFieldControl::getMasks( OUString& EditMask, OUString& LiteralMask ) throw(uno::RuntimeException)
    4154             : {
    4155           4 :     EditMask = ImplGetPropertyValue_UString( BASEPROPERTY_EDITMASK );
    4156           4 :     LiteralMask = ImplGetPropertyValue_UString( BASEPROPERTY_LITERALMASK );
    4157           4 : }
    4158             : 
    4159           2 : void UnoPatternFieldControl::setStrictFormat( sal_Bool bStrict ) throw(uno::RuntimeException)
    4160             : {
    4161           2 :     uno::Any aAny;
    4162           2 :     aAny <<= bStrict;
    4163           2 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_STRICTFORMAT ), aAny, sal_True );
    4164           2 : }
    4165             : 
    4166           4 : sal_Bool UnoPatternFieldControl::isStrictFormat() throw(uno::RuntimeException)
    4167             : {
    4168           4 :     return ImplGetPropertyValue_BOOL( BASEPROPERTY_STRICTFORMAT );
    4169             : }
    4170             : 
    4171             : 
    4172             : //  ----------------------------------------------------
    4173             : //  class UnoControlProgressBarModel
    4174             : //  ----------------------------------------------------
    4175           4 : UnoControlProgressBarModel::UnoControlProgressBarModel( const Reference< XComponentContext >& rxContext )
    4176           4 :     :UnoControlModel( rxContext )
    4177             : {
    4178           4 :     ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
    4179           4 :     ImplRegisterProperty( BASEPROPERTY_BORDER );
    4180           4 :     ImplRegisterProperty( BASEPROPERTY_BORDERCOLOR );
    4181           4 :     ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
    4182           4 :     ImplRegisterProperty( BASEPROPERTY_ENABLED );
    4183           4 :     ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
    4184           4 :     ImplRegisterProperty( BASEPROPERTY_FILLCOLOR );
    4185           4 :     ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
    4186           4 :     ImplRegisterProperty( BASEPROPERTY_HELPURL );
    4187           4 :     ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
    4188           4 :     ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE );
    4189           4 :     ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MAX );
    4190           4 :     ImplRegisterProperty( BASEPROPERTY_PROGRESSVALUE_MIN );
    4191           4 : }
    4192             : 
    4193           1 : OUString UnoControlProgressBarModel::getServiceName( ) throw(::com::sun::star::uno::RuntimeException)
    4194             : {
    4195           1 :     return OUString::createFromAscii( szServiceName_UnoControlProgressBarModel );
    4196             : }
    4197             : 
    4198          65 : uno::Any UnoControlProgressBarModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
    4199             : {
    4200          65 :     if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
    4201             :     {
    4202           5 :         uno::Any aAny;
    4203           5 :         aAny <<= OUString::createFromAscii( szServiceName_UnoControlProgressBar );
    4204           5 :         return aAny;
    4205             :     }
    4206             : 
    4207          60 :     return UnoControlModel::ImplGetDefaultValue( nPropId );
    4208             : }
    4209             : 
    4210         372 : ::cppu::IPropertyArrayHelper& UnoControlProgressBarModel::getInfoHelper()
    4211             : {
    4212             :     static UnoPropertyArrayHelper* pHelper = NULL;
    4213         372 :     if ( !pHelper )
    4214             :     {
    4215           1 :         uno::Sequence<sal_Int32>    aIDs = ImplGetPropertyIds();
    4216           1 :         pHelper = new UnoPropertyArrayHelper( aIDs );
    4217             :     }
    4218         372 :     return *pHelper;
    4219             : }
    4220             : 
    4221             : // beans::XMultiPropertySet
    4222          14 : uno::Reference< beans::XPropertySetInfo > UnoControlProgressBarModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
    4223             : {
    4224          14 :     static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
    4225          14 :     return xInfo;
    4226             : }
    4227             : 
    4228             : 
    4229             : //  ----------------------------------------------------
    4230             : //  class UnoProgressBarControl
    4231             : //  ----------------------------------------------------
    4232           0 : UnoProgressBarControl::UnoProgressBarControl()
    4233           0 :     :UnoControlBase()
    4234             : {
    4235           0 : }
    4236             : 
    4237           0 : OUString UnoProgressBarControl::GetComponentServiceName()
    4238             : {
    4239           0 :     return OUString("ProgressBar");
    4240             : }
    4241             : 
    4242             : // uno::XInterface
    4243           0 : uno::Any UnoProgressBarControl::queryAggregation( const uno::Type & rType ) throw(uno::RuntimeException)
    4244             : {
    4245             :     uno::Any aRet = ::cppu::queryInterface( rType,
    4246           0 :                                         (static_cast< awt::XProgressBar* >(this)) );
    4247           0 :     return (aRet.hasValue() ? aRet : UnoControlBase::queryAggregation( rType ));
    4248             : }
    4249             : 
    4250             : // lang::XTypeProvider
    4251           0 : IMPL_XTYPEPROVIDER_START( UnoProgressBarControl )
    4252           0 :     getCppuType( ( uno::Reference< awt::XProgressBar>* ) NULL ),
    4253             :     UnoControlBase::getTypes()
    4254           0 : IMPL_XTYPEPROVIDER_END
    4255             : 
    4256             : // ::com::sun::star::awt::XProgressBar
    4257           0 : void UnoProgressBarControl::setForegroundColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException)
    4258             : {
    4259           0 :     uno::Any aAny;
    4260           0 :     aAny <<= nColor;
    4261           0 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_FILLCOLOR ), aAny, sal_True );
    4262           0 : }
    4263             : 
    4264           0 : void UnoProgressBarControl::setBackgroundColor( sal_Int32 nColor ) throw(::com::sun::star::uno::RuntimeException)
    4265             : {
    4266           0 :     uno::Any aAny;
    4267           0 :     aAny <<= nColor;
    4268           0 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_BACKGROUNDCOLOR ), aAny, sal_True );
    4269           0 : }
    4270             : 
    4271           0 : void UnoProgressBarControl::setValue( sal_Int32 nValue ) throw(::com::sun::star::uno::RuntimeException)
    4272             : {
    4273           0 :     uno::Any aAny;
    4274           0 :     aAny <<= nValue;
    4275           0 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE ), aAny, sal_True );
    4276           0 : }
    4277             : 
    4278           0 : void UnoProgressBarControl::setRange( sal_Int32 nMin, sal_Int32 nMax ) throw(::com::sun::star::uno::RuntimeException )
    4279             : {
    4280           0 :     uno::Any aMin;
    4281           0 :     uno::Any aMax;
    4282             : 
    4283           0 :     if ( nMin < nMax )
    4284             :     {
    4285             :         // take correct min and max
    4286           0 :         aMin <<= nMin;
    4287           0 :         aMax <<= nMax;
    4288             :     }
    4289             :     else
    4290             :     {
    4291             :         // change min and max
    4292           0 :         aMin <<= nMax;
    4293           0 :         aMax <<= nMin;
    4294             :     }
    4295             : 
    4296           0 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE_MIN ), aMin, sal_True );
    4297           0 :     ImplSetPropertyValue( GetPropertyName( BASEPROPERTY_PROGRESSVALUE_MAX ), aMax, sal_True );
    4298           0 : }
    4299             : 
    4300           0 : sal_Int32 UnoProgressBarControl::getValue() throw(::com::sun::star::uno::RuntimeException)
    4301             : {
    4302           0 :     return ImplGetPropertyValue_INT32( BASEPROPERTY_PROGRESSVALUE );
    4303             : }
    4304             : 
    4305             : 
    4306             : //  ----------------------------------------------------
    4307             : //  class UnoControlFixedLineModel
    4308             : //  ----------------------------------------------------
    4309           4 : UnoControlFixedLineModel::UnoControlFixedLineModel( const Reference< XComponentContext >& rxContext )
    4310           4 :     :UnoControlModel( rxContext )
    4311             : {
    4312           4 :     ImplRegisterProperty( BASEPROPERTY_BACKGROUNDCOLOR );
    4313           4 :     ImplRegisterProperty( BASEPROPERTY_DEFAULTCONTROL );
    4314           4 :     ImplRegisterProperty( BASEPROPERTY_ENABLED );
    4315           4 :     ImplRegisterProperty( BASEPROPERTY_ENABLEVISIBLE );
    4316           4 :     ImplRegisterProperty( BASEPROPERTY_FONTDESCRIPTOR );
    4317           4 :     ImplRegisterProperty( BASEPROPERTY_HELPTEXT );
    4318           4 :     ImplRegisterProperty( BASEPROPERTY_HELPURL );
    4319           4 :     ImplRegisterProperty( BASEPROPERTY_LABEL );
    4320           4 :     ImplRegisterProperty( BASEPROPERTY_ORIENTATION );
    4321           4 :     ImplRegisterProperty( BASEPROPERTY_PRINTABLE );
    4322           4 : }
    4323             : 
    4324           1 : OUString UnoControlFixedLineModel::getServiceName( ) throw(::com::sun::star::uno::RuntimeException)
    4325             : {
    4326           1 :     return OUString::createFromAscii( szServiceName_UnoControlFixedLineModel );
    4327             : }
    4328             : 
    4329          70 : uno::Any UnoControlFixedLineModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const
    4330             : {
    4331          70 :     if ( nPropId == BASEPROPERTY_DEFAULTCONTROL )
    4332             :     {
    4333           5 :         uno::Any aAny;
    4334           5 :         aAny <<= OUString::createFromAscii( szServiceName_UnoControlFixedLine );
    4335           5 :         return aAny;
    4336             :     }
    4337          65 :     return UnoControlModel::ImplGetDefaultValue( nPropId );
    4338             : }
    4339             : 
    4340         731 : ::cppu::IPropertyArrayHelper& UnoControlFixedLineModel::getInfoHelper()
    4341             : {
    4342             :     static UnoPropertyArrayHelper* pHelper = NULL;
    4343         731 :     if ( !pHelper )
    4344             :     {
    4345           1 :         uno::Sequence<sal_Int32>    aIDs = ImplGetPropertyIds();
    4346           1 :         pHelper = new UnoPropertyArrayHelper( aIDs );
    4347             :     }
    4348         731 :     return *pHelper;
    4349             : }
    4350             : 
    4351             : // beans::XMultiPropertySet
    4352          34 : uno::Reference< beans::XPropertySetInfo > UnoControlFixedLineModel::getPropertySetInfo(  ) throw(uno::RuntimeException)
    4353             : {
    4354          34 :     static uno::Reference< beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
    4355          34 :     return xInfo;
    4356             : }
    4357             : 
    4358             : //  ----------------------------------------------------
    4359             : //  class UnoFixedLineControl
    4360             : //  ----------------------------------------------------
    4361           0 : UnoFixedLineControl::UnoFixedLineControl()
    4362           0 :     :UnoControlBase()
    4363             : {
    4364           0 :     maComponentInfos.nWidth = 100;      // ??
    4365           0 :     maComponentInfos.nHeight = 100;     // ??
    4366           0 : }
    4367             : 
    4368           0 : OUString UnoFixedLineControl::GetComponentServiceName()
    4369             : {
    4370           0 :     return OUString("FixedLine");
    4371             : }
    4372             : 
    4373           0 : sal_Bool UnoFixedLineControl::isTransparent() throw(uno::RuntimeException)
    4374             : {
    4375           0 :     return sal_True;
    4376         465 : }
    4377             : 
    4378             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10