diff options
author | Eike Rathke <erack@redhat.com> | 2015-09-02 19:31:29 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2015-09-03 00:09:02 +0200 |
commit | 834eddc8f75fa73b36f3ab5804104829809d8949 (patch) | |
tree | 26714708f1763c4e32cdff7b868a16f3277a5604 /sc/source/core | |
parent | 1cb61611c2308df86bf9acfafe25faff624dad26 (diff) |
TableRef: add RefreshTableColumnNames() from range
Change-Id: I32a47e306469aec5fe366a6621129e14b0d49c13
Diffstat (limited to 'sc/source/core')
-rw-r--r-- | sc/source/core/data/documen3.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/tool/dbdata.cxx | 42 |
2 files changed, 48 insertions, 0 deletions
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx index 32791dab34d1..53dff9231cb8 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -313,6 +313,12 @@ ScDBData* ScDocument::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nC return NULL; } +void ScDocument::RefreshTableColumnNames( const ScRange& rRange ) +{ + if (pDBCollection) + pDBCollection->RefreshTableColumnNames( rRange); +} + bool ScDocument::HasPivotTable() const { return pDPCollection && pDPCollection->GetCount(); diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx index 825e6ca51124..cf86a1e67d2f 100644 --- a/sc/source/core/tool/dbdata.cxx +++ b/sc/source/core/tool/dbdata.cxx @@ -728,6 +728,42 @@ void ScDBData::RefreshTableColumnNames( ScDocument* pDoc ) aNewNames.swap( maTableColumnNames); } +void ScDBData::RefreshTableColumnNames( ScDocument* pDoc, const ScRange& rRange ) +{ + if (!HasHeader()) + return; + + ScRange aRange( ScAddress::UNINITIALIZED); + GetArea( aRange); + aRange.aEnd.SetRow( aRange.aStart.Row()); + ScRange aIntersection( aRange.Intersection( rRange)); + if (!aIntersection.IsValid()) + return; + + if (maTableColumnNames.empty()) + { + RefreshTableColumnNames( pDoc); + return; + } + + // Update column names from cells in intersecting header range, but don't + // set names to empty string. + ScHorizontalCellIterator aIter( pDoc, nTable, + aIntersection.aStart.Col(), nStartRow, aIntersection.aEnd.Col(), nStartRow); + ScRefCellValue* pCell; + SCCOL nCol; + SCROW nRow; + for (size_t i=0; (pCell = aIter.GetNext( nCol, nRow)) != nullptr; ++i) + { + if (pCell->hasString()) + { + const OUString& rStr = pCell->getString( pDoc); + if (!rStr.isEmpty()) + maTableColumnNames[nCol-nStartCol] = rStr; + } + } +} + sal_Int32 ScDBData::GetColumnNameOffset( const OUString& rName ) const { if (maTableColumnNames.empty()) @@ -1173,6 +1209,12 @@ ScDBData* ScDBCollection::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCO return NULL; } +void ScDBCollection::RefreshTableColumnNames( const ScRange& rRange ) +{ + for (auto const& it : maNamedDBs) + it->RefreshTableColumnNames( pDoc, rRange); +} + void ScDBCollection::DeleteOnTab( SCTAB nTab ) { FindByTable func(nTab); |