if (aPO->mFrameType == eFrameSet && mPrt->mPrintFrameType == nsIPrintOptions::kFramesAsIs) {
if (aPO->mFrameType == eFrameSet && mPrt->mPrintFrameType == nsIPrintSettings::kFramesAsIs) {
DocumentViewerImpl::PrintPage(nsIPresContext*  aPresContext,                              nsIPrintOptions* aPrintOptions,                              PrintObject*     aPO){  NS_ASSERTION(aPresContext, "Pointer is null!");  NS_ASSERTION(aPrintOptions, "Pointer is null!");  NS_ASSERTION(aPO, "Pointer is null!");  PRINT_DEBUG_MSG1("-----------------------------------\n");  PRINT_DEBUG_MSG3("------ In DV::PrintPage PO: %p (%s)\n", aPO, gFrameTypesStr[aPO->mFrameType]);  nsresult rv;  nsCOMPtr<nsIPrintOptions> printService =            do_GetService(kPrintOptionsCID, &rv);  if (NS_SUCCEEDED(rv) && printService) {    PRBool isCancelled;    printService->GetIsCancelled(&isCancelled);    // DO NOT allow the print job to be cancelled if it is Print FrameAsIs    // because it is only printing one page.    if (isCancelled && mPrt->mPrintFrameType != nsIPrintOptions::kFramesAsIs) {      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;    PRInt32 numPages;    mPageSeqFrame->GetPrintRange(&fromPage, &toPage);    mPageSeqFrame->GetNumPages(&numPages);    if (fromPage > numPages) {      return PR_TRUE;    }    if (toPage > numPages) {      toPage = numPages;    }    PRINT_DEBUG_MSG4("****** Printing Page %d printing from %d to page %d\n", pageNum, fromPage, toPage);    donePrinting = pageNum >= toPage;    curPage = pageNum - fromPage;    endPage = toPage - fromPage;  } else {    PRInt32 numPages;    mPageSeqFrame->GetNumPages(&numPages);    PRINT_DEBUG_MSG3("****** Printing Page %d of %d page(s)\n", pageNum, numPages);    donePrinting = pageNum >= numPages;    curPage = pageNum;    endPage = numPages;  }  // NOTE: mPrt->mPrintFrameType gets set to  "kFramesAsIs" when a  // plain document contains IFrames, so we need to override that case here  if (mPrt->mPrintListener) {    if (mPrt->mPrintFrameType == nsIPrintOptions::kEachFrameSep) {      DoProgressForSeparateFrames();    } else if (mPrt->mPrintFrameType != nsIPrintOptions::kFramesAsIs ||                mPrt->mPrintObject->mFrameType == eDoc && aPO == mPrt->mPrintObject) {      // Make sure the Listener gets a "zero" progress at the beginning      // so it can initialize it's state      if (curPage == 1) {        mPrt->mPrintListener->OnProgressPrinting(0, endPage);       }      mPrt->mPrintListener->OnProgressPrinting(curPage, endPage);     }  }  // Set Clip when Printing "AsIs" or   // when printing an IFrame for SelectedFrame or EachFrame  PRBool setClip = PR_FALSE;  switch (mPrt->mPrintFrameType) {    case nsIPrintOptions::kFramesAsIs:      setClip = PR_TRUE;      break;    case nsIPrintOptions::kSelectedFrame:      if (aPO->mPrintAsIs) {        if (aPO->mFrameType == eIFrame) {          setClip = aPO != mPrt->mSelectedPO;        }      }      break;    case nsIPrintOptions::kEachFrameSep:      if (aPO->mPrintAsIs) {        if (aPO->mFrameType == eIFrame) {          setClip = PR_TRUE;        }      }      break;  } //switch   if (setClip) {    mPageSeqFrame->SetClipRect(aPO->mPresContext, &aPO->mClipRect);  }  // Print the Page  // if a print job was cancelled externally, an EndPage or BeginPage may  // fail and the failure is passed back here.  // Returning PR_TRUE means we are done printing.  if (NS_FAILED(mPageSeqFrame->PrintNextPage(aPresContext, aPrintOptions))) {    return PR_TRUE;  }                  // Now see if any of the SubDocs are on this page  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!");      // Now verify that SubDoc's PageNum matches the      // page num of it's parent doc      curPageSeq->GetCurrentPageNum(&pageNum);      nsIFrame* fr;      CallQueryInterface(curPageSeq, &fr);      if (fr == po->mSeqFrame && pageNum == po->mPageNum) {        PRBool donePrintingSubDoc;        DoPrint(po, PR_TRUE, donePrintingSubDoc); // synchronous printing, it changes the value mPageSeqFrame        po->mHasBeenPrinted = PR_TRUE;      }    } // while    mPageSeqFrame = curPageSeq;    if (aPO->mParent == nsnull ||        (aPO->mParent != nsnull && !aPO->mParent->mPrintAsIs && aPO->mPrintAsIs)) {      mPageSeqFrame->DoPageEnd(aPresContext);    }    // XXX this is because PrintAsIs for FrameSets reflows to two pages    // not sure why, but this needs to be fixed.    if (aPO->mFrameType == eFrameSet && mPrt->mPrintFrameType == nsIPrintOptions::kFramesAsIs) {      return PR_TRUE;    }  }  return donePrinting;}