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/. */
6 #ifndef nsIDeviceContextSpec_h___
7 #define nsIDeviceContextSpec_h___
10 #include "nsISupports.h"
11 #include "mozilla/StaticPrefs_print.h"
14 class nsIPrintSettings
;
18 class DrawEventRecorder
;
21 } // namespace mozilla
23 #define NS_IDEVICE_CONTEXT_SPEC_IID \
25 0xf407cfba, 0xbe28, 0x46c9, { \
26 0x8a, 0xba, 0x04, 0x2d, 0xae, 0xbb, 0x4f, 0x23 \
30 class nsIDeviceContextSpec
: public nsISupports
{
32 typedef mozilla::gfx::PrintTarget PrintTarget
;
34 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDEVICE_CONTEXT_SPEC_IID
)
37 * Initialize the device context spec.
38 * @param aWidget A widget a dialog can be hosted in
39 * @param aPrintSettings Print settings for the print operation
40 * @param aIsPrintPreview True if creating Spec for PrintPreview
41 * @return NS_OK or a suitable error code.
43 NS_IMETHOD
Init(nsIPrintSettings
* aPrintSettings
, bool aIsPrintPreview
) = 0;
45 virtual already_AddRefed
<PrintTarget
> MakePrintTarget() = 0;
48 * If required override to return a recorder to record the print.
50 * @param aDrawEventRecorder out param for the recorder to use
51 * @return NS_OK or a suitable error code
53 NS_IMETHOD
GetDrawEventRecorder(
54 mozilla::gfx::DrawEventRecorder
** aDrawEventRecorder
) {
55 MOZ_ASSERT(aDrawEventRecorder
);
56 *aDrawEventRecorder
= nullptr;
61 * @return DPI for printing.
63 float GetDPI() { return mozilla::StaticPrefs::print_default_dpi(); }
66 * @return the printing scale to be applied to the context for printing.
68 float GetPrintingScale();
71 * @return the point to translate the context to for printing.
73 gfxPoint
GetPrintingTranslate();
75 NS_IMETHOD
BeginDocument(const nsAString
& aTitle
,
76 const nsAString
& aPrintToFileName
,
77 int32_t aStartPage
, int32_t aEndPage
) = 0;
79 NS_IMETHOD
EndDocument() = 0;
80 NS_IMETHOD
AbortDocument() { return EndDocument(); }
81 NS_IMETHOD
BeginPage() = 0;
82 NS_IMETHOD
EndPage() = 0;
85 nsCOMPtr
<nsIPrintSettings
> mPrintSettings
;
87 #ifdef MOZ_ENABLE_SKIA_PDF
88 // This variable is independant of nsIPrintSettings::kOutputFormatPDF (i.e.
89 // save-to-PDF). If set to true, then even when we print to a printer we
90 // output and send it PDF.
91 bool mPrintViaSkPDF
= false;
95 NS_DEFINE_STATIC_IID_ACCESSOR(nsIDeviceContextSpec
, NS_IDEVICE_CONTEXT_SPEC_IID
)