[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/source

Kohei Yoshida kohei.yoshida at gmail.com
Fri Aug 9 09:09:51 PDT 2013


 sc/source/filter/excel/xetable.cxx   |   39 +++++++++++++++++------------------
 sc/source/filter/excel/xlformula.cxx |    7 ------
 sc/source/filter/inc/xetable.hxx     |    3 --
 sc/source/filter/inc/xlformula.hxx   |    8 -------
 4 files changed, 21 insertions(+), 36 deletions(-)

New commits:
commit c31f2b862804f057adeb055a5bb069dced03eaae
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Aug 9 12:09:44 2013 -0400

    Export shared formulas to xls, from the new shared formula in the core.
    
    Turns out we don't export shared formulas to xlsx, so no work is needed
    there.
    
    Change-Id: I85604f3b80c95c5b6179bbdac41e758c5de7854a

diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx
index 99313ea..d7b6499 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -207,28 +207,29 @@ XclExpShrfmlaBuffer::XclExpShrfmlaBuffer( const XclExpRoot& rRoot ) :
 }
 
 XclExpShrfmlaRef XclExpShrfmlaBuffer::CreateOrExtendShrfmla(
-        const ScTokenArray& rScTokArr, const ScAddress& rScPos )
+    const ScFormulaCell& rScCell, const ScAddress& rScPos )
 {
     XclExpShrfmlaRef xRec;
-    if( const ScTokenArray* pShrdScTokArr = XclTokenArrayHelper::GetSharedFormula( GetRoot(), rScTokArr ) )
+    const ScTokenArray* pShrdScTokArr = rScCell.GetSharedCode();
+    if (!pShrdScTokArr)
+        // This formula cell is not shared formula cell.
+        return xRec;
+
+    XclExpShrfmlaMap::iterator aIt = maRecMap.find( pShrdScTokArr );
+    if( aIt == maRecMap.end() )
     {
-        XclExpShrfmlaMap::iterator aIt = maRecMap.find( pShrdScTokArr );
-        if( aIt == maRecMap.end() )
-        {
-            // create a new record
-            XclTokenArrayRef xTokArr = GetFormulaCompiler().CreateFormula( EXC_FMLATYPE_SHARED, *pShrdScTokArr, &rScPos );
-            xRec.reset( new XclExpShrfmla( xTokArr, rScPos ) );
-            maRecMap[ pShrdScTokArr ] = xRec;
-        }
-        else
-        {
-            // extend existing record
-            OSL_ENSURE( aIt->second, "XclExpShrfmlaBuffer::CreateOrExtendShrfmla - missing record" );
-            xRec = aIt->second;
-            xRec->ExtendRange( rScPos );
-        }
+        // create a new record
+        XclTokenArrayRef xTokArr = GetFormulaCompiler().CreateFormula( EXC_FMLATYPE_SHARED, *pShrdScTokArr, &rScPos );
+        xRec.reset( new XclExpShrfmla( xTokArr, rScPos ) );
+        maRecMap[ pShrdScTokArr ] = xRec;
+    }
+    else
+    {
+        // extend existing record
+        OSL_ENSURE( aIt->second, "XclExpShrfmlaBuffer::CreateOrExtendShrfmla - missing record" );
+        xRec = aIt->second;
+        xRec->ExtendRange( rScPos );
     }
-    return xRec;
 }
 
 // Multiple operations ========================================================
@@ -851,7 +852,7 @@ XclExpFormulaCell::XclExpFormulaCell(
 
     // no matrix found - try to create shared formula
     if( !mxAddRec )
-        mxAddRec = rShrfmlaBfr.CreateOrExtendShrfmla( rScTokArr, aScPos );
+        mxAddRec = rShrfmlaBfr.CreateOrExtendShrfmla(mrScFmlaCell, aScPos);
 
     // no shared formula found - create a simple cell formula
     if( !mxAddRec )
diff --git a/sc/source/filter/excel/xlformula.cxx b/sc/source/filter/excel/xlformula.cxx
index 2eff911..fa2bb20 100644
--- a/sc/source/filter/excel/xlformula.cxx
+++ b/sc/source/filter/excel/xlformula.cxx
@@ -763,13 +763,6 @@ void XclTokenArrayHelper::ConvertStringToList( ScTokenArray& rScTokArr, sal_Unic
     }
 }
 
-// shared formulas ------------------------------------------------------------
-
-const ScTokenArray* XclTokenArrayHelper::GetSharedFormula( const XclRoot& /*rRoot*/, const ScTokenArray& /*rScTokArr*/ )
-{
-    return NULL;
-}
-
 // multiple operations --------------------------------------------------------
 
 namespace {
diff --git a/sc/source/filter/inc/xetable.hxx b/sc/source/filter/inc/xetable.hxx
index 533d2ec..0e47052 100644
--- a/sc/source/filter/inc/xetable.hxx
+++ b/sc/source/filter/inc/xetable.hxx
@@ -189,8 +189,7 @@ public:
             function updates its cell range to include the passed cell position,
             if there is a SHRFMLA record for the passed token array; otherwise
             this function creates and returns a new SHRFMLA record. */
-    XclExpShrfmlaRef    CreateOrExtendShrfmla(
-                            const ScTokenArray& rScTokArr, const ScAddress& rScPos );
+    XclExpShrfmlaRef CreateOrExtendShrfmla( const ScFormulaCell& rScCell, const ScAddress& rScPos );
 
 private:
     typedef ::std::map< const ScTokenArray*, XclExpShrfmlaRef > XclExpShrfmlaMap;
diff --git a/sc/source/filter/inc/xlformula.hxx b/sc/source/filter/inc/xlformula.hxx
index fdf395e..0a90e08 100644
--- a/sc/source/filter/inc/xlformula.hxx
+++ b/sc/source/filter/inc/xlformula.hxx
@@ -523,14 +523,6 @@ public:
         @param bTrimLeadingSpaces  true = remove leading spaces from each token. */
     static void         ConvertStringToList( ScTokenArray& rScTokArr, sal_Unicode cStringSep, bool bTrimLeadingSpaces );
 
-    // shared formulas --------------------------------------------------------
-
-    /** Tries to extract the definition of a shared formula from the passed token array.
-        @descr  Shared formulas are stored as hidden defined names in Calc. This
-        function looks if the passed token array consists of the reference to
-        such a hidden defined name and returns its definition on success. */
-    static const ScTokenArray* GetSharedFormula( const XclRoot& rRoot, const ScTokenArray& rScTokArr );
-
     // multiple operations ----------------------------------------------------
 
     /** Parses the passed formula and tries to extract references of a multiple operation.


More information about the Libreoffice-commits mailing list