Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/widget/nsIDeviceContextSpec.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 nsIDeviceContextSpec_h___
7
#define nsIDeviceContextSpec_h___
8
9
#include "nsISupports.h"
10
11
class nsIWidget;
12
class nsIPrintSettings;
13
14
namespace mozilla {
15
namespace gfx{
16
class DrawEventRecorder;
17
class PrintTarget;
18
}
19
}
20
21
#define NS_IDEVICE_CONTEXT_SPEC_IID   \
22
{ 0xf407cfba, 0xbe28, 0x46c9, \
23
  { 0x8a, 0xba, 0x04, 0x2d, 0xae, 0xbb, 0x4f, 0x23 } }
24
25
class nsIDeviceContextSpec : public nsISupports
26
{
27
public:
28
  typedef mozilla::gfx::PrintTarget PrintTarget;
29
30
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDEVICE_CONTEXT_SPEC_IID)
31
32
   /**
33
    * Initialize the device context spec.
34
    * @param aWidget         A widget a dialog can be hosted in
35
    * @param aPrintSettings  Print settings for the print operation
36
    * @param aIsPrintPreview True if creating Spec for PrintPreview
37
    * @return NS_OK or a suitable error code.
38
    */
39
   NS_IMETHOD Init(nsIWidget *aWidget,
40
                   nsIPrintSettings* aPrintSettings,
41
                   bool aIsPrintPreview) = 0;
42
43
   virtual already_AddRefed<PrintTarget> MakePrintTarget() = 0;
44
45
   /**
46
    * If required override to return a recorder to record the print.
47
    *
48
    * @param aDrawEventRecorder out param for the recorder to use
49
    * @return NS_OK or a suitable error code
50
    */
51
   NS_IMETHOD GetDrawEventRecorder(mozilla::gfx::DrawEventRecorder** aDrawEventRecorder)
52
0
   {
53
0
     MOZ_ASSERT(aDrawEventRecorder);
54
0
     *aDrawEventRecorder = nullptr;
55
0
     return NS_OK;
56
0
   }
57
58
   /**
59
    * Override to return something other than the default.
60
    *
61
    * @return DPI for printing.
62
    */
63
0
   virtual float GetDPI() { return 72.0f; }
64
65
   /**
66
    * Override to return something other than the default.
67
    *
68
    * @return the printing scale to be applied to the context for printing.
69
    */
70
0
   virtual float GetPrintingScale() { return 1.0f;  }
71
72
   /**
73
    * Override to return something other than the default.
74
    *
75
    * @return the point to translate the context to for printing.
76
    */
77
0
   virtual gfxPoint GetPrintingTranslate() { return gfxPoint(0, 0);  }
78
79
   NS_IMETHOD BeginDocument(const nsAString& aTitle,
80
                            const nsAString& aPrintToFileName,
81
                            int32_t          aStartPage,
82
                            int32_t          aEndPage) = 0;
83
84
   NS_IMETHOD EndDocument() = 0;
85
0
   NS_IMETHOD AbortDocument() { return EndDocument(); }
86
   NS_IMETHOD BeginPage() = 0;
87
   NS_IMETHOD EndPage() = 0;
88
};
89
90
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDeviceContextSpec,
91
                              NS_IDEVICE_CONTEXT_SPEC_IID)
92
#endif