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 #if 0 29 #define _SV_IMPPRN_HXX 30 31 #include <vcl/print.hxx> 32 #include <vcl/timer.hxx> 33 #ifndef _VCL_IMPDEL_HXX 34 #include <vcl/impdel.hxx> 35 #endif 36 37 #include <vector> 38 39 struct QueuePage; 40 41 // ---------------- 42 // - ImplQPrinter - 43 // ---------------- 44 45 /* 46 ImplQPrinter is on most systems a simple buffer that allows a potential 47 lengthy print job to be printed in the background. For this it saves all 48 normal drawing operations for each printed page to a metafile, then spooling 49 the metafiles timer based to a normal printer. The application can act in the meantime 50 including changing the original document without influencing the print job. 51 52 On some systems (currently Mac/Aqua Cocoa) ImplQPrinter has the additional 53 purpose of adapting to the print system: here theprint systems starts a 54 job and will not return from that function until it has ended; to do so 55 it queries for each consecutive page to be printed. Also the Cocoa print system 56 needs to know the number of pages BEFORE starting a print job. Since our Printer 57 does not know that, we need to do the completing spooling to ImplQPrinter before 58 we can actually print to the real print system. Let's call this the pull model 59 instead of the push model (because the systems pulls the pages). 60 */ 61 62 class ImplQPrinter : public Printer, public vcl::DeletionNotifier 63 { 64 private: 65 Printer* mpParent; 66 std::vector< QueuePage* > maQueue; 67 AutoTimer maTimer; 68 bool mbAborted; 69 bool mbUserCopy; 70 bool mbDestroyAllowed; 71 bool mbDestroyed; 72 73 GDIMetaFile maCurPageMetaFile; 74 long mnMaxBmpDPIX; 75 long mnMaxBmpDPIY; 76 sal_uLong mnRestoreDrawMode; 77 int mnCurCopyCount; 78 79 DECL_LINK( ImplPrintHdl, Timer* ); 80 81 ~ImplQPrinter(); 82 83 void ImplPrintMtf( GDIMetaFile& rMtf, long nMaxBmpDPIX, long nMaxBmpDPIY ); 84 85 ImplQPrinter( const ImplQPrinter& rPrinter ); 86 Printer& operator =( const ImplQPrinter& rPrinter ); 87 88 void PrePrintPage( QueuePage* ); 89 void PostPrintPage(); 90 91 public: 92 93 ImplQPrinter( Printer* pParent ); 94 void Destroy(); 95 96 void StartQueuePrint(); 97 void EndQueuePrint(); 98 void AbortQueuePrint(); 99 void AddQueuePage( GDIMetaFile* pPage, sal_uInt16 nPage, sal_Bool bNewJobSetup ); 100 101 bool IsUserCopy() const { return mbUserCopy; } 102 void SetUserCopy( bool bSet ) { mbUserCopy = bSet; } 103 104 /** 105 used by pull implementation to emit the next page 106 */ 107 void PrintPage( unsigned int nPage ); 108 /** 109 used by pull implementation to get the number of physical pages 110 (that is how often PrintNextPage should be called) 111 */ 112 sal_uLong GetPrintPageCount() const; 113 114 /** 115 used by pull implementation to get ranges of physical pages that 116 are to be printed on the same paper. If bIncludeOrientationChanges is true 117 then orientation changes will not break a page run; the implementation has 118 to rotate the page contents accordingly in that case. 119 120 The returned vector contains all pages indices beginning a new medium and additionally 121 the index that of the last page+1 (for convenience, so the length of a range 122 is always v[i+1] - v[i]) 123 124 Example: 5 pages, all A4 125 return: [0 5] 126 127 Example: 6 pages, beginning A4, switching tol A5 on fourth page, back to A4 on fifth page 128 return [0 3 4 6] 129 130 returns an false in push model (error condition) 131 */ 132 bool GetPaperRanges( std::vector< sal_uLong >& o_rRanges, bool i_bIncludeOrientationChanges ) const; 133 134 /** 135 get the jobsetup for a page 136 */ 137 ImplJobSetup* GetPageSetup( unsigned int nPage ) const; 138 }; 139 140 #endif // _SV_IMPPRN_HXX 141