summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fxjs/cjs_document.cpp149
-rw-r--r--fxjs/cjs_document.h4
2 files changed, 73 insertions, 80 deletions
diff --git a/fxjs/cjs_document.cpp b/fxjs/cjs_document.cpp
index 35bb240671..4d74768b1b 100644
--- a/fxjs/cjs_document.cpp
+++ b/fxjs/cjs_document.cpp
@@ -27,6 +27,79 @@
#include "fxjs/cjs_printparamsobj.h"
#include "fxjs/js_resources.h"
+namespace {
+
+#define ISLATINWORD(u) (u != 0x20 && u <= 0x28FF)
+
+int CountWords(CPDF_TextObject* pTextObj) {
+ if (!pTextObj)
+ return 0;
+
+ CPDF_Font* pFont = pTextObj->GetFont();
+ if (!pFont)
+ return 0;
+
+ bool bIsLatin = false;
+ int nWords = 0;
+ for (size_t i = 0, sz = pTextObj->CountChars(); i < sz; ++i) {
+ uint32_t charcode = CPDF_Font::kInvalidCharCode;
+ float kerning;
+
+ pTextObj->GetCharInfo(i, &charcode, &kerning);
+ WideString swUnicode = pFont->UnicodeFromCharCode(charcode);
+
+ uint16_t unicode = 0;
+ if (swUnicode.GetLength() > 0)
+ unicode = swUnicode[0];
+
+ if (ISLATINWORD(unicode) && bIsLatin)
+ continue;
+
+ bIsLatin = ISLATINWORD(unicode);
+ if (unicode != 0x20)
+ nWords++;
+ }
+
+ return nWords;
+}
+
+WideString GetObjWordStr(CPDF_TextObject* pTextObj, int nWordIndex) {
+ WideString swRet;
+
+ CPDF_Font* pFont = pTextObj->GetFont();
+ if (!pFont)
+ return L"";
+
+ int nWords = 0;
+ bool bIsLatin = false;
+
+ for (size_t i = 0, sz = pTextObj->CountChars(); i < sz; ++i) {
+ uint32_t charcode = CPDF_Font::kInvalidCharCode;
+ float kerning;
+
+ pTextObj->GetCharInfo(i, &charcode, &kerning);
+ WideString swUnicode = pFont->UnicodeFromCharCode(charcode);
+
+ uint16_t unicode = 0;
+ if (swUnicode.GetLength() > 0)
+ unicode = swUnicode[0];
+
+ if (ISLATINWORD(unicode) && bIsLatin) {
+ } else {
+ bIsLatin = ISLATINWORD(unicode);
+ if (unicode != 0x20)
+ nWords++;
+ }
+
+ if (nWords - 1 == nWordIndex)
+ swRet += unicode;
+ }
+
+ return swRet;
+}
+
+} // namespace
+
const JSPropertySpec CJS_Document::PropertySpecs[] = {
{"ADBE", get_ADBE_static, set_ADBE_static},
{"author", get_author_static, set_author_static},
@@ -1090,12 +1163,6 @@ CJS_Result CJS_Document::getLinks(
return CJS_Result::Success();
}
-bool CJS_Document::IsEnclosedInRect(CFX_FloatRect rect,
- CFX_FloatRect LinkRect) {
- return (rect.left <= LinkRect.left && rect.top <= LinkRect.top &&
- rect.right >= LinkRect.right && rect.bottom >= LinkRect.bottom);
-}
-
CJS_Result CJS_Document::addIcon(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
@@ -1310,76 +1377,6 @@ CJS_Result CJS_Document::getPrintParams(
return CJS_Result::Failure(JSMessage::kNotSupportedError);
}
-#define ISLATINWORD(u) (u != 0x20 && u <= 0x28FF)
-
-int CJS_Document::CountWords(CPDF_TextObject* pTextObj) {
- if (!pTextObj)
- return 0;
-
- CPDF_Font* pFont = pTextObj->GetFont();
- if (!pFont)
- return 0;
-
- bool bIsLatin = false;
- int nWords = 0;
- for (size_t i = 0, sz = pTextObj->CountChars(); i < sz; ++i) {
- uint32_t charcode = CPDF_Font::kInvalidCharCode;
- float kerning;
-
- pTextObj->GetCharInfo(i, &charcode, &kerning);
- WideString swUnicode = pFont->UnicodeFromCharCode(charcode);
-
- uint16_t unicode = 0;
- if (swUnicode.GetLength() > 0)
- unicode = swUnicode[0];
-
- if (ISLATINWORD(unicode) && bIsLatin)
- continue;
-
- bIsLatin = ISLATINWORD(unicode);
- if (unicode != 0x20)
- nWords++;
- }
-
- return nWords;
-}
-
-WideString CJS_Document::GetObjWordStr(CPDF_TextObject* pTextObj,
- int nWordIndex) {
- WideString swRet;
-
- CPDF_Font* pFont = pTextObj->GetFont();
- if (!pFont)
- return L"";
-
- int nWords = 0;
- bool bIsLatin = false;
-
- for (size_t i = 0, sz = pTextObj->CountChars(); i < sz; ++i) {
- uint32_t charcode = CPDF_Font::kInvalidCharCode;
- float kerning;
-
- pTextObj->GetCharInfo(i, &charcode, &kerning);
- WideString swUnicode = pFont->UnicodeFromCharCode(charcode);
-
- uint16_t unicode = 0;
- if (swUnicode.GetLength() > 0)
- unicode = swUnicode[0];
-
- if (ISLATINWORD(unicode) && bIsLatin) {
- } else {
- bIsLatin = ISLATINWORD(unicode);
- if (unicode != 0x20)
- nWords++;
- }
-
- if (nWords - 1 == nWordIndex)
- swRet += unicode;
- }
-
- return swRet;
-}
-
CJS_Result CJS_Document::get_zoom(CJS_Runtime* pRuntime) {
return CJS_Result::Success();
}
diff --git a/fxjs/cjs_document.h b/fxjs/cjs_document.h
index 0f25703f34..c74855ebb0 100644
--- a/fxjs/cjs_document.h
+++ b/fxjs/cjs_document.h
@@ -298,10 +298,6 @@ class CJS_Document final : public CJS_Object, public Observable<CJS_Document> {
CJS_Result removeIcon(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params);
- bool IsEnclosedInRect(CFX_FloatRect rect, CFX_FloatRect LinkRect);
- int CountWords(CPDF_TextObject* pTextObj);
- WideString GetObjWordStr(CPDF_TextObject* pTextObj, int nWordIndex);
-
CJS_Result getPropertyInternal(CJS_Runtime* pRuntime,
const ByteString& propName);
CJS_Result setPropertyInternal(CJS_Runtime* pRuntime,