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

Eike Rathke erack at redhat.com
Thu Oct 27 12:43:12 UTC 2016


 sc/source/core/tool/address.cxx |   50 ++++++++++++++++++++++++++++++++--------
 1 file changed, 41 insertions(+), 9 deletions(-)

New commits:
commit 40241c2aec0e88cbb51b802bda2db458e14f792f
Author: Eike Rathke <erack at redhat.com>
Date:   Thu Oct 27 14:39:40 2016 +0200

    sc: OOXML: range with file ID within quoted sheet name, tdf#103531 related
    
    Wherever non-formula-expression ranges with external document reference might
    be used in OOXML, format ScAddress/ScRange as '[1]Sheet Name' instead of
    [1]'Sheet Name' as Excel expects them.
    
    Change-Id: Ia7be13f4d631405e4bcb4617fbded27586fa5dcd

diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index c613853..4e41852 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -2050,9 +2050,25 @@ template<typename T > inline void lcl_Format( T& r, SCTAB nTab, SCROW nRow, SCCO
                 r.append(".");
                 break;
 
+            case formula::FormulaGrammar::CONV_XL_OOX:
+                if (!aTabName.isEmpty() && aTabName[0] == '\'')
+                {
+                    if (!aDocName.isEmpty())
+                    {
+                        lcl_string_append(r.append("'["), aDocName);
+                        r.append("]");
+                        lcl_string_append(r, aTabName.copy(1));
+                    }
+                    else
+                    {
+                        lcl_string_append(r, aTabName);
+                    }
+                    r.append("!");
+                    break;
+                }
+                SAL_FALLTHROUGH;
             case formula::FormulaGrammar::CONV_XL_A1:
             case formula::FormulaGrammar::CONV_XL_R1C1:
-            case formula::FormulaGrammar::CONV_XL_OOX:
                 if (!aDocName.isEmpty())
                 {
                     lcl_string_append(r.append("["), aDocName);
@@ -2136,18 +2152,34 @@ static void lcl_ScRange_Format_XL_Header( OUStringBuffer& rString, const ScRange
     if( nFlags & ScRefFlags::TAB_3D )
     {
         OUString aTabName, aDocName;
-        lcl_Split_DocTab( pDoc, rRange.aStart.Tab(), rDetails, nFlags,
-                          aTabName, aDocName );
-        if( !aDocName.isEmpty() )
+        lcl_Split_DocTab( pDoc, rRange.aStart.Tab(), rDetails, nFlags, aTabName, aDocName );
+        switch (rDetails.eConv)
         {
-            rString.append("[").append(aDocName).append("]");
+            case formula::FormulaGrammar::CONV_XL_OOX:
+                if (!aTabName.isEmpty() && aTabName[0] == '\'')
+                {
+                    if (!aDocName.isEmpty())
+                    {
+                        rString.append("'[").append(aDocName).append("]").append(aTabName.copy(1));
+                    }
+                    else
+                    {
+                        rString.append(aTabName);
+                    }
+                    break;
+                }
+                SAL_FALLTHROUGH;
+            default:
+                if (!aDocName.isEmpty())
+                {
+                    rString.append("[").append(aDocName).append("]");
+                }
+                rString.append(aTabName);
+            break;
         }
-        rString.append(aTabName);
-
         if( nFlags & ScRefFlags::TAB2_3D )
         {
-            lcl_Split_DocTab( pDoc, rRange.aEnd.Tab(), rDetails, nFlags,
-                              aTabName, aDocName );
+            lcl_Split_DocTab( pDoc, rRange.aEnd.Tab(), rDetails, nFlags, aTabName, aDocName );
             rString.append(":");
             rString.append(aTabName);
         }


More information about the Libreoffice-commits mailing list