1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- 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/. */ 6 7 #ifndef nsPrintSettingsService_h 8 #define nsPrintSettingsService_h 9 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" 16 17 /** 18 * Class nsPrintSettingsService. Base class for the platform specific widget 19 * subclasses to inherit from. 20 */ 21 class nsPrintSettingsService : public nsIPrintSettingsService { 22 public: 23 NS_DECL_ISUPPORTS 24 NS_DECL_NSIPRINTSETTINGSSERVICE 25 26 nsPrintSettingsService() = default; 27 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. 33 */ 34 virtual nsresult Init(); 35 36 private: 37 // Copying is not supported. 38 nsPrintSettingsService(const nsPrintSettingsService& x) = delete; 39 nsPrintSettingsService& operator=(const nsPrintSettingsService& x) = delete; 40 41 protected: 42 virtual ~nsPrintSettingsService() = default; 43 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); 55 56 nsresult ReadPrefDouble(const char* aPrefId, double& aVal); 57 nsresult WritePrefDouble(const char* aPrefId, double aVal); 58 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 64 */ 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 72 */ 73 virtual nsresult WritePrefs(nsIPrintSettings* aPS, 74 const nsAString& aPrinterName, uint32_t aFlags); 75 76 const char* GetPrefName(const char* aPrefName, const nsAString& aPrinterName); 77 78 /** 79 * method _CreatePrintSettings 80 * May be implemented by the platform-specific derived class 81 * 82 * @return printer settings instance 83 */ 84 virtual nsresult _CreatePrintSettings(nsIPrintSettings** _retval) = 0; 85 86 // Members 87 nsCString mPrefName; 88 }; 89 90 #endif // nsPrintSettingsService_h 91