Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_serial.h" | 7 #include "../../../include/fpdfapi/fpdf_serial.h" |
| 8 CFDF_Document::CFDF_Document() : CPDF_IndirectObjects(NULL) | 8 CFDF_Document::CFDF_Document() : CPDF_IndirectObjects(NULL) |
| 9 { | 9 { |
| 10 m_pRootDict = NULL; | 10 m_pRootDict = NULL; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 size_t objnum; | 104 size_t objnum; |
| 105 CPDF_Object* pObj; | 105 CPDF_Object* pObj; |
| 106 m_IndirectObjs.GetNextAssoc(pos, (FX_LPVOID&)objnum, (FX_LPVOID&)pObj); | 106 m_IndirectObjs.GetNextAssoc(pos, (FX_LPVOID&)objnum, (FX_LPVOID&)pObj); |
| 107 buf << (FX_DWORD)objnum << FX_BSTRC(" 0 obj\r\n") << pObj << FX_BSTRC("\ r\nendobj\r\n\r\n"); | 107 buf << (FX_DWORD)objnum << FX_BSTRC(" 0 obj\r\n") << pObj << FX_BSTRC("\ r\nendobj\r\n\r\n"); |
| 108 } | 108 } |
| 109 buf << FX_BSTRC("trailer\r\n<</Root ") << m_pRootDict->GetObjNum() << FX_BST RC(" 0 R>>\r\n%%EOF\r\n"); | 109 buf << FX_BSTRC("trailer\r\n<</Root ") << m_pRootDict->GetObjNum() << FX_BST RC(" 0 R>>\r\n%%EOF\r\n"); |
| 110 return TRUE; | 110 return TRUE; |
| 111 } | 111 } |
| 112 CFX_WideString CFDF_Document::GetWin32Path() const | 112 CFX_WideString CFDF_Document::GetWin32Path() const |
| 113 { | 113 { |
| 114 CPDF_Object* pFileSpec = m_pRootDict->GetDict(FX_BSTRC("FDF"))->GetElementVa lue(FX_BSTRC("F")); | 114 CPDF_Dictionary* pDict = m_pRootDict->GetDict(FX_BSTRC("FDF")); |
|
Nico
2014/06/28 01:01:07
is m_pRootDict guaranteed to be not NULL here?
| |
| 115 CPDF_Object* pFileSpec = pDict ? pDict->GetElementValue(FX_BSTRC("F")) : NUL L; | |
| 115 if (pFileSpec == NULL) { | 116 if (pFileSpec == NULL) { |
| 116 return CFX_WideString(); | 117 return CFX_WideString(); |
| 117 } | 118 } |
| 118 if (pFileSpec->GetType() == PDFOBJ_STRING) { | 119 if (pFileSpec->GetType() == PDFOBJ_STRING) { |
| 119 return FPDF_FileSpec_GetWin32Path(m_pRootDict->GetDict(FX_BSTRC("FDF"))) ; | 120 return FPDF_FileSpec_GetWin32Path(m_pRootDict->GetDict(FX_BSTRC("FDF"))) ; |
| 120 } | 121 } |
| 121 return FPDF_FileSpec_GetWin32Path(pFileSpec); | 122 return FPDF_FileSpec_GetWin32Path(pFileSpec); |
| 122 } | 123 } |
| 123 FX_BOOL CFDF_Document::WriteFile(FX_LPCSTR file_path) const | 124 FX_BOOL CFDF_Document::WriteFile(FX_LPCSTR file_path) const |
| 124 { | 125 { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 wsFileName = pDict->GetUnicodeText(FX_BSTRC("UF")); | 197 wsFileName = pDict->GetUnicodeText(FX_BSTRC("UF")); |
| 197 if (wsFileName.IsEmpty()) { | 198 if (wsFileName.IsEmpty()) { |
| 198 wsFileName = CFX_WideString::FromLocal(pDict->GetString(FX_BSTRC("F" ))); | 199 wsFileName = CFX_WideString::FromLocal(pDict->GetString(FX_BSTRC("F" ))); |
| 199 } | 200 } |
| 200 if (pDict->GetString(FX_BSTRC("FS")) == FX_BSTRC("URL")) { | 201 if (pDict->GetString(FX_BSTRC("FS")) == FX_BSTRC("URL")) { |
| 201 return wsFileName; | 202 return wsFileName; |
| 202 } | 203 } |
| 203 if (wsFileName.IsEmpty() && pDict->KeyExist(FX_BSTRC("DOS"))) { | 204 if (wsFileName.IsEmpty() && pDict->KeyExist(FX_BSTRC("DOS"))) { |
| 204 wsFileName = CFX_WideString::FromLocal(pDict->GetString(FX_BSTRC("DO S"))); | 205 wsFileName = CFX_WideString::FromLocal(pDict->GetString(FX_BSTRC("DO S"))); |
| 205 } | 206 } |
| 206 } else { | 207 } |
| 208 else if (!pFileSpec) | |
| 209 wsFileName = CFX_WideString(); | |
| 210 else { | |
| 207 wsFileName = CFX_WideString::FromLocal(pFileSpec->GetString()); | 211 wsFileName = CFX_WideString::FromLocal(pFileSpec->GetString()); |
| 208 } | 212 } |
| 209 if (wsFileName[0] != '/') { | 213 if (wsFileName[0] != '/') { |
| 210 return ChangeSlash(wsFileName); | 214 return ChangeSlash(wsFileName); |
| 211 } | 215 } |
| 212 if (wsFileName[2] == '/') { | 216 if (wsFileName[2] == '/') { |
| 213 CFX_WideString result; | 217 CFX_WideString result; |
| 214 result += wsFileName[1]; | 218 result += wsFileName[1]; |
| 215 result += ':'; | 219 result += ':'; |
| 216 result += ChangeSlash(((FX_LPCWSTR)wsFileName) + 2); | 220 result += ChangeSlash(((FX_LPCWSTR)wsFileName) + 2); |
| 217 return result; | 221 return result; |
| 218 } else { | 222 } else { |
| 219 CFX_WideString result; | 223 CFX_WideString result; |
| 220 result += '\\'; | 224 result += '\\'; |
| 221 result += ChangeSlash(wsFileName); | 225 result += ChangeSlash(wsFileName); |
| 222 return result; | 226 return result; |
| 223 } | 227 } |
| 224 } | 228 } |
| OLD | NEW |