[Libreoffice-commits] core.git: 3 commits - chart2/qa sc/inc sc/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Tue Mar 5 22:57:53 PST 2013
chart2/qa/extras/chart2import.cxx | 20 ++++++++++++++++++++
sc/inc/reftokenhelper.hxx | 2 +-
sc/source/core/tool/reftokenhelper.cxx | 20 +++++++++++++++-----
sc/source/ui/unoobj/chart2uno.cxx | 18 ++++++++++--------
4 files changed, 46 insertions(+), 14 deletions(-)
New commits:
commit 47ec29ae934c82a58436bca0511117503568e907
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
Change-Id: I4c7f79393721bff3d5e6fda98b8d4bf16a5ee398
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 fd2961f..ccb1524 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 @@ 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();
}
@@ -1481,7 +1482,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();
@@ -1815,7 +1816,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)
@@ -1834,7 +1835,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)
@@ -2043,7 +2044,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();
}
@@ -2063,7 +2064,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;
@@ -2234,7 +2235,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();
commit a26217815d4e69ec2485c370dfef0fbb41d6c8ab
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue Mar 5 13:43:12 2013 +0100
make all chart ranges explicitly 3D refs during import/export, fdo#61781
Change-Id: I66657ce38456e4a8dc3a602997c451cf1cdd983b
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index fc8a462..fd2961f 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -964,7 +964,8 @@ private:
setRelative(aData.Ref1);
setRelative(aData.Ref2);
- // In XML, the end range must explicitly specify sheet name.
+ // In XML, the range must explicitly specify sheet name.
+ aData.Ref1.SetFlag3D(true);
aData.Ref2.SetFlag3D(true);
if (bExternal)
commit 6e39ea83a269ac56cbcf81084217457feabf5d47
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue Mar 5 12:07:32 2013 +0100
improve chart2 import test
Change-Id: I0de697ccf779163408755bcd677b2af2e74bd18f
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index 1a6db5b..e30e1a0 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -27,6 +27,7 @@
#include <com/sun/star/chart2/XChartTypeContainer.hpp>
#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
+#include <com/sun/star/chart/ErrorBarStyle.hpp>
#include <comphelper/processfactory.hxx>
@@ -73,6 +74,25 @@ void Chart2ImportTest::Fdo60083()
Reference< beans::XPropertySet > xErrorBarYProps;
xPropSet->getPropertyValue("ErrorBarY") >>= xErrorBarYProps;
CPPUNIT_ASSERT(xErrorBarYProps.is());
+ {
+ sal_Int32 nErrorBarStyle;
+ xErrorBarYProps->getPropertyValue("ErrorBarStyle") >>= nErrorBarStyle;
+ CPPUNIT_ASSERT_EQUAL(nErrorBarStyle, static_cast<sal_Int32>(chart::ErrorBarStyle::RELATIVE));
+
+ double nVal;
+ xErrorBarYProps->getPropertyValue("PositiveError") >>= nVal;
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(5.0, nVal, 1e-8);
+
+ xErrorBarYProps->getPropertyValue("NegativeError") >>= nVal;
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(5.0, nVal, 1e-8);
+
+ sal_Bool bVal;
+ xErrorBarYProps->getPropertyValue("ShowPositiveError") >>= bVal;
+ CPPUNIT_ASSERT_EQUAL(static_cast<bool>(bVal), true);
+
+ xErrorBarYProps->getPropertyValue("ShowNegativeError") >>= bVal;
+ CPPUNIT_ASSERT_EQUAL(static_cast<bool>(bVal), true);
+ }
// test that x error bars are not imported
Reference< beans::XPropertySet > xErrorBarXProps;
More information about the Libreoffice-commits
mailing list