This commit is contained in:
rods%netscape.com 2002-05-02 13:24:08 +00:00
Родитель a1f21a54d5
Коммит 04c750b94d
97 изменённых файлов: 3272 добавлений и 2015 удалений

Просмотреть файл

@ -42,7 +42,6 @@
#include "nsIWebProgressListener.idl"
interface nsIDOMWindowInternal;
interface nsIObserver;
[scriptable, uuid(7E46BC35-FB7D-4b45-AB35-82FD61015380)]
interface nsIPrintProgress: nsIWebProgressListener {
@ -50,11 +49,7 @@ interface nsIPrintProgress: nsIWebProgressListener {
/* Open the progress dialog
you can specify parameters through an xpcom object
*/
void openProgressDialog(in nsIDOMWindowInternal parent,
in string dialogURL,
in nsISupports parameters,
in nsIObserver openDialogObserver,
out boolean notifyOnOpen);
void openProgressDialog(in nsIDOMWindowInternal parent, in string dialogURL, in nsISupports parameters);
/* Close the progress dialog */
void closeProgressDialog(in boolean forceClose);

Просмотреть файл

@ -70,6 +70,8 @@ CPPSRCS = \
nsDocumentEncoder.cpp \
nsDocumentFragment.cpp \
nsDocumentViewer.cpp \
nsPrintProgress.cpp \
nsPrintProgressParams.cpp \
nsDOMAttribute.cpp \
nsDOMAttributeMap.cpp \
nsDOMDocumentType.cpp \

Просмотреть файл

@ -63,6 +63,8 @@ REQUIRES = xpcom \
CPP_OBJS= \
.\$(OBJDIR)\nsPrintPreviewListener.obj \
.\$(OBJDIR)\nsPrintProgress.obj \
.\$(OBJDIR)\nsPrintProgressParams.obj \
.\$(OBJDIR)\nsStyleContext.obj \
.\$(OBJDIR)\nsStyleSet.obj \
.\$(OBJDIR)\nsCommentNode.obj \

Просмотреть файл

@ -161,10 +161,6 @@ 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
@ -219,12 +215,12 @@ static const char * gPrintRangeStr[] = {"kRangeAllPages", "kRangeSpecified
static PRUint32 gDumpFileNameCnt = 0;
static PRUint32 gDumpLOFileNameCnt = 0;
#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);
#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);
#else //--------------
#define PRT_YESNO(_p)
#define PRINT_DEBUG_MSG1(_msg)
@ -402,9 +398,7 @@ private:
class PrintData {
public:
typedef enum ePrintDataType {eIsPrinting, eIsPrintPreview };
PrintData(ePrintDataType aType);
PrintData();
~PrintData(); // non-virtual
// Listener Helper Methods
@ -416,7 +410,6 @@ public:
PRBool aDoStartStop = PR_FALSE,
PRInt32 aFlag = 0);
ePrintDataType mType; // the type of data this is (Printing or Print Preview)
nsCOMPtr<nsIDeviceContext> mPrintDC;
nsIView *mPrintView;
FILE *mDebugFilePtr; // a file where information can go to when printing
@ -473,7 +466,6 @@ public:
#endif
private:
PrintData() {}
PrintData& operator=(const PrintData& aOther); // not implemented
};
@ -719,6 +711,7 @@ protected:
nsIPageSequenceFrame* mPageSeqFrame;
PRBool mIsPrinting;
PrintData* mPrt;
nsPagePrintTimer* mPagePrintTimer;
@ -885,8 +878,8 @@ static nsresult NS_NewUpdateTimer(nsPagePrintTimer **aResult)
//---------------------------------------------------
//-- PrintData Class Impl
//---------------------------------------------------
PrintData::PrintData(ePrintDataType aType) :
mType(aType), mPrintView(nsnull), mDebugFilePtr(nsnull), mPrintObject(nsnull), mSelectedPO(nsnull),
PrintData::PrintData() :
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),
@ -947,15 +940,13 @@ PrintData::~PrintData()
mPrintSettings->GetIsCancelled(&isCancelled);
nsresult rv = NS_OK;
if (mType == eIsPrinting) {
if (!isCancelled && !mIsAborted) {
rv = mPrintDC->EndDocument();
} else {
rv = mPrintDC->AbortDocument();
}
if (NS_FAILED(rv)) {
DocumentViewerImpl::ShowPrintErrorDialog(rv);
}
if (!isCancelled && !mIsAborted) {
rv = mPrintDC->EndDocument();
} else {
rv = mPrintDC->AbortDocument();
}
if (NS_FAILED(rv)) {
DocumentViewerImpl::ShowPrintErrorDialog(rv);
}
}
@ -1112,6 +1103,7 @@ void DocumentViewerImpl::PrepareToStartLoad()
mStopped = PR_FALSE;
mLoaded = PR_FALSE;
mPrt = nsnull;
mIsPrinting = PR_FALSE;
#ifdef NS_PRINT_PREVIEW
mIsDoingPrintPreview = PR_FALSE;
@ -4320,7 +4312,7 @@ DocumentViewerImpl::FindXMostFrameInList(nsIPresContext* aPresContext,
xMost = 0;
}
#ifdef DEBUG_PRINTING_X // keep this here but leave it turned off
#ifdef DEBUG_PRINTING // keep this here but leave it turned off
nsAutoString tmp;
nsIFrameDebug* frameDebug;
if (NS_SUCCEEDED(CallQueryInterface(child, &frameDebug))) {
@ -4331,7 +4323,7 @@ DocumentViewerImpl::FindXMostFrameInList(nsIPresContext* aPresContext,
if (xMost > aMaxWidth) {
aMaxWidth = xMost;
#ifdef DEBUG_PRINTING_X // keep this here but leave it turned off
#ifdef DEBUG_PRINTING // 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");
@ -4461,7 +4453,7 @@ DocumentViewerImpl::SetupToPrintContent(nsIWebShell* aParent,
}
// Only Shrink if we are smaller
if (mPrt->mShrinkRatio < 0.998f) {
if (mPrt->mShrinkRatio < 1.0f) {
// Clamp Shrink to Fit to 50%
mPrt->mShrinkRatio = PR_MAX(mPrt->mShrinkRatio, 0.5f);
@ -4479,30 +4471,6 @@ 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------------------------------------------");
@ -4542,54 +4510,12 @@ 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
}
@ -4762,11 +4688,23 @@ DocumentViewerImpl::DoPrint(PrintObject * aPO, PRBool aDoSyncPrinting, PRBool& a
#endif
if (mPrt->mPrintSettings) {
PRUnichar * docTitleStr = nsnull;
PRUnichar * docURLStr = nsnull;
if (!skipSetTitle) {
GetDisplayTitleAndURL(aPO, mPrt->mPrintSettings, mPrt->mBrandName, &docTitleStr, &docURLStr, eDocTitleDefBlank);
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);
}
}
if (nsIPrintSettings::kRangeSelection == printRangeType) {
@ -4856,7 +4794,7 @@ DocumentViewerImpl::DoPrint(PrintObject * aPO, PRBool aDoSyncPrinting, PRBool& a
rootFrame->SetRect(poPresContext, r);
mPageSeqFrame = pageSequence;
mPageSeqFrame->StartPrint(poPresContext, mPrt->mPrintSettings, docTitleStr, docURLStr);
mPageSeqFrame->StartPrint(poPresContext, mPrt->mPrintSettings);
if (!aDoSyncPrinting) {
// Get the delay time in between the printing of each page
@ -5555,26 +5493,25 @@ DocumentViewerImpl::IsThereAnIFrameSelected(nsIWebShell* aWebShell,
{
aIsParentFrameSet = IsParentAFrameSet(aWebShell);
PRBool iFrameIsSelected = PR_FALSE;
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<nsIDOMWindowInternal> domWin = getter_AddRefs(GetDOMWinForWebShell(aWebShell));
if (aDOMWin != nsnull && domWin != aDOMWin) {
iFrameIsSelected = PR_TRUE; // we have a selected IFRAME
}
#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<nsIDOMWindowInternal> domWin = getter_AddRefs(GetDOMWinForWebShell(aWebShell));
if (aDOMWin != nsnull && domWin != aDOMWin) {
iFrameIsSelected = PR_TRUE; // we have a selected IFRAME
}
}
}
#endif
return iFrameIsSelected;
}
@ -6389,7 +6326,7 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings)
mPrtPreview = nsnull;
}
mPrt = new PrintData(PrintData::eIsPrintPreview);
mPrt = new PrintData();
if (!mPrt) {
mIsCreatingPrintPreview = PR_FALSE;
return NS_ERROR_OUT_OF_MEMORY;
@ -6531,6 +6468,8 @@ 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);
@ -6539,7 +6478,7 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings)
if (factory) {
nsCOMPtr<nsIDeviceContextSpec> devspec;
nsCOMPtr<nsIDeviceContext> dx;
nsresult rv = factory->CreateDeviceContextSpec(mWindow, aPrintSettings, *getter_AddRefs(devspec), PR_TRUE);
nsresult rv = factory->CreateDeviceContextSpec(mWindow, aPrintSettings, *getter_AddRefs(devspec), doSilent);
if (NS_SUCCEEDED(rv)) {
rv = mDeviceContext->GetDeviceContextFor(devspec, *getter_AddRefs(ppDC));
if (NS_SUCCEEDED(rv)) {
@ -6557,7 +6496,9 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings)
}
}
mPrt->mPrintSettings->SetPrintFrameType(nsIPrintSettings::kFramesAsIs);
if (doSilent) {
mPrt->mPrintSettings->SetPrintFrameType(nsIPrintSettings::kFramesAsIs);
}
// override any UI that wants to PrintPreview any selection
PRInt16 printRangeType = nsIPrintSettings::kRangeAllPages;
@ -6662,20 +6603,28 @@ DocumentViewerImpl::SetDocAndURLIntoProgress(PrintObject* aPO,
docURLStr = ToNewUnicode(newURLStr);
}
aParams->SetDocTitle((const PRUnichar*) docTitleStr);
aParams->SetDocURL((const PRUnichar*) docURLStr);
mPrt->mPrintProgressParams->SetDocTitle((const PRUnichar*) docTitleStr);
mPrt->mPrintProgressParams->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)
{
// Assume we can't do progress and then see if we can
mPrt->mShowProgressDialog = PR_FALSE;
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);
nsCOMPtr<nsIPref> prefs (do_GetService(NS_PREF_CONTRACTID));
if (prefs) {
@ -6689,27 +6638,20 @@ DocumentViewerImpl::DoPrintProgress(PRBool aIsForPrinting)
mPrt->mPrintSettings->GetShowPrintProgress(&mPrt->mShowProgressDialog);
}
// Now open the service to get the progress dialog
nsCOMPtr<nsIPrintingPromptService> printPromptService(do_GetService(kPrintingPromptService));
if (printPromptService) {
nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject;
mDocument->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject));
if (!scriptGlobalObject) return;
nsCOMPtr<nsIDOMWindow> domWin = do_QueryInterface(scriptGlobalObject);
if (!domWin) return;
if (mPrt->mShowProgressDialog) {
nsPrintProgressParams* prtProgressParams = new nsPrintProgressParams();
nsCOMPtr<nsIPrintProgressParams> params;
rv = prtProgressParams->QueryInterface(NS_GET_IID(nsIPrintProgressParams), (void**)getter_AddRefs(mPrt->mPrintProgressParams));
if (NS_SUCCEEDED(rv) && mPrt->mPrintProgressParams) {
SetDocAndURLIntoProgress(mPrt->mPrintObject, mPrt->mPrintProgressParams);
// If we don't get a service, that's ok, then just don't show progress
PRBool notifyOnOpen;
nsresult rv = printPromptService->ShowProgress(domWin, this, mPrt->mPrintSettings, nsnull, getter_AddRefs(mPrt->mPrintProgressListener), getter_AddRefs(mPrt->mPrintProgressParams), &notifyOnOpen);
if (NS_SUCCEEDED(rv)) {
mPrt->mShowProgressDialog = mPrt->mPrintProgressListener != nsnull && mPrt->mPrintProgressParams != nsnull;
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
if (wwatch) {
nsCOMPtr<nsIDOMWindow> active;
wwatch->GetActiveWindow(getter_AddRefs(active));
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);
nsCOMPtr<nsIDOMWindowInternal> parent(do_QueryInterface(active));
mPrt->mPrintProgress->OpenProgressDialog(parent, "chrome://global/content/printProgress.xul", mPrt->mPrintProgressParams);
}
}
}
@ -6807,9 +6749,9 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings,
ShowPrintErrorDialog(rv);
return rv;
}
mPrt = new PrintData(PrintData::eIsPrinting);
if (!mPrt) {
mPrt = new PrintData();
if (mPrt == nsnull) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -6946,65 +6888,14 @@ 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);
}
// 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);
// 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<nsIPrintingPromptService> printPromptService(do_GetService(kPrintingPromptService));
if (printPromptService) {
nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject;
mDocument->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject));
if (!scriptGlobalObject) return nsnull;
nsCOMPtr<nsIDOMWindow> 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;
}
// we have to turn off printpreview mode for now.. because this is a real request to print.
if ( mIsDoingPrintPreview == PR_TRUE) {
aPrintSettings->SetIsPrintPreview(PR_FALSE);
}
// Create DeviceSpec for Printing
rv = factory->CreateDeviceContextSpec(mWindow, mPrt->mPrintSettings, *getter_AddRefs(devspec), PR_FALSE);
rv = factory->CreateDeviceContextSpec(mWindow, mPrt->mPrintSettings, *getter_AddRefs(devspec), printSilently);
// 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.
@ -7128,42 +7019,70 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings,
}
}
// 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
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
// and it uses the PrintService to get it, so we need to set it into the PrintService here
mPrt->mPrintSettings->GetToFileName(&fileName);
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);
}
}
PRUnichar * docTitleStr;
PRUnichar * docURLStr;
GetDisplayTitleAndURL(mPrt->mPrintObject, mPrt->mPrintSettings,
mPrt->mBrandName, &docTitleStr, &docURLStr,
eDocTitleDefURLDoc);
GetDisplayTitleAndURL(mPrt->mPrintObject, mPrt->mPrintSettings, mPrt->mBrandName, &docTitleStr, &docURLStr, eDocTitleDefURLDoc);
rv = mPrt->mPrintDC->PrepareDocument(docTitleStr, fileName);
// 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");
if (docTitleStr) nsMemory::Free(docTitleStr);
if (docURLStr) nsMemory::Free(docURLStr);
NS_ENSURE_SUCCESS(rv, rv);
DoPrintProgress(PR_TRUE);
if (NS_SUCCEEDED(rv)) {
// Print listener setup...
if (mPrt != nsnull) {
mPrt->OnStartPrinting();
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");
}
}
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
@ -7255,8 +7174,6 @@ 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:
@ -8381,10 +8298,12 @@ DocumentViewerImpl::GetCurrentPrintSettings(nsIPrintSettings * *aCurrentPrintSet
NS_IMETHODIMP
DocumentViewerImpl::Cancel()
{
if (mPrt && mPrt->mPrintSettings) {
return mPrt->mPrintSettings->SetIsCancelled(PR_TRUE);
nsresult rv;
nsCOMPtr<nsIPrintOptions> printService = do_GetService(kPrintOptionsCID, &rv);
if (NS_SUCCEEDED(rv) && printService) {
return printService->SetIsCancelled(PR_TRUE);
}
return NS_ERROR_FAILURE;
return NS_OK;
}
/* void initPrintSettingsFromPrefs (in nsIPrintSettings aPrintSettings, in boolean aUsePrinterNamePrefix, in unsigned long aFlags); */

Просмотреть файл

@ -62,7 +62,7 @@ public:
// nsIDOMContextMenuListener
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
NS_IMETHOD ContextMenu (nsIDOMEvent* aEvent) { aEvent->PreventDefault(); return NS_OK; }
NS_IMETHOD ContextMenu (nsIDOMEvent* aEvent) { printf("preventing ContextMenu\n"); aEvent->PreventDefault(); return NS_OK; }
// nsIDOMKeyListener
NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent);

Просмотреть файл

@ -72,11 +72,8 @@ nsPrintProgress::~nsPrintProgress()
/* void openProgressDialog (in nsIDOMWindowInternal parent, in string dialogURL, in nsISupports parameters); */
NS_IMETHODIMP nsPrintProgress::OpenProgressDialog(nsIDOMWindowInternal *parent,
const char *dialogURL,
nsISupports *parameters,
nsIObserver *openDialogObserver,
PRBool *notifyOnOpen)
nsISupports *parameters)
{
*notifyOnOpen = PR_FALSE;
nsresult rv = NS_ERROR_FAILURE;
if (m_dialog)

Просмотреть файл

@ -1610,6 +1610,20 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintProgress.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintProgressParams.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsCSSLoader.cpp</PATH>
@ -2943,6 +2957,16 @@
<PATH>nsPrintPreviewListener.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintProgress.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintProgressParams.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsCSSLoader.cpp</PATH>
@ -5087,6 +5111,20 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintProgress.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintProgressParams.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsCSSLoader.cpp</PATH>
@ -6420,6 +6458,16 @@
<PATH>nsPrintPreviewListener.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintProgress.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintProgressParams.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsCSSLoader.cpp</PATH>
@ -7076,6 +7124,18 @@
<PATH>nsPrintPreviewListener.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>content.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintProgress.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>content.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintProgressParams.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>content.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>

Просмотреть файл

@ -40,10 +40,6 @@ XPIDLSRCS = \
nsIPrintSettings.idl \
$(NULL)
ifneq (,$(filter mac cocoa,$(MOZ_GFX_TOOLKIT)))
XPIDLSRCS += nsIPrintSettingsX.idl
endif
ifeq ($(MOZ_GFX_TOOLKIT),windows)
XPIDLSRCS += nsIPrintSettingsWin.idl
endif

Просмотреть файл

@ -107,6 +107,15 @@ 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);

