X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.excel%2Fnative%2FInterface.cpp;h=9e67f4aa8258bb2ea627b0d5d971e512116fc073;hp=46f894c63397ded825af1c78a8e008fcd2073dba;hb=0c128e8f1ce1dd42d4375b0f91e4e93f02214ccf;hpb=0ae2b770234dfc3cbb18bd38f324125cf0faca07 diff --git a/bundles/org.simantics.excel/native/Interface.cpp b/bundles/org.simantics.excel/native/Interface.cpp index 46f894c63..9e67f4aa8 100644 --- a/bundles/org.simantics.excel/native/Interface.cpp +++ b/bundles/org.simantics.excel/native/Interface.cpp @@ -1,31 +1,21 @@ -//#include "stdafx.h" - -//#ifndef _UNICODE -//#define _UNICODE -//#endif - #include #include -//#include -//#include +#include +#include +#include +#include using namespace std; -#import "c:/program files (x86)/common files/microsoft shared/office12/mso.dll" \ - rename( "RGB", "MSORGB" ) - -using namespace Office; - -#import "c:/program files (x86)/common files/microsoft shared/vba/vba6/vbe6ext.olb" \ - -using namespace VBIDE; +// mso.dll +#import "libid:{2df8d04c-5bfa-101b-bde5-00aa0044de52}" auto_rename +// vb6ext.olb +#import "libid:{0002e157-0000-0000-c000-000000000046}" auto_rename +// excel.exe +#import "libid:{00020813-0000-0000-c000-000000000046}" auto_rename -#import "c:/program files (x86)/microsoft office/office12/excel.exe" \ - rename( "DialogBox", "ExcelDialogBox" ) \ - rename( "RGB", "ExcelRGB" ) \ - rename( "CopyFile", "ExcelCopyFile" ) \ - rename( "ReplaceText", "ExcelReplaceText" ) +using namespace Excel; #include "jni2.h" @@ -34,10 +24,10 @@ using namespace VBIDE; #define SIMANTICS_DEBUG(...) -using namespace std; -using namespace Excel; +//using namespace std; +//using namespace Office; -map handles; +map handles; static int handleCounter = 1; void replace(std::string &s, const std::string &s1, const std::string &s2) { @@ -464,7 +454,7 @@ JNIEXPORT jint JNICALL Java_org_simantics_excel_Excel_close(JNIEnv *env, jobject } -/** + JNIEXPORT jdouble JNICALL Java_org_simantics_excel_Excel_getDouble(JNIEnv *env, jobject, jint handle, jint row, jint column) { SIMANTICS_DEBUG("getDouble(%d, %d)\r\n", row, column); @@ -489,7 +479,7 @@ JNIEXPORT jdouble JNICALL Java_org_simantics_excel_Excel_getDouble(JNIEnv *env, } JNIEXPORT jstring JNICALL Java_org_simantics_excel_Excel_getString(JNIEnv *env, jobject, jint handle, jint row, jint column) { - + USES_CONVERSION; //string val = getString(env, value); SIMANTICS_DEBUG("getString(%d, %d)\r\n", row, column); @@ -499,30 +489,30 @@ JNIEXPORT jstring JNICALL Java_org_simantics_excel_Excel_getString(JNIEnv *env, Excel::RangePtr range = sheet->Cells; if(!range) return NULL; - variant_t val = range->Item[row+1][column+1]; - if (val.vt != VT_NULL) { // val.vt seems to be always VT_DISPATCH. - try { + _bstr_t val = _bstr_t(range->Item[row + 1][column + 1]); + //if (val.vt != VT_NULL) { // val.vt seems to be always VT_DISPATCH. + //try { //this call will crash the application, if the cell is empty! - _bstr_t bstrt = val; - TCHAR text[1024]; + //_bstr_t bstrt = val; + //std::string text(val); + //CString text(val); + //text. + //TCHAR text[1024]; // TODO: this uses wide character (16-bit) while NewStringUTF expext regular character (8-bit), hence Java gets only the fisrt charater of the whole string. - _stprintf(text, _T("%s"), (LPCTSTR)bstrt); + //_stprintf(text, _T("%s"), (LPCTSTR)bstrt); //const char *text = bstrt; SIMANTICS_DEBUG("%s\r\n",text); - - // this code returns "??" for all cells. - //BSTR bstr = val.bstrVal; - //const char *text = _com_util::ConvertBSTRToString(bstr); - jstring ret = env->NewStringUTF((const char*)text); - delete[] text; - return ret; - } catch (...) { - return NULL; - } - } - SIMANTICS_DEBUG("%d\r\n",val.vt); - return NULL; + string text(val); + + + return env->NewStringUTF(text.c_str()); + + //} catch (...) { + // return NULL; + //} + //} + //SIMANTICS_DEBUG("%d\r\n",val.vt); + //return NULL; } -*/ \ No newline at end of file