moving printing from gfx to widget part 1. bug 326149. r=vlad

This commit is contained in:
pavlov%pavlov.net 2006-02-10 20:40:54 +00:00
Родитель 409b045aa5
Коммит b356085867
45 изменённых файлов: 136 добавлений и 181 удалений

Просмотреть файл

@ -50,10 +50,6 @@ XPIDLSRCS = \
nsIFontEnumerator.idl \
nsIFontList.idl \
nsIScriptableRegion.idl \
nsIPrintOptions.idl \
nsIPrintSettings.idl \
nsIPrintSettingsService.idl \
nsIPrintSession.idl \
gfxIFormats.idl \
gfxIImageFrame.idl \
gfxtypes.idl \
@ -66,19 +62,9 @@ XPIDLSRCS += \
$(NULL)
endif
ifneq (,$(filter mac cocoa,$(MOZ_GFX_TOOLKIT)))
XPIDLSRCS += nsIPrintSettingsX.idl \
nsIPrintSessionX.idl \
$(NULL)
endif
ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
XPIDLSRCS += nsIQDFlushManager.idl
endif
ifeq ($(MOZ_GFX_TOOLKIT),windows)
XPIDLSRCS += nsIPrintSettingsWin.idl
endif
include $(topsrcdir)/config/rules.mk

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -65,8 +65,6 @@ EXPORTS = \
nsGfxCIID.h \
nsIRegion.h \
nsDeviceContext.h \
nsIDeviceContextSpec.h \
nsIDeviceContextSpecFactory.h \
nsIDrawingSurface.h \
nsITheme.h \
nsThemeConstants.h \

Просмотреть файл

