summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-10-27 14:39:40 +0200
committerEike Rathke <erack@redhat.com>2016-10-27 14:42:51 +0200
commit40241c2aec0e88cbb51b802bda2db458e14f792f (patch)
treec39b3ef2fa41d51e5d90cd3642993351bc181b45
parente5438e9ef75a7fdc3c8c6ba44d116f277e036d96 (diff)
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
-rw-r--r--sc/source/core/tool/address.cxx50
1 files changed, 41 insertions, 9 deletions
diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index c6138534bca9..4e4185276ab5 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);
}