Просмотреть файл

@ -88,7 +88,6 @@ interface nsIPrintSettings : nsISupports
const unsigned long kInitSaveToFileName = 0x00400000;
const unsigned long kInitSavePageDelay = 0x00800000;
const unsigned long kInitSaveMargins = 0x01000000;
const unsigned long kInitSaveNativeData = 0x02000000;
const unsigned long kInitSaveAll = 0xFFFFFFFF;
/* Print Option Flags for Bit Field*/
@ -166,11 +165,6 @@ interface nsIPrintSettings : nsISupports
*/
void GetPageSizeInTwips(out long aWidth, out long aHeight);
/**
* Makes a new copy
*/
nsIPrintSettings clone();
/**
* Data Members
*/

Просмотреть файл

@ -1,77 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Don Cone <dcone@netscape.com>
* Conrad Carlen <ccarlen@netscape.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
%{ C++
#include <Printing.h>
%}
/**
* Native types
*/
native nsTHPrint(THPrint);
/**
* Simplified PrintSettings for Mac interface
*
* @status UNDER_REVIEW
*/
[scriptable, uuid(3C85F9F5-3A9D-4bce-8CF8-A1B14E5E8508)]
interface nsIPrintSettingsMac : nsISupports
{
/*
* thPrint attribute
*
* Getter returns a clone of the current data
* Setter copies (does not take ownership of) the input
*/
[noscript] attribute nsTHPrint tHPrint;
/*
* readPageSetupFromPrefs and writePageSetupToPrefs
*
* Read and write a print record to/from prefs.
*/
[noscript] void readPageSetupFromPrefs();
[noscript] void writePageSetupToPrefs();
};

Просмотреть файл

@ -1,82 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Conrad Carlen <ccarlen@netscape.com>
* Don Cone <dcone@netscape.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
%{ C++
#include <PMApplication.h>
%}
/**
* Native types
*/
native nsPMPageFormat(PMPageFormat);
native nsPMPrintSettings(PMPrintSettings);
/**
* Simplified PrintSettings for OSX interface
*
* @status UNDER_REVIEW
*/
[scriptable, uuid(CD2A0A4F-0DE9-4c51-9232-42668F559F94)]
interface nsIPrintSettingsX : nsISupports
{
/*
* PMPageFormat and PMPrintSettings attributes
*
* Getter returns a clone of the current data
* Setter copies (does not take ownership of) the input
*/
[noscript] attribute nsPMPageFormat pMPageFormat;
[noscript] attribute nsPMPrintSettings pMPrintSettings;
/*
* readPageFormatFromPrefs and writePageFormatToPrefs
*
* Read and write a flattened PMPageFormat to/from prefs.
* This also contains any custom data we appended to the dialog
*/
[noscript] void readPageFormatFromPrefs();
[noscript] void writePageFormatToPrefs();
};

Просмотреть файл

@ -1060,20 +1060,6 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintSettingsMac.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintSettingsMac.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>InterfacesStubs</PATH>
@ -1314,16 +1300,6 @@
<PATH>nsPrintOptionsMac.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintSettingsMac.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintSettingsMac.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>InterfacesStubs</PATH>
@ -2423,20 +2399,6 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintSettingsMac.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintSettingsMac.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>InterfacesStubs</PATH>
@ -2677,16 +2639,6 @@
<PATH>nsPrintOptionsMac.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintSettingsMac.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintSettingsMac.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>InterfacesStubs</PATH>
@ -3821,20 +3773,6 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintSettingsX.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintSettingsX.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintOptionsImpl.cpp</PATH>
@ -4053,16 +3991,6 @@
<PATH>nsPrintOptionsX.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintSettingsX.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintSettingsX.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintOptionsImpl.cpp</PATH>
@ -5179,20 +5107,6 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintSettingsX.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintSettingsX.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintOptionsImpl.cpp</PATH>
@ -5409,16 +5323,6 @@
<PATH>nsPrintOptionsX.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintSettingsX.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintSettingsX.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintOptionsImpl.cpp</PATH>
@ -5612,36 +5516,12 @@
<PATH>nsPrintOptionsMac.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>gfxComponentDbg.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintSettingsMac.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>gfxComponentDbg.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintSettingsMac.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>gfxComponentCarbon.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintOptionsX.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>gfxComponentCarbon.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintSettingsX.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>gfxComponentCarbon.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintSettingsX.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>gfxComponentDbg.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>

Просмотреть файл

@ -776,20 +776,6 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsIPrintSettingsMac.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsIPrintSettingsX.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
</FILELIST>
<LINKORDER>
<FILEREF>
@ -832,16 +818,6 @@
<PATH>nsIPrintSettings.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsIPrintSettingsMac.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsIPrintSettingsX.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
</LINKORDER>
</TARGET>
<TARGET>
@ -1567,20 +1543,6 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsIPrintSettingsMac.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsIPrintSettingsX.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
</FILELIST>
<LINKORDER>
<FILEREF>
@ -1623,16 +1585,6 @@
<PATH>nsIPrintSettings.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsIPrintSettingsMac.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsIPrintSettingsX.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
</LINKORDER>
</TARGET>
</TARGETLIST>
@ -1673,18 +1625,6 @@
<PATH>nsIPrintSettings.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>headers</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsIPrintSettingsMac.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>headers</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsIPrintSettingsX.idl</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>headers</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>

Просмотреть файл

@ -27,6 +27,4 @@ nsIDrawingSurface.h
nsRepeater.h
nsThemeConstants.h
nsITheme.h
nsPDECommon.h
nsWatchTask.h

Просмотреть файл

@ -60,10 +60,7 @@ EXPORTS = \
$(NULL)
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
EXPORTS += \
nsIPrintingContext.h \
nsPDECommon.h \
$(NULL)
EXPORTS += nsIPrintingContext.h
endif
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -90,7 +90,6 @@ public:
NS_IMETHOD Init(nsNativeWidget aWidget);
NS_IMETHOD CreateRenderingContext(nsIView *aView, nsIRenderingContext *&aContext);
NS_IMETHOD CreateRenderingContext(nsIWidget *aWidget, nsIRenderingContext *&aContext);
NS_IMETHOD CreateRenderingContext(nsIRenderingContext *&aContext){return NS_ERROR_NOT_IMPLEMENTED;}
@ -132,8 +131,6 @@ 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

Просмотреть файл

@ -138,12 +138,6 @@ 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)
/**
@ -468,17 +462,6 @@ 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
@ -486,18 +469,9 @@ 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,
PRUnichar* aPrintToFileName,
PRInt32 aStartPage,
PRInt32 aEndPage) = 0;
NS_IMETHOD BeginDocument(PRUnichar * aTitle) = 0;
/**
* Inform the output device that output of a document is ending.

Просмотреть файл

@ -64,17 +64,24 @@ 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).
* 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.
* @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 aIsPrintPreview if PR_TRUE, creating Spec for PrintPreview
* @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 CreateDeviceContextSpec(nsIWidget *aWidget,
nsIPrintSettings* aPrintSettings,
nsIDeviceContextSpec *&aNewSpec,
PRBool aIsPrintPreview) = 0;
PRBool aQuiet) = 0;
};
#endif

Просмотреть файл

@ -54,10 +54,14 @@ public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPRINTING_CONTEXT_IID)
/**
* Initialize the printing context for use.
* @param aIsPrintPreview TRUE if doing print preview, FALSE if normal printing.
* @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 aIsPrintPreview) = 0;
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet) = 0;
/**
* This will tell if the printmanager is currently open
@ -74,8 +78,7 @@ public:
*/
NS_IMETHOD ClosePrintManager() = 0;
NS_IMETHOD BeginDocument(PRInt32 aStartPage,
PRInt32 aEndPage) = 0;
NS_IMETHOD BeginDocument() = 0;
NS_IMETHOD EndDocument() = 0;

Просмотреть файл

@ -1,70 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsPDECommon_h___
#define nsPDECommon_h___
#define kPDE_Creator 'MOZZ'
typedef struct {
Boolean mHaveSelection;
Boolean mHaveFrames;
Boolean mHaveFrameSelected;
Boolean mPrintSelection;
Boolean mPrintFrameAsIs;
Boolean mPrintSelectedFrame;
Boolean mPrintFramesSeperatly;
Boolean mShrinkToFit;
} nsPrintExtensions;
#define kPrintTitlesDefault false // the initial default value of our page format custom data
// Our tag for the Print Settings ticket. This should be defined in an application
// header that is common to this file and the applications' files so that it
// can get access to the data set in the Print Settings.
#define kAppPrintDialogPDEOnlyKey CFSTR("com.apple.print.PrintSettingsTicket.MOZZ")
#define kPrintSelectionOnlyDefault false // the initial default value of custom print settings custom data
#endif

Просмотреть файл

@ -1,107 +0,0 @@
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef WatchTask_h__
#define WatchTask_h__
#ifndef XP_MACOSX
#include <Retrace.h>
#endif
#include <Quickdraw.h>
#include "prtypes.h"
#include "nscore.h"
//
// class nsWatchTask
//
// A nice little class that installs/removes a VBL to set the cursor to
// the watch if we're away from the event loop for a while. Will also
// animate the watch cursor.
//
class nsWatchTask
{
public:
nsWatchTask ( ) ;
~nsWatchTask ( ) ;
// Registers the VBL task and does other various init tasks to begin
// watching for time away from the event loop. It is ok to call other
// methods on this object w/out calling Start().
NS_GFX void Start ( ) ;
// call from the main event loop
NS_GFX void EventLoopReached ( ) ;
// turn off when we know we're going into an area where it's ok
// that WNE is not called (eg, the menu code)
void Suspend ( ) { mSuspended = PR_TRUE; };
void Resume ( ) { mSuspended = PR_FALSE; };
static NS_GFX nsWatchTask& GetTask ( ) ;
private:
enum {
kRepeatInterval = 10, // check every 1/6 of a second if we should show watch (10/60)
kTicksToShowWatch = 45, // show watch if haven't seen WNE for 3/4 second (45/60)
kStepsInAnimation = 12
};
// the VBL task
static pascal void DoWatchTask(nsWatchTask* theTaskPtr) ;
#if !TARGET_CARBON
VBLTask mTask; // this must be first!!
#endif
long mChecksum; // 'mozz' to validate we have real data at interrupt time (not needed?)
void* mSelf; // so we can get back to |this| from the static routine
long mTicks; // last time the event loop was hit
Cursor mWatchCursor; // the watch cursor
PRPackedBool mBusy; // are we currently spinning the cursor?
PRPackedBool mSuspended; // set if we've temporarily suspended operation
PRPackedBool mInstallSucceeded; // did we succeed in installing the task? (used in dtor)
short mAnimation; // stage of animation
};
#endif

Просмотреть файл

@ -55,6 +55,8 @@ REQUIRES = xpcom \
view \
intl \
uconv \
dom \
windowwatcher \
unicharutil \
$(NULL)

Просмотреть файл

@ -381,7 +381,7 @@ NS_IMETHODIMP nsDeviceContextBeOS::GetDeviceContextFor(nsIDeviceContextSpec *aDe
#endif /* USE_POSTSCRIPT */
}
NS_IMETHODIMP nsDeviceContextBeOS::BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage)
NS_IMETHODIMP nsDeviceContextBeOS::BeginDocument(PRUnichar * aTitle)
{
return NS_OK;
}

Просмотреть файл

@ -81,7 +81,7 @@ public:
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
nsIDeviceContext *&aContext);
NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage);
NS_IMETHOD BeginDocument(PRUnichar * aTitle);
NS_IMETHOD EndDocument(void);
NS_IMETHOD BeginPage(void);

Просмотреть файл

@ -42,6 +42,19 @@
#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
@ -140,12 +153,73 @@ 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<nsISupportsArray> array;
NS_NewISupportsArray(getter_AddRefs(array));
if (!array) return NS_ERROR_FAILURE;
nsCOMPtr<nsIPrintSettings> ps = aPS;
nsCOMPtr<nsISupports> psSupports(do_QueryInterface(ps));
NS_ASSERTION(psSupports, "PrintSettings must be a supports");
array->AppendElement(psSupports);
nsCOMPtr<nsIDialogParamBlock> ioParamBlock(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1"));
if (ioParamBlock) {
ioParamBlock->SetInt(0, 0);
nsCOMPtr<nsISupports> blkSupps(do_QueryInterface(ioParamBlock));
NS_ASSERTION(blkSupps, "IOBlk must be a supports");
array->AppendElement(blkSupps);
nsCOMPtr<nsISupports> arguments(do_QueryInterface(array));
NS_ASSERTION(array, "array must be a supports");
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
if (wwatch) {
nsCOMPtr<nsIDOMWindow> active;
wwatch->GetActiveWindow(getter_AddRefs(active));
nsCOMPtr<nsIDOMWindowInternal> parent = do_QueryInterface(active);
nsCOMPtr<nsIDOMWindow> 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)
NS_IMETHODIMP nsDeviceContextSpecBeOS::Init(nsIPrintSettings* aPS, PRBool aQuiet)
{
nsresult rv = NS_ERROR_FAILURE;
NS_ASSERTION(nsnull != aPS, "No print settings.");
@ -186,88 +260,99 @@ NS_IMETHODIMP nsDeviceContextSpecBeOS::Init(nsIPrintSettings* aPS)
return rv;
}
if (!aQuiet ) {
rv = DisplayXPDialog(aPS,
"chrome://global/content/printdialog.xul", canPrint);
}
else {
canPrint = PR_TRUE;
}
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
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 (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 (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);
if (command != nsnull) {
nsMemory::Free(command);
}
if (printfile != nsnull) {
nsMemory::Free(printfile);
}
return NS_OK;
}
return rv;
@ -479,7 +564,19 @@ NS_IMETHODIMP nsPrinterEnumeratorBeOS::InitPrintSettingsFromPrinter(const PRUnic
NS_IMETHODIMP nsPrinterEnumeratorBeOS::DisplayPropertiesDlg(const PRUnichar *aPrinter, nsIPrintSettings *aPrintSettings)
{
return NS_OK;
/* 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);
}
//----------------------------------------------------------------------

Просмотреть файл

@ -68,10 +68,14 @@ public:
/**
* Initialize the nsDeviceContextSpecBeOS for use. This will allocate a printrecord for use
* @update dc 2/16/98
* @param aIsPrintPreview if PR_TRUE, creating Spec for PrintPreview
* @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);
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet);
/**

Просмотреть файл

@ -79,15 +79,15 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryBeOS :: Init(void)
*/
NS_IMETHODIMP nsDeviceContextSpecFactoryBeOS :: CreateDeviceContextSpec(nsIWidget *aWidget,
nsIPrintSettings* aPrintSettings,
nsIDeviceContextSpec *&aNewSpec,
PRBool aIsPrintPreview)
nsIDeviceContextSpec *&aNewSpec,
PRBool aQuiet)
{
nsresult rv;
static NS_DEFINE_CID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
nsCOMPtr<nsIDeviceContextSpec> devSpec = do_CreateInstance(kDeviceContextSpecCID, &rv);
if (NS_SUCCEEDED(rv))
{
rv = ((nsDeviceContextSpecBeOS *)devSpec.get())->Init(aPrintSettings);
rv = ((nsDeviceContextSpecBeOS *)devSpec.get())->Init(aPrintSettings, aQuiet);
if (NS_SUCCEEDED(rv))
{
aNewSpec = devSpec;

Просмотреть файл

@ -53,7 +53,7 @@ public:
NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget,
nsIPrintSettings* aPrintSettings,
nsIDeviceContextSpec *&aNewSpec,
PRBool aIsPrintPreview);
PRBool aQuiet);
protected:
virtual ~nsDeviceContextSpecFactoryBeOS();

Просмотреть файл

@ -37,13 +37,15 @@ REQUIRES = xpcom \
widget \
view \
util \
dom \
pref \
uconv \
unicharutil \
windowwatcher \
locale \
necko \
content \
layout \
necko \
$(NULL)
# Sun's Complex Text Layout support

Просмотреть файл

@ -562,7 +562,7 @@ NS_IMETHODIMP nsDeviceContextGTK::GetDeviceContextFor(nsIDeviceContextSpec *aDev
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP nsDeviceContextGTK::BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage)
NS_IMETHODIMP nsDeviceContextGTK::BeginDocument(PRUnichar * aTitle)
{
return NS_OK;
}

Просмотреть файл

@ -84,7 +84,7 @@ public:
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
nsIDeviceContext *&aContext);
NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage);
NS_IMETHOD BeginDocument(PRUnichar * aTitle);
NS_IMETHOD EndDocument(void);
NS_IMETHOD AbortDocument(void);

Просмотреть файл

@ -77,14 +77,14 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryGTK :: Init(void)
NS_IMETHODIMP nsDeviceContextSpecFactoryGTK :: CreateDeviceContextSpec(nsIWidget *aWidget,
nsIPrintSettings* aPrintSettings,
nsIDeviceContextSpec *&aNewSpec,
PRBool aIsPrintPreview)
PRBool aQuiet)
{
nsresult rv;
static NS_DEFINE_CID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
nsCOMPtr<nsIDeviceContextSpec> devSpec = do_CreateInstance(kDeviceContextSpecCID, &rv);
if (NS_SUCCEEDED(rv))
{
rv = ((nsDeviceContextSpecGTK *)devSpec.get())->Init(aPrintSettings);
rv = ((nsDeviceContextSpecGTK *)devSpec.get())->Init(aPrintSettings, aQuiet);
if (NS_SUCCEEDED(rv))
{
aNewSpec = devSpec;

Просмотреть файл

@ -53,7 +53,7 @@ public:
NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget,
nsIPrintSettings* aPrintSettings,
nsIDeviceContextSpec *&aNewSpec,
PRBool aIsPrintPreview);
PRBool aQuiet);
protected:
virtual ~nsDeviceContextSpecFactoryGTK();

Просмотреть файл

@ -51,9 +51,16 @@
#include "nsIPref.h"
#include "prenv.h" /* for PR_GetEnv */
#include "nsPrintfCString.h"
#include "nsIDOMWindowInternal.h"
#include "nsIServiceManager.h"
#include "nsIDialogParamBlock.h"
#include "nsISupportsPrimitives.h"
#include "nsIWindowWatcher.h"
#include "nsReadableUtils.h"
#include "nsIServiceManager.h"
#include "nsISupportsArray.h"
#include "nsPrintfCString.h"
#ifdef USE_XPRINT
#include "xprintutil.h"
@ -247,6 +254,66 @@ 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<nsISupportsArray> array;
NS_NewISupportsArray(getter_AddRefs(array));
if (!array) return NS_ERROR_FAILURE;
nsCOMPtr<nsIPrintSettings> ps = aPS;
nsCOMPtr<nsISupports> psSupports(do_QueryInterface(ps));
NS_ASSERTION(psSupports, "PrintSettings must be a supports");
array->AppendElement(psSupports);
nsCOMPtr<nsIDialogParamBlock> ioParamBlock(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1"));
if (ioParamBlock) {
ioParamBlock->SetInt(0, 0);
nsCOMPtr<nsISupports> blkSupps(do_QueryInterface(ioParamBlock));
NS_ASSERTION(blkSupps, "IOBlk must be a supports");
array->AppendElement(blkSupps);
nsCOMPtr<nsISupports> arguments(do_QueryInterface(array));
NS_ASSERTION(array, "array must be a supports");
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
if (wwatch) {
nsCOMPtr<nsIDOMWindow> active;
wwatch->GetActiveWindow(getter_AddRefs(active));
nsCOMPtr<nsIDOMWindowInternal> parent = do_QueryInterface(active);
nsCOMPtr<nsIDOMWindow> 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
@ -256,19 +323,19 @@ NS_IMPL_ISUPPORTS1(nsDeviceContextSpecGTK,
* toolkits including:
* - GTK+-toolkit:
* file: mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp
* function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init()
* function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init(PRBool aQuiet)
* - GTK-toolkit:
* file: mozilla/gfx/src/xlib/nsDeviceContextSpecGTK.cpp
* function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init()
* function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init(PRBool aQuiet)
* - Qt-toolkit:
* file: mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp
* function: NS_IMETHODIMP nsDeviceContextSpecQT::Init()
* function: NS_IMETHODIMP nsDeviceContextSpecQT::Init(PRBool aQuiet)
*
* ** Please update the other toolkits when changing this function.
*/
NS_IMETHODIMP nsDeviceContextSpecGTK::Init(nsIPrintSettings *aPS)
NS_IMETHODIMP nsDeviceContextSpecGTK::Init(nsIPrintSettings *aPS, PRBool aQuiet)
{
DO_PR_DEBUG_LOG(("nsDeviceContextSpecGTK::Init(aPS=%p)\n", aPS);
DO_PR_DEBUG_LOG(("nsDeviceContextSpecGTK::Init(aPS=%p. qQuiet=%d)\n", aPS, (int)aQuiet));
nsresult rv = NS_ERROR_FAILURE;
mPrintSettings = aPS;
@ -283,76 +350,88 @@ NS_IMETHODIMP nsDeviceContextSpecGTK::Init(nsIPrintSettings *aPS)
}
}
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 (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 (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;
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():"<NULL>"));
DO_PR_DEBUG_LOG(("command '%s'\n", command? NS_ConvertUCS2toUTF8(command).get():"<NULL>"));
DO_PR_DEBUG_LOG(("printer '%s'\n", printer? NS_ConvertUCS2toUTF8(printer).get():"<NULL>"));
DO_PR_DEBUG_LOG(("papername '%s'\n", papername? NS_ConvertUCS2toUTF8(papername).get():"<NULL>"));
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():"<NULL>"));
DO_PR_DEBUG_LOG(("command '%s'\n", command? NS_ConvertUCS2toUTF8(command).get():"<NULL>"));
DO_PR_DEBUG_LOG(("printer '%s'\n", printer? NS_ConvertUCS2toUTF8(printer).get():"<NULL>"));
DO_PR_DEBUG_LOG(("papername '%s'\n", papername? NS_ConvertUCS2toUTF8(papername).get():"<NULL>"));
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;
@ -914,7 +993,19 @@ NS_IMETHODIMP nsPrinterEnumeratorGTK::InitPrintSettingsFromPrinter(const PRUnich
NS_IMETHODIMP nsPrinterEnumeratorGTK::DisplayPropertiesDlg(const PRUnichar *aPrinter, nsIPrintSettings *aPrintSettings)
{
return NS_OK;
/* 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);
}
//----------------------------------------------------------------------

Просмотреть файл

@ -74,7 +74,7 @@ public:
NS_DECL_ISUPPORTS
NS_IMETHOD Init(nsIPrintSettings* aPS);
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet);
NS_IMETHOD ClosePrintManager();
NS_IMETHOD GetToPrinter(PRBool &aToPrinter);

Просмотреть файл

@ -35,6 +35,7 @@ REQUIRES = xpcom \
widget \
view \
util \
dom \
pref \
js \
uconv \
@ -42,6 +43,7 @@ REQUIRES = xpcom \
unicharutil \
gfx2 \
mozcomps \
windowwatcher \
content \
layout \
locale \
@ -66,7 +68,6 @@ CPPSRCS = \
nsScreenMac.cpp \
nsScreenManagerMac.cpp \
nsPrintOptionsX.cpp \
nsPrintSettingsX.cpp \
nsFontUtils.cpp \
nsNativeThemeMac.cpp \
$(NULL)

Просмотреть файл

@ -707,10 +707,7 @@ NS_IMETHODIMP nsDeviceContextMac::GetDeviceContextFor(nsIDeviceContextSpec *aDev
* See documentation in nsIDeviceContext.h
* @update 12/9/98 dwc
*/
NS_IMETHODIMP nsDeviceContextMac::BeginDocument(PRUnichar * aTitle,
PRUnichar* aPrintToFileName,
PRInt32 aStartPage,
PRInt32 aEndPage)
NS_IMETHODIMP nsDeviceContextMac::BeginDocument(PRUnichar * aTitle)
{
#if !TARGET_CARBON
GrafPtr thePort;
@ -727,7 +724,7 @@ GrafPtr thePort;
nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsIPrintingContext> printingContext = do_QueryInterface(mSpec);
if (printingContext)
rv = printingContext->BeginDocument(aStartPage, aEndPage);
rv = printingContext->BeginDocument();
return rv;
#endif
}

Просмотреть файл

@ -79,10 +79,7 @@ public:
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
nsIDeviceContext *&aContext);
NS_IMETHOD BeginDocument(PRUnichar * aTitle,
PRUnichar* aPrintToFileName,
PRInt32 aStartPage,
PRInt32 aEndPage);
NS_IMETHOD BeginDocument(PRUnichar * aTitle);
NS_IMETHOD EndDocument(void);
NS_IMETHOD AbortDocument(void);

Просмотреть файл

@ -82,7 +82,7 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryMac :: Init(void)
NS_IMETHODIMP nsDeviceContextSpecFactoryMac :: CreateDeviceContextSpec(nsIWidget *aWidget,
nsIPrintSettings* aPrintSettings,
nsIDeviceContextSpec *&aNewSpec,
PRBool aIsPrintPreview)
PRBool aQuiet)
{
nsresult rv;
@ -91,7 +91,7 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryMac :: CreateDeviceContextSpec(nsIWidget
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIPrintingContext> printingContext = do_QueryInterface(devSpec,&rv);
if (NS_SUCCEEDED(rv)) {
rv = printingContext->Init(aPrintSettings,aIsPrintPreview);
rv = printingContext->Init(aPrintSettings,aQuiet);
if (NS_SUCCEEDED(rv)) {
aNewSpec = devSpec;
NS_ADDREF(aNewSpec);

Просмотреть файл

@ -53,7 +53,7 @@ public:
NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget,
nsIPrintSettings* aPrintSettings,
nsIDeviceContextSpec *&aNewSpec,
PRBool aIsPrintPreview);
PRBool aQuiet);
protected:
~nsDeviceContextSpecFactoryMac();

Просмотреть файл

@ -37,10 +37,59 @@
* ***** END LICENSE BLOCK ***** */
#include "nsDeviceContextSpecMac.h"
#include "prmem.h"
#include "plstr.h"
#include "nsWatchTask.h"
#include "nsIServiceManager.h"
#include "nsIPrintOptions.h"
#include "nsIPrintSettingsMac.h"
#include "nsGfxCIID.h"
#include "nsGfxUtils.h"
#if !TARGET_CARBON
#include "nsMacResources.h"
#include <Resources.h>
#include <Dialogs.h>
#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
@ -51,6 +100,7 @@ nsDeviceContextSpecMac::nsDeviceContextSpecMac()
, mPrintManagerOpen(PR_FALSE)
{
NS_INIT_REFCNT();
gPrintSettings = nsnull;
}
/** -------------------------------------------------------
@ -65,36 +115,321 @@ 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<nsIPrintOptions> 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<nsIPrintOptions> 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 aIsPrintPreview)
NS_IMETHODIMP nsDeviceContextSpecMac::Init(nsIPrintSettings* aPS, PRBool aQuiet)
{
nsCOMPtr<nsIPrintSettingsMac> 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;
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;
}
nsresult rv = printSettingsMac->GetTHPrint(&mPrtRec);
// make sure the print record is valid
::PrValidate(mPrtRec);
THPrint hPrintRec; // handle to print record
GrafPtr oldport;
PDlgInitUPP theInitProcPtr;
::GetPort(&oldport);
nsresult rv;
nsCOMPtr<nsIPrintOptions> 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;
return NS_OK;
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;
}
// make sure the print record is valid
::PrValidate(hPrintRec);
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;
}
/** -------------------------------------------------------
@ -103,14 +438,18 @@ NS_IMETHODIMP nsDeviceContextSpecMac::Init(nsIPrintSettings* aPS, PRBool aIsPrin
*/
NS_IMETHODIMP nsDeviceContextSpecMac::ClosePrintManager()
{
if (mPrintManagerOpen)
PRBool isPMOpen;
PrintManagerOpen(&isPMOpen);
if (isPMOpen) {
#if !TARGET_CARBON
::PrClose();
#endif
}
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecMac::BeginDocument(PRInt32 aStartPage,
PRInt32 aEndPage)
NS_IMETHODIMP nsDeviceContextSpecMac::BeginDocument()
{
nsresult rv = NS_OK;
return rv;

Просмотреть файл

@ -58,10 +58,14 @@ public:
/**
* Initialize the nsDeviceContextSpecMac for use. This will allocate a printrecord for use
* @update dc 12/02/98
* @param aIsPrintPreview TRUE if doing print preview, FALSE if normal printing.
* @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 aIsPrintPreview);
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet);
/**
@ -79,8 +83,7 @@ public:
*/
NS_IMETHOD ClosePrintManager();
NS_IMETHOD BeginDocument(PRInt32 aStartPage,
PRInt32 aEndPage);
NS_IMETHOD BeginDocument();
NS_IMETHOD EndDocument();

Просмотреть файл

@ -22,7 +22,6 @@
* Contributor(s):
* Patrick C. Beard <beard@netscape.com>
* Simon Fraser <sfraser@netscape.com>
* Conrad Carlen <ccarlen@netscape.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
@ -47,7 +46,18 @@
#include "nsIServiceManager.h"
#include "nsIPrintOptions.h"
#include "nsIPrintSettingsX.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;
/** -------------------------------------------------------
* Construct the nsDeviceContextSpecX
@ -78,29 +88,130 @@ NS_IMPL_ISUPPORTS2(nsDeviceContextSpecX, nsIDeviceContextSpec, nsIPrintingContex
* Initialize the nsDeviceContextSpecMac
* @update dc 12/02/98
*/
NS_IMETHODIMP nsDeviceContextSpecX::Init(nsIPrintSettings* aPS, PRBool aIsPrintPreview)
NS_IMETHODIMP nsDeviceContextSpecX::Init(nsIPrintSettings* aPS, PRBool aQuiet)
{
nsresult rv;
OSStatus status;
nsCOMPtr<nsIPrintOptions> 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;
if (!aIsPrintPreview) {
status = ::PMBegin();
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 (status != noErr)
return NS_ERROR_FAILURE;
mBeganPrinting = PR_TRUE;
}
nsCOMPtr<nsIPrintSettingsX> 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;
// 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);
}
}
}
}
return NS_OK;
}
@ -128,17 +239,9 @@ NS_IMETHODIMP nsDeviceContextSpecX::ClosePrintManager()
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecX::BeginDocument(PRInt32 aStartPage,
PRInt32 aEndPage)
NS_IMETHODIMP nsDeviceContextSpecX::BeginDocument()
{
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);
OSStatus status = ::PMBeginDocument(mPrintSettings, mPageFormat, &mPrintingContext);
if (status != noErr) return NS_ERROR_ABORT;
return NS_OK;
@ -200,8 +303,6 @@ NS_IMETHODIMP nsDeviceContextSpecX::GetPageRect(double* aTop, double* aLeft, dou
*aBottom = pageRect.bottom, *aRight = pageRect.right;
return NS_OK;
}
<<<<<<< nsDeviceContextSpecX.cpp
=======
@ -254,4 +355,3 @@ FSSpec spec;
return result;
}
>>>>>>> 1.19

Просмотреть файл

@ -60,10 +60,14 @@ public:
/**
* Initialize the nsDeviceContextSpecMac for use. This will allocate a printrecord for use
* @update dc 12/02/98
* @param aIsPrintPreview TRUE if doing print preview, FALSE if normal printing.
* @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 aIsPrintPreview);
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet);
/**
* This will tell if the printmanager is currently open
@ -80,8 +84,7 @@ public:
*/
NS_IMETHOD ClosePrintManager();
NS_IMETHOD BeginDocument(PRInt32 aStartPage,
PRInt32 aEndPage);
NS_IMETHOD BeginDocument();
NS_IMETHOD EndDocument();

Просмотреть файл

@ -36,17 +36,42 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
#include "nsIPref.h"
#include "nsIServiceManager.h"
#include "nsWatchTask.h"
#include "nsPrintOptionsMac.h"
#include "nsPrintSettingsMac.h"
#include "nsGfxUtils.h"
#include "plbase64.h"
#include "prmem.h"
#define MAC_OS_PAGE_SETUP_PREFNAME "print.macos.pagesetup"
/** ---------------------------------------------------
* See documentation in nsPrintOptionsMac.h
* See documentation in nsPrintOptionsWin.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();
}
}
}
/** ---------------------------------------------------
@ -55,23 +80,10 @@ nsPrintOptionsMac::nsPrintOptionsMac()
*/
nsPrintOptionsMac::~nsPrintOptionsMac()
{
}
/** ---------------------------------------------------
* 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
// get rid of the print record
if (mPrintRecord) {
::DisposeHandle((Handle)mPrintRecord);
}
}
/** ---------------------------------------------------
@ -81,51 +93,121 @@ NS_IMETHODIMP nsPrintOptionsMac::CreatePrintSettings(nsIPrintSettings **_retval)
NS_IMETHODIMP
nsPrintOptionsMac::ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings)
{
return NS_ERROR_NOT_IMPLEMENTED;
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;
}
/* [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;
return NS_ERROR_NOT_IMPLEMENTED;
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;
}
#pragma mark -
nsresult
nsPrintOptionsMac::ReadPrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags)
nsPrintOptionsMac::ReadPageSetupFromPrefs()
{
nsresult rv;
rv = nsPrintOptions::ReadPrefs(aPS, aPrefName, aFlags);
NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::ReadPrefs() failed");
nsCOMPtr<nsIPrintSettingsMac> 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;
nsCOMPtr<nsIPref> 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;
}
nsresult
nsPrintOptionsMac::WritePrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags)
nsPrintOptionsMac::WritePageSetupToPrefs()
{
if (!mPrintRecord)
return NS_ERROR_NOT_INITIALIZED;
nsresult rv;
rv = nsPrintOptions::WritePrefs(aPS, aPrefName, aFlags);
NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::WritePrefs() failed");
nsCOMPtr<nsIPrintSettingsMac> 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;
nsCOMPtr<nsIPref> 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);
}

Просмотреть файл

@ -39,13 +39,19 @@ public:
virtual ~nsPrintOptionsMac();
NS_IMETHOD ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings);
NS_IMETHOD GetNativeData(PRInt16 aDataType, void * *_retval);
NS_IMETHOD CreatePrintSettings(nsIPrintSettings **_retval);
protected:
nsresult ReadPrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags);
nsresult WritePrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags);
nsresult ReadPageSetupFromPrefs();
nsresult WritePageSetupToPrefs();
THPrint GetPrintRecord(void) { return mPrintRecord; }
protected:
THPrint mPrintRecord;
};
#endif /* TARGET_CARBON */

Просмотреть файл

@ -43,7 +43,6 @@
#include "nsIServiceManager.h"
#include "nsWatchTask.h"
#include "nsPrintOptionsX.h"
#include "nsPrintSettingsX.h"
#include "nsIPref.h"
#include "nsGfxUtils.h"
@ -51,32 +50,37 @@
#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()
{
}
/** ---------------------------------------------------
* 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
if (mPageFormat)
::PMDisposePageFormat(mPageFormat);
}
/** ---------------------------------------------------
@ -84,51 +88,144 @@ NS_IMETHODIMP nsPrintOptionsX::CreatePrintSettings(nsIPrintSettings **_retval)
NS_IMETHODIMP
nsPrintOptionsX::ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings)
{
return NS_ERROR_NOT_IMPLEMENTED;
// 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;
}
/* [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 NS_ERROR_NOT_IMPLEMENTED;
return rv;
}
#pragma mark -
nsresult
nsPrintOptionsX::ReadPrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags)
nsPrintOptionsX::ReadPageSetupFromPrefs()
{
nsresult rv;
rv = nsPrintOptions::ReadPrefs(aPS, aPrefName, aFlags);
NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::ReadPrefs() failed");
nsCOMPtr<nsIPrintSettingsX> 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;
nsCOMPtr<nsIPref> 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;
}
nsresult
nsPrintOptionsX::WritePrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags)
nsPrintOptionsX::WritePageSetupToPrefs()
{
if (mPageFormat == kPMNoPageFormat)
return NS_ERROR_NOT_INITIALIZED;
nsresult rv;
nsCOMPtr<nsIPref> 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);
rv = nsPrintOptions::WritePrefs(aPS, aPrefName, aFlags);
NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::WritePrefs() failed");
nsCOMPtr<nsIPrintSettingsX> 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;
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);
}

Просмотреть файл

@ -39,7 +39,10 @@
#ifndef nsPrintOptionsX_h__
#define nsPrintOptionsX_h__
#include "nsPrintOptionsImpl.h"
#include <PMDefinitions.h>
#include "nsPrintOptionsImpl.h"
//*****************************************************************************
@ -56,12 +59,15 @@ public:
NS_IMETHOD GetNativeData(PRInt16 aDataType, void * *_retval);
NS_IMETHOD CreatePrintSettings(nsIPrintSettings **_retval);
protected:
nsresult ReadPrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags);
nsresult WritePrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags);
nsresult ReadPageSetupFromPrefs();
nsresult WritePageSetupToPrefs();
protected:
PMPageFormat mPageFormat; // persist this between runs
};

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -112,7 +112,9 @@ nsFont* nsPrintOptions::sDefaultFont = nsnull;
* See documentation in nsPrintOptionsImpl.h
* @update 6/21/00 dwc
*/
nsPrintOptions::nsPrintOptions()
nsPrintOptions::nsPrintOptions() :
mIsCancelled(PR_FALSE),
mPrintToFile(PR_FALSE)
{
NS_INIT_ISUPPORTS();
@ -897,6 +899,79 @@ 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)
{

Просмотреть файл

@ -54,12 +54,18 @@ protected:
nsresult ReadPrefDouble(nsIPref * aPref, const char * aPrefId, double& aVal);
nsresult WritePrefDouble(nsIPref * aPref, const char * aPrefId, double aVal);
virtual nsresult ReadPrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags);
virtual nsresult WritePrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags);
nsresult ReadPrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags);
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<nsIPrintSettings> mGlobalPrintSettings;
nsCString mPrefName;

Просмотреть файл

@ -91,46 +91,6 @@ nsPrintSettings::nsPrintSettings() :
}
/** ---------------------------------------------------
* See documentation in nsPrintSettingsImpl.h
* @update 6/21/00 dwc
*/
nsPrintSettings::nsPrintSettings(const nsPrintSettings* aPS) :
mPrintOptions(aPS->mPrintOptions),
mPrintRange(aPS->mPrintRange),
mStartPageNum(aPS->mStartPageNum),
mEndPageNum(aPS->mEndPageNum),
mScaling(aPS->mScaling),
mPrintBGColors(aPS->mPrintBGColors),
mPrintBGImages(aPS->mPrintBGImages),
mPrintFrameTypeUsage(aPS->mPrintFrameTypeUsage),
mPrintFrameType(aPS->mPrintFrameType),
mHowToEnableFrameUI(aPS->mHowToEnableFrameUI),
mIsCancelled(aPS->mIsCancelled),
mPrintSilent(aPS->mPrintSilent),
mPrintPreview(aPS->mPrintPreview),
mShrinkToFit(aPS->mShrinkToFit),
mPrintPageDelay(aPS->mPrintPageDelay),
mPaperData(aPS->mPaperData),
mPaperSizeType(aPS->mPaperSizeType),
mPaperWidth(aPS->mPaperWidth),
mPaperHeight(aPS->mPaperHeight),
mPaperSizeUnit(aPS->mPaperSizeUnit),
mPrintReversed(aPS->mPrintReversed),
mPrintInColor(aPS->mPrintInColor),
mOrientation(aPS->mOrientation),
mNumCopies(aPS->mNumCopies),
mPrintToFile(aPS->mPrintToFile),
mMargin(aPS->mMargin)
{
NS_INIT_ISUPPORTS();
for (PRInt32 i=0;i<3;i++) {
mHeaderStrs[i] = aPS->mHeaderStrs[i];
mFooterStrs[i] = aPS->mFooterStrs[i];
}
}
/** ---------------------------------------------------
* See documentation in nsPrintSettingsImpl.h
* @update 6/21/00 dwc
@ -809,16 +769,3 @@ nsPrintSettings::GetPageSizeInTwips(PRInt32 *aWidth, PRInt32 *aHeight)
return NS_OK;
}
nsresult
nsPrintSettings::CloneObj(nsIPrintSettings **_retval)
{
nsPrintSettings* printSettings = new nsPrintSettings(this);
return printSettings->QueryInterface(NS_GET_IID(nsIPrintSettings), (void**)_retval); // ref counts
}
/* nsIPrintSettings clone (); */
NS_IMETHODIMP
nsPrintSettings::Clone(nsIPrintSettings **_retval)
{
return CloneObj(_retval);
}

