Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1478)

Unified Diff: xfa/fxfa/fm2js/xfa_fm2jscontext.cpp

Issue 2024833003: Remove XFA_HFM2JSCONTEXT. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
index e778d429948df19ebcaa50d4e3e25203666f74fe..c9a75c3ba4ae5d2efe45eecb3e9643a69d681d40 100644
--- a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
+++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
@@ -11,7 +11,7 @@
#include "core/fxcrt/include/fx_ext.h"
#include "xfa/fgas/localization/fgas_locale.h"
#include "xfa/fxfa/app/xfa_ffnotify.h"
-#include "xfa/fxfa/fm2js/xfa_fm2jsapi.h"
+#include "xfa/fxfa/fm2js/xfa_program.h"
#include "xfa/fxfa/parser/xfa_document.h"
#include "xfa/fxfa/parser/xfa_localevalue.h"
#include "xfa/fxfa/parser/xfa_parser.h"
@@ -3404,7 +3404,7 @@ void CXFA_FM2JSContext::Eval(CFXJSE_Value* pThis,
CFX_WideTextBuf wsJavaScriptBuf;
CFX_WideString javaScript;
CFX_WideString wsError;
- XFA_FM2JS_Translate(
+ pContext->Translate(
CFX_WideString::FromUTF8(utf8ScriptString.AsStringC()).AsStringC(),
wsJavaScriptBuf, wsError);
CFXJSE_Context* pContext =
@@ -6417,7 +6417,7 @@ void CXFA_FM2JSContext::eval_translation(CFXJSE_Value* pThis,
CFX_WideString::FromUTF8(argString.AsStringC());
CFX_WideTextBuf wsJavaScriptBuf;
CFX_WideString wsError;
- XFA_FM2JS_Translate(scriptString.AsStringC(), wsJavaScriptBuf, wsError);
+ pContext->Translate(scriptString.AsStringC(), wsJavaScriptBuf, wsError);
if (wsError.IsEmpty()) {
CFX_WideString javaScript = wsJavaScriptBuf.MakeString();
FXJSE_Value_SetUTF8String(
@@ -7139,6 +7139,30 @@ void CXFA_FM2JSContext::GlobalPropertyGetter(CFXJSE_Value* pValue) {
FXJSE_Value_Set(pValue, m_pValue.get());
}
+int32_t CXFA_FM2JSContext::Translate(const CFX_WideStringC& wsFormcalc,
+ CFX_WideTextBuf& wsJavascript,
+ CFX_WideString& wsError) const {
+ if (wsFormcalc.IsEmpty()) {
+ wsJavascript.Clear();
+ wsError.clear();
+ return 0;
+ }
+ int32_t status = 0;
+ CXFA_FMProgram program;
+ status = program.Init(wsFormcalc);
+ if (status) {
+ wsError = program.GetError().message;
+ return status;
+ }
+ status = program.ParseProgram();
+ if (status) {
+ wsError = program.GetError().message;
+ return status;
+ }
+ program.TranslateProgram(wsJavascript);
+ return 0;
+}
+
void CXFA_FM2JSContext::ThrowScriptErrorMessage(int32_t iStringID, ...) {
IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider();
ASSERT(pAppProvider);

Powered by Google App Engine
This is Rietveld 408576698