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/include/cpdf_variabletext.h" | 7 #include "core/fpdfdoc/include/cpdf_variabletext.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" | 9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" |
10 #include "core/fpdfdoc/cpvt_wordinfo.h" | 10 #include "core/fpdfdoc/cpvt_wordinfo.h" |
| 11 #include "core/fpdfdoc/cline.h" |
11 #include "core/fpdfdoc/csection.h" | 12 #include "core/fpdfdoc/csection.h" |
12 #include "core/fpdfdoc/include/cpvt_section.h" | 13 #include "core/fpdfdoc/include/cpvt_section.h" |
13 #include "core/fpdfdoc/include/cpvt_word.h" | 14 #include "core/fpdfdoc/include/cpvt_word.h" |
14 #include "core/fpdfdoc/include/ipvt_fontmap.h" | 15 #include "core/fpdfdoc/include/ipvt_fontmap.h" |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 const float kFontScale = 0.001f; | 19 const float kFontScale = 0.001f; |
19 const uint8_t kReturnLength = 1; | 20 const uint8_t kReturnLength = 1; |
20 const float kScalePercent = 0.01f; | 21 const float kScalePercent = 0.01f; |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 FX_BOOL CPDF_VariableText::GetSectionInfo(const CPVT_WordPlace& place, | 750 FX_BOOL CPDF_VariableText::GetSectionInfo(const CPVT_WordPlace& place, |
750 CPVT_SectionInfo& secinfo) { | 751 CPVT_SectionInfo& secinfo) { |
751 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { | 752 if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { |
752 secinfo = pSection->m_SecInfo; | 753 secinfo = pSection->m_SecInfo; |
753 return TRUE; | 754 return TRUE; |
754 } | 755 } |
755 return FALSE; | 756 return FALSE; |
756 } | 757 } |
757 | 758 |
758 void CPDF_VariableText::SetPlateRect(const CFX_FloatRect& rect) { | 759 void CPDF_VariableText::SetPlateRect(const CFX_FloatRect& rect) { |
759 CPDF_EditContainer::SetPlateRect(rect); | 760 m_rcPlate = rect; |
| 761 } |
| 762 |
| 763 void CPDF_VariableText::SetContentRect(const CPVT_FloatRect& rect) { |
| 764 m_rcContent = rect; |
760 } | 765 } |
761 | 766 |
762 CFX_FloatRect CPDF_VariableText::GetContentRect() const { | 767 CFX_FloatRect CPDF_VariableText::GetContentRect() const { |
763 return InToOut(CPVT_FloatRect(CPDF_EditContainer::GetContentRect())); | 768 return InToOut(CPVT_FloatRect(m_rcContent)); |
764 } | 769 } |
765 | 770 |
766 const CFX_FloatRect& CPDF_VariableText::GetPlateRect() const { | 771 const CFX_FloatRect& CPDF_VariableText::GetPlateRect() const { |
767 return CPDF_EditContainer::GetPlateRect(); | 772 return m_rcPlate; |
768 } | 773 } |
769 | 774 |
770 FX_FLOAT CPDF_VariableText::GetWordFontSize(const CPVT_WordInfo& WordInfo) { | 775 FX_FLOAT CPDF_VariableText::GetWordFontSize(const CPVT_WordInfo& WordInfo) { |
771 return GetFontSize(); | 776 return GetFontSize(); |
772 } | 777 } |
773 | 778 |
774 int32_t CPDF_VariableText::GetWordFontIndex(const CPVT_WordInfo& WordInfo) { | 779 int32_t CPDF_VariableText::GetWordFontIndex(const CPVT_WordInfo& WordInfo) { |
775 return WordInfo.nFontIndex; | 780 return WordInfo.nFontIndex; |
776 } | 781 } |
777 | 782 |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1096 | 1101 |
1097 CPDF_VariableText::Iterator* CPDF_VariableText::GetIterator() { | 1102 CPDF_VariableText::Iterator* CPDF_VariableText::GetIterator() { |
1098 if (!m_pVTIterator) | 1103 if (!m_pVTIterator) |
1099 m_pVTIterator.reset(new CPDF_VariableText::Iterator(this)); | 1104 m_pVTIterator.reset(new CPDF_VariableText::Iterator(this)); |
1100 return m_pVTIterator.get(); | 1105 return m_pVTIterator.get(); |
1101 } | 1106 } |
1102 | 1107 |
1103 void CPDF_VariableText::SetProvider(CPDF_VariableText::Provider* pProvider) { | 1108 void CPDF_VariableText::SetProvider(CPDF_VariableText::Provider* pProvider) { |
1104 m_pVTProvider = pProvider; | 1109 m_pVTProvider = pProvider; |
1105 } | 1110 } |
| 1111 |
| 1112 CFX_SizeF CPDF_VariableText::GetPlateSize() const { |
| 1113 return CFX_SizeF(GetPlateWidth(), GetPlateHeight()); |
| 1114 } |
| 1115 |
| 1116 CFX_FloatPoint CPDF_VariableText::GetBTPoint() const { |
| 1117 return CFX_FloatPoint(m_rcPlate.left, m_rcPlate.top); |
| 1118 } |
| 1119 |
| 1120 CFX_FloatPoint CPDF_VariableText::GetETPoint() const { |
| 1121 return CFX_FloatPoint(m_rcPlate.right, m_rcPlate.bottom); |
| 1122 } |
| 1123 |
| 1124 CFX_FloatPoint CPDF_VariableText::InToOut(const CFX_FloatPoint& point) const { |
| 1125 return CFX_FloatPoint(point.x + GetBTPoint().x, GetBTPoint().y - point.y); |
| 1126 } |
| 1127 |
| 1128 CFX_FloatPoint CPDF_VariableText::OutToIn(const CFX_FloatPoint& point) const { |
| 1129 return CFX_FloatPoint(point.x - GetBTPoint().x, GetBTPoint().y - point.y); |
| 1130 } |
| 1131 |
| 1132 CFX_FloatRect CPDF_VariableText::InToOut(const CPVT_FloatRect& rect) const { |
| 1133 CFX_FloatPoint ptLeftTop = InToOut(CFX_FloatPoint(rect.left, rect.top)); |
| 1134 CFX_FloatPoint ptRightBottom = |
| 1135 InToOut(CFX_FloatPoint(rect.right, rect.bottom)); |
| 1136 return CFX_FloatRect(ptLeftTop.x, ptRightBottom.y, ptRightBottom.x, |
| 1137 ptLeftTop.y); |
| 1138 } |
| 1139 |
| 1140 CPVT_FloatRect CPDF_VariableText::OutToIn(const CFX_FloatRect& rect) const { |
| 1141 CFX_FloatPoint ptLeftTop = OutToIn(CFX_FloatPoint(rect.left, rect.top)); |
| 1142 CFX_FloatPoint ptRightBottom = |
| 1143 OutToIn(CFX_FloatPoint(rect.right, rect.bottom)); |
| 1144 return CPVT_FloatRect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x, |
| 1145 ptRightBottom.y); |
| 1146 } |
OLD | NEW |