if (printHowEnable == nsIPrintOptions::kFrameEnableNone) {
if (printHowEnable == nsIPrintSettings::kFrameEnableNone) {
DocumentViewerImpl::EnablePOsForPrinting(){  // NOTE: All POs have been "turned off" for printing  // this is where we decided which POs get printed.  mPrt->mSelectedPO = nsnull;  nsresult rv;  nsCOMPtr<nsIPrintOptions> printService =            do_GetService(kPrintOptionsCID, &rv);  if (NS_FAILED(rv)) {    return rv;  }  mPrt->mPrintFrameType = nsIPrintOptions::kNoFrames;   printService->GetPrintFrameType(&mPrt->mPrintFrameType);  PRInt16 printHowEnable = nsIPrintOptions::kFrameEnableNone;   printService->GetHowToEnableFrameUI(&printHowEnable);  PRInt16 printRangeType = nsIPrintOptions::kRangeAllPages;  printService->GetPrintRange(&printRangeType);  PRINT_DEBUG_MSG1("\n********* DocumentViewerImpl::EnablePOsForPrinting *********\n");  PRINT_DEBUG_MSG2("PrintFrameType:     %s \n", gPrintFrameTypeStr[mPrt->mPrintFrameType]);  PRINT_DEBUG_MSG2("HowToEnableFrameUI: %s \n", gFrameHowToEnableStr[printHowEnable]);  PRINT_DEBUG_MSG2("PrintRange:         %s \n", gPrintRangeStr[printRangeType]);  PRINT_DEBUG_MSG1("----\n");  PRINT_DEBUG_FLUSH  // ***** This is the ultimate override *****  // if we are printing the selection (either an IFrame or selection range)  // then set the mPrintFrameType as if it were the selected frame  if (printRangeType == nsIPrintOptions::kRangeSelection) {    mPrt->mPrintFrameType = nsIPrintOptions::kSelectedFrame;    printHowEnable        = nsIPrintOptions::kFrameEnableNone;   }  // This tells us that the "Frame" UI has turned off,  // so therefore there are no FrameSets/Frames/IFrames to be printed  //  // This means there are not FrameSets,   // but the document could contain an IFrame  if (printHowEnable == nsIPrintOptions::kFrameEnableNone) {    // Print all the pages or a sub range of pages    if (printRangeType == nsIPrintOptions::kRangeAllPages ||        printRangeType == nsIPrintOptions::kRangeSpecifiedPageRange) {      SetPrintPO(mPrt->mPrintObject, PR_TRUE);      // Set the children so they are PrinAsIs      // In this case, the children are probably IFrames      if (mPrt->mPrintObject->mKids.Count() > 0) {        for (PRInt32 i=0;i<mPrt->mPrintObject->mKids.Count();i++) {          PrintObject* po = (PrintObject*)mPrt->mPrintObject->mKids[i];          NS_ASSERTION(po, "PrintObject can't be null!");          SetPrintAsIs(po);        }        // ***** Another override *****        mPrt->mPrintFrameType = nsIPrintOptions::kFramesAsIs;      }      PRINT_DEBUG_MSG2("PrintFrameType:     %s \n", gPrintFrameTypeStr[mPrt->mPrintFrameType]);      PRINT_DEBUG_MSG2("HowToEnableFrameUI: %s \n", gFrameHowToEnableStr[printHowEnable]);      PRINT_DEBUG_MSG2("PrintRange:         %s \n", gPrintRangeStr[printRangeType]);      return NS_OK;    }        // This means we are either printed a selected IFrame or    // we are printing the current selection    if (printRangeType == nsIPrintOptions::kRangeSelection) {      // If the currentFocusDOMWin can'r be null if something is selected      if (mPrt->mCurrentFocusWin) {        // Find the selected IFrame        PrintObject * po = FindPrintObjectByDOMWin(mPrt->mPrintObject, mPrt->mCurrentFocusWin);        if (po != nsnull) {          mPrt->mSelectedPO = po;          // Makes sure all of its children are be printed "AsIs"          SetPrintAsIs(po);          // Now, only enable this POs (the selected PO) and all of its children          SetPrintPO(po, PR_TRUE);          // check to see if we have a range selection,           // as oppose to a insert selection          // this means if the user just clicked on the IFrame then           // there will not be a selection so we want the entire page to print          //          // XXX this is sort of a hack right here to make the page           // not try to reposition itself when printing selection          nsCOMPtr<nsIDOMWindowInternal> domWin = getter_AddRefs(GetDOMWinForWebShell(po->mWebShell));          if (!IsThereARangeSelection(domWin)) {            printRangeType = nsIPrintOptions::kRangeAllPages;            printService->SetPrintRange(printRangeType);          }          PRINT_DEBUG_MSG2("PrintFrameType:     %s \n", gPrintFrameTypeStr[mPrt->mPrintFrameType]);          PRINT_DEBUG_MSG2("HowToEnableFrameUI: %s \n", gFrameHowToEnableStr[printHowEnable]);          PRINT_DEBUG_MSG2("PrintRange:         %s \n", gPrintRangeStr[printRangeType]);          return NS_OK;        }      } else {        for (PRInt32 i=0;i<mPrt->mPrintDocList->Count();i++) {          PrintObject* po = (PrintObject*)mPrt->mPrintDocList->ElementAt(i);          NS_ASSERTION(po, "PrintObject can't be null!");          nsCOMPtr<nsIDOMWindowInternal> domWin = getter_AddRefs(GetDOMWinForWebShell(po->mWebShell));          if (IsThereARangeSelection(domWin)) {            SetPrintPO(po, PR_TRUE);            break;          }        }        return NS_OK;      }    }  }  // check to see if there is a selection when a FrameSet is present  if (printRangeType == nsIPrintOptions::kRangeSelection) {    // If the currentFocusDOMWin can'r be null if something is selected    if (mPrt->mCurrentFocusWin) {      // Find the selected IFrame      PrintObject * po = FindPrintObjectByDOMWin(mPrt->mPrintObject, mPrt->mCurrentFocusWin);      if (po != nsnull) {        mPrt->mSelectedPO = po;        // Makes sure all of its children are be printed "AsIs"        SetPrintAsIs(po);        // Now, only enable this POs (the selected PO) and all of its children        SetPrintPO(po, PR_TRUE);        // check to see if we have a range selection,         // as oppose to a insert selection        // this means if the user just clicked on the IFrame then         // there will not be a selection so we want the entire page to print        //        // XXX this is sort of a hack right here to make the page         // not try to reposition itself when printing selection        nsCOMPtr<nsIDOMWindowInternal> domWin = getter_AddRefs(GetDOMWinForWebShell(po->mWebShell));        if (!IsThereARangeSelection(domWin)) {          printRangeType = nsIPrintOptions::kRangeAllPages;          printService->SetPrintRange(printRangeType);        }        PRINT_DEBUG_MSG2("PrintFrameType:     %s \n", gPrintFrameTypeStr[mPrt->mPrintFrameType]);        PRINT_DEBUG_MSG2("HowToEnableFrameUI: %s \n", gFrameHowToEnableStr[printHowEnable]);        PRINT_DEBUG_MSG2("PrintRange:         %s \n", gPrintRangeStr[printRangeType]);        return NS_OK;      }    }  }  // If we are printing "AsIs" then sets all the POs to be printed as is  if (mPrt->mPrintFrameType == nsIPrintOptions::kFramesAsIs) {    SetPrintAsIs(mPrt->mPrintObject);    SetPrintPO(mPrt->mPrintObject, PR_TRUE);    return NS_OK;  }  // If we are printing the selected Frame then  // find that PO for that selected DOMWin and set it all of its  // children to be printed  if (mPrt->mPrintFrameType == nsIPrintOptions::kSelectedFrame) {    if ((mPrt->mIsParentAFrameSet && mPrt->mCurrentFocusWin) || mPrt->mIsIFrameSelected) {      PrintObject * po = FindPrintObjectByDOMWin(mPrt->mPrintObject, mPrt->mCurrentFocusWin);      if (po != nsnull) {        mPrt->mSelectedPO = po;        // NOTE: Calling this sets the "po" and         // we don't want to do this for documents that have no children,        // because then the "DoEndPage" gets called and it shouldn't         if (po->mKids.Count() > 0) {          // Makes sure that itself, and all of its children are printed "AsIs"          SetPrintAsIs(po);        }        // Now, only enable this POs (the selected PO) and all of its children        SetPrintPO(po, PR_TRUE);      }    }    return NS_OK;  }     // If we are print each subdoc separately,   // then don't print any of the FraneSet Docs   if (mPrt->mPrintFrameType == nsIPrintOptions::kEachFrameSep) {    SetPrintPO(mPrt->mPrintObject, PR_TRUE);    PRInt32 cnt = mPrt->mPrintDocList->Count();    for (PRInt32 i=0;i<cnt;i++) {      PrintObject* po = (PrintObject*)mPrt->mPrintDocList->ElementAt(i);      NS_ASSERTION(po, "PrintObject can't be null!");      if (po->mFrameType == eFrameSet) {        po->mDontPrint = PR_TRUE;      }    }  }  return NS_OK;}