summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-12-06 14:36:50 -0500
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-12-06 23:05:11 -0500
commit65dad3684c609e89b92714e51c914e9b1afa16a3 (patch)
tree5b1172716ef3e49057c4fc67f435c09c0644b488
parent28daebdf085844b8e611a90ece376ac3b19b8b9b (diff)
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
-rw-r--r--oox/source/drawingml/chart/titlecontext.cxx10
-rw-r--r--sc/source/core/tool/reftokenhelper.cxx91
-rw-r--r--sc/source/ui/unoobj/chart2uno.cxx1
3 files changed, 48 insertions, 54 deletions
diff --git a/oox/source/drawingml/chart/titlecontext.cxx b/oox/source/drawingml/chart/titlecontext.cxx
index 100235d7c2c6..4b921daac947 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 2a32e12de85c..1508df7a7cd2 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 00cbee882c90..7bf45e1b2992 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: