mPresContext->GetPixelsToTwips(&p2t);
p2t = mPresContext->PixelsToTwips();
DocumentViewerImpl::InstallNewPresentation(){#if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW)  // Get the current size of what is being viewed  nsRect area = mPresContext->GetVisibleArea();  nsRect bounds;  mWindow->GetBounds(bounds);  // In case we have focus focus the parent DocShell  // which in this case should always be chrome  nsCOMPtr<nsIDocShellTreeItem>  dstParentItem;  nsCOMPtr<nsIDocShellTreeItem>  dstItem(do_QueryInterface(mContainer));  if (dstItem) {    dstItem->GetParent(getter_AddRefs(dstParentItem));    nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(dstParentItem));    if (docShell) {      docShell->SetHasFocus(PR_TRUE);    }  }  // turn off selection painting  nsCOMPtr<nsISelectionController> selectionController =    do_QueryInterface(mPresShell);  if (selectionController) {    selectionController->SetDisplaySelection(nsISelectionController::SELECTION_OFF);  }  // Start to kill off the old Presentation  // by cleaning up the PresShell  if (mPresShell) {    // Break circular reference (or something)    mPresShell->EndObservingDocument();    nsCOMPtr<nsISelection> selection;    nsresult rv = GetDocumentSelection(getter_AddRefs(selection));    nsCOMPtr<nsISelectionPrivate> selPrivate(do_QueryInterface(selection));    if (NS_SUCCEEDED(rv) && selPrivate && mSelectionListener)      selPrivate->RemoveSelectionListener(mSelectionListener);    // We need to destroy the PreShell if there is an existing PP    // or we are not caching the original Presentation    if (!mPrintEngine->IsCachingPres() || mPrintEngine->IsOldPrintPreviewPres()) {      mPresShell->Destroy();    }  }  // clear weak references before we go away  if (mPresContext) {    mPresContext->SetContainer(nsnull);    mPresContext->SetLinkHandler(nsnull);  }  // See if we are suppose to be caching the old Presentation  // and then check to see if we already have.  if (mPrintEngine->IsCachingPres() && !mPrintEngine->HasCachedPres()) {    // Cach old presentation    mPrintEngine->CachePresentation(mPresShell, mPresContext, mViewManager, mWindow);    mWindow->Show(PR_FALSE);  } else {    // Destroy the old Presentation    mPresShell    = nsnull;    mPresContext  = nsnull;    mViewManager  = nsnull;    mWindow       = nsnull;  }  // XXX InstallPrintPreviewListener();  mPrintEngine->GetNewPresentation(mPresShell, mPresContext, mViewManager, mWindow);  mPresShell->BeginObservingDocument();  nscoord width  = bounds.width;  nscoord height = bounds.height;  float p2t;  mPresContext->GetPixelsToTwips(&p2t);  width = NSIntPixelsToTwips(width, p2t);  height = NSIntPixelsToTwips(height, p2t);  mViewManager->DisableRefresh();  mViewManager->SetWindowDimensions(width, height);  mDeviceContext->SetUseAltDC(kUseAltDCFor_FONTMETRICS, PR_FALSE);  mDeviceContext->SetUseAltDC(kUseAltDCFor_CREATERC_PAINT, PR_TRUE);  mViewManager->EnableRefresh(NS_VMREFRESH_NO_SYNC);  Show();  mPrintEngine->ShowDocList(PR_TRUE);#endif // NS_PRINTING && NS_PRINT_PREVIEW}