Quellcode-Bibliothek nsPrinterListBase.cpp
Sprache: C
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* 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/. */
using mozilla::ErrorResult; using mozilla::intl::Localization; using PrinterInfo = nsPrinterListBase::PrinterInfo; using MarginDouble = mozilla::gfx::MarginDouble;
Maybe<PrinterInfo> nsPrinterListBase::NamedOrDefaultPrinter(
nsString aName) const { if (Maybe<PrinterInfo> value = PrinterByName(std::move(aName))) { return value;
}
// Since the name had to be passed by-value, we can re-use it to fetch the // default printer name, potentially avoiding an extra string allocation. if (NS_SUCCEEDED(SystemDefaultPrinterName(aName))) { return PrinterByName(std::move(aName));
}
void nsPrinterListBase::EnsureCommonPaperInfo(JSContext* aCx) {
MOZ_DIAGNOSTIC_ASSERT(NS_IsMainThread()); if (mCommonPaperInfo) { return;
}
RefPtr<CommonPaperInfoArray> localizedPaperInfo =
MakeRefPtr<CommonPaperInfoArray>();
CommonPaperInfoArray& paperArray = *localizedPaperInfo; // Apply localization to the names while constructing the PaperInfo, if // available (otherwise leave them as the internal keys, which are at least // somewhat recognizable).
IgnoredErrorResult rv;
nsTArray<nsCString> resIds = { "toolkit/printing/printUI.ftl"_ns,
};
RefPtr<Localization> l10n = Localization::Create(resIds, true);
for (auto i : IntegerRange(nsPaper::kNumCommonPaperSizes)) { const CommonPaperSize& size = nsPaper::kCommonPaperSizes[i];
PaperInfo& info = paperArray[i];
// Fill out the info with our PWG size and the localized name.
info.mId = size.mPWGName;
CopyUTF8toUTF16(
(rv.Failed() || name.IsEmpty())
? static_cast<const nsCString&>(size.mLocalizableNameKey)
: name,
info.mName);
info.mSize = size.mSize;
info.mUnwriteableMargin = Some(MarginDouble{});
}
mCommonPaperInfo = std::move(localizedPaperInfo);
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.14Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.