OLD | NEW |
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_flatten.h" | 7 #include "../../public/fpdf_flatten.h" |
8 #include "../include/fsdk_define.h" | 8 #include "../include/fsdk_define.h" |
9 #include "../include/fpdfxfa/fpdfxfa_doc.h" | 9 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
10 #include "../include/fpdfxfa/fpdfxfa_page.h" | 10 #include "../include/fpdfxfa/fpdfxfa_page.h" |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 FX_FLOAT left = FX_MIN(FX_MIN(x1, x2), FX_MIN(x3, x4)); | 305 FX_FLOAT left = FX_MIN(FX_MIN(x1, x2), FX_MIN(x3, x4)); |
306 FX_FLOAT bottom = FX_MIN(FX_MIN(y1, y2), FX_MIN(y3, y4)); | 306 FX_FLOAT bottom = FX_MIN(FX_MIN(y1, y2), FX_MIN(y3, y4)); |
307 | 307 |
308 fa = (rcAnnot.right - rcAnnot.left) / fStreamWidth; | 308 fa = (rcAnnot.right - rcAnnot.left) / fStreamWidth; |
309 fd = (rcAnnot.top - rcAnnot.bottom) / fStreamHeight; | 309 fd = (rcAnnot.top - rcAnnot.bottom) / fStreamHeight; |
310 fe = rcAnnot.left - left * fa; | 310 fe = rcAnnot.left - left * fa; |
311 ff = rcAnnot.bottom - bottom * fd; | 311 ff = rcAnnot.bottom - bottom * fd; |
312 } | 312 } |
313 | 313 |
314 DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) { | 314 DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) { |
| 315 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
315 if (!page) { | 316 if (!page) { |
316 return FLATTEN_FAIL; | 317 return FLATTEN_FAIL; |
317 } | 318 } |
318 | 319 |
319 CPDF_Page* pPage = ((CPDFXFA_Page*)(page))->GetPDFPage(); | |
320 if (!pPage) | |
321 return FLATTEN_FAIL; | |
322 | |
323 CPDF_Document* pDocument = pPage->m_pDocument; | 320 CPDF_Document* pDocument = pPage->m_pDocument; |
324 CPDF_Dictionary* pPageDict = pPage->m_pFormDict; | 321 CPDF_Dictionary* pPageDict = pPage->m_pFormDict; |
325 | 322 |
326 if (!pDocument || !pPageDict) { | 323 if (!pDocument || !pPageDict) { |
327 return FLATTEN_FAIL; | 324 return FLATTEN_FAIL; |
328 } | 325 } |
329 | 326 |
330 CPDF_ObjectArray ObjectArray; | 327 CPDF_ObjectArray ObjectArray; |
331 CPDF_RectArray RectArray; | 328 CPDF_RectArray RectArray; |
332 | 329 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 pNewXObject->SetData((const uint8_t*)sStream, sStream.GetLength(), FALSE, | 519 pNewXObject->SetData((const uint8_t*)sStream, sStream.GetLength(), FALSE, |
523 FALSE); | 520 FALSE); |
524 } | 521 } |
525 pPageDict->RemoveAt("Annots"); | 522 pPageDict->RemoveAt("Annots"); |
526 | 523 |
527 ObjectArray.RemoveAll(); | 524 ObjectArray.RemoveAll(); |
528 RectArray.RemoveAll(); | 525 RectArray.RemoveAll(); |
529 | 526 |
530 return FLATTEN_SUCCESS; | 527 return FLATTEN_SUCCESS; |
531 } | 528 } |
OLD | NEW |