Qt 4.8
Classes | Macros | Functions | Variables
qaxserverbase.cpp File Reference
#include <qabstracteventdispatcher.h>
#include <qapplication.h>
#include <qbuffer.h>
#include <qdatastream.h>
#include <qdebug.h>
#include <qevent.h>
#include <qeventloop.h>
#include <qfile.h>
#include <qpointer.h>
#include <qhash.h>
#include <qmap.h>
#include <qmenubar.h>
#include <qmenu.h>
#include <qmetaobject.h>
#include <qpixmap.h>
#include <qstatusbar.h>
#include <qwhatsthis.h>
#include <ocidl.h>
#include <olectl.h>
#include <private/qcoreapplication_p.h>
#include "qaxfactory.h"
#include "qaxbindable.h"
#include "qaxaggregated.h"
#include "../shared/qaxtypes.h"

Go to the source code of this file.

Classes

class  HackWidget
 
class  QAxConnection
 
struct  QAxExceptInfo
 
class  QAxServerAggregate
 
class  QAxServerBase
 
class  QAxSignalVec
 
class  QClassFactory
 

Macros

#define QT_NO_CAST_TO_ASCII
 
#define ULONG_PTR   DWORD
 

Functions

LRESULT QT_WIN_CALLBACK axs_FilterProc (int nCode, WPARAM wParam, LPARAM lParam)
 
static bool checkHRESULT (HRESULT hres)
 
HRESULT GetClassObject (REFIID clsid, REFIID iid, void **ppUnk)
 
bool ignoreProps (const char *test)
 
bool ignoreSlots (const char *test)
 
static int mapModifiers (int state)
 
static QByteArray paramType (const QByteArray &ptype, bool *out)
 
bool qax_winEventFilter (void *message)
 
QAxFactoryqAxFactory ()
 
unsigned long qAxLock ()
 
unsigned long qAxUnlock ()
 
static LPOLESTR QStringToOLESTR (const QString &qstring)
 
bool qt_sendSpontaneousEvent (QObject *, QEvent *)
 
Q_GUI_EXPORT int qt_translateKeyCode (int)
 
void qWinMsgHandler (QtMsgType t, const char *str)
 

Variables

static int invokeCount = 0
 
bool qax_disable_inplaceframe = true
 
HHOOK qax_hhook
 
bool qax_ownQApp
 
HANDLE qAxInstance
 
bool qAxOutProcServer
 
unsigned long qaxserverbase_instance_count = 0
 
ITypeLib * qAxTypeLibrary
 

Macro Definition Documentation

◆ QT_NO_CAST_TO_ASCII

#define QT_NO_CAST_TO_ASCII

disables automatic conversion from QString to 8-bit strings (char *)

See also
QT_NO_CAST_FROM_ASCII, QT_NO_CAST_FROM_BYTEARRAY

◆ ULONG_PTR

#define ULONG_PTR   DWORD

Function Documentation

◆ axs_FilterProc()

