Re-enable print preview gui stuff (which was mostly off) on GTK and Xlib

ports.  Bug 187125, patch by Roland.Mainz@informatik.med.uni-giessen.de (Roland
Mainz), r=smontagu, sr=rbs
This commit is contained in:
bzbarsky%mit.edu 2003-01-10 00:53:28 +00:00
Родитель e01849d5ba
Коммит d87fde2b51
13 изменённых файлов: 130 добавлений и 74 удалений

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

@ -584,19 +584,6 @@ nsPrintEngine::Print(nsIPrintSettings* aPrintSettings,
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(mContainer));
NS_ASSERTION(docShell, "This has to be a docshell");
if (mIsDoingPrintPreview) {
PRBool okToPrint = PR_FALSE;
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch) {
prefBranch->GetBoolPref("print.whileInPrintPreview", &okToPrint);
}
if (!okToPrint) {
ShowPrintErrorDialog(NS_ERROR_GFX_PRINTER_PRINT_WHILE_PREVIEW, PR_FALSE);
return NS_OK;
}
}
mPrt = new nsPrintData(nsPrintData::eIsPrinting);
if (!mPrt) {
PR_PL(("NS_ERROR_OUT_OF_MEMORY - Creating PrintData"));

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

@ -125,6 +125,11 @@ public:
/* Does this device allow to set/change number of copies for an document ? */
void SetCanChangeNumCopies( PRBool aCanSetNumCopies );
/* Does this device allow multiple devicecontext instances to be used in
* parallel (e.g. print while the device is already in use by print-preview
* or printing while another print job is in progress) ? */
void SetMultipleConcurrentDeviceContextsSupported( PRBool aCanUseMultipleInstances );
private:
/* private helper methods */
@ -204,6 +209,11 @@ void nsPrinterFeatures::SetCanChangeNumCopies( PRBool aCanSetNumCopies )
SetBoolValue("can_change_num_copies", aCanSetNumCopies);
}
void nsPrinterFeatures::SetMultipleConcurrentDeviceContextsSupported( PRBool aCanUseMultipleInstances )
{
SetBoolValue("can_use_multiple_devicecontexts_concurrently", aCanUseMultipleInstances);
}
#endif /* SET_PRINTER_FEATURES_VIA_PREFS */
//---------------
@ -791,6 +801,10 @@ NS_IMETHODIMP nsPrinterEnumeratorGTK::InitPrintSettingsFromPrinter(const PRUnich
/* Xprint does not allow the client to set a spooler command.
* Job spooling is the job of the server side (=Xprt) */
printerFeatures.SetCanChangeSpoolerCommand(PR_FALSE);
/* Mozilla's Xprint support allows multiple nsIDeviceContext instances
* be used in parallel */
printerFeatures.SetMultipleConcurrentDeviceContextsSupported(PR_TRUE);
#endif /* SET_PRINTER_FEATURES_VIA_PREFS */
XpuClosePrinterDisplay(pdpy, pcontext);

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

@ -125,7 +125,12 @@ public:
/* Does this device allow to set/change number of copies for an document ? */
void SetCanChangeNumCopies( PRBool aCanSetNumCopies );
/* Does this device allow multiple devicecontext instances to be used in
* parallel (e.g. print while the device is already in use by print-preview
* or printing while another print job is in progress) ? */
void SetMultipleConcurrentDeviceContextsSupported( PRBool aCanUseMultipleInstances );
private:
/* private helper methods */
void SetBoolValue( const char *tagname, PRBool value );
@ -204,6 +209,11 @@ void nsPrinterFeatures::SetCanChangeNumCopies( PRBool aCanSetNumCopies )
SetBoolValue("can_change_num_copies", aCanSetNumCopies);
}
void nsPrinterFeatures::SetMultipleConcurrentDeviceContextsSupported( PRBool aCanUseMultipleInstances )
{
SetBoolValue("can_use_multiple_devicecontexts_concurrently", aCanUseMultipleInstances);
}
#endif /* SET_PRINTER_FEATURES_VIA_PREFS */
//---------------
@ -799,6 +809,10 @@ NS_IMETHODIMP nsPrinterEnumeratorXlib::InitPrintSettingsFromPrinter(const PRUnic
/* Xprint does not allow the client to set a spooler command.
* Job spooling is the job of the server side (=Xprt) */
printerFeatures.SetCanChangeSpoolerCommand(PR_FALSE);
/* Mozilla's Xprint support allows multiple nsIDeviceContext instances
* be used in parallel */
printerFeatures.SetMultipleConcurrentDeviceContextsSupported(PR_TRUE);
#endif /* SET_PRINTER_FEATURES_VIA_PREFS */
XpuClosePrinterDisplay(pdpy, pcontext);

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

@ -44,6 +44,7 @@
#include "xlibrgb.h"
class nsFontMetricsXlibContext;
class nsRenderingContextXlibContext;
/* common baseclass for |nsDeviceContextXlib| and |nsDeviceContextXp| */
class nsDeviceContextX : public DeviceContextImpl
@ -60,6 +61,7 @@ public:
NS_IMETHOD GetXlibRgbHandle(XlibRgbHandle *&aHandle) = 0;
virtual void GetFontMetricsContext(nsFontMetricsXlibContext *&aContext) = 0;
virtual void GetRCContext(nsRenderingContextXlibContext *&aContext) = 0;
};
#endif /* !nsDeviceContextX_h__ */

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

