OLD | NEW |
1 // Copyright 2015 PDFium Authors. All rights reserved. | 1 // Copyright 2015 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/fgas/font/fgas_stdfontmgr.h" | 7 #include "xfa/fgas/font/fgas_stdfontmgr.h" |
8 | 8 |
9 #include "core/fxcrt/fx_stream.h" | 9 #include "core/fxcrt/fx_stream.h" |
10 #include "core/fxge/cfx_fontmapper.h" | 10 #include "core/fxge/cfx_fontmapper.h" |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 CFX_FontDescriptor::~CFX_FontDescriptor() {} | 479 CFX_FontDescriptor::~CFX_FontDescriptor() {} |
480 | 480 |
481 CFX_FontSourceEnum_File::CFX_FontSourceEnum_File() { | 481 CFX_FontSourceEnum_File::CFX_FontSourceEnum_File() { |
482 for (size_t i = 0; i < FX_ArraySize(g_FontFolders); ++i) | 482 for (size_t i = 0; i < FX_ArraySize(g_FontFolders); ++i) |
483 m_FolderPaths.Add(g_FontFolders[i]); | 483 m_FolderPaths.Add(g_FontFolders[i]); |
484 } | 484 } |
485 | 485 |
486 CFX_FontSourceEnum_File::~CFX_FontSourceEnum_File() {} | 486 CFX_FontSourceEnum_File::~CFX_FontSourceEnum_File() {} |
487 | 487 |
488 CFX_ByteString CFX_FontSourceEnum_File::GetNextFile() { | 488 CFX_ByteString CFX_FontSourceEnum_File::GetNextFile() { |
489 Restart: | 489 FX_FileHandle* pCurHandle = |
490 void* pCurHandle = | |
491 m_FolderQueue.GetSize() != 0 | 490 m_FolderQueue.GetSize() != 0 |
492 ? m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->pFileHandle | 491 ? m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->pFileHandle |
493 : nullptr; | 492 : nullptr; |
494 if (!pCurHandle) { | 493 if (!pCurHandle) { |
495 if (m_FolderPaths.GetSize() < 1) { | 494 if (m_FolderPaths.GetSize() < 1) |
496 return ""; | 495 return ""; |
497 } | |
498 pCurHandle = | 496 pCurHandle = |
499 FX_OpenFolder(m_FolderPaths[m_FolderPaths.GetSize() - 1].c_str()); | 497 FX_OpenFolder(m_FolderPaths[m_FolderPaths.GetSize() - 1].c_str()); |
500 FX_HandleParentPath hpp; | 498 FX_HandleParentPath hpp; |
501 hpp.pFileHandle = pCurHandle; | 499 hpp.pFileHandle = pCurHandle; |
502 hpp.bsParentPath = m_FolderPaths[m_FolderPaths.GetSize() - 1]; | 500 hpp.bsParentPath = m_FolderPaths[m_FolderPaths.GetSize() - 1]; |
503 m_FolderQueue.Add(hpp); | 501 m_FolderQueue.Add(hpp); |
504 } | 502 } |
505 CFX_ByteString bsName; | 503 CFX_ByteString bsName; |
506 FX_BOOL bFolder; | 504 bool bFolder; |
507 CFX_ByteString bsFolderSpearator = | 505 CFX_ByteString bsFolderSpearator = |
508 CFX_ByteString::FromUnicode(CFX_WideString(FX_GetFolderSeparator())); | 506 CFX_ByteString::FromUnicode(CFX_WideString(FX_GetFolderSeparator())); |
509 while (TRUE) { | 507 while (true) { |
510 if (!FX_GetNextFile(pCurHandle, bsName, bFolder)) { | 508 if (!FX_GetNextFile(pCurHandle, &bsName, &bFolder)) { |
511 FX_CloseFolder(pCurHandle); | 509 FX_CloseFolder(pCurHandle); |
512 m_FolderQueue.RemoveAt(m_FolderQueue.GetSize() - 1); | 510 m_FolderQueue.RemoveAt(m_FolderQueue.GetSize() - 1); |
513 if (m_FolderQueue.GetSize() == 0) { | 511 if (m_FolderQueue.GetSize() == 0) { |
514 m_FolderPaths.RemoveAt(m_FolderPaths.GetSize() - 1); | 512 m_FolderPaths.RemoveAt(m_FolderPaths.GetSize() - 1); |
515 if (m_FolderPaths.GetSize() == 0) { | 513 return m_FolderPaths.GetSize() != 0 ? GetNextFile() : ""; |
516 return ""; | |
517 } else { | |
518 goto Restart; | |
519 } | |
520 } | 514 } |
521 pCurHandle = | 515 pCurHandle = |
522 m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->pFileHandle; | 516 m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->pFileHandle; |
523 continue; | 517 continue; |
524 } | 518 } |
525 if (bsName == "." || bsName == "..") { | 519 if (bsName == "." || bsName == "..") |
526 continue; | 520 continue; |
527 } | |
528 if (bFolder) { | 521 if (bFolder) { |
529 FX_HandleParentPath hpp; | 522 FX_HandleParentPath hpp; |
530 hpp.bsParentPath = | 523 hpp.bsParentPath = |
531 m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->bsParentPath + | 524 m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->bsParentPath + |
532 bsFolderSpearator + bsName; | 525 bsFolderSpearator + bsName; |
533 hpp.pFileHandle = FX_OpenFolder(hpp.bsParentPath.c_str()); | 526 hpp.pFileHandle = FX_OpenFolder(hpp.bsParentPath.c_str()); |
534 if (!hpp.pFileHandle) { | 527 if (!hpp.pFileHandle) |
535 continue; | 528 continue; |
536 } | |
537 m_FolderQueue.Add(hpp); | 529 m_FolderQueue.Add(hpp); |
538 pCurHandle = hpp.pFileHandle; | 530 pCurHandle = hpp.pFileHandle; |
539 continue; | 531 continue; |
540 } | 532 } |
541 bsName = | 533 bsName = |
542 m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->bsParentPath + | 534 m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->bsParentPath + |
543 bsFolderSpearator + bsName; | 535 bsFolderSpearator + bsName; |
544 break; | 536 break; |
545 } | 537 } |
546 return bsName; | 538 return bsName; |
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1382 | 1374 |
1383 int32_t CFGAS_FontMgrImp::IsPartName(const CFX_WideString& Name1, | 1375 int32_t CFGAS_FontMgrImp::IsPartName(const CFX_WideString& Name1, |
1384 const CFX_WideString& Name2) { | 1376 const CFX_WideString& Name2) { |
1385 if (Name1.Find(Name2.c_str()) != -1) { | 1377 if (Name1.Find(Name2.c_str()) != -1) { |
1386 return 1; | 1378 return 1; |
1387 } | 1379 } |
1388 return 0; | 1380 return 0; |
1389 } | 1381 } |
1390 | 1382 |
1391 #endif | 1383 #endif |
OLD | NEW |