зеркало из https://github.com/mozilla/pjs.git
fixing non-cairo windows printing bustage
This commit is contained in:
Родитель
c655303b8f
Коммит
a95b367c42
|
@ -37,14 +37,13 @@
|
|||
|
||||
#include "nsDeviceContextWin.h"
|
||||
#include "nsRenderingContextWin.h"
|
||||
//#include "nsDeviceContextSpecWin.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIScreenManager.h"
|
||||
#include "nsIScreen.h"
|
||||
#include "nsGfxCIID.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#if defined(DEBUG_rods) && defined(MOZ_LAYOUTDEBUG)
|
||||
|
@ -696,7 +695,6 @@ BOOL CALLBACK abortproc( HDC hdc, int iError )
|
|||
NS_IMETHODIMP nsDeviceContextWin :: GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
|
||||
nsIDeviceContext *&aContext)
|
||||
{
|
||||
#if 0
|
||||
nsDeviceContextWin* devConWin = new nsDeviceContextWin(); //ref count 0
|
||||
if (devConWin != nsnull) {
|
||||
// this will ref count it
|
||||
|
@ -707,26 +705,14 @@ NS_IMETHODIMP nsDeviceContextWin :: GetDeviceContextFor(nsIDeviceContextSpec *aD
|
|||
}
|
||||
|
||||
devConWin->mSpec = aDevice;
|
||||
NS_ADDREF(aDevice);
|
||||
|
||||
char* devicename;
|
||||
char* drivername;
|
||||
|
||||
nsDeviceContextSpecWin* devSpecWin = NS_STATIC_CAST(nsDeviceContextSpecWin*, aDevice);
|
||||
devSpecWin->GetDeviceName(devicename); // sets pointer do not free
|
||||
devSpecWin->GetDriverName(drivername); // sets pointer do not free
|
||||
NS_ADDREF(aDevice);
|
||||
|
||||
HDC dc = NULL;
|
||||
LPDEVMODE devmode;
|
||||
devSpecWin->GetDevMode(devmode);
|
||||
NS_ASSERTION(devmode, "DevMode can't be NULL here");
|
||||
if (devmode) {
|
||||
dc = ::CreateDC(drivername, devicename, NULL, devmode);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupportsVoid> supVoid = do_QueryInterface(aDevice);
|
||||
supVoid->GetData((void**)&dc);
|
||||
|
||||
return devConWin->Init(dc, this); // take ownership of the DC
|
||||
#endif
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
#if defined(DEBUG_rods) || defined(DEBUG_dcone)
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include <winspool.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsIWidget.h"
|
||||
|
||||
#include "nsVoidArray.h"
|
||||
|
@ -182,8 +183,11 @@ nsDeviceContextSpecWin::nsDeviceContextSpecWin()
|
|||
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
#ifdef MOZ_CAIRO_GFX
|
||||
NS_IMPL_ISUPPORTS1(nsDeviceContextSpecWin, nsIDeviceContextSpec)
|
||||
|
||||
#else
|
||||
NS_IMPL_ISUPPORTS2(nsDeviceContextSpecWin, nsIDeviceContextSpec, nsISupportsVoid)
|
||||
#endif
|
||||
nsDeviceContextSpecWin::~nsDeviceContextSpecWin()
|
||||
{
|
||||
SetDeviceName(nsnull);
|
||||
|
@ -535,6 +539,23 @@ NS_IMETHODIMP nsDeviceContextSpecWin::GetSurfaceForPrinter(gfxASurface **surface
|
|||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// nsISupportsVoid impl stuff. goes away when we turn on cairo.
|
||||
NS_IMETHODIMP nsDeviceContextSpecWin::GetData(void **data)
|
||||
{
|
||||
NS_ASSERTION(mDevMode, "DevMode can't be NULL here");
|
||||
|
||||
if (mDevMode) {
|
||||
HDC dc = ::CreateDC(mDriverName, mDeviceName, NULL, mDevMode);
|
||||
*data = (void*)dc;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
|
@ -901,7 +922,7 @@ nsPrinterEnumeratorWin::InitPrintSettingsFromPrinter(const PRUnichar *aPrinterNa
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsDeviceContextSpecWin> devSpecWin = new nsDeviceContextSpecWin();
|
||||
nsRefPtr<nsDeviceContextSpecWin> devSpecWin = new nsDeviceContextSpecWin();
|
||||
if (!devSpecWin) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (NS_FAILED(GlobalPrinters::GetInstance()->EnumeratePrinterList())) {
|
||||
|
|
|
@ -43,9 +43,13 @@
|
|||
#include "nsIPrintOptions.h" // For nsIPrinterEnumerator
|
||||
#include "nsIPrintSettings.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include <windows.h>
|
||||
|
||||
class nsDeviceContextSpecWin : public nsIDeviceContextSpec
|
||||
#ifndef MOZ_CAIRO_GFX
|
||||
, public nsISupportsVoid
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
nsDeviceContextSpecWin();
|
||||
|
@ -54,6 +58,12 @@ public:
|
|||
|
||||
#ifdef MOZ_CAIRO_GFX
|
||||
NS_IMETHOD GetSurfaceForPrinter(gfxASurface **surface);
|
||||
#else
|
||||
// kill these when we move to CAIRO_GFX
|
||||
NS_IMETHOD GetType(PRUint16 *aType) { *aType = nsISupportsPrimitive::TYPE_VOID; return NS_OK; }
|
||||
NS_IMETHOD GetData(void * *aData);
|
||||
NS_IMETHOD SetData(void * aData) { return NS_ERROR_FAILURE; }
|
||||
NS_IMETHOD ToString(char **_retval) { return NS_ERROR_FAILURE; }
|
||||
#endif
|
||||
|
||||
NS_IMETHOD Init(nsIWidget* aWidget, nsIPrintSettings* aPS, PRBool aIsPrintPreview);
|
||||
|
|
Загрузка…
Ссылка в новой задаче