sc/qa/unit/data/ods/RowHeightTdf165003.ods |binary sc/qa/unit/subsequent_filters_test4.cxx | 23 +++++++++++++++++++++++ sc/source/core/data/column2.cxx | 8 +++++++- 3 files changed, 30 insertions(+), 1 deletion(-)
New commits: commit 4a334d519c3fb2b5cb9c59b3ea4adc3a22be5d58 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Feb 11 12:54:02 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Tue Feb 11 22:21:18 2025 +0100 tdf#165003 Row height wrong at writing direction 90° regression from commit f91a411340ae204ce1e6997f22e0352a4c6a8355 Author: Noel Grandin <noelgran...@gmail.com> Date: Thu May 23 15:09:52 2024 +0200 reduce cost of calc column height calculation This also fixes another bug in the above commit where the code did not update nValue for the "else if (bBreak && !bWidth)" case Change-Id: I367a56c2cb555336e1d510efb0c7acac1447525f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181417 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> (cherry picked from commit f2639e2a98f114f053a13da669440587d56a0dd8) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181423 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> (cherry picked from commit ef385dbed89bbec4eac75f9fb6e1d348bc91fd03) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181427 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Michael Weghorn <m.wegh...@posteo.de> Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org> diff --git a/sc/qa/unit/data/ods/RowHeightTdf165003.ods b/sc/qa/unit/data/ods/RowHeightTdf165003.ods new file mode 100644 index 000000000000..b3672f929f82 Binary files /dev/null and b/sc/qa/unit/data/ods/RowHeightTdf165003.ods differ diff --git a/sc/qa/unit/subsequent_filters_test4.cxx b/sc/qa/unit/subsequent_filters_test4.cxx index caf29b9f9c03..d3e29f89d333 100644 --- a/sc/qa/unit/subsequent_filters_test4.cxx +++ b/sc/qa/unit/subsequent_filters_test4.cxx @@ -418,6 +418,29 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest4, testRowHeightODS) CPPUNIT_ASSERT_MESSAGE("Row should have an automatic height.", !bManual); } +CPPUNIT_TEST_FIXTURE(ScFiltersTest4, testRowHeightTdf165003) +{ + createScDoc("ods/RowHeightTdf165003.ods"); + + SCTAB nTab = 0; + SCROW nRow = 0; + ScDocument* pDoc = getScDoc(); + + int nHeight = pDoc->GetRowHeight(nRow, nTab, false); + CPPUNIT_ASSERT_EQUAL(256, nHeight); + nHeight = pDoc->GetRowHeight(++nRow, nTab, false); + CPPUNIT_ASSERT_EQUAL(256, nHeight); + nHeight = pDoc->GetRowHeight(++nRow, nTab, false); + CPPUNIT_ASSERT_EQUAL(256, nHeight); + nHeight = pDoc->GetRowHeight(++nRow, nTab, false); + CPPUNIT_ASSERT_EQUAL(256, nHeight); + // this row has 90-degree rotated text, and without the fix, would have had zero height. + nHeight = pDoc->GetRowHeight(++nRow, nTab, false); + CPPUNIT_ASSERT_EQUAL(582, nHeight); + nHeight = pDoc->GetRowHeight(++nRow, nTab, false); + CPPUNIT_ASSERT_EQUAL(256, nHeight); +} + CPPUNIT_TEST_FIXTURE(ScFiltersTest4, testRichTextContentODS) { createScDoc("ods/rich-text-cells.ods"); diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 2b0a88aef220..dd9fbf29a566 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -310,7 +310,10 @@ tools::Long ScColumn::GetNeededSize( tools::Long nWidth = 0; if ( eOrient != SvxCellOrientation::Standard ) { - nWidth = pDev->GetTextHeight(); + tools::Long nHeight = pDev->GetTextHeight(); + // swap width and height + nValue = bWidth ? nHeight : pDev->GetTextWidth( aValStr ); + nWidth = nHeight; } else if ( nRotate ) { @@ -363,7 +366,10 @@ tools::Long ScColumn::GetNeededSize( } } else if (bBreak && !bWidth) + { nWidth = pDev->GetTextWidth(aValStr); + nValue = pDev->GetTextHeight(); + } else // in the common case (height), avoid calling the expensive GetTextWidth nValue = bWidth ? pDev->GetTextWidth( aValStr ) : pDev->GetTextHeight();