sc/source/core/tool/reftokenhelper.cxx | 22 ++++++++++++++++++++-- sc/source/filter/excel/xichart.cxx | 12 ++++++++++++ sc/source/ui/unoobj/chart2uno.cxx | 29 +++++++++++++++++++++-------- 3 files changed, 53 insertions(+), 10 deletions(-)
New commits: commit 15202ad5b26ff48dc937ed12b57d53108c2731e4 Author: Muthu Subramanian <sumu...@suse.com> Date: Mon Oct 3 16:28:59 2011 +0530 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. diff --git a/sc/source/core/tool/reftokenhelper.cxx b/sc/source/core/tool/reftokenhelper.cxx index f4f09d6..5d6cbfb 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<ScTokenRef>& 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( diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx index d5b357f..36c0fe4 100644 --- a/sc/source/filter/excel/xichart.cxx +++ b/sc/source/filter/excel/xichart.cxx @@ -862,6 +862,18 @@ Reference< XDataSequence > XclImpChSourceLink::CreateDataSequence( const OUStrin // 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; } diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index 398bcfe..04c1537 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -371,7 +371,7 @@ Chart2PositionMap::Chart2PositionMap(SCCOL nAllColCount, SCROW nAllRowCount, maData.init(mnDataColCount,mnDataRowCount); Table* pCol = static_cast<Table*>(rCols.First()); - FormulaToken* pToken = static_cast<FormulaToken*>(pCol->First()); + FormulaToken* pToken = NULL; for (SCCOL nCol = 0; nCol < nAllColCount; ++nCol) { if (pCol) @@ -725,7 +725,8 @@ void Chart2Positioner::createPositionMap() String aTabName = bExternal ? pToken->GetString() : String(); ScComplexRefData aData; - ScRefTokenHelper::getDoubleRefDataFromToken(aData, *itr); + if( !ScRefTokenHelper::getDoubleRefDataFromToken(aData, *itr) ) + break; const ScSingleRefData& s = aData.Ref1; const ScSingleRefData& e = aData.Ref2; SCCOL nCol1 = s.nCol, nCol2 = e.nCol; @@ -2880,17 +2881,29 @@ uno::Sequence< double > SAL_CALL ScChart2DataSequence::getNumericalData() uno::Sequence< rtl::OUString > SAL_CALL ScChart2DataSequence::getTextualData( ) throw (uno::RuntimeException) { SolarMutexGuard aGuard; - if ( !m_pDocument) + uno::Sequence<rtl::OUString> aSeq; + if ( !m_pDocument ) throw uno::RuntimeException(); BuildDataCache(); sal_Int32 nCount = m_aDataArray.size(); - uno::Sequence<rtl::OUString> aSeq(nCount); - rtl::OUString* pArr = aSeq.getArray(); - ::std::list<Item>::const_iterator itr = m_aDataArray.begin(), itrEnd = m_aDataArray.end(); - for (; itr != itrEnd; ++itr, ++pArr) - *pArr = itr->maString; + if ( nCount > 0 ) + { + aSeq = uno::Sequence<rtl::OUString>(nCount); + rtl::OUString* pArr = aSeq.getArray(); + ::std::list<Item>::const_iterator itr = m_aDataArray.begin(), itrEnd = m_aDataArray.end(); + for(; itr != itrEnd; ++itr, ++pArr) + *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; } _______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits