diff options
author | Eike Rathke <erack@redhat.com> | 2015-06-29 20:50:53 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2015-06-29 21:06:32 +0200 |
commit | 48d55a1b6f6ce9e38c9b48dfbbdb7231a7b66d3e (patch) | |
tree | 4cf0b212caeff3c6cd3affa62ca8ac260bb7dc1e /sc | |
parent | 50c6b545f7ca9cc034eaa17ec603b8d21cabbe2b (diff) |
support plain database range (table) names in INDIRECT
Change-Id: I89c1249315059d6a04615de27e8b9b18dfd300ff
(cherry picked from commit 81b606f547fcfc254e040937519516b98f089241)
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 568ce1fc28dc..e2255ac7a31e 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -7095,7 +7095,40 @@ void ScInterpreter::ScIndirect() } while (false); - /* TODO: simple named ranges and database ranges could be resolved. */ + do + { + OUString aName( ScGlobal::pCharClass->uppercase( sRefStr)); + ScDBCollection::NamedDBs& rDBs = pDok->GetDBCollection()->getNamedDBs(); + const ScDBData* pData = rDBs.findByUpperName( aName); + if (!pData) + break; + + ScRange aRange; + pData->GetArea( aRange); + + // In Excel, specifying a table name without [] resolves to the + // same as with [], a range that excludes header and totals + // rows and contains only data rows. Do the same. + if (pData->HasHeader()) + aRange.aStart.IncRow(); + if (pData->HasTotals()) + aRange.aEnd.IncRow(-1); + + if (aRange.aStart.Row() > aRange.aEnd.Row()) + break; + + if (aRange.aStart == aRange.aEnd) + PushSingleRef( aRange.aStart.Col(), aRange.aStart.Row(), + aRange.aStart.Tab()); + else + PushDoubleRef( aRange.aStart.Col(), aRange.aStart.Row(), + aRange.aStart.Tab(), aRange.aEnd.Col(), + aRange.aEnd.Row(), aRange.aEnd.Tab()); + + // success! + return; + } + while (false); // It may be even a TableRef. // Anything else that resolves to one reference could be added |