| 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 "core/fxcrt/fx_arabic.h" | 7 #include "core/fxcrt/fx_arabic.h" |
| 8 #include "core/fxcrt/fx_ucd.h" | 8 #include "core/fxcrt/fx_ucd.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 iAction = (iAction & 0xF); | 367 iAction = (iAction & 0xF); |
| 368 if (iAction == FX_BIDINEUTRALACTION_In) { | 368 if (iAction == FX_BIDINEUTRALACTION_In) { |
| 369 return 0; | 369 return 0; |
| 370 } else { | 370 } else { |
| 371 return iAction; | 371 return iAction; |
| 372 } | 372 } |
| 373 } | 373 } |
| 374 | 374 |
| 375 int32_t FX_BidiReorderLevel(int32_t iBaseLevel, | 375 int32_t FX_BidiReorderLevel(int32_t iBaseLevel, |
| 376 CFX_WideString& wsText, | 376 CFX_WideString& wsText, |
| 377 const CFX_Int32Array& levels, | 377 const CFX_ArrayTemplate<int32_t>& levels, |
| 378 int32_t iStart, | 378 int32_t iStart, |
| 379 bool bReverse) { | 379 bool bReverse) { |
| 380 ASSERT(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL); | 380 ASSERT(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL); |
| 381 ASSERT(wsText.GetLength() == levels.GetSize()); | 381 ASSERT(wsText.GetLength() == levels.GetSize()); |
| 382 ASSERT(iStart >= 0 && iStart < wsText.GetLength()); | 382 ASSERT(iStart >= 0 && iStart < wsText.GetLength()); |
| 383 int32_t iSize = wsText.GetLength(); | 383 int32_t iSize = wsText.GetLength(); |
| 384 if (iSize < 1) { | 384 if (iSize < 1) { |
| 385 return 0; | 385 return 0; |
| 386 } | 386 } |
| 387 bReverse = bReverse || FX_IsOdd(iBaseLevel); | 387 bReverse = bReverse || FX_IsOdd(iBaseLevel); |
| 388 int32_t i = iStart, iLevel; | 388 int32_t i = iStart, iLevel; |
| 389 for (; i < iSize; i++) { | 389 for (; i < iSize; i++) { |
| 390 if ((iLevel = levels.GetAt(i)) == iBaseLevel) { | 390 if ((iLevel = levels.GetAt(i)) == iBaseLevel) { |
| 391 continue; | 391 continue; |
| 392 } | 392 } |
| 393 if (iLevel < iBaseLevel) { | 393 if (iLevel < iBaseLevel) { |
| 394 break; | 394 break; |
| 395 } | 395 } |
| 396 i += FX_BidiReorderLevel(iBaseLevel + 1, wsText, levels, i, bReverse) - 1; | 396 i += FX_BidiReorderLevel(iBaseLevel + 1, wsText, levels, i, bReverse) - 1; |
| 397 } | 397 } |
| 398 int32_t iCount = i - iStart; | 398 int32_t iCount = i - iStart; |
| 399 if (bReverse && iCount > 1) { | 399 if (bReverse && iCount > 1) { |
| 400 FX_BidiReverseString(wsText, iStart, iCount); | 400 FX_BidiReverseString(wsText, iStart, iCount); |
| 401 } | 401 } |
| 402 return iCount; | 402 return iCount; |
| 403 } | 403 } |
| 404 void FX_BidiReorder(int32_t iBaseLevel, | 404 void FX_BidiReorder(int32_t iBaseLevel, |
| 405 CFX_WideString& wsText, | 405 CFX_WideString& wsText, |
| 406 const CFX_Int32Array& levels) { | 406 const CFX_ArrayTemplate<int32_t>& levels) { |
| 407 ASSERT(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL); | 407 ASSERT(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL); |
| 408 ASSERT(wsText.GetLength() == levels.GetSize()); | 408 ASSERT(wsText.GetLength() == levels.GetSize()); |
| 409 int32_t iSize = wsText.GetLength(); | 409 int32_t iSize = wsText.GetLength(); |
| 410 if (iSize < 1) { | 410 if (iSize < 1) { |
| 411 return; | 411 return; |
| 412 } | 412 } |
| 413 int32_t i = 0; | 413 int32_t i = 0; |
| 414 while (i < iSize) { | 414 while (i < iSize) { |
| 415 i += FX_BidiReorderLevel(iBaseLevel, wsText, levels, i, false); | 415 i += FX_BidiReorderLevel(iBaseLevel, wsText, levels, i, false); |
| 416 } | 416 } |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 } | 741 } |
| 742 }; | 742 }; |
| 743 void FX_BidiLine(CFX_TxtCharArray& chars, int32_t iCount, int32_t iBaseLevel) { | 743 void FX_BidiLine(CFX_TxtCharArray& chars, int32_t iCount, int32_t iBaseLevel) { |
| 744 CFX_BidiLineTemplate<CFX_TxtChar> blt; | 744 CFX_BidiLineTemplate<CFX_TxtChar> blt; |
| 745 blt.FX_BidiLine(chars, iCount, iBaseLevel); | 745 blt.FX_BidiLine(chars, iCount, iBaseLevel); |
| 746 } | 746 } |
| 747 void FX_BidiLine(CFX_RTFCharArray& chars, int32_t iCount, int32_t iBaseLevel) { | 747 void FX_BidiLine(CFX_RTFCharArray& chars, int32_t iCount, int32_t iBaseLevel) { |
| 748 CFX_BidiLineTemplate<CFX_RTFChar> blt; | 748 CFX_BidiLineTemplate<CFX_RTFChar> blt; |
| 749 blt.FX_BidiLine(chars, iCount, iBaseLevel); | 749 blt.FX_BidiLine(chars, iCount, iBaseLevel); |
| 750 } | 750 } |
| OLD | NEW |