gfx/src/windows/nsDeviceContextWin.cpp - Revision 3.80

There were 10 changes made.
Legend
   Added lines
   Changed lines
   Removed lines

gfx/src/windows/nsDeviceContextWin.cpp,3.80
.
Disk File
Skipping to line 930. 
 
.
 
 
.
 
NS_IMETHODIMP nsDeviceContextWin :: GetDeviceContextFor(nsIDeviceContextSpec *
aDevice,
.
NS_IMETHODIMP nsDeviceContextWin :: GetDeviceContextFor(nsIDeviceContextSpec *
aDevice,
                                                        nsIDeviceContext *&aCo
ntext)
.
                                                        nsIDeviceContext *&aCo
ntext)
{
.
{
  char *devicename;
.
  nsDeviceContextWin* devConWin = new nsDeviceContextWin(); //ref count 0 
  char *drivername;
.
  if (devConWin != nsnull) {
  HGLOBAL hdevmode;
.
    // this will ref count it
  DEVMODE *devmode;
 
.
    nsresult rv = devConWin->QueryInterface(NS_GET_IID(nsIDeviceContext), (voi
d**)&aContext);
 
.
    NS_ASSERTION(NS_SUCCEEDED(rv), "This has to support nsIDeviceContext");
  //XXX this API should take an CID, use the repository and
.
 
  //then QI for the real object rather than casting... MMP
.
 
 
.
 
  aContext = new nsDeviceContextWin();
.
 
  if(nsnull != aContext){
.
 
    NS_ADDREF(aContext);
.
 
  } else {
.
  } else {
    return NS_ERROR_OUT_OF_MEMORY;
.
    return NS_ERROR_OUT_OF_MEMORY;
  }
.
  }
 
.
 
  ((nsDeviceContextWin *)aContext)->mSpec = aDevice;
.
  devConWin->mSpec = aDevice;
  NS_ADDREF(aDevice);
.
  NS_ADDREF(aDevice);
 
.
 
  ((nsDeviceContextSpecWin *)aDevice)->GetDeviceName(devicename);
.
  char*   devicename;
  ((nsDeviceContextSpecWin *)aDevice)->GetDriverName(drivername);
.
  char*   drivername;
  ((nsDeviceContextSpecWin *)aDevice)->GetDEVMODE(hdevmode);
.
 
 
.
 
  devmode = (DEVMODE *)::GlobalLock(hdevmode);
 
.
  nsDeviceContextSpecWin* devSpecWin = NS_STATIC_CAST(nsDeviceContextSpecWin*,
 aDevice);
  HDC dc = ::CreateDC(drivername, devicename, NULL, devmode);
.
  devSpecWin->GetDeviceName(devicename); // sets pointer do not free
 
.
  devSpecWin->GetDriverName(drivername); // sets pointer do not free
//  ::SetAbortProc(dc, (ABORTPROC)abortproc);
.
 
 
.
  HDC dc = NULL;
  ::GlobalUnlock(hdevmode);
.
  if (devSpecWin->IsDEVMODEGlobalHandle()) {
 
.
    HGLOBAL hGlobal;
 
.
    devSpecWin->GetGlobalDevMode(hGlobal);
 
.
    LPDEVMODE devmode = (DEVMODE *)::GlobalLock(hGlobal);
 
.
    dc = ::CreateDC(drivername, devicename, NULL, devmode);
 
.
    ::GlobalUnlock(hGlobal);
 
.
  } else {
 
.
    LPDEVMODE devmode;
 
.
    devSpecWin->GetDevMode(devmode);
 
.
    dc = ::CreateDC(drivername, devicename, NULL, devmode);
 
.
  }
 
.
 
  return ((nsDeviceContextWin *)aContext)->Init(dc, this);
.
  return devConWin->Init(dc, this); // take ownership of the DC
}
.
}
 
.
 
NS_IMETHODIMP nsDeviceContextWin :: BeginDocument(PRUnichar * aTitle)
.
NS_IMETHODIMP nsDeviceContextWin :: BeginDocument(PRUnichar * aTitle)
{
.
{
  nsresult rv = NS_OK;
.
  nsresult rv = NS_OK;
Skipping to line 976. 
 
.
 
    nsString titleStr;
.
    nsString titleStr;
    titleStr = aTitle;
.
    titleStr = aTitle;
    char *title = GetACPString(titleStr);
.
    char *title = GetACPString(titleStr);
 
.
 
 
.
    char* docName = nsnull;
 
.
    nsresult  rv = NS_ERROR_FAILURE;
 
 
.
    nsCOMPtr<nsIPrintOptions> printService = do_GetService(kPrintOptionsCID, &
rv);
 
.
    if (printService) {
 
.
      PRUnichar* uStr;
 
.
      printService->GetToFileName(&uStr);
 
.
      if (uStr != nsnull) {
 
.
        nsAutoString str(uStr);
 
.
        if (str.Length() > 0) {
 
.
          docName = ToNewCString(str);
 
.
        }
 
.
        nsMemory::Free(uStr);
 
.
      }
 
.
    }
    docinfo.cbSize = sizeof(docinfo);
.
    docinfo.cbSize = sizeof(docinfo);
    docinfo.lpszDocName = title != nsnull?title:"Mozilla Document";
.
    docinfo.lpszDocName = title != nsnull?title:"Mozilla Document";
 
.
 
#ifdef DEBUG_rods
.
#ifdef DEBUG_rods
    docinfo.lpszOutput = "p.ps";
.
    docinfo.lpszOutput = "p.ps";
#else
.
#else
    docinfo.lpszOutput = NULL;
.
    docinfo.lpszOutput = docName;
#endif
.
#endif
 
.
 
    docinfo.lpszDatatype = NULL;
.
    docinfo.lpszDatatype = NULL;
    docinfo.fwType = 0;
.
    docinfo.fwType = 0;
 
.
 
    if (::StartDoc(mDC, &docinfo) > 0)
.
    if (::StartDoc(mDC, &docinfo) > 0)
      rv = NS_OK;
.
      rv = NS_OK;
Skipping to line 1010. 
      rv = NS_ERROR_FAILURE;
.
      rv = NS_ERROR_FAILURE;
 
.
 
    if (title != nsnull) {
.
    if (title != nsnull) delete [] title;
      delete [] title;
.
    if (docName != nsnull) nsMemory::Free(docName);
    }
.
 
  }
.
  }
 
.
 
  return rv;
.
  return rv;
}
.
}
 
.