sc/inc/dbdata.hxx | 3 +++ sc/source/core/tool/compiler.cxx | 7 +++++++ sc/source/core/tool/dbdata.cxx | 14 ++++++++++++-- 3 files changed, 22 insertions(+), 2 deletions(-)
New commits: commit 0c1d3f0c17296c113358228cf36596347fd045e3 Author: Eike Rathke <er...@redhat.com> Date: Tue Sep 1 01:04:49 2015 +0200 remove now moot comment Change-Id: Idf8c958161a92ba73dfb60da9a10ab9d59be7c2d diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx index 17f59e1..46b9b2f 100644 --- a/sc/source/core/tool/dbdata.cxx +++ b/sc/source/core/tool/dbdata.cxx @@ -653,8 +653,6 @@ void ScDBData::RefreshTableColumnNames( ScDocument* pDoc ) // Try to not have empty names and remember previous name that might had // been used to compile formulas, but only if same number of columns and no // duplicates. - /* TODO: formula references' create string should be adapted to look for - * the column name here if the TableRef column header cell is empty. */ if (bHaveEmpty && aNewNames.size() == maTableColumnNames.size()) { for (size_t i=0, n=aNewNames.size(); i < n; ++i) commit e14c72954ec5b00557647cb1ec167d33828085cc Author: Eike Rathke <er...@redhat.com> Date: Tue Sep 1 00:56:34 2015 +0200 TableRef: fall back to stored table column name if header cell is empty ... during token string creation, as an empty column specifier is the last thing we want to see.. which still can happen though if the stored name was synced with the existing cell data and copying the older original name was not possible, for example due to name clashes. Change-Id: I6a0d313a02efafc092f0bbf7725fb3b3e77e486f diff --git a/sc/inc/dbdata.hxx b/sc/inc/dbdata.hxx index bacf099..967ba30 100644 --- a/sc/inc/dbdata.hxx +++ b/sc/inc/dbdata.hxx @@ -126,6 +126,9 @@ public: */ sal_Int32 GetColumnNameOffset( const OUString& rName ) const; + /** Returns table column name if nCol is within column range and name + is stored, else empty string. */ + const OUString& GetTableColumnName( SCCOL nCol ) const; OUString GetSourceString() const; OUString GetOperations() const; diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index 1adfaba..5aa34b3 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -4702,6 +4702,13 @@ void ScCompiler::CreateStringFromSingleRef( OUStringBuffer& rBuffer, const Formu { ScAddress aAbs = rRef.toAbs(aPos); OUString aStr = pDoc->GetString(aAbs); + if (aStr.isEmpty()) + { + // Hope that there's still the original column name available. + const ScDBData* pData = pDoc->GetDBAtCursor( aPos.Col(), aPos.Row(), aPos.Tab(), true); + if (pData) + aStr = pData->GetTableColumnName( aPos.Col()); + } escapeTableRefColumnSpecifier( aStr); rBuffer.append(aStr); } diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx index d87351d..17f59e1 100644 --- a/sc/source/core/tool/dbdata.cxx +++ b/sc/source/core/tool/dbdata.cxx @@ -712,6 +712,18 @@ sal_Int32 ScDBData::GetColumnNameOffset( const OUString& rName ) const return -1; } +const OUString& ScDBData::GetTableColumnName( SCCOL nCol ) const +{ + if (maTableColumnNames.empty()) + return EMPTY_OUSTRING; + + SCCOL nOffset = nCol - nStartCol; + if (nOffset < 0 || maTableColumnNames.size() <= static_cast<size_t>(nOffset)) + return EMPTY_OUSTRING; + + return maTableColumnNames[nOffset]; +} + namespace { class FindByTable : public unary_function<std::unique_ptr<ScDBData>, bool> _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits