Commit 7ac86fdd authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander Trofimov

(1.0.0.7) changes repair. generate styles bug



git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@57892 954022d7-b5bf-4e40-9824-e11837661b57
parent df069da3
...@@ -14,14 +14,12 @@ ...@@ -14,14 +14,12 @@
#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms." #error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
#endif #endif
CNativeControlsList NativeStaticList;
void CreateNativeObject(const v8::FunctionCallbackInfo<v8::Value>& args) void CreateNativeObject(const v8::FunctionCallbackInfo<v8::Value>& args)
{ {
v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Handle<v8::ObjectTemplate> NativeObjectTemplate = CreateNativeControlTemplate(isolate); v8::Handle<v8::ObjectTemplate> NativeObjectTemplate = CreateNativeControlTemplate(isolate);
CNativeControl* pNativeObject = NativeStaticList.CreateControl(); CNativeControl* pNativeObject = new CNativeControl();
v8::Local<v8::Object> obj = NativeObjectTemplate->NewInstance(); v8::Local<v8::Object> obj = NativeObjectTemplate->NewInstance();
obj->SetInternalField(0, v8::External::New(pNativeObject)); obj->SetInternalField(0, v8::External::New(pNativeObject));
...@@ -155,10 +153,16 @@ private: ...@@ -155,10 +153,16 @@ private:
CString m_strPpttSDK; CString m_strPpttSDK;
CString m_strXlstSDK; CString m_strXlstSDK;
CString m_strEditorType;
CString m_strFilePath;
BOOL m_bIsInitTypedArrays;
public: public:
CDoctRenderer() CDoctRenderer()
{ {
m_pRenderer = NULL; m_pRenderer = NULL;
m_bIsInitTypedArrays = FALSE;
} }
DECLARE_PROTECT_FINAL_CONSTRUCT() DECLARE_PROTECT_FINAL_CONSTRUCT()
...@@ -282,7 +286,7 @@ public: ...@@ -282,7 +286,7 @@ public:
case DoctRendererFormat::PDF: case DoctRendererFormat::PDF:
{ {
sResourceFile = m_strDoctSDK; sResourceFile = m_strDoctSDK;
strCorrector = _T("var NATIVE_DOCUMENT_TYPE = \"document\";"); m_strEditorType = _T("document");
break; break;
} }
default: default:
...@@ -298,7 +302,7 @@ public: ...@@ -298,7 +302,7 @@ public:
case DoctRendererFormat::PDF: case DoctRendererFormat::PDF:
{ {
sResourceFile = m_strPpttSDK; sResourceFile = m_strPpttSDK;
strCorrector = _T("var NATIVE_DOCUMENT_TYPE = \"presentation\";"); m_strEditorType = _T("presentation");
break; break;
} }
default: default:
...@@ -314,7 +318,7 @@ public: ...@@ -314,7 +318,7 @@ public:
case DoctRendererFormat::PDF: case DoctRendererFormat::PDF:
{ {
sResourceFile = m_strXlstSDK; sResourceFile = m_strXlstSDK;
strCorrector = _T("var NATIVE_DOCUMENT_TYPE = \"spreadsheet\";$.ready();"); m_strEditorType = _T("spreadsheet");
break; break;
} }
default: default:
...@@ -348,21 +352,20 @@ public: ...@@ -348,21 +352,20 @@ public:
strFileName.Replace(_T("\\"), _T("\\\\")); strFileName.Replace(_T("\\"), _T("\\\\"));
strFileName += _T("Editor.bin"); strFileName += _T("Editor.bin");
CString strScript = _T("var g_file_path = \""); m_strFilePath = strFileName;
strScript += strFileName;
strScript += _T("\";\n\n");
strScript += strMainPart; CString strScript = strMainPart;
strScript += ReadScriptFile(sResourceFile); strScript += ReadScriptFile(sResourceFile);
strScript += strCorrector; if (m_strEditorType == _T("spreadsheet"))
strScript += _T("\n$.ready();");
CString strError = _T(""); CString strError = _T("");
BOOL bResult = ExecuteScript(strScript, strError); BOOL bResult = ExecuteScript(strScript, strError);
if (_T("") != strError) if (_T("") != strError)
{ {
CString sDestError = _T("<result><error code=\"") + strError + _T("\" /></result>"); CString sDestError = _T("<result><error ") + strError + _T(" /></result>");
*pbsError = sDestError.AllocSysString(); *pbsError = sDestError.AllocSysString();
} }
...@@ -487,7 +490,12 @@ private: ...@@ -487,7 +490,12 @@ private:
{ {
CString strException = _T(""); CString strException = _T("");
if (!m_bIsInitTypedArrays)
{
enableTypedArrays(); enableTypedArrays();
m_bIsInitTypedArrays = TRUE;
}
WCHAR* javascript = (WCHAR*)strScript.GetBuffer(); WCHAR* javascript = (WCHAR*)strScript.GetBuffer();
v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::Isolate* isolate = v8::Isolate::GetCurrent();
...@@ -508,7 +516,7 @@ private: ...@@ -508,7 +516,7 @@ private:
CString strCode = to_cstring(try_catch.Message()->GetSourceLine()); CString strCode = to_cstring(try_catch.Message()->GetSourceLine());
strException = to_cstring(try_catch.Message()->Get()); strException = to_cstring(try_catch.Message()->Get());
strError = _T("compile"); strError = _T("code=\"compile\"");
return FALSE; return FALSE;
} }
...@@ -519,7 +527,7 @@ private: ...@@ -519,7 +527,7 @@ private:
CString strCode = to_cstring(try_catch.Message()->GetSourceLine()); CString strCode = to_cstring(try_catch.Message()->GetSourceLine());
strException = to_cstring(try_catch.Message()->Get()); strException = to_cstring(try_catch.Message()->Get());
strError = _T("run"); strError = _T("code=\"run\"");
return FALSE; return FALSE;
} }
...@@ -556,18 +564,46 @@ private: ...@@ -556,18 +564,46 @@ private:
int nLineError = try_catch.Message()->GetLineNumber(); int nLineError = try_catch.Message()->GetLineNumber();
strException = to_cstring(try_catch.Message()->Get()); // ? strException = to_cstring(try_catch.Message()->Get()); // ?
strError = _T("run"); strError = _T("code=\"run\"");
return FALSE; return FALSE;
} }
strDocumentId = to_cstring(js_result2); strDocumentId = to_cstring(js_result2);
} }
CNativeControl* pNative = NativeStaticList.GetControlById(strDocumentId); CNativeControl* pNative = NULL;
v8::Handle<v8::Value> js_func_get_native = global_js->Get(v8::String::New("GetNativeEngine"));
v8::Local<v8::Object> objNative;
if (js_func_get_native->IsFunction())
{
v8::Handle<v8::Function> func_get_native = v8::Handle<v8::Function>::Cast(js_func_get_native);
v8::Local<v8::Value> js_result2 = func_get_native->Call(global_js, 1, args);
if (try_catch.HasCaught())
{
int nLineError = try_catch.Message()->GetLineNumber();
strException = to_cstring(try_catch.Message()->Get()); // ?
isolate->Exit();
strError = _T("code=\"run\"");
return FALSE;
}
objNative = js_result2->ToObject();
v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(objNative->GetInternalField(0));
pNative = static_cast<CNativeControl*>(field->Value());
}
pNative->m_pChanges = &m_oParams.m_arChanges; pNative->m_pChanges = &m_oParams.m_arChanges;
pNative->m_strFontsDirectory = m_oParams.m_strFontsDirectory; pNative->m_strFontsDirectory = m_oParams.m_strFontsDirectory;
pNative->m_strImagesDirectory = m_oParams.m_strImagesDirectory; pNative->m_strImagesDirectory = m_oParams.m_strImagesDirectory;
pNative->m_strEditorType = m_strEditorType;
pNative->SetFilePath(m_strFilePath);
if (js_func_open->IsFunction()) if (js_func_open->IsFunction())
{ {
v8::Handle<v8::Function> func_open = v8::Handle<v8::Function>::Cast(js_func_open); v8::Handle<v8::Function> func_open = v8::Handle<v8::Function>::Cast(js_func_open);
...@@ -579,7 +615,7 @@ private: ...@@ -579,7 +615,7 @@ private:
CString strCode = to_cstring(try_catch.Message()->GetSourceLine()); CString strCode = to_cstring(try_catch.Message()->GetSourceLine());
strException = to_cstring(try_catch.Message()->Get()); // ? strException = to_cstring(try_catch.Message()->Get()); // ?
strError = _T("open"); strError = _T("code=\"open\"");
return FALSE; return FALSE;
} }
} }
...@@ -597,7 +633,11 @@ private: ...@@ -597,7 +633,11 @@ private:
CString strCode = to_cstring(try_catch.Message()->GetSourceLine()); CString strCode = to_cstring(try_catch.Message()->GetSourceLine());
strException = to_cstring(try_catch.Message()->Get()); // ? strException = to_cstring(try_catch.Message()->Get()); // ?
strError = _T("changes"); strError = _T("");
int nNumberC = pNative->m_nCurrentChangesNumber;
if (nNumberC >= 0)
--nNumberC;
strError.Format(_T("index=\"%d\""), nNumberC);
return FALSE; return FALSE;
} }
} }
...@@ -620,7 +660,7 @@ private: ...@@ -620,7 +660,7 @@ private:
CString strCode = to_cstring(try_catch.Message()->GetSourceLine()); CString strCode = to_cstring(try_catch.Message()->GetSourceLine());
strException = to_cstring(try_catch.Message()->Get()); // ? strException = to_cstring(try_catch.Message()->Get()); // ?
strError = _T("save"); strError = _T("code=\"save\"");
return FALSE; return FALSE;
} }
...@@ -648,7 +688,7 @@ private: ...@@ -648,7 +688,7 @@ private:
CString strCode = to_cstring(try_catch.Message()->GetSourceLine()); CString strCode = to_cstring(try_catch.Message()->GetSourceLine());
strException = to_cstring(try_catch.Message()->Get()); // ? strException = to_cstring(try_catch.Message()->Get()); // ?
strError = _T("calculate"); strError = _T("code=\"calculate\"");
return FALSE; return FALSE;
} }
} }
...@@ -664,7 +704,7 @@ private: ...@@ -664,7 +704,7 @@ private:
CString strCode = to_cstring(try_catch.Message()->GetSourceLine()); CString strCode = to_cstring(try_catch.Message()->GetSourceLine());
strException = to_cstring(try_catch.Message()->Get()); // ? strException = to_cstring(try_catch.Message()->Get()); // ?
strError = _T("calculate"); strError = _T("code=\"calculate\"");
return FALSE; return FALSE;
} }
...@@ -701,7 +741,7 @@ private: ...@@ -701,7 +741,7 @@ private:
CString strCode = to_cstring(try_catch.Message()->GetSourceLine()); CString strCode = to_cstring(try_catch.Message()->GetSourceLine());
strException = to_cstring(try_catch.Message()->Get()); // ? strException = to_cstring(try_catch.Message()->Get()); // ?
strError = _T("render"); strError = _T("code=\"render\"");
return FALSE; return FALSE;
} }
...@@ -727,7 +767,7 @@ private: ...@@ -727,7 +767,7 @@ private:
RELEASEINTERFACE(pPDF); RELEASEINTERFACE(pPDF);
if (S_OK != hr) if (S_OK != hr)
strError = _T("save"); strError = _T("code=\"save\"");
return (hr == S_OK) ? TRUE : FALSE; return (hr == S_OK) ? TRUE : FALSE;
} }
......
...@@ -32,6 +32,9 @@ public: ...@@ -32,6 +32,9 @@ public:
CString m_strFontsDirectory; CString m_strFontsDirectory;
CString m_strImagesDirectory; CString m_strImagesDirectory;
CString m_strEditorType;
int m_nCurrentChangesNumber;
public: public:
CMemoryStream* m_pStream; CMemoryStream* m_pStream;
...@@ -39,6 +42,8 @@ public: ...@@ -39,6 +42,8 @@ public:
{ {
m_pStream = NULL; m_pStream = NULL;
m_pChanges = NULL; m_pChanges = NULL;
m_nCurrentChangesNumber = -1;
} }
~CNativeControl() ~CNativeControl()
{ {
...@@ -112,6 +117,12 @@ void _GetFontsDirectory(const v8::FunctionCallbackInfo<v8::Value>& args) ...@@ -112,6 +117,12 @@ void _GetFontsDirectory(const v8::FunctionCallbackInfo<v8::Value>& args)
args.GetReturnValue().Set(v8::String::New((uint16_t*)pNative->m_strFontsDirectory.GetBuffer())); args.GetReturnValue().Set(v8::String::New((uint16_t*)pNative->m_strFontsDirectory.GetBuffer()));
} }
void _GetEditorType(const v8::FunctionCallbackInfo<v8::Value>& args)
{
CNativeControl* pNative = unwrap_nativeobject(args.This());
args.GetReturnValue().Set(v8::String::New((uint16_t*)pNative->m_strEditorType.GetBuffer()));
}
void _GetChangesCount(const v8::FunctionCallbackInfo<v8::Value>& args) void _GetChangesCount(const v8::FunctionCallbackInfo<v8::Value>& args)
{ {
CNativeControl* pNative = unwrap_nativeobject(args.This()); CNativeControl* pNative = unwrap_nativeobject(args.This());
...@@ -154,6 +165,19 @@ void _SetFileId(const v8::FunctionCallbackInfo<v8::Value>& args) ...@@ -154,6 +165,19 @@ void _SetFileId(const v8::FunctionCallbackInfo<v8::Value>& args)
pNative->SetFileId(to_cstring(args[0])); pNative->SetFileId(to_cstring(args[0]));
} }
void _SetCurrentChangeFile(const v8::FunctionCallbackInfo<v8::Value>& args)
{
args.GetReturnValue().Set(v8::Undefined());
if (args.Length() < 1)
return;
CNativeControl* pNative = unwrap_nativeobject(args.This());
int nIndex = args[0]->ToInt32()->Value();
pNative->m_nCurrentChangesNumber = nIndex;
}
void _GetFileArrayBuffer(const v8::FunctionCallbackInfo<v8::Value>& args) void _GetFileArrayBuffer(const v8::FunctionCallbackInfo<v8::Value>& args)
{ {
if (args.Length() < 1) if (args.Length() < 1)
...@@ -244,6 +268,9 @@ v8::Handle<v8::ObjectTemplate> CreateNativeControlTemplate(v8::Isolate* isolate) ...@@ -244,6 +268,9 @@ v8::Handle<v8::ObjectTemplate> CreateNativeControlTemplate(v8::Isolate* isolate)
result->Set(v8::String::NewSymbol("GetFontsDirectory"), v8::FunctionTemplate::New(_GetFontsDirectory)); result->Set(v8::String::NewSymbol("GetFontsDirectory"), v8::FunctionTemplate::New(_GetFontsDirectory));
result->Set(v8::String::NewSymbol("GetFileString"), v8::FunctionTemplate::New(_GetFileString)); result->Set(v8::String::NewSymbol("GetFileString"), v8::FunctionTemplate::New(_GetFileString));
result->Set(v8::String::NewSymbol("GetEditorType"), v8::FunctionTemplate::New(_GetEditorType));
result->Set(v8::String::NewSymbol("SetCurrentChangeFile"), v8::FunctionTemplate::New(_SetCurrentChangeFile));
result->Set(v8::String::NewSymbol("GetCountChanges"), v8::FunctionTemplate::New(_GetChangesCount)); result->Set(v8::String::NewSymbol("GetCountChanges"), v8::FunctionTemplate::New(_GetChangesCount));
result->Set(v8::String::NewSymbol("GetChangesFile"), v8::FunctionTemplate::New(_GetChangesFile)); result->Set(v8::String::NewSymbol("GetChangesFile"), v8::FunctionTemplate::New(_GetChangesFile));
......
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
//1 //1
//0 //0
//0 //0
//6 //7
#define INTVER 1,0,0,6 #define INTVER 1,0,0,7
#define STRVER "1,0,0,6\0" #define STRVER "1,0,0,7\0"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment