comphelper/source/misc/lok.cxx                               |   12 ++++
 drawinglayer/source/primitive2d/texthierarchyprimitive2d.cxx |    4 +
 drawinglayer/source/tools/primitive2dxmldump.cxx             |   14 +++++
 include/comphelper/lok.hxx                                   |    4 +
 sd/source/ui/tools/SlideshowLayerRenderer.cxx                |   29 ++++++++++-
 5 files changed, 60 insertions(+), 3 deletions(-)

New commits:
commit 7c76dfc35350d6a8fef0379129b17ab97a775a4a
Author:     Marco Cecchetti <marco.cecche...@collabora.com>
AuthorDate: Tue Dec 3 18:59:50 2024 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Mon Mar 31 13:10:56 2025 +0200

    lok: slideshow: handle text object in edit mode
    
    This patch allows to render a text object in edit mode by decomposing a
    TextHierarchyEditPrimitive2D instance in place of using TextEditDrawing.
    That avoids to have artifacts displayed while playing the slideshow such as 
a
    tiny rectangle around the edited text shape.
    Moreover it allows to animate a single paragraph even when the related text
    object is in edit mode.
    
    Change-Id: I0c27dc0953dd1b0fb7ae70f41e569587f3a623ac
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183532
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx
index 1d9f887e783a..5c64c2cc4ab0 100644
--- a/comphelper/source/misc/lok.cxx
+++ b/comphelper/source/misc/lok.cxx
@@ -40,6 +40,8 @@ static bool g_bViewIdForVisCursorInvalidation(false);
 
 static bool g_bLocalRendering(false);
 
+static bool g_bSlideshowRendering(false);
+
 static Compat g_eCompatFlags(Compat::none);
 
 static std::function<bool(void*, int)> g_pAnyInputCallback;
@@ -205,6 +207,16 @@ bool isLocalRendering()
     return g_bLocalRendering;
 }
 
+void setSlideshowRendering(bool bSlideshowRendering)
+{
+    g_bSlideshowRendering = bSlideshowRendering;
+}
+
+bool isSlideshowRendering()
+{
+    return g_bSlideshowRendering;
+}
+
 void setCompatFlag(Compat flag) { g_eCompatFlags = 
static_cast<Compat>(g_eCompatFlags | flag); }
 
 bool isCompatFlagSet(Compat flag) { return (g_eCompatFlags & flag) == flag; }
diff --git a/drawinglayer/source/primitive2d/texthierarchyprimitive2d.cxx 
b/drawinglayer/source/primitive2d/texthierarchyprimitive2d.cxx
index 73a21e3c5722..d0a69ad9a336 100644
--- a/drawinglayer/source/primitive2d/texthierarchyprimitive2d.cxx
+++ b/drawinglayer/source/primitive2d/texthierarchyprimitive2d.cxx
@@ -19,6 +19,7 @@
 
 #include <drawinglayer/primitive2d/texthierarchyprimitive2d.hxx>
 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
+#include <comphelper/lok.hxx>
 
 
 using namespace com::sun::star;
@@ -146,7 +147,8 @@ namespace drawinglayer::primitive2d
             const geometry::ViewInformation2D& rViewInformation) const
         {
             // check if TextEdit is active. If not, process. If yes, suppress 
the content
-            if (!rViewInformation.getTextEditActive())
+            // lok case: always decompose it when we're rendering a slide show
+            if (!rViewInformation.getTextEditActive() || 
comphelper::LibreOfficeKit::isSlideshowRendering())
                 GroupPrimitive2D::get2DDecomposition(rVisitor, 
rViewInformation);
         }
 
diff --git a/drawinglayer/source/tools/primitive2dxmldump.cxx 
b/drawinglayer/source/tools/primitive2dxmldump.cxx
index b8d40bd51f75..fb0d78a66be4 100644
--- a/drawinglayer/source/tools/primitive2dxmldump.cxx
+++ b/drawinglayer/source/tools/primitive2dxmldump.cxx
@@ -64,6 +64,7 @@
 #include <drawinglayer/attribute/fillgradientattribute.hxx>
 #include <drawinglayer/attribute/sdrfillgraphicattribute.hxx>
 #include <drawinglayer/attribute/materialattribute3d.hxx>
+#include <drawinglayer/primitive2d/texthierarchyprimitive2d.hxx>
 
 using namespace drawinglayer::primitive2d;
 
@@ -1109,6 +1110,19 @@ void Primitive2dXmlDump::decomposeAndWrite(
                 break;
             }
 
+            case PRIMITIVE2D_ID_TEXTHIERARCHYEDITPRIMITIVE2D:
+            {
+                rWriter.startElement("texthierarchyedit");
+                runDecomposeAndRecurse(pBasePrimitive, rWriter);
+                const auto* pTextHierarchyEditPrimitive
+                    = dynamic_cast<const 
drawinglayer::primitive2d::TextHierarchyEditPrimitive2D*>(
+                        pBasePrimitive);
+                if (pTextHierarchyEditPrimitive)
+                    
decomposeAndWrite(pTextHierarchyEditPrimitive->getChildren(), rWriter);
+                rWriter.endElement();
+                break;
+            }
+
             case PRIMITIVE2D_ID_TEXTHIERARCHYPARAGRAPHPRIMITIVE2D:
             {
                 // TextHierarchyParagraphPrimitive2D.
diff --git a/include/comphelper/lok.hxx b/include/comphelper/lok.hxx
index b6610259c13e..fb8f8417c4d1 100644
--- a/include/comphelper/lok.hxx
+++ b/include/comphelper/lok.hxx
@@ -70,6 +70,10 @@ COMPHELPER_DLLPUBLIC bool isForkedChild();
 COMPHELPER_DLLPUBLIC void setLocalRendering(bool bLocalRendering = true);
 COMPHELPER_DLLPUBLIC bool isLocalRendering();
 
+/// Used by SlideshowLayerRenderer for signaling that a slide rendering is 
occurring.
+COMPHELPER_DLLPUBLIC void setSlideshowRendering(bool bSlideshowRendering);
+COMPHELPER_DLLPUBLIC bool isSlideshowRendering();
+
 /// Check whether clients want a part number in an invalidation payload.
 COMPHELPER_DLLPUBLIC bool isPartInInvalidation();
 /// Set whether clients want a part number in an invalidation payload.
diff --git a/sd/source/ui/tools/SlideshowLayerRenderer.cxx 
b/sd/source/ui/tools/SlideshowLayerRenderer.cxx
index 328859b202bb..16bfb47305f3 100644
--- a/sd/source/ui/tools/SlideshowLayerRenderer.cxx
+++ b/sd/source/ui/tools/SlideshowLayerRenderer.cxx
@@ -31,6 +31,7 @@
 #include <drawdoc.hxx>
 #include <unokywds.hxx>
 #include <comphelper/servicehelper.hxx>
+#include <comphelper/lok.hxx>
 
 #include <com/sun/star/animations/XAnimate.hpp>
 #include <com/sun/star/animations/XAnimationNode.hpp>
@@ -42,7 +43,6 @@
 #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
 #include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx>
 #include <drawinglayer/primitive2d/texthierarchyprimitive2d.hxx>
-#include <drawinglayer/primitive2d/texthierarchyprimitive2d.hxx>
 
 #include <drawinglayer/tools/primitive2dxmldump.hxx>
 
@@ -226,6 +226,18 @@ 
findTextBlock(drawinglayer::primitive2d::Primitive2DContainer const& rContainer,
                 if (pTextBlock)
                     return pTextBlock;
             }
+
+            // for text object in edit mode
+            auto* pTextEditPrimitive
+                = 
dynamic_cast<drawinglayer::primitive2d::TextHierarchyEditPrimitive2D*>(
+                    pBasePrimitive);
+            if (pTextEditPrimitive)
+            {
+                auto* pTextBlock
+                    = findTextBlock(pTextEditPrimitive->getChildren(), 
rViewInformation2D);
+                if (pTextBlock)
+                    return pTextBlock;
+            }
         }
     }
     return nullptr;
@@ -741,7 +753,20 @@ void SlideshowLayerRenderer::createViewAndDraw(
     Point aPoint;
 
     vcl::Region aRegion(::tools::Rectangle(aPoint, aPageSize));
-    aView.CompleteRedraw(rRenderContext.maVirtualDevice, aRegion, pRedirector);
+
+    // Rendering of a text shape in edit mode is performed by decomposing the 
TextHierarchyEditPrimitive2D instance.
+    // Usually such kind of primitive doesn't decompose on primitive 
processing, so we need to signal through a flag
+    // that a slideshow rendering is going to be performed in order to enable 
the decomposition.
+    // Using TextHierarchyEditPrimitive2D decomposition in place of 
TextEditDrawing for rendering a text object
+    // in edit mode allows to animate a single paragraph even when the related 
text object is in edit mode.
+    comphelper::LibreOfficeKit::setSlideshowRendering(true);
+    // Redraw slide but skip EndCompleteRedraw() which uses TextEditDrawing 
for rendering text when a text object is
+    // in edit mode. TextEditDrawing was causing to have artifacts displayed 
while playing the slideshow such as
+    // a tiny rectangle around the edited text shape.
+    SdrPaintWindow* pPaintWindow = 
aView.BeginCompleteRedraw(rRenderContext.maVirtualDevice);
+    OSL_ENSURE(pPaintWindow, "SlideshowLayerRenderer::createViewAndDraw: No 
OutDev (!)");
+    aView.DoCompleteRedraw(*pPaintWindow, aRegion, pRedirector);
+    comphelper::LibreOfficeKit::setSlideshowRendering(false);
 }
 
 namespace

Reply via email to