Bug 565013: Implement printing to PDF for qt builds. r=romaxa r=dholbert a=blocking-fennec

--HG--
rename : widget/src/gtk2/nsDeviceContextSpecG.cpp => widget/src/qt/nsDeviceContextSpecQt.cpp
rename : widget/src/gtk2/nsDeviceContextSpecG.h => widget/src/qt/nsDeviceContextSpecQt.h
rename : widget/src/gtk2/nsPrintDialogGTK.cpp => widget/src/qt/nsPrintDialogQt.cpp
rename : widget/src/gtk2/nsPrintDialogGTK.h => widget/src/qt/nsPrintDialogQt.h
rename : widget/src/gtk2/nsPrintOptionsGTK.cpp => widget/src/qt/nsPrintOptionsQt.cpp
rename : widget/src/gtk2/nsPrintOptionsGTK.h => widget/src/qt/nsPrintOptionsQt.h
rename : widget/src/gtk2/nsPrintSettingsGTK.cpp => widget/src/qt/nsPrintSettingsQt.cpp
rename : widget/src/gtk2/nsPrintSettingsGTK.h => widget/src/qt/nsPrintSettingsQt.h
This commit is contained in:
Tom Brinkman 2010-10-07 12:19:33 -07:00
Родитель 3d4cae15c8
Коммит 6b981e0e94
14 изменённых файлов: 1287 добавлений и 8 удалений

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

@ -5196,7 +5196,6 @@ cairo-qt)
MOZ_WEBGL=1 MOZ_WEBGL=1
MOZ_WEBGL_GLX=1 MOZ_WEBGL_GLX=1
USE_ELF_DYNSTR_GC= USE_ELF_DYNSTR_GC=
NS_PRINTING=
AC_DEFINE(MOZ_X11) AC_DEFINE(MOZ_X11)
MOZ_X11=1 MOZ_X11=1
@ -5846,11 +5845,6 @@ MOZ_ARG_DISABLE_BOOL(printing,
NS_PRINTING=, NS_PRINTING=,
NS_PRINTING=1) NS_PRINTING=1)
if test "$MOZ_WIDGET_TOOLKIT" = "qt"; then
AC_MSG_WARN([Printing does not work with Qt at this time. Omitting printing support.])
NS_PRINTING=
fi
if test "$NS_PRINTING"; then if test "$NS_PRINTING"; then
AC_DEFINE(NS_PRINTING) AC_DEFINE(NS_PRINTING)
AC_DEFINE(NS_PRINT_PREVIEW) AC_DEFINE(NS_PRINT_PREVIEW)

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

@ -210,7 +210,9 @@ endif
ifeq ($(MOZ_WIDGET_TOOLKIT),qt) ifeq ($(MOZ_WIDGET_TOOLKIT),qt)
CPPSRCS += cairo-qt-surface.cpp CPPSRCS += cairo-qt-surface.cpp
CSRCS += $(PSPDF_BASE_CSRCS) $(PDF_CSRCS)
EXPORTS_cairo += cairo-qt.h EXPORTS_cairo += cairo-qt.h
EXPORTS_cairo += $(PDF_EXPORTS)
OS_INCLUDES += $(MOZ_QT_CFLAGS) OS_INCLUDES += $(MOZ_QT_CFLAGS)
endif endif

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

@ -87,6 +87,7 @@ static nsSystemFontsBeOS *gSystemFonts = nsnull;
static nsSystemFontsMac *gSystemFonts = nsnull; static nsSystemFontsMac *gSystemFonts = nsnull;
#elif defined(MOZ_WIDGET_QT) #elif defined(MOZ_WIDGET_QT)
#include "nsSystemFontsQt.h" #include "nsSystemFontsQt.h"
#include "gfxPDFSurface.h"
static nsSystemFontsQt *gSystemFonts = nsnull; static nsSystemFontsQt *gSystemFonts = nsnull;
#elif defined(ANDROID) #elif defined(ANDROID)
#include "nsSystemFontsAndroid.h" #include "nsSystemFontsAndroid.h"
@ -1108,7 +1109,7 @@ nsThebesDeviceContext::CalcPrintingSize()
size = reinterpret_cast<gfxImageSurface*>(mPrintingSurface.get())->GetSize(); size = reinterpret_cast<gfxImageSurface*>(mPrintingSurface.get())->GetSize();
break; break;
#if defined(MOZ_ENABLE_GTK2) || defined(XP_WIN) || defined(XP_OS2) #if defined(MOZ_ENABLE_GTK2) || defined(XP_WIN) || defined(XP_OS2) || defined(MOZ_WIDGET_QT)
case gfxASurface::SurfaceTypePDF: case gfxASurface::SurfaceTypePDF:
inPoints = PR_TRUE; inPoints = PR_TRUE;
size = reinterpret_cast<gfxPDFSurface*>(mPrintingSurface.get())->GetSize(); size = reinterpret_cast<gfxPDFSurface*>(mPrintingSurface.get())->GetSize();

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

