2010-10-07 23:19:33 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
*
|
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/. */
|
2010-10-07 23:19:33 +04:00
|
|
|
|
|
|
|
#include <QPrinter>
|
|
|
|
#include <QDebug>
|
|
|
|
#include "nsPrintSettingsQt.h"
|
2012-06-06 06:08:30 +04:00
|
|
|
#include "nsIFile.h"
|
2010-10-07 23:19:33 +04:00
|
|
|
#include "nsCRTGlue.h"
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS_INHERITED1(nsPrintSettingsQt,
|
|
|
|
nsPrintSettings,
|
|
|
|
nsPrintSettingsQt)
|
|
|
|
|
|
|
|
nsPrintSettingsQt::nsPrintSettingsQt():
|
|
|
|
mQPrinter(new QPrinter())
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPrintSettingsQt::~nsPrintSettingsQt()
|
|
|
|
{
|
|
|
|
//smart pointer should take care of cleanup
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPrintSettingsQt::nsPrintSettingsQt(const nsPrintSettingsQt& aPS):
|
|
|
|
mQPrinter(aPS.mQPrinter)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPrintSettingsQt&
|
|
|
|
nsPrintSettingsQt::operator=(const nsPrintSettingsQt& rhs)
|
|
|
|
{
|
|
|
|
if (this == &rhs) {
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPrintSettings::operator=(rhs);
|
|
|
|
mQPrinter = rhs.mQPrinter;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsPrintSettingsQt::_Clone(nsIPrintSettings** _retval)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(_retval);
|
|
|
|
|
|
|
|
nsPrintSettingsQt* newSettings = new nsPrintSettingsQt(*this);
|
|
|
|
*_retval = newSettings;
|
|
|
|
NS_ADDREF(*_retval);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPrintSettingsQt::_Assign(nsIPrintSettings* aPS)
|
|
|
|
{
|
|
|
|
nsPrintSettingsQt* printSettingsQt = static_cast<nsPrintSettingsQt*>(aPS);
|
|
|
|
if (!printSettingsQt)
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
*this = *printSettingsQt;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsPrintSettingsQt::GetPrintRange(int16_t* aPrintRange)
|
2010-10-07 23:19:33 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aPrintRange);
|
|
|
|
|
|
|
|
QPrinter::PrintRange range = mQPrinter->printRange();
|
|
|
|
if (range == QPrinter::PageRange) {
|
|
|
|
*aPrintRange = kRangeSpecifiedPageRange;
|
|
|
|
} else if (range == QPrinter::Selection) {
|
|
|
|
*aPrintRange = kRangeSelection;
|
|
|
|
} else {
|
|
|
|
*aPrintRange = kRangeAllPages;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsPrintSettingsQt::SetPrintRange(int16_t aPrintRange)
|
2010-10-07 23:19:33 +04:00
|
|
|
{
|
|
|
|
if (aPrintRange == kRangeSelection) {
|
|
|
|
mQPrinter->setPrintRange(QPrinter::Selection);
|
|
|
|
} else if (aPrintRange == kRangeSpecifiedPageRange) {
|
|
|
|
mQPrinter->setPrintRange(QPrinter::PageRange);
|
|
|
|
} else {
|
|
|
|
mQPrinter->setPrintRange(QPrinter::AllPages);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsPrintSettingsQt::GetStartPageRange(int32_t* aStartPageRange)
|
2010-10-07 23:19:33 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aStartPageRange);
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t start = mQPrinter->fromPage();
|
2010-10-07 23:19:33 +04:00
|
|
|
*aStartPageRange = start;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsPrintSettingsQt::SetStartPageRange(int32_t aStartPageRange)
|
2010-10-07 23:19:33 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t endRange = mQPrinter->toPage();
|
2010-10-07 23:19:33 +04:00
|
|
|
mQPrinter->setFromTo(aStartPageRange, endRange);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsPrintSettingsQt::GetEndPageRange(int32_t* aEndPageRange)
|
2010-10-07 23:19:33 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aEndPageRange);
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t end = mQPrinter->toPage();
|
2010-10-07 23:19:33 +04:00
|
|
|
*aEndPageRange = end;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsPrintSettingsQt::SetEndPageRange(int32_t aEndPageRange)
|
2010-10-07 23:19:33 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t startRange = mQPrinter->fromPage();
|
2010-10-07 23:19:33 +04:00
|
|
|
mQPrinter->setFromTo(startRange, aEndPageRange);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsPrintSettingsQt::GetPrintReversed(bool* aPrintReversed)
|
2010-10-07 23:19:33 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aPrintReversed);
|
|
|
|
if (mQPrinter->pageOrder() == QPrinter::LastPageFirst) {
|
2011-10-17 18:59:28 +04:00
|
|
|
*aPrintReversed = true;
|
2010-10-07 23:19:33 +04:00
|
|
|
} else {
|
2011-10-17 18:59:28 +04:00
|
|
|
*aPrintReversed = false;
|
2010-10-07 23:19:33 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsPrintSettingsQt::SetPrintReversed(bool aPrintReversed)
|
2010-10-07 23:19:33 +04:00
|
|
|
{
|
|
|
|
if (aPrintReversed) {
|
|
|
|
mQPrinter->setPageOrder(QPrinter::LastPageFirst);
|
|
|
|
} else {
|
|
|
|
mQPrinter->setPageOrder(QPrinter::FirstPageFirst);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsPrintSettingsQt::GetPrintInColor(bool* aPrintInColor)
|
2010-10-07 23:19:33 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aPrintInColor);
|
|
|
|
if (mQPrinter->colorMode() == QPrinter::Color) {
|
2011-10-17 18:59:28 +04:00
|
|
|
*aPrintInColor = true;
|
2010-10-07 23:19:33 +04:00
|
|
|
} else {
|
2011-10-17 18:59:28 +04:00
|
|
|
*aPrintInColor = false;
|
2010-10-07 23:19:33 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsPrintSettingsQt::SetPrintInColor(bool aPrintInColor)
|
2010-10-07 23:19:33 +04:00
|
|
|
{
|
|
|
|
if (aPrintInColor) {
|
|
|
|
mQPrinter->setColorMode(QPrinter::Color);
|
|
|
|
} else {
|
|
|
|
mQPrinter->setColorMode(QPrinter::GrayScale);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsPrintSettingsQt::GetOrientation(int32_t* aOrientation)
|
2010-10-07 23:19:33 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aOrientation);
|
|
|
|
QPrinter::Orientation orientation = mQPrinter->orientation();
|
|
|
|
if (orientation == QPrinter::Landscape) {
|
|
|
|
*aOrientation = kLandscapeOrientation;
|
|
|
|
} else {
|
|
|
|
*aOrientation = kPortraitOrientation;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsPrintSettingsQt::SetOrientation(int32_t aOrientation)
|
2010-10-07 23:19:33 +04:00
|
|
|
{
|
|
|
|
if (aOrientation == kLandscapeOrientation) {
|
|
|
|
mQPrinter->setOrientation(QPrinter::Landscape);
|
|
|
|
} else {
|
|
|
|
mQPrinter->setOrientation(QPrinter::Portrait);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-01-04 19:02:17 +04:00
|
|
|
nsPrintSettingsQt::GetToFileName(char16_t** aToFileName)
|
2010-10-07 23:19:33 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aToFileName);
|
|
|
|
QString filename;
|
|
|
|
filename = mQPrinter->outputFileName();
|
|
|
|
*aToFileName = ToNewUnicode(
|
2014-01-04 19:02:17 +04:00
|
|
|
nsDependentString((char16_t*)filename.data()));
|
2010-10-07 23:19:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-01-04 19:02:17 +04:00
|
|
|
nsPrintSettingsQt::SetToFileName(const char16_t* aToFileName)
|
2010-10-07 23:19:33 +04:00
|
|
|
{
|
2012-06-06 06:08:30 +04:00
|
|
|
nsCOMPtr<nsIFile> file;
|
2011-10-17 18:59:28 +04:00
|
|
|
nsresult rv = NS_NewLocalFile(nsDependentString(aToFileName), true,
|
2010-10-07 23:19:33 +04:00
|
|
|
getter_AddRefs(file));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
QString filename((const QChar*)aToFileName, NS_strlen(aToFileName));
|
|
|
|
mQPrinter->setOutputFileName(filename);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-01-04 19:02:17 +04:00
|
|
|
nsPrintSettingsQt::GetPrinterName(char16_t** aPrinter)
|
2010-10-07 23:19:33 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aPrinter);
|
|
|
|
*aPrinter = ToNewUnicode(nsDependentString(
|
2014-01-04 19:02:17 +04:00
|
|
|
(const char16_t*)mQPrinter->printerName().constData()));
|
2010-10-07 23:19:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-01-04 19:02:17 +04:00
|
|
|
nsPrintSettingsQt::SetPrinterName(const char16_t* aPrinter)
|
2010-10-07 23:19:33 +04:00
|
|
|
{
|
|
|
|
QString printername((const QChar*)aPrinter, NS_strlen(aPrinter));
|
|
|
|
mQPrinter->setPrinterName(printername);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsPrintSettingsQt::GetNumCopies(int32_t* aNumCopies)
|
2010-10-07 23:19:33 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aNumCopies);
|
|
|
|
*aNumCopies = mQPrinter->numCopies();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsPrintSettingsQt::SetNumCopies(int32_t aNumCopies)
|
2010-10-07 23:19:33 +04:00
|
|
|
{
|
|
|
|
mQPrinter->setNumCopies(aNumCopies);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPrintSettingsQt::GetScaling(double* aScaling)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aScaling);
|
|
|
|
qDebug()<<Q_FUNC_INFO;
|
|
|
|
qDebug()<<"Scaling not implemented in Qt port";
|
|
|
|
*aScaling = 1.0; //FIXME
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPrintSettingsQt::SetScaling(double aScaling)
|
|
|
|
{
|
|
|
|
qDebug()<<Q_FUNC_INFO;
|
|
|
|
qDebug()<<"Scaling not implemented in Qt port"; //FIXME
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char* const indexToPaperName[] =
|
|
|
|
{ "A4", "B5", "Letter", "Legal", "Executive",
|
|
|
|
"A0", "A1", "A2", "A3", "A5", "A6", "A7", "A8", "A9",
|
|
|
|
"B0", "B1", "B10", "B2", "B3", "B4", "B6", "B7", "B8", "B9",
|
|
|
|
"C5E", "Comm10E", "DLE", "Folio", "Ledger", "Tabloid"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const QPrinter::PageSize indexToQtPaperEnum[] =
|
|
|
|
{
|
|
|
|
QPrinter::A4, QPrinter::B5, QPrinter::Letter, QPrinter::Legal,
|
|
|
|
QPrinter::Executive, QPrinter::A0, QPrinter::A1, QPrinter::A2, QPrinter::A3,
|
|
|
|
QPrinter::A5, QPrinter::A6, QPrinter::A7, QPrinter::A8, QPrinter::A9,
|
|
|
|
QPrinter::B0, QPrinter::B1, QPrinter::B10, QPrinter::B2, QPrinter::B3,
|
|
|
|
QPrinter::B4, QPrinter::B6, QPrinter::B7, QPrinter::B8, QPrinter::B9,
|
|
|
|
QPrinter::C5E, QPrinter::Comm10E, QPrinter::DLE, QPrinter::Folio,
|
|
|
|
QPrinter::Ledger, QPrinter::Tabloid
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-01-04 19:02:17 +04:00
|
|
|
nsPrintSettingsQt::GetPaperName(char16_t** aPaperName)
|
2010-10-07 23:19:33 +04:00
|
|
|
{
|
|
|
|
PR_STATIC_ASSERT(sizeof(indexToPaperName)/
|
|
|
|
sizeof(char*) == QPrinter::NPageSize);
|
|
|
|
PR_STATIC_ASSERT(sizeof(indexToQtPaperEnum)/
|
|
|
|
sizeof(QPrinter::PageSize) == QPrinter::NPageSize);
|
|
|
|
|
|
|
|
QPrinter::PaperSize size = mQPrinter->paperSize();
|
|
|
|
QString name(indexToPaperName[size]);
|
|
|
|
*aPaperName = ToNewUnicode(nsDependentString
|
2014-01-04 19:02:17 +04:00
|
|
|
((const char16_t*)name.constData()));
|
2010-10-07 23:19:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-01-04 19:02:17 +04:00
|
|
|
nsPrintSettingsQt::SetPaperName(const char16_t* aPaperName)
|
2010-10-07 23:19:33 +04:00
|
|
|
{
|
|
|
|
QString ref((QChar*)aPaperName, NS_strlen(aPaperName));
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < QPrinter::NPageSize; i++)
|
2010-10-07 23:19:33 +04:00
|
|
|
{
|
|
|
|
if (ref == QString(indexToPaperName[i])) {
|
|
|
|
mQPrinter->setPageSize(indexToQtPaperEnum[i]);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
QPrinter::Unit GetQtUnit(int16_t aGeckoUnit)
|
2010-10-07 23:19:33 +04:00
|
|
|
{
|
|
|
|
if (aGeckoUnit == nsIPrintSettings::kPaperSizeMillimeters) {
|
|
|
|
return QPrinter::Millimeter;
|
|
|
|
} else {
|
|
|
|
return QPrinter::Inch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SETUNWRITEABLEMARGIN\
|
|
|
|
mQPrinter->setPageMargins(\
|
|
|
|
NS_TWIPS_TO_INCHES(mUnwriteableMargin.left),\
|
|
|
|
NS_TWIPS_TO_INCHES(mUnwriteableMargin.top),\
|
|
|
|
NS_TWIPS_TO_INCHES(mUnwriteableMargin.right),\
|
|
|
|
NS_TWIPS_TO_INCHES(mUnwriteableMargin.bottom),\
|
|
|
|
QPrinter::Inch);
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPrintSettingsQt::SetUnwriteableMarginInTwips(nsIntMargin& aUnwriteableMargin)
|
|
|
|
{
|
|
|
|
nsPrintSettings::SetUnwriteableMarginInTwips(aUnwriteableMargin);
|
|
|
|
SETUNWRITEABLEMARGIN
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPrintSettingsQt::SetUnwriteableMarginTop(double aUnwriteableMarginTop)
|
|
|
|
{
|
|
|
|
nsPrintSettings::SetUnwriteableMarginTop(aUnwriteableMarginTop);
|
|
|
|
SETUNWRITEABLEMARGIN
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPrintSettingsQt::SetUnwriteableMarginLeft(double aUnwriteableMarginLeft)
|
|
|
|
{
|
|
|
|
nsPrintSettings::SetUnwriteableMarginLeft(aUnwriteableMarginLeft);
|
|
|
|
SETUNWRITEABLEMARGIN
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPrintSettingsQt::SetUnwriteableMarginBottom(double aUnwriteableMarginBottom)
|
|
|
|
{
|
|
|
|
nsPrintSettings::SetUnwriteableMarginBottom(aUnwriteableMarginBottom);
|
|
|
|
SETUNWRITEABLEMARGIN
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPrintSettingsQt::SetUnwriteableMarginRight(double aUnwriteableMarginRight)
|
|
|
|
{
|
|
|
|
nsPrintSettings::SetUnwriteableMarginRight(aUnwriteableMarginRight);
|
|
|
|
SETUNWRITEABLEMARGIN
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPrintSettingsQt::GetPaperWidth(double* aPaperWidth)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aPaperWidth);
|
|
|
|
QSizeF papersize = mQPrinter->paperSize(GetQtUnit(mPaperSizeUnit));
|
|
|
|
*aPaperWidth = papersize.width();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPrintSettingsQt::SetPaperWidth(double aPaperWidth)
|
|
|
|
{
|
|
|
|
QSizeF papersize = mQPrinter->paperSize(GetQtUnit(mPaperSizeUnit));
|
|
|
|
papersize.setWidth(aPaperWidth);
|
|
|
|
mQPrinter->setPaperSize(papersize, GetQtUnit(mPaperSizeUnit));
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPrintSettingsQt::GetPaperHeight(double* aPaperHeight)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aPaperHeight);
|
|
|
|
QSizeF papersize = mQPrinter->paperSize(GetQtUnit(mPaperSizeUnit));
|
|
|
|
*aPaperHeight = papersize.height();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPrintSettingsQt::SetPaperHeight(double aPaperHeight)
|
|
|
|
{
|
|
|
|
QSizeF papersize = mQPrinter->paperSize(GetQtUnit(mPaperSizeUnit));
|
|
|
|
papersize.setHeight(aPaperHeight);
|
|
|
|
mQPrinter->setPaperSize(papersize, GetQtUnit(mPaperSizeUnit));
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsPrintSettingsQt::SetPaperSizeUnit(int16_t aPaperSizeUnit)
|
2010-10-07 23:19:33 +04:00
|
|
|
{
|
|
|
|
mPaperSizeUnit = aPaperSizeUnit;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPrintSettingsQt::GetEffectivePageSize(double* aWidth, double* aHeight)
|
|
|
|
{
|
|
|
|
QSizeF papersize = mQPrinter->paperSize(QPrinter::Inch);
|
|
|
|
if (mQPrinter->orientation() == QPrinter::Landscape) {
|
|
|
|
*aWidth = NS_INCHES_TO_INT_TWIPS(papersize.height());
|
|
|
|
*aHeight = NS_INCHES_TO_INT_TWIPS(papersize.width());
|
|
|
|
} else {
|
|
|
|
*aWidth = NS_INCHES_TO_INT_TWIPS(papersize.width());
|
|
|
|
*aHeight = NS_INCHES_TO_INT_TWIPS(papersize.height());
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|