[Libreoffice-commits] core.git: sc/inc sc/source

Jan Kantert jan-lo at kantert.net
Fri Feb 13 08:29:53 PST 2015


 sc/inc/compiler.hxx              |    2 +-
 sc/source/core/tool/compiler.cxx |   23 ++++++++++++++++++++---
 2 files changed, 21 insertions(+), 4 deletions(-)

New commits:
commit 0a9e7293a570da8a36b2ac4fd1c4a22d6bc084f2
Author: Jan Kantert <jan-lo at kantert.net>
Date:   Fri Feb 13 14:47:31 2015 +0100

    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 at redhat.com>
    Tested-by: Eike Rathke <erack at redhat.com>

diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 8ae1a8e..6fb4b1b 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 fee4159..926e56b 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


More information about the Libreoffice-commits mailing list