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 <sal/config.h>
25 #include <tools/long.hxx>
27 #include <osx/osxvcltypes.h>
33 class AquaSalGraphics
;
35 class AquaSalInfoPrinter
: public SalInfoPrinter
38 AquaSalGraphics
* mpGraphics
;
44 /// cocoa printer object
46 /// cocoa print info object
47 NSPrintInfo
* mpPrintInfo
;
49 /// FIXME: get real printer context for infoprinter if possible
50 /// fake context for info printer
51 /// graphics context for Quartz 2D
52 CGContextRef mrContext
;
53 /// memory for graphics bitmap context for querying metrics
54 std::unique_ptr
<sal_uInt8
[]> mpContextMemory
;
56 // since changes to NSPrintInfo during a job are ignored
57 // we have to care for some settings ourselves
58 // currently we do this for orientation;
59 // really needed however is a solution for paper formats
60 Orientation mePageOrientation
;
62 int mnStartPageOffsetX
;
63 int mnStartPageOffsetY
;
64 sal_Int32 mnCurPageRangeStart
;
65 sal_Int32 mnCurPageRangeCount
;
68 AquaSalInfoPrinter( const SalPrinterQueueInfo
& pInfo
);
69 virtual ~AquaSalInfoPrinter() override
;
71 void SetupPrinterGraphics( CGContextRef i_xContext
) const;
73 virtual SalGraphics
* AcquireGraphics() override
;
74 virtual void ReleaseGraphics( SalGraphics
* i_pGraphics
) override
;
75 virtual bool Setup( weld::Window
* i_pFrame
, ImplJobSetup
* i_pSetupData
) override
;
76 virtual bool SetPrinterData( ImplJobSetup
* pSetupData
) override
;
77 virtual bool SetData( JobSetFlags i_nFlags
, ImplJobSetup
* i_pSetupData
) override
;
78 virtual void GetPageInfo( const ImplJobSetup
* i_pSetupData
,
79 tools::Long
& o_rOutWidth
, tools::Long
& o_rOutHeight
,
81 Size
& rPaperSize
) override
;
82 virtual sal_uInt32
GetCapabilities( const ImplJobSetup
* i_pSetupData
, PrinterCapType i_nType
) override
;
83 virtual sal_uInt16
GetPaperBinCount( const ImplJobSetup
* i_pSetupData
) override
;
84 virtual OUString
GetPaperBinName( const ImplJobSetup
* i_pSetupData
, sal_uInt16 i_nPaperBin
) override
;
85 virtual sal_uInt16
GetPaperBinBySourceIndex(const ImplJobSetup
* pSetupData
,
86 sal_uInt16 nPaperSource
) override
;
87 virtual sal_uInt16
GetSourceIndexByPaperBin(const ImplJobSetup
* pSetupData
,
88 sal_uInt16 nPaperBin
) override
;
89 virtual void InitPaperFormats( const ImplJobSetup
* i_pSetupData
) override
;
90 virtual int GetLandscapeAngle( const ImplJobSetup
* i_pSetupData
) override
;
92 // the artificial separation between InfoPrinter and Printer
93 // is not really useful for us
94 // so let's make AquaSalPrinter just a forwarder to AquaSalInfoPrinter
95 // and concentrate the real work in one class
96 // implement pull model print system
97 bool StartJob( const OUString
* i_pFileName
,
98 const OUString
& rJobName
,
99 ImplJobSetup
* i_pSetupData
,
100 vcl::PrinterController
& i_rController
);
103 SalGraphics
* StartPage( ImplJobSetup
* i_pSetupData
, bool i_bNewJobData
);
106 NSPrintInfo
* getPrintInfo() const { return mpPrintInfo
; }
107 void setStartPageOffset( int nOffsetX
, int nOffsetY
) { mnStartPageOffsetX
= nOffsetX
; mnStartPageOffsetY
= nOffsetY
; }
108 sal_Int32
getCurPageRangeStart() const { return mnCurPageRangeStart
; }
109 sal_Int32
getCurPageRangeCount() const { return mnCurPageRangeCount
; }
111 // match width/height against known paper formats, possibly switching orientation
112 const PaperInfo
* matchPaper(
113 tools::Long i_nWidth
, tools::Long i_nHeight
, Orientation
& o_rOrientation
) const;
114 void setPaperSize( tools::Long i_nWidth
, tools::Long i_nHeight
, Orientation i_eSetOrientation
);
117 AquaSalInfoPrinter( const AquaSalInfoPrinter
& ) = delete;
118 AquaSalInfoPrinter
& operator=(const AquaSalInfoPrinter
&) = delete;
122 class AquaSalPrinter
: public SalPrinter
124 AquaSalInfoPrinter
* mpInfoPrinter
; // pointer to the compatible InfoPrinter
126 AquaSalPrinter( AquaSalInfoPrinter
* i_pInfoPrinter
);
127 virtual ~AquaSalPrinter() override
;
129 virtual bool StartJob( const OUString
* i_pFileName
,
130 const OUString
& i_rJobName
,
131 const OUString
& i_rAppName
,
132 sal_uInt32 i_nCopies
,
135 ImplJobSetup
* i_pSetupData
) override
;
136 // implement pull model print system
137 virtual bool StartJob( const OUString
* i_pFileName
,
138 const OUString
& rJobName
,
139 const OUString
& i_rAppName
,
140 ImplJobSetup
* i_pSetupData
,
141 vcl::PrinterController
& i_rListener
) override
;
143 virtual bool EndJob() override
;
144 virtual SalGraphics
* StartPage( ImplJobSetup
* i_pSetupData
, bool i_bNewJobData
) override
;
145 virtual void EndPage() override
;
148 AquaSalPrinter( const AquaSalPrinter
& ) = delete;
149 AquaSalPrinter
& operator=(const AquaSalPrinter
&) = delete;
152 const double fPtTo100thMM
= 35.27777778;
154 inline int PtTo10Mu( double nPoints
) { return static_cast<int>((nPoints
*fPtTo100thMM
)+0.5); }
156 inline double TenMuToPt( double nUnits
) { return floor((nUnits
/fPtTo100thMM
)+0.5); }
158 #endif // INCLUDED_VCL_INC_OSX_SALPRN_H
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */