Bug 1082579 - Introduce PPrinting.ipdl and proxies for opening printing UI. r=blassey.

--HG--
extra : rebase_source : 69ac7840ef72055911daa0ff482236b57f563aba
This commit is contained in:
Mike Conley 2014-10-28 11:59:08 -04:00
parent ce28b6ea6c
commit 7c82948304
32 changed files with 1112 additions and 46 deletions

View File

@ -1766,3 +1766,10 @@ pref("browser.apps.URL", "https://marketplace.firefox.com/discovery/");
pref("browser.polaris.enabled", false);
pref("privacy.trackingprotection.ui.enabled", false);
// Temporary pref to allow printing in e10s windows on some platforms.
#ifdef UNIX_BUT_NOT_MAC
pref("print.enable_e10s_testing", false);
#else
pref("print.enable_e10s_testing", true);
#endif

View File

@ -175,6 +175,7 @@ using namespace mozilla::dom::mobileconnection;
using namespace mozilla::dom::mobilemessage;
using namespace mozilla::dom::telephony;
using namespace mozilla::dom::voicemail;
using namespace mozilla::embedding;
using namespace mozilla::hal_sandbox;
using namespace mozilla::ipc;
using namespace mozilla::layers;
@ -1391,6 +1392,24 @@ ContentChild::DeallocPNeckoChild(PNeckoChild* necko)
return true;
}
PPrintingChild*
ContentChild::AllocPPrintingChild()
{
// The ContentParent should never attempt to allocate the
// nsPrintingPromptServiceProxy, which implements PPrintingChild. Instead,
// the nsPrintingPromptServiceProxy service is requested and instantiated
// via XPCOM, and the constructor of nsPrintingPromptServiceProxy sets up
// the IPC connection.
NS_NOTREACHED("Should never get here!");
return nullptr;
}
bool
ContentChild::DeallocPPrintingChild(PPrintingChild* printing)
{
return true;
}
PScreenManagerChild*
ContentChild::AllocPScreenManagerChild(uint32_t* aNumberOfScreens,
float* aSystemDefaultScale,

View File

@ -207,6 +207,9 @@ public:
virtual PNeckoChild* AllocPNeckoChild() MOZ_OVERRIDE;
virtual bool DeallocPNeckoChild(PNeckoChild*) MOZ_OVERRIDE;
virtual PPrintingChild* AllocPPrintingChild() MOZ_OVERRIDE;
virtual bool DeallocPPrintingChild(PPrintingChild*) MOZ_OVERRIDE;
virtual PScreenManagerChild*
AllocPScreenManagerChild(uint32_t* aNumberOfScreens,
float* aSystemDefaultScale,

View File

@ -57,6 +57,7 @@
#include "mozilla/dom/telephony/TelephonyParent.h"
#include "mozilla/dom/time/DateCacheCleaner.h"
#include "mozilla/dom/voicemail/VoicemailParent.h"
#include "mozilla/embedding/printingui/PrintingParent.h"
#include "mozilla/hal_sandbox/PHalParent.h"
#include "mozilla/ipc/BackgroundChild.h"
#include "mozilla/ipc/BackgroundParent.h"
@ -208,6 +209,7 @@ using namespace mozilla::dom::mobileconnection;
using namespace mozilla::dom::mobilemessage;
using namespace mozilla::dom::telephony;
using namespace mozilla::dom::voicemail;
using namespace mozilla::embedding;
using namespace mozilla::hal;
using namespace mozilla::ipc;
using namespace mozilla::layers;
@ -3116,6 +3118,25 @@ ContentParent::DeallocPNeckoParent(PNeckoParent* necko)
return true;
}
PPrintingParent*
ContentParent::AllocPPrintingParent()
{
return new PrintingParent();
}
bool
ContentParent::RecvPPrintingConstructor(PPrintingParent* aActor)
{
return true;
}
bool
ContentParent::DeallocPPrintingParent(PPrintingParent* printing)
{
delete printing;
return true;
}
PScreenManagerParent*
ContentParent::AllocPScreenManagerParent(uint32_t* aNumberOfScreens,
float* aSystemDefaultScale,

View File

@ -245,6 +245,10 @@ public:
return PContentParent::RecvPNeckoConstructor(aActor);
}
virtual PPrintingParent* AllocPPrintingParent() MOZ_OVERRIDE;
virtual bool RecvPPrintingConstructor(PPrintingParent* aActor) MOZ_OVERRIDE;
virtual bool DeallocPPrintingParent(PPrintingParent* aActor) MOZ_OVERRIDE;
virtual PScreenManagerParent*
AllocPScreenManagerParent(uint32_t* aNumberOfScreens,
float* aSystemDefaultScale,

View File

@ -25,6 +25,7 @@ include protocol PImageBridge;
include protocol PMemoryReportRequest;
include protocol PMobileConnection;
include protocol PNecko;
include protocol PPrinting;
include protocol PScreenManager;
include protocol PSharedBufferManager;
include protocol PSms;
@ -349,6 +350,7 @@ prio(normal upto high) intr protocol PContent
manages PMemoryReportRequest;
manages PMobileConnection;
manages PNecko;
manages PPrinting;
manages PScreenManager;
manages PSms;
manages PSpeechSynthesis;
@ -553,6 +555,8 @@ parent:
PNecko();
PPrinting();
prio(high) sync PScreenManager()
returns (uint32_t numberOfScreens,
float systemDefaultScale,

View File

@ -110,6 +110,7 @@ LOCAL_INCLUDES += [
'/dom/mobilemessage/ipc',
'/dom/storage',
'/editor/libeditor',
'/embedding/components/printingui/ipc',
'/extensions/cookie',
'/extensions/spellcheck/src',
'/hal/sandbox',

View File

@ -15,11 +15,13 @@ LOCAL_INCLUDES += [
'../appstartup',
'../commandhandler',
'../find',
'../printingui/ipc',
'../webbrowserpersist',
'../windowwatcher',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
DEFINES['PROXY_PRINTING'] = 1
LOCAL_INCLUDES += [
'../printingui/win',
]
@ -29,7 +31,10 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
]
if CONFIG['MOZ_PDF_PRINTING']:
DEFINES['PROXY_PRINTING'] = 1
LOCAL_INCLUDES += [
'../printingui/unixshared',
]
include('/ipc/chromium/chromium-config.mozbuild')

View File

@ -20,6 +20,7 @@
#ifdef NS_PRINTING
#include "nsPrintingPromptService.h"
#include "nsPrintingPromptServiceProxy.h"
#endif
@ -38,6 +39,9 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsBaseCommandController)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDialogParamBlock)
#ifdef NS_PRINTING
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintingPromptService, Init)
#ifdef PROXY_PRINTING
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintingPromptServiceProxy, Init)
#endif
#endif
#endif
@ -62,8 +66,16 @@ static const mozilla::Module::CIDEntry kEmbeddingCIDs[] = {
#ifdef MOZ_XUL
{ &kNS_DIALOGPARAMBLOCK_CID, false, nullptr, nsDialogParamBlockConstructor },
#ifdef NS_PRINTING
#ifdef PROXY_PRINTING
{ &kNS_PRINTINGPROMPTSERVICE_CID, false, nullptr, nsPrintingPromptServiceConstructor,
mozilla::Module::MAIN_PROCESS_ONLY },
{ &kNS_PRINTINGPROMPTSERVICE_CID, false, nullptr, nsPrintingPromptServiceProxyConstructor,
mozilla::Module::CONTENT_PROCESS_ONLY },
#else
{ &kNS_PRINTINGPROMPTSERVICE_CID, false, nullptr, nsPrintingPromptServiceConstructor },
#endif
#endif
#endif
{ &kNS_WINDOWWATCHER_CID, false, nullptr, nsWindowWatcherConstructor },
{ &kNS_FIND_CID, false, nullptr, nsFindConstructor },

View File

@ -0,0 +1,101 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
include protocol PContent;
include protocol PBrowser;
namespace mozilla {
namespace embedding {
struct PrintData {
int32_t startPageRange;
int32_t endPageRange;
double edgeTop;
double edgeLeft;
double edgeBottom;
double edgeRight;
double marginTop;
double marginLeft;
double marginBottom;
double marginRight;
double unwriteableMarginTop;
double unwriteableMarginLeft;
double unwriteableMarginBottom;
double unwriteableMarginRight;
double scaling;
bool printBGColors;
bool printBGImages;
short printRange;
nsString title;
nsString docURL;
nsString headerStrLeft;
nsString headerStrCenter;
nsString headerStrRight;
nsString footerStrLeft;
nsString footerStrCenter;
nsString footerStrRight;
short howToEnableFrameUI;
bool isCancelled;
short printFrameTypeUsage;
short printFrameType;
bool printSilent;
bool shrinkToFit;
bool showPrintProgress;
nsString paperName;
short paperSizeType;
short paperData;
double paperWidth;
double paperHeight;
short paperSizeUnit;
nsString plexName;
nsString colorspace;
nsString resolutionName;
bool downloadFonts;
bool printReversed;
bool printInColor;
int32_t orientation;
nsString printCommand;
int32_t numCopies;
nsString printerName;
bool printToFile;
nsString toFileName;
short outputFormat;
int32_t printPageDelay;
int32_t resolution;
int32_t duplex;
bool isInitializedFromPrinter;
bool isInitializedFromPrefs;
bool persistMarginBoxSettings;
/* Windows-specific things */
nsString driverName;
nsString deviceName;
bool isFramesetDocument;
bool isFramesetFrameSelected;
bool isIFrameSelected;
bool isRangeSelection;
/* TODO: OS X specific things - specifically, an array of names for the
* document to be supplied by nsIWebBrowserPrint::enumerateDocumentNames
*/
};
sync protocol PPrinting
{
manager PContent;
parent:
sync ShowProgress(PBrowser browser, bool isForPrinting);
sync ShowPrintDialog(PBrowser browser, PrintData settings)
returns(PrintData modifiedSettings, bool success);
child:
__delete__();
};
} // namespace embedding
} // namespace mozilla

View File

@ -0,0 +1,143 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set sw=4 ts=8 et tw=80 : */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "PrintDataUtils.h"
#include "nsIPrintOptions.h"
#include "nsIPrintSettings.h"
#include "nsIServiceManager.h"
#include "nsIWebBrowserPrint.h"
#include "nsXPIDLString.h"
namespace mozilla {
namespace embedding {
/**
* MockWebBrowserPrint is a mostly useless implementation of nsIWebBrowserPrint,
* but wraps a PrintData so that it's able to return information to print
* settings dialogs that need an nsIWebBrowserPrint to interrogate.
*/
NS_IMPL_ISUPPORTS(MockWebBrowserPrint, nsIWebBrowserPrint);
MockWebBrowserPrint::MockWebBrowserPrint(PrintData aData)
: mData(aData)
{
MOZ_COUNT_CTOR(MockWebBrowserPrint);
}
MockWebBrowserPrint::~MockWebBrowserPrint()
{
MOZ_COUNT_DTOR(MockWebBrowserPrint);
}
NS_IMETHODIMP
MockWebBrowserPrint::GetGlobalPrintSettings(nsIPrintSettings **aGlobalPrintSettings)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
MockWebBrowserPrint::GetCurrentPrintSettings(nsIPrintSettings **aCurrentPrintSettings)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
MockWebBrowserPrint::GetCurrentChildDOMWindow(nsIDOMWindow **aCurrentPrintSettings)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
MockWebBrowserPrint::GetDoingPrint(bool *aDoingPrint)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
MockWebBrowserPrint::GetDoingPrintPreview(bool *aDoingPrintPreview)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
MockWebBrowserPrint::GetIsFramesetDocument(bool *aIsFramesetDocument)
{
*aIsFramesetDocument = mData.isFramesetDocument();
return NS_OK;
}
NS_IMETHODIMP
MockWebBrowserPrint::GetIsFramesetFrameSelected(bool *aIsFramesetFrameSelected)
{
*aIsFramesetFrameSelected = mData.isFramesetFrameSelected();
return NS_OK;
}
NS_IMETHODIMP
MockWebBrowserPrint::GetIsIFrameSelected(bool *aIsIFrameSelected)
{
*aIsIFrameSelected = mData.isIFrameSelected();
return NS_OK;
}
NS_IMETHODIMP
MockWebBrowserPrint::GetIsRangeSelection(bool *aIsRangeSelection)
{
*aIsRangeSelection = mData.isRangeSelection();
return NS_OK;
}
NS_IMETHODIMP
MockWebBrowserPrint::GetPrintPreviewNumPages(int32_t *aPrintPreviewNumPages)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
MockWebBrowserPrint::Print(nsIPrintSettings* aThePrintSettings,
nsIWebProgressListener* aWPListener)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
MockWebBrowserPrint::PrintPreview(nsIPrintSettings* aThePrintSettings,
nsIDOMWindow* aChildDOMWin,
nsIWebProgressListener* aWPListener)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
MockWebBrowserPrint::PrintPreviewNavigate(int16_t aNavType,
int32_t aPageNum)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
MockWebBrowserPrint::Cancel()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
MockWebBrowserPrint::EnumerateDocumentNames(uint32_t* aCount,
char16_t*** aResult)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
MockWebBrowserPrint::ExitPrintPreview()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
} // namespace embedding
} // namespace mozilla

View File

@ -0,0 +1,39 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set sw=4 ts=8 et tw=80 : */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_embedding_PrintDataUtils_h
#define mozilla_embedding_PrintDataUtils_h
#include "mozilla/embedding/PPrinting.h"
#include "nsIWebBrowserPrint.h"
/**
* nsIPrintSettings and nsIWebBrowserPrint information is sent back and forth
* across PPrinting via the PrintData struct. These are utilities for
* manipulating PrintData that can be used on either side of the communications
* channel.
*/
namespace mozilla {
namespace embedding {
class MockWebBrowserPrint MOZ_FINAL : public nsIWebBrowserPrint
{
public:
MockWebBrowserPrint(PrintData aData);
NS_DECL_ISUPPORTS
NS_DECL_NSIWEBBROWSERPRINT
private:
~MockWebBrowserPrint();
PrintData mData;
};
} // namespace embedding
} // namespace mozilla
#endif

View File

@ -0,0 +1,150 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set sw=4 ts=8 et tw=80 : */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/Element.h"
#include "mozilla/dom/TabParent.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "nsIDOMWindow.h"
#include "nsIPrintingPromptService.h"
#include "nsIPrintProgressParams.h"
#include "nsIServiceManager.h"
#include "nsIWebProgressListener.h"
#include "PrintingParent.h"
#include "nsIPrintOptions.h"
#include "PrintDataUtils.h"
using namespace mozilla;
using namespace mozilla::dom;
namespace mozilla {
namespace embedding {
bool
PrintingParent::RecvShowProgress(PBrowserParent* parent,
const bool& isForPrinting)
{
TabParent* tabParent = static_cast<TabParent*>(parent);
if (!tabParent) {
return true;
}
nsCOMPtr<Element> frameElement = tabParent->GetOwnerElement();
if (!frameElement) {
return true;
}
nsCOMPtr<nsIContent> frame(do_QueryInterface(frameElement));
if (!frame) {
return true;
}
nsCOMPtr<nsIDOMWindow> parentWin = do_QueryInterface(frame->OwnerDoc()->GetWindow());
if (!parentWin) {
return true;
}
nsCOMPtr<nsIPrintingPromptService> pps(do_GetService("@mozilla.org/embedcomp/printingprompt-service;1"));
if (!pps) {
return true;
}
nsCOMPtr<nsIWebProgressListener> printProgressListener;
nsCOMPtr<nsIPrintProgressParams> printProgressParams;
// TODO: What do I do with this thing?
bool doNotify = false;
pps->ShowProgress(parentWin, nullptr, nullptr, nullptr,
isForPrinting,
getter_AddRefs(printProgressListener),
getter_AddRefs(printProgressParams),
&doNotify);
return true;
}
bool
PrintingParent::RecvShowPrintDialog(PBrowserParent* parent,
const PrintData& data,
PrintData* retVal,
bool* success)
{
*success = false;
TabParent* tabParent = static_cast<TabParent*>(parent);
if (!tabParent) {
return true;
}
nsCOMPtr<Element> frameElement = tabParent->GetOwnerElement();
if (!frameElement) {
return true;
}
nsCOMPtr<nsIContent> frame(do_QueryInterface(frameElement));
if (!frame) {
return true;
}
nsCOMPtr<nsIDOMWindow> parentWin = do_QueryInterface(frame->OwnerDoc()->GetWindow());
if (!parentWin) {
return true;
}
nsCOMPtr<nsIPrintingPromptService> pps(do_GetService("@mozilla.org/embedcomp/printingprompt-service;1"));
if (!pps) {
return true;
}
// The initSettings we got can be wrapped using
// PrintDataUtils' MockWebBrowserPrint, which implements enough of
// nsIWebBrowserPrint to keep the dialogs happy.
nsCOMPtr<nsIWebBrowserPrint> wbp = new MockWebBrowserPrint(data);
nsresult rv;
nsCOMPtr<nsIPrintOptions> po = do_GetService("@mozilla.org/gfx/printsettings-service;1", &rv);
NS_ENSURE_SUCCESS(rv, true);
nsCOMPtr<nsIPrintSettings> settings;
rv = po->CreatePrintSettings(getter_AddRefs(settings));
NS_ENSURE_SUCCESS(rv, true);
rv = po->DeserializeToPrintSettings(data, settings);
NS_ENSURE_SUCCESS(rv, true);
rv = pps->ShowPrintDialog(parentWin, wbp, settings);
NS_ENSURE_SUCCESS(rv, true);
// And send it back.
PrintData result;
rv = po->SerializeToPrintData(settings, nullptr, &result);
NS_ENSURE_SUCCESS(rv, true);
*retVal = result;
*success = true;
return true;
}
void
PrintingParent::ActorDestroy(ActorDestroyReason aWhy)
{
}
MOZ_IMPLICIT PrintingParent::PrintingParent()
{
MOZ_COUNT_CTOR(PrintingParent);
}
MOZ_IMPLICIT PrintingParent::~PrintingParent()
{
MOZ_COUNT_DTOR(PrintingParent);
}
} // namespace embedding
} // namespace mozilla

View File

@ -0,0 +1,37 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim: set sw=4 ts=8 et tw=80 : */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_embedding_PrintingParent_h
#define mozilla_embedding_PrintingParent_h
#include "mozilla/embedding/PPrintingParent.h"
#include "mozilla/dom/PBrowserParent.h"
namespace mozilla {
namespace embedding {
class PrintingParent : public PPrintingParent
{
public:
virtual bool
RecvShowProgress(PBrowserParent* parent,
const bool& isForPrinting);
virtual bool
RecvShowPrintDialog(PBrowserParent* parent,
const PrintData& initSettings,
PrintData* retVal,
bool* success);
virtual void
ActorDestroy(ActorDestroyReason aWhy);
MOZ_IMPLICIT PrintingParent();
virtual ~PrintingParent();
};
} // namespace embedding
} // namespace mozilla
#endif

View File

@ -0,0 +1,25 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXPORTS.mozilla.embedding.printingui += [
'PrintingParent.h',
]
UNIFIED_SOURCES += [
'nsPrintingPromptServiceProxy.cpp',
'PrintDataUtils.cpp',
'PrintingParent.cpp',
]
IPDL_SOURCES += [
'PPrinting.ipdl',
]
include('/ipc/chromium/chromium-config.mozbuild')
FAIL_ON_WARNINGS = True
FINAL_LIBRARY = 'xul'

View File

@ -0,0 +1,135 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/TabChild.h"
#include "mozilla/unused.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeOwner.h"
#include "nsPIDOMWindow.h"
#include "nsPrintingPromptServiceProxy.h"
#include "nsIPrintingPromptService.h"
#include "PrintDataUtils.h"
#include "nsPrintOptionsImpl.h"
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::embedding;
NS_IMPL_ISUPPORTS(nsPrintingPromptServiceProxy, nsIPrintingPromptService)
nsPrintingPromptServiceProxy::nsPrintingPromptServiceProxy()
{
}
nsPrintingPromptServiceProxy::~nsPrintingPromptServiceProxy()
{
}
nsresult
nsPrintingPromptServiceProxy::Init()
{
mozilla::unused << ContentChild::GetSingleton()->SendPPrintingConstructor(this);
return NS_OK;
}
NS_IMETHODIMP
nsPrintingPromptServiceProxy::ShowPrintDialog(nsIDOMWindow *parent,
nsIWebBrowserPrint *webBrowserPrint,
nsIPrintSettings *printSettings)
{
NS_ENSURE_ARG(parent);
NS_ENSURE_ARG(webBrowserPrint);
NS_ENSURE_ARG(printSettings);
// Get the root docshell owner of this nsIDOMWindow, which
// should map to a TabChild, which we can then pass up to
// the parent.
nsCOMPtr<nsPIDOMWindow> pwin = do_QueryInterface(parent);
NS_ENSURE_STATE(pwin);
nsCOMPtr<nsIDocShell> docShell = pwin->GetDocShell();
NS_ENSURE_STATE(docShell);
nsCOMPtr<nsIDocShellTreeOwner> owner;
nsresult rv = docShell->GetTreeOwner(getter_AddRefs(owner));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsITabChild> tabchild = do_GetInterface(owner);
NS_ENSURE_STATE(tabchild);
TabChild* pBrowser = static_cast<TabChild*>(tabchild.get());
// Next, serialize the nsIWebBrowserPrint and nsIPrintSettings we were given.
nsCOMPtr<nsIPrintOptions> po =
do_GetService("@mozilla.org/gfx/printsettings-service;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
PrintData inSettings;
rv = po->SerializeToPrintData(printSettings, webBrowserPrint, &inSettings);
NS_ENSURE_SUCCESS(rv, rv);
PrintData modifiedSettings;
bool success;
mozilla::unused << SendShowPrintDialog(pBrowser, inSettings, &modifiedSettings, &success);
if (!success) {
// Something failed in the parent.
return NS_ERROR_FAILURE;
}
rv = po->DeserializeToPrintSettings(modifiedSettings, printSettings);
return NS_OK;
}
NS_IMETHODIMP
nsPrintingPromptServiceProxy::ShowProgress(nsIDOMWindow* parent,
nsIWebBrowserPrint* webBrowserPrint, // ok to be null
nsIPrintSettings* printSettings, // ok to be null
nsIObserver* openDialogObserver, // ok to be null
bool isForPrinting,
nsIWebProgressListener** webProgressListener,
nsIPrintProgressParams** printProgressParams,
bool* notifyOnOpen)
{
NS_ENSURE_ARG(parent);
NS_ENSURE_ARG(webProgressListener);
NS_ENSURE_ARG(printProgressParams);
NS_ENSURE_ARG(notifyOnOpen);
// Get the root docshell owner of this nsIDOMWindow, which
// should map to a TabChild, which we can then pass up to
// the parent.
nsCOMPtr<nsPIDOMWindow> pwin = do_QueryInterface(parent);
NS_ENSURE_STATE(pwin);
nsCOMPtr<nsIDocShell> docShell = pwin->GetDocShell();
NS_ENSURE_STATE(docShell);
nsCOMPtr<nsIDocShellTreeOwner> owner;
nsresult rv = docShell->GetTreeOwner(getter_AddRefs(owner));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsITabChild> tabchild = do_GetInterface(owner);
TabChild* pBrowser = static_cast<TabChild*>(tabchild.get());
mozilla::unused << SendShowProgress(pBrowser, isForPrinting);
return NS_OK;
}
NS_IMETHODIMP
nsPrintingPromptServiceProxy::ShowPageSetup(nsIDOMWindow *parent,
nsIPrintSettings *printSettings,
nsIObserver *aObs)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsPrintingPromptServiceProxy::ShowPrinterProperties(nsIDOMWindow *parent,
const char16_t *printerName,
nsIPrintSettings *printSettings)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

View File

@ -0,0 +1,27 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef __nsPrintingPromptServiceProxy_h
#define __nsPrintingPromptServiceProxy_h
#include "nsIPrintingPromptService.h"
#include "mozilla/embedding/PPrintingChild.h"
class nsPrintingPromptServiceProxy: public nsIPrintingPromptService,
public mozilla::embedding::PPrintingChild
{
virtual ~nsPrintingPromptServiceProxy();
public:
nsPrintingPromptServiceProxy();
nsresult Init();
NS_DECL_ISUPPORTS
NS_DECL_NSIPRINTINGPROMPTSERVICE
};
#endif

View File

@ -6,6 +6,8 @@
toolkit = CONFIG['MOZ_WIDGET_TOOLKIT']
DIRS += ['ipc']
if toolkit == 'windows':
DIRS += ['win']
elif toolkit == 'cocoa':

View File

@ -11,6 +11,10 @@ UNIFIED_SOURCES += [
'nsPrintProgressParams.cpp',
]
EXPORTS += [
'nsPrintDialogUtil.h',
]
FAIL_ON_WARNINGS = True
FINAL_LIBRARY = 'xul'

View File

@ -682,7 +682,7 @@ static UINT CALLBACK PrintHookProc(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM
// This function assumes that aPrintName has already been converted from
// unicode
//
static HGLOBAL CreateGlobalDevModeAndInit(const nsXPIDLString& aPrintName, nsIPrintSettings* aPS)
HGLOBAL CreateGlobalDevModeAndInit(const nsXPIDLString& aPrintName, nsIPrintSettings* aPS)
{
HGLOBAL hGlobalDevMode = nullptr;

View File

@ -9,4 +9,6 @@ nsresult NativeShowPrintDialog(HWND aHWnd,
nsIWebBrowserPrint* aWebBrowserPrint,
nsIPrintSettings* aPrintSettings);
HGLOBAL CreateGlobalDevModeAndInit(const nsXPIDLString& aPrintName, nsIPrintSettings* aPS);
#endif /* nsFlyOwnDialog_h___ */

View File

@ -1066,13 +1066,14 @@ nsViewManager::ProcessPendingUpdates()
return;
}
mPresShell->GetPresContext()->RefreshDriver()->RevokeViewManagerFlush();
// Flush things like reflows by calling WillPaint on observer presShells.
if (mPresShell) {
mPresShell->GetPresContext()->RefreshDriver()->RevokeViewManagerFlush();
CallWillPaintOnObservers();
ProcessPendingUpdatesForView(mRootView, true);
}
ProcessPendingUpdatesForView(mRootView, true);
}
void

View File

@ -29,7 +29,7 @@ nsPrintOptionsX::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName,
return NS_ERROR_NO_INTERFACE;
rv = printSettingsX->ReadPageFormatFromPrefs();
return rv;
return NS_OK;
}
nsresult nsPrintOptionsX::_CreatePrintSettings(nsIPrintSettings **_retval)

View File

@ -140,13 +140,10 @@ static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
{ &kNS_THEMERENDERER_CID, false, NULL, nsNativeThemeCocoaConstructor },
{ &kNS_SCREENMANAGER_CID, false, NULL, nsScreenManagerCocoaConstructor,
mozilla::Module::MAIN_PROCESS_ONLY },
{ &kNS_DEVICE_CONTEXT_SPEC_CID, false, NULL, nsDeviceContextSpecXConstructor,
mozilla::Module::MAIN_PROCESS_ONLY },
{ &kNS_PRINTSESSION_CID, false, NULL, nsPrintSessionConstructor,
mozilla::Module::MAIN_PROCESS_ONLY },
{ &kNS_DEVICE_CONTEXT_SPEC_CID, false, NULL, nsDeviceContextSpecXConstructor },
{ &kNS_PRINTSESSION_CID, false, NULL, nsPrintSessionConstructor },
{ &kNS_PRINTSETTINGSSERVICE_CID, false, NULL, nsPrintOptionsXConstructor },
{ &kNS_PRINTDIALOGSERVICE_CID, false, NULL, nsPrintDialogServiceXConstructor,
mozilla::Module::MAIN_PROCESS_ONLY },
{ &kNS_PRINTDIALOGSERVICE_CID, false, NULL, nsPrintDialogServiceXConstructor },
{ &kNS_IDLE_SERVICE_CID, false, NULL, nsIdleServiceXConstructor },
{ &kNS_SYSTEMALERTSSERVICE_CID, false, NULL, OSXNotificationCenterConstructor },
{ &kNS_NATIVEMENUSERVICE_CID, false, NULL, nsNativeMenuServiceXConstructor },
@ -180,13 +177,10 @@ static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
{ "@mozilla.org/chrome/chrome-native-theme;1", &kNS_THEMERENDERER_CID },
{ "@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID,
mozilla::Module::MAIN_PROCESS_ONLY },
{ "@mozilla.org/gfx/devicecontextspec;1", &kNS_DEVICE_CONTEXT_SPEC_CID,
mozilla::Module::MAIN_PROCESS_ONLY },
{ "@mozilla.org/gfx/printsession;1", &kNS_PRINTSESSION_CID,
mozilla::Module::MAIN_PROCESS_ONLY },
{ "@mozilla.org/gfx/devicecontextspec;1", &kNS_DEVICE_CONTEXT_SPEC_CID },
{ "@mozilla.org/gfx/printsession;1", &kNS_PRINTSESSION_CID },
{ "@mozilla.org/gfx/printsettings-service;1", &kNS_PRINTSETTINGSSERVICE_CID },
{ NS_PRINTDIALOGSERVICE_CONTRACTID, &kNS_PRINTDIALOGSERVICE_CID,
mozilla::Module::MAIN_PROCESS_ONLY },
{ NS_PRINTDIALOGSERVICE_CONTRACTID, &kNS_PRINTDIALOGSERVICE_CID },
{ "@mozilla.org/widget/idleservice;1", &kNS_IDLE_SERVICE_CID },
{ "@mozilla.org/system-alerts-service;1", &kNS_SYSTEMALERTSSERVICE_CID },
{ "@mozilla.org/widget/nativemenuservice;1", &kNS_NATIVEMENUSERVICE_CID },

View File

@ -219,14 +219,10 @@ static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
{ &kNS_THEMERENDERER_CID, false, nullptr, nsNativeThemeGTKConstructor },
#ifdef NS_PRINTING
{ &kNS_PRINTSETTINGSSERVICE_CID, false, nullptr, nsPrintOptionsGTKConstructor },
{ &kNS_PRINTER_ENUMERATOR_CID, false, nullptr, nsPrinterEnumeratorGTKConstructor,
Module::MAIN_PROCESS_ONLY },
{ &kNS_PRINTSESSION_CID, false, nullptr, nsPrintSessionConstructor,
Module::MAIN_PROCESS_ONLY },
{ &kNS_DEVICE_CONTEXT_SPEC_CID, false, nullptr, nsDeviceContextSpecGTKConstructor,
Module::MAIN_PROCESS_ONLY },
{ &kNS_PRINTDIALOGSERVICE_CID, false, nullptr, nsPrintDialogServiceGTKConstructor,
Module::MAIN_PROCESS_ONLY },
{ &kNS_PRINTER_ENUMERATOR_CID, false, nullptr, nsPrinterEnumeratorGTKConstructor },
{ &kNS_PRINTSESSION_CID, false, nullptr, nsPrintSessionConstructor },
{ &kNS_DEVICE_CONTEXT_SPEC_CID, false, nullptr, nsDeviceContextSpecGTKConstructor },
{ &kNS_PRINTDIALOGSERVICE_CID, false, nullptr, nsPrintDialogServiceGTKConstructor },
#endif
{ &kNS_IMAGE_TO_PIXBUF_CID, false, nullptr, nsImageToPixbufConstructor },
#if defined(MOZ_X11)
@ -256,14 +252,10 @@ static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
{ "@mozilla.org/chrome/chrome-native-theme;1", &kNS_THEMERENDERER_CID },
#ifdef NS_PRINTING
{ "@mozilla.org/gfx/printsettings-service;1", &kNS_PRINTSETTINGSSERVICE_CID },
{ "@mozilla.org/gfx/printerenumerator;1", &kNS_PRINTER_ENUMERATOR_CID,
Module::MAIN_PROCESS_ONLY },
{ "@mozilla.org/gfx/printsession;1", &kNS_PRINTSESSION_CID,
Module::MAIN_PROCESS_ONLY },
{ "@mozilla.org/gfx/devicecontextspec;1", &kNS_DEVICE_CONTEXT_SPEC_CID,
Module::MAIN_PROCESS_ONLY },
{ NS_PRINTDIALOGSERVICE_CONTRACTID, &kNS_PRINTDIALOGSERVICE_CID,
Module::MAIN_PROCESS_ONLY },
{ "@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
{ "@mozilla.org/widget/image-to-gdk-pixbuf;1", &kNS_IMAGE_TO_PIXBUF_CID },
#if defined(MOZ_X11)

View File

@ -102,6 +102,7 @@ EXPORTS += [
'nsIRollupListener.h',
'nsIWidget.h',
'nsIWidgetListener.h',
'nsPrintOptionsImpl.h',
'nsWidgetInitData.h',
'nsWidgetsCID.h',
]

View File

@ -8,14 +8,23 @@
%{ C++
struct nsFont;
namespace mozilla {
namespace embedding {
class PrintData;
}
}
%}
interface nsIStringEnumerator;
interface nsIWebBrowserPrint;
/**
* Native types
*/
[ref] native nsNativeFontRef(nsFont);
[ref] native PrintDataRef(const mozilla::embedding::PrintData);
[ptr] native PrintDataPtr(mozilla::embedding::PrintData);
/**
* Print options interface
@ -24,7 +33,7 @@ interface nsIStringEnumerator;
* John Keiser <jkeiser@netscape.com> and Roland Mainz
* <roland.mainz@informatik.med.uni-giessen.de> for futher details.
*/
[scriptable, uuid(92597c2b-109b-40bb-8f93-9b9acfa31de8)]
[scriptable, uuid(2ac74034-700e-40fd-8059-81d33223af58)]
interface nsIPrintOptions : nsISupports
{
@ -57,6 +66,39 @@ interface nsIPrintOptions : nsISupports
const short kNativeDataPrintRecord = 0;
[noscript] voidPtr GetNativeData(in short aDataType);
/**
* Given some nsIPrintSettings and (optionally) an nsIWebBrowserPrint, populates
* a PrintData representing them which can be sent over IPC. Values are only
* ever read from aSettings and aWBP.
*
* @param aSettings
* An nsIPrintSettings for a print job.
* @param aWBP (optional)
* The nsIWebBrowserPrint for the print job.
* @param data
* Pointer to a pre-existing PrintData to populate.
*
* @return nsresult
*/
[noscript] void SerializeToPrintData(in nsIPrintSettings aPrintSettings,
in nsIWebBrowserPrint aWebBrowserPrint,
in PrintDataPtr data);
/**
* This function is the opposite of SerializeToPrintData, in that it takes
* a PrintData, and populates a pre-existing nsIPrintSettings with the data
* from PrintData.
*
* @param PrintData
* Printing information sent through IPC.
* @param settings
* A pre-existing nsIPrintSettings to populate with the PrintData.
*
* @return nsresult
*/
[noscript] void DeserializeToPrintSettings(in PrintDataRef data,
in nsIPrintSettings aPrintSettings);
};
[scriptable, uuid(5e738fff-404c-4c94-9189-e8f2cce93e94)]

View File

@ -3,6 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/embedding/PPrinting.h"
#include "nsPrintOptionsImpl.h"
#include "nsReadableUtils.h"
#include "nsPrintSettingsImpl.h"
@ -22,8 +23,10 @@
#include "nsAutoPtr.h"
#include "mozilla/Preferences.h"
#include "nsPrintfCString.h"
#include "nsIWebBrowserPrint.h"
using namespace mozilla;
using namespace mozilla::embedding;
NS_IMPL_ISUPPORTS(nsPrintOptions, nsIPrintOptions, nsIPrintSettingsService)
@ -97,6 +100,221 @@ nsPrintOptions::Init()
return NS_OK;
}
NS_IMETHODIMP
nsPrintOptions::SerializeToPrintData(nsIPrintSettings* aSettings,
nsIWebBrowserPrint* aWBP,
PrintData* data)
{
aSettings->GetStartPageRange(&data->startPageRange());
aSettings->GetEndPageRange(&data->endPageRange());
aSettings->GetEdgeTop(&data->edgeTop());
aSettings->GetEdgeLeft(&data->edgeLeft());
aSettings->GetEdgeBottom(&data->edgeBottom());
aSettings->GetEdgeRight(&data->edgeRight());
aSettings->GetMarginTop(&data->marginTop());
aSettings->GetMarginLeft(&data->marginLeft());
aSettings->GetMarginBottom(&data->marginBottom());
aSettings->GetMarginRight(&data->marginRight());
aSettings->GetUnwriteableMarginTop(&data->unwriteableMarginTop());
aSettings->GetUnwriteableMarginLeft(&data->unwriteableMarginLeft());
aSettings->GetUnwriteableMarginBottom(&data->unwriteableMarginBottom());
aSettings->GetUnwriteableMarginRight(&data->unwriteableMarginRight());
aSettings->GetScaling(&data->scaling());
aSettings->GetPrintBGColors(&data->printBGColors());
aSettings->GetPrintBGImages(&data->printBGImages());
aSettings->GetPrintRange(&data->printRange());
// I have no idea if I'm doing this string copying correctly...
nsXPIDLString title;
aSettings->GetTitle(getter_Copies(title));
data->title() = title;
nsXPIDLString docURL;
aSettings->GetDocURL(getter_Copies(docURL));
data->docURL() = docURL;
// Header strings...
nsXPIDLString headerStrLeft;
aSettings->GetHeaderStrLeft(getter_Copies(headerStrLeft));
data->headerStrLeft() = headerStrLeft;
nsXPIDLString headerStrCenter;
aSettings->GetHeaderStrCenter(getter_Copies(headerStrCenter));
data->headerStrCenter() = headerStrCenter;
nsXPIDLString headerStrRight;
aSettings->GetHeaderStrRight(getter_Copies(headerStrRight));
data->headerStrRight() = headerStrRight;
// Footer strings...
nsXPIDLString footerStrLeft;
aSettings->GetFooterStrLeft(getter_Copies(footerStrLeft));
data->footerStrLeft() = footerStrLeft;
nsXPIDLString footerStrCenter;
aSettings->GetFooterStrCenter(getter_Copies(footerStrCenter));
data->footerStrCenter() = footerStrCenter;
nsXPIDLString footerStrRight;
aSettings->GetFooterStrRight(getter_Copies(footerStrRight));
data->footerStrRight() = footerStrRight;
aSettings->GetHowToEnableFrameUI(&data->howToEnableFrameUI());
aSettings->GetIsCancelled(&data->isCancelled());
aSettings->GetPrintFrameTypeUsage(&data->printFrameTypeUsage());
aSettings->GetPrintFrameType(&data->printFrameType());
aSettings->GetPrintSilent(&data->printSilent());
aSettings->GetShrinkToFit(&data->shrinkToFit());
aSettings->GetShowPrintProgress(&data->showPrintProgress());
nsXPIDLString paperName;
aSettings->GetPaperName(getter_Copies(paperName));
data->paperName() = paperName;
aSettings->GetPaperSizeType(&data->paperSizeType());
aSettings->GetPaperData(&data->paperData());
aSettings->GetPaperWidth(&data->paperWidth());
aSettings->GetPaperHeight(&data->paperHeight());
aSettings->GetPaperSizeUnit(&data->paperSizeUnit());
nsXPIDLString plexName;
aSettings->GetPlexName(getter_Copies(plexName));
data->plexName() = plexName;
nsXPIDLString colorspace;
aSettings->GetColorspace(getter_Copies(colorspace));
data->colorspace() = colorspace;
nsXPIDLString resolutionName;
aSettings->GetResolutionName(getter_Copies(resolutionName));
data->resolutionName() = resolutionName;
aSettings->GetDownloadFonts(&data->downloadFonts());
aSettings->GetPrintReversed(&data->printReversed());
aSettings->GetPrintInColor(&data->printInColor());
aSettings->GetOrientation(&data->orientation());
nsXPIDLString printCommand;
aSettings->GetPrintCommand(getter_Copies(printCommand));
data->printCommand() = printCommand;
aSettings->GetNumCopies(&data->numCopies());
nsXPIDLString printerName;
aSettings->GetPrinterName(getter_Copies(printerName));
data->printerName() = printerName;
aSettings->GetPrintToFile(&data->printToFile());
nsXPIDLString toFileName;
aSettings->GetToFileName(getter_Copies(toFileName));
data->toFileName() = toFileName;
aSettings->GetOutputFormat(&data->outputFormat());
aSettings->GetPrintPageDelay(&data->printPageDelay());
aSettings->GetResolution(&data->resolution());
aSettings->GetDuplex(&data->duplex());
aSettings->GetIsInitializedFromPrinter(&data->isInitializedFromPrinter());
aSettings->GetIsInitializedFromPrefs(&data->isInitializedFromPrefs());
aSettings->GetPersistMarginBoxSettings(&data->persistMarginBoxSettings());
return NS_OK;
}
NS_IMETHODIMP
nsPrintOptions::DeserializeToPrintSettings(const PrintData& data,
nsIPrintSettings* settings)
{
settings->SetStartPageRange(data.startPageRange());
settings->SetEndPageRange(data.endPageRange());
settings->SetEdgeTop(data.edgeTop());
settings->SetEdgeLeft(data.edgeLeft());
settings->SetEdgeBottom(data.edgeBottom());
settings->SetEdgeRight(data.edgeRight());
settings->SetMarginTop(data.marginTop());
settings->SetMarginLeft(data.marginLeft());
settings->SetMarginBottom(data.marginBottom());
settings->SetMarginRight(data.marginRight());
settings->SetUnwriteableMarginTop(data.unwriteableMarginTop());
settings->SetUnwriteableMarginLeft(data.unwriteableMarginLeft());
settings->SetUnwriteableMarginBottom(data.unwriteableMarginBottom());
settings->SetUnwriteableMarginRight(data.unwriteableMarginRight());
settings->SetScaling(data.scaling());
settings->SetPrintBGColors(data.printBGColors());
settings->SetPrintBGImages(data.printBGImages());
settings->SetPrintRange(data.printRange());
// I have no idea if I'm doing this string copying correctly...
settings->SetTitle(data.title().get());
settings->SetDocURL(data.docURL().get());
// Header strings...
settings->SetHeaderStrLeft(data.headerStrLeft().get());
settings->SetHeaderStrCenter(data.headerStrCenter().get());
settings->SetHeaderStrRight(data.headerStrRight().get());
// Footer strings...
settings->SetFooterStrLeft(data.footerStrLeft().get());
settings->SetFooterStrCenter(data.footerStrCenter().get());
settings->SetFooterStrRight(data.footerStrRight().get());
settings->SetHowToEnableFrameUI(data.howToEnableFrameUI());
settings->SetIsCancelled(data.isCancelled());
settings->SetPrintFrameTypeUsage(data.printFrameTypeUsage());
settings->SetPrintFrameType(data.printFrameType());
settings->SetPrintSilent(data.printSilent());
settings->SetShrinkToFit(data.shrinkToFit());
settings->SetShowPrintProgress(data.showPrintProgress());
settings->SetPaperName(data.paperName().get());
settings->SetPaperSizeType(data.paperSizeType());
settings->SetPaperData(data.paperData());
settings->SetPaperWidth(data.paperWidth());
settings->SetPaperHeight(data.paperHeight());
settings->SetPaperSizeUnit(data.paperSizeUnit());
settings->SetPlexName(data.plexName().get());
settings->SetColorspace(data.colorspace().get());
settings->SetResolutionName(data.resolutionName().get());
settings->SetDownloadFonts(data.downloadFonts());
settings->SetPrintReversed(data.printReversed());
settings->SetPrintInColor(data.printInColor());
settings->SetOrientation(data.orientation());
settings->SetPrintCommand(data.printCommand().get());
settings->SetNumCopies(data.numCopies());
settings->SetPrinterName(data.printerName().get());
settings->SetPrintToFile(data.printToFile());
settings->SetToFileName(data.toFileName().get());
settings->SetOutputFormat(data.outputFormat());
settings->SetPrintPageDelay(data.printPageDelay());
settings->SetResolution(data.resolution());
settings->SetDuplex(data.duplex());
settings->SetIsInitializedFromPrinter(data.isInitializedFromPrinter());
settings->SetIsInitializedFromPrefs(data.isInitializedFromPrefs());
settings->SetPersistMarginBoxSettings(data.persistMarginBoxSettings());
return NS_OK;
}
NS_IMETHODIMP
nsPrintOptions::ShowPrintSetupDialog(nsIPrintSettings *aPS)
{

View File

@ -7,12 +7,16 @@
#ifndef nsPrintOptionsImpl_h__
#define nsPrintOptionsImpl_h__
#include "mozilla/embedding/PPrinting.h"
#include "nsCOMPtr.h"
#include "nsIPrintOptions.h"
#include "nsIPrintSettingsService.h"
#include "nsString.h"
#include "nsFont.h"
class nsIPrintSettings;
class nsIWebBrowserPrint;
/**
* Class nsPrintOptions
*/

View File

@ -5,11 +5,16 @@
#include "nsCOMPtr.h"
#include "nsPrintOptionsWin.h"
#include "nsPrintSettingsWin.h"
#include "nsPrintDialogUtil.h"
#include "nsGfxCIID.h"
#include "nsIServiceManager.h"
#include "nsIWebBrowserPrint.h"
const char kPrinterEnumeratorContractID[] = "@mozilla.org/gfx/printerenumerator;1";
using namespace mozilla::embedding;
/** ---------------------------------------------------
* See documentation in nsPrintOptionsWin.h
* @update 6/21/00 dwc
@ -27,6 +32,71 @@ nsPrintOptionsWin::~nsPrintOptionsWin()
{
}
NS_IMETHODIMP
nsPrintOptionsWin::SerializeToPrintData(nsIPrintSettings* aSettings,
nsIWebBrowserPrint* aWBP,
PrintData* data)
{
nsresult rv = nsPrintOptions::SerializeToPrintData(aSettings, aWBP, data);
NS_ENSURE_SUCCESS(rv, rv);
// Windows wants this information for its print dialogs
if (aWBP) {
aWBP->GetIsFramesetDocument(&data->isFramesetDocument());
aWBP->GetIsFramesetFrameSelected(&data->isFramesetFrameSelected());
aWBP->GetIsIFrameSelected(&data->isIFrameSelected());
aWBP->GetIsRangeSelection(&data->isRangeSelection());
}
nsCOMPtr<nsIPrintSettingsWin> psWin = do_QueryInterface(aSettings);
if (!psWin) {
return NS_ERROR_FAILURE;
}
char16_t* deviceName;
char16_t* driverName;
psWin->GetDeviceName(&deviceName);
psWin->GetDriverName(&driverName);
data->deviceName().Assign(deviceName);
data->driverName().Assign(driverName);
free(deviceName);
free(driverName);
return NS_OK;
}
NS_IMETHODIMP
nsPrintOptionsWin::DeserializeToPrintSettings(const PrintData& data,
nsIPrintSettings* settings)
{
nsresult rv = nsPrintOptions::DeserializeToPrintSettings(data, settings);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPrintSettingsWin> psWin = do_QueryInterface(settings);
if (!settings) {
return NS_ERROR_FAILURE;
}
psWin->SetDeviceName(data.deviceName().get());
psWin->SetDriverName(data.driverName().get());
// We also need to prepare a DevMode and stuff it into our newly
// created nsIPrintSettings...
nsXPIDLString printerName;
settings->GetPrinterName(getter_Copies(printerName));
HGLOBAL gDevMode = CreateGlobalDevModeAndInit(printerName, settings);
LPDEVMODEW devMode = (LPDEVMODEW)::GlobalLock(gDevMode);
psWin->SetDevMode(devMode);
::GlobalUnlock(gDevMode);
::GlobalFree(gDevMode);
return NS_OK;
}
/* nsIPrintSettings CreatePrintSettings (); */
nsresult nsPrintOptionsWin::_CreatePrintSettings(nsIPrintSettings **_retval)
{

View File

@ -7,8 +7,11 @@
#ifndef nsPrintOptionsWin_h__
#define nsPrintOptionsWin_h__
#include "mozilla/embedding/PPrinting.h"
#include "nsPrintOptionsImpl.h"
class nsIPrintSettings;
class nsIWebBrowserPrint;
//*****************************************************************************
//*** nsPrintOptions
@ -19,6 +22,12 @@ public:
nsPrintOptionsWin();
virtual ~nsPrintOptionsWin();
NS_IMETHODIMP SerializeToPrintData(nsIPrintSettings* aSettings,
nsIWebBrowserPrint* aWBP,
mozilla::embedding::PrintData* data);
NS_IMETHODIMP DeserializeToPrintSettings(const mozilla::embedding::PrintData& data,
nsIPrintSettings* settings);
virtual nsresult _CreatePrintSettings(nsIPrintSettings **_retval);
};

View File

@ -244,12 +244,9 @@ static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
#endif
#ifdef NS_PRINTING
{ &kNS_PRINTSETTINGSSERVICE_CID, false, nullptr, nsPrintOptionsWinConstructor },
{ &kNS_PRINTER_ENUMERATOR_CID, false, nullptr, nsPrinterEnumeratorWinConstructor,
Module::MAIN_PROCESS_ONLY },
{ &kNS_PRINTSESSION_CID, false, nullptr, nsPrintSessionConstructor,
Module::MAIN_PROCESS_ONLY },
{ &kNS_DEVICE_CONTEXT_SPEC_CID, false, nullptr, nsDeviceContextSpecWinConstructor,
Module::MAIN_PROCESS_ONLY },
{ &kNS_PRINTER_ENUMERATOR_CID, false, nullptr, nsPrinterEnumeratorWinConstructor },
{ &kNS_PRINTSESSION_CID, false, nullptr, nsPrintSessionConstructor },
{ &kNS_DEVICE_CONTEXT_SPEC_CID, false, nullptr, nsDeviceContextSpecWinConstructor },
#endif
{ nullptr }
};
@ -282,12 +279,9 @@ static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
#endif
#ifdef NS_PRINTING
{ "@mozilla.org/gfx/printsettings-service;1", &kNS_PRINTSETTINGSSERVICE_CID },
{ "@mozilla.org/gfx/printerenumerator;1", &kNS_PRINTER_ENUMERATOR_CID,
Module::MAIN_PROCESS_ONLY },
{ "@mozilla.org/gfx/printsession;1", &kNS_PRINTSESSION_CID,
Module::MAIN_PROCESS_ONLY },
{ "@mozilla.org/gfx/devicecontextspec;1", &kNS_DEVICE_CONTEXT_SPEC_CID,
Module::MAIN_PROCESS_ONLY },
{ "@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 },
#endif
{ nullptr }
};