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

Generated by: LCOV version 1.11