summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/source/filter/inc/unitconverter.hxx3
-rw-r--r--sc/source/filter/oox/sheetdatabuffer.cxx11
-rw-r--r--sc/source/filter/oox/unitconverter.cxx14
3 files changed, 18 insertions, 10 deletions
diff --git a/sc/source/filter/inc/unitconverter.hxx b/sc/source/filter/inc/unitconverter.hxx
index 726a133fbcb7..1f139450ffe0 100644
--- a/sc/source/filter/inc/unitconverter.hxx
+++ b/sc/source/filter/inc/unitconverter.hxx
@@ -86,6 +86,9 @@ public:
/** Returns a BIFF error code from the passed error string. */
sal_uInt8 calcBiffErrorCode( const OUString& rErrorCode ) const;
+ /** Returns an error string from the passed BIFF error code. */
+ const OUString& calcErrorString( sal_uInt8 nErrorCode ) const;
+
private:
/** Adds an error code to the internal maps. */
void addErrorCode( sal_uInt8 nErrorCode, const OUString& rErrorCode );
diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx b/sc/source/filter/oox/sheetdatabuffer.cxx
index 1e66c879864f..45c9fa9356db 100644
--- a/sc/source/filter/oox/sheetdatabuffer.cxx
+++ b/sc/source/filter/oox/sheetdatabuffer.cxx
@@ -204,16 +204,7 @@ void SheetDataBuffer::setErrorCell( const CellModel& rModel, const OUString& rEr
void SheetDataBuffer::setErrorCell( const CellModel& rModel, sal_uInt8 nErrorCode )
{
- assert(!"stringizing any NaN will only give 'nan'");
- /* FIXME: map nErrorCode to error string and call setErrorCell() above. */
-
- OUStringBuffer aBuf;
- aBuf.append('{');
- aBuf.append(BiffHelper::calcDoubleFromError(nErrorCode));
- aBuf.append('}');
-
- getFormulaBuffer().setCellFormula(rModel.maCellAddr, aBuf.makeStringAndClear());
- setCellFormat( rModel );
+ setErrorCell( rModel, getUnitConverter().calcErrorString( nErrorCode));
}
void SheetDataBuffer::setDateCell( const CellModel& rModel, const OUString& rDateString )
diff --git a/sc/source/filter/oox/unitconverter.cxx b/sc/source/filter/oox/unitconverter.cxx
index aca0d5155e54..55f2f4512289 100644
--- a/sc/source/filter/oox/unitconverter.cxx
+++ b/sc/source/filter/oox/unitconverter.cxx
@@ -218,6 +218,20 @@ sal_uInt8 UnitConverter::calcBiffErrorCode( const OUString& rErrorCode ) const
return (aIt == maOoxErrCodes.end()) ? BIFF_ERR_NA : aIt->second;
}
+const OUString& UnitConverter::calcErrorString( sal_uInt8 nErrorCode ) const
+{
+ OoxErrorCodeMap::const_iterator iFail( maOoxErrCodes.end());
+ for (OoxErrorCodeMap::const_iterator aIt( maOoxErrCodes.begin()); aIt != maOoxErrCodes.end(); ++aIt)
+ {
+ if (aIt->second == nErrorCode)
+ return aIt->first;
+ if (aIt->second == BIFF_ERR_NA)
+ iFail = aIt;
+ }
+ assert(iFail != maOoxErrCodes.end()); // BIFF_ERR_NA really should be in the map..
+ return iFail->first;
+}
+
void UnitConverter::addErrorCode( sal_uInt8 nErrorCode, const OUString& rErrorCode )
{
maOoxErrCodes[ rErrorCode ] = nErrorCode;