Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifdef _MSC_VER
30 : : #pragma optimize("",off)
31 : : // sonst Absturz Win beim Fuellen
32 : : #endif
33 : :
34 : : #include "scitems.hxx"
35 : : #include <svx/algitem.hxx>
36 : : #include <editeng/boxitem.hxx>
37 : : #include <editeng/brshitem.hxx>
38 : : #include <editeng/cntritem.hxx>
39 : : #include <editeng/colritem.hxx>
40 : : #include <editeng/crsditem.hxx>
41 : : #include <editeng/fhgtitem.hxx>
42 : : #include <editeng/fontitem.hxx>
43 : : #include <editeng/langitem.hxx>
44 : : #include <editeng/postitem.hxx>
45 : : #include <editeng/shdditem.hxx>
46 : : #include <editeng/udlnitem.hxx>
47 : : #include <editeng/wghtitem.hxx>
48 : : #include <svx/rotmodit.hxx>
49 : : #include <editeng/editobj.hxx>
50 : : #include <editeng/editeng.hxx>
51 : : #include <editeng/eeitem.hxx>
52 : : #include <editeng/escpitem.hxx>
53 : : #include <svl/zforlist.hxx>
54 : : #include <vcl/keycodes.hxx>
55 : : #include <rtl/math.hxx>
56 : : #include <unotools/charclass.hxx>
57 : :
58 : : #include "attrib.hxx"
59 : : #include "patattr.hxx"
60 : : #include "cell.hxx"
61 : : #include "table.hxx"
62 : : #include "globstr.hrc"
63 : : #include "global.hxx"
64 : : #include "document.hxx"
65 : : #include "autoform.hxx"
66 : : #include "userlist.hxx"
67 : : #include "zforauto.hxx"
68 : : #include "subtotal.hxx"
69 : : #include "formula/errorcodes.hxx"
70 : : #include "rangenam.hxx"
71 : : #include "docpool.hxx"
72 : : #include "progress.hxx"
73 : : #include "segmenttree.hxx"
74 : :
75 : : #include <math.h>
76 : :
77 : : // STATIC DATA -----------------------------------------------------------
78 : :
79 : : #define _D_MAX_LONG_ (double) 0x7fffffff
80 : :
81 : : extern sal_uInt16 nScFillModeMouseModifier; // global.cxx
82 : :
83 : : // -----------------------------------------------------------------------
84 : :
85 : 6 : short lcl_DecompValueString( String& aValue, sal_Int32& nVal, sal_uInt16* pMinDigits = NULL )
86 : : {
87 [ - + ]: 6 : if ( !aValue.Len() )
88 : : {
89 : 0 : nVal = 0;
90 : 0 : return 0;
91 : : }
92 : 6 : const sal_Unicode* p = aValue.GetBuffer();
93 : 6 : xub_StrLen nNeg = 0;
94 : 6 : xub_StrLen nNum = 0;
95 [ - + ]: 6 : if ( p[nNum] == '-' )
96 : 0 : nNum = nNeg = 1;
97 [ + - ][ + - ]: 6 : while ( p[nNum] && CharClass::isAsciiNumeric( rtl::OUString(p[nNum]) ) )
[ + - ][ - + ]
[ + - ][ + - ]
[ + - ][ - +
# # # # ]
98 : 0 : nNum++;
99 : :
100 : 6 : sal_Unicode cNext = p[nNum]; // 0 if at the end
101 : 6 : sal_Unicode cLast = p[aValue.Len()-1];
102 : :
103 : : // #i5550# If there are numbers at the beginning and the end,
104 : : // prefer the one at the beginning only if it's followed by a space.
105 : : // Otherwise, use the number at the end, to enable things like IP addresses.
106 [ # # ][ # # ]: 6 : if ( nNum > nNeg && ( cNext == 0 || cNext == ' ' || !CharClass::isAsciiNumeric(rtl::OUString(cLast)) ) )
[ # # ][ # # ]
[ # # ][ - + ]
[ # # ][ - + ]
[ - + # #
# # ][ - + ]
107 : : { // number at the beginning
108 [ # # ]: 0 : nVal = aValue.Copy( 0, nNum ).ToInt32();
109 : : // any number with a leading zero sets the minimum number of digits
110 [ # # ][ # # ]: 0 : if ( p[nNeg] == '0' && pMinDigits && ( nNum - nNeg > *pMinDigits ) )
[ # # ]
111 : 0 : *pMinDigits = nNum - nNeg;
112 : 0 : aValue.Erase( 0, nNum );
113 : 0 : return -1;
114 : : }
115 : : else
116 : : {
117 : 6 : nNeg = 0;
118 : 6 : xub_StrLen nEnd = nNum = aValue.Len() - 1;
119 [ + - ][ + - ]: 6 : while ( nNum && CharClass::isAsciiNumeric( rtl::OUString(p[nNum]) ) )
[ + - ][ - + ]
[ + - ][ + - ]
[ + - ][ - +
# # # # ]
120 : 0 : nNum--;
121 [ - + ]: 6 : if ( p[nNum] == '-' )
122 : : {
123 : 0 : nNum--;
124 : 0 : nNeg = 1;
125 : : }
126 [ - + ]: 6 : if ( nNum < nEnd - nNeg )
127 : : { // number at the end
128 [ # # ]: 0 : nVal = aValue.Copy( nNum + 1 ).ToInt32();
129 : : // any number with a leading zero sets the minimum number of digits
130 [ # # ][ # # ]: 0 : if ( p[nNum+1+nNeg] == '0' && pMinDigits && ( nEnd - nNum - nNeg > *pMinDigits ) )
[ # # ]
131 : 0 : *pMinDigits = nEnd - nNum - nNeg;
132 : 0 : aValue.Erase( nNum + 1 );
133 : 0 : return 1;
134 : : }
135 : : }
136 : 6 : nVal = 0;
137 : 6 : return 0;
138 : : }
139 : :
140 : 0 : String lcl_ValueString( sal_Int32 nValue, sal_uInt16 nMinDigits )
141 : : {
142 [ # # ]: 0 : if ( nMinDigits <= 1 )
143 : 0 : return String::CreateFromInt32( nValue ); // simple case...
144 : : else
145 : : {
146 [ # # ]: 0 : String aStr = String::CreateFromInt32( Abs( nValue ) );
147 [ # # ]: 0 : if ( aStr.Len() < nMinDigits )
148 : : {
149 [ # # ]: 0 : String aZero;
150 [ # # ]: 0 : aZero.Fill( nMinDigits - aStr.Len(), '0' );
151 [ # # ][ # # ]: 0 : aStr.Insert( aZero, 0 );
152 : : }
153 : : // nMinDigits doesn't include the '-' sign -> add after inserting zeros
154 [ # # ]: 0 : if ( nValue < 0 )
155 [ # # ]: 0 : aStr.Insert( '-', 0 );
156 [ # # ][ # # ]: 0 : return aStr;
157 : : }
158 : : }
159 : :
160 : 0 : static ScBaseCell * lcl_getSuffixCell( ScDocument* pDocument, sal_Int32 nValue,
161 : : sal_uInt16 nDigits, const String& rSuffix, CellType eCellType,
162 : : bool bIsOrdinalSuffix )
163 : : {
164 [ # # ]: 0 : String aValue( lcl_ValueString( nValue, nDigits ));
165 [ # # ]: 0 : if (!bIsOrdinalSuffix)
166 [ # # ][ # # ]: 0 : return new ScStringCell( aValue += rSuffix);
[ # # ][ # # ]
167 : :
168 [ # # ]: 0 : String aOrdinalSuffix( ScGlobal::GetOrdinalSuffix( nValue));
169 [ # # ]: 0 : if (eCellType != CELLTYPE_EDIT)
170 [ # # ][ # # ]: 0 : return new ScStringCell( aValue += aOrdinalSuffix);
[ # # ][ # # ]
171 : :
172 [ # # ][ # # ]: 0 : EditEngine aEngine( pDocument->GetEnginePool() );
173 [ # # ][ # # ]: 0 : SfxItemSet aAttr = aEngine.GetEmptyItemSet();
174 [ # # ][ # # ]: 0 : aAttr.Put( SvxEscapementItem( SVX_ESCAPEMENT_SUPERSCRIPT, EE_CHAR_ESCAPEMENT));
[ # # ]
175 [ # # ]: 0 : aEngine.SetText( aValue );
176 : 0 : aEngine.QuickInsertText( aOrdinalSuffix, ESelection( 0, aValue.Len(), 0,
177 [ # # ]: 0 : aValue.Len() + aOrdinalSuffix.Len()));
178 : 0 : aEngine.QuickSetAttribs( aAttr, ESelection( 0, aValue.Len(), 0, aValue.Len() +
179 [ # # ]: 0 : aOrdinalSuffix.Len()));
180 [ # # ][ # # ]: 0 : return new ScEditCell( aEngine.CreateTextObject(), pDocument, NULL );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
181 : : }
182 : :
183 : 23 : void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
184 : : FillCmd& rCmd, FillDateCmd& rDateCmd,
185 : : double& rInc, sal_uInt16& rMinDigits,
186 : : ScUserListData*& rListData, sal_uInt16& rListIndex)
187 : : {
188 : : OSL_ENSURE( nCol1==nCol2 || nRow1==nRow2, "FillAnalyse: falscher Bereich" );
189 : :
190 : 23 : rInc = 0.0;
191 : 23 : rMinDigits = 0;
192 : 23 : rListData = NULL;
193 : 23 : rCmd = FILL_SIMPLE;
194 [ - + ]: 23 : if ( (nScFillModeMouseModifier & KEY_MOD1) )
195 : 0 : return ; // Ctrl-Taste: Copy
196 : :
197 : : SCCOL nAddX;
198 : : SCROW nAddY;
199 : : SCSIZE nCount;
200 [ + - ]: 23 : if (nCol1 == nCol2)
201 : : {
202 : 23 : nAddX = 0;
203 : 23 : nAddY = 1;
204 : 23 : nCount = static_cast<SCSIZE>(nRow2 - nRow1 + 1);
205 : : }
206 : : else
207 : : {
208 : 0 : nAddX = 1;
209 : 0 : nAddY = 0;
210 : 0 : nCount = static_cast<SCSIZE>(nCol2 - nCol1 + 1);
211 : : }
212 : :
213 : 23 : SCCOL nCol = nCol1;
214 : 23 : SCROW nRow = nRow1;
215 : :
216 : 23 : ScBaseCell* pFirstCell = GetCell( nCol, nRow );
217 [ + - ]: 23 : CellType eCellType = pFirstCell ? pFirstCell->GetCellType() : CELLTYPE_NONE;
218 : :
219 [ + + ]: 23 : if (eCellType == CELLTYPE_VALUE)
220 : : {
221 : 16 : sal_uInt32 nFormat = ((const SfxUInt32Item*)GetAttr(nCol,nRow,ATTR_VALUE_FORMAT))->GetValue();
222 : 16 : bool bDate = ( pDocument->GetFormatTable()->GetType(nFormat) == NUMBERFORMAT_DATE );
223 [ - + ]: 16 : if (bDate)
224 : : {
225 [ # # ]: 0 : if (nCount > 1)
226 : : {
227 : : double nVal;
228 [ # # ][ # # ]: 0 : Date aNullDate = *pDocument->GetFormatTable()->GetNullDate();
229 : 0 : Date aDate1 = aNullDate;
230 : 0 : nVal = ((ScValueCell*)pFirstCell)->GetValue();
231 [ # # ]: 0 : aDate1 += (long)nVal;
232 : 0 : Date aDate2 = aNullDate;
233 [ # # ]: 0 : nVal = GetValue(nCol+nAddX, nRow+nAddY);
234 [ # # ]: 0 : aDate2 += (long)nVal;
235 [ # # ]: 0 : if ( aDate1 != aDate2 )
236 : : {
237 : 0 : long nCmpInc = 0;
238 : : FillDateCmd eType;
239 : 0 : long nDDiff = aDate2.GetDay() - (long) aDate1.GetDay();
240 : 0 : long nMDiff = aDate2.GetMonth() - (long) aDate1.GetMonth();
241 : 0 : long nYDiff = aDate2.GetYear() - (long) aDate1.GetYear();
242 [ # # ]: 0 : if ( nDDiff )
243 : : {
244 : 0 : eType = FILL_DAY;
245 [ # # ]: 0 : nCmpInc = aDate2 - aDate1;
246 : : }
247 : : else
248 : : {
249 : 0 : eType = FILL_MONTH;
250 : 0 : nCmpInc = nMDiff + 12 * nYDiff;
251 : : }
252 : :
253 : 0 : nCol = sal::static_int_cast<SCCOL>( nCol + nAddX );
254 : 0 : nRow = sal::static_int_cast<SCROW>( nRow + nAddY );
255 : 0 : bool bVal = true;
256 [ # # ][ # # ]: 0 : for (sal_uInt16 i=1; i<nCount && bVal; i++)
[ # # ]
257 : : {
258 [ # # ]: 0 : ScBaseCell* pCell = GetCell(nCol,nRow);
259 [ # # ][ # # ]: 0 : if (pCell && pCell->GetCellType() == CELLTYPE_VALUE)
[ # # ]
260 : : {
261 : 0 : nVal = ((ScValueCell*)pCell)->GetValue();
262 [ # # ]: 0 : aDate2 = aNullDate + (long) nVal;
263 [ # # ]: 0 : if ( eType == FILL_DAY )
264 : : {
265 [ # # ][ # # ]: 0 : if ( aDate2-aDate1 != nCmpInc )
266 : 0 : bVal = false;
267 : : }
268 : : else
269 : : {
270 : 0 : nDDiff = aDate2.GetDay() - (long) aDate1.GetDay();
271 : 0 : nMDiff = aDate2.GetMonth() - (long) aDate1.GetMonth();
272 : 0 : nYDiff = aDate2.GetYear() - (long) aDate1.GetYear();
273 [ # # ][ # # ]: 0 : if (nDDiff || ( nMDiff + 12 * nYDiff != nCmpInc ))
274 : 0 : bVal = false;
275 : : }
276 : 0 : aDate1 = aDate2;
277 : 0 : nCol = sal::static_int_cast<SCCOL>( nCol + nAddX );
278 : 0 : nRow = sal::static_int_cast<SCROW>( nRow + nAddY );
279 : : }
280 : : else
281 : 0 : bVal = false; // kein Datum passt auch nicht
282 : : }
283 [ # # ]: 0 : if (bVal)
284 : : {
285 [ # # ][ # # ]: 0 : if ( eType == FILL_MONTH && ( nCmpInc % 12 == 0 ) )
286 : : {
287 : 0 : eType = FILL_YEAR;
288 : 0 : nCmpInc /= 12;
289 : : }
290 : 0 : rCmd = FILL_DATE;
291 : 0 : rDateCmd = eType;
292 : 0 : rInc = nCmpInc;
293 : : }
294 : : }
295 : : }
296 : : else // einzelnes Datum -> Tage hochzaehlen
297 : : {
298 : 0 : rCmd = FILL_DATE;
299 : 0 : rDateCmd = FILL_DAY;
300 : 0 : rInc = 1.0;
301 : : }
302 : : }
303 : : else
304 : : {
305 [ - + ]: 16 : if (nCount > 1)
306 : : {
307 : 0 : double nVal1 = ((ScValueCell*)pFirstCell)->GetValue();
308 : 0 : double nVal2 = GetValue(nCol+nAddX, nRow+nAddY);
309 : 0 : rInc = nVal2 - nVal1;
310 : 0 : nCol = sal::static_int_cast<SCCOL>( nCol + nAddX );
311 : 0 : nRow = sal::static_int_cast<SCROW>( nRow + nAddY );
312 : 0 : bool bVal = true;
313 [ # # ][ # # ]: 0 : for (sal_uInt16 i=1; i<nCount && bVal; i++)
[ # # ]
314 : : {
315 : 0 : ScBaseCell* pCell = GetCell(nCol,nRow);
316 [ # # ][ # # ]: 0 : if (pCell && pCell->GetCellType() == CELLTYPE_VALUE)
[ # # ]
317 : : {
318 : 0 : nVal2 = ((ScValueCell*)pCell)->GetValue();
319 : 0 : double nDiff = nVal2 - nVal1;
320 [ # # ]: 0 : if ( !::rtl::math::approxEqual( nDiff, rInc, 13 ) )
321 : 0 : bVal = false;
322 : 0 : nVal1 = nVal2;
323 : : }
324 : : else
325 : 0 : bVal = false;
326 : 0 : nCol = sal::static_int_cast<SCCOL>( nCol + nAddX );
327 : 0 : nRow = sal::static_int_cast<SCROW>( nRow + nAddY );
328 : : }
329 [ # # ]: 0 : if (bVal)
330 : 0 : rCmd = FILL_LINEAR;
331 : : }
332 : : }
333 : : }
334 [ + + ][ - + ]: 7 : else if (eCellType == CELLTYPE_STRING || eCellType == CELLTYPE_EDIT)
335 : : {
336 : 6 : rtl::OUString aStr;
337 [ + - ]: 6 : GetString(nCol, nRow, aStr);
338 : :
339 : : // fdo#39500 don't deduce increment from multiple equal list entries
340 : 6 : bool bAllSame = true;
341 [ + + ]: 15 : for (sal_uInt16 i = 0; i < nCount; ++i)
342 : : {
343 : 9 : rtl::OUString aTestStr;
344 [ + - ]: 9 : GetString(static_cast<SCCOL>(nCol + i* nAddX), static_cast<SCROW>(nRow + i * nAddY), aTestStr);
345 [ - + ]: 9 : if(aStr != aTestStr)
346 : : {
347 : 9 : bAllSame = false;
348 : : break;
349 : : }
350 [ + - ]: 9 : }
351 [ + - ][ + + ]: 6 : if(bAllSame && nCount > 1)
352 : : return;
353 : :
354 [ + - ][ + - ]: 3 : rListData = (ScUserListData*)(ScGlobal::GetUserList()->GetData(aStr));
355 [ + - ]: 3 : if (rListData)
356 : : {
357 [ + - ]: 3 : rListData->GetSubIndex(aStr, rListIndex);
358 : 3 : nCol = sal::static_int_cast<SCCOL>( nCol + nAddX );
359 : 3 : nRow = sal::static_int_cast<SCROW>( nRow + nAddY );
360 [ - + ][ # # ]: 3 : for (sal_uInt16 i=1; i<nCount && rListData; i++)
[ - + ]
361 : : {
362 [ # # ]: 0 : GetString(nCol, nRow, aStr);
363 [ # # ][ # # ]: 0 : if (!rListData->GetSubIndex(aStr, rListIndex))
364 : 0 : rListData = NULL;
365 : 0 : nCol = sal::static_int_cast<SCCOL>( nCol + nAddX );
366 : 0 : nRow = sal::static_int_cast<SCROW>( nRow + nAddY );
367 : : }
368 : : }
369 [ # # ]: 0 : else if ( nCount > 1 )
370 : : {
371 : : // pass rMinDigits to all DecompValueString calls
372 : : // -> longest number defines rMinDigits
373 : :
374 : : sal_Int32 nVal1;
375 [ # # ]: 0 : String aString = aStr;
376 [ # # ]: 0 : short nFlag1 = lcl_DecompValueString( aString, nVal1, &rMinDigits );
377 [ # # ]: 0 : aStr = aString;
378 [ # # ]: 0 : if ( nFlag1 )
379 : : {
380 : : sal_Int32 nVal2;
381 [ # # ]: 0 : GetString( nCol+nAddX, nRow+nAddY, aStr );
382 [ # # ]: 0 : aString = aStr;
383 [ # # ]: 0 : short nFlag2 = lcl_DecompValueString( aString, nVal2, &rMinDigits );
384 [ # # ]: 0 : aStr = aString;
385 [ # # ]: 0 : if ( nFlag1 == nFlag2 )
386 : : {
387 : 0 : rInc = (double)nVal2 - (double)nVal1;
388 : 0 : nCol = sal::static_int_cast<SCCOL>( nCol + nAddX );
389 : 0 : nRow = sal::static_int_cast<SCROW>( nRow + nAddY );
390 : 0 : bool bVal = true;
391 [ # # ][ # # ]: 0 : for (sal_uInt16 i=1; i<nCount && bVal; i++)
[ # # ]
392 : : {
393 [ # # ]: 0 : ScBaseCell* pCell = GetCell(nCol,nRow);
394 [ # # ]: 0 : CellType eType = pCell ? pCell->GetCellType() : CELLTYPE_NONE;
395 [ # # ][ # # ]: 0 : if ( eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT )
396 : : {
397 [ # # ]: 0 : if ( eType == CELLTYPE_STRING )
398 : 0 : aStr = ((ScStringCell*)pCell)->GetString();
399 : : else
400 [ # # ]: 0 : aStr = ((ScEditCell*)pCell)->GetString();
401 [ # # ]: 0 : aString = aStr;
402 [ # # ]: 0 : nFlag2 = lcl_DecompValueString( aString, nVal2, &rMinDigits );
403 [ # # ]: 0 : aStr = aString;
404 [ # # ]: 0 : if ( nFlag1 == nFlag2 )
405 : : {
406 : 0 : double nDiff = (double)nVal2 - (double)nVal1;
407 [ # # ]: 0 : if ( !::rtl::math::approxEqual( nDiff, rInc, 13 ) )
408 : 0 : bVal = false;
409 : 0 : nVal1 = nVal2;
410 : : }
411 : : else
412 : 0 : bVal = false;
413 : : }
414 : : else
415 : 0 : bVal = false;
416 : 0 : nCol = sal::static_int_cast<SCCOL>( nCol + nAddX );
417 : 0 : nRow = sal::static_int_cast<SCROW>( nRow + nAddY );
418 : : }
419 [ # # ]: 0 : if (bVal)
420 : 0 : rCmd = FILL_LINEAR;
421 : : }
422 [ # # ]: 0 : }
423 : : }
424 : : else
425 : : {
426 : : // call DecompValueString to set rMinDigits
427 : : sal_Int32 nDummy;
428 [ # # ]: 0 : String aString = aStr;
429 [ # # ][ # # ]: 3 : lcl_DecompValueString( aString, nDummy, &rMinDigits );
430 [ + + ]: 23 : }
431 : : }
432 : : }
433 : :
434 : 3 : void ScTable::FillFormula(sal_uLong& /* nFormulaCounter */, bool /* bFirst */, ScFormulaCell* pSrcCell,
435 : : SCCOL nDestCol, SCROW nDestRow, bool bLast )
436 : : {
437 : :
438 : 3 : pDocument->SetNoListening( true ); // noch falsche Referenzen
439 : 3 : ScAddress aAddr( nDestCol, nDestRow, nTab );
440 [ + - ][ + - ]: 3 : ScFormulaCell* pDestCell = new ScFormulaCell( *pSrcCell, *pDocument, aAddr );
441 [ + - ][ + - ]: 3 : aCol[nDestCol].Insert(nDestRow, pDestCell);
442 : :
443 [ + + ][ - + ]: 3 : if ( bLast && pDestCell->GetMatrixFlag() )
[ - + ]
444 : : {
445 : 0 : ScAddress aOrg;
446 [ # # ][ # # ]: 0 : if ( pDestCell->GetMatrixOrigin( aOrg ) )
447 : : {
448 [ # # ][ # # ]: 0 : if ( nDestCol >= aOrg.Col() && nDestRow >= aOrg.Row() )
[ # # ]
449 : : {
450 [ # # ]: 0 : ScBaseCell* pOrgCell = pDocument->GetCell( aOrg );
451 [ # # ]: 0 : if ( pOrgCell && pOrgCell->GetCellType() == CELLTYPE_FORMULA
[ # # # # ]
[ # # ]
452 [ # # ]: 0 : && ((ScFormulaCell*)pOrgCell)->GetMatrixFlag() == MM_FORMULA )
453 : : {
454 : : ((ScFormulaCell*)pOrgCell)->SetMatColsRows(
455 : 0 : nDestCol - aOrg.Col() + 1,
456 [ # # ][ # # ]: 0 : nDestRow - aOrg.Row() + 1 );
457 : : }
458 : : else
459 : : {
460 : : OSL_FAIL( "FillFormula: MatrixOrigin keine Formelzelle mit MM_FORMULA" );
461 : : }
462 : : }
463 : : else
464 : : {
465 : : OSL_FAIL( "FillFormula: MatrixOrigin rechts unten" );
466 : : }
467 : : }
468 : : else
469 : : {
470 : : OSL_FAIL( "FillFormula: kein MatrixOrigin" );
471 : : }
472 : : }
473 : 3 : pDocument->SetNoListening( false );
474 [ + - ]: 3 : pDestCell->StartListeningTo( pDocument );
475 : :
476 : 3 : }
477 : :
478 : 10 : void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
479 : : sal_uLong nFillCount, FillDir eFillDir, ScProgress* pProgress )
480 : : {
481 [ + - ][ + - ]: 10 : if ( (nFillCount == 0) || !ValidColRow(nCol1, nRow1) || !ValidColRow(nCol2, nRow2) )
[ - + ][ + - ]
482 : 10 : return;
483 : :
484 : : //
485 : : // Richtung auswerten
486 : : //
487 : :
488 [ + + ][ - + ]: 10 : bool bVertical = (eFillDir == FILL_TO_BOTTOM || eFillDir == FILL_TO_TOP);
489 [ + + ][ + - ]: 10 : bool bPositive = (eFillDir == FILL_TO_BOTTOM || eFillDir == FILL_TO_RIGHT);
490 : :
491 : 10 : sal_uLong nCol = 0;
492 : 10 : sal_uLong nRow = 0;
493 [ + + ]: 10 : sal_uLong& rInner = bVertical ? nRow : nCol; // Schleifenvariablen
494 [ + + ]: 10 : sal_uLong& rOuter = bVertical ? nCol : nRow;
495 : : sal_uLong nOStart;
496 : : sal_uLong nOEnd;
497 : : sal_uLong nIStart;
498 : : sal_uLong nIEnd;
499 : : sal_uLong nISrcStart;
500 : : sal_uLong nISrcEnd;
501 : 10 : ScRange aFillRange;
502 : :
503 [ + + ]: 10 : if (bVertical)
504 : : {
505 : 8 : nOStart = nCol1;
506 : 8 : nOEnd = nCol2;
507 [ + - ]: 8 : if (bPositive)
508 : : {
509 : 8 : nISrcStart = nRow1;
510 : 8 : nISrcEnd = nRow2;
511 : 8 : nIStart = nRow2 + 1;
512 : 8 : nIEnd = nRow2 + nFillCount;
513 : 8 : aFillRange = ScRange(nCol1, nRow2+1, 0, nCol2, nRow2 + nFillCount, 0);
514 : : }
515 : : else
516 : : {
517 : 0 : nISrcStart = nRow2;
518 : 0 : nISrcEnd = nRow1;
519 : 0 : nIStart = nRow1 - 1;
520 : 0 : nIEnd = nRow1 - nFillCount;
521 : 0 : aFillRange = ScRange(nCol1, nRow1-1, 0, nCol2, nRow2 - nFillCount, 0);
522 : : }
523 : : }
524 : : else
525 : : {
526 : 2 : nOStart = nRow1;
527 : 2 : nOEnd = nRow2;
528 [ + - ]: 2 : if (bPositive)
529 : : {
530 : 2 : nISrcStart = nCol1;
531 : 2 : nISrcEnd = nCol2;
532 : 2 : nIStart = nCol2 + 1;
533 : 2 : nIEnd = nCol2 + nFillCount;
534 : 2 : aFillRange = ScRange(nCol2 + 1, nRow1, 0, nCol2 + nFillCount, nRow2, 0);
535 : : }
536 : : else
537 : : {
538 : 0 : nISrcStart = nCol2;
539 : 0 : nISrcEnd = nCol1;
540 : 0 : nIStart = nCol1 - 1;
541 : 0 : nIEnd = nCol1 - nFillCount;
542 : 0 : aFillRange = ScRange(nCol1 - 1, nRow1, 0, nCol1 - nFillCount, nRow2, 0);
543 : : }
544 : : }
545 : 10 : sal_uLong nIMin = nIStart;
546 : 10 : sal_uLong nIMax = nIEnd;
547 : 10 : PutInOrder(nIMin,nIMax);
548 [ + - ]: 10 : bool bHasFiltered = IsDataFiltered(aFillRange);
549 : :
550 [ + - ]: 10 : if (!bHasFiltered)
551 : : {
552 [ + + ]: 10 : if (bVertical)
553 [ + - ]: 8 : DeleteArea(nCol1, static_cast<SCROW>(nIMin), nCol2, static_cast<SCROW>(nIMax), IDF_AUTOFILL);
554 : : else
555 [ + - ]: 2 : DeleteArea(static_cast<SCCOL>(nIMin), nRow1, static_cast<SCCOL>(nIMax), nRow2, IDF_AUTOFILL);
556 : : }
557 : :
558 : 10 : sal_uLong nProgress = 0;
559 [ + + ]: 10 : if (pProgress)
560 : 4 : nProgress = pProgress->GetState();
561 : :
562 : : //
563 : : // ausfuehren
564 : : //
565 : :
566 : 10 : sal_uLong nActFormCnt = 0;
567 [ + + ]: 33 : for (rOuter = nOStart; rOuter <= nOEnd; rOuter++)
568 : : {
569 : 23 : sal_uLong nMaxFormCnt = 0; // fuer Formeln
570 : :
571 : : // Attributierung uebertragen
572 : :
573 : 23 : const ScPatternAttr* pSrcPattern = NULL;
574 : 23 : const ScStyleSheet* pStyleSheet = NULL;
575 : 23 : sal_uLong nAtSrc = nISrcStart;
576 : 23 : ScPatternAttr* pNewPattern = NULL;
577 : 23 : bool bGetPattern = true;
578 : 23 : rInner = nIStart;
579 : 21 : while (true) // #i53728# with "for (;;)" old solaris/x86 compiler mis-optimizes
580 : : {
581 [ + - ][ + - ]: 44 : if (!ColHidden(nCol) && !RowHidden(nRow))
[ + - ][ + - ]
[ + - ]
582 : : {
583 [ + + ]: 44 : if ( bGetPattern )
584 : : {
585 [ - + ][ # # ]: 26 : delete pNewPattern;
586 [ + + ]: 26 : if (bVertical) // rInner&:=nRow, rOuter&:=nCol
587 [ + - ]: 17 : pSrcPattern = aCol[nCol].GetPattern(static_cast<SCROW>(nAtSrc));
588 : : else // rInner&:=nCol, rOuter&:=nRow
589 [ + - ]: 9 : pSrcPattern = aCol[nAtSrc].GetPattern(static_cast<SCROW>(nRow));
590 : 26 : bGetPattern = false;
591 : 26 : pStyleSheet = pSrcPattern->GetStyleSheet();
592 : : // Merge/Mergeflag nicht uebernehmen,
593 : 26 : const SfxItemSet& rSet = pSrcPattern->GetItemSet();
594 [ + - ][ - + ]: 52 : if ( rSet.GetItemState(ATTR_MERGE, false) == SFX_ITEM_SET
[ - + ][ + - ]
595 [ + - ]: 26 : || rSet.GetItemState(ATTR_MERGE_FLAG, false) == SFX_ITEM_SET )
596 : : {
597 [ # # ][ # # ]: 0 : pNewPattern = new ScPatternAttr( *pSrcPattern );
598 : 0 : SfxItemSet& rNewSet = pNewPattern->GetItemSet();
599 [ # # ]: 0 : rNewSet.ClearItem(ATTR_MERGE);
600 [ # # ]: 0 : rNewSet.ClearItem(ATTR_MERGE_FLAG);
601 : : }
602 : : else
603 : 26 : pNewPattern = NULL;
604 : : }
605 : :
606 [ + + ][ + + ]: 44 : if ( bVertical && nISrcStart == nISrcEnd && !bHasFiltered )
[ + - ]
607 : : {
608 : : // Attribute komplett am Stueck setzen
609 [ + - ][ + - ]: 11 : if (pNewPattern || pSrcPattern != pDocument->GetDefPattern())
[ - + ][ - + ]
610 : : {
611 : : // Default steht schon da (DeleteArea)
612 : 0 : SCROW nY1 = static_cast<SCROW>(Min( nIStart, nIEnd ));
613 : 0 : SCROW nY2 = static_cast<SCROW>(Max( nIStart, nIEnd ));
614 [ # # ]: 0 : if ( pStyleSheet )
615 [ # # ]: 0 : aCol[nCol].ApplyStyleArea( nY1, nY2, *pStyleSheet );
616 [ # # ]: 0 : if ( pNewPattern )
617 [ # # ]: 0 : aCol[nCol].ApplyPatternArea( nY1, nY2, *pNewPattern );
618 : : else
619 [ # # ]: 0 : aCol[nCol].ApplyPatternArea( nY1, nY2, *pSrcPattern );
620 : : }
621 : 11 : break; // Schleife abbrechen
622 : : }
623 : :
624 [ - + ]: 33 : if ( bHasFiltered )
625 : : DeleteArea(static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow),
626 [ # # ]: 0 : static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow), IDF_AUTOFILL);
627 : :
628 [ + - ][ - + ]: 33 : if ( pSrcPattern != aCol[nCol].GetPattern( static_cast<SCROW>(nRow) ) )
629 : : {
630 : : // Vorlage auch uebernehmen
631 : : //! am AttrArray mit ApplyPattern zusammenfassen ??
632 [ # # ]: 0 : if ( pStyleSheet )
633 [ # # ]: 0 : aCol[nCol].ApplyStyle( static_cast<SCROW>(nRow), *pStyleSheet );
634 : :
635 : : // ApplyPattern statt SetPattern um alte MergeFlags stehenzulassen
636 [ # # ]: 0 : if ( pNewPattern )
637 [ # # ]: 0 : aCol[nCol].ApplyPattern( static_cast<SCROW>(nRow), *pNewPattern );
638 : : else
639 [ # # ]: 0 : aCol[nCol].ApplyPattern( static_cast<SCROW>(nRow), *pSrcPattern );
640 : : }
641 : :
642 [ + + ]: 33 : if (nAtSrc==nISrcEnd)
643 : : {
644 [ + + ]: 30 : if ( nAtSrc != nISrcStart )
645 : : { // mehr als eine Source-Zelle
646 : 3 : nAtSrc = nISrcStart;
647 : 3 : bGetPattern = true;
648 : : }
649 : : }
650 [ + - ]: 3 : else if (bPositive)
651 : : {
652 : 3 : ++nAtSrc;
653 : 3 : bGetPattern = true;
654 : : }
655 : : else
656 : : {
657 : 0 : --nAtSrc;
658 : 0 : bGetPattern = true;
659 : : }
660 : : }
661 : :
662 [ + + ]: 33 : if (rInner == nIEnd) break;
663 [ + - ]: 21 : if (bPositive) ++rInner; else --rInner;
664 : : }
665 [ - + ]: 23 : if ( pNewPattern )
666 [ # # ][ # # ]: 0 : delete pNewPattern;
667 : :
668 : : // Analyse
669 : :
670 : : FillCmd eFillCmd;
671 : : FillDateCmd eDateCmd;
672 : : double nInc;
673 : : sal_uInt16 nMinDigits;
674 : 23 : ScUserListData* pListData = NULL;
675 : : sal_uInt16 nListIndex;
676 [ + + ]: 23 : if (bVertical)
677 : : FillAnalyse(static_cast<SCCOL>(nCol),nRow1,
678 : : static_cast<SCCOL>(nCol),nRow2, eFillCmd,eDateCmd,
679 [ + - ]: 14 : nInc,nMinDigits, pListData,nListIndex);
680 : : else
681 : : FillAnalyse(nCol1,static_cast<SCROW>(nRow),
682 : : nCol2,static_cast<SCROW>(nRow), eFillCmd,eDateCmd,
683 [ + - ]: 9 : nInc,nMinDigits, pListData,nListIndex);
684 : :
685 [ + + ]: 23 : if (bVertical)
686 [ + - ][ + - ]: 14 : aCol[nCol].Resize( aCol[nCol].GetCellCount() + nFillCount );
687 : :
688 [ + + ]: 23 : if (pListData)
689 : : {
690 [ + - ]: 3 : sal_uInt16 nListCount = pListData->GetSubCount();
691 [ - + ]: 3 : if ( !bPositive )
692 : : {
693 : : // nListIndex auf FillAnalyse zeigt auf den letzten Eintrag -> anpassen
694 : 0 : sal_uLong nSub = nISrcStart - nISrcEnd;
695 [ # # ]: 0 : for (sal_uLong i=0; i<nSub; i++)
696 : : {
697 [ # # ]: 0 : if (nListIndex == 0) nListIndex = nListCount;
698 : 0 : --nListIndex;
699 : : }
700 : : }
701 : :
702 : 3 : rInner = nIStart;
703 : 3 : while (true) // #i53728# with "for (;;)" old solaris/x86 compiler mis-optimizes
704 : : {
705 [ + - ][ + - ]: 6 : if(!ColHidden(nCol) && !RowHidden(nRow))
[ + - ][ + - ]
[ + - ]
706 : : {
707 [ + - ]: 6 : if (bPositive)
708 : : {
709 : 6 : ++nListIndex;
710 [ - + ]: 6 : if (nListIndex >= nListCount) nListIndex = 0;
711 : : }
712 : : else
713 : : {
714 [ # # ]: 0 : if (nListIndex == 0) nListIndex = nListCount;
715 : 0 : --nListIndex;
716 : : }
717 [ + - ][ + - ]: 6 : aCol[nCol].Insert(static_cast<SCROW>(nRow), new ScStringCell(pListData->GetSubStr(nListIndex)));
[ + - ][ + - ]
718 : : }
719 : :
720 [ + + ]: 6 : if (rInner == nIEnd) break;
721 [ + - ]: 3 : if (bPositive) ++rInner; else --rInner;
722 : : }
723 [ - + ]: 3 : if(pProgress)
724 : : {
725 : 0 : nProgress += nIMax - nIMin + 1;
726 [ # # ]: 0 : pProgress->SetStateOnPercent( nProgress );
727 : : }
728 : : }
729 [ + - ]: 20 : else if (eFillCmd == FILL_SIMPLE) // Auffuellen mit Muster
730 : : {
731 : 20 : sal_uLong nSource = nISrcStart;
732 : : double nDelta;
733 [ - + ]: 20 : if ( (nScFillModeMouseModifier & KEY_MOD1) )
734 : 0 : nDelta = 0.0;
735 [ + - ]: 20 : else if ( bPositive )
736 : 20 : nDelta = 1.0;
737 : : else
738 : 0 : nDelta = -1.0;
739 : 20 : double nVal = 0.0;
740 : 20 : sal_uLong nFormulaCounter = nActFormCnt;
741 : 20 : bool bFirst = true;
742 : 20 : bool bGetCell = true;
743 : 20 : sal_uInt16 nCellDigits = 0;
744 : 20 : short nHeadNoneTail = 0;
745 : 20 : sal_Int32 nStringValue = 0;
746 [ + - ]: 20 : String aValue;
747 : 20 : ScBaseCell* pSrcCell = NULL;
748 : 20 : CellType eCellType = CELLTYPE_NONE;
749 : 20 : bool bIsOrdinalSuffix = false;
750 : :
751 : 20 : rInner = nIStart;
752 : 41 : while (true) // #i53728# with "for (;;)" old solaris/x86 compiler mis-optimizes
753 : : {
754 [ + - ][ + - ]: 61 : if(!ColHidden(nCol) && !RowHidden(nRow))
[ + - ][ + - ]
[ + - ]
755 : : {
756 [ + + ]: 61 : if ( bGetCell )
757 : : {
758 [ + + ]: 23 : if (bVertical) // rInner&:=nRow, rOuter&:=nCol
759 [ + - ]: 14 : pSrcCell = aCol[nCol].GetCell( static_cast<SCROW>(nSource) );
760 : : else // rInner&:=nCol, rOuter&:=nRow
761 [ + - ]: 9 : pSrcCell = aCol[nSource].GetCell( static_cast<SCROW>(nRow) );
762 : 23 : bGetCell = false;
763 [ + - ]: 23 : if ( pSrcCell )
764 : : {
765 : 23 : eCellType = pSrcCell->GetCellType();
766 [ + + + ]: 23 : switch ( eCellType )
767 : : {
768 : : case CELLTYPE_VALUE:
769 : 16 : nVal = ((ScValueCell*)pSrcCell)->GetValue();
770 : 16 : break;
771 : : case CELLTYPE_STRING:
772 : : case CELLTYPE_EDIT:
773 [ + - ]: 6 : if ( eCellType == CELLTYPE_STRING )
774 [ + - ]: 6 : aValue = ((ScStringCell*)pSrcCell)->GetString();
775 : : else
776 [ # # ][ # # ]: 0 : aValue = ((ScEditCell*)pSrcCell)->GetString();
777 [ + - ][ + - ]: 6 : if ( !(nScFillModeMouseModifier & KEY_MOD1) && !bHasFiltered )
778 : : {
779 : 6 : nCellDigits = 0; // look at each source cell individually
780 : : nHeadNoneTail = lcl_DecompValueString(
781 [ + - ]: 6 : aValue, nStringValue, &nCellDigits );
782 : :
783 : : bIsOrdinalSuffix = aValue.Equals(
784 [ + - ][ + - ]: 6 : ScGlobal::GetOrdinalSuffix( nStringValue));
[ + - ]
785 : : }
786 : 23 : break;
787 : : default:
788 : : {
789 : : // added to avoid warnings
790 : : }
791 : : }
792 : : }
793 : : else
794 : 0 : eCellType = CELLTYPE_NONE;
795 : : }
796 : :
797 [ + + + - ]: 61 : switch (eCellType)
798 : : {
799 : : case CELLTYPE_VALUE:
800 [ + - ][ + - ]: 52 : aCol[nCol].Insert(static_cast<SCROW>(nRow), new ScValueCell(nVal + nDelta));
[ + - ]
801 : 52 : break;
802 : : case CELLTYPE_STRING:
803 : : case CELLTYPE_EDIT:
804 [ - + ]: 6 : if ( nHeadNoneTail )
805 : : {
806 : : // #i48009# with the "nStringValue+(long)nDelta" expression within the
807 : : // lcl_ValueString calls, gcc 3.4.1 makes wrong optimizations (ok in 3.4.3),
808 : : // so nNextValue is now calculated ahead.
809 : 0 : sal_Int32 nNextValue = nStringValue+(sal_Int32)nDelta;
810 : :
811 [ # # ]: 0 : String aStr;
812 [ # # ]: 0 : if ( nHeadNoneTail < 0 )
813 : : {
814 : 0 : aCol[nCol].Insert( static_cast<SCROW>(nRow),
815 : : lcl_getSuffixCell( pDocument,
816 : : nNextValue, nCellDigits, aValue,
817 [ # # ][ # # ]: 0 : eCellType, bIsOrdinalSuffix));
818 : : }
819 : : else
820 : : {
821 [ # # ]: 0 : aStr = aValue;
822 [ # # ][ # # ]: 0 : aStr += lcl_ValueString( nNextValue, nCellDigits );
[ # # ]
823 : 0 : aCol[nCol].Insert( static_cast<SCROW>(nRow),
824 [ # # ][ # # ]: 0 : new ScStringCell( aStr));
[ # # ][ # # ]
825 [ # # ]: 0 : }
826 : : }
827 : : else
828 : : {
829 : 6 : ScAddress aDestPos( static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow), nTab );
830 [ + - ]: 6 : switch ( eCellType )
831 : : {
832 : : case CELLTYPE_STRING:
833 : : case CELLTYPE_EDIT:
834 [ + - ][ + - ]: 6 : aCol[nCol].Insert( aDestPos.Row(), pSrcCell->Clone( *pDocument ) );
835 : 6 : break;
836 : : default:
837 : : {
838 : : // added to avoid warnings
839 : : }
840 : : }
841 : : }
842 : 6 : break;
843 : : case CELLTYPE_FORMULA :
844 : : FillFormula( nFormulaCounter, bFirst,
845 : : (ScFormulaCell*) pSrcCell,
846 : : static_cast<SCCOL>(nCol),
847 [ + - ][ + - ]: 3 : static_cast<SCROW>(nRow), (rInner == nIEnd) );
848 [ - + ]: 3 : if (nFormulaCounter - nActFormCnt > nMaxFormCnt)
849 : 0 : nMaxFormCnt = nFormulaCounter - nActFormCnt;
850 : 3 : break;
851 : : default:
852 : : {
853 : : // added to avoid warnings
854 : : }
855 : : }
856 : :
857 [ + + ]: 61 : if (nSource==nISrcEnd)
858 : : {
859 [ + + ]: 58 : if ( nSource != nISrcStart )
860 : : { // mehr als eine Source-Zelle
861 : 3 : nSource = nISrcStart;
862 : 3 : bGetCell = true;
863 : : }
864 [ + - ]: 58 : if ( !(nScFillModeMouseModifier & KEY_MOD1) )
865 : : {
866 [ + - ]: 58 : if ( bPositive )
867 : 58 : nDelta += 1.0;
868 : : else
869 : 0 : nDelta -= 1.0;
870 : : }
871 : 58 : nFormulaCounter = nActFormCnt;
872 : 58 : bFirst = false;
873 : : }
874 [ + - ]: 3 : else if (bPositive)
875 : : {
876 : 3 : ++nSource;
877 : 3 : bGetCell = true;
878 : : }
879 : : else
880 : : {
881 : 0 : --nSource;
882 : 0 : bGetCell = true;
883 : : }
884 : : }
885 : :
886 [ + + ]: 61 : if (rInner == nIEnd) break;
887 [ + - ]: 41 : if (bPositive) ++rInner; else --rInner;
888 : :
889 : : // Progress in der inneren Schleife nur bei teuren Zellen,
890 : : // und auch dann nicht fuer jede einzelne
891 : :
892 : 41 : ++nProgress;
893 [ + + ][ + + ]: 41 : if ( pProgress && (eCellType == CELLTYPE_FORMULA || eCellType == CELLTYPE_EDIT) )
[ - + ]
894 [ + - ]: 2 : pProgress->SetStateOnPercent( nProgress );
895 : :
896 : : }
897 [ + + ]: 20 : if (pProgress)
898 [ + - ][ + - ]: 20 : pProgress->SetStateOnPercent( nProgress );
899 : : }
900 : : else
901 : : {
902 [ # # ]: 0 : if (!bPositive)
903 : 0 : nInc = -nInc;
904 [ # # ]: 0 : double nEndVal = (nInc>=0.0) ? MAXDOUBLE : -MAXDOUBLE;
905 [ # # ]: 0 : if (bVertical)
906 : : FillSeries( static_cast<SCCOL>(nCol), nRow1,
907 : : static_cast<SCCOL>(nCol), nRow2, nFillCount, eFillDir,
908 : : eFillCmd, eDateCmd, nInc, nEndVal, nMinDigits, false,
909 [ # # ]: 0 : pProgress );
910 : : else
911 : : FillSeries( nCol1, static_cast<SCROW>(nRow), nCol2,
912 : : static_cast<SCROW>(nRow), nFillCount, eFillDir,
913 : : eFillCmd, eDateCmd, nInc, nEndVal, nMinDigits, false,
914 [ # # ]: 0 : pProgress );
915 [ # # ]: 0 : if (pProgress)
916 : 0 : nProgress = pProgress->GetState();
917 : : }
918 : :
919 : 23 : nActFormCnt += nMaxFormCnt;
920 : : }
921 : : }
922 : :
923 : 0 : String ScTable::GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW nEndY )
924 : : {
925 : 0 : String aValue;
926 : :
927 : 0 : SCCOL nCol1 = rSource.aStart.Col();
928 : 0 : SCROW nRow1 = rSource.aStart.Row();
929 : 0 : SCCOL nCol2 = rSource.aEnd.Col();
930 : 0 : SCROW nRow2 = rSource.aEnd.Row();
931 : 0 : bool bOk = true;
932 : 0 : long nIndex = 0;
933 : 0 : sal_uLong nSrcCount = 0;
934 : 0 : FillDir eFillDir = FILL_TO_BOTTOM;
935 [ # # ][ # # ]: 0 : if ( nEndX == nCol2 && nEndY == nRow2 ) // leer
936 : 0 : bOk = false;
937 [ # # ]: 0 : else if ( nEndX == nCol2 ) // nach oben/unten
938 : : {
939 : 0 : nEndX = nCol2 = nCol1; // nur erste Spalte ansehen
940 : 0 : nSrcCount = nRow2 - nRow1 + 1;
941 : 0 : nIndex = ((long)nEndY) - nRow1; // kann negativ werden
942 [ # # ]: 0 : if ( nEndY >= nRow1 )
943 : 0 : eFillDir = FILL_TO_BOTTOM;
944 : : else
945 : 0 : eFillDir = FILL_TO_TOP;
946 : : }
947 [ # # ]: 0 : else if ( nEndY == nRow2 ) // nach links/rechts
948 : : {
949 : 0 : nEndY = nRow2 = nRow1; // nur erste Zeile ansehen
950 : 0 : nSrcCount = nCol2 - nCol1 + 1;
951 : 0 : nIndex = ((long)nEndX) - nCol1; // kann negativ werden
952 [ # # ]: 0 : if ( nEndX >= nCol1 )
953 : 0 : eFillDir = FILL_TO_RIGHT;
954 : : else
955 : 0 : eFillDir = FILL_TO_LEFT;
956 : : }
957 : : else // Richtung nicht eindeutig
958 : 0 : bOk = false;
959 : :
960 [ # # ]: 0 : if ( bOk )
961 : : {
962 : : FillCmd eFillCmd;
963 : : FillDateCmd eDateCmd;
964 : : double nInc;
965 : : sal_uInt16 nMinDigits;
966 : 0 : ScUserListData* pListData = NULL;
967 : : sal_uInt16 nListIndex;
968 : :
969 [ # # ]: 0 : FillAnalyse(nCol1,nRow1, nCol2,nRow2, eFillCmd,eDateCmd, nInc,nMinDigits, pListData,nListIndex);
970 : :
971 [ # # ]: 0 : if ( pListData ) // benutzerdefinierte Liste
972 : : {
973 [ # # ]: 0 : sal_uInt16 nListCount = pListData->GetSubCount();
974 [ # # ]: 0 : if ( nListCount )
975 : : {
976 : 0 : sal_uLong nSub = nSrcCount - 1; // nListIndex ist vom letzten Source-Eintrag
977 [ # # ]: 0 : while ( nIndex < sal::static_int_cast<long>(nSub) )
978 : 0 : nIndex += nListCount;
979 : 0 : sal_uLong nPos = ( nListIndex + nIndex - nSub ) % nListCount;
980 [ # # ][ # # ]: 0 : aValue = pListData->GetSubStr(sal::static_int_cast<sal_uInt16>(nPos));
981 : : }
982 : : }
983 [ # # ]: 0 : else if ( eFillCmd == FILL_SIMPLE ) // Auffuellen mit Muster
984 : : {
985 [ # # ][ # # ]: 0 : if ((eFillDir == FILL_TO_BOTTOM)||(eFillDir == FILL_TO_TOP))
986 : : {
987 : 0 : long nBegin = 0;
988 : 0 : long nEnd = 0;
989 [ # # ]: 0 : if (nEndY > nRow1)
990 : : {
991 : 0 : nBegin = nRow2+1;
992 : 0 : nEnd = nEndY;
993 : : }
994 : : else
995 : : {
996 : 0 : nBegin = nEndY;
997 : 0 : nEnd = nRow1 -1;
998 : : }
999 : :
1000 [ # # ]: 0 : long nNonFiltered = CountNonFilteredRows(nBegin, nEnd);
1001 : 0 : long nFiltered = nEnd + 1 - nBegin - nNonFiltered;
1002 : :
1003 [ # # ]: 0 : if (nIndex > 0)
1004 : 0 : nIndex = nIndex - nFiltered;
1005 : : else
1006 : 0 : nIndex = nIndex + nFiltered;
1007 : : }
1008 : :
1009 : 0 : long nPosIndex = nIndex;
1010 [ # # ]: 0 : while ( nPosIndex < 0 )
1011 : 0 : nPosIndex += nSrcCount;
1012 : 0 : sal_uLong nPos = nPosIndex % nSrcCount;
1013 : 0 : SCCOL nSrcX = nCol1;
1014 : 0 : SCROW nSrcY = nRow1;
1015 [ # # ][ # # ]: 0 : if ( eFillDir == FILL_TO_TOP || eFillDir == FILL_TO_BOTTOM )
1016 : 0 : nSrcY = sal::static_int_cast<SCROW>( nSrcY + static_cast<SCROW>(nPos) );
1017 : : else
1018 : 0 : nSrcX = sal::static_int_cast<SCCOL>( nSrcX + static_cast<SCCOL>(nPos) );
1019 : :
1020 [ # # ]: 0 : ScBaseCell* pCell = GetCell( nSrcX, nSrcY );
1021 [ # # ]: 0 : if ( pCell )
1022 : : {
1023 : : sal_Int32 nDelta;
1024 [ # # ]: 0 : if (nIndex >= 0)
1025 : 0 : nDelta = nIndex / nSrcCount;
1026 : : else
1027 : 0 : nDelta = ( nIndex - nSrcCount + 1 ) / nSrcCount; // -1 -> -1
1028 : :
1029 : 0 : CellType eType = pCell->GetCellType();
1030 [ # # # ]: 0 : switch ( eType )
1031 : : {
1032 : : case CELLTYPE_STRING:
1033 : : case CELLTYPE_EDIT:
1034 : : {
1035 [ # # ]: 0 : if ( eType == CELLTYPE_STRING )
1036 [ # # ]: 0 : aValue = ((ScStringCell*)pCell)->GetString();
1037 : : else
1038 [ # # ][ # # ]: 0 : aValue = ((ScEditCell*)pCell)->GetString();
1039 [ # # ]: 0 : if ( !(nScFillModeMouseModifier & KEY_MOD1) )
1040 : : {
1041 : : sal_Int32 nVal;
1042 : 0 : sal_uInt16 nCellDigits = 0; // look at each source cell individually
1043 [ # # ]: 0 : short nFlag = lcl_DecompValueString( aValue, nVal, &nCellDigits );
1044 [ # # ]: 0 : if ( nFlag < 0 )
1045 : : {
1046 [ # # ][ # # ]: 0 : if (aValue.Equals( ScGlobal::GetOrdinalSuffix( nVal)))
[ # # ][ # # ]
1047 [ # # ][ # # ]: 0 : aValue = ScGlobal::GetOrdinalSuffix( nVal + nDelta);
[ # # ]
1048 : :
1049 [ # # ][ # # ]: 0 : aValue.Insert( lcl_ValueString( nVal + nDelta, nCellDigits ), 0 );
[ # # ]
1050 : : }
1051 [ # # ]: 0 : else if ( nFlag > 0 )
1052 [ # # ][ # # ]: 0 : aValue += lcl_ValueString( nVal + nDelta, nCellDigits );
[ # # ]
1053 : : }
1054 : : }
1055 : 0 : break;
1056 : : case CELLTYPE_VALUE:
1057 : : {
1058 : : // dabei kann's keinen Ueberlauf geben...
1059 : 0 : double nVal = ((ScValueCell*)pCell)->GetValue();
1060 [ # # ]: 0 : if ( !(nScFillModeMouseModifier & KEY_MOD1) )
1061 : 0 : nVal += (double) nDelta;
1062 : :
1063 : : Color* pColor;
1064 [ # # ]: 0 : sal_uLong nNumFmt = GetNumberFormat( nSrcX, nSrcY );
1065 : : pDocument->GetFormatTable()->
1066 [ # # ][ # # ]: 0 : GetOutputString( nVal, nNumFmt, aValue, &pColor );
1067 : : }
1068 : 0 : break;
1069 : : // Formeln nicht
1070 : : default:
1071 : : {
1072 : : // added to avoid warnings
1073 : : }
1074 : : }
1075 : : }
1076 : : }
1077 [ # # ][ # # ]: 0 : else if ( eFillCmd == FILL_LINEAR || eFillCmd == FILL_DATE ) // Werte
1078 : : {
1079 : : bool bValueOk;
1080 : : double nStart;
1081 : 0 : sal_Int32 nVal = 0;
1082 : 0 : short nHeadNoneTail = 0;
1083 [ # # ]: 0 : ScBaseCell* pCell = GetCell( nCol1, nRow1 );
1084 [ # # ]: 0 : if ( pCell )
1085 : : {
1086 : 0 : CellType eType = pCell->GetCellType();
1087 [ # # # # ]: 0 : switch ( eType )
1088 : : {
1089 : : case CELLTYPE_STRING:
1090 : : case CELLTYPE_EDIT:
1091 : : {
1092 [ # # ]: 0 : if ( eType == CELLTYPE_STRING )
1093 [ # # ]: 0 : aValue = ((ScStringCell*)pCell)->GetString();
1094 : : else
1095 [ # # ][ # # ]: 0 : aValue = ((ScEditCell*)pCell)->GetString();
1096 [ # # ]: 0 : nHeadNoneTail = lcl_DecompValueString( aValue, nVal );
1097 [ # # ]: 0 : if ( nHeadNoneTail )
1098 : 0 : nStart = (double)nVal;
1099 : : else
1100 : 0 : nStart = 0.0;
1101 : : }
1102 : 0 : break;
1103 : : case CELLTYPE_VALUE:
1104 : 0 : nStart = ((ScValueCell*)pCell)->GetValue();
1105 : 0 : break;
1106 : : case CELLTYPE_FORMULA:
1107 [ # # ][ # # ]: 0 : nStart = ((ScFormulaCell*)pCell)->GetValue();
1108 : 0 : break;
1109 : : default:
1110 : 0 : nStart = 0.0;
1111 : : }
1112 : : }
1113 : : else
1114 : 0 : nStart = 0.0;
1115 [ # # ]: 0 : if ( eFillCmd == FILL_LINEAR )
1116 : : {
1117 : 0 : double nAdd = nInc;
1118 [ # # ]: 0 : bValueOk = ( SubTotal::SafeMult( nAdd, (double) nIndex ) &&
1119 [ # # ][ # # ]: 0 : SubTotal::SafePlus( nStart, nAdd ) );
[ # # ]
1120 : : }
1121 : : else // Datum
1122 : : {
1123 : 0 : bValueOk = true;
1124 : 0 : sal_uInt16 nDayOfMonth = 0;
1125 [ # # ]: 0 : if ( nIndex < 0 )
1126 : : {
1127 : 0 : nIndex = -nIndex;
1128 : 0 : nInc = -nInc;
1129 : : }
1130 [ # # ]: 0 : for (long i=0; i<nIndex; i++)
1131 [ # # ]: 0 : IncDate( nStart, nDayOfMonth, nInc, eDateCmd );
1132 : : }
1133 : :
1134 [ # # ]: 0 : if (bValueOk)
1135 : : {
1136 [ # # ]: 0 : if ( nHeadNoneTail )
1137 : : {
1138 [ # # ]: 0 : if ( nHeadNoneTail < 0 )
1139 : : {
1140 [ # # ][ # # ]: 0 : if (aValue.Equals( ScGlobal::GetOrdinalSuffix( nVal)))
[ # # ][ # # ]
1141 [ # # ][ # # ]: 0 : aValue = ScGlobal::GetOrdinalSuffix( (sal_Int32)nStart );
[ # # ]
1142 : :
1143 [ # # ][ # # ]: 0 : aValue.Insert( lcl_ValueString( (sal_Int32)nStart, nMinDigits ), 0 );
[ # # ]
1144 : : }
1145 : : else
1146 [ # # ][ # # ]: 0 : aValue += lcl_ValueString( (sal_Int32)nStart, nMinDigits );
[ # # ]
1147 : : }
1148 : : else
1149 : : {
1150 : : //! Zahlformat je nach Index holen?
1151 : : Color* pColor;
1152 [ # # ]: 0 : sal_uLong nNumFmt = GetNumberFormat( nCol1, nRow1 );
1153 : : pDocument->GetFormatTable()->
1154 [ # # ][ # # ]: 0 : GetOutputString( nStart, nNumFmt, aValue, &pColor );
1155 : : }
1156 : : }
1157 : : }
1158 : : else
1159 : : {
1160 : : OSL_FAIL("GetAutoFillPreview: falscher Modus");
1161 : : }
1162 : : }
1163 : :
1164 : 0 : return aValue;
1165 : : }
1166 : :
1167 : 0 : void ScTable::IncDate(double& rVal, sal_uInt16& nDayOfMonth, double nStep, FillDateCmd eCmd)
1168 : : {
1169 [ # # ]: 0 : if (eCmd == FILL_DAY)
1170 : : {
1171 : 0 : rVal += nStep;
1172 : 0 : return;
1173 : : }
1174 : :
1175 : : // class Date Grenzen
1176 : 0 : const sal_uInt16 nMinYear = 1583;
1177 : 0 : const sal_uInt16 nMaxYear = 9956;
1178 : :
1179 : 0 : long nInc = (long) nStep; // nach oben/unten begrenzen ?
1180 [ # # ][ # # ]: 0 : Date aNullDate = *pDocument->GetFormatTable()->GetNullDate();
1181 : 0 : Date aDate = aNullDate;
1182 [ # # ]: 0 : aDate += (long)rVal;
1183 [ # # # # ]: 0 : switch (eCmd)
1184 : : {
1185 : : case FILL_WEEKDAY:
1186 : : {
1187 [ # # ]: 0 : aDate += nInc;
1188 [ # # ]: 0 : DayOfWeek eWeekDay = aDate.GetDayOfWeek();
1189 [ # # ]: 0 : if (nInc >= 0)
1190 : : {
1191 [ # # ]: 0 : if (eWeekDay == SATURDAY)
1192 [ # # ]: 0 : aDate += 2;
1193 [ # # ]: 0 : else if (eWeekDay == SUNDAY)
1194 [ # # ]: 0 : aDate += 1;
1195 : : }
1196 : : else
1197 : : {
1198 [ # # ]: 0 : if (eWeekDay == SATURDAY)
1199 [ # # ]: 0 : aDate -= 1;
1200 [ # # ]: 0 : else if (eWeekDay == SUNDAY)
1201 [ # # ]: 0 : aDate -= 2;
1202 : : }
1203 : : }
1204 : 0 : break;
1205 : : case FILL_MONTH:
1206 : : {
1207 [ # # ]: 0 : if ( nDayOfMonth == 0 )
1208 : 0 : nDayOfMonth = aDate.GetDay(); // init
1209 : 0 : long nMonth = aDate.GetMonth();
1210 : 0 : long nYear = aDate.GetYear();
1211 : :
1212 : 0 : nMonth += nInc;
1213 : :
1214 [ # # ]: 0 : if (nInc >= 0)
1215 : : {
1216 [ # # ]: 0 : if (nMonth > 12)
1217 : : {
1218 : 0 : long nYAdd = (nMonth-1) / 12;
1219 : 0 : nMonth -= nYAdd * 12;
1220 : 0 : nYear += nYAdd;
1221 : : }
1222 : : }
1223 : : else
1224 : : {
1225 [ # # ]: 0 : if (nMonth < 1)
1226 : : {
1227 : 0 : long nYAdd = 1 - nMonth / 12; // positiv
1228 : 0 : nMonth += nYAdd * 12;
1229 : 0 : nYear -= nYAdd;
1230 : : }
1231 : : }
1232 : :
1233 [ # # ]: 0 : if ( nYear < nMinYear )
1234 : 0 : aDate = Date( 1,1, nMinYear );
1235 [ # # ]: 0 : else if ( nYear > nMaxYear )
1236 : 0 : aDate = Date( 31,12, nMaxYear );
1237 : : else
1238 : : {
1239 [ # # ]: 0 : aDate.SetMonth((sal_uInt16) nMonth);
1240 [ # # ]: 0 : aDate.SetYear((sal_uInt16) nYear);
1241 [ # # ]: 0 : if ( nDayOfMonth > 28 )
1242 [ # # ][ # # ]: 0 : aDate.SetDay( Min( aDate.GetDaysInMonth(), nDayOfMonth ) );
1243 : : }
1244 : : }
1245 : 0 : break;
1246 : : case FILL_YEAR:
1247 : : {
1248 : 0 : long nYear = aDate.GetYear();
1249 : 0 : nYear += nInc;
1250 [ # # ]: 0 : if ( nYear < nMinYear )
1251 : 0 : aDate = Date( 1,1, nMinYear );
1252 [ # # ]: 0 : else if ( nYear > nMaxYear )
1253 : 0 : aDate = Date( 31,12, nMaxYear );
1254 : : else
1255 [ # # ]: 0 : aDate.SetYear((sal_uInt16) nYear);
1256 : : }
1257 : 0 : break;
1258 : : default:
1259 : : {
1260 : : // added to avoid warnings
1261 : : }
1262 : : }
1263 : :
1264 [ # # ]: 0 : rVal = aDate - aNullDate;
1265 : : }
1266 : :
1267 : : namespace
1268 : : {
1269 : :
1270 : 0 : bool HiddenRowColumn(sal_uLong nRowColumn, bool bVertical, ScTable* pTable)
1271 : : {
1272 [ # # ]: 0 : if(bVertical)
1273 : : {
1274 : 0 : return pTable->RowHidden(static_cast<SCROW>(nRowColumn));
1275 : : }
1276 : : else
1277 : : {
1278 : 0 : return pTable->ColHidden(static_cast<SCCOL>(nRowColumn));
1279 : : }
1280 : : }
1281 : :
1282 : : }
1283 : :
1284 : 17 : void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1285 : : sal_uLong nFillCount, FillDir eFillDir, FillCmd eFillCmd, FillDateCmd eFillDateCmd,
1286 : : double nStepValue, double nMaxValue, sal_uInt16 nArgMinDigits,
1287 : : bool bAttribs, ScProgress* pProgress )
1288 : : {
1289 : : //
1290 : : // Richtung auswerten
1291 : : //
1292 : :
1293 [ + + ][ - + ]: 17 : bool bVertical = (eFillDir == FILL_TO_BOTTOM || eFillDir == FILL_TO_TOP);
1294 [ + + ][ + - ]: 17 : bool bPositive = (eFillDir == FILL_TO_BOTTOM || eFillDir == FILL_TO_RIGHT);
1295 : :
1296 : 17 : sal_uLong nCol = 0;
1297 : 17 : sal_uLong nRow = 0;
1298 [ + + ]: 17 : sal_uLong& rInner = bVertical ? nRow : nCol; // Schleifenvariablen
1299 [ + + ]: 17 : sal_uLong& rOuter = bVertical ? nCol : nRow;
1300 : : sal_uLong nOStart;
1301 : : sal_uLong nOEnd;
1302 : : sal_uLong nIStart;
1303 : : sal_uLong nIEnd;
1304 : : sal_uLong nISource;
1305 : 17 : ScRange aFillRange;
1306 : :
1307 [ + + ]: 17 : if (bVertical)
1308 : : {
1309 : 10 : nFillCount += (nRow2 - nRow1);
1310 [ + - ]: 10 : if (nFillCount == 0)
1311 : : return;
1312 : 10 : nOStart = nCol1;
1313 : 10 : nOEnd = nCol2;
1314 [ + - ]: 10 : if (bPositive)
1315 : : {
1316 : 10 : nISource = nRow1;
1317 : 10 : nIStart = nRow1 + 1;
1318 : 10 : nIEnd = nRow1 + nFillCount;
1319 : 10 : aFillRange = ScRange(nCol1, nRow1 + 1, nTab, nCol2, nRow1 + nFillCount, nTab);
1320 : : }
1321 : : else
1322 : : {
1323 : 0 : nISource = nRow2;
1324 : 0 : nIStart = nRow2 - 1;
1325 : 0 : nIEnd = nRow2 - nFillCount;
1326 : 0 : aFillRange = ScRange(nCol1, nRow2 -1, nTab, nCol2, nRow2 - nFillCount, nTab);
1327 : : }
1328 : : }
1329 : : else
1330 : : {
1331 : 7 : nFillCount += (nCol2 - nCol1);
1332 [ + - ]: 7 : if (nFillCount == 0)
1333 : : return;
1334 : 7 : nOStart = nRow1;
1335 : 7 : nOEnd = nRow2;
1336 [ + - ]: 7 : if (bPositive)
1337 : : {
1338 : 7 : nISource = nCol1;
1339 : 7 : nIStart = nCol1 + 1;
1340 : 7 : nIEnd = nCol1 + nFillCount;
1341 : 7 : aFillRange = ScRange(nCol1 + 1, nRow1, nTab, nCol1 + nFillCount, nRow2, nTab);
1342 : : }
1343 : : else
1344 : : {
1345 : 0 : nISource = nCol2;
1346 : 0 : nIStart = nCol2 - 1;
1347 : 0 : nIEnd = nCol2 - nFillCount;
1348 : 0 : aFillRange = ScRange(nCol2 - 1, nRow1, nTab, nCol2 - nFillCount, nRow2, nTab);
1349 : : }
1350 : : }
1351 : :
1352 : 17 : sal_uLong nIMin = nIStart;
1353 : 17 : sal_uLong nIMax = nIEnd;
1354 : 17 : PutInOrder(nIMin,nIMax);
1355 [ + - ]: 17 : sal_uInt16 nDel = bAttribs ? IDF_AUTOFILL : (IDF_AUTOFILL & IDF_CONTENTS);
1356 : :
1357 [ + - ]: 17 : bool bIsFiltered = IsDataFiltered(aFillRange);
1358 [ + + ]: 17 : if (!bIsFiltered)
1359 : : {
1360 [ + + ]: 11 : if (bVertical)
1361 [ + - ]: 7 : DeleteArea(nCol1, static_cast<SCROW>(nIMin), nCol2, static_cast<SCROW>(nIMax), nDel);
1362 : : else
1363 [ + - ]: 4 : DeleteArea(static_cast<SCCOL>(nIMin), nRow1, static_cast<SCCOL>(nIMax), nRow2, nDel);
1364 : : }
1365 : :
1366 : 17 : sal_uLong nProgress = 0;
1367 [ + + ]: 17 : if (pProgress)
1368 : 8 : nProgress = pProgress->GetState();
1369 : :
1370 : : //
1371 : : // ausfuehren
1372 : : //
1373 : :
1374 : 17 : sal_uLong nActFormCnt = 0;
1375 [ + + ]: 84 : for (rOuter = nOStart; rOuter <= nOEnd; rOuter++)
1376 : : {
1377 : 67 : bool bFirst = true;
1378 : 67 : rInner = nISource;
1379 [ + - ]: 67 : ScBaseCell* pSrcCell = aCol[nCol].GetCell(static_cast<SCROW>(nRow));
1380 : :
1381 [ + + ][ + - ]: 67 : if (bVertical && bAttribs)
1382 [ + - ][ + - ]: 22 : aCol[nCol].Resize( aCol[nCol].GetCellCount() + nFillCount );
1383 : :
1384 [ + - ]: 67 : if (bAttribs)
1385 : : {
1386 [ + - ]: 67 : const ScPatternAttr* pSrcPattern = aCol[nCol].GetPattern(static_cast<SCROW>(nRow));
1387 [ + + ]: 67 : if (bVertical)
1388 : : {
1389 : : // if not filtered use the faster method
1390 : : // hidden cols/rows should be skiped
1391 [ + + ]: 22 : if(!bIsFiltered)
1392 : : {
1393 : 19 : aCol[nCol].SetPatternArea( static_cast<SCROW>(nIMin),
1394 [ + - ]: 19 : static_cast<SCROW>(nIMax), *pSrcPattern, true );
1395 : : }
1396 : : else
1397 : : {
1398 [ + + ]: 27 : for(SCROW nAtRow = static_cast<SCROW>(nIMin); nAtRow <= static_cast<SCROW>(nIMax); ++nAtRow)
1399 : : {
1400 [ + - ][ + + ]: 24 : if(!RowHidden(nAtRow))
1401 : 18 : aCol[nCol].SetPatternArea( static_cast<SCROW>(nAtRow),
1402 [ + - ]: 18 : static_cast<SCROW>(nAtRow), *pSrcPattern, true);
1403 : : }
1404 : :
1405 : : }
1406 : : }
1407 : : else
1408 [ + + ]: 234 : for (SCCOL nAtCol = static_cast<SCCOL>(nIMin); nAtCol <= sal::static_int_cast<SCCOL>(nIMax); nAtCol++)
1409 [ + - ][ + - ]: 189 : if(!ColHidden(nAtCol))
1410 [ + - ]: 189 : aCol[nAtCol].SetPattern(static_cast<SCROW>(nRow), *pSrcPattern, true);
1411 : : }
1412 : :
1413 [ + + ]: 67 : if (pSrcCell)
1414 : : {
1415 : 54 : CellType eCellType = pSrcCell->GetCellType();
1416 : :
1417 [ - + ]: 54 : if (eFillCmd == FILL_SIMPLE) // kopieren
1418 : : {
1419 [ # # ]: 0 : if (eCellType == CELLTYPE_FORMULA)
1420 : : {
1421 [ # # ]: 0 : for (rInner = nIMin; rInner <= nIMax; rInner++)
1422 : : {
1423 [ # # ][ # # ]: 0 : if(HiddenRowColumn(rInner, bVertical, this))
1424 : 0 : continue;
1425 : 0 : sal_uLong nInd = nActFormCnt;
1426 : : FillFormula(nInd, bFirst, (ScFormulaCell*)pSrcCell,
1427 [ # # ][ # # ]: 0 : static_cast<SCCOL>(nCol), nRow, (rInner == nIEnd) );
1428 : 0 : bFirst = false;
1429 [ # # ]: 0 : if(pProgress)
1430 [ # # ]: 0 : pProgress->SetStateOnPercent( ++nProgress );
1431 : : }
1432 : : }
1433 [ # # ]: 0 : else if (eCellType != CELLTYPE_NOTE)
1434 : : {
1435 [ # # ]: 0 : for (rInner = nIMin; rInner <= nIMax; rInner++)
1436 : : {
1437 [ # # ][ # # ]: 0 : if(HiddenRowColumn(rInner, bVertical, this))
1438 : 0 : continue;
1439 : 0 : ScAddress aDestPos( static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow), nTab );
1440 [ # # ][ # # ]: 0 : aCol[nCol].Insert( aDestPos.Row(), pSrcCell->Clone( *pDocument ) );
1441 : : }
1442 : 0 : nProgress += nIMax - nIMin + 1;
1443 [ # # ]: 0 : if(pProgress)
1444 [ # # ]: 0 : pProgress->SetStateOnPercent( nProgress );
1445 : : }
1446 : : }
1447 [ + + ][ + - ]: 54 : else if (eCellType == CELLTYPE_VALUE || eCellType == CELLTYPE_FORMULA)
1448 : : {
1449 : : double nStartVal;
1450 [ + + ]: 54 : if (eCellType == CELLTYPE_VALUE)
1451 : 53 : nStartVal = ((ScValueCell*)pSrcCell)->GetValue();
1452 : : else
1453 [ + - ][ + - ]: 1 : nStartVal = ((ScFormulaCell*)pSrcCell)->GetValue();
1454 : 54 : double nVal = nStartVal;
1455 : 54 : long nIndex = 0;
1456 : :
1457 : 54 : bool bError = false;
1458 : 54 : bool bOverflow = false;
1459 : :
1460 : 54 : sal_uInt16 nDayOfMonth = 0;
1461 : 54 : rInner = nIStart;
1462 : 191 : while (true) // #i53728# with "for (;;)" old solaris/x86 compiler mis-optimizes
1463 : : {
1464 [ + - ][ + - ]: 245 : if(!ColHidden(nCol) && !RowHidden(nRow))
[ + - ][ + + ]
[ + + ]
1465 : : {
1466 [ + - ][ + + ]: 209 : if (!bError && !bOverflow)
1467 : : {
1468 [ + + - - ]: 187 : switch (eFillCmd)
1469 : : {
1470 : : case FILL_LINEAR:
1471 : : {
1472 : : // use multiplication instead of repeated addition
1473 : : // to avoid accumulating rounding errors
1474 : 161 : nVal = nStartVal;
1475 : 161 : double nAdd = nStepValue;
1476 [ + - ][ + - ]: 322 : if ( !SubTotal::SafeMult( nAdd, (double) ++nIndex ) ||
[ - + ][ - + ]
1477 [ + - ]: 161 : !SubTotal::SafePlus( nVal, nAdd ) )
1478 : 0 : bError = true;
1479 : : }
1480 : 161 : break;
1481 : : case FILL_GROWTH:
1482 [ + - ][ - + ]: 26 : if (!SubTotal::SafeMult(nVal, nStepValue))
1483 : 0 : bError = true;
1484 : 26 : break;
1485 : : case FILL_DATE:
1486 [ # # ]: 0 : if (fabs(nVal) > _D_MAX_LONG_)
1487 : 0 : bError = true;
1488 : : else
1489 [ # # ]: 0 : IncDate(nVal, nDayOfMonth, nStepValue, eFillDateCmd);
1490 : 0 : break;
1491 : : default:
1492 : : {
1493 : : // added to avoid warnings
1494 : : }
1495 : : }
1496 : :
1497 [ + - ]: 187 : if (nStepValue >= 0)
1498 : : {
1499 [ + + ]: 187 : if (nVal > nMaxValue) // Zielwert erreicht?
1500 : : {
1501 : 15 : nVal = nMaxValue;
1502 : 15 : bOverflow = true;
1503 : : }
1504 : : }
1505 : : else
1506 : : {
1507 [ # # ]: 0 : if (nVal < nMaxValue)
1508 : : {
1509 : 0 : nVal = nMaxValue;
1510 : 0 : bOverflow = true;
1511 : : }
1512 : : }
1513 : : }
1514 : :
1515 [ - + ]: 209 : if (bError)
1516 [ # # ]: 0 : aCol[nCol].SetError(static_cast<SCROW>(nRow), errNoValue);
1517 [ + + ]: 209 : else if (bOverflow)
1518 [ + - ]: 37 : aCol[nCol].SetError(static_cast<SCROW>(nRow), errIllegalFPOperation);
1519 : : else
1520 [ + - ]: 172 : aCol[nCol].SetValue(static_cast<SCROW>(nRow), nVal);
1521 : : }
1522 : :
1523 [ + + ]: 245 : if (rInner == nIEnd)
1524 : 54 : break;
1525 [ + - ]: 191 : if (bPositive)
1526 : : {
1527 : 191 : ++rInner;
1528 : : }
1529 : : else
1530 : : {
1531 : 0 : --rInner;
1532 : : }
1533 : : }
1534 : 54 : nProgress += nIMax - nIMin + 1;
1535 [ + + ]: 54 : if(pProgress)
1536 [ + - ]: 54 : pProgress->SetStateOnPercent( nProgress );
1537 : : }
1538 [ # # ][ # # ]: 0 : else if (eCellType == CELLTYPE_STRING || eCellType == CELLTYPE_EDIT)
1539 : : {
1540 [ # # ]: 0 : if ( nStepValue >= 0 )
1541 : : {
1542 [ # # ]: 0 : if ( nMaxValue >= (double)LONG_MAX )
1543 : 0 : nMaxValue = (double)LONG_MAX - 1;
1544 : : }
1545 : : else
1546 : : {
1547 [ # # ]: 0 : if ( nMaxValue <= (double)LONG_MIN )
1548 : 0 : nMaxValue = (double)LONG_MIN + 1;
1549 : : }
1550 [ # # ]: 0 : String aValue;
1551 [ # # ]: 0 : if (eCellType == CELLTYPE_STRING)
1552 [ # # ]: 0 : aValue = ((ScStringCell*)pSrcCell)->GetString();
1553 : : else
1554 [ # # ][ # # ]: 0 : aValue = ((ScEditCell*)pSrcCell)->GetString();
1555 : : sal_Int32 nStringValue;
1556 : 0 : sal_uInt16 nMinDigits = nArgMinDigits;
1557 [ # # ]: 0 : short nHeadNoneTail = lcl_DecompValueString( aValue, nStringValue, &nMinDigits );
1558 [ # # ]: 0 : if ( nHeadNoneTail )
1559 : : {
1560 : 0 : double nStartVal = (double)nStringValue;
1561 : 0 : double nVal = nStartVal;
1562 : 0 : long nIndex = 0;
1563 : 0 : bool bError = false;
1564 : 0 : bool bOverflow = false;
1565 : :
1566 : : bool bIsOrdinalSuffix = aValue.Equals( ScGlobal::GetOrdinalSuffix(
1567 [ # # ][ # # ]: 0 : (sal_Int32)nStartVal));
[ # # ]
1568 : :
1569 : 0 : rInner = nIStart;
1570 : 0 : while (true) // #i53728# with "for (;;)" old solaris/x86 compiler mis-optimizes
1571 : : {
1572 [ # # ][ # # ]: 0 : if(!ColHidden(nCol) && !RowHidden(nRow))
[ # # ][ # # ]
[ # # ]
1573 : : {
1574 [ # # ][ # # ]: 0 : if (!bError && !bOverflow)
1575 : : {
1576 [ # # # ]: 0 : switch (eFillCmd)
1577 : : {
1578 : : case FILL_LINEAR:
1579 : : {
1580 : : // use multiplication instead of repeated addition
1581 : : // to avoid accumulating rounding errors
1582 : 0 : nVal = nStartVal;
1583 : 0 : double nAdd = nStepValue;
1584 [ # # ][ # # ]: 0 : if ( !SubTotal::SafeMult( nAdd, (double) ++nIndex ) ||
[ # # ][ # # ]
1585 [ # # ]: 0 : !SubTotal::SafePlus( nVal, nAdd ) )
1586 : 0 : bError = true;
1587 : : }
1588 : 0 : break;
1589 : : case FILL_GROWTH:
1590 [ # # ][ # # ]: 0 : if (!SubTotal::SafeMult(nVal, nStepValue))
1591 : 0 : bError = true;
1592 : 0 : break;
1593 : : default:
1594 : : {
1595 : : // added to avoid warnings
1596 : : }
1597 : : }
1598 : :
1599 [ # # ]: 0 : if (nStepValue >= 0)
1600 : : {
1601 [ # # ]: 0 : if (nVal > nMaxValue) // Zielwert erreicht?
1602 : : {
1603 : 0 : nVal = nMaxValue;
1604 : 0 : bOverflow = true;
1605 : : }
1606 : : }
1607 : : else
1608 : : {
1609 [ # # ]: 0 : if (nVal < nMaxValue)
1610 : : {
1611 : 0 : nVal = nMaxValue;
1612 : 0 : bOverflow = true;
1613 : : }
1614 : : }
1615 : : }
1616 : :
1617 [ # # ]: 0 : if (bError)
1618 [ # # ]: 0 : aCol[nCol].SetError(static_cast<SCROW>(nRow), errNoValue);
1619 [ # # ]: 0 : else if (bOverflow)
1620 [ # # ]: 0 : aCol[nCol].SetError(static_cast<SCROW>(nRow), errIllegalFPOperation);
1621 : : else
1622 : : {
1623 : 0 : nStringValue = (sal_Int32)nVal;
1624 [ # # ]: 0 : String aStr;
1625 [ # # ]: 0 : if ( nHeadNoneTail < 0 )
1626 : : {
1627 : 0 : aCol[nCol].Insert( static_cast<SCROW>(nRow),
1628 : : lcl_getSuffixCell( pDocument,
1629 : : nStringValue, nMinDigits, aValue,
1630 [ # # ][ # # ]: 0 : eCellType, bIsOrdinalSuffix ));
1631 : : }
1632 : : else
1633 : : {
1634 [ # # ]: 0 : aStr = aValue;
1635 [ # # ][ # # ]: 0 : aStr += lcl_ValueString( nStringValue, nMinDigits );
[ # # ]
1636 [ # # ][ # # ]: 0 : ScStringCell* pCell = new ScStringCell( aStr );
[ # # ]
1637 [ # # ]: 0 : aCol[nCol].Insert( static_cast<SCROW>(nRow), pCell );
1638 [ # # ]: 0 : }
1639 : : }
1640 : : }
1641 : :
1642 [ # # ]: 0 : if (rInner == nIEnd) break;
1643 [ # # ]: 0 : if (bPositive) ++rInner; else --rInner;
1644 : : }
1645 : : }
1646 [ # # ]: 0 : if(pProgress)
1647 : : {
1648 : 0 : nProgress += nIMax - nIMin + 1;
1649 [ # # ]: 0 : pProgress->SetStateOnPercent( nProgress );
1650 [ # # ]: 54 : }
1651 : : }
1652 : : }
1653 [ + - ]: 13 : else if(pProgress)
1654 : : {
1655 : 13 : nProgress += nIMax - nIMin + 1;
1656 [ + - ]: 13 : pProgress->SetStateOnPercent( nProgress );
1657 : : }
1658 : 67 : ++nActFormCnt;
1659 : : }
1660 : : }
1661 : :
1662 : 27 : void ScTable::Fill( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1663 : : sal_uLong nFillCount, FillDir eFillDir, FillCmd eFillCmd, FillDateCmd eFillDateCmd,
1664 : : double nStepValue, double nMaxValue, ScProgress* pProgress)
1665 : : {
1666 [ + + ]: 27 : if (eFillCmd == FILL_AUTO)
1667 : 10 : FillAuto(nCol1, nRow1, nCol2, nRow2, nFillCount, eFillDir, pProgress);
1668 : : else
1669 : : FillSeries(nCol1, nRow1, nCol2, nRow2, nFillCount, eFillDir,
1670 : 17 : eFillCmd, eFillDateCmd, nStepValue, nMaxValue, 0, true, pProgress);
1671 : 27 : }
1672 : :
1673 : :
1674 : 0 : void ScTable::AutoFormatArea(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1675 : : const ScPatternAttr& rAttr, sal_uInt16 nFormatNo)
1676 : : {
1677 : 0 : ScAutoFormat& rFormat = *ScGlobal::GetOrCreateAutoFormat();
1678 : 0 : ScAutoFormatData* pData = rFormat.findByIndex(nFormatNo);
1679 [ # # ]: 0 : if (pData)
1680 : : {
1681 : 0 : ApplyPatternArea(nStartCol, nStartRow, nEndCol, nEndRow, rAttr);
1682 : : }
1683 : 0 : }
1684 : :
1685 : 0 : void ScTable::AutoFormat( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
1686 : : sal_uInt16 nFormatNo )
1687 : : {
1688 [ # # ][ # # ]: 0 : if (ValidColRow(nStartCol, nStartRow) && ValidColRow(nEndCol, nEndRow))
[ # # ]
1689 : : {
1690 : 0 : ScAutoFormat& rFormat = *ScGlobal::GetOrCreateAutoFormat();
1691 : 0 : ScAutoFormatData* pData = rFormat.findByIndex(nFormatNo);
1692 [ # # ]: 0 : if (pData)
1693 : : {
1694 : : ScPatternAttr* pPatternAttrs[16];
1695 [ # # ]: 0 : for (sal_uInt8 i = 0; i < 16; ++i)
1696 : : {
1697 [ # # ][ # # ]: 0 : pPatternAttrs[i] = new ScPatternAttr(pDocument->GetPool());
[ # # ]
1698 [ # # ]: 0 : pData->FillToItemSet(i, pPatternAttrs[i]->GetItemSet(), *pDocument);
1699 : : }
1700 : :
1701 : 0 : SCCOL nCol = nStartCol;
1702 : 0 : SCROW nRow = nStartRow;
1703 : 0 : sal_uInt16 nIndex = 0;
1704 : : // Linke obere Ecke
1705 [ # # ]: 0 : AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
1706 : : // Linke Spalte
1707 [ # # ][ # # ]: 0 : if (pData->IsEqualData(4, 8))
1708 [ # # ]: 0 : AutoFormatArea(nStartCol, nStartRow + 1, nStartCol, nEndRow - 1, *pPatternAttrs[4], nFormatNo);
1709 : : else
1710 : : {
1711 : 0 : nIndex = 4;
1712 [ # # ]: 0 : for (nRow = nStartRow + 1; nRow < nEndRow; nRow++)
1713 : : {
1714 [ # # ]: 0 : AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
1715 [ # # ]: 0 : if (nIndex == 4)
1716 : 0 : nIndex = 8;
1717 : : else
1718 : 0 : nIndex = 4;
1719 : : }
1720 : : }
1721 : : // Linke untere Ecke
1722 : 0 : nRow = nEndRow;
1723 : 0 : nIndex = 12;
1724 [ # # ]: 0 : AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
1725 : : // Rechte obere Ecke
1726 : 0 : nCol = nEndCol;
1727 : 0 : nRow = nStartRow;
1728 : 0 : nIndex = 3;
1729 [ # # ]: 0 : AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
1730 : : // Rechte Spalte
1731 [ # # ][ # # ]: 0 : if (pData->IsEqualData(7, 11))
1732 [ # # ]: 0 : AutoFormatArea(nEndCol, nStartRow + 1, nEndCol, nEndRow - 1, *pPatternAttrs[7], nFormatNo);
1733 : : else
1734 : : {
1735 : 0 : nIndex = 7;
1736 [ # # ]: 0 : for (nRow = nStartRow + 1; nRow < nEndRow; nRow++)
1737 : : {
1738 [ # # ]: 0 : AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
1739 [ # # ]: 0 : if (nIndex == 7)
1740 : 0 : nIndex = 11;
1741 : : else
1742 : 0 : nIndex = 7;
1743 : : }
1744 : : }
1745 : : // Rechte untere Ecke
1746 : 0 : nRow = nEndRow;
1747 : 0 : nIndex = 15;
1748 [ # # ]: 0 : AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
1749 : 0 : nRow = nStartRow;
1750 : 0 : nIndex = 1;
1751 [ # # ]: 0 : for (nCol = nStartCol + 1; nCol < nEndCol; nCol++)
1752 : : {
1753 [ # # ]: 0 : AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
1754 [ # # ]: 0 : if (nIndex == 1)
1755 : 0 : nIndex = 2;
1756 : : else
1757 : 0 : nIndex = 1;
1758 : : }
1759 : : // Untere Zeile
1760 : 0 : nRow = nEndRow;
1761 : 0 : nIndex = 13;
1762 [ # # ]: 0 : for (nCol = nStartCol + 1; nCol < nEndCol; nCol++)
1763 : : {
1764 [ # # ]: 0 : AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
1765 [ # # ]: 0 : if (nIndex == 13)
1766 : 0 : nIndex = 14;
1767 : : else
1768 : 0 : nIndex = 13;
1769 : : }
1770 : : // Boddy
1771 [ # # ][ # # ]: 0 : if ((pData->IsEqualData(5, 6)) && (pData->IsEqualData(9, 10)) && (pData->IsEqualData(5, 9)))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1772 [ # # ]: 0 : AutoFormatArea(nStartCol + 1, nStartRow + 1, nEndCol-1, nEndRow - 1, *pPatternAttrs[5], nFormatNo);
1773 : : else
1774 : : {
1775 [ # # ][ # # ]: 0 : if ((pData->IsEqualData(5, 9)) && (pData->IsEqualData(6, 10)))
[ # # ][ # # ]
[ # # ]
1776 : : {
1777 : 0 : nIndex = 5;
1778 [ # # ]: 0 : for (nCol = nStartCol + 1; nCol < nEndCol; nCol++)
1779 : : {
1780 [ # # ]: 0 : AutoFormatArea(nCol, nStartRow + 1, nCol, nEndRow - 1, *pPatternAttrs[nIndex], nFormatNo);
1781 [ # # ]: 0 : if (nIndex == 5)
1782 : 0 : nIndex = 6;
1783 : : else
1784 : 0 : nIndex = 5;
1785 : : }
1786 : : }
1787 : : else
1788 : : {
1789 : 0 : nIndex = 5;
1790 [ # # ]: 0 : for (nCol = nStartCol + 1; nCol < nEndCol; nCol++)
1791 : : {
1792 [ # # ]: 0 : for (nRow = nStartRow + 1; nRow < nEndRow; nRow++)
1793 : : {
1794 [ # # ]: 0 : AutoFormatArea(nCol, nRow, nCol, nRow, *pPatternAttrs[nIndex], nFormatNo);
1795 [ # # ][ # # ]: 0 : if ((nIndex == 5) || (nIndex == 9))
1796 : : {
1797 [ # # ]: 0 : if (nIndex == 5)
1798 : 0 : nIndex = 9;
1799 : : else
1800 : 0 : nIndex = 5;
1801 : : }
1802 : : else
1803 : : {
1804 [ # # ]: 0 : if (nIndex == 6)
1805 : 0 : nIndex = 10;
1806 : : else
1807 : 0 : nIndex = 6;
1808 : : }
1809 : : } // for nRow
1810 [ # # ][ # # ]: 0 : if ((nIndex == 5) || (nIndex == 9))
1811 : 0 : nIndex = 6;
1812 : : else
1813 : 0 : nIndex = 5;
1814 : : } // for nCol
1815 : : } // if not equal Column
1816 : : } // if not all equal
1817 : :
1818 [ # # ]: 0 : for (sal_uInt8 j = 0; j < 16; ++j)
1819 [ # # ][ # # ]: 0 : delete pPatternAttrs[j];
1820 : : } // if AutoFormatData != NULL
1821 : : } // if ValidColRow
1822 : 0 : }
1823 : :
1824 : 0 : void ScTable::GetAutoFormatAttr(SCCOL nCol, SCROW nRow, sal_uInt16 nIndex, ScAutoFormatData& rData)
1825 : : {
1826 [ # # ]: 0 : sal_uInt32 nFormatIndex = GetNumberFormat( nCol, nRow );
1827 [ # # ][ # # ]: 0 : ScNumFormatAbbrev aNumFormat( nFormatIndex, *pDocument->GetFormatTable() );
1828 [ # # ][ # # ]: 0 : rData.GetFromItemSet( nIndex, GetPattern( nCol, nRow )->GetItemSet(), aNumFormat );
[ # # ]
1829 : 0 : }
1830 : :
1831 : : #define LF_LEFT 1
1832 : : #define LF_TOP 2
1833 : : #define LF_RIGHT 4
1834 : : #define LF_BOTTOM 8
1835 : : #define LF_ALL (LF_LEFT | LF_TOP | LF_RIGHT | LF_BOTTOM)
1836 : :
1837 : 0 : void ScTable::GetAutoFormatFrame(SCCOL nCol, SCROW nRow, sal_uInt16 nFlags, sal_uInt16 nIndex, ScAutoFormatData& rData)
1838 : : {
1839 [ # # ]: 0 : const SvxBoxItem* pTheBox = (SvxBoxItem*)GetAttr(nCol, nRow, ATTR_BORDER);
1840 [ # # ]: 0 : const SvxBoxItem* pLeftBox = (SvxBoxItem*)GetAttr(nCol - 1, nRow, ATTR_BORDER);
1841 [ # # ]: 0 : const SvxBoxItem* pTopBox = (SvxBoxItem*)GetAttr(nCol, nRow - 1, ATTR_BORDER);
1842 [ # # ]: 0 : const SvxBoxItem* pRightBox = (SvxBoxItem*)GetAttr(nCol + 1, nRow, ATTR_BORDER);
1843 [ # # ]: 0 : const SvxBoxItem* pBottomBox = (SvxBoxItem*)GetAttr(nCol, nRow + 1, ATTR_BORDER);
1844 : :
1845 [ # # ]: 0 : SvxBoxItem aBox( ATTR_BORDER );
1846 [ # # ]: 0 : if (nFlags & LF_LEFT)
1847 : : {
1848 [ # # ]: 0 : if (pLeftBox)
1849 : : {
1850 [ # # ][ # # ]: 0 : if (ScHasPriority(pTheBox->GetLeft(), pLeftBox->GetRight()))
1851 [ # # ]: 0 : aBox.SetLine(pTheBox->GetLeft(), BOX_LINE_LEFT);
1852 : : else
1853 [ # # ]: 0 : aBox.SetLine(pLeftBox->GetRight(), BOX_LINE_LEFT);
1854 : : }
1855 : : else
1856 [ # # ]: 0 : aBox.SetLine(pTheBox->GetLeft(), BOX_LINE_LEFT);
1857 : : }
1858 [ # # ]: 0 : if (nFlags & LF_TOP)
1859 : : {
1860 [ # # ]: 0 : if (pTopBox)
1861 : : {
1862 [ # # ][ # # ]: 0 : if (ScHasPriority(pTheBox->GetTop(), pTopBox->GetBottom()))
1863 [ # # ]: 0 : aBox.SetLine(pTheBox->GetTop(), BOX_LINE_TOP);
1864 : : else
1865 [ # # ]: 0 : aBox.SetLine(pTopBox->GetBottom(), BOX_LINE_TOP);
1866 : : }
1867 : : else
1868 [ # # ]: 0 : aBox.SetLine(pTheBox->GetTop(), BOX_LINE_TOP);
1869 : : }
1870 [ # # ]: 0 : if (nFlags & LF_RIGHT)
1871 : : {
1872 [ # # ]: 0 : if (pRightBox)
1873 : : {
1874 [ # # ][ # # ]: 0 : if (ScHasPriority(pTheBox->GetRight(), pRightBox->GetLeft()))
1875 [ # # ]: 0 : aBox.SetLine(pTheBox->GetRight(), BOX_LINE_RIGHT);
1876 : : else
1877 [ # # ]: 0 : aBox.SetLine(pRightBox->GetLeft(), BOX_LINE_RIGHT);
1878 : : }
1879 : : else
1880 [ # # ]: 0 : aBox.SetLine(pTheBox->GetRight(), BOX_LINE_RIGHT);
1881 : : }
1882 [ # # ]: 0 : if (nFlags & LF_BOTTOM)
1883 : : {
1884 [ # # ]: 0 : if (pBottomBox)
1885 : : {
1886 [ # # ][ # # ]: 0 : if (ScHasPriority(pTheBox->GetBottom(), pBottomBox->GetTop()))
1887 [ # # ]: 0 : aBox.SetLine(pTheBox->GetBottom(), BOX_LINE_BOTTOM);
1888 : : else
1889 [ # # ]: 0 : aBox.SetLine(pBottomBox->GetTop(), BOX_LINE_BOTTOM);
1890 : : }
1891 : : else
1892 [ # # ]: 0 : aBox.SetLine(pTheBox->GetBottom(), BOX_LINE_BOTTOM);
1893 : : }
1894 [ # # ][ # # ]: 0 : rData.PutItem( nIndex, aBox );
1895 : 0 : }
1896 : :
1897 : 0 : void ScTable::GetAutoFormatData(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, ScAutoFormatData& rData)
1898 : : {
1899 [ # # ][ # # ]: 0 : if (ValidColRow(nStartCol, nStartRow) && ValidColRow(nEndCol, nEndRow))
[ # # ]
1900 : : {
1901 [ # # ][ # # ]: 0 : if ((nEndCol - nStartCol >= 3) && (nEndRow - nStartRow >= 3))
1902 : : {
1903 : : // Linke obere Ecke
1904 : 0 : GetAutoFormatAttr(nStartCol, nStartRow, 0, rData);
1905 : 0 : GetAutoFormatFrame(nStartCol, nStartRow, LF_ALL, 0, rData);
1906 : : // Linke Spalte
1907 : 0 : GetAutoFormatAttr(nStartCol, nStartRow + 1, 4, rData);
1908 : 0 : GetAutoFormatAttr(nStartCol, nStartRow + 2, 8, rData);
1909 : 0 : GetAutoFormatFrame(nStartCol, nStartRow + 1, LF_LEFT | LF_RIGHT | LF_BOTTOM, 4, rData);
1910 [ # # ]: 0 : if (nEndRow - nStartRow >= 4)
1911 : 0 : GetAutoFormatFrame(nStartCol, nStartRow + 2, LF_LEFT | LF_RIGHT | LF_BOTTOM, 8, rData);
1912 : : else
1913 : 0 : rData.CopyItem( 8, 4, ATTR_BORDER );
1914 : : // Linke untere Ecke
1915 : 0 : GetAutoFormatAttr(nStartCol, nEndRow, 12, rData);
1916 : 0 : GetAutoFormatFrame(nStartCol, nEndRow, LF_ALL, 12, rData);
1917 : : // Rechte obere Ecke
1918 : 0 : GetAutoFormatAttr(nEndCol, nStartRow, 3, rData);
1919 : 0 : GetAutoFormatFrame(nEndCol, nStartRow, LF_ALL, 3, rData);
1920 : : // Rechte Spalte
1921 : 0 : GetAutoFormatAttr(nEndCol, nStartRow + 1, 7, rData);
1922 : 0 : GetAutoFormatAttr(nEndCol, nStartRow + 2, 11, rData);
1923 : 0 : GetAutoFormatFrame(nEndCol, nStartRow + 1, LF_LEFT | LF_RIGHT | LF_BOTTOM, 7, rData);
1924 [ # # ]: 0 : if (nEndRow - nStartRow >= 4)
1925 : 0 : GetAutoFormatFrame(nEndCol, nStartRow + 2, LF_LEFT | LF_RIGHT | LF_BOTTOM, 11, rData);
1926 : : else
1927 : 0 : rData.CopyItem( 11, 7, ATTR_BORDER );
1928 : : // Rechte untere Ecke
1929 : 0 : GetAutoFormatAttr(nEndCol, nEndRow, 15, rData);
1930 : 0 : GetAutoFormatFrame(nEndCol, nEndRow, LF_ALL, 15, rData);
1931 : : // Ober Zeile
1932 : 0 : GetAutoFormatAttr(nStartCol + 1, nStartRow, 1, rData);
1933 : 0 : GetAutoFormatAttr(nStartCol + 2, nStartRow, 2, rData);
1934 : 0 : GetAutoFormatFrame(nStartCol + 1, nStartRow, LF_TOP | LF_BOTTOM | LF_RIGHT, 1, rData);
1935 [ # # ]: 0 : if (nEndCol - nStartCol >= 4)
1936 : 0 : GetAutoFormatFrame(nStartCol + 2, nStartRow, LF_TOP | LF_BOTTOM | LF_RIGHT, 2, rData);
1937 : : else
1938 : 0 : rData.CopyItem( 2, 1, ATTR_BORDER );
1939 : : // Untere Zeile
1940 : 0 : GetAutoFormatAttr(nStartCol + 1, nEndRow, 13, rData);
1941 : 0 : GetAutoFormatAttr(nStartCol + 2, nEndRow, 14, rData);
1942 : 0 : GetAutoFormatFrame(nStartCol + 1, nEndRow, LF_TOP | LF_BOTTOM | LF_RIGHT, 13, rData);
1943 [ # # ]: 0 : if (nEndCol - nStartCol >= 4)
1944 : 0 : GetAutoFormatFrame(nStartCol + 2, nEndRow, LF_TOP | LF_BOTTOM | LF_RIGHT, 14, rData);
1945 : : else
1946 : 0 : rData.CopyItem( 14, 13, ATTR_BORDER );
1947 : : // Body
1948 : 0 : GetAutoFormatAttr(nStartCol + 1, nStartRow + 1, 5, rData);
1949 : 0 : GetAutoFormatAttr(nStartCol + 2, nStartRow + 1, 6, rData);
1950 : 0 : GetAutoFormatAttr(nStartCol + 1, nStartRow + 2, 9, rData);
1951 : 0 : GetAutoFormatAttr(nStartCol + 2, nStartRow + 2, 10, rData);
1952 : 0 : GetAutoFormatFrame(nStartCol + 1, nStartRow + 1, LF_RIGHT | LF_BOTTOM, 5, rData);
1953 [ # # ][ # # ]: 0 : if ((nEndCol - nStartCol >= 4) && (nEndRow - nStartRow >= 4))
1954 : : {
1955 : 0 : GetAutoFormatFrame(nStartCol + 2, nStartRow + 1, LF_RIGHT | LF_BOTTOM, 6, rData);
1956 : 0 : GetAutoFormatFrame(nStartCol + 1, nStartRow + 2, LF_RIGHT | LF_BOTTOM, 9, rData);
1957 : 0 : GetAutoFormatFrame(nStartCol + 2, nStartRow + 2, LF_RIGHT | LF_BOTTOM, 10, rData);
1958 : : }
1959 : : else
1960 : : {
1961 : 0 : rData.CopyItem( 6, 5, ATTR_BORDER );
1962 : 0 : rData.CopyItem( 9, 5, ATTR_BORDER );
1963 : 0 : rData.CopyItem( 10, 5, ATTR_BORDER );
1964 : : }
1965 : : }
1966 : : }
1967 : 0 : }
1968 : :
1969 : 0 : void ScTable::SetError( SCCOL nCol, SCROW nRow, sal_uInt16 nError)
1970 : : {
1971 [ # # ]: 0 : if (ValidColRow(nCol, nRow))
1972 : 0 : aCol[nCol].SetError( nRow, nError );
1973 : 0 : }
1974 : :
1975 : 10 : void ScTable::UpdateInsertTabAbs(SCTAB nTable)
1976 : : {
1977 [ + + ]: 10250 : for (SCCOL i=0; i <= MAXCOL; i++)
1978 : 10240 : aCol[i].UpdateInsertTabAbs(nTable);
1979 : 10 : }
1980 : :
1981 : 0 : bool ScTable::GetNextSpellingCell(SCCOL& rCol, SCROW& rRow, bool bInSel,
1982 : : const ScMarkData& rMark) const
1983 : : {
1984 [ # # ]: 0 : if (rRow == MAXROW+2) // Tabellenende
1985 : : {
1986 : 0 : rRow = 0;
1987 : 0 : rCol = 0;
1988 : : }
1989 : : else
1990 : : {
1991 : 0 : rRow++;
1992 [ # # ]: 0 : if (rRow == MAXROW+1)
1993 : : {
1994 : 0 : rCol++;
1995 : 0 : rRow = 0;
1996 : : }
1997 : : }
1998 [ # # ]: 0 : if (rCol == MAXCOL+1)
1999 : 0 : return true;
2000 : : else
2001 : : {
2002 : 0 : bool bStop = false;
2003 [ # # ]: 0 : while (!bStop)
2004 : : {
2005 [ # # ]: 0 : if (ValidCol(rCol))
2006 : : {
2007 : 0 : bStop = aCol[rCol].GetNextSpellingCell(rRow, bInSel, rMark);
2008 [ # # ]: 0 : if (bStop)
2009 : 0 : return true;
2010 : : else /*if (rRow == MAXROW+1) */
2011 : : {
2012 : 0 : rCol++;
2013 : 0 : rRow = 0;
2014 : : }
2015 : : }
2016 : : else
2017 : 0 : return true;
2018 : : }
2019 : : }
2020 : 0 : return false;
2021 : : }
2022 : :
2023 : 0 : void ScTable::RemoveAutoSpellObj()
2024 : : {
2025 [ # # ]: 0 : for (SCCOL i=0; i <= MAXCOL; i++)
2026 : 0 : aCol[i].RemoveAutoSpellObj();
2027 : 0 : }
2028 : :
2029 : 2 : bool ScTable::TestTabRefAbs(SCTAB nTable) const
2030 : : {
2031 [ + - ]: 8 : for (SCCOL i=0; i <= MAXCOL; i++)
2032 [ + + ]: 8 : if (aCol[i].TestTabRefAbs(nTable))
2033 : 2 : return true;
2034 : 2 : return false;
2035 : : }
2036 : :
2037 : 16 : void ScTable::CompileDBFormula()
2038 : : {
2039 [ + + ]: 16400 : for (SCCOL i=0; i<=MAXCOL; i++) aCol[i].CompileDBFormula();
2040 : 16 : }
2041 : :
2042 : 10 : void ScTable::CompileDBFormula( bool bCreateFormulaString )
2043 : : {
2044 [ + + ]: 10250 : for (SCCOL i=0; i<=MAXCOL; i++) aCol[i].CompileDBFormula( bCreateFormulaString );
2045 : 10 : }
2046 : :
2047 : 234 : void ScTable::CompileNameFormula( bool bCreateFormulaString )
2048 : : {
2049 [ + + ]: 239850 : for (SCCOL i=0; i<=MAXCOL; i++) aCol[i].CompileNameFormula( bCreateFormulaString );
2050 : 234 : }
2051 : :
2052 : 7 : void ScTable::CompileColRowNameFormula()
2053 : : {
2054 [ + + ]: 7175 : for (SCCOL i=0; i<=MAXCOL; i++) aCol[i].CompileColRowNameFormula();
2055 : 7 : }
2056 : :
2057 : :
2058 : :
2059 : :
2060 : :
2061 : :
2062 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|