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/include/fxcrt/fx_ucd.h" | 7 #include "core/include/fxcrt/fx_ucd.h" |
8 #include "core/src/fxcrt/fx_arabic.h" | 8 #include "core/src/fxcrt/fx_arabic.h" |
9 | 9 |
10 namespace { | 10 namespace { |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 int32_t iStart, | 376 int32_t iStart, |
377 int32_t iCount, | 377 int32_t iCount, |
378 int32_t iNest) { | 378 int32_t iNest) { |
379 FXSYS_assert(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL && iNest >= 0); | 379 FXSYS_assert(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL && iNest >= 0); |
380 FXSYS_assert(classes.GetSize() == levels.GetSize()); | 380 FXSYS_assert(classes.GetSize() == levels.GetSize()); |
381 FXSYS_assert(iStart >= 0 && iStart < classes.GetSize()); | 381 FXSYS_assert(iStart >= 0 && iStart < classes.GetSize()); |
382 FXSYS_assert(iCount >= 0 && iStart + iCount <= classes.GetSize()); | 382 FXSYS_assert(iCount >= 0 && iStart + iCount <= classes.GetSize()); |
383 if (iCount < 1) { | 383 if (iCount < 1) { |
384 return 0; | 384 return 0; |
385 } | 385 } |
386 #if 0 | 386 |
387 int32_t iLastNest = iNest; | |
388 #endif | |
389 int32_t iSize = classes.GetSize(); | 387 int32_t iSize = classes.GetSize(); |
390 int32_t i = iStart, iCur, iCls; | 388 int32_t i = iStart, iCur, iCls; |
391 for (; i < iSize && iCount > 0; i++, iCount--) { | 389 for (; i < iSize && iCount > 0; i++, iCount--) { |
392 iCur = iCls = classes.GetAt(i); | 390 iCur = iCls = classes.GetAt(i); |
393 #if 0 | 391 |
394 switch (iCls) { | |
395 case FX_BIDICLASS_LRO: | |
396 case FX_BIDICLASS_LRE: | |
397 classes.SetAt(i, FX_BIDICLASS_BN); | |
398 iCls = FX_BIDICLASS_BN; | |
399 iNest ++; | |
400 if (FX_BidiGreaterEven(iBaseLevel) <= MAX_LEVEL) { | |
401 int32_t iLevel = FX_BidiGreaterEven(iBaseLevel); | |
402 levels.SetAt(i, iLevel); | |
403 i += FX_BidiResolveExplicit(iLevel, | |
404 (iCls == FX_BIDICLASS_LRE ? FX_B
IDICLASS_N : FX_BIDICLASS_L), | |
405 classes, | |
406 levels, | |
407 i + 1, | |
408 iCount - 1, | |
409 iNest); | |
410 iNest --; | |
411 continue; | |
412 } | |
413 break; | |
414 case FX_BIDICLASS_RLO: | |
415 case FX_BIDICLASS_RLE: | |
416 classes.SetAt(i, FX_BIDICLASS_BN); | |
417 iCls = FX_BIDICLASS_BN; | |
418 iNest ++; | |
419 if (FX_BidiGreaterOdd(iBaseLevel) <= MAX_LEVEL) { | |
420 int32_t iLevel = FX_BidiGreaterOdd(iBaseLevel); | |
421 levels.SetAt(i, iLevel); | |
422 i += FX_BidiResolveExplicit(iLevel, | |
423 (iCls == FX_BIDICLASS_RLE ? FX_B
IDICLASS_N : FX_BIDICLASS_R), | |
424 classes, | |
425 levels, | |
426 i + 1, | |
427 iCount - 1, | |
428 iNest); | |
429 iNest --; | |
430 continue; | |
431 } | |
432 break; | |
433 case FX_BIDICLASS_PDF: | |
434 classes.SetAt(i, FX_BIDICLASS_BN); | |
435 iCls = FX_BIDICLASS_BN; | |
436 if (iNest) { | |
437 if (iLastNest < iNest) { | |
438 iNest --; | |
439 } else { | |
440 iSize = i; | |
441 } | |
442 } | |
443 break; | |
444 } | |
445 iCur = iCls; | |
446 #endif | |
447 if (iDirection != FX_BIDICLASS_N) { | 392 if (iDirection != FX_BIDICLASS_N) { |
448 iCls = iDirection; | 393 iCls = iDirection; |
449 } | 394 } |
450 if (iCur != FX_BIDICLASS_BN) { | 395 if (iCur != FX_BIDICLASS_BN) { |
451 classes.SetAt(i, iCls); | 396 classes.SetAt(i, iCls); |
452 } | 397 } |
453 levels.SetAt(i, iBaseLevel); | 398 levels.SetAt(i, iBaseLevel); |
454 } | 399 } |
455 return i - iStart; | 400 return i - iStart; |
456 } | 401 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 int32_t iSize = classes.GetSize(); | 491 int32_t iSize = classes.GetSize(); |
547 if (iSize < 1) { | 492 if (iSize < 1) { |
548 return; | 493 return; |
549 } | 494 } |
550 iSize--; | 495 iSize--; |
551 int32_t iLevelCur = iBaseLevel; | 496 int32_t iLevelCur = iBaseLevel; |
552 int32_t iState = FX_IsOdd(iBaseLevel) ? FX_BWSxr : FX_BWSxl; | 497 int32_t iState = FX_IsOdd(iBaseLevel) ? FX_BWSxr : FX_BWSxl; |
553 int32_t i = 0, iCount = 0, iClsCur, iClsRun, iClsNew, iAction; | 498 int32_t i = 0, iCount = 0, iClsCur, iClsRun, iClsNew, iAction; |
554 for (; i <= iSize; i++) { | 499 for (; i <= iSize; i++) { |
555 iClsCur = classes.GetAt(i); | 500 iClsCur = classes.GetAt(i); |
556 #if 0 | 501 |
557 if (iClsCur == FX_BIDICLASS_BN) { | |
558 levels.SetAt(i, iLevelCur); | |
559 if (i == iSize && iLevelCur != iBaseLevel) { | |
560 iClsCur = FX_BidiDirection(iLevelCur); | |
561 classes.SetAt(i, iClsCur); | |
562 } else if (i < iSize) { | |
563 int32_t iLevelNext, iLevelNew; | |
564 iClsNew = classes.GetAt(i + 1); | |
565 iLevelNext = levels.GetAt(i + 1); | |
566 if (iClsNew != FX_BIDICLASS_BN && iLevelCur != iLevelNext) { | |
567 iLevelNew = iLevelNext; | |
568 if (iLevelCur > iLevelNew) { | |
569 iLevelNew = iLevelCur; | |
570 } | |
571 levels.SetAt(i, iLevelNew); | |
572 iClsCur = FX_BidiDirection(iLevelNew); | |
573 classes.SetAt(i, iClsCur); | |
574 iLevelCur = iLevelNext; | |
575 } else { | |
576 if (iCount) { | |
577 iCount ++; | |
578 } | |
579 continue; | |
580 } | |
581 } else { | |
582 if (iCount) { | |
583 iCount ++; | |
584 } | |
585 continue; | |
586 } | |
587 } | |
588 #endif | |
589 FXSYS_assert(iClsCur <= FX_BIDICLASS_BN); | 502 FXSYS_assert(iClsCur <= FX_BIDICLASS_BN); |
590 iAction = gc_FX_BidiWeakActions[iState][iClsCur]; | 503 iAction = gc_FX_BidiWeakActions[iState][iClsCur]; |
591 iClsRun = FX_BidiGetDeferredType(iAction); | 504 iClsRun = FX_BidiGetDeferredType(iAction); |
592 if (iClsRun != FX_BIDIWEAKACTION_XX && iCount > 0) { | 505 if (iClsRun != FX_BIDIWEAKACTION_XX && iCount > 0) { |
593 FX_BidiSetDeferredRun(classes, i, iCount, iClsRun); | 506 FX_BidiSetDeferredRun(classes, i, iCount, iClsRun); |
594 iCount = 0; | 507 iCount = 0; |
595 } | 508 } |
596 iClsNew = FX_BidiGetResolvedType(iAction); | 509 iClsNew = FX_BidiGetResolvedType(iAction); |
597 if (iClsNew != FX_BIDIWEAKACTION_XX) { | 510 if (iClsNew != FX_BIDIWEAKACTION_XX) { |
598 classes.SetAt(i, iClsNew); | 511 classes.SetAt(i, iClsNew); |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1141 } | 1054 } |
1142 }; | 1055 }; |
1143 void FX_BidiLine(CFX_TxtCharArray& chars, int32_t iCount, int32_t iBaseLevel) { | 1056 void FX_BidiLine(CFX_TxtCharArray& chars, int32_t iCount, int32_t iBaseLevel) { |
1144 CFX_BidiLineTemplate<CFX_TxtChar> blt; | 1057 CFX_BidiLineTemplate<CFX_TxtChar> blt; |
1145 blt.FX_BidiLine(chars, iCount, iBaseLevel); | 1058 blt.FX_BidiLine(chars, iCount, iBaseLevel); |
1146 } | 1059 } |
1147 void FX_BidiLine(CFX_RTFCharArray& chars, int32_t iCount, int32_t iBaseLevel) { | 1060 void FX_BidiLine(CFX_RTFCharArray& chars, int32_t iCount, int32_t iBaseLevel) { |
1148 CFX_BidiLineTemplate<CFX_RTFChar> blt; | 1061 CFX_BidiLineTemplate<CFX_RTFChar> blt; |
1149 blt.FX_BidiLine(chars, iCount, iBaseLevel); | 1062 blt.FX_BidiLine(chars, iCount, iBaseLevel); |
1150 } | 1063 } |
OLD | NEW |