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_transformpage.h" | 7 #include "public/fpdf_transformpage.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_page/include/cpdf_clippath.h" | 9 #include "core/fpdfapi/fpdf_page/include/cpdf_clippath.h" |
10 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" | 10 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
11 #include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h" | 11 #include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h" |
12 #include "core/fpdfapi/fpdf_page/include/cpdf_path.h" | 12 #include "core/fpdfapi/fpdf_page/include/cpdf_path.h" |
13 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
14 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 14 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
15 #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h" | 15 #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h" |
16 #include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h" | 16 #include "core/fpdfapi/fpdf_parser/include/cpdf_reference.h" |
17 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" | 17 #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" |
18 #include "fpdfsdk/include/fsdk_define.h" | 18 #include "fpdfsdk/include/fsdk_define.h" |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 void SetBoundingBox(CPDF_Page* page, | 22 void SetBoundingBox(CPDF_Page* page, |
23 const CFX_ByteStringC& key, | 23 const CFX_ByteString& key, |
24 float left, | 24 float left, |
25 float bottom, | 25 float bottom, |
26 float right, | 26 float right, |
27 float top) { | 27 float top) { |
28 CPDF_Dictionary* pPageDict = page->m_pFormDict; | |
29 CPDF_Array* pBoundingBoxArray = new CPDF_Array; | 28 CPDF_Array* pBoundingBoxArray = new CPDF_Array; |
30 pBoundingBoxArray->Add(new CPDF_Number(left)); | 29 pBoundingBoxArray->Add(new CPDF_Number(left)); |
31 pBoundingBoxArray->Add(new CPDF_Number(bottom)); | 30 pBoundingBoxArray->Add(new CPDF_Number(bottom)); |
32 pBoundingBoxArray->Add(new CPDF_Number(right)); | 31 pBoundingBoxArray->Add(new CPDF_Number(right)); |
33 pBoundingBoxArray->Add(new CPDF_Number(top)); | 32 pBoundingBoxArray->Add(new CPDF_Number(top)); |
34 pPageDict->SetAt(key, pBoundingBoxArray); | 33 page->m_pFormDict->SetAt(key, pBoundingBoxArray); |
35 } | 34 } |
36 | 35 |
37 FPDF_BOOL GetBoundingBox(CPDF_Page* page, | 36 bool GetBoundingBox(CPDF_Page* page, |
38 const CFX_ByteStringC& key, | 37 const CFX_ByteString& key, |
39 float* left, | 38 float* left, |
40 float* bottom, | 39 float* bottom, |
41 float* right, | 40 float* right, |
42 float* top) { | 41 float* top) { |
43 CPDF_Dictionary* pPageDict = page->m_pFormDict; | 42 CPDF_Array* pArray = page->m_pFormDict->GetArrayBy(key); |
44 CPDF_Array* pArray = pPageDict->GetArrayBy(key); | |
45 if (!pArray) | 43 if (!pArray) |
46 return FALSE; | 44 return false; |
47 | 45 |
48 *left = pArray->GetFloatAt(0); | 46 *left = pArray->GetFloatAt(0); |
49 *bottom = pArray->GetFloatAt(1); | 47 *bottom = pArray->GetFloatAt(1); |
50 *right = pArray->GetFloatAt(2); | 48 *right = pArray->GetFloatAt(2); |
51 *top = pArray->GetFloatAt(3); | 49 *top = pArray->GetFloatAt(3); |
52 return TRUE; | 50 return true; |
53 } | 51 } |
54 | 52 |
55 } // namespace | 53 } // namespace |
56 | 54 |
57 DLLEXPORT void STDCALL FPDFPage_SetMediaBox(FPDF_PAGE page, | 55 DLLEXPORT void STDCALL FPDFPage_SetMediaBox(FPDF_PAGE page, |
58 float left, | 56 float left, |
59 float bottom, | 57 float bottom, |
60 float right, | 58 float right, |
61 float top) { | 59 float top) { |
62 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); | 60 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 } else if (pDirectObj->IsStream()) { | 321 } else if (pDirectObj->IsStream()) { |
324 pContentArray = new CPDF_Array(); | 322 pContentArray = new CPDF_Array(); |
325 pContentArray->AddReference(pDoc, pStream->GetObjNum()); | 323 pContentArray->AddReference(pDoc, pStream->GetObjNum()); |
326 pContentArray->AddReference(pDoc, pDirectObj->GetObjNum()); | 324 pContentArray->AddReference(pDoc, pDirectObj->GetObjNum()); |
327 pPageDic->SetAtReference("Contents", pDoc, | 325 pPageDic->SetAtReference("Contents", pDoc, |
328 pDoc->AddIndirectObject(pContentArray)); | 326 pDoc->AddIndirectObject(pContentArray)); |
329 } | 327 } |
330 } | 328 } |
331 } | 329 } |
332 } | 330 } |
OLD | NEW |