| 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" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 textBuf << bsMatix; | 118 textBuf << bsMatix; |
| 119 | 119 |
| 120 CPDF_Dictionary* pPageDic = pPage->m_pFormDict; | 120 CPDF_Dictionary* pPageDic = pPage->m_pFormDict; |
| 121 CPDF_Object* pContentObj = | 121 CPDF_Object* pContentObj = |
| 122 pPageDic ? pPageDic->GetObjectFor("Contents") : nullptr; | 122 pPageDic ? pPageDic->GetObjectFor("Contents") : nullptr; |
| 123 if (!pContentObj) | 123 if (!pContentObj) |
| 124 pContentObj = pPageDic ? pPageDic->GetArrayFor("Contents") : nullptr; | 124 pContentObj = pPageDic ? pPageDic->GetArrayFor("Contents") : nullptr; |
| 125 if (!pContentObj) | 125 if (!pContentObj) |
| 126 return FALSE; | 126 return FALSE; |
| 127 | 127 |
| 128 CPDF_Dictionary* pDic = new CPDF_Dictionary; | |
| 129 CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, pDic); | |
| 130 pStream->SetData(textBuf.GetBuffer(), textBuf.GetSize()); | |
| 131 CPDF_Document* pDoc = pPage->m_pDocument; | 128 CPDF_Document* pDoc = pPage->m_pDocument; |
| 132 if (!pDoc) | 129 if (!pDoc) |
| 133 return FALSE; | 130 return FALSE; |
| 131 |
| 132 CPDF_Dictionary* pDic = new CPDF_Dictionary(pDoc->GetByteStringPool()); |
| 133 CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, pDic); |
| 134 pStream->SetData(textBuf.GetBuffer(), textBuf.GetSize()); |
| 134 pDoc->AddIndirectObject(pStream); | 135 pDoc->AddIndirectObject(pStream); |
| 136 pDic = new CPDF_Dictionary(pDoc->GetByteStringPool()); |
| 135 | 137 |
| 136 pDic = new CPDF_Dictionary; | |
| 137 CPDF_Stream* pEndStream = new CPDF_Stream(nullptr, 0, pDic); | 138 CPDF_Stream* pEndStream = new CPDF_Stream(nullptr, 0, pDic); |
| 138 pEndStream->SetData((const uint8_t*)" Q", 2); | 139 pEndStream->SetData((const uint8_t*)" Q", 2); |
| 139 pDoc->AddIndirectObject(pEndStream); | 140 pDoc->AddIndirectObject(pEndStream); |
| 140 | 141 |
| 141 CPDF_Array* pContentArray = nullptr; | 142 CPDF_Array* pContentArray = nullptr; |
| 142 CPDF_Array* pArray = ToArray(pContentObj); | 143 CPDF_Array* pArray = ToArray(pContentObj); |
| 143 if (pArray) { | 144 if (pArray) { |
| 144 pContentArray = pArray; | 145 pContentArray = pArray; |
| 145 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum()); | 146 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum()); |
| 146 pContentArray->InsertAt(0, pRef); | 147 pContentArray->InsertAt(0, pRef); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 // Empty clipping (totally clipped out) | 294 // Empty clipping (totally clipped out) |
| 294 strClip << "0 0 m W n "; | 295 strClip << "0 0 m W n "; |
| 295 } else { | 296 } else { |
| 296 OutputPath(strClip, path); | 297 OutputPath(strClip, path); |
| 297 if (iClipType == FXFILL_WINDING) | 298 if (iClipType == FXFILL_WINDING) |
| 298 strClip << "W n\n"; | 299 strClip << "W n\n"; |
| 299 else | 300 else |
| 300 strClip << "W* n\n"; | 301 strClip << "W* n\n"; |
| 301 } | 302 } |
| 302 } | 303 } |
| 303 CPDF_Dictionary* pDic = new CPDF_Dictionary; | |
| 304 CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, pDic); | |
| 305 pStream->SetData(strClip.GetBuffer(), strClip.GetSize()); | |
| 306 CPDF_Document* pDoc = pPage->m_pDocument; | 304 CPDF_Document* pDoc = pPage->m_pDocument; |
| 307 if (!pDoc) | 305 if (!pDoc) |
| 308 return; | 306 return; |
| 309 | 307 |
| 308 CPDF_Dictionary* pDic = new CPDF_Dictionary(pDoc->GetByteStringPool()); |
| 309 CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, pDic); |
| 310 pStream->SetData(strClip.GetBuffer(), strClip.GetSize()); |
| 310 pDoc->AddIndirectObject(pStream); | 311 pDoc->AddIndirectObject(pStream); |
| 311 | 312 |
| 312 CPDF_Array* pContentArray = nullptr; | 313 CPDF_Array* pContentArray = nullptr; |
| 313 CPDF_Array* pArray = ToArray(pContentObj); | 314 CPDF_Array* pArray = ToArray(pContentObj); |
| 314 if (pArray) { | 315 if (pArray) { |
| 315 pContentArray = pArray; | 316 pContentArray = pArray; |
| 316 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum()); | 317 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum()); |
| 317 pContentArray->InsertAt(0, pRef); | 318 pContentArray->InsertAt(0, pRef); |
| 318 } else if (CPDF_Reference* pReference = ToReference(pContentObj)) { | 319 } else if (CPDF_Reference* pReference = ToReference(pContentObj)) { |
| 319 CPDF_Object* pDirectObj = pReference->GetDirect(); | 320 CPDF_Object* pDirectObj = pReference->GetDirect(); |
| 320 if (pDirectObj) { | 321 if (pDirectObj) { |
| 321 CPDF_Array* pObjArray = pDirectObj->AsArray(); | 322 CPDF_Array* pObjArray = pDirectObj->AsArray(); |
| 322 if (pObjArray) { | 323 if (pObjArray) { |
| 323 pContentArray = pObjArray; | 324 pContentArray = pObjArray; |
| 324 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum()); | 325 CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum()); |
| 325 pContentArray->InsertAt(0, pRef); | 326 pContentArray->InsertAt(0, pRef); |
| 326 } else if (pDirectObj->IsStream()) { | 327 } else if (pDirectObj->IsStream()) { |
| 327 pContentArray = new CPDF_Array(); | 328 pContentArray = new CPDF_Array(); |
| 328 pContentArray->AddReference(pDoc, pStream->GetObjNum()); | 329 pContentArray->AddReference(pDoc, pStream->GetObjNum()); |
| 329 pContentArray->AddReference(pDoc, pDirectObj->GetObjNum()); | 330 pContentArray->AddReference(pDoc, pDirectObj->GetObjNum()); |
| 330 pPageDic->SetReferenceFor("Contents", pDoc, | 331 pPageDic->SetReferenceFor("Contents", pDoc, |
| 331 pDoc->AddIndirectObject(pContentArray)); | 332 pDoc->AddIndirectObject(pContentArray)); |
| 332 } | 333 } |
| 333 } | 334 } |
| 334 } | 335 } |
| 335 } | 336 } |
| OLD | NEW |