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

Side by Side Diff: core/fpdfdoc/cpdf_filespec.cpp

Issue 2345063002: Use string pools in some dictionaries (Closed)
Patch Set: windows compile 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 | « core/fpdfdoc/cpdf_annotlist.cpp ('k') | core/fpdfdoc/cpdf_filespec_unittest.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 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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 "core/fpdfdoc/include/cpdf_filespec.h" 7 #include "core/fpdfdoc/include/cpdf_filespec.h"
8 8
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_object.h" 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_object.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } 103 }
104 } else if (m_pObj->IsString()) { 104 } else if (m_pObj->IsString()) {
105 *csFileName = CFX_WideString::FromLocal(m_pObj->GetString().AsStringC()); 105 *csFileName = CFX_WideString::FromLocal(m_pObj->GetString().AsStringC());
106 } else { 106 } else {
107 return false; 107 return false;
108 } 108 }
109 *csFileName = DecodeFileName(csFileName->AsStringC()); 109 *csFileName = DecodeFileName(csFileName->AsStringC());
110 return true; 110 return true;
111 } 111 }
112 112
113 CPDF_FileSpec::CPDF_FileSpec() { 113 CPDF_FileSpec::CPDF_FileSpec(const CFX_WeakPtr<CFX_ByteStringPool>& pPool) {
114 m_pObj = new CPDF_Dictionary; 114 m_pObj = new CPDF_Dictionary(pPool);
115 m_pObj->AsDictionary()->SetNameFor("Type", "Filespec"); 115 m_pObj->AsDictionary()->SetNameFor("Type", "Filespec");
116 } 116 }
117 117
118 CFX_WideString CPDF_FileSpec::EncodeFileName(const CFX_WideStringC& filepath) { 118 CFX_WideString CPDF_FileSpec::EncodeFileName(const CFX_WideStringC& filepath) {
119 if (filepath.GetLength() <= 1) 119 if (filepath.GetLength() <= 1)
120 return CFX_WideString(); 120 return CFX_WideString();
121 121
122 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 122 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
123 if (filepath.GetAt(1) == ':') { 123 if (filepath.GetAt(1) == ':') {
124 CFX_WideString result; 124 CFX_WideString result;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 return; 158 return;
159 159
160 CFX_WideString wsStr = EncodeFileName(wsFileName); 160 CFX_WideString wsStr = EncodeFileName(wsFileName);
161 if (m_pObj->IsString()) { 161 if (m_pObj->IsString()) {
162 m_pObj->SetString(CFX_ByteString::FromUnicode(wsStr)); 162 m_pObj->SetString(CFX_ByteString::FromUnicode(wsStr));
163 } else if (CPDF_Dictionary* pDict = m_pObj->AsDictionary()) { 163 } else if (CPDF_Dictionary* pDict = m_pObj->AsDictionary()) {
164 pDict->SetStringFor("F", CFX_ByteString::FromUnicode(wsStr)); 164 pDict->SetStringFor("F", CFX_ByteString::FromUnicode(wsStr));
165 pDict->SetStringFor("UF", PDF_EncodeText(wsStr)); 165 pDict->SetStringFor("UF", PDF_EncodeText(wsStr));
166 } 166 }
167 } 167 }
OLDNEW
« no previous file with comments | « core/fpdfdoc/cpdf_annotlist.cpp ('k') | core/fpdfdoc/cpdf_filespec_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698