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 "core/fpdftext/include/cpdf_textpage.h" | 7 #include "core/fpdftext/include/cpdf_textpage.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 bottom = m_SelRects[rectIndex].bottom; | 500 bottom = m_SelRects[rectIndex].bottom; |
501 } | 501 } |
502 | 502 |
503 CPDF_TextPage::TextOrientation CPDF_TextPage::FindTextlineFlowOrientation() | 503 CPDF_TextPage::TextOrientation CPDF_TextPage::FindTextlineFlowOrientation() |
504 const { | 504 const { |
505 if (m_pPage->GetPageObjectList()->empty()) | 505 if (m_pPage->GetPageObjectList()->empty()) |
506 return TextOrientation::Unknown; | 506 return TextOrientation::Unknown; |
507 | 507 |
508 const int32_t nPageWidth = static_cast<int32_t>(m_pPage->GetPageWidth()); | 508 const int32_t nPageWidth = static_cast<int32_t>(m_pPage->GetPageWidth()); |
509 const int32_t nPageHeight = static_cast<int32_t>(m_pPage->GetPageHeight()); | 509 const int32_t nPageHeight = static_cast<int32_t>(m_pPage->GetPageHeight()); |
| 510 if (nPageWidth <= 0 || nPageHeight <= 0) |
| 511 return TextOrientation::Unknown; |
| 512 |
510 std::vector<bool> nHorizontalMask(nPageWidth); | 513 std::vector<bool> nHorizontalMask(nPageWidth); |
511 std::vector<bool> nVerticalMask(nPageHeight); | 514 std::vector<bool> nVerticalMask(nPageHeight); |
512 FX_FLOAT fLineHeight = 0.0f; | 515 FX_FLOAT fLineHeight = 0.0f; |
513 int32_t nStartH = nPageWidth; | 516 int32_t nStartH = nPageWidth; |
514 int32_t nEndH = 0; | 517 int32_t nEndH = 0; |
515 int32_t nStartV = nPageHeight; | 518 int32_t nStartV = nPageHeight; |
516 int32_t nEndV = 0; | 519 int32_t nEndV = 0; |
517 for (const auto& pPageObj : *m_pPage->GetPageObjectList()) { | 520 for (const auto& pPageObj : *m_pPage->GetPageObjectList()) { |
518 if (!pPageObj->IsText()) | 521 if (!pPageObj->IsText()) |
519 continue; | 522 continue; |
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1529 info.m_OriginY); | 1532 info.m_OriginY); |
1530 return TRUE; | 1533 return TRUE; |
1531 } | 1534 } |
1532 | 1535 |
1533 FX_BOOL CPDF_TextPage::IsRectIntersect(const CFX_FloatRect& rect1, | 1536 FX_BOOL CPDF_TextPage::IsRectIntersect(const CFX_FloatRect& rect1, |
1534 const CFX_FloatRect& rect2) { | 1537 const CFX_FloatRect& rect2) { |
1535 CFX_FloatRect rect = rect1; | 1538 CFX_FloatRect rect = rect1; |
1536 rect.Intersect(rect2); | 1539 rect.Intersect(rect2); |
1537 return !rect.IsEmpty(); | 1540 return !rect.IsEmpty(); |
1538 } | 1541 } |
OLD | NEW |