slideshow/source/engine/shapes/drawshape.cxx | 33 ++++++++++++++++++++++++--- slideshow/source/engine/shapes/drawshape.hxx | 2 + 2 files changed, 32 insertions(+), 3 deletions(-)
New commits: commit 53b2132137f526106a3d57ffc6a9cb088a221e17 Author: Armin Le Grand (allotropia) <armin.le.grand.ext...@allotropia.de> AuthorDate: Mon Sep 19 11:48:20 2022 +0200 Commit: Aron Budea <aron.bu...@collabora.com> CommitDate: Thu Nov 10 16:32:33 2022 +0100 tdf#150402 Correct wrong Bound of Shape in Slideshow Added and use mbContainsPageField that gets set in prepareHyperlinkIndices() which has to be run anyways, so this will cause no change in execution speed. It lets us detect the potential error case that a PageField is contained in the Text of the Shape. That is a hint that maBounds contains the wrong Range and needs to be corrected. For more backgrund information please refer to tdf#150402, Comment 16. Change-Id: Ifee01fffdb6e2f5915aa705afc7b5842781aae91 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140144 Tested-by: Jenkins Reviewed-by: Armin Le Grand <armin.le.gr...@me.com> (cherry picked from commit 1b0ff1c166211b34370f53995ae9fb3f8eed182e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140166 (cherry picked from commit 8cefc95845c585d830f642a8d6a575863e75b987) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142551 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Aron Budea <aron.bu...@collabora.com> diff --git a/slideshow/source/engine/shapes/drawshape.cxx b/slideshow/source/engine/shapes/drawshape.cxx index f8e03ebff36f..fc224b7f7b49 100644 --- a/slideshow/source/engine/shapes/drawshape.cxx +++ b/slideshow/source/engine/shapes/drawshape.cxx @@ -365,7 +365,8 @@ namespace slideshow::internal mbIsVisible( true ), mbForceUpdate( false ), mbAttributeLayerRevoked( false ), - mbDrawingLayerAnim( false ) + mbDrawingLayerAnim( false ), + mbContainsPageField( false ) { ENSURE_OR_THROW( mxShape.is(), "DrawShape::DrawShape(): Invalid XShape" ); ENSURE_OR_THROW( mxPage.is(), "DrawShape::DrawShape(): Invalid containing page" ); @@ -390,6 +391,26 @@ namespace slideshow::internal maSubsetting.reset( mpCurrMtf ); prepareHyperlinkIndices(); + + if(mbContainsPageField && mpCurrMtf && !maBounds.isEmpty()) + { + // tdf#150402 Use mbContainsPageField that gets set in prepareHyperlinkIndices + // which has to be run anyways, so this will cause no harm in execution speed. + // It lets us detect the potential error case that a PageField is contained in + // the Text of the Shape. That is a hint that maBounds contains the wrong Range + // and needs to be corrected. The correct size is in the PrefSize of the metafile. + // For more backgrund information please refer to tdf#150402, Comment 16. + const double fWidthDiff(fabs(mpCurrMtf->GetPrefSize().Width() - maBounds.getWidth())); + const double fHeightDiff(fabs(mpCurrMtf->GetPrefSize().Height() - maBounds.getHeight())); + + if(fWidthDiff > 1.0 || fHeightDiff > 1.0) + { + maBounds = basegfx::B2DRange( + maBounds.getMinX(), maBounds.getMinY(), + maBounds.getMinX() + mpCurrMtf->GetPrefSize().Width(), + maBounds.getMinY() + mpCurrMtf->GetPrefSize().Height()); + } + } } DrawShape::DrawShape( const uno::Reference< drawing::XShape >& xShape, @@ -424,7 +445,8 @@ namespace slideshow::internal mbIsVisible( true ), mbForceUpdate( false ), mbAttributeLayerRevoked( false ), - mbDrawingLayerAnim( false ) + mbDrawingLayerAnim( false ), + mbContainsPageField( false ) { ENSURE_OR_THROW( rGraphic.IsAnimated(), "DrawShape::DrawShape(): Graphic is no animation" ); @@ -474,7 +496,8 @@ namespace slideshow::internal mbIsVisible( rSrc.mbIsVisible ), mbForceUpdate( false ), mbAttributeLayerRevoked( false ), - mbDrawingLayerAnim( false ) + mbDrawingLayerAnim( false ), + mbContainsPageField( false ) { ENSURE_OR_THROW( mxShape.is(), "DrawShape::DrawShape(): Invalid XShape" ); ENSURE_OR_THROW( mpCurrMtf, "DrawShape::DrawShape(): Invalid metafile" ); @@ -866,6 +889,10 @@ namespace slideshow::internal { maHyperlinkIndices.back().second = nIndex; } + else if (pAct->GetComment().equalsIgnoreAsciiCase("FIELD_SEQ_BEGIN;PageField")) + { + mbContainsPageField = true; + } ++nIndex; } else diff --git a/slideshow/source/engine/shapes/drawshape.hxx b/slideshow/source/engine/shapes/drawshape.hxx index eb9030affde0..8636a7acd8e9 100644 --- a/slideshow/source/engine/shapes/drawshape.hxx +++ b/slideshow/source/engine/shapes/drawshape.hxx @@ -349,6 +349,8 @@ namespace slideshow::internal /// whether a drawing layer animation has to be performed bool mbDrawingLayerAnim; + /// tdf#150402 wether mpCurrMtf contains any Text with a PageField ("FIELD_SEQ_BEGIN;PageField") + mutable bool mbContainsPageField; }; }