slideshow/source/engine/shapes/drawshape.cxx |   33 ++++++++++++++++++++++++---
 slideshow/source/engine/shapes/drawshape.hxx |    2 +
 2 files changed, 32 insertions(+), 3 deletions(-)

New commits:
commit 1b0ff1c166211b34370f53995ae9fb3f8eed182e
Author:     Armin Le Grand (allotropia) <armin.le.grand.ext...@allotropia.de>
AuthorDate: Mon Sep 19 11:48:20 2022 +0200
Commit:     Armin Le Grand <armin.le.gr...@me.com>
CommitDate: Mon Sep 19 16:24:46 2022 +0200

    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>

diff --git a/slideshow/source/engine/shapes/drawshape.cxx 
b/slideshow/source/engine/shapes/drawshape.cxx
index ba6f2b0cbfb2..bc50fc695375 100644
--- a/slideshow/source/engine/shapes/drawshape.cxx
+++ b/slideshow/source/engine/shapes/drawshape.cxx
@@ -367,7 +367,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" );
@@ -392,6 +393,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,
@@ -426,7 +447,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" );
@@ -476,7 +498,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" );
@@ -868,6 +891,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 e775a891f679..4ede703cc982 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;
         };
 
 }

Reply via email to