summaryrefslogtreecommitdiffstats
path: root/src/printsupport/kernel/qprintengine_win.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/printsupport/kernel/qprintengine_win.cpp')
-rw-r--r--src/printsupport/kernel/qprintengine_win.cpp57
1 files changed, 23 insertions, 34 deletions
diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp
index 6f263e5ea8..e3a5c3d2e8 100644
--- a/src/printsupport/kernel/qprintengine_win.cpp
+++ b/src/printsupport/kernel/qprintengine_win.cpp
@@ -1556,14 +1556,15 @@ HGLOBAL *QWin32PrintEngine::createGlobalDevNames()
Q_D(QWin32PrintEngine);
int size = sizeof(DEVNAMES) + d->m_printDevice.id().length() * 2 + 2;
- HGLOBAL *hGlobal = (HGLOBAL *) GlobalAlloc(GMEM_MOVEABLE, size);
- DEVNAMES *dn = (DEVNAMES*) GlobalLock(hGlobal);
+ auto hGlobal = reinterpret_cast<HGLOBAL *>(GlobalAlloc(GMEM_MOVEABLE, size));
+ auto dn = reinterpret_cast<DEVNAMES*>(GlobalLock(hGlobal));
dn->wDriverOffset = 0;
dn->wDeviceOffset = sizeof(DEVNAMES) / sizeof(wchar_t);
dn->wOutputOffset = 0;
- memcpy((ushort*)dn + dn->wDeviceOffset, d->m_printDevice.id().utf16(), d->m_printDevice.id().length() * 2 + 2);
+ memcpy(reinterpret_cast<ushort*>(dn) + dn->wDeviceOffset,
+ d->m_printDevice.id().utf16(), d->m_printDevice.id().length() * 2 + 2);
dn->wDefault = 0;
GlobalUnlock(hGlobal);
@@ -1574,8 +1575,9 @@ void QWin32PrintEngine::setGlobalDevMode(HGLOBAL globalDevNames, HGLOBAL globalD
{
Q_D(QWin32PrintEngine);
if (globalDevNames) {
- DEVNAMES *dn = (DEVNAMES*) GlobalLock(globalDevNames);
- QString id = QString::fromWCharArray((wchar_t*)(dn) + dn->wDeviceOffset);
+ auto dn = reinterpret_cast<DEVNAMES*>(GlobalLock(globalDevNames));
+ const QString id =
+ QString::fromWCharArray(reinterpret_cast<const wchar_t*>(dn) + dn->wDeviceOffset);
QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
if (ps)
d->m_printDevice = ps->createPrintDevice(id.isEmpty() ? ps->defaultPrintDeviceId() : id);
@@ -1583,7 +1585,7 @@ void QWin32PrintEngine::setGlobalDevMode(HGLOBAL globalDevNames, HGLOBAL globalD
}
if (globalDevMode) {
- DEVMODE *dm = (DEVMODE*) GlobalLock(globalDevMode);
+ auto dm = reinterpret_cast<DEVMODE*>(GlobalLock(globalDevMode));
d->release();
d->globalDevMode = globalDevMode;
if (d->ownsDevMode) {
@@ -1779,39 +1781,26 @@ static void draw_text_item_win(const QPointF &pos, const QTextItemInt &ti, HDC h
QTransform matrix = QTransform::fromTranslate(baseline_pos.x(), baseline_pos.y());
ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags,
_glyphs, positions);
- if (_glyphs.size() == 0) {
+ if (_glyphs.isEmpty()) {
SelectObject(hdc, old_font);
return;
}
- bool outputEntireItem = _glyphs.size() > 0;
-
- if (outputEntireItem) {
- options |= ETO_PDY;
- QVarLengthArray<INT> glyphDistances(_glyphs.size() * 2);
- QVarLengthArray<wchar_t> g(_glyphs.size());
- for (int i=0; i<_glyphs.size() - 1; ++i) {
- glyphDistances[i * 2] = qRound(positions[i + 1].x) - qRound(positions[i].x);
- glyphDistances[i * 2 + 1] = qRound(positions[i + 1].y) - qRound(positions[i].y);
- g[i] = _glyphs[i];
- }
- glyphDistances[(_glyphs.size() - 1) * 2] = 0;
- glyphDistances[(_glyphs.size() - 1) * 2 + 1] = 0;
- g[_glyphs.size() - 1] = _glyphs[_glyphs.size() - 1];
- ExtTextOut(hdc, qRound(positions[0].x), qRound(positions[0].y), options, 0,
- g.constData(), _glyphs.size(),
- glyphDistances.data());
- } else {
- int i = 0;
- while(i < _glyphs.size()) {
- wchar_t g = _glyphs[i];
-
- ExtTextOut(hdc, qRound(positions[i].x),
- qRound(positions[i].y), options, 0,
- &g, 1, 0);
- ++i;
- }
+ options |= ETO_PDY;
+ QVarLengthArray<INT> glyphDistances(_glyphs.size() * 2);
+ QVarLengthArray<wchar_t> g(_glyphs.size());
+ const int lastGlyph = _glyphs.size() - 1;
+ for (int i = 0; i < lastGlyph; ++i) {
+ glyphDistances[i * 2] = qRound(positions[i + 1].x) - qRound(positions[i].x);
+ glyphDistances[i * 2 + 1] = qRound(positions[i + 1].y) - qRound(positions[i].y);
+ g[i] = _glyphs[i];
}
+ glyphDistances[lastGlyph * 2] = 0;
+ glyphDistances[lastGlyph * 2 + 1] = 0;
+ g[lastGlyph] = _glyphs[lastGlyph];
+ ExtTextOut(hdc, qRound(positions[0].x), qRound(positions[0].y), options, nullptr,
+ g.constData(), _glyphs.size(),
+ glyphDistances.data());
}
win_xform.eM11 = win_xform.eM22 = 1.0;