sc/source/filter/oox/defnamesbuffer.cxx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
New commits: commit 7ce206f88f04bdc422253c428a746adbaf5e16e8 Author: Eike Rathke <er...@redhat.com> AuthorDate: Thu Feb 27 18:19:56 2025 +0100 Commit: Adolfo Jayme Barrientos <fit...@ubuntu.com> CommitDate: Sat Mar 1 14:12:40 2025 +0100 Resolves: tdf#164895 Fix OOXML global names import without sheet reference ... like it's often the case in named expressions. Wonder why that didn't pop up earlier.. Change-Id: Ie9d2b8642848981f420e45c6ede995f86e062903 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182318 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Jenkins (cherry picked from commit 23a9d6f069039fb8032362e00fbe42dea4ffb125) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182358 Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> diff --git a/sc/source/filter/oox/defnamesbuffer.cxx b/sc/source/filter/oox/defnamesbuffer.cxx index 06a6ec114787..78a186f46ffd 100644 --- a/sc/source/filter/oox/defnamesbuffer.cxx +++ b/sc/source/filter/oox/defnamesbuffer.cxx @@ -270,7 +270,12 @@ bool DefinedName::isValid( std::unique_ptr<ScTokenArray> DefinedName::getScTokens( const css::uno::Sequence<css::sheet::ExternalLinkInfo>& rExternalLinks ) { - ScCompiler aCompiler(getScDocument(), ScAddress(0, 0, mnCalcSheet), formula::FormulaGrammar::GRAM_OOXML); + // mnCalcSheet < 0 means global name and results in tab deleted when + // compiling a reference without sheet reference. For a global name it + // doesn't really matter which sheet is the position's default sheet if the + // reference doesn't specify any. tdf#164895 + ScCompiler aCompiler(getScDocument(), ScAddress(0, 0, (mnCalcSheet < 0 ? 0 : mnCalcSheet)), + formula::FormulaGrammar::GRAM_OOXML); aCompiler.SetExternalLinks( rExternalLinks); std::unique_ptr<ScTokenArray> pArray(aCompiler.CompileString(maModel.maFormula)); // Compile the tokens into RPN once to populate information into tokens