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/cfgas_fontmgr.h" | 7 #include "xfa/fgas/font/cfgas_fontmgr.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 | 494 |
495 } // namespace | 495 } // namespace |
496 | 496 |
497 CFX_FontDescriptor::CFX_FontDescriptor() | 497 CFX_FontDescriptor::CFX_FontDescriptor() |
498 : m_nFaceIndex(0), m_dwFontStyles(0), m_dwUsb(), m_dwCsb() {} | 498 : m_nFaceIndex(0), m_dwFontStyles(0), m_dwUsb(), m_dwCsb() {} |
499 | 499 |
500 CFX_FontDescriptor::~CFX_FontDescriptor() {} | 500 CFX_FontDescriptor::~CFX_FontDescriptor() {} |
501 | 501 |
502 CFX_FontSourceEnum_File::CFX_FontSourceEnum_File() { | 502 CFX_FontSourceEnum_File::CFX_FontSourceEnum_File() { |
503 for (size_t i = 0; i < FX_ArraySize(g_FontFolders); ++i) | 503 for (size_t i = 0; i < FX_ArraySize(g_FontFolders); ++i) |
504 m_FolderPaths.Add(g_FontFolders[i]); | 504 m_FolderPaths.push_back(g_FontFolders[i]); |
505 } | 505 } |
506 | 506 |
507 CFX_FontSourceEnum_File::~CFX_FontSourceEnum_File() {} | 507 CFX_FontSourceEnum_File::~CFX_FontSourceEnum_File() {} |
508 | 508 |
509 CFX_ByteString CFX_FontSourceEnum_File::GetNextFile() { | 509 CFX_ByteString CFX_FontSourceEnum_File::GetNextFile() { |
510 FX_FileHandle* pCurHandle = | 510 FX_FileHandle* pCurHandle = |
511 m_FolderQueue.GetSize() != 0 | 511 !m_FolderQueue.empty() ? m_FolderQueue.back().pFileHandle : nullptr; |
512 ? m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->pFileHandle | |
513 : nullptr; | |
514 if (!pCurHandle) { | 512 if (!pCurHandle) { |
515 if (m_FolderPaths.GetSize() < 1) | 513 if (m_FolderPaths.empty()) |
516 return ""; | 514 return ""; |
517 pCurHandle = | 515 pCurHandle = FX_OpenFolder(m_FolderPaths.back().c_str()); |
518 FX_OpenFolder(m_FolderPaths[m_FolderPaths.GetSize() - 1].c_str()); | |
519 FX_HandleParentPath hpp; | 516 FX_HandleParentPath hpp; |
520 hpp.pFileHandle = pCurHandle; | 517 hpp.pFileHandle = pCurHandle; |
521 hpp.bsParentPath = m_FolderPaths[m_FolderPaths.GetSize() - 1]; | 518 hpp.bsParentPath = m_FolderPaths.back(); |
522 m_FolderQueue.Add(hpp); | 519 m_FolderQueue.push_back(hpp); |
523 } | 520 } |
524 CFX_ByteString bsName; | 521 CFX_ByteString bsName; |
525 bool bFolder; | 522 bool bFolder; |
526 CFX_ByteString bsFolderSpearator = | 523 CFX_ByteString bsFolderSeparator = |
527 CFX_ByteString::FromUnicode(CFX_WideString(FX_GetFolderSeparator())); | 524 CFX_ByteString::FromUnicode(CFX_WideString(FX_GetFolderSeparator())); |
528 while (true) { | 525 while (true) { |
529 if (!FX_GetNextFile(pCurHandle, &bsName, &bFolder)) { | 526 if (!FX_GetNextFile(pCurHandle, &bsName, &bFolder)) { |
530 FX_CloseFolder(pCurHandle); | 527 FX_CloseFolder(pCurHandle); |
531 m_FolderQueue.RemoveAt(m_FolderQueue.GetSize() - 1); | 528 if (!m_FolderQueue.empty()) |
532 if (m_FolderQueue.GetSize() == 0) { | 529 m_FolderQueue.pop_back(); |
533 m_FolderPaths.RemoveAt(m_FolderPaths.GetSize() - 1); | 530 if (!m_FolderQueue.empty()) { |
534 return m_FolderPaths.GetSize() != 0 ? GetNextFile() : ""; | 531 if (!m_FolderPaths.empty()) |
| 532 m_FolderPaths.pop_back(); |
| 533 return !m_FolderPaths.empty() ? GetNextFile() : ""; |
535 } | 534 } |
536 pCurHandle = | 535 pCurHandle = m_FolderQueue.back().pFileHandle; |
537 m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->pFileHandle; | |
538 continue; | 536 continue; |
539 } | 537 } |
540 if (bsName == "." || bsName == "..") | 538 if (bsName == "." || bsName == "..") |
541 continue; | 539 continue; |
542 if (bFolder) { | 540 if (bFolder) { |
543 FX_HandleParentPath hpp; | 541 FX_HandleParentPath hpp; |
544 hpp.bsParentPath = | 542 hpp.bsParentPath = |
545 m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->bsParentPath + | 543 m_FolderQueue.back().bsParentPath + bsFolderSeparator + bsName; |
546 bsFolderSpearator + bsName; | |
547 hpp.pFileHandle = FX_OpenFolder(hpp.bsParentPath.c_str()); | 544 hpp.pFileHandle = FX_OpenFolder(hpp.bsParentPath.c_str()); |
548 if (!hpp.pFileHandle) | 545 if (!hpp.pFileHandle) |
549 continue; | 546 continue; |
550 m_FolderQueue.Add(hpp); | 547 m_FolderQueue.push_back(hpp); |
551 pCurHandle = hpp.pFileHandle; | 548 pCurHandle = hpp.pFileHandle; |
552 continue; | 549 continue; |
553 } | 550 } |
554 bsName = | 551 bsName = m_FolderQueue.back().bsParentPath + bsFolderSeparator + bsName; |
555 m_FolderQueue.GetDataPtr(m_FolderQueue.GetSize() - 1)->bsParentPath + | |
556 bsFolderSpearator + bsName; | |
557 break; | 552 break; |
558 } | 553 } |
559 return bsName; | 554 return bsName; |
560 } | 555 } |
561 | 556 |
562 FX_POSITION CFX_FontSourceEnum_File::GetStartPosition() { | 557 FX_POSITION CFX_FontSourceEnum_File::GetStartPosition() { |
563 m_wsNext = GetNextFile().UTF8Decode(); | 558 m_wsNext = GetNextFile().UTF8Decode(); |
564 if (m_wsNext.GetLength() == 0) | 559 if (m_wsNext.GetLength() == 0) |
565 return (FX_POSITION)0; | 560 return (FX_POSITION)0; |
566 return (FX_POSITION)-1; | 561 return (FX_POSITION)-1; |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 } | 1183 } |
1189 | 1184 |
1190 int32_t CFGAS_FontMgr::IsPartName(const CFX_WideString& Name1, | 1185 int32_t CFGAS_FontMgr::IsPartName(const CFX_WideString& Name1, |
1191 const CFX_WideString& Name2) { | 1186 const CFX_WideString& Name2) { |
1192 if (Name1.Find(Name2.c_str()) != -1) | 1187 if (Name1.Find(Name2.c_str()) != -1) |
1193 return 1; | 1188 return 1; |
1194 return 0; | 1189 return 0; |
1195 } | 1190 } |
1196 | 1191 |
1197 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 1192 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
OLD | NEW |