1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsDeviceContextSpecWin_h___
7 #define nsDeviceContextSpecWin_h___
10 #include "nsIDeviceContextSpec.h"
11 #include "nsPrinterListBase.h"
12 #include "nsIPrintSettings.h"
14 #include "mozilla/Attributes.h"
15 #include "mozilla/RefPtr.h"
16 #include "mozilla/gfx/PrintPromise.h"
21 class nsDeviceContextSpecWin
: public nsIDeviceContextSpec
{
23 nsDeviceContextSpecWin();
27 already_AddRefed
<PrintTarget
> MakePrintTarget() final
;
28 NS_IMETHOD
BeginDocument(const nsAString
& aTitle
,
29 const nsAString
& aPrintToFileName
,
30 int32_t aStartPage
, int32_t aEndPage
) override
{
33 RefPtr
<mozilla::gfx::PrintEndDocumentPromise
> EndDocument() override
;
34 NS_IMETHOD
BeginPage(const IntSize
& aSizeInPoints
) override
{ return NS_OK
; }
35 NS_IMETHOD
EndPage() override
{ return NS_OK
; }
37 NS_IMETHOD
Init(nsIPrintSettings
* aPS
, bool aIsPrintPreview
) override
;
39 void GetDriverName(nsAString
& aDriverName
) const {
40 aDriverName
= mDriverName
;
42 void GetDeviceName(nsAString
& aDeviceName
) const {
43 aDeviceName
= mDeviceName
;
46 // The GetDevMode will return a pointer to a DevMode
47 // whether it is from the Global memory handle or just the DevMode
48 // To get the DevMode from the Global memory Handle it must lock it
49 // So this call must be paired with a call to UnlockGlobalHandle
50 void GetDevMode(LPDEVMODEW
& aDevMode
);
53 nsresult
GetDataFromPrinter(const nsAString
& aName
,
54 nsIPrintSettings
* aPS
= nullptr);
57 void SetDeviceName(const nsAString
& aDeviceName
);
58 void SetDriverName(const nsAString
& aDriverName
);
59 void SetDevMode(LPDEVMODEW aDevMode
);
61 virtual ~nsDeviceContextSpecWin();
65 LPDEVMODEW mDevMode
= nullptr;
67 int16_t mOutputFormat
= nsIPrintSettings::kOutputFormatNative
;
69 // A temporary file to create an "anonymous" print target. See bug 1664253,
70 // this should ideally not be needed.
71 nsCOMPtr
<nsIFile
> mTempFile
;
74 //-------------------------------------------------------------------------
76 //-------------------------------------------------------------------------
77 class nsPrinterListWin final
: public nsPrinterListBase
{
79 NS_IMETHOD
InitPrintSettingsFromPrinter(const nsAString
&,
80 nsIPrintSettings
*) final
;
82 nsTArray
<PrinterInfo
> Printers() const final
;
83 RefPtr
<nsIPrinter
> CreatePrinter(PrinterInfo
) const final
;
85 nsPrinterListWin() = default;
88 nsresult
SystemDefaultPrinterName(nsAString
&) const final
;
90 mozilla::Maybe
<PrinterInfo
> PrinterByName(nsString
) const final
;
91 mozilla::Maybe
<PrinterInfo
> PrinterBySystemName(
92 nsString aPrinterName
) const final
;