@ -122,6 +122,7 @@ EXPORTS += \
gfxQPainterSurface.h \ gfxQPainterSurface.h \
gfxQtNativeRenderer.h \ gfxQtNativeRenderer.h \
gfxQtPlatform.h \ gfxQtPlatform.h \
gfxPDFSurface.h \
$(NULL) $(NULL)
ifdef MOZ_X11 ifdef MOZ_X11
@ -350,6 +351,7 @@ CPPSRCS += gfxFT2FontBase.cpp
CPPSRCS += gfxFT2Utils.cpp CPPSRCS += gfxFT2Utils.cpp
CPPSRCS += gfxFontconfigUtils.cpp CPPSRCS += gfxFontconfigUtils.cpp
CPPSRCS += nsUnicodeRange.cpp CPPSRCS += nsUnicodeRange.cpp
CPPSRCS += gfxPDFSurface.cpp
EXTRA_DSO_LDOPTS += $(MOZ_PANGO_LIBS) $(ZLIB_LIBS) $(XLDFLAGS) $(XLIBS) $(CAIRO_FT_LIBS) $(XEXT_LIBS) EXTRA_DSO_LDOPTS += $(MOZ_PANGO_LIBS) $(ZLIB_LIBS) $(XLDFLAGS) $(XLIBS) $(CAIRO_FT_LIBS) $(XEXT_LIBS)
endif endif

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

@ -75,6 +75,10 @@ CPPSRCS = \
mozqwidget.cpp \ mozqwidget.cpp \
nsSound.cpp \ nsSound.cpp \
nsFilePicker.cpp \ nsFilePicker.cpp \
nsPrintOptionsQt.cpp \
nsPrintSettingsQt.cpp \
nsPrintDialogQt.cpp \
nsDeviceContextSpecQt.cpp \
$(NULL) $(NULL)
SHARED_LIBRARY_LIBS = ../xpwidgets/libxpwidgets_s.a SHARED_LIBRARY_LIBS = ../xpwidgets/libxpwidgets_s.a

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

