OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |