@@ -624,10 +624,10 @@ private static void ApplyCenterAlignment(RGraphics g, CssLineBox line)
624624 word . Left += diff ;
625625 }
626626
627- foreach ( CssBox b in line . Rectangles . Keys )
627+ foreach ( CssBox b in ToList ( line . Rectangles . Keys ) )
628628 {
629- RRect r = b . Rectangles [ line ] ;
630- b . Rectangles [ line ] = new RRect ( r . X + diff , r . Y , r . Width , r . Height ) ;
629+ RRect r = line . Rectangles [ b ] ;
630+ line . Rectangles [ b ] = new RRect ( r . X + diff , r . Y , r . Width , r . Height ) ;
631631 }
632632 }
633633 }
@@ -654,10 +654,10 @@ private static void ApplyRightAlignment(RGraphics g, CssLineBox line)
654654 word . Left += diff ;
655655 }
656656
657- foreach ( CssBox b in line . Rectangles . Keys )
657+ foreach ( CssBox b in ToList ( line . Rectangles . Keys ) )
658658 {
659- RRect r = b . Rectangles [ line ] ;
660- b . Rectangles [ line ] = new RRect ( r . X + diff , r . Y , r . Width , r . Height ) ;
659+ RRect r = line . Rectangles [ b ] ;
660+ line . Rectangles [ b ] = new RRect ( r . X + diff , r . Y , r . Width , r . Height ) ;
661661 }
662662 }
663663 }
@@ -687,6 +687,16 @@ private static void ApplyLeftAlignment(RGraphics g, CssLineBox line)
687687 //}
688688 }
689689
690+ private static List < T > ToList < T > ( IEnumerable < T > collection )
691+ {
692+ List < T > result = new List < T > ( ) ;
693+ foreach ( T item in collection )
694+ {
695+ result . Add ( item ) ;
696+ }
697+ return result ;
698+ }
699+
690700 #endregion
691701 }
692702}
0 commit comments