summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2013-03-06 06:50:22 +0100
committerEike Rathke <erack@redhat.com>2013-03-06 10:16:39 +0000
commit5a1c73cbf18ae5398f736d54224622b86a9bfd54 (patch)
treedbf521527e6d7de040a56567962c21fdf4682950
parent529172124be1bfcb55fca1e7be3317efa3ba0cfe (diff)
prevent non-3D refs from being accepted in chart2, related fdo#61781
(cherry picked from commit 47ec29ae934c82a58436bca0511117503568e907) Change-Id: I4c7f79393721bff3d5e6fda98b8d4bf16a5ee398 Edit: removed one unnecessary header file include. (erAck) Reviewed-on: https://gerrit.libreoffice.org/2562 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
-rw-r--r--sc/inc/reftokenhelper.hxx2
-rw-r--r--sc/source/core/tool/reftokenhelper.cxx20
-rw-r--r--sc/source/ui/unoobj/chart2uno.cxx14
3 files changed, 23 insertions, 13 deletions
diff --git a/sc/inc/reftokenhelper.hxx b/sc/inc/reftokenhelper.hxx
index fed82325241a..d4fc698eeb38 100644
--- a/sc/inc/reftokenhelper.hxx
+++ b/sc/inc/reftokenhelper.hxx
@@ -46,7 +46,7 @@ public:
*/
static void compileRangeRepresentation(
::std::vector<ScTokenRef>& rRefTokens, const ::rtl::OUString& rRangeStr, ScDocument* pDoc,
- const sal_Unicode cSep, ::formula::FormulaGrammar::Grammar eGrammar);
+ const sal_Unicode cSep, ::formula::FormulaGrammar::Grammar eGrammar, bool bOnly3DRef = false);
static bool getRangeFromToken(ScRange& rRange, const ScTokenRef& pToken, bool bExternal = false);
diff --git a/sc/source/core/tool/reftokenhelper.cxx b/sc/source/core/tool/reftokenhelper.cxx
index b59d1402e807..09d0712479bd 100644
--- a/sc/source/core/tool/reftokenhelper.cxx
+++ b/sc/source/core/tool/reftokenhelper.cxx
@@ -35,7 +35,7 @@ using ::rtl::OUString;
void ScRefTokenHelper::compileRangeRepresentation(
vector<ScTokenRef>& rRefTokens, const OUString& rRangeStr, ScDocument* pDoc,
- const sal_Unicode cSep, FormulaGrammar::Grammar eGrammar)
+ const sal_Unicode cSep, FormulaGrammar::Grammar eGrammar, bool bOnly3DRef)
{
const sal_Unicode cQuote = '\'';
@@ -80,12 +80,22 @@ void ScRefTokenHelper::compileRangeRepresentation(
switch (pT->GetType())
{
case svSingleRef:
- if (!pT->GetSingleRef().Valid())
- bFailure = true;
+ {
+ const ScSingleRefData& rRef = pT->GetSingleRef();
+ if (!rRef.Valid())
+ bFailure = true;
+ else if (bOnly3DRef && !rRef.IsFlag3D())
+ bFailure = true;
+ }
break;
case svDoubleRef:
- if (!pT->GetDoubleRef().Valid())
- bFailure = true;
+ {
+ const ScComplexRefData& rRef = pT->GetDoubleRef();
+ if (!rRef.Valid())
+ bFailure = true;
+ else if (bOnly3DRef && !rRef.Ref1.IsFlag3D())
+ bFailure = true;
+ }
break;
case svExternalSingleRef:
if (!pT->GetSingleRef().ValidExternal())
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index 60b19c9107f2..6bf1bfc9014d 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -1052,7 +1052,7 @@ void ScChart2DataProvider::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint
vector<ScTokenRef> aTokens;
const sal_Unicode cSep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
ScRefTokenHelper::compileRangeRepresentation(
- aTokens, aRangeRepresentation, m_pDocument, cSep, m_pDocument->GetGrammar());
+ aTokens, aRangeRepresentation, m_pDocument, cSep, m_pDocument->GetGrammar(), true);
return !aTokens.empty();
}
@@ -1484,7 +1484,7 @@ ScChart2DataProvider::createDataSource(
vector<ScTokenRef> aRefTokens;
const sal_Unicode cSep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
ScRefTokenHelper::compileRangeRepresentation(
- aRefTokens, aRangeRepresentation, m_pDocument, cSep, m_pDocument->GetGrammar());
+ aRefTokens, aRangeRepresentation, m_pDocument, cSep, m_pDocument->GetGrammar(), true);
if (aRefTokens.empty())
// Invalid range representation. Bail out.
throw lang::IllegalArgumentException();
@@ -1818,7 +1818,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL ScChart2DataProvider::detectArgum
vector<ScTokenRef> aTokens;
const sal_Unicode cSep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
ScRefTokenHelper::compileRangeRepresentation(
- aTokens, xLabel->getSourceRangeRepresentation(), m_pDocument, cSep, m_pDocument->GetGrammar());
+ aTokens, xLabel->getSourceRangeRepresentation(), m_pDocument, cSep, m_pDocument->GetGrammar(), true);
aLabel.initRangeAnalyzer(aTokens);
vector<ScTokenRef>::const_iterator itr = aTokens.begin(), itrEnd = aTokens.end();
for (; itr != itrEnd; ++itr)
@@ -1837,7 +1837,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL ScChart2DataProvider::detectArgum
vector<ScTokenRef> aTokens;
const sal_Unicode cSep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
ScRefTokenHelper::compileRangeRepresentation(
- aTokens, xValues->getSourceRangeRepresentation(), m_pDocument, cSep, m_pDocument->GetGrammar());
+ aTokens, xValues->getSourceRangeRepresentation(), m_pDocument, cSep, m_pDocument->GetGrammar(), true);
aValues.initRangeAnalyzer(aTokens);
vector<ScTokenRef>::const_iterator itr = aTokens.begin(), itrEnd = aTokens.end();
for (; itr != itrEnd; ++itr)
@@ -2046,7 +2046,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL ScChart2DataProvider::detectArgum
vector<ScTokenRef> aTokens;
const sal_Unicode cSep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
ScRefTokenHelper::compileRangeRepresentation(
- aTokens, aRangeRepresentation, m_pDocument, cSep, m_pDocument->GetGrammar());
+ aTokens, aRangeRepresentation, m_pDocument, cSep, m_pDocument->GetGrammar(), true);
return !aTokens.empty();
}
@@ -2066,7 +2066,7 @@ uno::Reference< chart2::data::XDataSequence > SAL_CALL
vector<ScTokenRef> aRefTokens;
const sal_Unicode cSep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
ScRefTokenHelper::compileRangeRepresentation(
- aRefTokens, aRangeRepresentation, m_pDocument, cSep, m_pDocument->GetGrammar());
+ aRefTokens, aRangeRepresentation, m_pDocument, cSep, m_pDocument->GetGrammar(), true);
if (aRefTokens.empty())
return xResult;
@@ -2237,7 +2237,7 @@ rtl::OUString SAL_CALL ScChart2DataProvider::convertRangeToXML( const rtl::OUStr
vector<ScTokenRef> aRefTokens;
const sal_Unicode cSep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
ScRefTokenHelper::compileRangeRepresentation(
- aRefTokens, sRangeRepresentation, m_pDocument, cSep, m_pDocument->GetGrammar());
+ aRefTokens, sRangeRepresentation, m_pDocument, cSep, m_pDocument->GetGrammar(), true);
if (aRefTokens.empty())
throw lang::IllegalArgumentException();