Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/widget/gtk/nsDeviceContextSpecG.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
 * License, v. 2.0. If a copy of the MPL was not distributed with this
4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
#ifndef nsDeviceContextSpecGTK_h___
7
#define nsDeviceContextSpecGTK_h___
8
9
#include "nsIDeviceContextSpec.h"
10
#include "nsIPrintSettings.h"
11
#include "nsIPrinterEnumerator.h"
12
#include "nsCOMPtr.h"
13
#include "nsString.h"
14
#include "mozilla/Attributes.h"
15
16
#include "nsCRT.h" /* should be <limits.h>? */
17
18
#include <gtk/gtk.h>
19
#include <gtk/gtkunixprint.h>
20
21
#define NS_PORTRAIT  0
22
#define NS_LANDSCAPE 1
23
24
class nsPrintSettingsGTK;
25
26
class nsDeviceContextSpecGTK : public nsIDeviceContextSpec
27
{
28
public:
29
  nsDeviceContextSpecGTK();
30
31
  NS_DECL_ISUPPORTS
32
33
  already_AddRefed<PrintTarget> MakePrintTarget() final;
34
35
  NS_IMETHOD Init(nsIWidget *aWidget, nsIPrintSettings* aPS,
36
                  bool aIsPrintPreview) override;
37
  NS_IMETHOD BeginDocument(const nsAString& aTitle,
38
                           const nsAString& aPrintToFileName,
39
                           int32_t aStartPage, int32_t aEndPage) override;
40
  NS_IMETHOD EndDocument() override;
41
0
  NS_IMETHOD BeginPage() override { return NS_OK; }
42
0
  NS_IMETHOD EndPage() override { return NS_OK; }
43
44
protected:
45
  virtual ~nsDeviceContextSpecGTK();
46
  nsCOMPtr<nsPrintSettingsGTK> mPrintSettings;
47
  bool mToPrinter : 1;      /* If true, print to printer */
48
  bool mIsPPreview : 1;     /* If true, is print preview */
49
  GtkPrintSettings* mGtkPrintSettings;
50
  GtkPageSetup*     mGtkPageSetup;
51
52
  nsCString         mSpoolName;
53
  nsCOMPtr<nsIFile> mSpoolFile;
54
  nsCString         mTitle;
55
56
private:
57
  void EnumeratePrinters();
58
  void StartPrintJob();
59
  static gboolean PrinterEnumerator(GtkPrinter *aPrinter, gpointer aData);
60
};
61
62
//-------------------------------------------------------------------------
63
// Printer Enumerator
64
//-------------------------------------------------------------------------
65
class nsPrinterEnumeratorGTK final : public nsIPrinterEnumerator
66
{
67
0
  ~nsPrinterEnumeratorGTK() {}
68
public:
69
  nsPrinterEnumeratorGTK();
70
  NS_DECL_ISUPPORTS
71
  NS_DECL_NSIPRINTERENUMERATOR
72
};
73
74
#endif /* !nsDeviceContextSpecGTK_h___ */