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

Unified Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp

Issue 1778173002: Split apart the remainder of fpdf_render_render.cpp into per-class files. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Nits Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp
deleted file mode 100644
index c87fd63a289ba41a7e2331e0985257acb10e874d..0000000000000000000000000000000000000000
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "core/include/fpdfapi/fpdf_parser.h"
-
-#include "core/include/fpdfapi/fpdf_serial.h"
-#include "core/src/fpdfapi/fpdf_parser/cpdf_syntax_parser.h"
-
-CFDF_Document::CFDF_Document() : CPDF_IndirectObjectHolder(NULL) {
- m_pRootDict = NULL;
- m_pFile = NULL;
- m_bOwnFile = FALSE;
-}
-CFDF_Document::~CFDF_Document() {
- if (m_bOwnFile && m_pFile) {
- m_pFile->Release();
- }
-}
-CFDF_Document* CFDF_Document::CreateNewDoc() {
- CFDF_Document* pDoc = new CFDF_Document;
- pDoc->m_pRootDict = new CPDF_Dictionary;
- pDoc->AddIndirectObject(pDoc->m_pRootDict);
- CPDF_Dictionary* pFDFDict = new CPDF_Dictionary;
- pDoc->m_pRootDict->SetAt("FDF", pFDFDict);
- return pDoc;
-}
-CFDF_Document* CFDF_Document::ParseFile(IFX_FileRead* pFile, FX_BOOL bOwnFile) {
- if (!pFile) {
- return NULL;
- }
- CFDF_Document* pDoc = new CFDF_Document;
- pDoc->ParseStream(pFile, bOwnFile);
- if (!pDoc->m_pRootDict) {
- delete pDoc;
- return NULL;
- }
- return pDoc;
-}
-CFDF_Document* CFDF_Document::ParseMemory(const uint8_t* pData, FX_DWORD size) {
- return CFDF_Document::ParseFile(FX_CreateMemoryStream((uint8_t*)pData, size),
- TRUE);
-}
-void CFDF_Document::ParseStream(IFX_FileRead* pFile, FX_BOOL bOwnFile) {
- m_pFile = pFile;
- m_bOwnFile = bOwnFile;
- CPDF_SyntaxParser parser;
- parser.InitParser(m_pFile, 0);
- while (1) {
- bool bNumber;
- CFX_ByteString word = parser.GetNextWord(&bNumber);
- if (bNumber) {
- FX_DWORD objnum = FXSYS_atoui(word);
- word = parser.GetNextWord(&bNumber);
- if (!bNumber) {
- break;
- }
- word = parser.GetNextWord(nullptr);
- if (word != "obj") {
- break;
- }
- CPDF_Object* pObj = parser.GetObject(this, objnum, 0, true);
- if (!pObj) {
- break;
- }
- InsertIndirectObject(objnum, pObj);
- word = parser.GetNextWord(nullptr);
- if (word != "endobj") {
- break;
- }
- } else {
- if (word != "trailer") {
- break;
- }
- if (CPDF_Dictionary* pMainDict =
- ToDictionary(parser.GetObject(this, 0, 0, true))) {
- m_pRootDict = pMainDict->GetDictBy("Root");
- pMainDict->Release();
- }
- break;
- }
- }
-}
-FX_BOOL CFDF_Document::WriteBuf(CFX_ByteTextBuf& buf) const {
- if (!m_pRootDict) {
- return FALSE;
- }
- buf << "%FDF-1.2\r\n";
- for (const auto& pair : m_IndirectObjs) {
- buf << pair.first << " 0 obj\r\n" << pair.second << "\r\nendobj\r\n\r\n";
- }
- buf << "trailer\r\n<</Root " << m_pRootDict->GetObjNum()
- << " 0 R>>\r\n%%EOF\r\n";
- return TRUE;
-}

Powered by Google App Engine
This is Rietveld 408576698