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" |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 } | 387 } |
388 | 388 |
389 CPVT_WordPlace CPDF_VariableText::DeleteWord(const CPVT_WordPlace& place) { | 389 CPVT_WordPlace CPDF_VariableText::DeleteWord(const CPVT_WordPlace& place) { |
390 return ClearRightWord(AdjustLineHeader(place, TRUE)); | 390 return ClearRightWord(AdjustLineHeader(place, TRUE)); |
391 } | 391 } |
392 | 392 |
393 CPVT_WordPlace CPDF_VariableText::BackSpaceWord(const CPVT_WordPlace& place) { | 393 CPVT_WordPlace CPDF_VariableText::BackSpaceWord(const CPVT_WordPlace& place) { |
394 return ClearLeftWord(AdjustLineHeader(place, TRUE)); | 394 return ClearLeftWord(AdjustLineHeader(place, TRUE)); |
395 } | 395 } |
396 | 396 |
397 void CPDF_VariableText::SetText(const FX_WCHAR* text) { | 397 void CPDF_VariableText::SetText(const CFX_WideString& swText) { |
398 DeleteWords(CPVT_WordRange(GetBeginWordPlace(), GetEndWordPlace())); | 398 DeleteWords(CPVT_WordRange(GetBeginWordPlace(), GetEndWordPlace())); |
399 CFX_WideString swText = text; | |
400 CPVT_WordPlace wp(0, 0, -1); | 399 CPVT_WordPlace wp(0, 0, -1); |
401 CPVT_SectionInfo secinfo; | 400 CPVT_SectionInfo secinfo; |
402 if (CSection* pSection = m_SectionArray.GetAt(0)) | 401 if (CSection* pSection = m_SectionArray.GetAt(0)) |
403 pSection->m_SecInfo = secinfo; | 402 pSection->m_SecInfo = secinfo; |
404 | 403 |
405 int32_t nCharCount = 0; | 404 int32_t nCharCount = 0; |
406 for (int32_t i = 0, sz = swText.GetLength(); i < sz; i++) { | 405 for (int32_t i = 0, sz = swText.GetLength(); i < sz; i++) { |
407 if (m_nLimitChar > 0 && nCharCount >= m_nLimitChar) | 406 if (m_nLimitChar > 0 && nCharCount >= m_nLimitChar) |
408 break; | 407 break; |
409 if (m_nCharArray > 0 && nCharCount >= m_nCharArray) | 408 if (m_nCharArray > 0 && nCharCount >= m_nCharArray) |
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 ptLeftTop.y); | 1136 ptLeftTop.y); |
1138 } | 1137 } |
1139 | 1138 |
1140 CPVT_FloatRect CPDF_VariableText::OutToIn(const CFX_FloatRect& rect) const { | 1139 CPVT_FloatRect CPDF_VariableText::OutToIn(const CFX_FloatRect& rect) const { |
1141 CFX_FloatPoint ptLeftTop = OutToIn(CFX_FloatPoint(rect.left, rect.top)); | 1140 CFX_FloatPoint ptLeftTop = OutToIn(CFX_FloatPoint(rect.left, rect.top)); |
1142 CFX_FloatPoint ptRightBottom = | 1141 CFX_FloatPoint ptRightBottom = |
1143 OutToIn(CFX_FloatPoint(rect.right, rect.bottom)); | 1142 OutToIn(CFX_FloatPoint(rect.right, rect.bottom)); |
1144 return CPVT_FloatRect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x, | 1143 return CPVT_FloatRect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x, |
1145 ptRightBottom.y); | 1144 ptRightBottom.y); |
1146 } | 1145 } |
OLD | NEW |