@ -78,34 +78,10 @@
{ 0x6049b264, 0xc1e6, 0x11d1, \
{ 0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
#define NS_DEVICE_CONTEXT_SPEC_CID \
{ 0xd7193600, 0x78e0, 0x11d2, \
{ 0xa8, 0x46, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
#define NS_DEVICE_CONTEXT_SPEC_FACTORY_CID \
{ 0xec5bebb0, 0x7b51, 0x11d2, \
{ 0xa8, 0x48, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
#define NS_DRAWING_SURFACE_CID \
{ 0x199c7040, 0xcab0, 0x11d2, \
{ 0xa8, 0x49, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
#define NS_PRINTSETTINGSSERVICE_CID \
{ 0x841387c8, 0x72e6, 0x484b, \
{ 0x92, 0x96, 0xbf, 0x6e, 0xea, 0x80, 0xd5, 0x8a } }
// NOTE: This now has the same CID as NS_PRINTSETTINGSSERVICE_CID
// will go away when Bug 144114 is fixed
#define NS_PRINTOPTIONS_CID NS_PRINTSETTINGSSERVICE_CID
#define NS_PRINTER_ENUMERATOR_CID \
{ 0xa6cf9129, 0x15b3, 0x11d2, \
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
#define NS_PRINTSESSION_CID \
{ 0x2f977d53, 0x5485, 0x11d4, \
{ 0x87, 0xe2, 0x00, 0x10, 0xa4, 0xe7, 0x5e, 0xf2 } }
#define NS_FONTCATALOGSERVICE_CID \
{ 0xa3057187, 0xc40f, 0x4ffa, \
{ 0x91, 0x60, 0x2b, 0x16, 0x48, 0x20, 0x53, 0xb1 } }

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -122,9 +122,6 @@ CPPSRCS = \
nsRegion.cpp \
nsTransform2D.cpp \
nsScriptableRegion.cpp \
nsPrintOptionsImpl.cpp \
nsPrintSettingsImpl.cpp \
nsPrintSession.cpp \
$(NULL)
ifeq (,$(filter windows,$(MOZ_WIDGET_TOOLKIT)))

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -76,18 +76,10 @@ CPPSRCS = \
nsFontMetricsWin.cpp \
nsImageWin.cpp \
nsRegionWin.cpp \
nsDeviceContextSpecWin.cpp \
nsDeviceContextSpecFactoryW.cpp \
nsGfxFactoryWin.cpp \
nsUnicodeRange.cpp \
$(NULL)
ifneq ($(OS_ARCH), WINCE)
CPPSRCS += nsPrintOptionsWin.cpp \
nsPrintSettingsWin.cpp \
$(NULL)
endif
EXPORTS = nsIRenderingContextWin.h nsIDrawingSurfaceWin.h
EXTRA_DSO_LIBS = gkgfx mozutil_s gfxshared_s
@ -99,7 +91,7 @@ LOCAL_INCLUDES = \
$(NULL)
ifndef WINCE
_OS_LIBS = winspool comdlg32
_OS_LIBS = comdlg32
endif
ifdef GNU_CC
_OS_LIBS += gdi32

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -45,13 +45,9 @@
#include "nsDeviceContextWin.h"
#include "nsRegionWin.h"
#include "nsBlender.h"
#include "nsDeviceContextSpecWin.h"
#include "nsDeviceContextSpecFactoryW.h"
#include "nsScriptableRegion.h"
#include "nsPrintOptionsWin.h"
#include "nsFontList.h"
#include "nsIGenericFactory.h"
#include "nsPrintSession.h"
#include "gfxImageFrame.h"
@ -69,12 +65,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontEnumeratorWin)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontList)
NS_GENERIC_FACTORY_CONSTRUCTOR(gfxImageFrame)
#ifndef WINCE
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsWin, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorWin)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
#endif
PRBool
UseAFunctions()
{
@ -216,25 +206,6 @@ static const nsModuleComponentInfo components[] =
GFX_IMAGEFRAME_CID,
"@mozilla.org/gfx/image/frame;2",
gfxImageFrameConstructor, },
#ifndef WINCE
{ "nsPrintOptionsWin",
NS_PRINTSETTINGSSERVICE_CID,
"@mozilla.org/gfx/printsettings-service;1",
nsPrintOptionsWinConstructor },
{ "Win Printer Enumerator",
NS_PRINTER_ENUMERATOR_CID,
// "@mozilla.org/gfx/printer_enumerator/win;1",
"@mozilla.org/gfx/printerenumerator;1",
nsPrinterEnumeratorWinConstructor },
{ "Print Session",
NS_PRINTSESSION_CID,
"@mozilla.org/gfx/printsession;1",
nsPrintSessionConstructor }
#endif
};
NS_IMPL_NSGETMODULE(nsGfxModule, components)

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -68,6 +68,8 @@ EXPORTS = \
nsIDragSessionBeOS.h \
nsIPluginWidget.h \
nsINativeKeyBindings.h \
nsIDeviceContextSpec.h \
nsIDeviceContextSpecFactory.h \
$(NULL)
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
@ -96,10 +98,20 @@ XPIDLSRCS = \
nsINativeScrollbar.idl \
nsIScreen.idl \
nsIScreenManager.idl \
nsIPrintSession.idl \
nsIPrintSettings.idl \
nsIPrintSettingsService.idl \
nsIPrintOptions.idl \
$(NULL)
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
XPIDLSRCS += nsIPrintSettingsWin.idl
endif
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
XPIDLSRCS += nsIEventSink.idl
XPIDLSRCS += nsIEventSink.idl \
nsIPrintSettingsX.idl \
nsIPrintSessionX.idl
endif
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))

Просмотреть файл

@ -40,14 +40,22 @@
#include "nsIDeviceContext.h"
#ifdef MOZ_CAIRO_GFX
class gfxASurface;
#endif
#define NS_IDEVICE_CONTEXT_SPEC_IID \
{ 0x9951f910, 0x78d7, 0x11d2, \
{ 0xa8, 0x46, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
{ 0x001eeff2, 0x72f3, 0x4d65, \
{ 0xb0, 0x92, 0x35, 0x88, 0xb0, 0x1e, 0x48, 0xd2 } }
class nsIDeviceContextSpec : public nsISupports
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDEVICE_CONTEXT_SPEC_IID)
#ifdef MOZ_CAIRO_GFX
NS_IMETHOD GetSurfaceForPrinter(gfxASurface **nativeSurface) = 0;
#endif
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDeviceContextSpec,

Просмотреть файл

@ -144,3 +144,31 @@
#define NS_SCREENMANAGER_CID \
{ 0xc401eb80, 0xf9ea, 0x11d3, { 0xbb, 0x6f, 0xe7, 0x32, 0xb7, 0x3e, 0xbe, 0x7c } }
//-----------------------------------------------------------
//Printing
//-----------------------------------------------------------
#define NS_DEVICE_CONTEXT_SPEC_CID \
{ 0xd7193600, 0x78e0, 0x11d2, \
{ 0xa8, 0x46, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
#define NS_DEVICE_CONTEXT_SPEC_FACTORY_CID \
{ 0xec5bebb0, 0x7b51, 0x11d2, \
{ 0xa8, 0x48, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
#define NS_PRINTSETTINGSSERVICE_CID \
{ 0x841387c8, 0x72e6, 0x484b, \
{ 0x92, 0x96, 0xbf, 0x6e, 0xea, 0x80, 0xd5, 0x8a } }
// NOTE: This now has the same CID as NS_PRINTSETTINGSSERVICE_CID
// will go away when Bug 144114 is fixed
#define NS_PRINTOPTIONS_CID NS_PRINTSETTINGSSERVICE_CID
#define NS_PRINTER_ENUMERATOR_CID \
{ 0xa6cf9129, 0x15b3, 0x11d2, \
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
#define NS_PRINTSESSION_CID \
{ 0x2f977d53, 0x5485, 0x11d4, \
{ 0x87, 0xe2, 0x00, 0x10, 0xa4, 0xe7, 0x5e, 0xf2 } }

Просмотреть файл

@ -76,10 +76,10 @@ LOCAL_INCLUDES = \
-I$(srcdir)/../windows \
$(NULL)
OS_LIBS += $(call EXPAND_LIBNAME, uuid ole32 oleaut32 )
OS_LIBS += $(call EXPAND_LIBNAME, uuid ole32 oleaut32 Winspool)
ifneq ($(OS_ARCH), WINCE)
OS_LIBS += $(call EXPAND_LIBNAME, comctl32 comdlg32 shell32 gdi32 imm32 )
OS_LIBS += $(call EXPAND_LIBNAME, comctl32 comdlg32 shell32 gdi32 imm32 Winspool )
endif
SHARED_LIBRARY_LIBS = \

Просмотреть файл

@ -62,6 +62,12 @@
#include "nsScreenManagerWin.h"
#include "nsIGenericFactory.h"
// printing
#include "nsDeviceContextSpecWin.h"
#include "nsDeviceContextSpecFactoryW.h"
#include "nsPrintOptionsWin.h"
#include "nsPrintSession.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow)
NS_GENERIC_FACTORY_CONSTRUCTOR(ChildWindow)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard)
@ -83,6 +89,13 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerWin)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsWin, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorWin)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecWin)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecFactoryWin)
static const nsModuleComponentInfo components[] =
{
{ "nsWindow",
@ -152,6 +165,26 @@ static const nsModuleComponentInfo components[] =
NS_SCREENMANAGER_CID,
"@mozilla.org/gfx/screenmanager;1",
nsScreenManagerWinConstructor },
{ "nsPrintOptionsWin",
NS_PRINTSETTINGSSERVICE_CID,
"@mozilla.org/gfx/printsettings-service;1",
nsPrintOptionsWinConstructor },
{ "Win Printer Enumerator",
NS_PRINTER_ENUMERATOR_CID,
"@mozilla.org/gfx/printerenumerator;1",
nsPrinterEnumeratorWinConstructor },
{ "Print Session",
NS_PRINTSESSION_CID,
"@mozilla.org/gfx/printsession;1",
nsPrintSessionConstructor },
{ "nsDeviceContextSpecWin",
NS_DEVICE_CONTEXT_SPEC_CID,
"@mozilla.org/gfx/devicecontextspec;1",
nsDeviceContextSpecWinConstructor },
{ "nsDeviceContextSpecFactoryWin",
NS_DEVICE_CONTEXT_SPEC_FACTORY_CID,
"@mozilla.org/gfx/devicecontextspecfactory;1",
nsDeviceContextSpecFactoryWinConstructor },
};

Просмотреть файл

@ -86,6 +86,10 @@ CPPSRCS = \
nsFilePicker.cpp \
nsScreenWin.cpp \
nsScreenManagerWin.cpp \
nsPrintOptionsWin.cpp \
nsPrintSettingsWin.cpp \
nsDeviceContextSpecWin.cpp \
nsDeviceContextSpecFactoryW.cpp \
$(NULL)
ifneq ($(OS_ARCH), WINCE)

Просмотреть файл

@ -1,86 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsDeviceContextSpecFactoryW.h"
#include "nsDeviceContextSpecWin.h"
#include "nsGfxCIID.h"
nsDeviceContextSpecFactoryWin :: nsDeviceContextSpecFactoryWin()
{
}
nsDeviceContextSpecFactoryWin :: ~nsDeviceContextSpecFactoryWin()
{
}
static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID);
static NS_DEFINE_IID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
NS_IMPL_ISUPPORTS1(nsDeviceContextSpecFactoryWin, nsIDeviceContextSpecFactory)
NS_IMETHODIMP nsDeviceContextSpecFactoryWin :: Init(void)
{
return NS_OK;
}
//XXX this method needs to do what the API says...
NS_IMETHODIMP nsDeviceContextSpecFactoryWin :: CreateDeviceContextSpec(nsIWidget *aWidget,
nsIPrintSettings* aPrintSettings,
nsIDeviceContextSpec *&aNewSpec,
PRBool aIsPrintPreview)
{
NS_ENSURE_ARG_POINTER(aWidget);
nsresult rv = NS_ERROR_FAILURE;
nsIDeviceContextSpec* devspec = nsnull;
CallCreateInstance(kDeviceContextSpecCID, &devspec);
if (nsnull != devspec){
nsDeviceContextSpecWin* specWin = NS_STATIC_CAST(nsDeviceContextSpecWin*, devspec);
rv = specWin->Init(aWidget, aPrintSettings, aIsPrintPreview);
if (NS_SUCCEEDED(rv)) {
aNewSpec = devspec;
} else {
NS_RELEASE(devspec);
}
}
return rv;
}

Просмотреть файл

@ -40,6 +40,8 @@
#include <winspool.h>
#include <tchar.h>
#include "nsIWidget.h"
#include "nsVoidArray.h"
#include "nsIPrintSettingsWin.h"
@ -47,8 +49,11 @@
#include "nsCRT.h"
#include "nsIServiceManager.h"
#include "nsReadableUtils.h"
#include "nsGfxCIID.h"
#ifdef MOZ_CAIRO_GFX
#include "gfxWindowsSurface.h"
#endif
#include "nsUnitConversion.h"
#include "nsIWindowWatcher.h"
#include "nsIDOMWindow.h"
@ -64,7 +69,7 @@
#include "prlog.h"
#ifdef PR_LOGGING
extern PRLogModuleInfo * kGfxPrintingLogMod;
PRLogModuleInfo * kGfxPrintingLogMod = PR_NewLogModule("printing-widget");
#define PR_PL(_p1) PR_LOG(kGfxPrintingLogMod, PR_LOG_DEBUG, _p1)
#else
#define PR_PL(_p1)
@ -510,6 +515,28 @@ static void CleanAndCopyString(char*& aStr, char* aNewStr)
}
}
#ifdef MOZ_CAIRO_GFX
NS_IMETHODIMP nsDeviceContextSpecWin::GetSurfaceForPrinter(gfxASurface **surface)
{
NS_ASSERTION(mDevMode, "DevMode can't be NULL here");
if (mDevMode) {
HDC dc = ::CreateDC(mDriverName, mDeviceName, NULL, mDevMode);
// have this surface take over ownership of this DC
nsRefPtr<gfxASurface> newSurface = new gfxWindowsSurface(dc, PR_TRUE);
*surface = newSurface;
NS_ADDREF(*surface);
return NS_OK;
}
*surface = nsnull;
return NS_ERROR_FAILURE;
}
#endif
//----------------------------------------------------------------------------------
void nsDeviceContextSpecWin::SetDeviceName(char* aDeviceName)
{

Просмотреть файл

@ -42,6 +42,7 @@
#include "nsIDeviceContextSpec.h"
#include "nsIPrintOptions.h" // For nsIPrinterEnumerator
#include "nsIPrintSettings.h"
#include "nsIWidget.h"
#include <windows.h>
class nsDeviceContextSpecWin : public nsIDeviceContextSpec
@ -51,6 +52,10 @@ public:
NS_DECL_ISUPPORTS
#ifdef MOZ_CAIRO_GFX
NS_IMETHOD GetSurfaceForPrinter(gfxASurface **surface);
#endif
NS_IMETHOD Init(nsIWidget* aWidget, nsIPrintSettings* aPS, PRBool aIsPrintPreview);
void GetDriverName(char *&aDriverName) const { aDriverName = mDriverName; }

Просмотреть файл

@ -48,7 +48,7 @@
//*** nsPrintSettingsWin
//*****************************************************************************
class nsPrintSettingsWin : public nsPrintSettings,
public nsIPrintSettingsWin
public nsIPrintSettingsWin
{
public:
NS_DECL_ISUPPORTS_INHERITED

Просмотреть файл

@ -59,6 +59,7 @@ REQUIRES = xpcom \
uconv \
unicharutil \
view \
windowwatcher \
$(NULL)
ifeq ($(MOZ_ENABLE_CAIRO_GFX),1)
@ -75,6 +76,9 @@ CPPSRCS = \
nsPrimitiveHelpers.cpp \
nsXPLookAndFeel.cpp \
nsClipboardHelper.cpp \
nsPrintOptionsImpl.cpp \
nsPrintSettingsImpl.cpp \
nsPrintSession.cpp \
$(NULL)
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))

Просмотреть файл

@ -62,7 +62,7 @@
#include "nsISimpleEnumerator.h"
#include "nsISupportsPrimitives.h"
#include "nsGfxCIID.h"
#include "nsWidgetsCID.h"
#include "stdlib.h"
#include "nsAutoPtr.h"

Просмотреть файл

@ -54,8 +54,8 @@
/**
* Class nsPrintOptions
*/
class NS_GFX nsPrintOptions : public nsIPrintOptions, public
nsIPrintSettingsService
class nsPrintOptions : public nsIPrintOptions,
public nsIPrintSettingsService
{
public:
NS_DECL_ISUPPORTS

Просмотреть файл

@ -50,8 +50,8 @@
#undef IMETHOD_VISIBILITY
#define IMETHOD_VISIBILITY NS_VISIBILITY_DEFAULT
class NS_GFX nsPrintSession : public nsIPrintSession,
public nsSupportsWeakReference
class nsPrintSession : public nsIPrintSession,
public nsSupportsWeakReference
{
public:
NS_DECL_ISUPPORTS

Просмотреть файл

@ -55,7 +55,7 @@
#undef IMETHOD_VISIBILITY
#define IMETHOD_VISIBILITY NS_VISIBILITY_DEFAULT
class NS_GFX nsPrintSettings : public nsIPrintSettings
class nsPrintSettings : public nsIPrintSettings
{
public:
NS_DECL_ISUPPORTS