summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorSerge Krot <Serge.Krot@cib.de>2019-02-06 20:02:02 +0100
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2019-02-15 15:44:44 +0100
commitc4f0a9dbe4aa4d3f418971b62b82620fe5e203d4 (patch)
tree32f41bac927f8ac14fe8d287c80fb17bc1560171 /sc
parent0b5fa9ba9f6ab401e411d5ffe843c77b74734657 (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/67729 Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
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 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;