diff --git a/mozilla/content/base/src/Makefile.in b/mozilla/content/base/src/Makefile.in index c407c58886b..90d032a6554 100644 --- a/mozilla/content/base/src/Makefile.in +++ b/mozilla/content/base/src/Makefile.in @@ -70,8 +70,6 @@ CPPSRCS = \ nsDocumentEncoder.cpp \ nsDocumentFragment.cpp \ nsDocumentViewer.cpp \ - nsPrintProgress.cpp \ - nsPrintProgressParams.cpp \ nsDOMAttribute.cpp \ nsDOMAttributeMap.cpp \ nsDOMDocumentType.cpp \ diff --git a/mozilla/content/base/src/makefile.win b/mozilla/content/base/src/makefile.win index 34c578e05bc..5b44dd33307 100644 --- a/mozilla/content/base/src/makefile.win +++ b/mozilla/content/base/src/makefile.win @@ -63,8 +63,6 @@ REQUIRES = xpcom \ CPP_OBJS= \ .\$(OBJDIR)\nsPrintPreviewListener.obj \ - .\$(OBJDIR)\nsPrintProgress.obj \ - .\$(OBJDIR)\nsPrintProgressParams.obj \ .\$(OBJDIR)\nsStyleContext.obj \ .\$(OBJDIR)\nsStyleSet.obj \ .\$(OBJDIR)\nsCommentNode.obj \ diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index 532483db0a8..bced580c86c 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -161,6 +161,10 @@ static NS_DEFINE_IID(kPrinterEnumeratorCID, NS_PRINTER_ENUMERATOR_CID); #include "nsIWindowWatcher.h" #include "nsIStringBundle.h" +// Printing Prompts +#include "nsIPrintingPromptService.h" +const char* kPrintingPromptService = "@mozilla.org/embedcomp/printingprompt-service;1"; + #define NS_ERROR_GFX_PRINTER_BUNDLE_URL "chrome://global/locale/printing.properties" // FrameSet @@ -215,12 +219,12 @@ static const char * gPrintRangeStr[] = {"kRangeAllPages", "kRangeSpecified static PRUint32 gDumpFileNameCnt = 0; static PRUint32 gDumpLOFileNameCnt = 0; -#define PRINT_DEBUG_MSG1(_msg1) fprintf(mPrt->mDebugFD, (_msg1)); -#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_MSG4(_msg1, _msg2, _msg3, _msg4) fprintf(mPrt->mDebugFD, (_msg1), (_msg2), (_msg3), (_msg4)); -#define PRINT_DEBUG_MSG5(_msg1, _msg2, _msg3, _msg4, _msg5) fprintf(mPrt->mDebugFD, (_msg1), (_msg2), (_msg3), (_msg4), (_msg5)); -#define PRINT_DEBUG_FLUSH fflush(mPrt->mDebugFD); +#define PRINT_DEBUG_MSG1(_msg1) if (mPrt && mPrt->mDebugFD) fprintf(mPrt->mDebugFD, (_msg1)); +#define PRINT_DEBUG_MSG2(_msg1, _msg2) if (mPrt && mPrt->mDebugFD) fprintf(mPrt->mDebugFD, (_msg1), (_msg2)); +#define PRINT_DEBUG_MSG3(_msg1, _msg2, _msg3) if (mPrt && mPrt->mDebugFD) fprintf(mPrt->mDebugFD, (_msg1), (_msg2), (_msg3)); +#define PRINT_DEBUG_MSG4(_msg1, _msg2, _msg3, _msg4) if (mPrt && mPrt->mDebugFD) fprintf(mPrt->mDebugFD, (_msg1), (_msg2), (_msg3), (_msg4)); +#define PRINT_DEBUG_MSG5(_msg1, _msg2, _msg3, _msg4, _msg5) if (mPrt && mPrt->mDebugFD) fprintf(mPrt->mDebugFD, (_msg1), (_msg2), (_msg3), (_msg4), (_msg5)); +#define PRINT_DEBUG_FLUSH if (mPrt && mPrt->mDebugFD) fflush(mPrt->mDebugFD); #else //-------------- #define PRT_YESNO(_p) #define PRINT_DEBUG_MSG1(_msg) @@ -398,7 +402,9 @@ private: class PrintData { public: - PrintData(); + typedef enum ePrintDataType {eIsPrinting, eIsPrintPreview }; + + PrintData(ePrintDataType aType); ~PrintData(); // non-virtual // Listener Helper Methods @@ -410,6 +416,7 @@ public: PRBool aDoStartStop = PR_FALSE, PRInt32 aFlag = 0); + ePrintDataType mType; // the type of data this is (Printing or Print Preview) nsCOMPtr mPrintDC; nsIView *mPrintView; FILE *mDebugFilePtr; // a file where information can go to when printing @@ -466,6 +473,7 @@ public: #endif private: + PrintData() {} PrintData& operator=(const PrintData& aOther); // not implemented }; @@ -711,7 +719,6 @@ protected: nsIPageSequenceFrame* mPageSeqFrame; - PRBool mIsPrinting; PrintData* mPrt; nsPagePrintTimer* mPagePrintTimer; @@ -878,8 +885,8 @@ static nsresult NS_NewUpdateTimer(nsPagePrintTimer **aResult) //--------------------------------------------------- //-- PrintData Class Impl //--------------------------------------------------- -PrintData::PrintData() : - mPrintView(nsnull), mDebugFilePtr(nsnull), mPrintObject(nsnull), mSelectedPO(nsnull), +PrintData::PrintData(ePrintDataType aType) : + mType(aType), mPrintView(nsnull), mDebugFilePtr(nsnull), mPrintObject(nsnull), mSelectedPO(nsnull), mShowProgressDialog(PR_TRUE), mPrintDocList(nsnull), mIsIFrameSelected(PR_FALSE), mIsParentAFrameSet(PR_FALSE), mPrintingAsIsSubDoc(PR_FALSE), mOnStartSent(PR_FALSE), mIsAborted(PR_FALSE), mPreparingForPrint(PR_FALSE), mDocWasToBeDestroyed(PR_FALSE), @@ -940,13 +947,15 @@ PrintData::~PrintData() mPrintSettings->GetIsCancelled(&isCancelled); nsresult rv = NS_OK; - if (!isCancelled && !mIsAborted) { - rv = mPrintDC->EndDocument(); - } else { - rv = mPrintDC->AbortDocument(); - } - if (NS_FAILED(rv)) { - DocumentViewerImpl::ShowPrintErrorDialog(rv); + if (mType == eIsPrinting) { + if (!isCancelled && !mIsAborted) { + rv = mPrintDC->EndDocument(); + } else { + rv = mPrintDC->AbortDocument(); + } + if (NS_FAILED(rv)) { + DocumentViewerImpl::ShowPrintErrorDialog(rv); + } } } @@ -1103,7 +1112,6 @@ void DocumentViewerImpl::PrepareToStartLoad() mStopped = PR_FALSE; mLoaded = PR_FALSE; mPrt = nsnull; - mIsPrinting = PR_FALSE; #ifdef NS_PRINT_PREVIEW mIsDoingPrintPreview = PR_FALSE; @@ -4312,7 +4320,7 @@ DocumentViewerImpl::FindXMostFrameInList(nsIPresContext* aPresContext, xMost = 0; } -#ifdef DEBUG_PRINTING // keep this here but leave it turned off +#ifdef DEBUG_PRINTING_X // keep this here but leave it turned off nsAutoString tmp; nsIFrameDebug* frameDebug; if (NS_SUCCEEDED(CallQueryInterface(child, &frameDebug))) { @@ -4323,7 +4331,7 @@ DocumentViewerImpl::FindXMostFrameInList(nsIPresContext* aPresContext, if (xMost > aMaxWidth) { aMaxWidth = xMost; -#ifdef DEBUG_PRINTING // keep this here but leave it turned off +#ifdef DEBUG_PRINTING_X // keep this here but leave it turned off printf("%p - %d %s ", child, aMaxWidth, NS_LossyConvertUCS2toASCII(tmp).get()); if (aList == nsLayoutAtoms::overflowList) printf(" nsLayoutAtoms::overflowList\n"); if (aList == nsLayoutAtoms::floaterList) printf(" nsLayoutAtoms::floaterList\n"); @@ -4453,7 +4461,7 @@ DocumentViewerImpl::SetupToPrintContent(nsIWebShell* aParent, } // Only Shrink if we are smaller - if (mPrt->mShrinkRatio < 1.0f) { + if (mPrt->mShrinkRatio < 0.998f) { // Clamp Shrink to Fit to 50% mPrt->mShrinkRatio = PR_MAX(mPrt->mShrinkRatio, 0.5f); @@ -4471,6 +4479,30 @@ DocumentViewerImpl::SetupToPrintContent(nsIWebShell* aParent, return NS_ERROR_FAILURE; } } +#ifdef DEBUG_rods + { + float calcRatio; + if (mPrt->mPrintDocList->Count() > 1 && mPrt->mPrintObject->mFrameType == eFrameSet) { + PrintObject* xMostPO = FindXMostPO(); + NS_ASSERTION(xMostPO, "There must always be an XMost PO!"); + if (xMostPO) { + // The margin is included in the PO's mRect so we need to subtract it + nsMargin margin(0,0,0,0); + mPrt->mPrintSettings->GetMarginInTwips(margin); + nsRect rect = xMostPO->mRect; + rect.x -= margin.left; + // Calc the shrinkage based on the entire content area + calcRatio = float(rect.XMost()) / float(rect.x + xMostPO->mXMost); + } + } else { + // Single document so use the Shrink as calculated for the PO + calcRatio = mPrt->mPrintObject->mShrinkRatio; + } + printf("**************************************************************************\n"); + printf("STF Ratio is: %8.5f Effective Ratio: %8.5f Diff: %8.5f\n", mPrt->mShrinkRatio, calcRatio, mPrt->mShrinkRatio-calcRatio); + printf("**************************************************************************\n"); + } +#endif } DUMP_DOC_LIST("\nAfter Reflow------------------------------------------"); @@ -4510,12 +4542,54 @@ DocumentViewerImpl::SetupToPrintContent(nsIWebShell* aParent, mPrt->mPrintDocDW = aCurrentFocusedDOMWin; + PRUnichar* fileName = nsnull; + // check to see if we are printing to a file + PRBool isPrintToFile = PR_FALSE; + mPrt->mPrintSettings->GetPrintToFile(&isPrintToFile); + if (isPrintToFile) { + // On some platforms The BeginDocument needs to know the name of the file + // and it uses the PrintService to get it, so we need to set it into the PrintService here + mPrt->mPrintSettings->GetToFileName(&fileName); + } + + PRUnichar * docTitleStr; + PRUnichar * docURLStr; + GetDisplayTitleAndURL(mPrt->mPrintObject, mPrt->mPrintSettings, mPrt->mBrandName, &docTitleStr, &docURLStr, eDocTitleDefURLDoc); + + PRInt32 startPage = 1; + PRInt32 endPage = mPrt->mNumPrintablePages; + + PRInt16 printRangeType = nsIPrintSettings::kRangeAllPages; + mPrt->mPrintSettings->GetPrintRange(&printRangeType); + if (printRangeType == nsIPrintSettings::kRangeSpecifiedPageRange) { + mPrt->mPrintSettings->GetStartPageRange(&startPage); + mPrt->mPrintSettings->GetEndPageRange(&endPage); + if (endPage > mPrt->mNumPrintablePages) { + endPage = mPrt->mNumPrintablePages; + } + } + + nsresult rv = NS_OK; + // BeginDocument may pass back a FAILURE code + // i.e. On Windows, if you are printing to a file and hit "Cancel" + // to the "File Name" dialog, this comes back as an error + // Don't start printing when regression test are executed + if (!mPrt->mDebugFilePtr && mIsDoingPrinting) { + rv = mPrt->mPrintDC->BeginDocument(docTitleStr, fileName, startPage, endPage); + } + + PRINT_DEBUG_MSG1("****************** Begin Document ************************\n"); + + if (docTitleStr) nsMemory::Free(docTitleStr); + if (docURLStr) nsMemory::Free(docURLStr); + + NS_ENSURE_SUCCESS(rv, rv); + // This will print the webshell document // when it completes asynchronously in the DonePrintingPages method // it will check to see if there are more webshells to be printed and // then PrintDocContent will be called again. - nsresult rv = NS_OK; if (mIsDoingPrinting) { PrintDocContent(mPrt->mPrintObject, rv); // ignore return value } @@ -4688,23 +4762,11 @@ DocumentViewerImpl::DoPrint(PrintObject * aPO, PRBool aDoSyncPrinting, PRBool& a #endif if (mPrt->mPrintSettings) { + PRUnichar * docTitleStr = nsnull; + PRUnichar * docURLStr = nsnull; + if (!skipSetTitle) { - PRUnichar * docTitleStr; - PRUnichar * docURLStr; - GetDisplayTitleAndURL(aPO, mPrt->mPrintSettings, mPrt->mBrandName, - &docTitleStr, &docURLStr, eDocTitleDefBlank); - - // Set them down into the PrintOptions so - // they can used by the DeviceContext - if (docTitleStr) { - mPrt->mPrintOptions->SetTitle(docTitleStr); - nsMemory::Free(docTitleStr); - } - - if (docURLStr) { - mPrt->mPrintOptions->SetDocURL(docURLStr); - nsMemory::Free(docURLStr); - } + GetDisplayTitleAndURL(aPO, mPrt->mPrintSettings, mPrt->mBrandName, &docTitleStr, &docURLStr, eDocTitleDefBlank); } if (nsIPrintSettings::kRangeSelection == printRangeType) { @@ -4794,7 +4856,7 @@ DocumentViewerImpl::DoPrint(PrintObject * aPO, PRBool aDoSyncPrinting, PRBool& a rootFrame->SetRect(poPresContext, r); mPageSeqFrame = pageSequence; - mPageSeqFrame->StartPrint(poPresContext, mPrt->mPrintSettings); + mPageSeqFrame->StartPrint(poPresContext, mPrt->mPrintSettings, docTitleStr, docURLStr); if (!aDoSyncPrinting) { // Get the delay time in between the printing of each page @@ -5493,25 +5555,26 @@ DocumentViewerImpl::IsThereAnIFrameSelected(nsIWebShell* aWebShell, { aIsParentFrameSet = IsParentAFrameSet(aWebShell); PRBool iFrameIsSelected = PR_FALSE; -#if 1 - PrintObject* po = FindPrintObjectByDOMWin(mPrt->mPrintObject, aDOMWin); - iFrameIsSelected = po && po->mFrameType == eIFrame; -#else - // First, check to see if we are a frameset - if (!aIsParentFrameSet) { - // Check to see if there is a currenlt focused frame - // if so, it means the selected frame is either the main webshell - // or an IFRAME - if (aDOMWin != nsnull) { - // Get the main webshell's DOMWin to see if it matches - // the frame that is selected - nsCOMPtr domWin = getter_AddRefs(GetDOMWinForWebShell(aWebShell)); - if (aDOMWin != nsnull && domWin != aDOMWin) { - iFrameIsSelected = PR_TRUE; // we have a selected IFRAME + if (mPrt && mPrt->mPrintObject) { + PrintObject* po = FindPrintObjectByDOMWin(mPrt->mPrintObject, aDOMWin); + iFrameIsSelected = po && po->mFrameType == eIFrame; + } else { + // First, check to see if we are a frameset + if (!aIsParentFrameSet) { + // Check to see if there is a currenlt focused frame + // if so, it means the selected frame is either the main webshell + // or an IFRAME + if (aDOMWin != nsnull) { + // Get the main webshell's DOMWin to see if it matches + // the frame that is selected + nsCOMPtr domWin = getter_AddRefs(GetDOMWinForWebShell(aWebShell)); + if (aDOMWin != nsnull && domWin != aDOMWin) { + iFrameIsSelected = PR_TRUE; // we have a selected IFRAME + } } } } -#endif + return iFrameIsSelected; } @@ -6326,7 +6389,7 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings) mPrtPreview = nsnull; } - mPrt = new PrintData(); + mPrt = new PrintData(PrintData::eIsPrintPreview); if (!mPrt) { mIsCreatingPrintPreview = PR_FALSE; return NS_ERROR_OUT_OF_MEMORY; @@ -6380,7 +6443,6 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings) // Let's print ... mIsCreatingPrintPreview = PR_TRUE; mIsDoingPrintPreview = PR_TRUE; - aPrintSettings->SetIsPrintPreview(mIsDoingPrintPreview); // Very important! Turn Off scripting TurnScriptingOn(PR_FALSE); @@ -6399,7 +6461,6 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings) if (!mPrt->mPrintDocList) { mIsCreatingPrintPreview = PR_FALSE; mIsDoingPrintPreview = PR_FALSE; - aPrintSettings->SetIsPrintPreview(mIsDoingPrintPreview); TurnScriptingOn(PR_TRUE); return NS_ERROR_OUT_OF_MEMORY; } @@ -6468,8 +6529,6 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings) } #endif - PRBool doSilent = PR_TRUE; - nscoord width = NS_INCHES_TO_TWIPS(8.5); nscoord height = NS_INCHES_TO_TWIPS(11.0); @@ -6478,7 +6537,7 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings) if (factory) { nsCOMPtr devspec; nsCOMPtr dx; - nsresult rv = factory->CreateDeviceContextSpec(mWindow, aPrintSettings, *getter_AddRefs(devspec), doSilent); + nsresult rv = factory->CreateDeviceContextSpec(mWindow, aPrintSettings, *getter_AddRefs(devspec), PR_TRUE); if (NS_SUCCEEDED(rv)) { rv = mDeviceContext->GetDeviceContextFor(devspec, *getter_AddRefs(ppDC)); if (NS_SUCCEEDED(rv)) { @@ -6496,9 +6555,7 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings) } } - if (doSilent) { - mPrt->mPrintSettings->SetPrintFrameType(nsIPrintSettings::kFramesAsIs); - } + mPrt->mPrintSettings->SetPrintFrameType(nsIPrintSettings::kFramesAsIs); // override any UI that wants to PrintPreview any selection PRInt16 printRangeType = nsIPrintSettings::kRangeAllPages; @@ -6603,28 +6660,20 @@ DocumentViewerImpl::SetDocAndURLIntoProgress(PrintObject* aPO, docURLStr = ToNewUnicode(newURLStr); } - mPrt->mPrintProgressParams->SetDocTitle((const PRUnichar*) docTitleStr); - mPrt->mPrintProgressParams->SetDocURL((const PRUnichar*) docURLStr); + aParams->SetDocTitle((const PRUnichar*) docTitleStr); + aParams->SetDocURL((const PRUnichar*) docURLStr); if (docTitleStr != nsnull) nsMemory::Free(docTitleStr); if (docURLStr != nsnull) nsMemory::Free(docURLStr); } +//---------------------------------------------------------------------- +// Set up to use the "pluggable" Print Progress Dialog void DocumentViewerImpl::DoPrintProgress(PRBool aIsForPrinting) { - nsPrintProgress* prtProgress = new nsPrintProgress(); - nsresult rv = prtProgress->QueryInterface(NS_GET_IID(nsIPrintProgress), (void**)getter_AddRefs(mPrt->mPrintProgress)); - if (NS_FAILED(rv)) return; - - - rv = prtProgress->QueryInterface(NS_GET_IID(nsIWebProgressListener), (void**)getter_AddRefs(mPrt->mPrintProgressListener)); - if (NS_FAILED(rv)) return; - // add to listener list - mPrt->mPrintProgressListeners.AppendElement((void*)mPrt->mPrintProgressListener); - nsIWebProgressListener* wpl = NS_STATIC_CAST(nsIWebProgressListener*, mPrt->mPrintProgressListener.get()); - NS_ASSERTION(wpl, "nsIWebProgressListener is NULL!"); - NS_ADDREF(wpl); + // Assume we can't do progress and then see if we can + mPrt->mShowProgressDialog = PR_FALSE; nsCOMPtr prefs (do_GetService(NS_PREF_CONTRACTID)); if (prefs) { @@ -6638,21 +6687,29 @@ DocumentViewerImpl::DoPrintProgress(PRBool aIsForPrinting) mPrt->mPrintSettings->GetShowPrintProgress(&mPrt->mShowProgressDialog); } - if (mPrt->mShowProgressDialog) { - nsPrintProgressParams* prtProgressParams = new nsPrintProgressParams(); - nsCOMPtr params; - rv = prtProgressParams->QueryInterface(NS_GET_IID(nsIPrintProgressParams), (void**)getter_AddRefs(mPrt->mPrintProgressParams)); - if (NS_SUCCEEDED(rv) && mPrt->mPrintProgressParams) { - SetDocAndURLIntoProgress(mPrt->mPrintObject, mPrt->mPrintProgressParams); + // Now open the service to get the progress dialog + nsCOMPtr printPromptService(do_GetService(kPrintingPromptService)); + if (printPromptService) { + nsCOMPtr scriptGlobalObject; + mDocument->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject)); + if (!scriptGlobalObject) return; + nsCOMPtr domWin = do_QueryInterface(scriptGlobalObject); + if (!domWin) return; - nsCOMPtr wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); - if (wwatch) { - nsCOMPtr active; - wwatch->GetActiveWindow(getter_AddRefs(active)); + // If we don't get a service, that's ok, then just don't show progress + if (mPrt->mShowProgressDialog) { + PRBool notifyOnOpen; + nsresult rv = printPromptService->ShowProgress(domWin, this, mPrt->mPrintSettings, nsnull, getter_AddRefs(mPrt->mPrintProgressListener), getter_AddRefs(mPrt->mPrintProgressParams), ¬ifyOnOpen); + if (NS_SUCCEEDED(rv)) { + mPrt->mShowProgressDialog = mPrt->mPrintProgressListener != nsnull && mPrt->mPrintProgressParams != nsnull; - PRBool notifyOnOpen; - nsCOMPtr parent(do_QueryInterface(active)); - mPrt->mPrintProgress->OpenProgressDialog(parent, "chrome://global/content/printProgress.xul", mPrt->mPrintProgressParams, nsnull, ¬ifyOnOpen); + if (mPrt->mShowProgressDialog) { + mPrt->mPrintProgressListeners.AppendElement((void*)mPrt->mPrintProgressListener); + nsIWebProgressListener* wpl = NS_STATIC_CAST(nsIWebProgressListener*, mPrt->mPrintProgressListener.get()); + NS_ASSERTION(wpl, "nsIWebProgressListener is NULL!"); + NS_ADDREF(wpl); + SetDocAndURLIntoProgress(mPrt->mPrintObject, mPrt->mPrintProgressParams); + } } } } @@ -6687,6 +6744,7 @@ DocumentViewerImpl::Print(PRBool aSilent, NS_ASSERTION(printSettings, "You can't PrintPreview without a PrintSettings!"); } if (printSettings) printSettings->SetPrintSilent(aSilent); + if (printSettings) printSettings->SetShowPrintProgress(PR_FALSE); #endif @@ -6750,9 +6808,9 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings, ShowPrintErrorDialog(rv); return rv; } - - mPrt = new PrintData(); - if (mPrt == nsnull) { + + mPrt = new PrintData(PrintData::eIsPrinting); + if (!mPrt) { return NS_ERROR_OUT_OF_MEMORY; } @@ -6889,14 +6947,55 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings, mPrt->mDebugFilePtr = mDebugFile; #endif - // we have to turn off printpreview mode for now.. because this is a real request to print. - if (mIsDoingPrintPreview) { - aPrintSettings->SetIsPrintPreview(PR_FALSE); - } - PRBool printSilently; mPrt->mPrintSettings->GetPrintSilent(&printSilently); - rv = factory->CreateDeviceContextSpec(mWindow, mPrt->mPrintSettings, *getter_AddRefs(devspec), printSilently); + + // Ask dialog to be Print Shown via the Plugable Printing Dialog Service + // This service is for the Print Dialog and the Print Progress Dialog + // If printing silently or you can't get the service continue on + if (!printSilently) { + nsCOMPtr printPromptService(do_GetService(kPrintingPromptService)); + if (printPromptService) { + nsCOMPtr scriptGlobalObject; + mDocument->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject)); + if (!scriptGlobalObject) return nsnull; + nsCOMPtr domWin = do_QueryInterface(scriptGlobalObject); + if (!domWin) return nsnull; + + // Platforms not implementing a given dialog for the service may + // return NS_ERROR_NOT_IMPLEMENTED or an error code. + // + // NS_ERROR_NOT_IMPLEMENTED indicates they want default behavior + // Any other error code means we must bail out + // + rv = printPromptService->ShowPrintDialog(domWin, this, aPrintSettings); + if (rv == NS_ERROR_NOT_IMPLEMENTED) { + // This means the Dialog service was there, + // but they choose not to implement this dialog and + // are looking for default behavior from the toolkit + rv = NS_OK; + + } else if (NS_SUCCEEDED(rv)) { + // since we got the dialog and it worked then make sure we + // are telling GFX we want to print silent + printSilently = PR_TRUE; + } + } else { + rv = NS_ERROR_GFX_NO_PRINTROMPTSERVICE; + } + } + + if (NS_FAILED(rv)) { + if (rv != NS_ERROR_ABORT) { + ShowPrintErrorDialog(rv); + } + delete mPrt; + mPrt = nsnull; + return rv; + } + + // Create DeviceSpec for Printing + rv = factory->CreateDeviceContextSpec(mWindow, mPrt->mPrintSettings, *getter_AddRefs(devspec), PR_FALSE); // If the page was intended to be destroyed while we were in the print dialog // then we need to clean up and abort the printing. @@ -7020,76 +7119,43 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings, } } - if (mPrt->mPrintOptions) { - // check to see if we are printing to a file - PRBool isPrintToFile = PR_FALSE; - mPrt->mPrintSettings->GetPrintToFile(&isPrintToFile); - if (isPrintToFile) { - // On some platforms The BeginDocument needs to know the name of the file + // Get the Needed info for Calling PrepareDocument + PRUnichar* fileName = nsnull; + // check to see if we are printing to a file + PRBool isPrintToFile = PR_FALSE; + mPrt->mPrintSettings->GetPrintToFile(&isPrintToFile); + if (isPrintToFile) { + // On some platforms The PrepareDocument needs to know the name of the file // and it uses the PrintService to get it, so we need to set it into the PrintService here - PRUnichar* fileName; - mPrt->mPrintSettings->GetToFileName(&fileName); - if (fileName != nsnull) { - mPrt->mPrintOptions->SetPrintToFile(PR_TRUE); - mPrt->mPrintOptions->SetToFileName(fileName); - nsMemory::Free(fileName); - } - } else { - mPrt->mPrintOptions->SetPrintToFile(PR_FALSE); - mPrt->mPrintOptions->SetToFileName(nsnull); - } + mPrt->mPrintSettings->GetToFileName(&fileName); } PRUnichar * docTitleStr; PRUnichar * docURLStr; - GetDisplayTitleAndURL(mPrt->mPrintObject, mPrt->mPrintSettings, - mPrt->mBrandName, &docTitleStr, &docURLStr, - eDocTitleDefURLDoc); - // BeginDocument may pass back a FAILURE code - // i.e. On Windows, if you are printing to a file and hit "Cancel" - // to the "File Name" dialog, this comes back as an error - // Don't start printing when regression test are executed - rv = mPrt->mDebugFilePtr ? NS_OK: mPrt->mPrintDC->BeginDocument(docTitleStr); - PRINT_DEBUG_MSG1("****************** Begin Document ************************\n"); + GetDisplayTitleAndURL(mPrt->mPrintObject, mPrt->mPrintSettings, mPrt->mBrandName, &docTitleStr, &docURLStr, eDocTitleDefURLDoc); + + rv = mPrt->mPrintDC->PrepareDocument(docTitleStr, fileName); if (docTitleStr) nsMemory::Free(docTitleStr); if (docURLStr) nsMemory::Free(docURLStr); + NS_ENSURE_SUCCESS(rv, rv); - if (NS_SUCCEEDED(rv)) { + DoPrintProgress(PR_TRUE); - DoPrintProgress(PR_TRUE); - - // Print listener setup... - if (mPrt != nsnull) { - mPrt->OnStartPrinting(); - } - - // - // The mIsPrinting flag is set when the ImageGroup observer is - // notified that images must be loaded as a result of the - // InitialReflow... - // - if(!mIsPrinting || mPrt->mDebugFilePtr) { - rv = DocumentReadyForPrinting(); - PRINT_DEBUG_MSG1("PRINT JOB ENDING, OBSERVER WAS NOT CALLED\n"); - } else { - // use the observer mechanism to finish the printing - PRINT_DEBUG_MSG1("PRINTING OBSERVER STARTED\n"); - } + // Print listener setup... + if (mPrt != nsnull) { + mPrt->OnStartPrinting(); } + + rv = DocumentReadyForPrinting(); + PRINT_DEBUG_MSG1("PRINT JOB ENDING, OBSERVER WAS NOT CALLED\n"); } } } } else { mPrt->mPrintSettings->SetIsCancelled(PR_TRUE); - mPrt->mPrintOptions->SetIsCancelled(PR_TRUE); } - - // Set that we are once again in print preview - if (mIsDoingPrintPreview) { - aPrintSettings->SetIsPrintPreview(PR_TRUE); - } } /* cleaup on failure + notify user */ @@ -7175,6 +7241,8 @@ DocumentViewerImpl::ShowPrintErrorDialog(nsresult aPrintError, PRBool aIsPrintin NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTER_XPRINT_BROKEN_XPRT) NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTER_DOC_IS_BUSY_PP) NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTER_DOC_WAS_DESTORYED) + NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_NO_PRINTDIALOG_IN_TOOLKIT) + NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_NO_PRINTROMPTSERVICE) NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTER_NO_XUL) // Temporary code for Bug 136185 default: @@ -8299,12 +8367,10 @@ DocumentViewerImpl::GetCurrentPrintSettings(nsIPrintSettings * *aCurrentPrintSet NS_IMETHODIMP DocumentViewerImpl::Cancel() { - nsresult rv; - nsCOMPtr printService = do_GetService(kPrintOptionsCID, &rv); - if (NS_SUCCEEDED(rv) && printService) { - return printService->SetIsCancelled(PR_TRUE); + if (mPrt && mPrt->mPrintSettings) { + return mPrt->mPrintSettings->SetIsCancelled(PR_TRUE); } - return NS_OK; + return NS_ERROR_FAILURE; } /* void initPrintSettingsFromPrefs (in nsIPrintSettings aPrintSettings, in boolean aUsePrinterNamePrefix, in unsigned long aFlags); */ diff --git a/mozilla/content/base/src/nsPrintPreviewListener.h b/mozilla/content/base/src/nsPrintPreviewListener.h index 9efa2808bd0..be3709badce 100644 --- a/mozilla/content/base/src/nsPrintPreviewListener.h +++ b/mozilla/content/base/src/nsPrintPreviewListener.h @@ -62,7 +62,7 @@ public: // nsIDOMContextMenuListener NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; } - NS_IMETHOD ContextMenu (nsIDOMEvent* aEvent) { printf("preventing ContextMenu\n"); aEvent->PreventDefault(); return NS_OK; } + NS_IMETHOD ContextMenu (nsIDOMEvent* aEvent) { aEvent->PreventDefault(); return NS_OK; } // nsIDOMKeyListener NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent); diff --git a/mozilla/content/macbuild/content.xml b/mozilla/content/macbuild/content.xml index 0b27eb8ba8d..78ae88c819e 100644 --- a/mozilla/content/macbuild/content.xml +++ b/mozilla/content/macbuild/content.xml @@ -1610,20 +1610,6 @@ Text Debug - - Name - nsPrintProgress.cpp - MacOS - Text - Debug - - - Name - nsPrintProgressParams.cpp - MacOS - Text - Debug - Name nsCSSLoader.cpp @@ -2957,16 +2943,6 @@ nsPrintPreviewListener.cpp MacOS - - Name - nsPrintProgress.cpp - MacOS - - - Name - nsPrintProgressParams.cpp - MacOS - Name nsCSSLoader.cpp @@ -5111,20 +5087,6 @@ Text Debug - - Name - nsPrintProgress.cpp - MacOS - Text - Debug - - - Name - nsPrintProgressParams.cpp - MacOS - Text - Debug - Name nsCSSLoader.cpp @@ -6458,16 +6420,6 @@ nsPrintPreviewListener.cpp MacOS - - Name - nsPrintProgress.cpp - MacOS - - - Name - nsPrintProgressParams.cpp - MacOS - Name nsCSSLoader.cpp @@ -7124,18 +7076,6 @@ nsPrintPreviewListener.cpp MacOS - - content.shlb - Name - nsPrintProgress.cpp - MacOS - - - content.shlb - Name - nsPrintProgressParams.cpp - MacOS - content.shlb Name diff --git a/mozilla/dom/src/base/nsGlobalWindow.cpp b/mozilla/dom/src/base/nsGlobalWindow.cpp index f192118707a..adf66e9fc39 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.cpp +++ b/mozilla/dom/src/base/nsGlobalWindow.cpp @@ -2465,7 +2465,9 @@ GlobalWindowImpl::Print() nsCOMPtr webBrowserPrint; if (NS_SUCCEEDED(GetInterface(NS_GET_IID(nsIWebBrowserPrint), getter_AddRefs(webBrowserPrint)))) { - webBrowserPrint->Print(nsnull, nsnull); + nsCOMPtr printSettings; + webBrowserPrint->GetGlobalPrintSettings(getter_AddRefs(printSettings)); + webBrowserPrint->Print(printSettings, nsnull); } return NS_OK; } diff --git a/mozilla/embedding/browser/macbuild/browserIDL.xml b/mozilla/embedding/browser/macbuild/browserIDL.xml index f5ae07c4672..62388d5d3d1 100644 --- a/mozilla/embedding/browser/macbuild/browserIDL.xml +++ b/mozilla/embedding/browser/macbuild/browserIDL.xml @@ -801,20 +801,6 @@ Text - - Name - nsIPrintingPrompt.idl - MacOS - Text - - - - Name - nsIPrintingPromptService.idl - MacOS - Text - - @@ -882,16 +868,6 @@ nsITooltipTextProvider.idl MacOS - - Name - nsIPrintingPrompt.idl - MacOS - - - Name - nsIPrintingPromptService.idl - MacOS - @@ -1642,20 +1618,6 @@ Text - - Name - nsIPrintingPrompt.idl - MacOS - Text - - - - Name - nsIPrintingPromptService.idl - MacOS - Text - - @@ -1723,16 +1685,6 @@ nsITooltipTextProvider.idl MacOS - - Name - nsIPrintingPrompt.idl - MacOS - - - Name - nsIPrintingPromptService.idl - MacOS - @@ -1821,18 +1773,6 @@ nsIWebBrowserSetup.idl MacOS - - embeddingbrowser.xpt - Name - nsIPrintingPrompt.idl - MacOS - - - embeddingbrowser.xpt - Name - nsIPrintingPromptService.idl - MacOS - diff --git a/mozilla/embedding/browser/powerplant/source/CPrintAttachment.cpp b/mozilla/embedding/browser/powerplant/source/CPrintAttachment.cpp index c268994ec01..7dd21d5fd6d 100644 --- a/mozilla/embedding/browser/powerplant/source/CPrintAttachment.cpp +++ b/mozilla/embedding/browser/powerplant/source/CPrintAttachment.cpp @@ -39,163 +39,17 @@ // Local #include "CPrintAttachment.h" #include "CBrowserShell.h" -#include "UMacUnicode.h" -#include "ApplIDs.h" // Gecko -#include "nsIPrintOptions.h" +#include "nsIPrintingPromptService.h" +#include "nsIDOMWindow.h" #include "nsIServiceManagerUtils.h" #include "nsIWebBrowserPrint.h" #include "nsIInterfaceRequestorUtils.h" #include "nsIWebProgressListener.h" -#include "nsIPrefService.h" -#include "nsIPrefBranch.h" #include "nsIWebBrowserChrome.h" #include "nsIEmbeddingSiteWindow.h" -// PowerPlant -#include -#include - -// Std Lib -#include -using namespace std; - -// Constants -enum { - paneID_ProgressBar = 'Prog', - paneID_StatusText = 'Stat' -}; - -//***************************************************************************** -//*** CPrintProgressListener -//***************************************************************************** - -class CPrintProgressListener : public nsIWebProgressListener, - public LListener -{ -public: - CPrintProgressListener(nsIWebBrowserPrint *wbPrint, - const nsAString& jobTitle); - virtual ~CPrintProgressListener(); - - NS_DECL_ISUPPORTS - NS_DECL_NSIWEBPROGRESSLISTENER - - void ListenToMessage(MessageT inMessage, - void* ioParam); - -protected: - nsIWebBrowserPrint *mWBPrint; - nsString mJobTitle; - - LWindow *mDialog; - LProgressBar *mDialogProgressBar; - LStaticText *mDialogStatusText; -}; - -CPrintProgressListener::CPrintProgressListener(nsIWebBrowserPrint* wbPrint, - const nsAString& jobTitle) : - mWBPrint(wbPrint), mJobTitle(jobTitle), - mDialog(nsnull), mDialogProgressBar(nsnull), mDialogStatusText(nsnull) -{ - NS_INIT_ISUPPORTS(); - ThrowIfNil_(mWBPrint); -} - -CPrintProgressListener::~CPrintProgressListener() -{ -} - -NS_IMPL_ISUPPORTS1(CPrintProgressListener, - nsIWebProgressListener); - -NS_IMETHODIMP CPrintProgressListener::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRInt32 aStateFlags, PRUint32 aStatus) -{ - if ((aStateFlags & nsIWebProgressListener::STATE_IS_DOCUMENT) && - (aStateFlags & nsIWebProgressListener::STATE_START)) - { - if (!mDialog) { - try { - mDialog = LWindow::CreateWindow(dlog_OS9PrintProgress, LCommander::GetTopCommander()); - UReanimator::LinkListenerToBroadcasters(this, mDialog, dlog_OS9PrintProgress); - mDialogProgressBar = dynamic_cast(mDialog->FindPaneByID(paneID_ProgressBar)); - mDialogStatusText = dynamic_cast(mDialog->FindPaneByID(paneID_StatusText)); - if (mDialogStatusText && mJobTitle.Length()) { - // The status text in the resource is something like: "Document: ^0" or "Printing: ^0" - // Get that text and replace "^0" with the job title. - char buf[256]; - Size bufLen; - mDialogStatusText->GetText(buf, sizeof(buf) - 1, &bufLen); - buf[bufLen] = '\0'; - - nsCAutoString statusCString(buf); - nsCAutoString jobTitleCString; - CPlatformUCSConversion::GetInstance()->UCSToPlatform(mJobTitle, jobTitleCString); - statusCString.ReplaceSubstring(nsCAutoString("^0"), jobTitleCString); - - mDialogStatusText->SetText(const_cast(statusCString.get()), statusCString.Length()); - } - mDialog->Show(); - } - catch (...) { - NS_ERROR("Failed to make print progress dialog - missing a resource?"); - } - } - } - else if ((aStateFlags & nsIWebProgressListener::STATE_IS_DOCUMENT) && - (aStateFlags & nsIWebProgressListener::STATE_STOP)) - { - delete mDialog; - mDialog = nsnull; - } - - return NS_OK; -} - -NS_IMETHODIMP CPrintProgressListener::OnProgressChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRInt32 aCurSelfProgress, PRInt32 aMaxSelfProgress, PRInt32 aCurTotalProgress, PRInt32 aMaxTotalProgress) -{ - if (mDialogProgressBar) { - if (aMaxSelfProgress != -1 && mDialogProgressBar->IsIndeterminate()) - mDialogProgressBar->SetIndeterminateFlag(false, false); - else if (aMaxSelfProgress == -1 && !mDialogProgressBar->IsIndeterminate()) - mDialogProgressBar->SetIndeterminateFlag(true, true); - - if (!mDialogProgressBar->IsIndeterminate()) { - PRInt32 aMax = max(0, aMaxSelfProgress); - PRInt32 aVal = min(aMax, max(0, aCurSelfProgress)); - mDialogProgressBar->SetMaxValue(aMax); - mDialogProgressBar->SetValue(aVal); - } - } - - return NS_OK; -} - -NS_IMETHODIMP CPrintProgressListener::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP CPrintProgressListener::OnStatusChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsresult aStatus, const PRUnichar *aMessage) -{ - nsCAutoString cString; cString.AssignWithConversion(aMessage); - printf("CPrintProgressListener::OnStatusChange: aStatus = %s\n", cString.get()); - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP CPrintProgressListener::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRInt32 state) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -void CPrintProgressListener::ListenToMessage(MessageT inMessage, - void* ioParam) -{ - if (inMessage == msg_Cancel) - mWBPrint->Cancel(); -} - //***************************************************************************** //*** CPrintAttachment @@ -287,57 +141,32 @@ void CPrintAttachment::DoPrint() nsCOMPtr settings; mBrowserShell->GetPrintSettings(getter_AddRefs(settings)); ThrowIfNil_(settings); - - // The progress listener handles a print progress dialog. Don't do this on OS X because - // the OS puts up a perfectly lovely one automatically. We're not at the mercy of the - // printer driver for this as we are on Classic. - nsCOMPtr listener; - - long version; - PRBool runningOSX = (::Gestalt(gestaltSystemVersion, &version) == noErr && version >= 0x00001000); - - if (!runningOSX) { - // Get the title for the job and make a listener. - nsXPIDLString jobTitle; - nsCOMPtr chrome; - mBrowserShell->GetWebBrowserChrome(getter_AddRefs(chrome)); - ThrowIfNil_(chrome); - nsCOMPtr siteWindow(do_QueryInterface(chrome)); - ThrowIfNil_(siteWindow); - siteWindow->GetTitle(getter_Copies(jobTitle)); - - // Don't AddRef the listener. The nsIWebBrowserPrint holds the only ref to it. - listener = new CPrintProgressListener(wbPrint, jobTitle); - } - - // In any case, we don't want Gecko to display its XUL progress dialog. - // Unfortunately, there is nothing in the printing API to control this - - // it's done through a pref :-( If you are distributing your own default - // prefs, this could be done there instead of programatically. - nsCOMPtr prefsService(do_GetService(NS_PREFSERVICE_CONTRACTID)); - if (prefsService) { - nsCOMPtr printBranch; - prefsService->GetBranch("print.", getter_AddRefs(printBranch)); - if (printBranch) { - printBranch->SetBoolPref("show_print_progress", PR_FALSE); - } - } - - nsresult rv = wbPrint->Print(settings, listener); - ThrowIfError_(rv); + + nsresult rv = wbPrint->Print(settings, nsnull); + if (rv != NS_ERROR_ABORT) + ThrowIfError_(rv); } void CPrintAttachment::DoPageSetup() { - nsCOMPtr printOptionsService = do_GetService("@mozilla.org/gfx/printoptions;1"); - ThrowIfNil_(printOptionsService); - nsCOMPtr printSettings; - mBrowserShell->GetPrintSettings(getter_AddRefs(printSettings)); - ThrowIfNil_(printSettings); + nsCOMPtr wb; + mBrowserShell->GetWebBrowser(getter_AddRefs(wb)); + ThrowIfNil_(wb); + nsCOMPtr domWindow; + wb->GetContentDOMWindow(getter_AddRefs(domWindow)); + ThrowIfNil_(domWindow); + nsCOMPtr settings; + mBrowserShell->GetPrintSettings(getter_AddRefs(settings)); + ThrowIfNil_(settings); - nsresult rv = printOptionsService->ShowPrintSetupDialog(printSettings); - ThrowIfError_(rv); + nsCOMPtr printingPromptService = + do_GetService("@mozilla.org/embedcomp/printingprompt-service;1"); + ThrowIfNil_(printingPromptService); + + nsresult rv = printingPromptService->ShowPageSetup(domWindow, settings); + if (rv != NS_ERROR_ABORT) + ThrowIfError_(rv); } diff --git a/mozilla/embedding/components/build/Makefile.in b/mozilla/embedding/components/build/Makefile.in index 1041f377596..44fbf00de76 100644 --- a/mozilla/embedding/components/build/Makefile.in +++ b/mozilla/embedding/components/build/Makefile.in @@ -84,7 +84,7 @@ LOCAL_INCLUDES += -I$(srcdir)/../printingui/src/os2 endif ifneq (,$(filter gtk gtk2 xlib beos qt, $(MOZ_WIDGET_TOOLKIT))) -LOCAL_INCLUDES += -I$(srcdir)/../printingui/src/gtk +LOCAL_INCLUDES += -I$(srcdir)/../printingui/src/unixshared endif ifeq ($(MOZ_GFX_TOOLKIT),windows) diff --git a/mozilla/embedding/components/printingui/src/Makefile.in b/mozilla/embedding/components/printingui/src/Makefile.in index 9d488830349..7f88ac4b623 100644 --- a/mozilla/embedding/components/printingui/src/Makefile.in +++ b/mozilla/embedding/components/printingui/src/Makefile.in @@ -27,7 +27,7 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk ifneq (,$(filter gtk gtk2 xlib qt beos,$(MOZ_WIDGET_TOOLKIT))) -DIRS += gtk +DIRS += unixshared endif ifeq ($(MOZ_WIDGET_TOOLKIT),os2) diff --git a/mozilla/embedding/components/printingui/src/mac/nsPrintDialogExtension.r b/mozilla/embedding/components/printingui/src/mac/nsPrintDialogExtension.r index 407cd13cfb0..e50ac62de3f 100644 --- a/mozilla/embedding/components/printingui/src/mac/nsPrintDialogExtension.r +++ b/mozilla/embedding/components/printingui/src/mac/nsPrintDialogExtension.r @@ -41,7 +41,7 @@ resource 'DITL' (128) { { /* array DITLarray: 6 elements */ /* [1] */ - {16, 32, 33, 168}, + {16, 32, 33, 178}, CheckBox { enabled, "Print Selection Only" diff --git a/mozilla/embedding/tests/mfcembed/BrowserView.cpp b/mozilla/embedding/tests/mfcembed/BrowserView.cpp index 564c655a816..66d860ef0b9 100644 --- a/mozilla/embedding/tests/mfcembed/BrowserView.cpp +++ b/mozilla/embedding/tests/mfcembed/BrowserView.cpp @@ -984,18 +984,15 @@ LRESULT CBrowserView::OnFindMsg(WPARAM wParam, LPARAM lParam) void CBrowserView::OnFilePrint() { nsresult rv; - nsCOMPtr prefs(do_GetService(NS_PREF_CONTRACTID, &rv)); - if (NS_SUCCEEDED(rv)) - { - prefs->SetBoolPref("print.use_native_print_dialog", PR_TRUE); - prefs->SetBoolPref("print.show_print_progress", PR_FALSE); - } - else - NS_ASSERTION(PR_FALSE, "Could not get preferences service"); - nsCOMPtr print(do_GetInterface(mWebBrowser)); if(print) { + if (!m_PrintSettings) + { + print->GetGlobalPrintSettings(getter_AddRefs(m_PrintSettings)); + } + + m_PrintSettings->SetShowPrintProgress(PR_FALSE); CPrintProgressDialog dlg(mWebBrowser, m_PrintSettings); nsCOMPtr currentURI; diff --git a/mozilla/gfx/idl/nsIPrintOptions.idl b/mozilla/gfx/idl/nsIPrintOptions.idl index 2b201a9d981..2568bdbf187 100644 --- a/mozilla/gfx/idl/nsIPrintOptions.idl +++ b/mozilla/gfx/idl/nsIPrintOptions.idl @@ -107,15 +107,6 @@ interface nsIPrintOptions : nsISupports */ void displayJobProperties (in wstring aPrinter, in nsIPrintSettings aPrintSettings, out boolean aDisplayed); - // Attributes - attribute boolean isCancelled; - - attribute wstring title; - attribute wstring docURL; - - attribute boolean printToFile; - attribute wstring toFileName; - // no script methods [noscript] void SetFontNamePointSize(in nsNativeStringRef aName, in PRInt32 aPointSize); diff --git a/mozilla/gfx/macbuild/gfxComponent.xml b/mozilla/gfx/macbuild/gfxComponent.xml index caa8cbe34ed..4195daca378 100644 --- a/mozilla/gfx/macbuild/gfxComponent.xml +++ b/mozilla/gfx/macbuild/gfxComponent.xml @@ -735,9 +735,9 @@ MWLinker_PPC_dontdeadstripinitcode0 MWLinker_PPC_permitmultdefs1 MWLinker_PPC_linkmodeFast - MWLinker_PPC_initname__initializeResources + MWLinker_PPC_initname__NSInitialize MWLinker_PPC_mainname - MWLinker_PPC_termname__terminateResources + MWLinker_PPC_termname__NSTerminate MWLinker_MachO_exportsNone @@ -1062,23 +1062,16 @@ Name - InterfacesStubs - MacOS - Library - Debug - - - Name - nsMacResources.cpp + nsPrintSettingsMac.cpp MacOS Text Debug Name - nsMacGFX.rsrc + InterfacesStubs MacOS - Resource + Library Debug @@ -1300,21 +1293,16 @@ nsPrintOptionsMac.cpp MacOS + + Name + nsPrintSettingsMac.cpp + MacOS + Name InterfacesStubs MacOS - - Name - nsMacResources.cpp - MacOS - - - Name - nsMacGFX.rsrc - MacOS - Name gfxDebug.shlb @@ -2074,9 +2062,9 @@ MWLinker_PPC_dontdeadstripinitcode0 MWLinker_PPC_permitmultdefs1 MWLinker_PPC_linkmodeFast - MWLinker_PPC_initname__initializeResources + MWLinker_PPC_initname__NSInitialize MWLinker_PPC_mainname - MWLinker_PPC_termname__terminateResources + MWLinker_PPC_termname__NSTerminate MWLinker_MachO_exportsNone @@ -2401,23 +2389,16 @@ Name - InterfacesStubs - MacOS - Library - Debug - - - Name - nsMacResources.cpp + nsPrintSettingsMac.cpp MacOS Text Debug Name - nsMacGFX.rsrc + InterfacesStubs MacOS - Resource + Library Debug @@ -2639,21 +2620,16 @@ nsPrintOptionsMac.cpp MacOS + + Name + nsPrintSettingsMac.cpp + MacOS + Name InterfacesStubs MacOS - - Name - nsMacResources.cpp - MacOS - - - Name - nsMacGFX.rsrc - MacOS - Name nsGraphicsImpl.cpp @@ -3413,9 +3389,9 @@ MWLinker_PPC_dontdeadstripinitcode0 MWLinker_PPC_permitmultdefs1 MWLinker_PPC_linkmodeFast - MWLinker_PPC_initname__initializeResources + MWLinker_PPC_initname__NSInitialize MWLinker_PPC_mainname - MWLinker_PPC_termname__terminateResources + MWLinker_PPC_termname__NSTerminate MWLinker_MachO_exportsNone @@ -3729,1970 +3705,4 @@ InterfacesStubs MacOS Library - Debug - - - Name - nsDeviceContextSpecX.cpp - MacOS - Text - Debug - - - Name - nsMacResources.cpp - MacOS - Text - Debug - - - Name - nsMacGFX.rsrc - MacOS - Resource - Debug - - - Name - nsGraphicsImpl.cpp - MacOS - Text - Debug - - - Name - NSComponentStartup.o - MacOS - Library - Debug - - - Name - nsPrintOptionsX.cpp - MacOS - Text - Debug - - - Name - nsPrintOptionsImpl.cpp - MacOS - Text - Debug - - - Name - nsPrintSettingsImpl.cpp - MacOS - Text - Debug - - - Name - nsRenderingContextImpl.cpp - MacOS - Text - Debug - - - Name - nsBlender.cpp - MacOS - Text - Debug - - - Name - nsScriptableRegion.cpp - MacOS - Text - Debug - - - Name - nsMacUnicodeFontInfo.cpp - MacOS - Text - Debug - - - Name - nsNativeThemeMac.cpp - MacOS - Text - Debug - - - Name - nsCompressedCharMap.cpp - MacOS - Text - Debug - - - Name - nsDeviceContext.cpp - MacOS - Text - Debug - - - Name - UnicharUtilsStatic.o - MacOS - Library - Debug - - - Name - gfx.shlb - MacOS - Library - Debug - - - Name - nsGfxFactoryMac.cpp - MacOS - Text - Debug - - - Name - nsFontList.cpp - MacOS - Text - Debug - - - - - Name - NSComponentStartup.o - MacOS - - - Name - NSRuntime.shlb - MacOS - - - Name - NSStdLib.shlb - MacOS - - - Name - xpcom.shlb - MacOS - - - Name - NSPR20.shlb - MacOS - - - Name - nsImageMac.cpp - MacOS - - - Name - nsRegionMac.cpp - MacOS - - - Name - nsDeviceContextMac.cpp - MacOS - - - Name - nsFontMetricsMac.cpp - MacOS - - - Name - nsRenderingContextMac.cpp - MacOS - - - Name - nsDeviceContextSpecFactoryM.cpp - MacOS - - - Name - nsDrawingSurfaceMac.cpp - MacOS - - - Name - nsATSUIUtils.cpp - MacOS - - - Name - nsGraphicState.cpp - MacOS - - - Name - nsUnicodeRenderingToolkit.cpp - MacOS - - - Name - nsUnicodeMappingUtil.cpp - MacOS - - - Name - nsUnicodeFontMappingMac.cpp - MacOS - - - Name - nsScreenMac.cpp - MacOS - - - Name - nsScreenManagerMac.cpp - MacOS - - - Name - InterfacesStubs - MacOS - - - Name - nsDeviceContextSpecX.cpp - MacOS - - - Name - nsMacResources.cpp - MacOS - - - Name - nsMacGFX.rsrc - MacOS - - - Name - nsGraphicsImpl.cpp - MacOS - - - Name - nsPrintOptionsX.cpp - MacOS - - - Name - nsPrintOptionsImpl.cpp - MacOS - - - Name - nsPrintSettingsImpl.cpp - MacOS - - - Name - nsRenderingContextImpl.cpp - MacOS - - - Name - nsBlender.cpp - MacOS - - - Name - nsScriptableRegion.cpp - MacOS - - - Name - nsMacUnicodeFontInfo.cpp - MacOS - - - Name - nsNativeThemeMac.cpp - MacOS - - - Name - nsCompressedCharMap.cpp - MacOS - - - Name - nsDeviceContext.cpp - MacOS - - - Name - UnicharUtilsStatic.o - MacOS - - - Name - gfx.shlb - MacOS - - - Name - nsGfxFactoryMac.cpp - MacOS - - - Name - nsFontList.cpp - MacOS - - - - - gfxComponentCarbonDbg.shlb - - - - UserSourceTrees - - - AlwaysSearchUserPathsfalse - InterpretDOSAndUnixPathsfalse - RequireFrameworkStyleIncludesfalse - UserSearchPaths - - SearchPath - Path::src:mac: - PathFormatMacOS - PathRootProject - - Recursivetrue - FrameworkPathfalse - HostFlagsAll - - - SearchPath - Path:: - PathFormatMacOS - PathRootProject - - Recursivetrue - FrameworkPathfalse - HostFlagsAll - - - SearchPath - Path:::dist: - PathFormatMacOS - PathRootProject - - Recursivetrue - FrameworkPathfalse - HostFlagsAll - - - SystemSearchPaths - - SearchPath - Path:MSL: - PathFormatMacOS - PathRootCodeWarrior - - Recursivetrue - FrameworkPathfalse - HostFlagsAll - - - SearchPath - Path:MacOS Support:Universal: - PathFormatMacOS - PathRootCodeWarrior - - Recursivetrue - FrameworkPathfalse - HostFlagsAll - - - - - MWRuntimeSettings_WorkingDirectory - MWRuntimeSettings_CommandLine - MWRuntimeSettings_HostApplication - Path - PathFormatGeneric - PathRootAbsolute - - MWRuntimeSettings_EnvVars - - - LinkerMacOS PPC Linker - PreLinker - PostLinker - TargetnamegfxComponentCarbonDbg.shlb - OutputDirectory - Path: - PathFormatMacOS - PathRootProject - - SaveEntriesUsingRelativePathsfalse - - - FileMappings - - FileTypeAPPL - FileExtension - Compiler - EditLanguage - Precompilefalse - Launchabletrue - ResourceFiletrue - IgnoredByMakefalse - - - FileTypeAppl - FileExtension - Compiler - EditLanguage - Precompilefalse - Launchabletrue - ResourceFiletrue - IgnoredByMakefalse - - - FileTypeMMLB - FileExtension - CompilerLib Import PPC - EditLanguage - Precompilefalse - Launchablefalse - ResourceFilefalse - IgnoredByMakefalse - - - FileTypeMPLF - FileExtension - CompilerLib Import PPC - EditLanguage - Precompilefalse - Launchablefalse - ResourceFilefalse - IgnoredByMakefalse - - - FileTypeMWCD - FileExtension - Compiler - EditLanguage - Precompilefalse - Launchabletrue - ResourceFiletrue - IgnoredByMakefalse - - - FileTypeRSRC - FileExtension - Compiler - EditLanguage - Precompilefalse - Launchabletrue - ResourceFiletrue - IgnoredByMakefalse - - - FileTypeTEXT - FileExtension.c - CompilerMW C/C++ PPC - EditLanguageC/C++ - Precompilefalse - Launchablefalse - ResourceFilefalse - IgnoredByMakefalse - - - FileTypeTEXT - FileExtension.c++ - CompilerMW C/C++ PPC - EditLanguageC/C++ - Precompilefalse - Launchablefalse - ResourceFilefalse - IgnoredByMakefalse - - - FileTypeTEXT - FileExtension.cc - CompilerMW C/C++ PPC - EditLanguageC/C++ - Precompilefalse - Launchablefalse - ResourceFilefalse - IgnoredByMakefalse - - - FileTypeTEXT - FileExtension.cp - CompilerMW C/C++ PPC - EditLanguageC/C++ - Precompilefalse - Launchablefalse - ResourceFilefalse - IgnoredByMakefalse - - - FileTypeTEXT - FileExtension.cpp - CompilerMW C/C++ PPC - EditLanguageC/C++ - Precompilefalse - Launchablefalse - ResourceFilefalse - IgnoredByMakefalse - - - FileTypeTEXT - FileExtension.exp - Compiler - EditLanguage - Precompilefalse - Launchablefalse - ResourceFilefalse - IgnoredByMakefalse - - - FileTypeTEXT - FileExtension.h - CompilerMW C/C++ PPC - EditLanguageC/C++ - Precompilefalse - Launchablefalse - ResourceFilefalse - IgnoredByMaketrue - - - FileTypeTEXT - FileExtension.p - CompilerMW Pascal PPC - EditLanguage - Precompilefalse - Launchablefalse - ResourceFilefalse - IgnoredByMakefalse - - - FileTypeTEXT - FileExtension.pas - CompilerMW Pascal PPC - EditLanguage - Precompilefalse - Launchablefalse - ResourceFilefalse - IgnoredByMakefalse - - - FileTypeTEXT - FileExtension.pch - CompilerMW C/C++ PPC - EditLanguageC/C++ - Precompiletrue - Launchablefalse - ResourceFilefalse - IgnoredByMakefalse - - - FileTypeTEXT - FileExtension.pch++ - CompilerMW C/C++ PPC - EditLanguageC/C++ - Precompiletrue - Launchablefalse - ResourceFilefalse - IgnoredByMakefalse - - - FileTypeTEXT - FileExtension.ppu - CompilerMW Pascal PPC - EditLanguage - Precompiletrue - Launchablefalse - ResourceFilefalse - IgnoredByMakefalse - - - FileTypeTEXT - FileExtension.r - CompilerRez - EditLanguageRez - Precompilefalse - Launchablefalse - ResourceFilefalse - IgnoredByMakefalse - - - FileTypeTEXT - FileExtension.s - CompilerPPCAsm - EditLanguage - Precompilefalse - Launchablefalse - ResourceFilefalse - IgnoredByMakefalse - - - FileTypeXCOF - FileExtension - CompilerXCOFF Import PPC - EditLanguage - Precompilefalse - Launchablefalse - ResourceFilefalse - IgnoredByMakefalse - - - FileTypedocu - FileExtension - Compiler - EditLanguage - Precompilefalse - Launchabletrue - ResourceFiletrue - IgnoredByMakefalse - - - FileTypersrc - FileExtension - Compiler - EditLanguage - Precompilefalse - Launchabletrue - ResourceFiletrue - IgnoredByMakefalse - - - FileTypeshlb - FileExtension - CompilerPEF Import PPC - EditLanguage - Precompilefalse - Launchablefalse - ResourceFilefalse - IgnoredByMakefalse - - - FileTypestub - FileExtension - CompilerPEF Import PPC - EditLanguage - Precompilefalse - Launchablefalse - ResourceFilefalse - IgnoredByMakefalse - - - FileExtension.doc - Compiler - EditLanguage - Precompilefalse - Launchabletrue - ResourceFilefalse - IgnoredByMaketrue - - - - - CacheModDatesfalse - ActivateBrowsertrue - DumpBrowserInfofalse - CacheSubprojectstrue - UseThirdPartyDebuggerfalse - DebuggerAppPath - Path - PathFormatGeneric - PathRootAbsolute - - DebuggerCmdLineArgs - DebuggerWorkingDir - Path - PathFormatGeneric - PathRootAbsolute - - - - LogSystemMessagestrue - AutoTargetDLLsfalse - StopAtWatchpointstrue - PauseWhileRunningfalse - PauseInterval5 - PauseUIFlags0 - AltExePath - Path - PathFormatGeneric - PathRootAbsolute - - StopAtTempBPOnLaunchtrue - CacheSymbolicstrue - TempBPFunctionNamemain - TempBPType0 - - - Enabledfalse - ConnectionName - DownloadPath - LaunchRemoteAppfalse - RemoteAppPath - - - OtherExecutables - - - CustomColor1 - Red0 - Green32767 - Blue0 - - CustomColor2 - Red0 - Green32767 - Blue0 - - CustomColor3 - Red0 - Green32767 - Blue0 - - CustomColor4 - Red0 - Green32767 - Blue0 - - - - MWFrontEnd_C_cplusplus0 - MWFrontEnd_C_checkprotos1 - MWFrontEnd_C_arm0 - MWFrontEnd_C_trigraphs0 - MWFrontEnd_C_onlystdkeywords0 - MWFrontEnd_C_enumsalwaysint1 - MWFrontEnd_C_mpwpointerstyle0 - MWFrontEnd_C_prefixnameGFXComponentDebugPrefix.h - MWFrontEnd_C_ansistrict0 - MWFrontEnd_C_mpwcnewline0 - MWFrontEnd_C_wchar_type1 - MWFrontEnd_C_enableexceptions1 - MWFrontEnd_C_dontreusestrings0 - MWFrontEnd_C_poolstrings0 - MWFrontEnd_C_dontinline1 - MWFrontEnd_C_useRTTI1 - MWFrontEnd_C_multibyteaware0 - MWFrontEnd_C_unsignedchars0 - MWFrontEnd_C_autoinline0 - MWFrontEnd_C_booltruefalse0 - MWFrontEnd_C_direct_to_som0 - MWFrontEnd_C_som_env_check0 - MWFrontEnd_C_alwaysinline0 - MWFrontEnd_C_inlinelevel0 - MWFrontEnd_C_ecplusplus0 - MWFrontEnd_C_objective_c0 - MWFrontEnd_C_defer_codegen0 - - - MWWarning_C_warn_illpragma1 - MWWarning_C_warn_emptydecl1 - MWWarning_C_warn_possunwant1 - MWWarning_C_warn_unusedvar1 - MWWarning_C_warn_unusedarg1 - MWWarning_C_warn_extracomma1 - MWWarning_C_pedantic1 - MWWarning_C_warningerrors0 - MWWarning_C_warn_hidevirtual1 - MWWarning_C_warn_implicitconv0 - MWWarning_C_warn_notinlined0 - MWWarning_C_warn_structclass0 - - - MWFTP_Post_hostName - MWFTP_Post_username - MWFTP_Post_password0 - MWFTP_Post_remoteDir - MWFTP_Post_ftp_PathVersion0 - MWFTP_Post_ftp_PathType0 - MWFTP_Post_ftp_PathFormat0 - MWFTP_Post_ftp_tree - MWFTP_Post_uploadDir - MWFTP_Post_ftp_port21 - MWFTP_Post_SendBin1 - MWFTP_Post_ShouldLog1 - - - MWCommandLine_Java_clsName - MWCommandLine_Java_args - - - MWVJavaDebugging_Protocol1 - MWVJavaDebugging_JDKVersion1 - MWVJavaDebugging_TimeOut10 - MWVJavaDebugging_SupportSlowDevicesfalse - - - MWJava_Language_optimizefalse - MWJava_Language_warnDeprecatedfalse - MWJava_Language_emitMapfalse - MWJava_Language_strictFileNamesfalse - MWJava_Language_strictFileHierarchyfalse - MWJava_Language_1_1_Compatiblefalse - MWJava_Language_emitHeaders0 - MWJava_Language_headerTypeJNINativeHeaders - MWJava_Language_packageFilter - MWJava_Language_genCommentstrue - MWJava_Language_genHeadersfalse - - - MWJava_MRJAppBuilder_outFileMRJApplication - MWJava_MRJAppBuilder_mergefalse - MWJava_MRJAppBuilder_quitMenutrue - MWJava_MRJAppBuilder_growfalse - MWJava_MRJAppBuilder_stdoutTypeConsole - MWJava_MRJAppBuilder_stderrTypeConsole - MWJava_MRJAppBuilder_stdinTypeConsole - MWJava_MRJAppBuilder_appIconPVersion0 - MWJava_MRJAppBuilder_appIconPType0 - MWJava_MRJAppBuilder_appIconPFormat0 - MWJava_MRJAppBuilder_appIconPTree - MWJava_MRJAppBuilder_appIconFile - MWJava_MRJAppBuilder_splashScreenPVersion0 - MWJava_MRJAppBuilder_splashScreenPType0 - MWJava_MRJAppBuilder_splashScreenPFormat0 - MWJava_MRJAppBuilder_splashScreenPTree - MWJava_MRJAppBuilder_splashScreenPICTFile - MWJava_MRJAppBuilder_aboutName - MWJava_MRJAppBuilder_stdoutPVersion0 - MWJava_MRJAppBuilder_stdoutPType0 - MWJava_MRJAppBuilder_stdoutPFormat0 - MWJava_MRJAppBuilder_stdoutPTree - MWJava_MRJAppBuilder_stdoutFile - MWJava_MRJAppBuilder_stdoutAppendfalse - MWJava_MRJAppBuilder_stderrPType0 - MWJava_MRJAppBuilder_stderrPFormat0 - MWJava_MRJAppBuilder_stderrPTree - MWJava_MRJAppBuilder_stderrFile - MWJava_MRJAppBuilder_stderrAppendfalse - MWJava_MRJAppBuilder_stdinPType0 - MWJava_MRJAppBuilder_stdinPFormat0 - MWJava_MRJAppBuilder_stdinPTree - MWJava_MRJAppBuilder_stdinFile - - - MWJava_Output_outputtypeJarFile - MWJava_Output_outfileJavaClasses.jar - MWJava_Output_ftype1514754080 - MWJava_Output_fcreator1297570384 - MWJava_Output_compress0 - MWJava_Output_genManifest0 - MWJava_Output_trunctypeFront - MWJava_Output_deleteClasses0 - MWJava_Output_consoleApp1 - - - MWJava_Proj_projtypeApplet - MWJava_Proj_mainClassName - MWJava_Proj_HTMLAppCreator1463898714 - MWJava_Proj_HTMLAppName - MWJava_Proj_PathVersion0 - MWJava_Proj_PathType0 - MWJava_Proj_PathFormat0 - MWJava_Proj_tree - MWJava_Proj_HTMLAppWin32Name - MWJava_Proj_compress0 - MWJava_Proj_useVM1 - MWJava_Proj_vmarguments - MWJava_Proj_vmName - MWJava_Proj_simPropFile - - - MWJavaDoc_Proj_Version1 - MWJavaDoc_Proj_Depricated1 - MWJavaDoc_Proj_Author1 - MWJavaDoc_Proj_Index1 - MWJavaDoc_Proj_Tree1 - MWJavaDoc_Proj_SunResolveToSame0 - MWJavaDoc_Proj_Shortnames1 - MWJavaDoc_Proj_Folder0 - MWJavaDoc_Proj_GenerateAPILinks0 - MWJavaDoc_Proj_scopePublic - MWJavaDoc_Proj_fcreator1297303877 - MWJavaDoc_Proj_encodingName - MWJavaDoc_Proj_decodingName - MWJavaDoc_Proj_javaPackagePathhttp://java.sun.com/products/jdk/1.1/docs/api/ - - - MWMerge_MacOS_projectTypeApplication - MWMerge_MacOS_outputNameMerge Out - MWMerge_MacOS_outputCreator???? - MWMerge_MacOS_outputTypeAPPL - MWMerge_MacOS_suppressWarning0 - MWMerge_MacOS_copyFragments1 - MWMerge_MacOS_copyResources1 - MWMerge_MacOS_flattenResource0 - MWMerge_MacOS_flatFileNamea.rsrc - MWMerge_MacOS_flatFileOutputPath - Path: - PathFormatMacOS - PathRootProject - - MWMerge_MacOS_skipResources - DLGX - ckid - Proj - WSPC - - - - FileLockedfalse - ResourcesMapIsReadOnlyfalse - PrinterDriverIsMultiFinderCompatiblefalse - Invisiblefalse - HasBundlefalse - NameLockedfalse - Stationeryfalse - HasCustomIconfalse - Sharedfalse - HasBeenInitedfalse - Label0 - Comments - - - MWMacOSPackager_UsePackager0 - MWMacOSPackager_FolderToPackage - Path: - PathFormatMacOS - PathRootProject - - MWMacOSPackager_CreateClassicAlias0 - MWMacOSPackager_ClassicAliasMethodUseTargetOutput - MWMacOSPackager_ClassicAliasPath - Path: - PathFormatMacOS - PathRootProject - - MWMacOSPackager_CreatePkgInfo0 - MWMacOSPackager_PkgCreatorType???? - MWMacOSPackager_PkgFileTypeAPPL - - - MWCodeGen_PPC_structalignmentPPC - MWCodeGen_PPC_tracebacktablesInline - MWCodeGen_PPC_processorGeneric - MWCodeGen_PPC_readonlystrings0 - MWCodeGen_PPC_tocdata1 - MWCodeGen_PPC_profiler0 - MWCodeGen_PPC_fpcontract1 - MWCodeGen_PPC_schedule0 - MWCodeGen_PPC_peephole0 - MWCodeGen_PPC_processorspecific0 - MWCodeGen_PPC_altivec0 - MWCodeGen_PPC_vectortocdata0 - MWCodeGen_PPC_vrsave0 - - - MWCodeGen_MachO_structalignmentPPC - MWCodeGen_MachO_tracebacktablesNone - MWCodeGen_MachO_processorGeneric - MWCodeGen_MachO_readonlystrings0 - MWCodeGen_MachO_profiler0 - MWCodeGen_MachO_fpcontract1 - MWCodeGen_MachO_schedule0 - MWCodeGen_MachO_peephole1 - MWCodeGen_MachO_processorspecific0 - MWCodeGen_MachO_altivec0 - MWCodeGen_MachO_vrsave1 - MWCodeGen_MachO_common0 - MWCodeGen_MachO_implicit_templates1 - - - MWDisassembler_PPC_showcode1 - MWDisassembler_PPC_extended1 - MWDisassembler_PPC_mix0 - MWDisassembler_PPC_nohex0 - MWDisassembler_PPC_showdata1 - MWDisassembler_PPC_showexceptions1 - MWDisassembler_PPC_showsym0 - MWDisassembler_PPC_shownames1 - - - GlobalOptimizer_PPC_optimizationlevelLevel0 - GlobalOptimizer_PPC_optforSpeed - - - MWLinker_PPC_linksym1 - MWLinker_PPC_symfullpath1 - MWLinker_PPC_linkmap0 - MWLinker_PPC_nolinkwarnings0 - MWLinker_PPC_dontdeadstripinitcode0 - MWLinker_PPC_permitmultdefs1 - MWLinker_PPC_linkmodeFast - MWLinker_PPC_initname__initializeResources - MWLinker_PPC_mainname - MWLinker_PPC_termname__terminateResources - - - MWLinker_MachO_exportsNone - MWLinker_MachO_mainnamestart - MWLinker_MachO_currentversion0 - MWLinker_MachO_compatibleversion0 - MWLinker_MachO_symfullpath0 - MWLinker_MachO_supresswarnings0 - MWLinker_MachO_multisymerror0 - MWLinker_MachO_prebind1 - MWLinker_MachO_deadstrip1 - MWLinker_MachO_objectivecsemantics0 - MWLinker_MachO_whichfileloaded0 - MWLinker_MachO_whyfileloaded0 - MWLinker_MachO_readonlyrelocsErrors - MWLinker_MachO_undefinedsymbolsErrors - MWLinker_MachO_twolevelnamespace1 - MWLinker_MachO_stripdebugsymbols0 - - - MWProject_MachO_typeExecutable - MWProject_MachO_outfilea.exe - MWProject_MachO_filecreator???? - MWProject_MachO_filetypeMEXE - MWProject_MachO_stacksize64 - MWProject_MachO_stackaddress0 - MWProject_MachO_flatrsrc1 - MWProject_MachO_flatrsrcfilenamea.rsrc - MWProject_MachO_flatrsrcoutputdir - Path: - PathFormatMacOS - PathRootProject - - MWProject_MachO_installpath./ - - - MWPEF_exportsPragma - MWPEF_libfolder0 - MWPEF_sortcodeNone - MWPEF_expandbss0 - MWPEF_sharedata0 - MWPEF_olddefversion0 - MWPEF_oldimpversion0 - MWPEF_currentversion0 - MWPEF_fragmentnameGfxComponent - MWPEF_collapsereloads0 - - - MWProject_PPC_typeSharedLibrary - MWProject_PPC_outfilegfxComponentDebug.shlb - MWProject_PPC_filecreatorMOZZ - MWProject_PPC_filetypeshlb - MWProject_PPC_size0 - MWProject_PPC_minsize0 - MWProject_PPC_stacksize0 - MWProject_PPC_flags0 - MWProject_PPC_symfilename - MWProject_PPC_rsrcname - MWProject_PPC_rsrcheaderNative - MWProject_PPC_rsrctype???? - MWProject_PPC_rsrcid0 - MWProject_PPC_rsrcflags0 - MWProject_PPC_rsrcstore0 - MWProject_PPC_rsrcmerge0 - MWProject_PPC_flatrsrc0 - MWProject_PPC_flatrsrcoutputdir - Path: - PathFormatMacOS - PathRootProject - - MWProject_PPC_flatrsrcfilename - - - MWAssembler_PPC_auxheader0 - MWAssembler_PPC_symmodeMac - MWAssembler_PPC_dialectPPC - MWAssembler_PPC_prefixfile - MWAssembler_PPC_typecheck0 - MWAssembler_PPC_warnings0 - MWAssembler_PPC_casesensitive0 - - - MWRez_Language_maxwidth80 - MWRez_Language_scriptRoman - MWRez_Language_alignmentAlign1 - MWRez_Language_filtermodeFilterSkip - MWRez_Language_suppresswarnings0 - MWRez_Language_escapecontrolchars1 - MWRez_Language_prefixname - MWRez_Language_filteredtypes'CODE' 'DATA' 'PICT' - - - MWWinRC_prefixname - - - MWCodeGen_X86_processorGeneric - MWCodeGen_X86_alignmentbytes8 - MWCodeGen_X86_exceptionsZeroOverhead - MWCodeGen_X86_extinst_mmx0 - MWCodeGen_X86_extinst_3dnow0 - MWCodeGen_X86_use_mmx_3dnow_convention0 - MWCodeGen_X86_machinecodelisting0 - MWCodeGen_X86_intrinsics0 - MWCodeGen_X86_syminfo0 - MWCodeGen_X86_codeviewinfo1 - MWCodeGen_X86_extinst_cmov_fcomi0 - MWCodeGen_X86_extinst_sse0 - - - PDisasmX86_showHeaderstrue - PDisasmX86_showSymTabtrue - PDisasmX86_showCodetrue - PDisasmX86_showSourcefalse - PDisasmX86_showHextrue - PDisasmX86_showRelocationtrue - PDisasmX86_showCommentsfalse - PDisasmX86_showDebugfalse - PDisasmX86_showExceptionsfalse - PDisasmX86_showDatatrue - PDisasmX86_showRawfalse - PDisasmX86_verbosefalse - - - MWDebugger_X86_Exceptions - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - - - - GlobalOptimizer_X86_optimizationlevelLevel0 - GlobalOptimizer_X86_optforSpeed - - - MWLinker_X86_entrypointusageDefault - MWLinker_X86_entrypoint - MWLinker_X86_subsystemWinGUI - MWLinker_X86_subsysmajorid4 - MWLinker_X86_subsysminorid0 - MWLinker_X86_usrmajorid0 - MWLinker_X86_usrminorid0 - MWLinker_X86_commandfile - MWLinker_X86_generatemap0 - MWLinker_X86_linksym0 - MWLinker_X86_linkCV1 - - - MWProject_X86_typeApplication - MWProject_X86_outfilenoname.exe - MWProject_X86_baseaddress4194304 - MWProject_X86_maxstacksize1024 - MWProject_X86_minstacksize4 - MWProject_X86_size1024 - MWProject_X86_minsize4 - MWProject_X86_importlib - xpidl Settings - 0001000101000000000000000000000000000000000000000000000000000000 - 0000000000000000 - - - - - Name - nsImageMac.cpp - MacOS - Text - Debug - - - Name - nsRegionMac.cpp - MacOS - Text - Debug - - - Name - nsDeviceContextMac.cpp - MacOS - Text - Debug - - - Name - nsFontMetricsMac.cpp - MacOS - Text - Debug - - - Name - nsRenderingContextMac.cpp - MacOS - Text - Debug - - - Name - NSRuntimeDebug.shlb - MacOS - Library - Debug - - - Name - NSStdLibDebug.shlb - MacOS - Library - Debug - - - Name - xpcomDebug.shlb - MacOS - Library - Debug - - - Name - NSPR20Debug.shlb - MacOS - Library - Debug - - - Name - nsDeviceContextSpecFactoryM.cpp - MacOS - Text - Debug - - - Name - nsDrawingSurfaceMac.cpp - MacOS - Text - Debug - - - Name - nsATSUIUtils.cpp - MacOS - Text - Debug - - - Name - nsGraphicState.cpp - MacOS - Text - Debug - - - Name - nsUnicodeRenderingToolkit.cpp - MacOS - Text - Debug - - - Name - nsUnicodeMappingUtil.cpp - MacOS - Text - Debug - - - Name - nsUnicodeFontMappingMac.cpp - MacOS - Text - Debug - - - Name - nsScreenMac.cpp - MacOS - Text - Debug - - - Name - nsScreenManagerMac.cpp - MacOS - Text - Debug - - - Name - InterfacesStubs - MacOS - Library - Debug - - - Name - nsDeviceContextSpecX.cpp - MacOS - Text - Debug - - - Name - nsMacResources.cpp - MacOS - Text - Debug - - - Name - nsMacGFX.rsrc - MacOS - Resource - Debug - - - Name - gfxDebug.shlb - MacOS - Library - Debug - - - Name - nsGraphicsImpl.cpp - MacOS - Text - Debug - - - Name - NSComponentStartup.o - MacOS - Library - Debug - - - Name - nsPrintOptionsX.cpp - MacOS - Text - Debug - - - Name - nsPrintOptionsImpl.cpp - MacOS - Text - Debug - - - Name - nsPrintSettingsImpl.cpp - MacOS - Text - Debug - - - Name - nsRenderingContextImpl.cpp - MacOS - Text - Debug - - - Name - nsBlender.cpp - MacOS - Text - Debug - - - Name - nsScriptableRegion.cpp - MacOS - Text - Debug - - - Name - nsMacUnicodeFontInfo.cpp - MacOS - Text - Debug - - - Name - nsNativeThemeMac.cpp - MacOS - Text - Debug - - - Name - nsCompressedCharMap.cpp - MacOS - Text - Debug - - - Name - nsDeviceContext.cpp - MacOS - Text - Debug - - - Name - UnicharUtilsStaticDebug.o - MacOS - Library - Debug - - - Name - nsGfxFactoryMac.cpp - MacOS - Text - Debug - - - Name - nsFontList.cpp - MacOS - Text - Debug - - - - - Name - NSComponentStartup.o - MacOS - - - Name - NSRuntimeDebug.shlb - MacOS - - - Name - NSStdLibDebug.shlb - MacOS - - - Name - xpcomDebug.shlb - MacOS - - - Name - NSPR20Debug.shlb - MacOS - - - Name - nsImageMac.cpp - MacOS - - - Name - nsRegionMac.cpp - MacOS - - - Name - nsDeviceContextMac.cpp - MacOS - - - Name - nsFontMetricsMac.cpp - MacOS - - - Name - nsRenderingContextMac.cpp - MacOS - - - Name - nsDeviceContextSpecFactoryM.cpp - MacOS - - - Name - nsDrawingSurfaceMac.cpp - MacOS - - - Name - nsATSUIUtils.cpp - MacOS - - - Name - nsGraphicState.cpp - MacOS - - - Name - nsUnicodeRenderingToolkit.cpp - MacOS - - - Name - nsUnicodeMappingUtil.cpp - MacOS - - - Name - nsUnicodeFontMappingMac.cpp - MacOS - - - Name - nsScreenMac.cpp - MacOS - - - Name - nsScreenManagerMac.cpp - MacOS - - - Name - InterfacesStubs - MacOS - - - Name - nsDeviceContextSpecX.cpp - MacOS - - - Name - nsMacResources.cpp - MacOS - - - Name - nsMacGFX.rsrc - MacOS - - - Name - gfxDebug.shlb - MacOS - - - Name - nsGraphicsImpl.cpp - MacOS - - - Name - nsPrintOptionsX.cpp - MacOS - - - Name - nsPrintOptionsImpl.cpp - MacOS - - - Name - nsPrintSettingsImpl.cpp - MacOS - - - Name - nsRenderingContextImpl.cpp - MacOS - - - Name - nsBlender.cpp - MacOS - - - Name - nsScriptableRegion.cpp - MacOS - - - Name - nsMacUnicodeFontInfo.cpp - MacOS - - - Name - nsNativeThemeMac.cpp - MacOS - - - Name - nsCompressedCharMap.cpp - MacOS - - - Name - nsDeviceContext.cpp - MacOS - - - Name - UnicharUtilsStaticDebug.o - MacOS - - - Name - nsGfxFactoryMac.cpp - MacOS - - - Name - nsFontList.cpp - MacOS - - - - - - - gfxComponentDbg.shlb - gfxComponent.shlb - gfxComponentCarbon.shlb - gfxComponentCarbonDbg.shlb - - - - mac - - gfxComponentDbg.shlb - Name - nsATSUIUtils.cpp - MacOS - - - gfxComponentDbg.shlb - Name - nsBlender.cpp - MacOS - - - gfxComponentDbg.shlb - Name - nsCompressedCharMap.cpp - MacOS - - - gfxComponentDbg.shlb - Name - nsDeviceContext.cpp - MacOS - - - gfxComponentDbg.shlb - Name - nsDeviceContextMac.cpp - MacOS - - - gfxComponentDbg.shlb - Name - nsDeviceContextSpecFactoryM.cpp - MacOS - - - gfxComponentDbg.shlb - Name - nsDeviceContextSpecMac.cpp - MacOS - - - gfxComponentCarbon.shlb - Name - nsDeviceContextSpecX.cpp - MacOS - - - gfxComponentDbg.shlb - Name - nsDrawingSurfaceMac.cpp - MacOS - - - gfxComponentDbg.shlb - Name - nsFontMetricsMac.cpp - MacOS - - - gfxComponentDbg.shlb - Name - nsFontList.cpp - MacOS - - - gfxComponentDbg.shlb - Name - nsGraphicsImpl.cpp - MacOS - - - gfxComponentDbg.shlb - Name - nsGraphicState.cpp - MacOS - - - gfxComponentDbg.shlb - Name - nsImageMac.cpp - MacOS - - - gfxComponentDbg.shlb - Name - nsMacResources.cpp - MacOS - - - gfxComponentDbg.shlb - Name - nsMacUnicodeFontInfo.cpp - MacOS - - - gfxComponentDbg.shlb - Name - nsNativeThemeMac.cpp - MacOS - - - gfxComponentDbg.shlb - Name - nsPrintOptionsImpl.cpp - MacOS - - - gfxComponentDbg.shlb - Name - nsPrintSettingsImpl.cpp - MacOS - - - gfxComponentDbg.shlb - Name - nsPrintOptionsMac.cpp - MacOS - - - gfxComponentCarbon.shlb - Name - nsPrintOptionsX.cpp - MacOS - - - gfxComponentDbg.shlb - Name - nsRegionMac.cpp - MacOS - - - gfxComponentDbg.shlb - Name - nsRenderingContextImpl.cpp - MacOS - - - gfxComponentDbg.shlb - Name - nsRenderingContextMac.cpp - MacOS - - - gfxComponentDbg.shlb - Name - nsScreenMac.cpp - MacOS - - - gfxComponentDbg.shlb - Name - nsScreenManagerMac.cpp - MacOS - - - gfxComponentDbg.shlb - Name - nsScriptableRegion.cpp - MacOS - - - gfxComponentDbg.shlb - Name - nsUnicodeFontMappingMac.cpp - MacOS - - - gfxComponentDbg.shlb - Name - nsUnicodeMappingUtil.cpp - MacOS - - - gfxComponentDbg.shlb - Name - nsUnicodeRenderingToolkit.cpp - MacOS - - - Module - - gfxComponentDbg.shlb - Name - nsGfxFactoryMac.cpp - MacOS - - - NS Libraries - Debug - - gfxComponentDbg.shlb - Name - gfxDebug.shlb - MacOS - - - gfxComponentDbg.shlb - Name - NSPR20Debug.shlb - MacOS - - - gfxComponentDbg.shlb - Name - NSRuntimeDebug.shlb - MacOS - - - gfxComponentDbg.shlb - Name - NSStdLibDebug.shlb - MacOS - - - gfxComponentDbg.shlb - Name - xpcomDebug.shlb - MacOS - - - Optimized - - gfxComponentCarbon.shlb - Name - gfx.shlb - MacOS - - - gfxComponentCarbon.shlb - Name - NSPR20.shlb - MacOS - - - gfxComponentCarbon.shlb - Name - NSRuntime.shlb - MacOS - - - gfxComponentCarbon.shlb - Name - NSStdLib.shlb - MacOS - - - gfxComponentCarbon.shlb - Name - xpcom.shlb - MacOS - - - - Resources - - gfxComponentDbg.shlb - Name - nsMacGFX.rsrc - MacOS - - - Static libs - - gfxComponentCarbon.shlb - Name - UnicharUtilsStatic.o - MacOS - - - gfxComponentDbg.shlb - Name - UnicharUtilsStaticDebug.o - MacOS - - - System Libraries - - gfxComponentDbg.shlb - Name - InterfacesStubs - MacOS - - - gfxComponentDbg.shlb - Name - NSComponentStartup.o - MacOS - - - gfxComponentDbg.shlb - Name - FontManager - MacOS - - - - - + \ No newline at end of file diff --git a/mozilla/gfx/public/nsDeviceContext.h b/mozilla/gfx/public/nsDeviceContext.h index 895fc4aebfa..d55a579c716 100644 --- a/mozilla/gfx/public/nsDeviceContext.h +++ b/mozilla/gfx/public/nsDeviceContext.h @@ -131,6 +131,8 @@ public: NS_IMETHOD GetPaletteInfo(nsPaletteInfo& aPaletteInfo); + NS_IMETHOD PrepareDocument(PRUnichar * aTitle, + PRUnichar* aPrintToFileName) { return NS_OK; } NS_IMETHOD AbortDocument(void) { return NS_OK; } #ifdef NS_PRINT_PREVIEW diff --git a/mozilla/gfx/public/nsIDeviceContext.h b/mozilla/gfx/public/nsIDeviceContext.h index e53f5a61932..f40e9f2ea18 100644 --- a/mozilla/gfx/public/nsIDeviceContext.h +++ b/mozilla/gfx/public/nsIDeviceContext.h @@ -138,6 +138,12 @@ typedef void * nsNativeDeviceContext; /* Cannot Print or Print Preview XUL Documents */ #define NS_ERROR_GFX_PRINTER_NO_XUL \ NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+27) +/* The toolkit no longer supports the Print Dialog (for embedders) */ +#define NS_ERROR_GFX_NO_PRINTDIALOG_IN_TOOLKIT \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+28) +/* The was wasn't any Print Prompt service registered (this shouldn't happen) */ +#define NS_ERROR_GFX_NO_PRINTROMPTSERVICE \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+29) /** @@ -462,6 +468,17 @@ public: NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice, nsIDeviceContext *&aContext) = 0; + /** + * This is enables the DeviceContext to anything it needs to do for Printing + * before Reflow and BeginDocument is where work can be done after reflow. + * @param aTitle - itle of Document + * @param aPrintToFileName - name of file to print to, if NULL then don't print to file + * + * @return error status + */ + NS_IMETHOD PrepareDocument(PRUnichar * aTitle, + PRUnichar* aPrintToFileName) = 0; + //XXX need to work out re-entrancy issues for these APIs... MMP /** * Inform the output device that output of a document is beginning @@ -469,9 +486,18 @@ public: * EndDocument(). * XXX needs to take parameters so that feedback can be given to the * app regarding pagination progress and aborting print operations? + * + * @param aTitle - itle of Document + * @param aPrintToFileName - name of file to print to, if NULL then don't print to file + * @param aStartPage - starting page number (must be greater than zero) + * @param aEndPage - ending page number (must be less than or equal to number of pages) + * * @return error status */ - NS_IMETHOD BeginDocument(PRUnichar * aTitle) = 0; + NS_IMETHOD BeginDocument(PRUnichar* aTitle, + PRUnichar* aPrintToFileName, + PRInt32 aStartPage, + PRInt32 aEndPage) = 0; /** * Inform the output device that output of a document is ending. diff --git a/mozilla/gfx/public/nsIDeviceContextSpecFactory.h b/mozilla/gfx/public/nsIDeviceContextSpecFactory.h index 30b914745de..e9011f2687a 100644 --- a/mozilla/gfx/public/nsIDeviceContextSpecFactory.h +++ b/mozilla/gfx/public/nsIDeviceContextSpecFactory.h @@ -64,24 +64,17 @@ public: * means getting information about a printer. A previously * returned device context spec can be passed in and used as * a starting point for getting a new spec (or simply returning - * the old spec again). Additionally, if it is desirable to - * get the device context spec without user intervention, any - * dialog boxes can be supressed by passing in PR_TRUE for the - * aQuiet parameter. + * the old spec again). * @param aWidget.. this is a widget a dialog can be hosted in * @param aNewSpec out parameter for device context spec returned. the * aOldSpec may be returned if the object is recyclable. - * @param aQuiet if PR_TRUE, prevent the need for user intervention - * in obtaining device context spec. if nsnull is passed in for - * the aOldSpec, this will typically result in getting a device - * context spec for the default output device (i.e. default - * printer). + * @param aIsPrintPreview if PR_TRUE, creating Spec for PrintPreview * @return error status */ NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget, nsIPrintSettings* aPrintSettings, nsIDeviceContextSpec *&aNewSpec, - PRBool aQuiet) = 0; + PRBool aIsPrintPreview) = 0; }; #endif diff --git a/mozilla/gfx/public/nsIPrintingContext.h b/mozilla/gfx/public/nsIPrintingContext.h index 7620a50c372..71ea28484c5 100644 --- a/mozilla/gfx/public/nsIPrintingContext.h +++ b/mozilla/gfx/public/nsIPrintingContext.h @@ -54,14 +54,10 @@ public: NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPRINTING_CONTEXT_IID) /** * Initialize the printing context for use. - * @param aQuiet if PR_TRUE, prevent the need for user intervention - * in obtaining device context spec. if nsnull is passed in for - * the aOldSpec, this will typically result in getting a device - * context spec for the default output device (i.e. default - * printer). + * @param aIsPrintPreview TRUE if doing print preview, FALSE if normal printing. * @return error status */ - NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet) = 0; + NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aIsPrintPreview) = 0; /** * This will tell if the printmanager is currently open @@ -78,7 +74,8 @@ public: */ NS_IMETHOD ClosePrintManager() = 0; - NS_IMETHOD BeginDocument() = 0; + NS_IMETHOD BeginDocument(PRInt32 aStartPage, + PRInt32 aEndPage) = 0; NS_IMETHOD EndDocument() = 0; diff --git a/mozilla/gfx/src/beos/Makefile.in b/mozilla/gfx/src/beos/Makefile.in index ac268d70e28..dc00cbed21e 100644 --- a/mozilla/gfx/src/beos/Makefile.in +++ b/mozilla/gfx/src/beos/Makefile.in @@ -55,8 +55,6 @@ REQUIRES = xpcom \ view \ intl \ uconv \ - dom \ - windowwatcher \ unicharutil \ $(NULL) diff --git a/mozilla/gfx/src/beos/nsDeviceContextBeOS.cpp b/mozilla/gfx/src/beos/nsDeviceContextBeOS.cpp index b4a520eed3c..0f82f61226c 100644 --- a/mozilla/gfx/src/beos/nsDeviceContextBeOS.cpp +++ b/mozilla/gfx/src/beos/nsDeviceContextBeOS.cpp @@ -381,7 +381,7 @@ NS_IMETHODIMP nsDeviceContextBeOS::GetDeviceContextFor(nsIDeviceContextSpec *aDe #endif /* USE_POSTSCRIPT */ } -NS_IMETHODIMP nsDeviceContextBeOS::BeginDocument(PRUnichar * aTitle) +NS_IMETHODIMP nsDeviceContextBeOS::BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage) { return NS_OK; } diff --git a/mozilla/gfx/src/beos/nsDeviceContextBeOS.h b/mozilla/gfx/src/beos/nsDeviceContextBeOS.h index 8145603479f..c6ee60523db 100644 --- a/mozilla/gfx/src/beos/nsDeviceContextBeOS.h +++ b/mozilla/gfx/src/beos/nsDeviceContextBeOS.h @@ -81,7 +81,7 @@ public: NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice, nsIDeviceContext *&aContext); - NS_IMETHOD BeginDocument(PRUnichar * aTitle); + NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage); NS_IMETHOD EndDocument(void); NS_IMETHOD BeginPage(void); diff --git a/mozilla/gfx/src/beos/nsDeviceContextSpecB.cpp b/mozilla/gfx/src/beos/nsDeviceContextSpecB.cpp index 20aecc7b405..57e5f4c9f65 100644 --- a/mozilla/gfx/src/beos/nsDeviceContextSpecB.cpp +++ b/mozilla/gfx/src/beos/nsDeviceContextSpecB.cpp @@ -42,19 +42,6 @@ #include "nsIPref.h" #include "prenv.h" /* for PR_GetEnv */ -#include "nsIDOMWindow.h" -#include "nsIServiceManager.h" -#include "nsIDialogParamBlock.h" -#include "nsISupportsPrimitives.h" -#include "nsIWindowWatcher.h" -#include "nsIDOMWindowInternal.h" - -#include "nsReadableUtils.h" -#include "nsISupportsArray.h" - -//#include "prmem.h" -//#include "plstr.h" - //---------------------------------------------------------------------------------- // The printer data is shared between the PrinterEnumerator and the nsDeviceContextSpecG // The PrinterEnumerator creates the printer info @@ -153,73 +140,12 @@ NS_IMETHODIMP nsDeviceContextSpecBeOS :: QueryInterface(REFNSIID aIID, void** aI NS_IMPL_ADDREF(nsDeviceContextSpecBeOS) NS_IMPL_RELEASE(nsDeviceContextSpecBeOS) - -/** ------------------------------------------------------- - */ -static nsresult DisplayXPDialog(nsIPrintSettings* aPS, - const char* aChromeURL, - PRBool& aClickedOK) -{ - NS_ASSERTION(aPS, "Must have a print settings!"); - - aClickedOK = PR_FALSE; - nsresult rv = NS_ERROR_FAILURE; - - // create a nsISupportsArray of the parameters - // being passed to the window - nsCOMPtr array; - NS_NewISupportsArray(getter_AddRefs(array)); - if (!array) return NS_ERROR_FAILURE; - - nsCOMPtr ps = aPS; - nsCOMPtr psSupports(do_QueryInterface(ps)); - NS_ASSERTION(psSupports, "PrintSettings must be a supports"); - array->AppendElement(psSupports); - - nsCOMPtr ioParamBlock(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1")); - if (ioParamBlock) { - ioParamBlock->SetInt(0, 0); - nsCOMPtr blkSupps(do_QueryInterface(ioParamBlock)); - NS_ASSERTION(blkSupps, "IOBlk must be a supports"); - - array->AppendElement(blkSupps); - nsCOMPtr arguments(do_QueryInterface(array)); - NS_ASSERTION(array, "array must be a supports"); - - nsCOMPtr wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); - if (wwatch) { - nsCOMPtr active; - wwatch->GetActiveWindow(getter_AddRefs(active)); - nsCOMPtr parent = do_QueryInterface(active); - - nsCOMPtr newWindow; - rv = wwatch->OpenWindow(parent, aChromeURL, - "_blank", "chrome,modal,centerscreen", array, - getter_AddRefs(newWindow)); - } - } - - if (NS_SUCCEEDED(rv)) { - PRInt32 buttonPressed = 0; - ioParamBlock->GetInt(0, &buttonPressed); - if (buttonPressed == 1) { - aClickedOK = PR_TRUE; - } else { - rv = NS_ERROR_ABORT; - } - } else { - rv = NS_ERROR_ABORT; - } - return rv; -} - - /** ------------------------------------------------------- * Initialize the nsDeviceContextSpecBeOS * @update dc 2/15/98 * @update syd 3/2/99 */ -NS_IMETHODIMP nsDeviceContextSpecBeOS::Init(nsIPrintSettings* aPS, PRBool aQuiet) +NS_IMETHODIMP nsDeviceContextSpecBeOS::Init(nsIPrintSettings* aPS) { nsresult rv = NS_ERROR_FAILURE; NS_ASSERTION(nsnull != aPS, "No print settings."); @@ -260,99 +186,88 @@ NS_IMETHODIMP nsDeviceContextSpecBeOS::Init(nsIPrintSettings* aPS, PRBool aQuiet return rv; } - if (!aQuiet ) { - rv = DisplayXPDialog(aPS, - "chrome://global/content/printdialog.xul", canPrint); - } - else { - canPrint = PR_TRUE; - } GlobalPrinters::GetInstance()->FreeGlobalPrinters(); - if (canPrint) { - if (aPS != nsnull) { - aPS->GetPrinterName(&printer); - aPS->GetPrintReversed(&reversed); - aPS->GetPrintInColor(&color); - aPS->GetPaperSize(&paper_size); - aPS->GetOrientation(&orientation); - aPS->GetPrintCommand(&command); - aPS->GetPrintRange(&printRange); - aPS->GetToFileName(&printfile); - aPS->GetPrintToFile(&tofile); - aPS->GetStartPageRange(&fromPage); - aPS->GetEndPageRange(&toPage); - aPS->GetNumCopies(&copies); - aPS->GetMarginTop(&dtop); - aPS->GetMarginLeft(&dleft); - aPS->GetMarginBottom(&dbottom); - aPS->GetMarginRight(&dright); + if (aPS != nsnull) { + aPS->GetPrinterName(&printer); + aPS->GetPrintReversed(&reversed); + aPS->GetPrintInColor(&color); + aPS->GetPaperSize(&paper_size); + aPS->GetOrientation(&orientation); + aPS->GetPrintCommand(&command); + aPS->GetPrintRange(&printRange); + aPS->GetToFileName(&printfile); + aPS->GetPrintToFile(&tofile); + aPS->GetStartPageRange(&fromPage); + aPS->GetEndPageRange(&toPage); + aPS->GetNumCopies(&copies); + aPS->GetMarginTop(&dtop); + aPS->GetMarginLeft(&dleft); + aPS->GetMarginBottom(&dbottom); + aPS->GetMarginRight(&dright); - if (command != nsnull && printfile != nsnull) { - // ToDo: Use LocalEncoding instead of UTF-8 (see bug 73446) - strcpy(mPrData.command, NS_ConvertUCS2toUTF8(command).get()); - strcpy(mPrData.path, NS_ConvertUCS2toUTF8(printfile).get()); - } - if (printer != nsnull) - strcpy(mPrData.printer, NS_ConvertUCS2toUTF8(printer).get()); + if (command != nsnull && printfile != nsnull) { + // ToDo: Use LocalEncoding instead of UTF-8 (see bug 73446) + strcpy(mPrData.command, NS_ConvertUCS2toUTF8(command).get()); + strcpy(mPrData.path, NS_ConvertUCS2toUTF8(printfile).get()); + } + if (printer != nsnull) + strcpy(mPrData.printer, NS_ConvertUCS2toUTF8(printer).get()); #ifdef DEBUG_rods - printf("margins: %5.2f,%5.2f,%5.2f,%5.2f\n", dtop, dleft, dbottom, dright); - printf("printRange %d\n", printRange); - printf("fromPage %d\n", fromPage); - printf("toPage %d\n", toPage); + printf("margins: %5.2f,%5.2f,%5.2f,%5.2f\n", dtop, dleft, dbottom, dright); + printf("printRange %d\n", printRange); + printf("fromPage %d\n", fromPage); + printf("toPage %d\n", toPage); #endif /* DEBUG_rods */ - } else { + } else { #ifdef VMS - // Note to whoever puts the "lpr" into the prefs file. Please contact me - // as I need to make the default be "print" instead of "lpr" for OpenVMS. - strcpy(mPrData.command, "print"); + // Note to whoever puts the "lpr" into the prefs file. Please contact me + // as I need to make the default be "print" instead of "lpr" for OpenVMS. + strcpy(mPrData.command, "print"); #else - strcpy(mPrData.command, "lpr ${MOZ_PRINTER_NAME:+'-P'}${MOZ_PRINTER_NAME}"); + strcpy(mPrData.command, "lpr ${MOZ_PRINTER_NAME:+'-P'}${MOZ_PRINTER_NAME}"); #endif /* VMS */ - } + } - mPrData.top = dtop; - mPrData.bottom = dbottom; - mPrData.left = dleft; - mPrData.right = dright; - mPrData.fpf = !reversed; - mPrData.grayscale = !color; - mPrData.size = paper_size; - mPrData.orientation = orientation; - mPrData.toPrinter = !tofile; - mPrData.copies = copies; + mPrData.top = dtop; + mPrData.bottom = dbottom; + mPrData.left = dleft; + mPrData.right = dright; + mPrData.fpf = !reversed; + mPrData.grayscale = !color; + mPrData.size = paper_size; + mPrData.orientation = orientation; + mPrData.toPrinter = !tofile; + mPrData.copies = copies; - // PWD, HOME, or fail - - if (!printfile) { - if ( ( path = PR_GetEnv( "PWD" ) ) == (char *) nsnull ) - if ( ( path = PR_GetEnv( "HOME" ) ) == (char *) nsnull ) - strcpy(mPrData.path, "mozilla.ps"); - - if ( path != (char *) nsnull ) - sprintf(mPrData.path, "%s/mozilla.ps", path); - else - return NS_ERROR_FAILURE; - } - + // PWD, HOME, or fail + + if (!printfile) { + if ( ( path = PR_GetEnv( "PWD" ) ) == (char *) nsnull ) + if ( ( path = PR_GetEnv( "HOME" ) ) == (char *) nsnull ) + strcpy(mPrData.path, "mozilla.ps"); + + if ( path != (char *) nsnull ) + sprintf(mPrData.path, "%s/mozilla.ps", path); + else + return NS_ERROR_FAILURE; + } + #ifdef NOT_IMPLEMENTED_YET - if (mGlobalNumPrinters) { - for(int i = 0; (i < mGlobalNumPrinters) && !mQueue; i++) { - if (!(mGlobalPrinterList->StringAt(i)->CompareWithConversion(mPrData.printer, TRUE, -1))) - mQueue = PrnDlg.SetPrinterQueue(i); - } - } + if (mGlobalNumPrinters) { + for(int i = 0; (i < mGlobalNumPrinters) && !mQueue; i++) { + if (!(mGlobalPrinterList->StringAt(i)->CompareWithConversion(mPrData.printer, TRUE, -1))) + mQueue = PrnDlg.SetPrinterQueue(i); + } + } #endif /* NOT_IMPLEMENTED_YET */ - - if (command != nsnull) { - nsMemory::Free(command); - } - if (printfile != nsnull) { - nsMemory::Free(printfile); - } - - return NS_OK; + + if (command != nsnull) { + nsMemory::Free(command); + } + if (printfile != nsnull) { + nsMemory::Free(printfile); } return rv; @@ -564,19 +479,7 @@ NS_IMETHODIMP nsPrinterEnumeratorBeOS::InitPrintSettingsFromPrinter(const PRUnic NS_IMETHODIMP nsPrinterEnumeratorBeOS::DisplayPropertiesDlg(const PRUnichar *aPrinter, nsIPrintSettings *aPrintSettings) { - /* fixme: We simply ignore the |aPrinter| argument here - * We should get the supported printer attributes from the printer and - * populate the print job options dialog with these data instead of using - * the "default set" here. - * However, this requires changes on all platforms and is another big chunk - * of patches ... ;-( - */ - - PRBool pressedOK; - return DisplayXPDialog(aPrintSettings, - "chrome://global/content/printjoboptions.xul", - pressedOK); - + return NS_OK; } //---------------------------------------------------------------------- diff --git a/mozilla/gfx/src/beos/nsDeviceContextSpecB.h b/mozilla/gfx/src/beos/nsDeviceContextSpecB.h index 779feeb3b92..31fddef43fc 100644 --- a/mozilla/gfx/src/beos/nsDeviceContextSpecB.h +++ b/mozilla/gfx/src/beos/nsDeviceContextSpecB.h @@ -68,14 +68,10 @@ public: /** * Initialize the nsDeviceContextSpecBeOS for use. This will allocate a printrecord for use * @update dc 2/16/98 - * @param aQuiet if PR_TRUE, prevent the need for user intervention - * in obtaining device context spec. if nsnull is passed in for - * the aOldSpec, this will typically result in getting a device - * context spec for the default output device (i.e. default - * printer). + * @param aIsPrintPreview if PR_TRUE, creating Spec for PrintPreview * @return error status */ - NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet); + NS_IMETHOD Init(nsIPrintSettings* aPS); /** diff --git a/mozilla/gfx/src/beos/nsDeviceContextSpecFactoryB.cpp b/mozilla/gfx/src/beos/nsDeviceContextSpecFactoryB.cpp index 57d518e9eed..6d5d1a2f429 100644 --- a/mozilla/gfx/src/beos/nsDeviceContextSpecFactoryB.cpp +++ b/mozilla/gfx/src/beos/nsDeviceContextSpecFactoryB.cpp @@ -79,15 +79,15 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryBeOS :: Init(void) */ NS_IMETHODIMP nsDeviceContextSpecFactoryBeOS :: CreateDeviceContextSpec(nsIWidget *aWidget, nsIPrintSettings* aPrintSettings, - nsIDeviceContextSpec *&aNewSpec, - PRBool aQuiet) + nsIDeviceContextSpec *&aNewSpec, + PRBool aIsPrintPreview) { nsresult rv; static NS_DEFINE_CID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID); nsCOMPtr devSpec = do_CreateInstance(kDeviceContextSpecCID, &rv); if (NS_SUCCEEDED(rv)) { - rv = ((nsDeviceContextSpecBeOS *)devSpec.get())->Init(aPrintSettings, aQuiet); + rv = ((nsDeviceContextSpecBeOS *)devSpec.get())->Init(aPrintSettings); if (NS_SUCCEEDED(rv)) { aNewSpec = devSpec; diff --git a/mozilla/gfx/src/beos/nsDeviceContextSpecFactoryB.h b/mozilla/gfx/src/beos/nsDeviceContextSpecFactoryB.h index 1ee077f3558..40dbccf18c8 100644 --- a/mozilla/gfx/src/beos/nsDeviceContextSpecFactoryB.h +++ b/mozilla/gfx/src/beos/nsDeviceContextSpecFactoryB.h @@ -53,7 +53,7 @@ public: NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget, nsIPrintSettings* aPrintSettings, nsIDeviceContextSpec *&aNewSpec, - PRBool aQuiet); + PRBool aIsPrintPreview); protected: virtual ~nsDeviceContextSpecFactoryBeOS(); diff --git a/mozilla/gfx/src/gtk/Makefile.in b/mozilla/gfx/src/gtk/Makefile.in index 242c2a825bd..249ced4cd56 100644 --- a/mozilla/gfx/src/gtk/Makefile.in +++ b/mozilla/gfx/src/gtk/Makefile.in @@ -37,15 +37,13 @@ REQUIRES = xpcom \ widget \ view \ util \ - dom \ pref \ uconv \ unicharutil \ - windowwatcher \ locale \ + necko \ content \ layout \ - necko \ $(NULL) # Sun's Complex Text Layout support diff --git a/mozilla/gfx/src/gtk/nsDeviceContextGTK.cpp b/mozilla/gfx/src/gtk/nsDeviceContextGTK.cpp index 215d9c1ffd0..9d42725d91c 100644 --- a/mozilla/gfx/src/gtk/nsDeviceContextGTK.cpp +++ b/mozilla/gfx/src/gtk/nsDeviceContextGTK.cpp @@ -562,7 +562,7 @@ NS_IMETHODIMP nsDeviceContextGTK::GetDeviceContextFor(nsIDeviceContextSpec *aDev return NS_ERROR_UNEXPECTED; } -NS_IMETHODIMP nsDeviceContextGTK::BeginDocument(PRUnichar * aTitle) +NS_IMETHODIMP nsDeviceContextGTK::BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage) { return NS_OK; } diff --git a/mozilla/gfx/src/gtk/nsDeviceContextGTK.h b/mozilla/gfx/src/gtk/nsDeviceContextGTK.h index da29abd23e6..e08ef99d466 100644 --- a/mozilla/gfx/src/gtk/nsDeviceContextGTK.h +++ b/mozilla/gfx/src/gtk/nsDeviceContextGTK.h @@ -84,7 +84,7 @@ public: NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice, nsIDeviceContext *&aContext); - NS_IMETHOD BeginDocument(PRUnichar * aTitle); + NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage); NS_IMETHOD EndDocument(void); NS_IMETHOD AbortDocument(void); diff --git a/mozilla/gfx/src/gtk/nsDeviceContextSpecFactoryG.cpp b/mozilla/gfx/src/gtk/nsDeviceContextSpecFactoryG.cpp index cd368a99018..55dd0a7fa1b 100644 --- a/mozilla/gfx/src/gtk/nsDeviceContextSpecFactoryG.cpp +++ b/mozilla/gfx/src/gtk/nsDeviceContextSpecFactoryG.cpp @@ -77,14 +77,14 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryGTK :: Init(void) NS_IMETHODIMP nsDeviceContextSpecFactoryGTK :: CreateDeviceContextSpec(nsIWidget *aWidget, nsIPrintSettings* aPrintSettings, nsIDeviceContextSpec *&aNewSpec, - PRBool aQuiet) + PRBool aIsPrintPreview) { nsresult rv; static NS_DEFINE_CID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID); nsCOMPtr devSpec = do_CreateInstance(kDeviceContextSpecCID, &rv); if (NS_SUCCEEDED(rv)) { - rv = ((nsDeviceContextSpecGTK *)devSpec.get())->Init(aPrintSettings, aQuiet); + rv = ((nsDeviceContextSpecGTK *)devSpec.get())->Init(aPrintSettings); if (NS_SUCCEEDED(rv)) { aNewSpec = devSpec; diff --git a/mozilla/gfx/src/gtk/nsDeviceContextSpecFactoryG.h b/mozilla/gfx/src/gtk/nsDeviceContextSpecFactoryG.h index 63262db4b78..0cd0169b860 100644 --- a/mozilla/gfx/src/gtk/nsDeviceContextSpecFactoryG.h +++ b/mozilla/gfx/src/gtk/nsDeviceContextSpecFactoryG.h @@ -53,7 +53,7 @@ public: NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget, nsIPrintSettings* aPrintSettings, nsIDeviceContextSpec *&aNewSpec, - PRBool aQuiet); + PRBool aIsPrintPreview); protected: virtual ~nsDeviceContextSpecFactoryGTK(); diff --git a/mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp b/mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp index 603ef369227..17b823f61ae 100644 --- a/mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp +++ b/mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp @@ -51,16 +51,9 @@ #include "nsIPref.h" #include "prenv.h" /* for PR_GetEnv */ -#include "nsIDOMWindowInternal.h" -#include "nsIServiceManager.h" -#include "nsIDialogParamBlock.h" -#include "nsISupportsPrimitives.h" -#include "nsIWindowWatcher.h" - -#include "nsReadableUtils.h" -#include "nsISupportsArray.h" - #include "nsPrintfCString.h" +#include "nsReadableUtils.h" +#include "nsIServiceManager.h" #ifdef USE_XPRINT #include "xprintutil.h" @@ -254,66 +247,6 @@ NS_IMPL_ISUPPORTS1(nsDeviceContextSpecGTK, #error "This should not happen" #endif -/** ------------------------------------------------------- - */ -static nsresult DisplayXPDialog(nsIPrintSettings* aPS, - const char* aChromeURL, - PRBool& aClickedOK) -{ - DO_PR_DEBUG_LOG(("nsDeviceContextSpecGTK::DisplayXPDialog()\n")); - NS_ASSERTION(aPS, "Must have a print settings!"); - - aClickedOK = PR_FALSE; - nsresult rv = NS_ERROR_FAILURE; - - // create a nsISupportsArray of the parameters - // being passed to the window - nsCOMPtr array; - NS_NewISupportsArray(getter_AddRefs(array)); - if (!array) return NS_ERROR_FAILURE; - - nsCOMPtr ps = aPS; - nsCOMPtr psSupports(do_QueryInterface(ps)); - NS_ASSERTION(psSupports, "PrintSettings must be a supports"); - array->AppendElement(psSupports); - - nsCOMPtr ioParamBlock(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1")); - if (ioParamBlock) { - ioParamBlock->SetInt(0, 0); - nsCOMPtr blkSupps(do_QueryInterface(ioParamBlock)); - NS_ASSERTION(blkSupps, "IOBlk must be a supports"); - - array->AppendElement(blkSupps); - nsCOMPtr arguments(do_QueryInterface(array)); - NS_ASSERTION(array, "array must be a supports"); - - nsCOMPtr wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); - if (wwatch) { - nsCOMPtr active; - wwatch->GetActiveWindow(getter_AddRefs(active)); - nsCOMPtr parent = do_QueryInterface(active); - - nsCOMPtr newWindow; - rv = wwatch->OpenWindow(parent, aChromeURL, - "_blank", "chrome,modal,centerscreen", array, - getter_AddRefs(newWindow)); - } - } - - if (NS_SUCCEEDED(rv)) { - PRInt32 buttonPressed = 0; - ioParamBlock->GetInt(0, &buttonPressed); - if (buttonPressed == 1) { - aClickedOK = PR_TRUE; - } else { - rv = NS_ERROR_ABORT; - } - } else { - rv = NS_ERROR_ABORT; - } - return rv; -} - /** ------------------------------------------------------- * Initialize the nsDeviceContextSpecGTK * @update dc 2/15/98 @@ -323,115 +256,94 @@ static nsresult DisplayXPDialog(nsIPrintSettings* aPS, * toolkits including: * - GTK+-toolkit: * file: mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp - * function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init(PRBool aQuiet) + * function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init() * - GTK-toolkit: * file: mozilla/gfx/src/xlib/nsDeviceContextSpecGTK.cpp - * function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init(PRBool aQuiet) + * function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init() * - Qt-toolkit: * file: mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp - * function: NS_IMETHODIMP nsDeviceContextSpecQT::Init(PRBool aQuiet) + * function: NS_IMETHODIMP nsDeviceContextSpecQT::Init() * * ** Please update the other toolkits when changing this function. */ -NS_IMETHODIMP nsDeviceContextSpecGTK::Init(nsIPrintSettings *aPS, PRBool aQuiet) +NS_IMETHODIMP nsDeviceContextSpecGTK::Init(nsIPrintSettings *aPS) { - DO_PR_DEBUG_LOG(("nsDeviceContextSpecGTK::Init(aPS=%p. qQuiet=%d)\n", aPS, (int)aQuiet)); + DO_PR_DEBUG_LOG(("nsDeviceContextSpecGTK::Init(aPS=%p)\n", aPS)); nsresult rv = NS_ERROR_FAILURE; mPrintSettings = aPS; // if there is a current selection then enable the "Selection" radio button - if (mPrintSettings) { - PRBool isOn; - mPrintSettings->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB, &isOn); - nsCOMPtr pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv); - if (NS_SUCCEEDED(rv)) { - (void) pPrefs->SetBoolPref("print.selection_radio_enabled", isOn); - } - } - - PRBool canPrint = PR_FALSE; - rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters(); if (NS_FAILED(rv)) { return rv; } - if (!aQuiet) { - rv = DisplayXPDialog(mPrintSettings, - "chrome://global/content/printdialog.xul", canPrint); - } else { - rv = NS_OK; - canPrint = PR_TRUE; - } - GlobalPrinters::GetInstance()->FreeGlobalPrinters(); - if (NS_SUCCEEDED(rv) && canPrint) { - if (aPS) { - PRBool reversed = PR_FALSE; - PRBool color = PR_FALSE; - PRBool tofile = PR_FALSE; - PRInt16 printRange = nsIPrintSettings::kRangeAllPages; - PRInt32 orientation = NS_PORTRAIT; - PRInt32 fromPage = 1; - PRInt32 toPage = 1; - PRUnichar *command = nsnull; - PRInt32 copies = 1; - PRUnichar *printer = nsnull; - PRUnichar *papername = nsnull; - PRUnichar *printfile = nsnull; - double dleft = 0.5; - double dright = 0.5; - double dtop = 0.5; - double dbottom = 0.5; + if (aPS) { + PRBool reversed = PR_FALSE; + PRBool color = PR_FALSE; + PRBool tofile = PR_FALSE; + PRInt16 printRange = nsIPrintSettings::kRangeAllPages; + PRInt32 orientation = NS_PORTRAIT; + PRInt32 fromPage = 1; + PRInt32 toPage = 1; + PRUnichar *command = nsnull; + PRInt32 copies = 1; + PRUnichar *printer = nsnull; + PRUnichar *papername = nsnull; + PRUnichar *printfile = nsnull; + double dleft = 0.5; + double dright = 0.5; + double dtop = 0.5; + double dbottom = 0.5; - aPS->GetPrinterName(&printer); - aPS->GetPrintReversed(&reversed); - aPS->GetPrintInColor(&color); - aPS->GetPaperName(&papername); - aPS->GetOrientation(&orientation); - aPS->GetPrintCommand(&command); - aPS->GetPrintRange(&printRange); - aPS->GetToFileName(&printfile); - aPS->GetPrintToFile(&tofile); - aPS->GetStartPageRange(&fromPage); - aPS->GetEndPageRange(&toPage); - aPS->GetNumCopies(&copies); - aPS->GetMarginTop(&dtop); - aPS->GetMarginLeft(&dleft); - aPS->GetMarginBottom(&dbottom); - aPS->GetMarginRight(&dright); + aPS->GetPrinterName(&printer); + aPS->GetPrintReversed(&reversed); + aPS->GetPrintInColor(&color); + aPS->GetPaperName(&papername); + aPS->GetOrientation(&orientation); + aPS->GetPrintCommand(&command); + aPS->GetPrintRange(&printRange); + aPS->GetToFileName(&printfile); + aPS->GetPrintToFile(&tofile); + aPS->GetStartPageRange(&fromPage); + aPS->GetEndPageRange(&toPage); + aPS->GetNumCopies(&copies); + aPS->GetMarginTop(&dtop); + aPS->GetMarginLeft(&dleft); + aPS->GetMarginBottom(&dbottom); + aPS->GetMarginRight(&dright); - if (printfile) - strcpy(mPath, NS_ConvertUCS2toUTF8(printfile).get()); - if (command) - strcpy(mCommand, NS_ConvertUCS2toUTF8(command).get()); - if (printer) - strcpy(mPrinter, NS_ConvertUCS2toUTF8(printer).get()); - if (papername) - strcpy(mPaperName, NS_ConvertUCS2toUTF8(papername).get()); + if (printfile) + strcpy(mPath, NS_ConvertUCS2toUTF8(printfile).get()); + if (command) + strcpy(mCommand, NS_ConvertUCS2toUTF8(command).get()); + if (printer) + strcpy(mPrinter, NS_ConvertUCS2toUTF8(printer).get()); + if (papername) + strcpy(mPaperName, NS_ConvertUCS2toUTF8(papername).get()); - DO_PR_DEBUG_LOG(("margins: %5.2f,%5.2f,%5.2f,%5.2f\n", dtop, dleft, dbottom, dright)); - DO_PR_DEBUG_LOG(("printRange %d\n", printRange)); - DO_PR_DEBUG_LOG(("fromPage %d\n", fromPage)); - DO_PR_DEBUG_LOG(("toPage %d\n", toPage)); - DO_PR_DEBUG_LOG(("tofile %d\n", tofile)); - DO_PR_DEBUG_LOG(("printfile '%s'\n", printfile? NS_ConvertUCS2toUTF8(printfile).get():"")); - DO_PR_DEBUG_LOG(("command '%s'\n", command? NS_ConvertUCS2toUTF8(command).get():"")); - DO_PR_DEBUG_LOG(("printer '%s'\n", printer? NS_ConvertUCS2toUTF8(printer).get():"")); - DO_PR_DEBUG_LOG(("papername '%s'\n", papername? NS_ConvertUCS2toUTF8(papername).get():"")); + DO_PR_DEBUG_LOG(("margins: %5.2f,%5.2f,%5.2f,%5.2f\n", dtop, dleft, dbottom, dright)); + DO_PR_DEBUG_LOG(("printRange %d\n", printRange)); + DO_PR_DEBUG_LOG(("fromPage %d\n", fromPage)); + DO_PR_DEBUG_LOG(("toPage %d\n", toPage)); + DO_PR_DEBUG_LOG(("tofile %d\n", tofile)); + DO_PR_DEBUG_LOG(("printfile '%s'\n", printfile? NS_ConvertUCS2toUTF8(printfile).get():"")); + DO_PR_DEBUG_LOG(("command '%s'\n", command? NS_ConvertUCS2toUTF8(command).get():"")); + DO_PR_DEBUG_LOG(("printer '%s'\n", printer? NS_ConvertUCS2toUTF8(printer).get():"")); + DO_PR_DEBUG_LOG(("papername '%s'\n", papername? NS_ConvertUCS2toUTF8(papername).get():"")); - mTop = dtop; - mBottom = dbottom; - mLeft = dleft; - mRight = dright; - mFpf = !reversed; - mGrayscale = !color; - mOrientation = orientation; - mToPrinter = !tofile; - mCopies = copies; - } + mTop = dtop; + mBottom = dbottom; + mLeft = dleft; + mRight = dright; + mFpf = !reversed; + mGrayscale = !color; + mOrientation = orientation; + mToPrinter = !tofile; + mCopies = copies; } return rv; @@ -993,19 +905,7 @@ NS_IMETHODIMP nsPrinterEnumeratorGTK::InitPrintSettingsFromPrinter(const PRUnich NS_IMETHODIMP nsPrinterEnumeratorGTK::DisplayPropertiesDlg(const PRUnichar *aPrinter, nsIPrintSettings *aPrintSettings) { - /* fixme: We simply ignore the |aPrinter| argument here - * We should get the supported printer attributes from the printer and - * populate the print job options dialog with these data instead of using - * the "default set" here. - * However, this requires changes on all platforms and is another big chunk - * of patches ... ;-( - */ - - PRBool pressedOK; - return DisplayXPDialog(aPrintSettings, - "chrome://global/content/printjoboptions.xul", - pressedOK); - + return NS_OK; } //---------------------------------------------------------------------- diff --git a/mozilla/gfx/src/gtk/nsDeviceContextSpecG.h b/mozilla/gfx/src/gtk/nsDeviceContextSpecG.h index 8044d537cea..03f13dd47d8 100644 --- a/mozilla/gfx/src/gtk/nsDeviceContextSpecG.h +++ b/mozilla/gfx/src/gtk/nsDeviceContextSpecG.h @@ -74,7 +74,7 @@ public: NS_DECL_ISUPPORTS - NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet); + NS_IMETHOD Init(nsIPrintSettings* aPS); NS_IMETHOD ClosePrintManager(); NS_IMETHOD GetToPrinter(PRBool &aToPrinter); diff --git a/mozilla/gfx/src/mac/Makefile.in b/mozilla/gfx/src/mac/Makefile.in index 5dc6a3b223f..98ad064d98b 100644 --- a/mozilla/gfx/src/mac/Makefile.in +++ b/mozilla/gfx/src/mac/Makefile.in @@ -35,7 +35,6 @@ REQUIRES = xpcom \ widget \ view \ util \ - dom \ pref \ js \ uconv \ @@ -43,7 +42,6 @@ REQUIRES = xpcom \ unicharutil \ gfx2 \ mozcomps \ - windowwatcher \ content \ layout \ locale \ @@ -68,6 +66,7 @@ CPPSRCS = \ nsScreenMac.cpp \ nsScreenManagerMac.cpp \ nsPrintOptionsX.cpp \ + nsPrintSettingsX.cpp \ nsFontUtils.cpp \ nsNativeThemeMac.cpp \ $(NULL) @@ -85,6 +84,7 @@ EXTRA_DSO_LDOPTS = \ include $(topsrcdir)/config/rules.mk +DEFINES += -DPM_USE_SESSION_APIS=0 CXXFLAGS += $(TK_CFLAGS) CFLAGS += $(TK_CFLAGS) diff --git a/mozilla/gfx/src/mac/nsDeviceContextMac.cpp b/mozilla/gfx/src/mac/nsDeviceContextMac.cpp index a66b16de254..5f5d5baacb4 100644 --- a/mozilla/gfx/src/mac/nsDeviceContextMac.cpp +++ b/mozilla/gfx/src/mac/nsDeviceContextMac.cpp @@ -707,7 +707,10 @@ NS_IMETHODIMP nsDeviceContextMac::GetDeviceContextFor(nsIDeviceContextSpec *aDev * See documentation in nsIDeviceContext.h * @update 12/9/98 dwc */ -NS_IMETHODIMP nsDeviceContextMac::BeginDocument(PRUnichar * aTitle) +NS_IMETHODIMP nsDeviceContextMac::BeginDocument(PRUnichar * aTitle, + PRUnichar* aPrintToFileName, + PRInt32 aStartPage, + PRInt32 aEndPage) { #if !TARGET_CARBON GrafPtr thePort; @@ -724,7 +727,7 @@ GrafPtr thePort; nsresult rv = NS_ERROR_FAILURE; nsCOMPtr printingContext = do_QueryInterface(mSpec); if (printingContext) - rv = printingContext->BeginDocument(); + rv = printingContext->BeginDocument(aStartPage, aEndPage); return rv; #endif } diff --git a/mozilla/gfx/src/mac/nsDeviceContextMac.h b/mozilla/gfx/src/mac/nsDeviceContextMac.h index 956295bad29..d17383df5c0 100644 --- a/mozilla/gfx/src/mac/nsDeviceContextMac.h +++ b/mozilla/gfx/src/mac/nsDeviceContextMac.h @@ -79,7 +79,10 @@ public: NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice, nsIDeviceContext *&aContext); - NS_IMETHOD BeginDocument(PRUnichar * aTitle); + NS_IMETHOD BeginDocument(PRUnichar * aTitle, + PRUnichar* aPrintToFileName, + PRInt32 aStartPage, + PRInt32 aEndPage); NS_IMETHOD EndDocument(void); NS_IMETHOD AbortDocument(void); diff --git a/mozilla/gfx/src/mac/nsDeviceContextSpecFactoryM.cpp b/mozilla/gfx/src/mac/nsDeviceContextSpecFactoryM.cpp index f7ad26dec43..3b7c464a743 100644 --- a/mozilla/gfx/src/mac/nsDeviceContextSpecFactoryM.cpp +++ b/mozilla/gfx/src/mac/nsDeviceContextSpecFactoryM.cpp @@ -82,7 +82,7 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryMac :: Init(void) NS_IMETHODIMP nsDeviceContextSpecFactoryMac :: CreateDeviceContextSpec(nsIWidget *aWidget, nsIPrintSettings* aPrintSettings, nsIDeviceContextSpec *&aNewSpec, - PRBool aQuiet) + PRBool aIsPrintPreview) { nsresult rv; @@ -91,7 +91,7 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryMac :: CreateDeviceContextSpec(nsIWidget if (NS_SUCCEEDED(rv)) { nsCOMPtr printingContext = do_QueryInterface(devSpec,&rv); if (NS_SUCCEEDED(rv)) { - rv = printingContext->Init(aPrintSettings,aQuiet); + rv = printingContext->Init(aPrintSettings,aIsPrintPreview); if (NS_SUCCEEDED(rv)) { aNewSpec = devSpec; NS_ADDREF(aNewSpec); diff --git a/mozilla/gfx/src/mac/nsDeviceContextSpecFactoryM.h b/mozilla/gfx/src/mac/nsDeviceContextSpecFactoryM.h index dc4049c723a..d6fd690d2b6 100644 --- a/mozilla/gfx/src/mac/nsDeviceContextSpecFactoryM.h +++ b/mozilla/gfx/src/mac/nsDeviceContextSpecFactoryM.h @@ -53,7 +53,7 @@ public: NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget, nsIPrintSettings* aPrintSettings, nsIDeviceContextSpec *&aNewSpec, - PRBool aQuiet); + PRBool aIsPrintPreview); protected: ~nsDeviceContextSpecFactoryMac(); diff --git a/mozilla/gfx/src/mac/nsDeviceContextSpecMac.cpp b/mozilla/gfx/src/mac/nsDeviceContextSpecMac.cpp index 6c053458179..13605e79587 100644 --- a/mozilla/gfx/src/mac/nsDeviceContextSpecMac.cpp +++ b/mozilla/gfx/src/mac/nsDeviceContextSpecMac.cpp @@ -37,59 +37,10 @@ * ***** END LICENSE BLOCK ***** */ #include "nsDeviceContextSpecMac.h" -#include "prmem.h" -#include "plstr.h" -#include "nsWatchTask.h" #include "nsIServiceManager.h" #include "nsIPrintOptions.h" -#include "nsGfxCIID.h" +#include "nsIPrintSettingsMac.h" -#include "nsGfxUtils.h" - -#if !TARGET_CARBON -#include "nsMacResources.h" -#include -#include -#endif - -#if !TARGET_CARBON - -enum { - ePrintSelectionCheckboxID = 1, - ePrintFrameAsIsCheckboxID, - ePrintSelectedFrameCheckboxID, - ePrintAllFramesCheckboxID, - eDrawFrameID -}; - - - -// items to support the additional items for the dialog -#define DITL_ADDITIONS 128 - -static pascal TPPrDlg MyJobDlgInit(THPrint); // Our extention to PrJobInit -static TPPrDlg gPrtJobDialog; // pointer to job dialog -static long prFirstItem; // our first item in the extended dialog -static PItemUPP prPItemProc; // store the old item handler here -static PRBool gPrintSelection; -static PItemUPP gPrtJobDialogItemProc; -static UserItemUPP gDrawListUPP = nsnull; -static nsIPrintSettings *gPrintSettings=nsnull; - - -typedef struct dialog_item_struct { - Handle handle; // handle or procedure pointer for this item */ - Rect bounds; // display rectangle for this item */ - char type; // item type - 1 */ - char data[1]; // length byte of data */ -} DialogItem, *DialogItemPtr, **DialogItemHandle; - -typedef struct append_item_list_struct { - short max_index; // number of items - 1 - DialogItem items[1]; // first item in the array -} ItemList, *ItemListPtr, **ItemListHandle; - -#endif /** ------------------------------------------------------- * Construct the nsDeviceContextSpecMac @@ -100,7 +51,6 @@ nsDeviceContextSpecMac::nsDeviceContextSpecMac() , mPrintManagerOpen(PR_FALSE) { NS_INIT_REFCNT(); - gPrintSettings = nsnull; } /** ------------------------------------------------------- @@ -115,321 +65,36 @@ nsDeviceContextSpecMac::~nsDeviceContextSpecMac() ::DisposeHandle((Handle)mPrtRec); mPrtRec = nsnull; } - } NS_IMPL_ISUPPORTS2(nsDeviceContextSpecMac, nsIDeviceContextSpec, nsIPrintingContext) -#if !TARGET_CARBON - -/** ------------------------------------------------------- - * this is a drawing procedure for the user item.. this draws a box around the frameset radio buttons - * @update dc 12/02/98 - */ -static pascal void MyBBoxDraw(WindowPtr theWindow, short aItemNo) -{ - short itemType; - Rect itemBox; - Handle itemH; - - ::GetDialogItem((DialogPtr)gPrtJobDialog, prFirstItem + eDrawFrameID-1, &itemType, &itemH, &itemBox); - - // use appearance if possible - if ((long)DrawThemeSecondaryGroup != kUnresolvedCFragSymbolAddress) - ::DrawThemeSecondaryGroup(&itemBox, kThemeStateActive); - else - ::FrameRect(&itemBox); -} - - -/** ------------------------------------------------------- - * this is the dialog hook, takes care of setting the dialog items - * @update dc 12/02/98 - */ -static pascal void MyJobItems(DialogPtr aDialog, short aItemNo) -{ -short myItem, firstItem, i, itemType; -short value; -Rect itemBox; -Handle itemH; - - firstItem = prFirstItem; - - myItem = aItemNo-firstItem+1; - if (myItem>0) { - switch (myItem) { - case ePrintSelectionCheckboxID: - ::GetDialogItem(aDialog, firstItem, &itemType, &itemH, &itemBox); - gPrintSelection = !gPrintSelection; - ::SetControlValue((ControlHandle)itemH, gPrintSelection); - break; - - case ePrintFrameAsIsCheckboxID: - case ePrintSelectedFrameCheckboxID: - case ePrintAllFramesCheckboxID: - for (i=ePrintFrameAsIsCheckboxID; i<=ePrintAllFramesCheckboxID; i++){ - ::GetDialogItem(aDialog, firstItem+i-1, &itemType, &itemH, &itemBox); - ::SetControlValue((ControlHandle)itemH, i==myItem); - } - break; - - default: - break; - } - } else { - // chain to standard Item handler - CallPItemProc(prPItemProc, aDialog, aItemNo); - - if (((TPPrDlg)aDialog)->fDone) - { - //nsCOMPtr printOptionsService = do_GetService("@mozilla.org/gfx/printoptions;1"); - // cleanup and set the print options to what we want - if (gPrintSettings) - { - // print selection - ::GetDialogItem(aDialog, firstItem+ePrintSelectionCheckboxID-1, &itemType, &itemH, &itemBox); - value = ::GetControlValue((ControlHandle)itemH); - if (1==value){ - gPrintSettings->SetPrintRange(nsIPrintSettings::kRangeSelection); - } else { - gPrintSettings->SetPrintRange(nsIPrintSettings::kRangeAllPages); - } - - // print frames as is - ::GetDialogItem(aDialog, firstItem+ePrintFrameAsIsCheckboxID-1, &itemType, &itemH, &itemBox); - value = ::GetControlValue((ControlHandle)itemH); - if (1==value){ - gPrintSettings->SetPrintFrameType(nsIPrintSettings::kFramesAsIs); - } - - // selected frame - ::GetDialogItem(aDialog, firstItem+ePrintSelectedFrameCheckboxID-1, &itemType, &itemH, &itemBox); - value = ::GetControlValue((ControlHandle)itemH); - if (1==value){ - gPrintSettings->SetPrintFrameType(nsIPrintSettings::kSelectedFrame); - } - - // print all frames - ::GetDialogItem(aDialog, firstItem+ePrintAllFramesCheckboxID-1, &itemType, &itemH, &itemBox); - value = ::GetControlValue((ControlHandle)itemH); - if (1==value){ - gPrintSettings->SetPrintFrameType(nsIPrintSettings::kEachFrameSep); - } - } - } - } -} - -/** ------------------------------------------------------- - * Append DITL items to the dialog - * @update dc 05/04/2001 - */ -static PRInt32 AppendToDialog(TPPrDlg aDialog, PRInt32 aDITLID) -{ -nsresult theResult = NS_ERROR_FAILURE; -short firstItem; -ItemListHandle myAppendDITLH; -ItemListHandle dlg_Item_List; - - dlg_Item_List = (ItemListHandle)((DialogPeek)aDialog)->items; - firstItem = (**dlg_Item_List).max_index+2; - - theResult = nsMacResources::OpenLocalResourceFile(); - if (theResult == NS_OK) { - myAppendDITLH = (ItemListHandle)::GetResource('DITL', aDITLID); - if (nsnull == myAppendDITLH) { - // some sort of error - theResult = NS_ERROR_FAILURE; - } else { - ::AppendDITL((DialogPtr)aDialog, (Handle)myAppendDITLH, appendDITLBottom); - ::ReleaseResource((Handle) myAppendDITLH); - } - theResult = nsMacResources::CloseLocalResourceFile(); - } - - return firstItem; -} - - -/** ------------------------------------------------------- - * Initialize the print dialogs additional items - * @update dc 05/04/2001 - */ -static pascal TPPrDlg MyJobDlgInit(THPrint aHPrint) -{ - PRInt32 i; - short itemType; - Handle itemH; - Rect itemBox; - PRBool isOn; - PRInt16 howToEnableFrameUI = nsIPrintSettings::kFrameEnableNone; - - prFirstItem = AppendToDialog(gPrtJobDialog, DITL_ADDITIONS); - - //nsCOMPtr printOptionsService = do_GetService("@mozilla.org/gfx/printoptions;1"); - - if (gPrintSettings) { - gPrintSettings->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB, &isOn); - gPrintSettings->GetHowToEnableFrameUI(&howToEnableFrameUI); - } - - ::GetDialogItem((DialogPtr) gPrtJobDialog, prFirstItem+ePrintSelectionCheckboxID-1, &itemType, &itemH, &itemBox); - if ( isOn ) { - ::HiliteControl((ControlHandle)itemH, 0); - } else { - ::HiliteControl((ControlHandle)itemH, 255); - } - - gPrintSelection = PR_FALSE; - ::SetControlValue((ControlHandle) itemH, gPrintSelection); - - if (howToEnableFrameUI == nsIPrintSettings::kFrameEnableAll) { - for (i = ePrintFrameAsIsCheckboxID; i <= ePrintAllFramesCheckboxID; i++){ - ::GetDialogItem((DialogPtr) gPrtJobDialog, prFirstItem+i-1, &itemType, &itemH, &itemBox); - ::SetControlValue((ControlHandle) itemH, (i==4)); - ::HiliteControl((ControlHandle)itemH, 0); - } - } - else if (howToEnableFrameUI == nsIPrintSettings::kFrameEnableAsIsAndEach) { - for (i = ePrintFrameAsIsCheckboxID; i <= ePrintAllFramesCheckboxID; i++){ - ::GetDialogItem((DialogPtr) gPrtJobDialog, prFirstItem+i-1, &itemType, &itemH, &itemBox); - ::SetControlValue((ControlHandle) itemH, (i==4)); - if ( i == 3){ - ::HiliteControl((ControlHandle)itemH, 255); - } - } - } - else { - for (i = ePrintFrameAsIsCheckboxID; i <= ePrintAllFramesCheckboxID; i++){ - ::GetDialogItem((DialogPtr) gPrtJobDialog, prFirstItem+i-1, &itemType, &itemH, &itemBox); - ::SetControlValue((ControlHandle) itemH, FALSE); - ::HiliteControl((ControlHandle)itemH, 255); - } - } - - // attach our handler - prPItemProc = gPrtJobDialog->pItemProc; - gPrtJobDialog->pItemProc = gPrtJobDialogItemProc = NewPItemUPP(MyJobItems); - - - // attach a draw routine - gDrawListUPP = NewUserItemProc(MyBBoxDraw); - ::GetDialogItem((DialogPtr)gPrtJobDialog, prFirstItem+eDrawFrameID-1, &itemType, &itemH, &itemBox); - ::SetDialogItem((DialogPtr)gPrtJobDialog, prFirstItem+eDrawFrameID-1, itemType, (Handle)gDrawListUPP, &itemBox); - - return gPrtJobDialog; -} - -#endif - - /** ------------------------------------------------------- * Initialize the nsDeviceContextSpecMac * @update dc 05/04/2001 */ -NS_IMETHODIMP nsDeviceContextSpecMac::Init(nsIPrintSettings* aPS, PRBool aQuiet) +NS_IMETHODIMP nsDeviceContextSpecMac::Init(nsIPrintSettings* aPS, PRBool aIsPrintPreview) { - gPrintSettings = aPS; - -#if !TARGET_CARBON - - if (aQuiet) - { - // If aQuiet is true, then we're being called through - // the print preview path, so don't put up the print dialog. - return NS_ERROR_ABORT; + nsCOMPtr printSettingsMac(do_QueryInterface(aPS)); + if (!printSettingsMac) + return NS_ERROR_NO_INTERFACE; + + // open the printing manager if not print preview + if (!aIsPrintPreview) { + ::PrOpen(); + if (::PrError() != noErr) + return NS_ERROR_FAILURE; + mPrintManagerOpen = PR_TRUE; } - THPrint hPrintRec; // handle to print record - GrafPtr oldport; - PDlgInitUPP theInitProcPtr; - - ::GetPort(&oldport); - - nsresult rv; - nsCOMPtr printOptionsService = do_GetService("@mozilla.org/gfx/printoptions;1", &rv); - if (NS_FAILED(rv)) return rv; - - // open the printing manager - ::PrOpen(); - if (::PrError() != noErr) - return NS_ERROR_FAILURE; - - mPrintManagerOpen = PR_TRUE; - - // Allocate a print record - hPrintRec = (THPrint)::NewHandleClear(sizeof(TPrint)); - if (!hPrintRec) return NS_ERROR_OUT_OF_MEMORY; - - StHandleOwner printRecOwner((Handle)hPrintRec); - - // see if we have a print record - void* printRecordData = nsnull; - rv = printOptionsService->GetNativeData(nsIPrintOptions::kNativeDataPrintRecord, &printRecordData); - if (NS_SUCCEEDED(rv) && printRecordData) - { - ::BlockMoveData(printRecordData, *hPrintRec, sizeof(TPrint)); - } - else - { - // fill in default values - ::PrintDefault(hPrintRec); - } - - if (printRecordData) - { - nsMemory::Free(printRecordData); - printRecordData = nsnull; - } - + nsresult rv = printSettingsMac->GetTHPrint(&mPrtRec); + // make sure the print record is valid - ::PrValidate(hPrintRec); + ::PrValidate(mPrtRec); if (::PrError() != noErr) return NS_ERROR_FAILURE; - - // get pointer to invisible job dialog box - gPrtJobDialog = ::PrJobInit(hPrintRec); - if (::PrError() != noErr) - return NS_ERROR_FAILURE; - // create a UUP for the dialog init procedure - theInitProcPtr = NewPDlgInitProc(MyJobDlgInit); - if (!theInitProcPtr) - return NS_ERROR_FAILURE; - - // standard print dialog, if true print - nsWatchTask::GetTask().Suspend(); - ::InitCursor(); - - // put up the print dialog - if (::PrDlgMain(hPrintRec, theInitProcPtr)) - { - // have the print record - rv = NS_OK; - printRecOwner.ClearHandle(false); - mPrtRec = hPrintRec; - } - else - { - // don't print - ::SetPort(oldport); - rv = NS_ERROR_ABORT; - } - - // clean up our dialog routines - DisposePItemUPP(gPrtJobDialogItemProc); - gPrtJobDialogItemProc = nsnull; - - DisposePItemUPP(theInitProcPtr); - DisposePItemUPP(gDrawListUPP); - gDrawListUPP = nsnull; - - nsWatchTask::GetTask().Resume(); - return rv; - -#endif /* TARGET_CARBON */ - - return NS_ERROR_FAILURE; + return NS_OK; } /** ------------------------------------------------------- @@ -438,18 +103,14 @@ NS_IMETHODIMP nsDeviceContextSpecMac::Init(nsIPrintSettings* aPS, PRBool aQuiet) */ NS_IMETHODIMP nsDeviceContextSpecMac::ClosePrintManager() { - PRBool isPMOpen; - PrintManagerOpen(&isPMOpen); - if (isPMOpen) { -#if !TARGET_CARBON + if (mPrintManagerOpen) ::PrClose(); -#endif - } return NS_OK; } -NS_IMETHODIMP nsDeviceContextSpecMac::BeginDocument() +NS_IMETHODIMP nsDeviceContextSpecMac::BeginDocument(PRInt32 aStartPage, + PRInt32 aEndPage) { nsresult rv = NS_OK; return rv; diff --git a/mozilla/gfx/src/mac/nsDeviceContextSpecMac.h b/mozilla/gfx/src/mac/nsDeviceContextSpecMac.h index 27a194cf024..5dfc4c28978 100644 --- a/mozilla/gfx/src/mac/nsDeviceContextSpecMac.h +++ b/mozilla/gfx/src/mac/nsDeviceContextSpecMac.h @@ -58,14 +58,10 @@ public: /** * Initialize the nsDeviceContextSpecMac for use. This will allocate a printrecord for use * @update dc 12/02/98 - * @param aQuiet if PR_TRUE, prevent the need for user intervention - * in obtaining device context spec. if nsnull is passed in for - * the aOldSpec, this will typically result in getting a device - * context spec for the default output device (i.e. default - * printer). + * @param aIsPrintPreview TRUE if doing print preview, FALSE if normal printing. * @return error status */ - NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet); + NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aIsPrintPreview); /** @@ -83,7 +79,8 @@ public: */ NS_IMETHOD ClosePrintManager(); - NS_IMETHOD BeginDocument(); + NS_IMETHOD BeginDocument(PRInt32 aStartPage, + PRInt32 aEndPage); NS_IMETHOD EndDocument(); diff --git a/mozilla/gfx/src/mac/nsDeviceContextSpecX.cpp b/mozilla/gfx/src/mac/nsDeviceContextSpecX.cpp index 8ed4b04f1b1..2de8f70bf9e 100644 --- a/mozilla/gfx/src/mac/nsDeviceContextSpecX.cpp +++ b/mozilla/gfx/src/mac/nsDeviceContextSpecX.cpp @@ -22,6 +22,7 @@ * Contributor(s): * Patrick C. Beard * Simon Fraser + * Conrad Carlen * * * Alternatively, the contents of this file may be used under the terms of @@ -46,18 +47,7 @@ #include "nsIServiceManager.h" #include "nsIPrintOptions.h" - - -#include "CoreServices.h" -#include "nsFileSpec.h" -#include "nsPDECommon.h" -#include "nsAppDirectoryServiceDefs.h" -#include "nsDirectoryServiceDefs.h" -#include "nsDirectoryService.h" - -static Boolean LoadPrinterPlugin(); - -static Boolean gPlugInNotLoaded = true; +#include "nsIPrintSettingsX.h" /** ------------------------------------------------------- * Construct the nsDeviceContextSpecX @@ -88,130 +78,29 @@ NS_IMPL_ISUPPORTS2(nsDeviceContextSpecX, nsIDeviceContextSpec, nsIPrintingContex * Initialize the nsDeviceContextSpecMac * @update dc 12/02/98 */ -NS_IMETHODIMP nsDeviceContextSpecX::Init(nsIPrintSettings* aPS, PRBool aQuiet) +NS_IMETHODIMP nsDeviceContextSpecX::Init(nsIPrintSettings* aPS, PRBool aIsPrintPreview) { nsresult rv; OSStatus status; - - nsCOMPtr printOptionsService = do_GetService("@mozilla.org/gfx/printoptions;1", &rv); - if (NS_FAILED(rv)) return rv; - - // are we doing a printpreview.. then don't start setting up for the printing - PRBool doingPrintPreview; - - aPS->GetIsPrintPreview(&doingPrintPreview); - - // Because page setup can get called at any time, we can't use the session APIs here. - if(!doingPrintPreview) { - status = ::PMBegin(); - if (status != noErr) return NS_ERROR_FAILURE; - } - - mBeganPrinting = PR_TRUE; - PMPageFormat optionsPageFormat = kPMNoPageFormat; - rv = printOptionsService->GetNativeData(nsIPrintOptions::kNativeDataPrintRecord, (void **)&optionsPageFormat); - if (NS_FAILED(rv)) return rv; - - status = ::PMNewPageFormat(&mPageFormat); - if (status != noErr) return NS_ERROR_FAILURE; - - if (optionsPageFormat != kPMNoPageFormat) - { - status = ::PMCopyPageFormat(optionsPageFormat, mPageFormat); - ::PMDisposePageFormat(optionsPageFormat); - } - else - status = ::PMDefaultPageFormat(mPageFormat); - - if (status != noErr) return NS_ERROR_FAILURE; - - Boolean validated; - ::PMValidatePageFormat(mPageFormat, &validated); - - status = ::PMNewPrintSettings(&mPrintSettings); - if (status != noErr) return NS_ERROR_FAILURE; - - status = ::PMDefaultPrintSettings(mPrintSettings); - if (status != noErr) return NS_ERROR_FAILURE; - - if (! aQuiet) { - Boolean plugInExtended,accepted=false; - PRBool isOn; - PRInt16 howToEnableFrameUI = nsIPrintSettings::kFrameEnableNone; - nsPrintExtensions printData = {false,false,false,false,false,false,false,false}; - - ::InitCursor(); - - // set the values for the plugin here - aPS->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB, &isOn); - printData.mHaveSelection = (Boolean) isOn; - - aPS->GetHowToEnableFrameUI(&howToEnableFrameUI); - if (howToEnableFrameUI == nsIPrintSettings::kFrameEnableAll) { - printData.mHaveFrames = true; - printData.mHaveFrameSelected = true; - } - - if (howToEnableFrameUI == nsIPrintSettings::kFrameEnableAsIsAndEach) { - printData.mHaveFrames = true; - printData.mHaveFrameSelected = false; - } - - aPS->GetShrinkToFit(&isOn); - printData.mShrinkToFit = isOn; - - if( gPlugInNotLoaded ) { - plugInExtended = LoadPrinterPlugin(); - } - - status = PMSetPrintSettingsExtendedData(mPrintSettings,kPDE_Creator,sizeof(printData),&printData); - - status = ::PMPrintDialog(mPrintSettings, mPageFormat, &accepted); - - if (! accepted) - return NS_ERROR_ABORT; - + if (!aIsPrintPreview) { + status = ::PMBegin(); if (status != noErr) return NS_ERROR_FAILURE; - - - // get the data from the plugin - if(status == noErr){ - UInt32 bytesNeeded; - - status = PMGetPrintSettingsExtendedData(mPrintSettings, kPDE_Creator, &bytesNeeded, NULL); - - if(status == noErr && bytesNeeded == sizeof(printData) ){ - status = PMGetPrintSettingsExtendedData(mPrintSettings, kPDE_Creator,&bytesNeeded, &printData); - - // set the correct data fields - if( printData.mPrintSelection){ - aPS->SetPrintRange(nsIPrintSettings::kRangeSelection); - } else { - aPS->SetPrintRange(nsIPrintSettings::kRangeAllPages); - } - - if(printData.mPrintFrameAsIs){ - aPS->SetPrintFrameType(nsIPrintSettings::kFramesAsIs); - } - - if(printData.mPrintSelectedFrame){ - aPS->SetPrintFrameType(nsIPrintSettings::kSelectedFrame); - } - - if(printData.mPrintFramesSeperatly){ - aPS->SetPrintFrameType(nsIPrintSettings::kEachFrameSep); - } - - if(printData.mShrinkToFit){ - aPS->SetShrinkToFit(PR_TRUE); - } else { - aPS->SetShrinkToFit(PR_FALSE); - } - } - } + mBeganPrinting = PR_TRUE; } + + nsCOMPtr printSettingsX(do_QueryInterface(aPS)); + if (!printSettingsX) + return NS_ERROR_NO_INTERFACE; + + rv = printSettingsX->GetPMPageFormat(&mPageFormat); + if (NS_FAILED(rv)) + return rv; + rv = printSettingsX->GetPMPrintSettings(&mPrintSettings); + if (NS_FAILED(rv)) + return rv; + return NS_OK; } @@ -239,9 +128,17 @@ NS_IMETHODIMP nsDeviceContextSpecX::ClosePrintManager() return NS_OK; } -NS_IMETHODIMP nsDeviceContextSpecX::BeginDocument() +NS_IMETHODIMP nsDeviceContextSpecX::BeginDocument(PRInt32 aStartPage, + PRInt32 aEndPage) { - OSStatus status = ::PMBeginDocument(mPrintSettings, mPageFormat, &mPrintingContext); + OSStatus status; + + status = ::PMSetFirstPage(mPrintSettings, aStartPage, false); + NS_ASSERTION(status == noErr, "PMSetFirstPage failed"); + status = ::PMSetLastPage(mPrintSettings, aEndPage, false); + NS_ASSERTION(status == noErr, "PMSetLastPage failed"); + + status = ::PMBeginDocument(mPrintSettings, mPageFormat, &mPrintingContext); if (status != noErr) return NS_ERROR_ABORT; return NS_OK; @@ -303,55 +200,3 @@ NS_IMETHODIMP nsDeviceContextSpecX::GetPageRect(double* aTop, double* aLeft, dou *aBottom = pageRect.bottom, *aRight = pageRect.right; return NS_OK; } - - - -Boolean -LoadPrinterPlugin() -{ -Boolean result=false; -FSSpec spec; - -#ifndef XP_MACOSX - // get the relative path for the essential files folder.. then load the printer plugin - nsCOMPtr mozFile; - nsCOMPtr directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID)); - if (!directoryService) { - return false; - } else { - directoryService->Get( NS_XPCOM_CURRENT_PROCESS_DIR,NS_GET_IID(nsIFile), getter_AddRefs(mozFile)); - if (!mozFile) { - return false; - } - - mozFile->Append(NS_LITERAL_CSTRING("Essential Files")); - mozFile->Append(NS_LITERAL_CSTRING("PrintDialogPDE.plugin")); - nsCOMPtr mozMacFile(do_QueryInterface(mozFile)); - mozMacFile->GetFSSpec(&spec); - - - FSRef ref; - OSErr err = FSpMakeFSRef(&spec,&ref); - char path[512]; - - err = FSRefMakePath(&ref,(UInt8*)path,sizeof(path)-1); - - if(err == noErr){ - CFStringRef pathRef = CFStringCreateWithCString(NULL,path,kCFStringEncodingUTF8); - if(pathRef) { - CFURLRef url = CFURLCreateWithFileSystemPath(NULL,pathRef,kCFURLPOSIXPathStyle,TRUE); - if(url !=NULL){ - CFPlugInRef plugin = ::CFPlugInCreate(NULL,url); - if(plugin){ - result = true; - gPlugInNotLoaded = false; - } - } - } - } - - } -#endif - return result; -} - diff --git a/mozilla/gfx/src/mac/nsDeviceContextSpecX.h b/mozilla/gfx/src/mac/nsDeviceContextSpecX.h index 762596b22b2..3d63bcfff22 100644 --- a/mozilla/gfx/src/mac/nsDeviceContextSpecX.h +++ b/mozilla/gfx/src/mac/nsDeviceContextSpecX.h @@ -60,14 +60,10 @@ public: /** * Initialize the nsDeviceContextSpecMac for use. This will allocate a printrecord for use * @update dc 12/02/98 - * @param aQuiet if PR_TRUE, prevent the need for user intervention - * in obtaining device context spec. if nsnull is passed in for - * the aOldSpec, this will typically result in getting a device - * context spec for the default output device (i.e. default - * printer). + * @param aIsPrintPreview TRUE if doing print preview, FALSE if normal printing. * @return error status */ - NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet); + NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aIsPrintPreview); /** * This will tell if the printmanager is currently open @@ -84,7 +80,8 @@ public: */ NS_IMETHOD ClosePrintManager(); - NS_IMETHOD BeginDocument(); + NS_IMETHOD BeginDocument(PRInt32 aStartPage, + PRInt32 aEndPage); NS_IMETHOD EndDocument(); diff --git a/mozilla/gfx/src/mac/nsPrintOptionsMac.cpp b/mozilla/gfx/src/mac/nsPrintOptionsMac.cpp index 617f9bbe2d3..cfc07e5cc16 100644 --- a/mozilla/gfx/src/mac/nsPrintOptionsMac.cpp +++ b/mozilla/gfx/src/mac/nsPrintOptionsMac.cpp @@ -36,42 +36,17 @@ * * ***** END LICENSE BLOCK ***** */ -#include "nsCOMPtr.h" -#include "nsIPref.h" -#include "nsIServiceManager.h" - -#include "nsWatchTask.h" #include "nsPrintOptionsMac.h" -#include "nsGfxUtils.h" - -#include "plbase64.h" -#include "prmem.h" +#include "nsPrintSettingsMac.h" #define MAC_OS_PAGE_SETUP_PREFNAME "print.macos.pagesetup" /** --------------------------------------------------- - * See documentation in nsPrintOptionsWin.h + * See documentation in nsPrintOptionsMac.h * @update 6/21/00 dwc */ nsPrintOptionsMac::nsPrintOptionsMac() { - // create the print style and print record - mPrintRecord = (THPrint)::NewHandleClear(sizeof(TPrint)); - if (mPrintRecord) - { - nsresult rv = ReadPageSetupFromPrefs(); - ::PrOpen(); - if (::PrError() == noErr) - { - if (NS_FAILED(rv)) - ::PrintDefault(mPrintRecord); - else - ::PrValidate(mPrintRecord); - - ::PrClose(); - } - } - } /** --------------------------------------------------- @@ -80,10 +55,23 @@ nsPrintOptionsMac::nsPrintOptionsMac() */ nsPrintOptionsMac::~nsPrintOptionsMac() { - // get rid of the print record - if (mPrintRecord) { - ::DisposeHandle((Handle)mPrintRecord); - } +} + +/** --------------------------------------------------- + * See documentation in nsPrintOptionsImpl.h + */ +/* nsIPrintSettings CreatePrintSettings (); */ +NS_IMETHODIMP nsPrintOptionsMac::CreatePrintSettings(nsIPrintSettings **_retval) +{ + nsresult rv; + nsPrintSettingsMac* printSettings = new nsPrintSettingsMac(); // does not initially ref count + if (!printSettings) + return NS_ERROR_OUT_OF_MEMORY; + rv = printSettings->Init(); + if (NS_FAILED(rv)) + return rv; + + return printSettings->QueryInterface(NS_GET_IID(nsIPrintSettings), (void**)_retval); // ref counts } /** --------------------------------------------------- @@ -93,121 +81,51 @@ nsPrintOptionsMac::~nsPrintOptionsMac() NS_IMETHODIMP nsPrintOptionsMac::ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings) { - - if (!mPrintRecord) return NS_ERROR_NOT_INITIALIZED; - - // it doesn't really matter if this fails - nsresult rv = ReadPageSetupFromPrefs(); - NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to write page setup to prefs"); - - // open the printing manager - ::PrOpen(); - if(::PrError() != noErr) - return NS_ERROR_FAILURE; - - ::PrValidate(mPrintRecord); - NS_ASSERTION(::PrError() == noErr, "Printing error"); - - nsWatchTask::GetTask().Suspend(); - ::InitCursor(); - Boolean dialogOK = ::PrStlDialog(mPrintRecord); // open up and process the style record - nsWatchTask::GetTask().Resume(); - - OSErr err = ::PrError(); - - ::PrClose(); - - // it doesn't really matter if this fails - rv = WritePageSetupToPrefs(); - NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to save page setup to prefs"); - - if (err != noErr) - return NS_ERROR_FAILURE; - - return NS_OK; + return NS_ERROR_NOT_IMPLEMENTED; } /* [noscript] voidPtr GetNativeData (in short aDataType); */ NS_IMETHODIMP nsPrintOptionsMac::GetNativeData(PRInt16 aDataType, void * *_retval) { - nsresult rv = NS_OK; - NS_ENSURE_ARG_POINTER(_retval); *_retval = nsnull; - switch (aDataType) - { - case kNativeDataPrintRecord: - if (mPrintRecord) - { - void* printRecord = nsMemory::Alloc(sizeof(TPrint)); - if (!printRecord) { - rv = NS_ERROR_OUT_OF_MEMORY; - break; - } - - ::BlockMoveData(*mPrintRecord, printRecord, sizeof(TPrint)); - *_retval = printRecord; - } - break; - - default: - rv = NS_ERROR_FAILURE; - break; - } - - return rv; + return NS_ERROR_NOT_IMPLEMENTED; } #pragma mark - nsresult -nsPrintOptionsMac::ReadPageSetupFromPrefs() +nsPrintOptionsMac::ReadPrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags) { nsresult rv; - nsCOMPtr prefs = do_GetService(NS_PREF_CONTRACTID, &rv); - if (NS_FAILED(rv)) - return rv; - - nsXPIDLCString encodedData; - rv = prefs->GetCharPref(MAC_OS_PAGE_SETUP_PREFNAME, getter_Copies(encodedData)); - if (NS_FAILED(rv)) - return rv; - - // decode the base64 - PRInt32 encodedDataLen = nsCRT::strlen(encodedData.get()); - char* decodedData = ::PL_Base64Decode(encodedData.get(), encodedDataLen, nsnull); - if (!decodedData) - return NS_ERROR_FAILURE; - - if (((encodedDataLen * 3) / 4) >= sizeof(TPrint)) - ::BlockMoveData(decodedData, *mPrintRecord, sizeof(TPrint)); - else - rv = NS_ERROR_FAILURE; // the data was too small - - PR_Free(decodedData); - return rv; + + rv = nsPrintOptions::ReadPrefs(aPS, aPrefName, aFlags); + NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::ReadPrefs() failed"); + + nsCOMPtr printSettingsMac(do_QueryInterface(aPS)); + if (!printSettingsMac) + return NS_ERROR_NO_INTERFACE; + rv = printSettingsMac->ReadPageSetupFromPrefs(); + NS_ASSERTION(NS_SUCCEEDED(rv), "nsIPrintSettingsMac::ReadPageFormatFromPrefs() failed"); + + return NS_OK; } nsresult -nsPrintOptionsMac::WritePageSetupToPrefs() +nsPrintOptionsMac::WritePrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags) { - if (!mPrintRecord) - return NS_ERROR_NOT_INITIALIZED; - nsresult rv; - nsCOMPtr prefs = do_GetService(NS_PREF_CONTRACTID, &rv); - if (NS_FAILED(rv)) - return rv; - - StHandleLocker locker((Handle)mPrintRecord); - - nsXPIDLCString encodedData; - encodedData.Adopt(::PL_Base64Encode((char *)*mPrintRecord, sizeof(TPrint), nsnull)); - if (!encodedData.get()) - return NS_ERROR_OUT_OF_MEMORY; - - return prefs->SetCharPref(MAC_OS_PAGE_SETUP_PREFNAME, encodedData); + + rv = nsPrintOptions::WritePrefs(aPS, aPrefName, aFlags); + NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::WritePrefs() failed"); + + nsCOMPtr printSettingsMac(do_QueryInterface(aPS)); + if (!printSettingsMac) + return NS_ERROR_NO_INTERFACE; + rv = printSettingsMac->WritePageSetupToPrefs(); + NS_ASSERTION(NS_SUCCEEDED(rv), "nsIPrintSettingsX::WritePageFormatToPrefs() failed"); + + return NS_OK; } - diff --git a/mozilla/gfx/src/mac/nsPrintOptionsMac.h b/mozilla/gfx/src/mac/nsPrintOptionsMac.h index 278db17c529..7b3a4e373f1 100644 --- a/mozilla/gfx/src/mac/nsPrintOptionsMac.h +++ b/mozilla/gfx/src/mac/nsPrintOptionsMac.h @@ -39,19 +39,13 @@ public: virtual ~nsPrintOptionsMac(); NS_IMETHOD ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings); + NS_IMETHOD GetNativeData(PRInt16 aDataType, void * *_retval); + NS_IMETHOD CreatePrintSettings(nsIPrintSettings **_retval); protected: - - nsresult ReadPageSetupFromPrefs(); - nsresult WritePageSetupToPrefs(); - - THPrint GetPrintRecord(void) { return mPrintRecord; } - -protected: - - THPrint mPrintRecord; - + nsresult ReadPrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags); + nsresult WritePrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags); }; #endif /* TARGET_CARBON */ diff --git a/mozilla/gfx/src/mac/nsPrintOptionsX.cpp b/mozilla/gfx/src/mac/nsPrintOptionsX.cpp index 098253c5ca9..2dbfd672846 100644 --- a/mozilla/gfx/src/mac/nsPrintOptionsX.cpp +++ b/mozilla/gfx/src/mac/nsPrintOptionsX.cpp @@ -43,6 +43,7 @@ #include "nsIServiceManager.h" #include "nsWatchTask.h" #include "nsPrintOptionsX.h" +#include "nsPrintSettingsX.h" #include "nsIPref.h" #include "nsGfxUtils.h" @@ -50,37 +51,32 @@ #include "prmem.h" -#define MAC_OS_X_PAGE_SETUP_PREFNAME "print.macosx.pagesetup" - /** --------------------------------------------------- */ nsPrintOptionsX::nsPrintOptionsX() -: mPageFormat(kPMNoPageFormat) { - OSStatus status = ::PMNewPageFormat(&mPageFormat); - NS_ASSERTION(status == noErr, "Error creating print settings"); - - status = ::PMBegin(); - NS_ASSERTION(status == noErr, "Error from PMBegin()"); - - nsresult rv = ReadPageSetupFromPrefs(); - if (NS_FAILED(rv)) - ::PMDefaultPageFormat(mPageFormat); - else - { - Boolean valid; - ::PMValidatePageFormat(mPageFormat, &valid); - } - - ::PMEnd(); } /** --------------------------------------------------- */ nsPrintOptionsX::~nsPrintOptionsX() { - if (mPageFormat) - ::PMDisposePageFormat(mPageFormat); +} + +/** --------------------------------------------------- + * See documentation in nsPrintOptionsImpl.h + */ +/* nsIPrintSettings CreatePrintSettings (); */ +NS_IMETHODIMP nsPrintOptionsX::CreatePrintSettings(nsIPrintSettings **_retval) +{ + nsresult rv; + nsPrintSettingsX* printSettings = new nsPrintSettingsX; // does not initially ref count + if (!printSettings) + return NS_ERROR_OUT_OF_MEMORY; + rv = printSettings->Init(); + if (NS_FAILED(rv)) + return rv; + return printSettings->QueryInterface(NS_GET_IID(nsIPrintSettings), (void**)_retval); // ref counts } /** --------------------------------------------------- @@ -88,144 +84,51 @@ nsPrintOptionsX::~nsPrintOptionsX() NS_IMETHODIMP nsPrintOptionsX::ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings) { - - // it doesn't really matter if this fails - nsresult rv = ReadPageSetupFromPrefs(); - NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to write page setup to prefs"); - - NS_ASSERTION(mPageFormat != kPMNoPageFormat, "No page format"); - if (mPageFormat == kPMNoPageFormat) - return NS_ERROR_NOT_INITIALIZED; - - OSStatus status = ::PMBegin(); - if (status != noErr) return NS_ERROR_FAILURE; - - Boolean validated; - ::PMValidatePageFormat(mPageFormat, &validated); - - ::InitCursor(); - - Boolean accepted = false; - status = ::PMPageSetupDialog(mPageFormat, &accepted); - - ::PMEnd(); - - // it doesn't really matter if this fails - rv = WritePageSetupToPrefs(); - NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to save page setup to prefs"); - - if (status != noErr) - return NS_ERROR_FAILURE; - - if (!accepted) - return NS_ERROR_ABORT; - - return NS_OK; + return NS_ERROR_NOT_IMPLEMENTED; } /* [noscript] voidPtr GetNativeData (in short aDataType); */ NS_IMETHODIMP nsPrintOptionsX::GetNativeData(PRInt16 aDataType, void * *_retval) { - nsresult rv = NS_OK; - NS_ENSURE_ARG_POINTER(_retval); *_retval = nsnull; - - switch (aDataType) - { - case kNativeDataPrintRecord: - { - // we need to clone and pass out - PMPageFormat pageFormat = kPMNoPageFormat; - OSStatus status = ::PMNewPageFormat(&pageFormat); - if (status != noErr) return NS_ERROR_FAILURE; - - status = ::PMCopyPageFormat(mPageFormat, pageFormat); - if (status != noErr) { - ::PMDisposePageFormat(pageFormat); - return NS_ERROR_FAILURE; - } - - *_retval = pageFormat; - } - break; - - default: - rv = NS_ERROR_FAILURE; - break; - } - return rv; + return NS_ERROR_NOT_IMPLEMENTED; } - #pragma mark - nsresult -nsPrintOptionsX::ReadPageSetupFromPrefs() +nsPrintOptionsX::ReadPrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags) { nsresult rv; - nsCOMPtr prefs = do_GetService(NS_PREF_CONTRACTID, &rv); - if (NS_FAILED(rv)) - return rv; - - nsXPIDLCString encodedData; - rv = prefs->GetCharPref(MAC_OS_X_PAGE_SETUP_PREFNAME, getter_Copies(encodedData)); - if (NS_FAILED(rv)) - return rv; - - // decode the base64 - PRInt32 encodedDataLen = nsCRT::strlen(encodedData.get()); - char* decodedData = ::PL_Base64Decode(encodedData.get(), encodedDataLen, nsnull); - if (!decodedData) - return NS_ERROR_FAILURE; - - Handle decodedDataHandle = nsnull; - OSErr err = ::PtrToHand(decodedData, &decodedDataHandle, (encodedDataLen * 3) / 4); - PR_Free(decodedData); - if (err != noErr) - return NS_ERROR_OUT_OF_MEMORY; - - StHandleOwner handleOwner(decodedDataHandle); - - PMPageFormat newPageFormat = kPMNoPageFormat; - OSStatus status = ::PMUnflattenPageFormat(decodedDataHandle, &newPageFormat); - if (status != noErr) - return NS_ERROR_FAILURE; - - status = ::PMCopyPageFormat(newPageFormat, mPageFormat); - ::PMDisposePageFormat(newPageFormat); - newPageFormat = kPMNoPageFormat; - - return (status == noErr) ? NS_OK : NS_ERROR_FAILURE; + + rv = nsPrintOptions::ReadPrefs(aPS, aPrefName, aFlags); + NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::ReadPrefs() failed"); + + nsCOMPtr printSettingsX(do_QueryInterface(aPS)); + if (!printSettingsX) + return NS_ERROR_NO_INTERFACE; + rv = printSettingsX->ReadPageFormatFromPrefs(); + NS_ASSERTION(NS_SUCCEEDED(rv), "nsIPrintSettingsX::ReadPageFormatFromPrefs() failed"); + + return NS_OK; } nsresult -nsPrintOptionsX::WritePageSetupToPrefs() +nsPrintOptionsX::WritePrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags) { - if (mPageFormat == kPMNoPageFormat) - return NS_ERROR_NOT_INITIALIZED; - nsresult rv; - nsCOMPtr prefs = do_GetService(NS_PREF_CONTRACTID, &rv); - if (NS_FAILED(rv)) - return rv; - - Handle pageFormatHandle = nsnull; - OSStatus err = ::PMFlattenPageFormat(mPageFormat, &pageFormatHandle); - if (err != noErr) - return NS_ERROR_FAILURE; - - StHandleOwner handleOwner(pageFormatHandle); - StHandleLocker handleLocker(pageFormatHandle); - nsXPIDLCString encodedData; - encodedData.Adopt(::PL_Base64Encode(*pageFormatHandle, ::GetHandleSize(pageFormatHandle), nsnull)); - if (!encodedData.get()) - return NS_ERROR_OUT_OF_MEMORY; - - return prefs->SetCharPref(MAC_OS_X_PAGE_SETUP_PREFNAME, encodedData); + rv = nsPrintOptions::WritePrefs(aPS, aPrefName, aFlags); + NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::WritePrefs() failed"); + + nsCOMPtr printSettingsX(do_QueryInterface(aPS)); + if (!printSettingsX) + return NS_ERROR_NO_INTERFACE; + rv = printSettingsX->WritePageFormatToPrefs(); + NS_ASSERTION(NS_SUCCEEDED(rv), "nsIPrintSettingsX::WritePageFormatToPrefs() failed"); + + return NS_OK; } - - diff --git a/mozilla/gfx/src/mac/nsPrintOptionsX.h b/mozilla/gfx/src/mac/nsPrintOptionsX.h index c28cb548cb6..aadce21db60 100644 --- a/mozilla/gfx/src/mac/nsPrintOptionsX.h +++ b/mozilla/gfx/src/mac/nsPrintOptionsX.h @@ -39,10 +39,7 @@ #ifndef nsPrintOptionsX_h__ #define nsPrintOptionsX_h__ -#include - -#include "nsPrintOptionsImpl.h" - +#include "nsPrintOptionsImpl.h" //***************************************************************************** @@ -59,15 +56,12 @@ public: NS_IMETHOD GetNativeData(PRInt16 aDataType, void * *_retval); + NS_IMETHOD CreatePrintSettings(nsIPrintSettings **_retval); + protected: - nsresult ReadPageSetupFromPrefs(); - nsresult WritePageSetupToPrefs(); - -protected: - - PMPageFormat mPageFormat; // persist this between runs - + nsresult ReadPrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags); + nsresult WritePrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags); }; diff --git a/mozilla/gfx/src/nsPrintOptionsImpl.cpp b/mozilla/gfx/src/nsPrintOptionsImpl.cpp index 9de0b0e18bb..1f05522f677 100644 --- a/mozilla/gfx/src/nsPrintOptionsImpl.cpp +++ b/mozilla/gfx/src/nsPrintOptionsImpl.cpp @@ -112,9 +112,7 @@ nsFont* nsPrintOptions::sDefaultFont = nsnull; * See documentation in nsPrintOptionsImpl.h * @update 6/21/00 dwc */ -nsPrintOptions::nsPrintOptions() : - mIsCancelled(PR_FALSE), - mPrintToFile(PR_FALSE) +nsPrintOptions::nsPrintOptions() { NS_INIT_ISUPPORTS(); @@ -354,8 +352,11 @@ static void GetAdjustedPrinterName(nsIPrintSettings* aPS, PRBool aUsePNP, nsStri if (prtName) { aPrinterName = prtName; PRUnichar uc = '_'; - PRUnichar space = ' '; - aPrinterName.ReplaceChar(space, uc); + const char* replaceStr = " \n\r"; + for (PRInt32 i=0;i<(PRInt32)strlen(replaceStr);i++) { + PRUnichar uChar = replaceStr[i]; + aPrinterName.ReplaceChar(uChar, uc); + } } } @@ -899,79 +900,6 @@ NS_IMETHODIMP nsPrintOptions::DisplayJobProperties( const PRUnichar *aPrinter, n return NS_OK; } -/* attribute long isCancelled; */ -NS_IMETHODIMP nsPrintOptions::GetIsCancelled(PRBool *aIsCancelled) -{ - NS_ENSURE_ARG_POINTER(aIsCancelled); - *aIsCancelled = mIsCancelled; - return NS_OK; -} -NS_IMETHODIMP nsPrintOptions::SetIsCancelled(PRBool aIsCancelled) -{ - mIsCancelled = aIsCancelled; - return NS_OK; -} - -/* attribute boolean printToFile; */ -NS_IMETHODIMP nsPrintOptions::GetPrintToFile(PRBool *aPrintToFile) -{ - //NS_ENSURE_ARG_POINTER(aPrintToFile); - *aPrintToFile = mPrintToFile; - return NS_OK; -} -NS_IMETHODIMP nsPrintOptions::SetPrintToFile(PRBool aPrintToFile) -{ - mPrintToFile = aPrintToFile; - return NS_OK; -} - -/* attribute wstring toFileName; */ -NS_IMETHODIMP nsPrintOptions::GetToFileName(PRUnichar * *aToFileName) -{ - //NS_ENSURE_ARG_POINTER(aToFileName); - *aToFileName = ToNewUnicode(mToFileName); - return NS_OK; -} -NS_IMETHODIMP nsPrintOptions::SetToFileName(const PRUnichar * aToFileName) -{ - mToFileName = aToFileName; - return NS_OK; -} - -/* attribute wstring docTitle; */ -NS_IMETHODIMP nsPrintOptions::GetTitle(PRUnichar * *aTitle) -{ - NS_ENSURE_ARG_POINTER(aTitle); - *aTitle = ToNewUnicode(mTitle); - return NS_OK; -} -NS_IMETHODIMP nsPrintOptions::SetTitle(const PRUnichar * aTitle) -{ - if (aTitle) { - mTitle = aTitle; - } else { - mTitle.SetLength(0); - } - return NS_OK; -} - -/* attribute wstring docURL; */ -NS_IMETHODIMP nsPrintOptions::GetDocURL(PRUnichar * *aDocURL) -{ - NS_ENSURE_ARG_POINTER(aDocURL); - *aDocURL = ToNewUnicode(mURL); - return NS_OK; -} -NS_IMETHODIMP nsPrintOptions::SetDocURL(const PRUnichar * aDocURL) -{ - if (aDocURL) { - mURL = aDocURL; - } else { - mURL.SetLength(0); - } - return NS_OK; -} - /* [noscript] voidPtr GetNativeData (in short aDataType); */ NS_IMETHODIMP nsPrintOptions::GetNativeData(PRInt16 aDataType, void * *_retval) { diff --git a/mozilla/gfx/src/nsPrintOptionsImpl.h b/mozilla/gfx/src/nsPrintOptionsImpl.h index d4aad962170..627ea1477bc 100644 --- a/mozilla/gfx/src/nsPrintOptionsImpl.h +++ b/mozilla/gfx/src/nsPrintOptionsImpl.h @@ -54,18 +54,12 @@ protected: nsresult ReadPrefDouble(nsIPref * aPref, const char * aPrefId, double& aVal); nsresult WritePrefDouble(nsIPref * aPref, const char * aPrefId, double aVal); - nsresult ReadPrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags); - nsresult WritePrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags); + virtual nsresult ReadPrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags); + virtual nsresult WritePrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags); const char* GetPrefName(const char * aPrefName, const nsString& aPrinterName); // Members - PRBool mIsCancelled; - nsString mTitle; - nsString mURL; - PRBool mPrintToFile; - nsString mToFileName; - nsCOMPtr mGlobalPrintSettings; nsCString mPrefName; diff --git a/mozilla/gfx/src/os2/Makefile.in b/mozilla/gfx/src/os2/Makefile.in index 460574d5fa9..96a42f948d1 100644 --- a/mozilla/gfx/src/os2/Makefile.in +++ b/mozilla/gfx/src/os2/Makefile.in @@ -37,10 +37,8 @@ REQUIRES = xpcom \ widget \ view \ util \ - dom \ pref \ uconv \ - windowwatcher \ locale \ unicharutil \ $(NULL) diff --git a/mozilla/gfx/src/os2/nsDeviceContextOS2.cpp b/mozilla/gfx/src/os2/nsDeviceContextOS2.cpp index 4d3db3896ef..aa69fe4886a 100644 --- a/mozilla/gfx/src/os2/nsDeviceContextOS2.cpp +++ b/mozilla/gfx/src/os2/nsDeviceContextOS2.cpp @@ -884,7 +884,7 @@ nsresult nsDeviceContextOS2::CreateFontAliasTable() } // Printing ------------------------------------------------------------------ -nsresult nsDeviceContextOS2::BeginDocument(PRUnichar * aTitle) +nsresult nsDeviceContextOS2::PrepareDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName) { nsresult rv = NS_OK; @@ -915,6 +915,12 @@ nsresult nsDeviceContextOS2::BeginDocument(PRUnichar * aTitle) return rv; } +nsresult nsDeviceContextOS2::BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage) +{ + // Everything is done in PrepareDocument + return NS_OK; +} + nsresult nsDeviceContextOS2::EndDocument() { if (NULL != mPrintDC) diff --git a/mozilla/gfx/src/os2/nsDeviceContextOS2.h b/mozilla/gfx/src/os2/nsDeviceContextOS2.h index 1ba28c630e9..227028c3be9 100644 --- a/mozilla/gfx/src/os2/nsDeviceContextOS2.h +++ b/mozilla/gfx/src/os2/nsDeviceContextOS2.h @@ -86,7 +86,9 @@ public: NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice, nsIDeviceContext *&aContext); - NS_IMETHOD BeginDocument(PRUnichar * aTitle); + NS_IMETHOD PrepareDocument(PRUnichar * aTitle, + PRUnichar* aPrintToFileName); + NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage); NS_IMETHOD EndDocument(void); NS_IMETHOD AbortDocument(void); diff --git a/mozilla/gfx/src/os2/nsDeviceContextSpecFactoryO.cpp b/mozilla/gfx/src/os2/nsDeviceContextSpecFactoryO.cpp index db814f455c3..3cea565bb1f 100644 --- a/mozilla/gfx/src/os2/nsDeviceContextSpecFactoryO.cpp +++ b/mozilla/gfx/src/os2/nsDeviceContextSpecFactoryO.cpp @@ -63,14 +63,14 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryOS2 :: Init(void) NS_IMETHODIMP nsDeviceContextSpecFactoryOS2 :: CreateDeviceContextSpec(nsIWidget *aWidget, nsIPrintSettings* aPrintSettings, nsIDeviceContextSpec *&aNewSpec, - PRBool aQuiet) + PRBool aIsPrintPreview) { nsresult rv; static NS_DEFINE_CID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID); nsCOMPtr devSpec = do_CreateInstance(kDeviceContextSpecCID, &rv); if (NS_SUCCEEDED(rv)) { - rv = ((nsDeviceContextSpecOS2 *)devSpec.get())->Init(aPrintSettings, aQuiet); + rv = ((nsDeviceContextSpecOS2 *)devSpec.get())->Init(aPrintSettings, aIsPrintPreview); if (NS_SUCCEEDED(rv)) { aNewSpec = devSpec; NS_ADDREF(aNewSpec); diff --git a/mozilla/gfx/src/os2/nsDeviceContextSpecFactoryO.h b/mozilla/gfx/src/os2/nsDeviceContextSpecFactoryO.h index 6362f83d3d4..564f8a040a5 100644 --- a/mozilla/gfx/src/os2/nsDeviceContextSpecFactoryO.h +++ b/mozilla/gfx/src/os2/nsDeviceContextSpecFactoryO.h @@ -54,7 +54,7 @@ public: NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget, nsIPrintSettings* aPrintSettings, nsIDeviceContextSpec *&aNewSpec, - PRBool aQuiet); + PRBool aIsPrintPreview); protected: ~nsDeviceContextSpecFactoryOS2(); diff --git a/mozilla/gfx/src/os2/nsDeviceContextSpecOS2.cpp b/mozilla/gfx/src/os2/nsDeviceContextSpecOS2.cpp index 875ecddfdf7..262b7c6876c 100644 --- a/mozilla/gfx/src/os2/nsDeviceContextSpecOS2.cpp +++ b/mozilla/gfx/src/os2/nsDeviceContextSpecOS2.cpp @@ -28,12 +28,7 @@ #include "nsIPref.h" #include "prenv.h" /* for PR_GetEnv */ -#include "nsIDOMWindow.h" #include "nsIServiceManager.h" -#include "nsIDialogParamBlock.h" -#include "nsISupportsPrimitives.h" -#include "nsIWindowWatcher.h" -#include "nsIDOMWindowInternal.h" #include "nsUnicharUtils.h" PRINTDLG nsDeviceContextSpecOS2::PrnDlg; @@ -259,13 +254,13 @@ NS_IMPL_RELEASE(nsDeviceContextSpecOS2) * toolkits including: * - GTK+-toolkit: * file: mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp - * function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init(PRBool aQuiet) + * function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init(PRBool aPrintPreview ) * - Xlib-toolkit: * file: mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp - * function: NS_IMETHODIMP nsDeviceContextSpecXlib::Init(PRBool aQuiet) + * function: NS_IMETHODIMP nsDeviceContextSpecXlib::Init(PRBool aPrintPreview ) * - Qt-toolkit: * file: mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp - * function: NS_IMETHODIMP nsDeviceContextSpecQT::Init(PRBool aQuiet) + * function: NS_IMETHODIMP nsDeviceContextSpecQT::Init(PRBool aPrintPreview ) * * ** Please update the other toolkits when changing this function. */ @@ -276,129 +271,57 @@ NS_IMETHODIMP nsDeviceContextSpecOS2::Init(nsIPrintSettings* aPS, PRBool aQuiet) mPrintSettings = aPS; NS_ASSERTION(aPS, "Must have a PrintSettings!"); - // if there is a current selection then enable the "Selection" radio button - if (aPS != nsnull) { - PRBool isOn; - aPS->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB, &isOn); - nsCOMPtr pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv); - if (NS_SUCCEEDED(rv)) { - (void) pPrefs->SetBoolPref("print.selection_radio_enabled", isOn); - } - } - - PRBool canPrint = PR_FALSE; - rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters(); if (NS_FAILED(rv)) { return rv; } - if ( !aQuiet ) { - rv = NS_ERROR_FAILURE; - // create a nsISupportsArray of the parameters - // being passed to the window - nsCOMPtr array; - NS_NewISupportsArray(getter_AddRefs(array)); - if (!array) return NS_ERROR_FAILURE; + if (aPS) { + PRBool tofile = PR_FALSE; + PRInt32 copies = 1; + PRUnichar *printer = nsnull; + PRUnichar *printfile = nsnull; - nsCOMPtr ps = aPS; - nsCOMPtr psSupports(do_QueryInterface(ps)); - NS_ASSERTION(psSupports, "PrintSettings must be a supports"); - array->AppendElement(psSupports); + mPrintSettings->GetPrinterName(&printer); + mPrintSettings->GetToFileName(&printfile); + mPrintSettings->GetPrintToFile(&tofile); + mPrintSettings->GetNumCopies(&copies); - nsCOMPtr ioParamBlock(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1")); - if (ioParamBlock) { - ioParamBlock->SetInt(0, 0); - nsCOMPtr blkSupps(do_QueryInterface(ioParamBlock)); - NS_ASSERTION(blkSupps, "IOBlk must be a supports"); - - array->AppendElement(blkSupps); - nsCOMPtr arguments(do_QueryInterface(array)); - NS_ASSERTION(array, "array must be a supports"); - - nsCOMPtr wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); - if (wwatch) { - nsCOMPtr active; - wwatch->GetActiveWindow(getter_AddRefs(active)); - nsCOMPtr parent = do_QueryInterface(active); - - nsCOMPtr newWindow; - rv = wwatch->OpenWindow(parent, "chrome://global/content/printdialog.xul", - "_blank", "chrome,modal,centerscreen", array, - getter_AddRefs(newWindow)); - } + if ((copies == 0) || (copies > 999)) { + GlobalPrinters::GetInstance()->FreeGlobalPrinters(); + return NS_ERROR_FAILURE; } - if (NS_SUCCEEDED(rv)) { - PRInt32 buttonPressed = 0; - ioParamBlock->GetInt(0, &buttonPressed); - if (buttonPressed == 1) - canPrint = PR_TRUE; - else - { - GlobalPrinters::GetInstance()->FreeGlobalPrinters(); - return NS_ERROR_ABORT; - } - } else - return NS_ERROR_ABORT; - } else { - canPrint = PR_TRUE; - } - - if (canPrint) { - if (aPS) { - PRBool tofile = PR_FALSE; - PRInt16 printRange = nsIPrintSettings::kRangeAllPages; - PRInt32 fromPage = 1; - PRInt32 toPage = 1; - PRInt32 copies = 1; - PRUnichar *printer = nsnull; - PRUnichar *printfile = nsnull; - - mPrintSettings->GetPrinterName(&printer); - mPrintSettings->GetPrintRange(&printRange); - mPrintSettings->GetToFileName(&printfile); - mPrintSettings->GetPrintToFile(&tofile); - mPrintSettings->GetStartPageRange(&fromPage); - mPrintSettings->GetEndPageRange(&toPage); - mPrintSettings->GetNumCopies(&copies); - - if ((copies == 0) || (copies > 999)) { - GlobalPrinters::GetInstance()->FreeGlobalPrinters(); - return NS_ERROR_FAILURE; - } - - if (printfile != nsnull) { - // ToDo: Use LocalEncoding instead of UTF-8 (see bug 73446) - strcpy(mPrData.path, NS_ConvertUCS2toUTF8(printfile).get()); - } - if (printer != nsnull) - strcpy(mPrData.printer, NS_ConvertUCS2toUTF8(printer).get()); - - mPrData.toPrinter = !tofile; - mPrData.copies = copies; - - rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters(); - if (NS_FAILED(rv)) - return rv; - - const nsAFlatString& printerUCS2 = NS_ConvertUTF8toUCS2(mPrData.printer); - int numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters(); - if (numPrinters) { - for(int i = 0; (i < numPrinters) && !mQueue; i++) { - if ((GlobalPrinters::GetInstance()->GetStringAt(i)->Equals(printerUCS2, nsCaseInsensitiveStringComparator()))) { - SetupDevModeFromSettings(i, aPS); - mQueue = PrnDlg.SetPrinterQueue(i); - } - } - } - - if (printfile != nsnull) - nsMemory::Free(printfile); - - if (printer != nsnull) - nsMemory::Free(printer); + if (printfile != nsnull) { + // ToDo: Use LocalEncoding instead of UTF-8 (see bug 73446) + strcpy(mPrData.path, NS_ConvertUCS2toUTF8(printfile).get()); } + if (printer != nsnull) + strcpy(mPrData.printer, NS_ConvertUCS2toUTF8(printer).get()); + + mPrData.toPrinter = !tofile; + mPrData.copies = copies; + + rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters(); + if (NS_FAILED(rv)) + return rv; + + const nsAFlatString& printerUCS2 = NS_ConvertUTF8toUCS2(mPrData.printer); + int numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters(); + if (numPrinters) { + for(int i = 0; (i < numPrinters) && !mQueue; i++) { + if ((GlobalPrinters::GetInstance()->GetStringAt(i)->Equals(printerUCS2, nsCaseInsensitiveStringComparator()))) { + SetupDevModeFromSettings(i, aPS); + mQueue = PrnDlg.SetPrinterQueue(i); + } + } + } + + if (printfile != nsnull) + nsMemory::Free(printfile); + + if (printer != nsnull) + nsMemory::Free(printer); } GlobalPrinters::GetInstance()->FreeGlobalPrinters(); diff --git a/mozilla/gfx/src/os2/nsDeviceContextSpecOS2.h b/mozilla/gfx/src/os2/nsDeviceContextSpecOS2.h index 0df0cb3ebd5..2bac515911d 100644 --- a/mozilla/gfx/src/os2/nsDeviceContextSpecOS2.h +++ b/mozilla/gfx/src/os2/nsDeviceContextSpecOS2.h @@ -132,14 +132,10 @@ public: /** * Initialize the nsDeviceContextSpecMac for use. This will allocate a printrecord for use * @update dc 2/16/98 - * @param aQuiet if PR_TRUE, prevent the need for user intervention - * in obtaining device context spec. if nsnull is passed in for - * the aOldSpec, this will typically result in getting a device - * context spec for the default output device (i.e. default - * printer). + * @param aIsPrintPreview if PR_TRUE, creating Spec for PrintPreview * @return error status */ - NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet); + NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aIsPrintPreview); NS_IMETHOD ClosePrintManager(); diff --git a/mozilla/gfx/src/photon/Makefile.in b/mozilla/gfx/src/photon/Makefile.in index a27afef5c91..c99652a54f1 100644 --- a/mozilla/gfx/src/photon/Makefile.in +++ b/mozilla/gfx/src/photon/Makefile.in @@ -36,11 +36,9 @@ REQUIRES = xpcom \ widget \ view \ util \ - dom \ pref \ uconv \ unicharutil \ - windowwatcher \ locale \ intl \ $(NULL) diff --git a/mozilla/gfx/src/photon/nsDeviceContextPh.cpp b/mozilla/gfx/src/photon/nsDeviceContextPh.cpp index bb412ab5935..772c2baf992 100644 --- a/mozilla/gfx/src/photon/nsDeviceContextPh.cpp +++ b/mozilla/gfx/src/photon/nsDeviceContextPh.cpp @@ -451,7 +451,7 @@ int nsDeviceContextPh::prefChanged( const char *aPref, void *aClosure ) { return 0; } -NS_IMETHODIMP nsDeviceContextPh :: BeginDocument( PRUnichar *t ) { +NS_IMETHODIMP nsDeviceContextPh :: BeginDocument( PRUnichar *t, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage ) { PpPrintContext_t *pc = ((nsDeviceContextSpecPh *)mSpec)->GetPrintContext(); PpStartJob(pc); mIsPrinting = 1; diff --git a/mozilla/gfx/src/photon/nsDeviceContextPh.h b/mozilla/gfx/src/photon/nsDeviceContextPh.h index f975571e822..4aff3e07e11 100644 --- a/mozilla/gfx/src/photon/nsDeviceContextPh.h +++ b/mozilla/gfx/src/photon/nsDeviceContextPh.h @@ -84,7 +84,7 @@ public: NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice, nsIDeviceContext *&aContext); - NS_IMETHOD BeginDocument(PRUnichar *t); + NS_IMETHOD BeginDocument(PRUnichar *t, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage); NS_IMETHOD EndDocument(void); NS_IMETHOD AbortDocument(void); diff --git a/mozilla/gfx/src/photon/nsDeviceContextSpecFactoryP.cpp b/mozilla/gfx/src/photon/nsDeviceContextSpecFactoryP.cpp index 3a982405f4b..8a1a1679c70 100644 --- a/mozilla/gfx/src/photon/nsDeviceContextSpecFactoryP.cpp +++ b/mozilla/gfx/src/photon/nsDeviceContextSpecFactoryP.cpp @@ -72,7 +72,7 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryPh :: Init(void) NS_IMETHODIMP nsDeviceContextSpecFactoryPh :: CreateDeviceContextSpec(nsIWidget *aWidget, nsIPrintSettings* aPrintSettings, nsIDeviceContextSpec *&aNewSpec, - PRBool aQuiet) + PRBool aIsPrintPreview) { NS_ENSURE_ARG_POINTER(aWidget); PpPrintContext_t *pc = NULL; @@ -90,8 +90,6 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryPh :: CreateDeviceContextSpec(nsIWidget { PRInt32 range = 0; - aQuiet = 1; /* for the embedding stuff, the PrintSelection dialog is displayed by the client */ - /* check for the page range if we are called by an embedded app, the pc is there */ aPrintSettings->GetEndPageRange(&range); if (range) pc = (PpPrintContext_t *) range; @@ -102,7 +100,7 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryPh :: CreateDeviceContextSpec(nsIWidget { specPh->SetPrintContext(pc); } - rv = specPh->Init(aWidget, aPrintSettings, aQuiet); + rv = specPh->Init(aWidget, aPrintSettings, PR_TRUE); if (NS_SUCCEEDED(rv)) { aNewSpec = devSpec; } else { diff --git a/mozilla/gfx/src/photon/nsDeviceContextSpecFactoryP.h b/mozilla/gfx/src/photon/nsDeviceContextSpecFactoryP.h index a9da1380633..0e384868bde 100644 --- a/mozilla/gfx/src/photon/nsDeviceContextSpecFactoryP.h +++ b/mozilla/gfx/src/photon/nsDeviceContextSpecFactoryP.h @@ -53,7 +53,7 @@ public: NS_IMETHOD CreateDeviceContextSpec( nsIWidget *aWidget, nsIPrintSettings* aPrintSettings, nsIDeviceContextSpec *&aNewSpec, - PRBool aQuiet); + PRBool aIsPrintPreview); protected: virtual ~nsDeviceContextSpecFactoryPh(); diff --git a/mozilla/gfx/src/photon/nsDeviceContextSpecPh.cpp b/mozilla/gfx/src/photon/nsDeviceContextSpecPh.cpp index d135728f840..8ede7990f83 100644 --- a/mozilla/gfx/src/photon/nsDeviceContextSpecPh.cpp +++ b/mozilla/gfx/src/photon/nsDeviceContextSpecPh.cpp @@ -42,23 +42,11 @@ #include "plstr.h" #include "nsPhGfxLog.h" -#include "nsGfxCIID.h" -#include "nsIPrintOptions.h" -#include "nsIDOMWindow.h" -#include "nsIDialogParamBlock.h" -#include "nsISupportsPrimitives.h" -#include "nsIWindowWatcher.h" -#include "nsIDOMWindowInternal.h" -#include "nsVoidArray.h" -#include "nsSupportsArray.h" - #include "nsString.h" #include "nsIServiceManager.h" #include "nsReadableUtils.h" #include "nsIPref.h" -static NS_DEFINE_CID( kPrintOptionsCID, NS_PRINTOPTIONS_CID ); - nsDeviceContextSpecPh :: nsDeviceContextSpecPh() { NS_INIT_REFCNT(); diff --git a/mozilla/gfx/src/ps/nsDeviceContextPS.cpp b/mozilla/gfx/src/ps/nsDeviceContextPS.cpp index c2b18e0ad28..fd38e3d0988 100644 --- a/mozilla/gfx/src/ps/nsDeviceContextPS.cpp +++ b/mozilla/gfx/src/ps/nsDeviceContextPS.cpp @@ -340,7 +340,7 @@ NS_IMETHODIMP nsDeviceContextPS::GetDeviceContextFor(nsIDeviceContextSpec *aDevi * See documentation in nsIDeviceContext.h * @update 12/21/98 dwc */ -NS_IMETHODIMP nsDeviceContextPS::BeginDocument(PRUnichar * aTitle) +NS_IMETHODIMP nsDeviceContextPS::BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage) { PR_LOG(nsDeviceContextPSLM, PR_LOG_DEBUG, ("nsDeviceContextPS::BeginDocument()\n")); diff --git a/mozilla/gfx/src/ps/nsDeviceContextPS.h b/mozilla/gfx/src/ps/nsDeviceContextPS.h index df5d9111242..774bb9c0acc 100644 --- a/mozilla/gfx/src/ps/nsDeviceContextPS.h +++ b/mozilla/gfx/src/ps/nsDeviceContextPS.h @@ -89,7 +89,7 @@ public: NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,nsIDeviceContext *&aContext); NS_IMETHOD GetSystemFont(nsSystemFontID anID, nsFont *aFont) const; - NS_IMETHOD BeginDocument(PRUnichar * aTitle); + NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage); NS_IMETHOD EndDocument(void); NS_IMETHOD AbortDocument(void); NS_IMETHOD BeginPage(void); diff --git a/mozilla/gfx/src/qt/Makefile.in b/mozilla/gfx/src/qt/Makefile.in index 4915f1f51d3..adea2e2c116 100644 --- a/mozilla/gfx/src/qt/Makefile.in +++ b/mozilla/gfx/src/qt/Makefile.in @@ -37,12 +37,9 @@ REQUIRES = xpcom \ gfx2 \ uconv \ pref \ - dom \ util \ js \ - appshell \ mozcomps \ - windowwatcher \ unicharutil \ intl \ locale \ diff --git a/mozilla/gfx/src/qt/nsDeviceContextQT.cpp b/mozilla/gfx/src/qt/nsDeviceContextQT.cpp index 8d221a8496b..4e10b4906f0 100644 --- a/mozilla/gfx/src/qt/nsDeviceContextQT.cpp +++ b/mozilla/gfx/src/qt/nsDeviceContextQT.cpp @@ -376,7 +376,7 @@ nsDeviceContextQT::GetDeviceContextFor(nsIDeviceContextSpec *aDevice, return rv; } -NS_IMETHODIMP nsDeviceContextQT::BeginDocument(PRUnichar *aTitle) +NS_IMETHODIMP nsDeviceContextQT::BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage) { return NS_OK; } diff --git a/mozilla/gfx/src/qt/nsDeviceContextQT.h b/mozilla/gfx/src/qt/nsDeviceContextQT.h index 1d7ba4a5bf5..1093c015276 100644 --- a/mozilla/gfx/src/qt/nsDeviceContextQT.h +++ b/mozilla/gfx/src/qt/nsDeviceContextQT.h @@ -87,7 +87,7 @@ public: NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice, nsIDeviceContext *&aContext); - NS_IMETHOD BeginDocument(PRUnichar *aTitle); + NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage); NS_IMETHOD EndDocument(void); NS_IMETHOD BeginPage(void); diff --git a/mozilla/gfx/src/qt/nsDeviceContextSpecFactoryQT.cpp b/mozilla/gfx/src/qt/nsDeviceContextSpecFactoryQT.cpp index 9c65bab240b..5e0071d78de 100644 --- a/mozilla/gfx/src/qt/nsDeviceContextSpecFactoryQT.cpp +++ b/mozilla/gfx/src/qt/nsDeviceContextSpecFactoryQT.cpp @@ -99,7 +99,7 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryQT::CreateDeviceContextSpec(nsIWidget *aWidget, nsIPrintSettings* aPrintSettings, nsIDeviceContextSpec *&aNewSpec, - PRBool aQuiet) + PRBool aIsPrintPreview) { nsresult rv = NS_ERROR_FAILURE; nsIDeviceContextSpec *devSpec = nsnull; @@ -109,7 +109,7 @@ nsDeviceContextSpecFactoryQT::CreateDeviceContextSpec(nsIWidget *aWidget, (void **)&devSpec); if (nsnull != devSpec) { - if (NS_OK == ((nsDeviceContextSpecQT*)devSpec)->Init(aPrintSettings, aQuiet)) { + if (NS_OK == ((nsDeviceContextSpecQT*)devSpec)->Init(aPrintSettings)) { aNewSpec = devSpec; rv = NS_OK; } diff --git a/mozilla/gfx/src/qt/nsDeviceContextSpecFactoryQT.h b/mozilla/gfx/src/qt/nsDeviceContextSpecFactoryQT.h index 0baa22ec995..ed0cd84a7d3 100644 --- a/mozilla/gfx/src/qt/nsDeviceContextSpecFactoryQT.h +++ b/mozilla/gfx/src/qt/nsDeviceContextSpecFactoryQT.h @@ -54,7 +54,7 @@ public: NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget, nsIPrintSettings* aPrintSettings, nsIDeviceContextSpec *&aNewSpec, - PRBool aQuiet); + PRBool aIsPrintPreview); protected: virtual ~nsDeviceContextSpecFactoryQT(); diff --git a/mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp b/mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp index c2071d9ca07..3be6ca3d348 100644 --- a/mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp +++ b/mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp @@ -20,7 +20,7 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * John C. Griggs + * John C. Griggs * * * Alternatively, the contents of this file may be used under the terms of @@ -43,15 +43,6 @@ #include "nsIPref.h" #include "prenv.h" /* for PR_GetEnv */ -#include "nsIDOMWindowInternal.h" -#include "nsIServiceManager.h" -#include "nsIDialogParamBlock.h" -#include "nsISupportsPrimitives.h" -#include "nsIWindowWatcher.h" - -#include "nsReadableUtils.h" -#include "nsISupportsArray.h" - #include //JCG #define DBG_JCG 1 @@ -130,7 +121,7 @@ NS_IMETHODIMP nsDeviceContextSpecQT::QueryInterface(REFNSIID aIID, * @update dc 2/15/98 * @update syd 3/2/99 */ -NS_IMETHODIMP nsDeviceContextSpecQT::Init(nsIPrintSettings* aPS, PRBool aQuiet) +NS_IMETHODIMP nsDeviceContextSpecQT::Init(nsIPrintSettings* aPS) { nsresult rv = NS_ERROR_FAILURE; NS_ASSERTION(aPS, "Must have a PrintSettings!"); @@ -161,115 +152,73 @@ NS_IMETHODIMP nsDeviceContextSpecQT::Init(nsIPrintSettings* aPS, PRBool aQuiet) double dtop = 0.5; double dbottom = 0.5; - rv = NS_ERROR_FAILURE; - // create a nsISupportsArray of the parameters - // being passed to the window - nsCOMPtr array; - NS_NewISupportsArray(getter_AddRefs(array)); - if (!array) return NS_ERROR_FAILURE; + if (aPS) { + aPS->GetPrintReversed(&reversed); + aPS->GetPrintInColor(&color); + aPS->GetPaperSize(&paper_size); + aPS->GetOrientation(&orientation); + aPS->GetPrintCommand(&command); + aPS->GetPrintRange(&printRange); + aPS->GetToFileName(&printfile); + aPS->GetPrintToFile(&tofile); + aPS->GetStartPageRange(&fromPage); + aPS->GetEndPageRange(&toPage); + aPS->GetMarginTop(&dtop); + aPS->GetMarginLeft(&dleft); + aPS->GetMarginBottom(&dbottom); + aPS->GetMarginRight(&dright); - nsCOMPtr ps = aPS; - nsCOMPtr psSupports(do_QueryInterface(ps)); - NS_ASSERTION(psSupports, "PrintSettings must be a supports"); - array->AppendElement(psSupports); + if (command != nsnull && printfile != nsnull) { + // convert Unicode strings to cstrings + nsAutoString cmdStr; + nsAutoString printFileStr; - nsCOMPtr ioParamBlock(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1")); - if (ioParamBlock) { - ioParamBlock->SetInt(0, 0); - nsCOMPtr blkSupps(do_QueryInterface(ioParamBlock)); - NS_ASSERTION(blkSupps, "IOBlk must be a supports"); - - array->AppendElement(blkSupps); - nsCOMPtr arguments(do_QueryInterface(array)); - NS_ASSERTION(array, "array must be a supports"); - - nsCOMPtr wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); - if (wwatch) { - nsCOMPtr active; - wwatch->GetActiveWindow(getter_AddRefs(active)); - nsCOMPtr parent = do_QueryInterface(active); - - nsCOMPtr newWindow; - rv = wwatch->OpenWindow(parent, "chrome://global/content/printdialog.xul", - "_blank", "chrome,modal,centerscreen", array, - getter_AddRefs(newWindow)); + cmdStr = command; + printFileStr = printfile; + char *pCmdStr = ToNewCString(cmdStr); + char *pPrintFileStr = ToNewCString(printFileStr); + sprintf(mPrData.command,pCmdStr); + sprintf(mPrData.path,pPrintFileStr); + nsMemory::Free(pCmdStr); + nsMemory::Free(pPrintFileStr); } - } - - if (NS_SUCCEEDED(rv)) { - PRInt32 buttonPressed = 0; - ioParamBlock->GetInt(0, &buttonPressed); - if (buttonPressed == 1) { - if (aPS) { - aPS->GetPrintReversed(&reversed); - aPS->GetPrintInColor(&color); - aPS->GetPaperSize(&paper_size); - aPS->GetOrientation(&orientation); - aPS->GetPrintCommand(&command); - aPS->GetPrintRange(&printRange); - aPS->GetToFileName(&printfile); - aPS->GetPrintToFile(&tofile); - aPS->GetStartPageRange(&fromPage); - aPS->GetEndPageRange(&toPage); - aPS->GetMarginTop(&dtop); - aPS->GetMarginLeft(&dleft); - aPS->GetMarginBottom(&dbottom); - aPS->GetMarginRight(&dright); - - if (command != nsnull && printfile != nsnull) { - // convert Unicode strings to cstrings - nsAutoString cmdStr; - nsAutoString printFileStr; - - cmdStr = command; - printFileStr = printfile; - char *pCmdStr = ToNewCString(cmdStr); - char *pPrintFileStr = ToNewCString(printFileStr); - sprintf(mPrData.command,pCmdStr); - sprintf(mPrData.path,pPrintFileStr); - nsMemory::Free(pCmdStr); - nsMemory::Free(pPrintFileStr); - } - } - else { + } else { #ifndef VMS - sprintf( mPrData.command, "lpr" ); + const char* kCommandStr = "lpr"; #else - // Note to whoever puts the "lpr" into the prefs file. Please contact me - // as I need to make the default be "print" instead of "lpr" for OpenVMS. - sprintf( mPrData.command, "print" ); + // Note to whoever puts the "lpr" into the prefs file. Please contact me + // as I need to make the default be "print" instead of "lpr" for OpenVMS. + const char* kCommandStr = "print"; #endif - } - mPrData.top = dtop; - mPrData.bottom = dbottom; - mPrData.left = dleft; - mPrData.right = dright; - mPrData.fpf = !reversed; - mPrData.grayscale = !color; - mPrData.size = paper_size; - mPrData.orientation = orientation; - mPrData.toPrinter = !tofile; - - // PWD, HOME, or fail - if (!printfile) { - if ((path = PR_GetEnv("PWD")) == (char*)NULL) - if ((path = PR_GetEnv("HOME")) == (char*)NULL) - strcpy(mPrData.path,"mozilla.ps"); - if (path != (char*)NULL) - sprintf(mPrData.path,"%s/mozilla.ps",path); - else - return NS_ERROR_FAILURE; - } - if (command != nsnull) { - nsMemory::Free(command); - } - if (printfile != nsnull) { - nsMemory::Free(printfile); - } - return NS_OK; - } } - return NS_ERROR_FAILURE; + sprintf( mPrData.command, kCommandStr ); + mPrData.top = dtop; + mPrData.bottom = dbottom; + mPrData.left = dleft; + mPrData.right = dright; + mPrData.fpf = !reversed; + mPrData.grayscale = !color; + mPrData.size = paper_size; + mPrData.orientation = orientation; + mPrData.toPrinter = !tofile; + + // PWD, HOME, or fail + if (!printfile) { + if ((path = PR_GetEnv("PWD")) == (char*)NULL) + if ((path = PR_GetEnv("HOME")) == (char*)NULL) + strcpy(mPrData.path,"mozilla.ps"); + if (path != (char*)NULL) + sprintf(mPrData.path,"%s/mozilla.ps",path); + else + return NS_ERROR_FAILURE; + } + if (command != nsnull) { + nsMemory::Free(command); + } + if (printfile != nsnull) { + nsMemory::Free(printfile); + } + return NS_OK; } NS_IMETHODIMP nsDeviceContextSpecQT::GetToPrinter(PRBool &aToPrinter) diff --git a/mozilla/gfx/src/qt/nsDeviceContextSpecQT.h b/mozilla/gfx/src/qt/nsDeviceContextSpecQT.h index 4b5cee6c089..b2d8d9fd50e 100644 --- a/mozilla/gfx/src/qt/nsDeviceContextSpecQT.h +++ b/mozilla/gfx/src/qt/nsDeviceContextSpecQT.h @@ -62,14 +62,9 @@ public: /** * Initialize the nsDeviceContextSpecQT for use. This will allocate a printrecord for use * @update dc 2/16/98 - * @param aQuiet if PR_TRUE, prevent the need for user intervention - * in obtaining device context spec. if nsnull is passed in for - * the aOldSpec, this will typically result in getting a device - * context spec for the default output device (i.e. default - * printer). * @return error status */ - NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet); + NS_IMETHOD Init(nsIPrintSettings* aPS); /** diff --git a/mozilla/gfx/src/windows/Makefile.in b/mozilla/gfx/src/windows/Makefile.in index 76cb89f0346..b515114b7e4 100644 --- a/mozilla/gfx/src/windows/Makefile.in +++ b/mozilla/gfx/src/windows/Makefile.in @@ -42,8 +42,6 @@ REQUIRES = xpcom \ unicharutil \ locale \ necko \ - dom \ - windowwatcher \ content \ layout \ $(NULL) diff --git a/mozilla/gfx/src/windows/makefile.win b/mozilla/gfx/src/windows/makefile.win index bb8191d5ba5..9f49538eece 100644 --- a/mozilla/gfx/src/windows/makefile.win +++ b/mozilla/gfx/src/windows/makefile.win @@ -35,8 +35,6 @@ REQUIRES = xpcom \ unicharutil \ locale \ necko \ - dom \ - windowwatcher \ content \ layout \ layout_xul \ diff --git a/mozilla/gfx/src/windows/nsDeviceContextSpecFactoryW.cpp b/mozilla/gfx/src/windows/nsDeviceContextSpecFactoryW.cpp index 55e22626a06..437c7b4c973 100644 --- a/mozilla/gfx/src/windows/nsDeviceContextSpecFactoryW.cpp +++ b/mozilla/gfx/src/windows/nsDeviceContextSpecFactoryW.cpp @@ -66,7 +66,7 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryWin :: Init(void) NS_IMETHODIMP nsDeviceContextSpecFactoryWin :: CreateDeviceContextSpec(nsIWidget *aWidget, nsIPrintSettings* aPrintSettings, nsIDeviceContextSpec *&aNewSpec, - PRBool aQuiet) + PRBool aIsPrintPreview) { NS_ENSURE_ARG_POINTER(aWidget); @@ -77,7 +77,7 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryWin :: CreateDeviceContextSpec(nsIWidget if (nsnull != devspec){ nsDeviceContextSpecWin* specWin = NS_STATIC_CAST(nsDeviceContextSpecWin*, devspec); - rv = specWin->Init(aWidget, aPrintSettings, aQuiet); + rv = specWin->Init(aWidget, aPrintSettings, aIsPrintPreview); if (NS_SUCCEEDED(rv)) { aNewSpec = devspec; } else { diff --git a/mozilla/gfx/src/windows/nsDeviceContextSpecFactoryW.h b/mozilla/gfx/src/windows/nsDeviceContextSpecFactoryW.h index 99e9352121e..0341ac5af5e 100644 --- a/mozilla/gfx/src/windows/nsDeviceContextSpecFactoryW.h +++ b/mozilla/gfx/src/windows/nsDeviceContextSpecFactoryW.h @@ -55,7 +55,7 @@ public: NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget, nsIPrintSettings* aPrintSettings, nsIDeviceContextSpec *&aNewSpec, - PRBool aQuiet); + PRBool aIsPrintPreview); protected: ~nsDeviceContextSpecFactoryWin(); diff --git a/mozilla/gfx/src/windows/nsDeviceContextSpecWin.cpp b/mozilla/gfx/src/windows/nsDeviceContextSpecWin.cpp index 348991ed9a1..10023c302af 100644 --- a/mozilla/gfx/src/windows/nsDeviceContextSpecWin.cpp +++ b/mozilla/gfx/src/windows/nsDeviceContextSpecWin.cpp @@ -41,73 +41,39 @@ #define WINVER 0x0500 #endif +//#include +//#include +#include + #include "nsDeviceContextSpecWin.h" #include "prmem.h" -#include "plstr.h" +//#include "plstr.h" #include +#include +//#include "prenv.h" /* for PR_GetEnv */ #include -#include -#include - -#include "nsIDOMWindow.h" -#include "nsIServiceManager.h" -#include "nsIDialogParamBlock.h" -#include "nsISupportsPrimitives.h" -#include "nsIWindowWatcher.h" -#include "nsIDOMWindowInternal.h" #include "nsVoidArray.h" -#include "nsSupportsArray.h" +#include "nsIPrintSettingsWin.h" #include "nsString.h" #include "nsIServiceManager.h" #include "nsReadableUtils.h" #include "nsGfxCIID.h" static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID); -#include "nsIPromptService.h" + +// File Picker +#include "nsILocalFile.h" +#include "nsIFile.h" +#include "nsIFilePicker.h" +#include "nsIStringBundle.h" +#define NS_ERROR_GFX_PRINTER_BUNDLE_URL "chrome://communicator/locale/printing.properties" #include "nsIPref.h" -#include "prenv.h" /* for PR_GetEnv */ - -#include -#include - -// For Localization -#include "nsIStringBundle.h" -#include "nsDeviceContext.h" -#include "nsDeviceContextWin.h" - -// This is for extending the dialog -#include - -static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID); - -// For PrintDlgEx -// needed because there are unicode/ansi versions of this routine -// and we need to make sure we get the correct one. -#ifdef UNICODE -#define GetPrintDlgExQuoted "PrintDlgExW" -#else -#define GetPrintDlgExQuoted "PrintDlgExA" -#endif - -// Default labels for the radio buttons -const char* kAsLaidOutOnScreenStr = "As &laid out on the screen"; -const char* kTheSelectedFrameStr = "The selected &frame"; -const char* kEachFrameSeparately = "&Each frame separately"; - //----------------------------------------------- // Global Data //----------------------------------------------- -// Identifies which new radio btn was cliked on -static UINT gFrameSelectedRadioBtn = 0; - -// Indicates whether the native print dialog was successfully extended -static PRPackedBool gDialogWasExtended = PR_FALSE; - -#define PRINTDLG_PROPERTIES "chrome://global/locale/printdialog.properties" - static HWND gParentWnd = NULL; //---------------------------------------------------------------------------------- @@ -200,8 +166,7 @@ const NativePaperSizes kPaperSizes[] = { const PRInt32 kNumPaperSizes = 41; //---------------------------------------------------------------------------------- -nsDeviceContextSpecWin::nsDeviceContextSpecWin() : - mUseExtendedPrintDlg(NULL) +nsDeviceContextSpecWin::nsDeviceContextSpecWin() { NS_INIT_REFCNT(); @@ -211,12 +176,6 @@ nsDeviceContextSpecWin::nsDeviceContextSpecWin() : mGlobalDevMode = NULL; mIsDEVMODEGlobalHandle = PR_FALSE; -#ifdef MOZ_REQUIRE_CURRENT_SDK - HMODULE lib = GetModuleHandle("comdlg32.dll"); - if ( lib ) { - mUseExtendedPrintDlg = GetProcAddress(lib, GetPrintDlgExQuoted); - } -#endif } @@ -235,6 +194,334 @@ nsDeviceContextSpecWin::~nsDeviceContextSpecWin() } +//------------------------------------------------------------------ +// helper +static PRUnichar * GetDefaultPrinterNameFromGlobalPrinters() +{ + PRUnichar * printerName; + LPTSTR lpPrtName; + GlobalPrinters::GetInstance()->GetDefaultPrinterName(lpPrtName); + nsString str; +#ifdef UNICODE + str.AppendWithConversion((PRUnichar *)lpPrtName); +#else + str.AssignWithConversion((char*)lpPrtName); +#endif + printerName = ToNewUnicode(str); + free(lpPrtName); + return printerName; +} + +//---------------------------------------------------------------- +static nsresult +EnumerateNativePrinters(DWORD aWhichPrinters, LPTSTR aPrinterName, PRBool& aIsFound, PRBool& aIsFile) +{ + DWORD dwSizeNeeded; + DWORD dwNumItems; + LPPRINTER_INFO_2 lpInfo = NULL; + + // Get buffer size + ::EnumPrinters ( aWhichPrinters, NULL, 2, NULL, 0, &dwSizeNeeded, &dwNumItems ); + + // allocate memory + lpInfo = (LPPRINTER_INFO_2)HeapAlloc ( GetProcessHeap (), HEAP_ZERO_MEMORY, dwSizeNeeded ); + if ( lpInfo == NULL ) { + return NS_ERROR_OUT_OF_MEMORY; + } + + if (::EnumPrinters ( PRINTER_ENUM_LOCAL, NULL, 2, (LPBYTE)lpInfo, dwSizeNeeded, &dwSizeNeeded, &dwNumItems) == 0 ) { + return NS_OK; + } + + + for (DWORD i = 0; i < dwNumItems; i++ ) { + if (_tcscmp(lpInfo[i].pPrinterName, aPrinterName)) { + aIsFound = PR_TRUE; + aIsFile = _tcscmp(lpInfo[i].pPortName, _T("FILE:")) == 0; + break; + } + } + + HeapFree(GetProcessHeap (), 0, lpInfo); + return NS_OK; +} + +//---------------------------------------------------------------- +static nsresult +CheckForPrintToFile(LPTSTR aPrinterName, PRBool& aIsFile) +{ + PRBool isFound = PR_FALSE; + aIsFile = PR_FALSE; + nsresult rv = EnumerateNativePrinters(PRINTER_ENUM_LOCAL, aPrinterName, isFound, aIsFile); + if (isFound || NS_FAILED(rv)) return rv; + + rv = EnumerateNativePrinters(PRINTER_ENUM_NETWORK, aPrinterName, isFound, aIsFile); + if (isFound || NS_FAILED(rv)) return rv; + + rv = EnumerateNativePrinters(PRINTER_ENUM_SHARED, aPrinterName, isFound, aIsFile); + if (isFound || NS_FAILED(rv)) return rv; + + rv = EnumerateNativePrinters(PRINTER_ENUM_REMOTE, aPrinterName, isFound, aIsFile); + if (isFound || NS_FAILED(rv)) return rv; + + return NS_OK; +} + +static nsresult +GetFileNameForPrintSettings(nsIPrintSettings* aPS) +{ + // for testing +#ifdef DEBUG_rods + return NS_OK; +#endif + + nsresult rv; + + nsCOMPtr filePicker = do_CreateInstance("@mozilla.org/filepicker;1", &rv); + NS_ENSURE_SUCCESS(rv, rv); + + nsCOMPtr bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv); + NS_ENSURE_SUCCESS(rv, rv); + nsCOMPtr bundle; + rv = bundleService->CreateBundle(NS_ERROR_GFX_PRINTER_BUNDLE_URL, getter_AddRefs(bundle)); + NS_ENSURE_SUCCESS(rv, rv); + + nsXPIDLString title; + rv = bundle->GetStringFromName(NS_LITERAL_STRING("PrintToFile").get(), getter_Copies(title)); + NS_ENSURE_SUCCESS(rv, rv); + + rv = filePicker->Init(nsnull, title.get(), nsIFilePicker::modeSave); + NS_ENSURE_SUCCESS(rv, rv); + + rv = filePicker->AppendFilters(nsIFilePicker::filterAll); + NS_ENSURE_SUCCESS(rv, rv); + + PRUnichar* fileName; + aPS->GetToFileName(&fileName); + + if (fileName) { + if (*fileName) { + nsCAutoString leafName; + nsCOMPtr file(do_CreateInstance("@mozilla.org/file/local;1")); + if (file) { + rv = file->InitWithPath(NS_ConvertUCS2toUTF8(fileName)); + if (NS_SUCCEEDED(rv)) { + file->GetLeafName(leafName); + filePicker->SetDisplayDirectory(file); + } + } + if (!leafName.IsEmpty()) { + NS_ConvertUTF8toUCS2 unicodeFileName(leafName); + rv = filePicker->SetDefaultString(unicodeFileName.get()); + } + NS_ENSURE_SUCCESS(rv, rv); + } + nsMemory::Free(fileName); + } + + PRInt16 dialogResult; + filePicker->Show(&dialogResult); + + if (dialogResult == nsIFilePicker::returnCancel) { + return NS_ERROR_ABORT; + } + + nsCOMPtr localFile; + rv = filePicker->GetFile(getter_AddRefs(localFile)); + NS_ENSURE_SUCCESS(rv, rv); + + if (dialogResult == nsIFilePicker::returnReplace) { + // be extra safe and only delete when the file is really a file + PRBool isFile; + rv = localFile->IsFile(&isFile); + if (NS_SUCCEEDED(rv) && isFile) { + rv = localFile->Remove(PR_FALSE /* recursive delete */); + NS_ENSURE_SUCCESS(rv, rv); + } + } + + nsCAutoString cPath; + rv = localFile->GetPath(cPath); + NS_ENSURE_SUCCESS(rv,rv); + + if (cPath.IsEmpty()) { + rv = NS_ERROR_ABORT; + } + + NS_ConvertUTF8toUCS2 unicodePath(cPath); + if (NS_SUCCEEDED(rv)) aPS->SetToFileName(unicodePath.get()); + + return rv; +} + +//---------------------------------------------------------------------------------- +static nsresult +CheckForPrintToFile(nsIPrintSettings* aPS, LPTSTR aPrinterName, PRUnichar* aUPrinterName) +{ + nsresult rv = NS_OK; + + if (!aPrinterName && !aUPrinterName) return rv; + + PRBool toFile; +#ifdef UNICODE + CheckForPrintToFile(aPrinterName?aPrinterName:aUPrinterName, toFile); +#else + if (aPrinterName) { + CheckForPrintToFile(aPrinterName, toFile); + } else { + CheckForPrintToFile((char*)NS_ConvertUCS2toUTF8(aUPrinterName).get(), toFile); + } +#endif + aPS->SetPrintToFile(toFile); + if (toFile) { + rv = GetFileNameForPrintSettings(aPS); + } + return rv; +} + +//---------------------------------------------------------------------------------- +NS_IMETHODIMP nsDeviceContextSpecWin::Init(nsIWidget* aWidget, + nsIPrintSettings* aPrintSettings, + PRBool aIsPrintPreview) +{ + mPrintSettings = aPrintSettings; + + gParentWnd = (HWND)aWidget->GetNativeData(NS_NATIVE_WINDOW); + + nsresult rv = NS_ERROR_FAILURE; + if (aPrintSettings) { + nsCOMPtr psWin(do_QueryInterface(aPrintSettings)); + if (psWin) { + char* deviceName; + char* driverName; + psWin->GetDeviceName(&deviceName); // creates new memory (makes a copy) + psWin->GetDriverName(&driverName); // creates new memory (makes a copy) + + LPDEVMODE devMode; + psWin->GetDevMode(&devMode); // creates new memory (makes a copy) + + if (deviceName && driverName && devMode) { + // Scaling is special, it is one of the few + // devMode items that we control in layout + if (devMode->dmFields & DM_SCALE) { + double scale = double(devMode->dmScale) / 100.0f; + if (scale != 1.0) { + aPrintSettings->SetScaling(scale); + devMode->dmScale = 100; + } + } + + SetDeviceName(deviceName); + SetDriverName(driverName); + SetDevMode(devMode); + + if (!aIsPrintPreview) { + rv = CheckForPrintToFile(mPrintSettings, deviceName, nsnull); + NS_ENSURE_SUCCESS(rv, rv); + } + + // clean up + nsCRT::free(deviceName); + nsCRT::free(driverName); + + return NS_OK; + } else { + if (deviceName) nsCRT::free(deviceName); + if (driverName) nsCRT::free(driverName); + if (devMode) free(devMode); + } + } + } + + LPDEVMODE pDevMode = NULL; + HGLOBAL hDevNames = NULL; + + // Get the Print Name to be used + PRUnichar * printerName; + mPrintSettings->GetPrinterName(&printerName); + + // If there is no name then use the default printer + if (!printerName || (printerName && !*printerName)) { + printerName = GetDefaultPrinterNameFromGlobalPrinters(); + } + + NS_ASSERTION(printerName, "We have to have a printer name"); + if (!printerName || !*printerName) return NS_ERROR_FAILURE; + + if (!aIsPrintPreview) { + CheckForPrintToFile(mPrintSettings, nsnull, printerName); + } + + return GetDataFromPrinter(printerName, mPrintSettings); +} + +//---------------------------------------------------------- +// Helper Function - Free and reallocate the string +static void CleanAndCopyString(char*& aStr, char* aNewStr) +{ + if (aStr != nsnull) { + if (aNewStr != nsnull && strlen(aStr) > strlen(aNewStr)) { // reuse it if we can + PL_strcpy(aStr, aNewStr); + return; + } else { + PR_Free(aStr); + aStr = nsnull; + } + } + + if (nsnull != aNewStr) { + aStr = (char *)PR_Malloc(PL_strlen(aNewStr) + 1); + PL_strcpy(aStr, aNewStr); + } +} + +//---------------------------------------------------------------------------------- +void nsDeviceContextSpecWin::SetDeviceName(char* aDeviceName) +{ + CleanAndCopyString(mDeviceName, aDeviceName); +} + +//---------------------------------------------------------------------------------- +void nsDeviceContextSpecWin::SetDriverName(char* aDriverName) +{ + CleanAndCopyString(mDriverName, aDriverName); +} + +//---------------------------------------------------------------------------------- +void nsDeviceContextSpecWin::SetGlobalDevMode(HGLOBAL aHGlobal) +{ + if (mGlobalDevMode) { + ::GlobalFree(mGlobalDevMode); + mGlobalDevMode = NULL; + } + mGlobalDevMode = aHGlobal; + mIsDEVMODEGlobalHandle = PR_TRUE; +} + +//---------------------------------------------------------------------------------- +void nsDeviceContextSpecWin::SetDevMode(LPDEVMODE aDevMode) +{ + if (mDevMode) free(mDevMode); + + mDevMode = aDevMode; + mIsDEVMODEGlobalHandle = PR_FALSE; +} + +//------------------------------------------------------------------ +void +nsDeviceContextSpecWin::GetDevMode(LPDEVMODE &aDevMode) +{ + if (mIsDEVMODEGlobalHandle) { + if (mGlobalDevMode) { + aDevMode = (DEVMODE *)::GlobalLock(mGlobalDevMode); + } else { + aDevMode = NULL; + } + } else { + aDevMode = mDevMode; + } +} + //---------------------------------------------------------------------------------- // Map an incoming size to a Windows Native enum in the DevMode static void @@ -326,1216 +613,6 @@ SetupDevModeFromSettings(LPDEVMODE aDevMode, nsIPrintSettings* aPrintSettings) } -//---------------------------------------------------------------------------------- -// Helper Function - Free and reallocate the string -nsresult -nsDeviceContextSpecWin::SetPrintSettingsFromDevMode(nsIPrintSettings* aPrintSettings, - LPDEVMODE aDevMode) -{ - if (aPrintSettings == nsnull) { - return NS_ERROR_FAILURE; - } - BOOL doingNumCopies = aDevMode->dmFields & DM_COPIES; - BOOL doingOrientation = aDevMode->dmFields & DM_ORIENTATION; - BOOL doingPaperSize = aDevMode->dmFields & DM_PAPERSIZE; - BOOL doingPaperLength = aDevMode->dmFields & DM_PAPERLENGTH; - BOOL doingPaperWidth = aDevMode->dmFields & DM_PAPERWIDTH; - - if (doingOrientation) { - PRInt32 orientation = aDevMode->dmOrientation == DMORIENT_PORTRAIT? - nsIPrintSettings::kPortraitOrientation:nsIPrintSettings::kLandscapeOrientation; - aPrintSettings->SetOrientation(orientation); - } - - // Setup Number of Copies - if (doingNumCopies) { - aPrintSettings->SetNumCopies(PRInt32(aDevMode->dmCopies)); - } - - if (aDevMode->dmFields & DM_SCALE) { - double scale = double(aDevMode->dmScale) / 100.0f; - if (scale != 1.0) { - aPrintSettings->SetScaling(scale); - aDevMode->dmScale = 100; - // To turn this on you must change where the mPrt->mShrinkToFit is being set in the DocumentViewer - //aPrintSettings->SetShrinkToFit(PR_FALSE); - } - } - - if (doingPaperSize) { - aPrintSettings->SetPaperSizeType(nsIPrintSettings::kPaperSizeNativeData); - aPrintSettings->SetPaperData(aDevMode->dmPaperSize); - - } else if (doingPaperLength && doingPaperWidth) { - PRBool found = PR_FALSE; - for (PRInt32 i=0;idmPaperSize) { - aPrintSettings->SetPaperSizeType(nsIPrintSettings::kPaperSizeDefined); - aPrintSettings->SetPaperWidth(kPaperSizes[i].mWidth); - aPrintSettings->SetPaperHeight(kPaperSizes[i].mHeight); - aPrintSettings->SetPaperSizeUnit(kPaperSizes[i].mIsInches?nsIPrintSettings::kPaperSizeInches:nsIPrintSettings::kPaperSizeInches); - found = PR_TRUE; - break; - } - } - if (!found) { - return NS_ERROR_FAILURE; - } - } else { - return NS_ERROR_FAILURE; - } - return NS_OK; -} - -//---------------------------------------------------------------------------------- -NS_IMETHODIMP nsDeviceContextSpecWin::Init(nsIWidget* aWidget, - nsIPrintSettings* aPrintSettings, - PRBool aQuiet) -{ - mPrintSettings = aPrintSettings; - - gParentWnd = (HWND)aWidget->GetNativeData(NS_NATIVE_WINDOW); - - PRBool doNativeDialog = PR_FALSE; - nsresult rv = NS_ERROR_FAILURE; - nsCOMPtr pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv); - if (NS_SUCCEEDED(rv)) { - pPrefs->GetBoolPref("print.use_native_print_dialog", &doNativeDialog); - } - - if (doNativeDialog || aQuiet) { -#ifdef MOZ_REQUIRE_CURRENT_SDK - if (mUseExtendedPrintDlg) { - rv = ShowNativePrintDialogEx(aWidget, aQuiet); - } else { - rv = ShowNativePrintDialog(aWidget, aQuiet); - } -#else - rv = ShowNativePrintDialog(aWidget, aQuiet); -#endif - } else { - rv = ShowXPPrintDialog(aQuiet); - } - - return rv; -} - -//---------------------------------------------------------- -// Helper Function - Free and reallocate the string -static void CleanAndCopyString(char*& aStr, char* aNewStr) -{ - if (aStr != nsnull) { - if (aNewStr != nsnull && strlen(aStr) > strlen(aNewStr)) { // reuse it if we can - PL_strcpy(aStr, aNewStr); - return; - } else { - PR_Free(aStr); - aStr = nsnull; - } - } - - if (nsnull != aNewStr) { - aStr = (char *)PR_Malloc(PL_strlen(aNewStr) + 1); - PL_strcpy(aStr, aNewStr); - } -} - -//---------------------------------------------------------------------------------- -void nsDeviceContextSpecWin::SetDeviceName(char* aDeviceName) -{ - CleanAndCopyString(mDeviceName, aDeviceName); -} - -//---------------------------------------------------------------------------------- -void nsDeviceContextSpecWin::SetDriverName(char* aDriverName) -{ - CleanAndCopyString(mDriverName, aDriverName); -} - -//---------------------------------------------------------------------------------- -void nsDeviceContextSpecWin::SetGlobalDevMode(HGLOBAL aHGlobal) -{ - if (mGlobalDevMode) { - ::GlobalFree(mGlobalDevMode); - mGlobalDevMode = NULL; - } - mGlobalDevMode = aHGlobal; - mIsDEVMODEGlobalHandle = PR_TRUE; -} - -//---------------------------------------------------------------------------------- -void nsDeviceContextSpecWin::SetDevMode(LPDEVMODE aDevMode) -{ - if (mDevMode) free(mDevMode); - - mDevMode = aDevMode; - mIsDEVMODEGlobalHandle = PR_FALSE; -} - -//---------------------------------------------------------------------------------- -// Return localized bundle for resource strings -static nsresult -GetLocalizedBundle(const char * aPropFileName, nsIStringBundle** aStrBundle) -{ - NS_ENSURE_ARG_POINTER(aPropFileName); - NS_ENSURE_ARG_POINTER(aStrBundle); - - nsresult rv; - nsCOMPtr bundle; - - - // Create bundle - nsCOMPtr stringService = - do_GetService(kStringBundleServiceCID, &rv); - if (NS_SUCCEEDED(rv) && stringService) { - rv = stringService->CreateBundle(aPropFileName, aStrBundle); - } - - return rv; -} - -//-------------------------------------------------------- -// Return localized string -static nsresult -GetLocalizedString(nsIStringBundle* aStrBundle, const char* aKey, nsString& oVal) -{ - NS_ENSURE_ARG_POINTER(aStrBundle); - NS_ENSURE_ARG_POINTER(aKey); - - // Determine default label from string bundle - nsXPIDLString valUni; - nsAutoString key; - key.AssignWithConversion(aKey); - nsresult rv = aStrBundle->GetStringFromName(key.get(), getter_Copies(valUni)); - if (NS_SUCCEEDED(rv) && valUni) { - oVal.Assign(valUni); - } else { - oVal.Truncate(); - } - return rv; -} - -//-------------------------------------------------------- -// Set a multi-byte string in the control -static void SetTextOnWnd(HWND aControl, const nsString& aStr) -{ - char* pStr = nsDeviceContextWin::GetACPString(aStr); - if (pStr) { - ::SetWindowText(aControl, pStr); - delete [] pStr; - } -} - -//-------------------------------------------------------- -// Will get the control and localized string by "key" -static void SetText(HWND aParent, - UINT aId, - nsIStringBundle* aStrBundle, - const char* aKey) -{ - HWND wnd = GetDlgItem (aParent, aId); - if (!wnd) { - return; - } - nsAutoString str; - nsresult rv = GetLocalizedString(aStrBundle, aKey, str); - if (NS_SUCCEEDED(rv)) { - SetTextOnWnd(wnd, str); - } -} - -//-------------------------------------------------------- -static void SetRadio(HWND aParent, - UINT aId, - PRBool aIsSet, - PRBool isEnabled = PR_TRUE) -{ - HWND wnd = ::GetDlgItem (aParent, aId); - if (!wnd) { - return; - } - if (!isEnabled) { - ::EnableWindow(wnd, FALSE); - return; - } - ::EnableWindow(wnd, TRUE); - ::SendMessage(wnd, BM_SETCHECK, (WPARAM)aIsSet, (LPARAM)0); -} - -//-------------------------------------------------------- -static void SetRadioOfGroup(HWND aDlg, int aRadId) -{ - int radioIds[] = {rad4, rad5, rad6}; - int numRads = 3; - - for (int i=0;i strBundle; - if (NS_SUCCEEDED(GetLocalizedBundle(PRINTDLG_PROPERTIES, getter_AddRefs(strBundle)))) { - PRInt32 i = 0; - while (gAllPropKeys[i].mKeyStr != NULL) { - SetText(hdlg, gAllPropKeys[i].mKeyId, strBundle, gAllPropKeys[i].mKeyStr); - i++; - } - } - - // Set up radio buttons - if (aHowToEnableFrameUI == nsIPrintSettings::kFrameEnableAll) { - SetRadio(hdlg, rad4, PR_FALSE); - SetRadio(hdlg, rad5, PR_TRUE); - SetRadio(hdlg, rad6, PR_FALSE); - // set default so user doesn't have to actually press on it - gFrameSelectedRadioBtn = rad5; - - } else if (aHowToEnableFrameUI == nsIPrintSettings::kFrameEnableAsIsAndEach) { - SetRadio(hdlg, rad4, PR_FALSE); - SetRadio(hdlg, rad5, PR_FALSE, PR_FALSE); - SetRadio(hdlg, rad6, PR_TRUE); - // set default so user doesn't have to actually press on it - gFrameSelectedRadioBtn = rad6; - - - } else { // nsIPrintSettings::kFrameEnableNone - // we are using this function to disabe the group box - SetRadio(hdlg, grp3, PR_FALSE, PR_FALSE); - // now disable radiobuttons - SetRadio(hdlg, rad4, PR_FALSE, PR_FALSE); - SetRadio(hdlg, rad5, PR_FALSE, PR_FALSE); - SetRadio(hdlg, rad6, PR_FALSE, PR_FALSE); - } - -} - - -//-------------------------------------------------------- -// Special Hook Procedure for handling the print dialog messages -UINT CALLBACK PrintHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) -{ - - if (uiMsg == WM_COMMAND) { - UINT id = LOWORD(wParam); - if (id == rad4 || id == rad5 || id == rad6) { - gFrameSelectedRadioBtn = id; - SetRadioOfGroup(hdlg, id); - } - - } else if (uiMsg == WM_INITDIALOG) { - PRINTDLG * printDlg = (PRINTDLG *)lParam; - if (printDlg == NULL) return 0L; - - PRInt16 howToEnableFrameUI = (PRInt16)printDlg->lCustData; - - HINSTANCE hInst = (HINSTANCE)::GetWindowLong(hdlg, GWL_HINSTANCE); - if (hInst == NULL) return 0L; - - // Start by getting the local rects of several of the controls - // so we can calculate where the new controls are - HWND wnd = ::GetDlgItem(hdlg, grp1); - if (wnd == NULL) return 0L; - RECT dlgRect; - GetLocalRect(wnd, dlgRect, hdlg); - - wnd = ::GetDlgItem(hdlg, rad1); // this is the top control "All" - if (wnd == NULL) return 0L; - RECT rad1Rect; - GetLocalRect(wnd, rad1Rect, hdlg); - - wnd = ::GetDlgItem(hdlg, rad2); // this is the bottom control "Selection" - if (wnd == NULL) return 0L; - RECT rad2Rect; - GetLocalRect(wnd, rad2Rect, hdlg); - - wnd = ::GetDlgItem(hdlg, rad3); // this is the middle control "Pages" - if (wnd == NULL) return 0L; - RECT rad3Rect; - GetLocalRect(wnd, rad3Rect, hdlg); - - HWND okWnd = ::GetDlgItem(hdlg, IDOK); - if (okWnd == NULL) return 0L; - RECT okRect; - GetLocalRect(okWnd, okRect, hdlg); - - wnd = ::GetDlgItem(hdlg, grp4); // this is the "Print range" groupbox - if (wnd == NULL) return 0L; - RECT prtRect; - GetLocalRect(wnd, prtRect, hdlg); - - - // calculate various different "gaps" for layout purposes - - int rbGap = rad3Rect.top - rad1Rect.bottom; // gap between radiobtns - int grpBotGap = dlgRect.bottom - rad2Rect.bottom; // gap from bottom rb to bottom of grpbox - int grpGap = dlgRect.top - prtRect.bottom ; // gap between group boxes - int top = dlgRect.bottom + grpGap; - int radHgt = rad1Rect.bottom - rad1Rect.top + 1; // top of new group box - int y = top+(rad1Rect.top-dlgRect.top); // starting pos of first radio - int rbWidth = dlgRect.right - rad1Rect.left - 5; // measure from rb left to the edge of the groupbox - // (5 is arbitrary) - nsRect rect; - - // Create and position the radio buttons - // - // If any one control cannot be created then - // hide the others and bail out - // - rect.SetRect(rad1Rect.left, y, rbWidth,radHgt); - HWND rad4Wnd = CreateRadioBtn(hInst, hdlg, rad4, kAsLaidOutOnScreenStr, rect); - if (rad4Wnd == NULL) return 0L; - y += radHgt + rbGap; - - rect.SetRect(rad1Rect.left, y, rbWidth, radHgt); - HWND rad5Wnd = CreateRadioBtn(hInst, hdlg, rad5, kTheSelectedFrameStr, rect); - if (rad5Wnd == NULL) { - Show(rad4Wnd, FALSE); // hide - return 0L; - } - y += radHgt + rbGap; - - rect.SetRect(rad1Rect.left, y, rbWidth, radHgt); - HWND rad6Wnd = CreateRadioBtn(hInst, hdlg, rad6, kEachFrameSeparately, rect); - if (rad6Wnd == NULL) { - Show(rad4Wnd, FALSE); // hide - Show(rad5Wnd, FALSE); // hide - return 0L; - } - y += radHgt + grpBotGap; - - // Create and position the group box - rect.SetRect (dlgRect.left, top, dlgRect.right-dlgRect.left+1, y-top+1); - HWND grpBoxWnd = CreateGroupBox(hInst, hdlg, grp3, NS_LITERAL_STRING("Print Frame"), rect); - if (grpBoxWnd == NULL) { - Show(rad4Wnd, FALSE); // hide - Show(rad5Wnd, FALSE); // hide - Show(rad6Wnd, FALSE); // hide - return 0L; - } - - // Here we figure out the old height of the dlg - // then figure it's gap from the old grpbx to the bottom - // then size the dlg - RECT pr, cr; - ::GetWindowRect(hdlg, &pr); - ::GetClientRect(hdlg, &cr); - - int dlgHgt = (cr.bottom - cr.top) + 1; - int bottomGap = dlgHgt - okRect.bottom; - pr.bottom += (dlgRect.bottom-dlgRect.top) + grpGap + 1 - (dlgHgt-dlgRect.bottom) + bottomGap; - - ::SetWindowPos(hdlg, NULL, pr.left, pr.top, pr.right-pr.left+1, pr.bottom-pr.top+1, - SWP_NOMOVE|SWP_NOREDRAW|SWP_NOZORDER); - - // figure out the new height of the dialog - ::GetClientRect(hdlg, &cr); - dlgHgt = (cr.bottom - cr.top) + 1; - - // Reposition the OK and Cancel btns - int okHgt = okRect.bottom - okRect.top + 1; - ::SetWindowPos(okWnd, NULL, okRect.left, dlgHgt-bottomGap-okHgt, 0, 0, - SWP_NOSIZE|SWP_NOREDRAW|SWP_NOZORDER); - - HWND cancelWnd = ::GetDlgItem(hdlg, IDCANCEL); - if (cancelWnd == NULL) return 0L; - - RECT cancelRect; - GetLocalRect(cancelWnd, cancelRect, hdlg); - int cancelHgt = cancelRect.bottom - cancelRect.top + 1; - ::SetWindowPos(cancelWnd, NULL, cancelRect.left, dlgHgt-bottomGap-cancelHgt, 0, 0, - SWP_NOSIZE|SWP_NOREDRAW|SWP_NOZORDER); - - // localize and initialize the groupbox and radiobuttons - InitializeExtendedDialog(hdlg, howToEnableFrameUI); - - // Looks like we were able to extend the dialog - gDialogWasExtended = PR_TRUE; - } - return 0L; -} - -//---------------------------------------------------------------------------------- -// Returns a Global Moveable Memory Handle to a DevMode -// from the Printer byt the name of aPrintName -static HGLOBAL CreateGlobalDevModeAndInit(LPTSTR aPrintName, nsIPrintSettings* aPS) -{ - HGLOBAL hGlobalDevMode = NULL; - - nsresult rv = NS_ERROR_FAILURE; - HANDLE hPrinter = NULL; - BOOL status = ::OpenPrinter(aPrintName, &hPrinter, NULL); - if (status) { - - LPDEVMODE pNewDevMode; - DWORD dwNeeded, dwRet; - - // Allocate a buffer of the correct size. - dwNeeded = ::DocumentProperties(gParentWnd, hPrinter, aPrintName, NULL, NULL, 0); - - pNewDevMode = (LPDEVMODE)malloc(dwNeeded); - if (!pNewDevMode) return NULL; - - hGlobalDevMode = (HGLOBAL)::GlobalAlloc(GHND, dwNeeded); - if (!hGlobalDevMode) { - free(pNewDevMode); - } - - dwRet = ::DocumentProperties(gParentWnd, hPrinter, aPrintName, pNewDevMode, NULL, DM_OUT_BUFFER); - - if (dwRet != IDOK) { - free(pNewDevMode); - ::GlobalFree(hGlobalDevMode); - ::ClosePrinter(hPrinter); - return NULL; - } - - // Lock memory and copy contents from DEVMODE (current printer) - // to Global Memory DEVMODE - LPDEVMODE devMode = (DEVMODE *)::GlobalLock(hGlobalDevMode); - if (devMode) { - memcpy(devMode, pNewDevMode, dwNeeded); - // Initialize values from the PrintSettings - SetupDevModeFromSettings(devMode, aPS); - ::GlobalUnlock(hGlobalDevMode); - } else { - ::GlobalFree(hGlobalDevMode); - hGlobalDevMode = NULL; - } - - free(pNewDevMode); - - ::ClosePrinter(hPrinter); - - } else { - return NULL; - } - - return hGlobalDevMode; -} - -//------------------------------------------------------------------ -// helper -static PRUnichar * GetDefaultPrinterNameFromGlobalPrinters() -{ - PRUnichar * printerName; - LPTSTR lpPrtName; - GlobalPrinters::GetInstance()->GetDefaultPrinterName(lpPrtName); - nsString str; -#ifdef UNICODE - str.AppendWithConversion((PRUnichar *)lpPrtName); -#else - str.AssignWithConversion((char*)lpPrtName); -#endif - printerName = ToNewUnicode(str); - free(lpPrtName); - return printerName; -} - - -//------------------------------------------------------------------ -void -nsDeviceContextSpecWin::GetDevMode(LPDEVMODE &aDevMode) -{ - if (mIsDEVMODEGlobalHandle) { - if (mGlobalDevMode) { - aDevMode = (DEVMODE *)::GlobalLock(mGlobalDevMode); - } else { - aDevMode = NULL; - } - } else { - aDevMode = mDevMode; - } -} - -//------------------------------------------------------------------ -// Displays the native Print Dialog -nsresult -nsDeviceContextSpecWin::ShowNativePrintDialog(nsIWidget *aWidget, PRBool aQuiet) -{ - NS_ENSURE_ARG_POINTER(aWidget); - nsresult rv = NS_ERROR_FAILURE; - gDialogWasExtended = PR_FALSE; - - HGLOBAL hGlobalDevMode = NULL; - HGLOBAL hDevNames = NULL; - - // Get the Print Name to be used - PRUnichar * printerName; - mPrintSettings->GetPrinterName(&printerName); - - // If there is no name then use the default printer - if (!printerName || (printerName && !*printerName)) { - printerName = GetDefaultPrinterNameFromGlobalPrinters(); - } - - NS_ASSERTION(printerName, "We have to have a printer name"); - if (!printerName) return NS_ERROR_FAILURE; - - if (!aQuiet) { - // Now create a DEVNAMES struct so the the dialog is initialized correctly. - PRUint32 len = nsCRT::strlen(printerName); - PRUint32 len2 = len+sizeof(DEVNAMES); - hDevNames = (HGLOBAL)::GlobalAlloc(GHND, len+sizeof(DEVNAMES)+1); - DEVNAMES* pDevNames = (DEVNAMES*)::GlobalLock(hDevNames); - pDevNames->wDriverOffset = sizeof(DEVNAMES); - pDevNames->wDeviceOffset = sizeof(DEVNAMES); - pDevNames->wOutputOffset = sizeof(DEVNAMES)+len+1; - pDevNames->wDefault = 0; - char* device = &(((char*)pDevNames)[pDevNames->wDeviceOffset]); - strcpy(device, (char*)NS_ConvertUCS2toUTF8(printerName).get()); - ::GlobalUnlock(hDevNames); - - // Create a Moveable Memory Object that holds a new DevMode - // from the Printer Name - // The PRINTDLG.hDevMode requires that it be a moveable memory object - // NOTE: We only need to free hGlobalDevMode when the dialog is cancelled - // When the user prints, it comes back in the printdlg struct and - // is used and cleaned up later -#ifdef UNICODE - hGlobalDevMode = CreateGlobalDevModeAndInit(printerName, mPrintSettings); -#else - hGlobalDevMode = CreateGlobalDevModeAndInit((char*)NS_ConvertUCS2toUTF8(printerName).get(), mPrintSettings); -#endif - } else { - // For aQuiet create a LPDEVMODE from the printer name - // set it into the mDeviceMode - // then transfer the appropriate PrintSettnigs to it. - return GetDataFromPrinter(printerName, mPrintSettings); - } - - // Prepare to Display the Print Dialog - PRINTDLG prntdlg; - memset(&prntdlg, 0, sizeof(PRINTDLG)); - - prntdlg.lStructSize = sizeof(prntdlg); - prntdlg.hwndOwner = (HWND)aWidget->GetNativeData(NS_NATIVE_WINDOW); - prntdlg.hDevMode = hGlobalDevMode; - prntdlg.hDevNames = hDevNames; - prntdlg.hDC = NULL; - prntdlg.Flags = PD_ALLPAGES | PD_RETURNIC | PD_HIDEPRINTTOFILE | PD_USEDEVMODECOPIESANDCOLLATE; - - // if there is a current selection then enable the "Selection" radio button - PRInt16 howToEnableFrameUI = nsIPrintSettings::kFrameEnableNone; - if (mPrintSettings != nsnull) { - PRBool isOn; - mPrintSettings->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB, &isOn); - if (!isOn) { - prntdlg.Flags |= PD_NOSELECTION; - } - mPrintSettings->GetHowToEnableFrameUI(&howToEnableFrameUI); - } - - // Determine whether we have a completely native dialog - // or whether we cshould extend it - // true - do only the native - // false - extend the dialog - PRPackedBool doExtend = PR_FALSE; - nsCOMPtr strBundle; - if (NS_SUCCEEDED(GetLocalizedBundle(PRINTDLG_PROPERTIES, getter_AddRefs(strBundle)))) { - nsAutoString doExtendStr; - if (NS_SUCCEEDED(GetLocalizedString(strBundle, "extend", doExtendStr))) { - doExtend = doExtendStr.Equals(NS_LITERAL_STRING("true")); - } - } - - prntdlg.nFromPage = 0xFFFF; - prntdlg.nToPage = 0xFFFF; - prntdlg.nMinPage = 1; - prntdlg.nMaxPage = 0xFFFF; - prntdlg.nCopies = 1; - prntdlg.lpfnSetupHook = NULL; - prntdlg.lpSetupTemplateName = NULL; - prntdlg.hPrintTemplate = NULL; - prntdlg.hSetupTemplate = NULL; - - prntdlg.hInstance = NULL; - prntdlg.lpPrintTemplateName = NULL; - - if (!doExtend) { - prntdlg.lCustData = NULL; - prntdlg.lpfnPrintHook = NULL; - } else { - // Set up print dialog "hook" procedure for extending the dialog - prntdlg.lCustData = (DWORD)howToEnableFrameUI; - prntdlg.lpfnPrintHook = (LPPRINTHOOKPROC)PrintHookProc; - prntdlg.Flags |= PD_ENABLEPRINTHOOK; - } - - BOOL result = ::PrintDlg(&prntdlg); - - if (TRUE == result) { - if (mPrintSettings && prntdlg.hDevMode != NULL) { - // Transfer the settings from the native data to the PrintSettings - LPDEVMODE devMode = (LPDEVMODE)::GlobalLock(prntdlg.hDevMode); - SetPrintSettingsFromDevMode(mPrintSettings, devMode); - ::GlobalUnlock(prntdlg.hDevMode); - } - DEVNAMES *devnames = (DEVNAMES *)::GlobalLock(prntdlg.hDevNames); - if ( NULL != devnames ) { - - char* device = &(((char *)devnames)[devnames->wDeviceOffset]); - char* driver = &(((char *)devnames)[devnames->wDriverOffset]); - - // Setup local Data members - SetDeviceName(device); - SetDriverName(driver); - -#if defined(DEBUG_rods) || defined(DEBUG_dcone) - printf("printer: driver %s, device %s flags: %d\n", driver, device, prntdlg.Flags); -#endif - // fill the print options with the info from the dialog - if (mPrintSettings != nsnull) { - nsString printerName; - printerName.AssignWithConversion(device); - - mPrintSettings->SetPrinterName(printerName.get()); - - if (prntdlg.Flags & PD_SELECTION) { - mPrintSettings->SetPrintRange(nsIPrintSettings::kRangeSelection); - - } else if (prntdlg.Flags & PD_PAGENUMS) { - mPrintSettings->SetPrintRange(nsIPrintSettings::kRangeSpecifiedPageRange); - mPrintSettings->SetStartPageRange(prntdlg.nFromPage); - mPrintSettings->SetEndPageRange( prntdlg.nToPage); - - } else { // (prntdlg.Flags & PD_ALLPAGES) - mPrintSettings->SetPrintRange(nsIPrintSettings::kRangeAllPages); - } - - if (howToEnableFrameUI != nsIPrintSettings::kFrameEnableNone) { - // make sure the dialog got extended - if (gDialogWasExtended) { - // check to see about the frame radio buttons - switch (gFrameSelectedRadioBtn) { - case rad4: - mPrintSettings->SetPrintFrameType(nsIPrintSettings::kFramesAsIs); - break; - case rad5: - mPrintSettings->SetPrintFrameType(nsIPrintSettings::kSelectedFrame); - break; - case rad6: - mPrintSettings->SetPrintFrameType(nsIPrintSettings::kEachFrameSep); - break; - } // switch - } else { - // if it didn't get extended then have it default to printing - // each frame separately - mPrintSettings->SetPrintFrameType(nsIPrintSettings::kEachFrameSep); - } - } else { - mPrintSettings->SetPrintFrameType(nsIPrintSettings::kNoFrames); - } - } - ::GlobalUnlock(prntdlg.hDevNames); - -#if defined(DEBUG_rods) || defined(DEBUG_dcone) - PRBool printSelection = prntdlg.Flags & PD_SELECTION; - PRBool printAllPages = prntdlg.Flags & PD_ALLPAGES; - PRBool printNumPages = prntdlg.Flags & PD_PAGENUMS; - PRInt32 fromPageNum = 0; - PRInt32 toPageNum = 0; - - if (printNumPages) { - fromPageNum = prntdlg.nFromPage; - toPageNum = prntdlg.nToPage; - } - if (printSelection) { - printf("Printing the selection\n"); - - } else if (printAllPages) { - printf("Printing all the pages\n"); - - } else { - printf("Printing from page no. %d to %d\n", fromPageNum, toPageNum); - } -#endif - - SetGlobalDevMode(prntdlg.hDevMode); - - // Set into DevMode Paper Size and Orientation here - // remove comment if you want to override the values from - // the native setup with those specified in the Page Setup - // mainly Paper Size, Orientation - if (aQuiet) { - SetupPaperInfoFromSettings(); - } - - } - } else { - ::GlobalFree(hGlobalDevMode); - return NS_ERROR_ABORT; - } - - return NS_OK; -} - - -#ifdef MOZ_REQUIRE_CURRENT_SDK -//------------------------------------------------------------------ -// Callback for Property Sheet -BOOL APIENTRY PropSheetCallBack(HWND hdlg, UINT uiMsg, UINT wParam, LONG lParam) -{ - if (uiMsg == WM_COMMAND) { - UINT id = LOWORD(wParam); - if (id == rad4 || id == rad5 || id == rad6) { - gFrameSelectedRadioBtn = id; - SetRadioOfGroup(hdlg, id); - } - - } else if (uiMsg == WM_INITDIALOG) { - // Create the groupbox and Radiobuttons on the "Options" Property Sheet - - // We temporarily borrowed the global value for initialization - // now clear it before the dialog appears - PRInt16 howToEnableFrameUI = gFrameSelectedRadioBtn; - gFrameSelectedRadioBtn = 0; - - HINSTANCE hInst = (HINSTANCE)::GetWindowLong(hdlg, GWL_HINSTANCE); - if (hInst == NULL) return 0L; - - // Get default font for the dialog & then its font metrics - // we need the text height to determine the height of the radio buttons - TEXTMETRIC metrics; - HFONT hFont = (HFONT)::SendMessage(hdlg, WM_GETFONT, (WPARAM)0, (LPARAM)0); - HDC localDC = ::GetDC(hdlg); - ::SelectObject(localDC, (HGDIOBJ)hFont); - ::GetTextMetrics(localDC, &metrics); - ::ReleaseDC(hdlg, localDC); - - // calculate various different "gaps" for layout purposes - RECT dlgr; - ::GetWindowRect(hdlg, &dlgr); - - int horzGap = 5; // generic horz gap - int vertGap = 5; // generic vert gap - int rbGap = metrics.tmHeight / 2; // gap between radiobtns - int top = vertGap*2; // start at the top - int radHgt = metrics.tmHeight; // top of new group box - int y = top; // starting pos of first radio - int x = horzGap*2; - int rbWidth = dlgr.right - dlgr.left - (5*horzGap); - int grpWidth = dlgr.right - dlgr.left - (2*horzGap); - - nsRect rect; - - // Create and position the radio buttons - // - // If any one control cannot be created then - // hide the others and bail out - // - x += horzGap*2; - y += vertGap + metrics.tmHeight; - rect.SetRect(x, y, rbWidth,radHgt); - HWND rad4Wnd = CreateRadioBtn(hInst, hdlg, rad4, kAsLaidOutOnScreenStr, rect); - if (rad4Wnd == NULL) return 0L; - y += radHgt + rbGap; - - rect.SetRect(x, y, rbWidth, radHgt); - HWND rad5Wnd = CreateRadioBtn(hInst, hdlg, rad5, kTheSelectedFrameStr, rect); - if (rad5Wnd == NULL) { - Show(rad4Wnd, FALSE); // hide - return 0L; - } - y += radHgt + rbGap; - - rect.SetRect(x, y, rbWidth, radHgt); - HWND rad6Wnd = CreateRadioBtn(hInst, hdlg, rad6, kEachFrameSeparately, rect); - if (rad6Wnd == NULL) { - Show(rad4Wnd, FALSE); // hide - Show(rad5Wnd, FALSE); // hide - return 0L; - } - y += radHgt + (vertGap*2); - - x -= horzGap*2; - // Create and position the group box - rect.SetRect (x, top, grpWidth, y-top+1); - HWND grpBoxWnd = CreateGroupBox(hInst, hdlg, grp3, NS_LITERAL_STRING("Print Frame"), rect); - if (grpBoxWnd == NULL) { - Show(rad4Wnd, FALSE); // hide - Show(rad5Wnd, FALSE); // hide - Show(rad6Wnd, FALSE); // hide - return 0L; - } - - // localize and initialize the groupbox and radiobuttons - InitializeExtendedDialog(hdlg, howToEnableFrameUI); - - // Looks like we were able to extend the dialog - gDialogWasExtended = PR_TRUE; - } - return 0L; -} - -//------------------------------------------------------------------ -// Creates the "Options" Property Sheet -static HPROPSHEETPAGE ExtendPrintDialog(HWND aHWnd, char* aTitle) -{ - // The resource "OPTPROPSHEET" comes out of the widget/build/widget.rc file - HINSTANCE hInst = (HINSTANCE)::GetWindowLong(aHWnd, GWL_HINSTANCE); - PROPSHEETPAGE psp; - memset(&psp, 0, sizeof(PROPSHEETPAGE)); - psp.dwSize = sizeof(PROPSHEETPAGE); - psp.dwFlags = PSP_USETITLE | PSP_PREMATURE; - psp.hInstance = hInst; - psp.pszTemplate = "OPTPROPSHEET"; - psp.pfnDlgProc = PropSheetCallBack; - psp.pszTitle = aTitle?aTitle:"Options"; - - HPROPSHEETPAGE newPropSheet = ::CreatePropertySheetPage(&psp); - return newPropSheet; - -} - -//------------------------------------------------------------------ -// Displays the native Print Dialog -nsresult -nsDeviceContextSpecWin::ShowNativePrintDialogEx(nsIWidget *aWidget, PRBool aQuiet) -{ - NS_ENSURE_ARG_POINTER(aWidget); - - nsresult rv = NS_ERROR_FAILURE; - gDialogWasExtended = PR_FALSE; - - // Create a Moveable Memory Object that holds a new DevMode - // from the Printer Name - // The PRINTDLG.hDevMode requires that it be a moveable memory object - // NOTE: We only need to free hGlobalDevMode when the dialog is cancelled - // When the user prints, it comes back in the printdlg struct and - // is used and cleaned up later - PRUnichar * printerName; - mPrintSettings->GetPrinterName(&printerName); - HGLOBAL hGlobalDevMode = NULL; - if (printerName) { -#ifdef UNICODE - hGlobalDevMode = CreateGlobalDevModeAndInit(printerName, mPrintSettings); -#else - hGlobalDevMode = CreateGlobalDevModeAndInit((char*)NS_ConvertUCS2toUTF8(printerName).get(), mPrintSettings); -#endif - } - - // Prepare to Display the Print Dialog - PRINTDLGEX prntdlg; - memset(&prntdlg, 0, sizeof(PRINTDLGEX)); - - prntdlg.lStructSize = sizeof(prntdlg); - prntdlg.hwndOwner = (HWND)aWidget->GetNativeData(NS_NATIVE_WINDOW); - prntdlg.hDevMode = hGlobalDevMode; - prntdlg.Flags = PD_ALLPAGES | PD_RETURNDC | PD_HIDEPRINTTOFILE | PD_USEDEVMODECOPIESANDCOLLATE | - PD_NOCURRENTPAGE; - prntdlg.nStartPage = START_PAGE_GENERAL; - - // if there is a current selection then enable the "Selection" radio button - PRInt16 howToEnableFrameUI = nsIPrintSettings::kFrameEnableNone; - if (mPrintSettings != nsnull) { - PRBool isOn; - mPrintSettings->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB, &isOn); - if (!isOn) { - prntdlg.Flags |= PD_NOSELECTION; - } - mPrintSettings->GetHowToEnableFrameUI(&howToEnableFrameUI); - } - - // Determine whether we have a completely native dialog - // or whether we cshould extend it - // true - do only the native - // false - extend the dialog - PRPackedBool doExtend = PR_FALSE; - nsCOMPtr strBundle; - if (NS_SUCCEEDED(GetLocalizedBundle(PRINTDLG_PROPERTIES, getter_AddRefs(strBundle)))) { - nsAutoString doExtendStr; - if (NS_SUCCEEDED(GetLocalizedString(strBundle, "extend", doExtendStr))) { - doExtend = doExtendStr.EqualsIgnoreCase("true"); - } - } - - // At the moment we can only support one page range - // from all the documentation I can find, it appears that this - // will get cleanup automatically when the struct goes away - const int kNumPageRanges = 1; - LPPRINTPAGERANGE pPageRanges = (LPPRINTPAGERANGE) GlobalAlloc(GPTR, kNumPageRanges * sizeof(PRINTPAGERANGE)); - if (!pPageRanges) - return E_OUTOFMEMORY; - - prntdlg.nPageRanges = 0; - prntdlg.nMaxPageRanges = kNumPageRanges; - prntdlg.lpPageRanges = pPageRanges; - prntdlg.nMinPage = 1; - prntdlg.nMaxPage = 0xFFFF; - prntdlg.nCopies = 1; - - if (doExtend && !aQuiet) { - // lLcalize the Property Sheet (Tab) title - char* pTitle = NULL; - nsString optionsStr; - if (NS_SUCCEEDED(GetLocalizedString(strBundle, "options", optionsStr))) { - pTitle = nsDeviceContextWin::GetACPString(optionsStr); - } - - // Temporarily borrow this variable for setting up the radiobuttons - // if we don't use this, we will need to define a new global var - gFrameSelectedRadioBtn = howToEnableFrameUI; - HPROPSHEETPAGE psp[1]; - psp[0] = ExtendPrintDialog((HWND)aWidget->GetNativeData(NS_NATIVE_WINDOW), pTitle); - prntdlg.nPropertyPages = 1; - prntdlg.lphPropertyPages = psp; - } - - if (PR_TRUE == aQuiet){ - prntdlg.Flags = PD_ALLPAGES | PD_RETURNDEFAULT | PD_RETURNIC | PD_USEDEVMODECOPIESANDCOLLATE; - } - - HRESULT result = ::PrintDlgEx(&prntdlg); - - if (S_OK == result && - (prntdlg.dwResultAction == PD_RESULT_PRINT || - (prntdlg.dwResultAction == PD_RESULT_CANCEL && aQuiet))) { - if (mPrintSettings && prntdlg.hDevMode != NULL) { - // when it is quite use the printsettings passed - if (!aQuiet) { - LPDEVMODE devMode = (LPDEVMODE)::GlobalLock(prntdlg.hDevMode); - SetPrintSettingsFromDevMode(mPrintSettings, devMode); - ::GlobalUnlock(prntdlg.hDevMode); - } - } - DEVNAMES *devnames = (DEVNAMES *)::GlobalLock(prntdlg.hDevNames); - if ( NULL != devnames ) { - - char* device = &(((char *)devnames)[devnames->wDeviceOffset]); - char* driver = &(((char *)devnames)[devnames->wDriverOffset]); - - // Setup local Data members - SetDeviceName(device); - SetDriverName(driver); - -#if defined(DEBUG_rods) || defined(DEBUG_dcone) - printf("printer: driver %s, device %s flags: %d\n", driver, device, prntdlg.Flags); -#endif - ::GlobalUnlock(prntdlg.hDevNames); - - // fill the print options with the info from the dialog - if (mPrintSettings != nsnull) { - - if (prntdlg.Flags & PD_SELECTION) { - mPrintSettings->SetPrintRange(nsIPrintSettings::kRangeSelection); - - } else if (prntdlg.Flags & PD_PAGENUMS) { - mPrintSettings->SetPrintRange(nsIPrintSettings::kRangeSpecifiedPageRange); - mPrintSettings->SetStartPageRange(pPageRanges->nFromPage); - mPrintSettings->SetEndPageRange(pPageRanges->nToPage); - - } else { // (prntdlg.Flags & PD_ALLPAGES) - mPrintSettings->SetPrintRange(nsIPrintSettings::kRangeAllPages); - } - - if (howToEnableFrameUI != nsIPrintSettings::kFrameEnableNone) { - // make sure the dialog got extended - if (gDialogWasExtended) { - // check to see about the frame radio buttons - switch (gFrameSelectedRadioBtn) { - case rad4: - mPrintSettings->SetPrintFrameType(nsIPrintSettings::kFramesAsIs); - break; - case rad5: - mPrintSettings->SetPrintFrameType(nsIPrintSettings::kSelectedFrame); - break; - case rad6: - mPrintSettings->SetPrintFrameType(nsIPrintSettings::kEachFrameSep); - break; - } // switch - } else { - // if it didn't get extended then have it default to printing - // each frame separately - mPrintSettings->SetPrintFrameType(nsIPrintSettings::kEachFrameSep); - } - } else { - mPrintSettings->SetPrintFrameType(nsIPrintSettings::kNoFrames); - } - } - - -#if defined(DEBUG_rods) || defined(DEBUG_dcone) - PRBool printSelection = prntdlg.Flags & PD_SELECTION; - PRBool printAllPages = prntdlg.Flags & PD_ALLPAGES; - PRBool printNumPages = prntdlg.Flags & PD_PAGENUMS; - PRInt32 fromPageNum = 0; - PRInt32 toPageNum = 0; - - if (printNumPages) { - fromPageNum = pPageRanges->nFromPage; - toPageNum = pPageRanges->nToPage; - } - if (printSelection) { - printf("Printing the selection\n"); - - } else if (printAllPages) { - printf("Printing all the pages\n"); - - } else { - printf("Printing from page no. %d to %d\n", fromPageNum, toPageNum); - } -#endif - - SetGlobalDevMode(prntdlg.hDevMode); - - // Set into DevMode Paper Size and Orientation here - // remove comment if you want to override the values from - // the native setup with those specified in the Page Setup - // mainly Paper Size, Orientation - if (aQuiet) { - SetupPaperInfoFromSettings(); - } - - } - } else { - if (hGlobalDevMode) ::GlobalFree(hGlobalDevMode); - return NS_ERROR_ABORT; - } - - ::GlobalFree(pPageRanges); - - return NS_OK; -} -#endif // MOZ_REQUIRE_CURRENT_SDK - //---------------------------------------------------------------------------------- // Setup the object's data member with the selected printer's data nsresult @@ -1616,92 +693,64 @@ nsDeviceContextSpecWin::SetupPaperInfoFromSettings() } //---------------------------------------------------------------------------------- +// Helper Function - Free and reallocate the string nsresult -nsDeviceContextSpecWin::ShowXPPrintDialog(PRBool aQuiet) +nsDeviceContextSpecWin::SetPrintSettingsFromDevMode(nsIPrintSettings* aPrintSettings, + LPDEVMODE aDevMode) { - nsresult rv = NS_ERROR_FAILURE; + if (aPrintSettings == nsnull) { + return NS_ERROR_FAILURE; + } + BOOL doingNumCopies = aDevMode->dmFields & DM_COPIES; + BOOL doingOrientation = aDevMode->dmFields & DM_ORIENTATION; + BOOL doingPaperSize = aDevMode->dmFields & DM_PAPERSIZE; + BOOL doingPaperLength = aDevMode->dmFields & DM_PAPERLENGTH; + BOOL doingPaperWidth = aDevMode->dmFields & DM_PAPERWIDTH; - NS_ASSERTION(mPrintSettings, "Can't have a null PrintSettings!"); - - // if there is a current selection then enable the "Selection" radio button - PRBool isOn; - mPrintSettings->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB, &isOn); - nsCOMPtr pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv); - if (NS_SUCCEEDED(rv)) { - (void) pPrefs->SetBoolPref("print.selection_radio_enabled", isOn); + if (doingOrientation) { + PRInt32 orientation = aDevMode->dmOrientation == DMORIENT_PORTRAIT? + nsIPrintSettings::kPortraitOrientation:nsIPrintSettings::kLandscapeOrientation; + aPrintSettings->SetOrientation(orientation); } - PRBool canPrint = PR_FALSE; - if (!aQuiet ) { - rv = NS_ERROR_FAILURE; + // Setup Number of Copies + if (doingNumCopies) { + aPrintSettings->SetNumCopies(PRInt32(aDevMode->dmCopies)); + } - // create a nsISupportsArray of the parameters - // being passed to the window - nsCOMPtr array; - NS_NewISupportsArray(getter_AddRefs(array)); - if (!array) return NS_ERROR_FAILURE; + if (aDevMode->dmFields & DM_SCALE) { + double scale = double(aDevMode->dmScale) / 100.0f; + if (scale != 1.0) { + aPrintSettings->SetScaling(scale); + aDevMode->dmScale = 100; + // To turn this on you must change where the mPrt->mShrinkToFit is being set in the DocumentViewer + //aPrintSettings->SetShrinkToFit(PR_FALSE); + } + } - nsCOMPtr psSupports(do_QueryInterface(mPrintSettings)); - NS_ASSERTION(psSupports, "PrintSettings must be a supports"); - array->AppendElement(psSupports); + if (doingPaperSize) { + aPrintSettings->SetPaperSizeType(nsIPrintSettings::kPaperSizeNativeData); + aPrintSettings->SetPaperData(aDevMode->dmPaperSize); - nsCOMPtr ioParamBlock(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1")); - if (ioParamBlock) { - ioParamBlock->SetInt(0, 0); - nsCOMPtr blkSupps(do_QueryInterface(ioParamBlock)); - NS_ASSERTION(blkSupps, "IOBlk must be a supports"); - - array->AppendElement(blkSupps); - nsCOMPtr arguments(do_QueryInterface(array)); - NS_ASSERTION(array, "array must be a supports"); - - nsCOMPtr wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); - if (wwatch) { - nsCOMPtr active; - wwatch->GetActiveWindow(getter_AddRefs(active)); - nsCOMPtr parent = do_QueryInterface(active); - - nsCOMPtr newWindow; - rv = wwatch->OpenWindow(parent, "chrome://global/content/printdialog.xul", - "_blank", "chrome,modal,centerscreen", array, - getter_AddRefs(newWindow)); + } else if (doingPaperLength && doingPaperWidth) { + PRBool found = PR_FALSE; + for (PRInt32 i=0;idmPaperSize) { + aPrintSettings->SetPaperSizeType(nsIPrintSettings::kPaperSizeDefined); + aPrintSettings->SetPaperWidth(kPaperSizes[i].mWidth); + aPrintSettings->SetPaperHeight(kPaperSizes[i].mHeight); + aPrintSettings->SetPaperSizeUnit(kPaperSizes[i].mIsInches?nsIPrintSettings::kPaperSizeInches:nsIPrintSettings::kPaperSizeInches); + found = PR_TRUE; + break; } } - - if (NS_SUCCEEDED(rv)) { - PRInt32 buttonPressed = 0; - ioParamBlock->GetInt(0, &buttonPressed); - if (buttonPressed == 1) { - canPrint = PR_TRUE; - } else { - rv = NS_ERROR_ABORT; - } + if (!found) { + return NS_ERROR_FAILURE; } } else { - canPrint = PR_TRUE; + return NS_ERROR_FAILURE; } - - if (canPrint) { - if (mPrintSettings != nsnull) { - PRUnichar *printerName = nsnull; - mPrintSettings->GetPrinterName(&printerName); - - if (printerName != nsnull) { - // Gets DEVMODE, Device and Driver Names - rv = GetDataFromPrinter(printerName, mPrintSettings); - - nsMemory::Free(printerName); - } else { - rv = NS_ERROR_OUT_OF_MEMORY; - } - } - return NS_OK; - } - - // Free them, we won't need them for a while - GlobalPrinters::GetInstance()->FreeGlobalPrinters(); - - return rv; + return NS_OK; } //*********************************************************** diff --git a/mozilla/gfx/src/windows/nsDeviceContextSpecWin.h b/mozilla/gfx/src/windows/nsDeviceContextSpecWin.h index 91254c7a731..af22b266e65 100644 --- a/mozilla/gfx/src/windows/nsDeviceContextSpecWin.h +++ b/mozilla/gfx/src/windows/nsDeviceContextSpecWin.h @@ -51,7 +51,7 @@ public: NS_DECL_ISUPPORTS - NS_IMETHOD Init(nsIWidget* aWidget, nsIPrintSettings* aPS, PRBool aQuiet); + NS_IMETHOD Init(nsIWidget* aWidget, nsIPrintSettings* aPS, PRBool aIsPrintPreview); void GetDriverName(char *&aDriverName) const { aDriverName = mDriverName; } void GetDeviceName(char *&aDeviceName) const { aDeviceName = mDeviceName; } @@ -70,12 +70,6 @@ public: LPDEVMODE aDevMode); protected: - nsresult ShowXPPrintDialog(PRBool aQuiet); - nsresult ShowNativePrintDialog(nsIWidget* aWidget, PRBool aQuiet); - -#ifdef MOZ_REQUIRE_CURRENT_SDK - nsresult ShowNativePrintDialogEx(nsIWidget* aWidget, PRBool aQuiet); -#endif void SetDeviceName(char* aDeviceName); void SetDriverName(char* aDriverName); @@ -93,9 +87,6 @@ protected: PRBool mIsDEVMODEGlobalHandle; nsCOMPtr mPrintSettings; - - // For PrintDlgEx - FARPROC mUseExtendedPrintDlg; }; diff --git a/mozilla/gfx/src/windows/nsDeviceContextWin.cpp b/mozilla/gfx/src/windows/nsDeviceContextWin.cpp index 14d7ae71255..3a5d584f161 100644 --- a/mozilla/gfx/src/windows/nsDeviceContextWin.cpp +++ b/mozilla/gfx/src/windows/nsDeviceContextWin.cpp @@ -47,10 +47,7 @@ #include "nsGfxCIID.h" #include "nsReadableutils.h" -// Print Options -#include "nsIPrintOptions.h" #include "nsString.h" -static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID); #define DOC_TITLE_LENGTH 64 @@ -755,7 +752,7 @@ static void DisplayLastError() #endif -NS_IMETHODIMP nsDeviceContextWin :: BeginDocument(PRUnichar * aTitle) +NS_IMETHODIMP nsDeviceContextWin :: BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage) { nsresult rv = NS_ERROR_GFX_PRINTER_STARTDOC; @@ -771,21 +768,9 @@ NS_IMETHODIMP nsDeviceContextWin :: BeginDocument(PRUnichar * aTitle) char *title = GetACPString(titleStr); char* docName = nsnull; - nsCOMPtr printService = do_GetService(kPrintOptionsCID, &rv); - if (printService) { - PRBool printToFile = PR_FALSE; - printService->GetPrintToFile(&printToFile); - if (printToFile) { - PRUnichar* uStr; - printService->GetToFileName(&uStr); - if (uStr != nsnull) { - nsAutoString str(uStr); - if (str.Length() > 0) { - docName = ToNewCString(str); - } - nsMemory::Free(uStr); - } - } + nsAutoString str(aPrintToFileName); + if (str.Length() > 0) { + docName = ToNewCString(str); } docinfo.cbSize = sizeof(docinfo); docinfo.lpszDocName = title != nsnull?title:"Mozilla Document"; diff --git a/mozilla/gfx/src/windows/nsDeviceContextWin.h b/mozilla/gfx/src/windows/nsDeviceContextWin.h index 90895b4c119..db4c33c9d6f 100644 --- a/mozilla/gfx/src/windows/nsDeviceContextWin.h +++ b/mozilla/gfx/src/windows/nsDeviceContextWin.h @@ -84,7 +84,7 @@ public: NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice, nsIDeviceContext *&aContext); - NS_IMETHOD BeginDocument(PRUnichar * aTitle); + NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage); NS_IMETHOD EndDocument(void); NS_IMETHOD AbortDocument(void); diff --git a/mozilla/gfx/src/xlib/Makefile.in b/mozilla/gfx/src/xlib/Makefile.in index 8e88bfdb015..f6522f694a7 100644 --- a/mozilla/gfx/src/xlib/Makefile.in +++ b/mozilla/gfx/src/xlib/Makefile.in @@ -38,10 +38,6 @@ REQUIRES = xpcom \ string \ xlibrgb \ widget \ - dom \ - layout \ - content \ - appshell \ js \ necko \ pref \ @@ -53,7 +49,6 @@ REQUIRES = xpcom \ gfx2 \ imglib2 \ mozcomps \ - windowwatcher \ intl \ $(NULL) diff --git a/mozilla/gfx/src/xlib/nsDeviceContextSpecFactoryX.cpp b/mozilla/gfx/src/xlib/nsDeviceContextSpecFactoryX.cpp index 0108332c461..384929b940a 100644 --- a/mozilla/gfx/src/xlib/nsDeviceContextSpecFactoryX.cpp +++ b/mozilla/gfx/src/xlib/nsDeviceContextSpecFactoryX.cpp @@ -62,14 +62,14 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryXlib::Init(void) NS_IMETHODIMP nsDeviceContextSpecFactoryXlib::CreateDeviceContextSpec(nsIWidget *aWidget, nsIPrintSettings* aPrintSettings, nsIDeviceContextSpec *&aNewSpec, - PRBool aQuiet) + PRBool aIsPrintPreview) { nsresult rv; static NS_DEFINE_CID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID); nsCOMPtr devSpec = do_CreateInstance(kDeviceContextSpecCID, &rv); if (NS_SUCCEEDED(rv)) { - rv = ((nsDeviceContextSpecXlib *)devSpec.get())->Init(aPrintSettings, aQuiet); + rv = ((nsDeviceContextSpecXlib *)devSpec.get())->Init(aPrintSettings); if (NS_SUCCEEDED(rv)) { aNewSpec = devSpec; diff --git a/mozilla/gfx/src/xlib/nsDeviceContextSpecFactoryX.h b/mozilla/gfx/src/xlib/nsDeviceContextSpecFactoryX.h index 7441831e940..d99c78680ed 100644 --- a/mozilla/gfx/src/xlib/nsDeviceContextSpecFactoryX.h +++ b/mozilla/gfx/src/xlib/nsDeviceContextSpecFactoryX.h @@ -54,7 +54,7 @@ public: NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget, nsIPrintSettings* aPrintSettings, nsIDeviceContextSpec *&aNewSpec, - PRBool aQuiet); + PRBool aIsPrintPreview); protected: virtual ~nsDeviceContextSpecFactoryXlib(); diff --git a/mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp b/mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp index 454187b50e5..ac5fd901fba 100644 --- a/mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp +++ b/mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp @@ -51,16 +51,9 @@ #include "nsIPref.h" #include "prenv.h" /* for PR_GetEnv */ -#include "nsIDOMWindowInternal.h" -#include "nsIServiceManager.h" -#include "nsIDialogParamBlock.h" -#include "nsISupportsPrimitives.h" -#include "nsIWindowWatcher.h" - -#include "nsReadableUtils.h" -#include "nsISupportsArray.h" - #include "nsPrintfCString.h" +#include "nsReadableUtils.h" +#include "nsIServiceManager.h" #ifdef USE_XPRINT #include "xprintutil.h" @@ -254,66 +247,6 @@ NS_IMPL_ISUPPORTS1(nsDeviceContextSpecXlib, #error "This should not happen" #endif -/** ------------------------------------------------------- - */ -static nsresult DisplayXPDialog(nsIPrintSettings* aPS, - const char* aChromeURL, - PRBool& aClickedOK) -{ - DO_PR_DEBUG_LOG(("nsDeviceContextSpecXlib::DisplayXPDialog()\n")); - NS_ASSERTION(aPS, "Must have a print settings!"); - - aClickedOK = PR_FALSE; - nsresult rv = NS_ERROR_FAILURE; - - // create a nsISupportsArray of the parameters - // being passed to the window - nsCOMPtr array; - NS_NewISupportsArray(getter_AddRefs(array)); - if (!array) return NS_ERROR_FAILURE; - - nsCOMPtr ps = aPS; - nsCOMPtr psSupports(do_QueryInterface(ps)); - NS_ASSERTION(psSupports, "PrintSettings must be a supports"); - array->AppendElement(psSupports); - - nsCOMPtr ioParamBlock(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1")); - if (ioParamBlock) { - ioParamBlock->SetInt(0, 0); - nsCOMPtr blkSupps(do_QueryInterface(ioParamBlock)); - NS_ASSERTION(blkSupps, "IOBlk must be a supports"); - - array->AppendElement(blkSupps); - nsCOMPtr arguments(do_QueryInterface(array)); - NS_ASSERTION(array, "array must be a supports"); - - nsCOMPtr wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); - if (wwatch) { - nsCOMPtr active; - wwatch->GetActiveWindow(getter_AddRefs(active)); - nsCOMPtr parent = do_QueryInterface(active); - - nsCOMPtr newWindow; - rv = wwatch->OpenWindow(parent, aChromeURL, - "_blank", "chrome,modal,centerscreen", array, - getter_AddRefs(newWindow)); - } - } - - if (NS_SUCCEEDED(rv)) { - PRInt32 buttonPressed = 0; - ioParamBlock->GetInt(0, &buttonPressed); - if (buttonPressed == 1) { - aClickedOK = PR_TRUE; - } else { - rv = NS_ERROR_ABORT; - } - } else { - rv = NS_ERROR_ABORT; - } - return rv; -} - /** ------------------------------------------------------- * Initialize the nsDeviceContextSpecXlib * @update dc 2/15/98 @@ -323,19 +256,19 @@ static nsresult DisplayXPDialog(nsIPrintSettings* aPS, * toolkits including: * - GTK+-toolkit: * file: mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp - * function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init(PRBool aQuiet) + * function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init() * - Xlib-toolkit: * file: mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp - * function: NS_IMETHODIMP nsDeviceContextSpecXlib::Init(PRBool aQuiet) + * function: NS_IMETHODIMP nsDeviceContextSpecXlib::Init() * - Qt-toolkit: * file: mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp - * function: NS_IMETHODIMP nsDeviceContextSpecQT::Init(PRBool aQuiet) + * function: NS_IMETHODIMP nsDeviceContextSpecQT::Init() * * ** Please update the other toolkits when changing this function. */ -NS_IMETHODIMP nsDeviceContextSpecXlib::Init(nsIPrintSettings *aPS, PRBool aQuiet) +NS_IMETHODIMP nsDeviceContextSpecXlib::Init(nsIPrintSettings *aPS) { - DO_PR_DEBUG_LOG(("nsDeviceContextSpecXlib::Init(aPS=%p. qQuiet=%d)\n", aPS, (int)aQuiet)); + DO_PR_DEBUG_LOG(("nsDeviceContextSpecXlib::Init(aPS=%p\n", aPS)); nsresult rv = NS_ERROR_FAILURE; mPrintSettings = aPS; @@ -350,88 +283,76 @@ NS_IMETHODIMP nsDeviceContextSpecXlib::Init(nsIPrintSettings *aPS, PRBool aQuiet } } - PRBool canPrint = PR_FALSE; - rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters(); if (NS_FAILED(rv)) { return rv; } - if (!aQuiet) { - rv = DisplayXPDialog(mPrintSettings, - "chrome://global/content/printdialog.xul", canPrint); - } else { - rv = NS_OK; - canPrint = PR_TRUE; - } - GlobalPrinters::GetInstance()->FreeGlobalPrinters(); - if (NS_SUCCEEDED(rv) && canPrint) { - if (aPS) { - PRBool reversed = PR_FALSE; - PRBool color = PR_FALSE; - PRBool tofile = PR_FALSE; - PRInt16 printRange = nsIPrintSettings::kRangeAllPages; - PRInt32 orientation = NS_PORTRAIT; - PRInt32 fromPage = 1; - PRInt32 toPage = 1; - PRUnichar *command = nsnull; - PRInt32 copies = 1; - PRUnichar *printer = nsnull; - PRUnichar *papername = nsnull; - PRUnichar *printfile = nsnull; - double dleft = 0.5; - double dright = 0.5; - double dtop = 0.5; - double dbottom = 0.5; + if (aPS) { + PRBool reversed = PR_FALSE; + PRBool color = PR_FALSE; + PRBool tofile = PR_FALSE; + PRInt16 printRange = nsIPrintSettings::kRangeAllPages; + PRInt32 orientation = NS_PORTRAIT; + PRInt32 fromPage = 1; + PRInt32 toPage = 1; + PRUnichar *command = nsnull; + PRInt32 copies = 1; + PRUnichar *printer = nsnull; + PRUnichar *papername = nsnull; + PRUnichar *printfile = nsnull; + double dleft = 0.5; + double dright = 0.5; + double dtop = 0.5; + double dbottom = 0.5; - aPS->GetPrinterName(&printer); - aPS->GetPrintReversed(&reversed); - aPS->GetPrintInColor(&color); - aPS->GetPaperName(&papername); - aPS->GetOrientation(&orientation); - aPS->GetPrintCommand(&command); - aPS->GetPrintRange(&printRange); - aPS->GetToFileName(&printfile); - aPS->GetPrintToFile(&tofile); - aPS->GetStartPageRange(&fromPage); - aPS->GetEndPageRange(&toPage); - aPS->GetNumCopies(&copies); - aPS->GetMarginTop(&dtop); - aPS->GetMarginLeft(&dleft); - aPS->GetMarginBottom(&dbottom); - aPS->GetMarginRight(&dright); + aPS->GetPrinterName(&printer); + aPS->GetPrintReversed(&reversed); + aPS->GetPrintInColor(&color); + aPS->GetPaperName(&papername); + aPS->GetOrientation(&orientation); + aPS->GetPrintCommand(&command); + aPS->GetPrintRange(&printRange); + aPS->GetToFileName(&printfile); + aPS->GetPrintToFile(&tofile); + aPS->GetStartPageRange(&fromPage); + aPS->GetEndPageRange(&toPage); + aPS->GetNumCopies(&copies); + aPS->GetMarginTop(&dtop); + aPS->GetMarginLeft(&dleft); + aPS->GetMarginBottom(&dbottom); + aPS->GetMarginRight(&dright); - if (printfile) - strcpy(mPath, NS_ConvertUCS2toUTF8(printfile).get()); - if (command) - strcpy(mCommand, NS_ConvertUCS2toUTF8(command).get()); - if (printer) - strcpy(mPrinter, NS_ConvertUCS2toUTF8(printer).get()); - if (papername) - strcpy(mPaperName, NS_ConvertUCS2toUTF8(papername).get()); + if (printfile) + strcpy(mPath, NS_ConvertUCS2toUTF8(printfile).get()); + if (command) + strcpy(mCommand, NS_ConvertUCS2toUTF8(command).get()); + if (printer) + strcpy(mPrinter, NS_ConvertUCS2toUTF8(printer).get()); + if (papername) + strcpy(mPaperName, NS_ConvertUCS2toUTF8(papername).get()); - DO_PR_DEBUG_LOG(("margins: %5.2f,%5.2f,%5.2f,%5.2f\n", dtop, dleft, dbottom, dright)); - DO_PR_DEBUG_LOG(("printRange %d\n", printRange)); - DO_PR_DEBUG_LOG(("fromPage %d\n", fromPage)); - DO_PR_DEBUG_LOG(("toPage %d\n", toPage)); - DO_PR_DEBUG_LOG(("tofile %d\n", tofile)); - DO_PR_DEBUG_LOG(("printfile '%s'\n", printfile? NS_ConvertUCS2toUTF8(printfile).get():"")); - DO_PR_DEBUG_LOG(("command '%s'\n", command? NS_ConvertUCS2toUTF8(command).get():"")); - DO_PR_DEBUG_LOG(("printer '%s'\n", printer? NS_ConvertUCS2toUTF8(printer).get():"")); - DO_PR_DEBUG_LOG(("papername '%s'\n", papername? NS_ConvertUCS2toUTF8(papername).get():"")); + DO_PR_DEBUG_LOG(("margins: %5.2f,%5.2f,%5.2f,%5.2f\n", dtop, dleft, dbottom, dright)); + DO_PR_DEBUG_LOG(("printRange %d\n", printRange)); + DO_PR_DEBUG_LOG(("fromPage %d\n", fromPage)); + DO_PR_DEBUG_LOG(("toPage %d\n", toPage)); + DO_PR_DEBUG_LOG(("tofile %d\n", tofile)); + DO_PR_DEBUG_LOG(("printfile '%s'\n", printfile? NS_ConvertUCS2toUTF8(printfile).get():"")); + DO_PR_DEBUG_LOG(("command '%s'\n", command? NS_ConvertUCS2toUTF8(command).get():"")); + DO_PR_DEBUG_LOG(("printer '%s'\n", printer? NS_ConvertUCS2toUTF8(printer).get():"")); + DO_PR_DEBUG_LOG(("papername '%s'\n", papername? NS_ConvertUCS2toUTF8(papername).get():"")); - mTop = dtop; - mBottom = dbottom; - mLeft = dleft; - mRight = dright; - mFpf = !reversed; - mGrayscale = !color; - mOrientation = orientation; - mToPrinter = !tofile; - mCopies = copies; - } + mTop = dtop; + mBottom = dbottom; + mLeft = dleft; + mRight = dright; + mFpf = !reversed; + mGrayscale = !color; + mOrientation = orientation; + mToPrinter = !tofile; + mCopies = copies; } return rv; @@ -993,19 +914,7 @@ NS_IMETHODIMP nsPrinterEnumeratorXlib::InitPrintSettingsFromPrinter(const PRUnic NS_IMETHODIMP nsPrinterEnumeratorXlib::DisplayPropertiesDlg(const PRUnichar *aPrinter, nsIPrintSettings *aPrintSettings) { - /* fixme: We simply ignore the |aPrinter| argument here - * We should get the supported printer attributes from the printer and - * populate the print job options dialog with these data instead of using - * the "default set" here. - * However, this requires changes on all platforms and is another big chunk - * of patches ... ;-( - */ - - PRBool pressedOK; - return DisplayXPDialog(aPrintSettings, - "chrome://global/content/printjoboptions.xul", - pressedOK); - + return NS_OK; } //---------------------------------------------------------------------- diff --git a/mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.h b/mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.h index eb135d979fc..f65ca943541 100644 --- a/mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.h +++ b/mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.h @@ -74,7 +74,7 @@ public: NS_DECL_ISUPPORTS - NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet); + NS_IMETHOD Init(nsIPrintSettings* aPS); NS_IMETHOD ClosePrintManager(); NS_IMETHOD GetToPrinter(PRBool &aToPrinter); diff --git a/mozilla/gfx/src/xlib/nsDeviceContextXlib.cpp b/mozilla/gfx/src/xlib/nsDeviceContextXlib.cpp index c8e839c9204..b19ac5570cd 100644 --- a/mozilla/gfx/src/xlib/nsDeviceContextXlib.cpp +++ b/mozilla/gfx/src/xlib/nsDeviceContextXlib.cpp @@ -460,7 +460,7 @@ NS_IMETHODIMP nsDeviceContextXlib::GetDeviceContextFor(nsIDeviceContextSpec *aDe return NS_ERROR_UNEXPECTED; } -NS_IMETHODIMP nsDeviceContextXlib::BeginDocument(PRUnichar * aTitle) +NS_IMETHODIMP nsDeviceContextXlib::BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage) { PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::BeginDocument()\n")); return NS_OK; diff --git a/mozilla/gfx/src/xlib/nsDeviceContextXlib.h b/mozilla/gfx/src/xlib/nsDeviceContextXlib.h index 7d90f547cdf..53c35b69793 100644 --- a/mozilla/gfx/src/xlib/nsDeviceContextXlib.h +++ b/mozilla/gfx/src/xlib/nsDeviceContextXlib.h @@ -73,7 +73,7 @@ public: NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice, nsIDeviceContext *&aContext); - NS_IMETHOD BeginDocument(PRUnichar * aTitle); + NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage); NS_IMETHOD EndDocument(void); NS_IMETHOD AbortDocument(void); diff --git a/mozilla/gfx/src/xprint/nsDeviceContextXP.cpp b/mozilla/gfx/src/xprint/nsDeviceContextXP.cpp index 16b113c4dc2..0c85cc932d3 100644 --- a/mozilla/gfx/src/xprint/nsDeviceContextXP.cpp +++ b/mozilla/gfx/src/xprint/nsDeviceContextXP.cpp @@ -303,12 +303,12 @@ NS_IMETHODIMP nsDeviceContextXp::GetDeviceContextFor(nsIDeviceContextSpec *aDevi /** --------------------------------------------------- * See documentation in nsIDeviceContext.h */ -NS_IMETHODIMP nsDeviceContextXp::BeginDocument(PRUnichar * aTitle) +NS_IMETHODIMP nsDeviceContextXp::BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage) { PR_LOG(nsDeviceContextXpLM, PR_LOG_DEBUG, ("nsDeviceContextXp::BeginDocument()\n")); nsresult rv = NS_OK; if (mPrintContext != nsnull) { - rv = mPrintContext->BeginDocument(aTitle); + rv = mPrintContext->BeginDocument(aTitle, aPrintToFileName, aStartPage, aEndPage); } return rv; } diff --git a/mozilla/gfx/src/xprint/nsDeviceContextXP.h b/mozilla/gfx/src/xprint/nsDeviceContextXP.h index 53113cd1350..5374ed4d4de 100644 --- a/mozilla/gfx/src/xprint/nsDeviceContextXP.h +++ b/mozilla/gfx/src/xprint/nsDeviceContextXP.h @@ -80,7 +80,7 @@ public: NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,nsIDeviceContext *&aContext); NS_IMETHOD GetSystemFont(nsSystemFontID anID, nsFont *aFont) const; - NS_IMETHOD BeginDocument(PRUnichar * aTitle); + NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage); NS_IMETHOD EndDocument(void); NS_IMETHOD AbortDocument(void); NS_IMETHOD BeginPage(void); diff --git a/mozilla/gfx/src/xprint/nsXPrintContext.cpp b/mozilla/gfx/src/xprint/nsXPrintContext.cpp index 239aeed8f69..5629004e699 100644 --- a/mozilla/gfx/src/xprint/nsXPrintContext.cpp +++ b/mozilla/gfx/src/xprint/nsXPrintContext.cpp @@ -685,7 +685,7 @@ nsXPrintContext::SetResolution( void ) } NS_IMETHODIMP -nsXPrintContext::BeginDocument( PRUnichar *aTitle ) +nsXPrintContext::BeginDocument( PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage ) { PR_LOG(nsXPrintContextLM, PR_LOG_DEBUG, ("nsXPrintContext::BeginDocument(aTitle='%s')\n", ((aTitle)?(NS_ConvertUCS2toUTF8(aTitle).get()):("")))); diff --git a/mozilla/gfx/src/xprint/nsXPrintContext.h b/mozilla/gfx/src/xprint/nsXPrintContext.h index b46be4472fa..035fe5979ea 100644 --- a/mozilla/gfx/src/xprint/nsXPrintContext.h +++ b/mozilla/gfx/src/xprint/nsXPrintContext.h @@ -73,7 +73,7 @@ public: NS_IMETHOD Init(nsDeviceContextXp *dc, nsIDeviceContextSpecXp *aSpec); NS_IMETHOD BeginPage(); NS_IMETHOD EndPage(); - NS_IMETHOD BeginDocument(PRUnichar *aTitle); + NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage); NS_IMETHOD EndDocument(); NS_IMETHOD AbortDocument(); diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index 532483db0a8..bced580c86c 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -161,6 +161,10 @@ static NS_DEFINE_IID(kPrinterEnumeratorCID, NS_PRINTER_ENUMERATOR_CID); #include "nsIWindowWatcher.h" #include "nsIStringBundle.h" +// Printing Prompts +#include "nsIPrintingPromptService.h" +const char* kPrintingPromptService = "@mozilla.org/embedcomp/printingprompt-service;1"; + #define NS_ERROR_GFX_PRINTER_BUNDLE_URL "chrome://global/locale/printing.properties" // FrameSet @@ -215,12 +219,12 @@ static const char * gPrintRangeStr[] = {"kRangeAllPages", "kRangeSpecified static PRUint32 gDumpFileNameCnt = 0; static PRUint32 gDumpLOFileNameCnt = 0; -#define PRINT_DEBUG_MSG1(_msg1) fprintf(mPrt->mDebugFD, (_msg1)); -#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_MSG4(_msg1, _msg2, _msg3, _msg4) fprintf(mPrt->mDebugFD, (_msg1), (_msg2), (_msg3), (_msg4)); -#define PRINT_DEBUG_MSG5(_msg1, _msg2, _msg3, _msg4, _msg5) fprintf(mPrt->mDebugFD, (_msg1), (_msg2), (_msg3), (_msg4), (_msg5)); -#define PRINT_DEBUG_FLUSH fflush(mPrt->mDebugFD); +#define PRINT_DEBUG_MSG1(_msg1) if (mPrt && mPrt->mDebugFD) fprintf(mPrt->mDebugFD, (_msg1)); +#define PRINT_DEBUG_MSG2(_msg1, _msg2) if (mPrt && mPrt->mDebugFD) fprintf(mPrt->mDebugFD, (_msg1), (_msg2)); +#define PRINT_DEBUG_MSG3(_msg1, _msg2, _msg3) if (mPrt && mPrt->mDebugFD) fprintf(mPrt->mDebugFD, (_msg1), (_msg2), (_msg3)); +#define PRINT_DEBUG_MSG4(_msg1, _msg2, _msg3, _msg4) if (mPrt && mPrt->mDebugFD) fprintf(mPrt->mDebugFD, (_msg1), (_msg2), (_msg3), (_msg4)); +#define PRINT_DEBUG_MSG5(_msg1, _msg2, _msg3, _msg4, _msg5) if (mPrt && mPrt->mDebugFD) fprintf(mPrt->mDebugFD, (_msg1), (_msg2), (_msg3), (_msg4), (_msg5)); +#define PRINT_DEBUG_FLUSH if (mPrt && mPrt->mDebugFD) fflush(mPrt->mDebugFD); #else //-------------- #define PRT_YESNO(_p) #define PRINT_DEBUG_MSG1(_msg) @@ -398,7 +402,9 @@ private: class PrintData { public: - PrintData(); + typedef enum ePrintDataType {eIsPrinting, eIsPrintPreview }; + + PrintData(ePrintDataType aType); ~PrintData(); // non-virtual // Listener Helper Methods @@ -410,6 +416,7 @@ public: PRBool aDoStartStop = PR_FALSE, PRInt32 aFlag = 0); + ePrintDataType mType; // the type of data this is (Printing or Print Preview) nsCOMPtr mPrintDC; nsIView *mPrintView; FILE *mDebugFilePtr; // a file where information can go to when printing @@ -466,6 +473,7 @@ public: #endif private: + PrintData() {} PrintData& operator=(const PrintData& aOther); // not implemented }; @@ -711,7 +719,6 @@ protected: nsIPageSequenceFrame* mPageSeqFrame; - PRBool mIsPrinting; PrintData* mPrt; nsPagePrintTimer* mPagePrintTimer; @@ -878,8 +885,8 @@ static nsresult NS_NewUpdateTimer(nsPagePrintTimer **aResult) //--------------------------------------------------- //-- PrintData Class Impl //--------------------------------------------------- -PrintData::PrintData() : - mPrintView(nsnull), mDebugFilePtr(nsnull), mPrintObject(nsnull), mSelectedPO(nsnull), +PrintData::PrintData(ePrintDataType aType) : + mType(aType), mPrintView(nsnull), mDebugFilePtr(nsnull), mPrintObject(nsnull), mSelectedPO(nsnull), mShowProgressDialog(PR_TRUE), mPrintDocList(nsnull), mIsIFrameSelected(PR_FALSE), mIsParentAFrameSet(PR_FALSE), mPrintingAsIsSubDoc(PR_FALSE), mOnStartSent(PR_FALSE), mIsAborted(PR_FALSE), mPreparingForPrint(PR_FALSE), mDocWasToBeDestroyed(PR_FALSE), @@ -940,13 +947,15 @@ PrintData::~PrintData() mPrintSettings->GetIsCancelled(&isCancelled); nsresult rv = NS_OK; - if (!isCancelled && !mIsAborted) { - rv = mPrintDC->EndDocument(); - } else { - rv = mPrintDC->AbortDocument(); - } - if (NS_FAILED(rv)) { - DocumentViewerImpl::ShowPrintErrorDialog(rv); + if (mType == eIsPrinting) { + if (!isCancelled && !mIsAborted) { + rv = mPrintDC->EndDocument(); + } else { + rv = mPrintDC->AbortDocument(); + } + if (NS_FAILED(rv)) { + DocumentViewerImpl::ShowPrintErrorDialog(rv); + } } } @@ -1103,7 +1112,6 @@ void DocumentViewerImpl::PrepareToStartLoad() mStopped = PR_FALSE; mLoaded = PR_FALSE; mPrt = nsnull; - mIsPrinting = PR_FALSE; #ifdef NS_PRINT_PREVIEW mIsDoingPrintPreview = PR_FALSE; @@ -4312,7 +4320,7 @@ DocumentViewerImpl::FindXMostFrameInList(nsIPresContext* aPresContext, xMost = 0; } -#ifdef DEBUG_PRINTING // keep this here but leave it turned off +#ifdef DEBUG_PRINTING_X // keep this here but leave it turned off nsAutoString tmp; nsIFrameDebug* frameDebug; if (NS_SUCCEEDED(CallQueryInterface(child, &frameDebug))) { @@ -4323,7 +4331,7 @@ DocumentViewerImpl::FindXMostFrameInList(nsIPresContext* aPresContext, if (xMost > aMaxWidth) { aMaxWidth = xMost; -#ifdef DEBUG_PRINTING // keep this here but leave it turned off +#ifdef DEBUG_PRINTING_X // keep this here but leave it turned off printf("%p - %d %s ", child, aMaxWidth, NS_LossyConvertUCS2toASCII(tmp).get()); if (aList == nsLayoutAtoms::overflowList) printf(" nsLayoutAtoms::overflowList\n"); if (aList == nsLayoutAtoms::floaterList) printf(" nsLayoutAtoms::floaterList\n"); @@ -4453,7 +4461,7 @@ DocumentViewerImpl::SetupToPrintContent(nsIWebShell* aParent, } // Only Shrink if we are smaller - if (mPrt->mShrinkRatio < 1.0f) { + if (mPrt->mShrinkRatio < 0.998f) { // Clamp Shrink to Fit to 50% mPrt->mShrinkRatio = PR_MAX(mPrt->mShrinkRatio, 0.5f); @@ -4471,6 +4479,30 @@ DocumentViewerImpl::SetupToPrintContent(nsIWebShell* aParent, return NS_ERROR_FAILURE; } } +#ifdef DEBUG_rods + { + float calcRatio; + if (mPrt->mPrintDocList->Count() > 1 && mPrt->mPrintObject->mFrameType == eFrameSet) { + PrintObject* xMostPO = FindXMostPO(); + NS_ASSERTION(xMostPO, "There must always be an XMost PO!"); + if (xMostPO) { + // The margin is included in the PO's mRect so we need to subtract it + nsMargin margin(0,0,0,0); + mPrt->mPrintSettings->GetMarginInTwips(margin); + nsRect rect = xMostPO->mRect; + rect.x -= margin.left; + // Calc the shrinkage based on the entire content area + calcRatio = float(rect.XMost()) / float(rect.x + xMostPO->mXMost); + } + } else { + // Single document so use the Shrink as calculated for the PO + calcRatio = mPrt->mPrintObject->mShrinkRatio; + } + printf("**************************************************************************\n"); + printf("STF Ratio is: %8.5f Effective Ratio: %8.5f Diff: %8.5f\n", mPrt->mShrinkRatio, calcRatio, mPrt->mShrinkRatio-calcRatio); + printf("**************************************************************************\n"); + } +#endif } DUMP_DOC_LIST("\nAfter Reflow------------------------------------------"); @@ -4510,12 +4542,54 @@ DocumentViewerImpl::SetupToPrintContent(nsIWebShell* aParent, mPrt->mPrintDocDW = aCurrentFocusedDOMWin; + PRUnichar* fileName = nsnull; + // check to see if we are printing to a file + PRBool isPrintToFile = PR_FALSE; + mPrt->mPrintSettings->GetPrintToFile(&isPrintToFile); + if (isPrintToFile) { + // On some platforms The BeginDocument needs to know the name of the file + // and it uses the PrintService to get it, so we need to set it into the PrintService here + mPrt->mPrintSettings->GetToFileName(&fileName); + } + + PRUnichar * docTitleStr; + PRUnichar * docURLStr; + GetDisplayTitleAndURL(mPrt->mPrintObject, mPrt->mPrintSettings, mPrt->mBrandName, &docTitleStr, &docURLStr, eDocTitleDefURLDoc); + + PRInt32 startPage = 1; + PRInt32 endPage = mPrt->mNumPrintablePages; + + PRInt16 printRangeType = nsIPrintSettings::kRangeAllPages; + mPrt->mPrintSettings->GetPrintRange(&printRangeType); + if (printRangeType == nsIPrintSettings::kRangeSpecifiedPageRange) { + mPrt->mPrintSettings->GetStartPageRange(&startPage); + mPrt->mPrintSettings->GetEndPageRange(&endPage); + if (endPage > mPrt->mNumPrintablePages) { + endPage = mPrt->mNumPrintablePages; + } + } + + nsresult rv = NS_OK; + // BeginDocument may pass back a FAILURE code + // i.e. On Windows, if you are printing to a file and hit "Cancel" + // to the "File Name" dialog, this comes back as an error + // Don't start printing when regression test are executed + if (!mPrt->mDebugFilePtr && mIsDoingPrinting) { + rv = mPrt->mPrintDC->BeginDocument(docTitleStr, fileName, startPage, endPage); + } + + PRINT_DEBUG_MSG1("****************** Begin Document ************************\n"); + + if (docTitleStr) nsMemory::Free(docTitleStr); + if (docURLStr) nsMemory::Free(docURLStr); + + NS_ENSURE_SUCCESS(rv, rv); + // This will print the webshell document // when it completes asynchronously in the DonePrintingPages method // it will check to see if there are more webshells to be printed and // then PrintDocContent will be called again. - nsresult rv = NS_OK; if (mIsDoingPrinting) { PrintDocContent(mPrt->mPrintObject, rv); // ignore return value } @@ -4688,23 +4762,11 @@ DocumentViewerImpl::DoPrint(PrintObject * aPO, PRBool aDoSyncPrinting, PRBool& a #endif if (mPrt->mPrintSettings) { + PRUnichar * docTitleStr = nsnull; + PRUnichar * docURLStr = nsnull; + if (!skipSetTitle) { - PRUnichar * docTitleStr; - PRUnichar * docURLStr; - GetDisplayTitleAndURL(aPO, mPrt->mPrintSettings, mPrt->mBrandName, - &docTitleStr, &docURLStr, eDocTitleDefBlank); - - // Set them down into the PrintOptions so - // they can used by the DeviceContext - if (docTitleStr) { - mPrt->mPrintOptions->SetTitle(docTitleStr); - nsMemory::Free(docTitleStr); - } - - if (docURLStr) { - mPrt->mPrintOptions->SetDocURL(docURLStr); - nsMemory::Free(docURLStr); - } + GetDisplayTitleAndURL(aPO, mPrt->mPrintSettings, mPrt->mBrandName, &docTitleStr, &docURLStr, eDocTitleDefBlank); } if (nsIPrintSettings::kRangeSelection == printRangeType) { @@ -4794,7 +4856,7 @@ DocumentViewerImpl::DoPrint(PrintObject * aPO, PRBool aDoSyncPrinting, PRBool& a rootFrame->SetRect(poPresContext, r); mPageSeqFrame = pageSequence; - mPageSeqFrame->StartPrint(poPresContext, mPrt->mPrintSettings); + mPageSeqFrame->StartPrint(poPresContext, mPrt->mPrintSettings, docTitleStr, docURLStr); if (!aDoSyncPrinting) { // Get the delay time in between the printing of each page @@ -5493,25 +5555,26 @@ DocumentViewerImpl::IsThereAnIFrameSelected(nsIWebShell* aWebShell, { aIsParentFrameSet = IsParentAFrameSet(aWebShell); PRBool iFrameIsSelected = PR_FALSE; -#if 1 - PrintObject* po = FindPrintObjectByDOMWin(mPrt->mPrintObject, aDOMWin); - iFrameIsSelected = po && po->mFrameType == eIFrame; -#else - // First, check to see if we are a frameset - if (!aIsParentFrameSet) { - // Check to see if there is a currenlt focused frame - // if so, it means the selected frame is either the main webshell - // or an IFRAME - if (aDOMWin != nsnull) { - // Get the main webshell's DOMWin to see if it matches - // the frame that is selected - nsCOMPtr domWin = getter_AddRefs(GetDOMWinForWebShell(aWebShell)); - if (aDOMWin != nsnull && domWin != aDOMWin) { - iFrameIsSelected = PR_TRUE; // we have a selected IFRAME + if (mPrt && mPrt->mPrintObject) { + PrintObject* po = FindPrintObjectByDOMWin(mPrt->mPrintObject, aDOMWin); + iFrameIsSelected = po && po->mFrameType == eIFrame; + } else { + // First, check to see if we are a frameset + if (!aIsParentFrameSet) { + // Check to see if there is a currenlt focused frame + // if so, it means the selected frame is either the main webshell + // or an IFRAME + if (aDOMWin != nsnull) { + // Get the main webshell's DOMWin to see if it matches + // the frame that is selected + nsCOMPtr domWin = getter_AddRefs(GetDOMWinForWebShell(aWebShell)); + if (aDOMWin != nsnull && domWin != aDOMWin) { + iFrameIsSelected = PR_TRUE; // we have a selected IFRAME + } } } } -#endif + return iFrameIsSelected; } @@ -6326,7 +6389,7 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings) mPrtPreview = nsnull; } - mPrt = new PrintData(); + mPrt = new PrintData(PrintData::eIsPrintPreview); if (!mPrt) { mIsCreatingPrintPreview = PR_FALSE; return NS_ERROR_OUT_OF_MEMORY; @@ -6380,7 +6443,6 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings) // Let's print ... mIsCreatingPrintPreview = PR_TRUE; mIsDoingPrintPreview = PR_TRUE; - aPrintSettings->SetIsPrintPreview(mIsDoingPrintPreview); // Very important! Turn Off scripting TurnScriptingOn(PR_FALSE); @@ -6399,7 +6461,6 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings) if (!mPrt->mPrintDocList) { mIsCreatingPrintPreview = PR_FALSE; mIsDoingPrintPreview = PR_FALSE; - aPrintSettings->SetIsPrintPreview(mIsDoingPrintPreview); TurnScriptingOn(PR_TRUE); return NS_ERROR_OUT_OF_MEMORY; } @@ -6468,8 +6529,6 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings) } #endif - PRBool doSilent = PR_TRUE; - nscoord width = NS_INCHES_TO_TWIPS(8.5); nscoord height = NS_INCHES_TO_TWIPS(11.0); @@ -6478,7 +6537,7 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings) if (factory) { nsCOMPtr devspec; nsCOMPtr dx; - nsresult rv = factory->CreateDeviceContextSpec(mWindow, aPrintSettings, *getter_AddRefs(devspec), doSilent); + nsresult rv = factory->CreateDeviceContextSpec(mWindow, aPrintSettings, *getter_AddRefs(devspec), PR_TRUE); if (NS_SUCCEEDED(rv)) { rv = mDeviceContext->GetDeviceContextFor(devspec, *getter_AddRefs(ppDC)); if (NS_SUCCEEDED(rv)) { @@ -6496,9 +6555,7 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings) } } - if (doSilent) { - mPrt->mPrintSettings->SetPrintFrameType(nsIPrintSettings::kFramesAsIs); - } + mPrt->mPrintSettings->SetPrintFrameType(nsIPrintSettings::kFramesAsIs); // override any UI that wants to PrintPreview any selection PRInt16 printRangeType = nsIPrintSettings::kRangeAllPages; @@ -6603,28 +6660,20 @@ DocumentViewerImpl::SetDocAndURLIntoProgress(PrintObject* aPO, docURLStr = ToNewUnicode(newURLStr); } - mPrt->mPrintProgressParams->SetDocTitle((const PRUnichar*) docTitleStr); - mPrt->mPrintProgressParams->SetDocURL((const PRUnichar*) docURLStr); + aParams->SetDocTitle((const PRUnichar*) docTitleStr); + aParams->SetDocURL((const PRUnichar*) docURLStr); if (docTitleStr != nsnull) nsMemory::Free(docTitleStr); if (docURLStr != nsnull) nsMemory::Free(docURLStr); } +//---------------------------------------------------------------------- +// Set up to use the "pluggable" Print Progress Dialog void DocumentViewerImpl::DoPrintProgress(PRBool aIsForPrinting) { - nsPrintProgress* prtProgress = new nsPrintProgress(); - nsresult rv = prtProgress->QueryInterface(NS_GET_IID(nsIPrintProgress), (void**)getter_AddRefs(mPrt->mPrintProgress)); - if (NS_FAILED(rv)) return; - - - rv = prtProgress->QueryInterface(NS_GET_IID(nsIWebProgressListener), (void**)getter_AddRefs(mPrt->mPrintProgressListener)); - if (NS_FAILED(rv)) return; - // add to listener list - mPrt->mPrintProgressListeners.AppendElement((void*)mPrt->mPrintProgressListener); - nsIWebProgressListener* wpl = NS_STATIC_CAST(nsIWebProgressListener*, mPrt->mPrintProgressListener.get()); - NS_ASSERTION(wpl, "nsIWebProgressListener is NULL!"); - NS_ADDREF(wpl); + // Assume we can't do progress and then see if we can + mPrt->mShowProgressDialog = PR_FALSE; nsCOMPtr prefs (do_GetService(NS_PREF_CONTRACTID)); if (prefs) { @@ -6638,21 +6687,29 @@ DocumentViewerImpl::DoPrintProgress(PRBool aIsForPrinting) mPrt->mPrintSettings->GetShowPrintProgress(&mPrt->mShowProgressDialog); } - if (mPrt->mShowProgressDialog) { - nsPrintProgressParams* prtProgressParams = new nsPrintProgressParams(); - nsCOMPtr params; - rv = prtProgressParams->QueryInterface(NS_GET_IID(nsIPrintProgressParams), (void**)getter_AddRefs(mPrt->mPrintProgressParams)); - if (NS_SUCCEEDED(rv) && mPrt->mPrintProgressParams) { - SetDocAndURLIntoProgress(mPrt->mPrintObject, mPrt->mPrintProgressParams); + // Now open the service to get the progress dialog + nsCOMPtr printPromptService(do_GetService(kPrintingPromptService)); + if (printPromptService) { + nsCOMPtr scriptGlobalObject; + mDocument->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject)); + if (!scriptGlobalObject) return; + nsCOMPtr domWin = do_QueryInterface(scriptGlobalObject); + if (!domWin) return; - nsCOMPtr wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); - if (wwatch) { - nsCOMPtr active; - wwatch->GetActiveWindow(getter_AddRefs(active)); + // If we don't get a service, that's ok, then just don't show progress + if (mPrt->mShowProgressDialog) { + PRBool notifyOnOpen; + nsresult rv = printPromptService->ShowProgress(domWin, this, mPrt->mPrintSettings, nsnull, getter_AddRefs(mPrt->mPrintProgressListener), getter_AddRefs(mPrt->mPrintProgressParams), ¬ifyOnOpen); + if (NS_SUCCEEDED(rv)) { + mPrt->mShowProgressDialog = mPrt->mPrintProgressListener != nsnull && mPrt->mPrintProgressParams != nsnull; - PRBool notifyOnOpen; - nsCOMPtr parent(do_QueryInterface(active)); - mPrt->mPrintProgress->OpenProgressDialog(parent, "chrome://global/content/printProgress.xul", mPrt->mPrintProgressParams, nsnull, ¬ifyOnOpen); + if (mPrt->mShowProgressDialog) { + mPrt->mPrintProgressListeners.AppendElement((void*)mPrt->mPrintProgressListener); + nsIWebProgressListener* wpl = NS_STATIC_CAST(nsIWebProgressListener*, mPrt->mPrintProgressListener.get()); + NS_ASSERTION(wpl, "nsIWebProgressListener is NULL!"); + NS_ADDREF(wpl); + SetDocAndURLIntoProgress(mPrt->mPrintObject, mPrt->mPrintProgressParams); + } } } } @@ -6687,6 +6744,7 @@ DocumentViewerImpl::Print(PRBool aSilent, NS_ASSERTION(printSettings, "You can't PrintPreview without a PrintSettings!"); } if (printSettings) printSettings->SetPrintSilent(aSilent); + if (printSettings) printSettings->SetShowPrintProgress(PR_FALSE); #endif @@ -6750,9 +6808,9 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings, ShowPrintErrorDialog(rv); return rv; } - - mPrt = new PrintData(); - if (mPrt == nsnull) { + + mPrt = new PrintData(PrintData::eIsPrinting); + if (!mPrt) { return NS_ERROR_OUT_OF_MEMORY; } @@ -6889,14 +6947,55 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings, mPrt->mDebugFilePtr = mDebugFile; #endif - // we have to turn off printpreview mode for now.. because this is a real request to print. - if (mIsDoingPrintPreview) { - aPrintSettings->SetIsPrintPreview(PR_FALSE); - } - PRBool printSilently; mPrt->mPrintSettings->GetPrintSilent(&printSilently); - rv = factory->CreateDeviceContextSpec(mWindow, mPrt->mPrintSettings, *getter_AddRefs(devspec), printSilently); + + // Ask dialog to be Print Shown via the Plugable Printing Dialog Service + // This service is for the Print Dialog and the Print Progress Dialog + // If printing silently or you can't get the service continue on + if (!printSilently) { + nsCOMPtr printPromptService(do_GetService(kPrintingPromptService)); + if (printPromptService) { + nsCOMPtr scriptGlobalObject; + mDocument->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject)); + if (!scriptGlobalObject) return nsnull; + nsCOMPtr domWin = do_QueryInterface(scriptGlobalObject); + if (!domWin) return nsnull; + + // Platforms not implementing a given dialog for the service may + // return NS_ERROR_NOT_IMPLEMENTED or an error code. + // + // NS_ERROR_NOT_IMPLEMENTED indicates they want default behavior + // Any other error code means we must bail out + // + rv = printPromptService->ShowPrintDialog(domWin, this, aPrintSettings); + if (rv == NS_ERROR_NOT_IMPLEMENTED) { + // This means the Dialog service was there, + // but they choose not to implement this dialog and + // are looking for default behavior from the toolkit + rv = NS_OK; + + } else if (NS_SUCCEEDED(rv)) { + // since we got the dialog and it worked then make sure we + // are telling GFX we want to print silent + printSilently = PR_TRUE; + } + } else { + rv = NS_ERROR_GFX_NO_PRINTROMPTSERVICE; + } + } + + if (NS_FAILED(rv)) { + if (rv != NS_ERROR_ABORT) { + ShowPrintErrorDialog(rv); + } + delete mPrt; + mPrt = nsnull; + return rv; + } + + // Create DeviceSpec for Printing + rv = factory->CreateDeviceContextSpec(mWindow, mPrt->mPrintSettings, *getter_AddRefs(devspec), PR_FALSE); // If the page was intended to be destroyed while we were in the print dialog // then we need to clean up and abort the printing. @@ -7020,76 +7119,43 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings, } } - if (mPrt->mPrintOptions) { - // check to see if we are printing to a file - PRBool isPrintToFile = PR_FALSE; - mPrt->mPrintSettings->GetPrintToFile(&isPrintToFile); - if (isPrintToFile) { - // On some platforms The BeginDocument needs to know the name of the file + // Get the Needed info for Calling PrepareDocument + PRUnichar* fileName = nsnull; + // check to see if we are printing to a file + PRBool isPrintToFile = PR_FALSE; + mPrt->mPrintSettings->GetPrintToFile(&isPrintToFile); + if (isPrintToFile) { + // On some platforms The PrepareDocument needs to know the name of the file // and it uses the PrintService to get it, so we need to set it into the PrintService here - PRUnichar* fileName; - mPrt->mPrintSettings->GetToFileName(&fileName); - if (fileName != nsnull) { - mPrt->mPrintOptions->SetPrintToFile(PR_TRUE); - mPrt->mPrintOptions->SetToFileName(fileName); - nsMemory::Free(fileName); - } - } else { - mPrt->mPrintOptions->SetPrintToFile(PR_FALSE); - mPrt->mPrintOptions->SetToFileName(nsnull); - } + mPrt->mPrintSettings->GetToFileName(&fileName); } PRUnichar * docTitleStr; PRUnichar * docURLStr; - GetDisplayTitleAndURL(mPrt->mPrintObject, mPrt->mPrintSettings, - mPrt->mBrandName, &docTitleStr, &docURLStr, - eDocTitleDefURLDoc); - // BeginDocument may pass back a FAILURE code - // i.e. On Windows, if you are printing to a file and hit "Cancel" - // to the "File Name" dialog, this comes back as an error - // Don't start printing when regression test are executed - rv = mPrt->mDebugFilePtr ? NS_OK: mPrt->mPrintDC->BeginDocument(docTitleStr); - PRINT_DEBUG_MSG1("****************** Begin Document ************************\n"); + GetDisplayTitleAndURL(mPrt->mPrintObject, mPrt->mPrintSettings, mPrt->mBrandName, &docTitleStr, &docURLStr, eDocTitleDefURLDoc); + + rv = mPrt->mPrintDC->PrepareDocument(docTitleStr, fileName); if (docTitleStr) nsMemory::Free(docTitleStr); if (docURLStr) nsMemory::Free(docURLStr); + NS_ENSURE_SUCCESS(rv, rv); - if (NS_SUCCEEDED(rv)) { + DoPrintProgress(PR_TRUE); - DoPrintProgress(PR_TRUE); - - // Print listener setup... - if (mPrt != nsnull) { - mPrt->OnStartPrinting(); - } - - // - // The mIsPrinting flag is set when the ImageGroup observer is - // notified that images must be loaded as a result of the - // InitialReflow... - // - if(!mIsPrinting || mPrt->mDebugFilePtr) { - rv = DocumentReadyForPrinting(); - PRINT_DEBUG_MSG1("PRINT JOB ENDING, OBSERVER WAS NOT CALLED\n"); - } else { - // use the observer mechanism to finish the printing - PRINT_DEBUG_MSG1("PRINTING OBSERVER STARTED\n"); - } + // Print listener setup... + if (mPrt != nsnull) { + mPrt->OnStartPrinting(); } + + rv = DocumentReadyForPrinting(); + PRINT_DEBUG_MSG1("PRINT JOB ENDING, OBSERVER WAS NOT CALLED\n"); } } } } else { mPrt->mPrintSettings->SetIsCancelled(PR_TRUE); - mPrt->mPrintOptions->SetIsCancelled(PR_TRUE); } - - // Set that we are once again in print preview - if (mIsDoingPrintPreview) { - aPrintSettings->SetIsPrintPreview(PR_TRUE); - } } /* cleaup on failure + notify user */ @@ -7175,6 +7241,8 @@ DocumentViewerImpl::ShowPrintErrorDialog(nsresult aPrintError, PRBool aIsPrintin NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTER_XPRINT_BROKEN_XPRT) NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTER_DOC_IS_BUSY_PP) NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTER_DOC_WAS_DESTORYED) + NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_NO_PRINTDIALOG_IN_TOOLKIT) + NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_NO_PRINTROMPTSERVICE) NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTER_NO_XUL) // Temporary code for Bug 136185 default: @@ -8299,12 +8367,10 @@ DocumentViewerImpl::GetCurrentPrintSettings(nsIPrintSettings * *aCurrentPrintSet NS_IMETHODIMP DocumentViewerImpl::Cancel() { - nsresult rv; - nsCOMPtr printService = do_GetService(kPrintOptionsCID, &rv); - if (NS_SUCCEEDED(rv) && printService) { - return printService->SetIsCancelled(PR_TRUE); + if (mPrt && mPrt->mPrintSettings) { + return mPrt->mPrintSettings->SetIsCancelled(PR_TRUE); } - return NS_OK; + return NS_ERROR_FAILURE; } /* void initPrintSettingsFromPrefs (in nsIPrintSettings aPrintSettings, in boolean aUsePrinterNamePrefix, in unsigned long aFlags); */ diff --git a/mozilla/layout/base/public/nsIPageSequenceFrame.h b/mozilla/layout/base/public/nsIPageSequenceFrame.h index d2d06d975d2..ca667f97445 100644 --- a/mozilla/layout/base/public/nsIPageSequenceFrame.h +++ b/mozilla/layout/base/public/nsIPageSequenceFrame.h @@ -131,7 +131,9 @@ public: * @see nsIPrintStatusCallback#OnProgress() */ NS_IMETHOD StartPrint(nsIPresContext* aPresContext, - nsIPrintSettings* aPrintOptions) = 0; + nsIPrintSettings* aPrintOptions, + PRUnichar* aDocTitle, + PRUnichar* aDocURL) = 0; NS_IMETHOD PrintNextPage(nsIPresContext* aPresContext) = 0; NS_IMETHOD GetCurrentPageNum(PRInt32* aPageNum) = 0; NS_IMETHOD GetNumPages(PRInt32* aNumPages) = 0; diff --git a/mozilla/layout/generic/nsIPageSequenceFrame.h b/mozilla/layout/generic/nsIPageSequenceFrame.h index d2d06d975d2..ca667f97445 100644 --- a/mozilla/layout/generic/nsIPageSequenceFrame.h +++ b/mozilla/layout/generic/nsIPageSequenceFrame.h @@ -131,7 +131,9 @@ public: * @see nsIPrintStatusCallback#OnProgress() */ NS_IMETHOD StartPrint(nsIPresContext* aPresContext, - nsIPrintSettings* aPrintOptions) = 0; + nsIPrintSettings* aPrintOptions, + PRUnichar* aDocTitle, + PRUnichar* aDocURL) = 0; NS_IMETHOD PrintNextPage(nsIPresContext* aPresContext) = 0; NS_IMETHOD GetCurrentPageNum(PRInt32* aPageNum) = 0; NS_IMETHOD GetNumPages(PRInt32* aNumPages) = 0; diff --git a/mozilla/layout/generic/nsPageFrame.cpp b/mozilla/layout/generic/nsPageFrame.cpp index 9038236d5f6..3e29d1b6066 100644 --- a/mozilla/layout/generic/nsPageFrame.cpp +++ b/mozilla/layout/generic/nsPageFrame.cpp @@ -410,17 +410,13 @@ nsPageFrame::ProcessSpecialCodes(const nsString& aStr, nsString& aNewStr) NS_NAMED_LITERAL_STRING(kTitle, "&T"); if (aStr.Find(kTitle) != kNotFound) { - nsXPIDLString uTitle; - mPD->mPrintOptions->GetTitle(getter_Copies(uTitle)); - SubstValueForCode(aNewStr, kTitle.get(), uTitle.get()); + SubstValueForCode(aNewStr, kTitle.get(), mPD->mDocTitle); return; } NS_NAMED_LITERAL_STRING(kDocURL, "&U"); if (aStr.Find(kDocURL) != kNotFound) { - nsXPIDLString uDocURL; - mPD->mPrintOptions->GetDocURL(getter_Copies(uDocURL)); - SubstValueForCode(aNewStr, kDocURL.get(), uDocURL.get()); + SubstValueForCode(aNewStr, kDocURL.get(), mPD->mDocURL); return; } } diff --git a/mozilla/layout/generic/nsSimplePageSequence.cpp b/mozilla/layout/generic/nsSimplePageSequence.cpp index 06cdd46e7fa..4569dfc5529 100644 --- a/mozilla/layout/generic/nsSimplePageSequence.cpp +++ b/mozilla/layout/generic/nsSimplePageSequence.cpp @@ -111,6 +111,8 @@ nsSharedPageData::nsSharedPageData() : mHeadFootFont(nsnull), mPageNumFormat(nsnull), mPageNumAndTotalsFormat(nsnull), + mDocTitle(nsnull), + mDocURL(nsnull), mReflowRect(0,0,0,0), mReflowMargin(0,0,0,0), mShadowSize(0,0), @@ -126,6 +128,8 @@ nsSharedPageData::~nsSharedPageData() if (mHeadFootFont) delete mHeadFootFont; nsMemory::Free(mPageNumFormat); nsMemory::Free(mPageNumAndTotalsFormat); + if (mDocTitle) nsMemory::Free(mDocTitle); + if (mDocURL) nsMemory::Free(mDocURL); } nsresult @@ -660,8 +664,10 @@ nsIRegion* nsSimplePageSequenceFrame::CreateRegion() } NS_IMETHODIMP -nsSimplePageSequenceFrame::StartPrint(nsIPresContext* aPresContext, - nsIPrintSettings* aPrintSettings) +nsSimplePageSequenceFrame::StartPrint(nsIPresContext* aPresContext, + nsIPrintSettings* aPrintSettings, + PRUnichar* aDocTitle, + PRUnichar* aDocURL) { NS_ENSURE_ARG_POINTER(aPresContext); NS_ENSURE_ARG_POINTER(aPrintSettings); @@ -670,6 +676,10 @@ nsSimplePageSequenceFrame::StartPrint(nsIPresContext* aPresContext, mPageData->mPrintSettings = aPrintSettings; } + // Only set them if they are not null + if (aDocTitle) mPageData->mDocTitle = aDocTitle; + if (aDocURL) mPageData->mDocURL = aDocURL; + aPrintSettings->GetMarginInTwips(mMargin); aPrintSettings->GetStartPageRange(&mFromPageNum); diff --git a/mozilla/layout/generic/nsSimplePageSequence.h b/mozilla/layout/generic/nsSimplePageSequence.h index 91020b3bb9b..b3709d4542b 100644 --- a/mozilla/layout/generic/nsSimplePageSequence.h +++ b/mozilla/layout/generic/nsSimplePageSequence.h @@ -55,6 +55,8 @@ public: nsFont * mHeadFootFont; PRUnichar * mPageNumFormat; PRUnichar * mPageNumAndTotalsFormat; + PRUnichar * mDocTitle; + PRUnichar * mDocURL; nsRect mReflowRect; nsMargin mReflowMargin; @@ -99,7 +101,9 @@ public: // Async Printing NS_IMETHOD StartPrint(nsIPresContext* aPresContext, - nsIPrintSettings* aPrintSettings); + nsIPrintSettings* aPrintSettings, + PRUnichar* aDocTitle, + PRUnichar* aDocURL); NS_IMETHOD PrintNextPage(nsIPresContext* aPresContext); NS_IMETHOD GetCurrentPageNum(PRInt32* aPageNum); NS_IMETHOD GetNumPages(PRInt32* aNumPages); diff --git a/mozilla/layout/html/base/src/nsPageFrame.cpp b/mozilla/layout/html/base/src/nsPageFrame.cpp index 9038236d5f6..3e29d1b6066 100644 --- a/mozilla/layout/html/base/src/nsPageFrame.cpp +++ b/mozilla/layout/html/base/src/nsPageFrame.cpp @@ -410,17 +410,13 @@ nsPageFrame::ProcessSpecialCodes(const nsString& aStr, nsString& aNewStr) NS_NAMED_LITERAL_STRING(kTitle, "&T"); if (aStr.Find(kTitle) != kNotFound) { - nsXPIDLString uTitle; - mPD->mPrintOptions->GetTitle(getter_Copies(uTitle)); - SubstValueForCode(aNewStr, kTitle.get(), uTitle.get()); + SubstValueForCode(aNewStr, kTitle.get(), mPD->mDocTitle); return; } NS_NAMED_LITERAL_STRING(kDocURL, "&U"); if (aStr.Find(kDocURL) != kNotFound) { - nsXPIDLString uDocURL; - mPD->mPrintOptions->GetDocURL(getter_Copies(uDocURL)); - SubstValueForCode(aNewStr, kDocURL.get(), uDocURL.get()); + SubstValueForCode(aNewStr, kDocURL.get(), mPD->mDocURL); return; } } diff --git a/mozilla/layout/html/base/src/nsSimplePageSequence.cpp b/mozilla/layout/html/base/src/nsSimplePageSequence.cpp index 06cdd46e7fa..4569dfc5529 100644 --- a/mozilla/layout/html/base/src/nsSimplePageSequence.cpp +++ b/mozilla/layout/html/base/src/nsSimplePageSequence.cpp @@ -111,6 +111,8 @@ nsSharedPageData::nsSharedPageData() : mHeadFootFont(nsnull), mPageNumFormat(nsnull), mPageNumAndTotalsFormat(nsnull), + mDocTitle(nsnull), + mDocURL(nsnull), mReflowRect(0,0,0,0), mReflowMargin(0,0,0,0), mShadowSize(0,0), @@ -126,6 +128,8 @@ nsSharedPageData::~nsSharedPageData() if (mHeadFootFont) delete mHeadFootFont; nsMemory::Free(mPageNumFormat); nsMemory::Free(mPageNumAndTotalsFormat); + if (mDocTitle) nsMemory::Free(mDocTitle); + if (mDocURL) nsMemory::Free(mDocURL); } nsresult @@ -660,8 +664,10 @@ nsIRegion* nsSimplePageSequenceFrame::CreateRegion() } NS_IMETHODIMP -nsSimplePageSequenceFrame::StartPrint(nsIPresContext* aPresContext, - nsIPrintSettings* aPrintSettings) +nsSimplePageSequenceFrame::StartPrint(nsIPresContext* aPresContext, + nsIPrintSettings* aPrintSettings, + PRUnichar* aDocTitle, + PRUnichar* aDocURL) { NS_ENSURE_ARG_POINTER(aPresContext); NS_ENSURE_ARG_POINTER(aPrintSettings); @@ -670,6 +676,10 @@ nsSimplePageSequenceFrame::StartPrint(nsIPresContext* aPresContext, mPageData->mPrintSettings = aPrintSettings; } + // Only set them if they are not null + if (aDocTitle) mPageData->mDocTitle = aDocTitle; + if (aDocURL) mPageData->mDocURL = aDocURL; + aPrintSettings->GetMarginInTwips(mMargin); aPrintSettings->GetStartPageRange(&mFromPageNum); diff --git a/mozilla/layout/html/base/src/nsSimplePageSequence.h b/mozilla/layout/html/base/src/nsSimplePageSequence.h index 91020b3bb9b..b3709d4542b 100644 --- a/mozilla/layout/html/base/src/nsSimplePageSequence.h +++ b/mozilla/layout/html/base/src/nsSimplePageSequence.h @@ -55,6 +55,8 @@ public: nsFont * mHeadFootFont; PRUnichar * mPageNumFormat; PRUnichar * mPageNumAndTotalsFormat; + PRUnichar * mDocTitle; + PRUnichar * mDocURL; nsRect mReflowRect; nsMargin mReflowMargin; @@ -99,7 +101,9 @@ public: // Async Printing NS_IMETHOD StartPrint(nsIPresContext* aPresContext, - nsIPrintSettings* aPrintSettings); + nsIPrintSettings* aPrintSettings, + PRUnichar* aDocTitle, + PRUnichar* aDocURL); NS_IMETHOD PrintNextPage(nsIPresContext* aPresContext); NS_IMETHOD GetCurrentPageNum(PRInt32* aPageNum); NS_IMETHOD GetNumPages(PRInt32* aNumPages); diff --git a/mozilla/layout/html/base/src/printing.properties b/mozilla/layout/html/base/src/printing.properties index 7cc109edc03..f043df37f2b 100644 --- a/mozilla/layout/html/base/src/printing.properties +++ b/mozilla/layout/html/base/src/printing.properties @@ -80,8 +80,11 @@ NS_ERROR_GFX_PRINTER_DRIVER_CONFIGURATION_ERROR=There was a problem printing. Th NS_ERROR_GFX_PRINTER_XPRINT_BROKEN_XPRT=A broken version of the X print server (Xprt) has been detected. Note that printing using this Xprt server may not work properly. Please contact the server vendor for a fixed version. NS_ERROR_GFX_PRINTER_DOC_IS_BUSY_PP=The browser cannot print preview right now.\nPlease try again when the page has finished loading. NS_ERROR_GFX_PRINTER_DOC_WAS_DESTORYED=The page was replaced while you were trying to print.\nPlease try again. +NS_ERROR_GFX_NO_PRINTDIALOG_IN_TOOLKIT=Either pluggable dialogs were not properly installed\nOr this GFX Toolkit no longer supports native Print Dialogs +NS_ERROR_GFX_NO_PRINTROMPTSERVICE=The Printing Prompt Service is missing. NS_ERROR_GFX_PRINTER_NO_XUL=We are unable to Print or Print Preview this page. # No printers available noprinter=No printers available. +PrintToFile=Print To File # EOF. diff --git a/mozilla/layout/printing/nsPrintPreviewListener.h b/mozilla/layout/printing/nsPrintPreviewListener.h index 9efa2808bd0..be3709badce 100644 --- a/mozilla/layout/printing/nsPrintPreviewListener.h +++ b/mozilla/layout/printing/nsPrintPreviewListener.h @@ -62,7 +62,7 @@ public: // nsIDOMContextMenuListener NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; } - NS_IMETHOD ContextMenu (nsIDOMEvent* aEvent) { printf("preventing ContextMenu\n"); aEvent->PreventDefault(); return NS_OK; } + NS_IMETHOD ContextMenu (nsIDOMEvent* aEvent) { aEvent->PreventDefault(); return NS_OK; } // nsIDOMKeyListener NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent); diff --git a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp index bdc5af79441..962847f6732 100644 --- a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp +++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp @@ -3405,4 +3405,13 @@ NS_IMETHODIMP nsBrowserWindow::EnsureWebBrowserChrome() return NS_OK; } +nsresult nsBrowserWindow::GetWindow(nsIWidget** aWindow) +{ + if (aWindow && mWindow) { + *aWindow = mWindow.get(); + NS_IF_ADDREF(*aWindow); + return NS_OK; + } + return NS_ERROR_FAILURE; +} diff --git a/mozilla/webshell/tests/viewer/nsBrowserWindow.h b/mozilla/webshell/tests/viewer/nsBrowserWindow.h index 1a2b818ec8e..ac3fc5342d6 100644 --- a/mozilla/webshell/tests/viewer/nsBrowserWindow.h +++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.h @@ -155,6 +155,7 @@ public: void LoadThrobberImages(); void DestroyThrobberImages(); virtual nsEventStatus DispatchMenuItem(PRInt32 aID) = 0; + virtual nsresult GetWindow(nsIWidget** aWindow); void DoFileOpen(); void DoCopy(); diff --git a/mozilla/webshell/tests/viewer/nsWebBrowserChrome.cpp b/mozilla/webshell/tests/viewer/nsWebBrowserChrome.cpp index b846ac7680e..588b38816cd 100644 --- a/mozilla/webshell/tests/viewer/nsWebBrowserChrome.cpp +++ b/mozilla/webshell/tests/viewer/nsWebBrowserChrome.cpp @@ -323,8 +323,13 @@ NS_IMETHODIMP nsWebBrowserChrome::GetSiteWindow(void ** aParentNativeWindow) { NS_ENSURE_ARG_POINTER(aParentNativeWindow); - //XXX First Check In - NS_ASSERTION(PR_FALSE, "Not Yet Implemented"); + if (mBrowserWindow) { + nsCOMPtr window; + mBrowserWindow->GetWindow(getter_AddRefs(window)); + if (window) { + *aParentNativeWindow = window->GetNativeData(NS_NATIVE_WINDOW); + } + } return NS_OK; } diff --git a/mozilla/xpfe/browser/resources/content/browser.js b/mozilla/xpfe/browser/resources/content/browser.js index 411fe432c6f..7e262d8f09a 100644 --- a/mozilla/xpfe/browser/resources/content/browser.js +++ b/mozilla/xpfe/browser/resources/content/browser.js @@ -39,6 +39,8 @@ * ***** END LICENSE BLOCK ***** */ const nsIWebNavigation = Components.interfaces.nsIWebNavigation; +var gPrintSettingsAreGlobal = true; +var gSavePrintSettings = true; var gPrintSettings = null; var gChromeState = null; // chrome state before we went into print preview var gOldCloseHandler = null; // close handler before we went into print preview @@ -202,15 +204,18 @@ function GetPrintSettings(webBrowserPrint) try { if (gPrintSettings == null) { - var useGlobalPrintSettings = true; var pref = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefBranch); if (pref) { - useGlobalPrintSettings = pref.getBoolPref("print.use_global_printsettings", false); + gPrintSettingsAreGlobal = pref.getBoolPref("print.use_global_printsettings", false); + gSavePrintSettings = pref.getBoolPref("print.save_print_settings", false); } - if (useGlobalPrintSettings) { - gPrintSettings = webBrowserPrint.globalPrintSettings; + if (gPrintSettingsAreGlobal) { + gPrintSettings = webBrowserPrint.globalPrintSettings; + if (gSavePrintSettings) { + webBrowserPrint.initPrintSettingsFromPrefs(gPrintSettings, false, gPrintSettings.kInitSaveNativeData); + } } else { gPrintSettings = webBrowserPrint.newPrintSettings; } @@ -272,14 +277,17 @@ function BrowserPrintSetup() gPrintSettings = GetPrintSettings(webBrowserPrint); } - goPageSetup(gPrintSettings); // from utilityOverlay.js + if (goPageSetup(window, gPrintSettings)) { // from utilityOverlay.js - if (webBrowserPrint) { - if (webBrowserPrint.doingPrintPreview) { - webBrowserPrint.printPreview(gPrintSettings); + if (webBrowserPrint) { + if (gPrintSettingsAreGlobal && gSavePrintSettings) { + webBrowserPrint.savePrintSettingsToPrefs(gPrintSettings, false, gPrintSettings.kInitSaveNativeData); + } + if (webBrowserPrint.doingPrintPreview) { + webBrowserPrint.printPreview(gPrintSettings); + } } } - } catch (e) { dump("BrowserPrintSetup "+e); } diff --git a/mozilla/xpfe/communicator/resources/content/printPageSetup.js b/mozilla/xpfe/communicator/resources/content/printPageSetup.js index 5fed837b1a4..cc055e1f2df 100644 --- a/mozilla/xpfe/communicator/resources/content/printPageSetup.js +++ b/mozilla/xpfe/communicator/resources/content/printPageSetup.js @@ -39,6 +39,7 @@ * ***** END LICENSE BLOCK ***** */ var gDialog; +var paramBlock; var gPrintSettings = null; var gStringBundle = null; @@ -344,10 +345,14 @@ function onLoad() if (window.arguments[0] != null) { gPrintSettings = window.arguments[0].QueryInterface(Components.interfaces.nsIPrintSettings); + paramBlock = window.arguments[1].QueryInterface(Components.interfaces.nsIDialogParamBlock); } else if (gDoDebug) { alert("window.arguments[0] == null!"); } + // default return value is "cancel" + paramBlock.SetInt(0, 0); + if (gPrintSettings) { loadDialog(); } else if (gDoDebug) { @@ -404,5 +409,26 @@ function onAccept() } } + // set return value to "ok" + if (paramBlock) { + paramBlock.SetInt(0, 1); + } else { + dump("*** FATAL ERROR: No paramBlock\n"); + } + return true; } + +//--------------------------------------------------- +function onCancel() +{ + // set return value to "cancel" + if (paramBlock) { + paramBlock.SetInt(0, 0); + } else { + dump("*** FATAL ERROR: No paramBlock\n"); + } + + return true; +} + diff --git a/mozilla/xpfe/communicator/resources/content/printPageSetup.xul b/mozilla/xpfe/communicator/resources/content/printPageSetup.xul index 27d14c092fb..1ba6c96964f 100644 --- a/mozilla/xpfe/communicator/resources/content/printPageSetup.xul +++ b/mozilla/xpfe/communicator/resources/content/printPageSetup.xul @@ -36,6 +36,7 @@ Contributor(s): diff --git a/mozilla/xpfe/communicator/resources/content/utilityOverlay.js b/mozilla/xpfe/communicator/resources/content/utilityOverlay.js index f242d5e3013..14f63c85b80 100644 --- a/mozilla/xpfe/communicator/resources/content/utilityOverlay.js +++ b/mozilla/xpfe/communicator/resources/content/utilityOverlay.js @@ -125,7 +125,7 @@ function getBrowserURL() { return "chrome://navigator/content/navigator.xul"; } -function goPageSetup(printSettings) +function goPageSetup(domwin, printSettings) { try { if (printSettings == null) { @@ -135,10 +135,12 @@ function goPageSetup(printSettings) // This code calls the printoptions service to bring up the printoptions // dialog. This will be an xp dialog if the platform did not override // the ShowPrintSetupDialog method. - var printOptionsService = Components.classes["@mozilla.org/gfx/printoptions;1"] - .getService(Components.interfaces.nsIPrintOptions); - printOptionsService.ShowPrintSetupDialog(printSettings); - } catch(e) { + var printingPromptService = Components.classes["@mozilla.org/embedcomp/printingprompt-service;1"] + .getService(Components.interfaces.nsIPrintingPromptService); + printingPromptService.showPageSetup(domwin, printSettings); + return true; + } catch(e) { + return false; } } diff --git a/mozilla/xpfe/global/resources/content/printPageSetup.js b/mozilla/xpfe/global/resources/content/printPageSetup.js index 5fed837b1a4..cc055e1f2df 100644 --- a/mozilla/xpfe/global/resources/content/printPageSetup.js +++ b/mozilla/xpfe/global/resources/content/printPageSetup.js @@ -39,6 +39,7 @@ * ***** END LICENSE BLOCK ***** */ var gDialog; +var paramBlock; var gPrintSettings = null; var gStringBundle = null; @@ -344,10 +345,14 @@ function onLoad() if (window.arguments[0] != null) { gPrintSettings = window.arguments[0].QueryInterface(Components.interfaces.nsIPrintSettings); + paramBlock = window.arguments[1].QueryInterface(Components.interfaces.nsIDialogParamBlock); } else if (gDoDebug) { alert("window.arguments[0] == null!"); } + // default return value is "cancel" + paramBlock.SetInt(0, 0); + if (gPrintSettings) { loadDialog(); } else if (gDoDebug) { @@ -404,5 +409,26 @@ function onAccept() } } + // set return value to "ok" + if (paramBlock) { + paramBlock.SetInt(0, 1); + } else { + dump("*** FATAL ERROR: No paramBlock\n"); + } + return true; } + +//--------------------------------------------------- +function onCancel() +{ + // set return value to "cancel" + if (paramBlock) { + paramBlock.SetInt(0, 0); + } else { + dump("*** FATAL ERROR: No paramBlock\n"); + } + + return true; +} + diff --git a/mozilla/xpfe/global/resources/content/printPageSetup.xul b/mozilla/xpfe/global/resources/content/printPageSetup.xul index 27d14c092fb..1ba6c96964f 100644 --- a/mozilla/xpfe/global/resources/content/printPageSetup.xul +++ b/mozilla/xpfe/global/resources/content/printPageSetup.xul @@ -36,6 +36,7 @@ Contributor(s): diff --git a/mozilla/xpfe/global/resources/content/printdialog.js b/mozilla/xpfe/global/resources/content/printdialog.js index e3a45fcf57c..b7c6c4a6578 100644 --- a/mozilla/xpfe/global/resources/content/printdialog.js +++ b/mozilla/xpfe/global/resources/content/printdialog.js @@ -196,8 +196,6 @@ function setPrinterDefaultsForSelectedPrinter() /* FixMe: We should save the old printer's values here... */ gPrintSettings.printerName = dialog.printerList.value; - var ifreq = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor); - gWebBrowserPrint = ifreq.getInterface(Components.interfaces.nsIWebBrowserPrint); // First get any defaults from the printer gWebBrowserPrint.initPrintSettingsFromPrinter(gPrintSettings.printerName, gPrintSettings); @@ -215,19 +213,16 @@ function setPrinterDefaultsForSelectedPrinter() //--------------------------------------------------- function displayPropertiesDialog() { - var displayed = new Object; - displayed.value = false; gPrintSettings.numCopies = dialog.numCopiesInput.value; - - printService.displayJobProperties(dialog.printerList.value, gPrintSettings, displayed); - dialog.numCopiesInput.value = gPrintSettings.numCopies; - - if (doDebug) { - if (displayed.value) - dump("\nproperties dlg came up. displayed = "+displayed.value+"\n"); - else - dump("\nproperties dlg didn't come up. displayed = "+displayed.value+"\n"); - } + try { + var printingPromptService = Components.classes["@mozilla.org/embedcomp/printingprompt-service;1"] + .getService(Components.interfaces.nsIPrintingPromptService); + if (printingPromptService) { + printingPromptService.showPrinterProperties(null, dialog.printerList.value, gPrintSettings); + } + } catch(e) { + dump("problems getting printingPromptService\n"); + } } //--------------------------------------------------- @@ -363,27 +358,9 @@ function onLoad() // param[0]: nsIPrintSettings object // param[1]: container for return value (1 = print, 0 = cancel) - var ps = window.arguments[0].QueryInterface(gPrintSetInterface); - if (ps != null) { - gPrintSettings = ps; - paramBlock = window.arguments[1].QueryInterface(Components.interfaces.nsIDialogParamBlock); - } else { - var suppsArray = window.arguments[0].QueryInterface(Components.interfaces.nsISupportsArray); - if (suppsArray) { - var supps = suppsArray.ElementAt(0); - gPrintSettings = supps.QueryInterface(gPrintSetInterface); - if(!gPrintSettings) { - return; - } - supps = suppsArray.ElementAt(1); - paramBlock = supps.QueryInterface(Components.interfaces.nsIDialogParamBlock); - if(!paramBlock) { - return; - } - } else { - return; - } - } + gPrintSettings = window.arguments[0].QueryInterface(gPrintSetInterface); + gWebBrowserPrint = window.arguments[1].QueryInterface(Components.interfaces.nsIWebBrowserPrint); + paramBlock = window.arguments[2].QueryInterface(Components.interfaces.nsIDialogParamBlock); // default return value is "cancel" paramBlock.SetInt(0, 0); @@ -477,6 +454,19 @@ function onAccept() } +//--------------------------------------------------- +function onCancel() +{ + // set return value to "cancel" + if (paramBlock) { + paramBlock.SetInt(0, 0); + } else { + dump("*** FATAL ERROR: No paramBlock\n"); + } + + return true; +} + //--------------------------------------------------- const nsIFilePicker = Components.interfaces.nsIFilePicker; function onChooseFile() diff --git a/mozilla/xpfe/global/resources/content/printdialog.xul b/mozilla/xpfe/global/resources/content/printdialog.xul index 4b8ce78deeb..5ff1a970e89 100644 --- a/mozilla/xpfe/global/resources/content/printdialog.xul +++ b/mozilla/xpfe/global/resources/content/printdialog.xul @@ -34,6 +34,7 @@ Contributor(s): diff --git a/mozilla/xpfe/global/resources/content/unix/printjoboptions.js b/mozilla/xpfe/global/resources/content/unix/printjoboptions.js index ced87dea379..5a5dd4fe4f8 100644 --- a/mozilla/xpfe/global/resources/content/unix/printjoboptions.js +++ b/mozilla/xpfe/global/resources/content/unix/printjoboptions.js @@ -351,15 +351,11 @@ function onLoad() // Init dialog. initDialog(); - // window.arguments[0]: container for return value (1 = ok, 0 = cancel) - var ps = window.arguments[0].QueryInterface(gPrintSetInterface); - if (ps != null) { - gPrintSettings = ps; - paramBlock = window.arguments[1].QueryInterface(Components.interfaces.nsIDialogParamBlock); - } + gPrintSettings = window.arguments[0].QueryInterface(gPrintSetInterface); + paramBlock = window.arguments[1].QueryInterface(Components.interfaces.nsIDialogParamBlock); if (doDebug) { - if (ps == null) alert("PrintSettings is null!"); + if (gPrintSettings == null) alert("PrintSettings is null!"); if (paramBlock == null) alert("nsIDialogParam is null!"); }