sc/source/core/data/drwlayer.cxx |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

New commits:
commit 788859c02f11d264ab04cec4a29a1bcaafc05c18
Author:     Julien Nabet <serval2...@yahoo.fr>
AuthorDate: Thu Nov 25 21:59:57 2021 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Dec 1 18:11:26 2021 +0100

    tdf#144244: fix crash when FILESAVE a calc file after delete some columns
    
    see bt here:
    https://bugs.documentfoundation.org/attachment.cgi?id=176507
    
    Regression from 3238606c8470f3eaeada3fc601e186ec5cfac925
    tdf138138 Apply shape shift also to NoRotatedAnchor
    The 'normal' anchor (as on screen) is connected to the snap rectangle,
    the NoRotatedAnchor is connected to the logic rectangle. They differ,
    if the shape is transformed, e.g. rotated. Error was, that values of
    the 'normal' anchor were applied to NoRotatedAnchor instead of
    calculating the shift of NoRotatedAnchor independently. The error
    becomes only visible on save, because there the NoRotatedAnchor is
    used. Effected shape types are legacy shapes, text boxes and
    transformable OLEs.
    I have not tested, whether this fix would work for LO 7.0 too.
    
    Let's apply the same controls as we do with ScDrawObjData retrieved with 
GetObjDataTab
    
    Change-Id: I73cb3dd3c47a7ec55667e498d4a62842ce63d861
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125852
    Tested-by: Jenkins
    Tested-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-by: Eike Rathke <er...@redhat.com>
    (cherry picked from commit 1d45f84bd08c8d196fcf3c9baaf2cad010884e5c)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126140
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index 1ead0b8fe872..ab70efe5a7ce 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -547,10 +547,18 @@ void ScDrawLayer::MoveCells( SCTAB nTab, SCCOL 
nCol1,SCROW nRow1, SCCOL nCol2,SC
                 ScDrawObjData* pNoRotatedAnchor = GetNonRotatedObjData( pObj );
                 if ( pNoRotatedAnchor )
                 {
-                    pNoRotatedAnchor->maStart.IncCol(nDx);
-                    pNoRotatedAnchor->maStart.IncRow(nDy);
-                    pNoRotatedAnchor->maEnd.IncCol(nDx);
-                    pNoRotatedAnchor->maEnd.IncRow(nDy);
+                    const ScAddress aOldSttNoRotatedAnchor = 
pNoRotatedAnchor->maStart;
+                    const ScAddress aOldEndNoRotatedAnchor = 
pNoRotatedAnchor->maEnd;
+                    if ( aOldSttNoRotatedAnchor.IsValid() && IsInBlock( 
aOldSttNoRotatedAnchor, nCol1,nRow1, nCol2,nRow2 ) )
+                    {
+                        pNoRotatedAnchor->maStart.IncCol(nDx);
+                        pNoRotatedAnchor->maStart.IncRow(nDy);
+                    }
+                    if ( aOldEndNoRotatedAnchor.IsValid() && IsInBlock( 
aOldEndNoRotatedAnchor, nCol1,nRow1, nCol2,nRow2 ) )
+                    {
+                        pNoRotatedAnchor->maEnd.IncCol(nDx);
+                        pNoRotatedAnchor->maEnd.IncRow(nDy);
+                    }
                 }
 
                 AddCalcUndo( std::make_unique<ScUndoObjData>( pObj, aOldStt, 
aOldEnd, pData->maStart, pData->maEnd ) );

Reply via email to