Add the new pluggable dialog work, in build, not used

BUg 135441 r=dcone,pink sr=attinasi
This commit is contained in:
rods%netscape.com 2002-05-02 12:38:43 +00:00
Родитель 5afae97bea
Коммит a1f21a54d5
118 изменённых файлов: 2748 добавлений и 6942 удалений

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

@ -688,6 +688,7 @@ sub BuildRuntimeDist()
InstallFromManifest(":mozilla:lib:mac:NSRuntime:include:MANIFEST", "$distdirectory:mac:common:");
InstallFromManifest(":mozilla:lib:mac:NSStdLib:include:MANIFEST", "$distdirectory:mac:common:");
InstallFromManifest(":mozilla:lib:mac:MoreFiles:MANIFEST", "$distdirectory:mac:common:morefiles:");
InstallFromManifest(":mozilla:lib:mac:NSStartup:MANIFEST", "$distdirectory:mac:common:");
#GC_LEAK_DETECTOR
InstallFromManifest(":mozilla:gc:boehm:MANIFEST", "$distdirectory:gc:");
@ -2107,6 +2108,11 @@ sub BuildEmbeddingProjects()
StartBuildModule("embedding");
# Since there are separate Carbon targets, but the name is the same.
unlink ":mozilla:embedding:components:printingui:macbuild:printingUI$D.o";
BuildProject(":mozilla:embedding:components:printingui:macbuild:printingUI.xml", "printingUI$C$D.o");
MakeAlias(":mozilla:embedding:components:printingui:macbuild:printingUI$D.o", ":mozilla:dist:embedding:components:");
BuildOneProject(":mozilla:embedding:components:build:macbuild:EmbedComponents.xml", "EmbedComponents$D.$S", 1, $main::ALIAS_SYM_FILES, 1);
BuildOneProject(":mozilla:embedding:browser:macbuild:webBrowser.xml", "webBrowser$D.$S", 1, $main::ALIAS_SYM_FILES, 1);

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

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

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

@ -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;
@ -6468,8 +6531,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 +6539,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 +6557,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 +6662,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,20 +6689,27 @@ 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
PRBool notifyOnOpen;
nsresult rv = printPromptService->ShowProgress(domWin, this, mPrt->mPrintSettings, nsnull, getter_AddRefs(mPrt->mPrintProgressListener), getter_AddRefs(mPrt->mPrintProgressParams), &notifyOnOpen);
if (NS_SUCCEEDED(rv)) {
mPrt->mShowProgressDialog = mPrt->mPrintProgressListener != nsnull && mPrt->mPrintProgressParams != nsnull;
nsCOMPtr<nsIDOMWindowInternal> parent(do_QueryInterface(active));
mPrt->mPrintProgress->OpenProgressDialog(parent, "chrome://global/content/printProgress.xul", mPrt->mPrintProgressParams);
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);
}
}
}
@ -6749,9 +6807,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;
}
@ -6888,14 +6946,65 @@ DocumentViewerImpl::Print(nsIPrintSettings* aPrintSettings,
mPrt->mDebugFilePtr = mDebugFile;
#endif
// we have to turn off printpreview mode for now.. because this is a real request to print.
if (mIsDoingPrintPreview) {
aPrintSettings->SetIsPrintPreview(PR_FALSE);
}
// we have to turn off printpreview mode for now.. because this is a real request to print.
if (mIsDoingPrintPreview) {
aPrintSettings->SetIsPrintPreview(PR_FALSE);
}
PRBool printSilently;
mPrt->mPrintSettings->GetPrintSilent(&printSilently);
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;
}
// we have to turn off printpreview mode for now.. because this is a real request to print.
if ( mIsDoingPrintPreview == PR_TRUE) {
aPrintSettings->SetIsPrintPreview(PR_FALSE);
}
// Create DeviceSpec for Printing
rv = factory->CreateDeviceContextSpec(mWindow, mPrt->mPrintSettings, *getter_AddRefs(devspec), PR_FALSE);
// 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.
@ -7019,70 +7128,42 @@ 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
@ -7174,6 +7255,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:
@ -8298,12 +8381,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);

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

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

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

@ -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>

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

@ -801,6 +801,20 @@
<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>
@ -868,6 +882,16 @@
<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>
@ -1618,6 +1642,20 @@
<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>
@ -1685,6 +1723,16 @@
<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>
@ -1773,6 +1821,18 @@
<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>

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

@ -1,32 +0,0 @@
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
# This is a list of local files which get copied to the mozilla:dist:editor directory
#
nsCWebBrowser.idl
nsIWebBrowser.idl
nsIWebBrowserChrome.idl
nsIWebBrowserChromeFocus.idl
nsIWebBrowserSetup.idl
nsIEmbeddingSiteWindow.idl
nsIWebBrowserFocus.idl
nsIWebBrowserPrint.idl
nsITooltipListener.idl
nsITooltipTextProvider.idl

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

@ -65,6 +65,8 @@ XPIDLSRCS = \
nsITooltipTextProvider.idl \
nsIWebBrowserFocus.idl \
nsIWebBrowserPrint.idl \
nsIPrintingPrompt.idl \
nsIPrintingPromptService.idl \
$(NULL)
CPPSRCS = \

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

