diff options
author | Jan Kantert <jan-lo@kantert.net> | 2015-02-13 14:47:31 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2015-02-13 16:29:23 +0000 |
commit | 0a9e7293a570da8a36b2ac4fd1c4a22d6bc084f2 (patch) | |
tree | 831f28135672c2f6b744783c0d7dd9dac9a7a6dd | |
parent | 92cfa66f3b8dc3a3b984632bfa4d010a235c6c50 (diff) |
tdf#89330 preserve file name case in an unresolvable external named range
Change-Id: Ib8728a4a9c793b162de07a0cef66e242879f2aa1
Reviewed-on: https://gerrit.libreoffice.org/14474
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
-rw-r--r-- | sc/inc/compiler.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/tool/compiler.cxx | 23 |
2 files changed, 21 insertions, 4 deletions
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx index 8ae1a8e56db8..6fb4b1b1ed3f 100644 --- a/sc/inc/compiler.hxx +++ b/sc/inc/compiler.hxx @@ -322,7 +322,7 @@ private: bool IsDoubleReference( const OUString& ); bool IsMacro( const OUString& ); bool IsNamedRange( const OUString& ); - bool IsExternalNamedRange( const OUString& rSymbol ); + bool IsExternalNamedRange( const OUString& rSymbol, bool& rbInvalidExternalNameRange ); bool IsDBRange( const OUString& ); bool IsColRowName( const OUString& ); bool IsBoolean( const OUString& ); diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index fee41593812c..926e56b24c65 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -2920,7 +2920,7 @@ bool ScCompiler::IsNamedRange( const OUString& rUpperName ) return false; } -bool ScCompiler::IsExternalNamedRange( const OUString& rSymbol ) +bool ScCompiler::IsExternalNamedRange( const OUString& rSymbol, bool& rbInvalidExternalNameRange ) { /* FIXME: This code currently (2008-12-02T15:41+0100 in CWS mooxlsc) * correctly parses external named references in OOo, as required per RFE @@ -2928,6 +2928,8 @@ bool ScCompiler::IsExternalNamedRange( const OUString& rSymbol ) * spec first. Until then don't pretend to support external names that * wouldn't survive a save and reload cycle, return false instead. */ + rbInvalidExternalNameRange = false; + if (!pConv) return false; @@ -2944,8 +2946,11 @@ bool ScCompiler::IsExternalNamedRange( const OUString& rSymbol ) aFile = aTmp; sal_uInt16 nFileId = pRefMgr->getExternalFileId(aFile); if (!pRefMgr->isValidRangeName(nFileId, aName)) + { + rbInvalidExternalNameRange = true; // range name doesn't exist in the source document. return false; + } const OUString* pRealName = pRefMgr->getRealRangeName(nFileId, aName); maRawToken.SetExternalName(nFileId, pRealName ? *pRealName : OUString(aTmp)); @@ -3481,7 +3486,8 @@ bool ScCompiler::NextNewToken( bool bInArray ) if (mnPredetectedReference) { OUString aStr( cSymbol); - if (!IsPredetectedReference( aStr) && !IsExternalNamedRange( aStr)) + bool bInvalidExternalNameRange; + if (!IsPredetectedReference( aStr) && !IsExternalNamedRange( aStr, bInvalidExternalNameRange )) { /* TODO: it would be nice to generate a #REF! error here, which * would need an ocBad token with additional error value. @@ -3610,8 +3616,19 @@ bool ScCompiler::NextNewToken( bool bInArray ) if (IsNamedRange( aUpper )) return true; // Preserve case of file names in external references. - if (IsExternalNamedRange( aOrg )) + bool bInvalidExternalNameRange; + if (IsExternalNamedRange( aOrg, bInvalidExternalNameRange )) + return true; + // Preserve case of file names in external references even when range + // is not valid and previous check failed tdf#89330 + if (bInvalidExternalNameRange) + { + // add ocBad but do not lowercase + svl::SharedString aSS = pDoc->GetSharedStringPool().intern(aOrg); + maRawToken.SetString(aSS.getData(), aSS.getDataIgnoreCase()); + maRawToken.NewOpCode( ocBad ); return true; + } if (IsDBRange( aUpper )) return true; // If followed by '(' (with or without space inbetween) it can not be a |