Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(769)

Side by Side Diff: fpdfsdk/fpdfeditpage.cpp

Issue 2425003002: FPDFPage_TransformAnnots(): don't re-insert unowned object on top of itself (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 double d, 282 double d,
283 double e, 283 double e,
284 double f) { 284 double f) {
285 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); 285 CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
286 if (!pPage) 286 if (!pPage)
287 return; 287 return;
288 288
289 CPDF_AnnotList AnnotList(pPage); 289 CPDF_AnnotList AnnotList(pPage);
290 for (size_t i = 0; i < AnnotList.Count(); ++i) { 290 for (size_t i = 0; i < AnnotList.Count(); ++i) {
291 CPDF_Annot* pAnnot = AnnotList.GetAt(i); 291 CPDF_Annot* pAnnot = AnnotList.GetAt(i);
292 // transformAnnots Rectangle 292 CFX_FloatRect rect = pAnnot->GetRect(); // transformAnnots Rectangle
293 CFX_FloatRect rect = pAnnot->GetRect();
294 CFX_Matrix matrix((FX_FLOAT)a, (FX_FLOAT)b, (FX_FLOAT)c, (FX_FLOAT)d, 293 CFX_Matrix matrix((FX_FLOAT)a, (FX_FLOAT)b, (FX_FLOAT)c, (FX_FLOAT)d,
295 (FX_FLOAT)e, (FX_FLOAT)f); 294 (FX_FLOAT)e, (FX_FLOAT)f);
296 rect.Transform(&matrix); 295 rect.Transform(&matrix);
296
297 CPDF_Array* pRectArray = pAnnot->GetAnnotDict()->GetArrayFor("Rect"); 297 CPDF_Array* pRectArray = pAnnot->GetAnnotDict()->GetArrayFor("Rect");
298 if (!pRectArray) 298 if (!pRectArray) {
299 pRectArray = new CPDF_Array; 299 pRectArray = new CPDF_Array;
300 pAnnot->GetAnnotDict()->SetFor("Rect", pRectArray);
301 }
300 pRectArray->SetAt(0, new CPDF_Number(rect.left)); 302 pRectArray->SetAt(0, new CPDF_Number(rect.left));
301 pRectArray->SetAt(1, new CPDF_Number(rect.bottom)); 303 pRectArray->SetAt(1, new CPDF_Number(rect.bottom));
302 pRectArray->SetAt(2, new CPDF_Number(rect.right)); 304 pRectArray->SetAt(2, new CPDF_Number(rect.right));
303 pRectArray->SetAt(3, new CPDF_Number(rect.top)); 305 pRectArray->SetAt(3, new CPDF_Number(rect.top));
304 pAnnot->GetAnnotDict()->SetFor("Rect", pRectArray);
305 306
306 // Transform AP's rectangle 307 // TODO: Transform AP's rectangle
307 // To Do
308 } 308 }
309 } 309 }
310 310
311 DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate) { 311 DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate) {
312 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); 312 CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
313 if (!IsPageObject(pPage)) 313 if (!IsPageObject(pPage))
314 return; 314 return;
315 315
316 CPDF_Dictionary* pDict = pPage->m_pFormDict; 316 CPDF_Dictionary* pDict = pPage->m_pFormDict;
317 rotate %= 4; 317 rotate %= 4;
318 pDict->SetFor("Rotate", new CPDF_Number(rotate * 90)); 318 pDict->SetFor("Rotate", new CPDF_Number(rotate * 90));
319 } 319 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698