From a112251d748ab74c5254e7e0ad1c8f3fb3d67b70 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Thu, 7 Feb 2013 23:12:55 -0500 Subject: Import multi-line content into ScEditCell. Change-Id: I4fc53ddb888ff31a78dc233dd487f0e70daa6522 --- sc/source/filter/xml/xmlcelli.cxx | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index 2272e988862d..abe8353f8cfa 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -676,6 +676,27 @@ void ScXMLTableRowCellContext::SetFormulaCell(ScFormulaCell* pFCell) const } } +namespace { + +ScBaseCell* createEditCell(ScDocument* pDoc, const std::vector& rParagraphs) +{ + // Create edit cell. + OUStringBuffer aBuf; + std::vector::const_iterator it = rParagraphs.begin(), itEnd = rParagraphs.end(); + bool bFirst = true; + for (; it != itEnd; ++it) + { + if (bFirst) + bFirst = false; + else + aBuf.append('\n'); + aBuf.append(*it); + } + return ScBaseCell::CreateTextCell(aBuf.makeStringAndClear(), pDoc); +} + +} + void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos, const SCCOL nCurrentCol, const ::boost::optional< rtl::OUString >& pOUText ) { @@ -728,7 +749,7 @@ void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos, if (maStringValue) pNewCell = ScBaseCell::CreateTextCell( *maStringValue, pDoc ); else if (!maParagraphs.empty()) - pNewCell = ScBaseCell::CreateTextCell(maParagraphs.back(), pDoc); + pNewCell = createEditCell(pDoc, maParagraphs); else if ( nCurrentCol > 0 && pOUText && !pOUText->isEmpty() ) pNewCell = ScBaseCell::CreateTextCell( *pOUText, pDoc ); -- cgit