Bug 1668076 - Fix formatting of nsPrinterListCUPS.cpp r=nordzilla

The functions are in the wrong order, and there was some missing whitespace.

Differential Revision: https://phabricator.services.mozilla.com/D91818
This commit is contained in:
Emily McDonough 2020-10-01 23:14:32 +00:00
parent 584d9d8e68
commit bcead76cbc

View File

@ -31,6 +31,34 @@ static void GetDisplayNameForPrinter(const cups_dest_t& aDest,
#endif
}
NS_IMETHODIMP
nsPrinterListCUPS::InitPrintSettingsFromPrinter(
const nsAString& aPrinterName, nsIPrintSettings* aPrintSettings) {
MOZ_ASSERT(aPrintSettings);
// Set a default file name.
nsAutoString filename;
nsresult rv = aPrintSettings->GetToFileName(filename);
if (NS_FAILED(rv) || filename.IsEmpty()) {
const char* path = PR_GetEnv("PWD");
if (!path) {
path = PR_GetEnv("HOME");
}
if (path) {
CopyUTF8toUTF16(mozilla::MakeStringSpan(path), filename);
filename.AppendLiteral("/mozilla.pdf");
} else {
filename.AssignLiteral("mozilla.pdf");
}
aPrintSettings->SetToFileName(filename);
}
aPrintSettings->SetIsInitializedFromPrinter(true);
return NS_OK;
}
nsTArray<PrinterInfo> nsPrinterListCUPS::Printers() const {
if (!sCupsShim.EnsureInitialized()) {
return {};
@ -148,6 +176,7 @@ Maybe<PrinterInfo> nsPrinterListCUPS::PrinterBySystemName(
}
return rv;
}
nsresult nsPrinterListCUPS::SystemDefaultPrinterName(nsAString& aName) const {
aName.Truncate();
@ -171,31 +200,3 @@ nsresult nsPrinterListCUPS::SystemDefaultPrinterName(nsAString& aName) const {
sCupsShim.cupsFreeDests(1, dest);
return NS_OK;
}
NS_IMETHODIMP
nsPrinterListCUPS::InitPrintSettingsFromPrinter(
const nsAString& aPrinterName, nsIPrintSettings* aPrintSettings) {
MOZ_ASSERT(aPrintSettings);
// Set a default file name.
nsAutoString filename;
nsresult rv = aPrintSettings->GetToFileName(filename);
if (NS_FAILED(rv) || filename.IsEmpty()) {
const char* path = PR_GetEnv("PWD");
if (!path) {
path = PR_GetEnv("HOME");
}
if (path) {
CopyUTF8toUTF16(mozilla::MakeStringSpan(path), filename);
filename.AppendLiteral("/mozilla.pdf");
} else {
filename.AssignLiteral("mozilla.pdf");
}
aPrintSettings->SetToFileName(filename);
}
aPrintSettings->SetIsInitializedFromPrinter(true);
return NS_OK;
}