Hi,
I have submitted a patch for review:
https://gerrit.libreoffice.org/2562
To pull it, you can do:
git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/62/2562/1
prevent non-3D refs from being accepted in chart2, related fdo#61781
Change-Id: I4c7f79393721bff3d5e6fda98b8d4bf16a5ee398
(cherry picked from commit 47ec29ae934c82a58436bca0511117503568e907)
---
M sc/inc/reftokenhelper.hxx
M sc/source/core/tool/reftokenhelper.cxx
M sc/source/ui/unoobj/chart2uno.cxx
3 files changed, 24 insertions(+), 13 deletions(-)
diff --git a/sc/inc/reftokenhelper.hxx b/sc/inc/reftokenhelper.hxx
index fed8232..d4fc698 100644
--- a/sc/inc/reftokenhelper.hxx
+++ b/sc/inc/reftokenhelper.hxx
@@ -46,7 +46,7 @@
*/
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 b59d140..09d0712 100644
--- a/sc/source/core/tool/reftokenhelper.cxx
+++ b/sc/source/core/tool/reftokenhelper.cxx
@@ -35,7 +35,7 @@
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 @@
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 60b19c9..ff095af 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -34,6 +34,7 @@
#include "chartlis.hxx"
#include "stlalgorithm.hxx"
#include "tokenuno.hxx"
+#include "docsh.hxx"
#include "formula/opcode.hxx"
@@ -1052,7 +1053,7 @@
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 +1485,7 @@
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 +1819,7 @@
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 +1838,7 @@
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 +2047,7 @@
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 +2067,7 @@
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 +2238,7 @@
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();
--
To view, visit https://gerrit.libreoffice.org/2562
To unsubscribe, visit https://gerrit.libreoffice.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4c7f79393721bff3d5e6fda98b8d4bf16a5ee398
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Markus Mohrhard <markus.mohrhard@googlemail.com>
Context
- [PATCH libreoffice-4-0] prevent non-3D refs from being accepted in chart2, related f... · Markus Mohrhard (via Code Review)
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.