LCOV - code coverage report
Current view: top level - vcl/source/gdi - outdevnative.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 36 147 24.5 %
Date: 2012-08-25 Functions: 9 33 27.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 25 211 11.8 %

           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                 :            : 
      30                 :            : #include "vcl/outdev.hxx"
      31                 :            : #include "vcl/window.hxx"
      32                 :            : #include "vcl/salnativewidgets.hxx"
      33                 :            : #include "vcl/pdfextoutdevdata.hxx"
      34                 :            : 
      35                 :            : #include "salgdi.hxx"
      36                 :            : 
      37                 :            : // -----------------------------------------------------------------------
      38                 :            : 
      39                 :     617421 : static bool lcl_enableNativeWidget( const OutputDevice& i_rDevice )
      40                 :            : {
      41                 :     617421 :     const OutDevType eType( i_rDevice.GetOutDevType() );
      42      [ +  -  - ]:     617421 :     switch ( eType )
      43                 :            :     {
      44                 :            : 
      45                 :            :     case OUTDEV_WINDOW:
      46         [ -  + ]:     617421 :         return dynamic_cast< const Window* >( &i_rDevice )->IsNativeWidgetEnabled();
      47                 :            : 
      48                 :            :     case OUTDEV_VIRDEV:
      49                 :            :     {
      50                 :          0 :         const ::vcl::ExtOutDevData* pOutDevData( i_rDevice.GetExtOutDevData() );
      51         [ #  # ]:          0 :         const ::vcl::PDFExtOutDevData* pPDFData( dynamic_cast< const ::vcl::PDFExtOutDevData* >( pOutDevData ) );
      52         [ #  # ]:          0 :         if ( pPDFData != NULL )
      53                 :          0 :             return false;
      54                 :          0 :         return true;
      55                 :            :     }
      56                 :            : 
      57                 :            :     default:
      58                 :     617421 :         return false;
      59                 :            :     }
      60                 :            : }
      61                 :            : 
      62                 :     137300 : ImplControlValue::~ImplControlValue()
      63                 :            : {
      64         [ -  + ]:     191423 : }
      65                 :            : 
      66                 :        121 : ImplControlValue* ImplControlValue::clone() const
      67                 :            : {
      68                 :            :     assert( typeid( const ImplControlValue ) == typeid( *this ));
      69                 :        121 :     return new ImplControlValue( *this );
      70                 :            : }
      71                 :            : 
      72                 :      24917 : ScrollbarValue::~ScrollbarValue()
      73                 :            : {
      74         [ -  + ]:      24917 : }
      75                 :            : 
      76                 :          0 : ScrollbarValue* ScrollbarValue::clone() const
      77                 :            : {
      78                 :            :     assert( typeid( const ScrollbarValue ) == typeid( *this ));
      79         [ #  # ]:          0 :     return new ScrollbarValue( *this );
      80                 :            : }
      81                 :            : 
      82                 :          0 : SliderValue::~SliderValue()
      83                 :            : {
      84         [ #  # ]:          0 : }
      85                 :            : 
      86                 :          0 : SliderValue* SliderValue::clone() const
      87                 :            : {
      88                 :            :     assert( typeid( const SliderValue ) == typeid( *this ));
      89         [ #  # ]:          0 :     return new SliderValue( *this );
      90                 :            : }
      91                 :            : 
      92                 :          0 : TabitemValue::~TabitemValue()
      93                 :            : {
      94         [ #  # ]:          0 : }
      95                 :            : 
      96                 :          0 : TabitemValue* TabitemValue::clone() const
      97                 :            : {
      98                 :            :     assert( typeid( const TabitemValue ) == typeid( *this ));
      99         [ #  # ]:          0 :     return new TabitemValue( *this );
     100                 :            : }
     101                 :            : 
     102                 :        707 : SpinbuttonValue::~SpinbuttonValue()
     103                 :            : {
     104         [ -  + ]:        707 : }
     105                 :            : 
     106                 :          0 : SpinbuttonValue* SpinbuttonValue::clone() const
     107                 :            : {
     108                 :            :     assert( typeid( const SpinbuttonValue ) == typeid( *this ));
     109         [ #  # ]:          0 :     return new SpinbuttonValue( *this );
     110                 :            : }
     111                 :            : 
     112                 :          0 : ToolbarValue::~ToolbarValue()
     113                 :            : {
     114         [ #  # ]:          0 : }
     115                 :            : 
     116                 :          0 : ToolbarValue* ToolbarValue::clone() const
     117                 :            : {
     118                 :            :     assert( typeid( const ToolbarValue ) == typeid( *this ));
     119         [ #  # ]:          0 :     return new ToolbarValue( *this );
     120                 :            : }
     121                 :            : 
     122                 :          0 : MenubarValue::~MenubarValue()
     123                 :            : {
     124         [ #  # ]:          0 : }
     125                 :            : 
     126                 :          0 : MenubarValue* MenubarValue::clone() const
     127                 :            : {
     128                 :            :     assert( typeid( const MenubarValue ) == typeid( *this ));
     129         [ #  # ]:          0 :     return new MenubarValue( *this );
     130                 :            : }
     131                 :            : 
     132                 :          0 : MenupopupValue::~MenupopupValue()
     133                 :            : {
     134         [ #  # ]:          0 : }
     135                 :            : 
     136                 :          0 : MenupopupValue* MenupopupValue::clone() const
     137                 :            : {
     138                 :            :     assert( typeid( const MenupopupValue ) == typeid( *this ));
     139         [ #  # ]:          0 :     return new MenupopupValue( *this );
     140                 :            : }
     141                 :            : 
     142                 :          0 : PushButtonValue::~PushButtonValue()
     143                 :            : {
     144         [ #  # ]:          0 : }
     145                 :            : 
     146                 :          0 : PushButtonValue* PushButtonValue::clone() const
     147                 :            : {
     148                 :            :     assert( typeid( const PushButtonValue ) == typeid( *this ));
     149         [ #  # ]:          0 :     return new PushButtonValue( *this );
     150                 :            : }
     151                 :            : 
     152                 :            : // -----------------------------------------------------------------------
     153                 :            : // These functions are mainly passthrough functions that allow access to
     154                 :            : // the SalFrame behind a Window object for native widget rendering purposes.
     155                 :            : // -----------------------------------------------------------------------
     156                 :            : 
     157                 :            : // -----------------------------------------------------------------------
     158                 :            : 
     159                 :     560926 : sal_Bool OutputDevice::IsNativeControlSupported( ControlType nType, ControlPart nPart )
     160                 :            : {
     161         [ +  + ]:     560926 :     if( !lcl_enableNativeWidget( *this ) )
     162                 :      24970 :         return sal_False;
     163                 :            : 
     164         [ +  + ]:     535956 :     if ( !mpGraphics )
     165         [ -  + ]:      52953 :         if ( !ImplGetGraphics() )
     166                 :          0 :             return sal_False;
     167                 :            : 
     168                 :     560926 :     return( mpGraphics->IsNativeControlSupported(nType, nPart) );
     169                 :            : }
     170                 :            : 
     171                 :            : 
     172                 :            : // -----------------------------------------------------------------------
     173                 :            : 
     174                 :          0 : sal_Bool OutputDevice::HitTestNativeControl( ControlType nType,
     175                 :            :                               ControlPart nPart,
     176                 :            :                               const Rectangle& rControlRegion,
     177                 :            :                               const Point& aPos,
     178                 :            :                               sal_Bool& rIsInside )
     179                 :            : {
     180 [ #  # ][ #  # ]:          0 :     if( !lcl_enableNativeWidget( *this ) )
     181                 :          0 :         return sal_False;
     182                 :            : 
     183         [ #  # ]:          0 :     if ( !mpGraphics )
     184 [ #  # ][ #  # ]:          0 :         if ( !ImplGetGraphics() )
     185                 :          0 :             return sal_False;
     186                 :            : 
     187                 :          0 :     Point aWinOffs( mnOutOffX, mnOutOffY );
     188                 :          0 :     Rectangle screenRegion( rControlRegion );
     189         [ #  # ]:          0 :     screenRegion.Move( aWinOffs.X(), aWinOffs.Y());
     190                 :            : 
     191                 :          0 :     return( mpGraphics->HitTestNativeControl(nType, nPart, screenRegion, Point( aPos.X() + mnOutOffX, aPos.Y() + mnOutOffY ),
     192         [ #  # ]:          0 :         rIsInside, this ) );
     193                 :            : }
     194                 :            : 
     195                 :            : // -----------------------------------------------------------------------
     196                 :            : 
     197                 :      54002 : static boost::shared_ptr< ImplControlValue > lcl_transformControlValue( const ImplControlValue& rVal, const OutputDevice& rDev )
     198                 :            : {
     199                 :      54002 :     boost::shared_ptr< ImplControlValue > aResult;
     200   [ -  -  -  -  :      54002 :     switch( rVal.getType() )
          -  -  -  +  -  
                      - ]
     201                 :            :     {
     202                 :            :     case CTRL_SLIDER:
     203                 :            :         {
     204                 :          0 :             const SliderValue* pSlVal = static_cast<const SliderValue*>(&rVal);
     205 [ #  # ][ #  # ]:          0 :             SliderValue* pNew = new SliderValue( *pSlVal );
     206         [ #  # ]:          0 :             aResult.reset( pNew );
     207         [ #  # ]:          0 :             pNew->maThumbRect = rDev.ImplLogicToDevicePixel( pSlVal->maThumbRect );
     208                 :            :         }
     209                 :          0 :         break;
     210                 :            :     case CTRL_SCROLLBAR:
     211                 :            :         {
     212                 :          0 :             const ScrollbarValue* pScVal = static_cast<const ScrollbarValue*>(&rVal);
     213 [ #  # ][ #  # ]:          0 :             ScrollbarValue* pNew = new ScrollbarValue( *pScVal );
     214         [ #  # ]:          0 :             aResult.reset( pNew );
     215         [ #  # ]:          0 :             pNew->maThumbRect = rDev.ImplLogicToDevicePixel( pScVal->maThumbRect );
     216         [ #  # ]:          0 :             pNew->maButton1Rect = rDev.ImplLogicToDevicePixel( pScVal->maButton1Rect );
     217         [ #  # ]:          0 :             pNew->maButton2Rect = rDev.ImplLogicToDevicePixel( pScVal->maButton2Rect );
     218                 :            :         }
     219                 :          0 :         break;
     220                 :            :     case CTRL_SPINBUTTONS:
     221                 :            :         {
     222                 :          0 :             const SpinbuttonValue* pSpVal = static_cast<const SpinbuttonValue*>(&rVal);
     223 [ #  # ][ #  # ]:          0 :             SpinbuttonValue* pNew = new SpinbuttonValue( *pSpVal );
     224         [ #  # ]:          0 :             aResult.reset( pNew );
     225         [ #  # ]:          0 :             pNew->maUpperRect = rDev.ImplLogicToDevicePixel( pSpVal->maUpperRect );
     226         [ #  # ]:          0 :             pNew->maLowerRect = rDev.ImplLogicToDevicePixel( pSpVal->maLowerRect );
     227                 :            :         }
     228                 :          0 :         break;
     229                 :            :     case CTRL_TOOLBAR:
     230                 :            :         {
     231                 :          0 :             const ToolbarValue* pTVal = static_cast<const ToolbarValue*>(&rVal);
     232 [ #  # ][ #  # ]:          0 :             ToolbarValue* pNew = new ToolbarValue( *pTVal );
     233         [ #  # ]:          0 :             aResult.reset( pNew );
     234         [ #  # ]:          0 :             pNew->maGripRect = rDev.ImplLogicToDevicePixel( pTVal->maGripRect );
     235                 :            :         }
     236                 :          0 :         break;
     237                 :            :     case CTRL_TAB_ITEM:
     238                 :            :         {
     239                 :          0 :             const TabitemValue* pTIVal = static_cast<const TabitemValue*>(&rVal);
     240 [ #  # ][ #  # ]:          0 :             TabitemValue* pNew = new TabitemValue( *pTIVal );
     241         [ #  # ]:          0 :             aResult.reset( pNew );
     242                 :            :         }
     243                 :          0 :         break;
     244                 :            :     case CTRL_MENUBAR:
     245                 :            :         {
     246                 :          0 :             const MenubarValue* pMVal = static_cast<const MenubarValue*>(&rVal);
     247 [ #  # ][ #  # ]:          0 :             MenubarValue* pNew = new MenubarValue( *pMVal );
     248         [ #  # ]:          0 :             aResult.reset( pNew );
     249                 :            :         }
     250                 :          0 :         break;
     251                 :            :     case CTRL_PUSHBUTTON:
     252                 :            :         {
     253                 :          0 :             const PushButtonValue* pBVal = static_cast<const PushButtonValue*>(&rVal);
     254 [ #  # ][ #  # ]:          0 :             PushButtonValue* pNew = new PushButtonValue( *pBVal );
     255         [ #  # ]:          0 :             aResult.reset( pNew );
     256                 :            :         }
     257                 :          0 :         break;
     258                 :            :     case CTRL_GENERIC:
     259 [ +  - ][ +  - ]:      54002 :             aResult.reset( new ImplControlValue( rVal ) );
     260                 :      54002 :             break;
     261                 :            :     case CTRL_MENU_POPUP:
     262                 :            :         {
     263                 :          0 :             const MenupopupValue* pMVal = static_cast<const MenupopupValue*>(&rVal);
     264 [ #  # ][ #  # ]:          0 :             MenupopupValue* pNew = new MenupopupValue( *pMVal );
     265         [ #  # ]:          0 :             pNew->maItemRect = rDev.ImplLogicToDevicePixel( pMVal->maItemRect );
     266         [ #  # ]:          0 :             aResult.reset( pNew );
     267                 :            :         }
     268                 :          0 :         break;
     269                 :            :     default:
     270                 :            :         OSL_FAIL( "unknown ImplControlValue type !" );
     271                 :          0 :         break;
     272                 :            :     }
     273                 :      54002 :     return aResult;
     274                 :            : }
     275                 :          0 : sal_Bool OutputDevice::DrawNativeControl( ControlType nType,
     276                 :            :                             ControlPart nPart,
     277                 :            :                             const Rectangle& rControlRegion,
     278                 :            :                             ControlState nState,
     279                 :            :                             const ImplControlValue& aValue,
     280                 :            :                             ::rtl::OUString aCaption )
     281                 :            : {
     282 [ #  # ][ #  # ]:          0 :     if( !lcl_enableNativeWidget( *this ) )
     283                 :          0 :         return sal_False;
     284                 :            : 
     285                 :            :     // make sure the current clip region is initialized correctly
     286         [ #  # ]:          0 :     if ( !mpGraphics )
     287 [ #  # ][ #  # ]:          0 :         if ( !ImplGetGraphics() )
     288                 :          0 :             return sal_False;
     289                 :            : 
     290         [ #  # ]:          0 :     if ( mbInitClipRegion )
     291         [ #  # ]:          0 :         ImplInitClipRegion();
     292         [ #  # ]:          0 :     if ( mbOutputClipped )
     293                 :          0 :         return sal_True;
     294                 :            : 
     295         [ #  # ]:          0 :     if ( mbInitLineColor )
     296         [ #  # ]:          0 :         ImplInitLineColor();
     297         [ #  # ]:          0 :     if ( mbInitFillColor )
     298         [ #  # ]:          0 :         ImplInitFillColor();
     299                 :            : 
     300                 :            :     // Convert the coordinates from relative to Window-absolute, so we draw
     301                 :            :     // in the correct place in platform code
     302         [ #  # ]:          0 :     boost::shared_ptr< ImplControlValue > aScreenCtrlValue( lcl_transformControlValue( aValue, *this ) );
     303         [ #  # ]:          0 :     Rectangle screenRegion( ImplLogicToDevicePixel( rControlRegion ) );
     304                 :            : 
     305         [ #  # ]:          0 :     Region aTestRegion( GetActiveClipRegion() );
     306         [ #  # ]:          0 :     aTestRegion.Intersect( rControlRegion );
     307 [ #  # ][ #  # ]:          0 :     if( aTestRegion == rControlRegion )
         [ #  # ][ #  # ]
     308                 :          0 :         nState |= CTRL_CACHING_ALLOWED;   // control is not clipped, caching allowed
     309                 :            : 
     310         [ #  # ]:          0 :     sal_Bool bRet = mpGraphics->DrawNativeControl(nType, nPart, screenRegion, nState, *aScreenCtrlValue, aCaption, this );
     311                 :            : 
     312 [ #  # ][ #  # ]:          0 :     return bRet;
     313                 :            : }
     314                 :            : 
     315                 :            : // -----------------------------------------------------------------------
     316                 :            : 
     317                 :      56495 : sal_Bool OutputDevice::GetNativeControlRegion(  ControlType nType,
     318                 :            :                                 ControlPart nPart,
     319                 :            :                                 const Rectangle& rControlRegion,
     320                 :            :                                 ControlState nState,
     321                 :            :                                 const ImplControlValue& aValue,
     322                 :            :                                 ::rtl::OUString aCaption,
     323                 :            :                                 Rectangle &rNativeBoundingRegion,
     324                 :            :                                 Rectangle &rNativeContentRegion ) const
     325                 :            : {
     326 [ +  - ][ +  + ]:      56495 :     if( !lcl_enableNativeWidget( *this ) )
     327                 :       2493 :         return sal_False;
     328                 :            : 
     329         [ +  + ]:      54002 :     if ( !mpGraphics )
     330 [ +  - ][ -  + ]:        454 :         if ( !ImplGetGraphics() )
     331                 :          0 :             return sal_False;
     332                 :            : 
     333                 :            :     // Convert the coordinates from relative to Window-absolute, so we draw
     334                 :            :     // in the correct place in platform code
     335         [ +  - ]:      54002 :     boost::shared_ptr< ImplControlValue > aScreenCtrlValue( lcl_transformControlValue( aValue, *this ) );
     336         [ +  - ]:      54002 :     Rectangle screenRegion( ImplLogicToDevicePixel( rControlRegion ) );
     337                 :            : 
     338                 :      54002 :     sal_Bool bRet = mpGraphics->GetNativeControlRegion(nType, nPart, screenRegion, nState, *aScreenCtrlValue,
     339                 :            :                                 aCaption, rNativeBoundingRegion,
     340         [ +  - ]:      54002 :                                 rNativeContentRegion, this );
     341         [ -  + ]:      54002 :     if( bRet )
     342                 :            :     {
     343                 :            :         // transform back native regions
     344         [ #  # ]:          0 :         rNativeBoundingRegion = ImplDevicePixelToLogic( rNativeBoundingRegion );
     345         [ #  # ]:          0 :         rNativeContentRegion = ImplDevicePixelToLogic( rNativeContentRegion );
     346                 :            :     }
     347                 :            : 
     348         [ +  - ]:      56495 :     return bRet;
     349                 :            : }
     350                 :            : 
     351                 :            : 
     352                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10