summaryrefslogtreecommitdiff
path: root/sc/source/core/tool/compiler.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/core/tool/compiler.cxx')
-rw-r--r--sc/source/core/tool/compiler.cxx90
1 files changed, 73 insertions, 17 deletions
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 8031f8eef87c..bfd8802edef7 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -823,7 +823,8 @@ struct ConventionOOO_A1 : public Convention_A1
return lcl_parseExternalName(rSymbol, rFile, rName, '#', pDoc, pExternalLinks);
}
- virtual OUString makeExternalNameStr( const OUString& rFile, const OUString& rName ) const SAL_OVERRIDE
+ virtual OUString makeExternalNameStr( sal_uInt16 /*nFileId*/, const OUString& rFile,
+ const OUString& rName ) const SAL_OVERRIDE
{
return lcl_makeExternalNameStr( rFile, rName, '#', false);
}
@@ -874,7 +875,7 @@ struct ConventionOOO_A1 : public Convention_A1
}
virtual void makeExternalRefStr(
- OUStringBuffer& rBuffer, const ScAddress& rPos, const OUString& rFileName,
+ OUStringBuffer& rBuffer, const ScAddress& rPos, sal_uInt16 /*nFileId*/, const OUString& rFileName,
const OUString& rTabName, const ScSingleRefData& rRef ) const SAL_OVERRIDE
{
makeExternalRefStrImpl(rBuffer, rPos, rFileName, rTabName, rRef, false);
@@ -921,7 +922,7 @@ struct ConventionOOO_A1 : public Convention_A1
}
virtual void makeExternalRefStr(
- OUStringBuffer& rBuffer, const ScAddress& rPos, const OUString& rFileName,
+ OUStringBuffer& rBuffer, const ScAddress& rPos, sal_uInt16 /*nFileId*/, const OUString& rFileName,
const std::vector<OUString>& rTabNames, const OUString& rTabName,
const ScComplexRefData& rRef ) const SAL_OVERRIDE
{
@@ -966,20 +967,21 @@ struct ConventionOOO_A1_ODF : public ConventionOOO_A1
rBuffer.append(']');
}
- virtual OUString makeExternalNameStr( const OUString& rFile, const OUString& rName ) const SAL_OVERRIDE
+ virtual OUString makeExternalNameStr( sal_uInt16 /*nFileId*/, const OUString& rFile,
+ const OUString& rName ) const SAL_OVERRIDE
{
return lcl_makeExternalNameStr( rFile, rName, '#', true);
}
virtual void makeExternalRefStr(
- OUStringBuffer& rBuffer, const ScAddress& rPos, const OUString& rFileName,
+ OUStringBuffer& rBuffer, const ScAddress& rPos, sal_uInt16 /*nFileId*/, const OUString& rFileName,
const OUString& rTabName, const ScSingleRefData& rRef ) const SAL_OVERRIDE
{
makeExternalRefStrImpl(rBuffer, rPos, rFileName, rTabName, rRef, true);
}
virtual void makeExternalRefStr(
- OUStringBuffer& rBuffer, const ScAddress& rPos, const OUString& rFileName,
+ OUStringBuffer& rBuffer, const ScAddress& rPos, sal_uInt16 /*nFileId*/, const OUString& rFileName,
const std::vector<OUString>& rTabNames,
const OUString& rTabName, const ScComplexRefData& rRef ) const SAL_OVERRIDE
{
@@ -1264,13 +1266,14 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
return ConventionXL::parseExternalName( rSymbol, rFile, rName, pDoc, pExternalLinks);
}
- virtual OUString makeExternalNameStr( const OUString& rFile, const OUString& rName ) const SAL_OVERRIDE
+ virtual OUString makeExternalNameStr( sal_uInt16 /*nFileId*/, const OUString& rFile,
+ const OUString& rName ) const SAL_OVERRIDE
{
return ConventionXL::makeExternalNameStr(rFile, rName);
}
virtual void makeExternalRefStr(
- OUStringBuffer& rBuffer, const ScAddress& rPos, const OUString& rFileName,
+ OUStringBuffer& rBuffer, const ScAddress& rPos, sal_uInt16 /*nFileId*/, const OUString& rFileName,
const OUString& rTabName, const ScSingleRefData& rRef ) const SAL_OVERRIDE
{
// ['file:///path/to/file/filename.xls']'Sheet Name'!$A$1
@@ -1287,7 +1290,7 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
}
virtual void makeExternalRefStr(
- OUStringBuffer& rBuffer, const ScAddress& rPos, const OUString& rFileName,
+ OUStringBuffer& rBuffer, const ScAddress& rPos, sal_uInt16 /*nFileId*/, const OUString& rFileName,
const std::vector<OUString>& rTabNames, const OUString& rTabName,
const ScComplexRefData& rRef ) const SAL_OVERRIDE
{
@@ -1309,6 +1312,57 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
struct ConventionXL_OOX : public ConventionXL_A1
{
ConventionXL_OOX() : ConventionXL_A1( FormulaGrammar::CONV_XL_OOX ) { }
+
+ virtual OUString makeExternalNameStr( sal_uInt16 nFileId, const OUString& /*rFile*/,
+ const OUString& rName ) const SAL_OVERRIDE
+ {
+ // [N]!DefinedName is a workbook global name.
+ return OUString( "[" + OUString::number(nFileId+1) + "]!" + rName );
+
+ /* TODO: add support for sheet local names, would be
+ * [N]'Sheet Name'!DefinedName
+ * Similar to makeExternalRefStr() but with DefinedName instead of
+ * CellStr. */
+ }
+
+ virtual void makeExternalRefStr(
+ OUStringBuffer& rBuffer, const ScAddress& rPos, sal_uInt16 nFileId, const OUString& /*rFileName*/,
+ const OUString& rTabName, const ScSingleRefData& rRef ) const SAL_OVERRIDE
+ {
+ // [N]'Sheet Name'!$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);
+ rBuffer.append('!');
+
+ makeSingleCellStr(rBuffer, rRef, rRef.toAbs(rPos));
+ }
+
+ virtual void makeExternalRefStr(
+ OUStringBuffer& rBuffer, const ScAddress& rPos, sal_uInt16 nFileId, const OUString& /*rFileName*/,
+ const std::vector<OUString>& rTabNames, const OUString& rTabName,
+ const ScComplexRefData& rRef ) const SAL_OVERRIDE
+ {
+ ScRange aAbsRef = rRef.toAbs(rPos);
+
+ ConventionXL_OOX::makeExternalDocStr(rBuffer, nFileId);
+ ConventionXL::makeExternalTabNameRange(rBuffer, rTabName, rTabNames, aAbsRef);
+ rBuffer.append('!');
+
+ makeSingleCellStr(rBuffer, rRef.Ref1, aAbsRef.aStart);
+ if (aAbsRef.aStart != aAbsRef.aEnd)
+ {
+ rBuffer.append(':');
+ makeSingleCellStr(rBuffer, rRef.Ref2, aAbsRef.aEnd);
+ }
+ }
+
+ static void makeExternalDocStr( OUStringBuffer& rBuffer, sal_uInt16 nFileId )
+ {
+ rBuffer.append('[').append( OUString::number( nFileId+1)).append(']');
+ }
};
static void
@@ -1438,13 +1492,14 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
return ConventionXL::parseExternalName( rSymbol, rFile, rName, pDoc, pExternalLinks);
}
- virtual OUString makeExternalNameStr( const OUString& rFile, const OUString& rName ) const SAL_OVERRIDE
+ virtual OUString makeExternalNameStr( sal_uInt16 /*nFileId*/, const OUString& rFile,
+ const OUString& rName ) const SAL_OVERRIDE
{
return ConventionXL::makeExternalNameStr(rFile, rName);
}
virtual void makeExternalRefStr(
- OUStringBuffer& rBuffer, const ScAddress& rPos, const OUString& rFileName,
+ OUStringBuffer& rBuffer, const ScAddress& rPos, sal_uInt16 /*nFileId*/, const OUString& rFileName,
const OUString& rTabName, const ScSingleRefData& rRef ) const SAL_OVERRIDE
{
// ['file:///path/to/file/filename.xls']'Sheet Name'!$A$1
@@ -1463,7 +1518,7 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
}
virtual void makeExternalRefStr(
- OUStringBuffer& rBuffer, const ScAddress& rPos, const OUString& rFileName,
+ OUStringBuffer& rBuffer, const ScAddress& rPos, sal_uInt16 /*nFileId*/, const OUString& rFileName,
const std::vector<OUString>& rTabNames, const OUString& rTabName,
const ScComplexRefData& rRef ) const SAL_OVERRIDE
{
@@ -4082,30 +4137,31 @@ bool ScCompiler::IsCharFlagAllConventions(
void ScCompiler::CreateStringFromExternal(OUStringBuffer& rBuffer, FormulaToken* pTokenP) const
{
FormulaToken* t = pTokenP;
+ sal_uInt16 nFileId = t->GetIndex();
ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager();
- const OUString* pFileName = pRefMgr->getExternalFileName(t->GetIndex());
+ const OUString* pFileName = pRefMgr->getExternalFileName(nFileId);
if (!pFileName)
return;
switch (t->GetType())
{
case svExternalName:
- rBuffer.append(pConv->makeExternalNameStr(*pFileName, t->GetString().getString()));
+ rBuffer.append(pConv->makeExternalNameStr( nFileId, *pFileName, t->GetString().getString()));
break;
case svExternalSingleRef:
pConv->makeExternalRefStr(
- rBuffer, GetPos(), *pFileName, t->GetString().getString(),
+ rBuffer, GetPos(), nFileId, *pFileName, t->GetString().getString(),
static_cast<ScToken*>(t)->GetSingleRef());
break;
case svExternalDoubleRef:
{
vector<OUString> aTabNames;
- pRefMgr->getAllCachedTableNames(t->GetIndex(), aTabNames);
+ pRefMgr->getAllCachedTableNames(nFileId, aTabNames);
if (aTabNames.empty())
return;
pConv->makeExternalRefStr(
- rBuffer, GetPos(), *pFileName, aTabNames, t->GetString().getString(),
+ rBuffer, GetPos(), nFileId, *pFileName, aTabNames, t->GetString().getString(),
static_cast<ScToken*>(t)->GetDoubleRef());
}
break;