summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-02-09 19:52:43 +0000
committerAdolfo Jayme Barrientos <fitojb@ubuntu.com>2022-02-11 01:39:25 +0100
commitc1fd702dacec60cbd87531e9f11caf3d0cfbb155 (patch)
treee7f74b2719f5990c97ada303921b81102901f874
parentd7a727334b50253e86f21e5ff34ac361e13c3b37 (diff)
tdf#137571 use XActionGuard to lock blocks that don't need updating
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/+/129762 Tested-by: Jenkins Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
-rw-r--r--sd/source/core/CustomAnimationEffect.cxx1
-rw-r--r--sd/source/ui/animations/CustomAnimationList.cxx13
-rw-r--r--sd/source/ui/animations/CustomAnimationPane.cxx36
-rw-r--r--svx/source/unodraw/unoshtxt.cxx5
4 files changed, 52 insertions, 3 deletions
diff --git a/sd/source/core/CustomAnimationEffect.cxx b/sd/source/core/CustomAnimationEffect.cxx
index ee6317916f23..99f68aadb1e4 100644
--- a/sd/source/core/CustomAnimationEffect.cxx
+++ b/sd/source/core/CustomAnimationEffect.cxx
@@ -51,6 +51,7 @@
#include <com/sun/star/util/XCloneable.hpp>
#include <com/sun/star/util/XChangesNotifier.hpp>
#include <comphelper/processfactory.hxx>
+#include <comphelper/scopeguard.hxx>
#include <comphelper/sequence.hxx>
#include <com/sun/star/lang/Locale.hpp>
#include <com/sun/star/i18n/BreakIterator.hpp>
diff --git a/sd/source/ui/animations/CustomAnimationList.cxx b/sd/source/ui/animations/CustomAnimationList.cxx
index 2ae97e5cc5dc..4c18a8429c38 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 <com/sun/star/document/XActionLockable.hpp>
+#include <com/sun/star/drawing/XDrawPage.hpp>
#include <com/sun/star/drawing/XShapes.hpp>
#include <com/sun/star/presentation/ShapeAnimationSubType.hpp>
#include <com/sun/star/presentation/EffectNodeType.hpp>
@@ -26,7 +28,7 @@
#include <com/sun/star/presentation/EffectCommands.hpp>
#include <com/sun/star/text/XTextRange.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/drawing/XDrawPage.hpp>
+#include <comphelper/scopeguard.hxx>
#include <CustomAnimationList.hxx>
#include <CustomAnimationPreset.hxx>
#include <vcl/commandevent.hxx>
@@ -182,6 +184,15 @@ static OUString getDescription( const Any& rTarget, bool bWithText )
ParagraphTarget aParaTarget;
rTarget >>= aParaTarget;
+ css::uno::Reference<css::document::XActionLockable> 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 b952a72f69ab..5782005d0870 100644
--- a/sd/source/ui/animations/CustomAnimationPane.cxx
+++ b/sd/source/ui/animations/CustomAnimationPane.cxx
@@ -22,6 +22,7 @@
#include <com/sun/star/animations/AnimationNodeType.hpp>
#include <com/sun/star/animations/ParallelTimeContainer.hpp>
#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <com/sun/star/document/XActionLockable.hpp>
#include <com/sun/star/drawing/XDrawView.hpp>
#include <com/sun/star/drawing/XShape.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
@@ -36,6 +37,7 @@
#include <com/sun/star/drawing/LineStyle.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
#include <comphelper/processfactory.hxx>
+#include <comphelper/scopeguard.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/viewfrm.hxx>
#include <tools/debug.hxx>
@@ -1645,6 +1647,15 @@ static bool getTextSelection( const Any& rSelection, Reference< XShape >& xShape
{
xShape.set( xSelectedText->getText(), UNO_QUERY_THROW );
+ css::uno::Reference<css::document::XActionLockable> 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 );
@@ -1698,6 +1709,22 @@ static bool getTextSelection( const Any& rSelection, Reference< XShape >& xShape
return false;
}
+namespace
+{
+ Reference<XShape> getTargetShape(const Any& rTarget)
+ {
+ Reference<XShape> xShape;
+ rTarget >>= xShape;
+ if( !xShape.is() )
+ {
+ ParagraphTarget aParaTarget;
+ if (rTarget >>= aParaTarget)
+ xShape = aParaTarget.Shape;
+ }
+ return xShape;
+ }
+}
+
void CustomAnimationPane::onAdd()
{
bool bHasText = true;
@@ -1803,6 +1830,15 @@ void CustomAnimationPane::onAdd()
bool bFirst = true;
for( const auto& rTarget : aTargets )
{
+ css::uno::Reference<css::document::XActionLockable> 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
diff --git a/svx/source/unodraw/unoshtxt.cxx b/svx/source/unodraw/unoshtxt.cxx
index cfb01211c129..8ccf0e8e47b8 100644
--- a/svx/source/unodraw/unoshtxt.cxx
+++ b/svx/source/unodraw/unoshtxt.cxx
@@ -661,8 +661,9 @@ SvxTextForwarder* SvxTextEditSourceImpl::GetTextForwarder()
{
// tdf#123470 if the text edit mode of the shape is active, then we
// cannot trust a previously cached TextForwarder state as the text may
- // be out of date, so force a refetch in that case.
- if (IsEditMode())
+ // be out of date, so force a refetch in that case, unless locked against
+ // changes
+ if (IsEditMode() && mpTextForwarder && !mbIsLocked)
{
assert(!mbForwarderIsEditMode); // because without a view there is no other option except !mbForwarderIsEditMode
bool bTextEditActive = false;