/* -*- Mode: C++; tab-width: 20; 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/. */
/* static */
already_AddRefed<PrintTargetWindows> PrintTargetWindows::CreateOrNull(HDC aDC) { // Figure out the paper size, the actual surface size will be the printable // area which is likely smaller, but the size here is later used to create the // draw target where the full page size is needed. // Note: we only scale the printing using the LOGPIXELSY, // so we use that when calculating the surface width as well as the height.
int32_t heightDPI = ::GetDeviceCaps(aDC, LOGPIXELSY); float width =
(::GetDeviceCaps(aDC, PHYSICALWIDTH) * POINTS_PER_INCH_FLOAT) / heightDPI; float height =
(::GetDeviceCaps(aDC, PHYSICALHEIGHT) * POINTS_PER_INCH_FLOAT) /
heightDPI;
IntSize size = IntSize::Truncate(width, height);
if (!Factory::CheckSurfaceSize(size)) { return nullptr;
}
// If the user selected Microsoft Print to PDF or XPS Document Printer, then // the following StartDoc call will put up a dialog window to prompt the // user to provide the name and location of the file to be saved. A zero or // negative return value indicates failure. In that case we want to check // whether that is because the user hit Cancel, since we want to treat that // specially to avoid notifying the user that the print "failed" in that // case. // XXX We should perhaps introduce a new NS_ERROR_USER_CANCELLED errer. int result = ::StartDocW(mDC, &docinfo); if (result <= 0) { if (::GetLastError() == ERROR_CANCELLED) { return NS_ERROR_ABORT;
} return NS_ERROR_FAILURE;
} return NS_OK;
}
nsresult PrintTargetWindows::EndPrinting() { int result = ::EndDoc(mDC); return (result <= 0) ? NS_ERROR_FAILURE : NS_OK;
}
nsresult PrintTargetWindows::AbortPrinting() {
PrintTarget::AbortPrinting(); int result = ::AbortDoc(mDC); return (result <= 0) ? NS_ERROR_FAILURE : NS_OK;
}
nsresult PrintTargetWindows::BeginPage(const IntSize& aSizeInPoints) {
MOZ_ALWAYS_SUCCEEDS(PrintTarget::BeginPage(aSizeInPoints)); int result = ::StartPage(mDC); return (result <= 0) ? NS_ERROR_FAILURE : NS_OK;
}
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.