summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParis Oplopoios <paris.oplopoios@collabora.com>2023-08-23 12:31:15 +0300
committerParis Oplopoios <parisoplop@gmail.com>2023-08-28 10:27:37 +0200
commit1760ee4d328cfb6ba22a5b3c84016625b12adb25 (patch)
tree3ed545f3ad1d2871d4dc617c8be74a6c610c25e2
parent407297d9c592479d9fc90033876cad96206f9259 (diff)
sc: Fix wrapText not being applied correctly on export
Change-Id: I03aaa36af8fe820fa07d2eea13c5b0f69ad74dad Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155970 Tested-by: Jenkins Reviewed-by: Paris Oplopoios <parisoplop@gmail.com>
-rw-r--r--sc/qa/unit/data/xlsx/wrap-text.xlsxbin0 -> 8730 bytes
-rw-r--r--sc/qa/unit/subsequent_export_test.cxx20
-rw-r--r--sc/source/filter/excel/xestyle.cxx2
-rw-r--r--sc/source/filter/excel/xetable.cxx2
4 files changed, 22 insertions, 2 deletions
diff --git a/sc/qa/unit/data/xlsx/wrap-text.xlsx b/sc/qa/unit/data/xlsx/wrap-text.xlsx
new file mode 100644
index 000000000000..961cfcbdc02e
--- /dev/null
+++ b/sc/qa/unit/data/xlsx/wrap-text.xlsx
Binary files differ
diff --git a/sc/qa/unit/subsequent_export_test.cxx b/sc/qa/unit/subsequent_export_test.cxx
index 1ce8ef99c926..60b9f9fb1c0f 100644
--- a/sc/qa/unit/subsequent_export_test.cxx
+++ b/sc/qa/unit/subsequent_export_test.cxx
@@ -1805,6 +1805,26 @@ CPPUNIT_TEST_FIXTURE(ScExportTest, testRichTextCellFormatXLSX)
assertXPath(pStyles, aXPath3, "val", "true");
}
+CPPUNIT_TEST_FIXTURE(ScExportTest, testWrapText)
+{
+ createScDoc("xlsx/wrap-text.xlsx");
+
+ save("Calc Office Open XML");
+
+ xmlDocUniquePtr pStyles = parseExport("xl/styles.xml");
+ CPPUNIT_ASSERT(pStyles);
+
+ assertXPath(pStyles, "/x:styleSheet/x:cellXfs", "count", "7");
+
+ assertXPath(pStyles, "/x:styleSheet/x:cellXfs/x:xf[1]/x:alignment", "wrapText", "false");
+ assertXPath(pStyles, "/x:styleSheet/x:cellXfs/x:xf[2]/x:alignment", "wrapText", "false");
+ assertXPath(pStyles, "/x:styleSheet/x:cellXfs/x:xf[3]/x:alignment", "wrapText", "false");
+ assertXPath(pStyles, "/x:styleSheet/x:cellXfs/x:xf[4]/x:alignment", "wrapText", "false");
+ assertXPath(pStyles, "/x:styleSheet/x:cellXfs/x:xf[5]/x:alignment", "wrapText", "true");
+ assertXPath(pStyles, "/x:styleSheet/x:cellXfs/x:xf[6]/x:alignment", "wrapText", "true");
+ assertXPath(pStyles, "/x:styleSheet/x:cellXfs/x:xf[7]/x:alignment", "wrapText", "true");
+}
+
CPPUNIT_TEST_FIXTURE(ScExportTest, testFormulaRefSheetNameODS)
{
createScDoc("ods/formula-quote-in-sheet-name.ods");
diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx
index 191dab1822d9..f7f24c17d223 100644
--- a/sc/source/filter/excel/xestyle.cxx
+++ b/sc/source/filter/excel/xestyle.cxx
@@ -1507,7 +1507,7 @@ bool XclExpCellAlign::FillFromItemSet(const XclRoot& rRoot, const SfxItemSet& rI
case EXC_BIFF3: // attributes new in BIFF3
{
// text wrap
- mbLineBreak = bForceLineBreak || rItemSet.Get( ATTR_LINEBREAK ).GetValue();
+ mbLineBreak = bForceLineBreak;
bUsed |= bForceLineBreak || ScfTools::CheckItem( rItemSet, ATTR_LINEBREAK, bStyle );
[[fallthrough]];
diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx
index 022da6cd754f..f7b9a81be9f0 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -745,7 +745,7 @@ void XclExpLabelCell::Init( const XclExpRoot& rRoot,
if( GetXFId() == EXC_XFID_NOTFOUND )
{
OSL_ENSURE( nXclFont != EXC_FONT_NOTFOUND, "XclExpLabelCell::Init - leading font not found" );
- bool bForceLineBreak = mxText->IsWrapped();
+ bool bForceLineBreak = pPattern->GetItemSet().Get(ATTR_LINEBREAK ).GetValue();
SetXFId( rRoot.GetXFBuffer().InsertWithFont( pPattern, ApiScriptType::WEAK, nXclFont, bForceLineBreak ) );
}