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

Generated by: LCOV version 1.10