sc/inc/compiler.hxx | 60 +++++---------------------------------- sc/qa/unit/ucalc_formula.cxx | 18 +++++++++++ sc/source/core/tool/compiler.cxx | 52 +++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 52 deletions(-)
New commits: commit 9313a71461a76f8e5fda13a00aeafdf4e0ed1cb2 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Wed Jul 31 19:19:41 2013 -0400 Add test on updating references in named range. This currently fails. Change-Id: Ibb2b9e4430c97479d068d94d233f04f60b255966 diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index f731f2a..e85c01c55 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -1064,6 +1064,24 @@ void Test::testFormulaRefUpdateNamedExpression() CPPUNIT_ASSERT_EQUAL(34.0, m_pDoc->GetValue(ScAddress(2,7,0))); #endif + // Clear all and start over. + clearRange(m_pDoc, ScRange(0,0,0,100,100,0)); + pGlobalNames->clear(); + + pName = new ScRangeData( + m_pDoc, "MyRange", "$B$1:$C$6", ScAddress(0,0,0), RT_NAME, formula::FormulaGrammar::GRAM_NATIVE); + bInserted = pGlobalNames->insert(pName); + CPPUNIT_ASSERT_MESSAGE("Failed to insert a new name.", bInserted); + pName->GetSymbol(aExpr); + CPPUNIT_ASSERT_EQUAL(OUString("$B$1:$C$6"), aExpr); + + // Insert range of cells to shift right. The range partially overlaps the named range. + m_pDoc->InsertCol(ScRange(2,4,0,3,8,0)); + + // This should not alter the range. + pName->GetSymbol(aExpr); + CPPUNIT_ASSERT_EQUAL(OUString("$B$1:$C$6"), aExpr); + m_pDoc->DeleteTab(0); } commit 4de00d49a6eb42d2cc2c41cb0a2fa76ca9661b04 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Wed Jul 31 17:24:40 2013 -0400 Avoid having these fat inline methods. They tend to cause linkage problem on Windows. Change-Id: I98fff8c5e45987670629e6eeacec7ecadf71ff48 diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx index 46606d8..6cb4301 100644 --- a/sc/inc/compiler.hxx +++ b/sc/inc/compiler.hxx @@ -443,66 +443,22 @@ public: /** If the character is allowed as first character in sheet names or references, includes '$' and '?'. */ - static inline bool IsCharWordChar( String const & rStr, - xub_StrLen nPos, - const formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_OOO ) - { - sal_Unicode c = rStr.GetChar( nPos ); - sal_Unicode cLast = nPos > 0 ? rStr.GetChar(nPos-1) : 0; - if (c < 128) - { - return pConventions[eConv] ? (pConventions[eConv]->getCharTableFlags(c, cLast) & SC_COMPILER_C_CHAR_WORD) == SC_COMPILER_C_CHAR_WORD : - false; // no convention => assume invalid - } - else - return ScGlobal::pCharClass->isLetterNumeric( rStr, nPos ); - } + static bool IsCharWordChar( + String const & rStr, xub_StrLen nPos, + const formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_OOO ); /** If the character is allowed in sheet names, thus may be part of a reference, includes '$' and '?' and such. */ - static inline bool IsWordChar( String const & rStr, - xub_StrLen nPos, - const formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_OOO ) - { - sal_Unicode c = rStr.GetChar( nPos ); - sal_Unicode cLast = nPos > 0 ? rStr.GetChar(nPos-1) : 0; - if (c < 128) - { - return pConventions[eConv] ? (pConventions[eConv]->getCharTableFlags(c, cLast) & SC_COMPILER_C_WORD) == SC_COMPILER_C_WORD : - false; // convention not known => assume invalid - } - else - return ScGlobal::pCharClass->isLetterNumeric( rStr, nPos ); - } + static bool IsWordChar( + String const & rStr, xub_StrLen nPos, + const formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_OOO ); /** If the character is allowed as tested by nFlags (SC_COMPILER_C_... bits) for all known address conventions. If more than one bit is given in nFlags, all bits must match. If bTestLetterNumeric is false and char>=128, no LetterNumeric test is done and false is returned. */ - static inline bool IsCharFlagAllConventions( String const & rStr, - xub_StrLen nPos, - sal_uLong nFlags, - bool bTestLetterNumeric = true ) - { - sal_Unicode c = rStr.GetChar( nPos ); - sal_Unicode cLast = nPos > 0 ? rStr.GetChar( nPos-1 ) : 0; - if (c < 128) - { - for ( int nConv = formula::FormulaGrammar::CONV_UNSPECIFIED; - ++nConv < formula::FormulaGrammar::CONV_LAST; ) - { - if (pConventions[nConv] && - ((pConventions[nConv]->getCharTableFlags(c, cLast) & nFlags) != nFlags)) - return false; - // convention not known => assume valid - } - return true; - } - else if (bTestLetterNumeric) - return ScGlobal::pCharClass->isLetterNumeric( rStr, nPos ); - else - return false; - } + static bool IsCharFlagAllConventions( + String const & rStr, xub_StrLen nPos, sal_uLong nFlags, bool bTestLetterNumeric = true ); private: // FormulaCompiler diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index 4d140ba..6391690 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -4137,6 +4137,58 @@ void ScCompiler::MoveRelWrap( ScTokenArray& rArr, ScDocument* pDoc, const ScAddr } } +bool ScCompiler::IsCharWordChar( + String const & rStr, xub_StrLen nPos, const formula::FormulaGrammar::AddressConvention eConv ) +{ + sal_Unicode c = rStr.GetChar( nPos ); + sal_Unicode cLast = nPos > 0 ? rStr.GetChar(nPos-1) : 0; + if (c < 128) + { + return pConventions[eConv] ? (pConventions[eConv]->getCharTableFlags(c, cLast) & SC_COMPILER_C_CHAR_WORD) == SC_COMPILER_C_CHAR_WORD : + false; // no convention => assume invalid + } + else + return ScGlobal::pCharClass->isLetterNumeric( rStr, nPos ); +} + +bool ScCompiler::IsWordChar( + String const & rStr, xub_StrLen nPos, + const formula::FormulaGrammar::AddressConvention eConv ) +{ + sal_Unicode c = rStr.GetChar( nPos ); + sal_Unicode cLast = nPos > 0 ? rStr.GetChar(nPos-1) : 0; + if (c < 128) + { + return pConventions[eConv] ? (pConventions[eConv]->getCharTableFlags(c, cLast) & SC_COMPILER_C_WORD) == SC_COMPILER_C_WORD : + false; // convention not known => assume invalid + } + else + return ScGlobal::pCharClass->isLetterNumeric( rStr, nPos ); +} + +bool ScCompiler::IsCharFlagAllConventions( + String const & rStr, xub_StrLen nPos, sal_uLong nFlags, bool bTestLetterNumeric ) +{ + sal_Unicode c = rStr.GetChar( nPos ); + sal_Unicode cLast = nPos > 0 ? rStr.GetChar( nPos-1 ) : 0; + if (c < 128) + { + for ( int nConv = formula::FormulaGrammar::CONV_UNSPECIFIED; + ++nConv < formula::FormulaGrammar::CONV_LAST; ) + { + if (pConventions[nConv] && + ((pConventions[nConv]->getCharTableFlags(c, cLast) & nFlags) != nFlags)) + return false; + // convention not known => assume valid + } + return true; + } + else if (bTestLetterNumeric) + return ScGlobal::pCharClass->isLetterNumeric( rStr, nPos ); + else + return false; +} + void ScCompiler::CreateStringFromExternal(OUStringBuffer& rBuffer, FormulaToken* pTokenP) { FormulaToken* t = pTokenP; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits