зеркало из https://github.com/mozilla/pjs.git
Bug 226600 - Add a print preview flag to *nix print device context specs.
r=blizzard, sr=roc
This commit is contained in:
Родитель
cb3684b13c
Коммит
ca75dc2060
|
@ -1,94 +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) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
|
||||
*
|
||||
* 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 "nsDeviceContextSpecFactoryG.h"
|
||||
#include "nsDeviceContextSpecG.h"
|
||||
#include "nsGfxCIID.h"
|
||||
#include "plstr.h"
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* Constructor
|
||||
* @update dc 2/16/98
|
||||
*/
|
||||
nsDeviceContextSpecFactoryGTK :: nsDeviceContextSpecFactoryGTK()
|
||||
{
|
||||
}
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* Destructor
|
||||
* @update dc 2/16/98
|
||||
*/
|
||||
nsDeviceContextSpecFactoryGTK :: ~nsDeviceContextSpecFactoryGTK()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsDeviceContextSpecFactoryGTK, nsIDeviceContextSpecFactory)
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* Initialize the device context spec factory
|
||||
* @update dc 2/16/98
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextSpecFactoryGTK :: Init(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* Get a device context specification
|
||||
* @update dc 2/16/98
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextSpecFactoryGTK :: CreateDeviceContextSpec(nsIWidget *aWidget,
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aIsPrintPreview)
|
||||
{
|
||||
nsresult rv;
|
||||
static NS_DEFINE_CID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
|
||||
nsCOMPtr<nsIDeviceContextSpec> devSpec = do_CreateInstance(kDeviceContextSpecCID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = ((nsDeviceContextSpecGTK *)devSpec.get())->Init(aPrintSettings);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
aNewSpec = devSpec;
|
||||
NS_ADDREF(aNewSpec);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
|
@ -319,13 +319,11 @@ NS_IMPL_ISUPPORTS1(nsDeviceContextSpecGTK,
|
|||
* - Xlib-toolkit:
|
||||
* file: mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp
|
||||
* function: NS_IMETHODIMP nsDeviceContextSpecXlib::Init()
|
||||
* - Qt-toolkit:
|
||||
* file: mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp
|
||||
* function: NS_IMETHODIMP nsDeviceContextSpecQT::Init()
|
||||
*
|
||||
* ** Please update the other toolkits when changing this function.
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextSpecGTK::Init(nsIPrintSettings *aPS)
|
||||
NS_IMETHODIMP nsDeviceContextSpecGTK::Init(nsIPrintSettings *aPS,
|
||||
PRBool aIsPrintPreview)
|
||||
{
|
||||
DO_PR_DEBUG_LOG(("nsDeviceContextSpecGTK::Init(aPS=%p)\n", aPS));
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
@ -408,6 +406,7 @@ NS_IMETHODIMP nsDeviceContextSpecGTK::Init(nsIPrintSettings *aPS)
|
|||
mOrientation = orientation;
|
||||
mToPrinter = !tofile;
|
||||
mCopies = copies;
|
||||
mIsPPreview = aIsPrintPreview;
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -419,6 +418,12 @@ NS_IMETHODIMP nsDeviceContextSpecGTK::GetToPrinter(PRBool &aToPrinter)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecGTK::GetIsPrintPreview(PRBool &aIsPPreview)
|
||||
{
|
||||
aIsPPreview = mIsPPreview;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecGTK::GetPrinterName ( const char **aPrinter )
|
||||
{
|
||||
*aPrinter = mPrinter;
|
||||
|
|
|
@ -75,10 +75,11 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init(nsIPrintSettings* aPS);
|
||||
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aIsPrintPreview);
|
||||
NS_IMETHOD ClosePrintManager();
|
||||
|
||||
NS_IMETHOD GetToPrinter(PRBool &aToPrinter);
|
||||
NS_IMETHOD GetIsPrintPreview(PRBool &aIsPPreview);
|
||||
NS_IMETHOD GetPrinterName ( const char **aPrinter );
|
||||
NS_IMETHOD GetCopies ( int &aCopies );
|
||||
NS_IMETHOD GetFirstPageFirst(PRBool &aFpf);
|
||||
|
@ -100,9 +101,11 @@ public:
|
|||
|
||||
protected:
|
||||
nsCOMPtr<nsIPrintSettings> mPrintSettings;
|
||||
PRBool mToPrinter; /* If PR_TRUE, print to printer */
|
||||
PRBool mFpf; /* If PR_TRUE, first page first */
|
||||
PRBool mGrayscale; /* If PR_TRUE, print grayscale */
|
||||
PRBool mToPrinter : 1; /* If PR_TRUE, print to printer */
|
||||
PRBool mIsPPreview : 1; /* If PR_TRUE, is print preview */
|
||||
PRBool mFpf : 1; /* If PR_TRUE, first page first */
|
||||
PRBool mGrayscale : 1; /* If PR_TRUE, print grayscale */
|
||||
PRBool mCancel : 1; /* If PR_TRUE, user cancelled */
|
||||
int mOrientation; /* Orientation e.g. Portrait */
|
||||
char mCommand[PATH_MAX]; /* Print command e.g., lpr */
|
||||
char mPath[PATH_MAX]; /* If toPrinter = PR_FALSE, dest file */
|
||||
|
@ -110,7 +113,6 @@ protected:
|
|||
char mPaperName[256]; /* Printer name */
|
||||
char mPlexName[256]; /* Plex mode name */
|
||||
int mCopies; /* number of copies */
|
||||
PRBool mCancel; /* If PR_TRUE, user cancelled */
|
||||
float mLeft; /* left margin */
|
||||
float mRight; /* right margin */
|
||||
float mTop; /* top margin */
|
||||
|
|
|
@ -62,6 +62,14 @@ public:
|
|||
**/
|
||||
NS_IMETHOD GetToPrinter( PRBool &aToPrinter ) = 0;
|
||||
|
||||
/*
|
||||
* If PR_TRUE, print to printer
|
||||
* @update
|
||||
* @param aIsPPreview -- Set to PR_TRUE for print preview, PR_FALSE otherwise.
|
||||
* @return
|
||||
**/
|
||||
NS_IMETHOD GetIsPrintPreview( PRBool &aIsPPreview ) = 0;
|
||||
|
||||
/*
|
||||
* If PR_TRUE, first page first
|
||||
* @update
|
||||
|
|
|
@ -54,29 +54,34 @@
|
|||
|
||||
nsresult
|
||||
nsPrintJobFactoryPS::CreatePrintJob(nsIDeviceContextSpecPS *aSpec,
|
||||
nsIPrintJobPS* &aPrintJob)
|
||||
nsIPrintJobPS* &aPrintJob)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aSpec, "aSpec is NULL");
|
||||
|
||||
nsIPrintJobPS *newPJ;
|
||||
|
||||
PRBool destIsPrinter;
|
||||
aSpec->GetToPrinter(destIsPrinter);
|
||||
if (destIsPrinter)
|
||||
PRBool setting;
|
||||
aSpec->GetIsPrintPreview(setting);
|
||||
if (setting)
|
||||
newPJ = new nsPrintJobPreviewPS();
|
||||
else {
|
||||
aSpec->GetToPrinter(setting);
|
||||
if (setting)
|
||||
#ifdef VMS
|
||||
newPJ = new nsPrintJobVMSCmdPS();
|
||||
newPJ = new nsPrintJobVMSCmdPS();
|
||||
#else
|
||||
newPJ = new nsPrintJobPipePS();
|
||||
newPJ = new nsPrintJobPipePS();
|
||||
#endif
|
||||
else
|
||||
newPJ = new nsPrintJobFilePS();
|
||||
else
|
||||
newPJ = new nsPrintJobFilePS();
|
||||
}
|
||||
if (!newPJ)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult rv = newPJ->Init(aSpec);
|
||||
if (NS_FAILED(rv))
|
||||
delete newPJ;
|
||||
delete newPJ;
|
||||
else
|
||||
aPrintJob = newPJ;
|
||||
aPrintJob = newPJ;
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -1,80 +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):
|
||||
* Vino Fernando Crescini <vino@igelaus.com.au>
|
||||
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
|
||||
*
|
||||
* 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 "nsDeviceContextSpecFactoryX.h"
|
||||
#include "nsDeviceContextSpecXlib.h"
|
||||
#include "nsGfxCIID.h"
|
||||
#include "plstr.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsDeviceContextSpecFactoryXlib, nsIDeviceContextSpecFactory)
|
||||
|
||||
nsDeviceContextSpecFactoryXlib::nsDeviceContextSpecFactoryXlib()
|
||||
{
|
||||
}
|
||||
|
||||
nsDeviceContextSpecFactoryXlib::~nsDeviceContextSpecFactoryXlib()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecFactoryXlib::Init(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecFactoryXlib::CreateDeviceContextSpec(nsIWidget *aWidget,
|
||||
nsIPrintSettings* aPrintSettings,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aIsPrintPreview)
|
||||
{
|
||||
nsresult rv;
|
||||
static NS_DEFINE_CID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
|
||||
nsCOMPtr<nsIDeviceContextSpec> devSpec = do_CreateInstance(kDeviceContextSpecCID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = ((nsDeviceContextSpecXlib *)devSpec.get())->Init(aPrintSettings);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
aNewSpec = devSpec;
|
||||
NS_ADDREF(aNewSpec);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
|
@ -319,13 +319,11 @@ NS_IMPL_ISUPPORTS1(nsDeviceContextSpecXlib,
|
|||
* - Xlib-toolkit:
|
||||
* file: mozilla/gfx/src/xlib/nsDeviceContextSpecXlib.cpp
|
||||
* function: NS_IMETHODIMP nsDeviceContextSpecXlib::Init()
|
||||
* - Qt-toolkit:
|
||||
* file: mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp
|
||||
* function: NS_IMETHODIMP nsDeviceContextSpecQT::Init()
|
||||
*
|
||||
* ** Please update the other toolkits when changing this function.
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextSpecXlib::Init(nsIPrintSettings *aPS)
|
||||
NS_IMETHODIMP nsDeviceContextSpecXlib::Init(nsIPrintSettings *aPS,
|
||||
PRBool aIsPrintPreview)
|
||||
{
|
||||
DO_PR_DEBUG_LOG(("nsDeviceContextSpecXlib::Init(aPS=%p)\n", aPS));
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
@ -408,6 +406,7 @@ NS_IMETHODIMP nsDeviceContextSpecXlib::Init(nsIPrintSettings *aPS)
|
|||
mOrientation = orientation;
|
||||
mToPrinter = !tofile;
|
||||
mCopies = copies;
|
||||
mIsPPreview = aIsPrintPreview;
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -419,6 +418,12 @@ NS_IMETHODIMP nsDeviceContextSpecXlib::GetToPrinter(PRBool &aToPrinter)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecXlib::GetIsPrintPreview(PRBool &aIsPPreview)
|
||||
{
|
||||
aIsPPreview = mIsPPreview;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecXlib::GetPrinterName ( const char **aPrinter )
|
||||
{
|
||||
*aPrinter = mPrinter;
|
||||
|
|
|
@ -75,10 +75,11 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init(nsIPrintSettings* aPS);
|
||||
NS_IMETHOD Init(nsIPrintSettings* aPS, PRBool aIsPrintPreview);
|
||||
NS_IMETHOD ClosePrintManager();
|
||||
|
||||
NS_IMETHOD GetToPrinter(PRBool &aToPrinter);
|
||||
NS_IMETHOD GetIsPrintPreview(PRBool &aIsPPreview);
|
||||
NS_IMETHOD GetPrinterName ( const char **aPrinter );
|
||||
NS_IMETHOD GetCopies ( int &aCopies );
|
||||
NS_IMETHOD GetFirstPageFirst(PRBool &aFpf);
|
||||
|
@ -100,9 +101,11 @@ public:
|
|||
|
||||
protected:
|
||||
nsCOMPtr<nsIPrintSettings> mPrintSettings;
|
||||
PRBool mToPrinter; /* If PR_TRUE, print to printer */
|
||||
PRBool mFpf; /* If PR_TRUE, first page first */
|
||||
PRBool mGrayscale; /* If PR_TRUE, print grayscale */
|
||||
PRBool mToPrinter : 1; /* If PR_TRUE, print to printer */
|
||||
PRBool mIsPPreview : 1; /* If PR_TRUE, is print preview */
|
||||
PRBool mFpf : 1; /* If PR_TRUE, first page first */
|
||||
PRBool mGrayscale : 1; /* If PR_TRUE, print grayscale */
|
||||
PRBool mCancel : 1; /* If PR_TRUE, user cancelled */
|
||||
int mOrientation; /* Orientation e.g. Portrait */
|
||||
char mCommand[PATH_MAX]; /* Print command e.g., lpr */
|
||||
char mPath[PATH_MAX]; /* If toPrinter = PR_FALSE, dest file */
|
||||
|
@ -110,7 +113,6 @@ protected:
|
|||
char mPaperName[256]; /* Printer name */
|
||||
char mPlexName[256]; /* Plex mode name */
|
||||
int mCopies; /* number of copies */
|
||||
PRBool mCancel; /* If PR_TRUE, user cancelled */
|
||||
float mLeft; /* left margin */
|
||||
float mRight; /* right margin */
|
||||
float mTop; /* top margin */
|
||||
|
|
Загрузка…
Ссылка в новой задаче