diff --git a/widget/src/os2/nsDeviceContextSpecOS2.cpp b/widget/src/os2/nsDeviceContextSpecOS2.cpp index b94570b930c4..a2a818e7916a 100644 --- a/widget/src/os2/nsDeviceContextSpecOS2.cpp +++ b/widget/src/os2/nsDeviceContextSpecOS2.cpp @@ -74,14 +74,14 @@ protected: static GlobalPrinters mGlobalPrinters; static nsStringArray* mGlobalPrinterList; - static int mGlobalNumPrinters; + static ULONG mGlobalNumPrinters; }; //--------------- // static members GlobalPrinters GlobalPrinters::mGlobalPrinters; nsStringArray* GlobalPrinters::mGlobalPrinterList = nsnull; -int GlobalPrinters::mGlobalNumPrinters = 0; +ULONG GlobalPrinters::mGlobalNumPrinters = 0; //--------------- /** ------------------------------------------------------- @@ -108,7 +108,7 @@ static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID); static NS_DEFINE_IID(kIDeviceContextSpecXPIID, NS_IDEVICE_CONTEXT_SPEC_XP_IID); #endif -void SetupDevModeFromSettings(int printer, nsIPrintSettings* aPrintSettings) +void SetupDevModeFromSettings(ULONG printer, nsIPrintSettings* aPrintSettings) { if (aPrintSettings) { int bufferSize = 3 * sizeof(DJP_ITEM); @@ -149,15 +149,15 @@ void SetupDevModeFromSettings(int printer, nsIPrintSettings* aPrintSettings) pDJP->ulValue = 0; LONG driverSize = nsDeviceContextSpecOS2::PrnDlg.GetPrintDriverSize(printer); - LONG rc = GreEscape (hdc, DEVESC_SETJOBPROPERTIES, bufferSize, pDJP_Buffer, - &driverSize, PBYTE(nsDeviceContextSpecOS2::PrnDlg.GetPrintDriver(printer))); + GreEscape (hdc, DEVESC_SETJOBPROPERTIES, bufferSize, pDJP_Buffer, + &driverSize, PBYTE(nsDeviceContextSpecOS2::PrnDlg.GetPrintDriver(printer))); delete [] pDJP_Buffer; DevCloseDC(hdc); } } -nsresult nsDeviceContextSpecOS2::SetPrintSettingsFromDevMode(nsIPrintSettings* aPrintSettings, int printer) +nsresult nsDeviceContextSpecOS2::SetPrintSettingsFromDevMode(nsIPrintSettings* aPrintSettings, ULONG printer) { if (aPrintSettings == nsnull) return NS_ERROR_FAILURE; @@ -324,9 +324,9 @@ NS_IMETHODIMP nsDeviceContextSpecOS2::Init(nsIPrintSettings* aPS, PRBool aIsPrin return rv; const nsAFlatString& printerUCS2 = NS_ConvertUTF8toUCS2(mPrData.printer); - int numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters(); + ULONG numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters(); if (numPrinters) { - for(int i = 0; (i < numPrinters) && !mQueue; i++) { + for(ULONG i = 0; (i < numPrinters) && !mQueue; i++) { if ((GlobalPrinters::GetInstance()->GetStringAt(i)->Equals(printerUCS2, nsCaseInsensitiveStringComparator()))) { SetupDevModeFromSettings(i, aPS); mQueue = PrnDlg.SetPrinterQueue(i); @@ -420,7 +420,7 @@ NS_IMETHODIMP nsPrinterEnumeratorOS2::EnumeratePrinters(PRUint32* aCount, PRUnic return rv; } - PRInt32 numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters(); + ULONG numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters(); PRUnichar** array = (PRUnichar**) nsMemory::Alloc(numPrinters * sizeof(PRUnichar*)); if (!array && numPrinters > 0) { @@ -428,13 +428,13 @@ NS_IMETHODIMP nsPrinterEnumeratorOS2::EnumeratePrinters(PRUint32* aCount, PRUnic return NS_ERROR_OUT_OF_MEMORY; } - int count = 0; + ULONG count = 0; while( count < numPrinters ) { PRUnichar *str = ToNewUnicode(*GlobalPrinters::GetInstance()->GetStringAt(count)); if (!str) { - for (int i = count - 1; i >= 0; i--) + for (ULONG i = 0 ; i < count ; i++) nsMemory::Free(array[i]); nsMemory::Free(array); @@ -471,8 +471,8 @@ NS_IMETHODIMP nsPrinterEnumeratorOS2::InitPrintSettingsFromPrinter(const PRUnich if (NS_FAILED(GlobalPrinters::GetInstance()->InitializeGlobalPrinters())) return NS_ERROR_FAILURE; - PRInt32 numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters(); - for(int i = 0; i < numPrinters; i++) { + ULONG numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters(); + for(ULONG i = 0; i < numPrinters; i++) { if ((GlobalPrinters::GetInstance()->GetStringAt(i)->Equals(aPrinterName, nsCaseInsensitiveStringComparator()))) nsDeviceContextSpecOS2::SetPrintSettingsFromDevMode(aPrintSettings, i); } @@ -490,9 +490,8 @@ NS_IMETHODIMP nsPrinterEnumeratorOS2::DisplayPropertiesDlg(const PRUnichar *aPri return rv; } - PRInt32 numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters(); - - for(int i = 0; i < numPrinters; i++) { + ULONG numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters(); + for(ULONG i = 0; i < numPrinters; i++) { if ((GlobalPrinters::GetInstance()->GetStringAt(i)->Equals(aPrinter, nsCaseInsensitiveStringComparator()))) { SetupDevModeFromSettings(i, aPrintSettings); if ( nsDeviceContextSpecOS2::PrnDlg.ShowProperties(i) ) { @@ -549,7 +548,7 @@ void GlobalPrinters::GetDefaultPrinterName(PRUnichar*& aDefaultPrinterName) if (GetNumPrinters() == 0) return; - int defaultPrinter = nsDeviceContextSpecOS2::PrnDlg.GetDefaultPrinter(); + ULONG defaultPrinter = nsDeviceContextSpecOS2::PrnDlg.GetDefaultPrinter(); nsXPIDLCString printer; nsDeviceContextSpecOS2::PrnDlg.GetPrinter(defaultPrinter, getter_Copies(printer)); @@ -694,7 +693,7 @@ PRINTDLG::PRINTDLG () PRINTDLG::~PRINTDLG () { - for (int cnt = 0 ; cnt < mQueueCount ; cnt++) + for (ULONG cnt = 0 ; cnt < mQueueCount ; cnt++) delete mPQBuf [cnt]; } @@ -738,14 +737,14 @@ void PRINTDLG::RefreshPrintQueue() tmpBuf[cnt] = new PRTQUEUE (&pPQI3Buf[cnt]); } - for (int i=0; i < newQueueCount; i++) { + for (ULONG i=0; i < newQueueCount; i++) { if (mPQBuf[i] != 0) delete(mPQBuf[i]); mPQBuf[i] = tmpBuf[i]; } if (mQueueCount > newQueueCount) - for (int i = newQueueCount; i < mQueueCount; i++) + for (ULONG i = newQueueCount; i < mQueueCount; i++) if (mPQBuf[i] != 0) delete(mPQBuf[i]); @@ -753,9 +752,9 @@ void PRINTDLG::RefreshPrintQueue() free (pPQI3Buf); } -int PRINTDLG::GetIndex (int numPrinter) +ULONG PRINTDLG::GetIndex (ULONG numPrinter) { - int index; + ULONG index; if (numPrinter == 0) index = mDefaultQueue; @@ -767,17 +766,17 @@ int PRINTDLG::GetIndex (int numPrinter) return index; } -int PRINTDLG::GetNumPrinters () +ULONG PRINTDLG::GetNumPrinters () { return mQueueCount; } -int PRINTDLG::GetDefaultPrinter () +ULONG PRINTDLG::GetDefaultPrinter () { return mDefaultQueue; } -void PRINTDLG::GetPrinter (int numPrinter, char** printerName) +void PRINTDLG::GetPrinter (ULONG numPrinter, char** printerName) { if (numPrinter > mQueueCount) return; @@ -789,7 +788,7 @@ void PRINTDLG::GetPrinter (int numPrinter, char** printerName) *printerName = ToNewCString(pName); } -PRTQUEUE* PRINTDLG::SetPrinterQueue (int numPrinter) +PRTQUEUE* PRINTDLG::SetPrinterQueue (ULONG numPrinter) { PRTQUEUE *pPQ = NULL; @@ -801,12 +800,12 @@ PRTQUEUE* PRINTDLG::SetPrinterQueue (int numPrinter) return new PRTQUEUE (*pPQ); } -LONG PRINTDLG::GetPrintDriverSize (int printer) +LONG PRINTDLG::GetPrintDriverSize (ULONG printer) { return mPQBuf[GetIndex(printer)]->PQI3().pDriverData->cb; } -PDRIVDATA PRINTDLG::GetPrintDriver (int printer) +PDRIVDATA PRINTDLG::GetPrintDriver (ULONG printer) { if (printer > mQueueCount) return NULL; @@ -814,10 +813,10 @@ PDRIVDATA PRINTDLG::GetPrintDriver (int printer) return mPQBuf[GetIndex(printer)]->PQI3().pDriverData; } -HDC PRINTDLG::GetDCHandle (int numPrinter) +HDC PRINTDLG::GetDCHandle (ULONG numPrinter) { HDC hdc = 0; - int index = GetIndex(numPrinter); + ULONG index = GetIndex(numPrinter); DEVOPENSTRUC dop; dop.pszLogAddress = 0; @@ -834,19 +833,19 @@ HDC PRINTDLG::GetDCHandle (int numPrinter) return hdc; } -char* PRINTDLG::GetDriverType (int printer) +char* PRINTDLG::GetDriverType (ULONG printer) { return (char *)mPQBuf[GetIndex(printer)]->DriverName (); } -BOOL PRINTDLG::ShowProperties (int index) +BOOL PRINTDLG::ShowProperties (ULONG index) { BOOL rc = FALSE; - ULONG devrc = FALSE; + LONG devrc = FALSE; PDRIVDATA pOldDrivData; PDRIVDATA pNewDrivData = NULL; LONG buflen; - int Ind = GetIndex(index); + ULONG Ind = GetIndex(index); /* check size of buffer required for job properties */ buflen = DevPostDeviceModes( 0 /*hab*/, @@ -919,25 +918,25 @@ HDC PrnOpenDC( PRTQUEUE *pInfo, PSZ pszApplicationName, int copies, int destinat dcType = OD_DIRECT; } - dop.pszLogAddress = pszLogAddress; - dop.pszDriverName = (char*)pInfo->DriverName (); - dop.pdriv = pInfo->PQI3 ().pDriverData; - dop.pszDataType = pszDataType; - dop.pszComment = pszApplicationName; - dop.pszQueueProcName = pInfo->PQI3 ().pszPrProc; - dop.pszQueueProcParams = 0; - dop.pszSpoolerParams = 0; - dop.pszNetworkParams = 0; + dop.pszLogAddress = pszLogAddress; + dop.pszDriverName = (char*)pInfo->DriverName (); + dop.pdriv = pInfo->PQI3 ().pDriverData; + dop.pszDataType = pszDataType; + dop.pszComment = pszApplicationName; + dop.pszQueueProcName = pInfo->PQI3 ().pszPrProc; + dop.pszQueueProcParams = 0; + dop.pszSpoolerParams = 0; + dop.pszNetworkParams = 0; - hdc = ::DevOpenDC( 0, dcType, "*", 9, (PDEVOPENDATA) &dop, NULLHANDLE); + hdc = ::DevOpenDC( 0, dcType, "*", 9, (PDEVOPENDATA) &dop, NULLHANDLE); -if (hdc == 0) -{ - ULONG ErrorCode = ERRORIDERROR (::WinGetLastError (0)); #ifdef DEBUG - printf ("!ERROR! - Can't open DC for printer %04X\a\n", ErrorCode); + if (hdc == 0) + { + ULONG ErrorCode = ERRORIDERROR (::WinGetLastError (0)); + printf ("!ERROR! - Can't open DC for printer %04lX\a\n", ErrorCode); + } #endif -} return hdc; } diff --git a/widget/src/os2/nsDeviceContextSpecOS2.h b/widget/src/os2/nsDeviceContextSpecOS2.h index 0daa571b9278..b584bf099236 100644 --- a/widget/src/os2/nsDeviceContextSpecOS2.h +++ b/widget/src/os2/nsDeviceContextSpecOS2.h @@ -79,15 +79,15 @@ public: PRINTDLG (); ~PRINTDLG (); void RefreshPrintQueue(); - int GetNumPrinters (); - int GetDefaultPrinter (); - void GetPrinter (int numPrinter, char** printerName); - PRTQUEUE* SetPrinterQueue (int numPrinter); - HDC GetDCHandle (int numPrinter); - LONG GetPrintDriverSize (int printer); - PDRIVDATA GetPrintDriver (int printer); - char* GetDriverType (int printer); - BOOL ShowProperties(int index); + ULONG GetNumPrinters (); + ULONG GetDefaultPrinter (); + void GetPrinter (ULONG numPrinter, char** printerName); + PRTQUEUE* SetPrinterQueue (ULONG numPrinter); + HDC GetDCHandle (ULONG numPrinter); + LONG GetPrintDriverSize (ULONG printer); + PDRIVDATA GetPrintDriver (ULONG printer); + char* GetDriverType (ULONG printer); + BOOL ShowProperties(ULONG index); PRTQUEUE* SelectPrinter (HWND hwndOwner, BOOL bQuiet); private: @@ -95,7 +95,7 @@ private: ULONG mDefaultQueue; PRTQUEUE* mPQBuf [MAX_PRINT_QUEUES]; - int GetIndex( int numPrinter); + ULONG GetIndex( ULONG numPrinter); }; @@ -160,7 +160,7 @@ public: virtual ~nsDeviceContextSpecOS2(); static PRINTDLG PrnDlg; - static nsresult SetPrintSettingsFromDevMode(nsIPrintSettings* aPrintSettings, int printer); + static nsresult SetPrintSettingsFromDevMode(nsIPrintSettings* aPrintSettings, ULONG printer); protected: