tdf#138832 XLSX export: fix lost file names in modified links
Also for single-reference links, use the temporary indexes
calculated in commit f85d860ccbebd99bc128218148e2992c9415f221
(tdf#87973 XLSX export: fix lost file names in modified links),
Note: only a new test case has been added to the modified unit
test document.
Co-authored-by: Tibor Nagy (NISZ)
Change-Id: I4337a4e68008956ea42b626d210f07b1cbfe59ee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109088
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109536
Tested-by: Jenkins
diff --git a/sc/qa/unit/data/ods/tdf87973_externalLinkSkipUnuseds.ods b/sc/qa/unit/data/ods/tdf87973_externalLinkSkipUnuseds.ods
index cdaf9d4..d25a18b 100644
--- a/sc/qa/unit/data/ods/tdf87973_externalLinkSkipUnuseds.ods
+++ b/sc/qa/unit/data/ods/tdf87973_externalLinkSkipUnuseds.ods
Binary files differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 3d57725..054452e 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -5642,6 +5642,15 @@ void ScExportTest::testTdf87973_externalLinkSkipUnuseds()
aFormula = aFormula.replaceAt(nIdxOfFile, nIdxOfFilename - nIdxOfFile, aTempFilename);
rDoc.SetFormula(ScAddress(3, 1, 0), aFormula, formula::FormulaGrammar::GRAM_NATIVE_UI);
// tdf#138832: test the same thing with singleref link
rDoc.GetFormula(3, 2, 0, aFormula);
nIdxOfFilename = aFormula.indexOf("tdf132105_external.ods");
aFormula = aFormula.replaceAt(nIdxOfFilename, 22, "87973_externalSource.ods");
nIdxOfFile = aFormula.indexOf("file");
aFormula = aFormula.replaceAt(nIdxOfFile, nIdxOfFilename - nIdxOfFile, aTempFilename);
rDoc.SetFormula(ScAddress(3, 2, 0), aFormula, formula::FormulaGrammar::GRAM_NATIVE_UI);
// save and load back
ScDocShellRef pDocSh = saveAndReload(&(*pShell), FORMAT_XLSX);
CPPUNIT_ASSERT(pDocSh.is());
@@ -5651,6 +5660,9 @@ void ScExportTest::testTdf87973_externalLinkSkipUnuseds()
rDoc2.GetFormula(3, 1, 0, aFormula2);
CPPUNIT_ASSERT(aFormula2.indexOf("tdf132105_external.ods") < 0);
CPPUNIT_ASSERT(aFormula2.indexOf("87973_externalSource.ods") >= 0);
rDoc2.GetFormula(3, 2, 0, aFormula2);
CPPUNIT_ASSERT(aFormula2.indexOf("tdf132105_external.ods") < 0);
CPPUNIT_ASSERT(aFormula2.indexOf("87973_externalSource.ods") >= 0);
pDocSh->DoClose();
}
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 25ab7cf..f4e100c 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -5092,7 +5092,7 @@ void ScCompiler::CreateStringFromExternal( OUStringBuffer& rBuffer, const Formul
break;
case svExternalSingleRef:
pConv->makeExternalRefStr(rDoc.GetSheetLimits(),
rBuffer, GetPos(), nFileId, *pFileName, t->GetString().getString(),
rBuffer, GetPos(), nUsedFileId, *pFileName, t->GetString().getString(),
*t->GetSingleRef());
break;
case svExternalDoubleRef: