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
|
|
|
|
nsPrintOptionsX::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, PRUint32 aFlags)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = nsPrintOptions::ReadPrefs(aPS, aPrinterName, aFlags);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::ReadPrefs() failed");
|
2009-10-09 09:14:31 +04:00
|
|
|
|
2009-10-09 09:20:37 +04:00
|
|
|
nsCOMPtr<nsPrintSettingsX> printSettingsX(do_QueryInterface(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
|
|
|
|
2009-10-09 09:20:37 +04:00
|
|
|
return rv;
|
2007-01-12 00:54:29 +03:00
|
|
|
}
|
|
|
|
|
2008-09-25 06:26:58 +04:00
|
|
|
nsresult nsPrintOptionsX::_CreatePrintSettings(nsIPrintSettings **_retval)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
*_retval = nsnull;
|
|
|
|
|
|
|
|
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
|
|
|
|
nsPrintOptionsX::WritePrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, PRUint32 aFlags)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
2009-10-09 09:20:37 +04:00
|
|
|
nsCOMPtr<nsPrintSettingsX> printSettingsX(do_QueryInterface(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
|
|
|
}
|