@ -100,7 +100,7 @@ nsDeviceContextXlib::nsDeviceContextXlib()
if (!mXlibRgbHandle)
abort();
mFontMetricsContextCounter++;
mContextCounter++;
}
nsDeviceContextXlib::~nsDeviceContextXlib()
@ -109,17 +109,20 @@ nsDeviceContextXlib::~nsDeviceContextXlib()
NS_IF_RELEASE(surf);
mSurface = nsnull;
mFontMetricsContextCounter--;
mContextCounter--;
if (mFontMetricsContext && (mFontMetricsContextCounter == 0))
if (mContextCounter == 0)
{
DeleteRenderingContextXlibContext(mRCContext);
DeleteFontMetricsXlibContext(mFontMetricsContext);
mRCContext = nsnull;
mFontMetricsContext = nsnull;
}
}
nsFontMetricsXlibContext *nsDeviceContextXlib::mFontMetricsContext = nsnull;
int nsDeviceContextXlib::mFontMetricsContextCounter = 0;
nsFontMetricsXlibContext *nsDeviceContextXlib::mFontMetricsContext = nsnull;
nsRenderingContextXlibContext *nsDeviceContextXlib::mRCContext = nsnull;
int nsDeviceContextXlib::mContextCounter = 0;
NS_IMETHODIMP nsDeviceContextXlib::Init(nsNativeWidget aNativeWidget)
{
@ -203,6 +206,15 @@ nsDeviceContextXlib::CommonInit(void)
if (!mFontMetricsContext)
{
rv = CreateFontMetricsXlibContext(this, PR_FALSE, &mFontMetricsContext);
if (NS_FAILED(rv))
return rv;
}
if (!mRCContext)
{
rv = CreateRenderingContextXlibContext(this, &mRCContext);
if (NS_FAILED(rv))
return rv;
}
return rv;

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

@ -89,6 +89,7 @@ public:
XlibRgbHandle *GetXlibRgbHandle() { return mXlibRgbHandle; }
NS_IMETHOD GetDepth( PRUint32 &depth ) { depth = (PRUint32)mDepth; return NS_OK; }
virtual void GetFontMetricsContext(nsFontMetricsXlibContext *&aContext) { aContext = mFontMetricsContext; };
virtual void GetRCContext(nsRenderingContextXlibContext *&aContext) { aContext = mRCContext; };
protected:
virtual ~nsDeviceContextXlib();
@ -103,8 +104,9 @@ private:
Screen * mScreen;
Visual * mVisual;
int mDepth;
static nsFontMetricsXlibContext *mFontMetricsContext;
static int mFontMetricsContextCounter;
static nsFontMetricsXlibContext *mFontMetricsContext;
static nsRenderingContextXlibContext *mRCContext;
static int mContextCounter;
float mWidthFloat;
float mHeightFloat;

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

@ -201,7 +201,6 @@ static const nsModuleComponentInfo components[] =
PR_STATIC_CALLBACK(void)
nsGfxXlibModuleDtor(nsIModule *self)
{
nsRenderingContextXlib::Shutdown();
}
NS_IMPL_NSGETMODULE_WITH_DTOR(nsGfxXlibModule, components, nsGfxXlibModuleDtor)

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

@ -74,7 +74,34 @@ static void Widen8To16AndDraw(Drawable drawable,
int text_length);
nsGCCacheXlib *nsRenderingContextXlib::gcCache = nsnull;
class nsRenderingContextXlibContext
{
public:
nsGCCacheXlib mGcCache;
};
nsresult CreateRenderingContextXlibContext(nsIDeviceContext *aDevice, nsRenderingContextXlibContext **aContext)
{
nsRenderingContextXlibContext *rcctx;
*aContext = nsnull;
rcctx = new nsRenderingContextXlibContext();
if (!rcctx)
return NS_ERROR_OUT_OF_MEMORY;
/* No |Init()|-function to call (yet) */
*aContext = rcctx;
return NS_OK;
}
void DeleteRenderingContextXlibContext(nsRenderingContextXlibContext *aContext)
{
if (aContext) {
delete aContext;
}
}
class GraphicsState
{
@ -142,16 +169,6 @@ nsRenderingContextXlib::~nsRenderingContextXlib()
mGC->Release();
}
/*static*/ nsresult
nsRenderingContextXlib::Shutdown()
{
if (gcCache) {
delete gcCache;
gcCache = nsnull;
}
return NS_OK;
}
NS_IMETHODIMP
nsRenderingContextXlib::Init(nsIDeviceContext* aContext, nsIWidget *aWindow)
{
@ -604,15 +621,13 @@ void nsRenderingContextXlib::UpdateGC()
if (mClipRegion) {
mClipRegion->GetNativeRegion((void*&)rgn);
}
if (!gcCache) {
gcCache = new nsGCCacheXlib();
if (!gcCache)
return;
}
mGC = gcCache->GetGC(mDisplay, drawable,
valuesMask, &values, rgn);
nsRenderingContextXlibContext *rcContext;
nsIDeviceContext *dc = mContext;
NS_STATIC_CAST(nsDeviceContextX *, dc)->GetRCContext(rcContext);
mGC = rcContext->mGcCache.GetGC(mDisplay, drawable,
valuesMask, &values, rgn);
}
NS_IMETHODIMP

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

@ -66,7 +66,6 @@ class nsRenderingContextXlib : public nsRenderingContextImpl
public:
nsRenderingContextXlib();
virtual ~nsRenderingContextXlib();
static nsresult Shutdown(); // release statics
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
@ -272,8 +271,10 @@ protected:
w = 32766 - x;
}
}
static nsGCCacheXlib *gcCache;
};
/* Prototypes */
nsresult CreateRenderingContextXlibContext(nsIDeviceContext *aDevice, nsRenderingContextXlibContext **aContext);
void DeleteRenderingContextXlibContext(nsRenderingContextXlibContext *aContext);
#endif /* !nsRenderingContextXlib_h___ */

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

@ -62,7 +62,8 @@ nsDeviceContextXp :: nsDeviceContextXp()
mPrintContext(nsnull),
mSpec(nsnull),
mParentDeviceContext(nsnull),
mFontMetricsContext(nsnull)
mFontMetricsContext(nsnull),
mRCContext(nsnull)
{
}
@ -144,15 +145,18 @@ nsDeviceContextXp::InitDeviceContextXP(nsIDeviceContext *aCreatingDeviceContext,
mParentDeviceContext = aParentContext;
/* be sure we've cleaned-up old rubbish - new values will re-populate nsFontMetricsXlib soon... */
if (mFontMetricsContext)
{
DeleteFontMetricsXlibContext(mFontMetricsContext);
mFontMetricsContext = nsnull;
}
DeleteRenderingContextXlibContext(mRCContext);
DeleteFontMetricsXlibContext(mFontMetricsContext);
mRCContext = nsnull;
mFontMetricsContext = nsnull;
rv = CreateFontMetricsXlibContext(this, PR_TRUE, &mFontMetricsContext);
if (NS_FAILED(rv))
return rv;
rv = CreateRenderingContextXlibContext(this, &mRCContext);
if (NS_FAILED(rv))
return rv;
return NS_OK;
}
@ -310,12 +314,10 @@ void nsDeviceContextXp::DestroyXPContext()
* properties (build-in fonts for example ) than the printer
* previously used. */
FlushFontCache();
nsRenderingContextXlib::Shutdown();
if (mFontMetricsContext)
{
DeleteFontMetricsXlibContext(mFontMetricsContext);
mFontMetricsContext = nsnull;
}
DeleteRenderingContextXlibContext(mRCContext);
DeleteFontMetricsXlibContext(mFontMetricsContext);
mRCContext = nsnull;
mFontMetricsContext = nsnull;
mPrintContext = nsnull; // nsCOMPtr will call |delete mPrintContext;|
}

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

