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