mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-13 19:41:49 +00:00
Wasn't setting the default correctly.
Bug 118409 r=dcone sr=attinasi
This commit is contained in:
parent
ef7d3419f0
commit
126e97c993
@ -112,7 +112,10 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
GlobalPrinters() {}
|
GlobalPrinters() {}
|
||||||
nsresult EnumerateNativePrinters(DWORD aWhichPrinters, char* aDefPrinter);
|
nsresult EnumerateNativePrinters(DWORD aWhichPrinters,
|
||||||
|
char* aDefPrinter,
|
||||||
|
PRInt32 aDefInx,
|
||||||
|
LPPRINTER_INFO_2& aDefPtr);
|
||||||
void ReallocatePrinters();
|
void ReallocatePrinters();
|
||||||
|
|
||||||
static GlobalPrinters mGlobalPrinters;
|
static GlobalPrinters mGlobalPrinters;
|
||||||
@ -1401,7 +1404,10 @@ GlobalPrinters::FindPrinterByName(const PRUnichar* aPrinterName)
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
nsresult
|
nsresult
|
||||||
GlobalPrinters::EnumerateNativePrinters(DWORD aWhichPrinters, char* aDefPrinter)
|
GlobalPrinters::EnumerateNativePrinters(DWORD aWhichPrinters,
|
||||||
|
char* aDefPrinter,
|
||||||
|
PRInt32 aDefInx,
|
||||||
|
LPPRINTER_INFO_2& aDefPtr)
|
||||||
{
|
{
|
||||||
#if defined(DEBUG_rods) || defined(DEBUG_dcone)
|
#if defined(DEBUG_rods) || defined(DEBUG_dcone)
|
||||||
OSVERSIONINFO os;
|
OSVERSIONINFO os;
|
||||||
@ -1440,8 +1446,9 @@ GlobalPrinters::EnumerateNativePrinters(DWORD aWhichPrinters, char* aDefPrinter)
|
|||||||
PRBool isDef = aDefPrinter && !PL_strcmp(printerInfo[i].pPrinterName, aDefPrinter);
|
PRBool isDef = aDefPrinter && !PL_strcmp(printerInfo[i].pPrinterName, aDefPrinter);
|
||||||
// put the default printer at the beginning of list
|
// put the default printer at the beginning of list
|
||||||
if (isDef) {
|
if (isDef) {
|
||||||
defInx = i;
|
NS_ASSERTION(aDefInx == -1, "Can't have two default printers!");
|
||||||
defPtr = &printerInfo[i];
|
aDefInx = i;
|
||||||
|
aDefPtr = &printerInfo[i];
|
||||||
}
|
}
|
||||||
mPrinters->AppendElement((void*)&printerInfo[i]);
|
mPrinters->AppendElement((void*)&printerInfo[i]);
|
||||||
|
|
||||||
@ -1459,14 +1466,6 @@ GlobalPrinters::EnumerateNativePrinters(DWORD aWhichPrinters, char* aDefPrinter)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// swap the default printer with the zero'th item
|
|
||||||
if (defInx > 0) {
|
|
||||||
LPPRINTER_INFO_2 ptr = (LPPRINTER_INFO_2)mPrinters->ElementAt(0);
|
|
||||||
mPrinters->ReplaceElementAt((void*)defPtr, 0);
|
|
||||||
mPrinters->ReplaceElementAt((void*)ptr, defInx);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// hang onto the pointer until we are done
|
// hang onto the pointer until we are done
|
||||||
mPrinterInfoArray->AppendElement((void*)printerInfo);
|
mPrinterInfoArray->AppendElement((void*)printerInfo);
|
||||||
|
|
||||||
@ -1515,12 +1514,22 @@ GlobalPrinters::EnumeratePrinterList()
|
|||||||
char* defPrinterName;
|
char* defPrinterName;
|
||||||
GetDefaultPrinterName(defPrinterName);
|
GetDefaultPrinterName(defPrinterName);
|
||||||
|
|
||||||
|
PRInt32 defInx = -1;
|
||||||
|
LPPRINTER_INFO_2 defPtr = nsnull;
|
||||||
|
|
||||||
// any of these could only fail with an OUT_MEMORY_ERROR
|
// any of these could only fail with an OUT_MEMORY_ERROR
|
||||||
// PRINTER_ENUM_LOCAL should get the network printers on Win95
|
// PRINTER_ENUM_LOCAL should get the network printers on Win95
|
||||||
nsresult rv = EnumerateNativePrinters(PRINTER_ENUM_LOCAL, defPrinterName);
|
nsresult rv = EnumerateNativePrinters(PRINTER_ENUM_CONNECTIONS, defPrinterName, defInx, defPtr);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
// Gets all networked printer the user has connected to
|
// Gets all networked printer the user has connected to
|
||||||
rv = EnumerateNativePrinters(PRINTER_ENUM_CONNECTIONS, defPrinterName);
|
rv = EnumerateNativePrinters(PRINTER_ENUM_LOCAL, defPrinterName, defInx, defPtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// swap the default printer with the zero'th item
|
||||||
|
if (defInx > 0) {
|
||||||
|
LPPRINTER_INFO_2 ptr = (LPPRINTER_INFO_2)mPrinters->ElementAt(0);
|
||||||
|
mPrinters->ReplaceElementAt((void*)defPtr, 0);
|
||||||
|
mPrinters->ReplaceElementAt((void*)ptr, defInx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defPrinterName) delete[] defPrinterName;
|
if (defPrinterName) delete[] defPrinterName;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user