Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
nsDeviceContextSpecQt.cpp File Reference
#include "prlog.h"
#include "nsDeviceContextSpecQt.h"
#include "nsIPref.h"
#include "prenv.h"
#include "nsPrintfCString.h"
#include "nsReadableUtils.h"
#include "nsIServiceManager.h"
#include "nsCRT.h"

Go to the source code of this file.

Classes

class  GlobalPrinters
class  nsPrinterFeatures

Defines

#define SET_PRINTER_FEATURES_VIA_PREFS   1
#define PRINTERFEATURES_PREF   "print.tmp.printerfeatures"
#define FORCE_PR_LOG   /* Allow logging in the release build */
#define PR_LOGGING   1
#define MAKE_PR_BOOL(val)   ((val)?(PR_TRUE):(PR_FALSE))
#define DO_PR_DEBUG_LOG(x)   PR_LOG(DeviceContextSpecQtLM, PR_LOG_DEBUG, x)

Functions

 NS_IMPL_ISUPPORTS1 (nsDeviceContextSpecQt, nsIDeviceContextSpec) NS_IMETHODIMP nsDeviceContextSpecQt
 
Initialize the nsDeviceContextSpecQt dc 2/15/98 syd 3/2/99
static nsresult CopyPrinterCharPref (nsIPref *pref, const char *modulename, const char *printername, const char *prefname, char **return_buf)

Variables

static PRLogModuleInfoDeviceContextSpecQtLM = PR_NewLogModule("DeviceContextSpecQt")

Define Documentation

Definition at line 78 of file nsDeviceContextSpecQt.cpp.

#define FORCE_PR_LOG   /* Allow logging in the release build */

Definition at line 46 of file nsDeviceContextSpecQt.cpp.

#define MAKE_PR_BOOL (   val)    ((val)?(PR_TRUE):(PR_FALSE))

Definition at line 72 of file nsDeviceContextSpecQt.cpp.

#define PR_LOGGING   1

Definition at line 47 of file nsDeviceContextSpecQt.cpp.

#define PRINTERFEATURES_PREF   "print.tmp.printerfeatures"

Definition at line 44 of file nsDeviceContextSpecQt.cpp.

Definition at line 43 of file nsDeviceContextSpecQt.cpp.


Function Documentation

static nsresult CopyPrinterCharPref ( nsIPref pref,
const char *  modulename,
const char *  printername,
const char *  prefname,
char **  return_buf 
) [static]

Definition at line 504 of file nsDeviceContextSpecQt.cpp.

{
  DO_PR_DEBUG_LOG(("CopyPrinterCharPref('%s', '%s', '%s')\n", modulename, printername, prefname));

  NS_ENSURE_ARG_POINTER(return_buf);

  nsXPIDLCString name;
  nsresult rv = NS_ERROR_FAILURE;

  if (printername && modulename) {
    /* Get prefs per printer name and module name */
    name = nsPrintfCString(512, "print.%s.printer_%s.%s", modulename, printername, prefname);
    DO_PR_DEBUG_LOG(("trying to get '%s'\n", name.get()));
    rv = pref->CopyCharPref(name, return_buf);
  }

  if (NS_FAILED(rv)) {
    if (printername) {
      /* Get prefs per printer name */
      name = nsPrintfCString(512, "print.printer_%s.%s", printername, prefname);
      DO_PR_DEBUG_LOG(("trying to get '%s'\n", name.get()));
      rv = pref->CopyCharPref(name, return_buf);
    }

    if (NS_FAILED(rv)) {
      if (modulename) {
        /* Get prefs per module name */
        name = nsPrintfCString(512, "print.%s.%s", modulename, prefname);
        DO_PR_DEBUG_LOG(("trying to get '%s'\n", name.get()));
        rv = pref->CopyCharPref(name, return_buf);
      }

      if (NS_FAILED(rv)) {
        /* Get prefs */
        name = nsPrintfCString(512, "print.%s", prefname);
        DO_PR_DEBUG_LOG(("trying to get '%s'\n", name.get()));
        rv = pref->CopyCharPref(name, return_buf);
      }
    }
  }

#ifdef PR_LOG
  if (NS_SUCCEEDED(rv)) {
    DO_PR_DEBUG_LOG(("CopyPrinterCharPref returning '%s'.\n", *return_buf));
  }
  else
  {
    DO_PR_DEBUG_LOG(("CopyPrinterCharPref failure.\n"));
  }
#endif /* PR_LOG */

  return rv;
}

Here is the call graph for this function:


Initialize the nsDeviceContextSpecQt dc 2/15/98 syd 3/2/99

gisburn: Please note that this function exists as 1:1 copy in other toolkits including:

** Please update the other toolkits when changing this function.

Definition at line 257 of file nsDeviceContextSpecQt.cpp.

{
  DO_PR_DEBUG_LOG(("nsDeviceContextSpecQt::Init(aPS=%p\n", aPS));
  nsresult rv = NS_ERROR_FAILURE;

  mPrintSettings = aPS;

  // if there is a current selection then enable the "Selection" radio button
  if (mPrintSettings) {
    PRBool isOn;
    mPrintSettings->GetPrintOptions(nsIPrintSettings::kEnableSelectionRB, &isOn);
    nsCOMPtr<nsIPref> pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv);
    if (NS_SUCCEEDED(rv)) {
      (void) pPrefs->SetBoolPref("print.selection_radio_enabled", isOn);
    }
  }

  rv = GlobalPrinters::GetInstance()->InitializeGlobalPrinters();
  if (NS_FAILED(rv)) {
    return rv;
  }

  GlobalPrinters::GetInstance()->FreeGlobalPrinters();

  if (aPS) {
    PRBool     reversed       = PR_FALSE;
    PRBool     color          = PR_FALSE;
    PRBool     tofile         = PR_FALSE;
    PRInt16    printRange     = nsIPrintSettings::kRangeAllPages;
    PRInt32    orientation    = NS_PORTRAIT;
    PRInt32    fromPage       = 1;
    PRInt32    toPage         = 1;
    PRUnichar *command        = nsnull;
    PRInt32    copies         = 1;
    PRUnichar *printer        = nsnull;
    PRUnichar *papername      = nsnull;
    PRUnichar *printfile      = nsnull;
    double     dleft          = 0.5;
    double     dright         = 0.5;
    double     dtop           = 0.5;
    double     dbottom        = 0.5;

    aPS->GetPrinterName(&printer);
    aPS->GetPrintReversed(&reversed);
    aPS->GetPrintInColor(&color);
    aPS->GetPaperName(&papername);
    aPS->GetOrientation(&orientation);
    aPS->GetPrintCommand(&command);
    aPS->GetPrintRange(&printRange);
    aPS->GetToFileName(&printfile);
    aPS->GetPrintToFile(&tofile);
    aPS->GetStartPageRange(&fromPage);
    aPS->GetEndPageRange(&toPage);
    aPS->GetNumCopies(&copies);
    aPS->GetMarginTop(&dtop);
    aPS->GetMarginLeft(&dleft);
    aPS->GetMarginBottom(&dbottom);
    aPS->GetMarginRight(&dright);

    if (printfile)
      strcpy(mPath,    NS_ConvertUCS2toUTF8(printfile).get());
    if (command)
      strcpy(mCommand, NS_ConvertUCS2toUTF8(command).get());
    if (printer)
      strcpy(mPrinter, NS_ConvertUCS2toUTF8(printer).get());
    if (papername)
      strcpy(mPaperName, NS_ConvertUCS2toUTF8(papername).get());

    DO_PR_DEBUG_LOG(("margins:   %5.2f,%5.2f,%5.2f,%5.2f\n", dtop, dleft, dbottom, dright));
    DO_PR_DEBUG_LOG(("printRange %d\n",   printRange));
    DO_PR_DEBUG_LOG(("fromPage   %d\n",   fromPage));
    DO_PR_DEBUG_LOG(("toPage     %d\n",   toPage));
    DO_PR_DEBUG_LOG(("tofile     %d\n",   tofile));
    DO_PR_DEBUG_LOG(("printfile  '%s'\n", printfile? NS_ConvertUCS2toUTF8(printfile).get():"<NULL>"));
    DO_PR_DEBUG_LOG(("command    '%s'\n", command? NS_ConvertUCS2toUTF8(command).get():"<NULL>"));
    DO_PR_DEBUG_LOG(("printer    '%s'\n", printer? NS_ConvertUCS2toUTF8(printer).get():"<NULL>"));
    DO_PR_DEBUG_LOG(("papername  '%s'\n", papername? NS_ConvertUCS2toUTF8(papername).get():"<NULL>"));

    mTop         = dtop;
    mBottom      = dbottom;
    mLeft        = dleft;
    mRight       = dright;
    mFpf         = !reversed;
    mGrayscale   = !color;
    mOrientation = orientation;
    mToPrinter   = !tofile;
    mCopies      = copies;
  }

  return rv;
}

Here is the call graph for this function:


Variable Documentation

PRLogModuleInfo* DeviceContextSpecQtLM = PR_NewLogModule("DeviceContextSpecQt") [static]

Definition at line 75 of file nsDeviceContextSpecQt.cpp.