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

Generated by: LCOV version 1.10