Lines 64-70
Link Here
|
64 |
#include <svtools/zforlist.hxx> |
64 |
#include <svtools/zforlist.hxx> |
65 |
#include <vcl/keycodes.hxx> |
65 |
#include <vcl/keycodes.hxx> |
66 |
#include <rtl/math.hxx> |
66 |
#include <rtl/math.hxx> |
67 |
#include <unotools/charclass.hxx> |
|
|
68 |
|
67 |
|
69 |
#include "attrib.hxx" |
68 |
#include "attrib.hxx" |
70 |
#include "patattr.hxx" |
69 |
#include "patattr.hxx" |
Lines 81-86
Link Here
|
81 |
#include "rangenam.hxx" |
80 |
#include "rangenam.hxx" |
82 |
#include "docpool.hxx" |
81 |
#include "docpool.hxx" |
83 |
#include "progress.hxx" |
82 |
#include "progress.hxx" |
|
|
83 |
#include "sc/valuestringparser.hxx" |
84 |
|
84 |
|
85 |
#include <math.h> |
85 |
#include <math.h> |
86 |
|
86 |
|
Lines 92-152
Link Here
|
92 |
|
92 |
|
93 |
// ----------------------------------------------------------------------- |
93 |
// ----------------------------------------------------------------------- |
94 |
|
94 |
|
95 |
short lcl_DecompValueString( String& aValue, sal_Int32& nVal, USHORT* pMinDigits = NULL ) |
|
|
96 |
{ |
97 |
if ( !aValue.Len() ) |
98 |
{ |
99 |
nVal = 0; |
100 |
return 0; |
101 |
} |
102 |
const sal_Unicode* p = aValue.GetBuffer(); |
103 |
xub_StrLen nNeg = 0; |
104 |
xub_StrLen nNum = 0; |
105 |
if ( p[nNum] == '-' ) |
106 |
nNum = nNeg = 1; |
107 |
while ( p[nNum] && CharClass::isAsciiNumeric( p[nNum] ) ) |
108 |
nNum++; |
109 |
|
110 |
sal_Unicode cNext = p[nNum]; // 0 if at the end |
111 |
sal_Unicode cLast = p[aValue.Len()-1]; |
112 |
|
113 |
// #i5550# If there are numbers at the beginning and the end, |
114 |
// prefer the one at the beginning only if it's followed by a space. |
115 |
// Otherwise, use the number at the end, to enable things like IP addresses. |
116 |
if ( nNum > nNeg && ( cNext == 0 || cNext == ' ' || !CharClass::isAsciiNumeric(cLast) ) ) |
117 |
{ // number at the beginning |
118 |
nVal = aValue.Copy( 0, nNum ).ToInt32(); |
119 |
// #60893# any number with a leading zero sets the minimum number of digits |
120 |
if ( p[nNeg] == '0' && pMinDigits && ( nNum - nNeg > *pMinDigits ) ) |
121 |
*pMinDigits = nNum - nNeg; |
122 |
aValue.Erase( 0, nNum ); |
123 |
return -1; |
124 |
} |
125 |
else |
126 |
{ |
127 |
nNeg = 0; |
128 |
xub_StrLen nEnd = nNum = aValue.Len() - 1; |
129 |
while ( nNum && CharClass::isAsciiNumeric( p[nNum] ) ) |
130 |
nNum--; |
131 |
if ( p[nNum] == '-' ) |
132 |
{ |
133 |
nNum--; |
134 |
nNeg = 1; |
135 |
} |
136 |
if ( nNum < nEnd - nNeg ) |
137 |
{ // number at the end |
138 |
nVal = aValue.Copy( nNum + 1 ).ToInt32(); |
139 |
// #60893# any number with a leading zero sets the minimum number of digits |
140 |
if ( p[nNum+1+nNeg] == '0' && pMinDigits && ( nEnd - nNum - nNeg > *pMinDigits ) ) |
141 |
*pMinDigits = nEnd - nNum - nNeg; |
142 |
aValue.Erase( nNum + 1 ); |
143 |
return 1; |
144 |
} |
145 |
} |
146 |
nVal = 0; |
147 |
return 0; |
148 |
} |
149 |
|
150 |
String lcl_ValueString( sal_Int32 nValue, USHORT nMinDigits ) |
95 |
String lcl_ValueString( sal_Int32 nValue, USHORT nMinDigits ) |
151 |
{ |
96 |
{ |
152 |
if ( nMinDigits <= 1 ) |
97 |
if ( nMinDigits <= 1 ) |
Lines 197-202
Link Here
|
197 |
{ |
142 |
{ |
198 |
DBG_ASSERT( nCol1==nCol2 || nRow1==nRow2, "FillAnalyse: falscher Bereich" ); |
143 |
DBG_ASSERT( nCol1==nCol2 || nRow1==nRow2, "FillAnalyse: falscher Bereich" ); |
199 |
|
144 |
|
|
|
145 |
using sc::ValueStringParser; |
200 |
rInc = 0.0; |
146 |
rInc = 0.0; |
201 |
rMinDigits = 0; |
147 |
rMinDigits = 0; |
202 |
rListData = NULL; |
148 |
rListData = NULL; |
Lines 362-380
Link Here
|
362 |
} |
308 |
} |
363 |
else if ( nCount > 1 ) |
309 |
else if ( nCount > 1 ) |
364 |
{ |
310 |
{ |
365 |
// pass rMinDigits to all DecompValueString calls |
311 |
// rMinDigits is the maximum of all MinDigits values that has |
366 |
// -> longest number defines rMinDigits |
312 |
// been got from analyzed cells |
367 |
|
313 |
|
368 |
sal_Int32 nVal1; |
314 |
const ValueStringParser aValueString1(aStr); |
369 |
short nFlag1 = lcl_DecompValueString( aStr, nVal1, &rMinDigits ); |
315 |
sal_Int32 nVal1(aValueString1.GetValue()); |
370 |
if ( nFlag1 ) |
316 |
rMinDigits = sal::static_int_cast<USHORT>(aValueString1.GetMinDigits()); |
|
|
317 |
if (aValueString1.HasValue()) |
371 |
{ |
318 |
{ |
372 |
sal_Int32 nVal2; |
|
|
373 |
GetString( nCol+nAddX, nRow+nAddY, aStr ); |
319 |
GetString( nCol+nAddX, nRow+nAddY, aStr ); |
374 |
short nFlag2 = lcl_DecompValueString( aStr, nVal2, &rMinDigits ); |
320 |
const ValueStringParser aValueString2(aStr); |
375 |
if ( nFlag1 == nFlag2 ) |
321 |
sal_Int32 nVal2(aValueString2.GetValue()); |
|
|
322 |
rMinDigits = std::max(rMinDigits, |
323 |
sal::static_int_cast<USHORT>(aValueString2.GetMinDigits())); |
324 |
if (CanBeOrdered(aValueString1, aValueString2)) |
376 |
{ |
325 |
{ |
377 |
rInc = (double)nVal2 - (double)nVal1; |
326 |
rInc = static_cast<double>(nVal2) - static_cast<double>(nVal1); |
378 |
nCol = sal::static_int_cast<SCCOL>( nCol + nAddX ); |
327 |
nCol = sal::static_int_cast<SCCOL>( nCol + nAddX ); |
379 |
nRow = sal::static_int_cast<SCROW>( nRow + nAddY ); |
328 |
nRow = sal::static_int_cast<SCROW>( nRow + nAddY ); |
380 |
BOOL bVal = TRUE; |
329 |
BOOL bVal = TRUE; |
Lines 388-397
Link Here
|
388 |
((ScStringCell*)pCell)->GetString( aStr ); |
337 |
((ScStringCell*)pCell)->GetString( aStr ); |
389 |
else |
338 |
else |
390 |
((ScEditCell*)pCell)->GetString( aStr ); |
339 |
((ScEditCell*)pCell)->GetString( aStr ); |
391 |
nFlag2 = lcl_DecompValueString( aStr, nVal2, &rMinDigits ); |
340 |
const ValueStringParser aValueString(aStr); |
392 |
if ( nFlag1 == nFlag2 ) |
341 |
nVal2 = aValueString.GetValue(); |
|
|
342 |
rMinDigits = std::max(rMinDigits, |
343 |
sal::static_int_cast<USHORT>(aValueString.GetMinDigits())); |
344 |
if (CanBeOrdered(aValueString1, aValueString)) |
393 |
{ |
345 |
{ |
394 |
double nDiff = (double)nVal2 - (double)nVal1; |
346 |
double nDiff = static_cast<double>(nVal2) - static_cast<double>(nVal1); |
395 |
if ( !::rtl::math::approxEqual( nDiff, rInc ) ) |
347 |
if ( !::rtl::math::approxEqual( nDiff, rInc ) ) |
396 |
bVal = FALSE; |
348 |
bVal = FALSE; |
397 |
nVal1 = nVal2; |
349 |
nVal1 = nVal2; |
Lines 411-419
Link Here
|
411 |
} |
363 |
} |
412 |
else |
364 |
else |
413 |
{ |
365 |
{ |
414 |
// call DecompValueString to set rMinDigits |
366 |
// just set rMinDigits |
415 |
sal_Int32 nDummy; |
367 |
const ValueStringParser aValueString(aStr); |
416 |
lcl_DecompValueString( aStr, nDummy, &rMinDigits ); |
368 |
rMinDigits = aValueString.GetMinDigits(); |
417 |
} |
369 |
} |
418 |
} |
370 |
} |
419 |
} |
371 |
} |
Lines 747-753
Link Here
|
747 |
BOOL bFirst = TRUE; |
699 |
BOOL bFirst = TRUE; |
748 |
BOOL bGetCell = TRUE; |
700 |
BOOL bGetCell = TRUE; |
749 |
USHORT nCellDigits = 0; |
701 |
USHORT nCellDigits = 0; |
750 |
short nHeadNoneTail = 0; |
702 |
bool bIsValue(false); |
|
|
703 |
bool bIsPrefix(false); |
751 |
sal_Int32 nStringValue = 0; |
704 |
sal_Int32 nStringValue = 0; |
752 |
String aValue; |
705 |
String aValue; |
753 |
ScBaseCell* pSrcCell = NULL; |
706 |
ScBaseCell* pSrcCell = NULL; |
Lines 780-789
Link Here
|
780 |
((ScEditCell*)pSrcCell)->GetString( aValue ); |
733 |
((ScEditCell*)pSrcCell)->GetString( aValue ); |
781 |
if ( !(nScFillModeMouseModifier & KEY_MOD1) ) |
734 |
if ( !(nScFillModeMouseModifier & KEY_MOD1) ) |
782 |
{ |
735 |
{ |
783 |
nCellDigits = 0; // look at each source cell individually |
736 |
// look at each source cell individually |
784 |
nHeadNoneTail = lcl_DecompValueString( |
737 |
const sc::ValueStringParser aValueString(aValue); |
785 |
aValue, nStringValue, &nCellDigits ); |
738 |
bIsValue = aValueString.HasValue(); |
786 |
|
739 |
nCellDigits = aValueString.GetMinDigits(); |
|
|
740 |
aValue = aValueString.GetBaseSubstring(); |
741 |
nStringValue = aValueString.GetValue(); |
742 |
bIsPrefix = aValueString.IsPrefix(); |
787 |
bIsOrdinalSuffix = aValue.Equals( |
743 |
bIsOrdinalSuffix = aValue.Equals( |
788 |
ScGlobal::GetOrdinalSuffix( nStringValue)); |
744 |
ScGlobal::GetOrdinalSuffix( nStringValue)); |
789 |
} |
745 |
} |
Lines 804-810
Link Here
|
804 |
break; |
760 |
break; |
805 |
case CELLTYPE_STRING: |
761 |
case CELLTYPE_STRING: |
806 |
case CELLTYPE_EDIT: |
762 |
case CELLTYPE_EDIT: |
807 |
if ( nHeadNoneTail ) |
763 |
if (bIsValue) |
808 |
{ |
764 |
{ |
809 |
// #i48009# with the "nStringValue+(long)nDelta" expression within the |
765 |
// #i48009# with the "nStringValue+(long)nDelta" expression within the |
810 |
// lcl_ValueString calls, gcc 3.4.1 makes wrong optimizations (ok in 3.4.3), |
766 |
// lcl_ValueString calls, gcc 3.4.1 makes wrong optimizations (ok in 3.4.3), |
Lines 812-818
Link Here
|
812 |
sal_Int32 nNextValue = nStringValue+(sal_Int32)nDelta; |
768 |
sal_Int32 nNextValue = nStringValue+(sal_Int32)nDelta; |
813 |
|
769 |
|
814 |
String aStr; |
770 |
String aStr; |
815 |
if ( nHeadNoneTail < 0 ) |
771 |
if (bIsPrefix) |
816 |
{ |
772 |
{ |
817 |
aCol[nCol].Insert( static_cast<SCROW>(nRow), |
773 |
aCol[nCol].Insert( static_cast<SCROW>(nRow), |
818 |
lcl_getSuffixCell( pDocument, |
774 |
lcl_getSuffixCell( pDocument, |
Lines 902-917
Link Here
|
902 |
if (!bPositive) |
858 |
if (!bPositive) |
903 |
nInc = -nInc; |
859 |
nInc = -nInc; |
904 |
double nEndVal = (nInc>=0.0) ? MAXDOUBLE : -MAXDOUBLE; |
860 |
double nEndVal = (nInc>=0.0) ? MAXDOUBLE : -MAXDOUBLE; |
|
|
861 |
sc::FillSeriesData aFillData; |
862 |
aFillData.eDir = eFillDir; |
863 |
aFillData.eCmd = eFillCmd; |
864 |
aFillData.eDateCmd = eDateCmd; |
865 |
aFillData.fStep = nInc; |
866 |
aFillData.fMax = nEndVal; |
905 |
if (bVertical) |
867 |
if (bVertical) |
906 |
FillSeries( static_cast<SCCOL>(nCol), nRow1, |
868 |
FillSeries( static_cast<SCCOL>(nCol), nRow1, |
907 |
static_cast<SCCOL>(nCol), nRow2, nFillCount, eFillDir, |
869 |
static_cast<SCCOL>(nCol), nRow2, nFillCount, aFillData, |
908 |
eFillCmd, eDateCmd, nInc, nEndVal, nMinDigits, FALSE, |
870 |
nMinDigits, FALSE, rProgress ); |
909 |
rProgress ); |
|
|
910 |
else |
871 |
else |
911 |
FillSeries( nCol1, static_cast<SCROW>(nRow), nCol2, |
872 |
FillSeries( nCol1, static_cast<SCROW>(nRow), nCol2, |
912 |
static_cast<SCROW>(nRow), nFillCount, eFillDir, |
873 |
static_cast<SCROW>(nRow), nFillCount, aFillData, |
913 |
eFillCmd, eDateCmd, nInc, nEndVal, nMinDigits, FALSE, |
874 |
nMinDigits, FALSE, rProgress ); |
914 |
rProgress ); |
|
|
915 |
nProgress = rProgress.GetState(); |
875 |
nProgress = rProgress.GetState(); |
916 |
} |
876 |
} |
917 |
|
877 |
|
Lines 1013-1031
Link Here
|
1013 |
((ScEditCell*)pCell)->GetString( aValue ); |
973 |
((ScEditCell*)pCell)->GetString( aValue ); |
1014 |
if ( !(nScFillModeMouseModifier & KEY_MOD1) ) |
974 |
if ( !(nScFillModeMouseModifier & KEY_MOD1) ) |
1015 |
{ |
975 |
{ |
1016 |
sal_Int32 nVal; |
976 |
// look at each source cell individually |
1017 |
USHORT nCellDigits = 0; // look at each source cell individually |
977 |
const sc::ValueStringParser aValueString(aValue); |
1018 |
short nFlag = lcl_DecompValueString( aValue, nVal, &nCellDigits ); |
978 |
sal_Int32 nVal(aValueString.GetValue()); |
1019 |
if ( nFlag < 0 ) |
979 |
USHORT nCellDigits(sal::static_int_cast<USHORT>( |
|
|
980 |
aValueString.GetMinDigits())); |
981 |
aValue = aValueString.GetBaseSubstring(); |
982 |
if (aValueString.HasValue()) |
1020 |
{ |
983 |
{ |
1021 |
if (aValue.Equals( ScGlobal::GetOrdinalSuffix( nVal))) |
984 |
if (aValueString.IsPrefix()) |
1022 |
aValue = ScGlobal::GetOrdinalSuffix( nVal + nDelta); |
985 |
{ |
|
|
986 |
if (aValue.Equals( ScGlobal::GetOrdinalSuffix( nVal))) |
987 |
aValue = ScGlobal::GetOrdinalSuffix( nVal + nDelta); |
1023 |
|
988 |
|
1024 |
aValue.Insert( lcl_ValueString( nVal + nDelta, nCellDigits ), 0 ); |
989 |
aValue.Insert( lcl_ValueString( nVal + nDelta, nCellDigits ), 0 ); |
|
|
990 |
} |
991 |
else |
992 |
{ |
993 |
aValue += lcl_ValueString( nVal + nDelta, nCellDigits ); |
994 |
} |
1025 |
} |
995 |
} |
1026 |
else if ( nFlag > 0 ) |
996 |
} |
1027 |
aValue += lcl_ValueString( nVal + nDelta, nCellDigits ); |
|
|
1028 |
} |
1029 |
} |
997 |
} |
1030 |
break; |
998 |
break; |
1031 |
case CELLTYPE_VALUE: |
999 |
case CELLTYPE_VALUE: |
Lines 1054-1060
Link Here
|
1054 |
BOOL bValueOk; |
1022 |
BOOL bValueOk; |
1055 |
double nStart; |
1023 |
double nStart; |
1056 |
sal_Int32 nVal = 0; |
1024 |
sal_Int32 nVal = 0; |
1057 |
short nHeadNoneTail = 0; |
1025 |
bool bHasValue(false); |
|
|
1026 |
bool bIsPrefix(false); |
1058 |
ScBaseCell* pCell = GetCell( nCol1, nRow1 ); |
1027 |
ScBaseCell* pCell = GetCell( nCol1, nRow1 ); |
1059 |
if ( pCell ) |
1028 |
if ( pCell ) |
1060 |
{ |
1029 |
{ |
Lines 1068-1075
Link Here
|
1068 |
((ScStringCell*)pCell)->GetString( aValue ); |
1037 |
((ScStringCell*)pCell)->GetString( aValue ); |
1069 |
else |
1038 |
else |
1070 |
((ScEditCell*)pCell)->GetString( aValue ); |
1039 |
((ScEditCell*)pCell)->GetString( aValue ); |
1071 |
nHeadNoneTail = lcl_DecompValueString( aValue, nVal ); |
1040 |
{ |
1072 |
if ( nHeadNoneTail ) |
1041 |
const sc::ValueStringParser aValueString(aValue); |
|
|
1042 |
aValue = aValueString.GetBaseSubstring(); |
1043 |
bHasValue = aValueString.HasValue(); |
1044 |
bIsPrefix = aValueString.IsPrefix(); |
1045 |
nVal = aValueString.GetValue(); |
1046 |
} |
1047 |
if (bHasValue) |
1073 |
nStart = (double)nVal; |
1048 |
nStart = (double)nVal; |
1074 |
else |
1049 |
else |
1075 |
nStart = 0.0; |
1050 |
nStart = 0.0; |
Lines 1108-1116
Link Here
|
1108 |
|
1083 |
|
1109 |
if (bValueOk) |
1084 |
if (bValueOk) |
1110 |
{ |
1085 |
{ |
1111 |
if ( nHeadNoneTail ) |
1086 |
if (bHasValue) |
1112 |
{ |
1087 |
{ |
1113 |
if ( nHeadNoneTail < 0 ) |
1088 |
if (bIsPrefix) |
1114 |
{ |
1089 |
{ |
1115 |
if (aValue.Equals( ScGlobal::GetOrdinalSuffix( nVal))) |
1090 |
if (aValue.Equals( ScGlobal::GetOrdinalSuffix( nVal))) |
1116 |
aValue = ScGlobal::GetOrdinalSuffix( (sal_Int32)nStart ); |
1091 |
aValue = ScGlobal::GetOrdinalSuffix( (sal_Int32)nStart ); |
Lines 1239-1255
Link Here
|
1239 |
rVal = aDate - aNullDate; |
1214 |
rVal = aDate - aNullDate; |
1240 |
} |
1215 |
} |
1241 |
|
1216 |
|
1242 |
void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, |
1217 |
|
1243 |
ULONG nFillCount, FillDir eFillDir, FillCmd eFillCmd, FillDateCmd eFillDateCmd, |
1218 |
void |
1244 |
double nStepValue, double nMaxValue, USHORT nArgMinDigits, |
1219 |
ScTable::FillSeries(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, |
1245 |
BOOL bAttribs, ScProgress& rProgress ) |
1220 |
ULONG nFillCount, const sc::FillSeriesData& rFillData, |
|
|
1221 |
USHORT nArgMinDigits, bool bAttribs, ScProgress& rProgress) |
1246 |
{ |
1222 |
{ |
1247 |
// |
1223 |
// |
1248 |
// Richtung auswerten |
1224 |
// Richtung auswerten |
1249 |
// |
1225 |
// |
1250 |
|
1226 |
|
1251 |
BOOL bVertical = (eFillDir == FILL_TO_BOTTOM || eFillDir == FILL_TO_TOP); |
1227 |
BOOL bVertical = (rFillData.eDir == FILL_TO_BOTTOM || rFillData.eDir == FILL_TO_TOP); |
1252 |
BOOL bPositive = (eFillDir == FILL_TO_BOTTOM || eFillDir == FILL_TO_RIGHT); |
1228 |
BOOL bPositive = (rFillData.eDir == FILL_TO_BOTTOM || rFillData.eDir == FILL_TO_RIGHT); |
1253 |
|
1229 |
|
1254 |
ULONG nCol = 0; |
1230 |
ULONG nCol = 0; |
1255 |
ULONG nRow = 0; |
1231 |
ULONG nRow = 0; |
Lines 1340-1348
Link Here
|
1340 |
|
1316 |
|
1341 |
if (pSrcCell) |
1317 |
if (pSrcCell) |
1342 |
{ |
1318 |
{ |
|
|
1319 |
double fMaxValue(rFillData.fMax); |
1343 |
CellType eCellType = pSrcCell->GetCellType(); |
1320 |
CellType eCellType = pSrcCell->GetCellType(); |
1344 |
|
1321 |
|
1345 |
if (eFillCmd == FILL_SIMPLE) // kopieren |
1322 |
if (rFillData.eCmd == FILL_SIMPLE) // kopieren |
1346 |
{ |
1323 |
{ |
1347 |
if (eCellType == CELLTYPE_FORMULA) |
1324 |
if (eCellType == CELLTYPE_FORMULA) |
1348 |
{ |
1325 |
{ |
Lines 1385-1432
Link Here
|
1385 |
{ |
1362 |
{ |
1386 |
if (!bError && !bOverflow) |
1363 |
if (!bError && !bOverflow) |
1387 |
{ |
1364 |
{ |
1388 |
switch (eFillCmd) |
1365 |
switch (rFillData.eCmd) |
1389 |
{ |
1366 |
{ |
1390 |
case FILL_LINEAR: |
1367 |
case FILL_LINEAR: |
1391 |
{ |
1368 |
{ |
1392 |
// #86365# use multiplication instead of repeated addition |
1369 |
// #86365# use multiplication instead of repeated addition |
1393 |
// to avoid accumulating rounding errors |
1370 |
// to avoid accumulating rounding errors |
1394 |
nVal = nStartVal; |
1371 |
nVal = nStartVal; |
1395 |
double nAdd = nStepValue; |
1372 |
double nAdd = rFillData.fStep; |
1396 |
if ( !SubTotal::SafeMult( nAdd, (double) ++nIndex ) || |
1373 |
if ( !SubTotal::SafeMult( nAdd, (double) ++nIndex ) || |
1397 |
!SubTotal::SafePlus( nVal, nAdd ) ) |
1374 |
!SubTotal::SafePlus( nVal, nAdd ) ) |
1398 |
bError = TRUE; |
1375 |
bError = TRUE; |
1399 |
} |
1376 |
} |
1400 |
break; |
1377 |
break; |
1401 |
case FILL_GROWTH: |
1378 |
case FILL_GROWTH: |
1402 |
if (!SubTotal::SafeMult(nVal, nStepValue)) |
1379 |
if (!SubTotal::SafeMult(nVal, rFillData.fStep)) |
1403 |
bError = TRUE; |
1380 |
bError = TRUE; |
1404 |
break; |
1381 |
break; |
1405 |
case FILL_DATE: |
1382 |
case FILL_DATE: |
1406 |
if (fabs(nVal) > _D_MAX_LONG_) |
1383 |
if (fabs(nVal) > _D_MAX_LONG_) |
1407 |
bError = TRUE; |
1384 |
bError = TRUE; |
1408 |
else |
1385 |
else |
1409 |
IncDate(nVal, nDayOfMonth, nStepValue, eFillDateCmd); |
1386 |
IncDate(nVal, nDayOfMonth, rFillData.fStep, rFillData.eDateCmd); break; |
1410 |
break; |
|
|
1411 |
default: |
1387 |
default: |
1412 |
{ |
1388 |
{ |
1413 |
// added to avoid warnings |
1389 |
// added to avoid warnings |
1414 |
} |
1390 |
} |
1415 |
} |
1391 |
} |
1416 |
|
1392 |
|
1417 |
if (nStepValue >= 0) |
1393 |
if (rFillData.fStep >= 0) |
1418 |
{ |
1394 |
{ |
1419 |
if (nVal > nMaxValue) // Zielwert erreicht? |
1395 |
if (nVal > fMaxValue) // Zielwert erreicht? |
1420 |
{ |
1396 |
{ |
1421 |
nVal = nMaxValue; |
1397 |
nVal = fMaxValue; |
1422 |
bOverflow = TRUE; |
1398 |
bOverflow = TRUE; |
1423 |
} |
1399 |
} |
1424 |
} |
1400 |
} |
1425 |
else |
1401 |
else |
1426 |
{ |
1402 |
{ |
1427 |
if (nVal < nMaxValue) |
1403 |
if (nVal < fMaxValue) |
1428 |
{ |
1404 |
{ |
1429 |
nVal = nMaxValue; |
1405 |
nVal = fMaxValue; |
1430 |
bOverflow = TRUE; |
1406 |
bOverflow = TRUE; |
1431 |
} |
1407 |
} |
1432 |
} |
1408 |
} |
Lines 1445-1471
Link Here
|
1445 |
} |
1421 |
} |
1446 |
else if (eCellType == CELLTYPE_STRING || eCellType == CELLTYPE_EDIT) |
1422 |
else if (eCellType == CELLTYPE_STRING || eCellType == CELLTYPE_EDIT) |
1447 |
{ |
1423 |
{ |
1448 |
if ( nStepValue >= 0 ) |
1424 |
if (rFillData.fStep >= 0) |
1449 |
{ |
1425 |
{ |
1450 |
if ( nMaxValue >= (double)LONG_MAX ) |
1426 |
if (fMaxValue >= static_cast<double>(LONG_MAX)) |
1451 |
nMaxValue = (double)LONG_MAX - 1; |
1427 |
fMaxValue = static_cast<double>(LONG_MAX) - 1; |
1452 |
} |
1428 |
} |
1453 |
else |
1429 |
else |
1454 |
{ |
1430 |
{ |
1455 |
if ( nMaxValue <= (double)LONG_MIN ) |
1431 |
if (fMaxValue <= static_cast<double>(LONG_MIN)) |
1456 |
nMaxValue = (double)LONG_MIN + 1; |
1432 |
fMaxValue = static_cast<double>(LONG_MIN) + 1; |
1457 |
} |
1433 |
} |
1458 |
String aValue; |
1434 |
String aValue; |
1459 |
if (eCellType == CELLTYPE_STRING) |
1435 |
if (eCellType == CELLTYPE_STRING) |
1460 |
((ScStringCell*)pSrcCell)->GetString( aValue ); |
1436 |
((ScStringCell*)pSrcCell)->GetString( aValue ); |
1461 |
else |
1437 |
else |
1462 |
((ScEditCell*)pSrcCell)->GetString( aValue ); |
1438 |
((ScEditCell*)pSrcCell)->GetString( aValue ); |
1463 |
sal_Int32 nStringValue; |
1439 |
const sc::ValueStringParser aValueString(aValue); |
1464 |
USHORT nMinDigits = nArgMinDigits; |
1440 |
sal_Int32 nStringValue(aValueString.GetValue()); |
1465 |
short nHeadNoneTail = lcl_DecompValueString( aValue, nStringValue, &nMinDigits ); |
1441 |
USHORT nMinDigits(0); |
1466 |
if ( nHeadNoneTail ) |
1442 |
if (nArgMinDigits == 0 && rFillData.bUseString) |
|
|
1443 |
{ |
1444 |
const sc::ValueStringParser aStart(rFillData.aStart); |
1445 |
const sc::ValueStringParser aMax(rFillData.aMax); |
1446 |
nMinDigits = std::max(aStart.GetMinDigits(), aMax.GetMinDigits()); |
1447 |
} |
1448 |
else |
1449 |
{ |
1450 |
nMinDigits = std::max( |
1451 |
nArgMinDigits, |
1452 |
sal::static_int_cast<USHORT>(aValueString.GetMinDigits())); |
1453 |
} |
1454 |
aValue = aValueString.GetBaseSubstring(); |
1455 |
if (aValueString.HasValue()) |
1467 |
{ |
1456 |
{ |
1468 |
double nStartVal = (double)nStringValue; |
1457 |
double nStartVal = static_cast<double>(nStringValue); |
1469 |
double nVal = nStartVal; |
1458 |
double nVal = nStartVal; |
1470 |
long nIndex = 0; |
1459 |
long nIndex = 0; |
1471 |
BOOL bError = FALSE; |
1460 |
BOOL bError = FALSE; |
Lines 1479-1499
Link Here
|
1479 |
{ |
1468 |
{ |
1480 |
if (!bError && !bOverflow) |
1469 |
if (!bError && !bOverflow) |
1481 |
{ |
1470 |
{ |
1482 |
switch (eFillCmd) |
1471 |
switch (rFillData.eCmd) |
1483 |
{ |
1472 |
{ |
1484 |
case FILL_LINEAR: |
1473 |
case FILL_LINEAR: |
1485 |
{ |
1474 |
{ |
1486 |
// #86365# use multiplication instead of repeated addition |
1475 |
// #86365# use multiplication instead of repeated addition |
1487 |
// to avoid accumulating rounding errors |
1476 |
// to avoid accumulating rounding errors |
1488 |
nVal = nStartVal; |
1477 |
nVal = nStartVal; |
1489 |
double nAdd = nStepValue; |
1478 |
double nAdd = rFillData.fStep; |
1490 |
if ( !SubTotal::SafeMult( nAdd, (double) ++nIndex ) || |
1479 |
if ( !SubTotal::SafeMult( nAdd, (double) ++nIndex ) || |
1491 |
!SubTotal::SafePlus( nVal, nAdd ) ) |
1480 |
!SubTotal::SafePlus( nVal, nAdd ) ) |
1492 |
bError = TRUE; |
1481 |
bError = TRUE; |
1493 |
} |
1482 |
} |
1494 |
break; |
1483 |
break; |
1495 |
case FILL_GROWTH: |
1484 |
case FILL_GROWTH: |
1496 |
if (!SubTotal::SafeMult(nVal, nStepValue)) |
1485 |
if (!SubTotal::SafeMult(nVal, rFillData.fStep)) |
1497 |
bError = TRUE; |
1486 |
bError = TRUE; |
1498 |
break; |
1487 |
break; |
1499 |
default: |
1488 |
default: |
Lines 1502-1520
Link Here
|
1502 |
} |
1491 |
} |
1503 |
} |
1492 |
} |
1504 |
|
1493 |
|
1505 |
if (nStepValue >= 0) |
1494 |
if (rFillData.fStep >= 0) |
1506 |
{ |
1495 |
{ |
1507 |
if (nVal > nMaxValue) // Zielwert erreicht? |
1496 |
if (nVal > fMaxValue) // Zielwert erreicht? |
1508 |
{ |
1497 |
{ |
1509 |
nVal = nMaxValue; |
1498 |
nVal = fMaxValue; |
1510 |
bOverflow = TRUE; |
1499 |
bOverflow = TRUE; |
1511 |
} |
1500 |
} |
1512 |
} |
1501 |
} |
1513 |
else |
1502 |
else |
1514 |
{ |
1503 |
{ |
1515 |
if (nVal < nMaxValue) |
1504 |
if (nVal < fMaxValue) |
1516 |
{ |
1505 |
{ |
1517 |
nVal = nMaxValue; |
1506 |
nVal = fMaxValue; |
1518 |
bOverflow = TRUE; |
1507 |
bOverflow = TRUE; |
1519 |
} |
1508 |
} |
1520 |
} |
1509 |
} |
Lines 1524-1532
Link Here
|
1524 |
aCol[nCol].SetError(static_cast<SCROW>(nRow), errNoValue); |
1513 |
aCol[nCol].SetError(static_cast<SCROW>(nRow), errNoValue); |
1525 |
else if (!bOverflow) |
1514 |
else if (!bOverflow) |
1526 |
{ |
1515 |
{ |
1527 |
nStringValue = (sal_Int32)nVal; |
1516 |
nStringValue = static_cast<sal_Int32>(nVal); |
1528 |
String aStr; |
1517 |
String aStr; |
1529 |
if ( nHeadNoneTail < 0 ) |
1518 |
if (aValueString.IsPrefix()) |
1530 |
{ |
1519 |
{ |
1531 |
aCol[nCol].Insert( static_cast<SCROW>(nRow), |
1520 |
aCol[nCol].Insert( static_cast<SCROW>(nRow), |
1532 |
lcl_getSuffixCell( pDocument, |
1521 |
lcl_getSuffixCell( pDocument, |
Lines 1563-1570
Link Here
|
1563 |
ULONG nFillCount, FillDir eFillDir, FillCmd eFillCmd, FillDateCmd eFillDateCmd, |
1552 |
ULONG nFillCount, FillDir eFillDir, FillCmd eFillCmd, FillDateCmd eFillDateCmd, |
1564 |
double nStepValue, double nMaxValue) |
1553 |
double nStepValue, double nMaxValue) |
1565 |
{ |
1554 |
{ |
|
|
1555 |
sc::FillSeriesData aFillData; |
1556 |
aFillData.eDir = eFillDir; |
1557 |
aFillData.eCmd = eFillCmd; |
1558 |
aFillData.eDateCmd = eFillDateCmd; |
1559 |
aFillData.fStep = nStepValue; |
1560 |
aFillData.fMax = nMaxValue; |
1561 |
Fill(nCol1, nRow1, nCol2, nRow2, nFillCount, aFillData); |
1562 |
} |
1563 |
|
1564 |
|
1565 |
void ScTable::Fill( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, |
1566 |
ULONG nFillCount, const sc::FillSeriesData& rFillData) |
1567 |
{ |
1566 |
ULONG nProgCount; |
1568 |
ULONG nProgCount; |
1567 |
if (eFillDir == FILL_TO_BOTTOM || eFillDir == FILL_TO_TOP) |
1569 |
if (rFillData.eDir == FILL_TO_BOTTOM || rFillData.eDir == FILL_TO_TOP) |
1568 |
nProgCount = nCol2 - nCol1 + 1; |
1570 |
nProgCount = nCol2 - nCol1 + 1; |
1569 |
else |
1571 |
else |
1570 |
nProgCount = nRow2 - nRow1 + 1; |
1572 |
nProgCount = nRow2 - nRow1 + 1; |
Lines 1574-1584
Link Here
|
1574 |
|
1576 |
|
1575 |
bSharedNameInserted = FALSE; |
1577 |
bSharedNameInserted = FALSE; |
1576 |
|
1578 |
|
1577 |
if (eFillCmd == FILL_AUTO) |
1579 |
if (rFillData.eCmd == FILL_AUTO) |
1578 |
FillAuto(nCol1, nRow1, nCol2, nRow2, nFillCount, eFillDir, aProgress); |
1580 |
FillAuto(nCol1, nRow1, nCol2, nRow2, nFillCount, rFillData.eDir, aProgress); |
1579 |
else |
1581 |
else |
1580 |
FillSeries(nCol1, nRow1, nCol2, nRow2, nFillCount, eFillDir, |
1582 |
FillSeries(nCol1, nRow1, nCol2, nRow2, nFillCount, rFillData, 0, true, aProgress); |
1581 |
eFillCmd, eFillDateCmd, nStepValue, nMaxValue, 0, TRUE, aProgress); |
|
|
1582 |
|
1583 |
|
1583 |
if (bSharedNameInserted) // Wurde Shared-Name eingefuegt? |
1584 |
if (bSharedNameInserted) // Wurde Shared-Name eingefuegt? |
1584 |
pDocument->GetRangeName()->SetSharedMaxIndex( |
1585 |
pDocument->GetRangeName()->SetSharedMaxIndex( |
Lines 1985-1993
Link Here
|
1985 |
{ |
1986 |
{ |
1986 |
for (SCCOL i=0; i<=MAXCOL; i++) aCol[i].CompileColRowNameFormula(); |
1987 |
for (SCCOL i=0; i<=MAXCOL; i++) aCol[i].CompileColRowNameFormula(); |
1987 |
} |
1988 |
} |
1988 |
|
|
|
1989 |
|
1990 |
|
1991 |
|
1992 |
|
1993 |
|