diff options
author | Eike Rathke <erack@redhat.com> | 2022-09-06 13:48:29 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2022-09-06 15:40:59 +0200 |
commit | 64f673238cf9b645a751e8f8137ca14e595a779a (patch) | |
tree | 0b853fa52978a2b853234fad471b18720fc9523f | |
parent | 9a193c81f735771796a347cb4d545b8d277c0625 (diff) |
A ColRowName (label) is a QuotedLabel is a SingleQuoted
Hence a ' is not escaped by \' but by '' doubling it.
See also ODFF 5.10 Quoted Label
https://docs.oasis-open.org/office/OpenDocument/v1.3/os/part4-formula/OpenDocument-v1.3-os-part4-formula.html#__RefHeading__1017950_715980110
Apparently this was always wrong and even stored in files and
never correctly read/compiled back.
Change-Id: I94bdb7d1fdffe9bbd77cf443883dd76637be981b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139491
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
-rw-r--r-- | formula/source/core/api/FormulaCompiler.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/tool/compiler.cxx | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index 3f41b2196bcf..6684fd17da47 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -1203,7 +1203,7 @@ bool FormulaCompiler::DeQuote( OUString& rStr ) if ( nLen > 1 && rStr[0] == '\'' && rStr[ nLen-1 ] == '\'' ) { rStr = rStr.copy( 1, nLen-2 ); - rStr = rStr.replaceAll( "\\\'", "\'" ); + rStr = rStr.replaceAll( "''", "'" ); return true; } return false; diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index de4cb870861e..550354d6b8f4 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -5357,13 +5357,13 @@ void ScCompiler::CreateStringFromSingleRef( OUStringBuffer& rBuffer, const Formu OUString aStr = rDoc.GetString(aAbs, mpInterpreterContext); // If string contains only numeric characters or if it contains non-alphanumeric characters - // -> quote characters contained within are escaped by '\\'. + // -> quote characters contained within are escaped by ''. // -> put quotes around string sal_Int32 nType = ScGlobal::getCharClass().getStringType( aStr, 0, aStr.getLength() ); if ( CharClass::isNumericType( nType ) || !CharClass::isAlphaNumericType( nType ) ) { - aStr = aStr.replaceAll(u"'", u"\\'"); + aStr = aStr.replaceAll(u"'", u"''"); aStr = "'" + aStr + "'"; } rBuffer.append(aStr); |