[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - sc/source

Eike Rathke erack at redhat.com
Wed Jan 7 03:42:46 PST 2015


 sc/source/core/data/formulacell.cxx      |    2 +-
 sc/source/filter/inc/unitconverter.hxx   |    3 +++
 sc/source/filter/oox/sheetdatabuffer.cxx |   12 ++++--------
 sc/source/filter/oox/unitconverter.cxx   |   16 +++++++++++++++-
 4 files changed, 23 insertions(+), 10 deletions(-)

New commits:
commit 11724301fb690cbd58581e468f3cd80e7becc07d
Author: Eike Rathke <erack at redhat.com>
Date:   Tue Dec 16 01:37:31 2014 +0100

    fdo#79249 call formula compiler with error string
    
    ... instead of attempting to stringize a NaN coded error value.
    
    Regression introduced with 30a20743ae17e6e02183a65603d38968253b3ffb
    
    (cherry picked from commit 994607b55104b9ae4554554c13b001b8d5d513b6)
    
    construct grouped ScFormulaCell with bDirty=true, fdo#79249 related
    
    Noticed when loading
    https://bugs.freedesktop.org/attachment.cgi?id=99844
    with fdo#79249 fix where oox::xls::applyCellFormulas() groups the
    consecutive =#N/A formulas. Only A1 result was displayed, other cells
    were displayed empty.
    
    (cherry picked from commit a1dc5e97da273bf35d58d54e625149022569a993)
    
    correct error string, #N/A instead of #NA
    
    (cherry picked from commit 758755e31b3d9e1ed2eab522d4794282178346ac)
    
    implement an actually working setErrorCell() from BIFF error codes
    
    (cherry picked from commit ca9a81b2ca858b82e863e1e6f917928916fea79e)
    
    Change-Id: Ia7a8ca39938820ac75db169404446fa696c6ee1b
    3a541f74d3d25e1515a1c6d47f02ec6a8e817c93
    15019072b6e812b9ffe29d3ee6afacd9ab526948
    67b8fc324779875ba14e2d69204c40fe27cc180e
    Reviewed-on: https://gerrit.libreoffice.org/13490
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
    Tested-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index db3ccb2..48e6760 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -687,7 +687,7 @@ ScFormulaCell::ScFormulaCell(
     nSeenInIteration(0),
     cMatrixFlag ( cInd ),
     nFormatType(xGroup->mnFormatType),
-    bDirty(false),
+    bDirty(true),
     bChanged( false ),
     bRunning( false ),
     bCompile( false ),
diff --git a/sc/source/filter/inc/unitconverter.hxx b/sc/source/filter/inc/unitconverter.hxx
index 726a133..1f13945 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 434c07c..68b39db 100644
--- a/sc/source/filter/oox/sheetdatabuffer.cxx
+++ b/sc/source/filter/oox/sheetdatabuffer.cxx
@@ -197,18 +197,14 @@ void SheetDataBuffer::setBooleanCell( const CellModel& rModel, bool bValue )
 
 void SheetDataBuffer::setErrorCell( const CellModel& rModel, const OUString& rErrorCode )
 {
-    setErrorCell( rModel, getUnitConverter().calcBiffErrorCode( rErrorCode ) );
+    // Using the formula compiler now we can simply pass on the error string.
+    getFormulaBuffer().setCellFormula( rModel.maCellAddr, rErrorCode);
+    setCellFormat( rModel );
 }
 
 void SheetDataBuffer::setErrorCell( const CellModel& rModel, sal_uInt8 nErrorCode )
 {
-    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 dd6f555..87c59c27 100644
--- a/sc/source/filter/oox/unitconverter.cxx
+++ b/sc/source/filter/oox/unitconverter.cxx
@@ -112,7 +112,7 @@ UnitConverter::UnitConverter( const WorkbookHelper& rHelper ) :
     addErrorCode( BIFF_ERR_REF,   "#REF!" );
     addErrorCode( BIFF_ERR_NAME,  "#NAME?" );
     addErrorCode( BIFF_ERR_NUM,   "#NUM!" );
-    addErrorCode( BIFF_ERR_NA,    "#NA" );
+    addErrorCode( BIFF_ERR_NA,    "#N/A" );
 }
 
 void UnitConverter::finalizeImport()
@@ -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;


More information about the Libreoffice-commits mailing list