slideshow/source/engine/shapes/drawshapesubsetting.cxx |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

New commits:
commit 5d2fa4ab6e75609c30351f0623dac63182be4c27
Author:     Khaled Hosny <kha...@libreoffice.org>
AuthorDate: Wed Jul 5 17:12:19 2023 +0300
Commit:     خالد حسني <kha...@libreoffice.org>
CommitDate: Wed Jul 5 23:21:24 2023 +0200

    tdf#113290: Fix handling of grapheme clusters in slideshow animations
    
    When doing animations by character cells (AKA grapheme clusters), we
    were taking the first character of the cluster only and lumping the rest
    with the next cluster, so a combining mark would appear at the start of
    the next sequence instead of the end of the current one.
    
    For surrogate pairs it was even more broken we were splitting in the
    middle of the pair resulting in invalid Unicode sequence.
    
    Change-Id: I9bbfe412e9b0a876b69e33c0916067bf75064122
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154066
    Tested-by: Jenkins
    Reviewed-by: خالد حسني <kha...@libreoffice.org>

diff --git a/slideshow/source/engine/shapes/drawshapesubsetting.cxx 
b/slideshow/source/engine/shapes/drawshapesubsetting.cxx
index 264f8f3316b2..13ea0300fa63 100644
--- a/slideshow/source/engine/shapes/drawshapesubsetting.cxx
+++ b/slideshow/source/engine/shapes/drawshapesubsetting.cxx
@@ -579,16 +579,24 @@ namespace slideshow::internal
                             aLastWordStart = aNext;
                             [[fallthrough]];
                         case DrawShapeSubsetting::CLASS_CHARACTER_CELL_END:
+                            // tdf#113290
+                            // This is a special case since a character cell
+                            // (AKA grapheme cluster) can have multiple
+                            // characters, so if we passed nCurrCharCount to
+                            // io_rFunctor() it would stop at the first
+                            // character in the cluster, so we subtract one
+                            // so that it matches when we reach the start of
+                            // the next cluster.
                             if( !io_rFunctor( 
DrawShapeSubsetting::CLASS_CHARACTER_CELL_END,
-                                              nCurrCharCount,
+                                              nCurrCharCount - 1,
                                               aLastCharStart,
-                                              aNext ) )
+                                              aCurr ) )
                             {
                                 return;
                             }
 
                             ++nCurrCharCount;
-                            aLastCharStart = aNext;
+                            aLastCharStart = aCurr;
                             break;
                     }
 

Reply via email to