LCOV - code coverage report
Current view: top level - toolkit/source/controls - unocontrol.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 652 786 83.0 %
Date: 2015-06-13 12:38:46 Functions: 59 81 72.8 %
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 <sal/config.h>
      21             : 
      22             : #include <boost/noncopyable.hpp>
      23             : #include <com/sun/star/awt/XControlContainer.hpp>
      24             : #include <com/sun/star/awt/WindowAttribute.hpp>
      25             : #include <com/sun/star/awt/VclWindowPeerAttribute.hpp>
      26             : #include <com/sun/star/awt/PosSize.hpp>
      27             : #include <com/sun/star/beans/PropertyValue.hpp>
      28             : #include <com/sun/star/resource/XStringResourceResolver.hpp>
      29             : #include <toolkit/controls/unocontrol.hxx>
      30             : #include <toolkit/helper/vclunohelper.hxx>
      31             : #include <cppuhelper/supportsservice.hxx>
      32             : #include <cppuhelper/typeprovider.hxx>
      33             : #include <rtl/uuid.h>
      34             : #include <osl/mutex.hxx>
      35             : #include <tools/date.hxx>
      36             : #include <tools/debug.hxx>
      37             : #include <tools/diagnose_ex.h>
      38             : #include <vcl/svapp.hxx>
      39             : #include <vcl/wrkwin.hxx>
      40             : #include <comphelper/processfactory.hxx>
      41             : #include <toolkit/helper/property.hxx>
      42             : #include <toolkit/helper/servicenames.hxx>
      43             : #include <toolkit/awt/vclxwindow.hxx>
      44             : #include <toolkit/controls/accessiblecontrolcontext.hxx>
      45             : #include <comphelper/container.hxx>
      46             : 
      47             : #include <algorithm>
      48             : #include <map>
      49             : #include <set>
      50             : #include <vector>
      51             : 
      52             : using namespace ::com::sun::star;
      53             : using namespace ::com::sun::star::uno;
      54             : using namespace ::com::sun::star::awt;
      55             : using namespace ::com::sun::star::beans;
      56             : using namespace ::com::sun::star::lang;
      57             : using namespace ::com::sun::star::util;
      58             : 
      59             : using ::com::sun::star::accessibility::XAccessibleContext;
      60             : using ::com::sun::star::accessibility::XAccessible;
      61             : 
      62             : struct LanguageDependentProp
      63             : {
      64             :     const char* pPropName;
      65             :     sal_Int32   nPropNameLength;
      66             : };
      67             : 
      68             : static const LanguageDependentProp aLanguageDependentProp[] =
      69             : {
      70             :     { "Text",            4 },
      71             :     { "Label",           5 },
      72             :     { "Title",           5 },
      73             :     { "HelpText",        8 },
      74             :     { "CurrencySymbol", 14 },
      75             :     { "StringItemList", 14 },
      76             :     { 0, 0                 }
      77             : };
      78             : 
      79        1876 : static Sequence< OUString> lcl_ImplGetPropertyNames( const Reference< XMultiPropertySet > & rxModel )
      80             : {
      81        1876 :     Sequence< OUString> aNames;
      82        3752 :     Reference< XPropertySetInfo >  xPSInf = rxModel->getPropertySetInfo();
      83             :     DBG_ASSERT( xPSInf.is(), "UpdateFromModel: No PropertySetInfo!" );
      84        1876 :     if ( xPSInf.is() )
      85             :     {
      86        1876 :         Sequence< Property> aProps = xPSInf->getProperties();
      87        1876 :         sal_Int32 nLen = aProps.getLength();
      88        1876 :         aNames = Sequence< OUString>( nLen );
      89        1876 :         OUString* pNames = aNames.getArray();
      90        1876 :         const Property* pProps = aProps.getConstArray();
      91       64966 :         for ( sal_Int32 n = 0; n < nLen; ++n, ++pProps, ++pNames)
      92       64966 :             *pNames = pProps->Name;
      93             :     }
      94        3752 :     return aNames;
      95             : }
      96             : 
      97             : 
      98             : class VclListenerLock: private boost::noncopyable
      99             : {
     100             : private:
     101             :     VCLXWindow*  m_pLockWindow;
     102             : 
     103             : public:
     104        4791 :     explicit VclListenerLock( VCLXWindow* _pLockWindow )
     105        4791 :         : m_pLockWindow( _pLockWindow )
     106             :     {
     107        4791 :         if ( m_pLockWindow )
     108        4791 :             m_pLockWindow->suspendVclEventListening( );
     109        4791 :     }
     110        4791 :     ~VclListenerLock()
     111             :     {
     112        4791 :         if ( m_pLockWindow )
     113        4791 :             m_pLockWindow->resumeVclEventListening( );
     114        4791 :     }
     115             : };
     116             : 
     117             : typedef ::std::map< OUString, sal_Int32 >    MapString2Int;
     118        1484 : struct UnoControl_Data
     119             : {
     120             :     MapString2Int   aSuspendedPropertyNotifications;
     121             :     /// true if and only if our model has a property ResourceResolver
     122             :     bool            bLocalizationSupport;
     123             : 
     124        1538 :     UnoControl_Data()
     125             :         :aSuspendedPropertyNotifications()
     126        1538 :         ,bLocalizationSupport( false )
     127             :     {
     128        1538 :     }
     129             : };
     130             : 
     131        1538 : UnoControl::UnoControl() :
     132             :       maDisposeListeners( *this )
     133             :     , maWindowListeners( *this )
     134             :     , maFocusListeners( *this )
     135             :     , maKeyListeners( *this )
     136             :     , maMouseListeners( *this )
     137             :     , maMouseMotionListeners( *this )
     138             :     , maPaintListeners( *this )
     139        1538 :     , maModeChangeListeners( GetMutex() )
     140        3076 :     , mpData( new UnoControl_Data )
     141             : {
     142        1538 :     mbDisposePeer = true;
     143        1538 :     mbRefeshingPeer = false;
     144        1538 :     mbCreatingPeer = false;
     145        1538 :     mbCreatingCompatiblePeer = false;
     146        1538 :     mbDesignMode = false;
     147        1538 : }
     148             : 
     149        2968 : UnoControl::~UnoControl()
     150             : {
     151        1484 :     DELETEZ( mpData );
     152        1484 : }
     153             : 
     154           0 : OUString UnoControl::GetComponentServiceName()
     155             : {
     156           0 :     return OUString();
     157             : }
     158             : 
     159        4703 : Reference< XWindowPeer >    UnoControl::ImplGetCompatiblePeer( bool bAcceptExistingPeer )
     160             : {
     161             :     DBG_ASSERT( !mbCreatingCompatiblePeer, "ImplGetCompatiblePeer - rekursive?" );
     162             : 
     163        4703 :     mbCreatingCompatiblePeer = true;
     164             : 
     165        4703 :     Reference< XWindowPeer > xCompatiblePeer;
     166             : 
     167        4703 :     if ( bAcceptExistingPeer )
     168        4703 :         xCompatiblePeer = getPeer();
     169             : 
     170        4703 :     if ( !xCompatiblePeer.is() )
     171             :     {
     172             :         // Create the pair as invisible
     173           6 :         bool bVis = maComponentInfos.bVisible;
     174           6 :         if( bVis )
     175           6 :             maComponentInfos.bVisible = false;
     176             : 
     177           6 :         Reference< XWindowPeer >    xCurrentPeer = getPeer();
     178           6 :         setPeer( NULL );
     179             : 
     180             :         // queryInterface ourself, to allow aggregation
     181          12 :         Reference< XControl > xMe;
     182           6 :         OWeakAggObject::queryInterface( cppu::UnoType<decltype(xMe)>::get() ) >>= xMe;
     183             : 
     184           6 :         vcl::Window* pParentWindow( NULL );
     185             :         {
     186           6 :             SolarMutexGuard aGuard;
     187           6 :             pParentWindow = dynamic_cast< vcl::Window* >( Application::GetDefaultDevice() );
     188           6 :             ENSURE_OR_THROW( pParentWindow != NULL, "could obtain a default parent window!" );
     189             :         }
     190             :         try
     191             :         {
     192           6 :             xMe->createPeer( NULL, pParentWindow->GetComponentInterface( true ) );
     193             :         }
     194           0 :         catch( const Exception& )
     195             :         {
     196           0 :             mbCreatingCompatiblePeer = false;
     197           0 :             throw;
     198             :         }
     199           6 :         xCompatiblePeer = getPeer();
     200           6 :         setPeer( xCurrentPeer );
     201             : 
     202           6 :         if ( xCompatiblePeer.is() && mxGraphics.is() )
     203             :         {
     204           6 :             Reference< XView > xPeerView( xCompatiblePeer, UNO_QUERY );
     205           6 :             if ( xPeerView.is() )
     206           6 :                 xPeerView->setGraphics( mxGraphics );
     207             :         }
     208             : 
     209           6 :         if( bVis )
     210          12 :             maComponentInfos.bVisible = true;
     211             :     }
     212             : 
     213        4703 :     mbCreatingCompatiblePeer = false;
     214             : 
     215        4703 :     return xCompatiblePeer;
     216             : }
     217             : 
     218         383 : bool UnoControl::ImplCheckLocalize( OUString& _rPossiblyLocalizable )
     219             : {
     220         766 :     if  (   !mpData->bLocalizationSupport
     221          23 :         ||  ( _rPossiblyLocalizable.isEmpty() )
     222         391 :         ||  ( _rPossiblyLocalizable[0] != '&' )
     223             :             // TODO: make this reasonable. At the moment, everything which by accident starts with a & is considered
     224             :             // localizable, which is probably wrong.
     225             :         )
     226         383 :         return false;
     227             : 
     228             :     try
     229             :     {
     230           0 :         Reference< XPropertySet > xPropSet( mxModel, UNO_QUERY_THROW );
     231             :         Reference< resource::XStringResourceResolver > xStringResourceResolver(
     232           0 :             xPropSet->getPropertyValue("ResourceResolver"),
     233             :             UNO_QUERY
     234           0 :         );
     235           0 :         if ( xStringResourceResolver.is() )
     236             :         {
     237           0 :             OUString aLocalizationKey( _rPossiblyLocalizable.copy( 1 ) );
     238           0 :             _rPossiblyLocalizable = xStringResourceResolver->resolveString( aLocalizationKey );
     239           0 :             return true;
     240           0 :         }
     241             :     }
     242           0 :     catch( const Exception& )
     243             :     {
     244             :         DBG_UNHANDLED_EXCEPTION();
     245             :     }
     246           0 :     return false;
     247             : }
     248             : 
     249       32283 : void UnoControl::ImplSetPeerProperty( const OUString& rPropName, const Any& rVal )
     250             : {
     251             :     // since a change made in propertiesChange, we can't be sure that this is called with an valid getPeer(),
     252             :     // this assumption may be false in some (seldom) multi-threading scenarios (cause propertiesChange
     253             :     // releases our mutex before calling here in)
     254             :     // That's why this additional check
     255             : 
     256       32283 :     if ( mxVclWindowPeer.is() )
     257             :     {
     258       32283 :         Any aConvertedValue( rVal );
     259             : 
     260       32283 :         if ( mpData->bLocalizationSupport )
     261             :         {
     262             :             // We now support a mapping for language dependent properties. This is the
     263             :             // central method to implement it.
     264        1953 :             if( rPropName == "Text"            ||
     265        1299 :                 rPropName == "Label"           ||
     266        1292 :                 rPropName == "Title"           ||
     267        1277 :                 rPropName == "HelpText"        ||
     268        1917 :                 rPropName == "CurrencySymbol"  ||
     269         633 :                 rPropName == "StringItemList"  )
     270             :             {
     271          18 :                 OUString aValue;
     272          36 :                 uno::Sequence< OUString > aSeqValue;
     273          18 :                 if ( aConvertedValue >>= aValue )
     274             :                 {
     275          18 :                     if ( ImplCheckLocalize( aValue ) )
     276           0 :                         aConvertedValue <<= aValue;
     277             :                 }
     278           0 :                 else if ( aConvertedValue >>= aSeqValue )
     279             :                 {
     280           0 :                     for ( sal_Int32 i = 0; i < aSeqValue.getLength(); i++ )
     281           0 :                         ImplCheckLocalize( aSeqValue[i] );
     282           0 :                     aConvertedValue <<= aSeqValue;
     283          18 :                 }
     284             :             }
     285             :         }
     286             : 
     287       32283 :         mxVclWindowPeer->setProperty( rPropName, aConvertedValue );
     288             :     }
     289       32283 : }
     290             : 
     291         327 : void UnoControl::PrepareWindowDescriptor( WindowDescriptor& )
     292             : {
     293         327 : }
     294             : 
     295        4791 : Reference< XWindow >    UnoControl::getParentPeer() const
     296             : {
     297        4791 :     Reference< XWindow > xPeer;
     298        4791 :     if( mxContext.is() )
     299             :     {
     300        4759 :         Reference< XControl > xContComp( mxContext, UNO_QUERY );
     301        4759 :         if ( xContComp.is() )
     302             :         {
     303        4578 :             Reference< XWindowPeer > xP = xContComp->getPeer();
     304        4578 :             if ( xP.is() )
     305        4574 :                 xPeer.set( xP, UNO_QUERY );
     306        4759 :         }
     307             :     }
     308        4791 :     return xPeer;
     309             : }
     310             : 
     311         389 : void UnoControl::updateFromModel()
     312             : {
     313             :     // Read default properties and hand over to peer
     314         389 :     if( getPeer().is() )
     315             :     {
     316         389 :         Reference< XMultiPropertySet >  xPropSet( mxModel, UNO_QUERY );
     317         389 :         if( xPropSet.is() )
     318             :         {
     319         389 :             Sequence< OUString> aNames = lcl_ImplGetPropertyNames( xPropSet );
     320         389 :             xPropSet->firePropertiesChangeEvent( aNames, this );
     321         389 :         }
     322             :     }
     323         389 : }
     324             : 
     325             : 
     326             : // XTypeProvider
     327           0 : IMPL_IMPLEMENTATION_ID( UnoControl )
     328             : 
     329             : void
     330        1812 : UnoControl::DisposeAccessibleContext(Reference<XComponent> const& xContextComp)
     331             : {
     332        1812 :     if (xContextComp.is())
     333             :     {
     334             :         try
     335             :         {
     336          32 :             xContextComp->removeEventListener( this );
     337          32 :             xContextComp->dispose();
     338             :         }
     339           0 :         catch( const Exception& )
     340             :         {
     341             :             OSL_FAIL( "UnoControl::disposeAccessibleContext: could not dispose my AccessibleContext!" );
     342             :         }
     343             :     }
     344        1812 : }
     345             : 
     346        1586 : void UnoControl::dispose(  ) throw(RuntimeException, std::exception)
     347             : {
     348        1586 :     Reference< XWindowPeer > xPeer;
     349        3172 :     Reference<XComponent> xAccessibleComp;
     350             :     {
     351        1586 :         ::osl::MutexGuard aGuard( GetMutex() );
     352        1586 :         if( mbDisposePeer )
     353             :         {
     354         561 :             xPeer = mxPeer;
     355             :         }
     356        1586 :         setPeer( NULL );
     357        1586 :         xAccessibleComp.set(maAccessibleContext, UNO_QUERY);
     358        1586 :         maAccessibleContext.clear();
     359             :     }
     360        1586 :     if( xPeer.is() )
     361             :     {
     362         225 :         xPeer->dispose();
     363             :     }
     364             : 
     365             :     // dispose our AccessibleContext - without Mutex locked
     366        1586 :     DisposeAccessibleContext(xAccessibleComp);
     367             : 
     368        3172 :     EventObject aDisposeEvent;
     369        1586 :     aDisposeEvent.Source = static_cast< XAggregation* >( this );
     370             : 
     371        1586 :     maDisposeListeners.disposeAndClear( aDisposeEvent );
     372        1586 :     maWindowListeners.disposeAndClear( aDisposeEvent );
     373        1586 :     maFocusListeners.disposeAndClear( aDisposeEvent );
     374        1586 :     maKeyListeners.disposeAndClear( aDisposeEvent );
     375        1586 :     maMouseListeners.disposeAndClear( aDisposeEvent );
     376        1586 :     maMouseMotionListeners.disposeAndClear( aDisposeEvent );
     377        1586 :     maPaintListeners.disposeAndClear( aDisposeEvent );
     378        1586 :     maModeChangeListeners.disposeAndClear( aDisposeEvent );
     379             : 
     380             :     // release Model again
     381        1586 :     setModel( Reference< XControlModel > () );
     382        3172 :     setContext( Reference< XInterface > () );
     383        1586 : }
     384             : 
     385          92 : void UnoControl::addEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException, std::exception)
     386             : {
     387          92 :     ::osl::MutexGuard aGuard( GetMutex() );
     388             : 
     389          92 :     maDisposeListeners.addInterface( rxListener );
     390          92 : }
     391             : 
     392          85 : void UnoControl::removeEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException, std::exception)
     393             : {
     394          85 :     ::osl::MutexGuard aGuard( GetMutex() );
     395             : 
     396          85 :     maDisposeListeners.removeInterface( rxListener );
     397          85 : }
     398             : 
     399        1207 : bool UnoControl::requiresNewPeer( const OUString& /* _rPropertyName */ ) const
     400             : {
     401        1207 :     return false;
     402             : }
     403             : 
     404             : // XPropertiesChangeListener
     405        5093 : void UnoControl::propertiesChange( const Sequence< PropertyChangeEvent >& rEvents ) throw(RuntimeException, std::exception)
     406             : {
     407        5093 :     Sequence< PropertyChangeEvent > aEvents( rEvents );
     408             :     {
     409        5093 :         ::osl::MutexGuard aGuard( GetMutex() );
     410             : 
     411        5093 :         if ( !mpData->aSuspendedPropertyNotifications.empty() )
     412             :         {
     413             :             // strip the property which we are currently updating (somewhere up the stack)
     414          85 :             PropertyChangeEvent* pEvents = aEvents.getArray();
     415          85 :             PropertyChangeEvent* pEventsEnd = pEvents + aEvents.getLength();
     416         258 :             for ( ; pEvents < pEventsEnd; )
     417          88 :                 if ( mpData->aSuspendedPropertyNotifications.find( pEvents->PropertyName ) != mpData->aSuspendedPropertyNotifications.end() )
     418             :                 {
     419          88 :                     if ( pEvents != pEventsEnd )
     420          88 :                         ::std::copy( pEvents + 1, pEventsEnd, pEvents );
     421          88 :                     --pEventsEnd;
     422             :                 }
     423             :                 else
     424           0 :                     ++pEvents;
     425          85 :             aEvents.realloc( pEventsEnd - aEvents.getConstArray() );
     426             : 
     427          85 :             if ( !aEvents.getLength() )
     428        5178 :                 return;
     429        5008 :         }
     430             :     }
     431             : 
     432        5008 :     ImplModelPropertiesChanged( aEvents );
     433             : }
     434             : 
     435         600 : void UnoControl::ImplLockPropertyChangeNotification( const OUString& rPropertyName, bool bLock )
     436             : {
     437         600 :     MapString2Int::iterator pos = mpData->aSuspendedPropertyNotifications.find( rPropertyName );
     438         600 :     if ( bLock )
     439             :     {
     440         300 :         if ( pos == mpData->aSuspendedPropertyNotifications.end() )
     441         300 :             pos = mpData->aSuspendedPropertyNotifications.insert( MapString2Int::value_type( rPropertyName, 0 ) ).first;
     442         300 :         ++pos->second;
     443             :     }
     444             :     else
     445             :     {
     446             :         OSL_ENSURE( pos != mpData->aSuspendedPropertyNotifications.end(), "UnoControl::ImplLockPropertyChangeNotification: property not locked!" );
     447         300 :         if ( pos != mpData->aSuspendedPropertyNotifications.end() )
     448             :         {
     449             :             OSL_ENSURE( pos->second > 0, "UnoControl::ImplLockPropertyChangeNotification: invalid suspension counter!" );
     450         300 :             if ( 0 == --pos->second )
     451         300 :                 mpData->aSuspendedPropertyNotifications.erase( pos );
     452             :         }
     453             :     }
     454         600 : }
     455             : 
     456          12 : void UnoControl::ImplLockPropertyChangeNotifications( const Sequence< OUString >& rPropertyNames, bool bLock )
     457             : {
     458          72 :     for (   const OUString* pPropertyName = rPropertyNames.getConstArray();
     459          36 :             pPropertyName != rPropertyNames.getConstArray() + rPropertyNames.getLength();
     460             :             ++pPropertyName
     461             :         )
     462          24 :         ImplLockPropertyChangeNotification( *pPropertyName, bLock );
     463          12 : }
     464             : 
     465        5008 : void UnoControl::ImplModelPropertiesChanged( const Sequence< PropertyChangeEvent >& rEvents )
     466             : {
     467        5008 :     ::osl::ClearableGuard< ::osl::Mutex > aGuard( GetMutex() );
     468             : 
     469        5008 :     if( getPeer().is() )
     470             :     {
     471        4791 :         std::vector< PropertyValue > aPeerPropertiesToSet;
     472        4791 :         sal_Int32               nIndependentPos = 0;
     473        4791 :         bool                    bResourceResolverSet( false );
     474             :             // position where to insert the independent properties into aPeerPropertiesToSet,
     475             :             // dependent ones are inserted at the end of the vector
     476             : 
     477        4791 :         bool bNeedNewPeer = false;
     478             :             // some properties require a re-creation of the peer, 'cause they can't be changed on the fly
     479             : 
     480        9582 :         Reference< XControlModel > xOwnModel( getModel(), UNO_QUERY );
     481             :             // our own model for comparison
     482        9582 :         Reference< XPropertySet > xPS( xOwnModel, UNO_QUERY );
     483        9582 :         Reference< XPropertySetInfo > xPSI( xPS->getPropertySetInfo(), UNO_QUERY );
     484             :         OSL_ENSURE( xPSI.is(), "UnoControl::ImplModelPropertiesChanged: should have property set meta data!" );
     485             : 
     486        4791 :         const PropertyChangeEvent* pEvents = rEvents.getConstArray();
     487             : 
     488        4791 :         sal_Int32 nLen = rEvents.getLength();
     489        4791 :         aPeerPropertiesToSet.reserve(nLen);
     490             : 
     491       37714 :         for( sal_Int32 i = 0; i < nLen; ++i, ++pEvents )
     492             :         {
     493       33082 :             Reference< XControlModel > xModel( pEvents->Source, UNO_QUERY );
     494       33082 :             bool bOwnModel = xModel.get() == xOwnModel.get();
     495       33082 :             if ( !bOwnModel )
     496          27 :                 continue;
     497             : 
     498             :             // Detect changes on our resource resolver which invalidates
     499             :             // automatically some language dependent properties.
     500       33055 :             if ( pEvents->PropertyName == "ResourceResolver" )
     501             :             {
     502          11 :                 Reference< resource::XStringResourceResolver > xStrResolver;
     503          11 :                 if ( pEvents->NewValue >>= xStrResolver )
     504          11 :                     bResourceResolverSet = xStrResolver.is();
     505             :             }
     506             : 
     507       33055 :             sal_uInt16 nPType = GetPropertyId( pEvents->PropertyName );
     508       33055 :             if ( mbDesignMode && mbDisposePeer && !mbRefeshingPeer && !mbCreatingPeer )
     509             :             {
     510             :                 // if we're in design mode, then some properties can change which
     511             :                 // require creating a *new* peer (since these properties cannot
     512             :                 // be switched at existing peers)
     513        4821 :                 if ( nPType )
     514             :                     bNeedNewPeer = ( nPType == BASEPROPERTY_BORDER )
     515        3580 :                                 || ( nPType == BASEPROPERTY_MULTILINE )
     516        3552 :                                 || ( nPType == BASEPROPERTY_DROPDOWN )
     517        3519 :                                 || ( nPType == BASEPROPERTY_HSCROLL )
     518        3511 :                                 || ( nPType == BASEPROPERTY_VSCROLL )
     519        3503 :                                 || ( nPType == BASEPROPERTY_AUTOHSCROLL )
     520        3503 :                                 || ( nPType == BASEPROPERTY_AUTOVSCROLL )
     521        3503 :                                 || ( nPType == BASEPROPERTY_ORIENTATION )
     522        3503 :                                 || ( nPType == BASEPROPERTY_SPIN )
     523        3467 :                                 || ( nPType == BASEPROPERTY_ALIGN )
     524        7077 :                                 || ( nPType == BASEPROPERTY_PAINTTRANSPARENT );
     525             :                 else
     526        1207 :                     bNeedNewPeer = requiresNewPeer( pEvents->PropertyName );
     527             : 
     528        4821 :                 if ( bNeedNewPeer )
     529         159 :                     break;
     530             :             }
     531             : 
     532       32896 :             if ( nPType && ( nLen > 1 ) && DoesDependOnOthers( nPType ) )
     533             :             {
     534             :                 // Add properties with dependencies on other properties last
     535             :                 // since they're dependent on properties added later (such as
     536             :                 // VALUE dependency on VALUEMIN/MAX)
     537         508 :                 aPeerPropertiesToSet.push_back(PropertyValue(pEvents->PropertyName, 0, pEvents->NewValue, PropertyState_DIRECT_VALUE));
     538             :             }
     539             :             else
     540             :             {
     541       32388 :                 if ( bResourceResolverSet )
     542             :                 {
     543             :                     // The resource resolver property change should be one of the first ones.
     544             :                     // All language dependent properties are dependent on this property.
     545             :                     // As BASEPROPERTY_NATIVE_WIDGET_LOOK is not dependent on resource
     546             :                     // resolver. We don't need to handle a special order for these two props.
     547             :                     aPeerPropertiesToSet.insert(
     548             :                         aPeerPropertiesToSet.begin(),
     549           0 :                         PropertyValue( pEvents->PropertyName, 0, pEvents->NewValue, PropertyState_DIRECT_VALUE ) );
     550           0 :                     ++nIndependentPos;
     551             :                 }
     552       32388 :                 else if ( nPType == BASEPROPERTY_NATIVE_WIDGET_LOOK )
     553             :                 {
     554             :                     // since *a lot* of other properties might be overruled by this one, we need
     555             :                     // a special handling:
     556             :                     // NativeWidgetLook needs to be set first: If it is set to ON, all other
     557             :                     // properties describing the look (e.g. BackgroundColor) are ignored, anyway.
     558             :                     // If it is switched OFF, then we need to do it first because else it will
     559             :                     // overrule other look-related properties, and re-initialize them from system
     560             :                     // defaults.
     561             :                     aPeerPropertiesToSet.insert(
     562             :                         aPeerPropertiesToSet.begin(),
     563         466 :                         PropertyValue( pEvents->PropertyName, 0, pEvents->NewValue, PropertyState_DIRECT_VALUE ) );
     564         466 :                     ++nIndependentPos;
     565             :                 }
     566             :                 else
     567             :                 {
     568             :                     aPeerPropertiesToSet.insert(aPeerPropertiesToSet.begin() + nIndependentPos,
     569       31922 :                         PropertyValue(pEvents->PropertyName, 0, pEvents->NewValue, PropertyState_DIRECT_VALUE));
     570       31922 :                     ++nIndependentPos;
     571             :                 }
     572             :             }
     573       32896 :         }
     574             : 
     575        9582 :         Reference< XWindow >    xParent = getParentPeer();
     576        9582 :         Reference< XControl > xThis( static_cast<XAggregation*>(static_cast<cppu::OWeakAggObject*>(this)), UNO_QUERY );
     577             :         // call createPeer via a interface got from queryInterface, so the aggregating class can intercept it
     578             : 
     579             :         DBG_ASSERT( !bNeedNewPeer || xParent.is(), "Need new peer, but don't have a parent!" );
     580             : 
     581             :         // Check if we have to update language dependent properties
     582        4791 :         if ( !bNeedNewPeer && bResourceResolverSet )
     583             :         {
     584             :             // Add language dependent properties into the peer property set.
     585             :             // Our resource resolver has been changed and we must be sure
     586             :             // that language dependent props use the new resolver.
     587           0 :             const LanguageDependentProp* pLangDepProp = aLanguageDependentProp;
     588           0 :             while ( pLangDepProp->pPropName != 0 )
     589             :             {
     590           0 :                 bool bMustBeInserted( true );
     591           0 :                 for ( size_t i = 0; i < aPeerPropertiesToSet.size(); i++ )
     592             :                 {
     593           0 :                     if ( aPeerPropertiesToSet[i].Name.equalsAsciiL(
     594           0 :                             pLangDepProp->pPropName, pLangDepProp->nPropNameLength ))
     595             :                     {
     596           0 :                         bMustBeInserted = false;
     597           0 :                         break;
     598             :                     }
     599             :                 }
     600             : 
     601           0 :                 if ( bMustBeInserted )
     602             :                 {
     603             :                     // Add language dependent props at the end
     604           0 :                     OUString aPropName( OUString::createFromAscii( pLangDepProp->pPropName ));
     605           0 :                     if ( xPSI.is() && xPSI->hasPropertyByName( aPropName ) )
     606             :                     {
     607             :                         aPeerPropertiesToSet.push_back(
     608           0 :                             PropertyValue( aPropName, 0, xPS->getPropertyValue( aPropName ), PropertyState_DIRECT_VALUE ) );
     609           0 :                     }
     610             :                 }
     611             : 
     612           0 :                 ++pLangDepProp;
     613             :             }
     614             :         }
     615        4791 :         aGuard.clear();
     616             : 
     617             :         // clear the guard before creating a new peer - as usual, our peer implementations use the SolarMutex
     618             : 
     619        4791 :         if (bNeedNewPeer && xParent.is())
     620             :         {
     621         158 :             SolarMutexGuard aVclGuard;
     622             :                 // and now this is the final withdrawal:
     623             :                 // I have no other idea than locking the SolarMutex here ....
     624             :                 // I really hate the fact that VCL is not theadsafe ....
     625             : 
     626             :             // Doesn't work for Container!
     627         158 :             getPeer()->dispose();
     628         158 :             mxPeer.clear();
     629         158 :             mxVclWindowPeer = NULL;
     630         158 :             mbRefeshingPeer = true;
     631         316 :             Reference< XWindowPeer >    xP( xParent, UNO_QUERY );
     632         158 :             xThis->createPeer( Reference< XToolkit > (), xP );
     633         158 :             mbRefeshingPeer = false;
     634         316 :             aPeerPropertiesToSet.clear();
     635             :         }
     636             : 
     637             :         // lock the multiplexing of VCL events to our UNO listeners
     638             :         // this is for compatibility reasons: in OOo 1.0.x, changes which were done at the
     639             :         // model did not cause the listeners of the controls/peers to be called
     640             :         // Since the implementations for the listeners changed a lot towards 1.1, this
     641             :         // would not be the case anymore, if we would not do this listener-lock below
     642             :         // #i14703#
     643        4791 :         vcl::Window* pVclPeer = VCLUnoHelper::GetWindow( getPeer() );
     644        4791 :         VCLXWindow* pPeer = pVclPeer ? pVclPeer->GetWindowPeer() : NULL;
     645        9582 :         VclListenerLock aNoVclEventMultiplexing( pPeer );
     646             : 
     647             :         // setting peer properties may result in an attempt to acquire the solar mutex, 'cause the peers
     648             :         // usually don't have an own mutex but use the SolarMutex instead.
     649             :         // To prevent deadlocks resulting from this, we do this without our own mutex locked
     650        4791 :         std::vector< PropertyValue >::iterator aEnd = aPeerPropertiesToSet.end();
     651       37531 :         for (   std::vector< PropertyValue >::iterator aLoop = aPeerPropertiesToSet.begin();
     652             :                 aLoop != aEnd;
     653             :                 ++aLoop
     654             :             )
     655             :         {
     656       32740 :             ImplSetPeerProperty( aLoop->Name, aLoop->Value );
     657        4791 :         }
     658        5008 :     }
     659        5008 : }
     660             : 
     661         826 : void UnoControl::disposing( const EventObject& rEvt ) throw(RuntimeException, std::exception)
     662             : {
     663         826 :     ::osl::ClearableMutexGuard aGuard( GetMutex() );
     664             :     // do not compare differing types in case of multible inheritance
     665             : 
     666         826 :     if ( maAccessibleContext.get() == rEvt.Source )
     667             :     {
     668             :         // just in case the context is disposed, but not released - ensure that we do not re-use it in the future
     669           0 :         maAccessibleContext = NULL;
     670             :     }
     671         826 :     else if( mxModel.get() == Reference< XControlModel >(rEvt.Source,UNO_QUERY).get() )
     672             :     {
     673             :         // #62337# if the model dies, it does not make sense for us to live ...
     674          97 :         Reference< XControl >  xThis = this;
     675             : 
     676          97 :         aGuard.clear();
     677          97 :         xThis->dispose();
     678             : 
     679             :         DBG_ASSERT( !mxModel.is(), "UnoControl::disposing: invalid dispose behaviour!" );
     680          97 :         mxModel.clear();
     681         826 :     }
     682         826 : }
     683             : 
     684             : 
     685           0 : void SAL_CALL UnoControl::setOutputSize( const awt::Size& aSize ) throw (RuntimeException, std::exception)
     686             : {
     687           0 :     Reference< XWindow2 > xPeerWindow;
     688             :     {
     689           0 :         ::osl::MutexGuard aGuard( GetMutex() );
     690           0 :         xPeerWindow.set(getPeer(), css::uno::UNO_QUERY);
     691             :     }
     692             : 
     693           0 :     if ( xPeerWindow.is() )
     694           0 :         xPeerWindow->setOutputSize( aSize );
     695           0 : }
     696             : 
     697             : namespace
     698             : {
     699             :     template < typename RETVALTYPE, typename DEFAULTTYPE >
     700        6908 :     RETVALTYPE lcl_askPeer( const uno::Reference< awt::XWindowPeer >& _rxPeer, RETVALTYPE (SAL_CALL XWindow2::*_pMethod)(), DEFAULTTYPE _aDefault )
     701             :     {
     702        6908 :         RETVALTYPE aReturn( _aDefault );
     703             : 
     704        6908 :         Reference< XWindow2 > xPeerWindow( _rxPeer, UNO_QUERY );
     705        6908 :         if ( xPeerWindow.is() )
     706        6893 :             aReturn = (xPeerWindow.get()->*_pMethod)();
     707             : 
     708        6908 :         return aReturn;
     709             :     }
     710             : }
     711             : 
     712           0 : awt::Size SAL_CALL UnoControl::getOutputSize(  ) throw (RuntimeException, std::exception)
     713             : {
     714           0 :     return lcl_askPeer( getPeer(), &XWindow2::getOutputSize, awt::Size() );
     715             : }
     716             : 
     717        6908 : sal_Bool SAL_CALL UnoControl::isVisible(  ) throw (RuntimeException, std::exception)
     718             : {
     719        6908 :     return lcl_askPeer( getPeer(), &XWindow2::isVisible, maComponentInfos.bVisible );
     720             : }
     721             : 
     722           0 : sal_Bool SAL_CALL UnoControl::isActive(  ) throw (RuntimeException, std::exception)
     723             : {
     724           0 :     return lcl_askPeer( getPeer(), &XWindow2::isActive, sal_False );
     725             : }
     726             : 
     727           0 : sal_Bool SAL_CALL UnoControl::isEnabled(  ) throw (RuntimeException, std::exception)
     728             : {
     729           0 :     return lcl_askPeer( getPeer(), &XWindow2::isEnabled, maComponentInfos.bEnable );
     730             : }
     731             : 
     732           0 : sal_Bool SAL_CALL UnoControl::hasFocus(  ) throw (RuntimeException, std::exception)
     733             : {
     734           0 :     return lcl_askPeer( getPeer(), &XWindow2::hasFocus, sal_False );
     735             : }
     736             : 
     737             : // XWindow
     738         782 : void UnoControl::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags ) throw(RuntimeException, std::exception)
     739             : {
     740         782 :     Reference< XWindow > xWindow;
     741             :     {
     742         782 :         ::osl::MutexGuard aGuard( GetMutex() );
     743             : 
     744         782 :         if ( Flags & awt::PosSize::X )
     745         775 :             maComponentInfos.nX = X;
     746         782 :         if ( Flags & awt::PosSize::Y )
     747         775 :             maComponentInfos.nY = Y;
     748         782 :         if ( Flags & awt::PosSize::WIDTH )
     749         776 :             maComponentInfos.nWidth = Width;
     750         782 :         if ( Flags & awt::PosSize::HEIGHT )
     751         776 :             maComponentInfos.nHeight = Height;
     752         782 :         maComponentInfos.nFlags |= Flags;
     753             : 
     754         782 :         xWindow.set(getPeer(), css::uno::UNO_QUERY);
     755             :     }
     756             : 
     757         782 :     if( xWindow.is() )
     758         444 :         xWindow->setPosSize( X, Y, Width, Height, Flags );
     759         782 : }
     760             : 
     761       26773 : awt::Rectangle UnoControl::getPosSize(  ) throw(RuntimeException, std::exception)
     762             : {
     763       26773 :     awt::Rectangle aRect( maComponentInfos.nX, maComponentInfos.nY, maComponentInfos.nWidth, maComponentInfos.nHeight);
     764       26773 :     Reference< XWindow > xWindow;
     765             : 
     766             :     {
     767       26773 :         ::osl::MutexGuard aGuard( GetMutex() );
     768       26773 :         xWindow.set(getPeer(), css::uno::UNO_QUERY);
     769             :     }
     770             : 
     771       26773 :     if( xWindow.is() )
     772       26216 :         aRect = xWindow->getPosSize();
     773       26773 :     return aRect;
     774             : }
     775             : 
     776          70 : void UnoControl::setVisible( sal_Bool bVisible ) throw(RuntimeException, std::exception)
     777             : {
     778          70 :     Reference< XWindow > xWindow;
     779             :     {
     780          70 :         ::osl::MutexGuard aGuard( GetMutex() );
     781             : 
     782             :         // Visible status is handled by View
     783          70 :         maComponentInfos.bVisible = bVisible;
     784          70 :         xWindow.set(getPeer(), css::uno::UNO_QUERY);
     785             :     }
     786          70 :     if ( xWindow.is() )
     787           2 :         xWindow->setVisible( bVisible );
     788          70 : }
     789             : 
     790           5 : void UnoControl::setEnable( sal_Bool bEnable ) throw(RuntimeException, std::exception)
     791             : {
     792           5 :     Reference< XWindow > xWindow;
     793             :     {
     794           5 :         ::osl::MutexGuard aGuard( GetMutex() );
     795             : 
     796             :         // Enable status is handled by View
     797           5 :         maComponentInfos.bEnable = bEnable;
     798           5 :         xWindow.set(getPeer(), css::uno::UNO_QUERY);
     799             :     }
     800           5 :     if ( xWindow.is() )
     801           4 :         xWindow->setEnable( bEnable );
     802           5 : }
     803             : 
     804           1 : void UnoControl::setFocus(  ) throw(RuntimeException, std::exception)
     805             : {
     806           1 :     Reference< XWindow > xWindow;
     807             :     {
     808           1 :         ::osl::MutexGuard aGuard( GetMutex() );
     809           1 :         xWindow.set(getPeer(), css::uno::UNO_QUERY);
     810             :     }
     811           1 :     if ( xWindow.is() )
     812           1 :         xWindow->setFocus();
     813           1 : }
     814             : 
     815         223 : void UnoControl::addWindowListener( const Reference< XWindowListener >& rxListener ) throw(RuntimeException, std::exception)
     816             : {
     817         223 :     Reference< XWindow > xPeerWindow;
     818             :     {
     819         223 :         ::osl::MutexGuard aGuard( GetMutex() );
     820         223 :         maWindowListeners.addInterface( rxListener );
     821         223 :         if ( maWindowListeners.getLength() == 1 )
     822         221 :             xPeerWindow.set(getPeer(), css::uno::UNO_QUERY);
     823             :     }
     824         223 :     if ( xPeerWindow.is() )
     825         216 :         xPeerWindow->addWindowListener( &maWindowListeners );
     826         223 : }
     827             : 
     828         219 : void UnoControl::removeWindowListener( const Reference< XWindowListener >& rxListener ) throw(RuntimeException, std::exception)
     829             : {
     830         219 :     Reference< XWindow > xPeerWindow;
     831             :     {
     832         219 :         ::osl::MutexGuard aGuard( GetMutex() );
     833         219 :         if ( maWindowListeners.getLength() == 1 )
     834         216 :             xPeerWindow.set(getPeer(), css::uno::UNO_QUERY);
     835         219 :         maWindowListeners.removeInterface( rxListener );
     836             :     }
     837         219 :     if ( xPeerWindow.is() )
     838         211 :         xPeerWindow->removeWindowListener( &maWindowListeners );
     839         219 : }
     840             : 
     841         171 : void UnoControl::addFocusListener( const Reference< XFocusListener >& rxListener ) throw(RuntimeException, std::exception)
     842             : {
     843         171 :     Reference< XWindow > xPeerWindow;
     844             :     {
     845         171 :         ::osl::MutexGuard aGuard( GetMutex() );
     846         171 :         maFocusListeners.addInterface( rxListener );
     847         171 :         if ( maFocusListeners.getLength() == 1 )
     848         151 :             xPeerWindow.set(getPeer(), css::uno::UNO_QUERY);
     849             :     }
     850         171 :     if ( xPeerWindow.is() )
     851          58 :         xPeerWindow->addFocusListener( &maFocusListeners );
     852         171 : }
     853             : 
     854          62 : void UnoControl::removeFocusListener( const Reference< XFocusListener >& rxListener ) throw(RuntimeException, std::exception)
     855             : {
     856          62 :     Reference< XWindow > xPeerWindow;
     857             :     {
     858          62 :         ::osl::MutexGuard aGuard( GetMutex() );
     859          62 :         if ( maFocusListeners.getLength() == 1 )
     860          51 :             xPeerWindow.set(getPeer(), css::uno::UNO_QUERY);
     861          62 :         maFocusListeners.removeInterface( rxListener );
     862             :     }
     863          62 :     if ( xPeerWindow.is() )
     864          51 :         xPeerWindow->removeFocusListener( &maFocusListeners );
     865          62 : }
     866             : 
     867          79 : void UnoControl::addKeyListener( const Reference< XKeyListener >& rxListener ) throw(RuntimeException, std::exception)
     868             : {
     869          79 :     Reference< XWindow > xPeerWindow;
     870             :     {
     871          79 :         ::osl::MutexGuard aGuard( GetMutex() );
     872          79 :         maKeyListeners.addInterface( rxListener );
     873          79 :         if ( maKeyListeners.getLength() == 1 )
     874          70 :             xPeerWindow.set(getPeer(), css::uno::UNO_QUERY);
     875             :     }
     876          79 :     if ( xPeerWindow.is() )
     877           9 :         xPeerWindow->addKeyListener( &maKeyListeners);
     878          79 : }
     879             : 
     880           2 : void UnoControl::removeKeyListener( const Reference< XKeyListener >& rxListener ) throw(RuntimeException, std::exception)
     881             : {
     882           2 :     Reference< XWindow > xPeerWindow;
     883             :     {
     884           2 :         ::osl::MutexGuard aGuard( GetMutex() );
     885           2 :         if ( maKeyListeners.getLength() == 1 )
     886           1 :             xPeerWindow.set(getPeer(), css::uno::UNO_QUERY);
     887           2 :         maKeyListeners.removeInterface( rxListener );
     888             :     }
     889           2 :     if ( xPeerWindow.is() )
     890           1 :         xPeerWindow->removeKeyListener( &maKeyListeners);
     891           2 : }
     892             : 
     893          90 : void UnoControl::addMouseListener( const Reference< XMouseListener >& rxListener ) throw(RuntimeException, std::exception)
     894             : {
     895          90 :     Reference< XWindow > xPeerWindow;
     896             :     {
     897          90 :         ::osl::MutexGuard aGuard( GetMutex() );
     898          90 :         maMouseListeners.addInterface( rxListener );
     899          90 :         if ( maMouseListeners.getLength() == 1 )
     900          76 :             xPeerWindow.set(getPeer(), css::uno::UNO_QUERY);
     901             :     }
     902          90 :     if ( xPeerWindow.is() )
     903          64 :         xPeerWindow->addMouseListener( &maMouseListeners);
     904          90 : }
     905             : 
     906          62 : void UnoControl::removeMouseListener( const Reference< XMouseListener >& rxListener ) throw(RuntimeException, std::exception)
     907             : {
     908          62 :     Reference< XWindow > xPeerWindow;
     909             :     {
     910          62 :         ::osl::MutexGuard aGuard( GetMutex() );
     911          62 :         if ( maMouseListeners.getLength() == 1 )
     912          56 :             xPeerWindow.set(getPeer(), css::uno::UNO_QUERY);
     913          62 :         maMouseListeners.removeInterface( rxListener );
     914             :     }
     915          62 :     if ( xPeerWindow.is() )
     916          56 :         xPeerWindow->removeMouseListener( &maMouseListeners );
     917          62 : }
     918             : 
     919          18 : void UnoControl::addMouseMotionListener( const Reference< XMouseMotionListener >& rxListener ) throw(RuntimeException, std::exception)
     920             : {
     921          18 :     Reference< XWindow > xPeerWindow;
     922             :     {
     923          18 :         ::osl::MutexGuard aGuard( GetMutex() );
     924          18 :         maMouseMotionListeners.addInterface( rxListener );
     925          18 :         if ( maMouseMotionListeners.getLength() == 1 )
     926           9 :             xPeerWindow.set(getPeer(), css::uno::UNO_QUERY);
     927             :     }
     928          18 :     if ( xPeerWindow.is() )
     929           9 :         xPeerWindow->addMouseMotionListener( &maMouseMotionListeners);
     930          18 : }
     931             : 
     932           2 : void UnoControl::removeMouseMotionListener( const Reference< XMouseMotionListener >& rxListener ) throw(RuntimeException, std::exception)
     933             : {
     934           2 :     Reference< XWindow > xPeerWindow;
     935             :     {
     936           2 :         ::osl::MutexGuard aGuard( GetMutex() );
     937           2 :         if ( maMouseMotionListeners.getLength() == 1 )
     938           1 :             xPeerWindow.set(getPeer(), css::uno::UNO_QUERY);
     939           2 :         maMouseMotionListeners.removeInterface( rxListener );
     940             :     }
     941           2 :     if ( xPeerWindow.is() )
     942           1 :         xPeerWindow->removeMouseMotionListener( &maMouseMotionListeners );
     943           2 : }
     944             : 
     945           0 : void UnoControl::addPaintListener( const Reference< XPaintListener >& rxListener ) throw(RuntimeException, std::exception)
     946             : {
     947           0 :     Reference< XWindow > xPeerWindow;
     948             :     {
     949           0 :         ::osl::MutexGuard aGuard( GetMutex() );
     950           0 :         maPaintListeners.addInterface( rxListener );
     951           0 :         if ( maPaintListeners.getLength() == 1 )
     952           0 :             xPeerWindow.set(getPeer(), css::uno::UNO_QUERY);
     953             :     }
     954           0 :     if ( xPeerWindow.is() )
     955           0 :         xPeerWindow->addPaintListener( &maPaintListeners);
     956           0 : }
     957             : 
     958           0 : void UnoControl::removePaintListener( const Reference< XPaintListener >& rxListener ) throw(RuntimeException, std::exception)
     959             : {
     960           0 :     Reference< XWindow > xPeerWindow;
     961             :     {
     962           0 :         ::osl::MutexGuard aGuard( GetMutex() );
     963           0 :         if ( maPaintListeners.getLength() == 1 )
     964           0 :             xPeerWindow.set(getPeer(), css::uno::UNO_QUERY);
     965           0 :         maPaintListeners.removeInterface( rxListener );
     966             :     }
     967           0 :     if ( xPeerWindow.is() )
     968           0 :         xPeerWindow->removePaintListener( &maPaintListeners );
     969           0 : }
     970             : 
     971             : // XView
     972        9691 : sal_Bool UnoControl::setGraphics( const Reference< XGraphics >& rDevice ) throw(RuntimeException, std::exception)
     973             : {
     974        9691 :     Reference< XView > xView;
     975             :     {
     976        9691 :         ::osl::MutexGuard aGuard( GetMutex() );
     977             : 
     978        9691 :         mxGraphics = rDevice;
     979        9691 :         xView.set(getPeer(), css::uno::UNO_QUERY);
     980             :     }
     981        9691 :     return xView.is() ? xView->setGraphics( rDevice ) : sal_True;
     982             : }
     983             : 
     984        4845 : Reference< XGraphics > UnoControl::getGraphics(  ) throw(RuntimeException, std::exception)
     985             : {
     986        4845 :     return mxGraphics;
     987             : }
     988             : 
     989           0 : awt::Size UnoControl::getSize(  ) throw(RuntimeException, std::exception)
     990             : {
     991           0 :     ::osl::MutexGuard aGuard( GetMutex() );
     992           0 :     return awt::Size( maComponentInfos.nWidth, maComponentInfos.nHeight );
     993             : }
     994             : 
     995        4595 : void UnoControl::draw( sal_Int32 x, sal_Int32 y ) throw(RuntimeException, std::exception)
     996             : {
     997        4595 :     Reference< XWindowPeer > xDrawPeer;
     998        9190 :     Reference< XView > xDrawPeerView;
     999             : 
    1000        4595 :     bool bDisposeDrawPeer( false );
    1001             :     {
    1002        4595 :         ::osl::MutexGuard aGuard( GetMutex() );
    1003             : 
    1004        4595 :         xDrawPeer = ImplGetCompatiblePeer( true );
    1005        4595 :         bDisposeDrawPeer = xDrawPeer.is() && ( xDrawPeer != getPeer() );
    1006             : 
    1007        4595 :         xDrawPeerView.set( xDrawPeer, UNO_QUERY );
    1008        4595 :         DBG_ASSERT( xDrawPeerView.is(), "UnoControl::draw: no peer!" );
    1009             :     }
    1010             : 
    1011        4595 :     if ( xDrawPeerView.is() )
    1012             :     {
    1013        4595 :         Reference< XVclWindowPeer > xWindowPeer;
    1014        4595 :         xWindowPeer.set( xDrawPeer, UNO_QUERY );
    1015        4595 :         if ( xWindowPeer.is() )
    1016        4595 :             xWindowPeer->setDesignMode( mbDesignMode );
    1017        4595 :         xDrawPeerView->draw( x, y );
    1018             :     }
    1019             : 
    1020        4595 :     if ( bDisposeDrawPeer )
    1021        4601 :         xDrawPeer->dispose();
    1022        4595 : }
    1023             : 
    1024       26438 : void UnoControl::setZoom( float fZoomX, float fZoomY ) throw(RuntimeException, std::exception)
    1025             : {
    1026       26438 :     Reference< XView > xView;
    1027             :     {
    1028       26438 :         ::osl::MutexGuard aGuard( GetMutex() );
    1029             : 
    1030       26438 :         maComponentInfos.nZoomX = fZoomX;
    1031       26438 :         maComponentInfos.nZoomY = fZoomY;
    1032             : 
    1033       26438 :         xView.set(getPeer(), css::uno::UNO_QUERY);
    1034             :     }
    1035       26438 :     if ( xView.is() )
    1036       26213 :         xView->setZoom( fZoomX, fZoomY );
    1037       26438 : }
    1038             : 
    1039             : // XControl
    1040        2093 : void UnoControl::setContext( const Reference< XInterface >& rxContext ) throw(RuntimeException, std::exception)
    1041             : {
    1042        2093 :     ::osl::MutexGuard aGuard( GetMutex() );
    1043             : 
    1044        2093 :     mxContext = rxContext;
    1045        2093 : }
    1046             : 
    1047        1055 : Reference< XInterface > UnoControl::getContext(  ) throw(RuntimeException, std::exception)
    1048             : {
    1049        1055 :     ::osl::MutexGuard aGuard( GetMutex() );
    1050             : 
    1051        1055 :     return mxContext;
    1052             : }
    1053             : 
    1054         369 : void UnoControl::peerCreated()
    1055             : {
    1056         369 :     Reference< XWindow > xWindow( getPeer(), UNO_QUERY );
    1057         369 :     if ( !xWindow.is() )
    1058         369 :         return;
    1059             : 
    1060         369 :     if ( maWindowListeners.getLength() )
    1061         154 :         xWindow->addWindowListener( &maWindowListeners );
    1062             : 
    1063         369 :     if ( maFocusListeners.getLength() )
    1064         104 :         xWindow->addFocusListener( &maFocusListeners );
    1065             : 
    1066         369 :     if ( maKeyListeners.getLength() )
    1067          84 :         xWindow->addKeyListener( &maKeyListeners );
    1068             : 
    1069         369 :     if ( maMouseListeners.getLength() )
    1070          10 :         xWindow->addMouseListener( &maMouseListeners );
    1071             : 
    1072         369 :     if ( maMouseMotionListeners.getLength() )
    1073           0 :         xWindow->addMouseMotionListener( &maMouseMotionListeners );
    1074             : 
    1075         369 :     if ( maPaintListeners.getLength() )
    1076           0 :         xWindow->addPaintListener( &maPaintListeners );
    1077             : }
    1078             : 
    1079         359 : void UnoControl::createPeer( const Reference< XToolkit >& rxToolkit, const Reference< XWindowPeer >& rParentPeer ) throw(RuntimeException, std::exception)
    1080             : {
    1081         359 :     ::osl::ClearableMutexGuard aGuard( GetMutex() );
    1082         359 :     if ( !mxModel.is() )
    1083             :     {
    1084           0 :         RuntimeException aException;
    1085           0 :         aException.Message = "createPeer: no model!";
    1086           0 :         aException.Context = static_cast<XAggregation*>(static_cast<cppu::OWeakAggObject*>(this));
    1087           0 :         throw( aException );
    1088             :     }
    1089             : 
    1090         359 :     if( !getPeer().is() )
    1091             :     {
    1092         331 :         mbCreatingPeer = true;
    1093             : 
    1094             :         WindowClass eType;
    1095         331 :         Reference< XToolkit >  xToolkit = rxToolkit;
    1096         331 :         if( rParentPeer.is() && mxContext.is() )
    1097             :         {
    1098             :             // kein TopWindow
    1099         325 :             if ( !xToolkit.is() )
    1100         319 :                 xToolkit = rParentPeer->getToolkit();
    1101         325 :             Any aAny = OWeakAggObject::queryInterface( cppu::UnoType<XControlContainer>::get());
    1102         650 :             Reference< XControlContainer > xC;
    1103         325 :             aAny >>= xC;
    1104         325 :             if( xC.is() )
    1105             :                 // It's a container
    1106           0 :                 eType = WindowClass_CONTAINER;
    1107             :             else
    1108         650 :                 eType = WindowClass_SIMPLE;
    1109             :         }
    1110             :         else
    1111             :         { // This is only correct for Top Window
    1112           6 :             if( rParentPeer.is() )
    1113             :             {
    1114           4 :                 if ( !xToolkit.is() )
    1115           2 :                     xToolkit = rParentPeer->getToolkit();
    1116           4 :                 eType = WindowClass_CONTAINER;
    1117             :             }
    1118             :             else
    1119             :             {
    1120           2 :                 if ( !xToolkit.is() )
    1121           1 :                     xToolkit = VCLUnoHelper::CreateToolkit();
    1122           2 :                 eType = WindowClass_TOP;
    1123             :             }
    1124             :         }
    1125         662 :         WindowDescriptor aDescr;
    1126         331 :         aDescr.Type = eType;
    1127         331 :         aDescr.WindowServiceName = GetComponentServiceName();
    1128         331 :         aDescr.Parent = rParentPeer;
    1129         331 :         aDescr.Bounds = getPosSize();
    1130         331 :         aDescr.WindowAttributes = 0;
    1131             : 
    1132             :         // Border
    1133         662 :         Reference< XPropertySet > xPSet( mxModel, UNO_QUERY );
    1134         662 :         Reference< XPropertySetInfo >  xInfo = xPSet->getPropertySetInfo();
    1135             : 
    1136         662 :         Any aVal;
    1137         662 :         OUString aPropName = GetPropertyName( BASEPROPERTY_BORDER );
    1138         331 :         if ( xInfo->hasPropertyByName( aPropName ) )
    1139             :         {
    1140         225 :             aVal = xPSet->getPropertyValue( aPropName );
    1141         225 :             sal_Int16 n = sal_Int16();
    1142         225 :             if ( aVal >>= n )
    1143             :             {
    1144         225 :                 if ( n )
    1145         222 :                     aDescr.WindowAttributes |= WindowAttribute::BORDER;
    1146             :                 else
    1147           3 :                     aDescr.WindowAttributes |= VclWindowPeerAttribute::NOBORDER;
    1148             :             }
    1149             :         }
    1150             : 
    1151             :         // DESKTOP_AS_PARENT
    1152         331 :         if ( aDescr.Type == WindowClass_TOP )
    1153             :         {
    1154           2 :             aPropName = GetPropertyName( BASEPROPERTY_DESKTOP_AS_PARENT );
    1155           2 :             if ( xInfo->hasPropertyByName( aPropName ) )
    1156             :             {
    1157           2 :                 aVal = xPSet->getPropertyValue( aPropName );
    1158           2 :                 bool b = bool();
    1159           2 :                 if ( ( aVal >>= b ) && b)
    1160           0 :                     aDescr.ParentIndex = -1;
    1161             :             }
    1162             :         }
    1163             :         // Moveable
    1164         331 :         aPropName = GetPropertyName( BASEPROPERTY_MOVEABLE );
    1165         331 :         if ( xInfo->hasPropertyByName( aPropName ) )
    1166             :         {
    1167           4 :             aVal = xPSet->getPropertyValue( aPropName );
    1168           4 :             bool b = bool();
    1169           4 :             if ( ( aVal >>= b ) && b)
    1170           4 :                 aDescr.WindowAttributes |= WindowAttribute::MOVEABLE;
    1171             :         }
    1172             : 
    1173             :         // Closeable
    1174         331 :         aPropName = GetPropertyName( BASEPROPERTY_CLOSEABLE );
    1175         331 :         if ( xInfo->hasPropertyByName( aPropName ) )
    1176             :         {
    1177           4 :             aVal = xPSet->getPropertyValue( aPropName );
    1178           4 :             bool b = bool();
    1179           4 :             if ( ( aVal >>= b ) && b)
    1180           4 :                 aDescr.WindowAttributes |= WindowAttribute::CLOSEABLE;
    1181             :         }
    1182             : 
    1183             :         // Dropdown
    1184         331 :         aPropName = GetPropertyName( BASEPROPERTY_DROPDOWN );
    1185         331 :         if ( xInfo->hasPropertyByName( aPropName ) )
    1186             :         {
    1187          83 :             aVal = xPSet->getPropertyValue( aPropName );
    1188          83 :             bool b = bool();
    1189          83 :             if ( ( aVal >>= b ) && b)
    1190          39 :                 aDescr.WindowAttributes |= VclWindowPeerAttribute::DROPDOWN;
    1191             :         }
    1192             : 
    1193             :         // Spin
    1194         331 :         aPropName = GetPropertyName( BASEPROPERTY_SPIN );
    1195         331 :         if ( xInfo->hasPropertyByName( aPropName ) )
    1196             :         {
    1197          87 :             aVal = xPSet->getPropertyValue( aPropName );
    1198          87 :             bool b = bool();
    1199          87 :             if ( ( aVal >>= b ) && b)
    1200          24 :                 aDescr.WindowAttributes |= VclWindowPeerAttribute::SPIN;
    1201             :         }
    1202             : 
    1203             :         // HScroll
    1204         331 :         aPropName = GetPropertyName( BASEPROPERTY_HSCROLL );
    1205         331 :         if ( xInfo->hasPropertyByName( aPropName ) )
    1206             :         {
    1207          70 :             aVal = xPSet->getPropertyValue( aPropName );
    1208          70 :             bool b = bool();
    1209          70 :             if ( ( aVal >>= b ) && b)
    1210          11 :                 aDescr.WindowAttributes |= VclWindowPeerAttribute::HSCROLL;
    1211             :         }
    1212             : 
    1213             :         // VScroll
    1214         331 :         aPropName = GetPropertyName( BASEPROPERTY_VSCROLL );
    1215         331 :         if ( xInfo->hasPropertyByName( aPropName ) )
    1216             :         {
    1217          70 :             aVal = xPSet->getPropertyValue( aPropName );
    1218          70 :             bool b = bool();
    1219          70 :             if ( ( aVal >>= b ) && b)
    1220          11 :                 aDescr.WindowAttributes |= VclWindowPeerAttribute::VSCROLL;
    1221             :         }
    1222             : 
    1223             :         // AutoHScroll
    1224         331 :         aPropName = GetPropertyName( BASEPROPERTY_AUTOHSCROLL );
    1225         331 :         if ( xInfo->hasPropertyByName( aPropName ) )
    1226             :         {
    1227           1 :             aVal = xPSet->getPropertyValue( aPropName );
    1228           1 :             bool b = bool();
    1229           1 :             if ( ( aVal >>= b ) && b)
    1230           0 :                 aDescr.WindowAttributes |= VclWindowPeerAttribute::AUTOHSCROLL;
    1231             :         }
    1232             : 
    1233             :         // AutoVScroll
    1234         331 :         aPropName = GetPropertyName( BASEPROPERTY_AUTOVSCROLL );
    1235         331 :         if ( xInfo->hasPropertyByName( aPropName ) )
    1236             :         {
    1237           1 :             aVal = xPSet->getPropertyValue( aPropName );
    1238           1 :             bool b = bool();
    1239           1 :             if ( ( aVal >>= b ) && b)
    1240           0 :                 aDescr.WindowAttributes |= VclWindowPeerAttribute::AUTOVSCROLL;
    1241             :         }
    1242             : 
    1243             :         //added for issue79712
    1244             :         //NoLabel
    1245         331 :         aPropName = GetPropertyName( BASEPROPERTY_NOLABEL );
    1246         331 :         if ( xInfo->hasPropertyByName( aPropName ) )
    1247             :         {
    1248           2 :             aVal = xPSet->getPropertyValue( aPropName );
    1249           2 :             bool b = bool();
    1250           2 :             if ( ( aVal >>=b ) && b )
    1251           0 :                 aDescr.WindowAttributes |= VclWindowPeerAttribute::NOLABEL;
    1252             :         }
    1253             :         //issue79712 ends
    1254             : 
    1255             :         // Align
    1256         331 :         aPropName = GetPropertyName( BASEPROPERTY_ALIGN );
    1257         331 :         if ( xInfo->hasPropertyByName( aPropName ) )
    1258             :         {
    1259         304 :             aVal = xPSet->getPropertyValue( aPropName );
    1260         304 :             sal_Int16 n = sal_Int16();
    1261         304 :             if ( aVal >>= n )
    1262             :             {
    1263         304 :                 if ( n == PROPERTY_ALIGN_LEFT )
    1264         228 :                     aDescr.WindowAttributes |= VclWindowPeerAttribute::LEFT;
    1265          76 :                 else if ( n == PROPERTY_ALIGN_CENTER )
    1266          76 :                     aDescr.WindowAttributes |= VclWindowPeerAttribute::CENTER;
    1267             :                 else
    1268           0 :                     aDescr.WindowAttributes |= VclWindowPeerAttribute::RIGHT;
    1269             :             }
    1270             :         }
    1271             : 
    1272             :         // Allow derivates to manipulate attributes
    1273         331 :         PrepareWindowDescriptor(aDescr);
    1274             : 
    1275             :         // create the peer
    1276         331 :         setPeer( xToolkit->createWindow( aDescr ) );
    1277             : 
    1278             :         // release the mutex guard (and work with copies of our members)
    1279             :         // this is necessary as our peer may lock the SolarMutex (actually, all currently known peers do), so calling
    1280             :         // into the peer with our own mutex locked may cause deadlocks
    1281             :         // (We _really_ need peers which do not use the SolarMutex. It's really pissing me off that from time to
    1282             :         // time deadlocks pop up because the low-level components like our peers use a mutex which usually
    1283             :         // is locked at the top of the stack (it protects the global message looping). This is always dangerous, and
    1284             :         // can not always be solved by tampering with other mutexes.
    1285             :         // Unfortunately, the VCL used in the peers is not threadsafe, and by definition needs a locked SolarMutex.)
    1286             :         // 82300 - 12/21/00 - FS
    1287         331 :         UnoControlComponentInfos aComponentInfos(maComponentInfos);
    1288         331 :         bool bDesignMode(mbDesignMode);
    1289             : 
    1290         662 :         Reference< XGraphics >  xGraphics( mxGraphics           );
    1291         662 :         Reference< XView >      xView    ( getPeer(), UNO_QUERY_THROW );
    1292         662 :         Reference< XWindow >    xWindow  ( getPeer(), UNO_QUERY_THROW );
    1293             : 
    1294         331 :         aGuard.clear();
    1295             : 
    1296             :         // the updateFromModel is done without a locked mutex, too.
    1297             :         // The reason is that the only thing this method does  is firing property changes, and this in general has
    1298             :         // to be done without locked mutexes (as every notification to external listeners).
    1299             :         // 82300 - 12/21/00 - FS
    1300         331 :         updateFromModel();
    1301             : 
    1302         331 :         xView->setZoom( aComponentInfos.nZoomX, aComponentInfos.nZoomY );
    1303             : 
    1304         331 :         setPosSize( aComponentInfos.nX, aComponentInfos.nY, aComponentInfos.nWidth, aComponentInfos.nHeight, aComponentInfos.nFlags );
    1305             : 
    1306         331 :         if( aComponentInfos.bVisible && !bDesignMode )
    1307             :             // Show only after setting the data
    1308          63 :             xWindow->setVisible( aComponentInfos.bVisible );
    1309             : 
    1310         331 :         if( !aComponentInfos.bEnable )
    1311           0 :             xWindow->setEnable( aComponentInfos.bEnable );
    1312             : 
    1313         331 :         xView->setGraphics( xGraphics );
    1314             : 
    1315         331 :         peerCreated();
    1316             : 
    1317         662 :         mbCreatingPeer = false;
    1318         359 :     }
    1319         359 : }
    1320             : 
    1321      107098 : Reference< XWindowPeer > UnoControl::getPeer() throw(RuntimeException, std::exception)
    1322             : {
    1323      107098 :     ::osl::MutexGuard aGuard( GetMutex() );
    1324      107098 :     return mxPeer;
    1325             : }
    1326             : 
    1327        3073 : sal_Bool UnoControl::setModel( const Reference< XControlModel >& rxModel ) throw(RuntimeException, std::exception)
    1328             : {
    1329        3073 :     ::osl::MutexGuard aGuard( GetMutex() );
    1330             : 
    1331        6146 :     Reference< XMultiPropertySet > xPropSet( mxModel, UNO_QUERY );
    1332             : 
    1333             :     // query for the XPropertiesChangeListener - our delegator is allowed to overwrite this interface
    1334        6146 :     Reference< XPropertiesChangeListener > xListener;
    1335        3073 :     queryInterface( cppu::UnoType<decltype(xListener)>::get() ) >>= xListener;
    1336             : 
    1337        3073 :     if( xPropSet.is() )
    1338        1477 :         xPropSet->removePropertiesChangeListener( xListener );
    1339             : 
    1340        3073 :     mpData->bLocalizationSupport = false;
    1341        3073 :     mxModel = rxModel;
    1342             : 
    1343        3073 :     if( mxModel.is() )
    1344             :     {
    1345             :         try
    1346             :         {
    1347        1487 :             xPropSet.set( mxModel, UNO_QUERY_THROW );
    1348        1487 :             Reference< XPropertySetInfo > xPSI( xPropSet->getPropertySetInfo(), UNO_SET_THROW );
    1349             : 
    1350        2974 :             Sequence< OUString> aNames = lcl_ImplGetPropertyNames( xPropSet );
    1351        1487 :             xPropSet->addPropertiesChangeListener( aNames, xListener );
    1352             : 
    1353        2974 :             mpData->bLocalizationSupport = xPSI->hasPropertyByName("ResourceResolver");
    1354             :         }
    1355           0 :         catch( const Exception& )
    1356             :         {
    1357             :             DBG_UNHANDLED_EXCEPTION();
    1358           0 :             mxModel.clear();
    1359             :         }
    1360             :     }
    1361             : 
    1362        6146 :     return mxModel.is();
    1363             : }
    1364             : 
    1365        8457 : Reference< XControlModel > UnoControl::getModel(    ) throw(RuntimeException, std::exception)
    1366             : {
    1367        8457 :     return mxModel;
    1368             : }
    1369             : 
    1370          29 : Reference< XView > UnoControl::getView(  ) throw(RuntimeException, std::exception)
    1371             : {
    1372          29 :     return  static_cast< XView* >( this );
    1373             : }
    1374             : 
    1375         268 : void UnoControl::setDesignMode( sal_Bool bOn ) throw(RuntimeException, std::exception)
    1376             : {
    1377         268 :     ModeChangeEvent aModeChangeEvent;
    1378             : 
    1379         481 :     Reference< XWindow > xWindow;
    1380         481 :     Reference<XComponent> xAccessibleComp;
    1381             :     {
    1382         268 :         ::osl::MutexGuard aGuard( GetMutex() );
    1383         268 :         if ( bool(bOn) == mbDesignMode )
    1384         323 :             return;
    1385             : 
    1386             :         // remember this
    1387         213 :         mbDesignMode = bOn;
    1388         213 :         xWindow.set(getPeer(), css::uno::UNO_QUERY);
    1389             : 
    1390         213 :         xAccessibleComp.set(maAccessibleContext, UNO_QUERY);
    1391         213 :         maAccessibleContext.clear();
    1392             : 
    1393         213 :         aModeChangeEvent.Source = *this;
    1394         213 :         aModeChangeEvent.NewMode = mbDesignMode ? OUString("design") : OUString("alive" );
    1395             :     }
    1396             : 
    1397             :     // dispose current AccessibleContext, if we have one - without Mutex lock
    1398             :     // (changing the design mode implies having a new implementation for this context,
    1399             :     // so the old one must be declared DEFUNC)
    1400         213 :     DisposeAccessibleContext(xAccessibleComp);
    1401             : 
    1402             :     // adjust the visibility of our window
    1403         213 :     if ( xWindow.is() )
    1404          61 :         xWindow->setVisible( !bOn );
    1405             : 
    1406             :     // and notify our mode listeners
    1407         426 :     maModeChangeListeners.notifyEach( &XModeChangeListener::modeChanged, aModeChangeEvent );
    1408             : }
    1409             : 
    1410       16047 : sal_Bool UnoControl::isDesignMode(  ) throw(RuntimeException, std::exception)
    1411             : {
    1412       16047 :     return mbDesignMode;
    1413             : }
    1414             : 
    1415          20 : sal_Bool UnoControl::isTransparent(  ) throw(RuntimeException, std::exception)
    1416             : {
    1417          20 :     return sal_False;
    1418             : }
    1419             : 
    1420             : // XServiceInfo
    1421           0 : OUString UnoControl::getImplementationName(  ) throw(RuntimeException, std::exception)
    1422             : {
    1423             :     OSL_FAIL( "This method should be overridden!" );
    1424           0 :     return OUString();
    1425             : }
    1426             : 
    1427           0 : sal_Bool UnoControl::supportsService( const OUString& rServiceName ) throw(RuntimeException, std::exception)
    1428             : {
    1429           0 :     return cppu::supportsService(this, rServiceName);
    1430             : }
    1431             : 
    1432          40 : Sequence< OUString > UnoControl::getSupportedServiceNames(  ) throw(RuntimeException, std::exception)
    1433             : {
    1434          40 :     OUString sName( "com.sun.star.awt.UnoControl" );
    1435          40 :     return Sequence< OUString >( &sName, 1 );
    1436             : }
    1437             : 
    1438             : 
    1439          32 : Reference< XAccessibleContext > SAL_CALL UnoControl::getAccessibleContext(  ) throw (RuntimeException, std::exception)
    1440             : {
    1441             :     // creation of the context will certainly require the SolarMutex ...
    1442          32 :     SolarMutexGuard aSolarGuard;
    1443          64 :     ::osl::MutexGuard aGuard( GetMutex() );
    1444             : 
    1445          32 :     Reference< XAccessibleContext > xCurrentContext( maAccessibleContext.get(), UNO_QUERY );
    1446          32 :     if ( !xCurrentContext.is() )
    1447             :     {
    1448          32 :         if ( !mbDesignMode )
    1449             :         {   // in alive mode, use the AccessibleContext of the peer
    1450           3 :             Reference< XAccessible > xPeerAcc( getPeer(), UNO_QUERY );
    1451           3 :             if ( xPeerAcc.is() )
    1452           3 :                 xCurrentContext = xPeerAcc->getAccessibleContext( );
    1453             :         }
    1454             :         else
    1455             :             // in design mode, use a fallback
    1456          29 :             xCurrentContext = ::toolkit::OAccessibleControlContext::create( this );
    1457             : 
    1458             :         DBG_ASSERT( xCurrentContext.is(), "UnoControl::getAccessibleContext: invalid context (invalid peer?)!" );
    1459          32 :         maAccessibleContext = xCurrentContext;
    1460             : 
    1461             :         // get notified when the context is disposed
    1462          32 :         Reference< XComponent > xContextComp( xCurrentContext, UNO_QUERY );
    1463          32 :         if ( xContextComp.is() )
    1464          32 :             xContextComp->addEventListener( this );
    1465             :         // In an ideal world, this is not necessary - there the object would be released as soon as it has been
    1466             :         // disposed, and thus our weak reference would be empty, too.
    1467             :         // But 'til this ideal world comes (means 'til we do never have any refcount/lifetime bugs anymore), we
    1468             :         // need to listen for disposal and reset our weak reference then.
    1469             :     }
    1470             : 
    1471          64 :     return xCurrentContext;
    1472             : }
    1473             : 
    1474         217 : void SAL_CALL UnoControl::addModeChangeListener( const Reference< XModeChangeListener >& _rxListener ) throw (RuntimeException, std::exception)
    1475             : {
    1476         217 :     ::osl::MutexGuard aGuard( GetMutex() );
    1477         217 :     maModeChangeListeners.addInterface( _rxListener );
    1478         217 : }
    1479             : 
    1480         217 : void SAL_CALL UnoControl::removeModeChangeListener( const Reference< XModeChangeListener >& _rxListener ) throw (RuntimeException, std::exception)
    1481             : {
    1482         217 :     ::osl::MutexGuard aGuard( GetMutex() );
    1483         217 :     maModeChangeListeners.removeInterface( _rxListener );
    1484         217 : }
    1485             : 
    1486           0 : void SAL_CALL UnoControl::addModeChangeApproveListener( const Reference< XModeChangeApproveListener >& ) throw (NoSupportException, RuntimeException, std::exception)
    1487             : {
    1488           0 :     throw NoSupportException( );
    1489             : }
    1490             : 
    1491           0 : void SAL_CALL UnoControl::removeModeChangeApproveListener( const Reference< XModeChangeApproveListener >&  ) throw (NoSupportException, RuntimeException, std::exception)
    1492             : {
    1493           0 :     throw NoSupportException( );
    1494             : }
    1495             : 
    1496             : 
    1497           0 : awt::Point SAL_CALL UnoControl::convertPointToLogic( const awt::Point& i_Point, ::sal_Int16 i_TargetUnit ) throw (IllegalArgumentException, RuntimeException, std::exception)
    1498             : {
    1499           0 :     Reference< XUnitConversion > xPeerConversion;
    1500             :     {
    1501           0 :         ::osl::MutexGuard aGuard( GetMutex() );
    1502           0 :         xPeerConversion.set(getPeer(), css::uno::UNO_QUERY);
    1503             :     }
    1504           0 :     if ( xPeerConversion.is() )
    1505           0 :         return xPeerConversion->convertPointToLogic( i_Point, i_TargetUnit );
    1506           0 :     return awt::Point( );
    1507             : }
    1508             : 
    1509             : 
    1510           0 : awt::Point SAL_CALL UnoControl::convertPointToPixel( const awt::Point& i_Point, ::sal_Int16 i_SourceUnit ) throw (IllegalArgumentException, RuntimeException, std::exception)
    1511             : {
    1512           0 :     Reference< XUnitConversion > xPeerConversion;
    1513             :     {
    1514           0 :         ::osl::MutexGuard aGuard( GetMutex() );
    1515           0 :         xPeerConversion.set(getPeer(), css::uno::UNO_QUERY);
    1516             :     }
    1517           0 :     if ( xPeerConversion.is() )
    1518           0 :         return xPeerConversion->convertPointToPixel( i_Point, i_SourceUnit );
    1519           0 :     return awt::Point( );
    1520             : }
    1521             : 
    1522             : 
    1523           0 : awt::Size SAL_CALL UnoControl::convertSizeToLogic( const awt::Size& i_Size, ::sal_Int16 i_TargetUnit ) throw (IllegalArgumentException, RuntimeException, std::exception)
    1524             : {
    1525           0 :     Reference< XUnitConversion > xPeerConversion;
    1526             :     {
    1527           0 :         ::osl::MutexGuard aGuard( GetMutex() );
    1528           0 :         xPeerConversion.set(getPeer(), css::uno::UNO_QUERY);
    1529             :     }
    1530           0 :     if ( xPeerConversion.is() )
    1531           0 :         return xPeerConversion->convertSizeToLogic( i_Size, i_TargetUnit );
    1532           0 :     return awt::Size( );
    1533             : }
    1534             : 
    1535             : 
    1536           0 : awt::Size SAL_CALL UnoControl::convertSizeToPixel( const awt::Size& i_Size, ::sal_Int16 i_SourceUnit ) throw (IllegalArgumentException, RuntimeException, std::exception)
    1537             : {
    1538           0 :     Reference< XUnitConversion > xPeerConversion;
    1539             :     {
    1540           0 :         ::osl::MutexGuard aGuard( GetMutex() );
    1541           0 :         xPeerConversion.set(getPeer(), css::uno::UNO_QUERY);
    1542             :     }
    1543           0 :     if ( xPeerConversion.is() )
    1544           0 :         return xPeerConversion->convertSizeToPixel( i_Size, i_SourceUnit );
    1545           0 :     return awt::Size( );
    1546             : }
    1547             : 
    1548             : 
    1549           0 : uno::Reference< awt::XStyleSettings > SAL_CALL UnoControl::getStyleSettings() throw (RuntimeException, std::exception)
    1550             : {
    1551           0 :     Reference< awt::XStyleSettingsSupplier > xPeerSupplier;
    1552             :     {
    1553           0 :         ::osl::MutexGuard aGuard( GetMutex() );
    1554           0 :         xPeerSupplier.set(getPeer(), css::uno::UNO_QUERY);
    1555             :     }
    1556           0 :     if ( xPeerSupplier.is() )
    1557           0 :         return xPeerSupplier->getStyleSettings();
    1558           0 :     return NULL;
    1559             : }
    1560             : 
    1561             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11