diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-08-09 12:09:44 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-08-12 19:46:28 -0400 |
commit | a592b81558c41e71c0f139d86489b163148ea8b7 (patch) | |
tree | a5e804c6964352acdf1f75cd9879ab5035a514bf /sc | |
parent | b26fd34f8aa9589dd66a8f4c5b0e6771a4529c03 (diff) |
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
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/filter/excel/xetable.cxx | 39 | ||||
-rw-r--r-- | sc/source/filter/excel/xlformula.cxx | 7 | ||||
-rw-r--r-- | sc/source/filter/inc/xetable.hxx | 3 | ||||
-rw-r--r-- | sc/source/filter/inc/xlformula.hxx | 8 |
4 files changed, 21 insertions, 36 deletions
diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx index 99313ead7c35..d7b6499c4319 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 2eff9115f905..fa2bb209d8db 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 533d2ec80e68..0e470527a81e 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 fdf395e7e229..0a90e085dbcc 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. |