summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-07-24 08:57:35 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-07-24 13:32:10 +0000
commitc08dc39850188d96ad81f5800c7a51d2663eeb44 (patch)
tree9e132af2dd7989ea3375013c1109dd6dadb4cd55
parent677275efd05ce5dcbbd62f474db1f0a59e45cce8 (diff)
downloadpdfium-c08dc39850188d96ad81f5800c7a51d2663eeb44.tar.xz
Remove fx_edit.h
This CL moves GetPDFWordString to be a method on CFX_Edit. The FX_EDIT_ISLATINWORD define is moved into fx_edit.h. CFWL_Edit::FX_EDIT_ISLATINWORD is renamed to FxEditIsLatinWord to make less confusing with the define. Change-Id: I47d12d41447b268894a1d0376ac4b2bdb409e2df Reviewed-on: https://pdfium-review.googlesource.com/8531 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
-rw-r--r--BUILD.gn2
-rw-r--r--fpdfsdk/fxedit/fx_edit.h23
-rw-r--r--fpdfsdk/fxedit/fxet_ap.cpp36
-rw-r--r--fpdfsdk/fxedit/fxet_edit.cpp36
-rw-r--r--fpdfsdk/fxedit/fxet_edit.h9
-rw-r--r--fpdfsdk/fxedit/fxet_list.h2
-rw-r--r--fpdfsdk/pdfwindow/cpwl_appstream.cpp7
-rw-r--r--fpdfsdk/pdfwindow/cpwl_font_map.h1
-rw-r--r--fpdfsdk/pdfwindow/cpwl_list_box.h1
-rw-r--r--xfa/fwl/cfwl_edit.cpp4
10 files changed, 44 insertions, 77 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 80a258ea45..313714d668 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1079,8 +1079,6 @@ static_library("fxge") {
static_library("fxedit") {
sources = [
- "fpdfsdk/fxedit/fx_edit.h",
- "fpdfsdk/fxedit/fxet_ap.cpp",
"fpdfsdk/fxedit/fxet_edit.cpp",
"fpdfsdk/fxedit/fxet_edit.h",
"fpdfsdk/fxedit/fxet_list.cpp",
diff --git a/fpdfsdk/fxedit/fx_edit.h b/fpdfsdk/fxedit/fx_edit.h
deleted file mode 100644
index 6c9166709c..0000000000
--- a/fpdfsdk/fxedit/fx_edit.h
+++ /dev/null
@@ -1,23 +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_FXEDIT_FX_EDIT_H_
-#define FPDFSDK_FXEDIT_FX_EDIT_H_
-
-#include "core/fxcrt/fx_basic.h"
-
-class IPVT_FontMap;
-
-#define FX_EDIT_ISLATINWORD(u) \
- (u == 0x2D || (u <= 0x005A && u >= 0x0041) || \
- (u <= 0x007A && u >= 0x0061) || (u <= 0x02AF && u >= 0x00C0))
-
-CFX_ByteString GetPDFWordString(IPVT_FontMap* pFontMap,
- int32_t nFontIndex,
- uint16_t Word,
- uint16_t SubWord);
-
-#endif // FPDFSDK_FXEDIT_FX_EDIT_H_
diff --git a/fpdfsdk/fxedit/fxet_ap.cpp b/fpdfsdk/fxedit/fxet_ap.cpp
deleted file mode 100644
index 1576efa89a..0000000000
--- a/fpdfsdk/fxedit/fxet_ap.cpp
+++ /dev/null
@@ -1,36 +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 "core/fpdfapi/font/cpdf_font.h"
-#include "core/fpdfapi/parser/fpdf_parser_decode.h"
-#include "core/fpdfdoc/cpvt_word.h"
-#include "core/fpdfdoc/ipvt_fontmap.h"
-#include "fpdfsdk/fxedit/fx_edit.h"
-#include "fpdfsdk/fxedit/fxet_edit.h"
-
-CFX_ByteString GetPDFWordString(IPVT_FontMap* pFontMap,
- int32_t nFontIndex,
- uint16_t Word,
- uint16_t SubWord) {
- CPDF_Font* pPDFFont = pFontMap->GetPDFFont(nFontIndex);
- if (!pPDFFont)
- return CFX_ByteString();
-
- CFX_ByteString sWord;
- if (SubWord > 0) {
- Word = SubWord;
- } else {
- uint32_t dwCharCode = pPDFFont->IsUnicodeCompatible()
- ? pPDFFont->CharCodeFromUnicode(Word)
- : pFontMap->CharCodeFromUnicode(nFontIndex, Word);
- if (dwCharCode > 0) {
- pPDFFont->AppendChar(&sWord, dwCharCode);
- return sWord;
- }
- }
- pPDFFont->AppendChar(&sWord, Word);
- return sWord;
-}
diff --git a/fpdfsdk/fxedit/fxet_edit.cpp b/fpdfsdk/fxedit/fxet_edit.cpp
index 96868d03c1..6c4595408f 100644
--- a/fpdfsdk/fxedit/fxet_edit.cpp
+++ b/fpdfsdk/fxedit/fxet_edit.cpp
@@ -27,7 +27,6 @@
#include "core/fxge/cfx_pathdata.h"
#include "core/fxge/cfx_renderdevice.h"
#include "fpdfsdk/cfx_systemhandler.h"
-#include "fpdfsdk/fxedit/fx_edit.h"
#include "fpdfsdk/pdfwindow/cpwl_edit.h"
#include "fpdfsdk/pdfwindow/cpwl_edit_ctrl.h"
#include "fpdfsdk/pdfwindow/cpwl_scroll_bar.h"
@@ -586,14 +585,15 @@ void CFX_Edit::DrawEdit(CFX_RenderDevice* pDevice,
crOldFill = crCurFill;
}
- sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word,
- SubWord);
+ sTextBuf << pEdit->GetPDFWordString(word.nFontIndex, word.Word,
+ SubWord);
} else {
DrawTextString(
- pDevice, CFX_PointF(word.ptWord.x + ptOffset.x,
- word.ptWord.y + ptOffset.y),
+ pDevice,
+ CFX_PointF(word.ptWord.x + ptOffset.x,
+ word.ptWord.y + ptOffset.y),
pFontMap->GetPDFFont(word.nFontIndex), fFontSize, pUser2Device,
- GetPDFWordString(pFontMap, word.nFontIndex, word.Word, SubWord),
+ pEdit->GetPDFWordString(word.nFontIndex, word.Word, SubWord),
crCurFill, nHorzScale);
}
oldplace = place;
@@ -1937,6 +1937,30 @@ void CFX_Edit::AddEditUndoItem(
m_Undo.AddItem(std::move(pEditUndoItem));
}
+CFX_ByteString CFX_Edit::GetPDFWordString(int32_t nFontIndex,
+ uint16_t Word,
+ uint16_t SubWord) {
+ IPVT_FontMap* pFontMap = GetFontMap();
+ CPDF_Font* pPDFFont = pFontMap->GetPDFFont(nFontIndex);
+ if (!pPDFFont)
+ return CFX_ByteString();
+
+ CFX_ByteString sWord;
+ if (SubWord > 0) {
+ Word = SubWord;
+ } else {
+ uint32_t dwCharCode = pPDFFont->IsUnicodeCompatible()
+ ? pPDFFont->CharCodeFromUnicode(Word)
+ : pFontMap->CharCodeFromUnicode(nFontIndex, Word);
+ if (dwCharCode > 0) {
+ pPDFFont->AppendChar(&sWord, dwCharCode);
+ return sWord;
+ }
+ }
+ pPDFFont->AppendChar(&sWord, Word);
+ return sWord;
+}
+
CFX_Edit_LineRectArray::CFX_Edit_LineRectArray() {}
CFX_Edit_LineRectArray::~CFX_Edit_LineRectArray() {}
diff --git a/fpdfsdk/fxedit/fxet_edit.h b/fpdfsdk/fxedit/fxet_edit.h
index bb5246226d..4aaee69f96 100644
--- a/fpdfsdk/fxedit/fxet_edit.h
+++ b/fpdfsdk/fxedit/fxet_edit.h
@@ -14,7 +14,10 @@
#include "core/fpdfdoc/cpvt_secprops.h"
#include "core/fpdfdoc/cpvt_wordprops.h"
#include "core/fxcrt/cfx_unowned_ptr.h"
-#include "fpdfsdk/fxedit/fx_edit.h"
+
+#define FX_EDIT_ISLATINWORD(u) \
+ (u == 0x2D || (u <= 0x005A && u >= 0x0041) || \
+ (u <= 0x007A && u >= 0x0061) || (u <= 0x02AF && u >= 0x00C0))
class CFFL_FormFiller;
class CFX_Edit;
@@ -388,6 +391,10 @@ class CFX_Edit {
int32_t GetTotalLines() const;
+ CFX_ByteString GetPDFWordString(int32_t nFontIndex,
+ uint16_t Word,
+ uint16_t SubWord);
+
private:
friend class CFX_Edit_Iterator;
friend class CFXEU_InsertWord;
diff --git a/fpdfsdk/fxedit/fxet_list.h b/fpdfsdk/fxedit/fxet_list.h
index 6a37d6125a..83b8d9e865 100644
--- a/fpdfsdk/fxedit/fxet_list.h
+++ b/fpdfsdk/fxedit/fxet_list.h
@@ -13,11 +13,11 @@
#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_coordinates.h"
-#include "fpdfsdk/fxedit/fx_edit.h"
class CFX_Edit;
class CFX_Edit_Iterator;
class CPWL_List_Notify;
+class IPVT_FontMap;
class CPLST_Select {
public:
diff --git a/fpdfsdk/pdfwindow/cpwl_appstream.cpp b/fpdfsdk/pdfwindow/cpwl_appstream.cpp
index 969c521d68..f7ba4c465c 100644
--- a/fpdfsdk/pdfwindow/cpwl_appstream.cpp
+++ b/fpdfsdk/pdfwindow/cpwl_appstream.cpp
@@ -577,8 +577,7 @@ CFX_ByteString GetEditAppStream(CFX_Edit* pEdit,
nCurFontIndex = word.nFontIndex;
}
- sWords << GetPDFWordString(pEdit->GetFontMap(), nCurFontIndex,
- word.Word, SubWord);
+ sWords << pEdit->GetPDFWordString(nCurFontIndex, word.Word, SubWord);
}
oldplace = place;
@@ -600,8 +599,8 @@ CFX_ByteString GetEditAppStream(CFX_Edit* pEdit,
nCurFontIndex = word.nFontIndex;
}
- sEditStream << GetWordRenderString(GetPDFWordString(
- pEdit->GetFontMap(), nCurFontIndex, word.Word, SubWord));
+ sEditStream << GetWordRenderString(
+ pEdit->GetPDFWordString(nCurFontIndex, word.Word, SubWord));
}
}
}
diff --git a/fpdfsdk/pdfwindow/cpwl_font_map.h b/fpdfsdk/pdfwindow/cpwl_font_map.h
index de7a944425..e1a3edeb79 100644
--- a/fpdfsdk/pdfwindow/cpwl_font_map.h
+++ b/fpdfsdk/pdfwindow/cpwl_font_map.h
@@ -13,7 +13,6 @@
#include "core/fpdfdoc/ipvt_fontmap.h"
#include "core/fxcrt/fx_codepage.h"
#include "core/fxge/fx_font.h"
-#include "fpdfsdk/fxedit/fx_edit.h"
#include "public/fpdf_sysfontinfo.h"
class CPDF_Document;
diff --git a/fpdfsdk/pdfwindow/cpwl_list_box.h b/fpdfsdk/pdfwindow/cpwl_list_box.h
index 8bc7651ada..f41a6dd87f 100644
--- a/fpdfsdk/pdfwindow/cpwl_list_box.h
+++ b/fpdfsdk/pdfwindow/cpwl_list_box.h
@@ -10,7 +10,6 @@
#include <memory>
#include "core/fxcrt/cfx_unowned_ptr.h"
-#include "fpdfsdk/fxedit/fx_edit.h"
#include "fpdfsdk/pdfwindow/cpwl_wnd.h"
class CFX_ListCtrl;
diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp
index acefd3a964..12786496d4 100644
--- a/xfa/fwl/cfwl_edit.cpp
+++ b/xfa/fwl/cfwl_edit.cpp
@@ -38,7 +38,7 @@ namespace {
const int kEditMargin = 3;
-bool FX_EDIT_ISLATINWORD(wchar_t c) {
+bool FxEditIsLatinWord(wchar_t c) {
return c == 0x2D || (c <= 0x005A && c >= 0x0041) ||
(c <= 0x007A && c >= 0x0061) || (c <= 0x02AF && c >= 0x00C0) ||
c == 0x0027;
@@ -200,7 +200,7 @@ void CFWL_Edit::DrawSpellCheck(CXFA_Graphics* pGraphics,
CFX_WideString wsSpell = GetText();
int32_t nContentLen = wsSpell.GetLength();
for (int i = 0; i < nContentLen; i++) {
- if (FX_EDIT_ISLATINWORD(wsSpell[i])) {
+ if (FxEditIsLatinWord(wsSpell[i])) {
if (sLatinWord.IsEmpty())
nStart = i;
sLatinWord += (char)wsSpell[i];