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 .
23 #include "aqua/aquavcltypes.h"
27 #include <boost/shared_array.hpp>
30 // ---------------------
31 // - AquaSalInfoPrinter -
32 // ---------------------
34 class AquaSalGraphics
;
36 class AquaSalInfoPrinter
: public SalInfoPrinter
39 AquaSalGraphics
* mpGraphics
;
45 /// cocoa printer object
47 /// cocoa print info object
48 NSPrintInfo
* mpPrintInfo
;
50 /// FIXME: get real printer context for infoprinter if possible
51 /// fake context for info printer
52 /// graphics context for Quartz 2D
53 CGContextRef mrContext
;
54 /// memory for graphics bitmap context for querying metrics
55 boost::shared_array
< sal_uInt8
> maContextMemory
;
57 // since changes to NSPrintInfo during a job are ignored
58 // we have to care for some settings ourselves
59 // currently we do this for orientation;
60 // really needed however is a solution for paper formats
61 Orientation mePageOrientation
;
63 int mnStartPageOffsetX
;
64 int mnStartPageOffsetY
;
65 sal_Int32 mnCurPageRangeStart
;
66 sal_Int32 mnCurPageRangeCount
;
69 AquaSalInfoPrinter( const SalPrinterQueueInfo
& pInfo
);
70 virtual ~AquaSalInfoPrinter();
72 void SetupPrinterGraphics( CGContextRef i_xContext
) const;
74 virtual SalGraphics
* GetGraphics();
75 virtual void ReleaseGraphics( SalGraphics
* i_pGraphics
);
76 virtual sal_Bool
Setup( SalFrame
* i_pFrame
, ImplJobSetup
* i_pSetupData
);
77 virtual sal_Bool
SetPrinterData( ImplJobSetup
* pSetupData
);
78 virtual sal_Bool
SetData( sal_uLong i_nFlags
, ImplJobSetup
* i_pSetupData
);
79 virtual void GetPageInfo( const ImplJobSetup
* i_pSetupData
,
80 long& o_rOutWidth
, long& o_rOutHeight
,
81 long& o_rPageOffX
, long& o_rPageOffY
,
82 long& o_rPageWidth
, long& o_rPageHeight
);
83 virtual sal_uLong
GetCapabilities( const ImplJobSetup
* i_pSetupData
, sal_uInt16 i_nType
);
84 virtual sal_uLong
GetPaperBinCount( const ImplJobSetup
* i_pSetupData
);
85 virtual rtl::OUString
GetPaperBinName( const ImplJobSetup
* i_pSetupData
, sal_uLong i_nPaperBin
);
86 virtual void InitPaperFormats( const ImplJobSetup
* i_pSetupData
);
87 virtual int GetLandscapeAngle( const ImplJobSetup
* i_pSetupData
);
89 // the artificial separation between InfoPrinter and Printer
90 // is not really useful for us
91 // so let's make AquaSalPrinter just a forwarder to AquaSalInfoPrinter
92 // and concentrate the real work in one class
93 // implement pull model print system
94 sal_Bool
StartJob( const rtl::OUString
* i_pFileName
,
95 const rtl::OUString
& rJobName
,
96 const rtl::OUString
& i_rAppName
,
97 ImplJobSetup
* i_pSetupData
,
98 vcl::PrinterController
& i_rController
);
101 SalGraphics
* StartPage( ImplJobSetup
* i_pSetupData
, sal_Bool i_bNewJobData
);
103 sal_uLong
GetErrorCode() const;
105 NSPrintInfo
* getPrintInfo() const { return mpPrintInfo
; }
106 void setStartPageOffset( int nOffsetX
, int nOffsetY
) { mnStartPageOffsetX
= nOffsetX
; mnStartPageOffsetY
= nOffsetY
; }
107 sal_Int32
getCurPageRangeStart() const { return mnCurPageRangeStart
; }
108 sal_Int32
getCurPageRangeCount() const { return mnCurPageRangeCount
; }
110 // match width/height against known paper formats, possibly switching orientation
111 const PaperInfo
* matchPaper( long i_nWidth
, long i_nHeight
, Orientation
& o_rOrientation
) const;
112 void setPaperSize( long i_nWidth
, long i_nHeight
, Orientation i_eSetOrientation
);
115 AquaSalInfoPrinter( const AquaSalInfoPrinter
& );
116 AquaSalInfoPrinter
& operator=(const AquaSalInfoPrinter
&);
120 // - AquaSalPrinter -
123 class AquaSalPrinter
: public SalPrinter
125 AquaSalInfoPrinter
* mpInfoPrinter
; // pointer to the compatible InfoPrinter
127 AquaSalPrinter( AquaSalInfoPrinter
* i_pInfoPrinter
);
128 virtual ~AquaSalPrinter();
130 virtual sal_Bool
StartJob( const rtl::OUString
* i_pFileName
,
131 const rtl::OUString
& i_rJobName
,
132 const rtl::OUString
& i_rAppName
,
136 ImplJobSetup
* i_pSetupData
);
137 // implement pull model print system
138 virtual sal_Bool
StartJob( const rtl::OUString
* i_pFileName
,
139 const rtl::OUString
& rJobName
,
140 const rtl::OUString
& i_rAppName
,
141 ImplJobSetup
* i_pSetupData
,
142 vcl::PrinterController
& i_rListener
);
144 virtual sal_Bool
EndJob();
145 virtual sal_Bool
AbortJob();
146 virtual SalGraphics
* StartPage( ImplJobSetup
* i_pSetupData
, sal_Bool i_bNewJobData
);
147 virtual sal_Bool
EndPage();
148 virtual sal_uLong
GetErrorCode();
151 AquaSalPrinter( const AquaSalPrinter
& );
152 AquaSalPrinter
& operator=(const AquaSalPrinter
&);
155 const double fPtTo100thMM
= 35.27777778;
157 inline int PtTo10Mu( double nPoints
) { return (int)(((nPoints
)*fPtTo100thMM
)+0.5); }
159 inline double TenMuToPt( double nUnits
) { return floor(((nUnits
)/fPtTo100thMM
)+0.5); }
163 #endif // _SV_SALPRN_H
165 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */