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

Generated by: LCOV version 1.10