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

Side by Side Diff: fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp

Issue 2351673004: Cleanup CPDFXFA and CPDF document methods (Closed)
Patch Set: Review feedback Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp ('k') | fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" 7 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h"
8 8
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
10 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h" 10 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_app.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 return FALSE; 101 return FALSE;
102 } 102 }
103 103
104 m_pXFADocView->DoLayout(nullptr); 104 m_pXFADocView->DoLayout(nullptr);
105 m_pXFADocView->StopLayout(); 105 m_pXFADocView->StopLayout();
106 m_nLoadStatus = FXFA_LOADSTATUS_LOADED; 106 m_nLoadStatus = FXFA_LOADSTATUS_LOADED;
107 107
108 return TRUE; 108 return TRUE;
109 } 109 }
110 110
111 int CPDFXFA_Document::GetPageCount() { 111 int CPDFXFA_Document::GetPageCount() const {
112 if (!m_pPDFDoc && !m_pXFADoc) 112 if (!m_pPDFDoc && !m_pXFADoc)
113 return 0; 113 return 0;
114 114
115 switch (m_iDocType) { 115 switch (m_iDocType) {
116 case DOCTYPE_PDF: 116 case DOCTYPE_PDF:
117 case DOCTYPE_STATIC_XFA: 117 case DOCTYPE_STATIC_XFA:
118 if (m_pPDFDoc) 118 if (m_pPDFDoc)
119 return m_pPDFDoc->GetPageCount(); 119 return m_pPDFDoc->GetPageCount();
120 case DOCTYPE_DYNAMIC_XFA: 120 case DOCTYPE_DYNAMIC_XFA:
121 if (m_pXFADoc) 121 if (m_pXFADoc)
122 return m_pXFADocView->CountPageViews(); 122 return m_pXFADocView->CountPageViews();
123 default: 123 default:
124 return 0; 124 return 0;
125 } 125 }
126 } 126 }
127 127
128 CPDFXFA_Page* CPDFXFA_Document::GetPage(int page_index) { 128 CPDFXFA_Page* CPDFXFA_Document::GetXFAPage(int page_index) {
129 if (page_index < 0) 129 if (page_index < 0)
130 return nullptr; 130 return nullptr;
131 131
132 CPDFXFA_Page* pPage = nullptr; 132 CPDFXFA_Page* pPage = nullptr;
133 int nCount = m_XFAPageList.GetSize(); 133 int nCount = m_XFAPageList.GetSize();
134 if (nCount > 0 && page_index < nCount) { 134 if (nCount > 0 && page_index < nCount) {
135 pPage = m_XFAPageList.GetAt(page_index); 135 pPage = m_XFAPageList.GetAt(page_index);
136 if (pPage) 136 if (pPage)
137 pPage->Retain(); 137 pPage->Retain();
138 } else { 138 } else {
139 m_nPageCount = GetPageCount(); 139 m_nPageCount = GetPageCount();
140 m_XFAPageList.SetSize(m_nPageCount); 140 m_XFAPageList.SetSize(m_nPageCount);
141 } 141 }
142 if (pPage) 142 if (pPage)
143 return pPage; 143 return pPage;
144 144
145 pPage = new CPDFXFA_Page(this, page_index); 145 pPage = new CPDFXFA_Page(this, page_index);
146 if (!pPage->LoadPage()) { 146 if (!pPage->LoadPage()) {
147 pPage->Release(); 147 pPage->Release();
148 return nullptr; 148 return nullptr;
149 } 149 }
150 m_XFAPageList.SetAt(page_index, pPage); 150 m_XFAPageList.SetAt(page_index, pPage);
151 return pPage; 151 return pPage;
152 } 152 }
153 153
154 CPDFXFA_Page* CPDFXFA_Document::GetPage(CXFA_FFPageView* pPage) { 154 CPDFXFA_Page* CPDFXFA_Document::GetXFAPage(CXFA_FFPageView* pPage) const {
155 if (!pPage) 155 if (!pPage)
156 return nullptr; 156 return nullptr;
157 157
158 if (!m_pXFADoc) 158 if (!m_pXFADoc)
159 return nullptr; 159 return nullptr;
160 160
161 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) 161 if (m_iDocType != DOCTYPE_DYNAMIC_XFA)
162 return nullptr; 162 return nullptr;
163 163
164 int nSize = m_XFAPageList.GetSize(); 164 int nSize = m_XFAPageList.GetSize();
(...skipping 30 matching lines...) Expand all
195 CPDFSDK_Environment* pFormFillEnv) { 195 CPDFSDK_Environment* pFormFillEnv) {
196 if (!m_pSDKDoc && pFormFillEnv) 196 if (!m_pSDKDoc && pFormFillEnv)
197 m_pSDKDoc.reset(new CPDFSDK_Document(this, pFormFillEnv)); 197 m_pSDKDoc.reset(new CPDFSDK_Document(this, pFormFillEnv));
198 return m_pSDKDoc.get(); 198 return m_pSDKDoc.get();
199 } 199 }
200 200
201 void CPDFXFA_Document::ClearChangeMark() { 201 void CPDFXFA_Document::ClearChangeMark() {
202 if (m_pSDKDoc) 202 if (m_pSDKDoc)
203 m_pSDKDoc->ClearChangeMark(); 203 m_pSDKDoc->ClearChangeMark();
204 } 204 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp ('k') | fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698