Back out patch for bug 381361 due to ref test failures on Windows.
authorkherron@fmailbox.com
Sun, 24 Jun 2007 08:13:23 -0700
changeset 2733 39ce3df2e9ec1ab51993169d246ffbf5bd5b810f
parent 2732 f0d0c8c446cc07d6fc5236652b478f5ad9dd466a
child 2734 34820920609996e7a4e8075dc27fe2de12bf83e7
push idunknown
push userunknown
push dateunknown
bugs381361
milestone1.9a6pre
Back out patch for bug 381361 due to ref test failures on Windows.
layout/base/nsDocumentViewer.cpp
widget/public/nsIPrintSettings.idl
widget/src/beos/nsDeviceContextSpecB.cpp
widget/src/beos/nsDeviceContextSpecB.h
widget/src/gtk2/nsDeviceContextSpecG.cpp
widget/src/gtk2/nsDeviceContextSpecG.h
widget/src/windows/nsDeviceContextSpecWin.cpp
widget/src/xpwidgets/nsPrintSettingsImpl.cpp
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -840,19 +840,19 @@ DocumentViewerImpl::InitInternal(nsIWidg
         NS_ENSURE_SUCCESS(rv, rv);
         rv = devctx->InitForPrinting(devspec);
         NS_ENSURE_SUCCESS(rv, rv);
         // XXX I'm breaking this code; I'm not sure I really want to mess with
         // the document viewer at the moment to get the right device context
         // (this won't break anyone, since page layout mode was never really
         // usable)
 #endif
-        double pageWidth = 0, pageHeight = 0;
-        mPresContext->GetPrintSettings()->GetEffectivePageSize(&pageWidth,
-                                                               &pageHeight);
+        PRInt32 pageWidth = 0, pageHeight = 0;
+        mPresContext->GetPrintSettings()->GetPageSizeInTwips(&pageWidth,
+                                                             &pageHeight);
         mPresContext->SetPageSize(
           nsSize(mPresContext->TwipsToAppUnits(pageWidth),
                  mPresContext->TwipsToAppUnits(pageHeight)));
         mPresContext->SetIsRootPaginatedDocument(PR_TRUE);
         mPresContext->SetPageScale(1.0f);
       }
 #endif
     }
--- a/widget/public/nsIPrintSettings.idl
+++ b/widget/public/nsIPrintSettings.idl
@@ -53,17 +53,17 @@
   
 interface nsIPrintSession;
 
 /**
  * Simplified graphics interface for JS rendering.
  *
  * @status UNDER_REVIEW
  */
-[scriptable, uuid(89c06ccb-6d41-4846-a8e2-63bfa7bd3157)]
+[scriptable, uuid(f1094df6-ce0e-42c9-9847-2f663172c38d)]
 
 interface nsIPrintSettings : nsISupports
 {
   /**
    * PrintSettings to be Saved Navigation Constants
    */
   const unsigned long kInitSaveOddEvenPages   = 0x00000001;
   const unsigned long kInitSaveHeaderLeft     = 0x00000002;
@@ -173,20 +173,19 @@ interface nsIPrintSettings : nsISupports
   PRBool GetPrintOptions(in PRInt32 aType);
 
   /**
    * Set PrintOptions Bit field
    */
   PRInt32 GetPrintOptionsBits();
 
   /**
-   * Get the page size in twips, considering the
-   * orientation (portrait or landscape).
+   * Returns W/H in Twips from Paper Size H/W
    */
-  void GetEffectivePageSize(out double aWidth, out double aHeight);
+  void GetPageSizeInTwips(out long aWidth, out long aHeight);
 
   /**
    * Makes a new copy
    */
     nsIPrintSettings clone();
 
   /**
    * Assigns the internal values from the "in" arg to the current object
--- a/widget/src/beos/nsDeviceContextSpecB.cpp
+++ b/widget/src/beos/nsDeviceContextSpecB.cpp
@@ -397,16 +397,21 @@ NS_IMETHODIMP nsDeviceContextSpecBeOS ::
  * Closes the printmanager if it is open.
  *  @update   dc 2/15/98
  */
 NS_IMETHODIMP nsDeviceContextSpecBeOS :: ClosePrintManager()
 {
   return NS_OK;
 }  
 
+NS_IMETHODIMP nsDeviceContextSpecBeOS::GetPageSizeInTwips(PRInt32 *aWidth, PRInt32 *aHeight)
+{
+  return mPrintSettings->GetPageSizeInTwips(aWidth, aHeight);
+}
+
 //  Printer Enumerator
 nsPrinterEnumeratorBeOS::nsPrinterEnumeratorBeOS()
 {
 }
 
 NS_IMPL_ISUPPORTS1(nsPrinterEnumeratorBeOS, nsIPrinterEnumerator)
 
 NS_IMETHODIMP nsPrinterEnumeratorBeOS::GetPrinterNameList(nsIStringEnumerator **aPrinterNameList)
--- a/widget/src/beos/nsDeviceContextSpecB.h
+++ b/widget/src/beos/nsDeviceContextSpecB.h
@@ -80,16 +80,18 @@ public:
   
 /**
  * Closes the printmanager if it is open.
  * @update   dc 2/13/98
  * @return error status
  */
   NS_IMETHOD ClosePrintManager();
   
+  NS_IMETHOD GetPageSizeInTwips(PRInt32 *aWidth, PRInt32 *aHeight);
+
   NS_IMETHOD GetToPrinter( PRBool &aToPrinter ); 
 
   NS_IMETHOD GetPrinterName ( const char **aPrinter );
 
   NS_IMETHOD GetCopies ( int &aCopies ); 
 
   NS_IMETHOD GetFirstPageFirst ( PRBool &aFpf );     
  
--- a/widget/src/gtk2/nsDeviceContextSpecG.cpp
+++ b/widget/src/gtk2/nsDeviceContextSpecG.cpp
@@ -398,42 +398,43 @@ NS_IMPL_ISUPPORTS1(nsDeviceContextSpecGT
 #include "gfxPDFSurface.h"
 #include "gfxPSSurface.h"
 #include "nsUnitConversion.h"
 NS_IMETHODIMP nsDeviceContextSpecGTK::GetSurfaceForPrinter(gfxASurface **aSurface)
 {
   const char *path;
   GetPath(&path);
 
-  double width, height;
-  mPrintSettings->GetEffectivePageSize(&width, &height);
+  PRInt32 width, height;
+  GetPageSizeInTwips(&width, &height);
+  double w, h;
   // convert twips to points
-  width /= 20;
-  height /= 20;
+  w = width/20;
+  h = height/20;
 
-  DO_PR_DEBUG_LOG(("\"%s\", %f, %f\n", path, width, height));
+  printf("\"%s\", %d, %d\n", path, width, height);
 
   nsresult rv = nsPrintJobFactoryGTK::CreatePrintJob(this, mPrintJob);
   if (NS_FAILED(rv))
     return rv;
 
   nsCOMPtr<nsILocalFile> file;
   rv = mPrintJob->GetSpoolFile(getter_AddRefs(file));
   if (NS_FAILED(rv))
     return rv;
 
   nsCOMPtr<nsIFileOutputStream> stream = do_CreateInstance("@mozilla.org/network/file-output-stream;1");
   rv = stream->Init(file, -1, -1, 0);
   if (NS_FAILED(rv))
     return rv;
 
 #ifdef USE_PDF
-  gfxPDFSurface *surface = new gfxPDFSurface(stream, gfxSize(width, height));
+  gfxPDFSurface *surface = new gfxPDFSurface(stream, gfxSize(w, h));
 #else
-  gfxPSSurface *surface = new gfxPSSurface(stream, gfxSize(width, height));
+  gfxPSSurface *surface = new gfxPSSurface(stream, gfxSize(w, h));
 #endif
 //  surface->SetDPI(600, 600);
   
   *aSurface = surface;
   NS_ADDREF(*aSurface);
 
   return NS_OK;
 }
@@ -657,16 +658,21 @@ NS_IMETHODIMP nsDeviceContextSpecGTK::Ge
 }
 
 NS_IMETHODIMP nsDeviceContextSpecGTK::GetDownloadFonts(PRBool &aDownloadFonts)      
 {
   aDownloadFonts = mDownloadFonts;
   return NS_OK;
 }
 
+NS_IMETHODIMP nsDeviceContextSpecGTK::GetPageSizeInTwips(PRInt32 *aWidth, PRInt32 *aHeight)
+{
+  return mPrintSettings->GetPageSizeInTwips(aWidth, aHeight);
+}
+
 NS_IMETHODIMP nsDeviceContextSpecGTK::GetPrintMethod(PrintMethod &aMethod)
 {
   return GetPrintMethod(mPrinter, aMethod);
 }
 
 /* static !! */
 nsresult nsDeviceContextSpecGTK::GetPrintMethod(const char *aPrinter, PrintMethod &aMethod)
 {
--- a/widget/src/gtk2/nsDeviceContextSpecG.h
+++ b/widget/src/gtk2/nsDeviceContextSpecG.h
@@ -84,16 +84,17 @@ public:
   NS_IMETHOD GetLeftMargin(float &value); 
   NS_IMETHOD GetRightMargin(float &value); 
   NS_IMETHOD GetCommand(const char **aCommand);   
   NS_IMETHOD GetPath (const char **aPath);    
   NS_IMETHOD GetLandscape (PRBool &aLandscape);
   NS_IMETHOD GetUserCancelled(PRBool &aCancel);      
   NS_IMETHOD GetPrintMethod(PrintMethod &aMethod);
   static nsresult GetPrintMethod(const char *aPrinter, PrintMethod &aMethod);
+  NS_IMETHOD GetPageSizeInTwips(PRInt32 *aWidth, PRInt32 *aHeight);
   NS_IMETHOD GetPaperName(const char **aPaperName);
   NS_IMETHOD GetPlexName(const char **aPlexName);
   NS_IMETHOD GetResolutionName(const char **aResolutionName);
   NS_IMETHOD GetColorspace(const char **aColorspace);
   NS_IMETHOD GetDownloadFonts(PRBool &aDownloadFonts);   
   virtual ~nsDeviceContextSpecGTK();
   
 protected:
--- a/widget/src/windows/nsDeviceContextSpecWin.cpp
+++ b/widget/src/windows/nsDeviceContextSpecWin.cpp
@@ -524,33 +524,34 @@ NS_IMETHODIMP nsDeviceContextSpecWin::Ge
 
   PRInt16 outputFormat;
   mPrintSettings->GetOutputFormat(&outputFormat);
 
   if (outputFormat == nsIPrintSettings::kOutputFormatPDF) {
     nsXPIDLString filename;
     mPrintSettings->GetToFileName(getter_Copies(filename));
 
-    double width, height;
-    mPrintSettings->GetEffectivePageSize(&width, &height);
+    PRInt32 width, height;
+    mPrintSettings->GetPageSizeInTwips(&width, &height);
+    double w, h;
     // convert twips to points
-    width /= 20;
-    height /= 20;
+    w = width/20;
+    h = height/20;
 
     nsCOMPtr<nsILocalFile> file = do_CreateInstance("@mozilla.org/file/local;1");
     nsresult rv = file->InitWithPath(filename);
     if (NS_FAILED(rv))
       return rv;
 
     nsCOMPtr<nsIFileOutputStream> stream = do_CreateInstance("@mozilla.org/network/file-output-stream;1");
     rv = stream->Init(file, -1, -1, 0);
     if (NS_FAILED(rv))
       return rv;
 
-    newSurface = new gfxPDFSurface(stream, gfxSize(width, height));
+    newSurface = new gfxPDFSurface(stream, gfxSize(w, h));
   } else {
     if (mDevMode) {
       HDC dc = ::CreateDC(mDriverName, mDeviceName, NULL, mDevMode);
 
       // have this surface take over ownership of this DC
       newSurface = new gfxWindowsSurface(dc, PR_TRUE);
     }
   }
--- a/widget/src/xpwidgets/nsPrintSettingsImpl.cpp
+++ b/widget/src/xpwidgets/nsPrintSettingsImpl.cpp
@@ -915,32 +915,28 @@ NS_IMETHODIMP
 nsPrintSettings::GetMarginInTwips(nsMargin& aMargin)
 {
   aMargin = mMargin;
   return NS_OK;
 }
 
 /** ---------------------------------------------------
  *  See documentation in nsPrintOptionsImpl.h
+ *	@update 6/21/00 dwc
  */
 NS_IMETHODIMP 
-nsPrintSettings::GetEffectivePageSize(double *aWidth, double *aHeight)
+nsPrintSettings::GetPageSizeInTwips(PRInt32 *aWidth, PRInt32 *aHeight)
 {
   if (mPaperSizeUnit == kPaperSizeInches) {
     *aWidth  = NS_INCHES_TO_TWIPS(float(mPaperWidth));
     *aHeight = NS_INCHES_TO_TWIPS(float(mPaperHeight));
   } else {
     *aWidth  = NS_MILLIMETERS_TO_TWIPS(float(mPaperWidth));
     *aHeight = NS_MILLIMETERS_TO_TWIPS(float(mPaperHeight));
   }
-  if (kLandscapeOrientation == mOrientation) {
-    double temp = *aWidth;
-    *aWidth = *aHeight;
-    *aHeight = temp;
-  }
   return NS_OK;
 }
 
 nsresult 
 nsPrintSettings::_Clone(nsIPrintSettings **_retval)
 {
   nsPrintSettings* printSettings = new nsPrintSettings(*this);
   return printSettings->QueryInterface(NS_GET_IID(nsIPrintSettings), (void**)_retval); // ref counts