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 e069c7fcff114fd42eda5712fb38938eb17214a9 Author: Henry Castro <hcas...@collabora.com> AuthorDate: Tue Feb 28 09:50:28 2023 -0400 Commit: Henry Castro <hcas...@collabora.com> CommitDate: Wed May 10 22:56:04 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/+/151430 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/sc/source/filter/excel/xihelper.cxx b/sc/source/filter/excel/xihelper.cxx index ef38c5b65089..30436be24be2 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 014b0fc61ae3..422220968812 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 a50f46d8662a..d62e7f14b283 100644 --- a/sc/source/filter/oox/worksheethelper.cxx +++ b/sc/source/filter/oox/worksheethelper.cxx @@ -1591,12 +1591,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 )