summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-04-29 15:56:24 +0200
committerEike Rathke <erack@redhat.com>2016-04-30 00:30:31 +0200
commit450a10d5fb193ec2a7d85ae604790b9dda1e3602 (patch)
treeca5dd34884d3aa01d7a52de3d7d7322c2deac97c /sc
parent17f4fc71164a1440e6805221fee19fae322129b9 (diff)
introduce ScRangeName::CopyUsedNames()
Change-Id: I2f3e88f70e5d7b9b4728f5bdd0a8237c7bcc7dcb
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/rangenam.hxx20
-rw-r--r--sc/source/core/tool/rangenam.cxx16
2 files changed, 36 insertions, 0 deletions
diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx
index c3fff07dde55..a7a5aa81ccd3 100644
--- a/sc/inc/rangenam.hxx
+++ b/sc/inc/rangenam.hxx
@@ -213,6 +213,26 @@ public:
*/
void CompileUnresolvedXML( sc::CompileFormulaContext& rCxt );
+ /** Copy names while copying a sheet if they reference the sheet to be copied.
+
+ Assumes that new sheet was already inserted, global names have been
+ updated/adjusted, but sheet-local names on nOldTab are not, as is the
+ case in ScDocument::CopyTab()
+
+ @param nLocalTab
+ -1 when operating on global names, else sheet/tab of
+ sheet-local name scope. The already adjusted tab on which to
+ find the name.
+
+ @param nOldTab
+ The original unadjusted tab position.
+
+ @param nNewTab
+ The new tab position.
+ */
+ void CopyUsedNames( const SCTAB nLocalTab, const SCTAB nOldTab, const SCTAB nNewTab,
+ const ScDocument& rOldDoc, ScDocument& rNewDoc, const bool bGlobalNamesToLocal ) const;
+
SC_DLLPUBLIC const_iterator begin() const;
SC_DLLPUBLIC const_iterator end() const;
SC_DLLPUBLIC iterator begin();
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index a9ab515d99cc..89500acb0d62 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -785,6 +785,22 @@ void ScRangeName::CompileUnresolvedXML( sc::CompileFormulaContext& rCxt )
}
}
+void ScRangeName::CopyUsedNames( const SCTAB nLocalTab, const SCTAB nOldTab, const SCTAB nNewTab,
+ const ScDocument& rOldDoc, ScDocument& rNewDoc, const bool bGlobalNamesToLocal ) const
+{
+ for (auto const& itr : m_Data)
+ {
+ SCTAB nSheet = (nLocalTab < 0) ? nLocalTab : nOldTab;
+ sal_uInt16 nIndex = itr.second->GetIndex();
+ ScAddress aOldPos( itr.second->GetPos());
+ aOldPos.SetTab( nOldTab);
+ ScAddress aNewPos( aOldPos);
+ aNewPos.SetTab( nNewTab);
+ ScRangeData* pRangeData = nullptr;
+ rOldDoc.CopyAdjustRangeName( nSheet, nIndex, pRangeData, rNewDoc, aNewPos, aOldPos, bGlobalNamesToLocal);
+ }
+}
+
ScRangeName::const_iterator ScRangeName::begin() const
{
return m_Data.begin();