/* -*- Mode: C++; tab-width: 2; 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/. */
// When creating the print dialog on Windows, we only need to send certain // print settings information from the parent to the child not vice versa. if (XRE_IsParentProcess()) { // A DEVMODE can actually be of arbitrary size. If it turns out that it'll // make our IPC message larger than the limit, then we'll error out.
LPDEVMODEW devModeRaw;
psWin->GetDevMode(&devModeRaw); // This actually allocates a copy of the // the nsIPrintSettingsWin DEVMODE, so // we're now responsible for deallocating // it. We'll use an nsAutoDevMode helper // to do this. if (devModeRaw) {
nsAutoDevMode devMode(devModeRaw);
devModeRaw = nullptr;
if (msgTotalSize > IPC::Channel::kMaximumMessageSize / 2) { return NS_ERROR_FAILURE;
}
// Instead of reaching in and manually reading each member, we'll just // copy the bits over. constchar* devModeData = reinterpret_cast<constchar*>(devMode.get());
nsTArray<uint8_t> arrayBuf;
arrayBuf.AppendElements(devModeData, devModeTotalSize);
data->devModeData() = std::move(arrayBuf);
}
}
nsCOMPtr<nsIPrintSettingsWin> psWin = do_QueryInterface(settings); if (!settings) { return NS_ERROR_FAILURE;
}
if (XRE_IsContentProcess()) {
psWin->SetDeviceName(data.deviceName());
psWin->SetDriverName(data.driverName());
if (data.devModeData().IsEmpty()) {
psWin->SetDevMode(nullptr);
} else { // Check minimum length of DEVMODE data. auto devModeDataLength = data.devModeData().Length(); if (devModeDataLength < sizeof(DEVMODEW)) {
NS_WARNING("DEVMODE data is too short."); return NS_ERROR_FAILURE;
}
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.