Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Protected Attributes
nsDeviceContextSpecBeOS Class Reference

#include <nsDeviceContextSpecB.h>

Inheritance diagram for nsDeviceContextSpecBeOS:
Inheritance graph
[legend]
Collaboration diagram for nsDeviceContextSpecBeOS:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsDeviceContextSpecBeOS ()
 Construct a nsDeviceContextSpecMac, which is an object which contains and manages a mac printrecord dc 12/02/98.
NS_DECL_ISUPPORTS NS_IMETHOD Init (nsIPrintSettings *aPS)
 Initialize the nsDeviceContextSpecBeOS for use.
NS_IMETHOD ClosePrintManager ()
 Closes the printmanager if it is open.
NS_IMETHOD GetPageSizeInTwips (PRInt32 *aWidth, PRInt32 *aHeight)
NS_IMETHOD GetToPrinter (PRBool &aToPrinter)
NS_IMETHOD GetPrinterName (const char **aPrinter)
NS_IMETHOD GetCopies (int &aCopies)
NS_IMETHOD GetFirstPageFirst (PRBool &aFpf)
NS_IMETHOD GetGrayscale (PRBool &aGrayscale)
NS_IMETHOD GetSize (int &aSize)
NS_IMETHOD GetTopMargin (float &value)
NS_IMETHOD GetBottomMargin (float &value)
NS_IMETHOD GetLeftMargin (float &value)
NS_IMETHOD GetRightMargin (float &value)
NS_IMETHOD GetCommand (const char **aCommand)
NS_IMETHOD GetPath (const char **aPath)
NS_IMETHOD GetPageDimensions (float &aWidth, float &aHeight)
NS_IMETHOD GetLandscape (PRBool &aLandscape)
NS_IMETHOD GetUserCancelled (PRBool &aCancel)
int InitializeGlobalPrinters ()
void FreeGlobalPrinters ()

Protected Member Functions

virtual ~nsDeviceContextSpecBeOS ()
 Destuct a nsDeviceContextSpecMac, this will release the printrecord dc 2/16/98.

Protected Attributes

BeOSPrData mPrData
nsCOMPtr< nsIPrintSettingsmPrintSettings

Detailed Description

Definition at line 53 of file nsDeviceContextSpecB.h.


Constructor & Destructor Documentation

Construct a nsDeviceContextSpecMac, which is an object which contains and manages a mac printrecord dc 12/02/98.


Construct the nsDeviceContextSpecBeOS dc 12/02/98

Definition at line 83 of file nsDeviceContextSpecB.cpp.

{
}

Destuct a nsDeviceContextSpecMac, this will release the printrecord dc 2/16/98.


Destroy the nsDeviceContextSpecBeOS dc 2/15/98

Definition at line 91 of file nsDeviceContextSpecB.cpp.

{
} 

Member Function Documentation

Closes the printmanager if it is open.


Closes the printmanager if it is open.

dc 2/13/98

Returns:
error status

dc 2/15/98

Definition at line 395 of file nsDeviceContextSpecB.cpp.

{
  return NS_OK;
}  

Definition at line 355 of file nsDeviceContextSpecB.cpp.

{ 
  value = mPrData.bottom; 
  return NS_OK; 
} 

Definition at line 373 of file nsDeviceContextSpecB.cpp.

{ 
  *aCommand = &mPrData.command[0]; 
  return NS_OK; 
} 

Definition at line 288 of file nsDeviceContextSpecB.cpp.

{
   aCopies = mPrData.copies;
   return NS_OK;
}

Definition at line 294 of file nsDeviceContextSpecB.cpp.

{ 
  aFpf = mPrData.fpf; 
  return NS_OK; 
} 

Definition at line 300 of file nsDeviceContextSpecB.cpp.

{ 
  aGrayscale = mPrData.grayscale; 
  return NS_OK; 
} 

Definition at line 343 of file nsDeviceContextSpecB.cpp.

{ 
  landscape = (mPrData.orientation == NS_LANDSCAPE);
  return NS_OK; 
} 

Definition at line 367 of file nsDeviceContextSpecB.cpp.

{ 
  value = mPrData.left; 
  return NS_OK; 
} 
NS_IMETHODIMP nsDeviceContextSpecBeOS::GetPageDimensions ( float &  aWidth,
float &  aHeight 
)

Definition at line 312 of file nsDeviceContextSpecB.cpp.

{ 
    if ( mPrData.size == NS_LETTER_SIZE ) { 
        aWidth = 8.5; 
        aHeight = 11.0; 
    } else if ( mPrData.size == NS_LEGAL_SIZE ) { 
        aWidth = 8.5; 
        aHeight = 14.0; 
    } else if ( mPrData.size == NS_EXECUTIVE_SIZE ) { 
        aWidth = 7.5; 
        aHeight = 10.0; 
    } else if ( mPrData.size == NS_A4_SIZE ) { 
        // 210mm X 297mm == 8.27in X 11.69in 
        aWidth = 8.27; 
        aHeight = 11.69; 
    } else if ( mPrData.size == NS_A3_SIZE ) {
        // 297mm X 420mm == 11.69in X 16.53in
        aWidth = 11.69;
        aHeight = 16.53;
    } 

    if (mPrData.orientation == NS_LANDSCAPE) {
      float temp;
      temp = aWidth;
      aWidth = aHeight;
      aHeight = temp;
    }

    return NS_OK; 
} 

Definition at line 400 of file nsDeviceContextSpecB.cpp.

{
  return mPrintSettings->GetPageSizeInTwips(aWidth, aHeight);
}

Definition at line 379 of file nsDeviceContextSpecB.cpp.

{ 
  *aPath = &mPrData.path[0]; 
  return NS_OK; 
} 

Definition at line 282 of file nsDeviceContextSpecB.cpp.

{
   *aPrinter = &mPrData.printer[0];
   return NS_OK;
}

Definition at line 361 of file nsDeviceContextSpecB.cpp.

{ 
  value = mPrData.right; 
  return NS_OK; 
} 

Definition at line 306 of file nsDeviceContextSpecB.cpp.

{ 
  aSize = mPrData.size; 
  return NS_OK; 
} 

Definition at line 349 of file nsDeviceContextSpecB.cpp.

{ 
  value = mPrData.top; 
  return NS_OK; 
} 

Definition at line 276 of file nsDeviceContextSpecB.cpp.

{ 
  aToPrinter = mPrData.toPrinter;
        return NS_OK;
} 

Definition at line 385 of file nsDeviceContextSpecB.cpp.

{ 
  aCancel = mPrData.cancel; 
  return NS_OK;
}

Initialize the nsDeviceContextSpecBeOS for use.


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

This will allocate a printrecord for use dc 2/16/98

Parameters:
aIsPrintPreviewif PR_TRUE, creating Spec for PrintPreview
Returns:
error status

Definition at line 149 of file nsDeviceContextSpecB.cpp.

{
  nsresult rv = NS_ERROR_FAILURE;
  NS_ASSERTION(nsnull != aPS, "No print settings.");

  mPrintSettings = aPS;
  
  // if there is a current selection then enable the "Selection" radio button
  if (aPS != nsnull) {
    PRBool isOn;
    aPS->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);
    }
  }

  char      *path;
  PRBool     reversed       = PR_FALSE;
  PRBool     color          = PR_FALSE;
  PRBool     tofile         = PR_FALSE;
  PRInt16    printRange     = nsIPrintSettings::kRangeAllPages;
  PRInt32    paper_size     = NS_LETTER_SIZE;
  PRInt32    orientation    = NS_PORTRAIT;
  PRInt32    fromPage       = 1;
  PRInt32    toPage         = 1;
  PRUnichar *command        = nsnull;
  PRInt32    copies         = 1;
  PRUnichar *printer        = nsnull;
  PRUnichar *printfile      = nsnull;
  double     dleft          = 0.5;
  double     dright         = 0.5;
  double     dtop           = 0.5;
  double     dbottom        = 0.5; 

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

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

  if (aPS != nsnull) {
    aPS->GetPrinterName(&printer);
    aPS->GetPrintReversed(&reversed);
    aPS->GetPrintInColor(&color);
    aPS->GetPaperSize(&paper_size);
    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 (command != nsnull && printfile != nsnull) {
      // ToDo: Use LocalEncoding instead of UTF-8 (see bug 73446)
      strcpy(mPrData.command, NS_ConvertUCS2toUTF8(command).get());  
      strcpy(mPrData.path,    NS_ConvertUCS2toUTF8(printfile).get());
    }
    if (printer != nsnull) 
      strcpy(mPrData.printer, NS_ConvertUCS2toUTF8(printer).get());        
#ifdef DEBUG_rods
    printf("margins:       %5.2f,%5.2f,%5.2f,%5.2f\n", dtop, dleft, dbottom, dright);
    printf("printRange     %d\n", printRange);
    printf("fromPage       %d\n", fromPage);
    printf("toPage         %d\n", toPage);
#endif /* DEBUG_rods */
  } else {
#ifdef VMS
    // Note to whoever puts the "lpr" into the prefs file. Please contact me
    // as I need to make the default be "print" instead of "lpr" for OpenVMS.
    strcpy(mPrData.command, "print");
#else
    strcpy(mPrData.command, "lpr ${MOZ_PRINTER_NAME:+'-P'}${MOZ_PRINTER_NAME}");
#endif /* VMS */
  }

  mPrData.top       = dtop;
  mPrData.bottom    = dbottom;
  mPrData.left      = dleft;
  mPrData.right     = dright;
  mPrData.fpf       = !reversed;
  mPrData.grayscale = !color;
  mPrData.size      = paper_size;
  mPrData.orientation = orientation;
  mPrData.toPrinter = !tofile;
  mPrData.copies = copies;

  // PWD, HOME, or fail 
  
  if (!printfile) {
    if ( ( path = PR_GetEnv( "PWD" ) ) == (char *) nsnull ) 
      if ( ( path = PR_GetEnv( "HOME" ) ) == (char *) nsnull )
        strcpy(mPrData.path, "mozilla.ps");
        
    if ( path != (char *) nsnull )
      sprintf(mPrData.path, "%s/mozilla.ps", path);
    else
      return NS_ERROR_FAILURE;
  }
  
#ifdef NOT_IMPLEMENTED_YET
  if (mGlobalNumPrinters) {
     for(int i = 0; (i < mGlobalNumPrinters) && !mQueue; i++) {
        if (!(mGlobalPrinterList->StringAt(i)->EqualsIgnoreCase(mPrData.printer)))
           mQueue = PrnDlg.SetPrinterQueue(i);
     }
  }
#endif /* NOT_IMPLEMENTED_YET */
  
  if (command != nsnull) {
    nsMemory::Free(command);
  }
  if (printfile != nsnull) {
    nsMemory::Free(printfile);
  }

  return rv;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 127 of file nsDeviceContextSpecB.h.

Definition at line 128 of file nsDeviceContextSpecB.h.


The documentation for this class was generated from the following files: