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

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

Issue 2469813004: Rename CPDFXFA_Document to CPDFXFA_Context (Closed)
Patch Set: Merge to master Created 4 years, 1 month 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_page.h ('k') | fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.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/cpdfxfa_page.h" 7 #include "fpdfsdk/fpdfxfa/cpdfxfa_page.h"
8 8
9 #include "core/fpdfapi/page/cpdf_page.h" 9 #include "core/fpdfapi/page/cpdf_page.h"
10 #include "core/fpdfapi/parser/cpdf_document.h" 10 #include "core/fpdfapi/parser/cpdf_document.h"
11 #include "fpdfsdk/fpdfxfa/cpdfxfa_document.h" 11 #include "fpdfsdk/fpdfxfa/cpdfxfa_context.h"
12 #include "fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h" 12 #include "fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h"
13 #include "fpdfsdk/fsdk_define.h" 13 #include "fpdfsdk/fsdk_define.h"
14 #include "public/fpdf_formfill.h" 14 #include "public/fpdf_formfill.h"
15 #include "third_party/base/ptr_util.h" 15 #include "third_party/base/ptr_util.h"
16 #include "xfa/fxfa/xfa_ffdocview.h" 16 #include "xfa/fxfa/xfa_ffdocview.h"
17 #include "xfa/fxfa/xfa_ffpageview.h" 17 #include "xfa/fxfa/xfa_ffpageview.h"
18 18
19 CPDFXFA_Page::CPDFXFA_Page(CPDFXFA_Document* pDoc, int page_index) 19 CPDFXFA_Page::CPDFXFA_Page(CPDFXFA_Context* pContext, int page_index)
20 : m_pXFAPageView(nullptr), 20 : m_pXFAPageView(nullptr),
21 m_pDocument(pDoc), 21 m_pContext(pContext),
22 m_iPageIndex(page_index), 22 m_iPageIndex(page_index),
23 m_iRef(1) {} 23 m_iRef(1) {}
24 24
25 CPDFXFA_Page::~CPDFXFA_Page() { 25 CPDFXFA_Page::~CPDFXFA_Page() {
26 if (m_pDocument) 26 if (m_pContext)
27 m_pDocument->RemovePage(this); 27 m_pContext->RemovePage(this);
28 } 28 }
29 29
30 FX_BOOL CPDFXFA_Page::LoadPDFPage() { 30 FX_BOOL CPDFXFA_Page::LoadPDFPage() {
31 if (!m_pDocument) 31 if (!m_pContext)
32 return FALSE; 32 return FALSE;
33 33
34 CPDF_Document* pPDFDoc = m_pDocument->GetPDFDoc(); 34 CPDF_Document* pPDFDoc = m_pContext->GetPDFDoc();
35 if (!pPDFDoc) 35 if (!pPDFDoc)
36 return FALSE; 36 return FALSE;
37 37
38 CPDF_Dictionary* pDict = pPDFDoc->GetPage(m_iPageIndex); 38 CPDF_Dictionary* pDict = pPDFDoc->GetPage(m_iPageIndex);
39 if (!pDict) 39 if (!pDict)
40 return FALSE; 40 return FALSE;
41 41
42 if (!m_pPDFPage || m_pPDFPage->m_pFormDict != pDict) { 42 if (!m_pPDFPage || m_pPDFPage->m_pFormDict != pDict) {
43 m_pPDFPage = pdfium::MakeUnique<CPDF_Page>(pPDFDoc, pDict, true); 43 m_pPDFPage = pdfium::MakeUnique<CPDF_Page>(pPDFDoc, pDict, true);
44 m_pPDFPage->ParseContent(); 44 m_pPDFPage->ParseContent();
45 } 45 }
46 return TRUE; 46 return TRUE;
47 } 47 }
48 48
49 FX_BOOL CPDFXFA_Page::LoadXFAPageView() { 49 FX_BOOL CPDFXFA_Page::LoadXFAPageView() {
50 if (!m_pDocument) 50 if (!m_pContext)
51 return FALSE; 51 return FALSE;
52 52
53 CXFA_FFDoc* pXFADoc = m_pDocument->GetXFADoc(); 53 CXFA_FFDoc* pXFADoc = m_pContext->GetXFADoc();
54 if (!pXFADoc) 54 if (!pXFADoc)
55 return FALSE; 55 return FALSE;
56 56
57 CXFA_FFDocView* pXFADocView = m_pDocument->GetXFADocView(); 57 CXFA_FFDocView* pXFADocView = m_pContext->GetXFADocView();
58 if (!pXFADocView) 58 if (!pXFADocView)
59 return FALSE; 59 return FALSE;
60 60
61 CXFA_FFPageView* pPageView = pXFADocView->GetPageView(m_iPageIndex); 61 CXFA_FFPageView* pPageView = pXFADocView->GetPageView(m_iPageIndex);
62 if (!pPageView) 62 if (!pPageView)
63 return FALSE; 63 return FALSE;
64 64
65 m_pXFAPageView = pPageView; 65 m_pXFAPageView = pPageView;
66 return TRUE; 66 return TRUE;
67 } 67 }
68 68
69 FX_BOOL CPDFXFA_Page::LoadPage() { 69 FX_BOOL CPDFXFA_Page::LoadPage() {
70 if (!m_pDocument || m_iPageIndex < 0) 70 if (!m_pContext || m_iPageIndex < 0)
71 return FALSE; 71 return FALSE;
72 72
73 int iDocType = m_pDocument->GetDocType(); 73 int iDocType = m_pContext->GetDocType();
74 switch (iDocType) { 74 switch (iDocType) {
75 case DOCTYPE_PDF: 75 case DOCTYPE_PDF:
76 case DOCTYPE_STATIC_XFA: { 76 case DOCTYPE_STATIC_XFA: {
77 return LoadPDFPage(); 77 return LoadPDFPage();
78 } 78 }
79 case DOCTYPE_DYNAMIC_XFA: { 79 case DOCTYPE_DYNAMIC_XFA: {
80 return LoadXFAPageView(); 80 return LoadXFAPageView();
81 } 81 }
82 default: 82 default:
83 return FALSE; 83 return FALSE;
84 } 84 }
85 } 85 }
86 86
87 FX_BOOL CPDFXFA_Page::LoadPDFPage(CPDF_Dictionary* pageDict) { 87 FX_BOOL CPDFXFA_Page::LoadPDFPage(CPDF_Dictionary* pageDict) {
88 if (!m_pDocument || m_iPageIndex < 0 || !pageDict) 88 if (!m_pContext || m_iPageIndex < 0 || !pageDict)
89 return FALSE; 89 return FALSE;
90 90
91 m_pPDFPage = 91 m_pPDFPage =
92 pdfium::MakeUnique<CPDF_Page>(m_pDocument->GetPDFDoc(), pageDict, true); 92 pdfium::MakeUnique<CPDF_Page>(m_pContext->GetPDFDoc(), pageDict, true);
93 m_pPDFPage->ParseContent(); 93 m_pPDFPage->ParseContent();
94 return TRUE; 94 return TRUE;
95 } 95 }
96 96
97 FX_FLOAT CPDFXFA_Page::GetPageWidth() const { 97 FX_FLOAT CPDFXFA_Page::GetPageWidth() const {
98 if (!m_pPDFPage && !m_pXFAPageView) 98 if (!m_pPDFPage && !m_pXFAPageView)
99 return 0.0f; 99 return 0.0f;
100 100
101 int nDocType = m_pDocument->GetDocType(); 101 int nDocType = m_pContext->GetDocType();
102 switch (nDocType) { 102 switch (nDocType) {
103 case DOCTYPE_DYNAMIC_XFA: { 103 case DOCTYPE_DYNAMIC_XFA: {
104 if (m_pXFAPageView) { 104 if (m_pXFAPageView) {
105 CFX_RectF rect; 105 CFX_RectF rect;
106 m_pXFAPageView->GetPageViewRect(rect); 106 m_pXFAPageView->GetPageViewRect(rect);
107 return rect.width; 107 return rect.width;
108 } 108 }
109 } break; 109 } break;
110 case DOCTYPE_STATIC_XFA: 110 case DOCTYPE_STATIC_XFA:
111 case DOCTYPE_PDF: { 111 case DOCTYPE_PDF: {
112 if (m_pPDFPage) 112 if (m_pPDFPage)
113 return m_pPDFPage->GetPageWidth(); 113 return m_pPDFPage->GetPageWidth();
114 } break; 114 } break;
115 default: 115 default:
116 return 0.0f; 116 return 0.0f;
117 } 117 }
118 118
119 return 0.0f; 119 return 0.0f;
120 } 120 }
121 121
122 FX_FLOAT CPDFXFA_Page::GetPageHeight() const { 122 FX_FLOAT CPDFXFA_Page::GetPageHeight() const {
123 if (!m_pPDFPage && !m_pXFAPageView) 123 if (!m_pPDFPage && !m_pXFAPageView)
124 return 0.0f; 124 return 0.0f;
125 125
126 int nDocType = m_pDocument->GetDocType(); 126 int nDocType = m_pContext->GetDocType();
127 switch (nDocType) { 127 switch (nDocType) {
128 case DOCTYPE_PDF: 128 case DOCTYPE_PDF:
129 case DOCTYPE_STATIC_XFA: { 129 case DOCTYPE_STATIC_XFA: {
130 if (m_pPDFPage) 130 if (m_pPDFPage)
131 return m_pPDFPage->GetPageHeight(); 131 return m_pPDFPage->GetPageHeight();
132 } break; 132 } break;
133 case DOCTYPE_DYNAMIC_XFA: { 133 case DOCTYPE_DYNAMIC_XFA: {
134 if (m_pXFAPageView) { 134 if (m_pXFAPageView) {
135 CFX_RectF rect; 135 CFX_RectF rect;
136 m_pXFAPageView->GetPageViewRect(rect); 136 m_pXFAPageView->GetPageViewRect(rect);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 196
197 void CPDFXFA_Page::GetDisplayMatrix(CFX_Matrix& matrix, 197 void CPDFXFA_Page::GetDisplayMatrix(CFX_Matrix& matrix,
198 int xPos, 198 int xPos,
199 int yPos, 199 int yPos,
200 int xSize, 200 int xSize,
201 int ySize, 201 int ySize,
202 int iRotate) const { 202 int iRotate) const {
203 if (!m_pPDFPage && !m_pXFAPageView) 203 if (!m_pPDFPage && !m_pXFAPageView)
204 return; 204 return;
205 205
206 int nDocType = m_pDocument->GetDocType(); 206 int nDocType = m_pContext->GetDocType();
207 switch (nDocType) { 207 switch (nDocType) {
208 case DOCTYPE_DYNAMIC_XFA: { 208 case DOCTYPE_DYNAMIC_XFA: {
209 if (m_pXFAPageView) { 209 if (m_pXFAPageView) {
210 CFX_Rect rect; 210 CFX_Rect rect;
211 rect.Set(xPos, yPos, xSize, ySize); 211 rect.Set(xPos, yPos, xSize, ySize);
212 m_pXFAPageView->GetDisplayMatrix(matrix, rect, iRotate); 212 m_pXFAPageView->GetDisplayMatrix(matrix, rect, iRotate);
213 } 213 }
214 } break; 214 } break;
215 case DOCTYPE_PDF: 215 case DOCTYPE_PDF:
216 case DOCTYPE_STATIC_XFA: { 216 case DOCTYPE_STATIC_XFA: {
217 if (m_pPDFPage) { 217 if (m_pPDFPage) {
218 m_pPDFPage->GetDisplayMatrix(matrix, xPos, yPos, xSize, ySize, iRotate); 218 m_pPDFPage->GetDisplayMatrix(matrix, xPos, yPos, xSize, ySize, iRotate);
219 } 219 }
220 } break; 220 } break;
221 default: 221 default:
222 return; 222 return;
223 } 223 }
224 } 224 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfxfa/cpdfxfa_page.h ('k') | fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698