Fix bug 302958: specify a name for the print job on Mac, getting it from the title passed to the BeginDocument() call. r=jhpedemonte, sr=bryner, a=asa

This commit is contained in:
smfr%smfr.org 2005-08-08 19:34:44 +00:00
Родитель 9617fb14ba
Коммит 12b4e65c31
5 изменённых файлов: 14 добавлений и 315 удалений

Просмотреть файл

@ -45,8 +45,8 @@ class nsIPrintSettings;
// 3d5917da-1dd2-11b2-bc7b-aa83823362e0
#define NS_IPRINTING_CONTEXT_IID \
{ 0x3d5917da, 0x1dd2, 0x11b2, \
{ 0xbc, 0x7b, 0xaa, 0x83, 0x82, 0x33, 0x62, 0xe0 } }
{ 0xD9853908, 0xA34D, 0x4D8B, \
{ 0xB4, 0xD6, 0x5D, 0xC3, 0x6E, 0x21, 0x1B, 0xDD } }
class nsIPrintingContext : public nsISupports {
public:
@ -73,7 +73,9 @@ public:
*/
NS_IMETHOD ClosePrintManager() = 0;
NS_IMETHOD BeginDocument(PRInt32 aStartPage,
NS_IMETHOD BeginDocument(PRUnichar* aTitle,
PRUnichar* aPrintToFileName,
PRInt32 aStartPage,
PRInt32 aEndPage) = 0;
NS_IMETHOD EndDocument() = 0;

Просмотреть файл

@ -478,8 +478,8 @@ public:
/**
* Draw an arc in the current forground color
* @param aRect The rectangle define bounds of ellipse to use
* @param aStartAngle the starting angle of the arc, in the ellipse
* @param aEndAngle The ending angle of the arc, in the ellipse
* @param aStartAngle the starting angle of the arc, in degrees
* @param aEndAngle The ending angle of the arc, in degrees
*/
NS_IMETHOD DrawArc(const nsRect& aRect,
float aStartAngle, float aEndAngle) = 0;
@ -490,8 +490,8 @@ public:
* @param aY Vertical top Coordinate in twips
* @param aWidth Width of horizontal axis in twips
* @param aHeight Height of vertical axis in twips
* @param aStartAngle the starting angle of the arc, in the ellipse
* @param aEndAngle The ending angle of the arc, in the ellipse
* @param aStartAngle the starting angle of the arc, in degrees
* @param aEndAngle The ending angle of the arc, in degrees
*/
NS_IMETHOD DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle) = 0;
@ -499,8 +499,8 @@ public:
/**
* Fill an arc in the current forground color
* @param aRect The rectangle define bounds of ellipse to use
* @param aStartAngle the starting angle of the arc, in the ellipse
* @param aEndAngle The ending angle of the arc, in the ellipse
* @param aStartAngle the starting angle of the arc, in degrees
* @param aEndAngle The ending angle of the arc, in degrees
*/
NS_IMETHOD FillArc(const nsRect& aRect,
float aStartAngle, float aEndAngle) = 0;
@ -511,8 +511,8 @@ public:
* @param aY Vertical top Coordinate in twips
* @param aWidth Width of horizontal axis in twips
* @param aHeight Height of vertical axis in twips
* @param aStartAngle the starting angle of the arc, in the ellipse
* @param aEndAngle The ending angle of the arc, in the ellipse
* @param aStartAngle the starting angle of the arc, in degrees
* @param aEndAngle The ending angle of the arc, in degrees
*/
NS_IMETHOD FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle) = 0;

Просмотреть файл

@ -682,7 +682,7 @@ NS_IMETHODIMP nsDeviceContextMac::BeginDocument(PRUnichar * aTitle,
nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsIPrintingContext> printingContext = do_QueryInterface(mSpec);
if (printingContext)
rv = printingContext->BeginDocument(aStartPage, aEndPage);
rv = printingContext->BeginDocument(aTitle, aPrintToFileName, aStartPage, aEndPage);
return rv;
}

Просмотреть файл

