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

Side by Side Diff: fpdfsdk/src/fpdfeditpage.cpp

Issue 1411623002: Merge to XFA: Introduce CPDFPageFromFPFDPage() (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Stray file. Created 5 years, 2 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/src/fpdfeditimg.cpp ('k') | fpdfsdk/src/fpdfformfill.cpp » ('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 "../../public/fpdf_edit.h" 7 #include "../../public/fpdf_edit.h"
8 #include "../../public/fpdf_formfill.h" 8 #include "../../public/fpdf_formfill.h"
9 #include "../include/fsdk_define.h" 9 #include "../include/fsdk_define.h"
10 #include "../include/fpdfxfa/fpdfxfa_doc.h" 10 #include "../include/fpdfxfa/fpdfxfa_doc.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 pPageDict->SetAt("Resources", new CPDF_Dictionary); 82 pPageDict->SetAt("Resources", new CPDF_Dictionary);
83 83
84 CPDFXFA_Page* pPage = 84 CPDFXFA_Page* pPage =
85 new CPDFXFA_Page((CPDFXFA_Document*)document, page_index); 85 new CPDFXFA_Page((CPDFXFA_Document*)document, page_index);
86 pPage->LoadPDFPage(pPageDict); 86 pPage->LoadPDFPage(pPageDict);
87 87
88 return pPage; 88 return pPage;
89 } 89 }
90 90
91 DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page) { 91 DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page) {
92 CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage(); 92 CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
93 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || 93 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") ||
94 !pPage->m_pFormDict->GetElement("Type")->GetDirect() || 94 !pPage->m_pFormDict->GetElement("Type")->GetDirect() ||
95 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( 95 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(
96 "Page")) { 96 "Page")) {
97 return -1; 97 return -1;
98 } 98 }
99 CPDF_Dictionary* pDict = pPage->m_pFormDict; 99 CPDF_Dictionary* pDict = pPage->m_pFormDict;
100 100
101 int rotate = 0; 101 int rotate = 0;
102 if (pDict != NULL) { 102 if (pDict != NULL) {
(...skipping 23 matching lines...) Expand all
126 } 126 }
127 } else { 127 } else {
128 return -1; 128 return -1;
129 } 129 }
130 130
131 return rotate; 131 return rotate;
132 } 132 }
133 133
134 DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page, 134 DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page,
135 FPDF_PAGEOBJECT page_obj) { 135 FPDF_PAGEOBJECT page_obj) {
136 CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage(); 136 CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
137 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || 137 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") ||
138 !pPage->m_pFormDict->GetElement("Type")->GetDirect() || 138 !pPage->m_pFormDict->GetElement("Type")->GetDirect() ||
139 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( 139 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(
140 "Page")) { 140 "Page")) {
141 return; 141 return;
142 } 142 }
143 CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_obj; 143 CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_obj;
144 if (pPageObj == NULL) 144 if (pPageObj == NULL)
145 return; 145 return;
146 FX_POSITION LastPersition = pPage->GetLastObjectPosition(); 146 FX_POSITION LastPersition = pPage->GetLastObjectPosition();
(...skipping 21 matching lines...) Expand all
168 break; 168 break;
169 } 169 }
170 case FPDF_PAGEOBJ_FORM: { 170 case FPDF_PAGEOBJ_FORM: {
171 CPDF_FormObject* pFormObj = (CPDF_FormObject*)pPageObj; 171 CPDF_FormObject* pFormObj = (CPDF_FormObject*)pPageObj;
172 pFormObj->CalcBoundingBox(); 172 pFormObj->CalcBoundingBox();
173 break; 173 break;
174 } 174 }
175 default: 175 default:
176 break; 176 break;
177 } 177 }
178
179 // pPage->ParseContent();
180 // pPage->GenerateContent();
181 } 178 }
182 179
183 DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page) { 180 DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page) {
184 CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage(); 181 CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
185 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || 182 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") ||
186 !pPage->m_pFormDict->GetElement("Type")->GetDirect() || 183 !pPage->m_pFormDict->GetElement("Type")->GetDirect() ||
187 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( 184 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(
188 "Page")) { 185 "Page")) {
189 return -1; 186 return -1;
190 } 187 }
191 return pPage->CountObjects(); 188 return pPage->CountObjects();
192 // return 0;
193 } 189 }
194 190
195 DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPage_GetObject(FPDF_PAGE page, 191 DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPage_GetObject(FPDF_PAGE page,
196 int index) { 192 int index) {
197 CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage(); 193 CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
198 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || 194 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") ||
199 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( 195 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(
200 "Page")) { 196 "Page")) {
201 return NULL; 197 return NULL;
202 } 198 }
203 return pPage->GetObjectByIndex(index); 199 return pPage->GetObjectByIndex(index);
204 // return NULL;
205 } 200 }
206 201
207 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_HasTransparency(FPDF_PAGE page) { 202 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_HasTransparency(FPDF_PAGE page) {
208 if (!page) 203 CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
209 return FALSE; 204 return pPage && pPage->BackgroundAlphaNeeded();
210 CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
211 if (!pPage)
212 return FALSE;
213
214 return pPage->BackgroundAlphaNeeded();
215 } 205 }
216 206
217 DLLEXPORT FPDF_BOOL STDCALL 207 DLLEXPORT FPDF_BOOL STDCALL
218 FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject) { 208 FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject) {
219 if (!pageObject) 209 if (!pageObject)
220 return FALSE; 210 return FALSE;
221 CPDF_PageObject* pPageObj = (CPDF_PageObject*)pageObject; 211 CPDF_PageObject* pPageObj = (CPDF_PageObject*)pageObject;
222 212
223 const CPDF_GeneralStateData* pGeneralState = pPageObj->m_GeneralState; 213 const CPDF_GeneralStateData* pGeneralState = pPageObj->m_GeneralState;
224 int blend_type = 214 int blend_type =
(...skipping 21 matching lines...) Expand all
246 return TRUE; 236 return TRUE;
247 if (pFormObj->m_pForm && 237 if (pFormObj->m_pForm &&
248 (!(pFormObj->m_pForm->m_Transparency & PDFTRANS_ISOLATED) && 238 (!(pFormObj->m_pForm->m_Transparency & PDFTRANS_ISOLATED) &&
249 (pFormObj->m_pForm->m_Transparency & PDFTRANS_GROUP))) 239 (pFormObj->m_pForm->m_Transparency & PDFTRANS_GROUP)))
250 return TRUE; 240 return TRUE;
251 } 241 }
252 return FALSE; 242 return FALSE;
253 } 243 }
254 244
255 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GenerateContent(FPDF_PAGE page) { 245 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GenerateContent(FPDF_PAGE page) {
256 CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage(); 246 CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
257 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || 247 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") ||
258 !pPage->m_pFormDict->GetElement("Type")->GetDirect() || 248 !pPage->m_pFormDict->GetElement("Type")->GetDirect() ||
259 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( 249 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(
260 "Page")) { 250 "Page")) {
261 return FALSE; 251 return FALSE;
262 } 252 }
263 CPDF_PageContentGenerate CG(pPage); 253 CPDF_PageContentGenerate CG(pPage);
264 CG.GenerateContent(); 254 CG.GenerateContent();
265 255
266 return TRUE; 256 return TRUE;
(...skipping 14 matching lines...) Expand all
281 (FX_FLOAT)e, (FX_FLOAT)f); 271 (FX_FLOAT)e, (FX_FLOAT)f);
282 pPageObj->Transform(matrix); 272 pPageObj->Transform(matrix);
283 } 273 }
284 DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page, 274 DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page,
285 double a, 275 double a,
286 double b, 276 double b,
287 double c, 277 double c,
288 double d, 278 double d,
289 double e, 279 double e,
290 double f) { 280 double f) {
291 if (page == NULL) 281 CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
292 return;
293 CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
294 if (!pPage) 282 if (!pPage)
295 return; 283 return;
296 CPDF_AnnotList AnnotList(pPage); 284 CPDF_AnnotList AnnotList(pPage);
297 for (int i = 0; i < AnnotList.Count(); i++) { 285 for (int i = 0; i < AnnotList.Count(); i++) {
298 CPDF_Annot* pAnnot = AnnotList.GetAt(i); 286 CPDF_Annot* pAnnot = AnnotList.GetAt(i);
299 // transformAnnots Rectangle 287 // transformAnnots Rectangle
300 CPDF_Rect rect; 288 CPDF_Rect rect;
301 pAnnot->GetRect(rect); 289 pAnnot->GetRect(rect);
302 CFX_AffineMatrix matrix((FX_FLOAT)a, (FX_FLOAT)b, (FX_FLOAT)c, (FX_FLOAT)d, 290 CFX_AffineMatrix matrix((FX_FLOAT)a, (FX_FLOAT)b, (FX_FLOAT)c, (FX_FLOAT)d,
303 (FX_FLOAT)e, (FX_FLOAT)f); 291 (FX_FLOAT)e, (FX_FLOAT)f);
304 rect.Transform(&matrix); 292 rect.Transform(&matrix);
305 CPDF_Array* pRectArray = NULL; 293 CPDF_Array* pRectArray = NULL;
306 pRectArray = pAnnot->GetAnnotDict()->GetArray("Rect"); 294 pRectArray = pAnnot->GetAnnotDict()->GetArray("Rect");
307 if (!pRectArray) 295 if (!pRectArray)
308 pRectArray = CPDF_Array::Create(); 296 pRectArray = CPDF_Array::Create();
309 pRectArray->SetAt(0, new CPDF_Number(rect.left)); 297 pRectArray->SetAt(0, new CPDF_Number(rect.left));
310 pRectArray->SetAt(1, new CPDF_Number(rect.bottom)); 298 pRectArray->SetAt(1, new CPDF_Number(rect.bottom));
311 pRectArray->SetAt(2, new CPDF_Number(rect.right)); 299 pRectArray->SetAt(2, new CPDF_Number(rect.right));
312 pRectArray->SetAt(3, new CPDF_Number(rect.top)); 300 pRectArray->SetAt(3, new CPDF_Number(rect.top));
313 pAnnot->GetAnnotDict()->SetAt("Rect", pRectArray); 301 pAnnot->GetAnnotDict()->SetAt("Rect", pRectArray);
314 302
315 // Transform AP's rectangle 303 // Transform AP's rectangle
316 // To Do 304 // To Do
317 } 305 }
318 } 306 }
319 307
320 DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate) { 308 DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate) {
321 if (page == NULL) 309 CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
322 return;
323 CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
324 if (!pPage)
325 return;
326
327 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || 310 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") ||
328 !pPage->m_pFormDict->GetElement("Type")->GetDirect() || 311 !pPage->m_pFormDict->GetElement("Type")->GetDirect() ||
329 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( 312 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(
330 "Page")) { 313 "Page")) {
331 return; 314 return;
332 } 315 }
333 CPDF_Dictionary* pDict = pPage->m_pFormDict; 316 CPDF_Dictionary* pDict = pPage->m_pFormDict;
334 rotate %= 4; 317 rotate %= 4;
335 318
336 pDict->SetAt("Rotate", new CPDF_Number(rotate * 90)); 319 pDict->SetAt("Rotate", new CPDF_Number(rotate * 90));
337 } 320 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdfeditimg.cpp ('k') | fpdfsdk/src/fpdfformfill.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698