formula/source/core/api/FormulaCompiler.cxx | 11 --- formula/source/core/api/token.cxx | 73 +++++++++++++++++++------ formula/source/core/resource/core_resource.src | 2 include/formula/tokenarray.hxx | 16 +++++ 4 files changed, 72 insertions(+), 30 deletions(-)
New commits: commit fc305bb6d656736bedc2f89789e18d8c9a3bbf2c Author: Eike Rathke <er...@redhat.com> Date: Thu Jul 14 23:16:41 2016 +0200 strip second parameter from ISOWEEKNUM if literal double != 1.0 For other arguments convert to WEEKNUM_OOO, which now can be saved as ORG.LIBREOFFICE.WEEKNUM_OOO. Change-Id: I63fd3df1ec4ccaa535a1437200854d8734544a2c diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index 1379cba..3143525 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -1412,12 +1412,6 @@ void FormulaCompiler::Factor() pFacToken->SetByte( nSepCount ); if (nSepCount == 2) { - /* XXX TODO FIXME: activate this conversion to ISOWEEKNUM - * when at least two releases can actually handle the real - * ISOWEEKNUM with one parameter, i.e. for 5.3 or 5.2 if - * 5.0.5 is patched. Until then unconditionally use the - * WEEKNUM_OOO compatibility function. */ -#if 0 // An old mode!=1 indicates ISO week, remove argument if // literal double value and keep function. Anything else // can not be resolved, there exists no "like ISO but week @@ -1440,11 +1434,6 @@ void FormulaCompiler::Factor() // compatibility function. pFacToken->NewOpCode( ocWeeknumOOo, FormulaToken::PrivateAccess()); } -#else - (void) nSepPos; - // Use compatibility function. - pFacToken->NewOpCode( ocWeeknumOOo, FormulaToken::PrivateAccess()); -#endif } PutCode( pFacToken ); } commit 77ccf8a9ca527ff261218208c1b838922001ce9b Author: Eike Rathke <er...@redhat.com> Date: Thu Jul 14 23:13:18 2016 +0200 store WEEKNUM_OOO as ORG.LIBREOFFICE.WEEKNUM_OOO Now that the previous two releases can read it. Change-Id: Ie04c7b0fd94f5906b678d738370e4fc0696da79c diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx index 072216b..f8d7a9d 100644 --- a/formula/source/core/api/token.cxx +++ b/formula/source/core/api/token.cxx @@ -1066,7 +1066,6 @@ inline bool MissingConventionODF::isRewriteNeeded( OpCode eOp ) const case ocAddress: case ocLogNormDist: case ocNormDist: - case ocWeeknumOOo: return true; case ocMissing: case ocLog: @@ -1514,22 +1513,6 @@ FormulaTokenArray * FormulaTokenArray::RewriteMissing( const MissingConvention & ( pCur->GetOpCode() == ocCeil ? ocCeil_Math : ocFloor_Math ) ); pNewArr->Add( pToken ); } - else if (pCur->GetOpCode() == ocWeeknumOOo && - rConv.getConvention() == MissingConvention::FORMULA_MISSING_CONVENTION_ODFF) - { - /* XXX TODO FIXME: Remove this special handling (also - * ocWeeknumOOo in MissingConventionODF::isRewriteNeeded() - * above) in 5.3 or later, this still abuses the ODFF - * ISOWEEKNUM function to store the old WEEKNUM (now - * WEEKNUM_OOO) cases that can't be mapped to the new WEEKNUM - * or ISOWEEKNUM, as 5.0 and earlier always stored the old - * WEEKNUM as ISOWEEKNUM. Ugly nasty ... - * Later write ORG.LIBREOFFICE.WEEKNUM_OOO, see - * formula/source/core/resource/core_resource.src - * SC_OPCODE_WEEKNUM_OOO */ - FormulaToken *pToken = new FormulaByteToken( ocIsoWeeknum, pCur->GetByte(), pCur->IsInForceArray()); - pNewArr->Add( pToken ); - } else pNewArr->AddToken( *pCur ); } diff --git a/formula/source/core/resource/core_resource.src b/formula/source/core/resource/core_resource.src index d32a578..a953db0 100644 --- a/formula/source/core/resource/core_resource.src +++ b/formula/source/core/resource/core_resource.src @@ -405,8 +405,6 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_ODFF String SC_OPCODE_BETA_INV_MS { Text = "COM.MICROSOFT.BETA.INV" ; }; String SC_OPCODE_WEEK { Text = "WEEKNUM" ; }; String SC_OPCODE_ISOWEEKNUM { Text = "ISOWEEKNUM" ; }; - /* WEEKNUM_OOO currently (5.1) not written, see - * formula/source/core/api/token.cxx FormulaTokenArray::RewriteMissing() */ String SC_OPCODE_WEEKNUM_OOO { Text = "ORG.LIBREOFFICE.WEEKNUM_OOO" ; }; String SC_OPCODE_EASTERSUNDAY { Text = "ORG.OPENOFFICE.EASTERSUNDAY" ; }; String SC_OPCODE_GET_DAY_OF_WEEK { Text = "WEEKDAY" ; }; commit 908449639beaeafb04b9a9668ee20b0042389426 Author: Eike Rathke <er...@redhat.com> Date: Thu Jul 14 22:31:14 2016 +0200 let FormulaTokenArray::RemoveToken() return the actual count of tokens removed Change-Id: Iebf654e7b4c682036b4ff334298948557b755eac diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx index 0eb9066..072216b 100644 --- a/formula/source/core/api/token.cxx +++ b/formula/source/core/api/token.cxx @@ -856,7 +856,7 @@ FormulaToken* FormulaTokenArray::ReplaceToken( sal_uInt16 nOffset, FormulaToken* } } -void FormulaTokenArray::RemoveToken( sal_uInt16 nOffset, sal_uInt16 nCount ) +sal_uInt16 FormulaTokenArray::RemoveToken( sal_uInt16 nOffset, sal_uInt16 nCount ) { if (nOffset < nLen) { @@ -903,10 +903,12 @@ void FormulaTokenArray::RemoveToken( sal_uInt16 nOffset, sal_uInt16 nCount ) else nIndex -= nStop - nOffset; } + return nCount; } else { SAL_WARN("formula.core","FormulaTokenArray::RemoveToken - nOffset " << nOffset << " >= nLen " << nLen); + return 0; } } diff --git a/include/formula/tokenarray.hxx b/include/formula/tokenarray.hxx index e7f3231..b1d2deb 100644 --- a/include/formula/tokenarray.hxx +++ b/include/formula/tokenarray.hxx @@ -166,8 +166,10 @@ protected: Start offset into pCode. @param nCount Count of tokens to remove. + + @return Count of tokens removed. */ - void RemoveToken( sal_uInt16 nOffset, sal_uInt16 nCount ); + sal_uInt16 RemoveToken( sal_uInt16 nOffset, sal_uInt16 nCount ); inline void SetCombinedBitsRecalcMode( ScRecalcMode nBits ) { nMode |= (nBits & ~RECALCMODE_EMASK); } commit f9021f7eea06b1e5498534988f95e9cdbb79bc11 Author: Eike Rathke <er...@redhat.com> Date: Thu Jul 14 22:25:59 2016 +0200 re-add FormulaTokenArray::ReplaceToken() that was removed as unused, grml.. with 4ff5a5558472beee85eb1234dcc2aa2ed9000f6c Change-Id: Id99c3ae74515f24c55a3734698c560dcac8bacd9 diff --git a/formula/source/core/api/token.cxx b/formula/source/core/api/token.cxx index 3c3bdc5..0eb9066 100644 --- a/formula/source/core/api/token.cxx +++ b/formula/source/core/api/token.cxx @@ -856,6 +856,60 @@ FormulaToken* FormulaTokenArray::ReplaceToken( sal_uInt16 nOffset, FormulaToken* } } +void FormulaTokenArray::RemoveToken( sal_uInt16 nOffset, sal_uInt16 nCount ) +{ + if (nOffset < nLen) + { + SAL_WARN_IF( nOffset + nCount > nLen, "formula.core", + "FormulaTokenArray::RemoveToken - nOffset " << nOffset << " + nCount " << nCount << " > nLen " << nLen); + const sal_uInt16 nStop = ::std::min( static_cast<sal_uInt16>(nOffset + nCount), nLen); + nCount = nStop - nOffset; + for (sal_uInt16 j = nOffset; j < nStop; ++j) + { + FormulaToken* p = pCode[j]; + if (p->GetRef() > 1) + { + for (sal_uInt16 i=0; i < nRPN; ++i) + { + if (pRPN[i] == p) + { + // Shift remaining tokens in pRPN down. + for (sal_uInt16 x=i+1; x < nRPN; ++x) + { + pRPN[x-1] = pRPN[x]; + } + --nRPN; + + p->DecRef(); + if (p->GetRef() == 1) + break; // for + } + } + } + p->DecRef(); // may be dead now + } + + // Shift remaining tokens in pCode down. + for (sal_uInt16 x = nStop; x < nLen; ++x) + { + pCode[x-nCount] = pCode[x]; + } + nLen -= nCount; + + if (nIndex >= nOffset) + { + if (nIndex < nStop) + nIndex = nOffset + 1; + else + nIndex -= nStop - nOffset; + } + } + else + { + SAL_WARN("formula.core","FormulaTokenArray::RemoveToken - nOffset " << nOffset << " >= nLen " << nLen); + } +} + FormulaToken* FormulaTokenArray::Add( FormulaToken* t ) { if( !pCode ) diff --git a/include/formula/tokenarray.hxx b/include/formula/tokenarray.hxx index 6ba48fe..e7f3231 100644 --- a/include/formula/tokenarray.hxx +++ b/include/formula/tokenarray.hxx @@ -155,6 +155,20 @@ protected: */ FormulaToken* ReplaceToken( sal_uInt16 nOffset, FormulaToken*, ReplaceMode eMode ); + /** Remove a sequence of tokens from pCode array, and pRPN array if the + tokens are referenced there. + + This' nLen and nRPN are adapted, as is nIndex if it points behind + nOffset. If nIndex points into the to be removed range + (nOffset < nIndex < nOffset+nCount) it is set to nOffset+1. + + @param nOffset + Start offset into pCode. + @param nCount + Count of tokens to remove. + */ + void RemoveToken( sal_uInt16 nOffset, sal_uInt16 nCount ); + inline void SetCombinedBitsRecalcMode( ScRecalcMode nBits ) { nMode |= (nBits & ~RECALCMODE_EMASK); } inline ScRecalcMode GetCombinedBitsRecalcMode() const _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits