LCOV - code coverage report
Current view: top level - toolkit/source/controls - unocontrol.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 649 786 82.6 %
Date: 2014-04-11 Functions: 58 81 71.6 %
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        1528 : static Sequence< OUString> lcl_ImplGetPropertyNames( const Reference< XMultiPropertySet > & rxModel )
      80             : {
      81        1528 :     Sequence< OUString> aNames;
      82        3056 :     Reference< XPropertySetInfo >  xPSInf = rxModel->getPropertySetInfo();
      83             :     DBG_ASSERT( xPSInf.is(), "UpdateFromModel: No PropertySetInfo!" );
      84        1528 :     if ( xPSInf.is() )
      85             :     {
      86        1528 :         Sequence< Property> aProps = xPSInf->getProperties();
      87        1528 :         sal_Int32 nLen = aProps.getLength();
      88        1528 :         aNames = Sequence< OUString>( nLen );
      89        1528 :         OUString* pNames = aNames.getArray();
      90        1528 :         const Property* pProps = aProps.getConstArray();
      91       60067 :         for ( sal_Int32 n = 0; n < nLen; ++n, ++pProps, ++pNames)
      92       60067 :             *pNames = pProps->Name;
      93             :     }
      94        3056 :     return aNames;
      95             : }
      96             : 
      97             : 
      98             : class VclListenerLock: private boost::noncopyable
      99             : {
     100             : private:
     101             :     VCLXWindow*  m_pLockWindow;
     102             : 
     103             : public:
     104        5027 :     inline VclListenerLock( VCLXWindow* _pLockWindow )
     105        5027 :         :m_pLockWindow( _pLockWindow )
     106             :     {
     107        5027 :         if ( m_pLockWindow )
     108        5027 :             m_pLockWindow->suspendVclEventListening( );
     109        5027 :     }
     110        5027 :     inline ~VclListenerLock( )
     111             :     {
     112        5027 :         if ( m_pLockWindow )
     113        5027 :             m_pLockWindow->resumeVclEventListening( );
     114        5027 :     }
     115             : };
     116             : 
     117             : typedef ::std::map< OUString, sal_Int32 >    MapString2Int;
     118        1093 : struct UnoControl_Data
     119             : {
     120             :     MapString2Int   aSuspendedPropertyNotifications;
     121             :     /// true if and only if our model has a property ResourceResolver
     122             :     bool            bLocalizationSupport;
     123             : 
     124        1155 :     UnoControl_Data()
     125             :         :aSuspendedPropertyNotifications()
     126        1155 :         ,bLocalizationSupport( false )
     127             :     {
     128        1155 :     }
     129             : };
     130             : 
     131        1155 : UnoControl::UnoControl() :
     132             :       maDisposeListeners( *this )
     133             :     , maWindowListeners( *this )
     134             :     , maFocusListeners( *this )
     135             :     , maKeyListeners( *this )
     136             :     , maMouseListeners( *this )
     137             :     , maMouseMotionListeners( *this )
     138             :     , maPaintListeners( *this )
     139        1155 :     , maModeChangeListeners( GetMutex() )
     140        2310 :     , mpData( new UnoControl_Data )
     141             : {
     142        1155 :     mbDisposePeer = true;
     143        1155 :     mbRefeshingPeer = false;
     144        1155 :     mbCreatingPeer = false;
     145        1155 :     mbCreatingCompatiblePeer = false;
     146        1155 :     mbDesignMode = false;
     147        1155 : }
     148             : 
     149        2186 : UnoControl::~UnoControl()
     150             : {
     151        1093 :     DELETEZ( mpData );
     152        1093 : }
     153             : 
     154           0 : OUString UnoControl::GetComponentServiceName()
     155             : {
     156           0 :     return OUString();
     157             : }
     158             : 
     159        2901 : Reference< XWindowPeer >    UnoControl::ImplGetCompatiblePeer( bool bAcceptExistingPeer )
     160             : {
     161             :     DBG_ASSERT( !mbCreatingCompatiblePeer, "ImplGetCompatiblePeer - rekursive?" );
     162             : 
     163        2901 :     mbCreatingCompatiblePeer = true;
     164             : 
     165        2901 :     Reference< XWindowPeer > xCompatiblePeer;
     166             : 
     167        2901 :     if ( bAcceptExistingPeer )
     168        2901 :         xCompatiblePeer = getPeer();
     169             : 
     170        2901 :     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( ::getCppuType( &xMe ) ) >>= xMe;
     183             : 
     184           6 :         Window* pParentWindow( NULL );
     185             :         {
     186           6 :             SolarMutexGuard aGuard;
     187           6 :             pParentWindow = dynamic_cast< 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( sal_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        2901 :     mbCreatingCompatiblePeer = false;
     214             : 
     215        2901 :     return xCompatiblePeer;
     216             : }
     217             : 
     218         371 : bool UnoControl::ImplCheckLocalize( OUString& _rPossiblyLocalizable )
     219             : {
     220         742 :     if  (   !mpData->bLocalizationSupport
     221          23 :         ||  ( _rPossiblyLocalizable.isEmpty() )
     222         379 :         ||  ( _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         371 :         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       31616 : 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       31616 :     if ( mxVclWindowPeer.is() )
     257             :     {
     258       31616 :         Any aConvertedValue( rVal );
     259             : 
     260       31616 :         if ( mpData->bLocalizationSupport )
     261             :         {
     262             :             // We now support a mapping for language dependent properties. This is the
     263             :             // central method to implement it.
     264        1959 :             if( rPropName == "Text"            ||
     265        1303 :                 rPropName == "Label"           ||
     266        1296 :                 rPropName == "Title"           ||
     267        1281 :                 rPropName == "HelpText"        ||
     268        1923 :                 rPropName == "CurrencySymbol"  ||
     269         635 :                 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       31616 :         mxVclWindowPeer->setProperty( rPropName, aConvertedValue );
     288             :     }
     289       31616 : }
     290             : 
     291         316 : void UnoControl::PrepareWindowDescriptor( WindowDescriptor& )
     292             : {
     293         316 : }
     294             : 
     295        5027 : Reference< XWindow >    UnoControl::getParentPeer() const
     296             : {
     297        5027 :     Reference< XWindow > xPeer;
     298        5027 :     if( mxContext.is() )
     299             :     {
     300        4994 :         Reference< XControl > xContComp( mxContext, UNO_QUERY );
     301        4994 :         if ( xContComp.is() )
     302             :         {
     303        4813 :             Reference< XWindowPeer > xP = xContComp->getPeer();
     304        4813 :             if ( xP.is() )
     305        4809 :                 xPeer.set( xP, UNO_QUERY );
     306        4994 :         }
     307             :     }
     308        5027 :     return xPeer;
     309             : }
     310             : 
     311         378 : void UnoControl::updateFromModel()
     312             : {
     313             :     // Read default properties and hand over to peer
     314         378 :     if( getPeer().is() )
     315             :     {
     316         378 :         Reference< XMultiPropertySet >  xPropSet( mxModel, UNO_QUERY );
     317         378 :         if( xPropSet.is() )
     318             :         {
     319         378 :             Sequence< OUString> aNames = lcl_ImplGetPropertyNames( xPropSet );
     320         378 :             xPropSet->firePropertiesChangeEvent( aNames, this );
     321         378 :         }
     322             :     }
     323         378 : }
     324             : 
     325             : 
     326             : // XTypeProvider
     327           0 : IMPL_IMPLEMENTATION_ID( UnoControl )
     328             : 
     329             : void
     330        1424 : UnoControl::DisposeAccessibleContext(Reference<XComponent> const& xContextComp)
     331             : {
     332        1424 :     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        1424 : }
     345             : 
     346        1194 : void UnoControl::dispose(  ) throw(RuntimeException, std::exception)
     347             : {
     348        1194 :     Reference< XWindowPeer > xPeer;
     349        2388 :     Reference<XComponent> xAccessibleComp;
     350             :     {
     351        1194 :         ::osl::MutexGuard aGuard( GetMutex() );
     352        1194 :         if( mbDisposePeer )
     353             :         {
     354         653 :             xPeer = mxPeer;
     355             :         }
     356        1194 :         setPeer( NULL );
     357        1194 :         xAccessibleComp.set(maAccessibleContext, UNO_QUERY);
     358        1194 :         maAccessibleContext.clear();
     359             :     }
     360        1194 :     if( xPeer.is() )
     361             :     {
     362         206 :         xPeer->dispose();
     363             :     }
     364             : 
     365             :     // dispose our AccessibleContext - without Mutex locked
     366        1194 :     DisposeAccessibleContext(xAccessibleComp);
     367             : 
     368        2388 :     EventObject aDisposeEvent;
     369        1194 :     aDisposeEvent.Source = static_cast< XAggregation* >( this );
     370             : 
     371        1194 :     maDisposeListeners.disposeAndClear( aDisposeEvent );
     372        1194 :     maWindowListeners.disposeAndClear( aDisposeEvent );
     373        1194 :     maFocusListeners.disposeAndClear( aDisposeEvent );
     374        1194 :     maKeyListeners.disposeAndClear( aDisposeEvent );
     375        1194 :     maMouseListeners.disposeAndClear( aDisposeEvent );
     376        1194 :     maMouseMotionListeners.disposeAndClear( aDisposeEvent );
     377        1194 :     maPaintListeners.disposeAndClear( aDisposeEvent );
     378        1194 :     maModeChangeListeners.disposeAndClear( aDisposeEvent );
     379             : 
     380             :     // release Model again
     381        1194 :     setModel( Reference< XControlModel > () );
     382        2388 :     setContext( Reference< XInterface > () );
     383        1194 : }
     384             : 
     385          90 : void UnoControl::addEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException, std::exception)
     386             : {
     387          90 :     ::osl::MutexGuard aGuard( GetMutex() );
     388             : 
     389          90 :     maDisposeListeners.addInterface( rxListener );
     390          90 : }
     391             : 
     392          80 : void UnoControl::removeEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException, std::exception)
     393             : {
     394          80 :     ::osl::MutexGuard aGuard( GetMutex() );
     395             : 
     396          80 :     maDisposeListeners.removeInterface( rxListener );
     397          80 : }
     398             : 
     399        1248 : bool UnoControl::requiresNewPeer( const OUString& /* _rPropertyName */ ) const
     400             : {
     401        1248 :     return false;
     402             : }
     403             : 
     404             : // XPropertiesChangeListener
     405        5329 : void UnoControl::propertiesChange( const Sequence< PropertyChangeEvent >& rEvents ) throw(RuntimeException, std::exception)
     406             : {
     407        5329 :     Sequence< PropertyChangeEvent > aEvents( rEvents );
     408             :     {
     409        5329 :         ::osl::MutexGuard aGuard( GetMutex() );
     410             : 
     411        5329 :         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        5414 :                 return;
     429        5244 :         }
     430             :     }
     431             : 
     432        5244 :     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        5244 : void UnoControl::ImplModelPropertiesChanged( const Sequence< PropertyChangeEvent >& rEvents )
     466             : {
     467        5244 :     ::osl::ClearableGuard< ::osl::Mutex > aGuard( GetMutex() );
     468             : 
     469        5244 :     if( getPeer().is() )
     470             :     {
     471        5027 :         std::vector< PropertyValue > aPeerPropertiesToSet;
     472        5027 :         sal_Int32               nIndependentPos = 0;
     473        5027 :         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        5027 :         bool bNeedNewPeer = false;
     478             :             // some properties require a re-creation of the peer, 'cause they can't be changed on the fly
     479             : 
     480       10054 :         Reference< XControlModel > xOwnModel( getModel(), UNO_QUERY );
     481             :             // our own model for comparison
     482       10054 :         Reference< XPropertySet > xPS( xOwnModel, UNO_QUERY );
     483       10054 :         Reference< XPropertySetInfo > xPSI( xPS->getPropertySetInfo(), UNO_QUERY );
     484             :         OSL_ENSURE( xPSI.is(), "UnoControl::ImplModelPropertiesChanged: should have property set meta data!" );
     485             : 
     486        5027 :         const PropertyChangeEvent* pEvents = rEvents.getConstArray();
     487             : 
     488        5027 :         sal_Int32 nLen = rEvents.getLength();
     489        5027 :         aPeerPropertiesToSet.reserve(nLen);
     490             : 
     491       37266 :         for( sal_Int32 i = 0; i < nLen; ++i, ++pEvents )
     492             :         {
     493       32398 :             Reference< XControlModel > xModel( pEvents->Source, UNO_QUERY );
     494       32398 :             bool bOwnModel = xModel.get() == xOwnModel.get();
     495       32398 :             if ( !bOwnModel )
     496          27 :                 continue;
     497             : 
     498             :             // Detect changes on our resource resolver which invalidates
     499             :             // automatically some language dependent properties.
     500       32371 :             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       32371 :             sal_uInt16 nPType = GetPropertyId( pEvents->PropertyName );
     508       32371 :             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        5089 :                 if ( nPType )
     514             :                     bNeedNewPeer = ( nPType == BASEPROPERTY_BORDER )
     515        3807 :                                 || ( nPType == BASEPROPERTY_MULTILINE )
     516        3779 :                                 || ( nPType == BASEPROPERTY_DROPDOWN )
     517        3746 :                                 || ( nPType == BASEPROPERTY_HSCROLL )
     518        3738 :                                 || ( nPType == BASEPROPERTY_VSCROLL )
     519        3730 :                                 || ( nPType == BASEPROPERTY_AUTOHSCROLL )
     520        3730 :                                 || ( nPType == BASEPROPERTY_AUTOVSCROLL )
     521        3730 :                                 || ( nPType == BASEPROPERTY_ORIENTATION )
     522        3730 :                                 || ( nPType == BASEPROPERTY_SPIN )
     523        3694 :                                 || ( nPType == BASEPROPERTY_ALIGN )
     524        7531 :                                 || ( nPType == BASEPROPERTY_PAINTTRANSPARENT );
     525             :                 else
     526        1248 :                     bNeedNewPeer = requiresNewPeer( pEvents->PropertyName );
     527             : 
     528        5089 :                 if ( bNeedNewPeer )
     529         159 :                     break;
     530             :             }
     531             : 
     532       32212 :             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         459 :                 aPeerPropertiesToSet.push_back(PropertyValue(pEvents->PropertyName, 0, pEvents->NewValue, PropertyState_DIRECT_VALUE));
     538             :             }
     539             :             else
     540             :             {
     541       31753 :                 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       31753 :                 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         463 :                         PropertyValue( pEvents->PropertyName, 0, pEvents->NewValue, PropertyState_DIRECT_VALUE ) );
     564         463 :                     ++nIndependentPos;
     565             :                 }
     566             :                 else
     567             :                 {
     568             :                     aPeerPropertiesToSet.insert(aPeerPropertiesToSet.begin() + nIndependentPos,
     569       31290 :                         PropertyValue(pEvents->PropertyName, 0, pEvents->NewValue, PropertyState_DIRECT_VALUE));
     570       31290 :                     ++nIndependentPos;
     571             :                 }
     572             :             }
     573       32212 :         }
     574             : 
     575       10054 :         Reference< XWindow >    xParent = getParentPeer();
     576       10054 :         Reference< XControl > xThis( (XAggregation*)(::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        5027 :         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 ( sal_uInt32 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        5027 :         aGuard.clear();
     616             : 
     617             :         // clear the guard before creating a new peer - as usual, our peer implementations use the SolarMutex
     618             : 
     619        5027 :         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        5027 :         Window* pVclPeer = VCLUnoHelper::GetWindow( getPeer() );
     644        5027 :         VCLXWindow* pPeer = pVclPeer ? pVclPeer->GetWindowPeer() : NULL;
     645       10054 :         VclListenerLock aNoVclEventMultiplexing( pPeer );
     646             : 
     647             :         // setting peer properties may result in an attemp 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        5027 :         std::vector< PropertyValue >::iterator aEnd = aPeerPropertiesToSet.end();
     651       37083 :         for (   std::vector< PropertyValue >::iterator aLoop = aPeerPropertiesToSet.begin();
     652             :                 aLoop != aEnd;
     653             :                 ++aLoop
     654             :             )
     655             :         {
     656       32056 :             ImplSetPeerProperty( aLoop->Name, aLoop->Value );
     657        5027 :         }
     658        5244 :     }
     659        5244 : }
     660             : 
     661         820 : void UnoControl::disposing( const EventObject& rEvt ) throw(RuntimeException, std::exception)
     662             : {
     663         820 :     ::osl::ClearableMutexGuard aGuard( GetMutex() );
     664             :     // do not compare differing types in case of multible inheritance
     665             : 
     666         820 :     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         820 :     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         101 :         Reference< XControl >  xThis = this;
     675             : 
     676         101 :         aGuard.clear();
     677         101 :         xThis->dispose();
     678             : 
     679             :         DBG_ASSERT( !mxModel.is(), "UnoControl::disposing: invalid dispose behaviour!" );
     680         101 :         mxModel.clear();
     681         820 :     }
     682         820 : }
     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 = xPeerWindow.query( getPeer() );
     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        3573 :     RETVALTYPE lcl_askPeer( const uno::Reference< awt::XWindowPeer >& _rxPeer, RETVALTYPE (SAL_CALL XWindow2::*_pMethod)(), DEFAULTTYPE _aDefault )
     701             :     {
     702        3573 :         RETVALTYPE aReturn( _aDefault );
     703             : 
     704        3573 :         Reference< XWindow2 > xPeerWindow( _rxPeer, UNO_QUERY );
     705        3573 :         if ( xPeerWindow.is() )
     706        3558 :             aReturn = (xPeerWindow.get()->*_pMethod)();
     707             : 
     708        3573 :         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        3573 : sal_Bool SAL_CALL UnoControl::isVisible(  ) throw (RuntimeException, std::exception)
     718             : {
     719        3573 :     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         886 : void UnoControl::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags ) throw(RuntimeException, std::exception)
     739             : {
     740         886 :     Reference< XWindow > xWindow;
     741             :     {
     742         886 :         ::osl::MutexGuard aGuard( GetMutex() );
     743             : 
     744         886 :         if ( Flags & awt::PosSize::X )
     745         879 :             maComponentInfos.nX = X;
     746         886 :         if ( Flags & awt::PosSize::Y )
     747         879 :             maComponentInfos.nY = Y;
     748         886 :         if ( Flags & awt::PosSize::WIDTH )
     749         880 :             maComponentInfos.nWidth = Width;
     750         886 :         if ( Flags & awt::PosSize::HEIGHT )
     751         880 :             maComponentInfos.nHeight = Height;
     752         886 :         maComponentInfos.nFlags |= Flags;
     753             : 
     754         886 :         xWindow = xWindow.query( getPeer() );
     755             :     }
     756             : 
     757         886 :     if( xWindow.is() )
     758         406 :         xWindow->setPosSize( X, Y, Width, Height, Flags );
     759         886 : }
     760             : 
     761       13847 : awt::Rectangle UnoControl::getPosSize(  ) throw(RuntimeException, std::exception)
     762             : {
     763       13847 :     awt::Rectangle aRect( maComponentInfos.nX, maComponentInfos.nY, maComponentInfos.nWidth, maComponentInfos.nHeight);
     764       13847 :     Reference< XWindow > xWindow;
     765             : 
     766             :     {
     767       13847 :         ::osl::MutexGuard aGuard( GetMutex() );
     768       13847 :         xWindow = xWindow.query( getPeer() );
     769             :     }
     770             : 
     771       13847 :     if( xWindow.is() )
     772       13312 :         aRect = xWindow->getPosSize();
     773       13847 :     return aRect;
     774             : }
     775             : 
     776          55 : void UnoControl::setVisible( sal_Bool bVisible ) throw(RuntimeException, std::exception)
     777             : {
     778          55 :     Reference< XWindow > xWindow;
     779             :     {
     780          55 :         ::osl::MutexGuard aGuard( GetMutex() );
     781             : 
     782             :         // Visible status is handled by View
     783          55 :         maComponentInfos.bVisible = bVisible;
     784          55 :         xWindow = xWindow.query( getPeer() );
     785             :     }
     786          55 :     if ( xWindow.is() )
     787           2 :         xWindow->setVisible( bVisible );
     788          55 : }
     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 = xWindow.query( getPeer() );
     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 = xWindow.query( getPeer() );
     810             :     }
     811           1 :     if ( xWindow.is() )
     812           1 :         xWindow->setFocus();
     813           1 : }
     814             : 
     815         212 : void UnoControl::addWindowListener( const Reference< XWindowListener >& rxListener ) throw(RuntimeException, std::exception)
     816             : {
     817         212 :     Reference< XWindow > xPeerWindow;
     818             :     {
     819         212 :         ::osl::MutexGuard aGuard( GetMutex() );
     820         212 :         maWindowListeners.addInterface( rxListener );
     821         212 :         if ( maWindowListeners.getLength() == 1 )
     822         210 :             xPeerWindow = xPeerWindow.query( getPeer() );
     823             :     }
     824         212 :     if ( xPeerWindow.is() )
     825         205 :         xPeerWindow->addWindowListener( &maWindowListeners );
     826         212 : }
     827             : 
     828         208 : void UnoControl::removeWindowListener( const Reference< XWindowListener >& rxListener ) throw(RuntimeException, std::exception)
     829             : {
     830         208 :     Reference< XWindow > xPeerWindow;
     831             :     {
     832         208 :         ::osl::MutexGuard aGuard( GetMutex() );
     833         208 :         if ( maWindowListeners.getLength() == 1 )
     834         205 :             xPeerWindow = xPeerWindow.query( getPeer() );
     835         208 :         maWindowListeners.removeInterface( rxListener );
     836             :     }
     837         208 :     if ( xPeerWindow.is() )
     838         200 :         xPeerWindow->removeWindowListener( &maWindowListeners );
     839         208 : }
     840             : 
     841         139 : void UnoControl::addFocusListener( const Reference< XFocusListener >& rxListener ) throw(RuntimeException, std::exception)
     842             : {
     843         139 :     Reference< XWindow > xPeerWindow;
     844             :     {
     845         139 :         ::osl::MutexGuard aGuard( GetMutex() );
     846         139 :         maFocusListeners.addInterface( rxListener );
     847         139 :         if ( maFocusListeners.getLength() == 1 )
     848         120 :             xPeerWindow = xPeerWindow.query( getPeer() );
     849             :     }
     850         139 :     if ( xPeerWindow.is() )
     851          44 :         xPeerWindow->addFocusListener( &maFocusListeners );
     852         139 : }
     853             : 
     854          47 : void UnoControl::removeFocusListener( const Reference< XFocusListener >& rxListener ) throw(RuntimeException, std::exception)
     855             : {
     856          47 :     Reference< XWindow > xPeerWindow;
     857             :     {
     858          47 :         ::osl::MutexGuard aGuard( GetMutex() );
     859          47 :         if ( maFocusListeners.getLength() == 1 )
     860          37 :             xPeerWindow = xPeerWindow.query( getPeer() );
     861          47 :         maFocusListeners.removeInterface( rxListener );
     862             :     }
     863          47 :     if ( xPeerWindow.is() )
     864          37 :         xPeerWindow->removeFocusListener( &maFocusListeners );
     865          47 : }
     866             : 
     867          77 : void UnoControl::addKeyListener( const Reference< XKeyListener >& rxListener ) throw(RuntimeException, std::exception)
     868             : {
     869          77 :     Reference< XWindow > xPeerWindow;
     870             :     {
     871          77 :         ::osl::MutexGuard aGuard( GetMutex() );
     872          77 :         maKeyListeners.addInterface( rxListener );
     873          77 :         if ( maKeyListeners.getLength() == 1 )
     874          68 :             xPeerWindow = xPeerWindow.query( getPeer() );
     875             :     }
     876          77 :     if ( xPeerWindow.is() )
     877           9 :         xPeerWindow->addKeyListener( &maKeyListeners);
     878          77 : }
     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 = xPeerWindow.query( getPeer() );
     887           2 :         maKeyListeners.removeInterface( rxListener );
     888             :     }
     889           2 :     if ( xPeerWindow.is() )
     890           1 :         xPeerWindow->removeKeyListener( &maKeyListeners);
     891           2 : }
     892             : 
     893          73 : void UnoControl::addMouseListener( const Reference< XMouseListener >& rxListener ) throw(RuntimeException, std::exception)
     894             : {
     895          73 :     Reference< XWindow > xPeerWindow;
     896             :     {
     897          73 :         ::osl::MutexGuard aGuard( GetMutex() );
     898          73 :         maMouseListeners.addInterface( rxListener );
     899          73 :         if ( maMouseListeners.getLength() == 1 )
     900          59 :             xPeerWindow = xPeerWindow.query( getPeer() );
     901             :     }
     902          73 :     if ( xPeerWindow.is() )
     903          49 :         xPeerWindow->addMouseListener( &maMouseListeners);
     904          73 : }
     905             : 
     906          47 : void UnoControl::removeMouseListener( const Reference< XMouseListener >& rxListener ) throw(RuntimeException, std::exception)
     907             : {
     908          47 :     Reference< XWindow > xPeerWindow;
     909             :     {
     910          47 :         ::osl::MutexGuard aGuard( GetMutex() );
     911          47 :         if ( maMouseListeners.getLength() == 1 )
     912          41 :             xPeerWindow = xPeerWindow.query( getPeer() );
     913          47 :         maMouseListeners.removeInterface( rxListener );
     914             :     }
     915          47 :     if ( xPeerWindow.is() )
     916          41 :         xPeerWindow->removeMouseListener( &maMouseListeners );
     917          47 : }
     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 = xPeerWindow.query( getPeer() );
     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 = xPeerWindow.query( getPeer() );
     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 = xPeerWindow.query( getPeer() );
     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 = xPeerWindow.query( getPeer() );
     965           0 :         maPaintListeners.removeInterface( rxListener );
     966             :     }
     967           0 :     if ( xPeerWindow.is() )
     968           0 :         xPeerWindow->removePaintListener( &maPaintListeners );
     969           0 : }
     970             : 
     971             : // XView
     972        5785 : sal_Bool UnoControl::setGraphics( const Reference< XGraphics >& rDevice ) throw(RuntimeException, std::exception)
     973             : {
     974        5785 :     Reference< XView > xView;
     975             :     {
     976        5785 :         ::osl::MutexGuard aGuard( GetMutex() );
     977             : 
     978        5785 :         mxGraphics = rDevice;
     979        5785 :         xView = xView.query( getPeer() );
     980             :     }
     981        5785 :     return xView.is() ? xView->setGraphics( rDevice ) : sal_True;
     982             : }
     983             : 
     984        2892 : Reference< XGraphics > UnoControl::getGraphics(  ) throw(RuntimeException, std::exception)
     985             : {
     986        2892 :     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        2793 : void UnoControl::draw( sal_Int32 x, sal_Int32 y ) throw(RuntimeException, std::exception)
     996             : {
     997        2793 :     Reference< XWindowPeer > xDrawPeer;
     998        5586 :     Reference< XView > xDrawPeerView;
     999             : 
    1000        2793 :     bool bDisposeDrawPeer( false );
    1001             :     {
    1002        2793 :         ::osl::MutexGuard aGuard( GetMutex() );
    1003             : 
    1004        2793 :         xDrawPeer = ImplGetCompatiblePeer( true );
    1005        2793 :         bDisposeDrawPeer = xDrawPeer.is() && ( xDrawPeer != getPeer() );
    1006             : 
    1007        2793 :         xDrawPeerView.set( xDrawPeer, UNO_QUERY );
    1008        2793 :         DBG_ASSERT( xDrawPeerView.is(), "UnoControl::draw: no peer!" );
    1009             :     }
    1010             : 
    1011        2793 :     if ( xDrawPeerView.is() )
    1012             :     {
    1013        2793 :         Reference< XVclWindowPeer > xWindowPeer;
    1014        2793 :         xWindowPeer.set( xDrawPeer, UNO_QUERY );
    1015        2793 :         if ( xWindowPeer.is() )
    1016        2793 :             xWindowPeer->setDesignMode( mbDesignMode );
    1017        2793 :         xDrawPeerView->draw( x, y );
    1018             :     }
    1019             : 
    1020        2793 :     if ( bDisposeDrawPeer )
    1021        2799 :         xDrawPeer->dispose();
    1022        2793 : }
    1023             : 
    1024       13523 : void UnoControl::setZoom( float fZoomX, float fZoomY ) throw(RuntimeException, std::exception)
    1025             : {
    1026       13523 :     Reference< XView > xView;
    1027             :     {
    1028       13523 :         ::osl::MutexGuard aGuard( GetMutex() );
    1029             : 
    1030       13523 :         maComponentInfos.nZoomX = fZoomX;
    1031       13523 :         maComponentInfos.nZoomY = fZoomY;
    1032             : 
    1033       13523 :         xView = xView.query( getPeer() );
    1034             :     }
    1035       13523 :     if ( xView.is() )
    1036       13309 :         xView->setZoom( fZoomX, fZoomY );
    1037       13523 : }
    1038             : 
    1039             : // XControl
    1040        1673 : void UnoControl::setContext( const Reference< XInterface >& rxContext ) throw(RuntimeException, std::exception)
    1041             : {
    1042        1673 :     ::osl::MutexGuard aGuard( GetMutex() );
    1043             : 
    1044        1673 :     mxContext = rxContext;
    1045        1673 : }
    1046             : 
    1047         572 : Reference< XInterface > UnoControl::getContext(  ) throw(RuntimeException, std::exception)
    1048             : {
    1049         572 :     ::osl::MutexGuard aGuard( GetMutex() );
    1050             : 
    1051         572 :     return mxContext;
    1052             : }
    1053             : 
    1054         358 : void UnoControl::peerCreated()
    1055             : {
    1056         358 :     Reference< XWindow > xWindow( getPeer(), UNO_QUERY );
    1057         358 :     if ( !xWindow.is() )
    1058         358 :         return;
    1059             : 
    1060         358 :     if ( maWindowListeners.getLength() )
    1061         154 :         xWindow->addWindowListener( &maWindowListeners );
    1062             : 
    1063         358 :     if ( maFocusListeners.getLength() )
    1064         103 :         xWindow->addFocusListener( &maFocusListeners );
    1065             : 
    1066         358 :     if ( maKeyListeners.getLength() )
    1067          84 :         xWindow->addKeyListener( &maKeyListeners );
    1068             : 
    1069         358 :     if ( maMouseListeners.getLength() )
    1070          10 :         xWindow->addMouseListener( &maMouseListeners );
    1071             : 
    1072         358 :     if ( maMouseMotionListeners.getLength() )
    1073           0 :         xWindow->addMouseMotionListener( &maMouseMotionListeners );
    1074             : 
    1075         358 :     if ( maPaintListeners.getLength() )
    1076           0 :         xWindow->addPaintListener( &maPaintListeners );
    1077             : }
    1078             : 
    1079         348 : void UnoControl::createPeer( const Reference< XToolkit >& rxToolkit, const Reference< XWindowPeer >& rParentPeer ) throw(RuntimeException, std::exception)
    1080             : {
    1081         348 :     ::osl::ClearableMutexGuard aGuard( GetMutex() );
    1082         348 :     if ( !mxModel.is() )
    1083             :     {
    1084           0 :         RuntimeException aException;
    1085           0 :         aException.Message = "createPeer: no model!";
    1086           0 :         aException.Context = (XAggregation*)(::cppu::OWeakAggObject*)this;
    1087           0 :         throw( aException );
    1088             :     }
    1089             : 
    1090         348 :     if( !getPeer().is() )
    1091             :     {
    1092         320 :         mbCreatingPeer = true;
    1093             : 
    1094             :         WindowClass eType;
    1095         320 :         Reference< XToolkit >  xToolkit = rxToolkit;
    1096         320 :         if( rParentPeer.is() && mxContext.is() )
    1097             :         {
    1098             :             // kein TopWindow
    1099         314 :             if ( !xToolkit.is() )
    1100         308 :                 xToolkit = rParentPeer->getToolkit();
    1101         314 :             Any aAny = OWeakAggObject::queryInterface( ::getCppuType((const Reference< XControlContainer>*)0) );
    1102         628 :             Reference< XControlContainer > xC;
    1103         314 :             aAny >>= xC;
    1104         314 :             if( xC.is() )
    1105             :                 // It's a container
    1106           0 :                 eType = WindowClass_CONTAINER;
    1107             :             else
    1108         628 :                 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         640 :         WindowDescriptor aDescr;
    1126         320 :         aDescr.Type = eType;
    1127         320 :         aDescr.WindowServiceName = GetComponentServiceName();
    1128         320 :         aDescr.Parent = rParentPeer;
    1129         320 :         aDescr.Bounds = getPosSize();
    1130         320 :         aDescr.WindowAttributes = 0;
    1131             : 
    1132             :         // Border
    1133         640 :         Reference< XPropertySet > xPSet( mxModel, UNO_QUERY );
    1134         640 :         Reference< XPropertySetInfo >  xInfo = xPSet->getPropertySetInfo();
    1135             : 
    1136         640 :         Any aVal;
    1137         640 :         OUString aPropName = GetPropertyName( BASEPROPERTY_BORDER );
    1138         320 :         if ( xInfo->hasPropertyByName( aPropName ) )
    1139             :         {
    1140         213 :             aVal = xPSet->getPropertyValue( aPropName );
    1141         213 :             sal_Int16 n = sal_Int16();
    1142         213 :             if ( aVal >>= n )
    1143             :             {
    1144         213 :                 if ( n )
    1145         210 :                     aDescr.WindowAttributes |= WindowAttribute::BORDER;
    1146             :                 else
    1147           3 :                     aDescr.WindowAttributes |= VclWindowPeerAttribute::NOBORDER;
    1148             :             }
    1149             :         }
    1150             : 
    1151             :         // DESKTOP_AS_PARENT
    1152         320 :         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         320 :         aPropName = GetPropertyName( BASEPROPERTY_MOVEABLE );
    1165         320 :         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         320 :         aPropName = GetPropertyName( BASEPROPERTY_CLOSEABLE );
    1175         320 :         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         320 :         aPropName = GetPropertyName( BASEPROPERTY_DROPDOWN );
    1185         320 :         if ( xInfo->hasPropertyByName( aPropName ) )
    1186             :         {
    1187          71 :             aVal = xPSet->getPropertyValue( aPropName );
    1188          71 :             bool b = bool();
    1189          71 :             if ( ( aVal >>= b ) && b)
    1190          27 :                 aDescr.WindowAttributes |= VclWindowPeerAttribute::DROPDOWN;
    1191             :         }
    1192             : 
    1193             :         // Spin
    1194         320 :         aPropName = GetPropertyName( BASEPROPERTY_SPIN );
    1195         320 :         if ( xInfo->hasPropertyByName( aPropName ) )
    1196             :         {
    1197          81 :             aVal = xPSet->getPropertyValue( aPropName );
    1198          81 :             bool b = bool();
    1199          81 :             if ( ( aVal >>= b ) && b)
    1200          25 :                 aDescr.WindowAttributes |= VclWindowPeerAttribute::SPIN;
    1201             :         }
    1202             : 
    1203             :         // HScroll
    1204         320 :         aPropName = GetPropertyName( BASEPROPERTY_HSCROLL );
    1205         320 :         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         320 :         aPropName = GetPropertyName( BASEPROPERTY_VSCROLL );
    1215         320 :         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         320 :         aPropName = GetPropertyName( BASEPROPERTY_AUTOHSCROLL );
    1225         320 :         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         320 :         aPropName = GetPropertyName( BASEPROPERTY_AUTOVSCROLL );
    1235         320 :         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         320 :         aPropName = GetPropertyName( BASEPROPERTY_NOLABEL );
    1246         320 :         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         320 :         aPropName = GetPropertyName( BASEPROPERTY_ALIGN );
    1257         320 :         if ( xInfo->hasPropertyByName( aPropName ) )
    1258             :         {
    1259         289 :             aVal = xPSet->getPropertyValue( aPropName );
    1260         289 :             sal_Int16 n = sal_Int16();
    1261         289 :             if ( aVal >>= n )
    1262             :             {
    1263         289 :                 if ( n == PROPERTY_ALIGN_LEFT )
    1264         212 :                     aDescr.WindowAttributes |= VclWindowPeerAttribute::LEFT;
    1265          77 :                 else if ( n == PROPERTY_ALIGN_CENTER )
    1266          77 :                     aDescr.WindowAttributes |= VclWindowPeerAttribute::CENTER;
    1267             :                 else
    1268           0 :                     aDescr.WindowAttributes |= VclWindowPeerAttribute::RIGHT;
    1269             :             }
    1270             :         }
    1271             : 
    1272             :         // Allow derivates to manipulate attributes
    1273         320 :         PrepareWindowDescriptor(aDescr);
    1274             : 
    1275             :         // create the peer
    1276         320 :         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 ususally
    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         320 :         UnoControlComponentInfos aComponentInfos(maComponentInfos);
    1288         320 :         bool bDesignMode(mbDesignMode);
    1289             : 
    1290         640 :         Reference< XGraphics >  xGraphics( mxGraphics           );
    1291         640 :         Reference< XView >      xView    ( getPeer(), UNO_QUERY_THROW );
    1292         640 :         Reference< XWindow >    xWindow  ( getPeer(), UNO_QUERY_THROW );
    1293             : 
    1294         320 :         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         320 :         updateFromModel();
    1301             : 
    1302         320 :         xView->setZoom( aComponentInfos.nZoomX, aComponentInfos.nZoomY );
    1303             : 
    1304         320 :         setPosSize( aComponentInfos.nX, aComponentInfos.nY, aComponentInfos.nWidth, aComponentInfos.nHeight, aComponentInfos.nFlags );
    1305             : 
    1306         320 :         if( aComponentInfos.bVisible && !bDesignMode )
    1307             :             // Show only after setting the data
    1308          48 :             xWindow->setVisible( aComponentInfos.bVisible );
    1309             : 
    1310         320 :         if( !aComponentInfos.bEnable )
    1311           0 :             xWindow->setEnable( aComponentInfos.bEnable );
    1312             : 
    1313         320 :         xView->setGraphics( xGraphics );
    1314             : 
    1315         320 :         peerCreated();
    1316             : 
    1317         640 :         mbCreatingPeer = false;
    1318         348 :     }
    1319         348 : }
    1320             : 
    1321       68916 : Reference< XWindowPeer > UnoControl::getPeer() throw(RuntimeException, std::exception)
    1322             : {
    1323       68916 :     ::osl::MutexGuard aGuard( GetMutex() );
    1324       68916 :     return mxPeer;
    1325             : }
    1326             : 
    1327        2344 : sal_Bool UnoControl::setModel( const Reference< XControlModel >& rxModel ) throw(RuntimeException, std::exception)
    1328             : {
    1329        2344 :     ::osl::MutexGuard aGuard( GetMutex() );
    1330             : 
    1331        4688 :     Reference< XMultiPropertySet > xPropSet( mxModel, UNO_QUERY );
    1332             : 
    1333             :     // query for the XPropertiesChangeListener - our delegator is allowed to overwrite this interface
    1334        4688 :     Reference< XPropertiesChangeListener > xListener;
    1335        2344 :     queryInterface( ::getCppuType( &xListener ) ) >>= xListener;
    1336             : 
    1337        2344 :     if( xPropSet.is() )
    1338        1131 :         xPropSet->removePropertiesChangeListener( xListener );
    1339             : 
    1340        2344 :     mpData->bLocalizationSupport = false;
    1341        2344 :     mxModel = rxModel;
    1342             : 
    1343        2344 :     if( mxModel.is() )
    1344             :     {
    1345             :         try
    1346             :         {
    1347        1150 :             xPropSet.set( mxModel, UNO_QUERY_THROW );
    1348        1150 :             Reference< XPropertySetInfo > xPSI( xPropSet->getPropertySetInfo(), UNO_SET_THROW );
    1349             : 
    1350        2300 :             Sequence< OUString> aNames = lcl_ImplGetPropertyNames( xPropSet );
    1351        1150 :             xPropSet->addPropertiesChangeListener( aNames, xListener );
    1352             : 
    1353        2300 :             mpData->bLocalizationSupport = xPSI->hasPropertyByName("ResourceResolver");
    1354             :         }
    1355           0 :         catch( const Exception& )
    1356             :         {
    1357             :             DBG_UNHANDLED_EXCEPTION();
    1358           0 :             mxModel.clear();
    1359             :         }
    1360             :     }
    1361             : 
    1362        4688 :     return mxModel.is();
    1363             : }
    1364             : 
    1365        8493 : Reference< XControlModel > UnoControl::getModel(    ) throw(RuntimeException, std::exception)
    1366             : {
    1367        8493 :     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         257 : void UnoControl::setDesignMode( sal_Bool bOn ) throw(RuntimeException, std::exception)
    1376             : {
    1377         257 :     ModeChangeEvent aModeChangeEvent;
    1378             : 
    1379         474 :     Reference< XWindow > xWindow;
    1380         474 :     Reference<XComponent> xAccessibleComp;
    1381             :     {
    1382         257 :         ::osl::MutexGuard aGuard( GetMutex() );
    1383         257 :         if ( bool(bOn) == mbDesignMode )
    1384         297 :             return;
    1385             : 
    1386             :         // remember this
    1387         217 :         mbDesignMode = bOn;
    1388         217 :         xWindow = xWindow.query( getPeer() );
    1389             : 
    1390         217 :         xAccessibleComp.set(maAccessibleContext, UNO_QUERY);
    1391         217 :         maAccessibleContext.clear();
    1392             : 
    1393         217 :         aModeChangeEvent.Source = *this;
    1394         217 :         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         217 :     DisposeAccessibleContext(xAccessibleComp);
    1401             : 
    1402             :     // adjust the visibility of our window
    1403         217 :     if ( xWindow.is() )
    1404          61 :         xWindow->setVisible( !bOn );
    1405             : 
    1406             :     // and notify our mode listeners
    1407         434 :     maModeChangeListeners.notifyEach( &XModeChangeListener::modeChanged, aModeChangeEvent );
    1408             : }
    1409             : 
    1410       12885 : sal_Bool UnoControl::isDesignMode(  ) throw(RuntimeException, std::exception)
    1411             : {
    1412       12885 :     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 overloaded!" );
    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           0 : Sequence< OUString > UnoControl::getSupportedServiceNames(  ) throw(RuntimeException, std::exception)
    1433             : {
    1434           0 :     OUString sName( "com.sun.star.awt.UnoControl" );
    1435           0 :     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         206 : void SAL_CALL UnoControl::addModeChangeListener( const Reference< XModeChangeListener >& _rxListener ) throw (RuntimeException, std::exception)
    1475             : {
    1476         206 :     ::osl::MutexGuard aGuard( GetMutex() );
    1477         206 :     maModeChangeListeners.addInterface( _rxListener );
    1478         206 : }
    1479             : 
    1480         206 : void SAL_CALL UnoControl::removeModeChangeListener( const Reference< XModeChangeListener >& _rxListener ) throw (RuntimeException, std::exception)
    1481             : {
    1482         206 :     ::osl::MutexGuard aGuard( GetMutex() );
    1483         206 :     maModeChangeListeners.removeInterface( _rxListener );
    1484         206 : }
    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 = xPeerConversion.query( getPeer() );
    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 = xPeerConversion.query( getPeer() );
    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 = xPeerConversion.query( getPeer() );
    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 = xPeerConversion.query( getPeer() );
    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 = xPeerSupplier.query( getPeer() );
    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.10