LibreOffice Module vcl (master)  1
oldprintadaptor.cxx
Go to the documentation of this file.
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 #include <vcl/oldprintadaptor.hxx>
21 #include <vcl/gdimtf.hxx>
22 
23 #include <com/sun/star/awt/Size.hpp>
24 
25 #include <vector>
26 
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;
32 
33 namespace vcl
34 {
35  namespace {
36 
37  struct AdaptorPage
38  {
39  GDIMetaFile maPage;
40  css::awt::Size maPageSize;
41  };
42 
43  }
44 
46  {
47  std::vector< AdaptorPage > maPages;
48  };
49 }
50 
52  : PrinterController(i_xPrinter, i_pWindow)
53  , mpData(new ImplOldStyleAdaptorData)
54 {
55 }
56 
58 {
59 }
60 
62 {
63  Size aPaperSize( getPrinter()->PixelToLogic( getPrinter()->GetPaperSizePixel(), MapMode( MapUnit::Map100thMM ) ) );
64  mpData->maPages.emplace_back( );
65  mpData->maPages.back().maPageSize.Width = aPaperSize.getWidth();
66  mpData->maPages.back().maPageSize.Height = aPaperSize.getHeight();
67  getPrinter()->SetConnectMetaFile( &mpData->maPages.back().maPage );
68 
69  // copy state into metafile
70  VclPtr<Printer> xPrinter( getPrinter() );
71  xPrinter->SetMapMode(xPrinter->GetMapMode());
72  xPrinter->SetFont(xPrinter->GetFont());
73  xPrinter->SetDrawMode(xPrinter->GetDrawMode());
74  xPrinter->SetLineColor(xPrinter->GetLineColor());
75  xPrinter->SetFillColor(xPrinter->GetFillColor());
76 }
77 
79 {
80  getPrinter()->SetConnectMetaFile( nullptr );
81  mpData->maPages.back().maPage.WindStart();
82 }
83 
85 {
86  return int(mpData->maPages.size());
87 }
88 
90 {
91  Sequence< PropertyValue > aRet( 1 );
92  aRet[0].Name = "PageSize";
93  if( i_nPage < int(mpData->maPages.size() ) )
94  aRet[0].Value <<= mpData->maPages[i_nPage].maPageSize;
95  else
96  {
97  awt::Size aEmpty( 0, 0 );
98  aRet[0].Value <<= aEmpty;
99  }
100  return aRet;
101 }
102 
103 void OldStylePrintAdaptor::printPage( int i_nPage ) const
104 {
105  if( i_nPage < int(mpData->maPages.size()) )
106  {
107  mpData->maPages[ i_nPage ].maPage.WindStart();
108  mpData->maPages[ i_nPage ].maPage.Play( getPrinter().get() );
109  }
110 }
111 
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OldStylePrintAdaptor(const VclPtr< Printer > &, weld::Window *)
const wchar_t *typedef int(__stdcall *DllNativeUnregProc)(int
const MapMode & GetMapMode() const
Definition: outdev.hxx:1681
std::vector< AdaptorPage > maPages
virtual void printPage(int i_nPage) const override
App must override this.
void SetMapMode()
Definition: map.cxx:655
void SetDrawMode(DrawModeFlags nDrawMode)
const vcl::Font & GetFont() const
Definition: outdev.hxx:643
const ::basegfx::B2DSize maPageSize
virtual css::uno::Sequence< css::beans::PropertyValue > getPageParameters(int i_nPage) const override
Get the page parameters.
void SetLineColor()
void SetConnectMetaFile(GDIMetaFile *pMtf)
Definition: outdev.cxx:208
void SetFillColor()
const Color & GetLineColor() const
Definition: outdev.hxx:624
DrawModeFlags GetDrawMode() const
Definition: outdev.hxx:601
virtual int getPageCount() const override
App must override this.
std::unique_ptr< ImplOldStyleAdaptorData > mpData
void SetFont(const vcl::Font &rNewFont)
const VclPtr< Printer > & getPrinter() const
Definition: print3.cxx:779
virtual ~OldStylePrintAdaptor() override
long getHeight() const
long getWidth() const
const Color & GetFillColor() const
Definition: outdev.hxx:629