1998-11-05 02:21:50 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
1998-11-05 02:21:50 +03:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
1998-11-05 02:21:50 +03:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1998-11-05 02:21:50 +03:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:40:37 +03:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1998-11-05 02:21:50 +03:00
|
|
|
*/
|
1999-02-12 20:45:58 +03:00
|
|
|
#include "nsCOMPtr.h"
|
1998-11-05 02:21:50 +03:00
|
|
|
#include "nsSimplePageSequence.h"
|
|
|
|
#include "nsIPresContext.h"
|
1998-11-05 09:13:55 +03:00
|
|
|
#include "nsIReflowCommand.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
1998-11-05 02:21:50 +03:00
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsHTMLAtoms.h"
|
1998-12-07 06:43:02 +03:00
|
|
|
#include "nsHTMLIIDs.h"
|
|
|
|
#include "nsIDeviceContext.h"
|
|
|
|
#include "nsIViewManager.h"
|
|
|
|
#include "nsIPresShell.h"
|
1999-02-24 07:03:50 +03:00
|
|
|
#include "nsIStyleSet.h"
|
2001-01-27 17:09:34 +03:00
|
|
|
#include "nsIFontMetrics.h"
|
|
|
|
#include "nsIPrintOptions.h"
|
|
|
|
#include "nsPageFrame.h"
|
|
|
|
|
|
|
|
#define OFFSET_NOT_SET -1
|
|
|
|
|
|
|
|
// This is for localization of the "x of n" pages string
|
|
|
|
// this class contains a helper method we need to get
|
|
|
|
// a string from a string bundle
|
|
|
|
#include "nsFormControlHelper.h"
|
|
|
|
#define PRINTING_PROPERTIES "chrome://communicator/locale/printing.properties"
|
|
|
|
|
|
|
|
// Print Options
|
|
|
|
#include "nsIPrintOptions.h"
|
|
|
|
#include "nsGfxCIID.h"
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID);
|
|
|
|
//
|
1998-12-07 06:43:02 +03:00
|
|
|
|
2001-04-12 17:04:29 +04:00
|
|
|
#if defined(DEBUG_rods) || defined(DEBUG_dcone)
|
|
|
|
#define DEBUG_PRINTING
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DEBUG_PRINTING
|
|
|
|
#define PRINT_DEBUG_MSG1(_msg1) fprintf(mDebugFD, (_msg1))
|
|
|
|
#define PRINT_DEBUG_MSG2(_msg1, _msg2) fprintf(mDebugFD, (_msg1), (_msg2))
|
|
|
|
#define PRINT_DEBUG_MSG3(_msg1, _msg2, _msg3) fprintf(mDebugFD, (_msg1), (_msg2), (_msg3))
|
|
|
|
#define PRINT_DEBUG_MSG4(_msg1, _msg2, _msg3, _msg4) fprintf(mDebugFD, (_msg1), (_msg2), (_msg3), (_msg4))
|
|
|
|
#define PRINT_DEBUG_MSG5(_msg1, _msg2, _msg3, _msg4, _msg5) fprintf(mDebugFD, (_msg1), (_msg2), (_msg3), (_msg4), (_msg5))
|
|
|
|
#else //--------------
|
|
|
|
#define PRINT_DEBUG_MSG1(_msg)
|
|
|
|
#define PRINT_DEBUG_MSG2(_msg1, _msg2)
|
|
|
|
#define PRINT_DEBUG_MSG3(_msg1, _msg2, _msg3)
|
|
|
|
#define PRINT_DEBUG_MSG4(_msg1, _msg2, _msg3, _msg4)
|
|
|
|
#define PRINT_DEBUG_MSG5(_msg1, _msg2, _msg3, _msg4, _msg5)
|
|
|
|
#endif
|
|
|
|
|
1999-05-12 02:03:29 +04:00
|
|
|
nsresult
|
1999-12-05 02:49:50 +03:00
|
|
|
NS_NewSimplePageSequenceFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
1999-05-12 02:03:29 +04:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-12-05 02:49:50 +03:00
|
|
|
nsSimplePageSequenceFrame* it = new (aPresShell) nsSimplePageSequenceFrame;
|
1999-05-12 02:03:29 +04:00
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
*aNewFrame = it;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-27 17:09:34 +03:00
|
|
|
nsSimplePageSequenceFrame::nsSimplePageSequenceFrame() :
|
|
|
|
mIsPrintingSelection(PR_FALSE)
|
|
|
|
{
|
|
|
|
mStartOffset = OFFSET_NOT_SET;
|
|
|
|
mEndOffset = OFFSET_NOT_SET;
|
|
|
|
|
|
|
|
nscoord halfInch = NS_INCHES_TO_TWIPS(0.5);
|
|
|
|
mMargin.SizeTo(halfInch, halfInch, halfInch, halfInch);
|
|
|
|
|
|
|
|
// XXX this code and the object data member "mIsPrintingSelection" is only needed
|
|
|
|
// for the hack for printing selection where we make the page the max size
|
|
|
|
nsresult rv;
|
2001-07-25 11:54:28 +04:00
|
|
|
nsCOMPtr<nsIPrintOptions> printService =
|
|
|
|
do_GetService(kPrintOptionsCID, &rv);
|
2001-01-27 17:09:34 +03:00
|
|
|
if (NS_SUCCEEDED(rv) && printService) {
|
2001-02-02 11:42:53 +03:00
|
|
|
PRInt16 printType;
|
2001-01-27 17:09:34 +03:00
|
|
|
printService->GetPrintRange(&printType);
|
2001-02-02 11:42:53 +03:00
|
|
|
mIsPrintingSelection = nsIPrintOptions::kRangeSelection == printType;
|
2001-07-19 00:57:10 +04:00
|
|
|
printService->GetMarginInTwips(mMargin);
|
2001-01-27 17:09:34 +03:00
|
|
|
}
|
2001-04-12 17:04:29 +04:00
|
|
|
mSkipPageBegin = PR_FALSE;
|
|
|
|
mSkipPageEnd = PR_FALSE;
|
|
|
|
mPrintThisPage = PR_FALSE;
|
|
|
|
mOffsetX = 0;
|
|
|
|
mOffsetY = 0;
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
mDebugFD = stdout;
|
|
|
|
#endif
|
2001-01-27 17:09:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsSimplePageSequenceFrame::~nsSimplePageSequenceFrame()
|
1999-05-12 02:03:29 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1998-12-07 06:43:02 +03:00
|
|
|
nsresult
|
|
|
|
nsSimplePageSequenceFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(0 != aInstancePtr, "null ptr");
|
|
|
|
if (NULL == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
if (aIID.Equals(kIPageSequenceFrameIID)) {
|
|
|
|
*aInstancePtr = (void*)(nsIPageSequenceFrame*)this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return nsContainerFrame::QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
1998-11-05 02:21:50 +03:00
|
|
|
|
1999-07-03 06:22:10 +04:00
|
|
|
// Creates a continuing page frame
|
|
|
|
nsresult
|
1999-11-24 09:03:41 +03:00
|
|
|
nsSimplePageSequenceFrame::CreateContinuingPageFrame(nsIPresContext* aPresContext,
|
1999-07-03 06:22:10 +04:00
|
|
|
nsIFrame* aPageFrame,
|
|
|
|
nsIFrame** aContinuingPage)
|
|
|
|
{
|
|
|
|
nsIPresShell* presShell;
|
|
|
|
nsIStyleSet* styleSet;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
// Create the continuing frame
|
1999-11-24 09:03:41 +03:00
|
|
|
aPresContext->GetShell(&presShell);
|
1999-07-03 06:22:10 +04:00
|
|
|
presShell->GetStyleSet(&styleSet);
|
|
|
|
NS_RELEASE(presShell);
|
1999-11-24 09:03:41 +03:00
|
|
|
rv = styleSet->CreateContinuingFrame(aPresContext, aPageFrame, this, aContinuingPage);
|
1999-07-03 06:22:10 +04:00
|
|
|
NS_RELEASE(styleSet);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handles incremental reflow
|
|
|
|
nsresult
|
1999-11-24 09:03:41 +03:00
|
|
|
nsSimplePageSequenceFrame::IncrementalReflow(nsIPresContext* aPresContext,
|
1999-07-03 06:22:10 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsSize& aPageSize,
|
|
|
|
nscoord aX,
|
|
|
|
nscoord& aY)
|
|
|
|
{
|
|
|
|
// We don't expect the target of the reflow command to be the simple
|
|
|
|
// page sequence frame
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
nsIFrame* targetFrame;
|
|
|
|
aReflowState.reflowCommand->GetTarget(targetFrame);
|
|
|
|
NS_ASSERTION(targetFrame != this, "simple page sequence frame is reflow command target");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Get the next child frame in the target chain
|
|
|
|
nsIFrame* nextFrame;
|
|
|
|
aReflowState.reflowCommand->GetNext(nextFrame);
|
|
|
|
|
|
|
|
// Compute the y-offset of this page
|
2001-01-27 17:09:34 +03:00
|
|
|
for (nsIFrame* f = mFrames.FirstChild(); f != nextFrame; f->GetNextSibling(&f)) {
|
1999-07-03 06:22:10 +04:00
|
|
|
nsSize size;
|
|
|
|
f->GetSize(size);
|
2001-01-27 17:09:34 +03:00
|
|
|
aY += size.height + mMargin.top + mMargin.bottom;
|
1999-07-03 06:22:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Reflow the page
|
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState,
|
|
|
|
nextFrame, aPageSize);
|
|
|
|
nsHTMLReflowMetrics kidSize(nsnull);
|
|
|
|
nsReflowStatus status;
|
|
|
|
|
|
|
|
// Dispatch the reflow command to our child frame. Allow it to be as high
|
|
|
|
// as it wants
|
1999-11-19 18:33:29 +03:00
|
|
|
ReflowChild(nextFrame, aPresContext, kidSize, kidReflowState, aX, aY, 0, status);
|
1999-07-03 06:22:10 +04:00
|
|
|
|
|
|
|
// Place and size the page. If the page is narrower than our max width, then
|
|
|
|
// center it horizontally
|
1999-11-19 18:33:29 +03:00
|
|
|
FinishReflowChild(nextFrame, aPresContext, kidSize, aX, aY, 0);
|
2001-01-27 17:09:34 +03:00
|
|
|
aY += kidSize.height + mMargin.top + mMargin.bottom;
|
1999-07-03 06:22:10 +04:00
|
|
|
|
|
|
|
// Check if the page is complete...
|
|
|
|
nsIFrame* kidNextInFlow;
|
|
|
|
nextFrame->GetNextInFlow(&kidNextInFlow);
|
|
|
|
|
|
|
|
if (NS_FRAME_IS_COMPLETE(status)) {
|
|
|
|
NS_ASSERTION(nsnull == kidNextInFlow, "bad child flow list");
|
|
|
|
} else {
|
|
|
|
nsReflowReason reflowReason = eReflowReason_Resize;
|
|
|
|
|
|
|
|
if (!kidNextInFlow) {
|
|
|
|
// The page isn't complete and it doesn't have a next-in-flow so
|
|
|
|
// create a continuing page
|
|
|
|
nsIFrame* continuingPage;
|
|
|
|
CreateContinuingPageFrame(aPresContext, nextFrame, &continuingPage);
|
|
|
|
|
|
|
|
// Add it to our child list
|
|
|
|
nextFrame->SetNextSibling(continuingPage);
|
|
|
|
reflowReason = eReflowReason_Initial;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reflow the remaining pages
|
|
|
|
// XXX Ideally we would only reflow the next page if the current page indicated
|
|
|
|
// its next-in-flow was dirty...
|
|
|
|
nsIFrame* kidFrame;
|
|
|
|
nextFrame->GetNextSibling(&kidFrame);
|
|
|
|
|
|
|
|
while (kidFrame) {
|
|
|
|
// Reflow the page
|
1999-09-21 06:20:14 +04:00
|
|
|
nsHTMLReflowMetrics childSize(nsnull);
|
1999-07-03 06:22:10 +04:00
|
|
|
nsHTMLReflowState childReflowState(aPresContext, aReflowState, kidFrame,
|
|
|
|
aPageSize, reflowReason);
|
|
|
|
|
|
|
|
// Place and size the page. If the page is narrower than our
|
|
|
|
// max width then center it horizontally
|
1999-09-21 06:20:14 +04:00
|
|
|
ReflowChild(kidFrame, aPresContext, childSize, childReflowState,
|
1999-11-19 18:33:29 +03:00
|
|
|
aX, aY, 0, status);
|
|
|
|
|
|
|
|
FinishReflowChild(kidFrame, aPresContext, childSize, aX, aY, 0);
|
1999-09-21 06:20:14 +04:00
|
|
|
aY += childSize.height;
|
1999-07-03 06:22:10 +04:00
|
|
|
|
|
|
|
// Leave a slight gap between the pages
|
2001-01-27 17:09:34 +03:00
|
|
|
aY += mMargin.top + mMargin.bottom;
|
1999-07-03 06:22:10 +04:00
|
|
|
|
|
|
|
// Is the page complete?
|
|
|
|
kidFrame->GetNextInFlow(&kidNextInFlow);
|
|
|
|
|
|
|
|
if (NS_FRAME_IS_COMPLETE(status)) {
|
|
|
|
NS_ASSERTION(nsnull == kidNextInFlow, "bad child flow list");
|
|
|
|
} else if (nsnull == kidNextInFlow) {
|
|
|
|
// The page isn't complete and it doesn't have a next-in-flow, so
|
|
|
|
// create a continuing page
|
|
|
|
nsIFrame* continuingPage;
|
|
|
|
CreateContinuingPageFrame(aPresContext, kidFrame, &continuingPage);
|
|
|
|
|
|
|
|
// Add it to our child list
|
|
|
|
kidFrame->SetNextSibling(continuingPage);
|
|
|
|
reflowReason = eReflowReason_Initial;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the next page
|
|
|
|
kidFrame->GetNextSibling(&kidFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-11-05 02:21:50 +03:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsSimplePageSequenceFrame::Reflow(nsIPresContext* aPresContext,
|
1998-11-05 02:21:50 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2000-04-21 18:59:47 +04:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsSimplePageSequenceFrame", aReflowState.reason);
|
1998-11-05 02:21:50 +03:00
|
|
|
NS_FRAME_TRACE_REFLOW_IN("nsSimplePageSequenceFrame::Reflow");
|
|
|
|
|
1999-03-10 01:34:51 +03:00
|
|
|
aStatus = NS_FRAME_COMPLETE; // we're always complete
|
1998-11-05 02:21:50 +03:00
|
|
|
|
|
|
|
// Compute the size of each page and the x coordinate that each page will
|
|
|
|
// be placed at
|
2001-04-12 17:04:29 +04:00
|
|
|
nsRect pageSize;
|
|
|
|
nsRect adjSize;
|
|
|
|
aPresContext->GetPageDim(&pageSize, &adjSize);
|
|
|
|
|
|
|
|
PRBool suppressLeftMargin = PR_FALSE;
|
|
|
|
PRBool suppressRightMargin = PR_FALSE;
|
|
|
|
PRBool suppressTopMargin = PR_FALSE;
|
|
|
|
PRBool suppressBottomMargin = PR_FALSE;
|
|
|
|
|
|
|
|
if (pageSize != adjSize &&
|
|
|
|
(adjSize.x != 0 || adjSize.y != 0 || adjSize.width != 0 || adjSize.height != 0)) {
|
|
|
|
suppressLeftMargin = pageSize.x != adjSize.x;
|
|
|
|
suppressTopMargin = pageSize.y != adjSize.y;
|
|
|
|
if (pageSize.width != adjSize.width) {
|
|
|
|
suppressRightMargin = PR_TRUE;
|
|
|
|
pageSize.width = adjSize.width;
|
|
|
|
}
|
|
|
|
if (pageSize.height != adjSize.height) {
|
|
|
|
suppressBottomMargin = PR_TRUE;
|
|
|
|
pageSize.height = adjSize.height;
|
|
|
|
}
|
|
|
|
}
|
1998-11-05 02:21:50 +03:00
|
|
|
|
2001-01-27 17:09:34 +03:00
|
|
|
// XXX - Hack Alert
|
|
|
|
// OK, so ther eis a selection, we will print the entire selection
|
|
|
|
// on one page and then crop the page.
|
|
|
|
// This means you can never print any selection that is longer than one page
|
|
|
|
// put it keeps it from page breaking in the middle of your print of the selection
|
|
|
|
// (see also nsDocumentViewer.cpp)
|
|
|
|
if (mIsPrintingSelection) {
|
|
|
|
pageSize.height = 0x0FFFFFFF;
|
1998-11-05 02:21:50 +03:00
|
|
|
}
|
|
|
|
|
2001-04-12 17:04:29 +04:00
|
|
|
// only use this local margin for sizing,
|
|
|
|
// not for positioning
|
|
|
|
nsMargin margin(suppressLeftMargin?0:mMargin.left,
|
|
|
|
suppressTopMargin?0:mMargin.top,
|
|
|
|
suppressRightMargin?0:mMargin.right,
|
|
|
|
suppressBottomMargin?0:mMargin.bottom);
|
2001-01-27 17:09:34 +03:00
|
|
|
|
2001-04-12 17:04:29 +04:00
|
|
|
nscoord x = mMargin.left;
|
|
|
|
nscoord y = mMargin.top;// Running y-offset for each page
|
1998-11-05 02:21:50 +03:00
|
|
|
|
1999-07-03 06:22:10 +04:00
|
|
|
// See if it's an incremental reflow command
|
1998-11-05 02:21:50 +03:00
|
|
|
if (eReflowReason_Incremental == aReflowState.reason) {
|
2001-03-27 15:56:03 +04:00
|
|
|
// XXX Skip Incremental reflow,
|
|
|
|
// in fact, all we want is the initial reflow
|
|
|
|
//IncrementalReflow(aPresContext, aReflowState, pageSize, x, y);
|
1998-11-05 02:21:50 +03:00
|
|
|
|
|
|
|
} else {
|
|
|
|
nsReflowReason reflowReason = aReflowState.reason;
|
|
|
|
|
|
|
|
// Tile the pages vertically
|
|
|
|
nsHTMLReflowMetrics kidSize(nsnull);
|
1999-01-16 01:53:39 +03:00
|
|
|
for (nsIFrame* kidFrame = mFrames.FirstChild(); nsnull != kidFrame; ) {
|
1998-11-05 02:21:50 +03:00
|
|
|
// Reflow the page
|
2001-04-12 17:04:29 +04:00
|
|
|
nsSize availSize(pageSize.width, pageSize.height);
|
1999-03-05 07:29:11 +03:00
|
|
|
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, kidFrame,
|
2001-04-12 17:04:29 +04:00
|
|
|
availSize, reflowReason);
|
1998-11-05 02:21:50 +03:00
|
|
|
nsReflowStatus status;
|
2001-04-12 17:04:29 +04:00
|
|
|
kidReflowState.availableWidth = pageSize.width - margin.left - margin.right;
|
|
|
|
kidReflowState.availableHeight = pageSize.height - margin.top - margin.bottom;
|
2001-01-27 17:09:34 +03:00
|
|
|
kidReflowState.mComputedWidth = kidReflowState.availableWidth;
|
|
|
|
//kidReflowState.mComputedHeight = kidReflowState.availableHeight;
|
1998-11-05 02:21:50 +03:00
|
|
|
|
|
|
|
// Place and size the page. If the page is narrower than our
|
|
|
|
// max width then center it horizontally
|
1999-11-19 18:33:29 +03:00
|
|
|
ReflowChild(kidFrame, aPresContext, kidSize, kidReflowState, x, y, 0, status);
|
|
|
|
|
|
|
|
FinishReflowChild(kidFrame, aPresContext, kidSize, x, y, 0);
|
1998-11-05 02:21:50 +03:00
|
|
|
y += kidSize.height;
|
|
|
|
|
2001-01-27 17:09:34 +03:00
|
|
|
nsIView* view;
|
|
|
|
kidFrame->GetView(aPresContext, &view);
|
|
|
|
NS_ASSERTION(nsnull != view, "no page view");
|
|
|
|
nsRect rect;
|
|
|
|
kidFrame->GetRect(rect);
|
|
|
|
nsRect viewRect;
|
|
|
|
view->GetBounds(viewRect);
|
|
|
|
|
1998-11-05 02:21:50 +03:00
|
|
|
// Leave a slight gap between the pages
|
2001-01-27 17:09:34 +03:00
|
|
|
y += mMargin.top + mMargin.bottom;
|
1998-11-05 02:21:50 +03:00
|
|
|
|
|
|
|
// Is the page complete?
|
|
|
|
nsIFrame* kidNextInFlow;
|
1999-02-24 07:48:08 +03:00
|
|
|
kidFrame->GetNextInFlow(&kidNextInFlow);
|
1999-03-10 01:34:51 +03:00
|
|
|
|
1998-11-05 02:21:50 +03:00
|
|
|
if (NS_FRAME_IS_COMPLETE(status)) {
|
|
|
|
NS_ASSERTION(nsnull == kidNextInFlow, "bad child flow list");
|
|
|
|
} else if (nsnull == kidNextInFlow) {
|
1999-07-03 06:22:10 +04:00
|
|
|
// The page isn't complete and it doesn't have a next-in-flow, so
|
1998-11-05 02:21:50 +03:00
|
|
|
// create a continuing page
|
1999-02-24 07:03:50 +03:00
|
|
|
nsIFrame* continuingPage;
|
1999-07-03 06:22:10 +04:00
|
|
|
CreateContinuingPageFrame(aPresContext, kidFrame, &continuingPage);
|
1998-11-05 02:21:50 +03:00
|
|
|
|
|
|
|
// Add it to our child list
|
|
|
|
kidFrame->SetNextSibling(continuingPage);
|
1999-07-03 06:22:10 +04:00
|
|
|
reflowReason = eReflowReason_Initial;
|
1998-11-05 02:21:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get the next page
|
1999-02-10 09:13:38 +03:00
|
|
|
kidFrame->GetNextSibling(&kidFrame);
|
1998-11-05 02:21:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return our desired size
|
2001-01-27 17:09:34 +03:00
|
|
|
aDesiredSize.height = y;
|
|
|
|
aDesiredSize.width = pageSize.width;
|
|
|
|
aDesiredSize.ascent = aDesiredSize.height;
|
1998-11-05 02:21:50 +03:00
|
|
|
aDesiredSize.descent = 0;
|
|
|
|
|
|
|
|
NS_FRAME_TRACE_REFLOW_OUT("nsSimplePageSequeceFrame::Reflow", aStatus);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-12-07 06:43:02 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1998-11-05 02:21:50 +03:00
|
|
|
NS_IMETHODIMP
|
1998-11-19 20:22:29 +03:00
|
|
|
nsSimplePageSequenceFrame::GetFrameName(nsString& aResult) const
|
1998-11-05 02:21:50 +03:00
|
|
|
{
|
1998-11-19 20:22:29 +03:00
|
|
|
return MakeFrameName("SimplePageSequence", aResult);
|
1998-11-05 02:21:50 +03:00
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1998-11-05 02:21:50 +03:00
|
|
|
|
1998-12-07 06:43:02 +03:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Helper function that sends the progress notification. Returns PR_TRUE
|
|
|
|
// if printing should continue and PR_FALSE otherwise
|
|
|
|
static PRBool
|
|
|
|
SendStatusNotification(nsIPrintStatusCallback* aStatusCallback,
|
|
|
|
PRInt32 aPageNumber,
|
|
|
|
PRInt32 aTotalPages,
|
|
|
|
nsPrintStatus aStatus)
|
|
|
|
{
|
|
|
|
PRBool ret = PR_TRUE;
|
|
|
|
|
|
|
|
if (nsnull != aStatusCallback) {
|
|
|
|
aStatusCallback->OnProgress(aPageNumber, aTotalPages, aStatus,ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsSimplePageSequenceFrame::Print(nsIPresContext* aPresContext,
|
2001-01-27 17:09:34 +03:00
|
|
|
nsIPrintOptions* aPrintOptions,
|
1998-12-07 06:43:02 +03:00
|
|
|
nsIPrintStatusCallback* aStatusCallback)
|
|
|
|
{
|
2001-04-12 17:04:29 +04:00
|
|
|
NS_ASSERTION(0, "No longer being used.");
|
|
|
|
return NS_ERROR_FAILURE;
|
1998-12-07 06:43:02 +03:00
|
|
|
}
|
2001-01-27 17:09:34 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSimplePageSequenceFrame::SetOffsets(nscoord aStartOffset, nscoord aEndOffset)
|
|
|
|
{
|
|
|
|
mStartOffset = aStartOffset;
|
|
|
|
mEndOffset = aEndOffset;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-03-27 15:56:03 +04:00
|
|
|
//====================================================================
|
|
|
|
//== Asynch Printing
|
|
|
|
//====================================================================
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSimplePageSequenceFrame::GetCurrentPageNum(PRInt32* aPageNum)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aPageNum);
|
|
|
|
|
|
|
|
*aPageNum = mPageNum;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSimplePageSequenceFrame::GetNumPages(PRInt32* aNumPages)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aNumPages);
|
|
|
|
|
|
|
|
*aNumPages = mTotalPages;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSimplePageSequenceFrame::IsDoingPrintRange(PRBool* aDoing)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aDoing);
|
|
|
|
|
|
|
|
*aDoing = mDoingPageRange;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSimplePageSequenceFrame::GetPrintRange(PRInt32* aFromPage, PRInt32* aToPage)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aFromPage);
|
|
|
|
NS_ENSURE_ARG_POINTER(aToPage);
|
|
|
|
|
|
|
|
*aFromPage = mFromPageNum;
|
|
|
|
*aToPage = mToPageNum;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSimplePageSequenceFrame::StartPrint(nsIPresContext* aPresContext,
|
|
|
|
nsIPrintOptions* aPrintOptions)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aPresContext);
|
|
|
|
NS_ENSURE_ARG_POINTER(aPrintOptions);
|
|
|
|
|
|
|
|
PRInt16 printType;
|
|
|
|
aPrintOptions->GetPrintRange(&printType);
|
|
|
|
mPrintRangeType = printType;
|
|
|
|
aPrintOptions->GetStartPageRange(&mFromPageNum);
|
|
|
|
aPrintOptions->GetEndPageRange(&mToPageNum);
|
|
|
|
aPrintOptions->GetMarginInTwips(mMargin);
|
|
|
|
|
|
|
|
mDoingPageRange = nsIPrintOptions::kRangeSpecifiedPageRange == mPrintRangeType ||
|
|
|
|
nsIPrintOptions::kRangeSelection == mPrintRangeType;
|
|
|
|
|
|
|
|
// If printing a range of pages make sure at least the starting page
|
|
|
|
// number is valid
|
|
|
|
PRInt32 totalPages = mFrames.GetLength();
|
|
|
|
|
|
|
|
if (mDoingPageRange) {
|
|
|
|
if (mFromPageNum > totalPages) {
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Begin printing of the document
|
|
|
|
nsCOMPtr<nsIDeviceContext> dc;
|
|
|
|
aPresContext->GetDeviceContext(getter_AddRefs(dc));
|
|
|
|
NS_ASSERTION(dc, "nsIDeviceContext can't be NULL!");
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
|
|
|
NS_ASSERTION(presShell, "nsIPresShell can't be NULL!");
|
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
#if defined(DEBUG_rods) || defined(DEBUG_dcone)
|
|
|
|
{
|
|
|
|
nsIView * seqView;
|
|
|
|
GetView(aPresContext, &seqView);
|
|
|
|
nsRect rect;
|
|
|
|
GetRect(rect);
|
2001-04-12 17:04:29 +04:00
|
|
|
fprintf(mDebugFD, "Seq Frame: %p - [%5d,%5d,%5d,%5d] ", this, rect.x, rect.y, rect.width, rect.height);
|
|
|
|
fprintf(mDebugFD, "view: %p ", seqView);
|
2001-03-27 15:56:03 +04:00
|
|
|
nsRect viewRect;
|
|
|
|
if (seqView) {
|
|
|
|
seqView->GetBounds(viewRect);
|
2001-04-12 17:04:29 +04:00
|
|
|
fprintf(mDebugFD, " [%5d,%5d,%5d,%5d]", viewRect.x, viewRect.y, viewRect.width, viewRect.height);
|
2001-03-27 15:56:03 +04:00
|
|
|
}
|
2001-04-12 17:04:29 +04:00
|
|
|
fprintf(mDebugFD, "\n");
|
2001-03-27 15:56:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
PRInt32 pageNum = 1;
|
|
|
|
for (nsIFrame* page = mFrames.FirstChild(); nsnull != page; page->GetNextSibling(&page)) {
|
|
|
|
nsIView* view;
|
|
|
|
page->GetView(aPresContext, &view);
|
|
|
|
NS_ASSERTION(nsnull != view, "no page view");
|
|
|
|
nsRect rect;
|
|
|
|
page->GetRect(rect);
|
|
|
|
nsRect viewRect;
|
|
|
|
view->GetBounds(viewRect);
|
2001-04-12 17:04:29 +04:00
|
|
|
fprintf(mDebugFD, " Page: %p No: %d - [%5d,%5d,%5d,%5d] ", page, pageNum, rect.x, rect.y, rect.width, rect.height);
|
|
|
|
fprintf(mDebugFD, " [%5d,%5d,%5d,%5d]\n", viewRect.x, viewRect.y, viewRect.width, viewRect.height);
|
2001-03-27 15:56:03 +04:00
|
|
|
pageNum++;
|
|
|
|
}
|
|
|
|
}
|
2001-04-12 17:04:29 +04:00
|
|
|
//printf("***** Setting aPresContext %p is painting selection %d\n", aPresContext, nsIPrintOptions::kRangeSelection == mPrintRangeType);
|
2001-03-27 15:56:03 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Determine if we are rendering only the selection
|
|
|
|
aPresContext->SetIsRenderingOnlySelection(nsIPrintOptions::kRangeSelection == mPrintRangeType);
|
|
|
|
|
|
|
|
|
|
|
|
if (mDoingPageRange) {
|
|
|
|
// 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.
|
|
|
|
PRInt32 width,height;
|
|
|
|
dc->GetDeviceSurfaceDimensions(width,height);
|
|
|
|
height -= mMargin.top + mMargin.bottom;
|
|
|
|
|
|
|
|
PRInt32 pageNum = 1;
|
|
|
|
nscoord y = mMargin.top;
|
|
|
|
for (nsIFrame* page = mFrames.FirstChild(); nsnull != page; page->GetNextSibling(&page)) {
|
|
|
|
nsIView* view;
|
|
|
|
page->GetView(aPresContext, &view);
|
|
|
|
NS_ASSERTION(nsnull != view, "no page view");
|
|
|
|
if (pageNum < mFromPageNum || pageNum > mToPageNum) {
|
2001-05-31 01:19:46 +04:00
|
|
|
// Hide the pages that won't be printed to the Viewmanager
|
|
|
|
// doesn't put them in the display list. Also, makde
|
|
|
|
// sure the child views don't get asked to print
|
|
|
|
// but my guess is that there won't be any
|
|
|
|
view->SetVisibility(nsViewVisibility_kHide);
|
|
|
|
view->SetChildClip(0,0,0,0);
|
|
|
|
view->SetViewFlags(NS_VIEW_PUBLIC_FLAG_CLIPCHILDREN);
|
2001-03-27 15:56:03 +04:00
|
|
|
} else {
|
|
|
|
nsRect rect;
|
|
|
|
page->GetRect(rect);
|
|
|
|
rect.y = y;
|
|
|
|
rect.height = height;
|
|
|
|
page->SetRect(aPresContext, rect);
|
|
|
|
nsRect viewRect;
|
|
|
|
view->GetBounds(viewRect);
|
|
|
|
viewRect.y = y;
|
|
|
|
viewRect.height = height;
|
|
|
|
view->SetBounds(viewRect);
|
|
|
|
y += rect.height + mMargin.top + mMargin.bottom;
|
|
|
|
}
|
|
|
|
pageNum++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// adjust total number of pages
|
|
|
|
if (nsIPrintOptions::kRangeSelection == mPrintRangeType) {
|
|
|
|
totalPages = mToPageNum - mFromPageNum + 1;
|
|
|
|
} else {
|
|
|
|
totalPages = pageNum - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// XXX - This wouldn't have to be done each time
|
|
|
|
// but it isn't that expensive and this the best place
|
|
|
|
// to have access to a localized file properties file
|
|
|
|
//
|
|
|
|
// Note: because this is done here it makes a little bit harder
|
|
|
|
// to have UI for setting the header/footer font name and size
|
|
|
|
//
|
|
|
|
// Get default font name and size to be used for the headers and footers
|
|
|
|
nsAutoString fontName;
|
|
|
|
rv = nsFormControlHelper::GetLocalizedString(PRINTING_PROPERTIES, "fontname", fontName);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
fontName.AssignWithConversion("serif");
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString fontSizeStr;
|
|
|
|
nscoord pointSize = 10;;
|
|
|
|
rv = nsFormControlHelper::GetLocalizedString(PRINTING_PROPERTIES, "fontsize", fontSizeStr);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
PRInt32 errCode;
|
|
|
|
pointSize = fontSizeStr.ToInteger(&errCode);
|
|
|
|
if (NS_FAILED(errCode)) {
|
|
|
|
pointSize = 10;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aPrintOptions->SetFontNamePointSize(fontName, pointSize);
|
|
|
|
|
|
|
|
// Now go get the Localized Page Formating String
|
|
|
|
PRBool doingPageTotals = PR_TRUE;
|
|
|
|
aPrintOptions->GetPrintOptions(nsIPrintOptions::kOptPrintPageTotal, &doingPageTotals);
|
|
|
|
|
|
|
|
nsAutoString pageFormatStr;
|
|
|
|
rv = nsFormControlHelper::GetLocalizedString(PRINTING_PROPERTIES,
|
|
|
|
doingPageTotals?"pageofpages":"pagenumber",
|
|
|
|
pageFormatStr);
|
|
|
|
if (NS_FAILED(rv)) { // back stop formatting
|
|
|
|
pageFormatStr.AssignWithConversion(doingPageTotals?"%ld of %ld":"%ld");
|
|
|
|
}
|
|
|
|
// Sets the format into a static data memeber which will own the memory and free it
|
|
|
|
nsPageFrame::SetPageNumberFormat(pageFormatStr.ToNewUnicode());
|
|
|
|
|
|
|
|
mPageNum = 1;
|
|
|
|
mPrintedPageNum = 1;
|
|
|
|
mTotalPages = totalPages;
|
|
|
|
mCurrentPageFrame = mFrames.FirstChild();
|
|
|
|
|
|
|
|
//rv = PrintNextPage(aPresContext, aPrintOptions);
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSimplePageSequenceFrame::PrintNextPage(nsIPresContext* aPresContext,
|
|
|
|
nsIPrintOptions* aPrintOptions)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aPresContext);
|
|
|
|
NS_ENSURE_ARG_POINTER(aPrintOptions);
|
|
|
|
|
|
|
|
// Print each specified page
|
|
|
|
// pageNum keeps track of the current page and what pages are printing
|
|
|
|
//
|
|
|
|
// printedPageNum keeps track of the current page number to be printed
|
|
|
|
// Note: When print al the pages or a page range the printed page shows the
|
|
|
|
// actual page number, when printing selection it prints the page number starting
|
|
|
|
// with the first page of the selection. For example if the user has a
|
|
|
|
// selection that starts on page 2 and ends on page 3, the page numbers when
|
|
|
|
// print are 1 and then two (which is different than printing a page range, where
|
|
|
|
// the page numbers would have been 2 and then 3)
|
|
|
|
|
|
|
|
if (mCurrentPageFrame == nsnull) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool printEvenPages, printOddPages;
|
|
|
|
aPrintOptions->GetPrintOptions(nsIPrintOptions::kOptPrintEvenPages, &printEvenPages);
|
|
|
|
aPrintOptions->GetPrintOptions(nsIPrintOptions::kOptPrintOddPages, &printOddPages);
|
|
|
|
|
|
|
|
// Begin printing of the document
|
|
|
|
nsCOMPtr<nsIDeviceContext> dc;
|
|
|
|
aPresContext->GetDeviceContext(getter_AddRefs(dc));
|
|
|
|
NS_ASSERTION(dc, "nsIDeviceContext can't be NULL!");
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
|
|
|
NS_ASSERTION(presShell, "nsIPresShell can't be NULL!");
|
|
|
|
|
|
|
|
nsCOMPtr<nsIViewManager> vm;
|
|
|
|
presShell->GetViewManager(getter_AddRefs(vm));
|
|
|
|
NS_ASSERTION(vm, "nsIViewManager can't be NULL!");
|
|
|
|
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
// See whether we should print this page
|
2001-04-12 17:04:29 +04:00
|
|
|
mPrintThisPage = PR_TRUE;
|
2001-03-27 15:56:03 +04:00
|
|
|
|
|
|
|
// If printing a range of pages check whether the page number is in the
|
|
|
|
// range of pages to print
|
|
|
|
if (mDoingPageRange) {
|
|
|
|
if (mPageNum < mFromPageNum) {
|
2001-04-12 17:04:29 +04:00
|
|
|
mPrintThisPage = PR_FALSE;
|
2001-03-27 15:56:03 +04:00
|
|
|
} else if (mPageNum > mToPageNum) {
|
|
|
|
mPageNum++;
|
|
|
|
mCurrentPageFrame = nsnull;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check for printing of odd and even pages
|
|
|
|
if (mPageNum & 0x1) {
|
|
|
|
if (!printOddPages) {
|
2001-04-12 17:04:29 +04:00
|
|
|
mPrintThisPage = PR_FALSE; // don't print odd numbered page
|
2001-03-27 15:56:03 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!printEvenPages) {
|
2001-04-12 17:04:29 +04:00
|
|
|
mPrintThisPage = PR_FALSE; // don't print even numbered page
|
2001-03-27 15:56:03 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-12 17:04:29 +04:00
|
|
|
if (mPrintThisPage) {
|
|
|
|
if (!mSkipPageBegin) {
|
|
|
|
PRINT_DEBUG_MSG1("\n***************** BeginPage *****************\n");
|
|
|
|
rv = dc->BeginPage();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
2001-03-27 15:56:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// cast the frame to be a page frame
|
|
|
|
nsPageFrame * pf = NS_STATIC_CAST(nsPageFrame*, mCurrentPageFrame);
|
|
|
|
if (pf != nsnull) {
|
|
|
|
pf->SetPrintOptions(aPrintOptions);
|
|
|
|
pf->SetPageNumInfo(mPrintedPageNum, mTotalPages);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Print the page
|
|
|
|
nsIView* view;
|
|
|
|
mCurrentPageFrame->GetView(aPresContext, &view);
|
|
|
|
|
|
|
|
NS_ASSERTION(nsnull != view, "no page view");
|
2001-04-12 17:04:29 +04:00
|
|
|
|
|
|
|
PRINT_DEBUG_MSG4("SeqFr::Paint -> %p PageNo: %d View: %p", pf, mPageNum, view);
|
|
|
|
PRINT_DEBUG_MSG3(" At: %d,%d\n", mMargin.left+mOffsetX, mMargin.top+mOffsetY);
|
|
|
|
|
2001-06-14 00:14:38 +04:00
|
|
|
view->SetContentTransparency(PR_FALSE);
|
2001-04-12 17:04:29 +04:00
|
|
|
vm->Display(view, mMargin.left+mOffsetX, mMargin.top+mOffsetY);
|
2001-03-27 15:56:03 +04:00
|
|
|
|
|
|
|
|
|
|
|
// this view was printed and since display set the origin
|
|
|
|
// 0,0 there is a danger that this view can be printed again
|
|
|
|
// If it is a sibling to another page/view. Setting the visibility
|
|
|
|
// to hide will keep this page from printing again - dwc
|
|
|
|
//
|
|
|
|
// XXX Doesn't seem like we need to do this anymore
|
|
|
|
//view->SetVisibility(nsViewVisibility_kHide);
|
|
|
|
|
2001-04-12 17:04:29 +04:00
|
|
|
if (!mSkipPageEnd) {
|
|
|
|
PRINT_DEBUG_MSG1("***************** End Page (PrintNextPage) *****************\n");
|
|
|
|
rv = dc->EndPage();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mSkipPageEnd) {
|
|
|
|
if (nsIPrintOptions::kRangeSelection != mPrintRangeType ||
|
|
|
|
(nsIPrintOptions::kRangeSelection == mPrintRangeType && mPrintThisPage)) {
|
|
|
|
mPrintedPageNum++;
|
|
|
|
}
|
|
|
|
|
|
|
|
mPageNum++;
|
|
|
|
rv = mCurrentPageFrame->GetNextSibling(&mCurrentPageFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSimplePageSequenceFrame::DoPageEnd(nsIPresContext* aPresContext)
|
|
|
|
{
|
2001-04-25 18:26:28 +04:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
2001-04-12 17:04:29 +04:00
|
|
|
if (mPrintThisPage) {
|
|
|
|
nsCOMPtr<nsIDeviceContext> dc;
|
|
|
|
aPresContext->GetDeviceContext(getter_AddRefs(dc));
|
|
|
|
NS_ASSERTION(dc, "nsIDeviceContext can't be NULL!");
|
|
|
|
|
2001-04-25 18:26:28 +04:00
|
|
|
if(mSkipPageEnd){
|
|
|
|
PRINT_DEBUG_MSG1("***************** End Page (DoPageEnd) *****************\n");
|
|
|
|
nsresult rv = dc->EndPage();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
2001-03-27 15:56:03 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsIPrintOptions::kRangeSelection != mPrintRangeType ||
|
2001-04-12 17:04:29 +04:00
|
|
|
(nsIPrintOptions::kRangeSelection == mPrintRangeType && mPrintThisPage)) {
|
2001-03-27 15:56:03 +04:00
|
|
|
mPrintedPageNum++;
|
|
|
|
}
|
|
|
|
|
|
|
|
mPageNum++;
|
2001-04-25 18:26:28 +04:00
|
|
|
|
|
|
|
if( nsnull != mCurrentPageFrame){
|
|
|
|
rv = mCurrentPageFrame->GetNextSibling(&mCurrentPageFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
2001-04-12 17:04:29 +04:00
|
|
|
}
|
2001-03-27 15:56:03 +04:00
|
|
|
|
2001-04-12 17:04:29 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSimplePageSequenceFrame::SuppressHeadersAndFooters(PRBool aDoSup)
|
|
|
|
{
|
|
|
|
for (nsIFrame* f = mFrames.FirstChild(); f != nsnull; f->GetNextSibling(&f)) {
|
|
|
|
nsPageFrame * pf = NS_STATIC_CAST(nsPageFrame*, f);
|
|
|
|
if (pf != nsnull) {
|
|
|
|
pf->SuppressHeadersAndFooters(aDoSup);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
2001-03-27 15:56:03 +04:00
|
|
|
}
|
|
|
|
|
2001-04-12 17:04:29 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSimplePageSequenceFrame::SetClipRect(nsIPresContext* aPresContext, nsRect* aRect)
|
|
|
|
{
|
|
|
|
for (nsIFrame* f = mFrames.FirstChild(); f != nsnull; f->GetNextSibling(&f)) {
|
|
|
|
nsPageFrame * pf = NS_STATIC_CAST(nsPageFrame*, f);
|
|
|
|
if (pf != nsnull) {
|
|
|
|
pf->SetClipRect(aRect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSimplePageSequenceFrame::SetDebugFD(FILE* aFD)
|
|
|
|
{
|
|
|
|
mDebugFD = aFD;
|
|
|
|
for (nsIFrame* f = mFrames.FirstChild(); f != nsnull; f->GetNextSibling(&f)) {
|
|
|
|
nsPageFrame * pf = NS_STATIC_CAST(nsPageFrame*, f);
|
|
|
|
if (pf != nsnull) {
|
|
|
|
pf->SetDebugFD(aFD);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
#endif
|