[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-1+backports' - sc/qa sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Feb 15 14:45:12 UTC 2019


 sc/qa/unit/data/ods/tdf121040.ods      |binary
 sc/qa/unit/subsequent_filters-test.cxx |   18 ++++++++++++++++++
 sc/source/core/data/column2.cxx        |   16 +++++++++++++---
 sc/source/ui/view/output2.cxx          |    6 ++++--
 4 files changed, 35 insertions(+), 5 deletions(-)

New commits:
commit c4f0a9dbe4aa4d3f418971b62b82620fe5e203d4
Author:     Serge Krot <Serge.Krot at cib.de>
AuthorDate: Wed Feb 6 20:02:02 2019 +0100
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Fri Feb 15 15:44:44 2019 +0100

    tdf#121040 sc: cell with ### has too big height
    
    Make the same behavior as inside MSO - numbers with any
    different number format should not be broken on two or more lines
    regardless "wrap text automatically" option.
    
    Change-Id: I135ecef1ad01171dd22828100309311bd8eea6ce
    Reviewed-on: https://gerrit.libreoffice.org/67470
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Reviewed-on: https://gerrit.libreoffice.org/67729
    Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/sc/qa/unit/data/ods/tdf121040.ods b/sc/qa/unit/data/ods/tdf121040.ods
new file mode 100644
index 000000000000..ef25565a7ea8
Binary files /dev/null and b/sc/qa/unit/data/ods/tdf121040.ods differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 326dc0608f29..83a803f71374 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -194,6 +194,7 @@ public:
     void testMiscRowHeights();
     void testOptimalHeightReset();
     void testCustomNumFormatHybridCellODS();
+    void testTdf121040();
 
     void testPrintRangeODS();
     void testOutlineODS();
@@ -329,6 +330,7 @@ public:
     CPPUNIT_TEST(testMiscRowHeights);
     CPPUNIT_TEST(testOptimalHeightReset);
     CPPUNIT_TEST(testCustomNumFormatHybridCellODS);
+    CPPUNIT_TEST(testTdf121040);
     CPPUNIT_TEST(testPrintRangeODS);
     CPPUNIT_TEST(testOutlineODS);
     CPPUNIT_TEST(testColumnStyleXLSX);
@@ -2748,6 +2750,22 @@ void ScFiltersTest::testCustomNumFormatHybridCellODS()
     xDocSh->DoClose();
 }
 
+void ScFiltersTest::testTdf121040()
+{
+    ScDocShellRef xDocSh = loadDoc("tdf121040.", FORMAT_ODS);
+    CPPUNIT_ASSERT_MESSAGE("Failed to load tdf121040.ods", xDocSh.is());
+
+    const SCTAB nTab = 0;
+    ScDocument& rDoc = xDocSh->GetDocument();
+
+    // The first 9 rows should have the same height
+    const sal_uInt16 nHeight = rDoc.GetRowHeight(0, nTab, false);
+    for (SCTAB nRow=1; nRow<9; nRow++)
+    {
+        CPPUNIT_ASSERT_EQUAL(nHeight, rDoc.GetRowHeight(nRow, nTab, false));
+    }
+}
+
 void ScFiltersTest::testPrintRangeODS()
 {
     ScDocShellRef xDocSh = loadDoc("print-range.", FORMAT_ODS);
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 89ac4e47fe53..c7883862674f 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -159,8 +159,18 @@ long ScColumn::GetNeededSize(
 
     SvNumberFormatter* pFormatter = pDocument->GetFormatTable();
     sal_uInt32 nFormat = pPattern->GetNumberFormat( pFormatter, pCondSet );
-    // #i111387# disable automatic line breaks only for "General" number format
-    if (bBreak && ( nFormat % SV_COUNTRY_LANGUAGE_OFFSET ) == 0 )
+
+    // get "cell is value" flag
+    // Must be synchronized with ScOutputData::LayoutStrings()
+    bool bCellIsValue = (aCell.meType == CELLTYPE_VALUE);
+    if (aCell.meType == CELLTYPE_FORMULA)
+    {
+        ScFormulaCell* pFCell = aCell.mpFormula;
+        bCellIsValue = pFCell->IsRunning() || pFCell->IsValue();
+    }
+
+    // #i111387#, tdf#121040: disable automatic line breaks for all number formats
+    if (bBreak && bCellIsValue && (pFormatter->GetType(nFormat) == SvNumFormatType::NUMBER))
     {
         // If a formula cell needs to be interpreted during aCell.hasNumeric()
         // to determine the type, the pattern may get invalidated because the
@@ -182,7 +192,7 @@ long ScColumn::GetNeededSize(
             else
             {
                 nFormat = pPattern->GetNumberFormat( pFormatter, pCondSet );
-                if ((nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0)
+                if (pFormatter->GetType(nFormat) == SvNumFormatType::NUMBER)
                     bBreak = false;
             }
         }
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 3dfaaa9889f9..3f1f463b5d6b 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -1716,8 +1716,10 @@ tools::Rectangle ScOutputData::LayoutStrings(bool bPixelToLogic, bool bPaint, co
                             *pPattern, pCondSet, mpDoc, nTab, bNumberFormatIsText );
 
                     bool bBreak = ( aVars.GetLineBreak() || aVars.GetHorJust() == SvxCellHorJustify::Block );
-                    // #i111387# #o11817313# disable automatic line breaks only for "General" number format
-                    if (bBreak && bCellIsValue && (aVars.GetResultValueFormat() % SV_COUNTRY_LANGUAGE_OFFSET) == 0)
+                    // #i111387# #o11817313# tdf#121040 disable automatic line breaks for all number formats
+                    // Must be synchronized with ScColumn::GetNeededSize()
+                    SvNumberFormatter* pFormatter = mpDoc->GetFormatTable();
+                    if (bBreak && bCellIsValue && (pFormatter->GetType(aVars.GetResultValueFormat()) == SvNumFormatType::NUMBER))
                         bBreak = false;
 
                     bool bRepeat = aVars.IsRepeat() && !bBreak;


More information about the Libreoffice-commits mailing list