b=118889 r=rods sr=sfraser Fixed app. so printSettings dialogs will work

This commit is contained in:
dcone%netscape.com 2002-02-07 05:32:59 +00:00
Родитель d58faf4a79
Коммит c34cb2647d
10 изменённых файлов: 81 добавлений и 14 удалений

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

@ -129,7 +129,7 @@ interface nsIPrintOptions : nsISupports
/**
* Show Native Print Options dialog, this may not be supported on all platforms
*/
void ShowNativeDialog();
void ShowPrintSetupDialog(in nsIPrintSettings aThePrintSettings);
/**
* Set PrintOptions

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

@ -31,6 +31,8 @@ EXPORTS = nsFontList.h
LIBRARY_NAME = gkgfx
EXPORT_LIBRARY = 1
REQUIRES = xpcom \
windowwatcher \
dom \
string \
widget \
locale \

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

@ -91,10 +91,13 @@ nsPrintOptionsMac::~nsPrintOptionsMac()
* @update 6/21/00 dwc
*/
NS_IMETHODIMP
nsPrintOptionsMac::ShowNativeDialog(void)
nsPrintOptionsMac::ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings)
{
if (!mPrintRecord) return NS_ERROR_NOT_INITIALIZED;
ReadPrefs();
// open the printing manager
::PrOpen();
if(::PrError() != noErr)
@ -111,9 +114,11 @@ nsPrintOptionsMac::ShowNativeDialog(void)
OSErr err = ::PrError();
::PrClose();
WritePrefs();
if (err != noErr)
return NS_ERROR_FAILURE;
return NS_OK;
}

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

@ -38,7 +38,7 @@ public:
nsPrintOptionsMac();
virtual ~nsPrintOptionsMac();
NS_IMETHOD ShowNativeDialog(void);
NS_IMETHOD ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings);
NS_IMETHOD GetNativeData(PRInt16 aDataType, void * *_retval);
NS_IMETHOD ReadPrefs();

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

@ -86,8 +86,11 @@ nsPrintOptionsX::~nsPrintOptionsX()
/** ---------------------------------------------------
*/
NS_IMETHODIMP
nsPrintOptionsX::ShowNativeDialog(void)
nsPrintOptionsX::ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings)
{
ReadPrefs();
NS_ASSERTION(mPageFormat != kPMNoPageFormat, "No page format");
if (mPageFormat == kPMNoPageFormat)
return NS_ERROR_NOT_INITIALIZED;
@ -104,6 +107,8 @@ nsPrintOptionsX::ShowNativeDialog(void)
status = ::PMPageSetupDialog(mPageFormat, &accepted);
::PMEnd();
WritePrefs();
if (status != noErr)
return NS_ERROR_FAILURE;

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

@ -55,7 +55,7 @@ public:
nsPrintOptionsX();
virtual ~nsPrintOptionsX();
NS_IMETHOD ShowNativeDialog(void);
NS_IMETHOD ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings);
NS_IMETHOD ReadPrefs(void);
NS_IMETHOD WritePrefs(void);

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

@ -26,6 +26,8 @@ DIRS = windows
MODULE=gfx
REQUIRES= xpcom \
windowwatcher \
dom \
string \
widget \
locale \

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

@ -43,6 +43,15 @@
#include "nsReadableUtils.h"
#include "nsPrintSettingsImpl.h"
#include "nsIDOMWindow.h"
#include "nsIServiceManager.h"
#include "nsIDialogParamBlock.h"
#include "nsISupportsPrimitives.h"
#include "nsIWindowWatcher.h"
#include "nsIDOMWindowInternal.h"
#include "nsVoidArray.h"
#include "nsSupportsArray.h"
// For Prefs
#include "nsIPref.h"
#include "nsIServiceManager.h"
@ -333,9 +342,47 @@ nsPrintOptions::GetPageSizeInTwips(PRInt32 *aWidth, PRInt32 *aHeight)
* @update 6/21/00 dwc
*/
NS_IMETHODIMP
nsPrintOptions::ShowNativeDialog()
{
return NS_ERROR_NOT_IMPLEMENTED;
nsPrintOptions::ShowPrintSetupDialog(nsIPrintSettings *aPS)
{
NS_ASSERTION(aPS, "Can't have a null PrintSettings!");
if (aPS == nsnull) return NS_OK;
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<nsISupports> psSupports(do_QueryInterface(aPS));
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://communicator/content/printPageSetup.xul",
"_blank", "chrome,modal,centerscreen", array,
getter_AddRefs(newWindow));
}
}
return rv;
}
/** ---------------------------------------------------

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

@ -17,7 +17,7 @@
insertbefore="printMenuItem"
label="&printSetupCmd.label;"
accesskey="&printSetupCmd.accesskey;"
command="cmd_printSetup"/>
command="Browser:PrintSetup"/>
<!-- quit -->
<menuseparator id="menu_FileQuitSeparator"/>
<menuitem label="&quitApplicationCmd.label;" id="menu_FileQuitItem"
@ -41,7 +41,7 @@
insertafter="printMenuItemToolbar"
label="&printSetupCmd.label;"
accesskey="&printSetupCmd.accesskey;"
command="cmd_printSetup"/>
command="Browser:PrintSetup"/>
</menupopup>
</overlay>

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

@ -129,9 +129,15 @@ function goPageSetup(printSettings)
if (printSettings == null) {
alert("PrintSettings arg is null!");
}
// This code brings up the native page setup dialog (for platforms that
// implement nsIPrintOptions.ShowNativeDialog()).
window.openDialog("chrome://communicator/content/printPageSetup.xul","PageSetup", "chrome,modal,centerscreen", printSettings);
// This code calls the printoptions service to bring up the printoptions
// dialog. This will be an xp dialog if the platform did not override
// the ShowPrintSetupDialog method.
var printOptionsService = Components.classes["@mozilla.org/gfx/printoptions;1"]
.getService(Components.interfaces.nsIPrintOptions);
printOptionsService.ShowPrintSetupDialog(printSettings);
}
function goPreferences(containerID, paneURL, itemID)