LCOV - code coverage report
Current view: top level - libreoffice/vcl/source/gdi - oldprintadaptor.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 40 0.0 %
Date: 2012-12-27 Functions: 0 13 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 "vcl/oldprintadaptor.hxx"
      22             : #include "vcl/gdimtf.hxx"
      23             : 
      24             : #include "com/sun/star/awt/Size.hpp"
      25             : 
      26             : #include <vector>
      27             : 
      28             : namespace vcl
      29             : {
      30           0 :     struct AdaptorPage
      31             :     {
      32             :         GDIMetaFile                     maPage;
      33             :         com::sun::star::awt::Size       maPageSize;
      34             :     };
      35             : 
      36           0 :     struct ImplOldStyleAdaptorData
      37             :     {
      38             :         std::vector< AdaptorPage >  maPages;
      39             :     };
      40             : }
      41             : 
      42             : using namespace vcl;
      43             : using namespace cppu;
      44             : using namespace com::sun::star;
      45             : using namespace com::sun::star::uno;
      46             : using namespace com::sun::star::beans;
      47             : 
      48           0 : OldStylePrintAdaptor::OldStylePrintAdaptor( const boost::shared_ptr< Printer >& i_pPrinter )
      49             :     : PrinterController( i_pPrinter )
      50           0 :     , mpData( new ImplOldStyleAdaptorData() )
      51             : {
      52           0 : }
      53             : 
      54           0 : OldStylePrintAdaptor::~OldStylePrintAdaptor()
      55             : {
      56           0 :     delete mpData;
      57           0 : }
      58             : 
      59           0 : void OldStylePrintAdaptor::StartPage()
      60             : {
      61           0 :     Size aPaperSize( getPrinter()->PixelToLogic( getPrinter()->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ) );
      62           0 :     mpData->maPages.push_back( AdaptorPage() );
      63           0 :     mpData->maPages.back().maPageSize.Width = aPaperSize.getWidth();
      64           0 :     mpData->maPages.back().maPageSize.Height = aPaperSize.getHeight();
      65           0 :     getPrinter()->SetConnectMetaFile( &mpData->maPages.back().maPage );
      66             : 
      67             :     // copy state into metafile
      68           0 :     boost::shared_ptr<Printer> pPrinter( getPrinter() );
      69           0 :     pPrinter->SetMapMode( pPrinter->GetMapMode() );
      70           0 :     pPrinter->SetFont( pPrinter->GetFont() );
      71           0 :     pPrinter->SetDrawMode( pPrinter->GetDrawMode() );
      72           0 :     pPrinter->SetLineColor( pPrinter->GetLineColor() );
      73           0 :     pPrinter->SetFillColor( pPrinter->GetFillColor() );
      74           0 : }
      75             : 
      76           0 : void OldStylePrintAdaptor::EndPage()
      77             : {
      78           0 :     getPrinter()->SetConnectMetaFile( NULL );
      79           0 :     mpData->maPages.back().maPage.WindStart();
      80           0 : }
      81             : 
      82           0 : int  OldStylePrintAdaptor::getPageCount() const
      83             : {
      84           0 :     return int(mpData->maPages.size());
      85             : }
      86             : 
      87           0 : Sequence< PropertyValue > OldStylePrintAdaptor::getPageParameters( int i_nPage ) const
      88             : {
      89           0 :     Sequence< PropertyValue > aRet( 1 );
      90           0 :     aRet[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PageSize") );
      91           0 :     if( i_nPage < int(mpData->maPages.size() ) )
      92           0 :         aRet[0].Value = makeAny( mpData->maPages[i_nPage].maPageSize );
      93             :     else
      94             :     {
      95           0 :         awt::Size aEmpty( 0, 0  );
      96           0 :         aRet[0].Value = makeAny( aEmpty );
      97             :     }
      98           0 :     return aRet;
      99             : }
     100             : 
     101           0 : void OldStylePrintAdaptor::printPage( int i_nPage ) const
     102             : {
     103           0 :     if( i_nPage < int(mpData->maPages.size()) )
     104             :    {
     105           0 :        mpData->maPages[ i_nPage ].maPage.WindStart();
     106           0 :        mpData->maPages[ i_nPage ].maPage.Play( getPrinter().get() );
     107             :    }
     108           0 : }
     109             : 
     110             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10