dev/null |binary sc/qa/unit/subsequent_export_test2.cxx | 48 --------------------------------- sc/source/filter/oox/drawingbase.cxx | 14 --------- 3 files changed, 1 insertion(+), 61 deletions(-)
New commits: commit 07cf9822b2fc875878b9b3aee712a8413b933e7c Author: Andras Timar <[email protected]> AuthorDate: Wed Dec 17 12:59:16 2025 +0100 Commit: Andras Timar <[email protected]> CommitDate: Wed Dec 17 13:01:07 2025 +0100 Revert "tdf#166724 sc oox: limit x:anchor offsets to inside of the cell" This reverts commit dc3192b27edc8f7a2366e7de6af006e75668d210. Reason: according to Gabor Kelemen this patch triggered a crash and endless loops that is tracked under tdf#170012. Change-Id: I98078cb1375c3a290238c31d74962efe5c193c82 diff --git a/sc/qa/unit/data/xlsx/tdf166724_cellAnchor.xlsx b/sc/qa/unit/data/xlsx/tdf166724_cellAnchor.xlsx deleted file mode 100644 index 3b7004b39d50..000000000000 Binary files a/sc/qa/unit/data/xlsx/tdf166724_cellAnchor.xlsx and /dev/null differ diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx index f88861a2e8df..0729d513d34d 100644 --- a/sc/qa/unit/subsequent_export_test2.cxx +++ b/sc/qa/unit/subsequent_export_test2.cxx @@ -23,8 +23,6 @@ #include <formula/grammar.hxx> #include <svl/numformat.hxx> #include <svl/zformat.hxx> -#include <svx/svdograf.hxx> -#include <svx/svdpage.hxx> #include <com/sun/star/sheet/XHeaderFooterContent.hpp> @@ -52,52 +50,6 @@ CPPUNIT_TEST_FIXTURE(ScExportTest2, testGroupShape) assertXPath(pDoc, "/xdr:wsDr/xdr:twoCellAnchor/xdr:grpSp/xdr:grpSpPr"); } -CPPUNIT_TEST_FIXTURE(ScExportTest2, testTdf166724_cellAnchor) -{ - // given a hand-modified document where the checkbox position was changed to not match anchor - // and the anchor was changed to some absurd values, - // and row 2 was given a much larger height than what optimal-height needs - // (which means that all imported row heights and positions are meaningless)... - - // vmlDrawing1.vml: <x:Anchor> 1, 11, 1, 904, 3, 41, 3, 1</x:Anchor> - // From: Col B pixel offset 11, Row 2 offset 904 - // To: Col D offset 41, Row 4 offset 1 - - createScDoc("xlsx/tdf166724_cellAnchor.xlsx"); - - ScDocument& rDoc = *getScDoc(); - ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer(); - const SdrPage* pPage = pDrawLayer->GetPage(0); - - ScAnchorType anchorType = ScDrawLayer::GetAnchorType(*pPage->GetObj(0)); - // VML's x:anchor indicates cell-anchor - CPPUNIT_ASSERT_EQUAL(SCA_CELL_RESIZE, anchorType); - - // VML's x:anchor has too large Offsets: limit to cell B2's edges. - // Without the fixes, this was X[9040] Y[10257] W[2823] H[742] - tools::Rectangle aRect = pPage->GetObj(0)->GetSnapRect(); - CPPUNIT_ASSERT_EQUAL(tools::Long(1990), aRect.Left()); - CPPUNIT_ASSERT_EQUAL(tools::Long(1058), aRect.Top()); - CPPUNIT_ASSERT_EQUAL(tools::Long(4192), aRect.GetWidth()); - CPPUNIT_ASSERT_EQUAL(tools::Long(557), aRect.GetHeight()); - - // I did not focus on (minor) round-trip concerns. Just documenting the current results... - saveAndReload(TestFilter::XLSX); - - ScDocument& rRTDoc = *getScDoc(); - pDrawLayer = rRTDoc.GetDrawLayer(); - pPage = pDrawLayer->GetPage(0); - - anchorType = ScDrawLayer::GetAnchorType(*pPage->GetObj(0)); - CPPUNIT_ASSERT_EQUAL(SCA_CELL_RESIZE, anchorType); - - aRect = pPage->GetObj(0)->GetSnapRect(); - CPPUNIT_ASSERT_EQUAL(tools::Long(1990), aRect.Left()); - CPPUNIT_ASSERT_EQUAL(tools::Long(1058), aRect.Top()); - CPPUNIT_ASSERT_EQUAL(tools::Long(4192), aRect.GetWidth()); - CPPUNIT_ASSERT_EQUAL(tools::Long(557), aRect.GetHeight()); -}; - CPPUNIT_TEST_FIXTURE(ScExportTest2, testFreezePaneStartCellXLSX) { // given a hand-mangled document with a newly-invalid topLeftCell for the active pane diff --git a/sc/source/filter/oox/drawingbase.cxx b/sc/source/filter/oox/drawingbase.cxx index 127cb73d4c7e..0f1ee8690c35 100644 --- a/sc/source/filter/oox/drawingbase.cxx +++ b/sc/source/filter/oox/drawingbase.cxx @@ -266,19 +266,9 @@ css::awt::Rectangle ShapeAnchor::calcAnchorRectHmm( const css::awt::Size& rPageS EmuPoint ShapeAnchor::calcCellAnchorEmu( const CellAnchorModel& rModel ) const { - const UnitConverter& rUnitConv = getUnitConverter(); - // calculate position of top-left edge of the cell css::awt::Point aPoint = getCellPosition( rModel.mnCol, rModel.mnRow ); - css::awt::Point aNextCell = getCellPosition(rModel.mnCol + 1, rModel.mnRow + 1); EmuPoint aEmuPoint( lclHmmToEmu( aPoint.X ), lclHmmToEmu( aPoint.Y ) ); - // It is easily possible that the provided Offset is invalid (too large). - // Excel seems to limit the offsets to the bottom/left edge of the cell. - // Because most calculations are rounded down to TWIPs, reduce cell's right edge by a full twip. - // Reduce by another twip because of the way GetRange calculates which cell this point is in... - sal_Int64 n2TwipInEmu = std::ceil(rUnitConv.scaleValue(2, Unit::Twip, Unit::Emu)); - EmuPoint aEmuMaxOffset( - lclHmmToEmu(aNextCell.X) - n2TwipInEmu, lclHmmToEmu(aNextCell.Y) - n2TwipInEmu); // add the offset inside the cell switch( meCellAnchorType ) @@ -290,15 +280,13 @@ EmuPoint ShapeAnchor::calcCellAnchorEmu( const CellAnchorModel& rModel ) const case CellAnchorType::Pixel: { + const UnitConverter& rUnitConv = getUnitConverter(); aEmuPoint.X += std::round( rUnitConv.scaleValue( rModel.mnColOffset, Unit::ScreenX, Unit::Emu ) ); aEmuPoint.Y += std::round( rUnitConv.scaleValue( rModel.mnRowOffset, Unit::ScreenY, Unit::Emu ) ); } break; } - aEmuPoint.X = std::min(aEmuPoint.X, aEmuMaxOffset.X); - aEmuPoint.Y = std::min(aEmuPoint.Y, aEmuMaxOffset.Y); - return aEmuPoint; }
