1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
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 nsIDocumentViewerPrint_h___
8 #define nsIDocumentViewerPrint_h___
9 
10 #include "nsISupports.h"
11 #include "mozilla/UniquePtr.h"
12 
13 namespace mozilla {
14 class PresShell;
15 class ServoStyleSet;
16 }  // namespace mozilla
17 class nsPresContext;
18 class nsViewManager;
19 
20 // {c6f255cf-cadd-4382-b57f-cd2a9874169b}
21 #define NS_IDOCUMENT_VIEWER_PRINT_IID                \
22   {                                                  \
23     0xc6f255cf, 0xcadd, 0x4382, {                    \
24       0xb5, 0x7f, 0xcd, 0x2a, 0x98, 0x74, 0x16, 0x9b \
25     }                                                \
26   }
27 
28 /**
29  * A DocumentViewerPrint is an INTERNAL Interface used for interaction
30  * between the DocumentViewer and nsPrintJob.
31  */
32 class nsIDocumentViewerPrint : public nsISupports {
33  public:
34   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_VIEWER_PRINT_IID)
35 
36   virtual void SetIsPrinting(bool aIsPrinting) = 0;
37   virtual bool GetIsPrinting() = 0;
38 
39   virtual void SetIsPrintPreview(bool aIsPrintPreview) = 0;
40   virtual bool GetIsPrintPreview() = 0;
41 
42   /**
43    * This is used by nsPagePrintTimer to make nsDocumentViewer::Destroy()
44    * a no-op until printing is finished.  That prevents the nsDocumentViewer
45    * and its document, presshell and prescontext from going away.
46    */
47   virtual void IncrementDestroyBlockedCount() = 0;
48   virtual void DecrementDestroyBlockedCount() = 0;
49 
50   virtual void OnDonePrinting() = 0;
51 
52   /**
53    * Returns true is InitializeForPrintPreview() has been called.
54    */
55   virtual bool IsInitializedForPrintPreview() = 0;
56 
57   /**
58    * Marks this viewer to be used for print preview.
59    */
60   virtual void InitializeForPrintPreview() = 0;
61 
62   /**
63    * Replaces the current presentation with print preview presentation.
64    */
65   virtual void SetPrintPreviewPresentation(nsViewManager* aViewManager,
66                                            nsPresContext* aPresContext,
67                                            mozilla::PresShell* aPresShell) = 0;
68 };
69 
70 NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentViewerPrint,
71                               NS_IDOCUMENT_VIEWER_PRINT_IID)
72 
73 /* Use this macro when declaring classes that implement this interface. */
74 #define NS_DECL_NSIDOCUMENTVIEWERPRINT                          \
75   void SetIsPrinting(bool aIsPrinting) override;                \
76   bool GetIsPrinting() override;                                \
77   void SetIsPrintPreview(bool aIsPrintPreview) override;        \
78   bool GetIsPrintPreview() override;                            \
79   void IncrementDestroyBlockedCount() override;                 \
80   void DecrementDestroyBlockedCount() override;                 \
81   void OnDonePrinting() override;                               \
82   bool IsInitializedForPrintPreview() override;                 \
83   void InitializeForPrintPreview() override;                    \
84   void SetPrintPreviewPresentation(nsViewManager* aViewManager, \
85                                    nsPresContext* aPresContext, \
86                                    mozilla::PresShell* aPresShell) override;
87 
88 #endif /* nsIDocumentViewerPrint_h___ */
89