diff options
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/cpdfsdk_actionhandler.cpp | 38 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_actionhandler.h | 12 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_helpers.cpp | 14 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_helpers.h | 17 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_interform.cpp | 14 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_interform.h | 2 | ||||
-rw-r--r-- | fpdfsdk/fpdf_doc.cpp | 4 |
7 files changed, 55 insertions, 46 deletions
diff --git a/fpdfsdk/cpdfsdk_actionhandler.cpp b/fpdfsdk/cpdfsdk_actionhandler.cpp index 660b09c515..d7bcd7f350 100644 --- a/fpdfsdk/cpdfsdk_actionhandler.cpp +++ b/fpdfsdk/cpdfsdk_actionhandler.cpp @@ -23,7 +23,7 @@ bool CPDFSDK_ActionHandler::DoAction_DocOpen( const CPDF_Action& action, CPDFSDK_FormFillEnvironment* pFormFillEnv) { - std::set<CPDF_Dictionary*> visited; + std::set<const CPDF_Dictionary*> visited; return ExecuteDocumentOpenAction(action, pFormFillEnv, &visited); } @@ -64,7 +64,7 @@ bool CPDFSDK_ActionHandler::DoAction_Page( const CPDF_Action& action, enum CPDF_AAction::AActionType eType, CPDFSDK_FormFillEnvironment* pFormFillEnv) { - std::set<CPDF_Dictionary*> visited; + std::set<const CPDF_Dictionary*> visited; return ExecuteDocumentPageAction(action, eType, pFormFillEnv, &visited); } @@ -72,7 +72,7 @@ bool CPDFSDK_ActionHandler::DoAction_Document( const CPDF_Action& action, enum CPDF_AAction::AActionType eType, CPDFSDK_FormFillEnvironment* pFormFillEnv) { - std::set<CPDF_Dictionary*> visited; + std::set<const CPDF_Dictionary*> visited; return ExecuteDocumentPageAction(action, eType, pFormFillEnv, &visited); } @@ -81,7 +81,7 @@ bool CPDFSDK_ActionHandler::DoAction_BookMark( const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_FormFillEnvironment* pFormFillEnv) { - std::set<CPDF_Dictionary*> visited; + std::set<const CPDF_Dictionary*> visited; return ExecuteBookMark(action, pFormFillEnv, pBookMark, &visited); } @@ -90,14 +90,14 @@ bool CPDFSDK_ActionHandler::DoAction_Screen( CPDF_AAction::AActionType type, CPDFSDK_FormFillEnvironment* pFormFillEnv, CPDFSDK_Annot* pScreen) { - std::set<CPDF_Dictionary*> visited; + std::set<const CPDF_Dictionary*> visited; return ExecuteScreenAction(action, type, pFormFillEnv, pScreen, &visited); } bool CPDFSDK_ActionHandler::DoAction_Link( const CPDF_Action& action, CPDFSDK_FormFillEnvironment* pFormFillEnv) { - std::set<CPDF_Dictionary*> visited; + std::set<const CPDF_Dictionary*> visited; return ExecuteLinkAction(action, pFormFillEnv, &visited); } @@ -107,7 +107,7 @@ bool CPDFSDK_ActionHandler::DoAction_Field( CPDFSDK_FormFillEnvironment* pFormFillEnv, CPDF_FormField* pFormField, CPDFSDK_FieldAction* data) { - std::set<CPDF_Dictionary*> visited; + std::set<const CPDF_Dictionary*> visited; return ExecuteFieldAction(action, type, pFormFillEnv, pFormField, data, &visited); } @@ -115,8 +115,8 @@ bool CPDFSDK_ActionHandler::DoAction_Field( bool CPDFSDK_ActionHandler::ExecuteDocumentOpenAction( const CPDF_Action& action, CPDFSDK_FormFillEnvironment* pFormFillEnv, - std::set<CPDF_Dictionary*>* visited) { - CPDF_Dictionary* pDict = action.GetDict(); + std::set<const CPDF_Dictionary*>* visited) { + const CPDF_Dictionary* pDict = action.GetDict(); if (pdfium::ContainsKey(*visited, pDict)) return false; @@ -145,8 +145,8 @@ bool CPDFSDK_ActionHandler::ExecuteDocumentOpenAction( bool CPDFSDK_ActionHandler::ExecuteLinkAction( const CPDF_Action& action, CPDFSDK_FormFillEnvironment* pFormFillEnv, - std::set<CPDF_Dictionary*>* visited) { - CPDF_Dictionary* pDict = action.GetDict(); + std::set<const CPDF_Dictionary*>* visited) { + const CPDF_Dictionary* pDict = action.GetDict(); if (pdfium::ContainsKey(*visited, pDict)) return false; @@ -175,8 +175,8 @@ bool CPDFSDK_ActionHandler::ExecuteDocumentPageAction( const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_FormFillEnvironment* pFormFillEnv, - std::set<CPDF_Dictionary*>* visited) { - CPDF_Dictionary* pDict = action.GetDict(); + std::set<const CPDF_Dictionary*>* visited) { + const CPDF_Dictionary* pDict = action.GetDict(); if (pdfium::ContainsKey(*visited, pDict)) return false; @@ -220,8 +220,8 @@ bool CPDFSDK_ActionHandler::ExecuteFieldAction( CPDFSDK_FormFillEnvironment* pFormFillEnv, CPDF_FormField* pFormField, CPDFSDK_FieldAction* data, - std::set<CPDF_Dictionary*>* visited) { - CPDF_Dictionary* pDict = action.GetDict(); + std::set<const CPDF_Dictionary*>* visited) { + const CPDF_Dictionary* pDict = action.GetDict(); if (pdfium::ContainsKey(*visited, pDict)) return false; @@ -256,8 +256,8 @@ bool CPDFSDK_ActionHandler::ExecuteScreenAction( CPDF_AAction::AActionType type, CPDFSDK_FormFillEnvironment* pFormFillEnv, CPDFSDK_Annot* pScreen, - std::set<CPDF_Dictionary*>* visited) { - CPDF_Dictionary* pDict = action.GetDict(); + std::set<const CPDF_Dictionary*>* visited) { + const CPDF_Dictionary* pDict = action.GetDict(); if (pdfium::ContainsKey(*visited, pDict)) return false; @@ -282,8 +282,8 @@ bool CPDFSDK_ActionHandler::ExecuteBookMark( const CPDF_Action& action, CPDFSDK_FormFillEnvironment* pFormFillEnv, CPDF_Bookmark* pBookmark, - std::set<CPDF_Dictionary*>* visited) { - CPDF_Dictionary* pDict = action.GetDict(); + std::set<const CPDF_Dictionary*>* visited) { + const CPDF_Dictionary* pDict = action.GetDict(); if (pdfium::ContainsKey(*visited, pDict)) return false; diff --git a/fpdfsdk/cpdfsdk_actionhandler.h b/fpdfsdk/cpdfsdk_actionhandler.h index 78d3e22e4f..a144504dec 100644 --- a/fpdfsdk/cpdfsdk_actionhandler.h +++ b/fpdfsdk/cpdfsdk_actionhandler.h @@ -68,29 +68,29 @@ class CPDFSDK_ActionHandler { bool ExecuteDocumentOpenAction(const CPDF_Action& action, CPDFSDK_FormFillEnvironment* pFormFillEnv, - std::set<CPDF_Dictionary*>* visited); + std::set<const CPDF_Dictionary*>* visited); bool ExecuteDocumentPageAction(const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_FormFillEnvironment* pFormFillEnv, - std::set<CPDF_Dictionary*>* visited); + std::set<const CPDF_Dictionary*>* visited); bool ExecuteFieldAction(const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_FormFillEnvironment* pFormFillEnv, CPDF_FormField* pFormField, CPDFSDK_FieldAction* data, - std::set<CPDF_Dictionary*>* visited); + std::set<const CPDF_Dictionary*>* visited); bool ExecuteScreenAction(const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_FormFillEnvironment* pFormFillEnv, CPDFSDK_Annot* pScreen, - std::set<CPDF_Dictionary*>* visited); + std::set<const CPDF_Dictionary*>* visited); bool ExecuteBookMark(const CPDF_Action& action, CPDFSDK_FormFillEnvironment* pFormFillEnv, CPDF_Bookmark* pBookmark, - std::set<CPDF_Dictionary*>* visited); + std::set<const CPDF_Dictionary*>* visited); bool ExecuteLinkAction(const CPDF_Action& action, CPDFSDK_FormFillEnvironment* pFormFillEnv, - std::set<CPDF_Dictionary*>* visited); + std::set<const CPDF_Dictionary*>* visited); void DoAction_NoJs(const CPDF_Action& action, CPDFSDK_FormFillEnvironment* pFormFillEnv); diff --git a/fpdfsdk/cpdfsdk_helpers.cpp b/fpdfsdk/cpdfsdk_helpers.cpp index 87ba9e2ec2..eb91bcf9ba 100644 --- a/fpdfsdk/cpdfsdk_helpers.cpp +++ b/fpdfsdk/cpdfsdk_helpers.cpp @@ -224,14 +224,15 @@ void CheckUnSupportError(CPDF_Document* pDoc, uint32_t err_code) { return; } if (pRootDict->KeyExist("Names")) { - CPDF_Dictionary* pNameDict = pRootDict->GetDictFor("Names"); + const CPDF_Dictionary* pNameDict = pRootDict->GetDictFor("Names"); if (pNameDict && pNameDict->KeyExist("EmbeddedFiles")) { RaiseUnSupportError(FPDF_UNSP_DOC_ATTACHMENT); return; } if (pNameDict && pNameDict->KeyExist("JavaScript")) { - CPDF_Dictionary* pJSDict = pNameDict->GetDictFor("JavaScript"); - CPDF_Array* pArray = pJSDict ? pJSDict->GetArrayFor("Names") : nullptr; + const CPDF_Dictionary* pJSDict = pNameDict->GetDictFor("JavaScript"); + const CPDF_Array* pArray = + pJSDict ? pJSDict->GetArrayFor("Names") : nullptr; if (pArray) { for (size_t i = 0; i < pArray->GetCount(); i++) { ByteString cbStr = pArray->GetStringAt(i); @@ -384,7 +385,12 @@ CFX_FloatRect CFXFloatRectFromFSRECTF(const FS_RECTF& rect) { return CFX_FloatRect(rect.left, rect.bottom, rect.right, rect.top); } -CPDF_Array* GetQuadPointsArrayFromDictionary(const CPDF_Dictionary* dict) { +const CPDF_Array* GetQuadPointsArrayFromDictionary( + const CPDF_Dictionary* dict) { + return dict ? dict->GetArrayFor("QuadPoints") : nullptr; +} + +CPDF_Array* GetQuadPointsArrayFromDictionary(CPDF_Dictionary* dict) { return dict ? dict->GetArrayFor("QuadPoints") : nullptr; } diff --git a/fpdfsdk/cpdfsdk_helpers.h b/fpdfsdk/cpdfsdk_helpers.h index d93ecfc89b..10f44e409a 100644 --- a/fpdfsdk/cpdfsdk_helpers.h +++ b/fpdfsdk/cpdfsdk_helpers.h @@ -64,11 +64,11 @@ FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc); CPDF_Document* CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc); // Conversions to/from incomplete FPDF_ API types. -inline FPDF_ACTION FPDFActionFromCPDFDictionary(CPDF_Dictionary* action) { +inline FPDF_ACTION FPDFActionFromCPDFDictionary(const CPDF_Dictionary* action) { return reinterpret_cast<FPDF_ACTION>(action); } -inline CPDF_Dictionary* CPDFDictionaryFromFPDFAction(FPDF_ACTION action) { - return reinterpret_cast<CPDF_Dictionary*>(action); +inline const CPDF_Dictionary* CPDFDictionaryFromFPDFAction(FPDF_ACTION action) { + return reinterpret_cast<const CPDF_Dictionary*>(action); } inline FPDF_ANNOTATION FPDFAnnotationFromCPDFAnnotContext( @@ -94,11 +94,13 @@ inline CFX_DIBitmap* CFXDIBitmapFromFPDFBitmap(FPDF_BITMAP bitmap) { return reinterpret_cast<CFX_DIBitmap*>(bitmap); } -inline FPDF_BOOKMARK FPDFBookmarkFromCPDFDictionary(CPDF_Dictionary* bookmark) { +inline FPDF_BOOKMARK FPDFBookmarkFromCPDFDictionary( + const CPDF_Dictionary* bookmark) { return reinterpret_cast<FPDF_BOOKMARK>(bookmark); } -inline CPDF_Dictionary* CPDFDictionaryFromFPDFBookmark(FPDF_BOOKMARK bookmark) { - return reinterpret_cast<CPDF_Dictionary*>(bookmark); +inline const CPDF_Dictionary* CPDFDictionaryFromFPDFBookmark( + FPDF_BOOKMARK bookmark) { + return reinterpret_cast<const CPDF_Dictionary*>(bookmark); } inline FPDF_CLIPPATH FPDFClipPathFromCPDFClipPath(CPDF_ClipPath* path) { @@ -220,7 +222,8 @@ RetainPtr<IFX_SeekableStream> MakeSeekableStream( FPDF_FILEHANDLER* pFileHandler); #endif // PDF_ENABLE_XFA -CPDF_Array* GetQuadPointsArrayFromDictionary(const CPDF_Dictionary* dict); +const CPDF_Array* GetQuadPointsArrayFromDictionary(const CPDF_Dictionary* dict); +CPDF_Array* GetQuadPointsArrayFromDictionary(CPDF_Dictionary* dict); CPDF_Array* AddQuadPointsArrayToDictionary(CPDF_Dictionary* dict); bool IsValidQuadPointsIndex(const CPDF_Array* array, size_t index); bool GetQuadPointsAtIndex(const CPDF_Array* array, diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp index b37562ccf2..638b4dfc07 100644 --- a/fpdfsdk/cpdfsdk_interform.cpp +++ b/fpdfsdk/cpdfsdk_interform.cpp @@ -412,7 +412,7 @@ bool CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) { ASSERT(action.GetDict()); CPDF_ActionFields af(&action); - std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); + std::vector<const CPDF_Object*> fieldObjects = af.GetAllFields(); std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); bool bHide = action.GetHideStatus(); @@ -446,11 +446,11 @@ bool CPDFSDK_InterForm::DoAction_SubmitForm(const CPDF_Action& action) { if (sDestination.IsEmpty()) return false; - CPDF_Dictionary* pActionDict = action.GetDict(); + const CPDF_Dictionary* pActionDict = action.GetDict(); if (pActionDict->KeyExist("Fields")) { CPDF_ActionFields af(&action); uint32_t dwFlags = action.GetFlags(); - std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); + std::vector<const CPDF_Object*> fieldObjects = af.GetAllFields(); std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); if (!fields.empty()) { bool bIncludeOrExclude = !(dwFlags & 0x01); @@ -590,7 +590,7 @@ ByteString CPDFSDK_InterForm::ExportFormToFDFTextBuf() { void CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action) { ASSERT(action.GetDict()); - CPDF_Dictionary* pActionDict = action.GetDict(); + const CPDF_Dictionary* pActionDict = action.GetDict(); if (!pActionDict->KeyExist("Fields")) { m_pInterForm->ResetForm(true); return; @@ -599,15 +599,15 @@ void CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action) { CPDF_ActionFields af(&action); uint32_t dwFlags = action.GetFlags(); - std::vector<CPDF_Object*> fieldObjects = af.GetAllFields(); + std::vector<const CPDF_Object*> fieldObjects = af.GetAllFields(); std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects); m_pInterForm->ResetForm(fields, !(dwFlags & 0x01), true); } std::vector<CPDF_FormField*> CPDFSDK_InterForm::GetFieldFromObjects( - const std::vector<CPDF_Object*>& objects) const { + const std::vector<const CPDF_Object*>& objects) const { std::vector<CPDF_FormField*> fields; - for (CPDF_Object* pObject : objects) { + for (const CPDF_Object* pObject : objects) { if (!pObject || !pObject->IsString()) continue; diff --git a/fpdfsdk/cpdfsdk_interform.h b/fpdfsdk/cpdfsdk_interform.h index 6195ee9f5f..bb6d7fc260 100644 --- a/fpdfsdk/cpdfsdk_interform.h +++ b/fpdfsdk/cpdfsdk_interform.h @@ -80,7 +80,7 @@ class CPDFSDK_InterForm : public IPDF_FormNotify { void DoAction_ResetForm(const CPDF_Action& action); std::vector<CPDF_FormField*> GetFieldFromObjects( - const std::vector<CPDF_Object*>& objects) const; + const std::vector<const CPDF_Object*>& objects) const; bool IsValidField(CPDF_Dictionary* pFieldDict); bool SubmitFields(const WideString& csDestination, const std::vector<CPDF_FormField*>& fields, diff --git a/fpdfsdk/fpdf_doc.cpp b/fpdfsdk/fpdf_doc.cpp index 3bb89fc48a..6b62227da2 100644 --- a/fpdfsdk/fpdf_doc.cpp +++ b/fpdfsdk/fpdf_doc.cpp @@ -26,7 +26,7 @@ namespace { CPDF_Bookmark FindBookmark(const CPDF_BookmarkTree& tree, CPDF_Bookmark bookmark, const WideString& title, - std::set<CPDF_Dictionary*>* visited) { + std::set<const CPDF_Dictionary*>* visited) { // Return if already checked to avoid circular calling. if (pdfium::ContainsKey(*visited, bookmark.GetDict())) return CPDF_Bookmark(); @@ -107,7 +107,7 @@ FPDFBookmark_Find(FPDF_DOCUMENT document, FPDF_WIDESTRING title) { CPDF_BookmarkTree tree(pDoc); size_t len = WideString::WStringLength(title); WideString encodedTitle = WideString::FromUTF16LE(title, len); - std::set<CPDF_Dictionary*> visited; + std::set<const CPDF_Dictionary*> visited; return FPDFBookmarkFromCPDFDictionary( FindBookmark(tree, CPDF_Bookmark(), encodedTitle, &visited).GetDict()); } |