summaryrefslogtreecommitdiff
path: root/sc/source/core/tool/token.cxx
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-03-24 16:23:59 +0100
committerEike Rathke <erack@redhat.com>2016-03-24 17:02:56 +0100
commitccabf4a408a246a931011732a5711e3b5334b17f (patch)
tree3c015024142169eff2edbcde68cf13f2e489a5ac /sc/source/core/tool/token.cxx
parent18cce14dd6389bd67e6c8311ebac8a6d7241a1ee (diff)
tdf#75372 rework sheet-copy names for converting global names to sheet-local
This during copying a sheet copies global names that from a copied formula cell reference the copied sheet and converts the copied global names to sheet-local names. References to the original sheet are updated to point to the new sheet. It works for names used in formula cells copied but needs enhancement to pick up nested names, i.e. names used in names that do not reference the sheet but the nested name does. Change-Id: I1aa16cb28c9f7b3581bec289435492c21e6fcd73
Diffstat (limited to 'sc/source/core/tool/token.cxx')
-rw-r--r--sc/source/core/tool/token.cxx50
1 files changed, 50 insertions, 0 deletions
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index f5e32879120b..a8f27bf77293 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2523,6 +2523,56 @@ void ScTokenArray::AdjustSheetLocalNameReferences( SCTAB nOldTab, SCTAB nNewTab
}
}
+bool ScTokenArray::ReferencesSheet( SCTAB nTab, SCTAB nPosTab ) const
+{
+ TokenPointers aPtrs( pCode, nLen, pRPN, nRPN, false);
+ for (size_t j=0; j<2; ++j)
+ {
+ FormulaToken** pp = aPtrs.maPointerRange[j].mpStart;
+ FormulaToken** pEnd = aPtrs.maPointerRange[j].mpStop;
+ for (; pp != pEnd; ++pp)
+ {
+ FormulaToken* p = aPtrs.getHandledToken(j,pp);
+ if (!p)
+ continue;
+
+ switch ( p->GetType() )
+ {
+ case svDoubleRef :
+ {
+ ScComplexRefData& rRef = *p->GetDoubleRef();
+ ScSingleRefData& rRef2 = rRef.Ref2;
+ ScSingleRefData& rRef1 = rRef.Ref1;
+
+ SCTAB nTab1 = (rRef1.IsTabRel() ? rRef1.Tab() + nPosTab : rRef1.Tab());
+ SCTAB nTab2 = (rRef2.IsTabRel() ? rRef2.Tab() + nPosTab : rRef2.Tab());
+ if (nTab1 <= nTab && nTab <= nTab2)
+ return true;
+ }
+ break;
+ case svSingleRef :
+ {
+ ScSingleRefData& rRef = *p->GetSingleRef();
+ if (rRef.IsTabRel())
+ {
+ if (rRef.Tab() + nPosTab == nTab)
+ return true;
+ }
+ else
+ {
+ if (rRef.Tab() == nTab)
+ return true;
+ }
+ }
+ break;
+ default:
+ ;
+ }
+ }
+ }
+ return false;
+}
+
namespace {
ScRange getSelectedRange( const sc::RefUpdateContext& rCxt )