Kaydet (Commit) 0075402e authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Another one involving cell data validation in detective functionality.

Change-Id: I1987f45e436744d4029f8b7af812867ebcfb09c4
üst 04e265e9
...@@ -256,6 +256,9 @@ public: ...@@ -256,6 +256,9 @@ public:
bool first(); bool first();
bool next(); bool next();
// TODO: Remove this later.
ScBaseCell* getHackedBaseCell();
}; };
class ScQueryCellIterator // walk through all non-empty cells in an area class ScQueryCellIterator // walk through all non-empty cells in an area
......
...@@ -29,6 +29,7 @@ namespace ValidListType = ::com::sun::star::sheet::TableValidationVisibility; ...@@ -29,6 +29,7 @@ namespace ValidListType = ::com::sun::star::sheet::TableValidationVisibility;
class ScPatternAttr; class ScPatternAttr;
class ScTokenArray; class ScTokenArray;
class ScTypedStrData; class ScTypedStrData;
class ScCellIterator;
enum ScValidationMode enum ScValidationMode
{ {
...@@ -129,6 +130,8 @@ public: ...@@ -129,6 +130,8 @@ public:
const ScAddress& rPos ) const; const ScAddress& rPos ) const;
sal_Bool IsDataValid( ScBaseCell* pCell, const ScAddress& rPos ) const; sal_Bool IsDataValid( ScBaseCell* pCell, const ScAddress& rPos ) const;
bool IsDataValid( ScCellIterator& rIter ) const;
// TRUE -> break // TRUE -> break
sal_Bool DoError( Window* pParent, const String& rInput, const ScAddress& rPos ) const; sal_Bool DoError( Window* pParent, const String& rInput, const ScAddress& rPos ) const;
void DoCalcError( ScFormulaCell* pCell ) const; void DoCalcError( ScFormulaCell* pCell ) const;
......
...@@ -1326,6 +1326,11 @@ bool ScCellIterator::next() ...@@ -1326,6 +1326,11 @@ bool ScCellIterator::next()
return getCurrent(); return getCurrent();
} }
ScBaseCell* ScCellIterator::getHackedBaseCell()
{
return mpDoc->GetCell(maCurPos);
}
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
ScQueryCellIterator::ScQueryCellIterator(ScDocument* pDocument, SCTAB nTable, ScQueryCellIterator::ScQueryCellIterator(ScDocument* pDocument, SCTAB nTable,
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "rangenam.hxx" #include "rangenam.hxx"
#include "dbdata.hxx" #include "dbdata.hxx"
#include "typedstrdata.hxx" #include "typedstrdata.hxx"
#include "dociter.hxx"
#include <math.h> #include <math.h>
#include <memory> #include <memory>
...@@ -545,6 +546,90 @@ sal_Bool ScValidationData::IsDataValid( ScBaseCell* pCell, const ScAddress& rPos ...@@ -545,6 +546,90 @@ sal_Bool ScValidationData::IsDataValid( ScBaseCell* pCell, const ScAddress& rPos
return bOk; return bOk;
} }
bool ScValidationData::IsDataValid( ScCellIterator& rIter ) const
{
const ScAddress& rPos = rIter.GetPos();
if( eDataMode == SC_VALID_LIST )
{
ScBaseCell* pBC = rIter.getHackedBaseCell();
return IsListValid(pBC, rPos);
}
double fVal = 0.0;
OUString aString;
bool bIsVal = true;
switch (rIter.getType())
{
case CELLTYPE_VALUE:
fVal = rIter.getValue();
break;
case CELLTYPE_STRING:
case CELLTYPE_EDIT:
aString = rIter.getString();
bIsVal = false;
break;
case CELLTYPE_FORMULA:
{
ScFormulaCell* pFCell = rIter.getFormulaCell();
bIsVal = pFCell->IsValue();
if ( bIsVal )
fVal = pFCell->GetValue();
else
aString = pFCell->GetString();
}
break;
default: // Notizen, Broadcaster
return IsIgnoreBlank(); // wie eingestellt
}
bool bOk = true;
switch (eDataMode)
{
// SC_VALID_ANY schon oben
case SC_VALID_WHOLE:
case SC_VALID_DECIMAL:
case SC_VALID_DATE: // Date/Time ist nur Formatierung
case SC_VALID_TIME:
bOk = bIsVal;
if ( bOk && eDataMode == SC_VALID_WHOLE )
bOk = ::rtl::math::approxEqual( fVal, floor(fVal+0.5) ); // ganze Zahlen
if ( bOk )
{
ScBaseCell* pBC = rIter.getHackedBaseCell();
bOk = IsCellValid(pBC, rPos);
}
break;
case SC_VALID_CUSTOM:
{
// fuer Custom muss eOp == SC_COND_DIRECT sein
//! der Wert muss im Dokument stehen !!!!!!!!!!!!!!!!!!!!
ScBaseCell* pBC = rIter.getHackedBaseCell();
bOk = IsCellValid(pBC, rPos);
}
break;
case SC_VALID_TEXTLEN:
bOk = !bIsVal; // nur Text
if ( bOk )
{
double nLenVal = (double) aString.getLength();
ScValueCell* pTmpCell = new ScValueCell( nLenVal );
bOk = IsCellValid( pTmpCell, rPos );
pTmpCell->Delete();
}
break;
default:
OSL_FAIL("not yet done");
break;
}
return bOk;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
namespace { namespace {
......
...@@ -1357,8 +1357,7 @@ sal_Bool ScDetectiveFunc::MarkInvalid(sal_Bool& rOverflow) ...@@ -1357,8 +1357,7 @@ sal_Bool ScDetectiveFunc::MarkInvalid(sal_Bool& rOverflow)
SCROW nNextRow = nRow1; SCROW nNextRow = nRow1;
SCROW nRow; SCROW nRow;
ScCellIterator aCellIter( pDoc, nCol,nRow1,nTab, nCol,nRow2,nTab ); ScCellIterator aCellIter( pDoc, nCol,nRow1,nTab, nCol,nRow2,nTab );
ScBaseCell* pCell = aCellIter.GetFirst(); for (bool bHas = aCellIter.first(); bHas && nInsCount < SC_DET_MAXCIRCLE; bHas = aCellIter.next())
while ( pCell && nInsCount < SC_DET_MAXCIRCLE )
{ {
SCROW nCellRow = aCellIter.GetPos().Row(); SCROW nCellRow = aCellIter.GetPos().Row();
if ( bMarkEmpty ) if ( bMarkEmpty )
...@@ -1367,13 +1366,12 @@ sal_Bool ScDetectiveFunc::MarkInvalid(sal_Bool& rOverflow) ...@@ -1367,13 +1366,12 @@ sal_Bool ScDetectiveFunc::MarkInvalid(sal_Bool& rOverflow)
DrawCircle( nCol, nRow, aData ); DrawCircle( nCol, nRow, aData );
++nInsCount; ++nInsCount;
} }
if ( !pData->IsDataValid( pCell, ScAddress( nCol, nCellRow, nTab ) ) ) if (!pData->IsDataValid(aCellIter))
{ {
DrawCircle( nCol, nCellRow, aData ); DrawCircle( nCol, nCellRow, aData );
++nInsCount; ++nInsCount;
} }
nNextRow = nCellRow + 1; nNextRow = nCellRow + 1;
pCell = aCellIter.GetNext();
} }
if ( bMarkEmpty ) if ( bMarkEmpty )
for ( nRow = nNextRow; nRow <= nRow2 && nInsCount < SC_DET_MAXCIRCLE; nRow++ ) for ( nRow = nNextRow; nRow <= nRow2 && nInsCount < SC_DET_MAXCIRCLE; nRow++ )
......
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