Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / widget / src / cocoa / nsPrintOptionsX.mm
blob22d791fb4ee4a510cfad7e95385cc3dfdef1d869
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4  *
5  * The contents of this file are subject to the Mozilla Public License Version
6  * 1.1 (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  * http://www.mozilla.org/MPL/
9  *
10  * Software distributed under the License is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12  * for the specific language governing rights and limitations under the
13  * License.
14  *
15  * The Original Code is mozilla.org code.
16  *
17  * The Initial Developer of the Original Code is
18  * Netscape Communications Corporation.
19  * Portions created by the Initial Developer are Copyright (C) 1998
20  * the Initial Developer. All Rights Reserved.
21  *
22  * Contributor(s):
23  *   Simon Fraser <sfraser@netscape.com>
24  *
25  * Alternatively, the contents of this file may be used under the terms of
26  * either of the GNU General Public License Version 2 or later (the "GPL"),
27  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28  * in which case the provisions of the GPL or the LGPL are applicable instead
29  * of those above. If you wish to allow use of your version of this file only
30  * under the terms of either the GPL or the LGPL, and not to allow others to
31  * use your version of this file under the terms of the MPL, indicate your
32  * decision by deleting the provisions above and replace them with the notice
33  * and other provisions required by the GPL or the LGPL. If you do not delete
34  * the provisions above, a recipient may use your version of this file under
35  * the terms of any one of the MPL, the GPL or the LGPL.
36  *
37  * ***** END LICENSE BLOCK ***** */
39 #include "nsCOMPtr.h"
40 #include "nsIServiceManager.h"
41 #include "nsPrintOptionsX.h"
42 #include "nsPrintSettingsX.h"
44 #include "nsCRT.h"
45 #include "plbase64.h"
46 #include "prmem.h"
49 nsPrintOptionsX::nsPrintOptionsX()
54 nsPrintOptionsX::~nsPrintOptionsX()
59 NS_IMETHODIMP
60 nsPrintOptionsX::ShowPrintSetupDialog(nsIPrintSettings *aThePrintSettings)
62   return NS_ERROR_NOT_IMPLEMENTED;
63
66 NS_IMETHODIMP
67 nsPrintOptionsX::GetNativeData(PRInt16 aDataType, void **_retval)
69   NS_ENSURE_ARG_POINTER(_retval);
70   *_retval = nsnull;
72   return NS_ERROR_NOT_IMPLEMENTED;
76 nsresult
77 nsPrintOptionsX::ReadPrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, PRUint32 aFlags)
79   nsresult rv;
80   
81   rv = nsPrintOptions::ReadPrefs(aPS, aPrinterName, aFlags);
82   NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::ReadPrefs() failed");
83   
84   nsCOMPtr<nsIPrintSettingsX> printSettingsX(do_QueryInterface(aPS));
85   if (!printSettingsX)
86     return NS_ERROR_NO_INTERFACE;
87   rv = printSettingsX->ReadPageFormatFromPrefs();
88   NS_ASSERTION(NS_SUCCEEDED(rv), "nsIPrintSettingsX::ReadPageFormatFromPrefs() failed");
89   
90   return NS_OK;
94 nsresult nsPrintOptionsX::_CreatePrintSettings(nsIPrintSettings **_retval)
96   nsresult rv;
97   *_retval = nsnull;
99   nsPrintSettingsX* printSettings = new nsPrintSettingsX; // does not initially ref count
100   NS_ENSURE_TRUE(printSettings, NS_ERROR_OUT_OF_MEMORY);
101   NS_ADDREF(*_retval = printSettings);
103   rv = printSettings->Init();
104   if (NS_FAILED(rv)) {
105     NS_RELEASE(*_retval);
106     return rv;
107   }
109   InitPrintSettingsFromPrefs(*_retval, PR_FALSE, nsIPrintSettings::kInitSaveAll);
110   return rv;
114 nsresult
115 nsPrintOptionsX::WritePrefs(nsIPrintSettings* aPS, const nsAString& aPrinterName, PRUint32 aFlags)
117   nsresult rv;
119   rv = nsPrintOptions::WritePrefs(aPS, aPrinterName, aFlags);
120   NS_ASSERTION(NS_SUCCEEDED(rv), "nsPrintOptions::WritePrefs() failed");
122   nsCOMPtr<nsIPrintSettingsX> printSettingsX(do_QueryInterface(aPS));
123   if (!printSettingsX)
124     return NS_ERROR_NO_INTERFACE;
125   rv = printSettingsX->WritePageFormatToPrefs();
126   NS_ASSERTION(NS_SUCCEEDED(rv), "nsIPrintSettingsX::WritePageFormatToPrefs() failed");
128   return NS_OK;