build fix
[LibreOffice.git] / vcl / inc / osx / salprn.h
blobf47a32b07bb58cbadf3fc2a121ac454019fc3c3e
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 #ifndef INCLUDED_VCL_INC_OSX_SALPRN_H
21 #define INCLUDED_VCL_INC_OSX_SALPRN_H
23 #include "osx/osxvcltypes.h"
25 #include "salprn.hxx"
27 #include <memory>
29 class AquaSalGraphics;
31 class AquaSalInfoPrinter : public SalInfoPrinter
33 /// Printer graphics
34 AquaSalGraphics* mpGraphics;
35 /// is Graphics used
36 bool mbGraphics;
37 /// job active ?
38 bool mbJob;
40 /// cocoa printer object
41 NSPrinter* mpPrinter;
42 /// cocoa print info object
43 NSPrintInfo* mpPrintInfo;
45 /// FIXME: get real printer context for infoprinter if possible
46 /// fake context for info printer
47 /// graphics context for Quartz 2D
48 CGContextRef mrContext;
49 /// memory for graphics bitmap context for querying metrics
50 std::shared_ptr<sal_uInt8> mpContextMemory;
52 // since changes to NSPrintInfo during a job are ignored
53 // we have to care for some settings ourselves
54 // currently we do this for orientation;
55 // really needed however is a solution for paper formats
56 Orientation mePageOrientation;
58 int mnStartPageOffsetX;
59 int mnStartPageOffsetY;
60 sal_Int32 mnCurPageRangeStart;
61 sal_Int32 mnCurPageRangeCount;
63 public:
64 AquaSalInfoPrinter( const SalPrinterQueueInfo& pInfo );
65 virtual ~AquaSalInfoPrinter() override;
67 void SetupPrinterGraphics( CGContextRef i_xContext ) const;
69 virtual SalGraphics* AcquireGraphics() override;
70 virtual void ReleaseGraphics( SalGraphics* i_pGraphics ) override;
71 virtual bool Setup( SalFrame* i_pFrame, ImplJobSetup* i_pSetupData ) override;
72 virtual bool SetPrinterData( ImplJobSetup* pSetupData ) override;
73 virtual bool SetData( JobSetFlags i_nFlags, ImplJobSetup* i_pSetupData ) override;
74 virtual void GetPageInfo( const ImplJobSetup* i_pSetupData,
75 long& o_rOutWidth, long& o_rOutHeight,
76 long& o_rPageOffX, long& o_rPageOffY,
77 long& o_rPageWidth, long& o_rPageHeight ) override;
78 virtual sal_uInt32 GetCapabilities( const ImplJobSetup* i_pSetupData, PrinterCapType i_nType ) override;
79 virtual sal_uLong GetPaperBinCount( const ImplJobSetup* i_pSetupData ) override;
80 virtual OUString GetPaperBinName( const ImplJobSetup* i_pSetupData, sal_uLong i_nPaperBin ) override;
81 virtual void InitPaperFormats( const ImplJobSetup* i_pSetupData ) override;
82 virtual int GetLandscapeAngle( const ImplJobSetup* i_pSetupData ) override;
84 // the artificial separation between InfoPrinter and Printer
85 // is not really useful for us
86 // so let's make AquaSalPrinter just a forwarder to AquaSalInfoPrinter
87 // and concentrate the real work in one class
88 // implement pull model print system
89 bool StartJob( const OUString* i_pFileName,
90 const OUString& rJobName,
91 const OUString& i_rAppName,
92 ImplJobSetup* i_pSetupData,
93 vcl::PrinterController& i_rController );
94 bool EndJob();
95 bool AbortJob();
96 SalGraphics* StartPage( ImplJobSetup* i_pSetupData, bool i_bNewJobData );
97 bool EndPage();
98 static sal_uLong GetErrorCode();
100 NSPrintInfo* getPrintInfo() const { return mpPrintInfo; }
101 void setStartPageOffset( int nOffsetX, int nOffsetY ) { mnStartPageOffsetX = nOffsetX; mnStartPageOffsetY = nOffsetY; }
102 sal_Int32 getCurPageRangeStart() const { return mnCurPageRangeStart; }
103 sal_Int32 getCurPageRangeCount() const { return mnCurPageRangeCount; }
105 // match width/height against known paper formats, possibly switching orientation
106 const PaperInfo* matchPaper( long i_nWidth, long i_nHeight, Orientation& o_rOrientation ) const;
107 void setPaperSize( long i_nWidth, long i_nHeight, Orientation i_eSetOrientation );
109 private:
110 AquaSalInfoPrinter( const AquaSalInfoPrinter& ) = delete;
111 AquaSalInfoPrinter& operator=(const AquaSalInfoPrinter&) = delete;
115 class AquaSalPrinter : public SalPrinter
117 AquaSalInfoPrinter* mpInfoPrinter; // pointer to the compatible InfoPrinter
118 public:
119 AquaSalPrinter( AquaSalInfoPrinter* i_pInfoPrinter );
120 virtual ~AquaSalPrinter() override;
122 virtual bool StartJob( const OUString* i_pFileName,
123 const OUString& i_rJobName,
124 const OUString& i_rAppName,
125 sal_uInt32 i_nCopies,
126 bool i_bCollate,
127 bool i_bDirect,
128 ImplJobSetup* i_pSetupData ) override;
129 // implement pull model print system
130 virtual bool StartJob( const OUString* i_pFileName,
131 const OUString& rJobName,
132 const OUString& i_rAppName,
133 ImplJobSetup* i_pSetupData,
134 vcl::PrinterController& i_rListener ) override;
136 virtual bool EndJob() override;
137 virtual SalGraphics* StartPage( ImplJobSetup* i_pSetupData, bool i_bNewJobData ) override;
138 virtual void EndPage() override;
139 virtual sal_uLong GetErrorCode() override;
141 private:
142 AquaSalPrinter( const AquaSalPrinter& ) = delete;
143 AquaSalPrinter& operator=(const AquaSalPrinter&) = delete;
146 const double fPtTo100thMM = 35.27777778;
148 inline int PtTo10Mu( double nPoints ) { return (int)(((nPoints)*fPtTo100thMM)+0.5); }
150 inline double TenMuToPt( double nUnits ) { return floor(((nUnits)/fPtTo100thMM)+0.5); }
152 #endif // INCLUDED_VCL_INC_OSX_SALPRN_H
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */