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 f2639e2a98f114f053a13da669440587d56a0dd8
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Feb 11 12:54:02 2025 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Feb 11 14:39:09 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>

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 72a5b1bd2a53..d8f11d5a3493 100644
--- a/sc/qa/unit/subsequent_filters_test4.cxx
+++ b/sc/qa/unit/subsequent_filters_test4.cxx
@@ -440,6 +440,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 e0e5505da9aa..37db657fb552 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();

Reply via email to