Просмотреть файл

@ -37,12 +37,9 @@ public:
NS_DECL_NSIPRINTSETTINGS
nsPrintSettings();
nsPrintSettings(const nsPrintSettings* aPS);
virtual ~nsPrintSettings();
protected:
virtual nsresult CloneObj(nsIPrintSettings **_retval);
typedef enum {
eHeader,
eFooter

Просмотреть файл

@ -37,8 +37,10 @@ REQUIRES = xpcom \
widget \
view \
util \
dom \
pref \
uconv \
windowwatcher \
locale \
unicharutil \
$(NULL)

Просмотреть файл

@ -892,7 +892,7 @@ nsresult nsDeviceContextOS2::CreateFontAliasTable()
}
// Printing ------------------------------------------------------------------
nsresult nsDeviceContextOS2::PrepareDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName)
nsresult nsDeviceContextOS2::BeginDocument(PRUnichar * aTitle)
{
nsresult rv = NS_OK;
@ -923,12 +923,6 @@ nsresult nsDeviceContextOS2::PrepareDocument(PRUnichar * aTitle, PRUnichar* aPri
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)

Просмотреть файл

@ -88,9 +88,7 @@ public:
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
nsIDeviceContext *&aContext);
NS_IMETHOD PrepareDocument(PRUnichar * aTitle,
PRUnichar* aPrintToFileName);
NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage);
NS_IMETHOD BeginDocument(PRUnichar * aTitle);
NS_IMETHOD EndDocument(void);
NS_IMETHOD AbortDocument(void);

Просмотреть файл

