1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
29 class AquaSalGraphics
;
31 class AquaSalInfoPrinter
: public SalInfoPrinter
34 AquaSalGraphics
* mpGraphics
;
40 /// cocoa printer object
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::unique_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
;
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( weld::Window
* 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
,
77 Size
& rPaperSize
) override
;
78 virtual sal_uInt32
GetCapabilities( const ImplJobSetup
* i_pSetupData
, PrinterCapType i_nType
) override
;
79 virtual sal_uInt16
GetPaperBinCount( const ImplJobSetup
* i_pSetupData
) override
;
80 virtual OUString
GetPaperBinName( const ImplJobSetup
* i_pSetupData
, sal_uInt16 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
);
96 SalGraphics
* StartPage( ImplJobSetup
* i_pSetupData
, bool i_bNewJobData
);
99 NSPrintInfo
* getPrintInfo() const { return mpPrintInfo
; }
100 void setStartPageOffset( int nOffsetX
, int nOffsetY
) { mnStartPageOffsetX
= nOffsetX
; mnStartPageOffsetY
= nOffsetY
; }
101 sal_Int32
getCurPageRangeStart() const { return mnCurPageRangeStart
; }
102 sal_Int32
getCurPageRangeCount() const { return mnCurPageRangeCount
; }
104 // match width/height against known paper formats, possibly switching orientation
105 const PaperInfo
* matchPaper( long i_nWidth
, long i_nHeight
, Orientation
& o_rOrientation
) const;
106 void setPaperSize( long i_nWidth
, long i_nHeight
, Orientation i_eSetOrientation
);
109 AquaSalInfoPrinter( const AquaSalInfoPrinter
& ) = delete;
110 AquaSalInfoPrinter
& operator=(const AquaSalInfoPrinter
&) = delete;
114 class AquaSalPrinter
: public SalPrinter
116 AquaSalInfoPrinter
* mpInfoPrinter
; // pointer to the compatible InfoPrinter
118 AquaSalPrinter( AquaSalInfoPrinter
* i_pInfoPrinter
);
119 virtual ~AquaSalPrinter() override
;
121 virtual bool StartJob( const OUString
* i_pFileName
,
122 const OUString
& i_rJobName
,
123 const OUString
& i_rAppName
,
124 sal_uInt32 i_nCopies
,
127 ImplJobSetup
* i_pSetupData
) override
;
128 // implement pull model print system
129 virtual bool StartJob( const OUString
* i_pFileName
,
130 const OUString
& rJobName
,
131 const OUString
& i_rAppName
,
132 ImplJobSetup
* i_pSetupData
,
133 vcl::PrinterController
& i_rListener
) override
;
135 virtual bool EndJob() override
;
136 virtual SalGraphics
* StartPage( ImplJobSetup
* i_pSetupData
, bool i_bNewJobData
) override
;
137 virtual void EndPage() override
;
140 AquaSalPrinter( const AquaSalPrinter
& ) = delete;
141 AquaSalPrinter
& operator=(const AquaSalPrinter
&) = delete;
144 const double fPtTo100thMM
= 35.27777778;
146 inline int PtTo10Mu( double nPoints
) { return static_cast<int>((nPoints
*fPtTo100thMM
)+0.5); }
148 inline double TenMuToPt( double nUnits
) { return floor((nUnits
/fPtTo100thMM
)+0.5); }
150 #endif // INCLUDED_VCL_INC_OSX_SALPRN_H
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */