зеркало из https://github.com/mozilla/gecko-dev.git
Turn on pluggable dialogs (second part of checkin, first part Bug 135441)
Bug 115136 r=dcone sr=attinasi
This commit is contained in:
Родитель
8a0f87e149
Коммит
15a673155f
|
@ -70,8 +70,6 @@ CPPSRCS = \
|
|||
nsDocumentEncoder.cpp \
|
||||
nsDocumentFragment.cpp \
|
||||
nsDocumentViewer.cpp \
|
||||
nsPrintProgress.cpp \
|
||||
nsPrintProgressParams.cpp \
|
||||
nsDOMAttribute.cpp \
|
||||
nsDOMAttributeMap.cpp \
|
||||
nsDOMDocumentType.cpp \
|
||||
|
|
|
@ -63,8 +63,6 @@ REQUIRES = xpcom \
|
|||
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsPrintPreviewListener.obj \
|
||||
.\$(OBJDIR)\nsPrintProgress.obj \
|
||||
.\$(OBJDIR)\nsPrintProgressParams.obj \
|
||||
.\$(OBJDIR)\nsStyleContext.obj \
|
||||
.\$(OBJDIR)\nsStyleSet.obj \
|
||||
.\$(OBJDIR)\nsCommentNode.obj \
|
||||
|
|
|
@ -161,6 +161,10 @@ static NS_DEFINE_IID(kPrinterEnumeratorCID, NS_PRINTER_ENUMERATOR_CID);
|
|||
#include "nsIWindowWatcher.h"
|
||||
#include "nsIStringBundle.h"
|
||||
|
||||
// Printing Prompts
|
||||
#include "nsIPrintingPromptService.h"
|
||||
const char* kPrintingPromptService = "@mozilla.org/embedcomp/printingprompt-service;1";
|
||||
|
||||
#define NS_ERROR_GFX_PRINTER_BUNDLE_URL "chrome://global/locale/printing.properties"
|
||||
|
||||
// FrameSet
|
||||
|
@ -215,12 +219,12 @@ static const char * gPrintRangeStr[] = {"kRangeAllPages", "kRangeSpecified
|
|||
static PRUint32 gDumpFileNameCnt = 0;
|
||||
static PRUint32 gDumpLOFileNameCnt = 0;
|
||||
|
||||
#define PRINT_DEBUG_MSG1(_msg1) fprintf(mPrt->mDebugFD, (_msg1));
|
||||
#define PRINT_DEBUG_MSG2(_msg1, _msg2) fprintf(mPrt->mDebugFD, (_msg1), (_msg2));
|
||||
#define PRINT_DEBUG_MSG3(_msg1, _msg2, _msg3) fprintf(mPrt->mDebugFD, (_msg1), (_msg2), (_msg3));
|
||||
#define PRINT_DEBUG_MSG4(_msg1, _msg2, _msg3, _msg4) fprintf(mPrt->mDebugFD, (_msg1), (_msg2), (_msg3), (_msg4));
|
||||
#define PRINT_DEBUG_MSG5(_msg1, _msg2, _msg3, _msg4, _msg5) fprintf(mPrt->mDebugFD, (_msg1), (_msg2), (_msg3), (_msg4), (_msg5));
|
||||
#define PRINT_DEBUG_FLUSH fflush(mPrt->mDebugFD);
|
||||
#define PRINT_DEBUG_MSG1(_msg1) if (mPrt && mPrt->mDebugFD) fprintf(mPrt->mDebugFD, (_msg1));
|
||||
#define PRINT_DEBUG_MSG2(_msg1, _msg2) if (mPrt && mPrt->mDebugFD) fprintf(mPrt->mDebugFD, (_msg1), (_msg2));
|
||||
#define PRINT_DEBUG_MSG3(_msg1, _msg2, _msg3) if (mPrt && mPrt->mDebugFD) fprintf(mPrt->mDebugFD, (_msg1), (_msg2), (_msg3));
|
||||
#define PRINT_DEBUG_MSG4(_msg1, _msg2, _msg3, _msg4) if (mPrt && mPrt->mDebugFD) fprintf(mPrt->mDebugFD, (_msg1), (_msg2), (_msg3), (_msg4));
|
||||
#define PRINT_DEBUG_MSG5(_msg1, _msg2, _msg3, _msg4, _msg5) if (mPrt && mPrt->mDebugFD) fprintf(mPrt->mDebugFD, (_msg1), (_msg2), (_msg3), (_msg4), (_msg5));
|
||||
#define PRINT_DEBUG_FLUSH if (mPrt && mPrt->mDebugFD) fflush(mPrt->mDebugFD);
|
||||
#else //--------------
|
||||
#define PRT_YESNO(_p)
|
||||
#define PRINT_DEBUG_MSG1(_msg)
|
||||
|
@ -398,7 +402,9 @@ private:
|
|||
class PrintData {
|
||||
public:
|
||||
|
||||
PrintData();
|
||||
typedef enum ePrintDataType {eIsPrinting, eIsPrintPreview };
|
||||
|
||||
PrintData(ePrintDataType aType);
|
||||
~PrintData(); // non-virtual
|
||||
|
||||
// Listener Helper Methods
|
||||
|
@ -410,6 +416,7 @@ public:
|
|||
PRBool aDoStartStop = PR_FALSE,
|
||||
PRInt32 aFlag = 0);
|
||||
|
||||
ePrintDataType mType; // the type of data this is (Printing or Print Preview)
|
||||
nsCOMPtr<nsIDeviceContext> mPrintDC;
|
||||
nsIView *mPrintView;
|
||||
FILE *mDebugFilePtr; // a file where information can go to when printing
|
||||
|
@ -466,6 +473,7 @@ public:
|
|||
#endif
|
||||
|
||||
private:
|
||||
PrintData() {}
|
||||
PrintData& operator=(const PrintData& aOther); // not implemented
|
||||
|
||||
};
|
||||
|
@ -711,7 +719,6 @@ protected:
|
|||
nsIPageSequenceFrame* mPageSeqFrame;
|
||||
|
||||
|
||||
PRBool mIsPrinting;
|
||||
PrintData* mPrt;
|
||||
nsPagePrintTimer* mPagePrintTimer;
|
||||
|
||||
|
@ -878,8 +885,8 @@ static nsresult NS_NewUpdateTimer(nsPagePrintTimer **aResult)
|
|||
//---------------------------------------------------
|
||||
//-- PrintData Class Impl
|
||||
//---------------------------------------------------
|
||||
PrintData::PrintData() :
|
||||
mPrintView(nsnull), mDebugFilePtr(nsnull), mPrintObject(nsnull), mSelectedPO(nsnull),
|
||||
PrintData::PrintData(ePrintDataType aType) :
|
||||
mType(aType), mPrintView(nsnull), mDebugFilePtr(nsnull), mPrintObject(nsnull), mSelectedPO(nsnull),
|
||||
mShowProgressDialog(PR_TRUE), mPrintDocList(nsnull), mIsIFrameSelected(PR_FALSE),
|
||||
mIsParentAFrameSet(PR_FALSE), mPrintingAsIsSubDoc(PR_FALSE), mOnStartSent(PR_FALSE),
|
||||
mIsAborted(PR_FALSE), mPreparingForPrint(PR_FALSE), mDocWasToBeDestroyed(PR_FALSE),
|
||||
|
@ -940,13 +947,15 @@ PrintData::~PrintData()
|
|||
mPrintSettings->GetIsCancelled(&isCancelled);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
if (!isCancelled && !mIsAborted) {
|
||||
rv = mPrintDC->EndDocument();
|
||||
} else {
|
||||
rv = mPrintDC->AbortDocument();
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
DocumentViewerImpl::ShowPrintErrorDialog(rv);
|
||||
if (mType == eIsPrinting) {
|
||||
if (!isCancelled && !mIsAborted) {
|
||||
rv = mPrintDC->EndDocument();
|
||||
} else {
|
||||
rv = mPrintDC->AbortDocument();
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
DocumentViewerImpl::ShowPrintErrorDialog(rv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1103,7 +1112,6 @@ void DocumentViewerImpl::PrepareToStartLoad()
|
|||
mStopped = PR_FALSE;
|
||||
mLoaded = PR_FALSE;
|
||||
mPrt = nsnull;
|
||||
mIsPrinting = PR_FALSE;
|
||||
|
||||
#ifdef NS_PRINT_PREVIEW
|
||||
mIsDoingPrintPreview = PR_FALSE;
|
||||
|
@ -4312,7 +4320,7 @@ DocumentViewerImpl::FindXMostFrameInList(nsIPresContext* aPresContext,
|
|||
xMost = 0;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_PRINTING // keep this here but leave it turned off
|
||||
#ifdef DEBUG_PRINTING_X // keep this here but leave it turned off
|
||||
nsAutoString tmp;
|
||||
nsIFrameDebug* frameDebug;
|
||||
if (NS_SUCCEEDED(CallQueryInterface(child, &frameDebug))) {
|
||||
|
@ -4323,7 +4331,7 @@ DocumentViewerImpl::FindXMostFrameInList(nsIPresContext* aPresContext,
|
|||
|
||||
if (xMost > aMaxWidth) {
|
||||
aMaxWidth = xMost;
|
||||
#ifdef DEBUG_PRINTING // keep this here but leave it turned off
|
||||
#ifdef DEBUG_PRINTING_X // keep this here but leave it turned off
|
||||
printf("%p - %d %s ", child, aMaxWidth, NS_LossyConvertUCS2toASCII(tmp).get());
|
||||
if (aList == nsLayoutAtoms::overflowList) printf(" nsLayoutAtoms::overflowList\n");
|
||||
if (aList == nsLayoutAtoms::floaterList) printf(" nsLayoutAtoms::floaterList\n");
|
||||
|
@ -4453,7 +4461,7 @@ DocumentViewerImpl::SetupToPrintContent(nsIWebShell* aParent,
|
|||
}
|
||||
|
||||
// Only Shrink if we are smaller
|
||||
if (mPrt->mShrinkRatio < 1.0f) {
|
||||
if (mPrt->mShrinkRatio < 0.998f) {
|
||||
// Clamp Shrink to Fit to 50%
|
||||
mPrt->mShrinkRatio = PR_MAX(mPrt->mShrinkRatio, 0.5f);
|
||||
|
||||
|
@ -4471,6 +4479,30 @@ DocumentViewerImpl::SetupToPrintContent(nsIWebShell* aParent,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG_rods
|
||||
{
|
||||
float calcRatio;
|
||||
if (mPrt->mPrintDocList->Count() > 1 && mPrt->mPrintObject->mFrameType == eFrameSet) {
|
||||
PrintObject* xMostPO = FindXMostPO();
|
||||
NS_ASSERTION(xMostPO, "There must always be an XMost PO!");
|
||||
if (xMostPO) {
|
||||
// The margin is included in the PO's mRect so we need to subtract it
|
||||
nsMargin margin(0,0,0,0);
|
||||
mPrt->mPrintSettings->GetMarginInTwips(margin);
|
||||
nsRect rect = xMostPO->mRect;
|
||||
rect.x -= margin.left;
|
||||
// Calc the shrinkage based on the entire content area
|
||||
calcRatio = float(rect.XMost()) / float(rect.x + xMostPO->mXMost);
|
||||
}
|
||||
} else {
|
||||
// Single document so use the Shrink as calculated for the PO
|
||||
calcRatio = mPrt->mPrintObject->mShrinkRatio;
|
||||
}
|
||||
printf("**************************************************************************\n");
|
||||
printf("STF Ratio is: %8.5f Effective Ratio: %8.5f Diff: %8.5f\n", mPrt->mShrinkRatio, calcRatio, mPrt->mShrinkRatio-calcRatio);
|
||||
printf("**************************************************************************\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
DUMP_DOC_LIST("\nAfter Reflow------------------------------------------");
|
||||
|
@ -4510,12 +4542,54 @@ DocumentViewerImpl::SetupToPrintContent(nsIWebShell* aParent,
|
|||
|
||||
mPrt->mPrintDocDW = aCurrentFocusedDOMWin;
|
||||
|
||||
PRUnichar* fileName = nsnull;
|
||||
// check to see if we are printing to a file
|
||||
PRBool isPrintToFile = PR_FALSE;
|
||||
mPrt->mPrintSettings->GetPrintToFile(&isPrintToFile);
|
||||
if (isPrintToFile) {
|
||||
// On some platforms The BeginDocument needs to know the name of the file
|
||||
// and it uses the PrintService to get it, so we need to set it into the PrintService here
|
||||
mPrt->mPrintSettings->GetToFileName(&fileName);
|
||||
}
|
||||
|
||||
PRUnichar * docTitleStr;
|
||||
PRUnichar * docURLStr;
|
||||
GetDisplayTitleAndURL(mPrt->mPrintObject, mPrt->mPrintSettings, mPrt->mBrandName, &docTitleStr, &docURLStr, eDocTitleDefURLDoc);
|
||||
|
||||
PRInt32 startPage = 1;
|
||||
PRInt32 endPage = mPrt->mNumPrintablePages;
|
||||
|
||||
PRInt16 printRangeType = nsIPrintSettings::kRangeAllPages;
|
||||
mPrt->mPrintSettings->GetPrintRange(&printRangeType);
|
||||
if (printRangeType == nsIPrintSettings::kRangeSpecifiedPageRange) {
|
||||
mPrt->mPrintSettings->GetStartPageRange(&startPage);
|
||||
mPrt->mPrintSettings->GetEndPageRange(&endPage);
|
||||
if (endPage > mPrt->mNumPrintablePages) {
|
||||
endPage = mPrt->mNumPrintablePages;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
// BeginDocument may pass back a FAILURE code
|
||||
// i.e. On Windows, if you are printing to a file and hit "Cancel"
|
||||
// to the "File Name" dialog, this comes back as an error
|
||||
// Don't start printing when regression test are executed
|
||||
if (!mPrt->mDebugFilePtr && mIsDoingPrinting) {
|
||||
rv = mPrt->mPrintDC->BeginDocument(docTitleStr, fileName, startPage, endPage);
|
||||
}
|
||||
|
||||
PRINT_DEBUG_MSG1("****************** Begin Document ************************\n");
|
||||
|
||||
if (docTitleStr) nsMemory::Free(docTitleStr);
|
||||
if (docURLStr) nsMemory::Free(docURLStr);
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// This will print the webshell document
|
||||
// when it completes asynchronously in the DonePrintingPages method
|
||||
// it will check to see if there are more webshells to be printed and
|
||||
// then PrintDocContent will be called again.
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
if (mIsDoingPrinting) {
|
||||
PrintDocContent(mPrt->mPrintObject, rv); // ignore return value
|
||||
}
|
||||
|
@ -4688,23 +4762,11 @@ DocumentViewerImpl::DoPrint(PrintObject * aPO, PRBool aDoSyncPrinting, PRBool& a
|
|||
#endif
|
||||
|
||||
if (mPrt->mPrintSettings) {
|
||||
PRUnichar * docTitleStr = nsnull;
|
||||
PRUnichar * docURLStr = nsnull;
|
||||
|
||||
if (!skipSetTitle) {
|
||||
PRUnichar * docTitleStr;
|
||||
PRUnichar * docURLStr;
|
||||
GetDisplayTitleAndURL(aPO, mPrt->mPrintSettings, mPrt->mBrandName,
|
||||
&docTitleStr, &docURLStr, eDocTitleDefBlank);
|
||||
|
||||
// Set them down into the PrintOptions so
|
||||
// they can used by the DeviceContext
|
||||
if (docTitleStr) {
|
||||
mPrt->mPrintOptions->SetTitle(docTitleStr);
|
||||
nsMemory::Free(docTitleStr);
|
||||
}
|
||||
|
||||
if (docURLStr) {
|
||||
mPrt->mPrintOptions->SetDocURL(docURLStr);
|
||||
nsMemory::Free(docURLStr);
|
||||
}
|
||||
GetDisplayTitleAndURL(aPO, mPrt->mPrintSettings, mPrt->mBrandName, &docTitleStr, &docURLStr, eDocTitleDefBlank);
|
||||
}
|
||||
|
||||
if (nsIPrintSettings::kRangeSelection == printRangeType) {
|
||||
|
@ -4794,7 +4856,7 @@ DocumentViewerImpl::DoPrint(PrintObject * aPO, PRBool aDoSyncPrinting, PRBool& a
|
|||
rootFrame->SetRect(poPresContext, r);
|
||||
|
||||
mPageSeqFrame = pageSequence;
|
||||
mPageSeqFrame->StartPrint(poPresContext, mPrt->mPrintSettings);
|
||||
mPageSeqFrame->StartPrint(poPresContext, mPrt->mPrintSettings, docTitleStr, docURLStr);
|
||||
|
||||
if (!aDoSyncPrinting) {
|
||||
// Get the delay time in between the printing of each page
|
||||
|
@ -5493,25 +5555,26 @@ DocumentViewerImpl::IsThereAnIFrameSelected(nsIWebShell* aWebShell,
|
|||
{
|
||||
aIsParentFrameSet = IsParentAFrameSet(aWebShell);
|
||||
PRBool iFrameIsSelected = PR_FALSE;
|
||||
#if 1
|
||||
PrintObject* po = FindPrintObjectByDOMWin(mPrt->mPrintObject, aDOMWin);
|
||||
iFrameIsSelected = po && po->mFrameType == eIFrame;
|
||||
#else
|
||||
// First, check to see if we are a frameset
|
||||
if (!aIsParentFrameSet) {
|
||||
// Check to see if there is a currenlt focused frame
|
||||
// if so, it means the selected frame is either the main webshell
|
||||
// or an IFRAME
|
||||
if (aDOMWin != nsnull) {
|
||||
// Get the main webshell's DOMWin to see if it matches
|
||||
// the frame that is selected
|
||||
nsCOMPtr<nsIDOMWindowInternal> domWin = getter_AddRefs(GetDOMWinForWebShell(aWebShell));
|
||||
if (aDOMWin != nsnull && domWin != aDOMWin) {
|
||||
iFrameIsSelected = PR_TRUE; // we have a selected IFRAME
|
||||
if (mPrt && mPrt->mPrintObject) {
|
||||
PrintObject* po = FindPrintObjectByDOMWin(mPrt->mPrintObject, aDOMWin);
|
||||
iFrameIsSelected = po && po->mFrameType == eIFrame;
|
||||
} else {
|
||||
// First, check to see if we are a frameset
|
||||
if (!aIsParentFrameSet) {
|
||||
// Check to see if there is a currenlt focused frame
|
||||
// if so, it means the selected frame is either the main webshell
|
||||
// or an IFRAME
|
||||
if (aDOMWin != nsnull) {
|
||||
// Get the main webshell's DOMWin to see if it matches
|
||||
// the frame that is selected
|
||||
nsCOMPtr<nsIDOMWindowInternal> domWin = getter_AddRefs(GetDOMWinForWebShell(aWebShell));
|
||||
if (aDOMWin != nsnull && domWin != aDOMWin) {
|
||||
iFrameIsSelected = PR_TRUE; // we have a selected IFRAME
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return iFrameIsSelected;
|
||||
}
|
||||
|
||||
|
@ -6326,7 +6389,7 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings)
|
|||
mPrtPreview = nsnull;
|
||||
}
|
||||
|
||||
mPrt = new PrintData();
|
||||
mPrt = new PrintData(PrintData::eIsPrintPreview);
|
||||
if (!mPrt) {
|
||||
mIsCreatingPrintPreview = PR_FALSE;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -6380,7 +6443,6 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings)
|
|||
// Let's print ...
|
||||
mIsCreatingPrintPreview = PR_TRUE;
|
||||
mIsDoingPrintPreview = PR_TRUE;
|
||||
aPrintSettings->SetIsPrintPreview(mIsDoingPrintPreview);
|
||||
|
||||
// Very important! Turn Off scripting
|
||||
TurnScriptingOn(PR_FALSE);
|
||||
|
@ -6399,7 +6461,6 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings)
|
|||
if (!mPrt->mPrintDocList) {
|
||||
mIsCreatingPrintPreview = PR_FALSE;
|
||||
mIsDoingPrintPreview = PR_FALSE;
|
||||
aPrintSettings->SetIsPrintPreview(mIsDoingPrintPreview);
|
||||
TurnScriptingOn(PR_TRUE);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -6468,8 +6529,6 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings)
|
|||
}
|
||||
#endif
|
||||
|
||||
PRBool doSilent = PR_TRUE;
|
||||
|
||||
nscoord width = NS_INCHES_TO_TWIPS(8.5);
|
||||
nscoord height = NS_INCHES_TO_TWIPS(11.0);
|
||||
|
||||
|
@ -6478,7 +6537,7 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings)
|
|||
if (factory) {
|
||||
nsCOMPtr<nsIDeviceContextSpec> devspec;
|
||||
nsCOMPtr<nsIDeviceContext> dx;
|
||||
nsresult rv = factory->CreateDeviceContextSpec(mWindow, aPrintSettings, *getter_AddRefs(devspec), doSilent);
|
||||
nsresult rv = factory->CreateDeviceContextSpec(mWindow, aPrintSettings, *getter_AddRefs(devspec), PR_TRUE);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = mDeviceContext->GetDeviceContextFor(devspec, *getter_AddRefs(ppDC));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
@ -6496,9 +6555,7 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings)
|
|||
}
|
||||
}
|
||||
|
||||
if (doSilent) {
|
||||
mPrt->mPrintSettings->SetPrintFrameType(nsIPrintSettings::kFramesAsIs);
|
||||
}
|
||||
mPrt->mPrintSettings->SetPrintFrameType(nsIPrintSettings::kFramesAsIs);
|
||||
|
||||
// override any UI that wants to PrintPreview any selection
|
||||
PRInt16 printRangeType = nsIPrintSettings::kRangeAllPages;
|
||||
|
@ -6603,28 +6660,20 @@ DocumentViewerImpl::SetDocAndURLIntoProgress(PrintObject* aPO,
|
|||
docURLStr = ToNewUnicode(newURLStr);
|
||||
}
|
||||
|
||||
mPrt->mPrintProgressParams->SetDocTitle((const PRUnichar*) docTitleStr);
|
||||
mPrt->mPrintProgressParams->SetDocURL((const PRUnichar*) docURLStr);
|
||||
aParams->SetDocTitle((const PRUnichar*) docTitleStr);
|
||||
aParams->SetDocURL((const PRUnichar*) docURLStr);
|
||||
|
||||
if (docTitleStr != nsnull) nsMemory::Free(docTitleStr);
|
||||
if (docURLStr != nsnull) nsMemory::Free(docURLStr);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Set up to use the "pluggable" Print Progress Dialog
|
||||
void
|
||||
DocumentViewerImpl::DoPrintProgress(PRBool aIsForPrinting)
|
||||
{
|
||||
nsPrintProgress* prtProgress = new nsPrintProgress();
|
||||
nsresult rv = prtProgress->QueryInterface(NS_GET_IID(nsIPrintProgress), (void**)getter_AddRefs(mPrt->mPrintProgress));
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
|
||||
rv = prtProgress->QueryInterface(NS_GET_IID(nsIWebProgressListener), (void**)getter_AddRefs(mPrt->mPrintProgressListener));
|
||||
if (NS_FAILED(rv)) return;
|
||||
// add to listener list
|
||||
mPrt->mPrintProgressListeners.AppendElement((void*)mPrt->mPrintProgressListener);
|
||||
nsIWebProgressListener* wpl = NS_STATIC_CAST(nsIWebProgressListener*, mPrt->mPrintProgressListener.get());
|
||||
NS_ASSERTION(wpl, "nsIWebProgressListener is NULL!");
|
||||
NS_ADDREF(wpl);
|
||||
// Assume we can't do progress and then see if we can
|
||||
mPrt->mShowProgressDialog = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIPref> prefs (do_GetService(NS_PREF_CONTRACTID));
|
||||
if (prefs) {
|
||||
|
@ -6638,21 +6687,29 @@ DocumentViewerImpl::DoPrintProgress(PRBool aIsForPrinting)
|
|||
mPrt->mPrintSettings->GetShowPrintProgress(&mPrt->mShowProgressDialog);
|
||||
}
|
||||
|
||||
if (mPrt->mShowProgressDialog) {
|
||||
nsPrintProgressParams* prtProgressParams = new nsPrintProgressParams();
|
||||
nsCOMPtr<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);
|
||||
// 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;
|
||||
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
|
||||
if (wwatch) {
|
||||
nsCOMPtr<nsIDOMWindow> active;
|
||||
wwatch->GetActiveWindow(getter_AddRefs(active));
|
||||
// If we don't get a service, that's ok, then just don't show progress
|
||||
if (mPrt->mShowProgressDialog) {
|
||||
PRBool notifyOnOpen;
|
||||
nsresult rv = printPromptService->ShowProgress(domWin, this, mPrt->mPrintSettings, nsnull, getter_AddRefs(mPrt->mPrintProgressListener), getter_AddRefs(mPrt->mPrintProgressParams), ¬ifyOnOpen);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mPrt->mShowProgressDialog = mPrt->mPrintProgressListener != nsnull && mPrt->mPrintProgressParams != nsnull;
|
||||
|
||||
PRBool notifyOnOpen;
|
||||
nsCOMPtr<nsIDOMWindowInternal> parent(do_QueryInterface(active));
|
||||
mPrt->mPrintProgress->OpenProgressDialog(parent, "chrome://global/content/printProgress.xul", mPrt->mPrintProgressParams, nsnull, ¬ifyOnOpen);
|
||||
if (mPrt->mShowProgressDialog) {
|
||||
mPrt->mPrintProgressListeners.AppendElement((void*)mPrt->mPrintProgressListener);
|
||||
nsIWebProgressListener* wpl = NS_STATIC_CAST(nsIWebProgressListener*, mPrt->mPrintProgressListener.get());
|
||||
NS_ASSERTION(wpl, "nsIWebProgressListener is NULL!");
|
||||
NS_ADDREF(wpl);
|
||||
SetDocAndURLIntoProgress(mPrt->mPrintObject, mPrt->mPrintProgressParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6687,6 +6744,7 @@ DocumentViewerImpl::Print(PRBool aSilent,
|
|||
NS_ASSERTION(printSettings, "You can't PrintPreview without a PrintSettings!");
|
||||
}
|
||||
if (printSettings) printSettings->SetPrintSilent(aSilent);
|
||||
if (printSettings) printSettings->SetShowPrintProgress(PR_FALSE);
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -6750,9 +6808,9 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings,
|
|||
ShowPrintErrorDialog(rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
mPrt = new PrintData();
|
||||
if (mPrt == nsnull) {
|
||||
|
||||
mPrt = new PrintData(PrintData::eIsPrinting);
|
||||
if (!mPrt) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -6889,14 +6947,55 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings,
|
|||
mPrt->mDebugFilePtr = mDebugFile;
|
||||
#endif
|
||||
|
||||
// we have to turn off printpreview mode for now.. because this is a real request to print.
|
||||
if (mIsDoingPrintPreview) {
|
||||
aPrintSettings->SetIsPrintPreview(PR_FALSE);
|
||||
}
|
||||
|
||||
PRBool printSilently;
|
||||
mPrt->mPrintSettings->GetPrintSilent(&printSilently);
|
||||
rv = factory->CreateDeviceContextSpec(mWindow, mPrt->mPrintSettings, *getter_AddRefs(devspec), printSilently);
|
||||
|
||||
// Ask dialog to be Print Shown via the Plugable Printing Dialog Service
|
||||
// This service is for the Print Dialog and the Print Progress Dialog
|
||||
// If printing silently or you can't get the service continue on
|
||||
if (!printSilently) {
|
||||
nsCOMPtr<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;
|
||||
}
|
||||
|
||||
// Create DeviceSpec for Printing
|
||||
rv = factory->CreateDeviceContextSpec(mWindow, mPrt->mPrintSettings, *getter_AddRefs(devspec), PR_FALSE);
|
||||
|
||||
// If the page was intended to be destroyed while we were in the print dialog
|
||||
// then we need to clean up and abort the printing.
|
||||
|
@ -7020,76 +7119,43 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings,
|
|||
}
|
||||
}
|
||||
|
||||
if (mPrt->mPrintOptions) {
|
||||
// check to see if we are printing to a file
|
||||
PRBool isPrintToFile = PR_FALSE;
|
||||
mPrt->mPrintSettings->GetPrintToFile(&isPrintToFile);
|
||||
if (isPrintToFile) {
|
||||
// On some platforms The BeginDocument needs to know the name of the file
|
||||
// Get the Needed info for Calling PrepareDocument
|
||||
PRUnichar* fileName = nsnull;
|
||||
// check to see if we are printing to a file
|
||||
PRBool isPrintToFile = PR_FALSE;
|
||||
mPrt->mPrintSettings->GetPrintToFile(&isPrintToFile);
|
||||
if (isPrintToFile) {
|
||||
// On some platforms The PrepareDocument needs to know the name of the file
|
||||
// and it uses the PrintService to get it, so we need to set it into the PrintService here
|
||||
PRUnichar* fileName;
|
||||
mPrt->mPrintSettings->GetToFileName(&fileName);
|
||||
if (fileName != nsnull) {
|
||||
mPrt->mPrintOptions->SetPrintToFile(PR_TRUE);
|
||||
mPrt->mPrintOptions->SetToFileName(fileName);
|
||||
nsMemory::Free(fileName);
|
||||
}
|
||||
} else {
|
||||
mPrt->mPrintOptions->SetPrintToFile(PR_FALSE);
|
||||
mPrt->mPrintOptions->SetToFileName(nsnull);
|
||||
}
|
||||
mPrt->mPrintSettings->GetToFileName(&fileName);
|
||||
}
|
||||
|
||||
PRUnichar * docTitleStr;
|
||||
PRUnichar * docURLStr;
|
||||
GetDisplayTitleAndURL(mPrt->mPrintObject, mPrt->mPrintSettings,
|
||||
mPrt->mBrandName, &docTitleStr, &docURLStr,
|
||||
eDocTitleDefURLDoc);
|
||||
|
||||
// BeginDocument may pass back a FAILURE code
|
||||
// i.e. On Windows, if you are printing to a file and hit "Cancel"
|
||||
// to the "File Name" dialog, this comes back as an error
|
||||
// Don't start printing when regression test are executed
|
||||
rv = mPrt->mDebugFilePtr ? NS_OK: mPrt->mPrintDC->BeginDocument(docTitleStr);
|
||||
PRINT_DEBUG_MSG1("****************** Begin Document ************************\n");
|
||||
GetDisplayTitleAndURL(mPrt->mPrintObject, mPrt->mPrintSettings, mPrt->mBrandName, &docTitleStr, &docURLStr, eDocTitleDefURLDoc);
|
||||
|
||||
rv = mPrt->mPrintDC->PrepareDocument(docTitleStr, fileName);
|
||||
|
||||
if (docTitleStr) nsMemory::Free(docTitleStr);
|
||||
if (docURLStr) nsMemory::Free(docURLStr);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
DoPrintProgress(PR_TRUE);
|
||||
|
||||
DoPrintProgress(PR_TRUE);
|
||||
|
||||
// Print listener setup...
|
||||
if (mPrt != nsnull) {
|
||||
mPrt->OnStartPrinting();
|
||||
}
|
||||
|
||||
//
|
||||
// The mIsPrinting flag is set when the ImageGroup observer is
|
||||
// notified that images must be loaded as a result of the
|
||||
// InitialReflow...
|
||||
//
|
||||
if(!mIsPrinting || mPrt->mDebugFilePtr) {
|
||||
rv = DocumentReadyForPrinting();
|
||||
PRINT_DEBUG_MSG1("PRINT JOB ENDING, OBSERVER WAS NOT CALLED\n");
|
||||
} else {
|
||||
// use the observer mechanism to finish the printing
|
||||
PRINT_DEBUG_MSG1("PRINTING OBSERVER STARTED\n");
|
||||
}
|
||||
// Print listener setup...
|
||||
if (mPrt != nsnull) {
|
||||
mPrt->OnStartPrinting();
|
||||
}
|
||||
|
||||
rv = DocumentReadyForPrinting();
|
||||
PRINT_DEBUG_MSG1("PRINT JOB ENDING, OBSERVER WAS NOT CALLED\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mPrt->mPrintSettings->SetIsCancelled(PR_TRUE);
|
||||
mPrt->mPrintOptions->SetIsCancelled(PR_TRUE);
|
||||
}
|
||||
|
||||
// Set that we are once again in print preview
|
||||
if (mIsDoingPrintPreview) {
|
||||
aPrintSettings->SetIsPrintPreview(PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/* cleaup on failure + notify user */
|
||||
|
@ -7175,6 +7241,8 @@ DocumentViewerImpl::ShowPrintErrorDialog(nsresult aPrintError, PRBool aIsPrintin
|
|||
NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTER_XPRINT_BROKEN_XPRT)
|
||||
NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTER_DOC_IS_BUSY_PP)
|
||||
NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTER_DOC_WAS_DESTORYED)
|
||||
NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_NO_PRINTDIALOG_IN_TOOLKIT)
|
||||
NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_NO_PRINTROMPTSERVICE)
|
||||
NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTER_NO_XUL) // Temporary code for Bug 136185
|
||||
|
||||
default:
|
||||
|
@ -8299,12 +8367,10 @@ DocumentViewerImpl::GetCurrentPrintSettings(nsIPrintSettings * *aCurrentPrintSet
|
|||
NS_IMETHODIMP
|
||||
DocumentViewerImpl::Cancel()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrintOptions> printService = do_GetService(kPrintOptionsCID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && printService) {
|
||||
return printService->SetIsCancelled(PR_TRUE);
|
||||
if (mPrt && mPrt->mPrintSettings) {
|
||||
return mPrt->mPrintSettings->SetIsCancelled(PR_TRUE);
|
||||
}
|
||||
return NS_OK;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/* void initPrintSettingsFromPrefs (in nsIPrintSettings aPrintSettings, in boolean aUsePrinterNamePrefix, in unsigned long aFlags); */
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
|
||||
// nsIDOMContextMenuListener
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD ContextMenu (nsIDOMEvent* aEvent) { printf("preventing ContextMenu\n"); aEvent->PreventDefault(); return NS_OK; }
|
||||
NS_IMETHOD ContextMenu (nsIDOMEvent* aEvent) { aEvent->PreventDefault(); return NS_OK; }
|
||||
|
||||
// nsIDOMKeyListener
|
||||
NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent);
|
||||
|
|
|
@ -1610,20 +1610,6 @@
|
|||
<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>
|
||||
|
@ -2957,16 +2943,6 @@
|
|||
<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>
|
||||
|
@ -5111,20 +5087,6 @@
|
|||
<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>
|
||||
|
@ -6458,16 +6420,6 @@
|
|||
<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>
|
||||
|
@ -7124,18 +7076,6 @@
|
|||
<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>
|
||||
|
|
|
@ -2465,7 +2465,9 @@ GlobalWindowImpl::Print()
|
|||
nsCOMPtr<nsIWebBrowserPrint> webBrowserPrint;
|
||||
if (NS_SUCCEEDED(GetInterface(NS_GET_IID(nsIWebBrowserPrint),
|
||||
getter_AddRefs(webBrowserPrint)))) {
|
||||
webBrowserPrint->Print(nsnull, nsnull);
|
||||
nsCOMPtr<nsIPrintSettings> printSettings;
|
||||
webBrowserPrint->GetGlobalPrintSettings(getter_AddRefs(printSettings));
|
||||
webBrowserPrint->Print(printSettings, nsnull);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -801,20 +801,6 @@
|
|||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsIPrintingPrompt.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsIPrintingPromptService.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
</FILE>
|
||||
</FILELIST>
|
||||
<LINKORDER>
|
||||
<FILEREF>
|
||||
|
@ -882,16 +868,6 @@
|
|||
<PATH>nsITooltipTextProvider.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsIPrintingPrompt.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsIPrintingPromptService.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
</LINKORDER>
|
||||
</TARGET>
|
||||
<TARGET>
|
||||
|
@ -1642,20 +1618,6 @@
|
|||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsIPrintingPrompt.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsIPrintingPromptService.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
</FILE>
|
||||
</FILELIST>
|
||||
<LINKORDER>
|
||||
<FILEREF>
|
||||
|
@ -1723,16 +1685,6 @@
|
|||
<PATH>nsITooltipTextProvider.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsIPrintingPrompt.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsIPrintingPromptService.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
</LINKORDER>
|
||||
</TARGET>
|
||||
</TARGETLIST>
|
||||
|
@ -1821,18 +1773,6 @@
|
|||
<PATH>nsIWebBrowserSetup.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<TARGETNAME>embeddingbrowser.xpt</TARGETNAME>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsIPrintingPrompt.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<TARGETNAME>embeddingbrowser.xpt</TARGETNAME>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsIPrintingPromptService.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
</GROUPLIST>
|
||||
|
||||
</PROJECT>
|
||||
|
|
|
@ -39,163 +39,17 @@
|
|||
// Local
|
||||
#include "CPrintAttachment.h"
|
||||
#include "CBrowserShell.h"
|
||||
#include "UMacUnicode.h"
|
||||
#include "ApplIDs.h"
|
||||
|
||||
// Gecko
|
||||
#include "nsIPrintOptions.h"
|
||||
#include "nsIPrintingPromptService.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIServiceManagerUtils.h"
|
||||
#include "nsIWebBrowserPrint.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
#include "nsIEmbeddingSiteWindow.h"
|
||||
|
||||
// PowerPlant
|
||||
#include <LProgressBar.h>
|
||||
#include <LStaticText.h>
|
||||
|
||||
// Std Lib
|
||||
#include <algorithm>
|
||||
using namespace std;
|
||||
|
||||
// Constants
|
||||
enum {
|
||||
paneID_ProgressBar = 'Prog',
|
||||
paneID_StatusText = 'Stat'
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
//*** CPrintProgressListener
|
||||
//*****************************************************************************
|
||||
|
||||
class CPrintProgressListener : public nsIWebProgressListener,
|
||||
public LListener
|
||||
{
|
||||
public:
|
||||
CPrintProgressListener(nsIWebBrowserPrint *wbPrint,
|
||||
const nsAString& jobTitle);
|
||||
virtual ~CPrintProgressListener();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWEBPROGRESSLISTENER
|
||||
|
||||
void ListenToMessage(MessageT inMessage,
|
||||
void* ioParam);
|
||||
|
||||
protected:
|
||||
nsIWebBrowserPrint *mWBPrint;
|
||||
nsString mJobTitle;
|
||||
|
||||
LWindow *mDialog;
|
||||
LProgressBar *mDialogProgressBar;
|
||||
LStaticText *mDialogStatusText;
|
||||
};
|
||||
|
||||
CPrintProgressListener::CPrintProgressListener(nsIWebBrowserPrint* wbPrint,
|
||||
const nsAString& jobTitle) :
|
||||
mWBPrint(wbPrint), mJobTitle(jobTitle),
|
||||
mDialog(nsnull), mDialogProgressBar(nsnull), mDialogStatusText(nsnull)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
ThrowIfNil_(mWBPrint);
|
||||
}
|
||||
|
||||
CPrintProgressListener::~CPrintProgressListener()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(CPrintProgressListener,
|
||||
nsIWebProgressListener);
|
||||
|
||||
NS_IMETHODIMP CPrintProgressListener::OnStateChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRInt32 aStateFlags, PRUint32 aStatus)
|
||||
{
|
||||
if ((aStateFlags & nsIWebProgressListener::STATE_IS_DOCUMENT) &&
|
||||
(aStateFlags & nsIWebProgressListener::STATE_START))
|
||||
{
|
||||
if (!mDialog) {
|
||||
try {
|
||||
mDialog = LWindow::CreateWindow(dlog_OS9PrintProgress, LCommander::GetTopCommander());
|
||||
UReanimator::LinkListenerToBroadcasters(this, mDialog, dlog_OS9PrintProgress);
|
||||
mDialogProgressBar = dynamic_cast<LProgressBar*>(mDialog->FindPaneByID(paneID_ProgressBar));
|
||||
mDialogStatusText = dynamic_cast<LStaticText*>(mDialog->FindPaneByID(paneID_StatusText));
|
||||
if (mDialogStatusText && mJobTitle.Length()) {
|
||||
// The status text in the resource is something like: "Document: ^0" or "Printing: ^0"
|
||||
// Get that text and replace "^0" with the job title.
|
||||
char buf[256];
|
||||
Size bufLen;
|
||||
mDialogStatusText->GetText(buf, sizeof(buf) - 1, &bufLen);
|
||||
buf[bufLen] = '\0';
|
||||
|
||||
nsCAutoString statusCString(buf);
|
||||
nsCAutoString jobTitleCString;
|
||||
CPlatformUCSConversion::GetInstance()->UCSToPlatform(mJobTitle, jobTitleCString);
|
||||
statusCString.ReplaceSubstring(nsCAutoString("^0"), jobTitleCString);
|
||||
|
||||
mDialogStatusText->SetText(const_cast<char *>(statusCString.get()), statusCString.Length());
|
||||
}
|
||||
mDialog->Show();
|
||||
}
|
||||
catch (...) {
|
||||
NS_ERROR("Failed to make print progress dialog - missing a resource?");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((aStateFlags & nsIWebProgressListener::STATE_IS_DOCUMENT) &&
|
||||
(aStateFlags & nsIWebProgressListener::STATE_STOP))
|
||||
{
|
||||
delete mDialog;
|
||||
mDialog = nsnull;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CPrintProgressListener::OnProgressChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRInt32 aCurSelfProgress, PRInt32 aMaxSelfProgress, PRInt32 aCurTotalProgress, PRInt32 aMaxTotalProgress)
|
||||
{
|
||||
if (mDialogProgressBar) {
|
||||
if (aMaxSelfProgress != -1 && mDialogProgressBar->IsIndeterminate())
|
||||
mDialogProgressBar->SetIndeterminateFlag(false, false);
|
||||
else if (aMaxSelfProgress == -1 && !mDialogProgressBar->IsIndeterminate())
|
||||
mDialogProgressBar->SetIndeterminateFlag(true, true);
|
||||
|
||||
if (!mDialogProgressBar->IsIndeterminate()) {
|
||||
PRInt32 aMax = max(0, aMaxSelfProgress);
|
||||
PRInt32 aVal = min(aMax, max(0, aCurSelfProgress));
|
||||
mDialogProgressBar->SetMaxValue(aMax);
|
||||
mDialogProgressBar->SetValue(aVal);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CPrintProgressListener::OnLocationChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsIURI *location)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CPrintProgressListener::OnStatusChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, nsresult aStatus, const PRUnichar *aMessage)
|
||||
{
|
||||
nsCAutoString cString; cString.AssignWithConversion(aMessage);
|
||||
printf("CPrintProgressListener::OnStatusChange: aStatus = %s\n", cString.get());
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CPrintProgressListener::OnSecurityChange(nsIWebProgress *aWebProgress, nsIRequest *aRequest, PRInt32 state)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
void CPrintProgressListener::ListenToMessage(MessageT inMessage,
|
||||
void* ioParam)
|
||||
{
|
||||
if (inMessage == msg_Cancel)
|
||||
mWBPrint->Cancel();
|
||||
}
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
//*** CPrintAttachment
|
||||
|
@ -287,57 +141,32 @@ void CPrintAttachment::DoPrint()
|
|||
nsCOMPtr<nsIPrintSettings> settings;
|
||||
mBrowserShell->GetPrintSettings(getter_AddRefs(settings));
|
||||
ThrowIfNil_(settings);
|
||||
|
||||
// The progress listener handles a print progress dialog. Don't do this on OS X because
|
||||
// the OS puts up a perfectly lovely one automatically. We're not at the mercy of the
|
||||
// printer driver for this as we are on Classic.
|
||||
nsCOMPtr<nsIWebProgressListener> listener;
|
||||
|
||||
long version;
|
||||
PRBool runningOSX = (::Gestalt(gestaltSystemVersion, &version) == noErr && version >= 0x00001000);
|
||||
|
||||
if (!runningOSX) {
|
||||
// Get the title for the job and make a listener.
|
||||
nsXPIDLString jobTitle;
|
||||
nsCOMPtr<nsIWebBrowserChrome> chrome;
|
||||
mBrowserShell->GetWebBrowserChrome(getter_AddRefs(chrome));
|
||||
ThrowIfNil_(chrome);
|
||||
nsCOMPtr<nsIEmbeddingSiteWindow> siteWindow(do_QueryInterface(chrome));
|
||||
ThrowIfNil_(siteWindow);
|
||||
siteWindow->GetTitle(getter_Copies(jobTitle));
|
||||
|
||||
// Don't AddRef the listener. The nsIWebBrowserPrint holds the only ref to it.
|
||||
listener = new CPrintProgressListener(wbPrint, jobTitle);
|
||||
}
|
||||
|
||||
// In any case, we don't want Gecko to display its XUL progress dialog.
|
||||
// Unfortunately, there is nothing in the printing API to control this -
|
||||
// it's done through a pref :-( If you are distributing your own default
|
||||
// prefs, this could be done there instead of programatically.
|
||||
nsCOMPtr<nsIPrefService> prefsService(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||
if (prefsService) {
|
||||
nsCOMPtr<nsIPrefBranch> printBranch;
|
||||
prefsService->GetBranch("print.", getter_AddRefs(printBranch));
|
||||
if (printBranch) {
|
||||
printBranch->SetBoolPref("show_print_progress", PR_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult rv = wbPrint->Print(settings, listener);
|
||||
ThrowIfError_(rv);
|
||||
|
||||
nsresult rv = wbPrint->Print(settings, nsnull);
|
||||
if (rv != NS_ERROR_ABORT)
|
||||
ThrowIfError_(rv);
|
||||
}
|
||||
|
||||
|
||||
void CPrintAttachment::DoPageSetup()
|
||||
{
|
||||
nsCOMPtr<nsIPrintOptions> printOptionsService = do_GetService("@mozilla.org/gfx/printoptions;1");
|
||||
ThrowIfNil_(printOptionsService);
|
||||
nsCOMPtr<nsIPrintSettings> printSettings;
|
||||
mBrowserShell->GetPrintSettings(getter_AddRefs(printSettings));
|
||||
ThrowIfNil_(printSettings);
|
||||
nsCOMPtr<nsIWebBrowser> wb;
|
||||
mBrowserShell->GetWebBrowser(getter_AddRefs(wb));
|
||||
ThrowIfNil_(wb);
|
||||
nsCOMPtr<nsIDOMWindow> domWindow;
|
||||
wb->GetContentDOMWindow(getter_AddRefs(domWindow));
|
||||
ThrowIfNil_(domWindow);
|
||||
nsCOMPtr<nsIPrintSettings> settings;
|
||||
mBrowserShell->GetPrintSettings(getter_AddRefs(settings));
|
||||
ThrowIfNil_(settings);
|
||||
|
||||
nsresult rv = printOptionsService->ShowPrintSetupDialog(printSettings);
|
||||
ThrowIfError_(rv);
|
||||
nsCOMPtr<nsIPrintingPromptService> printingPromptService =
|
||||
do_GetService("@mozilla.org/embedcomp/printingprompt-service;1");
|
||||
ThrowIfNil_(printingPromptService);
|
||||
|
||||
nsresult rv = printingPromptService->ShowPageSetup(domWindow, settings);
|
||||
if (rv != NS_ERROR_ABORT)
|
||||
ThrowIfError_(rv);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ LOCAL_INCLUDES += -I$(srcdir)/../printingui/src/os2
|
|||
endif
|
||||
|
||||
ifneq (,$(filter gtk gtk2 xlib beos qt, $(MOZ_WIDGET_TOOLKIT)))
|
||||
LOCAL_INCLUDES += -I$(srcdir)/../printingui/src/gtk
|
||||
LOCAL_INCLUDES += -I$(srcdir)/../printingui/src/unixshared
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_GFX_TOOLKIT),windows)
|
||||
|
|
|
@ -27,7 +27,7 @@ VPATH = @srcdir@
|
|||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
ifneq (,$(filter gtk gtk2 xlib qt beos,$(MOZ_WIDGET_TOOLKIT)))
|
||||
DIRS += gtk
|
||||
DIRS += unixshared
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
resource 'DITL' (128) {
|
||||
{ /* array DITLarray: 6 elements */
|
||||
/* [1] */
|
||||
{16, 32, 33, 168},
|
||||
{16, 32, 33, 178},
|
||||
CheckBox {
|
||||
enabled,
|
||||
"Print Selection Only"
|
||||
|
|
|
@ -984,18 +984,15 @@ LRESULT CBrowserView::OnFindMsg(WPARAM wParam, LPARAM lParam)
|
|||
void CBrowserView::OnFilePrint()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID, &rv));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
prefs->SetBoolPref("print.use_native_print_dialog", PR_TRUE);
|
||||
prefs->SetBoolPref("print.show_print_progress", PR_FALSE);
|
||||
}
|
||||
else
|
||||
NS_ASSERTION(PR_FALSE, "Could not get preferences service");
|
||||
|
||||
nsCOMPtr<nsIWebBrowserPrint> print(do_GetInterface(mWebBrowser));
|
||||
if(print)
|
||||
{
|
||||
if (!m_PrintSettings)
|
||||
{
|
||||
print->GetGlobalPrintSettings(getter_AddRefs(m_PrintSettings));
|
||||
}
|
||||
|
||||
m_PrintSettings->SetShowPrintProgress(PR_FALSE);
|
||||
CPrintProgressDialog dlg(mWebBrowser, m_PrintSettings);
|
||||
|
||||
nsCOMPtr<nsIURI> currentURI;
|
||||
|
|
|
@ -107,15 +107,6 @@ interface nsIPrintOptions : nsISupports
|
|||
*/
|
||||
void displayJobProperties (in wstring aPrinter, in nsIPrintSettings aPrintSettings, out boolean aDisplayed);
|
||||
|
||||
// Attributes
|
||||
attribute boolean isCancelled;
|
||||
|
||||
attribute wstring title;
|
||||
attribute wstring docURL;
|
||||
|
||||
attribute boolean printToFile;
|
||||
attribute wstring toFileName;
|
||||
|
||||
// no script methods
|
||||
[noscript] void SetFontNamePointSize(in nsNativeStringRef aName, in PRInt32 aPointSize);
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -131,6 +131,8 @@ public:
|
|||
|
||||
NS_IMETHOD GetPaletteInfo(nsPaletteInfo& aPaletteInfo);
|
||||
|
||||
NS_IMETHOD PrepareDocument(PRUnichar * aTitle,
|
||||
PRUnichar* aPrintToFileName) { return NS_OK; }
|
||||
NS_IMETHOD AbortDocument(void) { return NS_OK; }
|
||||
|
||||
#ifdef NS_PRINT_PREVIEW
|
||||
|
|
|
@ -138,6 +138,12 @@ typedef void * nsNativeDeviceContext;
|
|||
/* Cannot Print or Print Preview XUL Documents */
|
||||
#define NS_ERROR_GFX_PRINTER_NO_XUL \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+27)
|
||||
/* The toolkit no longer supports the Print Dialog (for embedders) */
|
||||
#define NS_ERROR_GFX_NO_PRINTDIALOG_IN_TOOLKIT \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+28)
|
||||
/* The was wasn't any Print Prompt service registered (this shouldn't happen) */
|
||||
#define NS_ERROR_GFX_NO_PRINTROMPTSERVICE \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GFX,NS_ERROR_GFX_PRINTER_BASE+29)
|
||||
|
||||
|
||||
/**
|
||||
|
@ -462,6 +468,17 @@ public:
|
|||
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
|
||||
nsIDeviceContext *&aContext) = 0;
|
||||
|
||||
/**
|
||||
* This is enables the DeviceContext to anything it needs to do for Printing
|
||||
* before Reflow and BeginDocument is where work can be done after reflow.
|
||||
* @param aTitle - itle of Document
|
||||
* @param aPrintToFileName - name of file to print to, if NULL then don't print to file
|
||||
*
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD PrepareDocument(PRUnichar * aTitle,
|
||||
PRUnichar* aPrintToFileName) = 0;
|
||||
|
||||
//XXX need to work out re-entrancy issues for these APIs... MMP
|
||||
/**
|
||||
* Inform the output device that output of a document is beginning
|
||||
|
@ -469,9 +486,18 @@ public:
|
|||
* EndDocument().
|
||||
* XXX needs to take parameters so that feedback can be given to the
|
||||
* app regarding pagination progress and aborting print operations?
|
||||
*
|
||||
* @param aTitle - itle of Document
|
||||
* @param aPrintToFileName - name of file to print to, if NULL then don't print to file
|
||||
* @param aStartPage - starting page number (must be greater than zero)
|
||||
* @param aEndPage - ending page number (must be less than or equal to number of pages)
|
||||
*
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD BeginDocument(PRUnichar * aTitle) = 0;
|
||||
NS_IMETHOD BeginDocument(PRUnichar* aTitle,
|
||||
PRUnichar* aPrintToFileName,
|
||||
PRInt32 aStartPage,
|
||||
PRInt32 aEndPage) = 0;
|
||||
|
||||
/**
|
||||
* Inform the output device that output of a document is ending.
|
||||
|
|
|
@ -64,24 +64,17 @@ public:
|
|||
* means getting information about a printer. A previously
|
||||
* returned device context spec can be passed in and used as
|
||||
* a starting point for getting a new spec (or simply returning
|
||||
* the old spec again). Additionally, if it is desirable to
|
||||
* get the device context spec without user intervention, any
|
||||
* dialog boxes can be supressed by passing in PR_TRUE for the
|
||||
* aQuiet parameter.
|
||||
* the old spec again).
|
||||
* @param aWidget.. this is a widget a dialog can be hosted in
|
||||
* @param aNewSpec out parameter for device context spec returned. the
|
||||
* aOldSpec may be returned if the object is recyclable.
|
||||
* @param aQuiet if PR_TRUE, prevent the need for user intervention
|
||||
* in obtaining device context spec. if nsnull is passed in for
|
||||
* the aOldSpec, this will typically result in getting a device
|
||||
* context spec for the default output device (i.e. default
|
||||
* printer).
|
||||
* @param aIsPrintPreview if PR_TRUE, creating Spec for PrintPreview
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget,
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet) = 0;
|
||||
PRBool aIsPrintPreview) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -54,14 +54,10 @@ public:
|
|||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPRINTING_CONTEXT_IID)
|
||||
/**
|
||||
* Initialize the printing context for use.
|
||||
* @param aQuiet if PR_TRUE, prevent the need for user intervention
|
||||
* in obtaining device context spec. if nsnull is passed in for
|
||||
* the aOldSpec, this will typically result in getting a device
|
||||
* context spec for the default output device (i.e. default
|
||||
* printer).
|
||||
* @param aIsPrintPreview TRUE if doing print preview, FALSE if normal printing.
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet) = 0;
|
||||
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aIsPrintPreview) = 0;
|
||||
|
||||
/**
|
||||
* This will tell if the printmanager is currently open
|
||||
|
@ -78,7 +74,8 @@ public:
|
|||
*/
|
||||
NS_IMETHOD ClosePrintManager() = 0;
|
||||
|
||||
NS_IMETHOD BeginDocument() = 0;
|
||||
NS_IMETHOD BeginDocument(PRInt32 aStartPage,
|
||||
PRInt32 aEndPage) = 0;
|
||||
|
||||
NS_IMETHOD EndDocument() = 0;
|
||||
|
||||
|
|
|
@ -55,8 +55,6 @@ 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)
|
||||
NS_IMETHODIMP nsDeviceContextBeOS::BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ public:
|
|||
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
|
||||
nsIDeviceContext *&aContext);
|
||||
|
||||
NS_IMETHOD BeginDocument(PRUnichar * aTitle);
|
||||
NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage);
|
||||
NS_IMETHOD EndDocument(void);
|
||||
|
||||
NS_IMETHOD BeginPage(void);
|
||||
|
|
|
@ -42,19 +42,6 @@
|
|||
#include "nsIPref.h"
|
||||
#include "prenv.h" /* for PR_GetEnv */
|
||||
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDialogParamBlock.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsISupportsArray.h"
|
||||
|
||||
//#include "prmem.h"
|
||||
//#include "plstr.h"
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// The printer data is shared between the PrinterEnumerator and the nsDeviceContextSpecG
|
||||
// The PrinterEnumerator creates the printer info
|
||||
|
@ -153,73 +140,12 @@ NS_IMETHODIMP nsDeviceContextSpecBeOS :: QueryInterface(REFNSIID aIID, void** aI
|
|||
NS_IMPL_ADDREF(nsDeviceContextSpecBeOS)
|
||||
NS_IMPL_RELEASE(nsDeviceContextSpecBeOS)
|
||||
|
||||
|
||||
/** -------------------------------------------------------
|
||||
*/
|
||||
static nsresult DisplayXPDialog(nsIPrintSettings* aPS,
|
||||
const char* aChromeURL,
|
||||
PRBool& aClickedOK)
|
||||
{
|
||||
NS_ASSERTION(aPS, "Must have a print settings!");
|
||||
|
||||
aClickedOK = PR_FALSE;
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
// create a nsISupportsArray of the parameters
|
||||
// being passed to the window
|
||||
nsCOMPtr<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, PRBool aQuiet)
|
||||
NS_IMETHODIMP nsDeviceContextSpecBeOS::Init(nsIPrintSettings* aPS)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
NS_ASSERTION(nsnull != aPS, "No print settings.");
|
||||
|
@ -260,99 +186,88 @@ NS_IMETHODIMP nsDeviceContextSpecBeOS::Init(nsIPrintSettings* aPS, PRBool aQuiet
|
|||
return rv;
|
||||
}
|
||||
|
||||
if (!aQuiet ) {
|
||||
rv = DisplayXPDialog(aPS,
|
||||
"chrome://global/content/printdialog.xul", canPrint);
|
||||
}
|
||||
else {
|
||||
canPrint = PR_TRUE;
|
||||
}
|
||||
|
||||
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
|
||||
|
||||
if (canPrint) {
|
||||
if (aPS != nsnull) {
|
||||
aPS->GetPrinterName(&printer);
|
||||
aPS->GetPrintReversed(&reversed);
|
||||
aPS->GetPrintInColor(&color);
|
||||
aPS->GetPaperSize(&paper_size);
|
||||
aPS->GetOrientation(&orientation);
|
||||
aPS->GetPrintCommand(&command);
|
||||
aPS->GetPrintRange(&printRange);
|
||||
aPS->GetToFileName(&printfile);
|
||||
aPS->GetPrintToFile(&tofile);
|
||||
aPS->GetStartPageRange(&fromPage);
|
||||
aPS->GetEndPageRange(&toPage);
|
||||
aPS->GetNumCopies(&copies);
|
||||
aPS->GetMarginTop(&dtop);
|
||||
aPS->GetMarginLeft(&dleft);
|
||||
aPS->GetMarginBottom(&dbottom);
|
||||
aPS->GetMarginRight(&dright);
|
||||
if (aPS != nsnull) {
|
||||
aPS->GetPrinterName(&printer);
|
||||
aPS->GetPrintReversed(&reversed);
|
||||
aPS->GetPrintInColor(&color);
|
||||
aPS->GetPaperSize(&paper_size);
|
||||
aPS->GetOrientation(&orientation);
|
||||
aPS->GetPrintCommand(&command);
|
||||
aPS->GetPrintRange(&printRange);
|
||||
aPS->GetToFileName(&printfile);
|
||||
aPS->GetPrintToFile(&tofile);
|
||||
aPS->GetStartPageRange(&fromPage);
|
||||
aPS->GetEndPageRange(&toPage);
|
||||
aPS->GetNumCopies(&copies);
|
||||
aPS->GetMarginTop(&dtop);
|
||||
aPS->GetMarginLeft(&dleft);
|
||||
aPS->GetMarginBottom(&dbottom);
|
||||
aPS->GetMarginRight(&dright);
|
||||
|
||||
if (command != nsnull && printfile != nsnull) {
|
||||
// ToDo: Use LocalEncoding instead of UTF-8 (see bug 73446)
|
||||
strcpy(mPrData.command, NS_ConvertUCS2toUTF8(command).get());
|
||||
strcpy(mPrData.path, NS_ConvertUCS2toUTF8(printfile).get());
|
||||
}
|
||||
if (printer != nsnull)
|
||||
strcpy(mPrData.printer, NS_ConvertUCS2toUTF8(printer).get());
|
||||
if (command != nsnull && printfile != nsnull) {
|
||||
// ToDo: Use LocalEncoding instead of UTF-8 (see bug 73446)
|
||||
strcpy(mPrData.command, NS_ConvertUCS2toUTF8(command).get());
|
||||
strcpy(mPrData.path, NS_ConvertUCS2toUTF8(printfile).get());
|
||||
}
|
||||
if (printer != nsnull)
|
||||
strcpy(mPrData.printer, NS_ConvertUCS2toUTF8(printer).get());
|
||||
#ifdef DEBUG_rods
|
||||
printf("margins: %5.2f,%5.2f,%5.2f,%5.2f\n", dtop, dleft, dbottom, dright);
|
||||
printf("printRange %d\n", printRange);
|
||||
printf("fromPage %d\n", fromPage);
|
||||
printf("toPage %d\n", toPage);
|
||||
printf("margins: %5.2f,%5.2f,%5.2f,%5.2f\n", dtop, dleft, dbottom, dright);
|
||||
printf("printRange %d\n", printRange);
|
||||
printf("fromPage %d\n", fromPage);
|
||||
printf("toPage %d\n", toPage);
|
||||
#endif /* DEBUG_rods */
|
||||
} else {
|
||||
} else {
|
||||
#ifdef VMS
|
||||
// Note to whoever puts the "lpr" into the prefs file. Please contact me
|
||||
// as I need to make the default be "print" instead of "lpr" for OpenVMS.
|
||||
strcpy(mPrData.command, "print");
|
||||
// Note to whoever puts the "lpr" into the prefs file. Please contact me
|
||||
// as I need to make the default be "print" instead of "lpr" for OpenVMS.
|
||||
strcpy(mPrData.command, "print");
|
||||
#else
|
||||
strcpy(mPrData.command, "lpr ${MOZ_PRINTER_NAME:+'-P'}${MOZ_PRINTER_NAME}");
|
||||
strcpy(mPrData.command, "lpr ${MOZ_PRINTER_NAME:+'-P'}${MOZ_PRINTER_NAME}");
|
||||
#endif /* VMS */
|
||||
}
|
||||
}
|
||||
|
||||
mPrData.top = dtop;
|
||||
mPrData.bottom = dbottom;
|
||||
mPrData.left = dleft;
|
||||
mPrData.right = dright;
|
||||
mPrData.fpf = !reversed;
|
||||
mPrData.grayscale = !color;
|
||||
mPrData.size = paper_size;
|
||||
mPrData.orientation = orientation;
|
||||
mPrData.toPrinter = !tofile;
|
||||
mPrData.copies = copies;
|
||||
mPrData.top = dtop;
|
||||
mPrData.bottom = dbottom;
|
||||
mPrData.left = dleft;
|
||||
mPrData.right = dright;
|
||||
mPrData.fpf = !reversed;
|
||||
mPrData.grayscale = !color;
|
||||
mPrData.size = paper_size;
|
||||
mPrData.orientation = orientation;
|
||||
mPrData.toPrinter = !tofile;
|
||||
mPrData.copies = copies;
|
||||
|
||||
// PWD, HOME, or fail
|
||||
|
||||
if (!printfile) {
|
||||
if ( ( path = PR_GetEnv( "PWD" ) ) == (char *) nsnull )
|
||||
if ( ( path = PR_GetEnv( "HOME" ) ) == (char *) nsnull )
|
||||
strcpy(mPrData.path, "mozilla.ps");
|
||||
|
||||
if ( path != (char *) nsnull )
|
||||
sprintf(mPrData.path, "%s/mozilla.ps", path);
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// PWD, HOME, or fail
|
||||
|
||||
if (!printfile) {
|
||||
if ( ( path = PR_GetEnv( "PWD" ) ) == (char *) nsnull )
|
||||
if ( ( path = PR_GetEnv( "HOME" ) ) == (char *) nsnull )
|
||||
strcpy(mPrData.path, "mozilla.ps");
|
||||
|
||||
if ( path != (char *) nsnull )
|
||||
sprintf(mPrData.path, "%s/mozilla.ps", path);
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef NOT_IMPLEMENTED_YET
|
||||
if (mGlobalNumPrinters) {
|
||||
for(int i = 0; (i < mGlobalNumPrinters) && !mQueue; i++) {
|
||||
if (!(mGlobalPrinterList->StringAt(i)->CompareWithConversion(mPrData.printer, TRUE, -1)))
|
||||
mQueue = PrnDlg.SetPrinterQueue(i);
|
||||
}
|
||||
}
|
||||
if (mGlobalNumPrinters) {
|
||||
for(int i = 0; (i < mGlobalNumPrinters) && !mQueue; i++) {
|
||||
if (!(mGlobalPrinterList->StringAt(i)->CompareWithConversion(mPrData.printer, TRUE, -1)))
|
||||
mQueue = PrnDlg.SetPrinterQueue(i);
|
||||
}
|
||||
}
|
||||
#endif /* NOT_IMPLEMENTED_YET */
|
||||
|
||||
if (command != nsnull) {
|
||||
nsMemory::Free(command);
|
||||
}
|
||||
if (printfile != nsnull) {
|
||||
nsMemory::Free(printfile);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
||||
if (command != nsnull) {
|
||||
nsMemory::Free(command);
|
||||
}
|
||||
if (printfile != nsnull) {
|
||||
nsMemory::Free(printfile);
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -564,19 +479,7 @@ NS_IMETHODIMP nsPrinterEnumeratorBeOS::InitPrintSettingsFromPrinter(const PRUnic
|
|||
|
||||
NS_IMETHODIMP nsPrinterEnumeratorBeOS::DisplayPropertiesDlg(const PRUnichar *aPrinter, nsIPrintSettings *aPrintSettings)
|
||||
{
|
||||
/* fixme: We simply ignore the |aPrinter| argument here
|
||||
* We should get the supported printer attributes from the printer and
|
||||
* populate the print job options dialog with these data instead of using
|
||||
* the "default set" here.
|
||||
* However, this requires changes on all platforms and is another big chunk
|
||||
* of patches ... ;-(
|
||||
*/
|
||||
|
||||
PRBool pressedOK;
|
||||
return DisplayXPDialog(aPrintSettings,
|
||||
"chrome://global/content/printjoboptions.xul",
|
||||
pressedOK);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -68,14 +68,10 @@ public:
|
|||
/**
|
||||
* Initialize the nsDeviceContextSpecBeOS for use. This will allocate a printrecord for use
|
||||
* @update dc 2/16/98
|
||||
* @param aQuiet if PR_TRUE, prevent the need for user intervention
|
||||
* in obtaining device context spec. if nsnull is passed in for
|
||||
* the aOldSpec, this will typically result in getting a device
|
||||
* context spec for the default output device (i.e. default
|
||||
* printer).
|
||||
* @param aIsPrintPreview if PR_TRUE, creating Spec for PrintPreview
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet);
|
||||
NS_IMETHOD Init(nsIPrintSettings* aPS);
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -79,15 +79,15 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryBeOS :: Init(void)
|
|||
*/
|
||||
NS_IMETHODIMP nsDeviceContextSpecFactoryBeOS :: CreateDeviceContextSpec(nsIWidget *aWidget,
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet)
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aIsPrintPreview)
|
||||
{
|
||||
nsresult rv;
|
||||
static NS_DEFINE_CID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
|
||||
nsCOMPtr<nsIDeviceContextSpec> devSpec = do_CreateInstance(kDeviceContextSpecCID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = ((nsDeviceContextSpecBeOS *)devSpec.get())->Init(aPrintSettings, aQuiet);
|
||||
rv = ((nsDeviceContextSpecBeOS *)devSpec.get())->Init(aPrintSettings);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
aNewSpec = devSpec;
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget,
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet);
|
||||
PRBool aIsPrintPreview);
|
||||
|
||||
protected:
|
||||
virtual ~nsDeviceContextSpecFactoryBeOS();
|
||||
|
|
|
@ -37,15 +37,13 @@ REQUIRES = xpcom \
|
|||
widget \
|
||||
view \
|
||||
util \
|
||||
dom \
|
||||
pref \
|
||||
uconv \
|
||||
unicharutil \
|
||||
windowwatcher \
|
||||
locale \
|
||||
necko \
|
||||
content \
|
||||
layout \
|
||||
necko \
|
||||
$(NULL)
|
||||
|
||||
# Sun's Complex Text Layout support
|
||||
|
|
|
@ -562,7 +562,7 @@ NS_IMETHODIMP nsDeviceContextGTK::GetDeviceContextFor(nsIDeviceContextSpec *aDev
|
|||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextGTK::BeginDocument(PRUnichar * aTitle)
|
||||
NS_IMETHODIMP nsDeviceContextGTK::BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ public:
|
|||
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
|
||||
nsIDeviceContext *&aContext);
|
||||
|
||||
NS_IMETHOD BeginDocument(PRUnichar * aTitle);
|
||||
NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage);
|
||||
NS_IMETHOD EndDocument(void);
|
||||
NS_IMETHOD AbortDocument(void);
|
||||
|
||||
|
|
|
@ -77,14 +77,14 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryGTK :: Init(void)
|
|||
NS_IMETHODIMP nsDeviceContextSpecFactoryGTK :: CreateDeviceContextSpec(nsIWidget *aWidget,
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet)
|
||||
PRBool aIsPrintPreview)
|
||||
{
|
||||
nsresult rv;
|
||||
static NS_DEFINE_CID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
|
||||
nsCOMPtr<nsIDeviceContextSpec> devSpec = do_CreateInstance(kDeviceContextSpecCID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = ((nsDeviceContextSpecGTK *)devSpec.get())->Init(aPrintSettings, aQuiet);
|
||||
rv = ((nsDeviceContextSpecGTK *)devSpec.get())->Init(aPrintSettings);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
aNewSpec = devSpec;
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget,
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet);
|
||||
PRBool aIsPrintPreview);
|
||||
|
||||
protected:
|
||||
virtual ~nsDeviceContextSpecFactoryGTK();
|
||||
|
|
|
@ -51,16 +51,9 @@
|
|||
#include "nsIPref.h"
|
||||
#include "prenv.h" /* for PR_GetEnv */
|
||||
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDialogParamBlock.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsISupportsArray.h"
|
||||
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#ifdef USE_XPRINT
|
||||
#include "xprintutil.h"
|
||||
|
@ -254,66 +247,6 @@ NS_IMPL_ISUPPORTS1(nsDeviceContextSpecGTK,
|
|||
#error "This should not happen"
|
||||
#endif
|
||||
|
||||
/** -------------------------------------------------------
|
||||
*/
|
||||
static nsresult DisplayXPDialog(nsIPrintSettings* aPS,
|
||||
const char* aChromeURL,
|
||||
PRBool& aClickedOK)
|
||||
{
|
||||
DO_PR_DEBUG_LOG(("nsDeviceContextSpecGTK::DisplayXPDialog()\n"));
|
||||
NS_ASSERTION(aPS, "Must have a print settings!");
|
||||
|
||||
aClickedOK = PR_FALSE;
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
// create a nsISupportsArray of the parameters
|
||||
// being passed to the window
|
||||
nsCOMPtr<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
|
||||
|
@ -323,115 +256,94 @@ static nsresult DisplayXPDialog(nsIPrintSettings* aPS,
|
|||
* toolkits including:
|
||||
* - GTK+-toolkit:
|
||||
* file: mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp
|
||||
* function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init(PRBool aQuiet)
|
||||
* function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init()
|
||||
* - GTK-toolkit:
|
||||
* file: mozilla/gfx/src/xlib/nsDeviceContextSpecGTK.cpp
|
||||
* function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init(PRBool aQuiet)
|
||||
* function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init()
|
||||
* - Qt-toolkit:
|
||||
* file: mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp
|
||||
* function: NS_IMETHODIMP nsDeviceContextSpecQT::Init(PRBool aQuiet)
|
||||
* function: NS_IMETHODIMP nsDeviceContextSpecQT::Init()
|
||||
*
|
||||
* ** Please update the other toolkits when changing this function.
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextSpecGTK::Init(nsIPrintSettings *aPS, PRBool aQuiet)
|
||||
NS_IMETHODIMP nsDeviceContextSpecGTK::Init(nsIPrintSettings *aPS)
|
||||
{
|
||||
DO_PR_DEBUG_LOG(("nsDeviceContextSpecGTK::Init(aPS=%p. qQuiet=%d)\n", aPS, (int)aQuiet));
|
||||
DO_PR_DEBUG_LOG(("nsDeviceContextSpecGTK::Init(aPS=%p)\n", aPS));
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
mPrintSettings = aPS;
|
||||
|
||||
// if there is a current selection then enable the "Selection" radio button
|
||||
if (mPrintSettings) {
|
||||
PRBool isOn;
|
||||
mPrintSettings->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB, &isOn);
|
||||
nsCOMPtr<nsIPref> pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
(void) pPrefs->SetBoolPref("print.selection_radio_enabled", isOn);
|
||||
}
|
||||
}
|
||||
|
||||
PRBool canPrint = PR_FALSE;
|
||||
|
||||
rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (!aQuiet) {
|
||||
rv = DisplayXPDialog(mPrintSettings,
|
||||
"chrome://global/content/printdialog.xul", canPrint);
|
||||
} else {
|
||||
rv = NS_OK;
|
||||
canPrint = PR_TRUE;
|
||||
}
|
||||
|
||||
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
|
||||
|
||||
if (NS_SUCCEEDED(rv) && canPrint) {
|
||||
if (aPS) {
|
||||
PRBool reversed = PR_FALSE;
|
||||
PRBool color = PR_FALSE;
|
||||
PRBool tofile = PR_FALSE;
|
||||
PRInt16 printRange = nsIPrintSettings::kRangeAllPages;
|
||||
PRInt32 orientation = NS_PORTRAIT;
|
||||
PRInt32 fromPage = 1;
|
||||
PRInt32 toPage = 1;
|
||||
PRUnichar *command = nsnull;
|
||||
PRInt32 copies = 1;
|
||||
PRUnichar *printer = nsnull;
|
||||
PRUnichar *papername = nsnull;
|
||||
PRUnichar *printfile = nsnull;
|
||||
double dleft = 0.5;
|
||||
double dright = 0.5;
|
||||
double dtop = 0.5;
|
||||
double dbottom = 0.5;
|
||||
if (aPS) {
|
||||
PRBool reversed = PR_FALSE;
|
||||
PRBool color = PR_FALSE;
|
||||
PRBool tofile = PR_FALSE;
|
||||
PRInt16 printRange = nsIPrintSettings::kRangeAllPages;
|
||||
PRInt32 orientation = NS_PORTRAIT;
|
||||
PRInt32 fromPage = 1;
|
||||
PRInt32 toPage = 1;
|
||||
PRUnichar *command = nsnull;
|
||||
PRInt32 copies = 1;
|
||||
PRUnichar *printer = nsnull;
|
||||
PRUnichar *papername = nsnull;
|
||||
PRUnichar *printfile = nsnull;
|
||||
double dleft = 0.5;
|
||||
double dright = 0.5;
|
||||
double dtop = 0.5;
|
||||
double dbottom = 0.5;
|
||||
|
||||
aPS->GetPrinterName(&printer);
|
||||
aPS->GetPrintReversed(&reversed);
|
||||
aPS->GetPrintInColor(&color);
|
||||
aPS->GetPaperName(&papername);
|
||||
aPS->GetOrientation(&orientation);
|
||||
aPS->GetPrintCommand(&command);
|
||||
aPS->GetPrintRange(&printRange);
|
||||
aPS->GetToFileName(&printfile);
|
||||
aPS->GetPrintToFile(&tofile);
|
||||
aPS->GetStartPageRange(&fromPage);
|
||||
aPS->GetEndPageRange(&toPage);
|
||||
aPS->GetNumCopies(&copies);
|
||||
aPS->GetMarginTop(&dtop);
|
||||
aPS->GetMarginLeft(&dleft);
|
||||
aPS->GetMarginBottom(&dbottom);
|
||||
aPS->GetMarginRight(&dright);
|
||||
aPS->GetPrinterName(&printer);
|
||||
aPS->GetPrintReversed(&reversed);
|
||||
aPS->GetPrintInColor(&color);
|
||||
aPS->GetPaperName(&papername);
|
||||
aPS->GetOrientation(&orientation);
|
||||
aPS->GetPrintCommand(&command);
|
||||
aPS->GetPrintRange(&printRange);
|
||||
aPS->GetToFileName(&printfile);
|
||||
aPS->GetPrintToFile(&tofile);
|
||||
aPS->GetStartPageRange(&fromPage);
|
||||
aPS->GetEndPageRange(&toPage);
|
||||
aPS->GetNumCopies(&copies);
|
||||
aPS->GetMarginTop(&dtop);
|
||||
aPS->GetMarginLeft(&dleft);
|
||||
aPS->GetMarginBottom(&dbottom);
|
||||
aPS->GetMarginRight(&dright);
|
||||
|
||||
if (printfile)
|
||||
strcpy(mPath, NS_ConvertUCS2toUTF8(printfile).get());
|
||||
if (command)
|
||||
strcpy(mCommand, NS_ConvertUCS2toUTF8(command).get());
|
||||
if (printer)
|
||||
strcpy(mPrinter, NS_ConvertUCS2toUTF8(printer).get());
|
||||
if (papername)
|
||||
strcpy(mPaperName, NS_ConvertUCS2toUTF8(papername).get());
|
||||
if (printfile)
|
||||
strcpy(mPath, NS_ConvertUCS2toUTF8(printfile).get());
|
||||
if (command)
|
||||
strcpy(mCommand, NS_ConvertUCS2toUTF8(command).get());
|
||||
if (printer)
|
||||
strcpy(mPrinter, NS_ConvertUCS2toUTF8(printer).get());
|
||||
if (papername)
|
||||
strcpy(mPaperName, NS_ConvertUCS2toUTF8(papername).get());
|
||||
|
||||
DO_PR_DEBUG_LOG(("margins: %5.2f,%5.2f,%5.2f,%5.2f\n", dtop, dleft, dbottom, dright));
|
||||
DO_PR_DEBUG_LOG(("printRange %d\n", printRange));
|
||||
DO_PR_DEBUG_LOG(("fromPage %d\n", fromPage));
|
||||
DO_PR_DEBUG_LOG(("toPage %d\n", toPage));
|
||||
DO_PR_DEBUG_LOG(("tofile %d\n", tofile));
|
||||
DO_PR_DEBUG_LOG(("printfile '%s'\n", printfile? NS_ConvertUCS2toUTF8(printfile).get():"<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;
|
||||
|
@ -993,19 +905,7 @@ NS_IMETHODIMP nsPrinterEnumeratorGTK::InitPrintSettingsFromPrinter(const PRUnich
|
|||
|
||||
NS_IMETHODIMP nsPrinterEnumeratorGTK::DisplayPropertiesDlg(const PRUnichar *aPrinter, nsIPrintSettings *aPrintSettings)
|
||||
{
|
||||
/* fixme: We simply ignore the |aPrinter| argument here
|
||||
* We should get the supported printer attributes from the printer and
|
||||
* populate the print job options dialog with these data instead of using
|
||||
* the "default set" here.
|
||||
* However, this requires changes on all platforms and is another big chunk
|
||||
* of patches ... ;-(
|
||||
*/
|
||||
|
||||
PRBool pressedOK;
|
||||
return DisplayXPDialog(aPrintSettings,
|
||||
"chrome://global/content/printjoboptions.xul",
|
||||
pressedOK);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet);
|
||||
NS_IMETHOD Init(nsIPrintSettings* aPS);
|
||||
NS_IMETHOD ClosePrintManager();
|
||||
|
||||
NS_IMETHOD GetToPrinter(PRBool &aToPrinter);
|
||||
|
|
|
@ -35,7 +35,6 @@ REQUIRES = xpcom \
|
|||
widget \
|
||||
view \
|
||||
util \
|
||||
dom \
|
||||
pref \
|
||||
js \
|
||||
uconv \
|
||||
|
@ -43,7 +42,6 @@ REQUIRES = xpcom \
|
|||
unicharutil \
|
||||
gfx2 \
|
||||
mozcomps \
|
||||
windowwatcher \
|
||||
content \
|
||||
layout \
|
||||
locale \
|
||||
|
@ -68,6 +66,7 @@ CPPSRCS = \
|
|||
nsScreenMac.cpp \
|
||||
nsScreenManagerMac.cpp \
|
||||
nsPrintOptionsX.cpp \
|
||||
nsPrintSettingsX.cpp \
|
||||
nsFontUtils.cpp \
|
||||
nsNativeThemeMac.cpp \
|
||||
$(NULL)
|
||||
|
@ -85,6 +84,7 @@ EXTRA_DSO_LDOPTS = \
|
|||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -DPM_USE_SESSION_APIS=0
|
||||
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
CFLAGS += $(TK_CFLAGS)
|
||||
|
|
|
@ -707,7 +707,10 @@ NS_IMETHODIMP nsDeviceContextMac::GetDeviceContextFor(nsIDeviceContextSpec *aDev
|
|||
* See documentation in nsIDeviceContext.h
|
||||
* @update 12/9/98 dwc
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextMac::BeginDocument(PRUnichar * aTitle)
|
||||
NS_IMETHODIMP nsDeviceContextMac::BeginDocument(PRUnichar * aTitle,
|
||||
PRUnichar* aPrintToFileName,
|
||||
PRInt32 aStartPage,
|
||||
PRInt32 aEndPage)
|
||||
{
|
||||
#if !TARGET_CARBON
|
||||
GrafPtr thePort;
|
||||
|
@ -724,7 +727,7 @@ GrafPtr thePort;
|
|||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIPrintingContext> printingContext = do_QueryInterface(mSpec);
|
||||
if (printingContext)
|
||||
rv = printingContext->BeginDocument();
|
||||
rv = printingContext->BeginDocument(aStartPage, aEndPage);
|
||||
return rv;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -79,7 +79,10 @@ public:
|
|||
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
|
||||
nsIDeviceContext *&aContext);
|
||||
|
||||
NS_IMETHOD BeginDocument(PRUnichar * aTitle);
|
||||
NS_IMETHOD BeginDocument(PRUnichar * aTitle,
|
||||
PRUnichar* aPrintToFileName,
|
||||
PRInt32 aStartPage,
|
||||
PRInt32 aEndPage);
|
||||
NS_IMETHOD EndDocument(void);
|
||||
NS_IMETHOD AbortDocument(void);
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryMac :: Init(void)
|
|||
NS_IMETHODIMP nsDeviceContextSpecFactoryMac :: CreateDeviceContextSpec(nsIWidget *aWidget,
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet)
|
||||
PRBool aIsPrintPreview)
|
||||
{
|
||||
|
||||
nsresult rv;
|
||||
|
@ -91,7 +91,7 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryMac :: CreateDeviceContextSpec(nsIWidget
|
|||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIPrintingContext> printingContext = do_QueryInterface(devSpec,&rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = printingContext->Init(aPrintSettings,aQuiet);
|
||||
rv = printingContext->Init(aPrintSettings,aIsPrintPreview);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
aNewSpec = devSpec;
|
||||
NS_ADDREF(aNewSpec);
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget,
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet);
|
||||
PRBool aIsPrintPreview);
|
||||
|
||||
protected:
|
||||
~nsDeviceContextSpecFactoryMac();
|
||||
|
|
|
@ -37,59 +37,10 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsDeviceContextSpecMac.h"
|
||||
#include "prmem.h"
|
||||
#include "plstr.h"
|
||||
#include "nsWatchTask.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIPrintOptions.h"
|
||||
#include "nsGfxCIID.h"
|
||||
#include "nsIPrintSettingsMac.h"
|
||||
|
||||
#include "nsGfxUtils.h"
|
||||
|
||||
#if !TARGET_CARBON
|
||||
#include "nsMacResources.h"
|
||||
#include <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
|
||||
|
@ -100,7 +51,6 @@ nsDeviceContextSpecMac::nsDeviceContextSpecMac()
|
|||
, mPrintManagerOpen(PR_FALSE)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
gPrintSettings = nsnull;
|
||||
}
|
||||
|
||||
/** -------------------------------------------------------
|
||||
|
@ -115,321 +65,36 @@ nsDeviceContextSpecMac::~nsDeviceContextSpecMac()
|
|||
::DisposeHandle((Handle)mPrtRec);
|
||||
mPrtRec = nsnull;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsDeviceContextSpecMac, nsIDeviceContextSpec, nsIPrintingContext)
|
||||
|
||||
#if !TARGET_CARBON
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* this is a drawing procedure for the user item.. this draws a box around the frameset radio buttons
|
||||
* @update dc 12/02/98
|
||||
*/
|
||||
static pascal void MyBBoxDraw(WindowPtr theWindow, short aItemNo)
|
||||
{
|
||||
short itemType;
|
||||
Rect itemBox;
|
||||
Handle itemH;
|
||||
|
||||
::GetDialogItem((DialogPtr)gPrtJobDialog, prFirstItem + eDrawFrameID-1, &itemType, &itemH, &itemBox);
|
||||
|
||||
// use appearance if possible
|
||||
if ((long)DrawThemeSecondaryGroup != kUnresolvedCFragSymbolAddress)
|
||||
::DrawThemeSecondaryGroup(&itemBox, kThemeStateActive);
|
||||
else
|
||||
::FrameRect(&itemBox);
|
||||
}
|
||||
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* this is the dialog hook, takes care of setting the dialog items
|
||||
* @update dc 12/02/98
|
||||
*/
|
||||
static pascal void MyJobItems(DialogPtr aDialog, short aItemNo)
|
||||
{
|
||||
short myItem, firstItem, i, itemType;
|
||||
short value;
|
||||
Rect itemBox;
|
||||
Handle itemH;
|
||||
|
||||
firstItem = prFirstItem;
|
||||
|
||||
myItem = aItemNo-firstItem+1;
|
||||
if (myItem>0) {
|
||||
switch (myItem) {
|
||||
case ePrintSelectionCheckboxID:
|
||||
::GetDialogItem(aDialog, firstItem, &itemType, &itemH, &itemBox);
|
||||
gPrintSelection = !gPrintSelection;
|
||||
::SetControlValue((ControlHandle)itemH, gPrintSelection);
|
||||
break;
|
||||
|
||||
case ePrintFrameAsIsCheckboxID:
|
||||
case ePrintSelectedFrameCheckboxID:
|
||||
case ePrintAllFramesCheckboxID:
|
||||
for (i=ePrintFrameAsIsCheckboxID; i<=ePrintAllFramesCheckboxID; i++){
|
||||
::GetDialogItem(aDialog, firstItem+i-1, &itemType, &itemH, &itemBox);
|
||||
::SetControlValue((ControlHandle)itemH, i==myItem);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// chain to standard Item handler
|
||||
CallPItemProc(prPItemProc, aDialog, aItemNo);
|
||||
|
||||
if (((TPPrDlg)aDialog)->fDone)
|
||||
{
|
||||
//nsCOMPtr<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 aQuiet)
|
||||
NS_IMETHODIMP nsDeviceContextSpecMac::Init(nsIPrintSettings* aPS, PRBool aIsPrintPreview)
|
||||
{
|
||||
gPrintSettings = aPS;
|
||||
|
||||
#if !TARGET_CARBON
|
||||
|
||||
if (aQuiet)
|
||||
{
|
||||
// If aQuiet is true, then we're being called through
|
||||
// the print preview path, so don't put up the print dialog.
|
||||
return NS_ERROR_ABORT;
|
||||
nsCOMPtr<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;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
mPrintManagerOpen = PR_TRUE;
|
||||
|
||||
// Allocate a print record
|
||||
hPrintRec = (THPrint)::NewHandleClear(sizeof(TPrint));
|
||||
if (!hPrintRec) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
StHandleOwner printRecOwner((Handle)hPrintRec);
|
||||
|
||||
// see if we have a print record
|
||||
void* printRecordData = nsnull;
|
||||
rv = printOptionsService->GetNativeData(nsIPrintOptions::kNativeDataPrintRecord, &printRecordData);
|
||||
if (NS_SUCCEEDED(rv) && printRecordData)
|
||||
{
|
||||
::BlockMoveData(printRecordData, *hPrintRec, sizeof(TPrint));
|
||||
}
|
||||
else
|
||||
{
|
||||
// fill in default values
|
||||
::PrintDefault(hPrintRec);
|
||||
}
|
||||
|
||||
if (printRecordData)
|
||||
{
|
||||
nsMemory::Free(printRecordData);
|
||||
printRecordData = nsnull;
|
||||
}
|
||||
|
||||
nsresult rv = printSettingsMac->GetTHPrint(&mPrtRec);
|
||||
|
||||
// make sure the print record is valid
|
||||
::PrValidate(hPrintRec);
|
||||
::PrValidate(mPrtRec);
|
||||
if (::PrError() != noErr)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// get pointer to invisible job dialog box
|
||||
gPrtJobDialog = ::PrJobInit(hPrintRec);
|
||||
if (::PrError() != noErr)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// create a UUP for the dialog init procedure
|
||||
theInitProcPtr = NewPDlgInitProc(MyJobDlgInit);
|
||||
if (!theInitProcPtr)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// standard print dialog, if true print
|
||||
nsWatchTask::GetTask().Suspend();
|
||||
::InitCursor();
|
||||
|
||||
// put up the print dialog
|
||||
if (::PrDlgMain(hPrintRec, theInitProcPtr))
|
||||
{
|
||||
// have the print record
|
||||
rv = NS_OK;
|
||||
printRecOwner.ClearHandle(false);
|
||||
mPrtRec = hPrintRec;
|
||||
}
|
||||
else
|
||||
{
|
||||
// don't print
|
||||
::SetPort(oldport);
|
||||
rv = NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
// clean up our dialog routines
|
||||
DisposePItemUPP(gPrtJobDialogItemProc);
|
||||
gPrtJobDialogItemProc = nsnull;
|
||||
|
||||
DisposePItemUPP(theInitProcPtr);
|
||||
DisposePItemUPP(gDrawListUPP);
|
||||
gDrawListUPP = nsnull;
|
||||
|
||||
nsWatchTask::GetTask().Resume();
|
||||
return rv;
|
||||
|
||||
#endif /* TARGET_CARBON */
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** -------------------------------------------------------
|
||||
|
@ -438,18 +103,14 @@ NS_IMETHODIMP nsDeviceContextSpecMac::Init(nsIPrintSettings* aPS, PRBool aQuiet)
|
|||
*/
|
||||
NS_IMETHODIMP nsDeviceContextSpecMac::ClosePrintManager()
|
||||
{
|
||||
PRBool isPMOpen;
|
||||
PrintManagerOpen(&isPMOpen);
|
||||
if (isPMOpen) {
|
||||
#if !TARGET_CARBON
|
||||
if (mPrintManagerOpen)
|
||||
::PrClose();
|
||||
#endif
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecMac::BeginDocument()
|
||||
NS_IMETHODIMP nsDeviceContextSpecMac::BeginDocument(PRInt32 aStartPage,
|
||||
PRInt32 aEndPage)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
return rv;
|
||||
|
|
|
@ -58,14 +58,10 @@ public:
|
|||
/**
|
||||
* Initialize the nsDeviceContextSpecMac for use. This will allocate a printrecord for use
|
||||
* @update dc 12/02/98
|
||||
* @param aQuiet if PR_TRUE, prevent the need for user intervention
|
||||
* in obtaining device context spec. if nsnull is passed in for
|
||||
* the aOldSpec, this will typically result in getting a device
|
||||
* context spec for the default output device (i.e. default
|
||||
* printer).
|
||||
* @param aIsPrintPreview TRUE if doing print preview, FALSE if normal printing.
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet);
|
||||
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aIsPrintPreview);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -83,7 +79,8 @@ public:
|
|||
*/
|
||||
NS_IMETHOD ClosePrintManager();
|
||||
|
||||
NS_IMETHOD BeginDocument();
|
||||
NS_IMETHOD BeginDocument(PRInt32 aStartPage,
|
||||
PRInt32 aEndPage);
|
||||
|
||||
NS_IMETHOD EndDocument();
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
* 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
|
||||
|
@ -46,18 +47,7 @@
|
|||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIPrintOptions.h"
|
||||
|
||||
|
||||
#include "CoreServices.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsPDECommon.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsDirectoryService.h"
|
||||
|
||||
static Boolean LoadPrinterPlugin();
|
||||
|
||||
static Boolean gPlugInNotLoaded = true;
|
||||
#include "nsIPrintSettingsX.h"
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* Construct the nsDeviceContextSpecX
|
||||
|
@ -88,130 +78,29 @@ NS_IMPL_ISUPPORTS2(nsDeviceContextSpecX, nsIDeviceContextSpec, nsIPrintingContex
|
|||
* Initialize the nsDeviceContextSpecMac
|
||||
* @update dc 12/02/98
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextSpecX::Init(nsIPrintSettings* aPS, PRBool aQuiet)
|
||||
NS_IMETHODIMP nsDeviceContextSpecX::Init(nsIPrintSettings* aPS, PRBool aIsPrintPreview)
|
||||
{
|
||||
nsresult rv;
|
||||
OSStatus status;
|
||||
|
||||
nsCOMPtr<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;
|
||||
|
||||
PMPageFormat optionsPageFormat = kPMNoPageFormat;
|
||||
rv = printOptionsService->GetNativeData(nsIPrintOptions::kNativeDataPrintRecord, (void **)&optionsPageFormat);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
status = ::PMNewPageFormat(&mPageFormat);
|
||||
if (status != noErr) return NS_ERROR_FAILURE;
|
||||
|
||||
if (optionsPageFormat != kPMNoPageFormat)
|
||||
{
|
||||
status = ::PMCopyPageFormat(optionsPageFormat, mPageFormat);
|
||||
::PMDisposePageFormat(optionsPageFormat);
|
||||
}
|
||||
else
|
||||
status = ::PMDefaultPageFormat(mPageFormat);
|
||||
|
||||
if (status != noErr) return NS_ERROR_FAILURE;
|
||||
|
||||
Boolean validated;
|
||||
::PMValidatePageFormat(mPageFormat, &validated);
|
||||
|
||||
status = ::PMNewPrintSettings(&mPrintSettings);
|
||||
if (status != noErr) return NS_ERROR_FAILURE;
|
||||
|
||||
status = ::PMDefaultPrintSettings(mPrintSettings);
|
||||
if (status != noErr) return NS_ERROR_FAILURE;
|
||||
|
||||
if (! aQuiet) {
|
||||
Boolean plugInExtended,accepted=false;
|
||||
PRBool isOn;
|
||||
PRInt16 howToEnableFrameUI = nsIPrintSettings::kFrameEnableNone;
|
||||
nsPrintExtensions printData = {false,false,false,false,false,false,false,false};
|
||||
|
||||
::InitCursor();
|
||||
|
||||
// set the values for the plugin here
|
||||
aPS->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB, &isOn);
|
||||
printData.mHaveSelection = (Boolean) isOn;
|
||||
|
||||
aPS->GetHowToEnableFrameUI(&howToEnableFrameUI);
|
||||
if (howToEnableFrameUI == nsIPrintSettings::kFrameEnableAll) {
|
||||
printData.mHaveFrames = true;
|
||||
printData.mHaveFrameSelected = true;
|
||||
}
|
||||
|
||||
if (howToEnableFrameUI == nsIPrintSettings::kFrameEnableAsIsAndEach) {
|
||||
printData.mHaveFrames = true;
|
||||
printData.mHaveFrameSelected = false;
|
||||
}
|
||||
|
||||
aPS->GetShrinkToFit(&isOn);
|
||||
printData.mShrinkToFit = isOn;
|
||||
|
||||
if( gPlugInNotLoaded ) {
|
||||
plugInExtended = LoadPrinterPlugin();
|
||||
}
|
||||
|
||||
status = PMSetPrintSettingsExtendedData(mPrintSettings,kPDE_Creator,sizeof(printData),&printData);
|
||||
|
||||
status = ::PMPrintDialog(mPrintSettings, mPageFormat, &accepted);
|
||||
|
||||
if (! accepted)
|
||||
return NS_ERROR_ABORT;
|
||||
|
||||
if (!aIsPrintPreview) {
|
||||
status = ::PMBegin();
|
||||
if (status != noErr)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
||||
// get the data from the plugin
|
||||
if(status == noErr){
|
||||
UInt32 bytesNeeded;
|
||||
|
||||
status = PMGetPrintSettingsExtendedData(mPrintSettings, kPDE_Creator, &bytesNeeded, NULL);
|
||||
|
||||
if(status == noErr && bytesNeeded == sizeof(printData) ){
|
||||
status = PMGetPrintSettingsExtendedData(mPrintSettings, kPDE_Creator,&bytesNeeded, &printData);
|
||||
|
||||
// set the correct data fields
|
||||
if( printData.mPrintSelection){
|
||||
aPS->SetPrintRange(nsIPrintSettings::kRangeSelection);
|
||||
} else {
|
||||
aPS->SetPrintRange(nsIPrintSettings::kRangeAllPages);
|
||||
}
|
||||
|
||||
if(printData.mPrintFrameAsIs){
|
||||
aPS->SetPrintFrameType(nsIPrintSettings::kFramesAsIs);
|
||||
}
|
||||
|
||||
if(printData.mPrintSelectedFrame){
|
||||
aPS->SetPrintFrameType(nsIPrintSettings::kSelectedFrame);
|
||||
}
|
||||
|
||||
if(printData.mPrintFramesSeperatly){
|
||||
aPS->SetPrintFrameType(nsIPrintSettings::kEachFrameSep);
|
||||
}
|
||||
|
||||
if(printData.mShrinkToFit){
|
||||
aPS->SetShrinkToFit(PR_TRUE);
|
||||
} else {
|
||||
aPS->SetShrinkToFit(PR_FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
mBeganPrinting = PR_TRUE;
|
||||
}
|
||||
|
||||
nsCOMPtr<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;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -239,9 +128,17 @@ NS_IMETHODIMP nsDeviceContextSpecX::ClosePrintManager()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecX::BeginDocument()
|
||||
NS_IMETHODIMP nsDeviceContextSpecX::BeginDocument(PRInt32 aStartPage,
|
||||
PRInt32 aEndPage)
|
||||
{
|
||||
OSStatus status = ::PMBeginDocument(mPrintSettings, mPageFormat, &mPrintingContext);
|
||||
OSStatus status;
|
||||
|
||||
status = ::PMSetFirstPage(mPrintSettings, aStartPage, false);
|
||||
NS_ASSERTION(status == noErr, "PMSetFirstPage failed");
|
||||
status = ::PMSetLastPage(mPrintSettings, aEndPage, false);
|
||||
NS_ASSERTION(status == noErr, "PMSetLastPage failed");
|
||||
|
||||
status = ::PMBeginDocument(mPrintSettings, mPageFormat, &mPrintingContext);
|
||||
if (status != noErr) return NS_ERROR_ABORT;
|
||||
|
||||
return NS_OK;
|
||||
|
@ -303,55 +200,3 @@ NS_IMETHODIMP nsDeviceContextSpecX::GetPageRect(double* aTop, double* aLeft, dou
|
|||
*aBottom = pageRect.bottom, *aRight = pageRect.right;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Boolean
|
||||
LoadPrinterPlugin()
|
||||
{
|
||||
Boolean result=false;
|
||||
FSSpec spec;
|
||||
|
||||
#ifndef XP_MACOSX
|
||||
// get the relative path for the essential files folder.. then load the printer plugin
|
||||
nsCOMPtr<nsILocalFile> mozFile;
|
||||
nsCOMPtr<nsIProperties> directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID));
|
||||
if (!directoryService) {
|
||||
return false;
|
||||
} else {
|
||||
directoryService->Get( NS_XPCOM_CURRENT_PROCESS_DIR,NS_GET_IID(nsIFile), getter_AddRefs(mozFile));
|
||||
if (!mozFile) {
|
||||
return false;
|
||||
}
|
||||
|
||||
mozFile->Append(NS_LITERAL_CSTRING("Essential Files"));
|
||||
mozFile->Append(NS_LITERAL_CSTRING("PrintDialogPDE.plugin"));
|
||||
nsCOMPtr<nsILocalFileMac> mozMacFile(do_QueryInterface(mozFile));
|
||||
mozMacFile->GetFSSpec(&spec);
|
||||
|
||||
|
||||
FSRef ref;
|
||||
OSErr err = FSpMakeFSRef(&spec,&ref);
|
||||
char path[512];
|
||||
|
||||
err = FSRefMakePath(&ref,(UInt8*)path,sizeof(path)-1);
|
||||
|
||||
if(err == noErr){
|
||||
CFStringRef pathRef = CFStringCreateWithCString(NULL,path,kCFStringEncodingUTF8);
|
||||
if(pathRef) {
|
||||
CFURLRef url = CFURLCreateWithFileSystemPath(NULL,pathRef,kCFURLPOSIXPathStyle,TRUE);
|
||||
if(url !=NULL){
|
||||
CFPlugInRef plugin = ::CFPlugInCreate(NULL,url);
|
||||
if(plugin){
|
||||
result = true;
|
||||
gPlugInNotLoaded = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,14 +60,10 @@ public:
|
|||
/**
|
||||
* Initialize the nsDeviceContextSpecMac for use. This will allocate a printrecord for use
|
||||
* @update dc 12/02/98
|
||||
* @param aQuiet if PR_TRUE, prevent the need for user intervention
|
||||
* in obtaining device context spec. if nsnull is passed in for
|
||||
* the aOldSpec, this will typically result in getting a device
|
||||
* context spec for the default output device (i.e. default
|
||||
* printer).
|
||||
* @param aIsPrintPreview TRUE if doing print preview, FALSE if normal printing.
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet);
|
||||
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aIsPrintPreview);
|
||||
|
||||
/**
|
||||
* This will tell if the printmanager is currently open
|
||||
|
@ -84,7 +80,8 @@ public:
|
|||
*/
|
||||
NS_IMETHOD ClosePrintManager();
|
||||
|
||||
NS_IMETHOD BeginDocument();
|
||||
NS_IMETHOD BeginDocument(PRInt32 aStartPage,
|
||||
PRInt32 aEndPage);
|
||||
|
||||
NS_IMETHOD EndDocument();
|
||||
|
||||
|
|
|
@ -36,42 +36,17 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "nsWatchTask.h"
|
||||
#include "nsPrintOptionsMac.h"
|
||||
#include "nsGfxUtils.h"
|
||||
|
||||
#include "plbase64.h"
|
||||
#include "prmem.h"
|
||||
#include "nsPrintSettingsMac.h"
|
||||
|
||||
#define MAC_OS_PAGE_SETUP_PREFNAME "print.macos.pagesetup"
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsPrintOptionsWin.h
|
||||
* See documentation in nsPrintOptionsMac.h
|
||||
* @update 6/21/00 dwc
|
||||
*/
|
||||
nsPrintOptionsMac::nsPrintOptionsMac()
|
||||
{
|
||||
// create the print style and print record
|
||||
mPrintRecord = (THPrint)::NewHandleClear(sizeof(TPrint));
|
||||
if (mPrintRecord)
|
||||
{
|
||||
nsresult rv = ReadPageSetupFromPrefs();
|
||||
::PrOpen();
|
||||
if (::PrError() == noErr)
|
||||
{
|
||||
if (NS_FAILED(rv))
|
||||
::PrintDefault(mPrintRecord);
|
||||
else
|
||||
::PrValidate(mPrintRecord);
|
||||
|
||||
::PrClose();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
|
@ -80,10 +55,23 @@ nsPrintOptionsMac::nsPrintOptionsMac()
|
|||
*/
|
||||
nsPrintOptionsMac::~nsPrintOptionsMac()
|
||||
{
|
||||
// get rid of the print record
|
||||
if (mPrintRecord) {
|
||||
::DisposeHandle((Handle)mPrintRecord);
|
||||
}
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsPrintOptionsImpl.h
|
||||
*/
|
||||
/* nsIPrintSettings CreatePrintSettings (); */
|
||||
NS_IMETHODIMP nsPrintOptionsMac::CreatePrintSettings(nsIPrintSettings **_retval)
|
||||
{
|
||||
nsresult rv;
|
||||
nsPrintSettingsMac* printSettings = new nsPrintSettingsMac(); // does not initially ref count
|
||||
if (!printSettings)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = printSettings->Init();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return printSettings->QueryInterface(NS_GET_IID(nsIPrintSettings), (void**)_retval); // ref counts
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
|
@ -93,121 +81,51 @@ nsPrintOptionsMac::~nsPrintOptionsMac()
|
|||
NS_IMETHODIMP
|
||||
nsPrintOptionsMac::ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings)
|
||||
{
|
||||
|
||||
if (!mPrintRecord) return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// it doesn't really matter if this fails
|
||||
nsresult rv = ReadPageSetupFromPrefs();
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to write page setup to prefs");
|
||||
|
||||
// open the printing manager
|
||||
::PrOpen();
|
||||
if(::PrError() != noErr)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
::PrValidate(mPrintRecord);
|
||||
NS_ASSERTION(::PrError() == noErr, "Printing error");
|
||||
|
||||
nsWatchTask::GetTask().Suspend();
|
||||
::InitCursor();
|
||||
Boolean dialogOK = ::PrStlDialog(mPrintRecord); // open up and process the style record
|
||||
nsWatchTask::GetTask().Resume();
|
||||
|
||||
OSErr err = ::PrError();
|
||||
|
||||
::PrClose();
|
||||
|
||||
// it doesn't really matter if this fails
|
||||
rv = WritePageSetupToPrefs();
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to save page setup to prefs");
|
||||
|
||||
if (err != noErr)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* [noscript] voidPtr GetNativeData (in short aDataType); */
|
||||
NS_IMETHODIMP
|
||||
nsPrintOptionsMac::GetNativeData(PRInt16 aDataType, void * *_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = nsnull;
|
||||
|
||||
switch (aDataType)
|
||||
{
|
||||
case kNativeDataPrintRecord:
|
||||
if (mPrintRecord)
|
||||
{
|
||||
void* printRecord = nsMemory::Alloc(sizeof(TPrint));
|
||||
if (!printRecord) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
break;
|
||||
}
|
||||
|
||||
::BlockMoveData(*mPrintRecord, printRecord, sizeof(TPrint));
|
||||
*_retval = printRecord;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
rv = NS_ERROR_FAILURE;
|
||||
break;
|
||||
}
|
||||
|
||||
return rv;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
nsresult
|
||||
nsPrintOptionsMac::ReadPageSetupFromPrefs()
|
||||
nsPrintOptionsMac::ReadPrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPrintOptionsMac::WritePageSetupToPrefs()
|
||||
nsPrintOptionsMac::WritePrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags)
|
||||
{
|
||||
if (!mPrintRecord)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsresult rv;
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,19 +39,13 @@ public:
|
|||
virtual ~nsPrintOptionsMac();
|
||||
|
||||
NS_IMETHOD ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings);
|
||||
|
||||
NS_IMETHOD GetNativeData(PRInt16 aDataType, void * *_retval);
|
||||
|
||||
NS_IMETHOD CreatePrintSettings(nsIPrintSettings **_retval);
|
||||
protected:
|
||||
|
||||
nsresult ReadPageSetupFromPrefs();
|
||||
nsresult WritePageSetupToPrefs();
|
||||
|
||||
THPrint GetPrintRecord(void) { return mPrintRecord; }
|
||||
|
||||
protected:
|
||||
|
||||
THPrint mPrintRecord;
|
||||
|
||||
nsresult ReadPrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags);
|
||||
nsresult WritePrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags);
|
||||
};
|
||||
|
||||
#endif /* TARGET_CARBON */
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "nsIServiceManager.h"
|
||||
#include "nsWatchTask.h"
|
||||
#include "nsPrintOptionsX.h"
|
||||
#include "nsPrintSettingsX.h"
|
||||
#include "nsIPref.h"
|
||||
|
||||
#include "nsGfxUtils.h"
|
||||
|
@ -50,37 +51,32 @@
|
|||
#include "prmem.h"
|
||||
|
||||
|
||||
#define MAC_OS_X_PAGE_SETUP_PREFNAME "print.macosx.pagesetup"
|
||||
|
||||
/** ---------------------------------------------------
|
||||
*/
|
||||
nsPrintOptionsX::nsPrintOptionsX()
|
||||
: mPageFormat(kPMNoPageFormat)
|
||||
{
|
||||
OSStatus status = ::PMNewPageFormat(&mPageFormat);
|
||||
NS_ASSERTION(status == noErr, "Error creating print settings");
|
||||
|
||||
status = ::PMBegin();
|
||||
NS_ASSERTION(status == noErr, "Error from PMBegin()");
|
||||
|
||||
nsresult rv = ReadPageSetupFromPrefs();
|
||||
if (NS_FAILED(rv))
|
||||
::PMDefaultPageFormat(mPageFormat);
|
||||
else
|
||||
{
|
||||
Boolean valid;
|
||||
::PMValidatePageFormat(mPageFormat, &valid);
|
||||
}
|
||||
|
||||
::PMEnd();
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
*/
|
||||
nsPrintOptionsX::~nsPrintOptionsX()
|
||||
{
|
||||
if (mPageFormat)
|
||||
::PMDisposePageFormat(mPageFormat);
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsPrintOptionsImpl.h
|
||||
*/
|
||||
/* nsIPrintSettings CreatePrintSettings (); */
|
||||
NS_IMETHODIMP nsPrintOptionsX::CreatePrintSettings(nsIPrintSettings **_retval)
|
||||
{
|
||||
nsresult rv;
|
||||
nsPrintSettingsX* printSettings = new nsPrintSettingsX; // does not initially ref count
|
||||
if (!printSettings)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = printSettings->Init();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
return printSettings->QueryInterface(NS_GET_IID(nsIPrintSettings), (void**)_retval); // ref counts
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
|
@ -88,144 +84,51 @@ nsPrintOptionsX::~nsPrintOptionsX()
|
|||
NS_IMETHODIMP
|
||||
nsPrintOptionsX::ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings)
|
||||
{
|
||||
|
||||
// it doesn't really matter if this fails
|
||||
nsresult rv = ReadPageSetupFromPrefs();
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to write page setup to prefs");
|
||||
|
||||
NS_ASSERTION(mPageFormat != kPMNoPageFormat, "No page format");
|
||||
if (mPageFormat == kPMNoPageFormat)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
OSStatus status = ::PMBegin();
|
||||
if (status != noErr) return NS_ERROR_FAILURE;
|
||||
|
||||
Boolean validated;
|
||||
::PMValidatePageFormat(mPageFormat, &validated);
|
||||
|
||||
::InitCursor();
|
||||
|
||||
Boolean accepted = false;
|
||||
status = ::PMPageSetupDialog(mPageFormat, &accepted);
|
||||
|
||||
::PMEnd();
|
||||
|
||||
// it doesn't really matter if this fails
|
||||
rv = WritePageSetupToPrefs();
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to save page setup to prefs");
|
||||
|
||||
if (status != noErr)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (!accepted)
|
||||
return NS_ERROR_ABORT;
|
||||
|
||||
return NS_OK;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* [noscript] voidPtr GetNativeData (in short aDataType); */
|
||||
NS_IMETHODIMP
|
||||
nsPrintOptionsX::GetNativeData(PRInt16 aDataType, void * *_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = nsnull;
|
||||
|
||||
switch (aDataType)
|
||||
{
|
||||
case kNativeDataPrintRecord:
|
||||
{
|
||||
// we need to clone and pass out
|
||||
PMPageFormat pageFormat = kPMNoPageFormat;
|
||||
OSStatus status = ::PMNewPageFormat(&pageFormat);
|
||||
if (status != noErr) return NS_ERROR_FAILURE;
|
||||
|
||||
status = ::PMCopyPageFormat(mPageFormat, pageFormat);
|
||||
if (status != noErr) {
|
||||
::PMDisposePageFormat(pageFormat);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
*_retval = pageFormat;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
rv = NS_ERROR_FAILURE;
|
||||
break;
|
||||
}
|
||||
|
||||
return rv;
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
|
||||
nsresult
|
||||
nsPrintOptionsX::ReadPageSetupFromPrefs()
|
||||
nsPrintOptionsX::ReadPrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPrintOptionsX::WritePageSetupToPrefs()
|
||||
nsPrintOptionsX::WritePrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags)
|
||||
{
|
||||
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);
|
||||
|
||||
nsXPIDLCString encodedData;
|
||||
encodedData.Adopt(::PL_Base64Encode(*pageFormatHandle, ::GetHandleSize(pageFormatHandle), nsnull));
|
||||
if (!encodedData.get())
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return prefs->SetCharPref(MAC_OS_X_PAGE_SETUP_PREFNAME, encodedData);
|
||||
rv = nsPrintOptions::WritePrefs(aPS, aPrefName, aFlags);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::WritePrefs() failed");
|
||||
|
||||
nsCOMPtr<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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -39,10 +39,7 @@
|
|||
#ifndef nsPrintOptionsX_h__
|
||||
#define nsPrintOptionsX_h__
|
||||
|
||||
#include <PMDefinitions.h>
|
||||
|
||||
#include "nsPrintOptionsImpl.h"
|
||||
|
||||
#include "nsPrintOptionsImpl.h"
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
|
@ -59,15 +56,12 @@ public:
|
|||
|
||||
NS_IMETHOD GetNativeData(PRInt16 aDataType, void * *_retval);
|
||||
|
||||
NS_IMETHOD CreatePrintSettings(nsIPrintSettings **_retval);
|
||||
|
||||
protected:
|
||||
|
||||
nsresult ReadPageSetupFromPrefs();
|
||||
nsresult WritePageSetupToPrefs();
|
||||
|
||||
protected:
|
||||
|
||||
PMPageFormat mPageFormat; // persist this between runs
|
||||
|
||||
nsresult ReadPrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags);
|
||||
nsresult WritePrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -112,9 +112,7 @@ nsFont* nsPrintOptions::sDefaultFont = nsnull;
|
|||
* See documentation in nsPrintOptionsImpl.h
|
||||
* @update 6/21/00 dwc
|
||||
*/
|
||||
nsPrintOptions::nsPrintOptions() :
|
||||
mIsCancelled(PR_FALSE),
|
||||
mPrintToFile(PR_FALSE)
|
||||
nsPrintOptions::nsPrintOptions()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
|
||||
|
@ -354,8 +352,11 @@ static void GetAdjustedPrinterName(nsIPrintSettings* aPS, PRBool aUsePNP, nsStri
|
|||
if (prtName) {
|
||||
aPrinterName = prtName;
|
||||
PRUnichar uc = '_';
|
||||
PRUnichar space = ' ';
|
||||
aPrinterName.ReplaceChar(space, uc);
|
||||
const char* replaceStr = " \n\r";
|
||||
for (PRInt32 i=0;i<(PRInt32)strlen(replaceStr);i++) {
|
||||
PRUnichar uChar = replaceStr[i];
|
||||
aPrinterName.ReplaceChar(uChar, uc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -899,79 +900,6 @@ NS_IMETHODIMP nsPrintOptions::DisplayJobProperties( const PRUnichar *aPrinter, n
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute long isCancelled; */
|
||||
NS_IMETHODIMP nsPrintOptions::GetIsCancelled(PRBool *aIsCancelled)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aIsCancelled);
|
||||
*aIsCancelled = mIsCancelled;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsPrintOptions::SetIsCancelled(PRBool aIsCancelled)
|
||||
{
|
||||
mIsCancelled = aIsCancelled;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute boolean printToFile; */
|
||||
NS_IMETHODIMP nsPrintOptions::GetPrintToFile(PRBool *aPrintToFile)
|
||||
{
|
||||
//NS_ENSURE_ARG_POINTER(aPrintToFile);
|
||||
*aPrintToFile = mPrintToFile;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsPrintOptions::SetPrintToFile(PRBool aPrintToFile)
|
||||
{
|
||||
mPrintToFile = aPrintToFile;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute wstring toFileName; */
|
||||
NS_IMETHODIMP nsPrintOptions::GetToFileName(PRUnichar * *aToFileName)
|
||||
{
|
||||
//NS_ENSURE_ARG_POINTER(aToFileName);
|
||||
*aToFileName = ToNewUnicode(mToFileName);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsPrintOptions::SetToFileName(const PRUnichar * aToFileName)
|
||||
{
|
||||
mToFileName = aToFileName;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute wstring docTitle; */
|
||||
NS_IMETHODIMP nsPrintOptions::GetTitle(PRUnichar * *aTitle)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aTitle);
|
||||
*aTitle = ToNewUnicode(mTitle);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsPrintOptions::SetTitle(const PRUnichar * aTitle)
|
||||
{
|
||||
if (aTitle) {
|
||||
mTitle = aTitle;
|
||||
} else {
|
||||
mTitle.SetLength(0);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute wstring docURL; */
|
||||
NS_IMETHODIMP nsPrintOptions::GetDocURL(PRUnichar * *aDocURL)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDocURL);
|
||||
*aDocURL = ToNewUnicode(mURL);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsPrintOptions::SetDocURL(const PRUnichar * aDocURL)
|
||||
{
|
||||
if (aDocURL) {
|
||||
mURL = aDocURL;
|
||||
} else {
|
||||
mURL.SetLength(0);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* [noscript] voidPtr GetNativeData (in short aDataType); */
|
||||
NS_IMETHODIMP nsPrintOptions::GetNativeData(PRInt16 aDataType, void * *_retval)
|
||||
{
|
||||
|
|
|
@ -54,18 +54,12 @@ protected:
|
|||
nsresult ReadPrefDouble(nsIPref * aPref, const char * aPrefId, double& aVal);
|
||||
nsresult WritePrefDouble(nsIPref * aPref, const char * aPrefId, double aVal);
|
||||
|
||||
nsresult ReadPrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags);
|
||||
nsresult WritePrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags);
|
||||
virtual nsresult ReadPrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags);
|
||||
virtual nsresult WritePrefs(nsIPrintSettings* aPS, const nsString& aPrefName, PRUint32 aFlags);
|
||||
const char* GetPrefName(const char * aPrefName,
|
||||
const nsString& aPrinterName);
|
||||
|
||||
// Members
|
||||
PRBool mIsCancelled;
|
||||
nsString mTitle;
|
||||
nsString mURL;
|
||||
PRBool mPrintToFile;
|
||||
nsString mToFileName;
|
||||
|
||||
nsCOMPtr<nsIPrintSettings> mGlobalPrintSettings;
|
||||
|
||||
nsCString mPrefName;
|
||||
|
|
|
@ -37,10 +37,8 @@ REQUIRES = xpcom \
|
|||
widget \
|
||||
view \
|
||||
util \
|
||||
dom \
|
||||
pref \
|
||||
uconv \
|
||||
windowwatcher \
|
||||
locale \
|
||||
unicharutil \
|
||||
$(NULL)
|
||||
|
|
|
@ -884,7 +884,7 @@ nsresult nsDeviceContextOS2::CreateFontAliasTable()
|
|||
}
|
||||
|
||||
// Printing ------------------------------------------------------------------
|
||||
nsresult nsDeviceContextOS2::BeginDocument(PRUnichar * aTitle)
|
||||
nsresult nsDeviceContextOS2::PrepareDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
|
@ -915,6 +915,12 @@ nsresult nsDeviceContextOS2::BeginDocument(PRUnichar * aTitle)
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsDeviceContextOS2::BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage)
|
||||
{
|
||||
// Everything is done in PrepareDocument
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsDeviceContextOS2::EndDocument()
|
||||
{
|
||||
if (NULL != mPrintDC)
|
||||
|
|
|
@ -86,7 +86,9 @@ public:
|
|||
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
|
||||
nsIDeviceContext *&aContext);
|
||||
|
||||
NS_IMETHOD BeginDocument(PRUnichar * aTitle);
|
||||
NS_IMETHOD PrepareDocument(PRUnichar * aTitle,
|
||||
PRUnichar* aPrintToFileName);
|
||||
NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage);
|
||||
NS_IMETHOD EndDocument(void);
|
||||
NS_IMETHOD AbortDocument(void);
|
||||
|
||||
|
|
|
@ -63,14 +63,14 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryOS2 :: Init(void)
|
|||
NS_IMETHODIMP nsDeviceContextSpecFactoryOS2 :: CreateDeviceContextSpec(nsIWidget *aWidget,
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet)
|
||||
PRBool aIsPrintPreview)
|
||||
{
|
||||
nsresult rv;
|
||||
static NS_DEFINE_CID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
|
||||
nsCOMPtr<nsIDeviceContextSpec> devSpec = do_CreateInstance(kDeviceContextSpecCID, &rv);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = ((nsDeviceContextSpecOS2 *)devSpec.get())->Init(aPrintSettings, aQuiet);
|
||||
rv = ((nsDeviceContextSpecOS2 *)devSpec.get())->Init(aPrintSettings, aIsPrintPreview);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
aNewSpec = devSpec;
|
||||
NS_ADDREF(aNewSpec);
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget,
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet);
|
||||
PRBool aIsPrintPreview);
|
||||
|
||||
protected:
|
||||
~nsDeviceContextSpecFactoryOS2();
|
||||
|
|
|
@ -28,12 +28,7 @@
|
|||
#include "nsIPref.h"
|
||||
#include "prenv.h" /* for PR_GetEnv */
|
||||
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDialogParamBlock.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
|
||||
PRINTDLG nsDeviceContextSpecOS2::PrnDlg;
|
||||
|
@ -259,13 +254,13 @@ NS_IMPL_RELEASE(nsDeviceContextSpecOS2)
|
|||
* toolkits including:
|
||||
* - GTK+-toolkit:
|
||||
* file: mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp
|
||||
* function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init(PRBool aQuiet)
|
||||
* function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init(PRBool aPrintPreview )
|
||||
* - Xlib-toolkit:
|
||||
* file: mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp
|
||||
* function: NS_IMETHODIMP nsDeviceContextSpecXlib::Init(PRBool aQuiet)
|
||||
* function: NS_IMETHODIMP nsDeviceContextSpecXlib::Init(PRBool aPrintPreview )
|
||||
* - Qt-toolkit:
|
||||
* file: mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp
|
||||
* function: NS_IMETHODIMP nsDeviceContextSpecQT::Init(PRBool aQuiet)
|
||||
* function: NS_IMETHODIMP nsDeviceContextSpecQT::Init(PRBool aPrintPreview )
|
||||
*
|
||||
* ** Please update the other toolkits when changing this function.
|
||||
*/
|
||||
|
@ -276,129 +271,57 @@ NS_IMETHODIMP nsDeviceContextSpecOS2::Init(nsIPrintSettings* aPS, PRBool aQuiet)
|
|||
mPrintSettings = aPS;
|
||||
NS_ASSERTION(aPS, "Must have a PrintSettings!");
|
||||
|
||||
// if there is a current selection then enable the "Selection" radio button
|
||||
if (aPS != nsnull) {
|
||||
PRBool isOn;
|
||||
aPS->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB, &isOn);
|
||||
nsCOMPtr<nsIPref> pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
(void) pPrefs->SetBoolPref("print.selection_radio_enabled", isOn);
|
||||
}
|
||||
}
|
||||
|
||||
PRBool canPrint = PR_FALSE;
|
||||
|
||||
rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if ( !aQuiet ) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
// create a nsISupportsArray of the parameters
|
||||
// being passed to the window
|
||||
nsCOMPtr<nsISupportsArray> array;
|
||||
NS_NewISupportsArray(getter_AddRefs(array));
|
||||
if (!array) return NS_ERROR_FAILURE;
|
||||
if (aPS) {
|
||||
PRBool tofile = PR_FALSE;
|
||||
PRInt32 copies = 1;
|
||||
PRUnichar *printer = nsnull;
|
||||
PRUnichar *printfile = nsnull;
|
||||
|
||||
nsCOMPtr<nsIPrintSettings> ps = aPS;
|
||||
nsCOMPtr<nsISupports> psSupports(do_QueryInterface(ps));
|
||||
NS_ASSERTION(psSupports, "PrintSettings must be a supports");
|
||||
array->AppendElement(psSupports);
|
||||
mPrintSettings->GetPrinterName(&printer);
|
||||
mPrintSettings->GetToFileName(&printfile);
|
||||
mPrintSettings->GetPrintToFile(&tofile);
|
||||
mPrintSettings->GetNumCopies(&copies);
|
||||
|
||||
nsCOMPtr<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 ((copies == 0) || (copies > 999)) {
|
||||
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PRInt32 buttonPressed = 0;
|
||||
ioParamBlock->GetInt(0, &buttonPressed);
|
||||
if (buttonPressed == 1)
|
||||
canPrint = PR_TRUE;
|
||||
else
|
||||
{
|
||||
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
} else
|
||||
return NS_ERROR_ABORT;
|
||||
} else {
|
||||
canPrint = PR_TRUE;
|
||||
}
|
||||
|
||||
if (canPrint) {
|
||||
if (aPS) {
|
||||
PRBool tofile = PR_FALSE;
|
||||
PRInt16 printRange = nsIPrintSettings::kRangeAllPages;
|
||||
PRInt32 fromPage = 1;
|
||||
PRInt32 toPage = 1;
|
||||
PRInt32 copies = 1;
|
||||
PRUnichar *printer = nsnull;
|
||||
PRUnichar *printfile = nsnull;
|
||||
|
||||
mPrintSettings->GetPrinterName(&printer);
|
||||
mPrintSettings->GetPrintRange(&printRange);
|
||||
mPrintSettings->GetToFileName(&printfile);
|
||||
mPrintSettings->GetPrintToFile(&tofile);
|
||||
mPrintSettings->GetStartPageRange(&fromPage);
|
||||
mPrintSettings->GetEndPageRange(&toPage);
|
||||
mPrintSettings->GetNumCopies(&copies);
|
||||
|
||||
if ((copies == 0) || (copies > 999)) {
|
||||
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (printfile != nsnull) {
|
||||
// ToDo: Use LocalEncoding instead of UTF-8 (see bug 73446)
|
||||
strcpy(mPrData.path, NS_ConvertUCS2toUTF8(printfile).get());
|
||||
}
|
||||
if (printer != nsnull)
|
||||
strcpy(mPrData.printer, NS_ConvertUCS2toUTF8(printer).get());
|
||||
|
||||
mPrData.toPrinter = !tofile;
|
||||
mPrData.copies = copies;
|
||||
|
||||
rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
const nsAFlatString& printerUCS2 = NS_ConvertUTF8toUCS2(mPrData.printer);
|
||||
int numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters();
|
||||
if (numPrinters) {
|
||||
for(int i = 0; (i < numPrinters) && !mQueue; i++) {
|
||||
if ((GlobalPrinters::GetInstance()->GetStringAt(i)->Equals(printerUCS2, nsCaseInsensitiveStringComparator()))) {
|
||||
SetupDevModeFromSettings(i, aPS);
|
||||
mQueue = PrnDlg.SetPrinterQueue(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (printfile != nsnull)
|
||||
nsMemory::Free(printfile);
|
||||
|
||||
if (printer != nsnull)
|
||||
nsMemory::Free(printer);
|
||||
if (printfile != nsnull) {
|
||||
// ToDo: Use LocalEncoding instead of UTF-8 (see bug 73446)
|
||||
strcpy(mPrData.path, NS_ConvertUCS2toUTF8(printfile).get());
|
||||
}
|
||||
if (printer != nsnull)
|
||||
strcpy(mPrData.printer, NS_ConvertUCS2toUTF8(printer).get());
|
||||
|
||||
mPrData.toPrinter = !tofile;
|
||||
mPrData.copies = copies;
|
||||
|
||||
rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
const nsAFlatString& printerUCS2 = NS_ConvertUTF8toUCS2(mPrData.printer);
|
||||
int numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters();
|
||||
if (numPrinters) {
|
||||
for(int i = 0; (i < numPrinters) && !mQueue; i++) {
|
||||
if ((GlobalPrinters::GetInstance()->GetStringAt(i)->Equals(printerUCS2, nsCaseInsensitiveStringComparator()))) {
|
||||
SetupDevModeFromSettings(i, aPS);
|
||||
mQueue = PrnDlg.SetPrinterQueue(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (printfile != nsnull)
|
||||
nsMemory::Free(printfile);
|
||||
|
||||
if (printer != nsnull)
|
||||
nsMemory::Free(printer);
|
||||
}
|
||||
|
||||
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
|
||||
|
|
|
@ -132,14 +132,10 @@ public:
|
|||
/**
|
||||
* Initialize the nsDeviceContextSpecMac for use. This will allocate a printrecord for use
|
||||
* @update dc 2/16/98
|
||||
* @param aQuiet if PR_TRUE, prevent the need for user intervention
|
||||
* in obtaining device context spec. if nsnull is passed in for
|
||||
* the aOldSpec, this will typically result in getting a device
|
||||
* context spec for the default output device (i.e. default
|
||||
* printer).
|
||||
* @param aIsPrintPreview if PR_TRUE, creating Spec for PrintPreview
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet);
|
||||
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aIsPrintPreview);
|
||||
|
||||
NS_IMETHOD ClosePrintManager();
|
||||
|
||||
|
|
|
@ -36,11 +36,9 @@ 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 ) {
|
||||
NS_IMETHODIMP nsDeviceContextPh :: BeginDocument( PRUnichar *t, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage ) {
|
||||
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);
|
||||
NS_IMETHOD BeginDocument(PRUnichar *t, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage);
|
||||
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 aQuiet)
|
||||
PRBool aIsPrintPreview)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aWidget);
|
||||
PpPrintContext_t *pc = NULL;
|
||||
|
@ -90,8 +90,6 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryPh :: CreateDeviceContextSpec(nsIWidget
|
|||
{
|
||||
PRInt32 range = 0;
|
||||
|
||||
aQuiet = 1; /* for the embedding stuff, the PrintSelection dialog is displayed by the client */
|
||||
/* check for the page range if we are called by an embedded app, the pc is there */
|
||||
aPrintSettings->GetEndPageRange(&range);
|
||||
if (range)
|
||||
pc = (PpPrintContext_t *) range;
|
||||
|
@ -102,7 +100,7 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryPh :: CreateDeviceContextSpec(nsIWidget
|
|||
{
|
||||
specPh->SetPrintContext(pc);
|
||||
}
|
||||
rv = specPh->Init(aWidget, aPrintSettings, aQuiet);
|
||||
rv = specPh->Init(aWidget, aPrintSettings, PR_TRUE);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
aNewSpec = devSpec;
|
||||
} else {
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
NS_IMETHOD CreateDeviceContextSpec( nsIWidget *aWidget,
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet);
|
||||
PRBool aIsPrintPreview);
|
||||
|
||||
protected:
|
||||
virtual ~nsDeviceContextSpecFactoryPh();
|
||||
|
|
|
@ -42,23 +42,11 @@
|
|||
#include "plstr.h"
|
||||
#include "nsPhGfxLog.h"
|
||||
|
||||
#include "nsGfxCIID.h"
|
||||
#include "nsIPrintOptions.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIDialogParamBlock.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsSupportsArray.h"
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIPref.h"
|
||||
|
||||
static NS_DEFINE_CID( kPrintOptionsCID, NS_PRINTOPTIONS_CID );
|
||||
|
||||
nsDeviceContextSpecPh :: nsDeviceContextSpecPh()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
|
|
@ -340,7 +340,7 @@ NS_IMETHODIMP nsDeviceContextPS::GetDeviceContextFor(nsIDeviceContextSpec *aDevi
|
|||
* See documentation in nsIDeviceContext.h
|
||||
* @update 12/21/98 dwc
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextPS::BeginDocument(PRUnichar * aTitle)
|
||||
NS_IMETHODIMP nsDeviceContextPS::BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage)
|
||||
{
|
||||
PR_LOG(nsDeviceContextPSLM, PR_LOG_DEBUG, ("nsDeviceContextPS::BeginDocument()\n"));
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ public:
|
|||
|
||||
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,nsIDeviceContext *&aContext);
|
||||
NS_IMETHOD GetSystemFont(nsSystemFontID anID, nsFont *aFont) const;
|
||||
NS_IMETHOD BeginDocument(PRUnichar * aTitle);
|
||||
NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage);
|
||||
NS_IMETHOD EndDocument(void);
|
||||
NS_IMETHOD AbortDocument(void);
|
||||
NS_IMETHOD BeginPage(void);
|
||||
|
|
|
@ -37,12 +37,9 @@ REQUIRES = xpcom \
|
|||
gfx2 \
|
||||
uconv \
|
||||
pref \
|
||||
dom \
|
||||
util \
|
||||
js \
|
||||
appshell \
|
||||
mozcomps \
|
||||
windowwatcher \
|
||||
unicharutil \
|
||||
intl \
|
||||
locale \
|
||||
|
|
|
@ -376,7 +376,7 @@ nsDeviceContextQT::GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextQT::BeginDocument(PRUnichar *aTitle)
|
||||
NS_IMETHODIMP nsDeviceContextQT::BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ public:
|
|||
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
|
||||
nsIDeviceContext *&aContext);
|
||||
|
||||
NS_IMETHOD BeginDocument(PRUnichar *aTitle);
|
||||
NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage);
|
||||
NS_IMETHOD EndDocument(void);
|
||||
|
||||
NS_IMETHOD BeginPage(void);
|
||||
|
|
|
@ -99,7 +99,7 @@ NS_IMETHODIMP
|
|||
nsDeviceContextSpecFactoryQT::CreateDeviceContextSpec(nsIWidget *aWidget,
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet)
|
||||
PRBool aIsPrintPreview)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsIDeviceContextSpec *devSpec = nsnull;
|
||||
|
@ -109,7 +109,7 @@ nsDeviceContextSpecFactoryQT::CreateDeviceContextSpec(nsIWidget *aWidget,
|
|||
(void **)&devSpec);
|
||||
|
||||
if (nsnull != devSpec) {
|
||||
if (NS_OK == ((nsDeviceContextSpecQT*)devSpec)->Init(aPrintSettings, aQuiet)) {
|
||||
if (NS_OK == ((nsDeviceContextSpecQT*)devSpec)->Init(aPrintSettings)) {
|
||||
aNewSpec = devSpec;
|
||||
rv = NS_OK;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget,
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet);
|
||||
PRBool aIsPrintPreview);
|
||||
|
||||
protected:
|
||||
virtual ~nsDeviceContextSpecFactoryQT();
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John C. Griggs <johng@corel.com>
|
||||
* John C. Griggs <johng@corel.com>
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
|
@ -43,15 +43,6 @@
|
|||
#include "nsIPref.h"
|
||||
#include "prenv.h" /* for PR_GetEnv */
|
||||
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDialogParamBlock.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsISupportsArray.h"
|
||||
|
||||
#include <qapplication.h>
|
||||
|
||||
//JCG #define DBG_JCG 1
|
||||
|
@ -130,7 +121,7 @@ NS_IMETHODIMP nsDeviceContextSpecQT::QueryInterface(REFNSIID aIID,
|
|||
* @update dc 2/15/98
|
||||
* @update syd 3/2/99
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextSpecQT::Init(nsIPrintSettings* aPS, PRBool aQuiet)
|
||||
NS_IMETHODIMP nsDeviceContextSpecQT::Init(nsIPrintSettings* aPS)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
NS_ASSERTION(aPS, "Must have a PrintSettings!");
|
||||
|
@ -161,115 +152,73 @@ NS_IMETHODIMP nsDeviceContextSpecQT::Init(nsIPrintSettings* aPS, PRBool aQuiet)
|
|||
double dtop = 0.5;
|
||||
double dbottom = 0.5;
|
||||
|
||||
rv = NS_ERROR_FAILURE;
|
||||
// create a nsISupportsArray of the parameters
|
||||
// being passed to the window
|
||||
nsCOMPtr<nsISupportsArray> array;
|
||||
NS_NewISupportsArray(getter_AddRefs(array));
|
||||
if (!array) return NS_ERROR_FAILURE;
|
||||
if (aPS) {
|
||||
aPS->GetPrintReversed(&reversed);
|
||||
aPS->GetPrintInColor(&color);
|
||||
aPS->GetPaperSize(&paper_size);
|
||||
aPS->GetOrientation(&orientation);
|
||||
aPS->GetPrintCommand(&command);
|
||||
aPS->GetPrintRange(&printRange);
|
||||
aPS->GetToFileName(&printfile);
|
||||
aPS->GetPrintToFile(&tofile);
|
||||
aPS->GetStartPageRange(&fromPage);
|
||||
aPS->GetEndPageRange(&toPage);
|
||||
aPS->GetMarginTop(&dtop);
|
||||
aPS->GetMarginLeft(&dleft);
|
||||
aPS->GetMarginBottom(&dbottom);
|
||||
aPS->GetMarginRight(&dright);
|
||||
|
||||
nsCOMPtr<nsIPrintSettings> ps = aPS;
|
||||
nsCOMPtr<nsISupports> psSupports(do_QueryInterface(ps));
|
||||
NS_ASSERTION(psSupports, "PrintSettings must be a supports");
|
||||
array->AppendElement(psSupports);
|
||||
if (command != nsnull && printfile != nsnull) {
|
||||
// convert Unicode strings to cstrings
|
||||
nsAutoString cmdStr;
|
||||
nsAutoString printFileStr;
|
||||
|
||||
nsCOMPtr<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));
|
||||
cmdStr = command;
|
||||
printFileStr = printfile;
|
||||
char *pCmdStr = ToNewCString(cmdStr);
|
||||
char *pPrintFileStr = ToNewCString(printFileStr);
|
||||
sprintf(mPrData.command,pCmdStr);
|
||||
sprintf(mPrData.path,pPrintFileStr);
|
||||
nsMemory::Free(pCmdStr);
|
||||
nsMemory::Free(pPrintFileStr);
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PRInt32 buttonPressed = 0;
|
||||
ioParamBlock->GetInt(0, &buttonPressed);
|
||||
if (buttonPressed == 1) {
|
||||
if (aPS) {
|
||||
aPS->GetPrintReversed(&reversed);
|
||||
aPS->GetPrintInColor(&color);
|
||||
aPS->GetPaperSize(&paper_size);
|
||||
aPS->GetOrientation(&orientation);
|
||||
aPS->GetPrintCommand(&command);
|
||||
aPS->GetPrintRange(&printRange);
|
||||
aPS->GetToFileName(&printfile);
|
||||
aPS->GetPrintToFile(&tofile);
|
||||
aPS->GetStartPageRange(&fromPage);
|
||||
aPS->GetEndPageRange(&toPage);
|
||||
aPS->GetMarginTop(&dtop);
|
||||
aPS->GetMarginLeft(&dleft);
|
||||
aPS->GetMarginBottom(&dbottom);
|
||||
aPS->GetMarginRight(&dright);
|
||||
|
||||
if (command != nsnull && printfile != nsnull) {
|
||||
// convert Unicode strings to cstrings
|
||||
nsAutoString cmdStr;
|
||||
nsAutoString printFileStr;
|
||||
|
||||
cmdStr = command;
|
||||
printFileStr = printfile;
|
||||
char *pCmdStr = ToNewCString(cmdStr);
|
||||
char *pPrintFileStr = ToNewCString(printFileStr);
|
||||
sprintf(mPrData.command,pCmdStr);
|
||||
sprintf(mPrData.path,pPrintFileStr);
|
||||
nsMemory::Free(pCmdStr);
|
||||
nsMemory::Free(pPrintFileStr);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
#ifndef VMS
|
||||
sprintf( mPrData.command, "lpr" );
|
||||
const char* kCommandStr = "lpr";
|
||||
#else
|
||||
// Note to whoever puts the "lpr" into the prefs file. Please contact me
|
||||
// as I need to make the default be "print" instead of "lpr" for OpenVMS.
|
||||
sprintf( mPrData.command, "print" );
|
||||
// Note to whoever puts the "lpr" into the prefs file. Please contact me
|
||||
// as I need to make the default be "print" instead of "lpr" for OpenVMS.
|
||||
const char* kCommandStr = "print";
|
||||
#endif
|
||||
}
|
||||
mPrData.top = dtop;
|
||||
mPrData.bottom = dbottom;
|
||||
mPrData.left = dleft;
|
||||
mPrData.right = dright;
|
||||
mPrData.fpf = !reversed;
|
||||
mPrData.grayscale = !color;
|
||||
mPrData.size = paper_size;
|
||||
mPrData.orientation = orientation;
|
||||
mPrData.toPrinter = !tofile;
|
||||
|
||||
// PWD, HOME, or fail
|
||||
if (!printfile) {
|
||||
if ((path = PR_GetEnv("PWD")) == (char*)NULL)
|
||||
if ((path = PR_GetEnv("HOME")) == (char*)NULL)
|
||||
strcpy(mPrData.path,"mozilla.ps");
|
||||
if (path != (char*)NULL)
|
||||
sprintf(mPrData.path,"%s/mozilla.ps",path);
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (command != nsnull) {
|
||||
nsMemory::Free(command);
|
||||
}
|
||||
if (printfile != nsnull) {
|
||||
nsMemory::Free(printfile);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
sprintf( mPrData.command, kCommandStr );
|
||||
mPrData.top = dtop;
|
||||
mPrData.bottom = dbottom;
|
||||
mPrData.left = dleft;
|
||||
mPrData.right = dright;
|
||||
mPrData.fpf = !reversed;
|
||||
mPrData.grayscale = !color;
|
||||
mPrData.size = paper_size;
|
||||
mPrData.orientation = orientation;
|
||||
mPrData.toPrinter = !tofile;
|
||||
|
||||
// PWD, HOME, or fail
|
||||
if (!printfile) {
|
||||
if ((path = PR_GetEnv("PWD")) == (char*)NULL)
|
||||
if ((path = PR_GetEnv("HOME")) == (char*)NULL)
|
||||
strcpy(mPrData.path,"mozilla.ps");
|
||||
if (path != (char*)NULL)
|
||||
sprintf(mPrData.path,"%s/mozilla.ps",path);
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (command != nsnull) {
|
||||
nsMemory::Free(command);
|
||||
}
|
||||
if (printfile != nsnull) {
|
||||
nsMemory::Free(printfile);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecQT::GetToPrinter(PRBool &aToPrinter)
|
||||
|
|
|
@ -62,14 +62,9 @@ public:
|
|||
/**
|
||||
* Initialize the nsDeviceContextSpecQT for use. This will allocate a printrecord for use
|
||||
* @update dc 2/16/98
|
||||
* @param aQuiet if PR_TRUE, prevent the need for user intervention
|
||||
* in obtaining device context spec. if nsnull is passed in for
|
||||
* the aOldSpec, this will typically result in getting a device
|
||||
* context spec for the default output device (i.e. default
|
||||
* printer).
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet);
|
||||
NS_IMETHOD Init(nsIPrintSettings* aPS);
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,8 +42,6 @@ REQUIRES = xpcom \
|
|||
unicharutil \
|
||||
locale \
|
||||
necko \
|
||||
dom \
|
||||
windowwatcher \
|
||||
content \
|
||||
layout \
|
||||
$(NULL)
|
||||
|
|
|
@ -35,8 +35,6 @@ 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 aQuiet)
|
||||
PRBool aIsPrintPreview)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aWidget);
|
||||
|
||||
|
@ -77,7 +77,7 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryWin :: CreateDeviceContextSpec(nsIWidget
|
|||
|
||||
if (nsnull != devspec){
|
||||
nsDeviceContextSpecWin* specWin = NS_STATIC_CAST(nsDeviceContextSpecWin*, devspec);
|
||||
rv = specWin->Init(aWidget, aPrintSettings, aQuiet);
|
||||
rv = specWin->Init(aWidget, aPrintSettings, aIsPrintPreview);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
aNewSpec = devspec;
|
||||
} else {
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget,
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet);
|
||||
PRBool aIsPrintPreview);
|
||||
|
||||
protected:
|
||||
~nsDeviceContextSpecFactoryWin();
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -51,7 +51,7 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init(nsIWidget* aWidget, nsIPrintSettings* aPS, PRBool aQuiet);
|
||||
NS_IMETHOD Init(nsIWidget* aWidget, nsIPrintSettings* aPS, PRBool aIsPrintPreview);
|
||||
|
||||
void GetDriverName(char *&aDriverName) const { aDriverName = mDriverName; }
|
||||
void GetDeviceName(char *&aDeviceName) const { aDeviceName = mDeviceName; }
|
||||
|
@ -70,12 +70,6 @@ public:
|
|||
LPDEVMODE aDevMode);
|
||||
|
||||
protected:
|
||||
nsresult ShowXPPrintDialog(PRBool aQuiet);
|
||||
nsresult ShowNativePrintDialog(nsIWidget* aWidget, PRBool aQuiet);
|
||||
|
||||
#ifdef MOZ_REQUIRE_CURRENT_SDK
|
||||
nsresult ShowNativePrintDialogEx(nsIWidget* aWidget, PRBool aQuiet);
|
||||
#endif
|
||||
|
||||
void SetDeviceName(char* aDeviceName);
|
||||
void SetDriverName(char* aDriverName);
|
||||
|
@ -93,9 +87,6 @@ protected:
|
|||
PRBool mIsDEVMODEGlobalHandle;
|
||||
|
||||
nsCOMPtr<nsIPrintSettings> mPrintSettings;
|
||||
|
||||
// For PrintDlgEx
|
||||
FARPROC mUseExtendedPrintDlg;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -47,10 +47,7 @@
|
|||
#include "nsGfxCIID.h"
|
||||
#include "nsReadableutils.h"
|
||||
|
||||
// Print Options
|
||||
#include "nsIPrintOptions.h"
|
||||
#include "nsString.h"
|
||||
static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID);
|
||||
|
||||
#define DOC_TITLE_LENGTH 64
|
||||
|
||||
|
@ -755,7 +752,7 @@ static void DisplayLastError()
|
|||
#endif
|
||||
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextWin :: BeginDocument(PRUnichar * aTitle)
|
||||
NS_IMETHODIMP nsDeviceContextWin :: BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage)
|
||||
{
|
||||
nsresult rv = NS_ERROR_GFX_PRINTER_STARTDOC;
|
||||
|
||||
|
@ -771,21 +768,9 @@ NS_IMETHODIMP nsDeviceContextWin :: BeginDocument(PRUnichar * aTitle)
|
|||
char *title = GetACPString(titleStr);
|
||||
|
||||
char* docName = nsnull;
|
||||
nsCOMPtr<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);
|
||||
}
|
||||
}
|
||||
nsAutoString str(aPrintToFileName);
|
||||
if (str.Length() > 0) {
|
||||
docName = ToNewCString(str);
|
||||
}
|
||||
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);
|
||||
NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage);
|
||||
NS_IMETHOD EndDocument(void);
|
||||
NS_IMETHOD AbortDocument(void);
|
||||
|
||||
|
|
|
@ -38,10 +38,6 @@ REQUIRES = xpcom \
|
|||
string \
|
||||
xlibrgb \
|
||||
widget \
|
||||
dom \
|
||||
layout \
|
||||
content \
|
||||
appshell \
|
||||
js \
|
||||
necko \
|
||||
pref \
|
||||
|
@ -53,7 +49,6 @@ REQUIRES = xpcom \
|
|||
gfx2 \
|
||||
imglib2 \
|
||||
mozcomps \
|
||||
windowwatcher \
|
||||
intl \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -62,14 +62,14 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryXlib::Init(void)
|
|||
NS_IMETHODIMP nsDeviceContextSpecFactoryXlib::CreateDeviceContextSpec(nsIWidget *aWidget,
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet)
|
||||
PRBool aIsPrintPreview)
|
||||
{
|
||||
nsresult rv;
|
||||
static NS_DEFINE_CID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
|
||||
nsCOMPtr<nsIDeviceContextSpec> devSpec = do_CreateInstance(kDeviceContextSpecCID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = ((nsDeviceContextSpecXlib *)devSpec.get())->Init(aPrintSettings, aQuiet);
|
||||
rv = ((nsDeviceContextSpecXlib *)devSpec.get())->Init(aPrintSettings);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
aNewSpec = devSpec;
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget,
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet);
|
||||
PRBool aIsPrintPreview);
|
||||
|
||||
protected:
|
||||
virtual ~nsDeviceContextSpecFactoryXlib();
|
||||
|
|
|
@ -51,16 +51,9 @@
|
|||
#include "nsIPref.h"
|
||||
#include "prenv.h" /* for PR_GetEnv */
|
||||
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDialogParamBlock.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsIWindowWatcher.h"
|
||||
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsISupportsArray.h"
|
||||
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#ifdef USE_XPRINT
|
||||
#include "xprintutil.h"
|
||||
|
@ -254,66 +247,6 @@ NS_IMPL_ISUPPORTS1(nsDeviceContextSpecXlib,
|
|||
#error "This should not happen"
|
||||
#endif
|
||||
|
||||
/** -------------------------------------------------------
|
||||
*/
|
||||
static nsresult DisplayXPDialog(nsIPrintSettings* aPS,
|
||||
const char* aChromeURL,
|
||||
PRBool& aClickedOK)
|
||||
{
|
||||
DO_PR_DEBUG_LOG(("nsDeviceContextSpecXlib::DisplayXPDialog()\n"));
|
||||
NS_ASSERTION(aPS, "Must have a print settings!");
|
||||
|
||||
aClickedOK = PR_FALSE;
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
// create a nsISupportsArray of the parameters
|
||||
// being passed to the window
|
||||
nsCOMPtr<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
|
||||
|
@ -323,19 +256,19 @@ static nsresult DisplayXPDialog(nsIPrintSettings* aPS,
|
|||
* toolkits including:
|
||||
* - GTK+-toolkit:
|
||||
* file: mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp
|
||||
* function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init(PRBool aQuiet)
|
||||
* function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init()
|
||||
* - Xlib-toolkit:
|
||||
* file: mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp
|
||||
* function: NS_IMETHODIMP nsDeviceContextSpecXlib::Init(PRBool aQuiet)
|
||||
* function: NS_IMETHODIMP nsDeviceContextSpecXlib::Init()
|
||||
* - Qt-toolkit:
|
||||
* file: mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp
|
||||
* function: NS_IMETHODIMP nsDeviceContextSpecQT::Init(PRBool aQuiet)
|
||||
* function: NS_IMETHODIMP nsDeviceContextSpecQT::Init()
|
||||
*
|
||||
* ** Please update the other toolkits when changing this function.
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextSpecXlib::Init(nsIPrintSettings *aPS, PRBool aQuiet)
|
||||
NS_IMETHODIMP nsDeviceContextSpecXlib::Init(nsIPrintSettings *aPS)
|
||||
{
|
||||
DO_PR_DEBUG_LOG(("nsDeviceContextSpecXlib::Init(aPS=%p. qQuiet=%d)\n", aPS, (int)aQuiet));
|
||||
DO_PR_DEBUG_LOG(("nsDeviceContextSpecXlib::Init(aPS=%p\n", aPS));
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
mPrintSettings = aPS;
|
||||
|
@ -350,88 +283,76 @@ NS_IMETHODIMP nsDeviceContextSpecXlib::Init(nsIPrintSettings *aPS, PRBool aQuiet
|
|||
}
|
||||
}
|
||||
|
||||
PRBool canPrint = PR_FALSE;
|
||||
|
||||
rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (!aQuiet) {
|
||||
rv = DisplayXPDialog(mPrintSettings,
|
||||
"chrome://global/content/printdialog.xul", canPrint);
|
||||
} else {
|
||||
rv = NS_OK;
|
||||
canPrint = PR_TRUE;
|
||||
}
|
||||
|
||||
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
|
||||
|
||||
if (NS_SUCCEEDED(rv) && canPrint) {
|
||||
if (aPS) {
|
||||
PRBool reversed = PR_FALSE;
|
||||
PRBool color = PR_FALSE;
|
||||
PRBool tofile = PR_FALSE;
|
||||
PRInt16 printRange = nsIPrintSettings::kRangeAllPages;
|
||||
PRInt32 orientation = NS_PORTRAIT;
|
||||
PRInt32 fromPage = 1;
|
||||
PRInt32 toPage = 1;
|
||||
PRUnichar *command = nsnull;
|
||||
PRInt32 copies = 1;
|
||||
PRUnichar *printer = nsnull;
|
||||
PRUnichar *papername = nsnull;
|
||||
PRUnichar *printfile = nsnull;
|
||||
double dleft = 0.5;
|
||||
double dright = 0.5;
|
||||
double dtop = 0.5;
|
||||
double dbottom = 0.5;
|
||||
if (aPS) {
|
||||
PRBool reversed = PR_FALSE;
|
||||
PRBool color = PR_FALSE;
|
||||
PRBool tofile = PR_FALSE;
|
||||
PRInt16 printRange = nsIPrintSettings::kRangeAllPages;
|
||||
PRInt32 orientation = NS_PORTRAIT;
|
||||
PRInt32 fromPage = 1;
|
||||
PRInt32 toPage = 1;
|
||||
PRUnichar *command = nsnull;
|
||||
PRInt32 copies = 1;
|
||||
PRUnichar *printer = nsnull;
|
||||
PRUnichar *papername = nsnull;
|
||||
PRUnichar *printfile = nsnull;
|
||||
double dleft = 0.5;
|
||||
double dright = 0.5;
|
||||
double dtop = 0.5;
|
||||
double dbottom = 0.5;
|
||||
|
||||
aPS->GetPrinterName(&printer);
|
||||
aPS->GetPrintReversed(&reversed);
|
||||
aPS->GetPrintInColor(&color);
|
||||
aPS->GetPaperName(&papername);
|
||||
aPS->GetOrientation(&orientation);
|
||||
aPS->GetPrintCommand(&command);
|
||||
aPS->GetPrintRange(&printRange);
|
||||
aPS->GetToFileName(&printfile);
|
||||
aPS->GetPrintToFile(&tofile);
|
||||
aPS->GetStartPageRange(&fromPage);
|
||||
aPS->GetEndPageRange(&toPage);
|
||||
aPS->GetNumCopies(&copies);
|
||||
aPS->GetMarginTop(&dtop);
|
||||
aPS->GetMarginLeft(&dleft);
|
||||
aPS->GetMarginBottom(&dbottom);
|
||||
aPS->GetMarginRight(&dright);
|
||||
aPS->GetPrinterName(&printer);
|
||||
aPS->GetPrintReversed(&reversed);
|
||||
aPS->GetPrintInColor(&color);
|
||||
aPS->GetPaperName(&papername);
|
||||
aPS->GetOrientation(&orientation);
|
||||
aPS->GetPrintCommand(&command);
|
||||
aPS->GetPrintRange(&printRange);
|
||||
aPS->GetToFileName(&printfile);
|
||||
aPS->GetPrintToFile(&tofile);
|
||||
aPS->GetStartPageRange(&fromPage);
|
||||
aPS->GetEndPageRange(&toPage);
|
||||
aPS->GetNumCopies(&copies);
|
||||
aPS->GetMarginTop(&dtop);
|
||||
aPS->GetMarginLeft(&dleft);
|
||||
aPS->GetMarginBottom(&dbottom);
|
||||
aPS->GetMarginRight(&dright);
|
||||
|
||||
if (printfile)
|
||||
strcpy(mPath, NS_ConvertUCS2toUTF8(printfile).get());
|
||||
if (command)
|
||||
strcpy(mCommand, NS_ConvertUCS2toUTF8(command).get());
|
||||
if (printer)
|
||||
strcpy(mPrinter, NS_ConvertUCS2toUTF8(printer).get());
|
||||
if (papername)
|
||||
strcpy(mPaperName, NS_ConvertUCS2toUTF8(papername).get());
|
||||
if (printfile)
|
||||
strcpy(mPath, NS_ConvertUCS2toUTF8(printfile).get());
|
||||
if (command)
|
||||
strcpy(mCommand, NS_ConvertUCS2toUTF8(command).get());
|
||||
if (printer)
|
||||
strcpy(mPrinter, NS_ConvertUCS2toUTF8(printer).get());
|
||||
if (papername)
|
||||
strcpy(mPaperName, NS_ConvertUCS2toUTF8(papername).get());
|
||||
|
||||
DO_PR_DEBUG_LOG(("margins: %5.2f,%5.2f,%5.2f,%5.2f\n", dtop, dleft, dbottom, dright));
|
||||
DO_PR_DEBUG_LOG(("printRange %d\n", printRange));
|
||||
DO_PR_DEBUG_LOG(("fromPage %d\n", fromPage));
|
||||
DO_PR_DEBUG_LOG(("toPage %d\n", toPage));
|
||||
DO_PR_DEBUG_LOG(("tofile %d\n", tofile));
|
||||
DO_PR_DEBUG_LOG(("printfile '%s'\n", printfile? NS_ConvertUCS2toUTF8(printfile).get():"<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;
|
||||
|
@ -993,19 +914,7 @@ NS_IMETHODIMP nsPrinterEnumeratorXlib::InitPrintSettingsFromPrinter(const PRUnic
|
|||
|
||||
NS_IMETHODIMP nsPrinterEnumeratorXlib::DisplayPropertiesDlg(const PRUnichar *aPrinter, nsIPrintSettings *aPrintSettings)
|
||||
{
|
||||
/* fixme: We simply ignore the |aPrinter| argument here
|
||||
* We should get the supported printer attributes from the printer and
|
||||
* populate the print job options dialog with these data instead of using
|
||||
* the "default set" here.
|
||||
* However, this requires changes on all platforms and is another big chunk
|
||||
* of patches ... ;-(
|
||||
*/
|
||||
|
||||
PRBool pressedOK;
|
||||
return DisplayXPDialog(aPrintSettings,
|
||||
"chrome://global/content/printjoboptions.xul",
|
||||
pressedOK);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aQuiet);
|
||||
NS_IMETHOD Init(nsIPrintSettings* aPS);
|
||||
NS_IMETHOD ClosePrintManager();
|
||||
|
||||
NS_IMETHOD GetToPrinter(PRBool &aToPrinter);
|
||||
|
|
|
@ -460,7 +460,7 @@ NS_IMETHODIMP nsDeviceContextXlib::GetDeviceContextFor(nsIDeviceContextSpec *aDe
|
|||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextXlib::BeginDocument(PRUnichar * aTitle)
|
||||
NS_IMETHODIMP nsDeviceContextXlib::BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage)
|
||||
{
|
||||
PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::BeginDocument()\n"));
|
||||
return NS_OK;
|
||||
|
|
|
@ -73,7 +73,7 @@ public:
|
|||
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
|
||||
nsIDeviceContext *&aContext);
|
||||
|
||||
NS_IMETHOD BeginDocument(PRUnichar * aTitle);
|
||||
NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage);
|
||||
NS_IMETHOD EndDocument(void);
|
||||
NS_IMETHOD AbortDocument(void);
|
||||
|
||||
|
|
|
@ -303,12 +303,12 @@ NS_IMETHODIMP nsDeviceContextXp::GetDeviceContextFor(nsIDeviceContextSpec *aDevi
|
|||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextXp::BeginDocument(PRUnichar * aTitle)
|
||||
NS_IMETHODIMP nsDeviceContextXp::BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage)
|
||||
{
|
||||
PR_LOG(nsDeviceContextXpLM, PR_LOG_DEBUG, ("nsDeviceContextXp::BeginDocument()\n"));
|
||||
nsresult rv = NS_OK;
|
||||
if (mPrintContext != nsnull) {
|
||||
rv = mPrintContext->BeginDocument(aTitle);
|
||||
rv = mPrintContext->BeginDocument(aTitle, aPrintToFileName, aStartPage, aEndPage);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ public:
|
|||
|
||||
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,nsIDeviceContext *&aContext);
|
||||
NS_IMETHOD GetSystemFont(nsSystemFontID anID, nsFont *aFont) const;
|
||||
NS_IMETHOD BeginDocument(PRUnichar * aTitle);
|
||||
NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage);
|
||||
NS_IMETHOD EndDocument(void);
|
||||
NS_IMETHOD AbortDocument(void);
|
||||
NS_IMETHOD BeginPage(void);
|
||||
|
|
|
@ -685,7 +685,7 @@ nsXPrintContext::SetResolution( void )
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPrintContext::BeginDocument( PRUnichar *aTitle )
|
||||
nsXPrintContext::BeginDocument( PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage )
|
||||
{
|
||||
PR_LOG(nsXPrintContextLM, PR_LOG_DEBUG, ("nsXPrintContext::BeginDocument(aTitle='%s')\n", ((aTitle)?(NS_ConvertUCS2toUTF8(aTitle).get()):("<NULL>"))));
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ public:
|
|||
NS_IMETHOD Init(nsDeviceContextXp *dc, nsIDeviceContextSpecXp *aSpec);
|
||||
NS_IMETHOD BeginPage();
|
||||
NS_IMETHOD EndPage();
|
||||
NS_IMETHOD BeginDocument(PRUnichar *aTitle);
|
||||
NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage);
|
||||
NS_IMETHOD EndDocument();
|
||||
NS_IMETHOD AbortDocument();
|
||||
|
||||
|
|
|
@ -161,6 +161,10 @@ static NS_DEFINE_IID(kPrinterEnumeratorCID, NS_PRINTER_ENUMERATOR_CID);
|
|||
#include "nsIWindowWatcher.h"
|
||||
#include "nsIStringBundle.h"
|
||||
|
||||
// Printing Prompts
|
||||
#include "nsIPrintingPromptService.h"
|
||||
const char* kPrintingPromptService = "@mozilla.org/embedcomp/printingprompt-service;1";
|
||||
|
||||
#define NS_ERROR_GFX_PRINTER_BUNDLE_URL "chrome://global/locale/printing.properties"
|
||||
|
||||
// FrameSet
|
||||
|
@ -215,12 +219,12 @@ static const char * gPrintRangeStr[] = {"kRangeAllPages", "kRangeSpecified
|
|||
static PRUint32 gDumpFileNameCnt = 0;
|
||||
static PRUint32 gDumpLOFileNameCnt = 0;
|
||||
|
||||
#define PRINT_DEBUG_MSG1(_msg1) fprintf(mPrt->mDebugFD, (_msg1));
|
||||
#define PRINT_DEBUG_MSG2(_msg1, _msg2) fprintf(mPrt->mDebugFD, (_msg1), (_msg2));
|
||||
#define PRINT_DEBUG_MSG3(_msg1, _msg2, _msg3) fprintf(mPrt->mDebugFD, (_msg1), (_msg2), (_msg3));
|
||||
#define PRINT_DEBUG_MSG4(_msg1, _msg2, _msg3, _msg4) fprintf(mPrt->mDebugFD, (_msg1), (_msg2), (_msg3), (_msg4));
|
||||
#define PRINT_DEBUG_MSG5(_msg1, _msg2, _msg3, _msg4, _msg5) fprintf(mPrt->mDebugFD, (_msg1), (_msg2), (_msg3), (_msg4), (_msg5));
|
||||
#define PRINT_DEBUG_FLUSH fflush(mPrt->mDebugFD);
|
||||
#define PRINT_DEBUG_MSG1(_msg1) if (mPrt && mPrt->mDebugFD) fprintf(mPrt->mDebugFD, (_msg1));
|
||||
#define PRINT_DEBUG_MSG2(_msg1, _msg2) if (mPrt && mPrt->mDebugFD) fprintf(mPrt->mDebugFD, (_msg1), (_msg2));
|
||||
#define PRINT_DEBUG_MSG3(_msg1, _msg2, _msg3) if (mPrt && mPrt->mDebugFD) fprintf(mPrt->mDebugFD, (_msg1), (_msg2), (_msg3));
|
||||
#define PRINT_DEBUG_MSG4(_msg1, _msg2, _msg3, _msg4) if (mPrt && mPrt->mDebugFD) fprintf(mPrt->mDebugFD, (_msg1), (_msg2), (_msg3), (_msg4));
|
||||
#define PRINT_DEBUG_MSG5(_msg1, _msg2, _msg3, _msg4, _msg5) if (mPrt && mPrt->mDebugFD) fprintf(mPrt->mDebugFD, (_msg1), (_msg2), (_msg3), (_msg4), (_msg5));
|
||||
#define PRINT_DEBUG_FLUSH if (mPrt && mPrt->mDebugFD) fflush(mPrt->mDebugFD);
|
||||
#else //--------------
|
||||
#define PRT_YESNO(_p)
|
||||
#define PRINT_DEBUG_MSG1(_msg)
|
||||
|
@ -398,7 +402,9 @@ private:
|
|||
class PrintData {
|
||||
public:
|
||||
|
||||
PrintData();
|
||||
typedef enum ePrintDataType {eIsPrinting, eIsPrintPreview };
|
||||
|
||||
PrintData(ePrintDataType aType);
|
||||
~PrintData(); // non-virtual
|
||||
|
||||
// Listener Helper Methods
|
||||
|
@ -410,6 +416,7 @@ public:
|
|||
PRBool aDoStartStop = PR_FALSE,
|
||||
PRInt32 aFlag = 0);
|
||||
|
||||
ePrintDataType mType; // the type of data this is (Printing or Print Preview)
|
||||
nsCOMPtr<nsIDeviceContext> mPrintDC;
|
||||
nsIView *mPrintView;
|
||||
FILE *mDebugFilePtr; // a file where information can go to when printing
|
||||
|
@ -466,6 +473,7 @@ public:
|
|||
#endif
|
||||
|
||||
private:
|
||||
PrintData() {}
|
||||
PrintData& operator=(const PrintData& aOther); // not implemented
|
||||
|
||||
};
|
||||
|
@ -711,7 +719,6 @@ protected:
|
|||
nsIPageSequenceFrame* mPageSeqFrame;
|
||||
|
||||
|
||||
PRBool mIsPrinting;
|
||||
PrintData* mPrt;
|
||||
nsPagePrintTimer* mPagePrintTimer;
|
||||
|
||||
|
@ -878,8 +885,8 @@ static nsresult NS_NewUpdateTimer(nsPagePrintTimer **aResult)
|
|||
//---------------------------------------------------
|
||||
//-- PrintData Class Impl
|
||||
//---------------------------------------------------
|
||||
PrintData::PrintData() :
|
||||
mPrintView(nsnull), mDebugFilePtr(nsnull), mPrintObject(nsnull), mSelectedPO(nsnull),
|
||||
PrintData::PrintData(ePrintDataType aType) :
|
||||
mType(aType), mPrintView(nsnull), mDebugFilePtr(nsnull), mPrintObject(nsnull), mSelectedPO(nsnull),
|
||||
mShowProgressDialog(PR_TRUE), mPrintDocList(nsnull), mIsIFrameSelected(PR_FALSE),
|
||||
mIsParentAFrameSet(PR_FALSE), mPrintingAsIsSubDoc(PR_FALSE), mOnStartSent(PR_FALSE),
|
||||
mIsAborted(PR_FALSE), mPreparingForPrint(PR_FALSE), mDocWasToBeDestroyed(PR_FALSE),
|
||||
|
@ -940,13 +947,15 @@ PrintData::~PrintData()
|
|||
mPrintSettings->GetIsCancelled(&isCancelled);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
if (!isCancelled && !mIsAborted) {
|
||||
rv = mPrintDC->EndDocument();
|
||||
} else {
|
||||
rv = mPrintDC->AbortDocument();
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
DocumentViewerImpl::ShowPrintErrorDialog(rv);
|
||||
if (mType == eIsPrinting) {
|
||||
if (!isCancelled && !mIsAborted) {
|
||||
rv = mPrintDC->EndDocument();
|
||||
} else {
|
||||
rv = mPrintDC->AbortDocument();
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
DocumentViewerImpl::ShowPrintErrorDialog(rv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1103,7 +1112,6 @@ void DocumentViewerImpl::PrepareToStartLoad()
|
|||
mStopped = PR_FALSE;
|
||||
mLoaded = PR_FALSE;
|
||||
mPrt = nsnull;
|
||||
mIsPrinting = PR_FALSE;
|
||||
|
||||
#ifdef NS_PRINT_PREVIEW
|
||||
mIsDoingPrintPreview = PR_FALSE;
|
||||
|
@ -4312,7 +4320,7 @@ DocumentViewerImpl::FindXMostFrameInList(nsIPresContext* aPresContext,
|
|||
xMost = 0;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_PRINTING // keep this here but leave it turned off
|
||||
#ifdef DEBUG_PRINTING_X // keep this here but leave it turned off
|
||||
nsAutoString tmp;
|
||||
nsIFrameDebug* frameDebug;
|
||||
if (NS_SUCCEEDED(CallQueryInterface(child, &frameDebug))) {
|
||||
|
@ -4323,7 +4331,7 @@ DocumentViewerImpl::FindXMostFrameInList(nsIPresContext* aPresContext,
|
|||
|
||||
if (xMost > aMaxWidth) {
|
||||
aMaxWidth = xMost;
|
||||
#ifdef DEBUG_PRINTING // keep this here but leave it turned off
|
||||
#ifdef DEBUG_PRINTING_X // keep this here but leave it turned off
|
||||
printf("%p - %d %s ", child, aMaxWidth, NS_LossyConvertUCS2toASCII(tmp).get());
|
||||
if (aList == nsLayoutAtoms::overflowList) printf(" nsLayoutAtoms::overflowList\n");
|
||||
if (aList == nsLayoutAtoms::floaterList) printf(" nsLayoutAtoms::floaterList\n");
|
||||
|
@ -4453,7 +4461,7 @@ DocumentViewerImpl::SetupToPrintContent(nsIWebShell* aParent,
|
|||
}
|
||||
|
||||
// Only Shrink if we are smaller
|
||||
if (mPrt->mShrinkRatio < 1.0f) {
|
||||
if (mPrt->mShrinkRatio < 0.998f) {
|
||||
// Clamp Shrink to Fit to 50%
|
||||
mPrt->mShrinkRatio = PR_MAX(mPrt->mShrinkRatio, 0.5f);
|
||||
|
||||
|
@ -4471,6 +4479,30 @@ DocumentViewerImpl::SetupToPrintContent(nsIWebShell* aParent,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG_rods
|
||||
{
|
||||
float calcRatio;
|
||||
if (mPrt->mPrintDocList->Count() > 1 && mPrt->mPrintObject->mFrameType == eFrameSet) {
|
||||
PrintObject* xMostPO = FindXMostPO();
|
||||
NS_ASSERTION(xMostPO, "There must always be an XMost PO!");
|
||||
if (xMostPO) {
|
||||
// The margin is included in the PO's mRect so we need to subtract it
|
||||
nsMargin margin(0,0,0,0);
|
||||
mPrt->mPrintSettings->GetMarginInTwips(margin);
|
||||
nsRect rect = xMostPO->mRect;
|
||||
rect.x -= margin.left;
|
||||
// Calc the shrinkage based on the entire content area
|
||||
calcRatio = float(rect.XMost()) / float(rect.x + xMostPO->mXMost);
|
||||
}
|
||||
} else {
|
||||
// Single document so use the Shrink as calculated for the PO
|
||||
calcRatio = mPrt->mPrintObject->mShrinkRatio;
|
||||
}
|
||||
printf("**************************************************************************\n");
|
||||
printf("STF Ratio is: %8.5f Effective Ratio: %8.5f Diff: %8.5f\n", mPrt->mShrinkRatio, calcRatio, mPrt->mShrinkRatio-calcRatio);
|
||||
printf("**************************************************************************\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
DUMP_DOC_LIST("\nAfter Reflow------------------------------------------");
|
||||
|
@ -4510,12 +4542,54 @@ DocumentViewerImpl::SetupToPrintContent(nsIWebShell* aParent,
|
|||
|
||||
mPrt->mPrintDocDW = aCurrentFocusedDOMWin;
|
||||
|
||||
PRUnichar* fileName = nsnull;
|
||||
// check to see if we are printing to a file
|
||||
PRBool isPrintToFile = PR_FALSE;
|
||||
mPrt->mPrintSettings->GetPrintToFile(&isPrintToFile);
|
||||
if (isPrintToFile) {
|
||||
// On some platforms The BeginDocument needs to know the name of the file
|
||||
// and it uses the PrintService to get it, so we need to set it into the PrintService here
|
||||
mPrt->mPrintSettings->GetToFileName(&fileName);
|
||||
}
|
||||
|
||||
PRUnichar * docTitleStr;
|
||||
PRUnichar * docURLStr;
|
||||
GetDisplayTitleAndURL(mPrt->mPrintObject, mPrt->mPrintSettings, mPrt->mBrandName, &docTitleStr, &docURLStr, eDocTitleDefURLDoc);
|
||||
|
||||
PRInt32 startPage = 1;
|
||||
PRInt32 endPage = mPrt->mNumPrintablePages;
|
||||
|
||||
PRInt16 printRangeType = nsIPrintSettings::kRangeAllPages;
|
||||
mPrt->mPrintSettings->GetPrintRange(&printRangeType);
|
||||
if (printRangeType == nsIPrintSettings::kRangeSpecifiedPageRange) {
|
||||
mPrt->mPrintSettings->GetStartPageRange(&startPage);
|
||||
mPrt->mPrintSettings->GetEndPageRange(&endPage);
|
||||
if (endPage > mPrt->mNumPrintablePages) {
|
||||
endPage = mPrt->mNumPrintablePages;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
// BeginDocument may pass back a FAILURE code
|
||||
// i.e. On Windows, if you are printing to a file and hit "Cancel"
|
||||
// to the "File Name" dialog, this comes back as an error
|
||||
// Don't start printing when regression test are executed
|
||||
if (!mPrt->mDebugFilePtr && mIsDoingPrinting) {
|
||||
rv = mPrt->mPrintDC->BeginDocument(docTitleStr, fileName, startPage, endPage);
|
||||
}
|
||||
|
||||
PRINT_DEBUG_MSG1("****************** Begin Document ************************\n");
|
||||
|
||||
if (docTitleStr) nsMemory::Free(docTitleStr);
|
||||
if (docURLStr) nsMemory::Free(docURLStr);
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// This will print the webshell document
|
||||
// when it completes asynchronously in the DonePrintingPages method
|
||||
// it will check to see if there are more webshells to be printed and
|
||||
// then PrintDocContent will be called again.
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
if (mIsDoingPrinting) {
|
||||
PrintDocContent(mPrt->mPrintObject, rv); // ignore return value
|
||||
}
|
||||
|
@ -4688,23 +4762,11 @@ DocumentViewerImpl::DoPrint(PrintObject * aPO, PRBool aDoSyncPrinting, PRBool& a
|
|||
#endif
|
||||
|
||||
if (mPrt->mPrintSettings) {
|
||||
PRUnichar * docTitleStr = nsnull;
|
||||
PRUnichar * docURLStr = nsnull;
|
||||
|
||||
if (!skipSetTitle) {
|
||||
PRUnichar * docTitleStr;
|
||||
PRUnichar * docURLStr;
|
||||
GetDisplayTitleAndURL(aPO, mPrt->mPrintSettings, mPrt->mBrandName,
|
||||
&docTitleStr, &docURLStr, eDocTitleDefBlank);
|
||||
|
||||
// Set them down into the PrintOptions so
|
||||
// they can used by the DeviceContext
|
||||
if (docTitleStr) {
|
||||
mPrt->mPrintOptions->SetTitle(docTitleStr);
|
||||
nsMemory::Free(docTitleStr);
|
||||
}
|
||||
|
||||
if (docURLStr) {
|
||||
mPrt->mPrintOptions->SetDocURL(docURLStr);
|
||||
nsMemory::Free(docURLStr);
|
||||
}
|
||||
GetDisplayTitleAndURL(aPO, mPrt->mPrintSettings, mPrt->mBrandName, &docTitleStr, &docURLStr, eDocTitleDefBlank);
|
||||
}
|
||||
|
||||
if (nsIPrintSettings::kRangeSelection == printRangeType) {
|
||||
|
@ -4794,7 +4856,7 @@ DocumentViewerImpl::DoPrint(PrintObject * aPO, PRBool aDoSyncPrinting, PRBool& a
|
|||
rootFrame->SetRect(poPresContext, r);
|
||||
|
||||
mPageSeqFrame = pageSequence;
|
||||
mPageSeqFrame->StartPrint(poPresContext, mPrt->mPrintSettings);
|
||||
mPageSeqFrame->StartPrint(poPresContext, mPrt->mPrintSettings, docTitleStr, docURLStr);
|
||||
|
||||
if (!aDoSyncPrinting) {
|
||||
// Get the delay time in between the printing of each page
|
||||
|
@ -5493,25 +5555,26 @@ DocumentViewerImpl::IsThereAnIFrameSelected(nsIWebShell* aWebShell,
|
|||
{
|
||||
aIsParentFrameSet = IsParentAFrameSet(aWebShell);
|
||||
PRBool iFrameIsSelected = PR_FALSE;
|
||||
#if 1
|
||||
PrintObject* po = FindPrintObjectByDOMWin(mPrt->mPrintObject, aDOMWin);
|
||||
iFrameIsSelected = po && po->mFrameType == eIFrame;
|
||||
#else
|
||||
// First, check to see if we are a frameset
|
||||
if (!aIsParentFrameSet) {
|
||||
// Check to see if there is a currenlt focused frame
|
||||
// if so, it means the selected frame is either the main webshell
|
||||
// or an IFRAME
|
||||
if (aDOMWin != nsnull) {
|
||||
// Get the main webshell's DOMWin to see if it matches
|
||||
// the frame that is selected
|
||||
nsCOMPtr<nsIDOMWindowInternal> domWin = getter_AddRefs(GetDOMWinForWebShell(aWebShell));
|
||||
if (aDOMWin != nsnull && domWin != aDOMWin) {
|
||||
iFrameIsSelected = PR_TRUE; // we have a selected IFRAME
|
||||
if (mPrt && mPrt->mPrintObject) {
|
||||
PrintObject* po = FindPrintObjectByDOMWin(mPrt->mPrintObject, aDOMWin);
|
||||
iFrameIsSelected = po && po->mFrameType == eIFrame;
|
||||
} else {
|
||||
// First, check to see if we are a frameset
|
||||
if (!aIsParentFrameSet) {
|
||||
// Check to see if there is a currenlt focused frame
|
||||
// if so, it means the selected frame is either the main webshell
|
||||
// or an IFRAME
|
||||
if (aDOMWin != nsnull) {
|
||||
// Get the main webshell's DOMWin to see if it matches
|
||||
// the frame that is selected
|
||||
nsCOMPtr<nsIDOMWindowInternal> domWin = getter_AddRefs(GetDOMWinForWebShell(aWebShell));
|
||||
if (aDOMWin != nsnull && domWin != aDOMWin) {
|
||||
iFrameIsSelected = PR_TRUE; // we have a selected IFRAME
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return iFrameIsSelected;
|
||||
}
|
||||
|
||||
|
@ -6326,7 +6389,7 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings)
|
|||
mPrtPreview = nsnull;
|
||||
}
|
||||
|
||||
mPrt = new PrintData();
|
||||
mPrt = new PrintData(PrintData::eIsPrintPreview);
|
||||
if (!mPrt) {
|
||||
mIsCreatingPrintPreview = PR_FALSE;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -6380,7 +6443,6 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings)
|
|||
// Let's print ...
|
||||
mIsCreatingPrintPreview = PR_TRUE;
|
||||
mIsDoingPrintPreview = PR_TRUE;
|
||||
aPrintSettings->SetIsPrintPreview(mIsDoingPrintPreview);
|
||||
|
||||
// Very important! Turn Off scripting
|
||||
TurnScriptingOn(PR_FALSE);
|
||||
|
@ -6399,7 +6461,6 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings)
|
|||
if (!mPrt->mPrintDocList) {
|
||||
mIsCreatingPrintPreview = PR_FALSE;
|
||||
mIsDoingPrintPreview = PR_FALSE;
|
||||
aPrintSettings->SetIsPrintPreview(mIsDoingPrintPreview);
|
||||
TurnScriptingOn(PR_TRUE);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -6468,8 +6529,6 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings)
|
|||
}
|
||||
#endif
|
||||
|
||||
PRBool doSilent = PR_TRUE;
|
||||
|
||||
nscoord width = NS_INCHES_TO_TWIPS(8.5);
|
||||
nscoord height = NS_INCHES_TO_TWIPS(11.0);
|
||||
|
||||
|
@ -6478,7 +6537,7 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings)
|
|||
if (factory) {
|
||||
nsCOMPtr<nsIDeviceContextSpec> devspec;
|
||||
nsCOMPtr<nsIDeviceContext> dx;
|
||||
nsresult rv = factory->CreateDeviceContextSpec(mWindow, aPrintSettings, *getter_AddRefs(devspec), doSilent);
|
||||
nsresult rv = factory->CreateDeviceContextSpec(mWindow, aPrintSettings, *getter_AddRefs(devspec), PR_TRUE);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = mDeviceContext->GetDeviceContextFor(devspec, *getter_AddRefs(ppDC));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
@ -6496,9 +6555,7 @@ DocumentViewerImpl::PrintPreview(nsIPrintSettings* aPrintSettings)
|
|||
}
|
||||
}
|
||||
|
||||
if (doSilent) {
|
||||
mPrt->mPrintSettings->SetPrintFrameType(nsIPrintSettings::kFramesAsIs);
|
||||
}
|
||||
mPrt->mPrintSettings->SetPrintFrameType(nsIPrintSettings::kFramesAsIs);
|
||||
|
||||
// override any UI that wants to PrintPreview any selection
|
||||
PRInt16 printRangeType = nsIPrintSettings::kRangeAllPages;
|
||||
|
@ -6603,28 +6660,20 @@ DocumentViewerImpl::SetDocAndURLIntoProgress(PrintObject* aPO,
|
|||
docURLStr = ToNewUnicode(newURLStr);
|
||||
}
|
||||
|
||||
mPrt->mPrintProgressParams->SetDocTitle((const PRUnichar*) docTitleStr);
|
||||
mPrt->mPrintProgressParams->SetDocURL((const PRUnichar*) docURLStr);
|
||||
aParams->SetDocTitle((const PRUnichar*) docTitleStr);
|
||||
aParams->SetDocURL((const PRUnichar*) docURLStr);
|
||||
|
||||
if (docTitleStr != nsnull) nsMemory::Free(docTitleStr);
|
||||
if (docURLStr != nsnull) nsMemory::Free(docURLStr);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Set up to use the "pluggable" Print Progress Dialog
|
||||
void
|
||||
DocumentViewerImpl::DoPrintProgress(PRBool aIsForPrinting)
|
||||
{
|
||||
nsPrintProgress* prtProgress = new nsPrintProgress();
|
||||
nsresult rv = prtProgress->QueryInterface(NS_GET_IID(nsIPrintProgress), (void**)getter_AddRefs(mPrt->mPrintProgress));
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
|
||||
rv = prtProgress->QueryInterface(NS_GET_IID(nsIWebProgressListener), (void**)getter_AddRefs(mPrt->mPrintProgressListener));
|
||||
if (NS_FAILED(rv)) return;
|
||||
// add to listener list
|
||||
mPrt->mPrintProgressListeners.AppendElement((void*)mPrt->mPrintProgressListener);
|
||||
nsIWebProgressListener* wpl = NS_STATIC_CAST(nsIWebProgressListener*, mPrt->mPrintProgressListener.get());
|
||||
NS_ASSERTION(wpl, "nsIWebProgressListener is NULL!");
|
||||
NS_ADDREF(wpl);
|
||||
// Assume we can't do progress and then see if we can
|
||||
mPrt->mShowProgressDialog = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIPref> prefs (do_GetService(NS_PREF_CONTRACTID));
|
||||
if (prefs) {
|
||||
|
@ -6638,21 +6687,29 @@ DocumentViewerImpl::DoPrintProgress(PRBool aIsForPrinting)
|
|||
mPrt->mPrintSettings->GetShowPrintProgress(&mPrt->mShowProgressDialog);
|
||||
}
|
||||
|
||||
if (mPrt->mShowProgressDialog) {
|
||||
nsPrintProgressParams* prtProgressParams = new nsPrintProgressParams();
|
||||
nsCOMPtr<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);
|
||||
// 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;
|
||||
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
|
||||
if (wwatch) {
|
||||
nsCOMPtr<nsIDOMWindow> active;
|
||||
wwatch->GetActiveWindow(getter_AddRefs(active));
|
||||
// If we don't get a service, that's ok, then just don't show progress
|
||||
if (mPrt->mShowProgressDialog) {
|
||||
PRBool notifyOnOpen;
|
||||
nsresult rv = printPromptService->ShowProgress(domWin, this, mPrt->mPrintSettings, nsnull, getter_AddRefs(mPrt->mPrintProgressListener), getter_AddRefs(mPrt->mPrintProgressParams), ¬ifyOnOpen);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mPrt->mShowProgressDialog = mPrt->mPrintProgressListener != nsnull && mPrt->mPrintProgressParams != nsnull;
|
||||
|
||||
PRBool notifyOnOpen;
|
||||
nsCOMPtr<nsIDOMWindowInternal> parent(do_QueryInterface(active));
|
||||
mPrt->mPrintProgress->OpenProgressDialog(parent, "chrome://global/content/printProgress.xul", mPrt->mPrintProgressParams, nsnull, ¬ifyOnOpen);
|
||||
if (mPrt->mShowProgressDialog) {
|
||||
mPrt->mPrintProgressListeners.AppendElement((void*)mPrt->mPrintProgressListener);
|
||||
nsIWebProgressListener* wpl = NS_STATIC_CAST(nsIWebProgressListener*, mPrt->mPrintProgressListener.get());
|
||||
NS_ASSERTION(wpl, "nsIWebProgressListener is NULL!");
|
||||
NS_ADDREF(wpl);
|
||||
SetDocAndURLIntoProgress(mPrt->mPrintObject, mPrt->mPrintProgressParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6687,6 +6744,7 @@ DocumentViewerImpl::Print(PRBool aSilent,
|
|||
NS_ASSERTION(printSettings, "You can't PrintPreview without a PrintSettings!");
|
||||
}
|
||||
if (printSettings) printSettings->SetPrintSilent(aSilent);
|
||||
if (printSettings) printSettings->SetShowPrintProgress(PR_FALSE);
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -6750,9 +6808,9 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings,
|
|||
ShowPrintErrorDialog(rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
mPrt = new PrintData();
|
||||
if (mPrt == nsnull) {
|
||||
|
||||
mPrt = new PrintData(PrintData::eIsPrinting);
|
||||
if (!mPrt) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -6889,14 +6947,55 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings,
|
|||
mPrt->mDebugFilePtr = mDebugFile;
|
||||
#endif
|
||||
|
||||
// we have to turn off printpreview mode for now.. because this is a real request to print.
|
||||
if (mIsDoingPrintPreview) {
|
||||
aPrintSettings->SetIsPrintPreview(PR_FALSE);
|
||||
}
|
||||
|
||||
PRBool printSilently;
|
||||
mPrt->mPrintSettings->GetPrintSilent(&printSilently);
|
||||
rv = factory->CreateDeviceContextSpec(mWindow, mPrt->mPrintSettings, *getter_AddRefs(devspec), printSilently);
|
||||
|
||||
// Ask dialog to be Print Shown via the Plugable Printing Dialog Service
|
||||
// This service is for the Print Dialog and the Print Progress Dialog
|
||||
// If printing silently or you can't get the service continue on
|
||||
if (!printSilently) {
|
||||
nsCOMPtr<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;
|
||||
}
|
||||
|
||||
// Create DeviceSpec for Printing
|
||||
rv = factory->CreateDeviceContextSpec(mWindow, mPrt->mPrintSettings, *getter_AddRefs(devspec), PR_FALSE);
|
||||
|
||||
// If the page was intended to be destroyed while we were in the print dialog
|
||||
// then we need to clean up and abort the printing.
|
||||
|
@ -7020,76 +7119,43 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings,
|
|||
}
|
||||
}
|
||||
|
||||
if (mPrt->mPrintOptions) {
|
||||
// check to see if we are printing to a file
|
||||
PRBool isPrintToFile = PR_FALSE;
|
||||
mPrt->mPrintSettings->GetPrintToFile(&isPrintToFile);
|
||||
if (isPrintToFile) {
|
||||
// On some platforms The BeginDocument needs to know the name of the file
|
||||
// Get the Needed info for Calling PrepareDocument
|
||||
PRUnichar* fileName = nsnull;
|
||||
// check to see if we are printing to a file
|
||||
PRBool isPrintToFile = PR_FALSE;
|
||||
mPrt->mPrintSettings->GetPrintToFile(&isPrintToFile);
|
||||
if (isPrintToFile) {
|
||||
// On some platforms The PrepareDocument needs to know the name of the file
|
||||
// and it uses the PrintService to get it, so we need to set it into the PrintService here
|
||||
PRUnichar* fileName;
|
||||
mPrt->mPrintSettings->GetToFileName(&fileName);
|
||||
if (fileName != nsnull) {
|
||||
mPrt->mPrintOptions->SetPrintToFile(PR_TRUE);
|
||||
mPrt->mPrintOptions->SetToFileName(fileName);
|
||||
nsMemory::Free(fileName);
|
||||
}
|
||||
} else {
|
||||
mPrt->mPrintOptions->SetPrintToFile(PR_FALSE);
|
||||
mPrt->mPrintOptions->SetToFileName(nsnull);
|
||||
}
|
||||
mPrt->mPrintSettings->GetToFileName(&fileName);
|
||||
}
|
||||
|
||||
PRUnichar * docTitleStr;
|
||||
PRUnichar * docURLStr;
|
||||
GetDisplayTitleAndURL(mPrt->mPrintObject, mPrt->mPrintSettings,
|
||||
mPrt->mBrandName, &docTitleStr, &docURLStr,
|
||||
eDocTitleDefURLDoc);
|
||||
|
||||
// BeginDocument may pass back a FAILURE code
|
||||
// i.e. On Windows, if you are printing to a file and hit "Cancel"
|
||||
// to the "File Name" dialog, this comes back as an error
|
||||
// Don't start printing when regression test are executed
|
||||
rv = mPrt->mDebugFilePtr ? NS_OK: mPrt->mPrintDC->BeginDocument(docTitleStr);
|
||||
PRINT_DEBUG_MSG1("****************** Begin Document ************************\n");
|
||||
GetDisplayTitleAndURL(mPrt->mPrintObject, mPrt->mPrintSettings, mPrt->mBrandName, &docTitleStr, &docURLStr, eDocTitleDefURLDoc);
|
||||
|
||||
rv = mPrt->mPrintDC->PrepareDocument(docTitleStr, fileName);
|
||||
|
||||
if (docTitleStr) nsMemory::Free(docTitleStr);
|
||||
if (docURLStr) nsMemory::Free(docURLStr);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
DoPrintProgress(PR_TRUE);
|
||||
|
||||
DoPrintProgress(PR_TRUE);
|
||||
|
||||
// Print listener setup...
|
||||
if (mPrt != nsnull) {
|
||||
mPrt->OnStartPrinting();
|
||||
}
|
||||
|
||||
//
|
||||
// The mIsPrinting flag is set when the ImageGroup observer is
|
||||
// notified that images must be loaded as a result of the
|
||||
// InitialReflow...
|
||||
//
|
||||
if(!mIsPrinting || mPrt->mDebugFilePtr) {
|
||||
rv = DocumentReadyForPrinting();
|
||||
PRINT_DEBUG_MSG1("PRINT JOB ENDING, OBSERVER WAS NOT CALLED\n");
|
||||
} else {
|
||||
// use the observer mechanism to finish the printing
|
||||
PRINT_DEBUG_MSG1("PRINTING OBSERVER STARTED\n");
|
||||
}
|
||||
// Print listener setup...
|
||||
if (mPrt != nsnull) {
|
||||
mPrt->OnStartPrinting();
|
||||
}
|
||||
|
||||
rv = DocumentReadyForPrinting();
|
||||
PRINT_DEBUG_MSG1("PRINT JOB ENDING, OBSERVER WAS NOT CALLED\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mPrt->mPrintSettings->SetIsCancelled(PR_TRUE);
|
||||
mPrt->mPrintOptions->SetIsCancelled(PR_TRUE);
|
||||
}
|
||||
|
||||
// Set that we are once again in print preview
|
||||
if (mIsDoingPrintPreview) {
|
||||
aPrintSettings->SetIsPrintPreview(PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/* cleaup on failure + notify user */
|
||||
|
@ -7175,6 +7241,8 @@ DocumentViewerImpl::ShowPrintErrorDialog(nsresult aPrintError, PRBool aIsPrintin
|
|||
NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTER_XPRINT_BROKEN_XPRT)
|
||||
NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTER_DOC_IS_BUSY_PP)
|
||||
NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTER_DOC_WAS_DESTORYED)
|
||||
NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_NO_PRINTDIALOG_IN_TOOLKIT)
|
||||
NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_NO_PRINTROMPTSERVICE)
|
||||
NS_ERROR_TO_LOCALIZED_PRINT_ERROR_MSG(NS_ERROR_GFX_PRINTER_NO_XUL) // Temporary code for Bug 136185
|
||||
|
||||
default:
|
||||
|
@ -8299,12 +8367,10 @@ DocumentViewerImpl::GetCurrentPrintSettings(nsIPrintSettings * *aCurrentPrintSet
|
|||
NS_IMETHODIMP
|
||||
DocumentViewerImpl::Cancel()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrintOptions> printService = do_GetService(kPrintOptionsCID, &rv);
|
||||
if (NS_SUCCEEDED(rv) && printService) {
|
||||
return printService->SetIsCancelled(PR_TRUE);
|
||||
if (mPrt && mPrt->mPrintSettings) {
|
||||
return mPrt->mPrintSettings->SetIsCancelled(PR_TRUE);
|
||||
}
|
||||
return NS_OK;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
/* void initPrintSettingsFromPrefs (in nsIPrintSettings aPrintSettings, in boolean aUsePrinterNamePrefix, in unsigned long aFlags); */
|
||||
|
|
|
@ -131,7 +131,9 @@ public:
|
|||
* @see nsIPrintStatusCallback#OnProgress()
|
||||
*/
|
||||
NS_IMETHOD StartPrint(nsIPresContext* aPresContext,
|
||||
nsIPrintSettings* aPrintOptions) = 0;
|
||||
nsIPrintSettings* aPrintOptions,
|
||||
PRUnichar* aDocTitle,
|
||||
PRUnichar* aDocURL) = 0;
|
||||
NS_IMETHOD PrintNextPage(nsIPresContext* aPresContext) = 0;
|
||||
NS_IMETHOD GetCurrentPageNum(PRInt32* aPageNum) = 0;
|
||||
NS_IMETHOD GetNumPages(PRInt32* aNumPages) = 0;
|
||||
|
|
|
@ -131,7 +131,9 @@ public:
|
|||
* @see nsIPrintStatusCallback#OnProgress()
|
||||
*/
|
||||
NS_IMETHOD StartPrint(nsIPresContext* aPresContext,
|
||||
nsIPrintSettings* aPrintOptions) = 0;
|
||||
nsIPrintSettings* aPrintOptions,
|
||||
PRUnichar* aDocTitle,
|
||||
PRUnichar* aDocURL) = 0;
|
||||
NS_IMETHOD PrintNextPage(nsIPresContext* aPresContext) = 0;
|
||||
NS_IMETHOD GetCurrentPageNum(PRInt32* aPageNum) = 0;
|
||||
NS_IMETHOD GetNumPages(PRInt32* aNumPages) = 0;
|
||||
|
|
|
@ -410,17 +410,13 @@ nsPageFrame::ProcessSpecialCodes(const nsString& aStr, nsString& aNewStr)
|
|||
|
||||
NS_NAMED_LITERAL_STRING(kTitle, "&T");
|
||||
if (aStr.Find(kTitle) != kNotFound) {
|
||||
nsXPIDLString uTitle;
|
||||
mPD->mPrintOptions->GetTitle(getter_Copies(uTitle));
|
||||
SubstValueForCode(aNewStr, kTitle.get(), uTitle.get());
|
||||
SubstValueForCode(aNewStr, kTitle.get(), mPD->mDocTitle);
|
||||
return;
|
||||
}
|
||||
|
||||
NS_NAMED_LITERAL_STRING(kDocURL, "&U");
|
||||
if (aStr.Find(kDocURL) != kNotFound) {
|
||||
nsXPIDLString uDocURL;
|
||||
mPD->mPrintOptions->GetDocURL(getter_Copies(uDocURL));
|
||||
SubstValueForCode(aNewStr, kDocURL.get(), uDocURL.get());
|
||||
SubstValueForCode(aNewStr, kDocURL.get(), mPD->mDocURL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,6 +111,8 @@ nsSharedPageData::nsSharedPageData() :
|
|||
mHeadFootFont(nsnull),
|
||||
mPageNumFormat(nsnull),
|
||||
mPageNumAndTotalsFormat(nsnull),
|
||||
mDocTitle(nsnull),
|
||||
mDocURL(nsnull),
|
||||
mReflowRect(0,0,0,0),
|
||||
mReflowMargin(0,0,0,0),
|
||||
mShadowSize(0,0),
|
||||
|
@ -126,6 +128,8 @@ nsSharedPageData::~nsSharedPageData()
|
|||
if (mHeadFootFont) delete mHeadFootFont;
|
||||
nsMemory::Free(mPageNumFormat);
|
||||
nsMemory::Free(mPageNumAndTotalsFormat);
|
||||
if (mDocTitle) nsMemory::Free(mDocTitle);
|
||||
if (mDocURL) nsMemory::Free(mDocURL);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -660,8 +664,10 @@ nsIRegion* nsSimplePageSequenceFrame::CreateRegion()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSimplePageSequenceFrame::StartPrint(nsIPresContext* aPresContext,
|
||||
nsIPrintSettings* aPrintSettings)
|
||||
nsSimplePageSequenceFrame::StartPrint(nsIPresContext* aPresContext,
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
PRUnichar* aDocTitle,
|
||||
PRUnichar* aDocURL)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPresContext);
|
||||
NS_ENSURE_ARG_POINTER(aPrintSettings);
|
||||
|
@ -670,6 +676,10 @@ nsSimplePageSequenceFrame::StartPrint(nsIPresContext* aPresContext,
|
|||
mPageData->mPrintSettings = aPrintSettings;
|
||||
}
|
||||
|
||||
// Only set them if they are not null
|
||||
if (aDocTitle) mPageData->mDocTitle = aDocTitle;
|
||||
if (aDocURL) mPageData->mDocURL = aDocURL;
|
||||
|
||||
aPrintSettings->GetMarginInTwips(mMargin);
|
||||
|
||||
aPrintSettings->GetStartPageRange(&mFromPageNum);
|
||||
|
|
|
@ -55,6 +55,8 @@ public:
|
|||
nsFont * mHeadFootFont;
|
||||
PRUnichar * mPageNumFormat;
|
||||
PRUnichar * mPageNumAndTotalsFormat;
|
||||
PRUnichar * mDocTitle;
|
||||
PRUnichar * mDocURL;
|
||||
|
||||
nsRect mReflowRect;
|
||||
nsMargin mReflowMargin;
|
||||
|
@ -99,7 +101,9 @@ public:
|
|||
|
||||
// Async Printing
|
||||
NS_IMETHOD StartPrint(nsIPresContext* aPresContext,
|
||||
nsIPrintSettings* aPrintSettings);
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
PRUnichar* aDocTitle,
|
||||
PRUnichar* aDocURL);
|
||||
NS_IMETHOD PrintNextPage(nsIPresContext* aPresContext);
|
||||
NS_IMETHOD GetCurrentPageNum(PRInt32* aPageNum);
|
||||
NS_IMETHOD GetNumPages(PRInt32* aNumPages);
|
||||
|
|
|
@ -410,17 +410,13 @@ nsPageFrame::ProcessSpecialCodes(const nsString& aStr, nsString& aNewStr)
|
|||
|
||||
NS_NAMED_LITERAL_STRING(kTitle, "&T");
|
||||
if (aStr.Find(kTitle) != kNotFound) {
|
||||
nsXPIDLString uTitle;
|
||||
mPD->mPrintOptions->GetTitle(getter_Copies(uTitle));
|
||||
SubstValueForCode(aNewStr, kTitle.get(), uTitle.get());
|
||||
SubstValueForCode(aNewStr, kTitle.get(), mPD->mDocTitle);
|
||||
return;
|
||||
}
|
||||
|
||||
NS_NAMED_LITERAL_STRING(kDocURL, "&U");
|
||||
if (aStr.Find(kDocURL) != kNotFound) {
|
||||
nsXPIDLString uDocURL;
|
||||
mPD->mPrintOptions->GetDocURL(getter_Copies(uDocURL));
|
||||
SubstValueForCode(aNewStr, kDocURL.get(), uDocURL.get());
|
||||
SubstValueForCode(aNewStr, kDocURL.get(), mPD->mDocURL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,6 +111,8 @@ nsSharedPageData::nsSharedPageData() :
|
|||
mHeadFootFont(nsnull),
|
||||
mPageNumFormat(nsnull),
|
||||
mPageNumAndTotalsFormat(nsnull),
|
||||
mDocTitle(nsnull),
|
||||
mDocURL(nsnull),
|
||||
mReflowRect(0,0,0,0),
|
||||
mReflowMargin(0,0,0,0),
|
||||
mShadowSize(0,0),
|
||||
|
@ -126,6 +128,8 @@ nsSharedPageData::~nsSharedPageData()
|
|||
if (mHeadFootFont) delete mHeadFootFont;
|
||||
nsMemory::Free(mPageNumFormat);
|
||||
nsMemory::Free(mPageNumAndTotalsFormat);
|
||||
if (mDocTitle) nsMemory::Free(mDocTitle);
|
||||
if (mDocURL) nsMemory::Free(mDocURL);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -660,8 +664,10 @@ nsIRegion* nsSimplePageSequenceFrame::CreateRegion()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSimplePageSequenceFrame::StartPrint(nsIPresContext* aPresContext,
|
||||
nsIPrintSettings* aPrintSettings)
|
||||
nsSimplePageSequenceFrame::StartPrint(nsIPresContext* aPresContext,
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
PRUnichar* aDocTitle,
|
||||
PRUnichar* aDocURL)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPresContext);
|
||||
NS_ENSURE_ARG_POINTER(aPrintSettings);
|
||||
|
@ -670,6 +676,10 @@ nsSimplePageSequenceFrame::StartPrint(nsIPresContext* aPresContext,
|
|||
mPageData->mPrintSettings = aPrintSettings;
|
||||
}
|
||||
|
||||
// Only set them if they are not null
|
||||
if (aDocTitle) mPageData->mDocTitle = aDocTitle;
|
||||
if (aDocURL) mPageData->mDocURL = aDocURL;
|
||||
|
||||
aPrintSettings->GetMarginInTwips(mMargin);
|
||||
|
||||
aPrintSettings->GetStartPageRange(&mFromPageNum);
|
||||
|
|
|
@ -55,6 +55,8 @@ public:
|
|||
nsFont * mHeadFootFont;
|
||||
PRUnichar * mPageNumFormat;
|
||||
PRUnichar * mPageNumAndTotalsFormat;
|
||||
PRUnichar * mDocTitle;
|
||||
PRUnichar * mDocURL;
|
||||
|
||||
nsRect mReflowRect;
|
||||
nsMargin mReflowMargin;
|
||||
|
@ -99,7 +101,9 @@ public:
|
|||
|
||||
// Async Printing
|
||||
NS_IMETHOD StartPrint(nsIPresContext* aPresContext,
|
||||
nsIPrintSettings* aPrintSettings);
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
PRUnichar* aDocTitle,
|
||||
PRUnichar* aDocURL);
|
||||
NS_IMETHOD PrintNextPage(nsIPresContext* aPresContext);
|
||||
NS_IMETHOD GetCurrentPageNum(PRInt32* aPageNum);
|
||||
NS_IMETHOD GetNumPages(PRInt32* aNumPages);
|
||||
|
|
|
@ -80,8 +80,11 @@ NS_ERROR_GFX_PRINTER_DRIVER_CONFIGURATION_ERROR=There was a problem printing. Th
|
|||
NS_ERROR_GFX_PRINTER_XPRINT_BROKEN_XPRT=A broken version of the X print server (Xprt) has been detected. Note that printing using this Xprt server may not work properly. Please contact the server vendor for a fixed version.
|
||||
NS_ERROR_GFX_PRINTER_DOC_IS_BUSY_PP=The browser cannot print preview right now.\nPlease try again when the page has finished loading.
|
||||
NS_ERROR_GFX_PRINTER_DOC_WAS_DESTORYED=The page was replaced while you were trying to print.\nPlease try again.
|
||||
NS_ERROR_GFX_NO_PRINTDIALOG_IN_TOOLKIT=Either pluggable dialogs were not properly installed\nOr this GFX Toolkit no longer supports native Print Dialogs
|
||||
NS_ERROR_GFX_NO_PRINTROMPTSERVICE=The Printing Prompt Service is missing.
|
||||
NS_ERROR_GFX_PRINTER_NO_XUL=We are unable to Print or Print Preview this page.
|
||||
# No printers available
|
||||
noprinter=No printers available.
|
||||
PrintToFile=Print To File
|
||||
# EOF.
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
|
||||
// nsIDOMContextMenuListener
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
|
||||
NS_IMETHOD ContextMenu (nsIDOMEvent* aEvent) { printf("preventing ContextMenu\n"); aEvent->PreventDefault(); return NS_OK; }
|
||||
NS_IMETHOD ContextMenu (nsIDOMEvent* aEvent) { aEvent->PreventDefault(); return NS_OK; }
|
||||
|
||||
// nsIDOMKeyListener
|
||||
NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent);
|
||||
|
|
|
@ -3405,4 +3405,13 @@ NS_IMETHODIMP nsBrowserWindow::EnsureWebBrowserChrome()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsBrowserWindow::GetWindow(nsIWidget** aWindow)
|
||||
{
|
||||
if (aWindow && mWindow) {
|
||||
*aWindow = mWindow.get();
|
||||
NS_IF_ADDREF(*aWindow);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче