[Libreoffice-commits] core.git: Branch 'libreoffice-4-0' - sc/inc sc/source

Markus Mohrhard markus.mohrhard at googlemail.com
Wed Mar 6 02:17:00 PST 2013


 sc/inc/reftokenhelper.hxx              |    2 +-
 sc/source/core/tool/reftokenhelper.cxx |   20 +++++++++++++++-----
 sc/source/ui/unoobj/chart2uno.cxx      |   14 +++++++-------
 3 files changed, 23 insertions(+), 13 deletions(-)

New commits:
commit 5a1c73cbf18ae5398f736d54224622b86a9bfd54
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Mar 6 06:50:22 2013 +0100

    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 at redhat.com>
    Tested-by: Eike Rathke <erack at redhat.com>

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 @@ 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 b59d140..09d0712 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 60b19c9..6bf1bfc 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();
 


More information about the Libreoffice-commits mailing list