nsPrintOptionsImpl.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. #ifndef nsPrintOptionsImpl_h__
  7. #define nsPrintOptionsImpl_h__
  8. #include "mozilla/embedding/PPrinting.h"
  9. #include "nsCOMPtr.h"
  10. #include "nsIPrintSettingsService.h"
  11. #include "nsString.h"
  12. #include "nsFont.h"
  13. class nsIPrintSettings;
  14. /**
  15. * Class nsPrintOptions
  16. */
  17. class nsPrintOptions : public nsIPrintSettingsService
  18. {
  19. public:
  20. NS_DECL_ISUPPORTS
  21. NS_DECL_NSIPRINTSETTINGSSERVICE
  22. /**
  23. * method Init
  24. * Initializes member variables. Every consumer that does manual
  25. * creation (instead of do_CreateInstance) needs to call this method
  26. * immediately after instantiation.
  27. */
  28. virtual nsresult Init();
  29. nsPrintOptions();
  30. protected:
  31. virtual ~nsPrintOptions();
  32. void ReadBitFieldPref(const char * aPrefId, int32_t anOption);
  33. void WriteBitFieldPref(const char * aPrefId, int32_t anOption);
  34. void ReadJustification(const char * aPrefId, int16_t& aJust,
  35. int16_t aInitValue);
  36. void WriteJustification(const char * aPrefId, int16_t aJust);
  37. void ReadInchesToTwipsPref(const char * aPrefId, int32_t& aTwips,
  38. const char * aMarginPref);
  39. void WriteInchesFromTwipsPref(const char * aPrefId, int32_t aTwips);
  40. void ReadInchesIntToTwipsPref(const char * aPrefId, int32_t& aTwips,
  41. const char * aMarginPref);
  42. void WriteInchesIntFromTwipsPref(const char * aPrefId, int32_t aTwips);
  43. nsresult ReadPrefDouble(const char * aPrefId, double& aVal);
  44. nsresult WritePrefDouble(const char * aPrefId, double aVal);
  45. /**
  46. * method ReadPrefs
  47. * @param aPS a pointer to the printer settings
  48. * @param aPrinterName the name of the printer for which to read prefs
  49. * @param aFlags flag specifying which prefs to read
  50. */
  51. virtual nsresult ReadPrefs(nsIPrintSettings* aPS, const nsAString&
  52. aPrinterName, uint32_t aFlags);
  53. /**
  54. * method WritePrefs
  55. * @param aPS a pointer to the printer settings
  56. * @param aPrinterName the name of the printer for which to write prefs
  57. * @param aFlags flag specifying which prefs to read
  58. */
  59. virtual nsresult WritePrefs(nsIPrintSettings* aPS, const nsAString& aPrefName,
  60. uint32_t aFlags);
  61. const char* GetPrefName(const char * aPrefName,
  62. const nsAString& aPrinterName);
  63. /**
  64. * method _CreatePrintSettings
  65. * May be implemented by the platform-specific derived class
  66. *
  67. * @return printer settings instance
  68. */
  69. virtual nsresult _CreatePrintSettings(nsIPrintSettings **_retval);
  70. // Members
  71. nsCOMPtr<nsIPrintSettings> mGlobalPrintSettings;
  72. nsCString mPrefName;
  73. private:
  74. // These are not supported and are not implemented!
  75. nsPrintOptions(const nsPrintOptions& x);
  76. nsPrintOptions& operator=(const nsPrintOptions& x);
  77. };
  78. #endif /* nsPrintOptionsImpl_h__ */