Bug 523323 - Restore the code from bug 312018 that was removed in bug 456646. r=josh

--HG--
extra : rebase_source : bdae0d890eda26a12425937b60ec7b6617f773fb
This commit is contained in:
Markus Stange 2009-11-02 20:23:53 +01:00
Родитель 8e7d53d318
Коммит dd8455c2da
7 изменённых файлов: 35 добавлений и 7 удалений

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

@ -78,7 +78,7 @@ nsPrintingPromptService::ShowPrintDialog(nsIDOMWindow *parent, nsIWebBrowserPrin
nsCOMPtr<nsIPrintDialogService> dlgPrint(do_GetService(
NS_PRINTDIALOGSERVICE_CONTRACTID));
if (dlgPrint)
return dlgPrint->Show(parent, printSettings);
return dlgPrint->Show(parent, printSettings, webBrowserPrint);
return NS_ERROR_FAILURE;

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

@ -114,7 +114,7 @@ nsPrintingPromptService::ShowPrintDialog(nsIDOMWindow *parent, nsIWebBrowserPrin
nsCOMPtr<nsIPrintDialogService> dlgPrint(do_GetService(
NS_PRINTDIALOGSERVICE_CONTRACTID));
if (dlgPrint)
return dlgPrint->Show(parent, printSettings);
return dlgPrint->Show(parent, printSettings, webBrowserPrint);
// Show the built-in dialog instead
ParamBlock block;

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

@ -42,6 +42,7 @@
class nsIDOMWindow;
class nsIPrintSettings;
class nsIWebBrowserPrint;
/*
* Interface to a print dialog accessed through the widget library.
@ -73,11 +74,14 @@ public:
* print dialog. On return, if the print operation should
* proceed then this contains settings for the print
* operation.
* @param aWebBrowserPrint A nsIWebBrowserPrint object that can be used for
* retreiving the title of the printed document.
* @return NS_OK if the print operation should proceed
* @return NS_ERROR_ABORT if the user indicated not to proceed
* @return a suitable error for failures to show the print dialog.
*/
NS_IMETHOD Show(nsIDOMWindow *aParent, nsIPrintSettings *aSettings) = 0;
NS_IMETHOD Show(nsIDOMWindow *aParent, nsIPrintSettings *aSettings,
nsIWebBrowserPrint *aWebBrowserPrint) = 0;
/**
* Show the page setup dialog. Note that there is no way to tell whether the

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

@ -57,7 +57,8 @@ public:
NS_DECL_ISUPPORTS
NS_IMETHODIMP Init();
NS_IMETHODIMP Show(nsIDOMWindow *aParent, nsIPrintSettings *aSettings);
NS_IMETHODIMP Show(nsIDOMWindow *aParent, nsIPrintSettings *aSettings,
nsIWebBrowserPrint *aWebBrowserPrint);
NS_IMETHODIMP ShowPageSetup(nsIDOMWindow *aParent,
nsIPrintSettings *aSettings);
};

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

@ -43,6 +43,8 @@
#include "nsServiceManagerUtils.h"
#include "nsIWebProgressListener.h"
#include "nsIStringBundle.h"
#include "nsIWebBrowserPrint.h"
#include "nsCRT.h"
#import <Cocoa/Cocoa.h>
#include "nsObjCExceptions.h"
@ -64,7 +66,8 @@ nsPrintDialogServiceX::Init()
}
NS_IMETHODIMP
nsPrintDialogServiceX::Show(nsIDOMWindow *aParent, nsIPrintSettings *aSettings)
nsPrintDialogServiceX::Show(nsIDOMWindow *aParent, nsIPrintSettings *aSettings,
nsIWebBrowserPrint *aWebBrowserPrint)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
@ -74,6 +77,24 @@ nsPrintDialogServiceX::Show(nsIDOMWindow *aParent, nsIPrintSettings *aSettings)
if (!settingsX)
return NS_ERROR_FAILURE;
// Set the print job title
PRUnichar** docTitles;
PRUint32 titleCount;
nsresult rv = aWebBrowserPrint->EnumerateDocumentNames(&titleCount, &docTitles);
if (NS_SUCCEEDED(rv) && titleCount > 0) {
CFStringRef cfTitleString = CFStringCreateWithCharacters(NULL, docTitles[0], nsCRT::strlen(docTitles[0]));
if (cfTitleString) {
::PMPrintSettingsSetJobName(settingsX->GetPMPrintSettings(), cfTitleString);
CFRelease(cfTitleString);
}
for (PRInt32 i = titleCount - 1; i >= 0; i--) {
NS_Free(docTitles[i]);
}
NS_Free(docTitles);
docTitles = NULL;
titleCount = 0;
}
NSPrintInfo* printInfo = settingsX->GetCocoaPrintInfo();
// Put the print info into the current print operation, since that's where

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

@ -568,7 +568,8 @@ nsPrintDialogServiceGTK::Init()
}
NS_IMETHODIMP
nsPrintDialogServiceGTK::Show(nsIDOMWindow *aParent, nsIPrintSettings *aSettings)
nsPrintDialogServiceGTK::Show(nsIDOMWindow *aParent, nsIPrintSettings *aSettings,
nsIWebBrowserPrint *aWebBrowserPrint)
{
NS_PRECONDITION(aParent, "aParent must not be null");
NS_PRECONDITION(aSettings, "aSettings must not be null");

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

@ -51,7 +51,8 @@ public:
NS_DECL_ISUPPORTS
NS_IMETHODIMP Init();
NS_IMETHODIMP Show(nsIDOMWindow *aParent, nsIPrintSettings *aSettings);
NS_IMETHODIMP Show(nsIDOMWindow *aParent, nsIPrintSettings *aSettings,
nsIWebBrowserPrint *aWebBrowserPrint);
NS_IMETHODIMP ShowPageSetup(nsIDOMWindow *aParent,
nsIPrintSettings *aSettings);
};