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

Side by Side Diff: core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp

Issue 470253004: Fix bug in CPDF_PageContentGenerate constructor and destructor (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 6 years, 4 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 "../../../include/fpdfapi/fpdf_page.h" 7 #include "../../../include/fpdfapi/fpdf_page.h"
8 #include "../../../include/fpdfapi/fpdf_serial.h" 8 #include "../../../include/fpdfapi/fpdf_serial.h"
9 #include "../../../include/fpdfapi/fpdf_module.h" 9 #include "../../../include/fpdfapi/fpdf_module.h"
10 #include "../../../include/fxcodec/fx_codec.h" 10 #include "../../../include/fxcodec/fx_codec.h"
11 #include "../fpdf_page/pageint.h" 11 #include "../fpdf_page/pageint.h"
12 CFX_ByteTextBuf& operator << (CFX_ByteTextBuf& ar, CFX_AffineMatrix& matrix) 12 CFX_ByteTextBuf& operator << (CFX_ByteTextBuf& ar, CFX_AffineMatrix& matrix)
13 { 13 {
14 ar << matrix.a << " " << matrix.b << " " << matrix.c << " " << matrix.d << " " << matrix.e << " " << matrix.f; 14 ar << matrix.a << " " << matrix.b << " " << matrix.c << " " << matrix.d << " " << matrix.e << " " << matrix.f;
15 return ar; 15 return ar;
16 } 16 }
17 CPDF_PageContentGenerate::CPDF_PageContentGenerate(CPDF_Page* pPage) : m_pPage(p Page) 17 CPDF_PageContentGenerate::CPDF_PageContentGenerate(CPDF_Page* pPage) : m_pPage(p Page)
18 { 18 {
19 m_pDocument = NULL; 19 m_pDocument = NULL;
20 if (m_pPage) { 20 if (m_pPage) {
21 m_pDocument = m_pPage->m_pDocument; 21 m_pDocument = m_pPage->m_pDocument;
22 } 22 }
23 FX_POSITION pos = pPage->GetFirstObjectPosition();
24 while (pos) {
25 if (CPDF_PageObject* pPageObj = pPage->GetNextObject(pos)) {
Lei Zhang 2014/08/20 00:04:22 Do you need the if statement? InsertPageObject() c
Bo Xu 2014/08/20 00:16:57 Right, it's not needed.
26 InsertPageObject(pPageObj);
27 }
28 }
29
23 } 30 }
24 CPDF_PageContentGenerate::~CPDF_PageContentGenerate() 31 CPDF_PageContentGenerate::~CPDF_PageContentGenerate()
25 { 32 {
26 for (int i = 0; i < m_pageObjects.GetSize(); ++i) {
27 CPDF_PageObject* pPageObj = (CPDF_PageObject*)m_pageObjects[i];
28 if (pPageObj) {
29 pPageObj->Release();
30 }
31 }
32 } 33 }
33 FX_BOOL CPDF_PageContentGenerate::InsertPageObject(CPDF_PageObject* pPageObject) 34 FX_BOOL CPDF_PageContentGenerate::InsertPageObject(CPDF_PageObject* pPageObject)
34 { 35 {
35 if (!pPageObject) { 36 if (!pPageObject) {
36 return FALSE; 37 return FALSE;
37 } 38 }
38 return m_pageObjects.Add(pPageObject); 39 return m_pageObjects.Add(pPageObject);
39 } 40 }
40 void CPDF_PageContentGenerate::GenerateContent() 41 void CPDF_PageContentGenerate::GenerateContent()
41 { 42 {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 } else if (type == PDFOBJ_STREAM) { 158 } else if (type == PDFOBJ_STREAM) {
158 CPDF_StreamAcc contentStream; 159 CPDF_StreamAcc contentStream;
159 contentStream.LoadAllData((CPDF_Stream*)pContent); 160 contentStream.LoadAllData((CPDF_Stream*)pContent);
160 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matri x); 161 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matri x);
161 } 162 }
162 CPDF_Stream* pStream = FX_NEW CPDF_Stream(NULL, 0, NULL); 163 CPDF_Stream* pStream = FX_NEW CPDF_Stream(NULL, 0, NULL);
163 pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE); 164 pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE);
164 m_pDocument->AddIndirectObject(pStream); 165 m_pDocument->AddIndirectObject(pStream);
165 m_pPage->m_pFormDict->SetAtReference("Contents", m_pDocument, pStream->GetOb jNum()); 166 m_pPage->m_pFormDict->SetAtReference("Contents", m_pDocument, pStream->GetOb jNum());
166 } 167 }
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