summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArmin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de>2022-09-19 11:48:20 +0200
committerArmin Le Grand <Armin.Le.Grand@me.com>2022-09-20 13:29:59 +0200
commit8cefc95845c585d830f642a8d6a575863e75b987 (patch)
tree2b3eb31b154e19027e9d45c6e744143183dc0503
parentsw HTML import: fix height of images when it is missing and width is relative (diff)
downloadcore-8cefc95845c585d830f642a8d6a575863e75b987.tar.gz
core-8cefc95845c585d830f642a8d6a575863e75b987.zip
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.Grand@me.com> (cherry picked from commit 1b0ff1c166211b34370f53995ae9fb3f8eed182e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140166
-rw-r--r--slideshow/source/engine/shapes/drawshape.cxx33
-rw-r--r--slideshow/source/engine/shapes/drawshape.hxx2
2 files changed, 32 insertions, 3 deletions
diff --git a/slideshow/source/engine/shapes/drawshape.cxx b/slideshow/source/engine/shapes/drawshape.cxx
index 22b65bf28e21..000ffd262065 100644
--- a/slideshow/source/engine/shapes/drawshape.cxx
+++ b/slideshow/source/engine/shapes/drawshape.cxx
@@ -366,7 +366,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" );
@@ -391,6 +392,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,
@@ -425,7 +446,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" );
@@ -475,7 +497,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" );
@@ -867,6 +890,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;
};
}