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: خالد حسني <khaled@libreoffice.org>
(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 264f8f3..13ea030 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;
                    }