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  struct AdaptorPage
36  {
38  css::awt::Size maPageSize;
39  };
40 
42  {
43  std::vector< AdaptorPage > maPages;
44  };
45 }
46 
48  : PrinterController(i_xPrinter, i_pWindow)
49  , mpData(new ImplOldStyleAdaptorData)
50 {
51 }
52 
54 {
55 }
56 
58 {
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 );
64 
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());
72 }
73 
75 {
76  getPrinter()->SetConnectMetaFile( nullptr );
77  mpData->maPages.back().maPage.WindStart();
78 }
79 
81 {
82  return int(mpData->maPages.size());
83 }
84 
86 {
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
92  {
93  awt::Size aEmpty( 0, 0 );
94  aRet[0].Value <<= aEmpty;
95  }
96  return aRet;
97 }
98 
99 void OldStylePrintAdaptor::printPage( int i_nPage ) const
100 {
101  if( i_nPage < int(mpData->maPages.size()) )
102  {
103  mpData->maPages[ i_nPage ].maPage.WindStart();
104  mpData->maPages[ i_nPage ].maPage.Play( getPrinter().get() );
105  }
106 }
107 
108 /* 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:1674
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:637
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:618
css::awt::Size maPageSize
DrawModeFlags GetDrawMode() const
Definition: outdev.hxx:595
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:771
virtual ~OldStylePrintAdaptor() override
long getHeight() const
long getWidth() const
const Color & GetFillColor() const
Definition: outdev.hxx:623