Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsDeviceContextSpecWin_h___ |
michael@0 | 7 | #define nsDeviceContextSpecWin_h___ |
michael@0 | 8 | |
michael@0 | 9 | #include "nsCOMPtr.h" |
michael@0 | 10 | #include "nsIDeviceContextSpec.h" |
michael@0 | 11 | #include "nsIPrintOptions.h" // For nsIPrinterEnumerator |
michael@0 | 12 | #include "nsIPrintSettings.h" |
michael@0 | 13 | #include "nsISupportsPrimitives.h" |
michael@0 | 14 | #include <windows.h> |
michael@0 | 15 | #include "mozilla/Attributes.h" |
michael@0 | 16 | |
michael@0 | 17 | class nsIWidget; |
michael@0 | 18 | |
michael@0 | 19 | class nsDeviceContextSpecWin : public nsIDeviceContextSpec |
michael@0 | 20 | { |
michael@0 | 21 | public: |
michael@0 | 22 | nsDeviceContextSpecWin(); |
michael@0 | 23 | |
michael@0 | 24 | NS_DECL_ISUPPORTS |
michael@0 | 25 | |
michael@0 | 26 | NS_IMETHOD GetSurfaceForPrinter(gfxASurface **surface); |
michael@0 | 27 | NS_IMETHOD BeginDocument(const nsAString& aTitle, |
michael@0 | 28 | char16_t* aPrintToFileName, |
michael@0 | 29 | int32_t aStartPage, |
michael@0 | 30 | int32_t aEndPage) { return NS_OK; } |
michael@0 | 31 | NS_IMETHOD EndDocument() { return NS_OK; } |
michael@0 | 32 | NS_IMETHOD BeginPage() { return NS_OK; } |
michael@0 | 33 | NS_IMETHOD EndPage() { return NS_OK; } |
michael@0 | 34 | |
michael@0 | 35 | NS_IMETHOD Init(nsIWidget* aWidget, nsIPrintSettings* aPS, bool aIsPrintPreview); |
michael@0 | 36 | |
michael@0 | 37 | void GetDriverName(wchar_t *&aDriverName) const { aDriverName = mDriverName; } |
michael@0 | 38 | void GetDeviceName(wchar_t *&aDeviceName) const { aDeviceName = mDeviceName; } |
michael@0 | 39 | |
michael@0 | 40 | // The GetDevMode will return a pointer to a DevMode |
michael@0 | 41 | // whether it is from the Global memory handle or just the DevMode |
michael@0 | 42 | // To get the DevMode from the Global memory Handle it must lock it |
michael@0 | 43 | // So this call must be paired with a call to UnlockGlobalHandle |
michael@0 | 44 | void GetDevMode(LPDEVMODEW &aDevMode); |
michael@0 | 45 | |
michael@0 | 46 | // helper functions |
michael@0 | 47 | nsresult GetDataFromPrinter(char16ptr_t aName, nsIPrintSettings* aPS = nullptr); |
michael@0 | 48 | |
michael@0 | 49 | static nsresult SetPrintSettingsFromDevMode(nsIPrintSettings* aPrintSettings, |
michael@0 | 50 | LPDEVMODEW aDevMode); |
michael@0 | 51 | |
michael@0 | 52 | protected: |
michael@0 | 53 | |
michael@0 | 54 | void SetDeviceName(char16ptr_t aDeviceName); |
michael@0 | 55 | void SetDriverName(char16ptr_t aDriverName); |
michael@0 | 56 | void SetDevMode(LPDEVMODEW aDevMode); |
michael@0 | 57 | |
michael@0 | 58 | void SetupPaperInfoFromSettings(); |
michael@0 | 59 | |
michael@0 | 60 | virtual ~nsDeviceContextSpecWin(); |
michael@0 | 61 | |
michael@0 | 62 | wchar_t* mDriverName; |
michael@0 | 63 | wchar_t* mDeviceName; |
michael@0 | 64 | LPDEVMODEW mDevMode; |
michael@0 | 65 | |
michael@0 | 66 | nsCOMPtr<nsIPrintSettings> mPrintSettings; |
michael@0 | 67 | }; |
michael@0 | 68 | |
michael@0 | 69 | |
michael@0 | 70 | //------------------------------------------------------------------------- |
michael@0 | 71 | // Printer Enumerator |
michael@0 | 72 | //------------------------------------------------------------------------- |
michael@0 | 73 | class nsPrinterEnumeratorWin MOZ_FINAL : public nsIPrinterEnumerator |
michael@0 | 74 | { |
michael@0 | 75 | public: |
michael@0 | 76 | nsPrinterEnumeratorWin(); |
michael@0 | 77 | ~nsPrinterEnumeratorWin(); |
michael@0 | 78 | NS_DECL_ISUPPORTS |
michael@0 | 79 | NS_DECL_NSIPRINTERENUMERATOR |
michael@0 | 80 | }; |
michael@0 | 81 | |
michael@0 | 82 | #endif |