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
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx
index 3f41b21..6684fd1 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 de4cb87..550354d 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);