@ -1,76 +0,0 @@
#!nmake
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Mozilla browser.
#
# The Initial Developer of the Original Code is Netscape
# Communications, Inc. Portions created by Netscape are
# Copyright (C) 1999, Mozilla. All Rights Reserved.
#
# Contributor(s):
# Travis Bogard <travis@netscape.com>
DEPTH=..\..\..
MODULE=webBrowser_core
REQUIRES = xpcom \
string \
docshell \
widget \
layout \
dom \
js \
necko \
uriloader \
shistory \
webshell \
windowwatcher \
gfx \
content \
history \
webbrowserpersist \
unicharutil \
$(NULL)
EXPORTS = \
nsCTooltipTextProvider.h \
$(NULL)
XPIDLSRCS= \
.\nsIContextMenuListener.idl \
.\nsITooltipListener.idl \
.\nsITooltipTextProvider.idl \
.\nsCWebBrowser.idl \
.\nsIWebBrowser.idl \
.\nsIWebBrowserChrome.idl \
.\nsIWebBrowserChromeFocus.idl \
.\nsICommandHandler.idl \
.\nsIWebBrowserSetup.idl \
.\nsIEmbeddingSiteWindow.idl \
.\nsIEmbeddingSiteWindow2.idl \
.\nsIWebBrowserFocus.idl \
.\nsIWebBrowserPrint.idl \
$(NULL)
LIBRARY_NAME=nsWebBrowser_s
CPP_OBJS= \
.\$(OBJDIR)\nsDocShellTreeOwner.obj \
.\$(OBJDIR)\nsWebBrowser.obj \
.\$(OBJDIR)\nsCommandHandler.obj \
.\$(OBJDIR)\nsWebBrowserContentPolicy.obj \
$(NULL)
include <$(DEPTH)\config\rules.mak>
include <$(DEPTH)\config\config.mak>
libs:: $(LIBRARY)
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib

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

@ -0,0 +1,189 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
* @status UNDER_REVIEW
*/
/**
* This is the printing prompt interface which can be used without knowlege of a
* parent window. The parentage is hidden by the GetInterface though
* which it is gotten. This interface is identical to nsIPintingPromptService
* but without the parent nsIDOMWindow parameter. See nsIPrintingPromptService
* for all documentation.
*/
#include "nsISupports.idl"
#include "nsIWebBrowserPrint.idl"
#include "nsIWebProgressListener.idl"
#include "nsIPrintSettings.idl"
#include "nsIPrintProgressParams.idl"
#include "nsIObserver.idl"
[scriptable, uuid(44E314CA-75B1-4f3d-9553-9B3507912108)]
interface nsIPrintingPrompt : nsISupports
{
/**
* This service enables embedders to implement their own Print and Progress Dialogs.
* Each platform has a "base" or "basckstop" implementation of the service. The
* service is automatically registered at start up.
*
* Historically, platform toolkits with native dialogs have implemented them in the GFX layer
* Usually they were displayed when a new DeviceContextSpec specific to that platform
* was created.
*
* Windows: The GFX layer no longers supports default toolkit behavior for displaying the
* native Print Dialog.
* If an embedder implemented service returns any error code (other than NS_ERROR_ABORT)
* printing will terminate.
*
* Returning NS_OK assumes that the PrintSettings object was correctly filled in and
* if it does not have valid fields for printer name, etc. it may also terminate.
*
* Defaults for platform service:
* showPrintDialog - displays a native dialog
* showPageSetup - displays a XUL dialog
* showProgress - displays a XUL dialog
* showPrinterProperties - n/a
*
* Summary for Windows Embedders:
* Stated once again: There is no "fallback" native platform support in GFX for the
* displaying of the native print dialog. The current default implementation for Windows
* display a native print dialog but a XUL-based progress dialog.
* If you wish to have a native progress dialog on Windows you will have to create and
* register your own service.
*
* Note: The Windows version Mozilla implements this service which is
* automatically built and registered for you. You can use it as an example.
* It is located at "mozilla/embedding/components/printingui/src/win". That service
* is capable of displaying a native print dialog and a XUL progress dialog.
*
* To fly your own dialog you may:
*
* 1) Implement this service to display at least the Print Dialog and a Print Progress Dialog
* or you may implement just one of the dialogs and pass back NS_ERROR_NOT_IMPLEMENTED
* for any of the others.
*
* 2) For the Print Dialog:
* You may stub out this service by having all the methods return NS_ERROR_NOT_IMPLEMENTED.
* You can then fly you own dialog and then properly fill in the PrintSettings object
* before calling nsIWebBrowserPrint's Print method. If you stub out this service
* you MUST set "printSilent" to true, if you do not, Printing will terminate and an
* error dialog will be displayed.
*
* Mac: The GFX layer still supports default toolkit behavior for displaying the Print Dialog.
* If an embedder implemented service returns NS_ERROR_NOT_IMPLEMENTED for "showPrintDialog"
* The toolkit will display the native print dialog.
*
* Defaults for platform service:
* Mac OS9: showPrintDialog - displays a native dialog
* showPageSetup - displays a native dialog
* showProgress - displays a XUL dialog
* showPrinterProperties - n/a
*
* Mac OSX: showPrintDialog - displays a native dialog
* showPageSetup - displays a native dialog
* showProgress - not implemented (provided by OS)
* showPrinterProperties - n/a
*
* GTK: There are no native dialog for GTK.
*
* Defaults for platform service:
* showPrintDialog - displays a XUL dialog
* showPageSetup - displays a XUL dialog
* showProgress - displays a XUL dialog
* showPrinterProperties - displays a XUL dialog
*
* OS2:
*
* Defaults for platform service:
* showPrintDialog - displays a XUL dialog
* showPageSetup - displays a XUL dialog
* showProgress - displays a XUL dialog
* showPrinterProperties - displays a native dialog
*
*
*/
/**
* Show the Print Dialog
*
* @param webBrowserPrint - represents the document to be printed
* @param printSettings - PrintSettings for print "job"
*
*/
void showPrintDialog(in nsIWebBrowserPrint webBrowserPrint,
in nsIPrintSettings printSettings);
/**
* Shows the print progress dialog
*
* @param webBrowserPrint - represents the document to be printed
* @param printSettings - PrintSettings for print "job"
* @param openDialogObserver - an observer that will be notifed when the dialog is opened
* @param webProgressListener - additional listener can be registered for progress notifications
* @param printProgressParams - parameter object for passing progress state
* @param notifyOnOpen - this indicates that the observer will be notified when the progress
* dialog has been opened
*/
void showProgress(in nsIWebBrowserPrint webBrowserPrint,
in nsIPrintSettings printSettings,
in nsIObserver openDialogObserver,
out nsIWebProgressListener webProgressListener,
out nsIPrintProgressParams printProgressParams,
out boolean notifyOnOpen);
/**
* Shows the print progress dialog
*
* @param printSettings - PrintSettings for page setup (required)
*/
void showPageSetup(in nsIPrintSettings printSettings);
/**
* Sometimes platforms need to bring up a special properties dialog for showing
* print specific properties. Although the PrintSettings has a place to set the
* printer name, here is is an argument to be clear as to what printer is being
* asked to have the properties set for it. The Printer name in the PS is ignored.
*
* @param printerName - name of printer (required)
* @param printSettings - PrintSettings for page setup (required)
*/
void showPrinterProperties(in wstring printerName,
in nsIPrintSettings printSettings);
};

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

