Back to index

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

#include <nsDeviceContextPS.h>

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

List of all members.

Public Member Functions

 nsDeviceContextPS ()
 
See documentation in nsIDeviceContext.h 12/21/98 dwc
NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD 
InitDeviceContextPS (nsIDeviceContext *aCreatingDeviceContext, nsIDeviceContext *aPrinterContext)
 This method does nothing since a postscript devicecontext will never be created with a NativeWidget.
NS_IMETHOD CreateRenderingContext (nsIRenderingContext *&aContext)
 
Create a Postscript RenderingContext.
NS_IMETHOD CreateRenderingContext (nsIView *aView, nsIRenderingContext *&aContext)
NS_IMETHOD CreateRenderingContext (nsIWidget *aWidget, nsIRenderingContext *&aContext)
NS_IMETHOD CreateRenderingContext (nsIDrawingSurface *aSurface, nsIRenderingContext *&aContext)
NS_IMETHOD CreateRenderingContextInstance (nsIRenderingContext *&aContext)
NS_IMETHOD SupportsNativeWidgets (PRBool &aSupportsWidgets)
 
See documentation in nsIDeviceContext.h 12/21/98 dwc
NS_IMETHOD GetScrollBarDimensions (float &aWidth, float &aHeight) const
 
See documentation in nsIDeviceContext.h 12/21/98 dwc
NS_IMETHOD CheckFontExistence (const nsString &aFontName)
 
See documentation in nsIDeviceContext.h 12/21/98 dwc
NS_IMETHOD GetDepth (PRUint32 &aDepth)
 
See documentation in nsIDeviceContext.h 12/21/98 dwc
NS_IMETHOD GetDeviceSurfaceDimensions (PRInt32 &aWidth, PRInt32 &aHeight)
 
See documentation in nsIDeviceContext.h 12/21/98 dwc
NS_IMETHOD GetClientRect (nsRect &aRect)
 
See documentation in nsIDeviceContext.h
NS_IMETHOD GetRect (nsRect &aRect)
 
See documentation in nsIDeviceContext.h
NS_IMETHOD GetDeviceContextFor (nsIDeviceContextSpec *aDevice, nsIDeviceContext *&aContext)
 
See documentation in nsIDeviceContext.h 12/21/98 dwc
NS_IMETHOD GetSystemFont (nsSystemFontID anID, nsFont *aFont) const
NS_IMETHOD BeginDocument (PRUnichar *aTitle, PRUnichar *aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage)
 
See documentation in nsIDeviceContext.h 12/21/98 dwc
NS_IMETHOD EndDocument (void)
 
See documentation in nsIDeviceContext.h 12/12/02 louie
NS_IMETHOD AbortDocument (void)
 
See documentation in nsIDeviceContext.h
NS_IMETHOD BeginPage (void)
 
See documentation in nsIDeviceContext.h 12/21/98 dwc
NS_IMETHOD EndPage (void)
 
See documentation in nsIDeviceContext.h 12/21/98 dwc
NS_IMETHOD CreateFontCache ()
NS_IMETHOD SetSpec (nsIDeviceContextSpec *aSpec)
nsPostScriptObj * GetPrintContext ()
nsHashtable * GetPSFontGeneratorList ()
 NS_DEFINE_STATIC_IID_ACCESSOR (NS_IDEVICECONTEXTPS_IID)

Public Attributes

PRBool mFTPEnable

Protected Member Functions

virtual ~nsDeviceContextPS ()
 
See documentation in nsIDeviceContext.h 12/21/98 dwc

Protected Attributes

nsIDrawingSurfacemSurface
PRUint32 mDepth
nsCOMPtr< nsIDeviceContextSpecmSpec
nsCOMPtr< nsIDeviceContextmParentDeviceContext
nsIPrintJobPSmPrintJob
nsPostScriptObj * mPSObj
nsHashtable * mPSFontGeneratorList

Detailed Description

Definition at line 56 of file nsDeviceContextPS.h.


Constructor & Destructor Documentation


See documentation in nsIDeviceContext.h 12/21/98 dwc

Definition at line 95 of file nsDeviceContextPS.cpp.

  : DeviceContextImpl(),
  mSpec(nsnull),
  mParentDeviceContext(nsnull),
  mPrintJob(nsnull),
  mPSObj(nsnull),
  mPSFontGeneratorList(nsnull)
{ 
  PR_LOG(nsDeviceContextPSLM, PR_LOG_DEBUG, ("nsDeviceContextPS::nsDeviceContextPS()\n"));

#ifdef WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS
  instance_counter++;
  NS_ASSERTION(instance_counter < 2, "Cannot have more than one print device context.");
#endif /* WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS */
}
nsDeviceContextPS::~nsDeviceContextPS ( ) [protected, virtual]


