| 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 "fpdfsdk/pdfwindow/PWL_Edit.h" | 7 #include "fpdfsdk/pdfwindow/PWL_Edit.h" |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 if (m_pEditCaret) | 517 if (m_pEditCaret) |
| 518 return m_pEditCaret->GetCaretAppearanceStream(ptOffset); | 518 return m_pEditCaret->GetCaretAppearanceStream(ptOffset); |
| 519 | 519 |
| 520 return CFX_ByteString(); | 520 return CFX_ByteString(); |
| 521 } | 521 } |
| 522 | 522 |
| 523 CFX_FloatPoint CPWL_Edit::GetWordRightBottomPoint( | 523 CFX_FloatPoint CPWL_Edit::GetWordRightBottomPoint( |
| 524 const CPVT_WordPlace& wpWord) { | 524 const CPVT_WordPlace& wpWord) { |
| 525 CFX_FloatPoint pt(0.0f, 0.0f); | 525 CFX_FloatPoint pt(0.0f, 0.0f); |
| 526 | 526 |
| 527 if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) { | 527 IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator(); |
| 528 CPVT_WordPlace wpOld = pIterator->GetAt(); | 528 CPVT_WordPlace wpOld = pIterator->GetAt(); |
| 529 pIterator->SetAt(wpWord); | 529 pIterator->SetAt(wpWord); |
| 530 CPVT_Word word; | 530 CPVT_Word word; |
| 531 if (pIterator->GetWord(word)) { | 531 if (pIterator->GetWord(word)) { |
| 532 pt = CFX_FloatPoint(word.ptWord.x + word.fWidth, | 532 pt = CFX_FloatPoint(word.ptWord.x + word.fWidth, |
| 533 word.ptWord.y + word.fDescent); | 533 word.ptWord.y + word.fDescent); |
| 534 } | 534 } |
| 535 | 535 |
| 536 pIterator->SetAt(wpOld); | 536 pIterator->SetAt(wpOld); |
| 537 } | |
| 538 | 537 |
| 539 return pt; | 538 return pt; |
| 540 } | 539 } |
| 541 | 540 |
| 542 FX_BOOL CPWL_Edit::IsTextFull() const { | 541 FX_BOOL CPWL_Edit::IsTextFull() const { |
| 543 return m_pEdit->IsTextFull(); | 542 return m_pEdit->IsTextFull(); |
| 544 } | 543 } |
| 545 | 544 |
| 546 FX_FLOAT CPWL_Edit::GetCharArrayAutoFontSize(CPDF_Font* pFont, | 545 FX_FLOAT CPWL_Edit::GetCharArrayAutoFontSize(CPDF_Font* pFont, |
| 547 const CFX_FloatRect& rcPlate, | 546 const CFX_FloatRect& rcPlate, |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 } | 871 } |
| 873 | 872 |
| 874 #define PWL_ISARABICWORD(word) \ | 873 #define PWL_ISARABICWORD(word) \ |
| 875 ((word >= 0x0600 && word <= 0x06FF) || (word >= 0xFB50 && word <= 0xFEFC)) | 874 ((word >= 0x0600 && word <= 0x06FF) || (word >= 0xFB50 && word <= 0xFEFC)) |
| 876 | 875 |
| 877 CPVT_WordRange CPWL_Edit::GetSameWordsRange(const CPVT_WordPlace& place, | 876 CPVT_WordRange CPWL_Edit::GetSameWordsRange(const CPVT_WordPlace& place, |
| 878 FX_BOOL bLatin, | 877 FX_BOOL bLatin, |
| 879 FX_BOOL bArabic) const { | 878 FX_BOOL bArabic) const { |
| 880 CPVT_WordRange range; | 879 CPVT_WordRange range; |
| 881 | 880 |
| 882 if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) { | 881 IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator(); |
| 883 CPVT_Word wordinfo; | 882 CPVT_Word wordinfo; |
| 884 CPVT_WordPlace wpStart(place), wpEnd(place); | 883 CPVT_WordPlace wpStart(place), wpEnd(place); |
| 885 pIterator->SetAt(place); | 884 pIterator->SetAt(place); |
| 886 | 885 |
| 887 if (bLatin) { | 886 if (bLatin) { |
| 888 while (pIterator->NextWord()) { | 887 while (pIterator->NextWord()) { |
| 889 if (!pIterator->GetWord(wordinfo) || | 888 if (!pIterator->GetWord(wordinfo) || |
| 890 !FX_EDIT_ISLATINWORD(wordinfo.Word)) { | 889 !FX_EDIT_ISLATINWORD(wordinfo.Word)) { |
| 891 break; | 890 break; |
| 892 } | 891 } |
| 893 | 892 |
| 894 wpEnd = pIterator->GetAt(); | 893 wpEnd = pIterator->GetAt(); |
| 895 } | 894 } |
| 896 } else if (bArabic) { | 895 } else if (bArabic) { |
| 897 while (pIterator->NextWord()) { | 896 while (pIterator->NextWord()) { |
| 898 if (!pIterator->GetWord(wordinfo) || !PWL_ISARABICWORD(wordinfo.Word)) | 897 if (!pIterator->GetWord(wordinfo) || !PWL_ISARABICWORD(wordinfo.Word)) |
| 899 break; | 898 break; |
| 900 | 899 |
| 901 wpEnd = pIterator->GetAt(); | 900 wpEnd = pIterator->GetAt(); |
| 902 } | |
| 903 } | 901 } |
| 904 | |
| 905 pIterator->SetAt(place); | |
| 906 | |
| 907 if (bLatin) { | |
| 908 do { | |
| 909 if (!pIterator->GetWord(wordinfo) || | |
| 910 !FX_EDIT_ISLATINWORD(wordinfo.Word)) { | |
| 911 break; | |
| 912 } | |
| 913 | |
| 914 wpStart = pIterator->GetAt(); | |
| 915 } while (pIterator->PrevWord()); | |
| 916 } else if (bArabic) { | |
| 917 do { | |
| 918 if (!pIterator->GetWord(wordinfo) || !PWL_ISARABICWORD(wordinfo.Word)) | |
| 919 break; | |
| 920 | |
| 921 wpStart = pIterator->GetAt(); | |
| 922 } while (pIterator->PrevWord()); | |
| 923 } | |
| 924 | |
| 925 range.Set(wpStart, wpEnd); | |
| 926 } | 902 } |
| 927 | 903 |
| 904 pIterator->SetAt(place); |
| 905 |
| 906 if (bLatin) { |
| 907 do { |
| 908 if (!pIterator->GetWord(wordinfo) || |
| 909 !FX_EDIT_ISLATINWORD(wordinfo.Word)) { |
| 910 break; |
| 911 } |
| 912 |
| 913 wpStart = pIterator->GetAt(); |
| 914 } while (pIterator->PrevWord()); |
| 915 } else if (bArabic) { |
| 916 do { |
| 917 if (!pIterator->GetWord(wordinfo) || !PWL_ISARABICWORD(wordinfo.Word)) |
| 918 break; |
| 919 |
| 920 wpStart = pIterator->GetAt(); |
| 921 } while (pIterator->PrevWord()); |
| 922 } |
| 923 |
| 924 range.Set(wpStart, wpEnd); |
| 928 return range; | 925 return range; |
| 929 } | 926 } |
| 930 | 927 |
| 931 void CPWL_Edit::GeneratePageObjects( | 928 void CPWL_Edit::GeneratePageObjects( |
| 932 CPDF_PageObjectHolder* pObjectHolder, | 929 CPDF_PageObjectHolder* pObjectHolder, |
| 933 const CFX_FloatPoint& ptOffset, | 930 const CFX_FloatPoint& ptOffset, |
| 934 CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) { | 931 CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) { |
| 935 IFX_Edit::GeneratePageObjects( | 932 IFX_Edit::GeneratePageObjects( |
| 936 pObjectHolder, m_pEdit, ptOffset, NULL, | 933 pObjectHolder, m_pEdit, ptOffset, NULL, |
| 937 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), | 934 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), |
| 938 ObjArray); | 935 ObjArray); |
| 939 } | 936 } |
| 940 | 937 |
| 941 void CPWL_Edit::GeneratePageObjects(CPDF_PageObjectHolder* pObjectHolder, | 938 void CPWL_Edit::GeneratePageObjects(CPDF_PageObjectHolder* pObjectHolder, |
| 942 const CFX_FloatPoint& ptOffset) { | 939 const CFX_FloatPoint& ptOffset) { |
| 943 CFX_ArrayTemplate<CPDF_TextObject*> ObjArray; | 940 CFX_ArrayTemplate<CPDF_TextObject*> ObjArray; |
| 944 IFX_Edit::GeneratePageObjects( | 941 IFX_Edit::GeneratePageObjects( |
| 945 pObjectHolder, m_pEdit, ptOffset, NULL, | 942 pObjectHolder, m_pEdit, ptOffset, NULL, |
| 946 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), | 943 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), |
| 947 ObjArray); | 944 ObjArray); |
| 948 } | 945 } |
| OLD | NEW |