if (aPO->mPrintAsIs) { nsIPageSequenceFrame * curPageSeq = mPageSeqFrame; aPO->mHasBeenPrinted = PR_TRUE; PRInt32 cnt = aPO->mKids.Count(); for (PRInt32 i=0;i<cnt;i++) { PrintObject* po = (PrintObject*)aPO->mKids[i]; NS_ASSERTION(po, "PrintObject can't be null!");    curPageSeq->GetCurrentPageNum(&pageNum); nsIFrame* fr; curPageSeq->QueryInterface(NS_GET_IID(nsIFrame), (void**)&fr);  if (fr == po->mSeqFrame && pageNum == po->mPageNum) { PRBool donePrintingSubDoc; DoPrint(po, PR_TRUE, donePrintingSubDoc); po->mHasBeenPrinted = PR_TRUE; } } mPageSeqFrame = curPageSeq;  if (aPO->mParent == nsnull || (aPO->mParent != nsnull && !aPO->mParent->mPrintAsIs && aPO->mPrintAsIs)) { mPageSeqFrame->DoPageEnd(aPresContext); }    if (aPO->mFrameType == eFrameSet && mPrt->mPrintFrameType == nsIPrintOptions::kFramesAsIs) { return PR_TRUE; } }
DocumentViewerImpl::PrintPage(nsIPresContext* aPresContext,                              nsIPrintOptions* aPrintOptions){  nsresult rv;  NS_WITH_SERVICE(nsIPrintOptions, printService, kPrintOptionsCID, &rv);  if (NS_SUCCEEDED(rv) && printService) {    PRBool isCancelled;    printService->GetIsCancelled(&isCancelled);    if (isCancelled) {      printService->SetIsCancelled(PR_FALSE);      return PR_TRUE;    }  }  PRInt32 pageNum;  PRInt32 curPage;  PRInt32 endPage;  mPageSeqFrame->GetCurrentPageNum(&pageNum);  PRBool donePrinting = PR_FALSE;  PRBool isDoingPrintRange;  mPageSeqFrame->IsDoingPrintRange(&isDoingPrintRange);  if (isDoingPrintRange) {    PRInt32 fromPage;    PRInt32 toPage;    mPageSeqFrame->GetPrintRange(&fromPage, &toPage);#if defined(DEBUG_rods) || defined(DEBUG_dcone)    printf("****** Printing Page %d printing from %d to page %d\n", pageNum, fromPage, toPage);#endif    donePrinting = pageNum >= toPage;    curPage = pageNum - fromPage;    endPage = toPage - fromPage;  } else {    PRInt32 numPages;    mPageSeqFrame->GetNumPages(&numPages);#if defined(DEBUG_rods) || defined(DEBUG_dcone)    printf("****** Printing Page %d of %d page(s)\n", pageNum, numPages);#endif    donePrinting = pageNum >= numPages;    curPage = pageNum;    endPage = numPages;  }  if (mPrintListener) {    // Make sure the Listener gets a "zero" progress at the beginning    // so it can initialize it's state    if (curPage == 1) {      mPrintListener->OnProgressPrinting(0, endPage);     }    mPrintListener->OnProgressPrinting(curPage, endPage);   }  mPageSeqFrame->PrintNextPage(aPresContext, aPrintOptions);  return donePrinting;}