sc/source/filter/excel/xihelper.cxx      |    6 ++++++
 sc/source/filter/inc/worksheethelper.hxx |    4 +++-
 sc/source/filter/oox/sheetdatabuffer.cxx |    4 +++-
 sc/source/filter/oox/worksheethelper.cxx |    6 +++++-
 4 files changed, 17 insertions(+), 3 deletions(-)

New commits:
commit 845a359609fccfa2d5b5d7e57f504074aafd3caf
Author:     Henry Castro <hcas...@collabora.com>
AuthorDate: Tue Feb 28 09:50:28 2023 -0400
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri Jun 23 22:00:01 2023 +0200

    sc: filter: excel: import cell multi-line text
    
    The excel document, if the cell has multi-line text and
    the property wrap text is off, the paragraphs are rendered
    all in a single line.
    
    Signed-off-by: Henry Castro <hcas...@collabora.com>
    Change-Id: I3b5c82dde2616887e51ad6e3dfe91d100482f747
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148004
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153470
    Tested-by: Jenkins
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153489

diff --git a/sc/source/filter/excel/xihelper.cxx 
b/sc/source/filter/excel/xihelper.cxx
index 3552e8d65f1b..e095d22018ac 100644
--- a/sc/source/filter/excel/xihelper.cxx
+++ b/sc/source/filter/excel/xihelper.cxx
@@ -238,10 +238,16 @@ void XclImpStringHelper::SetToDocument(
         const OUString& aStr = rString.GetText();
         if (aStr.indexOf('\n') != -1 || aStr.indexOf('\r') != -1)
         {
+            const XclImpXFBuffer& rXFBuffer = rRoot.GetXFBuffer();
+            const XclImpXF* pXF = rXFBuffer.GetXF( nXFIndex );
+            bool bSingleLine = pXF ? !pXF->GetLineBreak() : false;
+
             // Multiline content.
             ScFieldEditEngine& rEngine = rDoc.getDoc().GetEditEngine();
+            rEngine.SetSingleLine(bSingleLine);
             rEngine.SetTextCurrentDefaults(aStr);
             rDoc.setEditCell(rPos, rEngine.CreateTextObject());
+            rEngine.SetSingleLine(false);
         }
         else
         {
diff --git a/sc/source/filter/inc/worksheethelper.hxx 
b/sc/source/filter/inc/worksheethelper.hxx
index 3a44dc2e105e..4081d248e32b 100644
--- a/sc/source/filter/inc/worksheethelper.hxx
+++ b/sc/source/filter/inc/worksheethelper.hxx
@@ -262,7 +262,9 @@ public:
     /** Inserts a rich-string cell directly into the Calc sheet. */
     void putRichString(
         const ScAddress& rAddress,
-        RichString& rString, const oox::xls::Font* pFirstPortionFont );
+        RichString& rString,
+        const oox::xls::Font* pFirstPortionFont,
+        bool bSingleLine = false);
 
     /** Inserts a formula cell directly into the Calc sheet. */
     void putFormulaTokens(
diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx 
b/sc/source/filter/oox/sheetdatabuffer.cxx
index 5632d8356353..7c7e9a06d221 100644
--- a/sc/source/filter/oox/sheetdatabuffer.cxx
+++ b/sc/source/filter/oox/sheetdatabuffer.cxx
@@ -120,6 +120,8 @@ void SheetDataBuffer::setStringCell( const CellModel& 
rModel, const RichStringRe
 {
     OSL_ENSURE( rxString, "SheetDataBuffer::setStringCell - missing rich 
string object" );
     const oox::xls::Font* pFirstPortionFont = getStyles().getFontFromCellXf( 
rModel.mnXfId ).get();
+    const Xf* pXf = getStyles().getCellXf( rModel.mnXfId ).get();
+    bool bSingleLine = pXf ? !rxString->isPreserveSpace() && 
!pXf->getAlignment().getModel().mbWrapText : false;
     OUString aText;
     if( rxString->extractPlainString( aText, pFirstPortionFont ) )
     {
@@ -127,7 +129,7 @@ void SheetDataBuffer::setStringCell( const CellModel& 
rModel, const RichStringRe
     }
     else
     {
-        putRichString( rModel.maCellAddr, *rxString, pFirstPortionFont );
+        putRichString( rModel.maCellAddr, *rxString, pFirstPortionFont, 
bSingleLine );
         setCellFormat( rModel );
     }
 }
diff --git a/sc/source/filter/oox/worksheethelper.cxx 
b/sc/source/filter/oox/worksheethelper.cxx
index 6ea756f884ce..e34f5a47d190 100644
--- a/sc/source/filter/oox/worksheethelper.cxx
+++ b/sc/source/filter/oox/worksheethelper.cxx
@@ -1596,12 +1596,16 @@ void WorksheetHelper::setCellFormulaValue(
     getFormulaBuffer().setCellFormulaValue(rAddress, rValueStr, nCellType);
 }
 
-void WorksheetHelper::putRichString( const ScAddress& rAddress, RichString& 
rString, const oox::xls::Font* pFirstPortionFont )
+void WorksheetHelper::putRichString( const ScAddress& rAddress, RichString& 
rString, const oox::xls::Font* pFirstPortionFont, bool bSingleLine )
 {
     ScEditEngineDefaulter& rEE = getEditEngine();
 
+    rEE.SetSingleLine(bSingleLine);
+
     // The cell will own the text object instance returned from convert().
     getDocImport().setEditCell(rAddress, rString.convert(rEE, 
pFirstPortionFont));
+
+    rEE.SetSingleLine(false);
 }
 
 void WorksheetHelper::putFormulaTokens( const ScAddress& rAddress, const 
ApiTokenSequence& rTokens )

Reply via email to