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_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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page) { | 90 DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page) { |
91 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); | 91 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
92 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || | 92 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || |
93 !pPage->m_pFormDict->GetElement("Type")->GetDirect() || | 93 !pPage->m_pFormDict->GetElement("Type")->GetDirect() || |
94 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( | 94 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( |
95 "Page")) { | 95 "Page")) { |
96 return -1; | 96 return -1; |
97 } | 97 } |
98 CPDF_Dictionary* pDict = pPage->m_pFormDict; | 98 CPDF_Dictionary* pDict = pPage->m_pFormDict; |
| 99 if (!pDict) |
| 100 return -1; |
99 | 101 |
100 int rotate = 0; | 102 while (pDict) { |
101 if (pDict != NULL) { | 103 if (pDict->KeyExist("Rotate")) { |
102 if (pDict->KeyExist("Rotate")) | 104 CPDF_Object* pRotateObj = pDict->GetElement("Rotate")->GetDirect(); |
103 rotate = pDict->GetElement("Rotate")->GetDirect() | 105 return pRotateObj ? pRotateObj->GetInteger() / 90 : 0; |
104 ? pDict->GetElement("Rotate")->GetDirect()->GetInteger() / 90 | |
105 : 0; | |
106 else { | |
107 if (pDict->KeyExist("Parent")) { | |
108 CPDF_Dictionary* pPages = | |
109 ToDictionary(pDict->GetElement("Parent")->GetDirect()); | |
110 while (pPages) { | |
111 if (pPages->KeyExist("Rotate")) { | |
112 rotate = | |
113 pPages->GetElement("Rotate")->GetDirect() | |
114 ? pPages->GetElement("Rotate")->GetDirect()->GetInteger() / | |
115 90 | |
116 : 0; | |
117 break; | |
118 } else if (pPages->KeyExist("Parent")) | |
119 pPages = ToDictionary(pPages->GetElement("Parent")->GetDirect()); | |
120 else | |
121 break; | |
122 } | |
123 } | |
124 } | 106 } |
125 } else { | 107 if (!pDict->KeyExist("Parent")) |
126 return -1; | 108 break; |
| 109 |
| 110 pDict = ToDictionary(pDict->GetElement("Parent")->GetDirect()); |
127 } | 111 } |
128 | 112 |
129 return rotate; | 113 return 0; |
130 } | 114 } |
131 | 115 |
132 DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page, | 116 DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page, |
133 FPDF_PAGEOBJECT page_obj) { | 117 FPDF_PAGEOBJECT page_obj) { |
134 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); | 118 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
135 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || | 119 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || |
136 !pPage->m_pFormDict->GetElement("Type")->GetDirect() || | 120 !pPage->m_pFormDict->GetElement("Type")->GetDirect() || |
137 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( | 121 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( |
138 "Page")) { | 122 "Page")) { |
139 return; | 123 return; |
140 } | 124 } |
141 CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_obj; | 125 CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_obj; |
142 if (pPageObj == NULL) | 126 if (!pPageObj) |
143 return; | 127 return; |
144 FX_POSITION LastPersition = pPage->GetLastObjectPosition(); | 128 FX_POSITION LastPersition = pPage->GetLastObjectPosition(); |
145 | 129 |
146 pPage->InsertObject(LastPersition, pPageObj); | 130 pPage->InsertObject(LastPersition, pPageObj); |
147 switch (pPageObj->m_Type) { | 131 switch (pPageObj->m_Type) { |
148 case FPDF_PAGEOBJ_PATH: { | 132 case FPDF_PAGEOBJ_PATH: { |
149 CPDF_PathObject* pPathObj = (CPDF_PathObject*)pPageObj; | 133 CPDF_PathObject* pPathObj = (CPDF_PathObject*)pPageObj; |
150 pPathObj->CalcBoundingBox(); | 134 pPathObj->CalcBoundingBox(); |
151 break; | 135 break; |
152 } | 136 } |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 } | 239 } |
256 | 240 |
257 DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object, | 241 DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object, |
258 double a, | 242 double a, |
259 double b, | 243 double b, |
260 double c, | 244 double c, |
261 double d, | 245 double d, |
262 double e, | 246 double e, |
263 double f) { | 247 double f) { |
264 CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_object; | 248 CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_object; |
265 if (pPageObj == NULL) | 249 if (!pPageObj) |
266 return; | 250 return; |
267 | 251 |
268 CFX_AffineMatrix matrix((FX_FLOAT)a, (FX_FLOAT)b, (FX_FLOAT)c, (FX_FLOAT)d, | 252 CFX_AffineMatrix matrix((FX_FLOAT)a, (FX_FLOAT)b, (FX_FLOAT)c, (FX_FLOAT)d, |
269 (FX_FLOAT)e, (FX_FLOAT)f); | 253 (FX_FLOAT)e, (FX_FLOAT)f); |
270 pPageObj->Transform(matrix); | 254 pPageObj->Transform(matrix); |
271 } | 255 } |
272 DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page, | 256 DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page, |
273 double a, | 257 double a, |
274 double b, | 258 double b, |
275 double c, | 259 double c, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 !pPage->m_pFormDict->GetElement("Type")->GetDirect() || | 293 !pPage->m_pFormDict->GetElement("Type")->GetDirect() || |
310 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( | 294 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( |
311 "Page")) { | 295 "Page")) { |
312 return; | 296 return; |
313 } | 297 } |
314 CPDF_Dictionary* pDict = pPage->m_pFormDict; | 298 CPDF_Dictionary* pDict = pPage->m_pFormDict; |
315 rotate %= 4; | 299 rotate %= 4; |
316 | 300 |
317 pDict->SetAt("Rotate", new CPDF_Number(rotate * 90)); | 301 pDict->SetAt("Rotate", new CPDF_Number(rotate * 90)); |
318 } | 302 } |
OLD | NEW |