Closed Bug 84947 Opened 24 years ago Closed 23 years ago

We need a "better" print dialog...

Categories

(Core :: Printing: Output, enhancement)

All
Linux
enhancement
Not set
normal

Tracking

()

VERIFIED FIXED
mozilla0.9.7

People

(Reporter: roland.mainz, Assigned: roland.mainz)

References

Details

Attachments

(2 files, 27 obsolete files)

156.11 KB, patch
roland.mainz
: review+
roland.mainz
: superreview+
Details | Diff | Splinter Review
774 bytes, patch
Details | Diff | Splinter Review
We need a better print dialog for Mozilla on Unix platforms. This is mainly to reflect one of Xprint's main features - the ability to query supported printer features from the print server and only present "valid" print options in the print dialog. Native PostScript module should benefit from this feature, too - the admin would be able to "set" the values returned by EnumerateSupported*-functions via prefs instead of hacking the native source... A good example for this feature is our big poster printer which should _only_ print DIN-A0 print jobs. Unfortunately most applications are _hardcoded_ to DIN-A4 and US-letter, some offer DIN-A3, too - but none of them supports DIN-A0. BAD. And that's where Xprint can "jump-in". The idea is to write a XUL print dialog which queries attributes from the print system instead of using "hardcoded" values. Suggested API for communication between print dialog and native code: - EnumeratePrinters() - numerate all printers by "printer_name" and "display name" ("name is the string passed to other functions in this API to identify this printer) The native PostScript module (which only supports one printer) simply returns "mozilla_default_postscript_printer" which causes the "select printer dropdown" simply to hide itself... - CreateHandle(printer_name) - creates a handle to this printer, tracking resources - DestroyHandle(handle) - destroys handle - EnumerateSupportedPageOrientations(handle) - enumerate supported page orientations (portrait/landscape/etc.) - SetPageOrientation(handle) - set page orientation - EnumerateSupportedPaperSizes(handle) - enumerate supported paper sizes - SetPaperSize(handle) - set paper size - EnumerateSupportedColorModes(handle) - enumerate available color modes (b/w, grayscale, color, reverse-*, etc.) - SetColorMode(handle) - set color mode - EnumerateSupportedDPIValues(handle) - enumerate supported DPI values. - SetDPIValue(handle) - set DPI value This is enought for now, later versions can add more features (EnumerateSupported*, Set*)... Note that EnumerateSupported*-functions should always return two strings: the "human readable" format (example: "ISO DIN A3") and the "handle" format (example: "iso_din_a3"). Assigning to katakai@japan.sun.com - AFAIK he was one of the original "XUL print dialog" authors...
Setting milestone (yes... I know... it's _very_ close... but the "target milstone" dropdown doesn't offer "0.9.4" yet...)... Any comments ?
Target Milestone: --- → mozilla0.9.3
katakai, any comments ? IMHO we need this ASAP...
katakai - are you still alive ? :-)
target should be 1.0?? I'll start working soon.
Target Milestone: mozilla0.9.3 → Future
katakai: Is it possible to get this implemented for milestone 0.9.5, please ?
Keywords: helpwanted
I'm not an expert in Unix printing, and therefore my comment might be wrong. But my understanding is that this feature would work only in a limited set of environments. I fear, the information what features a printer does support, will only be available if you have a printing system that uses PPD files. My expectation is that your requested feature of a smart printer dialog is difficult to implement, because you often don't have a possibility to query the printer directly. If you have more information, please post comments how it could be done. But I have an idea that would be much simpler to implement. If your greatest problem is the support of different paper sizes, what about collecting a list of all sizes that Mozilla should (could) support? Let's simply extend the current list of only 5 hardcoded sizes and change this into a dropdown list with the all the paper sizes we know.
> I'm not an expert in Unix printing, and therefore my comment might be wrong. > But my understanding is that this feature would work only in a limited set of > environments. I fear, the information what features a printer does support, > will only be available if you have a printing system that uses PPD files. My > expectation is that your requested feature of a smart printer dialog is > difficult to implement, because you often don't have a possibility to > query the printer directly. If you have more information, please post > comments how it could be done. Xprint API does have an API to query all this information. You can simple ask the X print server for printer attributes, that's all. Only the Mozilla PS module would need direct support for querying such info, either via PPD or via prefs (easier (temp.) solution)... > But I have an idea that would be much simpler to implement. If your greatest > problem is the support of different paper sizes, what about collecting a list > of all sizes that Mozilla should (could) support? Let's simply extend the > current list of only 5 hardcoded sizes and change this into a dropdown list > with the all the paper sizes we know. Good luck. This does not work that way for (at least) three reasons: 1. Xprint API is not limited to paper size. You can query _tons_ of info... page size, plexes, color space, DPI, printer language etc. etc. We only need a subset, but everything should be queried from the printer device... 2. Just enumerating all page sizes would be hard (for the users =:-)... just think about all japanese paper sizes which are unknown to normal US/European users. This would be a long list (may be 20 or more items)... And you won't catch any custom size... 3. Just enumerating all possibilities would not get rid of the issue that a printer may be fed with wrong data. I want to get rid of the xx!!@@-issue that people can spam our poster printer with DIN A4 jobs with the excuse "that application offered that paper size"... The API suggested in this RFE still is very simple. I can do the work _except_ the XUL/JS stuff. That's my only problem... ;-((
Retargeting to 0.9.5 ...
Target Milestone: Future → mozilla0.9.5
Adding reference to bug 24847 - we need this one "in" first before starting hacking this one ...
Depends on: 24847
If you fix the dialog to query the Xprt server, can you also try to fix bug 90947. CUPS also includes information about the avaiable printer features. Or at least keep in mind that there is also this mechanism and make it flexible enough ;-) (http://www.cups.org/spm.html#CUPS_API) Maybe I will hack something for CUPS, but I don't know the Mozilla source well :-(
Depends on: 90380
Depends on: 97907
Depends on: 100069
mkaply: Is there any way to chat with you (irc.mozilla.org does not work for me) ? I have some ideas and new code - but I still need someone how knows about the XUL/XPCOM stuff...
Some thougths for the new architecture: - new class/interface nsIPrinterHandle with the following features: - constructor is _private_ * a |static| method to enumerate all available printers by {name, descr} * a |static| method to create an object based on the given |name| * method to get all available choices of an attribute (enumeration!?) * method to set/get an attribute ("set" may return an error if it is not supported) - |FinishSetup| method to inidate that the setup is "done", make final checks&alloc required resources, return NS_OK on success. [*] indicates that the method must be available to the print dialog code (e.g. XUL/JS/XPCONNECT) An alternative to the |private constructor| design would be that functions to enumerate available attribute values simply return an error until the object has been initalized with a name.
I'm posting a diff of a printer dialog that will display the printers in a dropdown list with a properties button to display the printer's properties dlg. I've added copies, and user can enter a path/filename to print to a file. I've changed OS/2 specific code for this to work on OS/2. I will also be adding files because I cannot do a cvs add.
Retargetting... Can anyone take this bug?
Target Milestone: mozilla0.9.5 → mozilla0.9.6
katakai wrote: > Can anyone take this bug? Taking over...
Assignee: katakai → Roland.Mainz
Changing my e-mail address.
Removing old e-mail address.
Accepting bug. ---- I am going to post more on sunday (short: I'd like to share the new OS/2 print dialog on Unix, too :-)
Status: NEW → ASSIGNED
Comment on attachment 51245 [details] [diff] [review] files already in mozilla that have been changed for print dlg to work -updated ? obj ? gfx/src/os2/nsPrintdOS2.h ? xpfe/global/resources/content/os2/printdialog.js ? xpfe/global/resources/content/os2/printdialog.xul ? xpfe/global/resources/locale/en-US/os2/platformDialogOverlay.dtd ? xpfe/global/resources/locale/en-US/os2/platformGlobalOverlay.dtd ? xpfe/global/resources/locale/en-US/os2/platformKeys.properties ? xpfe/global/resources/locale/en-US/os2/printdialog.dtd ? xpfe/global/resources/locale/en-US/os2/wizard.properties Index: content/base/src/nsDocumentViewer.cpp =================================================================== RCS file: /cvsroot/mozilla/content/base/src/nsDocumentViewer.cpp,v retrieving revision 1.155 diff -u -r1.155 nsDocumentViewer.cpp --- content/base/src/nsDocumentViewer.cpp 2001/10/03 23:28:38 1.155 +++ content/base/src/nsDocumentViewer.cpp 2001/10/05 18:50:17 @@ -4479,7 +4479,8 @@ /* cleanup done, let's fire-up an error dialog to notify the user * what went wrong... */ - ShowPrintErrorDialog(rv); + if (rv != NS_ERROR_ABORT) + ShowPrintErrorDialog(rv); } return rv; Index: gfx/idl/nsIPrintOptions.idl =================================================================== RCS file: /cvsroot/mozilla/gfx/idl/nsIPrintOptions.idl,v retrieving revision 1.14 diff -u -r1.14 nsIPrintOptions.idl --- gfx/idl/nsIPrintOptions.idl 2001/09/26 14:01:22 1.14 +++ gfx/idl/nsIPrintOptions.idl 2001/10/05 18:50:52 @@ -44,6 +44,10 @@ #include "nsFont.h" %} +#ifdef XP_OS2 +interface nsISimpleEnumerator; +#endif + /** * Native types */ @@ -133,6 +137,17 @@ */ void WritePrefs(); +#ifdef XP_OS2 + /** + * available Printers + */ + nsISimpleEnumerator availablePrinters (); + + /** + * display Printer Job Properties dialog + */ + void displayJobProperties (in wstring aPrinter, out boolean aDisplayed); +#endif /** * Data Members @@ -170,6 +185,10 @@ attribute long paperSize; /* see page size consts */ attribute long orientation; /* see orientation consts */ attribute wstring printCommand; +#ifdef XP_OS2 + attribute long numCopies; + attribute wstring printer; +#endif attribute boolean printToFile; attribute wstring toFileName; @@ -186,6 +205,29 @@ [noscript] void SetDefaultFont(in nsNativeFontRef aMargin); /* Purposely made this an "in" arg */ [noscript] void GetDefaultFont(in nsNativeFontRef aMargin); +}; +#ifdef XP_OS2 +[scriptable, uuid(a6cf9128-15b3-11d2-932e-00805f8add32)] +interface nsIPrinterEnumerator : nsISupports +{ + /** + * Return an array of the names of all installed printers. + * + * @param aCount returns number of printers returned + * @param aResult returns array of names + * @return void + */ + void EnumeratePrinters(out PRUint32 aCount,[retval, array, size_is(aCount)] out wstring aResult); + + /* takes printer selected and will display job properties dlg for that printer + * returns true if dialog displays + */ + void DisplayPropertiesDlg(in wstring aPrinter); + }; +#endif + + + Index: gfx/public/nsGfxCIID.h =================================================================== RCS file: /cvsroot/mozilla/gfx/public/nsGfxCIID.h,v retrieving revision 1.12 diff -u -r1.12 nsGfxCIID.h --- gfx/public/nsGfxCIID.h 2001/09/26 00:15:05 1.12 +++ gfx/public/nsGfxCIID.h 2001/10/05 18:50:52 @@ -103,5 +103,8 @@ { 0x30a3b080, 0x4867, 0x11d4, \ { 0xa8, 0x56, 0x0, 0x10, 0x5a, 0x18, 0x34, 0x19 } } +#define NS_PRINTER_ENUMERATOR_CID \ +{ 0xa6cf9129, 0x15b3, 0x11d2, \ +{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} } #endif Index: gfx/src/nsPrintOptionsImpl.cpp =================================================================== RCS file: /cvsroot/mozilla/gfx/src/nsPrintOptionsImpl.cpp,v retrieving revision 1.15 diff -u -r1.15 nsPrintOptionsImpl.cpp --- gfx/src/nsPrintOptionsImpl.cpp 2001/09/29 08:26:33 1.15 +++ gfx/src/nsPrintOptionsImpl.cpp 2001/10/05 18:50:53 @@ -48,6 +48,15 @@ //NS_IMPL_ISUPPORTS1(nsPrintOptions, nsIPrintOptions) NS_IMPL_ADDREF(nsPrintOptions) NS_IMPL_RELEASE(nsPrintOptions) + +#ifdef XP_OS2 +#include "nsISimpleEnumerator.h" +#include "nsISupportsPrimitives.h" +#include "nsGfxCIID.h" + +static NS_DEFINE_IID(kCPrinterEnumerator, NS_PRINTER_ENUMERATOR_CID); +#endif + NS_IMETHODIMP nsPrintOptions::QueryInterface(REFNSIID aIID, void** aInstancePtr) { if (NULL == aInstancePtr) { @@ -66,6 +75,7 @@ NS_ADDREF_THIS(); return NS_OK; } + return NS_NOINTERFACE; } @@ -91,6 +101,9 @@ const char * kPrintPaperSize = "print.print_paper_size"; const char * kPrintOrientation= "print.print_orientation"; const char * kPrintCommand = "print.print_command"; +#ifdef XP_OS2 +const char * kPrinter = "print.print_printer"; +#endif const char * kPrintFile = "print.print_file"; const char * kPrintToFile = "print.print_tofile"; const char * kPrintPageDelay = "print.print_pagedelay"; @@ -116,6 +129,9 @@ mPrintRange(kRangeAllPages), mStartPageNum(1), mEndPageNum(1), +#ifdef XP_OS2 + mNumCopies(1), +#endif mPrintOptions(0L), mPrintReversed(PR_FALSE), mPrintInColor(PR_TRUE), @@ -163,6 +179,90 @@ } } + +#ifdef XP_OS2 +class +nsPrinterListEnumerator : public nsISimpleEnumerator +{ + public: + nsPrinterListEnumerator(); + virtual ~nsPrinterListEnumerator(); + + //nsISupports interface + NS_DECL_ISUPPORTS + + //nsISimpleEnumerator interface + NS_DECL_NSISIMPLEENUMERATOR + + NS_IMETHOD Init(); + + protected: + PRUnichar **mPrinters; + PRUint32 mCount; + PRUint32 mIndex; +}; + +nsPrinterListEnumerator::nsPrinterListEnumerator() : + mPrinters(nsnull), mCount(0), mIndex(0) +{ + NS_INIT_REFCNT(); +} + +nsPrinterListEnumerator::~nsPrinterListEnumerator() +{ + if (mPrinters) { + PRUint32 i; + for (i = 0; i < mCount; i++ ) { + nsMemory::Free(mPrinters[i]); + } + nsMemory::Free(mPrinters); + } +} + +NS_IMPL_ISUPPORTS1(nsPrinterListEnumerator, nsISimpleEnumerator) + +NS_IMETHODIMP nsPrinterListEnumerator::Init( ) +{ + nsresult rv; + nsCOMPtr<nsIPrinterEnumerator> printerEnumerator; + + printerEnumerator = do_CreateInstance(kCPrinterEnumerator, &rv); + if (NS_FAILED(rv)) + return rv; + + rv = printerEnumerator->EnumeratePrinters(&mCount, &mPrinters); + return rv; +} + +NS_IMETHODIMP nsPrinterListEnumerator::HasMoreElements(PRBool *result) +{ + *result = (mIndex < mCount); + return NS_OK; +} + +NS_IMETHODIMP nsPrinterListEnumerator::GetNext(nsISupports **aPrinter) +{ + NS_ENSURE_ARG_POINTER(aPrinter); + *aPrinter = nsnull; + if (mIndex >= mCount) { + return NS_ERROR_UNEXPECTED; + } + + PRUnichar *printerName = mPrinters[mIndex++]; + nsCOMPtr<nsISupportsWString> printerNameWrapper; + nsresult rv; + + rv = nsComponentManager::CreateInstance(NS_SUPPORTS_WSTRING_CONTRACTID, nsnull, + NS_GET_IID(nsISupportsWString), getter_AddRefs(printerNameWrapper)); + NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_TRUE(printerNameWrapper, NS_ERROR_OUT_OF_MEMORY); + printerNameWrapper->SetData(NS_CONST_CAST(PRUnichar*, printerName)); + *aPrinter = NS_STATIC_CAST(nsISupports*, printerNameWrapper); + NS_ADDREF(*aPrinter); + return NS_OK; +} +#endif + /** --------------------------------------------------- * See documentation in nsPrintOptionsImpl.h * @update 1/12/01 rods @@ -306,6 +406,9 @@ prefs->GetIntPref(kPrintPaperSize, &mPaperSize); prefs->GetIntPref(kPrintOrientation, &mOrientation); ReadPrefString(prefs, kPrintCommand, mPrintCommand); +#ifdef XP_OS2 + ReadPrefString(prefs, kPrinter, mPrinter); +#endif prefs->GetBoolPref(kPrintFile, &mPrintToFile); ReadPrefString(prefs, kPrintToFile, mToFileName); prefs->GetIntPref(kPrintPageDelay, &mPrintPageDelay); @@ -345,6 +448,9 @@ prefs->SetIntPref(kPrintPaperSize, mPaperSize); prefs->SetIntPref(kPrintOrientation, mOrientation); WritePrefString(prefs, kPrintCommand, mPrintCommand); +#ifdef XP_OS2 + WritePrefString(prefs, kPrinter, mPrinter); +#endif prefs->SetBoolPref(kPrintFile, mPrintToFile); WritePrefString(prefs, kPrintToFile, mToFileName); prefs->SetIntPref(kPrintPageDelay, mPrintPageDelay); @@ -419,6 +525,19 @@ return NS_OK; } /* attribute wstring printCommand; */ NS_IMETHODIMP nsPrintOptions::GetPrintCommand(PRUnichar * *aPrintCommand) { //NS_ENSURE_ARG_POINTER(aPrintCommand); *aPrintCommand = mPrintCommand.ToNewUnicode(); return NS_OK; } NS_IMETHODIMP nsPrintOptions::SetPrintCommand(const PRUnichar * aPrintCommand) { mPrintCommand = aPrintCommand; return NS_OK; } /* attribute short orientation; */ NS_IMETHODIMP nsPrintOptions::GetOrientation(PRInt32 *aOrientation) { @@ -432,18 +551,71 @@ return NS_OK; } +#ifdef XP_OS2 +/* attribute wstring printer; */ +NS_IMETHODIMP nsPrintOptions::GetPrinter(PRUnichar * *aPrinter) + { + //NS_ENSURE_ARG_POINTER(aPrinter); + *aPrinter = mPrinter.ToNewUnicode(); + return NS_OK; +} +NS_IMETHODIMP nsPrintOptions::SetPrinter(const PRUnichar * aPrinter) +{ + mPrinter = aPrinter; + return NS_OK; +} + +/* attribute long numCopies; */ +NS_IMETHODIMP nsPrintOptions::GetNumCopies(PRInt32 *aNumCopies) +{ + //NS_ENSURE_ARG_POINTER(aNumCopies); + *aNumCopies = mNumCopies; + return NS_OK; +} +NS_IMETHODIMP nsPrintOptions::SetNumCopies(PRInt32 aNumCopies) +{ + mNumCopies = aNumCopies; + return NS_OK; +} + +NS_IMETHODIMP nsPrintOptions::AvailablePrinters( nsISimpleEnumerator **aPrinterEnumerator) +{ + NS_ENSURE_ARG_POINTER(aPrinterEnumerator); + nsCOMPtr<nsPrinterListEnumerator> printerListEnum = new nsPrinterListEnumerator(); + NS_ENSURE_TRUE(printerListEnum.get(), NS_ERROR_OUT_OF_MEMORY); + + nsresult rv = printerListEnum->Init(); + NS_ENSURE_SUCCESS(rv, rv); + + *aPrinterEnumerator = NS_STATIC_CAST(nsISimpleEnumerator*, printerListEnum); + NS_ADDREF(*aPrinterEnumerator); + return NS_OK; + +} + +NS_IMETHODIMP nsPrintOptions::DisplayJobProperties( const PRUnichar *aPrinter, PRBool *aDisplayed) +{ + NS_ENSURE_ARG(aPrinter); + *aDisplayed = PR_FALSE; + + nsresult rv; + nsCOMPtr<nsIPrinterEnumerator> propDlg; + + propDlg = do_CreateInstance(kCPrinterEnumerator, &rv); + if (NS_FAILED(rv)) + return rv; + + if (NS_OK == propDlg->DisplayPropertiesDlg((PRUnichar*)aPrinter)) + *aDisplayed = PR_TRUE; + + return NS_OK; +} +#endif /* attribute boolean printToFile; */ NS_IMETHODIMP nsPrintOptions::GetPrintToFile(PRBool *aPrintToFile) Index: gfx/src/nsPrintOptionsImpl.h =================================================================== RCS file: /cvsroot/mozilla/gfx/src/nsPrintOptionsImpl.h,v retrieving revision 1.9 diff -u -r1.9 nsPrintOptionsImpl.h --- gfx/src/nsPrintOptionsImpl.h 2001/09/26 14:01:25 1.9 +++ gfx/src/nsPrintOptionsImpl.h 2001/10/05 18:50:53 @@ -24,7 +24,6 @@ #define nsPrintOptionsImpl_h__ #include "nsIPrintOptions.h" - class nsIPref; //***************************************************************************** @@ -84,12 +83,15 @@ PRInt32 mPaperSize; // see page size consts PRInt32 mOrientation; // see orientation consts nsString mPrintCommand; +#ifdef XP_OS2 + PRInt32 mNumCopies; + nsString mPrinter; +#endif PRBool mPrintToFile; nsString mToFileName; static nsFont* mDefaultFont; }; - #endif /* nsPrintOptions_h__ */ Index: gfx/src/os2/Makefile.in =================================================================== RCS file: /cvsroot/mozilla/gfx/src/os2/Makefile.in,v retrieving revision 1.24 diff -u -r1.24 Makefile.in --- gfx/src/os2/Makefile.in 2001/09/28 02:42:47 1.24 +++ gfx/src/os2/Makefile.in 2001/10/05 18:50:53 @@ -35,21 +35,23 @@ REQUIRES = xpcom \ string \ widget \ + view \ + util \ + dom \ pref \ uconv \ + windowwatcher \ + locale \ $(NULL) -DIRS = res - CPPSRCS = \ - libprint.cpp \ + nsDeviceContextSpecOS2.cpp \ nsDeviceContextOS2.cpp \ nsDrawingSurfaceOS2.cpp \ nsRenderingContextOS2.cpp \ nsFontMetricsOS2.cpp \ nsImageOS2.cpp \ nsRegionOS2.cpp \ - nsDeviceContextSpecOS2.cpp \ nsDeviceContextSpecFactoryO.cpp \ nsScreenOS2.cpp \ nsScreenManagerOS2.cpp \ @@ -57,8 +59,6 @@ nsPrintOptionsOS2.cpp \ nsGfxDefs.cpp \ $(NULL) - -RES_FILE = $(srcdir)/libprint.res EXPORTS = \ nsIRenderingContextOS2.h \ Index: gfx/src/os2/nsDeviceContextOS2.cpp =================================================================== RCS file: /cvsroot/mozilla/gfx/src/os2/nsDeviceContextOS2.cpp,v retrieving revision 1.42 diff -u -r1.42 nsDeviceContextOS2.cpp --- gfx/src/os2/nsDeviceContextOS2.cpp 2001/10/02 03:10:39 1.42 +++ gfx/src/os2/nsDeviceContextOS2.cpp 2001/10/05 18:50:53 @@ -73,12 +73,6 @@ mPrintState = nsPrintState_ePreBeginDoc; #endif -#ifdef XP_OS2 // OS2TODO - GET RID OF THIS! - // Init module if necessary - if( !gGfxModuleData.hpsScreen) - gGfxModuleData.Init(); -#endif - // The first time in we initialize gIsWarp4 flag if (NOT_SETUP == gIsWarp4) { unsigned long ulValues[2]; @@ -823,13 +817,21 @@ } else { return NS_ERROR_OUT_OF_MEMORY; } - + ((nsDeviceContextOS2 *)aContext)->mSpec = aDevice; NS_ADDREF(aDevice); + + int numCopies = 0; + int toPrinter = 0; + char *file = nsnull; ((nsDeviceContextSpecOS2 *)aDevice)->GetPRTQUEUE(pq); + ((nsDeviceContextSpecOS2 *)aDevice)->GetCopies(numCopies); + ((nsDeviceContextSpecOS2 *)aDevice)->GetToPrinter(toPrinter); + if (!toPrinter) + ((nsDeviceContextSpecOS2 *)aDevice)->GetPath(&file); - HDC dc = PrnOpenDC(pq, "Mozilla"); + HDC dc = PrnOpenDC(pq, "Mozilla", numCopies, toPrinter, file); if (!dc) { PMERROR("DevOpenDC"); Index: gfx/src/os2/nsDeviceContextOS2.h =================================================================== RCS file: /cvsroot/mozilla/gfx/src/os2/nsDeviceContextOS2.h,v retrieving revision 1.16 diff -u -r1.16 nsDeviceContextOS2.h --- gfx/src/os2/nsDeviceContextOS2.h 2001/10/02 03:10:39 1.16 +++ gfx/src/os2/nsDeviceContextOS2.h 2001/10/05 18:50:53 @@ -43,7 +43,7 @@ #include "nsDeviceContext.h" #include "nsIScreenManager.h" -#include "libprint.h" +#include "nsDeviceContextSpecOS2.h" class nsIScreen; Index: gfx/src/os2/nsDeviceContextSpecFactoryO.cpp =================================================================== RCS file: /cvsroot/mozilla/gfx/src/os2/nsDeviceContextSpecFactoryO.cpp,v retrieving revision 1.10 diff -u -r1.10 nsDeviceContextSpecFactoryO.cpp --- gfx/src/os2/nsDeviceContextSpecFactoryO.cpp 2001/09/26 00:15:34 1.10 +++ gfx/src/os2/nsDeviceContextSpecFactoryO.cpp 2001/10/05 18:50:53 @@ -40,9 +40,6 @@ #include "nsDeviceContextSpecFactoryO.h" #include "nsDeviceContextSpecOS2.h" -#define INCL_DEV -#include <os2.h> -#include "libprint.h" #include "nsGfxCIID.h" nsDeviceContextSpecFactoryOS2 :: nsDeviceContextSpecFactoryOS2() @@ -54,11 +51,8 @@ { } -static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID); -static NS_DEFINE_CID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID); +NS_IMPL_ISUPPORTS1(nsDeviceContextSpecFactoryOS2, nsIDeviceContextSpecFactory); -NS_IMPL_ISUPPORTS1(nsDeviceContextSpecFactoryOS2, nsIDeviceContextSpecFactory) - NS_IMETHODIMP nsDeviceContextSpecFactoryOS2 :: Init(void) { return NS_OK; @@ -70,30 +64,16 @@ nsIDeviceContextSpec *&aNewSpec, PRBool aQuiet) { - nsresult rv = NS_ERROR_FAILURE; - PRINTDLG PrnDlg; - - PRTQUEUE* pq = PrnDlg.SelectPrinter (HWND_DESKTOP, aQuiet ? TRUE : FALSE); - - if( pq) - { - nsIDeviceContextSpec *devspec = nsnull; - - nsComponentManager::CreateInstance(kDeviceContextSpecCID, nsnull, kIDeviceContextSpecIID, (void **)&devspec); - - if (nsnull != devspec) - { - //XXX need to QI rather than cast... MMP - if (NS_OK == ((nsDeviceContextSpecOS2 *)devspec)->Init(pq)) - { - aNewSpec = devspec; - rv = NS_OK; - } - } - } else { - // Cancel was pressed - rv = NS_ERROR_ABORT; - } - - return rv; + nsresult rv; + static NS_DEFINE_CID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID); + nsCOMPtr<nsIDeviceContextSpec> devSpec = do_CreateInstance(kDeviceContextSpecCID, &rv); + + if (NS_SUCCEEDED(rv)) { + rv = ((nsDeviceContextSpecOS2 *)devSpec.get())->Init(aQuiet); + if (NS_SUCCEEDED(rv)) { + aNewSpec = devSpec; + NS_ADDREF(aNewSpec); + } + } + return rv; } Index: gfx/src/os2/nsDeviceContextSpecOS2.cpp =================================================================== RCS file: /cvsroot/mozilla/gfx/src/os2/nsDeviceContextSpecOS2.cpp,v retrieving revision 1.3 diff -u -r1.3 nsDeviceContextSpecOS2.cpp --- gfx/src/os2/nsDeviceContextSpecOS2.cpp 2001/08/21 01:46:35 1.3 +++ gfx/src/os2/nsDeviceContextSpecOS2.cpp 2001/10/05 18:50:53 @@ -1,52 +1,752 @@ -/* - * 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, - * <john_fairhurst@iname.com>. Portions created by John Fairhurst are - * Copyright (C) 1999 John Fairhurst. All Rights Reserved. +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape 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/NPL/ + * + * 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. * - * Contributor(s): - * Pierre Phaneuf <pp@ludusdesign.com> + * The Original Code is mozilla.org code. * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * Roland Mainz <roland.mainz@informatik.med.uni-giessen.de> + * */ +#include "nsDeviceContextSpecOS2.h" + +#include "nsCOMPtr.h" +#include "nsIServiceManager.h" +#include "nsIPrintOptions.h" +#include "nsGfxCIID.h" #include "nsGfxDefs.h" -#include "libprint.h" -#include "nsDeviceContextSpecOS2.h" +#include "nsIPref.h" +#include "prenv.h" /* for PR_GetEnv */ + +#include "nsIDOMWindow.h" +#include "nsIServiceManager.h" +#include "nsIDialogParamBlock.h" +#include "nsISupportsPrimitives.h" +#include "nsIWindowWatcher.h" +#include "nsIDOMWindowInternal.h" -nsDeviceContextSpecOS2::nsDeviceContextSpecOS2() -{ - NS_INIT_REFCNT(); - mQueue = nsnull; +static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID); + +nsStringArray* nsDeviceContextSpecOS2::globalPrinterList = nsnull; +int nsDeviceContextSpecOS2::globalNumPrinters = 0; +PRINTDLG nsDeviceContextSpecOS2::PrnDlg; + +/** ------------------------------------------------------- + * Construct the nsDeviceContextSpecOS2 + * @update dc 12/02/98 + */ +nsDeviceContextSpecOS2 :: nsDeviceContextSpecOS2() +{ + NS_INIT_REFCNT(); + mQueue = nsnull; } -nsDeviceContextSpecOS2::~nsDeviceContextSpecOS2() +/** ------------------------------------------------------- + * Destroy the nsDeviceContextSpecOS2 + * @update dc 2/15/98 + */ +nsDeviceContextSpecOS2 :: ~nsDeviceContextSpecOS2() { if( mQueue) PrnClosePrinter( mQueue); } +static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID); +//static NS_DEFINE_IID(kIDeviceContextSpecPSIID, NS_IDEVICE_CONTEXT_SPEC_PS_IID); +#ifdef USE_XPRINT +static NS_DEFINE_IID(kIDeviceContextSpecXPIID, NS_IDEVICE_CONTEXT_SPEC_XP_IID); +#endif + +#if 0 NS_IMPL_ISUPPORTS1(nsDeviceContextSpecOS2, nsIDeviceContextSpec) +#endif + +NS_IMETHODIMP nsDeviceContextSpecOS2 :: QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + if (nsnull == aInstancePtr) + return NS_ERROR_NULL_POINTER; + + if (aIID.Equals(kIDeviceContextSpecIID)) + { + nsIDeviceContextSpec* tmp = this; + *aInstancePtr = (void*) tmp; + NS_ADDREF_THIS(); + return NS_OK; + } + +/* if (aIID.Equals(kIDeviceContextSpecPSIID)) + { + nsIDeviceContextSpecPS* tmp = this; + *aInstancePtr = (void*) tmp; + NS_ADDREF_THIS(); + return NS_OK; + } +*/ +#ifdef USE_XPRINT + if (aIID.Equals(kIDeviceContextSpecXPIID)) + { + nsIDeviceContextSpecXp *tmp = this; + *aInstancePtr = (void*) tmp; + NS_ADDREF_THIS(); + return NS_OK; + } +#endif /* USE_XPRINT */ + + static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); + + if (aIID.Equals(kISupportsIID)) + { + nsIDeviceContextSpec* tmp = this; + nsISupports* tmp2 = tmp; + *aInstancePtr = (void*) tmp2; + NS_ADDREF_THIS(); + return NS_OK; + } + + return NS_NOINTERFACE; +} + +NS_IMPL_ADDREF(nsDeviceContextSpecOS2) +NS_IMPL_RELEASE(nsDeviceContextSpecOS2) + +int nsDeviceContextSpecOS2::InitializeGlobalPrinters () +{ + globalNumPrinters = PrnDlg.GetNumPrinters(); + if (!globalNumPrinters) + return NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAIULABLE; + + globalPrinterList = new nsStringArray(); + if (!globalPrinterList) + return NS_ERROR_OUT_OF_MEMORY; + + int defaultPrinter = PrnDlg.GetDefaultPrinter(); + + int j = 0; + for (int i = 0; i < globalNumPrinters; i++) { + char *printer = PrnDlg.GetPrinter(i); + if ( defaultPrinter == i ) + globalPrinterList->InsertStringAt(nsString(NS_ConvertASCIItoUCS2(printer)), 0); + else + globalPrinterList->AppendString(nsString(NS_ConvertASCIItoUCS2(printer))); + } + return NS_OK; +} + +/* +void nsDeviceContextSpecOS2::FreeGlobalPrinters () +{ +} +*/ + + +/** ------------------------------------------------------- + * Initialize the nsDeviceContextSpecOS2 + * @update dc 2/15/98 + * @update syd 3/2/99 + * + * gisburn: Please note that this function exists as 1:1 copy in other + * toolkits including: + * - GTK+-toolkit: + * file: mozilla/gfx/src/gtk/nsDeviceContextSpecG.cpp + * function: NS_IMETHODIMP nsDeviceContextSpecGTK::Init(PRBool aQuiet) + * - Xlib-toolkit: + * file: mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp + * function: NS_IMETHODIMP nsDeviceContextSpecXlib::Init(PRBool aQuiet) + * - Qt-toolkit: + * file: mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp + * function: NS_IMETHODIMP nsDeviceContextSpecQT::Init(PRBool aQuiet) + * + * ** Please update the other toolkits when changing this function. + */ +NS_IMETHODIMP nsDeviceContextSpecOS2::Init(PRBool aQuiet) +{ + nsresult rv = NS_ERROR_FAILURE; + + nsCOMPtr<nsIPrintOptions> printService(do_GetService(kPrintOptionsCID, &rv)); + NS_ASSERTION(nsnull != printService, "No print service."); + + // if there is a current selection then enable the "Selection" radio button + if (NS_SUCCEEDED(rv) && printService) { + PRBool isOn; + printService->GetPrintOptions(nsIPrintOptions::kPrintOptionsEnableSelectionRB, &isOn); + nsCOMPtr<nsIPref> pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv); + if (NS_SUCCEEDED(rv) && pPrefs) { + (void) pPrefs->SetBoolPref("print.selection_radio_enabled", isOn); + } + } + + char *path; + PRBool canPrint = PR_FALSE; + PRBool tofile = PR_FALSE; + PRInt16 printRange = nsIPrintOptions::kRangeAllPages; + PRInt32 fromPage = 1; + PRInt32 toPage = 1; + PRInt32 copies = 1; + PRUnichar *printer = nsnull; + PRUnichar *printfile = nsnull; + + if( !globalPrinterList ) + if (InitializeGlobalPrinters()) + return NS_ERROR_GFX_PRINTER_NO_PRINTER_AVAIULABLE; + if( globalNumPrinters && !globalPrinterList->Count() ) + return NS_ERROR_OUT_OF_MEMORY; + + if (PR_FALSE == aQuiet ) { + rv = NS_ERROR_FAILURE; + nsCOMPtr<nsIDialogParamBlock> ioParamBlock(do_CreateInstance("@mozilla.org/embedcomp/dialogparam;1")); + + nsCOMPtr<nsISupportsInterfacePointer> paramBlockWrapper; + if (ioParamBlock) + paramBlockWrapper = do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID); + + if (paramBlockWrapper) { + paramBlockWrapper->SetData(ioParamBlock); + paramBlockWrapper->SetDataIID(&NS_GET_IID(nsIDialogParamBlock)); + + nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1")); + if (wwatch) { + + nsCOMPtr<nsIDOMWindowInternal> parent; + nsCOMPtr<nsIDOMWindow> active; + wwatch->GetActiveWindow(getter_AddRefs(active)); + if (active) { + active->QueryInterface(NS_GET_IID(nsIDOMWindowInternal), getter_AddRefs(parent)); + } + + nsCOMPtr<nsIDOMWindow> newWindow; + rv = wwatch->OpenWindow(parent, "chrome://global/content/printdialog.xul", + "_blank", "chrome,modal", paramBlockWrapper, + getter_AddRefs(newWindow)); + } + } + if (NS_SUCCEEDED(rv)) { + PRInt32 buttonPressed = 0; + ioParamBlock->GetInt(0, &buttonPressed); + if (buttonPressed == 0) + canPrint = PR_TRUE; + else + return NS_ERROR_ABORT; + } + } else { + canPrint = PR_TRUE; + } + + if (canPrint) { + if (printService) { + printService->GetPrinter(&printer); + printService->GetPrintRange(&printRange); + printService->GetToFileName(&printfile); + printService->GetPrintToFile(&tofile); + printService->GetStartPageRange(&fromPage); + printService->GetEndPageRange(&toPage); + printService->GetNumCopies(&copies); -nsresult nsDeviceContextSpecOS2::Init( PRTQUEUE *pq) + if ((copies == 0) || (copies > 999)) + return NS_ERROR_FAILURE; + + if (printfile != nsnull) { + // ToDo: Use LocalEncoding instead of UTF-8 (see bug 73446) + strcpy(mPrData.path, NS_ConvertUCS2toUTF8(printfile).get()); + } + if (printer != nsnull) + strcpy(mPrData.printer, NS_ConvertUCS2toUTF8(printer).get()); + } + + mPrData.toPrinter = !tofile; + mPrData.copies = copies; + + if (globalNumPrinters) { + for(int i = 0; (i < globalNumPrinters) && !mQueue; i++) { + if (!(globalPrinterList->StringAt(i)->CompareWithConversion(mPrData.printer, TRUE, -1))) + mQueue = PrnDlg.SetPrinterQueue(i); + } + } + + if (printfile != nsnull) + nsMemory::Free(printfile); + + if (printer != nsnull) + nsMemory::Free(printer); + +// FreeGlobalPrinters(); + return NS_OK; + } +// FreeGlobalPrinters(); + + return rv; +} + + +NS_IMETHODIMP nsDeviceContextSpecOS2 :: GetToPrinter( PRBool &aToPrinter ) +{ + aToPrinter = mPrData.toPrinter; + return NS_OK; +} + +NS_IMETHODIMP nsDeviceContextSpecOS2 :: GetPrinter ( char **aPrinter ) +{ + *aPrinter = &mPrData.printer[0]; + return NS_OK; +} + +NS_IMETHODIMP nsDeviceContextSpecOS2 :: GetCopies ( int &aCopies ) { - mQueue = pq; + aCopies = mPrData.copies; return NS_OK; } + +NS_IMETHODIMP nsDeviceContextSpecOS2 :: GetPath ( char **aPath ) +{ + *aPath = &mPrData.path[0]; + return NS_OK; +} + +NS_IMETHODIMP nsDeviceContextSpecOS2 :: GetUserCancelled( PRBool &aCancel ) +{ + aCancel = mPrData.cancel; + return NS_OK; +} + +/** ------------------------------------------------------- + * Closes the printmanager if it is open. + * @update dc 2/15/98 + */ +NS_IMETHODIMP nsDeviceContextSpecOS2 :: ClosePrintManager() +{ + return NS_OK; +} + nsresult nsDeviceContextSpecOS2::GetPRTQUEUE( PRTQUEUE *&p) { p = mQueue; return NS_OK; } + +// Printer Enumerator +nsPrinterEnumeratorOS2::nsPrinterEnumeratorOS2() +{ + NS_INIT_REFCNT(); +} + +NS_IMPL_ISUPPORTS1(nsPrinterEnumeratorOS2, nsIPrinterEnumerator) + +NS_IMETHODIMP nsPrinterEnumeratorOS2::EnumeratePrinters(PRUint32* aCount, PRUnichar*** aResult) +{ + if (aCount) + *aCount = 0; + else + return NS_ERROR_NULL_POINTER; + + if (aResult) + *aResult = nsnull; + else + return NS_ERROR_NULL_POINTER; + + + PRUnichar** array = (PRUnichar**) nsMemory::Alloc(nsDeviceContextSpecOS2::globalNumPrinters * sizeof(PRUnichar*)); + if (!array && nsDeviceContextSpecOS2::globalNumPrinters) + return NS_ERROR_OUT_OF_MEMORY; + + int count = 0; + while( count < nsDeviceContextSpecOS2::globalNumPrinters ) + { + PRUnichar *str = (PRUnichar *)nsDeviceContextSpecOS2::globalPrinterList->StringAt(count)->ToNewUnicode();//get(); + + if (!str) { + for (int i = count - 1; i >= 0; i--) + nsMemory::Free(array[i]); + + nsMemory::Free(array); + return NS_ERROR_OUT_OF_MEMORY; + } + array[count++] = str; + + } + *aCount = count; + *aResult = array; + + return NS_OK; +} + +NS_IMETHODIMP nsPrinterEnumeratorOS2::DisplayPropertiesDlg(const PRUnichar *aPrinter) +{ + for(int i = 0; i < nsDeviceContextSpecOS2::globalNumPrinters; i++) { + if (!(nsDeviceContextSpecOS2::globalPrinterList->StringAt(i)->CompareWithConversion(aPrinter, TRUE, -1))) { + if ( nsDeviceContextSpecOS2::PrnDlg.ShowProperties(i) ) + return NS_OK; + } + } + return NS_ERROR_FAILURE; +} + +//--------------------------------------------------------------------------- +// OS/2 Printing - was in libprint.cpp +//--------------------------------------------------------------------------- +static HMODULE hmodRes; +static BOOL prnEscape (HDC hdc, long lEscape); + +#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; + mDefaultQueue = 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; + + for (ULONG cnt = 0 ; cnt < mQueueCount ; cnt++) + { + if (pPQI3Buf [cnt].fsType & PRQ3_TYPE_APPDEFAULT) + mDefaultQueue = cnt; + + mPQBuf [cnt] = new PRTQUEUE (&pPQI3Buf [cnt]); + } + + free (pPQI3Buf); +} + +PRINTDLG::~PRINTDLG () +{ + for (int cnt = 0 ; cnt < mQueueCount ; cnt++) + delete mPQBuf [cnt]; +} + +int PRINTDLG::GetIndex (int numPrinter) +{ + int index; + + if (numPrinter == 0) + index = mDefaultQueue; + else if (numPrinter > mDefaultQueue) + index = numPrinter; + else + index = numPrinter - 1; + + return index; +} + +int PRINTDLG::GetNumPrinters () +{ + return mQueueCount; +} + +int PRINTDLG::GetDefaultPrinter () +{ + return mDefaultQueue; +} + +char* PRINTDLG::GetPrinter (int numPrinter) +{ + const char* pq = NULL; + + if (numPrinter > mQueueCount) + return NULL; + + pq = mPQBuf [numPrinter]->PQI3().pszDriverName; + + return (char *)pq; +} + +PRTQUEUE* PRINTDLG::SetPrinterQueue (int numPrinter) +{ + PRTQUEUE *pPQ = NULL; + + if (numPrinter > mQueueCount) + return NULL; + + pPQ = mPQBuf [GetIndex(numPrinter)]; + + return new PRTQUEUE (*pPQ); +} + +BOOL PRINTDLG::ShowProperties (int index) +{ + BOOL rc = FALSE; + ULONG devrc = FALSE; + PDRIVDATA pOldDrivData; + PDRIVDATA pNewDrivData = NULL; + LONG buflen; + int Ind = GetIndex(index); + +/* check size of buffer required for job properties */ + buflen = DevPostDeviceModes( 0 /*hab*/, + NULL, + mPQBuf[Ind]->DriverName (), + mPQBuf[Ind]->DeviceName (), + mPQBuf[Ind]->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[Ind]->PQI3().pDriverData->cb) + { + if (DosAllocMem((PPVOID)&pNewDrivData,buflen,fALLOC)) + return(DPDM_ERROR); + +/* copy over old data so driver can use old job */ +/* properties as base for job properties dialog */ + pOldDrivData = mPQBuf[Ind]->PQI3().pDriverData; + mPQBuf[Ind]->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[Ind]->PQI3().pDriverData, + mPQBuf[Ind]->DriverName (), + mPQBuf[Ind]->DeviceName (), + mPQBuf[Ind]->PrinterName (), + DPDM_POSTJOBPROP); + rc = (devrc != DPDM_ERROR); + return rc; +} + +/****************************************************************************/ +/* Job management */ +/****************************************************************************/ + +HDC PrnOpenDC( PRTQUEUE *pInfo, PSZ pszApplicationName, int copies, int toPrinter, char *file ) +{ + HDC hdc = 0; + PSZ pszLogAddress; + PSZ pszDataType; + LONG dcType; + DEVOPENSTRUC dop; + + char pszQueueProcParams[CCHMAXPATH] = "COP="; + char numCopies[12]; + itoa (copies, numCopies, 10); + strcat (pszQueueProcParams, numCopies); + + if ( toPrinter ) { + pszLogAddress = pInfo->PQI3 ().pszName; + pszDataType = "PM_Q_STD"; + dcType = OD_QUEUED; + } else { + if (file && strlen(file) != 0) + 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 = pszQueueProcParams; + dop.pszSpoolerParams = 0; + dop.pszNetworkParams = 0; + + 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); +#endif +} + + return hdc; +} + +BOOL prnEscape( HDC hdc, long lEscape) +{ + BOOL rc = FALSE; + + if( hdc) + { + long lDummy = 0; + long lResult = ::DevEscape( hdc, lEscape, 0, NULL, &lDummy, NULL); + rc = (lResult == DEV_OK); + } + + return rc; +} + + +/* 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; +} + Index: gfx/src/os2/nsDeviceContextSpecOS2.h =================================================================== RCS file: /cvsroot/mozilla/gfx/src/os2/nsDeviceContextSpecOS2.h,v retrieving revision 1.6 diff -u -r1.6 nsDeviceContextSpecOS2.h --- gfx/src/os2/nsDeviceContextSpecOS2.h 2001/09/26 00:15:34 1.6 +++ gfx/src/os2/nsDeviceContextSpecOS2.h 2001/10/05 18:50:53 @@ -1,6 +1,4 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 +/* Version: NPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Netscape Public License * Version 1.1 (the "License"); you may not use this file except in @@ -14,51 +12,151 @@ * * 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 <john_fairhurst@iname.com> - * - * - * Alternatively, the contents of this file may be used under the terms of - * either 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 NPL, 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 NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ + */ -#ifndef _nsDeviceContextSpecOS2_h -#define _nsDeviceContextSpecOS2_h +#ifndef nsDeviceContextSpecOS2_h___ +#define nsDeviceContextSpecOS2_h___ -#include "nsGfxDefs.h" +#define INCL_PM +#define INCL_DOS +#define INCL_DOSERRORS +#define INCL_SPLDOSPRINT #include "nsIDeviceContextSpec.h" -#include "libprint.h" +#include "nsDeviceContextSpecOS2.h" +#include "nsIPrintOptions.h" +#include "nsVoidArray.h" +#ifdef USE_XPRINT +#include "nsIDeviceContextSpecXPrint.h" +#endif /* USE_XPRINT */ +#include "nsPrintdOS2.h" +#include <os2.h> + + +//--------------------------------------------------------------------------- +// 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 (); + int GetNumPrinters (); + int GetDefaultPrinter (); + char* GetPrinter (int numPrinter); + PRTQUEUE* SetPrinterQueue (int numPrinter); + BOOL ShowProperties(int index); + PRTQUEUE* SelectPrinter (HWND hwndOwner, BOOL bQuiet); + +private: + ULONG mQueueCount; + ULONG mDefaultQueue; + PRTQUEUE* mPQBuf [MAX_PRINT_QUEUES]; + + int GetIndex( int numPrinter); + +}; + + +// 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 toPrinter, 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); + +//--------------------------------------------------------------------- +// nsDeviceContextSpecOS2 +//--------------------------------------------------------------------- + class nsDeviceContextSpecOS2 : public nsIDeviceContextSpec +#ifdef USE_XPRINT + , public nsIDeviceContextSpecXp +#endif { public: +/** + * Construct a nsDeviceContextSpecMac, which is an object which contains and manages a mac printrecord + * @update dc 12/02/98 + */ nsDeviceContextSpecOS2(); NS_DECL_ISUPPORTS + +/** + * Initialize the nsDeviceContextSpecMac for use. This will allocate a printrecord for use + * @update dc 2/16/98 + * @param aQuiet if PR_TRUE, prevent the need for user intervention + * in obtaining device context spec. if nsnull is passed in for + * the aOldSpec, this will typically result in getting a device + * context spec for the default output device (i.e. default + * printer). + * @return error status + */ + NS_IMETHOD Init(PRBool aQuiet); + + NS_IMETHOD ClosePrintManager(); + + NS_IMETHOD GetToPrinter( PRBool &aToPrinter ); + + NS_IMETHOD GetPrinter ( char **aPrinter ); + + NS_IMETHOD GetCopies ( int &aCopies ); - NS_IMETHOD Init(PRTQUEUE *pq); + NS_IMETHOD GetPath ( char **aPath ); + + NS_IMETHOD GetUserCancelled( PRBool &aCancel ); + NS_IMETHOD GetPRTQUEUE(PRTQUEUE *&p); + static nsStringArray *globalPrinterList; + static int globalNumPrinters; + static PRINTDLG PrnDlg; + int InitializeGlobalPrinters(); +// void FreeGlobalPrinters(); + protected: +/** + * Destuct a nsDeviceContextSpecMac, this will release the printrecord + * @update dc 2/16/98 + */ virtual ~nsDeviceContextSpecOS2(); +protected: + + OS2PrData mPrData; PRTQUEUE *mQueue; }; +//------------------------------------------------------------------------- +// Printer Enumerator +//------------------------------------------------------------------------- +class nsPrinterEnumeratorOS2 : public nsIPrinterEnumerator +{ +public: + nsPrinterEnumeratorOS2(); + NS_DECL_ISUPPORTS + NS_DECL_NSIPRINTERENUMERATOR + +protected: +}; + + #endif + Index: gfx/src/os2/nsGfxDefs.cpp =================================================================== RCS file: /cvsroot/mozilla/gfx/src/os2/nsGfxDefs.cpp,v retrieving revision 1.6 diff -u -r1.6 nsGfxDefs.cpp --- gfx/src/os2/nsGfxDefs.cpp 2001/07/24 22:47:28 1.6 +++ gfx/src/os2/nsGfxDefs.cpp 2001/10/05 18:50:53 @@ -35,7 +35,7 @@ #define DPRINTF printf #endif -#include "libprint.h" +#include "nsDeviceContextSpecOS2.h" #include <stdlib.h> @@ -160,53 +160,6 @@ USHORT usError = ERRORIDERROR(eid); DPRINTF ( "%s failed, error = 0x%X\n", api, usError); } - -nsGfxModuleData::nsGfxModuleData() : hModResources(0), hpsScreen(0) -{ -} - - -void nsGfxModuleData::Init() -{ - char buffer[CCHMAXPATH]; - APIRET rc; - - rc = DosLoadModule( buffer, CCHMAXPATH, "GFXRES", &hModResources); - - if( rc) - { - DPRINTF ( "Gfx failed to load self. rc = %d, cause = %s\n", (int)rc, buffer); - // rats. Can't load ourselves. Oh well. Try to be harmless... - hModResources = 0; - } - PrnInitialize( hModResources); - - // get screen bit-depth - hpsScreen = ::WinGetScreenPS (HWND_DESKTOP); -} - -nsGfxModuleData::~nsGfxModuleData() -{ - /* Free any converters that were created */ - if (gUconvInfoList) { - nsUconvInfo* UconvInfoList = gUconvInfoList; - nsUconvInfo* tUconvInfoList; - do { - if (UconvInfoList->mConverter) - ::UniFreeUconvObject(UconvInfoList->mConverter); - tUconvInfoList = UconvInfoList; - UconvInfoList = UconvInfoList->pNext; - free(tUconvInfoList); - } while (UconvInfoList); - } /* endif */ - - PrnTerminate(); - if( hModResources) - DosFreeModule( hModResources); - ::WinReleasePS( hpsScreen); -} - -nsGfxModuleData gGfxModuleData; int WideCharToMultiByte( int CodePage, const PRUnichar *pText, ULONG ulLength, char* szBuffer, ULONG ulSize ) { Index: gfx/src/os2/nsGfxDefs.h =================================================================== RCS file: /cvsroot/mozilla/gfx/src/os2/nsGfxDefs.h,v retrieving revision 1.13 diff -u -r1.13 nsGfxDefs.h --- gfx/src/os2/nsGfxDefs.h 2001/07/24 22:47:29 1.13 +++ gfx/src/os2/nsGfxDefs.h 2001/10/05 18:50:53 @@ -81,18 +81,6 @@ static nsUconvInfo* gUconvInfoList = NULL; -// Module data -struct nsGfxModuleData -{ - HMODULE hModResources; - HPS hpsScreen; - - nsGfxModuleData(); - ~nsGfxModuleData(); - - void Init(); -}; - int WideCharToMultiByte( int CodePage, const PRUnichar *pText, ULONG ulLength, char* szBuffer, ULONG ulSize ); int MultiByteToWideChar( int CodePage, const char*pText, ULONG ulLength, PRUnichar *szBuffer, ULONG ulSize ); BOOL GetTextExtentPoint32(HPS aPS, const char* aString, int aLength, PSIZEL aSizeL); @@ -100,8 +88,6 @@ const char* aString, unsigned int aLength, const int* pDx); BOOL IsDBCS(); - -extern nsGfxModuleData gGfxModuleData; #ifndef min #define min(a,b) (((a) < (b)) ? (a) : (b)) Index: gfx/src/os2/nsGfxFactoryOS2.cpp =================================================================== RCS file: /cvsroot/mozilla/gfx/src/os2/nsGfxFactoryOS2.cpp,v retrieving revision 1.28 diff -u -r1.28 nsGfxFactoryOS2.cpp --- gfx/src/os2/nsGfxFactoryOS2.cpp 2001/09/26 00:15:34 1.28 +++ gfx/src/os2/nsGfxFactoryOS2.cpp 2001/10/05 18:50:54 @@ -69,6 +69,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontList); NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerOS2) NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrintOptionsOS2) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorOS2) // our custom constructors @@ -178,7 +179,12 @@ NS_SCREENMANAGER_CID, // "@mozilla.org/gfx/screenmanager/gtk;1", "@mozilla.org/gfx/screenmanager;1", - nsScreenManagerOS2Constructor } + nsScreenManagerOS2Constructor }, + { "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) Index: layout/html/base/src/printing.properties =================================================================== RCS file: /cvsroot/mozilla/layout/html/base/src/printing.properties,v retrieving revision 3.2 diff -u -r3.2 printing.properties --- layout/html/base/src/printing.properties 2001/09/21 13:47:15 3.2 +++ layout/html/base/src/printing.properties 2001/10/05 18:51:13 @@ -62,5 +62,8 @@ NS_ERROR_NOT_AVAILABLE=Not available NS_ERROR_ABORT=Job aborted NS_ERROR_FAILURE=Failure + +# No printers available +noprinter=(no printers available) # EOF. Index: xpcom/base/IIDS.h =================================================================== RCS file: /cvsroot/mozilla/xpcom/base/IIDS.h,v retrieving revision 1.90 diff -u -r1.90 IIDS.h --- xpcom/base/IIDS.h 2001/09/28 20:12:23 1.90 +++ xpcom/base/IIDS.h 2001/10/05 18:52:28 @@ -1307,13 +1307,13 @@ 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }; -INTERFACENAME = { /* a6cf9128-15b3-11d2-932e-00805f8add32 */ +nsIPrinterEnumerator = { /* a6cf9128-15b3-11d2-932e-00805f8add32 */ 0xa6cf9128, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }; -INTERFACENAME = { /* a6cf9129-15b3-11d2-932e-00805f8add32 */ +nsPrinterEnumerator_CID = { /* a6cf9129-15b3-11d2-932e-00805f8add32 */ 0xa6cf9129, 0x15b3, 0x11d2, Index: xpfe/global/Makefile.in =================================================================== RCS file: /cvsroot/mozilla/xpfe/global/Makefile.in,v retrieving revision 1.11 diff -u -r1.11 Makefile.in --- xpfe/global/Makefile.in 2001/07/23 03:46:55 1.11 +++ xpfe/global/Makefile.in 2001/10/05 18:52:38 @@ -45,7 +45,7 @@ @$(REGCHROME) locale en-US/global en-US.jar @$(REGCHROME) locale US/global-region US.jar ifeq ($(OS_ARCH),OS2) - @$(REGCHROME) locale en-US/global-platform en-win.jar + @$(REGCHROME) locale en-US/global-platform en-os2.jar else @$(REGCHROME) locale en-US/global-platform en-unix.jar endif Index: xpfe/global/resources/content/Makefile.in =================================================================== RCS file: /cvsroot/mozilla/xpfe/global/resources/content/Makefile.in,v retrieving revision 1.53 diff -u -r1.53 Makefile.in --- xpfe/global/resources/content/Makefile.in 2001/09/14 21:07:39 1.53 +++ xpfe/global/resources/content/Makefile.in 2001/10/05 18:52:38 @@ -27,7 +27,7 @@ include $(DEPTH)/config/autoconf.mk ifeq ($(MOZ_WIDGET_TOOLKIT),os2) -DIRS = win +DIRS = os2 else DIRS = unix endif Index: xpfe/global/resources/content/os2/Makefile.in =================================================================== RCS file: /cvsroot/mozilla/xpfe/global/resources/content/os2/Makefile.in,v retrieving revision 1.6 diff -u -r1.6 Makefile.in --- xpfe/global/resources/content/os2/Makefile.in 2000/07/18 23:04:22 1.6 +++ xpfe/global/resources/content/os2/Makefile.in 2001/10/05 18:52:39 @@ -33,6 +33,8 @@ platformGlobalOverlay.xul \ platformDialogOverlay.xul \ platformHTMLBindings.xml \ + printdialog.xul \ + printdialog.js \ $(NULL) include $(topsrcdir)/config/rules.mk Index: xpfe/global/resources/content/os2/jar.mn =================================================================== RCS file: /cvsroot/mozilla/xpfe/global/resources/content/os2/jar.mn,v retrieving revision 1.5 diff -u -r1.5 jar.mn --- xpfe/global/resources/content/os2/jar.mn 2001/08/31 00:12:54 1.5 +++ xpfe/global/resources/content/os2/jar.mn 2001/10/05 18:52:39 @@ -1,4 +1,6 @@ toolkit.jar: content/global/platformGlobalOverlay.xul content/global/platformDialogOverlay.xul - content/global/platformXUL.css + content/global/platformXUL.css + content/global/printdialog.js + content/global/printdialog.xul Index: xpfe/global/resources/locale/en-US/Makefile.in =================================================================== RCS file: /cvsroot/mozilla/xpfe/global/resources/locale/en-US/Makefile.in,v retrieving revision 1.22 diff -u -r1.22 Makefile.in --- xpfe/global/resources/locale/en-US/Makefile.in 2001/08/31 22:44:17 1.22 +++ xpfe/global/resources/locale/en-US/Makefile.in 2001/10/05 18:52:39 @@ -28,6 +28,10 @@ DIRS = unix win mac +ifeq ($(MOZ_WIDGET_TOOLKIT),os2) +DIRS += os2 +endif + CHROME_DIR=locales/en-US CHROME_L10N_DIR=global/locale Index: xpfe/global/resources/locale/en-US/os2/Makefile.in =================================================================== RCS file: /cvsroot/mozilla/xpfe/global/resources/locale/en-US/os2/Makefile.in,v retrieving revision 1.2 diff -u -r1.2 Makefile.in --- xpfe/global/resources/locale/en-US/os2/Makefile.in 2001/07/25 04:26:44 1.2 +++ xpfe/global/resources/locale/en-US/os2/Makefile.in 2001/10/05 18:52:39 @@ -30,6 +30,9 @@ CHROME_L10N_DIR=global/locale CHROME_L10N = \ + platformGlobalOverlay.dtd \ + platformDialogOverlay.dtd \ + printdialog.dtd \ $(NULL) include $(topsrcdir)/config/rules.mk Index: xpfe/global/resources/locale/en-US/os2/jar.mn =================================================================== RCS file: /cvsroot/mozilla/xpfe/global/resources/locale/en-US/os2/jar.mn,v retrieving revision 1.7 diff -u -r1.7 jar.mn --- xpfe/global/resources/locale/en-US/os2/jar.mn 2001/07/25 04:26:45 1.7 +++ xpfe/global/resources/locale/en-US/os2/jar.mn 2001/10/05 18:52:40 @@ -1,2 +1,7 @@ en-os2.jar: locale/en-US/global-platform/contents.rdf (contents-platform.rdf) + locale/en-US/global-platform/platformGlobalOverlay.dtd + locale/en-US/global-platform/platformDialogOverlay.dtd + locale/en-US/global-platform/platformKeys.properties + locale/en-US/global-platform/wizard.properties + locale/en-US/global-platform/printdialog.dtd
Attachment #51245 - Attachment description: files already in mozilla that have been changed for print dlg to work → files already in mozilla that have been changed for print dlg to work -updated
First time using the Edit button. I thought it would actually modify the attachment and it would still be a link. I didn't think it would put the whole diff as a comment in the bug. Now I know. - didn't mean to lengthen the bug
Attachment #51245 - Attachment is obsolete: true
Attachment #51247 - Attachment is obsolete: true
Attachment #51249 - Attachment is obsolete: true
By moving the printdialog.js/xul/dtd files out of the unix directory to the above one, this line would need to be changed in printdialog.xul - <!DOCTYPE window SYSTEM "chrome://global-platform/locale/printdialog.dtd"> to the following: <!DOCTYPE window SYSTEM "chrome://global/locale/printdialog.dtd">
The unix patch still misses a (XUL-based) "properties"-dialog to edit the following attributes: - printer command - paper size - page orientation (landscape/portrait) - color mode (grayscale/color)
I'll file an all-in-one patch...
Attachment #51251 - Attachment is obsolete: true
Attachment #53006 - Attachment is obsolete: true
Attachment #53010 - Attachment is obsolete: true
Attachment #53011 - Attachment is obsolete: true
Attachment #53871 - Attachment is obsolete: true
Attachment #48574 - Attachment is obsolete: true
Attachment #48575 - Attachment is obsolete: true
Attachment #48576 - Attachment is obsolete: true
Attachment #51246 - Attachment is obsolete: true
Comment on attachment 54444 [details] [diff] [review] All-in-one patch for 2001-10-20-08-trunk Things to fix: - IDL file uses |#ifdef XP_OS2| instead of |#if defined(XP_UNIX) || defined(XP_OS2)| - Makefile.in-fu needs to be updated
Attachment #54444 - Attachment is obsolete: true
Attachment #54444 - Flags: needs-work+
BTW: Patch from bug 100069 is required to get the unix/linux part working...
Attachment #54451 - Attachment is obsolete: true
Filed new patch (changed gfx/src/gtk/*, gfx/src/xlib/*, gfx/src/xprint/* and modules/libpref/src/unix/unix.js). Changes: - Added support for selecting the printer name with the PostScript module. Either use "print.printer_list" prefs or the "MOZILLA_PRINTER_LIST" env var to set the list of printers (seperated by spaces). - Updated modules/libpref/src/unix/unix.js - Fixed Jessica Blanco's name in the "contributors" section: s/Blanko/Blanco/
Depends on: 106372
Attachment #54813 - Attachment is obsolete: true
Attachment #55071 - Attachment is obsolete: true
Attachment #55072 - Attachment is obsolete: true
Attachment #55834 - Attachment description: New all-in-one patch for 2001-10-26-08-trunk (required patches from bug 100069 and bug 106372) → New all-in-one patch for 2001-10-26-08-trunk (requires patches from bug 100069 and bug 106372)
Attachment #55834 - Attachment is obsolete: true
I added a rudimentary "print options" dialog for Unix/Linux (it misses the ability to query/display print job attributes _dynamically_). I wish I could do here more - but fixing that would not touch all platforms instead of two (Unix,OS/2). I'll forward that to a new bug... this one is nearly ~160KB in size...
Keywords: helpwantedpatch
Minor ToDo: - rods suggested that the #ifdef stuff in the IDL file is a BAD(TM) thing. We need a comment there that this is only temporary (to avoid that other platforms (than OS/2,Unix,Linux) screw-up at that point) thing and will be removed by later bugs (see my previous comment).
Attachment #56254 - Attachment is obsolete: true
Attached patch Patch for 2001-11-04 (obsolete) — Splinter Review
Comment on attachment 56510 [details] [diff] [review] Patch for 2001-11-04 Unfortunately the landing of bug 107642 ("Land giant xul patch") caused some damage to our patch. We need to adopt the XUL/JS of this patch to match the new consitions... ;-(
Attachment #56510 - Flags: needs-work+
s/consitions/conditions/
Attached patch XUL fixes v2 (obsolete) — Splinter Review
Attachment #56672 - Attachment is obsolete: true
Comment on attachment 55072 [details] [diff] [review] gfx\src\os2\nsPrintdOS2.h needs to be added for OS/2 to work gfx/src/os2/nsPrintdOS2.h needs to be added to the tree for the OS/2 print dialog to work. Attachment #55072 [details] [diff] is not obsolete unless added into a future patch.
Attachment #55072 - Attachment is obsolete: false
I'll file a new all-on-one patch incl. Asko Tontti's fixes and the missing gfx/src/os2/nsPrintdOS2.h (sorry) ...
Attachment #55072 - Attachment is obsolete: true
Attachment #56510 - Attachment is obsolete: true
Attachment #56681 - Attachment is obsolete: true
katakai: Wanna review the changes in gfx/src/ps/, please ?
CC:'ing pchen@netscape.com to let him "know" what we are doing here (new print dialog for OS/2+Unix) ...
I was able to build and run with this, it looks great. I looked over the code. We have decided the ifdef's are fine for now until we can can some of this working on other platforms r=rods
I don't think the "ifdef's" work inside the IDL file. Try building your patch on Windows.
#ifdefs won't work in IDL files, nor should they appear in interfaces. You need to provide stub implementations for those methods on every platoform where you don't have a real implementation.
I can't provide such a patch due lack of matching build machines. Need help... ;-( sfraser@netscape.com, wanna help me, please ?
sfraser: Are you sure that |#ifdef| is not allowed in CPP files ? take a look at this output: -- snip -- % find . -name \*.idl | while read i ; do x=$(cat $i | fgrep "#if") ; if [ "$x" != "" ] ; then echo "|---------> $i <----"; echo "$x" ; fi ; done |---------> ./modules/libpref/public/nsIPref.idl <---- #ifndef have_PrefChangedFunc_typedef |---------> ./modules/oji/public/nsIJVMManager.idl <---- #ifndef JNI_H |---------> ./modules/plugin/base/public/nsPluginDefs.idl <---- #if defined(XP_OS2) || defined(__OS2__) #ifndef prtypes_h___ #if defined(XP_MAC) || defined(XP_MACOSX) #if defined(XP_UNIX) && !defined(NO_X11) #if defined(XP_PC) && !defined(XP_OS2) #ifndef RC_INVOKED #ifdef XP_MAC #ifdef XP_UNIX #ifndef NO_X11 #if defined(XP_MAC) || defined(XP_MACOSX) #ifdef XP_UNIX #if defined(XP_MAC) || defined(XP_MACOSX) #if defined(XP_MAC) || defined(XP_MACOSX) #ifdef XP_MAC #ifdef __OS2__ |---------> ./editor/idl/nsICiter.idl <---- #ifndef nsICiter_h__ |---------> ./editor/idl/nsIURIRefObject.idl <---- #ifndef nsIURIRefObject_h__ |---------> ./embedding/browser/activex/src/control/MozillaControl.idl <---- cpp_quote("#ifndef __exdisp_h__") |---------> ./netwerk/base/public/nsIURI.idl <---- #ifdef XP_OS2 // OS2 has UNKNOWN problems :) |---------> ./rdf/base/idl/xulstubs.idl <---- #if 0 |---------> ./xpcom/base/nsIProgrammingLanguage.idl <---- #ifdef XP_OS2 // OS2 has UNKNOWN problems :) |---------> ./xpcom/base/nsISupports.idl <---- #if 0 #ifndef MOZILLA_STRICT_API |---------> ./xpcom/base/nsIWeakReference.idl <---- #ifndef MOZILLA_STRICT_API |---------> ./xpcom/base/nsrootidl.idl <---- #if 0 |---------> ./xpcom/components/nsIServiceManager.idl <---- #ifndef MOZILLA_STRICT_API |---------> ./xpcom/ds/nsICollection.idl <---- #ifndef nsCOMPtr_h__ |---------> ./xpcom/ds/nsITimelineService.idl <---- #ifdef MOZ_TIMELINE #ifdef MOZ_TIMELINE |---------> ./xpcom/io/nsIFastLoadService.idl <---- #ifndef nsCOMPtr_h___ #ifndef __gen_nsIFile_h__ #ifndef nsIServiceManager_h___ |---------> ./xpcom/io/nsIStreamBufferAccess.idl <---- #if defined IS_LITTLE_ENDIAN |---------> ./xpcom/threads/nsIThread.idl <---- #if 0 |---------> ./xpcom/threads/nsIThreadPool.idl <---- #if 0 -- snip --
s/not allowed in CPP files/not allowed in IDL files/ (Silly mistake)
Look at the files. The #ifdefs in idl are all inside of %{C++ ... %} blocks. You *cannot* #ifdef in the IDL part of the file.
I added the new patch - attachment 56865 [details] [diff] [review] - to windows and built. There was an error in the gfx directory. I took the ifdefs out of nsIPrintOptions.idl, and for nsPrintOptionsImpl.cpp, I put the ifdefs inside the functions instead of putting the functions inside the ifdefs. I attached diffs of only those 3 files I modified. I rebuilt windows and it compiled with the patch(#56865) and my changes.
I wouldn't worry about the ifdefs in those files at all. Just take them out.
We usually use localized string for "default" but the patch hardcodes the string. Please provide the way to get l10n string from .dtd or .properties file. katakai@xymo> grep '"default"' /tmp/showattachment.cgi + nsString(NS_ConvertASCIItoUCS2(NS_POSTSCRIPT_DRIVER_NAME "default"))); + if (!strcmp(buf, "default")) + nsString(NS_ConvertASCIItoUCS2(NS_POSTSCRIPT_DRIVER_NAME "default")));
> We usually use localized string for "default" but the patch hardcodes the > string. Please provide the way to get l10n string from .dtd or .properties > file. > > katakai@xymo> grep '"default"' /tmp/showattachment.cgi > + nsString(NS_ConvertASCIItoUCS2(NS_POSTSCRIPT_DRIVER_NAME "default"))); > + if (!strcmp(buf, "default")) I am aware of this problem, but I'd like to forward this to another bug (please please - we already missed _FIVE_ milestones). I am planning to create a new class which represents a handle to the currently selected printer where "name", "description" + list of supported attributes can be obtained from - that's neccesary for the "unix print options dialog" and to avoid that we look-up printers multiple times. The current 'NS_POSTSCRIPT_DRIVER_NAME "default"'-thing is only a crappy hack to implement this.
Attachment #56865 - Attachment is obsolete: true
Attachment #57312 - Attachment is obsolete: true
Should compile cleanly on Win32/Beos/Mac etc.
OK, I agree. Please open new bug report when this patch gets checked in. Thanks.
katakai wrote: > OK, I agree. Please open new bug report when this patch gets checked in. Thanks! :-) New bugs summary: "We need a better print job options dialog on unix..." ... :-)
I've verified the patch works with native PostScript module and Xprt module. It can get printer list from remote Xprt server and use it as destination. Great!! However,I'm not module owner of PostScript printing. Roland, can you ask review to dcone@netscape.com and syd@netscape.com?
dcone is AFAIK on vacation, adding syd to the CC: field ...
Choosing blizzard@mozilla.org for superreview, IMHO we can do moa= (from syd for gfx/src/ps/) and sr= in parallel... :-)
Keywords: review
Blocks: 11275
r=mkaply on the OS/2 changes
Retargeting to 0.9.7. We have a patch and (per leaf) all neccesary reviews except blizzard's sr= ...
Target Milestone: mozilla0.9.6 → mozilla0.9.7
Interface method names should start with lower-case. I think you can replace calls to QueryInterface with simpler do_QueryInterface code. Why are you changing licenses from MPL to NPL? That seems very wrong. In mozilla/gfx/src/os2/nsDeviceContextSpecOS2.cpp, after " if ((copies == 0) || (copies > 999))" You should call FreeGlobalMemory before the error exit. After you address the above I will check it over again and sr. PS, it would be great if, in future, you can separate your work into smaller patches.
Comment on attachment 57437 [details] [diff] [review] New all-in-one-patch for 2001-11-10-cvs I'll file a new patch in a few hours ...
Attachment #57437 - Flags: needs-work+
> Interface method names should start with lower-case. Fixed. > I think you can replace calls to QueryInterface with simpler > do_QueryInterface code. Fixed for Xlib and GTK+ toolkit, OS/2 left unchanged (see below, [1]) > Why are you changing licenses from MPL to NPL? That seems very wrong. That's OS/2 only. I assume they only copied old gfx/src/gtk/ files and modified them without caring about the license... mkaply/jessica ([1]) ? > In mozilla/gfx/src/os2/nsDeviceContextSpecOS2.cpp, > after " if ((copies == 0) || (copies > 999))" > You should call FreeGlobalMemory before the error exit. [1] --> mkaply/jessica ? > After you address the above I will check it over again and sr. I fixed all issues except OS/2 stuff: [1] - I don't have a OS/2 build box. I have to wait until mkaply/jessica file an update... > PS, it would be great if, in future, you can separate your work into smaller > patches. We already had five bugs to build and preprare, this one is only that big because we replace whole XUL/JS/DTD files and hack three toolkits (Xlib/GTK+/OS2) in one step... I am not sure... but AFAIK the current patch cannot be split into smaller pieces without breaking at least one toolkit ... Wanna sr= the patch except the OS/2 parts, please ?
Attachment #57437 - Attachment is obsolete: true
> I think you can replace calls to QueryInterface with simpler > do_QueryInterface code. modified os/2 - looks similar to gtk > Why are you changing licenses from MPL to NPL? That seems very wrong. I did copy the gtk file when modifying it to use printdialog.xul instead of an OS/2 dialog, and I never changed the license. I now left all licenses as they are in the trunk. I made a few small changes including adding FreeGlobalPrinters after checking if copies entered is valid.
OK, AFAIK we now have all pieces together... roc+moz@cs.cmu.edu, wanna sr= both patches, please ? I'll file a all-in-one patch after sr= ...
r=pchen, I tested the 2001-11-10 patch on mac, and it built fine. I can't test the 2001-11-14-08-trunk patch right at the moment, but I don't think there should be any problems (famous last words ;-) ). Nice work, folks.
Comment on attachment 58251 [details] [diff] [review] New patch for 2001-11-14-08-trunk sr=roc+moz
Attachment #58251 - Flags: superreview+
Comment on attachment 58386 [details] [diff] [review] updated diff of gfx\src\os2. does not include needed nsPrintdOS2.h sr=roc+moz
Attachment #58386 - Flags: superreview+
I'll file a final all-in-one patch ...
Ready for checkin ...
Attachment #58251 - Attachment is obsolete: true
Attachment #58386 - Attachment is obsolete: true
Comment on attachment 58681 [details] [diff] [review] All-in-one patch for 2001-11-20-08-trunk (attachment 58251 [details] [diff] [review] + attachment 58386 [details] [diff] [review]) Summary of reviews: r=cls on the Makefile.in changes r=rods r=mkaply on the OS/2 changes r=pchen sr=roc+moz
Attachment #58681 - Flags: superreview+
Attachment #58681 - Flags: review+
Filed bug 111450 for the BeOS bustage ...
I'm sorry, but you new print dialog brakes completly my ability to print (with lpr and LPRng). I filled #111852.
Nope, it's working, See bug 111852 :) sujay, for verification please remove component.reg before testing (I do not know why, but it seems to fix all the weired effects reported in that bug) ...
Filed the follow-up to this bug: bug 111934 - "We need a better "print job options" dialog..."
Blocks: 111934
Roland, can I give you the honor to verify this bug and mark verified-fixed ? thanks.
sujay wrote: > can I give you the honor to verify this bug and mark verified-fixed ? :-) Unix Xprint and PostScript are working, but I do not have any responses from the OS/2 and BeOS platforms yet... but BeOS is handeled by bug 111450 ... Jessica/mkaply - is the OS/2 side working for you ?
Verified - works on OS/2
Jessica Blanco wrote: > Verified - works on OS/2 Thanks! Marking bug as VERIFIED.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: