diff --git a/gfx/src/os2/Makefile.in b/gfx/src/os2/Makefile.in index b43183cf0867..5e26881a4507 100644 --- a/gfx/src/os2/Makefile.in +++ b/gfx/src/os2/Makefile.in @@ -68,16 +68,13 @@ REQUIRES = xpcom \ SHARED_LCPPSRCS = nsUnicodeRange.cpp CPPSRCS = \ - nsDeviceContextSpecOS2.cpp \ nsDeviceContextOS2.cpp \ nsDrawingSurfaceOS2.cpp \ nsRenderingContextOS2.cpp \ nsFontMetricsOS2.cpp \ nsImageOS2.cpp \ nsRegionOS2.cpp \ - nsDeviceContextSpecFactoryO.cpp \ nsGfxFactoryOS2.cpp \ - nsPrintOptionsOS2.cpp \ nsGfxDefs.cpp \ $(SHARED_LCPPSRCS) \ $(NULL) @@ -104,6 +101,7 @@ LOCAL_INCLUDES = \ -I$(srcdir)/.. \ -I$(srcdir)/../shared \ -I$(srcdir)/../windows \ + -I$(srcdir)/../../../widget/src/os2 \ $(NULL) DEFINES += -DUSE_OS2_TOOLKIT_HEADERS diff --git a/gfx/src/os2/nsDeviceContextOS2.cpp b/gfx/src/os2/nsDeviceContextOS2.cpp index 6b5aa92139e9..814262216331 100644 --- a/gfx/src/os2/nsDeviceContextOS2.cpp +++ b/gfx/src/os2/nsDeviceContextOS2.cpp @@ -41,6 +41,7 @@ #include "nsDeviceContextOS2.h" #include "nsRenderingContextOS2.h" #include "nsDeviceContextSpecOS2.h" +#include "nsPrintOS2.h" #include "nsIServiceManager.h" #include "nsCOMPtr.h" #include "nsIScreenManager.h" @@ -60,6 +61,7 @@ static PRBool gIsWarp4 = NOT_SETUP; PRUint32 nsDeviceContextOS2::sNumberOfScreens = 0; nscoord nsDeviceContextOS2::mDpi = 120; + nsDeviceContextOS2 :: nsDeviceContextOS2() : DeviceContextImpl() { diff --git a/gfx/src/os2/nsGfxFactoryOS2.cpp b/gfx/src/os2/nsGfxFactoryOS2.cpp index 79443440378a..60ea4b640caa 100644 --- a/gfx/src/os2/nsGfxFactoryOS2.cpp +++ b/gfx/src/os2/nsGfxFactoryOS2.cpp @@ -44,16 +44,12 @@ #include "nsBlender.h" #include "nsFontMetricsOS2.h" #include "nsRenderingContextOS2.h" -#include "nsDeviceContextSpecOS2.h" -#include "nsDeviceContextSpecFactoryO.h" #include "nsScriptableRegion.h" #include "nsDeviceContextOS2.h" #include "nsImageOS2.h" #include "nsRegionOS2.h" -#include "nsPrintOptionsOS2.h" -#include "nsFontList.h" -#include "nsPrintSession.h" #include "gfxImageFrame.h" +#include "nsFontList.h" #include "nsIServiceManager.h" #include "prenv.h" #include "nsOS2Uni.h" @@ -69,13 +65,8 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsRenderingContextOS2) NS_GENERIC_FACTORY_CONSTRUCTOR(nsImageOS2) NS_GENERIC_FACTORY_CONSTRUCTOR(nsBlender) NS_GENERIC_FACTORY_CONSTRUCTOR(nsRegionOS2) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecOS2) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecFactoryOS2) NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontEnumeratorOS2) NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontList) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsOS2, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorOS2) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init) NS_GENERIC_FACTORY_CONSTRUCTOR(gfxImageFrame) #ifdef USE_FREETYPE @@ -299,21 +290,6 @@ static const nsModuleComponentInfo components[] = // "@mozilla.org/gfx/blender;1", "@mozilla.org/gfx/blender;1", nsBlenderConstructor }, - { "OS/2 Device Context Spec", - NS_DEVICE_CONTEXT_SPEC_CID, - // "@mozilla.org/gfx/device_context_spec/gtk;1", - "@mozilla.org/gfx/devicecontextspec;1", - nsDeviceContextSpecOS2Constructor }, - { "OS/2 Device Context Spec Factory", - NS_DEVICE_CONTEXT_SPEC_FACTORY_CID, - // "@mozilla.org/gfx/device_context_spec_factory/gtk;1", - "@mozilla.org/gfx/devicecontextspecfactory;1", - nsDeviceContextSpecFactoryOS2Constructor }, - { "PrintSettings Service", - NS_PRINTSETTINGSSERVICE_CID, - // "@mozilla.org/gfx/printsettings-service;1", - "@mozilla.org/gfx/printsettings-service;1", - nsPrintOptionsOS2Constructor }, { "OS2 Font Enumerator", NS_FONT_ENUMERATOR_CID, // "@mozilla.org/gfx/font_enumerator/gtk;1", @@ -324,19 +300,10 @@ static const nsModuleComponentInfo components[] = // "@mozilla.org/gfx/fontlist;1" NS_FONTLIST_CONTRACTID, nsFontListConstructor }, - { "OS/2 Printer Enumerator", - NS_PRINTER_ENUMERATOR_CID, - // "@mozilla.org/gfx/printer_enumerator/gtk;1", - "@mozilla.org/gfx/printerenumerator;1", - nsPrinterEnumeratorOS2Constructor }, { "windows image frame", GFX_IMAGEFRAME_CID, "@mozilla.org/gfx/image/frame;2", gfxImageFrameConstructor, }, - { "Print Session", - NS_PRINTSESSION_CID, - "@mozilla.org/gfx/printsession;1", - nsPrintSessionConstructor } }; PR_STATIC_CALLBACK(void) diff --git a/gfx/src/os2/nsPrintOS2.cpp b/gfx/src/os2/nsPrintOS2.cpp new file mode 100644 index 000000000000..0ce619d5de8d --- /dev/null +++ b/gfx/src/os2/nsPrintOS2.cpp @@ -0,0 +1,467 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is the Mozilla OS/2 libraries. + * + * The Initial Developer of the Original Code is + * John Fairhurst, . + * Portions created by the Initial Developer are Copyright (C) 1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Pierre Phaneuf + * Peter Weilbacher + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsPrintOS2.h" + +#include "nsOS2Uni.h" + +#include + +//--------------------------------------------------------------------------- +// OS/2 Printing - was in libprint.cpp +//--------------------------------------------------------------------------- +static HMODULE hmodRes; + +#define SHIFT_PTR(ptr,offset) ( *((LONG*)&ptr) += offset ) + + +class PRTQUEUE +{ +public: + PRTQUEUE (const PRQINFO3* pPQI3) { InitWithPQI3 (pPQI3); } + PRTQUEUE (const PRTQUEUE& PQInfo); + ~PRTQUEUE (void) { free (mpPQI3); } + + PRQINFO3& PQI3 () const { return *mpPQI3; } + const char* DriverName () const { return mDriverName; } + const char* DeviceName () const { return mDeviceName; } + const char* PrinterName() const { return mPrinterName; } + const char* QueueName () const { return mpPQI3->pszComment; } + +private: + PRTQUEUE& operator = (const PRTQUEUE& z); // prevent copying + void InitWithPQI3 (const PRQINFO3* pInfo); + + PRQINFO3* mpPQI3; + unsigned mPQI3BufSize; + char mDriverName [DRIV_NAME_SIZE + 1]; // Driver name + char mDeviceName [DRIV_DEVICENAME_SIZE + 1]; // Device name + char mPrinterName [PRINTERNAME_SIZE + 1]; // Printer name +}; + + +PRTQUEUE::PRTQUEUE (const PRTQUEUE& PQInfo) +{ + mPQI3BufSize = PQInfo.mPQI3BufSize; + mpPQI3 = (PRQINFO3*)malloc (mPQI3BufSize); + memcpy (mpPQI3, PQInfo.mpPQI3, mPQI3BufSize); // Copy entire buffer + + long Diff = (long)mpPQI3 - (long)PQInfo.mpPQI3; // Calculate the difference between addresses + SHIFT_PTR (mpPQI3->pszName, Diff); // Modify internal pointers accordingly + SHIFT_PTR (mpPQI3->pszSepFile, Diff); + SHIFT_PTR (mpPQI3->pszPrProc, Diff); + SHIFT_PTR (mpPQI3->pszParms, Diff); + SHIFT_PTR (mpPQI3->pszComment, Diff); + SHIFT_PTR (mpPQI3->pszPrinters, Diff); + SHIFT_PTR (mpPQI3->pszDriverName, Diff); + SHIFT_PTR (mpPQI3->pDriverData, Diff); + + strcpy (mDriverName, PQInfo.mDriverName); + strcpy (mDeviceName, PQInfo.mDeviceName); + strcpy (mPrinterName, PQInfo.mPrinterName); +} + +void PRTQUEUE::InitWithPQI3(const PRQINFO3* pInfo) +{ + // Make local copy of PPRQINFO3 object + ULONG SizeNeeded; + ::SplQueryQueue (NULL, pInfo->pszName, 3, NULL, 0, &SizeNeeded); + mpPQI3 = (PRQINFO3*)malloc (SizeNeeded); + ::SplQueryQueue (NULL, pInfo->pszName, 3, mpPQI3, SizeNeeded, &SizeNeeded); + + mPQI3BufSize = SizeNeeded; + + PCHAR sep = strchr (pInfo->pszDriverName, '.'); + + if (sep) + { + *sep = '\0'; + strcpy (mDriverName, pInfo->pszDriverName); + strcpy (mDeviceName, sep + 1); + *sep = '.'; + } else + { + strcpy (mDriverName, pInfo->pszDriverName); + mDeviceName [0] = '\0'; + } + + + sep = strchr (pInfo->pszPrinters, ','); + + if (sep) + { + *sep = '\0'; + strcpy (mPrinterName, pInfo->pszPrinters); + *sep = '.'; + } else + { + strcpy (mPrinterName, pInfo->pszPrinters); + } +} + + +//=========================================================================== + +PRINTDLG::PRINTDLG() +{ + mQueueCount = 0; + + ULONG TotalQueues = 0; + ULONG MemNeeded = 0; + SPLERR rc; + + rc = ::SplEnumQueue(NULL, 3, NULL, 0, &mQueueCount, &TotalQueues, &MemNeeded, NULL); + PRQINFO3* pPQI3Buf = (PRQINFO3*) malloc (MemNeeded); + rc = ::SplEnumQueue(NULL, 3, pPQI3Buf, MemNeeded, &mQueueCount, &TotalQueues, &MemNeeded, NULL); + + if (mQueueCount > MAX_PRINT_QUEUES) + mQueueCount = MAX_PRINT_QUEUES; + + ULONG defaultQueue = 0; + for (ULONG cnt = 0; cnt < mQueueCount; cnt++) { + if (pPQI3Buf[cnt].fsType & PRQ3_TYPE_APPDEFAULT) + defaultQueue = cnt; + mPQBuf[cnt] = new PRTQUEUE(&pPQI3Buf[cnt]); + } + + // move the entry for the default printer to index 0 (if necessary) + if (defaultQueue > 0) { + PRTQUEUE* temp = mPQBuf[0]; + mPQBuf[0] = mPQBuf[defaultQueue]; + mPQBuf[defaultQueue] = temp; + } + + free(pPQI3Buf); +} + +PRINTDLG::~PRINTDLG() +{ + for (ULONG index = 0; index < mQueueCount; index++) + delete mPQBuf[index]; +} + +void PRINTDLG::RefreshPrintQueue() +{ + ULONG newQueueCount = 0; + ULONG TotalQueues = 0; + ULONG MemNeeded = 0; + SPLERR rc; + + rc = ::SplEnumQueue(NULL, 3, NULL, 0, &newQueueCount, &TotalQueues, &MemNeeded, NULL); + PRQINFO3* pPQI3Buf = (PRQINFO3*)malloc(MemNeeded); + rc = ::SplEnumQueue(NULL, 3, pPQI3Buf, MemNeeded, &newQueueCount, &TotalQueues, &MemNeeded, NULL); + + if (newQueueCount > MAX_PRINT_QUEUES) + newQueueCount = MAX_PRINT_QUEUES; + + PRTQUEUE* tmpBuf[MAX_PRINT_QUEUES]; + + ULONG defaultQueue = 0; + for (ULONG cnt = 0; cnt < newQueueCount; cnt++) { + if (pPQI3Buf[cnt].fsType & PRQ3_TYPE_APPDEFAULT) + defaultQueue = cnt; + + BOOL found = FALSE; + for (ULONG index = 0; index < mQueueCount && !found; index++) { + //Compare printer from requeried list with what's already in Mozilla's printer list(mPQBuf) + //If printer is already there, use current properties; otherwise create a new printer in list + if (mPQBuf[index] != 0) { + if ((strcmp(pPQI3Buf[cnt].pszPrinters, mPQBuf[index]->PrinterName()) == 0) && + (strcmp(pPQI3Buf[cnt].pszDriverName, mPQBuf[index]->PQI3().pszDriverName) == 0)) { + found = TRUE; + tmpBuf[cnt] = mPQBuf[index]; + mPQBuf[index] = 0; + } + } + } + if (!found) + tmpBuf[cnt] = new PRTQUEUE(&pPQI3Buf[cnt]); + } + + for (ULONG index = 0; index < newQueueCount; index++) { + if (mPQBuf[index] != 0) + delete(mPQBuf[index]); + mPQBuf[index] = tmpBuf[index]; + } + + if (mQueueCount > newQueueCount) + for (ULONG index = newQueueCount; index < mQueueCount; index++) + if (mPQBuf[index] != 0) + delete(mPQBuf[index]); + + mQueueCount = newQueueCount; + + // move the entry for the default printer to index 0 (if necessary) + if (defaultQueue > 0) { + PRTQUEUE* temp = mPQBuf[0]; + mPQBuf[0] = mPQBuf[defaultQueue]; + mPQBuf[defaultQueue] = temp; + } + + free(pPQI3Buf); +} + +ULONG PRINTDLG::GetNumPrinters() +{ + return mQueueCount; +} + +void PRINTDLG::GetPrinter(ULONG printerNdx, char** printerName) +{ + if (printerNdx >= mQueueCount) + return; + + nsCAutoString pName(mPQBuf[printerNdx]->QueueName()); + + pName.ReplaceChar('\r', ' '); + pName.StripChars("\n"); + *printerName = ToNewCString(pName); +} + +PRTQUEUE* PRINTDLG::SetPrinterQueue(ULONG printerNdx) +{ + PRTQUEUE *pPQ = NULL; + + if (printerNdx >= mQueueCount) + return NULL; + + pPQ = mPQBuf[printerNdx]; + + return new PRTQUEUE(*pPQ); +} + +LONG PRINTDLG::GetPrintDriverSize(ULONG printerNdx) +{ + return mPQBuf[printerNdx]->PQI3().pDriverData->cb; +} + +PDRIVDATA PRINTDLG::GetPrintDriver(ULONG printerNdx) +{ + if (printerNdx >= mQueueCount) + return NULL; + + return mPQBuf[printerNdx]->PQI3().pDriverData; +} + +HDC PRINTDLG::GetDCHandle(ULONG printerNdx) +{ + HDC hdc = 0; + DEVOPENSTRUC dop; + + dop.pszLogAddress = 0; + dop.pszDriverName = (char *)mPQBuf[printerNdx]->DriverName(); + dop.pdriv = mPQBuf[printerNdx]->PQI3().pDriverData; + dop.pszDataType = 0; + dop.pszComment = 0; + dop.pszQueueProcName = 0; + dop.pszQueueProcParams = 0; + dop.pszSpoolerParams = 0; + dop.pszNetworkParams = 0; + + hdc = ::DevOpenDC(0, OD_INFO, "*", 9, (PDEVOPENDATA) &dop, NULLHANDLE); + return hdc; +} + +char* PRINTDLG::GetDriverType(ULONG printerNdx) +{ + return (char *)mPQBuf[printerNdx]->DriverName (); +} + +BOOL PRINTDLG::ShowProperties(ULONG printerNdx) +{ + BOOL rc = FALSE; + LONG devrc = FALSE; + PDRIVDATA pOldDrivData; + PDRIVDATA pNewDrivData = NULL; + LONG buflen; + +/* check size of buffer required for job properties */ + buflen = DevPostDeviceModes( 0 /*hab*/, + NULL, + mPQBuf[printerNdx]->DriverName (), + mPQBuf[printerNdx]->DeviceName (), + mPQBuf[printerNdx]->PrinterName (), + DPDM_POSTJOBPROP); + +/* return error to caller */ + if (buflen <= 0) + return(buflen); + +/* allocate some memory for larger job properties and */ +/* return error to caller */ + + if (buflen != mPQBuf[printerNdx]->PQI3().pDriverData->cb) + { + if (DosAllocMem((PPVOID)&pNewDrivData,buflen,fALLOC)) + return(FALSE); // DPDM_ERROR + +/* copy over old data so driver can use old job */ +/* properties as base for job properties dialog */ + pOldDrivData = mPQBuf[printerNdx]->PQI3().pDriverData; + mPQBuf[printerNdx]->PQI3().pDriverData = pNewDrivData; + memcpy( (PSZ)pNewDrivData, (PSZ)pOldDrivData, pOldDrivData->cb ); + } + +/* display job properties dialog and get updated */ +/* job properties from driver */ + + devrc = DevPostDeviceModes( 0 /*hab*/, + mPQBuf[printerNdx]->PQI3().pDriverData, + mPQBuf[printerNdx]->DriverName (), + mPQBuf[printerNdx]->DeviceName (), + mPQBuf[printerNdx]->PrinterName (), + DPDM_POSTJOBPROP); + rc = (devrc != DPDM_ERROR); + return rc; +} + +/****************************************************************************/ +/* Job management */ +/****************************************************************************/ + +HDC PrnOpenDC( PRTQUEUE *pInfo, PSZ pszApplicationName, int copies, int destination, char *file ) +{ + HDC hdc = 0; + PSZ pszLogAddress; + PSZ pszDataType; + LONG dcType; + DEVOPENSTRUC dop; + + if (!pInfo || !pszApplicationName) + return hdc; + + if ( destination ) { + pszLogAddress = pInfo->PQI3 ().pszName; + pszDataType = "PM_Q_STD"; + if ( destination == 2 ) + dcType = OD_METAFILE; + else + dcType = OD_QUEUED; + } else { + if (file && *file) + pszLogAddress = (PSZ) file; + else + pszLogAddress = "FILE"; + pszDataType = "PM_Q_RAW"; + 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; + + hdc = ::DevOpenDC( 0, dcType, "*", 9, (PDEVOPENDATA) &dop, NULLHANDLE); + +#ifdef DEBUG + if (hdc == 0) + { + ULONG ErrorCode = ERRORIDERROR (::WinGetLastError (0)); + printf ("!ERROR! - Can't open DC for printer %04lX\a\n", ErrorCode); + } +#endif + + return hdc; +} + +/* find the selected form */ +BOOL PrnQueryHardcopyCaps( HDC hdc, PHCINFO pHCInfo) +{ + BOOL rc = FALSE; + + if( hdc && pHCInfo) + { + PHCINFO pBuffer; + long lAvail, i; + + /* query how many forms are available */ + lAvail = ::DevQueryHardcopyCaps( hdc, 0, 0, NULL); + + pBuffer = (PHCINFO) malloc( lAvail * sizeof(HCINFO)); + + ::DevQueryHardcopyCaps( hdc, 0, lAvail, pBuffer); + + for( i = 0; i < lAvail; i++) + if( pBuffer[ i].flAttributes & HCAPS_CURRENT) + { + memcpy( pHCInfo, pBuffer + i, sizeof(HCINFO)); + rc = TRUE; + break; + } + + free( pBuffer); + } + + return rc; +} + + +/****************************************************************************/ +/* Library-level data and functions -Printing */ +/****************************************************************************/ + +BOOL PrnInitialize( HMODULE hmodResources) +{ + hmodRes = hmodResources; + return TRUE; +} + +BOOL PrnTerminate() +{ + /* nop for now, may do something eventually */ + return TRUE; +} + +BOOL PrnClosePrinter( PRTQUEUE *pPrintQueue) +{ + BOOL rc = FALSE; + + if (pPrintQueue) + { + delete pPrintQueue; + rc = TRUE; + } + + return rc; +} + diff --git a/gfx/src/os2/nsPrintOS2.h b/gfx/src/os2/nsPrintOS2.h new file mode 100644 index 000000000000..9f6babdc3720 --- /dev/null +++ b/gfx/src/os2/nsPrintOS2.h @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * John Fairhurst + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef nsPrintOS2_h___ +#define nsPrintOS2_h___ + +#define INCL_PM +#define INCL_DOS +#define INCL_DOSERRORS +#define INCL_SPLDOSPRINT +#define INCL_DEV +#define INCL_DEVDJP +#define INCL_GRE_DEVICE +#include +#include + +//--------------------------------------------------------------------------- +// OS/2 Printing - was in libprint +//--------------------------------------------------------------------------- +// Library init and term; job properties per queue are cached during run. +BOOL PrnInitialize(HMODULE hmodResources); +BOOL PrnTerminate(void); + +// opaque type to describe a print queue (printer) +class PRTQUEUE; + +#define MAX_PRINT_QUEUES (128) + +class PRINTDLG +{ +public: + PRINTDLG(); + ~PRINTDLG(); + void RefreshPrintQueue(); + ULONG GetNumPrinters(); + void GetPrinter(ULONG printerNdx, char** printerName); + PRTQUEUE* SetPrinterQueue(ULONG printerNdx); + LONG GetPrintDriverSize(ULONG printerNdx); + PDRIVDATA GetPrintDriver(ULONG printerNdx); + HDC GetDCHandle(ULONG printerNdx); + char* GetDriverType(ULONG printerNdx); + BOOL ShowProperties(ULONG printerNdx); + +private: + ULONG mQueueCount; + PRTQUEUE* mPQBuf[MAX_PRINT_QUEUES]; +}; + + +// Release app. resources associated with a printer +BOOL PrnClosePrinter( PRTQUEUE *pPrintQueue); + +// Get a DC for the selected printer. Must supply the application name. +HDC PrnOpenDC( PRTQUEUE *pPrintQueue, PSZ pszApplicationName, int copies, int destination, char *file); + +// Get the hardcopy caps for the selected form +BOOL PrnQueryHardcopyCaps( HDC hdc, PHCINFO pHCInfo); + +// Abort the current job started with PrnStartJob(). +BOOL PrnAbortJob( HDC hdc); + + + +#endif diff --git a/widget/src/os2/Makefile.in b/widget/src/os2/Makefile.in index 7c8ef990f975..43d618321fca 100644 --- a/widget/src/os2/Makefile.in +++ b/widget/src/os2/Makefile.in @@ -65,6 +65,7 @@ REQUIRES = gfx \ docshell \ webbrowserpersist \ imglib2 \ + unicharutil \ $(NULL) ifdef BUILD_STATIC_LIBS @@ -85,6 +86,9 @@ CPPSRCS = \ nsDragService.cpp \ nsScreenOS2.cpp \ nsScreenManagerOS2.cpp \ + nsDeviceContextSpecOS2.cpp \ + nsDeviceContextSpecFactoryO.cpp \ + nsPrintOptionsOS2.cpp \ $(NULL) SHARED_LIBRARY_LIBS = \ @@ -107,6 +111,8 @@ include $(topsrcdir)/config/rules.mk DEFINES += -D_IMPL_NS_WIDGET +DEFINES += -DUSE_OS2_TOOLKIT_HEADERS + LOCAL_INCLUDES = -I. -I$(srcdir)/../xpwidgets -I$(srcdir) export:: diff --git a/widget/src/os2/nsDragService.cpp b/widget/src/os2/nsDragService.cpp index 10016ee0cc6d..1eb09a65038e 100644 --- a/widget/src/os2/nsDragService.cpp +++ b/widget/src/os2/nsDragService.cpp @@ -1621,7 +1621,7 @@ nsresult GetTempFileName(char** outText) if (!pszText) return NS_ERROR_FAILURE; - char * pszPath; + const char * pszPath; if (!DosScanEnv("TEMP", &pszPath) || !DosScanEnv("TMP", &pszPath)) strcpy(pszText, pszPath); else diff --git a/widget/src/os2/nsWidgetFactory.cpp b/widget/src/os2/nsWidgetFactory.cpp index 1ad324a85a11..8e13eeed77bd 100644 --- a/widget/src/os2/nsWidgetFactory.cpp +++ b/widget/src/os2/nsWidgetFactory.cpp @@ -80,6 +80,12 @@ #include "nsScreenManagerOS2.h" +// Printing +#include "nsDeviceContextSpecOS2.h" +#include "nsDeviceContextSpecFactoryO.h" +#include "nsPrintOptionsOS2.h" +#include "nsPrintSession.h" + #include "nsFrameWindow.h" // OS/2 only // objects that just require generic constructors @@ -97,6 +103,11 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable) NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter) NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecOS2) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecFactoryOS2) +NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsOS2, Init) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorOS2) +NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init) NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerOS2) // component definition, will be exported using XPCOM @@ -158,6 +169,30 @@ static const nsModuleComponentInfo components[] = NS_SCREENMANAGER_CID, "@mozilla.org/gfx/screenmanager;1", nsScreenManagerOS2Constructor }, + { "OS/2 Device Context Spec", + NS_DEVICE_CONTEXT_SPEC_CID, + // "@mozilla.org/gfx/device_context_spec/gtk;1", + "@mozilla.org/gfx/devicecontextspec;1", + nsDeviceContextSpecOS2Constructor }, + { "OS/2 Device Context Spec Factory", + NS_DEVICE_CONTEXT_SPEC_FACTORY_CID, + // "@mozilla.org/gfx/device_context_spec_factory/gtk;1", + "@mozilla.org/gfx/devicecontextspecfactory;1", + nsDeviceContextSpecFactoryOS2Constructor }, + { "PrintSettings Service", + NS_PRINTSETTINGSSERVICE_CID, + // "@mozilla.org/gfx/printsettings-service;1", + "@mozilla.org/gfx/printsettings-service;1", + nsPrintOptionsOS2Constructor }, + { "Print Session", + NS_PRINTSESSION_CID, + "@mozilla.org/gfx/printsession;1", + nsPrintSessionConstructor }, + { "OS/2 Printer Enumerator", + NS_PRINTER_ENUMERATOR_CID, + // "@mozilla.org/gfx/printer_enumerator/gtk;1", + "@mozilla.org/gfx/printerenumerator;1", + nsPrinterEnumeratorOS2Constructor }, }; PR_STATIC_CALLBACK(void) diff --git a/widget/src/os2/nsWindow.cpp b/widget/src/os2/nsWindow.cpp index fe96e8be6d5d..e5e729de5f1a 100644 --- a/widget/src/os2/nsWindow.cpp +++ b/widget/src/os2/nsWindow.cpp @@ -2006,7 +2006,7 @@ HBITMAP nsWindow::DataToBitmap(PRUint8* aImageData, PRUint32 aWidth, // create a bitmap from the image data HBITMAP hBmp = GpiCreateBitmap(hps, &bi.head, CBM_INIT, - NS_REINTERPRET_CAST(const BYTE*, aImageData), + NS_REINTERPRET_CAST(BYTE*, aImageData), (BITMAPINFO2*)&bi); // free the hps, then return the bitmap