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

New commits:
commit ae730bdc0a2ee3d78ff3e0a9b47c8383840af4ee
Author:     Paris Oplopoios <[email protected]>
AuthorDate: Wed Aug 23 12:31:15 2023 +0300
Commit:     Paris Oplopoios <[email protected]>
CommitDate: Mon Aug 28 15:20:40 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 <[email protected]>
    (cherry picked from commit 5e8b2f0a084153ebab3355641b0aca06369baeff)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156140
    Tested-by: Jenkins CollaboraOffice <[email protected]>

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 02e7c8e28c5c..1d4285346f61 100644
--- a/sc/qa/unit/subsequent_export_test.cxx
+++ b/sc/qa/unit/subsequent_export_test.cxx
@@ -98,6 +98,7 @@ public:
     void testBuiltinRangesXLSX();
     void testRichTextExportODS();
     void testRichTextCellFormatXLSX();
+    void testWrapText();
     void testFormulaRefSheetNameODS();
 
     void testCellValuesExportODS();
@@ -219,6 +220,7 @@ public:
     CPPUNIT_TEST(testBuiltinRangesXLSX);
     CPPUNIT_TEST(testRichTextExportODS);
     CPPUNIT_TEST(testRichTextCellFormatXLSX);
+    CPPUNIT_TEST(testWrapText);
     CPPUNIT_TEST(testFormulaRefSheetNameODS);
     CPPUNIT_TEST(testCellValuesExportODS);
     CPPUNIT_TEST(testCellNoteExportODS);
@@ -2052,6 +2054,26 @@ void ScExportTest::testRichTextCellFormatXLSX()
     assertXPath(pStyles, aXPath3, "val", "true");
 }
 
+void 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");
+}
+
 void 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 fb580dd2e713..2a3d12d89938 100644
--- a/sc/source/filter/excel/xestyle.cxx
+++ b/sc/source/filter/excel/xestyle.cxx
@@ -1508,7 +1508,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 e7abb111c63e..cb8a3d65d12f 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