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 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 rcRet.top = GetMinMaxValue(*pRectArray, MAX, TOP); | 171 rcRet.top = GetMinMaxValue(*pRectArray, MAX, TOP); |
172 rcRet.right = GetMinMaxValue(*pRectArray, MAX, RIGHT); | 172 rcRet.right = GetMinMaxValue(*pRectArray, MAX, RIGHT); |
173 rcRet.bottom = GetMinMaxValue(*pRectArray, MIN, BOTTOM); | 173 rcRet.bottom = GetMinMaxValue(*pRectArray, MIN, BOTTOM); |
174 | 174 |
175 return rcRet; | 175 return rcRet; |
176 } | 176 } |
177 | 177 |
178 uint32_t NewIndirectContentsStream(const CFX_ByteString& key, | 178 uint32_t NewIndirectContentsStream(const CFX_ByteString& key, |
179 CPDF_Document* pDocument) { | 179 CPDF_Document* pDocument) { |
180 CPDF_Stream* pNewContents = pDocument->NewIndirect<CPDF_Stream>( | 180 CPDF_Stream* pNewContents = pDocument->NewIndirect<CPDF_Stream>( |
181 nullptr, 0, new CPDF_Dictionary(pDocument->GetByteStringPool())); | 181 nullptr, 0, |
| 182 pdfium::MakeUnique<CPDF_Dictionary>(pDocument->GetByteStringPool())); |
182 CFX_ByteString sStream; | 183 CFX_ByteString sStream; |
183 sStream.Format("q 1 0 0 1 0 0 cm /%s Do Q", key.c_str()); | 184 sStream.Format("q 1 0 0 1 0 0 cm /%s Do Q", key.c_str()); |
184 pNewContents->SetData(sStream.raw_str(), sStream.GetLength()); | 185 pNewContents->SetData(sStream.raw_str(), sStream.GetLength()); |
185 return pNewContents->GetObjNum(); | 186 return pNewContents->GetObjNum(); |
186 } | 187 } |
187 | 188 |
188 void SetPageContents(const CFX_ByteString& key, | 189 void SetPageContents(const CFX_ByteString& key, |
189 CPDF_Dictionary* pPage, | 190 CPDF_Dictionary* pPage, |
190 CPDF_Document* pDocument) { | 191 CPDF_Document* pDocument) { |
191 CPDF_Array* pContentsArray = nullptr; | 192 CPDF_Array* pContentsArray = nullptr; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 pCropBox->AddNew<CPDF_Number>(rcOriginalCB.bottom); | 290 pCropBox->AddNew<CPDF_Number>(rcOriginalCB.bottom); |
290 pCropBox->AddNew<CPDF_Number>(rcOriginalCB.right); | 291 pCropBox->AddNew<CPDF_Number>(rcOriginalCB.right); |
291 pCropBox->AddNew<CPDF_Number>(rcOriginalCB.top); | 292 pCropBox->AddNew<CPDF_Number>(rcOriginalCB.top); |
292 } | 293 } |
293 | 294 |
294 CPDF_Dictionary* pRes = pPageDict->GetDictFor("Resources"); | 295 CPDF_Dictionary* pRes = pPageDict->GetDictFor("Resources"); |
295 if (!pRes) | 296 if (!pRes) |
296 pRes = pPageDict->SetNewFor<CPDF_Dictionary>("Resources"); | 297 pRes = pPageDict->SetNewFor<CPDF_Dictionary>("Resources"); |
297 | 298 |
298 CPDF_Stream* pNewXObject = pDocument->NewIndirect<CPDF_Stream>( | 299 CPDF_Stream* pNewXObject = pDocument->NewIndirect<CPDF_Stream>( |
299 nullptr, 0, new CPDF_Dictionary(pDocument->GetByteStringPool())); | 300 nullptr, 0, |
| 301 pdfium::MakeUnique<CPDF_Dictionary>(pDocument->GetByteStringPool())); |
300 | 302 |
301 uint32_t dwObjNum = pNewXObject->GetObjNum(); | 303 uint32_t dwObjNum = pNewXObject->GetObjNum(); |
302 CPDF_Dictionary* pPageXObject = pRes->GetDictFor("XObject"); | 304 CPDF_Dictionary* pPageXObject = pRes->GetDictFor("XObject"); |
303 if (!pPageXObject) | 305 if (!pPageXObject) |
304 pPageXObject = pRes->SetNewFor<CPDF_Dictionary>("XObject"); | 306 pPageXObject = pRes->SetNewFor<CPDF_Dictionary>("XObject"); |
305 | 307 |
306 CFX_ByteString key = ""; | 308 CFX_ByteString key = ""; |
307 int nStreams = pdfium::CollectionSize<int>(ObjectArray); | 309 int nStreams = pdfium::CollectionSize<int>(ObjectArray); |
308 if (nStreams > 0) { | 310 if (nStreams > 0) { |
309 for (int iKey = 0; /*iKey < 100*/; iKey++) { | 311 for (int iKey = 0; /*iKey < 100*/; iKey++) { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 CFX_ByteString sTemp; | 420 CFX_ByteString sTemp; |
419 CFX_Matrix m = GetMatrix(rcAnnot, rcStream, matrix); | 421 CFX_Matrix m = GetMatrix(rcAnnot, rcStream, matrix); |
420 sTemp.Format("q %f 0 0 %f %f %f cm /%s Do Q\n", m.a, m.d, m.e, m.f, | 422 sTemp.Format("q %f 0 0 %f %f %f cm /%s Do Q\n", m.a, m.d, m.e, m.f, |
421 sFormName.c_str()); | 423 sFormName.c_str()); |
422 sStream += sTemp; | 424 sStream += sTemp; |
423 pNewXObject->SetData(sStream.raw_str(), sStream.GetLength()); | 425 pNewXObject->SetData(sStream.raw_str(), sStream.GetLength()); |
424 } | 426 } |
425 pPageDict->RemoveFor("Annots"); | 427 pPageDict->RemoveFor("Annots"); |
426 return FLATTEN_SUCCESS; | 428 return FLATTEN_SUCCESS; |
427 } | 429 } |
OLD | NEW |