Fix printing with a custom paper specified.

If DMPAPER_USER is set from the print dialog then it is expected that
the specific member variables to get the custom width and length are
used. The size returned by querying the DC_PAPERSIZE is some random
default and is not the one actually requested by the user.

Also ensure that when it is a custom paper size from the driver
itself that we store the right paper size.

Change-Id: I760b8429ca1b01f5e303f2111b8d7ca1795c8ab8
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
bb10
Andy Shaw 2014-01-31 13:11:34 +01:00 committed by The Qt Project
parent 845716d629
commit c8172953ed
1 changed files with 6 additions and 2 deletions

View File

@ -1959,13 +1959,17 @@ static void draw_text_item_win(const QPointF &pos, const QTextItemInt &ti, HDC h
void QWin32PrintEnginePrivate::updateCustomPaperSize()
{
const uint paperSize = devMode->dmPaperSize;
const double multiplier = qt_multiplierForUnit(QPrinter::Millimeter, resolution);
has_custom_paper_size = false;
if (paperSize > 0 && mapDevmodePaperSize(paperSize) == QPrinter::Custom) {
if (paperSize == DMPAPER_USER) {
has_custom_paper_size = true;
paper_size = QSizeF((devMode->dmPaperWidth / 10.0) * multiplier, (devMode->dmPaperLength / 10.0) * multiplier);
} else if (mapDevmodePaperSize(paperSize) == QPrinter::Custom) {
has_custom_paper_size = true;
const QList<QPair<QSizeF, int> > paperSizes = printerPaperSizes(name);
for (int i=0; i<paperSizes.size(); i++) {
if ((uint)paperSizes.at(i).second == paperSize) {
paper_size = paperSizes.at(paperSize).first;
paper_size = paperSizes.at(i).first * multiplier;
has_custom_paper_size = false;
break;
}