Back to index

lightning-sunbird  0.9+nobinonly
nsPrintData.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 #ifndef nsPrintData_h___
00038 #define nsPrintData_h___
00039 
00040 #include "nsPrintObject.h"
00041 
00042 // Interfaces
00043 #include "nsIDeviceContext.h"
00044 #include "nsIDocument.h"
00045 #include "nsIDOMWindow.h"
00046 #include "nsIObserver.h"
00047 #include "nsIPrintProgress.h"
00048 #include "nsIPrintProgressParams.h"
00049 #include "nsIPrintOptions.h"
00050 #include "nsIPrintSettings.h"
00051 #include "nsIWebProgressListener.h"
00052 #include "nsIPrintSession.h"
00053 
00054 // Other Includes
00055 #include "nsPrintPreviewListener.h"
00056 #include "nsIDocShellTreeNode.h"
00057 
00058 // Classes
00059 class nsIPageSequenceFrame;
00060 class nsPagePrintTimer;
00061 
00062 // Special Interfaces
00063 #include "nsIDocumentViewer.h"
00064 #include "nsIDocumentViewerPrint.h"
00065 
00066 //---------------------------------------------------
00067 //-- Object for Caching the Presentation
00068 //---------------------------------------------------
00069 class CachedPresentationObj
00070 {
00071 public:
00072   CachedPresentationObj(nsIPresShell* aShell, nsPresContext* aPC,
00073                         nsIViewManager* aVM, nsIWidget* aW):
00074     mWindow(aW), mViewManager(aVM), mPresShell(aShell), mPresContext(aPC)
00075   {
00076   }
00077 
00078   // The order here is important because the order of destruction is the
00079   // reverse of the order listed here, and the view manager must outlive
00080   // the pres shell.
00081   nsCOMPtr<nsIWidget>      mWindow;
00082   nsCOMPtr<nsIViewManager> mViewManager;
00083   nsCOMPtr<nsIPresShell>   mPresShell;
00084   nsCOMPtr<nsPresContext> mPresContext;
00085 };
00086 
00087 //------------------------------------------------------------------------
00088 // nsPrintData Class
00089 //
00090 // mPreparingForPrint - indicates that we have started Printing but 
00091 //   have not gone to the timer to start printing the pages. It gets turned 
00092 //   off right before we go to the timer.
00093 //
00094 // mDocWasToBeDestroyed - Gets set when "someone" tries to unload the document
00095 //   while we were prparing to Print. This typically happens if a user starts 
00096 //   to print while a page is still loading. If they start printing and pause 
00097 //   at the print dialog and then the page comes in, we then abort printing 
00098 //   because the document is no longer stable.
00099 // 
00100 //------------------------------------------------------------------------
00101 class nsPrintData {
00102 public:
00103 
00104   typedef enum {eIsPrinting, eIsPrintPreview } ePrintDataType;
00105 
00106   // This enum tells indicates what the default should be for the title
00107   // if the title from the document is null
00108   enum eDocTitleDefault {
00109     eDocTitleDefNone,
00110     eDocTitleDefBlank,
00111     eDocTitleDefURLDoc
00112   };
00113 
00114 
00115   nsPrintData(ePrintDataType aType);
00116   ~nsPrintData(); // non-virtual
00117 
00118   // Listener Helper Methods
00119   void OnEndPrinting();
00120   void OnStartPrinting();
00121   static void DoOnProgressChange(nsVoidArray& aListeners,
00122                                  PRInt32      aProgess,
00123                                  PRInt32      aMaxProgress,
00124                                  PRBool       aDoStartStop = PR_FALSE,
00125                                  PRInt32      aFlag = 0);
00126 
00127 
00128   ePrintDataType               mType;            // the type of data this is (Printing or Print Preview)
00129   nsCOMPtr<nsIDeviceContext>   mPrintDC;
00130   nsIView                     *mPrintView;
00131   FILE                        *mDebugFilePtr;    // a file where information can go to when printing
00132 
00133   nsPrintObject *                mPrintObject;
00134   nsPrintObject *                mSelectedPO;
00135 
00136   nsVoidArray                      mPrintProgressListeners;
00137   nsCOMPtr<nsIWebProgressListener> mPrintProgressListener;
00138   nsCOMPtr<nsIPrintProgress>       mPrintProgress;
00139   nsCOMPtr<nsIPrintProgressParams> mPrintProgressParams;
00140   PRBool                           mShowProgressDialog;    // means we should try to show it
00141   PRPackedBool                     mProgressDialogIsShown; // means it is already being shown
00142 
00143   nsCOMPtr<nsIDOMWindow> mCurrentFocusWin; // cache a pointer to the currently focused window
00144 
00145   nsVoidArray*                mPrintDocList;
00146   nsCOMPtr<nsIDeviceContext>  mPrintDocDC;
00147   nsCOMPtr<nsIDOMWindow>      mPrintDocDW;
00148   PRPackedBool                mIsIFrameSelected;
00149   PRPackedBool                mIsParentAFrameSet;
00150   PRPackedBool                mPrintingAsIsSubDoc;
00151   PRPackedBool                mOnStartSent;
00152   PRPackedBool                mIsAborted;           // tells us the document is being aborted
00153   PRPackedBool                mPreparingForPrint;   // see comments above
00154   PRPackedBool                mDocWasToBeDestroyed; // see comments above
00155   PRBool                      mShrinkToFit;
00156   PRInt16                     mPrintFrameType;
00157   PRInt32                     mNumPrintableDocs;
00158   PRInt32                     mNumDocsPrinted;
00159   PRInt32                     mNumPrintablePages;
00160   PRInt32                     mNumPagesPrinted;
00161   float                       mShrinkRatio;
00162   float                       mOrigDCScale;
00163   float                       mOrigZoom;
00164 
00165   nsCOMPtr<nsIPrintSession>   mPrintSession;
00166   nsCOMPtr<nsIPrintSettings>  mPrintSettings;
00167   nsCOMPtr<nsIPrintOptions>   mPrintOptions;
00168   nsPrintPreviewListener*     mPPEventListeners;
00169 
00170   PRUnichar*            mBrandName; //  needed as a substitute name for a document
00171 
00172   nsPagePrintTimer* mPagePrintTimer;
00173   nsIPageSequenceFrame* mPageSeqFrame;
00174 
00175 private:
00176   nsPrintData() {}
00177   nsPrintData& operator=(const nsPrintData& aOther); // not implemented
00178 
00179 };
00180 
00181 #endif /* nsPrintData_h___ */
00182