Rebased ref, commits from common ancestor:
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;
}
commit d087a31fed1f8dd12bd1d3cd008cdcd2af840d07
Author: Miklos Vajna <[email protected]>
AuthorDate: Tue Dec 16 14:39:18 2025 +0100
Commit: Mike Kaganski <[email protected]>
CommitDate: Wed Dec 17 10:30:35 2025 +0100
sw: fix crash in SwFieldEditDlg's AddressHdl
gdb in the core dump gives:
#0 0x000073b5e9fd6bb9 in SwFieldType::Which (this=<optimized out>)
at sw/inc/fldbas.hxx:276
#1 SwField::GetTypeId (this=0x0) at
sw/source/core/fields/fldbas.cxx:267
#2 0x000073b5e911faa4 in SwFieldEditDlg::AddressHdl
(this=0x4a057e70) at sw/source/ui/fldui/fldedt.cxx:296
#3 0x000073b5f85de37c in std::function<void ()>::operator()()
const (this=0x7fffed028930) at
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/std_function.h:587
#4 Control::ImplCallEventListenersAndHandler(VclEventId,
std::function<void ()> const&) (this=<optimized out>,
nEvent=nEvent@entry=VclEventId::ButtonClick, callHandler=...)
at vcl/source/control/ctrl.cxx:311
#5 0x000073b5f85c16c8 in Button::Click (this=<optimized out>) at
vcl/source/control/button.cxx:130
and
#2 0x000073b5e911faa4 in SwFieldEditDlg::AddressHdl
(this=0x4a057e70) at sw/source/ui/fldui/fldedt.cxx:296
warning: Source file is more recent than executable.
296 if (pCurField->GetTypeId() ==
SwFieldTypesEnum::DocumentInfo)
(gdb) print pCurField
$2 = (SwField *) 0x0
return early in case we don't have a valid pointer for the current field
anymore.
Change-Id: Ibc614cc825a0b14cd4f79060d35f6635eb0cdd55
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195716
Tested-by: Caolán McNamara <[email protected]>
Reviewed-by: Caolán McNamara <[email protected]>
Tested-by: Jenkins CollaboraOffice <[email protected]>
(cherry picked from commit a46fe18c9a568ffd5f0f91048163f3478b9c7e55)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195770
Tested-by: Mike Kaganski <[email protected]>
Reviewed-by: Mike Kaganski <[email protected]>
diff --git a/sw/source/ui/fldui/fldedt.cxx b/sw/source/ui/fldui/fldedt.cxx
index 7de2e44135e7..60dcf41b43a6 100644
--- a/sw/source/ui/fldui/fldedt.cxx
+++ b/sw/source/ui/fldui/fldedt.cxx
@@ -292,6 +292,10 @@ IMPL_LINK_NOARG(SwFieldEditDlg, AddressHdl, weld::Button&,
void)
SwFieldPage* pTabPage = static_cast<SwFieldPage*>(GetTabPage());
SwFieldMgr& rMgr = pTabPage->GetFieldMgr();
SwField *pCurField = rMgr.GetCurField();
+ if (!pCurField)
+ {
+ return;
+ }
if (pCurField->GetTypeId() == SwFieldTypesEnum::DocumentInfo)
comphelper::dispatchCommand(u".uno:SetDocumentProperties"_ustr, {});