Bug 1860823 [wpt PR 42716] - Update wpt metadata, a=testonly
[gecko.git] / widget / nsPrintSettingsService.h
blob43965455a12f8ebd124bbb34764f4c123aef78fe
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 "nsCOMPtr.h"
11 #include "nsIPrintSettings.h"
12 #include "nsIPrintSettingsService.h"
13 #include "nsString.h"
14 #include "nsFont.h"
16 /**
17 * Class nsPrintSettingsService. Base class for the platform specific widget
18 * subclasses to inherit from.
20 class nsPrintSettingsService : public nsIPrintSettingsService {
21 public:
22 NS_DECL_ISUPPORTS
23 NS_DECL_NSIPRINTSETTINGSSERVICE
25 nsPrintSettingsService() = default;
27 /**
28 * method Init
29 * Initializes member variables. Every consumer that does manual
30 * creation (instead of do_CreateInstance) needs to call this method
31 * immediately after instantiation.
33 virtual nsresult Init();
35 private:
36 // Copying is not supported.
37 nsPrintSettingsService(const nsPrintSettingsService& x) = delete;
38 nsPrintSettingsService& operator=(const nsPrintSettingsService& x) = delete;
40 protected:
41 virtual ~nsPrintSettingsService() = default;
43 void ReadBitFieldPref(const char* aPrefId, int32_t anOption);
44 void WriteBitFieldPref(const char* aPrefId, int32_t anOption);
45 void ReadJustification(const char* aPrefId, int16_t& aJust,
46 int16_t aInitValue);
47 void WriteJustification(const char* aPrefId, int16_t aJust);
48 bool ReadInchesToTwipsPref(const char* aPrefId, int32_t& aTwips);
49 void WriteInchesFromTwipsPref(const char* aPrefId, int32_t aTwips);
50 bool ReadInchesIntToTwipsPref(const char* aPrefId, int32_t& aTwips);
51 void WriteInchesIntFromTwipsPref(const char* aPrefId, int32_t aTwips);
53 nsresult ReadPrefDouble(const char* aPrefId, double& aVal);
54 nsresult WritePrefDouble(const char* aPrefId, double aVal);
56 /**
57 * method ReadPrefs
58 * @param aPS a pointer to the printer settings
59 * @param aPrinterName the name of the printer for which to read prefs
60 * @param aFlags flag specifying which prefs to read
62 virtual nsresult ReadPrefs(nsIPrintSettings* aPS,
63 const nsAString& aPrinterName, uint32_t aFlags);
64 /**
65 * method WritePrefs
66 * @param aPS a pointer to the printer settings
67 * @param aPrinterName the name of the printer for which to write prefs
68 * @param aFlags flag specifying which prefs to read
70 virtual nsresult WritePrefs(nsIPrintSettings* aPS,
71 const nsAString& aPrinterName, uint32_t aFlags);
73 const char* GetPrefName(const char* aPrefName, const nsAString& aPrinterName);
75 /**
76 * method _CreatePrintSettings
77 * May be implemented by the platform-specific derived class
79 * @return printer settings instance
81 virtual nsresult _CreatePrintSettings(nsIPrintSettings** _retval) = 0;
83 // Members
84 nsCString mPrefName;
87 #endif // nsPrintSettingsService_h