summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2015-04-24 16:55:01 -0400
committerAndras Timar <andras.timar@collabora.com>2015-05-28 14:56:12 +0200
commitb1f1c77687e301c99e81631d33298e44bdb5ca84 (patch)
tree073a2e94ed762ec7233968253e0f5e99df9568d7 /sc
parent6a17a535c34c76a766fe693ae10c58ddac6a3ab4 (diff)
Resolves tdf#67712 form controls and draw objects
anchored to cell but changes position after reopening Also included tdf#68797 "FILEOPEN lost position of lines anchored to cell". It was marked as duplicate but the step to reproduce are different. Conflicts: sc/qa/unit/subsequent_filters-test.cxx Conflicts: sc/qa/unit/subsequent_export-test.cxx Reviewed-on: https://gerrit.libreoffice.org/15523 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Andras Timar <andras.timar@collabora.com> (cherry picked from commit 487880b6882ec01c1b4679eae60bec484272a86b) Conflicts: sc/qa/unit/subsequent_export-test.cxx Change-Id: Ia1c4010f118749256077a0ecad6ca16b867d22f7
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/drwlayer.cxx59
1 files changed, 59 insertions, 0 deletions
diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx
index 23e0de35a36f..6649953ce0f7 100644
--- a/sc/source/core/data/drwlayer.cxx
+++ b/sc/source/core/data/drwlayer.cxx
@@ -27,6 +27,7 @@
#include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
#include <com/sun/star/datatransfer/XTransferable.hpp>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
#include "scitems.hxx"
#include <editeng/eeitem.hxx>
@@ -116,6 +117,14 @@ void ScUndoObjData::Undo()
pData->maStart = aOldStt;
pData->maEnd = aOldEnd;
}
+
+ // Undo also an untransformed anchor
+ pData = ScDrawLayer::GetNonRotatedObjData( pObj );
+ if (pData)
+ {
+ pData->maStart = aOldStt;
+ pData->maEnd = aOldEnd;
+ }
}
void ScUndoObjData::Redo()
@@ -127,6 +136,14 @@ void ScUndoObjData::Redo()
pData->maStart = aNewStt;
pData->maEnd = aNewEnd;
}
+
+ // Redo also an untransformed anchor
+ pData = ScDrawLayer::GetNonRotatedObjData( pObj );
+ if (pData)
+ {
+ pData->maStart = aNewStt;
+ pData->maEnd = aNewEnd;
+ }
}
ScTabDeletedHint::ScTabDeletedHint( SCTAB nTabNo ) :
@@ -495,6 +512,15 @@ void ScDrawLayer::MoveCells( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SC
{
if ( pObj->ISA( SdrRectObj ) && pData->maStart.IsValid() && pData->maEnd.IsValid() )
pData->maStart.PutInOrder( pData->maEnd );
+
+ // Update also an untransformed anchor thats what we stored ( and still do ) to xml
+ ScDrawObjData* pNoRotatedAnchor = GetNonRotatedObjData( pObj, false );
+ if ( pNoRotatedAnchor )
+ {
+ pNoRotatedAnchor->maStart = pData->maStart;
+ pNoRotatedAnchor->maEnd = pData->maEnd;
+ }
+
AddCalcUndo( new ScUndoObjData( pObj, aOldStt, aOldEnd, pData->maStart, pData->maEnd ) );
RecalcPos( pObj, *pData, bNegativePage, bUpdateNoteCaptionPos );
}
@@ -759,6 +785,39 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, ScDrawObjData& rData, bool bNegati
ScDrawObjData& rNoRotatedAnchor = *GetNonRotatedObjData( pObj, true );
if (rData.maLastRect.IsEmpty())
{
+ // Every shape it is saved with an negative offset relative to cell
+ if (ScDrawLayer::GetAnchorType(*pObj) == SCA_CELL)
+ {
+ double fRotate(0.0);
+ double fShearX(0.0);
+
+ Point aPoint;
+ Rectangle aRect;
+
+ basegfx::B2DTuple aScale;
+ basegfx::B2DTuple aTranslate;
+ basegfx::B2DPolyPolygon aPolyPolygon;
+ basegfx::B2DHomMatrix aOriginalMatrix;
+
+ aRect = pDoc->GetMMRect(nCol1, nRow1, nCol1 , nRow1, nTab1);
+
+ if (bNegativePage)
+ aPoint.X() = aRect.Right();
+ else
+ aPoint.X() = aRect.Left();
+ aPoint.Y() = aRect.Top();
+
+ pObj->TRGetBaseGeometry(aOriginalMatrix, aPolyPolygon);
+ aOriginalMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
+ aTranslate += ::basegfx::B2DTuple(aPoint.X(), aPoint.Y());
+ aOriginalMatrix = basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
+ aScale,
+ fShearX,
+ fRotate,
+ aTranslate);
+ pObj->TRSetBaseGeometry(aOriginalMatrix, aPolyPolygon);
+ }
+
// It's confusing ( but blame that we persist the anchor in terms of unrotated shape )
// that the initial anchor we get here is in terms of an unrotated shape ( if the shape is rotated )
// we need to save the old anchor ( for persisting ) and also track any resize or repositions that happen.