Bug 1692971 [wpt PR 27638] - WebKit export of https://bugs.webkit.org/show_bug.cgi...
[gecko.git] / widget / nsPrintSettingsService.h
blob75ac930c6b5e5832d8ca3f1d32783c4d1cf57ca6
1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsPrintSettingsService_h
8 #define nsPrintSettingsService_h
10 #include "mozilla/embedding/PPrinting.h"
11 #include "nsCOMPtr.h"
12 #include "nsIPrintSettings.h"
13 #include "nsIPrintSettingsService.h"
14 #include "nsString.h"
15 #include "nsFont.h"
17 /**
18 * Class nsPrintSettingsService. Base class for the platform specific widget
19 * subclasses to inherit from.
21 class nsPrintSettingsService : public nsIPrintSettingsService {
22 public:
23 NS_DECL_ISUPPORTS
24 NS_DECL_NSIPRINTSETTINGSSERVICE
26 nsPrintSettingsService() = default;
28 /**
29 * method Init
30 * Initializes member variables. Every consumer that does manual
31 * creation (instead of do_CreateInstance) needs to call this method
32 * immediately after instantiation.
34 virtual nsresult Init();
36 private:
37 // Copying is not supported.
38 nsPrintSettingsService(const nsPrintSettingsService& x) = delete;
39 nsPrintSettingsService& operator=(const nsPrintSettingsService& x) = delete;
41 protected:
42 virtual ~nsPrintSettingsService() = default;
44 void ReadBitFieldPref(const char* aPrefId, int32_t anOption);
45 void WriteBitFieldPref(const char* aPrefId, int32_t anOption);
46 void ReadJustification(const char* aPrefId, int16_t& aJust,
47 int16_t aInitValue);
48 void WriteJustification(const char* aPrefId, int16_t aJust);
49 void ReadInchesToTwipsPref(const char* aPrefId, int32_t& aTwips,
50 const char* aMarginPref);
51 void WriteInchesFromTwipsPref(const char* aPrefId, int32_t aTwips);
52 void ReadInchesIntToTwipsPref(const char* aPrefId, int32_t& aTwips,
53 const char* aMarginPref);
54 void WriteInchesIntFromTwipsPref(const char* aPrefId, int32_t aTwips);
56 nsresult ReadPrefDouble(const char* aPrefId, double& aVal);
57 nsresult WritePrefDouble(const char* aPrefId, double aVal);
59 /**
60 * method ReadPrefs
61 * @param aPS a pointer to the printer settings
62 * @param aPrinterName the name of the printer for which to read prefs
63 * @param aFlags flag specifying which prefs to read
65 virtual nsresult ReadPrefs(nsIPrintSettings* aPS,
66 const nsAString& aPrinterName, uint32_t aFlags);
67 /**
68 * method WritePrefs
69 * @param aPS a pointer to the printer settings
70 * @param aPrinterName the name of the printer for which to write prefs
71 * @param aFlags flag specifying which prefs to read
73 virtual nsresult WritePrefs(nsIPrintSettings* aPS,
74 const nsAString& aPrinterName, uint32_t aFlags);
76 const char* GetPrefName(const char* aPrefName, const nsAString& aPrinterName);
78 /**
79 * method _CreatePrintSettings
80 * May be implemented by the platform-specific derived class
82 * @return printer settings instance
84 virtual nsresult _CreatePrintSettings(nsIPrintSettings** _retval) = 0;
86 // Members
87 nsCString mPrefName;
90 #endif // nsPrintSettingsService_h