Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(643)

Side by Side Diff: core/src/fxcrt/fx_arabic.cpp

Issue 1423103002: XFA: Manual merge of Clean up IFX_BidiChar (Closed) Base URL: https://pdfium.googlesource.com/pdfium@xfa
Patch Set: missing files Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "../../include/fxcrt/fx_ucd.h" 7 #include "../../include/fxcrt/fx_ucd.h"
8 #include "fx_arabic.h" 8 #include "fx_arabic.h"
9 9
10 #ifdef __cplusplus 10 #ifdef __cplusplus
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 } 1046 }
1047 }; 1047 };
1048 void FX_BidiLine(CFX_TxtCharArray& chars, int32_t iCount, int32_t iBaseLevel) { 1048 void FX_BidiLine(CFX_TxtCharArray& chars, int32_t iCount, int32_t iBaseLevel) {
1049 CFX_BidiLineTemplate<CFX_TxtChar> blt; 1049 CFX_BidiLineTemplate<CFX_TxtChar> blt;
1050 blt.FX_BidiLine(chars, iCount, iBaseLevel); 1050 blt.FX_BidiLine(chars, iCount, iBaseLevel);
1051 } 1051 }
1052 void FX_BidiLine(CFX_RTFCharArray& chars, int32_t iCount, int32_t iBaseLevel) { 1052 void FX_BidiLine(CFX_RTFCharArray& chars, int32_t iCount, int32_t iBaseLevel) {
1053 CFX_BidiLineTemplate<CFX_RTFChar> blt; 1053 CFX_BidiLineTemplate<CFX_RTFChar> blt;
1054 blt.FX_BidiLine(chars, iCount, iBaseLevel); 1054 blt.FX_BidiLine(chars, iCount, iBaseLevel);
1055 } 1055 }
1056 IFX_BidiChar* IFX_BidiChar::Create() {
1057 return new CFX_BidiChar;
1058 }
1059 CFX_BidiChar::CFX_BidiChar()
1060 : m_bSeparateNeutral(TRUE),
1061 m_iCurStart(0),
1062 m_iCurCount(0),
1063 m_iCurBidi(0),
1064 m_iLastBidi(0),
1065 m_iLastStart(0),
1066 m_iLastCount(0) {}
1067 void CFX_BidiChar::SetPolicy(FX_BOOL bSeparateNeutral) {
1068 m_bSeparateNeutral = bSeparateNeutral;
1069 }
1070
1071 FX_BOOL CFX_BidiChar::AppendChar(FX_WCHAR wch) {
1072 FX_DWORD dwProps = kTextLayoutCodeProperties[(FX_WORD)wch];
1073 int32_t iBidiCls = (dwProps & FX_BIDICLASSBITSMASK) >> FX_BIDICLASSBITS;
1074 int32_t iContext = 0;
1075 switch (iBidiCls) {
1076 case FX_BIDICLASS_L:
1077 case FX_BIDICLASS_AN:
1078 case FX_BIDICLASS_EN:
1079 iContext = 1;
1080 break;
1081 case FX_BIDICLASS_R:
1082 case FX_BIDICLASS_AL:
1083 iContext = 2;
1084 break;
1085 }
1086 FX_BOOL bRet = FALSE;
1087 if (iContext != m_iCurBidi) {
1088 if (m_bSeparateNeutral) {
1089 bRet = TRUE;
1090 } else {
1091 if (m_iCurBidi == 0) {
1092 bRet = (m_iCurCount > 0);
1093 } else {
1094 bRet = (iContext != 0);
1095 }
1096 }
1097 if (bRet) {
1098 m_iLastBidi = m_iCurBidi;
1099 m_iLastStart = m_iCurStart;
1100 m_iCurStart = m_iCurCount;
1101 m_iLastCount = m_iCurCount - m_iLastStart;
1102 }
1103 if (m_bSeparateNeutral || iContext != 0) {
1104 m_iCurBidi = iContext;
1105 }
1106 }
1107 m_iCurCount++;
1108 return bRet;
1109 }
1110 FX_BOOL CFX_BidiChar::EndChar() {
1111 m_iLastBidi = m_iCurBidi;
1112 m_iLastStart = m_iCurStart;
1113 m_iCurStart = m_iCurCount;
1114 m_iLastCount = m_iCurCount - m_iLastStart;
1115 return m_iLastCount > 0;
1116 }
1117 int32_t CFX_BidiChar::GetBidiInfo(int32_t& iStart, int32_t& iCount) {
1118 iStart = m_iLastStart;
1119 iCount = m_iLastCount;
1120 return m_iLastBidi;
1121 }
1122 void CFX_BidiChar::Reset() {
1123 m_iCurStart = 0;
1124 m_iCurCount = 0;
1125 m_iCurBidi = 0;
1126 m_iLastBidi = 0;
1127 m_iLastStart = 0;
1128 m_iLastCount = 0;
1129 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698