From 0bab3d8ace939b143c3df13d8331d0932ba52975 Mon Sep 17 00:00:00 2001 From: Rik Veenboer Date: Tue, 1 Sep 2015 13:12:04 +0100 Subject: [PATCH] Replace tabs with spaces --- src/main/cpp/Dispatch.cpp | 92 +- src/main/cpp/DispatchEvents.cpp | 110 +- src/main/cpp/DispatchProxy.cpp | 2 +- src/main/cpp/EnumVariant.cpp | 2 +- src/main/cpp/EventProxy.cpp | 1290 ++--- src/main/cpp/SafeArray.cpp | 26 +- src/main/cpp/Variant.cpp | 108 +- src/main/cpp/util.cpp | 8 +- src/main/headers/Dispatch.h | 2 +- src/main/headers/EventProxy.h | 8 +- src/main/headers/atlalloc.h | 930 ++-- src/main/headers/atlchecked.h | 378 +- src/main/headers/atlcomcli.h | 4848 ++++++++--------- src/main/headers/atlconv.h | 1390 ++--- src/main/headers/atlcore.h | 696 +-- src/main/headers/atldef.h | 188 +- src/main/headers/atlexcept.h | 64 +- src/main/headers/atliface.h | 3274 +++++------ src/main/headers/atlsimpcoll.h | 776 +-- src/main/headers/statreg.h | 2368 ++++---- .../com/jacob/activeX/ActiveXComponent.java | 1018 ++-- .../jacob/activeX/ActiveXDispatchEvents.java | 156 +- .../jacob/activeX/ActiveXInvocationProxy.java | 274 +- src/main/java/com/jacob/com/ComException.java | 236 +- .../java/com/jacob/com/ComFailException.java | 140 +- src/main/java/com/jacob/com/ComThread.java | 282 +- src/main/java/com/jacob/com/Currency.java | 168 +- .../java/com/jacob/com/DateUtilities.java | 158 +- src/main/java/com/jacob/com/Dispatch.java | 2598 ++++----- .../java/com/jacob/com/DispatchEvents.java | 360 +- .../com/jacob/com/DispatchIdentifier.java | 166 +- .../java/com/jacob/com/DispatchProxy.java | 134 +- src/main/java/com/jacob/com/EnumVariant.java | 260 +- .../java/com/jacob/com/InvocationProxy.java | 150 +- .../jacob/com/InvocationProxyAllVariants.java | 194 +- .../java/com/jacob/com/JacobException.java | 64 +- src/main/java/com/jacob/com/JacobObject.java | 160 +- .../java/com/jacob/com/JacobReleaseInfo.java | 184 +- .../java/com/jacob/com/LibraryLoader.java | 46 +- src/main/java/com/jacob/com/MainSTA.java | 28 +- .../jacob/com/NotImplementedException.java | 48 +- src/main/java/com/jacob/com/ROT.java | 474 +- src/main/java/com/jacob/com/STA.java | 158 +- src/main/java/com/jacob/com/SafeArray.java | 2314 ++++---- src/main/java/com/jacob/com/Variant.java | 4390 +++++++-------- .../java/com/jacob/com/VariantUtilities.java | 958 ++-- .../java/com/jacob/com/VariantViaEvent.java | 40 +- .../com/jacob/com/WrongThreadException.java | 66 +- .../com/jacob/samples/MathProj/MathTest.java | 124 +- .../com/jacob/samples/access/Access.java | 210 +- src/sample/com/jacob/samples/ado/Command.java | 350 +- .../jacob/samples/ado/CommandTypeEnum.java | 14 +- .../com/jacob/samples/ado/Connection.java | 224 +- src/sample/com/jacob/samples/ado/Field.java | 144 +- src/sample/com/jacob/samples/ado/Fields.java | 58 +- .../com/jacob/samples/ado/Recordset.java | 670 +-- src/sample/com/jacob/samples/ado/test.java | 90 +- .../jacob/samples/applet/JacobTestApplet.java | 104 +- .../com/jacob/samples/atl/MultiFace/Face.cpp | 60 +- .../com/jacob/samples/atl/MultiFace/Face.h | 42 +- .../jacob/samples/atl/MultiFace/MultiFace.h | 80 +- .../jacob/samples/atl/MultiFace/MultiFace_p.c | 198 +- .../com/jacob/samples/atl/MultiFaceTest.java | 66 +- .../samples/office/ExcelDispatchTest.java | 66 +- .../jacob/samples/office/VisioPrintTest.java | 60 +- .../office/WordDocumentProperties.java | 246 +- .../com/jacob/samples/outlook/Outlook.java | 96 +- .../com/jacob/samples/system/DiskUtils.java | 234 +- .../jacob/samples/system/SystemMonitor.java | 92 +- .../com/jacob/samples/visio/VisioApp.java | 192 +- .../jacob/samples/visio/VisioAppFacade.java | 284 +- .../com/jacob/samples/visio/VisioDemo.java | 282 +- .../samples/visio/VisioEventAdapter.java | 84 +- .../samples/visio/VisioEventListener.java | 16 +- .../jacob/samples/visio/VisioException.java | 20 +- .../com/ActiveXComponentFactoryTest.java | 222 +- .../java/com/jacob/com/DateUtilitiesTest.java | 90 +- .../com/jacob/com/DispatchNullProgramId.java | 70 +- src/test/java/com/jacob/com/DispatchTest.java | 64 +- .../jacob/com/DispatchValidDispatchTest.java | 80 +- .../java/com/jacob/com/JacobDeadlockTest.java | 202 +- .../java/com/jacob/com/JacobObjectTest.java | 42 +- src/test/java/com/jacob/com/ROT2Test.java | 216 +- src/test/java/com/jacob/com/ROT3Test.java | 250 +- src/test/java/com/jacob/com/ROTTest.java | 250 +- .../java/com/jacob/com/VariantDateTest.java | 126 +- src/test/java/com/jacob/com/VariantTest.java | 1480 ++--- .../com/jacob/com/VariantUtilitiesTest.java | 214 +- .../java/com/jacob/test/BaseTestCase.java | 298 +- .../jacob/test/errors/UnicodeErrorTest.java | 64 +- .../com/jacob/test/events/ExcelEventTest.java | 262 +- .../java/com/jacob/test/events/IETest.java | 784 +-- .../jacob/test/events/IETestActiveXProxy.java | 492 +- .../com/jacob/test/events/WordEventTest.java | 154 +- .../com/jacob/test/excel/ControllerTest.java | 408 +- .../jacob/test/powerpoint/PowerpointTest.java | 260 +- .../test/safearray/SafeArrayBasicTest.java | 548 +- .../test/safearray/SafeArrayContents.java | 466 +- .../test/safearray/SafeArrayDispatchTest.java | 78 +- .../jacob/test/safearray/SafeArrayLeak.java | 284 +- .../test/safearray/SafeArrayReleaseTest.java | 92 +- .../SafeArrayStringConstructorTest.java | 42 +- .../test/safearray/SafeArrayViaExcel.java | 134 +- .../com/jacob/test/vbscript/ScriptTest.java | 116 +- .../com/jacob/test/vbscript/ScriptTest2.java | 142 +- .../test/vbscript/ScriptTest2ActiveX.java | 142 +- .../com/jacob/test/vbscript/ScriptTest3.java | 130 +- .../test/vbscript/ScriptTest3ActiveX.java | 124 +- .../test/vbscript/ScriptTestActiveX.java | 94 +- .../test/vbscript/ScriptTestErrEvents.java | 40 +- .../com/jacob/test/windowsmedia/WMPlayer.java | 112 +- 111 files changed, 22231 insertions(+), 22231 deletions(-) diff --git a/src/main/cpp/Dispatch.cpp b/src/main/cpp/Dispatch.cpp index aad1b75..9f0c4f2 100644 --- a/src/main/cpp/Dispatch.cpp +++ b/src/main/cpp/Dispatch.cpp @@ -279,7 +279,7 @@ JNIEXPORT jintArray JNICALL Java_com_jacob_com_Dispatch_getIDsOfNames { USES_CONVERSION; jstring s = (jstring)env->GetObjectArrayElement(names, i); - // if we used env->GetStringChars() would that let us drop the conversion? + // if we used env->GetStringChars() would that let us drop the conversion? const char *nm = env->GetStringUTFChars(s, NULL); LPOLESTR nmos = A2W(nm); env->ReleaseStringUTFChars(s, nm); @@ -319,8 +319,8 @@ static char* BasicToCharString(const BSTR inBasicString) if (charStrSize > 1) { charString = new char[charStrSize]; - size_t convertedSize; - ::wcstombs_s(&convertedSize, charString, charStrSize, inBasicString, charStrSize); + size_t convertedSize; + ::wcstombs_s(&convertedSize, charString, charStrSize, inBasicString, charStrSize); } else { @@ -394,14 +394,14 @@ static wchar_t* CreateErrorMsgFromInfo(HRESULT inResult, EXCEPINFO* ioInfo, const size_t MSG_LEN = ::wcslen(methNameW) + ::wcslen(msg2) + 256; msg = new wchar_t[MSG_LEN]; ::wcsncpy_s(msg, MSG_LEN, - L"A COM exception has been encountered:\nAt Invoke of: ", - wcslen(L"A COM exception has been encountered:\nAt Invoke of: ")); + L"A COM exception has been encountered:\nAt Invoke of: ", + wcslen(L"A COM exception has been encountered:\nAt Invoke of: ")); ::wcsncat_s(msg, MSG_LEN, methNameW, wcslen(methNameW)); ::wcsncat_s(msg, MSG_LEN, L"\nDescription: ", wcslen(L"\nDescription: ")); ::wcsncat_s(msg, MSG_LEN, msg2, wcslen(msg2)); // jacob-msg 1075 - SF 1053872 : Documentation says "use LocalFree"!! //delete msg2; - LocalFree(msg2); + LocalFree(msg2); } delete methNameW; return msg; @@ -494,15 +494,15 @@ JNIEXPORT jobject JNICALL Java_com_jacob_com_Dispatch_invokev jint count = env->GetArrayLength(uArgErr); if ( count != 0 ) { - jint *uAE = env->GetIntArrayElements(uArgErr, NULL); - hr = pIDispatch->Invoke(dispID,IID_NULL, - lcid,(WORD)wFlags,&dispparams,v,&excepInfo,(unsigned int *)uAE); // SF 1689061 - env->ReleaseIntArrayElements(uArgErr, uAE, 0); + jint *uAE = env->GetIntArrayElements(uArgErr, NULL); + hr = pIDispatch->Invoke(dispID,IID_NULL, + lcid,(WORD)wFlags,&dispparams,v,&excepInfo,(unsigned int *)uAE); // SF 1689061 + env->ReleaseIntArrayElements(uArgErr, uAE, 0); } else { - hr = pIDispatch->Invoke(dispID,IID_NULL, - lcid,(WORD)wFlags,&dispparams,v,&excepInfo, NULL); // SF 1689061 + hr = pIDispatch->Invoke(dispID,IID_NULL, + lcid,(WORD)wFlags,&dispparams,v,&excepInfo, NULL); // SF 1689061 } if (num_args) { @@ -531,30 +531,30 @@ JNIEXPORT jobject JNICALL Java_com_jacob_com_Dispatch_invokev // this method can get called with a name or a dispatch id // we need to handle both SF 1114159 if (name != NULL){ - const char *nm = env->GetStringUTFChars(name, NULL); - buf = CreateErrorMsgFromInfo(hr, &excepInfo, nm); - env->ReleaseStringUTFChars(name, nm); + const char *nm = env->GetStringUTFChars(name, NULL); + buf = CreateErrorMsgFromInfo(hr, &excepInfo, nm); + env->ReleaseStringUTFChars(name, nm); } else { - dispIdAsName = new char[256]; - // get the id string - _itoa_s (dispID, dispIdAsName, 256,10); - //continue on mostly as before - buf = CreateErrorMsgFromInfo(hr,&excepInfo,dispIdAsName); + dispIdAsName = new char[256]; + // get the id string + _itoa_s (dispID, dispIdAsName, 256,10); + //continue on mostly as before + buf = CreateErrorMsgFromInfo(hr,&excepInfo,dispIdAsName); } // jacob-msg 3696 - SF 1053866 - if(hr == DISP_E_EXCEPTION) - { - if(excepInfo.scode != 0) - { - hr = excepInfo.scode; - } - else - { - hr = _com_error::WCodeToHRESULT(excepInfo.wCode); - } - } - + if(hr == DISP_E_EXCEPTION) + { + if(excepInfo.scode != 0) + { + hr = excepInfo.scode; + } + else + { + hr = _com_error::WCodeToHRESULT(excepInfo.wCode); + } + } + ThrowComFailUnicode(env, buf, hr); if (buf) delete buf; if (dispIdAsName) delete dispIdAsName; @@ -568,20 +568,20 @@ JNIEXPORT jobject JNICALL Java_com_jacob_com_Dispatch_invokev * Wait method added so folks could wait until a com server terminated */ JNIEXPORT jint JNICALL Java_com_jacob_com_Dispatch_hasExited - (JNIEnv *env,jclass clazz, jobject disp, jint dispid, jint lcid) { - IDispatch *pIDispatch = extractDispatch(env, disp); - if (!pIDispatch) { - // should we return 0? - return NULL; - } - ITypeInfo *v; - HRESULT hr = pIDispatch->GetTypeInfo(dispid, lcid, &v); - if (hr == RPC_E_SERVERCALL_RETRYLATER || hr == RPC_E_CALL_REJECTED || hr - == 0) { - return 0; - } else { - return 1; - } + (JNIEnv *env,jclass clazz, jobject disp, jint dispid, jint lcid) { + IDispatch *pIDispatch = extractDispatch(env, disp); + if (!pIDispatch) { + // should we return 0? + return NULL; + } + ITypeInfo *v; + HRESULT hr = pIDispatch->GetTypeInfo(dispid, lcid, &v); + if (hr == RPC_E_SERVERCALL_RETRYLATER || hr == RPC_E_CALL_REJECTED || hr + == 0) { + return 0; + } else { + return 1; + } } } diff --git a/src/main/cpp/DispatchEvents.cpp b/src/main/cpp/DispatchEvents.cpp index d30625e..246a561 100644 --- a/src/main/cpp/DispatchEvents.cpp +++ b/src/main/cpp/DispatchEvents.cpp @@ -74,32 +74,32 @@ JNIEXPORT void JNICALL Java_com_jacob_com_DispatchEvents_init3 jstring _progid, jstring _typelib) { - USES_CONVERSION; + USES_CONVERSION; if (_typelib != NULL && _progid == NULL){ - // both are required if typelib exists - ThrowComFail(env,"TypeLib was specified but no program id was",-1); - return; + // both are required if typelib exists + ThrowComFail(env,"TypeLib was specified but no program id was",-1); + return; } BSTR typeLib = NULL; if (_typelib != NULL){ - // why is this UTF instead of unicode? Then we could probably drop the A2W - const char *typelib = env->GetStringUTFChars(_typelib, NULL); - typeLib = A2W(typelib); - // should we call env->ReleaseStringUTFChars(,) to free the memory like we do everywhere lese? - - //printf("we have a type lib %ls\n",typeLib); + // why is this UTF instead of unicode? Then we could probably drop the A2W + const char *typelib = env->GetStringUTFChars(_typelib, NULL); + typeLib = A2W(typelib); + // should we call env->ReleaseStringUTFChars(,) to free the memory like we do everywhere lese? + + //printf("we have a type lib %ls\n",typeLib); } // find progid if any LPOLESTR bsProgId = NULL; if (_progid!=NULL) { - // why is this UTF instead of unicode? Then we could probably drop the A2W - const char *progid = env->GetStringUTFChars(_progid, NULL); - bsProgId = A2W(progid); - // should we call env->ReleaseStringUTFChars(,) to free the memory like we do everywhere lese? - //printf("we have an applicaton %ls\n",bsProgId); + // why is this UTF instead of unicode? Then we could probably drop the A2W + const char *progid = env->GetStringUTFChars(_progid, NULL); + bsProgId = A2W(progid); + // should we call env->ReleaseStringUTFChars(,) to free the memory like we do everywhere lese? + //printf("we have an applicaton %ls\n",bsProgId); } // get the IDispatch for the source object @@ -119,15 +119,15 @@ JNIEXPORT void JNICALL Java_com_jacob_com_DispatchEvents_init3 DISPID *mIDs; int n_EventMethods; if (_typelib == NULL){ - if (!GetEventIID(pUnk, &eventIID, &mNames, &mIDs, &n_EventMethods,bsProgId)) { - ThrowComFail(env, "Can't find event iid", -1); - return; - } + if (!GetEventIID(pUnk, &eventIID, &mNames, &mIDs, &n_EventMethods,bsProgId)) { + ThrowComFail(env, "Can't find event iid", -1); + return; + } } else { - if (!GetEventIIDForTypeLib(typeLib, &eventIID, &mNames, &mIDs, &n_EventMethods,bsProgId)) { - ThrowComFail(env, "Can't find event iid for type lib", -1); - return; - } + if (!GetEventIIDForTypeLib(typeLib, &eventIID, &mNames, &mIDs, &n_EventMethods,bsProgId)) { + ThrowComFail(env, "Can't find event iid for type lib", -1); + return; + } } // hook up to the default source iid @@ -153,10 +153,10 @@ JNIEXPORT void JNICALL Java_com_jacob_com_DispatchEvents_release { EventProxy *ep = extractProxy(env, _this); if (ep) { - // Disconnect must be called to reduce the ref count to the EventProxy otherwise - // the destructor will never be called (to actually do the disconnect) - ep->Disconnect(); // SF 3412922 - // this is the line that blows up in IETest + // Disconnect must be called to reduce the ref count to the EventProxy otherwise + // the destructor will never be called (to actually do the disconnect) + ep->Disconnect(); // SF 3412922 + // this is the line that blows up in IETest ep->Release(); putProxy(env, _this, NULL); } @@ -219,15 +219,15 @@ BOOL GetEventIID(IUnknown *m_pObject, IID* piid, { //printf("got IProvideClassInfo\n"); ATLASSERT(pPCI != NULL); - HRESULT hr = pPCI->GetClassInfo(&pClassInfo); + HRESULT hr = pPCI->GetClassInfo(&pClassInfo); pPCI->Release(); if (!SUCCEEDED(hr)) return false; } else if (getClassInfoFromProgId(bsProgId,&pClassInfo)) { - } - else { + } + else { printf("GetEventIID: couldn't get IProvideClassInfo\n"); - return false; + return false; } return MapEventIIDs(piid, mNames, mIDs, nmeth, bsProgId, pClassInfo); @@ -249,7 +249,7 @@ BOOL MapEventIIDs(IID* piid, int nFlags; HREFTYPE hRefType; - //printf("MapEventIIDs: looking at %d class attribute impl types \n"); + //printf("MapEventIIDs: looking at %d class attribute impl types \n"); for (unsigned int i = 0; i < pClassAttr->cImplTypes; i++) { if (SUCCEEDED(pClassInfo->GetImplTypeFlags(i, &nFlags)) && @@ -300,25 +300,25 @@ BOOL getClassInfoFromProgId(LPOLESTR bsProgId,LPTYPEINFO *pClassInfo) LONG lVal; lVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE,_T("SOFTWARE"),0,KEY_READ,&keySoftware); if (lVal==ERROR_SUCCESS) { - lVal = RegOpenKeyEx(keySoftware,_T("Classes"),0,KEY_READ,&keyClasses); - if (lVal==ERROR_SUCCESS) { - lVal = RegOpenKeyEx(keyClasses,_T("CLSID"),0,KEY_READ,&keyCLSID); - if (lVal==ERROR_SUCCESS) { - _TCHAR *tsProgId = W2T(bsProgId); - lVal = RegOpenKeyEx(keyCLSID,tsProgId,0,KEY_READ,&keyXXXX); - if (lVal==ERROR_SUCCESS) { - lVal = RegOpenKeyEx(keyXXXX,_T("TypeLib"),0,KEY_READ,&keyTypeLib); - if (lVal==ERROR_SUCCESS) { - lVal = RegQueryValueExA(keyTypeLib,NULL,NULL,&dwType,abData,&dwCountData); - RegCloseKey(keyTypeLib); - } - RegCloseKey(keyXXXX); - } - RegCloseKey(keyCLSID); - } - RegCloseKey(keyClasses); - } - RegCloseKey(keySoftware); + lVal = RegOpenKeyEx(keySoftware,_T("Classes"),0,KEY_READ,&keyClasses); + if (lVal==ERROR_SUCCESS) { + lVal = RegOpenKeyEx(keyClasses,_T("CLSID"),0,KEY_READ,&keyCLSID); + if (lVal==ERROR_SUCCESS) { + _TCHAR *tsProgId = W2T(bsProgId); + lVal = RegOpenKeyEx(keyCLSID,tsProgId,0,KEY_READ,&keyXXXX); + if (lVal==ERROR_SUCCESS) { + lVal = RegOpenKeyEx(keyXXXX,_T("TypeLib"),0,KEY_READ,&keyTypeLib); + if (lVal==ERROR_SUCCESS) { + lVal = RegQueryValueExA(keyTypeLib,NULL,NULL,&dwType,abData,&dwCountData); + RegCloseKey(keyTypeLib); + } + RegCloseKey(keyXXXX); + } + RegCloseKey(keyCLSID); + } + RegCloseKey(keyClasses); + } + RegCloseKey(keySoftware); } if (lVal!=ERROR_SUCCESS) return false; BSTR bsLibId = A2BSTR((char*)abData); @@ -344,7 +344,7 @@ BOOL getClassInfoFromProgIdTypeLib(BSTR typeLib, LPOLESTR bsProgId, LPTYPEINFO * if (FAILED(StringFromCLSID(clsid,&bsProgId))) return false; ITypeLib* pITypeLib; - if (FAILED(LoadTypeLib(typeLib, &pITypeLib))) return false; + if (FAILED(LoadTypeLib(typeLib, &pITypeLib))) return false; //Find ITypeInfo for coclass. pITypeLib->GetTypeInfoOfGuid(clsid, pClassInfo); @@ -358,9 +358,9 @@ BOOL GetEventIIDForTypeLib(BSTR typeLib, IID* piid, LPTYPEINFO pClassInfo = NULL; if(getClassInfoFromProgIdTypeLib(typeLib, bsProgId,&pClassInfo)) { - if (pClassInfo == NULL){ - printf("we had a successful return but pClassInfo is null\n"); - } + if (pClassInfo == NULL){ + printf("we had a successful return but pClassInfo is null\n"); + } return MapEventIIDs(piid, mNames, mIDs, nmeth, bsProgId, pClassInfo); } else diff --git a/src/main/cpp/DispatchProxy.cpp b/src/main/cpp/DispatchProxy.cpp index c6b5e77..338f352 100644 --- a/src/main/cpp/DispatchProxy.cpp +++ b/src/main/cpp/DispatchProxy.cpp @@ -97,7 +97,7 @@ JNIEXPORT void JNICALL Java_com_jacob_com_DispatchProxy_release IStream *ps = extractStream(env, _this); if (ps) { ps->Release(); - jclass argClass = env->GetObjectClass(_this); + jclass argClass = env->GetObjectClass(_this); jfieldID ajf = env->GetFieldID( argClass, "m_pStream", "J"); env->SetLongField(_this, ajf, 0ll); } diff --git a/src/main/cpp/EnumVariant.cpp b/src/main/cpp/EnumVariant.cpp index a21d70c..0843599 100644 --- a/src/main/cpp/EnumVariant.cpp +++ b/src/main/cpp/EnumVariant.cpp @@ -48,7 +48,7 @@ JNIEXPORT jint JNICALL Java_com_jacob_com_EnumVariant_Next(JNIEnv* env, jobject _this, jobjectArray vars) { IEnumVARIANT* self = extractEnumVariant(env, _this); - //printf("self=%x\n", self); + //printf("self=%x\n", self); if(self == NULL) return 0; diff --git a/src/main/cpp/EventProxy.cpp b/src/main/cpp/EventProxy.cpp index 023b316..42e0061 100644 --- a/src/main/cpp/EventProxy.cpp +++ b/src/main/cpp/EventProxy.cpp @@ -22,7 +22,7 @@ // hook myself up as a listener for delegate EventProxy::EventProxy(JNIEnv *env, - jobject aSinkObj, + jobject aSinkObj, CComPtr pConn, IID eid, CComBSTR mName[], @@ -33,14 +33,14 @@ EventProxy::EventProxy(JNIEnv *env, eventIID(eid), MethNum(mNum), MethName(mName), MethID(mID) { - // keep a pointer to the sink - javaSinkObj = env->NewGlobalRef(aSinkObj); - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} + // keep a pointer to the sink + javaSinkObj = env->NewGlobalRef(aSinkObj); + if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - // we need this to attach to the event invocation thread - env->GetJavaVM(&jvm); - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - AddRef(); + // we need this to attach to the event invocation thread + env->GetJavaVM(&jvm); + if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} + AddRef(); Connect(env); } @@ -60,45 +60,45 @@ void EventProxy::Connect(JNIEnv *env) { // unhook myself up as a listener and get rid of delegate EventProxy::~EventProxy() { - JNIEnv *env; + JNIEnv *env; Disconnect(); jint vmConnectionStatus = JNI_EVERSION ; jint attachReturnStatus = -1; // AttachCurrentThread return status.. negative numbers are failure return codes. - // attach to the current running thread -- JDK 1.4 jni.h has two param cover for 3 param call + // attach to the current running thread -- JDK 1.4 jni.h has two param cover for 3 param call vmConnectionStatus = jvm->GetEnv((void **)&env, JNI_VERSION_1_2); - if ((env != NULL)&& env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - if (vmConnectionStatus == JNI_EDETACHED){ - //printf("Unhook: Attaching to current thread using JNI Version 1.2 (%d)\n",vmConnectionStatus); - JavaVMAttachArgs attachmentArgs; + if ((env != NULL)&& env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} + if (vmConnectionStatus == JNI_EDETACHED){ + //printf("Unhook: Attaching to current thread using JNI Version 1.2 (%d)\n",vmConnectionStatus); + JavaVMAttachArgs attachmentArgs; attachmentArgs.version = JNI_VERSION_1_2; attachmentArgs.name = NULL; attachmentArgs.group = NULL; attachReturnStatus = jvm->AttachCurrentThread((void **)&env, &attachmentArgs); - if ((env != NULL) && env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - } else { - // should really look for JNI_OK versus an error because it could have been JNI_EVERSION - // started method with thread hooked to VM so no need to attach again - //printf("Unhook: No need to attach because already attached %d\n",vmConnectionStatus); - } + if ((env != NULL) && env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} + } else { + // should really look for JNI_OK versus an error because it could have been JNI_EVERSION + // started method with thread hooked to VM so no need to attach again + //printf("Unhook: No need to attach because already attached %d\n",vmConnectionStatus); + } - // we should always have an env by this point but lets be paranoid and check - if (env != NULL){ - env->DeleteGlobalRef(javaSinkObj); - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - } - if (MethNum) { - delete [] MethName; - delete [] MethID; - } - // detach from thread only if we attached to it in this function - if (attachReturnStatus == 0){ - jvm->DetachCurrentThread(); - //printf("Unhook: Detached\n"); - } else { - //printf("Unhook: No need to detatch because attached prior to method\n"); - } - //fflush(stdout); + // we should always have an env by this point but lets be paranoid and check + if (env != NULL){ + env->DeleteGlobalRef(javaSinkObj); + if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} + } + if (MethNum) { + delete [] MethName; + delete [] MethID; + } + // detach from thread only if we attached to it in this function + if (attachReturnStatus == 0){ + jvm->DetachCurrentThread(); + //printf("Unhook: Detached\n"); + } else { + //printf("Unhook: No need to detatch because attached prior to method\n"); + } + //fflush(stdout); } void EventProxy::Disconnect() { @@ -136,123 +136,123 @@ STDMETHODIMP EventProxy::Invoke(DISPID dispID, REFIID riid, LCID lcid, unsigned short wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) { - const char *eventMethodName = NULL; //Sourceforge report 1394001 - JNIEnv *env = NULL; + const char *eventMethodName = NULL; //Sourceforge report 1394001 + JNIEnv *env = NULL; // map dispID to jmethodID for(int i=0;iAttachCurrentThread((void **)&env, &attachmentArgs); - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} + if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - if (!eventMethodName) - { - // could not find this signature in list - // printf("Invoke: didn't find method name for dispatch id %d\n",dispID); - // this probably leaves a native thread attached to the vm when we don't want it - ThrowComFail(env, "Event method received was not defined as part of callback interface", -1); - - // should we detatch before returning?? We probably never get here if we ThrowComFail() - // jvm->DetachCurrentThread(); - return S_OK; - } + if (!eventMethodName) + { + // could not find this signature in list + // printf("Invoke: didn't find method name for dispatch id %d\n",dispID); + // this probably leaves a native thread attached to the vm when we don't want it + ThrowComFail(env, "Event method received was not defined as part of callback interface", -1); + + // should we detatch before returning?? We probably never get here if we ThrowComFail() + // jvm->DetachCurrentThread(); + return S_OK; + } - // find the class of the InvocationHandler - jclass javaSinkClass = env->GetObjectClass(javaSinkObj); - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - //printf("Invoke: Got sink class\n"); + // find the class of the InvocationHandler + jclass javaSinkClass = env->GetObjectClass(javaSinkObj); + if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} + //printf("Invoke: Got sink class\n"); jmethodID invokeMethod; invokeMethod = env->GetMethodID(javaSinkClass, "invoke", "(Ljava/lang/String;[Lcom/jacob/com/Variant;)Lcom/jacob/com/Variant;"); - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} + if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} jstring eventMethodNameAsString = env->NewStringUTF(eventMethodName); - //printf("Invoke: Got method name\n"); - // now do what we need for the variant + //printf("Invoke: Got method name\n"); + // now do what we need for the variant jmethodID getVariantMethod = env->GetMethodID(javaSinkClass, "getVariant", "()Lcom/jacob/com/Variant;"); - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - //printf("Invoke: Found way too getVariant\n"); + if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} + //printf("Invoke: Found way too getVariant\n"); jobject aVariantObj = env->CallObjectMethod(javaSinkObj, getVariantMethod); - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - //printf("Invoke: Made Variant\n"); - jclass variantClass = env->GetObjectClass(aVariantObj); - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} + if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} + //printf("Invoke: Made Variant\n"); + jclass variantClass = env->GetObjectClass(aVariantObj); + if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - // create the variant parameter array + // create the variant parameter array // how many params int numVariantParams = pDispParams->cArgs; // make an array of them jobjectArray varr = env->NewObjectArray(numVariantParams, variantClass, 0); - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - //printf("Invoke: Created Array\n"); + if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} + //printf("Invoke: Created Array\n"); int i,j; for(i=numVariantParams-1,j=0;i>=0;i--,j++) { // construct a java variant holder - jobject arg = env->CallObjectMethod(javaSinkObj, getVariantMethod); - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} + jobject arg = env->CallObjectMethod(javaSinkObj, getVariantMethod); + if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} // get the empty variant from it VARIANT *va = extractVariant(env, arg); // copy the value VariantCopy(va, &pDispParams->rgvarg[i]); // put it in the array env->SetObjectArrayElement(varr, j, arg); - env->DeleteLocalRef(arg); - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} + env->DeleteLocalRef(arg); + if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} } - //printf("Invoke: Filled Array\n"); + //printf("Invoke: Filled Array\n"); // Set up the return value jobject ret; ret = env->CallObjectMethod(javaSinkObj, invokeMethod, - eventMethodNameAsString, varr); - //printf("Invoke: Invoked callback\n"); + eventMethodNameAsString, varr); + //printf("Invoke: Invoked callback\n"); if (!env->ExceptionOccurred() && ret != NULL) { VariantCopy(pVarResult, extractVariant(env,ret)); } - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} - // don't need the first variant we created to get the class - // SF 1689061 change not accepted but put in as comment for later reminder + if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} + // don't need the first variant we created to get the class + // SF 1689061 change not accepted but put in as comment for later reminder //Java_com_jacob_com_Variant_release(env, aVariantObj); - env->DeleteLocalRef(aVariantObj); - if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} + env->DeleteLocalRef(aVariantObj); + if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear();} // Begin code from Jiffie team that copies parameters back from java to COM for(i=numVariantParams-1,j=0;i>=0;i--,j++) { - jobject arg = env->GetObjectArrayElement(varr, j); - VARIANT *java = extractVariant(env, arg); - VARIANT *com = &pDispParams->rgvarg[i]; - convertJavaVariant(java, com); - // SF 1689061 change not accepted but put in as comment for later reminder - // note that a related fix has been submitted in SF 3435567 to do this in zeroVariant() method - //Java_com_jacob_com_Variant_release(env, arg); - zeroVariant(env, arg); - env->DeleteLocalRef(arg); + jobject arg = env->GetObjectArrayElement(varr, j); + VARIANT *java = extractVariant(env, arg); + VARIANT *com = &pDispParams->rgvarg[i]; + convertJavaVariant(java, com); + // SF 1689061 change not accepted but put in as comment for later reminder + // note that a related fix has been submitted in SF 3435567 to do this in zeroVariant() method + //Java_com_jacob_com_Variant_release(env, arg); + zeroVariant(env, arg); + env->DeleteLocalRef(arg); } // End code from Jiffie team that copies parameters back from java to COM // detach from thread - //printf("Invoke: Detatching\n"); - jvm->DetachCurrentThread(); - //fflush(stdout); + //printf("Invoke: Detatching\n"); + jvm->DetachCurrentThread(); + //fflush(stdout); return S_OK; } return E_NOINTERFACE; @@ -260,616 +260,616 @@ STDMETHODIMP EventProxy::Invoke(DISPID dispID, REFIID riid, void EventProxy::convertJavaVariant(VARIANT *java, VARIANT *com) { - switch (com->vt) - { - case VT_DISPATCH: - { - switch (java->vt) - { - case VT_DISPATCH: - { - V_DISPATCH(com) = V_DISPATCH(java); - break; - } + switch (com->vt) + { + case VT_DISPATCH: + { + switch (java->vt) + { + case VT_DISPATCH: + { + V_DISPATCH(com) = V_DISPATCH(java); + break; + } - case VT_DISPATCH | VT_BYREF: - { - V_DISPATCH(com) = *V_DISPATCHREF(java); - break; - } - } - break; - } + case VT_DISPATCH | VT_BYREF: + { + V_DISPATCH(com) = *V_DISPATCHREF(java); + break; + } + } + break; + } - case VT_DISPATCH | VT_BYREF: - { - switch (java->vt) - { - case VT_DISPATCH: - { - *V_DISPATCHREF(com) = V_DISPATCH(java); - break; - } + case VT_DISPATCH | VT_BYREF: + { + switch (java->vt) + { + case VT_DISPATCH: + { + *V_DISPATCHREF(com) = V_DISPATCH(java); + break; + } - case VT_DISPATCH | VT_BYREF: - { - *V_DISPATCHREF(com) = *V_DISPATCHREF(java); - break; - } - } - break; - } + case VT_DISPATCH | VT_BYREF: + { + *V_DISPATCHREF(com) = *V_DISPATCHREF(java); + break; + } + } + break; + } - case VT_BOOL: - { - switch (java->vt) - { - case VT_BOOL: - { - V_BOOL(com) = V_BOOL(java); - break; - } + case VT_BOOL: + { + switch (java->vt) + { + case VT_BOOL: + { + V_BOOL(com) = V_BOOL(java); + break; + } - case VT_BOOL | VT_BYREF: - { - V_BOOL(com) = *V_BOOLREF(java); - break; - } - } - break; - } + case VT_BOOL | VT_BYREF: + { + V_BOOL(com) = *V_BOOLREF(java); + break; + } + } + break; + } - case VT_BOOL | VT_BYREF: - { - switch (java->vt) - { - case VT_BOOL: - { - *V_BOOLREF(com) = V_BOOL(java); - break; - } + case VT_BOOL | VT_BYREF: + { + switch (java->vt) + { + case VT_BOOL: + { + *V_BOOLREF(com) = V_BOOL(java); + break; + } - case VT_BOOL | VT_BYREF: - { - *V_BOOLREF(com) = *V_BOOLREF(java); - break; - } - } - break; - } + case VT_BOOL | VT_BYREF: + { + *V_BOOLREF(com) = *V_BOOLREF(java); + break; + } + } + break; + } - case VT_UI1: - { - switch (java->vt) - { - case VT_UI1: - { - V_UI1(com) = V_UI1(java); - break; - } + case VT_UI1: + { + switch (java->vt) + { + case VT_UI1: + { + V_UI1(com) = V_UI1(java); + break; + } - case VT_UI1 | VT_BYREF: - { - V_UI1(com) = *V_UI1REF(java); - break; - } - } - break; - } + case VT_UI1 | VT_BYREF: + { + V_UI1(com) = *V_UI1REF(java); + break; + } + } + break; + } - case VT_UI1 | VT_BYREF: - { - switch (java->vt) - { - case VT_UI1: - { - *V_UI1REF(com) = V_UI1(java); - break; - } + case VT_UI1 | VT_BYREF: + { + switch (java->vt) + { + case VT_UI1: + { + *V_UI1REF(com) = V_UI1(java); + break; + } - case VT_UI1 | VT_BYREF: - { - *V_UI1REF(com) = *V_UI1REF(java); - break; - } - } - break; - } + case VT_UI1 | VT_BYREF: + { + *V_UI1REF(com) = *V_UI1REF(java); + break; + } + } + break; + } - case VT_I2: - { - switch (java->vt) - { - case VT_I2: - { - V_I2(com) = V_I2(java); - break; - } + case VT_I2: + { + switch (java->vt) + { + case VT_I2: + { + V_I2(com) = V_I2(java); + break; + } - case VT_I2 | VT_BYREF: - { - V_I2(com) = *V_I2REF(java); - break; - } - } - break; - } + case VT_I2 | VT_BYREF: + { + V_I2(com) = *V_I2REF(java); + break; + } + } + break; + } - case VT_I2 | VT_BYREF: - { - switch (java->vt) - { - case VT_I2: - { - *V_I2REF(com) = V_I2(java); - break; - } + case VT_I2 | VT_BYREF: + { + switch (java->vt) + { + case VT_I2: + { + *V_I2REF(com) = V_I2(java); + break; + } - case VT_I2 | VT_BYREF: - { - *V_I2REF(com) = *V_I2REF(java); - break; - } - } - break; - } + case VT_I2 | VT_BYREF: + { + *V_I2REF(com) = *V_I2REF(java); + break; + } + } + break; + } - case VT_I4: - { - switch (java->vt) - { - case VT_I4: - { - V_I4(com) = V_I4(java); - break; - } + case VT_I4: + { + switch (java->vt) + { + case VT_I4: + { + V_I4(com) = V_I4(java); + break; + } - case VT_I4 | VT_BYREF: - { - V_I4(com) = *V_I4REF(java); - break; - } - } - break; - } + case VT_I4 | VT_BYREF: + { + V_I4(com) = *V_I4REF(java); + break; + } + } + break; + } - case VT_I4 | VT_BYREF: - { - switch (java->vt) - { - case VT_I4: - { - *V_I4REF(com) = V_I4(java); - break; - } + case VT_I4 | VT_BYREF: + { + switch (java->vt) + { + case VT_I4: + { + *V_I4REF(com) = V_I4(java); + break; + } - case VT_I4 | VT_BYREF: - { - *V_I4REF(com) = *V_I4REF(java); - break; - } - } - break; - } + case VT_I4 | VT_BYREF: + { + *V_I4REF(com) = *V_I4REF(java); + break; + } + } + break; + } - case VT_R4: - { - switch (java->vt) - { - case VT_R4: - { - V_R4(com) = V_R4(java); - break; - } + case VT_R4: + { + switch (java->vt) + { + case VT_R4: + { + V_R4(com) = V_R4(java); + break; + } - case VT_R4 | VT_BYREF: - { - V_R4(com) = *V_R4REF(java); - break; - } - } - break; - } + case VT_R4 | VT_BYREF: + { + V_R4(com) = *V_R4REF(java); + break; + } + } + break; + } - case VT_R4 | VT_BYREF: - { - switch (java->vt) - { - case VT_R4: - { - *V_R4REF(com) = V_R4(java); - break; - } + case VT_R4 | VT_BYREF: + { + switch (java->vt) + { + case VT_R4: + { + *V_R4REF(com) = V_R4(java); + break; + } - case VT_R4 | VT_BYREF: - { - *V_R4REF(com) = *V_R4REF(java); - break; - } - } - break; - } + case VT_R4 | VT_BYREF: + { + *V_R4REF(com) = *V_R4REF(java); + break; + } + } + break; + } - case VT_R8: - { - switch (java->vt) - { - case VT_R8: - { - V_R8(com) = V_R8(java); - break; - } + case VT_R8: + { + switch (java->vt) + { + case VT_R8: + { + V_R8(com) = V_R8(java); + break; + } - case VT_R8 | VT_BYREF: - { - V_R8(com) = *V_R8REF(java); - break; - } - } - break; - } + case VT_R8 | VT_BYREF: + { + V_R8(com) = *V_R8REF(java); + break; + } + } + break; + } - case VT_R8 | VT_BYREF: - { - switch (java->vt) - { - case VT_R8: - { - *V_R8REF(com) = V_R8(java); - break; - } + case VT_R8 | VT_BYREF: + { + switch (java->vt) + { + case VT_R8: + { + *V_R8REF(com) = V_R8(java); + break; + } - case VT_R8 | VT_BYREF: - { - *V_R8REF(com) = *V_R8REF(java); - break; - } - } - break; - } + case VT_R8 | VT_BYREF: + { + *V_R8REF(com) = *V_R8REF(java); + break; + } + } + break; + } - case VT_I1: - { - switch (java->vt) - { - case VT_I1: - { - V_I1(com) = V_I1(java); - break; - } + case VT_I1: + { + switch (java->vt) + { + case VT_I1: + { + V_I1(com) = V_I1(java); + break; + } - case VT_I1 | VT_BYREF: - { - V_I1(com) = *V_I1REF(java); - break; - } - } - break; - } + case VT_I1 | VT_BYREF: + { + V_I1(com) = *V_I1REF(java); + break; + } + } + break; + } - case VT_I1 | VT_BYREF: - { - switch (java->vt) - { - case VT_I1: - { - *V_I1REF(com) = V_I1(java); - break; - } + case VT_I1 | VT_BYREF: + { + switch (java->vt) + { + case VT_I1: + { + *V_I1REF(com) = V_I1(java); + break; + } - case VT_I1 | VT_BYREF: - { - *V_I1REF(com) = *V_I1REF(java); - break; - } - } - break; - } + case VT_I1 | VT_BYREF: + { + *V_I1REF(com) = *V_I1REF(java); + break; + } + } + break; + } - case VT_UI2: - { - switch (java->vt) - { - case VT_UI2: - { - V_UI2(com) = V_UI2(java); - break; - } + case VT_UI2: + { + switch (java->vt) + { + case VT_UI2: + { + V_UI2(com) = V_UI2(java); + break; + } - case VT_UI2 | VT_BYREF: - { - V_UI2(com) = *V_UI2REF(java); - break; - } - } - break; - } + case VT_UI2 | VT_BYREF: + { + V_UI2(com) = *V_UI2REF(java); + break; + } + } + break; + } - case VT_UI2 | VT_BYREF: - { - switch (java->vt) - { - case VT_UI2: - { - *V_UI2REF(com) = V_UI2(java); - break; - } + case VT_UI2 | VT_BYREF: + { + switch (java->vt) + { + case VT_UI2: + { + *V_UI2REF(com) = V_UI2(java); + break; + } - case VT_UI2 | VT_BYREF: - { - *V_UI2REF(com) = *V_UI2REF(java); - break; - } - } - break; - } + case VT_UI2 | VT_BYREF: + { + *V_UI2REF(com) = *V_UI2REF(java); + break; + } + } + break; + } - case VT_UI4: - { - switch (java->vt) - { - case VT_UI4: - { - V_UI4(com) = V_UI4(java); - break; - } + case VT_UI4: + { + switch (java->vt) + { + case VT_UI4: + { + V_UI4(com) = V_UI4(java); + break; + } - case VT_UI4 | VT_BYREF: - { - V_UI4(com) = *V_UI4REF(java); - break; - } - } - break; - } + case VT_UI4 | VT_BYREF: + { + V_UI4(com) = *V_UI4REF(java); + break; + } + } + break; + } - case VT_UI4 | VT_BYREF: - { - switch (java->vt) - { - case VT_UI4: - { - *V_UI4REF(com) = V_UI4(java); - break; - } + case VT_UI4 | VT_BYREF: + { + switch (java->vt) + { + case VT_UI4: + { + *V_UI4REF(com) = V_UI4(java); + break; + } - case VT_UI4 | VT_BYREF: - { - *V_UI4REF(com) = *V_UI4REF(java); - break; - } - } - break; - } + case VT_UI4 | VT_BYREF: + { + *V_UI4REF(com) = *V_UI4REF(java); + break; + } + } + break; + } - case VT_INT: - { - switch (java->vt) - { - case VT_INT: - { - V_INT(com) = V_INT(java); - break; - } + case VT_INT: + { + switch (java->vt) + { + case VT_INT: + { + V_INT(com) = V_INT(java); + break; + } - case VT_INT | VT_BYREF: - { - V_INT(com) = *V_INTREF(java); - break; - } - } - break; - } + case VT_INT | VT_BYREF: + { + V_INT(com) = *V_INTREF(java); + break; + } + } + break; + } - case VT_INT | VT_BYREF: - { - switch (java->vt) - { - case VT_INT: - { - *V_INTREF(com) = V_INT(java); - break; - } + case VT_INT | VT_BYREF: + { + switch (java->vt) + { + case VT_INT: + { + *V_INTREF(com) = V_INT(java); + break; + } - case VT_INT | VT_BYREF: - { - *V_INTREF(com) = *V_INTREF(java); - break; - } - } - break; - } + case VT_INT | VT_BYREF: + { + *V_INTREF(com) = *V_INTREF(java); + break; + } + } + break; + } - case VT_UINT: - { - switch (java->vt) - { - case VT_UINT: - { - V_UINT(com) = V_UINT(java); - break; - } + case VT_UINT: + { + switch (java->vt) + { + case VT_UINT: + { + V_UINT(com) = V_UINT(java); + break; + } - case VT_UINT | VT_BYREF: - { - V_UINT(com) = *V_UINTREF(java); - break; - } - } - break; - } + case VT_UINT | VT_BYREF: + { + V_UINT(com) = *V_UINTREF(java); + break; + } + } + break; + } - case VT_UINT | VT_BYREF: - { - switch (java->vt) - { - case VT_UINT: - { - *V_UINTREF(com) = V_UINT(java); - break; - } + case VT_UINT | VT_BYREF: + { + switch (java->vt) + { + case VT_UINT: + { + *V_UINTREF(com) = V_UINT(java); + break; + } - case VT_UINT | VT_BYREF: - { - *V_UINTREF(com) = *V_UINTREF(java); - break; - } - } - break; - } + case VT_UINT | VT_BYREF: + { + *V_UINTREF(com) = *V_UINTREF(java); + break; + } + } + break; + } - case VT_CY: - { - switch (java->vt) - { - case VT_CY: - { - V_CY(com) = V_CY(java); - break; - } + case VT_CY: + { + switch (java->vt) + { + case VT_CY: + { + V_CY(com) = V_CY(java); + break; + } - case VT_CY | VT_BYREF: - { - V_CY(com) = *V_CYREF(java); - break; - } - } - break; - } + case VT_CY | VT_BYREF: + { + V_CY(com) = *V_CYREF(java); + break; + } + } + break; + } - case VT_CY | VT_BYREF: - { - switch (java->vt) - { - case VT_CY: - { - *V_CYREF(com) = V_CY(java); - break; - } + case VT_CY | VT_BYREF: + { + switch (java->vt) + { + case VT_CY: + { + *V_CYREF(com) = V_CY(java); + break; + } - case VT_CY | VT_BYREF: - { - *V_CYREF(com) = *V_CYREF(java); - break; - } - } - break; - } + case VT_CY | VT_BYREF: + { + *V_CYREF(com) = *V_CYREF(java); + break; + } + } + break; + } - case VT_DATE: - { - switch (java->vt) - { - case VT_DATE: - { - V_DATE(com) = V_DATE(java); - break; - } + case VT_DATE: + { + switch (java->vt) + { + case VT_DATE: + { + V_DATE(com) = V_DATE(java); + break; + } - case VT_DATE | VT_BYREF: - { - V_DATE(com) = *V_DATEREF(java); - break; - } - } - break; - } + case VT_DATE | VT_BYREF: + { + V_DATE(com) = *V_DATEREF(java); + break; + } + } + break; + } - case VT_DATE | VT_BYREF: - { - switch (java->vt) - { - case VT_DATE: - { - *V_DATEREF(com) = V_DATE(java); - break; - } + case VT_DATE | VT_BYREF: + { + switch (java->vt) + { + case VT_DATE: + { + *V_DATEREF(com) = V_DATE(java); + break; + } - case VT_DATE | VT_BYREF: - { - *V_DATEREF(com) = *V_DATEREF(java); - break; - } - } - break; - } + case VT_DATE | VT_BYREF: + { + *V_DATEREF(com) = *V_DATEREF(java); + break; + } + } + break; + } - case VT_BSTR: - { - switch (java->vt) - { - case VT_BSTR: - { - V_BSTR(com) = V_BSTR(java); - break; - } + case VT_BSTR: + { + switch (java->vt) + { + case VT_BSTR: + { + V_BSTR(com) = V_BSTR(java); + break; + } - case VT_BSTR | VT_BYREF: - { - V_BSTR(com) = *V_BSTRREF(java); - break; - } - } - break; - } + case VT_BSTR | VT_BYREF: + { + V_BSTR(com) = *V_BSTRREF(java); + break; + } + } + break; + } - case VT_BSTR | VT_BYREF: - { - switch (java->vt) - { - case VT_BSTR: - { - *V_BSTRREF(com) = V_BSTR(java); - break; - } + case VT_BSTR | VT_BYREF: + { + switch (java->vt) + { + case VT_BSTR: + { + *V_BSTRREF(com) = V_BSTR(java); + break; + } - case VT_BSTR | VT_BYREF: - { - *V_BSTRREF(com) = *V_BSTRREF(java); - break; - } - } - break; - } + case VT_BSTR | VT_BYREF: + { + *V_BSTRREF(com) = *V_BSTRREF(java); + break; + } + } + break; + } - case VT_DECIMAL: - { - switch (java->vt) - { - case VT_DECIMAL: - { - V_DECIMAL(com) = V_DECIMAL(java); - break; - } + case VT_DECIMAL: + { + switch (java->vt) + { + case VT_DECIMAL: + { + V_DECIMAL(com) = V_DECIMAL(java); + break; + } - case VT_DECIMAL | VT_BYREF: - { - V_DECIMAL(com) = *V_DECIMALREF(java); - break; - } - } - break; - } + case VT_DECIMAL | VT_BYREF: + { + V_DECIMAL(com) = *V_DECIMALREF(java); + break; + } + } + break; + } - case VT_DECIMAL | VT_BYREF: - { - switch (java->vt) - { - case VT_DECIMAL: - { - *V_DECIMALREF(com) = V_DECIMAL(java); - break; - } + case VT_DECIMAL | VT_BYREF: + { + switch (java->vt) + { + case VT_DECIMAL: + { + *V_DECIMALREF(com) = V_DECIMAL(java); + break; + } - case VT_DECIMAL | VT_BYREF: - { - *V_DECIMALREF(com) = *V_DECIMALREF(java); - break; - } - } - break; - } + case VT_DECIMAL | VT_BYREF: + { + *V_DECIMALREF(com) = *V_DECIMALREF(java); + break; + } + } + break; + } } diff --git a/src/main/cpp/SafeArray.cpp b/src/main/cpp/SafeArray.cpp index f6f74f6..656605b 100644 --- a/src/main/cpp/SafeArray.cpp +++ b/src/main/cpp/SafeArray.cpp @@ -1877,7 +1877,7 @@ JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setString__ILjava_lang_Strin env->ReleaseStringChars(s, str); VariantClear(&v); } else if (vt == VT_BSTR) { - // SF 2847577 support unicode move from GetStringUTFChars() to GetStringChars() + // SF 2847577 support unicode move from GetStringUTFChars() to GetStringChars() const jchar *str = env->GetStringChars(s, NULL); CComBSTR bs((LPCOLESTR)str); SafeArrayPutElement(sa,&idx,bs.Detach()); @@ -2623,12 +2623,12 @@ JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setVariants } /* PLEASE NOTE THE LINE: - jint *jIndices = env->GetIntArrayElements(indices, NULL); - which I added to replace "long idx[2] = {i,j};" from the 2D case. - Not sure if this is correct. Also, check that I am doing the null test and - dimension test correctly. - Would really like to call env->ReleaseIntArrayElements(indices, jIndices, NULL); - in here but I can't get it to work + jint *jIndices = env->GetIntArrayElements(indices, NULL); + which I added to replace "long idx[2] = {i,j};" from the 2D case. + Not sure if this is correct. Also, check that I am doing the null test and + dimension test correctly. + Would really like to call env->ReleaseIntArrayElements(indices, jIndices, NULL); + in here but I can't get it to work */ #define GETNDCODE(varType, varAccess, jtyp) \ @@ -2669,12 +2669,12 @@ JNIEXPORT void JNICALL Java_com_jacob_com_SafeArray_setVariants //--------------------------------- /* PLEASE NOTE THE LINE: - jint *jIndices = env->GetIntArrayElements(indices, NULL); - which I added to replace "long idx[2] = {i,j};" from the 2D case. - Not sure if this is correct. Also, check that I am doing the null test and - dimension test correctly. - Would really like to call env->ReleaseIntArrayElements(indices, jIndices, NULL); - in here but I can't get it to work + jint *jIndices = env->GetIntArrayElements(indices, NULL); + which I added to replace "long idx[2] = {i,j};" from the 2D case. + Not sure if this is correct. Also, check that I am doing the null test and + dimension test correctly. + Would really like to call env->ReleaseIntArrayElements(indices, jIndices, NULL); + in here but I can't get it to work */ #define SETNDCODE(varType, varAccess) \ diff --git a/src/main/cpp/Variant.cpp b/src/main/cpp/Variant.cpp index ab118ad..8e83283 100644 --- a/src/main/cpp/Variant.cpp +++ b/src/main/cpp/Variant.cpp @@ -116,26 +116,26 @@ void zeroVariant(JNIEnv *env, jobject _this) JNIEXPORT jbyteArray JNICALL Java_com_jacob_com_Variant_SerializationWriteToBytes (JNIEnv *env, jobject _this){ VARIANT *v = extractVariant(env, _this); - if (v) - { - DWORD flags = MSHCTX_LOCAL; - jint size = VARIANT_UserSize(&flags, 0L, v); - // allocate a byte array of the right length - jbyte* pBuf = new jbyte[size]; - // clear it out - ZeroMemory(pBuf, size); - // marshall the Variant into the buffer - VARIANT_UserMarshal(&flags, (unsigned char *)pBuf, v); - // need to convert the buffer to a java byte ba[] - jbyteArray ba = env->NewByteArray(size); - env->SetByteArrayRegion(ba, 0, size, pBuf); - // and delete the original memory - delete [] pBuf; - return ba; - } else { - jbyteArray ba = env->NewByteArray(0); - return ba; - } + if (v) + { + DWORD flags = MSHCTX_LOCAL; + jint size = VARIANT_UserSize(&flags, 0L, v); + // allocate a byte array of the right length + jbyte* pBuf = new jbyte[size]; + // clear it out + ZeroMemory(pBuf, size); + // marshall the Variant into the buffer + VARIANT_UserMarshal(&flags, (unsigned char *)pBuf, v); + // need to convert the buffer to a java byte ba[] + jbyteArray ba = env->NewByteArray(size); + env->SetByteArrayRegion(ba, 0, size, pBuf); + // and delete the original memory + delete [] pBuf; + return ba; + } else { + jbyteArray ba = env->NewByteArray(0); + return ba; + } } /** @@ -148,17 +148,17 @@ JNIEXPORT void JNICALL Java_com_jacob_com_Variant_SerializationReadFromBytes (JNIEnv *env, jobject _this, jbyteArray ba){ VARIANT *v = extractVariant(env, _this); - if (v){ - // get a buffer from it - jbyte *pBuf = env->GetByteArrayElements(ba, 0); - // unmarshall the Variant from the buffer - DWORD flags = MSHCTX_LOCAL; - printf("about to unmarshall array elements\n"); - VARIANT_UserUnmarshal(&flags, (unsigned char *)pBuf, v); - // release the byte array - printf("about to release array elements\n"); - env->ReleaseByteArrayElements(ba, pBuf, 0); - } + if (v){ + // get a buffer from it + jbyte *pBuf = env->GetByteArrayElements(ba, 0); + // unmarshall the Variant from the buffer + DWORD flags = MSHCTX_LOCAL; + printf("about to unmarshall array elements\n"); + VARIANT_UserUnmarshal(&flags, (unsigned char *)pBuf, v); + // release the byte array + printf("about to release array elements\n"); + env->ReleaseByteArrayElements(ba, pBuf, 0); + } } /** @@ -272,13 +272,13 @@ JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantStringRef if (v) { VariantClear(v); // whatever was there before - const jchar *cStr = env->GetStringChars(s,NULL); - // SF 1314116 - // DBeck: 2005-09-23: changed CComBSTR c-tor to accept - // Unicode string (no terminating NULL) provided by GetStringChars - const jsize numChars = env->GetStringLength(s); + const jchar *cStr = env->GetStringChars(s,NULL); + // SF 1314116 + // DBeck: 2005-09-23: changed CComBSTR c-tor to accept + // Unicode string (no terminating NULL) provided by GetStringChars + const jsize numChars = env->GetStringLength(s); //CComBSTR bs(cStr); - CComBSTR bs( numChars, (LPCOLESTR)cStr ); // SR cast SF 1689061 + CComBSTR bs( numChars, (LPCOLESTR)cStr ); // SR cast SF 1689061 BSTR *pbs = (BSTR *)CoTaskMemAlloc(sizeof(BSTR)); bs.CopyTo(pbs); @@ -802,11 +802,11 @@ JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantString const jchar *cStr = env->GetStringChars(s,NULL); // SF 1314116 - // DBeck: 2005-09-23: changed CComBSTR c-tor to accept - // Unicode string (no terminating NULL) provided by GetStringChars - const jsize numChars = env->GetStringLength(s); + // DBeck: 2005-09-23: changed CComBSTR c-tor to accept + // Unicode string (no terminating NULL) provided by GetStringChars + const jsize numChars = env->GetStringLength(s); //CComBSTR bs(cStr); - CComBSTR bs( numChars, (LPCOLESTR)cStr ); // SR cast SF 1689061 + CComBSTR bs( numChars, (LPCOLESTR)cStr ); // SR cast SF 1689061 V_VT(v) = VT_BSTR; V_BSTR(v) = bs.Copy(); @@ -975,7 +975,7 @@ JNIEXPORT void JNICALL Java_com_jacob_com_Variant_putVariantNoParam { VARIANT *v = extractVariant(env, _this); if (v) { - // SF 3377279 clear variable to fix leak + // SF 3377279 clear variable to fix leak VariantClear(v); V_VT(v) = VT_ERROR; V_ERROR(v) = DISP_E_PARAMNOTFOUND; @@ -1041,7 +1041,7 @@ JNIEXPORT jshort JNICALL Java_com_jacob_com_Variant_getVariantType /** * this is a big cover method that returns TRUE if * the variant type is - * VT_EMPTY, VT_NULL, VT_ERROR or VT_DISPATCH with no dispatch object + * VT_EMPTY, VT_NULL, VT_ERROR or VT_DISPATCH with no dispatch object * */ JNIEXPORT jboolean JNICALL Java_com_jacob_com_Variant_isVariantConsideredNull (JNIEnv *env, jobject _this) @@ -1110,14 +1110,14 @@ JNIEXPORT jlong JNICALL Java_com_jacob_com_Variant_getVariantVariant return NULL; } - VARIANT *refVar = V_VARIANTREF(v); + VARIANT *refVar = V_VARIANTREF(v); - // we could have made a copy of refV here but we aren't every going to free - // it outside of the scope of the enclosing context so we will just used the - // enclosed. This relies on the java layer to zero out its ref to this - // enclosed variant before the gc can come along and free the memory out from - // under this enclosing variant. - return (jlong)refVar; + // we could have made a copy of refV here but we aren't every going to free + // it outside of the scope of the enclosing context so we will just used the + // enclosed. This relies on the java layer to zero out its ref to this + // enclosed variant before the gc can come along and free the memory out from + // under this enclosing variant. + return (jlong)refVar; } return NULL; @@ -1136,9 +1136,9 @@ JNIEXPORT jlong JNICALL Java_com_jacob_com_Variant_getVariantVariant DECIMAL *pd = (DECIMAL *)CoTaskMemAlloc(sizeof(DECIMAL)); pd->scale = scale; if (signum == 1 || signum == 0){ - pd->sign = 0; + pd->sign = 0; } else { - pd->sign = 0x80; + pd->sign = 0x80; } pd->Hi32 = hi; pd->Mid32 = mid; @@ -1163,9 +1163,9 @@ JNIEXPORT jlong JNICALL Java_com_jacob_com_Variant_getVariantVariant d = (DECIMAL*)v; d->scale = scale; if (signum == 1 || signum == 0){ - d->sign = 0; + d->sign = 0; } else { - d->sign = 0x80; + d->sign = 0x80; } d->Hi32 = hi; d->Mid32 = mid; diff --git a/src/main/cpp/util.cpp b/src/main/cpp/util.cpp index 3ef1e5c..0e52886 100644 --- a/src/main/cpp/util.cpp +++ b/src/main/cpp/util.cpp @@ -37,7 +37,7 @@ void ThrowComFail(JNIEnv *env, const char* desc, jint hr) jmethodID failCons = env->GetMethodID(failClass, "", "(ILjava/lang/String;)V"); if (!desc) { - desc = "Java/COM Error"; + desc = "Java/COM Error"; } jstring js = env->NewStringUTF(desc); jthrowable fail = (jthrowable)env->NewObject(failClass, failCons, hr, js); @@ -47,7 +47,7 @@ void ThrowComFail(JNIEnv *env, const char* desc, jint hr) void ThrowComFailUnicode(JNIEnv *env, const wchar_t* desc, jint hr) { if (!desc) { - ThrowComFail(env, "Java/COM Error", hr); + ThrowComFail(env, "Java/COM Error", hr); } jclass failClass = env->FindClass("com/jacob/com/ComFailException"); // call the constructor that takes hr and message @@ -67,9 +67,9 @@ int CheckEnv(JNIEnv *env1, JNIEnv *env2) jmethodID failCons = env1->GetMethodID(failClass, "", "()V"); env1->ThrowNew(failClass, "Wrong Thread"); - return 0; + return 0; } - return 1; + return 1; } } diff --git a/src/main/headers/Dispatch.h b/src/main/headers/Dispatch.h index 6e4e731..8137b46 100644 --- a/src/main/headers/Dispatch.h +++ b/src/main/headers/Dispatch.h @@ -87,7 +87,7 @@ JNIEXPORT jobject JNICALL Java_com_jacob_com_Dispatch_invokev * Signature: (Ljava/lang/Object;I;)I */ JNIEXPORT jint JNICALL Java_com_jacob_com_Dispatch_hasExited - (JNIEnv *, jclass, jobject, jint, jint); + (JNIEnv *, jclass, jobject, jint, jint); #ifdef __cplusplus } diff --git a/src/main/headers/EventProxy.h b/src/main/headers/EventProxy.h index 060cd24..79f22e9 100644 --- a/src/main/headers/EventProxy.h +++ b/src/main/headers/EventProxy.h @@ -37,13 +37,13 @@ class EventProxy : public IDispatch { private: int connected; - LONG m_cRef; // a reference counter + LONG m_cRef; // a reference counter CComPtr pCP; // the connection point DWORD dwEventCookie; // connection point cookie jobject javaSinkObj; // the java object to delegate calls IID eventIID; // the interface iid passed in - int MethNum; // number of methods in the callback interface + int MethNum; // number of methods in the callback interface CComBSTR *MethName; // Array of method names DISPID *MethID; // Array of method ids, used to match invokations to method names JavaVM *jvm; // The java vm we are running @@ -53,7 +53,7 @@ public: // constuct with a global JNI ref to a sink object // to which we will delegate event callbacks EventProxy(JNIEnv *jenv, - jobject aSinkObj, + jobject aSinkObj, CComPtr pConn, IID eventIID, CComBSTR *mName, @@ -72,7 +72,7 @@ public: { LONG res = InterlockedDecrement(&m_cRef); if (res == 0) { - delete this; + delete this; } return res; diff --git a/src/main/headers/atlalloc.h b/src/main/headers/atlalloc.h index 133109a..6a08d83 100644 --- a/src/main/headers/atlalloc.h +++ b/src/main/headers/atlalloc.h @@ -22,16 +22,16 @@ namespace ATL { /* -This is more than a little unsatisfying. /Wp64 warns when we convert a size_t to an int -because it knows such a conversion won't port. -But, when we have overloaded templates, there may well exist both conversions and we need -to fool the warning into not firing on 32 bit builds +This is more than a little unsatisfying. /Wp64 warns when we convert a size_t to an int +because it knows such a conversion won't port. +But, when we have overloaded templates, there may well exist both conversions and we need +to fool the warning into not firing on 32 bit builds */ #if !defined(_ATL_W64) -#if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) -#define _ATL_W64 __w64 +#if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) +#define _ATL_W64 __w64 #else -#define _ATL_W64 +#define _ATL_W64 #endif #endif @@ -46,203 +46,203 @@ template<> class AtlLimits { public: - static const int _Min=INT_MIN; - static const int _Max=INT_MAX; + static const int _Min=INT_MIN; + static const int _Max=INT_MAX; }; template<> class AtlLimits { public: - static const unsigned int _Min=0; - static const unsigned int _Max=UINT_MAX; + static const unsigned int _Min=0; + static const unsigned int _Max=UINT_MAX; }; template<> class AtlLimits { public: - static const long _Min=LONG_MIN; - static const long _Max=LONG_MAX; + static const long _Min=LONG_MIN; + static const long _Max=LONG_MAX; }; template<> class AtlLimits { public: - static const unsigned long _Min=0; - static const unsigned long _Max=ULONG_MAX; + static const unsigned long _Min=0; + static const unsigned long _Max=ULONG_MAX; }; template<> class AtlLimits { public: - static const long long _Min=LLONG_MIN; - static const long long _Max=LLONG_MAX; + static const long long _Min=LLONG_MIN; + static const long long _Max=LLONG_MAX; }; template<> class AtlLimits { public: - static const unsigned long long _Min=0; - static const unsigned long long _Max=ULLONG_MAX; + static const unsigned long long _Min=0; + static const unsigned long long _Max=ULLONG_MAX; }; /* generic version */ template inline HRESULT AtlAdd( - _Out_ T* ptResult, - _In_ T tLeft, - _In_ T tRight) + _Out_ T* ptResult, + _In_ T tLeft, + _In_ T tRight) { - if(::ATL::AtlLimits::_Max-tLeft < tRight) - { - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - } - *ptResult= tLeft + tRight; - return S_OK; + if(::ATL::AtlLimits::_Max-tLeft < tRight) + { + return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); + } + *ptResult= tLeft + tRight; + return S_OK; } /* generic but compariatively slow version */ template inline HRESULT AtlMultiply( - _Out_ T* ptResult, - _In_ T tLeft, - _In_ T tRight) + _Out_ T* ptResult, + _In_ T tLeft, + _In_ T tRight) { - /* avoid divide 0 */ - if(tLeft==0) - { - *ptResult=0; - return S_OK; - } - if(::ATL::AtlLimits::_Max/tLeft < tRight) - { - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - } - *ptResult= tLeft * tRight; - return S_OK; + /* avoid divide 0 */ + if(tLeft==0) + { + *ptResult=0; + return S_OK; + } + if(::ATL::AtlLimits::_Max/tLeft < tRight) + { + return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); + } + *ptResult= tLeft * tRight; + return S_OK; } -/* fast version for 32 bit integers */ +/* fast version for 32 bit integers */ template<> inline HRESULT AtlMultiply( - _Out_ int _ATL_W64 *piResult, - _In_ int _ATL_W64 iLeft, - _In_ int _ATL_W64 iRight) + _Out_ int _ATL_W64 *piResult, + _In_ int _ATL_W64 iLeft, + _In_ int _ATL_W64 iRight) { - __int64 i64Result=static_cast<__int64>(iLeft) * static_cast<__int64>(iRight); - if(i64Result>INT_MAX || i64Result < INT_MIN) - { - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - } - *piResult=static_cast(i64Result); - return S_OK; + __int64 i64Result=static_cast<__int64>(iLeft) * static_cast<__int64>(iRight); + if(i64Result>INT_MAX || i64Result < INT_MIN) + { + return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); + } + *piResult=static_cast(i64Result); + return S_OK; } template<> inline HRESULT AtlMultiply( - _Out_ unsigned int _ATL_W64 *piResult, - _In_ unsigned int _ATL_W64 iLeft, - _In_ unsigned int _ATL_W64 iRight) + _Out_ unsigned int _ATL_W64 *piResult, + _In_ unsigned int _ATL_W64 iLeft, + _In_ unsigned int _ATL_W64 iRight) { - unsigned __int64 i64Result=static_cast(iLeft) * static_cast(iRight); - if(i64Result>UINT_MAX) - { - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - } - *piResult=static_cast(i64Result); - return S_OK; + unsigned __int64 i64Result=static_cast(iLeft) * static_cast(iRight); + if(i64Result>UINT_MAX) + { + return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); + } + *piResult=static_cast(i64Result); + return S_OK; } template<> inline HRESULT AtlMultiply( - _Out_ long _ATL_W64 *piResult, - _In_ long _ATL_W64 iLeft, - _In_ long _ATL_W64 iRight) + _Out_ long _ATL_W64 *piResult, + _In_ long _ATL_W64 iLeft, + _In_ long _ATL_W64 iRight) { - __int64 i64Result=static_cast<__int64>(iLeft) * static_cast<__int64>(iRight); - if(i64Result>LONG_MAX || i64Result < LONG_MIN) - { - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - } - *piResult=static_cast(i64Result); - return S_OK; + __int64 i64Result=static_cast<__int64>(iLeft) * static_cast<__int64>(iRight); + if(i64Result>LONG_MAX || i64Result < LONG_MIN) + { + return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); + } + *piResult=static_cast(i64Result); + return S_OK; } template<> inline HRESULT AtlMultiply( - _Out_ unsigned long _ATL_W64 *piResult, - _In_ unsigned long _ATL_W64 iLeft, - _In_ unsigned long _ATL_W64 iRight) + _Out_ unsigned long _ATL_W64 *piResult, + _In_ unsigned long _ATL_W64 iLeft, + _In_ unsigned long _ATL_W64 iRight) { - unsigned __int64 i64Result=static_cast(iLeft) * static_cast(iRight); - if(i64Result>ULONG_MAX) - { - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - } - *piResult=static_cast(i64Result); - return S_OK; + unsigned __int64 i64Result=static_cast(iLeft) * static_cast(iRight); + if(i64Result>ULONG_MAX) + { + return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); + } + *piResult=static_cast(i64Result); + return S_OK; } template inline T AtlMultiplyThrow( - _In_ T tLeft, - _In_ T tRight) + _In_ T tLeft, + _In_ T tRight) { - T tResult; - HRESULT hr=AtlMultiply(&tResult, tLeft, tRight); - if(FAILED(hr)) - { - AtlThrow(hr); - } - return tResult; + T tResult; + HRESULT hr=AtlMultiply(&tResult, tLeft, tRight); + if(FAILED(hr)) + { + AtlThrow(hr); + } + return tResult; } template inline T AtlAddThrow( - _In_ T tLeft, - _In_ T tRight) + _In_ T tLeft, + _In_ T tRight) { - T tResult; - HRESULT hr=AtlAdd(&tResult, tLeft, tRight); - if(FAILED(hr)) - { - AtlThrow(hr); - } - return tResult; + T tResult; + HRESULT hr=AtlAdd(&tResult, tLeft, tRight); + if(FAILED(hr)) + { + AtlThrow(hr); + } + return tResult; } _Ret_opt_bytecount_x_(nCount * nSize) inline LPVOID AtlCoTaskMemCAlloc( - _In_ ULONG nCount, - _In_ ULONG nSize) + _In_ ULONG nCount, + _In_ ULONG nSize) { - HRESULT hr; - ULONG nBytes=0; - if( FAILED(hr=::ATL::AtlMultiply(&nBytes, nCount, nSize))) - { - return NULL; - } - return ::CoTaskMemAlloc(nBytes); + HRESULT hr; + ULONG nBytes=0; + if( FAILED(hr=::ATL::AtlMultiply(&nBytes, nCount, nSize))) + { + return NULL; + } + return ::CoTaskMemAlloc(nBytes); } _Ret_opt_bytecount_x_(nCount * nSize) inline LPVOID AtlCoTaskMemRecalloc( - _In_opt_ void *pvMemory, - _In_ ULONG nCount, - _In_ ULONG nSize) + _In_opt_ void *pvMemory, + _In_ ULONG nCount, + _In_ ULONG nSize) { - HRESULT hr; - ULONG nBytes=0; - if( FAILED(hr=::ATL::AtlMultiply(&nBytes, nCount, nSize))) - { - return NULL; - } - return ::CoTaskMemRealloc(pvMemory, nBytes); + HRESULT hr; + ULONG nBytes=0; + if( FAILED(hr=::ATL::AtlMultiply(&nBytes, nCount, nSize))) + { + return NULL; + } + return ::CoTaskMemRealloc(pvMemory, nBytes); } -} // namespace ATL +} // namespace ATL #pragma pack(pop) #pragma pack(push,8) @@ -253,10 +253,10 @@ namespace ATL namespace Checked { void __cdecl memcpy_s( - _Out_bytecap_post_bytecount_(_S1max,_N) void *s1, - _In_ size_t _S1max, - _In_bytecount_(_N) const void *s2, - _In_ size_t _N); + _Out_bytecap_post_bytecount_(_S1max,_N) void *s1, + _In_ size_t _S1max, + _In_bytecount_(_N) const void *s2, + _In_ size_t _N); } ///////////////////////////////////////////////////////////////////////////// @@ -265,339 +265,339 @@ namespace Checked class CCRTAllocator { public: - _Ret_opt_bytecap_(nBytes) static void* Reallocate( - _In_ void* p, - _In_ size_t nBytes) throw() - { - return nb_realloc(p, nBytes); - } + _Ret_opt_bytecap_(nBytes) static void* Reallocate( + _In_ void* p, + _In_ size_t nBytes) throw() + { + return nb_realloc(p, nBytes); + } - _Ret_opt_bytecap_(nBytes) static void* Allocate(_In_ size_t nBytes) throw() - { - return nb_malloc(nBytes); - } + _Ret_opt_bytecap_(nBytes) static void* Allocate(_In_ size_t nBytes) throw() + { + return nb_malloc(nBytes); + } - static void Free(_In_ void* p) throw() - { - nb_free(p); - } + static void Free(_In_ void* p) throw() + { + nb_free(p); + } }; class CLocalAllocator { public: - _Ret_opt_bytecap_(nBytes) static void* Allocate(_In_ size_t nBytes) throw() - { - return ::LocalAlloc(LMEM_FIXED, nBytes); - } - _Ret_opt_bytecap_(nBytes) static void* Reallocate( - _In_ void* p, - _In_ size_t nBytes) throw() - { - if (p==NULL){ - return ( Allocate(nBytes) ); + _Ret_opt_bytecap_(nBytes) static void* Allocate(_In_ size_t nBytes) throw() + { + return ::LocalAlloc(LMEM_FIXED, nBytes); + } + _Ret_opt_bytecap_(nBytes) static void* Reallocate( + _In_ void* p, + _In_ size_t nBytes) throw() + { + if (p==NULL){ + return ( Allocate(nBytes) ); - } - if (nBytes==0){ - Free(p); - return NULL; - } - return ::LocalReAlloc(p, nBytes, 0); - } - static void Free(_In_ void* p) throw() - { - ::LocalFree(p); - } + } + if (nBytes==0){ + Free(p); + return NULL; + } + return ::LocalReAlloc(p, nBytes, 0); + } + static void Free(_In_ void* p) throw() + { + ::LocalFree(p); + } }; class CGlobalAllocator { public: - _Ret_opt_bytecap_(nBytes) static void* Allocate(_In_ size_t nBytes) throw() - { - return ::GlobalAlloc(GMEM_FIXED, nBytes); - } - _Ret_opt_bytecap_(nBytes) static void* Reallocate( - _In_ void* p, - _In_ size_t nBytes) throw() - { - if (p==NULL){ - return ( Allocate(nBytes) ); + _Ret_opt_bytecap_(nBytes) static void* Allocate(_In_ size_t nBytes) throw() + { + return ::GlobalAlloc(GMEM_FIXED, nBytes); + } + _Ret_opt_bytecap_(nBytes) static void* Reallocate( + _In_ void* p, + _In_ size_t nBytes) throw() + { + if (p==NULL){ + return ( Allocate(nBytes) ); - } - if (nBytes==0){ - Free(p); - return NULL; - } - return ::GlobalReAlloc(p, nBytes, 0); - } - static void Free(_In_ void* p) throw() - { - ::GlobalFree(p); - } + } + if (nBytes==0){ + Free(p); + return NULL; + } + return ::GlobalReAlloc(p, nBytes, 0); + } + static void Free(_In_ void* p) throw() + { + ::GlobalFree(p); + } }; template class CHeapPtrBase { protected: - CHeapPtrBase() throw() : - m_pData(NULL) - { - } - CHeapPtrBase(_Inout_ CHeapPtrBase& p) throw() - { - m_pData = p.Detach(); // Transfer ownership - } - explicit CHeapPtrBase(_In_ T* pData) throw() : - m_pData(pData) - { - } + CHeapPtrBase() throw() : + m_pData(NULL) + { + } + CHeapPtrBase(_Inout_ CHeapPtrBase& p) throw() + { + m_pData = p.Detach(); // Transfer ownership + } + explicit CHeapPtrBase(_In_ T* pData) throw() : + m_pData(pData) + { + } public: - ~CHeapPtrBase() throw() - { - Free(); - } + ~CHeapPtrBase() throw() + { + Free(); + } protected: - CHeapPtrBase& operator=(_Inout_ CHeapPtrBase& p) throw() - { - if(m_pData != p.m_pData) - Attach(p.Detach()); // Transfer ownership - return *this; - } + CHeapPtrBase& operator=(_Inout_ CHeapPtrBase& p) throw() + { + if(m_pData != p.m_pData) + Attach(p.Detach()); // Transfer ownership + return *this; + } public: - operator T*() const throw() - { - return m_pData; - } + operator T*() const throw() + { + return m_pData; + } - T* operator->() const throw() - { - ATLASSERT(m_pData != NULL); - return m_pData; - } + T* operator->() const throw() + { + ATLASSERT(m_pData != NULL); + return m_pData; + } - T** operator&() throw() - { - ATLASSUME(m_pData == NULL); - return &m_pData; - } + T** operator&() throw() + { + ATLASSUME(m_pData == NULL); + return &m_pData; + } - // Allocate a buffer with the given number of bytes - bool AllocateBytes(_In_ size_t nBytes) throw() - { - ATLASSERT(m_pData == NULL); - m_pData = static_cast(Allocator::Allocate(nBytes)); - if (m_pData == NULL) - return false; + // Allocate a buffer with the given number of bytes + bool AllocateBytes(_In_ size_t nBytes) throw() + { + ATLASSERT(m_pData == NULL); + m_pData = static_cast(Allocator::Allocate(nBytes)); + if (m_pData == NULL) + return false; - return true; - } + return true; + } - // Attach to an existing pointer (takes ownership) - void Attach(_In_ T* pData) throw() - { - Allocator::Free(m_pData); - m_pData = pData; - } + // Attach to an existing pointer (takes ownership) + void Attach(_In_ T* pData) throw() + { + Allocator::Free(m_pData); + m_pData = pData; + } - // Detach the pointer (releases ownership) - T* Detach() throw() - { - T* pTemp = m_pData; - m_pData = NULL; - return pTemp; - } + // Detach the pointer (releases ownership) + T* Detach() throw() + { + T* pTemp = m_pData; + m_pData = NULL; + return pTemp; + } - // Free the memory pointed to, and set the pointer to NULL - void Free() throw() - { - Allocator::Free(m_pData); - m_pData = NULL; - } + // Free the memory pointed to, and set the pointer to NULL + void Free() throw() + { + Allocator::Free(m_pData); + m_pData = NULL; + } - // Reallocate the buffer to hold a given number of bytes - bool ReallocateBytes(_In_ size_t nBytes) throw() - { - T* pNew; + // Reallocate the buffer to hold a given number of bytes + bool ReallocateBytes(_In_ size_t nBytes) throw() + { + T* pNew; - pNew = static_cast(Allocator::Reallocate(m_pData, nBytes)); - if (pNew == NULL) - return false; - m_pData = pNew; + pNew = static_cast(Allocator::Reallocate(m_pData, nBytes)); + if (pNew == NULL) + return false; + m_pData = pNew; - return true; - } + return true; + } public: - T* m_pData; + T* m_pData; }; template class CHeapPtr : - public CHeapPtrBase + public CHeapPtrBase { public: - CHeapPtr() throw() - { - } - CHeapPtr(_Inout_ CHeapPtr& p) throw() : - CHeapPtrBase(p) - { - } - explicit CHeapPtr(_In_ T* p) throw() : - CHeapPtrBase(p) - { - } + CHeapPtr() throw() + { + } + CHeapPtr(_Inout_ CHeapPtr& p) throw() : + CHeapPtrBase(p) + { + } + explicit CHeapPtr(_In_ T* p) throw() : + CHeapPtrBase(p) + { + } - CHeapPtr& operator=(_Inout_ CHeapPtr& p) throw() - { - CHeapPtrBase::operator=(p); + CHeapPtr& operator=(_Inout_ CHeapPtr& p) throw() + { + CHeapPtrBase::operator=(p); - return *this; - } + return *this; + } - // Allocate a buffer with the given number of elements - bool Allocate(_In_ size_t nElements = 1) throw() - { - size_t nBytes=0; - if(FAILED(::ATL::AtlMultiply(&nBytes, nElements, sizeof(T)))) - { - return false; - } - return this->AllocateBytes(nBytes); - } + // Allocate a buffer with the given number of elements + bool Allocate(_In_ size_t nElements = 1) throw() + { + size_t nBytes=0; + if(FAILED(::ATL::AtlMultiply(&nBytes, nElements, sizeof(T)))) + { + return false; + } + return this->AllocateBytes(nBytes); + } - // Reallocate the buffer to hold a given number of elements - bool Reallocate(_In_ size_t nElements) throw() - { - size_t nBytes=0; - if(FAILED(::ATL::AtlMultiply(&nBytes, nElements, sizeof(T)))) - { - return false; - } - return this->ReallocateBytes(nBytes); - } + // Reallocate the buffer to hold a given number of elements + bool Reallocate(_In_ size_t nElements) throw() + { + size_t nBytes=0; + if(FAILED(::ATL::AtlMultiply(&nBytes, nElements, sizeof(T)))) + { + return false; + } + return this->ReallocateBytes(nBytes); + } }; template< typename T, int t_nFixedBytes = 128, class Allocator = CCRTAllocator > class CTempBuffer { public: - CTempBuffer() throw() : - m_p( NULL ) - { - } - CTempBuffer(_In_ size_t nElements) throw() : - m_p( NULL ) - { - Allocate( nElements ); - } + CTempBuffer() throw() : + m_p( NULL ) + { + } + CTempBuffer(_In_ size_t nElements) throw() : + m_p( NULL ) + { + Allocate( nElements ); + } - ~CTempBuffer() throw() - { - if( m_p != reinterpret_cast< T* >( m_abFixedBuffer ) ) - { - FreeHeap(); - } - } + ~CTempBuffer() throw() + { + if( m_p != reinterpret_cast< T* >( m_abFixedBuffer ) ) + { + FreeHeap(); + } + } - operator T*() const throw() - { - return( m_p ); - } - T* operator->() const throw() - { - ATLASSERT( m_p != NULL ); - return( m_p ); - } + operator T*() const throw() + { + return( m_p ); + } + T* operator->() const throw() + { + ATLASSERT( m_p != NULL ); + return( m_p ); + } - _Ret_opt_bytecap_x_(nElements * sizeof(T)) T* Allocate(_In_ size_t nElements) throw() - { - return( this->AllocateBytes( ::ATL::AtlMultiplyThrow(nElements,sizeof( T )) ) ); - } + _Ret_opt_bytecap_x_(nElements * sizeof(T)) T* Allocate(_In_ size_t nElements) throw() + { + return( this->AllocateBytes( ::ATL::AtlMultiplyThrow(nElements,sizeof( T )) ) ); + } - _Ret_opt_bytecap_x_(nElements * sizeof(T)) T* Reallocate(_In_ size_t nElements) throw() - { - ATLENSURE(nElements < size_t(-1)/sizeof(T) ); - size_t nNewSize = nElements*sizeof( T ) ; + _Ret_opt_bytecap_x_(nElements * sizeof(T)) T* Reallocate(_In_ size_t nElements) throw() + { + ATLENSURE(nElements < size_t(-1)/sizeof(T) ); + size_t nNewSize = nElements*sizeof( T ) ; - if (m_p == NULL) - return this->AllocateBytes(nNewSize); + if (m_p == NULL) + return this->AllocateBytes(nNewSize); - if (nNewSize > t_nFixedBytes) - { - if( m_p == reinterpret_cast< T* >( m_abFixedBuffer ) ) - { - // We have to allocate from the heap and copy the contents into the new buffer - AllocateHeap(nNewSize); - Checked::memcpy_s(m_p, nNewSize, m_abFixedBuffer, t_nFixedBytes); - } - else - { - ReAllocateHeap( nNewSize ); - } - } - else - { - if (m_p != reinterpret_cast< T* >( m_abFixedBuffer )) - { - Checked::memcpy_s(m_abFixedBuffer, t_nFixedBytes, m_p, nNewSize); - FreeHeap(); - } - m_p = reinterpret_cast< T* >( m_abFixedBuffer ); - } + if (nNewSize > t_nFixedBytes) + { + if( m_p == reinterpret_cast< T* >( m_abFixedBuffer ) ) + { + // We have to allocate from the heap and copy the contents into the new buffer + AllocateHeap(nNewSize); + Checked::memcpy_s(m_p, nNewSize, m_abFixedBuffer, t_nFixedBytes); + } + else + { + ReAllocateHeap( nNewSize ); + } + } + else + { + if (m_p != reinterpret_cast< T* >( m_abFixedBuffer )) + { + Checked::memcpy_s(m_abFixedBuffer, t_nFixedBytes, m_p, nNewSize); + FreeHeap(); + } + m_p = reinterpret_cast< T* >( m_abFixedBuffer ); + } - return m_p; - } + return m_p; + } - _Ret_opt_bytecap_(nBytes) T* AllocateBytes(_In_ size_t nBytes) - { - ATLASSERT( m_p == NULL ); - if( nBytes > t_nFixedBytes ) - { - AllocateHeap( nBytes ); - } - else - { - m_p = reinterpret_cast< T* >( m_abFixedBuffer ); - } + _Ret_opt_bytecap_(nBytes) T* AllocateBytes(_In_ size_t nBytes) + { + ATLASSERT( m_p == NULL ); + if( nBytes > t_nFixedBytes ) + { + AllocateHeap( nBytes ); + } + else + { + m_p = reinterpret_cast< T* >( m_abFixedBuffer ); + } - return( m_p ); - } + return( m_p ); + } private: - void AllocateHeap(_In_ size_t nBytes) - { - T* p = static_cast< T* >( Allocator::Allocate( nBytes ) ); - if( p == NULL ) - { - AtlThrow( E_OUTOFMEMORY ); - } - m_p = p; - } + void AllocateHeap(_In_ size_t nBytes) + { + T* p = static_cast< T* >( Allocator::Allocate( nBytes ) ); + if( p == NULL ) + { + AtlThrow( E_OUTOFMEMORY ); + } + m_p = p; + } - void ReAllocateHeap(_In_ size_t nNewSize) - { - T* p = static_cast< T* >( Allocator::Reallocate(m_p, nNewSize) ); - if ( p == NULL ) - { - AtlThrow( E_OUTOFMEMORY ); - } - m_p = p; - } + void ReAllocateHeap(_In_ size_t nNewSize) + { + T* p = static_cast< T* >( Allocator::Reallocate(m_p, nNewSize) ); + if ( p == NULL ) + { + AtlThrow( E_OUTOFMEMORY ); + } + m_p = p; + } - void FreeHeap() throw() - { - Allocator::Free( m_p ); - } + void FreeHeap() throw() + { + Allocator::Free( m_p ); + } private: - T* m_p; - BYTE m_abFixedBuffer[t_nFixedBytes]; + T* m_p; + BYTE m_abFixedBuffer[t_nFixedBytes]; }; @@ -608,9 +608,9 @@ namespace _ATL_SAFE_ALLOCA_IMPL #ifndef _ATL_STACK_MARGIN #if defined(_M_IX86) -#define _ATL_STACK_MARGIN 0x2000 // Minimum stack available after call to _ATL_SAFE_ALLOCA +#define _ATL_STACK_MARGIN 0x2000 // Minimum stack available after call to _ATL_SAFE_ALLOCA #else //_M_AMD64 _M_IA64 -#define _ATL_STACK_MARGIN 0x4000 +#define _ATL_STACK_MARGIN 0x4000 #endif #endif //_ATL_STACK_MARGIN @@ -627,18 +627,18 @@ __declspec(noinline) inline bool _AtlVerifyStackAvailable(_In_ SIZE_T Size) try #endif { - SIZE_T size=0; - HRESULT hrAdd=::ATL::AtlAdd(&size, Size, static_cast(_ATL_STACK_MARGIN)); - if(FAILED(hrAdd)) - { - ATLASSERT(FALSE); - bStackAvailable = false; - } - else - { - PVOID p = _alloca(size); - (p); - } + SIZE_T size=0; + HRESULT hrAdd=::ATL::AtlAdd(&size, Size, static_cast(_ATL_STACK_MARGIN)); + if(FAILED(hrAdd)) + { + ATLASSERT(FALSE); + bStackAvailable = false; + } + else + { + PVOID p = _alloca(size); + (p); + } } #if !defined(__MINGW32__) __except ((EXCEPTION_STACK_OVERFLOW == GetExceptionCode()) ? @@ -664,57 +664,57 @@ template < class Allocator> class CAtlSafeAllocBufferManager { private : - struct CAtlSafeAllocBufferNode - { - CAtlSafeAllocBufferNode* m_pNext; + struct CAtlSafeAllocBufferNode + { + CAtlSafeAllocBufferNode* m_pNext; #if defined(_M_IX86) - BYTE _pad[4]; + BYTE _pad[4]; #elif defined(_M_IA64) - BYTE _pad[8]; + BYTE _pad[8]; #elif defined(_M_AMD64) - BYTE _pad[8]; + BYTE _pad[8]; #else - #error Only supported for X86, AMD64 and IA64 + #error Only supported for X86, AMD64 and IA64 #endif - void* GetData() - { - return (this + 1); - } - }; + void* GetData() + { + return (this + 1); + } + }; - CAtlSafeAllocBufferNode* m_pHead; + CAtlSafeAllocBufferNode* m_pHead; public : - CAtlSafeAllocBufferManager() : m_pHead(NULL) - { - } - _Ret_opt_bytecap_(nRequestedSize) void* Allocate(_In_ SIZE_T nRequestedSize) - { - CAtlSafeAllocBufferNode *p = (CAtlSafeAllocBufferNode*)Allocator::Allocate(::ATL::AtlAddThrow(nRequestedSize, static_cast(sizeof(CAtlSafeAllocBufferNode)))); - if (p == NULL) - return NULL; + CAtlSafeAllocBufferManager() : m_pHead(NULL) + { + } + _Ret_opt_bytecap_(nRequestedSize) void* Allocate(_In_ SIZE_T nRequestedSize) + { + CAtlSafeAllocBufferNode *p = (CAtlSafeAllocBufferNode*)Allocator::Allocate(::ATL::AtlAddThrow(nRequestedSize, static_cast(sizeof(CAtlSafeAllocBufferNode)))); + if (p == NULL) + return NULL; - // Add buffer to the list - p->m_pNext = m_pHead; - m_pHead = p; + // Add buffer to the list + p->m_pNext = m_pHead; + m_pHead = p; - return p->GetData(); - } - ~CAtlSafeAllocBufferManager() - { - // Walk the list and free the buffers - while (m_pHead != NULL) - { - CAtlSafeAllocBufferNode* p = m_pHead; - m_pHead = m_pHead->m_pNext; - Allocator::Free(p); - } - } + return p->GetData(); + } + ~CAtlSafeAllocBufferManager() + { + // Walk the list and free the buffers + while (m_pHead != NULL) + { + CAtlSafeAllocBufferNode* p = m_pHead; + m_pHead = m_pHead->m_pNext; + Allocator::Free(p); + } + } }; -} // namespace _ATL_SAFE_ALLOCA_IMPL +} // namespace _ATL_SAFE_ALLOCA_IMPL -} // namespace ATL +} // namespace ATL #pragma pack(pop) // Use one of the following macros before using _ATL_SAFE_ALLOCA @@ -722,7 +722,7 @@ public : #define USES_ATL_SAFE_ALLOCA_EX(x) ATL::_ATL_SAFE_ALLOCA_IMPL::CAtlSafeAllocBufferManager _AtlSafeAllocaManager #ifndef USES_ATL_SAFE_ALLOCA -#define USES_ATL_SAFE_ALLOCA USES_ATL_SAFE_ALLOCA_EX(ATL::CCRTAllocator) +#define USES_ATL_SAFE_ALLOCA USES_ATL_SAFE_ALLOCA_EX(ATL::CCRTAllocator) #endif // nRequestedSize - requested size in bytes @@ -733,35 +733,35 @@ public : // This available for testing purposes. It will help determine the max stack usage due to _alloca's // Disable _alloca not within try-except prefast warning since we verify stack space is available before. #ifdef _ATL_SAFE_ALLOCA_ALWAYS_ALLOCATE_THRESHOLD_SIZE -#define _ATL_SAFE_ALLOCA(nRequestedSize, nThreshold) \ - __pragma(warning(push))\ - __pragma(warning(disable:4616))\ - __pragma(warning(disable:6255))\ - ((nRequestedSize <= nThreshold && ATL::_ATL_SAFE_ALLOCA_IMPL::_AtlVerifyStackAvailable(nThreshold) ) ? \ - _alloca(nThreshold) : \ - ((ATL::_ATL_SAFE_ALLOCA_IMPL::_AtlVerifyStackAvailable(nThreshold)) ? _alloca(nThreshold) : 0), \ - _AtlSafeAllocaManager.Allocate(nRequestedSize))\ - __pragma(warning(pop)) +#define _ATL_SAFE_ALLOCA(nRequestedSize, nThreshold) \ + __pragma(warning(push))\ + __pragma(warning(disable:4616))\ + __pragma(warning(disable:6255))\ + ((nRequestedSize <= nThreshold && ATL::_ATL_SAFE_ALLOCA_IMPL::_AtlVerifyStackAvailable(nThreshold) ) ? \ + _alloca(nThreshold) : \ + ((ATL::_ATL_SAFE_ALLOCA_IMPL::_AtlVerifyStackAvailable(nThreshold)) ? _alloca(nThreshold) : 0), \ + _AtlSafeAllocaManager.Allocate(nRequestedSize))\ + __pragma(warning(pop)) #else #if !defined(__MINGW32__) -#define _ATL_SAFE_ALLOCA(nRequestedSize, nThreshold) \ - __pragma(warning(push))\ - __pragma(warning(disable:4616))\ - __pragma(warning(disable:6255))\ - ((nRequestedSize <= nThreshold && ATL::_ATL_SAFE_ALLOCA_IMPL::_AtlVerifyStackAvailable(nRequestedSize) ) ? \ - _alloca(nRequestedSize) : \ - _AtlSafeAllocaManager.Allocate(nRequestedSize))\ - __pragma(warning(pop)) +#define _ATL_SAFE_ALLOCA(nRequestedSize, nThreshold) \ + __pragma(warning(push))\ + __pragma(warning(disable:4616))\ + __pragma(warning(disable:6255))\ + ((nRequestedSize <= nThreshold && ATL::_ATL_SAFE_ALLOCA_IMPL::_AtlVerifyStackAvailable(nRequestedSize) ) ? \ + _alloca(nRequestedSize) : \ + _AtlSafeAllocaManager.Allocate(nRequestedSize))\ + __pragma(warning(pop)) #else -#define _ATL_SAFE_ALLOCA(nRequestedSize, nThreshold) \ - ((nRequestedSize <= nThreshold && ATL::_ATL_SAFE_ALLOCA_IMPL::_AtlVerifyStackAvailable(nRequestedSize) ) ? \ - _alloca(nRequestedSize) : \ - _AtlSafeAllocaManager.Allocate(nRequestedSize)) +#define _ATL_SAFE_ALLOCA(nRequestedSize, nThreshold) \ + ((nRequestedSize <= nThreshold && ATL::_ATL_SAFE_ALLOCA_IMPL::_AtlVerifyStackAvailable(nRequestedSize) ) ? \ + _alloca(nRequestedSize) : \ + _AtlSafeAllocaManager.Allocate(nRequestedSize)) #endif #endif // Use 1024 bytes as the default threshold in ATL #ifndef _ATL_SAFE_ALLOCA_DEF_THRESHOLD -#define _ATL_SAFE_ALLOCA_DEF_THRESHOLD 1024 +#define _ATL_SAFE_ALLOCA_DEF_THRESHOLD 1024 #endif diff --git a/src/main/headers/atlchecked.h b/src/main/headers/atlchecked.h index 3656462..6795683 100644 --- a/src/main/headers/atlchecked.h +++ b/src/main/headers/atlchecked.h @@ -29,23 +29,23 @@ namespace ATL inline errno_t AtlCrtErrorCheck(_In_ errno_t nError) { - switch(nError) - { - case ENOMEM: - AtlThrow(E_OUTOFMEMORY); - break; - case EINVAL: - case ERANGE: - AtlThrow(E_INVALIDARG); - break; - case 0: - case STRUNCATE: - break; - default: - AtlThrow(E_FAIL); - break; - } - return nError; + switch(nError) + { + case ENOMEM: + AtlThrow(E_OUTOFMEMORY); + break; + case EINVAL: + case ERANGE: + AtlThrow(E_INVALIDARG); + break; + case 0: + case STRUNCATE: + break; + default: + AtlThrow(E_FAIL); + break; + } + return nError; } ///////////////////////////////////////////////////////////////////////////// @@ -61,331 +61,331 @@ namespace Checked #endif inline void __cdecl memcpy_s( - _Out_bytecap_post_bytecount_(_S1max,_N) void *_S1, - _In_ size_t _S1max, - _In_bytecount_(_N) const void *_S2, - _In_ size_t _N) + _Out_bytecap_post_bytecount_(_S1max,_N) void *_S1, + _In_ size_t _S1max, + _In_bytecount_(_N) const void *_S2, + _In_ size_t _N) { - ATLMFC_CRT_ERRORCHECK(::memcpy_s(_S1, _S1max, _S2, _N)); + ATLMFC_CRT_ERRORCHECK(::memcpy_s(_S1, _S1max, _S2, _N)); } inline void __cdecl wmemcpy_s( - _Out_cap_post_count_(_N1,_N) wchar_t *_S1, - _In_ size_t _N1, - _In_count_(_N) const wchar_t *_S2, - _In_ size_t _N) + _Out_cap_post_count_(_N1,_N) wchar_t *_S1, + _In_ size_t _N1, + _In_count_(_N) const wchar_t *_S2, + _In_ size_t _N) { - ATLMFC_CRT_ERRORCHECK(::wmemcpy_s(_S1, _N1, _S2, _N)); + ATLMFC_CRT_ERRORCHECK(::wmemcpy_s(_S1, _N1, _S2, _N)); } inline void __cdecl memmove_s( - _Out_bytecap_post_bytecount_(_S1max,_N) void *_S1, - _In_ size_t _S1max, - _In_bytecount_(_N) const void *_S2, - _In_ size_t _N) + _Out_bytecap_post_bytecount_(_S1max,_N) void *_S1, + _In_ size_t _S1max, + _In_bytecount_(_N) const void *_S2, + _In_ size_t _N) { - ATLMFC_CRT_ERRORCHECK(::memmove_s(_S1, _S1max, _S2, _N)); + ATLMFC_CRT_ERRORCHECK(::memmove_s(_S1, _S1max, _S2, _N)); } inline void __cdecl strcpy_s( - _Out_z_cap_(_S1max) char *_S1, - _In_ size_t _S1max, - _In_z_ const char *_S2) + _Out_z_cap_(_S1max) char *_S1, + _In_ size_t _S1max, + _In_z_ const char *_S2) { - ATLMFC_CRT_ERRORCHECK(::strcpy_s(_S1, _S1max, _S2)); + ATLMFC_CRT_ERRORCHECK(::strcpy_s(_S1, _S1max, _S2)); } inline void __cdecl wcscpy_s( - _Out_z_cap_(_S1max) wchar_t *_S1, - _In_ size_t _S1max, - _In_z_ const wchar_t *_S2) + _Out_z_cap_(_S1max) wchar_t *_S1, + _In_ size_t _S1max, + _In_z_ const wchar_t *_S2) { - ATLMFC_CRT_ERRORCHECK(::wcscpy_s(_S1, _S1max, _S2)); + ATLMFC_CRT_ERRORCHECK(::wcscpy_s(_S1, _S1max, _S2)); } inline void __cdecl tcscpy_s( - _Out_z_cap_(_SizeInChars) TCHAR * _Dst, - _In_ size_t _SizeInChars, - _In_z_ const TCHAR * _Src) + _Out_z_cap_(_SizeInChars) TCHAR * _Dst, + _In_ size_t _SizeInChars, + _In_z_ const TCHAR * _Src) { - ATLMFC_CRT_ERRORCHECK(::_tcscpy_s(_Dst, _SizeInChars, _Src)); + ATLMFC_CRT_ERRORCHECK(::_tcscpy_s(_Dst, _SizeInChars, _Src)); } inline errno_t __cdecl strncpy_s( - _Out_z_cap_(_SizeInChars) char *_Dest, - _In_ size_t _SizeInChars, - _In_z_ const char *_Source, - _In_ size_t _Count) + _Out_z_cap_(_SizeInChars) char *_Dest, + _In_ size_t _SizeInChars, + _In_z_ const char *_Source, + _In_ size_t _Count) { - return ATLMFC_CRT_ERRORCHECK(::strncpy_s(_Dest, _SizeInChars, _Source,_Count)); + return ATLMFC_CRT_ERRORCHECK(::strncpy_s(_Dest, _SizeInChars, _Source,_Count)); } inline errno_t __cdecl wcsncpy_s( - _Out_z_cap_(_SizeInChars) wchar_t *_Dest, - _In_ size_t _SizeInChars, - _In_z_ const wchar_t *_Source, - _In_ size_t _Count) + _Out_z_cap_(_SizeInChars) wchar_t *_Dest, + _In_ size_t _SizeInChars, + _In_z_ const wchar_t *_Source, + _In_ size_t _Count) { - return ATLMFC_CRT_ERRORCHECK(::wcsncpy_s(_Dest, _SizeInChars, _Source,_Count)); + return ATLMFC_CRT_ERRORCHECK(::wcsncpy_s(_Dest, _SizeInChars, _Source,_Count)); } inline errno_t __cdecl tcsncpy_s( - _Out_z_cap_(_SizeInChars) TCHAR *_Dest, - _In_ size_t _SizeInChars, - _In_z_ const TCHAR *_Source, - _In_ size_t _Count) + _Out_z_cap_(_SizeInChars) TCHAR *_Dest, + _In_ size_t _SizeInChars, + _In_z_ const TCHAR *_Source, + _In_ size_t _Count) { - return ATLMFC_CRT_ERRORCHECK(::_tcsncpy_s(_Dest, _SizeInChars, _Source,_Count)); + return ATLMFC_CRT_ERRORCHECK(::_tcsncpy_s(_Dest, _SizeInChars, _Source,_Count)); } inline void __cdecl strcat_s( - _Inout_z_cap_(_SizeInChars) char * _Dst, - _In_ size_t _SizeInChars, - _In_z_ const char * _Src) + _Inout_z_cap_(_SizeInChars) char * _Dst, + _In_ size_t _SizeInChars, + _In_z_ const char * _Src) { - ATLMFC_CRT_ERRORCHECK(::strcat_s(_Dst, _SizeInChars, _Src)); + ATLMFC_CRT_ERRORCHECK(::strcat_s(_Dst, _SizeInChars, _Src)); } inline void __cdecl wcscat_s( - _Inout_z_cap_(_SizeInChars) wchar_t * _Dst, - _In_ size_t _SizeInChars, - _In_z_ const wchar_t * _Src) + _Inout_z_cap_(_SizeInChars) wchar_t * _Dst, + _In_ size_t _SizeInChars, + _In_z_ const wchar_t * _Src) { - ATLMFC_CRT_ERRORCHECK(::wcscat_s(_Dst, _SizeInChars, _Src)); + ATLMFC_CRT_ERRORCHECK(::wcscat_s(_Dst, _SizeInChars, _Src)); } inline void __cdecl tcscat_s( - _Inout_z_cap_(_SizeInChars) TCHAR * _Dst, - _In_ size_t _SizeInChars, - _In_z_ const TCHAR * _Src) + _Inout_z_cap_(_SizeInChars) TCHAR * _Dst, + _In_ size_t _SizeInChars, + _In_z_ const TCHAR * _Src) { - ATLMFC_CRT_ERRORCHECK(::_tcscat_s(_Dst, _SizeInChars, _Src)); + ATLMFC_CRT_ERRORCHECK(::_tcscat_s(_Dst, _SizeInChars, _Src)); } inline void __cdecl strlwr_s( - _Inout_z_cap_(_SizeInChars) char * _Str, - _In_ size_t _SizeInChars) + _Inout_z_cap_(_SizeInChars) char * _Str, + _In_ size_t _SizeInChars) { - ATLMFC_CRT_ERRORCHECK(::_strlwr_s(_Str, _SizeInChars)); + ATLMFC_CRT_ERRORCHECK(::_strlwr_s(_Str, _SizeInChars)); } inline void __cdecl wcslwr_s( - _Inout_z_cap_(_SizeInChars) wchar_t * _Str, - _In_ size_t _SizeInChars) + _Inout_z_cap_(_SizeInChars) wchar_t * _Str, + _In_ size_t _SizeInChars) { - ATLMFC_CRT_ERRORCHECK(::_wcslwr_s(_Str, _SizeInChars)); + ATLMFC_CRT_ERRORCHECK(::_wcslwr_s(_Str, _SizeInChars)); } inline void __cdecl mbslwr_s( - _Inout_z_bytecap_(_SizeInChars) unsigned char * _Str, - _In_ size_t _SizeInChars) + _Inout_z_bytecap_(_SizeInChars) unsigned char * _Str, + _In_ size_t _SizeInChars) { - ATLMFC_CRT_ERRORCHECK(::_mbslwr_s(_Str, _SizeInChars)); + ATLMFC_CRT_ERRORCHECK(::_mbslwr_s(_Str, _SizeInChars)); } inline void __cdecl tcslwr_s( - _Inout_z_cap_(_SizeInChars) TCHAR * _Str, - _In_ size_t _SizeInChars) + _Inout_z_cap_(_SizeInChars) TCHAR * _Str, + _In_ size_t _SizeInChars) { - ATLMFC_CRT_ERRORCHECK(::_tcslwr_s(_Str, _SizeInChars)); + ATLMFC_CRT_ERRORCHECK(::_tcslwr_s(_Str, _SizeInChars)); } inline void __cdecl strupr_s( - _Inout_z_cap_(_SizeInChars) char * _Str, - _In_ size_t _SizeInChars) + _Inout_z_cap_(_SizeInChars) char * _Str, + _In_ size_t _SizeInChars) { - ATLMFC_CRT_ERRORCHECK(::_strupr_s(_Str, _SizeInChars)); + ATLMFC_CRT_ERRORCHECK(::_strupr_s(_Str, _SizeInChars)); } inline void __cdecl wcsupr_s( - _Inout_z_cap_(_SizeInChars) wchar_t * _Str, - _In_ size_t _SizeInChars) + _Inout_z_cap_(_SizeInChars) wchar_t * _Str, + _In_ size_t _SizeInChars) { - ATLMFC_CRT_ERRORCHECK(::_wcsupr_s(_Str, _SizeInChars)); + ATLMFC_CRT_ERRORCHECK(::_wcsupr_s(_Str, _SizeInChars)); } inline void __cdecl mbsupr_s( - _Inout_z_bytecap_(_SizeInChars) unsigned char * _Str, - _In_ size_t _SizeInChars) + _Inout_z_bytecap_(_SizeInChars) unsigned char * _Str, + _In_ size_t _SizeInChars) { - ATLMFC_CRT_ERRORCHECK(::_mbsupr_s(_Str, _SizeInChars)); + ATLMFC_CRT_ERRORCHECK(::_mbsupr_s(_Str, _SizeInChars)); } inline void __cdecl tcsupr_s( - _Inout_z_cap_(_SizeInChars) TCHAR * _Str, - _In_ size_t _SizeInChars) + _Inout_z_cap_(_SizeInChars) TCHAR * _Str, + _In_ size_t _SizeInChars) { - ATLMFC_CRT_ERRORCHECK(::_tcsupr_s(_Str, _SizeInChars)); + ATLMFC_CRT_ERRORCHECK(::_tcsupr_s(_Str, _SizeInChars)); } inline void __cdecl itoa_s( - _In_ int _Val, - _Out_z_cap_(_SizeInChars) char *_Buf, - _In_ size_t _SizeInChars, - _In_ int _Radix) + _In_ int _Val, + _Out_z_cap_(_SizeInChars) char *_Buf, + _In_ size_t _SizeInChars, + _In_ int _Radix) { - ATLMFC_CRT_ERRORCHECK(::_itoa_s(_Val, _Buf, _SizeInChars, _Radix)); + ATLMFC_CRT_ERRORCHECK(::_itoa_s(_Val, _Buf, _SizeInChars, _Radix)); } inline void __cdecl itot_s( - _In_ int _Val, - _Out_z_cap_(_SizeInChars) TCHAR *_Buf, - _In_ size_t _SizeInChars, - _In_ int _Radix) + _In_ int _Val, + _Out_z_cap_(_SizeInChars) TCHAR *_Buf, + _In_ size_t _SizeInChars, + _In_ int _Radix) { - ATLMFC_CRT_ERRORCHECK(::_itot_s(_Val, _Buf, _SizeInChars, _Radix)); + ATLMFC_CRT_ERRORCHECK(::_itot_s(_Val, _Buf, _SizeInChars, _Radix)); } inline void __cdecl ltoa_s( - _In_ long _Val, - _Out_z_cap_(_SizeInChars) char *_Buf, - _In_ size_t _SizeInChars, - _In_ int _Radix) + _In_ long _Val, + _Out_z_cap_(_SizeInChars) char *_Buf, + _In_ size_t _SizeInChars, + _In_ int _Radix) { - ATLMFC_CRT_ERRORCHECK(::_ltoa_s(_Val, _Buf, _SizeInChars, _Radix)); + ATLMFC_CRT_ERRORCHECK(::_ltoa_s(_Val, _Buf, _SizeInChars, _Radix)); } inline void __cdecl ltot_s( - _In_ long _Val, - _Out_z_cap_(_SizeInChars) TCHAR *_Buf, - _In_ size_t _SizeInChars, - _In_ int _Radix) + _In_ long _Val, + _Out_z_cap_(_SizeInChars) TCHAR *_Buf, + _In_ size_t _SizeInChars, + _In_ int _Radix) { - ATLMFC_CRT_ERRORCHECK(::_ltot_s(_Val, _Buf, _SizeInChars, _Radix)); + ATLMFC_CRT_ERRORCHECK(::_ltot_s(_Val, _Buf, _SizeInChars, _Radix)); } inline void __cdecl ultoa_s( - _In_ unsigned long _Val, - _Out_z_cap_(_SizeInChars) char *_Buf, - _In_ size_t _SizeInChars, - _In_ int _Radix) + _In_ unsigned long _Val, + _Out_z_cap_(_SizeInChars) char *_Buf, + _In_ size_t _SizeInChars, + _In_ int _Radix) { - ATLMFC_CRT_ERRORCHECK(::_ultoa_s(_Val, _Buf, _SizeInChars, _Radix)); + ATLMFC_CRT_ERRORCHECK(::_ultoa_s(_Val, _Buf, _SizeInChars, _Radix)); } inline void __cdecl ultow_s( - _In_ unsigned long _Val, - _Out_z_cap_(_SizeInChars) wchar_t *_Buf, - _In_ size_t _SizeInChars, - _In_ int _Radix) + _In_ unsigned long _Val, + _Out_z_cap_(_SizeInChars) wchar_t *_Buf, + _In_ size_t _SizeInChars, + _In_ int _Radix) { - ATLMFC_CRT_ERRORCHECK(::_ultow_s(_Val, _Buf, _SizeInChars, _Radix)); + ATLMFC_CRT_ERRORCHECK(::_ultow_s(_Val, _Buf, _SizeInChars, _Radix)); } inline void __cdecl ultot_s( - _In_ unsigned long _Val, - _Out_z_cap_(_SizeInChars) TCHAR *_Buf, - _In_ size_t _SizeInChars, - _In_ int _Radix) + _In_ unsigned long _Val, + _Out_z_cap_(_SizeInChars) TCHAR *_Buf, + _In_ size_t _SizeInChars, + _In_ int _Radix) { - ATLMFC_CRT_ERRORCHECK(::_ultot_s(_Val, _Buf, _SizeInChars, _Radix)); + ATLMFC_CRT_ERRORCHECK(::_ultot_s(_Val, _Buf, _SizeInChars, _Radix)); } inline void __cdecl i64toa_s( - _In_ __int64 _Val, - _Out_z_cap_(_SizeInChars) char *_Buf, - _In_ size_t _SizeInChars, - _In_ int _Radix) + _In_ __int64 _Val, + _Out_z_cap_(_SizeInChars) char *_Buf, + _In_ size_t _SizeInChars, + _In_ int _Radix) { - ATLMFC_CRT_ERRORCHECK(::_i64toa_s(_Val, _Buf, _SizeInChars, _Radix)); + ATLMFC_CRT_ERRORCHECK(::_i64toa_s(_Val, _Buf, _SizeInChars, _Radix)); } inline void __cdecl i64tow_s( - _In_ __int64 _Val, - _Out_z_cap_(_SizeInChars) wchar_t *_Buf, - _In_ size_t _SizeInChars, - _In_ int _Radix) + _In_ __int64 _Val, + _Out_z_cap_(_SizeInChars) wchar_t *_Buf, + _In_ size_t _SizeInChars, + _In_ int _Radix) { - ATLMFC_CRT_ERRORCHECK(::_i64tow_s(_Val, _Buf, _SizeInChars, _Radix)); + ATLMFC_CRT_ERRORCHECK(::_i64tow_s(_Val, _Buf, _SizeInChars, _Radix)); } inline void __cdecl ui64toa_s( - _In_ unsigned __int64 _Val, - _Out_z_cap_(_SizeInChars) char *_Buf, - _In_ size_t _SizeInChars, - _In_ int _Radix) + _In_ unsigned __int64 _Val, + _Out_z_cap_(_SizeInChars) char *_Buf, + _In_ size_t _SizeInChars, + _In_ int _Radix) { - ATLMFC_CRT_ERRORCHECK(::_ui64toa_s(_Val, _Buf, _SizeInChars, _Radix)); + ATLMFC_CRT_ERRORCHECK(::_ui64toa_s(_Val, _Buf, _SizeInChars, _Radix)); } inline void __cdecl ui64tow_s( - _In_ unsigned __int64 _Val, - _Out_z_cap_(_SizeInChars) wchar_t *_Buf, - _In_ size_t _SizeInChars, - _In_ int _Radix) + _In_ unsigned __int64 _Val, + _Out_z_cap_(_SizeInChars) wchar_t *_Buf, + _In_ size_t _SizeInChars, + _In_ int _Radix) { - ATLMFC_CRT_ERRORCHECK(::_ui64tow_s(_Val, _Buf, _SizeInChars, _Radix)); + ATLMFC_CRT_ERRORCHECK(::_ui64tow_s(_Val, _Buf, _SizeInChars, _Radix)); } inline void __cdecl gcvt_s( - _Out_z_cap_(_SizeInChars) char *_Buffer, - _In_ size_t _SizeInChars, - _In_ double _Value, - _In_ int _Ndec) + _Out_z_cap_(_SizeInChars) char *_Buffer, + _In_ size_t _SizeInChars, + _In_ double _Value, + _In_ int _Ndec) { - ATLMFC_CRT_ERRORCHECK(::_gcvt_s(_Buffer, _SizeInChars, _Value, _Ndec)); + ATLMFC_CRT_ERRORCHECK(::_gcvt_s(_Buffer, _SizeInChars, _Value, _Ndec)); } inline void __cdecl tsplitpath_s( - _In_z_ const TCHAR *_Path, - _Out_opt_z_cap_(_Drive_len) TCHAR *_Drive, - _In_ size_t _Drive_len, - _Out_opt_z_cap_(_Dir_len) TCHAR *_Dir, - _In_ size_t _Dir_len, - _Out_opt_z_cap_(_Fname_len) TCHAR *_Fname, - _In_ size_t _Fname_len, - _Out_opt_z_cap_(_Ext_len) TCHAR *_Ext, - _In_ size_t _Ext_len) + _In_z_ const TCHAR *_Path, + _Out_opt_z_cap_(_Drive_len) TCHAR *_Drive, + _In_ size_t _Drive_len, + _Out_opt_z_cap_(_Dir_len) TCHAR *_Dir, + _In_ size_t _Dir_len, + _Out_opt_z_cap_(_Fname_len) TCHAR *_Fname, + _In_ size_t _Fname_len, + _Out_opt_z_cap_(_Ext_len) TCHAR *_Ext, + _In_ size_t _Ext_len) { - ATLMFC_CRT_ERRORCHECK(::_tsplitpath_s(_Path, _Drive, _Drive_len, _Dir, _Dir_len, _Fname, _Fname_len, _Ext, _Ext_len)); + ATLMFC_CRT_ERRORCHECK(::_tsplitpath_s(_Path, _Drive, _Drive_len, _Dir, _Dir_len, _Fname, _Fname_len, _Ext, _Ext_len)); } inline void __cdecl tmakepath_s( - _Out_z_cap_(_SizeInChars) TCHAR *_Path, - _In_ size_t _SizeInChars, - _In_z_ const TCHAR *_Drive, - _In_z_ const TCHAR *_Dir, - _In_z_ const TCHAR *_Fname, - _In_z_ const TCHAR *_Ext) + _Out_z_cap_(_SizeInChars) TCHAR *_Path, + _In_ size_t _SizeInChars, + _In_z_ const TCHAR *_Drive, + _In_z_ const TCHAR *_Dir, + _In_z_ const TCHAR *_Fname, + _In_z_ const TCHAR *_Ext) { - ATLMFC_CRT_ERRORCHECK(::_tmakepath_s(_Path, _SizeInChars, _Drive, _Dir, _Fname, _Ext)); + ATLMFC_CRT_ERRORCHECK(::_tmakepath_s(_Path, _SizeInChars, _Drive, _Dir, _Fname, _Ext)); } inline size_t __cdecl strnlen( - _In_z_count_(_Maxsize) const char *_Str, - _In_ size_t _Maxsize) + _In_z_count_(_Maxsize) const char *_Str, + _In_ size_t _Maxsize) { - return ::strnlen(_Str, _Maxsize); + return ::strnlen(_Str, _Maxsize); } inline size_t __cdecl wcsnlen( - _In_z_count_(_Maxsize) const wchar_t *_Wcs, - _In_ size_t _Maxsize) + _In_z_count_(_Maxsize) const wchar_t *_Wcs, + _In_ size_t _Maxsize) { - return ::wcsnlen(_Wcs, _Maxsize); + return ::wcsnlen(_Wcs, _Maxsize); } inline size_t __cdecl tcsnlen( - _In_z_count_(_Maxsize) const TCHAR *_Str, - _In_ size_t _Maxsize) + _In_z_count_(_Maxsize) const TCHAR *_Str, + _In_ size_t _Maxsize) { - return ::_tcsnlen(_Str, _Maxsize); + return ::_tcsnlen(_Str, _Maxsize); } inline int get_errno() throw() { - int nErrNo=0; - errno_t nErrCall=::_get_errno(&nErrNo); - if(nErrCall) - { - return nErrCall; - } - return nErrNo; + int nErrNo=0; + errno_t nErrCall=::_get_errno(&nErrNo); + if(nErrCall) + { + return nErrCall; + } + return nErrNo; } inline void set_errno(_In_ int _Value) { - ATLMFC_CRT_ERRORCHECK(::_set_errno(_Value)); + ATLMFC_CRT_ERRORCHECK(::_set_errno(_Value)); } } // namespace Checked diff --git a/src/main/headers/atlcomcli.h b/src/main/headers/atlcomcli.h index 33924e4..f26b017 100644 --- a/src/main/headers/atlcomcli.h +++ b/src/main/headers/atlcomcli.h @@ -5,7 +5,7 @@ // This source code is only intended as a supplement to the // Active Template Library Reference and related // electronic documentation provided with the library. -// See these sources for detailed information regarding the +// See these sources for detailed information regarding the // Active Template Library product. #ifndef __ATLCOMCLI_H__ @@ -31,26 +31,26 @@ namespace ATL ATL_NOINLINE inline HRESULT AtlHresultFromLastError() throw() { - DWORD dwErr = ::GetLastError(); - return HRESULT_FROM_WIN32(dwErr); + DWORD dwErr = ::GetLastError(); + return HRESULT_FROM_WIN32(dwErr); } ATL_NOINLINE inline HRESULT AtlHresultFromWin32(_In_ DWORD nError) throw() { - return( HRESULT_FROM_WIN32( nError ) ); + return( HRESULT_FROM_WIN32( nError ) ); } ///////////////////////////////////////////////////////////////////////////// // Smart Pointer helpers ATLAPI_(IUnknown*) AtlComPtrAssign( - _Inout_opt_ _Deref_pre_maybenull_ _Deref_post_maybenull_ IUnknown** pp, - _In_opt_ IUnknown* lp); + _Inout_opt_ _Deref_pre_maybenull_ _Deref_post_maybenull_ IUnknown** pp, + _In_opt_ IUnknown* lp); ATLAPI_(IUnknown*) AtlComQIPtrAssign( - _Inout_opt_ _Deref_pre_maybenull_ _Deref_post_maybenull_ IUnknown** pp, - _In_opt_ IUnknown* lp, - _In_ REFIID riid); + _Inout_opt_ _Deref_pre_maybenull_ _Deref_post_maybenull_ IUnknown** pp, + _In_opt_ IUnknown* lp, + _In_ REFIID riid); ///////////////////////////////////////////////////////////////////////////// // Safe Ole Object Reading @@ -58,46 +58,46 @@ ATLAPI_(IUnknown*) AtlComQIPtrAssign( #if !defined(__MINGW32__) union ClassesAllowedInStream { - const CLSID *rgclsidAllowed; - HRESULT (*pfnClsidAllowed)( - _In_ const CLSID& clsid, - _In_ REFIID iidInterface, - _Deref_out_opt_ void** ppvObj); + const CLSID *rgclsidAllowed; + HRESULT (*pfnClsidAllowed)( + _In_ const CLSID& clsid, + _In_ REFIID iidInterface, + _Deref_out_opt_ void** ppvObj); }; #endif #ifndef _ATL_DLL ATLINLINE ATLAPI_(IUnknown*) AtlComPtrAssign( - _Inout_opt_ _Deref_pre_maybenull_ _Deref_post_maybenull_ IUnknown** pp, - _In_opt_ IUnknown* lp) + _Inout_opt_ _Deref_pre_maybenull_ _Deref_post_maybenull_ IUnknown** pp, + _In_opt_ IUnknown* lp) { - if (pp == NULL) - return NULL; - - if (lp != NULL) - lp->AddRef(); - if (*pp) - (*pp)->Release(); - *pp = lp; - return lp; + if (pp == NULL) + return NULL; + + if (lp != NULL) + lp->AddRef(); + if (*pp) + (*pp)->Release(); + *pp = lp; + return lp; } ATLINLINE ATLAPI_(IUnknown*) AtlComQIPtrAssign( - _Inout_opt_ _Deref_pre_maybenull_ _Deref_post_maybenull_ IUnknown** pp, - _In_opt_ IUnknown* lp, - _In_ REFIID riid) + _Inout_opt_ _Deref_pre_maybenull_ _Deref_post_maybenull_ IUnknown** pp, + _In_opt_ IUnknown* lp, + _In_ REFIID riid) { - if (pp == NULL) - return NULL; + if (pp == NULL) + return NULL; - IUnknown* pTemp = *pp; - *pp = NULL; - if (lp != NULL) - lp->QueryInterface(riid, (void**)pp); - if (pTemp) - pTemp->Release(); - return *pp; + IUnknown* pTemp = *pp; + *pp = NULL; + if (lp != NULL) + lp->QueryInterface(riid, (void**)pp); + if (pTemp) + pTemp->Release(); + return *pp; } #endif // _ATL_DLL @@ -107,29 +107,29 @@ ATLINLINE ATLAPI_(IUnknown*) AtlComQIPtrAssign( template class _NoAddRefReleaseOnCComPtr : - public T + public T { - private: - STDMETHOD_(ULONG, AddRef)()=0; - STDMETHOD_(ULONG, Release)()=0; + private: + STDMETHOD_(ULONG, AddRef)()=0; + STDMETHOD_(ULONG, Release)()=0; }; _Check_return_ inline HRESULT AtlSetChildSite( - _Inout_ IUnknown* punkChild, - _Inout_opt_ IUnknown* punkParent) + _Inout_ IUnknown* punkChild, + _Inout_opt_ IUnknown* punkParent) { - if (punkChild == NULL) - return E_POINTER; + if (punkChild == NULL) + return E_POINTER; - HRESULT hr; - IObjectWithSite* pChildSite = NULL; - hr = punkChild->QueryInterface(__uuidof(IObjectWithSite), (void**)&pChildSite); - if (SUCCEEDED(hr) && pChildSite != NULL) - { - hr = pChildSite->SetSite(punkParent); - pChildSite->Release(); - } - return hr; + HRESULT hr; + IObjectWithSite* pChildSite = NULL; + hr = punkChild->QueryInterface(__uuidof(IObjectWithSite), (void**)&pChildSite); + if (SUCCEEDED(hr) && pChildSite != NULL) + { + hr = pChildSite->SetSite(punkParent); + pChildSite->Release(); + } + return hr; } @@ -139,529 +139,529 @@ template class CComPtrBase { protected: - CComPtrBase() throw() - { - p = NULL; - } - CComPtrBase(_Inout_opt_ T* lp) throw() - { - p = lp; - if (p != NULL) - p->AddRef(); - } + CComPtrBase() throw() + { + p = NULL; + } + CComPtrBase(_Inout_opt_ T* lp) throw() + { + p = lp; + if (p != NULL) + p->AddRef(); + } public: - typedef T _PtrClass; - ~CComPtrBase() throw() - { - if (p) - p->Release(); - } - operator T*() const throw() - { - return p; - } - T& operator*() const - { - ATLENSURE(p!=NULL); - return *p; - } - //The assert on operator& usually indicates a bug. If this is really - //what is needed, however, take the address of the p member explicitly. - T** operator&() throw() - { - ATLASSERT(p==NULL); - return &p; - } - _NoAddRefReleaseOnCComPtr* operator->() const throw() - { - ATLASSERT(p!=NULL); - return (_NoAddRefReleaseOnCComPtr*)p; - } - bool operator!() const throw() - { - return (p == NULL); - } - bool operator<(_In_opt_ T* pT) const throw() - { - return p < pT; - } - bool operator!=(_In_opt_ T* pT) const - { - return !operator==(pT); - } - bool operator==(_In_opt_ T* pT) const throw() - { - return p == pT; - } + typedef T _PtrClass; + ~CComPtrBase() throw() + { + if (p) + p->Release(); + } + operator T*() const throw() + { + return p; + } + T& operator*() const + { + ATLENSURE(p!=NULL); + return *p; + } + //The assert on operator& usually indicates a bug. If this is really + //what is needed, however, take the address of the p member explicitly. + T** operator&() throw() + { + ATLASSERT(p==NULL); + return &p; + } + _NoAddRefReleaseOnCComPtr* operator->() const throw() + { + ATLASSERT(p!=NULL); + return (_NoAddRefReleaseOnCComPtr*)p; + } + bool operator!() const throw() + { + return (p == NULL); + } + bool operator<(_In_opt_ T* pT) const throw() + { + return p < pT; + } + bool operator!=(_In_opt_ T* pT) const + { + return !operator==(pT); + } + bool operator==(_In_opt_ T* pT) const throw() + { + return p == pT; + } - // Release the interface and set to NULL - void Release() throw() - { - T* pTemp = p; - if (pTemp) - { - p = NULL; - pTemp->Release(); - } - } - // Compare two objects for equivalence - bool IsEqualObject(_Inout_opt_ IUnknown* pOther) throw() - { - /*if (p == NULL && pOther == NULL) - return true; // They are both NULL objects + // Release the interface and set to NULL + void Release() throw() + { + T* pTemp = p; + if (pTemp) + { + p = NULL; + pTemp->Release(); + } + } + // Compare two objects for equivalence + bool IsEqualObject(_Inout_opt_ IUnknown* pOther) throw() + { + /*if (p == NULL && pOther == NULL) + return true; // They are both NULL objects - if (p == NULL || pOther == NULL) - return false; // One is NULL the other is not + if (p == NULL || pOther == NULL) + return false; // One is NULL the other is not - CComPtr punk1; - CComPtr punk2; - p->QueryInterface(__uuidof(IUnknown), (void**)&punk1); - pOther->QueryInterface(__uuidof(IUnknown), (void**)&punk2); - return punk1 == punk2;*/ - return false; - } - // Attach to an existing interface (does not AddRef) - void Attach(_In_opt_ T* p2) throw() - { - if (p) - p->Release(); - p = p2; - } - // Detach the interface (does not Release) - T* Detach() throw() - { - T* pt = p; - p = NULL; - return pt; - } - _Check_return_ HRESULT CopyTo(_Deref_out_opt_ T** ppT) throw() - { - ATLASSERT(ppT != NULL); - if (ppT == NULL) - return E_POINTER; - *ppT = p; - if (p) - p->AddRef(); - return S_OK; - } - _Check_return_ HRESULT SetSite(_Inout_opt_ IUnknown* punkParent) throw() - { - return AtlSetChildSite(p, punkParent); - } - _Check_return_ HRESULT Advise( - _Inout_ IUnknown* pUnk, - _In_ const IID& iid, - _Out_ LPDWORD pdw) throw() - { - return AtlAdvise(p, pUnk, iid, pdw); - } - _Check_return_ HRESULT CoCreateInstance( - _In_ REFCLSID rclsid, - _Inout_opt_ LPUNKNOWN pUnkOuter = NULL, - _In_ DWORD dwClsContext = CLSCTX_ALL) throw() - { - ATLASSERT(p == NULL); - return ::CoCreateInstance(rclsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&p); - } - _Check_return_ HRESULT CoCreateInstance( - _In_z_ LPCOLESTR szProgID, - _Inout_opt_ LPUNKNOWN pUnkOuter = NULL, - _In_ DWORD dwClsContext = CLSCTX_ALL) throw() - { - CLSID clsid; - HRESULT hr = CLSIDFromProgID(szProgID, &clsid); - ATLASSERT(p == NULL); - if (SUCCEEDED(hr)) - hr = ::CoCreateInstance(clsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&p); - return hr; - } - template - _Check_return_ HRESULT QueryInterface(_Deref_out_ Q** pp) const throw() - { - ATLASSERT(pp != NULL); - return p->QueryInterface(__uuidof(Q), (void**)pp); - } - T* p; + CComPtr punk1; + CComPtr punk2; + p->QueryInterface(__uuidof(IUnknown), (void**)&punk1); + pOther->QueryInterface(__uuidof(IUnknown), (void**)&punk2); + return punk1 == punk2;*/ + return false; + } + // Attach to an existing interface (does not AddRef) + void Attach(_In_opt_ T* p2) throw() + { + if (p) + p->Release(); + p = p2; + } + // Detach the interface (does not Release) + T* Detach() throw() + { + T* pt = p; + p = NULL; + return pt; + } + _Check_return_ HRESULT CopyTo(_Deref_out_opt_ T** ppT) throw() + { + ATLASSERT(ppT != NULL); + if (ppT == NULL) + return E_POINTER; + *ppT = p; + if (p) + p->AddRef(); + return S_OK; + } + _Check_return_ HRESULT SetSite(_Inout_opt_ IUnknown* punkParent) throw() + { + return AtlSetChildSite(p, punkParent); + } + _Check_return_ HRESULT Advise( + _Inout_ IUnknown* pUnk, + _In_ const IID& iid, + _Out_ LPDWORD pdw) throw() + { + return AtlAdvise(p, pUnk, iid, pdw); + } + _Check_return_ HRESULT CoCreateInstance( + _In_ REFCLSID rclsid, + _Inout_opt_ LPUNKNOWN pUnkOuter = NULL, + _In_ DWORD dwClsContext = CLSCTX_ALL) throw() + { + ATLASSERT(p == NULL); + return ::CoCreateInstance(rclsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&p); + } + _Check_return_ HRESULT CoCreateInstance( + _In_z_ LPCOLESTR szProgID, + _Inout_opt_ LPUNKNOWN pUnkOuter = NULL, + _In_ DWORD dwClsContext = CLSCTX_ALL) throw() + { + CLSID clsid; + HRESULT hr = CLSIDFromProgID(szProgID, &clsid); + ATLASSERT(p == NULL); + if (SUCCEEDED(hr)) + hr = ::CoCreateInstance(clsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&p); + return hr; + } + template + _Check_return_ HRESULT QueryInterface(_Deref_out_ Q** pp) const throw() + { + ATLASSERT(pp != NULL); + return p->QueryInterface(__uuidof(Q), (void**)pp); + } + T* p; }; template class CComPtr : - public CComPtrBase + public CComPtrBase { public: - CComPtr() throw() - { - } - CComPtr(_Inout_opt_ T* lp) throw() : - CComPtrBase(lp) - { - } - CComPtr(_Inout_ const CComPtr& lp) throw() : - CComPtrBase(lp.p) - { - } - T* operator=(_Inout_opt_ T* lp) throw() - { + CComPtr() throw() + { + } + CComPtr(_Inout_opt_ T* lp) throw() : + CComPtrBase(lp) + { + } + CComPtr(_Inout_ const CComPtr& lp) throw() : + CComPtrBase(lp.p) + { + } + T* operator=(_Inout_opt_ T* lp) throw() + { if(*this!=lp) { - return static_cast(AtlComPtrAssign((IUnknown**)&this->p, lp)); + return static_cast(AtlComPtrAssign((IUnknown**)&this->p, lp)); } return *this; - } - template - T* operator=(_Inout_ const CComPtr& lp) throw() - { + } + template + T* operator=(_Inout_ const CComPtr& lp) throw() + { if( !IsEqualObject(lp) ) { - return static_cast(AtlComQIPtrAssign((IUnknown**)&this->p, lp, __uuidof(T))); + return static_cast(AtlComQIPtrAssign((IUnknown**)&this->p, lp, __uuidof(T))); } return *this; - } - T* operator=(_Inout_ const CComPtr& lp) throw() - { + } + T* operator=(_Inout_ const CComPtr& lp) throw() + { if(*this!=lp) { - return static_cast(AtlComPtrAssign((IUnknown**)&this->p, lp)); + return static_cast(AtlComPtrAssign((IUnknown**)&this->p, lp)); } return *this; - } + } #if !defined(__MINGW32__) - CComPtr(_Inout_ CComPtr&& lp) throw() : - CComPtrBase() - { - p = lp.p; - lp.p = NULL; - } - T* operator=(_Inout_ CComPtr&& lp) throw() - { - if (*this != lp) - { - if (p != NULL) - p->Release(); - - p = lp.p; - lp.p = NULL; - } - return *this; - } + CComPtr(_Inout_ CComPtr&& lp) throw() : + CComPtrBase() + { + p = lp.p; + lp.p = NULL; + } + T* operator=(_Inout_ CComPtr&& lp) throw() + { + if (*this != lp) + { + if (p != NULL) + p->Release(); + + p = lp.p; + lp.p = NULL; + } + return *this; + } #endif }; //specialization for IDispatch template <> class CComPtr : - public CComPtrBase + public CComPtrBase { public: - CComPtr() throw() - { - } - CComPtr(_Inout_opt_ IDispatch* lp) throw() : - CComPtrBase(lp) - { - } - CComPtr(_Inout_ const CComPtr& lp) throw() : - CComPtrBase(lp.p) - { - } - IDispatch* operator=(_Inout_opt_ IDispatch* lp) throw() - { + CComPtr() throw() + { + } + CComPtr(_Inout_opt_ IDispatch* lp) throw() : + CComPtrBase(lp) + { + } + CComPtr(_Inout_ const CComPtr& lp) throw() : + CComPtrBase(lp.p) + { + } + IDispatch* operator=(_Inout_opt_ IDispatch* lp) throw() + { if(*this!=lp) { return static_cast(AtlComPtrAssign((IUnknown**)&this->p, lp)); } return *this; - } - IDispatch* operator=(_Inout_ const CComPtr& lp) throw() - { + } + IDispatch* operator=(_Inout_ const CComPtr& lp) throw() + { if(*this!=lp) { - return static_cast(AtlComPtrAssign((IUnknown**)&this->p, lp.p)); + return static_cast(AtlComPtrAssign((IUnknown**)&this->p, lp.p)); } return *this; - } + } #if !defined(__MINGW32__) - CComPtr(_Inout_ CComPtr&& lp) throw() : - CComPtrBase() - { - p = lp.p; - lp.p = NULL; - } - IDispatch* operator=(_Inout_ CComPtr&& lp) throw() - { - if (*this != lp) - { - if (p != NULL) - p->Release(); - - p = lp.p; - lp.p = NULL; - } - return *this; - } + CComPtr(_Inout_ CComPtr&& lp) throw() : + CComPtrBase() + { + p = lp.p; + lp.p = NULL; + } + IDispatch* operator=(_Inout_ CComPtr&& lp) throw() + { + if (*this != lp) + { + if (p != NULL) + p->Release(); + + p = lp.p; + lp.p = NULL; + } + return *this; + } #endif // IDispatch specific stuff - _Check_return_ HRESULT GetPropertyByName( - _In_z_ LPCOLESTR lpsz, - _Out_ VARIANT* pVar) throw() - { - ATLASSERT(p); - ATLASSERT(pVar); - DISPID dwDispID; - HRESULT hr = GetIDOfName(lpsz, &dwDispID); - if (SUCCEEDED(hr)) - hr = GetProperty(dwDispID, pVar); - return hr; - } - _Check_return_ HRESULT GetProperty( - _In_ DISPID dwDispID, - _Out_ VARIANT* pVar) throw() - { - return GetProperty(p, dwDispID, pVar); - } - _Check_return_ HRESULT PutPropertyByName( - _In_z_ LPCOLESTR lpsz, - _In_ VARIANT* pVar) throw() - { - ATLASSERT(p); - ATLASSERT(pVar); - DISPID dwDispID; - HRESULT hr = GetIDOfName(lpsz, &dwDispID); - if (SUCCEEDED(hr)) - hr = PutProperty(dwDispID, pVar); - return hr; - } - _Check_return_ HRESULT PutProperty( - _In_ DISPID dwDispID, - _In_ VARIANT* pVar) throw() - { - return PutProperty(p, dwDispID, pVar); - } - _Check_return_ HRESULT GetIDOfName( - _In_z_ LPCOLESTR lpsz, - _Out_ DISPID* pdispid) throw() - { - return p->GetIDsOfNames(IID_NULL, const_cast(&lpsz), 1, LOCALE_USER_DEFAULT, pdispid); - } - // Invoke a method by DISPID with no parameters - _Check_return_ HRESULT Invoke0( - _In_ DISPID dispid, - _Out_opt_ VARIANT* pvarRet = NULL) throw() - { - DISPPARAMS dispparams = { NULL, NULL, 0, 0}; - return p->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispparams, pvarRet, NULL, NULL); - } - // Invoke a method by name with no parameters - _Check_return_ HRESULT Invoke0( - _In_z_ LPCOLESTR lpszName, - _Out_opt_ VARIANT* pvarRet = NULL) throw() - { - HRESULT hr; - DISPID dispid; - hr = GetIDOfName(lpszName, &dispid); - if (SUCCEEDED(hr)) - hr = Invoke0(dispid, pvarRet); - return hr; - } - // Invoke a method by DISPID with a single parameter - _Check_return_ HRESULT Invoke1( - _In_ DISPID dispid, - _In_ VARIANT* pvarParam1, - _Out_opt_ VARIANT* pvarRet = NULL) throw() - { - DISPPARAMS dispparams = { pvarParam1, NULL, 1, 0}; - return p->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispparams, pvarRet, NULL, NULL); - } - // Invoke a method by name with a single parameter - _Check_return_ HRESULT Invoke1( - _In_z_ LPCOLESTR lpszName, - _In_ VARIANT* pvarParam1, - _Out_opt_ VARIANT* pvarRet = NULL) throw() - { - DISPID dispid; - HRESULT hr = GetIDOfName(lpszName, &dispid); - if (SUCCEEDED(hr)) - hr = Invoke1(dispid, pvarParam1, pvarRet); - return hr; - } - // Invoke a method by DISPID with two parameters - _Check_return_ HRESULT Invoke2( - _In_ DISPID dispid, - _In_ VARIANT* pvarParam1, - _In_ VARIANT* pvarParam2, - _Out_opt_ VARIANT* pvarRet = NULL) throw(); - // Invoke a method by name with two parameters - _Check_return_ HRESULT Invoke2( - _In_z_ LPCOLESTR lpszName, - _In_ VARIANT* pvarParam1, - _In_ VARIANT* pvarParam2, - _Out_opt_ VARIANT* pvarRet = NULL) throw() - { - DISPID dispid; - HRESULT hr = GetIDOfName(lpszName, &dispid); - if (SUCCEEDED(hr)) - hr = Invoke2(dispid, pvarParam1, pvarParam2, pvarRet); - return hr; - } - // Invoke a method by DISPID with N parameters - _Check_return_ HRESULT InvokeN( - _In_ DISPID dispid, - _In_ VARIANT* pvarParams, - _In_ int nParams, - _Out_opt_ VARIANT* pvarRet = NULL) throw() - { - DISPPARAMS dispparams = { pvarParams, NULL, nParams, 0}; - return p->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispparams, pvarRet, NULL, NULL); - } - // Invoke a method by name with Nparameters - _Check_return_ HRESULT InvokeN( - _In_z_ LPCOLESTR lpszName, - _In_ VARIANT* pvarParams, - _In_ int nParams, - _Out_opt_ VARIANT* pvarRet = NULL) throw() - { - HRESULT hr; - DISPID dispid; - hr = GetIDOfName(lpszName, &dispid); - if (SUCCEEDED(hr)) - hr = InvokeN(dispid, pvarParams, nParams, pvarRet); - return hr; - } - _Check_return_ static HRESULT PutProperty( - _In_ IDispatch* p, - _In_ DISPID dwDispID, - _In_ VARIANT* pVar) throw() - { - ATLASSERT(p); - ATLASSERT(pVar != NULL); - if (pVar == NULL) - return E_POINTER; - - if(p == NULL) - return E_INVALIDARG; - - DISPPARAMS dispparams = {NULL, NULL, 1, 1}; - dispparams.rgvarg = pVar; - DISPID dispidPut = DISPID_PROPERTYPUT; - dispparams.rgdispidNamedArgs = &dispidPut; + _Check_return_ HRESULT GetPropertyByName( + _In_z_ LPCOLESTR lpsz, + _Out_ VARIANT* pVar) throw() + { + ATLASSERT(p); + ATLASSERT(pVar); + DISPID dwDispID; + HRESULT hr = GetIDOfName(lpsz, &dwDispID); + if (SUCCEEDED(hr)) + hr = GetProperty(dwDispID, pVar); + return hr; + } + _Check_return_ HRESULT GetProperty( + _In_ DISPID dwDispID, + _Out_ VARIANT* pVar) throw() + { + return GetProperty(p, dwDispID, pVar); + } + _Check_return_ HRESULT PutPropertyByName( + _In_z_ LPCOLESTR lpsz, + _In_ VARIANT* pVar) throw() + { + ATLASSERT(p); + ATLASSERT(pVar); + DISPID dwDispID; + HRESULT hr = GetIDOfName(lpsz, &dwDispID); + if (SUCCEEDED(hr)) + hr = PutProperty(dwDispID, pVar); + return hr; + } + _Check_return_ HRESULT PutProperty( + _In_ DISPID dwDispID, + _In_ VARIANT* pVar) throw() + { + return PutProperty(p, dwDispID, pVar); + } + _Check_return_ HRESULT GetIDOfName( + _In_z_ LPCOLESTR lpsz, + _Out_ DISPID* pdispid) throw() + { + return p->GetIDsOfNames(IID_NULL, const_cast(&lpsz), 1, LOCALE_USER_DEFAULT, pdispid); + } + // Invoke a method by DISPID with no parameters + _Check_return_ HRESULT Invoke0( + _In_ DISPID dispid, + _Out_opt_ VARIANT* pvarRet = NULL) throw() + { + DISPPARAMS dispparams = { NULL, NULL, 0, 0}; + return p->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispparams, pvarRet, NULL, NULL); + } + // Invoke a method by name with no parameters + _Check_return_ HRESULT Invoke0( + _In_z_ LPCOLESTR lpszName, + _Out_opt_ VARIANT* pvarRet = NULL) throw() + { + HRESULT hr; + DISPID dispid; + hr = GetIDOfName(lpszName, &dispid); + if (SUCCEEDED(hr)) + hr = Invoke0(dispid, pvarRet); + return hr; + } + // Invoke a method by DISPID with a single parameter + _Check_return_ HRESULT Invoke1( + _In_ DISPID dispid, + _In_ VARIANT* pvarParam1, + _Out_opt_ VARIANT* pvarRet = NULL) throw() + { + DISPPARAMS dispparams = { pvarParam1, NULL, 1, 0}; + return p->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispparams, pvarRet, NULL, NULL); + } + // Invoke a method by name with a single parameter + _Check_return_ HRESULT Invoke1( + _In_z_ LPCOLESTR lpszName, + _In_ VARIANT* pvarParam1, + _Out_opt_ VARIANT* pvarRet = NULL) throw() + { + DISPID dispid; + HRESULT hr = GetIDOfName(lpszName, &dispid); + if (SUCCEEDED(hr)) + hr = Invoke1(dispid, pvarParam1, pvarRet); + return hr; + } + // Invoke a method by DISPID with two parameters + _Check_return_ HRESULT Invoke2( + _In_ DISPID dispid, + _In_ VARIANT* pvarParam1, + _In_ VARIANT* pvarParam2, + _Out_opt_ VARIANT* pvarRet = NULL) throw(); + // Invoke a method by name with two parameters + _Check_return_ HRESULT Invoke2( + _In_z_ LPCOLESTR lpszName, + _In_ VARIANT* pvarParam1, + _In_ VARIANT* pvarParam2, + _Out_opt_ VARIANT* pvarRet = NULL) throw() + { + DISPID dispid; + HRESULT hr = GetIDOfName(lpszName, &dispid); + if (SUCCEEDED(hr)) + hr = Invoke2(dispid, pvarParam1, pvarParam2, pvarRet); + return hr; + } + // Invoke a method by DISPID with N parameters + _Check_return_ HRESULT InvokeN( + _In_ DISPID dispid, + _In_ VARIANT* pvarParams, + _In_ int nParams, + _Out_opt_ VARIANT* pvarRet = NULL) throw() + { + DISPPARAMS dispparams = { pvarParams, NULL, nParams, 0}; + return p->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispparams, pvarRet, NULL, NULL); + } + // Invoke a method by name with Nparameters + _Check_return_ HRESULT InvokeN( + _In_z_ LPCOLESTR lpszName, + _In_ VARIANT* pvarParams, + _In_ int nParams, + _Out_opt_ VARIANT* pvarRet = NULL) throw() + { + HRESULT hr; + DISPID dispid; + hr = GetIDOfName(lpszName, &dispid); + if (SUCCEEDED(hr)) + hr = InvokeN(dispid, pvarParams, nParams, pvarRet); + return hr; + } + _Check_return_ static HRESULT PutProperty( + _In_ IDispatch* p, + _In_ DISPID dwDispID, + _In_ VARIANT* pVar) throw() + { + ATLASSERT(p); + ATLASSERT(pVar != NULL); + if (pVar == NULL) + return E_POINTER; + + if(p == NULL) + return E_INVALIDARG; + + DISPPARAMS dispparams = {NULL, NULL, 1, 1}; + dispparams.rgvarg = pVar; + DISPID dispidPut = DISPID_PROPERTYPUT; + dispparams.rgdispidNamedArgs = &dispidPut; - if (pVar->vt == VT_UNKNOWN || pVar->vt == VT_DISPATCH || - (pVar->vt & VT_ARRAY) || (pVar->vt & VT_BYREF)) - { - HRESULT hr = p->Invoke(dwDispID, IID_NULL, - LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUTREF, - &dispparams, NULL, NULL, NULL); - if (SUCCEEDED(hr)) - return hr; - } - return p->Invoke(dwDispID, IID_NULL, - LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT, - &dispparams, NULL, NULL, NULL); - } - _Check_return_ static HRESULT GetProperty( - _In_ IDispatch* p, - _In_ DISPID dwDispID, - _Out_ VARIANT* pVar) throw() - { - ATLASSERT(p); - ATLASSERT(pVar != NULL); - if (pVar == NULL) - return E_POINTER; - - if(p == NULL) - return E_INVALIDARG; - - DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; - return p->Invoke(dwDispID, IID_NULL, - LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, - &dispparamsNoArgs, pVar, NULL, NULL); - } + if (pVar->vt == VT_UNKNOWN || pVar->vt == VT_DISPATCH || + (pVar->vt & VT_ARRAY) || (pVar->vt & VT_BYREF)) + { + HRESULT hr = p->Invoke(dwDispID, IID_NULL, + LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUTREF, + &dispparams, NULL, NULL, NULL); + if (SUCCEEDED(hr)) + return hr; + } + return p->Invoke(dwDispID, IID_NULL, + LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT, + &dispparams, NULL, NULL, NULL); + } + _Check_return_ static HRESULT GetProperty( + _In_ IDispatch* p, + _In_ DISPID dwDispID, + _Out_ VARIANT* pVar) throw() + { + ATLASSERT(p); + ATLASSERT(pVar != NULL); + if (pVar == NULL) + return E_POINTER; + + if(p == NULL) + return E_INVALIDARG; + + DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; + return p->Invoke(dwDispID, IID_NULL, + LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, + &dispparamsNoArgs, pVar, NULL, NULL); + } }; template class CComQIPtr : - public CComPtr + public CComPtr { public: - CComQIPtr() throw() - { - } - CComQIPtr(_Inout_opt_ T* lp) throw() : - CComPtr(lp) - { - } - CComQIPtr(_Inout_ const CComQIPtr& lp) throw() : - CComPtr(lp.p) - { - } - CComQIPtr(_Inout_opt_ IUnknown* lp) throw() - { - if (lp != NULL) - lp->QueryInterface(*piid, (void **)&this->p); - } - T* operator=(_Inout_opt_ T* lp) throw() - { + CComQIPtr() throw() + { + } + CComQIPtr(_Inout_opt_ T* lp) throw() : + CComPtr(lp) + { + } + CComQIPtr(_Inout_ const CComQIPtr& lp) throw() : + CComPtr(lp.p) + { + } + CComQIPtr(_Inout_opt_ IUnknown* lp) throw() + { + if (lp != NULL) + lp->QueryInterface(*piid, (void **)&this->p); + } + T* operator=(_Inout_opt_ T* lp) throw() + { if(*this!=lp) { - return static_cast(AtlComPtrAssign((IUnknown**)&this->p, lp)); + return static_cast(AtlComPtrAssign((IUnknown**)&this->p, lp)); } return *this; - } - T* operator=(_Inout_ const CComQIPtr& lp) throw() - { + } + T* operator=(_Inout_ const CComQIPtr& lp) throw() + { if(*this!=lp) { - return static_cast(AtlComPtrAssign((IUnknown**)&this->p, lp.p)); + return static_cast(AtlComPtrAssign((IUnknown**)&this->p, lp.p)); } return *this; - } - T* operator=(_Inout_opt_ IUnknown* lp) throw() - { + } + T* operator=(_Inout_opt_ IUnknown* lp) throw() + { if(*this!=lp) { - return static_cast(AtlComQIPtrAssign((IUnknown**)&this->p, lp, *piid)); + return static_cast(AtlComQIPtrAssign((IUnknown**)&this->p, lp, *piid)); } return *this; - } + } }; //Specialization to make it work template<> class CComQIPtr : - public CComPtr + public CComPtr { public: - CComQIPtr() throw() - { - } - CComQIPtr(_Inout_opt_ IUnknown* lp) throw() - { - //Actually do a QI to get identity - if (lp != NULL) - lp->QueryInterface(__uuidof(IUnknown), (void **)&this->p); - } - CComQIPtr(_Inout_ const CComQIPtr& lp) throw() : - CComPtr(lp.p) - { - } - IUnknown* operator=(_Inout_opt_ IUnknown* lp) throw() - { + CComQIPtr() throw() + { + } + CComQIPtr(_Inout_opt_ IUnknown* lp) throw() + { + //Actually do a QI to get identity + if (lp != NULL) + lp->QueryInterface(__uuidof(IUnknown), (void **)&this->p); + } + CComQIPtr(_Inout_ const CComQIPtr& lp) throw() : + CComPtr(lp.p) + { + } + IUnknown* operator=(_Inout_opt_ IUnknown* lp) throw() + { if(*this!=lp) { - //Actually do a QI to get identity - return AtlComQIPtrAssign((IUnknown**)&this->p, lp, __uuidof(IUnknown)); + //Actually do a QI to get identity + return AtlComQIPtrAssign((IUnknown**)&this->p, lp, __uuidof(IUnknown)); } return *this; - } + } - IUnknown* operator=(_Inout_ const CComQIPtr& lp) throw() - { + IUnknown* operator=(_Inout_ const CComQIPtr& lp) throw() + { if(*this!=lp) { - return AtlComPtrAssign((IUnknown**)&this->p, lp.p); + return AtlComPtrAssign((IUnknown**)&this->p, lp.p); } return *this; - } + } }; #if !defined(__MINGW32__) @@ -679,164 +679,164 @@ typedef CComQIPtr CComDispatchDriver; class CComBSTR { public: - BSTR m_str; + BSTR m_str; - CComBSTR() throw() - { - m_str = NULL; - } + CComBSTR() throw() + { + m_str = NULL; + } #ifdef _ATL_CCOMBSTR_EXPLICIT_CONSTRUCTORS - explicit CComBSTR(_In_ int nSize) + explicit CComBSTR(_In_ int nSize) #else - CComBSTR(_In_ int nSize) + CComBSTR(_In_ int nSize) #endif - { - if (nSize < 0) - { - AtlThrow(E_INVALIDARG); - } - - if (nSize == 0) - { - m_str = NULL; - } - else - { - m_str = ::SysAllocStringLen(NULL, nSize); - if (!*this) - { - AtlThrow(E_OUTOFMEMORY); - } - } - } - - CComBSTR(_In_ int nSize, _In_opt_count_(nSize) LPCOLESTR sz) - { - if (nSize < 0) - { - AtlThrow(E_INVALIDARG); - } - - if (nSize == 0) + { + if (nSize < 0) { - m_str = NULL; + AtlThrow(E_INVALIDARG); } - else - { - m_str = ::SysAllocStringLen(sz, nSize); - if (!*this) - { - AtlThrow(E_OUTOFMEMORY); - } - } - } - - CComBSTR(_In_opt_z_ LPCOLESTR pSrc) - { - if (pSrc == NULL) + + if (nSize == 0) { - m_str = NULL; + m_str = NULL; } - else - { - m_str = ::SysAllocString(pSrc); - if (!*this) - { - AtlThrow(E_OUTOFMEMORY); - } - } - } - - CComBSTR(_In_ const CComBSTR& src) - { - m_str = src.Copy(); - if (!!src && !*this) + else { - AtlThrow(E_OUTOFMEMORY); - } - } - - CComBSTR(_In_ REFGUID guid) - { - OLECHAR szGUID[64]; - ::StringFromGUID2(guid, szGUID, 64); - m_str = ::SysAllocString(szGUID); - if (!*this) - { - AtlThrow(E_OUTOFMEMORY); - } - } - - CComBSTR& operator=(_In_ const CComBSTR& src) - { - if (m_str != src.m_str) - { - ::SysFreeString(m_str); - m_str = src.Copy(); - if (!!src && !*this) + m_str = ::SysAllocStringLen(NULL, nSize); + if (!*this) { - AtlThrow(E_OUTOFMEMORY); + AtlThrow(E_OUTOFMEMORY); } - } - return *this; - } + } + } - CComBSTR& operator=(_In_opt_z_ LPCOLESTR pSrc) - { - if (pSrc != m_str) - { - ::SysFreeString(m_str); - if (pSrc != NULL) - { - m_str = ::SysAllocString(pSrc); - if (!*this) + CComBSTR(_In_ int nSize, _In_opt_count_(nSize) LPCOLESTR sz) + { + if (nSize < 0) + { + AtlThrow(E_INVALIDARG); + } + + if (nSize == 0) + { + m_str = NULL; + } + else + { + m_str = ::SysAllocStringLen(sz, nSize); + if (!*this) + { + AtlThrow(E_OUTOFMEMORY); + } + } + } + + CComBSTR(_In_opt_z_ LPCOLESTR pSrc) + { + if (pSrc == NULL) + { + m_str = NULL; + } + else + { + m_str = ::SysAllocString(pSrc); + if (!*this) + { + AtlThrow(E_OUTOFMEMORY); + } + } + } + + CComBSTR(_In_ const CComBSTR& src) + { + m_str = src.Copy(); + if (!!src && !*this) + { + AtlThrow(E_OUTOFMEMORY); + } + } + + CComBSTR(_In_ REFGUID guid) + { + OLECHAR szGUID[64]; + ::StringFromGUID2(guid, szGUID, 64); + m_str = ::SysAllocString(szGUID); + if (!*this) + { + AtlThrow(E_OUTOFMEMORY); + } + } + + CComBSTR& operator=(_In_ const CComBSTR& src) + { + if (m_str != src.m_str) + { + ::SysFreeString(m_str); + m_str = src.Copy(); + if (!!src && !*this) + { + AtlThrow(E_OUTOFMEMORY); + } + } + return *this; + } + + CComBSTR& operator=(_In_opt_z_ LPCOLESTR pSrc) + { + if (pSrc != m_str) + { + ::SysFreeString(m_str); + if (pSrc != NULL) + { + m_str = ::SysAllocString(pSrc); + if (!*this) { - AtlThrow(E_OUTOFMEMORY); + AtlThrow(E_OUTOFMEMORY); } - } - else - { - m_str = NULL; } - } - return *this; - } + else + { + m_str = NULL; + } + } + return *this; + } #if !defined(__MINGW32__) - CComBSTR(_Inout_ CComBSTR&& src) - { - m_str = src.m_str; - src.m_str = NULL; - } - - CComBSTR& operator=(_Inout_ CComBSTR&& src) - { - if (m_str != src.m_str) - { - ::SysFreeString(m_str); - m_str = src.m_str; - src.m_str = NULL; - } - return *this; - } + CComBSTR(_Inout_ CComBSTR&& src) + { + m_str = src.m_str; + src.m_str = NULL; + } + + CComBSTR& operator=(_Inout_ CComBSTR&& src) + { + if (m_str != src.m_str) + { + ::SysFreeString(m_str); + m_str = src.m_str; + src.m_str = NULL; + } + return *this; + } #endif - - ~CComBSTR() throw(); + + ~CComBSTR() throw(); - unsigned int Length() const throw() - { + unsigned int Length() const throw() + { return ::SysStringLen(m_str); - } + } - unsigned int ByteLength() const throw() - { + unsigned int ByteLength() const throw() + { return ::SysStringByteLen(m_str); - } + } - operator BSTR() const throw() - { - return m_str; - } + operator BSTR() const throw() + { + return m_str; + } #ifndef ATL_CCOMBSTR_ADDRESS_OF_ASSERT @@ -845,798 +845,798 @@ public: #endif - BSTR* operator&() throw() - { + BSTR* operator&() throw() + { #ifndef ATL_NO_CCOMBSTR_ADDRESS_OF_ASSERT - ATLASSERT(!*this); + ATLASSERT(!*this); #endif - return &m_str; - } + return &m_str; + } - _Ret_opt_z_ BSTR Copy() const throw() - { - if (!*this) - { - return NULL; - } - else if (m_str != NULL) - { - return ::SysAllocStringByteLen((char*)m_str, ::SysStringByteLen(m_str)); - } - else - { - return ::SysAllocStringByteLen(NULL, 0); - } - } - - _Check_return_ HRESULT CopyTo(_Deref_out_opt_z_ BSTR* pbstr) const throw() - { - ATLASSERT(pbstr != NULL); - if (pbstr == NULL) + _Ret_opt_z_ BSTR Copy() const throw() + { + if (!*this) { - return E_POINTER; + return NULL; } - *pbstr = Copy(); - - if ((*pbstr == NULL) && (m_str != NULL)) + else if (m_str != NULL) { - return E_OUTOFMEMORY; + return ::SysAllocStringByteLen((char*)m_str, ::SysStringByteLen(m_str)); } - return S_OK; - } + else + { + return ::SysAllocStringByteLen(NULL, 0); + } + } - // copy BSTR to VARIANT - _Check_return_ HRESULT CopyTo(_Out_ VARIANT *pvarDest) const throw() - { - ATLASSERT(pvarDest != NULL); - HRESULT hRes = E_POINTER; - if (pvarDest != NULL) - { - pvarDest->vt = VT_BSTR; - pvarDest->bstrVal = Copy(); + _Check_return_ HRESULT CopyTo(_Deref_out_opt_z_ BSTR* pbstr) const throw() + { + ATLASSERT(pbstr != NULL); + if (pbstr == NULL) + { + return E_POINTER; + } + *pbstr = Copy(); - if (pvarDest->bstrVal == NULL && m_str != NULL) + if ((*pbstr == NULL) && (m_str != NULL)) + { + return E_OUTOFMEMORY; + } + return S_OK; + } + + // copy BSTR to VARIANT + _Check_return_ HRESULT CopyTo(_Out_ VARIANT *pvarDest) const throw() + { + ATLASSERT(pvarDest != NULL); + HRESULT hRes = E_POINTER; + if (pvarDest != NULL) + { + pvarDest->vt = VT_BSTR; + pvarDest->bstrVal = Copy(); + + if (pvarDest->bstrVal == NULL && m_str != NULL) { - hRes = E_OUTOFMEMORY; + hRes = E_OUTOFMEMORY; } - else + else { - hRes = S_OK; + hRes = S_OK; } - } - return hRes; - } + } + return hRes; + } - void Attach(_In_opt_z_ BSTR src) throw() - { - if (m_str != src) - { - ::SysFreeString(m_str); - m_str = src; - } - } + void Attach(_In_opt_z_ BSTR src) throw() + { + if (m_str != src) + { + ::SysFreeString(m_str); + m_str = src; + } + } - _Ret_opt_z_ BSTR Detach() throw() - { - BSTR s = m_str; - m_str = NULL; - return s; - } + _Ret_opt_z_ BSTR Detach() throw() + { + BSTR s = m_str; + m_str = NULL; + return s; + } - void Empty() throw() - { - ::SysFreeString(m_str); - m_str = NULL; - } + void Empty() throw() + { + ::SysFreeString(m_str); + m_str = NULL; + } - bool operator!() const throw() - { - return (m_str == NULL); - } + bool operator!() const throw() + { + return (m_str == NULL); + } - _Check_return_ HRESULT Append(_In_ const CComBSTR& bstrSrc) throw() - { - return AppendBSTR(bstrSrc.m_str); - } + _Check_return_ HRESULT Append(_In_ const CComBSTR& bstrSrc) throw() + { + return AppendBSTR(bstrSrc.m_str); + } -/* _Check_return_ HRESULT Append(_In_z_ LPCOLESTR lpsz) throw() - { - return Append(lpsz, UINT(wcslen(lpsz))); - } +/* _Check_return_ HRESULT Append(_In_z_ LPCOLESTR lpsz) throw() + { + return Append(lpsz, UINT(wcslen(lpsz))); + } */ - // a BSTR is just a LPCOLESTR so we need a special version to signify - // that we are appending a BSTR - _Check_return_ HRESULT AppendBSTR(_In_opt_z_ BSTR p) throw() - { + // a BSTR is just a LPCOLESTR so we need a special version to signify + // that we are appending a BSTR + _Check_return_ HRESULT AppendBSTR(_In_opt_z_ BSTR p) throw() + { if (::SysStringLen(p) == 0) { - return S_OK; + return S_OK; } - BSTR bstrNew = NULL; - HRESULT hr; - __analysis_assume(p); - hr = VarBstrCat(m_str, p, &bstrNew); - if (SUCCEEDED(hr)) - { - ::SysFreeString(m_str); - m_str = bstrNew; - } - return hr; - } - -/* _Check_return_ HRESULT Append(_In_opt_count_(nLen) LPCOLESTR lpsz, _In_ int nLen) throw() - { - if (lpsz == NULL || (m_str != NULL && nLen == 0)) - { - return S_OK; - } - else if (nLen < 0) - { - return E_INVALIDARG; - } - - const unsigned int n1 = Length(); - unsigned int n1Bytes = 0; - unsigned int nSize = 0; - unsigned int nSizeBytes = 0; - - HRESULT hr = AtlAdd(&nSize, n1, nLen); - if (FAILED(hr)) - { - return hr; - } - - hr = AtlMultiply(&nSizeBytes, nSize, sizeof(OLECHAR)); - if (FAILED(hr)) - { - return hr; - } - - hr = AtlMultiply(&n1Bytes, n1, sizeof(OLECHAR)); - if (FAILED(hr)) - { - return hr; - } - - BSTR b = ::SysAllocStringLen(NULL, nSize); - if (b == NULL) - { - return E_OUTOFMEMORY; - } - - if(::SysStringLen(m_str) > 0) - { - __analysis_assume(m_str); // ::SysStringLen(m_str) guarantees that m_str != NULL - Checked::memcpy_s(b, nSizeBytes, m_str, n1Bytes); - } - - Checked::memcpy_s(b+n1, nLen*sizeof(OLECHAR), lpsz, nLen*sizeof(OLECHAR)); - b[nSize] = '\0'; - SysFreeString(m_str); - m_str = b; - return S_OK; - } - - _Check_return_ HRESULT Append(_In_ char ch) throw() - { - OLECHAR chO = ch; - - return( Append( &chO, 1 ) ); - } - - _Check_return_ HRESULT Append(_In_ wchar_t ch) throw() - { - return( Append( &ch, 1 ) ); - } - - _Check_return_ HRESULT AppendBytes( - _In_opt_count_(nLen) const char* lpsz, - _In_ int nLen) throw() - { - if (lpsz == NULL || nLen == 0) - { - return S_OK; - } - else if (nLen < 0) - { - return E_INVALIDARG; - } - - const unsigned int n1 = ByteLength(); - unsigned int nSize = 0; - HRESULT hr = AtlAdd(&nSize, n1, nLen); - if (FAILED(hr)) - { - return hr; - } - - BSTR b = ::SysAllocStringByteLen(NULL, nSize); - if (b == NULL) + BSTR bstrNew = NULL; + HRESULT hr; + __analysis_assume(p); + hr = VarBstrCat(m_str, p, &bstrNew); + if (SUCCEEDED(hr)) { - return E_OUTOFMEMORY; + ::SysFreeString(m_str); + m_str = bstrNew; } - - Checked::memcpy_s(b, nSize, m_str, n1); - Checked::memcpy_s(((char*)b) + n1, nLen, lpsz, nLen); - - *((OLECHAR*)(((char*)b) + nSize)) = '\0'; - SysFreeString(m_str); - m_str = b; - return S_OK; - } + return hr; + } + +/* _Check_return_ HRESULT Append(_In_opt_count_(nLen) LPCOLESTR lpsz, _In_ int nLen) throw() + { + if (lpsz == NULL || (m_str != NULL && nLen == 0)) + { + return S_OK; + } + else if (nLen < 0) + { + return E_INVALIDARG; + } + + const unsigned int n1 = Length(); + unsigned int n1Bytes = 0; + unsigned int nSize = 0; + unsigned int nSizeBytes = 0; + + HRESULT hr = AtlAdd(&nSize, n1, nLen); + if (FAILED(hr)) + { + return hr; + } + + hr = AtlMultiply(&nSizeBytes, nSize, sizeof(OLECHAR)); + if (FAILED(hr)) + { + return hr; + } + + hr = AtlMultiply(&n1Bytes, n1, sizeof(OLECHAR)); + if (FAILED(hr)) + { + return hr; + } + + BSTR b = ::SysAllocStringLen(NULL, nSize); + if (b == NULL) + { + return E_OUTOFMEMORY; + } + + if(::SysStringLen(m_str) > 0) + { + __analysis_assume(m_str); // ::SysStringLen(m_str) guarantees that m_str != NULL + Checked::memcpy_s(b, nSizeBytes, m_str, n1Bytes); + } + + Checked::memcpy_s(b+n1, nLen*sizeof(OLECHAR), lpsz, nLen*sizeof(OLECHAR)); + b[nSize] = '\0'; + SysFreeString(m_str); + m_str = b; + return S_OK; + } + + _Check_return_ HRESULT Append(_In_ char ch) throw() + { + OLECHAR chO = ch; + + return( Append( &chO, 1 ) ); + } + + _Check_return_ HRESULT Append(_In_ wchar_t ch) throw() + { + return( Append( &ch, 1 ) ); + } + + _Check_return_ HRESULT AppendBytes( + _In_opt_count_(nLen) const char* lpsz, + _In_ int nLen) throw() + { + if (lpsz == NULL || nLen == 0) + { + return S_OK; + } + else if (nLen < 0) + { + return E_INVALIDARG; + } + + const unsigned int n1 = ByteLength(); + unsigned int nSize = 0; + HRESULT hr = AtlAdd(&nSize, n1, nLen); + if (FAILED(hr)) + { + return hr; + } + + BSTR b = ::SysAllocStringByteLen(NULL, nSize); + if (b == NULL) + { + return E_OUTOFMEMORY; + } + + Checked::memcpy_s(b, nSize, m_str, n1); + Checked::memcpy_s(((char*)b) + n1, nLen, lpsz, nLen); + + *((OLECHAR*)(((char*)b) + nSize)) = '\0'; + SysFreeString(m_str); + m_str = b; + return S_OK; + } */ - _Check_return_ HRESULT AssignBSTR(_In_opt_z_ const BSTR bstrSrc) throw() - { - HRESULT hr = S_OK; - if (m_str != bstrSrc) - { - ::SysFreeString(m_str); - if (bstrSrc != NULL) - { - m_str = ::SysAllocStringByteLen((char*)bstrSrc, ::SysStringByteLen(bstrSrc)); - if (!*this) - { - hr = E_OUTOFMEMORY; - } - } - else + _Check_return_ HRESULT AssignBSTR(_In_opt_z_ const BSTR bstrSrc) throw() + { + HRESULT hr = S_OK; + if (m_str != bstrSrc) + { + ::SysFreeString(m_str); + if (bstrSrc != NULL) { - m_str = NULL; + m_str = ::SysAllocStringByteLen((char*)bstrSrc, ::SysStringByteLen(bstrSrc)); + if (!*this) + { + hr = E_OUTOFMEMORY; + } } - } + else + { + m_str = NULL; + } + } - return hr; - } + return hr; + } - _Check_return_ HRESULT ToLower() throw() - { - if (::SysStringLen(m_str) > 0) - { + _Check_return_ HRESULT ToLower() throw() + { + if (::SysStringLen(m_str) > 0) + { #ifdef _UNICODE - // Convert in place - CharLowerBuff(m_str, Length()); + // Convert in place + CharLowerBuff(m_str, Length()); #else - // Cannot use conversion macros due to possible embedded NULLs - UINT _acp = _AtlGetConversionACP(); - int _convert = WideCharToMultiByte(_acp, 0, m_str, Length(), NULL, 0, NULL, NULL); - CTempBuffer pszA; - ATLTRY(pszA.Allocate(_convert)); - if (pszA == NULL) - return E_OUTOFMEMORY; + // Cannot use conversion macros due to possible embedded NULLs + UINT _acp = _AtlGetConversionACP(); + int _convert = WideCharToMultiByte(_acp, 0, m_str, Length(), NULL, 0, NULL, NULL); + CTempBuffer pszA; + ATLTRY(pszA.Allocate(_convert)); + if (pszA == NULL) + return E_OUTOFMEMORY; - int nRet = WideCharToMultiByte(_acp, 0, m_str, Length(), pszA, _convert, NULL, NULL); - if (nRet == 0) - { - ATLASSERT(0); - return AtlHresultFromLastError(); - } + int nRet = WideCharToMultiByte(_acp, 0, m_str, Length(), pszA, _convert, NULL, NULL); + if (nRet == 0) + { + ATLASSERT(0); + return AtlHresultFromLastError(); + } - CharLowerBuff(pszA, nRet); + CharLowerBuff(pszA, nRet); - _convert = MultiByteToWideChar(_acp, 0, pszA, nRet, NULL, 0); + _convert = MultiByteToWideChar(_acp, 0, pszA, nRet, NULL, 0); - CTempBuffer pszW; - ATLTRY(pszW.Allocate(_convert)); - if (pszW == NULL) - return E_OUTOFMEMORY; + CTempBuffer pszW; + ATLTRY(pszW.Allocate(_convert)); + if (pszW == NULL) + return E_OUTOFMEMORY; - nRet = MultiByteToWideChar(_acp, 0, pszA, nRet, pszW, _convert); - if (nRet <= 0) - { - ATLASSERT(0); - return AtlHresultFromLastError(); - } + nRet = MultiByteToWideChar(_acp, 0, pszA, nRet, pszW, _convert); + if (nRet <= 0) + { + ATLASSERT(0); + return AtlHresultFromLastError(); + } - UINT nBytes=0; - HRESULT hr=S_OK; - if( FAILED(hr=::ATL::AtlMultiply(&nBytes, static_cast(nRet), static_cast(sizeof(OLECHAR))))) - { - return hr; - } - BSTR b = ::SysAllocStringByteLen((LPCSTR) (LPWSTR) pszW, nBytes); - if (b == NULL) - return E_OUTOFMEMORY; - SysFreeString(m_str); - m_str = b; + UINT nBytes=0; + HRESULT hr=S_OK; + if( FAILED(hr=::ATL::AtlMultiply(&nBytes, static_cast(nRet), static_cast(sizeof(OLECHAR))))) + { + return hr; + } + BSTR b = ::SysAllocStringByteLen((LPCSTR) (LPWSTR) pszW, nBytes); + if (b == NULL) + return E_OUTOFMEMORY; + SysFreeString(m_str); + m_str = b; #endif - } - return S_OK; - } - _Check_return_ HRESULT ToUpper() throw() - { - if (::SysStringLen(m_str) > 0) - { + } + return S_OK; + } + _Check_return_ HRESULT ToUpper() throw() + { + if (::SysStringLen(m_str) > 0) + { #ifdef _UNICODE - // Convert in place - CharUpperBuff(m_str, Length()); + // Convert in place + CharUpperBuff(m_str, Length()); #else - // Cannot use conversion macros due to possible embedded NULLs - UINT _acp = _AtlGetConversionACP(); - int _convert = WideCharToMultiByte(_acp, 0, m_str, Length(), NULL, 0, NULL, NULL); - CTempBuffer pszA; - ATLTRY(pszA.Allocate(_convert)); - if (pszA == NULL) - return E_OUTOFMEMORY; + // Cannot use conversion macros due to possible embedded NULLs + UINT _acp = _AtlGetConversionACP(); + int _convert = WideCharToMultiByte(_acp, 0, m_str, Length(), NULL, 0, NULL, NULL); + CTempBuffer pszA; + ATLTRY(pszA.Allocate(_convert)); + if (pszA == NULL) + return E_OUTOFMEMORY; - int nRet = WideCharToMultiByte(_acp, 0, m_str, Length(), pszA, _convert, NULL, NULL); - if (nRet == 0) - { - ATLASSERT(0); - return AtlHresultFromLastError(); - } + int nRet = WideCharToMultiByte(_acp, 0, m_str, Length(), pszA, _convert, NULL, NULL); + if (nRet == 0) + { + ATLASSERT(0); + return AtlHresultFromLastError(); + } - CharUpperBuff(pszA, nRet); + CharUpperBuff(pszA, nRet); - _convert = MultiByteToWideChar(_acp, 0, pszA, nRet, NULL, 0); + _convert = MultiByteToWideChar(_acp, 0, pszA, nRet, NULL, 0); - CTempBuffer pszW; - ATLTRY(pszW.Allocate(_convert)); - if (pszW == NULL) - return E_OUTOFMEMORY; + CTempBuffer pszW; + ATLTRY(pszW.Allocate(_convert)); + if (pszW == NULL) + return E_OUTOFMEMORY; - nRet = MultiByteToWideChar(_acp, 0, pszA, nRet, pszW, _convert); - if (nRet <= 0) - { - ATLASSERT(0); - return AtlHresultFromLastError(); - } + nRet = MultiByteToWideChar(_acp, 0, pszA, nRet, pszW, _convert); + if (nRet <= 0) + { + ATLASSERT(0); + return AtlHresultFromLastError(); + } - UINT nBytes=0; - HRESULT hr=S_OK; - if( FAILED(hr=::ATL::AtlMultiply(&nBytes, static_cast(nRet), static_cast(sizeof(OLECHAR))))) - { - return hr; - } - BSTR b = ::SysAllocStringByteLen((LPCSTR) (LPWSTR) pszW, nBytes); - if (b == NULL) - return E_OUTOFMEMORY; - SysFreeString(m_str); - m_str = b; + UINT nBytes=0; + HRESULT hr=S_OK; + if( FAILED(hr=::ATL::AtlMultiply(&nBytes, static_cast(nRet), static_cast(sizeof(OLECHAR))))) + { + return hr; + } + BSTR b = ::SysAllocStringByteLen((LPCSTR) (LPWSTR) pszW, nBytes); + if (b == NULL) + return E_OUTOFMEMORY; + SysFreeString(m_str); + m_str = b; #endif - } - return S_OK; - } + } + return S_OK; + } - bool LoadString( - _In_ HINSTANCE hInst, - _In_ UINT nID) throw() - { - ::SysFreeString(m_str); - m_str = NULL; - return LoadStringResource(hInst, nID, m_str); - } + bool LoadString( + _In_ HINSTANCE hInst, + _In_ UINT nID) throw() + { + ::SysFreeString(m_str); + m_str = NULL; + return LoadStringResource(hInst, nID, m_str); + } - bool LoadString(_In_ UINT nID) throw() - { - ::SysFreeString(m_str); - m_str = NULL; - return LoadStringResource(nID, m_str); - } + bool LoadString(_In_ UINT nID) throw() + { + ::SysFreeString(m_str); + m_str = NULL; + return LoadStringResource(nID, m_str); + } - CComBSTR& operator+=(_In_ const CComBSTR& bstrSrc) - { - HRESULT hr; - hr = AppendBSTR(bstrSrc.m_str); - if (FAILED(hr)) - AtlThrow(hr); - return *this; - } + CComBSTR& operator+=(_In_ const CComBSTR& bstrSrc) + { + HRESULT hr; + hr = AppendBSTR(bstrSrc.m_str); + if (FAILED(hr)) + AtlThrow(hr); + return *this; + } - CComBSTR& operator+=(_In_z_ LPCOLESTR pszSrc) - { - HRESULT hr; - hr = Append(pszSrc); - if (FAILED(hr)) - AtlThrow(hr); - return *this; - } + CComBSTR& operator+=(_In_z_ LPCOLESTR pszSrc) + { + HRESULT hr; + hr = Append(pszSrc); + if (FAILED(hr)) + AtlThrow(hr); + return *this; + } - bool operator<(_In_ const CComBSTR& bstrSrc) const throw() - { - return VarBstrCmp(m_str, bstrSrc.m_str, LOCALE_USER_DEFAULT, 0) == static_cast(VARCMP_LT); - } - bool operator<(_In_z_ LPCOLESTR pszSrc) const - { - CComBSTR bstr2(pszSrc); - return operator<(bstr2); - } - bool operator<(_In_z_ LPOLESTR pszSrc) const - { - return operator<((LPCOLESTR)pszSrc); - } + bool operator<(_In_ const CComBSTR& bstrSrc) const throw() + { + return VarBstrCmp(m_str, bstrSrc.m_str, LOCALE_USER_DEFAULT, 0) == static_cast(VARCMP_LT); + } + bool operator<(_In_z_ LPCOLESTR pszSrc) const + { + CComBSTR bstr2(pszSrc); + return operator<(bstr2); + } + bool operator<(_In_z_ LPOLESTR pszSrc) const + { + return operator<((LPCOLESTR)pszSrc); + } - bool operator>(_In_ const CComBSTR& bstrSrc) const throw() - { - return VarBstrCmp(m_str, bstrSrc.m_str, LOCALE_USER_DEFAULT, 0) == static_cast(VARCMP_GT); - } - bool operator>(_In_z_ LPCOLESTR pszSrc) const - { - CComBSTR bstr2(pszSrc); - return operator>(bstr2); - } - bool operator>(_In_z_ LPOLESTR pszSrc) const - { - return operator>((LPCOLESTR)pszSrc); - } - - bool operator!=(_In_ const CComBSTR& bstrSrc) const throw() - { - return !operator==(bstrSrc); - } - bool operator!=(_In_z_ LPCOLESTR pszSrc) const - { - return !operator==(pszSrc); - } - bool operator!=(_In_ int nNull) const throw() - { - return !operator==(nNull); - } - bool operator!=(_In_z_ LPOLESTR pszSrc) const - { - return operator!=((LPCOLESTR)pszSrc); - } - bool operator==(_In_ const CComBSTR& bstrSrc) const throw() - { - return VarBstrCmp(m_str, bstrSrc.m_str, LOCALE_USER_DEFAULT, 0) == static_cast(VARCMP_EQ); - } - bool operator==(LPCOLESTR pszSrc) const - { - CComBSTR bstr2(pszSrc); - return operator==(bstr2); - } - bool operator==(_In_z_ LPOLESTR pszSrc) const - { - return operator==((LPCOLESTR)pszSrc); - } - - bool operator==(_In_ int nNull) const throw() - { - ATLASSERT(nNull == 0); - (void)nNull; - return (!*this); - } + bool operator>(_In_ const CComBSTR& bstrSrc) const throw() + { + return VarBstrCmp(m_str, bstrSrc.m_str, LOCALE_USER_DEFAULT, 0) == static_cast(VARCMP_GT); + } + bool operator>(_In_z_ LPCOLESTR pszSrc) const + { + CComBSTR bstr2(pszSrc); + return operator>(bstr2); + } + bool operator>(_In_z_ LPOLESTR pszSrc) const + { + return operator>((LPCOLESTR)pszSrc); + } + + bool operator!=(_In_ const CComBSTR& bstrSrc) const throw() + { + return !operator==(bstrSrc); + } + bool operator!=(_In_z_ LPCOLESTR pszSrc) const + { + return !operator==(pszSrc); + } + bool operator!=(_In_ int nNull) const throw() + { + return !operator==(nNull); + } + bool operator!=(_In_z_ LPOLESTR pszSrc) const + { + return operator!=((LPCOLESTR)pszSrc); + } + bool operator==(_In_ const CComBSTR& bstrSrc) const throw() + { + return VarBstrCmp(m_str, bstrSrc.m_str, LOCALE_USER_DEFAULT, 0) == static_cast(VARCMP_EQ); + } + bool operator==(LPCOLESTR pszSrc) const + { + CComBSTR bstr2(pszSrc); + return operator==(bstr2); + } + bool operator==(_In_z_ LPOLESTR pszSrc) const + { + return operator==((LPCOLESTR)pszSrc); + } + + bool operator==(_In_ int nNull) const throw() + { + ATLASSERT(nNull == 0); + (void)nNull; + return (!*this); + } #if defined(_NATIVE_NULLPTR_SUPPORTED) && !defined(_DO_NOT_USE_NULLPTR_IN_ATL) - #ifdef _M_CEE - CComBSTR(decltype(__nullptr)) - { - m_str = NULL; - } - bool operator==(decltype(__nullptr)) const throw() - { - return *this == 0; - } - bool operator!=(decltype(__nullptr)) const throw() - { - return *this != 0; - } - #else // _M_CEE - CComBSTR(decltype(nullptr)) - { - m_str = NULL; - } - bool operator==(decltype(nullptr)) const throw() - { - return *this == 0; - } - bool operator!=(decltype(nullptr)) const throw() - { - return *this != 0; - } - #endif // _M_CEE + #ifdef _M_CEE + CComBSTR(decltype(__nullptr)) + { + m_str = NULL; + } + bool operator==(decltype(__nullptr)) const throw() + { + return *this == 0; + } + bool operator!=(decltype(__nullptr)) const throw() + { + return *this != 0; + } + #else // _M_CEE + CComBSTR(decltype(nullptr)) + { + m_str = NULL; + } + bool operator==(decltype(nullptr)) const throw() + { + return *this == 0; + } + bool operator!=(decltype(nullptr)) const throw() + { + return *this != 0; + } + #endif // _M_CEE #endif // defined(_NATIVE_NULLPTR_SUPPORTED) && !defined(_DO_NOT_USE_NULLPTR_IN_ATL) - CComBSTR(_In_opt_z_ LPCSTR pSrc) - { - if (pSrc != NULL) - { - m_str = A2WBSTR(pSrc); - if (!*this) + CComBSTR(_In_opt_z_ LPCSTR pSrc) + { + if (pSrc != NULL) + { + m_str = A2WBSTR(pSrc); + if (!*this) { - AtlThrow(E_OUTOFMEMORY); + AtlThrow(E_OUTOFMEMORY); } - } - else - { - m_str = NULL; } - } - - CComBSTR(_In_ int nSize, _In_opt_count_(nSize) LPCSTR sz) - { - if (nSize < 0) - { - AtlThrow(E_INVALIDARG); - } - - if (nSize != 0 && sz == NULL) - { - m_str = ::SysAllocStringLen(NULL, nSize); - if (!*this) - { - AtlThrow(E_OUTOFMEMORY); - } - return; - } - - m_str = A2WBSTR(sz, nSize); - if (!*this && nSize != 0) + else { - AtlThrow(E_OUTOFMEMORY); + m_str = NULL; } - } + } - _Check_return_ HRESULT Append(_In_opt_z_ LPCSTR lpsz) throw() - { - if (lpsz == NULL) - return S_OK; - - CComBSTR bstrTemp; - ATLTRY(bstrTemp = lpsz); - if (!bstrTemp) + CComBSTR(_In_ int nSize, _In_opt_count_(nSize) LPCSTR sz) + { + if (nSize < 0) { - return E_OUTOFMEMORY; + AtlThrow(E_INVALIDARG); } - return Append(bstrTemp); - } - - CComBSTR& operator=(_In_opt_z_ LPCSTR pSrc) - { - ::SysFreeString(m_str); - m_str = A2WBSTR(pSrc); - if (!*this && pSrc != NULL) + + if (nSize != 0 && sz == NULL) { - AtlThrow(E_OUTOFMEMORY); + m_str = ::SysAllocStringLen(NULL, nSize); + if (!*this) + { + AtlThrow(E_OUTOFMEMORY); + } + return; } - return *this; - } - bool operator<(_In_opt_z_ LPCSTR pszSrc) const - { - CComBSTR bstr2(pszSrc); - return operator<(bstr2); - } - bool operator>(_In_opt_z_ LPCSTR pszSrc) const - { - CComBSTR bstr2(pszSrc); - return operator>(bstr2); - } - bool operator!=(_In_opt_z_ LPCSTR pszSrc) const - { - return !operator==(pszSrc); - } - bool operator==(_In_opt_z_ LPCSTR pszSrc) const - { - CComBSTR bstr2(pszSrc); - return operator==(bstr2); - } + m_str = A2WBSTR(sz, nSize); + if (!*this && nSize != 0) + { + AtlThrow(E_OUTOFMEMORY); + } + } - _Check_return_ HRESULT WriteToStream(_Inout_ IStream* pStream) throw() - { - ATLASSERT(pStream != NULL); - if(pStream == NULL) - { - return E_INVALIDARG; - } - - ULONG cb; - ULONG cbStrLen = CComBSTR::GetStreamSize(m_str); - ATLASSERT(cbStrLen >= sizeof(ULONG)); - cbStrLen -= sizeof(ULONG); - - HRESULT hr = pStream->Write((void*) &cbStrLen, sizeof(cbStrLen), &cb); - if (FAILED(hr)) - { - return hr; - } - - if (cbStrLen == 0) - { - return S_OK; - } - return pStream->Write((void*) m_str, cbStrLen, &cb); - } + _Check_return_ HRESULT Append(_In_opt_z_ LPCSTR lpsz) throw() + { + if (lpsz == NULL) + return S_OK; - _Check_return_ HRESULT ReadFromStream(_Inout_ IStream* pStream) throw() - { - ATLASSERT(pStream != NULL); - if(pStream == NULL) - { - return E_INVALIDARG; - } + CComBSTR bstrTemp; + ATLTRY(bstrTemp = lpsz); + if (!bstrTemp) + { + return E_OUTOFMEMORY; + } + return Append(bstrTemp); + } - ATLASSERT(!*this); // should be empty - Empty(); - - HRESULT hrSeek; - ULARGE_INTEGER nBegOffset; - { - LARGE_INTEGER nZeroOffset; - nZeroOffset.QuadPart = 0L; - hrSeek = pStream->Seek(nZeroOffset, STREAM_SEEK_CUR, &nBegOffset); - } + CComBSTR& operator=(_In_opt_z_ LPCSTR pSrc) + { + ::SysFreeString(m_str); + m_str = A2WBSTR(pSrc); + if (!*this && pSrc != NULL) + { + AtlThrow(E_OUTOFMEMORY); + } + return *this; + } - ULONG cbRead = 0; - ULONG cbStrLen = 0; - HRESULT hr = pStream->Read(reinterpret_cast(&cbStrLen), sizeof(cbStrLen), &cbRead); + bool operator<(_In_opt_z_ LPCSTR pszSrc) const + { + CComBSTR bstr2(pszSrc); + return operator<(bstr2); + } + bool operator>(_In_opt_z_ LPCSTR pszSrc) const + { + CComBSTR bstr2(pszSrc); + return operator>(bstr2); + } + bool operator!=(_In_opt_z_ LPCSTR pszSrc) const + { + return !operator==(pszSrc); + } + bool operator==(_In_opt_z_ LPCSTR pszSrc) const + { + CComBSTR bstr2(pszSrc); + return operator==(bstr2); + } - if (SUCCEEDED(hr)) - { - // invalid data size - if (sizeof(cbStrLen) != cbRead) - { - hr = E_FAIL; - } - // read NULL string - else if (cbStrLen == 0) - { - } - // invalid data length - else if (cbStrLen < sizeof(OLECHAR)) - { - hr = E_FAIL; - } - // security checks when system hang for huge stream of data - else if (cbStrLen > _ATL_STREAM_MAX_SIZE) - { - hr = E_ACCESSDENIED; - } - else - { - //subtract size for terminating NULL which we wrote out - cbStrLen -= sizeof(OLECHAR); + _Check_return_ HRESULT WriteToStream(_Inout_ IStream* pStream) throw() + { + ATLASSERT(pStream != NULL); + if(pStream == NULL) + { + return E_INVALIDARG; + } + + ULONG cb; + ULONG cbStrLen = CComBSTR::GetStreamSize(m_str); + ATLASSERT(cbStrLen >= sizeof(ULONG)); + cbStrLen -= sizeof(ULONG); + + HRESULT hr = pStream->Write((void*) &cbStrLen, sizeof(cbStrLen), &cb); + if (FAILED(hr)) + { + return hr; + } + + if (cbStrLen == 0) + { + return S_OK; + } + return pStream->Write((void*) m_str, cbStrLen, &cb); + } - m_str = ::SysAllocStringByteLen(NULL, cbStrLen); - if (!*this) - { - hr = E_OUTOFMEMORY; - } - else - { - hr = pStream->Read(reinterpret_cast(m_str), cbStrLen, &cbRead); + _Check_return_ HRESULT ReadFromStream(_Inout_ IStream* pStream) throw() + { + ATLASSERT(pStream != NULL); + if(pStream == NULL) + { + return E_INVALIDARG; + } - if (SUCCEEDED(hr)) - { - if (cbRead != cbStrLen) - { - hr = E_FAIL; - } - else - { - OLECHAR ch; - hr = pStream->Read(reinterpret_cast(&ch), sizeof(OLECHAR), &cbRead); + ATLASSERT(!*this); // should be empty + Empty(); + + HRESULT hrSeek; + ULARGE_INTEGER nBegOffset; + { + LARGE_INTEGER nZeroOffset; + nZeroOffset.QuadPart = 0L; + hrSeek = pStream->Seek(nZeroOffset, STREAM_SEEK_CUR, &nBegOffset); + } - if (SUCCEEDED(hr)) - { + ULONG cbRead = 0; + ULONG cbStrLen = 0; + HRESULT hr = pStream->Read(reinterpret_cast(&cbStrLen), sizeof(cbStrLen), &cbRead); + + if (SUCCEEDED(hr)) + { + // invalid data size + if (sizeof(cbStrLen) != cbRead) + { + hr = E_FAIL; + } + // read NULL string + else if (cbStrLen == 0) + { + } + // invalid data length + else if (cbStrLen < sizeof(OLECHAR)) + { + hr = E_FAIL; + } + // security checks when system hang for huge stream of data + else if (cbStrLen > _ATL_STREAM_MAX_SIZE) + { + hr = E_ACCESSDENIED; + } + else + { + //subtract size for terminating NULL which we wrote out + cbStrLen -= sizeof(OLECHAR); + + m_str = ::SysAllocStringByteLen(NULL, cbStrLen); + if (!*this) + { + hr = E_OUTOFMEMORY; + } + else + { + hr = pStream->Read(reinterpret_cast(m_str), cbStrLen, &cbRead); + + if (SUCCEEDED(hr)) + { + if (cbRead != cbStrLen) + { + hr = E_FAIL; + } + else + { + OLECHAR ch; + hr = pStream->Read(reinterpret_cast(&ch), sizeof(OLECHAR), &cbRead); + + if (SUCCEEDED(hr)) + { #ifndef _ATL_CCOMBSTR_READFROMSTREAM_INSECURE - if (cbRead != sizeof(OLECHAR) || ch != L'\0') + if (cbRead != sizeof(OLECHAR) || ch != L'\0') #else - if (cbRead != sizeof(OLECHAR)) + if (cbRead != sizeof(OLECHAR)) #endif - { - hr = E_FAIL; - } - } - } - } - - if (FAILED(hr)) - { - ::SysFreeString(m_str); - m_str = NULL; - } - } - } - } - - // If SysAllocStringByteLen or IStream::Read failed, reset seek - // pointer to start of BSTR size. - if (FAILED(hr) && SUCCEEDED(hrSeek)) - { - LARGE_INTEGER nOffset; - nOffset.QuadPart = static_cast(nBegOffset.QuadPart); - pStream->Seek(nOffset, STREAM_SEEK_SET, NULL); - } - - return hr; - } + { + hr = E_FAIL; + } + } + } + } + + if (FAILED(hr)) + { + ::SysFreeString(m_str); + m_str = NULL; + } + } + } + } + + // If SysAllocStringByteLen or IStream::Read failed, reset seek + // pointer to start of BSTR size. + if (FAILED(hr) && SUCCEEDED(hrSeek)) + { + LARGE_INTEGER nOffset; + nOffset.QuadPart = static_cast(nBegOffset.QuadPart); + pStream->Seek(nOffset, STREAM_SEEK_SET, NULL); + } + + return hr; + } - static bool LoadStringResource( - _In_ HINSTANCE hInstance, - _In_ UINT uID, - _Deref_out_opt_z_ BSTR& bstrText) throw() - { + static bool LoadStringResource( + _In_ HINSTANCE hInstance, + _In_ UINT uID, + _Deref_out_opt_z_ BSTR& bstrText) throw() + { ATLPREFAST_SUPPRESS(6001) // Using uninitialized memory - ATLASSERT(bstrText == NULL); + ATLASSERT(bstrText == NULL); ATLPREFAST_UNSUPPRESS() - - const ATLSTRINGRESOURCEIMAGE* pImage = AtlGetStringResourceImage(hInstance, uID); - if (pImage != NULL) - { - bstrText = ::SysAllocStringLen(pImage->achString, pImage->nLength); - } - else - { - bstrText = NULL; - } - return (bstrText != NULL) ? true : false; - } + + const ATLSTRINGRESOURCEIMAGE* pImage = AtlGetStringResourceImage(hInstance, uID); + if (pImage != NULL) + { + bstrText = ::SysAllocStringLen(pImage->achString, pImage->nLength); + } + else + { + bstrText = NULL; + } + return (bstrText != NULL) ? true : false; + } - static bool LoadStringResource( - _In_ UINT uID, - _Deref_out_opt_z_ BSTR& bstrText) throw() - { + static bool LoadStringResource( + _In_ UINT uID, + _Deref_out_opt_z_ BSTR& bstrText) throw() + { ATLPREFAST_SUPPRESS(6001) // Using uninitialized memory - ATLASSERT(bstrText == NULL); + ATLASSERT(bstrText == NULL); ATLPREFAST_UNSUPPRESS() - - const ATLSTRINGRESOURCEIMAGE* pImage = AtlGetStringResourceImage(uID); - if (pImage != NULL) - { - bstrText = ::SysAllocStringLen(pImage->achString, pImage->nLength); - } - else - { - bstrText = NULL; - } + + const ATLSTRINGRESOURCEIMAGE* pImage = AtlGetStringResourceImage(uID); + if (pImage != NULL) + { + bstrText = ::SysAllocStringLen(pImage->achString, pImage->nLength); + } + else + { + bstrText = NULL; + } - return (bstrText != NULL) ? true : false; - } + return (bstrText != NULL) ? true : false; + } - // each character in BSTR is copied to each element in SAFEARRAY - HRESULT BSTRToArray(_Deref_out_ LPSAFEARRAY *ppArray) throw() - { - return VectorFromBstr(m_str, ppArray); - } + // each character in BSTR is copied to each element in SAFEARRAY + HRESULT BSTRToArray(_Deref_out_ LPSAFEARRAY *ppArray) throw() + { + return VectorFromBstr(m_str, ppArray); + } - // first character of each element in SAFEARRAY is copied to BSTR - _Check_return_ HRESULT ArrayToBSTR(_In_ const SAFEARRAY *pSrc) throw() - { - ::SysFreeString(m_str); - return BstrFromVector((LPSAFEARRAY)pSrc, &m_str); - } - static ULONG GetStreamSize(_In_opt_z_ BSTR bstr) - { - ULONG ulSize = sizeof(ULONG); - if (bstr != NULL) - { - ulSize += SysStringByteLen(bstr) + sizeof(OLECHAR); - } - - return ulSize; - } + // first character of each element in SAFEARRAY is copied to BSTR + _Check_return_ HRESULT ArrayToBSTR(_In_ const SAFEARRAY *pSrc) throw() + { + ::SysFreeString(m_str); + return BstrFromVector((LPSAFEARRAY)pSrc, &m_str); + } + static ULONG GetStreamSize(_In_opt_z_ BSTR bstr) + { + ULONG ulSize = sizeof(ULONG); + if (bstr != NULL) + { + ulSize += SysStringByteLen(bstr) + sizeof(OLECHAR); + } + + return ulSize; + } }; inline CComBSTR::~CComBSTR() throw() - { - ::SysFreeString(m_str); - } + { + ::SysFreeString(m_str); + } inline void SysFreeStringHelper(_In_ CComBSTR& bstr) { - bstr.Empty(); + bstr.Empty(); } inline void SysFreeStringHelper(_In_opt_z_ BSTR bstr) { - ::SysFreeString(bstr); + ::SysFreeString(bstr); } _Check_return_ inline HRESULT SysAllocStringHelper( - _Out_ CComBSTR& bstrDest, - _In_opt_z_ BSTR bstrSrc) + _Out_ CComBSTR& bstrDest, + _In_opt_z_ BSTR bstrSrc) { - bstrDest=bstrSrc; - return !bstrDest ? E_OUTOFMEMORY : S_OK; + bstrDest=bstrSrc; + return !bstrDest ? E_OUTOFMEMORY : S_OK; } _Check_return_ inline HRESULT SysAllocStringHelper( - _Out_ BSTR& bstrDest, - _In_opt_z_ BSTR bstrSrc) + _Out_ BSTR& bstrDest, + _In_opt_z_ BSTR bstrSrc) { - bstrDest=::SysAllocString(bstrSrc); + bstrDest=::SysAllocString(bstrSrc); - return bstrDest==NULL ? E_OUTOFMEMORY : S_OK; + return bstrDest==NULL ? E_OUTOFMEMORY : S_OK; } ///////////////////////////////////////////////////////////// @@ -1648,84 +1648,84 @@ template class CAdapt { public: - CAdapt() - { - } - CAdapt(_In_ const T& rSrc) : - m_T( rSrc ) - { - } - CAdapt(_In_ const CAdapt& rSrCA) : - m_T( rSrCA.m_T ) - { - } - CAdapt& operator=(_In_ const T& rSrc) - { - m_T = rSrc; + CAdapt() + { + } + CAdapt(_In_ const T& rSrc) : + m_T( rSrc ) + { + } + CAdapt(_In_ const CAdapt& rSrCA) : + m_T( rSrCA.m_T ) + { + } + CAdapt& operator=(_In_ const T& rSrc) + { + m_T = rSrc; - return *this; - } - CAdapt& operator=(_In_ const CAdapt& rSrc) - { - if (this != &rSrc) - { - m_T = rSrc.m_T; - } - return *this; - } + return *this; + } + CAdapt& operator=(_In_ const CAdapt& rSrc) + { + if (this != &rSrc) + { + m_T = rSrc.m_T; + } + return *this; + } #if !defined(__MINGW32__) - CAdapt(_Inout_ T&& rSrc) : - m_T( static_cast(rSrc) ) - { - } - CAdapt(_Inout_ CAdapt&& rSrCA) : - m_T( static_cast(rSrCA.m_T) ) - { - } - CAdapt& operator=(_Inout_ T&& rSrc) - { - m_T = static_cast(rSrc); - - return *this; - } - CAdapt& operator=(_Inout_ CAdapt&& rSrc) - { - if (this != &rSrc) - { - m_T = static_cast( rSrc.m_T ); - } - return *this; - } + CAdapt(_Inout_ T&& rSrc) : + m_T( static_cast(rSrc) ) + { + } + CAdapt(_Inout_ CAdapt&& rSrCA) : + m_T( static_cast(rSrCA.m_T) ) + { + } + CAdapt& operator=(_Inout_ T&& rSrc) + { + m_T = static_cast(rSrc); + + return *this; + } + CAdapt& operator=(_Inout_ CAdapt&& rSrc) + { + if (this != &rSrc) + { + m_T = static_cast( rSrc.m_T ); + } + return *this; + } #endif - bool operator<(_In_ const T& rSrc) const - { - return m_T < rSrc; - } - bool operator==(_In_ const T& rSrc) const - { - return m_T == rSrc; - } - operator T&() - { - return m_T; - } + bool operator<(_In_ const T& rSrc) const + { + return m_T < rSrc; + } + bool operator==(_In_ const T& rSrc) const + { + return m_T == rSrc; + } + operator T&() + { + return m_T; + } - operator const T&() const - { - return m_T; - } + operator const T&() const + { + return m_T; + } - T& operator->() - { - return m_T; - } + T& operator->() + { + return m_T; + } - const T& operator->() const - { - return m_T; - } + const T& operator->() const + { + return m_T; + } - T m_T; + T m_T; }; ///////////////////////////////////////////////////////////////////////////// @@ -1738,16 +1738,16 @@ public: template< typename T > class _CVarTypeInfo { -// static const VARTYPE VT; // VARTYPE corresponding to type T -// static T VARIANT::* const pmField; // Pointer-to-member of corresponding field in VARIANT struct +// static const VARTYPE VT; // VARTYPE corresponding to type T +// static T VARIANT::* const pmField; // Pointer-to-member of corresponding field in VARIANT struct }; template< typename T > class CVarTypeInfo : public _CVarTypeInfo { -#if defined(_CHAR_UNSIGNED) && !defined(_ATL_ALLOW_CHAR_UNSIGNED) - ATLSTATIC_ASSERT(!(_CVarTypeInfo::VT == static_cast(VT_I1) || _CVarTypeInfo::VT == (VT_I1|VT_BYREF)), - "CVarTypeInfo< char > or CVarTypeInfo< char* > cannot be compiled with /J or _CHAR_UNSIGNED flag enabled"); +#if defined(_CHAR_UNSIGNED) && !defined(_ATL_ALLOW_CHAR_UNSIGNED) + ATLSTATIC_ASSERT(!(_CVarTypeInfo::VT == static_cast(VT_I1) || _CVarTypeInfo::VT == (VT_I1|VT_BYREF)), + "CVarTypeInfo< char > or CVarTypeInfo< char* > cannot be compiled with /J or _CHAR_UNSIGNED flag enabled"); #endif }; @@ -1755,8 +1755,8 @@ template<> class _CVarTypeInfo< char > { public: - static const VARTYPE VT = VT_I1; - static char VARIANT::* const pmField; + static const VARTYPE VT = VT_I1; + static char VARIANT::* const pmField; }; __declspec( selectany ) char VARIANT::* const _CVarTypeInfo< char >::pmField = &VARIANT::cVal; @@ -1765,8 +1765,8 @@ template<> class _CVarTypeInfo< unsigned char > { public: - static const VARTYPE VT = VT_UI1; - static unsigned char VARIANT::* const pmField; + static const VARTYPE VT = VT_UI1; + static unsigned char VARIANT::* const pmField; }; __declspec( selectany ) unsigned char VARIANT::* const _CVarTypeInfo< unsigned char >::pmField = &VARIANT::bVal; @@ -1775,8 +1775,8 @@ template<> class _CVarTypeInfo< char* > { public: - static const VARTYPE VT = VT_I1|VT_BYREF; - static char* VARIANT::* const pmField; + static const VARTYPE VT = VT_I1|VT_BYREF; + static char* VARIANT::* const pmField; }; __declspec( selectany ) char* VARIANT::* const _CVarTypeInfo< char* >::pmField = &VARIANT::pcVal; @@ -1785,8 +1785,8 @@ template<> class _CVarTypeInfo< unsigned char* > { public: - static const VARTYPE VT = VT_UI1|VT_BYREF; - static unsigned char* VARIANT::* const pmField; + static const VARTYPE VT = VT_UI1|VT_BYREF; + static unsigned char* VARIANT::* const pmField; }; __declspec( selectany ) unsigned char* VARIANT::* const _CVarTypeInfo< unsigned char* >::pmField = &VARIANT::pbVal; @@ -1795,8 +1795,8 @@ template<> class _CVarTypeInfo< short > { public: - static const VARTYPE VT = VT_I2; - static short VARIANT::* const pmField; + static const VARTYPE VT = VT_I2; + static short VARIANT::* const pmField; }; __declspec( selectany ) short VARIANT::* const _CVarTypeInfo< short >::pmField = &VARIANT::iVal; @@ -1805,8 +1805,8 @@ template<> class _CVarTypeInfo< short* > { public: - static const VARTYPE VT = VT_I2|VT_BYREF; - static short* VARIANT::* const pmField; + static const VARTYPE VT = VT_I2|VT_BYREF; + static short* VARIANT::* const pmField; }; __declspec( selectany ) short* VARIANT::* const _CVarTypeInfo< short* >::pmField = &VARIANT::piVal; @@ -1815,8 +1815,8 @@ template<> class _CVarTypeInfo< unsigned short > { public: - static const VARTYPE VT = VT_UI2; - static unsigned short VARIANT::* const pmField; + static const VARTYPE VT = VT_UI2; + static unsigned short VARIANT::* const pmField; }; __declspec( selectany ) unsigned short VARIANT::* const _CVarTypeInfo< unsigned short >::pmField = &VARIANT::uiVal; @@ -1826,8 +1826,8 @@ template<> class _CVarTypeInfo< unsigned short* > { public: - static const VARTYPE VT = VT_UI2|VT_BYREF; - static unsigned short* VARIANT::* const pmField; + static const VARTYPE VT = VT_UI2|VT_BYREF; + static unsigned short* VARIANT::* const pmField; }; __declspec( selectany ) unsigned short* VARIANT::* const _CVarTypeInfo< unsigned short* >::pmField = &VARIANT::puiVal; @@ -1837,8 +1837,8 @@ template<> class _CVarTypeInfo< int > { public: - static const VARTYPE VT = VT_I4; - static int VARIANT::* const pmField; + static const VARTYPE VT = VT_I4; + static int VARIANT::* const pmField; }; __declspec( selectany ) int VARIANT::* const _CVarTypeInfo< int >::pmField = &VARIANT::intVal; @@ -1847,8 +1847,8 @@ template<> class _CVarTypeInfo< int* > { public: - static const VARTYPE VT = VT_I4|VT_BYREF; - static int* VARIANT::* const pmField; + static const VARTYPE VT = VT_I4|VT_BYREF; + static int* VARIANT::* const pmField; }; __declspec( selectany ) int* VARIANT::* const _CVarTypeInfo< int* >::pmField = &VARIANT::pintVal; @@ -1857,8 +1857,8 @@ template<> class _CVarTypeInfo< unsigned int > { public: - static const VARTYPE VT = VT_UI4; - static unsigned int VARIANT::* const pmField; + static const VARTYPE VT = VT_UI4; + static unsigned int VARIANT::* const pmField; }; __declspec( selectany ) unsigned int VARIANT::* const _CVarTypeInfo< unsigned int >::pmField = &VARIANT::uintVal; @@ -1867,8 +1867,8 @@ template<> class _CVarTypeInfo< unsigned int* > { public: - static const VARTYPE VT = VT_UI4|VT_BYREF; - static unsigned int* VARIANT::* const pmField; + static const VARTYPE VT = VT_UI4|VT_BYREF; + static unsigned int* VARIANT::* const pmField; }; __declspec( selectany ) unsigned int* VARIANT::* const _CVarTypeInfo< unsigned int* >::pmField = &VARIANT::puintVal; @@ -1877,8 +1877,8 @@ template<> class _CVarTypeInfo< long > { public: - static const VARTYPE VT = VT_I4; - static long VARIANT::* const pmField; + static const VARTYPE VT = VT_I4; + static long VARIANT::* const pmField; }; __declspec( selectany ) long VARIANT::* const _CVarTypeInfo< long >::pmField = &VARIANT::lVal; @@ -1887,8 +1887,8 @@ template<> class _CVarTypeInfo< long* > { public: - static const VARTYPE VT = VT_I4|VT_BYREF; - static long* VARIANT::* const pmField; + static const VARTYPE VT = VT_I4|VT_BYREF; + static long* VARIANT::* const pmField; }; __declspec( selectany ) long* VARIANT::* const _CVarTypeInfo< long* >::pmField = &VARIANT::plVal; @@ -1897,8 +1897,8 @@ template<> class _CVarTypeInfo< unsigned long > { public: - static const VARTYPE VT = VT_UI4; - static unsigned long VARIANT::* const pmField; + static const VARTYPE VT = VT_UI4; + static unsigned long VARIANT::* const pmField; }; __declspec( selectany ) unsigned long VARIANT::* const _CVarTypeInfo< unsigned long >::pmField = &VARIANT::ulVal; @@ -1907,8 +1907,8 @@ template<> class _CVarTypeInfo< unsigned long* > { public: - static const VARTYPE VT = VT_UI4|VT_BYREF; - static unsigned long* VARIANT::* const pmField; + static const VARTYPE VT = VT_UI4|VT_BYREF; + static unsigned long* VARIANT::* const pmField; }; __declspec( selectany ) unsigned long* VARIANT::* const _CVarTypeInfo< unsigned long* >::pmField = &VARIANT::pulVal; @@ -1917,8 +1917,8 @@ template<> class _CVarTypeInfo< __int64 > { public: - static const VARTYPE VT = VT_I8; - static __int64 VARIANT::* const pmField; + static const VARTYPE VT = VT_I8; + static __int64 VARIANT::* const pmField; }; __declspec( selectany ) __int64 VARIANT::* const _CVarTypeInfo< __int64 >::pmField = &VARIANT::llVal; @@ -1927,8 +1927,8 @@ template<> class _CVarTypeInfo< __int64* > { public: - static const VARTYPE VT = VT_I8|VT_BYREF; - static __int64* VARIANT::* const pmField; + static const VARTYPE VT = VT_I8|VT_BYREF; + static __int64* VARIANT::* const pmField; }; __declspec( selectany ) __int64* VARIANT::* const _CVarTypeInfo< __int64* >::pmField = &VARIANT::pllVal; @@ -1937,8 +1937,8 @@ template<> class _CVarTypeInfo< unsigned __int64 > { public: - static const VARTYPE VT = VT_UI8; - static unsigned __int64 VARIANT::* const pmField; + static const VARTYPE VT = VT_UI8; + static unsigned __int64 VARIANT::* const pmField; }; __declspec( selectany ) unsigned __int64 VARIANT::* const _CVarTypeInfo< unsigned __int64 >::pmField = &VARIANT::ullVal; @@ -1947,8 +1947,8 @@ template<> class _CVarTypeInfo< unsigned __int64* > { public: - static const VARTYPE VT = VT_UI8|VT_BYREF; - static unsigned __int64* VARIANT::* const pmField; + static const VARTYPE VT = VT_UI8|VT_BYREF; + static unsigned __int64* VARIANT::* const pmField; }; __declspec( selectany ) unsigned __int64* VARIANT::* const _CVarTypeInfo< unsigned __int64* >::pmField = &VARIANT::pullVal; @@ -1957,8 +1957,8 @@ template<> class _CVarTypeInfo< float > { public: - static const VARTYPE VT = VT_R4; - static float VARIANT::* const pmField; + static const VARTYPE VT = VT_R4; + static float VARIANT::* const pmField; }; __declspec( selectany ) float VARIANT::* const _CVarTypeInfo< float >::pmField = &VARIANT::fltVal; @@ -1967,8 +1967,8 @@ template<> class _CVarTypeInfo< float* > { public: - static const VARTYPE VT = VT_R4|VT_BYREF; - static float* VARIANT::* const pmField; + static const VARTYPE VT = VT_R4|VT_BYREF; + static float* VARIANT::* const pmField; }; __declspec( selectany ) float* VARIANT::* const _CVarTypeInfo< float* >::pmField = &VARIANT::pfltVal; @@ -1977,8 +1977,8 @@ template<> class _CVarTypeInfo< double > { public: - static const VARTYPE VT = VT_R8; - static double VARIANT::* const pmField; + static const VARTYPE VT = VT_R8; + static double VARIANT::* const pmField; }; __declspec( selectany ) double VARIANT::* const _CVarTypeInfo< double >::pmField = &VARIANT::dblVal; @@ -1987,8 +1987,8 @@ template<> class _CVarTypeInfo< double* > { public: - static const VARTYPE VT = VT_R8|VT_BYREF; - static double* VARIANT::* const pmField; + static const VARTYPE VT = VT_R8|VT_BYREF; + static double* VARIANT::* const pmField; }; __declspec( selectany ) double* VARIANT::* const _CVarTypeInfo< double* >::pmField = &VARIANT::pdblVal; @@ -1998,15 +1998,15 @@ template<> class _CVarTypeInfo< VARIANT* > { public: - static const VARTYPE VT = VT_VARIANT|VT_BYREF; + static const VARTYPE VT = VT_VARIANT|VT_BYREF; }; template<> class _CVarTypeInfo< BSTR > { public: - static const VARTYPE VT = VT_BSTR; - static BSTR VARIANT::* const pmField; + static const VARTYPE VT = VT_BSTR; + static BSTR VARIANT::* const pmField; }; __declspec( selectany ) BSTR VARIANT::* const _CVarTypeInfo< BSTR >::pmField = &VARIANT::bstrVal; @@ -2015,8 +2015,8 @@ template<> class _CVarTypeInfo< BSTR* > { public: - static const VARTYPE VT = VT_BSTR|VT_BYREF; - static BSTR* VARIANT::* const pmField; + static const VARTYPE VT = VT_BSTR|VT_BYREF; + static BSTR* VARIANT::* const pmField; }; __declspec( selectany ) BSTR* VARIANT::* const _CVarTypeInfo< BSTR* >::pmField = &VARIANT::pbstrVal; @@ -2025,8 +2025,8 @@ template<> class _CVarTypeInfo< IUnknown* > { public: - static const VARTYPE VT = VT_UNKNOWN; - static IUnknown* VARIANT::* const pmField; + static const VARTYPE VT = VT_UNKNOWN; + static IUnknown* VARIANT::* const pmField; }; __declspec( selectany ) IUnknown* VARIANT::* const _CVarTypeInfo< IUnknown* >::pmField = &VARIANT::punkVal; @@ -2035,8 +2035,8 @@ template<> class _CVarTypeInfo< IUnknown** > { public: - static const VARTYPE VT = VT_UNKNOWN|VT_BYREF; - static IUnknown** VARIANT::* const pmField; + static const VARTYPE VT = VT_UNKNOWN|VT_BYREF; + static IUnknown** VARIANT::* const pmField; }; __declspec( selectany ) IUnknown** VARIANT::* const _CVarTypeInfo< IUnknown** >::pmField = &VARIANT::ppunkVal; @@ -2045,8 +2045,8 @@ template<> class _CVarTypeInfo< IDispatch* > { public: - static const VARTYPE VT = VT_DISPATCH; - static IDispatch* VARIANT::* const pmField; + static const VARTYPE VT = VT_DISPATCH; + static IDispatch* VARIANT::* const pmField; }; __declspec( selectany ) IDispatch* VARIANT::* const _CVarTypeInfo< IDispatch* >::pmField = &VARIANT::pdispVal; @@ -2055,8 +2055,8 @@ template<> class _CVarTypeInfo< IDispatch** > { public: - static const VARTYPE VT = VT_DISPATCH|VT_BYREF; - static IDispatch** VARIANT::* const pmField; + static const VARTYPE VT = VT_DISPATCH|VT_BYREF; + static IDispatch** VARIANT::* const pmField; }; __declspec( selectany ) IDispatch** VARIANT::* const _CVarTypeInfo< IDispatch** >::pmField = &VARIANT::ppdispVal; @@ -2065,8 +2065,8 @@ template<> class _CVarTypeInfo< CY > { public: - static const VARTYPE VT = VT_CY; - static CY VARIANT::* const pmField; + static const VARTYPE VT = VT_CY; + static CY VARIANT::* const pmField; }; __declspec( selectany ) CY VARIANT::* const _CVarTypeInfo< CY >::pmField = &VARIANT::cyVal; @@ -2075,1136 +2075,1136 @@ template<> class _CVarTypeInfo< CY* > { public: - static const VARTYPE VT = VT_CY|VT_BYREF; - static CY* VARIANT::* const pmField; + static const VARTYPE VT = VT_CY|VT_BYREF; + static CY* VARIANT::* const pmField; }; __declspec( selectany ) CY* VARIANT::* const _CVarTypeInfo< CY* >::pmField = &VARIANT::pcyVal; #ifdef _ATL_NO_VARIANT_THROW -#define ATLVARIANT_THROW() throw() +#define ATLVARIANT_THROW() throw() #else #define ATLVARIANT_THROW() #endif class CComVariant : - public tagVARIANT + public tagVARIANT { // Constructors public: - CComVariant() throw() - { - ::VariantInit(this); - } - ~CComVariant() throw() - { - HRESULT hr = Clear(); - ATLASSERT(SUCCEEDED(hr)); - (hr); - } - CComVariant(_In_ const VARIANT& varSrc) ATLVARIANT_THROW() - { - vt = VT_EMPTY; - InternalCopy(&varSrc); - } - CComVariant(_In_ const CComVariant& varSrc) ATLVARIANT_THROW() - { - vt = VT_EMPTY; - InternalCopy(&varSrc); - } - CComVariant(_In_z_ LPCOLESTR lpszSrc) ATLVARIANT_THROW() - { - vt = VT_EMPTY; - *this = lpszSrc; - } - CComVariant(_In_z_ LPCSTR lpszSrc) ATLVARIANT_THROW() - { - vt = VT_EMPTY; - *this = lpszSrc; - } - CComVariant(_In_ bool bSrc) throw() - { - vt = VT_BOOL; - boolVal = bSrc ? ATL_VARIANT_TRUE : ATL_VARIANT_FALSE; - } + CComVariant() throw() + { + ::VariantInit(this); + } + ~CComVariant() throw() + { + HRESULT hr = Clear(); + ATLASSERT(SUCCEEDED(hr)); + (hr); + } + CComVariant(_In_ const VARIANT& varSrc) ATLVARIANT_THROW() + { + vt = VT_EMPTY; + InternalCopy(&varSrc); + } + CComVariant(_In_ const CComVariant& varSrc) ATLVARIANT_THROW() + { + vt = VT_EMPTY; + InternalCopy(&varSrc); + } + CComVariant(_In_z_ LPCOLESTR lpszSrc) ATLVARIANT_THROW() + { + vt = VT_EMPTY; + *this = lpszSrc; + } + CComVariant(_In_z_ LPCSTR lpszSrc) ATLVARIANT_THROW() + { + vt = VT_EMPTY; + *this = lpszSrc; + } + CComVariant(_In_ bool bSrc) throw() + { + vt = VT_BOOL; + boolVal = bSrc ? ATL_VARIANT_TRUE : ATL_VARIANT_FALSE; + } - CComVariant(_In_ int nSrc, _In_ VARTYPE vtSrc = VT_I4) ATLVARIANT_THROW() - { - ATLASSERT(vtSrc == VT_I4 || vtSrc == VT_INT); - if (vtSrc == VT_I4 || vtSrc == VT_INT) - { - vt = vtSrc; - intVal = nSrc; - } - else - { - vt = VT_ERROR; - scode = E_INVALIDARG; + CComVariant(_In_ int nSrc, _In_ VARTYPE vtSrc = VT_I4) ATLVARIANT_THROW() + { + ATLASSERT(vtSrc == VT_I4 || vtSrc == VT_INT); + if (vtSrc == VT_I4 || vtSrc == VT_INT) + { + vt = vtSrc; + intVal = nSrc; + } + else + { + vt = VT_ERROR; + scode = E_INVALIDARG; #ifndef _ATL_NO_VARIANT_THROW - AtlThrow(E_INVALIDARG); -#endif - } - } + AtlThrow(E_INVALIDARG); +#endif + } + } - CComVariant(_In_ BYTE nSrc) throw() - { - vt = VT_UI1; - bVal = nSrc; - } - CComVariant(_In_ short nSrc) throw() - { - vt = VT_I2; - iVal = nSrc; - } - CComVariant(_In_ long nSrc, _In_ VARTYPE vtSrc = VT_I4) ATLVARIANT_THROW() - { - ATLASSERT(vtSrc == VT_I4 || vtSrc == VT_ERROR); - if (vtSrc == VT_I4 || vtSrc == VT_ERROR) - { - vt = vtSrc; - lVal = nSrc; - } - else - { - vt = VT_ERROR; - scode = E_INVALIDARG; + CComVariant(_In_ BYTE nSrc) throw() + { + vt = VT_UI1; + bVal = nSrc; + } + CComVariant(_In_ short nSrc) throw() + { + vt = VT_I2; + iVal = nSrc; + } + CComVariant(_In_ long nSrc, _In_ VARTYPE vtSrc = VT_I4) ATLVARIANT_THROW() + { + ATLASSERT(vtSrc == VT_I4 || vtSrc == VT_ERROR); + if (vtSrc == VT_I4 || vtSrc == VT_ERROR) + { + vt = vtSrc; + lVal = nSrc; + } + else + { + vt = VT_ERROR; + scode = E_INVALIDARG; #ifndef _ATL_NO_VARIANT_THROW - AtlThrow(E_INVALIDARG); + AtlThrow(E_INVALIDARG); #endif - } - } + } + } - CComVariant(_In_ float fltSrc) throw() - { - vt = VT_R4; - fltVal = fltSrc; - } - CComVariant(_In_ double dblSrc, _In_ VARTYPE vtSrc = VT_R8) ATLVARIANT_THROW() - { - ATLASSERT(vtSrc == VT_R8 || vtSrc == VT_DATE); - if (vtSrc == VT_R8 || vtSrc == VT_DATE) - { - vt = vtSrc; - dblVal = dblSrc; - } - else - { - vt = VT_ERROR; - scode = E_INVALIDARG; + CComVariant(_In_ float fltSrc) throw() + { + vt = VT_R4; + fltVal = fltSrc; + } + CComVariant(_In_ double dblSrc, _In_ VARTYPE vtSrc = VT_R8) ATLVARIANT_THROW() + { + ATLASSERT(vtSrc == VT_R8 || vtSrc == VT_DATE); + if (vtSrc == VT_R8 || vtSrc == VT_DATE) + { + vt = vtSrc; + dblVal = dblSrc; + } + else + { + vt = VT_ERROR; + scode = E_INVALIDARG; #ifndef _ATL_NO_VARIANT_THROW - AtlThrow(E_INVALIDARG); + AtlThrow(E_INVALIDARG); #endif - } - } + } + } #if (_WIN32_WINNT >= 0x0501) || defined(_ATL_SUPPORT_VT_I8) - CComVariant(_In_ LONGLONG nSrc) throw() - { - vt = VT_I8; - llVal = nSrc; - } - CComVariant(_In_ ULONGLONG nSrc) throw() - { - vt = VT_UI8; - ullVal = nSrc; - } + CComVariant(_In_ LONGLONG nSrc) throw() + { + vt = VT_I8; + llVal = nSrc; + } + CComVariant(_In_ ULONGLONG nSrc) throw() + { + vt = VT_UI8; + ullVal = nSrc; + } #endif - CComVariant(_In_ CY cySrc) throw() - { - vt = VT_CY; - cyVal.Hi = cySrc.Hi; - cyVal.Lo = cySrc.Lo; - } - CComVariant(_In_opt_ IDispatch* pSrc) throw() - { - vt = VT_DISPATCH; - pdispVal = pSrc; - // Need to AddRef as VariantClear will Release - if (pdispVal != NULL) - pdispVal->AddRef(); - } - CComVariant(_In_opt_ IUnknown* pSrc) throw() - { - vt = VT_UNKNOWN; - punkVal = pSrc; - // Need to AddRef as VariantClear will Release - if (punkVal != NULL) - punkVal->AddRef(); - } - CComVariant(_In_ char cSrc) throw() - { - vt = VT_I1; - cVal = cSrc; - } - CComVariant(_In_ unsigned short nSrc) throw() - { - vt = VT_UI2; - uiVal = nSrc; - } - CComVariant(_In_ unsigned long nSrc) throw() - { - vt = VT_UI4; - ulVal = nSrc; - } - CComVariant(_In_ unsigned int nSrc, _In_ VARTYPE vtSrc = VT_UI4) ATLVARIANT_THROW() - { - ATLASSERT(vtSrc == VT_UI4 || vtSrc == VT_UINT); - if (vtSrc == VT_UI4 || vtSrc == VT_UINT) - { - vt = vtSrc; - uintVal= nSrc; - } - else - { - vt = VT_ERROR; - scode = E_INVALIDARG; + CComVariant(_In_ CY cySrc) throw() + { + vt = VT_CY; + cyVal.Hi = cySrc.Hi; + cyVal.Lo = cySrc.Lo; + } + CComVariant(_In_opt_ IDispatch* pSrc) throw() + { + vt = VT_DISPATCH; + pdispVal = pSrc; + // Need to AddRef as VariantClear will Release + if (pdispVal != NULL) + pdispVal->AddRef(); + } + CComVariant(_In_opt_ IUnknown* pSrc) throw() + { + vt = VT_UNKNOWN; + punkVal = pSrc; + // Need to AddRef as VariantClear will Release + if (punkVal != NULL) + punkVal->AddRef(); + } + CComVariant(_In_ char cSrc) throw() + { + vt = VT_I1; + cVal = cSrc; + } + CComVariant(_In_ unsigned short nSrc) throw() + { + vt = VT_UI2; + uiVal = nSrc; + } + CComVariant(_In_ unsigned long nSrc) throw() + { + vt = VT_UI4; + ulVal = nSrc; + } + CComVariant(_In_ unsigned int nSrc, _In_ VARTYPE vtSrc = VT_UI4) ATLVARIANT_THROW() + { + ATLASSERT(vtSrc == VT_UI4 || vtSrc == VT_UINT); + if (vtSrc == VT_UI4 || vtSrc == VT_UINT) + { + vt = vtSrc; + uintVal= nSrc; + } + else + { + vt = VT_ERROR; + scode = E_INVALIDARG; #ifndef _ATL_NO_VARIANT_THROW - AtlThrow(E_INVALIDARG); + AtlThrow(E_INVALIDARG); #endif - } - } - CComVariant(_In_ const CComBSTR& bstrSrc) ATLVARIANT_THROW() - { - vt = VT_EMPTY; - *this = bstrSrc; - } - CComVariant(_In_ const SAFEARRAY *pSrc) ATLVARIANT_THROW() - { - ATLASSERT(pSrc != NULL); - if (pSrc == NULL) - { - vt = VT_ERROR; - scode = E_INVALIDARG; + } + } + CComVariant(_In_ const CComBSTR& bstrSrc) ATLVARIANT_THROW() + { + vt = VT_EMPTY; + *this = bstrSrc; + } + CComVariant(_In_ const SAFEARRAY *pSrc) ATLVARIANT_THROW() + { + ATLASSERT(pSrc != NULL); + if (pSrc == NULL) + { + vt = VT_ERROR; + scode = E_INVALIDARG; #ifndef _ATL_NO_VARIANT_THROW - AtlThrow(E_INVALIDARG); -#endif - } - else - { - LPSAFEARRAY pCopy; - HRESULT hRes = ::SafeArrayCopy((LPSAFEARRAY)pSrc, &pCopy); - if (SUCCEEDED(hRes)) - { - ::ATL::AtlSafeArrayGetActualVartype((LPSAFEARRAY)pSrc, &vt); - vt |= VT_ARRAY; - parray = pCopy; - } - else - { - vt = VT_ERROR; - scode = hRes; + AtlThrow(E_INVALIDARG); +#endif + } + else + { + LPSAFEARRAY pCopy; + HRESULT hRes = ::SafeArrayCopy((LPSAFEARRAY)pSrc, &pCopy); + if (SUCCEEDED(hRes)) + { + ::ATL::AtlSafeArrayGetActualVartype((LPSAFEARRAY)pSrc, &vt); + vt |= VT_ARRAY; + parray = pCopy; + } + else + { + vt = VT_ERROR; + scode = hRes; #ifndef _ATL_NO_VARIANT_THROW - if(hRes == E_OUTOFMEMORY) - { - AtlThrow(E_OUTOFMEMORY); - } - else - { - ATLENSURE_THROW(FALSE, hRes); - } + if(hRes == E_OUTOFMEMORY) + { + AtlThrow(E_OUTOFMEMORY); + } + else + { + ATLENSURE_THROW(FALSE, hRes); + } #endif - } - } - } + } + } + } // Assignment Operators public: - CComVariant& operator=(_In_ const CComVariant& varSrc) ATLVARIANT_THROW() - { + CComVariant& operator=(_In_ const CComVariant& varSrc) ATLVARIANT_THROW() + { if(this!=&varSrc) { - InternalCopy(&varSrc); + InternalCopy(&varSrc); } - return *this; - } - CComVariant& operator=(_In_ const VARIANT& varSrc) ATLVARIANT_THROW() - { + return *this; + } + CComVariant& operator=(_In_ const VARIANT& varSrc) ATLVARIANT_THROW() + { if(static_cast(this)!=&varSrc) { - InternalCopy(&varSrc); + InternalCopy(&varSrc); } - return *this; - } + return *this; + } - CComVariant& operator=(_In_ const CComBSTR& bstrSrc) ATLVARIANT_THROW() - { - ClearThrow(); + CComVariant& operator=(_In_ const CComBSTR& bstrSrc) ATLVARIANT_THROW() + { + ClearThrow(); - vt = VT_BSTR; - bstrVal = bstrSrc.Copy(); + vt = VT_BSTR; + bstrVal = bstrSrc.Copy(); - if (bstrVal == NULL && bstrSrc.m_str != NULL) - { - vt = VT_ERROR; - scode = E_OUTOFMEMORY; + if (bstrVal == NULL && bstrSrc.m_str != NULL) + { + vt = VT_ERROR; + scode = E_OUTOFMEMORY; #ifndef _ATL_NO_VARIANT_THROW - AtlThrow(E_OUTOFMEMORY); + AtlThrow(E_OUTOFMEMORY); #endif - } + } - return *this; - } + return *this; + } - CComVariant& operator=(_In_z_ LPCOLESTR lpszSrc) ATLVARIANT_THROW() - { - ClearThrow(); + CComVariant& operator=(_In_z_ LPCOLESTR lpszSrc) ATLVARIANT_THROW() + { + ClearThrow(); - vt = VT_BSTR; - bstrVal = ::SysAllocString(lpszSrc); + vt = VT_BSTR; + bstrVal = ::SysAllocString(lpszSrc); - if (bstrVal == NULL && lpszSrc != NULL) - { - vt = VT_ERROR; - scode = E_OUTOFMEMORY; + if (bstrVal == NULL && lpszSrc != NULL) + { + vt = VT_ERROR; + scode = E_OUTOFMEMORY; #ifndef _ATL_NO_VARIANT_THROW - AtlThrow(E_OUTOFMEMORY); + AtlThrow(E_OUTOFMEMORY); #endif - } - return *this; - } + } + return *this; + } - CComVariant& operator=(_In_z_ LPCSTR lpszSrc) ATLVARIANT_THROW() - { - USES_CONVERSION_EX; - ClearThrow(); + CComVariant& operator=(_In_z_ LPCSTR lpszSrc) ATLVARIANT_THROW() + { + USES_CONVERSION_EX; + ClearThrow(); - vt = VT_BSTR; - bstrVal = ::SysAllocString(A2COLE_EX(lpszSrc, _ATL_SAFE_ALLOCA_DEF_THRESHOLD)); + vt = VT_BSTR; + bstrVal = ::SysAllocString(A2COLE_EX(lpszSrc, _ATL_SAFE_ALLOCA_DEF_THRESHOLD)); - if (bstrVal == NULL && lpszSrc != NULL) - { - vt = VT_ERROR; - scode = E_OUTOFMEMORY; + if (bstrVal == NULL && lpszSrc != NULL) + { + vt = VT_ERROR; + scode = E_OUTOFMEMORY; #ifndef _ATL_NO_VARIANT_THROW - AtlThrow(E_OUTOFMEMORY); + AtlThrow(E_OUTOFMEMORY); #endif - } - return *this; - } + } + return *this; + } - CComVariant& operator=(_In_ bool bSrc) ATLVARIANT_THROW() - { - if (vt != VT_BOOL) - { - ClearThrow(); - vt = VT_BOOL; - } - boolVal = bSrc ? ATL_VARIANT_TRUE : ATL_VARIANT_FALSE; - return *this; - } + CComVariant& operator=(_In_ bool bSrc) ATLVARIANT_THROW() + { + if (vt != VT_BOOL) + { + ClearThrow(); + vt = VT_BOOL; + } + boolVal = bSrc ? ATL_VARIANT_TRUE : ATL_VARIANT_FALSE; + return *this; + } - CComVariant& operator=(_In_ int nSrc) ATLVARIANT_THROW() - { - if (vt != VT_I4) - { - ClearThrow(); - vt = VT_I4; - } - intVal = nSrc; + CComVariant& operator=(_In_ int nSrc) ATLVARIANT_THROW() + { + if (vt != VT_I4) + { + ClearThrow(); + vt = VT_I4; + } + intVal = nSrc; - return *this; - } + return *this; + } - CComVariant& operator=(_In_ BYTE nSrc) ATLVARIANT_THROW() - { - if (vt != VT_UI1) - { - ClearThrow(); - vt = VT_UI1; - } - bVal = nSrc; - return *this; - } + CComVariant& operator=(_In_ BYTE nSrc) ATLVARIANT_THROW() + { + if (vt != VT_UI1) + { + ClearThrow(); + vt = VT_UI1; + } + bVal = nSrc; + return *this; + } - CComVariant& operator=(_In_ short nSrc) ATLVARIANT_THROW() - { - if (vt != VT_I2) - { - ClearThrow(); - vt = VT_I2; - } - iVal = nSrc; - return *this; - } + CComVariant& operator=(_In_ short nSrc) ATLVARIANT_THROW() + { + if (vt != VT_I2) + { + ClearThrow(); + vt = VT_I2; + } + iVal = nSrc; + return *this; + } - CComVariant& operator=(_In_ long nSrc) ATLVARIANT_THROW() - { - if (vt != VT_I4) - { - ClearThrow(); - vt = VT_I4; - } - lVal = nSrc; - return *this; - } + CComVariant& operator=(_In_ long nSrc) ATLVARIANT_THROW() + { + if (vt != VT_I4) + { + ClearThrow(); + vt = VT_I4; + } + lVal = nSrc; + return *this; + } - CComVariant& operator=(_In_ float fltSrc) ATLVARIANT_THROW() - { - if (vt != VT_R4) - { - ClearThrow(); - vt = VT_R4; - } - fltVal = fltSrc; - return *this; - } + CComVariant& operator=(_In_ float fltSrc) ATLVARIANT_THROW() + { + if (vt != VT_R4) + { + ClearThrow(); + vt = VT_R4; + } + fltVal = fltSrc; + return *this; + } - CComVariant& operator=(_In_ double dblSrc) ATLVARIANT_THROW() - { - if (vt != VT_R8) - { - ClearThrow(); - vt = VT_R8; - } - dblVal = dblSrc; - return *this; - } + CComVariant& operator=(_In_ double dblSrc) ATLVARIANT_THROW() + { + if (vt != VT_R8) + { + ClearThrow(); + vt = VT_R8; + } + dblVal = dblSrc; + return *this; + } - CComVariant& operator=(_In_ CY cySrc) ATLVARIANT_THROW() - { - if (vt != VT_CY) - { - ClearThrow(); - vt = VT_CY; - } - cyVal.Hi = cySrc.Hi; - cyVal.Lo = cySrc.Lo; - return *this; - } + CComVariant& operator=(_In_ CY cySrc) ATLVARIANT_THROW() + { + if (vt != VT_CY) + { + ClearThrow(); + vt = VT_CY; + } + cyVal.Hi = cySrc.Hi; + cyVal.Lo = cySrc.Lo; + return *this; + } - CComVariant& operator=(_Inout_opt_ IDispatch* pSrc) ATLVARIANT_THROW() - { - ClearThrow(); - - vt = VT_DISPATCH; - pdispVal = pSrc; - // Need to AddRef as VariantClear will Release - if (pdispVal != NULL) - pdispVal->AddRef(); - return *this; - } + CComVariant& operator=(_Inout_opt_ IDispatch* pSrc) ATLVARIANT_THROW() + { + ClearThrow(); + + vt = VT_DISPATCH; + pdispVal = pSrc; + // Need to AddRef as VariantClear will Release + if (pdispVal != NULL) + pdispVal->AddRef(); + return *this; + } - CComVariant& operator=(_Inout_opt_ IUnknown* pSrc) ATLVARIANT_THROW() - { - ClearThrow(); - - vt = VT_UNKNOWN; - punkVal = pSrc; + CComVariant& operator=(_Inout_opt_ IUnknown* pSrc) ATLVARIANT_THROW() + { + ClearThrow(); + + vt = VT_UNKNOWN; + punkVal = pSrc; - // Need to AddRef as VariantClear will Release - if (punkVal != NULL) - punkVal->AddRef(); - return *this; - } + // Need to AddRef as VariantClear will Release + if (punkVal != NULL) + punkVal->AddRef(); + return *this; + } - CComVariant& operator=(_In_ char cSrc) ATLVARIANT_THROW() - { - if (vt != VT_I1) - { - ClearThrow(); - vt = VT_I1; - } - cVal = cSrc; - return *this; - } + CComVariant& operator=(_In_ char cSrc) ATLVARIANT_THROW() + { + if (vt != VT_I1) + { + ClearThrow(); + vt = VT_I1; + } + cVal = cSrc; + return *this; + } - CComVariant& operator=(_In_ unsigned short nSrc) ATLVARIANT_THROW() - { - if (vt != VT_UI2) - { - ClearThrow(); - vt = VT_UI2; - } - uiVal = nSrc; - return *this; - } + CComVariant& operator=(_In_ unsigned short nSrc) ATLVARIANT_THROW() + { + if (vt != VT_UI2) + { + ClearThrow(); + vt = VT_UI2; + } + uiVal = nSrc; + return *this; + } - CComVariant& operator=(_In_ unsigned long nSrc) ATLVARIANT_THROW() - { - if (vt != VT_UI4) - { - ClearThrow(); - vt = VT_UI4; - } - ulVal = nSrc; - return *this; - } + CComVariant& operator=(_In_ unsigned long nSrc) ATLVARIANT_THROW() + { + if (vt != VT_UI4) + { + ClearThrow(); + vt = VT_UI4; + } + ulVal = nSrc; + return *this; + } - CComVariant& operator=(_In_ unsigned int nSrc) ATLVARIANT_THROW() - { - if (vt != VT_UI4) - { - ClearThrow(); - vt = VT_UI4; - } - uintVal= nSrc; - return *this; - } + CComVariant& operator=(_In_ unsigned int nSrc) ATLVARIANT_THROW() + { + if (vt != VT_UI4) + { + ClearThrow(); + vt = VT_UI4; + } + uintVal= nSrc; + return *this; + } - CComVariant& operator=(_In_ BYTE* pbSrc) ATLVARIANT_THROW() - { - if (vt != (VT_UI1|VT_BYREF)) - { - ClearThrow(); - vt = VT_UI1|VT_BYREF; - } - pbVal = pbSrc; - return *this; - } + CComVariant& operator=(_In_ BYTE* pbSrc) ATLVARIANT_THROW() + { + if (vt != (VT_UI1|VT_BYREF)) + { + ClearThrow(); + vt = VT_UI1|VT_BYREF; + } + pbVal = pbSrc; + return *this; + } - CComVariant& operator=(_In_ short* pnSrc) ATLVARIANT_THROW() - { - if (vt != (VT_I2|VT_BYREF)) - { - ClearThrow(); - vt = VT_I2|VT_BYREF; - } - piVal = pnSrc; - return *this; - } + CComVariant& operator=(_In_ short* pnSrc) ATLVARIANT_THROW() + { + if (vt != (VT_I2|VT_BYREF)) + { + ClearThrow(); + vt = VT_I2|VT_BYREF; + } + piVal = pnSrc; + return *this; + } #ifdef _NATIVE_WCHAR_T_DEFINED - CComVariant& operator=(_In_ USHORT* pnSrc) ATLVARIANT_THROW() - { - if (vt != (VT_UI2|VT_BYREF)) - { - ClearThrow(); - vt = VT_UI2|VT_BYREF; - } - puiVal = pnSrc; - return *this; - } + CComVariant& operator=(_In_ USHORT* pnSrc) ATLVARIANT_THROW() + { + if (vt != (VT_UI2|VT_BYREF)) + { + ClearThrow(); + vt = VT_UI2|VT_BYREF; + } + puiVal = pnSrc; + return *this; + } #endif - CComVariant& operator=(_In_ int* pnSrc) ATLVARIANT_THROW() - { - if (vt != (VT_I4|VT_BYREF)) - { - ClearThrow(); - vt = VT_I4|VT_BYREF; - } - pintVal = pnSrc; - return *this; - } + CComVariant& operator=(_In_ int* pnSrc) ATLVARIANT_THROW() + { + if (vt != (VT_I4|VT_BYREF)) + { + ClearThrow(); + vt = VT_I4|VT_BYREF; + } + pintVal = pnSrc; + return *this; + } - CComVariant& operator=(_In_ UINT* pnSrc) ATLVARIANT_THROW() - { - if (vt != (VT_UI4|VT_BYREF)) - { - ClearThrow(); - vt = VT_UI4|VT_BYREF; - } - puintVal = pnSrc; - return *this; - } + CComVariant& operator=(_In_ UINT* pnSrc) ATLVARIANT_THROW() + { + if (vt != (VT_UI4|VT_BYREF)) + { + ClearThrow(); + vt = VT_UI4|VT_BYREF; + } + puintVal = pnSrc; + return *this; + } - CComVariant& operator=(_In_ long* pnSrc) ATLVARIANT_THROW() - { - if (vt != (VT_I4|VT_BYREF)) - { - ClearThrow(); - vt = VT_I4|VT_BYREF; - } - plVal = pnSrc; - return *this; - } + CComVariant& operator=(_In_ long* pnSrc) ATLVARIANT_THROW() + { + if (vt != (VT_I4|VT_BYREF)) + { + ClearThrow(); + vt = VT_I4|VT_BYREF; + } + plVal = pnSrc; + return *this; + } - CComVariant& operator=(_In_ ULONG* pnSrc) ATLVARIANT_THROW() - { - if (vt != (VT_UI4|VT_BYREF)) - { - ClearThrow(); - vt = VT_UI4|VT_BYREF; - } - pulVal = pnSrc; - return *this; - } + CComVariant& operator=(_In_ ULONG* pnSrc) ATLVARIANT_THROW() + { + if (vt != (VT_UI4|VT_BYREF)) + { + ClearThrow(); + vt = VT_UI4|VT_BYREF; + } + pulVal = pnSrc; + return *this; + } #if (_WIN32_WINNT >= 0x0501) || defined(_ATL_SUPPORT_VT_I8) - CComVariant& operator=(_In_ LONGLONG nSrc) ATLVARIANT_THROW() - { - if (vt != VT_I8) - { - ClearThrow(); - vt = VT_I8; - } - llVal = nSrc; + CComVariant& operator=(_In_ LONGLONG nSrc) ATLVARIANT_THROW() + { + if (vt != VT_I8) + { + ClearThrow(); + vt = VT_I8; + } + llVal = nSrc; - return *this; - } + return *this; + } - CComVariant& operator=(_In_ LONGLONG* pnSrc) ATLVARIANT_THROW() - { - if (vt != (VT_I8|VT_BYREF)) - { - ClearThrow(); - vt = VT_I8|VT_BYREF; - } - pllVal = pnSrc; - return *this; - } + CComVariant& operator=(_In_ LONGLONG* pnSrc) ATLVARIANT_THROW() + { + if (vt != (VT_I8|VT_BYREF)) + { + ClearThrow(); + vt = VT_I8|VT_BYREF; + } + pllVal = pnSrc; + return *this; + } - CComVariant& operator=(_In_ ULONGLONG nSrc) ATLVARIANT_THROW() - { - if (vt != VT_UI8) - { - ClearThrow(); - vt = VT_UI8; - } - ullVal = nSrc; + CComVariant& operator=(_In_ ULONGLONG nSrc) ATLVARIANT_THROW() + { + if (vt != VT_UI8) + { + ClearThrow(); + vt = VT_UI8; + } + ullVal = nSrc; - return *this; - } + return *this; + } - CComVariant& operator=(_In_ ULONGLONG* pnSrc) ATLVARIANT_THROW() - { - if (vt != (VT_UI8|VT_BYREF)) - { - ClearThrow(); - vt = VT_UI8|VT_BYREF; - } - pullVal = pnSrc; - return *this; - } + CComVariant& operator=(_In_ ULONGLONG* pnSrc) ATLVARIANT_THROW() + { + if (vt != (VT_UI8|VT_BYREF)) + { + ClearThrow(); + vt = VT_UI8|VT_BYREF; + } + pullVal = pnSrc; + return *this; + } #endif - CComVariant& operator=(_In_ float* pfSrc) ATLVARIANT_THROW() - { - if (vt != (VT_R4|VT_BYREF)) - { - ClearThrow(); - vt = VT_R4|VT_BYREF; - } - pfltVal = pfSrc; - return *this; - } + CComVariant& operator=(_In_ float* pfSrc) ATLVARIANT_THROW() + { + if (vt != (VT_R4|VT_BYREF)) + { + ClearThrow(); + vt = VT_R4|VT_BYREF; + } + pfltVal = pfSrc; + return *this; + } - CComVariant& operator=(_In_ double* pfSrc) ATLVARIANT_THROW() - { - if (vt != (VT_R8|VT_BYREF)) - { - ClearThrow(); - vt = VT_R8|VT_BYREF; - } - pdblVal = pfSrc; - return *this; - } + CComVariant& operator=(_In_ double* pfSrc) ATLVARIANT_THROW() + { + if (vt != (VT_R8|VT_BYREF)) + { + ClearThrow(); + vt = VT_R8|VT_BYREF; + } + pdblVal = pfSrc; + return *this; + } - CComVariant& operator=(_In_ const SAFEARRAY *pSrc) ATLVARIANT_THROW() - { - ATLASSERT(pSrc != NULL); - ClearThrow(); - - if (pSrc == NULL) - { - vt = VT_ERROR; - scode = E_INVALIDARG; + CComVariant& operator=(_In_ const SAFEARRAY *pSrc) ATLVARIANT_THROW() + { + ATLASSERT(pSrc != NULL); + ClearThrow(); + + if (pSrc == NULL) + { + vt = VT_ERROR; + scode = E_INVALIDARG; #ifndef _ATL_NO_VARIANT_THROW - AtlThrow(E_INVALIDARG); + AtlThrow(E_INVALIDARG); #endif - } - else - { - LPSAFEARRAY pCopy; - HRESULT hr = ::SafeArrayCopy((LPSAFEARRAY)pSrc, &pCopy); - if (SUCCEEDED(hr)) - { - ::ATL::AtlSafeArrayGetActualVartype((LPSAFEARRAY)pSrc, &vt); - vt |= VT_ARRAY; - parray = pCopy; - } - else - { - vt = VT_ERROR; - scode = hr; + } + else + { + LPSAFEARRAY pCopy; + HRESULT hr = ::SafeArrayCopy((LPSAFEARRAY)pSrc, &pCopy); + if (SUCCEEDED(hr)) + { + ::ATL::AtlSafeArrayGetActualVartype((LPSAFEARRAY)pSrc, &vt); + vt |= VT_ARRAY; + parray = pCopy; + } + else + { + vt = VT_ERROR; + scode = hr; #ifndef _ATL_NO_VARIANT_THROW - if(hr == E_OUTOFMEMORY) - { - AtlThrow(E_OUTOFMEMORY); - } - else - { - ATLENSURE_THROW(FALSE, hr); - } + if(hr == E_OUTOFMEMORY) + { + AtlThrow(E_OUTOFMEMORY); + } + else + { + ATLENSURE_THROW(FALSE, hr); + } #endif - } - } - - return *this; - } + } + } + + return *this; + } // Comparison Operators public: - bool operator==(_In_ const VARIANT& varSrc) const throw() - { - // For backwards compatibility - if (vt == VT_NULL && varSrc.vt == VT_NULL) - { - return true; - } - // Variants not equal if types don't match - if (vt != varSrc.vt) - { - return false; - } - return VarCmp((VARIANT*)this, (VARIANT*)&varSrc, LOCALE_USER_DEFAULT, 0) == static_cast(VARCMP_EQ); - } + bool operator==(_In_ const VARIANT& varSrc) const throw() + { + // For backwards compatibility + if (vt == VT_NULL && varSrc.vt == VT_NULL) + { + return true; + } + // Variants not equal if types don't match + if (vt != varSrc.vt) + { + return false; + } + return VarCmp((VARIANT*)this, (VARIANT*)&varSrc, LOCALE_USER_DEFAULT, 0) == static_cast(VARCMP_EQ); + } - bool operator!=(_In_ const VARIANT& varSrc) const throw() - { - return !operator==(varSrc); - } + bool operator!=(_In_ const VARIANT& varSrc) const throw() + { + return !operator==(varSrc); + } - bool operator<(_In_ const VARIANT& varSrc) const throw() - { - if (vt == VT_NULL && varSrc.vt == VT_NULL) - return false; - return VarCmp((VARIANT*)this, (VARIANT*)&varSrc, LOCALE_USER_DEFAULT, 0)== static_cast(VARCMP_LT); - } + bool operator<(_In_ const VARIANT& varSrc) const throw() + { + if (vt == VT_NULL && varSrc.vt == VT_NULL) + return false; + return VarCmp((VARIANT*)this, (VARIANT*)&varSrc, LOCALE_USER_DEFAULT, 0)== static_cast(VARCMP_LT); + } - bool operator>(_In_ const VARIANT& varSrc) const throw() - { - if (vt == VT_NULL && varSrc.vt == VT_NULL) - return false; - return VarCmp((VARIANT*)this, (VARIANT*)&varSrc, LOCALE_USER_DEFAULT, 0)== static_cast(VARCMP_GT); - } + bool operator>(_In_ const VARIANT& varSrc) const throw() + { + if (vt == VT_NULL && varSrc.vt == VT_NULL) + return false; + return VarCmp((VARIANT*)this, (VARIANT*)&varSrc, LOCALE_USER_DEFAULT, 0)== static_cast(VARCMP_GT); + } private: - inline HRESULT VarCmp( - _In_ LPVARIANT pvarLeft, - _In_ LPVARIANT pvarRight, - _In_ LCID lcid, - _In_ ULONG dwFlags) const throw(); + inline HRESULT VarCmp( + _In_ LPVARIANT pvarLeft, + _In_ LPVARIANT pvarRight, + _In_ LCID lcid, + _In_ ULONG dwFlags) const throw(); // Operations public: - HRESULT Clear() - { - return ::VariantClear(this); - } - HRESULT Copy(_In_ const VARIANT* pSrc) - { - return ::VariantCopy(this, const_cast(pSrc)); - } - + HRESULT Clear() + { + return ::VariantClear(this); + } + HRESULT Copy(_In_ const VARIANT* pSrc) + { + return ::VariantCopy(this, const_cast(pSrc)); + } + ATLPREFAST_SUPPRESS(6387) - // copy VARIANT to BSTR - HRESULT CopyTo(_Deref_out_z_ BSTR *pstrDest) const - { - ATLASSERT(pstrDest != NULL && vt == VT_BSTR); - HRESULT hRes = E_POINTER; - if (pstrDest != NULL && vt == VT_BSTR) - { - *pstrDest = ::SysAllocStringByteLen((char*)bstrVal, ::SysStringByteLen(bstrVal)); - if (*pstrDest == NULL) - hRes = E_OUTOFMEMORY; - else - hRes = S_OK; - } - else if (vt != VT_BSTR) - hRes = DISP_E_TYPEMISMATCH; - - return hRes; - } + // copy VARIANT to BSTR + HRESULT CopyTo(_Deref_out_z_ BSTR *pstrDest) const + { + ATLASSERT(pstrDest != NULL && vt == VT_BSTR); + HRESULT hRes = E_POINTER; + if (pstrDest != NULL && vt == VT_BSTR) + { + *pstrDest = ::SysAllocStringByteLen((char*)bstrVal, ::SysStringByteLen(bstrVal)); + if (*pstrDest == NULL) + hRes = E_OUTOFMEMORY; + else + hRes = S_OK; + } + else if (vt != VT_BSTR) + hRes = DISP_E_TYPEMISMATCH; + + return hRes; + } ATLPREFAST_UNSUPPRESS() - - HRESULT Attach(_In_ VARIANT* pSrc) - { - if(pSrc == NULL) - return E_INVALIDARG; - - // Clear out the variant - HRESULT hr = Clear(); - if (SUCCEEDED(hr)) - { - // Copy the contents and give control to CComVariant - Checked::memcpy_s(this, sizeof(CComVariant), pSrc, sizeof(VARIANT)); - pSrc->vt = VT_EMPTY; - hr = S_OK; - } - return hr; - } + + HRESULT Attach(_In_ VARIANT* pSrc) + { + if(pSrc == NULL) + return E_INVALIDARG; + + // Clear out the variant + HRESULT hr = Clear(); + if (SUCCEEDED(hr)) + { + // Copy the contents and give control to CComVariant + Checked::memcpy_s(this, sizeof(CComVariant), pSrc, sizeof(VARIANT)); + pSrc->vt = VT_EMPTY; + hr = S_OK; + } + return hr; + } - HRESULT Detach(_Out_ VARIANT* pDest) - { - ATLASSERT(pDest != NULL); - if(pDest == NULL) - return E_POINTER; - - // Clear out the variant - HRESULT hr = ::VariantClear(pDest); - if (SUCCEEDED(hr)) - { - // Copy the contents and remove control from CComVariant - Checked::memcpy_s(pDest, sizeof(VARIANT), this, sizeof(VARIANT)); - vt = VT_EMPTY; - hr = S_OK; - } - return hr; - } + HRESULT Detach(_Out_ VARIANT* pDest) + { + ATLASSERT(pDest != NULL); + if(pDest == NULL) + return E_POINTER; + + // Clear out the variant + HRESULT hr = ::VariantClear(pDest); + if (SUCCEEDED(hr)) + { + // Copy the contents and remove control from CComVariant + Checked::memcpy_s(pDest, sizeof(VARIANT), this, sizeof(VARIANT)); + vt = VT_EMPTY; + hr = S_OK; + } + return hr; + } - HRESULT ChangeType(_In_ VARTYPE vtNew, _In_opt_ const VARIANT* pSrc = NULL) - { - VARIANT* pVar = const_cast(pSrc); - // Convert in place if pSrc is NULL - if (pVar == NULL) - pVar = this; - // Do nothing if doing in place convert and vts not different - return ::VariantChangeType(this, pVar, 0, vtNew); - } + HRESULT ChangeType(_In_ VARTYPE vtNew, _In_opt_ const VARIANT* pSrc = NULL) + { + VARIANT* pVar = const_cast(pSrc); + // Convert in place if pSrc is NULL + if (pVar == NULL) + pVar = this; + // Do nothing if doing in place convert and vts not different + return ::VariantChangeType(this, pVar, 0, vtNew); + } - template< typename T > - void SetByRef(_In_ T* pT) ATLVARIANT_THROW() - { - ClearThrow(); - vt = CVarTypeInfo< T* >::VT; - byref = pT; - } + template< typename T > + void SetByRef(_In_ T* pT) ATLVARIANT_THROW() + { + ClearThrow(); + vt = CVarTypeInfo< T* >::VT; + byref = pT; + } - _Check_return_ HRESULT WriteToStream(_Inout_ IStream* pStream); - _Check_return_ HRESULT WriteToStream( - _Inout_ IStream* pStream, - _In_ VARTYPE vtWrite) - { - if (vtWrite != VT_EMPTY && vtWrite != vt) - { - CComVariant varConv; - HRESULT hr = varConv.ChangeType(vtWrite, this); - if (FAILED(hr)) - { - return hr; - } - return varConv.WriteToStream(pStream); - } - return WriteToStream(pStream); - } + _Check_return_ HRESULT WriteToStream(_Inout_ IStream* pStream); + _Check_return_ HRESULT WriteToStream( + _Inout_ IStream* pStream, + _In_ VARTYPE vtWrite) + { + if (vtWrite != VT_EMPTY && vtWrite != vt) + { + CComVariant varConv; + HRESULT hr = varConv.ChangeType(vtWrite, this); + if (FAILED(hr)) + { + return hr; + } + return varConv.WriteToStream(pStream); + } + return WriteToStream(pStream); + } - _Check_return_ HRESULT ReadFromStream( - _Inout_ IStream* pStream, - _In_ VARTYPE vtExpected = VT_EMPTY); + _Check_return_ HRESULT ReadFromStream( + _Inout_ IStream* pStream, + _In_ VARTYPE vtExpected = VT_EMPTY); - _Check_return_ HRESULT ReadFromStream( - _Inout_ IStream* pStream, - _In_ VARTYPE vtExpected, - // _In_ ClassesAllowedInStream rgclsidAllowed, - _In_ DWORD cclsidAllowed); + _Check_return_ HRESULT ReadFromStream( + _Inout_ IStream* pStream, + _In_ VARTYPE vtExpected, + // _In_ ClassesAllowedInStream rgclsidAllowed, + _In_ DWORD cclsidAllowed); - // Return the size in bytes of the current contents - ULONG GetSize() const; - HRESULT GetSizeMax(_Out_ ULARGE_INTEGER* pcbSize) const; + // Return the size in bytes of the current contents + ULONG GetSize() const; + HRESULT GetSizeMax(_Out_ ULARGE_INTEGER* pcbSize) const; // Implementation private: - void ClearThrow() ATLVARIANT_THROW() - { - HRESULT hr = Clear(); - ATLASSERT(SUCCEEDED(hr)); - (hr); + void ClearThrow() ATLVARIANT_THROW() + { + HRESULT hr = Clear(); + ATLASSERT(SUCCEEDED(hr)); + (hr); #ifndef _ATL_NO_VARIANT_THROW - if (FAILED(hr)) - { - AtlThrow(hr); - } + if (FAILED(hr)) + { + AtlThrow(hr); + } #endif - } - + } + public: - _Check_return_ HRESULT InternalClear() ATLVARIANT_THROW() - { - HRESULT hr = Clear(); - ATLASSERT(SUCCEEDED(hr)); - if (FAILED(hr)) - { - vt = VT_ERROR; - scode = hr; + _Check_return_ HRESULT InternalClear() ATLVARIANT_THROW() + { + HRESULT hr = Clear(); + ATLASSERT(SUCCEEDED(hr)); + if (FAILED(hr)) + { + vt = VT_ERROR; + scode = hr; #ifndef _ATL_NO_VARIANT_THROW - AtlThrow(hr); + AtlThrow(hr); #endif - } - return hr; - } + } + return hr; + } - void InternalCopy(_In_ const VARIANT* pSrc) ATLVARIANT_THROW() - { - HRESULT hr = Copy(pSrc); - if (FAILED(hr)) - { - vt = VT_ERROR; - scode = hr; + void InternalCopy(_In_ const VARIANT* pSrc) ATLVARIANT_THROW() + { + HRESULT hr = Copy(pSrc); + if (FAILED(hr)) + { + vt = VT_ERROR; + scode = hr; #ifndef _ATL_NO_VARIANT_THROW - AtlThrow(hr); + AtlThrow(hr); #endif - } - } + } + } }; #pragma warning(push) #pragma warning(disable: 4702) _Check_return_ inline HRESULT CComVariant::WriteToStream(_Inout_ IStream* pStream) { - if(pStream == NULL) - return E_INVALIDARG; - - HRESULT hr = pStream->Write(&vt, sizeof(VARTYPE), NULL); - if (FAILED(hr)) - return hr; + if(pStream == NULL) + return E_INVALIDARG; + + HRESULT hr = pStream->Write(&vt, sizeof(VARTYPE), NULL); + if (FAILED(hr)) + return hr; - int cbWrite = 0; - switch (vt) - { - case VT_UNKNOWN: - case VT_DISPATCH: - { - CComPtr spStream; - if (punkVal != NULL) - { - hr = punkVal->QueryInterface(__uuidof(IPersistStream), (void**)&spStream); - if (FAILED(hr)) - { - hr = punkVal->QueryInterface(__uuidof(IPersistStreamInit), (void**)&spStream); - if (FAILED(hr)) - return hr; - } - } - if (spStream != NULL) - return OleSaveToStream(spStream, pStream); - return WriteClassStm(pStream, CLSID_NULL); - } - case VT_UI1: - case VT_I1: - cbWrite = sizeof(BYTE); - break; - case VT_I2: - case VT_UI2: - case VT_BOOL: - cbWrite = sizeof(short); - break; - case VT_I4: - case VT_UI4: - case VT_R4: - case VT_INT: - case VT_UINT: - case VT_ERROR: - cbWrite = sizeof(long); - break; - case VT_I8: - case VT_UI8: - cbWrite = sizeof(LONGLONG); - break; - case VT_R8: - case VT_CY: - case VT_DATE: - cbWrite = sizeof(double); - break; - default: - break; - } - if (cbWrite != 0) - return pStream->Write((void*) &bVal, cbWrite, NULL); + int cbWrite = 0; + switch (vt) + { + case VT_UNKNOWN: + case VT_DISPATCH: + { + CComPtr spStream; + if (punkVal != NULL) + { + hr = punkVal->QueryInterface(__uuidof(IPersistStream), (void**)&spStream); + if (FAILED(hr)) + { + hr = punkVal->QueryInterface(__uuidof(IPersistStreamInit), (void**)&spStream); + if (FAILED(hr)) + return hr; + } + } + if (spStream != NULL) + return OleSaveToStream(spStream, pStream); + return WriteClassStm(pStream, CLSID_NULL); + } + case VT_UI1: + case VT_I1: + cbWrite = sizeof(BYTE); + break; + case VT_I2: + case VT_UI2: + case VT_BOOL: + cbWrite = sizeof(short); + break; + case VT_I4: + case VT_UI4: + case VT_R4: + case VT_INT: + case VT_UINT: + case VT_ERROR: + cbWrite = sizeof(long); + break; + case VT_I8: + case VT_UI8: + cbWrite = sizeof(LONGLONG); + break; + case VT_R8: + case VT_CY: + case VT_DATE: + cbWrite = sizeof(double); + break; + default: + break; + } + if (cbWrite != 0) + return pStream->Write((void*) &bVal, cbWrite, NULL); - CComBSTR bstrWrite; - CComVariant varBSTR; - if (vt != VT_BSTR) - { - hr = VariantChangeType(&varBSTR, this, VARIANT_NOVALUEPROP, VT_BSTR); - if (FAILED(hr)) - return hr; - bstrWrite.Attach(varBSTR.bstrVal); - } - else - bstrWrite.Attach(bstrVal); + CComBSTR bstrWrite; + CComVariant varBSTR; + if (vt != VT_BSTR) + { + hr = VariantChangeType(&varBSTR, this, VARIANT_NOVALUEPROP, VT_BSTR); + if (FAILED(hr)) + return hr; + bstrWrite.Attach(varBSTR.bstrVal); + } + else + bstrWrite.Attach(bstrVal); - hr = bstrWrite.WriteToStream(pStream); - bstrWrite.Detach(); - return hr; + hr = bstrWrite.WriteToStream(pStream); + bstrWrite.Detach(); + return hr; } -#pragma warning(pop) // C4702 +#pragma warning(pop) // C4702 inline HRESULT CComVariant::GetSizeMax(_Out_ ULARGE_INTEGER* pcbSize) const { - ATLASSERT(pcbSize != NULL); - if (pcbSize == NULL) - { - return E_INVALIDARG; - } - - HRESULT hr = S_OK; - ULARGE_INTEGER nSize; - nSize.QuadPart = sizeof(VARTYPE); - - switch (vt) - { - case VT_UNKNOWN: - case VT_DISPATCH: - { - nSize.LowPart += sizeof(CLSID); - - if (punkVal != NULL) - { - CComPtr spStream; - - hr = punkVal->QueryInterface(__uuidof(IPersistStream), (void**)&spStream); - if (FAILED(hr)) - { - hr = punkVal->QueryInterface(__uuidof(IPersistStreamInit), (void**)&spStream); - if (FAILED(hr)) - { - break; - } - } - - ULARGE_INTEGER nPersistSize; - nPersistSize.QuadPart = 0; - - ATLASSERT(spStream != NULL); - hr = spStream->GetSizeMax(&nPersistSize); - if (SUCCEEDED(hr)) - { - hr = AtlAdd(&nSize.QuadPart, nSize.QuadPart, nPersistSize.QuadPart); - } - } - } - break; - case VT_UI1: - case VT_I1: - nSize.LowPart += sizeof(BYTE); - break; - case VT_I2: - case VT_UI2: - case VT_BOOL: - nSize.LowPart += sizeof(short); - break; - case VT_I4: - case VT_UI4: - case VT_R4: - case VT_INT: - case VT_UINT: - case VT_ERROR: - nSize.LowPart += sizeof(long); - break; - case VT_I8: - case VT_UI8: - nSize.LowPart += sizeof(LONGLONG); - break; - case VT_R8: - case VT_CY: - case VT_DATE: - nSize.LowPart += sizeof(double); - break; - default: - { - VARTYPE vtTmp = vt; - BSTR bstr = NULL; - CComVariant varBSTR; - if (vtTmp != VT_BSTR) - { - hr = VariantChangeType(&varBSTR, const_cast((const VARIANT*)this), VARIANT_NOVALUEPROP, VT_BSTR); - if (SUCCEEDED(hr)) - { - bstr = varBSTR.bstrVal; - vtTmp = VT_BSTR; - } - } - else - { - bstr = bstrVal; - } + ATLASSERT(pcbSize != NULL); + if (pcbSize == NULL) + { + return E_INVALIDARG; + } + + HRESULT hr = S_OK; + ULARGE_INTEGER nSize; + nSize.QuadPart = sizeof(VARTYPE); + + switch (vt) + { + case VT_UNKNOWN: + case VT_DISPATCH: + { + nSize.LowPart += sizeof(CLSID); + + if (punkVal != NULL) + { + CComPtr spStream; + + hr = punkVal->QueryInterface(__uuidof(IPersistStream), (void**)&spStream); + if (FAILED(hr)) + { + hr = punkVal->QueryInterface(__uuidof(IPersistStreamInit), (void**)&spStream); + if (FAILED(hr)) + { + break; + } + } + + ULARGE_INTEGER nPersistSize; + nPersistSize.QuadPart = 0; + + ATLASSERT(spStream != NULL); + hr = spStream->GetSizeMax(&nPersistSize); + if (SUCCEEDED(hr)) + { + hr = AtlAdd(&nSize.QuadPart, nSize.QuadPart, nPersistSize.QuadPart); + } + } + } + break; + case VT_UI1: + case VT_I1: + nSize.LowPart += sizeof(BYTE); + break; + case VT_I2: + case VT_UI2: + case VT_BOOL: + nSize.LowPart += sizeof(short); + break; + case VT_I4: + case VT_UI4: + case VT_R4: + case VT_INT: + case VT_UINT: + case VT_ERROR: + nSize.LowPart += sizeof(long); + break; + case VT_I8: + case VT_UI8: + nSize.LowPart += sizeof(LONGLONG); + break; + case VT_R8: + case VT_CY: + case VT_DATE: + nSize.LowPart += sizeof(double); + break; + default: + { + VARTYPE vtTmp = vt; + BSTR bstr = NULL; + CComVariant varBSTR; + if (vtTmp != VT_BSTR) + { + hr = VariantChangeType(&varBSTR, const_cast((const VARIANT*)this), VARIANT_NOVALUEPROP, VT_BSTR); + if (SUCCEEDED(hr)) + { + bstr = varBSTR.bstrVal; + vtTmp = VT_BSTR; + } + } + else + { + bstr = bstrVal; + } - if (vtTmp == VT_BSTR) - { - // Add the size of the length + string (in bytes) + NULL terminator. - nSize.QuadPart += CComBSTR::GetStreamSize(bstr); - } - } - } - - if (SUCCEEDED(hr)) - { - pcbSize->QuadPart = nSize.QuadPart; - } - - return hr; + if (vtTmp == VT_BSTR) + { + // Add the size of the length + string (in bytes) + NULL terminator. + nSize.QuadPart += CComBSTR::GetStreamSize(bstr); + } + } + } + + if (SUCCEEDED(hr)) + { + pcbSize->QuadPart = nSize.QuadPart; + } + + return hr; } inline ATL_DEPRECATED("GetSize has been replaced by GetSizeMax") ULONG CComVariant::GetSize() const { - ULARGE_INTEGER nSize; - HRESULT hr = GetSizeMax(&nSize); - - if (SUCCEEDED(hr) && nSize.QuadPart <= ULONG_MAX) - { - return nSize.LowPart; - } - - return sizeof(VARTYPE); + ULARGE_INTEGER nSize; + HRESULT hr = GetSizeMax(&nSize); + + if (SUCCEEDED(hr) && nSize.QuadPart <= ULONG_MAX) + { + return nSize.LowPart; + } + + return sizeof(VARTYPE); } _Check_return_ inline HRESULT CComPtr::Invoke2( - _In_ DISPID dispid, - _In_ VARIANT* pvarParam1, - _In_ VARIANT* pvarParam2, - _Out_opt_ VARIANT* pvarRet) throw() + _In_ DISPID dispid, + _In_ VARIANT* pvarParam1, + _In_ VARIANT* pvarParam2, + _Out_opt_ VARIANT* pvarRet) throw() { - if(pvarParam1 == NULL || pvarParam2 == NULL) - return E_INVALIDARG; - - CComVariant varArgs[2] = { *pvarParam2, *pvarParam1 }; - DISPPARAMS dispparams = { &varArgs[0], NULL, 2, 0}; - return p->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispparams, pvarRet, NULL, NULL); + if(pvarParam1 == NULL || pvarParam2 == NULL) + return E_INVALIDARG; + + CComVariant varArgs[2] = { *pvarParam2, *pvarParam1 }; + DISPPARAMS dispparams = { &varArgs[0], NULL, 2, 0}; + return p->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispparams, pvarRet, NULL, NULL); } /* - Workaround for VarCmp function which does not compare VT_I1, VT_UI2, VT_UI4, VT_UI8 values + Workaround for VarCmp function which does not compare VT_I1, VT_UI2, VT_UI4, VT_UI8 values */ inline HRESULT CComVariant::VarCmp( - _In_ LPVARIANT pvarLeft, - _In_ LPVARIANT pvarRight, - _In_ LCID lcid, - _In_ ULONG dwFlags) const throw() -{ - switch(vt) - { - case VT_I1: - if (pvarLeft->cVal == pvarRight->cVal) - { - return VARCMP_EQ; - } - return pvarLeft->cVal > pvarRight->cVal ? VARCMP_GT : VARCMP_LT; - case VT_UI2: - if (pvarLeft->uiVal == pvarRight->uiVal) - { - return VARCMP_EQ; - } - return pvarLeft->uiVal > pvarRight->uiVal ? VARCMP_GT : VARCMP_LT; + _In_ LPVARIANT pvarLeft, + _In_ LPVARIANT pvarRight, + _In_ LCID lcid, + _In_ ULONG dwFlags) const throw() +{ + switch(vt) + { + case VT_I1: + if (pvarLeft->cVal == pvarRight->cVal) + { + return VARCMP_EQ; + } + return pvarLeft->cVal > pvarRight->cVal ? VARCMP_GT : VARCMP_LT; + case VT_UI2: + if (pvarLeft->uiVal == pvarRight->uiVal) + { + return VARCMP_EQ; + } + return pvarLeft->uiVal > pvarRight->uiVal ? VARCMP_GT : VARCMP_LT; - case VT_UI4: - if (pvarLeft->uintVal == pvarRight->uintVal) - { - return VARCMP_EQ; - } - return pvarLeft->uintVal > pvarRight->uintVal ? VARCMP_GT : VARCMP_LT; + case VT_UI4: + if (pvarLeft->uintVal == pvarRight->uintVal) + { + return VARCMP_EQ; + } + return pvarLeft->uintVal > pvarRight->uintVal ? VARCMP_GT : VARCMP_LT; - case VT_UI8: - if (pvarLeft->ullVal == pvarRight->ullVal) - { - return VARCMP_EQ; - } - return pvarLeft->ullVal > pvarRight->ullVal ? VARCMP_GT : VARCMP_LT; + case VT_UI8: + if (pvarLeft->ullVal == pvarRight->ullVal) + { + return VARCMP_EQ; + } + return pvarLeft->ullVal > pvarRight->ullVal ? VARCMP_GT : VARCMP_LT; - default: - return ::VarCmp(pvarLeft, pvarRight, lcid, dwFlags); - } + default: + return ::VarCmp(pvarLeft, pvarRight, lcid, dwFlags); + } } -} // namespace ATL +} // namespace ATL #pragma pack(pop) -#pragma warning (pop) +#pragma warning (pop) #ifndef _ATL_NO_AUTOMATIC_NAMESPACE using namespace ATL; #endif //!_ATL_NO_AUTOMATIC_NAMESPACE -#endif // __ATLCOMCLI_H__ +#endif // __ATLCOMCLI_H__ diff --git a/src/main/headers/atlconv.h b/src/main/headers/atlconv.h index 17a90d7..5f064ae 100644 --- a/src/main/headers/atlconv.h +++ b/src/main/headers/atlconv.h @@ -19,7 +19,7 @@ #endif //!_ATL_NO_PRAGMA_WARNINGS #ifndef __cplusplus - #error ATL requires C++ compilation (use a .cpp suffix) + #error ATL requires C++ compilation (use a .cpp suffix) #endif #include @@ -61,8 +61,8 @@ typedef LPSTR LPOLESTR; typedef LPCSTR LPCOLESTR; #define OLESTR(str) str -#endif // !OLE2ANSI -#endif // __wtypes_h__ +#endif // !OLE2ANSI +#endif // __wtypes_h__ #ifndef _OLEAUTO_H_ typedef LPWSTR BSTR;// must (semantically) match typedef in oleauto.h @@ -71,12 +71,12 @@ extern "C" { __declspec(dllimport) _Ret_opt_z_ BSTR __stdcall SysAllocString(_In_opt_z_ const OLECHAR *); __declspec(dllimport) _Ret_opt_z_ BSTR __stdcall SysAllocStringLen( - _In_z_count_(nLen) const OLECHAR *, - _In_ UINT nLen); + _In_z_count_(nLen) const OLECHAR *, + _In_ UINT nLen); __declspec(dllimport) INT __stdcall SysReAllocStringLen( - _Deref_out_opt_z_ BSTR*, - _In_opt_z_count_(nLen) const OLECHAR *, - _In_ UINT nLen); + _Deref_out_opt_z_ BSTR*, + _In_opt_z_count_(nLen) const OLECHAR *, + _In_ UINT nLen); __declspec(dllimport) void __stdcall SysFreeString(_In_opt_z_ BSTR); } #endif @@ -85,12 +85,12 @@ __declspec(dllimport) void __stdcall SysFreeString(_In_opt_z_ BSTR); #ifdef _M_IX86 #undef InterlockedExchangePointer inline void* WINAPI InterlockedExchangePointer( - _Inout_ void** pp, - _In_opt_ void* pNew) throw() + _Inout_ void** pp, + _In_opt_ void* pNew) throw() { - return( reinterpret_cast(static_cast( - ::InterlockedExchange(reinterpret_cast(pp), - static_cast(reinterpret_cast(pNew))))) ); + return( reinterpret_cast(static_cast( + ::InterlockedExchange(reinterpret_cast(pp), + static_cast(reinterpret_cast(pNew))))) ); } #endif @@ -103,73 +103,73 @@ namespace ATL inline UINT WINAPI _AtlGetConversionACP() throw() { #ifdef _CONVERSION_DONT_USE_THREAD_LOCALE - return CP_ACP; + return CP_ACP; #else - return CP_THREAD_ACP; + return CP_THREAD_ACP; #endif } template inline void AtlConvAllocMemory( - _Inout_ _Deref_post_cap_(nLength) _CharType** ppBuff, - _In_ int nLength, - _Inout_cap_(nFixedBufferLength) _CharType* pszFixedBuffer, - _In_ int nFixedBufferLength) + _Inout_ _Deref_post_cap_(nLength) _CharType** ppBuff, + _In_ int nLength, + _Inout_cap_(nFixedBufferLength) _CharType* pszFixedBuffer, + _In_ int nFixedBufferLength) { - ATLENSURE_THROW(ppBuff != NULL, E_INVALIDARG); - ATLENSURE_THROW(nLength >= 0, E_INVALIDARG); - ATLENSURE_THROW(pszFixedBuffer != NULL, E_INVALIDARG); + ATLENSURE_THROW(ppBuff != NULL, E_INVALIDARG); + ATLENSURE_THROW(nLength >= 0, E_INVALIDARG); + ATLENSURE_THROW(pszFixedBuffer != NULL, E_INVALIDARG); - //if buffer malloced, try to realloc. - if (*ppBuff != pszFixedBuffer) - { - if( nLength > nFixedBufferLength ) - { - _CharType* ppReallocBuf = static_cast< _CharType* >( _recalloc(*ppBuff, nLength,sizeof( _CharType ) ) ); - if (ppReallocBuf == NULL) - { - AtlThrow( E_OUTOFMEMORY ); - } - *ppBuff = ppReallocBuf; - } else - { - nb_free(*ppBuff); - *ppBuff=pszFixedBuffer; - } + //if buffer malloced, try to realloc. + if (*ppBuff != pszFixedBuffer) + { + if( nLength > nFixedBufferLength ) + { + _CharType* ppReallocBuf = static_cast< _CharType* >( _recalloc(*ppBuff, nLength,sizeof( _CharType ) ) ); + if (ppReallocBuf == NULL) + { + AtlThrow( E_OUTOFMEMORY ); + } + *ppBuff = ppReallocBuf; + } else + { + nb_free(*ppBuff); + *ppBuff=pszFixedBuffer; + } - } else //Buffer is not currently malloced. - { - if( nLength > nFixedBufferLength ) - { - *ppBuff = static_cast< _CharType* >( nb_calloc(nLength,sizeof( _CharType ) ) ); - } else - { - *ppBuff=pszFixedBuffer; - } - } + } else //Buffer is not currently malloced. + { + if( nLength > nFixedBufferLength ) + { + *ppBuff = static_cast< _CharType* >( nb_calloc(nLength,sizeof( _CharType ) ) ); + } else + { + *ppBuff=pszFixedBuffer; + } + } - if (*ppBuff == NULL) - { - AtlThrow( E_OUTOFMEMORY ); - } + if (*ppBuff == NULL) + { + AtlThrow( E_OUTOFMEMORY ); + } } template inline void AtlConvFreeMemory( - _Inout_ _CharType* pBuff, - _Inout_cap_(nFixedBufferLength) _CharType* pszFixedBuffer, - _In_ int nFixedBufferLength) + _Inout_ _CharType* pBuff, + _Inout_cap_(nFixedBufferLength) _CharType* pszFixedBuffer, + _In_ int nFixedBufferLength) { - (nFixedBufferLength); - if( pBuff != pszFixedBuffer ) - { - nb_free( pBuff ); - } + (nFixedBufferLength); + if( pBuff != pszFixedBuffer ) + { + nb_free( pBuff ); + } #ifdef _DEBUG - else - { - memset(pszFixedBuffer,ATLCONV_DEADLAND_FILL,nFixedBufferLength*sizeof(_CharType)); - } + else + { + memset(pszFixedBuffer,ATLCONV_DEADLAND_FILL,nFixedBufferLength*sizeof(_CharType)); + } #endif } @@ -177,51 +177,51 @@ template< int t_nBufferLength = 128 > class CW2WEX { public: - CW2WEX(_In_z_ LPCWSTR psz) throw() : - m_psz( m_szBuffer ) - { - Init( psz ); - } - CW2WEX( - _In_z_ LPCWSTR psz, - _In_ UINT nCodePage) throw() : - m_psz( m_szBuffer ) - { - (void)nCodePage; // Code page doesn't matter + CW2WEX(_In_z_ LPCWSTR psz) throw() : + m_psz( m_szBuffer ) + { + Init( psz ); + } + CW2WEX( + _In_z_ LPCWSTR psz, + _In_ UINT nCodePage) throw() : + m_psz( m_szBuffer ) + { + (void)nCodePage; // Code page doesn't matter - Init( psz ); - } - ~CW2WEX() throw() - { - AtlConvFreeMemory(m_psz,m_szBuffer,t_nBufferLength); - } + Init( psz ); + } + ~CW2WEX() throw() + { + AtlConvFreeMemory(m_psz,m_szBuffer,t_nBufferLength); + } - _Ret_z_ operator LPWSTR() const throw() - { - return( m_psz ); - } + _Ret_z_ operator LPWSTR() const throw() + { + return( m_psz ); + } private: - void Init(_In_z_ LPCWSTR psz) throw() - { - if (psz == NULL) - { - m_psz = NULL; - return; - } - int nLength = lstrlenW( psz )+1; - AtlConvAllocMemory(&m_psz,nLength,m_szBuffer,t_nBufferLength); - ATLASSUME(m_psz != NULL); - Checked::memcpy_s( m_psz, nLength*sizeof( wchar_t ), psz, nLength*sizeof( wchar_t )); - } + void Init(_In_z_ LPCWSTR psz) throw() + { + if (psz == NULL) + { + m_psz = NULL; + return; + } + int nLength = lstrlenW( psz )+1; + AtlConvAllocMemory(&m_psz,nLength,m_szBuffer,t_nBufferLength); + ATLASSUME(m_psz != NULL); + Checked::memcpy_s( m_psz, nLength*sizeof( wchar_t ), psz, nLength*sizeof( wchar_t )); + } public: - LPWSTR m_psz; - wchar_t m_szBuffer[t_nBufferLength]; + LPWSTR m_psz; + wchar_t m_szBuffer[t_nBufferLength]; private: - CW2WEX(_In_ const CW2WEX&) throw(); - CW2WEX& operator=(_In_ const CW2WEX&) throw(); + CW2WEX(_In_ const CW2WEX&) throw(); + CW2WEX& operator=(_In_ const CW2WEX&) throw(); }; typedef CW2WEX<> CW2W; @@ -229,50 +229,50 @@ template< int t_nBufferLength = 128 > class CA2AEX { public: - CA2AEX(_In_z_ LPCSTR psz) throw() : - m_psz( m_szBuffer ) - { - Init( psz ); - } - CA2AEX( - _In_z_ LPCSTR psz, - _In_ UINT nCodePage) throw() : - m_psz( m_szBuffer ) - { - (void)nCodePage; // Code page doesn't matter + CA2AEX(_In_z_ LPCSTR psz) throw() : + m_psz( m_szBuffer ) + { + Init( psz ); + } + CA2AEX( + _In_z_ LPCSTR psz, + _In_ UINT nCodePage) throw() : + m_psz( m_szBuffer ) + { + (void)nCodePage; // Code page doesn't matter - Init( psz ); - } - ~CA2AEX() throw() - { - AtlConvFreeMemory(m_psz,m_szBuffer,t_nBufferLength); - } + Init( psz ); + } + ~CA2AEX() throw() + { + AtlConvFreeMemory(m_psz,m_szBuffer,t_nBufferLength); + } - _Ret_z_ operator LPSTR() const throw() - { - return( m_psz ); - } + _Ret_z_ operator LPSTR() const throw() + { + return( m_psz ); + } private: - void Init(_In_z_ LPCSTR psz) throw() - { - if (psz == NULL) - { - m_psz = NULL; - return; - } - int nLength = lstrlenA( psz )+1; - AtlConvAllocMemory(&m_psz,nLength,m_szBuffer,t_nBufferLength); - Checked::memcpy_s( m_psz, nLength*sizeof( char ), psz, nLength*sizeof( char )); - } + void Init(_In_z_ LPCSTR psz) throw() + { + if (psz == NULL) + { + m_psz = NULL; + return; + } + int nLength = lstrlenA( psz )+1; + AtlConvAllocMemory(&m_psz,nLength,m_szBuffer,t_nBufferLength); + Checked::memcpy_s( m_psz, nLength*sizeof( char ), psz, nLength*sizeof( char )); + } public: - LPSTR m_psz; - char m_szBuffer[t_nBufferLength]; + LPSTR m_psz; + char m_szBuffer[t_nBufferLength]; private: - CA2AEX(_In_ const CA2AEX&) throw(); - CA2AEX& operator=(_In_ const CA2AEX&) throw(); + CA2AEX(_In_ const CA2AEX&) throw(); + CA2AEX& operator=(_In_ const CA2AEX&) throw(); }; typedef CA2AEX<> CA2A; @@ -280,32 +280,32 @@ template< int t_nBufferLength = 128 > class CA2CAEX { public: - CA2CAEX(_In_z_ LPCSTR psz) throw() : - m_psz( psz ) - { - } - CA2CAEX( - _In_z_ LPCSTR psz, - _In_ UINT nCodePage) throw() : - m_psz( psz ) - { - (void)nCodePage; - } - ~CA2CAEX() throw() - { - } - - _Ret_z_ operator LPCSTR() const throw() - { - return( m_psz ); - } - + CA2CAEX(_In_z_ LPCSTR psz) throw() : + m_psz( psz ) + { + } + CA2CAEX( + _In_z_ LPCSTR psz, + _In_ UINT nCodePage) throw() : + m_psz( psz ) + { + (void)nCodePage; + } + ~CA2CAEX() throw() + { + } + + _Ret_z_ operator LPCSTR() const throw() + { + return( m_psz ); + } + public: - LPCSTR m_psz; + LPCSTR m_psz; private: - CA2CAEX(_In_ const CA2CAEX&) throw(); - CA2CAEX& operator=(_In_ const CA2CAEX&) throw(); + CA2CAEX(_In_ const CA2CAEX&) throw(); + CA2CAEX& operator=(_In_ const CA2CAEX&) throw(); }; typedef CA2CAEX<> CA2CA; @@ -313,32 +313,32 @@ template< int t_nBufferLength = 128 > class CW2CWEX { public: - CW2CWEX(_In_z_ LPCWSTR psz) throw() : - m_psz( psz ) - { - } - CW2CWEX( - _In_z_ LPCWSTR psz, - _In_ UINT nCodePage) throw() : - m_psz( psz ) - { - UNREFERENCED_PARAMETER(nCodePage); - } - ~CW2CWEX() throw() - { - } + CW2CWEX(_In_z_ LPCWSTR psz) throw() : + m_psz( psz ) + { + } + CW2CWEX( + _In_z_ LPCWSTR psz, + _In_ UINT nCodePage) throw() : + m_psz( psz ) + { + UNREFERENCED_PARAMETER(nCodePage); + } + ~CW2CWEX() throw() + { + } - _Ret_z_ operator LPCWSTR() const throw() - { - return( m_psz ); - } + _Ret_z_ operator LPCWSTR() const throw() + { + return( m_psz ); + } public: - LPCWSTR m_psz; + LPCWSTR m_psz; private: - CW2CWEX(_In_ const CW2CWEX&) throw(); - CW2CWEX& operator=(_In_ const CW2CWEX&) throw(); + CW2CWEX(_In_ const CW2CWEX&) throw(); + CW2CWEX& operator=(_In_ const CW2CWEX&) throw(); }; typedef CW2CWEX<> CW2CW; @@ -346,66 +346,66 @@ template< int t_nBufferLength = 128 > class CA2WEX { public: - CA2WEX(_In_z_ LPCSTR psz) throw() : - m_psz( m_szBuffer ) - { - Init( psz, _AtlGetConversionACP() ); - } - CA2WEX( - _In_z_ LPCSTR psz, - _In_ UINT nCodePage) throw() : - m_psz( m_szBuffer ) - { - Init( psz, nCodePage ); - } - ~CA2WEX() throw() - { - AtlConvFreeMemory(m_psz,m_szBuffer,t_nBufferLength); - } + CA2WEX(_In_z_ LPCSTR psz) throw() : + m_psz( m_szBuffer ) + { + Init( psz, _AtlGetConversionACP() ); + } + CA2WEX( + _In_z_ LPCSTR psz, + _In_ UINT nCodePage) throw() : + m_psz( m_szBuffer ) + { + Init( psz, nCodePage ); + } + ~CA2WEX() throw() + { + AtlConvFreeMemory(m_psz,m_szBuffer,t_nBufferLength); + } - _Ret_z_ operator LPWSTR() const throw() - { - return( m_psz ); - } + _Ret_z_ operator LPWSTR() const throw() + { + return( m_psz ); + } private: - void Init( - _In_z_ LPCSTR psz, - _In_ UINT nCodePage) throw() - { - if (psz == NULL) - { - m_psz = NULL; - return; - } - int nLengthA = lstrlenA( psz )+1; - int nLengthW = nLengthA; + void Init( + _In_z_ LPCSTR psz, + _In_ UINT nCodePage) throw() + { + if (psz == NULL) + { + m_psz = NULL; + return; + } + int nLengthA = lstrlenA( psz )+1; + int nLengthW = nLengthA; - AtlConvAllocMemory(&m_psz,nLengthW,m_szBuffer,t_nBufferLength); + AtlConvAllocMemory(&m_psz,nLengthW,m_szBuffer,t_nBufferLength); - BOOL bFailed=(0 == ::MultiByteToWideChar( nCodePage, 0, psz, nLengthA, m_psz, nLengthW ) ); - if (bFailed) - { - if (GetLastError()==ERROR_INSUFFICIENT_BUFFER) - { - nLengthW = ::MultiByteToWideChar( nCodePage, 0, psz, nLengthA, NULL, 0); - AtlConvAllocMemory(&m_psz,nLengthW,m_szBuffer,t_nBufferLength); - bFailed=(0 == ::MultiByteToWideChar( nCodePage, 0, psz, nLengthA, m_psz, nLengthW ) ); - } - } - if (bFailed) - { - AtlThrowLastWin32(); - } - } + BOOL bFailed=(0 == ::MultiByteToWideChar( nCodePage, 0, psz, nLengthA, m_psz, nLengthW ) ); + if (bFailed) + { + if (GetLastError()==ERROR_INSUFFICIENT_BUFFER) + { + nLengthW = ::MultiByteToWideChar( nCodePage, 0, psz, nLengthA, NULL, 0); + AtlConvAllocMemory(&m_psz,nLengthW,m_szBuffer,t_nBufferLength); + bFailed=(0 == ::MultiByteToWideChar( nCodePage, 0, psz, nLengthA, m_psz, nLengthW ) ); + } + } + if (bFailed) + { + AtlThrowLastWin32(); + } + } public: - LPWSTR m_psz; - wchar_t m_szBuffer[t_nBufferLength]; + LPWSTR m_psz; + wchar_t m_szBuffer[t_nBufferLength]; private: - CA2WEX(_In_ const CA2WEX&) throw(); - CA2WEX& operator=(_In_ const CA2WEX&) throw(); + CA2WEX(_In_ const CA2WEX&) throw(); + CA2WEX& operator=(_In_ const CA2WEX&) throw(); }; typedef CA2WEX<> CA2W; @@ -413,66 +413,66 @@ template< int t_nBufferLength = 128 > class CW2AEX { public: - CW2AEX(_In_z_ LPCWSTR psz) throw() : - m_psz( m_szBuffer ) - { - Init( psz, _AtlGetConversionACP() ); - } - CW2AEX( - _In_z_ LPCWSTR psz, - _In_ UINT nCodePage) throw() : - m_psz( m_szBuffer ) - { - Init( psz, nCodePage ); - } - ~CW2AEX() throw() - { - AtlConvFreeMemory(m_psz,m_szBuffer,t_nBufferLength); - } + CW2AEX(_In_z_ LPCWSTR psz) throw() : + m_psz( m_szBuffer ) + { + Init( psz, _AtlGetConversionACP() ); + } + CW2AEX( + _In_z_ LPCWSTR psz, + _In_ UINT nCodePage) throw() : + m_psz( m_szBuffer ) + { + Init( psz, nCodePage ); + } + ~CW2AEX() throw() + { + AtlConvFreeMemory(m_psz,m_szBuffer,t_nBufferLength); + } - _Ret_z_ operator LPSTR() const throw() - { - return( m_psz ); - } + _Ret_z_ operator LPSTR() const throw() + { + return( m_psz ); + } private: - void Init( - _In_z_ LPCWSTR psz, - _In_ UINT nConvertCodePage) throw() - { - if (psz == NULL) - { - m_psz = NULL; - return; - } - int nLengthW = lstrlenW( psz )+1; - int nLengthA = nLengthW*4; - - AtlConvAllocMemory(&m_psz,nLengthA,m_szBuffer,t_nBufferLength); + void Init( + _In_z_ LPCWSTR psz, + _In_ UINT nConvertCodePage) throw() + { + if (psz == NULL) + { + m_psz = NULL; + return; + } + int nLengthW = lstrlenW( psz )+1; + int nLengthA = nLengthW*4; + + AtlConvAllocMemory(&m_psz,nLengthA,m_szBuffer,t_nBufferLength); - BOOL bFailed=(0 == ::WideCharToMultiByte( nConvertCodePage, 0, psz, nLengthW, m_psz, nLengthA, NULL, NULL )); - if (bFailed) - { - if (GetLastError()==ERROR_INSUFFICIENT_BUFFER) - { - nLengthA = ::WideCharToMultiByte( nConvertCodePage, 0, psz, nLengthW, NULL, 0, NULL, NULL ); - AtlConvAllocMemory(&m_psz,nLengthA,m_szBuffer,t_nBufferLength); - bFailed=(0 == ::WideCharToMultiByte( nConvertCodePage, 0, psz, nLengthW, m_psz, nLengthA, NULL, NULL )); - } - } - if (bFailed) - { - AtlThrowLastWin32(); - } - } + BOOL bFailed=(0 == ::WideCharToMultiByte( nConvertCodePage, 0, psz, nLengthW, m_psz, nLengthA, NULL, NULL )); + if (bFailed) + { + if (GetLastError()==ERROR_INSUFFICIENT_BUFFER) + { + nLengthA = ::WideCharToMultiByte( nConvertCodePage, 0, psz, nLengthW, NULL, 0, NULL, NULL ); + AtlConvAllocMemory(&m_psz,nLengthA,m_szBuffer,t_nBufferLength); + bFailed=(0 == ::WideCharToMultiByte( nConvertCodePage, 0, psz, nLengthW, m_psz, nLengthA, NULL, NULL )); + } + } + if (bFailed) + { + AtlThrowLastWin32(); + } + } public: - LPSTR m_psz; - char m_szBuffer[t_nBufferLength]; + LPSTR m_psz; + char m_szBuffer[t_nBufferLength]; private: - CW2AEX(_In_ const CW2AEX&) throw(); - CW2AEX& operator=(_In_ const CW2AEX&) throw(); + CW2AEX(_In_ const CW2AEX&) throw(); + CW2AEX& operator=(_In_ const CW2AEX&) throw(); }; typedef CW2AEX<> CW2A; @@ -535,121 +535,121 @@ typedef CW2AEX<> CW2A; #ifndef _ATL_EX_CONVERSION_MACROS_ONLY #ifndef _DEBUG - #define USES_CONVERSION int _convert; (_convert); UINT _acp = ATL::_AtlGetConversionACP() /*CP_THREAD_ACP*/; (_acp); LPCWSTR _lpw; (_lpw); LPCSTR _lpa; (_lpa) + #define USES_CONVERSION int _convert; (_convert); UINT _acp = ATL::_AtlGetConversionACP() /*CP_THREAD_ACP*/; (_acp); LPCWSTR _lpw; (_lpw); LPCSTR _lpa; (_lpa) #else - #define USES_CONVERSION int _convert = 0; (_convert); UINT _acp = ATL::_AtlGetConversionACP() /*CP_THREAD_ACP*/; (_acp); LPCWSTR _lpw = NULL; (_lpw); LPCSTR _lpa = NULL; (_lpa) + #define USES_CONVERSION int _convert = 0; (_convert); UINT _acp = ATL::_AtlGetConversionACP() /*CP_THREAD_ACP*/; (_acp); LPCWSTR _lpw = NULL; (_lpw); LPCSTR _lpa = NULL; (_lpa) #endif -#endif // _ATL_EX_CONVERSION_MACROS_ONLY +#endif // _ATL_EX_CONVERSION_MACROS_ONLY #ifndef _DEBUG - #define USES_CONVERSION_EX int _convert_ex; (_convert_ex); UINT _acp_ex = ATL::_AtlGetConversionACP(); (_acp_ex); LPCWSTR _lpw_ex; (_lpw_ex); LPCSTR _lpa_ex; (_lpa_ex); USES_ATL_SAFE_ALLOCA + #define USES_CONVERSION_EX int _convert_ex; (_convert_ex); UINT _acp_ex = ATL::_AtlGetConversionACP(); (_acp_ex); LPCWSTR _lpw_ex; (_lpw_ex); LPCSTR _lpa_ex; (_lpa_ex); USES_ATL_SAFE_ALLOCA #else - #define USES_CONVERSION_EX int _convert_ex = 0; (_convert_ex); UINT _acp_ex = ATL::_AtlGetConversionACP(); (_acp_ex); LPCWSTR _lpw_ex = NULL; (_lpw_ex); LPCSTR _lpa_ex = NULL; (_lpa_ex); USES_ATL_SAFE_ALLOCA + #define USES_CONVERSION_EX int _convert_ex = 0; (_convert_ex); UINT _acp_ex = ATL::_AtlGetConversionACP(); (_acp_ex); LPCWSTR _lpw_ex = NULL; (_lpw_ex); LPCSTR _lpa_ex = NULL; (_lpa_ex); USES_ATL_SAFE_ALLOCA #endif ///////////////////////////////////////////////////////////////////////////// // Global UNICODE<>ANSI translation helpers _Ret_opt_z_cap_(nChars) inline LPWSTR WINAPI AtlA2WHelper( - _Out_opt_z_cap_(nChars) LPWSTR lpw, - _In_opt_z_ LPCSTR lpa, - _In_ int nChars, - _In_ UINT acp) throw() -{ - ATLASSERT(lpa != NULL); - ATLASSERT(lpw != NULL); - if (lpw == NULL || lpa == NULL) - return NULL; - // verify that no illegal character present - // since lpw was allocated based on the size of lpa - // don't worry about the number of chars - *lpw = '\0'; - int ret = MultiByteToWideChar(acp, 0, lpa, -1, lpw, nChars); - if(ret == 0) - { - ATLASSERT(FALSE); - return NULL; - } - return lpw; + _Out_opt_z_cap_(nChars) LPWSTR lpw, + _In_opt_z_ LPCSTR lpa, + _In_ int nChars, + _In_ UINT acp) throw() +{ + ATLASSERT(lpa != NULL); + ATLASSERT(lpw != NULL); + if (lpw == NULL || lpa == NULL) + return NULL; + // verify that no illegal character present + // since lpw was allocated based on the size of lpa + // don't worry about the number of chars + *lpw = '\0'; + int ret = MultiByteToWideChar(acp, 0, lpa, -1, lpw, nChars); + if(ret == 0) + { + ATLASSERT(FALSE); + return NULL; + } + return lpw; } _Ret_opt_z_cap_(nChars) inline LPSTR WINAPI AtlW2AHelper( - _Out_opt_z_cap_(nChars) LPSTR lpa, - _In_opt_z_ LPCWSTR lpw, - _In_ int nChars, - _In_ UINT acp) throw() + _Out_opt_z_cap_(nChars) LPSTR lpa, + _In_opt_z_ LPCWSTR lpw, + _In_ int nChars, + _In_ UINT acp) throw() { - ATLASSERT(lpw != NULL); - ATLASSERT(lpa != NULL); - if (lpa == NULL || lpw == NULL) - return NULL; - // verify that no illegal character present - // since lpa was allocated based on the size of lpw - // don't worry about the number of chars - *lpa = '\0'; - int ret = WideCharToMultiByte(acp, 0, lpw, -1, lpa, nChars, NULL, NULL); - if(ret == 0) - { - ATLASSERT(FALSE); - return NULL; - } - return lpa; + ATLASSERT(lpw != NULL); + ATLASSERT(lpa != NULL); + if (lpa == NULL || lpw == NULL) + return NULL; + // verify that no illegal character present + // since lpa was allocated based on the size of lpw + // don't worry about the number of chars + *lpa = '\0'; + int ret = WideCharToMultiByte(acp, 0, lpw, -1, lpa, nChars, NULL, NULL); + if(ret == 0) + { + ATLASSERT(FALSE); + return NULL; + } + return lpa; } _Ret_opt_z_cap_(nChars) inline LPWSTR WINAPI AtlA2WHelper( - _Out_opt_z_cap_(nChars) LPWSTR lpw, - _In_opt_z_ LPCSTR lpa, - _In_ int nChars) throw() + _Out_opt_z_cap_(nChars) LPWSTR lpw, + _In_opt_z_ LPCSTR lpa, + _In_ int nChars) throw() { - return AtlA2WHelper(lpw, lpa, nChars, CP_ACP); + return AtlA2WHelper(lpw, lpa, nChars, CP_ACP); } _Ret_opt_z_cap_(nChars) inline LPSTR WINAPI AtlW2AHelper( - _Out_opt_z_cap_(nChars) LPSTR lpa, - _In_opt_z_ LPCWSTR lpw, - _In_ int nChars) throw() + _Out_opt_z_cap_(nChars) LPSTR lpa, + _In_opt_z_ LPCWSTR lpw, + _In_ int nChars) throw() { - return AtlW2AHelper(lpa, lpw, nChars, CP_ACP); + return AtlW2AHelper(lpa, lpw, nChars, CP_ACP); } #ifndef _CONVERSION_DONT_USE_THREAD_LOCALE - #ifdef ATLA2WHELPER - #undef ATLA2WHELPER - #undef ATLW2AHELPER - #endif - #define ATLA2WHELPER AtlA2WHelper - #define ATLW2AHELPER AtlW2AHelper + #ifdef ATLA2WHELPER + #undef ATLA2WHELPER + #undef ATLW2AHELPER + #endif + #define ATLA2WHELPER AtlA2WHelper + #define ATLW2AHELPER AtlW2AHelper #else - #ifndef ATLA2WHELPER - #define ATLA2WHELPER AtlA2WHelper - #define ATLW2AHELPER AtlW2AHelper - #endif + #ifndef ATLA2WHELPER + #define ATLA2WHELPER AtlA2WHelper + #define ATLW2AHELPER AtlW2AHelper + #endif #endif #ifndef _ATL_EX_CONVERSION_MACROS_ONLY #define A2W(lpa) (\ - ((_lpa = lpa) == NULL) ? NULL : (\ - _convert = (lstrlenA(_lpa)+1),\ - (INT_MAX/2<_convert)? NULL : \ - ATLA2WHELPER((LPWSTR) alloca(_convert*sizeof(WCHAR)), _lpa, _convert, _acp))) + ((_lpa = lpa) == NULL) ? NULL : (\ + _convert = (lstrlenA(_lpa)+1),\ + (INT_MAX/2<_convert)? NULL : \ + ATLA2WHELPER((LPWSTR) alloca(_convert*sizeof(WCHAR)), _lpa, _convert, _acp))) #define W2A(lpw) (\ - ((_lpw = lpw) == NULL) ? NULL : (\ - (_convert = (lstrlenW(_lpw)+1), \ - (_convert>INT_MAX/2) ? NULL : \ - ATLW2AHELPER((LPSTR) alloca(_convert*sizeof(WCHAR)), _lpw, _convert*sizeof(WCHAR), _acp)))) + ((_lpw = lpw) == NULL) ? NULL : (\ + (_convert = (lstrlenW(_lpw)+1), \ + (_convert>INT_MAX/2) ? NULL : \ + ATLW2AHELPER((LPSTR) alloca(_convert*sizeof(WCHAR)), _lpw, _convert*sizeof(WCHAR), _acp)))) #define A2W_CP(lpa, cp) (\ - ((_lpa = lpa) == NULL) ? NULL : (\ - _convert = (lstrlenA(_lpa)+1),\ - (INT_MAX/2<_convert)? NULL : \ - ATLA2WHELPER((LPWSTR) alloca(_convert*sizeof(WCHAR)), _lpa, _convert, (cp)))) + ((_lpa = lpa) == NULL) ? NULL : (\ + _convert = (lstrlenA(_lpa)+1),\ + (INT_MAX/2<_convert)? NULL : \ + ATLA2WHELPER((LPWSTR) alloca(_convert*sizeof(WCHAR)), _lpa, _convert, (cp)))) #define W2A_CP(lpw, cp) (\ - ((_lpw = lpw) == NULL) ? NULL : (\ - (_convert = (lstrlenW(_lpw)+1), \ - (_convert>INT_MAX/2) ? NULL : \ - ATLW2AHELPER((LPSTR) alloca(_convert*sizeof(WCHAR)), _lpw, _convert*sizeof(WCHAR), (cp))))) + ((_lpw = lpw) == NULL) ? NULL : (\ + (_convert = (lstrlenW(_lpw)+1), \ + (_convert>INT_MAX/2) ? NULL : \ + ATLW2AHELPER((LPSTR) alloca(_convert*sizeof(WCHAR)), _lpw, _convert*sizeof(WCHAR), (cp))))) #endif @@ -657,48 +657,48 @@ _Ret_opt_z_cap_(nChars) inline LPSTR WINAPI AtlW2AHelper( // Notice that nChars is never used in these conversion functions. We cannot change the behavior of // these functions to actually use nChars because we could potentially break a lot of legacy code. #define A2W_EX(lpa, nChars) (\ - ((_lpa_ex = lpa) == NULL) ? NULL : (\ - _convert_ex = (lstrlenA(_lpa_ex)+1),\ - FAILED(::ATL::AtlMultiply(&_convert_ex, _convert_ex, static_cast(sizeof(WCHAR)))) ? NULL : \ - ATLA2WHELPER( \ - (LPWSTR)_ATL_SAFE_ALLOCA(_convert_ex, _ATL_SAFE_ALLOCA_DEF_THRESHOLD), \ - _lpa_ex, \ - _convert_ex / sizeof(WCHAR), \ - _acp_ex))) + ((_lpa_ex = lpa) == NULL) ? NULL : (\ + _convert_ex = (lstrlenA(_lpa_ex)+1),\ + FAILED(::ATL::AtlMultiply(&_convert_ex, _convert_ex, static_cast(sizeof(WCHAR)))) ? NULL : \ + ATLA2WHELPER( \ + (LPWSTR)_ATL_SAFE_ALLOCA(_convert_ex, _ATL_SAFE_ALLOCA_DEF_THRESHOLD), \ + _lpa_ex, \ + _convert_ex / sizeof(WCHAR), \ + _acp_ex))) #define A2W_EX_DEF(lpa) A2W_EX(lpa, _ATL_SAFE_ALLOCA_DEF_THRESHOLD) #define W2A_EX(lpw, nChars) (\ - ((_lpw_ex = lpw) == NULL) ? NULL : (\ - _convert_ex = (lstrlenW(_lpw_ex)+1),\ - FAILED(::ATL::AtlMultiply(&_convert_ex, _convert_ex, static_cast(sizeof(WCHAR)))) ? NULL : \ - ATLW2AHELPER( \ - (LPSTR)_ATL_SAFE_ALLOCA(_convert_ex, _ATL_SAFE_ALLOCA_DEF_THRESHOLD), \ - _lpw_ex, \ - _convert_ex, \ - _acp_ex))) + ((_lpw_ex = lpw) == NULL) ? NULL : (\ + _convert_ex = (lstrlenW(_lpw_ex)+1),\ + FAILED(::ATL::AtlMultiply(&_convert_ex, _convert_ex, static_cast(sizeof(WCHAR)))) ? NULL : \ + ATLW2AHELPER( \ + (LPSTR)_ATL_SAFE_ALLOCA(_convert_ex, _ATL_SAFE_ALLOCA_DEF_THRESHOLD), \ + _lpw_ex, \ + _convert_ex, \ + _acp_ex))) #define W2A_EX_DEF(lpa) W2A_EX(lpa, _ATL_SAFE_ALLOCA_DEF_THRESHOLD) #define A2W_CP_EX(lpa, nChars, cp) (\ - ((_lpa_ex = lpa) == NULL) ? NULL : (\ - _convert_ex = (lstrlenA(_lpa_ex)+1),\ - FAILED(::ATL::AtlMultiply(&_convert_ex, _convert_ex, static_cast(sizeof(WCHAR)))) ? NULL : \ - ATLA2WHELPER( \ - (LPWSTR)_ATL_SAFE_ALLOCA(_convert_ex, _ATL_SAFE_ALLOCA_DEF_THRESHOLD), \ - _lpa_ex, \ - _convert_ex / sizeof(WCHAR), \ - (cp)))) + ((_lpa_ex = lpa) == NULL) ? NULL : (\ + _convert_ex = (lstrlenA(_lpa_ex)+1),\ + FAILED(::ATL::AtlMultiply(&_convert_ex, _convert_ex, static_cast(sizeof(WCHAR)))) ? NULL : \ + ATLA2WHELPER( \ + (LPWSTR)_ATL_SAFE_ALLOCA(_convert_ex, _ATL_SAFE_ALLOCA_DEF_THRESHOLD), \ + _lpa_ex, \ + _convert_ex / sizeof(WCHAR), \ + (cp)))) #define W2A_CP_EX(lpw, nChars, cp) (\ - ((_lpw_ex = lpw) == NULL) ? NULL : (\ - _convert_ex = (lstrlenW(_lpw_ex)+1),\ - FAILED(::ATL::AtlMultiply(&_convert_ex, _convert_ex, static_cast(sizeof(WCHAR)))) ? NULL : \ - ATLW2AHELPER( \ - (LPSTR)_ATL_SAFE_ALLOCA(_convert_ex, _ATL_SAFE_ALLOCA_DEF_THRESHOLD), \ - _lpw_ex, \ - _convert_ex, \ - (cp)))) + ((_lpw_ex = lpw) == NULL) ? NULL : (\ + _convert_ex = (lstrlenW(_lpw_ex)+1),\ + FAILED(::ATL::AtlMultiply(&_convert_ex, _convert_ex, static_cast(sizeof(WCHAR)))) ? NULL : \ + ATLW2AHELPER( \ + (LPSTR)_ATL_SAFE_ALLOCA(_convert_ex, _ATL_SAFE_ALLOCA_DEF_THRESHOLD), \ + _lpw_ex, \ + _convert_ex, \ + (cp)))) #ifndef _ATL_EX_CONVERSION_MACROS_ONLY @@ -708,7 +708,7 @@ _Ret_opt_z_cap_(nChars) inline LPSTR WINAPI AtlW2AHelper( #define A2CW_CP(lpa, cp) ((LPCWSTR)A2W_CP(lpa, (cp))) #define W2CA_CP(lpw, cp) ((LPCSTR)W2A_CP(lpw, (cp))) -#endif // _ATL_EX_CONVERSION_MACROS_ONLY +#endif // _ATL_EX_CONVERSION_MACROS_ONLY #define A2CW_EX(lpa, nChar) ((LPCWSTR)A2W_EX(lpa, nChar)) #define A2CW_EX_DEF(lpa) ((LPCWSTR)A2W_EX_DEF(lpa)) @@ -720,23 +720,23 @@ _Ret_opt_z_cap_(nChars) inline LPSTR WINAPI AtlW2AHelper( inline int ocslen(_In_z_ LPCOLESTR x) throw() { - return lstrlenW(x); + return lstrlenW(x); } inline bool ocscpy_s( - _Out_z_cap_(maxSize) LPOLESTR dest, - _In_ size_t maxSize, - _In_z_ LPCOLESTR src) throw() + _Out_z_cap_(maxSize) LPOLESTR dest, + _In_ size_t maxSize, + _In_z_ LPCOLESTR src) throw() { - return 0 == memcpy_s(dest, maxSize*sizeof(WCHAR), src, (ocslen(src)+1)*sizeof(WCHAR)); + return 0 == memcpy_s(dest, maxSize*sizeof(WCHAR), src, (ocslen(src)+1)*sizeof(WCHAR)); } inline bool ocscat_s( - _Inout_z_cap_(maxSize) LPOLESTR dest, - _In_ size_t maxSize, - _In_z_ LPCOLESTR src) throw() + _Inout_z_cap_(maxSize) LPOLESTR dest, + _In_ size_t maxSize, + _In_z_ LPCOLESTR src) throw() { - return 0 == wcscat_s(dest, maxSize,src); + return 0 == wcscat_s(dest, maxSize,src); } #if defined(_UNICODE) @@ -744,88 +744,88 @@ inline bool ocscat_s( // in these cases the default (TCHAR) is the same as OLECHAR _Ret_z_ inline LPCOLESTR T2COLE_EX( - _In_z_ LPCTSTR lp, - _In_ UINT) + _In_z_ LPCTSTR lp, + _In_ UINT) { - return lp; + return lp; } _Ret_z_ inline LPCOLESTR T2COLE_EX_DEF(_In_z_ LPCTSTR lp) { - return lp; + return lp; } _Ret_z_ inline LPCTSTR OLE2CT_EX( - _In_z_ LPCOLESTR lp, - _In_ UINT) + _In_z_ LPCOLESTR lp, + _In_ UINT) { - return lp; + return lp; } _Ret_z_ inline LPCTSTR OLE2CT_EX_DEF(_In_z_ LPCOLESTR lp) { - return lp; + return lp; } _Ret_z_ inline LPOLESTR T2OLE_EX( - _In_z_ LPTSTR lp, - _In_ UINT) + _In_z_ LPTSTR lp, + _In_ UINT) { - return lp; + return lp; } _Ret_z_ inline LPOLESTR T2OLE_EX_DEF(_In_z_ LPTSTR lp) { - return lp; + return lp; } _Ret_z_ inline LPTSTR OLE2T_EX( - _In_z_ LPOLESTR lp, - _In_ UINT) + _In_z_ LPOLESTR lp, + _In_ UINT) { - return lp; -} + return lp; +} _Ret_z_ inline LPTSTR OLE2T_EX_DEF(_In_z_ LPOLESTR lp) { - return lp; -} + return lp; +} #ifndef _ATL_EX_CONVERSION_MACROS_ONLY _Ret_z_ inline LPCOLESTR T2COLE(_In_z_ LPCTSTR lp) { - return lp; + return lp; } _Ret_z_ inline LPCTSTR OLE2CT(_In_z_ LPCOLESTR lp) { - return lp; + return lp; } _Ret_z_ inline LPOLESTR T2OLE(_In_z_ LPTSTR lp) { - return lp; + return lp; } _Ret_z_ inline LPTSTR OLE2T(_In_z_ LPOLESTR lp) { - return lp; + return lp; } -#endif // _ATL_EX_CONVERSION_MACROS_ONLY +#endif // _ATL_EX_CONVERSION_MACROS_ONLY #else // !defined(_UNICODE) _ATL_INSECURE_DEPRECATE("ocscpy is not safe. Intead, use ocscpy_s") inline OLECHAR* ocscpy( - _Inout_ _Post_z_ LPOLESTR dest, - _In_z_ LPCOLESTR src) throw() + _Inout_ _Post_z_ LPOLESTR dest, + _In_z_ LPCOLESTR src) throw() { #pragma warning(push) #pragma warning(disable:4996) - return (LPOLESTR) memcpy(dest, src, (lstrlenW(src)+1)*sizeof(WCHAR)); + return (LPOLESTR) memcpy(dest, src, (lstrlenW(src)+1)*sizeof(WCHAR)); #pragma warning(pop) } _ATL_INSECURE_DEPRECATE("ocscat is not safe. Intead, use ocscat_s") inline OLECHAR* ocscat( - _Inout_ _Post_z_ LPOLESTR dest, - _In_z_ LPCOLESTR src) throw() + _Inout_ _Post_z_ LPOLESTR dest, + _In_z_ LPCOLESTR src) throw() { #pragma warning(push) #pragma warning(disable:4996) - return ocscpy(dest+ocslen(dest), src); + return ocscpy(dest+ocslen(dest), src); #pragma warning(pop) } @@ -845,29 +845,29 @@ inline OLECHAR* ocscat( #define OLE2CT(lpo) W2CA(lpo) #define OLE2T(lpo) W2A(lpo) -#endif // _ATL_EX_CONVERSION_MACROS_ONLY +#endif // _ATL_EX_CONVERSION_MACROS_ONLY #endif // defined(_UNICODE) _Ret_z_ inline LPOLESTR W2OLE_EX( - _In_z_ LPWSTR lp, - _In_ UINT) + _In_z_ LPWSTR lp, + _In_ UINT) { - return lp; + return lp; } _Ret_z_ inline LPOLESTR W2OLE_EX_DEF(_In_z_ LPWSTR lp) { - return lp; + return lp; } _Ret_z_ inline LPWSTR OLE2W_EX( - _In_z_ LPOLESTR lp, - _In_ UINT) + _In_z_ LPOLESTR lp, + _In_ UINT) { - return lp; + return lp; } _Ret_z_ inline LPWSTR OLE2W_EX_DEF(_In_z_ LPOLESTR lp) { - return lp; + return lp; } #define A2OLE_EX A2W_EX @@ -876,24 +876,24 @@ _Ret_z_ inline LPWSTR OLE2W_EX_DEF(_In_z_ LPOLESTR lp) #define OLE2A_EX_DEF W2A_EX_DEF _Ret_z_ inline LPCOLESTR W2COLE_EX( - _In_z_ LPCWSTR lp, - _In_ UINT) + _In_z_ LPCWSTR lp, + _In_ UINT) { - return lp; + return lp; } _Ret_z_ inline LPCOLESTR W2COLE_EX_DEF(_In_z_ LPCWSTR lp) { - return lp; + return lp; } _Ret_z_ inline LPCWSTR OLE2CW_EX( - _In_z_ LPCOLESTR lp, - _In_ UINT) + _In_z_ LPCOLESTR lp, + _In_ UINT) { - return lp; + return lp; } _Ret_z_ inline LPCWSTR OLE2CW_EX_DEF(_In_z_ LPCOLESTR lp) { - return lp; + return lp; } #define A2COLE_EX A2CW_EX @@ -905,11 +905,11 @@ _Ret_z_ inline LPCWSTR OLE2CW_EX_DEF(_In_z_ LPCOLESTR lp) _Ret_z_ inline LPOLESTR W2OLE(_In_z_ LPWSTR lp) { - return lp; + return lp; } _Ret_z_ inline LPWSTR OLE2W(_In_z_ LPOLESTR lp) { - return lp; + return lp; } #define A2OLE A2W @@ -917,17 +917,17 @@ _Ret_z_ inline LPWSTR OLE2W(_In_z_ LPOLESTR lp) _Ret_z_ inline LPCOLESTR W2COLE(_In_z_ LPCWSTR lp) { - return lp; + return lp; } _Ret_z_ inline LPCWSTR OLE2CW(_In_z_ LPCOLESTR lp) { - return lp; + return lp; } #define A2COLE A2CW #define OLE2CA W2CA -#endif // _ATL_EX_CONVERSION_MACROS_ONLY +#endif // _ATL_EX_CONVERSION_MACROS_ONLY #if defined(_UNICODE) @@ -937,24 +937,24 @@ _Ret_z_ inline LPCWSTR OLE2CW(_In_z_ LPCOLESTR lp) #define A2T_EX_DEF A2W_EX_DEF _Ret_z_ inline LPWSTR T2W_EX( - _In_z_ LPTSTR lp, - _In_ UINT) -{ - return lp; + _In_z_ LPTSTR lp, + _In_ UINT) +{ + return lp; } _Ret_z_ inline LPWSTR T2W_EX_DEF(_In_z_ LPTSTR lp) { - return lp; + return lp; } _Ret_z_ inline LPTSTR W2T_EX( - _In_z_ LPWSTR lp, - _In_ UINT) + _In_z_ LPWSTR lp, + _In_ UINT) { - return lp; + return lp; } _Ret_z_ inline LPTSTR W2T_DEF(_In_z_ LPWSTR lp) { - return lp; + return lp; } #define T2CA_EX W2CA_EX @@ -963,24 +963,24 @@ _Ret_z_ inline LPTSTR W2T_DEF(_In_z_ LPWSTR lp) #define A2CT_EX_DEF A2CW_EX_DEF _Ret_z_ inline LPCWSTR T2CW_EX( - _In_z_ LPCTSTR lp, - _In_ UINT) + _In_z_ LPCTSTR lp, + _In_ UINT) { - return lp; + return lp; } _Ret_z_ inline LPCWSTR T2CW_EX_DEF(_In_z_ LPCTSTR lp) { - return lp; + return lp; } _Ret_z_ inline LPCTSTR W2CT_EX( - _In_z_ LPCWSTR lp, - _In_ UINT) + _In_z_ LPCWSTR lp, + _In_ UINT) { - return lp; + return lp; } _Ret_z_ inline LPCTSTR W2CT_EX_DEF(_In_z_ LPCWSTR lp) { - return lp; + return lp; } #ifndef _ATL_EX_CONVERSION_MACROS_ONLY @@ -990,11 +990,11 @@ _Ret_z_ inline LPCTSTR W2CT_EX_DEF(_In_z_ LPCWSTR lp) _Ret_z_ inline LPWSTR T2W(_In_z_ LPTSTR lp) { - return lp; + return lp; } _Ret_z_ inline LPTSTR W2T(_In_z_ LPWSTR lp) { - return lp; + return lp; } #define T2CA W2CA @@ -1002,15 +1002,15 @@ _Ret_z_ inline LPTSTR W2T(_In_z_ LPWSTR lp) _Ret_z_ inline LPCWSTR T2CW(_In_z_ LPCTSTR lp) { - return lp; + return lp; } _Ret_z_ inline LPCTSTR W2CT(_In_z_ LPCWSTR lp) { - return lp; + return lp; } -#endif // _ATL_EX_CONVERSION_MACROS_ONLY - +#endif // _ATL_EX_CONVERSION_MACROS_ONLY + #else // !defined(_UNICODE) #define T2W_EX A2W_EX @@ -1019,24 +1019,24 @@ _Ret_z_ inline LPCTSTR W2CT(_In_z_ LPCWSTR lp) #define W2T_EX_DEF W2A_EX_DEF _Ret_z_ inline LPSTR T2A_EX( - _In_z_ LPTSTR lp, - _In_ UINT) + _In_z_ LPTSTR lp, + _In_ UINT) { - return lp; + return lp; } _Ret_z_ inline LPSTR T2A_EX_DEF(_In_z_ LPTSTR lp) { - return lp; + return lp; } _Ret_z_ inline LPTSTR A2T_EX( - _In_z_ LPSTR lp, - _In_ UINT) + _In_z_ LPSTR lp, + _In_ UINT) { - return lp; + return lp; } _Ret_z_ inline LPTSTR A2T_EX_DEF(_In_z_ LPSTR lp) { - return lp; + return lp; } #define T2CW_EX A2CW_EX @@ -1045,24 +1045,24 @@ _Ret_z_ inline LPTSTR A2T_EX_DEF(_In_z_ LPSTR lp) #define W2CT_EX_DEF W2CA_EX_DEF _Ret_z_ inline LPCSTR T2CA_EX( - _In_z_ LPCTSTR lp, - _In_ UINT) + _In_z_ LPCTSTR lp, + _In_ UINT) { - return lp; + return lp; } _Ret_z_ inline LPCSTR T2CA_EX_DEF(_In_z_ LPCTSTR lp) { - return lp; + return lp; } _Ret_z_ inline LPCTSTR A2CT_EX( - _In_z_ LPCSTR lp, - _In_ UINT) + _In_z_ LPCSTR lp, + _In_ UINT) { - return lp; + return lp; } _Ret_z_ inline LPCTSTR A2CT_EX_DEF(_In_z_ LPCSTR lp) { - return lp; + return lp; } #ifndef _ATL_EX_CONVERSION_MACROS_ONLY @@ -1071,125 +1071,125 @@ _Ret_z_ inline LPCTSTR A2CT_EX_DEF(_In_z_ LPCSTR lp) #define W2T W2A _Ret_z_ inline LPSTR T2A(_In_z_ LPTSTR lp) { - return lp; + return lp; } _Ret_z_ inline LPTSTR A2T(_In_z_ LPSTR lp) { - return lp; + return lp; } #define T2CW A2CW #define W2CT W2CA _Ret_z_ inline LPCSTR T2CA(_In_z_ LPCTSTR lp) { - return lp; + return lp; } _Ret_z_ inline LPCTSTR A2CT(_In_z_ LPCSTR lp) { - return lp; + return lp; } -#endif // _ATL_EX_CONVERSION_MACROS_ONLY +#endif // _ATL_EX_CONVERSION_MACROS_ONLY #endif // defined(_UNICODE) _Check_return_ _Ret_opt_z_ inline BSTR A2WBSTR( - _In_opt_z_ LPCSTR lp, - _In_ int nLen = -1) + _In_opt_z_ LPCSTR lp, + _In_ int nLen = -1) { - if (lp == NULL || nLen == 0) - return NULL; - USES_CONVERSION_EX; - BSTR str = NULL; + if (lp == NULL || nLen == 0) + return NULL; + USES_CONVERSION_EX; + BSTR str = NULL; ATLPREFAST_SUPPRESS(6385) - int nConvertedLen = MultiByteToWideChar(_acp_ex, 0, lp, nLen, NULL, 0); + int nConvertedLen = MultiByteToWideChar(_acp_ex, 0, lp, nLen, NULL, 0); ATLPREFAST_UNSUPPRESS() - int nAllocLen = nConvertedLen; - if (nLen == -1) - nAllocLen -= 1; // Don't allocate terminating '\0' - str = ::SysAllocStringLen(NULL, nAllocLen); + int nAllocLen = nConvertedLen; + if (nLen == -1) + nAllocLen -= 1; // Don't allocate terminating '\0' + str = ::SysAllocStringLen(NULL, nAllocLen); - if (str != NULL) - { - int nResult; - nResult = MultiByteToWideChar(_acp_ex, 0, lp, nLen, str, nConvertedLen); - ATLASSERT(nResult == nConvertedLen); - if(nResult != nConvertedLen) - { - SysFreeString(str); - return NULL; - } + if (str != NULL) + { + int nResult; + nResult = MultiByteToWideChar(_acp_ex, 0, lp, nLen, str, nConvertedLen); + ATLASSERT(nResult == nConvertedLen); + if(nResult != nConvertedLen) + { + SysFreeString(str); + return NULL; + } - } - return str; + } + return str; } _Ret_opt_z_ inline BSTR OLE2BSTR(_In_opt_z_ LPCOLESTR lp) { - return ::SysAllocString(lp); + return ::SysAllocString(lp); } #if defined(_UNICODE) // in these cases the default (TCHAR) is the same as OLECHAR _Ret_opt_z_ inline BSTR T2BSTR_EX(_In_opt_z_ LPCTSTR lp) { - return ::SysAllocString(lp); + return ::SysAllocString(lp); } _Ret_opt_z_ inline BSTR A2BSTR_EX(_In_opt_z_ LPCSTR lp) { - return A2WBSTR(lp); + return A2WBSTR(lp); } _Ret_opt_z_ inline BSTR W2BSTR_EX(_In_opt_z_ LPCWSTR lp) { - return ::SysAllocString(lp); + return ::SysAllocString(lp); } #ifndef _ATL_EX_CONVERSION_MACROS_ONLY _Ret_opt_z_ inline BSTR T2BSTR(_In_opt_z_ LPCTSTR lp) { - return ::SysAllocString(lp); + return ::SysAllocString(lp); } _Ret_opt_z_ inline BSTR A2BSTR(_In_opt_z_ LPCSTR lp) { - return A2WBSTR(lp); + return A2WBSTR(lp); } _Ret_opt_z_ inline BSTR W2BSTR(_In_opt_z_ LPCWSTR lp) { - return ::SysAllocString(lp); + return ::SysAllocString(lp); } - -#endif // _ATL_EX_CONVERSION_MACROS_ONLY + +#endif // _ATL_EX_CONVERSION_MACROS_ONLY #else // !defined(_UNICODE) _Ret_opt_z_ inline BSTR T2BSTR_EX(_In_opt_z_ LPCTSTR lp) { - return A2WBSTR(lp); + return A2WBSTR(lp); } _Ret_opt_z_ inline BSTR A2BSTR_EX(_In_opt_z_ LPCSTR lp) { - return A2WBSTR(lp); + return A2WBSTR(lp); } _Ret_opt_z_ inline BSTR W2BSTR_EX(_In_opt_z_ LPCWSTR lp) { - return ::SysAllocString(lp); + return ::SysAllocString(lp); } - + #ifndef _ATL_EX_CONVERSION_MACROS_ONLY _Ret_opt_z_ inline BSTR T2BSTR(_In_opt_z_ LPCTSTR lp) { - return A2WBSTR(lp); + return A2WBSTR(lp); } _Ret_opt_z_ inline BSTR A2BSTR(_In_opt_z_ LPCSTR lp) { - return A2WBSTR(lp); + return A2WBSTR(lp); } _Ret_opt_z_ inline BSTR W2BSTR(_In_opt_z_ LPCWSTR lp) { - return ::SysAllocString(lp); + return ::SysAllocString(lp); } -#endif // _ATL_EX_CONVERSION_MACROS_ONLY +#endif // _ATL_EX_CONVERSION_MACROS_ONLY #endif // defined(_UNICODE) @@ -1197,139 +1197,139 @@ _Ret_opt_z_ inline BSTR W2BSTR(_In_opt_z_ LPCWSTR lp) ///////////////////////////////////////////////////////////////////////////// // Global UNICODE<>ANSI translation helpers inline LPDEVMODEW AtlDevModeA2W( - _Inout_ LPDEVMODEW lpDevModeW, - _In_ const DEVMODEA* lpDevModeA) + _Inout_ LPDEVMODEW lpDevModeW, + _In_ const DEVMODEA* lpDevModeA) { - USES_CONVERSION_EX; - ATLASSERT(lpDevModeW != NULL); - if (lpDevModeA == NULL || lpDevModeW == NULL) - { - return NULL; - } + USES_CONVERSION_EX; + ATLASSERT(lpDevModeW != NULL); + if (lpDevModeA == NULL || lpDevModeW == NULL) + { + return NULL; + } - AtlA2WHelper(lpDevModeW->dmDeviceName, (LPCSTR)lpDevModeA->dmDeviceName, 32, _acp_ex); + AtlA2WHelper(lpDevModeW->dmDeviceName, (LPCSTR)lpDevModeA->dmDeviceName, 32, _acp_ex); - if(0 != memcpy_s(&lpDevModeW->dmSpecVersion, offsetof(DEVMODEW, dmFormName) - offsetof(DEVMODEW, dmSpecVersion), - &lpDevModeA->dmSpecVersion, offsetof(DEVMODEW, dmFormName) - offsetof(DEVMODEW, dmSpecVersion))) - { - return NULL; - } + if(0 != memcpy_s(&lpDevModeW->dmSpecVersion, offsetof(DEVMODEW, dmFormName) - offsetof(DEVMODEW, dmSpecVersion), + &lpDevModeA->dmSpecVersion, offsetof(DEVMODEW, dmFormName) - offsetof(DEVMODEW, dmSpecVersion))) + { + return NULL; + } - AtlA2WHelper(lpDevModeW->dmFormName, (LPCSTR)lpDevModeA->dmFormName, 32, _acp_ex); + AtlA2WHelper(lpDevModeW->dmFormName, (LPCSTR)lpDevModeA->dmFormName, 32, _acp_ex); - if(0 != memcpy_s(&lpDevModeW->dmLogPixels, sizeof(DEVMODEW) - offsetof(DEVMODEW, dmLogPixels), - &lpDevModeA->dmLogPixels, sizeof(DEVMODEW) - offsetof(DEVMODEW, dmLogPixels))) - { - return NULL; - } + if(0 != memcpy_s(&lpDevModeW->dmLogPixels, sizeof(DEVMODEW) - offsetof(DEVMODEW, dmLogPixels), + &lpDevModeA->dmLogPixels, sizeof(DEVMODEW) - offsetof(DEVMODEW, dmLogPixels))) + { + return NULL; + } - if (lpDevModeA->dmDriverExtra != 0) - { - // lpDevModeW holds more info + if (lpDevModeA->dmDriverExtra != 0) + { + // lpDevModeW holds more info #pragma warning(push) #pragma warning(disable:26000) - if(0 != memcpy_s(lpDevModeW+1, lpDevModeA->dmDriverExtra, lpDevModeA+1, lpDevModeA->dmDriverExtra)) - { - return NULL; - } + if(0 != memcpy_s(lpDevModeW+1, lpDevModeA->dmDriverExtra, lpDevModeA+1, lpDevModeA->dmDriverExtra)) + { + return NULL; + } #pragma warning(pop) - } - lpDevModeW->dmSize = sizeof(DEVMODEW); - return lpDevModeW; + } + lpDevModeW->dmSize = sizeof(DEVMODEW); + return lpDevModeW; } inline LPTEXTMETRICW AtlTextMetricA2W( - _Out_ LPTEXTMETRICW lptmW, - _In_ LPTEXTMETRICA lptmA) + _Out_ LPTEXTMETRICW lptmW, + _In_ LPTEXTMETRICA lptmA) { - USES_CONVERSION_EX; - ATLASSERT(lptmW != NULL); - if (lptmA == NULL || lptmW == NULL) - return NULL; + USES_CONVERSION_EX; + ATLASSERT(lptmW != NULL); + if (lptmA == NULL || lptmW == NULL) + return NULL; - if(0 != memcpy_s(lptmW, sizeof(LONG) * 11, lptmA, sizeof(LONG) * 11)) - { - return NULL; - } + if(0 != memcpy_s(lptmW, sizeof(LONG) * 11, lptmA, sizeof(LONG) * 11)) + { + return NULL; + } - if(0 != memcpy_s(&lptmW->tmItalic, sizeof(BYTE) * 5, &lptmA->tmItalic, sizeof(BYTE) * 5)) - { - return NULL; - } + if(0 != memcpy_s(&lptmW->tmItalic, sizeof(BYTE) * 5, &lptmA->tmItalic, sizeof(BYTE) * 5)) + { + return NULL; + } - if(MultiByteToWideChar(_acp_ex, 0, (LPCSTR)&lptmA->tmFirstChar, 1, &lptmW->tmFirstChar, 1) == 0) - { - ATLASSERT(FALSE); - return NULL; - } - - if(MultiByteToWideChar(_acp_ex, 0, (LPCSTR)&lptmA->tmLastChar, 1, &lptmW->tmLastChar, 1) == 0) - { - ATLASSERT(FALSE); - return NULL; - } - - if(MultiByteToWideChar(_acp_ex, 0, (LPCSTR)&lptmA->tmDefaultChar, 1, &lptmW->tmDefaultChar, 1)== 0) - { - ATLASSERT(FALSE); - return NULL; - } - - if(MultiByteToWideChar(_acp_ex, 0, (LPCSTR)&lptmA->tmBreakChar, 1, &lptmW->tmBreakChar, 1) == 0) - { - ATLASSERT(FALSE); - return NULL; - } - - return lptmW; + if(MultiByteToWideChar(_acp_ex, 0, (LPCSTR)&lptmA->tmFirstChar, 1, &lptmW->tmFirstChar, 1) == 0) + { + ATLASSERT(FALSE); + return NULL; + } + + if(MultiByteToWideChar(_acp_ex, 0, (LPCSTR)&lptmA->tmLastChar, 1, &lptmW->tmLastChar, 1) == 0) + { + ATLASSERT(FALSE); + return NULL; + } + + if(MultiByteToWideChar(_acp_ex, 0, (LPCSTR)&lptmA->tmDefaultChar, 1, &lptmW->tmDefaultChar, 1)== 0) + { + ATLASSERT(FALSE); + return NULL; + } + + if(MultiByteToWideChar(_acp_ex, 0, (LPCSTR)&lptmA->tmBreakChar, 1, &lptmW->tmBreakChar, 1) == 0) + { + ATLASSERT(FALSE); + return NULL; + } + + return lptmW; } inline LPTEXTMETRICA AtlTextMetricW2A( - _Out_ LPTEXTMETRICA lptmA, - _In_ LPTEXTMETRICW lptmW) + _Out_ LPTEXTMETRICA lptmA, + _In_ LPTEXTMETRICW lptmW) { - USES_CONVERSION_EX; - ATLASSERT(lptmA != NULL); - if (lptmW == NULL || lptmA == NULL) - { - return NULL; - } + USES_CONVERSION_EX; + ATLASSERT(lptmA != NULL); + if (lptmW == NULL || lptmA == NULL) + { + return NULL; + } - if(0 != memcpy_s(lptmA, sizeof(LONG) * 11, lptmW, sizeof(LONG) * 11)) - { - return NULL; - } + if(0 != memcpy_s(lptmA, sizeof(LONG) * 11, lptmW, sizeof(LONG) * 11)) + { + return NULL; + } - if(0 != memcpy_s(&lptmA->tmItalic, sizeof(BYTE) * 5, &lptmW->tmItalic, sizeof(BYTE) * 5)) - { - return NULL; - } - - if(WideCharToMultiByte(_acp_ex, 0, &lptmW->tmFirstChar, 1, (LPSTR)&lptmA->tmFirstChar, 1, NULL, NULL) == 0) - { - ATLASSERT(FALSE); - return NULL; - } + if(0 != memcpy_s(&lptmA->tmItalic, sizeof(BYTE) * 5, &lptmW->tmItalic, sizeof(BYTE) * 5)) + { + return NULL; + } + + if(WideCharToMultiByte(_acp_ex, 0, &lptmW->tmFirstChar, 1, (LPSTR)&lptmA->tmFirstChar, 1, NULL, NULL) == 0) + { + ATLASSERT(FALSE); + return NULL; + } - if(WideCharToMultiByte(_acp_ex, 0, &lptmW->tmLastChar, 1, (LPSTR)&lptmA->tmLastChar, 1, NULL, NULL) == 0) - { - ATLASSERT(FALSE); - return NULL; - } + if(WideCharToMultiByte(_acp_ex, 0, &lptmW->tmLastChar, 1, (LPSTR)&lptmA->tmLastChar, 1, NULL, NULL) == 0) + { + ATLASSERT(FALSE); + return NULL; + } - if(WideCharToMultiByte(_acp_ex, 0, &lptmW->tmDefaultChar, 1, (LPSTR)&lptmA->tmDefaultChar, 1, NULL, NULL) == 0) - { - ATLASSERT(FALSE); - return NULL; - } + if(WideCharToMultiByte(_acp_ex, 0, &lptmW->tmDefaultChar, 1, (LPSTR)&lptmA->tmDefaultChar, 1, NULL, NULL) == 0) + { + ATLASSERT(FALSE); + return NULL; + } - if(WideCharToMultiByte(_acp_ex, 0, &lptmW->tmBreakChar, 1, (LPSTR)&lptmA->tmBreakChar, 1, NULL, NULL) == 0) - { - ATLASSERT(FALSE); - return NULL; - } + if(WideCharToMultiByte(_acp_ex, 0, &lptmW->tmBreakChar, 1, (LPSTR)&lptmA->tmBreakChar, 1, NULL, NULL) == 0) + { + ATLASSERT(FALSE); + return NULL; + } - return lptmA; + return lptmA; } #ifndef ATLDEVMODEA2W @@ -1341,26 +1341,26 @@ inline LPTEXTMETRICA AtlTextMetricW2A( // Requires USES_CONVERSION_EX or USES_ATL_SAFE_ALLOCA macro before using the _EX versions of the macros #define DEVMODEW2A_EX(lpw)\ - (((lpw) == NULL) ? NULL : ATLDEVMODEW2A((LPDEVMODEA)_ATL_SAFE_ALLOCA(sizeof(DEVMODEA)+(lpw)->dmDriverExtra, _ATL_SAFE_ALLOCA_DEF_THRESHOLD), (lpw))) + (((lpw) == NULL) ? NULL : ATLDEVMODEW2A((LPDEVMODEA)_ATL_SAFE_ALLOCA(sizeof(DEVMODEA)+(lpw)->dmDriverExtra, _ATL_SAFE_ALLOCA_DEF_THRESHOLD), (lpw))) #define DEVMODEA2W_EX(lpa)\ - (((lpa) == NULL) ? NULL : ATLDEVMODEA2W((LPDEVMODEW)_ATL_SAFE_ALLOCA(sizeof(DEVMODEW)+(lpa)->dmDriverExtra, _ATL_SAFE_ALLOCA_DEF_THRESHOLD), (lpa))) + (((lpa) == NULL) ? NULL : ATLDEVMODEA2W((LPDEVMODEW)_ATL_SAFE_ALLOCA(sizeof(DEVMODEW)+(lpa)->dmDriverExtra, _ATL_SAFE_ALLOCA_DEF_THRESHOLD), (lpa))) #define TEXTMETRICW2A_EX(lptmw)\ - (((lptmw) == NULL) ? NULL : ATLTEXTMETRICW2A((LPTEXTMETRICA)_ATL_SAFE_ALLOCA(sizeof(TEXTMETRICA), _ATL_SAFE_ALLOCA_DEF_THRESHOLD), (lptmw))) + (((lptmw) == NULL) ? NULL : ATLTEXTMETRICW2A((LPTEXTMETRICA)_ATL_SAFE_ALLOCA(sizeof(TEXTMETRICA), _ATL_SAFE_ALLOCA_DEF_THRESHOLD), (lptmw))) #define TEXTMETRICA2W_EX(lptma)\ - (((lptma) == NULL) ? NULL : ATLTEXTMETRICA2W((LPTEXTMETRICW)_ATL_SAFE_ALLOCA(sizeof(TEXTMETRICW), _ATL_SAFE_ALLOCA_DEF_THRESHOLD), (lptma))) + (((lptma) == NULL) ? NULL : ATLTEXTMETRICA2W((LPTEXTMETRICW)_ATL_SAFE_ALLOCA(sizeof(TEXTMETRICW), _ATL_SAFE_ALLOCA_DEF_THRESHOLD), (lptma))) #ifndef _ATL_EX_CONVERSION_MACROS_ONLY #define DEVMODEW2A(lpw)\ - ((lpw == NULL) ? NULL : ATLDEVMODEW2A((LPDEVMODEA)alloca(sizeof(DEVMODEA)+lpw->dmDriverExtra), lpw)) + ((lpw == NULL) ? NULL : ATLDEVMODEW2A((LPDEVMODEA)alloca(sizeof(DEVMODEA)+lpw->dmDriverExtra), lpw)) #define DEVMODEA2W(lpa)\ - ((lpa == NULL) ? NULL : ATLDEVMODEA2W((LPDEVMODEW)alloca(sizeof(DEVMODEW)+lpa->dmDriverExtra), lpa)) + ((lpa == NULL) ? NULL : ATLDEVMODEA2W((LPDEVMODEW)alloca(sizeof(DEVMODEW)+lpa->dmDriverExtra), lpa)) #define TEXTMETRICW2A(lptmw)\ - ((lptmw == NULL) ? NULL : ATLTEXTMETRICW2A((LPTEXTMETRICA)alloca(sizeof(TEXTMETRICA)), lptmw)) + ((lptmw == NULL) ? NULL : ATLTEXTMETRICW2A((LPTEXTMETRICA)alloca(sizeof(TEXTMETRICA)), lptmw)) #define TEXTMETRICA2W(lptma)\ - ((lptma == NULL) ? NULL : ATLTEXTMETRICA2W((LPTEXTMETRICW)alloca(sizeof(TEXTMETRICW)), lptma)) + ((lptma == NULL) ? NULL : ATLTEXTMETRICA2W((LPTEXTMETRICW)alloca(sizeof(TEXTMETRICW)), lptma)) -#endif // _ATL_EX_CONVERSION_MACROS_ONLY +#endif // _ATL_EX_CONVERSION_MACROS_ONLY #define DEVMODEOLE DEVMODEW #define LPDEVMODEOLE LPDEVMODEW @@ -1371,40 +1371,40 @@ inline LPTEXTMETRICA AtlTextMetricW2A( // in these cases the default (TCHAR) is the same as OLECHAR inline LPDEVMODEW DEVMODEOLE2T_EX(_In_opt_ LPDEVMODEOLE lp) { - return lp; + return lp; } inline LPDEVMODEOLE DEVMODET2OLE_EX(_In_opt_ LPDEVMODEW lp) { - return lp; + return lp; } inline LPTEXTMETRICW TEXTMETRICOLE2T_EX(_In_ LPTEXTMETRICOLE lp) { - return lp; + return lp; } inline LPTEXTMETRICOLE TEXTMETRICT2OLE_EX(_In_ LPTEXTMETRICW lp) { - return lp; + return lp; } #ifndef _ATL_EX_CONVERSION_MACROS_ONLY inline LPDEVMODEW DEVMODEOLE2T(_In_ LPDEVMODEOLE lp) { - return lp; + return lp; } inline LPDEVMODEOLE DEVMODET2OLE(_In_ LPDEVMODEW lp) { - return lp; + return lp; } inline LPTEXTMETRICW TEXTMETRICOLE2T(_In_ LPTEXTMETRICOLE lp) { - return lp; + return lp; } inline LPTEXTMETRICOLE TEXTMETRICT2OLE(_In_ LPTEXTMETRICW lp) { - return lp; + return lp; } -#endif // _ATL_EX_CONVERSION_MACROS_ONLY - +#endif // _ATL_EX_CONVERSION_MACROS_ONLY + #else // !defined(_UNICODE) #define DEVMODEOLE2T_EX(lpo) DEVMODEW2A_EX(lpo) @@ -1419,7 +1419,7 @@ inline LPTEXTMETRICOLE TEXTMETRICT2OLE(_In_ LPTEXTMETRICW lp) #define TEXTMETRICOLE2T(lptmw) TEXTMETRICW2A(lptmw) #define TEXTMETRICT2OLE(lptma) TEXTMETRICA2W(lptma) -#endif // _ATL_EX_CONVERSION_MACROS_ONLY +#endif // _ATL_EX_CONVERSION_MACROS_ONLY #endif // defined(_UNICODE) @@ -1434,44 +1434,44 @@ inline LPTEXTMETRICOLE TEXTMETRICT2OLE(_In_ LPTEXTMETRICW lp) #ifdef _WINGDI_ ATLINLINE ATLAPI_(LPDEVMODEA) AtlDevModeW2A( - _Inout_opt_ LPDEVMODEA lpDevModeA, - _In_ const DEVMODEW* lpDevModeW) + _Inout_opt_ LPDEVMODEA lpDevModeA, + _In_ const DEVMODEW* lpDevModeW) { - USES_CONVERSION_EX; - ATLASSERT(lpDevModeA != NULL); - if (lpDevModeW == NULL || lpDevModeA == NULL) - return NULL; + USES_CONVERSION_EX; + ATLASSERT(lpDevModeA != NULL); + if (lpDevModeW == NULL || lpDevModeA == NULL) + return NULL; - AtlW2AHelper((LPSTR)lpDevModeA->dmDeviceName, lpDevModeW->dmDeviceName, 32, _acp_ex); + AtlW2AHelper((LPSTR)lpDevModeA->dmDeviceName, lpDevModeW->dmDeviceName, 32, _acp_ex); - if(0 != memcpy_s(&lpDevModeA->dmSpecVersion, offsetof(DEVMODEA, dmFormName) - offsetof(DEVMODEA, dmSpecVersion), - &lpDevModeW->dmSpecVersion, offsetof(DEVMODEA, dmFormName) - offsetof(DEVMODEA, dmSpecVersion))) - { - return NULL; - } + if(0 != memcpy_s(&lpDevModeA->dmSpecVersion, offsetof(DEVMODEA, dmFormName) - offsetof(DEVMODEA, dmSpecVersion), + &lpDevModeW->dmSpecVersion, offsetof(DEVMODEA, dmFormName) - offsetof(DEVMODEA, dmSpecVersion))) + { + return NULL; + } - AtlW2AHelper((LPSTR)lpDevModeA->dmFormName, lpDevModeW->dmFormName, 32, _acp_ex); + AtlW2AHelper((LPSTR)lpDevModeA->dmFormName, lpDevModeW->dmFormName, 32, _acp_ex); - if(0 != memcpy_s(&lpDevModeA->dmLogPixels, sizeof(DEVMODEA) - offsetof(DEVMODEA, dmLogPixels), - &lpDevModeW->dmLogPixels, sizeof(DEVMODEA) - offsetof(DEVMODEA, dmLogPixels))) - { - return NULL; - } + if(0 != memcpy_s(&lpDevModeA->dmLogPixels, sizeof(DEVMODEA) - offsetof(DEVMODEA, dmLogPixels), + &lpDevModeW->dmLogPixels, sizeof(DEVMODEA) - offsetof(DEVMODEA, dmLogPixels))) + { + return NULL; + } - if (lpDevModeW->dmDriverExtra != 0) - { - // lpDevModeW holds more info + if (lpDevModeW->dmDriverExtra != 0) + { + // lpDevModeW holds more info #pragma warning(push) #pragma warning(disable:26000) - if(0 != memcpy_s(lpDevModeA+1, lpDevModeW->dmDriverExtra, lpDevModeW+1, lpDevModeW->dmDriverExtra)) - { - return NULL; - } + if(0 != memcpy_s(lpDevModeA+1, lpDevModeW->dmDriverExtra, lpDevModeW+1, lpDevModeW->dmDriverExtra)) + { + return NULL; + } #pragma warning(pop) - } - - lpDevModeA->dmSize = sizeof(DEVMODEA); - return lpDevModeA; + } + + lpDevModeA->dmSize = sizeof(DEVMODEA); + return lpDevModeA; } #endif //_WINGDI diff --git a/src/main/headers/atlcore.h b/src/main/headers/atlcore.h index 6de8d0c..61f8fbe 100644 --- a/src/main/headers/atlcore.h +++ b/src/main/headers/atlcore.h @@ -41,41 +41,41 @@ namespace ATL ///////////////////////////////////////////////////////////////////////////// // Verify that a null-terminated string points to valid memory inline BOOL AtlIsValidString( - _In_z_count_(nMaxLength) LPCWSTR psz, - _In_ size_t nMaxLength = INT_MAX) + _In_z_count_(nMaxLength) LPCWSTR psz, + _In_ size_t nMaxLength = INT_MAX) { - (nMaxLength); - return (psz != NULL); + (nMaxLength); + return (psz != NULL); } // Verify that a null-terminated string points to valid memory inline BOOL AtlIsValidString( - _In_z_count_(nMaxLength) LPCSTR psz, - _In_ size_t nMaxLength = UINT_MAX) + _In_z_count_(nMaxLength) LPCSTR psz, + _In_ size_t nMaxLength = UINT_MAX) { - (nMaxLength); - return (psz != NULL); + (nMaxLength); + return (psz != NULL); } // Verify that a pointer points to valid memory inline BOOL AtlIsValidAddress( - _In_opt_bytecount_(nBytes) const void* p, - _In_ size_t nBytes, - _In_ BOOL bReadWrite = TRUE) + _In_opt_bytecount_(nBytes) const void* p, + _In_ size_t nBytes, + _In_ BOOL bReadWrite = TRUE) { - (bReadWrite); - (nBytes); - return (p != NULL); + (bReadWrite); + (nBytes); + return (p != NULL); } template inline void AtlAssertValidObject( - _In_opt_ _Prepost_opt_bytecount_x_(sizeof(T)) const T *pOb) + _In_opt_ _Prepost_opt_bytecount_x_(sizeof(T)) const T *pOb) { - ATLASSERT(pOb); - ATLASSERT(AtlIsValidAddress(pOb, sizeof(T))); - if(pOb) - pOb->AssertValid(); + ATLASSERT(pOb); + ATLASSERT(AtlIsValidAddress(pOb, sizeof(T))); + if(pOb) + pOb->AssertValid(); } #ifdef _DEBUG #define ATLASSERT_VALID(x) ATL::AtlAssertValidObject(x) @@ -87,143 +87,143 @@ inline void AtlAssertValidObject( class CComCriticalSection { public: - CComCriticalSection() throw() - { - memset(&m_sec, 0, sizeof(CRITICAL_SECTION)); - } - ~CComCriticalSection() - { - } - HRESULT Lock() throw() - { - EnterCriticalSection(&m_sec); - return S_OK; - } - HRESULT Unlock() throw() - { - LeaveCriticalSection(&m_sec); - return S_OK; - } - HRESULT Init() throw() - { - HRESULT hRes = S_OK; + CComCriticalSection() throw() + { + memset(&m_sec, 0, sizeof(CRITICAL_SECTION)); + } + ~CComCriticalSection() + { + } + HRESULT Lock() throw() + { + EnterCriticalSection(&m_sec); + return S_OK; + } + HRESULT Unlock() throw() + { + LeaveCriticalSection(&m_sec); + return S_OK; + } + HRESULT Init() throw() + { + HRESULT hRes = S_OK; - if (!InitializeCriticalSectionAndSpinCount(&m_sec, 0)) - { - hRes = HRESULT_FROM_WIN32(GetLastError()); - } + if (!InitializeCriticalSectionAndSpinCount(&m_sec, 0)) + { + hRes = HRESULT_FROM_WIN32(GetLastError()); + } - return hRes; - } + return hRes; + } - HRESULT Term() throw() - { - DeleteCriticalSection(&m_sec); - return S_OK; - } - CRITICAL_SECTION m_sec; + HRESULT Term() throw() + { + DeleteCriticalSection(&m_sec); + return S_OK; + } + CRITICAL_SECTION m_sec; }; class CComAutoCriticalSection : - public CComCriticalSection + public CComCriticalSection { public: - CComAutoCriticalSection() - { - HRESULT hr = CComCriticalSection::Init(); - if (FAILED(hr)) - AtlThrow(hr); - } - ~CComAutoCriticalSection() throw() - { - CComCriticalSection::Term(); - } + CComAutoCriticalSection() + { + HRESULT hr = CComCriticalSection::Init(); + if (FAILED(hr)) + AtlThrow(hr); + } + ~CComAutoCriticalSection() throw() + { + CComCriticalSection::Term(); + } private : - HRESULT Init(); // Not implemented. CComAutoCriticalSection::Init should never be called - HRESULT Term(); // Not implemented. CComAutoCriticalSection::Term should never be called + HRESULT Init(); // Not implemented. CComAutoCriticalSection::Init should never be called + HRESULT Term(); // Not implemented. CComAutoCriticalSection::Term should never be called }; class CComSafeDeleteCriticalSection : - public CComCriticalSection + public CComCriticalSection { public: - CComSafeDeleteCriticalSection(): m_bInitialized(false) - { - } + CComSafeDeleteCriticalSection(): m_bInitialized(false) + { + } - ~CComSafeDeleteCriticalSection() throw() - { - if (!m_bInitialized) - { - return; - } - m_bInitialized = false; - CComCriticalSection::Term(); - } + ~CComSafeDeleteCriticalSection() throw() + { + if (!m_bInitialized) + { + return; + } + m_bInitialized = false; + CComCriticalSection::Term(); + } - HRESULT Init() throw() - { - ATLASSERT( !m_bInitialized ); - HRESULT hr = CComCriticalSection::Init(); - if (SUCCEEDED(hr)) - { - m_bInitialized = true; - } - return hr; - } + HRESULT Init() throw() + { + ATLASSERT( !m_bInitialized ); + HRESULT hr = CComCriticalSection::Init(); + if (SUCCEEDED(hr)) + { + m_bInitialized = true; + } + return hr; + } - HRESULT Term() throw() - { - if (!m_bInitialized) - { - return S_OK; - } - m_bInitialized = false; - return CComCriticalSection::Term(); - } + HRESULT Term() throw() + { + if (!m_bInitialized) + { + return S_OK; + } + m_bInitialized = false; + return CComCriticalSection::Term(); + } - HRESULT Lock() - { - // CComSafeDeleteCriticalSection::Init or CComAutoDeleteCriticalSection::Init - // not called or failed. - // m_critsec member of CComObjectRootEx is now of type - // CComAutoDeleteCriticalSection. It has to be initialized - // by calling CComObjectRootEx::_AtlInitialConstruct - ATLASSUME(m_bInitialized); - return CComCriticalSection::Lock(); - } + HRESULT Lock() + { + // CComSafeDeleteCriticalSection::Init or CComAutoDeleteCriticalSection::Init + // not called or failed. + // m_critsec member of CComObjectRootEx is now of type + // CComAutoDeleteCriticalSection. It has to be initialized + // by calling CComObjectRootEx::_AtlInitialConstruct + ATLASSUME(m_bInitialized); + return CComCriticalSection::Lock(); + } private: - bool m_bInitialized; + bool m_bInitialized; }; class CComAutoDeleteCriticalSection : - public CComSafeDeleteCriticalSection + public CComSafeDeleteCriticalSection { private: - // CComAutoDeleteCriticalSection::Term should never be called - HRESULT Term() throw(); + // CComAutoDeleteCriticalSection::Term should never be called + HRESULT Term() throw(); }; class CComFakeCriticalSection { public: - HRESULT Lock() throw() - { - return S_OK; - } - HRESULT Unlock() throw() - { - return S_OK; - } - HRESULT Init() throw() - { - return S_OK; - } - HRESULT Term() throw() - { - return S_OK; - } + HRESULT Lock() throw() + { + return S_OK; + } + HRESULT Unlock() throw() + { + return S_OK; + } + HRESULT Init() throw() + { + return S_OK; + } + HRESULT Term() throw() + { + return S_OK; + } }; ///////////////////////////////////////////////////////////////////////////// @@ -232,40 +232,40 @@ public: // Used by any project that uses ATL struct _ATL_BASE_MODULE70 { - UINT cbSize; - HINSTANCE m_hInst; - HINSTANCE m_hInstResource; - DWORD dwAtlBuildVer; - const GUID* pguidVer; - CComCriticalSection m_csResource; - CSimpleArray m_rgResourceInstance; + UINT cbSize; + HINSTANCE m_hInst; + HINSTANCE m_hInstResource; + DWORD dwAtlBuildVer; + const GUID* pguidVer; + CComCriticalSection m_csResource; + CSimpleArray m_rgResourceInstance; }; typedef _ATL_BASE_MODULE70 _ATL_BASE_MODULE; class CAtlBaseModule : - public _ATL_BASE_MODULE + public _ATL_BASE_MODULE { public : - static bool m_bInitFailed; - CAtlBaseModule() throw(); - ~CAtlBaseModule() throw (); + static bool m_bInitFailed; + CAtlBaseModule() throw(); + ~CAtlBaseModule() throw (); - HINSTANCE GetModuleInstance() throw() - { - return m_hInst; - } - HINSTANCE GetResourceInstance() throw() - { - return m_hInstResource; - } - HINSTANCE SetResourceInstance(_In_ HINSTANCE hInst) throw() - { - return static_cast< HINSTANCE >(InterlockedExchangePointer((void**)&m_hInstResource, hInst)); - } + HINSTANCE GetModuleInstance() throw() + { + return m_hInst; + } + HINSTANCE GetResourceInstance() throw() + { + return m_hInstResource; + } + HINSTANCE SetResourceInstance(_In_ HINSTANCE hInst) throw() + { + return static_cast< HINSTANCE >(InterlockedExchangePointer((void**)&m_hInstResource, hInst)); + } - bool AddResourceInstance(_In_ HINSTANCE hInst) throw(); - bool RemoveResourceInstance(_In_ HINSTANCE hInst) throw(); - HINSTANCE GetHInstanceAt(_In_ int i) throw(); + bool AddResourceInstance(_In_ HINSTANCE hInst) throw(); + bool RemoveResourceInstance(_In_ HINSTANCE hInst) throw(); + HINSTANCE GetHInstanceAt(_In_ int i) throw(); }; __declspec(selectany) bool CAtlBaseModule::m_bInitFailed = false; @@ -276,199 +276,199 @@ extern CAtlBaseModule _AtlBaseModule; #pragma warning(push) #pragma warning(disable: 4200) - struct ATLSTRINGRESOURCEIMAGE - { - WORD nLength; - WCHAR achString[]; - }; -#pragma warning(pop) // C4200 + struct ATLSTRINGRESOURCEIMAGE + { + WORD nLength; + WCHAR achString[]; + }; +#pragma warning(pop) // C4200 inline const ATLSTRINGRESOURCEIMAGE* _AtlGetStringResourceImage( - _In_ HINSTANCE hInstance, - _In_ HRSRC hResource, - _In_ UINT id) throw() + _In_ HINSTANCE hInstance, + _In_ HRSRC hResource, + _In_ UINT id) throw() { - const ATLSTRINGRESOURCEIMAGE* pImage; - const ATLSTRINGRESOURCEIMAGE* pImageEnd; - ULONG nResourceSize; - HGLOBAL hGlobal; - UINT iIndex; + const ATLSTRINGRESOURCEIMAGE* pImage; + const ATLSTRINGRESOURCEIMAGE* pImageEnd; + ULONG nResourceSize; + HGLOBAL hGlobal; + UINT iIndex; - hGlobal = ::LoadResource( hInstance, hResource ); - if( hGlobal == NULL ) - { - return( NULL ); - } + hGlobal = ::LoadResource( hInstance, hResource ); + if( hGlobal == NULL ) + { + return( NULL ); + } - pImage = (const ATLSTRINGRESOURCEIMAGE*)::LockResource( hGlobal ); - if( pImage == NULL ) - { - return( NULL ); - } + pImage = (const ATLSTRINGRESOURCEIMAGE*)::LockResource( hGlobal ); + if( pImage == NULL ) + { + return( NULL ); + } - nResourceSize = ::SizeofResource( hInstance, hResource ); - pImageEnd = (const ATLSTRINGRESOURCEIMAGE*)(LPBYTE( pImage )+nResourceSize); - iIndex = id&0x000f; + nResourceSize = ::SizeofResource( hInstance, hResource ); + pImageEnd = (const ATLSTRINGRESOURCEIMAGE*)(LPBYTE( pImage )+nResourceSize); + iIndex = id&0x000f; - while( (iIndex > 0) && (pImage < pImageEnd) ) - { - pImage = (const ATLSTRINGRESOURCEIMAGE*)(LPBYTE( pImage )+(sizeof( ATLSTRINGRESOURCEIMAGE )+(pImage->nLength*sizeof( WCHAR )))); - iIndex--; - } - if( pImage >= pImageEnd ) - { - return( NULL ); - } - if( pImage->nLength == 0 ) - { - return( NULL ); - } + while( (iIndex > 0) && (pImage < pImageEnd) ) + { + pImage = (const ATLSTRINGRESOURCEIMAGE*)(LPBYTE( pImage )+(sizeof( ATLSTRINGRESOURCEIMAGE )+(pImage->nLength*sizeof( WCHAR )))); + iIndex--; + } + if( pImage >= pImageEnd ) + { + return( NULL ); + } + if( pImage->nLength == 0 ) + { + return( NULL ); + } - return( pImage ); + return( pImage ); } inline const ATLSTRINGRESOURCEIMAGE* AtlGetStringResourceImage( - _In_ HINSTANCE hInstance, - _In_ UINT id) throw() + _In_ HINSTANCE hInstance, + _In_ UINT id) throw() { - HRSRC hResource; - /* - The and operation (& static_cast(~0)) protects the expression from being greater - than WORD - this would cause a runtime error when the application is compiled with /RTCc flag. - */ - hResource = ::FindResourceW(hInstance, MAKEINTRESOURCEW( (((id>>4)+1) & static_cast(~0)) ), (LPWSTR) RT_STRING); - if( hResource == NULL ) - { - return( NULL ); - } + HRSRC hResource; + /* + The and operation (& static_cast(~0)) protects the expression from being greater + than WORD - this would cause a runtime error when the application is compiled with /RTCc flag. + */ + hResource = ::FindResourceW(hInstance, MAKEINTRESOURCEW( (((id>>4)+1) & static_cast(~0)) ), (LPWSTR) RT_STRING); + if( hResource == NULL ) + { + return( NULL ); + } - return _AtlGetStringResourceImage( hInstance, hResource, id ); + return _AtlGetStringResourceImage( hInstance, hResource, id ); } inline const ATLSTRINGRESOURCEIMAGE* AtlGetStringResourceImage( - _In_ HINSTANCE hInstance, - _In_ UINT id, - _In_ WORD wLanguage) throw() + _In_ HINSTANCE hInstance, + _In_ UINT id, + _In_ WORD wLanguage) throw() { - HRSRC hResource; - /* - The and operation (& static_cast(~0)) protects the expression from being greater - than WORD - this would cause a runtime error when the application is compiled with /RTCc flag. - */ - hResource = ::FindResourceExW(hInstance, (LPWSTR) RT_STRING, MAKEINTRESOURCEW( (((id>>4)+1) & static_cast(~0)) ), wLanguage); - if( hResource == NULL ) - { - return( NULL ); - } + HRSRC hResource; + /* + The and operation (& static_cast(~0)) protects the expression from being greater + than WORD - this would cause a runtime error when the application is compiled with /RTCc flag. + */ + hResource = ::FindResourceExW(hInstance, (LPWSTR) RT_STRING, MAKEINTRESOURCEW( (((id>>4)+1) & static_cast(~0)) ), wLanguage); + if( hResource == NULL ) + { + return( NULL ); + } - return _AtlGetStringResourceImage( hInstance, hResource, id ); + return _AtlGetStringResourceImage( hInstance, hResource, id ); } inline const ATLSTRINGRESOURCEIMAGE* AtlGetStringResourceImage(_In_ UINT id) throw() { - const ATLSTRINGRESOURCEIMAGE* p = NULL; - HINSTANCE hInst = _AtlBaseModule.GetHInstanceAt(0); + const ATLSTRINGRESOURCEIMAGE* p = NULL; + HINSTANCE hInst = _AtlBaseModule.GetHInstanceAt(0); - for (int i = 1; hInst != NULL && p == NULL; hInst = _AtlBaseModule.GetHInstanceAt(i++)) - { - p = AtlGetStringResourceImage(hInst, id); - } - return p; + for (int i = 1; hInst != NULL && p == NULL; hInst = _AtlBaseModule.GetHInstanceAt(i++)) + { + p = AtlGetStringResourceImage(hInst, id); + } + return p; } inline const ATLSTRINGRESOURCEIMAGE* AtlGetStringResourceImage( - _In_ UINT id, - _In_ WORD wLanguage) throw() + _In_ UINT id, + _In_ WORD wLanguage) throw() { - const ATLSTRINGRESOURCEIMAGE* p = NULL; - HINSTANCE hInst = _AtlBaseModule.GetHInstanceAt(0); + const ATLSTRINGRESOURCEIMAGE* p = NULL; + HINSTANCE hInst = _AtlBaseModule.GetHInstanceAt(0); - for (int i = 1; hInst != NULL && p == NULL; hInst = _AtlBaseModule.GetHInstanceAt(i++)) - { - p = AtlGetStringResourceImage(hInst, id, wLanguage); - } - return p; + for (int i = 1; hInst != NULL && p == NULL; hInst = _AtlBaseModule.GetHInstanceAt(i++)) + { + p = AtlGetStringResourceImage(hInst, id, wLanguage); + } + return p; } inline int AtlLoadString( - _In_ UINT nID, - _Out_z_cap_post_count_(nBufferMax, return + 1) LPTSTR lpBuffer, - _In_ int nBufferMax) throw() + _In_ UINT nID, + _Out_z_cap_post_count_(nBufferMax, return + 1) LPTSTR lpBuffer, + _In_ int nBufferMax) throw() { - HINSTANCE hInst = _AtlBaseModule.GetHInstanceAt(0); - int nRet = 0; + HINSTANCE hInst = _AtlBaseModule.GetHInstanceAt(0); + int nRet = 0; - for (int i = 1; hInst != NULL && nRet == 0; hInst = _AtlBaseModule.GetHInstanceAt(i++)) - { - nRet = LoadString(hInst, nID, lpBuffer, nBufferMax); - } - return nRet; + for (int i = 1; hInst != NULL && nRet == 0; hInst = _AtlBaseModule.GetHInstanceAt(i++)) + { + nRet = LoadString(hInst, nID, lpBuffer, nBufferMax); + } + return nRet; } inline HINSTANCE AtlFindResourceInstance( - _In_z_ LPCTSTR lpName, - _In_z_ LPCTSTR lpType, - _In_ WORD wLanguage = 0) throw() + _In_z_ LPCTSTR lpName, + _In_z_ LPCTSTR lpType, + _In_ WORD wLanguage = 0) throw() { - ATLASSERT(lpType != RT_STRING); // Call AtlFindStringResourceInstance to find the string - if (lpType == RT_STRING) - return NULL; + ATLASSERT(lpType != RT_STRING); // Call AtlFindStringResourceInstance to find the string + if (lpType == RT_STRING) + return NULL; - if (ATL_IS_INTRESOURCE(lpType)) - { - /* Prefast false warnings caused by bad-shaped definition of MAKEINTRESOURCE macro from PSDK */ - if (lpType == ATL_RT_ICON) - { - lpType = ATL_RT_GROUP_ICON; - } - else if (lpType == ATL_RT_CURSOR) - { - lpType = ATL_RT_GROUP_CURSOR; - } - } + if (ATL_IS_INTRESOURCE(lpType)) + { + /* Prefast false warnings caused by bad-shaped definition of MAKEINTRESOURCE macro from PSDK */ + if (lpType == ATL_RT_ICON) + { + lpType = ATL_RT_GROUP_ICON; + } + else if (lpType == ATL_RT_CURSOR) + { + lpType = ATL_RT_GROUP_CURSOR; + } + } - HINSTANCE hInst = _AtlBaseModule.GetHInstanceAt(0); - HRSRC hResource = NULL; + HINSTANCE hInst = _AtlBaseModule.GetHInstanceAt(0); + HRSRC hResource = NULL; - for (int i = 1; hInst != NULL; hInst = _AtlBaseModule.GetHInstanceAt(i++)) - { - hResource = ::FindResourceEx(hInst, lpType, lpName, wLanguage); - if (hResource != NULL) - { - return hInst; - } - } + for (int i = 1; hInst != NULL; hInst = _AtlBaseModule.GetHInstanceAt(i++)) + { + hResource = ::FindResourceEx(hInst, lpType, lpName, wLanguage); + if (hResource != NULL) + { + return hInst; + } + } - return NULL; + return NULL; } inline HINSTANCE AtlFindResourceInstance( - _In_ UINT nID, - _In_z_ LPCTSTR lpType, - _In_ WORD wLanguage = 0) throw() + _In_ UINT nID, + _In_z_ LPCTSTR lpType, + _In_ WORD wLanguage = 0) throw() { - /* - The and operation (& static_cast(~0)) protects the expression from being greater - than WORD - this would cause a runtime error when the application is compiled with /RTCc flag. - */ - return AtlFindResourceInstance(MAKEINTRESOURCE(nID & static_cast(~0)), lpType, wLanguage); + /* + The and operation (& static_cast(~0)) protects the expression from being greater + than WORD - this would cause a runtime error when the application is compiled with /RTCc flag. + */ + return AtlFindResourceInstance(MAKEINTRESOURCE(nID & static_cast(~0)), lpType, wLanguage); } inline HINSTANCE AtlFindStringResourceInstance( - _In_ UINT nID, - _In_ WORD wLanguage = 0) throw() + _In_ UINT nID, + _In_ WORD wLanguage = 0) throw() { - const ATLSTRINGRESOURCEIMAGE* p = NULL; - HINSTANCE hInst = _AtlBaseModule.GetHInstanceAt(0); + const ATLSTRINGRESOURCEIMAGE* p = NULL; + HINSTANCE hInst = _AtlBaseModule.GetHInstanceAt(0); - for (int i = 1; hInst != NULL && p == NULL; hInst = _AtlBaseModule.GetHInstanceAt(i++)) - { - p = AtlGetStringResourceImage(hInst, nID, wLanguage); - if (p != NULL) - return hInst; - } + for (int i = 1; hInst != NULL && p == NULL; hInst = _AtlBaseModule.GetHInstanceAt(i++)) + { + p = AtlGetStringResourceImage(hInst, nID, wLanguage); + if (p != NULL) + return hInst; + } - return NULL; + return NULL; } /* @@ -505,39 +505,39 @@ inline HRESULT AtlSafeArrayGetActualVartype( template inline _CharType* AtlCharNext(_In_ const _CharType* p) throw() { - ATLASSUME(p != NULL); // Too expensive to check separately here - if (*p == '\0') // ::CharNextA won't increment if we're at a \0 already - return const_cast<_CharType*>(p+1); - else - return ::CharNextA(p); + ATLASSUME(p != NULL); // Too expensive to check separately here + if (*p == '\0') // ::CharNextA won't increment if we're at a \0 already + return const_cast<_CharType*>(p+1); + else + return ::CharNextA(p); } template <> inline wchar_t* AtlCharNext(_In_ const wchar_t* p) throw() { - return const_cast< wchar_t* >( p+1 ); + return const_cast< wchar_t* >( p+1 ); } template inline const CharType* AtlstrchrT( - _In_z_ const CharType* p, - _In_ CharType ch) throw() + _In_z_ const CharType* p, + _In_ CharType ch) throw() { - ATLASSERT(p != NULL); - if(p==NULL) - { - return NULL; - } - while( *p != 0 ) - { - if (*p == ch) - { - return p; - } - p = AtlCharNext(p); - } - //strchr for '\0' should succeed - the while loop terminates - //*p == 0, but ch also == 0, so NULL terminator address is returned - return (*p == ch) ? p : NULL; + ATLASSERT(p != NULL); + if(p==NULL) + { + return NULL; + } + while( *p != 0 ) + { + if (*p == ch) + { + return p; + } + p = AtlCharNext(p); + } + //strchr for '\0' should succeed - the while loop terminates + //*p == 0, but ch also == 0, so NULL terminator address is returned + return (*p == ch) ? p : NULL; } //Ansi and Unicode versions of printf, used with templated CharType trait classes. #pragma warning(push) @@ -545,12 +545,12 @@ inline const CharType* AtlstrchrT( template inline int AtlprintfT(_In_z_ _Printf_format_string_ const CharType* pszFormat,...) throw() { - int retval=0; - va_list argList; - va_start( argList, pszFormat ); - retval=vprintf(pszFormat,argList); - va_end( argList ); - return retval; + int retval=0; + va_list argList; + va_start( argList, pszFormat ); + retval=vprintf(pszFormat,argList); + va_end( argList ); + return retval; } #pragma warning(pop) @@ -559,43 +559,43 @@ inline int AtlprintfT(_In_z_ _Printf_format_string_ const CharType* pszFormat,.. template<> inline int AtlprintfT(_In_z_ _Printf_format_string_ const wchar_t* pszFormat,... ) throw() { - int retval=0; - va_list argList; - va_start( argList, pszFormat ); - retval=vwprintf(pszFormat, argList); - va_end( argList ); - return retval; + int retval=0; + va_list argList; + va_start( argList, pszFormat ); + retval=vwprintf(pszFormat, argList); + va_end( argList ); + return retval; } #pragma warning(pop) inline BOOL AtlConvertSystemTimeToVariantTime( - _In_ const SYSTEMTIME& systimeSrc, - _Out_ double* pVarDtTm) + _In_ const SYSTEMTIME& systimeSrc, + _Out_ double* pVarDtTm) { - ATLENSURE(pVarDtTm!=NULL); - //Convert using ::SystemTimeToVariantTime and store the result in pVarDtTm then - //convert variant time back to system time and compare to original system time. - BOOL ok = ::SystemTimeToVariantTime(const_cast(&systimeSrc), pVarDtTm); - SYSTEMTIME sysTime; - ::ZeroMemory(&sysTime, sizeof(SYSTEMTIME)); + ATLENSURE(pVarDtTm!=NULL); + //Convert using ::SystemTimeToVariantTime and store the result in pVarDtTm then + //convert variant time back to system time and compare to original system time. + BOOL ok = ::SystemTimeToVariantTime(const_cast(&systimeSrc), pVarDtTm); + SYSTEMTIME sysTime; + ::ZeroMemory(&sysTime, sizeof(SYSTEMTIME)); - ok = ok && ::VariantTimeToSystemTime(*pVarDtTm, &sysTime); - ok = ok && (systimeSrc.wYear == sysTime.wYear && - systimeSrc.wMonth == sysTime.wMonth && - systimeSrc.wDay == sysTime.wDay && - systimeSrc.wHour == sysTime.wHour && - systimeSrc.wMinute == sysTime.wMinute && - systimeSrc.wSecond == sysTime.wSecond); + ok = ok && ::VariantTimeToSystemTime(*pVarDtTm, &sysTime); + ok = ok && (systimeSrc.wYear == sysTime.wYear && + systimeSrc.wMonth == sysTime.wMonth && + systimeSrc.wDay == sysTime.wDay && + systimeSrc.wHour == sysTime.wHour && + systimeSrc.wMinute == sysTime.wMinute && + systimeSrc.wSecond == sysTime.wSecond); - return ok; + return ok; } ///////////////////////////////////////////////////////////////////////////// -} // namespace ATL +} // namespace ATL #pragma pack(pop) #ifdef _ATL_ALL_WARNINGS #pragma warning( pop ) #endif -#endif // __ATLCORE_H__ +#endif // __ATLCORE_H__ diff --git a/src/main/headers/atldef.h b/src/main/headers/atldef.h index ce05b3c..8af1707 100644 --- a/src/main/headers/atldef.h +++ b/src/main/headers/atldef.h @@ -13,7 +13,7 @@ #pragma once -#pragma warning(disable : 4619) // there is no warning number +#pragma warning(disable : 4619) // there is no warning number #include #include @@ -33,11 +33,11 @@ #ifndef RC_INVOKED #ifndef __cplusplus - #error ATL requires C++ compilation (use a .cpp suffix) + #error ATL requires C++ compilation (use a .cpp suffix) #endif #ifdef UNDER_CE - #error This version of ATL is not currently supported for CE. Look for the CE specific version. + #error This version of ATL is not currently supported for CE. Look for the CE specific version. #endif // If you are mixing compilation units that are built as @@ -47,7 +47,7 @@ #if !defined(_ATL_MIXED) namespace Inconsistent_definition_of_symbol__ATL_MIXED { - struct _Please_define_it_the_same_throughout_your_project { }; + struct _Please_define_it_the_same_throughout_your_project { }; } #else namespace Inconsistent_definition_of_symbol__ATL_MIXED @@ -57,28 +57,28 @@ namespace Inconsistent_definition_of_symbol__ATL_MIXED #else #pragma comment(linker, "/include:??3@YAXPEAX@Z") #endif - struct _Please_define_it_the_same_throughout_your_project { virtual void one(){} }; + struct _Please_define_it_the_same_throughout_your_project { virtual void one(){} }; } #endif namespace Inconsistent_definition_of_symbol__ATL_MIXED { - __declspec(selectany) _Please_define_it_the_same_throughout_your_project clash = _Please_define_it_the_same_throughout_your_project (); + __declspec(selectany) _Please_define_it_the_same_throughout_your_project clash = _Please_define_it_the_same_throughout_your_project (); } #if !defined(_ATL_MIXED) namespace Define_the_symbol__ATL_MIXED { #if defined(_M_CEE) - struct Thank_you { }; + struct Thank_you { }; #else #ifdef _M_IX86 #pragma comment(linker, "/include:??3@YAXPAX@Z") #else #pragma comment(linker, "/include:??3@YAXPEAX@Z") #endif - struct Thank_you { virtual void one(){} }; + struct Thank_you { virtual void one(){} }; #endif - __declspec(selectany) Thank_you clash = Thank_you(); + __declspec(selectany) Thank_you clash = Thank_you(); } #endif @@ -113,7 +113,7 @@ namespace Define_the_symbol__ATL_MIXED #if defined(_PREFAST_) && (_MSC_VER < 1600) #define ATLSTATIC_ASSERT(expr, comment) #else -#define ATLSTATIC_ASSERT(expr, comment) static_assert(expr, comment) +#define ATLSTATIC_ASSERT(expr, comment) static_assert(expr, comment) #endif #ifdef _WIN64 @@ -184,19 +184,19 @@ Sometimes we have code like HRESULT ComMethod(void) { - ATLASSUME(m_pFoo); - return m_pFoo->Method(); + ATLASSUME(m_pFoo); + return m_pFoo->Method(); } We could add - if(!m_pFoo) return E_POINTER; + if(!m_pFoo) return E_POINTER; But this is very unlikely to help, since it removes the ability of the developer to debug this problem if it's seen in a retail build of the application. We could try something more severe - if(!m_pFoo) terminate(); // or your favourite shutdown function + if(!m_pFoo) terminate(); // or your favourite shutdown function This would ensure good reporting (because VC8 terminate generates a Windows Error Report and crash dump), but hardly seems a big win over the previous crash. @@ -233,9 +233,9 @@ So we've done a broad replace of all the member-related ATLASSERT to ATLASSUME. #ifndef ATLENSURE_THROW #define ATLENSURE_THROW(expr, hr) \ do { \ - int __atl_condVal=!!(expr); \ - ATLASSUME(__atl_condVal); \ - if(!(__atl_condVal)) AtlThrow(hr); \ + int __atl_condVal=!!(expr); \ + ATLASSUME(__atl_condVal); \ + if(!(__atl_condVal)) AtlThrow(hr); \ } while (0) #endif // ATLENSURE_THROW @@ -251,9 +251,9 @@ do { \ #ifndef ATLENSURE_RETURN_VAL #define ATLENSURE_RETURN_VAL(expr, val) \ do { \ - int __atl_condVal=!!(expr); \ - ATLASSERT(__atl_condVal); \ - if(!(__atl_condVal)) return val; \ + int __atl_condVal=!!(expr); \ + ATLASSERT(__atl_condVal); \ + if(!(__atl_condVal)) return val; \ } while (0) #endif // ATLENSURE_RETURN_VAL @@ -278,17 +278,17 @@ ATLENSURE_RETURN_HR is HRESULT-specific, though currently the same as _VAL #ifndef ATL_CRT_ERRORCHECK_SPRINTF #define ATL_CRT_ERRORCHECK_SPRINTF(expr) \ do { \ - errno_t _saveErrno = errno; \ - errno = 0; \ - (expr); \ - if(0 != errno) \ - { \ - AtlCrtErrorCheck(errno); \ - } \ - else \ - { \ - errno = _saveErrno; \ - } \ + errno_t _saveErrno = errno; \ + errno = 0; \ + (expr); \ + if(0 != errno) \ + { \ + AtlCrtErrorCheck(errno); \ + } \ + else \ + { \ + errno = _saveErrno; \ + } \ } while (0) #endif // ATL_CRT_ERRORCHECK_SPRINTF @@ -383,33 +383,33 @@ do { \ #endif #if defined(_ATL_DLL) - #define ATLAPI extern "C" HRESULT __declspec(dllimport) __stdcall - #define ATLAPI_(x) extern "C" __declspec(dllimport) x __stdcall - #define ATLINLINE - #define ATLAPIINL extern "C" inline HRESULT __stdcall - #define ATLAPIINL_(x) extern "C" inline x __stdcall + #define ATLAPI extern "C" HRESULT __declspec(dllimport) __stdcall + #define ATLAPI_(x) extern "C" __declspec(dllimport) x __stdcall + #define ATLINLINE + #define ATLAPIINL extern "C" inline HRESULT __stdcall + #define ATLAPIINL_(x) extern "C" inline x __stdcall #elif defined(_ATL_DLL_IMPL) - #define ATLAPI extern "C" inline HRESULT __stdcall - #define ATLAPI_(x) extern "C" inline x __stdcall - #define ATLAPIINL ATLAPI - #define ATLAPIINL_(x) ATLAPI_(x) - #define ATLINLINE + #define ATLAPI extern "C" inline HRESULT __stdcall + #define ATLAPI_(x) extern "C" inline x __stdcall + #define ATLAPIINL ATLAPI + #define ATLAPIINL_(x) ATLAPI_(x) + #define ATLINLINE #else - #define ATLAPI __declspec(nothrow) HRESULT __stdcall - #define ATLAPI_(x) __declspec(nothrow) x __stdcall - #define ATLAPIINL ATLAPI - #define ATLAPIINL_(x) ATLAPI_(x) - #define ATLINLINE inline + #define ATLAPI __declspec(nothrow) HRESULT __stdcall + #define ATLAPI_(x) __declspec(nothrow) x __stdcall + #define ATLAPIINL ATLAPI + #define ATLAPIINL_(x) ATLAPI_(x) + #define ATLINLINE inline #endif #ifdef _ATL_NO_EXCEPTIONS - #ifdef _AFX - // #error MFC projects cannot define _ATL_NO_EXCEPTIONS - #endif + #ifdef _AFX + // #error MFC projects cannot define _ATL_NO_EXCEPTIONS + #endif #else - #ifndef _CPPUNWIND - #define _ATL_NO_EXCEPTIONS - #endif + #ifndef _CPPUNWIND + #define _ATL_NO_EXCEPTIONS + #endif #endif #ifdef _CPPUNWIND @@ -421,9 +421,9 @@ do { \ #else /* prefast noise VSW 489981 */ #define ATLTRYALLOC(x) __pragma(warning(push)) __pragma(warning(disable: 4571)) try{x;} catch(...) {} __pragma(warning(pop)) -#endif //__AFX +#endif //__AFX -#endif //ATLTRYALLOC +#endif //ATLTRYALLOC // If you define _ATLTRY before including this file, then // you should define _ATLCATCH and _ATLRETHROW as well. @@ -444,7 +444,7 @@ do { \ #endif #define _ATLRETHROW throw -#endif // _ATLTRY +#endif // _ATLTRY /* COM functions should not throw. Which means we should protect their callers from C++ exceptions leaking out. These macros @@ -454,38 +454,38 @@ this end #ifndef _ATL_COM_BEGIN #define _ATL_COM_BEGIN \ - HRESULT __hrAtlComMethod=S_OK; \ - try \ - { + HRESULT __hrAtlComMethod=S_OK; \ + try \ + { #endif #ifdef _AFX /* Nice to do something more complex here in future to translate an MFC exception to a better HR */ #define _AFX_COM_END_PART \ - catch(CException *e) \ - { \ - if(e) \ - { \ - e->Delete(); \ - } \ - __hrAtlComMethod=E_FAIL; \ - } + catch(CException *e) \ + { \ + if(e) \ + { \ + e->Delete(); \ + } \ + __hrAtlComMethod=E_FAIL; \ + } #else #define _AFX_COM_END_PART \ - catch(CAtlException e) \ - { \ - __hrAtlComMethod=e.m_hr; \ - } + catch(CAtlException e) \ + { \ + __hrAtlComMethod=e.m_hr; \ + } #endif #ifndef _ATL_COM_END #define _ATL_COM_END \ - _AFX_COM_END_PART \ - catch(...) \ - { \ - __hrAtlComMethod=E_FAIL; \ - } \ - return hr; + _AFX_COM_END_PART \ + catch(...) \ + { \ + __hrAtlComMethod=E_FAIL; \ + } \ + return hr; #endif @@ -494,7 +494,7 @@ this end #ifndef ATLTRYALLOC #define ATLTRYALLOC(x) x; -#endif //ATLTRYALLOC +#endif //ATLTRYALLOC // if _ATLTRY is defined before including this file then // _ATLCATCH and _ATLRETHROW should be defined as well. @@ -504,13 +504,13 @@ this end #define _ATLCATCHALL() __pragma(warning(push)) __pragma(warning(disable: 4127)) if( false ) __pragma(warning(pop)) #define _ATLDELETEEXCEPTION(e) #define _ATLRETHROW -#endif // _ATLTRY +#endif // _ATLTRY -#endif //_CPPUNWIND +#endif //_CPPUNWIND #ifndef ATLTRY #define ATLTRY(x) ATLTRYALLOC(x) -#endif //ATLTRY +#endif //ATLTRY #define offsetofclass(base, derived) ((DWORD_PTR)(static_cast((derived*)_ATL_PACKING))-_ATL_PACKING) @@ -558,19 +558,19 @@ this end #ifndef NOMCX #define NOMCX #endif -#endif // ATL_NO_LEAN_AND_MEAN +#endif // ATL_NO_LEAN_AND_MEAN #ifdef NOSERVICE #ifndef _ATL_NO_SERVICE #define _ATL_NO_SERVICE -#endif // _ATL_NO_SERVICE +#endif // _ATL_NO_SERVICE #else #ifdef _ATL_NO_SERVICE #ifndef NOSERVICE #define NOSERVICE -#endif // NOSERVICE -#endif // _ATL_NO_SERVICE -#endif // NOSERVICE +#endif // NOSERVICE +#endif // _ATL_NO_SERVICE +#endif // NOSERVICE #include #ifdef _DEBUG @@ -580,15 +580,15 @@ this end // Warning: if you define the above symbol, you will have // to provide your own definition of the ATLASSERT(x) macro // in order to compile ATL - #include + #include #endif #endif // RC_INVOKED // Note : we can not use macros to generate the window class names because it // will require nested macros. rc.exe does not handle nested macros. -// #define ATLAXWIN_CLASS _ATL_STRINGIZE(_ATL_APPEND(AtlAxWin, _ATL_FILENAME_VER_NUM)) -// #define ATLAXWINLIC_CLASS _ATL_STRINGIZE(_ATL_APPEND(AtlAxWinLic, _ATL_FILENAME_VER_NUM)) +// #define ATLAXWIN_CLASS _ATL_STRINGIZE(_ATL_APPEND(AtlAxWin, _ATL_FILENAME_VER_NUM)) +// #define ATLAXWINLIC_CLASS _ATL_STRINGIZE(_ATL_APPEND(AtlAxWinLic, _ATL_FILENAME_VER_NUM)) #define ATLAXWIN_CLASS "AtlAxWin100" #define ATLAXWINLIC_CLASS "AtlAxWinLic100" @@ -622,10 +622,10 @@ that we consider it dangerous to even throw an exception #else #if !defined(__MINGW32__) #define PTM_WARNING_DISABLE \ - __pragma(warning( push )) \ - __pragma(warning( disable : 4867 )) + __pragma(warning( push )) \ + __pragma(warning( disable : 4867 )) #define PTM_WARNING_RESTORE \ - __pragma(warning( pop )) + __pragma(warning( pop )) #else #define PTM_WARNING_DISABLE #define PTM_WARNING_RESTORE @@ -695,13 +695,13 @@ that we consider it dangerous to even throw an exception #define ATLPREFAST_SUPPRESS(x) #define ATLPREFAST_UNSUPPRESS() #endif - + #ifndef _FormatMessage_format_string_ #define _FormatMessage_format_string_ #endif - + /* - Helper functions for SAL annotation + Helper functions for SAL annotation */ namespace ATL { diff --git a/src/main/headers/atlexcept.h b/src/main/headers/atlexcept.h index a1e88e6..fc49517 100644 --- a/src/main/headers/atlexcept.h +++ b/src/main/headers/atlexcept.h @@ -27,32 +27,32 @@ namespace ATL // Exception raise (for functions that cannot return an error code) inline void __declspec(noreturn) _AtlRaiseException( - _In_ DWORD dwExceptionCode, - _In_ DWORD dwExceptionFlags = EXCEPTION_NONCONTINUABLE) + _In_ DWORD dwExceptionCode, + _In_ DWORD dwExceptionFlags = EXCEPTION_NONCONTINUABLE) { - RaiseException( dwExceptionCode, dwExceptionFlags, 0, NULL ); + RaiseException( dwExceptionCode, dwExceptionFlags, 0, NULL ); } class CAtlException { public: - CAtlException() throw() : - m_hr( E_FAIL ) - { - } + CAtlException() throw() : + m_hr( E_FAIL ) + { + } - CAtlException(_In_ HRESULT hr) throw() : - m_hr( hr ) - { - } + CAtlException(_In_ HRESULT hr) throw() : + m_hr( hr ) + { + } - operator HRESULT() const throw() - { - return( m_hr ); - } + operator HRESULT() const throw() + { + return( m_hr ); + } public: - HRESULT m_hr; + HRESULT m_hr; }; #ifndef ATL_NOINLINE @@ -73,15 +73,15 @@ public: #else ATL_NOINLINE __declspec(noreturn) inline void WINAPI AtlThrowImpl(_In_ HRESULT hr) { - throw CAtlException( hr ); + throw CAtlException( hr ); } #endif // Throw a CAtlException corresponding to the result of ::GetLastError ATL_NOINLINE __declspec(noreturn) inline void WINAPI AtlThrowLastWin32() { - DWORD dwError = ::GetLastError(); - AtlThrowImpl( HRESULT_FROM_WIN32( dwError ) ); + DWORD dwError = ::GetLastError(); + AtlThrowImpl( HRESULT_FROM_WIN32( dwError ) ); } #else // no exception handling @@ -91,25 +91,25 @@ ATL_NOINLINE __declspec(noreturn) inline void WINAPI AtlThrowLastWin32() ATL_NOINLINE inline void WINAPI AtlThrowImpl(_In_ HRESULT hr) { - ATLASSERT( false ); - DWORD dwExceptionCode; - switch(hr) - { - case E_OUTOFMEMORY: - dwExceptionCode = STATUS_NO_MEMORY; - break; - default: - dwExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION; - } - _AtlRaiseException((DWORD)dwExceptionCode); + ATLASSERT( false ); + DWORD dwExceptionCode; + switch(hr) + { + case E_OUTOFMEMORY: + dwExceptionCode = STATUS_NO_MEMORY; + break; + default: + dwExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION; + } + _AtlRaiseException((DWORD)dwExceptionCode); } #endif // Throw a CAtlException corresponding to the result of ::GetLastError ATL_NOINLINE inline void WINAPI AtlThrowLastWin32() { - DWORD dwError = ::GetLastError(); - AtlThrowImpl( HRESULT_FROM_WIN32( dwError ) ); + DWORD dwError = ::GetLastError(); + AtlThrowImpl( HRESULT_FROM_WIN32( dwError ) ); } #endif // no exception handling diff --git a/src/main/headers/atliface.h b/src/main/headers/atliface.h index 75eef99..38209be 100644 --- a/src/main/headers/atliface.h +++ b/src/main/headers/atliface.h @@ -17,12 +17,12 @@ /* at Mon Feb 12 21:31:09 2001 */ /* Compiler settings for atliface.idl: - Oicf, W1, Zp8, env=Win32 (32b run) - protocol : dce , ms_ext, c_ext - error checks: allocation ref bounds_check enum stub_data - VC __declspec() decoration level: - __declspec(uuid()), __declspec(selectany), __declspec(novtable) - DECLSPEC_UUID(), MIDL_INTERFACE() + Oicf, W1, Zp8, env=Win32 (32b run) + protocol : dce , ms_ext, c_ext + error checks: allocation ref bounds_check enum stub_data + VC __declspec() decoration level: + __declspec(uuid()), __declspec(selectany), __declspec(novtable) + DECLSPEC_UUID(), MIDL_INTERFACE() */ //@@MIDL_FILE_HEADING( ) @@ -54,55 +54,55 @@ #ifndef __IRegistrarBase_FWD_DEFINED__ #define __IRegistrarBase_FWD_DEFINED__ typedef interface IRegistrarBase IRegistrarBase; -#endif /* __IRegistrarBase_FWD_DEFINED__ */ +#endif /* __IRegistrarBase_FWD_DEFINED__ */ #ifndef __IRegistrar_FWD_DEFINED__ #define __IRegistrar_FWD_DEFINED__ typedef interface IRegistrar IRegistrar; -#endif /* __IRegistrar_FWD_DEFINED__ */ +#endif /* __IRegistrar_FWD_DEFINED__ */ #ifndef __IDocHostUIHandlerDispatch_FWD_DEFINED__ #define __IDocHostUIHandlerDispatch_FWD_DEFINED__ typedef interface IDocHostUIHandlerDispatch IDocHostUIHandlerDispatch; -#endif /* __IDocHostUIHandlerDispatch_FWD_DEFINED__ */ +#endif /* __IDocHostUIHandlerDispatch_FWD_DEFINED__ */ #ifndef __IAxWinHostWindow_FWD_DEFINED__ #define __IAxWinHostWindow_FWD_DEFINED__ typedef interface IAxWinHostWindow IAxWinHostWindow; -#endif /* __IAxWinHostWindow_FWD_DEFINED__ */ +#endif /* __IAxWinHostWindow_FWD_DEFINED__ */ #ifndef __IAxWinHostWindowLic_FWD_DEFINED__ #define __IAxWinHostWindowLic_FWD_DEFINED__ typedef interface IAxWinHostWindowLic IAxWinHostWindowLic; -#endif /* __IAxWinHostWindowLic_FWD_DEFINED__ */ +#endif /* __IAxWinHostWindowLic_FWD_DEFINED__ */ #ifndef __IAxWinAmbientDispatch_FWD_DEFINED__ #define __IAxWinAmbientDispatch_FWD_DEFINED__ typedef interface IAxWinAmbientDispatch IAxWinAmbientDispatch; -#endif /* __IAxWinAmbientDispatch_FWD_DEFINED__ */ +#endif /* __IAxWinAmbientDispatch_FWD_DEFINED__ */ #ifndef __IAxWinAmbientDispatchEx_FWD_DEFINED__ #define __IAxWinAmbientDispatchEx_FWD_DEFINED__ typedef interface IAxWinAmbientDispatchEx IAxWinAmbientDispatchEx; -#endif /* __IAxWinAmbientDispatchEx_FWD_DEFINED__ */ +#endif /* __IAxWinAmbientDispatchEx_FWD_DEFINED__ */ #ifndef __IInternalConnection_FWD_DEFINED__ #define __IInternalConnection_FWD_DEFINED__ typedef interface IInternalConnection IInternalConnection; -#endif /* __IInternalConnection_FWD_DEFINED__ */ +#endif /* __IInternalConnection_FWD_DEFINED__ */ #ifndef __IAccessibleServer_FWD_DEFINED__ #define __IAccessibleServer_FWD_DEFINED__ typedef interface IAccessibleServer IAccessibleServer; -#endif /* __IAccessibleServer_FWD_DEFINED__ */ +#endif /* __IAccessibleServer_FWD_DEFINED__ */ /* header files for imported files */ @@ -140,105 +140,105 @@ EXTERN_C const IID IID_IRegistrarBase; #if defined(__cplusplus) && !defined(CINTERFACE) - MIDL_INTERFACE("e21f8a85-b05d-4243-8183-c7cb405588f7") - IRegistrarBase : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE AddReplacement( - /* [in] */ LPCOLESTR key, - /* [in] */ LPCOLESTR item) = 0; + MIDL_INTERFACE("e21f8a85-b05d-4243-8183-c7cb405588f7") + IRegistrarBase : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE AddReplacement( + /* [in] */ LPCOLESTR key, + /* [in] */ LPCOLESTR item) = 0; - virtual HRESULT STDMETHODCALLTYPE ClearReplacements( void) = 0; + virtual HRESULT STDMETHODCALLTYPE ClearReplacements( void) = 0; - }; + }; -#else /* C style interface */ +#else /* C style interface */ - typedef struct IRegistrarBaseVtbl - { - BEGIN_INTERFACE + typedef struct IRegistrarBaseVtbl + { + BEGIN_INTERFACE - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IRegistrarBase * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IRegistrarBase * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); - ULONG ( STDMETHODCALLTYPE *AddRef )( - IRegistrarBase * This); + ULONG ( STDMETHODCALLTYPE *AddRef )( + IRegistrarBase * This); - ULONG ( STDMETHODCALLTYPE *Release )( - IRegistrarBase * This); + ULONG ( STDMETHODCALLTYPE *Release )( + IRegistrarBase * This); - HRESULT ( STDMETHODCALLTYPE *AddReplacement )( - IRegistrarBase * This, - /* [in] */ LPCOLESTR key, - /* [in] */ LPCOLESTR item); + HRESULT ( STDMETHODCALLTYPE *AddReplacement )( + IRegistrarBase * This, + /* [in] */ LPCOLESTR key, + /* [in] */ LPCOLESTR item); - HRESULT ( STDMETHODCALLTYPE *ClearReplacements )( - IRegistrarBase * This); + HRESULT ( STDMETHODCALLTYPE *ClearReplacements )( + IRegistrarBase * This); - END_INTERFACE - } IRegistrarBaseVtbl; + END_INTERFACE + } IRegistrarBaseVtbl; - interface IRegistrarBase - { - CONST_VTBL struct IRegistrarBaseVtbl *lpVtbl; - }; + interface IRegistrarBase + { + CONST_VTBL struct IRegistrarBaseVtbl *lpVtbl; + }; #ifdef COBJMACROS -#define IRegistrarBase_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) +#define IRegistrarBase_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) -#define IRegistrarBase_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) +#define IRegistrarBase_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) -#define IRegistrarBase_Release(This) \ - (This)->lpVtbl -> Release(This) +#define IRegistrarBase_Release(This) \ + (This)->lpVtbl -> Release(This) -#define IRegistrarBase_AddReplacement(This,key,item) \ - (This)->lpVtbl -> AddReplacement(This,key,item) +#define IRegistrarBase_AddReplacement(This,key,item) \ + (This)->lpVtbl -> AddReplacement(This,key,item) -#define IRegistrarBase_ClearReplacements(This) \ - (This)->lpVtbl -> ClearReplacements(This) +#define IRegistrarBase_ClearReplacements(This) \ + (This)->lpVtbl -> ClearReplacements(This) #endif /* COBJMACROS */ -#endif /* C style interface */ +#endif /* C style interface */ HRESULT STDMETHODCALLTYPE IRegistrarBase_AddReplacement_Proxy( - IRegistrarBase * This, - /* [in] */ LPCOLESTR key, - /* [in] */ LPCOLESTR item); + IRegistrarBase * This, + /* [in] */ LPCOLESTR key, + /* [in] */ LPCOLESTR item); void __RPC_STUB IRegistrarBase_AddReplacement_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IRegistrarBase_ClearReplacements_Proxy( - IRegistrarBase * This); + IRegistrarBase * This); void __RPC_STUB IRegistrarBase_ClearReplacements_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); -#endif /* __IRegistrarBase_INTERFACE_DEFINED__ */ +#endif /* __IRegistrarBase_INTERFACE_DEFINED__ */ #ifndef __IRegistrar_INTERFACE_DEFINED__ @@ -252,276 +252,276 @@ EXTERN_C const IID IID_IRegistrar; #if defined(__cplusplus) && !defined(CINTERFACE) - MIDL_INTERFACE("44EC053B-400F-11D0-9DCD-00A0C90391D3") - IRegistrar : public IRegistrarBase - { - public: - virtual HRESULT STDMETHODCALLTYPE ResourceRegisterSz( - /* [in] */ LPCOLESTR resFileName, - /* [in] */ LPCOLESTR szID, - /* [in] */ LPCOLESTR szType) = 0; + MIDL_INTERFACE("44EC053B-400F-11D0-9DCD-00A0C90391D3") + IRegistrar : public IRegistrarBase + { + public: + virtual HRESULT STDMETHODCALLTYPE ResourceRegisterSz( + /* [in] */ LPCOLESTR resFileName, + /* [in] */ LPCOLESTR szID, + /* [in] */ LPCOLESTR szType) = 0; - virtual HRESULT STDMETHODCALLTYPE ResourceUnregisterSz( - /* [in] */ LPCOLESTR resFileName, - /* [in] */ LPCOLESTR szID, - /* [in] */ LPCOLESTR szType) = 0; + virtual HRESULT STDMETHODCALLTYPE ResourceUnregisterSz( + /* [in] */ LPCOLESTR resFileName, + /* [in] */ LPCOLESTR szID, + /* [in] */ LPCOLESTR szType) = 0; - virtual HRESULT STDMETHODCALLTYPE FileRegister( - /* [in] */ LPCOLESTR fileName) = 0; + virtual HRESULT STDMETHODCALLTYPE FileRegister( + /* [in] */ LPCOLESTR fileName) = 0; - virtual HRESULT STDMETHODCALLTYPE FileUnregister( - /* [in] */ LPCOLESTR fileName) = 0; + virtual HRESULT STDMETHODCALLTYPE FileUnregister( + /* [in] */ LPCOLESTR fileName) = 0; - virtual HRESULT STDMETHODCALLTYPE StringRegister( - /* [in] */ LPCOLESTR data) = 0; + virtual HRESULT STDMETHODCALLTYPE StringRegister( + /* [in] */ LPCOLESTR data) = 0; - virtual HRESULT STDMETHODCALLTYPE StringUnregister( - /* [in] */ LPCOLESTR data) = 0; + virtual HRESULT STDMETHODCALLTYPE StringUnregister( + /* [in] */ LPCOLESTR data) = 0; - virtual HRESULT STDMETHODCALLTYPE ResourceRegister( - /* [in] */ LPCOLESTR resFileName, - /* [in] */ UINT nID, - /* [in] */ LPCOLESTR szType) = 0; + virtual HRESULT STDMETHODCALLTYPE ResourceRegister( + /* [in] */ LPCOLESTR resFileName, + /* [in] */ UINT nID, + /* [in] */ LPCOLESTR szType) = 0; - virtual HRESULT STDMETHODCALLTYPE ResourceUnregister( - /* [in] */ LPCOLESTR resFileName, - /* [in] */ UINT nID, - /* [in] */ LPCOLESTR szType) = 0; + virtual HRESULT STDMETHODCALLTYPE ResourceUnregister( + /* [in] */ LPCOLESTR resFileName, + /* [in] */ UINT nID, + /* [in] */ LPCOLESTR szType) = 0; - }; + }; -#else /* C style interface */ +#else /* C style interface */ - typedef struct IRegistrarVtbl - { - BEGIN_INTERFACE + typedef struct IRegistrarVtbl + { + BEGIN_INTERFACE - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IRegistrar * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IRegistrar * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); - ULONG ( STDMETHODCALLTYPE *AddRef )( - IRegistrar * This); + ULONG ( STDMETHODCALLTYPE *AddRef )( + IRegistrar * This); - ULONG ( STDMETHODCALLTYPE *Release )( - IRegistrar * This); + ULONG ( STDMETHODCALLTYPE *Release )( + IRegistrar * This); - HRESULT ( STDMETHODCALLTYPE *AddReplacement )( - IRegistrar * This, - /* [in] */ LPCOLESTR key, - /* [in] */ LPCOLESTR item); + HRESULT ( STDMETHODCALLTYPE *AddReplacement )( + IRegistrar * This, + /* [in] */ LPCOLESTR key, + /* [in] */ LPCOLESTR item); - HRESULT ( STDMETHODCALLTYPE *ClearReplacements )( - IRegistrar * This); + HRESULT ( STDMETHODCALLTYPE *ClearReplacements )( + IRegistrar * This); - HRESULT ( STDMETHODCALLTYPE *ResourceRegisterSz )( - IRegistrar * This, - /* [in] */ LPCOLESTR resFileName, - /* [in] */ LPCOLESTR szID, - /* [in] */ LPCOLESTR szType); + HRESULT ( STDMETHODCALLTYPE *ResourceRegisterSz )( + IRegistrar * This, + /* [in] */ LPCOLESTR resFileName, + /* [in] */ LPCOLESTR szID, + /* [in] */ LPCOLESTR szType); - HRESULT ( STDMETHODCALLTYPE *ResourceUnregisterSz )( - IRegistrar * This, - /* [in] */ LPCOLESTR resFileName, - /* [in] */ LPCOLESTR szID, - /* [in] */ LPCOLESTR szType); + HRESULT ( STDMETHODCALLTYPE *ResourceUnregisterSz )( + IRegistrar * This, + /* [in] */ LPCOLESTR resFileName, + /* [in] */ LPCOLESTR szID, + /* [in] */ LPCOLESTR szType); - HRESULT ( STDMETHODCALLTYPE *FileRegister )( - IRegistrar * This, - /* [in] */ LPCOLESTR fileName); + HRESULT ( STDMETHODCALLTYPE *FileRegister )( + IRegistrar * This, + /* [in] */ LPCOLESTR fileName); - HRESULT ( STDMETHODCALLTYPE *FileUnregister )( - IRegistrar * This, - /* [in] */ LPCOLESTR fileName); + HRESULT ( STDMETHODCALLTYPE *FileUnregister )( + IRegistrar * This, + /* [in] */ LPCOLESTR fileName); - HRESULT ( STDMETHODCALLTYPE *StringRegister )( - IRegistrar * This, - /* [in] */ LPCOLESTR data); + HRESULT ( STDMETHODCALLTYPE *StringRegister )( + IRegistrar * This, + /* [in] */ LPCOLESTR data); - HRESULT ( STDMETHODCALLTYPE *StringUnregister )( - IRegistrar * This, - /* [in] */ LPCOLESTR data); + HRESULT ( STDMETHODCALLTYPE *StringUnregister )( + IRegistrar * This, + /* [in] */ LPCOLESTR data); - HRESULT ( STDMETHODCALLTYPE *ResourceRegister )( - IRegistrar * This, - /* [in] */ LPCOLESTR resFileName, - /* [in] */ UINT nID, - /* [in] */ LPCOLESTR szType); + HRESULT ( STDMETHODCALLTYPE *ResourceRegister )( + IRegistrar * This, + /* [in] */ LPCOLESTR resFileName, + /* [in] */ UINT nID, + /* [in] */ LPCOLESTR szType); - HRESULT ( STDMETHODCALLTYPE *ResourceUnregister )( - IRegistrar * This, - /* [in] */ LPCOLESTR resFileName, - /* [in] */ UINT nID, - /* [in] */ LPCOLESTR szType); + HRESULT ( STDMETHODCALLTYPE *ResourceUnregister )( + IRegistrar * This, + /* [in] */ LPCOLESTR resFileName, + /* [in] */ UINT nID, + /* [in] */ LPCOLESTR szType); - END_INTERFACE - } IRegistrarVtbl; + END_INTERFACE + } IRegistrarVtbl; - interface IRegistrar - { - CONST_VTBL struct IRegistrarVtbl *lpVtbl; - }; + interface IRegistrar + { + CONST_VTBL struct IRegistrarVtbl *lpVtbl; + }; #ifdef COBJMACROS -#define IRegistrar_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) +#define IRegistrar_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) -#define IRegistrar_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) +#define IRegistrar_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) -#define IRegistrar_Release(This) \ - (This)->lpVtbl -> Release(This) +#define IRegistrar_Release(This) \ + (This)->lpVtbl -> Release(This) -#define IRegistrar_AddReplacement(This,key,item) \ - (This)->lpVtbl -> AddReplacement(This,key,item) +#define IRegistrar_AddReplacement(This,key,item) \ + (This)->lpVtbl -> AddReplacement(This,key,item) -#define IRegistrar_ClearReplacements(This) \ - (This)->lpVtbl -> ClearReplacements(This) +#define IRegistrar_ClearReplacements(This) \ + (This)->lpVtbl -> ClearReplacements(This) -#define IRegistrar_ResourceRegisterSz(This,resFileName,szID,szType) \ - (This)->lpVtbl -> ResourceRegisterSz(This,resFileName,szID,szType) +#define IRegistrar_ResourceRegisterSz(This,resFileName,szID,szType) \ + (This)->lpVtbl -> ResourceRegisterSz(This,resFileName,szID,szType) -#define IRegistrar_ResourceUnregisterSz(This,resFileName,szID,szType) \ - (This)->lpVtbl -> ResourceUnregisterSz(This,resFileName,szID,szType) +#define IRegistrar_ResourceUnregisterSz(This,resFileName,szID,szType) \ + (This)->lpVtbl -> ResourceUnregisterSz(This,resFileName,szID,szType) -#define IRegistrar_FileRegister(This,fileName) \ - (This)->lpVtbl -> FileRegister(This,fileName) +#define IRegistrar_FileRegister(This,fileName) \ + (This)->lpVtbl -> FileRegister(This,fileName) -#define IRegistrar_FileUnregister(This,fileName) \ - (This)->lpVtbl -> FileUnregister(This,fileName) +#define IRegistrar_FileUnregister(This,fileName) \ + (This)->lpVtbl -> FileUnregister(This,fileName) -#define IRegistrar_StringRegister(This,data) \ - (This)->lpVtbl -> StringRegister(This,data) +#define IRegistrar_StringRegister(This,data) \ + (This)->lpVtbl -> StringRegister(This,data) -#define IRegistrar_StringUnregister(This,data) \ - (This)->lpVtbl -> StringUnregister(This,data) +#define IRegistrar_StringUnregister(This,data) \ + (This)->lpVtbl -> StringUnregister(This,data) -#define IRegistrar_ResourceRegister(This,resFileName,nID,szType) \ - (This)->lpVtbl -> ResourceRegister(This,resFileName,nID,szType) +#define IRegistrar_ResourceRegister(This,resFileName,nID,szType) \ + (This)->lpVtbl -> ResourceRegister(This,resFileName,nID,szType) -#define IRegistrar_ResourceUnregister(This,resFileName,nID,szType) \ - (This)->lpVtbl -> ResourceUnregister(This,resFileName,nID,szType) +#define IRegistrar_ResourceUnregister(This,resFileName,nID,szType) \ + (This)->lpVtbl -> ResourceUnregister(This,resFileName,nID,szType) #endif /* COBJMACROS */ -#endif /* C style interface */ +#endif /* C style interface */ HRESULT STDMETHODCALLTYPE IRegistrar_ResourceRegisterSz_Proxy( - IRegistrar * This, - /* [in] */ LPCOLESTR resFileName, - /* [in] */ LPCOLESTR szID, - /* [in] */ LPCOLESTR szType); + IRegistrar * This, + /* [in] */ LPCOLESTR resFileName, + /* [in] */ LPCOLESTR szID, + /* [in] */ LPCOLESTR szType); void __RPC_STUB IRegistrar_ResourceRegisterSz_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IRegistrar_ResourceUnregisterSz_Proxy( - IRegistrar * This, - /* [in] */ LPCOLESTR resFileName, - /* [in] */ LPCOLESTR szID, - /* [in] */ LPCOLESTR szType); + IRegistrar * This, + /* [in] */ LPCOLESTR resFileName, + /* [in] */ LPCOLESTR szID, + /* [in] */ LPCOLESTR szType); void __RPC_STUB IRegistrar_ResourceUnregisterSz_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IRegistrar_FileRegister_Proxy( - IRegistrar * This, - /* [in] */ LPCOLESTR fileName); + IRegistrar * This, + /* [in] */ LPCOLESTR fileName); void __RPC_STUB IRegistrar_FileRegister_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IRegistrar_FileUnregister_Proxy( - IRegistrar * This, - /* [in] */ LPCOLESTR fileName); + IRegistrar * This, + /* [in] */ LPCOLESTR fileName); void __RPC_STUB IRegistrar_FileUnregister_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IRegistrar_StringRegister_Proxy( - IRegistrar * This, - /* [in] */ LPCOLESTR data); + IRegistrar * This, + /* [in] */ LPCOLESTR data); void __RPC_STUB IRegistrar_StringRegister_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IRegistrar_StringUnregister_Proxy( - IRegistrar * This, - /* [in] */ LPCOLESTR data); + IRegistrar * This, + /* [in] */ LPCOLESTR data); void __RPC_STUB IRegistrar_StringUnregister_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IRegistrar_ResourceRegister_Proxy( - IRegistrar * This, - /* [in] */ LPCOLESTR resFileName, - /* [in] */ UINT nID, - /* [in] */ LPCOLESTR szType); + IRegistrar * This, + /* [in] */ LPCOLESTR resFileName, + /* [in] */ UINT nID, + /* [in] */ LPCOLESTR szType); void __RPC_STUB IRegistrar_ResourceRegister_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IRegistrar_ResourceUnregister_Proxy( - IRegistrar * This, - /* [in] */ LPCOLESTR resFileName, - /* [in] */ UINT nID, - /* [in] */ LPCOLESTR szType); + IRegistrar * This, + /* [in] */ LPCOLESTR resFileName, + /* [in] */ UINT nID, + /* [in] */ LPCOLESTR szType); void __RPC_STUB IRegistrar_ResourceUnregister_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); -#endif /* __IRegistrar_INTERFACE_DEFINED__ */ +#endif /* __IRegistrar_INTERFACE_DEFINED__ */ #ifndef __IDocHostUIHandlerDispatch_INTERFACE_DEFINED__ @@ -532,532 +532,532 @@ void __RPC_STUB IRegistrar_ResourceUnregister_Stub( typedef enum tagDOCHOSTUIDBLCLKDispatch - { docHostUIDblClkDEFAULT = 0, - docHostUIDblClkSHOWPROPERTIES = 1, - docHostUIDblClkSHOWCODE = 2 - } DOCHOSTUIDBLCLKDispatch; + { docHostUIDblClkDEFAULT = 0, + docHostUIDblClkSHOWPROPERTIES = 1, + docHostUIDblClkSHOWCODE = 2 + } DOCHOSTUIDBLCLKDispatch; typedef enum tagDocHostUIFlagDispatch - { docHostUIFlagDIALOG = 1, - docHostUIFlagDISABLE_HELP_MENU = 2, - docHostUIFlagNO3DBORDER = 4, - docHostUIFlagSCROLL_NO = 8, - docHostUIFlagDISABLE_SCRIPT_INACTIVE = 16, - docHostUIFlagOPENNEWWIN = 32, - docHostUIFlagDISABLE_OFFSCREEN = 64, - docHostUIFlagFLAT_SCROLLBAR = 128, - docHostUIFlagDIV_BLOCKDEFAULT = 256, - docHostUIFlagACTIVATE_CLIENTHIT_ONLY = 512 - } DocHostUIFlagDispatch; + { docHostUIFlagDIALOG = 1, + docHostUIFlagDISABLE_HELP_MENU = 2, + docHostUIFlagNO3DBORDER = 4, + docHostUIFlagSCROLL_NO = 8, + docHostUIFlagDISABLE_SCRIPT_INACTIVE = 16, + docHostUIFlagOPENNEWWIN = 32, + docHostUIFlagDISABLE_OFFSCREEN = 64, + docHostUIFlagFLAT_SCROLLBAR = 128, + docHostUIFlagDIV_BLOCKDEFAULT = 256, + docHostUIFlagACTIVATE_CLIENTHIT_ONLY = 512 + } DocHostUIFlagDispatch; EXTERN_C const IID IID_IDocHostUIHandlerDispatch; #if defined(__cplusplus) && !defined(CINTERFACE) - MIDL_INTERFACE("425B5AF0-65F1-11d1-9611-0000F81E0D0D") - IDocHostUIHandlerDispatch : public IDispatch - { - public: - virtual HRESULT STDMETHODCALLTYPE ShowContextMenu( - /* [in] */ DWORD dwID, - /* [in] */ DWORD x, - /* [in] */ DWORD y, - /* [in] */ IUnknown *pcmdtReserved, - /* [in] */ IDispatch *pdispReserved, - /* [retval][out] */ HRESULT *dwRetVal) = 0; + MIDL_INTERFACE("425B5AF0-65F1-11d1-9611-0000F81E0D0D") + IDocHostUIHandlerDispatch : public IDispatch + { + public: + virtual HRESULT STDMETHODCALLTYPE ShowContextMenu( + /* [in] */ DWORD dwID, + /* [in] */ DWORD x, + /* [in] */ DWORD y, + /* [in] */ IUnknown *pcmdtReserved, + /* [in] */ IDispatch *pdispReserved, + /* [retval][out] */ HRESULT *dwRetVal) = 0; - virtual HRESULT STDMETHODCALLTYPE GetHostInfo( - /* [out][in] */ DWORD *pdwFlags, - /* [out][in] */ DWORD *pdwDoubleClick) = 0; + virtual HRESULT STDMETHODCALLTYPE GetHostInfo( + /* [out][in] */ DWORD *pdwFlags, + /* [out][in] */ DWORD *pdwDoubleClick) = 0; - virtual HRESULT STDMETHODCALLTYPE ShowUI( - /* [in] */ DWORD dwID, - /* [in] */ IUnknown *pActiveObject, - /* [in] */ IUnknown *pCommandTarget, - /* [in] */ IUnknown *pFrame, - /* [in] */ IUnknown *pDoc, - /* [retval][out] */ HRESULT *dwRetVal) = 0; + virtual HRESULT STDMETHODCALLTYPE ShowUI( + /* [in] */ DWORD dwID, + /* [in] */ IUnknown *pActiveObject, + /* [in] */ IUnknown *pCommandTarget, + /* [in] */ IUnknown *pFrame, + /* [in] */ IUnknown *pDoc, + /* [retval][out] */ HRESULT *dwRetVal) = 0; - virtual HRESULT STDMETHODCALLTYPE HideUI( void) = 0; + virtual HRESULT STDMETHODCALLTYPE HideUI( void) = 0; - virtual HRESULT STDMETHODCALLTYPE UpdateUI( void) = 0; + virtual HRESULT STDMETHODCALLTYPE UpdateUI( void) = 0; - virtual HRESULT STDMETHODCALLTYPE EnableModeless( - /* [in] */ VARIANT_BOOL fEnable) = 0; + virtual HRESULT STDMETHODCALLTYPE EnableModeless( + /* [in] */ VARIANT_BOOL fEnable) = 0; - virtual HRESULT STDMETHODCALLTYPE OnDocWindowActivate( - /* [in] */ VARIANT_BOOL fActivate) = 0; + virtual HRESULT STDMETHODCALLTYPE OnDocWindowActivate( + /* [in] */ VARIANT_BOOL fActivate) = 0; - virtual HRESULT STDMETHODCALLTYPE OnFrameWindowActivate( - /* [in] */ VARIANT_BOOL fActivate) = 0; + virtual HRESULT STDMETHODCALLTYPE OnFrameWindowActivate( + /* [in] */ VARIANT_BOOL fActivate) = 0; - virtual HRESULT STDMETHODCALLTYPE ResizeBorder( - /* [in] */ long left, - /* [in] */ long top, - /* [in] */ long right, - /* [in] */ long bottom, - /* [in] */ IUnknown *pUIWindow, - /* [in] */ VARIANT_BOOL fFrameWindow) = 0; + virtual HRESULT STDMETHODCALLTYPE ResizeBorder( + /* [in] */ long left, + /* [in] */ long top, + /* [in] */ long right, + /* [in] */ long bottom, + /* [in] */ IUnknown *pUIWindow, + /* [in] */ VARIANT_BOOL fFrameWindow) = 0; - virtual HRESULT STDMETHODCALLTYPE TranslateAccelerator( - /* [in] */ DWORD_PTR hWnd, - /* [in] */ DWORD nMessage, - /* [in] */ DWORD_PTR wParam, - /* [in] */ DWORD_PTR lParam, - /* [in] */ BSTR bstrGuidCmdGroup, - /* [in] */ DWORD nCmdID, - /* [retval][out] */ HRESULT *dwRetVal) = 0; + virtual HRESULT STDMETHODCALLTYPE TranslateAccelerator( + /* [in] */ DWORD_PTR hWnd, + /* [in] */ DWORD nMessage, + /* [in] */ DWORD_PTR wParam, + /* [in] */ DWORD_PTR lParam, + /* [in] */ BSTR bstrGuidCmdGroup, + /* [in] */ DWORD nCmdID, + /* [retval][out] */ HRESULT *dwRetVal) = 0; - virtual HRESULT STDMETHODCALLTYPE GetOptionKeyPath( - /* [out] */ BSTR *pbstrKey, - /* [in] */ DWORD dw) = 0; + virtual HRESULT STDMETHODCALLTYPE GetOptionKeyPath( + /* [out] */ BSTR *pbstrKey, + /* [in] */ DWORD dw) = 0; - virtual HRESULT STDMETHODCALLTYPE GetDropTarget( - /* [in] */ IUnknown *pDropTarget, - /* [out] */ IUnknown **ppDropTarget) = 0; + virtual HRESULT STDMETHODCALLTYPE GetDropTarget( + /* [in] */ IUnknown *pDropTarget, + /* [out] */ IUnknown **ppDropTarget) = 0; - virtual HRESULT STDMETHODCALLTYPE GetExternal( - /* [out] */ IDispatch **ppDispatch) = 0; + virtual HRESULT STDMETHODCALLTYPE GetExternal( + /* [out] */ IDispatch **ppDispatch) = 0; - virtual HRESULT STDMETHODCALLTYPE TranslateUrl( - /* [in] */ DWORD dwTranslate, - /* [in] */ BSTR bstrURLIn, - /* [out] */ BSTR *pbstrURLOut) = 0; + virtual HRESULT STDMETHODCALLTYPE TranslateUrl( + /* [in] */ DWORD dwTranslate, + /* [in] */ BSTR bstrURLIn, + /* [out] */ BSTR *pbstrURLOut) = 0; - virtual HRESULT STDMETHODCALLTYPE FilterDataObject( - /* [in] */ IUnknown *pDO, - /* [out] */ IUnknown **ppDORet) = 0; + virtual HRESULT STDMETHODCALLTYPE FilterDataObject( + /* [in] */ IUnknown *pDO, + /* [out] */ IUnknown **ppDORet) = 0; - }; + }; -#else /* C style interface */ +#else /* C style interface */ - typedef struct IDocHostUIHandlerDispatchVtbl - { - BEGIN_INTERFACE + typedef struct IDocHostUIHandlerDispatchVtbl + { + BEGIN_INTERFACE - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IDocHostUIHandlerDispatch * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IDocHostUIHandlerDispatch * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); - ULONG ( STDMETHODCALLTYPE *AddRef )( - IDocHostUIHandlerDispatch * This); + ULONG ( STDMETHODCALLTYPE *AddRef )( + IDocHostUIHandlerDispatch * This); - ULONG ( STDMETHODCALLTYPE *Release )( - IDocHostUIHandlerDispatch * This); + ULONG ( STDMETHODCALLTYPE *Release )( + IDocHostUIHandlerDispatch * This); - HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( - IDocHostUIHandlerDispatch * This, - /* [out] */ UINT *pctinfo); + HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( + IDocHostUIHandlerDispatch * This, + /* [out] */ UINT *pctinfo); - HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( - IDocHostUIHandlerDispatch * This, - /* [in] */ UINT iTInfo, - /* [in] */ LCID lcid, - /* [out] */ ITypeInfo **ppTInfo); + HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( + IDocHostUIHandlerDispatch * This, + /* [in] */ UINT iTInfo, + /* [in] */ LCID lcid, + /* [out] */ ITypeInfo **ppTInfo); - HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( - IDocHostUIHandlerDispatch * This, - /* [in] */ REFIID riid, - /* [size_is][in] */ _In_count_(cNames) LPOLESTR *rgszNames, - /* [in] */ UINT cNames, - /* [in] */ LCID lcid, - /* [size_is][out] */ DISPID *rgDispId); + HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( + IDocHostUIHandlerDispatch * This, + /* [in] */ REFIID riid, + /* [size_is][in] */ _In_count_(cNames) LPOLESTR *rgszNames, + /* [in] */ UINT cNames, + /* [in] */ LCID lcid, + /* [size_is][out] */ DISPID *rgDispId); - /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( - IDocHostUIHandlerDispatch * This, - /* [in] */ DISPID dispIdMember, - /* [in] */ REFIID riid, - /* [in] */ LCID lcid, - /* [in] */ WORD wFlags, - /* [out][in] */ DISPPARAMS *pDispParams, - /* [out] */ VARIANT *pVarResult, - /* [out] */ EXCEPINFO *pExcepInfo, - /* [out] */ UINT *puArgErr); + /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( + IDocHostUIHandlerDispatch * This, + /* [in] */ DISPID dispIdMember, + /* [in] */ REFIID riid, + /* [in] */ LCID lcid, + /* [in] */ WORD wFlags, + /* [out][in] */ DISPPARAMS *pDispParams, + /* [out] */ VARIANT *pVarResult, + /* [out] */ EXCEPINFO *pExcepInfo, + /* [out] */ UINT *puArgErr); - HRESULT ( STDMETHODCALLTYPE *ShowContextMenu )( - IDocHostUIHandlerDispatch * This, - /* [in] */ DWORD dwID, - /* [in] */ DWORD x, - /* [in] */ DWORD y, - /* [in] */ IUnknown *pcmdtReserved, - /* [in] */ IDispatch *pdispReserved, - /* [retval][out] */ HRESULT *dwRetVal); + HRESULT ( STDMETHODCALLTYPE *ShowContextMenu )( + IDocHostUIHandlerDispatch * This, + /* [in] */ DWORD dwID, + /* [in] */ DWORD x, + /* [in] */ DWORD y, + /* [in] */ IUnknown *pcmdtReserved, + /* [in] */ IDispatch *pdispReserved, + /* [retval][out] */ HRESULT *dwRetVal); - HRESULT ( STDMETHODCALLTYPE *GetHostInfo )( - IDocHostUIHandlerDispatch * This, - /* [out][in] */ DWORD *pdwFlags, - /* [out][in] */ DWORD *pdwDoubleClick); + HRESULT ( STDMETHODCALLTYPE *GetHostInfo )( + IDocHostUIHandlerDispatch * This, + /* [out][in] */ DWORD *pdwFlags, + /* [out][in] */ DWORD *pdwDoubleClick); - HRESULT ( STDMETHODCALLTYPE *ShowUI )( - IDocHostUIHandlerDispatch * This, - /* [in] */ DWORD dwID, - /* [in] */ IUnknown *pActiveObject, - /* [in] */ IUnknown *pCommandTarget, - /* [in] */ IUnknown *pFrame, - /* [in] */ IUnknown *pDoc, - /* [retval][out] */ HRESULT *dwRetVal); + HRESULT ( STDMETHODCALLTYPE *ShowUI )( + IDocHostUIHandlerDispatch * This, + /* [in] */ DWORD dwID, + /* [in] */ IUnknown *pActiveObject, + /* [in] */ IUnknown *pCommandTarget, + /* [in] */ IUnknown *pFrame, + /* [in] */ IUnknown *pDoc, + /* [retval][out] */ HRESULT *dwRetVal); - HRESULT ( STDMETHODCALLTYPE *HideUI )( - IDocHostUIHandlerDispatch * This); + HRESULT ( STDMETHODCALLTYPE *HideUI )( + IDocHostUIHandlerDispatch * This); - HRESULT ( STDMETHODCALLTYPE *UpdateUI )( - IDocHostUIHandlerDispatch * This); + HRESULT ( STDMETHODCALLTYPE *UpdateUI )( + IDocHostUIHandlerDispatch * This); - HRESULT ( STDMETHODCALLTYPE *EnableModeless )( - IDocHostUIHandlerDispatch * This, - /* [in] */ VARIANT_BOOL fEnable); + HRESULT ( STDMETHODCALLTYPE *EnableModeless )( + IDocHostUIHandlerDispatch * This, + /* [in] */ VARIANT_BOOL fEnable); - HRESULT ( STDMETHODCALLTYPE *OnDocWindowActivate )( - IDocHostUIHandlerDispatch * This, - /* [in] */ VARIANT_BOOL fActivate); + HRESULT ( STDMETHODCALLTYPE *OnDocWindowActivate )( + IDocHostUIHandlerDispatch * This, + /* [in] */ VARIANT_BOOL fActivate); - HRESULT ( STDMETHODCALLTYPE *OnFrameWindowActivate )( - IDocHostUIHandlerDispatch * This, - /* [in] */ VARIANT_BOOL fActivate); + HRESULT ( STDMETHODCALLTYPE *OnFrameWindowActivate )( + IDocHostUIHandlerDispatch * This, + /* [in] */ VARIANT_BOOL fActivate); - HRESULT ( STDMETHODCALLTYPE *ResizeBorder )( - IDocHostUIHandlerDispatch * This, - /* [in] */ long left, - /* [in] */ long top, - /* [in] */ long right, - /* [in] */ long bottom, - /* [in] */ IUnknown *pUIWindow, - /* [in] */ VARIANT_BOOL fFrameWindow); + HRESULT ( STDMETHODCALLTYPE *ResizeBorder )( + IDocHostUIHandlerDispatch * This, + /* [in] */ long left, + /* [in] */ long top, + /* [in] */ long right, + /* [in] */ long bottom, + /* [in] */ IUnknown *pUIWindow, + /* [in] */ VARIANT_BOOL fFrameWindow); - HRESULT ( STDMETHODCALLTYPE *TranslateAccelerator )( - IDocHostUIHandlerDispatch * This, - /* [in] */ DWORD_PTR hWnd, - /* [in] */ DWORD nMessage, - /* [in] */ DWORD_PTR wParam, - /* [in] */ DWORD_PTR lParam, - /* [in] */ BSTR bstrGuidCmdGroup, - /* [in] */ DWORD nCmdID, - /* [retval][out] */ HRESULT *dwRetVal); + HRESULT ( STDMETHODCALLTYPE *TranslateAccelerator )( + IDocHostUIHandlerDispatch * This, + /* [in] */ DWORD_PTR hWnd, + /* [in] */ DWORD nMessage, + /* [in] */ DWORD_PTR wParam, + /* [in] */ DWORD_PTR lParam, + /* [in] */ BSTR bstrGuidCmdGroup, + /* [in] */ DWORD nCmdID, + /* [retval][out] */ HRESULT *dwRetVal); - HRESULT ( STDMETHODCALLTYPE *GetOptionKeyPath )( - IDocHostUIHandlerDispatch * This, - /* [out] */ BSTR *pbstrKey, - /* [in] */ DWORD dw); + HRESULT ( STDMETHODCALLTYPE *GetOptionKeyPath )( + IDocHostUIHandlerDispatch * This, + /* [out] */ BSTR *pbstrKey, + /* [in] */ DWORD dw); - HRESULT ( STDMETHODCALLTYPE *GetDropTarget )( - IDocHostUIHandlerDispatch * This, - /* [in] */ IUnknown *pDropTarget, - /* [out] */ IUnknown **ppDropTarget); + HRESULT ( STDMETHODCALLTYPE *GetDropTarget )( + IDocHostUIHandlerDispatch * This, + /* [in] */ IUnknown *pDropTarget, + /* [out] */ IUnknown **ppDropTarget); - HRESULT ( STDMETHODCALLTYPE *GetExternal )( - IDocHostUIHandlerDispatch * This, - /* [out] */ IDispatch **ppDispatch); + HRESULT ( STDMETHODCALLTYPE *GetExternal )( + IDocHostUIHandlerDispatch * This, + /* [out] */ IDispatch **ppDispatch); - HRESULT ( STDMETHODCALLTYPE *TranslateUrl )( - IDocHostUIHandlerDispatch * This, - /* [in] */ DWORD dwTranslate, - /* [in] */ BSTR bstrURLIn, - /* [out] */ BSTR *pbstrURLOut); + HRESULT ( STDMETHODCALLTYPE *TranslateUrl )( + IDocHostUIHandlerDispatch * This, + /* [in] */ DWORD dwTranslate, + /* [in] */ BSTR bstrURLIn, + /* [out] */ BSTR *pbstrURLOut); - HRESULT ( STDMETHODCALLTYPE *FilterDataObject )( - IDocHostUIHandlerDispatch * This, - /* [in] */ IUnknown *pDO, - /* [out] */ IUnknown **ppDORet); + HRESULT ( STDMETHODCALLTYPE *FilterDataObject )( + IDocHostUIHandlerDispatch * This, + /* [in] */ IUnknown *pDO, + /* [out] */ IUnknown **ppDORet); - END_INTERFACE - } IDocHostUIHandlerDispatchVtbl; + END_INTERFACE + } IDocHostUIHandlerDispatchVtbl; - interface IDocHostUIHandlerDispatch - { - CONST_VTBL struct IDocHostUIHandlerDispatchVtbl *lpVtbl; - }; + interface IDocHostUIHandlerDispatch + { + CONST_VTBL struct IDocHostUIHandlerDispatchVtbl *lpVtbl; + }; #ifdef COBJMACROS -#define IDocHostUIHandlerDispatch_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) +#define IDocHostUIHandlerDispatch_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) -#define IDocHostUIHandlerDispatch_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) +#define IDocHostUIHandlerDispatch_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) -#define IDocHostUIHandlerDispatch_Release(This) \ - (This)->lpVtbl -> Release(This) +#define IDocHostUIHandlerDispatch_Release(This) \ + (This)->lpVtbl -> Release(This) -#define IDocHostUIHandlerDispatch_GetTypeInfoCount(This,pctinfo) \ - (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) +#define IDocHostUIHandlerDispatch_GetTypeInfoCount(This,pctinfo) \ + (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) -#define IDocHostUIHandlerDispatch_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ - (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) +#define IDocHostUIHandlerDispatch_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ + (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) -#define IDocHostUIHandlerDispatch_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ - (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) +#define IDocHostUIHandlerDispatch_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ + (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) -#define IDocHostUIHandlerDispatch_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ - (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) +#define IDocHostUIHandlerDispatch_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ + (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) -#define IDocHostUIHandlerDispatch_ShowContextMenu(This,dwID,x,y,pcmdtReserved,pdispReserved,dwRetVal) \ - (This)->lpVtbl -> ShowContextMenu(This,dwID,x,y,pcmdtReserved,pdispReserved,dwRetVal) +#define IDocHostUIHandlerDispatch_ShowContextMenu(This,dwID,x,y,pcmdtReserved,pdispReserved,dwRetVal) \ + (This)->lpVtbl -> ShowContextMenu(This,dwID,x,y,pcmdtReserved,pdispReserved,dwRetVal) -#define IDocHostUIHandlerDispatch_GetHostInfo(This,pdwFlags,pdwDoubleClick) \ - (This)->lpVtbl -> GetHostInfo(This,pdwFlags,pdwDoubleClick) +#define IDocHostUIHandlerDispatch_GetHostInfo(This,pdwFlags,pdwDoubleClick) \ + (This)->lpVtbl -> GetHostInfo(This,pdwFlags,pdwDoubleClick) -#define IDocHostUIHandlerDispatch_ShowUI(This,dwID,pActiveObject,pCommandTarget,pFrame,pDoc,dwRetVal) \ - (This)->lpVtbl -> ShowUI(This,dwID,pActiveObject,pCommandTarget,pFrame,pDoc,dwRetVal) +#define IDocHostUIHandlerDispatch_ShowUI(This,dwID,pActiveObject,pCommandTarget,pFrame,pDoc,dwRetVal) \ + (This)->lpVtbl -> ShowUI(This,dwID,pActiveObject,pCommandTarget,pFrame,pDoc,dwRetVal) -#define IDocHostUIHandlerDispatch_HideUI(This) \ - (This)->lpVtbl -> HideUI(This) +#define IDocHostUIHandlerDispatch_HideUI(This) \ + (This)->lpVtbl -> HideUI(This) -#define IDocHostUIHandlerDispatch_UpdateUI(This) \ - (This)->lpVtbl -> UpdateUI(This) +#define IDocHostUIHandlerDispatch_UpdateUI(This) \ + (This)->lpVtbl -> UpdateUI(This) -#define IDocHostUIHandlerDispatch_EnableModeless(This,fEnable) \ - (This)->lpVtbl -> EnableModeless(This,fEnable) +#define IDocHostUIHandlerDispatch_EnableModeless(This,fEnable) \ + (This)->lpVtbl -> EnableModeless(This,fEnable) -#define IDocHostUIHandlerDispatch_OnDocWindowActivate(This,fActivate) \ - (This)->lpVtbl -> OnDocWindowActivate(This,fActivate) +#define IDocHostUIHandlerDispatch_OnDocWindowActivate(This,fActivate) \ + (This)->lpVtbl -> OnDocWindowActivate(This,fActivate) -#define IDocHostUIHandlerDispatch_OnFrameWindowActivate(This,fActivate) \ - (This)->lpVtbl -> OnFrameWindowActivate(This,fActivate) +#define IDocHostUIHandlerDispatch_OnFrameWindowActivate(This,fActivate) \ + (This)->lpVtbl -> OnFrameWindowActivate(This,fActivate) -#define IDocHostUIHandlerDispatch_ResizeBorder(This,left,top,right,bottom,pUIWindow,fFrameWindow) \ - (This)->lpVtbl -> ResizeBorder(This,left,top,right,bottom,pUIWindow,fFrameWindow) +#define IDocHostUIHandlerDispatch_ResizeBorder(This,left,top,right,bottom,pUIWindow,fFrameWindow) \ + (This)->lpVtbl -> ResizeBorder(This,left,top,right,bottom,pUIWindow,fFrameWindow) -#define IDocHostUIHandlerDispatch_TranslateAccelerator(This,hWnd,nMessage,wParam,lParam,bstrGuidCmdGroup,nCmdID,dwRetVal) \ - (This)->lpVtbl -> TranslateAccelerator(This,hWnd,nMessage,wParam,lParam,bstrGuidCmdGroup,nCmdID,dwRetVal) +#define IDocHostUIHandlerDispatch_TranslateAccelerator(This,hWnd,nMessage,wParam,lParam,bstrGuidCmdGroup,nCmdID,dwRetVal) \ + (This)->lpVtbl -> TranslateAccelerator(This,hWnd,nMessage,wParam,lParam,bstrGuidCmdGroup,nCmdID,dwRetVal) -#define IDocHostUIHandlerDispatch_GetOptionKeyPath(This,pbstrKey,dw) \ - (This)->lpVtbl -> GetOptionKeyPath(This,pbstrKey,dw) +#define IDocHostUIHandlerDispatch_GetOptionKeyPath(This,pbstrKey,dw) \ + (This)->lpVtbl -> GetOptionKeyPath(This,pbstrKey,dw) -#define IDocHostUIHandlerDispatch_GetDropTarget(This,pDropTarget,ppDropTarget) \ - (This)->lpVtbl -> GetDropTarget(This,pDropTarget,ppDropTarget) +#define IDocHostUIHandlerDispatch_GetDropTarget(This,pDropTarget,ppDropTarget) \ + (This)->lpVtbl -> GetDropTarget(This,pDropTarget,ppDropTarget) -#define IDocHostUIHandlerDispatch_GetExternal(This,ppDispatch) \ - (This)->lpVtbl -> GetExternal(This,ppDispatch) +#define IDocHostUIHandlerDispatch_GetExternal(This,ppDispatch) \ + (This)->lpVtbl -> GetExternal(This,ppDispatch) -#define IDocHostUIHandlerDispatch_TranslateUrl(This,dwTranslate,bstrURLIn,pbstrURLOut) \ - (This)->lpVtbl -> TranslateUrl(This,dwTranslate,bstrURLIn,pbstrURLOut) +#define IDocHostUIHandlerDispatch_TranslateUrl(This,dwTranslate,bstrURLIn,pbstrURLOut) \ + (This)->lpVtbl -> TranslateUrl(This,dwTranslate,bstrURLIn,pbstrURLOut) -#define IDocHostUIHandlerDispatch_FilterDataObject(This,pDO,ppDORet) \ - (This)->lpVtbl -> FilterDataObject(This,pDO,ppDORet) +#define IDocHostUIHandlerDispatch_FilterDataObject(This,pDO,ppDORet) \ + (This)->lpVtbl -> FilterDataObject(This,pDO,ppDORet) #endif /* COBJMACROS */ -#endif /* C style interface */ +#endif /* C style interface */ HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_ShowContextMenu_Proxy( - IDocHostUIHandlerDispatch * This, - /* [in] */ DWORD dwID, - /* [in] */ DWORD x, - /* [in] */ DWORD y, - /* [in] */ IUnknown *pcmdtReserved, - /* [in] */ IDispatch *pdispReserved, - /* [retval][out] */ HRESULT *dwRetVal); + IDocHostUIHandlerDispatch * This, + /* [in] */ DWORD dwID, + /* [in] */ DWORD x, + /* [in] */ DWORD y, + /* [in] */ IUnknown *pcmdtReserved, + /* [in] */ IDispatch *pdispReserved, + /* [retval][out] */ HRESULT *dwRetVal); void __RPC_STUB IDocHostUIHandlerDispatch_ShowContextMenu_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_GetHostInfo_Proxy( - IDocHostUIHandlerDispatch * This, - /* [out][in] */ DWORD *pdwFlags, - /* [out][in] */ DWORD *pdwDoubleClick); + IDocHostUIHandlerDispatch * This, + /* [out][in] */ DWORD *pdwFlags, + /* [out][in] */ DWORD *pdwDoubleClick); void __RPC_STUB IDocHostUIHandlerDispatch_GetHostInfo_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_ShowUI_Proxy( - IDocHostUIHandlerDispatch * This, - /* [in] */ DWORD dwID, - /* [in] */ IUnknown *pActiveObject, - /* [in] */ IUnknown *pCommandTarget, - /* [in] */ IUnknown *pFrame, - /* [in] */ IUnknown *pDoc, - /* [retval][out] */ HRESULT *dwRetVal); + IDocHostUIHandlerDispatch * This, + /* [in] */ DWORD dwID, + /* [in] */ IUnknown *pActiveObject, + /* [in] */ IUnknown *pCommandTarget, + /* [in] */ IUnknown *pFrame, + /* [in] */ IUnknown *pDoc, + /* [retval][out] */ HRESULT *dwRetVal); void __RPC_STUB IDocHostUIHandlerDispatch_ShowUI_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_HideUI_Proxy( - IDocHostUIHandlerDispatch * This); + IDocHostUIHandlerDispatch * This); void __RPC_STUB IDocHostUIHandlerDispatch_HideUI_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_UpdateUI_Proxy( - IDocHostUIHandlerDispatch * This); + IDocHostUIHandlerDispatch * This); void __RPC_STUB IDocHostUIHandlerDispatch_UpdateUI_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_EnableModeless_Proxy( - IDocHostUIHandlerDispatch * This, - /* [in] */ VARIANT_BOOL fEnable); + IDocHostUIHandlerDispatch * This, + /* [in] */ VARIANT_BOOL fEnable); void __RPC_STUB IDocHostUIHandlerDispatch_EnableModeless_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_OnDocWindowActivate_Proxy( - IDocHostUIHandlerDispatch * This, - /* [in] */ VARIANT_BOOL fActivate); + IDocHostUIHandlerDispatch * This, + /* [in] */ VARIANT_BOOL fActivate); void __RPC_STUB IDocHostUIHandlerDispatch_OnDocWindowActivate_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_OnFrameWindowActivate_Proxy( - IDocHostUIHandlerDispatch * This, - /* [in] */ VARIANT_BOOL fActivate); + IDocHostUIHandlerDispatch * This, + /* [in] */ VARIANT_BOOL fActivate); void __RPC_STUB IDocHostUIHandlerDispatch_OnFrameWindowActivate_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_ResizeBorder_Proxy( - IDocHostUIHandlerDispatch * This, - /* [in] */ long left, - /* [in] */ long top, - /* [in] */ long right, - /* [in] */ long bottom, - /* [in] */ IUnknown *pUIWindow, - /* [in] */ VARIANT_BOOL fFrameWindow); + IDocHostUIHandlerDispatch * This, + /* [in] */ long left, + /* [in] */ long top, + /* [in] */ long right, + /* [in] */ long bottom, + /* [in] */ IUnknown *pUIWindow, + /* [in] */ VARIANT_BOOL fFrameWindow); void __RPC_STUB IDocHostUIHandlerDispatch_ResizeBorder_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_TranslateAccelerator_Proxy( - IDocHostUIHandlerDispatch * This, - /* [in] */ DWORD_PTR hWnd, - /* [in] */ DWORD nMessage, - /* [in] */ DWORD_PTR wParam, - /* [in] */ DWORD_PTR lParam, - /* [in] */ BSTR bstrGuidCmdGroup, - /* [in] */ DWORD nCmdID, - /* [retval][out] */ HRESULT *dwRetVal); + IDocHostUIHandlerDispatch * This, + /* [in] */ DWORD_PTR hWnd, + /* [in] */ DWORD nMessage, + /* [in] */ DWORD_PTR wParam, + /* [in] */ DWORD_PTR lParam, + /* [in] */ BSTR bstrGuidCmdGroup, + /* [in] */ DWORD nCmdID, + /* [retval][out] */ HRESULT *dwRetVal); void __RPC_STUB IDocHostUIHandlerDispatch_TranslateAccelerator_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_GetOptionKeyPath_Proxy( - IDocHostUIHandlerDispatch * This, - /* [out] */ BSTR *pbstrKey, - /* [in] */ DWORD dw); + IDocHostUIHandlerDispatch * This, + /* [out] */ BSTR *pbstrKey, + /* [in] */ DWORD dw); void __RPC_STUB IDocHostUIHandlerDispatch_GetOptionKeyPath_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_GetDropTarget_Proxy( - IDocHostUIHandlerDispatch * This, - /* [in] */ IUnknown *pDropTarget, - /* [out] */ IUnknown **ppDropTarget); + IDocHostUIHandlerDispatch * This, + /* [in] */ IUnknown *pDropTarget, + /* [out] */ IUnknown **ppDropTarget); void __RPC_STUB IDocHostUIHandlerDispatch_GetDropTarget_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_GetExternal_Proxy( - IDocHostUIHandlerDispatch * This, - /* [out] */ IDispatch **ppDispatch); + IDocHostUIHandlerDispatch * This, + /* [out] */ IDispatch **ppDispatch); void __RPC_STUB IDocHostUIHandlerDispatch_GetExternal_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_TranslateUrl_Proxy( - IDocHostUIHandlerDispatch * This, - /* [in] */ DWORD dwTranslate, - /* [in] */ BSTR bstrURLIn, - /* [out] */ BSTR *pbstrURLOut); + IDocHostUIHandlerDispatch * This, + /* [in] */ DWORD dwTranslate, + /* [in] */ BSTR bstrURLIn, + /* [out] */ BSTR *pbstrURLOut); void __RPC_STUB IDocHostUIHandlerDispatch_TranslateUrl_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IDocHostUIHandlerDispatch_FilterDataObject_Proxy( - IDocHostUIHandlerDispatch * This, - /* [in] */ IUnknown *pDO, - /* [out] */ IUnknown **ppDORet); + IDocHostUIHandlerDispatch * This, + /* [in] */ IUnknown *pDO, + /* [out] */ IUnknown **ppDORet); void __RPC_STUB IDocHostUIHandlerDispatch_FilterDataObject_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); -#endif /* __IDocHostUIHandlerDispatch_INTERFACE_DEFINED__ */ +#endif /* __IDocHostUIHandlerDispatch_INTERFACE_DEFINED__ */ #ifndef __IAxWinHostWindow_INTERFACE_DEFINED__ @@ -1071,220 +1071,220 @@ EXTERN_C const IID IID_IAxWinHostWindow; #if defined(__cplusplus) && !defined(CINTERFACE) - MIDL_INTERFACE("B6EA2050-048A-11d1-82B9-00C04FB9942E") - IAxWinHostWindow : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE CreateControl( - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream) = 0; + MIDL_INTERFACE("B6EA2050-048A-11d1-82B9-00C04FB9942E") + IAxWinHostWindow : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE CreateControl( + /* [in] */ LPCOLESTR lpTricsData, + /* [in] */ HWND hWnd, + /* [in] */ IStream *pStream) = 0; - virtual HRESULT STDMETHODCALLTYPE CreateControlEx( - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream, - /* [out] */ IUnknown **ppUnk, - /* [in] */ REFIID riidAdvise, - /* [in] */ IUnknown *punkAdvise) = 0; + virtual HRESULT STDMETHODCALLTYPE CreateControlEx( + /* [in] */ LPCOLESTR lpTricsData, + /* [in] */ HWND hWnd, + /* [in] */ IStream *pStream, + /* [out] */ IUnknown **ppUnk, + /* [in] */ REFIID riidAdvise, + /* [in] */ IUnknown *punkAdvise) = 0; - virtual HRESULT STDMETHODCALLTYPE AttachControl( - /* [in] */ IUnknown *pUnkControl, - /* [in] */ HWND hWnd) = 0; + virtual HRESULT STDMETHODCALLTYPE AttachControl( + /* [in] */ IUnknown *pUnkControl, + /* [in] */ HWND hWnd) = 0; - virtual HRESULT STDMETHODCALLTYPE QueryControl( - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject) = 0; + virtual HRESULT STDMETHODCALLTYPE QueryControl( + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject) = 0; - virtual HRESULT STDMETHODCALLTYPE SetExternalDispatch( - /* [in] */ IDispatch *pDisp) = 0; + virtual HRESULT STDMETHODCALLTYPE SetExternalDispatch( + /* [in] */ IDispatch *pDisp) = 0; - virtual HRESULT STDMETHODCALLTYPE SetExternalUIHandler( - /* [in] */ IDocHostUIHandlerDispatch *pDisp) = 0; + virtual HRESULT STDMETHODCALLTYPE SetExternalUIHandler( + /* [in] */ IDocHostUIHandlerDispatch *pDisp) = 0; - }; + }; -#else /* C style interface */ +#else /* C style interface */ - typedef struct IAxWinHostWindowVtbl - { - BEGIN_INTERFACE + typedef struct IAxWinHostWindowVtbl + { + BEGIN_INTERFACE - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IAxWinHostWindow * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IAxWinHostWindow * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); - ULONG ( STDMETHODCALLTYPE *AddRef )( - IAxWinHostWindow * This); + ULONG ( STDMETHODCALLTYPE *AddRef )( + IAxWinHostWindow * This); - ULONG ( STDMETHODCALLTYPE *Release )( - IAxWinHostWindow * This); + ULONG ( STDMETHODCALLTYPE *Release )( + IAxWinHostWindow * This); - HRESULT ( STDMETHODCALLTYPE *CreateControl )( - IAxWinHostWindow * This, - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream); + HRESULT ( STDMETHODCALLTYPE *CreateControl )( + IAxWinHostWindow * This, + /* [in] */ LPCOLESTR lpTricsData, + /* [in] */ HWND hWnd, + /* [in] */ IStream *pStream); - HRESULT ( STDMETHODCALLTYPE *CreateControlEx )( - IAxWinHostWindow * This, - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream, - /* [out] */ IUnknown **ppUnk, - /* [in] */ REFIID riidAdvise, - /* [in] */ IUnknown *punkAdvise); + HRESULT ( STDMETHODCALLTYPE *CreateControlEx )( + IAxWinHostWindow * This, + /* [in] */ LPCOLESTR lpTricsData, + /* [in] */ HWND hWnd, + /* [in] */ IStream *pStream, + /* [out] */ IUnknown **ppUnk, + /* [in] */ REFIID riidAdvise, + /* [in] */ IUnknown *punkAdvise); - HRESULT ( STDMETHODCALLTYPE *AttachControl )( - IAxWinHostWindow * This, - /* [in] */ IUnknown *pUnkControl, - /* [in] */ HWND hWnd); + HRESULT ( STDMETHODCALLTYPE *AttachControl )( + IAxWinHostWindow * This, + /* [in] */ IUnknown *pUnkControl, + /* [in] */ HWND hWnd); - HRESULT ( STDMETHODCALLTYPE *QueryControl )( - IAxWinHostWindow * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); + HRESULT ( STDMETHODCALLTYPE *QueryControl )( + IAxWinHostWindow * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); - HRESULT ( STDMETHODCALLTYPE *SetExternalDispatch )( - IAxWinHostWindow * This, - /* [in] */ IDispatch *pDisp); + HRESULT ( STDMETHODCALLTYPE *SetExternalDispatch )( + IAxWinHostWindow * This, + /* [in] */ IDispatch *pDisp); - HRESULT ( STDMETHODCALLTYPE *SetExternalUIHandler )( - IAxWinHostWindow * This, - /* [in] */ IDocHostUIHandlerDispatch *pDisp); + HRESULT ( STDMETHODCALLTYPE *SetExternalUIHandler )( + IAxWinHostWindow * This, + /* [in] */ IDocHostUIHandlerDispatch *pDisp); - END_INTERFACE - } IAxWinHostWindowVtbl; + END_INTERFACE + } IAxWinHostWindowVtbl; - interface IAxWinHostWindow - { - CONST_VTBL struct IAxWinHostWindowVtbl *lpVtbl; - }; + interface IAxWinHostWindow + { + CONST_VTBL struct IAxWinHostWindowVtbl *lpVtbl; + }; #ifdef COBJMACROS -#define IAxWinHostWindow_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) +#define IAxWinHostWindow_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) -#define IAxWinHostWindow_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) +#define IAxWinHostWindow_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) -#define IAxWinHostWindow_Release(This) \ - (This)->lpVtbl -> Release(This) +#define IAxWinHostWindow_Release(This) \ + (This)->lpVtbl -> Release(This) -#define IAxWinHostWindow_CreateControl(This,lpTricsData,hWnd,pStream) \ - (This)->lpVtbl -> CreateControl(This,lpTricsData,hWnd,pStream) +#define IAxWinHostWindow_CreateControl(This,lpTricsData,hWnd,pStream) \ + (This)->lpVtbl -> CreateControl(This,lpTricsData,hWnd,pStream) -#define IAxWinHostWindow_CreateControlEx(This,lpTricsData,hWnd,pStream,ppUnk,riidAdvise,punkAdvise) \ - (This)->lpVtbl -> CreateControlEx(This,lpTricsData,hWnd,pStream,ppUnk,riidAdvise,punkAdvise) +#define IAxWinHostWindow_CreateControlEx(This,lpTricsData,hWnd,pStream,ppUnk,riidAdvise,punkAdvise) \ + (This)->lpVtbl -> CreateControlEx(This,lpTricsData,hWnd,pStream,ppUnk,riidAdvise,punkAdvise) -#define IAxWinHostWindow_AttachControl(This,pUnkControl,hWnd) \ - (This)->lpVtbl -> AttachControl(This,pUnkControl,hWnd) +#define IAxWinHostWindow_AttachControl(This,pUnkControl,hWnd) \ + (This)->lpVtbl -> AttachControl(This,pUnkControl,hWnd) -#define IAxWinHostWindow_QueryControl(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryControl(This,riid,ppvObject) +#define IAxWinHostWindow_QueryControl(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryControl(This,riid,ppvObject) -#define IAxWinHostWindow_SetExternalDispatch(This,pDisp) \ - (This)->lpVtbl -> SetExternalDispatch(This,pDisp) +#define IAxWinHostWindow_SetExternalDispatch(This,pDisp) \ + (This)->lpVtbl -> SetExternalDispatch(This,pDisp) -#define IAxWinHostWindow_SetExternalUIHandler(This,pDisp) \ - (This)->lpVtbl -> SetExternalUIHandler(This,pDisp) +#define IAxWinHostWindow_SetExternalUIHandler(This,pDisp) \ + (This)->lpVtbl -> SetExternalUIHandler(This,pDisp) #endif /* COBJMACROS */ -#endif /* C style interface */ +#endif /* C style interface */ HRESULT STDMETHODCALLTYPE IAxWinHostWindow_CreateControl_Proxy( - IAxWinHostWindow * This, - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream); + IAxWinHostWindow * This, + /* [in] */ LPCOLESTR lpTricsData, + /* [in] */ HWND hWnd, + /* [in] */ IStream *pStream); void __RPC_STUB IAxWinHostWindow_CreateControl_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IAxWinHostWindow_CreateControlEx_Proxy( - IAxWinHostWindow * This, - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream, - /* [out] */ IUnknown **ppUnk, - /* [in] */ REFIID riidAdvise, - /* [in] */ IUnknown *punkAdvise); + IAxWinHostWindow * This, + /* [in] */ LPCOLESTR lpTricsData, + /* [in] */ HWND hWnd, + /* [in] */ IStream *pStream, + /* [out] */ IUnknown **ppUnk, + /* [in] */ REFIID riidAdvise, + /* [in] */ IUnknown *punkAdvise); void __RPC_STUB IAxWinHostWindow_CreateControlEx_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IAxWinHostWindow_AttachControl_Proxy( - IAxWinHostWindow * This, - /* [in] */ IUnknown *pUnkControl, - /* [in] */ HWND hWnd); + IAxWinHostWindow * This, + /* [in] */ IUnknown *pUnkControl, + /* [in] */ HWND hWnd); void __RPC_STUB IAxWinHostWindow_AttachControl_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IAxWinHostWindow_QueryControl_Proxy( - IAxWinHostWindow * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); + IAxWinHostWindow * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); void __RPC_STUB IAxWinHostWindow_QueryControl_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IAxWinHostWindow_SetExternalDispatch_Proxy( - IAxWinHostWindow * This, - /* [in] */ IDispatch *pDisp); + IAxWinHostWindow * This, + /* [in] */ IDispatch *pDisp); void __RPC_STUB IAxWinHostWindow_SetExternalDispatch_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IAxWinHostWindow_SetExternalUIHandler_Proxy( - IAxWinHostWindow * This, - /* [in] */ IDocHostUIHandlerDispatch *pDisp); + IAxWinHostWindow * This, + /* [in] */ IDocHostUIHandlerDispatch *pDisp); void __RPC_STUB IAxWinHostWindow_SetExternalUIHandler_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); -#endif /* __IAxWinHostWindow_INTERFACE_DEFINED__ */ +#endif /* __IAxWinHostWindow_INTERFACE_DEFINED__ */ #ifndef __IAxWinHostWindowLic_INTERFACE_DEFINED__ @@ -1298,184 +1298,184 @@ EXTERN_C const IID IID_IAxWinHostWindowLic; #if defined(__cplusplus) && !defined(CINTERFACE) - MIDL_INTERFACE("3935BDA8-4ED9-495c-8650-E01FC1E38A4B") - IAxWinHostWindowLic : public IAxWinHostWindow - { - public: - virtual HRESULT STDMETHODCALLTYPE CreateControlLic( - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream, - /* [in] */ BSTR bstrLic) = 0; + MIDL_INTERFACE("3935BDA8-4ED9-495c-8650-E01FC1E38A4B") + IAxWinHostWindowLic : public IAxWinHostWindow + { + public: + virtual HRESULT STDMETHODCALLTYPE CreateControlLic( + /* [in] */ LPCOLESTR lpTricsData, + /* [in] */ HWND hWnd, + /* [in] */ IStream *pStream, + /* [in] */ BSTR bstrLic) = 0; - virtual HRESULT STDMETHODCALLTYPE CreateControlLicEx( - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream, - /* [out] */ IUnknown **ppUnk, - /* [in] */ REFIID riidAdvise, - /* [in] */ IUnknown *punkAdvise, - /* [in] */ BSTR bstrLic) = 0; + virtual HRESULT STDMETHODCALLTYPE CreateControlLicEx( + /* [in] */ LPCOLESTR lpTricsData, + /* [in] */ HWND hWnd, + /* [in] */ IStream *pStream, + /* [out] */ IUnknown **ppUnk, + /* [in] */ REFIID riidAdvise, + /* [in] */ IUnknown *punkAdvise, + /* [in] */ BSTR bstrLic) = 0; - }; + }; -#else /* C style interface */ +#else /* C style interface */ - typedef struct IAxWinHostWindowLicVtbl - { - BEGIN_INTERFACE + typedef struct IAxWinHostWindowLicVtbl + { + BEGIN_INTERFACE - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IAxWinHostWindowLic * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IAxWinHostWindowLic * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); - ULONG ( STDMETHODCALLTYPE *AddRef )( - IAxWinHostWindowLic * This); + ULONG ( STDMETHODCALLTYPE *AddRef )( + IAxWinHostWindowLic * This); - ULONG ( STDMETHODCALLTYPE *Release )( - IAxWinHostWindowLic * This); + ULONG ( STDMETHODCALLTYPE *Release )( + IAxWinHostWindowLic * This); - HRESULT ( STDMETHODCALLTYPE *CreateControl )( - IAxWinHostWindowLic * This, - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream); + HRESULT ( STDMETHODCALLTYPE *CreateControl )( + IAxWinHostWindowLic * This, + /* [in] */ LPCOLESTR lpTricsData, + /* [in] */ HWND hWnd, + /* [in] */ IStream *pStream); - HRESULT ( STDMETHODCALLTYPE *CreateControlEx )( - IAxWinHostWindowLic * This, - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream, - /* [out] */ IUnknown **ppUnk, - /* [in] */ REFIID riidAdvise, - /* [in] */ IUnknown *punkAdvise); + HRESULT ( STDMETHODCALLTYPE *CreateControlEx )( + IAxWinHostWindowLic * This, + /* [in] */ LPCOLESTR lpTricsData, + /* [in] */ HWND hWnd, + /* [in] */ IStream *pStream, + /* [out] */ IUnknown **ppUnk, + /* [in] */ REFIID riidAdvise, + /* [in] */ IUnknown *punkAdvise); - HRESULT ( STDMETHODCALLTYPE *AttachControl )( - IAxWinHostWindowLic * This, - /* [in] */ IUnknown *pUnkControl, - /* [in] */ HWND hWnd); + HRESULT ( STDMETHODCALLTYPE *AttachControl )( + IAxWinHostWindowLic * This, + /* [in] */ IUnknown *pUnkControl, + /* [in] */ HWND hWnd); - HRESULT ( STDMETHODCALLTYPE *QueryControl )( - IAxWinHostWindowLic * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); + HRESULT ( STDMETHODCALLTYPE *QueryControl )( + IAxWinHostWindowLic * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); - HRESULT ( STDMETHODCALLTYPE *SetExternalDispatch )( - IAxWinHostWindowLic * This, - /* [in] */ IDispatch *pDisp); + HRESULT ( STDMETHODCALLTYPE *SetExternalDispatch )( + IAxWinHostWindowLic * This, + /* [in] */ IDispatch *pDisp); - HRESULT ( STDMETHODCALLTYPE *SetExternalUIHandler )( - IAxWinHostWindowLic * This, - /* [in] */ IDocHostUIHandlerDispatch *pDisp); + HRESULT ( STDMETHODCALLTYPE *SetExternalUIHandler )( + IAxWinHostWindowLic * This, + /* [in] */ IDocHostUIHandlerDispatch *pDisp); - HRESULT ( STDMETHODCALLTYPE *CreateControlLic )( - IAxWinHostWindowLic * This, - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream, - /* [in] */ BSTR bstrLic); + HRESULT ( STDMETHODCALLTYPE *CreateControlLic )( + IAxWinHostWindowLic * This, + /* [in] */ LPCOLESTR lpTricsData, + /* [in] */ HWND hWnd, + /* [in] */ IStream *pStream, + /* [in] */ BSTR bstrLic); - HRESULT ( STDMETHODCALLTYPE *CreateControlLicEx )( - IAxWinHostWindowLic * This, - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream, - /* [out] */ IUnknown **ppUnk, - /* [in] */ REFIID riidAdvise, - /* [in] */ IUnknown *punkAdvise, - /* [in] */ BSTR bstrLic); + HRESULT ( STDMETHODCALLTYPE *CreateControlLicEx )( + IAxWinHostWindowLic * This, + /* [in] */ LPCOLESTR lpTricsData, + /* [in] */ HWND hWnd, + /* [in] */ IStream *pStream, + /* [out] */ IUnknown **ppUnk, + /* [in] */ REFIID riidAdvise, + /* [in] */ IUnknown *punkAdvise, + /* [in] */ BSTR bstrLic); - END_INTERFACE - } IAxWinHostWindowLicVtbl; + END_INTERFACE + } IAxWinHostWindowLicVtbl; - interface IAxWinHostWindowLic - { - CONST_VTBL struct IAxWinHostWindowLicVtbl *lpVtbl; - }; + interface IAxWinHostWindowLic + { + CONST_VTBL struct IAxWinHostWindowLicVtbl *lpVtbl; + }; #ifdef COBJMACROS -#define IAxWinHostWindowLic_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) +#define IAxWinHostWindowLic_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) -#define IAxWinHostWindowLic_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) +#define IAxWinHostWindowLic_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) -#define IAxWinHostWindowLic_Release(This) \ - (This)->lpVtbl -> Release(This) +#define IAxWinHostWindowLic_Release(This) \ + (This)->lpVtbl -> Release(This) -#define IAxWinHostWindowLic_CreateControl(This,lpTricsData,hWnd,pStream) \ - (This)->lpVtbl -> CreateControl(This,lpTricsData,hWnd,pStream) +#define IAxWinHostWindowLic_CreateControl(This,lpTricsData,hWnd,pStream) \ + (This)->lpVtbl -> CreateControl(This,lpTricsData,hWnd,pStream) -#define IAxWinHostWindowLic_CreateControlEx(This,lpTricsData,hWnd,pStream,ppUnk,riidAdvise,punkAdvise) \ - (This)->lpVtbl -> CreateControlEx(This,lpTricsData,hWnd,pStream,ppUnk,riidAdvise,punkAdvise) +#define IAxWinHostWindowLic_CreateControlEx(This,lpTricsData,hWnd,pStream,ppUnk,riidAdvise,punkAdvise) \ + (This)->lpVtbl -> CreateControlEx(This,lpTricsData,hWnd,pStream,ppUnk,riidAdvise,punkAdvise) -#define IAxWinHostWindowLic_AttachControl(This,pUnkControl,hWnd) \ - (This)->lpVtbl -> AttachControl(This,pUnkControl,hWnd) +#define IAxWinHostWindowLic_AttachControl(This,pUnkControl,hWnd) \ + (This)->lpVtbl -> AttachControl(This,pUnkControl,hWnd) -#define IAxWinHostWindowLic_QueryControl(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryControl(This,riid,ppvObject) +#define IAxWinHostWindowLic_QueryControl(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryControl(This,riid,ppvObject) -#define IAxWinHostWindowLic_SetExternalDispatch(This,pDisp) \ - (This)->lpVtbl -> SetExternalDispatch(This,pDisp) +#define IAxWinHostWindowLic_SetExternalDispatch(This,pDisp) \ + (This)->lpVtbl -> SetExternalDispatch(This,pDisp) -#define IAxWinHostWindowLic_SetExternalUIHandler(This,pDisp) \ - (This)->lpVtbl -> SetExternalUIHandler(This,pDisp) +#define IAxWinHostWindowLic_SetExternalUIHandler(This,pDisp) \ + (This)->lpVtbl -> SetExternalUIHandler(This,pDisp) -#define IAxWinHostWindowLic_CreateControlLic(This,lpTricsData,hWnd,pStream,bstrLic) \ - (This)->lpVtbl -> CreateControlLic(This,lpTricsData,hWnd,pStream,bstrLic) +#define IAxWinHostWindowLic_CreateControlLic(This,lpTricsData,hWnd,pStream,bstrLic) \ + (This)->lpVtbl -> CreateControlLic(This,lpTricsData,hWnd,pStream,bstrLic) -#define IAxWinHostWindowLic_CreateControlLicEx(This,lpTricsData,hWnd,pStream,ppUnk,riidAdvise,punkAdvise,bstrLic) \ - (This)->lpVtbl -> CreateControlLicEx(This,lpTricsData,hWnd,pStream,ppUnk,riidAdvise,punkAdvise,bstrLic) +#define IAxWinHostWindowLic_CreateControlLicEx(This,lpTricsData,hWnd,pStream,ppUnk,riidAdvise,punkAdvise,bstrLic) \ + (This)->lpVtbl -> CreateControlLicEx(This,lpTricsData,hWnd,pStream,ppUnk,riidAdvise,punkAdvise,bstrLic) #endif /* COBJMACROS */ -#endif /* C style interface */ +#endif /* C style interface */ HRESULT STDMETHODCALLTYPE IAxWinHostWindowLic_CreateControlLic_Proxy( - IAxWinHostWindowLic * This, - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream, - /* [in] */ BSTR bstrLic); + IAxWinHostWindowLic * This, + /* [in] */ LPCOLESTR lpTricsData, + /* [in] */ HWND hWnd, + /* [in] */ IStream *pStream, + /* [in] */ BSTR bstrLic); void __RPC_STUB IAxWinHostWindowLic_CreateControlLic_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IAxWinHostWindowLic_CreateControlLicEx_Proxy( - IAxWinHostWindowLic * This, - /* [in] */ LPCOLESTR lpTricsData, - /* [in] */ HWND hWnd, - /* [in] */ IStream *pStream, - /* [out] */ IUnknown **ppUnk, - /* [in] */ REFIID riidAdvise, - /* [in] */ IUnknown *punkAdvise, - /* [in] */ BSTR bstrLic); + IAxWinHostWindowLic * This, + /* [in] */ LPCOLESTR lpTricsData, + /* [in] */ HWND hWnd, + /* [in] */ IStream *pStream, + /* [out] */ IUnknown **ppUnk, + /* [in] */ REFIID riidAdvise, + /* [in] */ IUnknown *punkAdvise, + /* [in] */ BSTR bstrLic); void __RPC_STUB IAxWinHostWindowLic_CreateControlLicEx_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); -#endif /* __IAxWinHostWindowLic_INTERFACE_DEFINED__ */ +#endif /* __IAxWinHostWindowLic_INTERFACE_DEFINED__ */ #ifndef __IAxWinAmbientDispatch_INTERFACE_DEFINED__ @@ -1489,719 +1489,719 @@ EXTERN_C const IID IID_IAxWinAmbientDispatch; #if defined(__cplusplus) && !defined(CINTERFACE) - MIDL_INTERFACE("B6EA2051-048A-11d1-82B9-00C04FB9942E") - IAxWinAmbientDispatch : public IDispatch - { - public: - virtual /* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_AllowWindowlessActivation( - /* [in] */ VARIANT_BOOL bCanWindowlessActivate) = 0; + MIDL_INTERFACE("B6EA2051-048A-11d1-82B9-00C04FB9942E") + IAxWinAmbientDispatch : public IDispatch + { + public: + virtual /* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_AllowWindowlessActivation( + /* [in] */ VARIANT_BOOL bCanWindowlessActivate) = 0; - virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_AllowWindowlessActivation( - /* [retval][out] */ VARIANT_BOOL *pbCanWindowlessActivate) = 0; + virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_AllowWindowlessActivation( + /* [retval][out] */ VARIANT_BOOL *pbCanWindowlessActivate) = 0; - virtual /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_BackColor( - /* [in] */ OLE_COLOR clrBackground) = 0; + virtual /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_BackColor( + /* [in] */ OLE_COLOR clrBackground) = 0; - virtual /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_BackColor( - /* [retval][out] */ OLE_COLOR *pclrBackground) = 0; + virtual /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_BackColor( + /* [retval][out] */ OLE_COLOR *pclrBackground) = 0; - virtual /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_ForeColor( - /* [in] */ OLE_COLOR clrForeground) = 0; + virtual /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_ForeColor( + /* [in] */ OLE_COLOR clrForeground) = 0; - virtual /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_ForeColor( - /* [retval][out] */ OLE_COLOR *pclrForeground) = 0; + virtual /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_ForeColor( + /* [retval][out] */ OLE_COLOR *pclrForeground) = 0; - virtual /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_LocaleID( - /* [in] */ LCID lcidLocaleID) = 0; + virtual /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_LocaleID( + /* [in] */ LCID lcidLocaleID) = 0; - virtual /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_LocaleID( - /* [retval][out] */ LCID *plcidLocaleID) = 0; + virtual /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_LocaleID( + /* [retval][out] */ LCID *plcidLocaleID) = 0; - virtual /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_UserMode( - /* [in] */ VARIANT_BOOL bUserMode) = 0; + virtual /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_UserMode( + /* [in] */ VARIANT_BOOL bUserMode) = 0; - virtual /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_UserMode( - /* [retval][out] */ VARIANT_BOOL *pbUserMode) = 0; + virtual /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_UserMode( + /* [retval][out] */ VARIANT_BOOL *pbUserMode) = 0; - virtual /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_DisplayAsDefault( - /* [in] */ VARIANT_BOOL bDisplayAsDefault) = 0; + virtual /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_DisplayAsDefault( + /* [in] */ VARIANT_BOOL bDisplayAsDefault) = 0; - virtual /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_DisplayAsDefault( - /* [retval][out] */ VARIANT_BOOL *pbDisplayAsDefault) = 0; + virtual /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_DisplayAsDefault( + /* [retval][out] */ VARIANT_BOOL *pbDisplayAsDefault) = 0; - virtual /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_Font( - /* [in] */ IFontDisp *pFont) = 0; + virtual /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_Font( + /* [in] */ IFontDisp *pFont) = 0; - virtual /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_Font( - /* [retval][out] */ IFontDisp **pFont) = 0; + virtual /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_Font( + /* [retval][out] */ IFontDisp **pFont) = 0; - virtual /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_MessageReflect( - /* [in] */ VARIANT_BOOL bMsgReflect) = 0; + virtual /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_MessageReflect( + /* [in] */ VARIANT_BOOL bMsgReflect) = 0; - virtual /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_MessageReflect( - /* [retval][out] */ VARIANT_BOOL *pbMsgReflect) = 0; + virtual /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_MessageReflect( + /* [retval][out] */ VARIANT_BOOL *pbMsgReflect) = 0; - virtual /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_ShowGrabHandles( - /* [retval][out] */ VARIANT_BOOL *pbShowGrabHandles) = 0; + virtual /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_ShowGrabHandles( + /* [retval][out] */ VARIANT_BOOL *pbShowGrabHandles) = 0; - virtual /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_ShowHatching( - /* [retval][out] */ VARIANT_BOOL *pbShowHatching) = 0; + virtual /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_ShowHatching( + /* [retval][out] */ VARIANT_BOOL *pbShowHatching) = 0; - virtual /* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_DocHostFlags( - /* [in] */ DWORD dwDocHostFlags) = 0; + virtual /* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_DocHostFlags( + /* [in] */ DWORD dwDocHostFlags) = 0; - virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_DocHostFlags( - /* [retval][out] */ DWORD *pdwDocHostFlags) = 0; + virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_DocHostFlags( + /* [retval][out] */ DWORD *pdwDocHostFlags) = 0; - virtual /* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_DocHostDoubleClickFlags( - /* [in] */ DWORD dwDocHostDoubleClickFlags) = 0; + virtual /* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_DocHostDoubleClickFlags( + /* [in] */ DWORD dwDocHostDoubleClickFlags) = 0; - virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_DocHostDoubleClickFlags( - /* [retval][out] */ DWORD *pdwDocHostDoubleClickFlags) = 0; + virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_DocHostDoubleClickFlags( + /* [retval][out] */ DWORD *pdwDocHostDoubleClickFlags) = 0; - virtual /* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_AllowContextMenu( - /* [in] */ VARIANT_BOOL bAllowContextMenu) = 0; + virtual /* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_AllowContextMenu( + /* [in] */ VARIANT_BOOL bAllowContextMenu) = 0; - virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_AllowContextMenu( - /* [retval][out] */ VARIANT_BOOL *pbAllowContextMenu) = 0; + virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_AllowContextMenu( + /* [retval][out] */ VARIANT_BOOL *pbAllowContextMenu) = 0; - virtual /* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_AllowShowUI( - /* [in] */ VARIANT_BOOL bAllowShowUI) = 0; + virtual /* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_AllowShowUI( + /* [in] */ VARIANT_BOOL bAllowShowUI) = 0; - virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_AllowShowUI( - /* [retval][out] */ VARIANT_BOOL *pbAllowShowUI) = 0; + virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_AllowShowUI( + /* [retval][out] */ VARIANT_BOOL *pbAllowShowUI) = 0; - virtual /* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_OptionKeyPath( - /* [in] */ BSTR bstrOptionKeyPath) = 0; + virtual /* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE put_OptionKeyPath( + /* [in] */ BSTR bstrOptionKeyPath) = 0; - virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_OptionKeyPath( - /* [retval][out] */ BSTR *pbstrOptionKeyPath) = 0; + virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_OptionKeyPath( + /* [retval][out] */ BSTR *pbstrOptionKeyPath) = 0; - }; + }; -#else /* C style interface */ +#else /* C style interface */ - typedef struct IAxWinAmbientDispatchVtbl - { - BEGIN_INTERFACE + typedef struct IAxWinAmbientDispatchVtbl + { + BEGIN_INTERFACE - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IAxWinAmbientDispatch * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IAxWinAmbientDispatch * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); - ULONG ( STDMETHODCALLTYPE *AddRef )( - IAxWinAmbientDispatch * This); + ULONG ( STDMETHODCALLTYPE *AddRef )( + IAxWinAmbientDispatch * This); - ULONG ( STDMETHODCALLTYPE *Release )( - IAxWinAmbientDispatch * This); + ULONG ( STDMETHODCALLTYPE *Release )( + IAxWinAmbientDispatch * This); - HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( - IAxWinAmbientDispatch * This, - /* [out] */ UINT *pctinfo); + HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( + IAxWinAmbientDispatch * This, + /* [out] */ UINT *pctinfo); - HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( - IAxWinAmbientDispatch * This, - /* [in] */ UINT iTInfo, - /* [in] */ LCID lcid, - /* [out] */ ITypeInfo **ppTInfo); + HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( + IAxWinAmbientDispatch * This, + /* [in] */ UINT iTInfo, + /* [in] */ LCID lcid, + /* [out] */ ITypeInfo **ppTInfo); - HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( - IAxWinAmbientDispatch * This, - /* [in] */ REFIID riid, - /* [size_is][in] */ _In_count_(cNames) LPOLESTR *rgszNames, - /* [in] */ UINT cNames, - /* [in] */ LCID lcid, - /* [size_is][out] */ DISPID *rgDispId); + HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( + IAxWinAmbientDispatch * This, + /* [in] */ REFIID riid, + /* [size_is][in] */ _In_count_(cNames) LPOLESTR *rgszNames, + /* [in] */ UINT cNames, + /* [in] */ LCID lcid, + /* [size_is][out] */ DISPID *rgDispId); - /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( - IAxWinAmbientDispatch * This, - /* [in] */ DISPID dispIdMember, - /* [in] */ REFIID riid, - /* [in] */ LCID lcid, - /* [in] */ WORD wFlags, - /* [out][in] */ DISPPARAMS *pDispParams, - /* [out] */ VARIANT *pVarResult, - /* [out] */ EXCEPINFO *pExcepInfo, - /* [out] */ UINT *puArgErr); + /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( + IAxWinAmbientDispatch * This, + /* [in] */ DISPID dispIdMember, + /* [in] */ REFIID riid, + /* [in] */ LCID lcid, + /* [in] */ WORD wFlags, + /* [out][in] */ DISPPARAMS *pDispParams, + /* [out] */ VARIANT *pVarResult, + /* [out] */ EXCEPINFO *pExcepInfo, + /* [out] */ UINT *puArgErr); - /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_AllowWindowlessActivation )( - IAxWinAmbientDispatch * This, - /* [in] */ VARIANT_BOOL bCanWindowlessActivate); + /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_AllowWindowlessActivation )( + IAxWinAmbientDispatch * This, + /* [in] */ VARIANT_BOOL bCanWindowlessActivate); - /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_AllowWindowlessActivation )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbCanWindowlessActivate); + /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_AllowWindowlessActivation )( + IAxWinAmbientDispatch * This, + /* [retval][out] */ VARIANT_BOOL *pbCanWindowlessActivate); - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_BackColor )( - IAxWinAmbientDispatch * This, - /* [in] */ OLE_COLOR clrBackground); + /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_BackColor )( + IAxWinAmbientDispatch * This, + /* [in] */ OLE_COLOR clrBackground); - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_BackColor )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ OLE_COLOR *pclrBackground); + /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_BackColor )( + IAxWinAmbientDispatch * This, + /* [retval][out] */ OLE_COLOR *pclrBackground); - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_ForeColor )( - IAxWinAmbientDispatch * This, - /* [in] */ OLE_COLOR clrForeground); + /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_ForeColor )( + IAxWinAmbientDispatch * This, + /* [in] */ OLE_COLOR clrForeground); - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_ForeColor )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ OLE_COLOR *pclrForeground); + /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_ForeColor )( + IAxWinAmbientDispatch * This, + /* [retval][out] */ OLE_COLOR *pclrForeground); - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_LocaleID )( - IAxWinAmbientDispatch * This, - /* [in] */ LCID lcidLocaleID); + /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_LocaleID )( + IAxWinAmbientDispatch * This, + /* [in] */ LCID lcidLocaleID); - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_LocaleID )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ LCID *plcidLocaleID); - - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_UserMode )( - IAxWinAmbientDispatch * This, - /* [in] */ VARIANT_BOOL bUserMode); - - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_UserMode )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbUserMode); - - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_DisplayAsDefault )( - IAxWinAmbientDispatch * This, - /* [in] */ VARIANT_BOOL bDisplayAsDefault); - - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_DisplayAsDefault )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbDisplayAsDefault); - - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_Font )( - IAxWinAmbientDispatch * This, - /* [in] */ IFontDisp *pFont); - - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_Font )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ IFontDisp **pFont); - - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_MessageReflect )( - IAxWinAmbientDispatch * This, - /* [in] */ VARIANT_BOOL bMsgReflect); - - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_MessageReflect )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbMsgReflect); - - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_ShowGrabHandles )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbShowGrabHandles); - - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_ShowHatching )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbShowHatching); - - /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_DocHostFlags )( - IAxWinAmbientDispatch * This, - /* [in] */ DWORD dwDocHostFlags); - - /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_DocHostFlags )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ DWORD *pdwDocHostFlags); - - /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_DocHostDoubleClickFlags )( - IAxWinAmbientDispatch * This, - /* [in] */ DWORD dwDocHostDoubleClickFlags); - - /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_DocHostDoubleClickFlags )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ DWORD *pdwDocHostDoubleClickFlags); - - /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_AllowContextMenu )( - IAxWinAmbientDispatch * This, - /* [in] */ VARIANT_BOOL bAllowContextMenu); - - /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_AllowContextMenu )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbAllowContextMenu); - - /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_AllowShowUI )( - IAxWinAmbientDispatch * This, - /* [in] */ VARIANT_BOOL bAllowShowUI); + /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_LocaleID )( + IAxWinAmbientDispatch * This, + /* [retval][out] */ LCID *plcidLocaleID); + + /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_UserMode )( + IAxWinAmbientDispatch * This, + /* [in] */ VARIANT_BOOL bUserMode); + + /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_UserMode )( + IAxWinAmbientDispatch * This, + /* [retval][out] */ VARIANT_BOOL *pbUserMode); + + /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_DisplayAsDefault )( + IAxWinAmbientDispatch * This, + /* [in] */ VARIANT_BOOL bDisplayAsDefault); + + /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_DisplayAsDefault )( + IAxWinAmbientDispatch * This, + /* [retval][out] */ VARIANT_BOOL *pbDisplayAsDefault); + + /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_Font )( + IAxWinAmbientDispatch * This, + /* [in] */ IFontDisp *pFont); + + /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_Font )( + IAxWinAmbientDispatch * This, + /* [retval][out] */ IFontDisp **pFont); + + /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_MessageReflect )( + IAxWinAmbientDispatch * This, + /* [in] */ VARIANT_BOOL bMsgReflect); + + /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_MessageReflect )( + IAxWinAmbientDispatch * This, + /* [retval][out] */ VARIANT_BOOL *pbMsgReflect); + + /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_ShowGrabHandles )( + IAxWinAmbientDispatch * This, + /* [retval][out] */ VARIANT_BOOL *pbShowGrabHandles); + + /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_ShowHatching )( + IAxWinAmbientDispatch * This, + /* [retval][out] */ VARIANT_BOOL *pbShowHatching); + + /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_DocHostFlags )( + IAxWinAmbientDispatch * This, + /* [in] */ DWORD dwDocHostFlags); + + /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_DocHostFlags )( + IAxWinAmbientDispatch * This, + /* [retval][out] */ DWORD *pdwDocHostFlags); + + /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_DocHostDoubleClickFlags )( + IAxWinAmbientDispatch * This, + /* [in] */ DWORD dwDocHostDoubleClickFlags); + + /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_DocHostDoubleClickFlags )( + IAxWinAmbientDispatch * This, + /* [retval][out] */ DWORD *pdwDocHostDoubleClickFlags); + + /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_AllowContextMenu )( + IAxWinAmbientDispatch * This, + /* [in] */ VARIANT_BOOL bAllowContextMenu); + + /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_AllowContextMenu )( + IAxWinAmbientDispatch * This, + /* [retval][out] */ VARIANT_BOOL *pbAllowContextMenu); + + /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_AllowShowUI )( + IAxWinAmbientDispatch * This, + /* [in] */ VARIANT_BOOL bAllowShowUI); - /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_AllowShowUI )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbAllowShowUI); + /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_AllowShowUI )( + IAxWinAmbientDispatch * This, + /* [retval][out] */ VARIANT_BOOL *pbAllowShowUI); - /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_OptionKeyPath )( - IAxWinAmbientDispatch * This, - /* [in] */ BSTR bstrOptionKeyPath); + /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_OptionKeyPath )( + IAxWinAmbientDispatch * This, + /* [in] */ BSTR bstrOptionKeyPath); - /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_OptionKeyPath )( - IAxWinAmbientDispatch * This, - /* [retval][out] */ BSTR *pbstrOptionKeyPath); + /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_OptionKeyPath )( + IAxWinAmbientDispatch * This, + /* [retval][out] */ BSTR *pbstrOptionKeyPath); - END_INTERFACE - } IAxWinAmbientDispatchVtbl; + END_INTERFACE + } IAxWinAmbientDispatchVtbl; - interface IAxWinAmbientDispatch - { - CONST_VTBL struct IAxWinAmbientDispatchVtbl *lpVtbl; - }; + interface IAxWinAmbientDispatch + { + CONST_VTBL struct IAxWinAmbientDispatchVtbl *lpVtbl; + }; #ifdef COBJMACROS -#define IAxWinAmbientDispatch_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) +#define IAxWinAmbientDispatch_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) -#define IAxWinAmbientDispatch_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) +#define IAxWinAmbientDispatch_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) -#define IAxWinAmbientDispatch_Release(This) \ - (This)->lpVtbl -> Release(This) +#define IAxWinAmbientDispatch_Release(This) \ + (This)->lpVtbl -> Release(This) -#define IAxWinAmbientDispatch_GetTypeInfoCount(This,pctinfo) \ - (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) +#define IAxWinAmbientDispatch_GetTypeInfoCount(This,pctinfo) \ + (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) -#define IAxWinAmbientDispatch_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ - (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) +#define IAxWinAmbientDispatch_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ + (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) -#define IAxWinAmbientDispatch_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ - (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) +#define IAxWinAmbientDispatch_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ + (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) -#define IAxWinAmbientDispatch_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ - (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) +#define IAxWinAmbientDispatch_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ + (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) -#define IAxWinAmbientDispatch_put_AllowWindowlessActivation(This,bCanWindowlessActivate) \ - (This)->lpVtbl -> put_AllowWindowlessActivation(This,bCanWindowlessActivate) +#define IAxWinAmbientDispatch_put_AllowWindowlessActivation(This,bCanWindowlessActivate) \ + (This)->lpVtbl -> put_AllowWindowlessActivation(This,bCanWindowlessActivate) -#define IAxWinAmbientDispatch_get_AllowWindowlessActivation(This,pbCanWindowlessActivate) \ - (This)->lpVtbl -> get_AllowWindowlessActivation(This,pbCanWindowlessActivate) +#define IAxWinAmbientDispatch_get_AllowWindowlessActivation(This,pbCanWindowlessActivate) \ + (This)->lpVtbl -> get_AllowWindowlessActivation(This,pbCanWindowlessActivate) -#define IAxWinAmbientDispatch_put_BackColor(This,clrBackground) \ - (This)->lpVtbl -> put_BackColor(This,clrBackground) +#define IAxWinAmbientDispatch_put_BackColor(This,clrBackground) \ + (This)->lpVtbl -> put_BackColor(This,clrBackground) -#define IAxWinAmbientDispatch_get_BackColor(This,pclrBackground) \ - (This)->lpVtbl -> get_BackColor(This,pclrBackground) +#define IAxWinAmbientDispatch_get_BackColor(This,pclrBackground) \ + (This)->lpVtbl -> get_BackColor(This,pclrBackground) -#define IAxWinAmbientDispatch_put_ForeColor(This,clrForeground) \ - (This)->lpVtbl -> put_ForeColor(This,clrForeground) +#define IAxWinAmbientDispatch_put_ForeColor(This,clrForeground) \ + (This)->lpVtbl -> put_ForeColor(This,clrForeground) -#define IAxWinAmbientDispatch_get_ForeColor(This,pclrForeground) \ - (This)->lpVtbl -> get_ForeColor(This,pclrForeground) +#define IAxWinAmbientDispatch_get_ForeColor(This,pclrForeground) \ + (This)->lpVtbl -> get_ForeColor(This,pclrForeground) -#define IAxWinAmbientDispatch_put_LocaleID(This,lcidLocaleID) \ - (This)->lpVtbl -> put_LocaleID(This,lcidLocaleID) +#define IAxWinAmbientDispatch_put_LocaleID(This,lcidLocaleID) \ + (This)->lpVtbl -> put_LocaleID(This,lcidLocaleID) -#define IAxWinAmbientDispatch_get_LocaleID(This,plcidLocaleID) \ - (This)->lpVtbl -> get_LocaleID(This,plcidLocaleID) +#define IAxWinAmbientDispatch_get_LocaleID(This,plcidLocaleID) \ + (This)->lpVtbl -> get_LocaleID(This,plcidLocaleID) -#define IAxWinAmbientDispatch_put_UserMode(This,bUserMode) \ - (This)->lpVtbl -> put_UserMode(This,bUserMode) +#define IAxWinAmbientDispatch_put_UserMode(This,bUserMode) \ + (This)->lpVtbl -> put_UserMode(This,bUserMode) -#define IAxWinAmbientDispatch_get_UserMode(This,pbUserMode) \ - (This)->lpVtbl -> get_UserMode(This,pbUserMode) +#define IAxWinAmbientDispatch_get_UserMode(This,pbUserMode) \ + (This)->lpVtbl -> get_UserMode(This,pbUserMode) -#define IAxWinAmbientDispatch_put_DisplayAsDefault(This,bDisplayAsDefault) \ - (This)->lpVtbl -> put_DisplayAsDefault(This,bDisplayAsDefault) +#define IAxWinAmbientDispatch_put_DisplayAsDefault(This,bDisplayAsDefault) \ + (This)->lpVtbl -> put_DisplayAsDefault(This,bDisplayAsDefault) -#define IAxWinAmbientDispatch_get_DisplayAsDefault(This,pbDisplayAsDefault) \ - (This)->lpVtbl -> get_DisplayAsDefault(This,pbDisplayAsDefault) +#define IAxWinAmbientDispatch_get_DisplayAsDefault(This,pbDisplayAsDefault) \ + (This)->lpVtbl -> get_DisplayAsDefault(This,pbDisplayAsDefault) -#define IAxWinAmbientDispatch_put_Font(This,pFont) \ - (This)->lpVtbl -> put_Font(This,pFont) +#define IAxWinAmbientDispatch_put_Font(This,pFont) \ + (This)->lpVtbl -> put_Font(This,pFont) -#define IAxWinAmbientDispatch_get_Font(This,pFont) \ - (This)->lpVtbl -> get_Font(This,pFont) +#define IAxWinAmbientDispatch_get_Font(This,pFont) \ + (This)->lpVtbl -> get_Font(This,pFont) -#define IAxWinAmbientDispatch_put_MessageReflect(This,bMsgReflect) \ - (This)->lpVtbl -> put_MessageReflect(This,bMsgReflect) +#define IAxWinAmbientDispatch_put_MessageReflect(This,bMsgReflect) \ + (This)->lpVtbl -> put_MessageReflect(This,bMsgReflect) -#define IAxWinAmbientDispatch_get_MessageReflect(This,pbMsgReflect) \ - (This)->lpVtbl -> get_MessageReflect(This,pbMsgReflect) +#define IAxWinAmbientDispatch_get_MessageReflect(This,pbMsgReflect) \ + (This)->lpVtbl -> get_MessageReflect(This,pbMsgReflect) -#define IAxWinAmbientDispatch_get_ShowGrabHandles(This,pbShowGrabHandles) \ - (This)->lpVtbl -> get_ShowGrabHandles(This,pbShowGrabHandles) +#define IAxWinAmbientDispatch_get_ShowGrabHandles(This,pbShowGrabHandles) \ + (This)->lpVtbl -> get_ShowGrabHandles(This,pbShowGrabHandles) -#define IAxWinAmbientDispatch_get_ShowHatching(This,pbShowHatching) \ - (This)->lpVtbl -> get_ShowHatching(This,pbShowHatching) +#define IAxWinAmbientDispatch_get_ShowHatching(This,pbShowHatching) \ + (This)->lpVtbl -> get_ShowHatching(This,pbShowHatching) -#define IAxWinAmbientDispatch_put_DocHostFlags(This,dwDocHostFlags) \ - (This)->lpVtbl -> put_DocHostFlags(This,dwDocHostFlags) +#define IAxWinAmbientDispatch_put_DocHostFlags(This,dwDocHostFlags) \ + (This)->lpVtbl -> put_DocHostFlags(This,dwDocHostFlags) -#define IAxWinAmbientDispatch_get_DocHostFlags(This,pdwDocHostFlags) \ - (This)->lpVtbl -> get_DocHostFlags(This,pdwDocHostFlags) +#define IAxWinAmbientDispatch_get_DocHostFlags(This,pdwDocHostFlags) \ + (This)->lpVtbl -> get_DocHostFlags(This,pdwDocHostFlags) -#define IAxWinAmbientDispatch_put_DocHostDoubleClickFlags(This,dwDocHostDoubleClickFlags) \ - (This)->lpVtbl -> put_DocHostDoubleClickFlags(This,dwDocHostDoubleClickFlags) +#define IAxWinAmbientDispatch_put_DocHostDoubleClickFlags(This,dwDocHostDoubleClickFlags) \ + (This)->lpVtbl -> put_DocHostDoubleClickFlags(This,dwDocHostDoubleClickFlags) -#define IAxWinAmbientDispatch_get_DocHostDoubleClickFlags(This,pdwDocHostDoubleClickFlags) \ - (This)->lpVtbl -> get_DocHostDoubleClickFlags(This,pdwDocHostDoubleClickFlags) +#define IAxWinAmbientDispatch_get_DocHostDoubleClickFlags(This,pdwDocHostDoubleClickFlags) \ + (This)->lpVtbl -> get_DocHostDoubleClickFlags(This,pdwDocHostDoubleClickFlags) -#define IAxWinAmbientDispatch_put_AllowContextMenu(This,bAllowContextMenu) \ - (This)->lpVtbl -> put_AllowContextMenu(This,bAllowContextMenu) +#define IAxWinAmbientDispatch_put_AllowContextMenu(This,bAllowContextMenu) \ + (This)->lpVtbl -> put_AllowContextMenu(This,bAllowContextMenu) -#define IAxWinAmbientDispatch_get_AllowContextMenu(This,pbAllowContextMenu) \ - (This)->lpVtbl -> get_AllowContextMenu(This,pbAllowContextMenu) +#define IAxWinAmbientDispatch_get_AllowContextMenu(This,pbAllowContextMenu) \ + (This)->lpVtbl -> get_AllowContextMenu(This,pbAllowContextMenu) -#define IAxWinAmbientDispatch_put_AllowShowUI(This,bAllowShowUI) \ - (This)->lpVtbl -> put_AllowShowUI(This,bAllowShowUI) +#define IAxWinAmbientDispatch_put_AllowShowUI(This,bAllowShowUI) \ + (This)->lpVtbl -> put_AllowShowUI(This,bAllowShowUI) -#define IAxWinAmbientDispatch_get_AllowShowUI(This,pbAllowShowUI) \ - (This)->lpVtbl -> get_AllowShowUI(This,pbAllowShowUI) +#define IAxWinAmbientDispatch_get_AllowShowUI(This,pbAllowShowUI) \ + (This)->lpVtbl -> get_AllowShowUI(This,pbAllowShowUI) -#define IAxWinAmbientDispatch_put_OptionKeyPath(This,bstrOptionKeyPath) \ - (This)->lpVtbl -> put_OptionKeyPath(This,bstrOptionKeyPath) +#define IAxWinAmbientDispatch_put_OptionKeyPath(This,bstrOptionKeyPath) \ + (This)->lpVtbl -> put_OptionKeyPath(This,bstrOptionKeyPath) -#define IAxWinAmbientDispatch_get_OptionKeyPath(This,pbstrOptionKeyPath) \ - (This)->lpVtbl -> get_OptionKeyPath(This,pbstrOptionKeyPath) +#define IAxWinAmbientDispatch_get_OptionKeyPath(This,pbstrOptionKeyPath) \ + (This)->lpVtbl -> get_OptionKeyPath(This,pbstrOptionKeyPath) #endif /* COBJMACROS */ -#endif /* C style interface */ +#endif /* C style interface */ /* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_put_AllowWindowlessActivation_Proxy( - IAxWinAmbientDispatch * This, - /* [in] */ VARIANT_BOOL bCanWindowlessActivate); + IAxWinAmbientDispatch * This, + /* [in] */ VARIANT_BOOL bCanWindowlessActivate); void __RPC_STUB IAxWinAmbientDispatch_put_AllowWindowlessActivation_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_AllowWindowlessActivation_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbCanWindowlessActivate); + IAxWinAmbientDispatch * This, + /* [retval][out] */ VARIANT_BOOL *pbCanWindowlessActivate); void __RPC_STUB IAxWinAmbientDispatch_get_AllowWindowlessActivation_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_put_BackColor_Proxy( - IAxWinAmbientDispatch * This, - /* [in] */ OLE_COLOR clrBackground); + IAxWinAmbientDispatch * This, + /* [in] */ OLE_COLOR clrBackground); void __RPC_STUB IAxWinAmbientDispatch_put_BackColor_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_BackColor_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ OLE_COLOR *pclrBackground); + IAxWinAmbientDispatch * This, + /* [retval][out] */ OLE_COLOR *pclrBackground); void __RPC_STUB IAxWinAmbientDispatch_get_BackColor_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_put_ForeColor_Proxy( - IAxWinAmbientDispatch * This, - /* [in] */ OLE_COLOR clrForeground); + IAxWinAmbientDispatch * This, + /* [in] */ OLE_COLOR clrForeground); void __RPC_STUB IAxWinAmbientDispatch_put_ForeColor_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_ForeColor_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ OLE_COLOR *pclrForeground); + IAxWinAmbientDispatch * This, + /* [retval][out] */ OLE_COLOR *pclrForeground); void __RPC_STUB IAxWinAmbientDispatch_get_ForeColor_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_put_LocaleID_Proxy( - IAxWinAmbientDispatch * This, - /* [in] */ LCID lcidLocaleID); + IAxWinAmbientDispatch * This, + /* [in] */ LCID lcidLocaleID); void __RPC_STUB IAxWinAmbientDispatch_put_LocaleID_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_LocaleID_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ LCID *plcidLocaleID); + IAxWinAmbientDispatch * This, + /* [retval][out] */ LCID *plcidLocaleID); void __RPC_STUB IAxWinAmbientDispatch_get_LocaleID_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_put_UserMode_Proxy( - IAxWinAmbientDispatch * This, - /* [in] */ VARIANT_BOOL bUserMode); + IAxWinAmbientDispatch * This, + /* [in] */ VARIANT_BOOL bUserMode); void __RPC_STUB IAxWinAmbientDispatch_put_UserMode_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_UserMode_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbUserMode); + IAxWinAmbientDispatch * This, + /* [retval][out] */ VARIANT_BOOL *pbUserMode); void __RPC_STUB IAxWinAmbientDispatch_get_UserMode_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_put_DisplayAsDefault_Proxy( - IAxWinAmbientDispatch * This, - /* [in] */ VARIANT_BOOL bDisplayAsDefault); + IAxWinAmbientDispatch * This, + /* [in] */ VARIANT_BOOL bDisplayAsDefault); void __RPC_STUB IAxWinAmbientDispatch_put_DisplayAsDefault_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_DisplayAsDefault_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbDisplayAsDefault); + IAxWinAmbientDispatch * This, + /* [retval][out] */ VARIANT_BOOL *pbDisplayAsDefault); void __RPC_STUB IAxWinAmbientDispatch_get_DisplayAsDefault_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_put_Font_Proxy( - IAxWinAmbientDispatch * This, - /* [in] */ IFontDisp *pFont); + IAxWinAmbientDispatch * This, + /* [in] */ IFontDisp *pFont); void __RPC_STUB IAxWinAmbientDispatch_put_Font_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_Font_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ IFontDisp **pFont); + IAxWinAmbientDispatch * This, + /* [retval][out] */ IFontDisp **pFont); void __RPC_STUB IAxWinAmbientDispatch_get_Font_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); /* [id][helpstring][propput] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_put_MessageReflect_Proxy( - IAxWinAmbientDispatch * This, - /* [in] */ VARIANT_BOOL bMsgReflect); + IAxWinAmbientDispatch * This, + /* [in] */ VARIANT_BOOL bMsgReflect); void __RPC_STUB IAxWinAmbientDispatch_put_MessageReflect_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_MessageReflect_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbMsgReflect); + IAxWinAmbientDispatch * This, + /* [retval][out] */ VARIANT_BOOL *pbMsgReflect); void __RPC_STUB IAxWinAmbientDispatch_get_MessageReflect_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_ShowGrabHandles_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbShowGrabHandles); + IAxWinAmbientDispatch * This, + /* [retval][out] */ VARIANT_BOOL *pbShowGrabHandles); void __RPC_STUB IAxWinAmbientDispatch_get_ShowGrabHandles_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); /* [id][helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_ShowHatching_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbShowHatching); + IAxWinAmbientDispatch * This, + /* [retval][out] */ VARIANT_BOOL *pbShowHatching); void __RPC_STUB IAxWinAmbientDispatch_get_ShowHatching_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); /* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_put_DocHostFlags_Proxy( - IAxWinAmbientDispatch * This, - /* [in] */ DWORD dwDocHostFlags); + IAxWinAmbientDispatch * This, + /* [in] */ DWORD dwDocHostFlags); void __RPC_STUB IAxWinAmbientDispatch_put_DocHostFlags_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_DocHostFlags_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ DWORD *pdwDocHostFlags); + IAxWinAmbientDispatch * This, + /* [retval][out] */ DWORD *pdwDocHostFlags); void __RPC_STUB IAxWinAmbientDispatch_get_DocHostFlags_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); /* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_put_DocHostDoubleClickFlags_Proxy( - IAxWinAmbientDispatch * This, - /* [in] */ DWORD dwDocHostDoubleClickFlags); + IAxWinAmbientDispatch * This, + /* [in] */ DWORD dwDocHostDoubleClickFlags); void __RPC_STUB IAxWinAmbientDispatch_put_DocHostDoubleClickFlags_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_DocHostDoubleClickFlags_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ DWORD *pdwDocHostDoubleClickFlags); + IAxWinAmbientDispatch * This, + /* [retval][out] */ DWORD *pdwDocHostDoubleClickFlags); void __RPC_STUB IAxWinAmbientDispatch_get_DocHostDoubleClickFlags_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); /* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_put_AllowContextMenu_Proxy( - IAxWinAmbientDispatch * This, - /* [in] */ VARIANT_BOOL bAllowContextMenu); + IAxWinAmbientDispatch * This, + /* [in] */ VARIANT_BOOL bAllowContextMenu); void __RPC_STUB IAxWinAmbientDispatch_put_AllowContextMenu_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_AllowContextMenu_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbAllowContextMenu); + IAxWinAmbientDispatch * This, + /* [retval][out] */ VARIANT_BOOL *pbAllowContextMenu); void __RPC_STUB IAxWinAmbientDispatch_get_AllowContextMenu_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); /* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_put_AllowShowUI_Proxy( - IAxWinAmbientDispatch * This, - /* [in] */ VARIANT_BOOL bAllowShowUI); + IAxWinAmbientDispatch * This, + /* [in] */ VARIANT_BOOL bAllowShowUI); void __RPC_STUB IAxWinAmbientDispatch_put_AllowShowUI_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_AllowShowUI_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ VARIANT_BOOL *pbAllowShowUI); + IAxWinAmbientDispatch * This, + /* [retval][out] */ VARIANT_BOOL *pbAllowShowUI); void __RPC_STUB IAxWinAmbientDispatch_get_AllowShowUI_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); /* [helpstring][propput] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_put_OptionKeyPath_Proxy( - IAxWinAmbientDispatch * This, - /* [in] */ BSTR bstrOptionKeyPath); + IAxWinAmbientDispatch * This, + /* [in] */ BSTR bstrOptionKeyPath); void __RPC_STUB IAxWinAmbientDispatch_put_OptionKeyPath_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatch_get_OptionKeyPath_Proxy( - IAxWinAmbientDispatch * This, - /* [retval][out] */ BSTR *pbstrOptionKeyPath); + IAxWinAmbientDispatch * This, + /* [retval][out] */ BSTR *pbstrOptionKeyPath); void __RPC_STUB IAxWinAmbientDispatch_get_OptionKeyPath_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); -#endif /* __IAxWinAmbientDispatch_INTERFACE_DEFINED__ */ +#endif /* __IAxWinAmbientDispatch_INTERFACE_DEFINED__ */ #ifndef __IAxWinAmbientDispatchEx_INTERFACE_DEFINED__ @@ -2215,322 +2215,322 @@ EXTERN_C const IID IID_IAxWinAmbientDispatchEx; #if defined(__cplusplus) && !defined(CINTERFACE) - MIDL_INTERFACE("B2D0778B-AC99-4c58-A5C8-E7724E5316B5") - IAxWinAmbientDispatchEx : public IAxWinAmbientDispatch - { - public: - virtual /* [id] */ HRESULT STDMETHODCALLTYPE SetAmbientDispatch( - /* [in] */ IDispatch *pDispatch) = 0; + MIDL_INTERFACE("B2D0778B-AC99-4c58-A5C8-E7724E5316B5") + IAxWinAmbientDispatchEx : public IAxWinAmbientDispatch + { + public: + virtual /* [id] */ HRESULT STDMETHODCALLTYPE SetAmbientDispatch( + /* [in] */ IDispatch *pDispatch) = 0; - }; + }; -#else /* C style interface */ +#else /* C style interface */ - typedef struct IAxWinAmbientDispatchExVtbl - { - BEGIN_INTERFACE + typedef struct IAxWinAmbientDispatchExVtbl + { + BEGIN_INTERFACE - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IAxWinAmbientDispatchEx * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IAxWinAmbientDispatchEx * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); - ULONG ( STDMETHODCALLTYPE *AddRef )( - IAxWinAmbientDispatchEx * This); + ULONG ( STDMETHODCALLTYPE *AddRef )( + IAxWinAmbientDispatchEx * This); - ULONG ( STDMETHODCALLTYPE *Release )( - IAxWinAmbientDispatchEx * This); + ULONG ( STDMETHODCALLTYPE *Release )( + IAxWinAmbientDispatchEx * This); - HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( - IAxWinAmbientDispatchEx * This, - /* [out] */ UINT *pctinfo); + HRESULT ( STDMETHODCALLTYPE *GetTypeInfoCount )( + IAxWinAmbientDispatchEx * This, + /* [out] */ UINT *pctinfo); - HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( - IAxWinAmbientDispatchEx * This, - /* [in] */ UINT iTInfo, - /* [in] */ LCID lcid, - /* [out] */ ITypeInfo **ppTInfo); + HRESULT ( STDMETHODCALLTYPE *GetTypeInfo )( + IAxWinAmbientDispatchEx * This, + /* [in] */ UINT iTInfo, + /* [in] */ LCID lcid, + /* [out] */ ITypeInfo **ppTInfo); - HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( - IAxWinAmbientDispatchEx * This, - /* [in] */ REFIID riid, - /* [size_is][in] */ _In_count_(cNames) LPOLESTR *rgszNames, - /* [in] */ UINT cNames, - /* [in] */ LCID lcid, - /* [size_is][out] */ DISPID *rgDispId); + HRESULT ( STDMETHODCALLTYPE *GetIDsOfNames )( + IAxWinAmbientDispatchEx * This, + /* [in] */ REFIID riid, + /* [size_is][in] */ _In_count_(cNames) LPOLESTR *rgszNames, + /* [in] */ UINT cNames, + /* [in] */ LCID lcid, + /* [size_is][out] */ DISPID *rgDispId); - /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( - IAxWinAmbientDispatchEx * This, - /* [in] */ DISPID dispIdMember, - /* [in] */ REFIID riid, - /* [in] */ LCID lcid, - /* [in] */ WORD wFlags, - /* [out][in] */ DISPPARAMS *pDispParams, - /* [out] */ VARIANT *pVarResult, - /* [out] */ EXCEPINFO *pExcepInfo, - /* [out] */ UINT *puArgErr); + /* [local] */ HRESULT ( STDMETHODCALLTYPE *Invoke )( + IAxWinAmbientDispatchEx * This, + /* [in] */ DISPID dispIdMember, + /* [in] */ REFIID riid, + /* [in] */ LCID lcid, + /* [in] */ WORD wFlags, + /* [out][in] */ DISPPARAMS *pDispParams, + /* [out] */ VARIANT *pVarResult, + /* [out] */ EXCEPINFO *pExcepInfo, + /* [out] */ UINT *puArgErr); - /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_AllowWindowlessActivation )( - IAxWinAmbientDispatchEx * This, - /* [in] */ VARIANT_BOOL bCanWindowlessActivate); + /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_AllowWindowlessActivation )( + IAxWinAmbientDispatchEx * This, + /* [in] */ VARIANT_BOOL bCanWindowlessActivate); - /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_AllowWindowlessActivation )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ VARIANT_BOOL *pbCanWindowlessActivate); + /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_AllowWindowlessActivation )( + IAxWinAmbientDispatchEx * This, + /* [retval][out] */ VARIANT_BOOL *pbCanWindowlessActivate); - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_BackColor )( - IAxWinAmbientDispatchEx * This, - /* [in] */ OLE_COLOR clrBackground); + /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_BackColor )( + IAxWinAmbientDispatchEx * This, + /* [in] */ OLE_COLOR clrBackground); - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_BackColor )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ OLE_COLOR *pclrBackground); + /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_BackColor )( + IAxWinAmbientDispatchEx * This, + /* [retval][out] */ OLE_COLOR *pclrBackground); - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_ForeColor )( - IAxWinAmbientDispatchEx * This, - /* [in] */ OLE_COLOR clrForeground); + /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_ForeColor )( + IAxWinAmbientDispatchEx * This, + /* [in] */ OLE_COLOR clrForeground); - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_ForeColor )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ OLE_COLOR *pclrForeground); + /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_ForeColor )( + IAxWinAmbientDispatchEx * This, + /* [retval][out] */ OLE_COLOR *pclrForeground); - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_LocaleID )( - IAxWinAmbientDispatchEx * This, - /* [in] */ LCID lcidLocaleID); + /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_LocaleID )( + IAxWinAmbientDispatchEx * This, + /* [in] */ LCID lcidLocaleID); - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_LocaleID )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ LCID *plcidLocaleID); + /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_LocaleID )( + IAxWinAmbientDispatchEx * This, + /* [retval][out] */ LCID *plcidLocaleID); - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_UserMode )( - IAxWinAmbientDispatchEx * This, - /* [in] */ VARIANT_BOOL bUserMode); + /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_UserMode )( + IAxWinAmbientDispatchEx * This, + /* [in] */ VARIANT_BOOL bUserMode); - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_UserMode )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ VARIANT_BOOL *pbUserMode); + /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_UserMode )( + IAxWinAmbientDispatchEx * This, + /* [retval][out] */ VARIANT_BOOL *pbUserMode); - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_DisplayAsDefault )( - IAxWinAmbientDispatchEx * This, - /* [in] */ VARIANT_BOOL bDisplayAsDefault); + /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_DisplayAsDefault )( + IAxWinAmbientDispatchEx * This, + /* [in] */ VARIANT_BOOL bDisplayAsDefault); - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_DisplayAsDefault )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ VARIANT_BOOL *pbDisplayAsDefault); + /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_DisplayAsDefault )( + IAxWinAmbientDispatchEx * This, + /* [retval][out] */ VARIANT_BOOL *pbDisplayAsDefault); - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_Font )( - IAxWinAmbientDispatchEx * This, - /* [in] */ IFontDisp *pFont); + /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_Font )( + IAxWinAmbientDispatchEx * This, + /* [in] */ IFontDisp *pFont); - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_Font )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ IFontDisp **pFont); + /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_Font )( + IAxWinAmbientDispatchEx * This, + /* [retval][out] */ IFontDisp **pFont); - /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_MessageReflect )( - IAxWinAmbientDispatchEx * This, - /* [in] */ VARIANT_BOOL bMsgReflect); + /* [id][helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_MessageReflect )( + IAxWinAmbientDispatchEx * This, + /* [in] */ VARIANT_BOOL bMsgReflect); - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_MessageReflect )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ VARIANT_BOOL *pbMsgReflect); + /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_MessageReflect )( + IAxWinAmbientDispatchEx * This, + /* [retval][out] */ VARIANT_BOOL *pbMsgReflect); - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_ShowGrabHandles )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ VARIANT_BOOL *pbShowGrabHandles); + /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_ShowGrabHandles )( + IAxWinAmbientDispatchEx * This, + /* [retval][out] */ VARIANT_BOOL *pbShowGrabHandles); - /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_ShowHatching )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ VARIANT_BOOL *pbShowHatching); + /* [id][helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_ShowHatching )( + IAxWinAmbientDispatchEx * This, + /* [retval][out] */ VARIANT_BOOL *pbShowHatching); - /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_DocHostFlags )( - IAxWinAmbientDispatchEx * This, - /* [in] */ DWORD dwDocHostFlags); + /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_DocHostFlags )( + IAxWinAmbientDispatchEx * This, + /* [in] */ DWORD dwDocHostFlags); - /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_DocHostFlags )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ DWORD *pdwDocHostFlags); + /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_DocHostFlags )( + IAxWinAmbientDispatchEx * This, + /* [retval][out] */ DWORD *pdwDocHostFlags); - /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_DocHostDoubleClickFlags )( - IAxWinAmbientDispatchEx * This, - /* [in] */ DWORD dwDocHostDoubleClickFlags); + /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_DocHostDoubleClickFlags )( + IAxWinAmbientDispatchEx * This, + /* [in] */ DWORD dwDocHostDoubleClickFlags); - /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_DocHostDoubleClickFlags )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ DWORD *pdwDocHostDoubleClickFlags); + /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_DocHostDoubleClickFlags )( + IAxWinAmbientDispatchEx * This, + /* [retval][out] */ DWORD *pdwDocHostDoubleClickFlags); - /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_AllowContextMenu )( - IAxWinAmbientDispatchEx * This, - /* [in] */ VARIANT_BOOL bAllowContextMenu); + /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_AllowContextMenu )( + IAxWinAmbientDispatchEx * This, + /* [in] */ VARIANT_BOOL bAllowContextMenu); - /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_AllowContextMenu )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ VARIANT_BOOL *pbAllowContextMenu); + /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_AllowContextMenu )( + IAxWinAmbientDispatchEx * This, + /* [retval][out] */ VARIANT_BOOL *pbAllowContextMenu); - /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_AllowShowUI )( - IAxWinAmbientDispatchEx * This, - /* [in] */ VARIANT_BOOL bAllowShowUI); + /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_AllowShowUI )( + IAxWinAmbientDispatchEx * This, + /* [in] */ VARIANT_BOOL bAllowShowUI); - /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_AllowShowUI )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ VARIANT_BOOL *pbAllowShowUI); + /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_AllowShowUI )( + IAxWinAmbientDispatchEx * This, + /* [retval][out] */ VARIANT_BOOL *pbAllowShowUI); - /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_OptionKeyPath )( - IAxWinAmbientDispatchEx * This, - /* [in] */ BSTR bstrOptionKeyPath); + /* [helpstring][propput] */ HRESULT ( STDMETHODCALLTYPE *put_OptionKeyPath )( + IAxWinAmbientDispatchEx * This, + /* [in] */ BSTR bstrOptionKeyPath); - /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_OptionKeyPath )( - IAxWinAmbientDispatchEx * This, - /* [retval][out] */ BSTR *pbstrOptionKeyPath); + /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE *get_OptionKeyPath )( + IAxWinAmbientDispatchEx * This, + /* [retval][out] */ BSTR *pbstrOptionKeyPath); - /* [id] */ HRESULT ( STDMETHODCALLTYPE *SetAmbientDispatch )( - IAxWinAmbientDispatchEx * This, - /* [in] */ IDispatch *pDispatch); + /* [id] */ HRESULT ( STDMETHODCALLTYPE *SetAmbientDispatch )( + IAxWinAmbientDispatchEx * This, + /* [in] */ IDispatch *pDispatch); - END_INTERFACE - } IAxWinAmbientDispatchExVtbl; + END_INTERFACE + } IAxWinAmbientDispatchExVtbl; - interface IAxWinAmbientDispatchEx - { - CONST_VTBL struct IAxWinAmbientDispatchExVtbl *lpVtbl; - }; + interface IAxWinAmbientDispatchEx + { + CONST_VTBL struct IAxWinAmbientDispatchExVtbl *lpVtbl; + }; #ifdef COBJMACROS -#define IAxWinAmbientDispatchEx_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) +#define IAxWinAmbientDispatchEx_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) -#define IAxWinAmbientDispatchEx_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) +#define IAxWinAmbientDispatchEx_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) -#define IAxWinAmbientDispatchEx_Release(This) \ - (This)->lpVtbl -> Release(This) +#define IAxWinAmbientDispatchEx_Release(This) \ + (This)->lpVtbl -> Release(This) -#define IAxWinAmbientDispatchEx_GetTypeInfoCount(This,pctinfo) \ - (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) +#define IAxWinAmbientDispatchEx_GetTypeInfoCount(This,pctinfo) \ + (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) -#define IAxWinAmbientDispatchEx_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ - (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) +#define IAxWinAmbientDispatchEx_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ + (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) -#define IAxWinAmbientDispatchEx_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ - (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) +#define IAxWinAmbientDispatchEx_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ + (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) -#define IAxWinAmbientDispatchEx_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ - (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) +#define IAxWinAmbientDispatchEx_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ + (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) -#define IAxWinAmbientDispatchEx_put_AllowWindowlessActivation(This,bCanWindowlessActivate) \ - (This)->lpVtbl -> put_AllowWindowlessActivation(This,bCanWindowlessActivate) +#define IAxWinAmbientDispatchEx_put_AllowWindowlessActivation(This,bCanWindowlessActivate) \ + (This)->lpVtbl -> put_AllowWindowlessActivation(This,bCanWindowlessActivate) -#define IAxWinAmbientDispatchEx_get_AllowWindowlessActivation(This,pbCanWindowlessActivate) \ - (This)->lpVtbl -> get_AllowWindowlessActivation(This,pbCanWindowlessActivate) +#define IAxWinAmbientDispatchEx_get_AllowWindowlessActivation(This,pbCanWindowlessActivate) \ + (This)->lpVtbl -> get_AllowWindowlessActivation(This,pbCanWindowlessActivate) -#define IAxWinAmbientDispatchEx_put_BackColor(This,clrBackground) \ - (This)->lpVtbl -> put_BackColor(This,clrBackground) +#define IAxWinAmbientDispatchEx_put_BackColor(This,clrBackground) \ + (This)->lpVtbl -> put_BackColor(This,clrBackground) -#define IAxWinAmbientDispatchEx_get_BackColor(This,pclrBackground) \ - (This)->lpVtbl -> get_BackColor(This,pclrBackground) +#define IAxWinAmbientDispatchEx_get_BackColor(This,pclrBackground) \ + (This)->lpVtbl -> get_BackColor(This,pclrBackground) -#define IAxWinAmbientDispatchEx_put_ForeColor(This,clrForeground) \ - (This)->lpVtbl -> put_ForeColor(This,clrForeground) +#define IAxWinAmbientDispatchEx_put_ForeColor(This,clrForeground) \ + (This)->lpVtbl -> put_ForeColor(This,clrForeground) -#define IAxWinAmbientDispatchEx_get_ForeColor(This,pclrForeground) \ - (This)->lpVtbl -> get_ForeColor(This,pclrForeground) +#define IAxWinAmbientDispatchEx_get_ForeColor(This,pclrForeground) \ + (This)->lpVtbl -> get_ForeColor(This,pclrForeground) -#define IAxWinAmbientDispatchEx_put_LocaleID(This,lcidLocaleID) \ - (This)->lpVtbl -> put_LocaleID(This,lcidLocaleID) +#define IAxWinAmbientDispatchEx_put_LocaleID(This,lcidLocaleID) \ + (This)->lpVtbl -> put_LocaleID(This,lcidLocaleID) -#define IAxWinAmbientDispatchEx_get_LocaleID(This,plcidLocaleID) \ - (This)->lpVtbl -> get_LocaleID(This,plcidLocaleID) +#define IAxWinAmbientDispatchEx_get_LocaleID(This,plcidLocaleID) \ + (This)->lpVtbl -> get_LocaleID(This,plcidLocaleID) -#define IAxWinAmbientDispatchEx_put_UserMode(This,bUserMode) \ - (This)->lpVtbl -> put_UserMode(This,bUserMode) +#define IAxWinAmbientDispatchEx_put_UserMode(This,bUserMode) \ + (This)->lpVtbl -> put_UserMode(This,bUserMode) -#define IAxWinAmbientDispatchEx_get_UserMode(This,pbUserMode) \ - (This)->lpVtbl -> get_UserMode(This,pbUserMode) +#define IAxWinAmbientDispatchEx_get_UserMode(This,pbUserMode) \ + (This)->lpVtbl -> get_UserMode(This,pbUserMode) -#define IAxWinAmbientDispatchEx_put_DisplayAsDefault(This,bDisplayAsDefault) \ - (This)->lpVtbl -> put_DisplayAsDefault(This,bDisplayAsDefault) +#define IAxWinAmbientDispatchEx_put_DisplayAsDefault(This,bDisplayAsDefault) \ + (This)->lpVtbl -> put_DisplayAsDefault(This,bDisplayAsDefault) -#define IAxWinAmbientDispatchEx_get_DisplayAsDefault(This,pbDisplayAsDefault) \ - (This)->lpVtbl -> get_DisplayAsDefault(This,pbDisplayAsDefault) +#define IAxWinAmbientDispatchEx_get_DisplayAsDefault(This,pbDisplayAsDefault) \ + (This)->lpVtbl -> get_DisplayAsDefault(This,pbDisplayAsDefault) -#define IAxWinAmbientDispatchEx_put_Font(This,pFont) \ - (This)->lpVtbl -> put_Font(This,pFont) +#define IAxWinAmbientDispatchEx_put_Font(This,pFont) \ + (This)->lpVtbl -> put_Font(This,pFont) -#define IAxWinAmbientDispatchEx_get_Font(This,pFont) \ - (This)->lpVtbl -> get_Font(This,pFont) +#define IAxWinAmbientDispatchEx_get_Font(This,pFont) \ + (This)->lpVtbl -> get_Font(This,pFont) -#define IAxWinAmbientDispatchEx_put_MessageReflect(This,bMsgReflect) \ - (This)->lpVtbl -> put_MessageReflect(This,bMsgReflect) +#define IAxWinAmbientDispatchEx_put_MessageReflect(This,bMsgReflect) \ + (This)->lpVtbl -> put_MessageReflect(This,bMsgReflect) -#define IAxWinAmbientDispatchEx_get_MessageReflect(This,pbMsgReflect) \ - (This)->lpVtbl -> get_MessageReflect(This,pbMsgReflect) +#define IAxWinAmbientDispatchEx_get_MessageReflect(This,pbMsgReflect) \ + (This)->lpVtbl -> get_MessageReflect(This,pbMsgReflect) -#define IAxWinAmbientDispatchEx_get_ShowGrabHandles(This,pbShowGrabHandles) \ - (This)->lpVtbl -> get_ShowGrabHandles(This,pbShowGrabHandles) +#define IAxWinAmbientDispatchEx_get_ShowGrabHandles(This,pbShowGrabHandles) \ + (This)->lpVtbl -> get_ShowGrabHandles(This,pbShowGrabHandles) -#define IAxWinAmbientDispatchEx_get_ShowHatching(This,pbShowHatching) \ - (This)->lpVtbl -> get_ShowHatching(This,pbShowHatching) +#define IAxWinAmbientDispatchEx_get_ShowHatching(This,pbShowHatching) \ + (This)->lpVtbl -> get_ShowHatching(This,pbShowHatching) -#define IAxWinAmbientDispatchEx_put_DocHostFlags(This,dwDocHostFlags) \ - (This)->lpVtbl -> put_DocHostFlags(This,dwDocHostFlags) +#define IAxWinAmbientDispatchEx_put_DocHostFlags(This,dwDocHostFlags) \ + (This)->lpVtbl -> put_DocHostFlags(This,dwDocHostFlags) -#define IAxWinAmbientDispatchEx_get_DocHostFlags(This,pdwDocHostFlags) \ - (This)->lpVtbl -> get_DocHostFlags(This,pdwDocHostFlags) +#define IAxWinAmbientDispatchEx_get_DocHostFlags(This,pdwDocHostFlags) \ + (This)->lpVtbl -> get_DocHostFlags(This,pdwDocHostFlags) -#define IAxWinAmbientDispatchEx_put_DocHostDoubleClickFlags(This,dwDocHostDoubleClickFlags) \ - (This)->lpVtbl -> put_DocHostDoubleClickFlags(This,dwDocHostDoubleClickFlags) +#define IAxWinAmbientDispatchEx_put_DocHostDoubleClickFlags(This,dwDocHostDoubleClickFlags) \ + (This)->lpVtbl -> put_DocHostDoubleClickFlags(This,dwDocHostDoubleClickFlags) -#define IAxWinAmbientDispatchEx_get_DocHostDoubleClickFlags(This,pdwDocHostDoubleClickFlags) \ - (This)->lpVtbl -> get_DocHostDoubleClickFlags(This,pdwDocHostDoubleClickFlags) +#define IAxWinAmbientDispatchEx_get_DocHostDoubleClickFlags(This,pdwDocHostDoubleClickFlags) \ + (This)->lpVtbl -> get_DocHostDoubleClickFlags(This,pdwDocHostDoubleClickFlags) -#define IAxWinAmbientDispatchEx_put_AllowContextMenu(This,bAllowContextMenu) \ - (This)->lpVtbl -> put_AllowContextMenu(This,bAllowContextMenu) +#define IAxWinAmbientDispatchEx_put_AllowContextMenu(This,bAllowContextMenu) \ + (This)->lpVtbl -> put_AllowContextMenu(This,bAllowContextMenu) -#define IAxWinAmbientDispatchEx_get_AllowContextMenu(This,pbAllowContextMenu) \ - (This)->lpVtbl -> get_AllowContextMenu(This,pbAllowContextMenu) +#define IAxWinAmbientDispatchEx_get_AllowContextMenu(This,pbAllowContextMenu) \ + (This)->lpVtbl -> get_AllowContextMenu(This,pbAllowContextMenu) -#define IAxWinAmbientDispatchEx_put_AllowShowUI(This,bAllowShowUI) \ - (This)->lpVtbl -> put_AllowShowUI(This,bAllowShowUI) +#define IAxWinAmbientDispatchEx_put_AllowShowUI(This,bAllowShowUI) \ + (This)->lpVtbl -> put_AllowShowUI(This,bAllowShowUI) -#define IAxWinAmbientDispatchEx_get_AllowShowUI(This,pbAllowShowUI) \ - (This)->lpVtbl -> get_AllowShowUI(This,pbAllowShowUI) +#define IAxWinAmbientDispatchEx_get_AllowShowUI(This,pbAllowShowUI) \ + (This)->lpVtbl -> get_AllowShowUI(This,pbAllowShowUI) -#define IAxWinAmbientDispatchEx_put_OptionKeyPath(This,bstrOptionKeyPath) \ - (This)->lpVtbl -> put_OptionKeyPath(This,bstrOptionKeyPath) +#define IAxWinAmbientDispatchEx_put_OptionKeyPath(This,bstrOptionKeyPath) \ + (This)->lpVtbl -> put_OptionKeyPath(This,bstrOptionKeyPath) -#define IAxWinAmbientDispatchEx_get_OptionKeyPath(This,pbstrOptionKeyPath) \ - (This)->lpVtbl -> get_OptionKeyPath(This,pbstrOptionKeyPath) +#define IAxWinAmbientDispatchEx_get_OptionKeyPath(This,pbstrOptionKeyPath) \ + (This)->lpVtbl -> get_OptionKeyPath(This,pbstrOptionKeyPath) -#define IAxWinAmbientDispatchEx_SetAmbientDispatch(This,pDispatch) \ - (This)->lpVtbl -> SetAmbientDispatch(This,pDispatch) +#define IAxWinAmbientDispatchEx_SetAmbientDispatch(This,pDispatch) \ + (This)->lpVtbl -> SetAmbientDispatch(This,pDispatch) #endif /* COBJMACROS */ -#endif /* C style interface */ +#endif /* C style interface */ /* [id] */ HRESULT STDMETHODCALLTYPE IAxWinAmbientDispatchEx_SetAmbientDispatch_Proxy( - IAxWinAmbientDispatchEx * This, - /* [in] */ IDispatch *pDispatch); + IAxWinAmbientDispatchEx * This, + /* [in] */ IDispatch *pDispatch); void __RPC_STUB IAxWinAmbientDispatchEx_SetAmbientDispatch_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); -#endif /* __IAxWinAmbientDispatchEx_INTERFACE_DEFINED__ */ +#endif /* __IAxWinAmbientDispatchEx_INTERFACE_DEFINED__ */ #ifndef __IInternalConnection_INTERFACE_DEFINED__ @@ -2544,93 +2544,93 @@ EXTERN_C const IID IID_IInternalConnection; #if defined(__cplusplus) && !defined(CINTERFACE) - MIDL_INTERFACE("72AD0770-6A9F-11d1-BCEC-0060088F444E") - IInternalConnection : public IUnknown - { - public: - virtual HRESULT STDMETHODCALLTYPE AddConnection( void) = 0; + MIDL_INTERFACE("72AD0770-6A9F-11d1-BCEC-0060088F444E") + IInternalConnection : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE AddConnection( void) = 0; - virtual HRESULT STDMETHODCALLTYPE ReleaseConnection( void) = 0; + virtual HRESULT STDMETHODCALLTYPE ReleaseConnection( void) = 0; - }; + }; -#else /* C style interface */ +#else /* C style interface */ - typedef struct IInternalConnectionVtbl - { - BEGIN_INTERFACE + typedef struct IInternalConnectionVtbl + { + BEGIN_INTERFACE - HRESULT ( STDMETHODCALLTYPE *QueryInterface )( - IInternalConnection * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void **ppvObject); + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + IInternalConnection * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void **ppvObject); - ULONG ( STDMETHODCALLTYPE *AddRef )( - IInternalConnection * This); + ULONG ( STDMETHODCALLTYPE *AddRef )( + IInternalConnection * This); - ULONG ( STDMETHODCALLTYPE *Release )( - IInternalConnection * This); + ULONG ( STDMETHODCALLTYPE *Release )( + IInternalConnection * This); - HRESULT ( STDMETHODCALLTYPE *AddConnection )( - IInternalConnection * This); + HRESULT ( STDMETHODCALLTYPE *AddConnection )( + IInternalConnection * This); - HRESULT ( STDMETHODCALLTYPE *ReleaseConnection )( - IInternalConnection * This); + HRESULT ( STDMETHODCALLTYPE *ReleaseConnection )( + IInternalConnection * This); - END_INTERFACE - } IInternalConnectionVtbl; + END_INTERFACE + } IInternalConnectionVtbl; - interface IInternalConnection - { - CONST_VTBL struct IInternalConnectionVtbl *lpVtbl; - }; + interface IInternalConnection + { + CONST_VTBL struct IInternalConnectionVtbl *lpVtbl; + }; #ifdef COBJMACROS -#define IInternalConnection_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) +#define IInternalConnection_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) -#define IInternalConnection_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) +#define IInternalConnection_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) -#define IInternalConnection_Release(This) \ - (This)->lpVtbl -> Release(This) +#define IInternalConnection_Release(This) \ + (This)->lpVtbl -> Release(This) -#define IInternalConnection_AddConnection(This) \ - (This)->lpVtbl -> AddConnection(This) +#define IInternalConnection_AddConnection(This) \ + (This)->lpVtbl -> AddConnection(This) -#define IInternalConnection_ReleaseConnection(This) \ - (This)->lpVtbl -> ReleaseConnection(This) +#define IInternalConnection_ReleaseConnection(This) \ + (This)->lpVtbl -> ReleaseConnection(This) #endif /* COBJMACROS */ -#endif /* C style interface */ +#endif /* C style interface */ HRESULT STDMETHODCALLTYPE IInternalConnection_AddConnection_Proxy( - IInternalConnection * This); + IInternalConnection * This); void __RPC_STUB IInternalConnection_AddConnection_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); HRESULT STDMETHODCALLTYPE IInternalConnection_ReleaseConnection_Proxy( - IInternalConnection * This); + IInternalConnection * This); void __RPC_STUB IInternalConnection_ReleaseConnection_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); -#endif /* __IInternalConnection_INTERFACE_DEFINED__ */ +#endif /* __IInternalConnection_INTERFACE_DEFINED__ */ /* interface __MIDL_itf_atliface_0257 */ @@ -2646,21 +2646,21 @@ namespace ATL #define ATLAPI EXTERN_C HRESULT __declspec(dllimport) __stdcall #define ATLAPI_(x) EXTERN_C __declspec(dllimport) x __stdcall #define ATLINLINE -#endif // __cplusplus +#endif // __cplusplus ATLAPI_(INT_PTR) AtlAxDialogBoxW( - _In_ HINSTANCE hInstance, - _In_z_ LPCWSTR lpTemplateName, - _In_ HWND hWndParent, - _In_ DLGPROC lpDialogProc, - _In_ LPARAM dwInitParam); + _In_ HINSTANCE hInstance, + _In_z_ LPCWSTR lpTemplateName, + _In_ HWND hWndParent, + _In_ DLGPROC lpDialogProc, + _In_ LPARAM dwInitParam); ATLAPI_(INT_PTR) AtlAxDialogBoxA( - _In_ HINSTANCE hInstance, - _In_z_ LPCSTR lpTemplateName, - _In_ HWND hWndParent, - _In_ DLGPROC lpDialogProc, - _In_ LPARAM dwInitParam); + _In_ HINSTANCE hInstance, + _In_z_ LPCSTR lpTemplateName, + _In_ HWND hWndParent, + _In_ DLGPROC lpDialogProc, + _In_ LPARAM dwInitParam); #ifdef UNICODE #define AtlAxDialogBox AtlAxDialogBoxW @@ -2669,18 +2669,18 @@ ATLAPI_(INT_PTR) AtlAxDialogBoxA( #endif ATLAPI_(HWND) AtlAxCreateDialogW( - _In_ HINSTANCE hInstance, - _In_z_ LPCWSTR lpTemplateName, - _In_ HWND hWndParent, - _In_ DLGPROC lpDialogProc, - _In_ LPARAM dwInitParam); + _In_ HINSTANCE hInstance, + _In_z_ LPCWSTR lpTemplateName, + _In_ HWND hWndParent, + _In_ DLGPROC lpDialogProc, + _In_ LPARAM dwInitParam); ATLAPI_(HWND) AtlAxCreateDialogA( - _In_ HINSTANCE hInstance, - _In_z_ LPCSTR lpTemplateName, - _In_ HWND hWndParent, - _In_ DLGPROC lpDialogProc, - _In_ LPARAM dwInitParam); + _In_ HINSTANCE hInstance, + _In_z_ LPCSTR lpTemplateName, + _In_ HWND hWndParent, + _In_ DLGPROC lpDialogProc, + _In_ LPARAM dwInitParam); #ifdef UNICODE #define AtlAxCreateDialog AtlAxCreateDialogW @@ -2689,83 +2689,83 @@ ATLAPI_(HWND) AtlAxCreateDialogA( #endif ATLAPI AtlAxCreateControl( - _In_z_ LPCOLESTR lpszName, - _In_ HWND hWnd, - _Inout_opt_ IStream* pStream, - _Deref_out_ IUnknown** ppUnkContainer); + _In_z_ LPCOLESTR lpszName, + _In_ HWND hWnd, + _Inout_opt_ IStream* pStream, + _Deref_out_ IUnknown** ppUnkContainer); #ifdef __cplusplus ATLAPI AtlAxCreateControlEx( - _In_z_ LPCOLESTR lpszName, - _In_ HWND hWnd, - _Inout_opt_ IStream* pStream, - _Deref_opt_out_ IUnknown** ppUnkContainer, - _Deref_opt_out_ IUnknown** ppUnkControl, - _In_ REFIID iidSink=IID_NULL, - _Inout_opt_ IUnknown* punkSink=NULL); + _In_z_ LPCOLESTR lpszName, + _In_ HWND hWnd, + _Inout_opt_ IStream* pStream, + _Deref_opt_out_ IUnknown** ppUnkContainer, + _Deref_opt_out_ IUnknown** ppUnkControl, + _In_ REFIID iidSink=IID_NULL, + _Inout_opt_ IUnknown* punkSink=NULL); ATLAPI AtlAxCreateControlLic( - _In_z_ LPCOLESTR lpszName, - _In_ HWND hWnd, - _Inout_opt_ IStream* pStream, - _Deref_opt_out_ IUnknown** ppUnkContainer, - _In_opt_z_ BSTR bstrLic = NULL); + _In_z_ LPCOLESTR lpszName, + _In_ HWND hWnd, + _Inout_opt_ IStream* pStream, + _Deref_opt_out_ IUnknown** ppUnkContainer, + _In_opt_z_ BSTR bstrLic = NULL); ATLAPI AtlAxCreateControlLicEx( - _In_z_ LPCOLESTR lpszName, - _In_ HWND hWnd, - _Inout_opt_ IStream* pStream, - _Deref_opt_out_ IUnknown** ppUnkContainer, - _Deref_opt_out_ IUnknown** ppUnkControl, - _In_ REFIID iidSink=IID_NULL, - _Inout_opt_ IUnknown* punkSink=NULL, - _In_opt_z_ BSTR bstrLic = NULL); + _In_z_ LPCOLESTR lpszName, + _In_ HWND hWnd, + _Inout_opt_ IStream* pStream, + _Deref_opt_out_ IUnknown** ppUnkContainer, + _Deref_opt_out_ IUnknown** ppUnkControl, + _In_ REFIID iidSink=IID_NULL, + _Inout_opt_ IUnknown* punkSink=NULL, + _In_opt_z_ BSTR bstrLic = NULL); #else ATLAPI AtlAxCreateControlEx( - _In_z_ LPCOLESTR lpszName, - _In_ HWND hWnd, - _Inout_opt_ IStream* pStream, - _Deref_opt_out_ IUnknown** ppUnkContainer, - _Deref_opt_out_ IUnknown** ppUnkControl, - _In_ REFIID iidSink, - _Inout_opt_ IUnknown* punkSink); + _In_z_ LPCOLESTR lpszName, + _In_ HWND hWnd, + _Inout_opt_ IStream* pStream, + _Deref_opt_out_ IUnknown** ppUnkContainer, + _Deref_opt_out_ IUnknown** ppUnkControl, + _In_ REFIID iidSink, + _Inout_opt_ IUnknown* punkSink); ATLAPI AtlAxCreateControlLic( - _In_z_ LPCOLESTR lpszName, - _In_ HWND hWnd, - _Inout_opt_ IStream* pStream, - _Deref_opt_out_ IUnknown** ppUnkContainer, - _In_opt_z_ BSTR bstrLic); + _In_z_ LPCOLESTR lpszName, + _In_ HWND hWnd, + _Inout_opt_ IStream* pStream, + _Deref_opt_out_ IUnknown** ppUnkContainer, + _In_opt_z_ BSTR bstrLic); ATLAPI AtlAxCreateControlLicEx( - _In_z_ LPCOLESTR lpszName, - _Inout_ HWND hWnd, - _In_opt_ IStream* pStream, - _Deref_opt_out_ IUnknown** ppUnkContainer, - _Deref_opt_out_ IUnknown** ppUnkControl, - _In_ REFIID iidSink, - _Inout_opt_ IUnknown* punkSink, - _In_opt_z_ BSTR bstrLic); - -#endif // __cplusplus - + _In_z_ LPCOLESTR lpszName, + _Inout_ HWND hWnd, + _In_opt_ IStream* pStream, + _Deref_opt_out_ IUnknown** ppUnkContainer, + _Deref_opt_out_ IUnknown** ppUnkControl, + _In_ REFIID iidSink, + _Inout_opt_ IUnknown* punkSink, + _In_opt_z_ BSTR bstrLic); + +#endif // __cplusplus + ATLAPI AtlAxAttachControl( - _Inout_ IUnknown* pControl, - _In_ HWND hWnd, - _Deref_opt_out_ IUnknown** ppUnkContainer); + _Inout_ IUnknown* pControl, + _In_ HWND hWnd, + _Deref_opt_out_ IUnknown** ppUnkContainer); ATLAPI_(BOOL) AtlAxWinInit(); ATLAPI AtlAxGetHost( - _In_ HWND h, - _Deref_out_ IUnknown** pp); + _In_ HWND h, + _Deref_out_ IUnknown** pp); ATLAPI AtlAxGetControl( - _In_ HWND h, - _Deref_out_ IUnknown** pp); + _In_ HWND h, + _Deref_out_ IUnknown** pp); }; //namespace ATL #pragma pack(pop) diff --git a/src/main/headers/atlsimpcoll.h b/src/main/headers/atlsimpcoll.h index b89dc75..780fa00 100644 --- a/src/main/headers/atlsimpcoll.h +++ b/src/main/headers/atlsimpcoll.h @@ -49,64 +49,64 @@ template class CSimpleArrayEqualHelper { public: - static bool IsEqual( - _In_ const T& t1, - _In_ const T& t2) - { - return (t1 == t2); - } + static bool IsEqual( + _In_ const T& t1, + _In_ const T& t2) + { + return (t1 == t2); + } }; template class CSimpleArrayEqualHelperFalse { public: - static bool IsEqual( - _In_ const T&, - _In_ const T&) - { - ATLASSERT(false); - return false; - } + static bool IsEqual( + _In_ const T&, + _In_ const T&) + { + ATLASSERT(false); + return false; + } }; template class CSimpleMapEqualHelper { public: - static bool IsEqualKey( - _In_ const TKey& k1, - _In_ const TKey& k2) - { - return CSimpleArrayEqualHelper::IsEqual(k1, k2); - } + static bool IsEqualKey( + _In_ const TKey& k1, + _In_ const TKey& k2) + { + return CSimpleArrayEqualHelper::IsEqual(k1, k2); + } - static bool IsEqualValue( - _In_ const TVal& v1, - _In_ const TVal& v2) - { - return CSimpleArrayEqualHelper::IsEqual(v1, v2); - } + static bool IsEqualValue( + _In_ const TVal& v1, + _In_ const TVal& v2) + { + return CSimpleArrayEqualHelper::IsEqual(v1, v2); + } }; template class CSimpleMapEqualHelperFalse { public: - static bool IsEqualKey( - _In_ const TKey& k1, - _In_ const TKey& k2) - { - return CSimpleArrayEqualHelper::IsEqual(k1, k2); - } + static bool IsEqualKey( + _In_ const TKey& k1, + _In_ const TKey& k2) + { + return CSimpleArrayEqualHelper::IsEqual(k1, k2); + } - static bool IsEqualValue( - _In_ const TVal&, - _In_ const TVal&) - { - ATLASSERT(FALSE); - return false; - } + static bool IsEqualValue( + _In_ const TVal&, + _In_ const TVal&) + { + ATLASSERT(FALSE); + return false; + } }; template > @@ -114,193 +114,193 @@ class CSimpleArray { public: // Construction/destruction - CSimpleArray() : - m_aT(NULL), m_nSize(0), m_nAllocSize(0) - { - } + CSimpleArray() : + m_aT(NULL), m_nSize(0), m_nAllocSize(0) + { + } - ~CSimpleArray(); + ~CSimpleArray(); - CSimpleArray(_In_ const CSimpleArray< T, TEqual >& src) : - m_aT(NULL), m_nSize(0), m_nAllocSize(0) - { + CSimpleArray(_In_ const CSimpleArray< T, TEqual >& src) : + m_aT(NULL), m_nSize(0), m_nAllocSize(0) + { if (src.GetSize()) { - m_aT = (T*)nb_calloc(src.GetSize(), sizeof(T)); - if (m_aT != NULL) - { - m_nAllocSize = src.GetSize(); - for (int i=0; i& operator=(_In_ const CSimpleArray< T, TEqual >& src) - { - if (GetSize() != src.GetSize()) - { - RemoveAll(); - m_aT = (T*)nb_calloc(src.GetSize(), sizeof(T)); - if (m_aT != NULL) - m_nAllocSize = src.GetSize(); - } - else - { - for (int i = GetSize(); i > 0; i--) - RemoveAt(i - 1); - } - for (int i=0; i& operator=(_In_ const CSimpleArray< T, TEqual >& src) + { + if (GetSize() != src.GetSize()) + { + RemoveAll(); + m_aT = (T*)nb_calloc(src.GetSize(), sizeof(T)); + if (m_aT != NULL) + m_nAllocSize = src.GetSize(); + } + else + { + for (int i = GetSize(); i > 0; i--) + RemoveAt(i - 1); + } + for (int i=0; i= (m_aT + m_nAllocSize) ) ); - - T* aT; - int nNewAllocSize = (m_nAllocSize == 0) ? 1 : (m_nSize * 2); - - if (nNewAllocSize<0||nNewAllocSize>INT_MAX/sizeof(T)) - { - return FALSE; - } - - aT = (T*)_recalloc(m_aT, nNewAllocSize, sizeof(T)); - if(aT == NULL) - return FALSE; - m_nAllocSize = nNewAllocSize; - m_aT = aT; - } - InternalSetAtIndex(m_nSize, t); - m_nSize++; - return TRUE; - } - BOOL Remove(_In_ const T& t) - { - int nIndex = Find(t); - if(nIndex == -1) - return FALSE; - return RemoveAt(nIndex); - } - BOOL RemoveAt(_In_ int nIndex) - { - ATLASSERT(nIndex >= 0 && nIndex < m_nSize); - if (nIndex < 0 || nIndex >= m_nSize) - return FALSE; - m_aT[nIndex].~T(); - if(nIndex != (m_nSize - 1)) - Checked::memmove_s((void*)(m_aT + nIndex), (m_nSize - nIndex) * sizeof(T), (void*)(m_aT + nIndex + 1), (m_nSize - (nIndex + 1)) * sizeof(T)); - m_nSize--; - return TRUE; - } - void RemoveAll() - { - if(m_aT != NULL) - { - for(int i = 0; i < m_nSize; i++) - m_aT[i].~T(); - nb_free(m_aT); - m_aT = NULL; - } - m_nSize = 0; - m_nAllocSize = 0; + int GetSize() const + { + return m_nSize; } - const T& operator[] (_In_ int nIndex) const - { - ATLASSERT(nIndex >= 0 && nIndex < m_nSize); - if(nIndex < 0 || nIndex >= m_nSize) - { - _AtlRaiseException((DWORD)EXCEPTION_ARRAY_BOUNDS_EXCEEDED); - } - return m_aT[nIndex]; - } - T& operator[] (_In_ int nIndex) - { - ATLASSERT(nIndex >= 0 && nIndex < m_nSize); - if(nIndex < 0 || nIndex >= m_nSize) - { - _AtlRaiseException((DWORD)EXCEPTION_ARRAY_BOUNDS_EXCEEDED); - } - return m_aT[nIndex]; - } - T* GetData() const - { - return m_aT; - } + BOOL Add(_In_ const T& t) + { + if(m_nSize == m_nAllocSize) + { + // Make sure newElement is not a reference to an element in the array. + // Or else, it will be invalidated by the reallocation. + ATLENSURE( (&t < m_aT) || + (&t >= (m_aT + m_nAllocSize) ) ); - int Find(_In_ const T& t) const - { - for(int i = 0; i < m_nSize; i++) - { - if(TEqual::IsEqual(m_aT[i], t)) - return i; - } - return -1; // not found - } + T* aT; + int nNewAllocSize = (m_nAllocSize == 0) ? 1 : (m_nSize * 2); - BOOL SetAtIndex( - _In_ int nIndex, - _In_ const T& t) - { - if (nIndex < 0 || nIndex >= m_nSize) - return FALSE; - InternalSetAtIndex(nIndex, t); - return TRUE; - } + if (nNewAllocSize<0||nNewAllocSize>INT_MAX/sizeof(T)) + { + return FALSE; + } + + aT = (T*)_recalloc(m_aT, nNewAllocSize, sizeof(T)); + if(aT == NULL) + return FALSE; + m_nAllocSize = nNewAllocSize; + m_aT = aT; + } + InternalSetAtIndex(m_nSize, t); + m_nSize++; + return TRUE; + } + BOOL Remove(_In_ const T& t) + { + int nIndex = Find(t); + if(nIndex == -1) + return FALSE; + return RemoveAt(nIndex); + } + BOOL RemoveAt(_In_ int nIndex) + { + ATLASSERT(nIndex >= 0 && nIndex < m_nSize); + if (nIndex < 0 || nIndex >= m_nSize) + return FALSE; + m_aT[nIndex].~T(); + if(nIndex != (m_nSize - 1)) + Checked::memmove_s((void*)(m_aT + nIndex), (m_nSize - nIndex) * sizeof(T), (void*)(m_aT + nIndex + 1), (m_nSize - (nIndex + 1)) * sizeof(T)); + m_nSize--; + return TRUE; + } + void RemoveAll() + { + if(m_aT != NULL) + { + for(int i = 0; i < m_nSize; i++) + m_aT[i].~T(); + nb_free(m_aT); + m_aT = NULL; + } + m_nSize = 0; + m_nAllocSize = 0; + } + const T& operator[] (_In_ int nIndex) const + { + ATLASSERT(nIndex >= 0 && nIndex < m_nSize); + if(nIndex < 0 || nIndex >= m_nSize) + { + _AtlRaiseException((DWORD)EXCEPTION_ARRAY_BOUNDS_EXCEEDED); + } + return m_aT[nIndex]; + } + T& operator[] (_In_ int nIndex) + { + ATLASSERT(nIndex >= 0 && nIndex < m_nSize); + if(nIndex < 0 || nIndex >= m_nSize) + { + _AtlRaiseException((DWORD)EXCEPTION_ARRAY_BOUNDS_EXCEEDED); + } + return m_aT[nIndex]; + } + T* GetData() const + { + return m_aT; + } + + int Find(_In_ const T& t) const + { + for(int i = 0; i < m_nSize; i++) + { + if(TEqual::IsEqual(m_aT[i], t)) + return i; + } + return -1; // not found + } + + BOOL SetAtIndex( + _In_ int nIndex, + _In_ const T& t) + { + if (nIndex < 0 || nIndex >= m_nSize) + return FALSE; + InternalSetAtIndex(nIndex, t); + return TRUE; + } // Implementation - class Wrapper - { - public: - Wrapper(_In_ const T& _t) : t(_t) - { - } - template - void * __cdecl operator new( - _In_ size_t, - _In_ _Ty* p) - { - return p; - } - template - void __cdecl operator delete( - _In_ void* /* pv */, - _In_ _Ty* /* p */) - { - } - T t; - }; + class Wrapper + { + public: + Wrapper(_In_ const T& _t) : t(_t) + { + } + template + void * __cdecl operator new( + _In_ size_t, + _In_ _Ty* p) + { + return p; + } + template + void __cdecl operator delete( + _In_ void* /* pv */, + _In_ _Ty* /* p */) + { + } + T t; + }; // Implementation - void InternalSetAtIndex( - _In_ int nIndex, - _In_ const T& t) - { - new(m_aT + nIndex) Wrapper(t); - } + void InternalSetAtIndex( + _In_ int nIndex, + _In_ const T& t) + { + new(m_aT + nIndex) Wrapper(t); + } - typedef T _ArrayElementType; - T* m_aT; - int m_nSize; - int m_nAllocSize; + typedef T _ArrayElementType; + T* m_aT; + int m_nSize; + int m_nAllocSize; }; #define CSimpleValArray CSimpleArray template inline CSimpleArray::~CSimpleArray() { - RemoveAll(); + RemoveAll(); } // intended for small number of simple types or pointers @@ -308,204 +308,204 @@ template = 0 && nIndex < m_nSize); - if (nIndex < 0 || nIndex >= m_nSize) - return FALSE; - m_aKey[nIndex].~TKey(); - m_aVal[nIndex].~TVal(); - if(nIndex != (m_nSize - 1)) - { - Checked::memmove_s((void*)(m_aKey + nIndex), (m_nSize - nIndex) * sizeof(TKey), (void*)(m_aKey + nIndex + 1), (m_nSize - (nIndex + 1)) * sizeof(TKey)); - Checked::memmove_s((void*)(m_aVal + nIndex), (m_nSize - nIndex) * sizeof(TVal), (void*)(m_aVal + nIndex + 1), (m_nSize - (nIndex + 1)) * sizeof(TVal)); - } - TKey* pKey; - pKey = (TKey*)_recalloc(m_aKey, (m_nSize - 1), sizeof(TKey)); - if(pKey != NULL || m_nSize == 1) - m_aKey = pKey; - TVal* pVal; - pVal = (TVal*)_recalloc(m_aVal, (m_nSize - 1), sizeof(TVal)); - if(pVal != NULL || m_nSize == 1) - m_aVal = pVal; - m_nSize--; - return TRUE; - } - void RemoveAll() - { - if(m_aKey != NULL) - { - for(int i = 0; i < m_nSize; i++) - { - m_aKey[i].~TKey(); - m_aVal[i].~TVal(); - } - nb_free(m_aKey); - m_aKey = NULL; - } - if(m_aVal != NULL) - { - nb_free(m_aVal); - m_aVal = NULL; - } + int GetSize() const + { + return m_nSize; + } + BOOL Add( + _In_ const TKey& key, + _In_ const TVal& val) + { + TKey* pKey; + pKey = (TKey*)_recalloc(m_aKey, (m_nSize + 1), sizeof(TKey)); + if(pKey == NULL) + return FALSE; + m_aKey = pKey; + TVal* pVal; + pVal = (TVal*)_recalloc(m_aVal, (m_nSize + 1), sizeof(TVal)); + if(pVal == NULL) + return FALSE; + m_aVal = pVal; + InternalSetAtIndex(m_nSize, key, val); + m_nSize++; + return TRUE; + } + BOOL Remove(_In_ const TKey& key) + { + int nIndex = FindKey(key); + if(nIndex == -1) + return FALSE; + return RemoveAt(nIndex); + } + BOOL RemoveAt(_In_ int nIndex) + { + ATLASSERT(nIndex >= 0 && nIndex < m_nSize); + if (nIndex < 0 || nIndex >= m_nSize) + return FALSE; + m_aKey[nIndex].~TKey(); + m_aVal[nIndex].~TVal(); + if(nIndex != (m_nSize - 1)) + { + Checked::memmove_s((void*)(m_aKey + nIndex), (m_nSize - nIndex) * sizeof(TKey), (void*)(m_aKey + nIndex + 1), (m_nSize - (nIndex + 1)) * sizeof(TKey)); + Checked::memmove_s((void*)(m_aVal + nIndex), (m_nSize - nIndex) * sizeof(TVal), (void*)(m_aVal + nIndex + 1), (m_nSize - (nIndex + 1)) * sizeof(TVal)); + } + TKey* pKey; + pKey = (TKey*)_recalloc(m_aKey, (m_nSize - 1), sizeof(TKey)); + if(pKey != NULL || m_nSize == 1) + m_aKey = pKey; + TVal* pVal; + pVal = (TVal*)_recalloc(m_aVal, (m_nSize - 1), sizeof(TVal)); + if(pVal != NULL || m_nSize == 1) + m_aVal = pVal; + m_nSize--; + return TRUE; + } + void RemoveAll() + { + if(m_aKey != NULL) + { + for(int i = 0; i < m_nSize; i++) + { + m_aKey[i].~TKey(); + m_aVal[i].~TVal(); + } + nb_free(m_aKey); + m_aKey = NULL; + } + if(m_aVal != NULL) + { + nb_free(m_aVal); + m_aVal = NULL; + } - m_nSize = 0; - } - BOOL SetAt( - _In_ const TKey& key, - _In_ const TVal& val) - { - int nIndex = FindKey(key); - if(nIndex == -1) - return FALSE; - ATLASSERT(nIndex >= 0 && nIndex < m_nSize); - m_aKey[nIndex].~TKey(); - m_aVal[nIndex].~TVal(); - InternalSetAtIndex(nIndex, key, val); - return TRUE; - } - TVal Lookup(_In_ const TKey& key) const - { - int nIndex = FindKey(key); - if(nIndex == -1) - return NULL; // must be able to convert - return GetValueAt(nIndex); - } - TKey ReverseLookup(_In_ const TVal& val) const - { - int nIndex = FindVal(val); - if(nIndex == -1) - return NULL; // must be able to convert - return GetKeyAt(nIndex); - } - TKey& GetKeyAt(_In_ int nIndex) const - { - ATLASSERT(nIndex >= 0 && nIndex < m_nSize); - if(nIndex < 0 || nIndex >= m_nSize) - _AtlRaiseException((DWORD)EXCEPTION_ARRAY_BOUNDS_EXCEEDED); + m_nSize = 0; + } + BOOL SetAt( + _In_ const TKey& key, + _In_ const TVal& val) + { + int nIndex = FindKey(key); + if(nIndex == -1) + return FALSE; + ATLASSERT(nIndex >= 0 && nIndex < m_nSize); + m_aKey[nIndex].~TKey(); + m_aVal[nIndex].~TVal(); + InternalSetAtIndex(nIndex, key, val); + return TRUE; + } + TVal Lookup(_In_ const TKey& key) const + { + int nIndex = FindKey(key); + if(nIndex == -1) + return NULL; // must be able to convert + return GetValueAt(nIndex); + } + TKey ReverseLookup(_In_ const TVal& val) const + { + int nIndex = FindVal(val); + if(nIndex == -1) + return NULL; // must be able to convert + return GetKeyAt(nIndex); + } + TKey& GetKeyAt(_In_ int nIndex) const + { + ATLASSERT(nIndex >= 0 && nIndex < m_nSize); + if(nIndex < 0 || nIndex >= m_nSize) + _AtlRaiseException((DWORD)EXCEPTION_ARRAY_BOUNDS_EXCEEDED); - return m_aKey[nIndex]; - } - TVal& GetValueAt(_In_ int nIndex) const - { - ATLASSERT(nIndex >= 0 && nIndex < m_nSize); - if(nIndex < 0 || nIndex >= m_nSize) - _AtlRaiseException((DWORD)EXCEPTION_ARRAY_BOUNDS_EXCEEDED); + return m_aKey[nIndex]; + } + TVal& GetValueAt(_In_ int nIndex) const + { + ATLASSERT(nIndex >= 0 && nIndex < m_nSize); + if(nIndex < 0 || nIndex >= m_nSize) + _AtlRaiseException((DWORD)EXCEPTION_ARRAY_BOUNDS_EXCEEDED); - return m_aVal[nIndex]; - } + return m_aVal[nIndex]; + } - int FindKey(_In_ const TKey& key) const - { - for(int i = 0; i < m_nSize; i++) - { - if(TEqual::IsEqualKey(m_aKey[i], key)) - return i; - } - return -1; // not found - } - int FindVal(_In_ const TVal& val) const - { - for(int i = 0; i < m_nSize; i++) - { - if(TEqual::IsEqualValue(m_aVal[i], val)) - return i; - } - return -1; // not found - } + int FindKey(_In_ const TKey& key) const + { + for(int i = 0; i < m_nSize; i++) + { + if(TEqual::IsEqualKey(m_aKey[i], key)) + return i; + } + return -1; // not found + } + int FindVal(_In_ const TVal& val) const + { + for(int i = 0; i < m_nSize; i++) + { + if(TEqual::IsEqualValue(m_aVal[i], val)) + return i; + } + return -1; // not found + } - BOOL SetAtIndex( - _In_ int nIndex, - _In_ const TKey& key, - _In_ const TVal& val) - { - if (nIndex < 0 || nIndex >= m_nSize) - return FALSE; - InternalSetAtIndex(nIndex, key, val); - return TRUE; - } + BOOL SetAtIndex( + _In_ int nIndex, + _In_ const TKey& key, + _In_ const TVal& val) + { + if (nIndex < 0 || nIndex >= m_nSize) + return FALSE; + InternalSetAtIndex(nIndex, key, val); + return TRUE; + } // Implementation - template - class Wrapper - { - public: - Wrapper(_In_ const T& _t) : t(_t) - { - } - template - void *operator new( - _In_ size_t, - _In_ _Ty* p) - { - return p; - } - template - void operator delete( - _In_ void* /* pv */, - _In_ _Ty* /* p */) - { - } - T t; - }; - void InternalSetAtIndex( - _In_ int nIndex, - _In_ const TKey& key, - _In_ const TVal& val) - { - new(m_aKey + nIndex) Wrapper(key); - new(m_aVal + nIndex) Wrapper(val); - } + template + class Wrapper + { + public: + Wrapper(_In_ const T& _t) : t(_t) + { + } + template + void *operator new( + _In_ size_t, + _In_ _Ty* p) + { + return p; + } + template + void operator delete( + _In_ void* /* pv */, + _In_ _Ty* /* p */) + { + } + T t; + }; + void InternalSetAtIndex( + _In_ int nIndex, + _In_ const TKey& key, + _In_ const TVal& val) + { + new(m_aKey + nIndex) Wrapper(key); + new(m_aVal + nIndex) Wrapper(val); + } }; #pragma pop_macro("new") diff --git a/src/main/headers/statreg.h b/src/main/headers/statreg.h index 3afda41..f4ea09a 100644 --- a/src/main/headers/statreg.h +++ b/src/main/headers/statreg.h @@ -14,11 +14,11 @@ #pragma once #ifndef __cplusplus - #error ATL requires C++ compilation (use a .cpp suffix) + #error ATL requires C++ compilation (use a .cpp suffix) #endif #ifndef __ATLBASE_H__ - #error statreg.h requires atlbase.h to be included first + #error statreg.h requires atlbase.h to be included first #endif #pragma warning(push) @@ -70,85 +70,85 @@ const LPCTSTR szDelete = _T("Delete"); class CExpansionVectorEqualHelper { public: - static bool IsEqualKey( - _In_z_ const LPTSTR k1, - _In_z_ const LPTSTR k2) - { - if (lstrcmpi(k1, k2) == 0) - return true; - return false; - } + static bool IsEqualKey( + _In_z_ const LPTSTR k1, + _In_z_ const LPTSTR k2) + { + if (lstrcmpi(k1, k2) == 0) + return true; + return false; + } - // Not used - static bool IsEqualValue( - _In_opt_z_ const LPCOLESTR /*v1*/, - _In_opt_z_ const LPCOLESTR /*v2*/) - { - return false; - } + // Not used + static bool IsEqualValue( + _In_opt_z_ const LPCOLESTR /*v1*/, + _In_opt_z_ const LPCOLESTR /*v2*/) + { + return false; + } }; // Implementation helper class CExpansionVector : - public CSimpleMap + public CSimpleMap { public: - ~CExpansionVector() - { - ClearReplacements(); - } + ~CExpansionVector() + { + ClearReplacements(); + } - BOOL Add( - _In_z_ LPCTSTR lpszKey, - _In_z_ LPCOLESTR lpszValue) - { - ATLASSERT(lpszKey != NULL && lpszValue != NULL); - if (lpszKey == NULL || lpszValue == NULL) - return FALSE; + BOOL Add( + _In_z_ LPCTSTR lpszKey, + _In_z_ LPCOLESTR lpszValue) + { + ATLASSERT(lpszKey != NULL && lpszValue != NULL); + if (lpszKey == NULL || lpszValue == NULL) + return FALSE; - HRESULT hRes = S_OK; + HRESULT hRes = S_OK; - size_t cbKey = (lstrlen(lpszKey)+1)*sizeof(TCHAR); - TCHAR* szKey = NULL; + size_t cbKey = (lstrlen(lpszKey)+1)*sizeof(TCHAR); + TCHAR* szKey = NULL; - ATLTRY(szKey = new TCHAR[cbKey];) - CAutoVectorPtr spKey; - ATLASSUME(szKey != NULL); - spKey.Attach(szKey); + ATLTRY(szKey = new TCHAR[cbKey];) + CAutoVectorPtr spKey; + ATLASSUME(szKey != NULL); + spKey.Attach(szKey); - size_t cbValue = (ocslen(lpszValue)+1)*sizeof(OLECHAR); - LPOLESTR szValue = NULL; - ATLTRY(szValue = new OLECHAR[cbValue];) - CAutoVectorPtr spValue; - ATLASSUME(szValue != NULL); - spValue.Attach(szValue); + size_t cbValue = (ocslen(lpszValue)+1)*sizeof(OLECHAR); + LPOLESTR szValue = NULL; + ATLTRY(szValue = new OLECHAR[cbValue];) + CAutoVectorPtr spValue; + ATLASSUME(szValue != NULL); + spValue.Attach(szValue); - if (szKey == NULL || szValue == NULL) - hRes = E_OUTOFMEMORY; - else - { - Checked::memcpy_s(szKey, cbKey, lpszKey, cbKey); - Checked::memcpy_s(szValue, cbValue, lpszValue, cbValue); - if (!CSimpleMap::Add(szKey, szValue)) - hRes = E_OUTOFMEMORY; - } - if (SUCCEEDED(hRes)) - { - spKey.Detach(); - spValue.Detach(); - } - return SUCCEEDED(hRes); - } - HRESULT ClearReplacements() - { - for (int i = 0; i < GetSize(); i++) - { - delete []GetKeyAt(i); - delete []GetValueAt(i); - } - RemoveAll(); - return S_OK; - } + if (szKey == NULL || szValue == NULL) + hRes = E_OUTOFMEMORY; + else + { + Checked::memcpy_s(szKey, cbKey, lpszKey, cbKey); + Checked::memcpy_s(szValue, cbValue, lpszValue, cbValue); + if (!CSimpleMap::Add(szKey, szValue)) + hRes = E_OUTOFMEMORY; + } + if (SUCCEEDED(hRes)) + { + spKey.Detach(); + spValue.Detach(); + } + return SUCCEEDED(hRes); + } + HRESULT ClearReplacements() + { + for (int i = 0; i < GetSize(); i++) + { + delete []GetKeyAt(i); + delete []GetValueAt(i); + } + RemoveAll(); + return S_OK; + } }; class CRegObject; @@ -156,154 +156,154 @@ class CRegObject; class CRegParser { public: - CRegParser(_In_ CRegObject* pRegObj); + CRegParser(_In_ CRegObject* pRegObj); - HRESULT PreProcessBuffer( - _In_z_ LPTSTR lpszReg, - _Deref_out_z_ LPTSTR* ppszReg); + HRESULT PreProcessBuffer( + _In_z_ LPTSTR lpszReg, + _Deref_out_z_ LPTSTR* ppszReg); - HRESULT RegisterBuffer( - _In_z_ LPTSTR szReg, - _In_ BOOL bRegister); + HRESULT RegisterBuffer( + _In_z_ LPTSTR szReg, + _In_ BOOL bRegister); protected: - static const int MAX_VALUE = 4096; - void SkipWhiteSpace(); - HRESULT NextToken(_Out_z_cap_c_(MAX_VALUE) LPTSTR szToken); - HRESULT AddValue( - _Inout_ CRegKey& rkParent, - _In_opt_z_ LPCTSTR szValueName, - _Out_z_cap_c_(MAX_VALUE) LPTSTR szToken); - BOOL CanForceRemoveKey(_In_z_ LPCTSTR szKey); - BOOL HasSubKeys(_In_ HKEY hkey); - BOOL HasValues(_In_ HKEY hkey); - HRESULT RegisterSubkeys( - _Out_z_cap_c_(MAX_VALUE) LPTSTR szToken, - _In_ HKEY hkParent, - _In_ BOOL bRegister, - _In_ BOOL bInRecovery = FALSE); - BOOL IsSpace(_In_ TCHAR ch); - LPTSTR m_pchCur; + static const int MAX_VALUE = 4096; + void SkipWhiteSpace(); + HRESULT NextToken(_Out_z_cap_c_(MAX_VALUE) LPTSTR szToken); + HRESULT AddValue( + _Inout_ CRegKey& rkParent, + _In_opt_z_ LPCTSTR szValueName, + _Out_z_cap_c_(MAX_VALUE) LPTSTR szToken); + BOOL CanForceRemoveKey(_In_z_ LPCTSTR szKey); + BOOL HasSubKeys(_In_ HKEY hkey); + BOOL HasValues(_In_ HKEY hkey); + HRESULT RegisterSubkeys( + _Out_z_cap_c_(MAX_VALUE) LPTSTR szToken, + _In_ HKEY hkParent, + _In_ BOOL bRegister, + _In_ BOOL bInRecovery = FALSE); + BOOL IsSpace(_In_ TCHAR ch); + LPTSTR m_pchCur; - CRegObject* m_pRegObj; + CRegObject* m_pRegObj; - HRESULT GenerateError(_In_ UINT) - { - return DISP_E_EXCEPTION; - } - //HRESULT HandleReplacements(LPTSTR& szToken); - HRESULT SkipAssignment(_Inout_z_cap_c_(MAX_VALUE) LPTSTR szToken); + HRESULT GenerateError(_In_ UINT) + { + return DISP_E_EXCEPTION; + } + //HRESULT HandleReplacements(LPTSTR& szToken); + HRESULT SkipAssignment(_Inout_z_cap_c_(MAX_VALUE) LPTSTR szToken); - BOOL EndOfVar() - { - return chQuote == *m_pchCur && chQuote != *CharNext(m_pchCur); - } - static LPTSTR StrChr(_In_z_ LPTSTR lpsz, _In_ TCHAR ch); - static HKEY HKeyFromString(_In_z_ LPTSTR szToken); - static BYTE ChToByte(_In_ const TCHAR ch); - static BOOL VTFromRegType(_In_z_ LPCTSTR szValueType, _Out_ VARTYPE& vt); + BOOL EndOfVar() + { + return chQuote == *m_pchCur && chQuote != *CharNext(m_pchCur); + } + static LPTSTR StrChr(_In_z_ LPTSTR lpsz, _In_ TCHAR ch); + static HKEY HKeyFromString(_In_z_ LPTSTR szToken); + static BYTE ChToByte(_In_ const TCHAR ch); + static BOOL VTFromRegType(_In_z_ LPCTSTR szValueType, _Out_ VARTYPE& vt); - static const TCHAR* const rgszNeverDelete[]; - static const int cbNeverDelete; - static const int MAX_TYPE = 4096; + static const TCHAR* const rgszNeverDelete[]; + static const int cbNeverDelete; + static const int MAX_TYPE = 4096; - // Implementation Helper - class CParseBuffer - { - public: - int nPos; - int nSize; - LPTSTR p; - CParseBuffer(_In_ int nInitial) - { - if (nInitial < 100) - nInitial = 1000; - nPos = 0; - nSize = nInitial; - p = (LPTSTR) ::ATL::AtlCoTaskMemCAlloc(nSize,static_cast(sizeof(TCHAR))); - if (p != NULL) - *p = _T('\0'); - } - ~CParseBuffer() - { - CoTaskMemFree(p); - } - BOOL Append( - _In_count_(nChars) const TCHAR* pch, - _In_ int nChars) - { - ATLASSERT(p != NULL); - int newSize = nPos + nChars + 1; - if ((newSize <= nPos) || (newSize <= nChars)) - return FALSE; + // Implementation Helper + class CParseBuffer + { + public: + int nPos; + int nSize; + LPTSTR p; + CParseBuffer(_In_ int nInitial) + { + if (nInitial < 100) + nInitial = 1000; + nPos = 0; + nSize = nInitial; + p = (LPTSTR) ::ATL::AtlCoTaskMemCAlloc(nSize,static_cast(sizeof(TCHAR))); + if (p != NULL) + *p = _T('\0'); + } + ~CParseBuffer() + { + CoTaskMemFree(p); + } + BOOL Append( + _In_count_(nChars) const TCHAR* pch, + _In_ int nChars) + { + ATLASSERT(p != NULL); + int newSize = nPos + nChars + 1; + if ((newSize <= nPos) || (newSize <= nChars)) + return FALSE; - if (newSize >= nSize) - { - while (newSize >= nSize) { - if (nSize > INT_MAX / 2) - return FALSE; - nSize *= 2; - } - LPTSTR pTemp = (LPTSTR)::ATL::AtlCoTaskMemRecalloc(p, nSize, sizeof(TCHAR)); - if (pTemp == NULL) - return FALSE; - p = pTemp; - } - if ((nPos < 0) || (nPos >= nSize) || nSize - nPos > nSize) - return FALSE; + if (newSize >= nSize) + { + while (newSize >= nSize) { + if (nSize > INT_MAX / 2) + return FALSE; + nSize *= 2; + } + LPTSTR pTemp = (LPTSTR)::ATL::AtlCoTaskMemRecalloc(p, nSize, sizeof(TCHAR)); + if (pTemp == NULL) + return FALSE; + p = pTemp; + } + if ((nPos < 0) || (nPos >= nSize) || nSize - nPos > nSize) + return FALSE; #pragma warning(push) #pragma warning(disable: 22008) - /* Prefast false warning is fired here despite the all above checks */ - Checked::memcpy_s(p + nPos, (nSize-nPos) * sizeof(TCHAR), pch, int(nChars * sizeof(TCHAR))); - nPos += nChars; - *(p + nPos) = _T('\0'); + /* Prefast false warning is fired here despite the all above checks */ + Checked::memcpy_s(p + nPos, (nSize-nPos) * sizeof(TCHAR), pch, int(nChars * sizeof(TCHAR))); + nPos += nChars; + *(p + nPos) = _T('\0'); #pragma warning(pop) - return TRUE; - } + return TRUE; + } - BOOL AddChar(_In_z_ const TCHAR* pch) - { + BOOL AddChar(_In_z_ const TCHAR* pch) + { #ifndef _UNICODE - int nChars = int(CharNext(pch) - pch); + int nChars = int(CharNext(pch) - pch); #else - int nChars = 1; + int nChars = 1; #endif - return Append(pch, nChars); + return Append(pch, nChars); - } - BOOL AddString(_In_z_ LPCOLESTR lpsz) - { - if (lpsz == NULL) - { - return FALSE; - } - USES_CONVERSION_EX; - LPCTSTR lpszT = OLE2CT_EX(lpsz, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); - if (lpszT == NULL) - { - return FALSE; - } - return Append(lpszT, (int)lstrlen(lpszT)); - } - LPTSTR Detach() - { - LPTSTR lp = p; - p = NULL; - nSize = nPos = 0; - return lp; - } + } + BOOL AddString(_In_z_ LPCOLESTR lpsz) + { + if (lpsz == NULL) + { + return FALSE; + } + USES_CONVERSION_EX; + LPCTSTR lpszT = OLE2CT_EX(lpsz, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); + if (lpszT == NULL) + { + return FALSE; + } + return Append(lpszT, (int)lstrlen(lpszT)); + } + LPTSTR Detach() + { + LPTSTR lp = p; + p = NULL; + nSize = nPos = 0; + return lp; + } - }; + }; }; #if defined(_ATL_DLL) || defined(_ATL_DLL_IMPL) class ATL_NO_VTABLE CRegObject : - public IRegistrar + public IRegistrar #else class CRegObject : - public IRegistrarBase + public IRegistrarBase #endif { public: @@ -311,1294 +311,1294 @@ public: #if defined(_ATL_DLL) || defined(_ATL_DLL_IMPL) #else - STDMETHOD(QueryInterface)( - _In_ const IID &, - _In_opt_ void ** ) - { - ATLASSERT(_T("statically linked in CRegObject is not a com object. Do not callthis function")); - return E_NOTIMPL; - } + STDMETHOD(QueryInterface)( + _In_ const IID &, + _In_opt_ void ** ) + { + ATLASSERT(_T("statically linked in CRegObject is not a com object. Do not callthis function")); + return E_NOTIMPL; + } - STDMETHOD_(ULONG, AddRef)(void) - { - ATLASSERT(_T("statically linked in CRegObject is not a com object. Do not callthis function")); - return 1; - } - STDMETHOD_(ULONG, Release)(void) - { - ATLASSERT(_T("statically linked in CRegObject is not a com object. Do not callthis function")); - return 0; - } + STDMETHOD_(ULONG, AddRef)(void) + { + ATLASSERT(_T("statically linked in CRegObject is not a com object. Do not callthis function")); + return 1; + } + STDMETHOD_(ULONG, Release)(void) + { + ATLASSERT(_T("statically linked in CRegObject is not a com object. Do not callthis function")); + return 0; + } #endif - virtual ~CRegObject() - { - ClearReplacements(); - } - HRESULT FinalConstruct() - { - return m_csMap.Init(); - } - void FinalRelease() {} + virtual ~CRegObject() + { + ClearReplacements(); + } + HRESULT FinalConstruct() + { + return m_csMap.Init(); + } + void FinalRelease() {} - // Map based methods - HRESULT STDMETHODCALLTYPE AddReplacement( - _In_z_ LPCOLESTR lpszKey, - _In_z_ LPCOLESTR lpszItem); - HRESULT STDMETHODCALLTYPE ClearReplacements(); - LPCOLESTR StrFromMap(_In_z_ LPTSTR lpszKey); + // Map based methods + HRESULT STDMETHODCALLTYPE AddReplacement( + _In_z_ LPCOLESTR lpszKey, + _In_z_ LPCOLESTR lpszItem); + HRESULT STDMETHODCALLTYPE ClearReplacements(); + LPCOLESTR StrFromMap(_In_z_ LPTSTR lpszKey); - // Register via a given mechanism - HRESULT STDMETHODCALLTYPE ResourceRegister( - _In_z_ LPCOLESTR pszFileName, - _In_ UINT nID, - _In_z_ LPCOLESTR pszType); - HRESULT STDMETHODCALLTYPE ResourceRegisterSz( - _In_z_ LPCOLESTR pszFileName, - _In_z_ LPCOLESTR pszID, - _In_z_ LPCOLESTR pszType); - HRESULT STDMETHODCALLTYPE ResourceUnregister( - _In_z_ LPCOLESTR pszFileName, - _In_ UINT nID, - _In_z_ LPCOLESTR pszType); - HRESULT STDMETHODCALLTYPE ResourceUnregisterSz( - _In_z_ LPCOLESTR pszFileName, - _In_z_ LPCOLESTR pszID, - _In_z_ LPCOLESTR pszType); + // Register via a given mechanism + HRESULT STDMETHODCALLTYPE ResourceRegister( + _In_z_ LPCOLESTR pszFileName, + _In_ UINT nID, + _In_z_ LPCOLESTR pszType); + HRESULT STDMETHODCALLTYPE ResourceRegisterSz( + _In_z_ LPCOLESTR pszFileName, + _In_z_ LPCOLESTR pszID, + _In_z_ LPCOLESTR pszType); + HRESULT STDMETHODCALLTYPE ResourceUnregister( + _In_z_ LPCOLESTR pszFileName, + _In_ UINT nID, + _In_z_ LPCOLESTR pszType); + HRESULT STDMETHODCALLTYPE ResourceUnregisterSz( + _In_z_ LPCOLESTR pszFileName, + _In_z_ LPCOLESTR pszID, + _In_z_ LPCOLESTR pszType); - HRESULT STDMETHODCALLTYPE FileRegister(_In_z_ LPCOLESTR bstrFileName) - { - return CommonFileRegister(bstrFileName, TRUE); - } + HRESULT STDMETHODCALLTYPE FileRegister(_In_z_ LPCOLESTR bstrFileName) + { + return CommonFileRegister(bstrFileName, TRUE); + } - HRESULT STDMETHODCALLTYPE FileUnregister(_In_z_ LPCOLESTR bstrFileName) - { - return CommonFileRegister(bstrFileName, FALSE); - } + HRESULT STDMETHODCALLTYPE FileUnregister(_In_z_ LPCOLESTR bstrFileName) + { + return CommonFileRegister(bstrFileName, FALSE); + } - HRESULT STDMETHODCALLTYPE StringRegister(_In_z_ LPCOLESTR bstrData) - { - return RegisterWithString(bstrData, TRUE); - } + HRESULT STDMETHODCALLTYPE StringRegister(_In_z_ LPCOLESTR bstrData) + { + return RegisterWithString(bstrData, TRUE); + } - HRESULT STDMETHODCALLTYPE StringUnregister(_In_z_ LPCOLESTR bstrData) - { - return RegisterWithString(bstrData, FALSE); - } + HRESULT STDMETHODCALLTYPE StringUnregister(_In_z_ LPCOLESTR bstrData) + { + return RegisterWithString(bstrData, FALSE); + } protected: - HRESULT CommonFileRegister( - _In_z_ LPCOLESTR pszFileName, - _In_ BOOL bRegister); - HRESULT RegisterFromResource( - _In_z_ LPCOLESTR pszFileName, - _In_z_ LPCTSTR pszID, - _In_z_ LPCTSTR pszType, - _In_ BOOL bRegister); - HRESULT RegisterWithString( - _In_z_ LPCOLESTR pszData, - _In_ BOOL bRegister); + HRESULT CommonFileRegister( + _In_z_ LPCOLESTR pszFileName, + _In_ BOOL bRegister); + HRESULT RegisterFromResource( + _In_z_ LPCOLESTR pszFileName, + _In_z_ LPCTSTR pszID, + _In_z_ LPCTSTR pszType, + _In_ BOOL bRegister); + HRESULT RegisterWithString( + _In_z_ LPCOLESTR pszData, + _In_ BOOL bRegister); - static HRESULT GenerateError(_In_ UINT) - { - return DISP_E_EXCEPTION; - } + static HRESULT GenerateError(_In_ UINT) + { + return DISP_E_EXCEPTION; + } - CExpansionVector m_RepMap; - CComObjectThreadModel::AutoDeleteCriticalSection m_csMap; + CExpansionVector m_RepMap; + CComObjectThreadModel::AutoDeleteCriticalSection m_csMap; }; inline HRESULT STDMETHODCALLTYPE CRegObject::AddReplacement( - _In_z_ LPCOLESTR lpszKey, - _In_z_ LPCOLESTR lpszItem) + _In_z_ LPCOLESTR lpszKey, + _In_z_ LPCOLESTR lpszItem) { - if (lpszKey == NULL || lpszItem == NULL) - return E_INVALIDARG; - m_csMap.Lock(); - USES_CONVERSION_EX; + if (lpszKey == NULL || lpszItem == NULL) + return E_INVALIDARG; + m_csMap.Lock(); + USES_CONVERSION_EX; - LPCTSTR lpszT = OLE2CT_EX(lpszKey, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); + LPCTSTR lpszT = OLE2CT_EX(lpszKey, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); #ifndef _UNICODE - if(lpszT == NULL) - return E_OUTOFMEMORY; + if(lpszT == NULL) + return E_OUTOFMEMORY; #endif - BOOL bRet = m_RepMap.Add(lpszT, lpszItem); - m_csMap.Unlock(); - return bRet ? S_OK : E_OUTOFMEMORY; + BOOL bRet = m_RepMap.Add(lpszT, lpszItem); + m_csMap.Unlock(); + return bRet ? S_OK : E_OUTOFMEMORY; } inline HRESULT CRegObject::RegisterFromResource( - _In_z_ LPCOLESTR bstrFileName, - _In_z_ LPCTSTR szID, - _In_z_ LPCTSTR szType, - _In_ BOOL bRegister) + _In_z_ LPCOLESTR bstrFileName, + _In_z_ LPCTSTR szID, + _In_z_ LPCTSTR szType, + _In_ BOOL bRegister) { - USES_CONVERSION_EX; + USES_CONVERSION_EX; - HRESULT hr; - CRegParser parser(this); - HINSTANCE hInstResDll; - HRSRC hrscReg; - HGLOBAL hReg; - DWORD dwSize; - LPSTR szRegA; + HRESULT hr; + CRegParser parser(this); + HINSTANCE hInstResDll; + HRSRC hrscReg; + HGLOBAL hReg; + DWORD dwSize; + LPSTR szRegA; DWORD uniSize = 0; - CTempBuffer szReg; + CTempBuffer szReg; - LPCTSTR lpszBSTRFileName = OLE2CT_EX(bstrFileName, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); + LPCTSTR lpszBSTRFileName = OLE2CT_EX(bstrFileName, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); #ifndef _UNICODE - if (lpszBSTRFileName == NULL) - { - return E_OUTOFMEMORY; - } + if (lpszBSTRFileName == NULL) + { + return E_OUTOFMEMORY; + } #endif // _UNICODE - hInstResDll = LoadLibraryEx(lpszBSTRFileName, NULL, LOAD_LIBRARY_AS_DATAFILE); + hInstResDll = LoadLibraryEx(lpszBSTRFileName, NULL, LOAD_LIBRARY_AS_DATAFILE); - if (NULL == hInstResDll) - { - hr = AtlHresultFromLastError(); - goto ReturnHR; - } + if (NULL == hInstResDll) + { + hr = AtlHresultFromLastError(); + goto ReturnHR; + } - hrscReg =FindResource((HMODULE)hInstResDll, szID, szType); + hrscReg =FindResource((HMODULE)hInstResDll, szID, szType); - if (NULL == hrscReg) - { - hr = AtlHresultFromLastError(); - goto ReturnHR; - } - hReg = LoadResource((HMODULE)hInstResDll, hrscReg); + if (NULL == hrscReg) + { + hr = AtlHresultFromLastError(); + goto ReturnHR; + } + hReg = LoadResource((HMODULE)hInstResDll, hrscReg); - if (NULL == hReg) - { - hr = AtlHresultFromLastError(); - goto ReturnHR; - } + if (NULL == hReg) + { + hr = AtlHresultFromLastError(); + goto ReturnHR; + } - dwSize = SizeofResource((HMODULE)hInstResDll, hrscReg); - szRegA = (LPSTR)hReg; + dwSize = SizeofResource((HMODULE)hInstResDll, hrscReg); + szRegA = (LPSTR)hReg; - // Allocate extra space for NULL. - if (dwSize + 1 < dwSize) - { - hr = E_OUTOFMEMORY; - goto ReturnHR; - } + // Allocate extra space for NULL. + if (dwSize + 1 < dwSize) + { + hr = E_OUTOFMEMORY; + goto ReturnHR; + } - ATLTRY(szReg.Allocate(dwSize + 1)); - if (szReg == NULL) - { - hr = E_OUTOFMEMORY; - goto ReturnHR; - } + ATLTRY(szReg.Allocate(dwSize + 1)); + if (szReg == NULL) + { + hr = E_OUTOFMEMORY; + goto ReturnHR; + } #ifdef _UNICODE - uniSize = ::MultiByteToWideChar(_AtlGetConversionACP(), 0, szRegA, dwSize, szReg, dwSize); - if (uniSize == 0) - { - hr = AtlHresultFromLastError(); - goto ReturnHR; - } - // Append a NULL at the end. - szReg[uniSize] = _T('\0'); + uniSize = ::MultiByteToWideChar(_AtlGetConversionACP(), 0, szRegA, dwSize, szReg, dwSize); + if (uniSize == 0) + { + hr = AtlHresultFromLastError(); + goto ReturnHR; + } + // Append a NULL at the end. + szReg[uniSize] = _T('\0'); #else - Checked::memcpy_s(szReg, dwSize, szRegA, dwSize); - // Append a NULL at the end. - szReg[dwSize] = _T('\0'); + Checked::memcpy_s(szReg, dwSize, szRegA, dwSize); + // Append a NULL at the end. + szReg[dwSize] = _T('\0'); #endif - hr = parser.RegisterBuffer(szReg, bRegister); + hr = parser.RegisterBuffer(szReg, bRegister); ReturnHR: - if (NULL != hInstResDll) - FreeLibrary((HMODULE)hInstResDll); - return hr; + if (NULL != hInstResDll) + FreeLibrary((HMODULE)hInstResDll); + return hr; } inline HRESULT STDMETHODCALLTYPE CRegObject::ResourceRegister( - _In_z_ LPCOLESTR szFileName, - _In_ UINT nID, - _In_z_ LPCOLESTR szType) + _In_z_ LPCOLESTR szFileName, + _In_ UINT nID, + _In_z_ LPCOLESTR szType) { - USES_CONVERSION_EX; + USES_CONVERSION_EX; - LPCTSTR lpszT = OLE2CT_EX(szType, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); + LPCTSTR lpszT = OLE2CT_EX(szType, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); #ifndef _UNICODE - if (lpszT == NULL) - { - return E_OUTOFMEMORY; - } + if (lpszT == NULL) + { + return E_OUTOFMEMORY; + } #endif // _UNICODE - return RegisterFromResource(szFileName, MAKEINTRESOURCE(nID), lpszT, TRUE); + return RegisterFromResource(szFileName, MAKEINTRESOURCE(nID), lpszT, TRUE); } inline HRESULT STDMETHODCALLTYPE CRegObject::ResourceRegisterSz( - _In_z_ LPCOLESTR szFileName, - _In_z_ LPCOLESTR szID, - _In_z_ LPCOLESTR szType) + _In_z_ LPCOLESTR szFileName, + _In_z_ LPCOLESTR szID, + _In_z_ LPCOLESTR szType) { - USES_CONVERSION_EX; - if (szID == NULL || szType == NULL) - return E_INVALIDARG; + USES_CONVERSION_EX; + if (szID == NULL || szType == NULL) + return E_INVALIDARG; - LPCTSTR lpszID = OLE2CT_EX(szID, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); - LPCTSTR lpszType = OLE2CT_EX(szType, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); + LPCTSTR lpszID = OLE2CT_EX(szID, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); + LPCTSTR lpszType = OLE2CT_EX(szType, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); #ifndef _UNICODE - if (lpszID == NULL || lpszType==NULL) - { - return E_OUTOFMEMORY; - } + if (lpszID == NULL || lpszType==NULL) + { + return E_OUTOFMEMORY; + } #endif // _UNICODE - return RegisterFromResource(szFileName, lpszID, lpszType, TRUE); + return RegisterFromResource(szFileName, lpszID, lpszType, TRUE); } inline HRESULT STDMETHODCALLTYPE CRegObject::ResourceUnregister( - _In_z_ LPCOLESTR szFileName, - _In_ UINT nID, - _In_z_ LPCOLESTR szType) + _In_z_ LPCOLESTR szFileName, + _In_ UINT nID, + _In_z_ LPCOLESTR szType) { - USES_CONVERSION_EX; + USES_CONVERSION_EX; - LPCTSTR lpszT = OLE2CT_EX(szType, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); + LPCTSTR lpszT = OLE2CT_EX(szType, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); #ifndef _UNICODE - if (lpszT == NULL) - { - return E_OUTOFMEMORY; - } + if (lpszT == NULL) + { + return E_OUTOFMEMORY; + } #endif // _UNICODE - return RegisterFromResource(szFileName, MAKEINTRESOURCE(nID), lpszT, FALSE); + return RegisterFromResource(szFileName, MAKEINTRESOURCE(nID), lpszT, FALSE); } inline HRESULT STDMETHODCALLTYPE CRegObject::ResourceUnregisterSz( - _In_z_ LPCOLESTR szFileName, - _In_z_ LPCOLESTR szID, - _In_z_ LPCOLESTR szType) + _In_z_ LPCOLESTR szFileName, + _In_z_ LPCOLESTR szID, + _In_z_ LPCOLESTR szType) { - USES_CONVERSION_EX; - if (szID == NULL || szType == NULL) - return E_INVALIDARG; + USES_CONVERSION_EX; + if (szID == NULL || szType == NULL) + return E_INVALIDARG; - LPCTSTR lpszID = OLE2CT_EX(szID, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); - LPCTSTR lpszType = OLE2CT_EX(szType, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); + LPCTSTR lpszID = OLE2CT_EX(szID, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); + LPCTSTR lpszType = OLE2CT_EX(szType, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); #ifndef _UNICODE - if (lpszID == NULL || lpszType == NULL) - { - return E_OUTOFMEMORY; - } + if (lpszID == NULL || lpszType == NULL) + { + return E_OUTOFMEMORY; + } #endif // _UNICODE - return RegisterFromResource(szFileName, lpszID, lpszType, FALSE); + return RegisterFromResource(szFileName, lpszID, lpszType, FALSE); } inline HRESULT CRegObject::RegisterWithString( - _In_z_ LPCOLESTR bstrData, - _In_ BOOL bRegister) + _In_z_ LPCOLESTR bstrData, + _In_ BOOL bRegister) { - USES_CONVERSION_EX; - CRegParser parser(this); + USES_CONVERSION_EX; + CRegParser parser(this); - LPCTSTR szReg = OLE2CT_EX(bstrData, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); + LPCTSTR szReg = OLE2CT_EX(bstrData, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); #ifndef _UNICODE - if (szReg == NULL) - { - return E_OUTOFMEMORY; - } + if (szReg == NULL) + { + return E_OUTOFMEMORY; + } #endif // _UNICODE - HRESULT hr = parser.RegisterBuffer((LPTSTR)szReg, bRegister); + HRESULT hr = parser.RegisterBuffer((LPTSTR)szReg, bRegister); - return hr; + return hr; } inline HRESULT CRegObject::ClearReplacements() { - m_csMap.Lock(); - HRESULT hr = m_RepMap.ClearReplacements(); - m_csMap.Unlock(); - return hr; + m_csMap.Lock(); + HRESULT hr = m_RepMap.ClearReplacements(); + m_csMap.Unlock(); + return hr; } inline LPCOLESTR CRegObject::StrFromMap(_In_z_ LPTSTR lpszKey) { - m_csMap.Lock(); - LPCOLESTR lpsz = m_RepMap.Lookup(lpszKey); - m_csMap.Unlock(); - return lpsz; + m_csMap.Lock(); + LPCOLESTR lpsz = m_RepMap.Lookup(lpszKey); + m_csMap.Unlock(); + return lpsz; } inline HRESULT CRegObject::CommonFileRegister( - _In_z_ LPCOLESTR bstrFileName, - _In_ BOOL bRegister) + _In_z_ LPCOLESTR bstrFileName, + _In_ BOOL bRegister) { - USES_CONVERSION_EX; + USES_CONVERSION_EX; - CRegParser parser(this); + CRegParser parser(this); - LPCTSTR lpszBSTRFileName = OLE2CT_EX(bstrFileName, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); + LPCTSTR lpszBSTRFileName = OLE2CT_EX(bstrFileName, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); #ifndef _UNICODE - if (lpszBSTRFileName == NULL) - { - return E_OUTOFMEMORY; - } + if (lpszBSTRFileName == NULL) + { + return E_OUTOFMEMORY; + } #endif // _UNICODE - HANDLE hFile = CreateFile(lpszBSTRFileName, GENERIC_READ, 0, NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_READONLY, - NULL); - if (INVALID_HANDLE_VALUE == hFile) - { - return AtlHresultFromLastError(); - } + HANDLE hFile = CreateFile(lpszBSTRFileName, GENERIC_READ, 0, NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_READONLY, + NULL); + if (INVALID_HANDLE_VALUE == hFile) + { + return AtlHresultFromLastError(); + } - HRESULT hRes = S_OK; - DWORD cbRead; - DWORD cbFile = GetFileSize(hFile, NULL); // No HiOrder DWORD required + HRESULT hRes = S_OK; + DWORD cbRead; + DWORD cbFile = GetFileSize(hFile, NULL); // No HiOrder DWORD required - CTempBuffer szReg; - // Extra space for NULL. - ATLTRY(szReg.Allocate(cbFile + 1)); - if (szReg == NULL) - { - hRes = E_OUTOFMEMORY; - goto ReturnHR; - } + CTempBuffer szReg; + // Extra space for NULL. + ATLTRY(szReg.Allocate(cbFile + 1)); + if (szReg == NULL) + { + hRes = E_OUTOFMEMORY; + goto ReturnHR; + } - if (ReadFile(hFile, szReg, cbFile, &cbRead, NULL) == 0) - { - hRes = AtlHresultFromLastError(); - } - if (SUCCEEDED(hRes)) - { - szReg[cbRead] = '\0'; + if (ReadFile(hFile, szReg, cbFile, &cbRead, NULL) == 0) + { + hRes = AtlHresultFromLastError(); + } + if (SUCCEEDED(hRes)) + { + szReg[cbRead] = '\0'; #ifdef _UNICODE - CTempBuffer szConverted; - ATLTRY(szConverted.Allocate(cbFile + 1)); - if (szConverted == NULL) - { - hRes = E_OUTOFMEMORY; - goto ReturnHR; + CTempBuffer szConverted; + ATLTRY(szConverted.Allocate(cbFile + 1)); + if (szConverted == NULL) + { + hRes = E_OUTOFMEMORY; + goto ReturnHR; - } - if (::MultiByteToWideChar(_AtlGetConversionACP(), 0, szReg, cbFile + 1, szConverted, cbFile + 1) == 0) - { - hRes = AtlHresultFromLastError(); - goto ReturnHR; - } + } + if (::MultiByteToWideChar(_AtlGetConversionACP(), 0, szReg, cbFile + 1, szConverted, cbFile + 1) == 0) + { + hRes = AtlHresultFromLastError(); + goto ReturnHR; + } #else - LPTSTR szConverted = szReg; + LPTSTR szConverted = szReg; #endif - hRes = parser.RegisterBuffer(szConverted, bRegister); - } + hRes = parser.RegisterBuffer(szConverted, bRegister); + } ReturnHR: - CloseHandle(hFile); - return hRes; + CloseHandle(hFile); + return hRes; } __declspec(selectany) const TCHAR* const CRegParser::rgszNeverDelete[] = { - _T("AppID"), - _T("CLSID"), - _T("Component Categories"), - _T("FileType"), - _T("Interface"), - _T("Hardware"), - _T("Mime"), - _T("SAM"), - _T("SECURITY"), - _T("SYSTEM"), - _T("Software"), - _T("TypeLib") + _T("AppID"), + _T("CLSID"), + _T("Component Categories"), + _T("FileType"), + _T("Interface"), + _T("Hardware"), + _T("Mime"), + _T("SAM"), + _T("SECURITY"), + _T("SYSTEM"), + _T("Software"), + _T("TypeLib") }; __declspec(selectany) const int CRegParser::cbNeverDelete = sizeof(rgszNeverDelete) / sizeof(LPCTSTR*); inline BOOL CRegParser::VTFromRegType( - _In_z_ LPCTSTR szValueType, - _Out_ VARTYPE& vt) + _In_z_ LPCTSTR szValueType, + _Out_ VARTYPE& vt) { - struct typemap - { - LPCTSTR lpsz; - VARTYPE vt; - }; + struct typemap + { + LPCTSTR lpsz; + VARTYPE vt; + }; #pragma warning (push) -#pragma warning (disable : 4640) // construction of local static object is not thread-safe +#pragma warning (disable : 4640) // construction of local static object is not thread-safe - static const typemap map[] = { - {szStringVal, VT_BSTR}, - {multiszStringVal, VT_BSTR | VT_BYREF}, - {szDwordVal, VT_UI4}, - {szBinaryVal, VT_UI1} - }; + static const typemap map[] = { + {szStringVal, VT_BSTR}, + {multiszStringVal, VT_BSTR | VT_BYREF}, + {szDwordVal, VT_UI4}, + {szBinaryVal, VT_UI1} + }; #pragma warning (pop) - for (int i=0;i= szOrig + MAX_VALUE) - return GenerateError(E_ATL_VALUE_TOO_LARGE); + // Make sure we have room for nChars plus terminating NULL + if ((szToken + nChars + 1) >= szOrig + MAX_VALUE) + return GenerateError(E_ATL_VALUE_TOO_LARGE); - for (int i = 0; i < (int)nChars; i++, szToken++, pchPrev++) - *szToken = *pchPrev; - } + for (int i = 0; i < (int)nChars; i++, szToken++, pchPrev++) + *szToken = *pchPrev; + } - if (_T('\0') == *m_pchCur) - { - return GenerateError(E_ATL_UNEXPECTED_EOS); - } + if (_T('\0') == *m_pchCur) + { + return GenerateError(E_ATL_UNEXPECTED_EOS); + } - *szToken = _T('\0'); - m_pchCur = CharNext(m_pchCur); - } + *szToken = _T('\0'); + m_pchCur = CharNext(m_pchCur); + } - else - { - // Handle non-quoted ie parse up till first "White Space" - while (_T('\0') != *m_pchCur && !IsSpace(*m_pchCur)) - { - LPTSTR pchPrev = m_pchCur; - m_pchCur = CharNext(m_pchCur); + else + { + // Handle non-quoted ie parse up till first "White Space" + while (_T('\0') != *m_pchCur && !IsSpace(*m_pchCur)) + { + LPTSTR pchPrev = m_pchCur; + m_pchCur = CharNext(m_pchCur); - INT_PTR nChars = m_pchCur - pchPrev; + INT_PTR nChars = m_pchCur - pchPrev; - // Make sure we have room for nChars plus terminating NULL - if ((szToken + nChars + 1) >= szOrig + MAX_VALUE) - return GenerateError(E_ATL_VALUE_TOO_LARGE); + // Make sure we have room for nChars plus terminating NULL + if ((szToken + nChars + 1) >= szOrig + MAX_VALUE) + return GenerateError(E_ATL_VALUE_TOO_LARGE); - for (int i = 0; i < (int)nChars; i++, szToken++, pchPrev++) - *szToken = *pchPrev; - } + for (int i = 0; i < (int)nChars; i++, szToken++, pchPrev++) + *szToken = *pchPrev; + } - *szToken = _T('\0'); - } - return S_OK; + *szToken = _T('\0'); + } + return S_OK; } #pragma warning(push) #pragma warning(disable:6385) // suppressing code analysis warning on the GenerateError code path inline HRESULT CRegParser::AddValue( - _Inout_ CRegKey& rkParent, - _In_opt_z_ LPCTSTR szValueName, - _Out_z_cap_c_(MAX_VALUE) LPTSTR szToken) + _Inout_ CRegKey& rkParent, + _In_opt_z_ LPCTSTR szValueName, + _Out_z_cap_c_(MAX_VALUE) LPTSTR szToken) { - HRESULT hr; + HRESULT hr; - TCHAR szValue[MAX_VALUE]; - VARTYPE vt = VT_EMPTY; - LONG lRes = ERROR_SUCCESS; - UINT nIDRes = 0; + TCHAR szValue[MAX_VALUE]; + VARTYPE vt = VT_EMPTY; + LONG lRes = ERROR_SUCCESS; + UINT nIDRes = 0; - if (FAILED(hr = NextToken(szValue))) - return hr; - if (!VTFromRegType(szValue, vt)) - { - return GenerateError(E_ATL_TYPE_NOT_SUPPORTED); - } + if (FAILED(hr = NextToken(szValue))) + return hr; + if (!VTFromRegType(szValue, vt)) + { + return GenerateError(E_ATL_TYPE_NOT_SUPPORTED); + } #pragma warning(pop) - SkipWhiteSpace(); - if (FAILED(hr = NextToken(szValue))) - return hr; + SkipWhiteSpace(); + if (FAILED(hr = NextToken(szValue))) + return hr; - switch (vt) - { - case VT_BSTR: - { - lRes = rkParent.SetStringValue(szValueName, szValue); - break; - } - case VT_BSTR | VT_BYREF: - { - int nLen = lstrlen(szValue) + 2; //Allocate space for double null termination. - CTempBuffer pszDestValue; - //nLen should be >= the max size of the target buffer. - ATLTRY(pszDestValue.Allocate(nLen)); - if (pszDestValue != NULL) - { - TCHAR* p = pszDestValue; - TCHAR* q = szValue; - nLen = 0; - while (*q != _T('\0')) - { - TCHAR* r = CharNext(q); - if (*q == _T('\\') && *r == _T('0')) - { - *p++ = _T('\0'); - q = CharNext(r); - } - else - { - *p = *q; + switch (vt) + { + case VT_BSTR: + { + lRes = rkParent.SetStringValue(szValueName, szValue); + break; + } + case VT_BSTR | VT_BYREF: + { + int nLen = lstrlen(szValue) + 2; //Allocate space for double null termination. + CTempBuffer pszDestValue; + //nLen should be >= the max size of the target buffer. + ATLTRY(pszDestValue.Allocate(nLen)); + if (pszDestValue != NULL) + { + TCHAR* p = pszDestValue; + TCHAR* q = szValue; + nLen = 0; + while (*q != _T('\0')) + { + TCHAR* r = CharNext(q); + if (*q == _T('\\') && *r == _T('0')) + { + *p++ = _T('\0'); + q = CharNext(r); + } + else + { + *p = *q; #ifndef _UNICODE - if (IsDBCSLeadByte(*q)) - { - p++; - q++; - //Protect from Lead byte followed by the zero terminator.May skip beyond the end of the string. - if (*q == _T('\0')) { break; } - *p = *q; - } + if (IsDBCSLeadByte(*q)) + { + p++; + q++; + //Protect from Lead byte followed by the zero terminator.May skip beyond the end of the string. + if (*q == _T('\0')) { break; } + *p = *q; + } #endif - p++; - q++; - } - nLen ++; - } - //Always terminate with 2 null characters. - *p = _T('\0'); - p++; - *p = _T('\0'); - lRes = rkParent.SetMultiStringValue(szValueName, pszDestValue); - } - else - { - lRes = ERROR_OUTOFMEMORY; - } - } - break; - case VT_UI4: - { - ULONG ulVal; - USES_CONVERSION_EX; + p++; + q++; + } + nLen ++; + } + //Always terminate with 2 null characters. + *p = _T('\0'); + p++; + *p = _T('\0'); + lRes = rkParent.SetMultiStringValue(szValueName, pszDestValue); + } + else + { + lRes = ERROR_OUTOFMEMORY; + } + } + break; + case VT_UI4: + { + ULONG ulVal; + USES_CONVERSION_EX; - LPOLESTR lpszV = T2OLE_EX(szValue, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); - #ifndef _UNICODE - if(lpszV == NULL) - return E_OUTOFMEMORY; - #endif - VarUI4FromStr(lpszV, 0, 0, &ulVal); + LPOLESTR lpszV = T2OLE_EX(szValue, _ATL_SAFE_ALLOCA_DEF_THRESHOLD); + #ifndef _UNICODE + if(lpszV == NULL) + return E_OUTOFMEMORY; + #endif + VarUI4FromStr(lpszV, 0, 0, &ulVal); - lRes = rkParent.SetDWORDValue(szValueName, ulVal); - break; - } - case VT_UI1: - { - int cbValue = lstrlen(szValue); - if (cbValue & 0x00000001) - { - return E_FAIL; - } - int cbValDiv2 = cbValue/2; - CTempBuffer rgBinary; - ATLTRY(rgBinary.Allocate(cbValDiv2)); - if (rgBinary == NULL) - return E_FAIL; - memset(rgBinary, 0, cbValDiv2); - for (int irg = 0; irg < cbValue; irg++) - rgBinary[(irg/2)] |= (ChToByte(szValue[irg])) << (4*(1 - (irg & 0x00000001))); - lRes = RegSetValueEx(rkParent, szValueName, 0, REG_BINARY, rgBinary, cbValDiv2); - break; - } - } + lRes = rkParent.SetDWORDValue(szValueName, ulVal); + break; + } + case VT_UI1: + { + int cbValue = lstrlen(szValue); + if (cbValue & 0x00000001) + { + return E_FAIL; + } + int cbValDiv2 = cbValue/2; + CTempBuffer rgBinary; + ATLTRY(rgBinary.Allocate(cbValDiv2)); + if (rgBinary == NULL) + return E_FAIL; + memset(rgBinary, 0, cbValDiv2); + for (int irg = 0; irg < cbValue; irg++) + rgBinary[(irg/2)] |= (ChToByte(szValue[irg])) << (4*(1 - (irg & 0x00000001))); + lRes = RegSetValueEx(rkParent, szValueName, 0, REG_BINARY, rgBinary, cbValDiv2); + break; + } + } - if (ERROR_SUCCESS != lRes) - { - nIDRes = E_ATL_VALUE_SET_FAILED; - return AtlHresultFromWin32(lRes); - } + if (ERROR_SUCCESS != lRes) + { + nIDRes = E_ATL_VALUE_SET_FAILED; + return AtlHresultFromWin32(lRes); + } - if (FAILED(hr = NextToken(szToken))) - return hr; + if (FAILED(hr = NextToken(szToken))) + return hr; - return S_OK; + return S_OK; } inline BOOL CRegParser::CanForceRemoveKey(_In_z_ LPCTSTR szKey) { - for (int iNoDel = 0; iNoDel < cbNeverDelete; iNoDel++) - if (!lstrcmpi(szKey, rgszNeverDelete[iNoDel])) - return FALSE; // We cannot delete it + for (int iNoDel = 0; iNoDel < cbNeverDelete; iNoDel++) + if (!lstrcmpi(szKey, rgszNeverDelete[iNoDel])) + return FALSE; // We cannot delete it - return TRUE; + return TRUE; } inline BOOL CRegParser::HasSubKeys(_In_ HKEY hkey) { - DWORD cSubKeys = 0; + DWORD cSubKeys = 0; - if (RegQueryInfoKeyW(hkey, NULL, NULL, NULL, - &cSubKeys, NULL, NULL, - NULL, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) - { - ATLASSERT(FALSE); - return FALSE; - } + if (RegQueryInfoKeyW(hkey, NULL, NULL, NULL, + &cSubKeys, NULL, NULL, + NULL, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) + { + ATLASSERT(FALSE); + return FALSE; + } - return cSubKeys > 0; + return cSubKeys > 0; } inline BOOL CRegParser::HasValues(_In_ HKEY hkey) { - DWORD cValues = 0; - DWORD cMaxValueNameLen; + DWORD cValues = 0; + DWORD cMaxValueNameLen; - LONG lResult = RegQueryInfoKeyW(hkey, NULL, NULL, NULL, - NULL, NULL, NULL, - &cValues, &cMaxValueNameLen, NULL, NULL, NULL); - if (ERROR_SUCCESS != lResult) - { - ATLASSERT(FALSE); - return FALSE; - } + LONG lResult = RegQueryInfoKeyW(hkey, NULL, NULL, NULL, + NULL, NULL, NULL, + &cValues, &cMaxValueNameLen, NULL, NULL, NULL); + if (ERROR_SUCCESS != lResult) + { + ATLASSERT(FALSE); + return FALSE; + } - if ((1 == cValues) && (0 == cMaxValueNameLen)) - { - return FALSE; - } + if ((1 == cValues) && (0 == cMaxValueNameLen)) + { + return FALSE; + } - return cValues > 0; // More than 1 means we have a non-default value + return cValues > 0; // More than 1 means we have a non-default value } inline HRESULT CRegParser::SkipAssignment(_Inout_z_cap_c_(MAX_VALUE) LPTSTR szToken) { - HRESULT hr; - TCHAR szValue[MAX_VALUE]; + HRESULT hr; + TCHAR szValue[MAX_VALUE]; - if (*szToken == chEquals) - { - if (FAILED(hr = NextToken(szToken))) - return hr; - // Skip assignment - SkipWhiteSpace(); - if (FAILED(hr = NextToken(szValue))) - return hr; - if (FAILED(hr = NextToken(szToken))) - return hr; - } + if (*szToken == chEquals) + { + if (FAILED(hr = NextToken(szToken))) + return hr; + // Skip assignment + SkipWhiteSpace(); + if (FAILED(hr = NextToken(szValue))) + return hr; + if (FAILED(hr = NextToken(szToken))) + return hr; + } - return S_OK; + return S_OK; } ATLPREFAST_SUPPRESS(6387) inline HRESULT CRegParser::PreProcessBuffer( - _In_z_ LPTSTR lpszReg, - _Deref_out_z_ LPTSTR* ppszReg) + _In_z_ LPTSTR lpszReg, + _Deref_out_z_ LPTSTR* ppszReg) { - ATLASSERT(lpszReg != NULL); - ATLASSERT(ppszReg != NULL); + ATLASSERT(lpszReg != NULL); + ATLASSERT(ppszReg != NULL); - if (lpszReg == NULL || ppszReg == NULL) - return E_POINTER; + if (lpszReg == NULL || ppszReg == NULL) + return E_POINTER; - *ppszReg = NULL; - int nSize = lstrlen(lpszReg)*2; - CParseBuffer pb(nSize); - if (pb.p == NULL) - return E_OUTOFMEMORY; - m_pchCur = lpszReg; - HRESULT hr = S_OK; + *ppszReg = NULL; + int nSize = lstrlen(lpszReg)*2; + CParseBuffer pb(nSize); + if (pb.p == NULL) + return E_OUTOFMEMORY; + m_pchCur = lpszReg; + HRESULT hr = S_OK; - bool bRedirectionEnabled = false; - hr = AtlGetPerUserRegistration(&bRedirectionEnabled); - if( FAILED(hr) ) - { - return hr; - } + bool bRedirectionEnabled = false; + hr = AtlGetPerUserRegistration(&bRedirectionEnabled); + if( FAILED(hr) ) + { + return hr; + } - // nNestingLevel is used to avoid checking for unnecessary root key replacements - // since all of them are expected to be at the top level. - int nNestingLevel = 0; - bool bRedirectionPresent = false; - bool bInsideQuotes = false; + // nNestingLevel is used to avoid checking for unnecessary root key replacements + // since all of them are expected to be at the top level. + int nNestingLevel = 0; + bool bRedirectionPresent = false; + bool bInsideQuotes = false; - while (*m_pchCur != _T('\0')) // look for end - { - if ( true == bRedirectionEnabled ) - { - LPCOLESTR szStartHKCU = L"HKCU\r\n{\tSoftware\r\n\t{\r\n\t\tClasses"; - LPCOLESTR szEndHKCU = L"\r\n\t}\r\n}\r\n"; + while (*m_pchCur != _T('\0')) // look for end + { + if ( true == bRedirectionEnabled ) + { + LPCOLESTR szStartHKCU = L"HKCU\r\n{\tSoftware\r\n\t{\r\n\t\tClasses"; + LPCOLESTR szEndHKCU = L"\r\n\t}\r\n}\r\n"; - if ( 0 == nNestingLevel ) - { - // Then we should be reading a root key. HKCR, HKCU, etc - TCHAR* szRootKey = NULL; - if( NULL != ( szRootKey = _tcsstr(m_pchCur, _T("HKCR")) ) && // if HKCR is found. - (szRootKey == m_pchCur) ) // if HKCR is the first token. - { - // Skip HKCR - m_pchCur = CharNext(m_pchCur); - m_pchCur = CharNext(m_pchCur); - m_pchCur = CharNext(m_pchCur); - m_pchCur = CharNext(m_pchCur); + if ( 0 == nNestingLevel ) + { + // Then we should be reading a root key. HKCR, HKCU, etc + TCHAR* szRootKey = NULL; + if( NULL != ( szRootKey = _tcsstr(m_pchCur, _T("HKCR")) ) && // if HKCR is found. + (szRootKey == m_pchCur) ) // if HKCR is the first token. + { + // Skip HKCR + m_pchCur = CharNext(m_pchCur); + m_pchCur = CharNext(m_pchCur); + m_pchCur = CharNext(m_pchCur); + m_pchCur = CharNext(m_pchCur); - // Add HKCU - if (!pb.AddString(szStartHKCU)) - { - hr = E_OUTOFMEMORY; - break; - } + // Add HKCU + if (!pb.AddString(szStartHKCU)) + { + hr = E_OUTOFMEMORY; + break; + } - bRedirectionPresent = true; - } - } + bRedirectionPresent = true; + } + } - if ( chQuote == *m_pchCur ) - { - if( false == bInsideQuotes ) - { - bInsideQuotes = true; - } - else - { - // Make sure it is not an escaped sequence. - if( EndOfVar() ) - { - bInsideQuotes = false; - } - else - { - // An escaped single quote... - m_pchCur = CharNext(m_pchCur); - if (!pb.AddChar(m_pchCur)) - { - hr = E_OUTOFMEMORY; - break; - } - } - } - } + if ( chQuote == *m_pchCur ) + { + if( false == bInsideQuotes ) + { + bInsideQuotes = true; + } + else + { + // Make sure it is not an escaped sequence. + if( EndOfVar() ) + { + bInsideQuotes = false; + } + else + { + // An escaped single quote... + m_pchCur = CharNext(m_pchCur); + if (!pb.AddChar(m_pchCur)) + { + hr = E_OUTOFMEMORY; + break; + } + } + } + } - if ( (false == bInsideQuotes) && (*m_pchCur == _T('{')) ) - { - ++nNestingLevel; - } + if ( (false == bInsideQuotes) && (*m_pchCur == _T('{')) ) + { + ++nNestingLevel; + } - if ( (false == bInsideQuotes) && (*m_pchCur == _T('}')) ) - { - --nNestingLevel; - if ( (0 == nNestingLevel) && (true == bRedirectionPresent) ) - { - if (!pb.AddString(szEndHKCU)) - { - hr = E_OUTOFMEMORY; - break; - } + if ( (false == bInsideQuotes) && (*m_pchCur == _T('}')) ) + { + --nNestingLevel; + if ( (0 == nNestingLevel) && (true == bRedirectionPresent) ) + { + if (!pb.AddString(szEndHKCU)) + { + hr = E_OUTOFMEMORY; + break; + } - bRedirectionPresent = false; - } - } - } + bRedirectionPresent = false; + } + } + } - if (*m_pchCur == _T('%')) - { - m_pchCur = CharNext(m_pchCur); - if (*m_pchCur == _T('%')) - { - if (!pb.AddChar(m_pchCur)) - { - hr = E_OUTOFMEMORY; - break; - } - } - else - { - LPTSTR lpszNext = StrChr(m_pchCur, _T('%')); - if (lpszNext == NULL) - { - hr = GenerateError(E_ATL_UNEXPECTED_EOS); - break; - } - if ((lpszNext-m_pchCur) > 31) - { - hr = E_FAIL; - break; - } - int nLength = int(lpszNext - m_pchCur); - TCHAR buf[32]; - Checked::tcsncpy_s(buf, _countof(buf), m_pchCur, nLength); - LPCOLESTR lpszVar = m_pRegObj->StrFromMap(buf); - if (lpszVar == NULL) - { - hr = GenerateError(E_ATL_NOT_IN_MAP); - break; - } - if (!pb.AddString(lpszVar)) - { - hr = E_OUTOFMEMORY; - break; - } + if (*m_pchCur == _T('%')) + { + m_pchCur = CharNext(m_pchCur); + if (*m_pchCur == _T('%')) + { + if (!pb.AddChar(m_pchCur)) + { + hr = E_OUTOFMEMORY; + break; + } + } + else + { + LPTSTR lpszNext = StrChr(m_pchCur, _T('%')); + if (lpszNext == NULL) + { + hr = GenerateError(E_ATL_UNEXPECTED_EOS); + break; + } + if ((lpszNext-m_pchCur) > 31) + { + hr = E_FAIL; + break; + } + int nLength = int(lpszNext - m_pchCur); + TCHAR buf[32]; + Checked::tcsncpy_s(buf, _countof(buf), m_pchCur, nLength); + LPCOLESTR lpszVar = m_pRegObj->StrFromMap(buf); + if (lpszVar == NULL) + { + hr = GenerateError(E_ATL_NOT_IN_MAP); + break; + } + if (!pb.AddString(lpszVar)) + { + hr = E_OUTOFMEMORY; + break; + } - while (m_pchCur != lpszNext) - m_pchCur = CharNext(m_pchCur); - } - } - else - { - if (!pb.AddChar(m_pchCur)) - { - hr = E_OUTOFMEMORY; - break; - } - } + while (m_pchCur != lpszNext) + m_pchCur = CharNext(m_pchCur); + } + } + else + { + if (!pb.AddChar(m_pchCur)) + { + hr = E_OUTOFMEMORY; + break; + } + } - m_pchCur = CharNext(m_pchCur); - } - if (SUCCEEDED(hr)) - *ppszReg = pb.Detach(); - return hr; + m_pchCur = CharNext(m_pchCur); + } + if (SUCCEEDED(hr)) + *ppszReg = pb.Detach(); + return hr; } ATLPREFAST_UNSUPPRESS() inline HRESULT CRegParser::RegisterBuffer( - _In_z_ LPTSTR szBuffer, - _In_ BOOL bRegister) + _In_z_ LPTSTR szBuffer, + _In_ BOOL bRegister) { - TCHAR szToken[MAX_VALUE]; - HRESULT hr = S_OK; + TCHAR szToken[MAX_VALUE]; + HRESULT hr = S_OK; - LPTSTR szReg = NULL; - hr = PreProcessBuffer(szBuffer, &szReg); - if (FAILED(hr)) - return hr; + LPTSTR szReg = NULL; + hr = PreProcessBuffer(szBuffer, &szReg); + if (FAILED(hr)) + return hr; - m_pchCur = szReg; + m_pchCur = szReg; - // Preprocess szReg + // Preprocess szReg - while (_T('\0') != *m_pchCur) - { - if (FAILED(hr = NextToken(szToken))) - break; - HKEY hkBase; - if ((hkBase = HKeyFromString(szToken)) == NULL) - { - hr = GenerateError(E_ATL_BAD_HKEY); - break; - } + while (_T('\0') != *m_pchCur) + { + if (FAILED(hr = NextToken(szToken))) + break; + HKEY hkBase; + if ((hkBase = HKeyFromString(szToken)) == NULL) + { + hr = GenerateError(E_ATL_BAD_HKEY); + break; + } - if (FAILED(hr = NextToken(szToken))) - break; + if (FAILED(hr = NextToken(szToken))) + break; - if (chLeftBracket != *szToken) - { - hr = GenerateError(E_ATL_MISSING_OPENKEY_TOKEN); - break; - } - if (bRegister) - { - LPTSTR szRegAtRegister = m_pchCur; - hr = RegisterSubkeys(szToken, hkBase, bRegister); - if (FAILED(hr)) - { - m_pchCur = szRegAtRegister; - RegisterSubkeys(szToken, hkBase, FALSE); - break; - } - } - else - { - if (FAILED(hr = RegisterSubkeys(szToken, hkBase, bRegister))) - break; - } + if (chLeftBracket != *szToken) + { + hr = GenerateError(E_ATL_MISSING_OPENKEY_TOKEN); + break; + } + if (bRegister) + { + LPTSTR szRegAtRegister = m_pchCur; + hr = RegisterSubkeys(szToken, hkBase, bRegister); + if (FAILED(hr)) + { + m_pchCur = szRegAtRegister; + RegisterSubkeys(szToken, hkBase, FALSE); + break; + } + } + else + { + if (FAILED(hr = RegisterSubkeys(szToken, hkBase, bRegister))) + break; + } - SkipWhiteSpace(); - } - CoTaskMemFree(szReg); - return hr; + SkipWhiteSpace(); + } + CoTaskMemFree(szReg); + return hr; } inline HRESULT CRegParser::RegisterSubkeys( - _Out_z_cap_c_(MAX_VALUE) LPTSTR szToken, - _In_ HKEY hkParent, - _In_ BOOL bRegister, - _In_ BOOL bRecover) + _Out_z_cap_c_(MAX_VALUE) LPTSTR szToken, + _In_ HKEY hkParent, + _In_ BOOL bRegister, + _In_ BOOL bRecover) { - CRegKey keyCur; - LONG lRes; - TCHAR szKey[_MAX_PATH]; - BOOL bDelete = TRUE; - BOOL bInRecovery = bRecover; - HRESULT hr = S_OK; + CRegKey keyCur; + LONG lRes; + TCHAR szKey[_MAX_PATH]; + BOOL bDelete = TRUE; + BOOL bInRecovery = bRecover; + HRESULT hr = S_OK; - if (FAILED(hr = NextToken(szToken))) - return hr; + if (FAILED(hr = NextToken(szToken))) + return hr; - while (*szToken != chRightBracket) // Continue till we see a } - { - bDelete = TRUE; - BOOL bTokenDelete = !lstrcmpi(szToken, szDelete); + while (*szToken != chRightBracket) // Continue till we see a } + { + bDelete = TRUE; + BOOL bTokenDelete = !lstrcmpi(szToken, szDelete); - if (!lstrcmpi(szToken, szForceRemove) || bTokenDelete) - { - if (FAILED(hr = NextToken(szToken))) - break; + if (!lstrcmpi(szToken, szForceRemove) || bTokenDelete) + { + if (FAILED(hr = NextToken(szToken))) + break; - if (bRegister) - { - CRegKey rkForceRemove; + if (bRegister) + { + CRegKey rkForceRemove; - if (StrChr(szToken, chDirSep) != NULL) - return GenerateError(E_ATL_COMPOUND_KEY); + if (StrChr(szToken, chDirSep) != NULL) + return GenerateError(E_ATL_COMPOUND_KEY); - if (CanForceRemoveKey(szToken)) - { - rkForceRemove.Attach(hkParent); - // Error not returned. We will overwrite the values any way. - rkForceRemove.RecurseDeleteKey(szToken); - rkForceRemove.Detach(); - } - if (bTokenDelete) - { - if (FAILED(hr = NextToken(szToken))) - break; - if (FAILED(hr = SkipAssignment(szToken))) - break; - goto EndCheck; - } - } - } + if (CanForceRemoveKey(szToken)) + { + rkForceRemove.Attach(hkParent); + // Error not returned. We will overwrite the values any way. + rkForceRemove.RecurseDeleteKey(szToken); + rkForceRemove.Detach(); + } + if (bTokenDelete) + { + if (FAILED(hr = NextToken(szToken))) + break; + if (FAILED(hr = SkipAssignment(szToken))) + break; + goto EndCheck; + } + } + } - if (!lstrcmpi(szToken, szNoRemove)) - { - bDelete = FALSE; // set even for register - if (FAILED(hr = NextToken(szToken))) - break; - } + if (!lstrcmpi(szToken, szNoRemove)) + { + bDelete = FALSE; // set even for register + if (FAILED(hr = NextToken(szToken))) + break; + } - if (!lstrcmpi(szToken, szValToken)) // need to add a value to hkParent - { - TCHAR szValueName[MAX_VALUE]; + if (!lstrcmpi(szToken, szValToken)) // need to add a value to hkParent + { + TCHAR szValueName[MAX_VALUE]; - if (FAILED(hr = NextToken(szValueName))) - break; - if (FAILED(hr = NextToken(szToken))) - break; + if (FAILED(hr = NextToken(szValueName))) + break; + if (FAILED(hr = NextToken(szToken))) + break; - if (*szToken != chEquals) - return GenerateError(E_ATL_EXPECTING_EQUAL); + if (*szToken != chEquals) + return GenerateError(E_ATL_EXPECTING_EQUAL); - if (bRegister) - { - CRegKey rk; + if (bRegister) + { + CRegKey rk; - rk.Attach(hkParent); - hr = AddValue(rk, szValueName, szToken); - rk.Detach(); + rk.Attach(hkParent); + hr = AddValue(rk, szValueName, szToken); + rk.Detach(); - if (FAILED(hr)) - return hr; + if (FAILED(hr)) + return hr; - goto EndCheck; - } - else - { - if (!bRecover && bDelete) - { - // We have to open the key for write to be able to delete. - CRegKey rkParent; - lRes = rkParent.Open(hkParent, NULL, KEY_WRITE); - if (lRes == ERROR_SUCCESS) - { - lRes = rkParent.DeleteValue(szValueName); - if (lRes != ERROR_SUCCESS && lRes != ERROR_FILE_NOT_FOUND) - { - // Key not present is not an error - hr = AtlHresultFromWin32(lRes); - break; - } - } - else - { - hr = AtlHresultFromWin32(lRes); - break; - } - } - if (FAILED(hr = SkipAssignment(szToken))) - break; - continue; // can never have a subkey - } - } + goto EndCheck; + } + else + { + if (!bRecover && bDelete) + { + // We have to open the key for write to be able to delete. + CRegKey rkParent; + lRes = rkParent.Open(hkParent, NULL, KEY_WRITE); + if (lRes == ERROR_SUCCESS) + { + lRes = rkParent.DeleteValue(szValueName); + if (lRes != ERROR_SUCCESS && lRes != ERROR_FILE_NOT_FOUND) + { + // Key not present is not an error + hr = AtlHresultFromWin32(lRes); + break; + } + } + else + { + hr = AtlHresultFromWin32(lRes); + break; + } + } + if (FAILED(hr = SkipAssignment(szToken))) + break; + continue; // can never have a subkey + } + } - if (StrChr(szToken, chDirSep) != NULL) - return GenerateError(E_ATL_COMPOUND_KEY); + if (StrChr(szToken, chDirSep) != NULL) + return GenerateError(E_ATL_COMPOUND_KEY); - if (bRegister) - { - lRes = keyCur.Open(hkParent, szToken, KEY_READ | KEY_WRITE); - if (ERROR_SUCCESS != lRes) - { - // Failed all access try read only - lRes = keyCur.Open(hkParent, szToken, KEY_READ); - if (ERROR_SUCCESS != lRes) - { - // Finally try creating it - lRes = keyCur.Create(hkParent, szToken, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE); - if (lRes != ERROR_SUCCESS) - return AtlHresultFromWin32(lRes); - } - } + if (bRegister) + { + lRes = keyCur.Open(hkParent, szToken, KEY_READ | KEY_WRITE); + if (ERROR_SUCCESS != lRes) + { + // Failed all access try read only + lRes = keyCur.Open(hkParent, szToken, KEY_READ); + if (ERROR_SUCCESS != lRes) + { + // Finally try creating it + lRes = keyCur.Create(hkParent, szToken, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE); + if (lRes != ERROR_SUCCESS) + return AtlHresultFromWin32(lRes); + } + } - if (FAILED(hr = NextToken(szToken))) - break; + if (FAILED(hr = NextToken(szToken))) + break; - if (*szToken == chEquals) - { - if (FAILED(hr = AddValue(keyCur, NULL, szToken))) // NULL == default - break; - } - } - else //Unregister - { - if (!bRecover) - { - lRes = keyCur.Open(hkParent, szToken, KEY_READ); + if (*szToken == chEquals) + { + if (FAILED(hr = AddValue(keyCur, NULL, szToken))) // NULL == default + break; + } + } + else //Unregister + { + if (!bRecover) + { + lRes = keyCur.Open(hkParent, szToken, KEY_READ); - } - else - lRes = ERROR_FILE_NOT_FOUND; + } + else + lRes = ERROR_FILE_NOT_FOUND; - // Open failed set recovery mode - if (lRes != ERROR_SUCCESS) - bRecover = true; + // Open failed set recovery mode + if (lRes != ERROR_SUCCESS) + bRecover = true; - // TRACE out Key open status and if in recovery mode + // TRACE out Key open status and if in recovery mode - // Remember Subkey - Checked::tcsncpy_s(szKey, _countof(szKey), szToken, _TRUNCATE); + // Remember Subkey + Checked::tcsncpy_s(szKey, _countof(szKey), szToken, _TRUNCATE); - if (FAILED(hr = NextToken(szToken))) - break; - if (FAILED(hr = SkipAssignment(szToken))) - break; + if (FAILED(hr = NextToken(szToken))) + break; + if (FAILED(hr = SkipAssignment(szToken))) + break; - if (*szToken == chLeftBracket && lstrlen(szToken) == 1) - { - hr = RegisterSubkeys(szToken, keyCur.m_hKey, bRegister, bRecover); - // In recover mode ignore error - if (FAILED(hr) && !bRecover) - break; - // Skip the } - if (FAILED(hr = NextToken(szToken))) - break; - } - bRecover = bInRecovery; + if (*szToken == chLeftBracket && lstrlen(szToken) == 1) + { + hr = RegisterSubkeys(szToken, keyCur.m_hKey, bRegister, bRecover); + // In recover mode ignore error + if (FAILED(hr) && !bRecover) + break; + // Skip the } + if (FAILED(hr = NextToken(szToken))) + break; + } + bRecover = bInRecovery; - if (lRes == ERROR_FILE_NOT_FOUND) - // Key already not present so not an error. - continue; + if (lRes == ERROR_FILE_NOT_FOUND) + // Key already not present so not an error. + continue; - if (lRes != ERROR_SUCCESS) - { - // We are recovery mode continue on errors else break - if (bRecover) - continue; - else - { - hr = AtlHresultFromWin32(lRes); - break; - } - } + if (lRes != ERROR_SUCCESS) + { + // We are recovery mode continue on errors else break + if (bRecover) + continue; + else + { + hr = AtlHresultFromWin32(lRes); + break; + } + } - // If in recovery mode - if (bRecover && HasSubKeys(keyCur)) - { - // See if the KEY is in the NeverDelete list and if so, don't - if (CanForceRemoveKey(szKey) && bDelete) - { - // Error not returned since we are in recovery mode. The error that caused recovery mode is returned - keyCur.RecurseDeleteKey(szKey); - } - continue; - } + // If in recovery mode + if (bRecover && HasSubKeys(keyCur)) + { + // See if the KEY is in the NeverDelete list and if so, don't + if (CanForceRemoveKey(szKey) && bDelete) + { + // Error not returned since we are in recovery mode. The error that caused recovery mode is returned + keyCur.RecurseDeleteKey(szKey); + } + continue; + } - BOOL bHasSubKeys=HasSubKeys(keyCur); - lRes = keyCur.Close(); - if (lRes != ERROR_SUCCESS) - return AtlHresultFromWin32(lRes); + BOOL bHasSubKeys=HasSubKeys(keyCur); + lRes = keyCur.Close(); + if (lRes != ERROR_SUCCESS) + return AtlHresultFromWin32(lRes); - if (bDelete&& !bHasSubKeys) - { - CRegKey rkParent; - rkParent.Attach(hkParent); - lRes = rkParent.DeleteSubKey(szKey); - rkParent.Detach(); - if (lRes != ERROR_SUCCESS) - { + if (bDelete&& !bHasSubKeys) + { + CRegKey rkParent; + rkParent.Attach(hkParent); + lRes = rkParent.DeleteSubKey(szKey); + rkParent.Detach(); + if (lRes != ERROR_SUCCESS) + { - hr = AtlHresultFromWin32(lRes); - break; - } - } - } + hr = AtlHresultFromWin32(lRes); + break; + } + } + } EndCheck: - if (bRegister) - { - if (*szToken == chLeftBracket && lstrlen(szToken) == 1) - { - if (FAILED(hr = RegisterSubkeys(szToken, keyCur.m_hKey, bRegister, FALSE))) - break; - if (FAILED(hr = NextToken(szToken))) - break; - } - } - } + if (bRegister) + { + if (*szToken == chLeftBracket && lstrlen(szToken) == 1) + { + if (FAILED(hr = RegisterSubkeys(szToken, keyCur.m_hKey, bRegister, FALSE))) + break; + if (FAILED(hr = NextToken(szToken))) + break; + } + } + } - return hr; + return hr; } }; //namespace ATL diff --git a/src/main/java/com/jacob/activeX/ActiveXComponent.java b/src/main/java/com/jacob/activeX/ActiveXComponent.java index ae12208..9bd2058 100644 --- a/src/main/java/com/jacob/activeX/ActiveXComponent.java +++ b/src/main/java/com/jacob/activeX/ActiveXComponent.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.activeX; @@ -58,541 +58,541 @@ import com.jacob.com.Variant; */ public class ActiveXComponent extends Dispatch { - /** - * Normally used to create a new connection to a microsoft application. The - * passed in parameter is the name of the program as registered in the - * registry. It can also be the object name. - *

- * This constructor causes a new Windows object of the requested type to be - * created. The windows CoCreate() function gets called to create the - * underlying windows object. - * - *

-	 * new ActiveXComponent("ScriptControl");
-	 * 
- * - * @param programId - */ - public ActiveXComponent(String programId) { - super(programId); - } + /** + * Normally used to create a new connection to a microsoft application. The + * passed in parameter is the name of the program as registered in the + * registry. It can also be the object name. + *

+ * This constructor causes a new Windows object of the requested type to be + * created. The windows CoCreate() function gets called to create the + * underlying windows object. + * + *

+     * new ActiveXComponent("ScriptControl");
+     * 
+ * + * @param programId + */ + public ActiveXComponent(String programId) { + super(programId); + } - /** - * Creates an active X component that is built on top of the COM pointers - * held in the passed in dispatch. This widens the Dispatch object to pick - * up the ActiveXComponent API - * - * @param dispatchToBeWrapped - */ - public ActiveXComponent(Dispatch dispatchToBeWrapped) { - super(dispatchToBeWrapped); - } + /** + * Creates an active X component that is built on top of the COM pointers + * held in the passed in dispatch. This widens the Dispatch object to pick + * up the ActiveXComponent API + * + * @param dispatchToBeWrapped + */ + public ActiveXComponent(Dispatch dispatchToBeWrapped) { + super(dispatchToBeWrapped); + } - /** - * only used by the factories - * - */ - private ActiveXComponent() { - super(); - } + /** + * only used by the factories + * + */ + private ActiveXComponent() { + super(); + } - /** - * Probably was a cover for something else in the past. Should be - * deprecated. - * - * @return Now it actually returns this exact same object. - */ - public Dispatch getObject() { - return this; - } + /** + * Probably was a cover for something else in the past. Should be + * deprecated. + * + * @return Now it actually returns this exact same object. + */ + public Dispatch getObject() { + return this; + } - /** - * Most code should use the standard ActiveXComponent(String) contructor and - * not this factory method. This method exists for applications that need - * special behavior. Experimental in release 1.9.2. - *

- * Factory that returns a Dispatch object wrapped around the result of a - * CoCreate() call. This differs from the standard constructor in that it - * throws no exceptions and returns null on failure. - *

- * This will fail for any prog id with a ":" in it. - * - * @param pRequestedProgramId - * @return Dispatch pointer to the COM object or null if couldn't create - */ - public static ActiveXComponent createNewInstance(String pRequestedProgramId) { - ActiveXComponent mCreatedDispatch = null; - try { - mCreatedDispatch = new ActiveXComponent(); - mCreatedDispatch.coCreateInstance(pRequestedProgramId); - } catch (Exception e) { - mCreatedDispatch = null; - if (JacobObject.isDebugEnabled()) { - JacobObject.debug("Unable to co-create instance of " - + pRequestedProgramId); - } - } - return mCreatedDispatch; - } + /** + * Most code should use the standard ActiveXComponent(String) contructor and + * not this factory method. This method exists for applications that need + * special behavior. Experimental in release 1.9.2. + *

+ * Factory that returns a Dispatch object wrapped around the result of a + * CoCreate() call. This differs from the standard constructor in that it + * throws no exceptions and returns null on failure. + *

+ * This will fail for any prog id with a ":" in it. + * + * @param pRequestedProgramId + * @return Dispatch pointer to the COM object or null if couldn't create + */ + public static ActiveXComponent createNewInstance(String pRequestedProgramId) { + ActiveXComponent mCreatedDispatch = null; + try { + mCreatedDispatch = new ActiveXComponent(); + mCreatedDispatch.coCreateInstance(pRequestedProgramId); + } catch (Exception e) { + mCreatedDispatch = null; + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("Unable to co-create instance of " + + pRequestedProgramId); + } + } + return mCreatedDispatch; + } - /** - * Most code should use the standard ActiveXComponent(String) constructor and - * not this factory method. This method exists for applications that need - * special behavior. Experimental in release 1.9.2. - *

- * Factory that returns a Dispatch wrapped around the result of a - * getActiveObject() call. This differs from the standard constructor in - * that it throws no exceptions and returns null on failure. - *

- * This will fail for any prog id with a ":" in it - * - * @param pRequestedProgramId - * @return Dispatch pointer to a COM object or null if wasn't already - * running - */ - public static ActiveXComponent connectToActiveInstance( - String pRequestedProgramId) { - ActiveXComponent mCreatedDispatch = null; - try { - mCreatedDispatch = new ActiveXComponent(); - mCreatedDispatch.getActiveInstance(pRequestedProgramId); - } catch (Exception e) { - mCreatedDispatch = null; - if (JacobObject.isDebugEnabled()) { - JacobObject.debug("Unable to attach to running instance of " - + pRequestedProgramId); - } - } - return mCreatedDispatch; - } + /** + * Most code should use the standard ActiveXComponent(String) constructor and + * not this factory method. This method exists for applications that need + * special behavior. Experimental in release 1.9.2. + *

+ * Factory that returns a Dispatch wrapped around the result of a + * getActiveObject() call. This differs from the standard constructor in + * that it throws no exceptions and returns null on failure. + *

+ * This will fail for any prog id with a ":" in it + * + * @param pRequestedProgramId + * @return Dispatch pointer to a COM object or null if wasn't already + * running + */ + public static ActiveXComponent connectToActiveInstance( + String pRequestedProgramId) { + ActiveXComponent mCreatedDispatch = null; + try { + mCreatedDispatch = new ActiveXComponent(); + mCreatedDispatch.getActiveInstance(pRequestedProgramId); + } catch (Exception e) { + mCreatedDispatch = null; + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("Unable to attach to running instance of " + + pRequestedProgramId); + } + } + return mCreatedDispatch; + } - /** - * @see com.jacob.com.Dispatch#finalize() - */ - protected void finalize() { - super.finalize(); - } + /** + * @see com.jacob.com.Dispatch#finalize() + */ + protected void finalize() { + super.finalize(); + } - /* - * ============================================================ - * - * start of instance based calls to the COM layer - * =========================================================== - */ + /* + * ============================================================ + * + * start of instance based calls to the COM layer + * =========================================================== + */ - /** - * retrieves a property and returns it as a Variant - * - * @param propertyName - * @return variant value of property - */ - public Variant getProperty(String propertyName) { - return Dispatch.get(this, propertyName); - } + /** + * retrieves a property and returns it as a Variant + * + * @param propertyName + * @return variant value of property + */ + public Variant getProperty(String propertyName) { + return Dispatch.get(this, propertyName); + } - /** - * retrieves a property and returns it as an ActiveX component - * - * @param propertyName - * @return Dispatch representing the object under the property name - */ - public ActiveXComponent getPropertyAsComponent(String propertyName) { - return new ActiveXComponent(Dispatch.get(this, propertyName) - .toDispatch()); + /** + * retrieves a property and returns it as an ActiveX component + * + * @param propertyName + * @return Dispatch representing the object under the property name + */ + public ActiveXComponent getPropertyAsComponent(String propertyName) { + return new ActiveXComponent(Dispatch.get(this, propertyName) + .toDispatch()); - } + } - /** - * retrieves a property and returns it as a Boolean - * - * @param propertyName - * property we are looking up - * @return boolean value of property - */ - public boolean getPropertyAsBoolean(String propertyName) { - return Dispatch.get(this, propertyName).getBoolean(); - } + /** + * retrieves a property and returns it as a Boolean + * + * @param propertyName + * property we are looking up + * @return boolean value of property + */ + public boolean getPropertyAsBoolean(String propertyName) { + return Dispatch.get(this, propertyName).getBoolean(); + } - /** - * retrieves a property and returns it as a byte - * - * @param propertyName - * property we are looking up - * @return byte value of property - */ - public byte getPropertyAsByte(String propertyName) { - return Dispatch.get(this, propertyName).getByte(); - } + /** + * retrieves a property and returns it as a byte + * + * @param propertyName + * property we are looking up + * @return byte value of property + */ + public byte getPropertyAsByte(String propertyName) { + return Dispatch.get(this, propertyName).getByte(); + } - /** - * retrieves a property and returns it as a String - * - * @param propertyName - * @return String value of property - */ - public String getPropertyAsString(String propertyName) { - return Dispatch.get(this, propertyName).getString(); + /** + * retrieves a property and returns it as a String + * + * @param propertyName + * @return String value of property + */ + public String getPropertyAsString(String propertyName) { + return Dispatch.get(this, propertyName).getString(); - } + } - /** - * retrieves a property and returns it as a int - * - * @param propertyName - * @return the property value as an int - */ - public int getPropertyAsInt(String propertyName) { - return Dispatch.get(this, propertyName).getInt(); - } + /** + * retrieves a property and returns it as a int + * + * @param propertyName + * @return the property value as an int + */ + public int getPropertyAsInt(String propertyName) { + return Dispatch.get(this, propertyName).getInt(); + } - /** - * sets a property on this object - * - * @param propertyName - * property name - * @param arg - * variant value to be set - */ - public void setProperty(String propertyName, Variant arg) { - Dispatch.put(this, propertyName, arg); - } + /** + * sets a property on this object + * + * @param propertyName + * property name + * @param arg + * variant value to be set + */ + public void setProperty(String propertyName, Variant arg) { + Dispatch.put(this, propertyName, arg); + } - /** - * sets a property on this object - * - * @param propertyName - * property name - * @param arg - * variant value to be set - */ - public void setProperty(String propertyName, Dispatch arg) { - Dispatch.put(this, propertyName, arg); - } + /** + * sets a property on this object + * + * @param propertyName + * property name + * @param arg + * variant value to be set + */ + public void setProperty(String propertyName, Dispatch arg) { + Dispatch.put(this, propertyName, arg); + } - /** - * sets a property to be the value of the string - * - * @param propertyName - * @param propertyValue - */ - public void setProperty(String propertyName, String propertyValue) { - this.setProperty(propertyName, new Variant(propertyValue)); - } + /** + * sets a property to be the value of the string + * + * @param propertyName + * @param propertyValue + */ + public void setProperty(String propertyName, String propertyValue) { + this.setProperty(propertyName, new Variant(propertyValue)); + } - /** - * sets a property as a boolean value - * - * @param propertyName - * @param propValue - * the boolean value we want the prop set to - */ - public void setProperty(String propertyName, boolean propValue) { - this.setProperty(propertyName, new Variant(propValue)); - } + /** + * sets a property as a boolean value + * + * @param propertyName + * @param propValue + * the boolean value we want the prop set to + */ + public void setProperty(String propertyName, boolean propValue) { + this.setProperty(propertyName, new Variant(propValue)); + } - /** - * sets a property as a boolean value - * - * @param propertyName - * @param propValue - * the boolean value we want the prop set to - */ - public void setProperty(String propertyName, byte propValue) { - this.setProperty(propertyName, new Variant(propValue)); - } + /** + * sets a property as a boolean value + * + * @param propertyName + * @param propValue + * the boolean value we want the prop set to + */ + public void setProperty(String propertyName, byte propValue) { + this.setProperty(propertyName, new Variant(propValue)); + } - /** - * sets the property as an int value - * - * @param propertyName - * @param propValue - * the int value we want the prop to be set to. - */ - public void setProperty(String propertyName, int propValue) { - this.setProperty(propertyName, new Variant(propValue)); - } + /** + * sets the property as an int value + * + * @param propertyName + * @param propValue + * the int value we want the prop to be set to. + */ + public void setProperty(String propertyName, int propValue) { + this.setProperty(propertyName, new Variant(propValue)); + } - /*------------------------------------------------------- - * Listener logging helpers - *------------------------------------------------------- - */ + /*------------------------------------------------------- + * Listener logging helpers + *------------------------------------------------------- + */ - /** - * This boolean determines if callback events should be logged - */ - public static boolean shouldLogEvents = false; + /** + * This boolean determines if callback events should be logged + */ + public static boolean shouldLogEvents = false; - /** - * used by the doc and application listeners to get intelligent logging - * - * @param description - * event description - * @param args - * args passed in (variants) - * - */ - public void logCallbackEvent(String description, Variant[] args) { - String argString = ""; - if (args != null && ActiveXComponent.shouldLogEvents) { - if (args.length > 0) { - argString += " args: "; - } - for (int i = 0; i < args.length; i++) { - short argType = args[i].getvt(); - argString += ",[" + i + "]"; - // break out the byref bits if they are on this - if ((argType & Variant.VariantByref) == Variant.VariantByref) { - // show the type and the fact that its byref - argString += "(" - + (args[i].getvt() & ~Variant.VariantByref) + "/" - + Variant.VariantByref + ")"; - } else { - // show the type - argString += "(" + argType + ")"; - } - argString += "="; - if (argType == Variant.VariantDispatch) { - Dispatch foo = (args[i].getDispatch()); - argString += foo; - } else if ((argType & Variant.VariantBoolean) == Variant.VariantBoolean) { - // do the boolean thing - if ((argType & Variant.VariantByref) == Variant.VariantByref) { - // boolean by ref - argString += args[i].getBooleanRef(); - } else { - // boolean by value - argString += args[i].getBoolean(); - } - } else if ((argType & Variant.VariantString) == Variant.VariantString) { - // do the string thing - if ((argType & Variant.VariantByref) == Variant.VariantByref) { - // string by ref - argString += args[i].getStringRef(); - } else { - // string by value - argString += args[i].getString(); - } - } else { - argString += args[i].toString(); - } - } - System.out.println(description + argString); - } - } + /** + * used by the doc and application listeners to get intelligent logging + * + * @param description + * event description + * @param args + * args passed in (variants) + * + */ + public void logCallbackEvent(String description, Variant[] args) { + String argString = ""; + if (args != null && ActiveXComponent.shouldLogEvents) { + if (args.length > 0) { + argString += " args: "; + } + for (int i = 0; i < args.length; i++) { + short argType = args[i].getvt(); + argString += ",[" + i + "]"; + // break out the byref bits if they are on this + if ((argType & Variant.VariantByref) == Variant.VariantByref) { + // show the type and the fact that its byref + argString += "(" + + (args[i].getvt() & ~Variant.VariantByref) + "/" + + Variant.VariantByref + ")"; + } else { + // show the type + argString += "(" + argType + ")"; + } + argString += "="; + if (argType == Variant.VariantDispatch) { + Dispatch foo = (args[i].getDispatch()); + argString += foo; + } else if ((argType & Variant.VariantBoolean) == Variant.VariantBoolean) { + // do the boolean thing + if ((argType & Variant.VariantByref) == Variant.VariantByref) { + // boolean by ref + argString += args[i].getBooleanRef(); + } else { + // boolean by value + argString += args[i].getBoolean(); + } + } else if ((argType & Variant.VariantString) == Variant.VariantString) { + // do the string thing + if ((argType & Variant.VariantByref) == Variant.VariantByref) { + // string by ref + argString += args[i].getStringRef(); + } else { + // string by value + argString += args[i].getString(); + } + } else { + argString += args[i].toString(); + } + } + System.out.println(description + argString); + } + } - /* - * ============================================================== - * - * covers for dispatch call methods - * ============================================================= - */ + /* + * ============================================================== + * + * covers for dispatch call methods + * ============================================================= + */ - /** - * makes a dispatch call for the passed in action and no parameter - * - * @param callAction - * @return ActiveXComponent representing the results of the call - */ - public ActiveXComponent invokeGetComponent(String callAction) { - return new ActiveXComponent(invoke(callAction).toDispatch()); - } + /** + * makes a dispatch call for the passed in action and no parameter + * + * @param callAction + * @return ActiveXComponent representing the results of the call + */ + public ActiveXComponent invokeGetComponent(String callAction) { + return new ActiveXComponent(invoke(callAction).toDispatch()); + } - /** - * makes a dispatch call for the passed in action and single parameter - * - * @param callAction - * @param parameter - * @return ActiveXComponent representing the results of the call - */ - public ActiveXComponent invokeGetComponent(String callAction, - Variant parameter) { - return new ActiveXComponent(invoke(callAction, parameter).toDispatch()); - } + /** + * makes a dispatch call for the passed in action and single parameter + * + * @param callAction + * @param parameter + * @return ActiveXComponent representing the results of the call + */ + public ActiveXComponent invokeGetComponent(String callAction, + Variant parameter) { + return new ActiveXComponent(invoke(callAction, parameter).toDispatch()); + } - /** - * makes a dispatch call for the passed in action and single parameter - * - * @param callAction - * @param parameter1 - * @param parameter2 - * @return ActiveXComponent representing the results of the call - */ - public ActiveXComponent invokeGetComponent(String callAction, - Variant parameter1, Variant parameter2) { - return new ActiveXComponent(invoke(callAction, parameter1, parameter2) - .toDispatch()); - } + /** + * makes a dispatch call for the passed in action and single parameter + * + * @param callAction + * @param parameter1 + * @param parameter2 + * @return ActiveXComponent representing the results of the call + */ + public ActiveXComponent invokeGetComponent(String callAction, + Variant parameter1, Variant parameter2) { + return new ActiveXComponent(invoke(callAction, parameter1, parameter2) + .toDispatch()); + } - /** - * makes a dispatch call for the passed in action and single parameter - * - * @param callAction - * @param parameter1 - * @param parameter2 - * @param parameter3 - * @return ActiveXComponent representing the results of the call - */ - public ActiveXComponent invokeGetComponent(String callAction, - Variant parameter1, Variant parameter2, Variant parameter3) { - return new ActiveXComponent(invoke(callAction, parameter1, parameter2, - parameter3).toDispatch()); - } + /** + * makes a dispatch call for the passed in action and single parameter + * + * @param callAction + * @param parameter1 + * @param parameter2 + * @param parameter3 + * @return ActiveXComponent representing the results of the call + */ + public ActiveXComponent invokeGetComponent(String callAction, + Variant parameter1, Variant parameter2, Variant parameter3) { + return new ActiveXComponent(invoke(callAction, parameter1, parameter2, + parameter3).toDispatch()); + } - /** - * makes a dispatch call for the passed in action and single parameter - * - * @param callAction - * @param parameter1 - * @param parameter2 - * @param parameter3 - * @param parameter4 - * @return ActiveXComponent representing the results of the call - */ - public ActiveXComponent invokeGetComponent(String callAction, - Variant parameter1, Variant parameter2, Variant parameter3, - Variant parameter4) { - return new ActiveXComponent(invoke(callAction, parameter1, parameter2, - parameter3, parameter4).toDispatch()); - } + /** + * makes a dispatch call for the passed in action and single parameter + * + * @param callAction + * @param parameter1 + * @param parameter2 + * @param parameter3 + * @param parameter4 + * @return ActiveXComponent representing the results of the call + */ + public ActiveXComponent invokeGetComponent(String callAction, + Variant parameter1, Variant parameter2, Variant parameter3, + Variant parameter4) { + return new ActiveXComponent(invoke(callAction, parameter1, parameter2, + parameter3, parameter4).toDispatch()); + } - /** - * invokes a single parameter call on this dispatch that returns no value - * - * @param actionCommand - * @param parameter - * @return a Variant but that may be null for some calls - */ - public Variant invoke(String actionCommand, String parameter) { - return Dispatch.call(this, actionCommand, parameter); - } + /** + * invokes a single parameter call on this dispatch that returns no value + * + * @param actionCommand + * @param parameter + * @return a Variant but that may be null for some calls + */ + public Variant invoke(String actionCommand, String parameter) { + return Dispatch.call(this, actionCommand, parameter); + } - /** - * makes a dispatch call to the passed in action with a single boolean - * parameter - * - * @param actionCommand - * @param parameter - * @return Variant result - */ - public Variant invoke(String actionCommand, boolean parameter) { - return Dispatch.call(this, actionCommand, new Variant(parameter)); - } + /** + * makes a dispatch call to the passed in action with a single boolean + * parameter + * + * @param actionCommand + * @param parameter + * @return Variant result + */ + public Variant invoke(String actionCommand, boolean parameter) { + return Dispatch.call(this, actionCommand, new Variant(parameter)); + } - /** - * makes a dispatch call to the passed in action with a single int parameter - * - * @param actionCommand - * @param parameter - * @return Variant result of the invoke (Dispatch.call) - */ - public Variant invoke(String actionCommand, int parameter) { - return Dispatch.call(this, actionCommand, new Variant(parameter)); - } + /** + * makes a dispatch call to the passed in action with a single int parameter + * + * @param actionCommand + * @param parameter + * @return Variant result of the invoke (Dispatch.call) + */ + public Variant invoke(String actionCommand, int parameter) { + return Dispatch.call(this, actionCommand, new Variant(parameter)); + } - /** - * makes a dispatch call to the passed in action with a string and integer - * parameter (this was put in for some application) - * - * @param actionCommand - * @param parameter1 - * @param parameter2 - * @return Variant result - */ - public Variant invoke(String actionCommand, String parameter1, - int parameter2) { - return Dispatch.call(this, actionCommand, parameter1, new Variant( - parameter2)); - } + /** + * makes a dispatch call to the passed in action with a string and integer + * parameter (this was put in for some application) + * + * @param actionCommand + * @param parameter1 + * @param parameter2 + * @return Variant result + */ + public Variant invoke(String actionCommand, String parameter1, + int parameter2) { + return Dispatch.call(this, actionCommand, parameter1, new Variant( + parameter2)); + } - /** - * makes a dispatch call to the passed in action with two integer parameters - * (this was put in for some application) - * - * @param actionCommand - * @param parameter1 - * @param parameter2 - * @return a Variant but that may be null for some calls - */ - public Variant invoke(String actionCommand, int parameter1, int parameter2) { - return Dispatch.call(this, actionCommand, new Variant(parameter1), - new Variant(parameter2)); - } + /** + * makes a dispatch call to the passed in action with two integer parameters + * (this was put in for some application) + * + * @param actionCommand + * @param parameter1 + * @param parameter2 + * @return a Variant but that may be null for some calls + */ + public Variant invoke(String actionCommand, int parameter1, int parameter2) { + return Dispatch.call(this, actionCommand, new Variant(parameter1), + new Variant(parameter2)); + } - /** - * makes a dispatch call for the passed in action and single parameter - * - * @param callAction - * @param parameter - * @return a Variant but that may be null for some calls - */ - public Variant invoke(String callAction, Variant parameter) { - return Dispatch.call(this, callAction, parameter); - } + /** + * makes a dispatch call for the passed in action and single parameter + * + * @param callAction + * @param parameter + * @return a Variant but that may be null for some calls + */ + public Variant invoke(String callAction, Variant parameter) { + return Dispatch.call(this, callAction, parameter); + } - /** - * makes a dispatch call for the passed in action and two parameter - * - * @param callAction - * @param parameter1 - * @param parameter2 - * @return a Variant but that may be null for some calls - */ - public Variant invoke(String callAction, Variant parameter1, - Variant parameter2) { - return Dispatch.call(this, callAction, parameter1, parameter2); - } + /** + * makes a dispatch call for the passed in action and two parameter + * + * @param callAction + * @param parameter1 + * @param parameter2 + * @return a Variant but that may be null for some calls + */ + public Variant invoke(String callAction, Variant parameter1, + Variant parameter2) { + return Dispatch.call(this, callAction, parameter1, parameter2); + } - /** - * makes a dispatch call for the passed in action and two parameter - * - * @param callAction - * @param parameter1 - * @param parameter2 - * @param parameter3 - * @return Variant result data - */ - public Variant invoke(String callAction, Variant parameter1, - Variant parameter2, Variant parameter3) { - return Dispatch.call(this, callAction, parameter1, parameter2, - parameter3); - } + /** + * makes a dispatch call for the passed in action and two parameter + * + * @param callAction + * @param parameter1 + * @param parameter2 + * @param parameter3 + * @return Variant result data + */ + public Variant invoke(String callAction, Variant parameter1, + Variant parameter2, Variant parameter3) { + return Dispatch.call(this, callAction, parameter1, parameter2, + parameter3); + } - /** - * calls call() with 4 variant parameters - * - * @param callAction - * @param parameter1 - * @param parameter2 - * @param parameter3 - * @param parameter4 - * @return Variant result data - */ - public Variant invoke(String callAction, Variant parameter1, - Variant parameter2, Variant parameter3, Variant parameter4) { - return Dispatch.call(this, callAction, parameter1, parameter2, - parameter3, parameter4); - } + /** + * calls call() with 4 variant parameters + * + * @param callAction + * @param parameter1 + * @param parameter2 + * @param parameter3 + * @param parameter4 + * @return Variant result data + */ + public Variant invoke(String callAction, Variant parameter1, + Variant parameter2, Variant parameter3, Variant parameter4) { + return Dispatch.call(this, callAction, parameter1, parameter2, + parameter3, parameter4); + } - /** - * makes a dispatch call for the passed in action and no parameter - * - * @param callAction - * @return a Variant but that may be null for some calls - */ - public Variant invoke(String callAction) { - return Dispatch.call(this, callAction); - } + /** + * makes a dispatch call for the passed in action and no parameter + * + * @param callAction + * @return a Variant but that may be null for some calls + */ + public Variant invoke(String callAction) { + return Dispatch.call(this, callAction); + } - /** - * This is really a cover for call(String,Variant[]) that should be - * eliminated call with a variable number of args mainly used for quit. - * - * @param name - * @param args - * @return Variant returned by the invoke (Dispatch.callN) - */ - public Variant invoke(String name, Variant[] args) { - return Dispatch.callN(this, name, args); - } + /** + * This is really a cover for call(String,Variant[]) that should be + * eliminated call with a variable number of args mainly used for quit. + * + * @param name + * @param args + * @return Variant returned by the invoke (Dispatch.callN) + */ + public Variant invoke(String name, Variant[] args) { + return Dispatch.callN(this, name, args); + } } \ No newline at end of file diff --git a/src/main/java/com/jacob/activeX/ActiveXDispatchEvents.java b/src/main/java/com/jacob/activeX/ActiveXDispatchEvents.java index 7d4c74b..ba2fa00 100644 --- a/src/main/java/com/jacob/activeX/ActiveXDispatchEvents.java +++ b/src/main/java/com/jacob/activeX/ActiveXDispatchEvents.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.activeX; @@ -54,72 +54,72 @@ import com.jacob.com.InvocationProxy; */ public class ActiveXDispatchEvents extends DispatchEvents { - /** - * This is the most commonly used constructor. - *

- * Creates the event callback linkage between the the MS program represented - * by the Dispatch object and the Java object that will receive the - * callback. - * - * @param sourceOfEvent - * Dispatch object who's MS app will generate callbacks - * @param eventSink - * Java object that wants to receive the events - */ - public ActiveXDispatchEvents(Dispatch sourceOfEvent, Object eventSink) { - super(sourceOfEvent, eventSink, null); - } + /** + * This is the most commonly used constructor. + *

+ * Creates the event callback linkage between the the MS program represented + * by the Dispatch object and the Java object that will receive the + * callback. + * + * @param sourceOfEvent + * Dispatch object who's MS app will generate callbacks + * @param eventSink + * Java object that wants to receive the events + */ + public ActiveXDispatchEvents(Dispatch sourceOfEvent, Object eventSink) { + super(sourceOfEvent, eventSink, null); + } - /** - * None of the samples use this constructor. - *

- * Creates the event callback linkage between the the MS program represented - * by the Dispatch object and the Java object that will receive the - * callback. - * - * @param sourceOfEvent - * Dispatch object who's MS app will generate callbacks - * @param eventSink - * Java object that wants to receive the events - * @param progId - * ??? - */ - public ActiveXDispatchEvents(Dispatch sourceOfEvent, Object eventSink, - String progId) { - super(sourceOfEvent, eventSink, progId, null); - } + /** + * None of the samples use this constructor. + *

+ * Creates the event callback linkage between the the MS program represented + * by the Dispatch object and the Java object that will receive the + * callback. + * + * @param sourceOfEvent + * Dispatch object who's MS app will generate callbacks + * @param eventSink + * Java object that wants to receive the events + * @param progId + * ??? + */ + public ActiveXDispatchEvents(Dispatch sourceOfEvent, Object eventSink, + String progId) { + super(sourceOfEvent, eventSink, progId, null); + } - /** - * Creates the event callback linkage between the the MS program represented - * by the Dispatch object and the Java object that will receive the - * callback. - * - *

-	 * >ActiveXDispatchEvents de = 
-	 * 			new ActiveXDispatchEvents(someDispatch,someEventHAndler,
-	 * 				"Excel.Application",
-	 * 				"C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE");
-	 * 
-	 * @param sourceOfEvent Dispatch object who's MS app will generate callbacks
-	 * @param eventSink Java object that wants to receive the events
-	 * @param progId , mandatory if the typelib is specified
-	 * @param typeLib The location of the typelib to use
-	 * 
-	 */
-	public ActiveXDispatchEvents(Dispatch sourceOfEvent, Object eventSink,
-			String progId, String typeLib) {
-		super(sourceOfEvent, eventSink, progId, typeLib);
-	}
+    /**
+     * Creates the event callback linkage between the the MS program represented
+     * by the Dispatch object and the Java object that will receive the
+     * callback.
+     * 
+     * 
+     * >ActiveXDispatchEvents de = 
+     *             new ActiveXDispatchEvents(someDispatch,someEventHAndler,
+     *                 "Excel.Application",
+     *                 "C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE");
+     * 
+     * @param sourceOfEvent Dispatch object who's MS app will generate callbacks
+     * @param eventSink Java object that wants to receive the events
+     * @param progId , mandatory if the typelib is specified
+     * @param typeLib The location of the typelib to use
+     * 
+     */
+    public ActiveXDispatchEvents(Dispatch sourceOfEvent, Object eventSink,
+            String progId, String typeLib) {
+        super(sourceOfEvent, eventSink, progId, typeLib);
+    }
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see com.jacob.com.DispatchEvents#getInvocationProxy(java.lang.Object)
-	 */
-	protected InvocationProxy getInvocationProxy(Object pTargetObject) {
-		InvocationProxy newProxy = new ActiveXInvocationProxy();
-		newProxy.setTarget(pTargetObject);
-		return newProxy;
-	}
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.jacob.com.DispatchEvents#getInvocationProxy(java.lang.Object)
+     */
+    protected InvocationProxy getInvocationProxy(Object pTargetObject) {
+        InvocationProxy newProxy = new ActiveXInvocationProxy();
+        newProxy.setTarget(pTargetObject);
+        return newProxy;
+    }
 
 }
diff --git a/src/main/java/com/jacob/activeX/ActiveXInvocationProxy.java b/src/main/java/com/jacob/activeX/ActiveXInvocationProxy.java
index a34594b..87cc8bf 100644
--- a/src/main/java/com/jacob/activeX/ActiveXInvocationProxy.java
+++ b/src/main/java/com/jacob/activeX/ActiveXInvocationProxy.java
@@ -18,23 +18,23 @@
  *
  * This file incorporates work covered by the following copyright and
  * permission notice:
- * 	Copyright (c) 1999-2004 Sourceforge JACOB Project.
- * 	All rights reserved. Originator: Dan Adler (http://danadler.com).
- * 	Get more information about JACOB at http://sourceforge.net/projects/jacob-project
+ *     Copyright (c) 1999-2004 Sourceforge JACOB Project.
+ *     All rights reserved. Originator: Dan Adler (http://danadler.com).
+ *     Get more information about JACOB at http://sourceforge.net/projects/jacob-project
  *
- * 	This library is free software; you can redistribute it and/or
- * 	modify it under the terms of the GNU Lesser General Public
- * 	License as published by the Free Software Foundation; either
- * 	version 2.1 of the License, or (at your option) any later version.
+ *     This library is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU Lesser General Public
+ *     License as published by the Free Software Foundation; either
+ *     version 2.1 of the License, or (at your option) any later version.
  *
- * 	This library is distributed in the hope that it will be useful,
- * 	but WITHOUT ANY WARRANTY; without even the implied warranty of
- * 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * 	Lesser General Public License for more details.
+ *     This library is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *     Lesser General Public License for more details.
  *
- * 	You should have received a copy of the GNU Lesser General Public
- * 	License along with this library; if not, write to the Free Software
- * 	Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *     You should have received a copy of the GNU Lesser General Public
+ *     License along with this library; if not, write to the Free Software
+ *     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 package com.jacob.activeX;
 
@@ -72,131 +72,131 @@ import com.jacob.com.Variant;
  */
 public class ActiveXInvocationProxy extends InvocationProxy {
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see com.jacob.com.InvocationProxy#invoke(java.lang.String,
-	 *      com.jacob.com.Variant[])
-	 */
-	@SuppressWarnings("unchecked")
-	public Variant invoke(String methodName, Variant targetParameters[]) {
-		Variant mVariantToBeReturned = null;
-		if (mTargetObject == null) {
-			// structured programming guidlines say this return should not be up
-			// here
-			return null;
-		}
-		Class targetClass = mTargetObject.getClass();
-		if (methodName == null) {
-			throw new IllegalArgumentException(
-					"InvocationProxy: missing method name");
-		}
-		if (targetParameters == null) {
-			throw new IllegalArgumentException(
-					"InvocationProxy: missing Variant parameters");
-		}
-		try {
-			Method targetMethod;
-			Object parametersAsJavaObjects[] = getParametersAsJavaObjects(targetParameters);
-			Class parametersAsJavaClasses[] = getParametersAsJavaClasses(parametersAsJavaObjects);
-			targetMethod = targetClass.getMethod(methodName,
-					parametersAsJavaClasses);
-			if (targetMethod != null) {
-				// protected classes can't be invoked against even if they
-				// let you grab the method. you could do
-				// targetMethod.setAccessible(true);
-				// but that should be stopped by the security manager
-				Object mReturnedByInvocation = null;
-				mReturnedByInvocation = targetMethod.invoke(mTargetObject,
-						parametersAsJavaObjects);
-				if (mReturnedByInvocation == null) {
-					mVariantToBeReturned = null;
-				} else if (!(mReturnedByInvocation instanceof Variant)) {
-					mVariantToBeReturned = new Variant(mReturnedByInvocation);
-				} else {
-					mVariantToBeReturned = (Variant) mReturnedByInvocation;
-				}
-			}
-		} catch (SecurityException e) {
-			// what causes this exception?
-			e.printStackTrace();
-		} catch (NoSuchMethodException e) {
-			// this happens whenever the listener doesn't implement all the
-			// methods
-		} catch (IllegalArgumentException e) {
-			// we can throw these inside the catch block so need to re-throw it
-			Exception oneWeShouldToss = new IllegalArgumentException(
-					"Unable to map parameters for method " + methodName + ": "
-							+ e.toString());
-			oneWeShouldToss.printStackTrace();
-		} catch (IllegalAccessException e) {
-			// can't access the method on the target instance for some reason
-			e.printStackTrace();
-		} catch (InvocationTargetException e) {
-			// invocation of target method failed
-			e.printStackTrace();
-		}
-		return mVariantToBeReturned;
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.jacob.com.InvocationProxy#invoke(java.lang.String,
+     *      com.jacob.com.Variant[])
+     */
+    @SuppressWarnings("unchecked")
+    public Variant invoke(String methodName, Variant targetParameters[]) {
+        Variant mVariantToBeReturned = null;
+        if (mTargetObject == null) {
+            // structured programming guidlines say this return should not be up
+            // here
+            return null;
+        }
+        Class targetClass = mTargetObject.getClass();
+        if (methodName == null) {
+            throw new IllegalArgumentException(
+                    "InvocationProxy: missing method name");
+        }
+        if (targetParameters == null) {
+            throw new IllegalArgumentException(
+                    "InvocationProxy: missing Variant parameters");
+        }
+        try {
+            Method targetMethod;
+            Object parametersAsJavaObjects[] = getParametersAsJavaObjects(targetParameters);
+            Class parametersAsJavaClasses[] = getParametersAsJavaClasses(parametersAsJavaObjects);
+            targetMethod = targetClass.getMethod(methodName,
+                    parametersAsJavaClasses);
+            if (targetMethod != null) {
+                // protected classes can't be invoked against even if they
+                // let you grab the method. you could do
+                // targetMethod.setAccessible(true);
+                // but that should be stopped by the security manager
+                Object mReturnedByInvocation = null;
+                mReturnedByInvocation = targetMethod.invoke(mTargetObject,
+                        parametersAsJavaObjects);
+                if (mReturnedByInvocation == null) {
+                    mVariantToBeReturned = null;
+                } else if (!(mReturnedByInvocation instanceof Variant)) {
+                    mVariantToBeReturned = new Variant(mReturnedByInvocation);
+                } else {
+                    mVariantToBeReturned = (Variant) mReturnedByInvocation;
+                }
+            }
+        } catch (SecurityException e) {
+            // what causes this exception?
+            e.printStackTrace();
+        } catch (NoSuchMethodException e) {
+            // this happens whenever the listener doesn't implement all the
+            // methods
+        } catch (IllegalArgumentException e) {
+            // we can throw these inside the catch block so need to re-throw it
+            Exception oneWeShouldToss = new IllegalArgumentException(
+                    "Unable to map parameters for method " + methodName + ": "
+                            + e.toString());
+            oneWeShouldToss.printStackTrace();
+        } catch (IllegalAccessException e) {
+            // can't access the method on the target instance for some reason
+            e.printStackTrace();
+        } catch (InvocationTargetException e) {
+            // invocation of target method failed
+            e.printStackTrace();
+        }
+        return mVariantToBeReturned;
 
-	}
+    }
 
-	/**
-	 * creates a method signature compatible array of classes from an array of
-	 * parameters
-	 * 
-	 * @param parametersAsJavaObjects
-	 * @return
-	 */
-	@SuppressWarnings("unchecked")
-	private Class[] getParametersAsJavaClasses(Object[] parametersAsJavaObjects) {
-		if (parametersAsJavaObjects == null) {
-			throw new IllegalArgumentException(
-					"This only works with an array of parameters");
-		}
-		int numParameters = parametersAsJavaObjects.length;
-		Class parametersAsJavaClasses[] = new Class[numParameters];
-		for (int parameterIndex = 0; parameterIndex < numParameters; parameterIndex++) {
-			Object oneParameterObject = parametersAsJavaObjects[parameterIndex];
-			if (oneParameterObject == null) {
-				parametersAsJavaClasses[parameterIndex] = null;
-			} else {
-				Class oneParameterClass = oneParameterObject.getClass();
-				parametersAsJavaClasses[parameterIndex] = oneParameterClass;
-			}
-		}
-		return parametersAsJavaClasses;
-	}
+    /**
+     * creates a method signature compatible array of classes from an array of
+     * parameters
+     * 
+     * @param parametersAsJavaObjects
+     * @return
+     */
+    @SuppressWarnings("unchecked")
+    private Class[] getParametersAsJavaClasses(Object[] parametersAsJavaObjects) {
+        if (parametersAsJavaObjects == null) {
+            throw new IllegalArgumentException(
+                    "This only works with an array of parameters");
+        }
+        int numParameters = parametersAsJavaObjects.length;
+        Class parametersAsJavaClasses[] = new Class[numParameters];
+        for (int parameterIndex = 0; parameterIndex < numParameters; parameterIndex++) {
+            Object oneParameterObject = parametersAsJavaObjects[parameterIndex];
+            if (oneParameterObject == null) {
+                parametersAsJavaClasses[parameterIndex] = null;
+            } else {
+                Class oneParameterClass = oneParameterObject.getClass();
+                parametersAsJavaClasses[parameterIndex] = oneParameterClass;
+            }
+        }
+        return parametersAsJavaClasses;
+    }
 
-	/**
-	 * converts an array of Variants to their associated Java types
-	 * 
-	 * @param targetParameters
-	 * @return
-	 */
-	private Object[] getParametersAsJavaObjects(Variant[] targetParameters) {
-		if (targetParameters == null) {
-			throw new IllegalArgumentException(
-					"This only works with an array of parameters");
-		}
-		int numParameters = targetParameters.length;
-		Object parametersAsJavaObjects[] = new Object[numParameters];
-		for (int parameterIndex = 0; parameterIndex < numParameters; parameterIndex++) {
-			Variant oneParameterObject = targetParameters[parameterIndex];
-			if (oneParameterObject == null) {
-				parametersAsJavaObjects[parameterIndex] = null;
-			} else {
-				try {
-					parametersAsJavaObjects[parameterIndex] = oneParameterObject
-							.toJavaObject();
-				} catch (NotImplementedException nie) {
-					throw new IllegalArgumentException(
-							"Can't convert parameter " + parameterIndex
-									+ " type " + oneParameterObject.getvt()
-									+ " to java object: " + nie.getMessage());
-				}
-			}
-		}
-		return parametersAsJavaObjects;
-	}
+    /**
+     * converts an array of Variants to their associated Java types
+     * 
+     * @param targetParameters
+     * @return
+     */
+    private Object[] getParametersAsJavaObjects(Variant[] targetParameters) {
+        if (targetParameters == null) {
+            throw new IllegalArgumentException(
+                    "This only works with an array of parameters");
+        }
+        int numParameters = targetParameters.length;
+        Object parametersAsJavaObjects[] = new Object[numParameters];
+        for (int parameterIndex = 0; parameterIndex < numParameters; parameterIndex++) {
+            Variant oneParameterObject = targetParameters[parameterIndex];
+            if (oneParameterObject == null) {
+                parametersAsJavaObjects[parameterIndex] = null;
+            } else {
+                try {
+                    parametersAsJavaObjects[parameterIndex] = oneParameterObject
+                            .toJavaObject();
+                } catch (NotImplementedException nie) {
+                    throw new IllegalArgumentException(
+                            "Can't convert parameter " + parameterIndex
+                                    + " type " + oneParameterObject.getvt()
+                                    + " to java object: " + nie.getMessage());
+                }
+            }
+        }
+        return parametersAsJavaObjects;
+    }
 
 }
diff --git a/src/main/java/com/jacob/com/ComException.java b/src/main/java/com/jacob/com/ComException.java
index 350a64a..cbe385e 100644
--- a/src/main/java/com/jacob/com/ComException.java
+++ b/src/main/java/com/jacob/com/ComException.java
@@ -18,23 +18,23 @@
  *
  * This file incorporates work covered by the following copyright and
  * permission notice:
- * 	Copyright (c) 1999-2004 Sourceforge JACOB Project.
- * 	All rights reserved. Originator: Dan Adler (http://danadler.com).
- * 	Get more information about JACOB at http://sourceforge.net/projects/jacob-project
+ *     Copyright (c) 1999-2004 Sourceforge JACOB Project.
+ *     All rights reserved. Originator: Dan Adler (http://danadler.com).
+ *     Get more information about JACOB at http://sourceforge.net/projects/jacob-project
  *
- * 	This library is free software; you can redistribute it and/or
- * 	modify it under the terms of the GNU Lesser General Public
- * 	License as published by the Free Software Foundation; either
- * 	version 2.1 of the License, or (at your option) any later version.
+ *     This library is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU Lesser General Public
+ *     License as published by the Free Software Foundation; either
+ *     version 2.1 of the License, or (at your option) any later version.
  *
- * 	This library is distributed in the hope that it will be useful,
- * 	but WITHOUT ANY WARRANTY; without even the implied warranty of
- * 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * 	Lesser General Public License for more details.
+ *     This library is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *     Lesser General Public License for more details.
  *
- * 	You should have received a copy of the GNU Lesser General Public
- * 	License along with this library; if not, write to the Free Software
- * 	Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *     You should have received a copy of the GNU Lesser General Public
+ *     License along with this library; if not, write to the Free Software
+ *     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 package com.jacob.com;
 
@@ -43,118 +43,118 @@ package com.jacob.com;
  */
 public abstract class ComException extends JacobException {
 
-	/**
-	 * COM code initializes this filed with an appropriate return code that was
-	 * returned by the underlying com code
-	 */
-	protected int hr;
-	/**
-	 * No documentation is available at this time. Someone should document this
-	 * field
-	 */
-	protected int m_helpContext;
-	/**
-	 * No documentation is available at this time. Someone should document this
-	 * field
-	 */
-	protected String m_helpFile;
-	/**
-	 * No documentation is available at this time. Someone should document this
-	 * field
-	 */
-	protected String m_source;
+    /**
+     * COM code initializes this filed with an appropriate return code that was
+     * returned by the underlying com code
+     */
+    protected int hr;
+    /**
+     * No documentation is available at this time. Someone should document this
+     * field
+     */
+    protected int m_helpContext;
+    /**
+     * No documentation is available at this time. Someone should document this
+     * field
+     */
+    protected String m_helpFile;
+    /**
+     * No documentation is available at this time. Someone should document this
+     * field
+     */
+    protected String m_source;
 
-	/**
-	 * constructor
-	 * 
-	 */
-	public ComException() {
-		super();
-	}
+    /**
+     * constructor
+     * 
+     */
+    public ComException() {
+        super();
+    }
 
-	/**
-	 * constructor with error code?
-	 * 
-	 * @param newHr ??
-	 */
-	public ComException(int newHr) {
-		super();
-		this.hr = newHr;
-	}
+    /**
+     * constructor with error code?
+     * 
+     * @param newHr ??
+     */
+    public ComException(int newHr) {
+        super();
+        this.hr = newHr;
+    }
 
-	/**
-	 * @param newHr
-	 * @param description
-	 */
-	public ComException(int newHr, String description) {
-		super(description);
-		this.hr = newHr;
-	}
+    /**
+     * @param newHr
+     * @param description
+     */
+    public ComException(int newHr, String description) {
+        super(description);
+        this.hr = newHr;
+    }
 
-	/**
-	 * @param newHr
-	 * @param source
-	 * @param helpFile
-	 * @param helpContext
-	 */
-	public ComException(int newHr, String source, String helpFile,
-			int helpContext) {
-		super();
-		this.hr = newHr;
-		m_source = source;
-		m_helpFile = helpFile;
-		m_helpContext = helpContext;
-	}
+    /**
+     * @param newHr
+     * @param source
+     * @param helpFile
+     * @param helpContext
+     */
+    public ComException(int newHr, String source, String helpFile,
+            int helpContext) {
+        super();
+        this.hr = newHr;
+        m_source = source;
+        m_helpFile = helpFile;
+        m_helpContext = helpContext;
+    }
 
-	/**
-	 * @param newHr
-	 * @param description
-	 * @param source
-	 * @param helpFile
-	 * @param helpContext
-	 */
-	public ComException(int newHr, String description, String source,
-			String helpFile, int helpContext) {
-		super(description);
-		this.hr = newHr;
-		m_source = source;
-		m_helpFile = helpFile;
-		m_helpContext = helpContext;
-	}
+    /**
+     * @param newHr
+     * @param description
+     * @param source
+     * @param helpFile
+     * @param helpContext
+     */
+    public ComException(int newHr, String description, String source,
+            String helpFile, int helpContext) {
+        super(description);
+        this.hr = newHr;
+        m_source = source;
+        m_helpFile = helpFile;
+        m_helpContext = helpContext;
+    }
 
-	/**
-	 * @param description
-	 */
-	public ComException(String description) {
-		super(description);
-	}
+    /**
+     * @param description
+     */
+    public ComException(String description) {
+        super(description);
+    }
 
-	/**
-	 * @return int representation of the help context
-	 */
-	// Methods
-	public int getHelpContext() {
-		return m_helpContext;
-	}
+    /**
+     * @return int representation of the help context
+     */
+    // Methods
+    public int getHelpContext() {
+        return m_helpContext;
+    }
 
-	/**
-	 * @return String ??? help file
-	 */
-	public String getHelpFile() {
-		return m_helpFile;
-	}
+    /**
+     * @return String ??? help file
+     */
+    public String getHelpFile() {
+        return m_helpFile;
+    }
 
-	/**
-	 * @return int hr result ??
-	 */
-	public int getHResult() {
-		return hr;
-	}
+    /**
+     * @return int hr result ??
+     */
+    public int getHResult() {
+        return hr;
+    }
 
-	/**
-	 * @return String source ??
-	 */
-	public String getSource() {
-		return m_source;
-	}
+    /**
+     * @return String source ??
+     */
+    public String getSource() {
+        return m_source;
+    }
 }
\ No newline at end of file
diff --git a/src/main/java/com/jacob/com/ComFailException.java b/src/main/java/com/jacob/com/ComFailException.java
index 7a0a5b7..391fa4e 100644
--- a/src/main/java/com/jacob/com/ComFailException.java
+++ b/src/main/java/com/jacob/com/ComFailException.java
@@ -18,23 +18,23 @@
  *
  * This file incorporates work covered by the following copyright and
  * permission notice:
- * 	Copyright (c) 1999-2004 Sourceforge JACOB Project.
- * 	All rights reserved. Originator: Dan Adler (http://danadler.com).
- * 	Get more information about JACOB at http://sourceforge.net/projects/jacob-project
+ *     Copyright (c) 1999-2004 Sourceforge JACOB Project.
+ *     All rights reserved. Originator: Dan Adler (http://danadler.com).
+ *     Get more information about JACOB at http://sourceforge.net/projects/jacob-project
  *
- * 	This library is free software; you can redistribute it and/or
- * 	modify it under the terms of the GNU Lesser General Public
- * 	License as published by the Free Software Foundation; either
- * 	version 2.1 of the License, or (at your option) any later version.
+ *     This library is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU Lesser General Public
+ *     License as published by the Free Software Foundation; either
+ *     version 2.1 of the License, or (at your option) any later version.
  *
- * 	This library is distributed in the hope that it will be useful,
- * 	but WITHOUT ANY WARRANTY; without even the implied warranty of
- * 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * 	Lesser General Public License for more details.
+ *     This library is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *     Lesser General Public License for more details.
  *
- * 	You should have received a copy of the GNU Lesser General Public
- * 	License along with this library; if not, write to the Free Software
- * 	Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *     You should have received a copy of the GNU Lesser General Public
+ *     License along with this library; if not, write to the Free Software
+ *     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 package com.jacob.com;
 
@@ -42,66 +42,66 @@ package com.jacob.com;
  * COM Fail Exception class raised when there is a problem
  */
 public class ComFailException extends ComException {
-	/**
-	 * eclipse generated to get rid of a wanring
-	 */
-	private static final long serialVersionUID = -266047261992987700L;
+    /**
+     * eclipse generated to get rid of a wanring
+     */
+    private static final long serialVersionUID = -266047261992987700L;
 
-	/**
-	 * Constructor
-	 * 
-	 * @param hrNew
-	 */
-	public ComFailException(int hrNew) {
-		super(hrNew);
-	}
+    /**
+     * Constructor
+     * 
+     * @param hrNew
+     */
+    public ComFailException(int hrNew) {
+        super(hrNew);
+    }
 
-	/**
-	 * Constructor
-	 * 
-	 * @param hrNew
-	 * @param message
-	 */
-	public ComFailException(int hrNew, String message) {
-		super(hrNew, message);
-	}
+    /**
+     * Constructor
+     * 
+     * @param hrNew
+     * @param message
+     */
+    public ComFailException(int hrNew, String message) {
+        super(hrNew, message);
+    }
 
-	/**
-	 * @param hrNew
-	 * @param source
-	 * @param helpFile
-	 * @param helpContext
-	 */
-	public ComFailException(int hrNew, String source, String helpFile,
-			int helpContext) {
-		super(hrNew, source, helpFile, helpContext);
-	}
+    /**
+     * @param hrNew
+     * @param source
+     * @param helpFile
+     * @param helpContext
+     */
+    public ComFailException(int hrNew, String source, String helpFile,
+            int helpContext) {
+        super(hrNew, source, helpFile, helpContext);
+    }
 
-	/**
-	 * Constructor
-	 * 
-	 * @param hrNew
-	 * @param description
-	 * @param source
-	 * @param helpFile
-	 * @param helpContext
-	 */
-	public ComFailException(int hrNew, String description, String source,
-			String helpFile, int helpContext) {
-		super(hrNew, description, source, helpFile, helpContext);
-	}
+    /**
+     * Constructor
+     * 
+     * @param hrNew
+     * @param description
+     * @param source
+     * @param helpFile
+     * @param helpContext
+     */
+    public ComFailException(int hrNew, String description, String source,
+            String helpFile, int helpContext) {
+        super(hrNew, description, source, helpFile, helpContext);
+    }
 
-	/**
-	 * No argument Constructor
-	 */
-	public ComFailException() {
-		super();
-	}
+    /**
+     * No argument Constructor
+     */
+    public ComFailException() {
+        super();
+    }
 
-	/**
-	 * @param message
-	 */
-	public ComFailException(String message) {
-		super(message);
-	}
+    /**
+     * @param message
+     */
+    public ComFailException(String message) {
+        super(message);
+    }
 }
\ No newline at end of file
diff --git a/src/main/java/com/jacob/com/ComThread.java b/src/main/java/com/jacob/com/ComThread.java
index 6d9c016..cbcdc6a 100644
--- a/src/main/java/com/jacob/com/ComThread.java
+++ b/src/main/java/com/jacob/com/ComThread.java
@@ -18,23 +18,23 @@
  *
  * This file incorporates work covered by the following copyright and
  * permission notice:
- * 	Copyright (c) 1999-2004 Sourceforge JACOB Project.
- * 	All rights reserved. Originator: Dan Adler (http://danadler.com).
- * 	Get more information about JACOB at http://sourceforge.net/projects/jacob-project
+ *     Copyright (c) 1999-2004 Sourceforge JACOB Project.
+ *     All rights reserved. Originator: Dan Adler (http://danadler.com).
+ *     Get more information about JACOB at http://sourceforge.net/projects/jacob-project
  *
- * 	This library is free software; you can redistribute it and/or
- * 	modify it under the terms of the GNU Lesser General Public
- * 	License as published by the Free Software Foundation; either
- * 	version 2.1 of the License, or (at your option) any later version.
+ *     This library is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU Lesser General Public
+ *     License as published by the Free Software Foundation; either
+ *     version 2.1 of the License, or (at your option) any later version.
  *
- * 	This library is distributed in the hope that it will be useful,
- * 	but WITHOUT ANY WARRANTY; without even the implied warranty of
- * 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * 	Lesser General Public License for more details.
+ *     This library is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *     Lesser General Public License for more details.
  *
- * 	You should have received a copy of the GNU Lesser General Public
- * 	License along with this library; if not, write to the Free Software
- * 	Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *     You should have received a copy of the GNU Lesser General Public
+ *     License along with this library; if not, write to the Free Software
+ *     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 package com.jacob.com;
 
@@ -43,146 +43,146 @@ package com.jacob.com;
  * methods are static and no instances are ever created.
  */
 public abstract class ComThread {
-	private static final int MTA = 0x0;
+    private static final int MTA = 0x0;
 
-	private static final int STA = 0x2;
+    private static final int STA = 0x2;
 
-	/**
-	 * Comment for haveSTA
-	 */
-	public static boolean haveSTA = false;
+    /**
+     * Comment for haveSTA
+     */
+    public static boolean haveSTA = false;
 
-	/**
-	 * Comment for mainSTA
-	 */
-	public static MainSTA mainSTA = null;
+    /**
+     * Comment for mainSTA
+     */
+    public static MainSTA mainSTA = null;
 
-	/**
-	 * Initialize the current java thread to be part of the Multi-threaded COM
-	 * Apartment
-	 */
-	public static synchronized void InitMTA() {
-		InitMTA(false);
-	}
+    /**
+     * Initialize the current java thread to be part of the Multi-threaded COM
+     * Apartment
+     */
+    public static synchronized void InitMTA() {
+        InitMTA(false);
+    }
 
-	/**
-	 * Initialize the current java thread to be an STA
-	 */
-	public static synchronized void InitSTA() {
-		InitSTA(false);
-	}
+    /**
+     * Initialize the current java thread to be an STA
+     */
+    public static synchronized void InitSTA() {
+        InitSTA(false);
+    }
 
-	/**
-	 * Initialize the current java thread to be part of the Multi-threaded COM
-	 * Apartment, if createMainSTA is true, create a separate MainSTA thread
-	 * that will house all Apartment Threaded components
-	 * 
-	 * @param createMainSTA
-	 */
-	public static synchronized void InitMTA(boolean createMainSTA) {
-		Init(createMainSTA, MTA);
-	}
+    /**
+     * Initialize the current java thread to be part of the Multi-threaded COM
+     * Apartment, if createMainSTA is true, create a separate MainSTA thread
+     * that will house all Apartment Threaded components
+     * 
+     * @param createMainSTA
+     */
+    public static synchronized void InitMTA(boolean createMainSTA) {
+        Init(createMainSTA, MTA);
+    }
 
-	/**
-	 * Initialize the current java thread to be an STA COM Apartment, if
-	 * createMainSTA is true, create a separate MainSTA thread that will house
-	 * all Apartment Threaded components
-	 * 
-	 * @param createMainSTA
-	 */
-	public static synchronized void InitSTA(boolean createMainSTA) {
-		Init(createMainSTA, STA);
-	}
+    /**
+     * Initialize the current java thread to be an STA COM Apartment, if
+     * createMainSTA is true, create a separate MainSTA thread that will house
+     * all Apartment Threaded components
+     * 
+     * @param createMainSTA
+     */
+    public static synchronized void InitSTA(boolean createMainSTA) {
+        Init(createMainSTA, STA);
+    }
 
-	/**
-	 * 
-	 */
-	public static synchronized void startMainSTA() {
-		mainSTA = new MainSTA();
-		haveSTA = true;
-	}
+    /**
+     * 
+     */
+    public static synchronized void startMainSTA() {
+        mainSTA = new MainSTA();
+        haveSTA = true;
+    }
 
-	/**
-	 * 
-	 */
-	public static synchronized void quitMainSTA() {
-		if (mainSTA != null)
-			mainSTA.quit();
-	}
+    /**
+     * 
+     */
+    public static synchronized void quitMainSTA() {
+        if (mainSTA != null)
+            mainSTA.quit();
+    }
 
-	/**
-	 * Initialize the current java thread to be part of the MTA/STA COM
-	 * Apartment
-	 * 
-	 * @param createMainSTA
-	 * @param mode
-	 */
-	public static synchronized void Init(boolean createMainSTA, int mode) {
-		if (createMainSTA && !haveSTA) {
-			// if the current thread is going to be in the MTA and there
-			// is no STA thread yet, then create a main STA thread
-			// to avoid COM creating its own
-			startMainSTA();
-		}
-		if (JacobObject.isDebugEnabled()) {
-			JacobObject.debug("ComThread: before Init: " + mode);
-		}
-		doCoInitialize(mode);
-		if (JacobObject.isDebugEnabled()) {
-			JacobObject.debug("ComThread: after Init: " + mode);
-		}
-		ROT.addThread();
-		if (JacobObject.isDebugEnabled()) {
-			JacobObject.debug("ComThread: after ROT.addThread: " + mode);
-		}
-	}
+    /**
+     * Initialize the current java thread to be part of the MTA/STA COM
+     * Apartment
+     * 
+     * @param createMainSTA
+     * @param mode
+     */
+    public static synchronized void Init(boolean createMainSTA, int mode) {
+        if (createMainSTA && !haveSTA) {
+            // if the current thread is going to be in the MTA and there
+            // is no STA thread yet, then create a main STA thread
+            // to avoid COM creating its own
+            startMainSTA();
+        }
+        if (JacobObject.isDebugEnabled()) {
+            JacobObject.debug("ComThread: before Init: " + mode);
+        }
+        doCoInitialize(mode);
+        if (JacobObject.isDebugEnabled()) {
+            JacobObject.debug("ComThread: after Init: " + mode);
+        }
+        ROT.addThread();
+        if (JacobObject.isDebugEnabled()) {
+            JacobObject.debug("ComThread: after ROT.addThread: " + mode);
+        }
+    }
 
-	/**
-	 * Call CoUninitialize to release this java thread from COM
-	 */
-	public static synchronized void Release() {
-		if (JacobObject.isDebugEnabled()) {
-			JacobObject.debug("ComThread: before clearObjects");
-		}
-		ROT.clearObjects();
-		if (JacobObject.isDebugEnabled()) {
-			JacobObject.debug("ComThread: before UnInit");
-		}
-		doCoUninitialize();
-		if (JacobObject.isDebugEnabled()) {
-			JacobObject.debug("ComThread: after UnInit");
-		}
-	}
+    /**
+     * Call CoUninitialize to release this java thread from COM
+     */
+    public static synchronized void Release() {
+        if (JacobObject.isDebugEnabled()) {
+            JacobObject.debug("ComThread: before clearObjects");
+        }
+        ROT.clearObjects();
+        if (JacobObject.isDebugEnabled()) {
+            JacobObject.debug("ComThread: before UnInit");
+        }
+        doCoUninitialize();
+        if (JacobObject.isDebugEnabled()) {
+            JacobObject.debug("ComThread: after UnInit");
+        }
+    }
 
-	/**
-	 * @deprecated the java model leave the responsibility of clearing up
-	 *             objects to the Garbage Collector. Our programming model
-	 *             should not require that the user specifically remove object
-	 *             from the thread.
-	 * 
-	 * This will remove an object from the ROT
-	 * @param o
-	 */
-	@Deprecated
-	public static synchronized void RemoveObject(JacobObject o) {
-		ROT.removeObject(o);
-	}
+    /**
+     * @deprecated the java model leave the responsibility of clearing up
+     *             objects to the Garbage Collector. Our programming model
+     *             should not require that the user specifically remove object
+     *             from the thread.
+     * 
+     * This will remove an object from the ROT
+     * @param o
+     */
+    @Deprecated
+    public static synchronized void RemoveObject(JacobObject o) {
+        ROT.removeObject(o);
+    }
 
-	/**
-	 * @param threadModel
-	 */
-	public static native void doCoInitialize(int threadModel);
+    /**
+     * @param threadModel
+     */
+    public static native void doCoInitialize(int threadModel);
 
-	/**
-	 * 
-	 */
-	public static native void doCoUninitialize();
+    /**
+     * 
+     */
+    public static native void doCoUninitialize();
 
-	/**
-	 * load the Jacob DLL. We do this in case COMThread is called before any
-	 * other reference to one of the JacboObject subclasses is made.
-	 */
-	static {
-		LibraryLoader.loadJacobLibrary();
-	}
+    /**
+     * load the Jacob DLL. We do this in case COMThread is called before any
+     * other reference to one of the JacboObject subclasses is made.
+     */
+    static {
+        LibraryLoader.loadJacobLibrary();
+    }
 }
\ No newline at end of file
diff --git a/src/main/java/com/jacob/com/Currency.java b/src/main/java/com/jacob/com/Currency.java
index aa04b6b..d73c01c 100644
--- a/src/main/java/com/jacob/com/Currency.java
+++ b/src/main/java/com/jacob/com/Currency.java
@@ -18,23 +18,23 @@
  *
  * This file incorporates work covered by the following copyright and
  * permission notice:
- * 	Copyright (c) 1999-2004 Sourceforge JACOB Project.
- * 	All rights reserved. Originator: Dan Adler (http://danadler.com).
- * 	Get more information about JACOB at http://sourceforge.net/projects/jacob-project
+ *     Copyright (c) 1999-2004 Sourceforge JACOB Project.
+ *     All rights reserved. Originator: Dan Adler (http://danadler.com).
+ *     Get more information about JACOB at http://sourceforge.net/projects/jacob-project
  *
- * 	This library is free software; you can redistribute it and/or
- * 	modify it under the terms of the GNU Lesser General Public
- * 	License as published by the Free Software Foundation; either
- * 	version 2.1 of the License, or (at your option) any later version.
+ *     This library is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU Lesser General Public
+ *     License as published by the Free Software Foundation; either
+ *     version 2.1 of the License, or (at your option) any later version.
  *
- * 	This library is distributed in the hope that it will be useful,
- * 	but WITHOUT ANY WARRANTY; without even the implied warranty of
- * 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * 	Lesser General Public License for more details.
+ *     This library is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *     Lesser General Public License for more details.
  *
- * 	You should have received a copy of the GNU Lesser General Public
- * 	License along with this library; if not, write to the Free Software
- * 	Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *     You should have received a copy of the GNU Lesser General Public
+ *     License along with this library; if not, write to the Free Software
+ *     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 package com.jacob.com;
 
@@ -49,81 +49,81 @@ package com.jacob.com;
  * In the future, this should convert to and from BigDecimal or Double
  */
 public class Currency {
-	Long embeddedValue = null;
+    Long embeddedValue = null;
 
-	/**
-	 * constructor that takes a long already in COM representation
-	 * 
-	 * @param newValue
-	 */
-	public Currency(long newValue) {
-		embeddedValue = new Long(newValue);
-	}
+    /**
+     * constructor that takes a long already in COM representation
+     * 
+     * @param newValue
+     */
+    public Currency(long newValue) {
+        embeddedValue = new Long(newValue);
+    }
 
-	/**
-	 * constructor that takes a String already in COM representation
-	 * 
-	 * @param newValue
-	 */
-	public Currency(String newValue) {
-		embeddedValue = new Long(newValue);
-	}
+    /**
+     * constructor that takes a String already in COM representation
+     * 
+     * @param newValue
+     */
+    public Currency(String newValue) {
+        embeddedValue = new Long(newValue);
+    }
 
-	/**
-	 * 
-	 * @return the currency as a primitive long
-	 */
-	public long longValue() {
-		return embeddedValue.longValue();
-	}
+    /**
+     * 
+     * @return the currency as a primitive long
+     */
+    public long longValue() {
+        return embeddedValue.longValue();
+    }
 
-	/**
-	 * getter to the inner storage so that cmpareTo can work
-	 * 
-	 * @return the embedded long value
-	 */
-	protected Long getLongValue() {
-		return embeddedValue;
-	}
+    /**
+     * getter to the inner storage so that cmpareTo can work
+     * 
+     * @return the embedded long value
+     */
+    protected Long getLongValue() {
+        return embeddedValue;
+    }
 
-	/**
-	 * compares the values of two currencies
-	 * 
-	 * @param anotherCurrency
-	 * @return the usual compareTo results
-	 */
-	public int compareTo(Currency anotherCurrency) {
-		return embeddedValue.compareTo(anotherCurrency.getLongValue());
-	}
+    /**
+     * compares the values of two currencies
+     * 
+     * @param anotherCurrency
+     * @return the usual compareTo results
+     */
+    public int compareTo(Currency anotherCurrency) {
+        return embeddedValue.compareTo(anotherCurrency.getLongValue());
+    }
 
-	/**
-	 * standard comparison
-	 * 
-	 * @param o
-	 *            must be Currency or Long
-	 * @return the usual compareTo results
-	 */
-	public int compareTo(Object o) {
-		if (o instanceof Currency) {
-			return compareTo((Currency) o);
-		} else if (o instanceof Long) {
-			return embeddedValue.compareTo((Long) o);
-		} else
-			throw new IllegalArgumentException(
-					"Can only compare to Long and Currency not "
-							+ o.getClass().getName());
-	}
+    /**
+     * standard comparison
+     * 
+     * @param o
+     *            must be Currency or Long
+     * @return the usual compareTo results
+     */
+    public int compareTo(Object o) {
+        if (o instanceof Currency) {
+            return compareTo((Currency) o);
+        } else if (o instanceof Long) {
+            return embeddedValue.compareTo((Long) o);
+        } else
+            throw new IllegalArgumentException(
+                    "Can only compare to Long and Currency not "
+                            + o.getClass().getName());
+    }
 
-	/**
-	 * {@inheritDoc}
-	 */
-	public boolean equals(Object o) {
-		if (o == null) {
-			return false;
-		} else if (compareTo(o) == 0) {
-			return true;
-		} else {
-			return false;
-		}
-	}
+    /**
+     * {@inheritDoc}
+     */
+    public boolean equals(Object o) {
+        if (o == null) {
+            return false;
+        } else if (compareTo(o) == 0) {
+            return true;
+        } else {
+            return false;
+        }
+    }
 }
diff --git a/src/main/java/com/jacob/com/DateUtilities.java b/src/main/java/com/jacob/com/DateUtilities.java
index e6b9547..afcab64 100644
--- a/src/main/java/com/jacob/com/DateUtilities.java
+++ b/src/main/java/com/jacob/com/DateUtilities.java
@@ -18,23 +18,23 @@
  *
  * This file incorporates work covered by the following copyright and
  * permission notice:
- * 	Copyright (c) 1999-2004 Sourceforge JACOB Project.
- * 	All rights reserved. Originator: Dan Adler (http://danadler.com).
- * 	Get more information about JACOB at http://sourceforge.net/projects/jacob-project
+ *     Copyright (c) 1999-2004 Sourceforge JACOB Project.
+ *     All rights reserved. Originator: Dan Adler (http://danadler.com).
+ *     Get more information about JACOB at http://sourceforge.net/projects/jacob-project
  *
- * 	This library is free software; you can redistribute it and/or
- * 	modify it under the terms of the GNU Lesser General Public
- * 	License as published by the Free Software Foundation; either
- * 	version 2.1 of the License, or (at your option) any later version.
+ *     This library is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU Lesser General Public
+ *     License as published by the Free Software Foundation; either
+ *     version 2.1 of the License, or (at your option) any later version.
  *
- * 	This library is distributed in the hope that it will be useful,
- * 	but WITHOUT ANY WARRANTY; without even the implied warranty of
- * 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * 	Lesser General Public License for more details.
+ *     This library is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *     Lesser General Public License for more details.
  *
- * 	You should have received a copy of the GNU Lesser General Public
- * 	License along with this library; if not, write to the Free Software
- * 	Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *     You should have received a copy of the GNU Lesser General Public
+ *     License along with this library; if not, write to the Free Software
+ *     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 package com.jacob.com;
 
@@ -49,76 +49,76 @@ import java.util.Date;
  */
 public class DateUtilities {
 
-	/**
-	 * converts a windows time to a Java Date Object
-	 * 
-	 * @param comTime
-	 * @return Date object representing the windows time as specified in comTime
-	 */
-	static public Date convertWindowsTimeToDate(double comTime) {
-		return new Date(convertWindowsTimeToMilliseconds(comTime));
-	}
+    /**
+     * converts a windows time to a Java Date Object
+     * 
+     * @param comTime
+     * @return Date object representing the windows time as specified in comTime
+     */
+    static public Date convertWindowsTimeToDate(double comTime) {
+        return new Date(convertWindowsTimeToMilliseconds(comTime));
+    }
 
-	/**
-	 * Convert a COM time from functions Date(), Time(), Now() to a Java time
-	 * (milliseconds). Visual Basic time values are based to 30.12.1899, Java
-	 * time values are based to 1.1.1970 (= 0 milliseconds). The difference is
-	 * added to the Visual Basic value to get the corresponding Java value. The
-	 * Visual Basic double value reads: .<1
-	 * day percentage fraction>, e.g. "38100.6453" means: 38100 days since
-	 * 30.12.1899 plus (24 hours * 0.6453). Example usage:
-	 * Date javaDate = new Date(toMilliseconds (vbDate));.
-	 * 
-	 * @param comTime
-	 *            COM time.
-	 * @return Java time.
-	 */
-	static public long convertWindowsTimeToMilliseconds(double comTime) {
-		long result = 0;
+    /**
+     * Convert a COM time from functions Date(), Time(), Now() to a Java time
+     * (milliseconds). Visual Basic time values are based to 30.12.1899, Java
+     * time values are based to 1.1.1970 (= 0 milliseconds). The difference is
+     * added to the Visual Basic value to get the corresponding Java value. The
+     * Visual Basic double value reads: .<1
+     * day percentage fraction>, e.g. "38100.6453" means: 38100 days since
+     * 30.12.1899 plus (24 hours * 0.6453). Example usage:
+     * Date javaDate = new Date(toMilliseconds (vbDate));.
+     * 
+     * @param comTime
+     *            COM time.
+     * @return Java time.
+     */
+    static public long convertWindowsTimeToMilliseconds(double comTime) {
+        long result = 0;
 
-		// code from jacobgen:
-		comTime = comTime - 25569D;
-		Calendar cal = Calendar.getInstance();
-		result = Math.round(86400000L * comTime)
-				- cal.get(Calendar.ZONE_OFFSET);
-		cal.setTime(new Date(result));
-		result -= cal.get(Calendar.DST_OFFSET);
+        // code from jacobgen:
+        comTime = comTime - 25569D;
+        Calendar cal = Calendar.getInstance();
+        result = Math.round(86400000L * comTime)
+                - cal.get(Calendar.ZONE_OFFSET);
+        cal.setTime(new Date(result));
+        result -= cal.get(Calendar.DST_OFFSET);
 
-		return result;
-	}// convertWindowsTimeToMilliseconds()
+        return result;
+    }// convertWindowsTimeToMilliseconds()
 
-	/**
-	 * converts a java date to a windows time object (is this timezone safe?)
-	 * 
-	 * @param javaDate
-	 *            the java date to be converted to windows time
-	 * @return the double representing the date in a form windows understands
-	 */
-	static public double convertDateToWindowsTime(Date javaDate) {
-		if (javaDate == null) {
-			throw new IllegalArgumentException(
-					"cannot convert null to windows time");
-		}
-		return convertMillisecondsToWindowsTime(javaDate.getTime());
-	}
+    /**
+     * converts a java date to a windows time object (is this timezone safe?)
+     * 
+     * @param javaDate
+     *            the java date to be converted to windows time
+     * @return the double representing the date in a form windows understands
+     */
+    static public double convertDateToWindowsTime(Date javaDate) {
+        if (javaDate == null) {
+            throw new IllegalArgumentException(
+                    "cannot convert null to windows time");
+        }
+        return convertMillisecondsToWindowsTime(javaDate.getTime());
+    }
 
-	/**
-	 * Convert a Java time to a COM time.
-	 * 
-	 * @param milliseconds
-	 *            Java time.
-	 * @return COM time.
-	 */
-	static public double convertMillisecondsToWindowsTime(long milliseconds) {
-		double result = 0.0;
+    /**
+     * Convert a Java time to a COM time.
+     * 
+     * @param milliseconds
+     *            Java time.
+     * @return COM time.
+     */
+    static public double convertMillisecondsToWindowsTime(long milliseconds) {
+        double result = 0.0;
 
-		// code from jacobgen:
-		Calendar cal = Calendar.getInstance();
-		cal.setTimeInMillis(milliseconds);
-		milliseconds += (cal.get(Calendar.ZONE_OFFSET) + cal
-				.get(Calendar.DST_OFFSET)); // add GMT offset
-		result = (milliseconds / 86400000D) + 25569D;
+        // code from jacobgen:
+        Calendar cal = Calendar.getInstance();
+        cal.setTimeInMillis(milliseconds);
+        milliseconds += (cal.get(Calendar.ZONE_OFFSET) + cal
+                .get(Calendar.DST_OFFSET)); // add GMT offset
+        result = (milliseconds / 86400000D) + 25569D;
 
-		return result;
-	}// convertMillisecondsToWindowsTime()
+        return result;
+    }// convertMillisecondsToWindowsTime()
 }
diff --git a/src/main/java/com/jacob/com/Dispatch.java b/src/main/java/com/jacob/com/Dispatch.java
index 282e4a3..b184013 100644
--- a/src/main/java/com/jacob/com/Dispatch.java
+++ b/src/main/java/com/jacob/com/Dispatch.java
@@ -18,23 +18,23 @@
  *
  * This file incorporates work covered by the following copyright and
  * permission notice:
- * 	Copyright (c) 1999-2004 Sourceforge JACOB Project.
- * 	All rights reserved. Originator: Dan Adler (http://danadler.com).
- * 	Get more information about JACOB at http://sourceforge.net/projects/jacob-project
+ *     Copyright (c) 1999-2004 Sourceforge JACOB Project.
+ *     All rights reserved. Originator: Dan Adler (http://danadler.com).
+ *     Get more information about JACOB at http://sourceforge.net/projects/jacob-project
  *
- * 	This library is free software; you can redistribute it and/or
- * 	modify it under the terms of the GNU Lesser General Public
- * 	License as published by the Free Software Foundation; either
- * 	version 2.1 of the License, or (at your option) any later version.
+ *     This library is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU Lesser General Public
+ *     License as published by the Free Software Foundation; either
+ *     version 2.1 of the License, or (at your option) any later version.
  *
- * 	This library is distributed in the hope that it will be useful,
- * 	but WITHOUT ANY WARRANTY; without even the implied warranty of
- * 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * 	Lesser General Public License for more details.
+ *     This library is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *     Lesser General Public License for more details.
  *
- * 	You should have received a copy of the GNU Lesser General Public
- * 	License along with this library; if not, write to the Free Software
- * 	Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *     You should have received a copy of the GNU Lesser General Public
+ *     License along with this library; if not, write to the Free Software
+ *     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 package com.jacob.com;
 
@@ -48,1290 +48,1290 @@ package com.jacob.com;
  */
 public class Dispatch extends JacobObject {
 
-	/**
-	 * Used to set the locale in a call. The user locale is another option
-	 */
-	public static final int LOCALE_SYSTEM_DEFAULT = 2048;
-	/** used by callN() and callSubN() */
-	public static final int Method = 1;
-	/** used by callN() and callSubN() */
-	public static final int Get = 2;
-	/** used by put() */
-	public static final int Put = 4;
-	/** not used, probably intended for putRef() */
-	public static final int PutRef = 8;
-	/**
-	 * One of legal values for GetDispId. Not used in this layer and probably
-	 * not needed.
-	 */
-	public static final int fdexNameCaseSensitive = 1;
-
-	/**
-	 * This is public because Dispatch.cpp knows its name and accesses it
-	 * directly to get the dispatch id. You really can't rename it or make it
-	 * private
-	 */
-	public int m_pDispatch;
-
-	/** program Id passed in by ActiveX components in their constructor */
-	private String programId = null;
-
-	private static int NOT_ATTACHED = 0;
-
-	/**
-	 * Dummy empty array used one doesn't have to be created on every invocation
-	 */
-	private final static Object[] NO_OBJECT_ARGS = new Object[0];
-	/**
-	 * Dummy empty array used one doesn't have to be created on every invocation
-	 */
-	private final static Variant[] NO_VARIANT_ARGS = new Variant[0];
-	/**
-	 * Dummy empty array used one doesn't have to be created on every invocation
-	 */
-	private final static int[] NO_INT_ARGS = new int[0];
-
-	/**
-	 * zero argument constructor that sets the dispatch pointer to 0 This is the
-	 * only way to create a Dispatch without a value in the pointer field.
-	 */
-	public Dispatch() {
-		m_pDispatch = NOT_ATTACHED;
-	}
-
-	/**
-	 * This constructor calls createInstance with progid. This is the
-	 * constructor used by the ActiveXComponent or by programs that don't like
-	 * the activeX interface but wish to create new connections to windows
-	 * programs.
-	 * 

- * This constructor always creates a new windows/program object because it - * is based on the CoCreate() windows function. - *

- * - * @param requestedProgramId - * @throws IllegalArgumentException - * if null is passed in as the program id - *

- */ - public Dispatch(String requestedProgramId) { - programId = requestedProgramId; - if (programId != null && !"".equals(programId)) { - createInstanceNative(requestedProgramId); - } else { - throw new IllegalArgumentException( - "Dispatch(String) does not accept null or an empty string as a parameter"); - } - } - - /** - * native call createInstance only used by the constructor with the same - * parm type. This probably should be private. It is the wrapper for the - * Windows CoCreate() call - *

- * This ends up calling CoCreate down in the JNI layer - *

- * The behavior is different if a ":" character exists in the progId. In - * that case CoGetObject and CreateInstance (someone needs to describe this - * better) - * - * @param progid - */ - private native void createInstanceNative(String progid); - - /** - * native call getActiveInstance only used by the constructor with the same - * parm type. This probably should be private. It is the wrapper for the - * Windows GetActiveObject() call - *

- * This ends up calling GetActiveObject down in the JNI layer - *

- * This does not have the special behavior for program ids with ":" in them - * that createInstance has. - * - * @param progid - */ - private native void getActiveInstanceNative(String progid); - - /** - * Wrapper around the native method - * - * @param pProgramIdentifier - * name of the program you wish to connect to - */ - protected void getActiveInstance(String pProgramIdentifier) { - if (pProgramIdentifier == null || "".equals(pProgramIdentifier)) { - throw new IllegalArgumentException("program id is required"); - } - this.programId = pProgramIdentifier; - getActiveInstanceNative(pProgramIdentifier); - } - - /** - * native call coCreateInstance only used by the constructor with the same - * parm type. This probably should be private. It is the wrapper for the - * Windows CoCreate() call - *

- * This ends up calling CoCreate down in the JNI layer - *

- * This does not have the special behavior for program ids with ":" in them - * that createInstance has. - * - * @param progid - */ - private native void coCreateInstanceNative(String progid); - - /** - * Wrapper around the native method - * - * @param pProgramIdentifier - */ - protected void coCreateInstance(String pProgramIdentifier) { - if (pProgramIdentifier == null || "".equals(pProgramIdentifier)) { - throw new IllegalArgumentException("program id is required"); - } - this.programId = pProgramIdentifier; - coCreateInstanceNative(pProgramIdentifier); - } - - /** - * Return a different interface by IID string. - *

- * Once you have a Dispatch object, you can navigate to the other interfaces - * of a COM object by calling QueryInterafce. The argument is an IID string - * in the format: "{9BF24410-B2E0-11D4-A695-00104BFF3241}". You typically - * get this string from the idl file (it's called uuid in there). Any - * interface you try to use must be derived from IDispatch. T The atl - * example uses this. - *

- * The Dispatch instance resulting from this query is instanciated in the - * JNI code. - * - * @param iid - * @return Dispatch a disptach that matches ?? - */ - public native Dispatch QueryInterface(String iid); - - /** - * Constructor that only gets called from JNI QueryInterface calls JNI code - * that looks up the object for the key passed in. The JNI CODE then creates - * a new dispatch object using this constructor - * - * @param pDisp - */ - protected Dispatch(int pDisp) { - m_pDispatch = pDisp; - } - - /** - * Constructor to be used by subclass that want to swap themselves in for - * the default Dispatch class. Usually you will have a class like - * WordDocument that is a subclass of Dispatch and it will have a - * constructor public WordDocument(Dispatch). That constructor should just - * call this constructor as super(Dispatch) - * - * @param dispatchToBeDisplaced - */ - public Dispatch(Dispatch dispatchToBeDisplaced) { - // TAKE OVER THE IDispatch POINTER - this.m_pDispatch = dispatchToBeDisplaced.m_pDispatch; - // NULL OUT THE INPUT POINTER - dispatchToBeDisplaced.m_pDispatch = NOT_ATTACHED; - } - - /** - * returns the program id if an activeX component created this otherwise it - * returns null. This was added to aid in debugging - * - * @return the program id an activeX component was created against - */ - public String getProgramId() { - return programId; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#finalize() - */ - protected void finalize() { - safeRelease(); - } - - /* - * (non-Javadoc) - * - * @see com.jacob.com.JacobObject#safeRelease() - */ - public void safeRelease() { - super.safeRelease(); - if (isAttached()) { - release(); - m_pDispatch = NOT_ATTACHED; - } else { - // looks like a double release - if (isDebugEnabled()) { - debug(this.getClass().getName() + ":" + this.hashCode() - + " double release"); - } - } - } - - /** - * - * @return true if there is an underlying windows dispatch object - */ - protected boolean isAttached() { - if (m_pDispatch == NOT_ATTACHED) { - return false; - } else { - return true; - } - } - - /** - * @param theOneInQuestion - * dispatch being tested - * @throws IllegalStateException - * if this dispatch isn't hooked up - * @throws IllegalArgumentException - * if null the dispatch under test is null - */ - private static void throwIfUnattachedDispatch(Dispatch theOneInQuestion) { - if (theOneInQuestion == null) { - throw new IllegalArgumentException( - "Can't pass in null Dispatch object"); - } else if (theOneInQuestion.isAttached()) { - return; - } else { - throw new IllegalStateException( - "Dispatch not hooked to windows memory"); - } - } - - /** - * now private so only this object can access was: call this to explicitly - * release the com object before gc - * - */ - private native void release(); - - /** - * not implemented yet - * - * @param dispatchTarget - * @param name - * @param val - * @throws com.jacob.com.NotImplementedException - */ - public static void put_Casesensitive(Dispatch dispatchTarget, String name, - Object val) { - throw new NotImplementedException("not implemented yet"); - } - - /* - * ============================================================ start of the - * invokev section - * =========================================================== - */ - // eliminate _Guid arg - /** - * @param dispatchTarget - * @param name - * @param dispID - * @param lcid - * @param wFlags - * @param vArg - * @param uArgErr - */ - public static void invokeSubv(Dispatch dispatchTarget, String name, - int dispID, int lcid, int wFlags, Variant[] vArg, int[] uArgErr) { - throwIfUnattachedDispatch(dispatchTarget); - invokev(dispatchTarget, name, dispID, lcid, wFlags, vArg, uArgErr); - } - - /** - * @param dispatchTarget - * @param name - * @param wFlags - * @param vArg - * @param uArgErr - */ - public static void invokeSubv(Dispatch dispatchTarget, String name, - int wFlags, Variant[] vArg, int[] uArgErr) { - throwIfUnattachedDispatch(dispatchTarget); - invokev(dispatchTarget, name, 0, Dispatch.LOCALE_SYSTEM_DEFAULT, - wFlags, vArg, uArgErr); - } - - /** - * @param dispatchTarget - * @param dispID - * @param wFlags - * @param vArg - * @param uArgErr - */ - public static void invokeSubv(Dispatch dispatchTarget, int dispID, - int wFlags, Variant[] vArg, int[] uArgErr) { - throwIfUnattachedDispatch(dispatchTarget); - invokev(dispatchTarget, null, dispID, Dispatch.LOCALE_SYSTEM_DEFAULT, - wFlags, vArg, uArgErr); - } - - /** - * not implemented yet - * - * @param dispatchTarget - * @param name - * @param values - * @return never returns anything because - * @throws com.jacob.com.NotImplementedException - */ - public static Variant callN_CaseSensitive(Dispatch dispatchTarget, - String name, Object[] values) { - throw new NotImplementedException("not implemented yet"); - } - - /** - * @param dispatchTarget - * @param name - * @param args - * an array of argument objects - */ - public static void callSubN(Dispatch dispatchTarget, String name, - Object[] args) { - throwIfUnattachedDispatch(dispatchTarget); - invokeSubv(dispatchTarget, name, Dispatch.Method | Dispatch.Get, - VariantUtilities.objectsToVariants(args), - new int[args.length]); - } - - /** - * @param dispatchTarget - * @param dispID - * @param args - * an array of argument objects - */ - public static void callSubN(Dispatch dispatchTarget, int dispID, - Object[] args) { - throwIfUnattachedDispatch(dispatchTarget); - invokeSubv(dispatchTarget, dispID, Dispatch.Method | Dispatch.Get, - VariantUtilities.objectsToVariants(args), - new int[args.length]); - } - - /* - * ============================================================ start of the - * getIdsOfNames section - * =========================================================== - */ - /** - * @param dispatchTarget - * @param name - * @return int id for the passed in name - */ - public static int getIDOfName(Dispatch dispatchTarget, String name) { - int ids[] = getIDsOfNames(dispatchTarget, - Dispatch.LOCALE_SYSTEM_DEFAULT, new String[] { name }); - return ids[0]; - } - - /** - * @param dispatchTarget - * @param lcid - * @param names - * @return int[] in id array for passed in names - */ - // eliminated _Guid argument - public static native int[] getIDsOfNames(Dispatch dispatchTarget, int lcid, - String[] names); - - /** - * @param dispatchTarget - * @param names - * @return int[] int id array for passed in names - */ - // eliminated _Guid argument - public static int[] getIDsOfNames(Dispatch dispatchTarget, String[] names) { - return getIDsOfNames(dispatchTarget, Dispatch.LOCALE_SYSTEM_DEFAULT, - names); - } - - /* - * ============================================================ start of the - * invokev section - * =========================================================== - */ - /** - * @param dispatchTarget - * @param name - * @param args - * @return Variant returned by call - */ - public static Variant callN(Dispatch dispatchTarget, String name, - Object[] args) { - throwIfUnattachedDispatch(dispatchTarget); - return invokev(dispatchTarget, name, Dispatch.Method | Dispatch.Get, - VariantUtilities.objectsToVariants(args), - new int[args.length]); - } - - /** - * @param dispatchTarget - * @param dispID - * @param args - * @return Variant returned by call - */ - public static Variant callN(Dispatch dispatchTarget, int dispID, - Object[] args) { - throwIfUnattachedDispatch(dispatchTarget); - return invokev(dispatchTarget, dispID, Dispatch.Method | Dispatch.Get, - VariantUtilities.objectsToVariants(args), - new int[args.length]); - } - - /** - * @param dispatchTarget - * @param name - * @param dispID - * @param lcid - * @param wFlags - * @param oArg - * @param uArgErr - * @return Variant returned by invoke - */ - public static Variant invoke(Dispatch dispatchTarget, String name, - int dispID, int lcid, int wFlags, Object[] oArg, int[] uArgErr) { - throwIfUnattachedDispatch(dispatchTarget); - return invokev(dispatchTarget, name, dispID, lcid, wFlags, - VariantUtilities.objectsToVariants(oArg), uArgErr); - } - - /** - * @param dispatchTarget - * @param name - * @param wFlags - * @param oArg - * @param uArgErr - * @return Variant returned by invoke - */ - public static Variant invoke(Dispatch dispatchTarget, String name, - int wFlags, Object[] oArg, int[] uArgErr) { - throwIfUnattachedDispatch(dispatchTarget); - return invokev(dispatchTarget, name, wFlags, VariantUtilities - .objectsToVariants(oArg), uArgErr); - } - - /** - * @param dispatchTarget - * @param dispID - * @param wFlags - * @param oArg - * @param uArgErr - * @return Variant returned by invoke - */ - public static Variant invoke(Dispatch dispatchTarget, int dispID, - int wFlags, Object[] oArg, int[] uArgErr) { - throwIfUnattachedDispatch(dispatchTarget); - return invokev(dispatchTarget, dispID, wFlags, VariantUtilities - .objectsToVariants(oArg), uArgErr); - } - - /* - * ============================================================ start of the - * callN section =========================================================== - */ - - /** - * @param dispatchTarget - * @param name - * @return Variant returned by underlying callN - */ - public static Variant call(Dispatch dispatchTarget, String name) { - throwIfUnattachedDispatch(dispatchTarget); - return callN(dispatchTarget, name, NO_VARIANT_ARGS); - } - - /** - * @param dispatchTarget - * @param name - * @param a1 - * @return Variant returned by underlying callN - */ - public static Variant call(Dispatch dispatchTarget, String name, Object a1) { - throwIfUnattachedDispatch(dispatchTarget); - return callN(dispatchTarget, name, new Object[] { a1 }); - } - - /** - * @param dispatchTarget - * @param name - * @param a1 - * @param a2 - * @return Variant returned by underlying callN - */ - public static Variant call(Dispatch dispatchTarget, String name, Object a1, - Object a2) { - throwIfUnattachedDispatch(dispatchTarget); - return callN(dispatchTarget, name, new Object[] { a1, a2 }); - } - - /** - * @param dispatchTarget - * @param name - * @param a1 - * @param a2 - * @param a3 - * @return Variant returned by underlying callN - */ - public static Variant call(Dispatch dispatchTarget, String name, Object a1, - Object a2, Object a3) { - throwIfUnattachedDispatch(dispatchTarget); - return callN(dispatchTarget, name, new Object[] { a1, a2, a3 }); - } - - /** - * @param dispatchTarget - * @param name - * @param a1 - * @param a2 - * @param a3 - * @param a4 - * @return Variant retuned by underlying callN - */ - public static Variant call(Dispatch dispatchTarget, String name, Object a1, - Object a2, Object a3, Object a4) { - throwIfUnattachedDispatch(dispatchTarget); - return callN(dispatchTarget, name, new Object[] { a1, a2, a3, a4 }); - } - - /** - * @param dispatchTarget - * @param name - * @param a1 - * @param a2 - * @param a3 - * @param a4 - * @param a5 - * @return Variant returned by underlying callN - */ - public static Variant call(Dispatch dispatchTarget, String name, Object a1, - Object a2, Object a3, Object a4, Object a5) { - throwIfUnattachedDispatch(dispatchTarget); - return callN(dispatchTarget, name, new Object[] { a1, a2, a3, a4, a5 }); - } - - /** - * @param dispatchTarget - * @param name - * @param a1 - * @param a2 - * @param a3 - * @param a4 - * @param a5 - * @param a6 - * @return Variant retuned by underlying callN - */ - public static Variant call(Dispatch dispatchTarget, String name, Object a1, - Object a2, Object a3, Object a4, Object a5, Object a6) { - throwIfUnattachedDispatch(dispatchTarget); - return callN(dispatchTarget, name, new Object[] { a1, a2, a3, a4, a5, - a6 }); - } - - /** - * @param dispatchTarget - * @param name - * @param a1 - * @param a2 - * @param a3 - * @param a4 - * @param a5 - * @param a6 - * @param a7 - * @return Variant returned by underlying callN - */ - public static Variant call(Dispatch dispatchTarget, String name, Object a1, - Object a2, Object a3, Object a4, Object a5, Object a6, Object a7) { - throwIfUnattachedDispatch(dispatchTarget); - return callN(dispatchTarget, name, new Object[] { a1, a2, a3, a4, a5, - a6, a7 }); - } - - /** - * @param dispatchTarget - * @param name - * @param a1 - * @param a2 - * @param a3 - * @param a4 - * @param a5 - * @param a6 - * @param a7 - * @param a8 - * @return Variant retuned by underlying callN - */ - public static Variant call(Dispatch dispatchTarget, String name, Object a1, - Object a2, Object a3, Object a4, Object a5, Object a6, Object a7, - Object a8) { - throwIfUnattachedDispatch(dispatchTarget); - return callN(dispatchTarget, name, new Object[] { a1, a2, a3, a4, a5, - a6, a7, a8 }); - } - - /** - * @param dispatchTarget - * @param dispid - * @return Variant returned by underlying callN - */ - public static Variant call(Dispatch dispatchTarget, int dispid) { - throwIfUnattachedDispatch(dispatchTarget); - return callN(dispatchTarget, dispid, NO_VARIANT_ARGS); - } - - /** - * @param dispatchTarget - * @param dispid - * @param a1 - * @return Variant returned by underlying callN - */ - public static Variant call(Dispatch dispatchTarget, int dispid, Object a1) { - throwIfUnattachedDispatch(dispatchTarget); - return callN(dispatchTarget, dispid, new Object[] { a1 }); - } - - /** - * @param dispatchTarget - * @param dispid - * @param a1 - * @param a2 - * @return Variant returned by underlying callN - */ - public static Variant call(Dispatch dispatchTarget, int dispid, Object a1, - Object a2) { - throwIfUnattachedDispatch(dispatchTarget); - return callN(dispatchTarget, dispid, new Object[] { a1, a2 }); - } - - /** - * @param dispatchTarget - * @param dispid - * @param a1 - * @param a2 - * @param a3 - * @return Variant returned by underlying callN - */ - public static Variant call(Dispatch dispatchTarget, int dispid, Object a1, - Object a2, Object a3) { - throwIfUnattachedDispatch(dispatchTarget); - return callN(dispatchTarget, dispid, new Object[] { a1, a2, a3 }); - } - - /** - * @param dispatchTarget - * @param dispid - * @param a1 - * @param a2 - * @param a3 - * @param a4 - * @return Variant returned by underlying callN - */ - public static Variant call(Dispatch dispatchTarget, int dispid, Object a1, - Object a2, Object a3, Object a4) { - throwIfUnattachedDispatch(dispatchTarget); - return callN(dispatchTarget, dispid, new Object[] { a1, a2, a3, a4 }); - } - - /** - * @param dispatchTarget - * @param dispid - * @param a1 - * @param a2 - * @param a3 - * @param a4 - * @param a5 - * @return Variant returned by underlying callN - */ - public static Variant call(Dispatch dispatchTarget, int dispid, Object a1, - Object a2, Object a3, Object a4, Object a5) { - throwIfUnattachedDispatch(dispatchTarget); - return callN(dispatchTarget, dispid, - new Object[] { a1, a2, a3, a4, a5 }); - } - - /** - * @param dispatchTarget - * @param dispid - * @param a1 - * @param a2 - * @param a3 - * @param a4 - * @param a5 - * @param a6 - * @return Variant returned by underlying callN - */ - public static Variant call(Dispatch dispatchTarget, int dispid, Object a1, - Object a2, Object a3, Object a4, Object a5, Object a6) { - throwIfUnattachedDispatch(dispatchTarget); - return callN(dispatchTarget, dispid, new Object[] { a1, a2, a3, a4, a5, - a6 }); - } - - /** - * @param dispatchTarget - * @param dispid - * @param a1 - * @param a2 - * @param a3 - * @param a4 - * @param a5 - * @param a6 - * @param a7 - * @return Variant returned by underlying callN - */ - public static Variant call(Dispatch dispatchTarget, int dispid, Object a1, - Object a2, Object a3, Object a4, Object a5, Object a6, Object a7) { - throwIfUnattachedDispatch(dispatchTarget); - return callN(dispatchTarget, dispid, new Object[] { a1, a2, a3, a4, a5, - a6, a7 }); - } - - /** - * @param dispatchTarget - * @param dispid - * @param a1 - * @param a2 - * @param a3 - * @param a4 - * @param a5 - * @param a6 - * @param a7 - * @param a8 - * @return Variant returned by underlying callN - */ - public static Variant call(Dispatch dispatchTarget, int dispid, Object a1, - Object a2, Object a3, Object a4, Object a5, Object a6, Object a7, - Object a8) { - throwIfUnattachedDispatch(dispatchTarget); - return callN(dispatchTarget, dispid, new Object[] { a1, a2, a3, a4, a5, - a6, a7, a8 }); - } - - /* - * ============================================================ start of the - * invoke section - * =========================================================== - */ - /** - * @param dispatchTarget - * @param name - * @param val - */ - public static void put(Dispatch dispatchTarget, String name, Object val) { - throwIfUnattachedDispatch(dispatchTarget); - invoke(dispatchTarget, name, Dispatch.Put, new Object[] { val }, - new int[1]); - } - - /** - * @param dispatchTarget - * @param dispid - * @param val - */ - public static void put(Dispatch dispatchTarget, int dispid, Object val) { - throwIfUnattachedDispatch(dispatchTarget); - invoke(dispatchTarget, dispid, Dispatch.Put, new Object[] { val }, - new int[1]); - } - - /* - * ============================================================ start of the - * invokev section - * =========================================================== - */ - // removed _Guid argument - /** - * @param dispatchTarget - * @param name - * @param dispID - * @param lcid - * @param wFlags - * @param vArg - * @param uArgErr - * @return Variant returned by underlying invokev - */ - public static native Variant invokev(Dispatch dispatchTarget, String name, - int dispID, int lcid, int wFlags, Variant[] vArg, int[] uArgErr); - - /** - * @param dispatchTarget - * @param name - * @param wFlags - * @param vArg - * @param uArgErr - * @return Variant returned by underlying invokev - */ - public static Variant invokev(Dispatch dispatchTarget, String name, - int wFlags, Variant[] vArg, int[] uArgErr) { - throwIfUnattachedDispatch(dispatchTarget); - return invokev(dispatchTarget, name, 0, Dispatch.LOCALE_SYSTEM_DEFAULT, - wFlags, vArg, uArgErr); - } - - /** - * @param dispatchTarget - * @param name - * @param wFlags - * @param vArg - * @param uArgErr - * @param wFlagsEx - * @return Variant returned by underlying invokev - */ - public static Variant invokev(Dispatch dispatchTarget, String name, - int wFlags, Variant[] vArg, int[] uArgErr, int wFlagsEx) { - throwIfUnattachedDispatch(dispatchTarget); - // do not implement IDispatchEx for now - return invokev(dispatchTarget, name, 0, Dispatch.LOCALE_SYSTEM_DEFAULT, - wFlags, vArg, uArgErr); - } - - /** - * @param dispatchTarget - * @param dispID - * @param wFlags - * @param vArg - * @param uArgErr - * @return Variant returned by underlying invokev - */ - public static Variant invokev(Dispatch dispatchTarget, int dispID, - int wFlags, Variant[] vArg, int[] uArgErr) { - throwIfUnattachedDispatch(dispatchTarget); - return invokev(dispatchTarget, null, dispID, - Dispatch.LOCALE_SYSTEM_DEFAULT, wFlags, vArg, uArgErr); - } - - /* - * ============================================================ start of the - * invokeSubv section - * =========================================================== - */ - - // removed _Guid argument - /** - * @param dispatchTarget - * @param name - * @param dispid - * @param lcid - * @param wFlags - * @param oArg - * @param uArgErr - */ - public static void invokeSub(Dispatch dispatchTarget, String name, - int dispid, int lcid, int wFlags, Object[] oArg, int[] uArgErr) { - throwIfUnattachedDispatch(dispatchTarget); - invokeSubv(dispatchTarget, name, dispid, lcid, wFlags, - VariantUtilities.objectsToVariants(oArg), uArgErr); - } - - /* - * ============================================================ start of the - * invokeSub section - * =========================================================== - */ - /** - * @param dispatchTarget - * @param name - * @param wFlags - * @param oArg - * @param uArgErr - */ - public static void invokeSub(Dispatch dispatchTarget, String name, - int wFlags, Object[] oArg, int[] uArgErr) { - throwIfUnattachedDispatch(dispatchTarget); - invokeSub(dispatchTarget, name, 0, Dispatch.LOCALE_SYSTEM_DEFAULT, - wFlags, oArg, uArgErr); - } - - /** - * @param dispatchTarget - * @param dispid - * @param wFlags - * @param oArg - * @param uArgErr - */ - public static void invokeSub(Dispatch dispatchTarget, int dispid, - int wFlags, Object[] oArg, int[] uArgErr) { - throwIfUnattachedDispatch(dispatchTarget); - invokeSub(dispatchTarget, null, dispid, Dispatch.LOCALE_SYSTEM_DEFAULT, - wFlags, oArg, uArgErr); - } - - /* - * ============================================================ start of the - * callSubN section - * =========================================================== - */ - /** - * makes call to native callSubN - * - * @param dispatchTarget - * @param name - */ - public static void callSub(Dispatch dispatchTarget, String name) { - throwIfUnattachedDispatch(dispatchTarget); - callSubN(dispatchTarget, name, NO_OBJECT_ARGS); - } - - /** - * makes call to native callSubN - * - * @param dispatchTarget - * @param name - * @param a1 - */ - public static void callSub(Dispatch dispatchTarget, String name, Object a1) { - throwIfUnattachedDispatch(dispatchTarget); - callSubN(dispatchTarget, name, new Object[] { a1 }); - } - - /** - * makes call to native callSubN - * - * @param dispatchTarget - * @param name - * @param a1 - * @param a2 - */ - public static void callSub(Dispatch dispatchTarget, String name, Object a1, - Object a2) { - throwIfUnattachedDispatch(dispatchTarget); - callSubN(dispatchTarget, name, new Object[] { a1, a2 }); - } - - /** - * makes call to native callSubN - * - * @param dispatchTarget - * @param name - * @param a1 - * @param a2 - * @param a3 - */ - public static void callSub(Dispatch dispatchTarget, String name, Object a1, - Object a2, Object a3) { - throwIfUnattachedDispatch(dispatchTarget); - callSubN(dispatchTarget, name, new Object[] { a1, a2, a3 }); - } - - /** - * makes call to native callSubN - * - * @param dispatchTarget - * @param name - * @param a1 - * @param a2 - * @param a3 - * @param a4 - */ - public static void callSub(Dispatch dispatchTarget, String name, Object a1, - Object a2, Object a3, Object a4) { - throwIfUnattachedDispatch(dispatchTarget); - callSubN(dispatchTarget, name, new Object[] { a1, a2, a3, a4 }); - } - - /** - * makes call to native callSubN - * - * @param dispatchTarget - * @param name - * @param a1 - * @param a2 - * @param a3 - * @param a4 - * @param a5 - */ - public static void callSub(Dispatch dispatchTarget, String name, Object a1, - Object a2, Object a3, Object a4, Object a5) { - throwIfUnattachedDispatch(dispatchTarget); - callSubN(dispatchTarget, name, new Object[] { a1, a2, a3, a4, a5 }); - } - - /** - * makes call to native callSubN - * - * @param dispatchTarget - * @param name - * @param a1 - * @param a2 - * @param a3 - * @param a4 - * @param a5 - * @param a6 - */ - public static void callSub(Dispatch dispatchTarget, String name, Object a1, - Object a2, Object a3, Object a4, Object a5, Object a6) { - throwIfUnattachedDispatch(dispatchTarget); - callSubN(dispatchTarget, name, new Object[] { a1, a2, a3, a4, a5, a6 }); - } - - /** - * makes call to native callSubN - * - * @param dispatchTarget - * @param name - * @param a1 - * @param a2 - * @param a3 - * @param a4 - * @param a5 - * @param a6 - * @param a7 - */ - public static void callSub(Dispatch dispatchTarget, String name, Object a1, - Object a2, Object a3, Object a4, Object a5, Object a6, Object a7) { - throwIfUnattachedDispatch(dispatchTarget); - callSubN(dispatchTarget, name, new Object[] { a1, a2, a3, a4, a5, a6, - a7 }); - } - - /** - * makes call to native callSubN - * - * @param dispatchTarget - * @param name - * @param a1 - * @param a2 - * @param a3 - * @param a4 - * @param a5 - * @param a6 - * @param a7 - * @param a8 - */ - public static void callSub(Dispatch dispatchTarget, String name, Object a1, - Object a2, Object a3, Object a4, Object a5, Object a6, Object a7, - Object a8) { - throwIfUnattachedDispatch(dispatchTarget); - callSubN(dispatchTarget, name, new Object[] { a1, a2, a3, a4, a5, a6, - a7, a8 }); - } - - /** - * makes call to native callSubN - * - * @param dispatchTarget - * @param dispid - */ - public static void callSub(Dispatch dispatchTarget, int dispid) { - throwIfUnattachedDispatch(dispatchTarget); - callSubN(dispatchTarget, dispid, NO_OBJECT_ARGS); - } - - /** - * makes call to native callSubN - * - * @param dispatchTarget - * @param dispid - * @param a1 - */ - public static void callSub(Dispatch dispatchTarget, int dispid, Object a1) { - throwIfUnattachedDispatch(dispatchTarget); - callSubN(dispatchTarget, dispid, new Object[] { a1 }); - } - - /** - * makes call to native callSubN - * - * @param dispatchTarget - * @param dispid - * @param a1 - * @param a2 - */ - public static void callSub(Dispatch dispatchTarget, int dispid, Object a1, - Object a2) { - throwIfUnattachedDispatch(dispatchTarget); - callSubN(dispatchTarget, dispid, new Object[] { a1, a2 }); - } - - /** - * makes call to native callSubN - * - * @param dispatchTarget - * @param dispid - * @param a1 - * @param a2 - * @param a3 - */ - public static void callSub(Dispatch dispatchTarget, int dispid, Object a1, - Object a2, Object a3) { - callSubN(dispatchTarget, dispid, new Object[] { a1, a2, a3 }); - } - - /** - * makes call to native callSubN - * - * @param dispatchTarget - * @param dispid - * @param a1 - * @param a2 - * @param a3 - * @param a4 - */ - public static void callSub(Dispatch dispatchTarget, int dispid, Object a1, - Object a2, Object a3, Object a4) { - throwIfUnattachedDispatch(dispatchTarget); - callSubN(dispatchTarget, dispid, new Object[] { a1, a2, a3, a4 }); - } - - /** - * makes call to native callSubN - * - * @param dispatchTarget - * @param dispid - * @param a1 - * @param a2 - * @param a3 - * @param a4 - * @param a5 - */ - public static void callSub(Dispatch dispatchTarget, int dispid, Object a1, - Object a2, Object a3, Object a4, Object a5) { - throwIfUnattachedDispatch(dispatchTarget); - callSubN(dispatchTarget, dispid, new Object[] { a1, a2, a3, a4, a5 }); - } - - /** - * makes call to native callSubN - * - * @param dispatchTarget - * @param dispid - * @param a1 - * @param a2 - * @param a3 - * @param a4 - * @param a5 - * @param a6 - */ - public static void callSub(Dispatch dispatchTarget, int dispid, Object a1, - Object a2, Object a3, Object a4, Object a5, Object a6) { - throwIfUnattachedDispatch(dispatchTarget); - callSubN(dispatchTarget, dispid, - new Object[] { a1, a2, a3, a4, a5, a6 }); - } - - /** - * makes call to native callSubN - * - * @param dispatchTarget - * @param dispid - * @param a1 - * @param a2 - * @param a3 - * @param a4 - * @param a5 - * @param a6 - * @param a7 - */ - public static void callSub(Dispatch dispatchTarget, int dispid, Object a1, - Object a2, Object a3, Object a4, Object a5, Object a6, Object a7) { - throwIfUnattachedDispatch(dispatchTarget); - callSubN(dispatchTarget, dispid, new Object[] { a1, a2, a3, a4, a5, a6, - a7 }); - } - - /** - * makes call to native callSubN - * - * @param dispatchTarget - * @param dispid - * @param a1 - * @param a2 - * @param a3 - * @param a4 - * @param a5 - * @param a6 - * @param a7 - * @param a8 - */ - public static void callSub(Dispatch dispatchTarget, int dispid, Object a1, - Object a2, Object a3, Object a4, Object a5, Object a6, Object a7, - Object a8) { - callSubN(dispatchTarget, dispid, new Object[] { a1, a2, a3, a4, a5, a6, - a7, a8 }); - } - - /* - * ============================================================ start of the - * invokev section - * =========================================================== - */ - /** - * Cover for call to underlying invokev() - * - * @param dispatchTarget - * @param name - * @return Variant returned by the request for retrieval of parameter - */ - public static Variant get(Dispatch dispatchTarget, String name) { - throwIfUnattachedDispatch(dispatchTarget); - return invokev(dispatchTarget, name, Dispatch.Get, NO_VARIANT_ARGS, - NO_INT_ARGS); - } - - /** - * Cover for call to underlying invokev() - * - * @param dispatchTarget - * @param dispid - * @return Variant returned by the request for retrieval of parameter - */ - public static Variant get(Dispatch dispatchTarget, int dispid) { - throwIfUnattachedDispatch(dispatchTarget); - return invokev(dispatchTarget, dispid, Dispatch.Get, NO_VARIANT_ARGS, - NO_INT_ARGS); - } - - /* - * ============================================================ start of the - * invoke section - * =========================================================== - */ - /** - * cover for underlying call to invoke - * - * @param dispatchTarget - * @param name - * @param val - */ - public static void putRef(Dispatch dispatchTarget, String name, Object val) { - throwIfUnattachedDispatch(dispatchTarget); - invoke(dispatchTarget, name, Dispatch.PutRef, new Object[] { val }, - new int[1]); - } - - /** - * cover for underlying call to invoke - * - * @param dispatchTarget - * @param dispid - * @param val - */ - public static void putRef(Dispatch dispatchTarget, int dispid, Object val) { - throwIfUnattachedDispatch(dispatchTarget); - invoke(dispatchTarget, dispid, Dispatch.PutRef, new Object[] { val }, - new int[1]); - } - - /** - * not implemented yet - * - * @param dispatchTarget - * @param name - * @return Variant never returned - * @throws com.jacob.com.NotImplementedException - */ - public static Variant get_CaseSensitive(Dispatch dispatchTarget, String name) { - throw new NotImplementedException("not implemented yet"); - } + /** + * Used to set the locale in a call. The user locale is another option + */ + public static final int LOCALE_SYSTEM_DEFAULT = 2048; + /** used by callN() and callSubN() */ + public static final int Method = 1; + /** used by callN() and callSubN() */ + public static final int Get = 2; + /** used by put() */ + public static final int Put = 4; + /** not used, probably intended for putRef() */ + public static final int PutRef = 8; + /** + * One of legal values for GetDispId. Not used in this layer and probably + * not needed. + */ + public static final int fdexNameCaseSensitive = 1; + + /** + * This is public because Dispatch.cpp knows its name and accesses it + * directly to get the dispatch id. You really can't rename it or make it + * private + */ + public int m_pDispatch; + + /** program Id passed in by ActiveX components in their constructor */ + private String programId = null; + + private static int NOT_ATTACHED = 0; + + /** + * Dummy empty array used one doesn't have to be created on every invocation + */ + private final static Object[] NO_OBJECT_ARGS = new Object[0]; + /** + * Dummy empty array used one doesn't have to be created on every invocation + */ + private final static Variant[] NO_VARIANT_ARGS = new Variant[0]; + /** + * Dummy empty array used one doesn't have to be created on every invocation + */ + private final static int[] NO_INT_ARGS = new int[0]; + + /** + * zero argument constructor that sets the dispatch pointer to 0 This is the + * only way to create a Dispatch without a value in the pointer field. + */ + public Dispatch() { + m_pDispatch = NOT_ATTACHED; + } + + /** + * This constructor calls createInstance with progid. This is the + * constructor used by the ActiveXComponent or by programs that don't like + * the activeX interface but wish to create new connections to windows + * programs. + *

+ * This constructor always creates a new windows/program object because it + * is based on the CoCreate() windows function. + *

+ * + * @param requestedProgramId + * @throws IllegalArgumentException + * if null is passed in as the program id + *

+ */ + public Dispatch(String requestedProgramId) { + programId = requestedProgramId; + if (programId != null && !"".equals(programId)) { + createInstanceNative(requestedProgramId); + } else { + throw new IllegalArgumentException( + "Dispatch(String) does not accept null or an empty string as a parameter"); + } + } + + /** + * native call createInstance only used by the constructor with the same + * parm type. This probably should be private. It is the wrapper for the + * Windows CoCreate() call + *

+ * This ends up calling CoCreate down in the JNI layer + *

+ * The behavior is different if a ":" character exists in the progId. In + * that case CoGetObject and CreateInstance (someone needs to describe this + * better) + * + * @param progid + */ + private native void createInstanceNative(String progid); + + /** + * native call getActiveInstance only used by the constructor with the same + * parm type. This probably should be private. It is the wrapper for the + * Windows GetActiveObject() call + *

+ * This ends up calling GetActiveObject down in the JNI layer + *

+ * This does not have the special behavior for program ids with ":" in them + * that createInstance has. + * + * @param progid + */ + private native void getActiveInstanceNative(String progid); + + /** + * Wrapper around the native method + * + * @param pProgramIdentifier + * name of the program you wish to connect to + */ + protected void getActiveInstance(String pProgramIdentifier) { + if (pProgramIdentifier == null || "".equals(pProgramIdentifier)) { + throw new IllegalArgumentException("program id is required"); + } + this.programId = pProgramIdentifier; + getActiveInstanceNative(pProgramIdentifier); + } + + /** + * native call coCreateInstance only used by the constructor with the same + * parm type. This probably should be private. It is the wrapper for the + * Windows CoCreate() call + *

+ * This ends up calling CoCreate down in the JNI layer + *

+ * This does not have the special behavior for program ids with ":" in them + * that createInstance has. + * + * @param progid + */ + private native void coCreateInstanceNative(String progid); + + /** + * Wrapper around the native method + * + * @param pProgramIdentifier + */ + protected void coCreateInstance(String pProgramIdentifier) { + if (pProgramIdentifier == null || "".equals(pProgramIdentifier)) { + throw new IllegalArgumentException("program id is required"); + } + this.programId = pProgramIdentifier; + coCreateInstanceNative(pProgramIdentifier); + } + + /** + * Return a different interface by IID string. + *

+ * Once you have a Dispatch object, you can navigate to the other interfaces + * of a COM object by calling QueryInterafce. The argument is an IID string + * in the format: "{9BF24410-B2E0-11D4-A695-00104BFF3241}". You typically + * get this string from the idl file (it's called uuid in there). Any + * interface you try to use must be derived from IDispatch. T The atl + * example uses this. + *

+ * The Dispatch instance resulting from this query is instanciated in the + * JNI code. + * + * @param iid + * @return Dispatch a disptach that matches ?? + */ + public native Dispatch QueryInterface(String iid); + + /** + * Constructor that only gets called from JNI QueryInterface calls JNI code + * that looks up the object for the key passed in. The JNI CODE then creates + * a new dispatch object using this constructor + * + * @param pDisp + */ + protected Dispatch(int pDisp) { + m_pDispatch = pDisp; + } + + /** + * Constructor to be used by subclass that want to swap themselves in for + * the default Dispatch class. Usually you will have a class like + * WordDocument that is a subclass of Dispatch and it will have a + * constructor public WordDocument(Dispatch). That constructor should just + * call this constructor as super(Dispatch) + * + * @param dispatchToBeDisplaced + */ + public Dispatch(Dispatch dispatchToBeDisplaced) { + // TAKE OVER THE IDispatch POINTER + this.m_pDispatch = dispatchToBeDisplaced.m_pDispatch; + // NULL OUT THE INPUT POINTER + dispatchToBeDisplaced.m_pDispatch = NOT_ATTACHED; + } + + /** + * returns the program id if an activeX component created this otherwise it + * returns null. This was added to aid in debugging + * + * @return the program id an activeX component was created against + */ + public String getProgramId() { + return programId; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#finalize() + */ + protected void finalize() { + safeRelease(); + } + + /* + * (non-Javadoc) + * + * @see com.jacob.com.JacobObject#safeRelease() + */ + public void safeRelease() { + super.safeRelease(); + if (isAttached()) { + release(); + m_pDispatch = NOT_ATTACHED; + } else { + // looks like a double release + if (isDebugEnabled()) { + debug(this.getClass().getName() + ":" + this.hashCode() + + " double release"); + } + } + } + + /** + * + * @return true if there is an underlying windows dispatch object + */ + protected boolean isAttached() { + if (m_pDispatch == NOT_ATTACHED) { + return false; + } else { + return true; + } + } + + /** + * @param theOneInQuestion + * dispatch being tested + * @throws IllegalStateException + * if this dispatch isn't hooked up + * @throws IllegalArgumentException + * if null the dispatch under test is null + */ + private static void throwIfUnattachedDispatch(Dispatch theOneInQuestion) { + if (theOneInQuestion == null) { + throw new IllegalArgumentException( + "Can't pass in null Dispatch object"); + } else if (theOneInQuestion.isAttached()) { + return; + } else { + throw new IllegalStateException( + "Dispatch not hooked to windows memory"); + } + } + + /** + * now private so only this object can access was: call this to explicitly + * release the com object before gc + * + */ + private native void release(); + + /** + * not implemented yet + * + * @param dispatchTarget + * @param name + * @param val + * @throws com.jacob.com.NotImplementedException + */ + public static void put_Casesensitive(Dispatch dispatchTarget, String name, + Object val) { + throw new NotImplementedException("not implemented yet"); + } + + /* + * ============================================================ start of the + * invokev section + * =========================================================== + */ + // eliminate _Guid arg + /** + * @param dispatchTarget + * @param name + * @param dispID + * @param lcid + * @param wFlags + * @param vArg + * @param uArgErr + */ + public static void invokeSubv(Dispatch dispatchTarget, String name, + int dispID, int lcid, int wFlags, Variant[] vArg, int[] uArgErr) { + throwIfUnattachedDispatch(dispatchTarget); + invokev(dispatchTarget, name, dispID, lcid, wFlags, vArg, uArgErr); + } + + /** + * @param dispatchTarget + * @param name + * @param wFlags + * @param vArg + * @param uArgErr + */ + public static void invokeSubv(Dispatch dispatchTarget, String name, + int wFlags, Variant[] vArg, int[] uArgErr) { + throwIfUnattachedDispatch(dispatchTarget); + invokev(dispatchTarget, name, 0, Dispatch.LOCALE_SYSTEM_DEFAULT, + wFlags, vArg, uArgErr); + } + + /** + * @param dispatchTarget + * @param dispID + * @param wFlags + * @param vArg + * @param uArgErr + */ + public static void invokeSubv(Dispatch dispatchTarget, int dispID, + int wFlags, Variant[] vArg, int[] uArgErr) { + throwIfUnattachedDispatch(dispatchTarget); + invokev(dispatchTarget, null, dispID, Dispatch.LOCALE_SYSTEM_DEFAULT, + wFlags, vArg, uArgErr); + } + + /** + * not implemented yet + * + * @param dispatchTarget + * @param name + * @param values + * @return never returns anything because + * @throws com.jacob.com.NotImplementedException + */ + public static Variant callN_CaseSensitive(Dispatch dispatchTarget, + String name, Object[] values) { + throw new NotImplementedException("not implemented yet"); + } + + /** + * @param dispatchTarget + * @param name + * @param args + * an array of argument objects + */ + public static void callSubN(Dispatch dispatchTarget, String name, + Object[] args) { + throwIfUnattachedDispatch(dispatchTarget); + invokeSubv(dispatchTarget, name, Dispatch.Method | Dispatch.Get, + VariantUtilities.objectsToVariants(args), + new int[args.length]); + } + + /** + * @param dispatchTarget + * @param dispID + * @param args + * an array of argument objects + */ + public static void callSubN(Dispatch dispatchTarget, int dispID, + Object[] args) { + throwIfUnattachedDispatch(dispatchTarget); + invokeSubv(dispatchTarget, dispID, Dispatch.Method | Dispatch.Get, + VariantUtilities.objectsToVariants(args), + new int[args.length]); + } + + /* + * ============================================================ start of the + * getIdsOfNames section + * =========================================================== + */ + /** + * @param dispatchTarget + * @param name + * @return int id for the passed in name + */ + public static int getIDOfName(Dispatch dispatchTarget, String name) { + int ids[] = getIDsOfNames(dispatchTarget, + Dispatch.LOCALE_SYSTEM_DEFAULT, new String[] { name }); + return ids[0]; + } + + /** + * @param dispatchTarget + * @param lcid + * @param names + * @return int[] in id array for passed in names + */ + // eliminated _Guid argument + public static native int[] getIDsOfNames(Dispatch dispatchTarget, int lcid, + String[] names); + + /** + * @param dispatchTarget + * @param names + * @return int[] int id array for passed in names + */ + // eliminated _Guid argument + public static int[] getIDsOfNames(Dispatch dispatchTarget, String[] names) { + return getIDsOfNames(dispatchTarget, Dispatch.LOCALE_SYSTEM_DEFAULT, + names); + } + + /* + * ============================================================ start of the + * invokev section + * =========================================================== + */ + /** + * @param dispatchTarget + * @param name + * @param args + * @return Variant returned by call + */ + public static Variant callN(Dispatch dispatchTarget, String name, + Object[] args) { + throwIfUnattachedDispatch(dispatchTarget); + return invokev(dispatchTarget, name, Dispatch.Method | Dispatch.Get, + VariantUtilities.objectsToVariants(args), + new int[args.length]); + } + + /** + * @param dispatchTarget + * @param dispID + * @param args + * @return Variant returned by call + */ + public static Variant callN(Dispatch dispatchTarget, int dispID, + Object[] args) { + throwIfUnattachedDispatch(dispatchTarget); + return invokev(dispatchTarget, dispID, Dispatch.Method | Dispatch.Get, + VariantUtilities.objectsToVariants(args), + new int[args.length]); + } + + /** + * @param dispatchTarget + * @param name + * @param dispID + * @param lcid + * @param wFlags + * @param oArg + * @param uArgErr + * @return Variant returned by invoke + */ + public static Variant invoke(Dispatch dispatchTarget, String name, + int dispID, int lcid, int wFlags, Object[] oArg, int[] uArgErr) { + throwIfUnattachedDispatch(dispatchTarget); + return invokev(dispatchTarget, name, dispID, lcid, wFlags, + VariantUtilities.objectsToVariants(oArg), uArgErr); + } + + /** + * @param dispatchTarget + * @param name + * @param wFlags + * @param oArg + * @param uArgErr + * @return Variant returned by invoke + */ + public static Variant invoke(Dispatch dispatchTarget, String name, + int wFlags, Object[] oArg, int[] uArgErr) { + throwIfUnattachedDispatch(dispatchTarget); + return invokev(dispatchTarget, name, wFlags, VariantUtilities + .objectsToVariants(oArg), uArgErr); + } + + /** + * @param dispatchTarget + * @param dispID + * @param wFlags + * @param oArg + * @param uArgErr + * @return Variant returned by invoke + */ + public static Variant invoke(Dispatch dispatchTarget, int dispID, + int wFlags, Object[] oArg, int[] uArgErr) { + throwIfUnattachedDispatch(dispatchTarget); + return invokev(dispatchTarget, dispID, wFlags, VariantUtilities + .objectsToVariants(oArg), uArgErr); + } + + /* + * ============================================================ start of the + * callN section =========================================================== + */ + + /** + * @param dispatchTarget + * @param name + * @return Variant returned by underlying callN + */ + public static Variant call(Dispatch dispatchTarget, String name) { + throwIfUnattachedDispatch(dispatchTarget); + return callN(dispatchTarget, name, NO_VARIANT_ARGS); + } + + /** + * @param dispatchTarget + * @param name + * @param a1 + * @return Variant returned by underlying callN + */ + public static Variant call(Dispatch dispatchTarget, String name, Object a1) { + throwIfUnattachedDispatch(dispatchTarget); + return callN(dispatchTarget, name, new Object[] { a1 }); + } + + /** + * @param dispatchTarget + * @param name + * @param a1 + * @param a2 + * @return Variant returned by underlying callN + */ + public static Variant call(Dispatch dispatchTarget, String name, Object a1, + Object a2) { + throwIfUnattachedDispatch(dispatchTarget); + return callN(dispatchTarget, name, new Object[] { a1, a2 }); + } + + /** + * @param dispatchTarget + * @param name + * @param a1 + * @param a2 + * @param a3 + * @return Variant returned by underlying callN + */ + public static Variant call(Dispatch dispatchTarget, String name, Object a1, + Object a2, Object a3) { + throwIfUnattachedDispatch(dispatchTarget); + return callN(dispatchTarget, name, new Object[] { a1, a2, a3 }); + } + + /** + * @param dispatchTarget + * @param name + * @param a1 + * @param a2 + * @param a3 + * @param a4 + * @return Variant retuned by underlying callN + */ + public static Variant call(Dispatch dispatchTarget, String name, Object a1, + Object a2, Object a3, Object a4) { + throwIfUnattachedDispatch(dispatchTarget); + return callN(dispatchTarget, name, new Object[] { a1, a2, a3, a4 }); + } + + /** + * @param dispatchTarget + * @param name + * @param a1 + * @param a2 + * @param a3 + * @param a4 + * @param a5 + * @return Variant returned by underlying callN + */ + public static Variant call(Dispatch dispatchTarget, String name, Object a1, + Object a2, Object a3, Object a4, Object a5) { + throwIfUnattachedDispatch(dispatchTarget); + return callN(dispatchTarget, name, new Object[] { a1, a2, a3, a4, a5 }); + } + + /** + * @param dispatchTarget + * @param name + * @param a1 + * @param a2 + * @param a3 + * @param a4 + * @param a5 + * @param a6 + * @return Variant retuned by underlying callN + */ + public static Variant call(Dispatch dispatchTarget, String name, Object a1, + Object a2, Object a3, Object a4, Object a5, Object a6) { + throwIfUnattachedDispatch(dispatchTarget); + return callN(dispatchTarget, name, new Object[] { a1, a2, a3, a4, a5, + a6 }); + } + + /** + * @param dispatchTarget + * @param name + * @param a1 + * @param a2 + * @param a3 + * @param a4 + * @param a5 + * @param a6 + * @param a7 + * @return Variant returned by underlying callN + */ + public static Variant call(Dispatch dispatchTarget, String name, Object a1, + Object a2, Object a3, Object a4, Object a5, Object a6, Object a7) { + throwIfUnattachedDispatch(dispatchTarget); + return callN(dispatchTarget, name, new Object[] { a1, a2, a3, a4, a5, + a6, a7 }); + } + + /** + * @param dispatchTarget + * @param name + * @param a1 + * @param a2 + * @param a3 + * @param a4 + * @param a5 + * @param a6 + * @param a7 + * @param a8 + * @return Variant retuned by underlying callN + */ + public static Variant call(Dispatch dispatchTarget, String name, Object a1, + Object a2, Object a3, Object a4, Object a5, Object a6, Object a7, + Object a8) { + throwIfUnattachedDispatch(dispatchTarget); + return callN(dispatchTarget, name, new Object[] { a1, a2, a3, a4, a5, + a6, a7, a8 }); + } + + /** + * @param dispatchTarget + * @param dispid + * @return Variant returned by underlying callN + */ + public static Variant call(Dispatch dispatchTarget, int dispid) { + throwIfUnattachedDispatch(dispatchTarget); + return callN(dispatchTarget, dispid, NO_VARIANT_ARGS); + } + + /** + * @param dispatchTarget + * @param dispid + * @param a1 + * @return Variant returned by underlying callN + */ + public static Variant call(Dispatch dispatchTarget, int dispid, Object a1) { + throwIfUnattachedDispatch(dispatchTarget); + return callN(dispatchTarget, dispid, new Object[] { a1 }); + } + + /** + * @param dispatchTarget + * @param dispid + * @param a1 + * @param a2 + * @return Variant returned by underlying callN + */ + public static Variant call(Dispatch dispatchTarget, int dispid, Object a1, + Object a2) { + throwIfUnattachedDispatch(dispatchTarget); + return callN(dispatchTarget, dispid, new Object[] { a1, a2 }); + } + + /** + * @param dispatchTarget + * @param dispid + * @param a1 + * @param a2 + * @param a3 + * @return Variant returned by underlying callN + */ + public static Variant call(Dispatch dispatchTarget, int dispid, Object a1, + Object a2, Object a3) { + throwIfUnattachedDispatch(dispatchTarget); + return callN(dispatchTarget, dispid, new Object[] { a1, a2, a3 }); + } + + /** + * @param dispatchTarget + * @param dispid + * @param a1 + * @param a2 + * @param a3 + * @param a4 + * @return Variant returned by underlying callN + */ + public static Variant call(Dispatch dispatchTarget, int dispid, Object a1, + Object a2, Object a3, Object a4) { + throwIfUnattachedDispatch(dispatchTarget); + return callN(dispatchTarget, dispid, new Object[] { a1, a2, a3, a4 }); + } + + /** + * @param dispatchTarget + * @param dispid + * @param a1 + * @param a2 + * @param a3 + * @param a4 + * @param a5 + * @return Variant returned by underlying callN + */ + public static Variant call(Dispatch dispatchTarget, int dispid, Object a1, + Object a2, Object a3, Object a4, Object a5) { + throwIfUnattachedDispatch(dispatchTarget); + return callN(dispatchTarget, dispid, + new Object[] { a1, a2, a3, a4, a5 }); + } + + /** + * @param dispatchTarget + * @param dispid + * @param a1 + * @param a2 + * @param a3 + * @param a4 + * @param a5 + * @param a6 + * @return Variant returned by underlying callN + */ + public static Variant call(Dispatch dispatchTarget, int dispid, Object a1, + Object a2, Object a3, Object a4, Object a5, Object a6) { + throwIfUnattachedDispatch(dispatchTarget); + return callN(dispatchTarget, dispid, new Object[] { a1, a2, a3, a4, a5, + a6 }); + } + + /** + * @param dispatchTarget + * @param dispid + * @param a1 + * @param a2 + * @param a3 + * @param a4 + * @param a5 + * @param a6 + * @param a7 + * @return Variant returned by underlying callN + */ + public static Variant call(Dispatch dispatchTarget, int dispid, Object a1, + Object a2, Object a3, Object a4, Object a5, Object a6, Object a7) { + throwIfUnattachedDispatch(dispatchTarget); + return callN(dispatchTarget, dispid, new Object[] { a1, a2, a3, a4, a5, + a6, a7 }); + } + + /** + * @param dispatchTarget + * @param dispid + * @param a1 + * @param a2 + * @param a3 + * @param a4 + * @param a5 + * @param a6 + * @param a7 + * @param a8 + * @return Variant returned by underlying callN + */ + public static Variant call(Dispatch dispatchTarget, int dispid, Object a1, + Object a2, Object a3, Object a4, Object a5, Object a6, Object a7, + Object a8) { + throwIfUnattachedDispatch(dispatchTarget); + return callN(dispatchTarget, dispid, new Object[] { a1, a2, a3, a4, a5, + a6, a7, a8 }); + } + + /* + * ============================================================ start of the + * invoke section + * =========================================================== + */ + /** + * @param dispatchTarget + * @param name + * @param val + */ + public static void put(Dispatch dispatchTarget, String name, Object val) { + throwIfUnattachedDispatch(dispatchTarget); + invoke(dispatchTarget, name, Dispatch.Put, new Object[] { val }, + new int[1]); + } + + /** + * @param dispatchTarget + * @param dispid + * @param val + */ + public static void put(Dispatch dispatchTarget, int dispid, Object val) { + throwIfUnattachedDispatch(dispatchTarget); + invoke(dispatchTarget, dispid, Dispatch.Put, new Object[] { val }, + new int[1]); + } + + /* + * ============================================================ start of the + * invokev section + * =========================================================== + */ + // removed _Guid argument + /** + * @param dispatchTarget + * @param name + * @param dispID + * @param lcid + * @param wFlags + * @param vArg + * @param uArgErr + * @return Variant returned by underlying invokev + */ + public static native Variant invokev(Dispatch dispatchTarget, String name, + int dispID, int lcid, int wFlags, Variant[] vArg, int[] uArgErr); + + /** + * @param dispatchTarget + * @param name + * @param wFlags + * @param vArg + * @param uArgErr + * @return Variant returned by underlying invokev + */ + public static Variant invokev(Dispatch dispatchTarget, String name, + int wFlags, Variant[] vArg, int[] uArgErr) { + throwIfUnattachedDispatch(dispatchTarget); + return invokev(dispatchTarget, name, 0, Dispatch.LOCALE_SYSTEM_DEFAULT, + wFlags, vArg, uArgErr); + } + + /** + * @param dispatchTarget + * @param name + * @param wFlags + * @param vArg + * @param uArgErr + * @param wFlagsEx + * @return Variant returned by underlying invokev + */ + public static Variant invokev(Dispatch dispatchTarget, String name, + int wFlags, Variant[] vArg, int[] uArgErr, int wFlagsEx) { + throwIfUnattachedDispatch(dispatchTarget); + // do not implement IDispatchEx for now + return invokev(dispatchTarget, name, 0, Dispatch.LOCALE_SYSTEM_DEFAULT, + wFlags, vArg, uArgErr); + } + + /** + * @param dispatchTarget + * @param dispID + * @param wFlags + * @param vArg + * @param uArgErr + * @return Variant returned by underlying invokev + */ + public static Variant invokev(Dispatch dispatchTarget, int dispID, + int wFlags, Variant[] vArg, int[] uArgErr) { + throwIfUnattachedDispatch(dispatchTarget); + return invokev(dispatchTarget, null, dispID, + Dispatch.LOCALE_SYSTEM_DEFAULT, wFlags, vArg, uArgErr); + } + + /* + * ============================================================ start of the + * invokeSubv section + * =========================================================== + */ + + // removed _Guid argument + /** + * @param dispatchTarget + * @param name + * @param dispid + * @param lcid + * @param wFlags + * @param oArg + * @param uArgErr + */ + public static void invokeSub(Dispatch dispatchTarget, String name, + int dispid, int lcid, int wFlags, Object[] oArg, int[] uArgErr) { + throwIfUnattachedDispatch(dispatchTarget); + invokeSubv(dispatchTarget, name, dispid, lcid, wFlags, + VariantUtilities.objectsToVariants(oArg), uArgErr); + } + + /* + * ============================================================ start of the + * invokeSub section + * =========================================================== + */ + /** + * @param dispatchTarget + * @param name + * @param wFlags + * @param oArg + * @param uArgErr + */ + public static void invokeSub(Dispatch dispatchTarget, String name, + int wFlags, Object[] oArg, int[] uArgErr) { + throwIfUnattachedDispatch(dispatchTarget); + invokeSub(dispatchTarget, name, 0, Dispatch.LOCALE_SYSTEM_DEFAULT, + wFlags, oArg, uArgErr); + } + + /** + * @param dispatchTarget + * @param dispid + * @param wFlags + * @param oArg + * @param uArgErr + */ + public static void invokeSub(Dispatch dispatchTarget, int dispid, + int wFlags, Object[] oArg, int[] uArgErr) { + throwIfUnattachedDispatch(dispatchTarget); + invokeSub(dispatchTarget, null, dispid, Dispatch.LOCALE_SYSTEM_DEFAULT, + wFlags, oArg, uArgErr); + } + + /* + * ============================================================ start of the + * callSubN section + * =========================================================== + */ + /** + * makes call to native callSubN + * + * @param dispatchTarget + * @param name + */ + public static void callSub(Dispatch dispatchTarget, String name) { + throwIfUnattachedDispatch(dispatchTarget); + callSubN(dispatchTarget, name, NO_OBJECT_ARGS); + } + + /** + * makes call to native callSubN + * + * @param dispatchTarget + * @param name + * @param a1 + */ + public static void callSub(Dispatch dispatchTarget, String name, Object a1) { + throwIfUnattachedDispatch(dispatchTarget); + callSubN(dispatchTarget, name, new Object[] { a1 }); + } + + /** + * makes call to native callSubN + * + * @param dispatchTarget + * @param name + * @param a1 + * @param a2 + */ + public static void callSub(Dispatch dispatchTarget, String name, Object a1, + Object a2) { + throwIfUnattachedDispatch(dispatchTarget); + callSubN(dispatchTarget, name, new Object[] { a1, a2 }); + } + + /** + * makes call to native callSubN + * + * @param dispatchTarget + * @param name + * @param a1 + * @param a2 + * @param a3 + */ + public static void callSub(Dispatch dispatchTarget, String name, Object a1, + Object a2, Object a3) { + throwIfUnattachedDispatch(dispatchTarget); + callSubN(dispatchTarget, name, new Object[] { a1, a2, a3 }); + } + + /** + * makes call to native callSubN + * + * @param dispatchTarget + * @param name + * @param a1 + * @param a2 + * @param a3 + * @param a4 + */ + public static void callSub(Dispatch dispatchTarget, String name, Object a1, + Object a2, Object a3, Object a4) { + throwIfUnattachedDispatch(dispatchTarget); + callSubN(dispatchTarget, name, new Object[] { a1, a2, a3, a4 }); + } + + /** + * makes call to native callSubN + * + * @param dispatchTarget + * @param name + * @param a1 + * @param a2 + * @param a3 + * @param a4 + * @param a5 + */ + public static void callSub(Dispatch dispatchTarget, String name, Object a1, + Object a2, Object a3, Object a4, Object a5) { + throwIfUnattachedDispatch(dispatchTarget); + callSubN(dispatchTarget, name, new Object[] { a1, a2, a3, a4, a5 }); + } + + /** + * makes call to native callSubN + * + * @param dispatchTarget + * @param name + * @param a1 + * @param a2 + * @param a3 + * @param a4 + * @param a5 + * @param a6 + */ + public static void callSub(Dispatch dispatchTarget, String name, Object a1, + Object a2, Object a3, Object a4, Object a5, Object a6) { + throwIfUnattachedDispatch(dispatchTarget); + callSubN(dispatchTarget, name, new Object[] { a1, a2, a3, a4, a5, a6 }); + } + + /** + * makes call to native callSubN + * + * @param dispatchTarget + * @param name + * @param a1 + * @param a2 + * @param a3 + * @param a4 + * @param a5 + * @param a6 + * @param a7 + */ + public static void callSub(Dispatch dispatchTarget, String name, Object a1, + Object a2, Object a3, Object a4, Object a5, Object a6, Object a7) { + throwIfUnattachedDispatch(dispatchTarget); + callSubN(dispatchTarget, name, new Object[] { a1, a2, a3, a4, a5, a6, + a7 }); + } + + /** + * makes call to native callSubN + * + * @param dispatchTarget + * @param name + * @param a1 + * @param a2 + * @param a3 + * @param a4 + * @param a5 + * @param a6 + * @param a7 + * @param a8 + */ + public static void callSub(Dispatch dispatchTarget, String name, Object a1, + Object a2, Object a3, Object a4, Object a5, Object a6, Object a7, + Object a8) { + throwIfUnattachedDispatch(dispatchTarget); + callSubN(dispatchTarget, name, new Object[] { a1, a2, a3, a4, a5, a6, + a7, a8 }); + } + + /** + * makes call to native callSubN + * + * @param dispatchTarget + * @param dispid + */ + public static void callSub(Dispatch dispatchTarget, int dispid) { + throwIfUnattachedDispatch(dispatchTarget); + callSubN(dispatchTarget, dispid, NO_OBJECT_ARGS); + } + + /** + * makes call to native callSubN + * + * @param dispatchTarget + * @param dispid + * @param a1 + */ + public static void callSub(Dispatch dispatchTarget, int dispid, Object a1) { + throwIfUnattachedDispatch(dispatchTarget); + callSubN(dispatchTarget, dispid, new Object[] { a1 }); + } + + /** + * makes call to native callSubN + * + * @param dispatchTarget + * @param dispid + * @param a1 + * @param a2 + */ + public static void callSub(Dispatch dispatchTarget, int dispid, Object a1, + Object a2) { + throwIfUnattachedDispatch(dispatchTarget); + callSubN(dispatchTarget, dispid, new Object[] { a1, a2 }); + } + + /** + * makes call to native callSubN + * + * @param dispatchTarget + * @param dispid + * @param a1 + * @param a2 + * @param a3 + */ + public static void callSub(Dispatch dispatchTarget, int dispid, Object a1, + Object a2, Object a3) { + callSubN(dispatchTarget, dispid, new Object[] { a1, a2, a3 }); + } + + /** + * makes call to native callSubN + * + * @param dispatchTarget + * @param dispid + * @param a1 + * @param a2 + * @param a3 + * @param a4 + */ + public static void callSub(Dispatch dispatchTarget, int dispid, Object a1, + Object a2, Object a3, Object a4) { + throwIfUnattachedDispatch(dispatchTarget); + callSubN(dispatchTarget, dispid, new Object[] { a1, a2, a3, a4 }); + } + + /** + * makes call to native callSubN + * + * @param dispatchTarget + * @param dispid + * @param a1 + * @param a2 + * @param a3 + * @param a4 + * @param a5 + */ + public static void callSub(Dispatch dispatchTarget, int dispid, Object a1, + Object a2, Object a3, Object a4, Object a5) { + throwIfUnattachedDispatch(dispatchTarget); + callSubN(dispatchTarget, dispid, new Object[] { a1, a2, a3, a4, a5 }); + } + + /** + * makes call to native callSubN + * + * @param dispatchTarget + * @param dispid + * @param a1 + * @param a2 + * @param a3 + * @param a4 + * @param a5 + * @param a6 + */ + public static void callSub(Dispatch dispatchTarget, int dispid, Object a1, + Object a2, Object a3, Object a4, Object a5, Object a6) { + throwIfUnattachedDispatch(dispatchTarget); + callSubN(dispatchTarget, dispid, + new Object[] { a1, a2, a3, a4, a5, a6 }); + } + + /** + * makes call to native callSubN + * + * @param dispatchTarget + * @param dispid + * @param a1 + * @param a2 + * @param a3 + * @param a4 + * @param a5 + * @param a6 + * @param a7 + */ + public static void callSub(Dispatch dispatchTarget, int dispid, Object a1, + Object a2, Object a3, Object a4, Object a5, Object a6, Object a7) { + throwIfUnattachedDispatch(dispatchTarget); + callSubN(dispatchTarget, dispid, new Object[] { a1, a2, a3, a4, a5, a6, + a7 }); + } + + /** + * makes call to native callSubN + * + * @param dispatchTarget + * @param dispid + * @param a1 + * @param a2 + * @param a3 + * @param a4 + * @param a5 + * @param a6 + * @param a7 + * @param a8 + */ + public static void callSub(Dispatch dispatchTarget, int dispid, Object a1, + Object a2, Object a3, Object a4, Object a5, Object a6, Object a7, + Object a8) { + callSubN(dispatchTarget, dispid, new Object[] { a1, a2, a3, a4, a5, a6, + a7, a8 }); + } + + /* + * ============================================================ start of the + * invokev section + * =========================================================== + */ + /** + * Cover for call to underlying invokev() + * + * @param dispatchTarget + * @param name + * @return Variant returned by the request for retrieval of parameter + */ + public static Variant get(Dispatch dispatchTarget, String name) { + throwIfUnattachedDispatch(dispatchTarget); + return invokev(dispatchTarget, name, Dispatch.Get, NO_VARIANT_ARGS, + NO_INT_ARGS); + } + + /** + * Cover for call to underlying invokev() + * + * @param dispatchTarget + * @param dispid + * @return Variant returned by the request for retrieval of parameter + */ + public static Variant get(Dispatch dispatchTarget, int dispid) { + throwIfUnattachedDispatch(dispatchTarget); + return invokev(dispatchTarget, dispid, Dispatch.Get, NO_VARIANT_ARGS, + NO_INT_ARGS); + } + + /* + * ============================================================ start of the + * invoke section + * =========================================================== + */ + /** + * cover for underlying call to invoke + * + * @param dispatchTarget + * @param name + * @param val + */ + public static void putRef(Dispatch dispatchTarget, String name, Object val) { + throwIfUnattachedDispatch(dispatchTarget); + invoke(dispatchTarget, name, Dispatch.PutRef, new Object[] { val }, + new int[1]); + } + + /** + * cover for underlying call to invoke + * + * @param dispatchTarget + * @param dispid + * @param val + */ + public static void putRef(Dispatch dispatchTarget, int dispid, Object val) { + throwIfUnattachedDispatch(dispatchTarget); + invoke(dispatchTarget, dispid, Dispatch.PutRef, new Object[] { val }, + new int[1]); + } + + /** + * not implemented yet + * + * @param dispatchTarget + * @param name + * @return Variant never returned + * @throws com.jacob.com.NotImplementedException + */ + public static Variant get_CaseSensitive(Dispatch dispatchTarget, String name) { + throw new NotImplementedException("not implemented yet"); + } } \ No newline at end of file diff --git a/src/main/java/com/jacob/com/DispatchEvents.java b/src/main/java/com/jacob/com/DispatchEvents.java index 2f6a184..40c59fd 100644 --- a/src/main/java/com/jacob/com/DispatchEvents.java +++ b/src/main/java/com/jacob/com/DispatchEvents.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -59,180 +59,180 @@ package com.jacob.com; */ public class DispatchEvents extends JacobObject { - /** - * pointer to an MS data struct. The COM layer knows the name of this - * variable and puts the windows memory pointer here. - */ - int m_pConnPtProxy = 0; + /** + * pointer to an MS data struct. The COM layer knows the name of this + * variable and puts the windows memory pointer here. + */ + int m_pConnPtProxy = 0; - /** - * the wrapper for the event sink. This object is the one that will be sent - * a message when an event occurs in the MS layer. Normally, the - * InvocationProxy will forward the messages to a wrapped object that it - * contains. - */ - InvocationProxy mInvocationProxy = null; + /** + * the wrapper for the event sink. This object is the one that will be sent + * a message when an event occurs in the MS layer. Normally, the + * InvocationProxy will forward the messages to a wrapped object that it + * contains. + */ + InvocationProxy mInvocationProxy = null; - /** - * This is the most commonly used constructor. - *

- * Creates the event callback linkage between the the MS program represented - * by the Dispatch object and the Java object that will receive the - * callback. - *

- * Can be used on any object that implements IProvideClassInfo. - * - * @param sourceOfEvent - * Dispatch object who's MS app will generate callbacks - * @param eventSink - * Java object that wants to receive the events - */ - public DispatchEvents(Dispatch sourceOfEvent, Object eventSink) { - this(sourceOfEvent, eventSink, null); - } + /** + * This is the most commonly used constructor. + *

+ * Creates the event callback linkage between the the MS program represented + * by the Dispatch object and the Java object that will receive the + * callback. + *

+ * Can be used on any object that implements IProvideClassInfo. + * + * @param sourceOfEvent + * Dispatch object who's MS app will generate callbacks + * @param eventSink + * Java object that wants to receive the events + */ + public DispatchEvents(Dispatch sourceOfEvent, Object eventSink) { + this(sourceOfEvent, eventSink, null); + } - /** - * None of the samples use this constructor. - *

- * Creates the event callback linkage between the the MS program represented - * by the Dispatch object and the Java object that will receive the - * callback. - *

- * Used when the program doesn't implement IProvideClassInfo. It provides a - * way to find the TypeLib in the registry based on the programId. The - * TypeLib is looked up in the registry on the path - * HKEY_LOCAL_MACHINE/SOFTWARE/Classes/CLSID/(CLID drived from - * progid)/ProgID/Typelib - * - * @param sourceOfEvent - * Dispatch object who's MS app will generate callbacks - * @param eventSink - * Java object that wants to receive the events - * @param progId - * program id in the registry that has a TypeLib subkey. The - * progrId is mapped to a CLSID that is they used to look up the - * key to the Typelib - */ - public DispatchEvents(Dispatch sourceOfEvent, Object eventSink, - String progId) { - this(sourceOfEvent, eventSink, progId, null); - } + /** + * None of the samples use this constructor. + *

+ * Creates the event callback linkage between the the MS program represented + * by the Dispatch object and the Java object that will receive the + * callback. + *

+ * Used when the program doesn't implement IProvideClassInfo. It provides a + * way to find the TypeLib in the registry based on the programId. The + * TypeLib is looked up in the registry on the path + * HKEY_LOCAL_MACHINE/SOFTWARE/Classes/CLSID/(CLID drived from + * progid)/ProgID/Typelib + * + * @param sourceOfEvent + * Dispatch object who's MS app will generate callbacks + * @param eventSink + * Java object that wants to receive the events + * @param progId + * program id in the registry that has a TypeLib subkey. The + * progrId is mapped to a CLSID that is they used to look up the + * key to the Typelib + */ + public DispatchEvents(Dispatch sourceOfEvent, Object eventSink, + String progId) { + this(sourceOfEvent, eventSink, progId, null); + } - /** - * Creates the event callback linkage between the the MS program represented - * by the Dispatch object and the Java object that will receive the - * callback. - *

- * This method was added because Excel doesn't implement IProvideClassInfo - * and the registry entry for Excel.Application doesn't include a typelib - * key. - * - *

-	 * DispatchEvents de = new DispatchEvents(someDispatch, someEventHAndler,
-	 * 		"Excel.Application",
-	 * 		"C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE");
-	 * 
- * - * @param sourceOfEvent - * Dispatch object who's MS app will generate callbacks - * @param eventSink - * Java object that wants to receive the events - * @param progId , - * mandatory if the typelib is specified - * @param typeLib - * The location of the typelib to use - */ - public DispatchEvents(Dispatch sourceOfEvent, Object eventSink, - String progId, String typeLib) { - if (JacobObject.isDebugEnabled()) { - System.out.println("DispatchEvents: Registering " + eventSink - + "for events "); - } - if (eventSink instanceof InvocationProxy) { - mInvocationProxy = (InvocationProxy) eventSink; - } else { - mInvocationProxy = getInvocationProxy(eventSink); - } - if (mInvocationProxy != null) { - init3(sourceOfEvent, mInvocationProxy, progId, typeLib); - } else { - if (JacobObject.isDebugEnabled()) { - JacobObject.debug("Cannot register null event sink for events"); - } - throw new IllegalArgumentException( - "Cannot register null event sink for events"); - } - } + /** + * Creates the event callback linkage between the the MS program represented + * by the Dispatch object and the Java object that will receive the + * callback. + *

+ * This method was added because Excel doesn't implement IProvideClassInfo + * and the registry entry for Excel.Application doesn't include a typelib + * key. + * + *

+     * DispatchEvents de = new DispatchEvents(someDispatch, someEventHAndler,
+     *         "Excel.Application",
+     *         "C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE");
+     * 
+ * + * @param sourceOfEvent + * Dispatch object who's MS app will generate callbacks + * @param eventSink + * Java object that wants to receive the events + * @param progId , + * mandatory if the typelib is specified + * @param typeLib + * The location of the typelib to use + */ + public DispatchEvents(Dispatch sourceOfEvent, Object eventSink, + String progId, String typeLib) { + if (JacobObject.isDebugEnabled()) { + System.out.println("DispatchEvents: Registering " + eventSink + + "for events "); + } + if (eventSink instanceof InvocationProxy) { + mInvocationProxy = (InvocationProxy) eventSink; + } else { + mInvocationProxy = getInvocationProxy(eventSink); + } + if (mInvocationProxy != null) { + init3(sourceOfEvent, mInvocationProxy, progId, typeLib); + } else { + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("Cannot register null event sink for events"); + } + throw new IllegalArgumentException( + "Cannot register null event sink for events"); + } + } - /** - * Returns an instance of the proxy configured with pTargetObject as its - * target - * - * @param pTargetObject - * @return InvocationProxy an instance of the proxy this DispatchEvents will - * send to the COM layer - */ - protected InvocationProxy getInvocationProxy(Object pTargetObject) { - InvocationProxy newProxy = new InvocationProxyAllVariants(); - newProxy.setTarget(pTargetObject); - return newProxy; - } + /** + * Returns an instance of the proxy configured with pTargetObject as its + * target + * + * @param pTargetObject + * @return InvocationProxy an instance of the proxy this DispatchEvents will + * send to the COM layer + */ + protected InvocationProxy getInvocationProxy(Object pTargetObject) { + InvocationProxy newProxy = new InvocationProxyAllVariants(); + newProxy.setTarget(pTargetObject); + return newProxy; + } - /** - * hooks up a connection point proxy by progId event methods on the sink - * object will be called by name with a signature of (Variant[] args) - * - * You must specify the location of the typeLib. - * - * @param src - * dispatch that is the source of the messages - * @param sink - * the object that will receive the messages - * @param progId - * optional program id. most folks don't need this either - * @param typeLib - * optional parameter for those programs that don't register - * their type libs (like Excel) - */ - private native void init3(Dispatch src, Object sink, String progId, - String typeLib); + /** + * hooks up a connection point proxy by progId event methods on the sink + * object will be called by name with a signature of (Variant[] args) + * + * You must specify the location of the typeLib. + * + * @param src + * dispatch that is the source of the messages + * @param sink + * the object that will receive the messages + * @param progId + * optional program id. most folks don't need this either + * @param typeLib + * optional parameter for those programs that don't register + * their type libs (like Excel) + */ + private native void init3(Dispatch src, Object sink, String progId, + String typeLib); - /** - * now private so only this object can asccess was: call this to explicitly - * release the com object before gc - * - */ - private native void release(); + /** + * now private so only this object can asccess was: call this to explicitly + * release the com object before gc + * + */ + private native void release(); - /* - * (non-Javadoc) - * - * @see java.lang.Object#finalize() - */ - protected void finalize() { - safeRelease(); - } + /* + * (non-Javadoc) + * + * @see java.lang.Object#finalize() + */ + protected void finalize() { + safeRelease(); + } - /* - * (non-Javadoc) - * - * @see com.jacob.com.JacobObject#safeRelease() - */ - public void safeRelease() { - if (mInvocationProxy != null) { - mInvocationProxy.setTarget(null); - } - mInvocationProxy = null; - super.safeRelease(); - if (m_pConnPtProxy != 0) { - release(); - m_pConnPtProxy = 0; - } else { - // looks like a double release - if (isDebugEnabled()) { - debug("DispatchEvents:" + this.hashCode() + " double release"); - } - } - } + /* + * (non-Javadoc) + * + * @see com.jacob.com.JacobObject#safeRelease() + */ + public void safeRelease() { + if (mInvocationProxy != null) { + mInvocationProxy.setTarget(null); + } + mInvocationProxy = null; + super.safeRelease(); + if (m_pConnPtProxy != 0) { + release(); + m_pConnPtProxy = 0; + } else { + // looks like a double release + if (isDebugEnabled()) { + debug("DispatchEvents:" + this.hashCode() + " double release"); + } + } + } } diff --git a/src/main/java/com/jacob/com/DispatchIdentifier.java b/src/main/java/com/jacob/com/DispatchIdentifier.java index cef036c..dedc4a5 100644 --- a/src/main/java/com/jacob/com/DispatchIdentifier.java +++ b/src/main/java/com/jacob/com/DispatchIdentifier.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @@ -47,74 +47,74 @@ package com.jacob.com; */ public class DispatchIdentifier { - private DispatchIdentifier() { - // This is utility class so there is no constructor. - } + private DispatchIdentifier() { + // This is utility class so there is no constructor. + } - public static final int DISPID_UNKNOWN = -1; - public static final int DISPID_VALUE = 0; - public static final int DISPID_PROPERTYPUT = -3; - public static final int DISPID_NEWENUM = -4; - public static final int DISPID_EVALUATE = -5; - public static final int DISPID_CONSTRUCTOR = -6; - public static final int DISPID_DESTRUCTOR = -7; - public static final int DISPID_COLLECT = -8; - public static final int DISPID_AUTOSIZE = -500; - public static final int DISPID_BACKCOLOR = -501; - public static final int DISPID_BACKSTYLE = -502; - public static final int DISPID_BORDERCOLOR = -503; - public static final int DISPID_BORDERSTYLE = -504; - public static final int DISPID_BORDERWIDTH = -505; - public static final int DISPID_DRAWMODE = -507; - public static final int DISPID_DRAWSTYLE = -508; - public static final int DISPID_DRAWWIDTH = -509; - public static final int DISPID_FILLCOLOR = -510; - public static final int DISPID_FILLSTYLE = -511; - public static final int DISPID_FONT = -512; - public static final int DISPID_FORECOLOR = -513; - public static final int DISPID_ENABLED = -514; - public static final int DISPID_HWND = -515; - public static final int DISPID_TABSTOP = -516; - public static final int DISPID_TEXT = -517; - public static final int DISPID_CAPTION = -518; - public static final int DISPID_BORDERVISIBLE = -519; - public static final int DISPID_APPEARANCE = -520; - public static final int DISPID_MOUSEPOINTER = -521; - public static final int DISPID_MOUSEICON = -522; - public static final int DISPID_PICTURE = -523; - public static final int DISPID_VALID = -524; - public static final int DISPID_READYSTATE = -525; - public static final int DISPID_REFRESH = -550; - public static final int DISPID_DOCLICK = -551; - public static final int DISPID_ABOUTBOX = -552; - public static final int DISPID_CLICK = -600; - public static final int DISPID_DBLCLICK = -601; - public static final int DISPID_KEYDOWN = -602; - public static final int DISPID_KEYPRESS = -603; - public static final int DISPID_KEYUP = -604; - public static final int DISPID_MOUSEDOWN = -605; - public static final int DISPID_MOUSEMOVE = -606; - public static final int DISPID_MOUSEUP = -607; - public static final int DISPID_ERROREVENT = -608; - public static final int DISPID_READYSTATECHANGE = -609; - public static final int DISPID_AMBIENT_BACKCOLOR = -701; - public static final int DISPID_AMBIENT_DISPLAYNAME = -702; - public static final int DISPID_AMBIENT_FONT = -703; - public static final int DISPID_AMBIENT_FORECOLOR = -704; - public static final int DISPID_AMBIENT_LOCALEID = -705; - public static final int DISPID_AMBIENT_MESSAGEREFLECT = -706; - public static final int DISPID_AMBIENT_SCALEUNITS = -707; - public static final int DISPID_AMBIENT_TEXTALIGN = -708; - public static final int DISPID_AMBIENT_USERMODE = -709; - public static final int DISPID_AMBIENT_UIDEAD = -710; - public static final int DISPID_AMBIENT_SHOWGRABHANDLES = -711; - public static final int DISPID_AMBIENT_SHOWHATCHING = -712; - public static final int DISPID_AMBIENT_DISPLAYASDEFAULT = -713; - public static final int DISPID_AMBIENT_SUPPORTSMNEMONICS = -714; - public static final int DISPID_AMBIENT_AUTOCLIP = -715; - public static final int DISPID_AMBIENT_APPEARANCE = -716; - public static final int DISPID_AMBIENT_CODEPAGE = -725; - public static final int DISPID_AMBIENT_PALETTE = -726; - public static final int DISPID_AMBIENT_CHARSET = -727; - public static final int DISPID_AMBIENT_TRANSFERPRIORITY = -728; + public static final int DISPID_UNKNOWN = -1; + public static final int DISPID_VALUE = 0; + public static final int DISPID_PROPERTYPUT = -3; + public static final int DISPID_NEWENUM = -4; + public static final int DISPID_EVALUATE = -5; + public static final int DISPID_CONSTRUCTOR = -6; + public static final int DISPID_DESTRUCTOR = -7; + public static final int DISPID_COLLECT = -8; + public static final int DISPID_AUTOSIZE = -500; + public static final int DISPID_BACKCOLOR = -501; + public static final int DISPID_BACKSTYLE = -502; + public static final int DISPID_BORDERCOLOR = -503; + public static final int DISPID_BORDERSTYLE = -504; + public static final int DISPID_BORDERWIDTH = -505; + public static final int DISPID_DRAWMODE = -507; + public static final int DISPID_DRAWSTYLE = -508; + public static final int DISPID_DRAWWIDTH = -509; + public static final int DISPID_FILLCOLOR = -510; + public static final int DISPID_FILLSTYLE = -511; + public static final int DISPID_FONT = -512; + public static final int DISPID_FORECOLOR = -513; + public static final int DISPID_ENABLED = -514; + public static final int DISPID_HWND = -515; + public static final int DISPID_TABSTOP = -516; + public static final int DISPID_TEXT = -517; + public static final int DISPID_CAPTION = -518; + public static final int DISPID_BORDERVISIBLE = -519; + public static final int DISPID_APPEARANCE = -520; + public static final int DISPID_MOUSEPOINTER = -521; + public static final int DISPID_MOUSEICON = -522; + public static final int DISPID_PICTURE = -523; + public static final int DISPID_VALID = -524; + public static final int DISPID_READYSTATE = -525; + public static final int DISPID_REFRESH = -550; + public static final int DISPID_DOCLICK = -551; + public static final int DISPID_ABOUTBOX = -552; + public static final int DISPID_CLICK = -600; + public static final int DISPID_DBLCLICK = -601; + public static final int DISPID_KEYDOWN = -602; + public static final int DISPID_KEYPRESS = -603; + public static final int DISPID_KEYUP = -604; + public static final int DISPID_MOUSEDOWN = -605; + public static final int DISPID_MOUSEMOVE = -606; + public static final int DISPID_MOUSEUP = -607; + public static final int DISPID_ERROREVENT = -608; + public static final int DISPID_READYSTATECHANGE = -609; + public static final int DISPID_AMBIENT_BACKCOLOR = -701; + public static final int DISPID_AMBIENT_DISPLAYNAME = -702; + public static final int DISPID_AMBIENT_FONT = -703; + public static final int DISPID_AMBIENT_FORECOLOR = -704; + public static final int DISPID_AMBIENT_LOCALEID = -705; + public static final int DISPID_AMBIENT_MESSAGEREFLECT = -706; + public static final int DISPID_AMBIENT_SCALEUNITS = -707; + public static final int DISPID_AMBIENT_TEXTALIGN = -708; + public static final int DISPID_AMBIENT_USERMODE = -709; + public static final int DISPID_AMBIENT_UIDEAD = -710; + public static final int DISPID_AMBIENT_SHOWGRABHANDLES = -711; + public static final int DISPID_AMBIENT_SHOWHATCHING = -712; + public static final int DISPID_AMBIENT_DISPLAYASDEFAULT = -713; + public static final int DISPID_AMBIENT_SUPPORTSMNEMONICS = -714; + public static final int DISPID_AMBIENT_AUTOCLIP = -715; + public static final int DISPID_AMBIENT_APPEARANCE = -716; + public static final int DISPID_AMBIENT_CODEPAGE = -725; + public static final int DISPID_AMBIENT_PALETTE = -726; + public static final int DISPID_AMBIENT_CHARSET = -727; + public static final int DISPID_AMBIENT_TRANSFERPRIORITY = -728; } diff --git a/src/main/java/com/jacob/com/DispatchProxy.java b/src/main/java/com/jacob/com/DispatchProxy.java index a41980b..4710ce6 100644 --- a/src/main/java/com/jacob/com/DispatchProxy.java +++ b/src/main/java/com/jacob/com/DispatchProxy.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -48,64 +48,64 @@ package com.jacob.com; * construct a separate DispatchProxy instance for each such case! */ public class DispatchProxy extends JacobObject { - /** - * Comment for m_pStream - */ - public int m_pStream; + /** + * Comment for m_pStream + */ + public int m_pStream; - /** - * Marshals the passed in dispatch into the stream - * - * @param localDispatch - */ - public DispatchProxy(Dispatch localDispatch) { - MarshalIntoStream(localDispatch); - } + /** + * Marshals the passed in dispatch into the stream + * + * @param localDispatch + */ + public DispatchProxy(Dispatch localDispatch) { + MarshalIntoStream(localDispatch); + } - /** - * - * @return Dispatch the dispatch retrieved from the stream - */ - public Dispatch toDispatch() { - return MarshalFromStream(); - } + /** + * + * @return Dispatch the dispatch retrieved from the stream + */ + public Dispatch toDispatch() { + return MarshalFromStream(); + } - private native void MarshalIntoStream(Dispatch d); + private native void MarshalIntoStream(Dispatch d); - private native Dispatch MarshalFromStream(); + private native Dispatch MarshalFromStream(); - /** - * now private so only this object can access was: call this to explicitly - * release the com object before gc - * - */ - private native void release(); + /** + * now private so only this object can access was: call this to explicitly + * release the com object before gc + * + */ + private native void release(); - /* - * (non-Javadoc) - * - * @see java.lang.Object#finalize() - */ - public void finalize() { - safeRelease(); - } + /* + * (non-Javadoc) + * + * @see java.lang.Object#finalize() + */ + public void finalize() { + safeRelease(); + } - /* - * (non-Javadoc) - * - * @see com.jacob.com.JacobObject#safeRelease() - */ - public void safeRelease() { - super.safeRelease(); - if (m_pStream != 0) { - release(); - m_pStream = 0; - } else { - // looks like a double release - if (isDebugEnabled()) { - debug(this.getClass().getName() + ":" + this.hashCode() - + " double release"); - } - } - } + /* + * (non-Javadoc) + * + * @see com.jacob.com.JacobObject#safeRelease() + */ + public void safeRelease() { + super.safeRelease(); + if (m_pStream != 0) { + release(); + m_pStream = 0; + } else { + // looks like a double release + if (isDebugEnabled()) { + debug(this.getClass().getName() + ":" + this.hashCode() + + " double release"); + } + } + } } \ No newline at end of file diff --git a/src/main/java/com/jacob/com/EnumVariant.java b/src/main/java/com/jacob/com/EnumVariant.java index 4ca5815..ff637f8 100644 --- a/src/main/java/com/jacob/com/EnumVariant.java +++ b/src/main/java/com/jacob/com/EnumVariant.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -43,133 +43,133 @@ package com.jacob.com; * (mailto:Thomas.Hallgren@eoncompany.com) */ public class EnumVariant extends JacobObject implements - java.util.Enumeration { - private int m_pIEnumVARIANT; + java.util.Enumeration { + private int m_pIEnumVARIANT; - private final Variant[] m_recBuf = new Variant[1]; + private final Variant[] m_recBuf = new Variant[1]; - // this only gets called from JNI - // - protected EnumVariant(int pIEnumVARIANT) { - m_pIEnumVARIANT = pIEnumVARIANT; - } + // this only gets called from JNI + // + protected EnumVariant(int pIEnumVARIANT) { + m_pIEnumVARIANT = pIEnumVARIANT; + } - /** - * @param disp - */ - public EnumVariant(Dispatch disp) { - int[] hres = new int[1]; - Variant evv = Dispatch.invokev(disp, DispatchIdentifier.DISPID_NEWENUM, - Dispatch.Get, new Variant[0], hres); - if (evv.getvt() != Variant.VariantObject) - // - // The DISPID_NEWENUM did not result in a valid object - // - throw new ComFailException("Can't obtain EnumVARIANT"); + /** + * @param disp + */ + public EnumVariant(Dispatch disp) { + int[] hres = new int[1]; + Variant evv = Dispatch.invokev(disp, DispatchIdentifier.DISPID_NEWENUM, + Dispatch.Get, new Variant[0], hres); + if (evv.getvt() != Variant.VariantObject) + // + // The DISPID_NEWENUM did not result in a valid object + // + throw new ComFailException("Can't obtain EnumVARIANT"); - EnumVariant tmp = evv.toEnumVariant(); - m_pIEnumVARIANT = tmp.m_pIEnumVARIANT; - tmp.m_pIEnumVARIANT = 0; - } + EnumVariant tmp = evv.toEnumVariant(); + m_pIEnumVARIANT = tmp.m_pIEnumVARIANT; + tmp.m_pIEnumVARIANT = 0; + } - /** - * Implements java.util.Enumeration - * - * @return boolean true if there are more elements in this enumeration - */ - public boolean hasMoreElements() { - { - if (m_recBuf[0] == null) { - if (this.Next(m_recBuf) <= 0) - return false; - } - return true; - } - } + /** + * Implements java.util.Enumeration + * + * @return boolean true if there are more elements in this enumeration + */ + public boolean hasMoreElements() { + { + if (m_recBuf[0] == null) { + if (this.Next(m_recBuf) <= 0) + return false; + } + return true; + } + } - /** - * Implements java.util.Enumeration - * - * @return next element in the enumeration - */ - public Variant nextElement() { - Variant last = m_recBuf[0]; - if (last == null) { - if (this.Next(m_recBuf) <= 0) - throw new java.util.NoSuchElementException(); - last = m_recBuf[0]; - } - m_recBuf[0] = null; - return last; - } + /** + * Implements java.util.Enumeration + * + * @return next element in the enumeration + */ + public Variant nextElement() { + Variant last = m_recBuf[0]; + if (last == null) { + if (this.Next(m_recBuf) <= 0) + throw new java.util.NoSuchElementException(); + last = m_recBuf[0]; + } + m_recBuf[0] = null; + return last; + } - /** - * Get next element in collection or null if at end - * - * @return Variant that is next in the collection - * @deprecated use nextElement() instead - */ - @Deprecated - public Variant Next() { - if (hasMoreElements()) - return nextElement(); - return null; - } + /** + * Get next element in collection or null if at end + * + * @return Variant that is next in the collection + * @deprecated use nextElement() instead + */ + @Deprecated + public Variant Next() { + if (hasMoreElements()) + return nextElement(); + return null; + } - /** - * This should be private and wrapped to protect JNI layer. - * - * @param receiverArray - * @return Returns the next variant object pointer as an int from windows - * layer - */ - public native int Next(Variant[] receiverArray); + /** + * This should be private and wrapped to protect JNI layer. + * + * @param receiverArray + * @return Returns the next variant object pointer as an int from windows + * layer + */ + public native int Next(Variant[] receiverArray); - /** - * This should be private and wrapped to protect JNI layer. - * - * @param count - * number to skip - */ - public native void Skip(int count); + /** + * This should be private and wrapped to protect JNI layer. + * + * @param count + * number to skip + */ + public native void Skip(int count); - /** - * This should be private and wrapped to protect JNI layer - */ - public native void Reset(); + /** + * This should be private and wrapped to protect JNI layer + */ + public native void Reset(); - /** - * now private so only this object can access was: call this to explicitly - * release the com object before gc - * - */ - private native void release(); + /** + * now private so only this object can access was: call this to explicitly + * release the com object before gc + * + */ + private native void release(); - /* - * (non-Javadoc) - * - * @see java.lang.Object#finalize() - */ - protected void finalize() { - safeRelease(); - } + /* + * (non-Javadoc) + * + * @see java.lang.Object#finalize() + */ + protected void finalize() { + safeRelease(); + } - /* - * (non-Javadoc) - * - * @see com.jacob.com.JacobObject#safeRelease() - */ - public void safeRelease() { - super.safeRelease(); - if (m_pIEnumVARIANT != 0) { - this.release(); - m_pIEnumVARIANT = 0; - } else { - // looks like a double release - if (isDebugEnabled()) { - debug(this.getClass().getName() + ":" + this.hashCode() - + " double release"); - } - } - } + /* + * (non-Javadoc) + * + * @see com.jacob.com.JacobObject#safeRelease() + */ + public void safeRelease() { + super.safeRelease(); + if (m_pIEnumVARIANT != 0) { + this.release(); + m_pIEnumVARIANT = 0; + } else { + // looks like a double release + if (isDebugEnabled()) { + debug(this.getClass().getName() + ":" + this.hashCode() + + " double release"); + } + } + } } \ No newline at end of file diff --git a/src/main/java/com/jacob/com/InvocationProxy.java b/src/main/java/com/jacob/com/InvocationProxy.java index 467ba1e..7b71748 100644 --- a/src/main/java/com/jacob/com/InvocationProxy.java +++ b/src/main/java/com/jacob/com/InvocationProxy.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -58,70 +58,70 @@ package com.jacob.com; */ public abstract class InvocationProxy { - /** - * the object we will try and forward to. - */ - protected Object mTargetObject = null; + /** + * the object we will try and forward to. + */ + protected Object mTargetObject = null; - /** - * dummy constructor for subclasses that don't actually wrap anything and - * just want to override the invoke() method - */ - protected InvocationProxy() { - super(); - } + /** + * dummy constructor for subclasses that don't actually wrap anything and + * just want to override the invoke() method + */ + protected InvocationProxy() { + super(); + } - /** - * The method actually invoked by EventProxy.cpp. The method name is - * calculated by the underlying JNI code from the MS windows Callback - * function name. The method is assumed to take an array of Variant objects. - * The method may return a Variant or be a void. Those are the only two - * options that will not blow up. - *

- * Subclasses that override this should make sure mTargetObject is not null - * before processing. - * - * @param methodName - * name of method in mTargetObject we will invoke - * @param targetParameters - * Variant[] that is the single parameter to the method - * @return an object that will be returned to the com event caller - */ - public abstract Variant invoke(String methodName, - Variant targetParameters[]); + /** + * The method actually invoked by EventProxy.cpp. The method name is + * calculated by the underlying JNI code from the MS windows Callback + * function name. The method is assumed to take an array of Variant objects. + * The method may return a Variant or be a void. Those are the only two + * options that will not blow up. + *

+ * Subclasses that override this should make sure mTargetObject is not null + * before processing. + * + * @param methodName + * name of method in mTargetObject we will invoke + * @param targetParameters + * Variant[] that is the single parameter to the method + * @return an object that will be returned to the com event caller + */ + public abstract Variant invoke(String methodName, + Variant targetParameters[]); - /** - * used by EventProxy.cpp to create variant objects in the right thread - * - * @return Variant object that will be used by the COM layer - */ - public Variant getVariant() { - return new VariantViaEvent(); - } + /** + * used by EventProxy.cpp to create variant objects in the right thread + * + * @return Variant object that will be used by the COM layer + */ + public Variant getVariant() { + return new VariantViaEvent(); + } - /** - * Sets the target for this InvocationProxy. - * - * @param pTargetObject - * @throws IllegalArgumentException - * if target is not publicly accessible - */ - public void setTarget(Object pTargetObject) { - if (JacobObject.isDebugEnabled()) { - JacobObject.debug("InvocationProxy: setting target " - + pTargetObject); - } - if (pTargetObject != null) { - // JNI code apparently bypasses this check and could operate against - // protected classes. This seems like a security issue... - // maybe it was because JNI code isn't in a package? - if (!java.lang.reflect.Modifier.isPublic(pTargetObject.getClass() - .getModifiers())) { - throw new IllegalArgumentException( - "InvocationProxy only public classes can receive event notifications"); - } - } - mTargetObject = pTargetObject; - } + /** + * Sets the target for this InvocationProxy. + * + * @param pTargetObject + * @throws IllegalArgumentException + * if target is not publicly accessible + */ + public void setTarget(Object pTargetObject) { + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("InvocationProxy: setting target " + + pTargetObject); + } + if (pTargetObject != null) { + // JNI code apparently bypasses this check and could operate against + // protected classes. This seems like a security issue... + // maybe it was because JNI code isn't in a package? + if (!java.lang.reflect.Modifier.isPublic(pTargetObject.getClass() + .getModifiers())) { + throw new IllegalArgumentException( + "InvocationProxy only public classes can receive event notifications"); + } + } + mTargetObject = pTargetObject; + } } diff --git a/src/main/java/com/jacob/com/InvocationProxyAllVariants.java b/src/main/java/com/jacob/com/InvocationProxyAllVariants.java index 6a0fcef..d6ad675 100644 --- a/src/main/java/com/jacob/com/InvocationProxyAllVariants.java +++ b/src/main/java/com/jacob/com/InvocationProxyAllVariants.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -55,88 +55,88 @@ import java.lang.reflect.Method; */ public class InvocationProxyAllVariants extends InvocationProxy { - /* - * (non-Javadoc) - * - * @see com.jacob.com.InvocationProxy#invoke(java.lang.String, - * com.jacob.com.Variant[]) - */ - @SuppressWarnings("unchecked") - public Variant invoke(String methodName, Variant targetParameters[]) { - Variant mVariantToBeReturned = null; - if (mTargetObject == null) { - if (JacobObject.isDebugEnabled()) { - JacobObject.debug("InvocationProxy: received notification (" - + methodName + ") with no target set"); - } - // structured programming guidlines say this return should not be up - // here - return null; - } - Class targetClass = mTargetObject.getClass(); - if (methodName == null) { - throw new IllegalArgumentException( - "InvocationProxy: missing method name"); - } - if (targetParameters == null) { - throw new IllegalArgumentException( - "InvocationProxy: missing Variant parameters"); - } - try { - if (JacobObject.isDebugEnabled()) { - JacobObject.debug("InvocationProxy: trying to invoke " - + methodName + " on " + mTargetObject); - } - Method targetMethod; - targetMethod = targetClass.getMethod(methodName, - new Class[] { Variant[].class }); - if (targetMethod != null) { - // protected classes can't be invoked against even if they - // let you grab the method. you could do - // targetMethod.setAccessible(true); - // but that should be stopped by the security manager - Object mReturnedByInvocation = null; - mReturnedByInvocation = targetMethod.invoke(mTargetObject, - new Object[] { targetParameters }); - if (mReturnedByInvocation == null) { - mVariantToBeReturned = null; - } else if (!(mReturnedByInvocation instanceof Variant)) { - // could try and convert to Variant here. - throw new IllegalArgumentException( - "InvocationProxy: invokation of target method returned " - + "non-null non-variant object: " - + mReturnedByInvocation); - } else { - mVariantToBeReturned = (Variant) mReturnedByInvocation; - } - } - } catch (SecurityException e) { - // what causes this exception? - e.printStackTrace(); - } catch (NoSuchMethodException e) { - // this happens whenever the listener doesn't implement all the - // methods - if (JacobObject.isDebugEnabled()) { - JacobObject.debug("InvocationProxy: listener (" + mTargetObject - + ") doesn't implement " + methodName); - } - } catch (IllegalArgumentException e) { - e.printStackTrace(); - // we can throw these inside the catch block so need to re-throw it - throw e; - } catch (IllegalAccessException e) { - // can't access the method on the target instance for some reason - if (JacobObject.isDebugEnabled()) { - JacobObject - .debug("InvocationProxy: probably tried to access public method on non public class" - + methodName); - } - e.printStackTrace(); - } catch (InvocationTargetException e) { - // invocation of target method failed - e.printStackTrace(); - } - return mVariantToBeReturned; + /* + * (non-Javadoc) + * + * @see com.jacob.com.InvocationProxy#invoke(java.lang.String, + * com.jacob.com.Variant[]) + */ + @SuppressWarnings("unchecked") + public Variant invoke(String methodName, Variant targetParameters[]) { + Variant mVariantToBeReturned = null; + if (mTargetObject == null) { + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("InvocationProxy: received notification (" + + methodName + ") with no target set"); + } + // structured programming guidlines say this return should not be up + // here + return null; + } + Class targetClass = mTargetObject.getClass(); + if (methodName == null) { + throw new IllegalArgumentException( + "InvocationProxy: missing method name"); + } + if (targetParameters == null) { + throw new IllegalArgumentException( + "InvocationProxy: missing Variant parameters"); + } + try { + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("InvocationProxy: trying to invoke " + + methodName + " on " + mTargetObject); + } + Method targetMethod; + targetMethod = targetClass.getMethod(methodName, + new Class[] { Variant[].class }); + if (targetMethod != null) { + // protected classes can't be invoked against even if they + // let you grab the method. you could do + // targetMethod.setAccessible(true); + // but that should be stopped by the security manager + Object mReturnedByInvocation = null; + mReturnedByInvocation = targetMethod.invoke(mTargetObject, + new Object[] { targetParameters }); + if (mReturnedByInvocation == null) { + mVariantToBeReturned = null; + } else if (!(mReturnedByInvocation instanceof Variant)) { + // could try and convert to Variant here. + throw new IllegalArgumentException( + "InvocationProxy: invokation of target method returned " + + "non-null non-variant object: " + + mReturnedByInvocation); + } else { + mVariantToBeReturned = (Variant) mReturnedByInvocation; + } + } + } catch (SecurityException e) { + // what causes this exception? + e.printStackTrace(); + } catch (NoSuchMethodException e) { + // this happens whenever the listener doesn't implement all the + // methods + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("InvocationProxy: listener (" + mTargetObject + + ") doesn't implement " + methodName); + } + } catch (IllegalArgumentException e) { + e.printStackTrace(); + // we can throw these inside the catch block so need to re-throw it + throw e; + } catch (IllegalAccessException e) { + // can't access the method on the target instance for some reason + if (JacobObject.isDebugEnabled()) { + JacobObject + .debug("InvocationProxy: probably tried to access public method on non public class" + + methodName); + } + e.printStackTrace(); + } catch (InvocationTargetException e) { + // invocation of target method failed + e.printStackTrace(); + } + return mVariantToBeReturned; - } + } } diff --git a/src/main/java/com/jacob/com/JacobException.java b/src/main/java/com/jacob/com/JacobException.java index 94daa96..6179287 100644 --- a/src/main/java/com/jacob/com/JacobException.java +++ b/src/main/java/com/jacob/com/JacobException.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -45,24 +45,24 @@ package com.jacob.com; */ public class JacobException extends RuntimeException { - /** - * - */ - private static final long serialVersionUID = -1637125318746002715L; + /** + * + */ + private static final long serialVersionUID = -1637125318746002715L; - /** - * Default constructor. Calls super with a "No Message Provided" string - */ - public JacobException() { - super("No Message Provided"); - } + /** + * Default constructor. Calls super with a "No Message Provided" string + */ + public JacobException() { + super("No Message Provided"); + } - /** - * standard constructor - * - * @param message - */ - public JacobException(String message) { - super(message); - } + /** + * standard constructor + * + * @param message + */ + public JacobException(String message) { + super(message); + } } diff --git a/src/main/java/com/jacob/com/JacobObject.java b/src/main/java/com/jacob/com/JacobObject.java index 99a5d82..e8088a4 100644 --- a/src/main/java/com/jacob/com/JacobObject.java +++ b/src/main/java/com/jacob/com/JacobObject.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -53,78 +53,78 @@ package com.jacob.com; */ public class JacobObject { - /** - * Standard constructor that adds this JacobObject to the memory management - * pool. - */ - public JacobObject() { - ROT.addObject(this); - } + /** + * Standard constructor that adds this JacobObject to the memory management + * pool. + */ + public JacobObject() { + ROT.addObject(this); + } - /** - * Finalizers call this method. This method should release any COM data - * structures in a way that it can be called multiple times. This can happen - * if someone manually calls this and then a finalizer calls it. - */ - public void safeRelease() { - // currently does nothing - subclasses may do something - if (isDebugEnabled()) { - // this used to do a toString() but that is bad for SafeArray - debug("SafeRelease: " + this.getClass().getName()); - } - } + /** + * Finalizers call this method. This method should release any COM data + * structures in a way that it can be called multiple times. This can happen + * if someone manually calls this and then a finalizer calls it. + */ + public void safeRelease() { + // currently does nothing - subclasses may do something + if (isDebugEnabled()) { + // this used to do a toString() but that is bad for SafeArray + debug("SafeRelease: " + this.getClass().getName()); + } + } - /** - * When things go wrong, it is useful to be able to debug the ROT. - */ - private static final boolean DEBUG = - // true; - "true".equalsIgnoreCase(System.getProperty("com.jacob.debug")); + /** + * When things go wrong, it is useful to be able to debug the ROT. + */ + private static final boolean DEBUG = + // true; + "true".equalsIgnoreCase(System.getProperty("com.jacob.debug")); - protected static boolean isDebugEnabled() { - // return true; - return DEBUG; - } + protected static boolean isDebugEnabled() { + // return true; + return DEBUG; + } - /** - * Loads JacobVersion.Properties and returns the value of version in it - * - * @deprecated use JacobReleaseInfo.getBuildDate() instead. - * @return String value of version in JacobVersion.Properties or "" if none - */ - @Deprecated - public static String getBuildDate() { - return JacobReleaseInfo.getBuildDate(); - } + /** + * Loads JacobVersion.Properties and returns the value of version in it + * + * @deprecated use JacobReleaseInfo.getBuildDate() instead. + * @return String value of version in JacobVersion.Properties or "" if none + */ + @Deprecated + public static String getBuildDate() { + return JacobReleaseInfo.getBuildDate(); + } - /** - * Loads JacobVersion.Properties and returns the value of version in it - * - * @deprecated use JacobReleaseInfo.getBuildVersion() instead. - * @return String value of version in JacobVersion.Properties or "" if none - */ - @Deprecated - public static String getBuildVersion() { - return JacobReleaseInfo.getBuildVersion(); - } + /** + * Loads JacobVersion.Properties and returns the value of version in it + * + * @deprecated use JacobReleaseInfo.getBuildVersion() instead. + * @return String value of version in JacobVersion.Properties or "" if none + */ + @Deprecated + public static String getBuildVersion() { + return JacobReleaseInfo.getBuildVersion(); + } - /** - * Very basic debugging function. - * - * @param istrMessage - */ - protected static void debug(String istrMessage) { - if (isDebugEnabled()) { - System.out.println(Thread.currentThread().getName() + ": " - + istrMessage); - } - } + /** + * Very basic debugging function. + * + * @param istrMessage + */ + protected static void debug(String istrMessage) { + if (isDebugEnabled()) { + System.out.println(Thread.currentThread().getName() + ": " + + istrMessage); + } + } - /** - * force the jacob DLL to be loaded whenever this class is referenced - */ - static { - LibraryLoader.loadJacobLibrary(); - } + /** + * force the jacob DLL to be loaded whenever this class is referenced + */ + static { + LibraryLoader.loadJacobLibrary(); + } } \ No newline at end of file diff --git a/src/main/java/com/jacob/com/JacobReleaseInfo.java b/src/main/java/com/jacob/com/JacobReleaseInfo.java index ec9f669..855ed68 100644 --- a/src/main/java/com/jacob/com/JacobReleaseInfo.java +++ b/src/main/java/com/jacob/com/JacobReleaseInfo.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -49,86 +49,86 @@ import java.util.Properties; */ public class JacobReleaseInfo { - /** - * holds the build version as retrieved from the version properties file - * that exists in the JAR. This can be retrieved by calling the static - * method getBuildVersion() - * - * @see #getBuildVersion() - */ - private static String buildVersion = ""; - /** - * holds the build date as retrieved from the version properties file that - * exists in the JAR This can be retrieved by calling the static method - * getBuildDate() - * - * @see #getBuildDate() - */ - private static String buildDate = ""; - /** the name of the jacob version properties file */ - private static final String PROPERTY_FILE_NAME = "META-INF/JacobVersion.properties"; + /** + * holds the build version as retrieved from the version properties file + * that exists in the JAR. This can be retrieved by calling the static + * method getBuildVersion() + * + * @see #getBuildVersion() + */ + private static String buildVersion = ""; + /** + * holds the build date as retrieved from the version properties file that + * exists in the JAR This can be retrieved by calling the static method + * getBuildDate() + * + * @see #getBuildDate() + */ + private static String buildDate = ""; + /** the name of the jacob version properties file */ + private static final String PROPERTY_FILE_NAME = "META-INF/JacobVersion.properties"; - /** - * Loads version information from PROPERTY_FILE_NAME that was built as part - * of this release. - * - * @throws IllegalStateException - * when it can't find the version properties file - */ - private static void loadVersionProperties() { - Properties versionProps = new Properties(); - // can't use system class loader cause won't work in JavaWebStart - InputStream stream = JacobReleaseInfo.class.getClassLoader() - .getResourceAsStream(PROPERTY_FILE_NAME); - // This should never happen. This is an attempt to make something work - // for WebSphere. They may be using some kind of Servlet loader that - // needs an absolute path based search - if (stream == null) { - stream = JacobReleaseInfo.class.getClassLoader() - .getResourceAsStream("/" + PROPERTY_FILE_NAME); - } - // A report came in that WebSphere had trouble finding the file - // so lets trap it. Plus, it's a good idea anyway. - if (stream == null) { - throw new IllegalStateException( - "Can't find " - + PROPERTY_FILE_NAME - + " using JacobReleaseInfo.class.getClassLoader().getResourceAsStream()"); - } else { - try { - versionProps.load(stream); - stream.close(); - buildVersion = (String) versionProps.get("version"); - buildDate = (String) versionProps.get("build.date"); - } catch (IOException ioe) { - ioe.printStackTrace(); - System.err.println("Warning! Couldn't load props " + ioe); - } - } - } + /** + * Loads version information from PROPERTY_FILE_NAME that was built as part + * of this release. + * + * @throws IllegalStateException + * when it can't find the version properties file + */ + private static void loadVersionProperties() { + Properties versionProps = new Properties(); + // can't use system class loader cause won't work in JavaWebStart + InputStream stream = JacobReleaseInfo.class.getClassLoader() + .getResourceAsStream(PROPERTY_FILE_NAME); + // This should never happen. This is an attempt to make something work + // for WebSphere. They may be using some kind of Servlet loader that + // needs an absolute path based search + if (stream == null) { + stream = JacobReleaseInfo.class.getClassLoader() + .getResourceAsStream("/" + PROPERTY_FILE_NAME); + } + // A report came in that WebSphere had trouble finding the file + // so lets trap it. Plus, it's a good idea anyway. + if (stream == null) { + throw new IllegalStateException( + "Can't find " + + PROPERTY_FILE_NAME + + " using JacobReleaseInfo.class.getClassLoader().getResourceAsStream()"); + } else { + try { + versionProps.load(stream); + stream.close(); + buildVersion = (String) versionProps.get("version"); + buildDate = (String) versionProps.get("build.date"); + } catch (IOException ioe) { + ioe.printStackTrace(); + System.err.println("Warning! Couldn't load props " + ioe); + } + } + } - /** - * loads PROPERT_FILE_NAME and returns the value of version in it - * - * @return String value of version in PROPERT_FILE_NAME or "" if none - */ - public static String getBuildDate() { - if (buildDate.equals("")) { - loadVersionProperties(); - } - return buildDate; - } + /** + * loads PROPERT_FILE_NAME and returns the value of version in it + * + * @return String value of version in PROPERT_FILE_NAME or "" if none + */ + public static String getBuildDate() { + if (buildDate.equals("")) { + loadVersionProperties(); + } + return buildDate; + } - /** - * loads PROPERT_FILE_NAME and returns the value of version in it - * - * @return String value of version in PROPERT_FILE_NAME or "" if none - */ - public static String getBuildVersion() { - if (buildVersion.equals("")) { - loadVersionProperties(); - } - return buildVersion; - } + /** + * loads PROPERT_FILE_NAME and returns the value of version in it + * + * @return String value of version in PROPERT_FILE_NAME or "" if none + */ + public static String getBuildVersion() { + if (buildVersion.equals("")) { + loadVersionProperties(); + } + return buildVersion; + } } diff --git a/src/main/java/com/jacob/com/LibraryLoader.java b/src/main/java/com/jacob/com/LibraryLoader.java index 3655e60..7d352f8 100644 --- a/src/main/java/com/jacob/com/LibraryLoader.java +++ b/src/main/java/com/jacob/com/LibraryLoader.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -47,13 +47,13 @@ import com.github.boukefalos.jlibloader.Native; * @author Jason Smith */ public final class LibraryLoader { - /** - * Load the jacob dll - * - * @throws UnsatisfiedLinkError - * if the library does not exist. - */ - public static void loadJacobLibrary() { - Native.load("com.github.boukefalos", "jlibcom"); - } + /** + * Load the jacob dll + * + * @throws UnsatisfiedLinkError + * if the library does not exist. + */ + public static void loadJacobLibrary() { + Native.load("com.github.boukefalos", "jlibcom"); + } } diff --git a/src/main/java/com/jacob/com/MainSTA.java b/src/main/java/com/jacob/com/MainSTA.java index 3e72155..5db3005 100644 --- a/src/main/java/com/jacob/com/MainSTA.java +++ b/src/main/java/com/jacob/com/MainSTA.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; diff --git a/src/main/java/com/jacob/com/NotImplementedException.java b/src/main/java/com/jacob/com/NotImplementedException.java index 70f74e0..141d823 100644 --- a/src/main/java/com/jacob/com/NotImplementedException.java +++ b/src/main/java/com/jacob/com/NotImplementedException.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -45,16 +45,16 @@ package com.jacob.com; */ public class NotImplementedException extends JacobException { - /** - * - */ - private static final long serialVersionUID = -9169900832852356445L; + /** + * + */ + private static final long serialVersionUID = -9169900832852356445L; - /** - * @param description - */ - public NotImplementedException(String description) { - super(description); - } + /** + * @param description + */ + public NotImplementedException(String description) { + super(description); + } } diff --git a/src/main/java/com/jacob/com/ROT.java b/src/main/java/com/jacob/com/ROT.java index e912c39..f1e1b7e 100644 --- a/src/main/java/com/jacob/com/ROT.java +++ b/src/main/java/com/jacob/com/ROT.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -60,239 +60,239 @@ import java.util.WeakHashMap; * Is [ 1116101 ] jacob-msg 0284 relevant??? */ public abstract class ROT { - /** - * Manual garbage collection was the only option pre 1.9 Can staticly cache - * the results because only one value and we don't let it change during a - * run - */ - protected static final boolean USE_AUTOMATIC_GARBAGE_COLLECTION = "true" - .equalsIgnoreCase(System.getProperty("com.jacob.autogc")); + /** + * Manual garbage collection was the only option pre 1.9 Can staticly cache + * the results because only one value and we don't let it change during a + * run + */ + protected static final boolean USE_AUTOMATIC_GARBAGE_COLLECTION = "true" + .equalsIgnoreCase(System.getProperty("com.jacob.autogc")); - /** - * If the code is ran from an applet that is called from javascript the Java - * Plugin does not give full permissions to the code and thus System - * properties cannot be accessed. They can be accessed at class - * initialization time. - * - * The default behavior is to include all classes in the ROT, setting a - * boolean here to indicate this prevents a call to System.getProperty as - * part of the general call flow. - */ - protected static final Boolean INCLUDE_ALL_CLASSES_IN_ROT = Boolean - .valueOf(System.getProperty("com.jacob.includeAllClassesInROT", - "true")); + /** + * If the code is ran from an applet that is called from javascript the Java + * Plugin does not give full permissions to the code and thus System + * properties cannot be accessed. They can be accessed at class + * initialization time. + * + * The default behavior is to include all classes in the ROT, setting a + * boolean here to indicate this prevents a call to System.getProperty as + * part of the general call flow. + */ + protected static final Boolean INCLUDE_ALL_CLASSES_IN_ROT = Boolean + .valueOf(System.getProperty("com.jacob.includeAllClassesInROT", + "true")); - /** - * Suffix added to class name to make up property name that determines if - * this object should be stored in the ROT. This 1.13 "feature" makes it - * possible to cause VariantViaEvent objects to not be added to the ROT in - * event callbacks. - *

- * We don't have a static for the actual property because there is a - * different property for each class that may make use of this feature. - */ - protected static String PUT_IN_ROT_SUFFIX = ".PutInROT"; + /** + * Suffix added to class name to make up property name that determines if + * this object should be stored in the ROT. This 1.13 "feature" makes it + * possible to cause VariantViaEvent objects to not be added to the ROT in + * event callbacks. + *

+ * We don't have a static for the actual property because there is a + * different property for each class that may make use of this feature. + */ + protected static String PUT_IN_ROT_SUFFIX = ".PutInROT"; - /** - * A hash table where each element is another HashMap that represents a - * thread. Each thread HashMap contains the com objects created in that - * thread - */ - private static HashMap> rot = new HashMap>(); + /** + * A hash table where each element is another HashMap that represents a + * thread. Each thread HashMap contains the com objects created in that + * thread + */ + private static HashMap> rot = new HashMap>(); - /** - * adds a new thread storage area to rot - * - * @return Map corresponding to the thread that this call was made in - */ - protected synchronized static Map addThread() { - // should use the id here instead of the name because the name can be - // changed - String t_name = Thread.currentThread().getName(); - if (rot.containsKey(t_name)) { - // nothing to do - } else { - Map tab = null; - if (JacobObject.isDebugEnabled()) { - JacobObject.debug("ROT: Automatic GC flag == " - + USE_AUTOMATIC_GARBAGE_COLLECTION); - } - if (!USE_AUTOMATIC_GARBAGE_COLLECTION) { - tab = new HashMap(); - } else { - tab = new WeakHashMap(); - } - rot.put(t_name, tab); - } - return getThreadObjects(false); - } + /** + * adds a new thread storage area to rot + * + * @return Map corresponding to the thread that this call was made in + */ + protected synchronized static Map addThread() { + // should use the id here instead of the name because the name can be + // changed + String t_name = Thread.currentThread().getName(); + if (rot.containsKey(t_name)) { + // nothing to do + } else { + Map tab = null; + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("ROT: Automatic GC flag == " + + USE_AUTOMATIC_GARBAGE_COLLECTION); + } + if (!USE_AUTOMATIC_GARBAGE_COLLECTION) { + tab = new HashMap(); + } else { + tab = new WeakHashMap(); + } + rot.put(t_name, tab); + } + return getThreadObjects(false); + } - /** - * Returns the pool for this thread if it exists. can create a new one if - * you wish by passing in TRUE - * - * @param createIfDoesNotExist - * @return Map the collection that holds the objects created in the current - * thread - */ - protected synchronized static Map getThreadObjects( - boolean createIfDoesNotExist) { - String t_name = Thread.currentThread().getName(); - if (!rot.containsKey(t_name) && createIfDoesNotExist) { - addThread(); - } - return rot.get(t_name); - } + /** + * Returns the pool for this thread if it exists. can create a new one if + * you wish by passing in TRUE + * + * @param createIfDoesNotExist + * @return Map the collection that holds the objects created in the current + * thread + */ + protected synchronized static Map getThreadObjects( + boolean createIfDoesNotExist) { + String t_name = Thread.currentThread().getName(); + if (!rot.containsKey(t_name) && createIfDoesNotExist) { + addThread(); + } + return rot.get(t_name); + } - /** - * Iterates across all of the entries in the Hashmap in the rot that - * corresponds to this thread. This calls safeRelease() on each entry and - * then clears the map when done and removes it from the rot. All traces of - * this thread's objects will disappear. This is called by COMThread in the - * tear down and provides a synchronous way of releasing memory - */ - protected static void clearObjects() { - if (JacobObject.isDebugEnabled()) { - JacobObject.debug("ROT: " + rot.keySet().size() - + " thread tables exist"); - } + /** + * Iterates across all of the entries in the Hashmap in the rot that + * corresponds to this thread. This calls safeRelease() on each entry and + * then clears the map when done and removes it from the rot. All traces of + * this thread's objects will disappear. This is called by COMThread in the + * tear down and provides a synchronous way of releasing memory + */ + protected static void clearObjects() { + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("ROT: " + rot.keySet().size() + + " thread tables exist"); + } - Map tab = getThreadObjects(false); - if (tab != null) { - if (JacobObject.isDebugEnabled()) { - JacobObject.debug("ROT: " + tab.keySet().size() - + " objects to clear in this thread's ROT "); - } - // walk the values - Iterator it = tab.keySet().iterator(); - while (it.hasNext()) { - JacobObject o = it.next(); - if (o != null - // can't use this cause creates a Variant if calling SafeAray - // and we get an exception modifying the collection while - // iterating - // && o.toString() != null - ) { - if (JacobObject.isDebugEnabled()) { - if (o instanceof SafeArray) { - // SafeArray create more objects when calling - // toString() - // which causes a concurrent modification exception - // in HashMap - JacobObject.debug("ROT: removing " - + o.getClass().getName()); - } else { - // Variant toString() is probably always bad in here - JacobObject.debug("ROT: removing " + o.hashCode() - + "->" + o.getClass().getName()); - } - } - o.safeRelease(); - } - } - // empty the collection - tab.clear(); - // remove the collection from rot - ROT.removeThread(); - if (JacobObject.isDebugEnabled()) { - JacobObject.debug("ROT: thread table cleared and removed"); - } - } else { - if (JacobObject.isDebugEnabled()) { - JacobObject.debug("ROT: nothing to clear!"); - } - } - } + Map tab = getThreadObjects(false); + if (tab != null) { + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("ROT: " + tab.keySet().size() + + " objects to clear in this thread's ROT "); + } + // walk the values + Iterator it = tab.keySet().iterator(); + while (it.hasNext()) { + JacobObject o = it.next(); + if (o != null + // can't use this cause creates a Variant if calling SafeAray + // and we get an exception modifying the collection while + // iterating + // && o.toString() != null + ) { + if (JacobObject.isDebugEnabled()) { + if (o instanceof SafeArray) { + // SafeArray create more objects when calling + // toString() + // which causes a concurrent modification exception + // in HashMap + JacobObject.debug("ROT: removing " + + o.getClass().getName()); + } else { + // Variant toString() is probably always bad in here + JacobObject.debug("ROT: removing " + o.hashCode() + + "->" + o.getClass().getName()); + } + } + o.safeRelease(); + } + } + // empty the collection + tab.clear(); + // remove the collection from rot + ROT.removeThread(); + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("ROT: thread table cleared and removed"); + } + } else { + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("ROT: nothing to clear!"); + } + } + } - /** - * Removes the map from the rot that is associated with the current thread. - */ - private synchronized static void removeThread() { - // should this see if it exists first? - rot.remove(Thread.currentThread().getName()); - } + /** + * Removes the map from the rot that is associated with the current thread. + */ + private synchronized static void removeThread() { + // should this see if it exists first? + rot.remove(Thread.currentThread().getName()); + } - /** - * @deprecated the java model leave the responsibility of clearing up - * objects to the Garbage Collector. Our programming model - * should not require that the user specifically remove object - * from the thread.
- * This will remove an object from the ROT
- * This does not need to be synchronized because only the rot - * modification related methods need to synchronized. Each - * individual map is only modified in a single thread. - * @param o - */ - @Deprecated - protected static void removeObject(JacobObject o) { - Map tab = ROT.getThreadObjects(false); - if (tab != null) { - tab.remove(o); - } - o.safeRelease(); - } + /** + * @deprecated the java model leave the responsibility of clearing up + * objects to the Garbage Collector. Our programming model + * should not require that the user specifically remove object + * from the thread.
+ * This will remove an object from the ROT
+ * This does not need to be synchronized because only the rot + * modification related methods need to synchronized. Each + * individual map is only modified in a single thread. + * @param o + */ + @Deprecated + protected static void removeObject(JacobObject o) { + Map tab = ROT.getThreadObjects(false); + if (tab != null) { + tab.remove(o); + } + o.safeRelease(); + } - /** - * Adds an object to the HashMap for the current thread.
- *

- * This method does not need to be threaded because the only concurrent - * modification risk is on the hash map that contains all of the thread - * related hash maps. The individual thread related maps are only used on a - * per thread basis so there isn't a locking issue. - *

- * In addition, this method cannot be threaded because it calls - * ComThread.InitMTA. The ComThread object has some methods that call ROT so - * we could end up deadlocked. This method should be safe without the - * synchronization because the ROT works on per thread basis and the methods - * that add threads and remove thread related entries are all synchronized - * - * - * @param o - */ - protected static void addObject(JacobObject o) { - String shouldIncludeClassInROT = "true"; - // only call System.getProperty if we are not including all classes in - // the ROT. This lets us run with standard Jacob behavior in Applets - // without the security exception raised by System.getProperty in the - // flow - if (!ROT.INCLUDE_ALL_CLASSES_IN_ROT) { - shouldIncludeClassInROT = System.getProperty(o.getClass().getName() - + PUT_IN_ROT_SUFFIX, "true"); - } - if (shouldIncludeClassInROT.equalsIgnoreCase("false")) { - if (JacobObject.isDebugEnabled()) { - JacobObject.debug("JacobObject: New instance of " - + o.getClass().getName() + " not added to ROT"); - } - } else { - // first see if we have a table for this thread - Map tab = getThreadObjects(false); - if (tab == null) { - // this thread has not been initialized as a COM thread - // so make it part of MTA for backwards compatibility - ComThread.InitMTA(false); - // don't really need the "true" because the InitMTA will have - // called back to the ROT to create a table for this thread - tab = getThreadObjects(true); - } - if (JacobObject.isDebugEnabled()) { - JacobObject.debug("ROT: adding " + o + "->" - + o.getClass().getName() - + " table size prior to addition:" + tab.size()); - } - // add the object to the table that is specific to this thread - if (tab != null) { - tab.put(o, null); - } - } - } + /** + * Adds an object to the HashMap for the current thread.
+ *

+ * This method does not need to be threaded because the only concurrent + * modification risk is on the hash map that contains all of the thread + * related hash maps. The individual thread related maps are only used on a + * per thread basis so there isn't a locking issue. + *

+ * In addition, this method cannot be threaded because it calls + * ComThread.InitMTA. The ComThread object has some methods that call ROT so + * we could end up deadlocked. This method should be safe without the + * synchronization because the ROT works on per thread basis and the methods + * that add threads and remove thread related entries are all synchronized + * + * + * @param o + */ + protected static void addObject(JacobObject o) { + String shouldIncludeClassInROT = "true"; + // only call System.getProperty if we are not including all classes in + // the ROT. This lets us run with standard Jacob behavior in Applets + // without the security exception raised by System.getProperty in the + // flow + if (!ROT.INCLUDE_ALL_CLASSES_IN_ROT) { + shouldIncludeClassInROT = System.getProperty(o.getClass().getName() + + PUT_IN_ROT_SUFFIX, "true"); + } + if (shouldIncludeClassInROT.equalsIgnoreCase("false")) { + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("JacobObject: New instance of " + + o.getClass().getName() + " not added to ROT"); + } + } else { + // first see if we have a table for this thread + Map tab = getThreadObjects(false); + if (tab == null) { + // this thread has not been initialized as a COM thread + // so make it part of MTA for backwards compatibility + ComThread.InitMTA(false); + // don't really need the "true" because the InitMTA will have + // called back to the ROT to create a table for this thread + tab = getThreadObjects(true); + } + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("ROT: adding " + o + "->" + + o.getClass().getName() + + " table size prior to addition:" + tab.size()); + } + // add the object to the table that is specific to this thread + if (tab != null) { + tab.put(o, null); + } + } + } - /** - * ROT can't be a subclass of JacobObject because of the way ROT pools are - * managed so we force a DLL load here by referencing JacobObject - */ - static { - LibraryLoader.loadJacobLibrary(); - } + /** + * ROT can't be a subclass of JacobObject because of the way ROT pools are + * managed so we force a DLL load here by referencing JacobObject + */ + static { + LibraryLoader.loadJacobLibrary(); + } } diff --git a/src/main/java/com/jacob/com/STA.java b/src/main/java/com/jacob/com/STA.java index 61f81da..e31017d 100644 --- a/src/main/java/com/jacob/com/STA.java +++ b/src/main/java/com/jacob/com/STA.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -44,77 +44,77 @@ package com.jacob.com; * component that wants to run in an STA other than the main STA. */ public class STA extends Thread { - /** - * referenced by STA.cpp - */ - public int threadID; + /** + * referenced by STA.cpp + */ + public int threadID; - /** - * constructor for STA - */ - public STA() { - start(); // start the thread - } + /** + * constructor for STA + */ + public STA() { + start(); // start the thread + } - /* - * (non-Javadoc) - * - * @see java.lang.Thread#run() - */ - public void run() { - // init COM - ComThread.InitSTA(); - if (OnInit()) { - // this call blocks in the win32 message loop - // until quitMessagePump is called - doMessagePump(); - } - OnQuit(); - // uninit COM - ComThread.Release(); - } + /* + * (non-Javadoc) + * + * @see java.lang.Thread#run() + */ + public void run() { + // init COM + ComThread.InitSTA(); + if (OnInit()) { + // this call blocks in the win32 message loop + // until quitMessagePump is called + doMessagePump(); + } + OnQuit(); + // uninit COM + ComThread.Release(); + } - /** - * Override this method to create and initialize any COM component that you - * want to run in this thread. If anything fails, return false to terminate - * the thread. - * - * @return always returns true - */ - public boolean OnInit() { - return true; - } + /** + * Override this method to create and initialize any COM component that you + * want to run in this thread. If anything fails, return false to terminate + * the thread. + * + * @return always returns true + */ + public boolean OnInit() { + return true; + } - /** - * Override this method to destroy any resource before the thread exits and - * COM in uninitialized - */ - public void OnQuit() { - // there is nothing to see here - } + /** + * Override this method to destroy any resource before the thread exits and + * COM in uninitialized + */ + public void OnQuit() { + // there is nothing to see here + } - /** - * calls quitMessagePump - */ - public void quit() { - quitMessagePump(); - } + /** + * calls quitMessagePump + */ + public void quit() { + quitMessagePump(); + } - /** - * run a message pump for the main STA - */ - public native void doMessagePump(); + /** + * run a message pump for the main STA + */ + public native void doMessagePump(); - /** - * quit message pump for the main STA - */ - public native void quitMessagePump(); + /** + * quit message pump for the main STA + */ + public native void quitMessagePump(); - /** - * STA isn't a subclass of JacobObject so a reference to it doesn't load the - * DLL without this - */ - static { - LibraryLoader.loadJacobLibrary(); - } + /** + * STA isn't a subclass of JacobObject so a reference to it doesn't load the + * DLL without this + */ + static { + LibraryLoader.loadJacobLibrary(); + } } \ No newline at end of file diff --git a/src/main/java/com/jacob/com/SafeArray.java b/src/main/java/com/jacob/com/SafeArray.java index 1f72f58..550aa9c 100644 --- a/src/main/java/com/jacob/com/SafeArray.java +++ b/src/main/java/com/jacob/com/SafeArray.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -44,1148 +44,1148 @@ package com.jacob.com; * were a later addition. */ public class SafeArray extends JacobObject { - /** The super secret int that is actually the pointer to windows memory */ - int m_pV = 0; - - /** - * Constructor. Why does this exist? Yeah, someone will post on sourceforge - * about this comment. - * - */ - public SafeArray() { - } - - /** - * Constructor. - * - * @param vt - * type of array - */ - public SafeArray(int vt) { - init(vt, new int[] { 0 }, new int[] { -1 }); - } - - /** - * Constructor for a single dimensional array whose lower bounds is 0 and - * whose upper bound is specified as a parameter - * - * @param vt - * type of the array - * @param celems - * length of the array - */ - public SafeArray(int vt, int celems) { - init(vt, new int[] { 0 }, new int[] { celems }); - } - - /** - * Creates a two dimensional SafeArray whose base indexes are 0. - * - * @param vt - * Type of the array - * @param celems1 - * length of the array in first dimension - * @param celems2 - * length of the array in second dimension - */ - public SafeArray(int vt, int celems1, int celems2) { - init(vt, new int[] { 0, 0 }, new int[] { celems1, celems2 }); - } - - /** - * Constructor with support for N-dimensional array support - *

- * You create an N-D SafeArray by: SafeArray sa = new - * SafeArray(Variant.VariantVariant, new int[] {0,0,0,0}, new int[] - * {4,4,4,4}); Where the 1st array is lower bounds and 2nd has the lengths - * of each dimension * - * - * @param vt - * @param lbounds - * @param celems - */ - public SafeArray(int vt, int lbounds[], int celems[]) { - init(vt, lbounds, celems); - } - - /** - * convert a string to a VT_UI1 array - * - * @param s - * source string - */ - public SafeArray(String s) { - char[] ca = s.toCharArray(); - init(Variant.VariantByte, new int[] { 0 }, new int[] { ca.length }); - fromCharArray(ca); - } - - /** - * convert a VT_UI1 array to string - * - * @return variant byte as a string - */ - public String asString() { - if (getvt() != Variant.VariantByte) { - return null; - } - char ja[] = toCharArray(); - return new String(ja); - } - - public native Object clone(); - - /** - * now private so only this object can access. Was: call this to explicitly - * release the com object before gc - * - */ - private native void destroy(); - - /** - * {@inheritDoc} - */ - protected void finalize() { - safeRelease(); - } - - /** - * populate the safe array from the passed in array of data - * - * @param ja - */ - public native void fromBooleanArray(boolean ja[]); - - /** - * populate the safe array from the passed in array of data - * - * @param ja - */ - public native void fromByteArray(byte ja[]); - - /** - * populate the safe array from the passed in array of data - * - * @param ja - */ - public native void fromCharArray(char ja[]); - - /** - * populate the safe array from the passed in array of data - * - * @param ja - */ - public native void fromDoubleArray(double ja[]); - - /** - * populate the safe array from the passed in array of data - * - * @param ja - */ - public native void fromFloatArray(float ja[]); - - /** - * populate the safe array from the passed in array of data - * - * @param ja - */ - public native void fromIntArray(int ja[]); - - /** - * populate the safe array from the passed in array of data - * - * @param ja - */ - public native void fromLongArray(long ja[]); - - /** - * populate the safe array from the passed in array of data - * - * @param ja - */ - public native void fromShortArray(short ja[]); - - /** - * populate the safe array from the passed in array of data - * - * @param ja - */ - public native void fromStringArray(String ja[]); - - /** - * populate the safe array from the passed in array of data - * - * @param ja - */ - public native void fromVariantArray(Variant ja[]); - - /** - * boolean access - * - * @param sa_idx - * @return boolean representation - */ - public native boolean getBoolean(int sa_idx); - - /** - * get boolean value from N-dimensional array - * - * @param indices - - * length must equal Dimension of SafeArray - * @return the value at the specified location - */ - public native boolean getBoolean(int indices[]); - - /** - * boolean access - * - * @param sa_idx1 - * @param sa_idx2 - * @return boolean representation - */ - public native boolean getBoolean(int sa_idx1, int sa_idx2); - - /** - * boolean access - * - * @param sa_idx - * @param nelems - * @param ja - * @param ja_start - */ - public native void getBooleans(int sa_idx, int nelems, boolean ja[], - int ja_start); - - /** - * byte access - * - * @param sa_idx - * @return byte representaton - */ - public native byte getByte(int sa_idx); - - /** - * get byte value from N-dimensional array - * - * @param indices - - * length must equal Dimension of SafeArray - * @return the value at the specified location - */ - public native byte getByte(int indices[]); - - /** - * byte access - * - * @param sa_idx1 - * @param sa_idx2 - * @return byte representation - */ - public native byte getByte(int sa_idx1, int sa_idx2); - - /** - * Fills byte array from contents of this array - * - * @param sa_idx - * @param nelems - * @param ja - * @param ja_start - */ - public native void getBytes(int sa_idx, int nelems, byte ja[], int ja_start); - - /** - * char access - * - * @param sa_idx - * @return single character rpeesentation - */ - public native char getChar(int sa_idx); - - /** - * get char value from N-dimensional array - * - * @param indices - - * length must equal Dimension of SafeArray - * @return the value at the specified location - */ - public native char getChar(int indices[]); - - /** - * char access - * - * @param sa_idx1 - * @param sa_idx2 - * @return single character representation - */ - public native char getChar(int sa_idx1, int sa_idx2); - - /** - * char access - * - * @param sa_idx - * @param nelems - * @param ja - * @param ja_start - */ - public native void getChars(int sa_idx, int nelems, char ja[], int ja_start); - - /** - * double access - * - * @param sa_idx - * @return double stored in array - */ - public native double getDouble(int sa_idx); - - /** - * get double value from N-dimensional array - * - * @param indices - - * length must equal Dimension of SafeArray - * @return the value at the specified location - */ - public native double getDouble(int indices[]); - - /** - * double access - * - * @param sa_idx1 - * @param sa_idx2 - * @return double stored in array - */ - public native double getDouble(int sa_idx1, int sa_idx2); - - /** - * double access - * - * @param sa_idx - * @param nelems - * @param ja - * @param ja_start - */ - public native void getDoubles(int sa_idx, int nelems, double ja[], - int ja_start); - - /** - * @return the size of each element? - */ - public native int getElemSize(); - - /** - * @return The ??features of the array? - */ - public native int getFeatures(); - - /** - * float access - * - * @param sa_idx - * @return float held in array at location - */ - public native float getFloat(int sa_idx); - - /** - * get float value from N-dimensional array - * - * @param indices - - * length must equal Dimension of SafeArray - * @return the value at the specified location - */ - public native float getFloat(int indices[]); - - /** - * float access - * - * @param sa_idx1 - * @param sa_idx2 - * @return float held in array at location - */ - public native float getFloat(int sa_idx1, int sa_idx2); - - /** - * float access - * - * @param sa_idx - * @param nelems - * @param ja - * @param ja_start - */ - public native void getFloats(int sa_idx, int nelems, float ja[], - int ja_start); - - /** - * get int from an single dimensional array - * - * @param sa_idx - * array index - * @return int stored in array - */ - public native int getInt(int sa_idx); - - /** - * get int value from N-dimensional array - * - * @param indices - - * length must equal Dimension of SafeArray - * @return the value at the specified location - */ - public native int getInt(int indices[]); - - /** - * get int from 2 dimensional array - * - * @param sa_idx1 - * array index first dimension - * @param sa_idx2 - * array index of second dimension - * @return int stored in array - */ - public native int getInt(int sa_idx1, int sa_idx2); - - /** - * retrieves a group of ints from a single dimensional array - * - * @param sa_idx - * the index in the array to start the get - * @param nelems - * number of elements to retrieve - * @param ja - * the structure to be filled with the ints - * @param ja_start - * the start point in the java int array to start filling - */ - public native void getInts(int sa_idx, int nelems, int ja[], int ja_start); - - /** - * get int from an single dimensional array - * - * @param sa_idx - * array index - * @return long stored in array - */ - public native long getLong(int sa_idx); - - /** - * get long value from N-dimensional array - * - * @param indices - - * length must equal Dimension of SafeArray - * @return the value at the specified location - */ - public native long getLong(int indices[]); - - /** - * get long from 2 dimensional array - * - * @param sa_idx1 - * array index first dimension - * @param sa_idx2 - * array index of second dimension - * @return long stored in array - */ - public native long getLong(int sa_idx1, int sa_idx2); - - /** - * retrieves a group of longs from a single dimensional array - * - * @param sa_idx - * the index in the array to start the get - * @param nelems - * number of elements to retrieve - * @param ja - * the structure to be filled with the longs - * @param ja_start - * the start point in the java longs array to start filling - */ - public native void getLongs(int sa_idx, int nelems, long ja[], int ja_start); - - /** - * @return The lower bounds of the array? - */ - public native int getLBound(); - - /** - * @param dim - * the dimension we are checking in a multidimensional array - * @return The lower bounds of the array? - */ - public native int getLBound(int dim); - - /** - * @return The number of dimensions in this array - */ - public native int getNumDim(); - - /** - * not implemented. - * - * @return 0 - */ - public int getNumLocks() { - return 0; - } - - /** - * short access - * - * @param sa_idx - * @return short stored in array - */ - public native short getShort(int sa_idx); - - /** - * get short value from N-dimensional array - * - * @param indices - - * length must equal Dimension of SafeArray - * @return the value at the specified location - */ - public native short getShort(int indices[]); - - /** - * short access - * - * @param sa_idx1 - * @param sa_idx2 - * @return short stored in array - */ - public native short getShort(int sa_idx1, int sa_idx2); - - /** - * short access - * - * @param sa_idx - * @param nelems - * @param ja - * @param ja_start - */ - public native void getShorts(int sa_idx, int nelems, short ja[], - int ja_start); - - /** - * string access - * - * @param sa_idx - * @return String stored in array - * - */ - public native String getString(int sa_idx); - - /** - * get String value from N-dimensional array - * - * @param indices - - * length must equal Dimension of SafeArray - * @return the value at the specified location - */ - public native String getString(int indices[]); - - /** - * string access - * - * @param sa_idx1 - * @param sa_idx2 - * @return String stored in array - */ - public native String getString(int sa_idx1, int sa_idx2); - - /** - * string access - * - * @param sa_idx - * @param nelems - * @param ja - * @param ja_start - */ - public native void getStrings(int sa_idx, int nelems, String ja[], - int ja_start); - - /** - * @return The upper bounds of the array? - */ - public native int getUBound(); - - /** - * @param dim - * the dimension we are checking in a multidimensional array - * @return The upper bounds of the array? - */ - public native int getUBound(int dim); - - /** - * variant access - * - * @param sa_idx - * @return Variant held in location in the array? - */ - public native Variant getVariant(int sa_idx); - - /** - * get Variant value from N-dimensional array - * - * @param indices - - * length must equal Dimension of SafeArray - * @return the value at the specified location - */ - public native Variant getVariant(int indices[]); - - /** - * variant access - * - * @param sa_idx1 - * @param sa_idx2 - * @return Variant held in a location in the array? - */ - public native Variant getVariant(int sa_idx1, int sa_idx2); - - /** - * variant access - * - * @param sa_idx - * @param nelems - * @param ja - * @param ja_start - */ - public native void getVariants(int sa_idx, int nelems, Variant ja[], - int ja_start); - - /** - * @return the Variant type - */ - public native int getvt(); - - protected native void init(int vt, int lbounds[], int celems[]); - - /** - * Does anyone want to document this? - * - * @param sa - */ - public native void reinit(SafeArray sa); - - /** - * Does anyone want to document this? - * - * @param vt - * the variant type? - */ - public native void reinterpretType(int vt); - - /** - * {@inheritDoc} - */ - public void safeRelease() { - super.safeRelease(); - if (m_pV != 0) { - destroy(); - m_pV = 0; - } else { - // looks like a double release - if (isDebugEnabled()) { - debug(this.getClass().getName() + ":" + this.hashCode() - + " double release"); - } - } - } - - /** - * boolean access - * - * @param sa_idx - * @param c - */ - public native void setBoolean(int sa_idx, boolean c); - - /** - * set boolean value in N-dimensional array - * - * @param indices - - * length must equal Dimension of SafeArray - * @param c - */ - public native void setBoolean(int indices[], boolean c); - - /** - * boolean access - * - * @param sa_idx1 - * @param sa_idx2 - * @param c - */ - public native void setBoolean(int sa_idx1, int sa_idx2, boolean c); - - /** - * boolean access - * - * @param sa_idx - * @param nelems - * @param ja - * @param ja_start - */ - public native void setBooleans(int sa_idx, int nelems, boolean ja[], - int ja_start); - - /** - * byte access - * - * @param sa_idx - * @param c - */ - public native void setByte(int sa_idx, byte c); - - /** - * set byte value in N-dimensional array - * - * @param indices - - * length must equal Dimension of SafeArray - * @param c - */ - public native void setByte(int indices[], byte c); - - /** - * byte access - * - * @param sa_idx1 - * @param sa_idx2 - * @param c - */ - public native void setByte(int sa_idx1, int sa_idx2, byte c); - - /** - * fills array with passed in bytes - * - * @param sa_idx - * @param nelems - * @param ja - * @param ja_start - */ - public native void setBytes(int sa_idx, int nelems, byte ja[], int ja_start); - - /** - * char access - * - * @param sa_idx - * @param c - */ - public native void setChar(int sa_idx, char c); - - /** - * set char value in N-dimensional array - * - * @param indices - - * length must equal Dimension of SafeArray - * @param c - */ - public native void setChar(int indices[], char c); - - /** - * char access - * - * @param sa_idx1 - * @param sa_idx2 - * @param c - */ - public native void setChar(int sa_idx1, int sa_idx2, char c); - - /** - * char access - * - * @param sa_idx - * @param nelems - * @param ja - * @param ja_start - */ - public native void setChars(int sa_idx, int nelems, char ja[], int ja_start); - - /** - * double access - * - * @param sa_idx - * @param c - */ - public native void setDouble(int sa_idx, double c); - - /** - * set double value in N-dimensional array - * - * @param indices - - * length must equal Dimension of SafeArray - * @param c - */ - public native void setDouble(int indices[], double c); - - /** - * double access - * - * @param sa_idx1 - * @param sa_idx2 - * @param c - */ - public native void setDouble(int sa_idx1, int sa_idx2, double c); - - /** - * double access - * - * @param sa_idx - * @param nelems - * @param ja - * @param ja_start - */ - public native void setDoubles(int sa_idx, int nelems, double ja[], - int ja_start); - - /** - * float access - * - * @param sa_idx - * @param c - */ - public native void setFloat(int sa_idx, float c); - - /** - * set float value in N-dimensional array - * - * @param indices - - * length must equal Dimension of SafeArray - * @param c - */ - public native void setFloat(int indices[], float c); - - /** - * float access - * - * @param sa_idx1 - * @param sa_idx2 - * @param c - */ - public native void setFloat(int sa_idx1, int sa_idx2, float c); - - /** - * float access - * - * @param sa_idx - * @param nelems - * @param ja - * @param ja_start - */ - public native void setFloats(int sa_idx, int nelems, float ja[], - int ja_start); - - /** - * sets the int value of an element in a single dimensional array - * - * @param sa_idx - * index into the array - * @param c - * the value to be set - */ - public native void setInt(int sa_idx, int c); - - /** - * set int value in N-dimensional array - * - * @param indices - - * length must equal Dimension of SafeArray - * @param c - */ - public native void setInt(int indices[], int c); - - /** - * sets the int value of a 2 dimensional array - * - * @param sa_idx1 - * index on the first dimension - * @param sa_idx2 - * index on the second dimension - * @param c - * the value to be set - */ - public native void setInt(int sa_idx1, int sa_idx2, int c); - - /** - * sets a group of ints into a single dimensional array - * - * @param sa_idx - * the index of the start of the array to put into - * @param nelems - * number of elements to be copied - * @param ja - * the new int values to be put into the array - * @param ja_start - * the start index in the array that we are copying into - * SafeArray - */ - public native void setInts(int sa_idx, int nelems, int ja[], int ja_start); - - /** - * sets the long value of an element in a single dimensional array - * - * @param sa_idx - * index into the array - * @param c - * the value to be set - */ - public native void setLong(int sa_idx, long c); - - /** - * set long value in N-dimensional array - * - * @param indices - - * length must equal Dimension of SafeArray - * @param c - */ - public native void setLong(int indices[], long c); - - /** - * sets the long value of a 2 dimensional array - * - * @param sa_idx1 - * index on the first dimension - * @param sa_idx2 - * index on the second dimension - * @param c - * the value to be set - */ - public native void setLong(int sa_idx1, int sa_idx2, long c); - - /** - * sets a group of longs into a single dimensional array - * - * @param sa_idx - * the index of the start of the array to put into - * @param nelems - * number of elements to be copied - * @param ja - * the new long values to be put into the array - * @param ja_start - * the start index in the array that we are copying into - * SafeArray - */ - public native void setLongs(int sa_idx, int nelems, long ja[], int ja_start); - - /** - * short access - * - * @param sa_idx1 - * @param sa_idx2 - * @param c - */ - public native void setShort(int sa_idx1, int sa_idx2, short c); - - /** - * short access - * - * @param sa_idx - * @param c - */ - public native void setShort(int sa_idx, short c); - - /** - * set short value in N-dimensional array - * - * @param indices - - * length must equal Dimension of SafeArray - * @param c - */ - public native void setShort(int indices[], short c); - - /** - * short access - * - * @param sa_idx - * @param nelems - * @param ja - * @param ja_start - */ - public native void setShorts(int sa_idx, int nelems, short ja[], - int ja_start); - - /** - * puts a string into an element in a two dimensional array. - * - * @param sa_idx1 - * @param sa_idx2 - * @param c - */ - public native void setString(int sa_idx1, int sa_idx2, String c); - - /* - * ================================================================ The - * beginning of N-dimensional array support - * ================================================================ - */ - - /** - * puts a string into an element in a single dimensional safe array - * - * @param sa_idx - * @param c - */ - public native void setString(int sa_idx, String c); - - /** - * set Stringvalue in N-dimensional array - * - * @param indices - - * length must equal Dimension of SafeArray - * @param c - */ - public native void setString(int indices[], String c); - - /** - * string access - * - * @param sa_idx - * @param nelems - * @param ja - * @param ja_start - */ - public native void setStrings(int sa_idx, int nelems, String ja[], - int ja_start); - - /** - * variant access - * - * @param sa_idx1 - * @param sa_idx2 - * @param c - */ - public native void setVariant(int sa_idx1, int sa_idx2, Variant c); - - /** - * variant access - * - * @param sa_idx - * @param c - */ - public native void setVariant(int sa_idx, Variant c); - - /** - * set Variant value in N-dimensional array - * - * @param indices - - * length must equal Dimension of SafeArray - * @param v - */ - public native void setVariant(int indices[], Variant v); - - /** - * variant access - * - * @param sa_idx - * @param nelems - * @param ja - * @param ja_start - */ - public native void setVariants(int sa_idx, int nelems, Variant ja[], - int ja_start); - - /** - * Retrieves the data from the array cast to a Java data type - * - * @return boolean[] array of booleans contained in this collection - */ - public native boolean[] toBooleanArray(); - - /** - * Retrieves the data from the array cast to a Java data type - * - * @return byte[] byte array contained in this collection - */ - public native byte[] toByteArray(); - - /** - * Retrieves the data from the array cast to a Java data type - * - * @return char[] character array contained in this collection - */ - public native char[] toCharArray(); - - /** - * Retrieves the data from the array cast to a Java data type - * - * @return double[] double array contained in this collection - */ - public native double[] toDoubleArray(); - - /** - * Retrieves the data from the array cast to a Java data type - * - * @return float[] array of float contained in this collection - */ - public native float[] toFloatArray(); - - /** - * Retrieves the data from the array cast to a Java data type - * - * @return int[] int array contained in this collection - */ - public native int[] toIntArray(); - - /** - * Retrieves the data from the array cast to a Java data type - * - * @return long[] long array contained in this collection - */ - public native long[] toLongArray(); - - /** - * Retrieves the data from the array cast to a Java data type - * - * @return short[] short array contained in this collection - */ - public native short[] toShortArray(); - - /** - * Standard toString() Warning, this creates new Variant objects! - * - * @return String contents of variant - */ - public String toString() { - String s = ""; - int ndim = getNumDim(); - if (ndim == 1) { - int ldim = getLBound(); - int udim = getUBound(); - for (int i = ldim; i <= udim; i++) { - Variant v = getVariant(i); - - if (((v.getvt() & Variant.VariantTypeMask) | Variant.VariantArray) == v - .getvt()) { - return s + "[" + v.toSafeArray().toString() + "]"; - } else { - s += " " + v.toString(); - } - } - } else if (ndim == 2) { - int ldim1 = getLBound(1); - int udim1 = getUBound(1); - - int ldim2 = getLBound(2); - int udim2 = getUBound(2); - - for (int i = ldim1; i <= udim1; i++) { - for (int j = ldim2; j <= udim2; j++) { - Variant v = getVariant(i, j); - s += " " + v.toString(); - } - s += "\n"; - } - } - return s; - } - - /** - * Retrieves the data from the array cast to a Java data type - * - * @return String[] String array contained in this collection - */ - public native String[] toStringArray(); - - /** - * Retrieves the data from the array cast to a Java data type - * - * @return Variant[] array of variants contained in this collection - */ - public native Variant[] toVariantArray(); + /** The super secret int that is actually the pointer to windows memory */ + int m_pV = 0; + + /** + * Constructor. Why does this exist? Yeah, someone will post on sourceforge + * about this comment. + * + */ + public SafeArray() { + } + + /** + * Constructor. + * + * @param vt + * type of array + */ + public SafeArray(int vt) { + init(vt, new int[] { 0 }, new int[] { -1 }); + } + + /** + * Constructor for a single dimensional array whose lower bounds is 0 and + * whose upper bound is specified as a parameter + * + * @param vt + * type of the array + * @param celems + * length of the array + */ + public SafeArray(int vt, int celems) { + init(vt, new int[] { 0 }, new int[] { celems }); + } + + /** + * Creates a two dimensional SafeArray whose base indexes are 0. + * + * @param vt + * Type of the array + * @param celems1 + * length of the array in first dimension + * @param celems2 + * length of the array in second dimension + */ + public SafeArray(int vt, int celems1, int celems2) { + init(vt, new int[] { 0, 0 }, new int[] { celems1, celems2 }); + } + + /** + * Constructor with support for N-dimensional array support + *

+ * You create an N-D SafeArray by: SafeArray sa = new + * SafeArray(Variant.VariantVariant, new int[] {0,0,0,0}, new int[] + * {4,4,4,4}); Where the 1st array is lower bounds and 2nd has the lengths + * of each dimension * + * + * @param vt + * @param lbounds + * @param celems + */ + public SafeArray(int vt, int lbounds[], int celems[]) { + init(vt, lbounds, celems); + } + + /** + * convert a string to a VT_UI1 array + * + * @param s + * source string + */ + public SafeArray(String s) { + char[] ca = s.toCharArray(); + init(Variant.VariantByte, new int[] { 0 }, new int[] { ca.length }); + fromCharArray(ca); + } + + /** + * convert a VT_UI1 array to string + * + * @return variant byte as a string + */ + public String asString() { + if (getvt() != Variant.VariantByte) { + return null; + } + char ja[] = toCharArray(); + return new String(ja); + } + + public native Object clone(); + + /** + * now private so only this object can access. Was: call this to explicitly + * release the com object before gc + * + */ + private native void destroy(); + + /** + * {@inheritDoc} + */ + protected void finalize() { + safeRelease(); + } + + /** + * populate the safe array from the passed in array of data + * + * @param ja + */ + public native void fromBooleanArray(boolean ja[]); + + /** + * populate the safe array from the passed in array of data + * + * @param ja + */ + public native void fromByteArray(byte ja[]); + + /** + * populate the safe array from the passed in array of data + * + * @param ja + */ + public native void fromCharArray(char ja[]); + + /** + * populate the safe array from the passed in array of data + * + * @param ja + */ + public native void fromDoubleArray(double ja[]); + + /** + * populate the safe array from the passed in array of data + * + * @param ja + */ + public native void fromFloatArray(float ja[]); + + /** + * populate the safe array from the passed in array of data + * + * @param ja + */ + public native void fromIntArray(int ja[]); + + /** + * populate the safe array from the passed in array of data + * + * @param ja + */ + public native void fromLongArray(long ja[]); + + /** + * populate the safe array from the passed in array of data + * + * @param ja + */ + public native void fromShortArray(short ja[]); + + /** + * populate the safe array from the passed in array of data + * + * @param ja + */ + public native void fromStringArray(String ja[]); + + /** + * populate the safe array from the passed in array of data + * + * @param ja + */ + public native void fromVariantArray(Variant ja[]); + + /** + * boolean access + * + * @param sa_idx + * @return boolean representation + */ + public native boolean getBoolean(int sa_idx); + + /** + * get boolean value from N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @return the value at the specified location + */ + public native boolean getBoolean(int indices[]); + + /** + * boolean access + * + * @param sa_idx1 + * @param sa_idx2 + * @return boolean representation + */ + public native boolean getBoolean(int sa_idx1, int sa_idx2); + + /** + * boolean access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void getBooleans(int sa_idx, int nelems, boolean ja[], + int ja_start); + + /** + * byte access + * + * @param sa_idx + * @return byte representaton + */ + public native byte getByte(int sa_idx); + + /** + * get byte value from N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @return the value at the specified location + */ + public native byte getByte(int indices[]); + + /** + * byte access + * + * @param sa_idx1 + * @param sa_idx2 + * @return byte representation + */ + public native byte getByte(int sa_idx1, int sa_idx2); + + /** + * Fills byte array from contents of this array + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void getBytes(int sa_idx, int nelems, byte ja[], int ja_start); + + /** + * char access + * + * @param sa_idx + * @return single character rpeesentation + */ + public native char getChar(int sa_idx); + + /** + * get char value from N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @return the value at the specified location + */ + public native char getChar(int indices[]); + + /** + * char access + * + * @param sa_idx1 + * @param sa_idx2 + * @return single character representation + */ + public native char getChar(int sa_idx1, int sa_idx2); + + /** + * char access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void getChars(int sa_idx, int nelems, char ja[], int ja_start); + + /** + * double access + * + * @param sa_idx + * @return double stored in array + */ + public native double getDouble(int sa_idx); + + /** + * get double value from N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @return the value at the specified location + */ + public native double getDouble(int indices[]); + + /** + * double access + * + * @param sa_idx1 + * @param sa_idx2 + * @return double stored in array + */ + public native double getDouble(int sa_idx1, int sa_idx2); + + /** + * double access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void getDoubles(int sa_idx, int nelems, double ja[], + int ja_start); + + /** + * @return the size of each element? + */ + public native int getElemSize(); + + /** + * @return The ??features of the array? + */ + public native int getFeatures(); + + /** + * float access + * + * @param sa_idx + * @return float held in array at location + */ + public native float getFloat(int sa_idx); + + /** + * get float value from N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @return the value at the specified location + */ + public native float getFloat(int indices[]); + + /** + * float access + * + * @param sa_idx1 + * @param sa_idx2 + * @return float held in array at location + */ + public native float getFloat(int sa_idx1, int sa_idx2); + + /** + * float access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void getFloats(int sa_idx, int nelems, float ja[], + int ja_start); + + /** + * get int from an single dimensional array + * + * @param sa_idx + * array index + * @return int stored in array + */ + public native int getInt(int sa_idx); + + /** + * get int value from N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @return the value at the specified location + */ + public native int getInt(int indices[]); + + /** + * get int from 2 dimensional array + * + * @param sa_idx1 + * array index first dimension + * @param sa_idx2 + * array index of second dimension + * @return int stored in array + */ + public native int getInt(int sa_idx1, int sa_idx2); + + /** + * retrieves a group of ints from a single dimensional array + * + * @param sa_idx + * the index in the array to start the get + * @param nelems + * number of elements to retrieve + * @param ja + * the structure to be filled with the ints + * @param ja_start + * the start point in the java int array to start filling + */ + public native void getInts(int sa_idx, int nelems, int ja[], int ja_start); + + /** + * get int from an single dimensional array + * + * @param sa_idx + * array index + * @return long stored in array + */ + public native long getLong(int sa_idx); + + /** + * get long value from N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @return the value at the specified location + */ + public native long getLong(int indices[]); + + /** + * get long from 2 dimensional array + * + * @param sa_idx1 + * array index first dimension + * @param sa_idx2 + * array index of second dimension + * @return long stored in array + */ + public native long getLong(int sa_idx1, int sa_idx2); + + /** + * retrieves a group of longs from a single dimensional array + * + * @param sa_idx + * the index in the array to start the get + * @param nelems + * number of elements to retrieve + * @param ja + * the structure to be filled with the longs + * @param ja_start + * the start point in the java longs array to start filling + */ + public native void getLongs(int sa_idx, int nelems, long ja[], int ja_start); + + /** + * @return The lower bounds of the array? + */ + public native int getLBound(); + + /** + * @param dim + * the dimension we are checking in a multidimensional array + * @return The lower bounds of the array? + */ + public native int getLBound(int dim); + + /** + * @return The number of dimensions in this array + */ + public native int getNumDim(); + + /** + * not implemented. + * + * @return 0 + */ + public int getNumLocks() { + return 0; + } + + /** + * short access + * + * @param sa_idx + * @return short stored in array + */ + public native short getShort(int sa_idx); + + /** + * get short value from N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @return the value at the specified location + */ + public native short getShort(int indices[]); + + /** + * short access + * + * @param sa_idx1 + * @param sa_idx2 + * @return short stored in array + */ + public native short getShort(int sa_idx1, int sa_idx2); + + /** + * short access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void getShorts(int sa_idx, int nelems, short ja[], + int ja_start); + + /** + * string access + * + * @param sa_idx + * @return String stored in array + * + */ + public native String getString(int sa_idx); + + /** + * get String value from N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @return the value at the specified location + */ + public native String getString(int indices[]); + + /** + * string access + * + * @param sa_idx1 + * @param sa_idx2 + * @return String stored in array + */ + public native String getString(int sa_idx1, int sa_idx2); + + /** + * string access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void getStrings(int sa_idx, int nelems, String ja[], + int ja_start); + + /** + * @return The upper bounds of the array? + */ + public native int getUBound(); + + /** + * @param dim + * the dimension we are checking in a multidimensional array + * @return The upper bounds of the array? + */ + public native int getUBound(int dim); + + /** + * variant access + * + * @param sa_idx + * @return Variant held in location in the array? + */ + public native Variant getVariant(int sa_idx); + + /** + * get Variant value from N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @return the value at the specified location + */ + public native Variant getVariant(int indices[]); + + /** + * variant access + * + * @param sa_idx1 + * @param sa_idx2 + * @return Variant held in a location in the array? + */ + public native Variant getVariant(int sa_idx1, int sa_idx2); + + /** + * variant access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void getVariants(int sa_idx, int nelems, Variant ja[], + int ja_start); + + /** + * @return the Variant type + */ + public native int getvt(); + + protected native void init(int vt, int lbounds[], int celems[]); + + /** + * Does anyone want to document this? + * + * @param sa + */ + public native void reinit(SafeArray sa); + + /** + * Does anyone want to document this? + * + * @param vt + * the variant type? + */ + public native void reinterpretType(int vt); + + /** + * {@inheritDoc} + */ + public void safeRelease() { + super.safeRelease(); + if (m_pV != 0) { + destroy(); + m_pV = 0; + } else { + // looks like a double release + if (isDebugEnabled()) { + debug(this.getClass().getName() + ":" + this.hashCode() + + " double release"); + } + } + } + + /** + * boolean access + * + * @param sa_idx + * @param c + */ + public native void setBoolean(int sa_idx, boolean c); + + /** + * set boolean value in N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @param c + */ + public native void setBoolean(int indices[], boolean c); + + /** + * boolean access + * + * @param sa_idx1 + * @param sa_idx2 + * @param c + */ + public native void setBoolean(int sa_idx1, int sa_idx2, boolean c); + + /** + * boolean access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void setBooleans(int sa_idx, int nelems, boolean ja[], + int ja_start); + + /** + * byte access + * + * @param sa_idx + * @param c + */ + public native void setByte(int sa_idx, byte c); + + /** + * set byte value in N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @param c + */ + public native void setByte(int indices[], byte c); + + /** + * byte access + * + * @param sa_idx1 + * @param sa_idx2 + * @param c + */ + public native void setByte(int sa_idx1, int sa_idx2, byte c); + + /** + * fills array with passed in bytes + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void setBytes(int sa_idx, int nelems, byte ja[], int ja_start); + + /** + * char access + * + * @param sa_idx + * @param c + */ + public native void setChar(int sa_idx, char c); + + /** + * set char value in N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @param c + */ + public native void setChar(int indices[], char c); + + /** + * char access + * + * @param sa_idx1 + * @param sa_idx2 + * @param c + */ + public native void setChar(int sa_idx1, int sa_idx2, char c); + + /** + * char access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void setChars(int sa_idx, int nelems, char ja[], int ja_start); + + /** + * double access + * + * @param sa_idx + * @param c + */ + public native void setDouble(int sa_idx, double c); + + /** + * set double value in N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @param c + */ + public native void setDouble(int indices[], double c); + + /** + * double access + * + * @param sa_idx1 + * @param sa_idx2 + * @param c + */ + public native void setDouble(int sa_idx1, int sa_idx2, double c); + + /** + * double access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void setDoubles(int sa_idx, int nelems, double ja[], + int ja_start); + + /** + * float access + * + * @param sa_idx + * @param c + */ + public native void setFloat(int sa_idx, float c); + + /** + * set float value in N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @param c + */ + public native void setFloat(int indices[], float c); + + /** + * float access + * + * @param sa_idx1 + * @param sa_idx2 + * @param c + */ + public native void setFloat(int sa_idx1, int sa_idx2, float c); + + /** + * float access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void setFloats(int sa_idx, int nelems, float ja[], + int ja_start); + + /** + * sets the int value of an element in a single dimensional array + * + * @param sa_idx + * index into the array + * @param c + * the value to be set + */ + public native void setInt(int sa_idx, int c); + + /** + * set int value in N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @param c + */ + public native void setInt(int indices[], int c); + + /** + * sets the int value of a 2 dimensional array + * + * @param sa_idx1 + * index on the first dimension + * @param sa_idx2 + * index on the second dimension + * @param c + * the value to be set + */ + public native void setInt(int sa_idx1, int sa_idx2, int c); + + /** + * sets a group of ints into a single dimensional array + * + * @param sa_idx + * the index of the start of the array to put into + * @param nelems + * number of elements to be copied + * @param ja + * the new int values to be put into the array + * @param ja_start + * the start index in the array that we are copying into + * SafeArray + */ + public native void setInts(int sa_idx, int nelems, int ja[], int ja_start); + + /** + * sets the long value of an element in a single dimensional array + * + * @param sa_idx + * index into the array + * @param c + * the value to be set + */ + public native void setLong(int sa_idx, long c); + + /** + * set long value in N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @param c + */ + public native void setLong(int indices[], long c); + + /** + * sets the long value of a 2 dimensional array + * + * @param sa_idx1 + * index on the first dimension + * @param sa_idx2 + * index on the second dimension + * @param c + * the value to be set + */ + public native void setLong(int sa_idx1, int sa_idx2, long c); + + /** + * sets a group of longs into a single dimensional array + * + * @param sa_idx + * the index of the start of the array to put into + * @param nelems + * number of elements to be copied + * @param ja + * the new long values to be put into the array + * @param ja_start + * the start index in the array that we are copying into + * SafeArray + */ + public native void setLongs(int sa_idx, int nelems, long ja[], int ja_start); + + /** + * short access + * + * @param sa_idx1 + * @param sa_idx2 + * @param c + */ + public native void setShort(int sa_idx1, int sa_idx2, short c); + + /** + * short access + * + * @param sa_idx + * @param c + */ + public native void setShort(int sa_idx, short c); + + /** + * set short value in N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @param c + */ + public native void setShort(int indices[], short c); + + /** + * short access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void setShorts(int sa_idx, int nelems, short ja[], + int ja_start); + + /** + * puts a string into an element in a two dimensional array. + * + * @param sa_idx1 + * @param sa_idx2 + * @param c + */ + public native void setString(int sa_idx1, int sa_idx2, String c); + + /* + * ================================================================ The + * beginning of N-dimensional array support + * ================================================================ + */ + + /** + * puts a string into an element in a single dimensional safe array + * + * @param sa_idx + * @param c + */ + public native void setString(int sa_idx, String c); + + /** + * set Stringvalue in N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @param c + */ + public native void setString(int indices[], String c); + + /** + * string access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void setStrings(int sa_idx, int nelems, String ja[], + int ja_start); + + /** + * variant access + * + * @param sa_idx1 + * @param sa_idx2 + * @param c + */ + public native void setVariant(int sa_idx1, int sa_idx2, Variant c); + + /** + * variant access + * + * @param sa_idx + * @param c + */ + public native void setVariant(int sa_idx, Variant c); + + /** + * set Variant value in N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @param v + */ + public native void setVariant(int indices[], Variant v); + + /** + * variant access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void setVariants(int sa_idx, int nelems, Variant ja[], + int ja_start); + + /** + * Retrieves the data from the array cast to a Java data type + * + * @return boolean[] array of booleans contained in this collection + */ + public native boolean[] toBooleanArray(); + + /** + * Retrieves the data from the array cast to a Java data type + * + * @return byte[] byte array contained in this collection + */ + public native byte[] toByteArray(); + + /** + * Retrieves the data from the array cast to a Java data type + * + * @return char[] character array contained in this collection + */ + public native char[] toCharArray(); + + /** + * Retrieves the data from the array cast to a Java data type + * + * @return double[] double array contained in this collection + */ + public native double[] toDoubleArray(); + + /** + * Retrieves the data from the array cast to a Java data type + * + * @return float[] array of float contained in this collection + */ + public native float[] toFloatArray(); + + /** + * Retrieves the data from the array cast to a Java data type + * + * @return int[] int array contained in this collection + */ + public native int[] toIntArray(); + + /** + * Retrieves the data from the array cast to a Java data type + * + * @return long[] long array contained in this collection + */ + public native long[] toLongArray(); + + /** + * Retrieves the data from the array cast to a Java data type + * + * @return short[] short array contained in this collection + */ + public native short[] toShortArray(); + + /** + * Standard toString() Warning, this creates new Variant objects! + * + * @return String contents of variant + */ + public String toString() { + String s = ""; + int ndim = getNumDim(); + if (ndim == 1) { + int ldim = getLBound(); + int udim = getUBound(); + for (int i = ldim; i <= udim; i++) { + Variant v = getVariant(i); + + if (((v.getvt() & Variant.VariantTypeMask) | Variant.VariantArray) == v + .getvt()) { + return s + "[" + v.toSafeArray().toString() + "]"; + } else { + s += " " + v.toString(); + } + } + } else if (ndim == 2) { + int ldim1 = getLBound(1); + int udim1 = getUBound(1); + + int ldim2 = getLBound(2); + int udim2 = getUBound(2); + + for (int i = ldim1; i <= udim1; i++) { + for (int j = ldim2; j <= udim2; j++) { + Variant v = getVariant(i, j); + s += " " + v.toString(); + } + s += "\n"; + } + } + return s; + } + + /** + * Retrieves the data from the array cast to a Java data type + * + * @return String[] String array contained in this collection + */ + public native String[] toStringArray(); + + /** + * Retrieves the data from the array cast to a Java data type + * + * @return Variant[] array of variants contained in this collection + */ + public native Variant[] toVariantArray(); } \ No newline at end of file diff --git a/src/main/java/com/jacob/com/Variant.java b/src/main/java/com/jacob/com/Variant.java index 7c22b61..2f6d407 100644 --- a/src/main/java/com/jacob/com/Variant.java +++ b/src/main/java/com/jacob/com/Variant.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -59,2192 +59,2192 @@ import java.util.Date; */ public class Variant extends JacobObject { - /** - * Use this constant for optional parameters - */ - public final static com.jacob.com.Variant DEFAULT; + /** + * Use this constant for optional parameters + */ + public final static com.jacob.com.Variant DEFAULT; - /** - * Same than {@link #DEFAULT} - */ - public final static com.jacob.com.Variant VT_MISSING; + /** + * Same than {@link #DEFAULT} + */ + public final static com.jacob.com.Variant VT_MISSING; - /** - * Use for true/false variant parameters - */ - public final static com.jacob.com.Variant VT_TRUE = new com.jacob.com.Variant( - true); + /** + * Use for true/false variant parameters + */ + public final static com.jacob.com.Variant VT_TRUE = new com.jacob.com.Variant( + true); - /** - * Use for true/false variant parameters - */ - public final static com.jacob.com.Variant VT_FALSE = new com.jacob.com.Variant( - false); + /** + * Use for true/false variant parameters + */ + public final static com.jacob.com.Variant VT_FALSE = new com.jacob.com.Variant( + false); - /** variant's type is empty : equivalent to VB Nothing and VT_EMPTY */ - public static final short VariantEmpty = 0; + /** variant's type is empty : equivalent to VB Nothing and VT_EMPTY */ + public static final short VariantEmpty = 0; - /** variant's type is null : equivalent to VB Null and VT_NULL */ - public static final short VariantNull = 1; - - /** variant's type is short VT_I2 */ - public static final short VariantShort = 2; + /** variant's type is null : equivalent to VB Null and VT_NULL */ + public static final short VariantNull = 1; + + /** variant's type is short VT_I2 */ + public static final short VariantShort = 2; - /** variant's type is int VT_I4, a Long in VC */ - public static final short VariantInt = 3; - - /** variant's type is float VT_R4 */ - public static final short VariantFloat = 4; - - /** variant's type is double VT_R8 */ - public static final short VariantDouble = 5; - - /** variant's type is currency VT_CY */ - public static final short VariantCurrency = 6; - - /** variant's type is date VT_DATE */ - public static final short VariantDate = 7; - - /** variant's type is string also known as VT_BSTR */ - public static final short VariantString = 8; - - /** variant's type is dispatch VT_DISPATCH */ - public static final short VariantDispatch = 9; - - /** variant's type is error VT_ERROR */ - public static final short VariantError = 10; - - /** variant's type is boolean VT_BOOL */ - public static final short VariantBoolean = 11; - - /** variant's type is variant it encapsulate another variant VT_VARIANT */ - public static final short VariantVariant = 12; - - /** variant's type is object VT_UNKNOWN */ - public static final short VariantObject = 13; - - /** variant's type is object VT_DECIMAL */ - public static final short VariantDecimal = 14; - - // VT_I1 = 16 - - /** variant's type is byte VT_UI1 */ - public static final short VariantByte = 17; - - // VT_UI2 = 18 - // VT_UI4 = 19 - - /** - * variant's type is 64 bit long integer VT_I8 - not yet implemented in - * Jacob because we have to decide what to do with Currency and because its - * only supported on XP and later. No win2k, NT or 2003 server. - */ - public static final short VariantLongInt = 20; - - // VT_UI8 = 21 - // VT_INT = 22 - // VT_UNIT = 23 - // VT_VOID = 24 - // VT_HRESULT = 25 - - /** - * This value is for reference only and is not to be used by any callers - */ - public static final short VariantPointer = 26; - - // VT_SAFEARRAY = 27 - // VT_CARRARY = 28 - // VT_USERDEFINED = 29 - - /** what is this? VT_TYPEMASK && VT_BSTR_BLOB */ - public static final short VariantTypeMask = 4095; - - /** variant's type is array VT_ARRAY */ - public static final short VariantArray = 8192; - - /** variant's type is a reference (to IDispatch?) VT_BYREF */ - public static final short VariantByref = 16384; - - /* - * Do the run time definition of DEFAULT and MISSING. Have to use static - * block because of the way the initialization is done via two calls instead - * of just a constructor for this type. - */ - static { - com.jacob.com.Variant vtMissing = new com.jacob.com.Variant(); - vtMissing.putVariantNoParam(); - DEFAULT = vtMissing; - VT_MISSING = vtMissing; - } - - /** - * Pointer to MS struct. - */ - int m_pVariant = 0; - - /** - * public constructor, initializes and sets type to VariantEmpty - */ - public Variant() { - this(null, false); - } - - /** - * Constructor that accepts a primitive rather than an object - * - * @param in - */ - public Variant(boolean in) { - this(new Boolean(in)); - } - - /** - * Constructor that accepts a primitive rather than an object - * - * @param in - */ - public Variant(byte in) { - this(new Byte(in)); - } - - /** - * Constructor that accepts a primitive rather than an object - * - * @param in - */ - public Variant(double in) { - this(new Double(in)); - } - - /** - * Constructor that accepts a primitive rather than an object - * - * @param in - */ - public Variant(float in) { - this(new Float(in)); - } - - /** - * Constructor that accepts a primitive rather than an object - * - * @param in - */ - public Variant(int in) { - this(new Integer(in)); - }; - - /** - * Constructor that accepts a primitive rather than an object - * - * @param in - */ - public Variant(long in) { - this(new Long(in)); - } - - /** - * Convenience constructor that calls the main one with a byRef value of - * false - * - * @param in - * object to be made into variant - */ - public Variant(Object in) { - this(in, false); - } - - /** - * Constructor that accepts the data object and information about whether - * this is by reference or not. It calls the JavaVariantConverter to - * actually push the data into the newly created Variant. - * - * @param pValueObject - * The value object that will pushed down into windows memory. A - * null object sets this to "empty" - * @param fByRef - */ - public Variant(Object pValueObject, boolean fByRef) { - init(); - VariantUtilities.populateVariant(this, pValueObject, fByRef); - } - - /** - * Constructor that accepts a primitive rather than an object - * - * @param in - */ - public Variant(short in) { - this(new Short(in)); - } - - /** - * Cover for native method so we can cover it. - *

- * This cannot convert an object to a byRef. It can convert from byref to - * not byref - * - * @param in - * type to convert this variant too - * @return Variant returns this same object so folks can change when - * replacing calls toXXX() with changeType().getXXX() - */ - public Variant changeType(short in) { - changeVariantType(in); - return this; - } - - /** - * Converts variant to the passed in type by converting the underlying - * windows variant structure. private so folks use public java method - * - * @param in - * the desired resulting type - */ - private native void changeVariantType(short in); - - /** - * this returns null - * - * @return ?? comment says null? - */ - public native Object clone(); - - /** - * @deprecated No longer used - * @return null ! - */ - @Deprecated - public native Variant cloneIndirect(); - - /* - * (non-Javadoc) - * - * @see java.lang.Object#finalize() - */ - protected void finalize() { - safeRelease(); - } - - /** - * - * @return returns the value as a boolean, throws an exception if its not. - * @throws IllegalStateException - * if variant is not of the requested type - */ - public boolean getBoolean() { - if (this.getvt() == VariantBoolean) { - return getVariantBoolean(); - } else { - throw new IllegalStateException( - "getBoolean() only legal on Variants of type VariantBoolean, not " - + this.getvt()); - } - } - - /** - * public cover for native method - * - * @return the boolean from a booleanRef - * @throws IllegalStateException - * if variant is not of the requested type - */ - public boolean getBooleanRef() { - if ((this.getvt() & VariantBoolean) == VariantBoolean - && (this.getvt() & VariantByref) == VariantByref) { - return getVariantBooleanRef(); - } else { - throw new IllegalStateException( - "getBooleanRef() only legal on byRef Variants of type VariantBoolean, not " - + this.getvt()); - } - } - - /** - * - * @return returns the value as a boolean, throws an exception if its not. - * @throws IllegalStateException - * if variant is not of the requested type - */ - public byte getByte() { - if (this.getvt() == VariantByte) { - return getVariantByte(); - } else { - throw new IllegalStateException( - "getByte() only legal on Variants of type VariantByte, not " - + this.getvt()); - } - } - - /** - * public cover for native method - * - * @return the byte from a booleanRef - * @throws IllegalStateException - * if variant is not of the requested type - */ - public byte getByteRef() { - if ((this.getvt() & VariantByte) == VariantByte - && (this.getvt() & VariantByref) == VariantByref) { - return getVariantByteRef(); - } else { - throw new IllegalStateException( - "getByteRef() only legal on byRef Variants of type VariantByte, not " - + this.getvt()); - } - } - - /** - * MS Currency objects are 64 bit fixed point numbers with 15 digits to the - * left and 4 to the right of the decimal place. - * - * @return returns the currency value as a long, throws exception if not a - * currency type.. - * @throws IllegalStateException - * if variant is not of the requested type - */ - public Currency getCurrency() { - if (this.getvt() == VariantCurrency) { - return new Currency(getVariantCurrency()); - } else { - throw new IllegalStateException( - "getCurrency() only legal on Variants of type VariantCurrency, not " - + this.getvt()); - } - } - - /** - * MS Currency objects are 64 bit fixed point numbers with 15 digits to the - * left and 4 to the right of the decimal place. - * - * @return returns the currency value as a long, throws exception if not a - * currency type - * @throws IllegalStateException - * if variant is not of the requested type - */ - public Currency getCurrencyRef() { - if ((this.getvt() & VariantCurrency) == VariantCurrency - && (this.getvt() & VariantByref) == VariantByref) { - return new Currency(getVariantCurrencyRef()); - } else { - throw new IllegalStateException( - "getCurrencyRef() only legal on byRef Variants of type VariantCurrency, not " - + this.getvt()); - } - } - - /** - * @return double return the date (as a double) value held in this variant - * (fails on other types?) - * @throws IllegalStateException - * if variant is not of the requested type - */ - public double getDate() { - if (this.getvt() == VariantDate) { - return getVariantDate(); - } else { - throw new IllegalStateException( - "getDate() only legal on Variants of type VariantDate, not " - + this.getvt()); - } - } - - /** - * - * @return returns the date value as a double, throws exception if not a - * date type - * @throws IllegalStateException - * if variant is not of the requested type - */ - public double getDateRef() { - if ((this.getvt() & VariantDate) == VariantDate - && (this.getvt() & VariantByref) == VariantByref) { - return getVariantDateRef(); - } else { - throw new IllegalStateException( - "getDateRef() only legal on byRef Variants of type VariantDate, not " - + this.getvt()); - } - } - - /** - * return the BigDecimal value held in this variant (fails on other types) - * - * @return BigDecimal - * @throws IllegalStateException - * if variant is not of the requested type - */ - public BigDecimal getDecimal() { - if (this.getvt() == VariantDecimal) { - return (BigDecimal) (getVariantDec()); - } else { - throw new IllegalStateException( - "getDecimal() only legal on Variants of type VariantDecimal, not " - + this.getvt()); - } - } - - /** - * return the BigDecimal value held in this variant (fails on other types) - * - * @return BigDecimal - * @throws IllegalStateException - * if variant is not of the requested type - */ - public BigDecimal getDecimalRef() { - if ((this.getvt() & VariantDecimal) == VariantDecimal - && (this.getvt() & VariantByref) == VariantByref) { - return (BigDecimal) (getVariantDecRef()); - } else { - throw new IllegalStateException( - "getDecimalRef() only legal on byRef Variants of type VariantDecimal, not " - + this.getvt()); - } - } - - /** - * cover for {@link #toDispatch()} This method now matches other getXXX() - * methods. It throws an IllegalStateException if the object is not of type - * VariantDispatch - * - * @return this object as a dispatch - * @throws IllegalStateException - * if wrong variant type - */ - public Dispatch getDispatch() { - if ((this.getvt() & VariantDispatch) == VariantDispatch) { - return toDispatch(); - } else { - throw new IllegalStateException( - "getDispatch() only legal on Variants of type VariantDispatch, not " - + this.getvt()); - } - } - - /** - * Dispatch and dispatchRef are treated the same This is just a cover for - * toDispatch() with a flag check - * - * @return the results of toDispatch() - * @throws IllegalStateException - * if variant is not of the requested type - */ - public Dispatch getDispatchRef() { - if ((this.getvt() & VariantDispatch) == VariantDispatch - && (this.getvt() & VariantByref) == VariantByref) { - return toDispatch(); - } else { - throw new IllegalStateException( - "getDispatchRef() only legal on byRef Variants of type VariantDispatch, not " - + this.getvt()); - } - } - - /** - * @return double return the double value held in this variant (fails on - * other types?) - * @throws IllegalStateException - * if variant is not of the requested type - */ - public double getDouble() { - if (this.getvt() == VariantDouble) { - return getVariantDouble(); - } else { - throw new IllegalStateException( - "getDouble() only legal on Variants of type VariantDouble, not " - + this.getvt()); - } - } - - /** - * - * @return returns the double value, throws exception if not a Double type - * @throws IllegalStateException - * if variant is not of the requested type - */ - public double getDoubleRef() { - if ((this.getvt() & VariantDouble) == VariantDouble - && (this.getvt() & VariantByref) == VariantByref) { - return getVariantDoubleRef(); - } else { - throw new IllegalStateException( - "getDoubleRef() only legal on byRef Variants of type VariantDouble, not " - + this.getvt()); - } - } - - /** - * Pointless method that was put here so that putEmpty() has a get method. - * This would have returned null if the value was VT_EMPTY or if it wasn't - * so it would have always returned the same value. - * - * @deprecated method never did anything - */ - @Deprecated - public void getEmpty() { - } - - /** - * @return double return the error value held in this variant (fails on - * other types?) - * @throws IllegalStateException - * if variant is not of the requested type - */ - public int getError() { - if (this.getvt() == VariantError) { - return getVariantError(); - } else { - throw new IllegalStateException( - "getError() only legal on Variants of type VariantError, not " - + this.getvt()); - } - } - - /** - * - * @return returns the error value as an int, throws exception if not a - * Error type - * @throws IllegalStateException - * if variant is not of the requested type - */ - public int getErrorRef() { - if ((this.getvt() & VariantError) == VariantError - && (this.getvt() & VariantByref) == VariantByref) { - return getVariantErrorRef(); - } else { - throw new IllegalStateException( - "getErrorRef() only legal on byRef Variants of type VariantError, not " - + this.getvt()); - } - } - - /** - * @return returns the value as a float if the type is of type float - * @throws IllegalStateException - * if variant is not of the requested type - */ - public float getFloat() { - if (this.getvt() == VariantFloat) { - return getVariantFloat(); - } else { - throw new IllegalStateException( - "getFloat() only legal on Variants of type VariantFloat, not " - + this.getvt()); - } - } - - /** - * - * @return returns the float value, throws exception if not a Float type - * @throws IllegalStateException - * if variant is not of the requested type - */ - public float getFloatRef() { - if ((this.getvt() & VariantFloat) == VariantFloat - && (this.getvt() & VariantByref) == VariantByref) { - return getVariantFloatRef(); - } else { - throw new IllegalStateException( - "getFloatRef() only legal on byRef Variants of type VariantFloat, not " - + this.getvt()); - } - } - - /** - * return the int value held in this variant if it is an int or a short. - * Throws for other types. - * - * @return int contents of the windows memory - * @throws IllegalStateException - * if variant is not of the requested type - */ - public int getInt() { - if (this.getvt() == VariantInt) { - return getVariantInt(); - } else if (this.getvt() == VariantShort) { - return getVariantShort(); - } else { - throw new IllegalStateException( - "getInt() only legal on Variants of type VariantInt, not " - + this.getvt()); - } - } - - /** - * get the content of this variant as an int - * - * @return int - * @throws IllegalStateException - * if variant is not of the requested type - */ - public int getIntRef() { - if ((this.getvt() & VariantInt) == VariantInt - && (this.getvt() & VariantByref) == VariantByref) { - return getVariantIntRef(); - } else { - throw new IllegalStateException( - "getIntRef() only legal on byRef Variants of type VariantInt, not " - + this.getvt()); - } - } - - /** - * returns the windows time contained in this Variant to a Java Date. should - * return null if this is not a date Variant SF 959382 - * - * @return java.util.Date returns the date if this is a VariantDate != 0, - * null if it is a VariantDate == 0 and throws an - * IllegalStateException if this isn't a date. - * @throws IllegalStateException - * if variant is not of the requested type - */ - public Date getJavaDate() { - Date returnDate = null; - if (getvt() == VariantDate) { - double windowsDate = getDate(); - if (windowsDate != 0) { - returnDate = DateUtilities.convertWindowsTimeToDate(getDate()); - } - } else { - throw new IllegalStateException( - "getJavaDate() only legal on Variants of type VariantDate, not " - + this.getvt()); - } - return returnDate; - } - - /** - * returns the windows time contained in this Variant to a Java Date should - * return null if this is not a date reference Variant SF 959382 - * - * @return java.util.Date - */ - public Date getJavaDateRef() { - double windowsDate = getDateRef(); - if (windowsDate == 0) { - return null; - } else { - return DateUtilities.convertWindowsTimeToDate(windowsDate); - } - } - - /** - * 64 bit Longs only available on x64. 64 bit long support added 1.14 - * - * @return returns the value as a long, throws exception if not a Long - * type.. - * @throws IllegalStateException - * if variant is not of the requested type - */ - public long getLong() { - if (this.getvt() == VariantLongInt) { - return getVariantLong(); - } else { - throw new IllegalStateException( - "getLong() only legal on Variants of type VariantLongInt, not " - + this.getvt()); - } - } - - /** - * 64 bit Longs only available on x64. 64 bit long support added 1.14 - * - * @return returns the value as a long, throws exception if not a long type - * @throws IllegalStateException - * if variant is not of the requested type - */ - public long getLongRef() { - if ((this.getvt() & VariantLongInt) == VariantLongInt - && (this.getvt() & VariantByref) == VariantByref) { - return getVariantLongRef(); - } else { - throw new IllegalStateException( - "getLongRef() only legal on byRef Variants of type VariantLongInt, not " - + this.getvt()); - } - } - - /** - * This method would have returned null if the type was VT_NULL. But because - * we return null if the data is not of the right type, this method should - * have always returned null - * - * @deprecated method never did anything - */ - @Deprecated - public void getNull() { - } - - /** - * return the int value held in this variant (fails on other types?) - * - * @return int - * @throws IllegalStateException - * if variant is not of the requested type - */ - public short getShort() { - if (this.getvt() == VariantShort) { - return getVariantShort(); - } else { - throw new IllegalStateException( - "getShort() only legal on Variants of type VariantShort, not " - + this.getvt()); - } - } - - /** - * get the content of this variant as an int - * - * @return int - * @throws IllegalStateException - * if variant is not of the requested type - */ - public short getShortRef() { - if ((this.getvt() & VariantShort) == VariantShort - && (this.getvt() & VariantByref) == VariantByref) { - return getVariantShortRef(); - } else { - throw new IllegalStateException( - "getShortRef() only legal on byRef Variants of type VariantShort, not " - + this.getvt()); - } - } - - /** - * - * @return string contents of the variant. - * @throws IllegalStateException - * if this variant is not of type String - */ - public String getString() { - if (getvt() == Variant.VariantString) { - return getVariantString(); - } else { - throw new IllegalStateException( - "getString() only legal on Variants of type VariantString, not " - + this.getvt()); - } - } - - /** - * gets the content of the variant as a string ref - * - * @return String retrieved from the COM area. - * @throws IllegalStateException - * if variant is not of the requested type - */ - public String getStringRef() { - if ((this.getvt() & VariantString) == VariantString - && (this.getvt() & VariantByref) == VariantByref) { - return getVariantStringRef(); - } else { - throw new IllegalStateException( - "getStringRef() only legal on byRef Variants of type VariantString, not " - + this.getvt()); - } - } - - /** - * Used to get the value from a windows type of VT_VARIANT or a jacob - * Variant type of VariantVariant. Added 1.12 pre 6 - VT_VARIANT support is - * at an alpha level - * - * @return Object a java Object that represents the content of the enclosed - * Variant - */ - public Object getVariant() { - if ((this.getvt() & VariantVariant) == VariantVariant - && (this.getvt() & VariantByref) == VariantByref) { - if (JacobObject.isDebugEnabled()) { - JacobObject.debug("About to call getVariantVariant()"); - } - Variant enclosedVariant = new Variant(); - int enclosedVariantMemory = getVariantVariant(); - enclosedVariant.m_pVariant = enclosedVariantMemory; - Object enclosedVariantAsJava = enclosedVariant.toJavaObject(); - // zero out the reference to the underlying windows memory so that - // it is still only owned in one place by one java object - // (this object of type VariantVariant) - // enclosedVariant.putEmpty(); // don't know if this would have had - // side effects - if (JacobObject.isDebugEnabled()) { - JacobObject - .debug("Zeroing out enclosed Variant's ref to windows memory"); - } - enclosedVariant.m_pVariant = 0; - return enclosedVariantAsJava; - } else { - throw new IllegalStateException( - "getVariant() only legal on Variants of type VariantVariant, not " - + this.getvt()); - } - } - - /** - * @deprecated superseded by SafeArray - * @return never returns anything - * @throws com.jacob.com.NotImplementedException - */ - @Deprecated - public Variant[] getVariantArray() { - throw new NotImplementedException("Not implemented"); - } - - /** - * @return the Variant Array that represents the data in the Variant - * @deprecated superseded by SafeArray - * @throws com.jacob.com.NotImplementedException - */ - @Deprecated - public Variant[] getVariantArrayRef() { - throw new NotImplementedException("Not implemented"); - } - - /** - * - * @return the value in this Variant as a boolean, null if not a boolean - */ - private native boolean getVariantBoolean(); - - private native boolean getVariantBooleanRef(); - - /** - * @return the value in this Variant as a byte, null if not a byte - */ - private native byte getVariantByte(); - - /** - * @return the value in this Variant as a byte, null if not a byte - */ - private native byte getVariantByteRef(); - - /** - * @return the value in this Variant as a long, null if not a long - */ - private native long getVariantCurrency(); - - /** - * @return the value in this Variant as a long, null if not a long - */ - private native long getVariantCurrencyRef(); - - /** - * @return double return the date (as a double) value held in this variant - * (fails on other types?) - */ - private native double getVariantDate(); - - /** - * get the content of this variant as a double representing a date - * - * @return double - */ - private native double getVariantDateRef(); - - /** - * @return the value in this Variant as a decimal, null if not a decimal - */ - private native Object getVariantDec(); - - /** - * @return the value in this Variant (byref) as a decimal, null if not a - * decimal - */ - private native Object getVariantDecRef(); - - /** - * @return double get the content of this variant as a double - */ - private native double getVariantDouble(); - - /** - * @return double get the content of this variant as a double - */ - private native double getVariantDoubleRef(); - - private native int getVariantError(); - - private native int getVariantErrorRef(); - - /** - * @return returns the value as a float if the type is of type float - */ - private native float getVariantFloat(); - - /** - * @return returns the value as a float if the type is of type float - */ - private native float getVariantFloatRef(); - - /** - * @return the int value held in this variant (fails on other types?) - */ - private native int getVariantInt(); - - /** - * @return the int value held in this variant (fails on other types?) - */ - private native int getVariantIntRef(); - - /** - * @return the value in this Variant as a long, null if not a long - */ - private native long getVariantLong(); - - /** - * @return the value in this Variant as a long, null if not a long - */ - private native long getVariantLongRef(); - - /** - * get the content of this variant as a short - * - * @return short - */ - private native short getVariantShort(); - - /** - * @return short the content of this variant as a short - */ - private native short getVariantShortRef(); - - /** - * Native method that actually extracts a string value from the variant - * - * @return - */ - private native String getVariantString(); - - /** - * @return String the content of this variant as a string - */ - private native String getVariantStringRef(); - - /** - * Returns the variant type via a native method call - * - * @return short one of the VT_xx types - */ - private native short getVariantType(); - - /** - * Returns the variant type via a native method call. Added 1.12 pre 6 - - * VT_VARIANT support is at an alpha level - * - * @return Variant one of the VT_Variant types - */ - private native int getVariantVariant(); - - /** - * Reports the type of the underlying Variant object - * - * @return returns the variant type as a short, one of the Variantxxx values - * defined as statics in this class. returns VariantNull if not - * initialized - * @throws IllegalStateException - * if there is no underlying windows data structure - */ - public short getvt() { - if (m_pVariant != 0) { - return getVariantType(); - } else { - throw new IllegalStateException("uninitialized Variant"); - } - } - - /** - * initializes the COM Variant and puts its reference in this instance - */ - protected native void init(); - - /** - * - * @return returns true if the variant is considered null - * @throws IllegalStateException - * if there is no underlying windows memory - */ - public boolean isNull() { - getvt(); - return isVariantConsideredNull(); - } - - /** - * is the variant null or empty or error or null dispatch - * - * @return true if it is null or false if not - */ - private native boolean isVariantConsideredNull(); - - /** - * sets the type to VT_ERROR and the error message to DISP_E_PARAMNOTFOIUND - * - * @deprecated replaced by putNoParam() - */ - @Deprecated - public void noParam() { - putNoParam(); - } - - /** - * returns true if the passed in Variant is a constant that should not be - * freed - * - * @param pVariant - * @return boolean that is true if Variant is a type of constant, VT_FALSE, - * VT_TRUE, VT_MISSING, DEFAULT - */ - protected boolean objectIsAConstant(Variant pVariant) { - if (pVariant == VT_FALSE || pVariant == VT_TRUE - || pVariant == VT_MISSING || pVariant == DEFAULT) { - return true; - } else { - return false; - } - - } - - /** - * puts a boolean into the variant and sets it's type - * - * @param in - * the new value - */ - public void putBoolean(boolean in) { - // verify we aren't released yet - getvt(); - putVariantBoolean(in); - } - - /** - * pushes a boolean into the variant by ref and sets the type of the variant - * to boolean - * - * @param in - */ - public void putBooleanRef(boolean in) { - // verify we aren't released yet - getvt(); - putVariantBooleanRef(in); - } - - /** - * pushes a byte into the varaint and sets the type - * - * @param in - */ - public void putByte(byte in) { - // verify we aren't released yet - getvt(); - putVariantByte(in); - }; - - /** - * @deprecated superseded by SafeArray - * @param in - * doesn't matter because this method does nothing - * @throws com.jacob.com.NotImplementedException - */ - @Deprecated - public void putByteArray(Object in) { - throw new NotImplementedException("Not implemented"); - } - - /** - * pushes a byte into the variant by ref and sets the type - * - * @param in - */ - public void putByteRef(byte in) { - // verify we aren't released yet - getvt(); - putVariantByteRef(in); - } - - /** - * @param in - * the object that would be wrapped by the Variant if this method - * was implemented - * @deprecated superseded by SafeArray - * @throws com.jacob.com.NotImplementedException - */ - @Deprecated - public void putCharArray(Object in) { - throw new NotImplementedException("Not implemented"); - } - - /** - * Puts a value in as a currency and sets the variant type. MS Currency - * objects are 64 bit fixed point numbers with 15 digits to the left and 4 - * to the right of the decimal place. - * - * @param in - * the long that will be put into the 64 bit currency object. - */ - public void putCurrency(Currency in) { - // verify we aren't released yet - getvt(); - putVariantCurrency(in.longValue()); - } - - /** - * Pushes a long into the variant as currency and sets the type. MS Currency - * objects are 64 bit fixed point numbers with 15 digits to the left and 4 - * to the right of the decimal place. - * - * @param in - * the long that will be put into the 64 bit currency object - */ - public void putCurrencyRef(Currency in) { - // verify we aren't released yet - getvt(); - putVariantCurrencyRef(in.longValue()); - } - - /** - * converts a java date to a windows time and calls putDate(double) SF - * 959382 - * - * @param inDate - * a Java date to be converted - * @throws IllegalArgumentException - * if inDate = null - */ - public void putDate(Date inDate) { - if (inDate == null) { - throw new IllegalArgumentException( - "Cannot put null in as windows date"); - // do nothing - } else { - putDate(DateUtilities.convertDateToWindowsTime(inDate)); - } - } - - /** - * puts a windows date double into the variant and sets the type - * - * @param in - */ - public void putDate(double in) { - // verify we aren't released yet - getvt(); - putVariantDate(in); - } - - /** - * converts a java date to a windows time and calls putDateRef(double) SF - * 959382 - * - * @param inDate - * a Java date to be converted - * @throws IllegalArgumentException - * if inDate = null - */ - public void putDateRef(Date inDate) { - if (inDate == null) { - throw new IllegalArgumentException( - "Cannot put null in as windows date"); - // do nothing - } else { - putDateRef(DateUtilities.convertDateToWindowsTime(inDate)); - } - } - - /** - * set the content of this variant to a date (VT_DATE|VT_BYREF) - * - * @param in - */ - public void putDateRef(double in) { - // verify we aren't released - getvt(); - putVariantDateRef(in); - } - - /** - * This actual does all the validating and massaging of the BigDecimalValues - * when converting them to MS Decimal types - * - * @param in - * number to be made into VT_DECIMAL - * @param byRef - * store by reference or not - * @param roundingBehavior - * one of the BigDecimal ROUND_xxx methods. Any method other than - * ROUND_UNECESSARY means that the value will be rounded to fit - */ - private void putDecimal(BigDecimal in, boolean byRef) { - // verify we aren't released - getvt(); - // first validate the min and max - VariantUtilities.validateDecimalMinMax(in); - BigInteger allWordBigInt; - allWordBigInt = in.unscaledValue(); - // Assume any required rounding has been done. - VariantUtilities.validateDecimalScaleAndBits(in); - // finally we can do what we actually came here to do - int sign = in.signum(); - // VT_DECIMAL always has positive value with just the sign - // flipped - if (in.signum() < 0) { - in = in.negate(); - } - // ugh, reusing allWordBigInt but now should always be positive - // and any round is applied - allWordBigInt = in.unscaledValue(); - byte scale = (byte) in.scale(); - int lowWord = allWordBigInt.intValue(); - BigInteger middleWordBigInt = allWordBigInt.shiftRight(32); - int middleWord = middleWordBigInt.intValue(); - BigInteger highWordBigInt = allWordBigInt.shiftRight(64); - int highWord = highWordBigInt.intValue(); - if (byRef) { - putVariantDecRef(sign, scale, lowWord, middleWord, highWord); - } else { - putVariantDec(sign, scale, lowWord, middleWord, highWord); - } - } - - /** - * EXPERIMENTAL 1.14 feature to support rounded decimals. - *

- * Set the value of this variant and set the type. This may throw exceptions - * more often than the caller expects because most callers don't manage the - * scale of their BigDecimal objects. - *

- * This default set method throws exceptions if precision or size is out of - * bounds - *

- * There are 12 bytes available for the integer number. - *

- * There is 1 byte for the scale. - * - * @param in - * the BigDecimal that will be converted to VT_DECIMAL - * @throws IllegalArgumentException - * if the scale is > 28, the maximum for VT_DECIMAL or if there - * are more than 12 bytes worth the digits - */ - public void putDecimal(BigDecimal in) { - putDecimal(in, false); - } - - /** - * Set the value of this variant and set the type. This may throw exceptions - * more often than the caller expects because most callers don't manage the - * scale of their BigDecimal objects. - *

- * This default set method throws exceptions if precision or size is out of - * bounds - *

- * There are 12 bytes available for the integer number. - *

- * There is 1 byte for the scale. - * - * @param in - * the BigDecimal that will be converted to VT_DECIMAL - * @throws IllegalArgumentException - * if the scale is > 28, the maximum for VT_DECIMAL or if there - * are more than 12 bytes worth the digits - */ - public void putDecimalRef(BigDecimal in) { - putDecimal(in, true); - } - - /** - * This acts a cover for putVariant Dispatch. - * - * @param in - * the Dispatch we're putting down in the COM variant space. - */ - public void putDispatch(Dispatch in) { - putVariantDispatch(in); - } - - /** - * Dispatch and dispatchRef are treated the same This is a cover for - * putVariantDispatch(). putDispatch and putDispatchRef are treated the same - * because no one has written the COM code for putDispatchRef. - * - * @param in - * the Dispatch we're putting down in the COM variant space. - */ - public void putDispatchRef(Dispatch in) { - putVariantDispatch(in); - } - - /** - * wraps this Variant around the passed in double. - * - * @param in - */ - public void putDouble(double in) { - // verify we aren't released yet - getvt(); - putVariantDouble(in); - } - - /** - * set the content of this variant to a double (VT_R8|VT_BYREF) - * - * @param in - */ - public void putDoubleRef(double in) { - // verify we aren't released - getvt(); - putVariantDoubleRef(in); - } - - /** - * sets the type to VariantEmpty - * - */ - public void putEmpty() { - // verify we aren't released yet - getvt(); - putVariantEmpty(); - } - - /** - * puts an error code (I think) into the variant and sets the type - * - * @param in - */ - public void putError(int in) { - // verify we aren't released yet - getvt(); - putVariantError(in); - } - - /** - * pushes an error code into the variant by ref and sets the type - * - * @param in - */ - public void putErrorRef(int in) { - // verify we aren't released yet - getvt(); - putVariantErrorRef(in); - } - - /** - * fills the Variant with a float and sets the type to float - * - * @param in - */ - public void putFloat(float in) { - // verify we haven't been released yet - getvt(); - putVariantFloat(in); - } - - /** - * pushes a float into the variant and sets the type - * - * @param in - */ - public void putFloatRef(float in) { - // verify we aren't released yet - getvt(); - putVariantFloatRef(in); - } - - /** - * set the value of this variant and set the type - * - * @param in - */ - public void putInt(int in) { - // verify we aren't released yet - getvt(); - putVariantInt(in); - } - - /** - * set the content of this variant to an int (VT_I4|VT_BYREF) - * - * @param in - */ - public void putIntRef(int in) { - // verify we aren't released - getvt(); - putVariantIntRef(in); - } - - /** - * Puts a 64 bit Java Long into a 64 bit Variant Long. Only works on x64 - * systems otherwise throws an error. 64 bit long support added 1.14 - * - * @param in - * the long that will be put into the 64 bit Long object. - */ - public void putLong(long in) { - // verify we aren't released yet - getvt(); - putVariantLong(in); - } - - /** - * Puts a 64 bit Java Long into a 64 bit Variant Long. Only works on x64 - * systems otherwise throws an error. 64 bit long support added 1.14 - * - * @param in - * the long that will be put into the 64 bit Long object. - */ - public void putLongRef(long in) { - // verify we aren't released yet - getvt(); - putVariantLongRef(in); - } - - /** - * sets the type to VT_ERROR and the error message to DISP_E_PARAMNOTFOIUND - */ - public void putNoParam() { - // verify we aren't released yet - getvt(); - putVariantNoParam(); - } - - /** - * Sets the type to VariantDispatch and sets the value to null Equivalent to - * VB's nothing - */ - public void putNothing() { - // verify we aren't released yet - getvt(); - putVariantNothing(); - } - - /** - * Set this Variant's type to VT_NULL (the VB equivalent of NULL) - */ - public void putNull() { - // verify we aren't released yet - getvt(); - putVariantNull(); - } - - /** - * Puts an object into the Variant -- converts to Dispatch. Acts as a cover - * for putVariantDispatch(); This primarily exists to support jacobgen. This - * should be deprecated. - * - * @param in - * the object we are putting into the Variant, assumes a - * @see Variant#putDispatch(Dispatch) - * @deprecated should use putDispatch() - */ - @Deprecated - public void putObject(Object in) { - // this should verify in instanceof Dispatch - putVariantDispatch(in); - } - - /** - * Just a cover for putObject(). We shouldn't accept any old random object. - * This has been left in to support jacobgen. This should be deprecated. - * - * @param in - * @deprecated - */ - @Deprecated - public void putObjectRef(Object in) { - putObject(in); - } - - /** - * have no idea... - * - * @param in - */ - public void putSafeArray(SafeArray in) { - // verify we haven't been released yet - getvt(); - putVariantSafeArray(in); - } - - /** - * have no idea... - * - * @param in - */ - public void putSafeArrayRef(SafeArray in) { - // verify we haven't been released yet - getvt(); - putVariantSafeArrayRef(in); - } - - /** - * set the content of this variant to a short (VT_I2) - * - * @param in - */ - public void putShort(short in) { - // verify we aren't released - getvt(); - putVariantShort(in); - } - - /** - * set the content of this variant to a short (VT_I2|VT_BYREF) - * - * @param in - */ - public void putShortRef(short in) { - // verify we aren't released - getvt(); - putVariantShortRef(in); - } - - /** - * put a string into the variant and set its type - * - * @param in - */ - public void putString(String in) { - // verify we aren't released yet - getvt(); - putVariantString(in); - } - - /** - * set the content of this variant to a string (VT_BSTR|VT_BYREF) - * - * @param in - */ - public void putStringRef(String in) { - // verify we aren't released - getvt(); - putVariantStringRef(in); - } - - /** - * Puts a variant into this variant making it type VT_VARIANT. Added 1.12 - * pre 6 - * - * @param objectToBeWrapped - * A object that is to be referenced by this variant. If - * objectToBeWrapped is already of type Variant, then it is used. - * If objectToBeWrapped is not Variant then - * new Variant(objectToBeWrapped) is called and - * the result is passed into the com layer - * @throws IllegalArgumentException - * if inVariant = null or if inVariant is a Varint - */ - public void putVariant(Object objectToBeWrapped) { - if (objectToBeWrapped == null) { - throw new IllegalArgumentException( - "Cannot put null in as a variant"); - } else if (objectToBeWrapped instanceof Variant) { - throw new IllegalArgumentException( - "Cannot putVariant() only accepts non jacob objects."); - } else { - Variant inVariant = new Variant(objectToBeWrapped); - putVariantVariant(inVariant); - // This could be done in Variant.cpp - if (JacobObject.isDebugEnabled()) { - JacobObject - .debug("Zeroing out enclosed Variant's ref to windows memory"); - } - inVariant.m_pVariant = 0; - } - } - - /** - * @deprecated superseded by SafeArray - * @param in - * doesn't matter because this method does nothing - * @throws com.jacob.com.NotImplementedException - */ - @Deprecated - public void putVariantArray(Variant[] in) { - throw new NotImplementedException("Not implemented"); - } - - /** - * @param in - * the thing that would be come an array if this method was - * implemented - * @deprecated superseded by SafeArray - * @throws com.jacob.com.NotImplementedException - */ - @Deprecated - public void putVariantArrayRef(Variant[] in) { - throw new NotImplementedException("Not implemented"); - } - - /** - * puts a boolean into the variant and sets it's type - * - * @param in - * the new value - */ - private native void putVariantBoolean(boolean in); - - /** - * puts a boolean into the variant and sets it's type - * - * @param in - * the new value - */ - private native void putVariantBooleanRef(boolean in); - - /** - * puts a byte into the variant and sets it's type - * - * @param in - * the new value - */ - private native void putVariantByte(byte in); - - /** - * puts a byte into the variant and sets it's type - * - * @param in - * the new value - */ - private native void putVariantByteRef(byte in); - - /** - * puts a Currency into the variant and sets it's type - * - * @param in - * the new value - */ - private native void putVariantCurrency(long in); - - /** - * puts a Currency into the variant and sets it's type - * - * @param in - * the new value - */ - private native void putVariantCurrencyRef(long in); - - /** - * set the value of this variant - * - * @param in - */ - private native void putVariantDate(double in); - - /** - * set the content of this variant to a date (VT_DATE|VT_BYREF) - * - * @param in - */ - private native void putVariantDateRef(double in); - - /** - * private JNI method called by putDecimal - * - * @param signum - * sign - * @param scale - * BigDecimal's scale - * @param lo - * low 32 bits - * @param mid - * middle 32 bits - * @param hi - * high 32 bits - */ - private native void putVariantDec(int signum, byte scale, int lo, int mid, - int hi); - - /** - * private JNI method called by putDecimalRef - * - * @param signum - * sign - * @param scale - * BigDecimal's scale - * @param lo - * low 32 bits - * @param mid - * middle 32 bits - * @param hi - * high 32 bits - */ - private native void putVariantDecRef(int signum, byte scale, int lo, - int mid, int hi); - - /** - * the JNI implementation for putDispatch() so that we can screen the - * incoming dispatches in putDispatch() before this is invoked - * - * @param in - * should be a dispatch object - */ - private native void putVariantDispatch(Object in); - - private native void putVariantDouble(double in); - - /** - * set the content of this variant to a double (VT_R8|VT_BYREF) - * - * @param in - */ - private native void putVariantDoubleRef(double in); - - /** - * Sets the type to VariantEmpty. No values needed - */ - private native void putVariantEmpty(); - - private native void putVariantError(int in); - - private native void putVariantErrorRef(int in); - - /** - * fills the Variant with a float and sets the type to float - * - * @param in - */ - private native void putVariantFloat(float in); - - private native void putVariantFloatRef(float in); - - /** - * set the value of this variant and set the type - * - * @param in - */ - private native void putVariantInt(int in); - - /** - * set the content of this variant to an int (VT_I4|VT_BYREF) - * - * @param in - */ - private native void putVariantIntRef(int in); - - private native void putVariantLong(long in); - - private native void putVariantLongRef(long in); - - /** - * sets the type to VT_ERROR and the error message to DISP_E_PARAMNOTFOIUND - */ - private native void putVariantNoParam(); - - /** - * Sets the type to VariantDispatch and sets the value to null Equivalent to - * VB's nothing - */ - private native void putVariantNothing(); - - /** - * Set this Variant's type to VT_NULL (the VB equivalent of NULL) - */ - private native void putVariantNull(); - - private native void putVariantSafeArray(SafeArray in); - - private native void putVariantSafeArrayRef(SafeArray in); - - /** - * set the content of this variant to a short (VT_I2) - * - * @param in - */ - private native void putVariantShort(short in); - - /** - * set the content of this variant to a short (VT_I2|VT_BYREF) - * - * @param in - */ - private native void putVariantShortRef(short in); - - private native void putVariantString(String in); - - /** - * set the content of this variant to a string (VT_BSTR|VT_BYREF) - * - * @param in - */ - private native void putVariantStringRef(String in); - - /** - * All VariantVariant type variants are BYREF. - * - * Set the content of this variant to a string (VT_VARIANT|VT_BYREF). - * - * Added 1.12 pre 6 - VT_VARIANT support is at an alpha level - * - * @param in - * variant to be wrapped - * - */ - private native void putVariantVariant(Variant in); - - /** - * now private so only this object can access was: call this to explicitly - * release the com object before gc - * - */ - private native void release(); - - /** - * This will release the "C" memory for the Variant unless this Variant is - * one of the constants in which case we don't want to release the memory. - *

- * - * @see com.jacob.com.JacobObject#safeRelease() - */ - public void safeRelease() { - // The well known constants should not be released. - // Unfortunately this doesn't fix any other classes that are - // keeping constants around in their static ivars. - // those will still be busted. - // - // The only inconsistency here is that we leak - // when this class is unloaded because we won't - // free the memory even if the constants are being - // finalized. this is not a big deal at all. - // another way around this would be to create the constants - // in their own thread so that they would never be released - if (!objectIsAConstant(this)) { - super.safeRelease(); - if (m_pVariant != 0) { - release(); - m_pVariant = 0; - } else { - // looks like a double release - // this should almost always happen due to gc - // after someone has called ComThread.Release - if (isDebugEnabled()) { - debug("Variant: " + this.hashCode() + " double release"); - // Throwable x = new Throwable(); - // x.printStackTrace(); - } - } - } else { - if (isDebugEnabled()) { - debug("Variant: " + this.hashCode() - + " don't want to release a constant"); - } - } - } - - /** - * this is supposed to cause the underlying variant object struct to be - * rebuilt from a previously serialized byte array. - * - * @param ba - */ - protected native void SerializationReadFromBytes(byte[] ba); - - /** - * this is supposed to create a byte array that represents the underlying - * variant object structure - */ - protected native byte[] SerializationWriteToBytes(); - - /** - * @deprecated should be replaced by changeType() followed by getBoolean() - * @return the value of this variant as boolean (after possible conversion) - */ - @Deprecated - public boolean toBoolean() { - changeType(Variant.VariantBoolean); - return getBoolean(); - } - - /** - * attempts to return the content of this variant as a double (after - * possible conversion) - * - * @deprecated should be replaced by changeType() followed by getByte() - * @return byte - */ - @Deprecated - public byte toByte() { - changeType(Variant.VariantByte); - return getByte(); - } - - /** - * @deprecated superseded by SafeArray - * @return nothing because this method is not implemented - * @throws com.jacob.com.NotImplementedException - */ - @Deprecated - public Object toByteArray() { - throw new NotImplementedException("Not implemented"); - } - - /** - * @deprecated superseded by SafeArray - * @return never returns anything - * @throws com.jacob.com.NotImplementedException - */ - @Deprecated - public Object toCharArray() { - throw new NotImplementedException("Not implemented"); - } - - /** - * @deprecated should be replaced by changeType() followed by getCurrency - * @return the content of this variant as a long representing a monetary - * amount - */ - @Deprecated - public Currency toCurrency() { - changeType(Variant.VariantCurrency); - return getCurrency(); - } - - /** - * @deprecated should use changeType() followed by getDate() - * @return the value of this variant as a date (after possible conversion) - */ - @Deprecated - public double toDate() { - changeType(VariantDate); - return getDate(); - } - - /** - * @return the content of this variant as a Dispatch object (after possible - * conversion) - */ - public Dispatch toDispatch() { - // now make the native call - return toVariantDispatch(); - } - - /** - * @deprecated should call changeType() then getDouble() - * @return the content of this variant as a double (after possible - * conversion) - */ - @Deprecated - public double toDouble() { - changeType(Variant.VariantDouble); - return getDouble(); - } - - /** @return the value of this variant as an enumeration (java style) */ - public native EnumVariant toEnumVariant(); - - /** - * converts to an error type and returns the error - * - * @deprecated should use changeType() followed by getError() - * @return the error as an int (after conversion) - */ - @Deprecated - public int toError() { - changeType(Variant.VariantError); - return getError(); - } - - /** - * attempts to return the contents of this variant as a float (after - * possible conversion) - * - * @deprecated should use changeType() and getFloat() instead - * @return float - */ - @Deprecated - public float toFloat() { - changeType(Variant.VariantFloat); - return getFloat(); - } - - /** - * @deprecated should use changeType() followed by getInt() - * @return the value of this variant as an int (after possible conversion) - */ - @Deprecated - public int toInt() { - changeType(VariantInt); - return getInt(); - } - - /** - * Returns the windows time contained in this Variant as a Java Date - * converts to a date like many of the other toXXX() methods SF 959382. - *

- * This method added 12/2005 for possible use by jacobgen instead of its - * conversion code - *

- * This does not convert the data - * - * @deprecated callers should use getDate() - * @return java.util.Date version of this variant if it is a date, otherwise - * null - * - */ - @Deprecated - public Date toJavaDate() { - changeType(Variant.VariantDate); - return getJavaDate(); - } - - /** - * Convert a JACOB Variant value to a Java object (type conversions). - * provided in Sourceforge feature request 959381. See - * JavaVariantConverter..convertVariantTJavaObject(Variant) for more - * information. - * - * @return Corresponding Java object of the type matching the Variant type. - * @throws IllegalStateException - * if no underlying windows data structure - * @throws NotImplementedException - * if unsupported conversion is requested - * @throws JacobException - * if the calculated result was a JacobObject usually as a - * result of error - */ - public Object toJavaObject() throws JacobException { - return VariantUtilities.variantToObject(this); - } - - /** - * Acts a a cover for toDispatch. This primarily exists to support jacobgen. - * - * @deprecated this is a cover for toDispatch(); - * @return Object returned by toDispatch() - * @see Variant#toDispatch() instead - */ - @Deprecated - public Object toObject() { - return toDispatch(); - } - - /** - * By default toSafeArray makes a deep copy due to the fact that this - * Variant owns the embedded SafeArray and will destroy it when it gc's - * calls toSafeArray(true). - * - * @return the object converted to a SafeArray - */ - public SafeArray toSafeArray() { - // verify we haven't been released yet - getvt(); - return toSafeArray(true); - } - - /** - * This lets folk turn into a safe array without a deep copy. Should this - * API be public? - * - * @param deepCopy - * @return SafeArray constructed - */ - public SafeArray toSafeArray(boolean deepCopy) { - // verify we haven't been released yet - getvt(); - return toVariantSafeArray(deepCopy); - } - - /** - * I don't know what this is. Is it some legacy (pre 1.8) thing? - * - * @deprecated - * @return this object as a dispatch object by calling toDispatch() - */ - @Deprecated - public Object toScriptObject() { - return toDispatch(); - } - - /** - * attempts to return the contents of this Variant as a short (after - * possible conversion) - * - * @deprecated callers should use changeType() followed by getShort() - * @return short - */ - @Deprecated - public short toShort() { - this.changeType(Variant.VariantShort); - return getShort(); - } - - /** - * This method now correctly implements java toString() semantics Attempts - * to return the content of this variant as a string - *

    - *
  • "not initialized" if not initialized - *
  • "null" if VariantEmpty, - *
  • "null" if VariantError - *
  • "null" if VariantNull - *
  • the value if we know how to describe one of that type - *
  • three question marks if can't convert - * - * @return String value conversion, - * @throws IllegalStateException - * if there is no underlying windows data structure - */ - public String toString() { - try { - // see if we are in a legal state - getvt(); - } catch (IllegalStateException ise) { - return ""; - } - if (getvt() == VariantEmpty || getvt() == VariantError - || getvt() == VariantNull) { - return "null"; - } - if (getvt() == VariantString) { - return getString(); - } - try { - Object foo = toJavaObject(); - // rely on java objects to do the right thing - return foo.toString(); - } catch (NotImplementedException nie) { - // some types do not generate a good description yet - return "Description not available for type: " + getvt(); - } - } - - /** - * Exists to support jacobgen. This would be deprecated if it weren't for - * jacobgen - * - * @deprecated superseded by "this" - * @return this same object - */ - @Deprecated - public Variant toVariant() { - return this; - } - - /** - * @deprecated superseded by SafeArray - * @return nothing because this method is not implemented - * @throws com.jacob.com.NotImplementedException - */ - @Deprecated - public Variant[] toVariantArray() { - throw new NotImplementedException("Not implemented"); - } - - /** - * native method used by toDispatch() - * - * @return - */ - private native Dispatch toVariantDispatch(); - - private native SafeArray toVariantSafeArray(boolean deepCopy); - - /* - * ===================================================================== - * - * - * ===================================================================== - */ - - /** - * Clear the content of this variant - */ - public native void VariantClear(); + /** variant's type is int VT_I4, a Long in VC */ + public static final short VariantInt = 3; + + /** variant's type is float VT_R4 */ + public static final short VariantFloat = 4; + + /** variant's type is double VT_R8 */ + public static final short VariantDouble = 5; + + /** variant's type is currency VT_CY */ + public static final short VariantCurrency = 6; + + /** variant's type is date VT_DATE */ + public static final short VariantDate = 7; + + /** variant's type is string also known as VT_BSTR */ + public static final short VariantString = 8; + + /** variant's type is dispatch VT_DISPATCH */ + public static final short VariantDispatch = 9; + + /** variant's type is error VT_ERROR */ + public static final short VariantError = 10; + + /** variant's type is boolean VT_BOOL */ + public static final short VariantBoolean = 11; + + /** variant's type is variant it encapsulate another variant VT_VARIANT */ + public static final short VariantVariant = 12; + + /** variant's type is object VT_UNKNOWN */ + public static final short VariantObject = 13; + + /** variant's type is object VT_DECIMAL */ + public static final short VariantDecimal = 14; + + // VT_I1 = 16 + + /** variant's type is byte VT_UI1 */ + public static final short VariantByte = 17; + + // VT_UI2 = 18 + // VT_UI4 = 19 + + /** + * variant's type is 64 bit long integer VT_I8 - not yet implemented in + * Jacob because we have to decide what to do with Currency and because its + * only supported on XP and later. No win2k, NT or 2003 server. + */ + public static final short VariantLongInt = 20; + + // VT_UI8 = 21 + // VT_INT = 22 + // VT_UNIT = 23 + // VT_VOID = 24 + // VT_HRESULT = 25 + + /** + * This value is for reference only and is not to be used by any callers + */ + public static final short VariantPointer = 26; + + // VT_SAFEARRAY = 27 + // VT_CARRARY = 28 + // VT_USERDEFINED = 29 + + /** what is this? VT_TYPEMASK && VT_BSTR_BLOB */ + public static final short VariantTypeMask = 4095; + + /** variant's type is array VT_ARRAY */ + public static final short VariantArray = 8192; + + /** variant's type is a reference (to IDispatch?) VT_BYREF */ + public static final short VariantByref = 16384; + + /* + * Do the run time definition of DEFAULT and MISSING. Have to use static + * block because of the way the initialization is done via two calls instead + * of just a constructor for this type. + */ + static { + com.jacob.com.Variant vtMissing = new com.jacob.com.Variant(); + vtMissing.putVariantNoParam(); + DEFAULT = vtMissing; + VT_MISSING = vtMissing; + } + + /** + * Pointer to MS struct. + */ + int m_pVariant = 0; + + /** + * public constructor, initializes and sets type to VariantEmpty + */ + public Variant() { + this(null, false); + } + + /** + * Constructor that accepts a primitive rather than an object + * + * @param in + */ + public Variant(boolean in) { + this(new Boolean(in)); + } + + /** + * Constructor that accepts a primitive rather than an object + * + * @param in + */ + public Variant(byte in) { + this(new Byte(in)); + } + + /** + * Constructor that accepts a primitive rather than an object + * + * @param in + */ + public Variant(double in) { + this(new Double(in)); + } + + /** + * Constructor that accepts a primitive rather than an object + * + * @param in + */ + public Variant(float in) { + this(new Float(in)); + } + + /** + * Constructor that accepts a primitive rather than an object + * + * @param in + */ + public Variant(int in) { + this(new Integer(in)); + }; + + /** + * Constructor that accepts a primitive rather than an object + * + * @param in + */ + public Variant(long in) { + this(new Long(in)); + } + + /** + * Convenience constructor that calls the main one with a byRef value of + * false + * + * @param in + * object to be made into variant + */ + public Variant(Object in) { + this(in, false); + } + + /** + * Constructor that accepts the data object and information about whether + * this is by reference or not. It calls the JavaVariantConverter to + * actually push the data into the newly created Variant. + * + * @param pValueObject + * The value object that will pushed down into windows memory. A + * null object sets this to "empty" + * @param fByRef + */ + public Variant(Object pValueObject, boolean fByRef) { + init(); + VariantUtilities.populateVariant(this, pValueObject, fByRef); + } + + /** + * Constructor that accepts a primitive rather than an object + * + * @param in + */ + public Variant(short in) { + this(new Short(in)); + } + + /** + * Cover for native method so we can cover it. + *

    + * This cannot convert an object to a byRef. It can convert from byref to + * not byref + * + * @param in + * type to convert this variant too + * @return Variant returns this same object so folks can change when + * replacing calls toXXX() with changeType().getXXX() + */ + public Variant changeType(short in) { + changeVariantType(in); + return this; + } + + /** + * Converts variant to the passed in type by converting the underlying + * windows variant structure. private so folks use public java method + * + * @param in + * the desired resulting type + */ + private native void changeVariantType(short in); + + /** + * this returns null + * + * @return ?? comment says null? + */ + public native Object clone(); + + /** + * @deprecated No longer used + * @return null ! + */ + @Deprecated + public native Variant cloneIndirect(); + + /* + * (non-Javadoc) + * + * @see java.lang.Object#finalize() + */ + protected void finalize() { + safeRelease(); + } + + /** + * + * @return returns the value as a boolean, throws an exception if its not. + * @throws IllegalStateException + * if variant is not of the requested type + */ + public boolean getBoolean() { + if (this.getvt() == VariantBoolean) { + return getVariantBoolean(); + } else { + throw new IllegalStateException( + "getBoolean() only legal on Variants of type VariantBoolean, not " + + this.getvt()); + } + } + + /** + * public cover for native method + * + * @return the boolean from a booleanRef + * @throws IllegalStateException + * if variant is not of the requested type + */ + public boolean getBooleanRef() { + if ((this.getvt() & VariantBoolean) == VariantBoolean + && (this.getvt() & VariantByref) == VariantByref) { + return getVariantBooleanRef(); + } else { + throw new IllegalStateException( + "getBooleanRef() only legal on byRef Variants of type VariantBoolean, not " + + this.getvt()); + } + } + + /** + * + * @return returns the value as a boolean, throws an exception if its not. + * @throws IllegalStateException + * if variant is not of the requested type + */ + public byte getByte() { + if (this.getvt() == VariantByte) { + return getVariantByte(); + } else { + throw new IllegalStateException( + "getByte() only legal on Variants of type VariantByte, not " + + this.getvt()); + } + } + + /** + * public cover for native method + * + * @return the byte from a booleanRef + * @throws IllegalStateException + * if variant is not of the requested type + */ + public byte getByteRef() { + if ((this.getvt() & VariantByte) == VariantByte + && (this.getvt() & VariantByref) == VariantByref) { + return getVariantByteRef(); + } else { + throw new IllegalStateException( + "getByteRef() only legal on byRef Variants of type VariantByte, not " + + this.getvt()); + } + } + + /** + * MS Currency objects are 64 bit fixed point numbers with 15 digits to the + * left and 4 to the right of the decimal place. + * + * @return returns the currency value as a long, throws exception if not a + * currency type.. + * @throws IllegalStateException + * if variant is not of the requested type + */ + public Currency getCurrency() { + if (this.getvt() == VariantCurrency) { + return new Currency(getVariantCurrency()); + } else { + throw new IllegalStateException( + "getCurrency() only legal on Variants of type VariantCurrency, not " + + this.getvt()); + } + } + + /** + * MS Currency objects are 64 bit fixed point numbers with 15 digits to the + * left and 4 to the right of the decimal place. + * + * @return returns the currency value as a long, throws exception if not a + * currency type + * @throws IllegalStateException + * if variant is not of the requested type + */ + public Currency getCurrencyRef() { + if ((this.getvt() & VariantCurrency) == VariantCurrency + && (this.getvt() & VariantByref) == VariantByref) { + return new Currency(getVariantCurrencyRef()); + } else { + throw new IllegalStateException( + "getCurrencyRef() only legal on byRef Variants of type VariantCurrency, not " + + this.getvt()); + } + } + + /** + * @return double return the date (as a double) value held in this variant + * (fails on other types?) + * @throws IllegalStateException + * if variant is not of the requested type + */ + public double getDate() { + if (this.getvt() == VariantDate) { + return getVariantDate(); + } else { + throw new IllegalStateException( + "getDate() only legal on Variants of type VariantDate, not " + + this.getvt()); + } + } + + /** + * + * @return returns the date value as a double, throws exception if not a + * date type + * @throws IllegalStateException + * if variant is not of the requested type + */ + public double getDateRef() { + if ((this.getvt() & VariantDate) == VariantDate + && (this.getvt() & VariantByref) == VariantByref) { + return getVariantDateRef(); + } else { + throw new IllegalStateException( + "getDateRef() only legal on byRef Variants of type VariantDate, not " + + this.getvt()); + } + } + + /** + * return the BigDecimal value held in this variant (fails on other types) + * + * @return BigDecimal + * @throws IllegalStateException + * if variant is not of the requested type + */ + public BigDecimal getDecimal() { + if (this.getvt() == VariantDecimal) { + return (BigDecimal) (getVariantDec()); + } else { + throw new IllegalStateException( + "getDecimal() only legal on Variants of type VariantDecimal, not " + + this.getvt()); + } + } + + /** + * return the BigDecimal value held in this variant (fails on other types) + * + * @return BigDecimal + * @throws IllegalStateException + * if variant is not of the requested type + */ + public BigDecimal getDecimalRef() { + if ((this.getvt() & VariantDecimal) == VariantDecimal + && (this.getvt() & VariantByref) == VariantByref) { + return (BigDecimal) (getVariantDecRef()); + } else { + throw new IllegalStateException( + "getDecimalRef() only legal on byRef Variants of type VariantDecimal, not " + + this.getvt()); + } + } + + /** + * cover for {@link #toDispatch()} This method now matches other getXXX() + * methods. It throws an IllegalStateException if the object is not of type + * VariantDispatch + * + * @return this object as a dispatch + * @throws IllegalStateException + * if wrong variant type + */ + public Dispatch getDispatch() { + if ((this.getvt() & VariantDispatch) == VariantDispatch) { + return toDispatch(); + } else { + throw new IllegalStateException( + "getDispatch() only legal on Variants of type VariantDispatch, not " + + this.getvt()); + } + } + + /** + * Dispatch and dispatchRef are treated the same This is just a cover for + * toDispatch() with a flag check + * + * @return the results of toDispatch() + * @throws IllegalStateException + * if variant is not of the requested type + */ + public Dispatch getDispatchRef() { + if ((this.getvt() & VariantDispatch) == VariantDispatch + && (this.getvt() & VariantByref) == VariantByref) { + return toDispatch(); + } else { + throw new IllegalStateException( + "getDispatchRef() only legal on byRef Variants of type VariantDispatch, not " + + this.getvt()); + } + } + + /** + * @return double return the double value held in this variant (fails on + * other types?) + * @throws IllegalStateException + * if variant is not of the requested type + */ + public double getDouble() { + if (this.getvt() == VariantDouble) { + return getVariantDouble(); + } else { + throw new IllegalStateException( + "getDouble() only legal on Variants of type VariantDouble, not " + + this.getvt()); + } + } + + /** + * + * @return returns the double value, throws exception if not a Double type + * @throws IllegalStateException + * if variant is not of the requested type + */ + public double getDoubleRef() { + if ((this.getvt() & VariantDouble) == VariantDouble + && (this.getvt() & VariantByref) == VariantByref) { + return getVariantDoubleRef(); + } else { + throw new IllegalStateException( + "getDoubleRef() only legal on byRef Variants of type VariantDouble, not " + + this.getvt()); + } + } + + /** + * Pointless method that was put here so that putEmpty() has a get method. + * This would have returned null if the value was VT_EMPTY or if it wasn't + * so it would have always returned the same value. + * + * @deprecated method never did anything + */ + @Deprecated + public void getEmpty() { + } + + /** + * @return double return the error value held in this variant (fails on + * other types?) + * @throws IllegalStateException + * if variant is not of the requested type + */ + public int getError() { + if (this.getvt() == VariantError) { + return getVariantError(); + } else { + throw new IllegalStateException( + "getError() only legal on Variants of type VariantError, not " + + this.getvt()); + } + } + + /** + * + * @return returns the error value as an int, throws exception if not a + * Error type + * @throws IllegalStateException + * if variant is not of the requested type + */ + public int getErrorRef() { + if ((this.getvt() & VariantError) == VariantError + && (this.getvt() & VariantByref) == VariantByref) { + return getVariantErrorRef(); + } else { + throw new IllegalStateException( + "getErrorRef() only legal on byRef Variants of type VariantError, not " + + this.getvt()); + } + } + + /** + * @return returns the value as a float if the type is of type float + * @throws IllegalStateException + * if variant is not of the requested type + */ + public float getFloat() { + if (this.getvt() == VariantFloat) { + return getVariantFloat(); + } else { + throw new IllegalStateException( + "getFloat() only legal on Variants of type VariantFloat, not " + + this.getvt()); + } + } + + /** + * + * @return returns the float value, throws exception if not a Float type + * @throws IllegalStateException + * if variant is not of the requested type + */ + public float getFloatRef() { + if ((this.getvt() & VariantFloat) == VariantFloat + && (this.getvt() & VariantByref) == VariantByref) { + return getVariantFloatRef(); + } else { + throw new IllegalStateException( + "getFloatRef() only legal on byRef Variants of type VariantFloat, not " + + this.getvt()); + } + } + + /** + * return the int value held in this variant if it is an int or a short. + * Throws for other types. + * + * @return int contents of the windows memory + * @throws IllegalStateException + * if variant is not of the requested type + */ + public int getInt() { + if (this.getvt() == VariantInt) { + return getVariantInt(); + } else if (this.getvt() == VariantShort) { + return getVariantShort(); + } else { + throw new IllegalStateException( + "getInt() only legal on Variants of type VariantInt, not " + + this.getvt()); + } + } + + /** + * get the content of this variant as an int + * + * @return int + * @throws IllegalStateException + * if variant is not of the requested type + */ + public int getIntRef() { + if ((this.getvt() & VariantInt) == VariantInt + && (this.getvt() & VariantByref) == VariantByref) { + return getVariantIntRef(); + } else { + throw new IllegalStateException( + "getIntRef() only legal on byRef Variants of type VariantInt, not " + + this.getvt()); + } + } + + /** + * returns the windows time contained in this Variant to a Java Date. should + * return null if this is not a date Variant SF 959382 + * + * @return java.util.Date returns the date if this is a VariantDate != 0, + * null if it is a VariantDate == 0 and throws an + * IllegalStateException if this isn't a date. + * @throws IllegalStateException + * if variant is not of the requested type + */ + public Date getJavaDate() { + Date returnDate = null; + if (getvt() == VariantDate) { + double windowsDate = getDate(); + if (windowsDate != 0) { + returnDate = DateUtilities.convertWindowsTimeToDate(getDate()); + } + } else { + throw new IllegalStateException( + "getJavaDate() only legal on Variants of type VariantDate, not " + + this.getvt()); + } + return returnDate; + } + + /** + * returns the windows time contained in this Variant to a Java Date should + * return null if this is not a date reference Variant SF 959382 + * + * @return java.util.Date + */ + public Date getJavaDateRef() { + double windowsDate = getDateRef(); + if (windowsDate == 0) { + return null; + } else { + return DateUtilities.convertWindowsTimeToDate(windowsDate); + } + } + + /** + * 64 bit Longs only available on x64. 64 bit long support added 1.14 + * + * @return returns the value as a long, throws exception if not a Long + * type.. + * @throws IllegalStateException + * if variant is not of the requested type + */ + public long getLong() { + if (this.getvt() == VariantLongInt) { + return getVariantLong(); + } else { + throw new IllegalStateException( + "getLong() only legal on Variants of type VariantLongInt, not " + + this.getvt()); + } + } + + /** + * 64 bit Longs only available on x64. 64 bit long support added 1.14 + * + * @return returns the value as a long, throws exception if not a long type + * @throws IllegalStateException + * if variant is not of the requested type + */ + public long getLongRef() { + if ((this.getvt() & VariantLongInt) == VariantLongInt + && (this.getvt() & VariantByref) == VariantByref) { + return getVariantLongRef(); + } else { + throw new IllegalStateException( + "getLongRef() only legal on byRef Variants of type VariantLongInt, not " + + this.getvt()); + } + } + + /** + * This method would have returned null if the type was VT_NULL. But because + * we return null if the data is not of the right type, this method should + * have always returned null + * + * @deprecated method never did anything + */ + @Deprecated + public void getNull() { + } + + /** + * return the int value held in this variant (fails on other types?) + * + * @return int + * @throws IllegalStateException + * if variant is not of the requested type + */ + public short getShort() { + if (this.getvt() == VariantShort) { + return getVariantShort(); + } else { + throw new IllegalStateException( + "getShort() only legal on Variants of type VariantShort, not " + + this.getvt()); + } + } + + /** + * get the content of this variant as an int + * + * @return int + * @throws IllegalStateException + * if variant is not of the requested type + */ + public short getShortRef() { + if ((this.getvt() & VariantShort) == VariantShort + && (this.getvt() & VariantByref) == VariantByref) { + return getVariantShortRef(); + } else { + throw new IllegalStateException( + "getShortRef() only legal on byRef Variants of type VariantShort, not " + + this.getvt()); + } + } + + /** + * + * @return string contents of the variant. + * @throws IllegalStateException + * if this variant is not of type String + */ + public String getString() { + if (getvt() == Variant.VariantString) { + return getVariantString(); + } else { + throw new IllegalStateException( + "getString() only legal on Variants of type VariantString, not " + + this.getvt()); + } + } + + /** + * gets the content of the variant as a string ref + * + * @return String retrieved from the COM area. + * @throws IllegalStateException + * if variant is not of the requested type + */ + public String getStringRef() { + if ((this.getvt() & VariantString) == VariantString + && (this.getvt() & VariantByref) == VariantByref) { + return getVariantStringRef(); + } else { + throw new IllegalStateException( + "getStringRef() only legal on byRef Variants of type VariantString, not " + + this.getvt()); + } + } + + /** + * Used to get the value from a windows type of VT_VARIANT or a jacob + * Variant type of VariantVariant. Added 1.12 pre 6 - VT_VARIANT support is + * at an alpha level + * + * @return Object a java Object that represents the content of the enclosed + * Variant + */ + public Object getVariant() { + if ((this.getvt() & VariantVariant) == VariantVariant + && (this.getvt() & VariantByref) == VariantByref) { + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("About to call getVariantVariant()"); + } + Variant enclosedVariant = new Variant(); + int enclosedVariantMemory = getVariantVariant(); + enclosedVariant.m_pVariant = enclosedVariantMemory; + Object enclosedVariantAsJava = enclosedVariant.toJavaObject(); + // zero out the reference to the underlying windows memory so that + // it is still only owned in one place by one java object + // (this object of type VariantVariant) + // enclosedVariant.putEmpty(); // don't know if this would have had + // side effects + if (JacobObject.isDebugEnabled()) { + JacobObject + .debug("Zeroing out enclosed Variant's ref to windows memory"); + } + enclosedVariant.m_pVariant = 0; + return enclosedVariantAsJava; + } else { + throw new IllegalStateException( + "getVariant() only legal on Variants of type VariantVariant, not " + + this.getvt()); + } + } + + /** + * @deprecated superseded by SafeArray + * @return never returns anything + * @throws com.jacob.com.NotImplementedException + */ + @Deprecated + public Variant[] getVariantArray() { + throw new NotImplementedException("Not implemented"); + } + + /** + * @return the Variant Array that represents the data in the Variant + * @deprecated superseded by SafeArray + * @throws com.jacob.com.NotImplementedException + */ + @Deprecated + public Variant[] getVariantArrayRef() { + throw new NotImplementedException("Not implemented"); + } + + /** + * + * @return the value in this Variant as a boolean, null if not a boolean + */ + private native boolean getVariantBoolean(); + + private native boolean getVariantBooleanRef(); + + /** + * @return the value in this Variant as a byte, null if not a byte + */ + private native byte getVariantByte(); + + /** + * @return the value in this Variant as a byte, null if not a byte + */ + private native byte getVariantByteRef(); + + /** + * @return the value in this Variant as a long, null if not a long + */ + private native long getVariantCurrency(); + + /** + * @return the value in this Variant as a long, null if not a long + */ + private native long getVariantCurrencyRef(); + + /** + * @return double return the date (as a double) value held in this variant + * (fails on other types?) + */ + private native double getVariantDate(); + + /** + * get the content of this variant as a double representing a date + * + * @return double + */ + private native double getVariantDateRef(); + + /** + * @return the value in this Variant as a decimal, null if not a decimal + */ + private native Object getVariantDec(); + + /** + * @return the value in this Variant (byref) as a decimal, null if not a + * decimal + */ + private native Object getVariantDecRef(); + + /** + * @return double get the content of this variant as a double + */ + private native double getVariantDouble(); + + /** + * @return double get the content of this variant as a double + */ + private native double getVariantDoubleRef(); + + private native int getVariantError(); + + private native int getVariantErrorRef(); + + /** + * @return returns the value as a float if the type is of type float + */ + private native float getVariantFloat(); + + /** + * @return returns the value as a float if the type is of type float + */ + private native float getVariantFloatRef(); + + /** + * @return the int value held in this variant (fails on other types?) + */ + private native int getVariantInt(); + + /** + * @return the int value held in this variant (fails on other types?) + */ + private native int getVariantIntRef(); + + /** + * @return the value in this Variant as a long, null if not a long + */ + private native long getVariantLong(); + + /** + * @return the value in this Variant as a long, null if not a long + */ + private native long getVariantLongRef(); + + /** + * get the content of this variant as a short + * + * @return short + */ + private native short getVariantShort(); + + /** + * @return short the content of this variant as a short + */ + private native short getVariantShortRef(); + + /** + * Native method that actually extracts a string value from the variant + * + * @return + */ + private native String getVariantString(); + + /** + * @return String the content of this variant as a string + */ + private native String getVariantStringRef(); + + /** + * Returns the variant type via a native method call + * + * @return short one of the VT_xx types + */ + private native short getVariantType(); + + /** + * Returns the variant type via a native method call. Added 1.12 pre 6 - + * VT_VARIANT support is at an alpha level + * + * @return Variant one of the VT_Variant types + */ + private native int getVariantVariant(); + + /** + * Reports the type of the underlying Variant object + * + * @return returns the variant type as a short, one of the Variantxxx values + * defined as statics in this class. returns VariantNull if not + * initialized + * @throws IllegalStateException + * if there is no underlying windows data structure + */ + public short getvt() { + if (m_pVariant != 0) { + return getVariantType(); + } else { + throw new IllegalStateException("uninitialized Variant"); + } + } + + /** + * initializes the COM Variant and puts its reference in this instance + */ + protected native void init(); + + /** + * + * @return returns true if the variant is considered null + * @throws IllegalStateException + * if there is no underlying windows memory + */ + public boolean isNull() { + getvt(); + return isVariantConsideredNull(); + } + + /** + * is the variant null or empty or error or null dispatch + * + * @return true if it is null or false if not + */ + private native boolean isVariantConsideredNull(); + + /** + * sets the type to VT_ERROR and the error message to DISP_E_PARAMNOTFOIUND + * + * @deprecated replaced by putNoParam() + */ + @Deprecated + public void noParam() { + putNoParam(); + } + + /** + * returns true if the passed in Variant is a constant that should not be + * freed + * + * @param pVariant + * @return boolean that is true if Variant is a type of constant, VT_FALSE, + * VT_TRUE, VT_MISSING, DEFAULT + */ + protected boolean objectIsAConstant(Variant pVariant) { + if (pVariant == VT_FALSE || pVariant == VT_TRUE + || pVariant == VT_MISSING || pVariant == DEFAULT) { + return true; + } else { + return false; + } + + } + + /** + * puts a boolean into the variant and sets it's type + * + * @param in + * the new value + */ + public void putBoolean(boolean in) { + // verify we aren't released yet + getvt(); + putVariantBoolean(in); + } + + /** + * pushes a boolean into the variant by ref and sets the type of the variant + * to boolean + * + * @param in + */ + public void putBooleanRef(boolean in) { + // verify we aren't released yet + getvt(); + putVariantBooleanRef(in); + } + + /** + * pushes a byte into the varaint and sets the type + * + * @param in + */ + public void putByte(byte in) { + // verify we aren't released yet + getvt(); + putVariantByte(in); + }; + + /** + * @deprecated superseded by SafeArray + * @param in + * doesn't matter because this method does nothing + * @throws com.jacob.com.NotImplementedException + */ + @Deprecated + public void putByteArray(Object in) { + throw new NotImplementedException("Not implemented"); + } + + /** + * pushes a byte into the variant by ref and sets the type + * + * @param in + */ + public void putByteRef(byte in) { + // verify we aren't released yet + getvt(); + putVariantByteRef(in); + } + + /** + * @param in + * the object that would be wrapped by the Variant if this method + * was implemented + * @deprecated superseded by SafeArray + * @throws com.jacob.com.NotImplementedException + */ + @Deprecated + public void putCharArray(Object in) { + throw new NotImplementedException("Not implemented"); + } + + /** + * Puts a value in as a currency and sets the variant type. MS Currency + * objects are 64 bit fixed point numbers with 15 digits to the left and 4 + * to the right of the decimal place. + * + * @param in + * the long that will be put into the 64 bit currency object. + */ + public void putCurrency(Currency in) { + // verify we aren't released yet + getvt(); + putVariantCurrency(in.longValue()); + } + + /** + * Pushes a long into the variant as currency and sets the type. MS Currency + * objects are 64 bit fixed point numbers with 15 digits to the left and 4 + * to the right of the decimal place. + * + * @param in + * the long that will be put into the 64 bit currency object + */ + public void putCurrencyRef(Currency in) { + // verify we aren't released yet + getvt(); + putVariantCurrencyRef(in.longValue()); + } + + /** + * converts a java date to a windows time and calls putDate(double) SF + * 959382 + * + * @param inDate + * a Java date to be converted + * @throws IllegalArgumentException + * if inDate = null + */ + public void putDate(Date inDate) { + if (inDate == null) { + throw new IllegalArgumentException( + "Cannot put null in as windows date"); + // do nothing + } else { + putDate(DateUtilities.convertDateToWindowsTime(inDate)); + } + } + + /** + * puts a windows date double into the variant and sets the type + * + * @param in + */ + public void putDate(double in) { + // verify we aren't released yet + getvt(); + putVariantDate(in); + } + + /** + * converts a java date to a windows time and calls putDateRef(double) SF + * 959382 + * + * @param inDate + * a Java date to be converted + * @throws IllegalArgumentException + * if inDate = null + */ + public void putDateRef(Date inDate) { + if (inDate == null) { + throw new IllegalArgumentException( + "Cannot put null in as windows date"); + // do nothing + } else { + putDateRef(DateUtilities.convertDateToWindowsTime(inDate)); + } + } + + /** + * set the content of this variant to a date (VT_DATE|VT_BYREF) + * + * @param in + */ + public void putDateRef(double in) { + // verify we aren't released + getvt(); + putVariantDateRef(in); + } + + /** + * This actual does all the validating and massaging of the BigDecimalValues + * when converting them to MS Decimal types + * + * @param in + * number to be made into VT_DECIMAL + * @param byRef + * store by reference or not + * @param roundingBehavior + * one of the BigDecimal ROUND_xxx methods. Any method other than + * ROUND_UNECESSARY means that the value will be rounded to fit + */ + private void putDecimal(BigDecimal in, boolean byRef) { + // verify we aren't released + getvt(); + // first validate the min and max + VariantUtilities.validateDecimalMinMax(in); + BigInteger allWordBigInt; + allWordBigInt = in.unscaledValue(); + // Assume any required rounding has been done. + VariantUtilities.validateDecimalScaleAndBits(in); + // finally we can do what we actually came here to do + int sign = in.signum(); + // VT_DECIMAL always has positive value with just the sign + // flipped + if (in.signum() < 0) { + in = in.negate(); + } + // ugh, reusing allWordBigInt but now should always be positive + // and any round is applied + allWordBigInt = in.unscaledValue(); + byte scale = (byte) in.scale(); + int lowWord = allWordBigInt.intValue(); + BigInteger middleWordBigInt = allWordBigInt.shiftRight(32); + int middleWord = middleWordBigInt.intValue(); + BigInteger highWordBigInt = allWordBigInt.shiftRight(64); + int highWord = highWordBigInt.intValue(); + if (byRef) { + putVariantDecRef(sign, scale, lowWord, middleWord, highWord); + } else { + putVariantDec(sign, scale, lowWord, middleWord, highWord); + } + } + + /** + * EXPERIMENTAL 1.14 feature to support rounded decimals. + *

    + * Set the value of this variant and set the type. This may throw exceptions + * more often than the caller expects because most callers don't manage the + * scale of their BigDecimal objects. + *

    + * This default set method throws exceptions if precision or size is out of + * bounds + *

    + * There are 12 bytes available for the integer number. + *

    + * There is 1 byte for the scale. + * + * @param in + * the BigDecimal that will be converted to VT_DECIMAL + * @throws IllegalArgumentException + * if the scale is > 28, the maximum for VT_DECIMAL or if there + * are more than 12 bytes worth the digits + */ + public void putDecimal(BigDecimal in) { + putDecimal(in, false); + } + + /** + * Set the value of this variant and set the type. This may throw exceptions + * more often than the caller expects because most callers don't manage the + * scale of their BigDecimal objects. + *

    + * This default set method throws exceptions if precision or size is out of + * bounds + *

    + * There are 12 bytes available for the integer number. + *

    + * There is 1 byte for the scale. + * + * @param in + * the BigDecimal that will be converted to VT_DECIMAL + * @throws IllegalArgumentException + * if the scale is > 28, the maximum for VT_DECIMAL or if there + * are more than 12 bytes worth the digits + */ + public void putDecimalRef(BigDecimal in) { + putDecimal(in, true); + } + + /** + * This acts a cover for putVariant Dispatch. + * + * @param in + * the Dispatch we're putting down in the COM variant space. + */ + public void putDispatch(Dispatch in) { + putVariantDispatch(in); + } + + /** + * Dispatch and dispatchRef are treated the same This is a cover for + * putVariantDispatch(). putDispatch and putDispatchRef are treated the same + * because no one has written the COM code for putDispatchRef. + * + * @param in + * the Dispatch we're putting down in the COM variant space. + */ + public void putDispatchRef(Dispatch in) { + putVariantDispatch(in); + } + + /** + * wraps this Variant around the passed in double. + * + * @param in + */ + public void putDouble(double in) { + // verify we aren't released yet + getvt(); + putVariantDouble(in); + } + + /** + * set the content of this variant to a double (VT_R8|VT_BYREF) + * + * @param in + */ + public void putDoubleRef(double in) { + // verify we aren't released + getvt(); + putVariantDoubleRef(in); + } + + /** + * sets the type to VariantEmpty + * + */ + public void putEmpty() { + // verify we aren't released yet + getvt(); + putVariantEmpty(); + } + + /** + * puts an error code (I think) into the variant and sets the type + * + * @param in + */ + public void putError(int in) { + // verify we aren't released yet + getvt(); + putVariantError(in); + } + + /** + * pushes an error code into the variant by ref and sets the type + * + * @param in + */ + public void putErrorRef(int in) { + // verify we aren't released yet + getvt(); + putVariantErrorRef(in); + } + + /** + * fills the Variant with a float and sets the type to float + * + * @param in + */ + public void putFloat(float in) { + // verify we haven't been released yet + getvt(); + putVariantFloat(in); + } + + /** + * pushes a float into the variant and sets the type + * + * @param in + */ + public void putFloatRef(float in) { + // verify we aren't released yet + getvt(); + putVariantFloatRef(in); + } + + /** + * set the value of this variant and set the type + * + * @param in + */ + public void putInt(int in) { + // verify we aren't released yet + getvt(); + putVariantInt(in); + } + + /** + * set the content of this variant to an int (VT_I4|VT_BYREF) + * + * @param in + */ + public void putIntRef(int in) { + // verify we aren't released + getvt(); + putVariantIntRef(in); + } + + /** + * Puts a 64 bit Java Long into a 64 bit Variant Long. Only works on x64 + * systems otherwise throws an error. 64 bit long support added 1.14 + * + * @param in + * the long that will be put into the 64 bit Long object. + */ + public void putLong(long in) { + // verify we aren't released yet + getvt(); + putVariantLong(in); + } + + /** + * Puts a 64 bit Java Long into a 64 bit Variant Long. Only works on x64 + * systems otherwise throws an error. 64 bit long support added 1.14 + * + * @param in + * the long that will be put into the 64 bit Long object. + */ + public void putLongRef(long in) { + // verify we aren't released yet + getvt(); + putVariantLongRef(in); + } + + /** + * sets the type to VT_ERROR and the error message to DISP_E_PARAMNOTFOIUND + */ + public void putNoParam() { + // verify we aren't released yet + getvt(); + putVariantNoParam(); + } + + /** + * Sets the type to VariantDispatch and sets the value to null Equivalent to + * VB's nothing + */ + public void putNothing() { + // verify we aren't released yet + getvt(); + putVariantNothing(); + } + + /** + * Set this Variant's type to VT_NULL (the VB equivalent of NULL) + */ + public void putNull() { + // verify we aren't released yet + getvt(); + putVariantNull(); + } + + /** + * Puts an object into the Variant -- converts to Dispatch. Acts as a cover + * for putVariantDispatch(); This primarily exists to support jacobgen. This + * should be deprecated. + * + * @param in + * the object we are putting into the Variant, assumes a + * @see Variant#putDispatch(Dispatch) + * @deprecated should use putDispatch() + */ + @Deprecated + public void putObject(Object in) { + // this should verify in instanceof Dispatch + putVariantDispatch(in); + } + + /** + * Just a cover for putObject(). We shouldn't accept any old random object. + * This has been left in to support jacobgen. This should be deprecated. + * + * @param in + * @deprecated + */ + @Deprecated + public void putObjectRef(Object in) { + putObject(in); + } + + /** + * have no idea... + * + * @param in + */ + public void putSafeArray(SafeArray in) { + // verify we haven't been released yet + getvt(); + putVariantSafeArray(in); + } + + /** + * have no idea... + * + * @param in + */ + public void putSafeArrayRef(SafeArray in) { + // verify we haven't been released yet + getvt(); + putVariantSafeArrayRef(in); + } + + /** + * set the content of this variant to a short (VT_I2) + * + * @param in + */ + public void putShort(short in) { + // verify we aren't released + getvt(); + putVariantShort(in); + } + + /** + * set the content of this variant to a short (VT_I2|VT_BYREF) + * + * @param in + */ + public void putShortRef(short in) { + // verify we aren't released + getvt(); + putVariantShortRef(in); + } + + /** + * put a string into the variant and set its type + * + * @param in + */ + public void putString(String in) { + // verify we aren't released yet + getvt(); + putVariantString(in); + } + + /** + * set the content of this variant to a string (VT_BSTR|VT_BYREF) + * + * @param in + */ + public void putStringRef(String in) { + // verify we aren't released + getvt(); + putVariantStringRef(in); + } + + /** + * Puts a variant into this variant making it type VT_VARIANT. Added 1.12 + * pre 6 + * + * @param objectToBeWrapped + * A object that is to be referenced by this variant. If + * objectToBeWrapped is already of type Variant, then it is used. + * If objectToBeWrapped is not Variant then + * new Variant(objectToBeWrapped) is called and + * the result is passed into the com layer + * @throws IllegalArgumentException + * if inVariant = null or if inVariant is a Varint + */ + public void putVariant(Object objectToBeWrapped) { + if (objectToBeWrapped == null) { + throw new IllegalArgumentException( + "Cannot put null in as a variant"); + } else if (objectToBeWrapped instanceof Variant) { + throw new IllegalArgumentException( + "Cannot putVariant() only accepts non jacob objects."); + } else { + Variant inVariant = new Variant(objectToBeWrapped); + putVariantVariant(inVariant); + // This could be done in Variant.cpp + if (JacobObject.isDebugEnabled()) { + JacobObject + .debug("Zeroing out enclosed Variant's ref to windows memory"); + } + inVariant.m_pVariant = 0; + } + } + + /** + * @deprecated superseded by SafeArray + * @param in + * doesn't matter because this method does nothing + * @throws com.jacob.com.NotImplementedException + */ + @Deprecated + public void putVariantArray(Variant[] in) { + throw new NotImplementedException("Not implemented"); + } + + /** + * @param in + * the thing that would be come an array if this method was + * implemented + * @deprecated superseded by SafeArray + * @throws com.jacob.com.NotImplementedException + */ + @Deprecated + public void putVariantArrayRef(Variant[] in) { + throw new NotImplementedException("Not implemented"); + } + + /** + * puts a boolean into the variant and sets it's type + * + * @param in + * the new value + */ + private native void putVariantBoolean(boolean in); + + /** + * puts a boolean into the variant and sets it's type + * + * @param in + * the new value + */ + private native void putVariantBooleanRef(boolean in); + + /** + * puts a byte into the variant and sets it's type + * + * @param in + * the new value + */ + private native void putVariantByte(byte in); + + /** + * puts a byte into the variant and sets it's type + * + * @param in + * the new value + */ + private native void putVariantByteRef(byte in); + + /** + * puts a Currency into the variant and sets it's type + * + * @param in + * the new value + */ + private native void putVariantCurrency(long in); + + /** + * puts a Currency into the variant and sets it's type + * + * @param in + * the new value + */ + private native void putVariantCurrencyRef(long in); + + /** + * set the value of this variant + * + * @param in + */ + private native void putVariantDate(double in); + + /** + * set the content of this variant to a date (VT_DATE|VT_BYREF) + * + * @param in + */ + private native void putVariantDateRef(double in); + + /** + * private JNI method called by putDecimal + * + * @param signum + * sign + * @param scale + * BigDecimal's scale + * @param lo + * low 32 bits + * @param mid + * middle 32 bits + * @param hi + * high 32 bits + */ + private native void putVariantDec(int signum, byte scale, int lo, int mid, + int hi); + + /** + * private JNI method called by putDecimalRef + * + * @param signum + * sign + * @param scale + * BigDecimal's scale + * @param lo + * low 32 bits + * @param mid + * middle 32 bits + * @param hi + * high 32 bits + */ + private native void putVariantDecRef(int signum, byte scale, int lo, + int mid, int hi); + + /** + * the JNI implementation for putDispatch() so that we can screen the + * incoming dispatches in putDispatch() before this is invoked + * + * @param in + * should be a dispatch object + */ + private native void putVariantDispatch(Object in); + + private native void putVariantDouble(double in); + + /** + * set the content of this variant to a double (VT_R8|VT_BYREF) + * + * @param in + */ + private native void putVariantDoubleRef(double in); + + /** + * Sets the type to VariantEmpty. No values needed + */ + private native void putVariantEmpty(); + + private native void putVariantError(int in); + + private native void putVariantErrorRef(int in); + + /** + * fills the Variant with a float and sets the type to float + * + * @param in + */ + private native void putVariantFloat(float in); + + private native void putVariantFloatRef(float in); + + /** + * set the value of this variant and set the type + * + * @param in + */ + private native void putVariantInt(int in); + + /** + * set the content of this variant to an int (VT_I4|VT_BYREF) + * + * @param in + */ + private native void putVariantIntRef(int in); + + private native void putVariantLong(long in); + + private native void putVariantLongRef(long in); + + /** + * sets the type to VT_ERROR and the error message to DISP_E_PARAMNOTFOIUND + */ + private native void putVariantNoParam(); + + /** + * Sets the type to VariantDispatch and sets the value to null Equivalent to + * VB's nothing + */ + private native void putVariantNothing(); + + /** + * Set this Variant's type to VT_NULL (the VB equivalent of NULL) + */ + private native void putVariantNull(); + + private native void putVariantSafeArray(SafeArray in); + + private native void putVariantSafeArrayRef(SafeArray in); + + /** + * set the content of this variant to a short (VT_I2) + * + * @param in + */ + private native void putVariantShort(short in); + + /** + * set the content of this variant to a short (VT_I2|VT_BYREF) + * + * @param in + */ + private native void putVariantShortRef(short in); + + private native void putVariantString(String in); + + /** + * set the content of this variant to a string (VT_BSTR|VT_BYREF) + * + * @param in + */ + private native void putVariantStringRef(String in); + + /** + * All VariantVariant type variants are BYREF. + * + * Set the content of this variant to a string (VT_VARIANT|VT_BYREF). + * + * Added 1.12 pre 6 - VT_VARIANT support is at an alpha level + * + * @param in + * variant to be wrapped + * + */ + private native void putVariantVariant(Variant in); + + /** + * now private so only this object can access was: call this to explicitly + * release the com object before gc + * + */ + private native void release(); + + /** + * This will release the "C" memory for the Variant unless this Variant is + * one of the constants in which case we don't want to release the memory. + *

    + * + * @see com.jacob.com.JacobObject#safeRelease() + */ + public void safeRelease() { + // The well known constants should not be released. + // Unfortunately this doesn't fix any other classes that are + // keeping constants around in their static ivars. + // those will still be busted. + // + // The only inconsistency here is that we leak + // when this class is unloaded because we won't + // free the memory even if the constants are being + // finalized. this is not a big deal at all. + // another way around this would be to create the constants + // in their own thread so that they would never be released + if (!objectIsAConstant(this)) { + super.safeRelease(); + if (m_pVariant != 0) { + release(); + m_pVariant = 0; + } else { + // looks like a double release + // this should almost always happen due to gc + // after someone has called ComThread.Release + if (isDebugEnabled()) { + debug("Variant: " + this.hashCode() + " double release"); + // Throwable x = new Throwable(); + // x.printStackTrace(); + } + } + } else { + if (isDebugEnabled()) { + debug("Variant: " + this.hashCode() + + " don't want to release a constant"); + } + } + } + + /** + * this is supposed to cause the underlying variant object struct to be + * rebuilt from a previously serialized byte array. + * + * @param ba + */ + protected native void SerializationReadFromBytes(byte[] ba); + + /** + * this is supposed to create a byte array that represents the underlying + * variant object structure + */ + protected native byte[] SerializationWriteToBytes(); + + /** + * @deprecated should be replaced by changeType() followed by getBoolean() + * @return the value of this variant as boolean (after possible conversion) + */ + @Deprecated + public boolean toBoolean() { + changeType(Variant.VariantBoolean); + return getBoolean(); + } + + /** + * attempts to return the content of this variant as a double (after + * possible conversion) + * + * @deprecated should be replaced by changeType() followed by getByte() + * @return byte + */ + @Deprecated + public byte toByte() { + changeType(Variant.VariantByte); + return getByte(); + } + + /** + * @deprecated superseded by SafeArray + * @return nothing because this method is not implemented + * @throws com.jacob.com.NotImplementedException + */ + @Deprecated + public Object toByteArray() { + throw new NotImplementedException("Not implemented"); + } + + /** + * @deprecated superseded by SafeArray + * @return never returns anything + * @throws com.jacob.com.NotImplementedException + */ + @Deprecated + public Object toCharArray() { + throw new NotImplementedException("Not implemented"); + } + + /** + * @deprecated should be replaced by changeType() followed by getCurrency + * @return the content of this variant as a long representing a monetary + * amount + */ + @Deprecated + public Currency toCurrency() { + changeType(Variant.VariantCurrency); + return getCurrency(); + } + + /** + * @deprecated should use changeType() followed by getDate() + * @return the value of this variant as a date (after possible conversion) + */ + @Deprecated + public double toDate() { + changeType(VariantDate); + return getDate(); + } + + /** + * @return the content of this variant as a Dispatch object (after possible + * conversion) + */ + public Dispatch toDispatch() { + // now make the native call + return toVariantDispatch(); + } + + /** + * @deprecated should call changeType() then getDouble() + * @return the content of this variant as a double (after possible + * conversion) + */ + @Deprecated + public double toDouble() { + changeType(Variant.VariantDouble); + return getDouble(); + } + + /** @return the value of this variant as an enumeration (java style) */ + public native EnumVariant toEnumVariant(); + + /** + * converts to an error type and returns the error + * + * @deprecated should use changeType() followed by getError() + * @return the error as an int (after conversion) + */ + @Deprecated + public int toError() { + changeType(Variant.VariantError); + return getError(); + } + + /** + * attempts to return the contents of this variant as a float (after + * possible conversion) + * + * @deprecated should use changeType() and getFloat() instead + * @return float + */ + @Deprecated + public float toFloat() { + changeType(Variant.VariantFloat); + return getFloat(); + } + + /** + * @deprecated should use changeType() followed by getInt() + * @return the value of this variant as an int (after possible conversion) + */ + @Deprecated + public int toInt() { + changeType(VariantInt); + return getInt(); + } + + /** + * Returns the windows time contained in this Variant as a Java Date + * converts to a date like many of the other toXXX() methods SF 959382. + *

    + * This method added 12/2005 for possible use by jacobgen instead of its + * conversion code + *

    + * This does not convert the data + * + * @deprecated callers should use getDate() + * @return java.util.Date version of this variant if it is a date, otherwise + * null + * + */ + @Deprecated + public Date toJavaDate() { + changeType(Variant.VariantDate); + return getJavaDate(); + } + + /** + * Convert a JACOB Variant value to a Java object (type conversions). + * provided in Sourceforge feature request 959381. See + * JavaVariantConverter..convertVariantTJavaObject(Variant) for more + * information. + * + * @return Corresponding Java object of the type matching the Variant type. + * @throws IllegalStateException + * if no underlying windows data structure + * @throws NotImplementedException + * if unsupported conversion is requested + * @throws JacobException + * if the calculated result was a JacobObject usually as a + * result of error + */ + public Object toJavaObject() throws JacobException { + return VariantUtilities.variantToObject(this); + } + + /** + * Acts a a cover for toDispatch. This primarily exists to support jacobgen. + * + * @deprecated this is a cover for toDispatch(); + * @return Object returned by toDispatch() + * @see Variant#toDispatch() instead + */ + @Deprecated + public Object toObject() { + return toDispatch(); + } + + /** + * By default toSafeArray makes a deep copy due to the fact that this + * Variant owns the embedded SafeArray and will destroy it when it gc's + * calls toSafeArray(true). + * + * @return the object converted to a SafeArray + */ + public SafeArray toSafeArray() { + // verify we haven't been released yet + getvt(); + return toSafeArray(true); + } + + /** + * This lets folk turn into a safe array without a deep copy. Should this + * API be public? + * + * @param deepCopy + * @return SafeArray constructed + */ + public SafeArray toSafeArray(boolean deepCopy) { + // verify we haven't been released yet + getvt(); + return toVariantSafeArray(deepCopy); + } + + /** + * I don't know what this is. Is it some legacy (pre 1.8) thing? + * + * @deprecated + * @return this object as a dispatch object by calling toDispatch() + */ + @Deprecated + public Object toScriptObject() { + return toDispatch(); + } + + /** + * attempts to return the contents of this Variant as a short (after + * possible conversion) + * + * @deprecated callers should use changeType() followed by getShort() + * @return short + */ + @Deprecated + public short toShort() { + this.changeType(Variant.VariantShort); + return getShort(); + } + + /** + * This method now correctly implements java toString() semantics Attempts + * to return the content of this variant as a string + *

      + *
    • "not initialized" if not initialized + *
    • "null" if VariantEmpty, + *
    • "null" if VariantError + *
    • "null" if VariantNull + *
    • the value if we know how to describe one of that type + *
    • three question marks if can't convert + * + * @return String value conversion, + * @throws IllegalStateException + * if there is no underlying windows data structure + */ + public String toString() { + try { + // see if we are in a legal state + getvt(); + } catch (IllegalStateException ise) { + return ""; + } + if (getvt() == VariantEmpty || getvt() == VariantError + || getvt() == VariantNull) { + return "null"; + } + if (getvt() == VariantString) { + return getString(); + } + try { + Object foo = toJavaObject(); + // rely on java objects to do the right thing + return foo.toString(); + } catch (NotImplementedException nie) { + // some types do not generate a good description yet + return "Description not available for type: " + getvt(); + } + } + + /** + * Exists to support jacobgen. This would be deprecated if it weren't for + * jacobgen + * + * @deprecated superseded by "this" + * @return this same object + */ + @Deprecated + public Variant toVariant() { + return this; + } + + /** + * @deprecated superseded by SafeArray + * @return nothing because this method is not implemented + * @throws com.jacob.com.NotImplementedException + */ + @Deprecated + public Variant[] toVariantArray() { + throw new NotImplementedException("Not implemented"); + } + + /** + * native method used by toDispatch() + * + * @return + */ + private native Dispatch toVariantDispatch(); + + private native SafeArray toVariantSafeArray(boolean deepCopy); + + /* + * ===================================================================== + * + * + * ===================================================================== + */ + + /** + * Clear the content of this variant + */ + public native void VariantClear(); } \ No newline at end of file diff --git a/src/main/java/com/jacob/com/VariantUtilities.java b/src/main/java/com/jacob/com/VariantUtilities.java index a11baf6..9465dad 100644 --- a/src/main/java/com/jacob/com/VariantUtilities.java +++ b/src/main/java/com/jacob/com/VariantUtilities.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /** * @@ -51,485 +51,485 @@ import java.util.Date; * A utility class used to convert between Java objects and Variants */ public final class VariantUtilities { - private VariantUtilities() { - // utility class with only static methods don't need constructors - } + private VariantUtilities() { + // utility class with only static methods don't need constructors + } - /** - * Populates a variant object from a java object. This method attempts to - * figure out the appropriate Variant type - * - * @param targetVariant - * @param pValueObject - * @param fByRef - */ - protected static void populateVariant(Variant targetVariant, - Object pValueObject, boolean fByRef) { - if (pValueObject == null) { - targetVariant.putEmpty(); - } else if (pValueObject instanceof Integer) { - if (fByRef) { - targetVariant.putIntRef(((Integer) pValueObject).intValue()); - } else { - targetVariant.putInt(((Integer) pValueObject).intValue()); - } - } else if (pValueObject instanceof Short) { - if (fByRef) { - targetVariant.putShortRef(((Short) pValueObject).shortValue()); - } else { - targetVariant.putShort(((Short) pValueObject).shortValue()); - } - } else if (pValueObject instanceof String) { - if (fByRef) { - targetVariant.putStringRef((String) pValueObject); - } else { - targetVariant.putString((String) pValueObject); - } - } else if (pValueObject instanceof Boolean) { - if (fByRef) { - targetVariant.putBooleanRef(((Boolean) pValueObject) - .booleanValue()); - } else { - targetVariant.putBoolean(((Boolean) pValueObject) - .booleanValue()); - } - } else if (pValueObject instanceof Double) { - if (fByRef) { - targetVariant.putDoubleRef(((Double) pValueObject) - .doubleValue()); - } else { - targetVariant.putDouble(((Double) pValueObject).doubleValue()); - } - } else if (pValueObject instanceof Float) { - if (fByRef) { - targetVariant.putFloatRef(((Float) pValueObject).floatValue()); - } else { - targetVariant.putFloat(((Float) pValueObject).floatValue()); - } - } else if (pValueObject instanceof BigDecimal) { - if (fByRef) { - targetVariant.putDecimalRef(((BigDecimal) pValueObject)); - } else { - targetVariant.putDecimal(((BigDecimal) pValueObject)); - } - } else if (pValueObject instanceof Byte) { - if (fByRef) { - targetVariant.putByteRef(((Byte) pValueObject).byteValue()); - } else { - targetVariant.putByte(((Byte) pValueObject).byteValue()); - } - } else if (pValueObject instanceof Date) { - if (fByRef) { - targetVariant.putDateRef((Date) pValueObject); - } else { - targetVariant.putDate((Date) pValueObject); - } - } else if (pValueObject instanceof Long) { - if (fByRef) { - targetVariant.putLongRef(((Long) pValueObject).longValue()); - } else { - targetVariant.putLong(((Long) pValueObject).longValue()); - } - } else if (pValueObject instanceof Currency) { - if (fByRef) { - targetVariant.putCurrencyRef(((Currency) pValueObject)); - } else { - targetVariant.putCurrency(((Currency) pValueObject)); - } - } else if (pValueObject instanceof SafeArray) { - if (fByRef) { - targetVariant.putSafeArrayRef((SafeArray) pValueObject); - } else { - targetVariant.putSafeArray((SafeArray) pValueObject); - } - } else if (pValueObject instanceof Dispatch) { - if (fByRef) { - targetVariant.putDispatchRef((Dispatch) pValueObject); - } else { - targetVariant.putDispatch((Dispatch) pValueObject); - } - } else if (pValueObject instanceof Variant) { - // newly added 1.12-pre6 to support VT_VARIANT - targetVariant.putVariant(pValueObject); - } else { - // sourceforge patch 2171967 - // used to rely on coercion but sometimes crashed VM - throw new NotImplementedException( - "populateVariant() not implemented for " - + pValueObject.getClass()); - } - } + /** + * Populates a variant object from a java object. This method attempts to + * figure out the appropriate Variant type + * + * @param targetVariant + * @param pValueObject + * @param fByRef + */ + protected static void populateVariant(Variant targetVariant, + Object pValueObject, boolean fByRef) { + if (pValueObject == null) { + targetVariant.putEmpty(); + } else if (pValueObject instanceof Integer) { + if (fByRef) { + targetVariant.putIntRef(((Integer) pValueObject).intValue()); + } else { + targetVariant.putInt(((Integer) pValueObject).intValue()); + } + } else if (pValueObject instanceof Short) { + if (fByRef) { + targetVariant.putShortRef(((Short) pValueObject).shortValue()); + } else { + targetVariant.putShort(((Short) pValueObject).shortValue()); + } + } else if (pValueObject instanceof String) { + if (fByRef) { + targetVariant.putStringRef((String) pValueObject); + } else { + targetVariant.putString((String) pValueObject); + } + } else if (pValueObject instanceof Boolean) { + if (fByRef) { + targetVariant.putBooleanRef(((Boolean) pValueObject) + .booleanValue()); + } else { + targetVariant.putBoolean(((Boolean) pValueObject) + .booleanValue()); + } + } else if (pValueObject instanceof Double) { + if (fByRef) { + targetVariant.putDoubleRef(((Double) pValueObject) + .doubleValue()); + } else { + targetVariant.putDouble(((Double) pValueObject).doubleValue()); + } + } else if (pValueObject instanceof Float) { + if (fByRef) { + targetVariant.putFloatRef(((Float) pValueObject).floatValue()); + } else { + targetVariant.putFloat(((Float) pValueObject).floatValue()); + } + } else if (pValueObject instanceof BigDecimal) { + if (fByRef) { + targetVariant.putDecimalRef(((BigDecimal) pValueObject)); + } else { + targetVariant.putDecimal(((BigDecimal) pValueObject)); + } + } else if (pValueObject instanceof Byte) { + if (fByRef) { + targetVariant.putByteRef(((Byte) pValueObject).byteValue()); + } else { + targetVariant.putByte(((Byte) pValueObject).byteValue()); + } + } else if (pValueObject instanceof Date) { + if (fByRef) { + targetVariant.putDateRef((Date) pValueObject); + } else { + targetVariant.putDate((Date) pValueObject); + } + } else if (pValueObject instanceof Long) { + if (fByRef) { + targetVariant.putLongRef(((Long) pValueObject).longValue()); + } else { + targetVariant.putLong(((Long) pValueObject).longValue()); + } + } else if (pValueObject instanceof Currency) { + if (fByRef) { + targetVariant.putCurrencyRef(((Currency) pValueObject)); + } else { + targetVariant.putCurrency(((Currency) pValueObject)); + } + } else if (pValueObject instanceof SafeArray) { + if (fByRef) { + targetVariant.putSafeArrayRef((SafeArray) pValueObject); + } else { + targetVariant.putSafeArray((SafeArray) pValueObject); + } + } else if (pValueObject instanceof Dispatch) { + if (fByRef) { + targetVariant.putDispatchRef((Dispatch) pValueObject); + } else { + targetVariant.putDispatch((Dispatch) pValueObject); + } + } else if (pValueObject instanceof Variant) { + // newly added 1.12-pre6 to support VT_VARIANT + targetVariant.putVariant(pValueObject); + } else { + // sourceforge patch 2171967 + // used to rely on coercion but sometimes crashed VM + throw new NotImplementedException( + "populateVariant() not implemented for " + + pValueObject.getClass()); + } + } - /** - * Map arguments based on msdn documentation. This method relies on the - * variant constructor except for arrays. - * - * @param objectToBeMadeIntoVariant - * @return Variant that represents the object - */ - protected static Variant objectToVariant(Object objectToBeMadeIntoVariant) { - if (objectToBeMadeIntoVariant == null) { - return new Variant(); - } else if (objectToBeMadeIntoVariant instanceof Variant) { - // if a variant was passed in then be a slacker and just return it - return (Variant) objectToBeMadeIntoVariant; - } else if (objectToBeMadeIntoVariant.getClass().isArray()) { - // automatically convert arrays using reflection - // handle it differently based on the type of array - // added primitive support sourceforge 2762275 - SafeArray sa = null; - int len1 = Array.getLength(objectToBeMadeIntoVariant); - Class componentType = objectToBeMadeIntoVariant.getClass() - .getComponentType(); + /** + * Map arguments based on msdn documentation. This method relies on the + * variant constructor except for arrays. + * + * @param objectToBeMadeIntoVariant + * @return Variant that represents the object + */ + protected static Variant objectToVariant(Object objectToBeMadeIntoVariant) { + if (objectToBeMadeIntoVariant == null) { + return new Variant(); + } else if (objectToBeMadeIntoVariant instanceof Variant) { + // if a variant was passed in then be a slacker and just return it + return (Variant) objectToBeMadeIntoVariant; + } else if (objectToBeMadeIntoVariant.getClass().isArray()) { + // automatically convert arrays using reflection + // handle it differently based on the type of array + // added primitive support sourceforge 2762275 + SafeArray sa = null; + int len1 = Array.getLength(objectToBeMadeIntoVariant); + Class componentType = objectToBeMadeIntoVariant.getClass() + .getComponentType(); - if (componentType.isArray()) { // array of arrays - int max = 0; - for (int i = 0; i < len1; i++) { - Object e1 = Array.get(objectToBeMadeIntoVariant, i); - int len2 = Array.getLength(e1); - if (max < len2) { - max = len2; - } - } - sa = new SafeArray(Variant.VariantVariant, len1, max); - for (int i = 0; i < len1; i++) { - Object e1 = Array.get(objectToBeMadeIntoVariant, i); - for (int j = 0; j < Array.getLength(e1); j++) { - sa.setVariant(i, j, objectToVariant(Array.get(e1, j))); - } - } - } else if (byte.class.equals(componentType)) { - byte[] arr = (byte[]) objectToBeMadeIntoVariant; - sa = new SafeArray(Variant.VariantByte, len1); - for (int i = 0; i < len1; i++) { - sa.setByte(i, arr[i]); - } - } else if (int.class.equals(componentType)) { - int[] arr = (int[]) objectToBeMadeIntoVariant; - sa = new SafeArray(Variant.VariantInt, len1); - for (int i = 0; i < len1; i++) { - sa.setInt(i, arr[i]); - } - } else if (double.class.equals(componentType)) { - double[] arr = (double[]) objectToBeMadeIntoVariant; - sa = new SafeArray(Variant.VariantDouble, len1); - for (int i = 0; i < len1; i++) { - sa.setDouble(i, arr[i]); - } - } else if (long.class.equals(componentType)) { - long[] arr = (long[]) objectToBeMadeIntoVariant; - sa = new SafeArray(Variant.VariantLongInt, len1); - for (int i = 0; i < len1; i++) { - sa.setLong(i, arr[i]); - } - } else { - // array of object - sa = new SafeArray(Variant.VariantVariant, len1); - for (int i = 0; i < len1; i++) { - sa.setVariant(i, objectToVariant(Array.get( - objectToBeMadeIntoVariant, i))); - } - } - Variant returnVariant = new Variant(); - populateVariant(returnVariant, sa, false); - return returnVariant; - } else { - // rely on populateVariant to throw an exception if its an - // invalid type - Variant returnVariant = new Variant(); - populateVariant(returnVariant, objectToBeMadeIntoVariant, false); - return returnVariant; - } - } + if (componentType.isArray()) { // array of arrays + int max = 0; + for (int i = 0; i < len1; i++) { + Object e1 = Array.get(objectToBeMadeIntoVariant, i); + int len2 = Array.getLength(e1); + if (max < len2) { + max = len2; + } + } + sa = new SafeArray(Variant.VariantVariant, len1, max); + for (int i = 0; i < len1; i++) { + Object e1 = Array.get(objectToBeMadeIntoVariant, i); + for (int j = 0; j < Array.getLength(e1); j++) { + sa.setVariant(i, j, objectToVariant(Array.get(e1, j))); + } + } + } else if (byte.class.equals(componentType)) { + byte[] arr = (byte[]) objectToBeMadeIntoVariant; + sa = new SafeArray(Variant.VariantByte, len1); + for (int i = 0; i < len1; i++) { + sa.setByte(i, arr[i]); + } + } else if (int.class.equals(componentType)) { + int[] arr = (int[]) objectToBeMadeIntoVariant; + sa = new SafeArray(Variant.VariantInt, len1); + for (int i = 0; i < len1; i++) { + sa.setInt(i, arr[i]); + } + } else if (double.class.equals(componentType)) { + double[] arr = (double[]) objectToBeMadeIntoVariant; + sa = new SafeArray(Variant.VariantDouble, len1); + for (int i = 0; i < len1; i++) { + sa.setDouble(i, arr[i]); + } + } else if (long.class.equals(componentType)) { + long[] arr = (long[]) objectToBeMadeIntoVariant; + sa = new SafeArray(Variant.VariantLongInt, len1); + for (int i = 0; i < len1; i++) { + sa.setLong(i, arr[i]); + } + } else { + // array of object + sa = new SafeArray(Variant.VariantVariant, len1); + for (int i = 0; i < len1; i++) { + sa.setVariant(i, objectToVariant(Array.get( + objectToBeMadeIntoVariant, i))); + } + } + Variant returnVariant = new Variant(); + populateVariant(returnVariant, sa, false); + return returnVariant; + } else { + // rely on populateVariant to throw an exception if its an + // invalid type + Variant returnVariant = new Variant(); + populateVariant(returnVariant, objectToBeMadeIntoVariant, false); + return returnVariant; + } + } - /** - * converts an array of objects into an array of Variants by repeatedly - * calling obj2Variant(Object) - * - * @param arrayOfObjectsToBeConverted - * @return Variant[] - */ - protected static Variant[] objectsToVariants( - Object[] arrayOfObjectsToBeConverted) { - Variant vArg[] = new Variant[arrayOfObjectsToBeConverted.length]; - for (int i = 0; i < arrayOfObjectsToBeConverted.length; i++) { - vArg[i] = objectToVariant(arrayOfObjectsToBeConverted[i]); - } - return vArg; - } + /** + * converts an array of objects into an array of Variants by repeatedly + * calling obj2Variant(Object) + * + * @param arrayOfObjectsToBeConverted + * @return Variant[] + */ + protected static Variant[] objectsToVariants( + Object[] arrayOfObjectsToBeConverted) { + Variant vArg[] = new Variant[arrayOfObjectsToBeConverted.length]; + for (int i = 0; i < arrayOfObjectsToBeConverted.length; i++) { + vArg[i] = objectToVariant(arrayOfObjectsToBeConverted[i]); + } + return vArg; + } - /** - * Convert a JACOB Variant value to a Java object (type conversions). - * provided in Sourceforge feature request 959381. A fix was done to handle - * byRef bug report 1607878. - *

      - * Unlike other toXXX() methods, it does not do a type conversion except for - * special data types (it shouldn't do any!) - *

      - * Converts Variant.VariantArray types to SafeArrays - * - * @return Corresponding Java object of the type matching the Variant type. - * @throws IllegalStateException - * if no underlying windows data structure - * @throws NotImplementedException - * if unsupported conversion is requested - * @throws JacobException - * if the calculated result was a JacobObject usually as a - * result of error - */ - protected static Object variantToObject(Variant sourceData) { - Object result = null; + /** + * Convert a JACOB Variant value to a Java object (type conversions). + * provided in Sourceforge feature request 959381. A fix was done to handle + * byRef bug report 1607878. + *

      + * Unlike other toXXX() methods, it does not do a type conversion except for + * special data types (it shouldn't do any!) + *

      + * Converts Variant.VariantArray types to SafeArrays + * + * @return Corresponding Java object of the type matching the Variant type. + * @throws IllegalStateException + * if no underlying windows data structure + * @throws NotImplementedException + * if unsupported conversion is requested + * @throws JacobException + * if the calculated result was a JacobObject usually as a + * result of error + */ + protected static Object variantToObject(Variant sourceData) { + Object result = null; - short type = sourceData.getvt(); // variant type + short type = sourceData.getvt(); // variant type - if ((type & Variant.VariantArray) == Variant.VariantArray) { // array - // returned? - SafeArray array = null; - type = (short) (type - Variant.VariantArray); - // From SF Bug 1840487 - // This did call toSafeArray(false) but that meant - // this was the only variantToObject() that didn't have its own - // copy of the data so you would end up with weird run time - // errors after some GC. So now we just get stupid about it and - // always make a copy just like toSafeArray() does. - array = sourceData.toSafeArray(); - result = array; - } else { // non-array object returned - switch (type) { - case Variant.VariantEmpty: // 0 - case Variant.VariantNull: // 1 - break; - case Variant.VariantShort: // 2 - result = new Short(sourceData.getShort()); - break; - case Variant.VariantShort | Variant.VariantByref: // 2 - result = new Short(sourceData.getShortRef()); - break; - case Variant.VariantInt: // 3 - result = new Integer(sourceData.getInt()); - break; - case Variant.VariantInt | Variant.VariantByref: // 3 - result = new Integer(sourceData.getIntRef()); - break; - case Variant.VariantFloat: // 4 - result = new Float(sourceData.getFloat()); - break; - case Variant.VariantFloat | Variant.VariantByref: // 4 - result = new Float(sourceData.getFloatRef()); - break; - case Variant.VariantDouble: // 5 - result = new Double(sourceData.getDouble()); - break; - case Variant.VariantDouble | Variant.VariantByref: // 5 - result = new Double(sourceData.getDoubleRef()); - break; - case Variant.VariantCurrency: // 6 - result = sourceData.getCurrency(); - break; - case Variant.VariantCurrency | Variant.VariantByref: // 6 - result = sourceData.getCurrencyRef(); - break; - case Variant.VariantDate: // 7 - result = sourceData.getJavaDate(); - break; - case Variant.VariantDate | Variant.VariantByref: // 7 - result = sourceData.getJavaDateRef(); - break; - case Variant.VariantString: // 8 - result = sourceData.getString(); - break; - case Variant.VariantString | Variant.VariantByref: // 8 - result = sourceData.getStringRef(); - break; - case Variant.VariantDispatch: // 9 - result = sourceData.getDispatch(); - break; - case Variant.VariantDispatch | Variant.VariantByref: // 9 - result = sourceData.getDispatchRef(); // Can dispatches even - // be byRef? - break; - case Variant.VariantError: // 10 - result = new NotImplementedException( - "toJavaObject() Not implemented for VariantError"); - break; - case Variant.VariantBoolean: // 11 - result = new Boolean(sourceData.getBoolean()); - break; - case Variant.VariantBoolean | Variant.VariantByref: // 11 - result = new Boolean(sourceData.getBooleanRef()); - break; - case Variant.VariantVariant: // 12 they are always by ref - result = new NotImplementedException( - "toJavaObject() Not implemented for VariantVariant without ByRef"); - break; - case Variant.VariantVariant | Variant.VariantByref: // 12 - result = sourceData.getVariant(); - break; - case Variant.VariantObject: // 13 - result = new NotImplementedException( - "toJavaObject() Not implemented for VariantObject"); - break; - case Variant.VariantDecimal: // 14 - result = sourceData.getDecimal(); - break; - case Variant.VariantDecimal | Variant.VariantByref: // 14 - result = sourceData.getDecimalRef(); - break; - case Variant.VariantByte: // 17 - result = new Byte(sourceData.getByte()); - break; - case Variant.VariantByte | Variant.VariantByref: // 17 - result = new Byte(sourceData.getByteRef()); - break; - case Variant.VariantLongInt: // 20 - result = new Long(sourceData.getLong()); - break; - case Variant.VariantLongInt | Variant.VariantByref: // 20 - result = new Long(sourceData.getLongRef()); - break; - case Variant.VariantTypeMask: // 4095 - result = new NotImplementedException( - "toJavaObject() Not implemented for VariantTypeMask"); - break; - case Variant.VariantArray: // 8192 - result = new NotImplementedException( - "toJavaObject() Not implemented for VariantArray"); - break; - case Variant.VariantByref: // 16384 - result = new NotImplementedException( - "toJavaObject() Not implemented for VariantByref"); - break; - default: - result = new NotImplementedException("Unknown return type: " - + type); - // there was a "return result" here that caused defect 1602118 - // so it was removed - break; - }// switch (type) + if ((type & Variant.VariantArray) == Variant.VariantArray) { // array + // returned? + SafeArray array = null; + type = (short) (type - Variant.VariantArray); + // From SF Bug 1840487 + // This did call toSafeArray(false) but that meant + // this was the only variantToObject() that didn't have its own + // copy of the data so you would end up with weird run time + // errors after some GC. So now we just get stupid about it and + // always make a copy just like toSafeArray() does. + array = sourceData.toSafeArray(); + result = array; + } else { // non-array object returned + switch (type) { + case Variant.VariantEmpty: // 0 + case Variant.VariantNull: // 1 + break; + case Variant.VariantShort: // 2 + result = new Short(sourceData.getShort()); + break; + case Variant.VariantShort | Variant.VariantByref: // 2 + result = new Short(sourceData.getShortRef()); + break; + case Variant.VariantInt: // 3 + result = new Integer(sourceData.getInt()); + break; + case Variant.VariantInt | Variant.VariantByref: // 3 + result = new Integer(sourceData.getIntRef()); + break; + case Variant.VariantFloat: // 4 + result = new Float(sourceData.getFloat()); + break; + case Variant.VariantFloat | Variant.VariantByref: // 4 + result = new Float(sourceData.getFloatRef()); + break; + case Variant.VariantDouble: // 5 + result = new Double(sourceData.getDouble()); + break; + case Variant.VariantDouble | Variant.VariantByref: // 5 + result = new Double(sourceData.getDoubleRef()); + break; + case Variant.VariantCurrency: // 6 + result = sourceData.getCurrency(); + break; + case Variant.VariantCurrency | Variant.VariantByref: // 6 + result = sourceData.getCurrencyRef(); + break; + case Variant.VariantDate: // 7 + result = sourceData.getJavaDate(); + break; + case Variant.VariantDate | Variant.VariantByref: // 7 + result = sourceData.getJavaDateRef(); + break; + case Variant.VariantString: // 8 + result = sourceData.getString(); + break; + case Variant.VariantString | Variant.VariantByref: // 8 + result = sourceData.getStringRef(); + break; + case Variant.VariantDispatch: // 9 + result = sourceData.getDispatch(); + break; + case Variant.VariantDispatch | Variant.VariantByref: // 9 + result = sourceData.getDispatchRef(); // Can dispatches even + // be byRef? + break; + case Variant.VariantError: // 10 + result = new NotImplementedException( + "toJavaObject() Not implemented for VariantError"); + break; + case Variant.VariantBoolean: // 11 + result = new Boolean(sourceData.getBoolean()); + break; + case Variant.VariantBoolean | Variant.VariantByref: // 11 + result = new Boolean(sourceData.getBooleanRef()); + break; + case Variant.VariantVariant: // 12 they are always by ref + result = new NotImplementedException( + "toJavaObject() Not implemented for VariantVariant without ByRef"); + break; + case Variant.VariantVariant | Variant.VariantByref: // 12 + result = sourceData.getVariant(); + break; + case Variant.VariantObject: // 13 + result = new NotImplementedException( + "toJavaObject() Not implemented for VariantObject"); + break; + case Variant.VariantDecimal: // 14 + result = sourceData.getDecimal(); + break; + case Variant.VariantDecimal | Variant.VariantByref: // 14 + result = sourceData.getDecimalRef(); + break; + case Variant.VariantByte: // 17 + result = new Byte(sourceData.getByte()); + break; + case Variant.VariantByte | Variant.VariantByref: // 17 + result = new Byte(sourceData.getByteRef()); + break; + case Variant.VariantLongInt: // 20 + result = new Long(sourceData.getLong()); + break; + case Variant.VariantLongInt | Variant.VariantByref: // 20 + result = new Long(sourceData.getLongRef()); + break; + case Variant.VariantTypeMask: // 4095 + result = new NotImplementedException( + "toJavaObject() Not implemented for VariantTypeMask"); + break; + case Variant.VariantArray: // 8192 + result = new NotImplementedException( + "toJavaObject() Not implemented for VariantArray"); + break; + case Variant.VariantByref: // 16384 + result = new NotImplementedException( + "toJavaObject() Not implemented for VariantByref"); + break; + default: + result = new NotImplementedException("Unknown return type: " + + type); + // there was a "return result" here that caused defect 1602118 + // so it was removed + break; + }// switch (type) - if (result instanceof JacobException) { - throw (JacobException) result; - } - } + if (result instanceof JacobException) { + throw (JacobException) result; + } + } - return result; - }// toJava() + return result; + }// toJava() - /** - * Verifies that we have a scale 0 <= x <= 28 and now more than 96 bits of - * data. The roundToMSDecimal method will attempt to adjust a BigDecimal to - * pass this set of tests - * - * @param in - * @throws IllegalArgumentException - * if out of bounds - */ - protected static void validateDecimalScaleAndBits(BigDecimal in) { - BigInteger allWordBigInt = in.unscaledValue(); - if (in.scale() > 28) { - // should this cast to a string and call putStringRef()? - throw new IllegalArgumentException( - "VT_DECIMAL only supports a maximum scale of 28 and the passed" - + " in value has a scale of " + in.scale()); - } else if (in.scale() < 0) { - // should this cast to a string and call putStringRef()? - throw new IllegalArgumentException( - "VT_DECIMAL only supports a minimum scale of 0 and the passed" - + " in value has a scale of " + in.scale()); - } else if (allWordBigInt.bitLength() > 12 * 8) { - throw new IllegalArgumentException( - "VT_DECIMAL supports a maximum of " - + 12 - * 8 - + " bits not counting scale and the number passed in has " - + allWordBigInt.bitLength()); + /** + * Verifies that we have a scale 0 <= x <= 28 and now more than 96 bits of + * data. The roundToMSDecimal method will attempt to adjust a BigDecimal to + * pass this set of tests + * + * @param in + * @throws IllegalArgumentException + * if out of bounds + */ + protected static void validateDecimalScaleAndBits(BigDecimal in) { + BigInteger allWordBigInt = in.unscaledValue(); + if (in.scale() > 28) { + // should this cast to a string and call putStringRef()? + throw new IllegalArgumentException( + "VT_DECIMAL only supports a maximum scale of 28 and the passed" + + " in value has a scale of " + in.scale()); + } else if (in.scale() < 0) { + // should this cast to a string and call putStringRef()? + throw new IllegalArgumentException( + "VT_DECIMAL only supports a minimum scale of 0 and the passed" + + " in value has a scale of " + in.scale()); + } else if (allWordBigInt.bitLength() > 12 * 8) { + throw new IllegalArgumentException( + "VT_DECIMAL supports a maximum of " + + 12 + * 8 + + " bits not counting scale and the number passed in has " + + allWordBigInt.bitLength()); - } else { - // no bounds problem to be handled - } + } else { + // no bounds problem to be handled + } - } + } - /** - * Largest possible number with scale set to 0 - */ - private static final BigDecimal LARGEST_DECIMAL = new BigDecimal( - new BigInteger("ffffffffffffffffffffffff", 16)); - /** - * Smallest possible number with scale set to 0. MS doesn't support negative - * scales like BigDecimal. - */ - private static final BigDecimal SMALLEST_DECIMAL = new BigDecimal( - new BigInteger("ffffffffffffffffffffffff", 16).negate()); + /** + * Largest possible number with scale set to 0 + */ + private static final BigDecimal LARGEST_DECIMAL = new BigDecimal( + new BigInteger("ffffffffffffffffffffffff", 16)); + /** + * Smallest possible number with scale set to 0. MS doesn't support negative + * scales like BigDecimal. + */ + private static final BigDecimal SMALLEST_DECIMAL = new BigDecimal( + new BigInteger("ffffffffffffffffffffffff", 16).negate()); - /** - * Does any validation that couldn't have been fixed by rounding or scale - * modification. - * - * @param in - * The BigDecimal to be validated - * @throws IllegalArgumentException - * if the number is too large or too small or null - */ - protected static void validateDecimalMinMax(BigDecimal in) { - if (in == null) { - throw new IllegalArgumentException( - "null is not a supported Decimal value."); - } else if (LARGEST_DECIMAL.compareTo(in) < 0) { - throw new IllegalArgumentException( - "Value too large for VT_DECIMAL data type:" + in.toString() - + " integer: " + in.toBigInteger().toString(16) - + " scale: " + in.scale()); - } else if (SMALLEST_DECIMAL.compareTo(in) > 0) { - throw new IllegalArgumentException( - "Value too small for VT_DECIMAL data type:" + in.toString() - + " integer: " + in.toBigInteger().toString(16) - + " scale: " + in.scale()); - } + /** + * Does any validation that couldn't have been fixed by rounding or scale + * modification. + * + * @param in + * The BigDecimal to be validated + * @throws IllegalArgumentException + * if the number is too large or too small or null + */ + protected static void validateDecimalMinMax(BigDecimal in) { + if (in == null) { + throw new IllegalArgumentException( + "null is not a supported Decimal value."); + } else if (LARGEST_DECIMAL.compareTo(in) < 0) { + throw new IllegalArgumentException( + "Value too large for VT_DECIMAL data type:" + in.toString() + + " integer: " + in.toBigInteger().toString(16) + + " scale: " + in.scale()); + } else if (SMALLEST_DECIMAL.compareTo(in) > 0) { + throw new IllegalArgumentException( + "Value too small for VT_DECIMAL data type:" + in.toString() + + " integer: " + in.toBigInteger().toString(16) + + " scale: " + in.scale()); + } - } + } - /** - * Rounds the scale and bit length so that it will pass - * validateDecimalScaleBits(). Developers should call this method if they - * really want MS Decimal and don't want to lose precision. - *

      - * Changing the scale on a number that can fit in an MS Decimal can change - * the number's representation enough that it will round to a number too - * large to be represented by an MS VT_DECIMAL - * - * @param sourceDecimal - * @return BigDecimal a new big decimal that was rounded to fit in an MS - * VT_DECIMAL - */ - public static BigDecimal roundToMSDecimal(BigDecimal sourceDecimal) { - BigInteger sourceDecimalIntComponent = sourceDecimal.unscaledValue(); - BigDecimal destinationDecimal = new BigDecimal( - sourceDecimalIntComponent, sourceDecimal.scale()); - int roundingModel = BigDecimal.ROUND_HALF_UP; - validateDecimalMinMax(destinationDecimal); - // First limit the number of digits and then the precision. - // Try and round to 29 digits because we can sometimes do that - BigInteger allWordBigInt; - allWordBigInt = destinationDecimal.unscaledValue(); - if (allWordBigInt.bitLength() > 96) { - destinationDecimal = destinationDecimal.round(new MathContext(29)); - // see if 29 digits uses more than 96 bits - if (allWordBigInt.bitLength() > 96) { - // Dang. It was over 97 bits so shorten it one more digit to - // stay <= 96 bits - destinationDecimal = destinationDecimal.round(new MathContext( - 28)); - } - } - // the bit manipulations above may change the scale so do it afterwards - // round the scale to the max MS can support - if (destinationDecimal.scale() > 28) { - destinationDecimal = destinationDecimal.setScale(28, roundingModel); - } - if (destinationDecimal.scale() < 0) { - destinationDecimal = destinationDecimal.setScale(0, roundingModel); - } - return destinationDecimal; - } + /** + * Rounds the scale and bit length so that it will pass + * validateDecimalScaleBits(). Developers should call this method if they + * really want MS Decimal and don't want to lose precision. + *

      + * Changing the scale on a number that can fit in an MS Decimal can change + * the number's representation enough that it will round to a number too + * large to be represented by an MS VT_DECIMAL + * + * @param sourceDecimal + * @return BigDecimal a new big decimal that was rounded to fit in an MS + * VT_DECIMAL + */ + public static BigDecimal roundToMSDecimal(BigDecimal sourceDecimal) { + BigInteger sourceDecimalIntComponent = sourceDecimal.unscaledValue(); + BigDecimal destinationDecimal = new BigDecimal( + sourceDecimalIntComponent, sourceDecimal.scale()); + int roundingModel = BigDecimal.ROUND_HALF_UP; + validateDecimalMinMax(destinationDecimal); + // First limit the number of digits and then the precision. + // Try and round to 29 digits because we can sometimes do that + BigInteger allWordBigInt; + allWordBigInt = destinationDecimal.unscaledValue(); + if (allWordBigInt.bitLength() > 96) { + destinationDecimal = destinationDecimal.round(new MathContext(29)); + // see if 29 digits uses more than 96 bits + if (allWordBigInt.bitLength() > 96) { + // Dang. It was over 97 bits so shorten it one more digit to + // stay <= 96 bits + destinationDecimal = destinationDecimal.round(new MathContext( + 28)); + } + } + // the bit manipulations above may change the scale so do it afterwards + // round the scale to the max MS can support + if (destinationDecimal.scale() > 28) { + destinationDecimal = destinationDecimal.setScale(28, roundingModel); + } + if (destinationDecimal.scale() < 0) { + destinationDecimal = destinationDecimal.setScale(0, roundingModel); + } + return destinationDecimal; + } } diff --git a/src/main/java/com/jacob/com/VariantViaEvent.java b/src/main/java/com/jacob/com/VariantViaEvent.java index cb54f4b..841cc5b 100644 --- a/src/main/java/com/jacob/com/VariantViaEvent.java +++ b/src/main/java/com/jacob/com/VariantViaEvent.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -44,10 +44,10 @@ package com.jacob.com; */ public class VariantViaEvent extends Variant { - /** - * Standard constructor used by JNI event handling layer - */ - public VariantViaEvent() { - super(); - } + /** + * Standard constructor used by JNI event handling layer + */ + public VariantViaEvent() { + super(); + } } diff --git a/src/main/java/com/jacob/com/WrongThreadException.java b/src/main/java/com/jacob/com/WrongThreadException.java index 7b4989d..5ac113d 100644 --- a/src/main/java/com/jacob/com/WrongThreadException.java +++ b/src/main/java/com/jacob/com/WrongThreadException.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -42,25 +42,25 @@ package com.jacob.com; * thrown in util.cpp */ public class WrongThreadException extends JacobException { - /** - * identifier generated by Eclipse - */ - private static final long serialVersionUID = 6308780364980228692L; + /** + * identifier generated by Eclipse + */ + private static final long serialVersionUID = 6308780364980228692L; - /** - * standard 0 arg constructor with no message - * - */ - public WrongThreadException() { - super("No Message Provided."); - } + /** + * standard 0 arg constructor with no message + * + */ + public WrongThreadException() { + super("No Message Provided."); + } - /** - * standard constructor with a string message - * - * @param s - */ - public WrongThreadException(String s) { - super(s); - } + /** + * standard constructor with a string message + * + * @param s + */ + public WrongThreadException(String s) { + super(s); + } } \ No newline at end of file diff --git a/src/sample/com/jacob/samples/MathProj/MathTest.java b/src/sample/com/jacob/samples/MathProj/MathTest.java index d1793b5..154d528 100644 --- a/src/sample/com/jacob/samples/MathProj/MathTest.java +++ b/src/sample/com/jacob/samples/MathProj/MathTest.java @@ -13,71 +13,71 @@ import com.jacob.com.Variant; * options. */ class MathTest { - /** - * standard main program to run the sample - * - * @param args - * command line parameters - */ - public static void main(String[] args) { - MathTest me = new MathTest(); - me.runTest(); - } + /** + * standard main program to run the sample + * + * @param args + * command line parameters + */ + public static void main(String[] args) { + MathTest me = new MathTest(); + me.runTest(); + } - /** default constructor */ - public MathTest() { - } + /** default constructor */ + public MathTest() { + } - /** - * not clear why we need a class and run method but that's the way it was - * written - */ - public void runTest() { - // deprecated - // System.runFinalizersOnExit(true); - Dispatch test = new ActiveXComponent("MathTest.Math"); - TestEvents te = new TestEvents(); - DispatchEvents de = new DispatchEvents(test, te); - if (de == null) { - System.out - .println("null returned when trying to create DispatchEvents"); - } - System.out.println(Dispatch.call(test, "Add", new Variant(1), - new Variant(2))); - System.out.println(Dispatch.call(test, "Mult", new Variant(2), - new Variant(2))); - Variant v = Dispatch.call(test, "Mult", new Variant(2), new Variant(2)); - // this should return false - System.out.println("v.isNull=" + v.isNull()); - v = Dispatch.call(test, "getNothing"); - // these should return nothing - System.out.println("v.isNull=" + v.isNull()); - System.out.println("v.toDispatch=" + v.toDispatch()); - } + /** + * not clear why we need a class and run method but that's the way it was + * written + */ + public void runTest() { + // deprecated + // System.runFinalizersOnExit(true); + Dispatch test = new ActiveXComponent("MathTest.Math"); + TestEvents te = new TestEvents(); + DispatchEvents de = new DispatchEvents(test, te); + if (de == null) { + System.out + .println("null returned when trying to create DispatchEvents"); + } + System.out.println(Dispatch.call(test, "Add", new Variant(1), + new Variant(2))); + System.out.println(Dispatch.call(test, "Mult", new Variant(2), + new Variant(2))); + Variant v = Dispatch.call(test, "Mult", new Variant(2), new Variant(2)); + // this should return false + System.out.println("v.isNull=" + v.isNull()); + v = Dispatch.call(test, "getNothing"); + // these should return nothing + System.out.println("v.isNull=" + v.isNull()); + System.out.println("v.toDispatch=" + v.toDispatch()); + } - /** - * - * sample class to catch the events - * - */ - public class TestEvents { - /** - * catches the DoneAdd event - * - * @param args - */ - public void DoneAdd(Variant[] args) { - System.out.println("DoneAdd called in java"); - } + /** + * + * sample class to catch the events + * + */ + public class TestEvents { + /** + * catches the DoneAdd event + * + * @param args + */ + public void DoneAdd(Variant[] args) { + System.out.println("DoneAdd called in java"); + } - /** - * catches the DoneMult event - * - * @param args - */ - public void DoneMult(Variant[] args) { - System.out.println("DoneMult called in java"); - } - } + /** + * catches the DoneMult event + * + * @param args + */ + public void DoneMult(Variant[] args) { + System.out.println("DoneMult called in java"); + } + } } diff --git a/src/sample/com/jacob/samples/access/Access.java b/src/sample/com/jacob/samples/access/Access.java index c99bb73..e9f831a 100644 --- a/src/sample/com/jacob/samples/access/Access.java +++ b/src/sample/com/jacob/samples/access/Access.java @@ -31,114 +31,114 @@ import com.jacob.com.Variant; * */ class Access { - /** - * the main loop for the test - * - * @param args - * @throws Exception - */ - public static void main(String[] args) throws Exception { - ComThread.InitSTA(); - // original test used this - // ActiveXComponent ax = new ActiveXComponent("DAO.PrivateDBEngine"); - // my xp box with a later release of access needed this - ActiveXComponent ax = new ActiveXComponent("DAO.PrivateDBEngine.35"); - // this only works for access files pre-access-2000 - // this line doesn't work on my xp box in Eclipse - // Dispatch db = open(ax, ".\\sample2.mdb"); - // this works when running in eclipse because the test cases run pwd - // project root - Dispatch db = open(ax, "samples/com/jacob/samples/access/sample2.mdb"); - String sql = "select * from MainTable"; - // make a temporary querydef - Dispatch qd = Dispatch.call(db, "CreateQueryDef", "").toDispatch(); - // set the SQL string on it - Dispatch.put(qd, "SQL", sql); - Variant result = getByQueryDef(qd); - // the 2-d safearray is transposed from what you might expect - System.out.println("resulting array is " + result.toSafeArray()); - close(db); - System.out.println("about to call ComThread.Release()"); - ComThread.Release(); - } + /** + * the main loop for the test + * + * @param args + * @throws Exception + */ + public static void main(String[] args) throws Exception { + ComThread.InitSTA(); + // original test used this + // ActiveXComponent ax = new ActiveXComponent("DAO.PrivateDBEngine"); + // my xp box with a later release of access needed this + ActiveXComponent ax = new ActiveXComponent("DAO.PrivateDBEngine.35"); + // this only works for access files pre-access-2000 + // this line doesn't work on my xp box in Eclipse + // Dispatch db = open(ax, ".\\sample2.mdb"); + // this works when running in eclipse because the test cases run pwd + // project root + Dispatch db = open(ax, "samples/com/jacob/samples/access/sample2.mdb"); + String sql = "select * from MainTable"; + // make a temporary querydef + Dispatch qd = Dispatch.call(db, "CreateQueryDef", "").toDispatch(); + // set the SQL string on it + Dispatch.put(qd, "SQL", sql); + Variant result = getByQueryDef(qd); + // the 2-d safearray is transposed from what you might expect + System.out.println("resulting array is " + result.toSafeArray()); + close(db); + System.out.println("about to call ComThread.Release()"); + ComThread.Release(); + } - /** - * Open a database - * - * @param ax - * @param fileName - * @return dispatch object that was opened - */ - public static Dispatch open(ActiveXComponent ax, String fileName) { - Variant f = new Variant(false); - // open the file in read-only mode - Variant[] args = new Variant[] { new Variant(fileName), f, f }; - Dispatch openDB = ax.invoke("OpenDatabase", args).toDispatch(); - return openDB; - } + /** + * Open a database + * + * @param ax + * @param fileName + * @return dispatch object that was opened + */ + public static Dispatch open(ActiveXComponent ax, String fileName) { + Variant f = new Variant(false); + // open the file in read-only mode + Variant[] args = new Variant[] { new Variant(fileName), f, f }; + Dispatch openDB = ax.invoke("OpenDatabase", args).toDispatch(); + return openDB; + } - /** - * Close a database - * - * @param openDB - * db to be closed - */ - public static void close(Dispatch openDB) { - Dispatch.call(openDB, "Close"); - } + /** + * Close a database + * + * @param openDB + * db to be closed + */ + public static void close(Dispatch openDB) { + Dispatch.call(openDB, "Close"); + } - /** - * Extract the values from the recordset - * - * @param recset - * @return Variant that is the returned values - */ - public static Variant getValues(Dispatch recset) { - Dispatch.callSub(recset, "moveFirst"); - Variant vi = new Variant(4096); - Variant v = Dispatch.call(recset, "GetRows", vi); - return v; - } + /** + * Extract the values from the recordset + * + * @param recset + * @return Variant that is the returned values + */ + public static Variant getValues(Dispatch recset) { + Dispatch.callSub(recset, "moveFirst"); + Variant vi = new Variant(4096); + Variant v = Dispatch.call(recset, "GetRows", vi); + return v; + } - /** - * should return ?? for the passed in ?? - * - * @param qd - * @return Variant results of query? - */ - public static Variant getByQueryDef(Dispatch qd) { - // get a reference to the recordset - Dispatch recset = Dispatch.call(qd, "OpenRecordset").toDispatch(); - // get the values as a safe array - String[] cols = getColumns(recset); - for (int i = 0; i < cols.length; i++) { - System.out.print(cols[i] + " "); - } - System.out.println(""); - Variant vals = getValues(recset); - return vals; - } + /** + * should return ?? for the passed in ?? + * + * @param qd + * @return Variant results of query? + */ + public static Variant getByQueryDef(Dispatch qd) { + // get a reference to the recordset + Dispatch recset = Dispatch.call(qd, "OpenRecordset").toDispatch(); + // get the values as a safe array + String[] cols = getColumns(recset); + for (int i = 0; i < cols.length; i++) { + System.out.print(cols[i] + " "); + } + System.out.println(""); + Variant vals = getValues(recset); + return vals; + } - /** - * gets the columns form the rec set - * - * @param recset - * @return list of column names - */ - public static String[] getColumns(Dispatch recset) { - Dispatch flds = Dispatch.get(recset, "Fields").toDispatch(); - int n_flds = Dispatch.get(flds, "Count").getInt(); - String[] s = new String[n_flds]; - Variant vi = new Variant(); - for (int i = 0; i < n_flds; i++) { - vi.putInt(i); - // must use the invoke method because this is a method call - // that wants to have a Dispatch.Get flag... - Dispatch fld = Dispatch.invoke(recset, "Fields", Dispatch.Get, - new Object[] { vi }, new int[1]).toDispatch(); - Variant name = Dispatch.get(fld, "Name"); - s[i] = name.toString(); - } - return s; - } + /** + * gets the columns form the rec set + * + * @param recset + * @return list of column names + */ + public static String[] getColumns(Dispatch recset) { + Dispatch flds = Dispatch.get(recset, "Fields").toDispatch(); + int n_flds = Dispatch.get(flds, "Count").getInt(); + String[] s = new String[n_flds]; + Variant vi = new Variant(); + for (int i = 0; i < n_flds; i++) { + vi.putInt(i); + // must use the invoke method because this is a method call + // that wants to have a Dispatch.Get flag... + Dispatch fld = Dispatch.invoke(recset, "Fields", Dispatch.Get, + new Object[] { vi }, new int[1]).toDispatch(); + Variant name = Dispatch.get(fld, "Name"); + s[i] = name.toString(); + } + return s; + } } diff --git a/src/sample/com/jacob/samples/ado/Command.java b/src/sample/com/jacob/samples/ado/Command.java index ca5add8..d43db66 100644 --- a/src/sample/com/jacob/samples/ado/Command.java +++ b/src/sample/com/jacob/samples/ado/Command.java @@ -9,199 +9,199 @@ import com.jacob.com.Variant; * */ public class Command extends Dispatch { - /** - * standard constructor - */ - public Command() { - super("ADODB.Command"); - } + /** + * standard constructor + */ + public Command() { + super("ADODB.Command"); + } - /** - * This constructor is used instead of a case operation to turn a Dispatch - * object into a wider object - it must exist in every wrapper class whose - * instances may be returned from method calls wrapped in VT_DISPATCH - * Variants. - * - * @param dispatchTarget - */ - public Command(Dispatch dispatchTarget) { - super(dispatchTarget); - } + /** + * This constructor is used instead of a case operation to turn a Dispatch + * object into a wider object - it must exist in every wrapper class whose + * instances may be returned from method calls wrapped in VT_DISPATCH + * Variants. + * + * @param dispatchTarget + */ + public Command(Dispatch dispatchTarget) { + super(dispatchTarget); + } - /** - * runs the "Properties" command - * - * @return the properties - */ - public Variant getProperties() { - return Dispatch.get(this, "Properties"); - } + /** + * runs the "Properties" command + * + * @return the properties + */ + public Variant getProperties() { + return Dispatch.get(this, "Properties"); + } - /** - * runs the "ActiveConnection" command - * - * @return a Connection object - */ - public Connection getActiveConnection() { - return new Connection(Dispatch.get(this, "ActiveConnection") - .toDispatch()); - } + /** + * runs the "ActiveConnection" command + * + * @return a Connection object + */ + public Connection getActiveConnection() { + return new Connection(Dispatch.get(this, "ActiveConnection") + .toDispatch()); + } - /** - * Sets the "ActiveConnection" object - * - * @param ppvObject - * the new connection - */ - public void setActiveConnection(Connection ppvObject) { - Dispatch.put(this, "ActiveConnection", ppvObject); - } + /** + * Sets the "ActiveConnection" object + * + * @param ppvObject + * the new connection + */ + public void setActiveConnection(Connection ppvObject) { + Dispatch.put(this, "ActiveConnection", ppvObject); + } - /** - * - * @return the results from "CommandText" - */ - public String getCommandText() { - return Dispatch.get(this, "CommandText").toString(); - } + /** + * + * @return the results from "CommandText" + */ + public String getCommandText() { + return Dispatch.get(this, "CommandText").toString(); + } - /** - * - * @param pbstr - * the new "CommandText" - */ - public void setCommandText(String pbstr) { - Dispatch.put(this, "CommandText", pbstr); - } + /** + * + * @param pbstr + * the new "CommandText" + */ + public void setCommandText(String pbstr) { + Dispatch.put(this, "CommandText", pbstr); + } - /** - * - * @return the results of "CommandTimeout" - */ - public int getCommandTimeout() { - return Dispatch.get(this, "CommandTimeout").getInt(); - } + /** + * + * @return the results of "CommandTimeout" + */ + public int getCommandTimeout() { + return Dispatch.get(this, "CommandTimeout").getInt(); + } - /** - * - * @param plTimeout - * the new "CommandTimeout" - */ - public void setCommandTimeout(int plTimeout) { - Dispatch.put(this, "CommandTimeout", new Variant(plTimeout)); - } + /** + * + * @param plTimeout + * the new "CommandTimeout" + */ + public void setCommandTimeout(int plTimeout) { + Dispatch.put(this, "CommandTimeout", new Variant(plTimeout)); + } - /** - * - * @return results from "Prepared" - */ - public boolean getPrepared() { - return Dispatch.get(this, "Prepared").getBoolean(); - } + /** + * + * @return results from "Prepared" + */ + public boolean getPrepared() { + return Dispatch.get(this, "Prepared").getBoolean(); + } - /** - * - * @param pfPrepared - * the new value for "Prepared" - */ - public void setPrepared(boolean pfPrepared) { - Dispatch.put(this, "Prepared", new Variant(pfPrepared)); - } + /** + * + * @param pfPrepared + * the new value for "Prepared" + */ + public void setPrepared(boolean pfPrepared) { + Dispatch.put(this, "Prepared", new Variant(pfPrepared)); + } - /** - * "Execute"s a command - * - * @param RecordsAffected - * @param Parameters - * @param Options - * @return - */ - public Recordset Execute(Variant RecordsAffected, Variant Parameters, - int Options) { - return (Recordset) Dispatch.call(this, "Execute", RecordsAffected, - Parameters, new Variant(Options)).toDispatch(); - } + /** + * "Execute"s a command + * + * @param RecordsAffected + * @param Parameters + * @param Options + * @return + */ + public Recordset Execute(Variant RecordsAffected, Variant Parameters, + int Options) { + return (Recordset) Dispatch.call(this, "Execute", RecordsAffected, + Parameters, new Variant(Options)).toDispatch(); + } - /** - * "Execute"s a command - * - * @return - */ - public Recordset Execute() { - Variant dummy = new Variant(); - return new Recordset(Dispatch.call(this, "Execute", dummy).toDispatch()); - } + /** + * "Execute"s a command + * + * @return + */ + public Recordset Execute() { + Variant dummy = new Variant(); + return new Recordset(Dispatch.call(this, "Execute", dummy).toDispatch()); + } - /** - * creates a parameter - * - * @param Name - * @param Type - * @param Direction - * @param Size - * @param Value - * @return - */ - public Variant CreateParameter(String Name, int Type, int Direction, - int Size, Variant Value) { - return Dispatch.call(this, "CreateParameter", Name, new Variant(Type), - new Variant(Direction), new Variant(Size), Value); - } + /** + * creates a parameter + * + * @param Name + * @param Type + * @param Direction + * @param Size + * @param Value + * @return + */ + public Variant CreateParameter(String Name, int Type, int Direction, + int Size, Variant Value) { + return Dispatch.call(this, "CreateParameter", Name, new Variant(Type), + new Variant(Direction), new Variant(Size), Value); + } - // need to wrap Parameters - /** - * @return "Parameters" - */ - public Variant getParameters() { - return Dispatch.get(this, "Parameters"); - } + // need to wrap Parameters + /** + * @return "Parameters" + */ + public Variant getParameters() { + return Dispatch.get(this, "Parameters"); + } - /** - * - * @param plCmdType - * new "CommandType" - */ - public void setCommandType(int plCmdType) { - Dispatch.put(this, "CommandType", new Variant(plCmdType)); - } + /** + * + * @param plCmdType + * new "CommandType" + */ + public void setCommandType(int plCmdType) { + Dispatch.put(this, "CommandType", new Variant(plCmdType)); + } - /** - * - * @return current "CommandType" - */ - public int getCommandType() { - return Dispatch.get(this, "CommandType").getInt(); - } + /** + * + * @return current "CommandType" + */ + public int getCommandType() { + return Dispatch.get(this, "CommandType").getInt(); + } - /** - * - * @return "Name" - */ - public String getName() { - return Dispatch.get(this, "Name").toString(); - } + /** + * + * @return "Name" + */ + public String getName() { + return Dispatch.get(this, "Name").toString(); + } - /** - * - * @param pbstrName - * new "Name" - */ - public void setName(String pbstrName) { - Dispatch.put(this, "Name", pbstrName); - } + /** + * + * @param pbstrName + * new "Name" + */ + public void setName(String pbstrName) { + Dispatch.put(this, "Name", pbstrName); + } - /** - * - * @return curent "State" - */ - public int getState() { - return Dispatch.get(this, "State").getInt(); - } + /** + * + * @return curent "State" + */ + public int getState() { + return Dispatch.get(this, "State").getInt(); + } - /** - * cancel whatever it is we're doing - */ - public void Cancel() { - Dispatch.call(this, "Cancel"); - } + /** + * cancel whatever it is we're doing + */ + public void Cancel() { + Dispatch.call(this, "Cancel"); + } } diff --git a/src/sample/com/jacob/samples/ado/CommandTypeEnum.java b/src/sample/com/jacob/samples/ado/CommandTypeEnum.java index 2afd585..8ee04cb 100644 --- a/src/sample/com/jacob/samples/ado/CommandTypeEnum.java +++ b/src/sample/com/jacob/samples/ado/CommandTypeEnum.java @@ -3,11 +3,11 @@ package com.jacob.samples.ado; // Enum: CommandTypeEnum public interface CommandTypeEnum { - public static final int adCmdUnspecified = -1; - public static final int adCmdUnknown = 8; - public static final int adCmdText = 1; - public static final int adCmdTable = 2; - public static final int adCmdStoredProc = 4; - public static final int adCmdFile = 256; - public static final int adCmdTableDirect = 512; + public static final int adCmdUnspecified = -1; + public static final int adCmdUnknown = 8; + public static final int adCmdText = 1; + public static final int adCmdTable = 2; + public static final int adCmdStoredProc = 4; + public static final int adCmdFile = 256; + public static final int adCmdTableDirect = 512; } diff --git a/src/sample/com/jacob/samples/ado/Connection.java b/src/sample/com/jacob/samples/ado/Connection.java index 8e0c9a6..e25ee59 100644 --- a/src/sample/com/jacob/samples/ado/Connection.java +++ b/src/sample/com/jacob/samples/ado/Connection.java @@ -4,148 +4,148 @@ import com.jacob.com.Dispatch; import com.jacob.com.Variant; public class Connection extends Dispatch { - public Connection() { - super("ADODB.Connection"); - } + public Connection() { + super("ADODB.Connection"); + } - /** - * This constructor is used instead of a case operation to turn a Dispatch - * object into a wider object - it must exist in every wrapper class whose - * instances may be returned from method calls wrapped in VT_DISPATCH - * Variants. - */ - public Connection(Dispatch d) { - super(d); - } + /** + * This constructor is used instead of a case operation to turn a Dispatch + * object into a wider object - it must exist in every wrapper class whose + * instances may be returned from method calls wrapped in VT_DISPATCH + * Variants. + */ + public Connection(Dispatch d) { + super(d); + } - // need to wrap Properties - public Variant getProperties() { - return Dispatch.get(this, "Properties"); - } + // need to wrap Properties + public Variant getProperties() { + return Dispatch.get(this, "Properties"); + } - public String getConnectionString() { - return Dispatch.get(this, "ConnectionString").toString(); - } + public String getConnectionString() { + return Dispatch.get(this, "ConnectionString").toString(); + } - public void setConnectionString(String pbstr) { - Dispatch.put(this, "ConnectionString", pbstr); - } + public void setConnectionString(String pbstr) { + Dispatch.put(this, "ConnectionString", pbstr); + } - public int getCommandTimeout() { - return Dispatch.get(this, "CommandTimeout").getInt(); - } + public int getCommandTimeout() { + return Dispatch.get(this, "CommandTimeout").getInt(); + } - public void setCommandTimeout(int plTimeout) { - Dispatch.put(this, "CommandTimeout", new Variant(plTimeout)); - } + public void setCommandTimeout(int plTimeout) { + Dispatch.put(this, "CommandTimeout", new Variant(plTimeout)); + } - public int getConnectionTimeout() { - return Dispatch.get(this, "ConnectionTimeout").getInt(); - } + public int getConnectionTimeout() { + return Dispatch.get(this, "ConnectionTimeout").getInt(); + } - public void setConnectionTimeout(int plTimeout) { - Dispatch.put(this, "ConnectionTimeout", new Variant(plTimeout)); - } + public void setConnectionTimeout(int plTimeout) { + Dispatch.put(this, "ConnectionTimeout", new Variant(plTimeout)); + } - public String getVersion() { - return Dispatch.get(this, "Version").toString(); - } + public String getVersion() { + return Dispatch.get(this, "Version").toString(); + } - public void Close() { - Dispatch.call(this, "Close"); - } + public void Close() { + Dispatch.call(this, "Close"); + } - // how to deal with RecordsAffected being output? - public Variant Execute(String CommandText, Variant RecordsAffected, - int Options) { - return Dispatch.call(this, CommandText, RecordsAffected, new Variant( - Options)); - } + // how to deal with RecordsAffected being output? + public Variant Execute(String CommandText, Variant RecordsAffected, + int Options) { + return Dispatch.call(this, CommandText, RecordsAffected, new Variant( + Options)); + } - public int BeginTrans() { - return Dispatch.call(this, "BeginTrans").getInt(); - } + public int BeginTrans() { + return Dispatch.call(this, "BeginTrans").getInt(); + } - public void CommitTrans() { - Dispatch.call(this, "CommitTrans"); - } + public void CommitTrans() { + Dispatch.call(this, "CommitTrans"); + } - public void RollbackTrans() { - Dispatch.call(this, "RollbackTrans"); - } + public void RollbackTrans() { + Dispatch.call(this, "RollbackTrans"); + } - public void Open(String ConnectionString, String UserID, String Password, - int Options) { - Dispatch.call(this, "Open", ConnectionString, UserID, Password, - new Variant(Options)); - } + public void Open(String ConnectionString, String UserID, String Password, + int Options) { + Dispatch.call(this, "Open", ConnectionString, UserID, Password, + new Variant(Options)); + } - public void Open() { - Dispatch.call(this, "Open"); - } + public void Open() { + Dispatch.call(this, "Open"); + } - public Variant getErrors() { - return Dispatch.get(this, "Errors"); - } + public Variant getErrors() { + return Dispatch.get(this, "Errors"); + } - public String getDefaultDatabase() { - return Dispatch.get(this, "DefaultDatabase").toString(); - } + public String getDefaultDatabase() { + return Dispatch.get(this, "DefaultDatabase").toString(); + } - public void setDefaultDatabase(String pbstr) { - Dispatch.put(this, "DefaultDatabase", pbstr); - } + public void setDefaultDatabase(String pbstr) { + Dispatch.put(this, "DefaultDatabase", pbstr); + } - public int getIsolationLevel() { - return Dispatch.get(this, "IsolationLevel").getInt(); - } + public int getIsolationLevel() { + return Dispatch.get(this, "IsolationLevel").getInt(); + } - public void setIsolationLevel(int Level) { - Dispatch.put(this, "IsolationLevel", new Variant(Level)); - } + public void setIsolationLevel(int Level) { + Dispatch.put(this, "IsolationLevel", new Variant(Level)); + } - public int getAttributes() { - return Dispatch.get(this, "Attributes").getInt(); - } + public int getAttributes() { + return Dispatch.get(this, "Attributes").getInt(); + } - public void setAttributes(int plAttr) { - Dispatch.put(this, "Attributes", new Variant(plAttr)); - } + public void setAttributes(int plAttr) { + Dispatch.put(this, "Attributes", new Variant(plAttr)); + } - public int getCursorLocation() { - return Dispatch.get(this, "CursorLocation").getInt(); - } + public int getCursorLocation() { + return Dispatch.get(this, "CursorLocation").getInt(); + } - public void setCursorLocation(int plCursorLoc) { - Dispatch.put(this, "CursorLocation", new Variant(plCursorLoc)); - } + public void setCursorLocation(int plCursorLoc) { + Dispatch.put(this, "CursorLocation", new Variant(plCursorLoc)); + } - public int getMode() { - return Dispatch.get(this, "Mode").getInt(); - } + public int getMode() { + return Dispatch.get(this, "Mode").getInt(); + } - public void setMode(int plMode) { - Dispatch.put(this, "Mode", new Variant(plMode)); - } + public void setMode(int plMode) { + Dispatch.put(this, "Mode", new Variant(plMode)); + } - public String getProvider() { - return Dispatch.get(this, "Provider").toString(); - } + public String getProvider() { + return Dispatch.get(this, "Provider").toString(); + } - public void setProvider(String pbstr) { - Dispatch.put(this, "Provider", pbstr); - } + public void setProvider(String pbstr) { + Dispatch.put(this, "Provider", pbstr); + } - public int getState() { - return Dispatch.get(this, "State").getInt(); - } + public int getState() { + return Dispatch.get(this, "State").getInt(); + } - public Variant OpenSchema(int Schema, Variant Restrictions, Variant SchemaID) { - return Dispatch.call(this, "OpenSchema", new Variant(Schema), - Restrictions, SchemaID); - } + public Variant OpenSchema(int Schema, Variant Restrictions, Variant SchemaID) { + return Dispatch.call(this, "OpenSchema", new Variant(Schema), + Restrictions, SchemaID); + } - public void Cancel() { - Dispatch.call(this, "Cancel"); - } + public void Cancel() { + Dispatch.call(this, "Cancel"); + } } diff --git a/src/sample/com/jacob/samples/ado/Field.java b/src/sample/com/jacob/samples/ado/Field.java index abb8588..34912d0 100644 --- a/src/sample/com/jacob/samples/ado/Field.java +++ b/src/sample/com/jacob/samples/ado/Field.java @@ -4,98 +4,98 @@ import com.jacob.com.Dispatch; import com.jacob.com.Variant; public class Field extends Dispatch { - /** - * This constructor is used instead of a case operation to turn a Dispatch - * object into a wider object - it must exist in every wrapper class whose - * instances may be returned from method calls wrapped in VT_DISPATCH - * Variants. - */ - public Field(Dispatch d) { - super(d); - } + /** + * This constructor is used instead of a case operation to turn a Dispatch + * object into a wider object - it must exist in every wrapper class whose + * instances may be returned from method calls wrapped in VT_DISPATCH + * Variants. + */ + public Field(Dispatch d) { + super(d); + } - public Variant getProperties() { - return Dispatch.get(this, "Properties"); - } + public Variant getProperties() { + return Dispatch.get(this, "Properties"); + } - public int getActualSize() { - return Dispatch.get(this, "ActualSize").getInt(); - } + public int getActualSize() { + return Dispatch.get(this, "ActualSize").getInt(); + } - public int getAttributes() { - return Dispatch.get(this, "Attributes").getInt(); - } + public int getAttributes() { + return Dispatch.get(this, "Attributes").getInt(); + } - public int getDefinedSize() { - return Dispatch.get(this, "DefinedSize").getInt(); - } + public int getDefinedSize() { + return Dispatch.get(this, "DefinedSize").getInt(); + } - public String getName() { - return Dispatch.get(this, "Name").toString(); - } + public String getName() { + return Dispatch.get(this, "Name").toString(); + } - public int getType() { - return Dispatch.get(this, "Type").getInt(); - } + public int getType() { + return Dispatch.get(this, "Type").getInt(); + } - public Variant getValue() { - return Dispatch.get(this, "Value"); - } + public Variant getValue() { + return Dispatch.get(this, "Value"); + } - public void setValue(Variant pvar) { - Dispatch.put(this, "Value", pvar); - } + public void setValue(Variant pvar) { + Dispatch.put(this, "Value", pvar); + } - public byte getPrecision() { - return Dispatch.get(this, "Precision").getByte(); - } + public byte getPrecision() { + return Dispatch.get(this, "Precision").getByte(); + } - public byte getNumericScale() { - return Dispatch.get(this, "NumericScale").getByte(); - } + public byte getNumericScale() { + return Dispatch.get(this, "NumericScale").getByte(); + } - public void AppendChunk(Variant Data) { - Dispatch.call(this, "AppendChunk", Data); - } + public void AppendChunk(Variant Data) { + Dispatch.call(this, "AppendChunk", Data); + } - public Variant GetChunk(int Length) { - return Dispatch.call(this, "GetChunk", new Variant(Length)); - } + public Variant GetChunk(int Length) { + return Dispatch.call(this, "GetChunk", new Variant(Length)); + } - public Variant getOriginalValue() { - return Dispatch.get(this, "OriginalValue"); - } + public Variant getOriginalValue() { + return Dispatch.get(this, "OriginalValue"); + } - public Variant getUnderlyingValue() { - return Dispatch.get(this, "UnderlyingValue"); - } + public Variant getUnderlyingValue() { + return Dispatch.get(this, "UnderlyingValue"); + } - public Variant getDataFormat() { - return Dispatch.get(this, "DataFormat"); - } + public Variant getDataFormat() { + return Dispatch.get(this, "DataFormat"); + } - public void setDataFormat(Variant ppiDF) { - Dispatch.put(this, "DataFormat", ppiDF); - } + public void setDataFormat(Variant ppiDF) { + Dispatch.put(this, "DataFormat", ppiDF); + } - public void setPrecision(byte pb) { - Dispatch.put(this, "Precision", new Variant(pb)); - } + public void setPrecision(byte pb) { + Dispatch.put(this, "Precision", new Variant(pb)); + } - public void setNumericScale(byte pb) { - Dispatch.put(this, "NumericScale", new Variant(pb)); - } + public void setNumericScale(byte pb) { + Dispatch.put(this, "NumericScale", new Variant(pb)); + } - public void setType(int pDataType) { - Dispatch.put(this, "Type", new Variant(pDataType)); - } + public void setType(int pDataType) { + Dispatch.put(this, "Type", new Variant(pDataType)); + } - public void setDefinedSize(int pl) { - Dispatch.put(this, "DefinedSize", new Variant(pl)); - } + public void setDefinedSize(int pl) { + Dispatch.put(this, "DefinedSize", new Variant(pl)); + } - public void setAttributes(int pl) { - Dispatch.put(this, "Attributes", new Variant(pl)); - } + public void setAttributes(int pl) { + Dispatch.put(this, "Attributes", new Variant(pl)); + } } diff --git a/src/sample/com/jacob/samples/ado/Fields.java b/src/sample/com/jacob/samples/ado/Fields.java index 8676327..96e2495 100644 --- a/src/sample/com/jacob/samples/ado/Fields.java +++ b/src/sample/com/jacob/samples/ado/Fields.java @@ -4,40 +4,40 @@ import com.jacob.com.Dispatch; import com.jacob.com.Variant; public class Fields extends Dispatch { - /** - * This constructor is used instead of a case operation to turn a Dispatch - * object into a wider object - it must exist in every wrapper class whose - * instances may be returned from method calls wrapped in VT_DISPATCH - * Variants. - */ - public Fields(Dispatch d) { - super(d); - } + /** + * This constructor is used instead of a case operation to turn a Dispatch + * object into a wider object - it must exist in every wrapper class whose + * instances may be returned from method calls wrapped in VT_DISPATCH + * Variants. + */ + public Fields(Dispatch d) { + super(d); + } - public int getCount() { - return Dispatch.get(this, "Count").getInt(); - } + public int getCount() { + return Dispatch.get(this, "Count").getInt(); + } - public Variant _NewEnum() { - return Dispatch.call(this, "_NewEnum"); - } + public Variant _NewEnum() { + return Dispatch.call(this, "_NewEnum"); + } - public void Refresh() { - Dispatch.call(this, "Refresh"); - } + public void Refresh() { + Dispatch.call(this, "Refresh"); + } - public Field getItem(int Index) { - return new Field(Dispatch.call(this, "Item", new Variant(Index)) - .toDispatch()); - } + public Field getItem(int Index) { + return new Field(Dispatch.call(this, "Item", new Variant(Index)) + .toDispatch()); + } - public void Append(String Name, int Type, int DefinedSize, int Attrib) { - Dispatch.call(this, "Append", Name, new Variant(Type), new Variant( - DefinedSize), new Variant(Attrib)); - } + public void Append(String Name, int Type, int DefinedSize, int Attrib) { + Dispatch.call(this, "Append", Name, new Variant(Type), new Variant( + DefinedSize), new Variant(Attrib)); + } - public void Delete(Variant Index) { - Dispatch.call(this, "Delete", Index); - } + public void Delete(Variant Index) { + Dispatch.call(this, "Delete", Index); + } } diff --git a/src/sample/com/jacob/samples/ado/Recordset.java b/src/sample/com/jacob/samples/ado/Recordset.java index d0b3019..2d678d9 100644 --- a/src/sample/com/jacob/samples/ado/Recordset.java +++ b/src/sample/com/jacob/samples/ado/Recordset.java @@ -4,339 +4,339 @@ import com.jacob.com.Dispatch; import com.jacob.com.Variant; public class Recordset extends Dispatch { - public Recordset() { - super("ADODB.Recordset"); - } - - /** - * This constructor is used instead of a case operation to turn a Dispatch - * object into a wider object - it must exist in every wrapper class whose - * instances may be returned from method calls wrapped in VT_DISPATCH - * Variants. - */ - public Recordset(Dispatch d) { - super(d); - } - - public Variant getProperties() { - return Dispatch.get(this, "Properties"); - } - - public int getAbsolutePosition() { - return Dispatch.get(this, "AbsolutePosition").getInt(); - } - - public void setAbsolutePosition(int pl) { - Dispatch.put(this, "AbsolutePosition", new Variant(pl)); - } - - public Connection getActiveConnection() { - return new Connection(Dispatch.get(this, "ActiveConnection") - .toDispatch()); - } - - public void setActiveConnection(Connection ppvObject) { - Dispatch.put(this, "ActiveConnection", ppvObject); - } - - public void setActiveConnection(Variant ppvObject) { - Dispatch.put(this, "ActiveConnection", ppvObject); - } - - public boolean getBOF() { - return Dispatch.get(this, "BOF").getBoolean(); - } - - public Variant getBookmark() { - return Dispatch.get(this, "Bookmark"); - } - - public void setBookmark(Variant pvBookmark) { - Dispatch.put(this, "Bookmark", pvBookmark); - } - - public int getCacheSize() { - return Dispatch.get(this, "CacheSize").getInt(); - } - - public void setCacheSize(int pl) { - Dispatch.put(this, "CacheSize", new Variant(pl)); - } - - public int getCursorType() { - return Dispatch.get(this, "CursorType").getInt(); - } - - public void setCursorType(int pl) { - Dispatch.put(this, "CursorType", new Variant(pl)); - } - - public boolean getEOF() { - return Dispatch.get(this, "EOF").getBoolean(); - } - - public Fields getFields() { - return new Fields(Dispatch.get(this, "Fields").toDispatch()); - } - - public int getLockType() { - return Dispatch.get(this, "LockType").getInt(); - } - - public void setLockType(int plLockType) { - Dispatch.put(this, "LockType", new Variant(plLockType)); - } - - public int getMaxRecords() { - return Dispatch.get(this, "MaxRecords").getInt(); - } - - public void setMaxRecords(int pl) { - Dispatch.put(this, "MaxRecords", new Variant(pl)); - } - - public int getRecordCount() { - return Dispatch.get(this, "RecordCount").getInt(); - } - - public void setSource(Object pvSource) { - Dispatch.put(this, "Source", pvSource); - } - - public void setSource(String pvSource) { - Dispatch.put(this, "Source", pvSource); - } - - public Variant getSource() { - return Dispatch.get(this, "Source"); - } - - public void AddNew(Variant FieldList, Variant Values) { - Dispatch.call(this, "AddNew", FieldList, Values); - } - - public void CancelUpdate() { - Dispatch.call(this, "CancelUpdate"); - } - - public void Close() { - Dispatch.call(this, "Close"); - } - - public void Delete(int AffectRecords) { - Dispatch.call(this, "Delete", new Variant(AffectRecords)); - } - - public Variant GetRows(int Rows, Variant Start, Variant Fields) { - return Dispatch.call(this, "GetRows", new Variant(Rows), Start, Fields); - } - - // get all rows - public Variant GetRows() { - return Dispatch.call(this, "GetRows"); - } - - public void Move(int NumRecords, Variant Start) { - Dispatch.call(this, "Move", new Variant(NumRecords), Start); - } - - public void MoveNext() { - Dispatch.call(this, "MoveNext"); - } - - public void MovePrevious() { - Dispatch.call(this, "MovePrevious"); - } - - public void MoveFirst() { - Dispatch.call(this, "MoveFirst"); - } - - public void MoveLast() { - Dispatch.call(this, "MoveLast"); - } - - public void Open(Variant Source, Variant ActiveConnection, int CursorType, - int LockType, int Options) { - Dispatch.call(this, "Open", Source, ActiveConnection, new Variant( - CursorType), new Variant(LockType), new Variant(Options)); - } - - public void Open(Variant Source, Variant ActiveConnection) { - Dispatch.call(this, "Open", Source, ActiveConnection); - } - - public void Requery(int Options) { - Dispatch.call(this, "Requery", new Variant(Options)); - } - - public void Update(Variant Fields, Variant Values) { - Dispatch.call(this, "Update", Fields, Values); - } - - public int getAbsolutePage() { - return Dispatch.get(this, "AbsolutePage").getInt(); - } - - public void setAbsolutePage(int pl) { - Dispatch.put(this, "AbsolutePage", new Variant(pl)); - } - - public int getEditMode() { - return Dispatch.get(this, "EditMode").getInt(); - } - - public Variant getFilter() { - return Dispatch.get(this, "Filter"); - } - - public void setFilter(Variant Criteria) { - Dispatch.put(this, "Filter", Criteria); - } - - public int getPageCount() { - return Dispatch.get(this, "PageCount").getInt(); - } - - public int getPageSize() { - return Dispatch.get(this, "PageSize").getInt(); - } - - public void setPageSize(int pl) { - Dispatch.put(this, "PageSize", new Variant(pl)); - } - - public String getSort() { - return Dispatch.get(this, "Sort").toString(); - } - - public void setSort(String Criteria) { - Dispatch.put(this, "Sort", Criteria); - } - - public int getStatus() { - return Dispatch.get(this, "Status").getInt(); - } - - public int getState() { - return Dispatch.get(this, "State").getInt(); - } - - public void UpdateBatch(int AffectRecords) { - Dispatch.call(this, "UpdateBatch", new Variant(AffectRecords)); - } - - public void CancelBatch(int AffectRecords) { - Dispatch.call(this, "CancelBatch", new Variant(AffectRecords)); - } - - public int getCursorLocation() { - return Dispatch.get(this, "CursorLocation").getInt(); - } - - public void setCursorLocation(int pl) { - Dispatch.put(this, "CursorLocation", new Variant(pl)); - } - - public Recordset NextRecordset(Variant RecordsAffected) { - return new Recordset(Dispatch.call(this, "NextRecordset", - RecordsAffected).toDispatch()); - } - - public boolean Supports(int CursorOptions) { - return Dispatch.call(this, "Supports", new Variant(CursorOptions)) - .getBoolean(); - } - - public Variant getCollect(Variant Index) { - return Dispatch.get(this, "Collect"); - } - - public void setCollect(Variant Index, Variant pvar) { - Dispatch.call(this, "Collect", Index, pvar); - } - - public int getMarshalOptions() { - return Dispatch.get(this, "MarshalOptions").getInt(); - } - - public void setMarshalOptions(int pl) { - Dispatch.put(this, "MarshalOptions", new Variant(pl)); - } - - public void Find(String Criteria, int SkipRecords, int SearchDirection, - Variant Start) { - Dispatch.call(this, "Find", Criteria, new Variant(SkipRecords), - new Variant(SearchDirection), Start); - } - - public void Cancel() { - Dispatch.call(this, "Cancel"); - } - - public Variant getDataSource() { - return Dispatch.get(this, "DataSource"); - } - - public void setDataSource(Variant ppunkDataSource) { - Dispatch.put(this, "DataSource", ppunkDataSource); - } - - public void Save(String FileName, int PersistFormat) { - Dispatch.call(this, "Save", FileName, new Variant(PersistFormat)); - } - - public Variant getActiveCommand() { - return Dispatch.get(this, "ActiveCommand"); - } - - public void setStayInSync(boolean pb) { - Dispatch.put(this, "StayInSync", new Variant(pb)); - } - - public boolean getStayInSync() { - return Dispatch.get(this, "StayInSync").getBoolean(); - } - - public String GetString(int StringFormat, int NumRows, - String ColumnDelimeter, String RowDelimeter, String NullExpr) { - return Dispatch.call(this, "GetString", new Variant(StringFormat), - new Variant(NumRows), ColumnDelimeter, RowDelimeter, NullExpr) - .toString(); - } - - public String getDataMember() { - return Dispatch.get(this, "DataMember").toString(); - } - - public void setDataMember(String pl) { - Dispatch.put(this, "DataMember", new Variant(pl)); - } - - public int CompareBookmarks(Variant Bookmark1, Variant Bookmark2) { - return Dispatch.call(this, "CompareBookmarks", Bookmark1, Bookmark2) - .getInt(); - } - - public Recordset Clone(int LockType) { - return new Recordset(Dispatch - .call(this, "Clone", new Variant(LockType)).toDispatch()); - } - - public void Resync(int AffectRecords, int ResyncValues) { - Dispatch.call(this, "Resync", new Variant(AffectRecords), new Variant( - ResyncValues)); - } - - public void Seek(Variant KeyValues, int SeekOption) { - Dispatch.call(this, "Seek", KeyValues, new Variant(SeekOption)); - } - - public void setIndex(String pl) { - Dispatch.put(this, "Index", new Variant(pl)); - } - - public String getIndex() { - return Dispatch.get(this, "Index)").toString(); - } + public Recordset() { + super("ADODB.Recordset"); + } + + /** + * This constructor is used instead of a case operation to turn a Dispatch + * object into a wider object - it must exist in every wrapper class whose + * instances may be returned from method calls wrapped in VT_DISPATCH + * Variants. + */ + public Recordset(Dispatch d) { + super(d); + } + + public Variant getProperties() { + return Dispatch.get(this, "Properties"); + } + + public int getAbsolutePosition() { + return Dispatch.get(this, "AbsolutePosition").getInt(); + } + + public void setAbsolutePosition(int pl) { + Dispatch.put(this, "AbsolutePosition", new Variant(pl)); + } + + public Connection getActiveConnection() { + return new Connection(Dispatch.get(this, "ActiveConnection") + .toDispatch()); + } + + public void setActiveConnection(Connection ppvObject) { + Dispatch.put(this, "ActiveConnection", ppvObject); + } + + public void setActiveConnection(Variant ppvObject) { + Dispatch.put(this, "ActiveConnection", ppvObject); + } + + public boolean getBOF() { + return Dispatch.get(this, "BOF").getBoolean(); + } + + public Variant getBookmark() { + return Dispatch.get(this, "Bookmark"); + } + + public void setBookmark(Variant pvBookmark) { + Dispatch.put(this, "Bookmark", pvBookmark); + } + + public int getCacheSize() { + return Dispatch.get(this, "CacheSize").getInt(); + } + + public void setCacheSize(int pl) { + Dispatch.put(this, "CacheSize", new Variant(pl)); + } + + public int getCursorType() { + return Dispatch.get(this, "CursorType").getInt(); + } + + public void setCursorType(int pl) { + Dispatch.put(this, "CursorType", new Variant(pl)); + } + + public boolean getEOF() { + return Dispatch.get(this, "EOF").getBoolean(); + } + + public Fields getFields() { + return new Fields(Dispatch.get(this, "Fields").toDispatch()); + } + + public int getLockType() { + return Dispatch.get(this, "LockType").getInt(); + } + + public void setLockType(int plLockType) { + Dispatch.put(this, "LockType", new Variant(plLockType)); + } + + public int getMaxRecords() { + return Dispatch.get(this, "MaxRecords").getInt(); + } + + public void setMaxRecords(int pl) { + Dispatch.put(this, "MaxRecords", new Variant(pl)); + } + + public int getRecordCount() { + return Dispatch.get(this, "RecordCount").getInt(); + } + + public void setSource(Object pvSource) { + Dispatch.put(this, "Source", pvSource); + } + + public void setSource(String pvSource) { + Dispatch.put(this, "Source", pvSource); + } + + public Variant getSource() { + return Dispatch.get(this, "Source"); + } + + public void AddNew(Variant FieldList, Variant Values) { + Dispatch.call(this, "AddNew", FieldList, Values); + } + + public void CancelUpdate() { + Dispatch.call(this, "CancelUpdate"); + } + + public void Close() { + Dispatch.call(this, "Close"); + } + + public void Delete(int AffectRecords) { + Dispatch.call(this, "Delete", new Variant(AffectRecords)); + } + + public Variant GetRows(int Rows, Variant Start, Variant Fields) { + return Dispatch.call(this, "GetRows", new Variant(Rows), Start, Fields); + } + + // get all rows + public Variant GetRows() { + return Dispatch.call(this, "GetRows"); + } + + public void Move(int NumRecords, Variant Start) { + Dispatch.call(this, "Move", new Variant(NumRecords), Start); + } + + public void MoveNext() { + Dispatch.call(this, "MoveNext"); + } + + public void MovePrevious() { + Dispatch.call(this, "MovePrevious"); + } + + public void MoveFirst() { + Dispatch.call(this, "MoveFirst"); + } + + public void MoveLast() { + Dispatch.call(this, "MoveLast"); + } + + public void Open(Variant Source, Variant ActiveConnection, int CursorType, + int LockType, int Options) { + Dispatch.call(this, "Open", Source, ActiveConnection, new Variant( + CursorType), new Variant(LockType), new Variant(Options)); + } + + public void Open(Variant Source, Variant ActiveConnection) { + Dispatch.call(this, "Open", Source, ActiveConnection); + } + + public void Requery(int Options) { + Dispatch.call(this, "Requery", new Variant(Options)); + } + + public void Update(Variant Fields, Variant Values) { + Dispatch.call(this, "Update", Fields, Values); + } + + public int getAbsolutePage() { + return Dispatch.get(this, "AbsolutePage").getInt(); + } + + public void setAbsolutePage(int pl) { + Dispatch.put(this, "AbsolutePage", new Variant(pl)); + } + + public int getEditMode() { + return Dispatch.get(this, "EditMode").getInt(); + } + + public Variant getFilter() { + return Dispatch.get(this, "Filter"); + } + + public void setFilter(Variant Criteria) { + Dispatch.put(this, "Filter", Criteria); + } + + public int getPageCount() { + return Dispatch.get(this, "PageCount").getInt(); + } + + public int getPageSize() { + return Dispatch.get(this, "PageSize").getInt(); + } + + public void setPageSize(int pl) { + Dispatch.put(this, "PageSize", new Variant(pl)); + } + + public String getSort() { + return Dispatch.get(this, "Sort").toString(); + } + + public void setSort(String Criteria) { + Dispatch.put(this, "Sort", Criteria); + } + + public int getStatus() { + return Dispatch.get(this, "Status").getInt(); + } + + public int getState() { + return Dispatch.get(this, "State").getInt(); + } + + public void UpdateBatch(int AffectRecords) { + Dispatch.call(this, "UpdateBatch", new Variant(AffectRecords)); + } + + public void CancelBatch(int AffectRecords) { + Dispatch.call(this, "CancelBatch", new Variant(AffectRecords)); + } + + public int getCursorLocation() { + return Dispatch.get(this, "CursorLocation").getInt(); + } + + public void setCursorLocation(int pl) { + Dispatch.put(this, "CursorLocation", new Variant(pl)); + } + + public Recordset NextRecordset(Variant RecordsAffected) { + return new Recordset(Dispatch.call(this, "NextRecordset", + RecordsAffected).toDispatch()); + } + + public boolean Supports(int CursorOptions) { + return Dispatch.call(this, "Supports", new Variant(CursorOptions)) + .getBoolean(); + } + + public Variant getCollect(Variant Index) { + return Dispatch.get(this, "Collect"); + } + + public void setCollect(Variant Index, Variant pvar) { + Dispatch.call(this, "Collect", Index, pvar); + } + + public int getMarshalOptions() { + return Dispatch.get(this, "MarshalOptions").getInt(); + } + + public void setMarshalOptions(int pl) { + Dispatch.put(this, "MarshalOptions", new Variant(pl)); + } + + public void Find(String Criteria, int SkipRecords, int SearchDirection, + Variant Start) { + Dispatch.call(this, "Find", Criteria, new Variant(SkipRecords), + new Variant(SearchDirection), Start); + } + + public void Cancel() { + Dispatch.call(this, "Cancel"); + } + + public Variant getDataSource() { + return Dispatch.get(this, "DataSource"); + } + + public void setDataSource(Variant ppunkDataSource) { + Dispatch.put(this, "DataSource", ppunkDataSource); + } + + public void Save(String FileName, int PersistFormat) { + Dispatch.call(this, "Save", FileName, new Variant(PersistFormat)); + } + + public Variant getActiveCommand() { + return Dispatch.get(this, "ActiveCommand"); + } + + public void setStayInSync(boolean pb) { + Dispatch.put(this, "StayInSync", new Variant(pb)); + } + + public boolean getStayInSync() { + return Dispatch.get(this, "StayInSync").getBoolean(); + } + + public String GetString(int StringFormat, int NumRows, + String ColumnDelimeter, String RowDelimeter, String NullExpr) { + return Dispatch.call(this, "GetString", new Variant(StringFormat), + new Variant(NumRows), ColumnDelimeter, RowDelimeter, NullExpr) + .toString(); + } + + public String getDataMember() { + return Dispatch.get(this, "DataMember").toString(); + } + + public void setDataMember(String pl) { + Dispatch.put(this, "DataMember", new Variant(pl)); + } + + public int CompareBookmarks(Variant Bookmark1, Variant Bookmark2) { + return Dispatch.call(this, "CompareBookmarks", Bookmark1, Bookmark2) + .getInt(); + } + + public Recordset Clone(int LockType) { + return new Recordset(Dispatch + .call(this, "Clone", new Variant(LockType)).toDispatch()); + } + + public void Resync(int AffectRecords, int ResyncValues) { + Dispatch.call(this, "Resync", new Variant(AffectRecords), new Variant( + ResyncValues)); + } + + public void Seek(Variant KeyValues, int SeekOption) { + Dispatch.call(this, "Seek", KeyValues, new Variant(SeekOption)); + } + + public void setIndex(String pl) { + Dispatch.put(this, "Index", new Variant(pl)); + } + + public String getIndex() { + return Dispatch.get(this, "Index)").toString(); + } } diff --git a/src/sample/com/jacob/samples/ado/test.java b/src/sample/com/jacob/samples/ado/test.java index 7a96568..93d342f 100644 --- a/src/sample/com/jacob/samples/ado/test.java +++ b/src/sample/com/jacob/samples/ado/test.java @@ -3,54 +3,54 @@ package com.jacob.samples.ado; import com.jacob.com.Variant; public class test { - public static void printRS(Recordset rs) { - Fields fs = rs.getFields(); + public static void printRS(Recordset rs) { + Fields fs = rs.getFields(); - for (int i = 0; i < fs.getCount(); i++) { - System.out.print(fs.getItem(i).getName() + " "); - } - System.out.println(""); + for (int i = 0; i < fs.getCount(); i++) { + System.out.print(fs.getItem(i).getName() + " "); + } + System.out.println(""); - rs.MoveFirst(); - while (!rs.getEOF()) { - for (int i = 0; i < fs.getCount(); i++) { - Field f = fs.getItem(i); - Variant v = f.getValue(); - System.out.print(v + " "); - } - System.out.println(""); - rs.MoveNext(); - } - } + rs.MoveFirst(); + while (!rs.getEOF()) { + for (int i = 0; i < fs.getCount(); i++) { + Field f = fs.getItem(i); + Variant v = f.getValue(); + System.out.print(v + " "); + } + System.out.println(""); + rs.MoveNext(); + } + } - // open a recordset directly - public static void getRS(String con, String query) { - System.out.println("Recordset Open"); - Recordset rs = new Recordset(); - rs.Open(new Variant(query), new Variant(con)); - printRS(rs); - } + // open a recordset directly + public static void getRS(String con, String query) { + System.out.println("Recordset Open"); + Recordset rs = new Recordset(); + rs.Open(new Variant(query), new Variant(con)); + printRS(rs); + } - // create connection and command objects and use them - // to get a recordset - public static void getCommand(String con, String query) { - System.out.println("Command+Connection -> Recordset"); - Connection c = new Connection(); - c.setConnectionString(con); - c.Open(); - Command comm = new Command(); - comm.setActiveConnection(c); - comm.setCommandType(CommandTypeEnum.adCmdText); - comm.setCommandText(query); - Recordset rs = comm.Execute(); - printRS(rs); - c.Close(); - } + // create connection and command objects and use them + // to get a recordset + public static void getCommand(String con, String query) { + System.out.println("Command+Connection -> Recordset"); + Connection c = new Connection(); + c.setConnectionString(con); + c.Open(); + Command comm = new Command(); + comm.setActiveConnection(c); + comm.setCommandType(CommandTypeEnum.adCmdText); + comm.setCommandText(query); + Recordset rs = comm.Execute(); + printRS(rs); + c.Close(); + } - public static void main(String[] args) { - String connectStr = "DRIVER=SQL Server;SERVER=DANADLER;UID=sa;PWD=;WSID=DANADLER;DATABASE=pubs"; - String queryStr = "select * from authors"; - getCommand(connectStr, queryStr); - getRS(connectStr, queryStr); - } + public static void main(String[] args) { + String connectStr = "DRIVER=SQL Server;SERVER=DANADLER;UID=sa;PWD=;WSID=DANADLER;DATABASE=pubs"; + String queryStr = "select * from authors"; + getCommand(connectStr, queryStr); + getRS(connectStr, queryStr); + } } diff --git a/src/sample/com/jacob/samples/applet/JacobTestApplet.java b/src/sample/com/jacob/samples/applet/JacobTestApplet.java index 6e7b4d3..27bb11b 100644 --- a/src/sample/com/jacob/samples/applet/JacobTestApplet.java +++ b/src/sample/com/jacob/samples/applet/JacobTestApplet.java @@ -26,63 +26,63 @@ import com.jacob.com.Variant; public class JacobTestApplet extends Applet implements ActionListener { - private static final long serialVersionUID = 4492492907986849158L; + private static final long serialVersionUID = 4492492907986849158L; - TextField in; - TextField out; - Button calc; - ActiveXComponent sC = null; + TextField in; + TextField out; + Button calc; + ActiveXComponent sC = null; - /** - * startup method - */ - @Override - public void init() { - setLayout(new FlowLayout()); - add(this.in = new TextField("1+1", 16)); - add(this.out = new TextField("?", 16)); - add(this.calc = new Button("Calculate")); - this.calc.addActionListener(this); + /** + * startup method + */ + @Override + public void init() { + setLayout(new FlowLayout()); + add(this.in = new TextField("1+1", 16)); + add(this.out = new TextField("?", 16)); + add(this.calc = new Button("Calculate")); + this.calc.addActionListener(this); - } + } - /** - * Returns information about this applet. - * According to the java spec: - * "An applet should override this method to return a String containing information about the author, version, and copyright of the applet." - * - * @return information about the applet. - */ - @Override - public String getAppletInfo() { - return "Jacob Test Applet. Written by ttreeck, nepatec GmbH & Co. KG.\nhttp://www.nepatec.de"; - } - - /** - * Returns information about the parameters that are understood by this applet. - * According to the java spec: - * "An applet should override this method to return an array of Strings describing these parameters." - * - * @return array with a set of three Strings containing the name, the type, and a description. - */ + /** + * Returns information about this applet. + * According to the java spec: + * "An applet should override this method to return a String containing information about the author, version, and copyright of the applet." + * + * @return information about the applet. + */ + @Override + public String getAppletInfo() { + return "Jacob Test Applet. Written by ttreeck, nepatec GmbH & Co. KG.\nhttp://www.nepatec.de"; + } + + /** + * Returns information about the parameters that are understood by this applet. + * According to the java spec: + * "An applet should override this method to return an array of Strings describing these parameters." + * + * @return array with a set of three Strings containing the name, the type, and a description. + */ - @Override - public String[][] getParameterInfo(){ + @Override + public String[][] getParameterInfo(){ return new String[][]{}; - } + } - /** - * action method that receives button actions - * - * @param ev the event - */ - public void actionPerformed(ActionEvent ev) { - if (this.sC == null) { - String lang = "VBScript"; - this.sC = new ActiveXComponent("ScriptControl"); - Dispatch.put(this.sC, "Language", lang); - } - Variant v = Dispatch.call(this.sC, "Eval", this.in.getText()); - this.out.setText(v.toString()); - } + /** + * action method that receives button actions + * + * @param ev the event + */ + public void actionPerformed(ActionEvent ev) { + if (this.sC == null) { + String lang = "VBScript"; + this.sC = new ActiveXComponent("ScriptControl"); + Dispatch.put(this.sC, "Language", lang); + } + Variant v = Dispatch.call(this.sC, "Eval", this.in.getText()); + this.out.setText(v.toString()); + } } \ No newline at end of file diff --git a/src/sample/com/jacob/samples/atl/MultiFace/Face.cpp b/src/sample/com/jacob/samples/atl/MultiFace/Face.cpp index 836fbbd..69e5be3 100644 --- a/src/sample/com/jacob/samples/atl/MultiFace/Face.cpp +++ b/src/sample/com/jacob/samples/atl/MultiFace/Face.cpp @@ -9,59 +9,59 @@ STDMETHODIMP Face::InterfaceSupportsErrorInfo(REFIID riid) { - static const IID* arr[] = - { - &IID_IFace1, - &IID_IFace2, - &IID_IFace3, - }; + static const IID* arr[] = + { + &IID_IFace1, + &IID_IFace2, + &IID_IFace3, + }; - for (int i=0;i, - public IDispatchImpl, - public IDispatchImpl, - public ISupportErrorInfo, - public CComObjectRoot, - public CComCoClass + public IDispatchImpl, + public IDispatchImpl, + public IDispatchImpl, + public ISupportErrorInfo, + public CComObjectRoot, + public CComCoClass { // IFace1 private: CComBSTR name1; // IFace2 - CComBSTR name2; + CComBSTR name2; // IFace3 - CComBSTR name3; + CComBSTR name3; public: - Face() {} + Face() {} BEGIN_COM_MAP(Face) - COM_INTERFACE_ENTRY2(IDispatch, IFace1) - COM_INTERFACE_ENTRY(IFace1) - COM_INTERFACE_ENTRY(IFace2) - COM_INTERFACE_ENTRY(IFace3) - COM_INTERFACE_ENTRY(ISupportErrorInfo) + COM_INTERFACE_ENTRY2(IDispatch, IFace1) + COM_INTERFACE_ENTRY(IFace1) + COM_INTERFACE_ENTRY(IFace2) + COM_INTERFACE_ENTRY(IFace3) + COM_INTERFACE_ENTRY(ISupportErrorInfo) END_COM_MAP() //DECLARE_NOT_AGGREGATABLE(Face) // Remove the comment from the line above if you don't want your object to @@ -47,17 +47,17 @@ END_COM_MAP() DECLARE_REGISTRY_RESOURCEID(IDR_Face) // ISupportsErrorInfo - STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid); + STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid); public: - STDMETHOD(get_Face3Name)(/*[out, retval]*/ BSTR *pVal); - STDMETHOD(put_Face3Name)(/*[in]*/ BSTR newVal); - STDMETHOD(get_Face2Nam)(/*[out, retval]*/ BSTR *pVal); - STDMETHOD(put_Face2Nam)(/*[in]*/ BSTR newVal); - STDMETHOD(get_Face1Name)(/*[out, retval]*/ BSTR *pVal); - STDMETHOD(put_Face1Name)(/*[in]*/ BSTR newVal); + STDMETHOD(get_Face3Name)(/*[out, retval]*/ BSTR *pVal); + STDMETHOD(put_Face3Name)(/*[in]*/ BSTR newVal); + STDMETHOD(get_Face2Nam)(/*[out, retval]*/ BSTR *pVal); + STDMETHOD(put_Face2Nam)(/*[in]*/ BSTR newVal); + STDMETHOD(get_Face1Name)(/*[out, retval]*/ BSTR *pVal); + STDMETHOD(put_Face1Name)(/*[in]*/ BSTR newVal); }; #endif // !defined(AFX_FACE_H__9BF24413_B2E0_11D4_A695_00104BFF3241__INCLUDED_) diff --git a/src/sample/com/jacob/samples/atl/MultiFace/MultiFace.h b/src/sample/com/jacob/samples/atl/MultiFace/MultiFace.h index 7b976ee..56b1ae3 100644 --- a/src/sample/com/jacob/samples/atl/MultiFace/MultiFace.h +++ b/src/sample/com/jacob/samples/atl/MultiFace/MultiFace.h @@ -40,19 +40,19 @@ extern "C"{ #ifndef __IFace1_FWD_DEFINED__ #define __IFace1_FWD_DEFINED__ typedef interface IFace1 IFace1; -#endif /* __IFace1_FWD_DEFINED__ */ +#endif /* __IFace1_FWD_DEFINED__ */ #ifndef __IFace2_FWD_DEFINED__ #define __IFace2_FWD_DEFINED__ typedef interface IFace2 IFace2; -#endif /* __IFace2_FWD_DEFINED__ */ +#endif /* __IFace2_FWD_DEFINED__ */ #ifndef __IFace3_FWD_DEFINED__ #define __IFace3_FWD_DEFINED__ typedef interface IFace3 IFace3; -#endif /* __IFace3_FWD_DEFINED__ */ +#endif /* __IFace3_FWD_DEFINED__ */ #ifndef __Face_FWD_DEFINED__ @@ -64,7 +64,7 @@ typedef class Face Face; typedef struct Face Face; #endif /* __cplusplus */ -#endif /* __Face_FWD_DEFINED__ */ +#endif /* __Face_FWD_DEFINED__ */ /* header files for imported files */ @@ -97,7 +97,7 @@ EXTERN_C const IID IID_IFace1; }; -#else /* C style interface */ +#else /* C style interface */ typedef struct IFace1Vtbl { @@ -164,39 +164,39 @@ EXTERN_C const IID IID_IFace1; #ifdef COBJMACROS -#define IFace1_QueryInterface(This,riid,ppvObject) \ +#define IFace1_QueryInterface(This,riid,ppvObject) \ (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) -#define IFace1_AddRef(This) \ +#define IFace1_AddRef(This) \ (This)->lpVtbl -> AddRef(This) -#define IFace1_Release(This) \ +#define IFace1_Release(This) \ (This)->lpVtbl -> Release(This) -#define IFace1_GetTypeInfoCount(This,pctinfo) \ +#define IFace1_GetTypeInfoCount(This,pctinfo) \ (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) -#define IFace1_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ +#define IFace1_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) -#define IFace1_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ +#define IFace1_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) -#define IFace1_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ +#define IFace1_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) -#define IFace1_get_Face1Name(This,pVal) \ +#define IFace1_get_Face1Name(This,pVal) \ (This)->lpVtbl -> get_Face1Name(This,pVal) -#define IFace1_put_Face1Name(This,newVal) \ +#define IFace1_put_Face1Name(This,newVal) \ (This)->lpVtbl -> put_Face1Name(This,newVal) #endif /* COBJMACROS */ -#endif /* C style interface */ +#endif /* C style interface */ @@ -225,7 +225,7 @@ void __RPC_STUB IFace1_put_Face1Name_Stub( -#endif /* __IFace1_INTERFACE_DEFINED__ */ +#endif /* __IFace1_INTERFACE_DEFINED__ */ #ifndef __IFace2_INTERFACE_DEFINED__ @@ -251,7 +251,7 @@ EXTERN_C const IID IID_IFace2; }; -#else /* C style interface */ +#else /* C style interface */ typedef struct IFace2Vtbl { @@ -318,39 +318,39 @@ EXTERN_C const IID IID_IFace2; #ifdef COBJMACROS -#define IFace2_QueryInterface(This,riid,ppvObject) \ +#define IFace2_QueryInterface(This,riid,ppvObject) \ (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) -#define IFace2_AddRef(This) \ +#define IFace2_AddRef(This) \ (This)->lpVtbl -> AddRef(This) -#define IFace2_Release(This) \ +#define IFace2_Release(This) \ (This)->lpVtbl -> Release(This) -#define IFace2_GetTypeInfoCount(This,pctinfo) \ +#define IFace2_GetTypeInfoCount(This,pctinfo) \ (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) -#define IFace2_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ +#define IFace2_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) -#define IFace2_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ +#define IFace2_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) -#define IFace2_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ +#define IFace2_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) -#define IFace2_get_Face2Nam(This,pVal) \ +#define IFace2_get_Face2Nam(This,pVal) \ (This)->lpVtbl -> get_Face2Nam(This,pVal) -#define IFace2_put_Face2Nam(This,newVal) \ +#define IFace2_put_Face2Nam(This,newVal) \ (This)->lpVtbl -> put_Face2Nam(This,newVal) #endif /* COBJMACROS */ -#endif /* C style interface */ +#endif /* C style interface */ @@ -379,7 +379,7 @@ void __RPC_STUB IFace2_put_Face2Nam_Stub( -#endif /* __IFace2_INTERFACE_DEFINED__ */ +#endif /* __IFace2_INTERFACE_DEFINED__ */ #ifndef __IFace3_INTERFACE_DEFINED__ @@ -405,7 +405,7 @@ EXTERN_C const IID IID_IFace3; }; -#else /* C style interface */ +#else /* C style interface */ typedef struct IFace3Vtbl { @@ -472,39 +472,39 @@ EXTERN_C const IID IID_IFace3; #ifdef COBJMACROS -#define IFace3_QueryInterface(This,riid,ppvObject) \ +#define IFace3_QueryInterface(This,riid,ppvObject) \ (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) -#define IFace3_AddRef(This) \ +#define IFace3_AddRef(This) \ (This)->lpVtbl -> AddRef(This) -#define IFace3_Release(This) \ +#define IFace3_Release(This) \ (This)->lpVtbl -> Release(This) -#define IFace3_GetTypeInfoCount(This,pctinfo) \ +#define IFace3_GetTypeInfoCount(This,pctinfo) \ (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) -#define IFace3_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ +#define IFace3_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) -#define IFace3_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ +#define IFace3_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) -#define IFace3_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ +#define IFace3_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) -#define IFace3_get_Face3Name(This,pVal) \ +#define IFace3_get_Face3Name(This,pVal) \ (This)->lpVtbl -> get_Face3Name(This,pVal) -#define IFace3_put_Face3Name(This,newVal) \ +#define IFace3_put_Face3Name(This,newVal) \ (This)->lpVtbl -> put_Face3Name(This,newVal) #endif /* COBJMACROS */ -#endif /* C style interface */ +#endif /* C style interface */ @@ -533,7 +533,7 @@ void __RPC_STUB IFace3_put_Face3Name_Stub( -#endif /* __IFace3_INTERFACE_DEFINED__ */ +#endif /* __IFace3_INTERFACE_DEFINED__ */ diff --git a/src/sample/com/jacob/samples/atl/MultiFace/MultiFace_p.c b/src/sample/com/jacob/samples/atl/MultiFace/MultiFace_p.c index 58b87e7..5086219 100644 --- a/src/sample/com/jacob/samples/atl/MultiFace/MultiFace_p.c +++ b/src/sample/com/jacob/samples/atl/MultiFace/MultiFace_p.c @@ -346,117 +346,117 @@ static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString = 0, { - /* Procedure get_Face3Name */ + /* Procedure get_Face3Name */ - /* Procedure get_Face2Nam */ + /* Procedure get_Face2Nam */ - /* Procedure get_Face1Name */ + /* Procedure get_Face1Name */ - 0x33, /* FC_AUTO_HANDLE */ - 0x6c, /* Old Flags: object, Oi2 */ -/* 2 */ NdrFcLong( 0x0 ), /* 0 */ -/* 6 */ NdrFcShort( 0x7 ), /* 7 */ + 0x33, /* FC_AUTO_HANDLE */ + 0x6c, /* Old Flags: object, Oi2 */ +/* 2 */ NdrFcLong( 0x0 ), /* 0 */ +/* 6 */ NdrFcShort( 0x7 ), /* 7 */ #ifndef _ALPHA_ -/* 8 */ NdrFcShort( 0xc ), /* x86, MIPS, PPC Stack size/offset = 12 */ +/* 8 */ NdrFcShort( 0xc ), /* x86, MIPS, PPC Stack size/offset = 12 */ #else - NdrFcShort( 0x18 ), /* Alpha Stack size/offset = 24 */ + NdrFcShort( 0x18 ), /* Alpha Stack size/offset = 24 */ #endif -/* 10 */ NdrFcShort( 0x0 ), /* 0 */ -/* 12 */ NdrFcShort( 0x8 ), /* 8 */ -/* 14 */ 0x5, /* Oi2 Flags: srv must size, has return, */ - 0x2, /* 2 */ +/* 10 */ NdrFcShort( 0x0 ), /* 0 */ +/* 12 */ NdrFcShort( 0x8 ), /* 8 */ +/* 14 */ 0x5, /* Oi2 Flags: srv must size, has return, */ + 0x2, /* 2 */ - /* Parameter pVal */ + /* Parameter pVal */ - /* Parameter pVal */ + /* Parameter pVal */ - /* Parameter pVal */ + /* Parameter pVal */ -/* 16 */ NdrFcShort( 0x2113 ), /* Flags: must size, must free, out, simple ref, srv alloc size=8 */ +/* 16 */ NdrFcShort( 0x2113 ), /* Flags: must size, must free, out, simple ref, srv alloc size=8 */ #ifndef _ALPHA_ -/* 18 */ NdrFcShort( 0x4 ), /* x86, MIPS, PPC Stack size/offset = 4 */ +/* 18 */ NdrFcShort( 0x4 ), /* x86, MIPS, PPC Stack size/offset = 4 */ #else - NdrFcShort( 0x8 ), /* Alpha Stack size/offset = 8 */ + NdrFcShort( 0x8 ), /* Alpha Stack size/offset = 8 */ #endif -/* 20 */ NdrFcShort( 0x1e ), /* Type Offset=30 */ +/* 20 */ NdrFcShort( 0x1e ), /* Type Offset=30 */ - /* Return value */ + /* Return value */ - /* Return value */ + /* Return value */ - /* Return value */ + /* Return value */ -/* 22 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 22 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ #ifndef _ALPHA_ -/* 24 */ NdrFcShort( 0x8 ), /* x86, MIPS, PPC Stack size/offset = 8 */ +/* 24 */ NdrFcShort( 0x8 ), /* x86, MIPS, PPC Stack size/offset = 8 */ #else - NdrFcShort( 0x10 ), /* Alpha Stack size/offset = 16 */ + NdrFcShort( 0x10 ), /* Alpha Stack size/offset = 16 */ #endif -/* 26 */ 0x8, /* FC_LONG */ - 0x0, /* 0 */ +/* 26 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ - /* Procedure put_Face3Name */ + /* Procedure put_Face3Name */ - /* Procedure put_Face2Nam */ + /* Procedure put_Face2Nam */ - /* Procedure put_Face1Name */ + /* Procedure put_Face1Name */ -/* 28 */ 0x33, /* FC_AUTO_HANDLE */ - 0x6c, /* Old Flags: object, Oi2 */ -/* 30 */ NdrFcLong( 0x0 ), /* 0 */ -/* 34 */ NdrFcShort( 0x8 ), /* 8 */ +/* 28 */ 0x33, /* FC_AUTO_HANDLE */ + 0x6c, /* Old Flags: object, Oi2 */ +/* 30 */ NdrFcLong( 0x0 ), /* 0 */ +/* 34 */ NdrFcShort( 0x8 ), /* 8 */ #ifndef _ALPHA_ -/* 36 */ NdrFcShort( 0xc ), /* x86, MIPS, PPC Stack size/offset = 12 */ +/* 36 */ NdrFcShort( 0xc ), /* x86, MIPS, PPC Stack size/offset = 12 */ #else - NdrFcShort( 0x18 ), /* Alpha Stack size/offset = 24 */ + NdrFcShort( 0x18 ), /* Alpha Stack size/offset = 24 */ #endif -/* 38 */ NdrFcShort( 0x0 ), /* 0 */ -/* 40 */ NdrFcShort( 0x8 ), /* 8 */ -/* 42 */ 0x6, /* Oi2 Flags: clt must size, has return, */ - 0x2, /* 2 */ +/* 38 */ NdrFcShort( 0x0 ), /* 0 */ +/* 40 */ NdrFcShort( 0x8 ), /* 8 */ +/* 42 */ 0x6, /* Oi2 Flags: clt must size, has return, */ + 0x2, /* 2 */ - /* Parameter newVal */ + /* Parameter newVal */ - /* Parameter newVal */ + /* Parameter newVal */ - /* Parameter newVal */ + /* Parameter newVal */ -/* 44 */ NdrFcShort( 0x8b ), /* Flags: must size, must free, in, by val, */ +/* 44 */ NdrFcShort( 0x8b ), /* Flags: must size, must free, in, by val, */ #ifndef _ALPHA_ -/* 46 */ NdrFcShort( 0x4 ), /* x86, MIPS, PPC Stack size/offset = 4 */ +/* 46 */ NdrFcShort( 0x4 ), /* x86, MIPS, PPC Stack size/offset = 4 */ #else - NdrFcShort( 0x8 ), /* Alpha Stack size/offset = 8 */ + NdrFcShort( 0x8 ), /* Alpha Stack size/offset = 8 */ #endif -/* 48 */ NdrFcShort( 0x2c ), /* Type Offset=44 */ +/* 48 */ NdrFcShort( 0x2c ), /* Type Offset=44 */ - /* Return value */ + /* Return value */ - /* Return value */ + /* Return value */ - /* Return value */ + /* Return value */ -/* 50 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 50 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ #ifndef _ALPHA_ -/* 52 */ NdrFcShort( 0x8 ), /* x86, MIPS, PPC Stack size/offset = 8 */ +/* 52 */ NdrFcShort( 0x8 ), /* x86, MIPS, PPC Stack size/offset = 8 */ #else - NdrFcShort( 0x10 ), /* Alpha Stack size/offset = 16 */ + NdrFcShort( 0x10 ), /* Alpha Stack size/offset = 16 */ #endif -/* 54 */ 0x8, /* FC_LONG */ - 0x0, /* 0 */ +/* 54 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ - 0x0 + 0x0 } }; @@ -464,48 +464,48 @@ static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString = { 0, { - NdrFcShort( 0x0 ), /* 0 */ -/* 2 */ - 0x11, 0x4, /* FC_RP [alloced_on_stack] */ -/* 4 */ NdrFcShort( 0x1a ), /* Offset= 26 (30) */ -/* 6 */ - 0x13, 0x0, /* FC_OP */ -/* 8 */ NdrFcShort( 0xc ), /* Offset= 12 (20) */ -/* 10 */ - 0x1b, /* FC_CARRAY */ - 0x1, /* 1 */ -/* 12 */ NdrFcShort( 0x2 ), /* 2 */ -/* 14 */ 0x9, /* Corr desc: FC_ULONG */ - 0x0, /* */ -/* 16 */ NdrFcShort( 0xfffc ), /* -4 */ -/* 18 */ 0x6, /* FC_SHORT */ - 0x5b, /* FC_END */ -/* 20 */ - 0x17, /* FC_CSTRUCT */ - 0x3, /* 3 */ -/* 22 */ NdrFcShort( 0x8 ), /* 8 */ -/* 24 */ NdrFcShort( 0xfffffff2 ), /* Offset= -14 (10) */ -/* 26 */ 0x8, /* FC_LONG */ - 0x8, /* FC_LONG */ -/* 28 */ 0x5c, /* FC_PAD */ - 0x5b, /* FC_END */ -/* 30 */ 0xb4, /* FC_USER_MARSHAL */ - 0x83, /* 131 */ -/* 32 */ NdrFcShort( 0x0 ), /* 0 */ -/* 34 */ NdrFcShort( 0x4 ), /* 4 */ -/* 36 */ NdrFcShort( 0x0 ), /* 0 */ -/* 38 */ NdrFcShort( 0xffffffe0 ), /* Offset= -32 (6) */ -/* 40 */ - 0x12, 0x0, /* FC_UP */ -/* 42 */ NdrFcShort( 0xffffffea ), /* Offset= -22 (20) */ -/* 44 */ 0xb4, /* FC_USER_MARSHAL */ - 0x83, /* 131 */ -/* 46 */ NdrFcShort( 0x0 ), /* 0 */ -/* 48 */ NdrFcShort( 0x4 ), /* 4 */ -/* 50 */ NdrFcShort( 0x0 ), /* 0 */ -/* 52 */ NdrFcShort( 0xfffffff4 ), /* Offset= -12 (40) */ + NdrFcShort( 0x0 ), /* 0 */ +/* 2 */ + 0x11, 0x4, /* FC_RP [alloced_on_stack] */ +/* 4 */ NdrFcShort( 0x1a ), /* Offset= 26 (30) */ +/* 6 */ + 0x13, 0x0, /* FC_OP */ +/* 8 */ NdrFcShort( 0xc ), /* Offset= 12 (20) */ +/* 10 */ + 0x1b, /* FC_CARRAY */ + 0x1, /* 1 */ +/* 12 */ NdrFcShort( 0x2 ), /* 2 */ +/* 14 */ 0x9, /* Corr desc: FC_ULONG */ + 0x0, /* */ +/* 16 */ NdrFcShort( 0xfffc ), /* -4 */ +/* 18 */ 0x6, /* FC_SHORT */ + 0x5b, /* FC_END */ +/* 20 */ + 0x17, /* FC_CSTRUCT */ + 0x3, /* 3 */ +/* 22 */ NdrFcShort( 0x8 ), /* 8 */ +/* 24 */ NdrFcShort( 0xfffffff2 ), /* Offset= -14 (10) */ +/* 26 */ 0x8, /* FC_LONG */ + 0x8, /* FC_LONG */ +/* 28 */ 0x5c, /* FC_PAD */ + 0x5b, /* FC_END */ +/* 30 */ 0xb4, /* FC_USER_MARSHAL */ + 0x83, /* 131 */ +/* 32 */ NdrFcShort( 0x0 ), /* 0 */ +/* 34 */ NdrFcShort( 0x4 ), /* 4 */ +/* 36 */ NdrFcShort( 0x0 ), /* 0 */ +/* 38 */ NdrFcShort( 0xffffffe0 ), /* Offset= -32 (6) */ +/* 40 */ + 0x12, 0x0, /* FC_UP */ +/* 42 */ NdrFcShort( 0xffffffea ), /* Offset= -22 (20) */ +/* 44 */ 0xb4, /* FC_USER_MARSHAL */ + 0x83, /* 131 */ +/* 46 */ NdrFcShort( 0x0 ), /* 0 */ +/* 48 */ NdrFcShort( 0x4 ), /* 4 */ +/* 50 */ NdrFcShort( 0x0 ), /* 0 */ +/* 52 */ NdrFcShort( 0xfffffff4 ), /* Offset= -12 (40) */ - 0x0 + 0x0 } }; @@ -542,7 +542,7 @@ const IID * _MultiFace_BaseIIDList[] = }; -#define _MultiFace_CHECK_IID(n) IID_GENERIC_CHECK_IID( _MultiFace, pIID, n) +#define _MultiFace_CHECK_IID(n) IID_GENERIC_CHECK_IID( _MultiFace, pIID, n) int __stdcall _MultiFace_IID_Lookup( const IID * pIID, int * pIndex ) { diff --git a/src/sample/com/jacob/samples/atl/MultiFaceTest.java b/src/sample/com/jacob/samples/atl/MultiFaceTest.java index fc64923..809bae8 100644 --- a/src/sample/com/jacob/samples/atl/MultiFaceTest.java +++ b/src/sample/com/jacob/samples/atl/MultiFaceTest.java @@ -6,41 +6,41 @@ import com.jacob.com.Variant; class MultiFaceTest { - /** - * standard main() test program - * - * @param args - * the command line arguments - */ - public static void main(String[] args) { - // this method has been deprecated as being unreliable. - // shutdown should be done through other means - // whoever wrote this example should explain what this was intended to - // do - // System.runFinalizersOnExit(true); + /** + * standard main() test program + * + * @param args + * the command line arguments + */ + public static void main(String[] args) { + // this method has been deprecated as being unreliable. + // shutdown should be done through other means + // whoever wrote this example should explain what this was intended to + // do + // System.runFinalizersOnExit(true); - ActiveXComponent mf = new ActiveXComponent("MultiFace.Face"); - try { - // I am now dealing with the default interface (IFace1) - Dispatch.put(mf, "Face1Name", new Variant("Hello Face1")); - System.out.println(Dispatch.get(mf, "Face1Name")); + ActiveXComponent mf = new ActiveXComponent("MultiFace.Face"); + try { + // I am now dealing with the default interface (IFace1) + Dispatch.put(mf, "Face1Name", new Variant("Hello Face1")); + System.out.println(Dispatch.get(mf, "Face1Name")); - // get to IFace2 through the IID - Dispatch f2 = mf - .QueryInterface("{9BF24410-B2E0-11D4-A695-00104BFF3241}"); - // I am now dealing with IFace2 - Dispatch.put(f2, "Face2Nam", new Variant("Hello Face2")); - System.out.println(Dispatch.get(f2, "Face2Nam")); + // get to IFace2 through the IID + Dispatch f2 = mf + .QueryInterface("{9BF24410-B2E0-11D4-A695-00104BFF3241}"); + // I am now dealing with IFace2 + Dispatch.put(f2, "Face2Nam", new Variant("Hello Face2")); + System.out.println(Dispatch.get(f2, "Face2Nam")); - // get to IFace3 through the IID - Dispatch f3 = mf - .QueryInterface("{9BF24411-B2E0-11D4-A695-00104BFF3241}"); - // I am now dealing with IFace3 - Dispatch.put(f3, "Face3Name", new Variant("Hello Face3")); - System.out.println(Dispatch.get(f3, "Face3Name")); + // get to IFace3 through the IID + Dispatch f3 = mf + .QueryInterface("{9BF24411-B2E0-11D4-A695-00104BFF3241}"); + // I am now dealing with IFace3 + Dispatch.put(f3, "Face3Name", new Variant("Hello Face3")); + System.out.println(Dispatch.get(f3, "Face3Name")); - } catch (Exception e) { - e.printStackTrace(); - } - } + } catch (Exception e) { + e.printStackTrace(); + } + } } diff --git a/src/sample/com/jacob/samples/office/ExcelDispatchTest.java b/src/sample/com/jacob/samples/office/ExcelDispatchTest.java index fea6229..9a7081c 100644 --- a/src/sample/com/jacob/samples/office/ExcelDispatchTest.java +++ b/src/sample/com/jacob/samples/office/ExcelDispatchTest.java @@ -14,39 +14,39 @@ import com.jacob.com.Variant; */ public class ExcelDispatchTest { - /** - * main run loop for test program - * - * @param args - * standard command line arguments - */ - public static void main(String[] args) { - ComThread.InitSTA(); + /** + * main run loop for test program + * + * @param args + * standard command line arguments + */ + public static void main(String[] args) { + ComThread.InitSTA(); - ActiveXComponent xl = new ActiveXComponent("Excel.Application"); - try { - System.out.println("version=" + xl.getProperty("Version")); - System.out.println("version=" + Dispatch.get(xl, "Version")); - Dispatch.put(xl, "Visible", new Variant(true)); - Dispatch workbooks = xl.getProperty("Workbooks").toDispatch(); - Dispatch workbook = Dispatch.get(workbooks, "Add").toDispatch(); - Dispatch sheet = Dispatch.get(workbook, "ActiveSheet").toDispatch(); - Dispatch a1 = Dispatch.invoke(sheet, "Range", Dispatch.Get, - new Object[] { "A1" }, new int[1]).toDispatch(); - Dispatch a2 = Dispatch.invoke(sheet, "Range", Dispatch.Get, - new Object[] { "A2" }, new int[1]).toDispatch(); - Dispatch.put(a1, "Value", "123.456"); - Dispatch.put(a2, "Formula", "=A1*2"); - System.out.println("a1 from excel:" + Dispatch.get(a1, "Value")); - System.out.println("a2 from excel:" + Dispatch.get(a2, "Value")); - Variant f = new Variant(false); - Dispatch.call(workbook, "Close", f); - } catch (Exception e) { - e.printStackTrace(); - } finally { - xl.invoke("Quit", new Variant[] {}); - ComThread.Release(); - } - } + ActiveXComponent xl = new ActiveXComponent("Excel.Application"); + try { + System.out.println("version=" + xl.getProperty("Version")); + System.out.println("version=" + Dispatch.get(xl, "Version")); + Dispatch.put(xl, "Visible", new Variant(true)); + Dispatch workbooks = xl.getProperty("Workbooks").toDispatch(); + Dispatch workbook = Dispatch.get(workbooks, "Add").toDispatch(); + Dispatch sheet = Dispatch.get(workbook, "ActiveSheet").toDispatch(); + Dispatch a1 = Dispatch.invoke(sheet, "Range", Dispatch.Get, + new Object[] { "A1" }, new int[1]).toDispatch(); + Dispatch a2 = Dispatch.invoke(sheet, "Range", Dispatch.Get, + new Object[] { "A2" }, new int[1]).toDispatch(); + Dispatch.put(a1, "Value", "123.456"); + Dispatch.put(a2, "Formula", "=A1*2"); + System.out.println("a1 from excel:" + Dispatch.get(a1, "Value")); + System.out.println("a2 from excel:" + Dispatch.get(a2, "Value")); + Variant f = new Variant(false); + Dispatch.call(workbook, "Close", f); + } catch (Exception e) { + e.printStackTrace(); + } finally { + xl.invoke("Quit", new Variant[] {}); + ComThread.Release(); + } + } } diff --git a/src/sample/com/jacob/samples/office/VisioPrintTest.java b/src/sample/com/jacob/samples/office/VisioPrintTest.java index 94c0b00..4e49a33 100644 --- a/src/sample/com/jacob/samples/office/VisioPrintTest.java +++ b/src/sample/com/jacob/samples/office/VisioPrintTest.java @@ -14,35 +14,35 @@ import com.jacob.com.Dispatch; */ public class VisioPrintTest { - /** - * Runs the print ant lets the user say ok or cancel. Note the funky Visio - * behavior if someone hits the cancel button - * - */ - public void testPrintDialog() { - ActiveXComponent oActiveX = new ActiveXComponent("Visio.Application"); - Dispatch oDocuments = oActiveX.getProperty("Documents").toDispatch(); - // create a blank document - Dispatch.call(oDocuments, "Add", ""); - try { - Dispatch.call(oActiveX, "DoCmd", new Integer(1010)).getInt(); - System.out.println("User hit the ok button."); - } catch (ComFailException e) { - System.out.println("User hit the cancel button: " + e); - } finally { - oActiveX.invoke("Quit"); - } - return; - } + /** + * Runs the print ant lets the user say ok or cancel. Note the funky Visio + * behavior if someone hits the cancel button + * + */ + public void testPrintDialog() { + ActiveXComponent oActiveX = new ActiveXComponent("Visio.Application"); + Dispatch oDocuments = oActiveX.getProperty("Documents").toDispatch(); + // create a blank document + Dispatch.call(oDocuments, "Add", ""); + try { + Dispatch.call(oActiveX, "DoCmd", new Integer(1010)).getInt(); + System.out.println("User hit the ok button."); + } catch (ComFailException e) { + System.out.println("User hit the cancel button: " + e); + } finally { + oActiveX.invoke("Quit"); + } + return; + } - /** - * quick main() to test this - * - * @param args - * standard command line arguments - */ - public static void main(String[] args) { - VisioPrintTest testObject = new VisioPrintTest(); - testObject.testPrintDialog(); - } + /** + * quick main() to test this + * + * @param args + * standard command line arguments + */ + public static void main(String[] args) { + VisioPrintTest testObject = new VisioPrintTest(); + testObject.testPrintDialog(); + } } diff --git a/src/sample/com/jacob/samples/office/WordDocumentProperties.java b/src/sample/com/jacob/samples/office/WordDocumentProperties.java index 223ea82..786d495 100644 --- a/src/sample/com/jacob/samples/office/WordDocumentProperties.java +++ b/src/sample/com/jacob/samples/office/WordDocumentProperties.java @@ -18,154 +18,154 @@ import com.jacob.com.Variant; * are sections that could be enhanced */ public class WordDocumentProperties { - // Declare word object - private ActiveXComponent objWord; + // Declare word object + private ActiveXComponent objWord; - // Declare Word Properties - private Dispatch custDocprops; + // Declare Word Properties + private Dispatch custDocprops; - private Dispatch builtInDocProps; + private Dispatch builtInDocProps; - // the doucments object is important in any real app but this demo doesn't - // use it - // private Dispatch documents; + // the doucments object is important in any real app but this demo doesn't + // use it + // private Dispatch documents; - private Dispatch document; + private Dispatch document; - private Dispatch wordObject; + private Dispatch wordObject; - /** - * Empty Constructor - * - */ - public WordDocumentProperties() { - } + /** + * Empty Constructor + * + */ + public WordDocumentProperties() { + } - /** - * Opens a document - * - * @param filename - */ - public void open(String filename) { - // Instantiate objWord - objWord = new ActiveXComponent("Word.Application"); + /** + * Opens a document + * + * @param filename + */ + public void open(String filename) { + // Instantiate objWord + objWord = new ActiveXComponent("Word.Application"); - // Assign a local word object - wordObject = objWord.getObject(); + // Assign a local word object + wordObject = objWord.getObject(); - // Create a Dispatch Parameter to hide the document that is opened - Dispatch.put(wordObject, "Visible", new Variant(false)); + // Create a Dispatch Parameter to hide the document that is opened + Dispatch.put(wordObject, "Visible", new Variant(false)); - // Instantiate the Documents Property - Dispatch documents = objWord.getProperty("Documents").toDispatch(); + // Instantiate the Documents Property + Dispatch documents = objWord.getProperty("Documents").toDispatch(); - // Open a word document, Current Active Document - document = Dispatch.call(documents, "Open", filename).toDispatch(); - } + // Open a word document, Current Active Document + document = Dispatch.call(documents, "Open", filename).toDispatch(); + } - /** - * Creates an instance of the VBA CustomDocumentProperties property - * - */ - public void selectCustomDocumentProperitiesMode() { - // Create CustomDocumentProperties and BuiltInDocumentProperties - // properties - custDocprops = Dispatch.get(document, "CustomDocumentProperties") - .toDispatch(); - } + /** + * Creates an instance of the VBA CustomDocumentProperties property + * + */ + public void selectCustomDocumentProperitiesMode() { + // Create CustomDocumentProperties and BuiltInDocumentProperties + // properties + custDocprops = Dispatch.get(document, "CustomDocumentProperties") + .toDispatch(); + } - /** - * Creates an instance of the VBA BuiltInDocumentProperties property - * - */ - public void selectBuiltinPropertiesMode() { - // Create CustomDocumentProperties and BuiltInDocumentProperties - // properties - builtInDocProps = Dispatch.get(document, "BuiltInDocumentProperties") - .toDispatch(); - } + /** + * Creates an instance of the VBA BuiltInDocumentProperties property + * + */ + public void selectBuiltinPropertiesMode() { + // Create CustomDocumentProperties and BuiltInDocumentProperties + // properties + builtInDocProps = Dispatch.get(document, "BuiltInDocumentProperties") + .toDispatch(); + } - /** - * Closes a document - * - */ - public void close() { - // Close object - Dispatch.call(document, "Close"); - } + /** + * Closes a document + * + */ + public void close() { + // Close object + Dispatch.call(document, "Close"); + } - /** - * Custom Property Name is passed in - * - * @param cusPropName - * @return String - Custom property value - */ - public String getCustomProperty(String cusPropName) { - try { - cusPropName = Dispatch.call(custDocprops, "Item", cusPropName) - .toString(); - } catch (ComException e) { - // Do nothing - cusPropName = null; - } + /** + * Custom Property Name is passed in + * + * @param cusPropName + * @return String - Custom property value + */ + public String getCustomProperty(String cusPropName) { + try { + cusPropName = Dispatch.call(custDocprops, "Item", cusPropName) + .toString(); + } catch (ComException e) { + // Do nothing + cusPropName = null; + } - return cusPropName; - } + return cusPropName; + } - /** - * Built In Property Name is passed in - * - * @param builtInPropName - * @return String - Built in property value - */ - public String getBuiltInProperty(String builtInPropName) { - try { - builtInPropName = Dispatch.call(builtInDocProps, "Item", - builtInPropName).toString(); - } catch (ComException e) { - // Do nothing - builtInPropName = null; - } + /** + * Built In Property Name is passed in + * + * @param builtInPropName + * @return String - Built in property value + */ + public String getBuiltInProperty(String builtInPropName) { + try { + builtInPropName = Dispatch.call(builtInDocProps, "Item", + builtInPropName).toString(); + } catch (ComException e) { + // Do nothing + builtInPropName = null; + } - return builtInPropName; - } + return builtInPropName; + } - /** - * simple main program that gets some properties and prints them out - * - * @param args - */ - public static void main(String[] args) { - try { - // Instantiate the class - WordDocumentProperties jacTest = new WordDocumentProperties(); + /** + * simple main program that gets some properties and prints them out + * + * @param args + */ + public static void main(String[] args) { + try { + // Instantiate the class + WordDocumentProperties jacTest = new WordDocumentProperties(); - // Open the word doc - File doc = new File( - "samples/com/jacob/samples/office/TestDocument.doc"); - jacTest.open(doc.getAbsolutePath()); + // Open the word doc + File doc = new File( + "samples/com/jacob/samples/office/TestDocument.doc"); + jacTest.open(doc.getAbsolutePath()); - // Set Custom Properties - jacTest.selectCustomDocumentProperitiesMode(); + // Set Custom Properties + jacTest.selectCustomDocumentProperitiesMode(); - // Set Built In Properties - jacTest.selectBuiltinPropertiesMode(); + // Set Built In Properties + jacTest.selectBuiltinPropertiesMode(); - // Get custom Property Value - String custValue = jacTest.getCustomProperty("Information Source"); + // Get custom Property Value + String custValue = jacTest.getCustomProperty("Information Source"); - // Get built in prroperty Property Value - String builtInValue = jacTest.getBuiltInProperty("Author"); + // Get built in prroperty Property Value + String builtInValue = jacTest.getBuiltInProperty("Author"); - // Close Word Doc - jacTest.close(); + // Close Word Doc + jacTest.close(); - // Output data - System.out.println("Document Val One: " + custValue); - System.out.println("Document Author: " + builtInValue); + // Output data + System.out.println("Document Val One: " + custValue); + System.out.println("Document Author: " + builtInValue); - } catch (Exception e) { - System.out.println(e); - } - } + } catch (Exception e) { + System.out.println(e); + } + } } \ No newline at end of file diff --git a/src/sample/com/jacob/samples/outlook/Outlook.java b/src/sample/com/jacob/samples/outlook/Outlook.java index 018091d..95d3492 100644 --- a/src/sample/com/jacob/samples/outlook/Outlook.java +++ b/src/sample/com/jacob/samples/outlook/Outlook.java @@ -14,67 +14,67 @@ import com.jacob.com.Variant; */ public class Outlook { - private static String pad(int i) { - StringBuffer sb = new StringBuffer(); + private static String pad(int i) { + StringBuffer sb = new StringBuffer(); - while (sb.length() < i) { - sb.append(' '); - } + while (sb.length() < i) { + sb.append(' '); + } - return sb.toString(); - } + return sb.toString(); + } - private static void recurseFolders(int iIndent, Dispatch o) { + private static void recurseFolders(int iIndent, Dispatch o) { - if (o == null) { - return; - } - Dispatch oFolders = Dispatch.get(o, "Folders").toDispatch(); - // System.out.println("oFolders=" + oFolders); - if (oFolders == null) { - return; - } + if (o == null) { + return; + } + Dispatch oFolders = Dispatch.get(o, "Folders").toDispatch(); + // System.out.println("oFolders=" + oFolders); + if (oFolders == null) { + return; + } - Dispatch oFolder = Dispatch.get(oFolders, "GetFirst").toDispatch(); - do { - Object oFolderName = Dispatch.get(oFolder, "Name"); - if (null == oFolderName) { - break; - } + Dispatch oFolder = Dispatch.get(oFolders, "GetFirst").toDispatch(); + do { + Object oFolderName = Dispatch.get(oFolder, "Name"); + if (null == oFolderName) { + break; + } - System.out.println(pad(iIndent) + oFolderName); - recurseFolders(iIndent + 3, oFolder); + System.out.println(pad(iIndent) + oFolderName); + recurseFolders(iIndent + 3, oFolder); - oFolder = Dispatch.get(oFolders, "GetNext").toDispatch(); - } while (true); + oFolder = Dispatch.get(oFolders, "GetNext").toDispatch(); + } while (true); - } + } - /** - * standard run loop - * - * @param asArgs - * command line arguments - * @throws Exception - */ - public static void main(String asArgs[]) throws Exception { - System.out.println("Outlook: IN"); + /** + * standard run loop + * + * @param asArgs + * command line arguments + * @throws Exception + */ + public static void main(String asArgs[]) throws Exception { + System.out.println("Outlook: IN"); - ActiveXComponent axOutlook = new ActiveXComponent("Outlook.Application"); - try { - System.out.println("version=" + axOutlook.getProperty("Version")); + ActiveXComponent axOutlook = new ActiveXComponent("Outlook.Application"); + try { + System.out.println("version=" + axOutlook.getProperty("Version")); - Dispatch oOutlook = axOutlook.getObject(); - System.out.println("version=" + Dispatch.get(oOutlook, "Version")); + Dispatch oOutlook = axOutlook.getObject(); + System.out.println("version=" + Dispatch.get(oOutlook, "Version")); - Dispatch oNameSpace = axOutlook.getProperty("Session").toDispatch(); - System.out.println("oNameSpace=" + oNameSpace); + Dispatch oNameSpace = axOutlook.getProperty("Session").toDispatch(); + System.out.println("oNameSpace=" + oNameSpace); - recurseFolders(0, oNameSpace); + recurseFolders(0, oNameSpace); - } finally { - axOutlook.invoke("Quit", new Variant[] {}); - } - } + } finally { + axOutlook.invoke("Quit", new Variant[] {}); + } + } } diff --git a/src/sample/com/jacob/samples/system/DiskUtils.java b/src/sample/com/jacob/samples/system/DiskUtils.java index 93a0621..e8a81c5 100644 --- a/src/sample/com/jacob/samples/system/DiskUtils.java +++ b/src/sample/com/jacob/samples/system/DiskUtils.java @@ -21,132 +21,132 @@ import com.jacob.com.Variant; */ public class DiskUtils { - /** formatters aren't thread safe but the sample only has one thread */ - private static DecimalFormat sizeFormatter = new DecimalFormat( - "###,###,###,###"); + /** formatters aren't thread safe but the sample only has one thread */ + private static DecimalFormat sizeFormatter = new DecimalFormat( + "###,###,###,###"); - /** a pointer to the scripting file system object */ - private ActiveXComponent fileSystemApp = null; + /** a pointer to the scripting file system object */ + private ActiveXComponent fileSystemApp = null; - /** the dispatch that points at the drive this DiskUtil operates against */ - private Dispatch myDrive = null; + /** the dispatch that points at the drive this DiskUtil operates against */ + private Dispatch myDrive = null; - /** - * Standard constructor - * - * @param drive - * the drive to run the test against. - */ - public DiskUtils(String drive) { - setUp(drive); - } + /** + * Standard constructor + * + * @param drive + * the drive to run the test against. + */ + public DiskUtils(String drive) { + setUp(drive); + } - /** - * open the connection to the scripting object - * - * @param drive - * the drive to run the test against - */ - public void setUp(String drive) { - if (fileSystemApp == null) { - ComThread.InitSTA(); - fileSystemApp = new ActiveXComponent("Scripting.FileSystemObject"); - myDrive = Dispatch.call(fileSystemApp, "GetDrive", drive) - .toDispatch(); - } - } + /** + * open the connection to the scripting object + * + * @param drive + * the drive to run the test against + */ + public void setUp(String drive) { + if (fileSystemApp == null) { + ComThread.InitSTA(); + fileSystemApp = new ActiveXComponent("Scripting.FileSystemObject"); + myDrive = Dispatch.call(fileSystemApp, "GetDrive", drive) + .toDispatch(); + } + } - /** - * Do any needed cleanup - */ - public void tearDown() { - ComThread.Release(); - } + /** + * Do any needed cleanup + */ + public void tearDown() { + ComThread.Release(); + } - /** - * convenience method - * - * @return driver serial number - */ - public int getSerialNumber() { - return Dispatch.get(myDrive, "SerialNumber").getInt(); - } + /** + * convenience method + * + * @return driver serial number + */ + public int getSerialNumber() { + return Dispatch.get(myDrive, "SerialNumber").getInt(); + } - /** - * Convenience method. We go through these formatting hoops so we can make - * the size string pretty. We wouldn't have to do that if we didn't mind - * long strings with Exxx at the end or the fact that the value returned can - * vary in size based on the size of the disk. - * - * @return driver total size of the disk - */ - public String getTotalSize() { - Variant returnValue = Dispatch.get(myDrive, "TotalSize"); - if (returnValue.getvt() == Variant.VariantDouble) { - return sizeFormatter.format(returnValue.getDouble()); - } else if (returnValue.getvt() == Variant.VariantInt) { - return sizeFormatter.format(returnValue.getInt()); - } else { - return "Don't know type: " + returnValue.getvt(); - } - } + /** + * Convenience method. We go through these formatting hoops so we can make + * the size string pretty. We wouldn't have to do that if we didn't mind + * long strings with Exxx at the end or the fact that the value returned can + * vary in size based on the size of the disk. + * + * @return driver total size of the disk + */ + public String getTotalSize() { + Variant returnValue = Dispatch.get(myDrive, "TotalSize"); + if (returnValue.getvt() == Variant.VariantDouble) { + return sizeFormatter.format(returnValue.getDouble()); + } else if (returnValue.getvt() == Variant.VariantInt) { + return sizeFormatter.format(returnValue.getInt()); + } else { + return "Don't know type: " + returnValue.getvt(); + } + } - /** - * Convenience method. We wouldn't have to do that if we didn't mind long - * strings with Exxx at the end or the fact that the value returned can vary - * in size based on the size of the disk. - * - * @return driver free size of the disk - */ - public String getFreeSpace() { - Variant returnValue = Dispatch.get(myDrive, "FreeSpace"); - if (returnValue.getvt() == Variant.VariantDouble) { - return sizeFormatter.format(returnValue.getDouble()); - } else if (returnValue.getvt() == Variant.VariantInt) { - return sizeFormatter.format(returnValue.getInt()); - } else { - return "Don't know type: " + returnValue.getvt(); - } - } + /** + * Convenience method. We wouldn't have to do that if we didn't mind long + * strings with Exxx at the end or the fact that the value returned can vary + * in size based on the size of the disk. + * + * @return driver free size of the disk + */ + public String getFreeSpace() { + Variant returnValue = Dispatch.get(myDrive, "FreeSpace"); + if (returnValue.getvt() == Variant.VariantDouble) { + return sizeFormatter.format(returnValue.getDouble()); + } else if (returnValue.getvt() == Variant.VariantInt) { + return sizeFormatter.format(returnValue.getInt()); + } else { + return "Don't know type: " + returnValue.getvt(); + } + } - /** - * - * @return file system on the drive - */ - public String getFileSystemType() { - // figure ot the actual variant type - // Variant returnValue = Dispatch.get(myDrive, "FileSystem"); - // System.out.println(returnValue.getvt()); - return Dispatch.get(myDrive, "FileSystem").getString(); - } + /** + * + * @return file system on the drive + */ + public String getFileSystemType() { + // figure ot the actual variant type + // Variant returnValue = Dispatch.get(myDrive, "FileSystem"); + // System.out.println(returnValue.getvt()); + return Dispatch.get(myDrive, "FileSystem").getString(); + } - /** - * - * @return volume name - */ - public String getVolumeName() { - return Dispatch.get(myDrive, "VolumeName").getString(); - } + /** + * + * @return volume name + */ + public String getVolumeName() { + return Dispatch.get(myDrive, "VolumeName").getString(); + } - /** - * Simple main program that creates a DiskUtils object and queries for the - * C: drive - * - * @param args - * standard command line arguments - */ - public static void main(String[] args) { - // DiskUtils utilConnection = new DiskUtils("F"); - DiskUtils utilConnection = new DiskUtils("C"); - System.out.println("Disk serial number is: " - + utilConnection.getSerialNumber()); - System.out.println("FileSystem is: " - + utilConnection.getFileSystemType()); - System.out.println("Volume Name is: " + utilConnection.getVolumeName()); - System.out.println("Disk total size is: " - + utilConnection.getTotalSize()); - System.out.println("Disk free space is: " - + utilConnection.getFreeSpace()); - utilConnection.tearDown(); - } + /** + * Simple main program that creates a DiskUtils object and queries for the + * C: drive + * + * @param args + * standard command line arguments + */ + public static void main(String[] args) { + // DiskUtils utilConnection = new DiskUtils("F"); + DiskUtils utilConnection = new DiskUtils("C"); + System.out.println("Disk serial number is: " + + utilConnection.getSerialNumber()); + System.out.println("FileSystem is: " + + utilConnection.getFileSystemType()); + System.out.println("Volume Name is: " + utilConnection.getVolumeName()); + System.out.println("Disk total size is: " + + utilConnection.getTotalSize()); + System.out.println("Disk free space is: " + + utilConnection.getFreeSpace()); + utilConnection.tearDown(); + } } diff --git a/src/sample/com/jacob/samples/system/SystemMonitor.java b/src/sample/com/jacob/samples/system/SystemMonitor.java index a3a05a1..86261bb 100644 --- a/src/sample/com/jacob/samples/system/SystemMonitor.java +++ b/src/sample/com/jacob/samples/system/SystemMonitor.java @@ -17,59 +17,59 @@ import com.jacob.com.Variant; */ public class SystemMonitor { - /** - * example run loop method called by main() - */ - public void runMonitor() { + /** + * example run loop method called by main() + */ + public void runMonitor() { - ActiveXComponent wmi = null; - wmi = new ActiveXComponent("WbemScripting.SWbemLocator"); - // no connection parameters means to connect to the local machine - Variant conRet = wmi.invoke("ConnectServer"); - // the author liked the ActiveXComponent api style over the Dispatch - // style - ActiveXComponent wmiconnect = new ActiveXComponent(conRet.toDispatch()); + ActiveXComponent wmi = null; + wmi = new ActiveXComponent("WbemScripting.SWbemLocator"); + // no connection parameters means to connect to the local machine + Variant conRet = wmi.invoke("ConnectServer"); + // the author liked the ActiveXComponent api style over the Dispatch + // style + ActiveXComponent wmiconnect = new ActiveXComponent(conRet.toDispatch()); - // the WMI supports a query language. - String query = "select CategoryString, Message, TimeGenerated, User, Type " - + "from Win32_NtLogEvent " - + "where Logfile = 'Application' and TimeGenerated > '20070915000000.000000-***'"; - Variant vCollection = wmiconnect - .invoke("ExecQuery", new Variant(query)); + // the WMI supports a query language. + String query = "select CategoryString, Message, TimeGenerated, User, Type " + + "from Win32_NtLogEvent " + + "where Logfile = 'Application' and TimeGenerated > '20070915000000.000000-***'"; + Variant vCollection = wmiconnect + .invoke("ExecQuery", new Variant(query)); - EnumVariant enumVariant = new EnumVariant(vCollection.toDispatch()); + EnumVariant enumVariant = new EnumVariant(vCollection.toDispatch()); - String resultString = ""; - Dispatch item = null; + String resultString = ""; + Dispatch item = null; - while (enumVariant.hasMoreElements()) { - resultString = ""; - item = enumVariant.nextElement().toDispatch(); - String categoryString = Dispatch.call(item, "CategoryString") - .toString(); - String messageString = Dispatch.call(item, "Message").toString(); - String timeGenerated = Dispatch.call(item, "TimeGenerated") - .toString(); - String eventUser = Dispatch.call(item, "User").toString(); - String eventType = Dispatch.call(item, "Type").toString(); - resultString += "TimeGenerated: " + timeGenerated + " Category: " - + categoryString + " User: " + eventUser + " EventType: " - + eventType + " Message:" + messageString; - System.out.println(resultString); + while (enumVariant.hasMoreElements()) { + resultString = ""; + item = enumVariant.nextElement().toDispatch(); + String categoryString = Dispatch.call(item, "CategoryString") + .toString(); + String messageString = Dispatch.call(item, "Message").toString(); + String timeGenerated = Dispatch.call(item, "TimeGenerated") + .toString(); + String eventUser = Dispatch.call(item, "User").toString(); + String eventType = Dispatch.call(item, "Type").toString(); + resultString += "TimeGenerated: " + timeGenerated + " Category: " + + categoryString + " User: " + eventUser + " EventType: " + + eventType + " Message:" + messageString; + System.out.println(resultString); - } + } - } + } - /** - * sample's main program - * - * @param args - * command line arguments - */ - public static void main(String[] args) { - SystemMonitor utilConnection = new SystemMonitor(); - utilConnection.runMonitor(); - } + /** + * sample's main program + * + * @param args + * command line arguments + */ + public static void main(String[] args) { + SystemMonitor utilConnection = new SystemMonitor(); + utilConnection.runMonitor(); + } } diff --git a/src/sample/com/jacob/samples/visio/VisioApp.java b/src/sample/com/jacob/samples/visio/VisioApp.java index d1c8337..98b34d3 100644 --- a/src/sample/com/jacob/samples/visio/VisioApp.java +++ b/src/sample/com/jacob/samples/visio/VisioApp.java @@ -16,106 +16,106 @@ import com.jacob.com.Variant; */ public class VisioApp extends ActiveXComponent { - /** - * constructor that spins up Visio - * - * @throws VisioException - */ - public VisioApp() throws VisioException { - super("Visio.Application"); - setVisible(false); - } + /** + * constructor that spins up Visio + * + * @throws VisioException + */ + public VisioApp() throws VisioException { + super("Visio.Application"); + setVisible(false); + } - /** - * creates a DispatchEvents object to register o as a listener - * - * @param o - */ - public void addEventListener(VisioEventListener o) { - DispatchEvents events = new DispatchEvents(this, o); - if (events == null) { - System.out - .println("You should never get null back when creating a DispatchEvents object"); - } - } + /** + * creates a DispatchEvents object to register o as a listener + * + * @param o + */ + public void addEventListener(VisioEventListener o) { + DispatchEvents events = new DispatchEvents(this, o); + if (events == null) { + System.out + .println("You should never get null back when creating a DispatchEvents object"); + } + } - /** - * opens the passed in file in Visio - * - * @param f - * @throws VisioException - */ - public void open(File f) throws VisioException { - try { - ActiveXComponent documents = new ActiveXComponent(getProperty( - "Documents").toDispatch()); - Variant[] args = new Variant[1]; - args[0] = new Variant(f.getPath()); - documents.invoke("Open", args); - } catch (Exception e) { - e.printStackTrace(); - throw new VisioException(e); - } - } + /** + * opens the passed in file in Visio + * + * @param f + * @throws VisioException + */ + public void open(File f) throws VisioException { + try { + ActiveXComponent documents = new ActiveXComponent(getProperty( + "Documents").toDispatch()); + Variant[] args = new Variant[1]; + args[0] = new Variant(f.getPath()); + documents.invoke("Open", args); + } catch (Exception e) { + e.printStackTrace(); + throw new VisioException(e); + } + } - /** - * tells Visio to save the drawing - * - * @throws VisioException - */ - public void save() throws VisioException { - try { - ActiveXComponent document = new ActiveXComponent(getProperty( - "ActiveDocument").toDispatch()); - document.invoke("Save"); - } catch (Exception e) { - e.printStackTrace(); - throw new VisioException(e); - } - } + /** + * tells Visio to save the drawing + * + * @throws VisioException + */ + public void save() throws VisioException { + try { + ActiveXComponent document = new ActiveXComponent(getProperty( + "ActiveDocument").toDispatch()); + document.invoke("Save"); + } catch (Exception e) { + e.printStackTrace(); + throw new VisioException(e); + } + } - /** - * terminates Visio - */ - public void quit() { - System.out.println("Received quit()"); - // there can't be any open documents for this to work - // you'll get a visio error if you don't close them - ActiveXComponent document = new ActiveXComponent(getProperty( - "ActiveDocument").toDispatch()); - document.invoke("Close"); - invoke("Quit"); - } + /** + * terminates Visio + */ + public void quit() { + System.out.println("Received quit()"); + // there can't be any open documents for this to work + // you'll get a visio error if you don't close them + ActiveXComponent document = new ActiveXComponent(getProperty( + "ActiveDocument").toDispatch()); + document.invoke("Close"); + invoke("Quit"); + } - /** - * runs the Visio export command - * - * @param f - * @throws VisioException - */ - public void export(File f) throws VisioException { - try { - ActiveXComponent document = new ActiveXComponent(getProperty( - "ActivePage").toDispatch()); - Variant[] args = new Variant[1]; - args[0] = new Variant(f.getPath()); - document.invoke("Export", args); - } catch (Exception e) { - throw new VisioException(e); - } - } + /** + * runs the Visio export command + * + * @param f + * @throws VisioException + */ + public void export(File f) throws VisioException { + try { + ActiveXComponent document = new ActiveXComponent(getProperty( + "ActivePage").toDispatch()); + Variant[] args = new Variant[1]; + args[0] = new Variant(f.getPath()); + document.invoke("Export", args); + } catch (Exception e) { + throw new VisioException(e); + } + } - /** - * makes Visio visible so the user can watch - * - * @param b - * @throws VisioException - */ - public void setVisible(boolean b) throws VisioException { - try { - setProperty("Visible", new Variant(b)); - } catch (Exception e) { - throw new VisioException(e); - } - } + /** + * makes Visio visible so the user can watch + * + * @param b + * @throws VisioException + */ + public void setVisible(boolean b) throws VisioException { + try { + setProperty("Visible", new Variant(b)); + } catch (Exception e) { + throw new VisioException(e); + } + } } diff --git a/src/sample/com/jacob/samples/visio/VisioAppFacade.java b/src/sample/com/jacob/samples/visio/VisioAppFacade.java index 9395f84..eebcb3c 100644 --- a/src/sample/com/jacob/samples/visio/VisioAppFacade.java +++ b/src/sample/com/jacob/samples/visio/VisioAppFacade.java @@ -22,159 +22,159 @@ import java.io.OutputStream; */ public class VisioAppFacade { - private VisioApp app; - private static VisioAppFacade instance; + private VisioApp app; + private static VisioAppFacade instance; - /** extension for image files */ - public static final String IMAGE_EXT = ".jpg"; - /** extension for visio files */ - public static final String VISIO_EXT = ".vsd"; - /** the buffer size when we want to read stuff in */ - public static final int BUFFER_SIZE = 2048; + /** extension for image files */ + public static final String IMAGE_EXT = ".jpg"; + /** extension for visio files */ + public static final String VISIO_EXT = ".vsd"; + /** the buffer size when we want to read stuff in */ + public static final int BUFFER_SIZE = 2048; - /** - * Wrapper around Visio - * - * @throws VisioException - */ - private VisioAppFacade() throws VisioException { - this.app = new VisioApp(); - app.addEventListener(new VisioEventAdapter(app)); - } + /** + * Wrapper around Visio + * + * @throws VisioException + */ + private VisioAppFacade() throws VisioException { + this.app = new VisioApp(); + app.addEventListener(new VisioEventAdapter(app)); + } - /** - * @return the singleton instance of Visio - * @throws VisioException - */ - public static VisioAppFacade getInstance() throws VisioException { - if (instance == null) { - instance = new VisioAppFacade(); - } - return instance; - } + /** + * @return the singleton instance of Visio + * @throws VisioException + */ + public static VisioAppFacade getInstance() throws VisioException { + if (instance == null) { + instance = new VisioAppFacade(); + } + return instance; + } - /** - * creates a preview in a temp file and returns the raw data. - * - * @param visioData - * @return raw preview data - * @throws VisioException - */ - public byte[] createPreview(byte[] visioData) throws VisioException { - byte[] preview; - File tmpFile; - try { - tmpFile = getTempVisioFile(); - OutputStream out = new FileOutputStream(tmpFile); - out.write(visioData); - out.close(); - } catch (IOException ioe) { - throw new VisioException(ioe); - } - preview = createPreview(tmpFile); - tmpFile.delete(); - return preview; - } + /** + * creates a preview in a temp file and returns the raw data. + * + * @param visioData + * @return raw preview data + * @throws VisioException + */ + public byte[] createPreview(byte[] visioData) throws VisioException { + byte[] preview; + File tmpFile; + try { + tmpFile = getTempVisioFile(); + OutputStream out = new FileOutputStream(tmpFile); + out.write(visioData); + out.close(); + } catch (IOException ioe) { + throw new VisioException(ioe); + } + preview = createPreview(tmpFile); + tmpFile.delete(); + return preview; + } - /** - * reads a preview from a saved file - * - * @param visioFile - * @return raw preview data - * @throws VisioException - */ - public byte[] createPreview(File visioFile) throws VisioException { - try { - File imageFile; - imageFile = getTempImageFile(); - app.open(visioFile); - app.export(imageFile); - ByteArrayOutputStream bout = new ByteArrayOutputStream(); - FileInputStream fin = new FileInputStream(imageFile); - copy(fin, bout); - fin.close(); - imageFile.delete(); - bout.close(); - return bout.toByteArray(); - } catch (IOException ioe) { - throw new VisioException(ioe); - } - } + /** + * reads a preview from a saved file + * + * @param visioFile + * @return raw preview data + * @throws VisioException + */ + public byte[] createPreview(File visioFile) throws VisioException { + try { + File imageFile; + imageFile = getTempImageFile(); + app.open(visioFile); + app.export(imageFile); + ByteArrayOutputStream bout = new ByteArrayOutputStream(); + FileInputStream fin = new FileInputStream(imageFile); + copy(fin, bout); + fin.close(); + imageFile.delete(); + bout.close(); + return bout.toByteArray(); + } catch (IOException ioe) { + throw new VisioException(ioe); + } + } - private void copy(InputStream in, OutputStream out) throws IOException { - byte[] buff = new byte[BUFFER_SIZE]; - int read; - do { - read = in.read(buff); - if (read > 0) { - out.write(buff, 0, read); - } - } while (read > 0); - } + private void copy(InputStream in, OutputStream out) throws IOException { + byte[] buff = new byte[BUFFER_SIZE]; + int read; + do { + read = in.read(buff); + if (read > 0) { + out.write(buff, 0, read); + } + } while (read > 0); + } - /** - * creates a preview from an input stream - * - * @param in - * @return byte contents of the preview stream - * @throws VisioException - */ - public byte[] createPreview(InputStream in) throws VisioException { - byte[] preview; - // byte[] buff = new byte[2048]; - // int read = 0; - OutputStream out; - File tmpFile; + /** + * creates a preview from an input stream + * + * @param in + * @return byte contents of the preview stream + * @throws VisioException + */ + public byte[] createPreview(InputStream in) throws VisioException { + byte[] preview; + // byte[] buff = new byte[2048]; + // int read = 0; + OutputStream out; + File tmpFile; - try { - tmpFile = getTempVisioFile(); - out = new FileOutputStream(tmpFile); - copy(in, out); - out.close(); - } catch (IOException ioe) { - throw new VisioException(ioe); - } + try { + tmpFile = getTempVisioFile(); + out = new FileOutputStream(tmpFile); + copy(in, out); + out.close(); + } catch (IOException ioe) { + throw new VisioException(ioe); + } - preview = createPreview(tmpFile); - tmpFile.delete(); - return preview; - } + preview = createPreview(tmpFile); + tmpFile.delete(); + return preview; + } - /** - * opens the file in Visio and makes the editor visible - * - * @param f - * the reference to the Visio file to be opened - * @throws VisioException - */ - public void editDiagram(File f) throws VisioException { - app.open(f); - app.setVisible(true); - } + /** + * opens the file in Visio and makes the editor visible + * + * @param f + * the reference to the Visio file to be opened + * @throws VisioException + */ + public void editDiagram(File f) throws VisioException { + app.open(f); + app.setVisible(true); + } - /** - * creates a temporary viso file - * - * @return created visio temporary file - * @throws IOException - */ - private File getTempVisioFile() throws IOException { - return File.createTempFile("java", VISIO_EXT); - } + /** + * creates a temporary viso file + * + * @return created visio temporary file + * @throws IOException + */ + private File getTempVisioFile() throws IOException { + return File.createTempFile("java", VISIO_EXT); + } - /** - * creates a temporary image file and returns the File object - * - * @return the created image file object - * @throws IOException - */ - private File getTempImageFile() throws IOException { - return File.createTempFile("java", IMAGE_EXT); - } + /** + * creates a temporary image file and returns the File object + * + * @return the created image file object + * @throws IOException + */ + private File getTempImageFile() throws IOException { + return File.createTempFile("java", IMAGE_EXT); + } - /** exit visio */ - public void quit() { - app.quit(); - instance = null; - } + /** exit visio */ + public void quit() { + app.quit(); + instance = null; + } } diff --git a/src/sample/com/jacob/samples/visio/VisioDemo.java b/src/sample/com/jacob/samples/visio/VisioDemo.java index 7cb6c8d..b8a1045 100644 --- a/src/sample/com/jacob/samples/visio/VisioDemo.java +++ b/src/sample/com/jacob/samples/visio/VisioDemo.java @@ -32,166 +32,166 @@ import com.jacob.com.ComThread; */ public class VisioDemo extends JFrame implements ActionListener, WindowListener { - /** - * Totally dummy value to make Eclipse quit complaining - */ - private static final long serialVersionUID = 1L; + /** + * Totally dummy value to make Eclipse quit complaining + */ + private static final long serialVersionUID = 1L; - JButton chooseButton; - JButton openButton; - JPanel buttons; + JButton chooseButton; + JButton openButton; + JPanel buttons; - ImageIcon theImage; - JLabel theLabel; // the icon on the page is actually this button's icon + ImageIcon theImage; + JLabel theLabel; // the icon on the page is actually this button's icon - File selectedFile; - /** everyone should get this through getVisio() */ - private VisioAppFacade visioProxy = null; + File selectedFile; + /** everyone should get this through getVisio() */ + private VisioAppFacade visioProxy = null; - // put this up here so it remembers where we were on the last choose - JFileChooser chooser = null; + // put this up here so it remembers where we were on the last choose + JFileChooser chooser = null; - public class VisioFileFilter extends FileFilter { - public boolean accept(File f) { - if (f.isDirectory()) { - return true; - } else { - return (f.getName().toUpperCase().endsWith(".VSD")); - } - } + public class VisioFileFilter extends FileFilter { + public boolean accept(File f) { + if (f.isDirectory()) { + return true; + } else { + return (f.getName().toUpperCase().endsWith(".VSD")); + } + } - public String getDescription() { - return "Visio Drawings"; - } - } + public String getDescription() { + return "Visio Drawings"; + } + } - public VisioDemo() { - super("Visio in Swing POC"); - this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - buttons = new JPanel(); - getContentPane().setLayout(new BorderLayout()); - chooseButton = new JButton("Choose file to display"); - openButton = new JButton("Open file chosen file in Visio"); - chooseButton.addActionListener(this); - openButton.addActionListener(this); - buttons.add(chooseButton); - buttons.add(openButton); - getContentPane().add(buttons, BorderLayout.SOUTH); - theLabel = new JLabel(""); - getContentPane().add(theLabel, BorderLayout.CENTER); - addWindowListener(this); - setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - setSize(640, 480); - this.setVisible(true); - } + public VisioDemo() { + super("Visio in Swing POC"); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + buttons = new JPanel(); + getContentPane().setLayout(new BorderLayout()); + chooseButton = new JButton("Choose file to display"); + openButton = new JButton("Open file chosen file in Visio"); + chooseButton.addActionListener(this); + openButton.addActionListener(this); + buttons.add(chooseButton); + buttons.add(openButton); + getContentPane().add(buttons, BorderLayout.SOUTH); + theLabel = new JLabel(""); + getContentPane().add(theLabel, BorderLayout.CENTER); + addWindowListener(this); + setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + setSize(640, 480); + this.setVisible(true); + } - public static void main(String args[]) throws Exception { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - ComThread.InitSTA(); - VisioDemo poc = new VisioDemo(); - ComThread.Release(); - if (poc == null) { - System.out.println("poc== null? That should never happen!"); - } - } - }); - } + public static void main(String args[]) throws Exception { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + ComThread.InitSTA(); + VisioDemo poc = new VisioDemo(); + ComThread.Release(); + if (poc == null) { + System.out.println("poc== null? That should never happen!"); + } + } + }); + } - public void actionPerformed(ActionEvent e) { - if (e.getSource() == chooseButton) { - pickFile(); - } else if (e.getSource() == openButton) { - try { - openFile(); - } catch (Exception ex) { - ex.printStackTrace(); - throw new RuntimeException(ex); - } - } else { - System.out.println("Awesome!"); - } - } + public void actionPerformed(ActionEvent e) { + if (e.getSource() == chooseButton) { + pickFile(); + } else if (e.getSource() == openButton) { + try { + openFile(); + } catch (Exception ex) { + ex.printStackTrace(); + throw new RuntimeException(ex); + } + } else { + System.out.println("Awesome!"); + } + } - private void pickFile() { - try { - chooser = new JFileChooser(); - // comment this out if you want it to always go to myDocuments - chooser - .setCurrentDirectory(new File(System - .getProperty("user.dir"))); - chooser.setFileFilter(new VisioFileFilter()); - int returnVal = chooser.showOpenDialog(this); - if (returnVal == JFileChooser.APPROVE_OPTION) { - selectedFile = chooser.getSelectedFile(); - showSelectedFilePreview(); - } - } catch (Exception e) { - e.printStackTrace(); - } - } + private void pickFile() { + try { + chooser = new JFileChooser(); + // comment this out if you want it to always go to myDocuments + chooser + .setCurrentDirectory(new File(System + .getProperty("user.dir"))); + chooser.setFileFilter(new VisioFileFilter()); + int returnVal = chooser.showOpenDialog(this); + if (returnVal == JFileChooser.APPROVE_OPTION) { + selectedFile = chooser.getSelectedFile(); + showSelectedFilePreview(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } - /** - * use this private method instead of initializing on boot up so that - * instance and all listeners are created in this thread (event thread) - * rather than root thread - * - * @return - */ - private VisioAppFacade getVisio() { - if (visioProxy == null) { - try { - visioProxy = VisioAppFacade.getInstance(); - } catch (VisioException ve) { - System.out.println("ailed to openFile()"); - ve.printStackTrace(); - } - } - return visioProxy; - } + /** + * use this private method instead of initializing on boot up so that + * instance and all listeners are created in this thread (event thread) + * rather than root thread + * + * @return + */ + private VisioAppFacade getVisio() { + if (visioProxy == null) { + try { + visioProxy = VisioAppFacade.getInstance(); + } catch (VisioException ve) { + System.out.println("ailed to openFile()"); + ve.printStackTrace(); + } + } + return visioProxy; + } - private void showSelectedFilePreview() throws VisioException { - if (selectedFile != null) { - byte[] image = getVisio().createPreview(selectedFile); - theImage = new ImageIcon(image); - theLabel.setIcon(theImage); - } - } + private void showSelectedFilePreview() throws VisioException { + if (selectedFile != null) { + byte[] image = getVisio().createPreview(selectedFile); + theImage = new ImageIcon(image); + theLabel.setIcon(theImage); + } + } - private void openFile() throws VisioException { - try { - getVisio().editDiagram(selectedFile); - showSelectedFilePreview(); - } catch (VisioException ve) { - System.out.println("ailed to openFile()"); - ve.printStackTrace(); - } + private void openFile() throws VisioException { + try { + getVisio().editDiagram(selectedFile); + showSelectedFilePreview(); + } catch (VisioException ve) { + System.out.println("ailed to openFile()"); + ve.printStackTrace(); + } - } + } - public void windowActivated(WindowEvent e) { - } + public void windowActivated(WindowEvent e) { + } - public void windowClosed(WindowEvent e) { - System.out.println("WINDOW CLOSED"); - if (visioProxy != null) { - visioProxy.quit(); - } - } + public void windowClosed(WindowEvent e) { + System.out.println("WINDOW CLOSED"); + if (visioProxy != null) { + visioProxy.quit(); + } + } - public void windowClosing(WindowEvent e) { - } + public void windowClosing(WindowEvent e) { + } - public void windowDeactivated(WindowEvent e) { - } + public void windowDeactivated(WindowEvent e) { + } - public void windowDeiconified(WindowEvent e) { - } + public void windowDeiconified(WindowEvent e) { + } - public void windowIconified(WindowEvent e) { - System.out.println("Fooboo"); - } + public void windowIconified(WindowEvent e) { + System.out.println("Fooboo"); + } - public void windowOpened(WindowEvent e) { - } + public void windowOpened(WindowEvent e) { + } } diff --git a/src/sample/com/jacob/samples/visio/VisioEventAdapter.java b/src/sample/com/jacob/samples/visio/VisioEventAdapter.java index 2923310..430f956 100644 --- a/src/sample/com/jacob/samples/visio/VisioEventAdapter.java +++ b/src/sample/com/jacob/samples/visio/VisioEventAdapter.java @@ -13,56 +13,56 @@ import com.jacob.com.Variant; */ public class VisioEventAdapter implements VisioEventListener { - VisioApp app = null; + VisioApp app = null; - public VisioEventAdapter(VisioApp pApp) { - app = pApp; - System.out.println("Event listener constructed"); - } + public VisioEventAdapter(VisioApp pApp) { + app = pApp; + System.out.println("Event listener constructed"); + } - public void BeforeQuit(Variant[] args) { - } + public void BeforeQuit(Variant[] args) { + } - public void DocumentChanged(Variant[] args) { - System.out.println("documentChanged()"); - } + public void DocumentChanged(Variant[] args) { + System.out.println("documentChanged()"); + } - public void DocumentCloseCanceled(Variant[] args) { - } + public void DocumentCloseCanceled(Variant[] args) { + } - public void DocumentCreated(Variant[] args) { - } + public void DocumentCreated(Variant[] args) { + } - public void DocumentOpened(Variant[] args) { - System.out.println("DocumentOpened()"); - } + public void DocumentOpened(Variant[] args) { + System.out.println("DocumentOpened()"); + } - public void DocumentSaved(Variant[] args) { - } + public void DocumentSaved(Variant[] args) { + } - public void DocumentSavedAs(Variant[] args) { - } + public void DocumentSavedAs(Variant[] args) { + } - public Variant QueryCancelDocumentClose(Variant[] args) { - System.out.println("QueryCancelDocumentClose()"); - return new Variant(false); - } + public Variant QueryCancelDocumentClose(Variant[] args) { + System.out.println("QueryCancelDocumentClose()"); + return new Variant(false); + } - /** - * we don't actually let it quit. We block it so that we don't have to - * relaunch when we look at a new document - */ - public Variant QueryCancelQuit(Variant[] args) { - // these may throw VisioException - System.out - .println("Saving document, hiding and telling visio not to quit"); - try { - app.save(); - app.setVisible(false); - } catch (VisioException ve) { - System.out.println("ailed to openFile()"); - ve.printStackTrace(); - } - return new Variant(true); - } + /** + * we don't actually let it quit. We block it so that we don't have to + * relaunch when we look at a new document + */ + public Variant QueryCancelQuit(Variant[] args) { + // these may throw VisioException + System.out + .println("Saving document, hiding and telling visio not to quit"); + try { + app.save(); + app.setVisible(false); + } catch (VisioException ve) { + System.out.println("ailed to openFile()"); + ve.printStackTrace(); + } + return new Variant(true); + } } diff --git a/src/sample/com/jacob/samples/visio/VisioEventListener.java b/src/sample/com/jacob/samples/visio/VisioEventListener.java index 97ea2f9..542ef01 100644 --- a/src/sample/com/jacob/samples/visio/VisioEventListener.java +++ b/src/sample/com/jacob/samples/visio/VisioEventListener.java @@ -15,19 +15,19 @@ import com.jacob.com.Variant; */ public interface VisioEventListener { - public void BeforeQuit(Variant[] args); + public void BeforeQuit(Variant[] args); - public void DocumentChanged(Variant[] args); + public void DocumentChanged(Variant[] args); - public void DocumentCloseCanceled(Variant[] args); + public void DocumentCloseCanceled(Variant[] args); - public void DocumentCreated(Variant[] args); + public void DocumentCreated(Variant[] args); - public void DocumentOpened(Variant[] args); + public void DocumentOpened(Variant[] args); - public void DocumentSaved(Variant[] args); + public void DocumentSaved(Variant[] args); - public void DocumentSavedAs(Variant[] args); + public void DocumentSavedAs(Variant[] args); - public Variant QueryCancelQuit(Variant[] args); + public Variant QueryCancelQuit(Variant[] args); } diff --git a/src/sample/com/jacob/samples/visio/VisioException.java b/src/sample/com/jacob/samples/visio/VisioException.java index 06edd08..a5ce611 100644 --- a/src/sample/com/jacob/samples/visio/VisioException.java +++ b/src/sample/com/jacob/samples/visio/VisioException.java @@ -10,16 +10,16 @@ package com.jacob.samples.visio; * blocks everywhere */ public class VisioException extends Exception { - /** - * Totally dummy value to make Eclipse quit complaining - */ - private static final long serialVersionUID = 1L; + /** + * Totally dummy value to make Eclipse quit complaining + */ + private static final long serialVersionUID = 1L; - public VisioException(String msg) { - super(msg); - } + public VisioException(String msg) { + super(msg); + } - public VisioException(Throwable cause) { - super(cause); - } + public VisioException(Throwable cause) { + super(cause); + } } diff --git a/src/test/java/com/jacob/com/ActiveXComponentFactoryTest.java b/src/test/java/com/jacob/com/ActiveXComponentFactoryTest.java index c845ed9..a3140ed 100644 --- a/src/test/java/com/jacob/com/ActiveXComponentFactoryTest.java +++ b/src/test/java/com/jacob/com/ActiveXComponentFactoryTest.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -51,105 +51,105 @@ import com.jacob.test.BaseTestCase; */ public class ActiveXComponentFactoryTest extends BaseTestCase { - /** - * This test is supposed to verify we get multiple instances when we mean - * too. Unfortunately, it requires that the runner of the test verify via - * the "Windows Task Manager" - */ - public void testMultipleInstances() { - ComThread.InitMTA(); - String mApplicationId = "Word.Application"; - ActiveXComponent instance1 = ActiveXComponent - .createNewInstance(mApplicationId); - ActiveXComponent instance2 = ActiveXComponent - .createNewInstance(mApplicationId); - try { - Thread.sleep(10000); - } catch (InterruptedException ie) { - } - instance1.invoke("Quit", new Variant[] {}); - instance2.invoke("Quit", new Variant[] {}); - ComThread.Release(); + /** + * This test is supposed to verify we get multiple instances when we mean + * too. Unfortunately, it requires that the runner of the test verify via + * the "Windows Task Manager" + */ + public void testMultipleInstances() { + ComThread.InitMTA(); + String mApplicationId = "Word.Application"; + ActiveXComponent instance1 = ActiveXComponent + .createNewInstance(mApplicationId); + ActiveXComponent instance2 = ActiveXComponent + .createNewInstance(mApplicationId); + try { + Thread.sleep(10000); + } catch (InterruptedException ie) { + } + instance1.invoke("Quit", new Variant[] {}); + instance2.invoke("Quit", new Variant[] {}); + ComThread.Release(); - } + } - /** - * This test is supposed to verify we can force multiple items through a - * single running instance. It requires that a user physically watch the - * "Windows Task Manager" to verify only one copy of MS Word is executing - */ - public void testOnlyOneInstance() { - ComThread.InitMTA(); - String mApplicationId = "Word.Application"; - ActiveXComponent instance1 = new ActiveXComponent(mApplicationId); - ActiveXComponent instance2 = ActiveXComponent - .connectToActiveInstance(mApplicationId); - assertNotNull(instance2); - try { - Thread.sleep(10000); - } catch (InterruptedException ie) { - } - instance1.invoke("Quit", new Variant[] {}); - ComThread.Release(); + /** + * This test is supposed to verify we can force multiple items through a + * single running instance. It requires that a user physically watch the + * "Windows Task Manager" to verify only one copy of MS Word is executing + */ + public void testOnlyOneInstance() { + ComThread.InitMTA(); + String mApplicationId = "Word.Application"; + ActiveXComponent instance1 = new ActiveXComponent(mApplicationId); + ActiveXComponent instance2 = ActiveXComponent + .connectToActiveInstance(mApplicationId); + assertNotNull(instance2); + try { + Thread.sleep(10000); + } catch (InterruptedException ie) { + } + instance1.invoke("Quit", new Variant[] {}); + ComThread.Release(); - } + } - /** - * Test that verifies function of the ActiveXComponentFactory - */ - public void testActiveXComponentFactory() { - ComThread.InitSTA(true); - try { - System.out - .println("This test only works if MS Word is NOT already running"); - String mApplicationId = "Word.Application"; - ActiveXComponent mTryConnectingFirst = ActiveXComponent - .connectToActiveInstance(mApplicationId); - if (mTryConnectingFirst != null) { - mTryConnectingFirst.invoke("Quit", new Variant[] {}); - System.out - .println("Was able to connect to MSWord when hadn't started it"); - } else { - System.out - .println("Correctly could not connect to running MSWord"); - } - System.out.println(" Word Starting"); - ActiveXComponent mTryStartingSecond = ActiveXComponent - .createNewInstance(mApplicationId); - if (mTryStartingSecond == null) { - System.out.println("was unable to start up MSWord "); - } else { - System.out.println("Correctly could start MSWord"); - } - ActiveXComponent mTryConnectingThird = ActiveXComponent - .connectToActiveInstance(mApplicationId); - if (mTryConnectingThird == null) { - fail("Was unable able to connect to MSWord after previous startup"); - } else { - System.out.println("Stopping MSWord"); - // stop it so we can fail trying to connect to a running - mTryConnectingThird.invoke("Quit", new Variant[] {}); - } - Thread.sleep(2000); - ActiveXComponent mTryConnectingFourth = ActiveXComponent - .connectToActiveInstance(mApplicationId); - if (mTryConnectingFourth != null) { - mTryConnectingFourth.invoke("Quit", new Variant[] {}); - fail("Was able to connect to MSWord that was stopped"); - } else { - System.out - .println("Correctly could not connect to running MSWord"); - } - } catch (InterruptedException ie) { - } catch (ComException e) { - e.printStackTrace(); - fail("Caught COM exception"); - } finally { - // System.out.println("About to sleep for 2 seconds so we can bask - // in the glory of this success"); - // Thread.sleep(2000); - ComThread.Release(); - ComThread.quitMainSTA(); - } - } + /** + * Test that verifies function of the ActiveXComponentFactory + */ + public void testActiveXComponentFactory() { + ComThread.InitSTA(true); + try { + System.out + .println("This test only works if MS Word is NOT already running"); + String mApplicationId = "Word.Application"; + ActiveXComponent mTryConnectingFirst = ActiveXComponent + .connectToActiveInstance(mApplicationId); + if (mTryConnectingFirst != null) { + mTryConnectingFirst.invoke("Quit", new Variant[] {}); + System.out + .println("Was able to connect to MSWord when hadn't started it"); + } else { + System.out + .println("Correctly could not connect to running MSWord"); + } + System.out.println(" Word Starting"); + ActiveXComponent mTryStartingSecond = ActiveXComponent + .createNewInstance(mApplicationId); + if (mTryStartingSecond == null) { + System.out.println("was unable to start up MSWord "); + } else { + System.out.println("Correctly could start MSWord"); + } + ActiveXComponent mTryConnectingThird = ActiveXComponent + .connectToActiveInstance(mApplicationId); + if (mTryConnectingThird == null) { + fail("Was unable able to connect to MSWord after previous startup"); + } else { + System.out.println("Stopping MSWord"); + // stop it so we can fail trying to connect to a running + mTryConnectingThird.invoke("Quit", new Variant[] {}); + } + Thread.sleep(2000); + ActiveXComponent mTryConnectingFourth = ActiveXComponent + .connectToActiveInstance(mApplicationId); + if (mTryConnectingFourth != null) { + mTryConnectingFourth.invoke("Quit", new Variant[] {}); + fail("Was able to connect to MSWord that was stopped"); + } else { + System.out + .println("Correctly could not connect to running MSWord"); + } + } catch (InterruptedException ie) { + } catch (ComException e) { + e.printStackTrace(); + fail("Caught COM exception"); + } finally { + // System.out.println("About to sleep for 2 seconds so we can bask + // in the glory of this success"); + // Thread.sleep(2000); + ComThread.Release(); + ComThread.quitMainSTA(); + } + } } diff --git a/src/test/java/com/jacob/com/DateUtilitiesTest.java b/src/test/java/com/jacob/com/DateUtilitiesTest.java index 6cb6db8..9989782 100644 --- a/src/test/java/com/jacob/com/DateUtilitiesTest.java +++ b/src/test/java/com/jacob/com/DateUtilitiesTest.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -53,39 +53,39 @@ import junit.framework.TestCase; public class DateUtilitiesTest extends TestCase { - /** - * verify date conversion to and from java - */ - public void testDateUtilities() { - Date now = new Date(); - double comTimeForNow = DateUtilities.convertDateToWindowsTime(now); - Date retrievedNow = DateUtilities - .convertWindowsTimeToDate(comTimeForNow); - if (!now.equals(retrievedNow)) { - fail("DateUtilities Date Test failed " + now + " != " - + retrievedNow); - } else { - System.out.println("DateUtilities Date Test passed"); - } + /** + * verify date conversion to and from java + */ + public void testDateUtilities() { + Date now = new Date(); + double comTimeForNow = DateUtilities.convertDateToWindowsTime(now); + Date retrievedNow = DateUtilities + .convertWindowsTimeToDate(comTimeForNow); + if (!now.equals(retrievedNow)) { + fail("DateUtilities Date Test failed " + now + " != " + + retrievedNow); + } else { + System.out.println("DateUtilities Date Test passed"); + } - } + } - /** - * Verify that the start of time is when we think it is. - */ - public void testBeginningOfWindowsTime() { - // this is a magic time in the windows world - Date beginningOfWindowsTime = new GregorianCalendar(1899, - Calendar.DECEMBER, 30).getTime(); - double comTimeForBeginningOfWindowsTime = DateUtilities - .convertDateToWindowsTime(beginningOfWindowsTime); - if (comTimeForBeginningOfWindowsTime > 0) { - fail("Beginning of windows time test failed " - + comTimeForBeginningOfWindowsTime); - } else { - System.out.println("Beginning of windows time test passed"); - } + /** + * Verify that the start of time is when we think it is. + */ + public void testBeginningOfWindowsTime() { + // this is a magic time in the windows world + Date beginningOfWindowsTime = new GregorianCalendar(1899, + Calendar.DECEMBER, 30).getTime(); + double comTimeForBeginningOfWindowsTime = DateUtilities + .convertDateToWindowsTime(beginningOfWindowsTime); + if (comTimeForBeginningOfWindowsTime > 0) { + fail("Beginning of windows time test failed " + + comTimeForBeginningOfWindowsTime); + } else { + System.out.println("Beginning of windows time test passed"); + } - } + } } diff --git a/src/test/java/com/jacob/com/DispatchNullProgramId.java b/src/test/java/com/jacob/com/DispatchNullProgramId.java index ab769a5..1d95bff 100644 --- a/src/test/java/com/jacob/com/DispatchNullProgramId.java +++ b/src/test/java/com/jacob/com/DispatchNullProgramId.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -51,25 +51,25 @@ import com.jacob.test.BaseTestCase; */ public class DispatchNullProgramId extends BaseTestCase { - /** - * Verify that dispatch constructors are protected from null program ids. - */ - public void testNullProgramId() { - try { - String nullParam = null; - new Dispatch(nullParam); - fail("the dispatch failed to protect itself from null program ids"); - } catch (IllegalArgumentException iae) { - System.out - .println("the dispatch protected itself from null program ids"); - } - try { - String nullParam = ""; - new Dispatch(nullParam); - fail("the dispatch failed to protect itself from empty string program ids"); - } catch (IllegalArgumentException iae) { - System.out - .println("the dispatch protected itself from empty string program ids"); - } - } + /** + * Verify that dispatch constructors are protected from null program ids. + */ + public void testNullProgramId() { + try { + String nullParam = null; + new Dispatch(nullParam); + fail("the dispatch failed to protect itself from null program ids"); + } catch (IllegalArgumentException iae) { + System.out + .println("the dispatch protected itself from null program ids"); + } + try { + String nullParam = ""; + new Dispatch(nullParam); + fail("the dispatch failed to protect itself from empty string program ids"); + } catch (IllegalArgumentException iae) { + System.out + .println("the dispatch protected itself from empty string program ids"); + } + } } diff --git a/src/test/java/com/jacob/com/DispatchTest.java b/src/test/java/com/jacob/com/DispatchTest.java index ced58d0..747a69c 100644 --- a/src/test/java/com/jacob/com/DispatchTest.java +++ b/src/test/java/com/jacob/com/DispatchTest.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -50,22 +50,22 @@ import com.jacob.test.BaseTestCase; */ public class DispatchTest extends BaseTestCase { - /** - * Verify this detects word's exit - */ - public void testDispatchHasExited() { - String pid = "Word.Application"; - ActiveXComponent axc = new ActiveXComponent(pid); - assertEquals(0, Dispatch.hasExited(axc)); - axc.invoke("Quit", new Variant[] {}); - // should take some amount of time for Word to Quit so should = !exited - assertEquals(0, Dispatch.hasExited(axc)); - try { - // sleep some reasonable amount of time waiting for it to quit - Thread.sleep(2000); - } catch (InterruptedException e) { - fail("should not have been interrupted"); - } - assertEquals(1, Dispatch.hasExited(axc)); - } + /** + * Verify this detects word's exit + */ + public void testDispatchHasExited() { + String pid = "Word.Application"; + ActiveXComponent axc = new ActiveXComponent(pid); + assertEquals(0, Dispatch.hasExited(axc)); + axc.invoke("Quit", new Variant[] {}); + // should take some amount of time for Word to Quit so should = !exited + assertEquals(0, Dispatch.hasExited(axc)); + try { + // sleep some reasonable amount of time waiting for it to quit + Thread.sleep(2000); + } catch (InterruptedException e) { + fail("should not have been interrupted"); + } + assertEquals(1, Dispatch.hasExited(axc)); + } } diff --git a/src/test/java/com/jacob/com/DispatchValidDispatchTest.java b/src/test/java/com/jacob/com/DispatchValidDispatchTest.java index 2cdad26..ef4a402 100644 --- a/src/test/java/com/jacob/com/DispatchValidDispatchTest.java +++ b/src/test/java/com/jacob/com/DispatchValidDispatchTest.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -49,31 +49,31 @@ import com.jacob.test.BaseTestCase; */ public class DispatchValidDispatchTest extends BaseTestCase { - /** - * force an IllegalArgumentException to verify the utility method throws - * correctly. - */ - public void testThrowIllegalArgumentException() { - try { - Dispatch.call(null, 0); - fail("Failed to throw IllegalArgumentException"); - } catch (IllegalArgumentException iae) { - System.out.println("Caught correct IllegalArgumentException: " - + iae); - } - } + /** + * force an IllegalArgumentException to verify the utility method throws + * correctly. + */ + public void testThrowIllegalArgumentException() { + try { + Dispatch.call(null, 0); + fail("Failed to throw IllegalArgumentException"); + } catch (IllegalArgumentException iae) { + System.out.println("Caught correct IllegalArgumentException: " + + iae); + } + } - /** - * force an IllegalStateException to verify the utility method throws - * correctly. - */ - public void testThrowIllegalStateException() { - try { - Dispatch foo = new Dispatch(); - Dispatch.call(foo, 0); - fail("Failed to throw IllegalStateException"); - } catch (IllegalStateException ise) { - System.out.println("Caught correct IllegalStateException " + ise); - } - } + /** + * force an IllegalStateException to verify the utility method throws + * correctly. + */ + public void testThrowIllegalStateException() { + try { + Dispatch foo = new Dispatch(); + Dispatch.call(foo, 0); + fail("Failed to throw IllegalStateException"); + } catch (IllegalStateException ise) { + System.out.println("Caught correct IllegalStateException " + ise); + } + } } diff --git a/src/test/java/com/jacob/com/JacobDeadlockTest.java b/src/test/java/com/jacob/com/JacobDeadlockTest.java index cc776bb..02f02b0 100644 --- a/src/test/java/com/jacob/com/JacobDeadlockTest.java +++ b/src/test/java/com/jacob/com/JacobDeadlockTest.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -60,99 +60,99 @@ import com.jacob.test.BaseTestCase; * */ public class JacobDeadlockTest extends BaseTestCase { - private static final long TIMEOUT = 5000l; + private static final long TIMEOUT = 5000l; - /** Thread component */ - public static class TestThread extends Thread { - private final int id; - private final boolean initCOM; - private final boolean writeOutput; + /** Thread component */ + public static class TestThread extends Thread { + private final int id; + private final boolean initCOM; + private final boolean writeOutput; - /** - * constructor for ThestThread - * - * @param id - * @param initCOM - * @param writeOutput - * - */ - public TestThread(int id, boolean initCOM, boolean writeOutput) { - this.id = id; - this.initCOM = initCOM; - this.writeOutput = writeOutput; - } + /** + * constructor for ThestThread + * + * @param id + * @param initCOM + * @param writeOutput + * + */ + public TestThread(int id, boolean initCOM, boolean writeOutput) { + this.id = id; + this.initCOM = initCOM; + this.writeOutput = writeOutput; + } - @Override - public void run() { - for (int i = 0; i < 1000; i++) { - log("iteration " + i); - if (initCOM) { - log("Initializing COM thread"); - ComThread.InitMTA(false); - } - log("Creating JacobObject"); - new JacobObject(); - log("Releasing COM thread"); - ComThread.Release(); - } - log("Exiting Java Thread"); - } + @Override + public void run() { + for (int i = 0; i < 1000; i++) { + log("iteration " + i); + if (initCOM) { + log("Initializing COM thread"); + ComThread.InitMTA(false); + } + log("Creating JacobObject"); + new JacobObject(); + log("Releasing COM thread"); + ComThread.Release(); + } + log("Exiting Java Thread"); + } - private void log(String message) { - if (writeOutput) { - System.out.println(Thread.currentThread().getName() - + ": TestThread[" + id + "] " + " " + " - " + message); - } - } - } + private void log(String message) { + if (writeOutput) { + System.out.println(Thread.currentThread().getName() + + ": TestThread[" + id + "] " + " " + " - " + message); + } + } + } - /** - * This test shows that if ComThread.Init() is called explicitly, no problem - * occurs. - * - * @throws InterruptedException - */ - public void testShowNoProblemIfCOMIsInitialized() - throws InterruptedException { - runTest(2, true, false); - runTest(100, true, false); - } + /** + * This test shows that if ComThread.Init() is called explicitly, no problem + * occurs. + * + * @throws InterruptedException + */ + public void testShowNoProblemIfCOMIsInitialized() + throws InterruptedException { + runTest(2, true, false); + runTest(100, true, false); + } - /** - * This test shows that if only one thread is creating COM objects, no - * problem occurs. - * - * @throws InterruptedException - */ - public void testShowNoProblemIfSingleThreaded() throws InterruptedException { - runTest(1, false, false); - runTest(1, true, false); - } + /** + * This test shows that if only one thread is creating COM objects, no + * problem occurs. + * + * @throws InterruptedException + */ + public void testShowNoProblemIfSingleThreaded() throws InterruptedException { + runTest(1, false, false); + runTest(1, true, false); + } - /** - * Runs the test with two threads, which don't initialize the COM thread. - * - * This test will always fail. - * - * @throws InterruptedException - */ - public void testShowDeadlockProblem() throws InterruptedException { - runTest(2, false, true); - } + /** + * Runs the test with two threads, which don't initialize the COM thread. + * + * This test will always fail. + * + * @throws InterruptedException + */ + public void testShowDeadlockProblem() throws InterruptedException { + runTest(2, false, true); + } - private void runTest(int numberOfThreads, boolean initCOM, - boolean writeOutput) throws InterruptedException { - Thread[] threads = new Thread[numberOfThreads]; - for (int i = 0; i < threads.length; i++) { - threads[i] = new TestThread(i, initCOM, writeOutput); - threads[i].start(); - } - for (int i = 0; i < threads.length; i++) { - threads[i].join(TIMEOUT); - if (threads[i].isAlive()) { - fail("thread " + i + " failed to finish in " + TIMEOUT - + " milliseconds"); - } - } - } + private void runTest(int numberOfThreads, boolean initCOM, + boolean writeOutput) throws InterruptedException { + Thread[] threads = new Thread[numberOfThreads]; + for (int i = 0; i < threads.length; i++) { + threads[i] = new TestThread(i, initCOM, writeOutput); + threads[i].start(); + } + for (int i = 0; i < threads.length; i++) { + threads[i].join(TIMEOUT); + if (threads[i].isAlive()) { + fail("thread " + i + " failed to finish in " + TIMEOUT + + " milliseconds"); + } + } + } } diff --git a/src/test/java/com/jacob/com/JacobObjectTest.java b/src/test/java/com/jacob/com/JacobObjectTest.java index d9d238e..ce1de5b 100644 --- a/src/test/java/com/jacob/com/JacobObjectTest.java +++ b/src/test/java/com/jacob/com/JacobObjectTest.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -49,12 +49,12 @@ import com.jacob.test.BaseTestCase; */ public class JacobObjectTest extends BaseTestCase { - /** - * verify the build version and date functions work correctly - */ - public void testBuildVersion() { - System.out.println("build version is " + JacobReleaseInfo.getBuildVersion()); - System.out.println("build date is " + JacobReleaseInfo.getBuildDate()); - } + /** + * verify the build version and date functions work correctly + */ + public void testBuildVersion() { + System.out.println("build version is " + JacobReleaseInfo.getBuildVersion()); + System.out.println("build date is " + JacobReleaseInfo.getBuildDate()); + } } diff --git a/src/test/java/com/jacob/com/ROT2Test.java b/src/test/java/com/jacob/com/ROT2Test.java index 6ede3ec..1045ac8 100644 --- a/src/test/java/com/jacob/com/ROT2Test.java +++ b/src/test/java/com/jacob/com/ROT2Test.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -52,109 +52,109 @@ import com.jacob.test.BaseTestCase; */ public class ROT2Test extends BaseTestCase { - /** - * runs a multi-threaded test - */ - public void testDoesNotBlowUp() { - ROT2TestThread threads[] = new ROT2TestThread[4]; - for (int i = 0; i < threads.length; i++) { - threads[i] = new ROT2TestThread("thread-" + i, 3000); - } - for (int i = 0; i < threads.length; i++) { - threads[i].start(); - } - } + /** + * runs a multi-threaded test + */ + public void testDoesNotBlowUp() { + ROT2TestThread threads[] = new ROT2TestThread[4]; + for (int i = 0; i < threads.length; i++) { + threads[i] = new ROT2TestThread("thread-" + i, 3000); + } + for (int i = 0; i < threads.length; i++) { + threads[i].start(); + } + } - /** - * This will try and exercise the thread support in the ROT - */ + /** + * This will try and exercise the thread support in the ROT + */ - public class ROT2TestThread extends Thread { - private java.util.List ThreadObjects; + public class ROT2TestThread extends Thread { + private java.util.List ThreadObjects; - private int initialRunSize = 0; + private int initialRunSize = 0; - /** - * @param arg0 - * @param iStartCount - * the initial number of threads - */ - public ROT2TestThread(String arg0, int iStartCount) { - super(arg0); - initialRunSize = iStartCount; + /** + * @param arg0 + * @param iStartCount + * the initial number of threads + */ + public ROT2TestThread(String arg0, int iStartCount) { + super(arg0); + initialRunSize = iStartCount; - } + } - /** - * A semi-complex series of steps to put the ROT under stress. 1) - * discard half the objects we've created 2) if size is greater than 1 - * but not a even number, add 1 new object 3) stop when size is 1. - * - * @see java.lang.Runnable#run() - */ - public void run() { - // something that keeps object references around - // so the gc can't collect them - // we need to create these in the thread so they end up in the right - // ROT table - ThreadObjects = new java.util.ArrayList(initialRunSize); - for (int i = 0; i < initialRunSize; i++) { - // create the object - Variant aNewVariant = new Variant(getName() + "_" + i); + /** + * A semi-complex series of steps to put the ROT under stress. 1) + * discard half the objects we've created 2) if size is greater than 1 + * but not a even number, add 1 new object 3) stop when size is 1. + * + * @see java.lang.Runnable#run() + */ + public void run() { + // something that keeps object references around + // so the gc can't collect them + // we need to create these in the thread so they end up in the right + // ROT table + ThreadObjects = new java.util.ArrayList(initialRunSize); + for (int i = 0; i < initialRunSize; i++) { + // create the object + Variant aNewVariant = new Variant(getName() + "_" + i); - // create a hard reference to it - ThreadObjects.add(aNewVariant); - } + // create a hard reference to it + ThreadObjects.add(aNewVariant); + } - while (ThreadObjects.size() > 1) { - String message = ""; - message = getName() + " Workingset=" + ThreadObjects.size() - + " ROT: "; - message += "(before additions and gc " - + ROT.getThreadObjects(false).size() + ")"; - // if there is an odd number of objects greater than 2 - if (ThreadObjects.size() > 2 && ThreadObjects.size() % 2 != 0) { - // add a new object - Variant aNewVariant = new Variant(getName() + "_*" - + ThreadObjects.size()); - ThreadObjects.add(aNewVariant); - } - // now iterate across all the objects in our list - for (int i = ThreadObjects.size(); i > 0; i--) { - // removing every other one? - if (i % 2 == 0) { - // remove the reference so gc can get it - ThreadObjects.remove(i - 1); - } + while (ThreadObjects.size() > 1) { + String message = ""; + message = getName() + " Workingset=" + ThreadObjects.size() + + " ROT: "; + message += "(before additions and gc " + + ROT.getThreadObjects(false).size() + ")"; + // if there is an odd number of objects greater than 2 + if (ThreadObjects.size() > 2 && ThreadObjects.size() % 2 != 0) { + // add a new object + Variant aNewVariant = new Variant(getName() + "_*" + + ThreadObjects.size()); + ThreadObjects.add(aNewVariant); + } + // now iterate across all the objects in our list + for (int i = ThreadObjects.size(); i > 0; i--) { + // removing every other one? + if (i % 2 == 0) { + // remove the reference so gc can get it + ThreadObjects.remove(i - 1); + } - } + } - try { - // simulate the system under load and run the GC - // should end up with weak references with no objects - // attached - Thread.sleep(9); - } catch (InterruptedException e) { - // the VM doesn't want us to sleep anymore, - // so get back to work - } - message += " (before gc, after additions " - + ROT.getThreadObjects(false).size() + ")"; - System.gc(); - message += " (after System.gc " - + ROT.getThreadObjects(false).size() + ")"; - System.out.println(message); - } - } + try { + // simulate the system under load and run the GC + // should end up with weak references with no objects + // attached + Thread.sleep(9); + } catch (InterruptedException e) { + // the VM doesn't want us to sleep anymore, + // so get back to work + } + message += " (before gc, after additions " + + ROT.getThreadObjects(false).size() + ")"; + System.gc(); + message += " (after System.gc " + + ROT.getThreadObjects(false).size() + ")"; + System.out.println(message); + } + } - /** - * Another test would be to override this to always return the same - * name. That would really screw the ROT! - * - * @see java.lang.Object#toString() - */ - public String toString() { - return super.toString(); - } - } + /** + * Another test would be to override this to always return the same + * name. That would really screw the ROT! + * + * @see java.lang.Object#toString() + */ + public String toString() { + return super.toString(); + } + } } \ No newline at end of file diff --git a/src/test/java/com/jacob/com/ROT3Test.java b/src/test/java/com/jacob/com/ROT3Test.java index 6e8a16b..6a0f530 100644 --- a/src/test/java/com/jacob/com/ROT3Test.java +++ b/src/test/java/com/jacob/com/ROT3Test.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -54,126 +54,126 @@ import com.jacob.test.BaseTestCase; */ public class ROT3Test extends BaseTestCase { - /** - * runs a multi-threaded test - */ - public void testROTVersion3() { - ROT3TestThread threads[] = new ROT3TestThread[4]; - for (int i = 0; i < threads.length; i++) { - threads[i] = new ROT3TestThread("thread-" + i, 3000 + i * 10); - } - for (int i = 0; i < threads.length; i++) { - threads[i].start(); - } - } + /** + * runs a multi-threaded test + */ + public void testROTVersion3() { + ROT3TestThread threads[] = new ROT3TestThread[4]; + for (int i = 0; i < threads.length; i++) { + threads[i] = new ROT3TestThread("thread-" + i, 3000 + i * 10); + } + for (int i = 0; i < threads.length; i++) { + threads[i].start(); + } + } - /** - * This will try and exercise the thread support in the ROT - */ + /** + * This will try and exercise the thread support in the ROT + */ - public class ROT3TestThread extends Thread { - private java.util.List variansCreatedInThisThread; + public class ROT3TestThread extends Thread { + private java.util.List variansCreatedInThisThread; - private int initialRunSize = 0; + private int initialRunSize = 0; - /** - * @param arg0 - * @param iStartCount - * the number of initial threads - */ - public ROT3TestThread(String arg0, int iStartCount) { - super(arg0); - initialRunSize = iStartCount; + /** + * @param arg0 + * @param iStartCount + * the number of initial threads + */ + public ROT3TestThread(String arg0, int iStartCount) { + super(arg0); + initialRunSize = iStartCount; - } + } - /** - * A semi-complex series of steps to put the ROT under stress. 1) - * discard half the objects we've created 2) if size is greater than 1 - * but not a even number, add 1 new object 3) stop when size is 1. - * - * @see java.lang.Runnable#run() - */ - @SuppressWarnings("deprecation") - public void run() { - // something that keeps object references around - // so the gc can't collect them - // we need to create these in the thread so they end up in the right - // ROT table - variansCreatedInThisThread = new java.util.ArrayList( - initialRunSize); - for (int i = 0; i < initialRunSize; i++) { - // create the object - Variant aNewVariant = new Variant(getName() + "_" + i); - // create a hard reference to it - variansCreatedInThisThread.add(aNewVariant); - } + /** + * A semi-complex series of steps to put the ROT under stress. 1) + * discard half the objects we've created 2) if size is greater than 1 + * but not a even number, add 1 new object 3) stop when size is 1. + * + * @see java.lang.Runnable#run() + */ + @SuppressWarnings("deprecation") + public void run() { + // something that keeps object references around + // so the gc can't collect them + // we need to create these in the thread so they end up in the right + // ROT table + variansCreatedInThisThread = new java.util.ArrayList( + initialRunSize); + for (int i = 0; i < initialRunSize; i++) { + // create the object + Variant aNewVariant = new Variant(getName() + "_" + i); + // create a hard reference to it + variansCreatedInThisThread.add(aNewVariant); + } - while (variansCreatedInThisThread.size() > 1) { - String message = ""; - message = getName() + " Workingset=" - + variansCreatedInThisThread.size() - + " ROT threadObject hashCode: " - + ROT.getThreadObjects(true).hashCode(); - message += " size before mods and gc " - + ROT.getThreadObjects(true).size() + ")"; - // If there are more than 10 objects in our cache then add 1/4 - // of that again - if (variansCreatedInThisThread.size() > 10) { - message += " (adding) "; - // add an additional 1/4 of our current number - for (int i = 0; i < variansCreatedInThisThread.size() / 4; i++) { - // add a new object - Variant aNewVariant = new Variant(getName() + "_*" - + variansCreatedInThisThread.size()); - variansCreatedInThisThread.add(aNewVariant); - } - } - // now iterate across 1/2 the objects in our list - message += " (removing) "; - for (int i = variansCreatedInThisThread.size(); i > 0; i--) { - // removing every other one? - if (i % 2 == 0) { - // remove the reference so gc can get it - if (!ROT.USE_AUTOMATIC_GARBAGE_COLLECTION) { - // uses deprecated API to set up a special situation - // because this is an ROT test - ROT.removeObject(variansCreatedInThisThread - .get(i - 1)); - } - variansCreatedInThisThread.remove(i - 1); - } + while (variansCreatedInThisThread.size() > 1) { + String message = ""; + message = getName() + " Workingset=" + + variansCreatedInThisThread.size() + + " ROT threadObject hashCode: " + + ROT.getThreadObjects(true).hashCode(); + message += " size before mods and gc " + + ROT.getThreadObjects(true).size() + ")"; + // If there are more than 10 objects in our cache then add 1/4 + // of that again + if (variansCreatedInThisThread.size() > 10) { + message += " (adding) "; + // add an additional 1/4 of our current number + for (int i = 0; i < variansCreatedInThisThread.size() / 4; i++) { + // add a new object + Variant aNewVariant = new Variant(getName() + "_*" + + variansCreatedInThisThread.size()); + variansCreatedInThisThread.add(aNewVariant); + } + } + // now iterate across 1/2 the objects in our list + message += " (removing) "; + for (int i = variansCreatedInThisThread.size(); i > 0; i--) { + // removing every other one? + if (i % 2 == 0) { + // remove the reference so gc can get it + if (!ROT.USE_AUTOMATIC_GARBAGE_COLLECTION) { + // uses deprecated API to set up a special situation + // because this is an ROT test + ROT.removeObject(variansCreatedInThisThread + .get(i - 1)); + } + variansCreatedInThisThread.remove(i - 1); + } - } + } - message += " (after mods " + ROT.getThreadObjects(true).size() - + ")"; - // comm - if (!ROT.USE_AUTOMATIC_GARBAGE_COLLECTION) { - ROT.clearObjects(); - } - System.gc(); - try { - // vain attempt at letting the gc run - Thread.sleep(200); - } catch (InterruptedException ie) { + message += " (after mods " + ROT.getThreadObjects(true).size() + + ")"; + // comm + if (!ROT.USE_AUTOMATIC_GARBAGE_COLLECTION) { + ROT.clearObjects(); + } + System.gc(); + try { + // vain attempt at letting the gc run + Thread.sleep(200); + } catch (InterruptedException ie) { - } - message += " (after gc " + ROT.getThreadObjects(true).size() - + ")"; - message += " Should see GC if debug turned on..."; - System.out.println(message); - } - } + } + message += " (after gc " + ROT.getThreadObjects(true).size() + + ")"; + message += " Should see GC if debug turned on..."; + System.out.println(message); + } + } - /** - * Another test would be to overide this to always return the same name. - * That would really screw the ROT! - * - * @see java.lang.Object#toString() - */ - public String toString() { - return super.toString(); - } - } + /** + * Another test would be to overide this to always return the same name. + * That would really screw the ROT! + * + * @see java.lang.Object#toString() + */ + public String toString() { + return super.toString(); + } + } } diff --git a/src/test/java/com/jacob/com/ROTTest.java b/src/test/java/com/jacob/com/ROTTest.java index eaa12ae..dded69d 100644 --- a/src/test/java/com/jacob/com/ROTTest.java +++ b/src/test/java/com/jacob/com/ROTTest.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -51,121 +51,121 @@ import com.jacob.test.BaseTestCase; */ public class ROTTest extends BaseTestCase { - /** - * verify the SystemProperty (classname).PutInROT functions as expected. A - * value of false means instances of the class are not put in the ROT Any o - * ther value means they are - */ - public void testDontFillROTSystemProperty() { - debug("testDontFillROTSystemProperty: started"); - // Make sure the class is loaded before running any of the tests - // class to load and any pre-defined Variants (FALSE and TRUE) to be - // created immediately - VariantViaEvent.class.getName(); - if (ROT.getThreadObjects(true).entrySet().size() < 1) { - debug("Failure: ROT should have objects in it as soon as Variant class loaded."); - } + /** + * verify the SystemProperty (classname).PutInROT functions as expected. A + * value of false means instances of the class are not put in the ROT Any o + * ther value means they are + */ + public void testDontFillROTSystemProperty() { + debug("testDontFillROTSystemProperty: started"); + // Make sure the class is loaded before running any of the tests + // class to load and any pre-defined Variants (FALSE and TRUE) to be + // created immediately + VariantViaEvent.class.getName(); + if (ROT.getThreadObjects(true).entrySet().size() < 1) { + debug("Failure: ROT should have objects in it as soon as Variant class loaded."); + } - System.setProperty(VariantViaEvent.class.getName() - + ROT.PUT_IN_ROT_SUFFIX, "false"); - int countPriorToTest = ROT.getThreadObjects(true).entrySet().size(); - new VariantViaEvent(); - int countAfterAddWithoutROT = ROT.getThreadObjects(true).entrySet() - .size(); - if (countAfterAddWithoutROT != countPriorToTest) { - debug("Failure: count prior: " + countPriorToTest - + " and count after without ROT was: " - + countAfterAddWithoutROT); - } + System.setProperty(VariantViaEvent.class.getName() + + ROT.PUT_IN_ROT_SUFFIX, "false"); + int countPriorToTest = ROT.getThreadObjects(true).entrySet().size(); + new VariantViaEvent(); + int countAfterAddWithoutROT = ROT.getThreadObjects(true).entrySet() + .size(); + if (countAfterAddWithoutROT != countPriorToTest) { + debug("Failure: count prior: " + countPriorToTest + + " and count after without ROT was: " + + countAfterAddWithoutROT); + } - System.setProperty(VariantViaEvent.class.getName() - + ROT.PUT_IN_ROT_SUFFIX, "true"); - new VariantViaEvent(); - int countAfterAddWithROT = ROT.getThreadObjects(true).entrySet().size(); - if (countAfterAddWithROT != (countPriorToTest + 1)) { - debug("Failure: count prior: " + countPriorToTest - + " and count after with ROT was: " + countAfterAddWithROT); - } - debug("testDontFillROTSystemProperty: completed"); - } + System.setProperty(VariantViaEvent.class.getName() + + ROT.PUT_IN_ROT_SUFFIX, "true"); + new VariantViaEvent(); + int countAfterAddWithROT = ROT.getThreadObjects(true).entrySet().size(); + if (countAfterAddWithROT != (countPriorToTest + 1)) { + debug("Failure: count prior: " + countPriorToTest + + " and count after with ROT was: " + countAfterAddWithROT); + } + debug("testDontFillROTSystemProperty: completed"); + } - /** - * Needs documentation. This test looks broken - * - */ - public void testGCBehavior() { - int sizeBeforeBuild = 0; - int sizeAfterBuild = 0; - int sizeBeforeGC = 0; - int sizeAfterGC = 0; - int loopSize = 10000; - int sizeExpectedAfterBuild = 0; + /** + * Needs documentation. This test looks broken + * + */ + public void testGCBehavior() { + int sizeBeforeBuild = 0; + int sizeAfterBuild = 0; + int sizeBeforeGC = 0; + int sizeAfterGC = 0; + int loopSize = 10000; + int sizeExpectedAfterBuild = 0; - debug("testGCBehavior: started"); - debug("creating 10,000 object sets"); - // cause classes to get loaded and any static instances to be created - SafeArray.class.getName(); - Variant.class.getName(); - sizeBeforeBuild = ROT.getThreadObjects(false).size(); - sizeExpectedAfterBuild = ((loopSize * 3) + sizeBeforeBuild); - for (int i = 0; i < loopSize; i++) { - SafeArray a1 = new SafeArray(Variant.VariantVariant, 2); - a1.setVariant(0, new Variant("foo")); - a1.setVariant(1, new Variant("bar")); - } - sizeAfterBuild = ROT.getThreadObjects(false).size(); - if (sizeAfterBuild < sizeExpectedAfterBuild) { - debug("Something got GC'd: " + sizeAfterBuild); - } else if (sizeAfterBuild > sizeExpectedAfterBuild) { - debug("More: " + sizeAfterBuild + " than expected: " - + sizeExpectedAfterBuild); - } else { - debug("They're all there"); - } - // add more to the VM - debug("Flooding Memory to force GC"); - for (int i = 0; i <= loopSize * 2; i++) { - new String("this is just some text to see if we can force gc " + i); - } - // storage will hold weak references until the next JacobObject is - // created - System.gc(); - sizeBeforeGC = ROT.getThreadObjects(false).size(); - debug("Objects left after flood and gc but before adding a new object that clean's up weak references: " - + sizeBeforeGC); - debug("Creating single object. This adds one and causes ROT to clean up GC'd"); - new JacobObject(); - sizeAfterGC = ROT.getThreadObjects(false).size(); - debug("Objects left after adding one (caused weak ref objects to be removed): " - + sizeAfterGC); - new JacobObject(); - if (ROT.getThreadObjects(false).size() != sizeAfterGC + 1) { - debug("Unexpected number of objects after adding only one more " - + ROT.getThreadObjects(false).size()); - } else { - debug("Found number expected after adding one more " - + (sizeAfterGC + 1)); - } - ROT.clearObjects(); - if (ROT.getThreadObjects(false) == null) { - debug("ROT pool was destroyed as expected after clearObjects called."); - } else { - debug("ROT pool for thread still exists when it shouldn't"); - } + debug("testGCBehavior: started"); + debug("creating 10,000 object sets"); + // cause classes to get loaded and any static instances to be created + SafeArray.class.getName(); + Variant.class.getName(); + sizeBeforeBuild = ROT.getThreadObjects(false).size(); + sizeExpectedAfterBuild = ((loopSize * 3) + sizeBeforeBuild); + for (int i = 0; i < loopSize; i++) { + SafeArray a1 = new SafeArray(Variant.VariantVariant, 2); + a1.setVariant(0, new Variant("foo")); + a1.setVariant(1, new Variant("bar")); + } + sizeAfterBuild = ROT.getThreadObjects(false).size(); + if (sizeAfterBuild < sizeExpectedAfterBuild) { + debug("Something got GC'd: " + sizeAfterBuild); + } else if (sizeAfterBuild > sizeExpectedAfterBuild) { + debug("More: " + sizeAfterBuild + " than expected: " + + sizeExpectedAfterBuild); + } else { + debug("They're all there"); + } + // add more to the VM + debug("Flooding Memory to force GC"); + for (int i = 0; i <= loopSize * 2; i++) { + new String("this is just some text to see if we can force gc " + i); + } + // storage will hold weak references until the next JacobObject is + // created + System.gc(); + sizeBeforeGC = ROT.getThreadObjects(false).size(); + debug("Objects left after flood and gc but before adding a new object that clean's up weak references: " + + sizeBeforeGC); + debug("Creating single object. This adds one and causes ROT to clean up GC'd"); + new JacobObject(); + sizeAfterGC = ROT.getThreadObjects(false).size(); + debug("Objects left after adding one (caused weak ref objects to be removed): " + + sizeAfterGC); + new JacobObject(); + if (ROT.getThreadObjects(false).size() != sizeAfterGC + 1) { + debug("Unexpected number of objects after adding only one more " + + ROT.getThreadObjects(false).size()); + } else { + debug("Found number expected after adding one more " + + (sizeAfterGC + 1)); + } + ROT.clearObjects(); + if (ROT.getThreadObjects(false) == null) { + debug("ROT pool was destroyed as expected after clearObjects called."); + } else { + debug("ROT pool for thread still exists when it shouldn't"); + } - // ========= part two ================================ - debug("Verifying doesn't blow up with double release"); - for (int i = 0; i <= 10000; i++) { - new JacobObject(); - } - // force safeRelease call on all objects - ROT.clearObjects(); - // now force the gc to go collect them, running safeRelease again - System.gc(); - debug("testGCBehavior: finished"); - } + // ========= part two ================================ + debug("Verifying doesn't blow up with double release"); + for (int i = 0; i <= 10000; i++) { + new JacobObject(); + } + // force safeRelease call on all objects + ROT.clearObjects(); + // now force the gc to go collect them, running safeRelease again + System.gc(); + debug("testGCBehavior: finished"); + } - private static void debug(String message) { - System.out.println(Thread.currentThread().getName() + " " + message); - } + private static void debug(String message) { + System.out.println(Thread.currentThread().getName() + " " + message); + } } diff --git a/src/test/java/com/jacob/com/VariantDateTest.java b/src/test/java/com/jacob/com/VariantDateTest.java index a05f963..b024544 100644 --- a/src/test/java/com/jacob/com/VariantDateTest.java +++ b/src/test/java/com/jacob/com/VariantDateTest.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -51,58 +51,58 @@ import com.jacob.test.BaseTestCase; */ public class VariantDateTest extends BaseTestCase { - /** - * verify the conversion of Variants into java dates - */ - public void testVariantDate() { - Date now = new Date(); - Variant holder = new Variant(); - holder.putDate(now); - Date retrievedNow = holder.getJavaDate(); - if (!now.equals(retrievedNow)) { - fail("Variant Date Test failed " + now + " != " + retrievedNow); - } else { - System.out.println("Variant Date Test passed"); - } + /** + * verify the conversion of Variants into java dates + */ + public void testVariantDate() { + Date now = new Date(); + Variant holder = new Variant(); + holder.putDate(now); + Date retrievedNow = holder.getJavaDate(); + if (!now.equals(retrievedNow)) { + fail("Variant Date Test failed " + now + " != " + retrievedNow); + } else { + System.out.println("Variant Date Test passed"); + } - } + } - /** - * verify that the Variant constructor accepts Java dates and converts them - * correctly - */ - public void testVariantDateToJavaObject() { - Date now = new Date(); - Variant holder = new Variant(now); - for (int i = 0; i < 30000; i++) { - Variant dateVariant = new Variant(now); - Date retrievedNow = holder.getJavaDate(); - retrievedNow = dateVariant.getJavaDate(); - if (!now.equals(retrievedNow)) { - fail("Variant Date Test (1) failed " + now + " != " - + retrievedNow); - } else { - // System.out.println("Variant Date Test (1) passed"); - } - // verify auto typecasting works - retrievedNow = (Date) dateVariant.toJavaObject(); - if (!now.equals(retrievedNow)) { - fail("Variant Date Test (2) failed " + now + " != " - + retrievedNow); - } else { - // System.out.println("Variant Date Test (2) passed - // "+retrievedNow); - } + /** + * verify that the Variant constructor accepts Java dates and converts them + * correctly + */ + public void testVariantDateToJavaObject() { + Date now = new Date(); + Variant holder = new Variant(now); + for (int i = 0; i < 30000; i++) { + Variant dateVariant = new Variant(now); + Date retrievedNow = holder.getJavaDate(); + retrievedNow = dateVariant.getJavaDate(); + if (!now.equals(retrievedNow)) { + fail("Variant Date Test (1) failed " + now + " != " + + retrievedNow); + } else { + // System.out.println("Variant Date Test (1) passed"); + } + // verify auto typecasting works + retrievedNow = (Date) dateVariant.toJavaObject(); + if (!now.equals(retrievedNow)) { + fail("Variant Date Test (2) failed " + now + " != " + + retrievedNow); + } else { + // System.out.println("Variant Date Test (2) passed + // "+retrievedNow); + } - Variant intVariant = new Variant(4); - Object variantReturn = intVariant.toJavaObject(); - // degenerate test to make sure date isn't always returned - if (variantReturn instanceof Date) { - System.out.println("int variant returned date"); - } - } - System.out.print("Test finished. All tests passed."); + Variant intVariant = new Variant(4); + Object variantReturn = intVariant.toJavaObject(); + // degenerate test to make sure date isn't always returned + if (variantReturn instanceof Date) { + System.out.println("int variant returned date"); + } + } + System.out.print("Test finished. All tests passed."); - } + } } diff --git a/src/test/java/com/jacob/com/VariantTest.java b/src/test/java/com/jacob/com/VariantTest.java index 99c384e..f69df41 100644 --- a/src/test/java/com/jacob/com/VariantTest.java +++ b/src/test/java/com/jacob/com/VariantTest.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -54,730 +54,730 @@ import com.jacob.test.BaseTestCase; */ public class VariantTest extends BaseTestCase { - /** - * This verifies that toJavaObject() works for all of the main data types - * when they exist as a byRef version. - *

      - * It compares the toJavaObject() for a byref against the toJavaObject() for - * the regular. - * - */ - public void testByRefToJavaObject() { - Variant v = null; - Variant vByRef = null; - - v = new Variant(new Float(53.3), false); - vByRef = new Variant(new Float(53.3), true); - if (!v.toJavaObject().equals(vByRef.toJavaObject())) { - fail(v.toString() + " could not make type " + v.getvt() + " and " - + vByRef.getvt() + " java objects come out the same"); - } - v = new Variant(new Double(53.3), false); - vByRef = new Variant(new Double(53.3), true); - if (!v.toJavaObject().equals(vByRef.toJavaObject())) { - fail(v.toString() + " could not make type " + v.getvt() + " and " - + vByRef.getvt() + " java objects come out the same"); - } - - v = new Variant(new Boolean(true), false); - vByRef = new Variant(new Boolean(true), true); - if (!v.toJavaObject().equals(vByRef.toJavaObject())) { - fail(v.toString() + " could not make type " + v.getvt() + " and " - + vByRef.getvt() + " java objects come out the same"); - } - - v = new Variant(new Integer(53), false); - vByRef = new Variant(new Integer(53), true); - if (!v.toJavaObject().equals(vByRef.toJavaObject())) { - fail(v.toString() + " could not make type " + v.getvt() + " and " - + vByRef.getvt() + " java objects come out the same"); - } - - v = new Variant(new Short((short) 53), false); - vByRef = new Variant(new Short((short) 53), true); - if (!v.toJavaObject().equals(vByRef.toJavaObject())) { - fail(v.toString() + " could not make type " + v.getvt() + " and " - + vByRef.getvt() + " java objects come out the same"); - } - - v = new Variant("53.33", false); - vByRef = new Variant("53.33", true); - if (!v.toJavaObject().equals(vByRef.toJavaObject())) { - fail(v.toString() + " could not make type " + v.getvt() + " and " - + vByRef.getvt() + " java objects come out the same"); - } - - // Ugh, you have to pick a magic number whose scale is less than 28 - // 53.53 had a scale of 64 and 53.52 had a scale of 47 - BigDecimal testDecimal = new BigDecimal(53.50); - v = new Variant(testDecimal, false); - vByRef = new Variant(testDecimal, true); - if (!v.toJavaObject().equals(vByRef.toJavaObject())) { - fail(v.toString() + " could not make type " + v.getvt() + " and " - + vByRef.getvt() + " java objects come out the same"); - } - - Date now = new Date(); - v = new Variant(now, false); - vByRef = new Variant(now, true); - if (!v.toJavaObject().equals(vByRef.toJavaObject())) { - fail(v.toString() + " could not make type " + v.getvt() + " and " - + vByRef.getvt() + " java objects come out the same"); - } - } - - /** - * try and test VT_I8. This should only work on 64 bit machines - */ - public void testLong() { - Variant v = null; - Variant vByRef = null; - - long longNumber = 1L << 40; - v = new Variant(new Long(longNumber), false); - vByRef = new Variant(new Long(longNumber), true); - assertEquals("Could recover long number " + longNumber, v.getLong(), - longNumber); - assertEquals("Could not make long number " + longNumber - + " come out the same for get and getByRef()", - v.toJavaObject(), vByRef.toJavaObject()); - v = new Variant("" + longNumber); - v.changeType(Variant.VariantLongInt); - assertEquals("Conversion from string to long didn't work ", - v.getLong(), longNumber); - } - - /** - * do some testing around currencies - */ - public void testCurrencyHandling() { - Variant v = null; - Variant vByRef = null; - - // need to do currency also - // currency is an integer scaled up by 10,000 to give 4 digits to the - // right of the decimal - int currencyScale = 10000; - long twentyThousand = 20000 * currencyScale; - Currency twentyThousandAsCurrency = new Currency(twentyThousand); - v = new Variant(twentyThousandAsCurrency, false); - vByRef = new Variant(twentyThousandAsCurrency, true); - if (!(v.toJavaObject() instanceof Currency)) { - fail("v.toJavaObject was not Long for currency but was: " - + v.toJavaObject()); - } - if (!v.toJavaObject().equals(vByRef.toJavaObject())) { - fail(v.toString() + " could not make type " + v.getvt() + " and " - + vByRef.getvt() + " java objects come out the same"); - } - long twentyThousandDotSeven = twentyThousand + 700; - Currency twentyThousandDotSevenAsCurrency = new Currency( - twentyThousandDotSeven); - // use the primitive constructor - v = new Variant(twentyThousandDotSevenAsCurrency); - assertEquals("failed test with " + twentyThousandDotSeven, - twentyThousandDotSeven, v.getCurrency().longValue()); - - } - - /** - * 4/2007 bug report toObject on dispatch tries to call getDispatchRef - * instead of getDispatch so toString() on dispatch blows up. - * - */ - public void testDispatchToJavaObject() { - Variant v2 = new Variant(); - v2.putNothing(); - // this test fails even though the exact same code below works fine - // v2.toJavaObject(); - } - - /** - * see what happens when we conver to by ref - * - */ - public void testSomeChangeVT() { - Variant v; - // the code shows e shouldn't need to use a returned Variant but the - // test says we do - Variant vConverted; - v = new Variant(53.3); - short originalVT = v.getvt(); - short modifier; - - modifier = Variant.VariantShort; - vConverted = v.changeType(modifier); - if (vConverted.getvt() != modifier) { - fail("Failed to change Variant " + originalVT + " using mask " - + modifier + " resulted in " + vConverted.getvt()); - } - - modifier = Variant.VariantString; - vConverted = v.changeType(modifier); - if (vConverted.getvt() != modifier) { - fail("Failed to change Variant " + originalVT + " using mask " - + modifier + " resulted in " + vConverted.getvt()); - } - - // can't convert to byref! - modifier = Variant.VariantByref | Variant.VariantShort; - vConverted = v.changeType(modifier); - if (vConverted.getvt() == modifier) { - fail("Should not have been able to change Variant " + originalVT - + " using mask " + modifier + " resulted in " - + vConverted.getvt()); - } - } - - /** - * make sure variant with no backing store works. - * - */ - public void testUninitializedVariant() { - Variant v; - // Variants created without parameters are auto set to VariantEmpty - v = new Variant(); - try { - if (v.getvt() == Variant.VariantEmpty) { - // successful - // System.out.println("Variant initialized without parameters - // correctly set to empty"); - } else { - throw new RuntimeException( - "getvt() on uninitialized variant shoud have returned VariantEmpty, instead returned " - + v.getvt()); - } - } catch (IllegalStateException ise) { - throw new RuntimeException( - "getvt() on uninitialized variant shoud have succeeded, but instead threw exception"); - } - try { - v.toString(); - } catch (IllegalStateException ise) { - fail("toString() should never throw a runtime exception"); - throw new RuntimeException( - "toString() should not blow up even with uninitialized Variant"); - } - - } - - /** - * - * verify the toString() method does not do type conversion - */ - public void testToStringDoesNotConvert() { - Variant v; - v = new Variant(true); - v.toString(); - if (v.getvt() != Variant.VariantBoolean) { - throw new RuntimeException( - "toString() converted boolean to something else"); - } else { - // fail("toString() correctly does not convert type"); - } - if (v.getBoolean() != true) { - fail("toString() converted boolean true to " + v.getBoolean()); - } - v = new Variant(false); - v.toString(); - if (v.getvt() != Variant.VariantBoolean) { - throw new RuntimeException( - "toString() converted boolean to something else"); - } else { - // fail("toString() correctly does not convert type"); - } - if (v.getBoolean() != false) { - fail("toString() converted boolean false to " + v.getBoolean()); - } - } - - /** - * Exercise ToString special cases - */ - public void testToStringEmptyValues() { - Variant v; - // create an empty variant - v = new Variant(); - // check date per - v.changeType(Variant.VariantDate); - assertEquals("null", v.toString()); - v.putDate(new Date()); - assertNotNull(v.toString()); - assertFalse("null".equals(v.toString())); - - v.changeType(Variant.VariantInt); - v.putInt(1); - - assertEquals("1", v.toString()); - v.changeType(Variant.VariantEmpty); - assertEquals("null", v.toString()); - v.changeType(Variant.VariantNull); - assertEquals("null", v.toString()); - v.changeType(Variant.VariantError); - assertEquals("null", v.toString()); - } - - /** - * Verify that booleans can be released. Part of the suite that checks all - * types. - */ - public void testSafeReleaseBoolean() { - Variant v; - v = new Variant(true); - // System.out.println("Newly created Variant ("+ v.getBoolean()+") "+ - // "trying to create access violation but it doesn't seem to be easy"); - v.safeRelease(); - try { - v.getBoolean(); - fail("IllegalStateException should have been thrown when querying safeReleased object"); - throw new RuntimeException("test failed"); - } catch (IllegalStateException ise) { - // System.out.println("IllegalStateException correctly thrown after - // safeRelease"); - } - v = new Variant(true); - for (int i = 0; i < 10; i++) { - new Variant("xxx" + i); - new Variant(i); - new Variant("yyy" + i); - } - ComThread.Release(); - try { - v.getBoolean(); - fail("IllegalStateException should have been thrown when querying ComThread.Release"); - throw new RuntimeException("test failed"); - } catch (IllegalStateException ise) { - // System.out.println("IllegalStateException correctly thrown after - // ComThread.Release"); - } - } - - /** - * verify the constant values aren't released with safeRelease - * - */ - public void testSafeReleaseConstant() { - // System.out.println("Using Static constant Variant - should never - // throw access violation"); - Variant.VT_TRUE.safeRelease(); - if (Variant.VT_TRUE.getBoolean() != true) { - fail("VT_TRUE has been broken by SafeRelease()"); - throw new RuntimeException("test failed"); - } else { - // System.out.println("VT_TRUE survived SafeRelease()"); - } - - for (int i = 0; i < 10; i++) { - new Variant("xxx" + i); - new Variant(i); - new Variant("yyy" + i); - } - ComThread.Release(); - - if (Variant.VT_TRUE.getBoolean() != true) { - fail("VT_TRUE has been broken by ComThread.Release()"); - throw new RuntimeException("test failed"); - } else { - // System.out.println("VT_TRUE survived ComThread.Release()"); - } - - } - - /** - * this used to try and and create an access violation but that didn't work - * and now the methods on the Variant are smarter about working after a - * release - * - */ - public void testSafeReleaseString() { - String mTestString = "Guitar Hero"; - Variant v = new Variant(mTestString); - // System.out.println("Newly created Variant ("+ v.getString()+") "+ - // "about to safe release and then access"); - v.safeRelease(); - try { - v.getString(); - fail("IllegalStateException should have been thrown when querying safeReleased object"); - throw new RuntimeException("test failed"); - } catch (IllegalStateException ise) { - // System.out.println("IllegalStateException correctly thrown after - // safeRelease"); - } - } - - /** - * verifies objectIsAConstant works as expected - * - */ - public void testObjectIsAConstant() { - Variant v = new Variant("d"); - if (!v.objectIsAConstant(Variant.VT_FALSE)) { - fail("did not recognize VT_FALSE"); - } - if (!v.objectIsAConstant(Variant.VT_TRUE)) { - fail("did not recognize VT_TRUE"); - } - if (!v.objectIsAConstant(Variant.VT_MISSING)) { - fail("did not recognize VT_MISSING"); - } - if (!v.objectIsAConstant(Variant.DEFAULT)) { - fail("did not recognize DEFAULT"); - } - if (v.objectIsAConstant(new Variant(true))) { - fail("confused a boolean with VT_TRUE"); - } - if (v.objectIsAConstant(new Variant(false))) { - fail("confused a boolean with VT_FALSE"); - } - - } - - /** - * tests put and get methods looking for obvious defects - * - */ - public void testPutsAndGets() { - Variant v = new Variant(); - - v.putInt(10); - assertEquals("int test failed", 10, v.getInt()); - - v.putShort((short) 20); - assertEquals("short test failed", (short) 20, v.getShort()); - - v.putByte((byte) 30); - assertEquals("byte test failed", (byte) 30, v.getByte()); - - v.putFloat(40); - if (v.getFloat() != 40.0) { - fail("float test failed"); - } - - v.putDouble(50); - if (v.getDouble() != 50.0) { - fail("double test failed"); - } - - v.putString("1234.567"); - assertEquals("string test failed", "1234.567", v.getString()); - - v.putBoolean(true); - assertEquals("failed boolean test(true)", true, v.getBoolean()); - - v.putBoolean(false); - assertEquals("failed boolean test(false)", false, v.getBoolean()); - - long originalValue = 123456789123456789L; - v.putCurrency(new Currency(originalValue)); - assertEquals("failed currency test", 123456789123456789L, v - .getCurrency().longValue()); - - BigDecimal testDecimal = new BigDecimal("22.222"); - v.putDecimal(testDecimal); - assertEquals("failed BigDecimal test", testDecimal, v.getDecimal()); - - Date ourDate = new Date(); - v.putDate(ourDate); - Date retrievedDate = v.getJavaDate(); - if (!retrievedDate.equals(ourDate)) { - fail("failed java date load and unload"); - } - - v.putNull(); - if (!v.isNull()) { - fail("failed detecting set null"); - } - v.putString("something other than null"); - if (v.isNull()) { - fail("failed null replacement with string"); - } - - v.putEmpty(); - if (!v.isNull()) { - fail("failed detecting set empty as null"); - } - v.putString("something other than null"); - if (v.isNull()) { - fail("failed empty replacement with string as isNull"); - } - - Variant v2 = new Variant(); - v2.putNothing(); - if (v2.getvt() != Variant.VariantDispatch) { - fail("putNothing was supposed to set the type to VariantDispatch"); - } - if (!v2.isNull()) { - fail("putNothing is supposed to cause isNull() to return true"); - } - // this line blows up in the test above - if (v2.toJavaObject() == null) { - fail("putNothing() followed by toJavaObject() should return a Dispatch"); - } - - } - - /** - * verify decimal works right - */ - public void testDecimalConversion() { - Variant v = new Variant(); - v.changeType(Variant.VariantDecimal); - for (int i = 10; i >= -10; i--) { - v.putDecimal(new BigDecimal(i)); - // first see if we can get it back as decimal - assertEquals("conversion back to decimal failed " + i, - new BigDecimal(i), v.getDecimal()); - v.changeType(Variant.VariantFloat); - // now see if a float conversion would work - assertEquals("conversion to float failed " + i, new Float(i), - v.getFloat()); - // now convert it back to decimal for reassignment - v.changeType(Variant.VariantDecimal); - assertTrue("Failed conversion of type back to Decimal " + i, - v.getvt() == Variant.VariantDecimal); - } - - } - - /** - * for(BigDecimal i in 79228162514264337593543950330.0 .. - * 79228162514264337593543950341.0) { com.jacob.com.Variant dv = new - * com.jacob.com.Variant(i, false) println i + " : " + dv.getDecimal() } - * - */ - public void testLargeDecimals() { - // the largest decimal number, not in hex is - // 7922816251426433759354395033.0 - BigInteger theStartDigits = new BigInteger("ffffffffffffffffffffff00", - 16); - BigInteger theMaxDigits = new BigInteger("ffffffffffffffffffffffff", 16); - BigDecimal startDecimal = new BigDecimal(theStartDigits); - BigDecimal endDecimal = new BigDecimal(theMaxDigits); - BigDecimal incrementDecimal = new BigDecimal(1); - BigDecimal testDecimal = startDecimal; - Variant testVariant; - while (endDecimal.compareTo(testDecimal) >= 0) { - testVariant = new Variant(testDecimal, false); - BigDecimal result = testVariant.getDecimal(); - assertEquals(testDecimal, result); - testDecimal = testDecimal.add(incrementDecimal); - } - // test Decimal is now too large - try { - new Variant(testDecimal, false); - } catch (IllegalArgumentException iae) { - // System.out.println("Caught expected exception"); - } - // lets try something different. we can call putVariant with rounding - // enabled - testVariant = new Variant(); - testVariant.changeType(Variant.VariantDecimal); - try { - testVariant.putDecimal(endDecimal.setScale(30)); - fail("Should have thrown exception with scale of 30 and no rounding"); - } catch (IllegalArgumentException iae) { - // should have caught this exception - } - // now we test with a negative scale. Note that you can't do with - // without some magic, in this case scientific notation - try { - testVariant.putDecimal(new BigDecimal("700E24")); - assertTrue(new BigDecimal("700E24").compareTo(testVariant - .getDecimal()) == 0); - } catch (IllegalArgumentException iae) { - // should have caught this exception - } - - testVariant.putDecimal(VariantUtilities - .roundToMSDecimal(new BigDecimal("700E24"))); - // use compareTo because it takes into account varying scales - assertTrue(new BigDecimal("700E24").compareTo(testVariant.getDecimal()) == 0); - - // This passes because the number is within range. - testVariant.putDecimal(endDecimal); - - // this should pass because we have rounding turned on - // it turns out the max number gets more digits when - // it's scale is set to 30. so we can't use the max number when there is - // a scale - BigDecimal modifiedDecimal = endDecimal; - System.out.println("integer piece starts as " - + modifiedDecimal.unscaledValue().toString(16) + " scale=: " - + modifiedDecimal.scale()); - System.out.println("integer piece after rounding without scale is " - + VariantUtilities.roundToMSDecimal(modifiedDecimal) - .unscaledValue().toString(16) + " scale=: " - + modifiedDecimal.scale()); - System.out.println("integer piece after rounding with scale 30 is " - + VariantUtilities - .roundToMSDecimal(modifiedDecimal.setScale(30)) - .unscaledValue().toString(16) + " scale=: " - + modifiedDecimal.scale()); - try { - testVariant.putDecimal(VariantUtilities - .roundToMSDecimal(modifiedDecimal.setScale(30))); - fail("should have thrown an exception for a number whose scale " - + "change created too many digits to be represented."); - } catch (IllegalArgumentException iae) { - // should catch an exception here because the rounding after scale - // change would have made the number too large - } - - System.out.println(""); - modifiedDecimal = endDecimal.subtract(incrementDecimal); - System.out.println("integer piece starts as " - + modifiedDecimal.unscaledValue().toString(16) + " scale=: " - + modifiedDecimal.scale()); - System.out.println("integer piece after rounding without scale is " - + VariantUtilities.roundToMSDecimal(modifiedDecimal) - .unscaledValue().toString(16) + " scale=: " - + modifiedDecimal.scale()); - System.out.println("integer piece after rounding with scale 30 is " - + VariantUtilities - .roundToMSDecimal(modifiedDecimal.setScale(30)) - .unscaledValue().toString(16) + " scale=: " - + modifiedDecimal.scale()); - testVariant.putDecimal(VariantUtilities - .roundToMSDecimal(modifiedDecimal.setScale(30))); - System.out.println(""); - } - - /** - * Spin up a lot of threads and have them all create variants 3/2007 there - * have been several reports in multi-threaded servers that show init() - * failing - * - */ - public void testManyThreadedInit() { - VariantInitTestThread threads[] = new VariantInitTestThread[75]; - - System.out.println("Starting thread test (" + threads.length - + " threads each creating 10000 objects)." - + " This may take 30 seconds or more."); - for (int i = 0; i < threads.length; i++) { - threads[i] = new VariantInitTestThread("thread-" + i, 10000); - } - for (int i = 0; i < threads.length; i++) { - threads[i].start(); - } - int numComplete = 0; - while (numComplete < threads.length) { - // give the works time to work - try { - Thread.sleep(333); - } catch (InterruptedException ie) { - // do nothing - } - numComplete = 0; - for (int i = 0; i < threads.length; i++) { - if (threads[i].isComplete) { - numComplete++; - } - } - // System.out.print("["+numComplete+"/"+threads.length+"]"); - } - System.out.println("Finished thread test"); - } - - /** - * a class to create variants in separate threads - * - */ - class VariantInitTestThread extends Thread { - private boolean isComplete = false; - - private int initialRunSize = 0; - - /** - * @param newThreadName - * the name for the thread - * @param iStartCount - * number of threads to start with - */ - public VariantInitTestThread(String newThreadName, int iStartCount) { - super(newThreadName); - initialRunSize = iStartCount; - - } - - /** - * getter so master can see if thread is done - * - * @return state of complete flag - */ - public boolean isComplete() { - return isComplete; - } - - /** - * Blow out a bunch of Variants - * - * @see java.lang.Runnable#run() - */ - @Override - public void run() { - for (int variantIndex = 0; variantIndex < initialRunSize; variantIndex++) { - try { - Thread.yield(); - Thread.sleep(0); - } catch (InterruptedException ie) { - // do nothing - } - // System.out.println(Thread.currentThread().getName()); - Variant testSubject = new Variant(variantIndex); - testSubject.getvt(); - testSubject.getInt(); - } - isComplete = true; - } - } - - /** - * there was a bitwise masking error that let booleans be seen as dispatch - * objects Bug Report SF3065265 - */ - public void testGetDispatch() { - Variant testVariant = new Variant(); - testVariant.putBooleanRef(true); - try { - // throws IllegalStateException if Jacob detects the type - // throws some other bad exception if COM blows up failing the - // conversion - testVariant.getDispatchRef(); - fail("Should not have converted boolean to dispatch"); - } catch (IllegalStateException e) { - // yeah! can't get dispatch from boolean - } - } - - /** - * there was a bitwise masking error that let booleans be seen as dispatch - * objects Bug Report SF3065265 - */ - public void testGetError() { - Variant testVariant = new Variant(); - testVariant.putErrorRef(3); - try { - // throws IllegalStateException if Jacob detects the type - // throws some other bad exception if COM blows up failing the - // conversion - testVariant.getStringRef(); - fail("Should not have converted error to string"); - } catch (IllegalStateException e) { - // yeah! can't get dispatch from boolean - } - } - - /** - * Verify SF 3435567 null and empty behavior change - */ - public void testGetNullString() { - Variant testVariant = new Variant(); - testVariant.putNull(); - assertNull(testVariant.getString()); - testVariant.putEmpty(); - assertNull(testVariant.getString()); - testVariant.putString("dog"); - assertEquals("dog", testVariant.getString()); - } + /** + * This verifies that toJavaObject() works for all of the main data types + * when they exist as a byRef version. + *

      + * It compares the toJavaObject() for a byref against the toJavaObject() for + * the regular. + * + */ + public void testByRefToJavaObject() { + Variant v = null; + Variant vByRef = null; + + v = new Variant(new Float(53.3), false); + vByRef = new Variant(new Float(53.3), true); + if (!v.toJavaObject().equals(vByRef.toJavaObject())) { + fail(v.toString() + " could not make type " + v.getvt() + " and " + + vByRef.getvt() + " java objects come out the same"); + } + v = new Variant(new Double(53.3), false); + vByRef = new Variant(new Double(53.3), true); + if (!v.toJavaObject().equals(vByRef.toJavaObject())) { + fail(v.toString() + " could not make type " + v.getvt() + " and " + + vByRef.getvt() + " java objects come out the same"); + } + + v = new Variant(new Boolean(true), false); + vByRef = new Variant(new Boolean(true), true); + if (!v.toJavaObject().equals(vByRef.toJavaObject())) { + fail(v.toString() + " could not make type " + v.getvt() + " and " + + vByRef.getvt() + " java objects come out the same"); + } + + v = new Variant(new Integer(53), false); + vByRef = new Variant(new Integer(53), true); + if (!v.toJavaObject().equals(vByRef.toJavaObject())) { + fail(v.toString() + " could not make type " + v.getvt() + " and " + + vByRef.getvt() + " java objects come out the same"); + } + + v = new Variant(new Short((short) 53), false); + vByRef = new Variant(new Short((short) 53), true); + if (!v.toJavaObject().equals(vByRef.toJavaObject())) { + fail(v.toString() + " could not make type " + v.getvt() + " and " + + vByRef.getvt() + " java objects come out the same"); + } + + v = new Variant("53.33", false); + vByRef = new Variant("53.33", true); + if (!v.toJavaObject().equals(vByRef.toJavaObject())) { + fail(v.toString() + " could not make type " + v.getvt() + " and " + + vByRef.getvt() + " java objects come out the same"); + } + + // Ugh, you have to pick a magic number whose scale is less than 28 + // 53.53 had a scale of 64 and 53.52 had a scale of 47 + BigDecimal testDecimal = new BigDecimal(53.50); + v = new Variant(testDecimal, false); + vByRef = new Variant(testDecimal, true); + if (!v.toJavaObject().equals(vByRef.toJavaObject())) { + fail(v.toString() + " could not make type " + v.getvt() + " and " + + vByRef.getvt() + " java objects come out the same"); + } + + Date now = new Date(); + v = new Variant(now, false); + vByRef = new Variant(now, true); + if (!v.toJavaObject().equals(vByRef.toJavaObject())) { + fail(v.toString() + " could not make type " + v.getvt() + " and " + + vByRef.getvt() + " java objects come out the same"); + } + } + + /** + * try and test VT_I8. This should only work on 64 bit machines + */ + public void testLong() { + Variant v = null; + Variant vByRef = null; + + long longNumber = 1L << 40; + v = new Variant(new Long(longNumber), false); + vByRef = new Variant(new Long(longNumber), true); + assertEquals("Could recover long number " + longNumber, v.getLong(), + longNumber); + assertEquals("Could not make long number " + longNumber + + " come out the same for get and getByRef()", + v.toJavaObject(), vByRef.toJavaObject()); + v = new Variant("" + longNumber); + v.changeType(Variant.VariantLongInt); + assertEquals("Conversion from string to long didn't work ", + v.getLong(), longNumber); + } + + /** + * do some testing around currencies + */ + public void testCurrencyHandling() { + Variant v = null; + Variant vByRef = null; + + // need to do currency also + // currency is an integer scaled up by 10,000 to give 4 digits to the + // right of the decimal + int currencyScale = 10000; + long twentyThousand = 20000 * currencyScale; + Currency twentyThousandAsCurrency = new Currency(twentyThousand); + v = new Variant(twentyThousandAsCurrency, false); + vByRef = new Variant(twentyThousandAsCurrency, true); + if (!(v.toJavaObject() instanceof Currency)) { + fail("v.toJavaObject was not Long for currency but was: " + + v.toJavaObject()); + } + if (!v.toJavaObject().equals(vByRef.toJavaObject())) { + fail(v.toString() + " could not make type " + v.getvt() + " and " + + vByRef.getvt() + " java objects come out the same"); + } + long twentyThousandDotSeven = twentyThousand + 700; + Currency twentyThousandDotSevenAsCurrency = new Currency( + twentyThousandDotSeven); + // use the primitive constructor + v = new Variant(twentyThousandDotSevenAsCurrency); + assertEquals("failed test with " + twentyThousandDotSeven, + twentyThousandDotSeven, v.getCurrency().longValue()); + + } + + /** + * 4/2007 bug report toObject on dispatch tries to call getDispatchRef + * instead of getDispatch so toString() on dispatch blows up. + * + */ + public void testDispatchToJavaObject() { + Variant v2 = new Variant(); + v2.putNothing(); + // this test fails even though the exact same code below works fine + // v2.toJavaObject(); + } + + /** + * see what happens when we conver to by ref + * + */ + public void testSomeChangeVT() { + Variant v; + // the code shows e shouldn't need to use a returned Variant but the + // test says we do + Variant vConverted; + v = new Variant(53.3); + short originalVT = v.getvt(); + short modifier; + + modifier = Variant.VariantShort; + vConverted = v.changeType(modifier); + if (vConverted.getvt() != modifier) { + fail("Failed to change Variant " + originalVT + " using mask " + + modifier + " resulted in " + vConverted.getvt()); + } + + modifier = Variant.VariantString; + vConverted = v.changeType(modifier); + if (vConverted.getvt() != modifier) { + fail("Failed to change Variant " + originalVT + " using mask " + + modifier + " resulted in " + vConverted.getvt()); + } + + // can't convert to byref! + modifier = Variant.VariantByref | Variant.VariantShort; + vConverted = v.changeType(modifier); + if (vConverted.getvt() == modifier) { + fail("Should not have been able to change Variant " + originalVT + + " using mask " + modifier + " resulted in " + + vConverted.getvt()); + } + } + + /** + * make sure variant with no backing store works. + * + */ + public void testUninitializedVariant() { + Variant v; + // Variants created without parameters are auto set to VariantEmpty + v = new Variant(); + try { + if (v.getvt() == Variant.VariantEmpty) { + // successful + // System.out.println("Variant initialized without parameters + // correctly set to empty"); + } else { + throw new RuntimeException( + "getvt() on uninitialized variant shoud have returned VariantEmpty, instead returned " + + v.getvt()); + } + } catch (IllegalStateException ise) { + throw new RuntimeException( + "getvt() on uninitialized variant shoud have succeeded, but instead threw exception"); + } + try { + v.toString(); + } catch (IllegalStateException ise) { + fail("toString() should never throw a runtime exception"); + throw new RuntimeException( + "toString() should not blow up even with uninitialized Variant"); + } + + } + + /** + * + * verify the toString() method does not do type conversion + */ + public void testToStringDoesNotConvert() { + Variant v; + v = new Variant(true); + v.toString(); + if (v.getvt() != Variant.VariantBoolean) { + throw new RuntimeException( + "toString() converted boolean to something else"); + } else { + // fail("toString() correctly does not convert type"); + } + if (v.getBoolean() != true) { + fail("toString() converted boolean true to " + v.getBoolean()); + } + v = new Variant(false); + v.toString(); + if (v.getvt() != Variant.VariantBoolean) { + throw new RuntimeException( + "toString() converted boolean to something else"); + } else { + // fail("toString() correctly does not convert type"); + } + if (v.getBoolean() != false) { + fail("toString() converted boolean false to " + v.getBoolean()); + } + } + + /** + * Exercise ToString special cases + */ + public void testToStringEmptyValues() { + Variant v; + // create an empty variant + v = new Variant(); + // check date per + v.changeType(Variant.VariantDate); + assertEquals("null", v.toString()); + v.putDate(new Date()); + assertNotNull(v.toString()); + assertFalse("null".equals(v.toString())); + + v.changeType(Variant.VariantInt); + v.putInt(1); + + assertEquals("1", v.toString()); + v.changeType(Variant.VariantEmpty); + assertEquals("null", v.toString()); + v.changeType(Variant.VariantNull); + assertEquals("null", v.toString()); + v.changeType(Variant.VariantError); + assertEquals("null", v.toString()); + } + + /** + * Verify that booleans can be released. Part of the suite that checks all + * types. + */ + public void testSafeReleaseBoolean() { + Variant v; + v = new Variant(true); + // System.out.println("Newly created Variant ("+ v.getBoolean()+") "+ + // "trying to create access violation but it doesn't seem to be easy"); + v.safeRelease(); + try { + v.getBoolean(); + fail("IllegalStateException should have been thrown when querying safeReleased object"); + throw new RuntimeException("test failed"); + } catch (IllegalStateException ise) { + // System.out.println("IllegalStateException correctly thrown after + // safeRelease"); + } + v = new Variant(true); + for (int i = 0; i < 10; i++) { + new Variant("xxx" + i); + new Variant(i); + new Variant("yyy" + i); + } + ComThread.Release(); + try { + v.getBoolean(); + fail("IllegalStateException should have been thrown when querying ComThread.Release"); + throw new RuntimeException("test failed"); + } catch (IllegalStateException ise) { + // System.out.println("IllegalStateException correctly thrown after + // ComThread.Release"); + } + } + + /** + * verify the constant values aren't released with safeRelease + * + */ + public void testSafeReleaseConstant() { + // System.out.println("Using Static constant Variant - should never + // throw access violation"); + Variant.VT_TRUE.safeRelease(); + if (Variant.VT_TRUE.getBoolean() != true) { + fail("VT_TRUE has been broken by SafeRelease()"); + throw new RuntimeException("test failed"); + } else { + // System.out.println("VT_TRUE survived SafeRelease()"); + } + + for (int i = 0; i < 10; i++) { + new Variant("xxx" + i); + new Variant(i); + new Variant("yyy" + i); + } + ComThread.Release(); + + if (Variant.VT_TRUE.getBoolean() != true) { + fail("VT_TRUE has been broken by ComThread.Release()"); + throw new RuntimeException("test failed"); + } else { + // System.out.println("VT_TRUE survived ComThread.Release()"); + } + + } + + /** + * this used to try and and create an access violation but that didn't work + * and now the methods on the Variant are smarter about working after a + * release + * + */ + public void testSafeReleaseString() { + String mTestString = "Guitar Hero"; + Variant v = new Variant(mTestString); + // System.out.println("Newly created Variant ("+ v.getString()+") "+ + // "about to safe release and then access"); + v.safeRelease(); + try { + v.getString(); + fail("IllegalStateException should have been thrown when querying safeReleased object"); + throw new RuntimeException("test failed"); + } catch (IllegalStateException ise) { + // System.out.println("IllegalStateException correctly thrown after + // safeRelease"); + } + } + + /** + * verifies objectIsAConstant works as expected + * + */ + public void testObjectIsAConstant() { + Variant v = new Variant("d"); + if (!v.objectIsAConstant(Variant.VT_FALSE)) { + fail("did not recognize VT_FALSE"); + } + if (!v.objectIsAConstant(Variant.VT_TRUE)) { + fail("did not recognize VT_TRUE"); + } + if (!v.objectIsAConstant(Variant.VT_MISSING)) { + fail("did not recognize VT_MISSING"); + } + if (!v.objectIsAConstant(Variant.DEFAULT)) { + fail("did not recognize DEFAULT"); + } + if (v.objectIsAConstant(new Variant(true))) { + fail("confused a boolean with VT_TRUE"); + } + if (v.objectIsAConstant(new Variant(false))) { + fail("confused a boolean with VT_FALSE"); + } + + } + + /** + * tests put and get methods looking for obvious defects + * + */ + public void testPutsAndGets() { + Variant v = new Variant(); + + v.putInt(10); + assertEquals("int test failed", 10, v.getInt()); + + v.putShort((short) 20); + assertEquals("short test failed", (short) 20, v.getShort()); + + v.putByte((byte) 30); + assertEquals("byte test failed", (byte) 30, v.getByte()); + + v.putFloat(40); + if (v.getFloat() != 40.0) { + fail("float test failed"); + } + + v.putDouble(50); + if (v.getDouble() != 50.0) { + fail("double test failed"); + } + + v.putString("1234.567"); + assertEquals("string test failed", "1234.567", v.getString()); + + v.putBoolean(true); + assertEquals("failed boolean test(true)", true, v.getBoolean()); + + v.putBoolean(false); + assertEquals("failed boolean test(false)", false, v.getBoolean()); + + long originalValue = 123456789123456789L; + v.putCurrency(new Currency(originalValue)); + assertEquals("failed currency test", 123456789123456789L, v + .getCurrency().longValue()); + + BigDecimal testDecimal = new BigDecimal("22.222"); + v.putDecimal(testDecimal); + assertEquals("failed BigDecimal test", testDecimal, v.getDecimal()); + + Date ourDate = new Date(); + v.putDate(ourDate); + Date retrievedDate = v.getJavaDate(); + if (!retrievedDate.equals(ourDate)) { + fail("failed java date load and unload"); + } + + v.putNull(); + if (!v.isNull()) { + fail("failed detecting set null"); + } + v.putString("something other than null"); + if (v.isNull()) { + fail("failed null replacement with string"); + } + + v.putEmpty(); + if (!v.isNull()) { + fail("failed detecting set empty as null"); + } + v.putString("something other than null"); + if (v.isNull()) { + fail("failed empty replacement with string as isNull"); + } + + Variant v2 = new Variant(); + v2.putNothing(); + if (v2.getvt() != Variant.VariantDispatch) { + fail("putNothing was supposed to set the type to VariantDispatch"); + } + if (!v2.isNull()) { + fail("putNothing is supposed to cause isNull() to return true"); + } + // this line blows up in the test above + if (v2.toJavaObject() == null) { + fail("putNothing() followed by toJavaObject() should return a Dispatch"); + } + + } + + /** + * verify decimal works right + */ + public void testDecimalConversion() { + Variant v = new Variant(); + v.changeType(Variant.VariantDecimal); + for (int i = 10; i >= -10; i--) { + v.putDecimal(new BigDecimal(i)); + // first see if we can get it back as decimal + assertEquals("conversion back to decimal failed " + i, + new BigDecimal(i), v.getDecimal()); + v.changeType(Variant.VariantFloat); + // now see if a float conversion would work + assertEquals("conversion to float failed " + i, new Float(i), + v.getFloat()); + // now convert it back to decimal for reassignment + v.changeType(Variant.VariantDecimal); + assertTrue("Failed conversion of type back to Decimal " + i, + v.getvt() == Variant.VariantDecimal); + } + + } + + /** + * for(BigDecimal i in 79228162514264337593543950330.0 .. + * 79228162514264337593543950341.0) { com.jacob.com.Variant dv = new + * com.jacob.com.Variant(i, false) println i + " : " + dv.getDecimal() } + * + */ + public void testLargeDecimals() { + // the largest decimal number, not in hex is + // 7922816251426433759354395033.0 + BigInteger theStartDigits = new BigInteger("ffffffffffffffffffffff00", + 16); + BigInteger theMaxDigits = new BigInteger("ffffffffffffffffffffffff", 16); + BigDecimal startDecimal = new BigDecimal(theStartDigits); + BigDecimal endDecimal = new BigDecimal(theMaxDigits); + BigDecimal incrementDecimal = new BigDecimal(1); + BigDecimal testDecimal = startDecimal; + Variant testVariant; + while (endDecimal.compareTo(testDecimal) >= 0) { + testVariant = new Variant(testDecimal, false); + BigDecimal result = testVariant.getDecimal(); + assertEquals(testDecimal, result); + testDecimal = testDecimal.add(incrementDecimal); + } + // test Decimal is now too large + try { + new Variant(testDecimal, false); + } catch (IllegalArgumentException iae) { + // System.out.println("Caught expected exception"); + } + // lets try something different. we can call putVariant with rounding + // enabled + testVariant = new Variant(); + testVariant.changeType(Variant.VariantDecimal); + try { + testVariant.putDecimal(endDecimal.setScale(30)); + fail("Should have thrown exception with scale of 30 and no rounding"); + } catch (IllegalArgumentException iae) { + // should have caught this exception + } + // now we test with a negative scale. Note that you can't do with + // without some magic, in this case scientific notation + try { + testVariant.putDecimal(new BigDecimal("700E24")); + assertTrue(new BigDecimal("700E24").compareTo(testVariant + .getDecimal()) == 0); + } catch (IllegalArgumentException iae) { + // should have caught this exception + } + + testVariant.putDecimal(VariantUtilities + .roundToMSDecimal(new BigDecimal("700E24"))); + // use compareTo because it takes into account varying scales + assertTrue(new BigDecimal("700E24").compareTo(testVariant.getDecimal()) == 0); + + // This passes because the number is within range. + testVariant.putDecimal(endDecimal); + + // this should pass because we have rounding turned on + // it turns out the max number gets more digits when + // it's scale is set to 30. so we can't use the max number when there is + // a scale + BigDecimal modifiedDecimal = endDecimal; + System.out.println("integer piece starts as " + + modifiedDecimal.unscaledValue().toString(16) + " scale=: " + + modifiedDecimal.scale()); + System.out.println("integer piece after rounding without scale is " + + VariantUtilities.roundToMSDecimal(modifiedDecimal) + .unscaledValue().toString(16) + " scale=: " + + modifiedDecimal.scale()); + System.out.println("integer piece after rounding with scale 30 is " + + VariantUtilities + .roundToMSDecimal(modifiedDecimal.setScale(30)) + .unscaledValue().toString(16) + " scale=: " + + modifiedDecimal.scale()); + try { + testVariant.putDecimal(VariantUtilities + .roundToMSDecimal(modifiedDecimal.setScale(30))); + fail("should have thrown an exception for a number whose scale " + + "change created too many digits to be represented."); + } catch (IllegalArgumentException iae) { + // should catch an exception here because the rounding after scale + // change would have made the number too large + } + + System.out.println(""); + modifiedDecimal = endDecimal.subtract(incrementDecimal); + System.out.println("integer piece starts as " + + modifiedDecimal.unscaledValue().toString(16) + " scale=: " + + modifiedDecimal.scale()); + System.out.println("integer piece after rounding without scale is " + + VariantUtilities.roundToMSDecimal(modifiedDecimal) + .unscaledValue().toString(16) + " scale=: " + + modifiedDecimal.scale()); + System.out.println("integer piece after rounding with scale 30 is " + + VariantUtilities + .roundToMSDecimal(modifiedDecimal.setScale(30)) + .unscaledValue().toString(16) + " scale=: " + + modifiedDecimal.scale()); + testVariant.putDecimal(VariantUtilities + .roundToMSDecimal(modifiedDecimal.setScale(30))); + System.out.println(""); + } + + /** + * Spin up a lot of threads and have them all create variants 3/2007 there + * have been several reports in multi-threaded servers that show init() + * failing + * + */ + public void testManyThreadedInit() { + VariantInitTestThread threads[] = new VariantInitTestThread[75]; + + System.out.println("Starting thread test (" + threads.length + + " threads each creating 10000 objects)." + + " This may take 30 seconds or more."); + for (int i = 0; i < threads.length; i++) { + threads[i] = new VariantInitTestThread("thread-" + i, 10000); + } + for (int i = 0; i < threads.length; i++) { + threads[i].start(); + } + int numComplete = 0; + while (numComplete < threads.length) { + // give the works time to work + try { + Thread.sleep(333); + } catch (InterruptedException ie) { + // do nothing + } + numComplete = 0; + for (int i = 0; i < threads.length; i++) { + if (threads[i].isComplete) { + numComplete++; + } + } + // System.out.print("["+numComplete+"/"+threads.length+"]"); + } + System.out.println("Finished thread test"); + } + + /** + * a class to create variants in separate threads + * + */ + class VariantInitTestThread extends Thread { + private boolean isComplete = false; + + private int initialRunSize = 0; + + /** + * @param newThreadName + * the name for the thread + * @param iStartCount + * number of threads to start with + */ + public VariantInitTestThread(String newThreadName, int iStartCount) { + super(newThreadName); + initialRunSize = iStartCount; + + } + + /** + * getter so master can see if thread is done + * + * @return state of complete flag + */ + public boolean isComplete() { + return isComplete; + } + + /** + * Blow out a bunch of Variants + * + * @see java.lang.Runnable#run() + */ + @Override + public void run() { + for (int variantIndex = 0; variantIndex < initialRunSize; variantIndex++) { + try { + Thread.yield(); + Thread.sleep(0); + } catch (InterruptedException ie) { + // do nothing + } + // System.out.println(Thread.currentThread().getName()); + Variant testSubject = new Variant(variantIndex); + testSubject.getvt(); + testSubject.getInt(); + } + isComplete = true; + } + } + + /** + * there was a bitwise masking error that let booleans be seen as dispatch + * objects Bug Report SF3065265 + */ + public void testGetDispatch() { + Variant testVariant = new Variant(); + testVariant.putBooleanRef(true); + try { + // throws IllegalStateException if Jacob detects the type + // throws some other bad exception if COM blows up failing the + // conversion + testVariant.getDispatchRef(); + fail("Should not have converted boolean to dispatch"); + } catch (IllegalStateException e) { + // yeah! can't get dispatch from boolean + } + } + + /** + * there was a bitwise masking error that let booleans be seen as dispatch + * objects Bug Report SF3065265 + */ + public void testGetError() { + Variant testVariant = new Variant(); + testVariant.putErrorRef(3); + try { + // throws IllegalStateException if Jacob detects the type + // throws some other bad exception if COM blows up failing the + // conversion + testVariant.getStringRef(); + fail("Should not have converted error to string"); + } catch (IllegalStateException e) { + // yeah! can't get dispatch from boolean + } + } + + /** + * Verify SF 3435567 null and empty behavior change + */ + public void testGetNullString() { + Variant testVariant = new Variant(); + testVariant.putNull(); + assertNull(testVariant.getString()); + testVariant.putEmpty(); + assertNull(testVariant.getString()); + testVariant.putString("dog"); + assertEquals("dog", testVariant.getString()); + } } diff --git a/src/test/java/com/jacob/com/VariantUtilitiesTest.java b/src/test/java/com/jacob/com/VariantUtilitiesTest.java index 7825f83..964a447 100644 --- a/src/test/java/com/jacob/com/VariantUtilitiesTest.java +++ b/src/test/java/com/jacob/com/VariantUtilitiesTest.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.com; @@ -49,122 +49,122 @@ import com.jacob.test.BaseTestCase; */ public class VariantUtilitiesTest extends BaseTestCase { - /** - * verifies our unpacking stuff - */ - public void testObjectsToVariants() { - Object testArray[] = new Object[] { Integer.valueOf(1), - Integer.valueOf(2) }; - Variant resultArray[] = VariantUtilities.objectsToVariants(testArray); - assertEquals(2, resultArray.length); + /** + * verifies our unpacking stuff + */ + public void testObjectsToVariants() { + Object testArray[] = new Object[] { Integer.valueOf(1), + Integer.valueOf(2) }; + Variant resultArray[] = VariantUtilities.objectsToVariants(testArray); + assertEquals(2, resultArray.length); - Variant resultArray2[] = VariantUtilities - .objectsToVariants(resultArray); - assertEquals(2, resultArray2.length); - assertSame(resultArray[0], resultArray2[0]); - assertSame(resultArray[1], resultArray2[1]); - } + Variant resultArray2[] = VariantUtilities + .objectsToVariants(resultArray); + assertEquals(2, resultArray2.length); + assertSame(resultArray[0], resultArray2[0]); + assertSame(resultArray[1], resultArray2[1]); + } - /** - * test nested arrays - */ - public void testObjectsToVariantNestedArray() { - Object testArray[] = new Object[] { Integer.valueOf(1), - Integer.valueOf(2) }; - Object testArrayOuter[] = new Object[] { testArray }; - Variant resultArray[] = VariantUtilities - .objectsToVariants(testArrayOuter); - // should be a SafeArray - assertEquals(1, resultArray.length); - } + /** + * test nested arrays + */ + public void testObjectsToVariantNestedArray() { + Object testArray[] = new Object[] { Integer.valueOf(1), + Integer.valueOf(2) }; + Object testArrayOuter[] = new Object[] { testArray }; + Variant resultArray[] = VariantUtilities + .objectsToVariants(testArrayOuter); + // should be a SafeArray + assertEquals(1, resultArray.length); + } - /** - * verify that dispatch can convert from object to variant and that the - * variant holds the right value - */ - public void testConverters() { - Date testDate = new Date(); - Variant fromDate = VariantUtilities.objectToVariant(testDate); - Date returnedDate = fromDate.getJavaDate(); - // System.out.println("test date is "+testDate); - // System.out.println("VariantDate is "+fromDate.getJavaDate()); - assertTrue("Could not call obj2variant(Date) and get it to work", - testDate.equals(returnedDate)); - Currency someMoney = new Currency(12349876L); - Variant fromMoney = VariantUtilities.objectToVariant(someMoney); - Currency someMoneyConverted = fromMoney.getCurrency(); - assertTrue("Could not call obj2variant(Long) and get it to work", - someMoney.equals(someMoneyConverted)); - System.out.println("currency returned was: " + someMoneyConverted); + /** + * verify that dispatch can convert from object to variant and that the + * variant holds the right value + */ + public void testConverters() { + Date testDate = new Date(); + Variant fromDate = VariantUtilities.objectToVariant(testDate); + Date returnedDate = fromDate.getJavaDate(); + // System.out.println("test date is "+testDate); + // System.out.println("VariantDate is "+fromDate.getJavaDate()); + assertTrue("Could not call obj2variant(Date) and get it to work", + testDate.equals(returnedDate)); + Currency someMoney = new Currency(12349876L); + Variant fromMoney = VariantUtilities.objectToVariant(someMoney); + Currency someMoneyConverted = fromMoney.getCurrency(); + assertTrue("Could not call obj2variant(Long) and get it to work", + someMoney.equals(someMoneyConverted)); + System.out.println("currency returned was: " + someMoneyConverted); - } + } - public void testPrimitiveByteArray() { - byte[] arr = new byte[] { 1, 2, 3 }; + public void testPrimitiveByteArray() { + byte[] arr = new byte[] { 1, 2, 3 }; - Variant arrVar = VariantUtilities.objectToVariant(arr); - assertNotNull(arrVar); - SafeArray sa = arrVar.toSafeArray(); - assertNotNull(sa); + Variant arrVar = VariantUtilities.objectToVariant(arr); + assertNotNull(arrVar); + SafeArray sa = arrVar.toSafeArray(); + assertNotNull(sa); - assertEquals(Variant.VariantByte, sa.getvt()); + assertEquals(Variant.VariantByte, sa.getvt()); - assertEquals(0, sa.getLBound()); - assertEquals(2, sa.getUBound()); + assertEquals(0, sa.getLBound()); + assertEquals(2, sa.getUBound()); - byte[] bytes = sa.toByteArray(); - assertTrue(Arrays.equals(bytes, arr)); - } + byte[] bytes = sa.toByteArray(); + assertTrue(Arrays.equals(bytes, arr)); + } - public void testPrimitiveIntArray() { - int[] arr = new int[] { 1000, 2000, 3 }; + public void testPrimitiveIntArray() { + int[] arr = new int[] { 1000, 2000, 3 }; - Variant arrVar = VariantUtilities.objectToVariant(arr); - assertNotNull(arrVar); - SafeArray sa = arrVar.toSafeArray(); - assertNotNull(sa); + Variant arrVar = VariantUtilities.objectToVariant(arr); + assertNotNull(arrVar); + SafeArray sa = arrVar.toSafeArray(); + assertNotNull(sa); - assertEquals(Variant.VariantInt, sa.getvt()); + assertEquals(Variant.VariantInt, sa.getvt()); - assertEquals(0, sa.getLBound()); - assertEquals(2, sa.getUBound()); + assertEquals(0, sa.getLBound()); + assertEquals(2, sa.getUBound()); - int[] ints = sa.toIntArray(); - assertTrue(Arrays.equals(ints, arr)); - } + int[] ints = sa.toIntArray(); + assertTrue(Arrays.equals(ints, arr)); + } - public void testPrimitiveDoubleArray() { - double[] arr = new double[] { 1000, 2000, 3 }; + public void testPrimitiveDoubleArray() { + double[] arr = new double[] { 1000, 2000, 3 }; - Variant arrVar = VariantUtilities.objectToVariant(arr); - assertNotNull(arrVar); - SafeArray sa = arrVar.toSafeArray(); - assertNotNull(sa); + Variant arrVar = VariantUtilities.objectToVariant(arr); + assertNotNull(arrVar); + SafeArray sa = arrVar.toSafeArray(); + assertNotNull(sa); - assertEquals(Variant.VariantDouble, sa.getvt()); + assertEquals(Variant.VariantDouble, sa.getvt()); - assertEquals(0, sa.getLBound()); - assertEquals(2, sa.getUBound()); + assertEquals(0, sa.getLBound()); + assertEquals(2, sa.getUBound()); - double[] doubles = sa.toDoubleArray(); - assertTrue(Arrays.equals(doubles, arr)); - } + double[] doubles = sa.toDoubleArray(); + assertTrue(Arrays.equals(doubles, arr)); + } - public void testPrimitiveLongArray() { - long[] arr = new long[] { 0xcafebabecafebabeL, 42, 0xbabecafebabeL }; + public void testPrimitiveLongArray() { + long[] arr = new long[] { 0xcafebabecafebabeL, 42, 0xbabecafebabeL }; - Variant arrVar = VariantUtilities.objectToVariant(arr); - assertNotNull(arrVar); - SafeArray sa = arrVar.toSafeArray(); - assertNotNull(sa); + Variant arrVar = VariantUtilities.objectToVariant(arr); + assertNotNull(arrVar); + SafeArray sa = arrVar.toSafeArray(); + assertNotNull(sa); - assertEquals(Variant.VariantLongInt, sa.getvt()); + assertEquals(Variant.VariantLongInt, sa.getvt()); - assertEquals(0, sa.getLBound()); - assertEquals(2, sa.getUBound()); + assertEquals(0, sa.getLBound()); + assertEquals(2, sa.getUBound()); - long[] longs = sa.toLongArray(); - assertTrue(Arrays.equals(longs, arr)); - } + long[] longs = sa.toLongArray(); + assertTrue(Arrays.equals(longs, arr)); + } } diff --git a/src/test/java/com/jacob/test/BaseTestCase.java b/src/test/java/com/jacob/test/BaseTestCase.java index 7510382..376fa85 100644 --- a/src/test/java/com/jacob/test/BaseTestCase.java +++ b/src/test/java/com/jacob/test/BaseTestCase.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.test; @@ -61,152 +61,152 @@ import com.jacob.com.JacobObject; */ public class BaseTestCase extends TestCase { - protected void setUp() { - // verify we have run with the dll in the lib path - try { - JacobObject foo = new JacobObject(); - if (foo == null) { - fail("Failed basic sanity test: Can't create JacobObject (-D)"); - } - } catch (UnsatisfiedLinkError ule) { - fail("Did you remember to run with the jacob.dll in the libpath ?"); - } - } + protected void setUp() { + // verify we have run with the dll in the lib path + try { + JacobObject foo = new JacobObject(); + if (foo == null) { + fail("Failed basic sanity test: Can't create JacobObject (-D)"); + } + } catch (UnsatisfiedLinkError ule) { + fail("Did you remember to run with the jacob.dll in the libpath ?"); + } + } - /** - * this test exists just to test the setup. - */ - public void testSetup() { - JacobObject foo = new JacobObject(); - assertNotNull(foo); - } + /** + * this test exists just to test the setup. + */ + public void testSetup() { + JacobObject foo = new JacobObject(); + assertNotNull(foo); + } - /** - * - * @return a simple VB script that generates the result "3" - */ - public String getSampleVPScriptForEval() { - return "1+(2*4)-3"; + /** + * + * @return a simple VB script that generates the result "3" + */ + public String getSampleVPScriptForEval() { + return "1+(2*4)-3"; - } + } - /** - * Converts the class name into a path and appends the resource name. Used - * to derive the path to a resource in the file system where the resource is - * co-located with the referenced class. - * - * @param resourceName - * @param classInSamePackageAsResource - * @return a class loader compatible fully qualified file system path to a - * resource - */ - @SuppressWarnings("unchecked") - private String getJavaFilePathToPackageResource(String resourceName, - Class classInSamePackageAsResource) { + /** + * Converts the class name into a path and appends the resource name. Used + * to derive the path to a resource in the file system where the resource is + * co-located with the referenced class. + * + * @param resourceName + * @param classInSamePackageAsResource + * @return a class loader compatible fully qualified file system path to a + * resource + */ + @SuppressWarnings("unchecked") + private String getJavaFilePathToPackageResource(String resourceName, + Class classInSamePackageAsResource) { - String classPackageName = classInSamePackageAsResource.getName(); - int i = classPackageName.lastIndexOf('.'); - if (i == -1) { - classPackageName = ""; - } else { - classPackageName = classPackageName.substring(0, i); - } + String classPackageName = classInSamePackageAsResource.getName(); + int i = classPackageName.lastIndexOf('.'); + if (i == -1) { + classPackageName = ""; + } else { + classPackageName = classPackageName.substring(0, i); + } - // change all "." to ^ for later conversion to "/" so we can append - // resource names with "." - classPackageName = classPackageName.replace('.', '^'); - System.out.println("classPackageName: " + classPackageName); - String fullPathToResource; - if (classPackageName.length() > 0) { - fullPathToResource = classPackageName + "^" + resourceName; - } else { - fullPathToResource = resourceName; - } + // change all "." to ^ for later conversion to "/" so we can append + // resource names with "." + classPackageName = classPackageName.replace('.', '^'); + System.out.println("classPackageName: " + classPackageName); + String fullPathToResource; + if (classPackageName.length() > 0) { + fullPathToResource = classPackageName + "^" + resourceName; + } else { + fullPathToResource = resourceName; + } - fullPathToResource = fullPathToResource.replace('^', '/'); - System.out.println("fullPathToResource: " + fullPathToResource); + fullPathToResource = fullPathToResource.replace('^', '/'); + System.out.println("fullPathToResource: " + fullPathToResource); - URL urlToLibrary = classInSamePackageAsResource.getClassLoader() - .getResource(fullPathToResource); - assertNotNull("URL to resource " + resourceName - + " should not be null." - + " You probably need to add 'unittest' to the" - + " classpath so the tests can find resources", urlToLibrary); - String fullPathToResourceAsFile = urlToLibrary.getFile(); - System.out.println("url to library: " + urlToLibrary); - System.out.println("fullPathToResourceAsFile: " - + fullPathToResourceAsFile); + URL urlToLibrary = classInSamePackageAsResource.getClassLoader() + .getResource(fullPathToResource); + assertNotNull("URL to resource " + resourceName + + " should not be null." + + " You probably need to add 'unittest' to the" + + " classpath so the tests can find resources", urlToLibrary); + String fullPathToResourceAsFile = urlToLibrary.getFile(); + System.out.println("url to library: " + urlToLibrary); + System.out.println("fullPathToResourceAsFile: " + + fullPathToResourceAsFile); - return fullPathToResourceAsFile; - } + return fullPathToResourceAsFile; + } - /** - * Converts the class name into a path and appends the resource name. Used - * to derive the path to a resource in the file system where the resource is - * co-located with the referenced class. - * - * @param resourceName - * @param classInSamePackageAsResource - * @return returns the path in the file system of the requested resource in - * windows c compatible format - */ - @SuppressWarnings("unchecked") - public String getWindowsFilePathToPackageResource(String resourceName, - Class classInSamePackageAsResource) { - String javaFilePath = getJavaFilePathToPackageResource(resourceName, - classInSamePackageAsResource); - javaFilePath = javaFilePath.replace('/', '\\'); - return javaFilePath.substring(1); - } + /** + * Converts the class name into a path and appends the resource name. Used + * to derive the path to a resource in the file system where the resource is + * co-located with the referenced class. + * + * @param resourceName + * @param classInSamePackageAsResource + * @return returns the path in the file system of the requested resource in + * windows c compatible format + */ + @SuppressWarnings("unchecked") + public String getWindowsFilePathToPackageResource(String resourceName, + Class classInSamePackageAsResource) { + String javaFilePath = getJavaFilePathToPackageResource(resourceName, + classInSamePackageAsResource); + javaFilePath = javaFilePath.replace('/', '\\'); + return javaFilePath.substring(1); + } - /** - * - * @param resourceName - * @param classInSamePackageAsResource - * @return a resource located in the same package as the passed in class - */ - @SuppressWarnings( { "unused", "unchecked" }) - private Object getPackageResource(String resourceName, - Class classInSamePackageAsResource) { - String fullPathToResource = getJavaFilePathToPackageResource( - resourceName, classInSamePackageAsResource); - ClassLoader localClassLoader = classInSamePackageAsResource - .getClassLoader(); - if (null == localClassLoader) { - return ClassLoader.getSystemResource(fullPathToResource); - } else { - return localClassLoader.getResource(fullPathToResource); - } - } + /** + * + * @param resourceName + * @param classInSamePackageAsResource + * @return a resource located in the same package as the passed in class + */ + @SuppressWarnings( { "unused", "unchecked" }) + private Object getPackageResource(String resourceName, + Class classInSamePackageAsResource) { + String fullPathToResource = getJavaFilePathToPackageResource( + resourceName, classInSamePackageAsResource); + ClassLoader localClassLoader = classInSamePackageAsResource + .getClassLoader(); + if (null == localClassLoader) { + return ClassLoader.getSystemResource(fullPathToResource); + } else { + return localClassLoader.getResource(fullPathToResource); + } + } - /** - * load a library from same place in the file system that the class was - * loaded from. - *

      - * This is an attempt to let unit tests run without having to run regsvr32. - * - * @param libraryName - * @param classInSamePackageAsResource - */ - @SuppressWarnings( { "unchecked", "unused" }) - private void loadLibraryFromClassPackage(String libraryName, - Class classInSamePackageAsResource) { - String libraryNameWithSuffix = ""; - String fullLibraryNameWithPath = ""; - if (libraryName != null && libraryName.endsWith("dll")) { - libraryNameWithSuffix = libraryName; - } else if (libraryName != null) { - libraryNameWithSuffix = libraryName + ".dll"; - } else { - fail("can't create full library name " + libraryName); - } - // generate the path the classloader would use to find this on the - // classpath - fullLibraryNameWithPath = getJavaFilePathToPackageResource( - libraryNameWithSuffix, classInSamePackageAsResource); - System.load(fullLibraryNameWithPath); - // requires that the dll be on the library path - // System.loadLibrary(fullLibraryNameWithPath); - } + /** + * load a library from same place in the file system that the class was + * loaded from. + *

      + * This is an attempt to let unit tests run without having to run regsvr32. + * + * @param libraryName + * @param classInSamePackageAsResource + */ + @SuppressWarnings( { "unchecked", "unused" }) + private void loadLibraryFromClassPackage(String libraryName, + Class classInSamePackageAsResource) { + String libraryNameWithSuffix = ""; + String fullLibraryNameWithPath = ""; + if (libraryName != null && libraryName.endsWith("dll")) { + libraryNameWithSuffix = libraryName; + } else if (libraryName != null) { + libraryNameWithSuffix = libraryName + ".dll"; + } else { + fail("can't create full library name " + libraryName); + } + // generate the path the classloader would use to find this on the + // classpath + fullLibraryNameWithPath = getJavaFilePathToPackageResource( + libraryNameWithSuffix, classInSamePackageAsResource); + System.load(fullLibraryNameWithPath); + // requires that the dll be on the library path + // System.loadLibrary(fullLibraryNameWithPath); + } } diff --git a/src/test/java/com/jacob/test/errors/UnicodeErrorTest.java b/src/test/java/com/jacob/test/errors/UnicodeErrorTest.java index c55ae38..e7a1197 100644 --- a/src/test/java/com/jacob/test/errors/UnicodeErrorTest.java +++ b/src/test/java/com/jacob/test/errors/UnicodeErrorTest.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.test.errors; @@ -51,22 +51,22 @@ import com.jacob.com.ComException; */ public class UnicodeErrorTest extends BaseTestCase { - /** - * verifies that messages can now have unicode in them like when the file - * names have unicode characters - */ - public void testUnicodeCharactersInErrorMessage() { - ActiveXComponent application = new ActiveXComponent("Word.Application"); - ActiveXComponent documents = application - .getPropertyAsComponent("Documents"); - String fileName = "abc\u0411\u0412\u0413\u0414def"; - try { - documents.invoke("Open", fileName); - fail("Should have thrown an exception"); - } catch (ComException e) { - assertTrue("Error message should contain file name with unicode " - + "characters in it. " + e.getMessage(), e.getMessage() - .indexOf(fileName) > 0); - } - } + /** + * verifies that messages can now have unicode in them like when the file + * names have unicode characters + */ + public void testUnicodeCharactersInErrorMessage() { + ActiveXComponent application = new ActiveXComponent("Word.Application"); + ActiveXComponent documents = application + .getPropertyAsComponent("Documents"); + String fileName = "abc\u0411\u0412\u0413\u0414def"; + try { + documents.invoke("Open", fileName); + fail("Should have thrown an exception"); + } catch (ComException e) { + assertTrue("Error message should contain file name with unicode " + + "characters in it. " + e.getMessage(), e.getMessage() + .indexOf(fileName) > 0); + } + } } \ No newline at end of file diff --git a/src/test/java/com/jacob/test/events/ExcelEventTest.java b/src/test/java/com/jacob/test/events/ExcelEventTest.java index 8f50683..6314a71 100644 --- a/src/test/java/com/jacob/test/events/ExcelEventTest.java +++ b/src/test/java/com/jacob/test/events/ExcelEventTest.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.test.events; @@ -59,132 +59,132 @@ import com.jacob.test.BaseTestCase; */ public class ExcelEventTest extends BaseTestCase { - /** - * load up excel, register for events and make stuff happen - * - * @param args - */ - public void testExcelWithInvocationProxy() { - ComThread.InitSTA(); - // we are going to listen to events on Application. - // You can probably also listen Excel.Sheet and Excel.Chart - String excelApplicationProgramId = "Excel.Application"; - String excelSheetProgramId = "Excel.Sheet"; - String typeLibLocation; - // office 2003 - typeLibLocation = "C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE"; - // office 2007 - typeLibLocation = "C:\\Program Files\\Microsoft Office\\OFFICE12\\EXCEL.EXE"; - // office 2013 322 bit - typeLibLocation = "C:\\Program Files (x86)\\Microsoft Office\\Office14\\EXCEL.EXE"; + /** + * load up excel, register for events and make stuff happen + * + * @param args + */ + public void testExcelWithInvocationProxy() { + ComThread.InitSTA(); + // we are going to listen to events on Application. + // You can probably also listen Excel.Sheet and Excel.Chart + String excelApplicationProgramId = "Excel.Application"; + String excelSheetProgramId = "Excel.Sheet"; + String typeLibLocation; + // office 2003 + typeLibLocation = "C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE"; + // office 2007 + typeLibLocation = "C:\\Program Files\\Microsoft Office\\OFFICE12\\EXCEL.EXE"; + // office 2013 322 bit + typeLibLocation = "C:\\Program Files (x86)\\Microsoft Office\\Office14\\EXCEL.EXE"; - // Grab The Component. - ActiveXComponent axc = new ActiveXComponent(excelApplicationProgramId); - hookupListener(axc, excelApplicationProgramId, typeLibLocation); + // Grab The Component. + ActiveXComponent axc = new ActiveXComponent(excelApplicationProgramId); + hookupListener(axc, excelApplicationProgramId, typeLibLocation); - try { + try { - System.out.println("version=" + axc.getProperty("Version")); - System.out.println("version=" + Dispatch.get(axc, "Version")); - axc.setProperty("Visible", true); - Dispatch workbooks = axc.getPropertyAsComponent("Workbooks"); - Dispatch workbook = Dispatch.get(workbooks, "Add").toDispatch(); - Dispatch sheet = Dispatch.get(workbook, "ActiveSheet").toDispatch(); - System.out.println("Workbook: " + workbook); - System.out.println("Sheet: " + sheet); - if (typeLibLocation.contains("OFFICE11")) { - // office 2007 throws crashes the VM - System.out.println("Hooking up sheet listener"); - hookupListener(sheet, excelSheetProgramId, typeLibLocation); - } - System.out.println("Retrieving cells"); - Dispatch a1 = Dispatch.invoke(sheet, "Range", Dispatch.Get, - new Object[] { "A1" }, new int[1]).toDispatch(); - Dispatch a2 = Dispatch.invoke(sheet, "Range", Dispatch.Get, - new Object[] { "A2" }, new int[1]).toDispatch(); - System.out.println("Inserting value into A1"); - System.out.println("Inserting calculation 2xA1 into A2"); - Dispatch.put(a1, "Value", "123.456"); - Dispatch.put(a2, "Formula", "=A1*2"); - System.out.println("Retrieved a1 from excel:" - + Dispatch.get(a1, "Value")); - System.out.println("Retrieved a2 from excel:" - + Dispatch.get(a2, "Value")); - Variant f = new Variant(false); - Dispatch.call(workbook, "Close", f); - axc.invoke("Quit", new Variant[] {}); + System.out.println("version=" + axc.getProperty("Version")); + System.out.println("version=" + Dispatch.get(axc, "Version")); + axc.setProperty("Visible", true); + Dispatch workbooks = axc.getPropertyAsComponent("Workbooks"); + Dispatch workbook = Dispatch.get(workbooks, "Add").toDispatch(); + Dispatch sheet = Dispatch.get(workbook, "ActiveSheet").toDispatch(); + System.out.println("Workbook: " + workbook); + System.out.println("Sheet: " + sheet); + if (typeLibLocation.contains("OFFICE11")) { + // office 2007 throws crashes the VM + System.out.println("Hooking up sheet listener"); + hookupListener(sheet, excelSheetProgramId, typeLibLocation); + } + System.out.println("Retrieving cells"); + Dispatch a1 = Dispatch.invoke(sheet, "Range", Dispatch.Get, + new Object[] { "A1" }, new int[1]).toDispatch(); + Dispatch a2 = Dispatch.invoke(sheet, "Range", Dispatch.Get, + new Object[] { "A2" }, new int[1]).toDispatch(); + System.out.println("Inserting value into A1"); + System.out.println("Inserting calculation 2xA1 into A2"); + Dispatch.put(a1, "Value", "123.456"); + Dispatch.put(a2, "Formula", "=A1*2"); + System.out.println("Retrieved a1 from excel:" + + Dispatch.get(a1, "Value")); + System.out.println("Retrieved a2 from excel:" + + Dispatch.get(a2, "Value")); + Variant f = new Variant(false); + Dispatch.call(workbook, "Close", f); + axc.invoke("Quit", new Variant[] {}); - } catch (ComException cfe) { - cfe.printStackTrace(); - fail("Failed to attach to " + excelApplicationProgramId + ": " - + cfe.getMessage()); - } - try { - // the sleep is required to let everything clear out after the quit - Thread.sleep(2000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - ComThread.Release(); - } + } catch (ComException cfe) { + cfe.printStackTrace(); + fail("Failed to attach to " + excelApplicationProgramId + ": " + + cfe.getMessage()); + } + try { + // the sleep is required to let everything clear out after the quit + Thread.sleep(2000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + ComThread.Release(); + } - /** - * extracted the listener hookup so we could try multiple listeners. - * - * @param axc - * @param programId - * @param typeLibLocation - */ - private void hookupListener(Dispatch axc, String programId, - String typeLibLocation) { - // Add a listener (doesn't matter what it is). - DispatchEvents applicationEvents; - if (typeLibLocation == null) { - applicationEvents = new DispatchEvents(axc, new ExcelEvents( - programId)); - } else { - applicationEvents = new DispatchEvents(axc, new ExcelEvents( - programId), programId, typeLibLocation); - } - if (applicationEvents == null) { - System.out - .println("No exception thrown but no dispatch returned for Excel events"); - } else { - // Yea! - System.out - .println("Successfully attached listener to " + programId); + /** + * extracted the listener hookup so we could try multiple listeners. + * + * @param axc + * @param programId + * @param typeLibLocation + */ + private void hookupListener(Dispatch axc, String programId, + String typeLibLocation) { + // Add a listener (doesn't matter what it is). + DispatchEvents applicationEvents; + if (typeLibLocation == null) { + applicationEvents = new DispatchEvents(axc, new ExcelEvents( + programId)); + } else { + applicationEvents = new DispatchEvents(axc, new ExcelEvents( + programId), programId, typeLibLocation); + } + if (applicationEvents == null) { + System.out + .println("No exception thrown but no dispatch returned for Excel events"); + } else { + // Yea! + System.out + .println("Successfully attached listener to " + programId); - } - } + } + } - /** - * Proxy class to verify we receive expected events - */ - public class ExcelEvents extends InvocationProxy { + /** + * Proxy class to verify we receive expected events + */ + public class ExcelEvents extends InvocationProxy { - private String listenerPrefix = "-"; + private String listenerPrefix = "-"; - /** - * Constructor so we can create an instance that implements invoke() - * - * @param interfaceIdentifier - * a string that identifies which listener is speaking - */ - public ExcelEvents(String interfaceIdentifier) { - listenerPrefix = interfaceIdentifier; - } + /** + * Constructor so we can create an instance that implements invoke() + * + * @param interfaceIdentifier + * a string that identifies which listener is speaking + */ + public ExcelEvents(String interfaceIdentifier) { + listenerPrefix = interfaceIdentifier; + } - /** - * Override the invoke method to log all the events so that we don't - * have to implement all of the specific events. - */ - @Override - public Variant invoke(String methodName, Variant targetParameter[]) { - System.out.println("Received event from " + listenerPrefix + ": " - + methodName); - return null; - } + /** + * Override the invoke method to log all the events so that we don't + * have to implement all of the specific events. + */ + @Override + public Variant invoke(String methodName, Variant targetParameter[]) { + System.out.println("Received event from " + listenerPrefix + ": " + + methodName); + return null; + } - } + } } diff --git a/src/test/java/com/jacob/test/events/IETest.java b/src/test/java/com/jacob/test/events/IETest.java index 1bd076f..dd37b54 100644 --- a/src/test/java/com/jacob/test/events/IETest.java +++ b/src/test/java/com/jacob/test/events/IETest.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.test.events; @@ -60,418 +60,418 @@ import com.jacob.test.BaseTestCase; public class IETest extends BaseTestCase { - /** - * well known address we can navigate to - */ - private final String testUrls[] = { - "http://sourceforge.net/projects/jacob-project", - "http://www.google.com" }; + /** + * well known address we can navigate to + */ + private final String testUrls[] = { + "http://sourceforge.net/projects/jacob-project", + "http://www.google.com" }; - /** - * runs the IE test and feeds it commands - */ - public void testRunIECleanly() { - runTheTest(true, testUrls); - } + /** + * runs the IE test and feeds it commands + */ + public void testRunIECleanly() { + runTheTest(true, testUrls); + } - /** - * runs the IE test and feeds it commands - */ - public void testRunIETerminateWithoutWait() { - runTheTest(false, testUrls); - } + /** + * runs the IE test and feeds it commands + */ + public void testRunIETerminateWithoutWait() { + runTheTest(false, testUrls); + } - /** - * The actual work of running the test. - * - * @param waitForQuit - * @param urls - */ - private void runTheTest(boolean waitForQuit, String[] urls) { - // this line starts the pump but it runs fine without it - ComThread.startMainSTA(); - // Run the test in a thread. Lets us test running out of "main" thread - IETestThread aThread = new IETestThread(waitForQuit, urls); - aThread.start(); - while (aThread.isAlive()) { - try { - Thread.sleep(250); - } catch (InterruptedException e) { - // done with the sleep - } - } - System.out.println("Main: Thread quit, about to quitMainSTA in thread " - + Thread.currentThread().getName()); - // this line only does something if startMainSTA() was called - ComThread.quitMainSTA(); - System.out.println("Main: did quit main sta in thread " - + Thread.currentThread().getName()); + /** + * The actual work of running the test. + * + * @param waitForQuit + * @param urls + */ + private void runTheTest(boolean waitForQuit, String[] urls) { + // this line starts the pump but it runs fine without it + ComThread.startMainSTA(); + // Run the test in a thread. Lets us test running out of "main" thread + IETestThread aThread = new IETestThread(waitForQuit, urls); + aThread.start(); + while (aThread.isAlive()) { + try { + Thread.sleep(250); + } catch (InterruptedException e) { + // done with the sleep + } + } + System.out.println("Main: Thread quit, about to quitMainSTA in thread " + + Thread.currentThread().getName()); + // this line only does something if startMainSTA() was called + ComThread.quitMainSTA(); + System.out.println("Main: did quit main sta in thread " + + Thread.currentThread().getName()); - if (aThread.threadFailedWithException != null) { - aThread.threadFailedWithException.printStackTrace(); - fail("caught an unexpected exception " - + aThread.threadFailedWithException); - } - } + if (aThread.threadFailedWithException != null) { + aThread.threadFailedWithException.printStackTrace(); + fail("caught an unexpected exception " + + aThread.threadFailedWithException); + } + } } class IETestThread extends Thread { - /** flag that says we got a quit message from IE */ - public static boolean quitHandled = false; + /** flag that says we got a quit message from IE */ + public static boolean quitHandled = false; - /** - * determines if we wait until last quit call back received before - * terminating - */ - private static boolean waitUntilReceivedQuitCallback = true; + /** + * determines if we wait until last quit call back received before + * terminating + */ + private static boolean waitUntilReceivedQuitCallback = true; - /** - * the places we should navigate to - */ - private static String[] targets = null; + /** + * the places we should navigate to + */ + private static String[] targets = null; - /** - * holds any caught exception so the main/test case can see them - */ - public Throwable threadFailedWithException = null; + /** + * holds any caught exception so the main/test case can see them + */ + public Throwable threadFailedWithException = null; - /** - * constructor for the test thread - * - * @param beNeat - * should we wait until quit received - * @param urls - * the web pages we will navigate to - */ - public IETestThread(boolean beNeat, String urls[]) { - super(); - waitUntilReceivedQuitCallback = beNeat; - targets = urls; - } + /** + * constructor for the test thread + * + * @param beNeat + * should we wait until quit received + * @param urls + * the web pages we will navigate to + */ + public IETestThread(boolean beNeat, String urls[]) { + super(); + waitUntilReceivedQuitCallback = beNeat; + targets = urls; + } - /** - * Run through the addresses passed in via the constructor - */ - @Override - public void run() { - // pick a time that lets sourceforge respond (in msec) - int delay = 3000; - // pre-1.14 paired with statement below that blows up - ComThread.InitMTA(); - ActiveXComponent ie = new ActiveXComponent( - "InternetExplorer.Application"); - try { - Dispatch.put(ie, "Visible", new Variant(true)); - Dispatch.put(ie, "AddressBar", new Variant(true)); - System.out.println("IETestThread: " + Dispatch.get(ie, "Path")); - // Some version of IE broke this. Not sure which one - // Dispatch.put(ie, "StatusText", new Variant("My Status Text")); + /** + * Run through the addresses passed in via the constructor + */ + @Override + public void run() { + // pick a time that lets sourceforge respond (in msec) + int delay = 3000; + // pre-1.14 paired with statement below that blows up + ComThread.InitMTA(); + ActiveXComponent ie = new ActiveXComponent( + "InternetExplorer.Application"); + try { + Dispatch.put(ie, "Visible", new Variant(true)); + Dispatch.put(ie, "AddressBar", new Variant(true)); + System.out.println("IETestThread: " + Dispatch.get(ie, "Path")); + // Some version of IE broke this. Not sure which one + // Dispatch.put(ie, "StatusText", new Variant("My Status Text")); - System.out.println("IETestThread: About to hookup event listener"); - IEEvents ieE = new IEEvents(); - new DispatchEvents(ie, ieE, "InternetExplorer.Application.1"); - System.out.println("IETestThread: Did hookup event listener"); + System.out.println("IETestThread: About to hookup event listener"); + IEEvents ieE = new IEEvents(); + new DispatchEvents(ie, ieE, "InternetExplorer.Application.1"); + System.out.println("IETestThread: Did hookup event listener"); - for (String url : targets) { - System.out.println("IETestThread: About to call navigate to " - + url); - Dispatch.call(ie, "Navigate", new Variant(url)); - System.out.println("IETestThread: Did call navigate to " + url); - try { - Thread.sleep(delay); - } catch (Exception e) { - } - } - } catch (Exception e) { - threadFailedWithException = e; - e.printStackTrace(); - } catch (Throwable re) { - threadFailedWithException = re; - re.printStackTrace(); - } finally { - System.out.println("IETestThread: About to send Quit"); - ie.invoke("Quit", new Variant[] {}); - System.out.println("IETestThread: Did send Quit"); - } - // a value is set to false if we try to crash VM by leaving before - // callbacks all received - if (waitUntilReceivedQuitCallback) { - System.out - .println("IETestThread: Waiting until we've received quit callback"); - // wait a little while for it to end - while (!quitHandled) { - try { - Thread.sleep(delay / 10); - } catch (InterruptedException e) { - } - } - System.out.println("IETestThread: Received the OnQuit callback"); - } else { - System.out.println("IETestThread: Not waiting for OnQuit callback"); - } - System.out.println("IETestThread: Calling ComThread.Release in thread " - + Thread.currentThread().getName()); - ComThread.Release(); - } + for (String url : targets) { + System.out.println("IETestThread: About to call navigate to " + + url); + Dispatch.call(ie, "Navigate", new Variant(url)); + System.out.println("IETestThread: Did call navigate to " + url); + try { + Thread.sleep(delay); + } catch (Exception e) { + } + } + } catch (Exception e) { + threadFailedWithException = e; + e.printStackTrace(); + } catch (Throwable re) { + threadFailedWithException = re; + re.printStackTrace(); + } finally { + System.out.println("IETestThread: About to send Quit"); + ie.invoke("Quit", new Variant[] {}); + System.out.println("IETestThread: Did send Quit"); + } + // a value is set to false if we try to crash VM by leaving before + // callbacks all received + if (waitUntilReceivedQuitCallback) { + System.out + .println("IETestThread: Waiting until we've received quit callback"); + // wait a little while for it to end + while (!quitHandled) { + try { + Thread.sleep(delay / 10); + } catch (InterruptedException e) { + } + } + System.out.println("IETestThread: Received the OnQuit callback"); + } else { + System.out.println("IETestThread: Not waiting for OnQuit callback"); + } + System.out.println("IETestThread: Calling ComThread.Release in thread " + + Thread.currentThread().getName()); + ComThread.Release(); + } - /** - * The events class must be publicly accessible for reflection to work. The - * list of available events is located at - * http://msdn2.microsoft.com/en-us/library/aa768280.aspx - */ - public class IEEvents { - /** - * Internet explorer event this proxy can receive - * - * @param args - * the COM Variant objects that this event passes in. - */ - public void BeforeNavigate2(Variant[] args) { - System.out.println("IEEvents Received (" - + Thread.currentThread().getName() + "): BeforeNavigate2 " - + args.length + " parameters"); - } + /** + * The events class must be publicly accessible for reflection to work. The + * list of available events is located at + * http://msdn2.microsoft.com/en-us/library/aa768280.aspx + */ + public class IEEvents { + /** + * Internet explorer event this proxy can receive + * + * @param args + * the COM Variant objects that this event passes in. + */ + public void BeforeNavigate2(Variant[] args) { + System.out.println("IEEvents Received (" + + Thread.currentThread().getName() + "): BeforeNavigate2 " + + args.length + " parameters"); + } - /** - * Internet explorer event this proxy can receive - * - * @param args - * the COM Variant objects that this event passes in. - */ - public void CommandStateChange(Variant[] args) { - System.out.println("IEEvents Received (" - + Thread.currentThread().getName() - + "): CommandStateChange " + args.length + " parameters"); - } + /** + * Internet explorer event this proxy can receive + * + * @param args + * the COM Variant objects that this event passes in. + */ + public void CommandStateChange(Variant[] args) { + System.out.println("IEEvents Received (" + + Thread.currentThread().getName() + + "): CommandStateChange " + args.length + " parameters"); + } - /** - * Internet explorer event this proxy can receive - * - * @param args - * the COM Variant objects that this event passes in. - */ - public void DocumentComplete(Variant[] args) { - System.out.println("IEEvents Received (" - + Thread.currentThread().getName() + "): DocumentComplete " - + args.length + " parameters"); - } + /** + * Internet explorer event this proxy can receive + * + * @param args + * the COM Variant objects that this event passes in. + */ + public void DocumentComplete(Variant[] args) { + System.out.println("IEEvents Received (" + + Thread.currentThread().getName() + "): DocumentComplete " + + args.length + " parameters"); + } - /** - * Internet explorer event this proxy can receive - * - * @param args - * the COM Variant objects that this event passes in. - */ - public void DownloadBegin(Variant[] args) { - System.out.println("IEEvents Received (" - + Thread.currentThread().getName() + "): DownloadBegin " - + args.length + " parameters"); - } + /** + * Internet explorer event this proxy can receive + * + * @param args + * the COM Variant objects that this event passes in. + */ + public void DownloadBegin(Variant[] args) { + System.out.println("IEEvents Received (" + + Thread.currentThread().getName() + "): DownloadBegin " + + args.length + " parameters"); + } - /** - * Internet explorer event this proxy can receive - * - * @param args - * the COM Variant objects that this event passes in. - */ - public void DownloadComplete(Variant[] args) { - System.out.println("IEEvents Received (" - + Thread.currentThread().getName() + "): DownloadComplete " - + args.length + " parameters"); - } + /** + * Internet explorer event this proxy can receive + * + * @param args + * the COM Variant objects that this event passes in. + */ + public void DownloadComplete(Variant[] args) { + System.out.println("IEEvents Received (" + + Thread.currentThread().getName() + "): DownloadComplete " + + args.length + " parameters"); + } - /** - * Internet explorer event this proxy can receive - * - * @param args - * the COM Variant objects that this event passes in. - */ - public void NavigateError(Variant[] args) { - System.out.println("IEEvents Received (" - + Thread.currentThread().getName() + "): NavigateError " - + args.length + " parameters"); - } + /** + * Internet explorer event this proxy can receive + * + * @param args + * the COM Variant objects that this event passes in. + */ + public void NavigateError(Variant[] args) { + System.out.println("IEEvents Received (" + + Thread.currentThread().getName() + "): NavigateError " + + args.length + " parameters"); + } - /** - * Internet explorer event this proxy can receive - * - * @param args - * the COM Variant objects that this event passes in. - */ - public void NavigateComplete2(Variant[] args) { - System.out.println("IEEvents Received (" - + Thread.currentThread().getName() + "): NavigateComplete " - + args.length + " parameters"); - } + /** + * Internet explorer event this proxy can receive + * + * @param args + * the COM Variant objects that this event passes in. + */ + public void NavigateComplete2(Variant[] args) { + System.out.println("IEEvents Received (" + + Thread.currentThread().getName() + "): NavigateComplete " + + args.length + " parameters"); + } - /** - * Internet explorer event this proxy can receive - * - * @param args - * the COM Variant objects that this event passes in. - */ - public void NewWindow2(Variant[] args) { - System.out.println("IEEvents Received (" - + Thread.currentThread().getName() + "): NewWindow2 " - + args.length + " parameters"); - } + /** + * Internet explorer event this proxy can receive + * + * @param args + * the COM Variant objects that this event passes in. + */ + public void NewWindow2(Variant[] args) { + System.out.println("IEEvents Received (" + + Thread.currentThread().getName() + "): NewWindow2 " + + args.length + " parameters"); + } - /** - * Internet explorer event this proxy can receive - * - * @param args - * the COM Variant objects that this event passes in. - */ - public void OnFullScreen(Variant[] args) { - System.out.println("IEEvents Received (" - + Thread.currentThread().getName() + "): OnFullScreen " - + args.length + " parameters"); - } + /** + * Internet explorer event this proxy can receive + * + * @param args + * the COM Variant objects that this event passes in. + */ + public void OnFullScreen(Variant[] args) { + System.out.println("IEEvents Received (" + + Thread.currentThread().getName() + "): OnFullScreen " + + args.length + " parameters"); + } - /** - * Internet explorer event this proxy can receive - * - * @param args - * the COM Variant objects that this event passes in. - */ - public void OnMenuBar(Variant[] args) { - System.out.println("IEEvents Received (" - + Thread.currentThread().getName() + "): OnMenuBar " - + args.length + " parameters"); - } + /** + * Internet explorer event this proxy can receive + * + * @param args + * the COM Variant objects that this event passes in. + */ + public void OnMenuBar(Variant[] args) { + System.out.println("IEEvents Received (" + + Thread.currentThread().getName() + "): OnMenuBar " + + args.length + " parameters"); + } - /** - * Internet explorer event this proxy can receive - * - * @param args - * the COM Variant objects that this event passes in. - */ - public void OnQuit(Variant[] args) { - System.out.println("IEEvents Received (" - + Thread.currentThread().getName() + "): OnQuit " - + args.length + " parameters"); - IETestThread.quitHandled = true; - } + /** + * Internet explorer event this proxy can receive + * + * @param args + * the COM Variant objects that this event passes in. + */ + public void OnQuit(Variant[] args) { + System.out.println("IEEvents Received (" + + Thread.currentThread().getName() + "): OnQuit " + + args.length + " parameters"); + IETestThread.quitHandled = true; + } - /** - * Internet explorer event this proxy can receive - * - * @param args - * the COM Variant objects that this event passes in. - */ - public void OnStatusBar(Variant[] args) { - System.out.println("IEEvents Received (" - + Thread.currentThread().getName() + "): OnStatusBar " - + args.length + " parameters"); - } + /** + * Internet explorer event this proxy can receive + * + * @param args + * the COM Variant objects that this event passes in. + */ + public void OnStatusBar(Variant[] args) { + System.out.println("IEEvents Received (" + + Thread.currentThread().getName() + "): OnStatusBar " + + args.length + " parameters"); + } - /** - * Internet explorer event this proxy can receive - * - * @param args - * the COM Variant objects that this event passes in. - */ - public void OnTheaterMode(Variant[] args) { - System.out.println("IEEvents Received (" - + Thread.currentThread().getName() + "): OnTheaterMode " - + args.length + " parameters"); - } + /** + * Internet explorer event this proxy can receive + * + * @param args + * the COM Variant objects that this event passes in. + */ + public void OnTheaterMode(Variant[] args) { + System.out.println("IEEvents Received (" + + Thread.currentThread().getName() + "): OnTheaterMode " + + args.length + " parameters"); + } - /** - * Internet explorer event this proxy can receive - * - * @param args - * the COM Variant objects that this event passes in. - */ - public void OnToolBar(Variant[] args) { - System.out.println("IEEvents Received (" - + Thread.currentThread().getName() + "): OnToolBar " - + args.length + " parameters"); - } + /** + * Internet explorer event this proxy can receive + * + * @param args + * the COM Variant objects that this event passes in. + */ + public void OnToolBar(Variant[] args) { + System.out.println("IEEvents Received (" + + Thread.currentThread().getName() + "): OnToolBar " + + args.length + " parameters"); + } - /** - * Internet explorer event this proxy can receive - * - * @param args - * the COM Variant objects that this event passes in. - */ - public void OnVisible(Variant[] args) { - System.out.println("IEEvents Received (" - + Thread.currentThread().getName() + "): OnVisible " - + args.length + " parameters"); - } + /** + * Internet explorer event this proxy can receive + * + * @param args + * the COM Variant objects that this event passes in. + */ + public void OnVisible(Variant[] args) { + System.out.println("IEEvents Received (" + + Thread.currentThread().getName() + "): OnVisible " + + args.length + " parameters"); + } - /** - * Internet explorer event this proxy can receive - * - * @param args - * the COM Variant objects that this event passes in. - */ - public void ProgressChange(Variant[] args) { - System.out.println("IEEvents Received (" - + Thread.currentThread().getName() + "): ProgressChange " - + args.length + " parameters"); - } + /** + * Internet explorer event this proxy can receive + * + * @param args + * the COM Variant objects that this event passes in. + */ + public void ProgressChange(Variant[] args) { + System.out.println("IEEvents Received (" + + Thread.currentThread().getName() + "): ProgressChange " + + args.length + " parameters"); + } - /** - * Internet explorer event this proxy can receive - * - * @param args - * the COM Variant objects that this event passes in. - */ - public void PropertyChange(Variant[] args) { - System.out.println("IEEvents Received (" - + Thread.currentThread().getName() + "): PropertyChange " - + args.length + " parameters"); - } + /** + * Internet explorer event this proxy can receive + * + * @param args + * the COM Variant objects that this event passes in. + */ + public void PropertyChange(Variant[] args) { + System.out.println("IEEvents Received (" + + Thread.currentThread().getName() + "): PropertyChange " + + args.length + " parameters"); + } - /** - * Internet explorer event this proxy can receive - * - * @param args - * the COM Variant objects that this event passes in. - */ - public void SetSecureLockIcon(Variant[] args) { - System.out.println("IEEvents Received (" - + Thread.currentThread().getName() - + "): setSecureLockIcon " + args.length + " parameters"); - } + /** + * Internet explorer event this proxy can receive + * + * @param args + * the COM Variant objects that this event passes in. + */ + public void SetSecureLockIcon(Variant[] args) { + System.out.println("IEEvents Received (" + + Thread.currentThread().getName() + + "): setSecureLockIcon " + args.length + " parameters"); + } - /** - * Internet explorer event this proxy can receive - * - * @param args - * the COM Variant objects that this event passes in. - */ - public void StatusTextChange(Variant[] args) { - System.out.println("IEEvents Received (" - + Thread.currentThread().getName() + "): StatusTextChange " - + args.length + " parameters"); - } + /** + * Internet explorer event this proxy can receive + * + * @param args + * the COM Variant objects that this event passes in. + */ + public void StatusTextChange(Variant[] args) { + System.out.println("IEEvents Received (" + + Thread.currentThread().getName() + "): StatusTextChange " + + args.length + " parameters"); + } - /** - * Internet explorer event this proxy can receive - * - * @param args - * the COM Variant objects that this event passes in. - */ - public void TitleChange(Variant[] args) { - System.out.println("IEEvents Received (" - + Thread.currentThread().getName() + "): TitleChange " - + args.length + " parameters"); - } + /** + * Internet explorer event this proxy can receive + * + * @param args + * the COM Variant objects that this event passes in. + */ + public void TitleChange(Variant[] args) { + System.out.println("IEEvents Received (" + + Thread.currentThread().getName() + "): TitleChange " + + args.length + " parameters"); + } - /** - * Internet explorer event this proxy can receive - * - * @param args - * the COM Variant objects that this event passes in. - */ - public void WindowClosing(Variant[] args) { - System.out.println("IEEvents Received (" - + Thread.currentThread().getName() + "): WindowClosing " - + args.length + " parameters"); - } - } + /** + * Internet explorer event this proxy can receive + * + * @param args + * the COM Variant objects that this event passes in. + */ + public void WindowClosing(Variant[] args) { + System.out.println("IEEvents Received (" + + Thread.currentThread().getName() + "): WindowClosing " + + args.length + " parameters"); + } + } } diff --git a/src/test/java/com/jacob/test/events/IETestActiveXProxy.java b/src/test/java/com/jacob/test/events/IETestActiveXProxy.java index cd6c047..2b41ad4 100644 --- a/src/test/java/com/jacob/test/events/IETestActiveXProxy.java +++ b/src/test/java/com/jacob/test/events/IETestActiveXProxy.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.test.events; @@ -60,268 +60,268 @@ import com.jacob.test.BaseTestCase; public class IETestActiveXProxy extends BaseTestCase { - /** - * the main test method that builds up the connection and runs the test - */ - public void testIEActiveProxyCallback() { - // this line starts the pump but it runs fine without it - ComThread.startMainSTA(); - // remove this line and it dies - // /ComThread.InitMTA(true); - IETestActiveProxyThread aThread = new IETestActiveProxyThread(); - aThread.start(); - while (aThread.isAlive()) { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // doen with the sleep - // e.printStackTrace(); - } - } - System.out - .println("Main: Thread quit, about to quit main sta in thread " - + Thread.currentThread().getName()); - // this line only does someting if startMainSTA() was called - ComThread.quitMainSTA(); - System.out.println("Main: did quit main sta in thread " - + Thread.currentThread().getName()); - if (aThread.threadFailedWithException != null) { - fail("caught an unexpected exception " - + aThread.threadFailedWithException); - } - } + /** + * the main test method that builds up the connection and runs the test + */ + public void testIEActiveProxyCallback() { + // this line starts the pump but it runs fine without it + ComThread.startMainSTA(); + // remove this line and it dies + // /ComThread.InitMTA(true); + IETestActiveProxyThread aThread = new IETestActiveProxyThread(); + aThread.start(); + while (aThread.isAlive()) { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // doen with the sleep + // e.printStackTrace(); + } + } + System.out + .println("Main: Thread quit, about to quit main sta in thread " + + Thread.currentThread().getName()); + // this line only does someting if startMainSTA() was called + ComThread.quitMainSTA(); + System.out.println("Main: did quit main sta in thread " + + Thread.currentThread().getName()); + if (aThread.threadFailedWithException != null) { + fail("caught an unexpected exception " + + aThread.threadFailedWithException); + } + } } class IETestActiveProxyThread extends Thread { - /** says that the quit message has been received from the target application */ - public static boolean quitHandled = false; + /** says that the quit message has been received from the target application */ + public static boolean quitHandled = false; - /** - * holds any caught exception so the main/test case can see them - */ - public Throwable threadFailedWithException = null; + /** + * holds any caught exception so the main/test case can see them + */ + public Throwable threadFailedWithException = null; - /** the thread's constructor */ - public IETestActiveProxyThread() { - super(); - } + /** the thread's constructor */ + public IETestActiveProxyThread() { + super(); + } - public void run() { - // this used to be 5 seconds but sourceforge is slow - int delay = 5000; // msec - // paired with statement below that blows up - ComThread.InitMTA(); - ActiveXComponent ie = new ActiveXComponent( - "InternetExplorer.Application"); - try { - Dispatch.put(ie, "Visible", new Variant(true)); - Dispatch.put(ie, "AddressBar", new Variant(true)); - System.out.println("IETestActiveProxyThread: " - + Dispatch.get(ie, "Path")); - Dispatch.put(ie, "StatusText", new Variant("My Status Text")); + public void run() { + // this used to be 5 seconds but sourceforge is slow + int delay = 5000; // msec + // paired with statement below that blows up + ComThread.InitMTA(); + ActiveXComponent ie = new ActiveXComponent( + "InternetExplorer.Application"); + try { + Dispatch.put(ie, "Visible", new Variant(true)); + Dispatch.put(ie, "AddressBar", new Variant(true)); + System.out.println("IETestActiveProxyThread: " + + Dispatch.get(ie, "Path")); + Dispatch.put(ie, "StatusText", new Variant("My Status Text")); - System.out - .println("IETestActiveProxyThread: About to hookup event listener"); - IEEventsActiveProxy ieE = new IEEventsActiveProxy(); - new ActiveXDispatchEvents(ie, ieE, "InternetExplorer.Application.1"); - System.out - .println("IETestActiveProxyThread: Did hookup event listener"); - // / why is this here? Was there some other code here in the past? - Variant optional = new Variant(); - optional.putNoParam(); + System.out + .println("IETestActiveProxyThread: About to hookup event listener"); + IEEventsActiveProxy ieE = new IEEventsActiveProxy(); + new ActiveXDispatchEvents(ie, ieE, "InternetExplorer.Application.1"); + System.out + .println("IETestActiveProxyThread: Did hookup event listener"); + // / why is this here? Was there some other code here in the past? + Variant optional = new Variant(); + optional.putNoParam(); - System.out - .println("IETestActiveProxyThread: About to call navigate to sourceforge"); - Dispatch.call(ie, "Navigate", new Variant( - "http://sourceforge.net/projects/jacob-project")); - System.out - .println("IETestActiveProxyThread: Did call navigate to sourceforge"); - try { - Thread.sleep(delay); - } catch (Exception e) { - } - System.out - .println("IETestActiveProxyThread: About to call navigate to yahoo"); - Dispatch.call(ie, "Navigate", new Variant( - "http://groups.yahoo.com/group/jacob-project")); - System.out - .println("IETestActiveProxyThread: Did call navigate to yahoo"); - try { - Thread.sleep(delay); - } catch (Exception e) { - } - } catch (Exception e) { - threadFailedWithException = e; - e.printStackTrace(); - } catch (Throwable re) { - threadFailedWithException = re; - re.printStackTrace(); - } finally { - System.out.println("IETestActiveProxyThread: About to send Quit"); - ie.invoke("Quit", new Variant[] {}); - System.out.println("IETestActiveProxyThread: Did send Quit"); - } - // this blows up when it tries to release a DispatchEvents object - // I think this is because there is still one event we should get back - // "OnQuit" that will came after we have released the thread pool - // this is probably messed up because DispatchEvent object will have - // been - // freed before the callback - // commenting out ie.invoke(quit...) causes this to work without error - // this code tries to wait until the quit has been handled but that - // doesn't work - System.out - .println("IETestActiveProxyThread: Waiting until we've received the quit callback"); - while (!quitHandled) { - try { - Thread.sleep(delay / 5); - } catch (InterruptedException e) { - } - } - System.out - .println("IETestActiveProxyThread: Received the quit callback"); - // wait a little while for it to end - // try {Thread.sleep(delay); } catch (InterruptedException e) {} - System.out - .println("IETestActiveProxyThread: about to call ComThread.Release in thread " - + Thread.currentThread().getName()); + System.out + .println("IETestActiveProxyThread: About to call navigate to sourceforge"); + Dispatch.call(ie, "Navigate", new Variant( + "http://sourceforge.net/projects/jacob-project")); + System.out + .println("IETestActiveProxyThread: Did call navigate to sourceforge"); + try { + Thread.sleep(delay); + } catch (Exception e) { + } + System.out + .println("IETestActiveProxyThread: About to call navigate to yahoo"); + Dispatch.call(ie, "Navigate", new Variant( + "http://groups.yahoo.com/group/jacob-project")); + System.out + .println("IETestActiveProxyThread: Did call navigate to yahoo"); + try { + Thread.sleep(delay); + } catch (Exception e) { + } + } catch (Exception e) { + threadFailedWithException = e; + e.printStackTrace(); + } catch (Throwable re) { + threadFailedWithException = re; + re.printStackTrace(); + } finally { + System.out.println("IETestActiveProxyThread: About to send Quit"); + ie.invoke("Quit", new Variant[] {}); + System.out.println("IETestActiveProxyThread: Did send Quit"); + } + // this blows up when it tries to release a DispatchEvents object + // I think this is because there is still one event we should get back + // "OnQuit" that will came after we have released the thread pool + // this is probably messed up because DispatchEvent object will have + // been + // freed before the callback + // commenting out ie.invoke(quit...) causes this to work without error + // this code tries to wait until the quit has been handled but that + // doesn't work + System.out + .println("IETestActiveProxyThread: Waiting until we've received the quit callback"); + while (!quitHandled) { + try { + Thread.sleep(delay / 5); + } catch (InterruptedException e) { + } + } + System.out + .println("IETestActiveProxyThread: Received the quit callback"); + // wait a little while for it to end + // try {Thread.sleep(delay); } catch (InterruptedException e) {} + System.out + .println("IETestActiveProxyThread: about to call ComThread.Release in thread " + + Thread.currentThread().getName()); - ComThread.Release(); - } + ComThread.Release(); + } - /** - * The events class must be publicly accessable for reflection to work. The - * list of available events is located at - * http://msdn2.microsoft.com/en-us/library/aa768280.aspx - */ - public class IEEventsActiveProxy { + /** + * The events class must be publicly accessable for reflection to work. The + * list of available events is located at + * http://msdn2.microsoft.com/en-us/library/aa768280.aspx + */ + public class IEEventsActiveProxy { - public void BeforeNavigate2(Dispatch pDisp, String url, Integer flags, - String targetFrameName, Variant postData, String headers, - Boolean cancel) { - System.out.println("IEEventsActiveProxy Received (" - + Thread.currentThread().getName() + "): BeforeNavigate2 " - + url); - } + public void BeforeNavigate2(Dispatch pDisp, String url, Integer flags, + String targetFrameName, Variant postData, String headers, + Boolean cancel) { + System.out.println("IEEventsActiveProxy Received (" + + Thread.currentThread().getName() + "): BeforeNavigate2 " + + url); + } - public void CommandStateChange(Integer command, Boolean enable) { - System.out.println("IEEventsActiveProxy Received (" - + Thread.currentThread().getName() - + "): CommandStateChange " + command); - } + public void CommandStateChange(Integer command, Boolean enable) { + System.out.println("IEEventsActiveProxy Received (" + + Thread.currentThread().getName() + + "): CommandStateChange " + command); + } - public void DocumentComplete(Dispatch pDisp, String url) { - System.out.println("IEEventsActiveProxy Received (" - + Thread.currentThread().getName() + "): DocumentComplete " - + url); - } + public void DocumentComplete(Dispatch pDisp, String url) { + System.out.println("IEEventsActiveProxy Received (" + + Thread.currentThread().getName() + "): DocumentComplete " + + url); + } - public void DownloadBegin() { - System.out.println("IEEventsActiveProxy Received (" - + Thread.currentThread().getName() + "): DownloadBegin "); - } + public void DownloadBegin() { + System.out.println("IEEventsActiveProxy Received (" + + Thread.currentThread().getName() + "): DownloadBegin "); + } - public void DownloadComplete() { - System.out - .println("IEEventsActiveProxy Received (" - + Thread.currentThread().getName() - + "): DownloadComplete "); - } + public void DownloadComplete() { + System.out + .println("IEEventsActiveProxy Received (" + + Thread.currentThread().getName() + + "): DownloadComplete "); + } - public void NavigateComplete2(Dispatch pDisp, String url) { - System.out.println("IEEventsActiveProxy Received (" - + Thread.currentThread().getName() + "): NavigateComplete " - + url); - } + public void NavigateComplete2(Dispatch pDisp, String url) { + System.out.println("IEEventsActiveProxy Received (" + + Thread.currentThread().getName() + "): NavigateComplete " + + url); + } - public void NavigateError(Dispatch pDispatch, String url, - String targetFrameName, Integer statusCode, Boolean Cancel) { - System.out.println("IEEvents Received (" - + Thread.currentThread().getName() + "): NavigateError " - + statusCode); - } + public void NavigateError(Dispatch pDispatch, String url, + String targetFrameName, Integer statusCode, Boolean Cancel) { + System.out.println("IEEvents Received (" + + Thread.currentThread().getName() + "): NavigateError " + + statusCode); + } - public void NewWindow2(Dispatch pDisp, Boolean cancel) { - System.out.println("IEEventsActiveProxy Received (" - + Thread.currentThread().getName() + "): NewWindow2 " - + pDisp); - } + public void NewWindow2(Dispatch pDisp, Boolean cancel) { + System.out.println("IEEventsActiveProxy Received (" + + Thread.currentThread().getName() + "): NewWindow2 " + + pDisp); + } - public void OnFullScreen(Boolean fullScreen) { - System.out.println("IEEventsActiveProxy Received (" - + Thread.currentThread().getName() + "): OnFullScreen " - + fullScreen); - } + public void OnFullScreen(Boolean fullScreen) { + System.out.println("IEEventsActiveProxy Received (" + + Thread.currentThread().getName() + "): OnFullScreen " + + fullScreen); + } - public void OnMenuBar(Boolean menuBar) { - System.out.println("IEEventsActiveProxy Received (" - + Thread.currentThread().getName() + "): OnMenuBar " - + menuBar); - } + public void OnMenuBar(Boolean menuBar) { + System.out.println("IEEventsActiveProxy Received (" + + Thread.currentThread().getName() + "): OnMenuBar " + + menuBar); + } - public void OnQuit() { - System.out.println("IEEventsActiveProxy Received (" - + Thread.currentThread().getName() + "): OnQuit "); - IETestActiveProxyThread.quitHandled = true; - } + public void OnQuit() { + System.out.println("IEEventsActiveProxy Received (" + + Thread.currentThread().getName() + "): OnQuit "); + IETestActiveProxyThread.quitHandled = true; + } - public void OnStatusBar(Boolean statusBar) { - System.out.println("IEEventsActiveProxy Received (" - + Thread.currentThread().getName() + "): OnStatusBar " - + statusBar); - } + public void OnStatusBar(Boolean statusBar) { + System.out.println("IEEventsActiveProxy Received (" + + Thread.currentThread().getName() + "): OnStatusBar " + + statusBar); + } - public void OnTheaterMode(Boolean theaterMode) { - System.out.println("IEEventsActiveProxy Received (" - + Thread.currentThread().getName() + "): OnTheaterMode " - + theaterMode); - } + public void OnTheaterMode(Boolean theaterMode) { + System.out.println("IEEventsActiveProxy Received (" + + Thread.currentThread().getName() + "): OnTheaterMode " + + theaterMode); + } - public void OnToolBar(Boolean onToolBar) { - System.out.println("IEEventsActiveProxy Received (" - + Thread.currentThread().getName() + "): OnToolBar " - + onToolBar); - } + public void OnToolBar(Boolean onToolBar) { + System.out.println("IEEventsActiveProxy Received (" + + Thread.currentThread().getName() + "): OnToolBar " + + onToolBar); + } - public void OnVisible(Boolean onVisible) { - System.out.println("IEEventsActiveProxy Received (" - + Thread.currentThread().getName() + "): onVisible " - + onVisible); - } + public void OnVisible(Boolean onVisible) { + System.out.println("IEEventsActiveProxy Received (" + + Thread.currentThread().getName() + "): onVisible " + + onVisible); + } - public void ProgressChange() { - System.out.println("IEEventsActiveProxy Received (" - + Thread.currentThread().getName() + "): ProgressChange "); - } + public void ProgressChange() { + System.out.println("IEEventsActiveProxy Received (" + + Thread.currentThread().getName() + "): ProgressChange "); + } - public void PropertyChange() { - System.out.println("IEEventsActiveProxy Received (" - + Thread.currentThread().getName() + "): PropertyChange "); - } + public void PropertyChange() { + System.out.println("IEEventsActiveProxy Received (" + + Thread.currentThread().getName() + "): PropertyChange "); + } - public void SetSecureLockIcon(Integer secureLockIcon) { - System.out.println("IEEvents Received (" - + Thread.currentThread().getName() - + "): setSecureLockIcon " + secureLockIcon); - } + public void SetSecureLockIcon(Integer secureLockIcon) { + System.out.println("IEEvents Received (" + + Thread.currentThread().getName() + + "): setSecureLockIcon " + secureLockIcon); + } - public void StatusTextChange() { - System.out - .println("IEEventsActiveProxy Received (" - + Thread.currentThread().getName() - + "): StatusTextChange "); - } + public void StatusTextChange() { + System.out + .println("IEEventsActiveProxy Received (" + + Thread.currentThread().getName() + + "): StatusTextChange "); + } - public void TitleChange() { - System.out.println("IEEventsActiveProxy Received (" - + Thread.currentThread().getName() + "): TitleChange "); - } + public void TitleChange() { + System.out.println("IEEventsActiveProxy Received (" + + Thread.currentThread().getName() + "): TitleChange "); + } - public void WindowClosing(Boolean isChildWindow) { - System.out.println("IEEvents Received (" - + Thread.currentThread().getName() + "): WindowClosing " - + isChildWindow); - } - } + public void WindowClosing(Boolean isChildWindow) { + System.out.println("IEEvents Received (" + + Thread.currentThread().getName() + "): WindowClosing " + + isChildWindow); + } + } } diff --git a/src/test/java/com/jacob/test/events/WordEventTest.java b/src/test/java/com/jacob/test/events/WordEventTest.java index 3730d46..ff353a8 100644 --- a/src/test/java/com/jacob/test/events/WordEventTest.java +++ b/src/test/java/com/jacob/test/events/WordEventTest.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.test.events; @@ -58,74 +58,74 @@ import com.jacob.test.BaseTestCase; */ public class WordEventTest extends BaseTestCase { - /** - * load up word, register for events and make stuff happen - * - * @param args - */ - public void testCaptureWordEvents() { - String pid = "Word.Application"; - String typeLibLocation = null; + /** + * load up word, register for events and make stuff happen + * + * @param args + */ + public void testCaptureWordEvents() { + String pid = "Word.Application"; + String typeLibLocation = null; - // Grab The Component. - ActiveXComponent axc = new ActiveXComponent(pid); - try { - // Add a listener (doesn't matter what it is). - DispatchEvents de; - if (typeLibLocation == null) { - de = new DispatchEvents(axc, new WordEventTest()); - } else { - de = new DispatchEvents(axc, new WordEventTest(), pid, - typeLibLocation); - } - if (de == null) { - fail("No exception thrown but no dispatch returned for Word events"); - } else { - // Yea! - System.out.println("Successfully attached to " + pid); + // Grab The Component. + ActiveXComponent axc = new ActiveXComponent(pid); + try { + // Add a listener (doesn't matter what it is). + DispatchEvents de; + if (typeLibLocation == null) { + de = new DispatchEvents(axc, new WordEventTest()); + } else { + de = new DispatchEvents(axc, new WordEventTest(), pid, + typeLibLocation); + } + if (de == null) { + fail("No exception thrown but no dispatch returned for Word events"); + } else { + // Yea! + System.out.println("Successfully attached to " + pid); - } - // this is different from the ExcelEventTest because it uses - // the jacob active X api instead of the Dispatch api - System.out.println("version=" + axc.getPropertyAsString("Version")); - axc.setProperty("Visible", true); - ActiveXComponent documents = axc - .getPropertyAsComponent("Documents"); - if (documents == null) { - fail("unable to get documents"); - } - axc.invoke("Quit", new Variant[] {}); + } + // this is different from the ExcelEventTest because it uses + // the jacob active X api instead of the Dispatch api + System.out.println("version=" + axc.getPropertyAsString("Version")); + axc.setProperty("Visible", true); + ActiveXComponent documents = axc + .getPropertyAsComponent("Documents"); + if (documents == null) { + fail("unable to get documents"); + } + axc.invoke("Quit", new Variant[] {}); - } catch (ComException cfe) { - cfe.printStackTrace(); - fail("Failed to attach to " + pid + ": " + cfe.getMessage()); + } catch (ComException cfe) { + cfe.printStackTrace(); + fail("Failed to attach to " + pid + ": " + cfe.getMessage()); - } - System.out - .println("Someone needs to add some MSWord commands to this to " - + "make some on screen stuff happens so the tester " - + "thinks we tested something"); - } + } + System.out + .println("Someone needs to add some MSWord commands to this to " + + "make some on screen stuff happens so the tester " + + "thinks we tested something"); + } - /** - * a class that receives messages from word - */ - public class WordEvents extends InvocationProxy { - /** - * Constructor so we can create an instance that implements invoke() - */ - public WordEvents() { - } + /** + * a class that receives messages from word + */ + public class WordEvents extends InvocationProxy { + /** + * Constructor so we can create an instance that implements invoke() + */ + public WordEvents() { + } - /** - * override the invoke() method to log all the events without writing a - * bunch of code - */ - public Variant invoke(String methodName, Variant targetParameter[]) { - System.out.println("Received event from Windows program" - + methodName); - return null; - } + /** + * override the invoke() method to log all the events without writing a + * bunch of code + */ + public Variant invoke(String methodName, Variant targetParameter[]) { + System.out.println("Received event from Windows program" + + methodName); + return null; + } - } + } } \ No newline at end of file diff --git a/src/test/java/com/jacob/test/excel/ControllerTest.java b/src/test/java/com/jacob/test/excel/ControllerTest.java index 217dc99..754dbcf 100644 --- a/src/test/java/com/jacob/test/excel/ControllerTest.java +++ b/src/test/java/com/jacob/test/excel/ControllerTest.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.test.excel; @@ -56,219 +56,219 @@ import com.jacob.test.BaseTestCase; */ public class ControllerTest extends BaseTestCase { - private Controller controller; + private Controller controller; - protected void setUp() { - controller = new Controller(); - } + protected void setUp() { + controller = new Controller(); + } - public void testGetColumnA() { - List list = controller.getColumnA(super - .getWindowsFilePathToPackageResource("teste.xls", this - .getClass())); - assertEquals(50, list.size()); - } + public void testGetColumnA() { + List list = controller.getColumnA(super + .getWindowsFilePathToPackageResource("teste.xls", this + .getClass())); + assertEquals(50, list.size()); + } - public void testGetColumnB() { - List list = controller.getColumnB(super - .getWindowsFilePathToPackageResource("teste.xls", this - .getClass())); - assertEquals(40, list.size()); - } + public void testGetColumnB() { + List list = controller.getColumnB(super + .getWindowsFilePathToPackageResource("teste.xls", this + .getClass())); + assertEquals(40, list.size()); + } - /** - * This class looks bad because it is a compressed version that was - * originally in 3 different files as part of a bug submission. I didn't - * want to simplify it because it might no longer demonstrate the problem we - * were trying to fix - */ - public class Controller { + /** + * This class looks bad because it is a compressed version that was + * originally in 3 different files as part of a bug submission. I didn't + * want to simplify it because it might no longer demonstrate the problem we + * were trying to fix + */ + public class Controller { - private List columnA; + private List columnA; - private List columnB; + private List columnB; - public List getColumnA(String pathToTest) { - load(pathToTest); - return columnA; - } + public List getColumnA(String pathToTest) { + load(pathToTest); + return columnA; + } - public List getColumnB(String pathToTest) { - load(pathToTest); - return columnB; - } + public List getColumnB(String pathToTest) { + load(pathToTest); + return columnB; + } - public void load(String pathToTest) { - if (columnA == null || columnB == null) { - File excelFile = new File(pathToTest); - executaExcelCallBack(excelFile.getAbsolutePath(), "password"); - } - } + public void load(String pathToTest) { + if (columnA == null || columnB == null) { + File excelFile = new File(pathToTest); + executaExcelCallBack(excelFile.getAbsolutePath(), "password"); + } + } - public void executaExcelCallBack(String path, String password) { - // ComThread.InitSTA(); - ComThread.InitMTA(); - ActiveXComponent excel = new ActiveXComponent("Excel.Application"); + public void executaExcelCallBack(String path, String password) { + // ComThread.InitSTA(); + ComThread.InitMTA(); + ActiveXComponent excel = new ActiveXComponent("Excel.Application"); - try { + try { - excel.setProperty("Visible", false); - Dispatch workbooks = excel.getProperty("Workbooks") - .toDispatch(); + excel.setProperty("Visible", false); + Dispatch workbooks = excel.getProperty("Workbooks") + .toDispatch(); - Dispatch workbook = Dispatch.call(workbooks, "Open", path, // FileName - 3, // UpdateLinks - false, // Readonly - 5, // Format - password // Password - ).toDispatch(); + Dispatch workbook = Dispatch.call(workbooks, "Open", path, // FileName + 3, // UpdateLinks + false, // Readonly + 5, // Format + password // Password + ).toDispatch(); - Dispatch sheets = Dispatch.call(workbook, "Worksheets") - .toDispatch(); - System.out.println("Before executa"); - executa(excel, sheets); - System.out.println("After executa"); + Dispatch sheets = Dispatch.call(workbook, "Worksheets") + .toDispatch(); + System.out.println("Before executa"); + executa(excel, sheets); + System.out.println("After executa"); - Dispatch.call(workbook, "Close", new Variant(false)); - Dispatch.call(workbooks, "Close"); - System.out.println("After Close"); - } catch (Exception e) { - e.printStackTrace(); - } finally { - try { - Thread.sleep(1000); - } catch (Exception e) { - e.printStackTrace(); - } - System.out.println("Before Quit"); - excel.invoke("Quit", new Variant[] {}); - try { - Thread.sleep(1000); - } catch (Exception e) { - e.printStackTrace(); - } - System.out.println("After Quit, Before Release()"); - ComThread.Release(); - System.out.println("After Release()"); - } - } + Dispatch.call(workbook, "Close", new Variant(false)); + Dispatch.call(workbooks, "Close"); + System.out.println("After Close"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + Thread.sleep(1000); + } catch (Exception e) { + e.printStackTrace(); + } + System.out.println("Before Quit"); + excel.invoke("Quit", new Variant[] {}); + try { + Thread.sleep(1000); + } catch (Exception e) { + e.printStackTrace(); + } + System.out.println("After Quit, Before Release()"); + ComThread.Release(); + System.out.println("After Release()"); + } + } - /** - * Constante para configurar a planilha em modo "Calculation" automático - */ - public static final int CALC_AUTOMATICO = -4105; + /** + * Constante para configurar a planilha em modo "Calculation" automático + */ + public static final int CALC_AUTOMATICO = -4105; - /** - * Constante para configurar a planilha em modo "Calculation" manual - */ - public static final int CALC_MANUAL = -4135; + /** + * Constante para configurar a planilha em modo "Calculation" manual + */ + public static final int CALC_MANUAL = -4135; - /** - * Escreve um determinado valor em uma célula da pasta em questão. O - * valor é escrito configurando a propriedade Value da célula - * - * @param celula - - * célula para escrever novo valor - * @param sheet - - * pasta da planilha em questão - * @param valor - - * valor a ser escrito na celula - */ - public void informarValorCelula(String celula, Dispatch sheet, - String valor) { - System.out.println("Entered informarValorCelula"); - Dispatch cel = obterCelula(celula, sheet); - Dispatch.put(cel, "Value", valor); - System.out.println("Exiting informarValorCelula"); - } + /** + * Escreve um determinado valor em uma célula da pasta em questão. O + * valor é escrito configurando a propriedade Value da célula + * + * @param celula - + * célula para escrever novo valor + * @param sheet - + * pasta da planilha em questão + * @param valor - + * valor a ser escrito na celula + */ + public void informarValorCelula(String celula, Dispatch sheet, + String valor) { + System.out.println("Entered informarValorCelula"); + Dispatch cel = obterCelula(celula, sheet); + Dispatch.put(cel, "Value", valor); + System.out.println("Exiting informarValorCelula"); + } - /** - * Obtem o valor de contido em uma célula. O valor representa o conteúdo - * da propriedade Value da célula - * - * @param celula - - * célula a ser lida - * @param sheet - - * pasta da planilha que contém a célula - * @return - conteúdo da propriedade Value - */ - public Variant obterValorCelula(String celula, Dispatch sheet) { - System.out.println("Entered obterValorCelula"); - Dispatch d = obterCelula(celula, sheet); - Variant returnedValue = Dispatch.get(d, "Value"); - System.out.println("Exiting obterValorCelula"); - return returnedValue; - } + /** + * Obtem o valor de contido em uma célula. O valor representa o conteúdo + * da propriedade Value da célula + * + * @param celula - + * célula a ser lida + * @param sheet - + * pasta da planilha que contém a célula + * @return - conteúdo da propriedade Value + */ + public Variant obterValorCelula(String celula, Dispatch sheet) { + System.out.println("Entered obterValorCelula"); + Dispatch d = obterCelula(celula, sheet); + Variant returnedValue = Dispatch.get(d, "Value"); + System.out.println("Exiting obterValorCelula"); + return returnedValue; + } - /** - * Obtem referência para a célua ou conjunto de células especificado no - * parametro - * - * @param celula - - * Referência para célula ou conjunto de células. A String - * "A1" referencia a coluna A e linha 1. A Sting "A1:A10" - * referencia as células compreendidas no intervalo entre a - * célua A1 e a célula A10 - * @param sheet - - * pasta da planilha qye contém as células - * @return - referencia para um célula ou conjunto de células, - * dependendo do parâmetro passado - */ - public Dispatch obterCelula(String celula, Dispatch sheet) { - System.out.println("Entered obterCelula"); - Dispatch d = Dispatch.invoke(sheet, "Range", Dispatch.Get, - new Object[] { celula }, new int[1]).toDispatch(); - System.out.println("Exiting obterCelula"); - return d; - } + /** + * Obtem referência para a célua ou conjunto de células especificado no + * parametro + * + * @param celula - + * Referência para célula ou conjunto de células. A String + * "A1" referencia a coluna A e linha 1. A Sting "A1:A10" + * referencia as células compreendidas no intervalo entre a + * célua A1 e a célula A10 + * @param sheet - + * pasta da planilha qye contém as células + * @return - referencia para um célula ou conjunto de células, + * dependendo do parâmetro passado + */ + public Dispatch obterCelula(String celula, Dispatch sheet) { + System.out.println("Entered obterCelula"); + Dispatch d = Dispatch.invoke(sheet, "Range", Dispatch.Get, + new Object[] { celula }, new int[1]).toDispatch(); + System.out.println("Exiting obterCelula"); + return d; + } - /** - * Obtem os valores de um conjunto de células - * - * @param celulas - - * Referência para conjunto de células - * @param sheet - - * Pasta que contém as cálulas referenciadas - * @return - Lista onde cada elemento é o valor de uma célula - * referenciada na conjunto - */ - public List obterValoresRange(String celulas, Dispatch sheet) { - List valores = new LinkedList(); + /** + * Obtem os valores de um conjunto de células + * + * @param celulas - + * Referência para conjunto de células + * @param sheet - + * Pasta que contém as cálulas referenciadas + * @return - Lista onde cada elemento é o valor de uma célula + * referenciada na conjunto + */ + public List obterValoresRange(String celulas, Dispatch sheet) { + List valores = new LinkedList(); - // obtem valor das celulas como um Variant - Variant var = obterValorCelula(celulas, sheet); + // obtem valor das celulas como um Variant + Variant var = obterValorCelula(celulas, sheet); - // toString da Variant é interpretado por um StringTokenizer e os - // tokens - // inseridos na lista de retorno - String arrayAsString = null; - System.out - .println("Calling toString() on the Variant that is an array will blow up " - + var.getvt() + " --> " + arrayAsString); - arrayAsString = var.toString(); - StringTokenizer st = new StringTokenizer(arrayAsString, "\n"); - while (st.hasMoreTokens()) { - valores.add(st.nextToken().trim()); - } - return valores; - } + // toString da Variant é interpretado por um StringTokenizer e os + // tokens + // inseridos na lista de retorno + String arrayAsString = null; + System.out + .println("Calling toString() on the Variant that is an array will blow up " + + var.getvt() + " --> " + arrayAsString); + arrayAsString = var.toString(); + StringTokenizer st = new StringTokenizer(arrayAsString, "\n"); + while (st.hasMoreTokens()) { + valores.add(st.nextToken().trim()); + } + return valores; + } - /** - * Método para execução de ação a ser executada em planilha excel. - * - * @param xl - - * Referencia para aplicação excel - * @param sheets - - * Referencia para conjunto de pastas da planilha - */ - public void executa(ActiveXComponent xl, Dispatch sheets) { + /** + * Método para execução de ação a ser executada em planilha excel. + * + * @param xl - + * Referencia para aplicação excel + * @param sheets - + * Referencia para conjunto de pastas da planilha + */ + public void executa(ActiveXComponent xl, Dispatch sheets) { - System.out.println("Entered private ExcellCallBack executa()"); - Dispatch sheet = Dispatch.call(sheets, "Item", "Plan1") - .toDispatch(); - columnA = obterValoresRange("A1:A50", sheet); - columnB = obterValoresRange("B1:B40", sheet); - System.out.println("Exiting private ExcellCallBack executa()"); - } - } + System.out.println("Entered private ExcellCallBack executa()"); + Dispatch sheet = Dispatch.call(sheets, "Item", "Plan1") + .toDispatch(); + columnA = obterValoresRange("A1:A50", sheet); + columnB = obterValoresRange("B1:B40", sheet); + System.out.println("Exiting private ExcellCallBack executa()"); + } + } } diff --git a/src/test/java/com/jacob/test/powerpoint/PowerpointTest.java b/src/test/java/com/jacob/test/powerpoint/PowerpointTest.java index 5b5656e..e565afd 100644 --- a/src/test/java/com/jacob/test/powerpoint/PowerpointTest.java +++ b/src/test/java/com/jacob/test/powerpoint/PowerpointTest.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.test.powerpoint; @@ -69,131 +69,131 @@ import com.jacob.test.BaseTestCase; * options. */ public class PowerpointTest extends BaseTestCase { - private static final int NUM_THREADS = 5; - protected static final int NUM_ITERATIONS = 50; + private static final int NUM_THREADS = 5; + protected static final int NUM_ITERATIONS = 50; - /** - * main program that lets us run this as a test - * - * @param args - */ - public void testPowerpoint() { - ComThread.InitMTA(); + /** + * main program that lets us run this as a test + * + * @param args + */ + public void testPowerpoint() { + ComThread.InitMTA(); - ActiveXComponent component = new ActiveXComponent( - "Powerpoint.Application"); - Dispatch comPowerpoint = component.getObject(); + ActiveXComponent component = new ActiveXComponent( + "Powerpoint.Application"); + Dispatch comPowerpoint = component.getObject(); - try { - PowerpointTestThread[] threads = new PowerpointTestThread[NUM_THREADS]; - for (int i = 0; i < NUM_THREADS; i++) { - threads[i] = new PowerpointTestThread(i + 1, comPowerpoint); - threads[i].start(); - } + try { + PowerpointTestThread[] threads = new PowerpointTestThread[NUM_THREADS]; + for (int i = 0; i < NUM_THREADS; i++) { + threads[i] = new PowerpointTestThread(i + 1, comPowerpoint); + threads[i].start(); + } - boolean allThreadsFinished = false; - while (!allThreadsFinished) { - allThreadsFinished = true; - for (int i = 0; i < NUM_THREADS; i++) { - if (threads[i].isAlive()) { - allThreadsFinished = false; - break; - } - } - if (!allThreadsFinished) { - try { - Thread.sleep(100); - } catch (InterruptedException e) { - // no op - } - } - } + boolean allThreadsFinished = false; + while (!allThreadsFinished) { + allThreadsFinished = true; + for (int i = 0; i < NUM_THREADS; i++) { + if (threads[i].isAlive()) { + allThreadsFinished = false; + break; + } + } + if (!allThreadsFinished) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // no op + } + } + } - Dispatch.call(comPowerpoint, "Quit"); - for (int i = 0; i < NUM_THREADS; i++) { - if (threads[i].threadFailedWithException != null) { - fail("caught unexpected exception in thread " - + threads[i].threadFailedWithException); - } - } - } finally { - ComThread.Release(); - } + Dispatch.call(comPowerpoint, "Quit"); + for (int i = 0; i < NUM_THREADS; i++) { + if (threads[i].threadFailedWithException != null) { + fail("caught unexpected exception in thread " + + threads[i].threadFailedWithException); + } + } + } finally { + ComThread.Release(); + } - } + } - /** - * the thread class that runs power point - */ - public class PowerpointTestThread extends Thread { - /** - * holds any caught exception so the main/test case can see them - */ - public Throwable threadFailedWithException = null; + /** + * the thread class that runs power point + */ + public class PowerpointTestThread extends Thread { + /** + * holds any caught exception so the main/test case can see them + */ + public Throwable threadFailedWithException = null; - private int threadID; - private Dispatch comPowerpoint; + private int threadID; + private Dispatch comPowerpoint; - /** - * thread constructor - * - * @param threadID - * @param comPowerpoint - */ - public PowerpointTestThread(int threadID, Dispatch comPowerpoint) { - super("TestThread " + threadID); - this.threadID = threadID; - this.comPowerpoint = comPowerpoint; - } + /** + * thread constructor + * + * @param threadID + * @param comPowerpoint + */ + public PowerpointTestThread(int threadID, Dispatch comPowerpoint) { + super("TestThread " + threadID); + this.threadID = threadID; + this.comPowerpoint = comPowerpoint; + } - public void run() { - System.out.println("Thread \"" + Thread.currentThread().getName() - + "\" started"); - System.out.flush(); - ComThread.InitMTA(); - try { - for (int i = 0; i < NUM_ITERATIONS; i++) { - if (i % 10 == 0) { - System.out.println(Thread.currentThread().getName() - + ": Iteration " + i); - System.out.flush(); - } - // office 2003 seems to have been able to handle more - // multi-threaded requests than office 2007 - // office 2003 could handle 5 threads @ 50 iterations - // office 2007 can only handle 1 thread at a time - synchronized(comPowerpoint){ - Dispatch comPresentations = Dispatch.get(comPowerpoint, - "Presentations").toDispatch(); - Dispatch comPresentation = Dispatch.call( - comPresentations, - "Open", - getWindowsFilePathToPackageResource("test" - + threadID + ".ppt", this.getClass()), - new Integer(0), new Integer(0), new Integer(0)) - .toDispatch(); - Dispatch.call(comPresentation, "Close"); - } - } - } catch (ComFailException cfe) { - threadFailedWithException = cfe; - System.err.println(Thread.currentThread().getName() - + "\" while working on: " - + getWindowsFilePathToPackageResource("test" + threadID - + ".ppt", this.getClass())); - cfe.printStackTrace(); - } catch (Exception e) { - threadFailedWithException = e; - System.err.println("Error in Thread \"" - + Thread.currentThread().getName() + "\":"); - e.printStackTrace(); - } finally { - ComThread.Release(); - System.out.println("Thread \"" - + Thread.currentThread().getName() + "\" finished"); - System.out.flush(); - } - } + public void run() { + System.out.println("Thread \"" + Thread.currentThread().getName() + + "\" started"); + System.out.flush(); + ComThread.InitMTA(); + try { + for (int i = 0; i < NUM_ITERATIONS; i++) { + if (i % 10 == 0) { + System.out.println(Thread.currentThread().getName() + + ": Iteration " + i); + System.out.flush(); + } + // office 2003 seems to have been able to handle more + // multi-threaded requests than office 2007 + // office 2003 could handle 5 threads @ 50 iterations + // office 2007 can only handle 1 thread at a time + synchronized(comPowerpoint){ + Dispatch comPresentations = Dispatch.get(comPowerpoint, + "Presentations").toDispatch(); + Dispatch comPresentation = Dispatch.call( + comPresentations, + "Open", + getWindowsFilePathToPackageResource("test" + + threadID + ".ppt", this.getClass()), + new Integer(0), new Integer(0), new Integer(0)) + .toDispatch(); + Dispatch.call(comPresentation, "Close"); + } + } + } catch (ComFailException cfe) { + threadFailedWithException = cfe; + System.err.println(Thread.currentThread().getName() + + "\" while working on: " + + getWindowsFilePathToPackageResource("test" + threadID + + ".ppt", this.getClass())); + cfe.printStackTrace(); + } catch (Exception e) { + threadFailedWithException = e; + System.err.println("Error in Thread \"" + + Thread.currentThread().getName() + "\":"); + e.printStackTrace(); + } finally { + ComThread.Release(); + System.out.println("Thread \"" + + Thread.currentThread().getName() + "\" finished"); + System.out.flush(); + } + } - } + } } \ No newline at end of file diff --git a/src/test/java/com/jacob/test/safearray/SafeArrayBasicTest.java b/src/test/java/com/jacob/test/safearray/SafeArrayBasicTest.java index 7de5bf1..d44cef3 100644 --- a/src/test/java/com/jacob/test/safearray/SafeArrayBasicTest.java +++ b/src/test/java/com/jacob/test/safearray/SafeArrayBasicTest.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.test.safearray; @@ -57,297 +57,297 @@ import com.jacob.test.BaseTestCase; */ public class SafeArrayBasicTest extends BaseTestCase { - /** - * - */ - public void testShortSafeArray() { - short sourceData[] = new short[] { 1, 2, 3 }; - SafeArray saUnderTest = new SafeArray(Variant.VariantVariant, 3); + /** + * + */ + public void testShortSafeArray() { + short sourceData[] = new short[] { 1, 2, 3 }; + SafeArray saUnderTest = new SafeArray(Variant.VariantVariant, 3); - saUnderTest.fromShortArray(sourceData); - short[] extractedFromSafeArray = saUnderTest.toShortArray(); - for (int i = 0; i < extractedFromSafeArray.length; i++) { - assertEquals("" + i, sourceData[i], extractedFromSafeArray[i]); - } + saUnderTest.fromShortArray(sourceData); + short[] extractedFromSafeArray = saUnderTest.toShortArray(); + for (int i = 0; i < extractedFromSafeArray.length; i++) { + assertEquals("" + i, sourceData[i], extractedFromSafeArray[i]); + } - assertEquals("single get failed: ", sourceData[2], saUnderTest - .getShort(2)); + assertEquals("single get failed: ", sourceData[2], saUnderTest + .getShort(2)); - // test conversion - int[] extractedFromSafeArrayInt = saUnderTest.toIntArray(); - for (int i = 0; i < extractedFromSafeArray.length; i++) { - assertEquals("" + i, sourceData[i], extractedFromSafeArrayInt[i]); - } - // test conversion - double[] extractedFromSafeArrayDouble = saUnderTest.toDoubleArray(); - for (int i = 0; i < extractedFromSafeArrayDouble.length; i++) { - assertEquals("" + i, new Double(sourceData[i]).doubleValue(), - extractedFromSafeArrayDouble[i]); - } - // test conversion - Variant extractedFromSafeArrayVariant[] = saUnderTest.toVariantArray(); - for (int i = 0; i < extractedFromSafeArrayVariant.length; i++) { - assertEquals("" + i, sourceData[i], - extractedFromSafeArrayVariant[i].getShort()); - } - } + // test conversion + int[] extractedFromSafeArrayInt = saUnderTest.toIntArray(); + for (int i = 0; i < extractedFromSafeArray.length; i++) { + assertEquals("" + i, sourceData[i], extractedFromSafeArrayInt[i]); + } + // test conversion + double[] extractedFromSafeArrayDouble = saUnderTest.toDoubleArray(); + for (int i = 0; i < extractedFromSafeArrayDouble.length; i++) { + assertEquals("" + i, new Double(sourceData[i]).doubleValue(), + extractedFromSafeArrayDouble[i]); + } + // test conversion + Variant extractedFromSafeArrayVariant[] = saUnderTest.toVariantArray(); + for (int i = 0; i < extractedFromSafeArrayVariant.length; i++) { + assertEquals("" + i, sourceData[i], + extractedFromSafeArrayVariant[i].getShort()); + } + } - /** - * - */ - public void testIntSafeArray() { - int sourceData[] = new int[] { 100000, 200000, 300000 }; - SafeArray saUnderTest = new SafeArray(Variant.VariantVariant, 3); - saUnderTest.fromIntArray(sourceData); - int[] extractedFromSafeArray = saUnderTest.toIntArray(); - for (int i = 0; i < extractedFromSafeArray.length; i++) { - assertEquals("" + i, sourceData[i], extractedFromSafeArray[i]); - } - assertEquals("single get failed: ", sourceData[2], saUnderTest - .getInt(2)); + /** + * + */ + public void testIntSafeArray() { + int sourceData[] = new int[] { 100000, 200000, 300000 }; + SafeArray saUnderTest = new SafeArray(Variant.VariantVariant, 3); + saUnderTest.fromIntArray(sourceData); + int[] extractedFromSafeArray = saUnderTest.toIntArray(); + for (int i = 0; i < extractedFromSafeArray.length; i++) { + assertEquals("" + i, sourceData[i], extractedFromSafeArray[i]); + } + assertEquals("single get failed: ", sourceData[2], saUnderTest + .getInt(2)); - } + } - /** - * - */ - public void testLongSafeArrayVariantVariant() { - long sourceData[] = new long[] { 2L << 40, 3L << 41, 4L << 42 }; - SafeArray saUnderTest = new SafeArray(Variant.VariantVariant, - sourceData.length); - saUnderTest.fromLongArray(sourceData); - long[] extractedFromSafeArray = saUnderTest.toLongArray(); - assertEquals(sourceData.length, extractedFromSafeArray.length); - for (int i = 0; i < extractedFromSafeArray.length; i++) { - assertEquals("failed on index " + i, sourceData[i], - extractedFromSafeArray[i]); - } - assertEquals("single get failed: ", sourceData[2], saUnderTest - .getLong(2)); + /** + * + */ + public void testLongSafeArrayVariantVariant() { + long sourceData[] = new long[] { 2L << 40, 3L << 41, 4L << 42 }; + SafeArray saUnderTest = new SafeArray(Variant.VariantVariant, + sourceData.length); + saUnderTest.fromLongArray(sourceData); + long[] extractedFromSafeArray = saUnderTest.toLongArray(); + assertEquals(sourceData.length, extractedFromSafeArray.length); + for (int i = 0; i < extractedFromSafeArray.length; i++) { + assertEquals("failed on index " + i, sourceData[i], + extractedFromSafeArray[i]); + } + assertEquals("single get failed: ", sourceData[2], saUnderTest + .getLong(2)); - } + } - /** - * - */ - public void testLongSafeArrayVariantLongInt() { - long sourceData[] = new long[] { 2L << 40, 3L << 41, 4L << 42 }; - SafeArray saUnderTest = new SafeArray(Variant.VariantLongInt, - sourceData.length); - saUnderTest.fromLongArray(sourceData); - long[] extractedFromSafeArray = saUnderTest.toLongArray(); - assertEquals(sourceData.length, extractedFromSafeArray.length); - for (int i = 0; i < extractedFromSafeArray.length; i++) { - assertEquals("failed on index " + i, sourceData[i], - extractedFromSafeArray[i]); - } - assertEquals("single get failed: ", sourceData[2], saUnderTest - .getLong(2)); + /** + * + */ + public void testLongSafeArrayVariantLongInt() { + long sourceData[] = new long[] { 2L << 40, 3L << 41, 4L << 42 }; + SafeArray saUnderTest = new SafeArray(Variant.VariantLongInt, + sourceData.length); + saUnderTest.fromLongArray(sourceData); + long[] extractedFromSafeArray = saUnderTest.toLongArray(); + assertEquals(sourceData.length, extractedFromSafeArray.length); + for (int i = 0; i < extractedFromSafeArray.length; i++) { + assertEquals("failed on index " + i, sourceData[i], + extractedFromSafeArray[i]); + } + assertEquals("single get failed: ", sourceData[2], saUnderTest + .getLong(2)); - } + } - /** - * - */ - public void testDoubleSafeArrayVariantVariant() { - double sourceData[] = new double[] { 1.5, 2.5, 3.5 }; - SafeArray saUnderTest = new SafeArray(Variant.VariantVariant, - sourceData.length); - saUnderTest.fromDoubleArray(sourceData); - double[] extractedFromSafeArray = saUnderTest.toDoubleArray(); - for (int i = 0; i < extractedFromSafeArray.length; i++) { - assertEquals("" + i, sourceData[i], extractedFromSafeArray[i]); - } - assertEquals("single get failed: ", sourceData[2], saUnderTest - .getDouble(2)); + /** + * + */ + public void testDoubleSafeArrayVariantVariant() { + double sourceData[] = new double[] { 1.5, 2.5, 3.5 }; + SafeArray saUnderTest = new SafeArray(Variant.VariantVariant, + sourceData.length); + saUnderTest.fromDoubleArray(sourceData); + double[] extractedFromSafeArray = saUnderTest.toDoubleArray(); + for (int i = 0; i < extractedFromSafeArray.length; i++) { + assertEquals("" + i, sourceData[i], extractedFromSafeArray[i]); + } + assertEquals("single get failed: ", sourceData[2], saUnderTest + .getDouble(2)); - } + } - /** - * - */ - public void testDoubleSafeArrayVariantDouble() { - double sourceData[] = new double[] { 1.5, 2.5, 3.5 }; - SafeArray saUnderTest = new SafeArray(Variant.VariantDouble, - sourceData.length); - saUnderTest.fromDoubleArray(sourceData); - double[] extractedFromSafeArray = saUnderTest.toDoubleArray(); - for (int i = 0; i < extractedFromSafeArray.length; i++) { - assertEquals("" + i, sourceData[i], extractedFromSafeArray[i]); - } - assertEquals("single get failed: ", sourceData[2], saUnderTest - .getDouble(2)); + /** + * + */ + public void testDoubleSafeArrayVariantDouble() { + double sourceData[] = new double[] { 1.5, 2.5, 3.5 }; + SafeArray saUnderTest = new SafeArray(Variant.VariantDouble, + sourceData.length); + saUnderTest.fromDoubleArray(sourceData); + double[] extractedFromSafeArray = saUnderTest.toDoubleArray(); + for (int i = 0; i < extractedFromSafeArray.length; i++) { + assertEquals("" + i, sourceData[i], extractedFromSafeArray[i]); + } + assertEquals("single get failed: ", sourceData[2], saUnderTest + .getDouble(2)); - } + } - /** - * - */ - public void testFloatSafeArray() { - float sourceData[] = new float[] { 1.5F, 2.5F, 3.5F }; - SafeArray saUnderTest = new SafeArray(Variant.VariantVariant, 3); - saUnderTest.fromFloatArray(sourceData); - float[] extractedFromSafeArray = saUnderTest.toFloatArray(); - for (int i = 0; i < extractedFromSafeArray.length; i++) { - assertEquals("" + i, sourceData[i], extractedFromSafeArray[i]); - } - } + /** + * + */ + public void testFloatSafeArray() { + float sourceData[] = new float[] { 1.5F, 2.5F, 3.5F }; + SafeArray saUnderTest = new SafeArray(Variant.VariantVariant, 3); + saUnderTest.fromFloatArray(sourceData); + float[] extractedFromSafeArray = saUnderTest.toFloatArray(); + for (int i = 0; i < extractedFromSafeArray.length; i++) { + assertEquals("" + i, sourceData[i], extractedFromSafeArray[i]); + } + } - /** - * - */ - public void testBooleanSafeArray() { - boolean sourceData[] = new boolean[] { true, false, true, false }; - SafeArray saUnderTest = new SafeArray(Variant.VariantVariant, 3); - saUnderTest.fromBooleanArray(sourceData); - boolean[] extractedFromSafeArray = saUnderTest.toBooleanArray(); - for (int i = 0; i < extractedFromSafeArray.length; i++) { - assertEquals("" + i, sourceData[i], extractedFromSafeArray[i]); - } - assertEquals("single get failed: ", sourceData[2], saUnderTest - .getBoolean(2)); + /** + * + */ + public void testBooleanSafeArray() { + boolean sourceData[] = new boolean[] { true, false, true, false }; + SafeArray saUnderTest = new SafeArray(Variant.VariantVariant, 3); + saUnderTest.fromBooleanArray(sourceData); + boolean[] extractedFromSafeArray = saUnderTest.toBooleanArray(); + for (int i = 0; i < extractedFromSafeArray.length; i++) { + assertEquals("" + i, sourceData[i], extractedFromSafeArray[i]); + } + assertEquals("single get failed: ", sourceData[2], saUnderTest + .getBoolean(2)); - // test conversion - Variant extractedFromSafeArrayVariant[] = saUnderTest.toVariantArray(); - for (int i = 0; i < extractedFromSafeArrayVariant.length; i++) { - assertEquals("" + i, sourceData[i], - extractedFromSafeArrayVariant[i].getBoolean()); - } - } + // test conversion + Variant extractedFromSafeArrayVariant[] = saUnderTest.toVariantArray(); + for (int i = 0; i < extractedFromSafeArrayVariant.length; i++) { + assertEquals("" + i, sourceData[i], + extractedFromSafeArrayVariant[i].getBoolean()); + } + } - /** - * - */ - public void testCharSafeArray() { - char sourceData[] = new char[] { 'a', 'b', 'c', 'd' }; - SafeArray saUnderTest = new SafeArray(Variant.VariantVariant, 3); - saUnderTest.fromCharArray(sourceData); - char[] extractedFromSafeArray = saUnderTest.toCharArray(); - for (int i = 0; i < extractedFromSafeArray.length; i++) { - assertEquals("" + i, sourceData[i], extractedFromSafeArray[i]); - } - assertEquals("single get failed: ", sourceData[2], saUnderTest - .getChar(2)); + /** + * + */ + public void testCharSafeArray() { + char sourceData[] = new char[] { 'a', 'b', 'c', 'd' }; + SafeArray saUnderTest = new SafeArray(Variant.VariantVariant, 3); + saUnderTest.fromCharArray(sourceData); + char[] extractedFromSafeArray = saUnderTest.toCharArray(); + for (int i = 0; i < extractedFromSafeArray.length; i++) { + assertEquals("" + i, sourceData[i], extractedFromSafeArray[i]); + } + assertEquals("single get failed: ", sourceData[2], saUnderTest + .getChar(2)); - } + } - /** - * - */ - public void testStringSafeArray() { - String sourceData[] = new String[] { "hello", "from", "java", "com" }; - SafeArray saUnderTest = new SafeArray(Variant.VariantVariant, 3); - saUnderTest.fromStringArray(sourceData); - String[] extractedFromSafeArray = saUnderTest.toStringArray(); - for (int i = 0; i < extractedFromSafeArray.length; i++) { - assertEquals("" + i, sourceData[i], extractedFromSafeArray[i]); - } - assertEquals("single get failed: ", sourceData[2], saUnderTest - .getString(2)); + /** + * + */ + public void testStringSafeArray() { + String sourceData[] = new String[] { "hello", "from", "java", "com" }; + SafeArray saUnderTest = new SafeArray(Variant.VariantVariant, 3); + saUnderTest.fromStringArray(sourceData); + String[] extractedFromSafeArray = saUnderTest.toStringArray(); + for (int i = 0; i < extractedFromSafeArray.length; i++) { + assertEquals("" + i, sourceData[i], extractedFromSafeArray[i]); + } + assertEquals("single get failed: ", sourceData[2], saUnderTest + .getString(2)); - // test conversion - Variant extractedFromSafeArrayVariant[] = saUnderTest.toVariantArray(); - for (int i = 0; i < extractedFromSafeArrayVariant.length; i++) { - assertEquals("" + i, sourceData[i], - extractedFromSafeArrayVariant[i].getString()); - } - } + // test conversion + Variant extractedFromSafeArrayVariant[] = saUnderTest.toVariantArray(); + for (int i = 0; i < extractedFromSafeArrayVariant.length; i++) { + assertEquals("" + i, sourceData[i], + extractedFromSafeArrayVariant[i].getString()); + } + } - /** - * Verify we get expected unicode this test forces this file to UTF-16 :-( - * SF 2847577 - * - *

      -	 * 	 The console output will be the following without unicode support:
      -	 * 	 Russian: � уÑ�Ñ��º�¸�¹
      -	 * 		
      -	 * 	 Expected:
      -	 * 	 Russian: РуÑ?Ñ?кий
      -	 *
      - */ - public void testStringUnicode() { - SafeArray sa = new SafeArray(Variant.VariantString, 1); - sa.setString(0, "Russian: \u0420\u0443\u0441\u0441\u043A\u0438\u0439"); - String result = sa.getString(0); - Assert.assertEquals("Russian: РуÑ?Ñ?кий", result); - // System.out.println(sa.getString(0)); - } + /** + * Verify we get expected unicode this test forces this file to UTF-16 :-( + * SF 2847577 + * + *
      +     *      The console output will be the following without unicode support:
      +     *      Russian: � уÑ�Ñ��º�¸�¹
      +     *         
      +     *      Expected:
      +     *      Russian: РуÑ?Ñ?кий
      +     *
      + */ + public void testStringUnicode() { + SafeArray sa = new SafeArray(Variant.VariantString, 1); + sa.setString(0, "Russian: \u0420\u0443\u0441\u0441\u043A\u0438\u0439"); + String result = sa.getString(0); + Assert.assertEquals("Russian: РуÑ?Ñ?кий", result); + // System.out.println(sa.getString(0)); + } - /** - * - */ - public void testVariantSafeArray() { - Variant sourceData[] = new Variant[] { new Variant(1), - new Variant(2.3), new Variant("hi") }; + /** + * + */ + public void testVariantSafeArray() { + Variant sourceData[] = new Variant[] { new Variant(1), + new Variant(2.3), new Variant("hi") }; - SafeArray saUnderTest = new SafeArray(Variant.VariantVariant, 3); - saUnderTest.fromVariantArray(sourceData); - Variant[] extractedFromSafeArray = saUnderTest.toVariantArray(); - for (int i = 0; i < extractedFromSafeArray.length; i++) { - assertEquals("" + i, sourceData[i].toString(), - extractedFromSafeArray[i].toString()); - } - assertEquals("single get failed: ", sourceData[2].toString(), - saUnderTest.getVariant(2).toString()); + SafeArray saUnderTest = new SafeArray(Variant.VariantVariant, 3); + saUnderTest.fromVariantArray(sourceData); + Variant[] extractedFromSafeArray = saUnderTest.toVariantArray(); + for (int i = 0; i < extractedFromSafeArray.length; i++) { + assertEquals("" + i, sourceData[i].toString(), + extractedFromSafeArray[i].toString()); + } + assertEquals("single get failed: ", sourceData[2].toString(), + saUnderTest.getVariant(2).toString()); - } + } - /** - * test method that verifies setting of bounds in multi-dimensional arrays - */ - public void testSafeArrayNumDimensions() { - int[] lowerBounds = new int[] { 0, 0, 0 }; - int[] dimensionSizes = new int[] { 3, 3, 3 }; + /** + * test method that verifies setting of bounds in multi-dimensional arrays + */ + public void testSafeArrayNumDimensions() { + int[] lowerBounds = new int[] { 0, 0, 0 }; + int[] dimensionSizes = new int[] { 3, 3, 3 }; - SafeArray sa3x3 = new SafeArray(Variant.VariantVariant, lowerBounds, - dimensionSizes); + SafeArray sa3x3 = new SafeArray(Variant.VariantVariant, lowerBounds, + dimensionSizes); - Assert.assertEquals(3, sa3x3.getNumDim()); - // System.out.println("Num Dimensions = " + sa3x3.getNumDim()); - for (int safeArrayDimension = 1; safeArrayDimension <= sa3x3 - .getNumDim(); safeArrayDimension++) { - int configArrayIndex = safeArrayDimension - 1; - assertEquals("unexpected lower bound value ", - lowerBounds[configArrayIndex], sa3x3 - .getLBound(safeArrayDimension)); - assertEquals("unexpeced upper bound value ", - (dimensionSizes[configArrayIndex] - 1) - + lowerBounds[configArrayIndex], sa3x3 - .getUBound(safeArrayDimension)); - } - } + Assert.assertEquals(3, sa3x3.getNumDim()); + // System.out.println("Num Dimensions = " + sa3x3.getNumDim()); + for (int safeArrayDimension = 1; safeArrayDimension <= sa3x3 + .getNumDim(); safeArrayDimension++) { + int configArrayIndex = safeArrayDimension - 1; + assertEquals("unexpected lower bound value ", + lowerBounds[configArrayIndex], sa3x3 + .getLBound(safeArrayDimension)); + assertEquals("unexpeced upper bound value ", + (dimensionSizes[configArrayIndex] - 1) + + lowerBounds[configArrayIndex], sa3x3 + .getUBound(safeArrayDimension)); + } + } - /** - * test the set and get method on multi-dimensional arrays - */ - public void testSafeArrayMultiDimension() { + /** + * test the set and get method on multi-dimensional arrays + */ + public void testSafeArrayMultiDimension() { - int[] lowerBounds = new int[] { 0, 0, 0 }; - int[] dimensionSizes = new int[] { 3, 3, 3 }; + int[] lowerBounds = new int[] { 0, 0, 0 }; + int[] dimensionSizes = new int[] { 3, 3, 3 }; - SafeArray sa3x3 = new SafeArray(Variant.VariantVariant, lowerBounds, - dimensionSizes); - int[] indices = new int[] { 0, 0, 0 }; + SafeArray sa3x3 = new SafeArray(Variant.VariantVariant, lowerBounds, + dimensionSizes); + int[] indices = new int[] { 0, 0, 0 }; - for (int i = 0; i < 3; i++) { - indices[0] = i; - for (int j = 0; j < 3; j++) { - indices[1] = j; - for (int k = 0; k < 3; k++) { - indices[2] = k; + for (int i = 0; i < 3; i++) { + indices[0] = i; + for (int j = 0; j < 3; j++) { + indices[1] = j; + for (int k = 0; k < 3; k++) { + indices[2] = k; - int fill = 0; - fill = i * 100 + j * 10 + k; - sa3x3.setInt(indices, fill); - assertEquals(fill, sa3x3.getInt(indices)); + int fill = 0; + fill = i * 100 + j * 10 + k; + sa3x3.setInt(indices, fill); + assertEquals(fill, sa3x3.getInt(indices)); - long fillLong = 0L; - // Pick a number bigger than 2^31 - fillLong = 100000000000000L * fill; - sa3x3.setLong(indices, fillLong); - assertEquals(fillLong, sa3x3.getLong(indices)); - } - } - } - } + long fillLong = 0L; + // Pick a number bigger than 2^31 + fillLong = 100000000000000L * fill; + sa3x3.setLong(indices, fillLong); + assertEquals(fillLong, sa3x3.getLong(indices)); + } + } + } + } } diff --git a/src/test/java/com/jacob/test/safearray/SafeArrayContents.java b/src/test/java/com/jacob/test/safearray/SafeArrayContents.java index e87a71b..2f81c10 100644 --- a/src/test/java/com/jacob/test/safearray/SafeArrayContents.java +++ b/src/test/java/com/jacob/test/safearray/SafeArrayContents.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.test.safearray; @@ -53,259 +53,259 @@ import com.jacob.test.BaseTestCase; */ public class SafeArrayContents extends BaseTestCase { - public static void printArray(boolean a[]) { - System.out.print("["); - for (int i = 0; i < a.length; i++) { - System.out.print(" " + a[i] + " "); - } - System.out.println("]"); - } + public static void printArray(boolean a[]) { + System.out.print("["); + for (int i = 0; i < a.length; i++) { + System.out.print(" " + a[i] + " "); + } + System.out.println("]"); + } - public static void printArray(int a[]) { - System.out.print("["); - for (int i = 0; i < a.length; i++) { - System.out.print(" " + a[i] + " "); - } - System.out.println("]"); - } + public static void printArray(int a[]) { + System.out.print("["); + for (int i = 0; i < a.length; i++) { + System.out.print(" " + a[i] + " "); + } + System.out.println("]"); + } - public static void printArray(short a[]) { - System.out.print("["); - for (int i = 0; i < a.length; i++) { - System.out.print(" " + a[i] + " "); - } - System.out.println("]"); - } + public static void printArray(short a[]) { + System.out.print("["); + for (int i = 0; i < a.length; i++) { + System.out.print(" " + a[i] + " "); + } + System.out.println("]"); + } - public static void printArray(byte a[]) { - System.out.print("["); - for (int i = 0; i < a.length; i++) { - System.out.print(" " + a[i] + " "); - } - System.out.println("]"); - } + public static void printArray(byte a[]) { + System.out.print("["); + for (int i = 0; i < a.length; i++) { + System.out.print(" " + a[i] + " "); + } + System.out.println("]"); + } - public static void printArray(double a[]) { - System.out.print("["); - for (int i = 0; i < a.length; i++) { - System.out.print(" " + a[i] + " "); - } - System.out.println("]"); - } + public static void printArray(double a[]) { + System.out.print("["); + for (int i = 0; i < a.length; i++) { + System.out.print(" " + a[i] + " "); + } + System.out.println("]"); + } - public static void printArray(float a[]) { - System.out.print("["); - for (int i = 0; i < a.length; i++) { - System.out.print(" " + a[i] + " "); - } - System.out.println("]"); - } + public static void printArray(float a[]) { + System.out.print("["); + for (int i = 0; i < a.length; i++) { + System.out.print(" " + a[i] + " "); + } + System.out.println("]"); + } - public static void printArray(String a[]) { - System.out.print("["); - for (int i = 0; i < a.length; i++) { - System.out.print(" " + a[i] + " "); - } - System.out.println("]"); - } + public static void printArray(String a[]) { + System.out.print("["); + for (int i = 0; i < a.length; i++) { + System.out.print(" " + a[i] + " "); + } + System.out.println("]"); + } - public static void printArray(Variant a[]) { - System.out.print("["); - for (int i = 0; i < a.length; i++) { - System.out.print(" " + a[i] + " "); - } - System.out.println("]"); - } + public static void printArray(Variant a[]) { + System.out.print("["); + for (int i = 0; i < a.length; i++) { + System.out.print(" " + a[i] + " "); + } + System.out.println("]"); + } - public static void printArray(char a[]) { - System.out.print("["); - for (int i = 0; i < a.length; i++) { - System.out.print(" " + a[i] + " "); - } - System.out.println("]"); - } + public static void printArray(char a[]) { + System.out.print("["); + for (int i = 0; i < a.length; i++) { + System.out.print(" " + a[i] + " "); + } + System.out.println("]"); + } - public void testSafeArrayContents() { - // int - System.out.println("Int"); - SafeArray ia = new SafeArray(Variant.VariantInt, 4); - System.out.println("elem size:" + ia.getElemSize()); - int iack[] = new int[] { 100000, 200000, 300000, 400000 }; - printArray(iack); - ia.fromIntArray(iack); - iack = ia.toIntArray(); - printArray(iack); + public void testSafeArrayContents() { + // int + System.out.println("Int"); + SafeArray ia = new SafeArray(Variant.VariantInt, 4); + System.out.println("elem size:" + ia.getElemSize()); + int iack[] = new int[] { 100000, 200000, 300000, 400000 }; + printArray(iack); + ia.fromIntArray(iack); + iack = ia.toIntArray(); + printArray(iack); - int i4[] = new int[4]; - ia.getInts(0, 4, i4, 0); - printArray(i4); + int i4[] = new int[4]; + ia.getInts(0, 4, i4, 0); + printArray(i4); - SafeArray ia2 = new SafeArray(Variant.VariantInt, 4); - ia2.setInts(0, 4, i4, 0); - iack = ia2.toIntArray(); - printArray(iack); + SafeArray ia2 = new SafeArray(Variant.VariantInt, 4); + ia2.setInts(0, 4, i4, 0); + iack = ia2.toIntArray(); + printArray(iack); - // double - System.out.println("Double"); - SafeArray da = new SafeArray(Variant.VariantDouble, 4); - System.out.println("elem size:" + da.getElemSize()); - double dack[] = new double[] { 123.456, 456.123, 1234567.89, 12.3456789 }; - printArray(dack); - da.fromDoubleArray(dack); - dack = da.toDoubleArray(); - printArray(dack); + // double + System.out.println("Double"); + SafeArray da = new SafeArray(Variant.VariantDouble, 4); + System.out.println("elem size:" + da.getElemSize()); + double dack[] = new double[] { 123.456, 456.123, 1234567.89, 12.3456789 }; + printArray(dack); + da.fromDoubleArray(dack); + dack = da.toDoubleArray(); + printArray(dack); - double d4[] = new double[4]; - da.getDoubles(0, 4, d4, 0); - printArray(d4); + double d4[] = new double[4]; + da.getDoubles(0, 4, d4, 0); + printArray(d4); - SafeArray da2 = new SafeArray(Variant.VariantDouble, 4); - da2.setDoubles(0, 4, d4, 0); - dack = da2.toDoubleArray(); - printArray(dack); + SafeArray da2 = new SafeArray(Variant.VariantDouble, 4); + da2.setDoubles(0, 4, d4, 0); + dack = da2.toDoubleArray(); + printArray(dack); - // float - System.out.println("Float"); - SafeArray fa = new SafeArray(Variant.VariantFloat, 4); - System.out.println("elem size:" + fa.getElemSize()); - float fack[] = new float[] { 123.456F, 456.123F, 1234567.89F, - 12.3456789F }; - printArray(fack); - fa.fromFloatArray(fack); - fack = fa.toFloatArray(); - printArray(fack); + // float + System.out.println("Float"); + SafeArray fa = new SafeArray(Variant.VariantFloat, 4); + System.out.println("elem size:" + fa.getElemSize()); + float fack[] = new float[] { 123.456F, 456.123F, 1234567.89F, + 12.3456789F }; + printArray(fack); + fa.fromFloatArray(fack); + fack = fa.toFloatArray(); + printArray(fack); - float f4[] = new float[4]; - fa.getFloats(0, 4, f4, 0); - printArray(f4); + float f4[] = new float[4]; + fa.getFloats(0, 4, f4, 0); + printArray(f4); - SafeArray fa2 = new SafeArray(Variant.VariantFloat, 4); - fa2.setFloats(0, 4, f4, 0); - fack = fa2.toFloatArray(); - printArray(fack); + SafeArray fa2 = new SafeArray(Variant.VariantFloat, 4); + fa2.setFloats(0, 4, f4, 0); + fack = fa2.toFloatArray(); + printArray(fack); - // boolean - System.out.println("Boolean"); - SafeArray ba = new SafeArray(Variant.VariantBoolean, 4); - System.out.println("elem size:" + ba.getElemSize()); - boolean back[] = new boolean[] { true, false, true, false }; - printArray(back); - ba.fromBooleanArray(back); - back = ba.toBooleanArray(); - printArray(back); + // boolean + System.out.println("Boolean"); + SafeArray ba = new SafeArray(Variant.VariantBoolean, 4); + System.out.println("elem size:" + ba.getElemSize()); + boolean back[] = new boolean[] { true, false, true, false }; + printArray(back); + ba.fromBooleanArray(back); + back = ba.toBooleanArray(); + printArray(back); - boolean b4[] = new boolean[4]; - ba.getBooleans(0, 4, b4, 0); - printArray(b4); + boolean b4[] = new boolean[4]; + ba.getBooleans(0, 4, b4, 0); + printArray(b4); - SafeArray ba2 = new SafeArray(Variant.VariantBoolean, 4); - ba2.setBooleans(0, 4, b4, 0); - back = ba2.toBooleanArray(); - printArray(back); + SafeArray ba2 = new SafeArray(Variant.VariantBoolean, 4); + ba2.setBooleans(0, 4, b4, 0); + back = ba2.toBooleanArray(); + printArray(back); - // char - System.out.println("Char"); - SafeArray ca = new SafeArray(Variant.VariantShort, 4); - System.out.println("elem size:" + ca.getElemSize()); - char cack[] = new char[] { 'a', 'b', 'c', 'd' }; - printArray(cack); - ca.fromCharArray(cack); - cack = ca.toCharArray(); - printArray(cack); + // char + System.out.println("Char"); + SafeArray ca = new SafeArray(Variant.VariantShort, 4); + System.out.println("elem size:" + ca.getElemSize()); + char cack[] = new char[] { 'a', 'b', 'c', 'd' }; + printArray(cack); + ca.fromCharArray(cack); + cack = ca.toCharArray(); + printArray(cack); - char c4[] = new char[4]; - ca.getChars(0, 4, c4, 0); - printArray(c4); + char c4[] = new char[4]; + ca.getChars(0, 4, c4, 0); + printArray(c4); - SafeArray ca2 = new SafeArray(Variant.VariantShort, 4); - ca2.setChars(0, 4, c4, 0); - cack = ca2.toCharArray(); - printArray(cack); + SafeArray ca2 = new SafeArray(Variant.VariantShort, 4); + ca2.setChars(0, 4, c4, 0); + cack = ca2.toCharArray(); + printArray(cack); - // short - System.out.println("Short"); - SafeArray sha = new SafeArray(Variant.VariantShort, 4); - System.out.println("elem size:" + sha.getElemSize()); - short shack[] = new short[] { 1000, 2000, 3000, 4000 }; - printArray(shack); - sha.fromShortArray(shack); - shack = sha.toShortArray(); - printArray(shack); + // short + System.out.println("Short"); + SafeArray sha = new SafeArray(Variant.VariantShort, 4); + System.out.println("elem size:" + sha.getElemSize()); + short shack[] = new short[] { 1000, 2000, 3000, 4000 }; + printArray(shack); + sha.fromShortArray(shack); + shack = sha.toShortArray(); + printArray(shack); - short sh4[] = new short[4]; - sha.getShorts(0, 4, sh4, 0); - printArray(sh4); + short sh4[] = new short[4]; + sha.getShorts(0, 4, sh4, 0); + printArray(sh4); - SafeArray sha2 = new SafeArray(Variant.VariantShort, 4); - sha2.setShorts(0, 4, sh4, 0); - shack = sha2.toShortArray(); - printArray(shack); + SafeArray sha2 = new SafeArray(Variant.VariantShort, 4); + sha2.setShorts(0, 4, sh4, 0); + shack = sha2.toShortArray(); + printArray(shack); - // string - System.out.println("String"); - SafeArray sa = new SafeArray(Variant.VariantString, 4); - System.out.println("elem size:" + sa.getElemSize()); - String sack[] = new String[] { "aa", "bb", "cc", "dd" }; - printArray(sack); - sa.fromStringArray(sack); - sack = sa.toStringArray(); - printArray(sack); + // string + System.out.println("String"); + SafeArray sa = new SafeArray(Variant.VariantString, 4); + System.out.println("elem size:" + sa.getElemSize()); + String sack[] = new String[] { "aa", "bb", "cc", "dd" }; + printArray(sack); + sa.fromStringArray(sack); + sack = sa.toStringArray(); + printArray(sack); - String s4[] = new String[4]; - sa.getStrings(0, 4, s4, 0); - printArray(s4); + String s4[] = new String[4]; + sa.getStrings(0, 4, s4, 0); + printArray(s4); - SafeArray sa2 = new SafeArray(Variant.VariantString, 4); - sa2.setStrings(0, 4, s4, 0); - sack = sa2.toStringArray(); - printArray(sack); + SafeArray sa2 = new SafeArray(Variant.VariantString, 4); + sa2.setStrings(0, 4, s4, 0); + sack = sa2.toStringArray(); + printArray(sack); - // variant - System.out.println("Variant"); - SafeArray va = new SafeArray(Variant.VariantVariant, 4); - System.out.println("elem size:" + va.getElemSize()); - Variant vack[] = new Variant[] { new Variant(1), new Variant(2.3), - new Variant(true), new Variant("four"), }; - printArray(vack); - va.fromVariantArray(vack); - vack = va.toVariantArray(); - printArray(vack); + // variant + System.out.println("Variant"); + SafeArray va = new SafeArray(Variant.VariantVariant, 4); + System.out.println("elem size:" + va.getElemSize()); + Variant vack[] = new Variant[] { new Variant(1), new Variant(2.3), + new Variant(true), new Variant("four"), }; + printArray(vack); + va.fromVariantArray(vack); + vack = va.toVariantArray(); + printArray(vack); - Variant v4[] = new Variant[4]; - va.getVariants(0, 4, v4, 0); - printArray(v4); + Variant v4[] = new Variant[4]; + va.getVariants(0, 4, v4, 0); + printArray(v4); - SafeArray va2 = new SafeArray(Variant.VariantVariant, 4); - va2.setVariants(0, 4, v4, 0); - vack = va2.toVariantArray(); - printArray(vack); + SafeArray va2 = new SafeArray(Variant.VariantVariant, 4); + va2.setVariants(0, 4, v4, 0); + vack = va2.toVariantArray(); + printArray(vack); - // byte - System.out.println("Byte"); - SafeArray bba = new SafeArray(Variant.VariantByte, 4); - System.out.println("elem size:" + bba.getElemSize()); - byte bback[] = new byte[] { 0x1, 0x2, 0x3, 0x4 }; - printArray(bback); - bba.fromByteArray(bback); - bback = bba.toByteArray(); - printArray(bback); + // byte + System.out.println("Byte"); + SafeArray bba = new SafeArray(Variant.VariantByte, 4); + System.out.println("elem size:" + bba.getElemSize()); + byte bback[] = new byte[] { 0x1, 0x2, 0x3, 0x4 }; + printArray(bback); + bba.fromByteArray(bback); + bback = bba.toByteArray(); + printArray(bback); - byte bb4[] = new byte[4]; - bba.getBytes(0, 4, bb4, 0); - printArray(bb4); + byte bb4[] = new byte[4]; + bba.getBytes(0, 4, bb4, 0); + printArray(bb4); - SafeArray bba2 = new SafeArray(Variant.VariantByte, 4); - bba2.setBytes(0, 4, bb4, 0); - bback = bba2.toByteArray(); - printArray(bback); + SafeArray bba2 = new SafeArray(Variant.VariantByte, 4); + bba2.setBytes(0, 4, bb4, 0); + bback = bba2.toByteArray(); + printArray(bback); - try { - // this should throw ComException - bba2.fromCharArray(new char[] { 'a' }); - fail("Failed to catch expected exception"); - } catch (ComFailException cfe) { - // do nothing - // cfe.printStackTrace(); - } - } + try { + // this should throw ComException + bba2.fromCharArray(new char[] { 'a' }); + fail("Failed to catch expected exception"); + } catch (ComFailException cfe) { + // do nothing + // cfe.printStackTrace(); + } + } } diff --git a/src/test/java/com/jacob/test/safearray/SafeArrayDispatchTest.java b/src/test/java/com/jacob/test/safearray/SafeArrayDispatchTest.java index 3b3c7d2..aded3e4 100644 --- a/src/test/java/com/jacob/test/safearray/SafeArrayDispatchTest.java +++ b/src/test/java/com/jacob/test/safearray/SafeArrayDispatchTest.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.test.safearray; @@ -49,35 +49,35 @@ import com.jacob.test.BaseTestCase; * Test class to verify dispatch with SafeArray */ public class SafeArrayDispatchTest extends BaseTestCase { - public void testDispatchWithSafeArray() { - try { - String scriptCommand = "1+(2*4)-3"; - String lang = "VBScript"; - ActiveXComponent sControl = new ActiveXComponent("ScriptControl"); - Dispatch.put(sControl, "Language", lang); + public void testDispatchWithSafeArray() { + try { + String scriptCommand = "1+(2*4)-3"; + String lang = "VBScript"; + ActiveXComponent sControl = new ActiveXComponent("ScriptControl"); + Dispatch.put(sControl, "Language", lang); - Variant result = Dispatch.call(sControl, "Eval", scriptCommand); - assertTrue(result.toString().equals("6")); + Variant result = Dispatch.call(sControl, "Eval", scriptCommand); + assertTrue(result.toString().equals("6")); - // wrap the script control in a variant - Variant v = new Variant(sControl); + // wrap the script control in a variant + Variant v = new Variant(sControl); - // create a safe array of type dispatch - SafeArray sa = new SafeArray(Variant.VariantDispatch, 1); + // create a safe array of type dispatch + SafeArray sa = new SafeArray(Variant.VariantDispatch, 1); - // put the variant in the array - sa.setVariant(0, v); + // put the variant in the array + sa.setVariant(0, v); - // take it back out - Variant v2 = sa.getVariant(0); - Dispatch d = v2.toDispatch(); + // take it back out + Variant v2 = sa.getVariant(0); + Dispatch d = v2.toDispatch(); - // make sure you can call eval on it - result = Dispatch.call(d, "Eval", scriptCommand); - assertTrue(result.toString().equals("6")); - } catch (ComException e) { - e.printStackTrace(); - fail("script failure " + e); - } - } + // make sure you can call eval on it + result = Dispatch.call(d, "Eval", scriptCommand); + assertTrue(result.toString().equals("6")); + } catch (ComException e) { + e.printStackTrace(); + fail("script failure " + e); + } + } } diff --git a/src/test/java/com/jacob/test/safearray/SafeArrayLeak.java b/src/test/java/com/jacob/test/safearray/SafeArrayLeak.java index 6ee2bcd..5523b09 100644 --- a/src/test/java/com/jacob/test/safearray/SafeArrayLeak.java +++ b/src/test/java/com/jacob/test/safearray/SafeArrayLeak.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.test.safearray; @@ -59,157 +59,157 @@ import com.jacob.test.BaseTestCase; */ public class SafeArrayLeak extends BaseTestCase { - /** - * ---------------------------------------------------------------------------------------------------------------------------- - * - * ---------------------------------------------------------------------------------------------------------------------------- - */ - public void testLeakWithSetString() { + /** + * ---------------------------------------------------------------------------------------------------------------------------- + * + * ---------------------------------------------------------------------------------------------------------------------------- + */ + public void testLeakWithSetString() { - ActiveXComponent xl = null; - Dispatch workbooks = null; - Dispatch workbook = null; - Dispatch workSheets = null; - Dispatch sheet = null; - Dispatch tabCells = null; - SafeArray sa = null; + ActiveXComponent xl = null; + Dispatch workbooks = null; + Dispatch workbook = null; + Dispatch workSheets = null; + Dispatch sheet = null; + Dispatch tabCells = null; + SafeArray sa = null; - // -Dcom.jacob.autogc=true - System.out.println("Jacob version: " + JacobReleaseInfo.getBuildVersion()); + // -Dcom.jacob.autogc=true + System.out.println("Jacob version: " + JacobReleaseInfo.getBuildVersion()); - for (int t = 0; t < 10; t++) { - // look at a large range of cells - String position = "A7:DM8934"; + for (int t = 0; t < 10; t++) { + // look at a large range of cells + String position = "A7:DM8934"; - try { - xl = new ActiveXComponent("Excel.Application"); - System.out - .println("Excel version=" + xl.getProperty("Version")); + try { + xl = new ActiveXComponent("Excel.Application"); + System.out + .println("Excel version=" + xl.getProperty("Version")); - xl.setProperty("Visible", new Variant(false)); - workbooks = xl.getProperty("Workbooks").toDispatch(); + xl.setProperty("Visible", new Variant(false)); + workbooks = xl.getProperty("Workbooks").toDispatch(); - workbook = Dispatch.get(workbooks, "Add").toDispatch(); + workbook = Dispatch.get(workbooks, "Add").toDispatch(); - workSheets = Dispatch.get(workbook, "Worksheets").toDispatch(); + workSheets = Dispatch.get(workbook, "Worksheets").toDispatch(); - sheet = Dispatch.get(workbook, "ActiveSheet").toDispatch(); - // grab the whole range specified above. - tabCells = Dispatch.invoke(sheet, "Range", Dispatch.Get, - new Object[] { position }, new int[1]).toDispatch(); + sheet = Dispatch.get(workbook, "ActiveSheet").toDispatch(); + // grab the whole range specified above. + tabCells = Dispatch.invoke(sheet, "Range", Dispatch.Get, + new Object[] { position }, new int[1]).toDispatch(); - sa = Dispatch.get(tabCells, "Value").toSafeArray(true); + sa = Dispatch.get(tabCells, "Value").toSafeArray(true); - System.out.println("Ub0=" + sa.getUBound(1)); // nbCol - System.out.println("Ub1=" + sa.getUBound(2)); // nbLgn + System.out.println("Ub0=" + sa.getUBound(1)); // nbCol + System.out.println("Ub1=" + sa.getUBound(2)); // nbLgn - // number of rows - int nbLgn = sa.getUBound(2); - // number of columns - int nbCol = sa.getUBound(1); + // number of rows + int nbLgn = sa.getUBound(2); + // number of columns + int nbCol = sa.getUBound(1); - int[] colLgn = new int[] { 0, 0 }; + int[] colLgn = new int[] { 0, 0 }; - // now set a value on every cell in the range we retrieved - for (int i = 1; i <= nbLgn; i++) { - colLgn[1] = i; + // now set a value on every cell in the range we retrieved + for (int i = 1; i <= nbLgn; i++) { + colLgn[1] = i; - for (int j = 1; j <= nbCol; j++) { - colLgn[0] = j; - // this one works with out a leak 1.13-M3 - // sa.setString(j, i, "test"); - // This one leaks with 1.13-M3 and earlier - sa.setString(colLgn, "test"); - } - } + for (int j = 1; j <= nbCol; j++) { + colLgn[0] = j; + // this one works with out a leak 1.13-M3 + // sa.setString(j, i, "test"); + // This one leaks with 1.13-M3 and earlier + sa.setString(colLgn, "test"); + } + } - Dispatch.put(tabCells, "Value", sa); + Dispatch.put(tabCells, "Value", sa); - Variant f = new Variant(false); - Dispatch.call(workbook, "Close", f); - System.out.println("Close"); - } catch (Exception e) { - e.printStackTrace(); - } finally { + Variant f = new Variant(false); + Dispatch.call(workbook, "Close", f); + System.out.println("Close"); + } catch (Exception e) { + e.printStackTrace(); + } finally { - if (sa != null) { - try { - sa.safeRelease(); - } catch (Exception e) { - e.printStackTrace(); - } finally { - sa = null; - } - } + if (sa != null) { + try { + sa.safeRelease(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + sa = null; + } + } - if (tabCells != null) { - try { - tabCells.safeRelease(); - } catch (Exception e) { - e.printStackTrace(); - } finally { - tabCells = null; - } - } + if (tabCells != null) { + try { + tabCells.safeRelease(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + tabCells = null; + } + } - if (sheet != null) { - try { - sheet.safeRelease(); - } catch (Exception e) { - e.printStackTrace(); - } finally { - sheet = null; - } - } + if (sheet != null) { + try { + sheet.safeRelease(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + sheet = null; + } + } - if (workSheets != null) { - try { - workSheets.safeRelease(); - } catch (Exception e) { - e.printStackTrace(); - } finally { - workSheets = null; - } - } + if (workSheets != null) { + try { + workSheets.safeRelease(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + workSheets = null; + } + } - if (workbook != null) { - try { - workbook.safeRelease(); - } catch (Exception e) { - e.printStackTrace(); - } finally { - workbook = null; - } - } + if (workbook != null) { + try { + workbook.safeRelease(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + workbook = null; + } + } - if (workbooks != null) { - try { - workbooks.safeRelease(); - } catch (Exception e) { - e.printStackTrace(); - } finally { - workbooks = null; - } - } + if (workbooks != null) { + try { + workbooks.safeRelease(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + workbooks = null; + } + } - if (xl != null) { - try { - xl.invoke("Quit", new Variant[] {}); - } catch (Exception e) { - e.printStackTrace(); - } + if (xl != null) { + try { + xl.invoke("Quit", new Variant[] {}); + } catch (Exception e) { + e.printStackTrace(); + } - try { - xl.safeRelease(); - } catch (Exception e) { - e.printStackTrace(); - } finally { - xl = null; - } - } + try { + xl.safeRelease(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + xl = null; + } + } - ComThread.Release(); - } - } - } + ComThread.Release(); + } + } + } } diff --git a/src/test/java/com/jacob/test/safearray/SafeArrayReleaseTest.java b/src/test/java/com/jacob/test/safearray/SafeArrayReleaseTest.java index 204ac10..cf90afe 100644 --- a/src/test/java/com/jacob/test/safearray/SafeArrayReleaseTest.java +++ b/src/test/java/com/jacob/test/safearray/SafeArrayReleaseTest.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.test.safearray; @@ -91,37 +91,37 @@ import com.jacob.test.BaseTestCase; */ public class SafeArrayReleaseTest extends BaseTestCase { - final static int MAX = 300; + final static int MAX = 300; - /** - * verifies the release works on SafeArray - */ - public void testSaveArrayRelease() { - int count; - System.out.println("Starting test for max = " + MAX); - for (count = 1; count < MAX; count++) { - int i = 0; - try { - ComThread.InitMTA(); - for (i = 0; i < count; i++) { - SafeArray a1 = new SafeArray(Variant.VariantVariant, 2); - a1.setVariant(0, new Variant("foo")); - a1.setVariant(1, new Variant("bar")); - Variant v = new Variant(a1); - SafeArray a2 = v.toSafeArray(true); - if (a2 == null) { - System.out.println("got null back from toSafeArray()"); - } - } - ComThread.Release(); - System.gc(); - // System.out.print("."); - } catch (Exception e) { - fail("Test fails with i = " + i + " (max = " + MAX + ")"); - } - } - System.gc(); - System.out.println("\nTest ends with count = " + count + " (max = " - + MAX + ")"); - } + /** + * verifies the release works on SafeArray + */ + public void testSaveArrayRelease() { + int count; + System.out.println("Starting test for max = " + MAX); + for (count = 1; count < MAX; count++) { + int i = 0; + try { + ComThread.InitMTA(); + for (i = 0; i < count; i++) { + SafeArray a1 = new SafeArray(Variant.VariantVariant, 2); + a1.setVariant(0, new Variant("foo")); + a1.setVariant(1, new Variant("bar")); + Variant v = new Variant(a1); + SafeArray a2 = v.toSafeArray(true); + if (a2 == null) { + System.out.println("got null back from toSafeArray()"); + } + } + ComThread.Release(); + System.gc(); + // System.out.print("."); + } catch (Exception e) { + fail("Test fails with i = " + i + " (max = " + MAX + ")"); + } + } + System.gc(); + System.out.println("\nTest ends with count = " + count + " (max = " + + MAX + ")"); + } } \ No newline at end of file diff --git a/src/test/java/com/jacob/test/safearray/SafeArrayStringConstructorTest.java b/src/test/java/com/jacob/test/safearray/SafeArrayStringConstructorTest.java index d7ca984..ac7e4d1 100644 --- a/src/test/java/com/jacob/test/safearray/SafeArrayStringConstructorTest.java +++ b/src/test/java/com/jacob/test/safearray/SafeArrayStringConstructorTest.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.test.safearray; @@ -51,12 +51,12 @@ import com.jacob.test.BaseTestCase; * from Java chars, which are 16-bit unsigned integers (which would be VT_UI2). */ public class SafeArrayStringConstructorTest extends BaseTestCase { - public void testStringConstructor() { - // The line below will throw ComFailException using jacob 1.17-M2 - // without the patch. - SafeArray safeArrayFromString = new SafeArray("This is a string."); - String convertBack = safeArrayFromString.asString(); - assertEquals("This is a string.", convertBack); - } + public void testStringConstructor() { + // The line below will throw ComFailException using jacob 1.17-M2 + // without the patch. + SafeArray safeArrayFromString = new SafeArray("This is a string."); + String convertBack = safeArrayFromString.asString(); + assertEquals("This is a string.", convertBack); + } } diff --git a/src/test/java/com/jacob/test/safearray/SafeArrayViaExcel.java b/src/test/java/com/jacob/test/safearray/SafeArrayViaExcel.java index 44c12e7..12a0a05 100644 --- a/src/test/java/com/jacob/test/safearray/SafeArrayViaExcel.java +++ b/src/test/java/com/jacob/test/safearray/SafeArrayViaExcel.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.test.safearray; @@ -55,59 +55,59 @@ import com.jacob.test.BaseTestCase; */ public class SafeArrayViaExcel extends BaseTestCase { - /** - * verify safe arrays work with standard applications, Excel in this case - */ - public void testSafeArrayViaExcel() { + /** + * verify safe arrays work with standard applications, Excel in this case + */ + public void testSafeArrayViaExcel() { - ActiveXComponent xl = new ActiveXComponent("Excel.Application"); - try { - Dispatch cell; - SafeArray sAProdText; - Dispatch workbooks = xl.getProperty("Workbooks").toDispatch(); - System.out.println("have workbooks"); - Dispatch workbook = Dispatch.call( - workbooks, - "Open", - getWindowsFilePathToPackageResource( - "SafeArrayViaExcel.xls", this.getClass())) - .toDispatch(); - System.out.println("Opened File - SafeArrayViaExcel.xls\n"); - Dispatch sheet = Dispatch.get(workbook, "ActiveSheet").toDispatch(); - cell = Dispatch.invoke(sheet, "Range", Dispatch.Get, - new Object[] { "A1:D1000" }, new int[1]).toDispatch(); - System.out.println("have cell:" + cell); - sAProdText = Dispatch.get(cell, "Value").toSafeArray(); - System.out.println("sa: dim=" + sAProdText.getNumDim()); - System.out.println("sa: start row=" + sAProdText.getLBound(1)); - System.out.println("sa: start col=" + sAProdText.getLBound(2)); - System.out.println("sa: end row=" + sAProdText.getUBound(1)); - System.out.println("sa: end col=" + sAProdText.getUBound(2)); - int i; - int lineNumber = 1; - int n = 0; - for (lineNumber = 1; lineNumber < 1000; lineNumber++) { - for (i = 1; i < 4; i++) { - System.out.println((n++) + " " + lineNumber + " " + i + " " - + sAProdText.getString(lineNumber, i)); - /* - * if (sAProdText.getString(lineNumber,i).compareTo("aaaa") != - * 0 ) { System.out.println("Invalid String in line " + - * lineNumber + " Cell " + i + " Value = " + - * sAProdText.getString(lineNumber,i)); stringFound = false; } } - * if (stringFound) { System.out.println("Valid Strings in - * line " + lineNumber); lineNumber++; } - */ - } - } + ActiveXComponent xl = new ActiveXComponent("Excel.Application"); + try { + Dispatch cell; + SafeArray sAProdText; + Dispatch workbooks = xl.getProperty("Workbooks").toDispatch(); + System.out.println("have workbooks"); + Dispatch workbook = Dispatch.call( + workbooks, + "Open", + getWindowsFilePathToPackageResource( + "SafeArrayViaExcel.xls", this.getClass())) + .toDispatch(); + System.out.println("Opened File - SafeArrayViaExcel.xls\n"); + Dispatch sheet = Dispatch.get(workbook, "ActiveSheet").toDispatch(); + cell = Dispatch.invoke(sheet, "Range", Dispatch.Get, + new Object[] { "A1:D1000" }, new int[1]).toDispatch(); + System.out.println("have cell:" + cell); + sAProdText = Dispatch.get(cell, "Value").toSafeArray(); + System.out.println("sa: dim=" + sAProdText.getNumDim()); + System.out.println("sa: start row=" + sAProdText.getLBound(1)); + System.out.println("sa: start col=" + sAProdText.getLBound(2)); + System.out.println("sa: end row=" + sAProdText.getUBound(1)); + System.out.println("sa: end col=" + sAProdText.getUBound(2)); + int i; + int lineNumber = 1; + int n = 0; + for (lineNumber = 1; lineNumber < 1000; lineNumber++) { + for (i = 1; i < 4; i++) { + System.out.println((n++) + " " + lineNumber + " " + i + " " + + sAProdText.getString(lineNumber, i)); + /* + * if (sAProdText.getString(lineNumber,i).compareTo("aaaa") != + * 0 ) { System.out.println("Invalid String in line " + + * lineNumber + " Cell " + i + " Value = " + + * sAProdText.getString(lineNumber,i)); stringFound = false; } } + * if (stringFound) { System.out.println("Valid Strings in + * line " + lineNumber); lineNumber++; } + */ + } + } - Dispatch.call(workbook, "Close"); - System.out.println("Closed File\n"); - } catch (Exception e) { - e.printStackTrace(); - fail("Caught Exception " + e); - } finally { - xl.invoke("Quit", new Variant[] {}); - } - } + Dispatch.call(workbook, "Close"); + System.out.println("Closed File\n"); + } catch (Exception e) { + e.printStackTrace(); + fail("Caught Exception " + e); + } finally { + xl.invoke("Quit", new Variant[] {}); + } + } } diff --git a/src/test/java/com/jacob/test/vbscript/ScriptTest.java b/src/test/java/com/jacob/test/vbscript/ScriptTest.java index fd940ce..6137d80 100644 --- a/src/test/java/com/jacob/test/vbscript/ScriptTest.java +++ b/src/test/java/com/jacob/test/vbscript/ScriptTest.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.test.vbscript; @@ -56,50 +56,50 @@ import com.jacob.test.BaseTestCase; */ public class ScriptTest extends BaseTestCase { - public void testStupidSpeedTest() { - String lang = "VBScript"; - ActiveXComponent sC = new ActiveXComponent("ScriptControl"); - Dispatch sControl = sC.getObject(); - Dispatch.put(sControl, "Language", lang); - for (int i = 0; i < 10000; i++) { - Dispatch.call(sControl, "Eval", "1+1"); - } - } + public void testStupidSpeedTest() { + String lang = "VBScript"; + ActiveXComponent sC = new ActiveXComponent("ScriptControl"); + Dispatch sControl = sC.getObject(); + Dispatch.put(sControl, "Language", lang); + for (int i = 0; i < 10000; i++) { + Dispatch.call(sControl, "Eval", "1+1"); + } + } - public void testCreatingDispatchEvents() { - ComThread.InitSTA(true); - DispatchEvents de = null; - Dispatch sControl = null; + public void testCreatingDispatchEvents() { + ComThread.InitSTA(true); + DispatchEvents de = null; + Dispatch sControl = null; - try { - String scriptCommand = getSampleVPScriptForEval(); - String lang = "VBScript"; - ActiveXComponent sC = new ActiveXComponent("ScriptControl"); - sControl = sC.getObject(); - Dispatch.put(sControl, "Language", lang); - ScriptTestErrEvents te = new ScriptTestErrEvents(); - de = new DispatchEvents(sControl, te); - if (de == null) { - System.out - .println("Received null when trying to create new DispatchEvents"); - } - Variant result = Dispatch.call(sControl, "Eval", scriptCommand); - // call it twice to see the objects reused - result = Dispatch.call(sControl, "Eval", scriptCommand); - // call it 3 times to see the objects reused - result = Dispatch.call(sControl, "Eval", scriptCommand); - System.out.println("eval(" + scriptCommand + ") = " + result); - } catch (ComException e) { - e.printStackTrace(); - fail("Caught Exception " + e); - } finally { - Integer I = null; - for (int i = 1; i < 1000000; i++) { - I = new Integer(i); - } - System.out.println(I); - ComThread.Release(); - ComThread.quitMainSTA(); - } - } + try { + String scriptCommand = getSampleVPScriptForEval(); + String lang = "VBScript"; + ActiveXComponent sC = new ActiveXComponent("ScriptControl"); + sControl = sC.getObject(); + Dispatch.put(sControl, "Language", lang); + ScriptTestErrEvents te = new ScriptTestErrEvents(); + de = new DispatchEvents(sControl, te); + if (de == null) { + System.out + .println("Received null when trying to create new DispatchEvents"); + } + Variant result = Dispatch.call(sControl, "Eval", scriptCommand); + // call it twice to see the objects reused + result = Dispatch.call(sControl, "Eval", scriptCommand); + // call it 3 times to see the objects reused + result = Dispatch.call(sControl, "Eval", scriptCommand); + System.out.println("eval(" + scriptCommand + ") = " + result); + } catch (ComException e) { + e.printStackTrace(); + fail("Caught Exception " + e); + } finally { + Integer I = null; + for (int i = 1; i < 1000000; i++) { + I = new Integer(i); + } + System.out.println(I); + ComThread.Release(); + ComThread.quitMainSTA(); + } + } } diff --git a/src/test/java/com/jacob/test/vbscript/ScriptTest2.java b/src/test/java/com/jacob/test/vbscript/ScriptTest2.java index 0d7fbfe..a9dff93 100644 --- a/src/test/java/com/jacob/test/vbscript/ScriptTest2.java +++ b/src/test/java/com/jacob/test/vbscript/ScriptTest2.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.test.vbscript; @@ -71,73 +71,73 @@ import com.jacob.test.BaseTestCase; */ public class ScriptTest2 extends BaseTestCase { - public void testScript2() { - try { - ComThread.InitSTA(); - ScriptTestSTA script = new ScriptTestSTA(); - try { - Thread.sleep(1000); - } catch (InterruptedException ie) { - // should we get this? - } + public void testScript2() { + try { + ComThread.InitSTA(); + ScriptTestSTA script = new ScriptTestSTA(); + try { + Thread.sleep(1000); + } catch (InterruptedException ie) { + // should we get this? + } - String scriptCommand = getSampleVPScriptForEval(); - // get a thread-local Dispatch from sCon - Dispatch sc = script.sCon.toDispatch(); + String scriptCommand = getSampleVPScriptForEval(); + // get a thread-local Dispatch from sCon + Dispatch sc = script.sCon.toDispatch(); - // call a method on the thread-local Dispatch obtained - // from the DispatchProxy. If you try to make the same - // method call on the sControl object - you will get a - // ComException. - Variant result = Dispatch.call(sc, "Eval", scriptCommand); - System.out.println("eval(" + scriptCommand + ") = " + result); - script.quit(); - System.out.println("called quit"); - } catch (ComException e) { - e.printStackTrace(); - fail("caught exception" + e); - } finally { - Integer I = null; - for (int i = 1; i < 1000000; i++) { - I = new Integer(i); - } - System.out.println(I); - ComThread.Release(); - } - } + // call a method on the thread-local Dispatch obtained + // from the DispatchProxy. If you try to make the same + // method call on the sControl object - you will get a + // ComException. + Variant result = Dispatch.call(sc, "Eval", scriptCommand); + System.out.println("eval(" + scriptCommand + ") = " + result); + script.quit(); + System.out.println("called quit"); + } catch (ComException e) { + e.printStackTrace(); + fail("caught exception" + e); + } finally { + Integer I = null; + for (int i = 1; i < 1000000; i++) { + I = new Integer(i); + } + System.out.println(I); + ComThread.Release(); + } + } - public class ScriptTestSTA extends STA { + public class ScriptTestSTA extends STA { - public DispatchEvents de = null; + public DispatchEvents de = null; - public Dispatch sControl = null; + public Dispatch sControl = null; - public DispatchProxy sCon = null; + public DispatchProxy sCon = null; - public boolean OnInit() { - try { - System.out.println("OnInit"); - System.out.println(Thread.currentThread()); - String lang = "VBScript"; - sControl = new ActiveXComponent("ScriptControl"); + public boolean OnInit() { + try { + System.out.println("OnInit"); + System.out.println(Thread.currentThread()); + String lang = "VBScript"; + sControl = new ActiveXComponent("ScriptControl"); - // sCon can be called from another thread - sCon = new DispatchProxy(sControl); + // sCon can be called from another thread + sCon = new DispatchProxy(sControl); - Dispatch.put(sControl, "Language", lang); - ScriptTestErrEvents te = new ScriptTestErrEvents(); - de = new DispatchEvents(sControl, te); - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } + Dispatch.put(sControl, "Language", lang); + ScriptTestErrEvents te = new ScriptTestErrEvents(); + de = new DispatchEvents(sControl, te); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } - public void OnQuit() { - System.out.println("OnQuit"); - } + public void OnQuit() { + System.out.println("OnQuit"); + } - } + } } diff --git a/src/test/java/com/jacob/test/vbscript/ScriptTest2ActiveX.java b/src/test/java/com/jacob/test/vbscript/ScriptTest2ActiveX.java index a6e6d25..80af111 100644 --- a/src/test/java/com/jacob/test/vbscript/ScriptTest2ActiveX.java +++ b/src/test/java/com/jacob/test/vbscript/ScriptTest2ActiveX.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.test.vbscript; @@ -69,73 +69,73 @@ import com.jacob.test.BaseTestCase; * options. */ public class ScriptTest2ActiveX extends BaseTestCase { - public static ActiveXComponent sC; + public static ActiveXComponent sC; - public static DispatchEvents de = null; + public static DispatchEvents de = null; - public static DispatchProxy sCon = null; + public static DispatchProxy sCon = null; - public void testActiveXSTA() { - try { - ComThread.InitSTA(); - ScriptTest2ActiveXSTA script = new ScriptTest2ActiveXSTA(); - try { - Thread.sleep(1000); - } catch (InterruptedException ie) { - // should we get this? - } + public void testActiveXSTA() { + try { + ComThread.InitSTA(); + ScriptTest2ActiveXSTA script = new ScriptTest2ActiveXSTA(); + try { + Thread.sleep(1000); + } catch (InterruptedException ie) { + // should we get this? + } - // get a thread-local Dispatch from sCon - ActiveXComponent sc = new ActiveXComponent(sCon.toDispatch()); + // get a thread-local Dispatch from sCon + ActiveXComponent sc = new ActiveXComponent(sCon.toDispatch()); - // call a method on the thread-local Dispatch obtained - // from the DispatchProxy. If you try to make the same - // method call on the sControl object - you will get a - // ComException. - String scriptCommand = getSampleVPScriptForEval(); - Variant result = sc.invoke("Eval", scriptCommand); - System.out.println("eval(" + scriptCommand + ") = " + result); - script.quit(); - System.out.println("called quit"); - } catch (ComException e) { - e.printStackTrace(); - fail("blew up with Com Exception " + e); - } finally { - Integer I = null; - for (int i = 1; i < 1000000; i++) { - I = new Integer(i); - } - System.out.println(I); - ComThread.Release(); - } - } + // call a method on the thread-local Dispatch obtained + // from the DispatchProxy. If you try to make the same + // method call on the sControl object - you will get a + // ComException. + String scriptCommand = getSampleVPScriptForEval(); + Variant result = sc.invoke("Eval", scriptCommand); + System.out.println("eval(" + scriptCommand + ") = " + result); + script.quit(); + System.out.println("called quit"); + } catch (ComException e) { + e.printStackTrace(); + fail("blew up with Com Exception " + e); + } finally { + Integer I = null; + for (int i = 1; i < 1000000; i++) { + I = new Integer(i); + } + System.out.println(I); + ComThread.Release(); + } + } - public class ScriptTest2ActiveXSTA extends STA { + public class ScriptTest2ActiveXSTA extends STA { - public boolean OnInit() { - try { - System.out.println("OnInit"); - System.out.println(Thread.currentThread()); - String lang = "VBScript"; - sC = new ActiveXComponent("ScriptControl"); + public boolean OnInit() { + try { + System.out.println("OnInit"); + System.out.println(Thread.currentThread()); + String lang = "VBScript"; + sC = new ActiveXComponent("ScriptControl"); - // sCon can be called from another thread - sCon = new DispatchProxy(sC); + // sCon can be called from another thread + sCon = new DispatchProxy(sC); - sC.setProperty("Language", lang); - ScriptTestErrEvents te = new ScriptTestErrEvents(); - de = new DispatchEvents(sC, te); - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } + sC.setProperty("Language", lang); + ScriptTestErrEvents te = new ScriptTestErrEvents(); + de = new DispatchEvents(sC, te); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } - public void OnQuit() { - System.out.println("OnQuit"); - } + public void OnQuit() { + System.out.println("OnQuit"); + } - } + } } \ No newline at end of file diff --git a/src/test/java/com/jacob/test/vbscript/ScriptTest3.java b/src/test/java/com/jacob/test/vbscript/ScriptTest3.java index 86e0bfa..69cc004 100644 --- a/src/test/java/com/jacob/test/vbscript/ScriptTest3.java +++ b/src/test/java/com/jacob/test/vbscript/ScriptTest3.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.test.vbscript; @@ -58,62 +58,62 @@ import com.jacob.test.BaseTestCase; */ public class ScriptTest3 extends BaseTestCase { - public static ActiveXComponent sC; + public static ActiveXComponent sC; - public static DispatchEvents de = null; + public static DispatchEvents de = null; - public static Dispatch sControl = null; + public static Dispatch sControl = null; - public static boolean quit = false; + public static boolean quit = false; - public void testScript() { - try { - ComThread.InitMTA(); - ScriptTest3Inner script = new ScriptTest3Inner(); - script.start(); - try { - Thread.sleep(1000); - } catch (InterruptedException ie) { - // should we get this? - } + public void testScript() { + try { + ComThread.InitMTA(); + ScriptTest3Inner script = new ScriptTest3Inner(); + script.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException ie) { + // should we get this? + } - Variant result = Dispatch.call(sControl, "Eval", - getSampleVPScriptForEval()); - System.out.println("eval(" + getSampleVPScriptForEval() + ") = " - + result); - System.out.println("setting quit"); - ScriptTest3.quit = true; - } catch (ComException e) { - e.printStackTrace(); - fail("Caught excpetion running script with MTA"); - } finally { - System.out.println("main done"); - ComThread.Release(); - } - } + Variant result = Dispatch.call(sControl, "Eval", + getSampleVPScriptForEval()); + System.out.println("eval(" + getSampleVPScriptForEval() + ") = " + + result); + System.out.println("setting quit"); + ScriptTest3.quit = true; + } catch (ComException e) { + e.printStackTrace(); + fail("Caught excpetion running script with MTA"); + } finally { + System.out.println("main done"); + ComThread.Release(); + } + } - class ScriptTest3Inner extends Thread { - public void run() { - try { - ComThread.InitMTA(); - System.out.println("OnInit"); - String lang = "VBScript"; - sC = new ActiveXComponent("ScriptControl"); - sControl = sC.getObject(); - Dispatch.put(sControl, "Language", lang); - ScriptTestErrEvents te = new ScriptTestErrEvents(); - de = new DispatchEvents(sControl, te); - System.out.println("sControl=" + sControl); - while (!quit) { - sleep(100); - } - ComThread.Release(); - } catch (Exception e) { - e.printStackTrace(); - } finally { - System.out.println("worker thread exits"); - } - } + class ScriptTest3Inner extends Thread { + public void run() { + try { + ComThread.InitMTA(); + System.out.println("OnInit"); + String lang = "VBScript"; + sC = new ActiveXComponent("ScriptControl"); + sControl = sC.getObject(); + Dispatch.put(sControl, "Language", lang); + ScriptTestErrEvents te = new ScriptTestErrEvents(); + de = new DispatchEvents(sControl, te); + System.out.println("sControl=" + sControl); + while (!quit) { + sleep(100); + } + ComThread.Release(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + System.out.println("worker thread exits"); + } + } - } + } } diff --git a/src/test/java/com/jacob/test/vbscript/ScriptTest3ActiveX.java b/src/test/java/com/jacob/test/vbscript/ScriptTest3ActiveX.java index 17622c1..efa9157 100644 --- a/src/test/java/com/jacob/test/vbscript/ScriptTest3ActiveX.java +++ b/src/test/java/com/jacob/test/vbscript/ScriptTest3ActiveX.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.test.vbscript; @@ -56,58 +56,58 @@ import com.jacob.test.BaseTestCase; * options. */ public class ScriptTest3ActiveX extends BaseTestCase { - public static ActiveXComponent sC; + public static ActiveXComponent sC; - public static DispatchEvents de = null; + public static DispatchEvents de = null; - public static boolean quit = false; + public static boolean quit = false; - public void testYetAnotherScriptTest() { - try { - ComThread.InitMTA(); - ScriptTest3ActiveXInner script = new ScriptTest3ActiveXInner(); - script.start(); - try { - Thread.sleep(1000); - } catch (InterruptedException ie) { - // should we get this? - } + public void testYetAnotherScriptTest() { + try { + ComThread.InitMTA(); + ScriptTest3ActiveXInner script = new ScriptTest3ActiveXInner(); + script.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException ie) { + // should we get this? + } - Variant result = sC.invoke("Eval", getSampleVPScriptForEval()); - System.out.println("eval(" + getSampleVPScriptForEval() + ") = " - + result); - System.out.println("setting quit"); - ScriptTest3ActiveX.quit = true; - } catch (ComException e) { - e.printStackTrace(); - fail("Caught ComException " + e); - } finally { - System.out.println("main done"); - ComThread.Release(); - } - } + Variant result = sC.invoke("Eval", getSampleVPScriptForEval()); + System.out.println("eval(" + getSampleVPScriptForEval() + ") = " + + result); + System.out.println("setting quit"); + ScriptTest3ActiveX.quit = true; + } catch (ComException e) { + e.printStackTrace(); + fail("Caught ComException " + e); + } finally { + System.out.println("main done"); + ComThread.Release(); + } + } - public class ScriptTest3ActiveXInner extends Thread { - public void run() { - try { - ComThread.InitMTA(); - System.out.println("OnInit"); - String lang = "VBScript"; - sC = new ActiveXComponent("ScriptControl"); - sC.setProperty("Language", lang); - ScriptTestErrEvents te = new ScriptTestErrEvents(); - de = new DispatchEvents(sC, te); - System.out.println("sControl=" + sC); - while (!quit) { - sleep(100); - } - ComThread.Release(); - } catch (Exception e) { - e.printStackTrace(); - } finally { - System.out.println("worker thread exits"); - } - } + public class ScriptTest3ActiveXInner extends Thread { + public void run() { + try { + ComThread.InitMTA(); + System.out.println("OnInit"); + String lang = "VBScript"; + sC = new ActiveXComponent("ScriptControl"); + sC.setProperty("Language", lang); + ScriptTestErrEvents te = new ScriptTestErrEvents(); + de = new DispatchEvents(sC, te); + System.out.println("sControl=" + sC); + while (!quit) { + sleep(100); + } + ComThread.Release(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + System.out.println("worker thread exits"); + } + } - } + } } diff --git a/src/test/java/com/jacob/test/vbscript/ScriptTestActiveX.java b/src/test/java/com/jacob/test/vbscript/ScriptTestActiveX.java index b817aeb..fd66fcd 100644 --- a/src/test/java/com/jacob/test/vbscript/ScriptTestActiveX.java +++ b/src/test/java/com/jacob/test/vbscript/ScriptTestActiveX.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.test.vbscript; @@ -54,38 +54,38 @@ import com.jacob.test.BaseTestCase; * options. */ public class ScriptTestActiveX extends BaseTestCase { - public void testActiveXScript() { - ComThread.InitSTA(true); - DispatchEvents de = null; + public void testActiveXScript() { + ComThread.InitSTA(true); + DispatchEvents de = null; - try { - String lang = "VBScript"; - ActiveXComponent sC = new ActiveXComponent("ScriptControl"); - sC.setProperty("Language", lang); - ScriptTestErrEvents te = new ScriptTestErrEvents(); - de = new DispatchEvents(sC, te); - if (de == null) { - System.out - .println("null returned when trying to create DispatchEvents"); - } - Variant result; - result = sC.invoke("Eval", getSampleVPScriptForEval()); - // call it twice to see the objects reused - result = sC.invoke("Eval", getSampleVPScriptForEval()); - // call it 3 times to see the objects reused - result = sC.invoke("Eval", getSampleVPScriptForEval()); - System.out.println("eval(" + getSampleVPScriptForEval() + ") = " - + result); - } catch (ComException e) { - e.printStackTrace(); - } finally { - Integer I = null; - for (int i = 1; i < 1000000; i++) { - I = new Integer(i); - } - System.out.println(I); - ComThread.Release(); - ComThread.quitMainSTA(); - } - } + try { + String lang = "VBScript"; + ActiveXComponent sC = new ActiveXComponent("ScriptControl"); + sC.setProperty("Language", lang); + ScriptTestErrEvents te = new ScriptTestErrEvents(); + de = new DispatchEvents(sC, te); + if (de == null) { + System.out + .println("null returned when trying to create DispatchEvents"); + } + Variant result; + result = sC.invoke("Eval", getSampleVPScriptForEval()); + // call it twice to see the objects reused + result = sC.invoke("Eval", getSampleVPScriptForEval()); + // call it 3 times to see the objects reused + result = sC.invoke("Eval", getSampleVPScriptForEval()); + System.out.println("eval(" + getSampleVPScriptForEval() + ") = " + + result); + } catch (ComException e) { + e.printStackTrace(); + } finally { + Integer I = null; + for (int i = 1; i < 1000000; i++) { + I = new Integer(i); + } + System.out.println(I); + ComThread.Release(); + ComThread.quitMainSTA(); + } + } } diff --git a/src/test/java/com/jacob/test/vbscript/ScriptTestErrEvents.java b/src/test/java/com/jacob/test/vbscript/ScriptTestErrEvents.java index 830cbae..4126b2b 100644 --- a/src/test/java/com/jacob/test/vbscript/ScriptTestErrEvents.java +++ b/src/test/java/com/jacob/test/vbscript/ScriptTestErrEvents.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.test.vbscript; @@ -47,11 +47,11 @@ import com.jacob.test.BaseTestCase; */ public class ScriptTestErrEvents extends BaseTestCase { - public void Error(Variant[] args) { - System.out.println("java callback for error!"); - } + public void Error(Variant[] args) { + System.out.println("java callback for error!"); + } - public void Timeout(Variant[] args) { - System.out.println("java callback for error!"); - } + public void Timeout(Variant[] args) { + System.out.println("java callback for error!"); + } } diff --git a/src/test/java/com/jacob/test/windowsmedia/WMPlayer.java b/src/test/java/com/jacob/test/windowsmedia/WMPlayer.java index ab826ee..71e2bb3 100644 --- a/src/test/java/com/jacob/test/windowsmedia/WMPlayer.java +++ b/src/test/java/com/jacob/test/windowsmedia/WMPlayer.java @@ -18,23 +18,23 @@ * * This file incorporates work covered by the following copyright and * permission notice: - * Copyright (c) 1999-2004 Sourceforge JACOB Project. - * All rights reserved. Originator: Dan Adler (http://danadler.com). - * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package com.jacob.test.windowsmedia; @@ -58,50 +58,50 @@ import com.jacob.test.BaseTestCase; public class WMPlayer extends BaseTestCase { - /** - * This should demo the media player but it doesn't - */ - public void testOpenWMPlayer() { - // this file exists in windows 7 installations - File file = new File( - "C:/Windows/winsxs/x86_microsoft-windows-videosamples_31bf3856ad364e35_6.1.7600.16385_none_f583837f77a63ec7"); - String filePath = file.getAbsolutePath(); - String microsoftTestURL = filePath; - // use these instead if not on windows 7 - // "http://support.microsoft.com/support/mediaplayer/wmptest/samples/new/mediaexample.wma"; - // "http://support.microsoft.com/support/mediaplayer/wmptest/samples/new/mediaexample.wmv"; - ActiveXComponent wmp = null; - // could use WMPlayer.OCX alias also - wmp = new ActiveXComponent( - "CLSID:{6BF52A52-394A-11D3-B153-00C04F79FAA6}");// ("WMPlayer.OCX"); + /** + * This should demo the media player but it doesn't + */ + public void testOpenWMPlayer() { + // this file exists in windows 7 installations + File file = new File( + "C:/Windows/winsxs/x86_microsoft-windows-videosamples_31bf3856ad364e35_6.1.7600.16385_none_f583837f77a63ec7"); + String filePath = file.getAbsolutePath(); + String microsoftTestURL = filePath; + // use these instead if not on windows 7 + // "http://support.microsoft.com/support/mediaplayer/wmptest/samples/new/mediaexample.wma"; + // "http://support.microsoft.com/support/mediaplayer/wmptest/samples/new/mediaexample.wmv"; + ActiveXComponent wmp = null; + // could use WMPlayer.OCX alias also + wmp = new ActiveXComponent( + "CLSID:{6BF52A52-394A-11D3-B153-00C04F79FAA6}");// ("WMPlayer.OCX"); - wmp.setProperty("URL", microsoftTestURL); - assertEquals(wmp.getProperty("URL").toString(), microsoftTestURL); + wmp.setProperty("URL", microsoftTestURL); + assertEquals(wmp.getProperty("URL").toString(), microsoftTestURL); - // alternative way to get the controls - Dispatch controls = Dispatch.get(wmp, "controls").toDispatch(); - Dispatch.call(controls, "Play"); - // the sourceforge posting didn't post all the code so this is all we - // have we need some other information on how to set the document - // so that we have a url to open + // alternative way to get the controls + Dispatch controls = Dispatch.get(wmp, "controls").toDispatch(); + Dispatch.call(controls, "Play"); + // the sourceforge posting didn't post all the code so this is all we + // have we need some other information on how to set the document + // so that we have a url to open - // pause to let it play a second or two - try { - Thread.sleep(1500); - } catch (InterruptedException e) { - System.out.println("Thread interrupted"); - } - for (int i = 0; i < 1000; i++) { - // Get media object - Dispatch vMedObj = wmp.getProperty("currentMedia").toDispatch(); - // Get duration of media object - Variant vdur = Dispatch.call(vMedObj, "duration"); - // why is this always 0? - // System.out.println(microsoftTestURL + " length is " - // + vdur.getDouble()); - // System.out.println("the wmp url is " - // + wmp.getProperty("URL").toString()); - } + // pause to let it play a second or two + try { + Thread.sleep(1500); + } catch (InterruptedException e) { + System.out.println("Thread interrupted"); + } + for (int i = 0; i < 1000; i++) { + // Get media object + Dispatch vMedObj = wmp.getProperty("currentMedia").toDispatch(); + // Get duration of media object + Variant vdur = Dispatch.call(vMedObj, "duration"); + // why is this always 0? + // System.out.println(microsoftTestURL + " length is " + // + vdur.getDouble()); + // System.out.println("the wmp url is " + // + wmp.getProperty("URL").toString()); + } - } + } }