1*24f6443dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*24f6443dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*24f6443dSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*24f6443dSAndrew Rist * distributed with this work for additional information
6*24f6443dSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*24f6443dSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*24f6443dSAndrew Rist * "License"); you may not use this file except in compliance
9*24f6443dSAndrew Rist * with the License. You may obtain a copy of the License at
10*24f6443dSAndrew Rist *
11*24f6443dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*24f6443dSAndrew Rist *
13*24f6443dSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*24f6443dSAndrew Rist * software distributed under the License is distributed on an
15*24f6443dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*24f6443dSAndrew Rist * KIND, either express or implied. See the License for the
17*24f6443dSAndrew Rist * specific language governing permissions and limitations
18*24f6443dSAndrew Rist * under the License.
19*24f6443dSAndrew Rist *
20*24f6443dSAndrew Rist *************************************************************/
21*24f6443dSAndrew Rist
22*24f6443dSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #ifndef _SV_SALPRN_H
25cdf0e10cSrcweir #define _SV_SALPRN_H
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "aqua/aquavcltypes.h"
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include "salprn.hxx"
30cdf0e10cSrcweir
31cdf0e10cSrcweir #include <boost/shared_array.hpp>
32cdf0e10cSrcweir
33cdf0e10cSrcweir
34cdf0e10cSrcweir // ---------------------
35cdf0e10cSrcweir // - AquaSalInfoPrinter -
36cdf0e10cSrcweir // ---------------------
37cdf0e10cSrcweir
38cdf0e10cSrcweir class AquaSalGraphics;
39cdf0e10cSrcweir
40cdf0e10cSrcweir class AquaSalInfoPrinter : public SalInfoPrinter
41cdf0e10cSrcweir {
42cdf0e10cSrcweir /// Printer graphics
43cdf0e10cSrcweir AquaSalGraphics* mpGraphics;
44cdf0e10cSrcweir /// is Graphics used
45cdf0e10cSrcweir bool mbGraphics;
46cdf0e10cSrcweir /// job active ?
47cdf0e10cSrcweir bool mbJob;
48cdf0e10cSrcweir
49cdf0e10cSrcweir /// cocoa printer object
50cdf0e10cSrcweir NSPrinter* mpPrinter;
51cdf0e10cSrcweir /// cocoa print info object
52cdf0e10cSrcweir NSPrintInfo* mpPrintInfo;
53cdf0e10cSrcweir
54cdf0e10cSrcweir /// FIXME: get real printer context for infoprinter if possible
55cdf0e10cSrcweir /// fake context for info printer
56cdf0e10cSrcweir /// graphics context for Quartz 2D
57cdf0e10cSrcweir CGContextRef mrContext;
58cdf0e10cSrcweir /// memory for graphics bitmap context for querying metrics
59cdf0e10cSrcweir boost::shared_array< sal_uInt8 > maContextMemory;
60cdf0e10cSrcweir
61cdf0e10cSrcweir // since changes to NSPrintInfo during a job are ignored
62cdf0e10cSrcweir // we have to care for some settings ourselves
63cdf0e10cSrcweir // currently we do this for orientation;
64cdf0e10cSrcweir // really needed however is a solution for paper formats
65cdf0e10cSrcweir Orientation mePageOrientation;
66cdf0e10cSrcweir
67cdf0e10cSrcweir int mnStartPageOffsetX;
68cdf0e10cSrcweir int mnStartPageOffsetY;
69cdf0e10cSrcweir sal_Int32 mnCurPageRangeStart;
70cdf0e10cSrcweir sal_Int32 mnCurPageRangeCount;
71cdf0e10cSrcweir
72cdf0e10cSrcweir public:
73cdf0e10cSrcweir AquaSalInfoPrinter( const SalPrinterQueueInfo& pInfo );
74cdf0e10cSrcweir virtual ~AquaSalInfoPrinter();
75cdf0e10cSrcweir
76cdf0e10cSrcweir void SetupPrinterGraphics( CGContextRef i_xContext ) const;
77cdf0e10cSrcweir
78cdf0e10cSrcweir virtual SalGraphics* GetGraphics();
79cdf0e10cSrcweir virtual void ReleaseGraphics( SalGraphics* i_pGraphics );
80cdf0e10cSrcweir virtual sal_Bool Setup( SalFrame* i_pFrame, ImplJobSetup* i_pSetupData );
81cdf0e10cSrcweir virtual sal_Bool SetPrinterData( ImplJobSetup* pSetupData );
82cdf0e10cSrcweir virtual sal_Bool SetData( sal_uLong i_nFlags, ImplJobSetup* i_pSetupData );
83cdf0e10cSrcweir virtual void GetPageInfo( const ImplJobSetup* i_pSetupData,
84cdf0e10cSrcweir long& o_rOutWidth, long& o_rOutHeight,
85cdf0e10cSrcweir long& o_rPageOffX, long& o_rPageOffY,
86cdf0e10cSrcweir long& o_rPageWidth, long& o_rPageHeight );
87cdf0e10cSrcweir virtual sal_uLong GetCapabilities( const ImplJobSetup* i_pSetupData, sal_uInt16 i_nType );
88cdf0e10cSrcweir virtual sal_uLong GetPaperBinCount( const ImplJobSetup* i_pSetupData );
89cdf0e10cSrcweir virtual String GetPaperBinName( const ImplJobSetup* i_pSetupData, sal_uLong i_nPaperBin );
90cdf0e10cSrcweir virtual void InitPaperFormats( const ImplJobSetup* i_pSetupData );
91cdf0e10cSrcweir virtual int GetLandscapeAngle( const ImplJobSetup* i_pSetupData );
92cdf0e10cSrcweir
93cdf0e10cSrcweir // the artificial separation between InfoPrinter and Printer
94cdf0e10cSrcweir // is not really useful for us
95cdf0e10cSrcweir // so let's make AquaSalPrinter just a forwarder to AquaSalInfoPrinter
96cdf0e10cSrcweir // and concentrate the real work in one class
97cdf0e10cSrcweir // implement pull model print system
98cdf0e10cSrcweir sal_Bool StartJob( const String* i_pFileName,
99cdf0e10cSrcweir const String& rJobName,
100cdf0e10cSrcweir const String& i_rAppName,
101cdf0e10cSrcweir ImplJobSetup* i_pSetupData,
102cdf0e10cSrcweir vcl::PrinterController& i_rController );
103cdf0e10cSrcweir sal_Bool EndJob();
104cdf0e10cSrcweir sal_Bool AbortJob();
105cdf0e10cSrcweir SalGraphics* StartPage( ImplJobSetup* i_pSetupData, sal_Bool i_bNewJobData );
106cdf0e10cSrcweir sal_Bool EndPage();
107cdf0e10cSrcweir sal_uLong GetErrorCode() const;
108cdf0e10cSrcweir
getPrintInfo() const109cdf0e10cSrcweir NSPrintInfo* getPrintInfo() const { return mpPrintInfo; }
setStartPageOffset(int nOffsetX,int nOffsetY)110cdf0e10cSrcweir void setStartPageOffset( int nOffsetX, int nOffsetY ) { mnStartPageOffsetX = nOffsetX; mnStartPageOffsetY = nOffsetY; }
getCurPageRangeStart() const111cdf0e10cSrcweir sal_Int32 getCurPageRangeStart() const { return mnCurPageRangeStart; }
getCurPageRangeCount() const112cdf0e10cSrcweir sal_Int32 getCurPageRangeCount() const { return mnCurPageRangeCount; }
113cdf0e10cSrcweir
114cdf0e10cSrcweir // match width/height against known paper formats, possibly switching orientation
115cdf0e10cSrcweir const PaperInfo* matchPaper( long i_nWidth, long i_nHeight, Orientation& o_rOrientation ) const;
116cdf0e10cSrcweir void setPaperSize( long i_nWidth, long i_nHeight, Orientation i_eSetOrientation );
117cdf0e10cSrcweir
118cdf0e10cSrcweir private:
119cdf0e10cSrcweir AquaSalInfoPrinter( const AquaSalInfoPrinter& );
120cdf0e10cSrcweir AquaSalInfoPrinter& operator=(const AquaSalInfoPrinter&);
121cdf0e10cSrcweir };
122cdf0e10cSrcweir
123cdf0e10cSrcweir // -----------------
124cdf0e10cSrcweir // - AquaSalPrinter -
125cdf0e10cSrcweir // -----------------
126cdf0e10cSrcweir
127cdf0e10cSrcweir class AquaSalPrinter : public SalPrinter
128cdf0e10cSrcweir {
129cdf0e10cSrcweir AquaSalInfoPrinter* mpInfoPrinter; // pointer to the compatible InfoPrinter
130cdf0e10cSrcweir public:
131cdf0e10cSrcweir AquaSalPrinter( AquaSalInfoPrinter* i_pInfoPrinter );
132cdf0e10cSrcweir virtual ~AquaSalPrinter();
133cdf0e10cSrcweir
134cdf0e10cSrcweir virtual sal_Bool StartJob( const XubString* i_pFileName,
135cdf0e10cSrcweir const XubString& i_rJobName,
136cdf0e10cSrcweir const XubString& i_rAppName,
137cdf0e10cSrcweir sal_uLong i_nCopies,
138cdf0e10cSrcweir bool i_bCollate,
139cdf0e10cSrcweir bool i_bDirect,
140cdf0e10cSrcweir ImplJobSetup* i_pSetupData );
141cdf0e10cSrcweir // implement pull model print system
142cdf0e10cSrcweir virtual sal_Bool StartJob( const String* i_pFileName,
143cdf0e10cSrcweir const String& rJobName,
144cdf0e10cSrcweir const String& i_rAppName,
145cdf0e10cSrcweir ImplJobSetup* i_pSetupData,
146cdf0e10cSrcweir vcl::PrinterController& i_rListener );
147cdf0e10cSrcweir
148cdf0e10cSrcweir virtual sal_Bool EndJob();
149cdf0e10cSrcweir virtual sal_Bool AbortJob();
150cdf0e10cSrcweir virtual SalGraphics* StartPage( ImplJobSetup* i_pSetupData, sal_Bool i_bNewJobData );
151cdf0e10cSrcweir virtual sal_Bool EndPage();
152cdf0e10cSrcweir virtual sal_uLong GetErrorCode();
153cdf0e10cSrcweir
154cdf0e10cSrcweir private:
155cdf0e10cSrcweir AquaSalPrinter( const AquaSalPrinter& );
156cdf0e10cSrcweir AquaSalPrinter& operator=(const AquaSalPrinter&);
157cdf0e10cSrcweir };
158cdf0e10cSrcweir
159cdf0e10cSrcweir const double fPtTo100thMM = 35.27777778;
160cdf0e10cSrcweir
PtTo10Mu(double nPoints)161cdf0e10cSrcweir inline int PtTo10Mu( double nPoints ) { return (int)(((nPoints)*fPtTo100thMM)+0.5); }
162cdf0e10cSrcweir
TenMuToPt(double nUnits)163cdf0e10cSrcweir inline double TenMuToPt( double nUnits ) { return floor(((nUnits)/fPtTo100thMM)+0.5); }
164cdf0e10cSrcweir
165cdf0e10cSrcweir
166cdf0e10cSrcweir
167cdf0e10cSrcweir #endif // _SV_SALPRN_H
168