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"
27 #include <boost/shared_array.hpp>
29 // - AquaSalInfoPrinter -
31 class AquaSalGraphics
;
33 class AquaSalInfoPrinter
: public SalInfoPrinter
36 AquaSalGraphics
* mpGraphics
;
42 /// cocoa printer object
44 /// cocoa print info object
45 NSPrintInfo
* mpPrintInfo
;
47 /// FIXME: get real printer context for infoprinter if possible
48 /// fake context for info printer
49 /// graphics context for Quartz 2D
50 CGContextRef mrContext
;
51 /// memory for graphics bitmap context for querying metrics
52 boost::shared_array
< sal_uInt8
> maContextMemory
;
54 // since changes to NSPrintInfo during a job are ignored
55 // we have to care for some settings ourselves
56 // currently we do this for orientation;
57 // really needed however is a solution for paper formats
58 Orientation mePageOrientation
;
60 int mnStartPageOffsetX
;
61 int mnStartPageOffsetY
;
62 sal_Int32 mnCurPageRangeStart
;
63 sal_Int32 mnCurPageRangeCount
;
66 AquaSalInfoPrinter( const SalPrinterQueueInfo
& pInfo
);
67 virtual ~AquaSalInfoPrinter();
69 void SetupPrinterGraphics( CGContextRef i_xContext
) const;
71 virtual SalGraphics
* AcquireGraphics() SAL_OVERRIDE
;
72 virtual void ReleaseGraphics( SalGraphics
* i_pGraphics
) SAL_OVERRIDE
;
73 virtual bool Setup( SalFrame
* i_pFrame
, ImplJobSetup
* i_pSetupData
) SAL_OVERRIDE
;
74 virtual bool SetPrinterData( ImplJobSetup
* pSetupData
) SAL_OVERRIDE
;
75 virtual bool SetData( sal_uLong i_nFlags
, ImplJobSetup
* i_pSetupData
) SAL_OVERRIDE
;
76 virtual void GetPageInfo( const ImplJobSetup
* i_pSetupData
,
77 long& o_rOutWidth
, long& o_rOutHeight
,
78 long& o_rPageOffX
, long& o_rPageOffY
,
79 long& o_rPageWidth
, long& o_rPageHeight
) SAL_OVERRIDE
;
80 virtual sal_uLong
GetCapabilities( const ImplJobSetup
* i_pSetupData
, sal_uInt16 i_nType
) SAL_OVERRIDE
;
81 virtual sal_uLong
GetPaperBinCount( const ImplJobSetup
* i_pSetupData
) SAL_OVERRIDE
;
82 virtual OUString
GetPaperBinName( const ImplJobSetup
* i_pSetupData
, sal_uLong i_nPaperBin
) SAL_OVERRIDE
;
83 virtual void InitPaperFormats( const ImplJobSetup
* i_pSetupData
) SAL_OVERRIDE
;
84 virtual int GetLandscapeAngle( const ImplJobSetup
* i_pSetupData
) SAL_OVERRIDE
;
86 // the artificial separation between InfoPrinter and Printer
87 // is not really useful for us
88 // so let's make AquaSalPrinter just a forwarder to AquaSalInfoPrinter
89 // and concentrate the real work in one class
90 // implement pull model print system
91 bool StartJob( const OUString
* i_pFileName
,
92 const OUString
& rJobName
,
93 const OUString
& i_rAppName
,
94 ImplJobSetup
* i_pSetupData
,
95 vcl::PrinterController
& i_rController
);
98 SalGraphics
* StartPage( ImplJobSetup
* i_pSetupData
, bool i_bNewJobData
);
100 static sal_uLong
GetErrorCode();
102 NSPrintInfo
* getPrintInfo() const { return mpPrintInfo
; }
103 void setStartPageOffset( int nOffsetX
, int nOffsetY
) { mnStartPageOffsetX
= nOffsetX
; mnStartPageOffsetY
= nOffsetY
; }
104 sal_Int32
getCurPageRangeStart() const { return mnCurPageRangeStart
; }
105 sal_Int32
getCurPageRangeCount() const { return mnCurPageRangeCount
; }
107 // match width/height against known paper formats, possibly switching orientation
108 const PaperInfo
* matchPaper( long i_nWidth
, long i_nHeight
, Orientation
& o_rOrientation
) const;
109 void setPaperSize( long i_nWidth
, long i_nHeight
, Orientation i_eSetOrientation
);
112 AquaSalInfoPrinter( const AquaSalInfoPrinter
& ) SAL_DELETED_FUNCTION
;
113 AquaSalInfoPrinter
& operator=(const AquaSalInfoPrinter
&) SAL_DELETED_FUNCTION
;
116 // - AquaSalPrinter -
118 class AquaSalPrinter
: public SalPrinter
120 AquaSalInfoPrinter
* mpInfoPrinter
; // pointer to the compatible InfoPrinter
122 AquaSalPrinter( AquaSalInfoPrinter
* i_pInfoPrinter
);
123 virtual ~AquaSalPrinter();
125 virtual bool StartJob( const OUString
* i_pFileName
,
126 const OUString
& i_rJobName
,
127 const OUString
& i_rAppName
,
131 ImplJobSetup
* i_pSetupData
) SAL_OVERRIDE
;
132 // implement pull model print system
133 virtual bool StartJob( const OUString
* i_pFileName
,
134 const OUString
& rJobName
,
135 const OUString
& i_rAppName
,
136 ImplJobSetup
* i_pSetupData
,
137 vcl::PrinterController
& i_rListener
) SAL_OVERRIDE
;
139 virtual bool EndJob() SAL_OVERRIDE
;
140 virtual bool AbortJob() SAL_OVERRIDE
;
141 virtual SalGraphics
* StartPage( ImplJobSetup
* i_pSetupData
, bool i_bNewJobData
) SAL_OVERRIDE
;
142 virtual bool EndPage() SAL_OVERRIDE
;
143 virtual sal_uLong
GetErrorCode() SAL_OVERRIDE
;
146 AquaSalPrinter( const AquaSalPrinter
& ) SAL_DELETED_FUNCTION
;
147 AquaSalPrinter
& operator=(const AquaSalPrinter
&) SAL_DELETED_FUNCTION
;
150 const double fPtTo100thMM
= 35.27777778;
152 inline int PtTo10Mu( double nPoints
) { return (int)(((nPoints
)*fPtTo100thMM
)+0.5); }
154 inline double TenMuToPt( double nUnits
) { return floor(((nUnits
)/fPtTo100thMM
)+0.5); }
156 #endif // INCLUDED_VCL_INC_OSX_SALPRN_H
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */