зеркало из https://github.com/mozilla/gecko-dev.git
Bug 154883 - Use session printing APIs on Mac OSX. r=pinkerton/sr=sfraser/a=asa
This commit is contained in:
Родитель
18b367b406
Коммит
781a7e0d63
|
@ -49,6 +49,8 @@
|
|||
* Native types
|
||||
*/
|
||||
[ref] native nsNativeMarginRef(nsMargin);
|
||||
|
||||
interface nsIPrintSession;
|
||||
|
||||
/**
|
||||
* Simplified graphics interface for JS rendering.
|
||||
|
@ -179,6 +181,8 @@ interface nsIPrintSettings : nsISupports
|
|||
/**
|
||||
* Data Members
|
||||
*/
|
||||
[noscript] attribute nsIPrintSession printSession; /* We hold a weak reference */
|
||||
|
||||
attribute long startPageRange;
|
||||
attribute long endPageRange;
|
||||
|
||||
|
@ -231,7 +235,7 @@ interface nsIPrintSettings : nsISupports
|
|||
attribute wstring toFileName;
|
||||
|
||||
attribute long printPageDelay; /* in milliseconds */
|
||||
|
||||
|
||||
/* C++ Helper Functions */
|
||||
[noscript] void SetMarginInTwips(in nsNativeMarginRef aMargin);
|
||||
/* Purposely made this an "in" arg */
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
*/
|
||||
native nsPMPageFormat(PMPageFormat);
|
||||
native nsPMPrintSettings(PMPrintSettings);
|
||||
|
||||
native nsPMPrintSession(PMPrintSession);
|
||||
|
||||
/**
|
||||
* Simplified PrintSettings for OSX interface
|
||||
|
@ -60,18 +60,27 @@ native nsPMPrintSettings(PMPrintSettings);
|
|||
|
||||
interface nsIPrintSettingsX : nsISupports
|
||||
{
|
||||
/**
|
||||
* nativePrintSession attribute
|
||||
*
|
||||
* Convenience method which gets the nsIPrintSession
|
||||
* and returns its native session object
|
||||
*
|
||||
* Does NOT do PMRetain() on result.
|
||||
*/
|
||||
[noscript] readonly attribute nsPMPrintSession nativePrintSession;
|
||||
|
||||
/*
|
||||
/**
|
||||
* PMPageFormat and PMPrintSettings attributes
|
||||
*
|
||||
* Getter returns a clone of the current data
|
||||
* Setter copies (does not take ownership of) the input
|
||||
* Getter does NOT do PMRetain() on result.
|
||||
* Setter does PMRetain() on parameter.
|
||||
*/
|
||||
[noscript] attribute nsPMPageFormat pMPageFormat;
|
||||
|
||||
[noscript] attribute nsPMPrintSettings pMPrintSettings;
|
||||
|
||||
/*
|
||||
/**
|
||||
* readPageFormatFromPrefs and writePageFormatToPrefs
|
||||
*
|
||||
* Read and write a flattened PMPageFormat to/from prefs.
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "nsCoord.h"
|
||||
#include "nsUnitConversion.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIPrintSession.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsPrintSettings, nsIPrintSettings)
|
||||
|
||||
|
@ -110,6 +111,34 @@ nsPrintSettings::~nsPrintSettings()
|
|||
{
|
||||
}
|
||||
|
||||
/* [noscript] attribute nsIPrintSession printSession; */
|
||||
NS_IMETHODIMP nsPrintSettings::GetPrintSession(nsIPrintSession **aPrintSession)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPrintSession);
|
||||
*aPrintSession = nsnull;
|
||||
|
||||
nsCOMPtr<nsIPrintSession> session = do_QueryReferent(mSession);
|
||||
if (!session)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
*aPrintSession = session;
|
||||
NS_ADDREF(*aPrintSession);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsPrintSettings::SetPrintSession(nsIPrintSession *aPrintSession)
|
||||
{
|
||||
// Clearing it by passing NULL is not allowed. That's why we
|
||||
// use a weak ref so that it doesn't have to be cleared.
|
||||
NS_ENSURE_ARG(aPrintSession);
|
||||
|
||||
mSession = getter_AddRefs(NS_GetWeakReference(aPrintSession));
|
||||
if (!mSession) {
|
||||
// This may happen if the implementation of this object does
|
||||
// not support weak references - programmer error.
|
||||
NS_ERROR("Could not get a weak reference from aPrintSession");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute long startPageRange; */
|
||||
NS_IMETHODIMP nsPrintSettings::GetStartPageRange(PRInt32 *aStartPageRange)
|
||||
|
|
|
@ -25,7 +25,8 @@
|
|||
|
||||
#include "nsIPrintSettings.h"
|
||||
#include "nsMargin.h"
|
||||
#include "nsString.h"
|
||||
#include "nsString.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
#define NUM_HEAD_FOOT 3
|
||||
|
||||
|
@ -58,7 +59,9 @@ protected:
|
|||
nsresult GetMarginStrs(PRUnichar * *aTitle, nsHeaderFooterEnum aType, PRInt16 aJust);
|
||||
nsresult SetMarginStrs(const PRUnichar * aTitle, nsHeaderFooterEnum aType, PRInt16 aJust);
|
||||
|
||||
// Members
|
||||
// Members
|
||||
nsWeakPtr mSession; // Should never be touched by Clone or Assign
|
||||
|
||||
nsMargin mMargin;
|
||||
PRInt32 mPrintOptions;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче