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

Generated by: LCOV version 1.10