-//#include "stdafx.h"
-
-//#ifndef _UNICODE
-//#define _UNICODE
-//#endif
-
#include <sstream>
#include <map>
-//#include <cmath>
-//#include <TCHAR.H>
+#include <stdio.h>
+#include <tchar.h>
+#include <cstring>
+#include <atlstr.h>
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"
#define SIMANTICS_DEBUG(...)
-using namespace std;
-using namespace Excel;
+//using namespace std;
+//using namespace Office;
-map<int, Excel::_WorksheetPtr> handles;
+map<int, _WorksheetPtr> handles;
static int handleCounter = 1;
void replace(std::string &s, const std::string &s1, const std::string &s2) {
}
-/**
+
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);
}
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);
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