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 "../include/fsdk_define.h" | 7 #include "../include/fsdk_define.h" |
8 #include "../include/fpdf_flatten.h" | 8 #include "../include/fpdf_flatten.h" |
9 | 9 |
10 typedef CFX_ArrayTemplate<CPDF_Dictionary*> CPDF_ObjectArray; | 10 typedef CFX_ArrayTemplate<CPDF_Dictionary*> CPDF_ObjectArray; |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 if (!pContentsObj) | 213 if (!pContentsObj) |
214 { | 214 { |
215 //Create a new contents dictionary | 215 //Create a new contents dictionary |
216 if (!key.IsEmpty()) | 216 if (!key.IsEmpty()) |
217 { | 217 { |
218 CPDF_Stream* pNewContents = FX_NEW CPDF_Stream(NULL, 0,
FX_NEW CPDF_Dictionary); | 218 CPDF_Stream* pNewContents = FX_NEW CPDF_Stream(NULL, 0,
FX_NEW CPDF_Dictionary); |
219 if (!pNewContents)return; | 219 if (!pNewContents)return; |
220 pPage->SetAtReference("Contents", pDocument, pDocument->
AddIndirectObject(pNewContents)); | 220 pPage->SetAtReference("Contents", pDocument, pDocument->
AddIndirectObject(pNewContents)); |
221 | 221 |
222 CFX_ByteString sStream; | 222 CFX_ByteString sStream; |
223 » » » sStream.Format("q 1 0 0 1 0 0 cm /%s Do Q", (FX_LPCSTR)k
ey); | 223 » » » sStream.Format("q 1 0 0 1 0 0 cm /%s Do Q", key.c_str())
; |
224 pNewContents->SetData((FX_LPCBYTE)sStream, sStream.GetLe
ngth(), FALSE, FALSE); | 224 pNewContents->SetData((FX_LPCBYTE)sStream, sStream.GetLe
ngth(), FALSE, FALSE); |
225 } | 225 } |
226 return; | 226 return; |
227 } | 227 } |
228 | 228 |
229 int iType = pContentsObj->GetType(); | 229 int iType = pContentsObj->GetType(); |
230 CPDF_Array* pContentsArray = NULL; | 230 CPDF_Array* pContentsArray = NULL; |
231 | 231 |
232 switch(iType) | 232 switch(iType) |
233 { | 233 { |
(...skipping 26 matching lines...) Expand all Loading... |
260 FX_DWORD dwObjNum = pDocument->AddIndirectObject(pContentsArray); | 260 FX_DWORD dwObjNum = pDocument->AddIndirectObject(pContentsArray); |
261 pPage->SetAtReference("Contents", pDocument, dwObjNum); | 261 pPage->SetAtReference("Contents", pDocument, dwObjNum); |
262 | 262 |
263 if (!key.IsEmpty()) | 263 if (!key.IsEmpty()) |
264 { | 264 { |
265 CPDF_Stream* pNewContents = FX_NEW CPDF_Stream(NULL, 0, FX_NEW C
PDF_Dictionary); | 265 CPDF_Stream* pNewContents = FX_NEW CPDF_Stream(NULL, 0, FX_NEW C
PDF_Dictionary); |
266 dwObjNum = pDocument->AddIndirectObject(pNewContents); | 266 dwObjNum = pDocument->AddIndirectObject(pNewContents); |
267 pContentsArray->AddReference(pDocument, dwObjNum); | 267 pContentsArray->AddReference(pDocument, dwObjNum); |
268 | 268 |
269 CFX_ByteString sStream; | 269 CFX_ByteString sStream; |
270 » » sStream.Format("q 1 0 0 1 0 0 cm /%s Do Q", (FX_LPCSTR)key); | 270 » » sStream.Format("q 1 0 0 1 0 0 cm /%s Do Q", key.c_str()); |
271 pNewContents->SetData((FX_LPCBYTE)sStream, sStream.GetLength(),
FALSE, FALSE); | 271 pNewContents->SetData((FX_LPCBYTE)sStream, sStream.GetLength(),
FALSE, FALSE); |
272 } | 272 } |
273 } | 273 } |
274 | 274 |
275 CFX_AffineMatrix GetMatrix(CPDF_Rect rcAnnot, CPDF_Rect rcStream, CFX_AffineMatr
ix matrix) | 275 CFX_AffineMatrix GetMatrix(CPDF_Rect rcAnnot, CPDF_Rect rcStream, CFX_AffineMatr
ix matrix) |
276 { | 276 { |
277 if(rcStream.IsEmpty()) | 277 if(rcStream.IsEmpty()) |
278 return CFX_AffineMatrix(); | 278 return CFX_AffineMatrix(); |
279 | 279 |
280 matrix.TransformRect(rcStream); | 280 matrix.TransformRect(rcStream); |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 { | 540 { |
541 matrix.a = 1.0f; | 541 matrix.a = 1.0f; |
542 matrix.b = 0.0f; | 542 matrix.b = 0.0f; |
543 matrix.c = 0.0f; | 543 matrix.c = 0.0f; |
544 matrix.d = 1.0f; | 544 matrix.d = 1.0f; |
545 matrix.e = 0.0f; | 545 matrix.e = 0.0f; |
546 matrix.f = 0.0f; | 546 matrix.f = 0.0f; |
547 } | 547 } |
548 | 548 |
549 CFX_AffineMatrix m = GetMatrix(rcAnnot, rcStream, matrix); | 549 CFX_AffineMatrix m = GetMatrix(rcAnnot, rcStream, matrix); |
550 » » sTemp.Format("q %f 0 0 %f %f %f cm /%s Do Q\n", m.a, m.d, m.e, m
.f, (FX_LPCSTR)sFormName); | 550 » » sTemp.Format("q %f 0 0 %f %f %f cm /%s Do Q\n", m.a, m.d, m.e, m
.f, sFormName.c_str()); |
551 sStream += sTemp; | 551 sStream += sTemp; |
552 | 552 |
553 pNewXObject->SetData((FX_LPCBYTE)sStream, sStream.GetLength(), F
ALSE, FALSE); | 553 pNewXObject->SetData((FX_LPCBYTE)sStream, sStream.GetLength(), F
ALSE, FALSE); |
554 } | 554 } |
555 pPageDict->RemoveAt( "Annots" ); | 555 pPageDict->RemoveAt( "Annots" ); |
556 | 556 |
557 ObjectArray.RemoveAll(); | 557 ObjectArray.RemoveAll(); |
558 RectArray.RemoveAll(); | 558 RectArray.RemoveAll(); |
559 | 559 |
560 return FLATTEN_SUCCESS; | 560 return FLATTEN_SUCCESS; |
561 } | 561 } |
OLD | NEW |