[Libreoffice-commits] core.git: Branch 'libreoffice-5-0-0' - offapi/com sc/source
Eike Rathke
erack at redhat.com
Fri Jul 24 06:40:36 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 12e0032fc91c9f7bc3cf8dcd13b9fbbae26890f0
Author: Eike Rathke <erack at redhat.com>
Date: Wed Jul 22 17:59:04 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.
Squashed 4 commits into one:
add optional ContainsHeader property
great we never had this :-(
(cherry picked from commit 6dddd1aaf5dd3c54aaf87222712c9147466056f6)
handle ContainsHeader property at database range
(cherry picked from commit ed497c014444baf8036b1fb79ffeba2b139919f4)
clear HasHeader at database range if table headerRowCount is 0
(cherry picked from commit 22c9977d70e4812bca4bc038b775bb7eddb19bab)
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.
(cherry picked from commit d77947929c7f02cebe3d3e5d79c78642a8a439ba)
Change-Id: Id79b08ff9dfe42228ed7d6b27ad0c8cc29b1bfb0
f0d54ab1dee6c861b973dc490f6c4a1e11260546
1cf5b0ac3884320f39d439b6eecf0b39cdf6bc49
a42619ec800291b6617a61c8a89a2d54ef231cec
Reviewed-on: https://gerrit.libreoffice.org/17322
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
Reviewed-by: Michael Stahl <mstahl at redhat.com>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
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;
};
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 22272fb..37da6ab 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -3518,35 +3518,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;
+ }
}
}
}
@@ -3558,11 +3561,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;
}
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",
diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx
index 0401547..f5da6d1 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;
}
More information about the Libreoffice-commits
mailing list