Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/widget/nsPrintSettingsService.h
Line
Count
Source (jump to first uncovered line)
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 "nsIPrintSettingsService.h"
13
#include "nsString.h"
14
#include "nsFont.h"
15
16
class nsIPrintSettings;
17
18
/**
19
 * Class nsPrintSettingsService.  Base class for the platform specific widget
20
 * subclasses to inherit from.
21
 */
22
class nsPrintSettingsService : public nsIPrintSettingsService
23
{
24
public:
25
  NS_DECL_ISUPPORTS
26
  NS_DECL_NSIPRINTSETTINGSSERVICE
27
28
0
  nsPrintSettingsService() {}
29
30
  /**
31
   * method Init
32
   *  Initializes member variables. Every consumer that does manual
33
   *  creation (instead of do_CreateInstance) needs to call this method
34
   *  immediately after instantiation.
35
   */
36
  virtual nsresult Init();
37
38
private:
39
  // Copying is not supported.
40
  nsPrintSettingsService(const nsPrintSettingsService& x) = delete;
41
  nsPrintSettingsService& operator=(const nsPrintSettingsService& x) = delete;
42
43
protected:
44
0
  virtual ~nsPrintSettingsService() {}
45
46
  void ReadBitFieldPref(const char * aPrefId, int32_t anOption);
47
  void WriteBitFieldPref(const char * aPrefId, int32_t anOption);
48
  void ReadJustification(const char * aPrefId, int16_t& aJust,
49
                         int16_t aInitValue);
50
  void WriteJustification(const char * aPrefId, int16_t aJust);
51
  void ReadInchesToTwipsPref(const char * aPrefId, int32_t&  aTwips,
52
                             const char * aMarginPref);
53
  void WriteInchesFromTwipsPref(const char * aPrefId, int32_t aTwips);
54
  void ReadInchesIntToTwipsPref(const char * aPrefId, int32_t&  aTwips,
55
                                const char * aMarginPref);
56
  void WriteInchesIntFromTwipsPref(const char * aPrefId, int32_t aTwips);
57
58
  nsresult ReadPrefDouble(const char * aPrefId, double& aVal);
59
  nsresult WritePrefDouble(const char * aPrefId, double aVal);
60
61
  /**
62
   * method ReadPrefs
63
   * @param aPS          a pointer to the printer settings
64
   * @param aPrinterName the name of the printer for which to read prefs
65
   * @param aFlags       flag specifying which prefs to read
66
   */
67
  virtual nsresult ReadPrefs(nsIPrintSettings* aPS,
68
                             const nsAString& aPrinterName,
69
                             uint32_t aFlags);
70
  /**
71
   * method WritePrefs
72
   * @param aPS          a pointer to the printer settings
73
   * @param aPrinterName the name of the printer for which to write prefs
74
   * @param aFlags       flag specifying which prefs to read
75
   */
76
  virtual nsresult WritePrefs(nsIPrintSettings* aPS,
77
                              const nsAString& aPrinterName,
78
                              uint32_t aFlags);
79
80
  const char* GetPrefName(const char* aPrefName,
81
                          const nsAString&  aPrinterName);
82
83
  /**
84
   * method _CreatePrintSettings
85
   *   May be implemented by the platform-specific derived class
86
   *
87
   * @return             printer settings instance
88
   */
89
  virtual nsresult _CreatePrintSettings(nsIPrintSettings **_retval);
90
91
  // Members
92
  nsCOMPtr<nsIPrintSettings> mGlobalPrintSettings;
93
94
  nsCString mPrefName;
95
};
96
97
#endif // nsPrintSettingsService_h