Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2551)

Unified Diff: fpdfsdk/fsdk_mgr.cpp

Issue 2045013004: Fix GetPageIndex() for dynamic XFA documents. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Remove redundant CXFA_FFPageView::GetPageViewIndex Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | fpdfsdk/include/fsdk_mgr.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/fsdk_mgr.cpp
diff --git a/fpdfsdk/fsdk_mgr.cpp b/fpdfsdk/fsdk_mgr.cpp
index 835439394de0ad70f2f61b7d1bf0048635f2b318..c4c0384b44cf2fdc33006bd51612d362bf28b43d 100644
--- a/fpdfsdk/fsdk_mgr.cpp
+++ b/fpdfsdk/fsdk_mgr.cpp
@@ -34,11 +34,17 @@
#include <ctime>
#endif
+namespace {
+
+// NOTE: |bsUTF16LE| must outlive the use of the result. Care must be taken
+// since modifying the result would impact |bsUTF16LE|.
FPDF_WIDESTRING AsFPDFWideString(CFX_ByteString* bsUTF16LE) {
return reinterpret_cast<FPDF_WIDESTRING>(
bsUTF16LE->GetBuffer(bsUTF16LE->GetLength()));
}
+} // namespace
+
CPDFDoc_Environment::CPDFDoc_Environment(UnderlyingDocumentType* pDoc,
FPDF_FORMFILLINFO* pFFinfo)
: m_pInfo(pFFinfo), m_pSDKDoc(nullptr), m_pUnderlyingDoc(pDoc) {
@@ -988,19 +994,26 @@ void CPDFSDK_PageView::UpdateView(CPDFSDK_Annot* pAnnot) {
rcWindow.bottom);
}
-int CPDFSDK_PageView::GetPageIndex() {
- if (m_page) {
+int CPDFSDK_PageView::GetPageIndex() const {
+ if (!m_page)
+ return -1;
+
#ifdef PDF_ENABLE_XFA
- CPDF_Dictionary* pDic = m_page->GetPDFPage()->m_pFormDict;
-#else // PDF_ENABLE_XFA
- CPDF_Dictionary* pDic = m_page->m_pFormDict;
-#endif // PDF_ENABLE_XFA
- CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument();
- if (pDoc && pDic) {
- return pDoc->GetPageIndex(pDic->GetObjNum());
+ int nDocType = m_page->GetDocument()->GetDocType();
+ switch (nDocType) {
+ case DOCTYPE_DYNAMIC_XFA: {
+ CXFA_FFPageView* pPageView = m_page->GetXFAPageView();
+ return pPageView ? pPageView->GetPageIndex() : -1;
}
+ case DOCTYPE_STATIC_XFA:
+ case DOCTYPE_PDF:
+ return GetPageIndexForStaticPDF();
+ default:
+ return -1;
}
- return -1;
+#else // PDF_ENABLE_XFA
+ return GetPageIndexForStaticPDF();
+#endif // PDF_ENABLE_XFA
}
bool CPDFSDK_PageView::IsValidAnnot(const CPDF_Annot* p) const {
@@ -1022,3 +1035,14 @@ CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() {
}
return nullptr;
}
+
+int CPDFSDK_PageView::GetPageIndexForStaticPDF() const {
+#ifdef PDF_ENABLE_XFA
+ CPDF_Page* pPage = m_page->GetPDFPage();
+#else // PDF_ENABLE_XFA
+ CPDF_Page* pPage = m_page;
+#endif // PDF_ENABLE_XFA
+ CPDF_Dictionary* pDict = pPage->m_pFormDict;
+ CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument();
+ return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1;
+}
« no previous file with comments | « no previous file | fpdfsdk/include/fsdk_mgr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698