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 | 8 |
9 #include "fpdfsdk/include/fsdk_define.h" | 9 #include "fpdfsdk/include/fsdk_define.h" |
10 #include "public/fpdf_formfill.h" | 10 #include "public/fpdf_formfill.h" |
| 11 #include "third_party/base/stl_util.h" |
11 | 12 |
12 #ifdef PDF_ENABLE_XFA | 13 #ifdef PDF_ENABLE_XFA |
13 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h" | 14 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_app.h" |
14 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" | 15 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_doc.h" |
15 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_page.h" | 16 #include "fpdfsdk/include/fpdfxfa/fpdfxfa_page.h" |
16 #endif // PDF_ENABLE_XFA | 17 #endif // PDF_ENABLE_XFA |
17 | 18 |
18 #if _FX_OS_ == _FX_ANDROID_ | 19 #if _FX_OS_ == _FX_ANDROID_ |
19 #include "time.h" | 20 #include "time.h" |
20 #else | 21 #else |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); | 129 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
129 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || | 130 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || |
130 !pPage->m_pFormDict->GetElement("Type")->GetDirect() || | 131 !pPage->m_pFormDict->GetElement("Type")->GetDirect() || |
131 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( | 132 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( |
132 "Page")) { | 133 "Page")) { |
133 return; | 134 return; |
134 } | 135 } |
135 CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_obj; | 136 CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_obj; |
136 if (!pPageObj) | 137 if (!pPageObj) |
137 return; | 138 return; |
138 FX_POSITION LastPersition = pPage->GetPageObjectList()->GetTailPosition(); | |
139 | 139 |
140 pPage->GetPageObjectList()->InsertObject(LastPersition, pPageObj); | 140 pPage->GetPageObjectList()->push_back( |
| 141 std::unique_ptr<CPDF_PageObject>(pPageObj)); |
| 142 |
141 switch (pPageObj->m_Type) { | 143 switch (pPageObj->m_Type) { |
142 case FPDF_PAGEOBJ_PATH: { | 144 case FPDF_PAGEOBJ_PATH: { |
143 CPDF_PathObject* pPathObj = (CPDF_PathObject*)pPageObj; | 145 CPDF_PathObject* pPathObj = (CPDF_PathObject*)pPageObj; |
144 pPathObj->CalcBoundingBox(); | 146 pPathObj->CalcBoundingBox(); |
145 break; | 147 break; |
146 } | 148 } |
147 case FPDF_PAGEOBJ_TEXT: { | 149 case FPDF_PAGEOBJ_TEXT: { |
148 // CPDF_PathObject* pPathObj = (CPDF_PathObject*)pPageObj; | |
149 // pPathObj->CalcBoundingBox(); | |
150 break; | 150 break; |
151 } | 151 } |
152 case FPDF_PAGEOBJ_IMAGE: { | 152 case FPDF_PAGEOBJ_IMAGE: { |
153 CPDF_ImageObject* pImageObj = (CPDF_ImageObject*)pPageObj; | 153 CPDF_ImageObject* pImageObj = (CPDF_ImageObject*)pPageObj; |
154 pImageObj->CalcBoundingBox(); | 154 pImageObj->CalcBoundingBox(); |
155 break; | 155 break; |
156 } | 156 } |
157 case FPDF_PAGEOBJ_SHADING: { | 157 case FPDF_PAGEOBJ_SHADING: { |
158 CPDF_ShadingObject* pShadingObj = (CPDF_ShadingObject*)pPageObj; | 158 CPDF_ShadingObject* pShadingObj = (CPDF_ShadingObject*)pPageObj; |
159 pShadingObj->CalcBoundingBox(); | 159 pShadingObj->CalcBoundingBox(); |
(...skipping 10 matching lines...) Expand all Loading... |
170 } | 170 } |
171 | 171 |
172 DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page) { | 172 DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page) { |
173 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); | 173 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
174 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || | 174 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || |
175 !pPage->m_pFormDict->GetElement("Type")->GetDirect() || | 175 !pPage->m_pFormDict->GetElement("Type")->GetDirect() || |
176 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( | 176 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( |
177 "Page")) { | 177 "Page")) { |
178 return -1; | 178 return -1; |
179 } | 179 } |
180 return pPage->GetPageObjectList()->GetCount(); | 180 return pdfium::CollectionSize<int>(*pPage->GetPageObjectList()); |
181 } | 181 } |
182 | 182 |
183 DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPage_GetObject(FPDF_PAGE page, | 183 DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPage_GetObject(FPDF_PAGE page, |
184 int index) { | 184 int index) { |
185 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); | 185 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
186 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || | 186 if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") || |
187 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( | 187 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( |
188 "Page")) { | 188 "Page")) { |
189 return NULL; | 189 return nullptr; |
190 } | 190 } |
191 return pPage->GetPageObjectList()->GetObjectByIndex(index); | 191 return pPage->GetPageObjectList()->GetPageObjectByIndex(index); |
192 } | 192 } |
193 | 193 |
194 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_HasTransparency(FPDF_PAGE page) { | 194 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_HasTransparency(FPDF_PAGE page) { |
195 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); | 195 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
196 return pPage && pPage->BackgroundAlphaNeeded(); | 196 return pPage && pPage->BackgroundAlphaNeeded(); |
197 } | 197 } |
198 | 198 |
199 DLLEXPORT FPDF_BOOL STDCALL | 199 DLLEXPORT FPDF_BOOL STDCALL |
200 FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject) { | 200 FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject) { |
201 if (!pageObject) | 201 if (!pageObject) |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 !pPage->m_pFormDict->GetElement("Type")->GetDirect() || | 303 !pPage->m_pFormDict->GetElement("Type")->GetDirect() || |
304 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( | 304 pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare( |
305 "Page")) { | 305 "Page")) { |
306 return; | 306 return; |
307 } | 307 } |
308 CPDF_Dictionary* pDict = pPage->m_pFormDict; | 308 CPDF_Dictionary* pDict = pPage->m_pFormDict; |
309 rotate %= 4; | 309 rotate %= 4; |
310 | 310 |
311 pDict->SetAt("Rotate", new CPDF_Number(rotate * 90)); | 311 pDict->SetAt("Rotate", new CPDF_Number(rotate * 90)); |
312 } | 312 } |
OLD | NEW |