From 3de090d52aa629f3bbded16ce7069a8b25bbbc46 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 30 Oct 2017 19:18:54 +0000 Subject: Move resource to js_resource This CL moves the resource.{cpp|h} files to js_resources.{cpp|h}. Change-Id: I6a9ccb7e0819f40edf4a91e7839a92657d5d39d7 Reviewed-on: https://pdfium-review.googlesource.com/17045 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- BUILD.gn | 4 +- fpdfsdk/javascript/JS_Define.h | 2 +- fpdfsdk/javascript/cjs_annot.cpp | 1 + fpdfsdk/javascript/cjs_app.cpp | 1 + fpdfsdk/javascript/cjs_document.cpp | 1 + fpdfsdk/javascript/cjs_event_context.cpp | 3 +- fpdfsdk/javascript/cjs_field.cpp | 1 + fpdfsdk/javascript/cjs_global.cpp | 2 +- fpdfsdk/javascript/cjs_publicmethods.cpp | 2 +- fpdfsdk/javascript/js_resources.cpp | 68 ++++++++++++++++++++++++++++++++ fpdfsdk/javascript/js_resources.h | 38 ++++++++++++++++++ fpdfsdk/javascript/resource.cpp | 68 -------------------------------- fpdfsdk/javascript/resource.h | 40 ------------------- fpdfsdk/javascript/util.cpp | 2 +- 14 files changed, 118 insertions(+), 115 deletions(-) create mode 100644 fpdfsdk/javascript/js_resources.cpp create mode 100644 fpdfsdk/javascript/js_resources.h delete mode 100644 fpdfsdk/javascript/resource.cpp delete mode 100644 fpdfsdk/javascript/resource.h diff --git a/BUILD.gn b/BUILD.gn index 67f2a166ca..cedfbca4fe 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1258,8 +1258,8 @@ static_library("javascript") { "fpdfsdk/javascript/cjs_zoomtype.h", "fpdfsdk/javascript/global_timer.cpp", "fpdfsdk/javascript/global_timer.h", - "fpdfsdk/javascript/resource.cpp", - "fpdfsdk/javascript/resource.h", + "fpdfsdk/javascript/js_resources.cpp", + "fpdfsdk/javascript/js_resources.h", "fpdfsdk/javascript/util.cpp", "fpdfsdk/javascript/util.h", ] diff --git a/fpdfsdk/javascript/JS_Define.h b/fpdfsdk/javascript/JS_Define.h index 4f82a74b0d..41dccc6c8c 100644 --- a/fpdfsdk/javascript/JS_Define.h +++ b/fpdfsdk/javascript/JS_Define.h @@ -11,7 +11,7 @@ #include "fpdfsdk/javascript/cjs_object.h" #include "fpdfsdk/javascript/cjs_return.h" -#include "fpdfsdk/javascript/resource.h" +#include "fpdfsdk/javascript/js_resources.h" #include "fxjs/fxjs_v8.h" double JS_GetDateTime(); diff --git a/fpdfsdk/javascript/cjs_annot.cpp b/fpdfsdk/javascript/cjs_annot.cpp index 8ff0d2c72e..586e4629aa 100644 --- a/fpdfsdk/javascript/cjs_annot.cpp +++ b/fpdfsdk/javascript/cjs_annot.cpp @@ -9,6 +9,7 @@ #include "fpdfsdk/javascript/JS_Define.h" #include "fpdfsdk/javascript/cjs_event_context.h" #include "fpdfsdk/javascript/cjs_object.h" +#include "fpdfsdk/javascript/js_resources.h" namespace { diff --git a/fpdfsdk/javascript/cjs_app.cpp b/fpdfsdk/javascript/cjs_app.cpp index bd28fefc4e..df590976d8 100644 --- a/fpdfsdk/javascript/cjs_app.cpp +++ b/fpdfsdk/javascript/cjs_app.cpp @@ -11,6 +11,7 @@ #include "fpdfsdk/javascript/cjs_timerobj.h" #include "fpdfsdk/javascript/global_timer.h" #include "fpdfsdk/javascript/ijs_event_context.h" +#include "fpdfsdk/javascript/js_resources.h" namespace { diff --git a/fpdfsdk/javascript/cjs_document.cpp b/fpdfsdk/javascript/cjs_document.cpp index 1791db563b..8b0afa8eff 100644 --- a/fpdfsdk/javascript/cjs_document.cpp +++ b/fpdfsdk/javascript/cjs_document.cpp @@ -25,6 +25,7 @@ #include "fpdfsdk/javascript/cjs_field.h" #include "fpdfsdk/javascript/cjs_icon.h" #include "fpdfsdk/javascript/cjs_printparamsobj.h" +#include "fpdfsdk/javascript/js_resources.h" const JSPropertySpec CJS_Document::PropertySpecs[] = { {"ADBE", get_ADBE_static, set_ADBE_static}, diff --git a/fpdfsdk/javascript/cjs_event_context.cpp b/fpdfsdk/javascript/cjs_event_context.cpp index e02149d176..98f3c6d14a 100644 --- a/fpdfsdk/javascript/cjs_event_context.cpp +++ b/fpdfsdk/javascript/cjs_event_context.cpp @@ -7,9 +7,10 @@ #include "fpdfsdk/javascript/cjs_event_context.h" #include "core/fxcrt/autorestorer.h" +#include "fpdfsdk/javascript/JS_Define.h" #include "fpdfsdk/javascript/cjs_eventhandler.h" #include "fpdfsdk/javascript/cjs_runtime.h" -#include "fpdfsdk/javascript/resource.h" +#include "fpdfsdk/javascript/js_resources.h" CJS_EventContext::CJS_EventContext(CJS_Runtime* pRuntime) : m_pRuntime(pRuntime), diff --git a/fpdfsdk/javascript/cjs_field.cpp b/fpdfsdk/javascript/cjs_field.cpp index 84c0d6ab10..1c50f8ec98 100644 --- a/fpdfsdk/javascript/cjs_field.cpp +++ b/fpdfsdk/javascript/cjs_field.cpp @@ -19,6 +19,7 @@ #include "fpdfsdk/javascript/cjs_delaydata.h" #include "fpdfsdk/javascript/cjs_document.h" #include "fpdfsdk/javascript/cjs_icon.h" +#include "fpdfsdk/javascript/js_resources.h" namespace { diff --git a/fpdfsdk/javascript/cjs_global.cpp b/fpdfsdk/javascript/cjs_global.cpp index d89005d2af..3d605b23ab 100644 --- a/fpdfsdk/javascript/cjs_global.cpp +++ b/fpdfsdk/javascript/cjs_global.cpp @@ -18,7 +18,7 @@ #include "fpdfsdk/javascript/cjs_event_context.h" #include "fpdfsdk/javascript/cjs_eventhandler.h" #include "fpdfsdk/javascript/cjs_object.h" -#include "fpdfsdk/javascript/resource.h" +#include "fpdfsdk/javascript/js_resources.h" namespace { diff --git a/fpdfsdk/javascript/cjs_publicmethods.cpp b/fpdfsdk/javascript/cjs_publicmethods.cpp index 27bb869f0d..fb4cc2c3ee 100644 --- a/fpdfsdk/javascript/cjs_publicmethods.cpp +++ b/fpdfsdk/javascript/cjs_publicmethods.cpp @@ -26,7 +26,7 @@ #include "fpdfsdk/javascript/cjs_field.h" #include "fpdfsdk/javascript/cjs_object.h" #include "fpdfsdk/javascript/cjs_runtime.h" -#include "fpdfsdk/javascript/resource.h" +#include "fpdfsdk/javascript/js_resources.h" #include "fpdfsdk/javascript/util.h" #define DOUBLE_CORRECT 0.000000000000001 diff --git a/fpdfsdk/javascript/js_resources.cpp b/fpdfsdk/javascript/js_resources.cpp new file mode 100644 index 0000000000..39f59a6a63 --- /dev/null +++ b/fpdfsdk/javascript/js_resources.cpp @@ -0,0 +1,68 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "fpdfsdk/javascript/js_resources.h" + +WideString JSGetStringFromID(uint32_t id) { + switch (id) { + case IDS_STRING_JSALERT: + return L"Alert"; + case IDS_STRING_JSPARAMERROR: + return L"Incorrect number of parameters passed to function."; + case IDS_STRING_JSAFNUMBER_KEYSTROKE: + return L"The input value is invalid."; + case IDS_STRING_JSPARAM_TOOLONG: + return L"The input value is too long."; + case IDS_STRING_JSPARSEDATE: + return L"The input value can't be parsed as a valid date/time (%s)."; + case IDS_STRING_JSRANGE1: + return L"The input value must be greater than or equal to %s" + L" and less than or equal to %s."; + case IDS_STRING_JSRANGE2: + return L"The input value must be greater than or equal to %s."; + case IDS_STRING_JSRANGE3: + return L"The input value must be less than or equal to %s."; + case IDS_STRING_JSNOTSUPPORT: + return L"Operation not supported."; + case IDS_STRING_JSBUSY: + return L"System is busy."; + case IDS_STRING_JSEVENT: + return L"Duplicate formfield event found."; + case IDS_STRING_RUN: + return L"Script ran successfully."; + case IDS_STRING_JSPRINT1: + return L"The second parameter can't be converted to a Date."; + case IDS_STRING_JSPRINT2: + return L"The second parameter is an invalid Date!"; + case IDS_STRING_JSNOGLOBAL: + return L"Global value not found."; + case IDS_STRING_JSREADONLY: + return L"Cannot assign to readonly property."; + case IDS_STRING_JSTYPEERROR: + return L"Incorrect parameter type."; + case IDS_STRING_JSVALUEERROR: + return L"Incorrect parameter value."; + case IDS_STRING_JSNOPERMISSION: + return L"Permission denied."; + case IDS_STRING_JSBADOBJECT: + return L"Object no longer exists."; + default: + return L""; + } +} + +WideString JSFormatErrorString(const char* class_name, + const char* property_name, + const WideString& details) { + WideString result = WideString::FromLocal(class_name); + if (property_name) { + result += L"."; + result += WideString::FromLocal(property_name); + } + result += L": "; + result += details; + return result; +} diff --git a/fpdfsdk/javascript/js_resources.h b/fpdfsdk/javascript/js_resources.h new file mode 100644 index 0000000000..e1c3d6ea18 --- /dev/null +++ b/fpdfsdk/javascript/js_resources.h @@ -0,0 +1,38 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef FPDFSDK_JAVASCRIPT_JS_RESOURCES_H_ +#define FPDFSDK_JAVASCRIPT_JS_RESOURCES_H_ + +#include "core/fxcrt/widestring.h" + +#define IDS_STRING_JSALERT 25613 +#define IDS_STRING_JSPARAMERROR 25614 +#define IDS_STRING_JSAFNUMBER_KEYSTROKE 25615 +#define IDS_STRING_JSPARAM_TOOLONG 25617 +#define IDS_STRING_JSPARSEDATE 25618 +#define IDS_STRING_JSRANGE1 25619 +#define IDS_STRING_JSRANGE2 25620 +#define IDS_STRING_JSRANGE3 25621 +#define IDS_STRING_JSNOTSUPPORT 25627 +#define IDS_STRING_JSBUSY 25628 +#define IDS_STRING_JSEVENT 25629 +#define IDS_STRING_RUN 25630 +#define IDS_STRING_JSPRINT1 25632 +#define IDS_STRING_JSPRINT2 25633 +#define IDS_STRING_JSNOGLOBAL 25635 +#define IDS_STRING_JSREADONLY 25636 +#define IDS_STRING_JSTYPEERROR 25637 +#define IDS_STRING_JSVALUEERROR 25638 +#define IDS_STRING_JSNOPERMISSION 25639 +#define IDS_STRING_JSBADOBJECT 25640 + +WideString JSGetStringFromID(uint32_t id); +WideString JSFormatErrorString(const char* class_name, + const char* property_name, + const WideString& details); + +#endif // FPDFSDK_JAVASCRIPT_JS_RESOURCES_H_ diff --git a/fpdfsdk/javascript/resource.cpp b/fpdfsdk/javascript/resource.cpp deleted file mode 100644 index 8ca5b2a3b7..0000000000 --- a/fpdfsdk/javascript/resource.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "fpdfsdk/javascript/resource.h" - -WideString JSGetStringFromID(uint32_t id) { - switch (id) { - case IDS_STRING_JSALERT: - return L"Alert"; - case IDS_STRING_JSPARAMERROR: - return L"Incorrect number of parameters passed to function."; - case IDS_STRING_JSAFNUMBER_KEYSTROKE: - return L"The input value is invalid."; - case IDS_STRING_JSPARAM_TOOLONG: - return L"The input value is too long."; - case IDS_STRING_JSPARSEDATE: - return L"The input value can't be parsed as a valid date/time (%s)."; - case IDS_STRING_JSRANGE1: - return L"The input value must be greater than or equal to %s" - L" and less than or equal to %s."; - case IDS_STRING_JSRANGE2: - return L"The input value must be greater than or equal to %s."; - case IDS_STRING_JSRANGE3: - return L"The input value must be less than or equal to %s."; - case IDS_STRING_JSNOTSUPPORT: - return L"Operation not supported."; - case IDS_STRING_JSBUSY: - return L"System is busy."; - case IDS_STRING_JSEVENT: - return L"Duplicate formfield event found."; - case IDS_STRING_RUN: - return L"Script ran successfully."; - case IDS_STRING_JSPRINT1: - return L"The second parameter can't be converted to a Date."; - case IDS_STRING_JSPRINT2: - return L"The second parameter is an invalid Date!"; - case IDS_STRING_JSNOGLOBAL: - return L"Global value not found."; - case IDS_STRING_JSREADONLY: - return L"Cannot assign to readonly property."; - case IDS_STRING_JSTYPEERROR: - return L"Incorrect parameter type."; - case IDS_STRING_JSVALUEERROR: - return L"Incorrect parameter value."; - case IDS_STRING_JSNOPERMISSION: - return L"Permission denied."; - case IDS_STRING_JSBADOBJECT: - return L"Object no longer exists."; - default: - return L""; - } -} - -WideString JSFormatErrorString(const char* class_name, - const char* property_name, - const WideString& details) { - WideString result = WideString::FromLocal(class_name); - if (property_name) { - result += L"."; - result += WideString::FromLocal(property_name); - } - result += L": "; - result += details; - return result; -} diff --git a/fpdfsdk/javascript/resource.h b/fpdfsdk/javascript/resource.h deleted file mode 100644 index 3891918259..0000000000 --- a/fpdfsdk/javascript/resource.h +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef FPDFSDK_JAVASCRIPT_RESOURCE_H_ -#define FPDFSDK_JAVASCRIPT_RESOURCE_H_ - -#include "core/fxcrt/fx_string.h" - -class CJS_EventContext; - -#define IDS_STRING_JSALERT 25613 -#define IDS_STRING_JSPARAMERROR 25614 -#define IDS_STRING_JSAFNUMBER_KEYSTROKE 25615 -#define IDS_STRING_JSPARAM_TOOLONG 25617 -#define IDS_STRING_JSPARSEDATE 25618 -#define IDS_STRING_JSRANGE1 25619 -#define IDS_STRING_JSRANGE2 25620 -#define IDS_STRING_JSRANGE3 25621 -#define IDS_STRING_JSNOTSUPPORT 25627 -#define IDS_STRING_JSBUSY 25628 -#define IDS_STRING_JSEVENT 25629 -#define IDS_STRING_RUN 25630 -#define IDS_STRING_JSPRINT1 25632 -#define IDS_STRING_JSPRINT2 25633 -#define IDS_STRING_JSNOGLOBAL 25635 -#define IDS_STRING_JSREADONLY 25636 -#define IDS_STRING_JSTYPEERROR 25637 -#define IDS_STRING_JSVALUEERROR 25638 -#define IDS_STRING_JSNOPERMISSION 25639 -#define IDS_STRING_JSBADOBJECT 25640 - -WideString JSGetStringFromID(uint32_t id); -WideString JSFormatErrorString(const char* class_name, - const char* property_name, - const WideString& details); - -#endif // FPDFSDK_JAVASCRIPT_RESOURCE_H_ diff --git a/fpdfsdk/javascript/util.cpp b/fpdfsdk/javascript/util.cpp index 29e3fd5fbc..3dd5eb6d91 100644 --- a/fpdfsdk/javascript/util.cpp +++ b/fpdfsdk/javascript/util.cpp @@ -21,7 +21,7 @@ #include "fpdfsdk/javascript/cjs_object.h" #include "fpdfsdk/javascript/cjs_publicmethods.h" #include "fpdfsdk/javascript/cjs_runtime.h" -#include "fpdfsdk/javascript/resource.h" +#include "fpdfsdk/javascript/js_resources.h" #if _FX_OS_ == _FX_OS_ANDROID_ #include -- cgit v1.2.3