@ -1,191 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Patrick C. Beard <beard@netscape.com>
* Simon Fraser <sfraser@netscape.com>
* Conrad Carlen <ccarlen@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsDeviceContextSpecX.h"
#include "prmem.h"
#include "plstr.h"
#include "nsIServiceManager.h"
#include "nsIPrintOptions.h"
#include "nsIPrintSettingsX.h"
/** -------------------------------------------------------
* Construct the nsDeviceContextSpecX
* @update dc 12/02/98
*/
nsDeviceContextSpecX::nsDeviceContextSpecX()
: mPrintSession(0)
, mPageFormat(kPMNoPageFormat)
, mPrintSettings(kPMNoPrintSettings)
, mSavedPort(0)
, mBeganPrinting(PR_FALSE)
{
}
/** -------------------------------------------------------
* Destroy the nsDeviceContextSpecX
* @update dc 12/02/98
*/
nsDeviceContextSpecX::~nsDeviceContextSpecX()
{
ClosePrintManager();
}
NS_IMPL_ISUPPORTS2(nsDeviceContextSpecX, nsIDeviceContextSpec, nsIPrintingContext)
/** -------------------------------------------------------
* Initialize the nsDeviceContextSpecMac
* @update dc 12/02/98
*/
NS_IMETHODIMP nsDeviceContextSpecX::Init(nsIPrintSettings* aPS, PRBool aIsPrintPreview)
{
nsresult rv;
nsCOMPtr<nsIPrintSettingsX> printSettingsX(do_QueryInterface(aPS));
if (!printSettingsX)
return NS_ERROR_NO_INTERFACE;
rv = printSettingsX->GetNativePrintSession(&mPrintSession);
if (NS_FAILED(rv))
return rv;
rv = printSettingsX->GetPMPageFormat(&mPageFormat);
if (NS_FAILED(rv))
return rv;
rv = printSettingsX->GetPMPrintSettings(&mPrintSettings);
if (NS_FAILED(rv))
return rv;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecX::PrintManagerOpen(PRBool* aIsOpen)
{
*aIsOpen = mBeganPrinting;
return NS_OK;
}
/** -------------------------------------------------------
* Closes the printmanager if it is open.
* @update dc 12/03/98
*/
NS_IMETHODIMP nsDeviceContextSpecX::ClosePrintManager()
{
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecX::BeginDocument(PRInt32 aStartPage,
PRInt32 aEndPage)
{
OSStatus status;
status = ::PMSetFirstPage(mPrintSettings, aStartPage, false);
NS_ASSERTION(status == noErr, "PMSetFirstPage failed");
status = ::PMSetLastPage(mPrintSettings, aEndPage, false);
NS_ASSERTION(status == noErr, "PMSetLastPage failed");
status = ::PMSessionBeginDocument(mPrintSession, mPrintSettings, mPageFormat);
if (status != noErr) return NS_ERROR_ABORT;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecX::EndDocument()
{
::PMSessionEndDocument(mPrintSession);
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecX::AbortDocument()
{
return EndDocument();
}
NS_IMETHODIMP nsDeviceContextSpecX::BeginPage()
{
OSStatus status = ::PMSessionBeginPage(mPrintSession, mPageFormat, NULL);
if (status != noErr) return NS_ERROR_ABORT;
::GetPort(&mSavedPort);
void *graphicsContext;
status = ::PMSessionGetGraphicsContext(mPrintSession, kPMGraphicsContextQuickdraw, &graphicsContext);
if (status != noErr)
return NS_ERROR_ABORT;
::SetPort((CGrafPtr)graphicsContext);
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecX::EndPage()
{
OSStatus status = ::PMSessionEndPage(mPrintSession);
if (mSavedPort)
{
::SetPort(mSavedPort);
mSavedPort = 0;
}
if (status != noErr)
return NS_ERROR_ABORT;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecX::GetPrinterResolution(double* aResolution)
{
PMPrinter printer;
OSStatus status = ::PMSessionGetCurrentPrinter(mPrintSession, &printer);
if (status != noErr)
return NS_ERROR_FAILURE;
PMResolution defaultResolution;
status = ::PMPrinterGetPrinterResolution(printer, kPMDefaultResolution, &defaultResolution);
if (status != noErr)
return NS_ERROR_FAILURE;
*aResolution = defaultResolution.hRes;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextSpecX::GetPageRect(double* aTop, double* aLeft, double* aBottom, double* aRight)
{
PMRect pageRect;
::PMGetAdjustedPageRect(mPageFormat, &pageRect);
*aTop = pageRect.top, *aLeft = pageRect.left;
*aBottom = pageRect.bottom, *aRight = pageRect.right;
return NS_OK;
}

Просмотреть файл

@ -1,112 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Patrick C. Beard <beard@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDeviceContextSpecX_h___
#define nsDeviceContextSpecX_h___
#include "nsIDeviceContextSpec.h"
#include "nsIPrintingContext.h"
#include "nsDeviceContextMac.h"
#include <PMApplication.h>
class nsDeviceContextSpecX : public nsIDeviceContextSpec, public nsIPrintingContext
{
public:
/**
* Construct a nsDeviceContextSpecMac, which is an object which contains and manages a mac printrecord
* @update dc 12/02/98
*/
nsDeviceContextSpecX();
NS_DECL_ISUPPORTS
/**
* Initialize the nsDeviceContextSpecMac for use. This will allocate a printrecord for use
* @update dc 12/02/98
* @param aIsPrintPreview TRUE if doing print preview, FALSE if normal printing.
* @return error status
*/
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aIsPrintPreview);
/**
* This will tell if the printmanager is currently open
* @update dc 12/03/98
* @param aIsOpen True or False depending if the printmanager is open
* @return error status
*/
NS_IMETHOD PrintManagerOpen(PRBool* aIsOpen);
/**
* Closes the printmanager if it is open.
* @update dc 12/03/98
* @return error status
*/
NS_IMETHOD ClosePrintManager();
NS_IMETHOD BeginDocument(PRInt32 aStartPage,
PRInt32 aEndPage);
NS_IMETHOD EndDocument();
NS_IMETHOD AbortDocument();
NS_IMETHOD BeginPage();
NS_IMETHOD EndPage();
NS_IMETHOD GetPrinterResolution(double* aResolution);
NS_IMETHOD GetPageRect(double* aTop, double* aLeft, double* aBottom, double* aRight);
protected:
/**
* Destuct a nsDeviceContextSpecMac, this will release the printrecord
* @update dc 12/02/98
*/
virtual ~nsDeviceContextSpecX();
protected:
PMPrintSession mPrintSession; // printing context.
PMPageFormat mPageFormat; // page format.
PMPrintSettings mPrintSettings; // print settings.
CGrafPtr mSavedPort; // saved graphics port.
PRBool mBeganPrinting;
};
#endif