bool MacPrinterCanvas::finish() { #if carbon return false; #else endPaint(); PrClosePage(gPrinterPort); if (PrError() != noErr) { return false; } PrCloseDoc(gPrinterPort); if (PrError() != noErr) { return false; } if ((**prRecHdl).prJob.bJDocLoop == bSpoolLoop) { TPrStatus theStatus; PrPicFile(prRecHdl, nil, nil, nil, &theStatus); if (PrError() != noErr) { return false; } } PrClose(); if (PrError() != noErr) { return false; } SetPort(oldPort); //debugfile("MacPrinter::finish\n"); return true; #endif }
boolean shellprint (WindowPtr w, boolean fldialog) { /* 9/5/90 dmb: open and close print resources each time we're called. also, make sure we close each page opened, even when errors occur 9/28/91 dmb: for exit of edit mode before printing 4/24/92 dmb: make sure bJDocLoop is bSpoolLoop before calling PrPicFile, as per IM II-155. otherwise, we can get bogus PrErrors */ // classic mac TPPrPort printport; TPrStatus printstatus; THPrint hp = shellprintinfo.printhandle; SInt32 firstPage = 1; SInt32 lastPage = 9999; short i; boolean fl = false; if (w == nil) /*defensive driving*/ return (false); PrOpen (); if (!shellcheckprinterror (true)) return (false); fl = false; /*until sucessfull print, this is return value*/ if (fldialog) { if (!PrJobDialog (hp)) goto exit; } else PrValidate (hp); setcursortype (cursoriswatch); shellupdateallnow (); /*update all windows that were dirtied by the print dialog*/ shellpushglobals (w); (*shellglobals.settextmoderoutine) (false); /*make sure editing changes are accepted*/ pushport (nil); /*save current port on stack*/ shellprintinfo.printport = printport = PrOpenDoc (hp, nil, nil); currentprintport = w; /*prepares for printing*/ (*shellglobals.beginprintroutine) (); /*fills in fields of printinfo record*/ (*shellglobals.setprintinfoproutine) (); //this only counts the number of pages. // wird in classic lastPage gesetzt? if(lastPage > shellprintinfo.ctpages) lastPage = shellprintinfo.ctpages; for (i = 1; i <= lastPage; i++) { /*print one page*/ if (PrError () != noErr) break; PrOpenPage (printport, nil); if (PrError () == noErr) { SetFractEnable (true); fl = (*shellglobals.printroutine) (i); SetFractEnable (false); } PrClosePage (printport); if (!fl) break; if (keyboardescape ()) { PrSetError (iPrAbort); } } /*for*/ PrCloseDoc (printport); if (fl) { if ( (PrError () == noErr) && ((**hp).prJob.bJDocLoop == bSpoolLoop)) { PrPicFile (hp, nil, nil, nil, &printstatus); } fl = shellcheckprinterror (false); } popport (); (*shellglobals.endprintroutine) (); shellpopglobals (); exit: PrClose (); currentprintport = NULL; return (fl); } /*shellprint*/