Bug 1826326 [wpt PR 39360] - Get rid of ResourceWarnings produced by the tests, a...
[gecko.git] / widget / windows / nsDeviceContextSpecWin.h
blob74baeda5493106784e929325478365d5f4c778c1
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___
9 #include "nsCOMPtr.h"
10 #include "nsIDeviceContextSpec.h"
11 #include "nsPrinterListBase.h"
12 #include "nsIPrintSettings.h"
13 #include <windows.h>
14 #include "mozilla/Attributes.h"
15 #include "mozilla/RefPtr.h"
16 #include "mozilla/gfx/PrintPromise.h"
18 class nsIFile;
19 class nsIWidget;
21 class nsDeviceContextSpecWin : public nsIDeviceContextSpec {
22 public:
23 nsDeviceContextSpecWin();
25 NS_DECL_ISUPPORTS
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 {
31 return NS_OK;
33 RefPtr<mozilla::gfx::PrintEndDocumentPromise> EndDocument() override;
34 NS_IMETHOD BeginPage() 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);
52 // helper functions
53 nsresult GetDataFromPrinter(const nsAString& aName,
54 nsIPrintSettings* aPS = nullptr);
56 protected:
57 void SetDeviceName(const nsAString& aDeviceName);
58 void SetDriverName(const nsAString& aDriverName);
59 void SetDevMode(LPDEVMODEW aDevMode);
61 virtual ~nsDeviceContextSpecWin();
63 nsString mDriverName;
64 nsString mDeviceName;
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 //-------------------------------------------------------------------------
75 // Printer List
76 //-------------------------------------------------------------------------
77 class nsPrinterListWin final : public nsPrinterListBase {
78 public:
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;
87 protected:
88 nsresult SystemDefaultPrinterName(nsAString&) const final;
90 mozilla::Maybe<PrinterInfo> PrinterByName(nsString) const final;
91 mozilla::Maybe<PrinterInfo> PrinterBySystemName(
92 nsString aPrinterName) const final;
94 private:
95 ~nsPrinterListWin();
98 #endif