From eec62f3d823048c9b3b767cb7de72650a40b73cd Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Tue, 15 Apr 2014 10:12:58 -0400 Subject: fdo#76409: Write output cell string to element when saving to ods. The change was made by accident. Change-Id: Ife2461b0fca6e3ea5a65d72d985d1e0976737b5a (cherry picked from commit a0752fa4246dc71b64907c679657a1af3cb617e1) Reviewed-on: https://gerrit.libreoffice.org/9014 Tested-by: Markus Mohrhard Reviewed-by: Markus Mohrhard --- sc/inc/cellform.hxx | 3 +++ sc/source/core/tool/cellform.cxx | 32 ++++++++++++++++++++++++++++++ sc/source/filter/xml/XMLExportIterator.cxx | 3 ++- sc/source/filter/xml/XMLExportIterator.hxx | 4 +++- sc/source/filter/xml/xmlexprt.cxx | 9 +++++++-- 5 files changed, 47 insertions(+), 4 deletions(-) diff --git a/sc/inc/cellform.hxx b/sc/inc/cellform.hxx index 1f6b13a9254a..caea246ca2c3 100644 --- a/sc/inc/cellform.hxx +++ b/sc/inc/cellform.hxx @@ -54,6 +54,9 @@ public: static void GetInputString( ScRefCellValue& rCell, sal_uLong nFormat, OUString& rString, SvNumberFormatter& rFormatter, const ScDocument* pDoc ); + + static OUString GetOutputString( + ScDocument& rDoc, const ScAddress& rPos, ScRefCellValue& rCell ); }; #endif diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx index 6a23ba238f05..d96430af0f7e 100644 --- a/sc/source/core/tool/cellform.cxx +++ b/sc/source/core/tool/cellform.cxx @@ -29,6 +29,7 @@ #include "cellvalue.hxx" #include "formula/errorcodes.hxx" #include "sc.hrc" +#include // STATIC DATA // Err527 Workaround @@ -266,4 +267,35 @@ void ScCellFormat::GetInputString( rString = aString; } +OUString ScCellFormat::GetOutputString( ScDocument& rDoc, const ScAddress& rPos, ScRefCellValue& rCell ) +{ + if (rCell.isEmpty()) + return EMPTY_OUSTRING; + + OUString aVal; + + if (rCell.meType == CELLTYPE_EDIT) + { + // GetString an der EditCell macht Leerzeichen aus Umbruechen, + // hier werden die Umbrueche aber gebraucht + const EditTextObject* pData = rCell.mpEditText; + if (pData) + { + ScFieldEditEngine& rEngine = rDoc.GetEditEngine(); + rEngine.SetText(*pData); + aVal = rEngine.GetText(LINEEND_LF); + } + // Edit-Zellen auch nicht per NumberFormatter formatieren + // (passend zur Ausgabe) + } + else + { + // wie in GetString am Dokument (column) + Color* pColor; + sal_uLong nNumFmt = rDoc.GetNumberFormat(rPos); + aVal = GetString(rDoc, rPos, nNumFmt, &pColor, *rDoc.GetFormatTable()); + } + return aVal; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/filter/xml/XMLExportIterator.cxx b/sc/source/filter/xml/XMLExportIterator.cxx index afc05fdad835..57d03c4c6ba9 100644 --- a/sc/source/filter/xml/XMLExportIterator.cxx +++ b/sc/source/filter/xml/XMLExportIterator.cxx @@ -657,10 +657,11 @@ void ScMyNotEmptyCellsIterator::UpdateAddress( table::CellAddress& rAddress ) } } -void ScMyNotEmptyCellsIterator::SetCellData( ScMyCell& rMyCell, table::CellAddress& rAddress ) +void ScMyNotEmptyCellsIterator::SetCellData( ScMyCell& rMyCell, const table::CellAddress& rAddress ) { rMyCell.maBaseCell.clear(); rMyCell.aCellAddress = rAddress; + ScUnoConversion::FillScAddress(rMyCell.maCellAddress, rMyCell.aCellAddress); if( (nCellCol == rAddress.Column) && (nCellRow == rAddress.Row) ) { diff --git a/sc/source/filter/xml/XMLExportIterator.hxx b/sc/source/filter/xml/XMLExportIterator.hxx index 857f98c9f118..71d4b5840e08 100644 --- a/sc/source/filter/xml/XMLExportIterator.hxx +++ b/sc/source/filter/xml/XMLExportIterator.hxx @@ -294,6 +294,8 @@ public: // contains data to export for the current cell position struct ScMyCell { + ScAddress maCellAddress; /// Use this instead of the UNO one. + com::sun::star::table::CellAddress aCellAddress; com::sun::star::table::CellRangeAddress aMergeRange; com::sun::star::table::CellRangeAddress aMatrixRange; @@ -355,7 +357,7 @@ class ScMyNotEmptyCellsIterator : boost::noncopyable SCTAB nCurrentTable; void UpdateAddress( ::com::sun::star::table::CellAddress& rAddress ); - void SetCellData( ScMyCell& rMyCell, ::com::sun::star::table::CellAddress& rAddress ); + void SetCellData( ScMyCell& rMyCell, const css::table::CellAddress& rAddress ); void HasAnnotation( ScMyCell& aCell ); public: diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index c2ab4b2216b7..0f157a1c6a00 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -64,6 +64,7 @@ #include #include #include +#include #include #include @@ -3280,8 +3281,12 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount) else { SvXMLElementExport aElemP(*this, sElemP, true, false); - bool bPrevCharWasSpace(true); - GetTextParagraphExport()->exportText(aCell.maBaseCell.getString(pDoc), bPrevCharWasSpace); + + OUString aParaStr = + ScCellFormat::GetOutputString(*pDoc, aCell.maCellAddress, aCell.maBaseCell); + + bool bPrevCharWasSpace = true; + GetTextParagraphExport()->exportText(aParaStr, bPrevCharWasSpace); } } WriteShapes(aCell); -- cgit