LCOV - code coverage report
Current view: top level - sw/source/core/layout - virtoutp.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 4 67 6.0 %
Date: 2015-06-13 12:38:46 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::mpVout->IsFlushable() )
      58             :     {
      59           0 :         SwRootFrm::mpVout->_Flush();
      60           0 :         return true;
      61             :     }
      62           0 :     return false;
      63             : }
      64             : 
      65        7668 : bool SwRootFrm::HasSameRect( const SwRect& rRect )
      66             : {
      67        7668 :     if( SwRootFrm::mpVout->IsFlushable() )
      68           0 :         return ( rRect == SwRootFrm::mpVout->GetOrgRect() );
      69        7668 :     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 vcl::RenderContext* _pOrgOutDev,
     104             :                             vcl::RenderContext*  _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 = VclPtr<VirtualDevice>::Create();
     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 :             pVirDev.disposeAndClear();
     137           0 :             aSize.Width() = 0;
     138           0 :             return false;
     139             :         }
     140             :     }
     141           0 :     return true;
     142             : }
     143             : 
     144             : /// OD 27.09.2002 #103636# - change 2nd parameter <rRect> - no longer <const>
     145             : ///     in order to return value of class member variable <aRect>, if virtual
     146             : ///     output is used.
     147             : ///     <aRect> contains the rectangle that represents the area the virtual
     148             : ///     output device is used for and that is flushed at the end.
     149           0 : void SwLayVout::Enter(  SwViewShell *pShell, SwRect &rRect, bool bOn )
     150             : {
     151           0 :     Flush();
     152             : 
     153             : #ifdef DBG_UTIL
     154             :         if( pShell->GetViewOptions()->IsTest3() )
     155             :         {
     156             :             ++nCount;
     157             :             return;
     158             :         }
     159             : #endif
     160             : 
     161           0 :     bOn = bOn && !nCount && rRect.HasArea() && pShell->GetWin();
     162           0 :     ++nCount;
     163           0 :     if( bOn )
     164             :     {
     165           0 :         pSh = pShell;
     166           0 :         pOut = NULL;
     167           0 :         OutputDevice *pO = pSh->GetOut();
     168             : // We don't cheat on printers or virtual output devices...
     169           0 :         if( OUTDEV_WINDOW != pO->GetOutDevType() )
     170           0 :             return;
     171             : 
     172           0 :         pOut = pO;
     173           0 :         Size aPixSz( pOut->PixelToLogic( Size( 1,1 )) );
     174           0 :         SwRect aTmp( rRect );
     175           0 :         aTmp.SSize().Width() += aPixSz.Width()/2 + 1;
     176           0 :         aTmp.SSize().Height()+= aPixSz.Height()/2 + 1;
     177           0 :         Rectangle aTmpRect( pO->LogicToPixel( aTmp.SVRect() ) );
     178             : 
     179             :         OSL_ENSURE( !pSh->GetWin()->IsReallyVisible() ||
     180             :                 aTmpRect.GetWidth() <= pSh->GetWin()->GetOutputSizePixel().Width() + 2,
     181             :                 "Paintwidth bigger than visarea?" );
     182             :         // Does the rectangle fit in our buffer?
     183           0 :         if( !DoesFit( aTmpRect.GetSize() ) )
     184             :         {
     185           0 :             pOut = NULL;
     186           0 :             return;
     187             :         }
     188             : 
     189           0 :         aRect = SwRect( pO->PixelToLogic( aTmpRect ) );
     190             : 
     191           0 :         SetOutDev( pSh, pVirDev );
     192             : 
     193           0 :         if( pVirDev->GetFillColor() != pOut->GetFillColor() )
     194           0 :             pVirDev->SetFillColor( pOut->GetFillColor() );
     195             : 
     196           0 :         MapMode aMapMode( pOut->GetMapMode() );
     197             :         // OD 12.11.2002 #96272# - use method to set mapping
     198             :         //aMapMode.SetOrigin( Point(0,0) - aRect.Pos() );
     199           0 :         ::SetMappingForVirtDev( aRect.Pos(), &aMapMode, pOut, pVirDev );
     200             : 
     201           0 :         if( aMapMode != pVirDev->GetMapMode() )
     202           0 :             pVirDev->SetMapMode( aMapMode );
     203             : 
     204             :         /// OD 27.09.2002 #103636# - set value of parameter <rRect>
     205           0 :         rRect = aRect;
     206             :     }
     207             : }
     208             : 
     209           0 : void SwLayVout::_Flush()
     210             : {
     211             :     OSL_ENSURE( pVirDev, "SwLayVout::DrawOut: nothing left Toulouse" );
     212           0 :     pOut->DrawOutDev( aRect.Pos(), aRect.SSize(),
     213           0 :                       aRect.Pos(), aRect.SSize(), *pVirDev );
     214           0 :     SetOutDev( pSh, pOut );
     215           0 :     pOut = NULL;
     216         177 : }
     217             : 
     218             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11