diff options
author | Eike Rathke <erack@redhat.com> | 2015-04-22 23:16:04 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2015-04-23 15:18:02 +0200 |
commit | ce287a872ef435a207d4c22ddcccc60963165376 (patch) | |
tree | 271ff5c2deef146186aa009f15c67231226763e4 /sc | |
parent | e9646512e62b9f74bd82307d054a6739cb4ac0d3 (diff) |
TableRef: proper unescapeTableRefColumnSpecifier()
Change-Id: Id3b0a776f85b36c399a818ec1575a63ba250e318
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/tool/compiler.cxx | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index 19a073983825..bec4b2ec1318 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -3363,6 +3363,36 @@ bool ScCompiler::IsTableRefItem( const OUString& rName ) const return bItem; } +namespace { +OUString unescapeTableRefColumnSpecifier( const OUString& rStr ) +{ + // '#', '[', ']' and '\'' are escaped with '\'' + + if (rStr.indexOf( '\'' ) < 0) + return rStr; + + const sal_Int32 n = rStr.getLength(); + OUStringBuffer aBuf( n ); + const sal_Unicode* p = rStr.getStr(); + const sal_Unicode* const pStop = p + n; + bool bEscaped = false; + for ( ; p < pStop; ++p) + { + const sal_Unicode c = *p; + if (bEscaped) + { + aBuf.append( c ); + bEscaped = false; + } + else if (c == '\'') + bEscaped = true; // unescaped escaping '\'' + else + aBuf.append( c ); + } + return aBuf.makeStringAndClear(); +} +} + bool ScCompiler::IsTableRefColumn( const OUString& rName ) const { // Only called when there actually is a current TableRef, hence @@ -3374,8 +3404,7 @@ bool ScCompiler::IsTableRefColumn( const OUString& rName ) const if (!pDBData) return false; - // '#', '[', ']' and '\'' are escaped with '\'' - OUString aName( rName.replaceAll( OUString("'"), OUString())); + OUString aName( unescapeTableRefColumnSpecifier( rName)); ScRange aRange; pDBData->GetArea( aRange); |