From 15202ad5b26ff48dc937ed12b57d53108c2731e4 Mon Sep 17 00:00:00 2001 From: Muthu Subramanian Date: Mon, 3 Oct 2011 16:28:59 +0530 Subject: n717290: Feature to allow string constants in chart ranges. Chart ranges specifically for labels can now be of the form ="Label1". This allows labels to be picked from chart data (from UI) rather than from the sheet. --- sc/source/core/tool/reftokenhelper.cxx | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'sc/source/core/tool/reftokenhelper.cxx') diff --git a/sc/source/core/tool/reftokenhelper.cxx b/sc/source/core/tool/reftokenhelper.cxx index f4f09d635575..5d6cbfbd84b7 100644 --- a/sc/source/core/tool/reftokenhelper.cxx +++ b/sc/source/core/tool/reftokenhelper.cxx @@ -46,11 +46,23 @@ using ::std::vector; using ::std::auto_ptr; using ::rtl::OUString; +static bool lcl_mayBeRangeConstString( const OUString &aRangeStr ) +{ + if( aRangeStr.getLength() >= 3 && aRangeStr.endsWithAsciiL( "\"", 1 ) ) + if( aRangeStr[0] == '"' ) + return true; + else if( aRangeStr[0] == '=' && aRangeStr[1] == '"' ) + return true; + + return false; +} + void ScRefTokenHelper::compileRangeRepresentation( vector& rRefTokens, const OUString& rRangeStr, ScDocument* pDoc, const sal_Unicode cSep, FormulaGrammar::Grammar eGrammar) { const sal_Unicode cQuote = '\''; + bool bMayBeConstString = lcl_mayBeRangeConstString( rRangeStr ); // #i107275# ignore parentheses OUString aRangeStr = rRangeStr; @@ -80,7 +92,7 @@ void ScRefTokenHelper::compileRangeRepresentation( else { pArray->Reset(); - const FormulaToken* p = pArray->GetNextReference(); + const FormulaToken* p = pArray->Next(); if (!p) bFailure = true; else @@ -104,8 +116,14 @@ void ScRefTokenHelper::compileRangeRepresentation( if (!pT->GetDoubleRef().ValidExternal()) bFailure = true; break; + case svString: + if (!bMayBeConstString) + bFailure = true; + bMayBeConstString = false; + break; default: - ; + bFailure = true; + break; } if (!bFailure) rRefTokens.push_back( -- cgit v1.2.3