@ -0,0 +1,199 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* Doc interface here */
#include "nsISupports.idl"
#include "nsIWebBrowserPrint.idl"
#include "nsIWebProgressListener.idl"
#include "nsIPrintProgressParams.idl"
#include "nsIPrintSettings.idl"
#include "nsIObserver.idl"
interface nsIDOMWindow;
[scriptable, uuid(75D1553D-63BF-4b5d-A8F7-E4E4CAC21BA4)]
interface nsIPrintingPromptService : nsISupports
{
/**
* This service enables embedders to implement their own Print and Progress Dialogs.
* Each platform has a "base" or "basckstop" implementation of the service. The
* service is automatically registered at start up.
*
* Historically, platform toolkits with native dialogs have implemented them in the GFX layer
* Usually they were displayed when a new DeviceContextSpec specific to that platform
* was created.
*
* Windows: The GFX layer no longers supports default toolkit behavior for displaying the
* native Print Dialog.
* If an embedder implemented service returns any error code (other than NS_ERROR_ABORT)
* printing will terminate.
*
* Returning NS_OK assumes that the PrintSettings object was correctly filled in and
* if it does not have valid fields for printer name, etc. it may also terminate.
*
* Defaults for platform service:
* showPrintDialog - displays a native dialog
* showPageSetup - displays a XUL dialog
* showProgress - displays a XUL dialog
* showPrinterProperties - n/a
*
* Summary for Windows Embedders:
* Stated once again: There is no "fallback" native platform support in GFX for the
* displaying of the native print dialog. The current default implementation for Windows
* display a native print dialog but a XUL-based progress dialog.
* If you wish to have a native progress dialog on Windows you will have to create and
* register your own service.
*
* Note: The Windows version Mozilla implements this service which is
* automatically built and registered for you. You can use it as an example.
* It is located at "mozilla/embedding/components/printingui/src/win". That service
* is capable of displaying a native print dialog and a XUL progress dialog.
*
* To fly your own dialog you may:
*
* 1) Implement this service to display at least the Print Dialog and a Print Progress Dialog
* or you may implement just one of the dialogs and pass back NS_ERROR_NOT_IMPLEMENTED
* for any of the others.
*
* 2) For the Print Dialog:
* You may stub out this service by having all the methods return NS_ERROR_NOT_IMPLEMENTED.
* You can then fly you own dialog and then properly fill in the PrintSettings object
* before calling nsIWebBrowserPrint's Print method. If you stub out this service
* you MUST set "printSilent" to true, if you do not, Printing will terminate and an
* error dialog will be displayed.
*
* Mac: The GFX layer still supports default toolkit behavior for displaying the Print Dialog.
* If an embedder implemented service returns NS_ERROR_NOT_IMPLEMENTED for "showPrintDialog"
* The toolkit will display the native print dialog.
*
* Defaults for platform service:
* Mac OS9: showPrintDialog - displays a native dialog
* showPageSetup - displays a native dialog
* showProgress - displays a XUL dialog
* showPrinterProperties - n/a
*
* Mac OSX: showPrintDialog - displays a native dialog
* showPageSetup - displays a native dialog
* showProgress - not implemented (provided by OS)
* showPrinterProperties - n/a
*
* GTK: There are no native dialog for GTK.
*
* Defaults for platform service:
* showPrintDialog - displays a XUL dialog
* showPageSetup - displays a XUL dialog
* showProgress - displays a XUL dialog
* showPrinterProperties - displays a XUL dialog
*
* OS2:
*
* Defaults for platform service:
* showPrintDialog - displays a XUL dialog
* showPageSetup - displays a XUL dialog
* showProgress - displays a XUL dialog
* showPrinterProperties - displays a native dialog
*
*
*/
/**
* Show the Print Dialog
*
* @param parent - a DOM windows the dialog will be parented to (required)
* @param webBrowserPrint - represents the document to be printed (required)
* @param printSettings - PrintSettings for print "job" (required)
*
*/
void showPrintDialog(in nsIDOMWindow parent,
in nsIWebBrowserPrint webBrowserPrint,
in nsIPrintSettings printSettings);
/**
* Shows the print progress dialog
*
* @param parent - a DOM windows the dialog will be parented to
* @param webBrowserPrint - represents the document to be printed
* @param printSettings - PrintSettings for print "job"
* @param openDialogObserver - an observer that will be notifed when the dialog is opened
* @param webProgressListener - additional listener can be registered for progress notifications
* @param printProgressParams - parameter object for passing progress state
* @param notifyOnOpen - this indicates that the observer will be notified when the progress
* dialog has been opened
*/
void showProgress(in nsIDOMWindow parent,
in nsIWebBrowserPrint webBrowserPrint,
in nsIPrintSettings printSettings,
in nsIObserver openDialogObserver,
out nsIWebProgressListener webProgressListener,
out nsIPrintProgressParams printProgressParams,
out boolean notifyOnOpen);
/**
* Shows the print progress dialog
*
* @param parent - a DOM windows the dialog will be parented to (required)
* @param printSettings - PrintSettings for page setup (required)
*/
void showPageSetup(in nsIDOMWindow parent,
in nsIPrintSettings printSettings);
/**
* Sometimes platforms need to bring up a special properties dialog for showing
* print specific properties. Although the PrintSettings has a place to set the
* printer name, here is is an argument to be clear as to what printer is being
* asked to have the properties set for it. The Printer name in the PS is ignored.
*
* @param parent - a DOM windows the dialog will be parented to (required)
* @param printerName - name of printer (required)
* @param printSettings - PrintSettings for page setup (required)
*/
void showPrinterProperties(in nsIDOMWindow parent,
in wstring printerName,
in nsIPrintSettings printSettings);
};
%{C++
// {260FEDC5-524D-4aa6-9A41-E829F4C78B92}
#define NS_PRINTINGPROMPTSERVICE_IID \
{0x260fedc5, 0x524d, 0x4aa6, { 0x9a, 0x41, 0xe8, 0x29, 0xf4, 0xc7, 0x8b, 0x92}}
%}

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

@ -24,6 +24,6 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = windowwatcher appstartup find ui jsconsole webbrowserpersist commandhandler build
DIRS = windowwatcher appstartup find ui printingui jsconsole webbrowserpersist commandhandler build
include $(topsrcdir)/config/rules.mk

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

@ -39,6 +39,9 @@ REQUIRES = js \
xpcom \
string \
windowwatcher \
printingui \
webbrwsr \
gfx \
webbrowserpersist \
jsconsole \
find \
@ -59,6 +62,7 @@ CPPSRCS = nsModule.cpp
SHARED_LIBRARY_LIBS = \
$(DIST)/lib/$(LIB_PREFIX)windowwatcher_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)printingui_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)appstartupnotifier_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)jsconsole_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)find_s.$(LIB_SUFFIX) \
@ -75,6 +79,33 @@ LOCAL_INCLUDES = \
-I$(srcdir)/../commandhandler/src \
$(NULL)
ifeq ($(MOZ_GFX_TOOLKIT),os2)
LOCAL_INCLUDES += -I$(srcdir)/../printingui/src/os2
endif
ifeq ($(MOZ_GFX_TOOLKIT),gtk)
LOCAL_INCLUDES += -I$(srcdir)/../printingui/src/gtk
endif
ifeq ($(MOZ_GFX_TOOLKIT),beos)
LOCAL_INCLUDES += -I$(srcdir)/../printingui/src/gtk
endif
ifeq ($(MOZ_GFX_TOOLKIT),qt)
LOCAL_INCLUDES += -I$(srcdir)/../printingui/src/gtk
endif
ifeq ($(MOZ_GFX_TOOLKIT),windows)
LOCAL_INCLUDES += -I$(srcdir)/../printingui/src/win
OS_LIBS += winspool.lib comdlg32.lib
endif
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
LOCAL_INCLUDES += -I$(srcdir)/../printingui/src/mac
endif
EXTRA_DSO_LIBS = gkgfx
EXTRA_DSO_LDOPTS = \
$(LIBS_DIR) \
$(EXTRA_DSO_LIBS) \
@ -83,6 +114,12 @@ EXTRA_DSO_LDOPTS = \
$(MOZ_JS_LIBS) \
$(NULL)
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
EXTRA_DSO_LDOPTS += \
$(TK_LIBS) \
$(NULL)
endif
include $(topsrcdir)/config/rules.mk
ifeq ($(OS_ARCH),WINNT)

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

@ -85,6 +85,16 @@
<SETTING><NAME>FrameworkPath</NAME><VALUE>false</VALUE></SETTING>
<SETTING><NAME>HostFlags</NAME><VALUE>All</VALUE></SETTING>
</SETTING>
<SETTING>
<SETTING><NAME>SearchPath</NAME>
<SETTING><NAME>Path</NAME><VALUE>:::printingui:src:mac:</VALUE></SETTING>
<SETTING><NAME>PathFormat</NAME><VALUE>MacOS</VALUE></SETTING>
<SETTING><NAME>PathRoot</NAME><VALUE>Project</VALUE></SETTING>
</SETTING>
<SETTING><NAME>Recursive</NAME><VALUE>false</VALUE></SETTING>
<SETTING><NAME>FrameworkPath</NAME><VALUE>false</VALUE></SETTING>
<SETTING><NAME>HostFlags</NAME><VALUE>All</VALUE></SETTING>
</SETTING>
<SETTING>
<SETTING><NAME>SearchPath</NAME>
<SETTING><NAME>Path</NAME><VALUE>:::</VALUE></SETTING>
@ -752,9 +762,9 @@
<SETTING><NAME>MWLinker_PPC_dontdeadstripinitcode</NAME><VALUE>0</VALUE></SETTING>
<SETTING><NAME>MWLinker_PPC_permitmultdefs</NAME><VALUE>0</VALUE></SETTING>
<SETTING><NAME>MWLinker_PPC_linkmode</NAME><VALUE>Fast</VALUE></SETTING>
<SETTING><NAME>MWLinker_PPC_initname</NAME><VALUE>__NSInitialize</VALUE></SETTING>
<SETTING><NAME>MWLinker_PPC_initname</NAME><VALUE>__NSInitializeWithResources</VALUE></SETTING>
<SETTING><NAME>MWLinker_PPC_mainname</NAME><VALUE></VALUE></SETTING>
<SETTING><NAME>MWLinker_PPC_termname</NAME><VALUE>__NSTerminate</VALUE></SETTING>
<SETTING><NAME>MWLinker_PPC_termname</NAME><VALUE>__NSTerminateWithResources</VALUE></SETTING>
<!-- Settings for "PPC Mach-O Linker" panel -->
<SETTING><NAME>MWLinker_MachO_exports</NAME><VALUE>None</VALUE></SETTING>
@ -1077,6 +1087,13 @@
<FILEKIND>Library</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>printingUIDebug.o</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Library</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsCommandGroup.cpp</PATH>
@ -1105,6 +1122,13 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintDialogExtension.r</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
</FILELIST>
<LINKORDER>
<FILEREF>
@ -1207,6 +1231,11 @@
<PATH>UnicharUtilsStaticDebug.o</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>printingUIDebug.o</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsCommandGroup.cpp</PATH>
@ -1227,6 +1256,11 @@
<PATH>nsControllerCommandManager.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintDialogExtension.r</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
</LINKORDER>
</TARGET>
<TARGET>
@ -1261,6 +1295,16 @@
<SETTING><NAME>FrameworkPath</NAME><VALUE>false</VALUE></SETTING>
<SETTING><NAME>HostFlags</NAME><VALUE>All</VALUE></SETTING>
</SETTING>
<SETTING>
<SETTING><NAME>SearchPath</NAME>
<SETTING><NAME>Path</NAME><VALUE>:::printingui:src:mac:</VALUE></SETTING>
<SETTING><NAME>PathFormat</NAME><VALUE>MacOS</VALUE></SETTING>
<SETTING><NAME>PathRoot</NAME><VALUE>Project</VALUE></SETTING>
</SETTING>
<SETTING><NAME>Recursive</NAME><VALUE>false</VALUE></SETTING>
<SETTING><NAME>FrameworkPath</NAME><VALUE>false</VALUE></SETTING>
<SETTING><NAME>HostFlags</NAME><VALUE>All</VALUE></SETTING>
</SETTING>
<SETTING>
<SETTING><NAME>SearchPath</NAME>
<SETTING><NAME>Path</NAME><VALUE>:::</VALUE></SETTING>
@ -1928,9 +1972,9 @@
<SETTING><NAME>MWLinker_PPC_dontdeadstripinitcode</NAME><VALUE>0</VALUE></SETTING>
<SETTING><NAME>MWLinker_PPC_permitmultdefs</NAME><VALUE>0</VALUE></SETTING>
<SETTING><NAME>MWLinker_PPC_linkmode</NAME><VALUE>Fast</VALUE></SETTING>
<SETTING><NAME>MWLinker_PPC_initname</NAME><VALUE>__NSInitialize</VALUE></SETTING>
<SETTING><NAME>MWLinker_PPC_initname</NAME><VALUE>__NSInitializeWithResources</VALUE></SETTING>
<SETTING><NAME>MWLinker_PPC_mainname</NAME><VALUE></VALUE></SETTING>
<SETTING><NAME>MWLinker_PPC_termname</NAME><VALUE>__NSTerminate</VALUE></SETTING>
<SETTING><NAME>MWLinker_PPC_termname</NAME><VALUE>__NSTerminateWithResources</VALUE></SETTING>
<!-- Settings for "PPC Mach-O Linker" panel -->
<SETTING><NAME>MWLinker_MachO_exports</NAME><VALUE>None</VALUE></SETTING>
@ -2253,6 +2297,13 @@
<FILEKIND>Unknown</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>printingUI.o</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Unknown</FILEKIND>
<FILEFLAGS></FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsCommandGroup.cpp</PATH>
@ -2281,6 +2332,13 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintDialogExtension.r</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
</FILELIST>
<LINKORDER>
<FILEREF>
@ -2383,6 +2441,11 @@
<PATH>UnicharUtilsStatic.o</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>printingUI.o</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsCommandGroup.cpp</PATH>
@ -2403,6 +2466,11 @@
<PATH>nsControllerCommandManager.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintDialogExtension.r</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
</LINKORDER>
</TARGET>
</TARGETLIST>
@ -2513,6 +2581,14 @@
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
</GROUP>
<GROUP><NAME>Resources</NAME>
<FILEREF>
<TARGETNAME>EmbedComponentsDebug.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPrintDialogExtension.r</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
</GROUP>
<GROUP><NAME>Build</NAME>
<FILEREF>
<TARGETNAME>EmbedComponentsDebug.shlb</TARGETNAME>
@ -2522,18 +2598,34 @@
</FILEREF>
</GROUP>
<GROUP><NAME>Static Libs</NAME>
<FILEREF>
<TARGETNAME>EmbedComponents.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>UnicharUtilsStatic.o</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>EmbedComponentsDebug.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>UnicharUtilsStaticDebug.o</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<GROUP><NAME>Debug</NAME>
<FILEREF>
<TARGETNAME>EmbedComponentsDebug.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>UnicharUtilsStaticDebug.o</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>EmbedComponentsDebug.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>printingUIDebug.o</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
</GROUP>
<GROUP><NAME>Optimized</NAME>
<FILEREF>
<TARGETNAME>EmbedComponents.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>UnicharUtilsStatic.o</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>EmbedComponents.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>printingUI.o</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
</GROUP>
</GROUP>
<GROUP><NAME>NS Libraries</NAME>
<GROUP><NAME>Debug</NAME>

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

@ -26,6 +26,8 @@ REQUIRES = js \
string \
windowwatcher \
webbrowserpersist \
webBrowser_core \
gfx \
jsconsole \
find \
htmlparser \
@ -54,6 +56,7 @@ CPP_OBJS = \
SUB_LIBRARIES = \
$(DIST)\lib\windowwatcher_s.lib \
$(DIST)\lib\printingui_s.lib \
$(DIST)\lib\jsconsole_s.lib \
$(DIST)\lib\appstartupnotifier_s.lib \
$(DIST)\lib\find_s.lib \
@ -63,12 +66,19 @@ SUB_LIBRARIES = \
LLIBS = \
$(LIBNSPR) \
$(DIST)\lib\gkgfx.lib \
$(DIST)\lib\js3250.lib \
$(DIST)\lib\unicharutil_s.lib \
$(DIST)\lib\xpcom.lib \
$(NULL)
WIN_LIBS = \
comdlg32.lib \
winspool.lib \
$(NULL)
INCS = $(INCS) \
-I$(DEPTH)\embedding\components\printingui\src\gtk \
-I$(DEPTH)\embedding\components\windowwatcher\src \
-I$(DEPTH)\embedding\components\jsconsole\src \
-I$(DEPTH)\embedding\components\appstartup\src \

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

@ -49,6 +49,7 @@
#include "nsControllerCommandManager.h"
#include "nsCommandParams.h"
#include "nsCommandGroup.h"
#include "nsPrintingPromptService.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDialogParamBlock)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPromptService, Init)
@ -62,6 +63,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsControllerCommandManager)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCommandManager)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsCommandParams, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsControllerCommandGroup)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintingPromptService, Init)
static const nsModuleComponentInfo gComponents[] = {
@ -76,7 +78,8 @@ static const nsModuleComponentInfo gComponents[] = {
{ "Controller Command Manager", NS_CONTROLLERCOMMANDMANAGER_CID, NS_CONTROLLERCOMMANDMANAGER_CONTRACTID, nsControllerCommandManagerConstructor },
{ "Command Manager", NS_COMMAND_MANAGER_CID, NS_COMMAND_MANAGER_CONTRACTID, nsCommandManagerConstructor },
{ "Command Params", NS_COMMAND_PARAMS_CID, NS_COMMAND_PARAMS_CONTRACTID, nsCommandParamsConstructor },
{ "Command Group", NS_CONTROLLER_COMMAND_GROUP_CID, NS_CONTROLLER_COMMAND_GROUP_CONTRACTID, nsControllerCommandGroupConstructor }
{ "Command Group", NS_CONTROLLER_COMMAND_GROUP_CID, NS_CONTROLLER_COMMAND_GROUP_CONTRACTID, nsControllerCommandGroupConstructor },
{ "Printing Prompt Service", NS_PRINTINGPROMPTSERVICE_CID, NS_PRINTINGPROMPTSERVICE_CONTRACTID, nsPrintingPromptServiceConstructor }
};
NS_IMPL_NSGETMODULE(embedcomponents, gComponents)

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

@ -1,34 +0,0 @@
#!nmake
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications, Inc. Portions created by Netscape are
# Copyright (C) 2001, Mozilla. All Rights Reserved.
#
# Contributor(s):
DEPTH=..\..
DIRS= \
windowwatcher \
appstartup \
find \
commandhandler \
jsconsole \
ui \
webbrowserpersist \
build \
$(NULL)
include <$(DEPTH)\config\rules.mak>

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

@ -31,11 +31,13 @@ REQUIRES = xpcom \
dom \
windowwatcher \
widget \
gfx \
js \
xpconnect \
caps \
content \
necko \
uriloader \
docshell \
webbrwsr \
embed_base \
@ -47,6 +49,7 @@ CPPSRCS = nsDialogParamBlock.cpp \
nsPromptService.cpp \
nsWWJSUtils.cpp \
nsWindowWatcher.cpp \
nsPrintingPrompt.cpp \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a

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

@ -25,11 +25,13 @@ REQUIRES = xpcom \
string \
dom \
widget \
gfx \
js \
xpconnect \
caps \
content \
necko \
uriloader \
docshell \
webBrowser_core \
embed_base \
@ -44,6 +46,7 @@ CPP_OBJS= \
.\$(OBJDIR)\nsPromptService.obj \
.\$(OBJDIR)\nsWWJSUtils.obj \
.\$(OBJDIR)\nsWindowWatcher.obj \
.\$(OBJDIR)\nsPrintingPrompt.obj \
$(NULL)
include <$(DEPTH)\config\rules.mak>

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

@ -0,0 +1,112 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIServiceManager.h"
#include "nsPrintingPrompt.h"
#include "nsReadableUtils.h"
#include "nsIWebProgressListener.h"
nsresult
NS_NewPrintingPrompter(nsIPrintingPrompt **result, nsIDOMWindow *aParent)
{
nsresult rv;
*result = 0;
nsPrintingPrompt *prompter = new nsPrintingPrompt(aParent);
if (!prompter)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(prompter);
rv = prompter->Init();
if (NS_FAILED(rv)) {
NS_RELEASE(prompter);
return rv;
}
*result = prompter;
return NS_OK;
}
NS_IMPL_THREADSAFE_ISUPPORTS1(nsPrintingPrompt, nsIPrintingPrompt)
nsPrintingPrompt::nsPrintingPrompt(nsIDOMWindow *aParent)
: mParent(aParent)
{
NS_INIT_REFCNT();
}
nsresult
nsPrintingPrompt::Init()
{
mPromptService = do_GetService("@mozilla.org/embedcomp/printingprompt-service;1");
return mPromptService ? NS_OK : NS_ERROR_FAILURE;
}
//*****************************************************************************
// nsPrintingPrompt::nsIPrintingPrompt
//*****************************************************************************
/* void showPrintDialog (in nsIWebBrowserPrint webBrowserPrint, in nsIPrintSettings printSettings); */
NS_IMETHODIMP
nsPrintingPrompt::ShowPrintDialog(nsIWebBrowserPrint *webBrowserPrint, nsIPrintSettings *printSettings)
{
return mPromptService->ShowPrintDialog(mParent, webBrowserPrint, printSettings);
}
/* void showProgress (in nsIWebBrowserPrint webBrowserPrint, in nsIPrintSettings printSettings, out nsIWebProgressListener webProgressListener, out nsIPrintProgressParams printProgressParams); */
NS_IMETHODIMP
nsPrintingPrompt::ShowProgress(nsIWebBrowserPrint *webBrowserPrint, nsIPrintSettings *printSettings, nsIObserver *openDialogObserver, nsIWebProgressListener **webProgressListener, nsIPrintProgressParams** printProgressParams, PRBool* notifyOnOpen)
{
return mPromptService->ShowProgress(mParent, webBrowserPrint, printSettings, openDialogObserver, webProgressListener, printProgressParams, notifyOnOpen);
}
/* void showPageSetup (in nsIPrintSettings printSettings); */
NS_IMETHODIMP
nsPrintingPrompt::ShowPageSetup(nsIPrintSettings *printSettings)
{
return mPromptService->ShowPageSetup(mParent, printSettings);
}
/* void showPrinterProperties (in wstring printerName, in nsIPrintSettings printSettings); */
NS_IMETHODIMP
nsPrintingPrompt::ShowPrinterProperties(const PRUnichar *printerName, nsIPrintSettings *printSettings)
{
return mPromptService->ShowPrinterProperties(mParent, printerName, printSettings);
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

70
gfx/public/nsPDECommon.h Normal file
Просмотреть файл

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

107
gfx/public/nsWatchTask.h Normal file
Просмотреть файл

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

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

@ -55,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,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()
* - 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;
@ -350,88 +283,76 @@ NS_IMETHODIMP nsDeviceContextSpecGTK::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 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)

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

@ -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,6 +200,8 @@ NS_IMETHODIMP nsDeviceContextSpecX::GetPageRect(double* aTop, double* aLeft, dou
*aBottom = pageRect.bottom, *aRight = pageRect.right;
return NS_OK;
}
<<<<<<< nsDeviceContextSpecX.cpp
=======
@ -355,3 +254,4 @@ FSSpec spec;
return result;
}
>>>>>>> 1.19

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

@ -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();
@ -899,79 +897,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;

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

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

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

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

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

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

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

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

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

@ -88,7 +88,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,17 +254,17 @@ 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.
*/
NS_IMETHODIMP nsDeviceContextSpecOS2::Init(nsIPrintSettings* aPS, PRBool aQuiet)
NS_IMETHODIMP nsDeviceContextSpecOS2::Init(nsIPrintSettings* aPS, PRBool aPrintPreview)
{
nsresult rv = NS_ERROR_FAILURE;
@ -286,65 +281,46 @@ NS_IMETHODIMP nsDeviceContextSpecOS2::Init(nsIPrintSettings* aPS, PRBool aQuiet)
}
}
PRBool canPrint = PR_FALSE;
char *path;
PRBool tofile = PR_FALSE;
PRInt16 printRange = nsIPrintSettings::kRangeAllPages;
PRInt32 fromPage = 1;
PRInt32 toPage = 1;
PRInt32 copies = 1;
PRUnichar *printer = nsnull;
PRUnichar *printfile = nsnull;
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 (mPrintSettings) {
mPrintSettings->GetPrinterName(&printer);
mPrintSettings->GetPrintRange(&printRange);
mPrintSettings->GetToFileName(&printfile);
mPrintSettings->GetPrintToFile(&tofile);
mPrintSettings->GetStartPageRange(&fromPage);
mPrintSettings->GetEndPageRange(&toPage);
mPrintSettings->GetNumCopies(&copies);
nsCOMPtr<nsIPrintSettings> ps = aPS;
nsCOMPtr<nsISupports> psSupports(do_QueryInterface(ps));
NS_ASSERTION(psSupports, "PrintSettings must be a supports");
array->AppendElement(psSupports);
nsCOMPtr<nsIDialogParamBlock> ioParamBlock(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1"));
if (ioParamBlock) {
ioParamBlock->SetInt(0, 0);
nsCOMPtr<nsISupports> blkSupps(do_QueryInterface(ioParamBlock));
NS_ASSERTION(blkSupps, "IOBlk must be a supports");
array->AppendElement(blkSupps);
nsCOMPtr<nsISupports> arguments(do_QueryInterface(array));
NS_ASSERTION(array, "array must be a supports");
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
if (wwatch) {
nsCOMPtr<nsIDOMWindow> active;
wwatch->GetActiveWindow(getter_AddRefs(active));
nsCOMPtr<nsIDOMWindowInternal> parent = do_QueryInterface(active);
nsCOMPtr<nsIDOMWindow> newWindow;
rv = wwatch->OpenWindow(parent, "chrome://global/content/printdialog.xul",
"_blank", "chrome,modal,centerscreen", array,
getter_AddRefs(newWindow));
}
if ((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 (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());
}
<<<<<<< nsDeviceContextSpecOS2.cpp
mPrData.toPrinter = !tofile;
mPrData.copies = copies;
=======
if (canPrint) {
if (aPS) {
PRBool tofile = PR_FALSE;
@ -377,7 +353,13 @@ NS_IMETHODIMP nsDeviceContextSpecOS2::Init(nsIPrintSettings* aPS, PRBool aQuiet)
mPrData.toPrinter = !tofile;
mPrData.copies = copies;
>>>>>>> 1.12
<<<<<<< nsDeviceContextSpecOS2.cpp
rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
if (NS_FAILED(rv))
return rv;
=======
rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
if (NS_FAILED(rv))
return rv;
@ -392,7 +374,25 @@ NS_IMETHODIMP nsDeviceContextSpecOS2::Init(nsIPrintSettings* aPS, PRBool aQuiet)
}
}
}
>>>>>>> 1.12
<<<<<<< nsDeviceContextSpecOS2.cpp
const nsAFlatString& printerUCS2 = NS_ConvertUTF8toUCS2(mPrData.printer);
int numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters();
if (numPrinters) {
for(int i = 0; (i < numPrinters) && !mQueue; i++) {
if ((GlobalPrinters::GetInstance()->GetStringAt(i)->Equals(printerUCS2, nsCaseInsensitiveStringComparator())))
mQueue = PrnDlg.SetPrinterQueue(i);
}
}
if (printfile != nsnull)
nsMemory::Free(printfile);
if (printer != nsnull)
nsMemory::Free(printer);
=======
if (printfile != nsnull)
nsMemory::Free(printfile);
@ -400,6 +400,7 @@ NS_IMETHODIMP nsDeviceContextSpecOS2::Init(nsIPrintSettings* aPS, PRBool aQuiet)
nsMemory::Free(printer);
}
}
>>>>>>> 1.12
GlobalPrinters::GetInstance()->FreeGlobalPrinters();
return rv;

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

@ -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 \

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

@ -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);

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

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

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

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

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше