| 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 #include "../include/fsdk_define.h" | 8 #include "../include/fsdk_define.h" | 
| 9 | 9 | 
| 10 namespace { | 10 namespace { | 
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 137     pContentArray->AddReference(pDoc, pEndStream); | 137     pContentArray->AddReference(pDoc, pEndStream); | 
| 138   } else if (pContentObj && pContentObj->GetType() == PDFOBJ_REFERENCE) { | 138   } else if (pContentObj && pContentObj->GetType() == PDFOBJ_REFERENCE) { | 
| 139     CPDF_Reference* pReference = (CPDF_Reference*)pContentObj; | 139     CPDF_Reference* pReference = (CPDF_Reference*)pContentObj; | 
| 140     CPDF_Object* pDirectObj = pReference->GetDirect(); | 140     CPDF_Object* pDirectObj = pReference->GetDirect(); | 
| 141     if (pDirectObj) { | 141     if (pDirectObj) { | 
| 142       if (CPDF_Array* pArray = pDirectObj->AsArray()) { | 142       if (CPDF_Array* pArray = pDirectObj->AsArray()) { | 
| 143         pContentArray = pArray; | 143         pContentArray = pArray; | 
| 144         CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum()); | 144         CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum()); | 
| 145         pContentArray->InsertAt(0, pRef); | 145         pContentArray->InsertAt(0, pRef); | 
| 146         pContentArray->AddReference(pDoc, pEndStream); | 146         pContentArray->AddReference(pDoc, pEndStream); | 
| 147       } else if (pDirectObj->GetType() == PDFOBJ_STREAM) { | 147       } else if (pDirectObj->IsStream()) { | 
| 148         pContentArray = new CPDF_Array(); | 148         pContentArray = new CPDF_Array(); | 
| 149         pContentArray->AddReference(pDoc, pStream->GetObjNum()); | 149         pContentArray->AddReference(pDoc, pStream->GetObjNum()); | 
| 150         pContentArray->AddReference(pDoc, pDirectObj->GetObjNum()); | 150         pContentArray->AddReference(pDoc, pDirectObj->GetObjNum()); | 
| 151         pContentArray->AddReference(pDoc, pEndStream); | 151         pContentArray->AddReference(pDoc, pEndStream); | 
| 152         pPageDic->SetAtReference("Contents", pDoc, | 152         pPageDic->SetAtReference("Contents", pDoc, | 
| 153                                  pDoc->AddIndirectObject(pContentArray)); | 153                                  pDoc->AddIndirectObject(pContentArray)); | 
| 154       } | 154       } | 
| 155     } | 155     } | 
| 156   } | 156   } | 
| 157 | 157 | 
| 158   // Need to transform the patterns as well. | 158   // Need to transform the patterns as well. | 
| 159   CPDF_Dictionary* pRes = pPageDic->GetDict(FX_BSTRC("Resources")); | 159   CPDF_Dictionary* pRes = pPageDic->GetDict(FX_BSTRC("Resources")); | 
| 160   if (pRes) { | 160   if (pRes) { | 
| 161     CPDF_Dictionary* pPattenDict = pRes->GetDict(FX_BSTRC("Pattern")); | 161     CPDF_Dictionary* pPattenDict = pRes->GetDict(FX_BSTRC("Pattern")); | 
| 162     if (pPattenDict) { | 162     if (pPattenDict) { | 
| 163       FX_POSITION pos = pPattenDict->GetStartPos(); | 163       FX_POSITION pos = pPattenDict->GetStartPos(); | 
| 164       while (pos) { | 164       while (pos) { | 
| 165         CPDF_Dictionary* pDict = NULL; | 165         CPDF_Dictionary* pDict = nullptr; | 
| 166         CFX_ByteString key; | 166         CFX_ByteString key; | 
| 167         CPDF_Object* pObj = pPattenDict->GetNextElement(pos, key); | 167         CPDF_Object* pObj = pPattenDict->GetNextElement(pos, key); | 
| 168         if (pObj->GetType() == PDFOBJ_REFERENCE) | 168         if (pObj->GetType() == PDFOBJ_REFERENCE) | 
| 169           pObj = pObj->GetDirect(); | 169           pObj = pObj->GetDirect(); | 
| 170         if (pObj->IsDictionary()) { | 170 | 
|  | 171         if (pObj->IsDictionary()) | 
| 171           pDict = pObj->AsDictionary(); | 172           pDict = pObj->AsDictionary(); | 
| 172         } else if (pObj->GetType() == PDFOBJ_STREAM) { | 173         else if (CPDF_Stream* pStream = pObj->AsStream()) | 
| 173           pDict = ((CPDF_Stream*)pObj)->GetDict(); | 174           pDict = pStream->GetDict(); | 
| 174         } else | 175         else | 
| 175           continue; | 176           continue; | 
| 176 | 177 | 
| 177         CFX_AffineMatrix m = pDict->GetMatrix(FX_BSTRC("Matrix")); | 178         CFX_AffineMatrix m = pDict->GetMatrix(FX_BSTRC("Matrix")); | 
| 178         CFX_AffineMatrix t = *(CFX_AffineMatrix*)matrix; | 179         CFX_AffineMatrix t = *(CFX_AffineMatrix*)matrix; | 
| 179         m.Concat(t); | 180         m.Concat(t); | 
| 180         pDict->SetAtMatrix(FX_BSTRC("Matrix"), m); | 181         pDict->SetAtMatrix(FX_BSTRC("Matrix"), m); | 
| 181       } | 182       } | 
| 182     } | 183     } | 
| 183   } | 184   } | 
| 184 | 185 | 
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 306     CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum()); | 307     CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum()); | 
| 307     pContentArray->InsertAt(0, pRef); | 308     pContentArray->InsertAt(0, pRef); | 
| 308   } else if (pContentObj && pContentObj->GetType() == PDFOBJ_REFERENCE) { | 309   } else if (pContentObj && pContentObj->GetType() == PDFOBJ_REFERENCE) { | 
| 309     CPDF_Reference* pReference = (CPDF_Reference*)pContentObj; | 310     CPDF_Reference* pReference = (CPDF_Reference*)pContentObj; | 
| 310     CPDF_Object* pDirectObj = pReference->GetDirect(); | 311     CPDF_Object* pDirectObj = pReference->GetDirect(); | 
| 311     if (pDirectObj) { | 312     if (pDirectObj) { | 
| 312       if (CPDF_Array* pArray = pDirectObj->AsArray()) { | 313       if (CPDF_Array* pArray = pDirectObj->AsArray()) { | 
| 313         pContentArray = pArray; | 314         pContentArray = pArray; | 
| 314         CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum()); | 315         CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum()); | 
| 315         pContentArray->InsertAt(0, pRef); | 316         pContentArray->InsertAt(0, pRef); | 
| 316       } else if (pDirectObj->GetType() == PDFOBJ_STREAM) { | 317       } else if (pDirectObj->IsStream()) { | 
| 317         pContentArray = new CPDF_Array(); | 318         pContentArray = new CPDF_Array(); | 
| 318         pContentArray->AddReference(pDoc, pStream->GetObjNum()); | 319         pContentArray->AddReference(pDoc, pStream->GetObjNum()); | 
| 319         pContentArray->AddReference(pDoc, pDirectObj->GetObjNum()); | 320         pContentArray->AddReference(pDoc, pDirectObj->GetObjNum()); | 
| 320         pPageDic->SetAtReference("Contents", pDoc, | 321         pPageDic->SetAtReference("Contents", pDoc, | 
| 321                                  pDoc->AddIndirectObject(pContentArray)); | 322                                  pDoc->AddIndirectObject(pContentArray)); | 
| 322       } | 323       } | 
| 323     } | 324     } | 
| 324   } | 325   } | 
| 325 } | 326 } | 
| OLD | NEW | 
|---|