@ -63,14 +63,14 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryOS2 :: Init(void)
NS_IMETHODIMP nsDeviceContextSpecFactoryOS2 :: CreateDeviceContextSpec(nsIWidget *aWidget,
nsIPrintSettings* aPrintSettings,
nsIDeviceContextSpec *&aNewSpec,
PRBool aIsPrintPreview)
PRBool aQuiet)
{
nsresult rv;
static NS_DEFINE_CID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
nsCOMPtr<nsIDeviceContextSpec> devSpec = do_CreateInstance(kDeviceContextSpecCID, &rv);
if (NS_SUCCEEDED(rv)) {
rv = ((nsDeviceContextSpecOS2 *)devSpec.get())->Init(aPrintSettings, aIsPrintPreview);
rv = ((nsDeviceContextSpecOS2 *)devSpec.get())->Init(aPrintSettings, aQuiet);
if (NS_SUCCEEDED(rv)) {
aNewSpec = devSpec;
NS_ADDREF(aNewSpec);

Просмотреть файл

@ -54,7 +54,7 @@ public:
NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget,
nsIPrintSettings* aPrintSettings,
nsIDeviceContextSpec *&aNewSpec,
PRBool aIsPrintPreview);
PRBool aQuiet);
protected:
~nsDeviceContextSpecFactoryOS2();

Просмотреть файл

@ -28,7 +28,12 @@
#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;
@ -254,17 +259,17 @@ NS_IMPL_RELEASE(nsDeviceContextSpecOS2)
* toolkits including:
* - GTK+-toolkit:
* file: mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp
* function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init(PRBool aPrintPreview)
* function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init(PRBool aQuiet)
* - Xlib-toolkit:
* file: mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp
* function: NS_IMETHODIMP nsDeviceContextSpecXlib::Init(PRBool aPrintPreview)
* function: NS_IMETHODIMP nsDeviceContextSpecXlib::Init(PRBool aQuiet)
* - Qt-toolkit:
* file: mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp
* function: NS_IMETHODIMP nsDeviceContextSpecQT::Init(PRBool aPrintPreview)
* function: NS_IMETHODIMP nsDeviceContextSpecQT::Init(PRBool aQuiet)
*
* ** Please update the other toolkits when changing this function.
*/
NS_IMETHODIMP nsDeviceContextSpecOS2::Init(nsIPrintSettings* aPS, PRBool aPrintPreview)
NS_IMETHODIMP nsDeviceContextSpecOS2::Init(nsIPrintSettings* aPS, PRBool aQuiet)
{
nsresult rv = NS_ERROR_FAILURE;
@ -281,46 +286,65 @@ NS_IMETHODIMP nsDeviceContextSpecOS2::Init(nsIPrintSettings* aPS, PRBool aPrintP
}
}
char *path;
PRBool tofile = PR_FALSE;
PRInt16 printRange = nsIPrintSettings::kRangeAllPages;
PRInt32 fromPage = 1;
PRInt32 toPage = 1;
PRInt32 copies = 1;
PRUnichar *printer = nsnull;
PRUnichar *printfile = nsnull;
PRBool canPrint = PR_FALSE;
rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
if (NS_FAILED(rv)) {
return rv;
}
if (mPrintSettings) {
mPrintSettings->GetPrinterName(&printer);
mPrintSettings->GetPrintRange(&printRange);
mPrintSettings->GetToFileName(&printfile);
mPrintSettings->GetPrintToFile(&tofile);
mPrintSettings->GetStartPageRange(&fromPage);
mPrintSettings->GetEndPageRange(&toPage);
mPrintSettings->GetNumCopies(&copies);
if ( !aQuiet ) {
rv = NS_ERROR_FAILURE;
// create a nsISupportsArray of the parameters
// being passed to the window
nsCOMPtr<nsISupportsArray> array;
NS_NewISupportsArray(getter_AddRefs(array));
if (!array) return NS_ERROR_FAILURE;
if ((copies == 0) || (copies > 999)) {
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
return NS_ERROR_FAILURE;
nsCOMPtr<nsIPrintSettings> ps = aPS;
nsCOMPtr<nsISupports> psSupports(do_QueryInterface(ps));
NS_ASSERTION(psSupports, "PrintSettings must be a supports");
array->AppendElement(psSupports);
nsCOMPtr<nsIDialogParamBlock> ioParamBlock(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1"));
if (ioParamBlock) {
ioParamBlock->SetInt(0, 0);
nsCOMPtr<nsISupports> blkSupps(do_QueryInterface(ioParamBlock));
NS_ASSERTION(blkSupps, "IOBlk must be a supports");
array->AppendElement(blkSupps);
nsCOMPtr<nsISupports> arguments(do_QueryInterface(array));
NS_ASSERTION(array, "array must be a supports");
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
if (wwatch) {
nsCOMPtr<nsIDOMWindow> active;
wwatch->GetActiveWindow(getter_AddRefs(active));
nsCOMPtr<nsIDOMWindowInternal> parent = do_QueryInterface(active);
nsCOMPtr<nsIDOMWindow> newWindow;
rv = wwatch->OpenWindow(parent, "chrome://global/content/printdialog.xul",
"_blank", "chrome,modal,centerscreen", array,
getter_AddRefs(newWindow));
}
}
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());
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;
}
<<<<<<< nsDeviceContextSpecOS2.cpp
mPrData.toPrinter = !tofile;
mPrData.copies = copies;
=======
if (canPrint) {
if (aPS) {
PRBool tofile = PR_FALSE;
@ -353,13 +377,7 @@ NS_IMETHODIMP nsDeviceContextSpecOS2::Init(nsIPrintSettings* aPS, PRBool aPrintP
mPrData.toPrinter = !tofile;
mPrData.copies = copies;
>>>>>>> 1.12
<<<<<<< nsDeviceContextSpecOS2.cpp
rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
if (NS_FAILED(rv))
return rv;
=======
rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
if (NS_FAILED(rv))
return rv;
@ -374,25 +392,7 @@ NS_IMETHODIMP nsDeviceContextSpecOS2::Init(nsIPrintSettings* aPS, PRBool aPrintP
}
}
}
>>>>>>> 1.12
<<<<<<< nsDeviceContextSpecOS2.cpp
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())))
mQueue = PrnDlg.SetPrinterQueue(i);
}
}
if (printfile != nsnull)
nsMemory::Free(printfile);
if (printer != nsnull)
nsMemory::Free(printer);
=======
if (printfile != nsnull)
nsMemory::Free(printfile);
@ -400,7 +400,6 @@ NS_IMETHODIMP nsDeviceContextSpecOS2::Init(nsIPrintSettings* aPS, PRBool aPrintP
nsMemory::Free(printer);
}
}
>>>>>>> 1.12
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
return rv;

Просмотреть файл

@ -132,10 +132,14 @@ public:
/**
* Initialize the nsDeviceContextSpecMac for use. This will allocate a printrecord for use
* @update dc 2/16/98
* @param aIsPrintPreview if PR_TRUE, creating Spec for PrintPreview
* @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 aIsPrintPreview);
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet);
NS_IMETHOD ClosePrintManager();

Просмотреть файл

@ -36,9 +36,11 @@ REQUIRES = xpcom \
widget \
view \
util \
dom \
pref \
uconv \
unicharutil \
windowwatcher \
locale \
intl \
$(NULL)

Просмотреть файл

@ -451,7 +451,7 @@ int nsDeviceContextPh::prefChanged( const char *aPref, void *aClosure ) {
return 0;
}
NS_IMETHODIMP nsDeviceContextPh :: BeginDocument( PRUnichar *t, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage ) {
NS_IMETHODIMP nsDeviceContextPh :: BeginDocument( PRUnichar *t ) {
PpPrintContext_t *pc = ((nsDeviceContextSpecPh *)mSpec)->GetPrintContext();
PpStartJob(pc);
mIsPrinting = 1;

Просмотреть файл

@ -84,7 +84,7 @@ public:
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
nsIDeviceContext *&aContext);
NS_IMETHOD BeginDocument(PRUnichar *t, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage);
NS_IMETHOD BeginDocument(PRUnichar *t);
NS_IMETHOD EndDocument(void);
NS_IMETHOD AbortDocument(void);

Просмотреть файл

@ -72,7 +72,7 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryPh :: Init(void)
NS_IMETHODIMP nsDeviceContextSpecFactoryPh :: CreateDeviceContextSpec(nsIWidget *aWidget,
nsIPrintSettings* aPrintSettings,
nsIDeviceContextSpec *&aNewSpec,
PRBool aIsPrintPreview)
PRBool aQuiet)
{
NS_ENSURE_ARG_POINTER(aWidget);
PpPrintContext_t *pc = NULL;
@ -90,6 +90,8 @@ 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;
@ -100,7 +102,7 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryPh :: CreateDeviceContextSpec(nsIWidget
{
specPh->SetPrintContext(pc);
}
rv = specPh->Init(aWidget, aPrintSettings, PR_TRUE);
rv = specPh->Init(aWidget, aPrintSettings, aQuiet);
if (NS_SUCCEEDED(rv)) {
aNewSpec = devSpec;
} else {

Просмотреть файл

@ -53,7 +53,7 @@ public:
NS_IMETHOD CreateDeviceContextSpec( nsIWidget *aWidget,
nsIPrintSettings* aPrintSettings,
nsIDeviceContextSpec *&aNewSpec,
PRBool aIsPrintPreview);
PRBool aQuiet);
protected:
virtual ~nsDeviceContextSpecFactoryPh();

Просмотреть файл

@ -42,11 +42,23 @@
#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();

Просмотреть файл

@ -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, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage)
NS_IMETHODIMP nsDeviceContextPS::BeginDocument(PRUnichar * aTitle)
{
PR_LOG(nsDeviceContextPSLM, PR_LOG_DEBUG, ("nsDeviceContextPS::BeginDocument()\n"));

Просмотреть файл

@ -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, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage);
NS_IMETHOD BeginDocument(PRUnichar * aTitle);
NS_IMETHOD EndDocument(void);
NS_IMETHOD AbortDocument(void);
NS_IMETHOD BeginPage(void);

Просмотреть файл

@ -37,9 +37,12 @@ REQUIRES = xpcom \
gfx2 \
uconv \
pref \
dom \
util \
js \
appshell \
mozcomps \
windowwatcher \
unicharutil \
intl \
locale \

Просмотреть файл

@ -42,6 +42,8 @@ REQUIRES = xpcom \
unicharutil \
locale \
necko \
dom \
windowwatcher \
content \
layout \
$(NULL)

Просмотреть файл

@ -35,6 +35,8 @@ REQUIRES = xpcom \
unicharutil \
locale \
necko \
dom \
windowwatcher \
content \
layout \
layout_xul \

Просмотреть файл

@ -66,7 +66,7 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryWin :: Init(void)
NS_IMETHODIMP nsDeviceContextSpecFactoryWin :: CreateDeviceContextSpec(nsIWidget *aWidget,
nsIPrintSettings* aPrintSettings,
nsIDeviceContextSpec *&aNewSpec,
PRBool aIsPrintPreview)
PRBool aQuiet)
{
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, aIsPrintPreview);
rv = specWin->Init(aWidget, aPrintSettings, aQuiet);
if (NS_SUCCEEDED(rv)) {
aNewSpec = devspec;
} else {

Просмотреть файл

@ -55,7 +55,7 @@ public:
NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget,
nsIPrintSettings* aPrintSettings,
nsIDeviceContextSpec *&aNewSpec,
PRBool aIsPrintPreview);
PRBool aQuiet);
protected:
~nsDeviceContextSpecFactoryWin();

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -51,7 +51,7 @@ public:
NS_DECL_ISUPPORTS
NS_IMETHOD Init(nsIWidget* aWidget, nsIPrintSettings* aPS, PRBool aIsPrintPreview);
NS_IMETHOD Init(nsIWidget* aWidget, nsIPrintSettings* aPS, PRBool aQuiet);
void GetDriverName(char *&aDriverName) const { aDriverName = mDriverName; }
void GetDeviceName(char *&aDeviceName) const { aDeviceName = mDeviceName; }
@ -70,6 +70,12 @@ 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);
@ -87,6 +93,9 @@ protected:
PRBool mIsDEVMODEGlobalHandle;
nsCOMPtr<nsIPrintSettings> mPrintSettings;
// For PrintDlgEx
FARPROC mUseExtendedPrintDlg;
};

Просмотреть файл

@ -47,7 +47,10 @@
#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
@ -752,7 +755,7 @@ static void DisplayLastError()
#endif
NS_IMETHODIMP nsDeviceContextWin :: BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage)
NS_IMETHODIMP nsDeviceContextWin :: BeginDocument(PRUnichar * aTitle)
{
nsresult rv = NS_ERROR_GFX_PRINTER_STARTDOC;
@ -768,9 +771,21 @@ NS_IMETHODIMP nsDeviceContextWin :: BeginDocument(PRUnichar * aTitle, PRUnichar*
char *title = GetACPString(titleStr);
char* docName = nsnull;
nsAutoString str(aPrintToFileName);
if (str.Length() > 0) {
docName = ToNewCString(str);
nsCOMPtr<nsIPrintOptions> 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);
}
}
}
docinfo.cbSize = sizeof(docinfo);
docinfo.lpszDocName = title != nsnull?title:"Mozilla Document";

Просмотреть файл

@ -84,7 +84,7 @@ public:
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
nsIDeviceContext *&aContext);
NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage);
NS_IMETHOD BeginDocument(PRUnichar * aTitle);
NS_IMETHOD EndDocument(void);
NS_IMETHOD AbortDocument(void);

Просмотреть файл

@ -55,26 +55,6 @@ nsPrintSettingsWin::nsPrintSettingsWin() :
}
/** ---------------------------------------------------
* See documentation in nsPrintSettingsWin.h
* @update
*/
nsPrintSettingsWin::nsPrintSettingsWin(const nsPrintSettingsWin* aPS) :
nsPrintSettings(aPS),
mDeviceName(nsnull),
mDriverName(nsnull),
mDevMode(nsnull)
{
if (aPS->mDeviceName) mDeviceName = nsCRT::strdup(aPS->mDeviceName);
if (aPS->mDriverName) mDriverName = nsCRT::strdup(aPS->mDriverName);
if (aPS->mDevMode) {
size_t size = sizeof(*aPS->mDevMode);
mDevMode = (LPDEVMODE)malloc(size);
memcpy(mDevMode, aPS->mDevMode, size);
}
}
/** ---------------------------------------------------
* See documentation in nsPrintSettingsWin.h
* @update
@ -146,11 +126,3 @@ NS_IMETHODIMP nsPrintSettingsWin::SetDevMode(DEVMODE * aDevMode)
}
return NS_OK;
}
/* nsIPrintSettings clone (); */
nsresult
nsPrintSettingsWin::CloneObj(nsIPrintSettings **_retval)
{
nsPrintSettingsWin* printSettings = new nsPrintSettingsWin(this);
return printSettings->QueryInterface(NS_GET_IID(nsIPrintSettings), (void**)_retval); // ref counts
}

Просмотреть файл

@ -32,21 +32,15 @@
//*** nsPrintSettingsWin
//*****************************************************************************
class nsPrintSettingsWin : public nsPrintSettings,
public nsIPrintSettingsWin
public nsIPrintSettingsWin
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIPRINTSETTINGSWIN
nsPrintSettingsWin();
nsPrintSettingsWin(const nsPrintSettingsWin* aPS);
virtual ~nsPrintSettingsWin();
/**
* Makes a new copy
*/
virtual nsresult CloneObj(nsIPrintSettings **_retval);
protected:
char* mDeviceName;
char* mDriverName;

Просмотреть файл

@ -38,6 +38,10 @@ REQUIRES = xpcom \
string \
xlibrgb \
widget \
dom \
layout \
content \
appshell \
js \
necko \
pref \
@ -49,6 +53,7 @@ REQUIRES = xpcom \
gfx2 \
imglib2 \
mozcomps \
windowwatcher \
intl \
$(NULL)

Просмотреть файл

@ -62,14 +62,14 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryXlib::Init(void)
NS_IMETHODIMP nsDeviceContextSpecFactoryXlib::CreateDeviceContextSpec(nsIWidget *aWidget,
nsIPrintSettings* aPrintSettings,
nsIDeviceContextSpec *&aNewSpec,
PRBool aIsPrintPreview)
PRBool aQuiet)
{
nsresult rv;
static NS_DEFINE_CID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
nsCOMPtr<nsIDeviceContextSpec> devSpec = do_CreateInstance(kDeviceContextSpecCID, &rv);
if (NS_SUCCEEDED(rv))
{
rv = ((nsDeviceContextSpecXlib *)devSpec.get())->Init(aPrintSettings);
rv = ((nsDeviceContextSpecXlib *)devSpec.get())->Init(aPrintSettings, aQuiet);
if (NS_SUCCEEDED(rv))
{
aNewSpec = devSpec;

Просмотреть файл

@ -54,7 +54,7 @@ public:
NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget,
nsIPrintSettings* aPrintSettings,
nsIDeviceContextSpec *&aNewSpec,
PRBool aIsPrintPreview);
PRBool aQuiet);
protected:
virtual ~nsDeviceContextSpecFactoryXlib();

Просмотреть файл

@ -51,9 +51,16 @@
#include "nsIPref.h"
#include "prenv.h" /* for PR_GetEnv */
#include "nsPrintfCString.h"
#include "nsIDOMWindowInternal.h"
#include "nsIServiceManager.h"
#include "nsIDialogParamBlock.h"
#include "nsISupportsPrimitives.h"
#include "nsIWindowWatcher.h"
#include "nsReadableUtils.h"
#include "nsIServiceManager.h"
#include "nsISupportsArray.h"
#include "nsPrintfCString.h"
#ifdef USE_XPRINT
#include "xprintutil.h"
@ -247,6 +254,66 @@ 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<nsISupportsArray> array;
NS_NewISupportsArray(getter_AddRefs(array));
if (!array) return NS_ERROR_FAILURE;
nsCOMPtr<nsIPrintSettings> ps = aPS;
nsCOMPtr<nsISupports> psSupports(do_QueryInterface(ps));
NS_ASSERTION(psSupports, "PrintSettings must be a supports");
array->AppendElement(psSupports);
nsCOMPtr<nsIDialogParamBlock> ioParamBlock(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1"));
if (ioParamBlock) {
ioParamBlock->SetInt(0, 0);
nsCOMPtr<nsISupports> blkSupps(do_QueryInterface(ioParamBlock));
NS_ASSERTION(blkSupps, "IOBlk must be a supports");
array->AppendElement(blkSupps);
nsCOMPtr<nsISupports> arguments(do_QueryInterface(array));
NS_ASSERTION(array, "array must be a supports");
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
if (wwatch) {
nsCOMPtr<nsIDOMWindow> active;
wwatch->GetActiveWindow(getter_AddRefs(active));
nsCOMPtr<nsIDOMWindowInternal> parent = do_QueryInterface(active);
nsCOMPtr<nsIDOMWindow> 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
@ -256,19 +323,19 @@ NS_IMPL_ISUPPORTS1(nsDeviceContextSpecXlib,
* toolkits including:
* - GTK+-toolkit:
* file: mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp
* function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init()
* function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init(PRBool aQuiet)
* - Xlib-toolkit:
* file: mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp
* function: NS_IMETHODIMP nsDeviceContextSpecXlib::Init()
* function: NS_IMETHODIMP nsDeviceContextSpecXlib::Init(PRBool aQuiet)
* - Qt-toolkit:
* file: mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp
* function: NS_IMETHODIMP nsDeviceContextSpecQT::Init()
* function: NS_IMETHODIMP nsDeviceContextSpecQT::Init(PRBool aQuiet)
*
* ** Please update the other toolkits when changing this function.
*/
NS_IMETHODIMP nsDeviceContextSpecXlib::Init(nsIPrintSettings *aPS)
NS_IMETHODIMP nsDeviceContextSpecXlib::Init(nsIPrintSettings *aPS, PRBool aQuiet)
{
DO_PR_DEBUG_LOG(("nsDeviceContextSpecXlib::Init(aPS=%p\n", aPS));
DO_PR_DEBUG_LOG(("nsDeviceContextSpecXlib::Init(aPS=%p. qQuiet=%d)\n", aPS, (int)aQuiet));
nsresult rv = NS_ERROR_FAILURE;
mPrintSettings = aPS;
@ -283,76 +350,88 @@ NS_IMETHODIMP nsDeviceContextSpecXlib::Init(nsIPrintSettings *aPS)
}
}
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 (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 (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;
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():"<NULL>"));
DO_PR_DEBUG_LOG(("command '%s'\n", command? NS_ConvertUCS2toUTF8(command).get():"<NULL>"));
DO_PR_DEBUG_LOG(("printer '%s'\n", printer? NS_ConvertUCS2toUTF8(printer).get():"<NULL>"));
DO_PR_DEBUG_LOG(("papername '%s'\n", papername? NS_ConvertUCS2toUTF8(papername).get():"<NULL>"));
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():"<NULL>"));
DO_PR_DEBUG_LOG(("command '%s'\n", command? NS_ConvertUCS2toUTF8(command).get():"<NULL>"));
DO_PR_DEBUG_LOG(("printer '%s'\n", printer? NS_ConvertUCS2toUTF8(printer).get():"<NULL>"));
DO_PR_DEBUG_LOG(("papername '%s'\n", papername? NS_ConvertUCS2toUTF8(papername).get():"<NULL>"));
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;
@ -914,7 +993,19 @@ NS_IMETHODIMP nsPrinterEnumeratorXlib::InitPrintSettingsFromPrinter(const PRUnic
NS_IMETHODIMP nsPrinterEnumeratorXlib::DisplayPropertiesDlg(const PRUnichar *aPrinter, nsIPrintSettings *aPrintSettings)
{
return NS_OK;
/* 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);
}
//----------------------------------------------------------------------

Просмотреть файл

@ -74,7 +74,7 @@ public:
NS_DECL_ISUPPORTS
NS_IMETHOD Init(nsIPrintSettings* aPS);
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet);
NS_IMETHOD ClosePrintManager();
NS_IMETHOD GetToPrinter(PRBool &aToPrinter);

Просмотреть файл

@ -460,7 +460,7 @@ NS_IMETHODIMP nsDeviceContextXlib::GetDeviceContextFor(nsIDeviceContextSpec *aDe
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP nsDeviceContextXlib::BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage)
NS_IMETHODIMP nsDeviceContextXlib::BeginDocument(PRUnichar * aTitle)
{
PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::BeginDocument()\n"));
return NS_OK;

Просмотреть файл

@ -73,7 +73,7 @@ public:
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
nsIDeviceContext *&aContext);
NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage);
NS_IMETHOD BeginDocument(PRUnichar * aTitle);
NS_IMETHOD EndDocument(void);
NS_IMETHOD AbortDocument(void);

Просмотреть файл

@ -303,7 +303,7 @@ NS_IMETHODIMP nsDeviceContextXp::GetDeviceContextFor(nsIDeviceContextSpec *aDevi
/** ---------------------------------------------------
* See documentation in nsIDeviceContext.h
*/
NS_IMETHODIMP nsDeviceContextXp::BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage)
NS_IMETHODIMP nsDeviceContextXp::BeginDocument(PRUnichar * aTitle)
{
PR_LOG(nsDeviceContextXpLM, PR_LOG_DEBUG, ("nsDeviceContextXp::BeginDocument()\n"));
nsresult rv = NS_OK;

Просмотреть файл

@ -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, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage);
NS_IMETHOD BeginDocument(PRUnichar * aTitle);
NS_IMETHOD EndDocument(void);
NS_IMETHOD AbortDocument(void);
NS_IMETHOD BeginPage(void);

Просмотреть файл

@ -685,7 +685,7 @@ nsXPrintContext::SetResolution( void )
}
NS_IMETHODIMP
nsXPrintContext::BeginDocument( PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage )
nsXPrintContext::BeginDocument( PRUnichar *aTitle )
{
PR_LOG(nsXPrintContextLM, PR_LOG_DEBUG, ("nsXPrintContext::BeginDocument(aTitle='%s')\n", ((aTitle)?(NS_ConvertUCS2toUTF8(aTitle).get()):("<NULL>"))));

Просмотреть файл

@ -73,7 +73,7 @@ public:
NS_IMETHOD Init(nsDeviceContextXp *dc, nsIDeviceContextSpecXp *aSpec);
NS_IMETHOD BeginPage();
NS_IMETHOD EndPage();
NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage);
NS_IMETHOD BeginDocument(PRUnichar *aTitle);
NS_IMETHOD EndDocument();
NS_IMETHOD AbortDocument();

Просмотреть файл

@ -161,10 +161,6 @@ 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
@ -219,12 +215,12 @@ static const char * gPrintRangeStr[] = {"kRangeAllPages", "kRangeSpecified
static PRUint32 gDumpFileNameCnt = 0;
static PRUint32 gDumpLOFileNameCnt = 0;
#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);
#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);
#else //--------------
#define PRT_YESNO(_p)
#define PRINT_DEBUG_MSG1(_msg)
@ -402,9 +398,7 @@ private:
class PrintData {
public:
typedef enum ePrintDataType {eIsPrinting, eIsPrintPreview };
PrintData(ePrintDataType aType);
PrintData();
~PrintData(); // non-virtual
// Listener Helper Methods
@ -416,7 +410,6 @@ public:
PRBool aDoStartStop = PR_FALSE,
PRInt32 aFlag = 0);
ePrintDataType mType; // the type of data this is (Printing or Print Preview)
nsCOMPtr<nsIDeviceContext> mPrintDC;
nsIView *mPrintView;
FILE *mDebugFilePtr; // a file where information can go to when printing
@ -473,7 +466,6 @@ public:
#endif
private:
PrintData() {}
PrintData& operator=(const PrintData& aOther); // not implemented
};
@ -719,6 +711,7 @@ protected:
nsIPageSequenceFrame* mPageSeqFrame;
PRBool mIsPrinting;
PrintData* mPrt;
nsPagePrintTimer* mPagePrintTimer;
@ -885,8 +878,8 @@ static nsresult NS_NewUpdateTimer(nsPagePrintTimer **aResult)
//---------------------------------------------------
//-- PrintData Class Impl
//---------------------------------------------------
PrintData::PrintData(ePrintDataType aType) :
mType(aType), mPrintView(nsnull), mDebugFilePtr(nsnull), mPrintObject(nsnull), mSelectedPO(nsnull),
PrintData::PrintData() :
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),
@ -947,15 +940,13 @@ PrintData::~PrintData()
mPrintSettings->GetIsCancelled(&isCancelled);
nsresult rv = NS_OK;
if (mType == eIsPrinting) {
if (!isCancelled && !mIsAborted) {
rv = mPrintDC->EndDocument();
} else {
rv = mPrintDC->AbortDocument();
}
if (NS_FAILED(rv)) {
DocumentViewerImpl::ShowPrintErrorDialog(rv);
}
if (!isCancelled && !mIsAborted) {
rv = mPrintDC->EndDocument();
} else {
rv = mPrintDC->AbortDocument();
}
if (NS_FAILED(rv)) {
DocumentViewerImpl::ShowPrintErrorDialog(rv);
}
}
@ -1112,6 +1103,7 @@ void DocumentViewerImpl::PrepareToStartLoad()
mStopped = PR_FALSE;
mLoaded = PR_FALSE;
mPrt = nsnull;
mIsPrinting = PR_FALSE;
#ifdef NS_PRINT_PREVIEW
mIsDoingPrintPreview = PR_FALSE;
@ -4320,7 +4312,7 @@ DocumentViewerImpl::FindXMostFrameInList(nsIPresContext* aPresContext,
xMost = 0;
}
#ifdef DEBUG_PRINTING_X // keep this here but leave it turned off
#ifdef DEBUG_PRINTING // keep this here but leave it turned off
nsAutoString tmp;
nsIFrameDebug* frameDebug;
if (NS_SUCCEEDED(CallQueryInterface(child, &frameDebug))) {
@ -4331,7 +4323,7 @@ DocumentViewerImpl::FindXMostFrameInList(nsIPresContext* aPresContext,
if (xMost > aMaxWidth) {
aMaxWidth = xMost;
#ifdef DEBUG_PRINTING_X // keep this here but leave it turned off
#ifdef DEBUG_PRINTING // 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");
@ -4461,7 +4453,7 @@ DocumentViewerImpl::SetupToPrintContent(nsIWebShell* aParent,
}
// Only Shrink if we are smaller
if (mPrt->mShrinkRatio < 0.998f) {
if (mPrt->mShrinkRatio < 1.0f) {
// Clamp Shrink to Fit to 50%
mPrt->mShrinkRatio = PR_MAX(mPrt->mShrinkRatio, 0.5f);
@ -4479,30 +4471,6 @@ 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------------------------------------------");
@ -4542,54 +4510,12 @@ 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
}
@ -4762,11 +4688,23 @@ DocumentViewerImpl::DoPrint(PrintObject * aPO, PRBool aDoSyncPrinting, PRBool& a
#endif
if (mPrt->mPrintSettings) {
PRUnichar * docTitleStr = nsnull;
PRUnichar * docURLStr = nsnull;
if (!skipSetTitle) {
GetDisplayTitleAndURL(aPO, mPrt->mPrintSettings, mPrt->mBrandName, &docTitleStr, &docURLStr, eDocTitleDefBlank);
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);
}
}
if (nsIPrintSettings::kRangeSelection == printRangeType) {
@ -4856,7 +4794,7 @@ DocumentViewerImpl::DoPrint(PrintObject * aPO, PRBool aDoSyncPrinting, PRBool& a
rootFrame->SetRect(poPresContext, r);
mPageSeqFrame = pageSequence;
mPageSeqFrame->StartPrint(poPresContext, mPrt->mPrintSettings, docTitleStr, docURLStr);
mPageSeqFrame->StartPrint(poPresContext, mPrt->mPrintSettings);
if (!aDoSyncPrinting) {
// Get the delay time in between the printing of each page
@ -5555,26 +5493,25 @@ DocumentViewerImpl::IsThereAnIFrameSelected(nsIWebShell* aWebShell,
{
aIsParentFrameSet = IsParentAFrameSet(aWebShell);
PRBool iFrameIsSelected = PR_FALSE;
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<nsIDOMWindowInternal> domWin = getter_AddRefs(GetDOMWinForWebShell(aWebShell));
if (aDOMWin != nsnull && domWin != aDOMWin) {
iFrameIsSelected = PR_TRUE; // we have a selected IFRAME
}
#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<nsIDOMWindowInternal> domWin = getter_AddRefs(GetDOMWinForWebShell(aWebShell));
if (aDOMWin != nsnull && domWin != aDOMWin) {
iFrameIsSelected = PR_TRUE; // we have a selected IFRAME
}
}
}
#endif
return iFrameIsSelected;
}
@ -6389,7 +6326,7 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings)
mPrtPreview = nsnull;
}
mPrt = new PrintData(PrintData::eIsPrintPreview);
mPrt = new PrintData();
if (!mPrt) {
mIsCreatingPrintPreview = PR_FALSE;
return NS_ERROR_OUT_OF_MEMORY;
@ -6531,6 +6468,8 @@ 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);
@ -6539,7 +6478,7 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings)
if (factory) {
nsCOMPtr<nsIDeviceContextSpec> devspec;
nsCOMPtr<nsIDeviceContext> dx;
nsresult rv = factory->CreateDeviceContextSpec(mWindow, aPrintSettings, *getter_AddRefs(devspec), PR_TRUE);
nsresult rv = factory->CreateDeviceContextSpec(mWindow, aPrintSettings, *getter_AddRefs(devspec), doSilent);
if (NS_SUCCEEDED(rv)) {
rv = mDeviceContext->GetDeviceContextFor(devspec, *getter_AddRefs(ppDC));
if (NS_SUCCEEDED(rv)) {
@ -6557,7 +6496,9 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings)
}
}
mPrt->mPrintSettings->SetPrintFrameType(nsIPrintSettings::kFramesAsIs);
if (doSilent) {
mPrt->mPrintSettings->SetPrintFrameType(nsIPrintSettings::kFramesAsIs);
}
// override any UI that wants to PrintPreview any selection
PRInt16 printRangeType = nsIPrintSettings::kRangeAllPages;
@ -6662,20 +6603,28 @@ DocumentViewerImpl::SetDocAndURLIntoProgress(PrintObject* aPO,
docURLStr = ToNewUnicode(newURLStr);
}
aParams->SetDocTitle((const PRUnichar*) docTitleStr);
aParams->SetDocURL((const PRUnichar*) docURLStr);
mPrt->mPrintProgressParams->SetDocTitle((const PRUnichar*) docTitleStr);
mPrt->mPrintProgressParams->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)
{
// Assume we can't do progress and then see if we can
mPrt->mShowProgressDialog = PR_FALSE;
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);
nsCOMPtr<nsIPref> prefs (do_GetService(NS_PREF_CONTRACTID));
if (prefs) {
@ -6689,27 +6638,20 @@ DocumentViewerImpl::DoPrintProgress(PRBool aIsForPrinting)
mPrt->mPrintSettings->GetShowPrintProgress(&mPrt->mShowProgressDialog);
}
// Now open the service to get the progress dialog
nsCOMPtr<nsIPrintingPromptService> printPromptService(do_GetService(kPrintingPromptService));
if (printPromptService) {
nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject;
mDocument->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject));
if (!scriptGlobalObject) return;
nsCOMPtr<nsIDOMWindow> domWin = do_QueryInterface(scriptGlobalObject);
if (!domWin) return;
if (mPrt->mShowProgressDialog) {
nsPrintProgressParams* prtProgressParams = new nsPrintProgressParams();
nsCOMPtr<nsIPrintProgressParams> params;
rv = prtProgressParams->QueryInterface(NS_GET_IID(nsIPrintProgressParams), (void**)getter_AddRefs(mPrt->mPrintProgressParams));
if (NS_SUCCEEDED(rv) && mPrt->mPrintProgressParams) {
SetDocAndURLIntoProgress(mPrt->mPrintObject, mPrt->mPrintProgressParams);
// If we don't get a service, that's ok, then just don't show progress
PRBool notifyOnOpen;
nsresult rv = printPromptService->ShowProgress(domWin, this, mPrt->mPrintSettings, nsnull, getter_AddRefs(mPrt->mPrintProgressListener), getter_AddRefs(mPrt->mPrintProgressParams), &notifyOnOpen);
if (NS_SUCCEEDED(rv)) {
mPrt->mShowProgressDialog = mPrt->mPrintProgressListener != nsnull && mPrt->mPrintProgressParams != nsnull;
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
if (wwatch) {
nsCOMPtr<nsIDOMWindow> active;
wwatch->GetActiveWindow(getter_AddRefs(active));
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);
nsCOMPtr<nsIDOMWindowInternal> parent(do_QueryInterface(active));
mPrt->mPrintProgress->OpenProgressDialog(parent, "chrome://global/content/printProgress.xul", mPrt->mPrintProgressParams);
}
}
}
@ -6807,9 +6749,9 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings,
ShowPrintErrorDialog(rv);
return rv;
}
mPrt = new PrintData(PrintData::eIsPrinting);
if (!mPrt) {
mPrt = new PrintData();
if (mPrt == nsnull) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -6946,65 +6888,14 @@ 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);
}
// 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);
// 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<nsIPrintingPromptService> printPromptService(do_GetService(kPrintingPromptService));
if (printPromptService) {
nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject;
mDocument->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject));
if (!scriptGlobalObject) return nsnull;
nsCOMPtr<nsIDOMWindow> 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;
}
// we have to turn off printpreview mode for now.. because this is a real request to print.
if ( mIsDoingPrintPreview == PR_TRUE) {
aPrintSettings->SetIsPrintPreview(PR_FALSE);
}
// Create DeviceSpec for Printing
rv = factory->CreateDeviceContextSpec(mWindow, mPrt->mPrintSettings, *getter_AddRefs(devspec), PR_FALSE);
rv = factory->CreateDeviceContextSpec(mWindow, mPrt->mPrintSettings, *getter_AddRefs(devspec), printSilently);
// 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.
@ -7128,42 +7019,70 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings,
}
}
// 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
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
// and it uses the PrintService to get it, so we need to set it into the PrintService here
mPrt->mPrintSettings->GetToFileName(&fileName);
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);
}
}
PRUnichar * docTitleStr;
PRUnichar * docURLStr;
GetDisplayTitleAndURL(mPrt->mPrintObject, mPrt->mPrintSettings,
mPrt->mBrandName, &docTitleStr, &docURLStr,
eDocTitleDefURLDoc);
GetDisplayTitleAndURL(mPrt->mPrintObject, mPrt->mPrintSettings, mPrt->mBrandName, &docTitleStr, &docURLStr, eDocTitleDefURLDoc);
rv = mPrt->mPrintDC->PrepareDocument(docTitleStr, fileName);
// 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");
if (docTitleStr) nsMemory::Free(docTitleStr);
if (docURLStr) nsMemory::Free(docURLStr);
NS_ENSURE_SUCCESS(rv, rv);
DoPrintProgress(PR_TRUE);
if (NS_SUCCEEDED(rv)) {
// Print listener setup...
if (mPrt != nsnull) {
mPrt->OnStartPrinting();
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");
}
}
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
@ -7255,8 +7174,6 @@ 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:
@ -8381,10 +8298,12 @@ DocumentViewerImpl::GetCurrentPrintSettings(nsIPrintSettings * *aCurrentPrintSet
NS_IMETHODIMP
DocumentViewerImpl::Cancel()
{
if (mPrt && mPrt->mPrintSettings) {
return mPrt->mPrintSettings->SetIsCancelled(PR_TRUE);
nsresult rv;
nsCOMPtr<nsIPrintOptions> printService = do_GetService(kPrintOptionsCID, &rv);
if (NS_SUCCEEDED(rv) && printService) {
return printService->SetIsCancelled(PR_TRUE);
}
return NS_ERROR_FAILURE;
return NS_OK;
}
/* void initPrintSettingsFromPrefs (in nsIPrintSettings aPrintSettings, in boolean aUsePrinterNamePrefix, in unsigned long aFlags); */

Просмотреть файл

@ -42,7 +42,6 @@
#include "nsIWebProgressListener.idl"
interface nsIDOMWindowInternal;
interface nsIObserver;
[scriptable, uuid(7E46BC35-FB7D-4b45-AB35-82FD61015380)]
interface nsIPrintProgress: nsIWebProgressListener {
@ -50,11 +49,7 @@ interface nsIPrintProgress: nsIWebProgressListener {
/* Open the progress dialog
you can specify parameters through an xpcom object
*/
void openProgressDialog(in nsIDOMWindowInternal parent,
in string dialogURL,
in nsISupports parameters,
in nsIObserver openDialogObserver,
out boolean notifyOnOpen);
void openProgressDialog(in nsIDOMWindowInternal parent, in string dialogURL, in nsISupports parameters);
/* Close the progress dialog */
void closeProgressDialog(in boolean forceClose);

Просмотреть файл

@ -62,7 +62,7 @@ public:
// nsIDOMContextMenuListener
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
NS_IMETHOD ContextMenu (nsIDOMEvent* aEvent) { aEvent->PreventDefault(); return NS_OK; }
NS_IMETHOD ContextMenu (nsIDOMEvent* aEvent) { printf("preventing ContextMenu\n"); aEvent->PreventDefault(); return NS_OK; }
// nsIDOMKeyListener
NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent);