update dev300-m58
[ooovba.git] / vcl / aqua / inc / salprn.h
blob72d983ede12f8f785fee536d850330435110e2e0
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: salprn.h,v $
10 * $Revision: 1.12 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SV_SALPRN_H
32 #define _SV_SALPRN_H
34 #include "vcl/sv.h"
35 #include "aquavcltypes.h"
36 #include "vcl/salprn.hxx"
38 #include <boost/shared_array.hpp>
41 // ---------------------
42 // - AquaSalInfoPrinter -
43 // ---------------------
45 class AquaSalGraphics;
47 class AquaSalInfoPrinter : public SalInfoPrinter
49 /// Printer graphics
50 AquaSalGraphics* mpGraphics;
51 /// is Graphics used
52 bool mbGraphics;
53 /// job active ?
54 bool mbJob;
56 /// cocoa printer object
57 NSPrinter* mpPrinter;
58 /// cocoa print info object
59 NSPrintInfo* mpPrintInfo;
61 /// FIXME: get real printer context for infoprinter if possible
62 /// fake context for info printer
63 /// graphics context for Quartz 2D
64 CGContextRef mrContext;
65 /// memory for graphics bitmap context for querying metrics
66 boost::shared_array< sal_uInt8 > maContextMemory;
68 // since changes to NSPrintInfo during a job are ignored
69 // we have to care for some settings ourselves
70 // currently we do this for orientation;
71 // really needed however is a solution for paper formats
72 Orientation mePageOrientation;
74 int mnStartPageOffsetX;
75 int mnStartPageOffsetY;
76 ULONG mnCurPageRangeStart;
77 ULONG mnCurPageRangeCount;
79 public:
80 AquaSalInfoPrinter( const SalPrinterQueueInfo& pInfo );
81 virtual ~AquaSalInfoPrinter();
83 void SetupPrinterGraphics( CGContextRef i_xContext ) const;
85 virtual SalGraphics* GetGraphics();
86 virtual void ReleaseGraphics( SalGraphics* i_pGraphics );
87 virtual BOOL Setup( SalFrame* i_pFrame, ImplJobSetup* i_pSetupData );
88 virtual BOOL SetPrinterData( ImplJobSetup* pSetupData );
89 virtual BOOL SetData( ULONG i_nFlags, ImplJobSetup* i_pSetupData );
90 virtual void GetPageInfo( const ImplJobSetup* i_pSetupData,
91 long& o_rOutWidth, long& o_rOutHeight,
92 long& o_rPageOffX, long& o_rPageOffY,
93 long& o_rPageWidth, long& o_rPageHeight );
94 virtual ULONG GetCapabilities( const ImplJobSetup* i_pSetupData, USHORT i_nType );
95 virtual ULONG GetPaperBinCount( const ImplJobSetup* i_pSetupData );
96 virtual String GetPaperBinName( const ImplJobSetup* i_pSetupData, ULONG i_nPaperBin );
97 virtual void InitPaperFormats( const ImplJobSetup* i_pSetupData );
98 virtual int GetLandscapeAngle( const ImplJobSetup* i_pSetupData );
99 virtual DuplexMode GetDuplexMode( const ImplJobSetup* i_pSetupData );
102 // the artificial separation between InfoPrinter and Printer
103 // is not really useful for us
104 // so let's make AquaSalPrinter just a forwarder to AquaSalInfoPrinter
105 // and concentrate the real work in one class
106 // implement pull model print system
107 BOOL StartJob( const String* pFileName,
108 const String& rAppName,
109 ImplJobSetup* pSetupData,
110 ImplQPrinter* pQPrinter,
111 bool bIsQuickJob );
112 BOOL EndJob();
113 BOOL AbortJob();
114 SalGraphics* StartPage( ImplJobSetup* i_pSetupData, BOOL i_bNewJobData );
115 BOOL EndPage();
116 ULONG GetErrorCode() const;
118 NSPrintInfo* getPrintInfo() const { return mpPrintInfo; }
119 void setStartPageOffset( int nOffsetX, int nOffsetY ) { mnStartPageOffsetX = nOffsetX; mnStartPageOffsetY = nOffsetY; }
120 ULONG getCurPageRangeStart() const { return mnCurPageRangeStart; }
121 ULONG getCurPageRangeCount() const { return mnCurPageRangeCount; }
123 private:
124 AquaSalInfoPrinter( const AquaSalInfoPrinter& );
125 AquaSalInfoPrinter& operator=(const AquaSalInfoPrinter&);
128 // -----------------
129 // - AquaSalPrinter -
130 // -----------------
132 class AquaSalPrinter : public SalPrinter
134 AquaSalInfoPrinter* mpInfoPrinter; // pointer to the compatible InfoPrinter
135 public:
136 AquaSalPrinter( AquaSalInfoPrinter* i_pInfoPrinter );
137 virtual ~AquaSalPrinter();
139 virtual BOOL StartJob( const XubString* i_pFileName,
140 const XubString& i_rJobName,
141 const XubString& i_rAppName,
142 ULONG i_nCopies, BOOL i_bCollate,
143 ImplJobSetup* i_pSetupData );
144 // implement pull model print system
145 virtual BOOL StartJob( const String* pFileName,
146 const String& rAppName,
147 ImplJobSetup* pSetupData,
148 ImplQPrinter* pQPrinter );
150 virtual BOOL EndJob();
151 virtual BOOL AbortJob();
152 virtual SalGraphics* StartPage( ImplJobSetup* i_pSetupData, BOOL i_bNewJobData );
153 virtual BOOL EndPage();
154 virtual ULONG GetErrorCode();
156 private:
157 AquaSalPrinter( const AquaSalPrinter& );
158 AquaSalPrinter& operator=(const AquaSalPrinter&);
161 const double fPtTo100thMM = 35.27777778;
163 inline int PtTo10Mu( double nPoints ) { return (int)(((nPoints)*fPtTo100thMM)+0.5); }
165 inline double TenMuToPt( double nUnits ) { return (((nUnits)/fPtTo100thMM)+0.5); }
169 #endif // _SV_SALPRN_H