Commits

Anonymous committed 8348336

CWS-TOOLING: integrate CWS calcsheetref_DEV300
2009-03-30 17:47:46 +0200 er r270250 : #i100681# correctly quote sheet names

Comments (0)

Files changed (1)

sc/source/core/tool/rangeutl.cxx

 #include "globstr.hrc"
 #include "convuno.hxx"
 #include "externalrefmgr.hxx"
+#include "compiler.hxx"
 
 using ::rtl::OUString;
 using ::rtl::OUStringBuffer;
 	}
 }
 
-void ScRangeStringConverter::AppendTableName(OUStringBuffer& rBuf, const OUString& rTabName, sal_Unicode cQuote)
+void ScRangeStringConverter::AppendTableName(OUStringBuffer& rBuf, const OUString& rTabName, sal_Unicode /* cQuote */)
 {
-    bool bQuoted = rTabName.indexOf(sal_Unicode(' '), 0) >= 0;
-    if (bQuoted)
-        rBuf.append(cQuote);
-    rBuf.append(rTabName);
-    if (bQuoted)
-        rBuf.append(cQuote);
+    // quote character is always "'"
+    String aQuotedTab(rTabName);
+    ScCompiler::CheckTabQuotes(aQuotedTab, ::formula::FormulaGrammar::CONV_OOO);
+    rBuf.append(aQuotedTab);
 }
 
 sal_Int32 ScRangeStringConverter::GetTokenCount( const OUString& rString, sal_Unicode cSeperator, sal_Unicode cQuote )
         rBuf.append(cQuote);
         rBuf.append(sal_Unicode('#'));
         rBuf.append(sal_Unicode('$'));
-        rBuf.append(rExtInfo1.maTabName);
+        ScRangeStringConverter::AppendTableName(rBuf, rExtInfo1.maTabName);
         rBuf.append(sal_Unicode('.'));
 
         String aAddr;
         if (rExtInfo1.maTabName != rExtInfo2.maTabName)
         {
             rBuf.append(sal_Unicode('$'));
-            rBuf.append(rExtInfo2.maTabName);
+            ScRangeStringConverter::AppendTableName(rBuf, rExtInfo2.maTabName);
             rBuf.append(sal_Unicode('.'));
         }