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 "xfa/fde/cfx_wordbreak.h" | 7 #include "xfa/fde/cfx_wordbreak.h" |
8 | 8 |
9 #include "xfa/fde/cfx_chariter.h" | 9 #include "xfa/fde/cfx_chariter.h" |
10 | 10 |
(...skipping 2841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2852 FX_BOOL bPrev, | 2852 FX_BOOL bPrev, |
2853 FX_BOOL bFromNext) { | 2853 FX_BOOL bFromNext) { |
2854 FX_WordBreakProp ePreType = FX_WordBreakProp_None; | 2854 FX_WordBreakProp ePreType = FX_WordBreakProp_None; |
2855 FX_WordBreakProp eCurType = FX_WordBreakProp_None; | 2855 FX_WordBreakProp eCurType = FX_WordBreakProp_None; |
2856 FX_WordBreakProp eNextType = FX_WordBreakProp_None; | 2856 FX_WordBreakProp eNextType = FX_WordBreakProp_None; |
2857 if (pIter->IsEOF(!bPrev)) { | 2857 if (pIter->IsEOF(!bPrev)) { |
2858 return TRUE; | 2858 return TRUE; |
2859 } | 2859 } |
2860 if (!(bFromNext || pIter->IsEOF(bPrev))) { | 2860 if (!(bFromNext || pIter->IsEOF(bPrev))) { |
2861 pIter->Next(!bPrev); | 2861 pIter->Next(!bPrev); |
2862 FX_WCHAR wcTemp = pIter->GetChar(); | 2862 ePreType = GetWordBreakProperty(pIter->GetChar()); |
2863 ePreType = GetWordBreakProperty(wcTemp); | |
2864 pIter->Next(bPrev); | 2863 pIter->Next(bPrev); |
2865 } | 2864 } |
2866 FX_WCHAR wcTemp = pIter->GetChar(); | 2865 eCurType = GetWordBreakProperty(pIter->GetChar()); |
2867 eCurType = GetWordBreakProperty(wcTemp); | |
2868 FX_BOOL bFirst = TRUE; | 2866 FX_BOOL bFirst = TRUE; |
2869 do { | 2867 do { |
2870 pIter->Next(bPrev); | 2868 pIter->Next(bPrev); |
2871 FX_WCHAR wcTemp = pIter->GetChar(); | 2869 eNextType = GetWordBreakProperty(pIter->GetChar()); |
2872 eNextType = GetWordBreakProperty(wcTemp); | |
2873 uint16_t wBreak = | 2870 uint16_t wBreak = |
2874 gs_FX_WordBreak_Table[eCurType] & ((uint16_t)(1 << eNextType)); | 2871 gs_FX_WordBreak_Table[eCurType] & ((uint16_t)(1 << eNextType)); |
2875 if (wBreak) { | 2872 if (wBreak) { |
2876 if (pIter->IsEOF(!bPrev)) { | 2873 if (pIter->IsEOF(!bPrev)) { |
2877 pIter->Next(!bPrev); | 2874 pIter->Next(!bPrev); |
2878 return TRUE; | 2875 return TRUE; |
2879 } | 2876 } |
2880 if (bFirst) { | 2877 if (bFirst) { |
2881 int32_t nFlags = 0; | 2878 int32_t nFlags = 0; |
2882 if (eCurType == FX_WordBreakProp_MidLetter) { | 2879 if (eCurType == FX_WordBreakProp_MidLetter) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2922 } else if (eCurType == FX_WordBreakProp_Numberic) { | 2919 } else if (eCurType == FX_WordBreakProp_Numberic) { |
2923 nFlags = 2; | 2920 nFlags = 2; |
2924 } | 2921 } |
2925 } | 2922 } |
2926 if (nFlags <= 0) { | 2923 if (nFlags <= 0) { |
2927 pIter->Next(!bPrev); | 2924 pIter->Next(!bPrev); |
2928 return TRUE; | 2925 return TRUE; |
2929 } | 2926 } |
2930 ASSERT(nFlags <= 2); | 2927 ASSERT(nFlags <= 2); |
2931 pIter->Next(bPrev); | 2928 pIter->Next(bPrev); |
2932 wcTemp = pIter->GetChar(); | 2929 eNextType = (FX_WordBreakProp)GetWordBreakProperty(pIter->GetChar()); |
2933 eNextType = (FX_WordBreakProp)GetWordBreakProperty(wcTemp); | |
2934 if (!((nFlags == 1 && eNextType == FX_WordBreakProp_ALetter) || | 2930 if (!((nFlags == 1 && eNextType == FX_WordBreakProp_ALetter) || |
2935 (nFlags == 2 && eNextType == FX_WordBreakProp_Numberic))) { | 2931 (nFlags == 2 && eNextType == FX_WordBreakProp_Numberic))) { |
2936 pIter->Next(!bPrev); | 2932 pIter->Next(!bPrev); |
2937 pIter->Next(!bPrev); | 2933 pIter->Next(!bPrev); |
2938 return TRUE; | 2934 return TRUE; |
2939 } | 2935 } |
2940 } | 2936 } |
2941 } | 2937 } |
2942 ePreType = eCurType; | 2938 ePreType = eCurType; |
2943 eCurType = eNextType; | 2939 eCurType = eNextType; |
2944 bFirst = FALSE; | 2940 bFirst = FALSE; |
2945 } while (!pIter->IsEOF(!bPrev)); | 2941 } while (!pIter->IsEOF(!bPrev)); |
2946 return TRUE; | 2942 return TRUE; |
2947 } | 2943 } |
OLD | NEW |