From a0752fa4246dc71b64907c679657a1af3cb617e1 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 --- 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 3e155173cdc6..804088dcfcf6 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 @@ -268,4 +269,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 4ec1be58a976..ff0b41950dcd 100644 --- a/sc/source/filter/xml/XMLExportIterator.cxx +++ b/sc/source/filter/xml/XMLExportIterator.cxx @@ -641,10 +641,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 0275dd37f7fa..e2180e9873e8 100644 --- a/sc/source/filter/xml/XMLExportIterator.hxx +++ b/sc/source/filter/xml/XMLExportIterator.hxx @@ -278,6 +278,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; @@ -336,7 +338,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 89badd5c01e7..2603d0585d94 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -67,6 +67,7 @@ #include #include #include +#include #include #include @@ -3287,8 +3288,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 v1.2.3