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

Generated by: LCOV version 1.10