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