tdf#89998 set increment for percent values to 1%
Change-Id: I759f1041faa1222b0feb42e01c95166f56591e19
Reviewed-on: https://gerrit.libreoffice.org/66129
Tested-by: Jenkins
Reviewed-by: Eike Rathke <erack@redhat.com>
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index b01df14..d2a8fb8 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -367,6 +367,10 @@
if (bVal)
rCmd = FILL_LINEAR;
}
else if(nFormatType == SvNumFormatType::PERCENT)
{
rInc = 0.01; // tdf#89998 increment by 1% at a time
}
}
}
else if (eCellType == CELLTYPE_STRING || eCellType == CELLTYPE_EDIT)
@@ -948,10 +952,16 @@
double nVal = aCell.mfValue;
if ( !(nScFillModeMouseModifier & KEY_MOD1) )
{
if (nVal == 0.0 || nVal == 1.0)
const SvNumFormatType nFormatType = pDocument->GetFormatTable()->GetType(nNumFmt);
bool bPercentCell = (nFormatType == SvNumFormatType::PERCENT);
if (bPercentCell)
{
bool bBooleanCell = (pDocument->GetFormatTable()->GetType( nNumFmt) ==
SvNumFormatType::LOGICAL);
// tdf#89998 increment by 1% at a time
nVal += static_cast<double>(nDelta) * 0.01;
}
else if (nVal == 0.0 || nVal == 1.0)
{
bool bBooleanCell = (nFormatType == SvNumFormatType::LOGICAL);
if (!bBooleanCell)
nVal += static_cast<double>(nDelta);
}
@@ -1347,6 +1357,7 @@
sal_uLong nFormulaCounter = nActFormCnt;
bool bGetCell = true;
bool bBooleanCell = false;
bool bPercentCell = false;
sal_uInt16 nCellDigits = 0;
short nHeadNoneTail = 0;
sal_Int32 nStringValue = 0;
@@ -1378,15 +1389,19 @@
FillFormulaVertical(*aSrcCell.mpFormula, rInner, rCol, nIStart, nIEnd, pProgress, rProgress);
return;
}
bBooleanCell = (pDocument->GetFormatTable()->GetType(
aCol[rCol].GetNumberFormat( pDocument->GetNonThreadedContext(), nSource)) == SvNumFormatType::LOGICAL);
const SvNumFormatType nFormatType = pDocument->GetFormatTable()->GetType(
aCol[rCol].GetNumberFormat( pDocument->GetNonThreadedContext(), nSource));
bBooleanCell = (nFormatType == SvNumFormatType::LOGICAL);
bPercentCell = (nFormatType == SvNumFormatType::PERCENT);
}
else // rInner&:=nCol, rOuter&:=nRow
{
aSrcCell = aCol[nSource].GetCellValue(rRow);
bBooleanCell = (pDocument->GetFormatTable()->GetType(
aCol[nSource].GetNumberFormat( pDocument->GetNonThreadedContext(), rRow)) == SvNumFormatType::LOGICAL);
const SvNumFormatType nFormatType = pDocument->GetFormatTable()->GetType(
aCol[nSource].GetNumberFormat( pDocument->GetNonThreadedContext(), rRow));
bBooleanCell = (nFormatType == SvNumFormatType::LOGICAL);
bPercentCell = (nFormatType == SvNumFormatType::PERCENT);
}
bGetCell = false;
@@ -1425,6 +1440,8 @@
double fVal;
if (bBooleanCell && ((fVal = aSrcCell.mfValue) == 0.0 || fVal == 1.0))
aCol[rCol].SetValue(rRow, aSrcCell.mfValue);
else if(bPercentCell)
aCol[rCol].SetValue(rRow, aSrcCell.mfValue + nDelta * 0.01); // tdf#89998 increment by 1% at a time
else
aCol[rCol].SetValue(rRow, aSrcCell.mfValue + nDelta);
}