summaryrefslogtreecommitdiff
path: root/svx/source
diff options
context:
space:
mode:
authorArmin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de>2023-08-23 16:55:07 +0200
committerArmin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de>2023-08-24 12:40:58 +0200
commitbfafc863bbe7a4cd576f36db24bf5744f983c025 (patch)
treed537925ac9bcfd1ca710c95e833a16fc24de5529 /svx/source
parente43f09bec7bc1d7f367a9b6f6a8ec001a102645d (diff)
Reset buffered GridOffset(s) for suspicious values
Huge offsets of GridOffset(s) are a hint for error -> usually the conditions for calculation have changed. E.g. - I saw errors with +/-5740, that was in the environment of massive external UNO API using LO as target. If condtions for this calculation change, it is usually required to call - ViewObjectContact::resetGridOffset(), or - ObjectContact::resetAllGridOffsets() or - ScDrawView::resetGridOffsetsForAllSdrPageViews() as it is done e.g. when zoom changes (see ScDrawView::RecalcScale()). Theoretically these resets have to be done for any precondition changed that is used in the calculation of that value (see ScDrawView::calculateGridOffsetForSdrObject). This is not complete and would be hard to do so. Since it is just a buffered value and re-calculation is not expensive (linear O(n)) we can just reset suspicious values here what fixes the problem. Hopefully - when that non-linear ViewTransformation problem for the calc-view gets solved one day - all this can be removed again. For now, let's just reset here and force re-calculation. Added a SAL_WARN to inform about this, too. Change-Id: I09137f7703fd00c2351a288a40bf87a2691ba6e3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155983 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'svx/source')
-rw-r--r--svx/source/sdr/contact/viewobjectcontact.cxx35
1 files changed, 32 insertions, 3 deletions
diff --git a/svx/source/sdr/contact/viewobjectcontact.cxx b/svx/source/sdr/contact/viewobjectcontact.cxx
index d15ba27dd9f9..7191743188e1 100644
--- a/svx/source/sdr/contact/viewobjectcontact.cxx
+++ b/svx/source/sdr/contact/viewobjectcontact.cxx
@@ -461,10 +461,39 @@ drawinglayer::primitive2d::Primitive2DContainer ViewObjectContact::getPrimitive2
// (->View) that has then all needed information
const basegfx::B2DVector& ViewObjectContact::getGridOffset() const
{
- if(0.0 == maGridOffset.getX() && 0.0 == maGridOffset.getY() && GetObjectContact().supportsGridOffsets())
+ if (GetObjectContact().supportsGridOffsets())
{
- // create on-demand
- GetObjectContact().calculateGridOffsetForViewOjectContact(const_cast<ViewObjectContact*>(this)->maGridOffset, *this);
+ if (fabs(maGridOffset.getX()) > 1000.0)
+ {
+ // Huge offsets are a hint for error -> usually the conditions for
+ // calculation have changed. E.g. - I saw errors with +/-5740, that
+ // was in the environment of massive external UNO API using LO as
+ // target.
+ // If condtions for this calculation change, it is usually required to call
+ // - ViewObjectContact::resetGridOffset(), or
+ // - ObjectContact::resetAllGridOffsets() or
+ // - ScDrawView::resetGridOffsetsForAllSdrPageViews()
+ // as it is done e.g. when zoom changes (see ScDrawView::RecalcScale()).
+ // Theoretically these resets have to be done for any precondition
+ // changed that is used in the calculation of that value (see
+ // ScDrawView::calculateGridOffsetForSdrObject).
+ // This is not complete and would be hard to do so.
+ // Since it is just a buffered value and re-calculation is not
+ // expensive (linear O(n)) we can just reset suspicious values here.
+ // Hopefully - when that non-linear ViewTransformation problem for
+ // the calc-view gets solved one day - all this can be removed
+ // again. For now, let's just reset here and force re-calculation.
+ // Add a SAL_WARN to inform about this.
+ SAL_WARN("svx", "Suspicious GridOffset value resetted (!)");
+ const_cast<ViewObjectContact*>(this)->maGridOffset.setX(0.0);
+ const_cast<ViewObjectContact*>(this)->maGridOffset.setY(0.0);
+ }
+
+ if(0.0 == maGridOffset.getX() && 0.0 == maGridOffset.getY() && GetObjectContact().supportsGridOffsets())
+ {
+ // create on-demand
+ GetObjectContact().calculateGridOffsetForViewOjectContact(const_cast<ViewObjectContact*>(this)->maGridOffset, *this);
+ }
}
return maGridOffset;