make paper size table consistent with other tables

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-02-03 02:29:10 +02:00
parent 75804d43e4
commit fde4d9dabf

View file

@ -64,37 +64,40 @@ QT_BEGIN_NAMESPACE
} }
// NB! This table needs to be in sync with QPrinter::PaperSize // NB! This table needs to be in sync with QPrinter::PaperSize
static const float qt_paperSizes[][2] = { static const struct paperSizesData {
{210, 297}, // A4 const float width;
{176, 250}, // B5 const float height;
{215.9f, 279.4f}, // Letter } paperSizesTbl[QPrinter::NPaperSize] = {
{215.9f, 355.6f}, // Legal { 210, 297 }, // A4
{190.5f, 254}, // Executive { 176, 250 }, // B5
{841, 1189}, // A0 { 215.9f, 279.4f }, // Letter
{594, 841}, // A1 {215.9f, 355.6f }, // Legal
{420, 594}, // A2 { 190.5f, 254 }, // Executive
{297, 420}, // A3 { 841, 1189 }, // A0
{148, 210}, // A5 { 594, 841 }, // A1
{105, 148}, // A6 { 420, 594 }, // A2
{74, 105}, // A7 { 297, 420 }, // A3
{52, 74}, // A8 { 148, 210 }, // A5
{37, 52}, // A8 { 105, 148 }, // A6
{1000, 1414}, // B0 { 74, 105 }, // A7
{707, 1000}, // B1 { 52, 74 }, // A8
{31, 44}, // B10 { 37, 52 }, // A9
{500, 707}, // B2 { 1000, 1414 }, // B0
{353, 500}, // B3 { 707, 1000 }, // B1
{250, 353}, // B4 { 31, 44 }, // B10
{125, 176}, // B6 { 500, 707 }, // B2
{88, 125}, // B7 { 353, 500 }, // B3
{62, 88}, // B8 { 250, 353 }, // B4
{33, 62}, // B9 { 125, 176 }, // B6
{163, 229}, // C5E { 88, 125 }, // B7
{105, 241}, // US Common { 62, 88 }, // B8
{110, 220}, // DLE { 33, 62 }, // B9
{210, 330}, // Folio { 163, 229 }, // C5E
{431.8f, 279.4f}, // Ledger { 105, 241 }, // Comm10E
{279.4f, 431.8f} // Tabloid { 110, 220 }, // DLE
{ 210, 330 }, // Folio
{ 431.8f, 279.4f }, // Ledger
{ 279.4f, 431.8f } // Tabloid
}; };
/// return the multiplier of converting from the unit value to postscript-points. /// return the multiplier of converting from the unit value to postscript-points.
@ -125,15 +128,15 @@ QSizeF qt_printerPaperSize(QPrinter::Orientation orientation,
QPrinter::Unit unit, QPrinter::Unit unit,
int resolution) int resolution)
{ {
int width_index = 0; float width = paperSizesTbl[paperSize].width;
int height_index = 1; float height = paperSizesTbl[paperSize].height;
if (orientation == QPrinter::Landscape) { if (orientation == QPrinter::Landscape) {
width_index = 1; width = paperSizesTbl[paperSize].height;
height_index = 0; height = paperSizesTbl[paperSize].width;
} }
const qreal multiplier = qt_multiplierForUnit(unit, resolution); const qreal multiplier = qt_multiplierForUnit(unit, resolution);
return QSizeF((qt_paperSizes[paperSize][width_index] * 72 / 25.4) / multiplier, return QSizeF((width * 72 / 25.4) / multiplier,
(qt_paperSizes[paperSize][height_index] * 72 / 25.4) / multiplier); (height * 72 / 25.4) / multiplier);
} }
void QPrinterPrivate::createDefaultEngines() void QPrinterPrivate::createDefaultEngines()
@ -2087,9 +2090,7 @@ QPrinter::PrintRange QPrinter::printRange() const
QSizeF qt_paperSizeToQSizeF(QPrinter::PaperSize size) QSizeF qt_paperSizeToQSizeF(QPrinter::PaperSize size)
{ {
if (size == QPrinter::Custom) return QSizeF(0, 0); if (size == QPrinter::Custom) return QSizeF(0, 0);
return QSizeF(qt_paperSizes[size][0], qt_paperSizes[size][1]); return QSizeF(paperSizesTbl[size].width, paperSizesTbl[size].height);
}
} }
QT_END_NAMESPACE QT_END_NAMESPACE