summaryrefslogtreecommitdiff
path: root/sc/source/core
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/core')
-rw-r--r--sc/source/core/data/documen3.cxx6
-rw-r--r--sc/source/core/tool/dbdata.cxx42
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);