LCOV - code coverage report
Current view: top level - toolkit/source/controls - unocontrol.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 651 788 82.6 %
Date: 2014-11-03 Functions: 60 83 72.3 %
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        2981 : static Sequence< OUString> lcl_ImplGetPropertyNames( const Reference< XMultiPropertySet > & rxModel )
      80             : {
      81        2981 :     Sequence< OUString> aNames;
      82        5962 :     Reference< XPropertySetInfo >  xPSInf = rxModel->getPropertySetInfo();
      83             :     DBG_ASSERT( xPSInf.is(), "UpdateFromModel: No PropertySetInfo!" );
      84        2981 :     if ( xPSInf.is() )
      85             :     {
      86        2981 :         Sequence< Property> aProps = xPSInf->getProperties();
      87        2981 :         sal_Int32 nLen = aProps.getLength();
      88        2981 :         aNames = Sequence< OUString>( nLen );
      89        2981 :         OUString* pNames = aNames.getArray();
      90        2981 :         const Property* pProps = aProps.getConstArray();
      91      117545 :         for ( sal_Int32 n = 0; n < nLen; ++n, ++pProps, ++pNames)
      92      117545 :             *pNames = pProps->Name;
      93             :     }
      94        5962 :     return aNames;
      95             : }
      96             : 
      97             : 
      98             : class VclListenerLock: private boost::noncopyable
      99             : {
     100             : private:
     101             :     VCLXWindow*  m_pLockWindow;
     102             : 
     103             : public:
     104       10047 :     inline VclListenerLock( VCLXWindow* _pLockWindow )
     105       10047 :         :m_pLockWindow( _pLockWindow )
     106             :     {
     107       10047 :         if ( m_pLockWindow )
     108       10047 :             m_pLockWindow->suspendVclEventListening( );
     109       10047 :     }
     110       10047 :     inline ~VclListenerLock( )
     111             :     {
     112       10047 :         if ( m_pLockWindow )
     113       10047 :             m_pLockWindow->resumeVclEventListening( );
     114       10047 :     }
     115             : };
     116             : 
     117             : typedef ::std::map< OUString, sal_Int32 >    MapString2Int;
     118        2133 : struct UnoControl_Data
     119             : {
     120             :     MapString2Int   aSuspendedPropertyNotifications;
     121             :     /// true if and only if our model has a property ResourceResolver
     122             :     bool            bLocalizationSupport;
     123             : 
     124        2237 :     UnoControl_Data()
     125             :         :aSuspendedPropertyNotifications()
     126        2237 :         ,bLocalizationSupport( false )
     127             :     {
     128        2237 :     }
     129             : };
     130             : 
     131        2237 : UnoControl::UnoControl() :
     132             :       maDisposeListeners( *this )
     133             :     , maWindowListeners( *this )
     134             :     , maFocusListeners( *this )
     135             :     , maKeyListeners( *this )
     136             :     , maMouseListeners( *this )
     137             :     , maMouseMotionListeners( *this )
     138             :     , maPaintListeners( *this )
     139        2237 :     , maModeChangeListeners( GetMutex() )
     140        4474 :     , mpData( new UnoControl_Data )
     141             : {
     142        2237 :     mbDisposePeer = true;
     143        2237 :     mbRefeshingPeer = false;
     144        2237 :     mbCreatingPeer = false;
     145        2237 :     mbCreatingCompatiblePeer = false;
     146        2237 :     mbDesignMode = false;
     147        2237 : }
     148             : 
     149        4266 : UnoControl::~UnoControl()
     150             : {
     151        2133 :     DELETEZ( mpData );
     152        2133 : }
     153             : 
     154           0 : OUString UnoControl::GetComponentServiceName()
     155             : {
     156           0 :     return OUString();
     157             : }
     158             : 
     159        2809 : Reference< XWindowPeer >    UnoControl::ImplGetCompatiblePeer( bool bAcceptExistingPeer )
     160             : {
     161             :     DBG_ASSERT( !mbCreatingCompatiblePeer, "ImplGetCompatiblePeer - rekursive?" );
     162             : 
     163        2809 :     mbCreatingCompatiblePeer = true;
     164             : 
     165        2809 :     Reference< XWindowPeer > xCompatiblePeer;
     166             : 
     167        2809 :     if ( bAcceptExistingPeer )
     168        2809 :         xCompatiblePeer = getPeer();
     169             : 
     170        2809 :     if ( !xCompatiblePeer.is() )
     171             :     {
     172             :         // Create the pair as invisible
     173          11 :         bool bVis = maComponentInfos.bVisible;
     174          11 :         if( bVis )
     175          11 :             maComponentInfos.bVisible = false;
     176             : 
     177          11 :         Reference< XWindowPeer >    xCurrentPeer = getPeer();
     178          11 :         setPeer( NULL );
     179             : 
     180             :         // queryInterface ourself, to allow aggregation
     181          22 :         Reference< XControl > xMe;
     182          11 :         OWeakAggObject::queryInterface( ::getCppuType( &xMe ) ) >>= xMe;
     183             : 
     184          11 :         vcl::Window* pParentWindow( NULL );
     185             :         {
     186          11 :             SolarMutexGuard aGuard;
     187          11 :             pParentWindow = dynamic_cast< vcl::Window* >( Application::GetDefaultDevice() );
     188          11 :             ENSURE_OR_THROW( pParentWindow != NULL, "could obtain a default parent window!" );
     189             :         }
     190             :         try
     191             :         {
     192          11 :             xMe->createPeer( NULL, pParentWindow->GetComponentInterface( true ) );
     193             :         }
     194           0 :         catch( const Exception& )
     195             :         {
     196           0 :             mbCreatingCompatiblePeer = false;
     197           0 :             throw;
     198             :         }
     199          11 :         xCompatiblePeer = getPeer();
     200          11 :         setPeer( xCurrentPeer );
     201             : 
     202          11 :         if ( xCompatiblePeer.is() && mxGraphics.is() )
     203             :         {
     204          11 :             Reference< XView > xPeerView( xCompatiblePeer, UNO_QUERY );
     205          11 :             if ( xPeerView.is() )
     206          11 :                 xPeerView->setGraphics( mxGraphics );
     207             :         }
     208             : 
     209          11 :         if( bVis )
     210          22 :             maComponentInfos.bVisible = true;
     211             :     }
     212             : 
     213        2809 :     mbCreatingCompatiblePeer = false;
     214             : 
     215        2809 :     return xCompatiblePeer;
     216             : }
     217             : 
     218         746 : bool UnoControl::ImplCheckLocalize( OUString& _rPossiblyLocalizable )
     219             : {
     220        1492 :     if  (   !mpData->bLocalizationSupport
     221          46 :         ||  ( _rPossiblyLocalizable.isEmpty() )
     222         762 :         ||  ( _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         746 :         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       63245 : 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       63245 :     if ( mxVclWindowPeer.is() )
     257             :     {
     258       63245 :         Any aConvertedValue( rVal );
     259             : 
     260       63245 :         if ( mpData->bLocalizationSupport )
     261             :         {
     262             :             // We now support a mapping for language dependent properties. This is the
     263             :             // central method to implement it.
     264        3906 :             if( rPropName == "Text"            ||
     265        2598 :                 rPropName == "Label"           ||
     266        2584 :                 rPropName == "Title"           ||
     267        2554 :                 rPropName == "HelpText"        ||
     268        3834 :                 rPropName == "CurrencySymbol"  ||
     269        1266 :                 rPropName == "StringItemList"  )
     270             :             {
     271          36 :                 OUString aValue;
     272          72 :                 uno::Sequence< OUString > aSeqValue;
     273          36 :                 if ( aConvertedValue >>= aValue )
     274             :                 {
     275          36 :                     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          36 :                 }
     284             :             }
     285             :         }
     286             : 
     287       63245 :         mxVclWindowPeer->setProperty( rPropName, aConvertedValue );
     288             :     }
     289       63245 : }
     290             : 
     291         629 : void UnoControl::PrepareWindowDescriptor( WindowDescriptor& )
     292             : {
     293         629 : }
     294             : 
     295       10047 : Reference< XWindow >    UnoControl::getParentPeer() const
     296             : {
     297       10047 :     Reference< XWindow > xPeer;
     298       10047 :     if( mxContext.is() )
     299             :     {
     300        9983 :         Reference< XControl > xContComp( mxContext, UNO_QUERY );
     301        9983 :         if ( xContComp.is() )
     302             :         {
     303        9621 :             Reference< XWindowPeer > xP = xContComp->getPeer();
     304        9621 :             if ( xP.is() )
     305        9614 :                 xPeer.set( xP, UNO_QUERY );
     306        9983 :         }
     307             :     }
     308       10047 :     return xPeer;
     309             : }
     310             : 
     311         754 : void UnoControl::updateFromModel()
     312             : {
     313             :     // Read default properties and hand over to peer
     314         754 :     if( getPeer().is() )
     315             :     {
     316         754 :         Reference< XMultiPropertySet >  xPropSet( mxModel, UNO_QUERY );
     317         754 :         if( xPropSet.is() )
     318             :         {
     319         754 :             Sequence< OUString> aNames = lcl_ImplGetPropertyNames( xPropSet );
     320         754 :             xPropSet->firePropertiesChangeEvent( aNames, this );
     321         754 :         }
     322             :     }
     323         754 : }
     324             : 
     325             : 
     326             : // XTypeProvider
     327           0 : IMPL_IMPLEMENTATION_ID( UnoControl )
     328             : 
     329             : void
     330        2759 : UnoControl::DisposeAccessibleContext(Reference<XComponent> const& xContextComp)
     331             : {
     332        2759 :     if (xContextComp.is())
     333             :     {
     334             :         try
     335             :         {
     336          64 :             xContextComp->removeEventListener( this );
     337          64 :             xContextComp->dispose();
     338             :         }
     339           0 :         catch( const Exception& )
     340             :         {
     341             :             OSL_FAIL( "UnoControl::disposeAccessibleContext: could not dispose my AccessibleContext!" );
     342             :         }
     343             :     }
     344        2759 : }
     345             : 
     346        2308 : void UnoControl::dispose(  ) throw(RuntimeException, std::exception)
     347             : {
     348        2308 :     Reference< XWindowPeer > xPeer;
     349        4616 :     Reference<XComponent> xAccessibleComp;
     350             :     {
     351        2308 :         ::osl::MutexGuard aGuard( GetMutex() );
     352        2308 :         if( mbDisposePeer )
     353             :         {
     354         938 :             xPeer = mxPeer;
     355             :         }
     356        2308 :         setPeer( NULL );
     357        2308 :         xAccessibleComp.set(maAccessibleContext, UNO_QUERY);
     358        2308 :         maAccessibleContext.clear();
     359             :     }
     360        2308 :     if( xPeer.is() )
     361             :     {
     362         428 :         xPeer->dispose();
     363             :     }
     364             : 
     365             :     // dispose our AccessibleContext - without Mutex locked
     366        2308 :     DisposeAccessibleContext(xAccessibleComp);
     367             : 
     368        4616 :     EventObject aDisposeEvent;
     369        2308 :     aDisposeEvent.Source = static_cast< XAggregation* >( this );
     370             : 
     371        2308 :     maDisposeListeners.disposeAndClear( aDisposeEvent );
     372        2308 :     maWindowListeners.disposeAndClear( aDisposeEvent );
     373        2308 :     maFocusListeners.disposeAndClear( aDisposeEvent );
     374        2308 :     maKeyListeners.disposeAndClear( aDisposeEvent );
     375        2308 :     maMouseListeners.disposeAndClear( aDisposeEvent );
     376        2308 :     maMouseMotionListeners.disposeAndClear( aDisposeEvent );
     377        2308 :     maPaintListeners.disposeAndClear( aDisposeEvent );
     378        2308 :     maModeChangeListeners.disposeAndClear( aDisposeEvent );
     379             : 
     380             :     // release Model again
     381        2308 :     setModel( Reference< XControlModel > () );
     382        4616 :     setContext( Reference< XInterface > () );
     383        2308 : }
     384             : 
     385         180 : void UnoControl::addEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException, std::exception)
     386             : {
     387         180 :     ::osl::MutexGuard aGuard( GetMutex() );
     388             : 
     389         180 :     maDisposeListeners.addInterface( rxListener );
     390         180 : }
     391             : 
     392         166 : void UnoControl::removeEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException, std::exception)
     393             : {
     394         166 :     ::osl::MutexGuard aGuard( GetMutex() );
     395             : 
     396         166 :     maDisposeListeners.removeInterface( rxListener );
     397         166 : }
     398             : 
     399        2493 : bool UnoControl::requiresNewPeer( const OUString& /* _rPropertyName */ ) const
     400             : {
     401        2493 :     return false;
     402             : }
     403             : 
     404             : // XPropertiesChangeListener
     405       10651 : void UnoControl::propertiesChange( const Sequence< PropertyChangeEvent >& rEvents ) throw(RuntimeException, std::exception)
     406             : {
     407       10651 :     Sequence< PropertyChangeEvent > aEvents( rEvents );
     408             :     {
     409       10651 :         ::osl::MutexGuard aGuard( GetMutex() );
     410             : 
     411       10651 :         if ( !mpData->aSuspendedPropertyNotifications.empty() )
     412             :         {
     413             :             // strip the property which we are currently updating (somewhere up the stack)
     414         170 :             PropertyChangeEvent* pEvents = aEvents.getArray();
     415         170 :             PropertyChangeEvent* pEventsEnd = pEvents + aEvents.getLength();
     416         516 :             for ( ; pEvents < pEventsEnd; )
     417         176 :                 if ( mpData->aSuspendedPropertyNotifications.find( pEvents->PropertyName ) != mpData->aSuspendedPropertyNotifications.end() )
     418             :                 {
     419         176 :                     if ( pEvents != pEventsEnd )
     420         176 :                         ::std::copy( pEvents + 1, pEventsEnd, pEvents );
     421         176 :                     --pEventsEnd;
     422             :                 }
     423             :                 else
     424           0 :                     ++pEvents;
     425         170 :             aEvents.realloc( pEventsEnd - aEvents.getConstArray() );
     426             : 
     427         170 :             if ( !aEvents.getLength() )
     428       10821 :                 return;
     429       10481 :         }
     430             :     }
     431             : 
     432       10481 :     ImplModelPropertiesChanged( aEvents );
     433             : }
     434             : 
     435        1200 : void UnoControl::ImplLockPropertyChangeNotification( const OUString& rPropertyName, bool bLock )
     436             : {
     437        1200 :     MapString2Int::iterator pos = mpData->aSuspendedPropertyNotifications.find( rPropertyName );
     438        1200 :     if ( bLock )
     439             :     {
     440         600 :         if ( pos == mpData->aSuspendedPropertyNotifications.end() )
     441         600 :             pos = mpData->aSuspendedPropertyNotifications.insert( MapString2Int::value_type( rPropertyName, 0 ) ).first;
     442         600 :         ++pos->second;
     443             :     }
     444             :     else
     445             :     {
     446             :         OSL_ENSURE( pos != mpData->aSuspendedPropertyNotifications.end(), "UnoControl::ImplLockPropertyChangeNotification: property not locked!" );
     447         600 :         if ( pos != mpData->aSuspendedPropertyNotifications.end() )
     448             :         {
     449             :             OSL_ENSURE( pos->second > 0, "UnoControl::ImplLockPropertyChangeNotification: invalid suspension counter!" );
     450         600 :             if ( 0 == --pos->second )
     451         600 :                 mpData->aSuspendedPropertyNotifications.erase( pos );
     452             :         }
     453             :     }
     454        1200 : }
     455             : 
     456          24 : void UnoControl::ImplLockPropertyChangeNotifications( const Sequence< OUString >& rPropertyNames, bool bLock )
     457             : {
     458         144 :     for (   const OUString* pPropertyName = rPropertyNames.getConstArray();
     459          72 :             pPropertyName != rPropertyNames.getConstArray() + rPropertyNames.getLength();
     460             :             ++pPropertyName
     461             :         )
     462          48 :         ImplLockPropertyChangeNotification( *pPropertyName, bLock );
     463          24 : }
     464             : 
     465       10481 : void UnoControl::ImplModelPropertiesChanged( const Sequence< PropertyChangeEvent >& rEvents )
     466             : {
     467       10481 :     ::osl::ClearableGuard< ::osl::Mutex > aGuard( GetMutex() );
     468             : 
     469       10481 :     if( getPeer().is() )
     470             :     {
     471       10047 :         std::vector< PropertyValue > aPeerPropertiesToSet;
     472       10047 :         sal_Int32               nIndependentPos = 0;
     473       10047 :         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       10047 :         bool bNeedNewPeer = false;
     478             :             // some properties require a re-creation of the peer, 'cause they can't be changed on the fly
     479             : 
     480       20094 :         Reference< XControlModel > xOwnModel( getModel(), UNO_QUERY );
     481             :             // our own model for comparison
     482       20094 :         Reference< XPropertySet > xPS( xOwnModel, UNO_QUERY );
     483       20094 :         Reference< XPropertySetInfo > xPSI( xPS->getPropertySetInfo(), UNO_QUERY );
     484             :         OSL_ENSURE( xPSI.is(), "UnoControl::ImplModelPropertiesChanged: should have property set meta data!" );
     485             : 
     486       10047 :         const PropertyChangeEvent* pEvents = rEvents.getConstArray();
     487             : 
     488       10047 :         sal_Int32 nLen = rEvents.getLength();
     489       10047 :         aPeerPropertiesToSet.reserve(nLen);
     490             : 
     491       74542 :         for( sal_Int32 i = 0; i < nLen; ++i, ++pEvents )
     492             :         {
     493       64812 :             Reference< XControlModel > xModel( pEvents->Source, UNO_QUERY );
     494       64812 :             bool bOwnModel = xModel.get() == xOwnModel.get();
     495       64812 :             if ( !bOwnModel )
     496          54 :                 continue;
     497             : 
     498             :             // Detect changes on our resource resolver which invalidates
     499             :             // automatically some language dependent properties.
     500       64758 :             if ( pEvents->PropertyName == "ResourceResolver" )
     501             :             {
     502          22 :                 Reference< resource::XStringResourceResolver > xStrResolver;
     503          22 :                 if ( pEvents->NewValue >>= xStrResolver )
     504          22 :                     bResourceResolverSet = xStrResolver.is();
     505             :             }
     506             : 
     507       64758 :             sal_uInt16 nPType = GetPropertyId( pEvents->PropertyName );
     508       64758 :             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       10175 :                 if ( nPType )
     514             :                     bNeedNewPeer = ( nPType == BASEPROPERTY_BORDER )
     515        7613 :                                 || ( nPType == BASEPROPERTY_MULTILINE )
     516        7557 :                                 || ( nPType == BASEPROPERTY_DROPDOWN )
     517        7491 :                                 || ( nPType == BASEPROPERTY_HSCROLL )
     518        7475 :                                 || ( nPType == BASEPROPERTY_VSCROLL )
     519        7459 :                                 || ( nPType == BASEPROPERTY_AUTOHSCROLL )
     520        7459 :                                 || ( nPType == BASEPROPERTY_AUTOVSCROLL )
     521        7459 :                                 || ( nPType == BASEPROPERTY_ORIENTATION )
     522        7459 :                                 || ( nPType == BASEPROPERTY_SPIN )
     523        7389 :                                 || ( nPType == BASEPROPERTY_ALIGN )
     524       15063 :                                 || ( nPType == BASEPROPERTY_PAINTTRANSPARENT );
     525             :                 else
     526        2493 :                     bNeedNewPeer = requiresNewPeer( pEvents->PropertyName );
     527             : 
     528       10175 :                 if ( bNeedNewPeer )
     529         317 :                     break;
     530             :             }
     531             : 
     532       64441 :             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         918 :                 aPeerPropertiesToSet.push_back(PropertyValue(pEvents->PropertyName, 0, pEvents->NewValue, PropertyState_DIRECT_VALUE));
     538             :             }
     539             :             else
     540             :             {
     541       63523 :                 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       63523 :                 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         923 :                         PropertyValue( pEvents->PropertyName, 0, pEvents->NewValue, PropertyState_DIRECT_VALUE ) );
     564         923 :                     ++nIndependentPos;
     565             :                 }
     566             :                 else
     567             :                 {
     568      125200 :                     aPeerPropertiesToSet.insert(aPeerPropertiesToSet.begin() + nIndependentPos,
     569      187800 :                         PropertyValue(pEvents->PropertyName, 0, pEvents->NewValue, PropertyState_DIRECT_VALUE));
     570       62600 :                     ++nIndependentPos;
     571             :                 }
     572             :             }
     573       64441 :         }
     574             : 
     575       20094 :         Reference< XWindow >    xParent = getParentPeer();
     576       20094 :         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       10047 :         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       10047 :         aGuard.clear();
     616             : 
     617             :         // clear the guard before creating a new peer - as usual, our peer implementations use the SolarMutex
     618             : 
     619       10047 :         if (bNeedNewPeer && xParent.is())
     620             :         {
     621         315 :             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         315 :             getPeer()->dispose();
     628         315 :             mxPeer.clear();
     629         315 :             mxVclWindowPeer = NULL;
     630         315 :             mbRefeshingPeer = true;
     631         630 :             Reference< XWindowPeer >    xP( xParent, UNO_QUERY );
     632         315 :             xThis->createPeer( Reference< XToolkit > (), xP );
     633         315 :             mbRefeshingPeer = false;
     634         630 :             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       10047 :         vcl::Window* pVclPeer = VCLUnoHelper::GetWindow( getPeer() );
     644       10047 :         VCLXWindow* pPeer = pVclPeer ? pVclPeer->GetWindowPeer() : NULL;
     645       20094 :         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       10047 :         std::vector< PropertyValue >::iterator aEnd = aPeerPropertiesToSet.end();
     651       74176 :         for (   std::vector< PropertyValue >::iterator aLoop = aPeerPropertiesToSet.begin();
     652             :                 aLoop != aEnd;
     653             :                 ++aLoop
     654             :             )
     655             :         {
     656       64129 :             ImplSetPeerProperty( aLoop->Name, aLoop->Value );
     657       10047 :         }
     658       10481 :     }
     659       10481 : }
     660             : 
     661        1572 : void UnoControl::disposing( const EventObject& rEvt ) throw(RuntimeException, std::exception)
     662             : {
     663        1572 :     ::osl::ClearableMutexGuard aGuard( GetMutex() );
     664             :     // do not compare differing types in case of multible inheritance
     665             : 
     666        1572 :     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        1572 :     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         167 :         Reference< XControl >  xThis = this;
     675             : 
     676         167 :         aGuard.clear();
     677         167 :         xThis->dispose();
     678             : 
     679             :         DBG_ASSERT( !mxModel.is(), "UnoControl::disposing: invalid dispose behaviour!" );
     680         167 :         mxModel.clear();
     681        1572 :     }
     682        1572 : }
     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        5203 :     RETVALTYPE lcl_askPeer( const uno::Reference< awt::XWindowPeer >& _rxPeer, RETVALTYPE (SAL_CALL XWindow2::*_pMethod)(), DEFAULTTYPE _aDefault )
     701             :     {
     702        5203 :         RETVALTYPE aReturn( _aDefault );
     703             : 
     704        5203 :         Reference< XWindow2 > xPeerWindow( _rxPeer, UNO_QUERY );
     705        5203 :         if ( xPeerWindow.is() )
     706        5176 :             aReturn = (xPeerWindow.get()->*_pMethod)();
     707             : 
     708        5203 :         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        5203 : sal_Bool SAL_CALL UnoControl::isVisible(  ) throw (RuntimeException, std::exception)
     718             : {
     719        5203 :     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        1583 : void UnoControl::setPosSize( sal_Int32 X, sal_Int32 Y, sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags ) throw(RuntimeException, std::exception)
     739             : {
     740        1583 :     Reference< XWindow > xWindow;
     741             :     {
     742        1583 :         ::osl::MutexGuard aGuard( GetMutex() );
     743             : 
     744        1583 :         if ( Flags & awt::PosSize::X )
     745        1569 :             maComponentInfos.nX = X;
     746        1583 :         if ( Flags & awt::PosSize::Y )
     747        1569 :             maComponentInfos.nY = Y;
     748        1583 :         if ( Flags & awt::PosSize::WIDTH )
     749        1571 :             maComponentInfos.nWidth = Width;
     750        1583 :         if ( Flags & awt::PosSize::HEIGHT )
     751        1571 :             maComponentInfos.nHeight = Height;
     752        1583 :         maComponentInfos.nFlags |= Flags;
     753             : 
     754        1583 :         xWindow.set(getPeer(), css::uno::UNO_QUERY);
     755             :     }
     756             : 
     757        1583 :     if( xWindow.is() )
     758         945 :         xWindow->setPosSize( X, Y, Width, Height, Flags );
     759        1583 : }
     760             : 
     761       16012 : awt::Rectangle UnoControl::getPosSize(  ) throw(RuntimeException, std::exception)
     762             : {
     763       16012 :     awt::Rectangle aRect( maComponentInfos.nX, maComponentInfos.nY, maComponentInfos.nWidth, maComponentInfos.nHeight);
     764       16012 :     Reference< XWindow > xWindow;
     765             : 
     766             :     {
     767       16012 :         ::osl::MutexGuard aGuard( GetMutex() );
     768       16012 :         xWindow.set(getPeer(), css::uno::UNO_QUERY);
     769             :     }
     770             : 
     771       16012 :     if( xWindow.is() )
     772       14948 :         aRect = xWindow->getPosSize();
     773       16012 :     return aRect;
     774             : }
     775             : 
     776         118 : void UnoControl::setVisible( sal_Bool bVisible ) throw(RuntimeException, std::exception)
     777             : {
     778         118 :     Reference< XWindow > xWindow;
     779             :     {
     780         118 :         ::osl::MutexGuard aGuard( GetMutex() );
     781             : 
     782             :         // Visible status is handled by View
     783         118 :         maComponentInfos.bVisible = bVisible;
     784         118 :         xWindow.set(getPeer(), css::uno::UNO_QUERY);
     785             :     }
     786         118 :     if ( xWindow.is() )
     787           4 :         xWindow->setVisible( bVisible );
     788         118 : }
     789             : 
     790          10 : void UnoControl::setEnable( sal_Bool bEnable ) throw(RuntimeException, std::exception)
     791             : {
     792          10 :     Reference< XWindow > xWindow;
     793             :     {
     794          10 :         ::osl::MutexGuard aGuard( GetMutex() );
     795             : 
     796             :         // Enable status is handled by View
     797          10 :         maComponentInfos.bEnable = bEnable;
     798          10 :         xWindow.set(getPeer(), css::uno::UNO_QUERY);
     799             :     }
     800          10 :     if ( xWindow.is() )
     801           8 :         xWindow->setEnable( bEnable );
     802          10 : }
     803             : 
     804           2 : void UnoControl::setFocus(  ) throw(RuntimeException, std::exception)
     805             : {
     806           2 :     Reference< XWindow > xWindow;
     807             :     {
     808           2 :         ::osl::MutexGuard aGuard( GetMutex() );
     809           2 :         xWindow.set(getPeer(), css::uno::UNO_QUERY);
     810             :     }
     811           2 :     if ( xWindow.is() )
     812           2 :         xWindow->setFocus();
     813           2 : }
     814             : 
     815         423 : void UnoControl::addWindowListener( const Reference< XWindowListener >& rxListener ) throw(RuntimeException, std::exception)
     816             : {
     817         423 :     Reference< XWindow > xPeerWindow;
     818             :     {
     819         423 :         ::osl::MutexGuard aGuard( GetMutex() );
     820         423 :         maWindowListeners.addInterface( rxListener );
     821         423 :         if ( maWindowListeners.getLength() == 1 )
     822         419 :             xPeerWindow.set(getPeer(), css::uno::UNO_QUERY);
     823             :     }
     824         423 :     if ( xPeerWindow.is() )
     825         410 :         xPeerWindow->addWindowListener( &maWindowListeners );
     826         423 : }
     827             : 
     828         415 : void UnoControl::removeWindowListener( const Reference< XWindowListener >& rxListener ) throw(RuntimeException, std::exception)
     829             : {
     830         415 :     Reference< XWindow > xPeerWindow;
     831             :     {
     832         415 :         ::osl::MutexGuard aGuard( GetMutex() );
     833         415 :         if ( maWindowListeners.getLength() == 1 )
     834         409 :             xPeerWindow.set(getPeer(), css::uno::UNO_QUERY);
     835         415 :         maWindowListeners.removeInterface( rxListener );
     836             :     }
     837         415 :     if ( xPeerWindow.is() )
     838         400 :         xPeerWindow->removeWindowListener( &maWindowListeners );
     839         415 : }
     840             : 
     841         282 : void UnoControl::addFocusListener( const Reference< XFocusListener >& rxListener ) throw(RuntimeException, std::exception)
     842             : {
     843         282 :     Reference< XWindow > xPeerWindow;
     844             :     {
     845         282 :         ::osl::MutexGuard aGuard( GetMutex() );
     846         282 :         maFocusListeners.addInterface( rxListener );
     847         282 :         if ( maFocusListeners.getLength() == 1 )
     848         244 :             xPeerWindow.set(getPeer(), css::uno::UNO_QUERY);
     849             :     }
     850         282 :     if ( xPeerWindow.is() )
     851          92 :         xPeerWindow->addFocusListener( &maFocusListeners );
     852         282 : }
     853             : 
     854          98 : void UnoControl::removeFocusListener( const Reference< XFocusListener >& rxListener ) throw(RuntimeException, std::exception)
     855             : {
     856          98 :     Reference< XWindow > xPeerWindow;
     857             :     {
     858          98 :         ::osl::MutexGuard aGuard( GetMutex() );
     859          98 :         if ( maFocusListeners.getLength() == 1 )
     860          78 :             xPeerWindow.set(getPeer(), css::uno::UNO_QUERY);
     861          98 :         maFocusListeners.removeInterface( rxListener );
     862             :     }
     863          98 :     if ( xPeerWindow.is() )
     864          78 :         xPeerWindow->removeFocusListener( &maFocusListeners );
     865          98 : }
     866             : 
     867         154 : void UnoControl::addKeyListener( const Reference< XKeyListener >& rxListener ) throw(RuntimeException, std::exception)
     868             : {
     869         154 :     Reference< XWindow > xPeerWindow;
     870             :     {
     871         154 :         ::osl::MutexGuard aGuard( GetMutex() );
     872         154 :         maKeyListeners.addInterface( rxListener );
     873         154 :         if ( maKeyListeners.getLength() == 1 )
     874         136 :             xPeerWindow.set(getPeer(), css::uno::UNO_QUERY);
     875             :     }
     876         154 :     if ( xPeerWindow.is() )
     877          18 :         xPeerWindow->addKeyListener( &maKeyListeners);
     878         154 : }
     879             : 
     880           4 : void UnoControl::removeKeyListener( const Reference< XKeyListener >& rxListener ) throw(RuntimeException, std::exception)
     881             : {
     882           4 :     Reference< XWindow > xPeerWindow;
     883             :     {
     884           4 :         ::osl::MutexGuard aGuard( GetMutex() );
     885           4 :         if ( maKeyListeners.getLength() == 1 )
     886           2 :             xPeerWindow.set(getPeer(), css::uno::UNO_QUERY);
     887           4 :         maKeyListeners.removeInterface( rxListener );
     888             :     }
     889           4 :     if ( xPeerWindow.is() )
     890           2 :         xPeerWindow->removeKeyListener( &maKeyListeners);
     891           4 : }
     892             : 
     893         150 : void UnoControl::addMouseListener( const Reference< XMouseListener >& rxListener ) throw(RuntimeException, std::exception)
     894             : {
     895         150 :     Reference< XWindow > xPeerWindow;
     896             :     {
     897         150 :         ::osl::MutexGuard aGuard( GetMutex() );
     898         150 :         maMouseListeners.addInterface( rxListener );
     899         150 :         if ( maMouseListeners.getLength() == 1 )
     900         122 :             xPeerWindow.set(getPeer(), css::uno::UNO_QUERY);
     901             :     }
     902         150 :     if ( xPeerWindow.is() )
     903         102 :         xPeerWindow->addMouseListener( &maMouseListeners);
     904         150 : }
     905             : 
     906          98 : void UnoControl::removeMouseListener( const Reference< XMouseListener >& rxListener ) throw(RuntimeException, std::exception)
     907             : {
     908          98 :     Reference< XWindow > xPeerWindow;
     909             :     {
     910          98 :         ::osl::MutexGuard aGuard( GetMutex() );
     911          98 :         if ( maMouseListeners.getLength() == 1 )
     912          86 :             xPeerWindow.set(getPeer(), css::uno::UNO_QUERY);
     913          98 :         maMouseListeners.removeInterface( rxListener );
     914             :     }
     915          98 :     if ( xPeerWindow.is() )
     916          86 :         xPeerWindow->removeMouseListener( &maMouseListeners );
     917          98 : }
     918             : 
     919          36 : void UnoControl::addMouseMotionListener( const Reference< XMouseMotionListener >& rxListener ) throw(RuntimeException, std::exception)
     920             : {
     921          36 :     Reference< XWindow > xPeerWindow;
     922             :     {
     923          36 :         ::osl::MutexGuard aGuard( GetMutex() );
     924          36 :         maMouseMotionListeners.addInterface( rxListener );
     925          36 :         if ( maMouseMotionListeners.getLength() == 1 )
     926          18 :             xPeerWindow.set(getPeer(), css::uno::UNO_QUERY);
     927             :     }
     928          36 :     if ( xPeerWindow.is() )
     929          18 :         xPeerWindow->addMouseMotionListener( &maMouseMotionListeners);
     930          36 : }
     931             : 
     932           4 : void UnoControl::removeMouseMotionListener( const Reference< XMouseMotionListener >& rxListener ) throw(RuntimeException, std::exception)
     933             : {
     934           4 :     Reference< XWindow > xPeerWindow;
     935             :     {
     936           4 :         ::osl::MutexGuard aGuard( GetMutex() );
     937           4 :         if ( maMouseMotionListeners.getLength() == 1 )
     938           2 :             xPeerWindow.set(getPeer(), css::uno::UNO_QUERY);
     939           4 :         maMouseMotionListeners.removeInterface( rxListener );
     940             :     }
     941           4 :     if ( xPeerWindow.is() )
     942           2 :         xPeerWindow->removeMouseMotionListener( &maMouseMotionListeners );
     943           4 : }
     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        5894 : sal_Bool UnoControl::setGraphics( const Reference< XGraphics >& rDevice ) throw(RuntimeException, std::exception)
     973             : {
     974        5894 :     Reference< XView > xView;
     975             :     {
     976        5894 :         ::osl::MutexGuard aGuard( GetMutex() );
     977             : 
     978        5894 :         mxGraphics = rDevice;
     979        5894 :         xView.set(getPeer(), css::uno::UNO_QUERY);
     980             :     }
     981        5894 :     return xView.is() ? xView->setGraphics( rDevice ) : sal_True;
     982             : }
     983             : 
     984        2946 : Reference< XGraphics > UnoControl::getGraphics(  ) throw(RuntimeException, std::exception)
     985             : {
     986        2946 :     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        2593 : void UnoControl::draw( sal_Int32 x, sal_Int32 y ) throw(RuntimeException, std::exception)
     996             : {
     997        2593 :     Reference< XWindowPeer > xDrawPeer;
     998        5186 :     Reference< XView > xDrawPeerView;
     999             : 
    1000        2593 :     bool bDisposeDrawPeer( false );
    1001             :     {
    1002        2593 :         ::osl::MutexGuard aGuard( GetMutex() );
    1003             : 
    1004        2593 :         xDrawPeer = ImplGetCompatiblePeer( true );
    1005        2593 :         bDisposeDrawPeer = xDrawPeer.is() && ( xDrawPeer != getPeer() );
    1006             : 
    1007        2593 :         xDrawPeerView.set( xDrawPeer, UNO_QUERY );
    1008        2593 :         DBG_ASSERT( xDrawPeerView.is(), "UnoControl::draw: no peer!" );
    1009             :     }
    1010             : 
    1011        2593 :     if ( xDrawPeerView.is() )
    1012             :     {
    1013        2593 :         Reference< XVclWindowPeer > xWindowPeer;
    1014        2593 :         xWindowPeer.set( xDrawPeer, UNO_QUERY );
    1015        2593 :         if ( xWindowPeer.is() )
    1016        2593 :             xWindowPeer->setDesignMode( mbDesignMode );
    1017        2593 :         xDrawPeerView->draw( x, y );
    1018             :     }
    1019             : 
    1020        2593 :     if ( bDisposeDrawPeer )
    1021        2604 :         xDrawPeer->dispose();
    1022        2593 : }
    1023             : 
    1024       15367 : void UnoControl::setZoom( float fZoomX, float fZoomY ) throw(RuntimeException, std::exception)
    1025             : {
    1026       15367 :     Reference< XView > xView;
    1027             :     {
    1028       15367 :         ::osl::MutexGuard aGuard( GetMutex() );
    1029             : 
    1030       15367 :         maComponentInfos.nZoomX = fZoomX;
    1031       15367 :         maComponentInfos.nZoomY = fZoomY;
    1032             : 
    1033       15367 :         xView.set(getPeer(), css::uno::UNO_QUERY);
    1034             :     }
    1035       15367 :     if ( xView.is() )
    1036       14942 :         xView->setZoom( fZoomX, fZoomY );
    1037       15367 : }
    1038             : 
    1039             : // XControl
    1040        3276 : void UnoControl::setContext( const Reference< XInterface >& rxContext ) throw(RuntimeException, std::exception)
    1041             : {
    1042        3276 :     ::osl::MutexGuard aGuard( GetMutex() );
    1043             : 
    1044        3276 :     mxContext = rxContext;
    1045        3276 : }
    1046             : 
    1047        1428 : Reference< XInterface > UnoControl::getContext(  ) throw(RuntimeException, std::exception)
    1048             : {
    1049        1428 :     ::osl::MutexGuard aGuard( GetMutex() );
    1050             : 
    1051        1428 :     return mxContext;
    1052             : }
    1053             : 
    1054         713 : void UnoControl::peerCreated()
    1055             : {
    1056         713 :     Reference< XWindow > xWindow( getPeer(), UNO_QUERY );
    1057         713 :     if ( !xWindow.is() )
    1058         713 :         return;
    1059             : 
    1060         713 :     if ( maWindowListeners.getLength() )
    1061         305 :         xWindow->addWindowListener( &maWindowListeners );
    1062             : 
    1063         713 :     if ( maFocusListeners.getLength() )
    1064         206 :         xWindow->addFocusListener( &maFocusListeners );
    1065             : 
    1066         713 :     if ( maKeyListeners.getLength() )
    1067         168 :         xWindow->addKeyListener( &maKeyListeners );
    1068             : 
    1069         713 :     if ( maMouseListeners.getLength() )
    1070          20 :         xWindow->addMouseListener( &maMouseListeners );
    1071             : 
    1072         713 :     if ( maMouseMotionListeners.getLength() )
    1073           0 :         xWindow->addMouseMotionListener( &maMouseMotionListeners );
    1074             : 
    1075         713 :     if ( maPaintListeners.getLength() )
    1076           0 :         xWindow->addPaintListener( &maPaintListeners );
    1077             : }
    1078             : 
    1079         693 : void UnoControl::createPeer( const Reference< XToolkit >& rxToolkit, const Reference< XWindowPeer >& rParentPeer ) throw(RuntimeException, std::exception)
    1080             : {
    1081         693 :     ::osl::ClearableMutexGuard aGuard( GetMutex() );
    1082         693 :     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         693 :     if( !getPeer().is() )
    1091             :     {
    1092         637 :         mbCreatingPeer = true;
    1093             : 
    1094             :         WindowClass eType;
    1095         637 :         Reference< XToolkit >  xToolkit = rxToolkit;
    1096         637 :         if( rParentPeer.is() && mxContext.is() )
    1097             :         {
    1098             :             // kein TopWindow
    1099         625 :             if ( !xToolkit.is() )
    1100         613 :                 xToolkit = rParentPeer->getToolkit();
    1101         625 :             Any aAny = OWeakAggObject::queryInterface( cppu::UnoType<XControlContainer>::get());
    1102        1250 :             Reference< XControlContainer > xC;
    1103         625 :             aAny >>= xC;
    1104         625 :             if( xC.is() )
    1105             :                 // It's a container
    1106           0 :                 eType = WindowClass_CONTAINER;
    1107             :             else
    1108        1250 :                 eType = WindowClass_SIMPLE;
    1109             :         }
    1110             :         else
    1111             :         { // This is only correct for Top Window
    1112          12 :             if( rParentPeer.is() )
    1113             :             {
    1114           8 :                 if ( !xToolkit.is() )
    1115           4 :                     xToolkit = rParentPeer->getToolkit();
    1116           8 :                 eType = WindowClass_CONTAINER;
    1117             :             }
    1118             :             else
    1119             :             {
    1120           4 :                 if ( !xToolkit.is() )
    1121           2 :                     xToolkit = VCLUnoHelper::CreateToolkit();
    1122           4 :                 eType = WindowClass_TOP;
    1123             :             }
    1124             :         }
    1125        1274 :         WindowDescriptor aDescr;
    1126         637 :         aDescr.Type = eType;
    1127         637 :         aDescr.WindowServiceName = GetComponentServiceName();
    1128         637 :         aDescr.Parent = rParentPeer;
    1129         637 :         aDescr.Bounds = getPosSize();
    1130         637 :         aDescr.WindowAttributes = 0;
    1131             : 
    1132             :         // Border
    1133        1274 :         Reference< XPropertySet > xPSet( mxModel, UNO_QUERY );
    1134        1274 :         Reference< XPropertySetInfo >  xInfo = xPSet->getPropertySetInfo();
    1135             : 
    1136        1274 :         Any aVal;
    1137        1274 :         OUString aPropName = GetPropertyName( BASEPROPERTY_BORDER );
    1138         637 :         if ( xInfo->hasPropertyByName( aPropName ) )
    1139             :         {
    1140         428 :             aVal = xPSet->getPropertyValue( aPropName );
    1141         428 :             sal_Int16 n = sal_Int16();
    1142         428 :             if ( aVal >>= n )
    1143             :             {
    1144         428 :                 if ( n )
    1145         422 :                     aDescr.WindowAttributes |= WindowAttribute::BORDER;
    1146             :                 else
    1147           6 :                     aDescr.WindowAttributes |= VclWindowPeerAttribute::NOBORDER;
    1148             :             }
    1149             :         }
    1150             : 
    1151             :         // DESKTOP_AS_PARENT
    1152         637 :         if ( aDescr.Type == WindowClass_TOP )
    1153             :         {
    1154           4 :             aPropName = GetPropertyName( BASEPROPERTY_DESKTOP_AS_PARENT );
    1155           4 :             if ( xInfo->hasPropertyByName( aPropName ) )
    1156             :             {
    1157           4 :                 aVal = xPSet->getPropertyValue( aPropName );
    1158           4 :                 bool b = bool();
    1159           4 :                 if ( ( aVal >>= b ) && b)
    1160           0 :                     aDescr.ParentIndex = -1;
    1161             :             }
    1162             :         }
    1163             :         // Moveable
    1164         637 :         aPropName = GetPropertyName( BASEPROPERTY_MOVEABLE );
    1165         637 :         if ( xInfo->hasPropertyByName( aPropName ) )
    1166             :         {
    1167           8 :             aVal = xPSet->getPropertyValue( aPropName );
    1168           8 :             bool b = bool();
    1169           8 :             if ( ( aVal >>= b ) && b)
    1170           8 :                 aDescr.WindowAttributes |= WindowAttribute::MOVEABLE;
    1171             :         }
    1172             : 
    1173             :         // Closeable
    1174         637 :         aPropName = GetPropertyName( BASEPROPERTY_CLOSEABLE );
    1175         637 :         if ( xInfo->hasPropertyByName( aPropName ) )
    1176             :         {
    1177           8 :             aVal = xPSet->getPropertyValue( aPropName );
    1178           8 :             bool b = bool();
    1179           8 :             if ( ( aVal >>= b ) && b)
    1180           8 :                 aDescr.WindowAttributes |= WindowAttribute::CLOSEABLE;
    1181             :         }
    1182             : 
    1183             :         // Dropdown
    1184         637 :         aPropName = GetPropertyName( BASEPROPERTY_DROPDOWN );
    1185         637 :         if ( xInfo->hasPropertyByName( aPropName ) )
    1186             :         {
    1187         146 :             aVal = xPSet->getPropertyValue( aPropName );
    1188         146 :             bool b = bool();
    1189         146 :             if ( ( aVal >>= b ) && b)
    1190          58 :                 aDescr.WindowAttributes |= VclWindowPeerAttribute::DROPDOWN;
    1191             :         }
    1192             : 
    1193             :         // Spin
    1194         637 :         aPropName = GetPropertyName( BASEPROPERTY_SPIN );
    1195         637 :         if ( xInfo->hasPropertyByName( aPropName ) )
    1196             :         {
    1197         164 :             aVal = xPSet->getPropertyValue( aPropName );
    1198         164 :             bool b = bool();
    1199         164 :             if ( ( aVal >>= b ) && b)
    1200          48 :                 aDescr.WindowAttributes |= VclWindowPeerAttribute::SPIN;
    1201             :         }
    1202             : 
    1203             :         // HScroll
    1204         637 :         aPropName = GetPropertyName( BASEPROPERTY_HSCROLL );
    1205         637 :         if ( xInfo->hasPropertyByName( aPropName ) )
    1206             :         {
    1207         140 :             aVal = xPSet->getPropertyValue( aPropName );
    1208         140 :             bool b = bool();
    1209         140 :             if ( ( aVal >>= b ) && b)
    1210          22 :                 aDescr.WindowAttributes |= VclWindowPeerAttribute::HSCROLL;
    1211             :         }
    1212             : 
    1213             :         // VScroll
    1214         637 :         aPropName = GetPropertyName( BASEPROPERTY_VSCROLL );
    1215         637 :         if ( xInfo->hasPropertyByName( aPropName ) )
    1216             :         {
    1217         140 :             aVal = xPSet->getPropertyValue( aPropName );
    1218         140 :             bool b = bool();
    1219         140 :             if ( ( aVal >>= b ) && b)
    1220          22 :                 aDescr.WindowAttributes |= VclWindowPeerAttribute::VSCROLL;
    1221             :         }
    1222             : 
    1223             :         // AutoHScroll
    1224         637 :         aPropName = GetPropertyName( BASEPROPERTY_AUTOHSCROLL );
    1225         637 :         if ( xInfo->hasPropertyByName( aPropName ) )
    1226             :         {
    1227           2 :             aVal = xPSet->getPropertyValue( aPropName );
    1228           2 :             bool b = bool();
    1229           2 :             if ( ( aVal >>= b ) && b)
    1230           0 :                 aDescr.WindowAttributes |= VclWindowPeerAttribute::AUTOHSCROLL;
    1231             :         }
    1232             : 
    1233             :         // AutoVScroll
    1234         637 :         aPropName = GetPropertyName( BASEPROPERTY_AUTOVSCROLL );
    1235         637 :         if ( xInfo->hasPropertyByName( aPropName ) )
    1236             :         {
    1237           2 :             aVal = xPSet->getPropertyValue( aPropName );
    1238           2 :             bool b = bool();
    1239           2 :             if ( ( aVal >>= b ) && b)
    1240           0 :                 aDescr.WindowAttributes |= VclWindowPeerAttribute::AUTOVSCROLL;
    1241             :         }
    1242             : 
    1243             :         //added for issue79712
    1244             :         //NoLabel
    1245         637 :         aPropName = GetPropertyName( BASEPROPERTY_NOLABEL );
    1246         637 :         if ( xInfo->hasPropertyByName( aPropName ) )
    1247             :         {
    1248           4 :             aVal = xPSet->getPropertyValue( aPropName );
    1249           4 :             bool b = bool();
    1250           4 :             if ( ( aVal >>=b ) && b )
    1251           0 :                 aDescr.WindowAttributes |= VclWindowPeerAttribute::NOLABEL;
    1252             :         }
    1253             :         //issue79712 ends
    1254             : 
    1255             :         // Align
    1256         637 :         aPropName = GetPropertyName( BASEPROPERTY_ALIGN );
    1257         637 :         if ( xInfo->hasPropertyByName( aPropName ) )
    1258             :         {
    1259         575 :             aVal = xPSet->getPropertyValue( aPropName );
    1260         575 :             sal_Int16 n = sal_Int16();
    1261         575 :             if ( aVal >>= n )
    1262             :             {
    1263         575 :                 if ( n == PROPERTY_ALIGN_LEFT )
    1264         434 :                     aDescr.WindowAttributes |= VclWindowPeerAttribute::LEFT;
    1265         141 :                 else if ( n == PROPERTY_ALIGN_CENTER )
    1266         141 :                     aDescr.WindowAttributes |= VclWindowPeerAttribute::CENTER;
    1267             :                 else
    1268           0 :                     aDescr.WindowAttributes |= VclWindowPeerAttribute::RIGHT;
    1269             :             }
    1270             :         }
    1271             : 
    1272             :         // Allow derivates to manipulate attributes
    1273         637 :         PrepareWindowDescriptor(aDescr);
    1274             : 
    1275             :         // create the peer
    1276         637 :         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         637 :         UnoControlComponentInfos aComponentInfos(maComponentInfos);
    1288         637 :         bool bDesignMode(mbDesignMode);
    1289             : 
    1290        1274 :         Reference< XGraphics >  xGraphics( mxGraphics           );
    1291        1274 :         Reference< XView >      xView    ( getPeer(), UNO_QUERY_THROW );
    1292        1274 :         Reference< XWindow >    xWindow  ( getPeer(), UNO_QUERY_THROW );
    1293             : 
    1294         637 :         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         637 :         updateFromModel();
    1301             : 
    1302         637 :         xView->setZoom( aComponentInfos.nZoomX, aComponentInfos.nZoomY );
    1303             : 
    1304         637 :         setPosSize( aComponentInfos.nX, aComponentInfos.nY, aComponentInfos.nWidth, aComponentInfos.nHeight, aComponentInfos.nFlags );
    1305             : 
    1306         637 :         if( aComponentInfos.bVisible && !bDesignMode )
    1307             :             // Show only after setting the data
    1308         104 :             xWindow->setVisible( aComponentInfos.bVisible );
    1309             : 
    1310         637 :         if( !aComponentInfos.bEnable )
    1311           0 :             xWindow->setEnable( aComponentInfos.bEnable );
    1312             : 
    1313         637 :         xView->setGraphics( xGraphics );
    1314             : 
    1315         637 :         peerCreated();
    1316             : 
    1317        1274 :         mbCreatingPeer = false;
    1318         693 :     }
    1319         693 : }
    1320             : 
    1321       98012 : Reference< XWindowPeer > UnoControl::getPeer() throw(RuntimeException, std::exception)
    1322             : {
    1323       98012 :     ::osl::MutexGuard aGuard( GetMutex() );
    1324       98012 :     return mxPeer;
    1325             : }
    1326             : 
    1327        4535 : sal_Bool UnoControl::setModel( const Reference< XControlModel >& rxModel ) throw(RuntimeException, std::exception)
    1328             : {
    1329        4535 :     ::osl::MutexGuard aGuard( GetMutex() );
    1330             : 
    1331        9070 :     Reference< XMultiPropertySet > xPropSet( mxModel, UNO_QUERY );
    1332             : 
    1333             :     // query for the XPropertiesChangeListener - our delegator is allowed to overwrite this interface
    1334        9070 :     Reference< XPropertiesChangeListener > xListener;
    1335        4535 :     queryInterface( ::getCppuType( &xListener ) ) >>= xListener;
    1336             : 
    1337        4535 :     if( xPropSet.is() )
    1338        2209 :         xPropSet->removePropertiesChangeListener( xListener );
    1339             : 
    1340        4535 :     mpData->bLocalizationSupport = false;
    1341        4535 :     mxModel = rxModel;
    1342             : 
    1343        4535 :     if( mxModel.is() )
    1344             :     {
    1345             :         try
    1346             :         {
    1347        2227 :             xPropSet.set( mxModel, UNO_QUERY_THROW );
    1348        2227 :             Reference< XPropertySetInfo > xPSI( xPropSet->getPropertySetInfo(), UNO_SET_THROW );
    1349             : 
    1350        4454 :             Sequence< OUString> aNames = lcl_ImplGetPropertyNames( xPropSet );
    1351        2227 :             xPropSet->addPropertiesChangeListener( aNames, xListener );
    1352             : 
    1353        4454 :             mpData->bLocalizationSupport = xPSI->hasPropertyByName("ResourceResolver");
    1354             :         }
    1355           0 :         catch( const Exception& )
    1356             :         {
    1357             :             DBG_UNHANDLED_EXCEPTION();
    1358           0 :             mxModel.clear();
    1359             :         }
    1360             :     }
    1361             : 
    1362        9070 :     return mxModel.is();
    1363             : }
    1364             : 
    1365       16886 : Reference< XControlModel > UnoControl::getModel(    ) throw(RuntimeException, std::exception)
    1366             : {
    1367       16886 :     return mxModel;
    1368             : }
    1369             : 
    1370          58 : Reference< XView > UnoControl::getView(  ) throw(RuntimeException, std::exception)
    1371             : {
    1372          58 :     return  static_cast< XView* >( this );
    1373             : }
    1374             : 
    1375         513 : void UnoControl::setDesignMode( sal_Bool bOn ) throw(RuntimeException, std::exception)
    1376             : {
    1377         513 :     ModeChangeEvent aModeChangeEvent;
    1378             : 
    1379         938 :     Reference< XWindow > xWindow;
    1380         938 :     Reference<XComponent> xAccessibleComp;
    1381             :     {
    1382         513 :         ::osl::MutexGuard aGuard( GetMutex() );
    1383         513 :         if ( bool(bOn) == mbDesignMode )
    1384         601 :             return;
    1385             : 
    1386             :         // remember this
    1387         425 :         mbDesignMode = bOn;
    1388         425 :         xWindow.set(getPeer(), css::uno::UNO_QUERY);
    1389             : 
    1390         425 :         xAccessibleComp.set(maAccessibleContext, UNO_QUERY);
    1391         425 :         maAccessibleContext.clear();
    1392             : 
    1393         425 :         aModeChangeEvent.Source = *this;
    1394         425 :         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         425 :     DisposeAccessibleContext(xAccessibleComp);
    1401             : 
    1402             :     // adjust the visibility of our window
    1403         425 :     if ( xWindow.is() )
    1404         122 :         xWindow->setVisible( !bOn );
    1405             : 
    1406             :     // and notify our mode listeners
    1407         850 :     maModeChangeListeners.notifyEach( &XModeChangeListener::modeChanged, aModeChangeEvent );
    1408             : }
    1409             : 
    1410       21906 : sal_Bool UnoControl::isDesignMode(  ) throw(RuntimeException, std::exception)
    1411             : {
    1412       21906 :     return mbDesignMode;
    1413             : }
    1414             : 
    1415          40 : sal_Bool UnoControl::isTransparent(  ) throw(RuntimeException, std::exception)
    1416             : {
    1417          40 :     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          64 : Reference< XAccessibleContext > SAL_CALL UnoControl::getAccessibleContext(  ) throw (RuntimeException, std::exception)
    1440             : {
    1441             :     // creation of the context will certainly require the SolarMutex ...
    1442          64 :     SolarMutexGuard aSolarGuard;
    1443         128 :     ::osl::MutexGuard aGuard( GetMutex() );
    1444             : 
    1445          64 :     Reference< XAccessibleContext > xCurrentContext( maAccessibleContext.get(), UNO_QUERY );
    1446          64 :     if ( !xCurrentContext.is() )
    1447             :     {
    1448          64 :         if ( !mbDesignMode )
    1449             :         {   // in alive mode, use the AccessibleContext of the peer
    1450           6 :             Reference< XAccessible > xPeerAcc( getPeer(), UNO_QUERY );
    1451           6 :             if ( xPeerAcc.is() )
    1452           6 :                 xCurrentContext = xPeerAcc->getAccessibleContext( );
    1453             :         }
    1454             :         else
    1455             :             // in design mode, use a fallback
    1456          58 :             xCurrentContext = ::toolkit::OAccessibleControlContext::create( this );
    1457             : 
    1458             :         DBG_ASSERT( xCurrentContext.is(), "UnoControl::getAccessibleContext: invalid context (invalid peer?)!" );
    1459          64 :         maAccessibleContext = xCurrentContext;
    1460             : 
    1461             :         // get notified when the context is disposed
    1462          64 :         Reference< XComponent > xContextComp( xCurrentContext, UNO_QUERY );
    1463          64 :         if ( xContextComp.is() )
    1464          64 :             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         128 :     return xCurrentContext;
    1472             : }
    1473             : 
    1474         411 : void SAL_CALL UnoControl::addModeChangeListener( const Reference< XModeChangeListener >& _rxListener ) throw (RuntimeException, std::exception)
    1475             : {
    1476         411 :     ::osl::MutexGuard aGuard( GetMutex() );
    1477         411 :     maModeChangeListeners.addInterface( _rxListener );
    1478         411 : }
    1479             : 
    1480         411 : void SAL_CALL UnoControl::removeModeChangeListener( const Reference< XModeChangeListener >& _rxListener ) throw (RuntimeException, std::exception)
    1481             : {
    1482         411 :     ::osl::MutexGuard aGuard( GetMutex() );
    1483         411 :     maModeChangeListeners.removeInterface( _rxListener );
    1484         411 : }
    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        1227 : }
    1560             : 
    1561             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10