Kaydet (Commit) 15202ad5 authored tarafından Muthu Subramanian's avatar Muthu Subramanian

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.
üst 08d15d0b
...@@ -46,11 +46,23 @@ using ::std::vector; ...@@ -46,11 +46,23 @@ using ::std::vector;
using ::std::auto_ptr; using ::std::auto_ptr;
using ::rtl::OUString; 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( void ScRefTokenHelper::compileRangeRepresentation(
vector<ScTokenRef>& rRefTokens, const OUString& rRangeStr, ScDocument* pDoc, vector<ScTokenRef>& rRefTokens, const OUString& rRangeStr, ScDocument* pDoc,
const sal_Unicode cSep, FormulaGrammar::Grammar eGrammar) const sal_Unicode cSep, FormulaGrammar::Grammar eGrammar)
{ {
const sal_Unicode cQuote = '\''; const sal_Unicode cQuote = '\'';
bool bMayBeConstString = lcl_mayBeRangeConstString( rRangeStr );
// #i107275# ignore parentheses // #i107275# ignore parentheses
OUString aRangeStr = rRangeStr; OUString aRangeStr = rRangeStr;
...@@ -80,7 +92,7 @@ void ScRefTokenHelper::compileRangeRepresentation( ...@@ -80,7 +92,7 @@ void ScRefTokenHelper::compileRangeRepresentation(
else else
{ {
pArray->Reset(); pArray->Reset();
const FormulaToken* p = pArray->GetNextReference(); const FormulaToken* p = pArray->Next();
if (!p) if (!p)
bFailure = true; bFailure = true;
else else
...@@ -104,8 +116,14 @@ void ScRefTokenHelper::compileRangeRepresentation( ...@@ -104,8 +116,14 @@ void ScRefTokenHelper::compileRangeRepresentation(
if (!pT->GetDoubleRef().ValidExternal()) if (!pT->GetDoubleRef().ValidExternal())
bFailure = true; bFailure = true;
break; break;
case svString:
if (!bMayBeConstString)
bFailure = true;
bMayBeConstString = false;
break;
default: default:
; bFailure = true;
break;
} }
if (!bFailure) if (!bFailure)
rRefTokens.push_back( rRefTokens.push_back(
......
...@@ -862,6 +862,18 @@ Reference< XDataSequence > XclImpChSourceLink::CreateDataSequence( const OUStrin ...@@ -862,6 +862,18 @@ Reference< XDataSequence > XclImpChSourceLink::CreateDataSequence( const OUStrin
// OSL_FAIL( "XclImpChSourceLink::CreateDataSequence - cannot create data sequence" ); // OSL_FAIL( "XclImpChSourceLink::CreateDataSequence - cannot create data sequence" );
} }
} }
else if( rRole == EXC_CHPROP_ROLE_LABEL && mxString && mxString->GetText().Len() )
{
try
{
OUString aString = OUString::createFromAscii("\"");
xDataSeq = xDataProv->createDataSequenceByRangeRepresentation( aString + mxString->GetText() + aString );
// set sequence role
ScfPropertySet aSeqProp( xDataSeq );
aSeqProp.SetProperty( EXC_CHPROP_ROLE, rRole );
}
catch( Exception& ) { }
}
return xDataSeq; return xDataSeq;
} }
......
...@@ -371,7 +371,7 @@ Chart2PositionMap::Chart2PositionMap(SCCOL nAllColCount, SCROW nAllRowCount, ...@@ -371,7 +371,7 @@ Chart2PositionMap::Chart2PositionMap(SCCOL nAllColCount, SCROW nAllRowCount,
maData.init(mnDataColCount,mnDataRowCount); maData.init(mnDataColCount,mnDataRowCount);
Table* pCol = static_cast<Table*>(rCols.First()); Table* pCol = static_cast<Table*>(rCols.First());
FormulaToken* pToken = static_cast<FormulaToken*>(pCol->First()); FormulaToken* pToken = NULL;
for (SCCOL nCol = 0; nCol < nAllColCount; ++nCol) for (SCCOL nCol = 0; nCol < nAllColCount; ++nCol)
{ {
if (pCol) if (pCol)
...@@ -725,7 +725,8 @@ void Chart2Positioner::createPositionMap() ...@@ -725,7 +725,8 @@ void Chart2Positioner::createPositionMap()
String aTabName = bExternal ? pToken->GetString() : String(); String aTabName = bExternal ? pToken->GetString() : String();
ScComplexRefData aData; ScComplexRefData aData;
ScRefTokenHelper::getDoubleRefDataFromToken(aData, *itr); if( !ScRefTokenHelper::getDoubleRefDataFromToken(aData, *itr) )
break;
const ScSingleRefData& s = aData.Ref1; const ScSingleRefData& s = aData.Ref1;
const ScSingleRefData& e = aData.Ref2; const ScSingleRefData& e = aData.Ref2;
SCCOL nCol1 = s.nCol, nCol2 = e.nCol; SCCOL nCol1 = s.nCol, nCol2 = e.nCol;
...@@ -2880,17 +2881,29 @@ uno::Sequence< double > SAL_CALL ScChart2DataSequence::getNumericalData() ...@@ -2880,17 +2881,29 @@ uno::Sequence< double > SAL_CALL ScChart2DataSequence::getNumericalData()
uno::Sequence< rtl::OUString > SAL_CALL ScChart2DataSequence::getTextualData( ) throw (uno::RuntimeException) uno::Sequence< rtl::OUString > SAL_CALL ScChart2DataSequence::getTextualData( ) throw (uno::RuntimeException)
{ {
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
if ( !m_pDocument) uno::Sequence<rtl::OUString> aSeq;
if ( !m_pDocument )
throw uno::RuntimeException(); throw uno::RuntimeException();
BuildDataCache(); BuildDataCache();
sal_Int32 nCount = m_aDataArray.size(); sal_Int32 nCount = m_aDataArray.size();
uno::Sequence<rtl::OUString> aSeq(nCount); if ( nCount > 0 )
{
aSeq = uno::Sequence<rtl::OUString>(nCount);
rtl::OUString* pArr = aSeq.getArray(); rtl::OUString* pArr = aSeq.getArray();
::std::list<Item>::const_iterator itr = m_aDataArray.begin(), itrEnd = m_aDataArray.end(); ::std::list<Item>::const_iterator itr = m_aDataArray.begin(), itrEnd = m_aDataArray.end();
for (; itr != itrEnd; ++itr, ++pArr) for(; itr != itrEnd; ++itr, ++pArr)
*pArr = itr->maString; *pArr = itr->maString;
}
else if ( m_pTokens.get() && m_pTokens->front() )
{
if( m_pTokens->front()->GetType() == svString )
{
aSeq = uno::Sequence<rtl::OUString>(1);
aSeq[0] = m_pTokens->front()->GetString();
}
}
return aSeq; return aSeq;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment