layout/html/base/src/nsSimplePageSequence.cpp - Revision 3.66

There were 20 changes made.
Legend
   Added lines
   Changed lines
   Removed lines

layout/html/base/src/nsSimplePageSequence.cpp,3.66
.
Disk File
Skipping to line 46. 
#include "nsIDeviceContext.h"
.
#include "nsIDeviceContext.h"
#include "nsIViewManager.h"
.
#include "nsIViewManager.h"
#include "nsIPresShell.h"
.
#include "nsIPresShell.h"
#include "nsIStyleSet.h"
.
#include "nsIStyleSet.h"
#include "nsIFontMetrics.h"
.
#include "nsIFontMetrics.h"
#include "nsIPrintOptions.h"
.
#include "nsIPrintSettings.h"
#include "nsPageFrame.h"
.
#include "nsPageFrame.h"
#include "nsIPrintPreviewContext.h"
.
#include "nsIPrintPreviewContext.h"
#include "nsStyleConsts.h"
.
#include "nsStyleConsts.h"
#include "nsIRegion.h"
.
#include "nsIRegion.h"
 
.
 
Skipping to line 73. 
// a string from a string bundle
.
// a string from a string bundle
#include "nsFormControlHelper.h"
.
#include "nsFormControlHelper.h"
#define PRINTING_PROPERTIES "chrome://communicator/locale/printing.properties"
.
#define PRINTING_PROPERTIES "chrome://communicator/locale/printing.properties"
 
.
 
// Print Options
.
// Print Options
 
.
#include "nsIPrintSettings.h"
#include "nsIPrintOptions.h"
.
#include "nsIPrintOptions.h"
#include "nsGfxCIID.h"
.
#include "nsGfxCIID.h"
#include "nsIServiceManager.h"
.
#include "nsIServiceManager.h"
static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID);
.
static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID);
//
.
//
Skipping to line 161. 
  }
.
  }
 
.
 
  // XXX this code and the object data member "mIsPrintingSelection" is only n
eeded
.
  // XXX this code and the object data member "mIsPrintingSelection" is only n
eeded
  // for the hack for printing selection where we make the page the max size
.
  // for the hack for printing selection where we make the page the max size
  nsresult rv;
.
  nsresult rv;
   mPageData->mPrintOptions = do_GetService(kPrintOptionsCID, &rv);
.
  mPageData->mPrintOptions = do_GetService(kPrintOptionsCID, &rv);
  if (NS_SUCCEEDED(rv) && mPageData->mPrintOptions) {
.
  if (NS_SUCCEEDED(rv) && mPageData->mPrintOptions) {
    PRInt16 printType;
.
 
    mPageData->mPrintOptions->GetPrintRange(&printType);
.
 
    mIsPrintingSelection = nsIPrintOptions::kRangeSelection == printType;
.
 
    mPageData->mPrintOptions->GetMarginInTwips(mMargin);
.
 
 
.
 
    // now get the default font form the print options
.
    // now get the default font form the print options
    mPageData->mPrintOptions->GetDefaultFont(*mPageData->mHeadFootFont);
.
    mPageData->mPrintOptions->GetDefaultFont(*mPageData->mHeadFootFont);
  }
.
  }
  mSkipPageBegin = PR_FALSE;
.
  mSkipPageBegin = PR_FALSE;
  mSkipPageEnd   = PR_FALSE;
.
  mSkipPageEnd   = PR_FALSE;
Skipping to line 499. 
  }
.
  }
 
.
 
  return ret;
.
  return ret;
}
.
}
 
.
 
NS_IMETHODIMP
.
NS_IMETHODIMP
nsSimplePageSequenceFrame::Print(nsIPresContext*         aPresContext,
.
 
                                 nsIPrintOptions*        aPrintOptions,
.
 
                                 nsIPrintStatusCallback* aStatusCallback)
.
 
{
.
 
  NS_ASSERTION(0, "No longer being used.");
.
 
  return NS_ERROR_FAILURE;
.
 
}
.
 
 
.
 
NS_IMETHODIMP
.
 
nsSimplePageSequenceFrame::SetOffsets(nscoord aStartOffset, nscoord aEndOffset
)
.
nsSimplePageSequenceFrame::SetOffsets(nscoord aStartOffset, nscoord aEndOffset
)
{
.
{
  mStartOffset = aStartOffset;
.
  mStartOffset = aStartOffset;
  mEndOffset   = aEndOffset;
.
  mEndOffset   = aEndOffset;
  return NS_OK;
.
  return NS_OK;
Skipping to line 588. 
  return nsnull;
.
  return nsnull;
}
.
}
 
.
 
NS_IMETHODIMP
.
NS_IMETHODIMP
nsSimplePageSequenceFrame::StartPrint(nsIPresContext*  aPresContext,
.
nsSimplePageSequenceFrame::StartPrint(nsIPresContext*  aPresContext,
                                      nsIPrintOptions* aPrintOptions)
.
                                      nsIPrintSettings* aPrintSettings)
{
.
{
  NS_ENSURE_ARG_POINTER(aPresContext);
.
  NS_ENSURE_ARG_POINTER(aPresContext);
  NS_ENSURE_ARG_POINTER(aPrintOptions);
.
  NS_ENSURE_ARG_POINTER(aPrintSettings);
 
.
 
 
.
  if (!mPageData->mPrintSettings) {
 
.
    mPageData->mPrintSettings = aPrintSettings;
 
.
  }
 
.
 
  PRInt16 printType;
.
  PRInt16 printType;
  aPrintOptions->GetPrintRange(&printType);
.
  aPrintSettings->GetPrintRange(&printType);
  mPrintRangeType = printType;
.
  mPrintRangeType = printType;
  aPrintOptions->GetStartPageRange(&mFromPageNum);
.
  mIsPrintingSelection = nsIPrintSettings::kRangeSelection == printType;
  aPrintOptions->GetEndPageRange(&mToPageNum);
.
  aPrintSettings->GetMarginInTwips(mMargin);
  aPrintOptions->GetMarginInTwips(mMargin);
.
 
 
.
  aPrintSettings->GetStartPageRange(&mFromPageNum);
 
.
  aPrintSettings->GetEndPageRange(&mToPageNum);
 
.
  aPrintSettings->GetMarginInTwips(mMargin);
 
.
 
  mDoingPageRange = nsIPrintOptions::kRangeSpecifiedPageRange == mPrintRangeTy
pe ||
.
  mDoingPageRange = nsIPrintSettings::kRangeSpecifiedPageRange == mPrintRangeT
ype ||
                    nsIPrintOptions::kRangeSelection == mPrintRangeType;
.
                    nsIPrintSettings::kRangeSelection == mPrintRangeType;
 
.
 
  // If printing a range of pages make sure at least the starting page
.
  // If printing a range of pages make sure at least the starting page
  // number is valid
.
  // number is valid
  PRInt32 totalPages = mFrames.GetLength();
.
  PRInt32 totalPages = mFrames.GetLength();
 
.
 
Skipping to line 662. 
      fprintf(mDebugFD, " Page: %p  No: %d - [%5d,%5d,%5d,%5d] ", page, pageNu
m, rect.x, rect.y, rect.width, rect.height);
.
      fprintf(mDebugFD, " Page: %p  No: %d - [%5d,%5d,%5d,%5d] ", page, pageNu
m, rect.x, rect.y, rect.width, rect.height);
      fprintf(mDebugFD, " [%5d,%5d,%5d,%5d]\n", viewRect.x, viewRect.y, viewRe
ct.width, viewRect.height);
.
      fprintf(mDebugFD, " [%5d,%5d,%5d,%5d]\n", viewRect.x, viewRect.y, viewRe
ct.width, viewRect.height);
      pageNum++;
.
      pageNum++;
    }
.
    }
  }
.
  }
  //printf("***** Setting aPresContext %p is painting selection %d\n", aPresCo
ntext, nsIPrintOptions::kRangeSelection == mPrintRangeType);
.
  //printf("***** Setting aPresContext %p is painting selection %d\n", aPresCo
ntext, nsIPrintSettings::kRangeSelection == mPrintRangeType);
#endif
.
#endif
 
.
 
  // Determine if we are rendering only the selection
.
  // Determine if we are rendering only the selection
  aPresContext->SetIsRenderingOnlySelection(nsIPrintOptions::kRangeSelection =
= mPrintRangeType);
.
  aPresContext->SetIsRenderingOnlySelection(nsIPrintSettings::kRangeSelection 
== mPrintRangeType);
 
.
 
 
.
 
  if (mDoingPageRange) {
.
  if (mDoingPageRange) {
    // XXX because of the hack for making the selection all print on one page
.
    // XXX because of the hack for making the selection all print on one page
    // we must make sure that the page is sized correctly before printing.
.
    // we must make sure that the page is sized correctly before printing.
Skipping to line 716. 
      }
.
      }
      pageNum++;
.
      pageNum++;
    }
.
    }
 
.
 
    // adjust total number of pages
.
    // adjust total number of pages
    if (nsIPrintOptions::kRangeSelection == mPrintRangeType) {
.
    if (nsIPrintSettings::kRangeSelection == mPrintRangeType) {
      totalPages = mToPageNum - mFromPageNum + 1;
.
      totalPages = mToPageNum - mFromPageNum + 1;
    } else {
.
    } else {
      totalPages = pageNum - 1;
.
      totalPages = pageNum - 1;
    }
.
    }
  }
.
  }
Skipping to line 747. 
    pointSize = fontSizeStr.ToInteger(&errCode);
.
    pointSize = fontSizeStr.ToInteger(&errCode);
    if (NS_FAILED(errCode)) {
.
    if (NS_FAILED(errCode)) {
      pointSize = 10;
.
      pointSize = 10;
    }
.
    }
  }
.
  }
  aPrintOptions->SetFontNamePointSize(fontName, pointSize);
.
  mPageData->mPrintOptions->SetFontNamePointSize(fontName, pointSize);
 
.
 
  // Doing this here so we only have to go get these formats once
.
  // Doing this here so we only have to go get these formats once
  SetPageNumberFormat("pagenumber",  "%1$d", PR_TRUE);
.
  SetPageNumberFormat("pagenumber",  "%1$d", PR_TRUE);
  SetPageNumberFormat("pageofpages", "%1$d of %2$d", PR_FALSE);
.
  SetPageNumberFormat("pageofpages", "%1$d of %2$d", PR_FALSE);
 
.
 
Skipping to line 762. 
 
.
 
  return rv;
.
  return rv;
}
.
}
 
.
 
NS_IMETHODIMP
.
NS_IMETHODIMP
nsSimplePageSequenceFrame::PrintNextPage(nsIPresContext*  aPresContext,
.
nsSimplePageSequenceFrame::PrintNextPage(nsIPresContext*  aPresContext)
                                         nsIPrintOptions* aPrintOptions)
.
 
{
.
{
  NS_ENSURE_ARG_POINTER(aPresContext);
.
  NS_ENSURE_ARG_POINTER(aPresContext);
  NS_ENSURE_ARG_POINTER(aPrintOptions);
.
 
 
.
 
  // Print each specified page
.
  // Print each specified page
  // pageNum keeps track of the current page and what pages are printing
.
  // pageNum keeps track of the current page and what pages are printing
  //
.
  //
  // printedPageNum keeps track of the current page number to be printed
.
  // printedPageNum keeps track of the current page number to be printed
Skipping to line 782. 
  if (mCurrentPageFrame == nsnull) {
.
  if (mCurrentPageFrame == nsnull) {
    return NS_ERROR_FAILURE;
.
    return NS_ERROR_FAILURE;
  }
.
  }
 
.
 
  PRBool printEvenPages, printOddPages;
.
  PRBool printEvenPages, printOddPages;
  aPrintOptions->GetPrintOptions(nsIPrintOptions::kOptPrintEvenPages, &printEv
enPages);
.
  mPageData->mPrintSettings->GetPrintOptions(nsIPrintSettings::kPrintEvenPages
, &printEvenPages);
  aPrintOptions->GetPrintOptions(nsIPrintOptions::kOptPrintOddPages, &printOdd
Pages);
.
  mPageData->mPrintSettings->GetPrintOptions(nsIPrintSettings::kPrintOddPages,
 &printOddPages);
 
.
 
  // Begin printing of the document
.
  // Begin printing of the document
  nsCOMPtr<nsIDeviceContext> dc;
.
  nsCOMPtr<nsIDeviceContext> dc;
  aPresContext->GetDeviceContext(getter_AddRefs(dc));
.
  aPresContext->GetDeviceContext(getter_AddRefs(dc));
  NS_ASSERTION(dc, "nsIDeviceContext can't be NULL!");
.
  NS_ASSERTION(dc, "nsIDeviceContext can't be NULL!");
Skipping to line 856. 
    if (mSelectionHeight > -1) {
.
    if (mSelectionHeight > -1) {
      nsIFrame* childFrame = mFrames.FirstChild();
.
      nsIFrame* childFrame = mFrames.FirstChild();
      nsIFrame* conFrame;
.
      nsIFrame* conFrame;
      childFrame->FirstChild(aPresContext, nsnull, &conFrame);
.
      childFrame->FirstChild(aPresContext, nsnull, &conFrame);
      conFrame->GetView(aPresContext, &containerView);
.
      conFrame->GetView(aPresContext, &containerView);
 
.
      NS_ASSERTION(containerView != nsnull, "Container view can't be null!");
      containerView->GetBounds(containerRect);
.
      containerView->GetBounds(containerRect);
      containerRect.y -= mYSelOffset;
.
      containerRect.y -= mYSelOffset;
      containerRect.height = height-mYSelOffset;
.
      containerRect.height = height-mYSelOffset;
      
.
      
      vm->MoveViewTo(containerView, containerRect.x, containerRect.y);
.
      vm->MoveViewTo(containerView, containerRect.x, containerRect.y);
Skipping to line 926. 
      }
.
      }
    }
.
    }
  }
.
  }
 
.
 
  if (!mSkipPageEnd) {
.
  if (!mSkipPageEnd) {
    if (nsIPrintOptions::kRangeSelection != mPrintRangeType ||
.
    if (nsIPrintSettings::kRangeSelection != mPrintRangeType ||
        (nsIPrintOptions::kRangeSelection == mPrintRangeType && mPrintThisPage
)) {
.
        (nsIPrintSettings::kRangeSelection == mPrintRangeType && mPrintThisPag
e)) {
      mPrintedPageNum++;
.
      mPrintedPageNum++;
    }
.
    }
 
.
 
    mPageNum++;
.
    mPageNum++;
    rv = mCurrentPageFrame->GetNextSibling(&mCurrentPageFrame);
.
    rv = mCurrentPageFrame->GetNextSibling(&mCurrentPageFrame);
Skipping to line 957. 
	      return rv;
.
	      return rv;
      }
.
      }
    }
.
    }
  }
.
  }
 
.
 
  if (nsIPrintOptions::kRangeSelection != mPrintRangeType ||
.
  if (nsIPrintSettings::kRangeSelection != mPrintRangeType ||
      (nsIPrintOptions::kRangeSelection == mPrintRangeType && mPrintThisPage))
 {
.
      (nsIPrintSettings::kRangeSelection == mPrintRangeType && mPrintThisPage)
) {
    mPrintedPageNum++;
.
    mPrintedPageNum++;
  }
.
  }
 
.
 
  mPageNum++;
.
  mPageNum++;
  
.