LCOV - code coverage report
Current view: top level - sw/source/core/view - viewpg.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 80 0.0 %
Date: 2014-04-11 Functions: 0 4 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 <com/sun/star/uno/Sequence.hxx>
      21             : 
      22             : #include <hintids.hxx>
      23             : #include <vcl/window.hxx>
      24             : #include <vcl/oldprintadaptor.hxx>
      25             : #include <sfx2/printer.hxx>
      26             : #include <sfx2/progress.hxx>
      27             : #include <pvprtdat.hxx>
      28             : #include <viewsh.hxx>
      29             : #include <pagefrm.hxx>
      30             : #include <rootfrm.hxx>
      31             : #include <viewimp.hxx>
      32             : #include <viewopt.hxx>
      33             : #include <printdata.hxx>
      34             : #include <fldbas.hxx>
      35             : #include <ptqueue.hxx>
      36             : #include <swregion.hxx>
      37             : #include <hints.hxx>
      38             : #include <fntcache.hxx>
      39             : 
      40             : #include <statstr.hrc>
      41             : #include <comcore.hrc>
      42             : 
      43             : #include <IDocumentFieldsAccess.hxx>
      44             : #include <IDocumentDeviceAccess.hxx>
      45             : 
      46             : using namespace ::com::sun::star;
      47             : 
      48             : SwPageFrm const*
      49             : sw_getPage(SwRootFrm const& rLayout, sal_Int32 const nPage); // vprint.cxx
      50             : 
      51             : // OD 12.12.2002 #103492#
      52           0 : SwPagePreviewLayout* SwViewShell::PagePreviewLayout()
      53             : {
      54           0 :     return Imp()->PagePreviewLayout();
      55             : }
      56             : 
      57           0 : void SwViewShell::ShowPreviewSelection( sal_uInt16 nSelPage )
      58             : {
      59           0 :     Imp()->InvalidateAccessiblePreviewSelection( nSelPage );
      60           0 : }
      61             : 
      62             : /** adjust view options for page preview
      63             : 
      64             :     OD 09.01.2003 #i6467#
      65             : */
      66           0 : void SwViewShell::AdjustOptionsForPagePreview(SwPrintData const& rPrintOptions)
      67             : {
      68           0 :     if ( !IsPreview() )
      69             :     {
      70             :         OSL_FAIL( "view shell doesn't belongs to a page preview - no adjustment of its view options");
      71           0 :         return;
      72             :     }
      73             : 
      74           0 :     PrepareForPrint( rPrintOptions );
      75             : 
      76           0 :     return;
      77             : }
      78             : 
      79             : /// print brochure
      80             : // OD 05.05.2003 #i14016# - consider empty pages on calculation of the scaling
      81             : // for a page to be printed.
      82           0 : void SwViewShell::PrintProspect(
      83             :     OutputDevice *pOutDev,
      84             :     const SwPrintData &rPrintData,
      85             :     sal_Int32 nRenderer // the index in the vector of prospect pages to be printed
      86             :     )
      87             : {
      88           0 :     const sal_Int32 nMaxRenderer = rPrintData.GetRenderData().GetPagePairsForProspectPrinting().size() - 1;
      89             :     OSL_ENSURE( 0 <= nRenderer && nRenderer <= nMaxRenderer, "nRenderer out of bounds");
      90           0 :     Printer *pPrinter = dynamic_cast< Printer * >(pOutDev);
      91           0 :     if (!pPrinter || nMaxRenderer < 0 || nRenderer < 0 || nRenderer > nMaxRenderer)
      92           0 :         return;
      93             : 
      94             :     // save settings of OutputDevice (should be done always since the
      95             :     // output device is now provided by a call from outside the Writer)
      96           0 :     pPrinter->Push();
      97             : 
      98             :     std::pair< sal_Int32, sal_Int32 > rPagesToPrint =
      99           0 :             rPrintData.GetRenderData().GetPagePairsForProspectPrinting()[ nRenderer ];
     100             :     OSL_ENSURE( rPagesToPrint.first  == -1 || rPrintData.GetRenderData().GetValidPagesSet().count( rPagesToPrint.first ) == 1, "first Page not valid" );
     101             :     OSL_ENSURE( rPagesToPrint.second == -1 || rPrintData.GetRenderData().GetValidPagesSet().count( rPagesToPrint.second ) == 1, "second Page not valid" );
     102             : 
     103             :     // create a new shell for the printer
     104           0 :     SwViewShell aShell( *this, 0, pPrinter );
     105             : 
     106           0 :     SET_CURR_SHELL( &aShell );
     107             : 
     108           0 :     aShell.PrepareForPrint( rPrintData );
     109             : 
     110             :     //!! applying view options and formatting the document should now only be done in getRendererCount!
     111             : 
     112           0 :     MapMode aMapMode( MAP_TWIP );
     113           0 :     Size aPrtSize( pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), aMapMode ) );
     114             : 
     115             :     SwTwips nMaxRowSz, nMaxColSz;
     116             : 
     117           0 :     const SwPageFrm *pStPage    = 0;
     118           0 :     const SwPageFrm *pNxtPage   = 0;
     119           0 :     if (rPagesToPrint.first > 0)
     120             :     {
     121           0 :         pStPage = sw_getPage(*aShell.GetLayout(), rPagesToPrint.first);
     122             :     }
     123           0 :     if (rPagesToPrint.second > 0)
     124             :     {
     125           0 :         pNxtPage = sw_getPage(*aShell.GetLayout(), rPagesToPrint.second);
     126             :     }
     127             : 
     128             :     // OD 05.05.2003 #i14016# - consider empty pages on calculation
     129             :     // of page size, used for calculation of scaling.
     130           0 :     Size aSttPageSize;
     131           0 :     if ( pStPage )
     132             :     {
     133           0 :         if ( pStPage->IsEmptyPage() )
     134             :         {
     135           0 :             if ( pStPage->GetPhyPageNum() % 2 == 0 )
     136           0 :                 aSttPageSize = pStPage->GetPrev()->Frm().SSize();
     137             :             else
     138           0 :                 aSttPageSize = pStPage->GetNext()->Frm().SSize();
     139             :         }
     140             :         else
     141             :         {
     142           0 :             aSttPageSize = pStPage->Frm().SSize();
     143             :         }
     144             :     }
     145           0 :     Size aNxtPageSize;
     146           0 :     if ( pNxtPage )
     147             :     {
     148           0 :         if ( pNxtPage->IsEmptyPage() )
     149             :         {
     150           0 :             if ( pNxtPage->GetPhyPageNum() % 2 == 0 )
     151           0 :                 aNxtPageSize = pNxtPage->GetPrev()->Frm().SSize();
     152             :             else
     153           0 :                 aNxtPageSize = pNxtPage->GetNext()->Frm().SSize();
     154             :         }
     155             :         else
     156             :         {
     157           0 :             aNxtPageSize = pNxtPage->Frm().SSize();
     158             :         }
     159             :     }
     160             : 
     161           0 :     if( !pStPage )
     162             :     {
     163           0 :         nMaxColSz = 2 * aNxtPageSize.Width();
     164           0 :         nMaxRowSz = aNxtPageSize.Height();
     165             :     }
     166           0 :     else if( !pNxtPage )
     167             :     {
     168           0 :         nMaxColSz = 2 * aSttPageSize.Width();
     169           0 :         nMaxRowSz = aSttPageSize.Height();
     170             :     }
     171             :     else
     172             :     {
     173           0 :         nMaxColSz = aNxtPageSize.Width() + aSttPageSize.Width();
     174           0 :         nMaxRowSz = std::max( aNxtPageSize.Height(), aSttPageSize.Height() );
     175             :     }
     176             : 
     177             :     // set the MapMode
     178           0 :     aMapMode.SetOrigin( Point() );
     179             :     {
     180           0 :         Fraction aScX( aPrtSize.Width(), nMaxColSz );
     181           0 :         Fraction aScY( aPrtSize.Height(), nMaxRowSz );
     182           0 :         if( aScX < aScY )
     183           0 :             aScY = aScX;
     184             : 
     185             :         {
     186             :             // Round percentages for Drawings so that these can paint their objects properly
     187           0 :             aScY *= Fraction( 1000, 1 );
     188           0 :             long nTmp = (long)aScY;
     189           0 :             if( 1 < nTmp )
     190           0 :                 --nTmp;
     191             :             else
     192           0 :                 nTmp = 1;
     193           0 :             aScY = Fraction( nTmp, 1000 );
     194             :         }
     195             : 
     196           0 :         aMapMode.SetScaleY( aScY );
     197           0 :         aMapMode.SetScaleX( aScY );
     198             :     }
     199             : 
     200           0 :     Size aTmpPrtSize( pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), aMapMode ) );
     201             : 
     202             :     // calculate start point for equal border on all sides
     203           0 :     Point aSttPt( (aTmpPrtSize.Width() - nMaxColSz) / 2,
     204           0 :                   (aTmpPrtSize.Height() - nMaxRowSz) / 2 );
     205           0 :     for( int nC = 0; nC < 2; ++nC )
     206             :     {
     207           0 :         if( pStPage )
     208             :         {
     209           0 :             aShell.Imp()->SetFirstVisPageInvalid();
     210           0 :             aShell.maVisArea = pStPage->Frm();
     211             : 
     212           0 :             Point aPos( aSttPt );
     213           0 :             aPos -= aShell.maVisArea.Pos();
     214           0 :             aMapMode.SetOrigin( aPos );
     215           0 :             pPrinter->SetMapMode( aMapMode );
     216           0 :             pStPage->GetUpper()->Paint( pStPage->Frm() );
     217             :         }
     218             : 
     219           0 :         pStPage = pNxtPage;
     220           0 :         aSttPt.X() += aTmpPrtSize.Width() / 2;
     221             :     }
     222             : 
     223           0 :     SwPaintQueue::Repaint();
     224             : 
     225             :     //!! applying/modifying view options and formatting the document should now only be done in getRendererCount!
     226             : 
     227           0 :     pFntCache->Flush();
     228             : 
     229             :     // restore settings of OutputDevice (should be done always now since the
     230             :     // output device is now provided by a call from outside the Writer)
     231           0 :     pPrinter->Pop();
     232             : }
     233             : 
     234             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10