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/cpdf_variabletext.h" | 7 #include "core/fpdfdoc/cpdf_variabletext.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "core/fpdfapi/font/cpdf_font.h" | 11 #include "core/fpdfapi/font/cpdf_font.h" |
12 #include "core/fpdfdoc/cline.h" | 12 #include "core/fpdfdoc/cline.h" |
13 #include "core/fpdfdoc/cpvt_section.h" | 13 #include "core/fpdfdoc/cpvt_section.h" |
14 #include "core/fpdfdoc/cpvt_word.h" | 14 #include "core/fpdfdoc/cpvt_word.h" |
15 #include "core/fpdfdoc/cpvt_wordinfo.h" | 15 #include "core/fpdfdoc/cpvt_wordinfo.h" |
16 #include "core/fpdfdoc/csection.h" | 16 #include "core/fpdfdoc/csection.h" |
17 #include "core/fpdfdoc/ipvt_fontmap.h" | 17 #include "core/fpdfdoc/ipvt_fontmap.h" |
| 18 #include "third_party/base/ptr_util.h" |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 const float kFontScale = 0.001f; | 22 const float kFontScale = 0.001f; |
22 const uint8_t kReturnLength = 1; | 23 const uint8_t kReturnLength = 1; |
23 const float kScalePercent = 0.01f; | 24 const float kScalePercent = 0.01f; |
24 | 25 |
25 const uint8_t gFontSizeSteps[] = {4, 6, 8, 9, 10, 12, 14, 18, 20, | 26 const uint8_t gFontSizeSteps[] = {4, 6, 8, 9, 10, 12, 14, 18, 20, |
26 25, 30, 35, 40, 45, 50, 55, 60, 70, | 27 25, 30, 35, 40, 45, 50, 55, 60, 70, |
27 80, 90, 100, 110, 120, 130, 144}; | 28 80, 90, 100, 110, 120, 130, 144}; |
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 int32_t CPDF_VariableText::GetDefaultFontIndex() { | 1090 int32_t CPDF_VariableText::GetDefaultFontIndex() { |
1090 return m_pVTProvider ? m_pVTProvider->GetDefaultFontIndex() : -1; | 1091 return m_pVTProvider ? m_pVTProvider->GetDefaultFontIndex() : -1; |
1091 } | 1092 } |
1092 | 1093 |
1093 bool CPDF_VariableText::IsLatinWord(uint16_t word) { | 1094 bool CPDF_VariableText::IsLatinWord(uint16_t word) { |
1094 return m_pVTProvider ? m_pVTProvider->IsLatinWord(word) : false; | 1095 return m_pVTProvider ? m_pVTProvider->IsLatinWord(word) : false; |
1095 } | 1096 } |
1096 | 1097 |
1097 CPDF_VariableText::Iterator* CPDF_VariableText::GetIterator() { | 1098 CPDF_VariableText::Iterator* CPDF_VariableText::GetIterator() { |
1098 if (!m_pVTIterator) | 1099 if (!m_pVTIterator) |
1099 m_pVTIterator.reset(new CPDF_VariableText::Iterator(this)); | 1100 m_pVTIterator = pdfium::MakeUnique<CPDF_VariableText::Iterator>(this); |
1100 return m_pVTIterator.get(); | 1101 return m_pVTIterator.get(); |
1101 } | 1102 } |
1102 | 1103 |
1103 void CPDF_VariableText::SetProvider(CPDF_VariableText::Provider* pProvider) { | 1104 void CPDF_VariableText::SetProvider(CPDF_VariableText::Provider* pProvider) { |
1104 m_pVTProvider = pProvider; | 1105 m_pVTProvider = pProvider; |
1105 } | 1106 } |
1106 | 1107 |
1107 CFX_SizeF CPDF_VariableText::GetPlateSize() const { | 1108 CFX_SizeF CPDF_VariableText::GetPlateSize() const { |
1108 return CFX_SizeF(GetPlateWidth(), GetPlateHeight()); | 1109 return CFX_SizeF(GetPlateWidth(), GetPlateHeight()); |
1109 } | 1110 } |
(...skipping 22 matching lines...) Expand all Loading... |
1132 ptLeftTop.y); | 1133 ptLeftTop.y); |
1133 } | 1134 } |
1134 | 1135 |
1135 CPVT_FloatRect CPDF_VariableText::OutToIn(const CFX_FloatRect& rect) const { | 1136 CPVT_FloatRect CPDF_VariableText::OutToIn(const CFX_FloatRect& rect) const { |
1136 CFX_FloatPoint ptLeftTop = OutToIn(CFX_FloatPoint(rect.left, rect.top)); | 1137 CFX_FloatPoint ptLeftTop = OutToIn(CFX_FloatPoint(rect.left, rect.top)); |
1137 CFX_FloatPoint ptRightBottom = | 1138 CFX_FloatPoint ptRightBottom = |
1138 OutToIn(CFX_FloatPoint(rect.right, rect.bottom)); | 1139 OutToIn(CFX_FloatPoint(rect.right, rect.bottom)); |
1139 return CPVT_FloatRect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x, | 1140 return CPVT_FloatRect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x, |
1140 ptRightBottom.y); | 1141 ptRightBottom.y); |
1141 } | 1142 } |
OLD | NEW |