Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/activeqt/control/qaxserverbase.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the ActiveQt framework of the Qt Toolkit.
     
    789790    while (!axbase && baseHwnd) {
    790791#ifdef GWLP_USERDATA
    791         QT_WA({
    792             axbase = (QAxServerBase*)GetWindowLongPtrW(baseHwnd, GWLP_USERDATA);
    793         }, {
    794             axbase = (QAxServerBase*)GetWindowLongPtrA(baseHwnd, GWLP_USERDATA);
    795         });
     792        axbase = (QAxServerBase*)GetWindowLongPtr(baseHwnd, GWLP_USERDATA);
    796793#else
    797         QT_WA({
    798             axbase = (QAxServerBase*)GetWindowLongW(baseHwnd, GWL_USERDATA);
    799         }, {
    800             axbase = (QAxServerBase*)GetWindowLongA(baseHwnd, GWL_USERDATA);
    801         });
     794        axbase = (QAxServerBase*)GetWindowLong(baseHwnd, GWL_USERDATA);
    802795#endif
    803796
     
    906899        // hook into eventloop; this allows a server to create his own QApplication object
    907900        if (!qax_hhook && qax_ownQApp) {
    908             QT_WA({
    909                 qax_hhook = SetWindowsHookExW(WH_GETMESSAGE, axs_FilterProc, 0, GetCurrentThreadId());
    910             }, {
    911                 qax_hhook = SetWindowsHookExA(WH_GETMESSAGE, axs_FilterProc, 0, GetCurrentThreadId());
    912             });
     901            qax_hhook = SetWindowsHookEx(WH_GETMESSAGE, axs_FilterProc, 0, GetCurrentThreadId());
    913902        }
    914903
     
    984973    HRESULT WINAPI CreateInstanceLic(IUnknown *pUnkOuter, IUnknown *pUnkReserved, REFIID iid, BSTR bKey, PVOID *ppObject)
    985974    {
    986         QString licenseKey = QString::fromUtf16((const ushort *)bKey);
     975        QString licenseKey = QString::fromWCharArray(bKey);
    987976        if (!qAxFactory()->validateLicenseKey(className, licenseKey))
    988977            return CLASS_E_NOTLICENSED;
     
    13041293    internalBind();
    13051294    if (isWidget) {
    1306         if (!stayTopLevel) {
    1307             QEvent e(QEvent::EmbeddingControl);
    1308             QApplication::sendEvent(qt.widget, &e);
    1309             QT_WA({
    1310                 ::SetWindowLongW(qt.widget->winId(), GWL_STYLE, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
    1311             }, {
    1312                 ::SetWindowLongA(qt.widget->winId(), GWL_STYLE, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
    1313             });
    1314         }
     1295        if (!stayTopLevel) {
     1296            QEvent e(QEvent::EmbeddingControl);
     1297            QApplication::sendEvent(qt.widget, &e);
     1298            ::SetWindowLong(qt.widget->winId(), GWL_STYLE, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
     1299        }
    13151300        qt.widget->setAttribute(Qt::WA_QuitOnClose, false);
    13161301        qt.widget->move(0, 0);
     
    13691354{
    13701355    if (uMsg == WM_CREATE) {
    1371         QAxServerBase *that;
    1372         QT_WA({
    1373             CREATESTRUCTW *cs = (CREATESTRUCTW*)lParam;
    1374             that = (QAxServerBase*)cs->lpCreateParams;
    1375         }, {
    1376             CREATESTRUCTA *cs = (CREATESTRUCTA*)lParam;
    1377             that = (QAxServerBase*)cs->lpCreateParams;
    1378         });
     1356        CREATESTRUCT *cs = (CREATESTRUCT*)lParam;
     1357        QAxServerBase *that = (QAxServerBase*)cs->lpCreateParams;
    13791358
    13801359#ifdef GWLP_USERDATA
    1381         QT_WA({
    1382             SetWindowLongPtrW(hWnd, GWLP_USERDATA, (LONG_PTR)that);
    1383         }, {
    1384             SetWindowLongPtrA(hWnd, GWLP_USERDATA, (LONG_PTR)that);
    1385         });
     1360        SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)that);
    13861361#else
    1387         QT_WA({
    1388             SetWindowLongW(hWnd, GWL_USERDATA, (LONG)that);
    1389         }, {
    1390             SetWindowLongA(hWnd, GWL_USERDATA, (LONG)that);
    1391         });
     1362        SetWindowLong(hWnd, GWL_USERDATA, (LONG)that);
    13921363#endif
    13931364
    1394         that->m_hWnd = hWnd;
    1395 
    1396         QT_WA({
    1397             return ::DefWindowProcW(hWnd, uMsg, wParam, lParam);
    1398         }, {
    1399             return ::DefWindowProcA(hWnd, uMsg, wParam, lParam);
    1400         });
     1365        that->m_hWnd = hWnd;
     1366
     1367        return ::DefWindowProc(hWnd, uMsg, wParam, lParam);
    14011368    }
    14021369
     
    14041371
    14051372#ifdef GWLP_USERDATA
    1406     QT_WA({
    1407         that = (QAxServerBase*)GetWindowLongPtrW(hWnd, GWLP_USERDATA);
    1408     }, {
    1409         that = (QAxServerBase*)GetWindowLongPtrA(hWnd, GWLP_USERDATA);
    1410     });
     1373    that = (QAxServerBase*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
    14111374#else
    1412     QT_WA({
    1413         that = (QAxServerBase*)GetWindowLongW(hWnd, GWL_USERDATA);
    1414     }, {
    1415         that = (QAxServerBase*)GetWindowLongA(hWnd, GWL_USERDATA);
    1416     });
     1375    that = (QAxServerBase*)GetWindowLong(hWnd, GWL_USERDATA);
    14171376#endif
    14181377
     
    15641523    }
    15651524
    1566     QT_WA({
    1567         return ::DefWindowProcW(hWnd, uMsg, wParam, lParam);
    1568     }, {
    1569         return ::DefWindowProcA(hWnd, uMsg, wParam, lParam);
    1570     });
     1525    return ::DefWindowProc(hWnd, uMsg, wParam, lParam);
    15711526}
    15721527
     
    15841539    cn += QString::number((int)ActiveXProc);
    15851540    if (!atom) {
    1586         QT_WA({
    1587             WNDCLASSW wcTemp;
    1588             wcTemp.style = CS_DBLCLKS;
    1589             wcTemp.cbClsExtra = 0;
    1590             wcTemp.cbWndExtra = 0;
    1591             wcTemp.hbrBackground = 0;
    1592             wcTemp.hCursor = 0;
    1593             wcTemp.hIcon = 0;
    1594             wcTemp.hInstance = hInst;
    1595             wcTemp.lpszClassName = (wchar_t*)cn.utf16();
    1596             wcTemp.lpszMenuName = 0;
    1597             wcTemp.lpfnWndProc = ActiveXProc;
    1598 
    1599             atom = RegisterClassW(&wcTemp);
    1600         }, {
    1601             QByteArray cna = cn.toLatin1();
    1602             WNDCLASSA wcTemp;
    1603             wcTemp.style = CS_DBLCLKS;
    1604             wcTemp.cbClsExtra = 0;
    1605             wcTemp.cbWndExtra = 0;
    1606             wcTemp.hbrBackground = 0;
    1607             wcTemp.hCursor = 0;
    1608             wcTemp.hIcon = 0;
    1609             wcTemp.hInstance = hInst;
    1610             wcTemp.lpszClassName = cna.data();
    1611             wcTemp.lpszMenuName = 0;
    1612             wcTemp.lpfnWndProc = ActiveXProc;
    1613 
    1614             atom = RegisterClassA(&wcTemp);
    1615         });
     1541        WNDCLASS wcTemp;
     1542        wcTemp.style = CS_DBLCLKS;
     1543        wcTemp.cbClsExtra = 0;
     1544        wcTemp.cbWndExtra = 0;
     1545        wcTemp.hbrBackground = 0;
     1546        wcTemp.hCursor = 0;
     1547        wcTemp.hIcon = 0;
     1548        wcTemp.hInstance = hInst;
     1549        wcTemp.lpszClassName = (wchar_t*)cn.utf16();
     1550        wcTemp.lpszMenuName = 0;
     1551        wcTemp.lpfnWndProc = ActiveXProc;
     1552
     1553        atom = RegisterClass(&wcTemp);
    16161554    }
    16171555    LeaveCriticalSection(&createWindowSection);
     
    16201558
    16211559    Q_ASSERT(!m_hWnd);
    1622     HWND hWnd = 0;
    1623     QT_WA({
    1624         hWnd = ::CreateWindowW((wchar_t*)cn.utf16(), 0,
    1625             WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
    1626             rcPos.left, rcPos.top, rcPos.right - rcPos.left,
    1627             rcPos.bottom - rcPos.top, hWndParent, 0, hInst, this);
    1628     }, {
    1629         hWnd = ::CreateWindowA(cn.toLatin1().data(), 0,
    1630             WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
    1631             rcPos.left, rcPos.top, rcPos.right - rcPos.left,
    1632             rcPos.bottom - rcPos.top, hWndParent, 0, hInst, this);
    1633     });
     1560    HWND hWnd = ::CreateWindow((wchar_t*)cn.utf16(), 0,
     1561                               WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
     1562                               rcPos.left, rcPos.top, rcPos.right - rcPos.left,
     1563                               rcPos.bottom - rcPos.top, hWndParent, 0, hInst, this);
    16341564
    16351565    Q_ASSERT(m_hWnd == hWnd);
     
    16771607            actionMap.insert(itemId, action);
    16781608        }
    1679         QT_WA({
    1680             AppendMenuW(popupMenu, flags, itemId, (TCHAR*)action->text().utf16());
    1681         }, {
    1682             AppendMenuA(popupMenu, flags, itemId, action->text().toLocal8Bit());
    1683         });
     1609        AppendMenu(popupMenu, flags, itemId, (const wchar_t *)action->text().utf16());
    16841610    }
    16851611    if (oldMenu)
     
    17271653            actionMap.insert(itemId, action);
    17281654        }
    1729         QT_WA({
    1730             AppendMenuW(hmenuShared, flags, itemId, (TCHAR*)action->text().utf16());
    1731         } , {
    1732             AppendMenuA(hmenuShared, flags, itemId, action->text().toLocal8Bit());
    1733         });
     1655        AppendMenu(hmenuShared, flags, itemId, (const wchar_t *)action->text().utf16());
    17341656    }
    17351657
     
    23982320                return res;
    23992321
    2400             name = QString::fromUtf16((const ushort *)bname).toLatin1();
     2322            name = QString::fromWCharArray(bname).toLatin1();
    24012323            SysFreeString(bname);
    24022324        }
     
    24472369            if (index == -1) {
    24482370                nameLength = name.length();
    2449                 name += "(";
     2371                name += '(';
    24502372                // no parameter - shortcut
    24512373                if (!pDispParams->cArgs)
    2452                     index = mo->indexOfSlot((name + ")"));
     2374                    index = mo->indexOfSlot((name + ')'));
    24532375                // search
    24542376                if (index == -1) {
     
    24642386                        QRegExp regexp(QLatin1String("_([0-9])\\("));
    24652387                        if (regexp.lastIndexIn(QString::fromLatin1(name.constData())) != -1) {
    2466                             name = name.left(name.length() - regexp.cap(0).length()) + "(";
     2388                            name = name.left(name.length() - regexp.cap(0).length()) + '(';
    24672389                            int overload = regexp.cap(1).toInt() + 1;
    24682390
     
    25602482                    } else {
    25612483                        argv[p + 1] = const_cast<void*>(varp[p + 1].constData());
    2562                         if (ptype.endsWith("*")) {
     2484                        if (ptype.endsWith('*')) {
    25632485                            argv_pointer[p + 1] = argv[p + 1];
    25642486                            argv[p + 1] = argv_pointer + p + 1;
     
    25912513                    argv[0] = const_cast<void*>(varp[0].constData());
    25922514                }
    2593                 if (type.endsWith("*")) {
     2515                if (type.endsWith('*')) {
    25942516                    argv_pointer[0] = argv[0];
    25952517                    argv[0] = argv_pointer;
     
    28002722    QByteArray qtarray;
    28012723    if (hres == S_OK) {
    2802         QString streamName = QString::fromUtf16((const ushort *)stat.pwcsName);
     2724        QString streamName = QString::fromWCharArray(stat.pwcsName);
    28032725        CoTaskMemFree(stat.pwcsName);
    28042726        openAsText = streamName == QLatin1String("SomeStreamName");
     
    29412863    streamName += QLatin1String("_Stream4.2");
    29422864
    2943     pStg->OpenStream((const WCHAR *)streamName.utf16(), 0, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &spStream);
     2865    pStg->OpenStream((const wchar_t *)streamName.utf16(), 0, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &spStream);
    29442866    if (!spStream) // support for streams saved with 4.1 and earlier
    29452867        pStg->OpenStream(L"SomeStreamName", 0, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &spStream);
     
    29642886    streamName += QLatin1String("_Stream4.2");
    29652887
    2966     pStg->CreateStream((const WCHAR *)streamName.utf16(), STGM_CREATE | STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &spStream);
     2888    pStg->CreateStream((const wchar_t *)streamName.utf16(), STGM_CREATE | STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &spStream);
    29672889    if (!spStream)
    29682890        return E_FAIL;
     
    30803002        return E_NOTIMPL;
    30813003
    3082     currentFileName = QString::fromUtf16(reinterpret_cast<const ushort *>(fileName));
     3004    currentFileName = QString::fromWCharArray(fileName);
    30833005    return S_OK;
    30843006}
     
    30983020        return E_OUTOFMEMORY;
    30993021
    3100     *currentFile = static_cast<WCHAR *>(malloc->Alloc(currentFileName.length() * 2));
     3022    *currentFile = static_cast<wchar_t *>(malloc->Alloc(currentFileName.length() * 2));
    31013023    malloc->Release();
    31023024    memcpy(*currentFile, currentFileName.unicode(), currentFileName.length() * 2);
     
    31183040    }
    31193041
    3120     QString loadFileName = QString::fromUtf16(reinterpret_cast<const ushort *>(fileName));
     3042    QString loadFileName = QString::fromWCharArray(fileName);
    31213043    QString fileExtension = loadFileName.mid(loadFileName.lastIndexOf(QLatin1Char('.')) + 1);
    31223044    QFile file(loadFileName);
     
    31633085    }
    31643086
    3165     QString saveFileName = QString::fromUtf16(reinterpret_cast<const ushort *>(fileName));
     3087    QString saveFileName = QString::fromWCharArray(fileName);
    31663088    QString fileExtension = saveFileName.mid(saveFileName.lastIndexOf(QLatin1Char('.')) + 1);
    31673089    QFile file(saveFileName);
     
    32213143    bool bDeleteDC = false;
    32223144    if (!hicTargetDev) {
    3223         hicTargetDev = ::CreateDCA("DISPLAY", NULL, NULL, NULL);
     3145        hicTargetDev = ::CreateDC(L"DISPLAY", NULL, NULL, NULL);
    32243146        bDeleteDC = (hicTargetDev != hdcDraw);
    32253147    }
     
    33843306        if (var.vt != VT_BSTR || !isWidget)
    33853307            break;
    3386         qt.widget->setWindowTitle(QString::fromUtf16((const ushort *)var.bstrVal));
     3308        qt.widget->setWindowTitle(QString::fromWCharArray(var.bstrVal));
    33873309        break;
    33883310    case DISPID_AMBIENT_FONT:
     
    35823504{
    35833505    if (pMsg->message != WM_KEYDOWN || !isWidget)
    3584         return S_FALSE;
     3506        return S_FALSE;
    35853507
    35863508    DWORD dwKeyMod = 0;
    35873509    if (::GetKeyState(VK_SHIFT) < 0)
    3588         dwKeyMod |= 1;  // KEYMOD_SHIFT
     3510        dwKeyMod |= 1;  // KEYMOD_SHIFT
    35893511    if (::GetKeyState(VK_CONTROL) < 0)
    3590         dwKeyMod |= 2;  // KEYMOD_CONTROL
     3512        dwKeyMod |= 2;  // KEYMOD_CONTROL
    35913513    if (::GetKeyState(VK_MENU) < 0)
    3592         dwKeyMod |= 4;  // KEYMOD_ALT
     3514        dwKeyMod |= 4;  // KEYMOD_ALT
    35933515
    35943516    switch (LOWORD(pMsg->wParam)) {
    35953517    case VK_TAB:
    3596         if (isUIActive) {
    3597             bool shift = ::GetKeyState(VK_SHIFT) < 0;
    3598             bool giveUp = true;
     3518        if (isUIActive) {
     3519            bool shift = ::GetKeyState(VK_SHIFT) < 0;
     3520            bool giveUp = true;
    35993521            QWidget *curFocus = qt.widget->focusWidget();
    36003522            if (curFocus) {
    3601                 if (shift) {
     3523                if (shift) {
    36023524                    if (!curFocus->isWindow()) {
    36033525                        QWidget *nextFocus = curFocus->nextInFocusChain();
     
    36173539                            giveUp = false;
    36183540                            ((HackWidget*)curFocus)->focusNextPrevChild(false);
     3541                            curFocus->window()->setAttribute(Qt::WA_KeyboardFocusChange);
    36193542                        }
    36203543                    }
    3621                 } else {
     3544                } else {
    36223545                    QWidget *nextFocus = curFocus;
    36233546                    while (1) {
     
    36283551                            giveUp = false;
    36293552                            ((HackWidget*)curFocus)->focusNextPrevChild(true);
     3553                            curFocus->window()->setAttribute(Qt::WA_KeyboardFocusChange);
    36303554                            break;
    36313555                        }
    36323556                    }
    3633                 }
     3557                }
    36343558            }
    3635             if (giveUp) {
    3636                 HWND hwnd = ::GetParent(m_hWnd);
    3637                 ::SetFocus(hwnd);
    3638             } else {
    3639                 return S_OK;
    3640             }
    3641 
    3642         }
    3643         break;
     3559            if (giveUp) {
     3560                HWND hwnd = ::GetParent(m_hWnd);
     3561                ::SetFocus(hwnd);
     3562            } else {
     3563                return S_OK;
     3564            }
     3565
     3566        }
     3567        break;
    36443568
    36453569    case VK_LEFT:
     
    36473571    case VK_UP:
    36483572    case VK_DOWN:
    3649         if (isUIActive)
    3650             return S_FALSE;
    3651         break;
     3573        if (isUIActive)
     3574            return S_FALSE;
     3575        break;
    36523576
    36533577    default:
    3654         if (isUIActive && qt.widget->focusWidget()) {
     3578        if (isUIActive && qt.widget->focusWidget()) {
    36553579            int state = Qt::NoButton;
    3656             if (dwKeyMod & 1)
    3657                 state |= Qt::ShiftModifier;
    3658             if (dwKeyMod & 2)
    3659                 state |= Qt::ControlModifier;
    3660             if (dwKeyMod & 4)
    3661                 state |= Qt::AltModifier;
    3662 
    3663             int key = pMsg->wParam;
     3580            if (dwKeyMod & 1)
     3581                state |= Qt::ShiftModifier;
     3582            if (dwKeyMod & 2)
     3583                state |= Qt::ControlModifier;
     3584            if (dwKeyMod & 4)
     3585                state |= Qt::AltModifier;
     3586
     3587            int key = pMsg->wParam;
    36643588            if (!(key >= 'A' && key <= 'Z') && !(key >= '0' && key <= '9'))
    36653589                key = qt_translateKeyCode(pMsg->wParam);
    36663590
    3667             QKeyEvent override(QEvent::ShortcutOverride, key, (Qt::KeyboardModifiers)state);
    3668             override.ignore();
    3669             QApplication::sendEvent(qt.widget->focusWidget(), &override);
    3670             if (override.isAccepted())
    3671                 return S_FALSE;
    3672         }
    3673         break;
     3591            QKeyEvent override(QEvent::ShortcutOverride, key, (Qt::KeyboardModifiers)state);
     3592            override.ignore();
     3593            QApplication::sendEvent(qt.widget->focusWidget(), &override);
     3594            if (override.isAccepted())
     3595                return S_FALSE;
     3596        }
     3597        break;
    36743598    }
    36753599
    36763600    if (!m_spClientSite)
    3677         return S_FALSE;
     3601        return S_FALSE;
    36783602
    36793603    IOleControlSite *controlSite = 0;
    36803604    m_spClientSite->QueryInterface(IID_IOleControlSite, (void**)&controlSite);
    36813605    if (!controlSite)
    3682         return S_FALSE;
    3683 
     3606        return S_FALSE;
     3607    bool resetUserData = false;
     3608    // set server type in the user-data of the window.
     3609#ifdef GWLP_USERDATA
     3610    LONG_PTR serverType = QAX_INPROC_SERVER;
     3611#else
     3612    LONG serverType = QAX_INPROC_SERVER;
     3613#endif
     3614    if (qAxOutProcServer)
     3615        serverType = QAX_OUTPROC_SERVER;
     3616#ifdef GWLP_USERDATA
     3617    LONG_PTR oldData = SetWindowLongPtr(pMsg->hwnd, GWLP_USERDATA, serverType);
     3618#else
     3619    LONG oldData = SetWindowLong(pMsg->hwnd, GWL_USERDATA, serverType);
     3620#endif
    36843621    HRESULT hres = controlSite->TranslateAcceleratorW(pMsg, dwKeyMod);
    3685 
    36863622    controlSite->Release();
    3687 
     3623    // reset the user-data for the window.
     3624#ifdef GWLP_USERDATA
     3625    SetWindowLongPtr(pMsg->hwnd, GWLP_USERDATA, oldData);
     3626#else
     3627    SetWindowLong(pMsg->hwnd, GWL_USERDATA, oldData);
     3628#endif
    36883629    return hres;
    36893630}
Note: See TracChangeset for help on using the changeset viewer.