summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorSerge Krot <Serge.Krot@cib.de>2019-02-06 20:02:02 +0100
committerEike Rathke <erack@redhat.com>2019-02-14 15:33:08 +0100
commit367a2fe4880e7187092a38267d56193dcd54bc6c (patch)
treeb2ae5114ad0666b75fdb50589956687f50b227f0 /sc
parent11f6ca61d937e9c93a6f049ded534787544f6483 (diff)
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@CIB.de> Reviewed-on: https://gerrit.libreoffice.org/67777 Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/data/ods/tdf121040.odsbin0 -> 8575 bytes
-rw-r--r--sc/qa/unit/subsequent_filters-test.cxx18
-rw-r--r--sc/source/core/data/column2.cxx16
-rw-r--r--sc/source/ui/view/output2.cxx6
4 files changed, 35 insertions, 5 deletions
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
--- /dev/null
+++ b/sc/qa/unit/data/ods/tdf121040.ods
Binary files differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index eca265feeb9d..c1d68418ba1f 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -197,6 +197,7 @@ public:
void testMiscRowHeights();
void testOptimalHeightReset();
void testCustomNumFormatHybridCellODS();
+ void testTdf121040();
void testPrintRangeODS();
void testOutlineODS();
@@ -336,6 +337,7 @@ public:
CPPUNIT_TEST(testMiscRowHeights);
CPPUNIT_TEST(testOptimalHeightReset);
CPPUNIT_TEST(testCustomNumFormatHybridCellODS);
+ CPPUNIT_TEST(testTdf121040);
CPPUNIT_TEST(testPrintRangeODS);
CPPUNIT_TEST(testOutlineODS);
CPPUNIT_TEST(testColumnStyleXLSX);
@@ -2866,6 +2868,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 5f77628699f6..1124c162c0c2 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -151,8 +151,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
@@ -174,7 +184,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 bdb25193d89f..19505a5a0b8c 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -1718,8 +1718,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;