See documentation in nsIDeviceContext.h 12/21/98 dwc

Definition at line 115 of file nsDeviceContextPS.cpp.

{
  PR_LOG(nsDeviceContextPSLM, PR_LOG_DEBUG, ("nsDeviceContextPS::~nsDeviceContextPS()\n"));

  delete mPSObj;
  delete mPrintJob;
  mParentDeviceContext = nsnull;

#ifdef WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS
  instance_counter--;
  NS_ASSERTION(instance_counter >= 0, "We cannot have less than zero instances.");
#endif /* WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS */

  if (mPSFontGeneratorList) {
    mPSFontGeneratorList->Reset(FreePSFontGeneratorList, nsnull);
    delete mPSFontGeneratorList;
    mPSFontGeneratorList = nsnull;
  }
  NS_IF_RELEASE(gUsersLocale);
}

Here is the call graph for this function:


Member Function Documentation


See documentation in nsIDeviceContext.h

Definition at line 505 of file nsDeviceContextPS.cpp.

{
  PR_LOG(nsDeviceContextPSLM, PR_LOG_DEBUG, ("nsDeviceContextPS::AbortDocument()\n"));

  NS_ENSURE_TRUE(mPSObj != nsnull, NS_ERROR_NULL_POINTER);
  
  delete mPrintJob;
  mPrintJob = nsnull;
  return NS_OK;
}
NS_IMETHODIMP nsDeviceContextPS::BeginDocument ( PRUnichar aTitle,
PRUnichar aPrintToFileName,
PRInt32  aStartPage,
PRInt32  aEndPage 
)


See documentation in nsIDeviceContext.h 12/21/98 dwc

Definition at line 426 of file nsDeviceContextPS.cpp.

{
  PR_LOG(nsDeviceContextPSLM, PR_LOG_DEBUG, ("nsDeviceContextPS::BeginDocument()\n"));

  NS_ENSURE_TRUE(mPSObj != nsnull, NS_ERROR_NULL_POINTER);
  NS_ENSURE_TRUE(mPrintJob != nsnull, NS_ERROR_NULL_POINTER);

  mPSObj->settitle(aTitle); 
  mPrintJob->SetJobTitle(aTitle);
  return NS_OK;
}

Here is the call graph for this function:


See documentation in nsIDeviceContext.h 12/21/98 dwc

Definition at line 520 of file nsDeviceContextPS.cpp.

{
  PR_LOG(nsDeviceContextPSLM, PR_LOG_DEBUG, ("nsDeviceContextPS::BeginPage()\n"));

  NS_ENSURE_TRUE(mPSObj != nsnull, NS_ERROR_NULL_POINTER);

  // begin the page
  mPSObj->begin_page(); 
  return NS_OK;
}


See documentation in nsIDeviceContext.h 12/21/98 dwc

Definition at line 347 of file nsDeviceContextPS.cpp.

{
  PR_LOG(nsDeviceContextPSLM, PR_LOG_DEBUG, ("nsDeviceContextPS::CheckFontExistence()\n"));

  // XXX this needs to find out if this font is supported for postscript
  return NS_OK;
}

Definition at line 566 of file nsDeviceContextPS.cpp.

{
  PR_LOG(nsDeviceContextPSLM, PR_LOG_DEBUG, ("nsDeviceContextPS::CreateFontCache()\n"));

  mFontCache = new nsFontCachePS();
  if (!mFontCache) {
    return NS_ERROR_OUT_OF_MEMORY;
  }
  
  return mFontCache->Init(this);
}


Create a Postscript RenderingContext.

This will create a RenderingContext from the deligate RenderingContext and intall that into our Postscript RenderingContext. 12/21/98 dwc

Parameters:
aContext-- our newly created Postscript RenderingContextPS
Returns:
-- NS_OK if everything succeeded.

Definition at line 268 of file nsDeviceContextPS.cpp.

{
  PR_LOG(nsDeviceContextPSLM, PR_LOG_DEBUG, ("nsDeviceContextPS::CreateRenderingContext()\n"));

  nsresult rv;
   
  aContext = nsnull;

  NS_ENSURE_TRUE(mPSObj != nsnull, NS_ERROR_NULL_POINTER);

  nsCOMPtr<nsRenderingContextPS> renderingContext = new nsRenderingContextPS();
  if (!renderingContext)
    return NS_ERROR_OUT_OF_MEMORY;
     
  rv = renderingContext->Init(this);

  if (NS_SUCCEEDED(rv)) {
    aContext = renderingContext;
    NS_ADDREF(aContext);
  }

  return rv;
}

Here is the call graph for this function:

Definition at line 72 of file nsDeviceContextPS.h.

{return (DeviceContextImpl::CreateRenderingContext(aView,aContext));}

Definition at line 73 of file nsDeviceContextPS.h.

{return (DeviceContextImpl::CreateRenderingContext(aWidget,aContext));}

Definition at line 75 of file nsDeviceContextPS.h.

Definition at line 292 of file nsDeviceContextPS.cpp.

{
  nsCOMPtr<nsIRenderingContext> renderingContext = new nsRenderingContextPS();
  if (!renderingContext)
    return NS_ERROR_OUT_OF_MEMORY;
         
  aContext = renderingContext;
  NS_ADDREF(aContext);
  
  return NS_OK;
}

Here is the call graph for this function:


See documentation in nsIDeviceContext.h 12/12/02 louie

Definition at line 453 of file nsDeviceContextPS.cpp.

{
  PR_LOG(nsDeviceContextPSLM, PR_LOG_DEBUG, ("nsDeviceContextPS::EndDocument()\n"));

  NS_ENSURE_TRUE(mPSObj != nsnull, NS_ERROR_NULL_POINTER);

  // Finish the document and print it...
  nsresult rv = mPSObj->end_document();
  if (NS_SUCCEEDED(rv)) {
    FILE *submitFP;
    rv = mPrintJob->StartSubmission(&submitFP);
    if (NS_ERROR_GFX_PRINTING_NOT_IMPLEMENTED == rv) {
      // This was probably a print-preview operation
      rv = NS_OK;
    }
    else if (NS_SUCCEEDED(rv)) {
      NS_ASSERTION(submitFP, "No print job submission handle");

      // Start writing the print job to the job handler
#if defined(MOZ_ENABLE_FREETYPE2) || defined(MOZ_ENABLE_XFT)
      mPSObj->write_prolog(submitFP, mFTPEnable);
#else 
      mPSObj->write_prolog(submitFP);
#endif

      /* Core of TrueType printing:
       *   enumerate items("nsPSFontGenerator") in hashtable
       *   to generate Type1 fonts and output to Postscript file
       */
      if (mPSFontGeneratorList)
        mPSFontGeneratorList->Enumerate(GeneratePSFontCallback,
            (void *) submitFP);

      rv = mPSObj->write_script(submitFP);
      if (NS_SUCCEEDED(rv))
        rv = mPrintJob->FinishSubmission();
    }
  }

  delete mPrintJob;
  mPrintJob = nsnull;

  PR_LOG(nsDeviceContextPSLM, PR_LOG_DEBUG,
      ("nsDeviceContextPS::EndDocument() return value %d\n", rv));

  return rv;
}

Here is the call graph for this function:


See documentation in nsIDeviceContext.h 12/21/98 dwc

Definition at line 535 of file nsDeviceContextPS.cpp.

{
  PR_LOG(nsDeviceContextPSLM, PR_LOG_DEBUG, ("nsDeviceContextPS::EndPage()\n"));

  NS_ENSURE_TRUE(mPSObj != nsnull, NS_ERROR_NULL_POINTER);

  // end the page
  mPSObj->end_page();
  return NS_OK;
}


See documentation in nsIDeviceContext.h

Definition at line 404 of file nsDeviceContextPS.cpp.

{
  PR_LOG(nsDeviceContextPSLM, PR_LOG_DEBUG, ("nsDeviceContextPS::GetClientRect()\n"));

  return GetRect(aRect);
}

Here is the call graph for this function:


See documentation in nsIDeviceContext.h 12/21/98 dwc

Definition at line 336 of file nsDeviceContextPS.cpp.

{
  PR_LOG(nsDeviceContextPSLM, PR_LOG_DEBUG, ("nsDeviceContextPS::GetDepth(mDepth=%d)\n", mDepth));

  return mDepth;
}


See documentation in nsIDeviceContext.h 12/21/98 dwc

Definition at line 415 of file nsDeviceContextPS.cpp.

{
  PR_LOG(nsDeviceContextPSLM, PR_LOG_DEBUG, ("nsDeviceContextPS::GetDeviceContextFor()\n"));
  aContext = nsnull;
  return NS_OK;
}


See documentation in nsIDeviceContext.h 12/21/98 dwc

Definition at line 369 of file nsDeviceContextPS.cpp.

{
  PR_LOG(nsDeviceContextPSLM, PR_LOG_DEBUG, ("nsDeviceContextPS::GetDeviceSurfaceDimensions()\n"));

  NS_ENSURE_TRUE(mPSObj && mPSObj->mPrintSetup, NS_ERROR_NULL_POINTER);

  // Height and width are already in twips
  aWidth  = mPSObj->mPrintSetup->width;
  aHeight = mPSObj->mPrintSetup->height;

  return NS_OK;
}

Here is the caller graph for this function:

nsPostScriptObj* nsDeviceContextPS::GetPrintContext ( ) [inline]

Definition at line 100 of file nsDeviceContextPS.h.

{ return mPSObj; }
nsHashtable* nsDeviceContextPS::GetPSFontGeneratorList ( ) [inline]

Definition at line 101 of file nsDeviceContextPS.h.


See documentation in nsIDeviceContext.h

Definition at line 385 of file nsDeviceContextPS.cpp.

{
  PR_LOG(nsDeviceContextPSLM, PR_LOG_DEBUG, ("nsDeviceContextPS::GetRect()\n"));

  NS_ENSURE_TRUE(mPSObj != nsnull, NS_ERROR_NULL_POINTER);

  PRInt32 width, height;
  nsresult rv;
  rv = GetDeviceSurfaceDimensions(width, height);
  aRect.x = 0;
  aRect.y = 0;
  aRect.width = width;
  aRect.height = height;
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsDeviceContextPS::GetScrollBarDimensions ( float &  aWidth,
float &  aHeight 
) const


See documentation in nsIDeviceContext.h 12/21/98 dwc

Definition at line 320 of file nsDeviceContextPS.cpp.

{
  PR_LOG(nsDeviceContextPSLM, PR_LOG_DEBUG, ("nsDeviceContextPS::GetScrollBarDimensions()\n"));

  //XXX: Hardcoded values for Postscript
  float scale;
  GetCanonicalPixelScale(scale);
  aWidth  = 20.f * scale;
  aHeight = 20.f * scale;
  return NS_OK;
}

Definition at line 355 of file nsDeviceContextPS.cpp.

{
  PR_LOG(nsDeviceContextPSLM, PR_LOG_DEBUG, ("nsDeviceContextPS::GetSystemFont()\n"));

  if (mParentDeviceContext != nsnull) {
    return mParentDeviceContext->GetSystemFont(aID, aFont);
  }
  return NS_ERROR_FAILURE;
}

This method does nothing since a postscript devicecontext will never be created with a NativeWidget.

12/21/98 dwc

Implements nsIDeviceContextPS.

Implements nsIDeviceContextPS.

Definition at line 137 of file nsDeviceContextPS.cpp.

{
  PR_LOG(nsDeviceContextPSLM, PR_LOG_DEBUG, ("nsDeviceContextPS::SetSpec()\n"));
  NS_PRECONDITION(!mPSObj, "Already have a postscript object");
  NS_PRECONDITION(!mPrintJob, "Already have a printjob object");

#ifdef WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS
  NS_ASSERTION(instance_counter < 2, "Cannot have more than one print device context.");
  if (instance_counter > 1) {
    return NS_ERROR_GFX_PRINTER_PRINT_WHILE_PREVIEW;
  }
#endif /* WE_DO_NOT_SUPPORT_MULTIPLE_PRINT_DEVICECONTEXTS */

  mSpec = aSpec;

  mPSObj = new nsPostScriptObj();
  if (!mPSObj)
    return  NS_ERROR_OUT_OF_MEMORY; 

  nsresult rv;
  nsCOMPtr<nsIDeviceContextSpecPS> psSpec = do_QueryInterface(mSpec, &rv);
  if (NS_SUCCEEDED(rv)) {
    rv = mPSObj->Init(psSpec);
    if (NS_SUCCEEDED(rv))
      rv = nsPrintJobFactoryPS::CreatePrintJob(psSpec, mPrintJob);
  }
  if (NS_FAILED(rv)) {
    delete mPSObj;
    mPSObj = nsnull;
  }
  else {
    // Successfully allocated both PS and print job objects.
    // Determine which one will handle number-of-copies.
    int num_copies;
    psSpec->GetCopies(num_copies);
    if (NS_FAILED(mPrintJob->SetNumCopies(num_copies)))
      mPSObj->SetNumCopies(num_copies);
  }

  return rv;
}

Here is the call graph for this function:


See documentation in nsIDeviceContext.h 12/21/98 dwc

Definition at line 308 of file nsDeviceContextPS.cpp.

{
  PR_LOG(nsDeviceContextPSLM, PR_LOG_DEBUG, ("nsDeviceContextPS::SupportsNativeWidgets()\n"));

  aSupportsWidgets = PR_FALSE;
  return NS_OK;
}

Member Data Documentation

Definition at line 108 of file nsDeviceContextPS.h.

Definition at line 102 of file nsDeviceContextPS.h.

Definition at line 110 of file nsDeviceContextPS.h.

Definition at line 111 of file nsDeviceContextPS.h.

nsHashtable* nsDeviceContextPS::mPSFontGeneratorList [protected]

Definition at line 113 of file nsDeviceContextPS.h.

nsPostScriptObj* nsDeviceContextPS::mPSObj [protected]

Definition at line 112 of file nsDeviceContextPS.h.

Definition at line 109 of file nsDeviceContextPS.h.

Definition at line 107 of file nsDeviceContextPS.h.


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