Kaydet (Commit) ca9a81b2 authored tarafından Eike Rathke's avatar Eike Rathke

implement an actually working setErrorCell() from BIFF error codes

Not that we're currently using that, but..

Change-Id: I67b8fc324779875ba14e2d69204c40fe27cc180e
üst 90a8be80
...@@ -86,6 +86,9 @@ public: ...@@ -86,6 +86,9 @@ public:
/** Returns a BIFF error code from the passed error string. */ /** Returns a BIFF error code from the passed error string. */
sal_uInt8 calcBiffErrorCode( const OUString& rErrorCode ) const; 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: private:
/** Adds an error code to the internal maps. */ /** Adds an error code to the internal maps. */
void addErrorCode( sal_uInt8 nErrorCode, const OUString& rErrorCode ); void addErrorCode( sal_uInt8 nErrorCode, const OUString& rErrorCode );
......
...@@ -204,16 +204,7 @@ void SheetDataBuffer::setErrorCell( const CellModel& rModel, const OUString& rEr ...@@ -204,16 +204,7 @@ void SheetDataBuffer::setErrorCell( const CellModel& rModel, const OUString& rEr
void SheetDataBuffer::setErrorCell( const CellModel& rModel, sal_uInt8 nErrorCode ) void SheetDataBuffer::setErrorCell( const CellModel& rModel, sal_uInt8 nErrorCode )
{ {
assert(!"stringizing any NaN will only give 'nan'"); setErrorCell( rModel, getUnitConverter().calcErrorString( nErrorCode));
/* 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 );
} }
void SheetDataBuffer::setDateCell( const CellModel& rModel, const OUString& rDateString ) void SheetDataBuffer::setDateCell( const CellModel& rModel, const OUString& rDateString )
......
...@@ -218,6 +218,20 @@ sal_uInt8 UnitConverter::calcBiffErrorCode( const OUString& rErrorCode ) const ...@@ -218,6 +218,20 @@ sal_uInt8 UnitConverter::calcBiffErrorCode( const OUString& rErrorCode ) const
return (aIt == maOoxErrCodes.end()) ? BIFF_ERR_NA : aIt->second; 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 ) void UnitConverter::addErrorCode( sal_uInt8 nErrorCode, const OUString& rErrorCode )
{ {
maOoxErrCodes[ rErrorCode ] = nErrorCode; maOoxErrCodes[ rErrorCode ] = nErrorCode;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment