LCOV - code coverage report
Current view: top level - sw/source/core/layout - virtoutp.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 4 68 5.9 %
Date: 2014-11-03 Functions: 3 8 37.5 %
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 "virtoutp.hxx"
      21             : #include "viewopt.hxx"
      22             : #include "rootfrm.hxx"
      23             : 
      24             : #if OSL_DEBUG_LEVEL > 1
      25             : 
      26             : class DbgRect
      27             : {
      28             :         OutputDevice *pOut;
      29             : public:
      30             :         DbgRect( OutputDevice *pOut, const Rectangle &rRect,
      31             :                  const ColorData eColor = COL_LIGHTBLUE );
      32             : };
      33             : 
      34             : inline DbgRect::DbgRect( OutputDevice *pOutDev, const Rectangle &rRect,
      35             :                          const ColorData eColor )
      36             :    :pOut( pOutDev )
      37             : {
      38             :     if( pOut )
      39             :     {
      40             :         pOut->Push( PushFlags::FILLCOLOR|PushFlags::LINECOLOR );
      41             :         pOut->SetLineColor( eColor );
      42             :         pOut->SetFillColor();
      43             :         pOut->DrawRect( rRect );
      44             :         pOut->Pop();
      45             :     }
      46             : }
      47             : 
      48             : #endif
      49             : 
      50             : /* The SWLayVout class manages the virtual output devices.
      51             :  * RootFrm has a static member of this class which is created in _FrmInit
      52             :  * and destroyed in _FrmFinit.
      53             :  * */
      54             : 
      55           0 : bool SwRootFrm::FlushVout()
      56             : {
      57           0 :     if( SwRootFrm::pVout->IsFlushable() )
      58             :     {
      59           0 :         SwRootFrm::pVout->_Flush();
      60           0 :         return true;
      61             :     }
      62           0 :     return false;
      63             : }
      64             : 
      65       12941 : bool SwRootFrm::HasSameRect( const SwRect& rRect )
      66             : {
      67       12941 :     if( SwRootFrm::pVout->IsFlushable() )
      68           0 :         return ( rRect == SwRootFrm::pVout->GetOrgRect() );
      69       12941 :     return false;
      70             : }
      71             : 
      72             : /** method to set mapping/pixel offset for virtual output device
      73             : 
      74             :     OD 12.11.2002 #96272# - method implements two solutions for the mapping of
      75             :     the virtual output device:
      76             :     The old solution set the origin of the mapping mode, which will be used in
      77             :     the virtual output device. This causes several paint errors, because of the
      78             :     different roundings in the virtual output device and the original output device.
      79             :     The new solution avoids the rounding differences between virtual and original
      80             :     output device by setting a pixel offset at the virtual output device.
      81             :     A define controls, which solution is used, in order to switch in escalation
      82             :     back to old solution.
      83             : 
      84             :     @param _pOrgOutDev
      85             :     input parameter - constant instance of the original output device, for which
      86             :     the virtual output device is created.
      87             : 
      88             :     @param _pVirDev
      89             :     input/output parameter - instance of the virtual output device.
      90             : 
      91             :     @param _pMapMode
      92             :     input/output parameter - instance of the mapping mode, which will be set
      93             :     at the virtual output device.
      94             : 
      95             :     @param _rNewOrigin
      96             :     input parameter - constant instance of the origin, which will be used in
      97             :     the virtual output device
      98             : */
      99             : // define to control, if old or new solution for setting the mapping for
     100             : // an virtual output device is used.
     101           0 : void SetMappingForVirtDev(  const Point&    _rNewOrigin,
     102             :                             MapMode*        ,
     103             :                             const OutputDevice* _pOrgOutDev,
     104             :                             VirtualDevice*  _pVirDev )
     105             : {
     106             :         // new solution: set pixel offset at virtual output device
     107           0 :         Point aPixelOffset = _pOrgOutDev->LogicToPixel( _rNewOrigin );
     108           0 :         _pVirDev->SetPixelOffset( Size( -aPixelOffset.X(), -aPixelOffset.Y() ) );
     109           0 : }
     110             : 
     111             : // rSize must be pixel coordinates!
     112           0 : bool SwLayVout::DoesFit( const Size &rNew )
     113             : {
     114           0 :     if( rNew.Height() > VIRTUALHEIGHT )
     115           0 :         return false;
     116           0 :     if( rNew.Width() <= 0 || rNew.Height() <= 0 )
     117           0 :         return false;
     118           0 :     if( rNew.Width() <= aSize.Width() )
     119           0 :         return true;
     120           0 :     if( !pVirDev )
     121             :     {
     122           0 :         pVirDev = new VirtualDevice();
     123           0 :         pVirDev->SetLineColor();
     124           0 :         if( pOut )
     125             :         {
     126           0 :             if( pVirDev->GetFillColor() != pOut->GetFillColor() )
     127           0 :                 pVirDev->SetFillColor( pOut->GetFillColor() );
     128             :         }
     129             :     }
     130             : 
     131           0 :     if( rNew.Width() > aSize.Width() )
     132             :     {
     133           0 :         aSize.Width() = rNew.Width();
     134           0 :         if( !pVirDev->SetOutputSizePixel( aSize ) )
     135             :         {
     136           0 :             delete pVirDev;
     137           0 :             pVirDev = NULL;
     138           0 :             aSize.Width() = 0;
     139           0 :             return false;
     140             :         }
     141             :     }
     142           0 :     return true;
     143             : }
     144             : 
     145             : /// OD 27.09.2002 #103636# - change 2nd parameter <rRect> - no longer <const>
     146             : ///     in order to return value of class member variable <aRect>, if virtual
     147             : ///     output is used.
     148             : ///     <aRect> contains the rectangle that represents the area the virtual
     149             : ///     output device is used for and that is flushed at the end.
     150           0 : void SwLayVout::Enter(  SwViewShell *pShell, SwRect &rRect, bool bOn )
     151             : {
     152           0 :     Flush();
     153             : 
     154             : #ifdef DBG_UTIL
     155             :         if( pShell->GetViewOptions()->IsTest3() )
     156             :         {
     157             :             ++nCount;
     158             :             return;
     159             :         }
     160             : #endif
     161             : 
     162           0 :     bOn = bOn && !nCount && rRect.HasArea() && pShell->GetWin();
     163           0 :     ++nCount;
     164           0 :     if( bOn )
     165             :     {
     166           0 :         pSh = pShell;
     167           0 :         pOut = NULL;
     168           0 :         OutputDevice *pO = pSh->GetOut();
     169             : // We don't cheat on printers or virtual output devices...
     170           0 :         if( OUTDEV_WINDOW != pO->GetOutDevType() )
     171           0 :             return;
     172             : 
     173           0 :         pOut = pO;
     174           0 :         Size aPixSz( pOut->PixelToLogic( Size( 1,1 )) );
     175           0 :         SwRect aTmp( rRect );
     176           0 :         aTmp.SSize().Width() += aPixSz.Width()/2 + 1;
     177           0 :         aTmp.SSize().Height()+= aPixSz.Height()/2 + 1;
     178           0 :         Rectangle aTmpRect( pO->LogicToPixel( aTmp.SVRect() ) );
     179             : 
     180             :         OSL_ENSURE( !pSh->GetWin()->IsReallyVisible() ||
     181             :                 aTmpRect.GetWidth() <= pSh->GetWin()->GetOutputSizePixel().Width() + 2,
     182             :                 "Paintwidth bigger than visarea?" );
     183             :         // Does the rectangle fit in our buffer?
     184           0 :         if( !DoesFit( aTmpRect.GetSize() ) )
     185             :         {
     186           0 :             pOut = NULL;
     187           0 :             return;
     188             :         }
     189             : 
     190           0 :         aRect = SwRect( pO->PixelToLogic( aTmpRect ) );
     191             : 
     192           0 :         SetOutDev( pSh, pVirDev );
     193             : 
     194           0 :         if( pVirDev->GetFillColor() != pOut->GetFillColor() )
     195           0 :             pVirDev->SetFillColor( pOut->GetFillColor() );
     196             : 
     197           0 :         MapMode aMapMode( pOut->GetMapMode() );
     198             :         // OD 12.11.2002 #96272# - use method to set mapping
     199             :         //aMapMode.SetOrigin( Point(0,0) - aRect.Pos() );
     200           0 :         ::SetMappingForVirtDev( aRect.Pos(), &aMapMode, pOut, pVirDev );
     201             : 
     202           0 :         if( aMapMode != pVirDev->GetMapMode() )
     203           0 :             pVirDev->SetMapMode( aMapMode );
     204             : 
     205             :         /// OD 27.09.2002 #103636# - set value of parameter <rRect>
     206           0 :         rRect = aRect;
     207             :     }
     208             : }
     209             : 
     210           0 : void SwLayVout::_Flush()
     211             : {
     212             :     OSL_ENSURE( pVirDev, "SwLayVout::DrawOut: nothing left Toulouse" );
     213           0 :     pOut->DrawOutDev( aRect.Pos(), aRect.SSize(),
     214           0 :                       aRect.Pos(), aRect.SSize(), *pVirDev );
     215           0 :     SetOutDev( pSh, pOut );
     216           0 :     pOut = NULL;
     217         270 : }
     218             : 
     219             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10