summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-10-21 15:55:42 -0700
committerTom Sepez <tsepez@chromium.org>2015-10-21 15:55:42 -0700
commit69ceb6a9761b3ccb228a2405e9a493a3666e0601 (patch)
treeaeda419b1fc75d5c2d2147b172edd47ae12298ac /fpdfsdk
parent3b2ab45f0a883046a7c457e8435b5a9b2c1c4156 (diff)
downloadpdfium-69ceb6a9761b3ccb228a2405e9a493a3666e0601.tar.xz
More master side changes for convergence with XFA.
- Add new CPDFSDK_Document::GetPDFDocument() - FPDFDocumentFromCPDFDocument() to match XFA - rename some JS variables to be consistent with XFA - remove unused param from CJS_GlobalData(). - kill dead code used XFA only. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1413883005 .
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/include/fsdk_define.h4
-rw-r--r--fpdfsdk/include/fsdk_mgr.h9
-rw-r--r--fpdfsdk/src/fpdf_dataavail.cpp2
-rw-r--r--fpdfsdk/src/fpdfeditpage.cpp2
-rw-r--r--fpdfsdk/src/fpdfview.cpp8
-rw-r--r--fpdfsdk/src/javascript/Document.cpp28
-rw-r--r--fpdfsdk/src/javascript/JS_Define.h14
-rw-r--r--fpdfsdk/src/javascript/JS_GlobalData.cpp4
-rw-r--r--fpdfsdk/src/javascript/JS_GlobalData.h3
-rw-r--r--fpdfsdk/src/javascript/JS_Runtime.cpp6
10 files changed, 40 insertions, 40 deletions
diff --git a/fpdfsdk/include/fsdk_define.h b/fpdfsdk/include/fsdk_define.h
index 37788c3ff7..6e3c718948 100644
--- a/fpdfsdk/include/fsdk_define.h
+++ b/fpdfsdk/include/fsdk_define.h
@@ -52,8 +52,10 @@ class CPDF_CustomAccess final : public IFX_FileRead {
FPDF_FILEACCESS m_FileAccess;
};
-// Conversions from FPDF_ types.
+// Conversions to/from FPDF_ types.
CPDF_Document* CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc);
+FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc);
+
CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page);
void DropContext(void* data);
diff --git a/fpdfsdk/include/fsdk_mgr.h b/fpdfsdk/include/fsdk_mgr.h
index 5ddc8e6c57..068731ee8f 100644
--- a/fpdfsdk/include/fsdk_mgr.h
+++ b/fpdfsdk/include/fsdk_mgr.h
@@ -229,7 +229,14 @@ class CPDFSDK_Document {
~CPDFSDK_Document();
CPDFSDK_InterForm* GetInterForm();
- CPDF_Document* GetDocument() { return m_pDoc; }
+
+ // Gets the document object for the next layer down; for master this is
+ // a CPDF_Document, but for XFA it is a CPDFXFA_Document.
+ CPDF_Document* GetDocument() const { return m_pDoc; }
+
+ // Gets the CPDF_Document, either directly in master, or from the
+ // CPDFXFA_Document for XFA.
+ CPDF_Document* GetPDFDocument() const { return m_pDoc; }
CPDFSDK_PageView* GetPageView(CPDF_Page* pPDFPage, FX_BOOL ReNew = TRUE);
CPDFSDK_PageView* GetPageView(int nIndex);
diff --git a/fpdfsdk/src/fpdf_dataavail.cpp b/fpdfsdk/src/fpdf_dataavail.cpp
index b7b42ab32a..04e246b17e 100644
--- a/fpdfsdk/src/fpdf_dataavail.cpp
+++ b/fpdfsdk/src/fpdf_dataavail.cpp
@@ -111,7 +111,7 @@ FPDFAvail_GetDocument(FPDF_AVAIL avail, FPDF_BYTESTRING password) {
}
((CFPDF_DataAvail*)avail)->m_pDataAvail->SetDocument(pParser->GetDocument());
CheckUnSupportError(pParser->GetDocument(), FPDF_ERR_SUCCESS);
- return pParser->GetDocument();
+ return FPDFDocumentFromCPDFDocument(pParser->GetDocument());
}
DLLEXPORT int STDCALL FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc) {
diff --git a/fpdfsdk/src/fpdfeditpage.cpp b/fpdfsdk/src/fpdfeditpage.cpp
index 7b70526b0c..24a46a7273 100644
--- a/fpdfsdk/src/fpdfeditpage.cpp
+++ b/fpdfsdk/src/fpdfeditpage.cpp
@@ -40,7 +40,7 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument() {
pInfoDict->SetAt("Creator", new CPDF_String(L"PDFium"));
}
- return pDoc;
+ return FPDFDocumentFromCPDFDocument(pDoc);
}
DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index) {
diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp
index 0d6dcf29f1..c8c2c73c9a 100644
--- a/fpdfsdk/src/fpdfview.cpp
+++ b/fpdfsdk/src/fpdfview.cpp
@@ -20,6 +20,10 @@ CPDF_Document* CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc) {
return static_cast<CPDF_Document*>(doc);
}
+FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc) {
+ return static_cast<FPDF_DOCUMENT>(doc);
+}
+
CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page) {
return static_cast<CPDF_Page*>(page);
}
@@ -204,7 +208,7 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf,
CPDF_Document* pDoc = NULL;
pDoc = pParser ? pParser->GetDocument() : NULL;
CheckUnSupportError(pDoc, err_code);
- return pParser->GetDocument();
+ return FPDFDocumentFromCPDFDocument(pParser->GetDocument());
}
DLLEXPORT FPDF_DOCUMENT STDCALL
@@ -222,7 +226,7 @@ FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess,
CPDF_Document* pDoc = NULL;
pDoc = pParser ? pParser->GetDocument() : NULL;
CheckUnSupportError(pDoc, err_code);
- return pParser->GetDocument();
+ return FPDFDocumentFromCPDFDocument(pParser->GetDocument());
}
DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc,
diff --git a/fpdfsdk/src/javascript/Document.cpp b/fpdfsdk/src/javascript/Document.cpp
index 8908dfb664..4c7e1910cb 100644
--- a/fpdfsdk/src/javascript/Document.cpp
+++ b/fpdfsdk/src/javascript/Document.cpp
@@ -785,9 +785,7 @@ FX_BOOL Document::mailDoc(IJS_Context* cc,
FX_BOOL Document::author(IJS_Context* cc,
CJS_PropValue& vp,
CFX_WideString& sError) {
- ASSERT(m_pDocument != NULL);
-
- CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+ CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo();
if (!pDictionary)
return FALSE;
@@ -809,9 +807,7 @@ FX_BOOL Document::author(IJS_Context* cc,
FX_BOOL Document::info(IJS_Context* cc,
CJS_PropValue& vp,
CFX_WideString& sError) {
- ASSERT(m_pDocument != NULL);
-
- CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+ CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo();
if (!pDictionary)
return FALSE;
@@ -868,7 +864,7 @@ FX_BOOL Document::info(IJS_Context* cc,
FX_BOOL Document::creationDate(IJS_Context* cc,
CJS_PropValue& vp,
CFX_WideString& sError) {
- CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+ CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo();
if (!pDictionary)
return FALSE;
@@ -889,7 +885,7 @@ FX_BOOL Document::creationDate(IJS_Context* cc,
FX_BOOL Document::creator(IJS_Context* cc,
CJS_PropValue& vp,
CFX_WideString& sError) {
- CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+ CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo();
if (!pDictionary)
return FALSE;
@@ -945,7 +941,7 @@ FX_BOOL Document::delay(IJS_Context* cc,
FX_BOOL Document::keywords(IJS_Context* cc,
CJS_PropValue& vp,
CFX_WideString& sError) {
- CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+ CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo();
if (!pDictionary)
return FALSE;
@@ -966,7 +962,7 @@ FX_BOOL Document::keywords(IJS_Context* cc,
FX_BOOL Document::modDate(IJS_Context* cc,
CJS_PropValue& vp,
CFX_WideString& sError) {
- CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+ CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo();
if (!pDictionary)
return FALSE;
@@ -987,7 +983,7 @@ FX_BOOL Document::modDate(IJS_Context* cc,
FX_BOOL Document::producer(IJS_Context* cc,
CJS_PropValue& vp,
CFX_WideString& sError) {
- CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+ CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo();
if (!pDictionary)
return FALSE;
@@ -1008,7 +1004,7 @@ FX_BOOL Document::producer(IJS_Context* cc,
FX_BOOL Document::subject(IJS_Context* cc,
CJS_PropValue& vp,
CFX_WideString& sError) {
- CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+ CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo();
if (!pDictionary)
return FALSE;
@@ -1029,10 +1025,10 @@ FX_BOOL Document::subject(IJS_Context* cc,
FX_BOOL Document::title(IJS_Context* cc,
CJS_PropValue& vp,
CFX_WideString& sError) {
- if (m_pDocument == NULL || m_pDocument->GetDocument() == NULL)
+ if (m_pDocument == NULL || m_pDocument->GetPDFDocument() == NULL)
return FALSE;
- CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+ CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo();
if (!pDictionary)
return FALSE;
@@ -1522,7 +1518,7 @@ FX_BOOL Document::getPageNthWord(IJS_Context* cc,
int nWordNo = params.GetSize() > 1 ? params[1].ToInt() : 0;
bool bStrip = params.GetSize() > 2 ? params[2].ToBool() : true;
- CPDF_Document* pDocument = m_pDocument->GetDocument();
+ CPDF_Document* pDocument = m_pDocument->GetPDFDocument();
if (!pDocument)
return FALSE;
@@ -1594,7 +1590,7 @@ FX_BOOL Document::getPageNumWords(IJS_Context* cc,
int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0;
- CPDF_Document* pDocument = m_pDocument->GetDocument();
+ CPDF_Document* pDocument = m_pDocument->GetPDFDocument();
ASSERT(pDocument != NULL);
CJS_Context* pContext = static_cast<CJS_Context*>(cc);
diff --git a/fpdfsdk/src/javascript/JS_Define.h b/fpdfsdk/src/javascript/JS_Define.h
index b21f894ec8..867fafb3c2 100644
--- a/fpdfsdk/src/javascript/JS_Define.h
+++ b/fpdfsdk/src/javascript/JS_Define.h
@@ -147,7 +147,7 @@ void JSMethod(const char* method_name_string,
static_cast<CJS_Runtime*>(FXJS_GetRuntimeFromIsolate(isolate));
if (!pRuntime)
return;
- IJS_Context* cc = pRuntime->GetCurrentContext();
+ IJS_Context* pContext = pRuntime->GetCurrentContext();
CJS_Parameters parameters;
for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) {
parameters.push_back(CJS_Value(pRuntime, info[i], CJS_Value::VT_unknown));
@@ -156,7 +156,7 @@ void JSMethod(const char* method_name_string,
CJS_Object* pJSObj = (CJS_Object*)FXJS_GetPrivate(isolate, info.Holder());
C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
CFX_WideString sError;
- if (!(pObj->*M)(cc, parameters, valueRes, sError)) {
+ if (!(pObj->*M)(pContext, parameters, valueRes, sError)) {
FXJS_Error(isolate, JSFormatErrorString(class_name_string,
method_name_string, sError));
return;
@@ -435,24 +435,22 @@ void JSSpecialPropDel(const char* class_name,
}
}
-template <FX_BOOL (*F)(IJS_Context* cc,
- const CJS_Parameters& params,
- CJS_Value& vRet,
- CFX_WideString& sError)>
+template <FX_BOOL (
+ *F)(IJS_Context*, const CJS_Parameters&, CJS_Value&, CFX_WideString&)>
void JSGlobalFunc(const char* func_name_string,
const v8::FunctionCallbackInfo<v8::Value>& info) {
CJS_Runtime* pRuntime =
static_cast<CJS_Runtime*>(FXJS_GetRuntimeFromIsolate(info.GetIsolate()));
if (!pRuntime)
return;
- IJS_Context* cc = pRuntime->GetCurrentContext();
+ IJS_Context* pContext = pRuntime->GetCurrentContext();
CJS_Parameters parameters;
for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) {
parameters.push_back(CJS_Value(pRuntime, info[i], CJS_Value::VT_unknown));
}
CJS_Value valueRes(pRuntime);
CFX_WideString sError;
- if (!(*F)(cc, parameters, valueRes, sError)) {
+ if (!(*F)(pContext, parameters, valueRes, sError)) {
FXJS_Error(pRuntime->GetIsolate(),
JSFormatErrorString(func_name_string, nullptr, sError));
return;
diff --git a/fpdfsdk/src/javascript/JS_GlobalData.cpp b/fpdfsdk/src/javascript/JS_GlobalData.cpp
index cf51f9f73d..cf5b997dd2 100644
--- a/fpdfsdk/src/javascript/JS_GlobalData.cpp
+++ b/fpdfsdk/src/javascript/JS_GlobalData.cpp
@@ -104,7 +104,7 @@ CJS_GlobalData* CJS_GlobalData::g_Instance = nullptr;
// static
CJS_GlobalData* CJS_GlobalData::GetRetainedInstance(CPDFDoc_Environment* pApp) {
if (!g_Instance) {
- g_Instance = new CJS_GlobalData(pApp);
+ g_Instance = new CJS_GlobalData();
}
++g_Instance->m_RefCount;
return g_Instance;
@@ -117,7 +117,7 @@ void CJS_GlobalData::Release() {
}
}
-CJS_GlobalData::CJS_GlobalData(CPDFDoc_Environment* pApp) : m_RefCount(0) {
+CJS_GlobalData::CJS_GlobalData() : m_RefCount(0) {
m_sFilePath += SDK_JS_GLOBALDATA_FILENAME;
LoadGlobalPersistentVariables();
}
diff --git a/fpdfsdk/src/javascript/JS_GlobalData.h b/fpdfsdk/src/javascript/JS_GlobalData.h
index 606fe4b409..a358e80e55 100644
--- a/fpdfsdk/src/javascript/JS_GlobalData.h
+++ b/fpdfsdk/src/javascript/JS_GlobalData.h
@@ -79,7 +79,7 @@ class CJS_GlobalData {
private:
static CJS_GlobalData* g_Instance;
- CJS_GlobalData(CPDFDoc_Environment* pApp);
+ CJS_GlobalData();
~CJS_GlobalData();
void LoadGlobalPersistentVariables();
@@ -98,7 +98,6 @@ class CJS_GlobalData {
CJS_KeyValue* pData,
CFX_BinaryBuf& sData);
- private:
size_t m_RefCount;
CFX_ArrayTemplate<CJS_GlobalData_Element*> m_arrayGlobalData;
CFX_WideString m_sFilePath;
diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp
index 4331476bed..34a18dc385 100644
--- a/fpdfsdk/src/javascript/JS_Runtime.cpp
+++ b/fpdfsdk/src/javascript/JS_Runtime.cpp
@@ -214,9 +214,3 @@ void CJS_Runtime::RemoveObserver(Observer* observer) {
ASSERT(m_observers.find(observer) != m_observers.end());
m_observers.erase(observer);
}
-
-CFX_WideString ChangeObjName(const CFX_WideString& str) {
- CFX_WideString sRet = str;
- sRet.Replace(L"_", L".");
- return sRet;
-}