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

New commits:
commit 08152c9771b4f7d48f1a6b6dd1289d454d4f6514
Author:     Khaled Hosny <[email protected]>
AuthorDate: Wed Jul 5 17:12:19 2023 +0300
Commit:     خالد حسني <[email protected]>
CommitDate: Thu Jul 6 07:22:11 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: خالد حسني <[email protected]>
    (cherry picked from commit f98870faa7ec645675c178c69321f9e846598112)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154044

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