Fixed printing so it could not have more than one job at a time. bug=84537 r=rods sr=attinasi a=blizzard
git-svn-id: svn://10.0.0.236/trunk@97215 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
3a9a2b59a4
commit
d069af6f44
@ -128,18 +128,24 @@ static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
|||||||
#include "nsIDOMFocusListener.h"
|
#include "nsIDOMFocusListener.h"
|
||||||
#include "nsISelectionController.h"
|
#include "nsISelectionController.h"
|
||||||
|
|
||||||
|
#include "nsISound.h"
|
||||||
|
|
||||||
#include "nsITransformMediator.h"
|
#include "nsITransformMediator.h"
|
||||||
|
|
||||||
#ifdef IBMBIDI
|
#ifdef IBMBIDI
|
||||||
#include "nsIUBidiUtils.h"
|
#include "nsIUBidiUtils.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static NS_DEFINE_IID(kSoundCID,NS_SOUND_CID);
|
||||||
|
|
||||||
static NS_DEFINE_CID(kEventQueueService, NS_EVENTQUEUESERVICE_CID);
|
static NS_DEFINE_CID(kEventQueueService, NS_EVENTQUEUESERVICE_CID);
|
||||||
static NS_DEFINE_CID(kPresShellCID, NS_PRESSHELL_CID);
|
static NS_DEFINE_CID(kPresShellCID, NS_PRESSHELL_CID);
|
||||||
static NS_DEFINE_CID(kGalleyContextCID, NS_GALLEYCONTEXT_CID);
|
static NS_DEFINE_CID(kGalleyContextCID, NS_GALLEYCONTEXT_CID);
|
||||||
static NS_DEFINE_CID(kPrintContextCID, NS_PRINTCONTEXT_CID);
|
static NS_DEFINE_CID(kPrintContextCID, NS_PRINTCONTEXT_CID);
|
||||||
static NS_DEFINE_CID(kStyleSetCID, NS_STYLESET_CID);
|
static NS_DEFINE_CID(kStyleSetCID, NS_STYLESET_CID);
|
||||||
|
|
||||||
|
PRBool gCurrentlyPrinting = PR_FALSE;
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
|
|
||||||
#undef NOISY_VIEWER
|
#undef NOISY_VIEWER
|
||||||
@ -167,6 +173,7 @@ const char * gFrameHowToEnableStr[] = {"kFrameEnableNone", "kFrameEnableAll", "k
|
|||||||
const char * gPrintRangeStr[] = {"kRangeAllPages", "kRangeSpecifiedPageRange", "kRangeSelection", "kRangeFocusFrame"};
|
const char * gPrintRangeStr[] = {"kRangeAllPages", "kRangeSpecifiedPageRange", "kRangeSelection", "kRangeFocusFrame"};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define PRINT_DEBUG_MSG1(_msg1) fprintf(mPrt->mDebugFD, (_msg1));
|
#define PRINT_DEBUG_MSG1(_msg1) fprintf(mPrt->mDebugFD, (_msg1));
|
||||||
#define PRINT_DEBUG_MSG2(_msg1, _msg2) fprintf(mPrt->mDebugFD, (_msg1), (_msg2));
|
#define PRINT_DEBUG_MSG2(_msg1, _msg2) fprintf(mPrt->mDebugFD, (_msg1), (_msg2));
|
||||||
#define PRINT_DEBUG_MSG3(_msg1, _msg2, _msg3) fprintf(mPrt->mDebugFD, (_msg1), (_msg2), (_msg3));
|
#define PRINT_DEBUG_MSG3(_msg1, _msg2, _msg3) fprintf(mPrt->mDebugFD, (_msg1), (_msg2), (_msg3));
|
||||||
@ -578,6 +585,7 @@ public:
|
|||||||
if (mTimer) {
|
if (mTimer) {
|
||||||
mTimer->Cancel();
|
mTimer->Cancel();
|
||||||
}
|
}
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -616,6 +624,7 @@ public:
|
|||||||
nsresult result = StartTimer();
|
nsresult result = StartTimer();
|
||||||
if (NS_FAILED(result)) {
|
if (NS_FAILED(result)) {
|
||||||
donePrinting = PR_TRUE; // had a failure.. we are finished..
|
donePrinting = PR_TRUE; // had a failure.. we are finished..
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2088,6 +2097,7 @@ DocumentViewerImpl::DonePrintingPages(PrintObject* aPO)
|
|||||||
DoProgressForAsIsFrames();
|
DoProgressForAsIsFrames();
|
||||||
DoProgressForSeparateFrames();
|
DoProgressForSeparateFrames();
|
||||||
|
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
delete mPrt;
|
delete mPrt;
|
||||||
mPrt = nsnull;
|
mPrt = nsnull;
|
||||||
|
|
||||||
@ -3428,6 +3438,7 @@ DocumentViewerImpl::DoPrint(PrintObject * aPO, PRBool aDoSyncPrinting, PRBool& a
|
|||||||
if (startPageNum == endPageNum) {
|
if (startPageNum == endPageNum) {
|
||||||
nsIFrame * seqFrame;
|
nsIFrame * seqFrame;
|
||||||
if (NS_FAILED(pageSequence->QueryInterface(NS_GET_IID(nsIFrame), (void **)&seqFrame))) {
|
if (NS_FAILED(pageSequence->QueryInterface(NS_GET_IID(nsIFrame), (void **)&seqFrame))) {
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
nsRect rect(0,0,0,0);
|
nsRect rect(0,0,0,0);
|
||||||
@ -3444,6 +3455,7 @@ DocumentViewerImpl::DoPrint(PrintObject * aPO, PRBool aDoSyncPrinting, PRBool& a
|
|||||||
|
|
||||||
nsIFrame * seqFrame;
|
nsIFrame * seqFrame;
|
||||||
if (NS_FAILED(pageSequence->QueryInterface(NS_GET_IID(nsIFrame), (void **)&seqFrame))) {
|
if (NS_FAILED(pageSequence->QueryInterface(NS_GET_IID(nsIFrame), (void **)&seqFrame))) {
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3480,6 +3492,7 @@ DocumentViewerImpl::DoPrint(PrintObject * aPO, PRBool aDoSyncPrinting, PRBool& a
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// not sure what to do here!
|
// not sure what to do here!
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4231,8 +4244,29 @@ DocumentViewerImpl::IsThereARangeSelection(nsIDOMWindowInternal * aDOMWin)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
DocumentViewerImpl::Print(PRBool aSilent,FILE *aFile, nsIPrintListener *aPrintListener)
|
DocumentViewerImpl::Print(PRBool aSilent,FILE *aFile, nsIPrintListener *aPrintListener)
|
||||||
{
|
{
|
||||||
|
nsresult rv;
|
||||||
|
|
||||||
|
// if we are printing another URL, then exit
|
||||||
|
// the reason we check here is because this method can be called while
|
||||||
|
// another is still in here (the printing dialog is a good example).
|
||||||
|
if(gCurrentlyPrinting) {
|
||||||
|
// Beep at the user, let them know we are not ready to print.
|
||||||
|
nsCOMPtr<nsISound> soundInterface;
|
||||||
|
rv = nsComponentManager::CreateInstance(kSoundCID,
|
||||||
|
nsnull, NS_GET_IID(nsISound),
|
||||||
|
getter_AddRefs(soundInterface));
|
||||||
|
if (NS_SUCCEEDED(rv) && (soundInterface != nsnull)){
|
||||||
|
soundInterface->Beep();
|
||||||
|
}
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
} else {
|
||||||
|
gCurrentlyPrinting = PR_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
mPrt = new PrintData();
|
mPrt = new PrintData();
|
||||||
if (mPrt == nsnull) {
|
if (mPrt == nsnull) {
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4252,6 +4286,7 @@ DocumentViewerImpl::Print(PRBool aSilent,FILE *aFile, nsIPrintListener *aPrintLi
|
|||||||
if (mPrt->mPrintDocList == nsnull) {
|
if (mPrt->mPrintDocList == nsnull) {
|
||||||
mPrt->mPrintDocList = new nsVoidArray();
|
mPrt->mPrintDocList = new nsVoidArray();
|
||||||
if (mPrt->mPrintDocList == nsnull) {
|
if (mPrt->mPrintDocList == nsnull) {
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -4286,7 +4321,7 @@ DocumentViewerImpl::Print(PRBool aSilent,FILE *aFile, nsIPrintListener *aPrintLi
|
|||||||
DUMP_DOC_LIST("\nAfter Mapping------------------------------------------");
|
DUMP_DOC_LIST("\nAfter Mapping------------------------------------------");
|
||||||
|
|
||||||
// Setup print options for UI
|
// Setup print options for UI
|
||||||
nsresult rv = NS_ERROR_FAILURE;
|
rv = NS_ERROR_FAILURE;
|
||||||
NS_WITH_SERVICE(nsIPrintOptions, printService, kPrintOptionsCID, &rv);
|
NS_WITH_SERVICE(nsIPrintOptions, printService, kPrintOptionsCID, &rv);
|
||||||
if (NS_SUCCEEDED(rv) && printService) {
|
if (NS_SUCCEEDED(rv) && printService) {
|
||||||
if (mPrt->mIsParentAFrameSet) {
|
if (mPrt->mIsParentAFrameSet) {
|
||||||
@ -4349,10 +4384,12 @@ DocumentViewerImpl::Print(PRBool aSilent,FILE *aFile, nsIPrintListener *aPrintLi
|
|||||||
// load the document and do the initial reflow on the entire document
|
// load the document and do the initial reflow on the entire document
|
||||||
nsCOMPtr<nsIPrintContext> printcon(do_CreateInstance(kPrintContextCID,&rv));
|
nsCOMPtr<nsIPrintContext> printcon(do_CreateInstance(kPrintContextCID,&rv));
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
return rv;
|
return rv;
|
||||||
} else {
|
} else {
|
||||||
rv = printcon->QueryInterface(NS_GET_IID(nsIPresContext), (void**)&mPrt->mPrintPC);
|
rv = printcon->QueryInterface(NS_GET_IID(nsIPresContext), (void**)&mPrt->mPrintPC);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4375,27 +4412,32 @@ DocumentViewerImpl::Print(PRBool aSilent,FILE *aFile, nsIPrintListener *aPrintLi
|
|||||||
|
|
||||||
rv = nsComponentManager::CreateInstance(kPresShellCID, nsnull, NS_GET_IID(nsIPresShell),(void**)&mPrt->mPrintPS);
|
rv = nsComponentManager::CreateInstance(kPresShellCID, nsnull, NS_GET_IID(nsIPresShell),(void**)&mPrt->mPrintPS);
|
||||||
if(NS_FAILED(rv)){
|
if(NS_FAILED(rv)){
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = nsComponentManager::CreateInstance(kViewManagerCID, nsnull, NS_GET_IID(nsIViewManager),(void**)&mPrt->mPrintVM);
|
rv = nsComponentManager::CreateInstance(kViewManagerCID, nsnull, NS_GET_IID(nsIViewManager),(void**)&mPrt->mPrintVM);
|
||||||
if(NS_FAILED(rv)) {
|
if(NS_FAILED(rv)) {
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = mPrt->mPrintVM->Init(mPrt->mPrintDC);
|
rv = mPrt->mPrintVM->Init(mPrt->mPrintDC);
|
||||||
if(NS_FAILED(rv)) {
|
if(NS_FAILED(rv)) {
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = nsComponentManager::CreateInstance(kViewCID, nsnull, NS_GET_IID(nsIView),(void**)&mPrt->mPrintView);
|
rv = nsComponentManager::CreateInstance(kViewCID, nsnull, NS_GET_IID(nsIView),(void**)&mPrt->mPrintView);
|
||||||
if(NS_FAILED(rv)) {
|
if(NS_FAILED(rv)) {
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsRect tbounds = nsRect(0,0,width,height);
|
nsRect tbounds = nsRect(0,0,width,height);
|
||||||
rv = mPrt->mPrintView->Init(mPrt->mPrintVM,tbounds,nsnull);
|
rv = mPrt->mPrintView->Init(mPrt->mPrintVM,tbounds,nsnull);
|
||||||
if(NS_FAILED(rv)) {
|
if(NS_FAILED(rv)) {
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4491,7 +4533,7 @@ DocumentViewerImpl::Print(PRBool aSilent,FILE *aFile, nsIPrintListener *aPrintLi
|
|||||||
mPrt->OnEndPrinting(NS_ERROR_FAILURE);
|
mPrt->OnEndPrinting(NS_ERROR_FAILURE);
|
||||||
delete mPrt;
|
delete mPrt;
|
||||||
mPrt = nsnull;
|
mPrt = nsnull;
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
rv = NS_ERROR_FAILURE;
|
rv = NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -128,18 +128,24 @@ static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
|||||||
#include "nsIDOMFocusListener.h"
|
#include "nsIDOMFocusListener.h"
|
||||||
#include "nsISelectionController.h"
|
#include "nsISelectionController.h"
|
||||||
|
|
||||||
|
#include "nsISound.h"
|
||||||
|
|
||||||
#include "nsITransformMediator.h"
|
#include "nsITransformMediator.h"
|
||||||
|
|
||||||
#ifdef IBMBIDI
|
#ifdef IBMBIDI
|
||||||
#include "nsIUBidiUtils.h"
|
#include "nsIUBidiUtils.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static NS_DEFINE_IID(kSoundCID,NS_SOUND_CID);
|
||||||
|
|
||||||
static NS_DEFINE_CID(kEventQueueService, NS_EVENTQUEUESERVICE_CID);
|
static NS_DEFINE_CID(kEventQueueService, NS_EVENTQUEUESERVICE_CID);
|
||||||
static NS_DEFINE_CID(kPresShellCID, NS_PRESSHELL_CID);
|
static NS_DEFINE_CID(kPresShellCID, NS_PRESSHELL_CID);
|
||||||
static NS_DEFINE_CID(kGalleyContextCID, NS_GALLEYCONTEXT_CID);
|
static NS_DEFINE_CID(kGalleyContextCID, NS_GALLEYCONTEXT_CID);
|
||||||
static NS_DEFINE_CID(kPrintContextCID, NS_PRINTCONTEXT_CID);
|
static NS_DEFINE_CID(kPrintContextCID, NS_PRINTCONTEXT_CID);
|
||||||
static NS_DEFINE_CID(kStyleSetCID, NS_STYLESET_CID);
|
static NS_DEFINE_CID(kStyleSetCID, NS_STYLESET_CID);
|
||||||
|
|
||||||
|
PRBool gCurrentlyPrinting = PR_FALSE;
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
|
|
||||||
#undef NOISY_VIEWER
|
#undef NOISY_VIEWER
|
||||||
@ -167,6 +173,7 @@ const char * gFrameHowToEnableStr[] = {"kFrameEnableNone", "kFrameEnableAll", "k
|
|||||||
const char * gPrintRangeStr[] = {"kRangeAllPages", "kRangeSpecifiedPageRange", "kRangeSelection", "kRangeFocusFrame"};
|
const char * gPrintRangeStr[] = {"kRangeAllPages", "kRangeSpecifiedPageRange", "kRangeSelection", "kRangeFocusFrame"};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define PRINT_DEBUG_MSG1(_msg1) fprintf(mPrt->mDebugFD, (_msg1));
|
#define PRINT_DEBUG_MSG1(_msg1) fprintf(mPrt->mDebugFD, (_msg1));
|
||||||
#define PRINT_DEBUG_MSG2(_msg1, _msg2) fprintf(mPrt->mDebugFD, (_msg1), (_msg2));
|
#define PRINT_DEBUG_MSG2(_msg1, _msg2) fprintf(mPrt->mDebugFD, (_msg1), (_msg2));
|
||||||
#define PRINT_DEBUG_MSG3(_msg1, _msg2, _msg3) fprintf(mPrt->mDebugFD, (_msg1), (_msg2), (_msg3));
|
#define PRINT_DEBUG_MSG3(_msg1, _msg2, _msg3) fprintf(mPrt->mDebugFD, (_msg1), (_msg2), (_msg3));
|
||||||
@ -578,6 +585,7 @@ public:
|
|||||||
if (mTimer) {
|
if (mTimer) {
|
||||||
mTimer->Cancel();
|
mTimer->Cancel();
|
||||||
}
|
}
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -616,6 +624,7 @@ public:
|
|||||||
nsresult result = StartTimer();
|
nsresult result = StartTimer();
|
||||||
if (NS_FAILED(result)) {
|
if (NS_FAILED(result)) {
|
||||||
donePrinting = PR_TRUE; // had a failure.. we are finished..
|
donePrinting = PR_TRUE; // had a failure.. we are finished..
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2088,6 +2097,7 @@ DocumentViewerImpl::DonePrintingPages(PrintObject* aPO)
|
|||||||
DoProgressForAsIsFrames();
|
DoProgressForAsIsFrames();
|
||||||
DoProgressForSeparateFrames();
|
DoProgressForSeparateFrames();
|
||||||
|
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
delete mPrt;
|
delete mPrt;
|
||||||
mPrt = nsnull;
|
mPrt = nsnull;
|
||||||
|
|
||||||
@ -3428,6 +3438,7 @@ DocumentViewerImpl::DoPrint(PrintObject * aPO, PRBool aDoSyncPrinting, PRBool& a
|
|||||||
if (startPageNum == endPageNum) {
|
if (startPageNum == endPageNum) {
|
||||||
nsIFrame * seqFrame;
|
nsIFrame * seqFrame;
|
||||||
if (NS_FAILED(pageSequence->QueryInterface(NS_GET_IID(nsIFrame), (void **)&seqFrame))) {
|
if (NS_FAILED(pageSequence->QueryInterface(NS_GET_IID(nsIFrame), (void **)&seqFrame))) {
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
nsRect rect(0,0,0,0);
|
nsRect rect(0,0,0,0);
|
||||||
@ -3444,6 +3455,7 @@ DocumentViewerImpl::DoPrint(PrintObject * aPO, PRBool aDoSyncPrinting, PRBool& a
|
|||||||
|
|
||||||
nsIFrame * seqFrame;
|
nsIFrame * seqFrame;
|
||||||
if (NS_FAILED(pageSequence->QueryInterface(NS_GET_IID(nsIFrame), (void **)&seqFrame))) {
|
if (NS_FAILED(pageSequence->QueryInterface(NS_GET_IID(nsIFrame), (void **)&seqFrame))) {
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3480,6 +3492,7 @@ DocumentViewerImpl::DoPrint(PrintObject * aPO, PRBool aDoSyncPrinting, PRBool& a
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// not sure what to do here!
|
// not sure what to do here!
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4231,8 +4244,29 @@ DocumentViewerImpl::IsThereARangeSelection(nsIDOMWindowInternal * aDOMWin)
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
DocumentViewerImpl::Print(PRBool aSilent,FILE *aFile, nsIPrintListener *aPrintListener)
|
DocumentViewerImpl::Print(PRBool aSilent,FILE *aFile, nsIPrintListener *aPrintListener)
|
||||||
{
|
{
|
||||||
|
nsresult rv;
|
||||||
|
|
||||||
|
// if we are printing another URL, then exit
|
||||||
|
// the reason we check here is because this method can be called while
|
||||||
|
// another is still in here (the printing dialog is a good example).
|
||||||
|
if(gCurrentlyPrinting) {
|
||||||
|
// Beep at the user, let them know we are not ready to print.
|
||||||
|
nsCOMPtr<nsISound> soundInterface;
|
||||||
|
rv = nsComponentManager::CreateInstance(kSoundCID,
|
||||||
|
nsnull, NS_GET_IID(nsISound),
|
||||||
|
getter_AddRefs(soundInterface));
|
||||||
|
if (NS_SUCCEEDED(rv) && (soundInterface != nsnull)){
|
||||||
|
soundInterface->Beep();
|
||||||
|
}
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
} else {
|
||||||
|
gCurrentlyPrinting = PR_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
mPrt = new PrintData();
|
mPrt = new PrintData();
|
||||||
if (mPrt == nsnull) {
|
if (mPrt == nsnull) {
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4252,6 +4286,7 @@ DocumentViewerImpl::Print(PRBool aSilent,FILE *aFile, nsIPrintListener *aPrintLi
|
|||||||
if (mPrt->mPrintDocList == nsnull) {
|
if (mPrt->mPrintDocList == nsnull) {
|
||||||
mPrt->mPrintDocList = new nsVoidArray();
|
mPrt->mPrintDocList = new nsVoidArray();
|
||||||
if (mPrt->mPrintDocList == nsnull) {
|
if (mPrt->mPrintDocList == nsnull) {
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -4286,7 +4321,7 @@ DocumentViewerImpl::Print(PRBool aSilent,FILE *aFile, nsIPrintListener *aPrintLi
|
|||||||
DUMP_DOC_LIST("\nAfter Mapping------------------------------------------");
|
DUMP_DOC_LIST("\nAfter Mapping------------------------------------------");
|
||||||
|
|
||||||
// Setup print options for UI
|
// Setup print options for UI
|
||||||
nsresult rv = NS_ERROR_FAILURE;
|
rv = NS_ERROR_FAILURE;
|
||||||
NS_WITH_SERVICE(nsIPrintOptions, printService, kPrintOptionsCID, &rv);
|
NS_WITH_SERVICE(nsIPrintOptions, printService, kPrintOptionsCID, &rv);
|
||||||
if (NS_SUCCEEDED(rv) && printService) {
|
if (NS_SUCCEEDED(rv) && printService) {
|
||||||
if (mPrt->mIsParentAFrameSet) {
|
if (mPrt->mIsParentAFrameSet) {
|
||||||
@ -4349,10 +4384,12 @@ DocumentViewerImpl::Print(PRBool aSilent,FILE *aFile, nsIPrintListener *aPrintLi
|
|||||||
// load the document and do the initial reflow on the entire document
|
// load the document and do the initial reflow on the entire document
|
||||||
nsCOMPtr<nsIPrintContext> printcon(do_CreateInstance(kPrintContextCID,&rv));
|
nsCOMPtr<nsIPrintContext> printcon(do_CreateInstance(kPrintContextCID,&rv));
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
return rv;
|
return rv;
|
||||||
} else {
|
} else {
|
||||||
rv = printcon->QueryInterface(NS_GET_IID(nsIPresContext), (void**)&mPrt->mPrintPC);
|
rv = printcon->QueryInterface(NS_GET_IID(nsIPresContext), (void**)&mPrt->mPrintPC);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4375,27 +4412,32 @@ DocumentViewerImpl::Print(PRBool aSilent,FILE *aFile, nsIPrintListener *aPrintLi
|
|||||||
|
|
||||||
rv = nsComponentManager::CreateInstance(kPresShellCID, nsnull, NS_GET_IID(nsIPresShell),(void**)&mPrt->mPrintPS);
|
rv = nsComponentManager::CreateInstance(kPresShellCID, nsnull, NS_GET_IID(nsIPresShell),(void**)&mPrt->mPrintPS);
|
||||||
if(NS_FAILED(rv)){
|
if(NS_FAILED(rv)){
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = nsComponentManager::CreateInstance(kViewManagerCID, nsnull, NS_GET_IID(nsIViewManager),(void**)&mPrt->mPrintVM);
|
rv = nsComponentManager::CreateInstance(kViewManagerCID, nsnull, NS_GET_IID(nsIViewManager),(void**)&mPrt->mPrintVM);
|
||||||
if(NS_FAILED(rv)) {
|
if(NS_FAILED(rv)) {
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = mPrt->mPrintVM->Init(mPrt->mPrintDC);
|
rv = mPrt->mPrintVM->Init(mPrt->mPrintDC);
|
||||||
if(NS_FAILED(rv)) {
|
if(NS_FAILED(rv)) {
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = nsComponentManager::CreateInstance(kViewCID, nsnull, NS_GET_IID(nsIView),(void**)&mPrt->mPrintView);
|
rv = nsComponentManager::CreateInstance(kViewCID, nsnull, NS_GET_IID(nsIView),(void**)&mPrt->mPrintView);
|
||||||
if(NS_FAILED(rv)) {
|
if(NS_FAILED(rv)) {
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsRect tbounds = nsRect(0,0,width,height);
|
nsRect tbounds = nsRect(0,0,width,height);
|
||||||
rv = mPrt->mPrintView->Init(mPrt->mPrintVM,tbounds,nsnull);
|
rv = mPrt->mPrintView->Init(mPrt->mPrintVM,tbounds,nsnull);
|
||||||
if(NS_FAILED(rv)) {
|
if(NS_FAILED(rv)) {
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4491,7 +4533,7 @@ DocumentViewerImpl::Print(PRBool aSilent,FILE *aFile, nsIPrintListener *aPrintLi
|
|||||||
mPrt->OnEndPrinting(NS_ERROR_FAILURE);
|
mPrt->OnEndPrinting(NS_ERROR_FAILURE);
|
||||||
delete mPrt;
|
delete mPrt;
|
||||||
mPrt = nsnull;
|
mPrt = nsnull;
|
||||||
|
gCurrentlyPrinting = PR_FALSE;
|
||||||
rv = NS_ERROR_FAILURE;
|
rv = NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user