@ -103,7 +103,8 @@ public:
NS_IMETHOD CreateFontCache();
virtual void GetFontMetricsContext(nsFontMetricsXlibContext *&aContext) { aContext = mFontMetricsContext; };
virtual void GetRCContext(nsRenderingContextXlibContext *&aContext) { aContext = mRCContext; };
protected:
virtual ~nsDeviceContextXp();
void DestroyXPContext();
@ -112,6 +113,7 @@ protected:
nsCOMPtr<nsIDeviceContextSpec> mSpec;
nsCOMPtr<nsIDeviceContext> mParentDeviceContext;
nsFontMetricsXlibContext *mFontMetricsContext;
nsRenderingContextXlibContext *mRCContext;
};
#endif /* !nsDeviceContextXp_h___ */

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

@ -584,19 +584,6 @@ nsPrintEngine::Print(nsIPrintSettings* aPrintSettings,
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(mContainer));
NS_ASSERTION(docShell, "This has to be a docshell");
if (mIsDoingPrintPreview) {
PRBool okToPrint = PR_FALSE;
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefBranch) {
prefBranch->GetBoolPref("print.whileInPrintPreview", &okToPrint);
}
if (!okToPrint) {
ShowPrintErrorDialog(NS_ERROR_GFX_PRINTER_PRINT_WHILE_PREVIEW, PR_FALSE);
return NS_OK;
}
}
mPrt = new nsPrintData(nsPrintData::eIsPrinting);
if (!mPrt) {
PR_PL(("NS_ERROR_OUT_OF_MEMORY - Creating PrintData"));

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

@ -170,15 +170,35 @@
} catch(e) {}
// XXX TEMPORARY
// XXX Until bug 119491 ("Cleanup global vars in PostScript and Xprint
// modules") is fixed we will hide the ``Print...'' button
// Hide the ``Print...'' button when the underlying gfx code does not
// support multiple devicecontext to be used concurrently
// (e.g. printing and printpreview at the same time; required as
// legacy support for unices.'s PostScript module (Xprint
// on unices.does not have problems with that))
// XXX the scaling widgets, and the orientation widgets on unices.
var canPrint = true;
try
{
var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
canPrint = prefs.getBoolPref("print.whileInPrintPreview");
if (!canPrint)
{
// Ask the printerfeatures database if this printer device
// supports multiple device instances which can be used
// concurrently
var smdci = prefs.getBoolPref("print.tmp.printerfeatures." +
print.currentPrintSettings.printerName +
".can_use_multiple_devicecontexts_concurrently");
// We can print from print preview when we can use multiple
// devicecontext instances in parallel (regardless what
// "print.whileInPrintPreview" may say here...)
if (smdci)
{
canPrint = true;
}
}
} catch(e) {}
if (!canPrint)
@ -197,7 +217,6 @@
document.getAnonymousNodes(this)[i].setAttribute("hidden", "true");
}
}
// XXX TEMPORARY
]]>
</constructor>