[Libreoffice-commits] core.git: 4 commits - offapi/com sc/source
Eike Rathke
erack at redhat.com
Thu Jul 23 05:34:27 PDT 2015
offapi/com/sun/star/sheet/DatabaseRange.idl | 7 ++
sc/source/core/tool/compiler.cxx | 78 +++++++++++++++++-----------
sc/source/filter/oox/tablebuffer.cxx | 9 +++
sc/source/ui/unoobj/datauno.cxx | 9 +++
4 files changed, 73 insertions(+), 30 deletions(-)
New commits:
commit d77947929c7f02cebe3d3e5d79c78642a8a439ba
Author: Eike Rathke <erack at redhat.com>
Date: Thu Jul 23 14:29:20 2015 +0200
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
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 901261b..dc46edb 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -3517,35 +3517,38 @@ bool ScCompiler::IsTableRefColumn( const OUString& rName ) const
aRange.aEnd.SetTab( aRange.aStart.Tab());
aRange.aEnd.SetRow( aRange.aStart.Row());
- // Quite similar to IsColRowName() but limited to one row of headers.
- ScCellIterator aIter( pDoc, aRange);
- for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
+ if (pDBData->HasHeader())
{
- CellType eType = aIter.getType();
- bool bOk = false;
- if (eType == CELLTYPE_FORMULA)
+ // Quite similar to IsColRowName() but limited to one row of headers.
+ ScCellIterator aIter( pDoc, aRange);
+ for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
{
- ScFormulaCell* pFC = aIter.getFormulaCell();
- bOk = (pFC->GetCode()->GetCodeLen() > 0) && (pFC->aPos != aPos);
- }
- else
- bOk = true;
+ CellType eType = aIter.getType();
+ bool bOk = false;
+ if (eType == CELLTYPE_FORMULA)
+ {
+ ScFormulaCell* pFC = aIter.getFormulaCell();
+ bOk = (pFC->GetCode()->GetCodeLen() > 0) && (pFC->aPos != aPos);
+ }
+ else
+ bOk = true;
- if (bOk && aIter.hasString())
- {
- OUString aStr = aIter.getString();
- if (ScGlobal::GetpTransliteration()->isEqual( aStr, aName))
+ if (bOk && aIter.hasString())
{
- /* XXX NOTE: we could init the column as relative so copying a
- * formula across columns would point to the relative column,
- * but do it absolute because:
- * a) it makes the reference work in named expressions without
- * having to distinguish
- * b) Excel does it the same. */
- ScSingleRefData aRef;
- aRef.InitAddress( aIter.GetPos());
- maRawToken.SetSingleReference( aRef );
- return true;
+ OUString aStr = aIter.getString();
+ if (ScGlobal::GetpTransliteration()->isEqual( aStr, aName))
+ {
+ /* XXX NOTE: we could init the column as relative so copying a
+ * formula across columns would point to the relative column,
+ * but do it absolute because:
+ * a) it makes the reference work in named expressions without
+ * having to distinguish
+ * b) Excel does it the same. */
+ ScSingleRefData aRef;
+ aRef.InitAddress( aIter.GetPos());
+ maRawToken.SetSingleReference( aRef );
+ return true;
+ }
}
}
}
@@ -3557,11 +3560,26 @@ bool ScCompiler::IsTableRefColumn( const OUString& rName ) const
sal_Int32 nOffset = pDBData->GetColumnNameOffset( aName);
if (nOffset >= 0)
{
- ScSingleRefData aRef;
- ScAddress aAdr( aRange.aStart);
- aAdr.IncCol( nOffset);
- aRef.InitAddress( aAdr);
- maRawToken.SetSingleReference( aRef );
+ if (pDBData->HasHeader())
+ {
+ ScSingleRefData aRef;
+ ScAddress aAdr( aRange.aStart);
+ aAdr.IncCol( nOffset);
+ aRef.InitAddress( aAdr);
+ 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;
}
commit 22c9977d70e4812bca4bc038b775bb7eddb19bab
Author: Eike Rathke <erack at redhat.com>
Date: Wed Jul 22 18:03:58 2015 +0200
clear HasHeader at database range if table headerRowCount is 0
Change-Id: I1cf5b0ac3884320f39d439b6eecf0b39cdf6bc49
diff --git a/sc/source/filter/oox/tablebuffer.cxx b/sc/source/filter/oox/tablebuffer.cxx
index 779b784..9358d75 100644
--- a/sc/source/filter/oox/tablebuffer.cxx
+++ b/sc/source/filter/oox/tablebuffer.cxx
@@ -94,6 +94,15 @@ void Table::finalizeImport()
PropertySet aPropSet( xDatabaseRange );
+ // Default HasHeader is true at ScDBData.
+ if (maModel.mnHeaderRows != 1)
+ {
+ SAL_WARN_IF( maModel.mnHeaderRows > 1, "sc.filter",
+ "Table HeaderRows > 1 not supported: " << maModel.mnHeaderRows);
+ if (maModel.mnHeaderRows == 0)
+ aPropSet.setProperty( PROP_ContainsHeader, false);
+ }
+
if (maModel.mnTotalsRows > 0)
{
SAL_WARN_IF( maModel.mnTotalsRows > 1, "sc.filter",
commit ed497c014444baf8036b1fb79ffeba2b139919f4
Author: Eike Rathke <erack at redhat.com>
Date: Wed Jul 22 18:02:42 2015 +0200
handle ContainsHeader property at database range
Change-Id: If0d54ab1dee6c861b973dc490f6c4a1e11260546
diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx
index 0de088e..eb2b7d1 100644
--- a/sc/source/ui/unoobj/datauno.cxx
+++ b/sc/source/ui/unoobj/datauno.cxx
@@ -123,6 +123,7 @@ static const SfxItemPropertyMapEntry* lcl_GetDBRangePropertyMap()
{OUString(SC_UNONAME_TOKENINDEX),0, cppu::UnoType<sal_Int32>::get(), beans::PropertyAttribute::READONLY, 0 },
{OUString(SC_UNONAME_USEFLTCRT),0, cppu::UnoType<bool>::get(), 0, 0},
{OUString(SC_UNONAME_TOTALSROW),0, cppu::UnoType<bool>::get(), 0, 0},
+ {OUString(SC_UNONAME_CONTHDR) ,0, cppu::UnoType<bool>::get(), 0, 0},
{ OUString(), 0, css::uno::Type(), 0, 0 }
};
return aDBRangePropertyMap_Impl;
@@ -2085,6 +2086,8 @@ void SAL_CALL ScDatabaseRangeObj::setPropertyValue(
}
else if ( aString == SC_UNONAME_TOTALSROW )
aNewData.SetTotals( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if ( aString == SC_UNONAME_CONTHDR )
+ aNewData.SetHeader( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
else
bDo = false;
@@ -2170,6 +2173,12 @@ uno::Any SAL_CALL ScDatabaseRangeObj::getPropertyValue( const OUString& aPropert
ScUnoHelpFunctions::SetBoolInAny( aRet, bTotals );
}
+ else if (aString == SC_UNONAME_CONTHDR )
+ {
+ bool bHeader(GetDBData_Impl()->HasHeader());
+
+ ScUnoHelpFunctions::SetBoolInAny( aRet, bHeader );
+ }
}
return aRet;
}
commit 6dddd1aaf5dd3c54aaf87222712c9147466056f6
Author: Eike Rathke <erack at redhat.com>
Date: Wed Jul 22 17:59:04 2015 +0200
add optional ContainsHeader property
great we never had this :-(
Change-Id: Id79b08ff9dfe42228ed7d6b27ad0c8cc29b1bfb0
diff --git a/offapi/com/sun/star/sheet/DatabaseRange.idl b/offapi/com/sun/star/sheet/DatabaseRange.idl
index 585fcd3..0c48965 100644
--- a/offapi/com/sun/star/sheet/DatabaseRange.idl
+++ b/offapi/com/sun/star/sheet/DatabaseRange.idl
@@ -118,6 +118,13 @@ published service DatabaseRange
@since LibreOffice 5.0
*/
[optional, property] boolean TotalsRow;
+
+
+ /** specifies whether this range includes a top row of headers.
+
+ @since LibreOffice 5.0
+ */
+ [optional, property] boolean ContainsHeader;
};
More information about the Libreoffice-commits
mailing list