|
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/. */ |
|
5 |
|
6 #ifndef nsDeviceContextSpecWin_h___ |
|
7 #define nsDeviceContextSpecWin_h___ |
|
8 |
|
9 #include "nsCOMPtr.h" |
|
10 #include "nsIDeviceContextSpec.h" |
|
11 #include "nsIPrintOptions.h" // For nsIPrinterEnumerator |
|
12 #include "nsIPrintSettings.h" |
|
13 #include "nsISupportsPrimitives.h" |
|
14 #include <windows.h> |
|
15 #include "mozilla/Attributes.h" |
|
16 |
|
17 class nsIWidget; |
|
18 |
|
19 class nsDeviceContextSpecWin : public nsIDeviceContextSpec |
|
20 { |
|
21 public: |
|
22 nsDeviceContextSpecWin(); |
|
23 |
|
24 NS_DECL_ISUPPORTS |
|
25 |
|
26 NS_IMETHOD GetSurfaceForPrinter(gfxASurface **surface); |
|
27 NS_IMETHOD BeginDocument(const nsAString& aTitle, |
|
28 char16_t* aPrintToFileName, |
|
29 int32_t aStartPage, |
|
30 int32_t aEndPage) { return NS_OK; } |
|
31 NS_IMETHOD EndDocument() { return NS_OK; } |
|
32 NS_IMETHOD BeginPage() { return NS_OK; } |
|
33 NS_IMETHOD EndPage() { return NS_OK; } |
|
34 |
|
35 NS_IMETHOD Init(nsIWidget* aWidget, nsIPrintSettings* aPS, bool aIsPrintPreview); |
|
36 |
|
37 void GetDriverName(wchar_t *&aDriverName) const { aDriverName = mDriverName; } |
|
38 void GetDeviceName(wchar_t *&aDeviceName) const { aDeviceName = mDeviceName; } |
|
39 |
|
40 // The GetDevMode will return a pointer to a DevMode |
|
41 // whether it is from the Global memory handle or just the DevMode |
|
42 // To get the DevMode from the Global memory Handle it must lock it |
|
43 // So this call must be paired with a call to UnlockGlobalHandle |
|
44 void GetDevMode(LPDEVMODEW &aDevMode); |
|
45 |
|
46 // helper functions |
|
47 nsresult GetDataFromPrinter(char16ptr_t aName, nsIPrintSettings* aPS = nullptr); |
|
48 |
|
49 static nsresult SetPrintSettingsFromDevMode(nsIPrintSettings* aPrintSettings, |
|
50 LPDEVMODEW aDevMode); |
|
51 |
|
52 protected: |
|
53 |
|
54 void SetDeviceName(char16ptr_t aDeviceName); |
|
55 void SetDriverName(char16ptr_t aDriverName); |
|
56 void SetDevMode(LPDEVMODEW aDevMode); |
|
57 |
|
58 void SetupPaperInfoFromSettings(); |
|
59 |
|
60 virtual ~nsDeviceContextSpecWin(); |
|
61 |
|
62 wchar_t* mDriverName; |
|
63 wchar_t* mDeviceName; |
|
64 LPDEVMODEW mDevMode; |
|
65 |
|
66 nsCOMPtr<nsIPrintSettings> mPrintSettings; |
|
67 }; |
|
68 |
|
69 |
|
70 //------------------------------------------------------------------------- |
|
71 // Printer Enumerator |
|
72 //------------------------------------------------------------------------- |
|
73 class nsPrinterEnumeratorWin MOZ_FINAL : public nsIPrinterEnumerator |
|
74 { |
|
75 public: |
|
76 nsPrinterEnumeratorWin(); |
|
77 ~nsPrinterEnumeratorWin(); |
|
78 NS_DECL_ISUPPORTS |
|
79 NS_DECL_NSIPRINTERENUMERATOR |
|
80 }; |
|
81 |
|
82 #endif |