update credits
[LibreOffice.git] / vcl / source / gdi / oldprintadaptor.cxx
blobca0cc5cd556cc0f9e9e1de4a031a9c337c06b527
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "vcl/oldprintadaptor.hxx"
22 #include "vcl/gdimtf.hxx"
24 #include "com/sun/star/awt/Size.hpp"
26 #include <vector>
28 namespace vcl
30 struct AdaptorPage
32 GDIMetaFile maPage;
33 com::sun::star::awt::Size maPageSize;
36 struct ImplOldStyleAdaptorData
38 std::vector< AdaptorPage > maPages;
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;
48 OldStylePrintAdaptor::OldStylePrintAdaptor( const boost::shared_ptr< Printer >& i_pPrinter )
49 : PrinterController( i_pPrinter )
50 , mpData( new ImplOldStyleAdaptorData() )
54 OldStylePrintAdaptor::~OldStylePrintAdaptor()
56 delete mpData;
59 void OldStylePrintAdaptor::StartPage()
61 Size aPaperSize( getPrinter()->PixelToLogic( getPrinter()->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ) );
62 mpData->maPages.push_back( AdaptorPage() );
63 mpData->maPages.back().maPageSize.Width = aPaperSize.getWidth();
64 mpData->maPages.back().maPageSize.Height = aPaperSize.getHeight();
65 getPrinter()->SetConnectMetaFile( &mpData->maPages.back().maPage );
67 // copy state into metafile
68 boost::shared_ptr<Printer> pPrinter( getPrinter() );
69 pPrinter->SetMapMode( pPrinter->GetMapMode() );
70 pPrinter->SetFont( pPrinter->GetFont() );
71 pPrinter->SetDrawMode( pPrinter->GetDrawMode() );
72 pPrinter->SetLineColor( pPrinter->GetLineColor() );
73 pPrinter->SetFillColor( pPrinter->GetFillColor() );
76 void OldStylePrintAdaptor::EndPage()
78 getPrinter()->SetConnectMetaFile( NULL );
79 mpData->maPages.back().maPage.WindStart();
82 int OldStylePrintAdaptor::getPageCount() const
84 return int(mpData->maPages.size());
87 Sequence< PropertyValue > OldStylePrintAdaptor::getPageParameters( int i_nPage ) const
89 Sequence< PropertyValue > aRet( 1 );
90 aRet[0].Name = OUString( "PageSize" );
91 if( i_nPage < int(mpData->maPages.size() ) )
92 aRet[0].Value = makeAny( mpData->maPages[i_nPage].maPageSize );
93 else
95 awt::Size aEmpty( 0, 0 );
96 aRet[0].Value = makeAny( aEmpty );
98 return aRet;
101 void OldStylePrintAdaptor::printPage( int i_nPage ) const
103 if( i_nPage < int(mpData->maPages.size()) )
105 mpData->maPages[ i_nPage ].maPage.WindStart();
106 mpData->maPages[ i_nPage ].maPage.Play( getPrinter().get() );
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */