sc/qa/unit/data/xlsx/wrap-text.xlsx   |binary
 sc/qa/unit/subsequent_export_test.cxx |   20 ++++++++++++++++++++
 sc/source/filter/excel/xestyle.cxx    |    2 +-
 sc/source/filter/excel/xetable.cxx    |    2 +-
 4 files changed, 22 insertions(+), 2 deletions(-)

New commits:
commit 1760ee4d328cfb6ba22a5b3c84016625b12adb25
Author:     Paris Oplopoios <paris.oplopo...@collabora.com>
AuthorDate: Wed Aug 23 12:31:15 2023 +0300
Commit:     Paris Oplopoios <parisop...@gmail.com>
CommitDate: Mon Aug 28 10:27:37 2023 +0200

    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 <parisop...@gmail.com>

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
Binary files /dev/null and b/sc/qa/unit/data/xlsx/wrap-text.xlsx 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 ) );
     }
 

Reply via email to