bump product version to 6.4.0.3
[LibreOffice.git] / vcl / source / gdi / oldprintadaptor.cxx
blobad5cb8279dadb7db4bbbb262958bd5803843063c
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 .
20 #include <vcl/oldprintadaptor.hxx>
21 #include <vcl/gdimtf.hxx>
23 #include <com/sun/star/awt/Size.hpp>
25 #include <vector>
27 using namespace vcl;
28 using namespace cppu;
29 using namespace com::sun::star;
30 using namespace com::sun::star::uno;
31 using namespace com::sun::star::beans;
33 namespace vcl
35 struct AdaptorPage
37 GDIMetaFile maPage;
38 css::awt::Size maPageSize;
41 struct ImplOldStyleAdaptorData
43 std::vector< AdaptorPage > maPages;
47 OldStylePrintAdaptor::OldStylePrintAdaptor(const VclPtr<Printer>& i_xPrinter, weld::Window* i_pWindow)
48 : PrinterController(i_xPrinter, i_pWindow)
49 , mpData(new ImplOldStyleAdaptorData)
53 OldStylePrintAdaptor::~OldStylePrintAdaptor()
57 void OldStylePrintAdaptor::StartPage()
59 Size aPaperSize( getPrinter()->PixelToLogic( getPrinter()->GetPaperSizePixel(), MapMode( MapUnit::Map100thMM ) ) );
60 mpData->maPages.emplace_back( );
61 mpData->maPages.back().maPageSize.Width = aPaperSize.getWidth();
62 mpData->maPages.back().maPageSize.Height = aPaperSize.getHeight();
63 getPrinter()->SetConnectMetaFile( &mpData->maPages.back().maPage );
65 // copy state into metafile
66 VclPtr<Printer> xPrinter( getPrinter() );
67 xPrinter->SetMapMode(xPrinter->GetMapMode());
68 xPrinter->SetFont(xPrinter->GetFont());
69 xPrinter->SetDrawMode(xPrinter->GetDrawMode());
70 xPrinter->SetLineColor(xPrinter->GetLineColor());
71 xPrinter->SetFillColor(xPrinter->GetFillColor());
74 void OldStylePrintAdaptor::EndPage()
76 getPrinter()->SetConnectMetaFile( nullptr );
77 mpData->maPages.back().maPage.WindStart();
80 int OldStylePrintAdaptor::getPageCount() const
82 return int(mpData->maPages.size());
85 Sequence< PropertyValue > OldStylePrintAdaptor::getPageParameters( int i_nPage ) const
87 Sequence< PropertyValue > aRet( 1 );
88 aRet[0].Name = "PageSize";
89 if( i_nPage < int(mpData->maPages.size() ) )
90 aRet[0].Value <<= mpData->maPages[i_nPage].maPageSize;
91 else
93 awt::Size aEmpty( 0, 0 );
94 aRet[0].Value <<= aEmpty;
96 return aRet;
99 void OldStylePrintAdaptor::printPage( int i_nPage ) const
101 if( i_nPage < int(mpData->maPages.size()) )
103 mpData->maPages[ i_nPage ].maPage.WindStart();
104 mpData->maPages[ i_nPage ].maPage.Play( getPrinter().get() );
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */