summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-02-17 10:07:21 -0800
committerTom Sepez <tsepez@chromium.org>2016-02-17 10:07:21 -0800
commitab27768d235985c0789a10ab490be43e262f48f6 (patch)
tree692c2707020bee87753c05208c7d0c6f176ff30b
parent32c70815316672091946be88e5941089c359d151 (diff)
downloadpdfium-ab27768d235985c0789a10ab490be43e262f48f6.tar.xz
Banish CFX_ByteArray and CFX_WideArray to the XFA side.
Fix IWYU and include paths as we go. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1701883004 .
-rw-r--r--core/include/fpdfdoc/fpdf_doc.h2
-rw-r--r--core/include/fxcrt/fx_basic.h2
-rw-r--r--core/include/fxge/fx_font.h23
-rw-r--r--core/include/fxge/fx_ge.h4
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp18
-rw-r--r--core/src/fpdfdoc/doc_form.cpp11
-rw-r--r--core/src/fpdftext/fpdf_text_int.cpp20
-rw-r--r--core/src/fpdftext/text_int.h2
-rw-r--r--core/src/fxge/ge/fx_ge_fontmap.cpp24
-rw-r--r--fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h4
-rw-r--r--fpdfsdk/include/fsdk_mgr.h2
-rw-r--r--fpdfsdk/include/pdfwindow/PWL_Wnd.h4
-rw-r--r--fpdfsdk/src/fpdfformfill.cpp68
-rw-r--r--fpdfsdk/src/fsdk_mgr.cpp9
-rw-r--r--fpdfsdk/src/javascript/PublicMethods.cpp8
-rw-r--r--fpdfsdk/src/pdfwindow/PWL_Edit.cpp8
-rw-r--r--xfa/include/fwl/basewidget/fwl_edit.h21
-rw-r--r--xfa/include/fwl/lightwidget/edit.h18
-rw-r--r--xfa/include/fxfa/fxfa.h6
-rw-r--r--xfa/src/fwl/src/basewidget/fwl_editimp.cpp4
-rw-r--r--xfa/src/fwl/src/basewidget/include/fwl_editimp.h17
-rw-r--r--xfa/src/fwl/src/lightwidget/edit.cpp2
-rw-r--r--xfa/src/fxfa/src/app/xfa_fftextedit.cpp10
-rw-r--r--xfa/src/fxfa/src/app/xfa_fftextedit.h88
-rw-r--r--xfa/src/fxfa/src/app/xfa_ffwidget.h11
-rw-r--r--xfa/src/fxfa/src/app/xfa_ffwidgethandler.cpp11
-rw-r--r--xfa/src/fxfa/src/app/xfa_ffwidgethandler.h16
27 files changed, 227 insertions, 186 deletions
diff --git a/core/include/fpdfdoc/fpdf_doc.h b/core/include/fpdfdoc/fpdf_doc.h
index 7ade012bf0..17f2c824c6 100644
--- a/core/include/fpdfdoc/fpdf_doc.h
+++ b/core/include/fpdfdoc/fpdf_doc.h
@@ -563,8 +563,6 @@ class CPDF_InterForm : public CFX_PrivateData {
CPDF_FormField* GetField(FX_DWORD index,
const CFX_WideString& csFieldName = L"");
- void GetAllFieldNames(CFX_WideStringArray& allFieldNames);
-
CPDF_FormField* GetFieldByDict(CPDF_Dictionary* pFieldDict) const;
CPDF_FormControl* GetControlAtPoint(CPDF_Page* pPage,
diff --git a/core/include/fxcrt/fx_basic.h b/core/include/fxcrt/fx_basic.h
index 95927c38f2..7099e28447 100644
--- a/core/include/fxcrt/fx_basic.h
+++ b/core/include/fxcrt/fx_basic.h
@@ -545,9 +545,9 @@ class CFX_ObjectArray : public CFX_BasicArray {
CFX_BasicArray::SetSize(0);
}
};
+#ifdef PDF_ENABLE_XFA
typedef CFX_ObjectArray<CFX_ByteString> CFX_ByteStringArray;
typedef CFX_ObjectArray<CFX_WideString> CFX_WideStringArray;
-#ifdef PDF_ENABLE_XFA
class CFX_BaseSegmentedArray {
public:
CFX_BaseSegmentedArray(int unit_size = 1,
diff --git a/core/include/fxge/fx_font.h b/core/include/fxge/fx_font.h
index f2db4a1dc0..044e949ca4 100644
--- a/core/include/fxge/fx_font.h
+++ b/core/include/fxge/fx_font.h
@@ -9,9 +9,10 @@
#include <map>
#include <memory>
+#include <vector>
#include "core/include/fxcrt/fx_system.h"
-#include "fx_dib.h"
+#include "core/include/fxge/fx_dib.h"
typedef struct FT_FaceRec_* FXFT_Face;
typedef void* FXFT_Library;
@@ -306,7 +307,7 @@ class CFX_FontMapper {
IFX_SystemFontInfo* GetSystemFontInfo() { return m_pFontInfo; }
void AddInstalledFont(const CFX_ByteString& name, int charset);
void LoadInstalledFonts();
- CFX_ByteStringArray m_InstalledTTFonts;
+ std::vector<CFX_ByteString> m_InstalledTTFonts;
void SetFontEnumerator(IFX_FontEnumerator* pFontEnumerator) {
m_pFontEnumerator = pFontEnumerator;
}
@@ -325,7 +326,7 @@ class CFX_FontMapper {
int italic_angle);
#endif // PDF_ENABLE_XFA
FX_BOOL IsBuiltinFace(const FXFT_Face face) const;
- int GetFaceSize() const { return m_FaceArray.GetSize(); }
+ int GetFaceSize() const;
CFX_ByteString GetFaceName(int index) const { return m_FaceArray[index]; }
private:
@@ -344,7 +345,7 @@ class CFX_FontMapper {
FXFT_Face m_MMFaces[MM_FACE_COUNT];
CFX_ByteString m_LastFamily;
CFX_DWordArray m_CharsetArray;
- CFX_ByteStringArray m_FaceArray;
+ std::vector<CFX_ByteString> m_FaceArray;
IFX_SystemFontInfo* m_pFontInfo;
FXFT_Face m_FoxitFaces[FOXIT_FACE_COUNT];
IFX_FontEnumerator* m_pFontEnumerator;
@@ -417,12 +418,9 @@ class CFX_FolderFontInfo : public IFX_SystemFontInfo {
FX_BOOL GetFontCharset(void* hFont, int& charset) override;
protected:
- std::map<CFX_ByteString, CFX_FontFaceInfo*> m_FontList;
- CFX_ByteStringArray m_PathList;
- CFX_FontMapper* m_pMapper;
- void ScanPath(CFX_ByteString& path);
- void ScanFile(CFX_ByteString& path);
- void ReportFace(CFX_ByteString& path,
+ void ScanPath(const CFX_ByteString& path);
+ void ScanFile(const CFX_ByteString& path);
+ void ReportFace(const CFX_ByteString& path,
FXSYS_FILE* pFile,
FX_DWORD filesize,
FX_DWORD offset);
@@ -433,7 +431,12 @@ class CFX_FolderFontInfo : public IFX_SystemFontInfo {
int pitch_family,
const FX_CHAR* family,
FX_BOOL bMatchName);
+
+ std::map<CFX_ByteString, CFX_FontFaceInfo*> m_FontList;
+ std::vector<CFX_ByteString> m_PathList;
+ CFX_FontMapper* m_pMapper;
};
+
class CFX_CountedFaceCache {
public:
CFX_FaceCache* m_Obj;
diff --git a/core/include/fxge/fx_ge.h b/core/include/fxge/fx_ge.h
index 01a1c72a8f..ebcdea1483 100644
--- a/core/include/fxge/fx_ge.h
+++ b/core/include/fxge/fx_ge.h
@@ -7,8 +7,8 @@
#ifndef CORE_INCLUDE_FXGE_FX_GE_H_
#define CORE_INCLUDE_FXGE_FX_GE_H_
-#include "fx_dib.h"
-#include "fx_font.h"
+#include "core/include/fxge/fx_dib.h"
+#include "core/include/fxge/fx_font.h"
class CFX_Font;
class CFX_FontMgr;
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
index d3ef4d738a..7c1c6b1f53 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
@@ -10,6 +10,7 @@
#include "core/include/fpdfapi/fpdf_parser.h"
#include "core/include/fxcodec/fx_codec.h"
#include "core/include/fxcrt/fx_ext.h"
+#include "third_party/base/stl_util.h"
#define _STREAM_MAX_SIZE_ 20 * 1024 * 1024
@@ -339,7 +340,7 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf,
CPDF_Object* pParams =
pDict ? pDict->GetElementValue("DecodeParms") : nullptr;
- CFX_ByteStringArray DecoderList;
+ std::vector<CFX_ByteString> DecoderList;
CFX_ArrayTemplate<CPDF_Object*> ParamList;
if (CPDF_Array* pDecoders = pDecoder->AsArray()) {
CPDF_Array* pParamsArray = ToArray(pParams);
@@ -347,19 +348,18 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf,
pParams = nullptr;
for (FX_DWORD i = 0; i < pDecoders->GetCount(); i++) {
- CFX_ByteStringC str = pDecoders->GetConstStringAt(i);
- DecoderList.Add(str);
+ DecoderList.push_back(pDecoders->GetConstStringAt(i));
ParamList.Add(pParams ? pParamsArray->GetDictAt(i) : nullptr);
}
} else {
- DecoderList.Add(pDecoder->GetConstString());
+ DecoderList.push_back(pDecoder->GetConstString());
ParamList.Add(pParams ? pParams->GetDict() : nullptr);
}
uint8_t* last_buf = (uint8_t*)src_buf;
FX_DWORD last_size = src_size;
- for (int i = 0; i < DecoderList.GetSize(); i++) {
- int estimated_size =
- i == DecoderList.GetSize() - 1 ? last_estimated_size : 0;
+ int nSize = pdfium::CollectionSize<int>(DecoderList);
+ for (int i = 0; i < nSize; i++) {
+ int estimated_size = i == nSize - 1 ? last_estimated_size : 0;
CFX_ByteString decoder = DecoderList[i];
// Use ToDictionary here because we can push nullptr into the ParamList.
CPDF_Dictionary* pParam = ToDictionary(ParamList[i]);
@@ -367,7 +367,7 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf,
FX_DWORD new_size = (FX_DWORD)-1;
int offset = -1;
if (decoder == "FlateDecode" || decoder == "Fl") {
- if (bImageAcc && i == DecoderList.GetSize() - 1) {
+ if (bImageAcc && i == nSize - 1) {
ImageEncoding = "FlateDecode";
dest_buf = (uint8_t*)last_buf;
dest_size = last_size;
@@ -384,7 +384,7 @@ FX_BOOL PDF_DataDecode(const uint8_t* src_buf,
} else if (decoder == "ASCIIHexDecode" || decoder == "AHx") {
offset = HexDecode(last_buf, last_size, new_buf, new_size);
} else if (decoder == "RunLengthDecode" || decoder == "RL") {
- if (bImageAcc && i == DecoderList.GetSize() - 1) {
+ if (bImageAcc && i == nSize - 1) {
ImageEncoding = "RunLengthDecode";
dest_buf = (uint8_t*)last_buf;
dest_size = last_size;
diff --git a/core/src/fpdfdoc/doc_form.cpp b/core/src/fpdfdoc/doc_form.cpp
index 5cfad3f068..b4735bed41 100644
--- a/core/src/fpdfdoc/doc_form.cpp
+++ b/core/src/fpdfdoc/doc_form.cpp
@@ -663,17 +663,6 @@ CPDF_FormField* CPDF_InterForm::GetField(FX_DWORD index,
CFieldTree::_Node* pNode = m_pFieldTree->FindNode(csFieldName);
return pNode ? pNode->GetField(index) : nullptr;
}
-void CPDF_InterForm::GetAllFieldNames(CFX_WideStringArray& allFieldNames) {
- allFieldNames.RemoveAll();
- int nCount = m_pFieldTree->m_Root.CountFields();
- for (int i = 0; i < nCount; i++) {
- CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i);
- if (pField) {
- CFX_WideString full_name = GetFullName(pField->GetFieldDict());
- allFieldNames.Add(full_name);
- }
- }
-}
CPDF_FormField* CPDF_InterForm::GetFieldByDict(
CPDF_Dictionary* pFieldDict) const {
diff --git a/core/src/fpdftext/fpdf_text_int.cpp b/core/src/fpdftext/fpdf_text_int.cpp
index b6e39de004..aa13acee8a 100644
--- a/core/src/fpdftext/fpdf_text_int.cpp
+++ b/core/src/fpdftext/fpdf_text_int.cpp
@@ -1988,7 +1988,7 @@ FX_BOOL CPDF_TextPageFind::FindFirst(const CFX_WideString& findwhat,
} else {
m_findPreStart = startPos;
}
- m_csFindWhatArray.RemoveAll();
+ m_csFindWhatArray.clear();
int i = 0;
while (i < len) {
if (findwhatStr.GetAt(i) != ' ') {
@@ -1999,9 +1999,9 @@ FX_BOOL CPDF_TextPageFind::FindFirst(const CFX_WideString& findwhat,
if (i < len) {
ExtractFindWhat(findwhatStr);
} else {
- m_csFindWhatArray.Add(findwhatStr);
+ m_csFindWhatArray.push_back(findwhatStr);
}
- if (m_csFindWhatArray.GetSize() <= 0) {
+ if (m_csFindWhatArray.empty()) {
return FALSE;
}
m_IsFind = TRUE;
@@ -2027,7 +2027,7 @@ FX_BOOL CPDF_TextPageFind::FindNext() {
m_IsFind = FALSE;
return m_IsFind;
}
- int nCount = m_csFindWhatArray.GetSize();
+ int nCount = pdfium::CollectionSize<int>(m_csFindWhatArray);
int nResultPos = 0;
int nStartPos = 0;
nStartPos = m_findNextStart;
@@ -2102,8 +2102,7 @@ FX_BOOL CPDF_TextPageFind::FindNext() {
}
}
}
- m_resEnd = nResultPos +
- m_csFindWhatArray[m_csFindWhatArray.GetSize() - 1].GetLength() - 1;
+ m_resEnd = nResultPos + m_csFindWhatArray.back().GetLength() - 1;
m_IsFind = TRUE;
int resStart = GetCharIndex(m_resStart);
int resEnd = GetCharIndex(m_resEnd);
@@ -2175,7 +2174,7 @@ void CPDF_TextPageFind::ExtractFindWhat(const CFX_WideString& findwhat) {
ExtractSubString(csWord, findwhat.c_str(), index, TEXT_BLANK_CHAR);
if (csWord.IsEmpty()) {
if (ret) {
- m_csFindWhatArray.Add(CFX_WideString(L""));
+ m_csFindWhatArray.push_back(L"");
index++;
continue;
} else {
@@ -2192,10 +2191,9 @@ void CPDF_TextPageFind::ExtractFindWhat(const CFX_WideString& findwhat) {
continue;
}
if (pos > 0) {
- CFX_WideString preStr = csWord.Mid(0, pos);
- m_csFindWhatArray.Add(preStr);
+ m_csFindWhatArray.push_back(csWord.Mid(0, pos));
}
- m_csFindWhatArray.Add(curStr);
+ m_csFindWhatArray.push_back(curStr);
if (pos == csWord.GetLength() - 1) {
csWord.Empty();
break;
@@ -2207,7 +2205,7 @@ void CPDF_TextPageFind::ExtractFindWhat(const CFX_WideString& findwhat) {
pos++;
}
if (!csWord.IsEmpty()) {
- m_csFindWhatArray.Add(csWord);
+ m_csFindWhatArray.push_back(csWord);
}
index++;
}
diff --git a/core/src/fpdftext/text_int.h b/core/src/fpdftext/text_int.h
index edde651ddb..9b7d654930 100644
--- a/core/src/fpdftext/text_int.h
+++ b/core/src/fpdftext/text_int.h
@@ -186,7 +186,7 @@ class CPDF_TextPageFind : public IPDF_TextPageFind {
CFX_WideString m_strText;
CFX_WideString m_findWhat;
int m_flags;
- CFX_WideStringArray m_csFindWhatArray;
+ std::vector<CFX_WideString> m_csFindWhatArray;
int m_findNextStart;
int m_findPreStart;
FX_BOOL m_bMatchCase;
diff --git a/core/src/fxge/ge/fx_ge_fontmap.cpp b/core/src/fxge/ge/fx_ge_fontmap.cpp
index f624d5abd6..b9850f85db 100644
--- a/core/src/fxge/ge/fx_ge_fontmap.cpp
+++ b/core/src/fxge/ge/fx_ge_fontmap.cpp
@@ -724,7 +724,7 @@ void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) {
}
if (m_CharsetArray.Find((FX_DWORD)charset) == -1) {
m_CharsetArray.Add((FX_DWORD)charset);
- m_FaceArray.Add(name);
+ m_FaceArray.push_back(name);
}
if (name == m_LastFamily) {
return;
@@ -749,11 +749,11 @@ void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) {
CFX_ByteString new_name = GetPSNameFromTT(hFont);
if (!new_name.IsEmpty()) {
new_name.Insert(0, ' ');
- m_InstalledTTFonts.Add(new_name);
+ m_InstalledTTFonts.push_back(new_name);
}
m_pFontInfo->DeleteFont(hFont);
}
- m_InstalledTTFonts.Add(name);
+ m_InstalledTTFonts.push_back(name);
m_LastFamily = name;
}
void CFX_FontMapper::LoadInstalledFonts() {
@@ -773,7 +773,7 @@ CFX_ByteString CFX_FontMapper::MatchInstalledFonts(
const CFX_ByteString& norm_name) {
LoadInstalledFonts();
int i;
- for (i = m_InstalledTTFonts.GetSize() - 1; i >= 0; i--) {
+ for (i = pdfium::CollectionSize<int>(m_InstalledTTFonts) - 1; i >= 0; i--) {
CFX_ByteString norm1 = TT_NormalizeName(m_InstalledTTFonts[i]);
if (norm1 == norm_name) {
break;
@@ -1288,6 +1288,10 @@ FXFT_Face CFX_FontMapper::FindSubstFontByUnicode(FX_DWORD dwUnicode,
}
#endif // PDF_ENABLE_XFA
+int CFX_FontMapper::GetFaceSize() const {
+ return pdfium::CollectionSize<int>(m_FaceArray);
+}
+
FX_BOOL CFX_FontMapper::IsBuiltinFace(const FXFT_Face face) const {
for (int i = 0; i < MM_FACE_COUNT; ++i) {
if (m_MMFaces[i] == face) {
@@ -1321,19 +1325,19 @@ CFX_FolderFontInfo::~CFX_FolderFontInfo() {
}
}
void CFX_FolderFontInfo::AddPath(const CFX_ByteStringC& path) {
- m_PathList.Add(path);
+ m_PathList.push_back(path);
}
void CFX_FolderFontInfo::Release() {
delete this;
}
FX_BOOL CFX_FolderFontInfo::EnumFontList(CFX_FontMapper* pMapper) {
m_pMapper = pMapper;
- for (int i = 0; i < m_PathList.GetSize(); i++) {
- ScanPath(m_PathList[i]);
+ for (const auto& path : m_PathList) {
+ ScanPath(path);
}
return TRUE;
}
-void CFX_FolderFontInfo::ScanPath(CFX_ByteString& path) {
+void CFX_FolderFontInfo::ScanPath(const CFX_ByteString& path) {
void* handle = FX_OpenFolder(path);
if (!handle) {
return;
@@ -1367,7 +1371,7 @@ void CFX_FolderFontInfo::ScanPath(CFX_ByteString& path) {
}
FX_CloseFolder(handle);
}
-void CFX_FolderFontInfo::ScanFile(CFX_ByteString& path) {
+void CFX_FolderFontInfo::ScanFile(const CFX_ByteString& path) {
FXSYS_FILE* pFile = FXSYS_fopen(path, "rb");
if (!pFile) {
return;
@@ -1406,7 +1410,7 @@ void CFX_FolderFontInfo::ScanFile(CFX_ByteString& path) {
}
FXSYS_fclose(pFile);
}
-void CFX_FolderFontInfo::ReportFace(CFX_ByteString& path,
+void CFX_FolderFontInfo::ReportFace(const CFX_ByteString& path,
FXSYS_FILE* pFile,
FX_DWORD filesize,
FX_DWORD offset) {
diff --git a/fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h b/fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h
index 64b3875629..eb064d2682 100644
--- a/fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h
+++ b/fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h
@@ -7,6 +7,8 @@
#ifndef FPDFXFA_DOC_H_
#define FPDFXFA_DOC_H_
+#include <vector>
+
#include "public/fpdfview.h"
#include "xfa/include/fxfa/fxfa.h"
@@ -161,7 +163,7 @@ class CPDFXFA_Document : public IXFA_DocProvider {
}
virtual FX_BOOL GetSuggestWords(IXFA_Doc* hDoc,
const CFX_ByteStringC& sWord,
- CFX_ByteStringArray& sSuggest) {
+ std::vector<CFX_ByteString>& sSuggest) {
return FALSE;
}
diff --git a/fpdfsdk/include/fsdk_mgr.h b/fpdfsdk/include/fsdk_mgr.h
index bef3b980fe..5fdf645306 100644
--- a/fpdfsdk/include/fsdk_mgr.h
+++ b/fpdfsdk/include/fsdk_mgr.h
@@ -378,7 +378,7 @@ class CPDFDoc_Environment final {
FPDF_BOOL FFI_ShowFileDialog(const FX_WCHAR* wsTitle,
const FX_WCHAR* wsFilter,
- CFX_WideStringArray& wsPathArr,
+ std::vector<CFX_WideString>& wsPathArr,
FX_BOOL bOpen) {
return FALSE;
}
diff --git a/fpdfsdk/include/pdfwindow/PWL_Wnd.h b/fpdfsdk/include/pdfwindow/PWL_Wnd.h
index 058057bb76..1bc5023c98 100644
--- a/fpdfsdk/include/pdfwindow/PWL_Wnd.h
+++ b/fpdfsdk/include/pdfwindow/PWL_Wnd.h
@@ -7,6 +7,8 @@
#ifndef FPDFSDK_INCLUDE_PDFWINDOW_PWL_WND_H_
#define FPDFSDK_INCLUDE_PDFWINDOW_PWL_WND_H_
+#include <vector>
+
#include "core/include/fpdfdoc/fpdf_doc.h"
#include "core/include/fxcrt/fx_basic.h"
#include "fpdfsdk/include/fx_systemhandler.h"
@@ -171,7 +173,7 @@ class IPWL_SpellCheck {
virtual ~IPWL_SpellCheck() {}
virtual FX_BOOL CheckWord(const FX_CHAR* sWord) = 0;
virtual void SuggestWords(const FX_CHAR* sWord,
- CFX_ByteStringArray& sSuggest) = 0;
+ std::vector<CFX_ByteString>& sSuggest) = 0;
};
class IPWL_Provider {
diff --git a/fpdfsdk/src/fpdfformfill.cpp b/fpdfsdk/src/fpdfformfill.cpp
index 5825456b19..e39d623307 100644
--- a/fpdfsdk/src/fpdfformfill.cpp
+++ b/fpdfsdk/src/fpdfformfill.cpp
@@ -7,10 +7,12 @@
#include "public/fpdf_formfill.h"
#include <memory>
+#include <vector>
#include "fpdfsdk/include/fsdk_define.h"
#include "fpdfsdk/include/fsdk_mgr.h"
#include "public/fpdfview.h"
+#include "third_party/base/stl_util.h"
#ifdef PDF_ENABLE_XFA
#include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h"
@@ -35,6 +37,16 @@ CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle,
return pSDKDoc ? pSDKDoc->GetPageView(pPage, TRUE) : nullptr;
}
+#ifdef PDF_ENABLE_XFA
+std::vector<CFX_ByteString>* FromFPDFStringHandle(FPDF_STRINGHANDLE handle) {
+ return reinterpret_cast<std::vector<CFX_ByteString>*>(handle);
+}
+
+FPDF_STRINGHANDLE ToFPDFStringHandle(std::vector<CFX_ByteString>* strings) {
+ return reinterpret_cast<FPDF_STRINGHANDLE>(strings);
+}
+#endif // PDF_ENABLE_XFA
+
} // namespace
DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle,
@@ -467,6 +479,7 @@ DLLEXPORT void STDCALL FPDF_Widget_Copy(FPDF_DOCUMENT document,
}
*size = real_size;
}
+
DLLEXPORT void STDCALL FPDF_Widget_Cut(FPDF_DOCUMENT document,
FPDF_WIDGET hWidget,
FPDF_WIDESTRING wsText,
@@ -502,6 +515,7 @@ DLLEXPORT void STDCALL FPDF_Widget_Cut(FPDF_DOCUMENT document,
}
*size = real_size;
}
+
DLLEXPORT void STDCALL FPDF_Widget_Paste(FPDF_DOCUMENT document,
FPDF_WIDGET hWidget,
FPDF_WIDESTRING wsText,
@@ -522,6 +536,7 @@ DLLEXPORT void STDCALL FPDF_Widget_Paste(FPDF_DOCUMENT document,
CFX_WideString wstr = CFX_WideString::FromUTF16LE(wsText, size);
pXFAMenuHander->Paste((IXFA_Widget*)hWidget, wstr);
}
+
DLLEXPORT void STDCALL
FPDF_Widget_ReplaceSpellCheckWord(FPDF_DOCUMENT document,
FPDF_WIDGET hWidget,
@@ -547,13 +562,14 @@ FPDF_Widget_ReplaceSpellCheckWord(FPDF_DOCUMENT document,
CFX_ByteStringC bs(bsText);
pXFAMenuHander->ReplaceSpellCheckWord((IXFA_Widget*)hWidget, ptPopup, bs);
}
+
DLLEXPORT void STDCALL
FPDF_Widget_GetSpellCheckWords(FPDF_DOCUMENT document,
FPDF_WIDGET hWidget,
float x,
float y,
FPDF_STRINGHANDLE* stringHandle) {
- if (NULL == hWidget || NULL == document)
+ if (!hWidget || !document)
return;
CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document;
@@ -563,69 +579,63 @@ FPDF_Widget_GetSpellCheckWords(FPDF_DOCUMENT document,
IXFA_MenuHandler* pXFAMenuHander =
CPDFXFA_App::GetInstance()->GetXFAApp()->GetMenuHandler();
- if (pXFAMenuHander == NULL)
+ if (!pXFAMenuHander)
return;
- CFX_ByteStringArray* sSuggestWords = new CFX_ByteStringArray;
+ std::vector<CFX_ByteString>* sSuggestWords = new std::vector<CFX_ByteString>;
CFX_PointF ptPopup;
ptPopup.x = x;
ptPopup.y = y;
- pXFAMenuHander->GetSuggestWords((IXFA_Widget*)hWidget, ptPopup,
- *sSuggestWords);
- *stringHandle = (FPDF_STRINGHANDLE)sSuggestWords;
+ pXFAMenuHander->GetSuggestWords(reinterpret_cast<IXFA_Widget*>(hWidget),
+ ptPopup, *sSuggestWords);
+ *stringHandle = ToFPDFStringHandle(sSuggestWords);
}
-DLLEXPORT int STDCALL FPDF_StringHandleCounts(FPDF_STRINGHANDLE stringHandle) {
- if (stringHandle == NULL)
- return -1;
- CFX_ByteStringArray* sSuggestWords = (CFX_ByteStringArray*)stringHandle;
- return sSuggestWords->GetSize();
+
+DLLEXPORT int STDCALL FPDF_StringHandleCounts(FPDF_STRINGHANDLE sHandle) {
+ std::vector<CFX_ByteString>* sSuggestWords = FromFPDFStringHandle(sHandle);
+ return sSuggestWords ? pdfium::CollectionSize<int>(*sSuggestWords) : -1;
}
+
DLLEXPORT FPDF_BOOL STDCALL
-FPDF_StringHandleGetStringByIndex(FPDF_STRINGHANDLE stringHandle,
+FPDF_StringHandleGetStringByIndex(FPDF_STRINGHANDLE sHandle,
int index,
FPDF_BYTESTRING bsText,
FPDF_DWORD* size) {
- if (stringHandle == NULL || size == NULL)
+ if (!sHandle || !size)
return FALSE;
- int count = FPDF_StringHandleCounts(stringHandle);
+
+ int count = FPDF_StringHandleCounts(sHandle);
if (index < 0 || index >= count)
return FALSE;
- CFX_ByteStringArray sSuggestWords = *(CFX_ByteStringArray*)stringHandle;
- int len = sSuggestWords[index].GetLength();
-
- if (bsText == NULL) {
+ std::vector<CFX_ByteString>* sSuggestWords = FromFPDFStringHandle(sHandle);
+ int len = (*sSuggestWords)[index].GetLength();
+ if (!bsText) {
*size = len;
return TRUE;
}
int real_size = len < *size ? len : *size;
if (real_size > 0)
- FXSYS_memcpy((void*)bsText, (const FX_CHAR*)(sSuggestWords[index]),
+ FXSYS_memcpy((void*)bsText, (const FX_CHAR*)(*sSuggestWords)[index],
real_size);
*size = real_size;
-
return TRUE;
}
+
DLLEXPORT void STDCALL
FPDF_StringHandleRelease(FPDF_STRINGHANDLE stringHandle) {
- if (stringHandle == NULL)
- return;
- CFX_ByteStringArray* sSuggestWords = (CFX_ByteStringArray*)stringHandle;
- delete sSuggestWords;
+ delete FromFPDFStringHandle(stringHandle);
}
DLLEXPORT FPDF_BOOL STDCALL
FPDF_StringHandleAddString(FPDF_STRINGHANDLE stringHandle,
FPDF_BYTESTRING bsText,
FPDF_DWORD size) {
- if (stringHandle == NULL || bsText == NULL || size <= 0)
+ if (!stringHandle || !bsText || size == 0)
return FALSE;
- CFX_ByteStringArray* stringArr = (CFX_ByteStringArray*)stringHandle;
- CFX_ByteString bsStr(bsText, size);
-
- stringArr->Add(bsStr);
+ FromFPDFStringHandle(stringHandle)->push_back(CFX_ByteString(bsText, size));
return TRUE;
}
#endif // PDF_ENABLE_XFA
diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp
index 65dc926fb3..fd30cf1f18 100644
--- a/fpdfsdk/src/fsdk_mgr.cpp
+++ b/fpdfsdk/src/fsdk_mgr.cpp
@@ -176,14 +176,11 @@ FX_BOOL CFX_SystemHandler::FindNativeTrueTypeFont(
if (!pFontMapper)
return FALSE;
- int nSize = pFontMapper->m_InstalledTTFonts.GetSize();
- if (nSize == 0) {
+ if (pFontMapper->m_InstalledTTFonts.empty())
pFontMapper->LoadInstalledFonts();
- nSize = pFontMapper->m_InstalledTTFonts.GetSize();
- }
- for (int i = 0; i < nSize; ++i) {
- if (pFontMapper->m_InstalledTTFonts[i].Compare(sFontFaceName))
+ for (const auto& font : pFontMapper->m_InstalledTTFonts) {
+ if (font.Compare(sFontFaceName))
return TRUE;
}
diff --git a/fpdfsdk/src/javascript/PublicMethods.cpp b/fpdfsdk/src/javascript/PublicMethods.cpp
index 3c6d36fdd8..1a5c83cc46 100644
--- a/fpdfsdk/src/javascript/PublicMethods.cpp
+++ b/fpdfsdk/src/javascript/PublicMethods.cpp
@@ -1201,19 +1201,19 @@ FX_BOOL CJS_PublicMethods::AFDate_FormatEx(IJS_Context* cc,
}
double CJS_PublicMethods::MakeInterDate(CFX_WideString strValue) {
- CFX_WideStringArray wsArray;
+ std::vector<CFX_WideString> wsArray;
CFX_WideString sTemp = L"";
for (int i = 0; i < strValue.GetLength(); ++i) {
FX_WCHAR c = strValue.GetAt(i);
if (c == L' ' || c == L':') {
- wsArray.Add(sTemp);
+ wsArray.push_back(sTemp);
sTemp = L"";
continue;
}
sTemp += c;
}
- wsArray.Add(sTemp);
- if (wsArray.GetSize() != 8)
+ wsArray.push_back(sTemp);
+ if (wsArray.size() != 8)
return 0;
int nMonth = 1;
diff --git a/fpdfsdk/src/pdfwindow/PWL_Edit.cpp b/fpdfsdk/src/pdfwindow/PWL_Edit.cpp
index 057cb4191e..4b3886a11d 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Edit.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Edit.cpp
@@ -15,6 +15,7 @@
#include "fpdfsdk/include/pdfwindow/PWL_Utils.h"
#include "fpdfsdk/include/pdfwindow/PWL_Wnd.h"
#include "public/fpdf_fwlevent.h"
+#include "third_party/base/stl_util.h"
CPWL_Edit::CPWL_Edit()
: m_pFillerNotify(NULL), m_pSpellCheck(NULL), m_bFocus(FALSE) {
@@ -519,24 +520,21 @@ FX_BOOL CPWL_Edit::OnRButtonUp(const CPDF_Point& point, FX_DWORD nFlag) {
if (!hPopup)
return FALSE;
- CFX_ByteStringArray sSuggestWords;
+ std::vector<CFX_ByteString> sSuggestWords;
CPDF_Point ptPopup = point;
if (!IsReadOnly()) {
if (HasFlag(PES_SPELLCHECK) && !swLatin.IsEmpty()) {
if (m_pSpellCheck) {
CFX_ByteString sLatin = CFX_ByteString::FromUnicode(swLatin);
-
if (!m_pSpellCheck->CheckWord(sLatin)) {
m_pSpellCheck->SuggestWords(sLatin, sSuggestWords);
- int32_t nSuggest = sSuggestWords.GetSize();
-
+ int32_t nSuggest = pdfium::CollectionSize<int32_t>(sSuggestWords);
for (int32_t nWord = 0; nWord < nSuggest; nWord++) {
pSH->AppendMenuItem(hPopup, WM_PWLEDIT_SUGGEST + nWord,
sSuggestWords[nWord].UTF8Decode());
}
-
if (nSuggest > 0)
pSH->AppendMenuItem(hPopup, 0, L"");
diff --git a/xfa/include/fwl/basewidget/fwl_edit.h b/xfa/include/fwl/basewidget/fwl_edit.h
index b92c20f00d..878e5319fc 100644
--- a/xfa/include/fwl/basewidget/fwl_edit.h
+++ b/xfa/include/fwl/basewidget/fwl_edit.h
@@ -4,12 +4,16 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef _FWL_EDIT_H
-#define _FWL_EDIT_H
+#ifndef FWL_EDIT_H_
+#define FWL_EDIT_H_
+
+#include <vector>
+
+#include "xfa/include/fwl/lightwidget/widget.h"
+
class CFWL_WidgetImpProperties;
-class IFWL_Widget;
-class IFWL_EditDP;
class IFWL_Edit;
+
#define FWL_CLASS_Edit L"FWL_EDIT"
#define FWL_CLASSHASH_Edit 2893987822
#define FWL_STYLEEXT_EDT_ReadOnly (1L << 0)
@@ -99,7 +103,7 @@ END_FWL_EVENT_DEF
BEGIN_FWL_EVENT_DEF(CFWL_EvtEdtGetSuggestWords, FWL_EVTHASH_EDT_GetSuggestWords)
FX_BOOL bSuggestWords;
CFX_ByteString bsWord;
-CFX_ByteStringArray bsArraySuggestWords;
+std::vector<CFX_ByteString> bsArraySuggestWords;
END_FWL_EVENT_DEF
class IFWL_EditDP : public IFWL_DataProvider {};
#define FWL_EDT_FIND_FLAGS_Prev (0L << 0)
@@ -107,6 +111,7 @@ class IFWL_EditDP : public IFWL_DataProvider {};
#define FWL_EDT_FIND_FLAGS_WholeWord (1L << 1)
#define FWL_EDT_FIND_FLAGS_NoCase (1L << 2)
typedef struct _FWL_HEDTFIND { void* pData; } * FWL_HEDTFIND;
+
class IFWL_Edit : public IFWL_Widget {
public:
static IFWL_Edit* Create(const CFWL_WidgetImpProperties& properties,
@@ -154,11 +159,13 @@ class IFWL_Edit : public IFWL_Widget {
FWL_ERR SetBackColor(FX_DWORD dwColor);
FWL_ERR SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize);
void SetScrollOffset(FX_FLOAT fScrollOffset);
- FX_BOOL GetSuggestWords(CFX_PointF pointf, CFX_ByteStringArray& sSuggest);
+ FX_BOOL GetSuggestWords(CFX_PointF pointf,
+ std::vector<CFX_ByteString>& sSuggest);
FX_BOOL ReplaceSpellCheckWord(CFX_PointF pointf,
const CFX_ByteStringC& bsReplace);
protected:
IFWL_Edit();
};
-#endif
+
+#endif // FWL_EDIT_H_
diff --git a/xfa/include/fwl/lightwidget/edit.h b/xfa/include/fwl/lightwidget/edit.h
index 42bb5e374a..b1dc79cfc7 100644
--- a/xfa/include/fwl/lightwidget/edit.h
+++ b/xfa/include/fwl/lightwidget/edit.h
@@ -4,11 +4,15 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef _FWL_EDIT_LIGHT_H
-#define _FWL_EDIT_LIGHT_H
-class CFWL_Widget;
+#ifndef FWL_LIGHTWIDGET_EDIT_H_
+#define FWL_LIGHTWIDGET_EDIT_H_
+
+#include <vector>
+
+#include "xfa/include/fwl/lightwidget/widget.h"
+
class CFWL_WidgetProperties;
-class CFWL_Edit;
+
class CFWL_Edit : public CFWL_Widget {
public:
static CFWL_Edit* Create();
@@ -52,10 +56,12 @@ class CFWL_Edit : public CFWL_Widget {
FX_BOOL Paste(const CFX_WideString& wsPaste);
FX_BOOL Delete();
void SetScrollOffset(FX_FLOAT fScrollOffset);
- FX_BOOL GetSuggestWords(CFX_PointF pointf, CFX_ByteStringArray& sSuggest);
+ FX_BOOL GetSuggestWords(CFX_PointF pointf,
+ std::vector<CFX_ByteString>& sSuggest);
FX_BOOL ReplaceSpellCheckWord(CFX_PointF pointf,
const CFX_ByteStringC& bsReplace);
CFWL_Edit();
virtual ~CFWL_Edit();
};
-#endif
+
+#endif // FWL_LIGHTWIDGET_EDIT_H_
diff --git a/xfa/include/fxfa/fxfa.h b/xfa/include/fxfa/fxfa.h
index 5fbd829c4e..5a1b18469c 100644
--- a/xfa/include/fxfa/fxfa.h
+++ b/xfa/include/fxfa/fxfa.h
@@ -7,6 +7,8 @@
#ifndef FXFA_H_
#define FXFA_H_
+#include <vector>
+
class CFX_Graphics;
class CPDF_Document;
class CXFA_Node;
@@ -338,7 +340,7 @@ class IXFA_MenuHandler {
virtual FX_BOOL Redo(IXFA_Widget* hWidget) = 0;
virtual FX_BOOL GetSuggestWords(IXFA_Widget* hWidget,
CFX_PointF pointf,
- CFX_ByteStringArray& sSuggest) = 0;
+ std::vector<CFX_ByteString>& sSuggest) = 0;
virtual FX_BOOL ReplaceSpellCheckWord(IXFA_Widget* hWidget,
CFX_PointF pointf,
const CFX_ByteStringC& bsReplace) = 0;
@@ -442,7 +444,7 @@ class IXFA_DocProvider {
virtual FX_BOOL CheckWord(IXFA_Doc* hDoc, const CFX_ByteStringC& sWord) = 0;
virtual FX_BOOL GetSuggestWords(IXFA_Doc* hDoc,
const CFX_ByteStringC& sWord,
- CFX_ByteStringArray& sSuggest) = 0;
+ std::vector<CFX_ByteString>& sSuggest) = 0;
virtual FX_BOOL GetPDFScriptObject(IXFA_Doc* hDoc,
const CFX_ByteStringC& utf8Name,
FXJSE_HVALUE hValue) = 0;
diff --git a/xfa/src/fwl/src/basewidget/fwl_editimp.cpp b/xfa/src/fwl/src/basewidget/fwl_editimp.cpp
index f5342d0f52..263968652b 100644
--- a/xfa/src/fwl/src/basewidget/fwl_editimp.cpp
+++ b/xfa/src/fwl/src/basewidget/fwl_editimp.cpp
@@ -155,7 +155,7 @@ void IFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) {
return static_cast<CFWL_EditImp*>(GetImpl())->SetScrollOffset(fScrollOffset);
}
FX_BOOL IFWL_Edit::GetSuggestWords(CFX_PointF pointf,
- CFX_ByteStringArray& sSuggest) {
+ std::vector<CFX_ByteString>& sSuggest) {
return static_cast<CFWL_EditImp*>(GetImpl())
->GetSuggestWords(pointf, sSuggest);
}
@@ -357,7 +357,7 @@ int32_t CFWL_EditImp::GetWordAtPoint(CFX_PointF pointf, int32_t& nCount) {
return 0;
}
FX_BOOL CFWL_EditImp::GetSuggestWords(CFX_PointF pointf,
- CFX_ByteStringArray& sSuggest) {
+ std::vector<CFX_ByteString>& sSuggest) {
int32_t nWordCount = 0;
int32_t nWordStart = GetWordAtPoint(pointf, nWordCount);
if (nWordCount < 1) {
diff --git a/xfa/src/fwl/src/basewidget/include/fwl_editimp.h b/xfa/src/fwl/src/basewidget/include/fwl_editimp.h
index 67e6b69adb..d7e736106e 100644
--- a/xfa/src/fwl/src/basewidget/include/fwl_editimp.h
+++ b/xfa/src/fwl/src/basewidget/include/fwl_editimp.h
@@ -4,12 +4,15 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef _FWL_EDIT_IMP_H
-#define _FWL_EDIT_IMP_H
+#ifndef FWL_EDITIMP_H_
+#define FWL_EDITIMP_H_
#include <memory>
+#include <vector>
+
+#include "xfa/src/fee/include/ifde_txtedtengine.h"
+#include "xfa/src/fwl/src/core/include/fwl_widgetimp.h"
-class CFWL_WidgetImp;
class CFWL_WidgetImpProperties;
class CFWL_WidgetImpDelegate;
class CFWL_ScrollBarImp;
@@ -17,6 +20,7 @@ class IFWL_Caret;
class IFWL_AdapterTextField;
class CFWL_EditImp;
class CFWL_EditImpDelegate;
+
class CFWL_EditImp : public CFWL_WidgetImp, public IFDE_TxtEdtEventSink {
public:
CFWL_EditImp(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter);
@@ -106,7 +110,8 @@ class CFWL_EditImp : public CFWL_WidgetImp, public IFDE_TxtEdtEventSink {
virtual FWL_ERR SetBackgroundColor(FX_DWORD color);
virtual FWL_ERR SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize);
void SetScrollOffset(FX_FLOAT fScrollOffset);
- FX_BOOL GetSuggestWords(CFX_PointF pointf, CFX_ByteStringArray& sSuggest);
+ FX_BOOL GetSuggestWords(CFX_PointF pointf,
+ std::vector<CFX_ByteString>& sSuggest);
FX_BOOL ReplaceSpellCheckWord(CFX_PointF pointf,
const CFX_ByteStringC& bsReplace);
@@ -177,6 +182,7 @@ class CFWL_EditImp : public CFWL_WidgetImp, public IFDE_TxtEdtEventSink {
int32_t m_iCurRecord;
int32_t m_iMaxRecord;
};
+
class CFWL_EditImpDelegate : public CFWL_WidgetImpDelegate {
public:
CFWL_EditImpDelegate(CFWL_EditImp* pOwner);
@@ -200,4 +206,5 @@ class CFWL_EditImpDelegate : public CFWL_WidgetImpDelegate {
void DoCursor(CFWL_MsgMouse* pMsg);
CFWL_EditImp* m_pOwner;
};
-#endif
+
+#endif // FWL_EDITIMP_H_
diff --git a/xfa/src/fwl/src/lightwidget/edit.cpp b/xfa/src/fwl/src/lightwidget/edit.cpp
index 0d207ee288..f7667cb3a9 100644
--- a/xfa/src/fwl/src/lightwidget/edit.cpp
+++ b/xfa/src/fwl/src/lightwidget/edit.cpp
@@ -201,7 +201,7 @@ void CFWL_Edit::SetScrollOffset(FX_FLOAT fScrollOffset) {
return static_cast<IFWL_Edit*>(m_pIface)->SetScrollOffset(fScrollOffset);
}
FX_BOOL CFWL_Edit::GetSuggestWords(CFX_PointF pointf,
- CFX_ByteStringArray& sSuggest) {
+ std::vector<CFX_ByteString>& sSuggest) {
return static_cast<IFWL_Edit*>(m_pIface)->GetSuggestWords(pointf, sSuggest);
}
FX_BOOL CFWL_Edit::ReplaceSpellCheckWord(CFX_PointF pointf,
diff --git a/xfa/src/fxfa/src/app/xfa_fftextedit.cpp b/xfa/src/fxfa/src/app/xfa_fftextedit.cpp
index 083769866c..0b5a70170e 100644
--- a/xfa/src/fxfa/src/app/xfa_fftextedit.cpp
+++ b/xfa/src/fxfa/src/app/xfa_fftextedit.cpp
@@ -320,8 +320,9 @@ FX_BOOL CXFA_FFTextEdit::Delete() {
FX_BOOL CXFA_FFTextEdit::DeSelect() {
return ((CFWL_Edit*)m_pNormalWidget)->ClearSelections();
}
-FX_BOOL CXFA_FFTextEdit::GetSuggestWords(CFX_PointF pointf,
- CFX_ByteStringArray& sSuggest) {
+FX_BOOL CXFA_FFTextEdit::GetSuggestWords(
+ CFX_PointF pointf,
+ std::vector<CFX_ByteString>& sSuggest) {
if (m_pDataAcc->GetUIType() != XFA_ELEMENT_TextEdit) {
return FALSE;
}
@@ -377,8 +378,9 @@ FX_BOOL CXFA_FFTextEdit::CheckWord(const CFX_ByteStringC& sWord) {
}
return GetDoc()->GetDocProvider()->CheckWord(GetDoc(), sWord);
}
-FX_BOOL CXFA_FFTextEdit::GetSuggestWords(const CFX_ByteStringC& sWord,
- CFX_ByteStringArray& sSuggest) {
+FX_BOOL CXFA_FFTextEdit::GetSuggestWords(
+ const CFX_ByteStringC& sWord,
+ std::vector<CFX_ByteString>& sSuggest) {
if (m_pDataAcc->GetUIType() != XFA_ELEMENT_TextEdit) {
return FALSE;
}
diff --git a/xfa/src/fxfa/src/app/xfa_fftextedit.h b/xfa/src/fxfa/src/app/xfa_fftextedit.h
index 9694b49f40..0f99a69084 100644
--- a/xfa/src/fxfa/src/app/xfa_fftextedit.h
+++ b/xfa/src/fxfa/src/app/xfa_fftextedit.h
@@ -4,58 +4,65 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef _FXFA_FORMFILLER_TEXTEDIT_IMP_H
-#define _FXFA_FORMFILLER_TEXTEDIT_IMP_H
+#ifndef XFA_FFTEXTEDIT_H_
+#define XFA_FFTEXTEDIT_H_
+
class CXFA_FFTextEdit : public CXFA_FFField {
public:
CXFA_FFTextEdit(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc);
- virtual ~CXFA_FFTextEdit();
- virtual FX_BOOL LoadWidget();
- virtual void UpdateWidgetProperty();
- virtual FX_BOOL OnLButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy);
- virtual FX_BOOL OnRButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy);
- virtual FX_BOOL OnRButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy);
- virtual FX_BOOL OnSetFocus(CXFA_FFWidget* pOldWidget);
- virtual FX_BOOL OnKillFocus(CXFA_FFWidget* pNewWidget);
- virtual FX_BOOL CanUndo();
- virtual FX_BOOL CanRedo();
- virtual FX_BOOL Undo();
- virtual FX_BOOL Redo();
- virtual FX_BOOL CanCopy();
- virtual FX_BOOL CanCut();
- virtual FX_BOOL CanPaste();
- virtual FX_BOOL CanSelectAll();
- virtual FX_BOOL Copy(CFX_WideString& wsCopy);
- virtual FX_BOOL Cut(CFX_WideString& wsCut);
- virtual FX_BOOL Paste(const CFX_WideString& wsPaste);
- virtual FX_BOOL SelectAll();
- virtual FX_BOOL Delete();
- virtual FX_BOOL DeSelect();
- FX_BOOL GetSuggestWords(CFX_PointF pointf, CFX_ByteStringArray& sSuggest);
+ ~CXFA_FFTextEdit() override;
+
+ // CXFA_FFField:
+ FX_BOOL LoadWidget() override;
+ void UpdateWidgetProperty() override;
+ FX_BOOL OnLButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy) override;
+ FX_BOOL OnRButtonDown(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy) override;
+ FX_BOOL OnRButtonUp(FX_DWORD dwFlags, FX_FLOAT fx, FX_FLOAT fy) override;
+ FX_BOOL OnSetFocus(CXFA_FFWidget* pOldWidget) override;
+ FX_BOOL OnKillFocus(CXFA_FFWidget* pNewWidget) override;
+ FX_BOOL CanUndo() override;
+ FX_BOOL CanRedo() override;
+ FX_BOOL Undo() override;
+ FX_BOOL Redo() override;
+ FX_BOOL CanCopy() override;
+ FX_BOOL CanCut() override;
+ FX_BOOL CanPaste() override;
+ FX_BOOL CanSelectAll() override;
+ FX_BOOL Copy(CFX_WideString& wsCopy) override;
+ FX_BOOL Cut(CFX_WideString& wsCut) override;
+ FX_BOOL Paste(const CFX_WideString& wsPaste) override;
+ FX_BOOL SelectAll() override;
+ FX_BOOL Delete() override;
+ FX_BOOL DeSelect() override;
+ FX_BOOL GetSuggestWords(CFX_PointF pointf,
+ std::vector<CFX_ByteString>& sSuggest) override;
FX_BOOL ReplaceSpellCheckWord(CFX_PointF pointf,
- const CFX_ByteStringC& bsReplace);
+ const CFX_ByteStringC& bsReplace) override;
- protected:
- FX_DWORD GetAlignment();
- virtual FX_BOOL CommitData();
- virtual FX_BOOL UpdateFWLData();
- virtual FX_BOOL IsDataChanged();
- void ValidateNumberField(const CFX_WideString& wsText);
- IFWL_WidgetDelegate* m_pOldDelegate;
+ // IFWL_WidgetDelegate:
+ int32_t OnProcessMessage(CFWL_Message* pMessage) override;
+ FWL_ERR OnProcessEvent(CFWL_Event* pEvent) override;
+ FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
+ const CFX_Matrix* pMatrix = NULL) override;
- public:
void OnTextChanged(IFWL_Widget* pWidget,
const CFX_WideString& wsChanged,
const CFX_WideString& wsPrevText);
void OnTextFull(IFWL_Widget* pWidget);
FX_BOOL CheckWord(const CFX_ByteStringC& sWord);
FX_BOOL GetSuggestWords(const CFX_ByteStringC& sWord,
- CFX_ByteStringArray& sSuggest);
- virtual int32_t OnProcessMessage(CFWL_Message* pMessage);
- virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent);
- virtual FWL_ERR OnDrawWidget(CFX_Graphics* pGraphics,
- const CFX_Matrix* pMatrix = NULL);
+ std::vector<CFX_ByteString>& sSuggest);
+
+ protected:
+ FX_DWORD GetAlignment();
+ FX_BOOL CommitData() override;
+ FX_BOOL UpdateFWLData() override;
+ FX_BOOL IsDataChanged() override;
+ void ValidateNumberField(const CFX_WideString& wsText);
+
+ IFWL_WidgetDelegate* m_pOldDelegate;
};
+
class CXFA_FFNumericEdit : public CXFA_FFTextEdit {
public:
CXFA_FFNumericEdit(CXFA_FFPageView* pPageView, CXFA_WidgetAcc* pDataAcc);
@@ -123,4 +130,5 @@ class CXFA_FFDateTimeEdit : public CXFA_FFTextEdit {
int32_t iDay);
virtual FWL_ERR OnProcessEvent(CFWL_Event* pEvent);
};
-#endif
+
+#endif // XFA_FFTEXTEDIT_H_
diff --git a/xfa/src/fxfa/src/app/xfa_ffwidget.h b/xfa/src/fxfa/src/app/xfa_ffwidget.h
index f9e4478183..8262be8c13 100644
--- a/xfa/src/fxfa/src/app/xfa_ffwidget.h
+++ b/xfa/src/fxfa/src/app/xfa_ffwidget.h
@@ -4,8 +4,10 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef _FXFA_FORMFILLER_WIDGET_IMP_H
-#define _FXFA_FORMFILLER_WIDGET_IMP_H
+#ifndef XFA_FFWIDGET_H_
+#define XFA_FFWIDGET_H_
+
+#include <vector>
#include "xfa/include/fxfa/fxfa.h"
@@ -102,7 +104,7 @@ class CXFA_FFWidget : public IXFA_Widget,
virtual FX_BOOL Delete() { return FALSE; }
virtual FX_BOOL DeSelect() { return FALSE; }
virtual FX_BOOL GetSuggestWords(CFX_PointF pointf,
- CFX_ByteStringArray& sSuggest) {
+ std::vector<CFX_ByteString>& sSuggest) {
return FALSE;
}
virtual FX_BOOL ReplaceSpellCheckWord(CFX_PointF pointf,
@@ -183,4 +185,5 @@ void XFA_DrawBox(CXFA_Box box,
const CFX_RectF& rtWidget,
CFX_Matrix* pMatrix,
FX_DWORD dwFlags = 0);
-#endif
+
+#endif // XFA_FFWIDGET_H_
diff --git a/xfa/src/fxfa/src/app/xfa_ffwidgethandler.cpp b/xfa/src/fxfa/src/app/xfa_ffwidgethandler.cpp
index def79b7962..6d3af0ec37 100644
--- a/xfa/src/fxfa/src/app/xfa_ffwidgethandler.cpp
+++ b/xfa/src/fxfa/src/app/xfa_ffwidgethandler.cpp
@@ -620,13 +620,10 @@ FX_BOOL CXFA_FFMenuHandler::Undo(IXFA_Widget* hWidget) {
FX_BOOL CXFA_FFMenuHandler::Redo(IXFA_Widget* hWidget) {
return static_cast<CXFA_FFWidget*>(hWidget)->Redo();
}
-#define FX_EDIT_ISLATINWORD(u) \
- (u == 0x2D || (u <= 0x005A && u >= 0x0041) || \
- (u <= 0x007A && u >= 0x0061) || (u <= 0x02AF && u >= 0x00C0) || \
- u == 0x0027)
-FX_BOOL CXFA_FFMenuHandler::GetSuggestWords(IXFA_Widget* hWidget,
- CFX_PointF pointf,
- CFX_ByteStringArray& sSuggest) {
+FX_BOOL CXFA_FFMenuHandler::GetSuggestWords(
+ IXFA_Widget* hWidget,
+ CFX_PointF pointf,
+ std::vector<CFX_ByteString>& sSuggest) {
return static_cast<CXFA_FFWidget*>(hWidget)
->GetSuggestWords(pointf, sSuggest);
}
diff --git a/xfa/src/fxfa/src/app/xfa_ffwidgethandler.h b/xfa/src/fxfa/src/app/xfa_ffwidgethandler.h
index 26b8850b4e..e6d7721b21 100644
--- a/xfa/src/fxfa/src/app/xfa_ffwidgethandler.h
+++ b/xfa/src/fxfa/src/app/xfa_ffwidgethandler.h
@@ -4,9 +4,15 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef _FXFA_FORMFILLER_ANNOTHANDLER_IMP_H
-#define _FXFA_FORMFILLER_ANNOTHANDLER_IMP_H
+#ifndef XFA_FFWIDGETHANDLER_H_
+#define XFA_FFWIDGETHANDLER_H_
+
+#include <vector>
+
+#include "xfa/include/fxfa/fxfa.h"
+
class CXFA_FFDocView;
+
class CXFA_FFWidgetHandler : public IXFA_WidgetHandler {
public:
CXFA_FFWidgetHandler(CXFA_FFDocView* pDocView);
@@ -137,6 +143,7 @@ class CXFA_FFWidgetHandler : public IXFA_WidgetHandler {
CXFA_FFDocView* m_pDocView;
};
+
class CXFA_FFMenuHandler : public IXFA_MenuHandler {
public:
CXFA_FFMenuHandler();
@@ -159,9 +166,10 @@ class CXFA_FFMenuHandler : public IXFA_MenuHandler {
virtual FX_BOOL Redo(IXFA_Widget* hWidget);
virtual FX_BOOL GetSuggestWords(IXFA_Widget* hWidget,
CFX_PointF pointf,
- CFX_ByteStringArray& sSuggest);
+ std::vector<CFX_ByteString>& sSuggest);
virtual FX_BOOL ReplaceSpellCheckWord(IXFA_Widget* hWidget,
CFX_PointF pointf,
const CFX_ByteStringC& bsReplace);
};
-#endif
+
+#endif // XFA_FFWIDGETHANDLER_H_