1*ebfcd9afSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*ebfcd9afSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*ebfcd9afSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*ebfcd9afSAndrew Rist * distributed with this work for additional information 6*ebfcd9afSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*ebfcd9afSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*ebfcd9afSAndrew Rist * "License"); you may not use this file except in compliance 9*ebfcd9afSAndrew Rist * with the License. You may obtain a copy of the License at 10*ebfcd9afSAndrew Rist * 11*ebfcd9afSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*ebfcd9afSAndrew Rist * 13*ebfcd9afSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*ebfcd9afSAndrew Rist * software distributed under the License is distributed on an 15*ebfcd9afSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*ebfcd9afSAndrew Rist * KIND, either express or implied. See the License for the 17*ebfcd9afSAndrew Rist * specific language governing permissions and limitations 18*ebfcd9afSAndrew Rist * under the License. 19*ebfcd9afSAndrew Rist * 20*ebfcd9afSAndrew Rist *************************************************************/ 21*ebfcd9afSAndrew Rist 22*ebfcd9afSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #if 0 25cdf0e10cSrcweir #define _SV_IMPPRN_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <vcl/print.hxx> 28cdf0e10cSrcweir #include <vcl/timer.hxx> 29cdf0e10cSrcweir #ifndef _VCL_IMPDEL_HXX 30cdf0e10cSrcweir #include <vcl/impdel.hxx> 31cdf0e10cSrcweir #endif 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <vector> 34cdf0e10cSrcweir 35cdf0e10cSrcweir struct QueuePage; 36cdf0e10cSrcweir 37cdf0e10cSrcweir // ---------------- 38cdf0e10cSrcweir // - ImplQPrinter - 39cdf0e10cSrcweir // ---------------- 40cdf0e10cSrcweir 41cdf0e10cSrcweir /* 42cdf0e10cSrcweir ImplQPrinter is on most systems a simple buffer that allows a potential 43cdf0e10cSrcweir lengthy print job to be printed in the background. For this it saves all 44cdf0e10cSrcweir normal drawing operations for each printed page to a metafile, then spooling 45cdf0e10cSrcweir the metafiles timer based to a normal printer. The application can act in the meantime 46cdf0e10cSrcweir including changing the original document without influencing the print job. 47cdf0e10cSrcweir 48cdf0e10cSrcweir On some systems (currently Mac/Aqua Cocoa) ImplQPrinter has the additional 49cdf0e10cSrcweir purpose of adapting to the print system: here theprint systems starts a 50cdf0e10cSrcweir job and will not return from that function until it has ended; to do so 51cdf0e10cSrcweir it queries for each consecutive page to be printed. Also the Cocoa print system 52cdf0e10cSrcweir needs to know the number of pages BEFORE starting a print job. Since our Printer 53cdf0e10cSrcweir does not know that, we need to do the completing spooling to ImplQPrinter before 54cdf0e10cSrcweir we can actually print to the real print system. Let's call this the pull model 55cdf0e10cSrcweir instead of the push model (because the systems pulls the pages). 56cdf0e10cSrcweir */ 57cdf0e10cSrcweir 58cdf0e10cSrcweir class ImplQPrinter : public Printer, public vcl::DeletionNotifier 59cdf0e10cSrcweir { 60cdf0e10cSrcweir private: 61cdf0e10cSrcweir Printer* mpParent; 62cdf0e10cSrcweir std::vector< QueuePage* > maQueue; 63cdf0e10cSrcweir AutoTimer maTimer; 64cdf0e10cSrcweir bool mbAborted; 65cdf0e10cSrcweir bool mbUserCopy; 66cdf0e10cSrcweir bool mbDestroyAllowed; 67cdf0e10cSrcweir bool mbDestroyed; 68cdf0e10cSrcweir 69cdf0e10cSrcweir GDIMetaFile maCurPageMetaFile; 70cdf0e10cSrcweir long mnMaxBmpDPIX; 71cdf0e10cSrcweir long mnMaxBmpDPIY; 72cdf0e10cSrcweir sal_uLong mnRestoreDrawMode; 73cdf0e10cSrcweir int mnCurCopyCount; 74cdf0e10cSrcweir 75cdf0e10cSrcweir DECL_LINK( ImplPrintHdl, Timer* ); 76cdf0e10cSrcweir 77cdf0e10cSrcweir ~ImplQPrinter(); 78cdf0e10cSrcweir 79cdf0e10cSrcweir void ImplPrintMtf( GDIMetaFile& rMtf, long nMaxBmpDPIX, long nMaxBmpDPIY ); 80cdf0e10cSrcweir 81cdf0e10cSrcweir ImplQPrinter( const ImplQPrinter& rPrinter ); 82cdf0e10cSrcweir Printer& operator =( const ImplQPrinter& rPrinter ); 83cdf0e10cSrcweir 84cdf0e10cSrcweir void PrePrintPage( QueuePage* ); 85cdf0e10cSrcweir void PostPrintPage(); 86cdf0e10cSrcweir 87cdf0e10cSrcweir public: 88cdf0e10cSrcweir 89cdf0e10cSrcweir ImplQPrinter( Printer* pParent ); 90cdf0e10cSrcweir void Destroy(); 91cdf0e10cSrcweir 92cdf0e10cSrcweir void StartQueuePrint(); 93cdf0e10cSrcweir void EndQueuePrint(); 94cdf0e10cSrcweir void AbortQueuePrint(); 95cdf0e10cSrcweir void AddQueuePage( GDIMetaFile* pPage, sal_uInt16 nPage, sal_Bool bNewJobSetup ); 96cdf0e10cSrcweir 97cdf0e10cSrcweir bool IsUserCopy() const { return mbUserCopy; } 98cdf0e10cSrcweir void SetUserCopy( bool bSet ) { mbUserCopy = bSet; } 99cdf0e10cSrcweir 100cdf0e10cSrcweir /** 101cdf0e10cSrcweir used by pull implementation to emit the next page 102cdf0e10cSrcweir */ 103cdf0e10cSrcweir void PrintPage( unsigned int nPage ); 104cdf0e10cSrcweir /** 105cdf0e10cSrcweir used by pull implementation to get the number of physical pages 106cdf0e10cSrcweir (that is how often PrintNextPage should be called) 107cdf0e10cSrcweir */ 108cdf0e10cSrcweir sal_uLong GetPrintPageCount() const; 109cdf0e10cSrcweir 110cdf0e10cSrcweir /** 111cdf0e10cSrcweir used by pull implementation to get ranges of physical pages that 112cdf0e10cSrcweir are to be printed on the same paper. If bIncludeOrientationChanges is true 113cdf0e10cSrcweir then orientation changes will not break a page run; the implementation has 114cdf0e10cSrcweir to rotate the page contents accordingly in that case. 115cdf0e10cSrcweir 116cdf0e10cSrcweir The returned vector contains all pages indices beginning a new medium and additionally 117cdf0e10cSrcweir the index that of the last page+1 (for convenience, so the length of a range 118cdf0e10cSrcweir is always v[i+1] - v[i]) 119cdf0e10cSrcweir 120cdf0e10cSrcweir Example: 5 pages, all A4 121cdf0e10cSrcweir return: [0 5] 122cdf0e10cSrcweir 123cdf0e10cSrcweir Example: 6 pages, beginning A4, switching tol A5 on fourth page, back to A4 on fifth page 124cdf0e10cSrcweir return [0 3 4 6] 125cdf0e10cSrcweir 126cdf0e10cSrcweir returns an false in push model (error condition) 127cdf0e10cSrcweir */ 128cdf0e10cSrcweir bool GetPaperRanges( std::vector< sal_uLong >& o_rRanges, bool i_bIncludeOrientationChanges ) const; 129cdf0e10cSrcweir 130cdf0e10cSrcweir /** 131cdf0e10cSrcweir get the jobsetup for a page 132cdf0e10cSrcweir */ 133cdf0e10cSrcweir ImplJobSetup* GetPageSetup( unsigned int nPage ) const; 134cdf0e10cSrcweir }; 135cdf0e10cSrcweir 136cdf0e10cSrcweir #endif // _SV_IMPPRN_HXX 137