summaryrefslogtreecommitdiff
path: root/fpdfsdk
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 /fpdfsdk
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 .
Diffstat (limited to 'fpdfsdk')
-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
7 files changed, 56 insertions, 47 deletions
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"");