LRESULT QT_WIN_CALLBACK axs_FilterProc ( int  nCode,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 799 of file qaxserverbase.cpp.

Referenced by QClassFactory::CreateInstanceHelper().

800 {
801  if (qApp && !invokeCount)
802  qApp->sendPostedEvents();
803 
804  return CallNextHookEx(qax_hhook, nCode, wParam, lParam);
805 }
HHOOK qax_hhook
#define qApp
static int invokeCount

◆ checkHRESULT()

static bool checkHRESULT ( HRESULT  hres)
static

Definition at line 1878 of file qaxserverbase.cpp.

1879 {
1880  const char *name = 0;
1881  switch(hres) {
1882  case S_OK:
1883  return true;
1884  case DISP_E_BADPARAMCOUNT:
1885 #if defined(QT_CHECK_STATE)
1886  qWarning("QAxBase: Error calling IDispatch member %s: Bad parameter count", name);
1887 #endif
1888  return false;
1889  case DISP_E_BADVARTYPE:
1890 #if defined(QT_CHECK_STATE)
1891  qWarning("QAxBase: Error calling IDispatch member %s: Bad variant type", name);
1892 #endif
1893  return false;
1894  case DISP_E_EXCEPTION:
1895 #if defined(QT_CHECK_STATE)
1896  qWarning("QAxBase: Error calling IDispatch member %s: Exception thrown by server", name);
1897 #endif
1898  return false;
1899  case DISP_E_MEMBERNOTFOUND:
1900 #if defined(QT_CHECK_STATE)
1901  qWarning("QAxBase: Error calling IDispatch member %s: Member not found", name);
1902 #endif
1903  return false;
1904  case DISP_E_NONAMEDARGS:
1905 #if defined(QT_CHECK_STATE)
1906  qWarning("QAxBase: Error calling IDispatch member %s: No named arguments", name);
1907 #endif
1908  return false;
1909  case DISP_E_OVERFLOW:
1910 #if defined(QT_CHECK_STATE)
1911  qWarning("QAxBase: Error calling IDispatch member %s: Overflow", name);
1912 #endif
1913  return false;
1914  case DISP_E_PARAMNOTFOUND:
1915 #if defined(QT_CHECK_STATE)
1916  qWarning("QAxBase: Error calling IDispatch member %s: Parameter not found", name);
1917 #endif
1918  return false;
1919  case DISP_E_TYPEMISMATCH:
1920 #if defined(QT_CHECK_STATE)
1921  qWarning("QAxBase: Error calling IDispatch member %s: Type mismatch", name);
1922 #endif
1923  return false;
1924  case DISP_E_UNKNOWNINTERFACE:
1925 #if defined(QT_CHECK_STATE)
1926  qWarning("QAxBase: Error calling IDispatch member %s: Unknown interface", name);
1927 #endif
1928  return false;
1929  case DISP_E_UNKNOWNLCID:
1930 #if defined(QT_CHECK_STATE)
1931  qWarning("QAxBase: Error calling IDispatch member %s: Unknown locale ID", name);
1932 #endif
1933  return false;
1934  case DISP_E_PARAMNOTOPTIONAL:
1935 #if defined(QT_CHECK_STATE)
1936  qWarning("QAxBase: Error calling IDispatch member %s: Non-optional parameter missing", name);
1937 #endif
1938  return false;
1939  default:
1940 #if defined(QT_CHECK_STATE)
1941  qWarning("QAxBase: Error calling IDispatch member %s: Unknown error", name);
1942 #endif
1943  return false;
1944  }
1945 }
const char * name
Q_CORE_EXPORT void qWarning(const char *,...)

◆ GetClassObject()

HRESULT GetClassObject ( REFIID  clsid,
REFIID  iid,
void **  ppUnk 
)

Definition at line 1023 of file qaxserverbase.cpp.

1024 {
1025  QClassFactory *factory = new QClassFactory(clsid);
1026  if (!factory)
1027  return E_OUTOFMEMORY;
1028  if (factory->className.isEmpty()) {
1029  delete factory;
1030  return E_NOINTERFACE;
1031  }
1032  HRESULT res = factory->QueryInterface(iid, ppUnk);
1033  if (res != S_OK)
1034  delete factory;
1035  return res;
1036 }
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
HRESULT WINAPI QueryInterface(REFIID iid, LPVOID *iface)
long HRESULT

◆ ignoreProps()

bool ignoreProps ( const char *  test)

Definition at line 678 of file qaxserver.cpp.

Referenced by classIDL(), QAxServerBase::isPropertyExposed(), and QAxServerBase::removeMenu().

679 {
680  return ignore(test, ignore_props);
681 }
static bool ignore(const char *test, const char *const *table)
Definition: qaxserver.cpp:660
static const char *const ignore_props[]
Definition: qaxserver.cpp:596

◆ ignoreSlots()

bool ignoreSlots ( const char *  test)

Definition at line 673 of file qaxserver.cpp.

Referenced by classIDL(), and QAxServerBase::removeMenu().

674 {
675  return ignore(test, ignore_slots);
676 }
static bool ignore(const char *test, const char *const *table)
Definition: qaxserver.cpp:660
static const char *const ignore_slots[]
Definition: qaxserver.cpp:638

◆ mapModifiers()

static int mapModifiers ( int  state)
static

Definition at line 4304 of file qaxserverbase.cpp.

Referenced by QAxServerBase::eventFilter().

4305 {
4306  int ole = 0;
4307  if (state & Qt::ShiftModifier)
4308  ole |= 1;
4309  if (state & Qt::ControlModifier)
4310  ole |= 2;
4311  if (state & Qt::AltModifier)
4312  ole |= 4;
4313 
4314  return ole;
4315 }

◆ paramType()

static QByteArray paramType ( const QByteArray ptype,
bool *  out 
)
inlinestatic

Definition at line 1947 of file qaxserverbase.cpp.

Referenced by QAxBase::dynamicCallHelper(), QAxServerBase::Invoke(), and QAxServerBase::qt_metacall().

1948 {
1949  *out = ptype.endsWith('&') || ptype.endsWith("**");
1950  if (*out) {
1951  QByteArray res(ptype);
1952  res.truncate(res.length() - 1);
1953  return res;
1954  }
1955 
1956  return ptype;
1957 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
bool endsWith(const QByteArray &a) const
Returns true if this byte array ends with byte array ba; otherwise returns false. ...

◆ qax_winEventFilter()

bool qax_winEventFilter ( void *  message)

Definition at line 809 of file qaxserverbase.cpp.

Referenced by QClassFactory::CreateInstanceHelper().

810 {
811  MSG *pMsg = (MSG*)message;
812  if (pMsg->message < WM_KEYFIRST || pMsg->message > WM_KEYLAST)
813  return false;
814 
815  bool ret = false;
816  QWidget *aqt = QWidget::find(pMsg->hwnd);
817  if (!aqt)
818  return ret;
819 
820  HWND baseHwnd = ::GetParent(aqt->winId());
821  QAxServerBase *axbase = 0;
822  while (!axbase && baseHwnd) {
823 #ifdef GWLP_USERDATA
824  axbase = (QAxServerBase*)GetWindowLongPtr(baseHwnd, GWLP_USERDATA);
825 #else
826  axbase = (QAxServerBase*)GetWindowLong(baseHwnd, GWL_USERDATA);
827 #endif
828 
829  baseHwnd = ::GetParent(baseHwnd);
830  }
831  if (!axbase)
832  return ret;
833 
834  HRESULT hres = axbase->TranslateAcceleratorW(pMsg);
835  return hres == S_OK;
836 }
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
static QWidget * find(WId)
Returns a pointer to the widget with window identifer/handle id.
Definition: qwidget.cpp:2517
struct tagMSG MSG
long HRESULT
WId winId() const
Returns the window system identifier of the widget.
Definition: qwidget.cpp:2557

◆ qAxFactory()

QAxFactory* qAxFactory ( )

Definition at line 81 of file qaxserver.cpp.

Referenced by classIDL(), convertTypes(), QClassFactory::CreateInstance(), QClassFactory::CreateInstanceHelper(), QClassFactory::CreateInstanceLic(), DumpIDL(), QAxServerBase::ensureMetaData(), QAxServerBase::EnumVerbs(), QAxServerBase::GetClassID(), QAxServerBase::GetClassInfo(), QAxServerBase::GetGUID(), QClassFactory::GetLicInfo(), QAxServerBase::GetMiscStatus(), QAxServerBase::GetUserClassID(), QAxServerBase::internalConnect(), QAxServerBase::internalCreate(), QAxServerBase::InternalQueryInterface(), QClassFactory::QClassFactory(), QAxServerBase::qt_metacall(), QAxServerBase::registerActiveObject(), QClassFactory::RequestLicKey(), and UpdateRegistry().

82 {
83  if (!qax_factory) {
84  bool hadQApp = qApp != 0;
86  // QAxFactory created a QApplication
87  if (!hadQApp && qApp)
88  qax_ownQApp = true;
89 
90  // register all types with metatype system as pointers
92  for (int i = 0; i < keys.count(); ++i) {
93  QString key(keys.at(i));
94  qRegisterMetaType((key + QLatin1Char('*')).toLatin1(), (void**)(quintptr)-1);
95  }
96  }
97  return qax_factory;
98 }
QIntegerForSizeof< void * >::Unsigned quintptr
Definition: qglobal.h:986
QAxFactory * qax_instantiate()
bool qax_ownQApp
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
int qRegisterMetaType()
Call this function to register the type T.
Definition: qmetatype.h:234
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual QStringList featureList() const =0
Reimplement this function to return a list of the widgets (class names) supported by this factory...
QStringList keys
#define qApp
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
int key
static QAxFactory * qax_factory
Definition: qaxserver.cpp:71
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ qAxLock()

unsigned long qAxLock ( )

Definition at line 158 of file qaxserver.cpp.

Referenced by QAxServerBase::init(), and QClassFactory::LockServer().

159 {
160  EnterCriticalSection(&qAxModuleSection);
161  unsigned long ref = ++qAxModuleRef;
162  LeaveCriticalSection(&qAxModuleSection);
163  return ref;
164 }
static CRITICAL_SECTION qAxModuleSection
Definition: qaxserver.cpp:102
static unsigned long qAxModuleRef
Definition: qaxserver.cpp:101

◆ qAxUnlock()

unsigned long qAxUnlock ( )

Definition at line 166 of file qaxserver.cpp.

Referenced by QClassFactory::LockServer(), and QAxServerBase::~QAxServerBase().

167 {
168  if (!initCount) // cleaned up already
169  return 0;
170 
171  EnterCriticalSection(&qAxModuleSection);
172  unsigned long ref = --qAxModuleRef;
173  LeaveCriticalSection(&qAxModuleSection);
174 
175  if (!ref)
176  qax_shutDown();
177  return ref;
178 }
static CRITICAL_SECTION qAxModuleSection
Definition: qaxserver.cpp:102
static int initCount
Definition: qaxserver.cpp:109
static unsigned long qAxModuleRef
Definition: qaxserver.cpp:101
void qax_shutDown()

◆ QStringToOLESTR()

static LPOLESTR QStringToOLESTR ( const QString qstring)
inlinestatic

Definition at line 3726 of file qaxserverbase.cpp.

Referenced by QAxServerBase::GetUserType().

3727 {
3728  LPOLESTR olestr = (wchar_t*)CoTaskMemAlloc(qstring.length()*2+2);
3729  memcpy(olestr, (ushort*)qstring.unicode(), qstring.length()*2);
3730  olestr[qstring.length()] = 0;
3731  return olestr;
3732 }
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706
unsigned short ushort
Definition: qglobal.h:995

◆ qt_sendSpontaneousEvent()

bool qt_sendSpontaneousEvent ( QObject ,
QEvent  
)

Definition at line 5779 of file qapplication.cpp.

Referenced by QAxServerBase::resize(), QAxServerBase::SetColorScheme(), and QWSInputContext::translateIMEvent().

5780 {
5782 }
EventRef event
static bool sendSpontaneousEvent(QObject *receiver, QEvent *event)

◆ qt_translateKeyCode()

Q_GUI_EXPORT int qt_translateKeyCode ( int  )

Definition at line 517 of file qkeymapper_win.cpp.

Referenced by QAxServerBase::ReactivateAndUndo(), and QAxServerBase::TranslateAcceleratorW().

518 {
519  int code = winceKeyBend((vk < 0 || vk > 255) ? 0 : vk);
520  return code == Qt::Key_unknown ? 0 : code;
521 }
int winceKeyBend(int keyCode)

◆ qWinMsgHandler()

void qWinMsgHandler ( QtMsgType  t,
const char *  str 
)

Definition at line 143 of file qcoreapplication_win.cpp.

Referenced by QClassFactory::CreateInstanceHelper(), qax_winEventFilter(), qInstallMsgHandler(), qt_error_string(), and qWinMain().

144 {
145  Q_UNUSED(t);
146  // OutputDebugString is not threadsafe.
147 
148  // cannot use QMutex here, because qWarning()s in the QMutex
149  // implementation may cause this function to recurse
150  static QWinMsgHandlerCriticalSection staticCriticalSection;
151 
152  if (!str)
153  str = "(null)";
154 
155  staticCriticalSection.lock();
156 
158  s += QLatin1Char('\n');
159  OutputDebugString((wchar_t*)s.utf16());
160 
161  staticCriticalSection.unlock();
162 }
static QString fromLocal8Bit(const char *, int size=-1)
Returns a QString initialized with the first size characters of the 8-bit string str.
Definition: qstring.cpp:4245
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

Variable Documentation

◆ invokeCount

int invokeCount = 0
static

Definition at line 92 of file qaxserverbase.cpp.

Referenced by axs_FilterProc(), and QAxServerBase::Invoke().

◆ qax_disable_inplaceframe

bool qax_disable_inplaceframe = true

Definition at line 3814 of file qaxserverbase.cpp.

Referenced by QAxServerBase::internalActivate(), and qAxLockCount().

◆ qax_hhook

HHOOK qax_hhook

◆ qax_ownQApp

bool qax_ownQApp

Definition at line 50 of file qaxserverdll.cpp.

Referenced by QClassFactory::CreateInstanceHelper(), and DllCanUnloadNow().

◆ qAxInstance

HANDLE qAxInstance

Definition at line 65 of file qaxserver.cpp.

Referenced by QAxServerBase::create().

◆ qAxOutProcServer

bool qAxOutProcServer

◆ qaxserverbase_instance_count

unsigned long qaxserverbase_instance_count = 0

Definition at line 95 of file qaxserverbase.cpp.

Referenced by QAxServerBase::init(), and QAxServerBase::~QAxServerBase().

◆ qAxTypeLibrary

ITypeLib* qAxTypeLibrary