2008-09-25 06:26:58 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-01-12 00:54:29 +03:00
|
|
|
|
2007-01-18 09:34:07 +03:00
|
|
|
#ifndef nsPrintSettingsX_h_
|
|
|
|
#define nsPrintSettingsX_h_
|
2007-01-12 00:54:29 +03:00
|
|
|
|
|
|
|
#include "nsPrintSettingsImpl.h"
|
2009-10-09 09:20:37 +04:00
|
|
|
#import <Cocoa/Cocoa.h>
|
2007-01-12 00:54:29 +03:00
|
|
|
|
2017-02-06 05:02:50 +03:00
|
|
|
// The constants for paper orientation were renamed in 10.9. __MAC_10_9 is
|
|
|
|
// defined on OS X 10.9 and later. Although 10.8 and earlier are not supported
|
|
|
|
// at this time, this allows for building on those older OS versions. The
|
|
|
|
// values are consistent across OS versions so the rename does not affect
|
|
|
|
// runtime, just compilation.
|
|
|
|
#ifdef __MAC_10_9
|
|
|
|
# define NS_PAPER_ORIENTATION_PORTRAIT (NSPaperOrientationPortrait)
|
|
|
|
# define NS_PAPER_ORIENTATION_LANDSCAPE (NSPaperOrientationLandscape)
|
|
|
|
#else
|
|
|
|
# define NS_PAPER_ORIENTATION_PORTRAIT (NSPortraitOrientation)
|
|
|
|
# define NS_PAPER_ORIENTATION_LANDSCAPE (NSLandscapeOrientation)
|
|
|
|
#endif
|
|
|
|
|
2014-03-25 20:32:58 +04:00
|
|
|
#define NS_PRINTSETTINGSX_IID \
|
2018-11-30 13:46:48 +03:00
|
|
|
{ \
|
2014-03-25 20:32:58 +04:00
|
|
|
0x0DF2FDBD, 0x906D, 0x4726, { \
|
|
|
|
0x9E, 0x4D, 0xCF, 0xE0, 0x87, 0x8D, 0x70, 0x7C \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2009-10-09 09:20:37 +04:00
|
|
|
class nsPrintSettingsX : public nsPrintSettings {
|
2007-01-12 00:54:29 +03:00
|
|
|
public:
|
2014-03-25 20:32:58 +04:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_PRINTSETTINGSX_IID)
|
2007-01-12 00:54:29 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
nsPrintSettingsX();
|
2009-10-09 09:14:31 +04:00
|
|
|
nsresult Init();
|
2019-05-01 11:47:10 +03:00
|
|
|
NSPrintInfo* GetCocoaPrintInfo() { return mPrintInfo; }
|
|
|
|
void SetCocoaPrintInfo(NSPrintInfo* aPrintInfo);
|
2009-10-09 09:20:37 +04:00
|
|
|
virtual nsresult ReadPageFormatFromPrefs();
|
|
|
|
virtual nsresult WritePageFormatToPrefs();
|
2019-05-01 11:47:10 +03:00
|
|
|
virtual nsresult GetEffectivePageSize(double* aWidth,
|
|
|
|
double* aHeight) override;
|
|
|
|
void GetFilePageSize(double* aWidth, double* aHeight);
|
2016-11-18 02:29:08 +03:00
|
|
|
|
|
|
|
// In addition to setting the paper width and height, these
|
|
|
|
// overrides set the adjusted width and height returned from
|
|
|
|
// GetEffectivePageSize. This is needed when a paper size is
|
2017-07-27 08:53:46 +03:00
|
|
|
// set manually without using a print dialog a la reftest-paged.
|
2016-11-18 02:29:08 +03:00
|
|
|
virtual nsresult SetPaperWidth(double aPaperWidth) override;
|
|
|
|
virtual nsresult SetPaperHeight(double aPaperWidth) override;
|
2009-10-09 09:20:37 +04:00
|
|
|
|
|
|
|
PMPrintSettings GetPMPrintSettings();
|
|
|
|
PMPrintSession GetPMPrintSession();
|
|
|
|
PMPageFormat GetPMPageFormat();
|
|
|
|
void SetPMPageFormat(PMPageFormat aPageFormat);
|
2009-10-01 02:15:32 +04:00
|
|
|
|
2016-11-10 04:37:40 +03:00
|
|
|
// Re-initialize mUnwriteableMargin with values from mPageFormat.
|
|
|
|
// Should be called whenever mPageFormat is initialized or overwritten.
|
|
|
|
nsresult InitUnwriteableMargin();
|
|
|
|
|
2016-11-18 02:29:08 +03:00
|
|
|
// Re-initialize mAdjustedPaper{Width,Height} with values from mPageFormat.
|
|
|
|
// Should be called whenever mPageFormat is initialized or overwritten.
|
|
|
|
nsresult InitAdjustedPaperSize();
|
|
|
|
|
2016-11-10 04:37:40 +03:00
|
|
|
void SetInchesScale(float aWidthScale, float aHeightScale);
|
2019-05-01 11:47:10 +03:00
|
|
|
void GetInchesScale(float* aWidthScale, float* aHeightScale);
|
2016-11-10 04:37:40 +03:00
|
|
|
|
2017-02-06 05:02:50 +03:00
|
|
|
NS_IMETHOD SetScaling(double aScaling) override;
|
2019-05-01 11:47:10 +03:00
|
|
|
NS_IMETHOD GetScaling(double* aScaling) override;
|
2017-06-15 01:06:18 +03:00
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
NS_IMETHOD SetToFileName(const nsAString& aToFileName) override;
|
2017-02-06 05:02:50 +03:00
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
NS_IMETHOD GetOrientation(int32_t* aOrientation) override;
|
2017-02-06 05:02:50 +03:00
|
|
|
NS_IMETHOD SetOrientation(int32_t aOrientation) override;
|
|
|
|
|
|
|
|
NS_IMETHOD SetUnwriteableMarginTop(double aUnwriteableMarginTop) override;
|
|
|
|
NS_IMETHOD SetUnwriteableMarginLeft(double aUnwriteableMarginLeft) override;
|
|
|
|
NS_IMETHOD SetUnwriteableMarginBottom(
|
|
|
|
double aUnwriteableMarginBottom) override;
|
|
|
|
NS_IMETHOD SetUnwriteableMarginRight(double aUnwriteableMarginRight) override;
|
|
|
|
|
2016-11-18 02:29:08 +03:00
|
|
|
void SetAdjustedPaperSize(double aWidth, double aHeight);
|
2019-05-01 11:47:10 +03:00
|
|
|
void GetAdjustedPaperSize(double* aWidth, double* aHeight);
|
2017-02-06 05:02:50 +03:00
|
|
|
nsresult SetCocoaPaperSize(double aWidth, double aHeight);
|
2016-11-18 02:29:08 +03:00
|
|
|
|
2019-03-26 23:15:53 +03:00
|
|
|
// Set the printer name using the native PrintInfo data.
|
|
|
|
void SetPrinterNameFromPrintInfo();
|
|
|
|
|
2007-01-12 00:54:29 +03:00
|
|
|
protected:
|
2014-07-09 01:23:18 +04:00
|
|
|
virtual ~nsPrintSettingsX();
|
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
nsPrintSettingsX(const nsPrintSettingsX& src);
|
|
|
|
nsPrintSettingsX& operator=(const nsPrintSettingsX& rhs);
|
2007-01-12 00:54:29 +03:00
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
nsresult _Clone(nsIPrintSettings** _retval) override;
|
|
|
|
nsresult _Assign(nsIPrintSettings* aPS) override;
|
2008-09-25 06:26:58 +04:00
|
|
|
|
2017-02-06 05:02:50 +03:00
|
|
|
int GetCocoaUnit(int16_t aGeckoUnit);
|
|
|
|
|
2007-01-12 00:54:29 +03:00
|
|
|
// The out param has a ref count of 1 on return so caller needs to PMRelase()
|
|
|
|
// when done.
|
|
|
|
OSStatus CreateDefaultPageFormat(PMPrintSession aSession,
|
2019-05-01 11:47:10 +03:00
|
|
|
PMPageFormat& outFormat);
|
2007-01-12 00:54:29 +03:00
|
|
|
OSStatus CreateDefaultPrintSettings(PMPrintSession aSession,
|
2019-05-01 11:47:10 +03:00
|
|
|
PMPrintSettings& outSettings);
|
2007-01-12 00:54:29 +03:00
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
NSPrintInfo* mPrintInfo;
|
2016-11-10 04:37:40 +03:00
|
|
|
|
|
|
|
// Scaling factors used to convert the NSPrintInfo
|
|
|
|
// paper size units to inches
|
|
|
|
float mWidthScale;
|
|
|
|
float mHeightScale;
|
2016-11-18 02:29:08 +03:00
|
|
|
double mAdjustedPaperWidth;
|
|
|
|
double mAdjustedPaperHeight;
|
2007-01-12 00:54:29 +03:00
|
|
|
};
|
|
|
|
|
2014-03-25 20:32:58 +04:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsPrintSettingsX, NS_PRINTSETTINGSX_IID)
|
|
|
|
|
2007-01-18 09:34:07 +03:00
|
|
|
#endif // nsPrintSettingsX_h_
|