[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - sc/source

Eike Rathke erack at redhat.com
Fri Oct 28 16:39:07 UTC 2016


 sc/source/core/tool/compiler.cxx |   38 +++++++++++++++++++++++++++++++++-----
 1 file changed, 33 insertions(+), 5 deletions(-)

New commits:
commit 56d61fdfabe600cfba50d684df38701248df796f
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Oct 27 12:52:01 2016 +0200

    Resolves: tdf#103531 OOXML: write external file ID within quoted sheet names
    
    Excel expects '[1]Sheet Name' instead of [1]'Sheet Name' and complains if it
    encounters the latter.
    
    Fortunately Calc handles both.
    
    Change-Id: If1129e58725b522ca4755c05e313c03fca065f28
    (cherry picked from commit 02af87fdd76bc94fb51aeb160c74d6f719c42c63)
    Reviewed-on: https://gerrit.libreoffice.org/30324
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>

diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 3721431..f188a5a 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -1470,12 +1470,23 @@ struct ConventionXL_OOX : public ConventionXL_A1
         OUStringBuffer& rBuffer, const ScAddress& rPos, sal_uInt16 nFileId, const OUString& /*rFileName*/,
         const OUString& rTabName, const ScSingleRefData& rRef ) const override
     {
-        // [N]'Sheet Name'!$A$1
+        // '[N]Sheet Name'!$A$1 or [N]SheetName!$A$1
         // Where N is a 1-based positive integer number of a file name in OOXML
         // xl/externalLinks/externalLinkN.xml
 
-        ConventionXL_OOX::makeExternalDocStr(rBuffer, nFileId);
-        ScRangeStringConverter::AppendTableName(rBuffer, rTabName);
+        OUString aQuotedTab( rTabName);
+        ScCompiler::CheckTabQuotes( aQuotedTab);
+        if (!aQuotedTab.isEmpty() && aQuotedTab[0] == '\'')
+        {
+            rBuffer.append('\'');
+            ConventionXL_OOX::makeExternalDocStr( rBuffer, nFileId);
+            rBuffer.append( aQuotedTab.copy(1));
+        }
+        else
+        {
+            ConventionXL_OOX::makeExternalDocStr( rBuffer, nFileId);
+            rBuffer.append( aQuotedTab);
+        }
         rBuffer.append('!');
 
         makeSingleCellStr(rBuffer, rRef, rRef.toAbs(rPos));
@@ -1486,10 +1497,27 @@ struct ConventionXL_OOX : public ConventionXL_A1
         const std::vector<OUString>& rTabNames, const OUString& rTabName,
         const ScComplexRefData& rRef ) const override
     {
+        // '[N]Sheet One':'Sheet Two'!A1:B2 or [N]SheetOne!A1:B2
+        // Actually Excel writes '[N]Sheet One:Sheet Two'!A1:B2 but reads the
+        // simpler to produce and more logical form with independently quoted
+        // sheet names as well. The [N] having to be within the quoted sheet
+        // name is ugly enough..
+
         ScRange aAbsRef = rRef.toAbs(rPos);
 
-        ConventionXL_OOX::makeExternalDocStr(rBuffer, nFileId);
-        ConventionXL::makeExternalTabNameRange(rBuffer, rTabName, rTabNames, aAbsRef);
+        OUStringBuffer aBuf;
+        ConventionXL::makeExternalTabNameRange( aBuf, rTabName, rTabNames, aAbsRef);
+        if (!aBuf.isEmpty() && aBuf[0] == '\'')
+        {
+            rBuffer.append('\'');
+            ConventionXL_OOX::makeExternalDocStr( rBuffer, nFileId);
+            rBuffer.append( aBuf.copy(1));
+        }
+        else
+        {
+            ConventionXL_OOX::makeExternalDocStr( rBuffer, nFileId);
+            rBuffer.append( aBuf);
+        }
         rBuffer.append('!');
 
         makeSingleCellStr(rBuffer, rRef.Ref1, aAbsRef.aStart);


More information about the Libreoffice-commits mailing list