From f8eb28d6b6e306d87e5cec3f1b6f83c841a5f01e Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 9 Feb 2022 19:52:43 +0000 Subject: tdf#137571 use XActionGuard to lock blocks that don't need updating MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit so we can avoid constantly generating new TextForwarders which are the same as the one they replace. The underlying problem is that of tdf#123470 but this solution should be safe to backport Change-Id: I742f2a9ce0024adf9bd0acc5bb8edb9372fc0af5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129775 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- sd/source/core/CustomAnimationEffect.cxx | 1 + sd/source/ui/animations/CustomAnimationList.cxx | 13 ++++++++- sd/source/ui/animations/CustomAnimationPane.cxx | 36 +++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) (limited to 'sd') diff --git a/sd/source/core/CustomAnimationEffect.cxx b/sd/source/core/CustomAnimationEffect.cxx index cf6dcadc1b86..d9d88443ebe5 100644 --- a/sd/source/core/CustomAnimationEffect.cxx +++ b/sd/source/core/CustomAnimationEffect.cxx @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include diff --git a/sd/source/ui/animations/CustomAnimationList.cxx b/sd/source/ui/animations/CustomAnimationList.cxx index 356093d69810..09822606d67d 100644 --- a/sd/source/ui/animations/CustomAnimationList.cxx +++ b/sd/source/ui/animations/CustomAnimationList.cxx @@ -17,6 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include +#include #include #include #include @@ -26,7 +28,7 @@ #include #include #include -#include +#include #include #include #include @@ -182,6 +184,15 @@ static OUString getDescription( const Any& rTarget, bool bWithText ) ParagraphTarget aParaTarget; rTarget >>= aParaTarget; + css::uno::Reference xLockable(aParaTarget.Shape, css::uno::UNO_QUERY); + if (xLockable.is()) + xLockable->addActionLock(); + comphelper::ScopeGuard aGuard([&xLockable]() + { + if (xLockable.is()) + xLockable->removeActionLock(); + }); + Reference< XEnumerationAccess > xText( aParaTarget.Shape, UNO_QUERY_THROW ); Reference< XEnumeration > xEnumeration( xText->createEnumeration(), css::uno::UNO_SET_THROW ); sal_Int32 nPara = aParaTarget.Paragraph; diff --git a/sd/source/ui/animations/CustomAnimationPane.cxx b/sd/source/ui/animations/CustomAnimationPane.cxx index 66ded2c772c9..3f52abb544b3 100644 --- a/sd/source/ui/animations/CustomAnimationPane.cxx +++ b/sd/source/ui/animations/CustomAnimationPane.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -36,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -1657,6 +1659,15 @@ static bool getTextSelection( const Any& rSelection, Reference< XShape >& xShape { xShape.set( xSelectedText->getText(), UNO_QUERY_THROW ); + css::uno::Reference xLockable(xShape, css::uno::UNO_QUERY); + if (xLockable.is()) + xLockable->addActionLock(); + comphelper::ScopeGuard aGuard([&xLockable]() + { + if (xLockable.is()) + xLockable->removeActionLock(); + }); + Reference< XTextRangeCompare > xTextRangeCompare( xShape, UNO_QUERY_THROW ); Reference< XEnumerationAccess > xParaEnumAccess( xShape, UNO_QUERY_THROW ); Reference< XEnumeration > xParaEnum( xParaEnumAccess->createEnumeration(), UNO_SET_THROW ); @@ -1710,6 +1721,22 @@ static bool getTextSelection( const Any& rSelection, Reference< XShape >& xShape return false; } +namespace +{ + Reference getTargetShape(const Any& rTarget) + { + Reference xShape; + rTarget >>= xShape; + if( !xShape.is() ) + { + ParagraphTarget aParaTarget; + if (rTarget >>= aParaTarget) + xShape = aParaTarget.Shape; + } + return xShape; + } +} + void CustomAnimationPane::onAdd() { bool bHasText = true; @@ -1815,6 +1842,15 @@ void CustomAnimationPane::onAdd() bool bFirst = true; for( const auto& rTarget : aTargets ) { + css::uno::Reference xLockable(getTargetShape(rTarget), css::uno::UNO_QUERY); + if (xLockable.is()) + xLockable->addActionLock(); + comphelper::ScopeGuard aGuard([&xLockable]() + { + if (xLockable.is()) + xLockable->removeActionLock(); + }); + CustomAnimationEffectPtr pCreated = mpMainSequence->append( pDescriptor, rTarget, fDuration ); // if only one shape with text and no fill or outline is selected, animate only by first level paragraphs -- cgit