1) On windows and OS/2 it implements IDL attr of "defaultPrinterName" (like Bug 118152)

2) Stubs this out on al other platforms
3) On Windows implmenets new method "InitPrintSettingsFromPrinter" which sets certain key values from the native devmode into the print settings
4) Stubs this out on all other platforms
5) It also cleans up the nsDeviceContextSpecWin interface a little bit:
   It now has a single GetDevMode method that must be paired with a UnlockDevMode  method.
6) It moved GetDataFromPrinter into the public interface
7) Created a simple helper function for getting the default printer name.
Bug 123554 r=dcone sr=attinasi
This commit is contained in:
rods%netscape.com 2006-02-16 21:32:00 +00:00
parent 251e8a20b5
commit 904945e84a

View File

@ -54,6 +54,7 @@ public:
PRBool PrintersAreAllocated() { return mGlobalPrinterList != nsnull; }
PRInt32 GetNumPrinters() { return mGlobalNumPrinters; }
nsString* GetStringAt(PRInt32 aInx) { return mGlobalPrinterList->StringAt(aInx); }
void GetDefaultPrinterName(PRUnichar*& aDefaultPrinterName);
protected:
GlobalPrinters() {}
@ -397,6 +398,19 @@ NS_IMETHODIMP nsPrinterEnumeratorOS2::EnumeratePrinters(PRUint32* aCount, PRUnic
return NS_OK;
}
NS_IMETHODIMP nsPrinterEnumeratorOS2::GetDefaultPrinterName(PRUnichar * *aDefaultPrinterName)
{
NS_ENSURE_ARG_POINTER(aDefaultPrinterName);
GlobalPrinters::GetInstance()->GetDefaultPrinterName(*aDefaultPrinterName);
return NS_OK;
}
/* void initPrintSettingsFromPrinter (in wstring aPrinterName, in nsIPrintSettings aPrintSettings); */
NS_IMETHODIMP nsPrinterEnumeratorOS2::InitPrintSettingsFromPrinter(const PRUnichar *aPrinterName, nsIPrintSettings *aPrintSettings)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsPrinterEnumeratorOS2::DisplayPropertiesDlg(const PRUnichar *aPrinter, nsIPrintSettings *aPrintSettings)
{
nsresult rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
@ -442,6 +456,18 @@ nsresult GlobalPrinters::InitializeGlobalPrinters ()
return NS_OK;
}
void GlobalPrinters::GetDefaultPrinterName(PRUnichar*& aDefaultPrinterName)
{
aDefaultPrinterName = nsnull;
int defaultPrinter = nsDeviceContextSpecOS2::PrnDlg.GetDefaultPrinter();
char *printer = nsDeviceContextSpecOS2::PrnDlg.GetPrinter(defaultPrinter);
nsAutoString defaultName;
defaultName.AppendWithConversion(printer);
aDefaultPrinterName = ToNewUnicode(defaultName);
}
void GlobalPrinters::FreeGlobalPrinters()
{
delete mGlobalPrinterList;