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

Side by Side Diff: xfa/fxfa/app/xfa_ffdoc.cpp

Issue 2571913002: Avoid the ptr.reset(new XXX()) anti-pattern (Closed)
Patch Set: rebase Created 4 years 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 | « xfa/fxfa/app/xfa_ffapp.cpp ('k') | xfa/fxfa/app/xfa_ffdocview.cpp » ('j') | 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 "xfa/fxfa/xfa_ffdoc.h" 7 #include "xfa/fxfa/xfa_ffdoc.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
11 #include <vector> 11 #include <vector>
12 12
13 #include "core/fpdfapi/parser/cpdf_array.h" 13 #include "core/fpdfapi/parser/cpdf_array.h"
14 #include "core/fpdfapi/parser/cpdf_document.h" 14 #include "core/fpdfapi/parser/cpdf_document.h"
15 #include "core/fpdfapi/parser/fpdf_parser_decode.h" 15 #include "core/fpdfapi/parser/fpdf_parser_decode.h"
16 #include "core/fpdfdoc/cpdf_nametree.h" 16 #include "core/fpdfdoc/cpdf_nametree.h"
17 #include "core/fxcrt/fx_ext.h" 17 #include "core/fxcrt/fx_ext.h"
18 #include "core/fxcrt/fx_memory.h" 18 #include "core/fxcrt/fx_memory.h"
19 #include "third_party/base/ptr_util.h"
19 #include "xfa/fde/xml/fde_xml_imp.h" 20 #include "xfa/fde/xml/fde_xml_imp.h"
20 #include "xfa/fwl/cfwl_notedriver.h" 21 #include "xfa/fwl/cfwl_notedriver.h"
21 #include "xfa/fxfa/app/xfa_ffnotify.h" 22 #include "xfa/fxfa/app/xfa_ffnotify.h"
22 #include "xfa/fxfa/parser/cxfa_dataexporter.h" 23 #include "xfa/fxfa/parser/cxfa_dataexporter.h"
23 #include "xfa/fxfa/parser/cxfa_dataimporter.h" 24 #include "xfa/fxfa/parser/cxfa_dataimporter.h"
24 #include "xfa/fxfa/parser/cxfa_document.h" 25 #include "xfa/fxfa/parser/cxfa_document.h"
25 #include "xfa/fxfa/xfa_checksum.h" 26 #include "xfa/fxfa/xfa_checksum.h"
26 #include "xfa/fxfa/xfa_ffapp.h" 27 #include "xfa/fxfa/xfa_ffapp.h"
27 #include "xfa/fxfa/xfa_ffdocview.h" 28 #include "xfa/fxfa/xfa_ffdocview.h"
28 #include "xfa/fxfa/xfa_ffwidget.h" 29 #include "xfa/fxfa/xfa_ffwidget.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 160
160 CXFA_FFDoc::~CXFA_FFDoc() { 161 CXFA_FFDoc::~CXFA_FFDoc() {
161 CloseDoc(); 162 CloseDoc();
162 } 163 }
163 164
164 uint32_t CXFA_FFDoc::GetDocType() { 165 uint32_t CXFA_FFDoc::GetDocType() {
165 return m_dwDocType; 166 return m_dwDocType;
166 } 167 }
167 168
168 int32_t CXFA_FFDoc::StartLoad() { 169 int32_t CXFA_FFDoc::StartLoad() {
169 m_pNotify.reset(new CXFA_FFNotify(this)); 170 m_pNotify = pdfium::MakeUnique<CXFA_FFNotify>(this);
170 m_pDocumentParser.reset(new CXFA_DocumentParser(m_pNotify.get())); 171 m_pDocumentParser = pdfium::MakeUnique<CXFA_DocumentParser>(m_pNotify.get());
171 int32_t iStatus = m_pDocumentParser->StartParse(m_pStream, XFA_XDPPACKET_XDP); 172 return m_pDocumentParser->StartParse(m_pStream, XFA_XDPPACKET_XDP);
172 return iStatus;
173 } 173 }
174 174
175 bool XFA_GetPDFContentsFromPDFXML(CFDE_XMLNode* pPDFElement, 175 bool XFA_GetPDFContentsFromPDFXML(CFDE_XMLNode* pPDFElement,
176 uint8_t*& pByteBuffer, 176 uint8_t*& pByteBuffer,
177 int32_t& iBufferSize) { 177 int32_t& iBufferSize) {
178 CFDE_XMLElement* pDocumentElement = nullptr; 178 CFDE_XMLElement* pDocumentElement = nullptr;
179 for (CFDE_XMLNode* pXMLNode = 179 for (CFDE_XMLNode* pXMLNode =
180 pPDFElement->GetNodeItem(CFDE_XMLNode::FirstChild); 180 pPDFElement->GetNodeItem(CFDE_XMLNode::FirstChild);
181 pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { 181 pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) {
182 if (pXMLNode->GetType() == FDE_XMLNODE_Element) { 182 if (pXMLNode->GetType() == FDE_XMLNODE_Element) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 return; 265 return;
266 } 266 }
267 CFX_WideString wsType; 267 CFX_WideString wsType;
268 if (pDynamicRender->TryContent(wsType) && wsType == FX_WSTRC(L"required")) { 268 if (pDynamicRender->TryContent(wsType) && wsType == FX_WSTRC(L"required")) {
269 m_dwDocType = XFA_DOCTYPE_Dynamic; 269 m_dwDocType = XFA_DOCTYPE_Dynamic;
270 } 270 }
271 } 271 }
272 272
273 CXFA_FFDocView* CXFA_FFDoc::CreateDocView(uint32_t dwView) { 273 CXFA_FFDocView* CXFA_FFDoc::CreateDocView(uint32_t dwView) {
274 if (!m_TypeToDocViewMap[dwView]) 274 if (!m_TypeToDocViewMap[dwView])
275 m_TypeToDocViewMap[dwView].reset(new CXFA_FFDocView(this)); 275 m_TypeToDocViewMap[dwView] = pdfium::MakeUnique<CXFA_FFDocView>(this);
276 276
277 return m_TypeToDocViewMap[dwView].get(); 277 return m_TypeToDocViewMap[dwView].get();
278 } 278 }
279 279
280 CXFA_FFDocView* CXFA_FFDoc::GetDocView(CXFA_LayoutProcessor* pLayout) { 280 CXFA_FFDocView* CXFA_FFDoc::GetDocView(CXFA_LayoutProcessor* pLayout) {
281 for (const auto& pair : m_TypeToDocViewMap) { 281 for (const auto& pair : m_TypeToDocViewMap) {
282 if (pair.second->GetXFALayout() == pLayout) 282 if (pair.second->GetXFALayout() == pLayout)
283 return pair.second.get(); 283 return pair.second.get();
284 } 284 }
285 return nullptr; 285 return nullptr;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 pFile, pNode, 0, bsChecksum.GetLength() ? bsChecksum.c_str() : nullptr); 432 pFile, pNode, 0, bsChecksum.GetLength() ? bsChecksum.c_str() : nullptr);
433 } 433 }
434 434
435 bool CXFA_FFDoc::ImportData( 435 bool CXFA_FFDoc::ImportData(
436 const CFX_RetainPtr<IFX_SeekableReadStream>& pStream, 436 const CFX_RetainPtr<IFX_SeekableReadStream>& pStream,
437 bool bXDP) { 437 bool bXDP) {
438 auto importer = 438 auto importer =
439 pdfium::MakeUnique<CXFA_DataImporter>(m_pDocumentParser->GetDocument()); 439 pdfium::MakeUnique<CXFA_DataImporter>(m_pDocumentParser->GetDocument());
440 return importer->ImportData(pStream); 440 return importer->ImportData(pStream);
441 } 441 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_ffapp.cpp ('k') | xfa/fxfa/app/xfa_ffdocview.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698