Bug 377096 - Factor out nsIPrintOptions::AvailablePrinters. r=pavlov, sr=biesi.
authorkjh-5727@comcast.net
Sun, 06 May 2007 04:29:41 -0700
changeset 1155 d411716a02bc25c3dd6997fc1657474410b5a413
parent 1154 73c1a62699313785feba6c01795fec5b5c90cf99
child 1156 48f0fbe014d81f3c1ca48ed234779b202e7dbfc6
push idunknown
push userunknown
push dateunknown
reviewerspavlov, biesi
bugs377096
milestone1.9a5pre
Bug 377096 - Factor out nsIPrintOptions::AvailablePrinters. r=pavlov, sr=biesi.
gfx/src/qt/nsDeviceContextSpecQt.cpp
layout/printing/nsPrintData.h
layout/printing/nsPrintEngine.cpp
layout/printing/nsPrintEngine.h
toolkit/components/printing/content/printdialog.js
widget/public/nsIPrintOptions.idl
widget/src/beos/nsDeviceContextSpecB.cpp
widget/src/gtk2/nsDeviceContextSpecG.cpp
widget/src/os2/nsDeviceContextSpecOS2.cpp
widget/src/windows/nsDeviceContextSpecWin.cpp
widget/src/windows/nsDeviceContextSpecWin.h
widget/src/xpwidgets/nsPrintOptionsImpl.cpp
xpfe/global/resources/content/printdialog.js
--- a/gfx/src/qt/nsDeviceContextSpecQt.cpp
+++ b/gfx/src/qt/nsDeviceContextSpecQt.cpp
@@ -50,16 +50,17 @@
 #include "nsDeviceContextSpecQt.h"
 
 #include "nsIPrefBranch.h"
 #include "nsIPrefService.h"
 #include "prenv.h" /* for PR_GetEnv */
 
 #include "nsPrintfCString.h"
 #include "nsReadableUtils.h"
+#include "nsStringEnumerator.h"
 #include "nsIServiceManager.h"
 #include "nsCRT.h"
 
 #ifdef USE_XPRINT
 #include "xprintutil.h"
 #endif /* USE_XPRINT */
 
 #ifdef USE_POSTSCRIPT
@@ -558,66 +559,41 @@ nsresult CopyPrinterCharPref(nsIPrefBran
 
 //  Printer Enumerator
 nsPrinterEnumeratorQt::nsPrinterEnumeratorQt()
 {
 }
 
 NS_IMPL_ISUPPORTS1(nsPrinterEnumeratorQt, nsIPrinterEnumerator)
 
-NS_IMETHODIMP nsPrinterEnumeratorQt::EnumeratePrinters(PRUint32* aCount, PRUnichar*** aResult)
+NS_IMETHODIMP nsPrinterEnumeratorQt::GetPrinterNameList(nsIStringEnumerator **aPrinterNameList)
 {
-  NS_ENSURE_ARG(aCount);
-  NS_ENSURE_ARG_POINTER(aResult);
-
-  if (aCount)
-    *aCount = 0;
-  else
-    return NS_ERROR_NULL_POINTER;
-
-  if (aResult)
-    *aResult = nsnull;
-  else
-    return NS_ERROR_NULL_POINTER;
+  NS_ENSURE_ARG_POINTER(aPrinterNameList);
+  *aPrinterNameList = nsnull;
 
   nsresult rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   PRInt32 numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters();
-
-  PRUnichar** array = (PRUnichar**) nsMemory::Alloc(numPrinters * sizeof(PRUnichar*));
-  if (!array && numPrinters > 0) {
+  nsStringArray *printers = new nsStringArray(numPrinters);
+  if (!printers) {
     GlobalPrinters::GetInstance()->FreeGlobalPrinters();
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   int count = 0;
   while( count < numPrinters )
   {
-    PRUnichar *str = ToNewUnicode(*GlobalPrinters::GetInstance()->GetStringAt(count));
-
-    if (!str) {
-      for (int i = count - 1; i >= 0; i--)
-        nsMemory::Free(array[i]);
-
-      nsMemory::Free(array);
-
-      GlobalPrinters::GetInstance()->FreeGlobalPrinters();
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
-    array[count++] = str;
-
+    printers->AppendString(*GlobalPrinters::GetInstance()->GetStringAt(count++));
   }
-  *aCount = count;
-  *aResult = array;
   GlobalPrinters::GetInstance()->FreeGlobalPrinters();
 
-  return NS_OK;
+  return NS_NewAdoptingStringEnumerator(aPrinterNameList, printers);
 }
 
 /* readonly attribute wstring defaultPrinterName; */
 NS_IMETHODIMP nsPrinterEnumeratorQt::GetDefaultPrinterName(PRUnichar **aDefaultPrinterName)
 {
   DO_PR_DEBUG_LOG(("nsPrinterEnumeratorQt::GetDefaultPrinterName()\n"));
   NS_ENSURE_ARG_POINTER(aDefaultPrinterName);
 
--- a/layout/printing/nsPrintData.h
+++ b/layout/printing/nsPrintData.h
@@ -112,17 +112,16 @@ public:
   PRBool                      mShrinkToFit;
   PRInt16                     mPrintFrameType;
   PRInt32                     mNumPrintablePages;
   PRInt32                     mNumPagesPrinted;
   float                       mShrinkRatio;
   float                       mOrigDCScale;
 
   nsCOMPtr<nsIPrintSettings>  mPrintSettings;
-  nsCOMPtr<nsIPrintOptions>   mPrintOptions;
   nsPrintPreviewListener*     mPPEventListeners;
 
   PRUnichar*            mBrandName; //  needed as a substitute name for a document
 
 private:
   nsPrintData(); //not implemented
   nsPrintData& operator=(const nsPrintData& aOther); // not implemented
 
--- a/layout/printing/nsPrintEngine.cpp
+++ b/layout/printing/nsPrintEngine.cpp
@@ -52,23 +52,20 @@
 // Print Options
 #include "nsIPrintSettings.h"
 #include "nsIPrintSettingsService.h"
 #include "nsIPrintOptions.h"
 #include "nsIPrintSession.h"
 #include "nsGfxCIID.h"
 #include "nsIServiceManager.h"
 #include "nsGkAtoms.h"
-#include "nsISimpleEnumerator.h"
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 
-// PrintOptions is now implemented by PrintSettingsService
 static const char sPrintSettingsServiceContractID[] = "@mozilla.org/gfx/printsettings-service;1";
-static const char sPrintOptionsContractID[]         = "@mozilla.org/gfx/printsettings-service;1";
 
 // Printing Events
 #include "nsPrintPreviewListener.h"
 #include "nsThreadUtils.h"
 
 // Printing
 #include "nsIWebBrowserPrint.h"
 #include "nsIDOMHTMLFrameElement.h"
@@ -463,19 +460,17 @@ nsPrintEngine::DoCommonPrint(PRBool     
 
   // if they don't pass in a PrintSettings, then get the Global PS
   mPrt->mPrintSettings = aPrintSettings;
   if (!mPrt->mPrintSettings) {
     rv = GetGlobalPrintSettings(getter_AddRefs(mPrt->mPrintSettings));
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
-  mPrt->mPrintOptions = do_GetService(sPrintOptionsContractID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-  rv = CheckForPrinters(mPrt->mPrintOptions, mPrt->mPrintSettings);
+  rv = CheckForPrinters(mPrt->mPrintSettings);
   NS_ENSURE_SUCCESS(rv, rv);
 
   mPrt->mPrintSettings->SetIsCancelled(PR_FALSE);
   mPrt->mPrintSettings->GetShrinkToFit(&mPrt->mShrinkToFit);
 
   if (aIsPrintPreview) {
     SetIsCreatingPrintPreview(PR_TRUE);
     SetIsPrintPreview(PR_TRUE);
@@ -909,58 +904,42 @@ nsPrintEngine::GetCurrentPrintSettings(n
 //-- Section: Pre-Reflow Methods
 //-----------------------------------------------------------------
 
 //---------------------------------------------------------------------
 // This method checks to see if there is at least one printer defined
 // and if so, it sets the first printer in the list as the default name
 // in the PrintSettings which is then used for Printer Preview
 nsresult
-nsPrintEngine::CheckForPrinters(nsIPrintOptions*  aPrintOptions,
-                                nsIPrintSettings* aPrintSettings)
+nsPrintEngine::CheckForPrinters(nsIPrintSettings* aPrintSettings)
 {
-  NS_ENSURE_ARG_POINTER(aPrintOptions);
+#if defined(XP_MAC) || defined(XP_MACOSX)
+  // Mac doesn't support retrieving a printer list.
+  return NS_OK;
+#else
   NS_ENSURE_ARG_POINTER(aPrintSettings);
 
-  nsresult rv;
-
-  nsCOMPtr<nsISimpleEnumerator> simpEnum;
-  rv = aPrintOptions->AvailablePrinters(getter_AddRefs(simpEnum));
-  if (simpEnum) {
-    PRBool fndPrinter = PR_FALSE;
-    simpEnum->HasMoreElements(&fndPrinter);
-    if (fndPrinter) {
-      // For now, it assumes the first item in the list
-      // is the default printer, but only set the
-      // printer name if there isn't one
-      nsCOMPtr<nsISupports> supps;
-      simpEnum->GetNext(getter_AddRefs(supps));
-      PRUnichar* defPrinterName;
-      aPrintSettings->GetPrinterName(&defPrinterName);
-      if (!defPrinterName || !*defPrinterName) {
-        if (defPrinterName) nsMemory::Free(defPrinterName);
-        nsCOMPtr<nsISupportsString> wStr = do_QueryInterface(supps);
-        if (wStr) {
-          wStr->ToString(&defPrinterName);
-          aPrintSettings->SetPrinterName(defPrinterName);
-          nsMemory::Free(defPrinterName);
-        }
-      } else {
-        nsMemory::Free(defPrinterName);
-      }
-      rv = NS_OK;
-    }
-  } else {
-    // this means there were no printers
-    // XXX the ifdefs are temporary until they correctly implement Available Printers
-#if defined(XP_MAC) || defined(XP_MACOSX)
-    rv = NS_OK;
-#endif
+  // See if aPrintSettings already has a printer
+  nsXPIDLString printerName;
+  nsresult rv = aPrintSettings->GetPrinterName(getter_Copies(printerName));
+  if (NS_SUCCEEDED(rv) && !printerName.IsEmpty()) {
+    return NS_OK;
+  }
+
+  // aPrintSettings doesn't have a printer set. Try to fetch the default.
+  nsCOMPtr<nsIPrintSettingsService> printSettingsService =
+    do_GetService(sPrintSettingsServiceContractID, &rv);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  rv = printSettingsService->GetDefaultPrinterName(getter_Copies(printerName));
+  if (NS_SUCCEEDED(rv) && !printerName.IsEmpty()) {
+    rv = aPrintSettings->SetPrinterName(printerName.get());
   }
   return rv;
+#endif
 }
 
 //----------------------------------------------------------------------
 // Set up to use the "pluggable" Print Progress Dialog
 void
 nsPrintEngine::ShowPrintProgress(PRBool aIsForPrinting, PRBool& aDoNotify)
 {
   // default to not notifying, that if something here goes wrong
--- a/layout/printing/nsPrintEngine.h
+++ b/layout/printing/nsPrintEngine.h
@@ -157,18 +157,17 @@ public:
   void CalcNumPrintablePages(PRInt32& aNumPages);
   void ShowPrintProgress(PRBool aIsForPrinting, PRBool& aDoNotify);
   nsresult CleanupOnFailure(nsresult aResult, PRBool aIsPrinting);
   nsresult FinishPrintPreview();
   static void CloseProgressDialog(nsIWebProgressListener* aWebProgressListener);
   void SetDocAndURLIntoProgress(nsPrintObject* aPO,
                                 nsIPrintProgressParams* aParams);
   void ElipseLongString(PRUnichar *& aStr, const PRUint32 aLen, PRBool aDoFront);
-  nsresult CheckForPrinters(nsIPrintOptions*  aPrintOptions,
-                            nsIPrintSettings* aPrintSettings);
+  nsresult CheckForPrinters(nsIPrintSettings* aPrintSettings);
   void CleanupDocTitleArray(PRUnichar**& aArray, PRInt32& aCount);
 
   PRBool IsThereARangeSelection(nsIDOMWindow * aDOMWin);
 
   //---------------------------------------------------------------------
 
 
   // Timer Methods
--- a/toolkit/components/printing/content/printdialog.js
+++ b/toolkit/components/printing/content/printdialog.js
@@ -37,17 +37,16 @@
 # 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 *****
 
 var dialog;
 var printService       = null;
-var printOptions       = null;
 var gOriginalNumCopies = 1;
 
 var paramBlock;
 var gPrefs             = null;
 var gPrintSettings     = null;
 var gWebBrowserPrint   = null;
 var gPrintSetInterface = Components.interfaces.nsIPrintSettings;
 var doDebug            = false;
@@ -143,59 +142,56 @@ listElement.prototype =
           if (popup) {
             this.listElement.removeChild(popup);
           }
         },
 
     appendPrinterNames: 
       function (aDataObject) 
         { 
-          var list = document.getElementById("printerList"); 
-          var strDefaultPrinterName = "";
-          var printerName;
-
-          // build popup menu from printer names
-          while (aDataObject.hasMoreElements()) {
-            printerName = aDataObject.getNext();
-            printerName = printerName.QueryInterface(Components.interfaces.nsISupportsString);
-            var printerNameStr = printerName.toString();
-            if (strDefaultPrinterName == "")
-               strDefaultPrinterName = printerNameStr;
-
-            list.appendItem(printerNameStr, printerNameStr, getPrinterDescription(printerNameStr));
-          }
-          if (strDefaultPrinterName != "") {
-            this.listElement.removeAttribute("disabled");
-          } else {
+          if ((null == aDataObject) || !aDataObject.hasMore()) {
+            // disable dialog
             var stringBundle = srGetStrBundle("chrome://global/locale/printing.properties");
-            this.listElement.setAttribute("value", strDefaultPrinterName);
+            this.listElement.setAttribute("value", "");
             this.listElement.setAttribute("label", stringBundle.GetStringFromName("noprinter"));
 
-            // disable dialog
             this.listElement.setAttribute("disabled", "true");
             dialog.printerLabel.setAttribute("disabled","true");
             dialog.propertiesButton.setAttribute("disabled","true");
             dialog.fileCheck.setAttribute("disabled","true");
             dialog.printButton.setAttribute("disabled","true");
           }
-
-          return strDefaultPrinterName;
+          else {
+            // build popup menu from printer names
+            var list = document.getElementById("printerList"); 
+            do {
+              printerNameStr = aDataObject.getNext();
+              list.appendItem(printerNameStr, printerNameStr, getPrinterDescription(printerNameStr));
+            } while (aDataObject.hasMore());
+            this.listElement.removeAttribute("disabled");
+          }
         } 
   };
 
 //---------------------------------------------------
 function getPrinters()
 {
-  var printerEnumerator = printOptions.availablePrinters();
-
   var selectElement = new listElement(dialog.printerList);
   selectElement.clearList();
-  var strDefaultPrinterName = selectElement.appendPrinterNames(printerEnumerator);
 
-  selectElement.listElement.value = strDefaultPrinterName;
+  var printerEnumerator;
+  try {
+    printerEnumerator =
+        Components.classes["@mozilla.org/gfx/printerenumerator;1"]
+                  .getService(Components.interfaces.nsIPrinterEnumerator)
+                  .printerNameList;
+  } catch(e) { printerEnumerator = null; }
+
+  selectElement.appendPrinterNames(printerEnumerator);
+  selectElement.listElement.value = printService.defaultPrinterName;
 
   // make sure we load the prefs for the initially selected printer
   setPrinterDefaultsForSelectedPrinter();
 }
 
 
 //---------------------------------------------------
 // update gPrintSettings with the defaults for the selected printer
@@ -260,22 +256,21 @@ function loadDialog()
   try {
     gPrefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
 
     printService = Components.classes["@mozilla.org/gfx/printsettings-service;1"];
     if (printService) {
       printService = printService.getService();
       if (printService) {
         printService = printService.QueryInterface(Components.interfaces.nsIPrintSettingsService);
-        printOptions = printService.QueryInterface(Components.interfaces.nsIPrintOptions);
       }
     }
   } catch(e) {}
 
-  // Note: getPrinters sets up the PrintToFile radio buttons and initalises gPrintSettings
+  // Note: getPrinters sets up the PrintToFile control
   getPrinters();
 
   if (gPrintSettings) {
     print_tofile        = gPrintSettings.printToFile;
     gOriginalNumCopies  = gPrintSettings.numCopies;
 
     print_copies        = gPrintSettings.numCopies;
     print_frametype     = gPrintSettings.printFrameType;
--- a/widget/public/nsIPrintOptions.idl
+++ b/widget/public/nsIPrintOptions.idl
@@ -39,53 +39,46 @@
 
 #include "nsISupports.idl"
 #include "nsIPrintSettings.idl"
 
 %{ C++
 struct nsFont;
 %}
 
-interface nsISimpleEnumerator;
+interface nsIStringEnumerator;
 
 /**
  * Native types
  */
 [ref] native nsNativeFontRef(nsFont);
 
 /**
  * Print options interface
  *
  * Do not attempt to freeze this API - it still needs lots of work. Consult
  * John Keiser <jkeiser@netscape.com> and Roland Mainz
  * <roland.mainz@informatik.med.uni-giessen.de> for futher details.
  */
-[scriptable, uuid(722566e9-5983-42e8-9dae-7178b23933c7)]
+[scriptable, uuid(92597c2b-109b-40bb-8f93-9b9acfa31de8)]
 
 interface nsIPrintOptions : nsISupports
 {
   /**
    * Show Native Print Options dialog, this may not be supported on all platforms
    */
   void ShowPrintSetupDialog(in nsIPrintSettings aThePrintSettings);
 
   /**
    * Creates a new PrintSettnigs Object
    * and initializes it from prefs
    */
   nsIPrintSettings CreatePrintSettings();
 
   /**
-   * available Printers
-   * It returns an enumerator object or throws an exception on error cases
-   * like if internal setup failed and/or no printers are available.
-   */
-  nsISimpleEnumerator availablePrinters ();
-
-  /**
    * Get a prefixed integer pref 
    */
   PRInt32 getPrinterPrefInt(in nsIPrintSettings aPrintSettings, in wstring
                             aPrefName);
 
   /**
    * display Printer Job Properties dialog
    */
@@ -95,45 +88,41 @@ interface nsIPrintOptions : nsISupports
   /**
    * Native data constants
    */
   const short kNativeDataPrintRecord        = 0;
 
   [noscript] voidPtr GetNativeData(in short aDataType);
 };
 
-[scriptable, uuid(a6cf9128-15b3-11d2-932e-00805f8add32)]
+[scriptable, uuid(5e738fff-404c-4c94-9189-e8f2cce93e94)]
 
 interface nsIPrinterEnumerator : nsISupports
 {
   /**
-   * The name of the default printer 
-   * This name must be in the list of printer names returned by
-   * "availablePrinters"
-   * 
+   * The name of the system default printer. This name should also be
+   * present in printerNameList below. This is not necessarily gecko's
+   * default printer; see nsIPrintSettingsService.defaultPrinterName
+   * for that.
    */
   readonly attribute wstring defaultPrinterName;
 
   /**
    * Initializes certain settings from the native printer into the PrintSettings
    * These settings include, but are not limited to:
    *   Page Orientation
    *   Page Size
    *   Number of Copies
    */
   void initPrintSettingsFromPrinter(in wstring aPrinterName, in nsIPrintSettings aPrintSettings);
 
   /**
-   * Returns an array of the names of all installed printers.
-   *
-   * @param  aCount     returns number of printers returned
-   * @param  aResult    returns array of names
-   * @return void
+   * The list of printer names
    */
-  void enumeratePrinters(out PRUint32 aCount,[retval, array, size_is(aCount)] out wstring aResult);
+  readonly attribute nsIStringEnumerator printerNameList;
 
   /*  takes printer selected and will display job properties dlg for that printer
    *  returns true if dialog displays
    */
   void displayPropertiesDlg(in wstring aPrinter, in nsIPrintSettings aPrintSettings);
 
 };
 
--- a/widget/src/beos/nsDeviceContextSpecB.cpp
+++ b/widget/src/beos/nsDeviceContextSpecB.cpp
@@ -39,16 +39,17 @@
 #include "nsIWidget.h"
 #include "nsDeviceContextSpecB.h"
  
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "prenv.h" /* for PR_GetEnv */ 
 #include "nsIServiceManager.h"
 #include "nsReadableUtils.h"
+#include "nsStringEnumerator.h"
 #include "nsCRT.h"
 
 //----------------------------------------------------------------------------------
 // The printer data is shared between the PrinterEnumerator and the nsDeviceContextSpecG
 // The PrinterEnumerator creates the printer info
 // but the nsDeviceContextSpecG cleans it up
 // If it gets created (via the Page Setup Dialog) but the user never prints anything
 // then it will never be delete, so this class takes care of that.
@@ -408,67 +409,41 @@ NS_IMETHODIMP nsDeviceContextSpecBeOS::G
 
 //  Printer Enumerator
 nsPrinterEnumeratorBeOS::nsPrinterEnumeratorBeOS()
 {
 }
 
 NS_IMPL_ISUPPORTS1(nsPrinterEnumeratorBeOS, nsIPrinterEnumerator)
 
-NS_IMETHODIMP nsPrinterEnumeratorBeOS::EnumeratePrinters(PRUint32* aCount, PRUnichar*** aResult)
+NS_IMETHODIMP nsPrinterEnumeratorBeOS::GetPrinterNameList(nsIStringEnumerator **aPrinterNameList)
 {
-  NS_ENSURE_ARG(aCount);
-  NS_ENSURE_ARG_POINTER(aResult);
-
-  if (aCount) 
-    *aCount = 0;
-  else 
-    return NS_ERROR_NULL_POINTER;
-  
-  if (aResult) 
-    *aResult = nsnull;
-  else 
-    return NS_ERROR_NULL_POINTER;
+  NS_ENSURE_ARG_POINTER(aPrinterNameList);
+  *aPrinterNameList = nsnull;
   
   nsresult rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   PRInt32 numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters();
-
-  PRUnichar** array = (PRUnichar**) nsMemory::Alloc(numPrinters * sizeof(PRUnichar*));
-  if (!array && numPrinters > 0) {
+  nsStringArray *printers = new nsStringArray(numPrinters);
+  if (!printers) {
     GlobalPrinters::GetInstance()->FreeGlobalPrinters();
     return NS_ERROR_OUT_OF_MEMORY;
   }
   
   int count = 0;
   while( count < numPrinters )
   {
-
-    PRUnichar *str = ToNewUnicode(*GlobalPrinters::GetInstance()->GetStringAt(count));
-
-    if (!str) {
-      for (int i = count - 1; i >= 0; i--) 
-        nsMemory::Free(array[i]);
-      
-      nsMemory::Free(array);
-
-      GlobalPrinters::GetInstance()->FreeGlobalPrinters();
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
-    array[count++] = str;
-    
+    printers->AppendString(*GlobalPrinters::GetInstance()->GetStringAt(count++));
   }
-  *aCount = count;
-  *aResult = array;
   GlobalPrinters::GetInstance()->FreeGlobalPrinters();
 
-  return NS_OK;
+  return NS_NewAdoptingStringEnumerator(aPrinterNameList, printers);
 }
 
 /* readonly attribute wstring defaultPrinterName; */
 NS_IMETHODIMP nsPrinterEnumeratorBeOS::GetDefaultPrinterName(PRUnichar * *aDefaultPrinterName)
 {
   NS_ENSURE_ARG_POINTER(aDefaultPrinterName);
   *aDefaultPrinterName = nsnull;
   return NS_OK;
--- a/widget/src/gtk2/nsDeviceContextSpecG.cpp
+++ b/widget/src/gtk2/nsDeviceContextSpecG.cpp
@@ -53,16 +53,17 @@
 #include "nsDeviceContextSpecG.h"
 
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "prenv.h" /* for PR_GetEnv */
 
 #include "nsPrintfCString.h"
 #include "nsReadableUtils.h"
+#include "nsStringEnumerator.h"
 #include "nsIServiceManager.h" 
 
 #ifdef USE_XPRINT
 #include "xprintutil.h"
 #endif /* USE_XPRINT */
 
 #ifdef USE_POSTSCRIPT
 #include "nsPSPrinters.h"
@@ -823,66 +824,41 @@ nsresult CopyPrinterCharPref(nsIPrefBran
 
 //  Printer Enumerator
 nsPrinterEnumeratorGTK::nsPrinterEnumeratorGTK()
 {
 }
 
 NS_IMPL_ISUPPORTS1(nsPrinterEnumeratorGTK, nsIPrinterEnumerator)
 
-NS_IMETHODIMP nsPrinterEnumeratorGTK::EnumeratePrinters(PRUint32* aCount, PRUnichar*** aResult)
+NS_IMETHODIMP nsPrinterEnumeratorGTK::GetPrinterNameList(nsIStringEnumerator **aPrinterNameList)
 {
-  NS_ENSURE_ARG(aCount);
-  NS_ENSURE_ARG_POINTER(aResult);
-
-  if (aCount) 
-    *aCount = 0;
-  else 
-    return NS_ERROR_NULL_POINTER;
-  
-  if (aResult) 
-    *aResult = nsnull;
-  else 
-    return NS_ERROR_NULL_POINTER;
+  NS_ENSURE_ARG_POINTER(aPrinterNameList);
+  *aPrinterNameList = nsnull;
   
   nsresult rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   PRInt32 numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters();
-
-  PRUnichar** array = (PRUnichar**) nsMemory::Alloc(numPrinters * sizeof(PRUnichar*));
-  if (!array && numPrinters > 0) {
+  nsStringArray *printers = new nsStringArray(numPrinters);
+  if (!printers) {
     GlobalPrinters::GetInstance()->FreeGlobalPrinters();
     return NS_ERROR_OUT_OF_MEMORY;
   }
   
   int count = 0;
   while( count < numPrinters )
   {
-    PRUnichar *str = ToNewUnicode(*GlobalPrinters::GetInstance()->GetStringAt(count));
-
-    if (!str) {
-      for (int i = count - 1; i >= 0; i--) 
-        nsMemory::Free(array[i]);
-      
-      nsMemory::Free(array);
-
-      GlobalPrinters::GetInstance()->FreeGlobalPrinters();
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
-    array[count++] = str;
-    
+    printers->AppendString(*GlobalPrinters::GetInstance()->GetStringAt(count++));
   }
-  *aCount = count;
-  *aResult = array;
   GlobalPrinters::GetInstance()->FreeGlobalPrinters();
 
-  return NS_OK;
+  return NS_NewAdoptingStringEnumerator(aPrinterNameList, printers);
 }
 
 /* readonly attribute wstring defaultPrinterName; */
 NS_IMETHODIMP nsPrinterEnumeratorGTK::GetDefaultPrinterName(PRUnichar **aDefaultPrinterName)
 {
   DO_PR_DEBUG_LOG(("nsPrinterEnumeratorGTK::GetDefaultPrinterName()\n"));
   NS_ENSURE_ARG_POINTER(aDefaultPrinterName);
 
--- a/widget/src/os2/nsDeviceContextSpecOS2.cpp
+++ b/widget/src/os2/nsDeviceContextSpecOS2.cpp
@@ -45,16 +45,17 @@
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "prenv.h" /* for PR_GetEnv */
 
 #include "nsPrintfCString.h"
 #include "nsIServiceManager.h"
 #include "nsUnicharUtils.h"
 #include "nsStringFwd.h"
+#include "nsStringEnumerator.h"
 
 #include "nsOS2Uni.h"
 
 PRINTDLG nsDeviceContextSpecOS2::PrnDlg;
 
 //----------------------------------------------------------------------------------
 // The printer data is shared between the PrinterEnumerator and the nsDeviceContextSpecOS2
 // The PrinterEnumerator creates the printer info
@@ -430,68 +431,43 @@ NS_IMETHODIMP nsDeviceContextSpecOS2::En
 
 //  Printer Enumerator
 nsPrinterEnumeratorOS2::nsPrinterEnumeratorOS2()
 {
 }
 
 NS_IMPL_ISUPPORTS1(nsPrinterEnumeratorOS2, nsIPrinterEnumerator)
 
-NS_IMETHODIMP nsPrinterEnumeratorOS2::EnumeratePrinters(PRUint32* aCount, PRUnichar*** aResult)
+NS_IMETHODIMP nsPrinterEnumeratorOS2::GetPrinterNameList(nsIStringEnumerator **aPrinterNameList)
 {
-  NS_ENSURE_ARG(aCount);
-  NS_ENSURE_ARG_POINTER(aResult);
-
-  if (aCount) 
-    *aCount = 0;
-  else 
-    return NS_ERROR_NULL_POINTER;
-  
-  if (aResult) 
-    *aResult = nsnull;
-  else 
-    return NS_ERROR_NULL_POINTER;
+  NS_ENSURE_ARG_POINTER(aPrinterNameList);
+  *aPrinterNameList = nsnull;
 
   nsDeviceContextSpecOS2::PrnDlg.RefreshPrintQueue();
   
   nsresult rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   ULONG numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters();
-
-  PRUnichar** array = (PRUnichar**) nsMemory::Alloc(numPrinters * sizeof(PRUnichar*));
-  if (!array && numPrinters > 0) {
+  nsStringArray *printers = new nsStringArray(numPrinters);
+  if (!printers) {
     GlobalPrinters::GetInstance()->FreeGlobalPrinters();
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   ULONG count = 0;
   while( count < numPrinters )
   {
-    PRUnichar *str = ToNewUnicode(*GlobalPrinters::GetInstance()->GetStringAt(count));
-
-    if (!str) {
-      for (ULONG i = 0 ; i < count ; i++)
-        nsMemory::Free(array[i]);
-      
-      nsMemory::Free(array);
-
-      GlobalPrinters::GetInstance()->FreeGlobalPrinters();
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
-    array[count++] = str;
-    
+    printers->AppendString(*GlobalPrinters::GetInstance()->GetStringAt(count++));
   }
-  *aCount = count;
-  *aResult = array;
   GlobalPrinters::GetInstance()->FreeGlobalPrinters();
 
-  return NS_OK;
+  return NS_NewAdoptingStringEnumerator(aPrinterNameList, printers);
 }
 
 NS_IMETHODIMP nsPrinterEnumeratorOS2::GetDefaultPrinterName(PRUnichar * *aDefaultPrinterName)
 {
   NS_ENSURE_ARG_POINTER(aDefaultPrinterName);
   GlobalPrinters::GetInstance()->GetDefaultPrinterName(*aDefaultPrinterName);
   return NS_OK;
 }
--- a/widget/src/windows/nsDeviceContextSpecWin.cpp
+++ b/widget/src/windows/nsDeviceContextSpecWin.cpp
@@ -45,16 +45,17 @@
 
 #include "nsVoidArray.h"
 #include "nsIPrintSettingsWin.h"
 
 #include "nsString.h"
 #include "nsCRT.h"
 #include "nsIServiceManager.h"
 #include "nsReadableUtils.h"
+#include "nsStringEnumerator.h"
 #ifdef MOZ_CAIRO_GFX
 #include "gfxPDFSurface.h"
 #include "gfxWindowsSurface.h"
 #endif
 
 #include "nsIFileStreams.h"
 #include "nsUnitConversion.h"
 #include "nsIWindowWatcher.h"
@@ -900,28 +901,17 @@ nsPrinterEnumeratorWin::nsPrinterEnumera
 nsPrinterEnumeratorWin::~nsPrinterEnumeratorWin()
 {
   // Do not free printers here
   // GlobalPrinters::GetInstance()->FreeGlobalPrinters();
 }
 
 NS_IMPL_ISUPPORTS1(nsPrinterEnumeratorWin, nsIPrinterEnumerator)
 
-
-static void CleanupArray(PRUnichar**& aArray, PRInt32& aCount)
-{
-  for (PRInt32 i = aCount - 1; i >= 0; i--) {
-    nsMemory::Free(aArray[i]);
-  }
-  nsMemory::Free(aArray);
-  aArray = NULL;
-  aCount = 0;
-}
-
- //----------------------------------------------------------------------------------
+//----------------------------------------------------------------------------------
 // Return the Default Printer name
 /* readonly attribute wstring defaultPrinterName; */
 NS_IMETHODIMP 
 nsPrinterEnumeratorWin::GetDefaultPrinterName(PRUnichar * *aDefaultPrinterName)
 {
   NS_ENSURE_ARG_POINTER(aDefaultPrinterName);
 
   *aDefaultPrinterName = GetDefaultPrinterNameFromGlobalPrinters(); // helper
@@ -962,62 +952,41 @@ nsPrinterEnumeratorWin::InitPrintSetting
   return NS_OK;
 }
 
 
 //----------------------------------------------------------------------------------
 // Enumerate all the Printers from the global array and pass their
 // names back (usually to script)
 NS_IMETHODIMP 
-nsPrinterEnumeratorWin::EnumeratePrinters(PRUint32* aCount, PRUnichar*** aResult)
+nsPrinterEnumeratorWin::GetPrinterNameList(nsIStringEnumerator **aPrinterNameList)
 {
-  NS_ENSURE_ARG(aCount);
-  NS_ENSURE_ARG_POINTER(aResult);
+  NS_ENSURE_ARG_POINTER(aPrinterNameList);
+  *aPrinterNameList = nsnull;
 
   nsresult rv = GlobalPrinters::GetInstance()->EnumeratePrinterList();
   if (NS_FAILED(rv)) {
-    PR_PL(("***** nsDeviceContextSpecWin::EnumeratePrinters - Couldn't enumerate printers!\n"));
+    PR_PL(("***** nsDeviceContextSpecWin::GetPrinterNameList - Couldn't enumerate printers!\n"));
     return rv;
   }
 
-  if (aCount) 
-    *aCount = 0;
-  else 
-    return NS_ERROR_NULL_POINTER;
-  
-  if (aResult) 
-    *aResult = nsnull;
-  else 
-    return NS_ERROR_NULL_POINTER;
-  
   PRInt32 numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters();
-  PRInt32 numItems    = numPrinters;
-
-  PRUnichar** array = (PRUnichar**) nsMemory::Alloc(numItems * sizeof(PRUnichar*));
-  if (!array) 
+  nsStringArray *printers = new nsStringArray(numPrinters);
+  if (!printers)
     return NS_ERROR_OUT_OF_MEMORY;
-  
-  PRInt32 count      = 0;
+
   PRInt32 printerInx = 0;
-  while( count < numItems ) {
+  while( printerInx < numPrinters ) {
     LPTSTR name = GlobalPrinters::GetInstance()->GetItemFromList(printerInx++);
     nsAutoString newName; 
     NS_CopyNativeToUnicode(nsDependentCString(name), newName);
-    PRUnichar *str = ToNewUnicode(newName);
-    if (!str) {
-      CleanupArray(array, count);
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
-    array[count++] = str;
+    printers->AppendString(newName);
   }
-  *aCount  = count;
-  *aResult = array;
 
-  return NS_OK;
-
+  return NS_NewAdoptingStringEnumerator(aPrinterNameList, array);
 }
 
 //----------------------------------------------------------------------------------
 // Display the AdvancedDocumentProperties for the selected Printer
 NS_IMETHODIMP nsPrinterEnumeratorWin::DisplayPropertiesDlg(const PRUnichar *aPrinterName, nsIPrintSettings* aPrintSettings)
 {
   // Implementation removed because it is unused
   return NS_OK;
--- a/widget/src/windows/nsDeviceContextSpecWin.h
+++ b/widget/src/windows/nsDeviceContextSpecWin.h
@@ -113,15 +113,11 @@ protected:
 //-------------------------------------------------------------------------
 class nsPrinterEnumeratorWin : public nsIPrinterEnumerator
 {
 public:
   nsPrinterEnumeratorWin();
   ~nsPrinterEnumeratorWin();
   NS_DECL_ISUPPORTS
   NS_DECL_NSIPRINTERENUMERATOR
-
-private:
-  // helper 
-  nsresult DoEnumeratePrinters(PRBool aDoExtended, PRUint32* aCount, PRUnichar*** aResult);
 };
 
 #endif
--- a/widget/src/xpwidgets/nsPrintOptionsImpl.cpp
+++ b/widget/src/xpwidgets/nsPrintOptionsImpl.cpp
@@ -54,17 +54,17 @@
 #include "nsSupportsArray.h"
 #include "prprf.h"
 
 // For Prefs
 #include "nsIPrefBranch.h"
 #include "nsIPrefService.h"
 #include "nsIServiceManager.h"
 
-#include "nsISimpleEnumerator.h"
+#include "nsIStringEnumerator.h"
 #include "nsISupportsPrimitives.h"
 #include "nsWidgetsCID.h"
 #include "stdlib.h"
 #include "nsAutoPtr.h"
 
 static NS_DEFINE_IID(kCPrinterEnumerator, NS_PRINTER_ENUMERATOR_CID);
 
 NS_IMPL_ISUPPORTS2(nsPrintOptions, nsIPrintOptions, nsIPrintSettingsService)
@@ -132,90 +132,16 @@ nsPrintOptions::Init()
   nsresult rv;
   nsCOMPtr<nsIPrefService> prefService =
       do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return prefService->GetBranch("print.", getter_AddRefs(mPrefBranch));
 }
 
-
-//**************************************************************
-//** PageList Enumerator
-//**************************************************************
-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)
-{
-}
-
-nsPrinterListEnumerator::~nsPrinterListEnumerator()
-{
-  if (mPrinters)
-    NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(mCount, mPrinters);
-}
-
-NS_IMPL_ISUPPORTS1(nsPrinterListEnumerator, nsISimpleEnumerator)
-
-NS_IMETHODIMP
-nsPrinterListEnumerator::Init()
-{
-  nsresult rv;
-  nsCOMPtr<nsIPrinterEnumerator> printerEnumerator =
-    do_CreateInstance(kCPrinterEnumerator, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  return printerEnumerator->EnumeratePrinters(&mCount, &mPrinters);
-}
-
-NS_IMETHODIMP
-nsPrinterListEnumerator::HasMoreElements(PRBool *result)
-{
-  *result = (mIndex < mCount);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsPrinterListEnumerator::GetNext(nsISupports **aPrinter)
-{
-  NS_ENSURE_STATE(mIndex < mCount);
-
-  PRUnichar *printerName = mPrinters[mIndex++];
-
-  nsresult rv;
-  nsCOMPtr<nsISupportsString> printerNameWrapper =
-    do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  printerNameWrapper->SetData(nsDependentString(printerName));
-  *aPrinter = NS_STATIC_CAST(nsISupports*, printerNameWrapper);
-  NS_ADDREF(*aPrinter);
-  return NS_OK;
-}
-
 NS_IMETHODIMP
 nsPrintOptions::ShowPrintSetupDialog(nsIPrintSettings *aPS)
 {
   NS_ENSURE_ARG_POINTER(aPS);
   nsresult rv;
 
   // create a nsISupportsArray of the parameters
   // being passed to the window
@@ -857,33 +783,16 @@ nsPrintOptions::WritePrefs(nsIPrintSetti
   }
 
   // Not Writing Out:
   //   Number of Copies
 
   return NS_OK;
 }
 
-/* create and return a new |nsPrinterListEnumerator| */
-NS_IMETHODIMP
-nsPrintOptions::AvailablePrinters(nsISimpleEnumerator **aPrinterEnumerator)
-{
-  nsRefPtr<nsPrinterListEnumerator> printerListEnum =
-      new nsPrinterListEnumerator();
-  NS_ENSURE_TRUE(printerListEnum, NS_ERROR_OUT_OF_MEMORY);
-
-  NS_ADDREF(*aPrinterEnumerator = printerListEnum.get());
-
-  nsresult rv = printerListEnum->Init();
-  if (NS_FAILED(rv))
-    NS_RELEASE(*aPrinterEnumerator);
-
-  return rv;
-}
-
 NS_IMETHODIMP
 nsPrintOptions::DisplayJobProperties(const PRUnichar *aPrinter,
                                      nsIPrintSettings* aPrintSettings,
                                      PRBool *aDisplayed)
 {
   NS_ENSURE_ARG_POINTER(aPrinter);
   *aDisplayed = PR_FALSE;
 
@@ -957,28 +866,28 @@ nsPrintOptions::GetDefaultPrinterName(PR
                                                          &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Look up the printer from the last print job
   nsAutoString lastPrinterName;
   ReadPrefString(kPrinterName, lastPrinterName);
   if (!lastPrinterName.IsEmpty()) {
     // Verify it's still a valid printer
-    PRUnichar **printers;
-    PRUint32 ctPrinters;
-    rv = prtEnum->EnumeratePrinters(&ctPrinters, &printers);
+    nsCOMPtr<nsIStringEnumerator> printers;
+    rv = prtEnum->GetPrinterNameList(getter_AddRefs(printers));
     if (NS_SUCCEEDED(rv)) {
       PRBool isValid = PR_FALSE;
-      for (PRInt32 ii = ctPrinters - 1; ii >= 0; --ii) {
-        if (lastPrinterName.Equals(printers[ii])) {
+      PRBool hasMore;
+      while (NS_SUCCEEDED(printers->HasMore(&hasMore)) && hasMore) {
+        nsAutoString printer;
+        if (NS_SUCCEEDED(printers->GetNext(printer)) && lastPrinterName.Equals(printer)) {
           isValid = PR_TRUE;
           break;
         }
       }
-      NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(ctPrinters, printers);
       if (isValid) {
         *aDefaultPrinterName = ToNewUnicode(lastPrinterName);
         return NS_OK;
       }
     }
   }
 
   // There is no last printer preference, or it doesn't name a valid printer.
--- a/xpfe/global/resources/content/printdialog.js
+++ b/xpfe/global/resources/content/printdialog.js
@@ -38,17 +38,16 @@
  * 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 ***** */
 
 var dialog;
 var printService       = null;
-var printOptions       = null;
 var gOriginalNumCopies = 1;
 
 var paramBlock;
 var gPrefs             = null;
 var gPrintSettings     = null;
 var gWebBrowserPrint   = null;
 var gPrintSetInterface = Components.interfaces.nsIPrintSettings;
 var doDebug            = false;
@@ -143,59 +142,56 @@ listElement.prototype =
           if (popup) {
             this.listElement.removeChild(popup);
           }
         },
 
     appendPrinterNames: 
       function (aDataObject) 
         { 
-          var list = document.getElementById("printerList"); 
-          var strDefaultPrinterName = "";
-          var printerName;
-
-          // build popup menu from printer names
-          while (aDataObject.hasMoreElements()) {
-            printerName = aDataObject.getNext();
-            printerName = printerName.QueryInterface(Components.interfaces.nsISupportsString);
-            var printerNameStr = printerName.toString();
-            if (strDefaultPrinterName == "")
-               strDefaultPrinterName = printerNameStr;
-
-            list.appendItem(printerNameStr, printerNameStr, getPrinterDescription(printerNameStr));
-          }
-          if (strDefaultPrinterName != "") {
-            this.listElement.removeAttribute("disabled");
-          } else {
+          if ((null == aDataObject) || !aDataObject.hasMore()) {
+            // disable dialog
             var stringBundle = srGetStrBundle("chrome://global/locale/printing.properties");
-            this.listElement.setAttribute("value", strDefaultPrinterName);
+            this.listElement.setAttribute("value", "");
             this.listElement.setAttribute("label", stringBundle.GetStringFromName("noprinter"));
 
-            // disable dialog
             this.listElement.setAttribute("disabled", "true");
             dialog.printerLabel.setAttribute("disabled","true");
             dialog.propertiesButton.setAttribute("disabled","true");
             dialog.fileCheck.setAttribute("disabled","true");
             dialog.printButton.setAttribute("disabled","true");
           }
-
-          return strDefaultPrinterName;
+          else {
+            // build popup menu from printer names
+            var list = document.getElementById("printerList"); 
+            do {
+              printerNameStr = aDataObject.getNext();
+              list.appendItem(printerNameStr, printerNameStr, getPrinterDescription(printerNameStr));
+            } while (aDataObject.hasMore());
+            this.listElement.removeAttribute("disabled");
+          }
         } 
   };
 
 //---------------------------------------------------
 function getPrinters()
 {
-  var printerEnumerator = printOptions.availablePrinters();
-
   var selectElement = new listElement(dialog.printerList);
   selectElement.clearList();
-  var strDefaultPrinterName = selectElement.appendPrinterNames(printerEnumerator);
 
-  selectElement.listElement.value = strDefaultPrinterName;
+  var printerEnumerator;
+  try {
+    printerEnumerator =
+        Components.classes["@mozilla.org/gfx/printerenumerator;1"]
+                  .getService(Components.interfaces.nsIPrinterEnumerator)
+                  .printerNameList;
+  } catch(e) { printerEnumerator = null; }
+
+  selectElement.appendPrinterNames(printerEnumerator);
+  selectElement.listElement.value = printService.defaultPrinterName;
 
   // make sure we load the prefs for the initially selected printer
   setPrinterDefaultsForSelectedPrinter();
 }
 
 
 //---------------------------------------------------
 // update gPrintSettings with the defaults for the selected printer
@@ -260,22 +256,21 @@ function loadDialog()
   try {
     gPrefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
 
     printService = Components.classes["@mozilla.org/gfx/printsettings-service;1"];
     if (printService) {
       printService = printService.getService();
       if (printService) {
         printService = printService.QueryInterface(Components.interfaces.nsIPrintSettingsService);
-        printOptions = printService.QueryInterface(Components.interfaces.nsIPrintOptions);
       }
     }
   } catch(e) {}
 
-  // Note: getPrinters sets up the PrintToFile radio buttons and initalises gPrintSettings
+  // Note: getPrinters sets up the PrintToFile control
   getPrinters();
 
   if (gPrintSettings) {
     print_tofile        = gPrintSettings.printToFile;
     gOriginalNumCopies  = gPrintSettings.numCopies;
 
     print_copies        = gPrintSettings.numCopies;
     print_frametype     = gPrintSettings.printFrameType;