@ -0,0 +1,316 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** 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):
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
* Ken Herron <kherron+mozilla@fmailbox.com>
* Julien Lafon <julien.lafon@gmail.com>
* Michael Ventnor <m.ventnor@gmail.com>
* Florian Hänel <heeen@gmx.de>
*
* 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 <QTemporaryFile>
#include <QPrinterInfo>
#define SET_PRINTER_FEATURES_VIA_PREFS 1
#define PRINTERFEATURES_PREF "print.tmp.printerfeatures"
#ifdef MOZ_LOGGING
#define FORCE_PR_LOG 1 /* Allow logging in the release build */
#endif /* MOZ_LOGGING */
#include "prlog.h"
#include "plstr.h"
#include "nsDeviceContextSpecQt.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "prenv.h" /* for PR_GetEnv */
#include "nsPrintfCString.h"
#include "nsReadableUtils.h"
#include "nsStringEnumerator.h"
#include "nsIServiceManager.h"
#include "nsPrintSettingsQt.h"
#include "nsIFileStreams.h"
#include "nsILocalFile.h"
#include "nsTArray.h"
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "gfxPDFSurface.h"
/* Ensure that the result is always equal to either PR_TRUE or PR_FALSE */
#define MAKE_PR_BOOL(val) ((val)?(PR_TRUE):(PR_FALSE))
#ifdef PR_LOGGING
static PRLogModuleInfo* DeviceContextSpecQtLM =
PR_NewLogModule("DeviceContextSpecQt");
#endif /* PR_LOGGING */
/* Macro to make lines shorter */
#define DO_PR_DEBUG_LOG(x) PR_LOG(DeviceContextSpecQtLM, PR_LOG_DEBUG, x)
nsDeviceContextSpecQt::nsDeviceContextSpecQt()
{
DO_PR_DEBUG_LOG(("nsDeviceContextSpecQt::nsDeviceContextSpecQt()\n"));
}
nsDeviceContextSpecQt::~nsDeviceContextSpecQt()
{
DO_PR_DEBUG_LOG(("nsDeviceContextSpecQt::~nsDeviceContextSpecQt()\n"));
}
NS_IMPL_ISUPPORTS1(nsDeviceContextSpecQt,
nsIDeviceContextSpec)
NS_IMETHODIMP nsDeviceContextSpecQt::GetSurfaceForPrinter(
gfxASurface** aSurface)
{
NS_ENSURE_ARG_POINTER(aSurface);
*aSurface = nsnull;
double width, height;
mPrintSettings->GetEffectivePageSize(&width, &height);
// If we're in landscape mode, we'll be rotating the output --
// need to swap width & height.
PRInt32 orientation;
mPrintSettings->GetOrientation(&orientation);
if (nsIPrintSettings::kLandscapeOrientation == orientation) {
double tmp = width;
width = height;
height = tmp;
}
// convert twips to points
width /= TWIPS_PER_POINT_FLOAT;
height /= TWIPS_PER_POINT_FLOAT;
DO_PR_DEBUG_LOG(("\"%s\", %f, %f\n", mPath, width, height));
QTemporaryFile file;
if(!file.open()) {
return NS_ERROR_GFX_PRINTER_COULD_NOT_OPEN_FILE;
}
file.setAutoRemove(false);
nsresult rv = NS_NewNativeLocalFile(
nsDependentCString(file.fileName().toAscii().constData()),
PR_FALSE,
getter_AddRefs(mSpoolFile));
if (NS_FAILED(rv)) {
file.remove();
return NS_ERROR_GFX_PRINTER_COULD_NOT_OPEN_FILE;
}
mSpoolName = file.fileName().toUtf8().constData();
mSpoolFile->SetPermissions(0600);
nsCOMPtr<nsIFileOutputStream> stream =
do_CreateInstance("@mozilla.org/network/file-output-stream;1");
rv = stream->Init(mSpoolFile, -1, -1, 0);
if (NS_FAILED(rv))
return rv;
PRInt16 format;
mPrintSettings->GetOutputFormat(&format);
nsRefPtr<gfxASurface> surface;
gfxSize surfaceSize(width, height);
if (format == nsIPrintSettings::kOutputFormatNative) {
if (mIsPPreview) {
// There is nothing to detect on Print Preview, use PS.
// TODO: implement for Qt?
//format = nsIPrintSettings::kOutputFormatPS;
return NS_ERROR_NOT_IMPLEMENTED;
}
format = nsIPrintSettings::kOutputFormatPDF;
}
if (format == nsIPrintSettings::kOutputFormatPDF) {
surface = new gfxPDFSurface(stream, surfaceSize);
} else {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_ABORT_IF_FALSE(surface, "valid address expected");
surface.swap(*aSurface);
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecQt::Init(nsIWidget* aWidget,
nsIPrintSettings* aPS,
PRBool aIsPrintPreview)
{
DO_PR_DEBUG_LOG(("nsDeviceContextSpecQt::Init(aPS=%p)\n", aPS));
mPrintSettings = aPS;
mIsPPreview = aIsPrintPreview;
// This is only set by embedders
PRBool toFile;
aPS->GetPrintToFile(&toFile);
mToPrinter = !toFile && !aIsPrintPreview;
nsCOMPtr<nsPrintSettingsQt> printSettingsQt(do_QueryInterface(aPS));
if (!printSettingsQt)
return NS_ERROR_NO_INTERFACE;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecQt::GetPath(const char** aPath)
{
*aPath = mPath;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecQt::BeginDocument(
PRUnichar* aTitle,
PRUnichar* aPrintToFileName,
PRInt32 aStartPage,
PRInt32 aEndPage)
{
if (mToPrinter) {
return NS_ERROR_NOT_IMPLEMENTED;
}
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecQt::EndDocument()
{
if (mToPrinter) {
return NS_ERROR_NOT_IMPLEMENTED;
}
// Handle print-to-file ourselves for the benefit of embedders
nsXPIDLString targetPath;
nsCOMPtr<nsILocalFile> destFile;
mPrintSettings->GetToFileName(getter_Copies(targetPath));
nsresult rv = NS_NewNativeLocalFile(NS_ConvertUTF16toUTF8(targetPath),
PR_FALSE, getter_AddRefs(destFile));
NS_ENSURE_SUCCESS(rv, rv);
nsAutoString destLeafName;
rv = destFile->GetLeafName(destLeafName);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIFile> destDir;
rv = destFile->GetParent(getter_AddRefs(destDir));
NS_ENSURE_SUCCESS(rv, rv);
rv = mSpoolFile->MoveTo(destDir, destLeafName);
NS_ENSURE_SUCCESS(rv, rv);
// This is the standard way to get the UNIX umask. Ugh.
mode_t mask = umask(0);
umask(mask);
// If you're not familiar with umasks, they contain the bits of what NOT
// to set in the permissions
// (thats because files and directories have different numbers of bits
// for their permissions)
destFile->SetPermissions(0666 & ~(mask));
return NS_OK;
}
// Printer Enumerator
nsPrinterEnumeratorQt::nsPrinterEnumeratorQt()
{
}
NS_IMPL_ISUPPORTS1(nsPrinterEnumeratorQt, nsIPrinterEnumerator)
NS_IMETHODIMP nsPrinterEnumeratorQt::GetPrinterNameList(
nsIStringEnumerator** aPrinterNameList)
{
NS_ENSURE_ARG_POINTER(aPrinterNameList);
*aPrinterNameList = nsnull;
QList<QPrinterInfo> qprinters = QPrinterInfo::availablePrinters();
if (qprinters.size() == 0)
return NS_ERROR_NOT_AVAILABLE;
nsTArray<nsString>* printers =
new nsTArray<nsString>(qprinters.size());
for (PRInt32 i = 0; i < qprinters.size(); ++i) {
printers->AppendElement(
nsDependentString(
(const PRUnichar*)qprinters[i].printerName().constData()));
}
return NS_NewAdoptingStringEnumerator(aPrinterNameList, printers);
}
NS_IMETHODIMP nsPrinterEnumeratorQt::GetDefaultPrinterName(
PRUnichar** aDefaultPrinterName)
{
DO_PR_DEBUG_LOG(("nsPrinterEnumeratorQt::GetDefaultPrinterName()\n"));
NS_ENSURE_ARG_POINTER(aDefaultPrinterName);
QString defprinter = QPrinterInfo::defaultPrinter().printerName();
*aDefaultPrinterName = ToNewUnicode(nsDependentString(
(const PRUnichar*)defprinter.constData()));
DO_PR_DEBUG_LOG(("GetDefaultPrinterName(): default printer='%s'.\n",
NS_ConvertUTF16toUTF8(*aDefaultPrinterName).get()));
return NS_OK;
}
NS_IMETHODIMP nsPrinterEnumeratorQt::InitPrintSettingsFromPrinter(
const PRUnichar* aPrinterName,
nsIPrintSettings* aPrintSettings)
{
DO_PR_DEBUG_LOG(("nsPrinterEnumeratorQt::InitPrintSettingsFromPrinter()"));
// XXX Leave NS_OK for now
// Probably should use NS_ERROR_NOT_IMPLEMENTED
return NS_OK;
}
NS_IMETHODIMP nsPrinterEnumeratorQt::DisplayPropertiesDlg(
const PRUnichar* aPrinter,
nsIPrintSettings* aPrintSettings)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

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

@ -0,0 +1,93 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** 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):
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
* Florian Hänel <heeen@gmx.de>
*
* 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 ***** */
#ifndef nsDeviceContextSpecQt_h___
#define nsDeviceContextSpecQt_h___
#include "nsIDeviceContextSpec.h"
#include "nsIPrintSettings.h"
#include "nsIPrintOptions.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsCRT.h" /* should be <limits.h>? */
class nsDeviceContextSpecQt : public nsIDeviceContextSpec
{
public:
nsDeviceContextSpecQt();
virtual ~nsDeviceContextSpecQt();
NS_DECL_ISUPPORTS
NS_IMETHOD GetSurfaceForPrinter(gfxASurface** surface);
NS_IMETHOD Init(nsIWidget* aWidget,
nsIPrintSettings* aPS,
PRBool aIsPrintPreview);
NS_IMETHOD BeginDocument(PRUnichar* aTitle,
PRUnichar* aPrintToFileName,
PRInt32 aStartPage,
PRInt32 aEndPage);
NS_IMETHOD EndDocument();
NS_IMETHOD BeginPage() { return NS_OK; }
NS_IMETHOD EndPage() { return NS_OK; }
NS_IMETHOD GetPath (const char** aPath);
protected:
nsCOMPtr<nsIPrintSettings> mPrintSettings;
PRPackedBool mToPrinter : 1; /* If PR_TRUE, print to printer */
PRPackedBool mIsPPreview : 1; /* If PR_TRUE, is print preview */
char mPath[PATH_MAX]; /* If toPrinter = PR_FALSE, dest file */
char mPrinter[256]; /* Printer name */
nsCString mSpoolName;
nsCOMPtr<nsILocalFile> mSpoolFile;
};
class nsPrinterEnumeratorQt : public nsIPrinterEnumerator
{
public:
nsPrinterEnumeratorQt();
NS_DECL_ISUPPORTS
NS_DECL_NSIPRINTERENUMERATOR
};
#endif /* !nsDeviceContextSpecQt_h___ */

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

@ -0,0 +1,77 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** 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 the Mozilla GTK2 print dialog interface.
*
* The Initial Developer of the Original Code is
* Kenneth Herron <kherron@fmailbox.com>
* Portions created by the Initial Developer are Copyright (C) 2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Michael Ventnor <m.ventnor@gmail.com>
* Florian Hänel <heeen@gmx.de>
*
* Alternatively, the contents of this file may be used under the terms of
* either 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 "nsPrintSettingsQt.h"
#include "nsPrintDialogQt.h"
// For Qt, we only support printing to PDF, and that doesn't need a
// print dialog at this point. So, this class's methods are left
// un-implemented for now.
NS_IMPL_ISUPPORTS1(nsPrintDialogServiceQt, nsIPrintDialogService)
nsPrintDialogServiceQt::nsPrintDialogServiceQt()
{
}
nsPrintDialogServiceQt::~nsPrintDialogServiceQt()
{
}
NS_IMETHODIMP
nsPrintDialogServiceQt::Init()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsPrintDialogServiceQt::Show(nsIDOMWindow* aParent,
nsIPrintSettings* aSettings,
nsIWebBrowserPrint* aWebBrowserPrint)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsPrintDialogServiceQt::ShowPageSetup(nsIDOMWindow* aParent,
nsIPrintSettings* aNSSettings)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

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

@ -0,0 +1,63 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** 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 the Mozilla GTK2 print dialog interface.
*
* The Initial Developer of the Original Code is
* Kenneth Herron <kherron@fmailbox.com>
* Portions created by the Initial Developer are Copyright (C) 2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Florian Hänel <heeen@gmx.de>
*
* Alternatively, the contents of this file may be used under the terms of
* either 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 ***** */
#ifndef nsPrintDialogQt_h__
#define nsPrintDialogQt_h__
#include "nsIPrintDialogService.h"
class nsIPrintSettings;
class nsPrintDialogServiceQt : public nsIPrintDialogService
{
public:
nsPrintDialogServiceQt();
virtual ~nsPrintDialogServiceQt();
NS_DECL_ISUPPORTS
NS_IMETHODIMP Init();
NS_IMETHODIMP Show(nsIDOMWindow* aParent,
nsIPrintSettings* aSettings,
nsIWebBrowserPrint* aWebBrowserPrint);
NS_IMETHODIMP ShowPageSetup(nsIDOMWindow* aParent,
nsIPrintSettings* aSettings);
};
#endif

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

@ -0,0 +1,56 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** 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):
* Florian Hänel <heeen@gmx.de>
*
* 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 "nsPrintSettingsQt.h"
#include "nsPrintOptionsQt.h"
nsPrintOptionsQt::nsPrintOptionsQt()
{
}
nsPrintOptionsQt::~nsPrintOptionsQt()
{
}
nsresult nsPrintOptionsQt::_CreatePrintSettings(nsIPrintSettings** _retval)
{
nsPrintSettingsQt* printSettings =
new nsPrintSettingsQt(); // does not initially ref count
NS_ADDREF(*_retval = printSettings); // ref count
return NS_OK;
}

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

@ -0,0 +1,54 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** 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 the Mozilla browser.
*
* The Initial Developer of the Original Code is
* Netscape Communications, Inc.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Travis Bogard <travis@netscape.com>
* Florian Hänel <heeen@gmx.de>
*
* 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 ***** */
#ifndef nsPrintOptionsQt_h__
#define nsPrintOptionsQt_h__
#include "nsPrintOptionsImpl.h"
class nsPrintOptionsQt : public nsPrintOptions
{
public:
nsPrintOptionsQt();
virtual ~nsPrintOptionsQt();
virtual nsresult _CreatePrintSettings(nsIPrintSettings** _retval);
};
#endif /* nsPrintOptionsQt_h__ */

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

@ -0,0 +1,466 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** 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 Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Michael Ventnor <m.ventnor@gmail.com>
* Florian Hänel <heeen@gmx.de>
*
* 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 <QPrinter>
#include <QDebug>
#include "nsPrintSettingsQt.h"
#include "nsILocalFile.h"
#include "nsCRTGlue.h"
NS_IMPL_ISUPPORTS_INHERITED1(nsPrintSettingsQt,
nsPrintSettings,
nsPrintSettingsQt)
nsPrintSettingsQt::nsPrintSettingsQt():
mQPrinter(new QPrinter())
{
}
nsPrintSettingsQt::~nsPrintSettingsQt()
{
//smart pointer should take care of cleanup
}
nsPrintSettingsQt::nsPrintSettingsQt(const nsPrintSettingsQt& aPS):
mQPrinter(aPS.mQPrinter)
{
}
nsPrintSettingsQt&
nsPrintSettingsQt::operator=(const nsPrintSettingsQt& rhs)
{
if (this == &rhs) {
return *this;
}
nsPrintSettings::operator=(rhs);
mQPrinter = rhs.mQPrinter;
return *this;
}
nsresult
nsPrintSettingsQt::_Clone(nsIPrintSettings** _retval)
{
NS_ENSURE_ARG_POINTER(_retval);
nsPrintSettingsQt* newSettings = new nsPrintSettingsQt(*this);
*_retval = newSettings;
NS_ADDREF(*_retval);
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::_Assign(nsIPrintSettings* aPS)
{
nsPrintSettingsQt* printSettingsQt = static_cast<nsPrintSettingsQt*>(aPS);
if (!printSettingsQt)
return NS_ERROR_UNEXPECTED;
*this = *printSettingsQt;
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::GetPrintRange(PRInt16* aPrintRange)
{
NS_ENSURE_ARG_POINTER(aPrintRange);
QPrinter::PrintRange range = mQPrinter->printRange();
if (range == QPrinter::PageRange) {
*aPrintRange = kRangeSpecifiedPageRange;
} else if (range == QPrinter::Selection) {
*aPrintRange = kRangeSelection;
} else {
*aPrintRange = kRangeAllPages;
}
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::SetPrintRange(PRInt16 aPrintRange)
{
if (aPrintRange == kRangeSelection) {
mQPrinter->setPrintRange(QPrinter::Selection);
} else if (aPrintRange == kRangeSpecifiedPageRange) {
mQPrinter->setPrintRange(QPrinter::PageRange);
} else {
mQPrinter->setPrintRange(QPrinter::AllPages);
}
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::GetStartPageRange(PRInt32* aStartPageRange)
{
NS_ENSURE_ARG_POINTER(aStartPageRange);
PRInt32 start = mQPrinter->fromPage();
*aStartPageRange = start;
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::SetStartPageRange(PRInt32 aStartPageRange)
{
PRInt32 endRange = mQPrinter->toPage();
mQPrinter->setFromTo(aStartPageRange, endRange);
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::GetEndPageRange(PRInt32* aEndPageRange)
{
NS_ENSURE_ARG_POINTER(aEndPageRange);
PRInt32 end = mQPrinter->toPage();
*aEndPageRange = end;
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::SetEndPageRange(PRInt32 aEndPageRange)
{
PRInt32 startRange = mQPrinter->fromPage();
mQPrinter->setFromTo(startRange, aEndPageRange);
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::GetPrintReversed(PRBool* aPrintReversed)
{
NS_ENSURE_ARG_POINTER(aPrintReversed);
if (mQPrinter->pageOrder() == QPrinter::LastPageFirst) {
*aPrintReversed = PR_TRUE;
} else {
*aPrintReversed = PR_FALSE;
}
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::SetPrintReversed(PRBool aPrintReversed)
{
if (aPrintReversed) {
mQPrinter->setPageOrder(QPrinter::LastPageFirst);
} else {
mQPrinter->setPageOrder(QPrinter::FirstPageFirst);
}
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::GetPrintInColor(PRBool* aPrintInColor)
{
NS_ENSURE_ARG_POINTER(aPrintInColor);
if (mQPrinter->colorMode() == QPrinter::Color) {
*aPrintInColor = PR_TRUE;
} else {
*aPrintInColor = PR_FALSE;
}
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::SetPrintInColor(PRBool aPrintInColor)
{
if (aPrintInColor) {
mQPrinter->setColorMode(QPrinter::Color);
} else {
mQPrinter->setColorMode(QPrinter::GrayScale);
}
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::GetOrientation(PRInt32* aOrientation)
{
NS_ENSURE_ARG_POINTER(aOrientation);
QPrinter::Orientation orientation = mQPrinter->orientation();
if (orientation == QPrinter::Landscape) {
*aOrientation = kLandscapeOrientation;
} else {
*aOrientation = kPortraitOrientation;
}
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::SetOrientation(PRInt32 aOrientation)
{
if (aOrientation == kLandscapeOrientation) {
mQPrinter->setOrientation(QPrinter::Landscape);
} else {
mQPrinter->setOrientation(QPrinter::Portrait);
}
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::GetToFileName(PRUnichar** aToFileName)
{
NS_ENSURE_ARG_POINTER(aToFileName);
QString filename;
filename = mQPrinter->outputFileName();
*aToFileName = ToNewUnicode(
nsDependentString((PRUnichar*)filename.data()));
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::SetToFileName(const PRUnichar* aToFileName)
{
nsCOMPtr<nsILocalFile> file;
nsresult rv = NS_NewLocalFile(nsDependentString(aToFileName), PR_TRUE,
getter_AddRefs(file));
NS_ENSURE_SUCCESS(rv, rv);
QString filename((const QChar*)aToFileName, NS_strlen(aToFileName));
mQPrinter->setOutputFileName(filename);
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::GetPrinterName(PRUnichar** aPrinter)
{
NS_ENSURE_ARG_POINTER(aPrinter);
*aPrinter = ToNewUnicode(nsDependentString(
(const PRUnichar*)mQPrinter->printerName().constData()));
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::SetPrinterName(const PRUnichar* aPrinter)
{
QString printername((const QChar*)aPrinter, NS_strlen(aPrinter));
mQPrinter->setPrinterName(printername);
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::GetNumCopies(PRInt32* aNumCopies)
{
NS_ENSURE_ARG_POINTER(aNumCopies);
*aNumCopies = mQPrinter->numCopies();
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::SetNumCopies(PRInt32 aNumCopies)
{
mQPrinter->setNumCopies(aNumCopies);
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::GetScaling(double* aScaling)
{
NS_ENSURE_ARG_POINTER(aScaling);
qDebug()<<Q_FUNC_INFO;
qDebug()<<"Scaling not implemented in Qt port";
*aScaling = 1.0; //FIXME
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsPrintSettingsQt::SetScaling(double aScaling)
{
qDebug()<<Q_FUNC_INFO;
qDebug()<<"Scaling not implemented in Qt port"; //FIXME
return NS_ERROR_NOT_IMPLEMENTED;
}
static const char* const indexToPaperName[] =
{ "A4", "B5", "Letter", "Legal", "Executive",
"A0", "A1", "A2", "A3", "A5", "A6", "A7", "A8", "A9",
"B0", "B1", "B10", "B2", "B3", "B4", "B6", "B7", "B8", "B9",
"C5E", "Comm10E", "DLE", "Folio", "Ledger", "Tabloid"
};
static const QPrinter::PageSize indexToQtPaperEnum[] =
{
QPrinter::A4, QPrinter::B5, QPrinter::Letter, QPrinter::Legal,
QPrinter::Executive, QPrinter::A0, QPrinter::A1, QPrinter::A2, QPrinter::A3,
QPrinter::A5, QPrinter::A6, QPrinter::A7, QPrinter::A8, QPrinter::A9,
QPrinter::B0, QPrinter::B1, QPrinter::B10, QPrinter::B2, QPrinter::B3,
QPrinter::B4, QPrinter::B6, QPrinter::B7, QPrinter::B8, QPrinter::B9,
QPrinter::C5E, QPrinter::Comm10E, QPrinter::DLE, QPrinter::Folio,
QPrinter::Ledger, QPrinter::Tabloid
};
NS_IMETHODIMP
nsPrintSettingsQt::GetPaperName(PRUnichar** aPaperName)
{
PR_STATIC_ASSERT(sizeof(indexToPaperName)/
sizeof(char*) == QPrinter::NPageSize);
PR_STATIC_ASSERT(sizeof(indexToQtPaperEnum)/
sizeof(QPrinter::PageSize) == QPrinter::NPageSize);
QPrinter::PaperSize size = mQPrinter->paperSize();
QString name(indexToPaperName[size]);
*aPaperName = ToNewUnicode(nsDependentString
((const PRUnichar*)name.constData()));
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::SetPaperName(const PRUnichar* aPaperName)
{
QString ref((QChar*)aPaperName, NS_strlen(aPaperName));
for (PRUint32 i = 0; i < QPrinter::NPageSize; i++)
{
if (ref == QString(indexToPaperName[i])) {
mQPrinter->setPageSize(indexToQtPaperEnum[i]);
return NS_OK;
}
}
return NS_ERROR_FAILURE;
}
QPrinter::Unit GetQtUnit(PRInt16 aGeckoUnit)
{
if (aGeckoUnit == nsIPrintSettings::kPaperSizeMillimeters) {
return QPrinter::Millimeter;
} else {
return QPrinter::Inch;
}
}
#define SETUNWRITEABLEMARGIN\
mQPrinter->setPageMargins(\
NS_TWIPS_TO_INCHES(mUnwriteableMargin.left),\
NS_TWIPS_TO_INCHES(mUnwriteableMargin.top),\
NS_TWIPS_TO_INCHES(mUnwriteableMargin.right),\
NS_TWIPS_TO_INCHES(mUnwriteableMargin.bottom),\
QPrinter::Inch);
NS_IMETHODIMP
nsPrintSettingsQt::SetUnwriteableMarginInTwips(nsIntMargin& aUnwriteableMargin)
{
nsPrintSettings::SetUnwriteableMarginInTwips(aUnwriteableMargin);
SETUNWRITEABLEMARGIN
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::SetUnwriteableMarginTop(double aUnwriteableMarginTop)
{
nsPrintSettings::SetUnwriteableMarginTop(aUnwriteableMarginTop);
SETUNWRITEABLEMARGIN
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::SetUnwriteableMarginLeft(double aUnwriteableMarginLeft)
{
nsPrintSettings::SetUnwriteableMarginLeft(aUnwriteableMarginLeft);
SETUNWRITEABLEMARGIN
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::SetUnwriteableMarginBottom(double aUnwriteableMarginBottom)
{
nsPrintSettings::SetUnwriteableMarginBottom(aUnwriteableMarginBottom);
SETUNWRITEABLEMARGIN
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::SetUnwriteableMarginRight(double aUnwriteableMarginRight)
{
nsPrintSettings::SetUnwriteableMarginRight(aUnwriteableMarginRight);
SETUNWRITEABLEMARGIN
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::GetPaperWidth(double* aPaperWidth)
{
NS_ENSURE_ARG_POINTER(aPaperWidth);
QSizeF papersize = mQPrinter->paperSize(GetQtUnit(mPaperSizeUnit));
*aPaperWidth = papersize.width();
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::SetPaperWidth(double aPaperWidth)
{
QSizeF papersize = mQPrinter->paperSize(GetQtUnit(mPaperSizeUnit));
papersize.setWidth(aPaperWidth);
mQPrinter->setPaperSize(papersize, GetQtUnit(mPaperSizeUnit));
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::GetPaperHeight(double* aPaperHeight)
{
NS_ENSURE_ARG_POINTER(aPaperHeight);
QSizeF papersize = mQPrinter->paperSize(GetQtUnit(mPaperSizeUnit));
*aPaperHeight = papersize.height();
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::SetPaperHeight(double aPaperHeight)
{
QSizeF papersize = mQPrinter->paperSize(GetQtUnit(mPaperSizeUnit));
papersize.setHeight(aPaperHeight);
mQPrinter->setPaperSize(papersize, GetQtUnit(mPaperSizeUnit));
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::SetPaperSizeUnit(PRInt16 aPaperSizeUnit)
{
mPaperSizeUnit = aPaperSizeUnit;
return NS_OK;
}
NS_IMETHODIMP
nsPrintSettingsQt::GetEffectivePageSize(double* aWidth, double* aHeight)
{
QSizeF papersize = mQPrinter->paperSize(QPrinter::Inch);
if (mQPrinter->orientation() == QPrinter::Landscape) {
*aWidth = NS_INCHES_TO_INT_TWIPS(papersize.height());
*aHeight = NS_INCHES_TO_INT_TWIPS(papersize.width());
} else {
*aWidth = NS_INCHES_TO_INT_TWIPS(papersize.width());
*aHeight = NS_INCHES_TO_INT_TWIPS(papersize.height());
}
return NS_OK;
}

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

@ -0,0 +1,117 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** 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 the Mozilla browser.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Michael Ventnor <m.ventnor@gmail.com>
* Florian Hänel <heeen@gmx.de>
*
* 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 ***** */
#ifndef nsPrintSettingsQt_h_
#define nsPrintSettingsQt_h_
#include <QSharedPointer>
#include "nsPrintSettingsImpl.h"
#define NS_PRINTSETTINGSQT_IID \
{0x5bc4c746, 0x8970, 0x43a3, {0xbf, 0xb1, 0x5d, 0xe1, 0x74, 0xaf, 0x7c, 0xea}}
class QPrinter;
class nsPrintSettingsQt : public nsPrintSettings
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECLARE_STATIC_IID_ACCESSOR(NS_PRINTSETTINGSQT_IID)
nsPrintSettingsQt();
virtual ~nsPrintSettingsQt();
NS_IMETHOD GetPrintRange(PRInt16* aPrintRange);
NS_IMETHOD SetPrintRange(PRInt16 aPrintRange);
NS_IMETHOD GetStartPageRange(PRInt32* aStartPageRange);
NS_IMETHOD SetStartPageRange(PRInt32 aStartPageRange);
NS_IMETHOD GetEndPageRange(PRInt32* aEndPageRange);
NS_IMETHOD SetEndPageRange(PRInt32 aEndPageRange);
NS_IMETHOD GetPrintReversed(PRBool* aPrintReversed);
NS_IMETHOD SetPrintReversed(PRBool aPrintReversed);
NS_IMETHOD GetPrintInColor(PRBool* aPrintInColor);
NS_IMETHOD SetPrintInColor(PRBool aPrintInColor);
NS_IMETHOD GetOrientation(PRInt32* aOrientation);
NS_IMETHOD SetOrientation(PRInt32 aOrientation);
NS_IMETHOD GetToFileName(PRUnichar** aToFileName);
NS_IMETHOD SetToFileName(const PRUnichar* aToFileName);
NS_IMETHOD GetPrinterName(PRUnichar** aPrinter);
NS_IMETHOD SetPrinterName(const PRUnichar* aPrinter);
NS_IMETHOD GetNumCopies(PRInt32* aNumCopies);
NS_IMETHOD SetNumCopies(PRInt32 aNumCopies);
NS_IMETHOD GetScaling(double* aScaling);
NS_IMETHOD SetScaling(double aScaling);
NS_IMETHOD GetPaperName(PRUnichar** aPaperName);
NS_IMETHOD SetPaperName(const PRUnichar* aPaperName);
NS_IMETHOD SetUnwriteableMarginInTwips(nsIntMargin& aUnwriteableMargin);
NS_IMETHOD SetUnwriteableMarginTop(double aUnwriteableMarginTop);
NS_IMETHOD SetUnwriteableMarginLeft(double aUnwriteableMarginLeft);
NS_IMETHOD SetUnwriteableMarginBottom(double aUnwriteableMarginBottom);
NS_IMETHOD SetUnwriteableMarginRight(double aUnwriteableMarginRight);
NS_IMETHOD GetPaperWidth(double* aPaperWidth);
NS_IMETHOD SetPaperWidth(double aPaperWidth);
NS_IMETHOD GetPaperHeight(double* aPaperHeight);
NS_IMETHOD SetPaperHeight(double aPaperHeight);
NS_IMETHOD SetPaperSizeUnit(PRInt16 aPaperSizeUnit);
NS_IMETHOD GetEffectivePageSize(double* aWidth, double* aHeight);
protected:
nsPrintSettingsQt(const nsPrintSettingsQt& src);
nsPrintSettingsQt& operator=(const nsPrintSettingsQt& rhs);
virtual nsresult _Clone(nsIPrintSettings** _retval);
virtual nsresult _Assign(nsIPrintSettings* aPS);
QSharedPointer<QPrinter> mQPrinter;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsPrintSettingsQt, NS_PRINTSETTINGSQT_IID)
#endif // nsPrintSettingsQt_h_

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

@ -61,7 +61,12 @@
#include "nsSound.h" #include "nsSound.h"
#include "nsBidiKeyboard.h" #include "nsBidiKeyboard.h"
#include "nsNativeThemeQt.h" #include "nsNativeThemeQt.h"
#ifdef NS_PRINTING
#include "nsDeviceContextSpecQt.h"
#include "nsPrintSession.h"
#include "nsPrintOptionsQt.h"
#include "nsPrintDialogQt.h"
#endif
// from nsWindow.cpp // from nsWindow.cpp
extern PRBool gDisableNativeTheme; extern PRBool gDisableNativeTheme;
@ -81,6 +86,14 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsIdleServiceQt)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound) NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePicker) NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePicker)
#ifdef NS_PRINTING
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecQt)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsQt, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorQt)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintDialogServiceQt, Init)
#endif
static nsresult static nsresult
nsNativeThemeQtConstructor(nsISupports *aOuter, REFNSIID aIID, nsNativeThemeQtConstructor(nsISupports *aOuter, REFNSIID aIID,
void **aResult) void **aResult)
@ -123,6 +136,13 @@ NS_DEFINE_NAMED_CID(NS_THEMERENDERER_CID);
NS_DEFINE_NAMED_CID(NS_IDLE_SERVICE_CID); NS_DEFINE_NAMED_CID(NS_IDLE_SERVICE_CID);
NS_DEFINE_NAMED_CID(NS_POPUP_CID); NS_DEFINE_NAMED_CID(NS_POPUP_CID);
NS_DEFINE_NAMED_CID(NS_TOOLKIT_CID); NS_DEFINE_NAMED_CID(NS_TOOLKIT_CID);
#ifdef NS_PRINTING
NS_DEFINE_NAMED_CID(NS_PRINTSETTINGSSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_PRINTER_ENUMERATOR_CID);
NS_DEFINE_NAMED_CID(NS_PRINTSESSION_CID);
NS_DEFINE_NAMED_CID(NS_DEVICE_CONTEXT_SPEC_CID);
NS_DEFINE_NAMED_CID(NS_PRINTDIALOGSERVICE_CID);
#endif
static const mozilla::Module::CIDEntry kWidgetCIDs[] = { static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
{ &kNS_WINDOW_CID, false, NULL, nsWindowConstructor }, { &kNS_WINDOW_CID, false, NULL, nsWindowConstructor },
@ -142,6 +162,13 @@ static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
{ &kNS_IDLE_SERVICE_CID, false, NULL, nsIdleServiceQtConstructor }, { &kNS_IDLE_SERVICE_CID, false, NULL, nsIdleServiceQtConstructor },
{ &kNS_POPUP_CID, false, NULL, nsPopupWindowConstructor }, { &kNS_POPUP_CID, false, NULL, nsPopupWindowConstructor },
{ &kNS_TOOLKIT_CID, false, NULL, nsToolkitConstructor }, { &kNS_TOOLKIT_CID, false, NULL, nsToolkitConstructor },
#ifdef NS_PRINTING
{ &kNS_PRINTSETTINGSSERVICE_CID, false, NULL, nsPrintOptionsQtConstructor },
{ &kNS_PRINTER_ENUMERATOR_CID, false, NULL, nsPrinterEnumeratorQtConstructor },
{ &kNS_PRINTSESSION_CID, false, NULL, nsPrintSessionConstructor },
{ &kNS_DEVICE_CONTEXT_SPEC_CID, false, NULL, nsDeviceContextSpecQtConstructor },
{ &kNS_PRINTDIALOGSERVICE_CID, false, NULL, nsPrintDialogServiceQtConstructor },
#endif
{ NULL } { NULL }
}; };
@ -163,6 +190,13 @@ static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
{ "@mozilla.org/widget/idleservice;1", &kNS_IDLE_SERVICE_CID }, { "@mozilla.org/widget/idleservice;1", &kNS_IDLE_SERVICE_CID },
{ "@mozilla.org/widgets/popup_window/qt;1", &kNS_POPUP_CID }, { "@mozilla.org/widgets/popup_window/qt;1", &kNS_POPUP_CID },
{ "@mozilla.org/widget/toolkit/qt;1", &kNS_TOOLKIT_CID }, { "@mozilla.org/widget/toolkit/qt;1", &kNS_TOOLKIT_CID },
#ifdef NS_PRINTING
{ "@mozilla.org/gfx/printsettings-service;1", &kNS_PRINTSETTINGSSERVICE_CID },
{ "@mozilla.org/gfx/printerenumerator;1", &kNS_PRINTER_ENUMERATOR_CID },
{ "@mozilla.org/gfx/printsession;1", &kNS_PRINTSESSION_CID },
{ "@mozilla.org/gfx/devicecontextspec;1", &kNS_DEVICE_CONTEXT_SPEC_CID },
{ NS_PRINTDIALOGSERVICE_CONTRACTID, &kNS_PRINTDIALOGSERVICE_CID },
#endif
{ NULL } { NULL }
}; };