2007-01-12 00:54:29 +03: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
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsPrintOptionsX.h"
|
|
|
|
#include "nsPrintSettingsX.h"
|
|
|
|
|
|
|
|
nsPrintOptionsX::nsPrintOptionsX()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPrintOptionsX::~nsPrintOptionsX()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2012-08-22 19:56:38 +04:00
|
|
|
nsPrintOptionsX::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, uint32_t aFlags)
|
2007-01-12 00:54:29 +03:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = nsPrintOptions::ReadPrefs(aPS, aPrinterName, aFlags);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::ReadPrefs() failed");
|
2009-10-09 09:14:31 +04:00
|
|
|
|
2014-03-25 20:32:58 +04:00
|
|
|
nsRefPtr<nsPrintSettingsX> printSettingsX(do_QueryObject(aPS));
|
2007-01-12 00:54:29 +03:00
|
|
|
if (!printSettingsX)
|
|
|
|
return NS_ERROR_NO_INTERFACE;
|
|
|
|
rv = printSettingsX->ReadPageFormatFromPrefs();
|
2009-10-09 09:14:31 +04:00
|
|
|
|
2014-10-28 18:59:08 +03:00
|
|
|
return NS_OK;
|
2007-01-12 00:54:29 +03:00
|
|
|
}
|
|
|
|
|
2008-09-25 06:26:58 +04:00
|
|
|
nsresult nsPrintOptionsX::_CreatePrintSettings(nsIPrintSettings **_retval)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
2012-07-30 18:20:58 +04:00
|
|
|
*_retval = nullptr;
|
2008-09-25 06:26:58 +04:00
|
|
|
|
|
|
|
nsPrintSettingsX* printSettings = new nsPrintSettingsX; // does not initially ref count
|
|
|
|
NS_ENSURE_TRUE(printSettings, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
NS_ADDREF(*_retval = printSettings);
|
|
|
|
|
|
|
|
rv = printSettings->Init();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_RELEASE(*_retval);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2011-10-01 04:20:33 +04:00
|
|
|
InitPrintSettingsFromPrefs(*_retval, false, nsIPrintSettings::kInitSaveAll);
|
2008-09-25 06:26:58 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2007-01-12 00:54:29 +03:00
|
|
|
nsresult
|
2012-08-22 19:56:38 +04:00
|
|
|
nsPrintOptionsX::WritePrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, uint32_t aFlags)
|
2007-01-12 00:54:29 +03:00
|
|
|
{
|
|
|
|
nsresult rv;
|
2008-09-25 06:26:58 +04:00
|
|
|
|
2007-01-12 00:54:29 +03:00
|
|
|
rv = nsPrintOptions::WritePrefs(aPS, aPrinterName, aFlags);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::WritePrefs() failed");
|
2008-09-25 06:26:58 +04:00
|
|
|
|
2014-03-25 20:32:58 +04:00
|
|
|
nsRefPtr<nsPrintSettingsX> printSettingsX(do_QueryObject(aPS));
|
2007-01-12 00:54:29 +03:00
|
|
|
if (!printSettingsX)
|
|
|
|
return NS_ERROR_NO_INTERFACE;
|
|
|
|
rv = printSettingsX->WritePageFormatToPrefs();
|
2009-10-09 09:20:37 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintSettingsX::WritePageFormatToPrefs() failed");
|
2008-09-25 06:26:58 +04:00
|
|
|
|
2009-10-09 09:14:31 +04:00
|
|
|
return NS_OK;
|
2007-01-12 00:54:29 +03:00
|
|
|
}
|