[Libreoffice-commits] core.git: sc/qa sc/source
Katarina Behrens
Katarina.Behrens at cib.de
Thu May 11 14:03:01 UTC 2017
sc/qa/unit/ucalc_formula.cxx | 17 +++++++++++++++++
sc/source/core/tool/interpr4.cxx | 13 ++++++++++++-
2 files changed, 29 insertions(+), 1 deletion(-)
New commits:
commit 2dd2f3328acd564e5f77efa4fe91d67ac0984e63
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Wed May 10 15:30:39 2017 +0200
Get string also for external reference to double for operands of '&'
In a formula like ='ExtRef1' & 'ExtRef2', or ='LocalValue' & 'ExtRef1'
empty string became an operand in concat operation if the referenced
external cell was a non-string one.
Change-Id: I7b0ac5de68349eae85afe48f377e30cab76e3fbf
Reviewed-on: https://gerrit.libreoffice.org/37469
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Eike Rathke <erack at redhat.com>
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 474fedbcacf5..8647328a8aa9 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -5873,6 +5873,22 @@ void testExtRefFuncVLOOKUP(ScDocument* pDoc, ScDocument& rExtDoc)
CPPUNIT_ASSERT_EQUAL(OUString("B2"), pDoc->GetString(ScAddress(1,0,0)));
}
+void testExtRefConcat(ScDocument* pDoc, ScDocument& rExtDoc)
+{
+ Test::clearRange(pDoc, ScRange(0, 0, 0, 1, 9, 0));
+ Test::clearRange(&rExtDoc, ScRange(0, 0, 0, 1, 9, 0));
+
+ sc::AutoCalcSwitch aACSwitch(*pDoc, true);
+
+ // String and number
+ rExtDoc.SetString(ScAddress(0,0,0), "Answer: ");
+ rExtDoc.SetValue(ScAddress(0,1,0), 42);
+
+ // Concat operation should combine string and number converted to string
+ pDoc->SetString(ScAddress(0,0,0), "='file:///extdata.fake'#Data.A1 & 'file:///extdata.fake'#Data.A2");
+ CPPUNIT_ASSERT_EQUAL(OUString("Answer: 42"), pDoc->GetString(ScAddress(0,0,0)));
+}
+
void Test::testExternalRefFunctions()
{
ScDocShellRef xExtDocSh = new ScDocShell;
@@ -5956,6 +5972,7 @@ void Test::testExternalRefFunctions()
testExtRefFuncT(m_pDoc, rExtDoc);
testExtRefFuncOFFSET(m_pDoc, rExtDoc);
testExtRefFuncVLOOKUP(m_pDoc, rExtDoc);
+ testExtRefConcat(m_pDoc, rExtDoc);
// Unload the external document shell.
xExtDocSh->DoClose();
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index d7260b5c1bd1..9ed69677369f 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -2325,7 +2325,18 @@ svl::SharedString ScInterpreter::GetString()
if (nGlobalError != FormulaError::NONE)
return svl::SharedString::getEmptyString();
- return pToken->GetString();
+ if (pToken->GetType() == svDouble)
+ {
+ double fVal = pToken->GetDouble();
+ sal_uLong nIndex = pFormatter->GetStandardFormat(
+ css::util::NumberFormat::NUMBER,
+ ScGlobal::eLnge);
+ OUString aStr;
+ pFormatter->GetInputLineString(fVal, nIndex, aStr);
+ return mrStrPool.intern(aStr);
+ }
+ else // svString or svEmpty
+ return pToken->GetString();
}
case svExternalDoubleRef:
{
More information about the Libreoffice-commits
mailing list