Resolves: tdf#64001 exclude "boolean" value cells from increment during Fill

Change-Id: Id79438cc37a63c0619c6b96ecf57b10d781afea3
This commit is contained in:
Eike Rathke
2016-10-31 18:12:07 +01:00
parent 14e748a12f
commit d7984d88e6

View File

@@ -259,8 +259,11 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
if (eCellType == CELLTYPE_VALUE) if (eCellType == CELLTYPE_VALUE)
{ {
double fVal;
sal_uInt32 nFormat = static_cast<const SfxUInt32Item*>(GetAttr(nCol,nRow,ATTR_VALUE_FORMAT))->GetValue(); sal_uInt32 nFormat = static_cast<const SfxUInt32Item*>(GetAttr(nCol,nRow,ATTR_VALUE_FORMAT))->GetValue();
bool bDate = ( pDocument->GetFormatTable()->GetType(nFormat) == css::util::NumberFormat::DATE ); const sal_Int16 nFormatType = pDocument->GetFormatTable()->GetType(nFormat);
bool bDate = (nFormatType == css::util::NumberFormat::DATE );
bool bBooleanCell = (!bDate && nFormatType == css::util::NumberFormat::LOGICAL);
if (bDate) if (bDate)
{ {
if (nCount > 1) if (nCount > 1)
@@ -341,6 +344,10 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
rInc = 1.0; rInc = 1.0;
} }
} }
else if (bBooleanCell && ((fVal = aFirstCell.mfValue) == 0.0 || fVal == 1.0))
{
// Nothing, rInc stays 0.0, no specific fill mode.
}
else else
{ {
if (nCount > 1) if (nCount > 1)
@@ -360,6 +367,10 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
double nDiff = approxDiff( nVal2, nVal1); double nDiff = approxDiff( nVal2, nVal1);
if ( !::rtl::math::approxEqual( nDiff, rInc, 13 ) ) if ( !::rtl::math::approxEqual( nDiff, rInc, 13 ) )
bVal = false; bVal = false;
else if ((nVal2 == 0.0 || nVal2 == 1.0) &&
(pDocument->GetFormatTable()->GetType(GetNumberFormat(nCol,nRow)) ==
css::util::NumberFormat::LOGICAL))
bVal = false;
nVal1 = nVal2; nVal1 = nVal2;
} }
else else
@@ -939,13 +950,25 @@ OUString ScTable::GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW
break; break;
case CELLTYPE_VALUE: case CELLTYPE_VALUE:
{ {
sal_uLong nNumFmt = GetNumberFormat( nSrcX, nSrcY );
// overflow is possible... // overflow is possible...
double nVal = aCell.mfValue; double nVal = aCell.mfValue;
if ( !(nScFillModeMouseModifier & KEY_MOD1) ) if ( !(nScFillModeMouseModifier & KEY_MOD1) )
{
if (nVal == 0.0 || nVal == 1.0)
{
bool bBooleanCell = (pDocument->GetFormatTable()->GetType( nNumFmt) ==
css::util::NumberFormat::LOGICAL);
if (!bBooleanCell)
nVal += (double) nDelta; nVal += (double) nDelta;
}
else
{
nVal += (double) nDelta;
}
}
Color* pColor; Color* pColor;
sal_uLong nNumFmt = GetNumberFormat( nSrcX, nSrcY );
pDocument->GetFormatTable()->GetOutputString( nVal, nNumFmt, aValue, &pColor ); pDocument->GetFormatTable()->GetOutputString( nVal, nNumFmt, aValue, &pColor );
} }
break; break;
@@ -1326,6 +1349,7 @@ void ScTable::FillAutoSimple(
nDelta = -1.0; nDelta = -1.0;
sal_uLong nFormulaCounter = nActFormCnt; sal_uLong nFormulaCounter = nActFormCnt;
bool bGetCell = true; bool bGetCell = true;
bool bBooleanCell = false;
sal_uInt16 nCellDigits = 0; sal_uInt16 nCellDigits = 0;
short nHeadNoneTail = 0; short nHeadNoneTail = 0;
sal_Int32 nStringValue = 0; sal_Int32 nStringValue = 0;
@@ -1357,9 +1381,16 @@ void ScTable::FillAutoSimple(
FillFormulaVertical(*aSrcCell.mpFormula, rInner, rCol, nIStart, nIEnd, pProgress, rProgress); FillFormulaVertical(*aSrcCell.mpFormula, rInner, rCol, nIStart, nIEnd, pProgress, rProgress);
return; return;
} }
bBooleanCell = (pDocument->GetFormatTable()->GetType(
aCol[rCol].GetNumberFormat( nSource)) == css::util::NumberFormat::LOGICAL);
} }
else // rInner&:=nCol, rOuter&:=nRow else // rInner&:=nCol, rOuter&:=nRow
{
aSrcCell = aCol[nSource].GetCellValue(rRow); aSrcCell = aCol[nSource].GetCellValue(rRow);
bBooleanCell = (pDocument->GetFormatTable()->GetType(
aCol[nSource].GetNumberFormat( rRow)) == css::util::NumberFormat::LOGICAL);
}
bGetCell = false; bGetCell = false;
if (!aSrcCell.isEmpty()) if (!aSrcCell.isEmpty())
@@ -1393,7 +1424,13 @@ void ScTable::FillAutoSimple(
switch (aSrcCell.meType) switch (aSrcCell.meType)
{ {
case CELLTYPE_VALUE: case CELLTYPE_VALUE:
{
double fVal;
if (bBooleanCell && ((fVal = aSrcCell.mfValue) == 0.0 || fVal == 1.0))
aCol[rCol].SetValue(rRow, aSrcCell.mfValue);
else
aCol[rCol].SetValue(rRow, aSrcCell.mfValue + nDelta); aCol[rCol].SetValue(rRow, aSrcCell.mfValue + nDelta);
}
break; break;
case CELLTYPE_STRING: case CELLTYPE_STRING:
case CELLTYPE_EDIT: case CELLTYPE_EDIT: