summaryrefslogtreecommitdiff
path: root/sc/source/core/data
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/core/data')
-rw-r--r--sc/source/core/data/cell2.cxx2
-rw-r--r--sc/source/core/data/column3.cxx17
-rw-r--r--sc/source/core/data/documen3.cxx11
-rw-r--r--sc/source/core/data/dpcachetable.cxx30
-rwxr-xr-xsc/source/core/data/dptablecache.cxx34
-rw-r--r--sc/source/core/data/global2.cxx51
-rw-r--r--sc/source/core/data/table3.cxx61
7 files changed, 141 insertions, 65 deletions
diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx
index 9a3670d2a9e0..4de78c71fe79 100644
--- a/sc/source/core/data/cell2.cxx
+++ b/sc/source/core/data/cell2.cxx
@@ -996,6 +996,8 @@ void ScFormulaCell::UpdateReference(UpdateRefMode eUpdateRefMode,
pDocument->RemoveFromFormulaTree( this ); // update formula count
delete pCode;
pCode = pRangeData->GetCode()->Clone();
+ // #i18937# #i110008# call MoveRelWrap, but with the old position
+ ScCompiler::MoveRelWrap(*pCode, pDocument, aOldPos, pRangeData->GetMaxCol(), pRangeData->GetMaxRow());
ScCompiler aComp2(pDocument, aPos, *pCode);
aComp2.SetGrammar(pDocument->GetGrammar());
aComp2.UpdateSharedFormulaReference( eUpdateRefMode, aOldPos, r,
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index dc206950b3ea..22b75b8d4a6a 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1467,8 +1467,9 @@ BOOL ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString,
}
-void ScColumn::GetFilterEntries(SCROW nStartRow, SCROW nEndRow, TypedScStrCollection& rStrings)
+void ScColumn::GetFilterEntries(SCROW nStartRow, SCROW nEndRow, TypedScStrCollection& rStrings, bool& rHasDates)
{
+ bool bHasDates = false;
SvNumberFormatter* pFormatter = pDocument->GetFormatTable();
String aString;
SCROW nRow = 0;
@@ -1504,6 +1505,18 @@ void ScColumn::GetFilterEntries(SCROW nStartRow, SCROW nEndRow, TypedScStrCollec
nValue = 0.0;
}
+ if (pFormatter)
+ {
+ short nType = pFormatter->GetType(nFormat);
+ if ((nType & NUMBERFORMAT_DATE) && !(nType & NUMBERFORMAT_TIME))
+ {
+ // special case for date values. Disregard the time
+ // element if the number format is of date type.
+ nValue = ::rtl::math::approxFloor(nValue);
+ bHasDates = true;
+ }
+ }
+
pData = new TypedStrData( aString, nValue, SC_STRTYPE_VALUE );
}
#if 0 // DR
@@ -1522,6 +1535,8 @@ void ScColumn::GetFilterEntries(SCROW nStartRow, SCROW nEndRow, TypedScStrCollec
++nIndex;
}
+
+ rHasDates = bHasDates;
}
//
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index fd2b2f1fd309..557f181c9d8f 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -1263,7 +1263,8 @@ BOOL ScDocument::HasRowHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol,
// GetFilterEntries - Eintraege fuer AutoFilter-Listbox
//
-BOOL ScDocument::GetFilterEntries( SCCOL nCol, SCROW nRow, SCTAB nTab, TypedScStrCollection& rStrings, bool bFilter )
+BOOL ScDocument::GetFilterEntries(
+ SCCOL nCol, SCROW nRow, SCTAB nTab, bool bFilter, TypedScStrCollection& rStrings, bool& rHasDates)
{
if ( ValidTab(nTab) && pTab[nTab] && pDBCollection )
{
@@ -1300,11 +1301,11 @@ BOOL ScDocument::GetFilterEntries( SCCOL nCol, SCROW nRow, SCTAB nTab, TypedScSt
if ( bFilter )
{
- pTab[nTab]->GetFilteredFilterEntries( nCol, nStartRow, nEndRow, aParam, rStrings );
+ pTab[nTab]->GetFilteredFilterEntries( nCol, nStartRow, nEndRow, aParam, rStrings, rHasDates );
}
else
{
- pTab[nTab]->GetFilterEntries( nCol, nStartRow, nEndRow, rStrings );
+ pTab[nTab]->GetFilterEntries( nCol, nStartRow, nEndRow, rStrings, rHasDates );
}
return TRUE;
@@ -1319,11 +1320,11 @@ BOOL ScDocument::GetFilterEntries( SCCOL nCol, SCROW nRow, SCTAB nTab, TypedScSt
//
BOOL ScDocument::GetFilterEntriesArea( SCCOL nCol, SCROW nStartRow, SCROW nEndRow,
- SCTAB nTab, TypedScStrCollection& rStrings )
+ SCTAB nTab, TypedScStrCollection& rStrings, bool& rHasDates )
{
if ( ValidTab(nTab) && pTab[nTab] )
{
- pTab[nTab]->GetFilterEntries( nCol, nStartRow, nEndRow, rStrings );
+ pTab[nTab]->GetFilterEntries( nCol, nStartRow, nEndRow, rStrings, rHasDates );
return TRUE;
}
diff --git a/sc/source/core/data/dpcachetable.cxx b/sc/source/core/data/dpcachetable.cxx
index ad5e921cb278..d97900e6b904 100644
--- a/sc/source/core/data/dpcachetable.cxx
+++ b/sc/source/core/data/dpcachetable.cxx
@@ -183,39 +183,9 @@ sal_Int32 ScDPCacheTable::getColSize() const
return GetCache()->GetColumnCount();
}
-namespace {
-
-/**
- * While the macro interpret level is incremented, the formula cells are
- * (semi-)guaranteed to be interpreted.
- */
-class MacroInterpretIncrementer
-{
-public:
- MacroInterpretIncrementer(ScDocument* pDoc) :
- mpDoc(pDoc)
- {
- mpDoc->IncMacroInterpretLevel();
- }
- ~MacroInterpretIncrementer()
- {
- mpDoc->DecMacroInterpretLevel();
- }
-private:
- ScDocument* mpDoc;
-};
-
-}
-
void ScDPCacheTable::fillTable( const ScQueryParam& rQuery, BOOL* pSpecial,
bool bIgnoreEmptyRows, bool bRepeatIfEmpty )
{
- // Make sure the formula cells within the data range are interpreted
- // during this call, for this method may be called from the interpretation
- // of GETPIVOTDATA, which disables nested formula interpretation without
- // increasing the macro level.
- MacroInterpretIncrementer aMacroInc(GetCache()->GetDoc());
-
if ( mpCache == NULL )
InitNoneCache( NULL );
//check cache
diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx
index 42090e5203a2..fc9cf2b99a10 100755
--- a/sc/source/core/data/dptablecache.cxx
+++ b/sc/source/core/data/dptablecache.cxx
@@ -304,7 +304,7 @@ void ScDPItemData::dump() const
DBG_TRACE1( "Numberformat= %o", nNumFormat );
DBG_TRACESTR(aString );
DBG_TRACE1( "fValue= %f", fValue );
- DBG_TRACE1( "bHasValue= %d", bHasValue ? 1:0);
+ DBG_TRACE1( "mbFlag= %d", mbFlag);
}
#endif
//End
@@ -489,8 +489,40 @@ bool ScDPTableDataCache::IsValid() const
}
// -----------------------------------------------------------------------
+
+namespace {
+
+/**
+ * While the macro interpret level is incremented, the formula cells are
+ * (semi-)guaranteed to be interpreted.
+ */
+class MacroInterpretIncrementer
+{
+public:
+ MacroInterpretIncrementer(ScDocument* pDoc) :
+ mpDoc(pDoc)
+ {
+ mpDoc->IncMacroInterpretLevel();
+ }
+ ~MacroInterpretIncrementer()
+ {
+ mpDoc->DecMacroInterpretLevel();
+ }
+private:
+ ScDocument* mpDoc;
+};
+
+}
+
+// -----------------------------------------------------------------------
bool ScDPTableDataCache::InitFromDoc( ScDocument* pDoc, const ScRange& rRange )
{
+ // Make sure the formula cells within the data range are interpreted
+ // during this call, for this method may be called from the interpretation
+ // of GETPIVOTDATA, which disables nested formula interpretation without
+ // increasing the macro level.
+ MacroInterpretIncrementer aMacroInc(pDoc);
+
//
SCROW nStartRow = rRange.aStart.Row(); // start of data
SCROW nEndRow = rRange.aEnd.Row();
diff --git a/sc/source/core/data/global2.cxx b/sc/source/core/data/global2.cxx
index d32ebdafbf78..3234340ae9dd 100644
--- a/sc/source/core/data/global2.cxx
+++ b/sc/source/core/data/global2.cxx
@@ -145,30 +145,32 @@ BOOL ScImportParam::operator==( const ScImportParam& rOther ) const
//------------------------------------------------------------------------
// struct ScQueryParam:
-ScQueryEntry::ScQueryEntry()
+ScQueryEntry::ScQueryEntry() :
+ bDoQuery(FALSE),
+ bQueryByString(FALSE),
+ bQueryByDate(false),
+ nField(0),
+ eOp(SC_EQUAL),
+ eConnect(SC_AND),
+ pStr(new String),
+ nVal(0.0),
+ pSearchParam(NULL),
+ pSearchText(NULL)
+{
+}
+
+ScQueryEntry::ScQueryEntry(const ScQueryEntry& r) :
+ bDoQuery(r.bDoQuery),
+ bQueryByString(r.bQueryByString),
+ bQueryByDate(r.bQueryByDate),
+ nField(r.nField),
+ eOp(r.eOp),
+ eConnect(r.eConnect),
+ pStr(new String(*r.pStr)),
+ nVal(r.nVal),
+ pSearchParam(NULL),
+ pSearchText(NULL)
{
- bDoQuery = FALSE;
- bQueryByString = FALSE;
- eOp = SC_EQUAL;
- eConnect = SC_AND;
- nField = 0;
- nVal = 0.0;
- pStr = new String;
- pSearchParam = NULL;
- pSearchText = NULL;
-}
-
-ScQueryEntry::ScQueryEntry(const ScQueryEntry& r)
-{
- bDoQuery = r.bDoQuery;
- bQueryByString = r.bQueryByString;
- eOp = r.eOp;
- eConnect = r.eConnect;
- nField = r.nField;
- nVal = r.nVal;
- pStr = new String(*r.pStr);
- pSearchParam = NULL;
- pSearchText = NULL;
}
ScQueryEntry::~ScQueryEntry()
@@ -185,6 +187,7 @@ ScQueryEntry& ScQueryEntry::operator=( const ScQueryEntry& r )
{
bDoQuery = r.bDoQuery;
bQueryByString = r.bQueryByString;
+ bQueryByDate = r.bQueryByDate;
eOp = r.eOp;
eConnect = r.eConnect;
nField = r.nField;
@@ -205,6 +208,7 @@ void ScQueryEntry::Clear()
{
bDoQuery = FALSE;
bQueryByString = FALSE;
+ bQueryByDate = false;
eOp = SC_EQUAL;
eConnect = SC_AND;
nField = 0;
@@ -223,6 +227,7 @@ BOOL ScQueryEntry::operator==( const ScQueryEntry& r ) const
{
return bDoQuery == r.bDoQuery
&& bQueryByString == r.bQueryByString
+ && bQueryByDate == r.bQueryByDate
&& eOp == r.eOp
&& eConnect == r.eConnect
&& nField == r.nField
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 09a9f41929b5..90993367dde6 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -31,6 +31,7 @@
#include <rtl/math.hxx>
#include <unotools/textsearch.hxx>
#include <svl/zforlist.hxx>
+#include <svl/zformat.hxx>
#include <unotools/charclass.hxx>
#include <unotools/collatorwrapper.hxx>
#include <com/sun/star/i18n/CollatorOptions.hpp>
@@ -989,6 +990,35 @@ BOOL ScTable::ValidQuery(SCROW nRow, const ScQueryParam& rParam,
}
else
nCellVal = GetValue( static_cast<SCCOL>(rEntry.nField), nRow );
+
+ /* NOTE: lcl_PrepareQuery() prepares a filter query such that if a
+ * date+time format was queried rEntry.bQueryByDate is not set. In
+ * case other queries wanted to use this mechanism they should do
+ * the same, in other words only if rEntry.nVal is an integer value
+ * rEntry.bQueryByDate should be true and the time fraction be
+ * stripped here. */
+ if (rEntry.bQueryByDate)
+ {
+ sal_uInt32 nNumFmt = GetNumberFormat(static_cast<SCCOL>(rEntry.nField), nRow);
+ const SvNumberformat* pEntry = pDocument->GetFormatTable()->GetEntry(nNumFmt);
+ if (pEntry)
+ {
+ short nNumFmtType = pEntry->GetType();
+ /* NOTE: Omitting the check for absence of
+ * NUMBERFORMAT_TIME would include also date+time formatted
+ * values of the same day. That may be desired in some
+ * cases, querying all time values of a day, but confusing
+ * in other cases. A user can always setup a standard
+ * filter query for x >= date AND x < date+1 */
+ if ((nNumFmtType & NUMBERFORMAT_DATE) && !(nNumFmtType & NUMBERFORMAT_TIME))
+ {
+ // The format is of date type. Strip off the time
+ // element.
+ nCellVal = ::rtl::math::approxFloor(nCellVal);
+ }
+ }
+ }
+
switch (rEntry.eOp)
{
case SC_EQUAL :
@@ -1393,6 +1423,23 @@ static void lcl_PrepareQuery( ScDocument* pDoc, ScTable* pTab, ScQueryParam& rPa
sal_uInt32 nIndex = 0;
rEntry.bQueryByString = !( pDoc->GetFormatTable()->
IsNumberFormat( *rEntry.pStr, nIndex, rEntry.nVal ) );
+ if (rEntry.bQueryByDate)
+ {
+ if (!rEntry.bQueryByString && ((nIndex % SV_COUNTRY_LANGUAGE_OFFSET) != 0))
+ {
+ const SvNumberformat* pEntry = pDoc->GetFormatTable()->GetEntry(nIndex);
+ if (pEntry)
+ {
+ short nNumFmtType = pEntry->GetType();
+ if (!((nNumFmtType & NUMBERFORMAT_DATE) && !(nNumFmtType & NUMBERFORMAT_TIME)))
+ rEntry.bQueryByDate = false; // not a date only
+ }
+ else
+ rEntry.bQueryByDate = false; // what the ... not a date
+ }
+ else
+ rEntry.bQueryByDate = false; // not a date
+ }
}
else
{
@@ -1776,12 +1823,13 @@ BOOL ScTable::HasRowHeader( SCCOL nStartCol, SCROW nStartRow, SCCOL /* nEndCol *
return TRUE;
}
-void ScTable::GetFilterEntries(SCCOL nCol, SCROW nRow1, SCROW nRow2, TypedScStrCollection& rStrings)
+void ScTable::GetFilterEntries(SCCOL nCol, SCROW nRow1, SCROW nRow2, TypedScStrCollection& rStrings, bool& rHasDates)
{
- aCol[nCol].GetFilterEntries( nRow1, nRow2, rStrings );
+ aCol[nCol].GetFilterEntries( nRow1, nRow2, rStrings, rHasDates );
}
-void ScTable::GetFilteredFilterEntries( SCCOL nCol, SCROW nRow1, SCROW nRow2, const ScQueryParam& rParam, TypedScStrCollection& rStrings )
+void ScTable::GetFilteredFilterEntries(
+ SCCOL nCol, SCROW nRow1, SCROW nRow2, const ScQueryParam& rParam, TypedScStrCollection& rStrings, bool& rHasDates )
{
// remove the entry for this column from the query parameter
ScQueryParam aParam( rParam );
@@ -1799,15 +1847,18 @@ void ScTable::GetFilteredFilterEntries( SCCOL nCol, SCROW nRow1, SCROW nRow2, co
BOOL* pSpecial = new BOOL[nEntryCount];
lcl_PrepareQuery( pDocument, this, aParam, pSpecial );
-
+ bool bHasDates = false;
for ( SCROW j = nRow1; j <= nRow2; ++j )
{
if ( ValidQuery( j, aParam, pSpecial ) )
{
- aCol[nCol].GetFilterEntries( j, j, rStrings );
+ bool bThisHasDates = false;
+ aCol[nCol].GetFilterEntries( j, j, rStrings, bThisHasDates );
+ bHasDates |= bThisHasDates;
}
}
+ rHasDates = bHasDates;
delete[] pSpecial;
}