diff options
author | Regina Henschel <rb.henschel@t-online.de> | 2024-04-06 14:59:38 +0200 |
---|---|---|
committer | Regina Henschel <rb.henschel@t-online.de> | 2024-04-08 15:50:40 +0200 |
commit | 1e1b1d46155163380252093d9d2868351236ce0e (patch) | |
tree | 33113d823daadbafabfddcd2bd266bd63388d107 /sc/source/filter/xml | |
parent | c7362f365b7d4699740729e6bf263e1217577797 (diff) |
tdf#160369 Do not broadcast temporarily group change
The position and size of a group needs to be temporarily changed when
saving because ODF does not treat hidden rows/cols as zero, but LO does.
After saving, these changes have to be undone. The error was that the
restore was performed with GetGeoDate/SetGeoData. But SetGeoData
includes a broadcast that triggeres recalculations that should not be
performed here. Now the change and restore are both done with NbcMove
and NbcResize.
The import had set a 'logical rectangle', but that is nonsense for a
group, because a group does not have a 'logical rectangle'.
For a group, none of the special corrections in
ScDrawLayer::InitializeCellAnchoredObj are needed.
Change-Id: I00adf39e83011112492822d2900e41242d188e84
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165872
Tested-by: Jenkins
Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'sc/source/filter/xml')
-rw-r--r-- | sc/source/filter/xml/xmlexprt.cxx | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index e776c006643a..e85eb1f39c30 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -3528,10 +3528,12 @@ void ScXMLExport::WriteShapes(const ScMyCell& rMyCell) // rectangle from the anchor as if all column/rows are shown. Then we move and resize // (in case of "resize with cell") the object to meet this snap rectangle. We need to // manipulate the object itself, because the used methods in xmloff do not evaluate the - // ObjData. This manipulation is only done temporarily for export. Thus we stash the geometry - // and restore it when export is done and we use NbcFoo methods. - bool bNeedsRestore = false; - std::unique_ptr<SdrObjGeoData> pGeoData = pObj->GetGeoData(); + // ObjData. We remember the transformations and restore them later. + Point aMoveBy(0, 0); + bool bNeedsRestorePosition = false; + Fraction aScaleWidth(1, 1); + Fraction aScaleHeight(1, 1); + bool bNeedsRestoreSize = false; // Determine top point of fictive snap rectangle ('Full' rectangle). SCTAB aTab(aSnapStartAddress.Tab()); @@ -3552,8 +3554,8 @@ void ScXMLExport::WriteShapes(const ScMyCell& rMyCell) Point aActualTopPoint = bNegativePage ? aOrigSnapRect.TopRight() : aOrigSnapRect.TopLeft(); if (aFullTopPoint != aActualTopPoint) { - bNeedsRestore = true; - Point aMoveBy = aFullTopPoint - aActualTopPoint; + bNeedsRestorePosition = true; + aMoveBy = aFullTopPoint - aActualTopPoint; pObj->NbcMove(Size(aMoveBy.X(), aMoveBy.Y())); } @@ -3565,6 +3567,7 @@ void ScXMLExport::WriteShapes(const ScMyCell& rMyCell) // Object is anchored "To cell (resize with cell)". Compare size of actual snap rectangle // and fictive full one. Resize object accordingly. tools::Rectangle aActualSnapRect(pObj->GetSnapRect()); + Point aSnapEndOffset(pObjData->maEndOffset); aCol = aSnapEndAddress.Col(); aRow = aSnapEndAddress.Row(); @@ -3581,12 +3584,13 @@ void ScXMLExport::WriteShapes(const ScMyCell& rMyCell) if (aFullSnapRect != aActualSnapRect) { - bNeedsRestore = true; - Fraction aScaleWidth(aFullSnapRect.getOpenWidth(), aActualSnapRect.getOpenWidth()); + bNeedsRestoreSize = true; + aScaleWidth + = Fraction(aFullSnapRect.getOpenWidth(), aActualSnapRect.getOpenWidth()); if (!aScaleWidth.IsValid()) aScaleWidth = Fraction(1, 1); - Fraction aScaleHeight(aFullSnapRect.getOpenHeight(), - aActualSnapRect.getOpenHeight()); + aScaleHeight + = Fraction(aFullSnapRect.getOpenHeight(), aActualSnapRect.getOpenHeight()); if (!aScaleHeight.IsValid()) aScaleHeight = Fraction(1, 1); pObj->NbcResize(aFullTopPoint, aScaleWidth, aScaleHeight); @@ -3634,9 +3638,20 @@ void ScXMLExport::WriteShapes(const ScMyCell& rMyCell) ExportShape(rShape.xShape, &aPoint); - // Restore object geometry - if (bNeedsRestore && pGeoData) - pObj->SetGeoData(*pGeoData); + if (bNeedsRestoreSize) + { + Fraction aScaleWidthInvers(aScaleWidth.GetDenominator(), aScaleWidth.GetNumerator()); + if (!aScaleWidthInvers.IsValid()) + aScaleWidthInvers = Fraction(1, 1); + Fraction aScaleHeightInvers(aScaleHeight.GetDenominator(), aScaleHeight.GetNumerator()); + if (!aScaleHeightInvers.IsValid()) + aScaleHeightInvers = Fraction(1, 1); + pObj->NbcResize(aFullTopPoint, aScaleWidthInvers, aScaleHeightInvers); + } + if (bNeedsRestorePosition) + { + pObj->NbcMove(Size(-aMoveBy.X(), -aMoveBy.Y())); + } } } |