LCOV - code coverage report
Current view: top level - toolkit/source/controls - unocontrolbase.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 116 124 93.5 %
Date: 2012-08-25 Functions: 15 15 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 122 286 42.7 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <com/sun/star/awt/XLayoutConstrains.hpp>
      30                 :            : #include <com/sun/star/awt/XTextLayoutConstrains.hpp>
      31                 :            : 
      32                 :            : #include <toolkit/controls/unocontrolbase.hxx>
      33                 :            : #include <toolkit/helper/property.hxx>
      34                 :            : #include <comphelper/processfactory.hxx>
      35                 :            : 
      36                 :            : #include <tools/debug.hxx>
      37                 :            : 
      38                 :            : //  ----------------------------------------------------
      39                 :            : //  class UnoControlBase
      40                 :            : //  ----------------------------------------------------
      41                 :            : 
      42                 :        559 : sal_Bool UnoControlBase::ImplHasProperty( sal_uInt16 nPropId )
      43                 :            : {
      44         [ +  - ]:        559 :     ::rtl::OUString aPropName( GetPropertyName( nPropId ) );
      45         [ +  - ]:        559 :     return ImplHasProperty( aPropName );
      46                 :            : }
      47                 :            : 
      48                 :        559 : sal_Bool UnoControlBase::ImplHasProperty( const ::rtl::OUString& aPropertyName )
      49                 :            : {
      50         [ +  - ]:        559 :     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >  xPSet( mxModel, ::com::sun::star::uno::UNO_QUERY );
      51         [ +  + ]:        559 :     if ( !xPSet.is() )
      52                 :        181 :         return sal_False;
      53 [ +  - ][ +  - ]:        378 :     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >  xInfo = xPSet->getPropertySetInfo();
      54         [ -  + ]:        378 :     if ( !xInfo.is() )
      55                 :          0 :         return sal_False;
      56                 :            : 
      57 [ +  - ][ +  - ]:        559 :     return xInfo->hasPropertyByName( aPropertyName );
      58                 :            : }
      59                 :            : 
      60                 :         16 : void UnoControlBase::ImplSetPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues, sal_Bool bUpdateThis )
      61                 :            : {
      62         [ +  - ]:         16 :     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet > xMPS( mxModel, ::com::sun::star::uno::UNO_QUERY );
      63         [ -  + ]:         16 :     if ( !mxModel.is() )
      64                 :         16 :         return;
      65                 :            : 
      66                 :            :     DBG_ASSERT( xMPS.is(), "UnoControlBase::ImplSetPropertyValues: no multi property set interface!" );
      67         [ +  - ]:         16 :     if ( xMPS.is() )
      68                 :            :     {
      69         [ +  + ]:         16 :         if ( !bUpdateThis )
      70         [ +  - ]:         12 :             ImplLockPropertyChangeNotifications( aPropertyNames, true );
      71                 :            : 
      72                 :            :         try
      73                 :            :         {
      74 [ +  - ][ +  - ]:         16 :             xMPS->setPropertyValues( aPropertyNames, aValues );
      75                 :            :         }
      76   [ #  #  #  # ]:          0 :         catch( const ::com::sun::star::uno::Exception& )
      77                 :            :         {
      78         [ #  # ]:          0 :             if ( !bUpdateThis )
      79         [ #  # ]:          0 :                 ImplLockPropertyChangeNotifications( aPropertyNames, false );
      80                 :            :         }
      81         [ +  + ]:         16 :         if ( !bUpdateThis )
      82         [ +  - ]:         12 :             ImplLockPropertyChangeNotifications( aPropertyNames, false );
      83                 :            :     }
      84                 :            :     else
      85                 :            :     {
      86                 :         16 :         int dummy = 0;
      87                 :            :         (void)dummy;
      88         [ +  - ]:         16 :     }
      89                 :            : }
      90                 :            : 
      91                 :       1104 : void UnoControlBase::ImplSetPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue, sal_Bool bUpdateThis )
      92                 :            : {
      93                 :            :     // Model might be logged off already but an event still fires
      94         [ +  - ]:       1104 :     if ( mxModel.is() )
      95                 :            :     {
      96         [ +  - ]:       1104 :         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >  xPSet( mxModel, ::com::sun::star::uno::UNO_QUERY );
      97         [ +  + ]:       1104 :         if ( !bUpdateThis )
      98         [ +  - ]:        656 :             ImplLockPropertyChangeNotification( aPropertyName, true );
      99                 :            : 
     100                 :            :         try
     101                 :            :         {
     102 [ +  - ][ +  - ]:       1104 :             xPSet->setPropertyValue( aPropertyName, aValue );
     103                 :            :         }
     104         [ #  # ]:          0 :         catch( const com::sun::star::uno::Exception& )
     105                 :            :         {
     106         [ #  # ]:          0 :             if ( !bUpdateThis )
     107         [ #  # ]:          0 :                 ImplLockPropertyChangeNotification( aPropertyName, false );
     108                 :          0 :             throw;
     109                 :            :         }
     110         [ +  + ]:       1104 :         if ( !bUpdateThis )
     111         [ +  - ]:       1104 :             ImplLockPropertyChangeNotification( aPropertyName, false );
     112                 :            :     }
     113                 :       1104 : }
     114                 :            : 
     115                 :       1301 : ::com::sun::star::uno::Any UnoControlBase::ImplGetPropertyValue( const ::rtl::OUString& aPropertyName )
     116                 :            : {
     117         [ +  - ]:       1301 :     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >  xPSet( mxModel, ::com::sun::star::uno::UNO_QUERY );
     118         [ +  + ]:       1301 :     if ( xPSet.is() )
     119 [ +  - ][ +  - ]:       1293 :         return xPSet->getPropertyValue( aPropertyName );
     120                 :            :     else
     121                 :       1301 :         return ::com::sun::star::uno::Any();
     122                 :            : }
     123                 :            : 
     124                 :        102 : sal_Bool UnoControlBase::ImplGetPropertyValue_BOOL( sal_uInt16 nProp )
     125                 :            : {
     126                 :        102 :     sal_Bool b = sal_False;
     127         [ +  - ]:        102 :     if ( mxModel.is() )
     128                 :            :     {
     129 [ +  - ][ +  - ]:        102 :         ::com::sun::star::uno::Any aVal = ImplGetPropertyValue( GetPropertyName( nProp ) );
     130                 :        102 :         aVal >>= b;
     131                 :            :     }
     132                 :        102 :     return b;
     133                 :            : }
     134                 :            : 
     135                 :         70 : sal_Int16 UnoControlBase::ImplGetPropertyValue_INT16( sal_uInt16 nProp )
     136                 :            : {
     137                 :         70 :     sal_Int16 n = 0;
     138         [ +  - ]:         70 :     if ( mxModel.is() )
     139                 :            :     {
     140 [ +  - ][ +  - ]:         70 :         ::com::sun::star::uno::Any aVal = ImplGetPropertyValue( GetPropertyName( nProp ) );
     141                 :         70 :         aVal >>= n;
     142                 :            :     }
     143                 :         70 :     return n;
     144                 :            : }
     145                 :            : 
     146                 :         48 : sal_Int32 UnoControlBase::ImplGetPropertyValue_INT32( sal_uInt16 nProp )
     147                 :            : {
     148                 :         48 :     sal_Int32 n = 0;
     149         [ +  - ]:         48 :     if ( mxModel.is() )
     150                 :            :     {
     151 [ +  - ][ +  - ]:         48 :         ::com::sun::star::uno::Any aVal = ImplGetPropertyValue( GetPropertyName( nProp ) );
     152                 :         48 :         aVal >>= n;
     153                 :            :     }
     154                 :         48 :     return n;
     155                 :            : }
     156                 :            : 
     157                 :         64 : double UnoControlBase::ImplGetPropertyValue_DOUBLE( sal_uInt16 nProp )
     158                 :            : {
     159                 :         64 :     double n = 0;
     160         [ +  - ]:         64 :     if ( mxModel.is() )
     161                 :            :     {
     162 [ +  - ][ +  - ]:         64 :         ::com::sun::star::uno::Any aVal = ImplGetPropertyValue( GetPropertyName( nProp ) );
     163                 :         64 :         aVal >>= n;
     164                 :            :     }
     165                 :         64 :     return n;
     166                 :            : }
     167                 :            : 
     168                 :        640 : ::rtl::OUString UnoControlBase::ImplGetPropertyValue_UString( sal_uInt16 nProp )
     169                 :            : {
     170                 :        640 :     ::rtl::OUString aStr;
     171         [ +  - ]:        640 :     if ( mxModel.is() )
     172                 :            :     {
     173 [ +  - ][ +  - ]:        640 :         ::com::sun::star::uno::Any aVal = ImplGetPropertyValue( GetPropertyName( nProp ) );
     174                 :        640 :         aVal >>= aStr;
     175                 :            :     }
     176                 :        640 :     return aStr;
     177                 :            : }
     178                 :            : 
     179                 :         52 : ::com::sun::star::awt::Size UnoControlBase::Impl_getMinimumSize()
     180                 :            : {
     181                 :         52 :     ::com::sun::star::awt::Size aSz;
     182         [ +  - ]:         52 :     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >  xP = ImplGetCompatiblePeer( sal_True );
     183                 :            :     DBG_ASSERT( xP.is(), "Layout: No Peer!" );
     184         [ +  - ]:         52 :     if ( xP.is() )
     185                 :            :     {
     186         [ +  - ]:         52 :         ::com::sun::star::uno::Reference< ::com::sun::star::awt::XLayoutConstrains >  xL( xP, ::com::sun::star::uno::UNO_QUERY );
     187         [ +  - ]:         52 :         if ( xL.is() )
     188 [ +  - ][ +  - ]:         52 :             aSz = xL->getMinimumSize();
     189                 :            : 
     190 [ +  - ][ +  - ]:         52 :         if ( !getPeer().is() || ( getPeer() != xP ) )
         [ +  - ][ +  - ]
         [ -  + ][ +  - ]
         [ +  - ][ -  +  
             #  #  #  # ]
     191 [ #  # ][ #  # ]:         52 :             xP->dispose();
     192                 :            :     }
     193                 :         52 :     return aSz;
     194                 :            : }
     195                 :            : 
     196                 :         52 : ::com::sun::star::awt::Size UnoControlBase::Impl_getPreferredSize()
     197                 :            : {
     198                 :         52 :     ::com::sun::star::awt::Size aSz;
     199         [ +  - ]:         52 :     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >  xP = ImplGetCompatiblePeer( sal_True );
     200                 :            :     DBG_ASSERT( xP.is(), "Layout: No Peer!" );
     201         [ +  - ]:         52 :     if ( xP.is() )
     202                 :            :     {
     203         [ +  - ]:         52 :         ::com::sun::star::uno::Reference< ::com::sun::star::awt::XLayoutConstrains >  xL( xP, ::com::sun::star::uno::UNO_QUERY );
     204         [ +  - ]:         52 :         if ( xL.is() )
     205 [ +  - ][ +  - ]:         52 :             aSz = xL->getPreferredSize();
     206                 :            : 
     207 [ +  - ][ +  - ]:         52 :         if ( !getPeer().is() || ( getPeer() != xP ) )
         [ +  - ][ +  - ]
         [ -  + ][ +  - ]
         [ +  - ][ -  +  
             #  #  #  # ]
     208 [ #  # ][ #  # ]:         52 :             xP->dispose();
     209                 :            :     }
     210                 :         52 :     return aSz;
     211                 :            : }
     212                 :            : 
     213                 :         52 : ::com::sun::star::awt::Size UnoControlBase::Impl_calcAdjustedSize( const ::com::sun::star::awt::Size& rNewSize )
     214                 :            : {
     215                 :         52 :     ::com::sun::star::awt::Size aSz;
     216         [ +  - ]:         52 :     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >  xP = ImplGetCompatiblePeer( sal_True );
     217                 :            :     DBG_ASSERT( xP.is(), "Layout: No Peer!" );
     218         [ +  - ]:         52 :     if ( xP.is() )
     219                 :            :     {
     220         [ +  - ]:         52 :         ::com::sun::star::uno::Reference< ::com::sun::star::awt::XLayoutConstrains > xL( xP, ::com::sun::star::uno::UNO_QUERY );
     221         [ +  - ]:         52 :         if ( xL.is() )
     222 [ +  - ][ +  - ]:         52 :             aSz = xL->calcAdjustedSize( rNewSize );
     223                 :            : 
     224 [ +  - ][ +  - ]:         52 :         if ( !getPeer().is() || ( getPeer() != xP ) )
         [ +  - ][ +  - ]
         [ -  + ][ +  - ]
         [ +  - ][ -  +  
             #  #  #  # ]
     225 [ #  # ][ #  # ]:         52 :             xP->dispose();
     226                 :            :     }
     227                 :         52 :     return aSz;
     228                 :            : }
     229                 :            : 
     230                 :         32 : ::com::sun::star::awt::Size UnoControlBase::Impl_getMinimumSize( sal_Int16 nCols, sal_Int16 nLines )
     231                 :            : {
     232                 :         32 :     ::com::sun::star::awt::Size aSz;
     233         [ +  - ]:         32 :     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >  xP = ImplGetCompatiblePeer( sal_True );
     234                 :            :     DBG_ASSERT( xP.is(), "Layout: No Peer!" );
     235         [ +  - ]:         32 :     if ( xP.is() )
     236                 :            :     {
     237         [ +  - ]:         32 :         ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextLayoutConstrains >  xL( xP, ::com::sun::star::uno::UNO_QUERY );
     238         [ +  - ]:         32 :         if ( xL.is() )
     239 [ +  - ][ +  - ]:         32 :             aSz = xL->getMinimumSize( nCols, nLines );
     240                 :            : 
     241 [ +  - ][ +  - ]:         32 :         if ( !getPeer().is() || ( getPeer() != xP ) )
         [ +  - ][ +  - ]
         [ -  + ][ +  - ]
         [ +  - ][ -  +  
             #  #  #  # ]
     242 [ #  # ][ #  # ]:         32 :             xP->dispose();
     243                 :            :     }
     244                 :         32 :     return aSz;
     245                 :            : }
     246                 :            : 
     247                 :         32 : void UnoControlBase::Impl_getColumnsAndLines( sal_Int16& nCols, sal_Int16& nLines )
     248                 :            : {
     249         [ +  - ]:         32 :     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >  xP = ImplGetCompatiblePeer( sal_True );
     250                 :            :     DBG_ASSERT( xP.is(), "Layout: No Peer!" );
     251         [ +  - ]:         32 :     if ( xP.is() )
     252                 :            :     {
     253         [ +  - ]:         32 :         ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextLayoutConstrains >  xL( xP, ::com::sun::star::uno::UNO_QUERY );
     254         [ +  - ]:         32 :         if ( xL.is() )
     255 [ +  - ][ +  - ]:         32 :             xL->getColumnsAndLines( nCols, nLines );
     256                 :            : 
     257 [ +  - ][ +  - ]:         32 :         if ( !getPeer().is() || ( getPeer() != xP ) )
         [ +  - ][ +  - ]
         [ -  + ][ +  - ]
         [ +  - ][ -  +  
             #  #  #  # ]
     258 [ #  # ][ #  # ]:         32 :             xP->dispose();
     259                 :         32 :     }
     260                 :         32 : }
     261                 :            : 
     262                 :            : 
     263                 :            : 
     264                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10