oox/source/drawingml/chart/titlecontext.cxx | 10 ++- sc/source/core/tool/reftokenhelper.cxx | 91 ++++++++++++---------------- sc/source/ui/unoobj/chart2uno.cxx | 1 3 files changed, 48 insertions(+), 54 deletions(-)
New commits: commit 65dad3684c609e89b92714e51c914e9b1afa16a3 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Thu Dec 6 14:36:50 2012 -0500 bnc#792528: Import static data series labels from xlsx correctly. Static data series label is a data series label whose value is a string value rather than a cell reference. Also, when inputting static string label in the UI, we don't have to manually check for quotes; the formula compiler will take care of that later. Change-Id: I1657fc9879a7f652bba84898e308c3a5d5ba87a3 diff --git a/oox/source/drawingml/chart/titlecontext.cxx b/oox/source/drawingml/chart/titlecontext.cxx index 100235d..4b921da 100644 --- a/oox/source/drawingml/chart/titlecontext.cxx +++ b/oox/source/drawingml/chart/titlecontext.cxx @@ -33,6 +33,8 @@ #include "oox/drawingml/chart/datasourcecontext.hxx" #include "oox/drawingml/chart/titlemodel.hxx" +#include "rtl/ustrbuf.hxx" + namespace oox { namespace drawingml { namespace chart { @@ -75,9 +77,13 @@ ContextHandlerRef TextContext::onCreateContext( sal_Int32 nElement, const Attrib void TextContext::onCharacters( const OUString& rChars ) { - // store as single string sequence element if( isCurrentElement( C_TOKEN( v ) ) ) - mrModel.mxDataSeq.create().maData[ 0 ] <<= rChars; + { + // Static text is stored as a single string formula token. + OUStringBuffer aBuf; + aBuf.append('"').append(rChars).append('"'); + mrModel.mxDataSeq.create().maFormula = aBuf.makeStringAndClear(); + } } // ============================================================================ diff --git a/sc/source/core/tool/reftokenhelper.cxx b/sc/source/core/tool/reftokenhelper.cxx index 2a32e12..1508df7 100644 --- a/sc/source/core/tool/reftokenhelper.cxx +++ b/sc/source/core/tool/reftokenhelper.cxx @@ -44,25 +44,11 @@ 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; @@ -88,48 +74,49 @@ void ScRefTokenHelper::compileRangeRepresentation( if (!nLen) continue; // Should a missing range really be allowed? if (nLen != 1) + { bFailure = true; - else + break; + } + + pArray->Reset(); + const FormulaToken* p = pArray->Next(); + if (!p) { - pArray->Reset(); - const FormulaToken* p = pArray->Next(); - if (!p) + bFailure = true; + break; + } + + const ScToken* pT = static_cast<const ScToken*>(p); + switch (pT->GetType()) + { + case svSingleRef: + if (!pT->GetSingleRef().Valid()) + bFailure = true; + break; + case svDoubleRef: + if (!pT->GetDoubleRef().Valid()) + bFailure = true; + break; + case svExternalSingleRef: + if (!pT->GetSingleRef().ValidExternal()) + bFailure = true; + break; + case svExternalDoubleRef: + if (!pT->GetDoubleRef().ValidExternal()) + bFailure = true; + break; + case svString: + if (!pT->GetString().Len()) + bFailure = true; + break; + default: bFailure = true; - else - { - const ScToken* pT = static_cast<const ScToken*>(p); - switch (pT->GetType()) - { - case svSingleRef: - if (!pT->GetSingleRef().Valid()) - bFailure = true; - break; - case svDoubleRef: - if (!pT->GetDoubleRef().Valid()) - bFailure = true; - break; - case svExternalSingleRef: - if (!pT->GetSingleRef().ValidExternal()) - bFailure = true; - break; - case svExternalDoubleRef: - 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( - ScTokenRef(static_cast<ScToken*>(p->Clone()))); - } + break; } + if (!bFailure) + rRefTokens.push_back( + ScTokenRef(static_cast<ScToken*>(p->Clone()))); } if (bFailure) diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index 00cbee8..7bf45e1 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -2200,6 +2200,7 @@ ScChart2DataProvider::createDataSequenceByFormulaTokens( } } break; + case svString: case svSingleRef: case svDoubleRef: case svExternalSingleRef: _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits