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 #ifndef nsIDocumentViewerPrint_h___ 7 #define nsIDocumentViewerPrint_h___ 8 9 #include "nsISupports.h" 10 11 class nsIDocument; 12 namespace mozilla { 13 class StyleSetHandle; 14 } // namespace mozilla 15 class nsIPresShell; 16 class nsPresContext; 17 class nsViewManager; 18 19 // {c6f255cf-cadd-4382-b57f-cd2a9874169b} 20 #define NS_IDOCUMENT_VIEWER_PRINT_IID \ 21 { \ 22 0xc6f255cf, 0xcadd, 0x4382, { \ 23 0xb5, 0x7f, 0xcd, 0x2a, 0x98, 0x74, 0x16, 0x9b \ 24 } \ 25 } 26 27 /** 28 * A DocumentViewerPrint is an INTERNAL Interface used for interaction 29 * between the DocumentViewer and nsPrintJob. 30 */ 31 class nsIDocumentViewerPrint : public nsISupports { 32 public: 33 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_VIEWER_PRINT_IID) 34 35 virtual void SetIsPrinting(bool aIsPrinting) = 0; 36 virtual bool GetIsPrinting() = 0; 37 38 virtual void SetIsPrintPreview(bool aIsPrintPreview) = 0; 39 virtual bool GetIsPrintPreview() = 0; 40 41 // The style set returned by CreateStyleSet is in the middle of an 42 // update batch so that the caller can add sheets to it if needed. 43 // Callers should call EndUpdate() on it when ready to use. 44 virtual mozilla::StyleSetHandle CreateStyleSet(nsIDocument* aDocument) = 0; 45 46 /** 47 * This is used by nsPagePrintTimer to make nsDocumentViewer::Destroy() 48 * a no-op until printing is finished. That prevents the nsDocumentViewer 49 * and its document, presshell and prescontext from going away. 50 */ 51 virtual void IncrementDestroyBlockedCount() = 0; 52 virtual void DecrementDestroyBlockedCount() = 0; 53 54 virtual void OnDonePrinting() = 0; 55 56 /** 57 * Returns true is InitializeForPrintPreview() has been called. 58 */ 59 virtual bool IsInitializedForPrintPreview() = 0; 60 61 /** 62 * Marks this viewer to be used for print preview. 63 */ 64 virtual void InitializeForPrintPreview() = 0; 65 66 /** 67 * Replaces the current presentation with print preview presentation. 68 */ 69 virtual void SetPrintPreviewPresentation(nsViewManager* aViewManager, 70 nsPresContext* aPresContext, 71 nsIPresShell* aPresShell) = 0; 72 }; 73 74 NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentViewerPrint, 75 NS_IDOCUMENT_VIEWER_PRINT_IID) 76 77 /* Use this macro when declaring classes that implement this interface. */ 78 #define NS_DECL_NSIDOCUMENTVIEWERPRINT \ 79 void SetIsPrinting(bool aIsPrinting) override; \ 80 bool GetIsPrinting() override; \ 81 void SetIsPrintPreview(bool aIsPrintPreview) override; \ 82 bool GetIsPrintPreview() override; \ 83 mozilla::StyleSetHandle CreateStyleSet(nsIDocument* aDocument) override; \ 84 void IncrementDestroyBlockedCount() override; \ 85 void DecrementDestroyBlockedCount() override; \ 86 void OnDonePrinting() override; \ 87 bool IsInitializedForPrintPreview() override; \ 88 void InitializeForPrintPreview() override; \ 89 void SetPrintPreviewPresentation(nsViewManager* aViewManager, \ 90 nsPresContext* aPresContext, \ 91 nsIPresShell* aPresShell) override; 92 93 #endif /* nsIDocumentViewerPrint_h___ */ 94