summaryrefslogtreecommitdiff
path: root/sc/source/filter
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2020-03-31 01:14:36 +0200
committerEike Rathke <erack@redhat.com>2020-03-31 02:55:44 +0200
commit456f093975ce4e4266eb12b62590eaaba6f2de88 (patch)
treecb951f31682faa1a398ff434192bbfdaad847d1e /sc/source/filter
parent66914f5c15d940831049ddf8434b585652b2cb06 (diff)
Resolves: tdf#131372 Write "error cell" formula to OOXML
Change-Id: Iedbe0912ff28e6203bec0104c59b1102cf97daf9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91382 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins
Diffstat (limited to 'sc/source/filter')
-rw-r--r--sc/source/filter/excel/xestream.cxx21
-rw-r--r--sc/source/filter/excel/xetable.cxx3
-rw-r--r--sc/source/filter/inc/xestream.hxx4
3 files changed, 23 insertions, 5 deletions
diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx
index c22773e1505a..51b11ebaf029 100644
--- a/sc/source/filter/excel/xestream.cxx
+++ b/sc/source/filter/excel/xestream.cxx
@@ -795,15 +795,30 @@ OUString XclXmlUtils::ToOUString( const ScfUInt16Vec& rBuf, sal_Int32 nStart, sa
}
OUString XclXmlUtils::ToOUString(
- sc::CompileFormulaContext& rCtx, const ScAddress& rAddress, const ScTokenArray* pTokenArray )
+ sc::CompileFormulaContext& rCtx, const ScAddress& rAddress, const ScTokenArray* pTokenArray,
+ FormulaError nErrCode )
{
ScCompiler aCompiler( rCtx, rAddress, const_cast<ScTokenArray&>(*pTokenArray));
/* TODO: isn't this the same as passed in rCtx and thus superfluous? */
aCompiler.SetGrammar(FormulaGrammar::GRAM_OOXML);
- OUStringBuffer aBuffer( pTokenArray->GetLen() * 5 );
- aCompiler.CreateStringFromTokenArray( aBuffer );
+ sal_Int32 nLen = pTokenArray->GetLen();
+ OUStringBuffer aBuffer( nLen ? (nLen * 5) : 8 );
+ if (nLen)
+ aCompiler.CreateStringFromTokenArray( aBuffer );
+ else
+ {
+ if (nErrCode != FormulaError::NONE)
+ aCompiler.AppendErrorConstant( aBuffer, nErrCode);
+ else
+ {
+ // No code SHOULD be an "error cell", assert caller thought of that
+ // and it really is.
+ assert(!"No code and no error.");
+ }
+ }
+
return aBuffer.makeStringAndClear();
}
diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx
index 259ed5031c3f..bf2b66808aee 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -1011,7 +1011,8 @@ void XclExpFormulaCell::SaveXml( XclExpXmlStream& rStrm )
(mxAddRec && mxAddRec->IsVolatile()) ) );
}
rWorksheet->writeEscaped( XclXmlUtils::ToOUString(
- rStrm.GetRoot().GetCompileFormulaContext(), mrScFmlaCell.aPos, mrScFmlaCell.GetCode()));
+ rStrm.GetRoot().GetCompileFormulaContext(), mrScFmlaCell.aPos, mrScFmlaCell.GetCode(),
+ mrScFmlaCell.GetErrCode()));
rWorksheet->endElement( XML_f );
}
diff --git a/sc/source/filter/inc/xestream.hxx b/sc/source/filter/inc/xestream.hxx
index 88cf614664b4..3aaebd7ce776 100644
--- a/sc/source/filter/inc/xestream.hxx
+++ b/sc/source/filter/inc/xestream.hxx
@@ -27,6 +27,7 @@
#include <oox/core/xmlfilterbase.hxx>
#include <sax/fshelper.hxx>
#include <tools/stream.hxx>
+#include <formula/errorcodes.hxx>
#include "ftools.hxx"
#include <filter/msfilter/mscodec.hxx>
@@ -262,7 +263,8 @@ public:
static OUString ToOUString( const char* s );
static OUString ToOUString( const ScfUInt16Vec& rBuffer, sal_Int32 nStart = 0, sal_Int32 nLength = -1 );
- static OUString ToOUString( sc::CompileFormulaContext& rCtx, const ScAddress& rAddress, const ScTokenArray* pTokenArray );
+ static OUString ToOUString( sc::CompileFormulaContext& rCtx, const ScAddress& rAddress,
+ const ScTokenArray* pTokenArray, FormulaError nErrCode = FormulaError::NONE );
static OUString ToOUString( const XclExpString& s );
template <class T>