Kaydet (Commit) d7794792 authored tarafından Eike Rathke's avatar Eike Rathke

TableRef: generate error for header-less column references, tdf#91278 related

... instead of using an arbitray first data record's string as column
name. We don't support header-less tables properly yet, so don't pretend
to.

Change-Id: Ia42619ec800291b6617a61c8a89a2d54ef231cec
üst 22c9977d
...@@ -3517,6 +3517,8 @@ bool ScCompiler::IsTableRefColumn( const OUString& rName ) const ...@@ -3517,6 +3517,8 @@ bool ScCompiler::IsTableRefColumn( const OUString& rName ) const
aRange.aEnd.SetTab( aRange.aStart.Tab()); aRange.aEnd.SetTab( aRange.aStart.Tab());
aRange.aEnd.SetRow( aRange.aStart.Row()); aRange.aEnd.SetRow( aRange.aStart.Row());
if (pDBData->HasHeader())
{
// Quite similar to IsColRowName() but limited to one row of headers. // Quite similar to IsColRowName() but limited to one row of headers.
ScCellIterator aIter( pDoc, aRange); ScCellIterator aIter( pDoc, aRange);
for (bool bHas = aIter.first(); bHas; bHas = aIter.next()) for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
...@@ -3549,6 +3551,7 @@ bool ScCompiler::IsTableRefColumn( const OUString& rName ) const ...@@ -3549,6 +3551,7 @@ bool ScCompiler::IsTableRefColumn( const OUString& rName ) const
} }
} }
} }
}
// And now a fallback for named expressions during document load time when // And now a fallback for named expressions during document load time when
// cell content isn't available yet. This could be the preferred method IF // cell content isn't available yet. This could be the preferred method IF
...@@ -3556,12 +3559,27 @@ bool ScCompiler::IsTableRefColumn( const OUString& rName ) const ...@@ -3556,12 +3559,27 @@ bool ScCompiler::IsTableRefColumn( const OUString& rName ) const
// operations, including cell content changes. // operations, including cell content changes.
sal_Int32 nOffset = pDBData->GetColumnNameOffset( aName); sal_Int32 nOffset = pDBData->GetColumnNameOffset( aName);
if (nOffset >= 0) if (nOffset >= 0)
{
if (pDBData->HasHeader())
{ {
ScSingleRefData aRef; ScSingleRefData aRef;
ScAddress aAdr( aRange.aStart); ScAddress aAdr( aRange.aStart);
aAdr.IncCol( nOffset); aAdr.IncCol( nOffset);
aRef.InitAddress( aAdr); aRef.InitAddress( aAdr);
maRawToken.SetSingleReference( aRef ); maRawToken.SetSingleReference( aRef );
}
else
{
/* TODO: this probably needs a new token type to hold offset and
* name, to be handled in HandleTableRef(). We can't use a
* reference token here because any reference would be wrong as
* there are no header cells to be referenced. However, it would
* only work as long as the ScDBData column names are not
* invalidated during document structure changes, otherwise
* recompiling the same formula could not resolve the name again.
* As long as this doesn't work generate an error. */
return false;
}
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment