summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2022-09-08 20:55:03 +0200
committerEike Rathke <erack@redhat.com>2022-09-09 16:00:54 +0200
commit5a1bd80e0d685bbd76de2ebfaa1c6b0380d528f4 (patch)
treee073a5c6c349bf2ff94a5b0fcd792fed6be35c9a
parent6afb3232d32f1ebad0cefb94c145922e217526bd (diff)
Related: tdf#150312 "Repair" broken table:base-cell-address of defined names
... to not lose them entirely, though this may shift relative addressing, which may be equally bad because there is no indication and can go unnoticed. Most defined ranges use absolute addressing though and formula expressions are rarely affected. Change-Id: If57ff9274e673a4eb43c656698f6ed43e8415458 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139706 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins
-rw-r--r--sc/source/filter/xml/xmlimprt.cxx21
1 files changed, 17 insertions, 4 deletions
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index b72cf35ffcf1..5f654392c478 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -1258,10 +1258,11 @@ class RangeNameInserter
{
ScDocument& mrDoc;
ScRangeName& mrRangeName;
+ SCTAB mnTab;
public:
- RangeNameInserter(ScDocument& rDoc, ScRangeName& rRangeName) :
- mrDoc(rDoc), mrRangeName(rRangeName) {}
+ RangeNameInserter(ScDocument& rDoc, ScRangeName& rRangeName, SCTAB nTab) :
+ mrDoc(rDoc), mrRangeName(rRangeName), mnTab(nTab) {}
void operator() (const ScMyNamedExpression& p) const
{
@@ -1282,6 +1283,17 @@ public:
bool bSuccess = ScRangeStringConverter::GetAddressFromString(
aPos, p.sBaseCellAddress, mrDoc, FormulaGrammar::CONV_OOO, nOffset);
+ if (!bSuccess)
+ {
+ SAL_WARN("sc.filter", "No conversion from table:base-cell-address '" << p.sBaseCellAddress
+ << "' for name '" << p.sName << "' on sheet " << mnTab);
+ // Do not lose the defined name. Relative addressing in
+ // content/expression, if any, will be broken though.
+ // May had happened due to tdf#150312.
+ aPos.SetTab(mnTab < 0 ? 0 : mnTab);
+ bSuccess = true;
+ }
+
if (bSuccess)
{
OUString aContent = p.sContent;
@@ -1307,7 +1319,8 @@ void ScXMLImport::SetNamedRanges()
// Insert the namedRanges
ScRangeName* pRangeNames = pDoc->GetRangeName();
- ::std::for_each(m_aMyNamedExpressions.begin(), m_aMyNamedExpressions.end(), RangeNameInserter(*pDoc, *pRangeNames));
+ ::std::for_each(m_aMyNamedExpressions.begin(), m_aMyNamedExpressions.end(),
+ RangeNameInserter(*pDoc, *pRangeNames, -1));
}
void ScXMLImport::SetSheetNamedRanges()
@@ -1323,7 +1336,7 @@ void ScXMLImport::SetSheetNamedRanges()
continue;
const ScMyNamedExpressions& rNames = itr.second;
- ::std::for_each(rNames.begin(), rNames.end(), RangeNameInserter(*pDoc, *pRangeNames));
+ ::std::for_each(rNames.begin(), rNames.end(), RangeNameInserter(*pDoc, *pRangeNames, nTab));
}
}