LCOV - code coverage report
Current view: top level - sw/source/core/view - viewpg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 80 0.0 %
Date: 2012-08-25 Functions: 0 4 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 106 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <com/sun/star/uno/Sequence.hxx>
      31                 :            : 
      32                 :            : #include <hintids.hxx>
      33                 :            : #include <vcl/window.hxx>
      34                 :            : #include <vcl/oldprintadaptor.hxx>
      35                 :            : #include <sfx2/printer.hxx>
      36                 :            : #include <sfx2/progress.hxx>
      37                 :            : #include <pvprtdat.hxx>
      38                 :            : #include <viewsh.hxx>
      39                 :            : #include <pagefrm.hxx>
      40                 :            : #include <rootfrm.hxx>
      41                 :            : #include <viewimp.hxx>
      42                 :            : #include <viewopt.hxx>
      43                 :            : #include <printdata.hxx>
      44                 :            : #include <fldbas.hxx>
      45                 :            : #include <ptqueue.hxx>
      46                 :            : #include <swregion.hxx>
      47                 :            : #include <hints.hxx>
      48                 :            : #include <fntcache.hxx>
      49                 :            : 
      50                 :            : #include <statstr.hrc>  // Text fuer SfxProgress
      51                 :            : #include <comcore.hrc>
      52                 :            : 
      53                 :            : #include <IDocumentFieldsAccess.hxx>
      54                 :            : #include <IDocumentDeviceAccess.hxx>
      55                 :            : 
      56                 :            : 
      57                 :            : using namespace ::com::sun::star;
      58                 :            : 
      59                 :            : 
      60                 :            : SwPageFrm const*
      61                 :            : lcl_getPage(SwRootFrm const& rLayout, sal_Int32 const nPage); // vprint.cxx
      62                 :            : 
      63                 :            : // OD 12.12.2002 #103492#
      64                 :          0 : SwPagePreviewLayout* ViewShell::PagePreviewLayout()
      65                 :            : {
      66                 :          0 :     return Imp()->PagePreviewLayout();
      67                 :            : }
      68                 :            : 
      69                 :          0 : void ViewShell::ShowPreViewSelection( sal_uInt16 nSelPage )
      70                 :            : {
      71                 :          0 :     Imp()->InvalidateAccessiblePreViewSelection( nSelPage );
      72                 :          0 : }
      73                 :            : 
      74                 :            : /** adjust view options for page preview
      75                 :            : 
      76                 :            :     OD 09.01.2003 #i6467#
      77                 :            : */
      78                 :          0 : void ViewShell::AdjustOptionsForPagePreview(SwPrintData const& rPrintOptions)
      79                 :            : {
      80         [ #  # ]:          0 :     if ( !IsPreView() )
      81                 :            :     {
      82                 :            :         OSL_FAIL( "view shell doesn't belongs to a page preview - no adjustment of its view options");
      83                 :          0 :         return;
      84                 :            :     }
      85                 :            : 
      86                 :          0 :     PrepareForPrint( rPrintOptions );
      87                 :            : 
      88                 :          0 :     return;
      89                 :            : }
      90                 :            : 
      91                 :            : // print brochure
      92                 :            : // OD 05.05.2003 #i14016# - consider empty pages on calculation of the scaling
      93                 :            : // for a page to be printed.
      94                 :          0 : void ViewShell::PrintProspect(
      95                 :            :     OutputDevice *pOutDev,
      96                 :            :     const SwPrintData &rPrintData,
      97                 :            :     sal_Int32 nRenderer // the index in the vector of prospect pages to be printed
      98                 :            :     )
      99                 :            : {
     100                 :          0 :     const sal_Int32 nMaxRenderer = rPrintData.GetRenderData().GetPagePairsForProspectPrinting().size() - 1;
     101                 :            :     OSL_ENSURE( 0 <= nRenderer && nRenderer <= nMaxRenderer, "nRenderer out of bounds");
     102         [ #  # ]:          0 :     Printer *pPrinter = dynamic_cast< Printer * >(pOutDev);
     103 [ #  # ][ #  # ]:          0 :     if (!pPrinter || nMaxRenderer < 0 || nRenderer < 0 || nRenderer > nMaxRenderer)
         [ #  # ][ #  # ]
     104                 :          0 :         return;
     105                 :            : 
     106                 :            :     // save settings of OutputDevice (should be done always since the
     107                 :            :     // output device is now provided by a call from outside the Writer)
     108         [ #  # ]:          0 :     pPrinter->Push();
     109                 :            : 
     110                 :            :     std::pair< sal_Int32, sal_Int32 > rPagesToPrint =
     111         [ #  # ]:          0 :             rPrintData.GetRenderData().GetPagePairsForProspectPrinting()[ nRenderer ];
     112                 :            : // const USHORT nPageMax = static_cast< USHORT >(rPagesToPrint.first > rPagesToPrint.second ?
     113                 :            : //            rPagesToPrint.first : rPagesToPrint.second);
     114                 :            :     OSL_ENSURE( rPagesToPrint.first  == -1 || rPrintData.GetRenderData().GetValidPagesSet().count( rPagesToPrint.first ) == 1, "first Page not valid" );
     115                 :            :     OSL_ENSURE( rPagesToPrint.second == -1 || rPrintData.GetRenderData().GetValidPagesSet().count( rPagesToPrint.second ) == 1, "second Page not valid" );
     116                 :            : 
     117                 :            :     // eine neue Shell fuer den Printer erzeugen
     118         [ #  # ]:          0 :     ViewShell aShell( *this, 0, pPrinter );
     119                 :            : 
     120         [ #  # ]:          0 :     SET_CURR_SHELL( &aShell );
     121                 :            : 
     122         [ #  # ]:          0 :     aShell.PrepareForPrint( rPrintData );
     123                 :            : 
     124                 :            :     //!! applying view options and formatting the document should now only be done in getRendererCount!
     125                 :            : 
     126         [ #  # ]:          0 :     MapMode aMapMode( MAP_TWIP );
     127         [ #  # ]:          0 :     Size aPrtSize( pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), aMapMode ) );
     128                 :            : 
     129                 :            :     SwTwips nMaxRowSz, nMaxColSz;
     130                 :            : 
     131                 :          0 :     const SwPageFrm *pStPage    = 0;
     132                 :          0 :     const SwPageFrm *pNxtPage   = 0;
     133         [ #  # ]:          0 :     if (rPagesToPrint.first > 0)
     134                 :            :     {
     135 [ #  # ][ #  # ]:          0 :         pStPage = lcl_getPage(*aShell.GetLayout(), rPagesToPrint.first);
     136                 :            :     }
     137         [ #  # ]:          0 :     if (rPagesToPrint.second > 0)
     138                 :            :     {
     139 [ #  # ][ #  # ]:          0 :         pNxtPage = lcl_getPage(*aShell.GetLayout(), rPagesToPrint.second);
     140                 :            :     }
     141                 :            : 
     142                 :            :     // OD 05.05.2003 #i14016# - consider empty pages on calculation
     143                 :            :     // of page size, used for calculation of scaling.
     144                 :          0 :     Size aSttPageSize;
     145         [ #  # ]:          0 :     if ( pStPage )
     146                 :            :     {
     147         [ #  # ]:          0 :         if ( pStPage->IsEmptyPage() )
     148                 :            :         {
     149         [ #  # ]:          0 :             if ( pStPage->GetPhyPageNum() % 2 == 0 )
     150                 :          0 :                 aSttPageSize = pStPage->GetPrev()->Frm().SSize();
     151                 :            :             else
     152                 :          0 :                 aSttPageSize = pStPage->GetNext()->Frm().SSize();
     153                 :            :         }
     154                 :            :         else
     155                 :            :         {
     156                 :          0 :             aSttPageSize = pStPage->Frm().SSize();
     157                 :            :         }
     158                 :            :     }
     159                 :          0 :     Size aNxtPageSize;
     160         [ #  # ]:          0 :     if ( pNxtPage )
     161                 :            :     {
     162         [ #  # ]:          0 :         if ( pNxtPage->IsEmptyPage() )
     163                 :            :         {
     164         [ #  # ]:          0 :             if ( pNxtPage->GetPhyPageNum() % 2 == 0 )
     165                 :          0 :                 aNxtPageSize = pNxtPage->GetPrev()->Frm().SSize();
     166                 :            :             else
     167                 :          0 :                 aNxtPageSize = pNxtPage->GetNext()->Frm().SSize();
     168                 :            :         }
     169                 :            :         else
     170                 :            :         {
     171                 :          0 :             aNxtPageSize = pNxtPage->Frm().SSize();
     172                 :            :         }
     173                 :            :     }
     174                 :            : 
     175         [ #  # ]:          0 :     if( !pStPage )
     176                 :            :     {
     177                 :          0 :         nMaxColSz = 2 * aNxtPageSize.Width();
     178                 :          0 :         nMaxRowSz = aNxtPageSize.Height();
     179                 :            :     }
     180         [ #  # ]:          0 :     else if( !pNxtPage )
     181                 :            :     {
     182                 :          0 :         nMaxColSz = 2 * aSttPageSize.Width();
     183                 :          0 :         nMaxRowSz = aSttPageSize.Height();
     184                 :            :     }
     185                 :            :     else
     186                 :            :     {
     187                 :          0 :         nMaxColSz = aNxtPageSize.Width() + aSttPageSize.Width();
     188                 :          0 :         nMaxRowSz = Max( aNxtPageSize.Height(), aSttPageSize.Height() );
     189                 :            :     }
     190                 :            : 
     191                 :            :     // den MapMode einstellen
     192         [ #  # ]:          0 :     aMapMode.SetOrigin( Point() );
     193                 :            :     {
     194         [ #  # ]:          0 :         Fraction aScX( aPrtSize.Width(), nMaxColSz );
     195         [ #  # ]:          0 :         Fraction aScY( aPrtSize.Height(), nMaxRowSz );
     196 [ #  # ][ #  # ]:          0 :         if( aScX < aScY )
     197         [ #  # ]:          0 :             aScY = aScX;
     198                 :            : 
     199                 :            :         {
     200                 :            :             // fuer Drawing, damit diese ihre Objecte vernuenftig Painten
     201                 :            :             // koennen, auf "glatte" Prozentwerte setzen
     202 [ #  # ][ #  # ]:          0 :             aScY *= Fraction( 1000, 1 );
     203         [ #  # ]:          0 :             long nTmp = (long)aScY;
     204         [ #  # ]:          0 :             if( 1 < nTmp )
     205                 :          0 :                 --nTmp;
     206                 :            :             else
     207                 :          0 :                 nTmp = 1;
     208 [ #  # ][ #  # ]:          0 :             aScY = Fraction( nTmp, 1000 );
     209                 :            :         }
     210                 :            : 
     211         [ #  # ]:          0 :         aMapMode.SetScaleY( aScY );
     212         [ #  # ]:          0 :         aMapMode.SetScaleX( aScY );
     213                 :            :     }
     214                 :            : 
     215         [ #  # ]:          0 :     Size aTmpPrtSize( pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), aMapMode ) );
     216                 :            : 
     217                 :            :     // calculate start point for equal border on all sides
     218                 :          0 :     Point aSttPt( (aTmpPrtSize.Width() - nMaxColSz) / 2,
     219                 :          0 :                   (aTmpPrtSize.Height() - nMaxRowSz) / 2 );
     220         [ #  # ]:          0 :     for( int nC = 0; nC < 2; ++nC )
     221                 :            :     {
     222         [ #  # ]:          0 :         if( pStPage )
     223                 :            :         {
     224                 :          0 :             aShell.Imp()->SetFirstVisPageInvalid();
     225                 :          0 :             aShell.aVisArea = pStPage->Frm();
     226                 :            : 
     227                 :          0 :             Point aPos( aSttPt );
     228                 :          0 :             aPos -= aShell.aVisArea.Pos();
     229                 :            : //            aPos -= aPrtOff;
     230         [ #  # ]:          0 :             aMapMode.SetOrigin( aPos );
     231         [ #  # ]:          0 :             pPrinter->SetMapMode( aMapMode );
     232         [ #  # ]:          0 :             pStPage->GetUpper()->Paint( pStPage->Frm() );
     233                 :            :         }
     234                 :            : 
     235                 :          0 :         pStPage = pNxtPage;
     236                 :          0 :         aSttPt.X() += aTmpPrtSize.Width() / 2;
     237                 :            :     }
     238                 :            : 
     239         [ #  # ]:          0 :     SwPaintQueue::Repaint();
     240                 :            : 
     241                 :            :     //!! applying/modifying view options and formatting the document should now only be done in getRendererCount!
     242                 :            : 
     243         [ #  # ]:          0 :     pFntCache->Flush();
     244                 :            : 
     245                 :            :     // restore settings of OutputDevice (should be done always now since the
     246                 :            :     // output device is now provided by a call from outside the Writer)
     247 [ #  # ][ #  # ]:          0 :     pPrinter->Pop();
         [ #  # ][ #  # ]
     248                 :            : }
     249                 :            : 
     250                 :            : 
     251                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10